function i18n_path_admin_form_submit in Internationalization 7
Process form submission
File
- i18n_path/
i18n_path.admin.inc, line 89 - Administration pages for path translation.
Code
function i18n_path_admin_form_submit($form, &$form_state) {
$translation_set = $form_state['values']['translation_set'];
switch ($form_state['triggering_element']['#name']) {
case 'save':
$paths = array_filter($form_state['values']['translations']);
$translation_set = $translation_set ? $translation_set : i18n_translation_set_create('path');
$translation_set->title = '';
$translations = $translation_set
->get_translations();
foreach ($paths as $lang => $path) {
if (isset($translations[$lang])) {
$translations[$lang]->path = $path;
}
else {
$translation_set
->add_item($path, $lang);
}
}
foreach (array_diff(array_keys($translation_set
->get_translations()), array_keys($paths)) as $language) {
$translation_set
->remove_language($language);
unset($translations[$language]);
}
if (!empty($form_state['values']['title'])) {
$translation_set->title = $form_state['values']['title'];
}
$translation_set
->save(TRUE);
drupal_set_message(t('The path translation has been saved.'));
break;
case 'delete':
$destination = array();
if (isset($_GET['destination'])) {
$destination = drupal_get_destination();
unset($_GET['destination']);
}
$form_state['redirect'] = array(
$translation_set
->get_delete_path(),
array(
'query' => $destination,
),
);
return;
}
$form_state['redirect'] = 'admin/config/regional/i18n_translation/path';
}