class apachesolr_views_handler_filter_type in Apache Solr Views 6
Class for filtering by type.
Hierarchy
- class \apachesolr_views_handler_filter_type extends \views_handler_filter_in_operator
Expanded class hierarchy of apachesolr_views_handler_filter_type
1 string reference to 'apachesolr_views_handler_filter_type'
- apachesolr_views_views_data in ./
apachesolr_views.views.inc - Implementation of hook_views_data().
File
- handlers/
apachesolr_views_handler_filter_type.inc, line 7
View source
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;
}
}
/**
* Provide inclusive/exclusive matching
* TODO: cannot handle exlusive currently
*
* Perhaps use boolean logic to reverse the Not one of to One of all the rest?
*/
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']))) {
// 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);
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
apachesolr_views_handler_filter_type:: |
public | function | ||
apachesolr_views_handler_filter_type:: |
function | Provide inclusive/exclusive matching TODO: cannot handle exlusive currently | ||
apachesolr_views_handler_filter_type:: |
public | function |