function FacetapiAjaxWidgetCheckboxes::buildListItems in Ajax facets 7.2
Same name and namespace in other branches
- 7.3 plugins/facetapi/ajax_widget_checkboxes.inc \FacetapiAjaxWidgetCheckboxes::buildListItems()
- 7 plugins/facetapi/ajax_widget_checkboxes.inc \FacetapiAjaxWidgetCheckboxes::buildListItems()
Transforms the render array for use with theme_item_list().
The recursion allows this function to act on the various levels of a hierarchical data set.
Parameters
array $build: The items in the facet's render array being transformed.
Return value
array The "items" parameter for theme_item_list().
1 call to FacetapiAjaxWidgetCheckboxes::buildListItems()
- FacetapiAjaxWidgetCheckboxes::execute in plugins/
facetapi/ ajax_widget_checkboxes.inc - Implements FacetapiWidget::execute().
File
- plugins/
facetapi/ ajax_widget_checkboxes.inc, line 91 - The facetapi_links and facetapi_checkbox_links widget plugin classes.
Class
- FacetapiAjaxWidgetCheckboxes
- Widget that renders facets as a list of clickable links.
Code
function buildListItems($build) {
$have_active = FALSE;
// Builds rows.
$items = array();
$items_count = count($build);
$active_items = array();
foreach ($build as $value => $item) {
$row = array(
'class' => array(),
);
$attributes = array(
'class' => array(
'facet-multiselect-checkbox',
),
'data-facet' => $this->settings->facet,
);
// Respect current selection.
if ($item['#active']) {
$attributes['checked'] = 'checked';
$have_active = TRUE;
$active_items[] = $this->key . ':' . $item['#markup'];
}
$checkbox = array(
'#id' => 'ajax-facets-checkboxes-' . str_replace(array(
'_',
' ',
':',
), '-', $this->key) . '-' . drupal_strtolower($value),
'#name' => urlencode($this->key) . ':' . $value,
'#type' => 'checkbox',
'#title' => $item['#markup'] . theme('facetapi_count', array(
'count' => $item['#count'],
)),
'#attributes' => $attributes,
);
$row['data'] = drupal_render($checkbox);
if ($items_count == 1) {
$row['class'][] = 'single-leaf';
}
if (!empty($item['#item_children'])) {
if ($item['#active'] || !empty($this->settings->settings['show_expanded'])) {
$row['class'][] = 'expanded';
$row['children'] = $this
->buildListItems($item['#item_children']);
}
else {
$row['class'][] = 'collapsed';
}
}
$items[] = $row;
}
$this->jsSettings['haveActiveSelection'] = $this->settings->settings['have_active_selection'] = $have_active;
sort($active_items);
$this->jsSettings['activeItems'] = $active_items;
// Generate reset path on server side to make possible to use aliases.
if ($have_active) {
$this->jsSettings['resetPath'] = ajax_facets_facet_build_reset_path($this->facet
->getFacet(), $this->facet
->getAdapter());
}
return $items;
}