Project

General

Profile

« Previous | Next » 

Revision 1875

Added by Dietmar over 11 years ago

! wysgwyg, now check exitings table entries, otherwise script stop loading content in editor
! typofix in groups
! change constant DB_NAME to $database->DbName

View differences:

upgrade.php
24 24

  
25 25
if(!function_exists('mod_wysiwyg_upgrade'))
26 26
{
27
    function mod_wysiwyg_upgrade () {
28
        global $database,$bDebugModus;
29
        $callingScript = $_SERVER["SCRIPT_NAME"];
30
        // check if upgrade startet by upgrade-script to echo a message
31
        $tmp = 'upgrade-script.php';
32
        $globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0;
27
	function mod_wysiwyg_upgrade () {
28
		global $database,$bDebugModus;
29
		$callingScript = $_SERVER["SCRIPT_NAME"];
30
		// check if upgrade startet by upgrade-script to echo a message
31
		$tmp = 'upgrade-script.php';
32
		$globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0;
33 33

  
34
        $msg = array();
35
        $aTable = array('mod_wysiwyg');
36
        for($x=0; $x<sizeof($aTable);$x++) {
37
        	if(($sOldType = $database->getTableEngine(TABLE_PREFIX.$aTable[$x]))) {
38
        		if(('myisam' != strtolower($sOldType))) {
39
        			if(!$database->query('ALTER TABLE `'.TABLE_PREFIX.$aTable[$x].'` Engine = \'MyISAM\' ')) {
40
        				$msg[] = $database->get_error();
41
        			} else{
42
                        $msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` changed to Engine = \'MyISAM\'';
43
        			}
44
        		} else {
45
                 $msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` has Engine = \'MyISAM\'';
46
        		}
47
        	} else {
48
        		$msg[] = $database->get_error();
49
        	}
50
        }
34
		$msg = array();
35
		$aTable = array('mod_wysiwyg');
36
		for($x=0; $x<sizeof($aTable);$x++) {
37
			if(($sOldType = $database->getTableEngine(TABLE_PREFIX.$aTable[$x]))) {
38
				if(('myisam' != strtolower($sOldType))) {
39
					if(!$database->query('ALTER TABLE `'.TABLE_PREFIX.$aTable[$x].'` Engine = \'MyISAM\' ')) {
40
						$msg[] = $database->get_error();
41
					} else{
42
						$msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` changed to Engine = \'MyISAM\'';
43
					}
44
				} else {
45
					 $msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` has Engine = \'MyISAM\'';
46
				}
47
			} else {
48
				$msg[] = $database->get_error();
49
			}
50
		}
51 51

  
52
        $sTable = TABLE_PREFIX.'mod_wysiwyg';
53
        if($database->index_exists($sTable, 'PRIMARY')) {
54
            $sql = 'ALTER TABLE `'.DB_NAME.'`.`'.$sTable.'` DROP PRIMARY KEY';
55
            if(!$database->query($sql)) {
56
                $msg[] = ''.$database->get_error().'';
57
            }
58
        }
52
		$sTable = TABLE_PREFIX.'mod_wysiwyg';
53
		if($database->index_exists($sTable, 'PRIMARY')) {
54
			$sql = 'ALTER TABLE `'.$database->DbName.'`.`'.$sTable.'` DROP PRIMARY KEY';
55
			if(!$database->query($sql)) {
56
			    $msg[] = ''.$database->get_error().'';
57
			}
58
		}
59 59

  
60
        if(!$database->index_add($sTable, '', 'section_id', 'PRIMARY')) {
61
        	$msg[] = ''.$database->get_error().'';
62
        } else {
63
            $msg[] = 'Create PRIMARY KEY ( `section_id` )';
64
        }
60
		if(!$database->index_add($sTable, '', 'section_id', 'PRIMARY')) {
61
			$msg[] = ''.$database->get_error().'';
62
		} else {
63
		    $msg[] = 'Create PRIMARY KEY ( `section_id` )';
64
		}
65 65

  
66
        // change internal absolute links into relative links
67
        $sTable = TABLE_PREFIX.'mod_wysiwyg';
68
        $sql  = 'UPDATE `'.$sTable.'` ';
69
        $sql .= 'SET `content` = REPLACE(`content`, \'"'.WB_URL.MEDIA_DIRECTORY.'\', \'"{SYSVAR:MEDIA_REL}\')';
70
        if (!$database->query($sql)) {
71
        	$msg[] = ''.$database->get_error().'';
72
        } else {
73
            $msg[] = 'Change internal absolute links into relative links';
74
        }
75
        // only for upgrade-script
76
        if($globalStarted) {
77
            if($bDebugModus) {
78
                foreach($msg as $title) {
79
                    echo '<strong>'.$title.'</strong><br />';
80
                }
81
            }
82
        }
83
        return $msg;
84
    }
66
		// change internal absolute links into relative links
67
		$sTable = TABLE_PREFIX.'mod_wysiwyg';
68
		$sql  = 'UPDATE `'.$sTable.'` ';
69
		$sql .= 'SET `content` = REPLACE(`content`, \'"'.WB_URL.MEDIA_DIRECTORY.'\', \'"{SYSVAR:MEDIA_REL}\')';
70
		if (!$database->query($sql)) {
71
			$msg[] = ''.$database->get_error().'';
72
		} else {
73
		    $msg[] = 'Change internal absolute links into relative links';
74
		}
75
		// only for $callingScript upgrade-script.php
76
		if($globalStarted) {
77
			if($bDebugModus) {
78
				foreach($msg as $title) {
79
				    echo '<strong>'.$title.'</strong><br />';
80
				}
81
			}
82
		}
83
		return $msg;
84
	}
85 85
}
86 86
// ------------------------------------
87 87

  

Also available in: Unified diff