You are here

function skinr_ui_form_submit in Skinr 6.2

Same name and namespace in other branches
  1. 7.2 skinr_ui.edit.inc \skinr_ui_form_submit()

Submit handler.

3 string references to 'skinr_ui_form_submit'
panels_skinr_access_handler_display in modules/panels.skinr.inc
Skinr access handler.
skinr_ui_form_alter in ./skinr_ui.module
Implementation of hook_form_alter().
views_skinr_access_handler_view in modules/views.skinr.inc

File

./skinr_ui.module, line 623

Code

function skinr_ui_form_submit(&$form, &$form_state) {
  global $gskinr;
  $form_id = $form_state['values']['form_id'];
  $skinr_config = skinr_fetch_config();
  $current_theme = skinr_current_theme(TRUE);
  if ($form_id == 'skinr_ui_form') {
    $module = $form_state['values']['module'];
    $sids = !empty($form_state['values']['sids']) ? explode(',', $form_state['values']['sids']) : array(
      $form_state['values']['sid'],
    );
    $settings = $skinr_config[$module];
    if (isset($settings['form'][$form_id])) {
      $original_classes = array();
      if ($extracted = skinr_skin_extract($module, $sids, $settings, $current_theme)) {
        $original_classes = $extracted['classes'];
      }
      $form_settings = array_merge(_skinr_fetch_config_defaults('form'), $settings['form'][$form_id]);
      skinr_handler('submit_handler', '', $form_settings['submit_handler'], $form, $form_state, $module, $form_settings);

      // Fetch the updated style object.
      if ($extracted = skinr_skin_extract($module, $sids, $settings, $current_theme, TRUE)) {

        // Initialize global skinr array to store information for retrieval by js.
        if (!is_array($gskinr)) {
          $gskinr = array();
        }
        $sid = $form_state['values']['sid'];

        // Store class information for js to retrieve later on.
        // @todo Figure out what to do when a custom template file is required.
        $gskinr[$module][$sid] = array(
          'module' => $module,
          'sid' => $sid,
          'classes' => array(
            'remove' => implode(' ', $original_classes),
            'add' => implode(' ', $extracted['classes']),
          ),
          'css' => $extracted['css'],
          'js' => $extracted['js'],
        );
      }
    }
  }
  else {
    foreach ($skinr_config as $module => $settings) {
      if (isset($settings['form'][$form_id])) {
        $form_settings = array_merge(_skinr_fetch_config_defaults('form'), $settings['form'][$form_id]);
        skinr_handler('submit_handler', '', $form_settings['submit_handler'], $form, $form_state, $module, $form_settings);

        // Keep looping, there might be other modules that implement the same form_id.
      }
    }
  }
}