views_handler_filter_equality.inc 1013 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_filter_equality.
  5. */
  6. /**
  7. * Simple filter to handle equal to / not equal to filters.
  8. *
  9. * @ingroup views_filter_handlers
  10. */
  11. class views_handler_filter_equality extends views_handler_filter {
  12. /**
  13. * Exposed filter options.
  14. */
  15. public $always_multiple = TRUE;
  16. /**
  17. * Provide simple equality operator.
  18. */
  19. public function operator_options() {
  20. return array(
  21. '=' => t('Is equal to'),
  22. '!=' => t('Is not equal to'),
  23. );
  24. }
  25. /**
  26. * Provide a simple textfield for equality.
  27. */
  28. public function value_form(&$form, &$form_state) {
  29. $form['value'] = array(
  30. '#type' => 'textfield',
  31. '#title' => t('Value'),
  32. '#size' => 30,
  33. '#default_value' => $this->value,
  34. );
  35. if (!empty($form_state['exposed'])) {
  36. $identifier = $this->options['expose']['identifier'];
  37. if (!isset($form_state['input'][$identifier])) {
  38. $form_state['input'][$identifier] = $this->value;
  39. }
  40. }
  41. }
  42. }