You are here

public function views_handler_filter::accept_exposed_input in Views (for Drupal 7) 7.3

Same name and namespace in other branches
  1. 6.3 handlers/views_handler_filter.inc \views_handler_filter::accept_exposed_input()
  2. 6.2 handlers/views_handler_filter.inc \views_handler_filter::accept_exposed_input()

Check to see if input from the exposed filters should change the behavior.

Overrides views_handler::accept_exposed_input

2 calls to views_handler_filter::accept_exposed_input()
views_handler_filter_in_operator::accept_exposed_input in handlers/views_handler_filter_in_operator.inc
Check to see if input from the exposed filters should change the behavior.
views_handler_filter_numeric::accept_exposed_input in handlers/views_handler_filter_numeric.inc
Do some minor translation of the exposed input.
2 methods override views_handler_filter::accept_exposed_input()
views_handler_filter_in_operator::accept_exposed_input in handlers/views_handler_filter_in_operator.inc
Check to see if input from the exposed filters should change the behavior.
views_handler_filter_numeric::accept_exposed_input in handlers/views_handler_filter_numeric.inc
Do some minor translation of the exposed input.

File

handlers/views_handler_filter.inc, line 1377
Definitions of views_handler_filter and views_handler_filter_broken.

Class

views_handler_filter
Base class for filters.

Code

public function accept_exposed_input($input) {
  if (empty($this->options['exposed'])) {
    return TRUE;
  }
  if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id']) && isset($input[$this->options['expose']['operator_id']])) {
    $this->operator = $input[$this->options['expose']['operator_id']];
  }
  if (!empty($this->options['expose']['identifier'])) {
    if (isset($input[$this->options['expose']['identifier']])) {
      $value = $input[$this->options['expose']['identifier']];
    }
    else {
      return FALSE;
    }

    // Various ways to check for the absence of non-required input.
    if (empty($this->options['expose']['required'])) {
      if ($this->operator == 'empty' || $this->operator == 'not empty') {
        if (is_array($value) && array_key_exists('value', $value)) {
          $value = $value['value'];
        }
        $this->operator = $this->operator == 'empty' && empty($value) || $this->operator == 'not empty' && !empty($value) ? 'not empty' : 'empty';
      }
      if ($value == 'All' || $value === array()) {
        return FALSE;
      }
      if (!empty($this->always_multiple) && $value === '') {
        return FALSE;
      }
    }
    if (isset($value)) {
      $this->value = $value;
      if (empty($this->always_multiple) && empty($this->options['expose']['multiple'])) {
        $this->value = array(
          $value,
        );
      }
    }
    else {
      return FALSE;
    }
  }
  return TRUE;
}