diff --git facetapi.module facetapi.module index c11218f..a22d8c1 100644 --- facetapi.module +++ facetapi.module @@ -287,6 +287,10 @@ function facetapi_theme() { 'render element' => 'element', 'file' => 'facetapi.admin.inc', ), + 'facetapi_item_list' => array( + 'variables' => array('items' => array(), 'title' => NULL, 'type' => 'ul', 'attributes' => array()), + 'file' => 'facetapi.theme.inc', + ), ); } diff --git facetapi.theme.inc facetapi.theme.inc index 8eccab2..03a61dc 100644 --- facetapi.theme.inc +++ facetapi.theme.inc @@ -33,7 +33,7 @@ function theme_facetapi_title($variables) { } /** - * Returns HTML for an active facet item. + * Returns HTML for an inactive facet item. * * @param $variables * An associative array containing the keys 'text', 'path', 'options', and @@ -43,6 +43,10 @@ function theme_facetapi_title($variables) { * @ingroup themeable */ function theme_facetapi_link_inactive($variables) { + if (isset($variables[''])) { + $variables = $variables['']; + } + // Builds accessible markup. // @see http://drupal.org/node/1316580 $accessible_vars = array( @@ -57,7 +61,7 @@ function theme_facetapi_link_inactive($variables) { // Adds count to link if one was passed. if (isset($variables['count'])) { - $variables['text'] .= ' ' . theme('facetapi_count', $variables); + $variables['text'] .= ' ' . theme('facetapi_count', array('count' => $variables['count'])); } // Resets link text, sets to options to HTML since we already sanitized the @@ -81,7 +85,7 @@ function theme_facetapi_count($variables) { } /** - * Returns HTML for an inactive facet item. + * Returns HTML for an active facet item. * * @param $variables * An associative array containing the keys 'text', 'path', and 'options'. See @@ -90,6 +94,9 @@ function theme_facetapi_count($variables) { * @ingroup themeable */ function theme_facetapi_link_active($variables) { + if (isset($variables[''])) { + $variables = $variables['']; + } // Sanitizes the link text if necessary. $sanitize = empty($variables['options']['html']); @@ -143,3 +150,74 @@ function theme_facetapi_accessible_markup($variables) { $text = ($variables['active']) ? t('Remove @text filter', $vars) : t('Apply @text filter', $vars); return '' . $text . ''; } + +/** + * Returns HTML for a list or nested list of items. + * + * An almost exact copy of theme_item_list, except is uses renderable arrays properly. + * See http://drupal.org/node/891112 Once that issue is resolved in core, this function + * can go away. + * + * @param $variables + * An associative array containing: + * - items: An array of items to be displayed in the list. If an item is a + * string, then it is used as is. If an item is an array, then the "data" + * element of the array is used as the contents of the list item. If an item + * is an array with a "children" element, those children are displayed in a + * nested list. All other elements are treated as attributes of the list + * item element. + * - title: The title of the list. + * - type: The type of list to return (e.g. "ul", "ol"). + * - attributes: The attributes applied to the list element. + */ +function theme_facetapi_item_list($variables) { + $items = $variables['items']; + $title = $variables['title']; + $type = $variables['type']; + $attributes = $variables['attributes']; + + $output = '