views_handler_filter_group_by_numeric.inc

Definition of views_handler_filter_group_by_numeric.

File

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