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