| 1 |
<?php
|
| 2 |
// $Id: languageicons.install,v 1.1.2.2 2008/08/19 17:40:25 freso Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Install, update, and uninstall functions for Language Icons.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_install().
|
| 11 |
*/
|
| 12 |
function languageicons_install() {
|
| 13 |
// Convert old "i18n_icon_*" variables, if any.
|
| 14 |
_languageicons_convert_i18n_icon_variables();
|
| 15 |
}
|
| 16 |
|
| 17 |
/**
|
| 18 |
* Implementation of hook_uninstall().
|
| 19 |
*/
|
| 20 |
function languageicons_uninstall() {
|
| 21 |
// Clear any variables that might be in use
|
| 22 |
$variables = array(
|
| 23 |
'languageicons_show_node',
|
| 24 |
'languageicons_show_block',
|
| 25 |
'languageicons_placement',
|
| 26 |
'languageicons_path',
|
| 27 |
'languageicons_size',
|
| 28 |
);
|
| 29 |
foreach ($variables as $variable) {
|
| 30 |
variable_del($variable);
|
| 31 |
}
|
| 32 |
}
|
| 33 |
|
| 34 |
/**
|
| 35 |
* Private helper to convert i18n_icon_* variables.
|
| 36 |
*
|
| 37 |
* @see languageicons_install()
|
| 38 |
* @see languageicons_update_6000()
|
| 39 |
*/
|
| 40 |
function _languageicons_convert_i18n_icon_variables() {
|
| 41 |
$variables = array('path', 'size');
|
| 42 |
foreach ($variables as $variable) {
|
| 43 |
$old_variable = 'i18n_icon_'. $variable;
|
| 44 |
$new_variable = 'languageicons_'. $variable;
|
| 45 |
if (variable_get($new_variable, NULL) === NULL) {
|
| 46 |
$old_variable_value = variable_get($old_variable, NULL);
|
| 47 |
// If the standard path for flag icons was used, reset it.
|
| 48 |
if ($variable == 'path') {
|
| 49 |
$old_default_path = drupal_get_path('module', 'i18n') .'/flags/*.png';
|
| 50 |
if ($old_variable_value == $old_default_path) {
|
| 51 |
unset($old_variable_value, $old_default_path);
|
| 52 |
}
|
| 53 |
}
|
| 54 |
if (!empty($old_variable_value)) {
|
| 55 |
variable_set($new_variable, $old_variable_value);
|
| 56 |
}
|
| 57 |
}
|
| 58 |
variable_del($old_variable);
|
| 59 |
}
|
| 60 |
}
|
| 61 |
|
| 62 |
/**
|
| 63 |
* Convert old "i18n_icon_*" variables.
|
| 64 |
*/
|
| 65 |
function languageicons_update_6000() {
|
| 66 |
_languageicons_convert_i18n_icon_variables();
|
| 67 |
return array();
|
| 68 |
}
|