You are here

function _languageicons_convert_i18n_icon_variables in Language Icons 6.2

Same name and namespace in other branches
  1. 6 languageicons.install \_languageicons_convert_i18n_icon_variables()
  2. 7 languageicons.install \_languageicons_convert_i18n_icon_variables()

Private helper to convert i18n_icon_* variables.

See also

languageicons_install()

languageicons_update_6000()

2 calls to _languageicons_convert_i18n_icon_variables()
languageicons_install in ./languageicons.install
Implementation of hook_install().
languageicons_update_6000 in ./languageicons.install
Convert old "i18n_icon_*" variables.

File

./languageicons.install, line 39
Install, update, and uninstall functions for Language Icons.

Code

function _languageicons_convert_i18n_icon_variables() {
  $variables = array(
    'path',
    'size',
  );
  foreach ($variables as $variable) {
    $old_variable = 'i18n_icon_' . $variable;
    $new_variable = 'languageicons_' . $variable;
    if (variable_get($new_variable, NULL) === NULL) {
      $old_variable_value = variable_get($old_variable, NULL);

      // If the standard path for flag icons was used, reset it.
      if ($variable == 'path') {
        $old_default_path = drupal_get_path('module', 'i18n') . '/flags/*.png';
        if ($old_variable_value == $old_default_path) {
          unset($old_variable_value, $old_default_path);
        }
      }
      if (!empty($old_variable_value)) {
        variable_set($new_variable, $old_variable_value);
      }
    }
    variable_del($old_variable);
  }
}