Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @category        modules
5
 * @package         wysiwyg
6
 * @author          WebsiteBaker Project
7
 * @copyright       2009-2012, Website Baker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
9
 * @license         http://www.gnu.org/licenses/gpl.html
10
 * @platform        WebsiteBaker 2.8.3
11
 * @requirements    PHP 5.2.2 and higher
12
 * @version      	$Id: upgrade.php 1765 2012-09-22 20:06:49Z Luisehahne $
13
 * @filesource		$HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/wysiwyg/upgrade.php $
14
 * @lastmodified    $Date: 2012-09-22 22:06:49 +0200 (Sat, 22 Sep 2012) $
15
 *
16
 */
17
/* -------------------------------------------------------- */
18
// Must include code to stop this file being accessed directly
19
if(!defined('WB_PATH')) {
20
	require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
21
	throw new IllegalFileException();
22
}
23
/* -------------------------------------------------------- */
24

    
25
if(!function_exists('mod_wysiwyg_upgrade'))
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;
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
        }
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
        }
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
        }
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
    }
85
}
86
// ------------------------------------
87

    
88
$msg = mod_wysiwyg_upgrade();
(9-9/10)