/[drupal]/contributions/modules/views/handlers/views_handler_argument_null.inc
ViewVC logotype

Contents of /contributions/modules/views/handlers/views_handler_argument_null.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Wed Sep 3 19:21:28 2008 UTC (14 months, 3 weeks ago) by merlinofchaos
Branch: MAIN
CVS Tags: DRUPAL-6--2-7, DRUPAL-6--2-6, DRUPAL-6--2-5, DRUPAL-6--2-4, DRUPAL-6--2-3, DRUPAL-6--2-2, DRUPAL-6--2-1, DRUPAL-6--2-0, DRUPAL-6--3-0-ALPHA1, DRUPAL-6--2-0-RC5, DRUPAL-6--2-0-RC4, DRUPAL-6--2-0-RC3, DRUPAL-6--2-0-RC2, HEAD
Branch point for: DRUPAL-6--2, DRUPAL-6--3, DRUPAL-7--3
File MIME type: text/x-php
Major re-organization of handlers. PLEASE NOTE: This drastically affected the Views module API and until modules are updated to match, they will stop working. Efforts have been made to ensure that this won't cause your site to crash, but that's partly up to the individual module as well.
1 <?php
2 // $Id$
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 }

  ViewVC Help
Powered by ViewVC 1.1.2