function stringoverrides_admin_submit in String Overrides 7
Same name and namespace in other branches
- 5 stringoverrides.admin.inc \stringoverrides_admin_submit()
- 6 stringoverrides.admin.inc \stringoverrides_admin_submit()
Triggered when the user submits the administration page.
File
- ./
stringoverrides.admin.inc, line 105 - Admin page callbacks for the String Overrides module.
Code
function stringoverrides_admin_submit($form, &$form_state) {
if (!in_array($form_state['clicked_button']['#id'], array(
'edit-save',
'edit-remove',
))) {
// Submit the form only for save and remove buttons.
return;
}
// Format the words correctly so that they're put into the database correctly.
$words = array(
FALSE => array(),
TRUE => array(),
);
foreach ($form_state['values']['string'] as $index => $string) {
if (!empty($string['source'])) {
$context = check_plain($string['context']);
// Get rid of carriage returns.
list($source, $translation) = str_replace("\r", '', array(
$string['source'],
$string['translation'],
));
$words[$string['enabled']][$context][$source] = $translation;
}
}
// Save into the correct language definition.
$lang = $form['lang']['#value'];
if (empty($lang)) {
$language = language_default();
$lang = $language->language;
}
variable_set("locale_custom_strings_{$lang}", $words[1]);
// Save the values and display a message to the user depend.
switch ($form_state['clicked_button']['#id']) {
case 'edit-save':
variable_set("locale_custom_disabled_strings_{$lang}", $words[0]);
drupal_set_message(t('Your changes have been saved.'));
break;
case 'edit-remove':
variable_del("locale_custom_disabled_strings_{$lang}");
drupal_set_message(t('The disabled strings have been removed.'));
break;
}
}