1.20.x views_handler_filter_combine.inc views_handler_filter_combine::query()

Add this filter to the query.

Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.

Overrides views_handler_filter_string::query

File

modules/views/handlers/views_handler_filter_combine.inc, line 52
Definition of views_handler_filter_combine.

Class

views_handler_filter_combine
Filter handler which allows to search on multiple fields.

Code

function query() {
  $this->view->_build('field');
  $fields = array();
  // Only add the fields if they have a proper field and table alias.
  foreach ($this->options['fields'] as $id) {
    // Field access checks may have removed this handler.
    if (!isset($this->view->field[$id])) {
      continue;
    }

    $field = $this->view->field[$id];
    // Always add the table of the selected fields to be sure a table alias
    // exists.
    $field->ensure_my_table();
    if (!empty($field->field_alias) && !empty($field->field_alias)) {
      $fields[] = "$field->table_alias.$field->real_field";
    }
  }
  if ($fields) {
    $count = count($fields);
    $separated_fields = array();
    foreach ($fields as $key => $field) {
      $separated_fields[] = $field;
      if ($key < $count - 1) {
        $separated_fields[] = "' '";
      }
    }
    $expression = implode(', ', $separated_fields);
    $expression = "CONCAT_WS(' ', $expression)";

    $info = $this->operators();
    if (!empty($info[$this->operator]['method'])) {
      $this->{$info[$this->operator]['method']}($expression);
    }
  }
}