You are here

function locale_languages_configure_form_submit in Drupal 7

Same name and namespace in other branches
  1. 6 includes/locale.inc \locale_languages_configure_form_submit()

Submit handler for language negotiation settings.

Related topics

1 string reference to 'locale_languages_configure_form_submit'
locale_languages_configure_form in modules/locale/locale.admin.inc
Setting for language negotiation options

File

modules/locale/locale.admin.inc, line 675
Administration functions for locale.module.

Code

function locale_languages_configure_form_submit($form, &$form_state) {
  $configurable_types = $form['#language_types'];
  foreach ($configurable_types as $type) {
    $negotiation = array();
    $enabled_providers = $form_state['values'][$type]['enabled'];
    $enabled_providers[LANGUAGE_NEGOTIATION_DEFAULT] = TRUE;
    $providers_weight = $form_state['values'][$type]['weight'];
    foreach ($providers_weight as $id => $weight) {
      if ($enabled_providers[$id]) {
        $provider = $form[$type]['#language_providers'][$id];
        $provider['weight'] = $weight;
        $negotiation[$id] = $provider;
      }
    }
    language_negotiation_set($type, $negotiation);
    variable_set("locale_language_providers_weight_{$type}", $providers_weight);
  }

  // Update non-configurable language types and the related language negotiation
  // configuration.
  language_types_set();
  $form_state['redirect'] = 'admin/config/regional/language/configure';
  drupal_set_message(t('Language negotiation configuration saved.'));
}