Mercurial > hg > rr-repo
comparison sites/all/modules/views/handlers/views_handler_argument_null.inc @ 0:ff03f76ab3fe
initial version
author | danieleb <danielebarchiesi@me.com> |
---|---|
date | Wed, 21 Aug 2013 18:51:11 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ff03f76ab3fe |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * @file | |
5 * Definition of views_handler_argument_null. | |
6 */ | |
7 | |
8 /** | |
9 * Argument handler that ignores the argument. | |
10 * | |
11 * @ingroup views_argument_handlers | |
12 */ | |
13 class views_handler_argument_null extends views_handler_argument { | |
14 function option_definition() { | |
15 $options = parent::option_definition(); | |
16 $options['must_not_be'] = array('default' => FALSE, 'bool' => TRUE); | |
17 return $options; | |
18 } | |
19 | |
20 /** | |
21 * Override options_form() so that only the relevant options | |
22 * are displayed to the user. | |
23 */ | |
24 function options_form(&$form, &$form_state) { | |
25 parent::options_form($form, $form_state); | |
26 $form['must_not_be'] = array( | |
27 '#type' => 'checkbox', | |
28 '#title' => t('Fail basic validation if any argument is given'), | |
29 '#default_value' => !empty($this->options['must_not_be']), | |
30 '#description' => t('By checking this field, you can use this to make sure views with more arguments than necessary fail validation.'), | |
31 '#fieldset' => 'more', | |
32 ); | |
33 | |
34 unset($form['exception']); | |
35 } | |
36 | |
37 /** | |
38 * Override default_actions() to remove actions that don't | |
39 * make sense for a null argument. | |
40 */ | |
41 function default_actions($which = NULL) { | |
42 if ($which) { | |
43 if (in_array($which, array('ignore', 'not found', 'empty', 'default'))) { | |
44 return parent::default_actions($which); | |
45 } | |
46 return; | |
47 } | |
48 $actions = parent::default_actions(); | |
49 unset($actions['summary asc']); | |
50 unset($actions['summary desc']); | |
51 return $actions; | |
52 } | |
53 | |
54 function validate_argument_basic($arg) { | |
55 if (!empty($this->options['must_not_be'])) { | |
56 return !isset($arg); | |
57 } | |
58 | |
59 return parent::validate_argument_basic($arg); | |
60 } | |
61 | |
62 /** | |
63 * Override the behavior of query() to prevent the query | |
64 * from being changed in any way. | |
65 */ | |
66 function query($group_by = FALSE) {} | |
67 } |