You are here

public function apachesolr_views_handler_filter_type::query in Apache Solr Views 6

File

handlers/apachesolr_views_handler_filter_type.inc, line 32

Class

apachesolr_views_handler_filter_type
Class for filtering by type.

Code

public function query() {
  if (empty($this->value) && ($this->options['exposed'] && empty($this->options['expose']['optional']))) {

    // Add term that will yield no results
    $this->query
      ->add_filter('nid', apachesolr_views_query::escape_term('-1'));
  }
  else {
    foreach ($this->value as $type) {
      $filter .= " OR {$type}";
    }

    /**
     * This works, but breaks the facet blocks
     * $this->query->add_filter($this->real_field, substr($filter, 3));
     */
    $this
      ->get_value_options();
    foreach ($this->value_options as $type => $name) {
      if (!in_array($type, $this->value)) {
        $this->query
          ->add_filter($this->real_field, $type, TRUE);
      }
    }
  }
}