You are here

function views_oai_pmh_plugin_row_misc::options_submit in Views OAI-PMH 7.2

Same name and namespace in other branches
  1. 6.2 plugins/views_oai_pmh_plugin_row_misc.inc \views_oai_pmh_plugin_row_misc::options_submit()

Save the changes made in the Views form.

_state

Parameters

array $form:

bool $apply_changes Set to FALSE to return the form changes as a: response to the function call. TRUE (default) makes the changes directly to the $form_state variable.

Return value

array An array of the form changes.

Overrides views_plugin_row::options_submit

File

plugins/views_oai_pmh_plugin_row_misc.inc, line 181
Definition of the views_oai_pmh_plugin_row_misc class.

Class

views_oai_pmh_plugin_row_misc
@file Definition of the views_oai_pmh_plugin_row_misc class.

Code

function options_submit(&$form, &$form_state, $apply_changes = TRUE) {

  // It is very important to call the parent function here.
  parent::options_submit($form, $form_state);

  // Create an array to save the changes that we make to the form.
  $form_item_options = array();
  $section = $form_state['section'];
  switch ($section) {
    case 'row_options':
      $field_handlers = $this->display->handler
        ->get_handlers('field');
      $form_group_name = $GLOBALS['views_oai_pmh'][$this->_metadata_format]->form_group_name;
      $labels = $form_state['values'][$section][$form_group_name];
      foreach ($field_handlers as $id => $field) {
        $options = $field->options;
        if ($labels[$id] != 'none') {
          $options['custom_label'] = TRUE;
          $options['label'] = $labels[$id];
          $options['hide_empty'] = 1;
        }
        else {
          unset($options['custom_label']);
          $options['label'] = '';
        }
        $form_item_options[$id] = $options;

        // See if we should be applying the changes to the form state now, or
        // returning it to the calling function. The default behaviour is to
        // apply the changes now; the alternative of returning the changes to
        // the calling function is provided for the Auto class to combine all
        // the results of multiple calls to this function in various classes.
        if ($apply_changes) {

          // Save the field info in the view.
          $form_state['view']
            ->set_item($form_state['display_id'], 'field', $id, $options);
        }
      }
      break;
  }
  if (!$apply_changes) {
    return $form_item_options;
  }
  return NULL;
}