function FacetapiAdapter::addActiveFilters in Facet API 6.3
Same name and namespace in other branches
- 7.2 plugins/facetapi/adapter.inc \FacetapiAdapter::addActiveFilters()
- 7 plugins/facetapi/adapter.inc \FacetapiAdapter::addActiveFilters()
Adds facet query type plugins to the queue and invokes the execute() hook to allow for the backend to add filters to its native query object.
Parameters
mixed $query: The backend's native object.
File
- plugins/
facetapi/ adapter.inc, line 465 - Adapter plugin and adapter related calsses.
Class
- FacetapiAdapter
- Abstract class extended by search backends that retrieves facet information from the database.
Code
function addActiveFilters($query) {
module_load_include('inc', 'facetapi', 'facetapi.callbacks');
facetapi_add_active_searcher($this->info['name']);
// Runs initActiveFilters hook, finds active facets.
$this
->initActiveFilters($query);
foreach ($this
->getEnabledFacets() as $facet) {
$settings = $this
->getFacet($facet)
->getSettings();
// Invoke the dependency plugins.
$display = TRUE;
foreach ($facet['dependency plugins'] as $id) {
$class = ctools_plugin_load_class('facetapi', 'dependencies', $id, 'handler');
$plugin = new $class($id, $this, $facet, $settings, $this->activeItems['facet']);
if (NULL !== ($return = $plugin
->execute())) {
$display = $return;
}
}
// Stores whether this facet passed its dependencies.
$this->dependenciesPassed[$facet['name']] = $display;
// Add query type plugin if dependencies were met, otherwise remove the
// facet's active items so they don't display in the current search block
// or appear as active in the breadcrumb trail.
if ($display && $this->queryTypes[$facet['name']]) {
$this->queryTypes[$facet['name']]
->execute($query);
}
else {
foreach ($this->activeItems['facet'][$facet['name']] as $item) {
$this->urlProcessor
->removeParam($item['pos']);
$filter = $item['field alias'] . ':' . $item['value'];
unset($this->activeItems['filter'][$filter]);
}
$this->activeItems['facet'][$facet['name']] = array();
}
}
}