Transform the input from a grouped filter into a standard filter.

When a filter is a group, find the set of operator and values that the choosen item represents, and inform views that a normal filter was submitted by telling the operator and the value selected.

The param $selected_group_id is only passed when the filter uses the checkboxes widget, and this function will be called for each item choosen in the checkboxes.

File

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

Class

views_handler_filter
Base class for filters.

Code

public function convert_exposed_input(&$input, $selected_group_id = NULL) {
  if ($this
    ->is_a_group()) {

    // If it is already defined the selected group, use it. Only valid when
    // the filter uses checkboxes for widget.
    if (!empty($selected_group_id)) {
      $selected_group = $selected_group_id;
    }
    else {
      $selected_group = $input[$this->options['group_info']['identifier']];
    }
    if ($selected_group == 'All' && !empty($this->options['group_info']['optional'])) {
      return NULL;
    }
    if ($selected_group != 'All' && empty($this->options['group_info']['group_items'][$selected_group])) {
      return FALSE;
    }
    if (isset($selected_group) && isset($this->options['group_info']['group_items'][$selected_group])) {
      $input[$this->options['expose']['operator']] = $this->options['group_info']['group_items'][$selected_group]['operator'];

      // Value can be optional, For example for 'empty' and 'not empty'
      // filters.
      if (!empty($this->options['group_info']['group_items'][$selected_group]['value'])) {
        $input[$this->options['expose']['identifier']] = $this->options['group_info']['group_items'][$selected_group]['value'];
      }
      $this->options['expose']['use_operator'] = TRUE;
      $this->group_info = $input[$this->options['group_info']['identifier']];
      return TRUE;
    }
    else {
      return FALSE;
    }
  }
}