You are here

function i18n_variable_form_submit in Internationalization 6

Same name and namespace in other branches
  1. 5.3 i18n.module \i18n_variable_form_submit()
  2. 5 i18n.module \i18n_variable_form_submit()
  3. 5.2 i18n.module \i18n_variable_form_submit()

Save multilingual variables and remove them from form.

1 string reference to 'i18n_variable_form_submit'
i18n_form_alter in ./i18n.module
Implementation of hook_form_alter();

File

./i18n.module, line 685
Internationalization (i18n) module.

Code

function i18n_variable_form_submit($form, &$form_state) {
  $op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
  $variables = i18n_variable();
  $language = i18n_get_lang();
  $is_default = $language == language_default('language');
  foreach ($form_state['values'] as $key => $value) {
    if (i18n_variable($key)) {
      if ($op == t('Reset to defaults')) {
        i18n_variable_del($key, $language);
      }
      else {
        if (is_array($value) && isset($form_state['values']['array_filter'])) {
          $value = array_keys(array_filter($value));
        }
        i18n_variable_set($key, $value, $language);
      }

      // If current is default language, we allow global (without language) variables to be set too
      if (!$is_default) {
        unset($form_state['values'][$key]);
      }
    }
  }

  // The form will go now through system_settings_form_submit()
}