Index: edge.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/edge/edge.module,v retrieving revision 1.1 diff -u -p -r1.1 edge.module --- edge.module 2 Oct 2010 00:44:47 -0000 1.1 +++ edge.module 2 Oct 2010 22:47:53 -0000 @@ -6,3 +6,27 @@ * Cutting Edge functionality. */ +/** + * Implements hook_theme_registry_alter(). + */ +function edge_theme_registry_alter(&$callbacks) { + $path = drupal_get_path('module', 'edge'); + + // Apply replacement theme callbacks, but only if they have not been + // overridden. + $edge_theme = array('item_list'); + foreach ($edge_theme as $callback) { + if (isset($callbacks[$callback]) && $callbacks[$callback]['function'] == 'theme_' . $callback) { + $callbacks[$callback]['function'] = 'theme_edge_' . $callback; + $callbacks[$callback]['includes'][] = $path . '/edge.theme.inc'; + $callbacks[$callback]['file'] = 'edge.theme.inc'; + + // Perform additional callback-specific tweaks, if necessary. + switch ($callback) { + case 'item_list': + $callbacks[$callback]['variables']['title'] = ''; + break; + } + } + } +} Index: edge.theme.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/edge/edge.theme.inc,v retrieving revision 1.1 diff -u -p -r1.1 edge.theme.inc --- edge.theme.inc 2 Oct 2010 00:44:47 -0000 1.1 +++ edge.theme.inc 5 Oct 2010 00:18:10 -0000 @@ -6,3 +6,90 @@ * Cutting Edge theme functions. */ +/** + * Returns HTML for a list or nested list of items. + * + * @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'. + * - ...: All other key/value pairs are used as HTML attributes for the list + * item in 'data'. + * - 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_edge_item_list($variables) { + $items = $variables['items']; + $title = $variables['title']; + $type = $variables['type']; + $list_attributes = $variables['attributes']; + + $output = ''; + if ($items) { + $output .= '<' . $type . drupal_attributes($list_attributes) . '>'; + + $num_items = count($items); + $i = 0; + foreach ($items as $key => $item) { + $i++; + $attributes = array(); + + if (is_array($item)) { + $value = ''; + if (isset($item['data'])) { + $value .= $item['data']; + } + $attributes = array_diff_key($item, array('data' => 0, 'children' => 0)); + + // Append nested child list, if any. + if (isset($item['children'])) { + // List attributes are normally defined in the 'attributes' variable, + // but for nested child lists, all non-numeric keys in 'children' must + // be treated as child 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' => $type, + 'attributes' => $child_list_attributes, + )); + } + } + else { + $value = $item; + } + + $attributes['class'][] = ($i % 2 ? 'odd' : 'even'); + if ($i == 1) { + $attributes['class'][] = 'first'; + } + if ($i == $num_items) { + $attributes['class'][] = 'last'; + } + + $output .= '
' . check_plain(var_export($variables, TRUE)) . '' - . '
' . check_plain(var_export($output, TRUE)) . '' - . '
' . check_plain(var_export($expected, TRUE)) . '' + $this->verbose('Variables:' . '
' . check_plain(var_export($variables, TRUE)) . '' + . '
' . check_plain(var_export($output, TRUE)) . '' + . '
' . check_plain(var_export($expected, TRUE)) . '' . '