views_handler_filter_boolean_operator_string.inc 950 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_filter_boolean_operator_string.
  5. */
  6. /**
  7. * Simple filter to handle matching of boolean values.
  8. *
  9. * This handler checks to see if a string field is empty (equal to '') or not.
  10. * It is otherwise identical to the parent operator.
  11. *
  12. * Definition items:
  13. * - label: (REQUIRED) The label for the checkbox.
  14. *
  15. * @ingroup views_filter_handlers
  16. */
  17. class views_handler_filter_boolean_operator_string extends views_handler_filter_boolean_operator {
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public function query() {
  22. $this->ensure_my_table();
  23. $where = "$this->table_alias.$this->real_field ";
  24. if (empty($this->value)) {
  25. $where .= "= ''";
  26. if ($this->accept_null) {
  27. $where = '(' . $where . " OR $this->table_alias.$this->real_field IS NULL)";
  28. }
  29. }
  30. else {
  31. $where .= "<> ''";
  32. }
  33. $this->query->add_where_expression($this->options['group'], $where);
  34. }
  35. }