views_handler_filter_group_by_numeric.inc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. /**
  13. * {@inheritdoc}
  14. */
  15. public function query() {
  16. $this->ensure_my_table();
  17. $field = $this->get_field();
  18. $info = $this->operators();
  19. if (!empty($info[$this->operator]['method'])) {
  20. $this->{$info[$this->operator]['method']}($field);
  21. }
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function op_between($field) {
  27. $placeholder_min = $this->placeholder();
  28. $placeholder_max = $this->placeholder();
  29. if ($this->operator == 'between') {
  30. $this->query->add_having_expression($this->options['group'], "$field >= $placeholder_min", array($placeholder_min => $this->value['min']));
  31. $this->query->add_having_expression($this->options['group'], "$field <= $placeholder_max", array($placeholder_max => $this->value['max']));
  32. }
  33. else {
  34. $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']));
  35. }
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function op_simple($field) {
  41. $placeholder = $this->placeholder();
  42. $this->query->add_having_expression($this->options['group'], "$field $this->operator $placeholder", array($placeholder => $this->value['value']));
  43. }
  44. /**
  45. * {@inheritdoc}
  46. */
  47. public function op_empty($field) {
  48. if ($this->operator == 'empty') {
  49. $operator = "IS NULL";
  50. }
  51. else {
  52. $operator = "IS NOT NULL";
  53. }
  54. $this->query->add_having_expression($this->options['group'], "$field $operator");
  55. }
  56. /**
  57. * {@inheritdoc}
  58. */
  59. public function ui_name($short = FALSE) {
  60. return $this->get_field(parent::ui_name($short));
  61. }
  62. /**
  63. * {@inheritdoc}
  64. */
  65. public function can_group() {
  66. return FALSE;
  67. }
  68. }