You are here

function pagerer_preset_form_submit in Pagerer 7

Preset edit form - submission.

File

./pagerer.admin.inc, line 293
Pagerer administration

Code

function pagerer_preset_form_submit($form, &$form_state) {
  $preset_name = $form_state['build_info']['args'][0];
  $preset = _pagerer_get_preset($preset_name);
  $trigger = $form_state['triggering_element']['#name'];
  $v = $form_state['values'];

  // Set variables.
  $preset['left_pane']['theme_name'] = $v['panes']['e']['left']['data']['theme_name'];
  $preset['center_pane']['theme_name'] = $v['panes']['e']['center']['data']['theme_name'];
  $preset['right_pane']['theme_name'] = $v['panes']['e']['right']['data']['theme_name'];
  _pagerer_save_preset($preset_name, $preset);

  // Hands over to pane configuration or theme reset if requested.
  if (strpos($trigger, 'config', 0) === 0) {
    $e = explode('_', $trigger);
    $pane = $e[1];
    $form_state['redirect'] = _PAGERER_CONFIG_PATH . '/edit/' . $preset_name . '/' . $pane;
  }
  elseif (strpos($trigger, 'reset', 0) === 0) {
    $e = explode('_', $trigger);
    $pane = $e[1];
    $form_state['redirect'] = _PAGERER_CONFIG_PATH . '/edit/' . $preset_name . '/' . $pane . '/reset';
  }
  elseif ($trigger == 'save') {
    drupal_set_message(t('Preset %preset has been saved.', array(
      '%preset' => $preset_name,
    )), 'status');
  }
  else {
    drupal_set_message(t('Preset %preset has been saved.', array(
      '%preset' => $preset_name,
    )), 'status');
    $form_state['redirect'] = _PAGERER_CONFIG_PATH;
  }
}