diff --git a/core/includes/pager.inc b/core/includes/pager.inc index 75dcf82..90b8ab2 100644 --- a/core/includes/pager.inc +++ b/core/includes/pager.inc @@ -201,14 +201,14 @@ function theme_pager($variables) { if ($pager_total[$element] > 1) { if ($li_first) { $items[] = array( - 'class' => array('pager-first'), - 'data' => $li_first, + '#li_attributes' => array('class' => array('pager-first')), + '#markup' => $li_first, ); } if ($li_previous) { $items[] = array( - 'class' => array('pager-previous'), - 'data' => $li_previous, + '#li_attributes' => array('class' => array('pager-previous')), + '#markup' => $li_previous, ); } @@ -216,49 +216,49 @@ function theme_pager($variables) { if ($i != $pager_max) { if ($i > 1) { $items[] = array( - 'class' => array('pager-ellipsis'), - 'data' => '…', + '#li_attributes' => array('class' => array('pager-ellipsis')), + '#markup' => '…', ); } // Now generate the actual pager piece. for (; $i <= $pager_last && $i <= $pager_max; $i++) { if ($i < $pager_current) { $items[] = array( - 'class' => array('pager-item'), - 'data' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => ($pager_current - $i), 'parameters' => $parameters)), + '#li_attributes' => array('class' => array('pager-item')), + '#markup' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => ($pager_current - $i), 'parameters' => $parameters)), ); } if ($i == $pager_current) { $items[] = array( - 'class' => array('pager-current'), - 'data' => $i, + '#li_attributes' => array('class' => array('pager-current')), + '#markup' => $i, ); } if ($i > $pager_current) { $items[] = array( - 'class' => array('pager-item'), - 'data' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => ($i - $pager_current), 'parameters' => $parameters)), + '#li_attributes' => array('class' => array('pager-item')), + '#markup' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => ($i - $pager_current), 'parameters' => $parameters)), ); } } if ($i < $pager_max) { $items[] = array( - 'class' => array('pager-ellipsis'), - 'data' => '…', + '#li_attributes' => array('class' => array('pager-ellipsis')), + '#markup' => '…', ); } } // End generation. if ($li_next) { $items[] = array( - 'class' => array('pager-next'), - 'data' => $li_next, + '#li_attributes' => array('class' => array('pager-next')), + '#markup' => $li_next, ); } if ($li_last) { $items[] = array( - 'class' => array('pager-last'), - 'data' => $li_last, + '#li_attributes' => array('class' => array('pager-last')), + '#markup' => $li_last, ); } return '

' . t('Pages') . '

' . theme('item_list', array( diff --git a/core/includes/theme.inc b/core/includes/theme.inc index cc29a98..138b1f9 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2078,15 +2078,9 @@ function theme_mark($variables) { * * @param $variables * An associative array containing: - * - items: A list of items to render. String values are rendered as is. Each - * item can also be an associative array containing: - * - data: The string content of the list item. - * - children: A list of nested child items to render that behave - * identically to 'items', but any non-numeric string keys are treated as - * HTML attributes for the child list that wraps 'children'. - * - type: The type of list to return (e.g. "ul", "ol"). - * Any other key/value pairs are used as HTML attributes for the list item - * in 'data'. + * - items: A list of items to render. Allowed values are strings or + * renderable arrays. Additionally, the key #li_attributes can be used to + * specify attributes for the li tag. * - 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. @@ -2103,38 +2097,13 @@ function theme_item_list($variables) { $num_items = count($items); $i = 0; - foreach ($items as $key => $item) { + foreach ($items as $item) { $i++; - $attributes = array(); - + // @todo Support attributes on the li tag? How? if (is_array($item)) { - $value = ''; - if (isset($item['data'])) { - $value .= $item['data']; - } - $attributes = array_diff_key($item, array('data' => 0, 'children' => 0, 'type' => 0)); - - // Append nested child list, if any. - if (isset($item['children'])) { - // HTML attributes for the outer list are defined in the 'attributes' - // theme variable, but not inherited by children. For nested lists, - // all non-numeric keys in 'children' are used as list attributes. - $child_list_attributes = array(); - foreach ($item['children'] as $child_key => $child_item) { - if (is_string($child_key)) { - $child_list_attributes[$child_key] = $child_item; - unset($item['children'][$child_key]); - } - } - $value .= theme('item_list', array( - 'items' => $item['children'], - 'type' => (isset($item['type']) ? $item['type'] : $type), - 'attributes' => $child_list_attributes, - )); - } - } - else { - $value = $item; + $attributes = isset($item['#li_attributes']) ? $item['#li_attributes'] : array(); + unset($item['#li_attributes']); + $item = drupal_render($item); } $attributes['class'][] = ($i % 2 ? 'odd' : 'even'); @@ -2145,7 +2114,7 @@ function theme_item_list($variables) { $attributes['class'][] = 'last'; } - $output .= '' . $value . ''; + $output .= '' . $item . ''; } $output .= ""; } diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php index 0e33ef2..2f1aaaa 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php @@ -44,25 +44,28 @@ function testItemList() { ); $variables['items'] = array( 'a', + // Items can be render arrays with their own attributes. array( - 'data' => 'b', - 'children' => array( - 'c', - // Nested children may use additional attributes. - array( - 'data' => 'd', - 'class' => array('dee'), + '#li_attributes' => array( + 'id' => 'bee', + ), + 'item' => array('#markup' => 'b'), + 'childlist' => array( + '#theme' => 'item_list', + '#attributes' => array('id' => 'childlist'), + '#type' => 'ol', + '#items' => array( + 'c', + array( + '#markup' => 'd', + '#li_attributes' => array('class' => array('dee')), + ), ), - // Any string key is treated as child list attribute. - 'id' => 'childlist', ), - // Any other keys are treated as item attributes. - 'id' => 'bee', - 'type' => 'ol', ), array( - 'data' => 'e', - 'id' => 'E', + '#markup' => 'e', + '#li_attributes' => array('id' => 'E'), ), ); $inner = '
    '; diff --git a/core/modules/system/system.module b/core/modules/system/system.module index ea3dadc..dbfee54 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -4168,7 +4168,7 @@ function theme_exposed_filters($variables) { if (isset($form['current'])) { $items = array(); foreach (element_children($form['current']) as $key) { - $items[] = drupal_render($form['current'][$key]); + $items[] = $form['current'][$key]; } $output .= theme('item_list', array('items' => $items, 'attributes' => array('class' => array('clearfix', 'current-filters')))); }