1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Installation file for Internationalization (i18n) module.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Implements hook_install().
|
10
|
*/
|
11
|
function i18n_variable_install() {
|
12
|
// Set module weight for it to run before most modules, but after variable_realm
|
13
|
db_query("UPDATE {system} SET weight = -900 WHERE name = 'i18n_variable' AND type = 'module'");
|
14
|
// Update from d6, module changed name
|
15
|
if (variable_get('i18n_drupal6_update')) {
|
16
|
i18n_variable_update_7000();
|
17
|
i18n_variable_update_7001();
|
18
|
i18n_variable_update_7002();
|
19
|
}
|
20
|
// Set some minimum variables to be translated.
|
21
|
variable_set('variable_realm_list_language', array('site_name', 'site_slogan'));
|
22
|
}
|
23
|
|
24
|
/**
|
25
|
* Implements hook_install().
|
26
|
*/
|
27
|
function i18n_variable_uninstall() {
|
28
|
if (drupal_load('module', 'variable_store')) {
|
29
|
// Delete all our variables from store.
|
30
|
variable_store_delete_all('language', NULL);
|
31
|
}
|
32
|
}
|
33
|
|
34
|
/**
|
35
|
* Update multilingual variables variable name
|
36
|
*/
|
37
|
function i18n_variable_update_7000() {
|
38
|
variable_set('i18n_variable_list', variable_get('i18n_variables', array()));
|
39
|
variable_set('i18n_variable_conf', variable_get('i18n_variables', array()));
|
40
|
variable_del('i18n_variables');
|
41
|
}
|
42
|
|
43
|
/**
|
44
|
* Move variables from old storage to new table
|
45
|
*/
|
46
|
function i18n_variable_update_7001() {
|
47
|
drupal_load('module', 'variable_store');
|
48
|
foreach (db_select('i18n_variable', 'v')->fields('v')->execute()->fetchAll() as $variable) {
|
49
|
variable_store_set('language', $variable->language, $variable->name, unserialize($variable->value));
|
50
|
}
|
51
|
}
|
52
|
|
53
|
/**
|
54
|
* Drop i18n_variable table if exists
|
55
|
*/
|
56
|
function i18n_variable_update_7002() {
|
57
|
if (db_table_exists('i18n_variable')) {
|
58
|
db_drop_table('i18n_variable');
|
59
|
}
|
60
|
}
|
61
|
|
62
|
/**
|
63
|
* Update list of realm variables.
|
64
|
*/
|
65
|
function i18n_variable_update_7003() {
|
66
|
drupal_load('module', 'variable_store');
|
67
|
$variable_list = variable_get('i18n_variable_conf', array());
|
68
|
variable_set('variable_realm_list_language', $variable_list);
|
69
|
// Delete old variables from store that are not in the list.
|
70
|
$old_variables = array_diff(variable_store_list_all('language'), variable_children($variable_list));
|
71
|
foreach ($old_variables as $name) {
|
72
|
variable_store_delete_all('language', NULL, $name);
|
73
|
}
|
74
|
}
|
75
|
|
76
|
/**
|
77
|
* Delete obsoleted variable realm variables.
|
78
|
*/
|
79
|
function i18n_variable_update_7004() {
|
80
|
variable_del('i18n_variable_conf');
|
81
|
variable_del('i18n_variable_list');
|
82
|
}
|
83
|
|