Project

General

Profile

Paste
Download (950 Bytes) Statistics
| Branch: | Revision:

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

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_handler_filter_boolean_operator_string.
6
 */
7

    
8
/**
9
 * Simple filter to handle matching of boolean values.
10
 *
11
 * This handler checks to see if a string field is empty (equal to '') or not.
12
 * It is otherwise identical to the parent operator.
13
 *
14
 * Definition items:
15
 * - label: (REQUIRED) The label for the checkbox.
16
 *
17
 * @ingroup views_filter_handlers
18
 */
19
class views_handler_filter_boolean_operator_string extends views_handler_filter_boolean_operator {
20

    
21
  /**
22
   * {@inheritdoc}
23
   */
24
  public function query() {
25
    $this->ensure_my_table();
26
    $where = "$this->table_alias.$this->real_field ";
27

    
28
    if (empty($this->value)) {
29
      $where .= "= ''";
30
      if ($this->accept_null) {
31
        $where = '(' . $where . " OR $this->table_alias.$this->real_field IS NULL)";
32
      }
33
    }
34
    else {
35
      $where .= "<> ''";
36
    }
37
    $this->query->add_where_expression($this->options['group'], $where);
38
  }
39

    
40
}