[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/views/handlers/ -> views_handler_argument_null.inc (source)

   1  <?php
   2  // $Id: views_handler_argument_null.inc,v 1.1 2008/09/03 19:21:28 merlinofchaos Exp $
   3  /**
   4   * Argument handler that ignores the argument.
   5   */
   6  class views_handler_argument_null extends views_handler_argument {
   7    function option_definition() {
   8      $options = parent::option_definition();
   9      $options['must_not_be'] = array('default' => FALSE);
  10      return $options;
  11    }
  12  
  13    /**
  14     * Override options_form() so that only the relevant options
  15     * are displayed to the user.
  16     */
  17    function options_form(&$form, &$form_state) {
  18      parent::options_form($form, $form_state);
  19      $form['must_not_be'] = array(
  20        '#type' => 'checkbox',
  21        '#title' => t('Fail basic validation if any argument is given'),
  22        '#default_value' => !empty($this->options['must_not_be']),
  23        '#description' => t('By checking this field, you can use this to make sure views with more arguments than necessary fail validation.'),
  24      );
  25  
  26      unset($form['wildcard']);
  27      unset($form['wildcard_substitution']);
  28    }
  29  
  30    /**
  31     * Override default_actions() to remove actions that don't
  32     * make sense for a null argument.
  33     */
  34    function default_actions($which = NULL) {
  35      if ($which) {
  36        if (in_array($which, array('ignore', 'not found', 'empty', 'default'))) {
  37          return parent::default_actions($which);
  38        }
  39        return;
  40      }
  41      $actions = parent::default_actions();
  42      unset($actions['summary asc']);
  43      unset($actions['summary desc']);
  44      return $actions;
  45    }
  46  
  47    function validate_argument_basic($arg) {
  48      if (!empty($this->options['must_not_be'])) {
  49        return !isset($arg);
  50      }
  51  
  52      return parent::validate_argument_basic($arg);
  53    }
  54  
  55    /**
  56     * Override the behavior of query() to prevent the query
  57     * from being changed in any way.
  58     */
  59    function query() {}
  60  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7