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