You are here

public function SlickUi::edit_form_submit in Slick Carousel 7.2

Overrides the edit form submit handler.

At this point, submission is successful. Our only responsibility is to copy anything out of values onto the item that we are able to edit.

If the keys all match up to the schema, this method will not need to be overridden.

Overrides ctools_export_ui::edit_form_submit

File

slick_ui/plugins/export_ui/SlickUi.class.php, line 430
Contains the CTools export UI integration code.

Class

SlickUi
CTools Export UI class handler for Slick UI.

Code

public function edit_form_submit(&$form, &$form_state) {
  parent::edit_form_submit($form, $form_state);
  $options = $form_state['values']['options'];
  $optionset = $form_state['item'];
  $optimized = isset($options['optimized']) ? $options['optimized'] : FALSE;

  // Map and update the friendly CSS easing to its bezier equivalent.
  $override = '';
  if ($form_state['values']['options']['settings']['cssEaseOverride']) {
    $override = $this
      ->getBezier($form_state['values']['options']['settings']['cssEaseOverride']);
  }
  $optionset->options['settings']['cssEaseBezier'] = $override;
  if (isset($options['responsives']['responsive'])) {
    foreach ($options['responsives']['responsive'] as $key => $responsive) {
      if (isset($responsive['settings']['cssEaseOverride'])) {
        $responsive_override = $responsive['settings']['cssEaseOverride'] ? $this
          ->getBezier($responsive['settings']['cssEaseOverride']) : '';
        $optionset->options['responsives']['responsive'][$key]['settings']['cssEaseBezier'] = $responsive_override;
      }
    }
  }

  // Typecast the values.
  _slick_typecast_optionset($optionset->options, $form_state['values']['breakpoints']);

  // Optimized if so configured.
  if (!empty($optimized)) {
    $defaults = slick_get_options();
    $required = $this
      ->getOptionsRequiredByTemplate();
    $main = array_diff_assoc($defaults, $required);
    $settings = $optionset->options['settings'];

    // Remove wasted dependent options if disabled, empty or not.
    slick_remove_wasted_dependent_options($settings);
    $optionset->options['settings'] = array_diff_assoc($settings, $main);
    if (isset($options['responsives']['responsive'])) {
      $responsives =& $optionset->options['responsives']['responsive'];
      foreach ($responsives as $key => &$responsive) {
        if (!empty($responsive['unslick'])) {
          $responsives[$key]['settings'] = array();
        }
        else {
          slick_remove_wasted_dependent_options($responsives[$key]['settings']);
          $responsives[$key]['settings'] = array_diff_assoc($responsives[$key]['settings'], $defaults);
        }
      }
    }
  }

  // Remove useless option.
  if (isset($options['options__active_tab'])) {
    unset($optionset->options['options__active_tab']);
  }
}