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
|
|
15
|
/**
|
16
|
* {@inheritdoc}
|
17
|
*/
|
18
|
public function option_definition() {
|
19
|
$options = parent::option_definition();
|
20
|
$options['must_not_be'] = array('default' => FALSE, 'bool' => TRUE);
|
21
|
return $options;
|
22
|
}
|
23
|
|
24
|
/**
|
25
|
* Override options_form() so that only the relevant options
|
26
|
* are displayed to the user.
|
27
|
*/
|
28
|
public function options_form(&$form, &$form_state) {
|
29
|
parent::options_form($form, $form_state);
|
30
|
$form['must_not_be'] = array(
|
31
|
'#type' => 'checkbox',
|
32
|
'#title' => t('Fail basic validation if any argument is given'),
|
33
|
'#default_value' => !empty($this->options['must_not_be']),
|
34
|
'#description' => t('By checking this field, you can use this to make sure views with more arguments than necessary fail validation.'),
|
35
|
'#fieldset' => 'more',
|
36
|
);
|
37
|
|
38
|
unset($form['exception']);
|
39
|
}
|
40
|
|
41
|
/**
|
42
|
* Override default_actions() to remove actions that don't
|
43
|
* make sense for a null argument.
|
44
|
*/
|
45
|
public function default_actions($which = NULL) {
|
46
|
if ($which) {
|
47
|
if (in_array($which, array('ignore', 'not found', 'empty', 'default', 'access denied'))) {
|
48
|
return parent::default_actions($which);
|
49
|
}
|
50
|
return;
|
51
|
}
|
52
|
$actions = parent::default_actions();
|
53
|
unset($actions['summary asc']);
|
54
|
unset($actions['summary desc']);
|
55
|
return $actions;
|
56
|
}
|
57
|
|
58
|
/**
|
59
|
* {@inheritdoc}
|
60
|
*/
|
61
|
public function validate_argument_basic($arg) {
|
62
|
if (!empty($this->options['must_not_be'])) {
|
63
|
return !isset($arg);
|
64
|
}
|
65
|
|
66
|
return parent::validate_argument_basic($arg);
|
67
|
}
|
68
|
|
69
|
/**
|
70
|
* Override the behavior of query() to prevent the query
|
71
|
* from being changed in any way.
|
72
|
*/
|
73
|
public function query($group_by = FALSE) {
|
74
|
}
|
75
|
|
76
|
}
|