function lingotek_admin_language_switcher_form_submit in Lingotek Translation 7.4
Same name and namespace in other branches
- 7.7 lingotek.admin.inc \lingotek_admin_language_switcher_form_submit()
- 7.3 lingotek.admin.inc \lingotek_admin_language_switcher_form_submit()
- 7.5 lingotek.admin.inc \lingotek_admin_language_switcher_form_submit()
- 7.6 lingotek.admin.inc \lingotek_admin_language_switcher_form_submit()
2 calls to lingotek_admin_language_switcher_form_submit()
File
- ./
lingotek.admin.inc, line 2009
Code
function lingotek_admin_language_switcher_form_submit($form, $form_state) {
$block = array(
'status' => $form_state['values']['enabled'],
'weight' => 0,
'region' => $form_state['values']['region'],
'module' => 'locale',
'delta' => 'language',
'theme' => $form_state['values']['theme'],
);
db_update('block')
->fields(array(
'status' => $block['status'],
'weight' => $block['weight'],
'region' => $block['region'],
))
->condition('module', $block['module'])
->condition('delta', $block['delta'])
->condition('theme', $block['theme'])
->execute();
//If the site does not yet have more than 1 language, drupal doesn't bootstrap
//some language functions. So here we force this file to be loaded.
include_once DRUPAL_ROOT . '/includes/language.inc';
//The array variable 'language_negotiation_language' has a entry for each detection method.
//Thus if the max is 1 the only possible enabled method is default.
//Note that the variable is empty on a new drupal install.
if ($form_state['values']['enabled'] && count(variable_get('language_negotiation_language')) <= 1) {
$types = array(
LOCALE_LANGUAGE_NEGOTIATION_URL => 2,
LOCALE_LANGUAGE_NEGOTIATION_BROWSER => 4,
);
language_negotiation_set(LANGUAGE_TYPE_INTERFACE, $types);
}
if (isset($form_state['values']['lingotek_navbar_switcher'])) {
variable_set('lingotek_navbar_switcher', $form_state['values']['lingotek_navbar_switcher']);
}
// Flush cache
cache_clear_all();
$action = $form_state['values']['enabled'] ? t('now enabled') : t('not enabled');
$message_type = $form_state['values']['enabled'] ? 'status' : 'warning';
drupal_set_message(t('The default language switcher is @action.', array(
'@action' => $action,
)), $message_type);
}