public function FacetapiAdapter::processActiveItems in Facet API 6.3
Same name and namespace in other branches
- 7.2 plugins/facetapi/adapter.inc \FacetapiAdapter::processActiveItems()
- 7 plugins/facetapi/adapter.inc \FacetapiAdapter::processActiveItems()
Processes active items.
See also
1 call to FacetapiAdapter::processActiveItems()
- FacetapiAdapter::setParams in plugins/
facetapi/ adapter.inc - Processes a raw array of active filters.
File
- plugins/
facetapi/ adapter.inc, line 193 - Adapter plugin and adapter related calsses.
Class
- FacetapiAdapter
- Abstract class extended by search backends that retrieves facet information from the database.
Code
public function processActiveItems() {
$this->activeItems = array(
'facet' => array(),
'filter' => array(),
);
// Groups enabled facets by facet alias.
$enabled_aliases = array();
foreach ($this
->getEnabledFacets() as $facet) {
$enabled_aliases[$facet['field alias']][] = $facet['name'];
$this->activeItems['facet'][$facet['name']] = array();
}
// Extracts valid filters from query string.
$filter_key = $this->urlProcessor
->getFilterKey();
$params = $this->urlProcessor
->getParams();
foreach ($params[$filter_key] as $pos => $filter) {
// Bails if an object or array.
if (!is_scalar($filter)) {
continue;
}
// Performs basic parsing of the filter.
$parts = explode(':', $filter, 2);
$field_alias = rawurldecode($parts[0]);
if (isset($parts[1]) && isset($enabled_aliases[$field_alias])) {
// Stores the base item.
$item = array(
'field alias' => $field_alias,
'value' => $parts[1],
'pos' => $pos,
);
// Stores active items in the global active item array.
$this->activeItems['filter'][$filter] = $item;
$this->activeItems['filter'][$filter]['facets'] = array();
// Stores active items per facet.
foreach ($enabled_aliases[$field_alias] as $facet_name) {
$item += $this->queryTypes[$facet_name]
->extract($item);
$this->activeItems['filter'][$filter]['facets'][] = $facet_name;
$this->activeItems['facet'][$facet_name][$parts[1]] = $item;
}
}
}
}