apachesolr_views_handler_filter_type.inc in Apache Solr Views 6
File
handlers/apachesolr_views_handler_filter_type.inc
View source
<?php
class apachesolr_views_handler_filter_type extends views_handler_filter_in_operator {
public function get_value_options() {
if (!isset($this->value_options)) {
$this->value_title = t('Node type');
$types = node_get_types();
foreach ($types as $type => $info) {
$options[$type] = $info->name;
}
$this->value_options = $options;
}
}
function operator_options() {
return array(
'in' => t('Is one of'),
);
}
public function query() {
if (empty($this->value) && ($this->options['exposed'] && empty($this->options['expose']['optional']))) {
$this->query
->add_filter('nid', apachesolr_views_query::escape_term('-1'));
}
else {
foreach ($this->value as $type) {
$filter .= " OR {$type}";
}
$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);
}
}
}
}
}