function styleswitcher_style_form_submit in Style Switcher 6.2
Same name and namespace in other branches
- 7.2 styleswitcher.admin.inc \styleswitcher_style_form_submit()
Form submission handler for styleswitcher_style_form().
See also
styleswitcher_style_form_validate()
File
- ./
styleswitcher.admin.inc, line 287 - Styleswitcher configuration functionality.
Code
function styleswitcher_style_form_submit($form, &$form_state) {
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
$old_name = $form_state['values']['old_name'];
if ($op == t('Delete')) {
$form_state['redirect'] = 'admin/settings/styleswitcher/' . strtr($old_name, '_', '-') . '/delete';
return;
}
$styles = styleswitcher_custom_styles();
$style = array(
'label' => $form_state['values']['label'],
'name' => 'custom/' . $form_state['values']['name'],
'path' => $form_state['values']['path'],
);
if ($old_name !== '') {
unset($styles[$old_name]);
// Update style keys in settings variable.
if ($style['name'] != $old_name) {
$settings = variable_get('styleswitcher_styles_settings', array());
foreach (array_keys($settings) as $theme) {
if (isset($settings[$theme][$old_name])) {
$settings[$theme][$style['name']] = $settings[$theme][$old_name];
unset($settings[$theme][$old_name]);
}
}
variable_set('styleswitcher_styles_settings', $settings);
}
}
$styles[$style['name']] = $style;
variable_set('styleswitcher_custom_styles', $styles);
drupal_set_message(t('The style %title has been saved.', array(
'%title' => $style['label'],
)));
_styleswitcher_configuration_changed($form_state);
}