1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Install, update, and uninstall functions for Language Icons.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
/**
|
8 |
|
|
* Implements hook_install().
|
9 |
|
|
*/
|
10 |
|
|
function languageicons_install() {
|
11 |
|
|
// Convert old "i18n_icon_*" variables, if any.
|
12 |
|
|
_languageicons_convert_i18n_icon_variables();
|
13 |
|
|
}
|
14 |
|
|
|
15 |
|
|
/**
|
16 |
|
|
* Implements hook_uninstall().
|
17 |
|
|
*/
|
18 |
|
|
function languageicons_uninstall() {
|
19 |
|
|
// Clear any variables that might be in use
|
20 |
|
|
$variables = array(
|
21 |
|
|
'languageicons_show_node',
|
22 |
|
|
'languageicons_show_block',
|
23 |
|
|
'languageicons_placement',
|
24 |
|
|
'languageicons_path',
|
25 |
|
|
'languageicons_size',
|
26 |
|
|
'languageicons_show_tooltip',
|
27 |
|
|
);
|
28 |
|
|
foreach ($variables as $variable) {
|
29 |
|
|
variable_del($variable);
|
30 |
|
|
}
|
31 |
|
|
}
|
32 |
|
|
|
33 |
|
|
/**
|
34 |
|
|
* Private helper to convert i18n_icon_* variables.
|
35 |
|
|
*
|
36 |
|
|
* @see languageicons_install()
|
37 |
|
|
* @see languageicons_update_6000()
|
38 |
|
|
*/
|
39 |
|
|
function _languageicons_convert_i18n_icon_variables() {
|
40 |
|
|
$variables = array('path', 'size');
|
41 |
|
|
foreach ($variables as $variable) {
|
42 |
|
|
$old_variable = 'i18n_icon_' . $variable;
|
43 |
|
|
$new_variable = 'languageicons_' . $variable;
|
44 |
|
|
if (variable_get($new_variable) === NULL) {
|
45 |
|
|
$old_variable_value = variable_get($old_variable, NULL);
|
46 |
|
|
// If the standard path for flag icons was used, reset it.
|
47 |
|
|
if ($variable == 'path') {
|
48 |
|
|
$old_default_path = drupal_get_path('module', 'i18n') . '/flags/*.png';
|
49 |
|
|
if ($old_variable_value == $old_default_path) {
|
50 |
|
|
unset($old_variable_value, $old_default_path);
|
51 |
|
|
}
|
52 |
|
|
}
|
53 |
|
|
if (!empty($old_variable_value)) {
|
54 |
|
|
variable_set($new_variable, $old_variable_value);
|
55 |
|
|
}
|
56 |
|
|
}
|
57 |
|
|
variable_del($old_variable);
|
58 |
|
|
}
|
59 |
|
|
}
|
60 |
|
|
|
61 |
|
|
/**
|
62 |
|
|
* Convert old "i18n_icon_*" variables.
|
63 |
|
|
*/
|
64 |
|
|
function languageicons_update_6000() {
|
65 |
|
|
_languageicons_convert_i18n_icon_variables();
|
66 |
|
|
return t('Converted Internationalization (i18n) module settings to Language icons settings.');
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
/**
|
70 |
|
|
* Remove variable used for a short time during development of 6.x-2.x.
|
71 |
|
|
*
|
72 |
|
|
* @todo Remove this after the release of 7.x-1.0.
|
73 |
|
|
*/
|
74 |
|
|
function languageicons_update_6200() {
|
75 |
|
|
variable_del('languageicons_show_tooltip');
|
76 |
|
|
return t('Removed site variable used during development of 6.x-2.x.');
|
77 |
|
|
} |