public function SearchApiGlossaryWidget::buildListItems in Search API AZ Glossary 7.2
Same name and namespace in other branches
- 7.3 search_api_glossary.module \SearchApiGlossaryWidget::buildListItems()
Converts the render array for passing to theme_item_list().
Parameters
array $build: The facet's render array.
Return value
array The "items" parameter for theme_item_list().
1 call to SearchApiGlossaryWidget::buildListItems()
- SearchApiGlossaryWidget::execute in ./
search_api_glossary.module - Renders the links.
File
- ./
search_api_glossary.module, line 410 - Search api glossary module file.
Class
Code
public function buildListItems($build) {
$items = array();
foreach ($build as $value => $item) {
$row = array(
'class' => array(),
);
if (!isset($item['#active'])) {
$item['#active'] = FALSE;
}
// Initializes variables passed to theme hook.
$variables = array(
'text' => $item['#markup'],
'path' => isset($item['#path']) ? $item['#path'] : current_path(),
'options' => array(
'attributes' => array(
'class' => $this
->getItemClasses(),
),
'html' => isset($item['#html']) ? $item['#html'] : FALSE,
'query' => isset($item['#query']) ? $item['#query'] : array(),
),
);
$display_count = $this->settings->settings['show_count'];
// Pass the display count setting
$variables['display_count'] = $display_count;
$variables['count'] = $item['#count'];
// If the item has no children, it is a leaf.
if (empty($item['#item_children'])) {
$row['class'][] = 'leaf';
}
else {
// If the item is active or the "show_expanded" setting is selected,
// show this item as expanded so we see its children.
if ($item['#active'] || !empty($this->settings->settings['show_expanded'])) {
$row['class'][] = 'expanded';
$row['children'] = $this
->buildListItems($item['#item_children']);
}
else {
$row['class'][] = 'collapsed';
}
}
// Gets theme hook, adds last minute classes.
if ($item['#active']) {
$class = 'facetapi-tabs-active active';
$item['#theme'] = 'search_api_glossary_facetapi_link_active_v2';
$row['class'][] = 'active';
}
else {
$class = 'facetapi-tabs-inactive inactive';
$item['#theme'] = 'search_api_glossary_facetapi_link_inactive_v2';
}
// Add class is the facet is empty.
if ($item['#count'] == 0) {
$row['class'][] = 'no-content';
}
$variables['options']['attributes']['class'][] = $class;
// Themes the link, adds row to items.
$row['data'] = theme($item['#theme'], $variables);
$items[] = $row;
}
return $items;
}