You are here

function views_handler_argument::options_form in Views (for Drupal 7) 6.2

Same name and namespace in other branches
  1. 6.3 handlers/views_handler_argument.inc \views_handler_argument::options_form()
  2. 7.3 handlers/views_handler_argument.inc \views_handler_argument::options_form()

Provide a form for setting options.

Overrides views_handler::options_form

5 calls to views_handler_argument::options_form()
views_handler_argument_many_to_one::options_form in handlers/views_handler_argument_many_to_one.inc
Provide a form for setting options.
views_handler_argument_null::options_form in handlers/views_handler_argument_null.inc
Override options_form() so that only the relevant options are displayed to the user.
views_handler_argument_numeric::options_form in handlers/views_handler_argument_numeric.inc
Provide a form for setting options.
views_handler_argument_string::options_form in handlers/views_handler_argument_string.inc
Provide a form for setting options.
views_handler_argument_term_node_tid_depth::options_form in modules/taxonomy/views_handler_argument_term_node_tid_depth.inc
Provide a form for setting options.
7 methods override views_handler_argument::options_form()
views_handler_argument_broken::options_form in handlers/views_handler_argument.inc
Provide a form for setting options.
views_handler_argument_many_to_one::options_form in handlers/views_handler_argument_many_to_one.inc
Provide a form for setting options.
views_handler_argument_null::options_form in handlers/views_handler_argument_null.inc
Override options_form() so that only the relevant options are displayed to the user.
views_handler_argument_numeric::options_form in handlers/views_handler_argument_numeric.inc
Provide a form for setting options.
views_handler_argument_string::options_form in handlers/views_handler_argument_string.inc
Provide a form for setting options.

... See full list

File

handlers/views_handler_argument.inc, line 112

Class

views_handler_argument
Base class for arguments.

Code

function options_form(&$form, &$form_state) {
  $defaults = $this
    ->default_actions();
  $form['title'] = array(
    '#prefix' => '<div class="clear-block">',
    '#suffix' => '</div>',
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => $this->options['title'],
    '#description' => t('The title to use when this argument is present. It will override the title of the view and titles from previous arguments. You can use percent substitution here to replace with argument titles. Use "%1" for the first argument, "%2" for the second, etc.'),
  );
  $form['breadcrumb'] = array(
    '#prefix' => '<div class="clear-block">',
    '#suffix' => '</div>',
    '#type' => 'textfield',
    '#title' => t('Breadcrumb'),
    '#default_value' => $this->options['breadcrumb'],
    '#description' => t('The Breadcrumb title to use when this argument is present. If no breadcrumb is set here, default Title values will be used, see "Title" for percent substitutions.'),
  );
  $form['clear_start'] = array(
    '#value' => '<div class="clear-block">',
  );
  $form['defaults_start'] = array(
    '#value' => '<div class="views-left-50">',
  );
  $form['default_action'] = array(
    '#type' => 'radios',
    '#title' => t('Action to take if argument is not present'),
    '#default_value' => $this->options['default_action'],
  );
  $form['defaults_stop'] = array(
    '#value' => '</div>',
  );
  $form['wildcard'] = array(
    '#prefix' => '<div class="views-right-50">',
    // prefix and no suffix means these two items will be grouped together.
    '#type' => 'textfield',
    '#title' => t('Wildcard'),
    '#size' => 20,
    '#default_value' => $this->options['wildcard'],
    '#description' => t('If this value is received as an argument, the argument will be ignored; i.e, "all values"'),
  );
  $form['wildcard_substitution'] = array(
    '#suffix' => '</div>',
    '#type' => 'textfield',
    '#title' => t('Wildcard title'),
    '#size' => 20,
    '#default_value' => $this->options['wildcard_substitution'],
    '#description' => t('The title to use for the wildcard in substitutions elsewhere.'),
  );
  $form['clear_stop'] = array(
    '#value' => '</div>',
  );
  $options = array();
  $validate_options = array();
  foreach ($defaults as $id => $info) {
    $options[$id] = $info['title'];
    if (empty($info['default only'])) {
      $validate_options[$id] = $info['title'];
    }
    if (!empty($info['form method'])) {
      $this
        ->{$info['form method']}($form, $form_state);
    }
  }
  $form['default_action']['#options'] = $options;
  $form['validate_options_div_prefix'] = array(
    '#id' => 'views-validator-options',
    '#value' => '<fieldset id="views-validator-options"><legend>' . t('Validator options') . '</legend>',
  );
  $form['validate_type'] = array(
    '#type' => 'select',
    '#title' => t('Validator'),
    '#default_value' => $this->options['validate_type'],
  );
  $validate_types = array(
    'none' => t('- Basic validation -'),
  );
  $plugins = views_fetch_plugin_data('argument validator');
  foreach ($plugins as $id => $info) {
    if (!empty($info['no ui'])) {
      continue;
    }
    $valid = TRUE;
    if (!empty($info['type'])) {
      $valid = FALSE;
      if (empty($this->definition['validate type'])) {
        continue;
      }
      foreach ((array) $info['type'] as $type) {
        if ($type == $this->definition['validate type']) {
          $valid = TRUE;
          break;
        }
      }
    }

    // If we decide this validator is ok, add it to the list.
    if ($valid) {
      $plugin = views_get_plugin('argument validator', $id);
      if ($plugin) {
        $plugin
          ->init($this->view, $this, $id);
        if ($plugin
          ->access() || $this->options['validate_type'] == $id) {
          $plugin
            ->validate_form($form, $form_state, $id);
          $validate_types[$id] = $info['title'];
        }
      }
    }
  }
  asort($validate_types);
  $form['validate_type']['#options'] = $validate_types;
  $form['validate_fail'] = array(
    '#type' => 'select',
    '#title' => t('Action to take if argument does not validate'),
    '#default_value' => $this->options['validate_fail'],
    '#options' => $validate_options,
  );
  $form['validate_options_div_suffix'] = array(
    '#value' => '</fieldset>',
  );
}