1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Definition of views_handler_filter_group_by_numeric.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Simple filter to handle greater than/less than filters
|
10 |
|
|
*
|
11 |
|
|
* @ingroup views_filter_handlers
|
12 |
|
|
*/
|
13 |
|
|
class views_handler_filter_group_by_numeric extends views_handler_filter_numeric {
|
14 |
|
|
function query() {
|
15 |
|
|
$this->ensure_my_table();
|
16 |
|
|
$field = $this->get_field();
|
17 |
|
|
|
18 |
|
|
$info = $this->operators();
|
19 |
|
|
if (!empty($info[$this->operator]['method'])) {
|
20 |
|
|
$this->{$info[$this->operator]['method']}($field);
|
21 |
|
|
}
|
22 |
|
|
}
|
23 |
|
|
function op_between($field) {
|
24 |
|
|
$placeholder_min = $this->placeholder();
|
25 |
|
|
$placeholder_max = $this->placeholder();
|
26 |
|
|
if ($this->operator == 'between') {
|
27 |
|
|
$this->query->add_having_expression($this->options['group'], "$field >= $placeholder_min", array($placeholder_min => $this->value['min']));
|
28 |
|
|
$this->query->add_having_expression($this->options['group'], "$field <= $placeholder_max", array($placeholder_max => $this->value['max']));
|
29 |
|
|
}
|
30 |
|
|
else {
|
31 |
|
|
$this->query->add_having_expression($this->options['group'], "$field <= $placeholder_min OR $field >= $placeholder_max", array($placeholder_min => $this->value['min'], $placeholder_max => $this->value['max']));
|
32 |
|
|
}
|
33 |
|
|
}
|
34 |
|
|
|
35 |
|
|
function op_simple($field) {
|
36 |
|
|
$placeholder = $this->placeholder();
|
37 |
|
|
$this->query->add_having_expression($this->options['group'], "$field $this->operator $placeholder", array($placeholder => $this->value['value']));
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
function op_empty($field) {
|
41 |
|
|
if ($this->operator == 'empty') {
|
42 |
|
|
$operator = "IS NULL";
|
43 |
|
|
}
|
44 |
|
|
else {
|
45 |
|
|
$operator = "IS NOT NULL";
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
$this->query->add_having_expression($this->options['group'], "$field $operator");
|
49 |
|
|
}
|
50 |
|
|
|
51 |
|
|
function ui_name($short = FALSE) {
|
52 |
|
|
return $this->get_field(parent::ui_name($short));
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
function can_group() { return FALSE; }
|
56 |
|
|
} |