Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/handlers/views_handler_filter_numeric.inc | ||
---|---|---|
11 | 11 |
* @ingroup views_filter_handlers |
12 | 12 |
*/ |
13 | 13 |
class views_handler_filter_numeric extends views_handler_filter { |
14 |
var $always_multiple = TRUE; |
|
15 |
function option_definition() { |
|
14 |
|
|
15 |
/** |
|
16 |
* Exposed filter options. |
|
17 |
*/ |
|
18 |
public $always_multiple = TRUE; |
|
19 |
|
|
20 |
/** |
|
21 |
* {@inheritdoc} |
|
22 |
*/ |
|
23 |
public function option_definition() { |
|
16 | 24 |
$options = parent::option_definition(); |
17 | 25 |
|
18 | 26 |
$options['value'] = array( |
... | ... | |
26 | 34 |
return $options; |
27 | 35 |
} |
28 | 36 |
|
29 |
function operators() { |
|
37 |
/** |
|
38 |
* {@inheritdoc} |
|
39 |
*/ |
|
40 |
public function operators() { |
|
30 | 41 |
$operators = array( |
31 | 42 |
'<' => array( |
32 | 43 |
'title' => t('Is less than'), |
... | ... | |
114 | 125 |
/** |
115 | 126 |
* Provide a list of all the numeric operators |
116 | 127 |
*/ |
117 |
function operator_options($which = 'title') { |
|
128 |
public function operator_options($which = 'title') {
|
|
118 | 129 |
$options = array(); |
119 | 130 |
foreach ($this->operators() as $id => $info) { |
120 | 131 |
$options[$id] = $info[$which]; |
... | ... | |
123 | 134 |
return $options; |
124 | 135 |
} |
125 | 136 |
|
126 |
function operator_values($values = 1) { |
|
137 |
/** |
|
138 |
* {@inheritdoc} |
|
139 |
*/ |
|
140 |
public function operator_values($values = 1) { |
|
127 | 141 |
$options = array(); |
128 | 142 |
foreach ($this->operators() as $id => $info) { |
129 | 143 |
if ($info['values'] == $values) { |
... | ... | |
133 | 147 |
|
134 | 148 |
return $options; |
135 | 149 |
} |
150 |
|
|
136 | 151 |
/** |
137 | 152 |
* Provide a simple textfield for equality |
138 | 153 |
*/ |
139 |
function value_form(&$form, &$form_state) { |
|
154 |
public function value_form(&$form, &$form_state) {
|
|
140 | 155 |
$form['value']['#tree'] = TRUE; |
141 | 156 |
|
142 | 157 |
// We have to make some choices when creating this as an exposed |
... | ... | |
223 | 238 |
} |
224 | 239 |
} |
225 | 240 |
|
226 |
function query() { |
|
241 |
/** |
|
242 |
* {@inheritdoc} |
|
243 |
*/ |
|
244 |
public function query() { |
|
227 | 245 |
$this->ensure_my_table(); |
228 | 246 |
$field = "$this->table_alias.$this->real_field"; |
229 | 247 |
|
... | ... | |
233 | 251 |
} |
234 | 252 |
} |
235 | 253 |
|
236 |
function op_between($field) { |
|
254 |
/** |
|
255 |
* {@inheritdoc} |
|
256 |
*/ |
|
257 |
public function op_between($field) { |
|
237 | 258 |
if ($this->operator == 'between') { |
238 | 259 |
$this->query->add_where($this->options['group'], $field, array($this->value['min'], $this->value['max']), 'BETWEEN'); |
239 | 260 |
} |
... | ... | |
242 | 263 |
} |
243 | 264 |
} |
244 | 265 |
|
245 |
function op_simple($field) { |
|
266 |
/** |
|
267 |
* {@inheritdoc} |
|
268 |
*/ |
|
269 |
public function op_simple($field) { |
|
246 | 270 |
$this->query->add_where($this->options['group'], $field, $this->value['value'], $this->operator); |
247 | 271 |
} |
248 | 272 |
|
249 |
function op_empty($field) { |
|
273 |
/** |
|
274 |
* {@inheritdoc} |
|
275 |
*/ |
|
276 |
public function op_empty($field) { |
|
250 | 277 |
if ($this->operator == 'empty') { |
251 | 278 |
$operator = "IS NULL"; |
252 | 279 |
} |
... | ... | |
257 | 284 |
$this->query->add_where($this->options['group'], $field, NULL, $operator); |
258 | 285 |
} |
259 | 286 |
|
260 |
function op_regex($field) { |
|
287 |
/** |
|
288 |
* {@inheritdoc} |
|
289 |
*/ |
|
290 |
public function op_regex($field) { |
|
261 | 291 |
$this->query->add_where($this->options['group'], $field, $this->value['value'], 'RLIKE'); |
262 | 292 |
} |
263 | 293 |
|
264 |
function admin_summary() { |
|
294 |
/** |
|
295 |
* {@inheritdoc} |
|
296 |
*/ |
|
297 |
public function admin_summary() { |
|
265 | 298 |
if ($this->is_a_group()) { |
266 | 299 |
return t('grouped'); |
267 | 300 |
} |
... | ... | |
281 | 314 |
} |
282 | 315 |
|
283 | 316 |
/** |
284 |
* Do some minor translation of the exposed input |
|
317 |
* Do some minor translation of the exposed input.
|
|
285 | 318 |
*/ |
286 |
function accept_exposed_input($input) { |
|
319 |
public function accept_exposed_input($input) {
|
|
287 | 320 |
if (empty($this->options['exposed'])) { |
288 | 321 |
return TRUE; |
289 | 322 |
} |
290 | 323 |
|
291 |
// rewrite the input value so that it's in the correct format so that
|
|
292 |
// the parent gets the right data.
|
|
324 |
// Rewrite the input value so that it's in the correct format so that the
|
|
325 |
// parent gets the right data. |
|
293 | 326 |
if (!empty($this->options['expose']['identifier'])) { |
294 | 327 |
$value = &$input[$this->options['expose']['identifier']]; |
295 | 328 |
if (!is_array($value)) { |
... | ... | |
311 | 344 |
return FALSE; |
312 | 345 |
} |
313 | 346 |
break; |
347 |
|
|
314 | 348 |
case 2: |
315 | 349 |
if ($value['min'] === '' && $value['max'] === '') { |
316 | 350 |
return FALSE; |
... | ... | |
322 | 356 |
|
323 | 357 |
return $rc; |
324 | 358 |
} |
359 |
|
|
325 | 360 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules