Example #1
0
 /**
  * Determines if the input from a filter should change the generated query.
  *
  * @param array $input
  *   The exposed data for this view.
  *
  * @return bool
  *   TRUE if the input for this filter should be included in the view query.
  *   FALSE otherwise.
  */
 public function acceptExposedInput($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'])) {
         $value = $input[$this->options['expose']['identifier']];
         // 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') && $value === '') {
                 $value = ' ';
             }
             if ($this->operator != 'empty' && $this->operator != 'not empty') {
                 if ($value == 'All' || $value === array()) {
                     return FALSE;
                 }
                 // If checkboxes are used to render this filter, do not include the
                 // filter if no options are checked.
                 if (is_array($value) && Checkboxes::detectEmptyCheckboxes($value)) {
                     return FALSE;
                 }
             }
             if (!empty($this->alwaysMultiple) && $value === '') {
                 return FALSE;
             }
         }
         if (isset($value)) {
             $this->value = $value;
             if (empty($this->alwaysMultiple) && empty($this->options['expose']['multiple']) && !is_array($value)) {
                 $this->value = array($value);
             }
         } else {
             return FALSE;
         }
     }
     return TRUE;
 }