function facetapi_item_list_build in Facet API 6
Recursive function that converts the render array into an array that can be passed to theme_item_list().
NOTE: In Drupal 6 theme_item_list() does not accept an array, so the wrapper function theme_facetapi_item_list() must be used.
Parameters
$build: The render array for the facet's items.
Return value
An array that can be passed the theme_item_list().
See also
1 call to facetapi_item_list_build()
- facetapi_widget_links in ./
facetapi.widget.inc - Builds items as array of links that can be passed to theme_item_list().
File
- ./
facetapi.widget.inc, line 298 - Widget callbacks and building functions.
Code
function facetapi_item_list_build($build) {
$items = array();
foreach ($build as $value => $item) {
$row = array();
$options = array(
'attributes' => array(),
'query' => drupal_query_string_encode($item['#query'], array(
'q',
'page',
)),
);
// We don't display children unless the parent is clicked.
if (!empty($item['#item_children'])) {
if ($item['#active']) {
$row['class'] = 'expanded';
$row['children'] = facetapi_item_list_build($item['#item_children']);
}
else {
$row['class'] = 'collapsed';
}
}
// Gets theme hook, adds last minute classes.
if ($item['#active']) {
$options['attributes']['class'] = 'active';
}
// Themes the link.
// @todo Change #value to #markup in D7.
$row['data'] = theme($item['#theme'], $item['#value'], $_GET['q'], $options, $item['#count']);
// Adds links to array.
$items[] = $row;
}
return $items;
}