function node_registration_submit_locale_kick in Node registration 7
Submit handler for localized forms.
2 string references to 'node_registration_submit_locale_kick'
- node_registration_registrations_settings_form in includes/
node_registration.forms.inc - Return a form for a node's registration settings.
- node_registration_type_settings in includes/
node_registration.forms.inc - Form for registration type settings.
File
- includes/
node_registration.forms.inc, line 1390 - New registration forms. Public and admin.
Code
function node_registration_submit_locale_kick($form, &$form_state) {
if (!module_exists('locale')) {
return;
}
// Find any enabled non-English language.
foreach (language_list() as $langcode => $language) {
if ($langcode != 'en' && $language->enabled) {
break;
}
}
// No point if we only have English.
if ($langcode == 'en') {
return;
}
// Recursively find ALL #nr_locale_kick elements and force their value into locale.
$walk = function ($element) use (&$walk, $langcode) {
foreach (element_children($element) as $name) {
if (!empty($element[$name]['#nr_locale_kick'])) {
// Got one. Make sure this value exists in locale, so it's translatable via Locale's UI.
if (!empty($element[$name]['#value'])) {
$cfg = is_array($element[$name]['#nr_locale_kick']) ? $element[$name]['#nr_locale_kick'] : array();
$context = isset($cfg['context']) ? $cfg['context'] ?: NULL : 'node_registration';
locale($element[$name]['#value'], $context, $langcode);
}
}
elseif (is_array($element[$name])) {
$walk($element[$name]);
}
}
};
$walk($form_state['complete form']);
}