1 |
1939
|
darkviper
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
4 |
|
|
*
|
5 |
|
|
* This program is free software: you can redistribute it and/or modify
|
6 |
|
|
* it under the terms of the GNU General Public License as published by
|
7 |
|
|
* the Free Software Foundation, either version 3 of the License, or
|
8 |
|
|
* (at your option) any later version.
|
9 |
|
|
*
|
10 |
|
|
* This program is distributed in the hope that it will be useful,
|
11 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
|
|
* GNU General Public License for more details.
|
14 |
|
|
*
|
15 |
|
|
* You should have received a copy of the GNU General Public License
|
16 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17 |
|
|
*/
|
18 |
|
|
|
19 |
|
|
/**
|
20 |
|
|
* uprade.php
|
21 |
|
|
*
|
22 |
|
|
* @category Modules
|
23 |
|
|
* @package Modules_MultiLingual
|
24 |
|
|
* @author Werner v.d.Decken <wkl@isteam.de>
|
25 |
|
|
* @author Dietmar Wöllbrink <dietmar.woellbrink@websiteBaker.org>
|
26 |
|
|
* @copyright Werner v.d.Decken <wkl@isteam.de>
|
27 |
|
|
* @license http://www.gnu.org/licenses/gpl.html GPL License
|
28 |
|
|
* @version 1.6.8
|
29 |
|
|
* @revision $Revision: $
|
30 |
|
|
* @link $HeadURL: $
|
31 |
|
|
* @lastmodified $Date: $
|
32 |
|
|
* @since File available since 09.01.2013
|
33 |
|
|
* @description provides a flexible posibility for changeing to a translated page
|
34 |
|
|
*/
|
35 |
|
|
|
36 |
|
|
/* -------------------------------------------------------- */
|
37 |
|
|
// Must include code to stop this file being accessed directly
|
38 |
|
|
if(!defined('WB_URL')) {
|
39 |
|
|
require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
|
40 |
|
|
throw new IllegalFileException();
|
41 |
|
|
}
|
42 |
|
|
/* -------------------------------------------------------- */
|
43 |
|
|
|
44 |
|
|
// Work-out if we should check for existing page_code
|
45 |
|
|
$sql = 'DESCRIBE `'.$database->TablePrefix.'pages` `page_code`';
|
46 |
|
|
$field_sql = $database->query($sql);
|
47 |
|
|
$field_set = $field_sql->numRows();
|
48 |
|
|
$format = $field_sql->fetchRow(MYSQL_ASSOC) ;
|
49 |
|
|
// upgrade only if old format
|
50 |
|
|
if($format['Type'] == 'varchar(255)' )
|
51 |
|
|
{
|
52 |
|
|
$sql = 'SELECT `page_code`,`page_id` FROM `'.$database->TablePrefix.'pages` ORDER BY `page_id`';
|
53 |
|
|
if($query_code = $database->query($sql))
|
54 |
|
|
{
|
55 |
|
|
// extract page_id from old format
|
56 |
|
|
$pattern = '/(?<=_)([0-9]{1,11})/s';
|
57 |
|
|
while( $page = $query_code->fetchRow(MYSQL_ASSOC))
|
58 |
|
|
{
|
59 |
|
|
preg_match($pattern, $page['page_code'], $array);
|
60 |
|
|
$page_code = $array[0];
|
61 |
|
|
$page_id = $page['page_id'];
|
62 |
|
|
$sql = 'UPDATE `'.$database->TablePrefix.'pages` SET ';
|
63 |
|
|
$sql .= ((empty($array[0])) ? '`page_code` = 0 ' : '`page_code` = '.$page_code.' ');
|
64 |
|
|
$sql .= 'WHERE `page_id` = '.$page_id;
|
65 |
|
|
$database->query($sql);
|
66 |
|
|
}
|
67 |
|
|
$field_set = $database->field_modify('page_code', 'pages', 'INT(11) NOT NULL AFTER `modified_by`');
|
68 |
|
|
// $sql = 'ALTER TABLE `'.$database->TablePrefix.'pages` MODIFY COLUMN `page_code` INT(11) NOT NULL';
|
69 |
|
|
// $database->query($sql);
|
70 |
|
|
}
|
71 |
|
|
}
|
72 |
|
|
//
|
73 |
|
|
$directory = dirname(__FILE__).'/'.'info.php';
|
74 |
|
|
// update entry in table addons to new version
|
75 |
|
|
load_module($directory, $install = false);
|