Project

General

Profile

Paste
Download (2 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / views / handlers / views_handler_filter_group_by_numeric.inc @ 8be7bf84

1
<?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

    
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function query() {
19
    $this->ensure_my_table();
20
    $field = $this->get_field();
21

    
22
    $info = $this->operators();
23
    if (!empty($info[$this->operator]['method'])) {
24
      $this->{$info[$this->operator]['method']}($field);
25
    }
26
  }
27

    
28
  /**
29
   * {@inheritdoc}
30
   */
31
  public function op_between($field) {
32
    $placeholder_min = $this->placeholder();
33
    $placeholder_max = $this->placeholder();
34
    if ($this->operator == 'between') {
35
      $this->query->add_having_expression($this->options['group'], "$field >= $placeholder_min", array($placeholder_min => $this->value['min']));
36
      $this->query->add_having_expression($this->options['group'], "$field <= $placeholder_max", array($placeholder_max => $this->value['max']));
37
    }
38
    else {
39
      $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']));
40
    }
41
  }
42

    
43
  /**
44
   * {@inheritdoc}
45
   */
46
  public function op_simple($field) {
47
    $placeholder = $this->placeholder();
48
    $this->query->add_having_expression($this->options['group'], "$field $this->operator $placeholder", array($placeholder => $this->value['value']));
49
  }
50

    
51
  /**
52
   * {@inheritdoc}
53
   */
54
  public function op_empty($field) {
55
    if ($this->operator == 'empty') {
56
      $operator = "IS NULL";
57
    }
58
    else {
59
      $operator = "IS NOT NULL";
60
    }
61

    
62
    $this->query->add_having_expression($this->options['group'], "$field $operator");
63
  }
64

    
65
  /**
66
   * {@inheritdoc}
67
   */
68
  public function ui_name($short = FALSE) {
69
    return $this->get_field(parent::ui_name($short));
70
  }
71

    
72
  /**
73
   * {@inheritdoc}
74
   */
75
  public function can_group() {
76
    return FALSE;
77
  }
78

    
79
}