Révision 599a39cd
Ajouté par Assos Assos il y a environ 3 ans
drupal7/sites/all/modules/date/date_views/includes/date_views_argument_handler.inc | ||
---|---|---|
1 | 1 |
<?php |
2 |
|
|
2 | 3 |
/** |
3 | 4 |
* @file |
4 | 5 |
* Date API views argument handler. |
5 |
* This argument combines multiple date arguments into a single argument |
|
6 |
* where all fields are controlled by the same date and can be combined |
|
7 |
* with either AND or OR. |
|
6 |
* |
|
7 |
* This argument combines multiple date arguments into a single argument where |
|
8 |
* all fields are controlled by the same date and can be combined with either |
|
9 |
* AND or OR. |
|
8 | 10 |
*/ |
9 | 11 |
|
10 | 12 |
/** |
11 | 13 |
* Date API argument handler. |
12 | 14 |
*/ |
13 |
// @codingStandardsIgnoreStart |
|
14 | 15 |
class date_views_argument_handler extends date_views_argument_handler_simple { |
15 | 16 |
|
16 | 17 |
/** |
17 |
* Get granularity and use it to create the formula and a format |
|
18 |
* for the results. |
|
18 |
* {@inheritdoc} |
|
19 | 19 |
*/ |
20 | 20 |
function init(&$view, &$options) { |
21 | 21 |
parent::init($view, $options); |
... | ... | |
30 | 30 |
} |
31 | 31 |
|
32 | 32 |
/** |
33 |
* Default value for the date_fields option.
|
|
33 |
* {@inheritdoc}
|
|
34 | 34 |
*/ |
35 | 35 |
function option_definition() { |
36 | 36 |
$options = parent::option_definition(); |
... | ... | |
41 | 41 |
} |
42 | 42 |
|
43 | 43 |
/** |
44 |
* Add a form element to select date_fields for this argument.
|
|
44 |
* {@inheritdoc}
|
|
45 | 45 |
*/ |
46 | 46 |
function options_form(&$form, &$form_state) { |
47 | 47 |
parent::options_form($form, $form_state); |
... | ... | |
72 | 72 |
); |
73 | 73 |
} |
74 | 74 |
|
75 |
/** |
|
76 |
* {@inheritdoc} |
|
77 |
*/ |
|
75 | 78 |
function options_validate(&$form, &$form_state) { |
76 |
|
|
77 |
// Views will whine if we don't have something for the these values even though we removed the option for summaries.
|
|
79 |
// Views will whine if we don't have something for the these values even |
|
80 |
// though we removed the option for summaries. |
|
78 | 81 |
$form_state['values']['options']['summary']['format'] = 'none'; |
79 | 82 |
$form_state['values']['options']['summary']['options']['none'] = array(); |
80 | 83 |
|
... | ... | |
89 | 92 |
} |
90 | 93 |
} |
91 | 94 |
|
95 |
/** |
|
96 |
* {@inheritdoc} |
|
97 |
*/ |
|
92 | 98 |
function options_submit(&$form, &$form_state) { |
93 | 99 |
// It is very important to call the parent function here: |
94 | 100 |
parent::options_submit($form, $form_state); |
... | ... | |
97 | 103 |
} |
98 | 104 |
} |
99 | 105 |
|
100 |
// Update the summary values to show selected granularity. |
|
106 |
/** |
|
107 |
* {@inheritdoc} |
|
108 |
*/ |
|
101 | 109 |
function admin_summary() { |
102 | 110 |
$fields = date_views_fields($this->base_table); |
103 | 111 |
if (!empty($this->options['date_fields'])) { |
... | ... | |
115 | 123 |
} |
116 | 124 |
|
117 | 125 |
/** |
118 |
* Provide a list of default behaviors for this argument if the argument |
|
119 |
* is not present. |
|
120 |
* |
|
121 |
* Override this method to provide additional (or fewer) default behaviors. |
|
126 |
* {@inheritdoc} |
|
122 | 127 |
*/ |
123 | 128 |
function default_actions($which = NULL) { |
124 | 129 |
$defaults = parent::default_actions(); |
125 | 130 |
|
126 |
// There is no easy way to do summary queries on multiple fields, so remove that option. |
|
131 |
// There is no easy way to do summary queries on multiple fields, so remove |
|
132 |
// that option. |
|
127 | 133 |
unset($defaults['summary']); |
128 | 134 |
|
129 | 135 |
if ($which) { |
... | ... | |
137 | 143 |
} |
138 | 144 |
|
139 | 145 |
/** |
140 |
* Set up the query for this argument. |
|
141 |
* |
|
142 |
* The argument sent may be found at $this->argument. |
|
146 |
* {@inheritdoc} |
|
143 | 147 |
*/ |
144 | 148 |
function query($group_by = FALSE) { |
145 |
|
|
146 |
// @TODO Not doing anything with $group_by yet, need to figure out what has to be done. |
|
147 |
|
|
149 |
// @todo Not doing anything with $group_by yet, need to figure out what has |
|
150 |
// to be done. |
|
148 | 151 |
if ($this->date_forbid()) { |
149 | 152 |
return; |
150 | 153 |
} |
... | ... | |
156 | 159 |
$this->placeholders = array(); |
157 | 160 |
|
158 | 161 |
if (!empty($this->query_fields)) { |
159 |
// Use set_where_group() with the selected date_method |
|
160 |
// of 'AND' or 'OR' to create the where clause.
|
|
162 |
// Use set_where_group() with the selected date_method of 'AND' or 'OR'
|
|
163 |
// to create the where clause. |
|
161 | 164 |
foreach ($this->query_fields as $count => $query_field) { |
162 | 165 |
$field = $query_field['field']; |
163 | 166 |
$this->date_handler = $query_field['date_handler']; |
... | ... | |
168 | 171 |
if ($field['table_name'] != $this->table || !empty($this->relationship)) { |
169 | 172 |
$this->table = $this->query->ensure_table($field['table_name'], $this->relationship); |
170 | 173 |
} |
171 |
// $this->table_alias gets set when the first field is processed if otherwise empty. |
|
172 |
// For subsequent fields, we need to be sure it is emptied again. |
|
174 |
// $this->table_alias gets set when the first field is processed if |
|
175 |
// otherwise empty. For subsequent fields, we need to be sure it is |
|
176 |
// emptied again. |
|
173 | 177 |
elseif (empty($this->relationship)) { |
174 | 178 |
$this->table_alias = NULL; |
175 | 179 |
} |
... | ... | |
181 | 185 |
} |
182 | 186 |
|
183 | 187 |
/** |
184 |
* Collect information about our fields we will need to create the right query.
|
|
188 |
* {@inheritdoc}
|
|
185 | 189 |
*/ |
186 | 190 |
function get_query_fields() { |
187 | 191 |
$fields = date_views_fields($this->base_table); |
... | ... | |
200 | 204 |
} |
201 | 205 |
|
202 | 206 |
} |
203 |
// @codingStandardsIgnoreEnd |
Formats disponibles : Unified diff
Weekly update of contrib modules