# This patch file was generated by NetBeans IDE # This patch can be applied using context Tools: Apply Diff Patch action on respective folder. # It uses platform neutral UTF-8 encoding. # Above lines and this line are ignored by the patching process. Index: includes/common.inc --- includes/common.inc Base (1.770) +++ includes/common.inc Locally Modified (Based On 1.770) @@ -2885,6 +2886,9 @@ 'item_list' => array( 'arguments' => array('items' => array(), 'title' => NULL, 'type' => 'ul', 'attributes' => NULL), ), + 'item_list_item' => array( + 'arguments' => array('data' => NULL, 'attributes' => NULL), + ), 'more_help_link' => array( 'arguments' => array('url' => NULL), ), Index: includes/theme.inc --- includes/theme.inc Base (1.424) +++ includes/theme.inc Locally Modified (Based On 1.424) @@ -1473,59 +1458,96 @@ * All other elements are treated as attributes of the list item element. * @param $title * The title of the list. - * @param $attributes - * The attributes applied to the list element. * @param $type - * The type of list to return (e.g. "ul", "ol") + * The type of list to return (e.g. "ul", "ol"). + * @param $attributes + * The attributes to be applied to the list element. * @return * A string containing the list output. */ function theme_item_list($items = array(), $title = NULL, $type = 'ul', $attributes = NULL) { - $output = '
'; + // We build the output from the inside, wrapping it with opening and closing tags. + $output = "<$type" . drupal_attributes($attributes) . '>' . _theme_item_list($items) . ""; if (isset($title)) { - $output .= '

' . $title . '

'; + $output = "

$title

$output"; } + + return '
' . $output . '
'; +} - if (!empty($items)) { - $output .= "<$type" . drupal_attributes($attributes) . '>'; - $num_items = count($items); - foreach ($items as $i => $item) { - $attributes = array(); - $children = array(); - if (is_array($item)) { - foreach ($item as $key => $value) { - if ($key == 'data') { +/** + * Helper to theme list of items for theme_item_list(). + * + * @param $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. + * @return + * A string containing the list output. + */ +function _theme_item_list($items = array()) { + $items_out = array(); + $num_items = count($items); + $i = 0; + foreach ($items as $item) { + $i++; + $attributes = array(); + $children = array(); + if (is_array($item)) { + $data = ''; + foreach ($item as $key => $value) { + switch ($key) { + case 'data': $data = $value; - } - elseif ($key == 'children') { + break; + + case 'children': $children = $value; - } - else { + break; + + default: $attributes[$key] = $value; - } } } - else { - $data = $item; - } - if (count($children) > 0) { - $data .= theme_item_list($children, NULL, $type, $attributes); // Render nested list - } - if ($i == 0) { - $attributes['class'] = empty($attributes['class']) ? 'first' : ($attributes['class'] . ' first'); - } - if ($i == $num_items - 1) { - $attributes['class'] = empty($attributes['class']) ? 'last' : ($attributes['class'] . ' last'); - } - $output .= '' . $data . "\n"; } - $output .= ""; + else { + $data = $item; + } + if (count($children) > 0) { + $data .= theme_item_list($children, NULL, $type, $attributes); // Render nested list + } + + $zebra = ($i & 1) ? 'odd' : 'even'; + $attributes['class'] = empty($attributes['class']) ? $zebra : $attributes['class'] . ' ' . $zebra; + if ($i == 0) { + $attributes['class'] .= ' first'; + } + if ($i == $num_items - 1) { + $attributes['class'] .= ' last'; + } + $items_out[] = theme('item_list_item', $data, $attributes); } - $output .= '
'; - return $output; + + return "\n" . implode("\n", $items_out) . "\n"; } /** + * Return a themed item for a list. + * + * @param $data + * Data containing HTML for the item. + * @param $attributes + * The attributes to apply to the item. + * @return + * A string containing the item. + */ +function theme_item_list_item($data = NULL, $attributes = NULL) { + return '' . $data . ''; +} + +/** * Returns code that emits the 'more help'-link. */ function theme_more_help_link($url) {