Révision 599a39cd
Ajouté par Assos Assos il y a environ 3 ans
drupal7/sites/all/modules/date/date_views/includes/date_views_filter_handler.inc | ||
---|---|---|
1 | 1 |
<?php |
2 |
|
|
2 | 3 |
/** |
3 | 4 |
* @file |
4 | 5 |
* A flexible, configurable date filter. |
5 |
* This filter combines multiple date filters into a single filter |
|
6 |
* where all fields are controlled by the same date and can be combined |
|
7 |
* with either AND or OR. |
|
8 | 6 |
*/ |
9 | 7 |
|
10 |
// @codingStandardsIgnoreStart |
|
8 |
/** |
|
9 |
* A flexible, configurable date filter. |
|
10 |
* |
|
11 |
* This filter combines multiple date filters into a single filter where all |
|
12 |
* fields are controlled by the same date and can be combined with either AND or |
|
13 |
* OR. |
|
14 |
*/ |
|
11 | 15 |
class date_views_filter_handler extends date_views_filter_handler_simple { |
16 |
|
|
17 |
/** |
|
18 |
* {@inheritdoc} |
|
19 |
*/ |
|
12 | 20 |
function init(&$view, &$options) { |
13 | 21 |
parent::init($view, $options); |
14 | 22 |
|
... | ... | |
21 | 29 |
$this->view->date_info->date_fields = array_merge($this->view->date_info->date_fields, $this->options['date_fields']); |
22 | 30 |
} |
23 | 31 |
|
24 |
// Set default values for the date filter. |
|
32 |
/** |
|
33 |
* {@inheritdoc} |
|
34 |
*/ |
|
25 | 35 |
function option_definition() { |
26 | 36 |
$options = parent::option_definition(); |
27 | 37 |
$options['date_fields'] = array('default' => array()); |
... | ... | |
30 | 40 |
return $options; |
31 | 41 |
} |
32 | 42 |
|
43 |
/** |
|
44 |
* @todo |
|
45 |
*/ |
|
33 | 46 |
function op_between($field) { |
34 | 47 |
$this->date_combine_conditions('op_between'); |
35 | 48 |
} |
36 | 49 |
|
50 |
/** |
|
51 |
* @todo |
|
52 |
*/ |
|
37 | 53 |
function op_simple($field) { |
38 | 54 |
$this->date_combine_conditions('op_simple'); |
39 | 55 |
} |
40 | 56 |
|
57 |
/** |
|
58 |
* @todo |
|
59 |
*/ |
|
41 | 60 |
function op_contains($field) { |
42 | 61 |
$this->date_combine_conditions('op_contains'); |
43 | 62 |
} |
44 | 63 |
|
64 |
/** |
|
65 |
* @todo |
|
66 |
*/ |
|
45 | 67 |
function op_empty($field) { |
46 | 68 |
$this->get_query_fields(); |
47 | 69 |
if (empty($this->query_fields)) { |
... | ... | |
83 | 105 |
|
84 | 106 |
// Create a custom filter group for the conditions. |
85 | 107 |
$this->query->set_where_group($this->options['date_method'], $this->options['date_group']); |
108 |
|
|
86 | 109 |
// Add each condition to the custom filter group. |
87 | 110 |
foreach ((array) $this->query_fields as $query_field) { |
88 | 111 |
$field = $query_field['field']; |
... | ... | |
120 | 143 |
$this->query->add_where_expression($this->options['group'], $conditions, $placeholders); |
121 | 144 |
} |
122 | 145 |
|
146 |
/** |
|
147 |
* {@inheritdoc} |
|
148 |
*/ |
|
123 | 149 |
function extra_options_form(&$form, &$form_state) { |
124 | 150 |
parent::extra_options_form($form, $form_state); |
125 | 151 |
|
... | ... | |
147 | 173 |
); |
148 | 174 |
} |
149 | 175 |
|
176 |
/** |
|
177 |
* {@inheritdoc} |
|
178 |
*/ |
|
150 | 179 |
function extra_options_validate($form, &$form_state) { |
151 | 180 |
$check_fields = array_filter($form_state['values']['options']['date_fields']); |
152 | 181 |
if (empty($check_fields)) { |
... | ... | |
154 | 183 |
} |
155 | 184 |
} |
156 | 185 |
|
186 |
/** |
|
187 |
* {@inheritdoc} |
|
188 |
*/ |
|
157 | 189 |
function extra_options_submit($form, &$form_state) { |
158 | 190 |
$form_state['values']['options']['date_fields'] = array_filter($form_state['values']['options']['date_fields']); |
159 | 191 |
} |
160 | 192 |
|
161 |
// Update the summary values to provide |
|
162 |
// meaningful information for each option. |
|
193 |
/** |
|
194 |
* {@inheritdoc} |
|
195 |
*/ |
|
163 | 196 |
function admin_summary() { |
164 | 197 |
if (empty($this->options['date_fields'])) { |
165 | 198 |
return t('Missing date fields!'); |
... | ... | |
195 | 228 |
return $output; |
196 | 229 |
} |
197 | 230 |
|
231 |
/** |
|
232 |
* @todo |
|
233 |
*/ |
|
198 | 234 |
function get_query_fields() { |
199 | 235 |
$fields = date_views_fields($this->base_table); |
200 | 236 |
$fields = $fields['name']; |
... | ... | |
209 | 245 |
} |
210 | 246 |
} |
211 | 247 |
} |
248 |
|
|
212 | 249 |
} |
213 |
// @codingStandardsIgnoreEnd |
Formats disponibles : Unified diff
Weekly update of contrib modules