1 <?php |
1 <?php |
2 |
2 |
3 function MIGRATE() |
3 function MIGRATE() |
4 { |
4 { |
5 global $languages; |
5 global $languages; |
6 global $db, $dbdriver; |
6 global $db, $dbdriver; |
7 |
7 |
8 // Database upgrade |
8 // Database upgrade |
9 try |
9 try |
10 { |
10 { |
11 $sql_parser = new SQL_Parser('install/schemas/upgrade/migration/1.0-1.1-' . $dbdriver . '.sql'); |
11 $sql_parser = new SQL_Parser('install/schemas/upgrade/migration/1.0-1.1-' . $dbdriver . '.sql'); |
12 } |
12 } |
13 catch ( Exception $e ) |
13 catch ( Exception $e ) |
14 { |
14 { |
15 die("<pre>$e</pre>"); |
15 die("<pre>$e</pre>"); |
16 } |
16 } |
17 |
17 |
18 $sql_parser->assign_vars(array( |
18 $sql_parser->assign_vars(array( |
19 'TABLE_PREFIX' => table_prefix |
19 'TABLE_PREFIX' => table_prefix |
20 )); |
20 )); |
21 |
21 |
22 $sql_list = $sql_parser->parse(); |
22 $sql_list = $sql_parser->parse(); |
23 foreach ( $sql_list as $sql ) |
23 foreach ( $sql_list as $sql ) |
24 { |
24 { |
25 if ( !$db->sql_query($sql) ) |
25 if ( !$db->sql_query($sql) ) |
26 $db->_die(); |
26 $db->_die(); |
27 } |
27 } |
28 |
28 |
29 // Install default language |
29 // Install default language |
30 $lang_id = 'eng'; |
30 $lang_id = 'eng'; |
31 $lang_data =& $languages[$lang_id]; |
31 $lang_data =& $languages[$lang_id]; |
32 $lang_dir = ENANO_ROOT . "/language/{$lang_data['dir']}/"; |
32 $lang_dir = ENANO_ROOT . "/language/{$lang_data['dir']}/"; |
33 // function install_language($lang_code, $lang_name_neutral, $lang_name_local, $lang_file = false) |
33 // function install_language($lang_code, $lang_name_neutral, $lang_name_local, $lang_file = false) |
34 install_language($lang_id, $lang_data['name_eng'], false); |
34 install_language($lang_id, $lang_data['name_eng'], false); |
35 |
35 |
36 // Only import strings if the script isn't planning to do it again later |
36 // Only import strings if the script isn't planning to do it again later |
37 global $do_langimport; |
37 global $do_langimport; |
38 if ( !$do_langimport ) |
38 if ( !$do_langimport ) |
39 { |
39 { |
40 $lang_local = new Language($lang_id); |
40 $lang_local = new Language($lang_id); |
41 $lang_local->import($lang_dir . "core.json"); |
41 $lang_local->import($lang_dir . "core.json"); |
42 $lang_local->import($lang_dir . "tools.json"); |
42 $lang_local->import($lang_dir . "tools.json"); |
43 $lang_local->import($lang_dir . "user.json"); |
43 $lang_local->import($lang_dir . "user.json"); |
44 $lang_local->import($lang_dir . "admin.json"); |
44 $lang_local->import($lang_dir . "admin.json"); |
45 } |
45 } |
46 |
46 |
47 // This doesn't set to installer_enano_version() because it only |
47 // This doesn't set to installer_enano_version() because it only |
48 // migrates the database from 1.0.x to 1.1.x status and runs the |
48 // migrates the database from 1.0.x to 1.1.x status and runs the |
49 // core logic required to transform a 1.0.x installation into |
49 // core logic required to transform a 1.0.x installation into |
50 // a 1.1.x installation. Thus, when upgrading, the upgrade script |
50 // a 1.1.x installation. Thus, when upgrading, the upgrade script |
51 // still needs to run all later upgrade schema files in addition |
51 // still needs to run all later upgrade schema files in addition |
52 // to this migration code. |
52 // to this migration code. |
53 setConfig('enano_version', '1.1.1'); |
53 setConfig('enano_version', '1.1.1'); |
54 |
54 |
55 return true; |
55 return true; |
56 } |
56 } |
57 |
57 |