You are here

public function CurrentSearchItem::getItemValues in Facet API 7

Same name and namespace in other branches
  1. 6.3 contrib/current_search/plugins/current_search/item.inc \CurrentSearchItem::getItemValues()
  2. 7.2 contrib/current_search/plugins/current_search/item.inc \CurrentSearchItem::getItemValues()

Helper function that returns the item's value and its children.

Parameters

array $item: The item as returned by FacetapiAdapter::getAllActiveItems().

FacetapiAdapter $adapter: The adapter object associated with the searcher executing the search.

Return value

array An array of the item's value and all its children.

3 calls to CurrentSearchItem::getItemValues()
CurrentSearchItem::getFacetPath in contrib/current_search/plugins/current_search/item.inc
Helper function that returns a facet's path.
CurrentSearchItem::getQueryString in contrib/current_search/plugins/current_search/item.inc
Helper function that returns a facet's query string.
CurrentSearchItemActive::execute in contrib/current_search/plugins/current_search/item_active.inc
Implements CurrentSearchItem::execute().

File

contrib/current_search/plugins/current_search/item.inc, line 254
Base current search item plugin class.

Class

CurrentSearchItem
Abstract class extended by current search item plugins.

Code

public function getItemValues(array $item, FacetapiAdapter $adapter) {
  if (!isset($this->itemValues[$item['pos']])) {

    // Initializes items, sets $values as a reference for code readability.
    $this->itemValues[$item['pos']] = array();
    $values =& $this->itemValues[$item['pos']];

    // Gets all children so they are deactivated as well.
    foreach ($item['facets'] as $facet_name) {
      $active_children = $adapter
        ->getProcessor($facet_name)
        ->getActiveChildren($item['value']);
      $values = array_merge($values, $active_children);
    }

    // Handle the case of a URL value that matches no actual facet values.
    // Otherwise, it can't be unclicked.
    if (!in_array($item['value'], $values)) {
      $values[] = $item['value'];
    }
  }
  return $this->itemValues[$item['pos']];
}