Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.341
diff -u -F^f -p -r1.341 menu.inc
--- includes/menu.inc	24 Aug 2009 01:49:41 -0000	1.341
+++ includes/menu.inc	4 Sep 2009 23:15:00 -0000
@@ -824,20 +824,19 @@ function menu_tree_output($tree) {
 
   $num_items = count($items);
   foreach ($items as $i => $data) {
-    $extra_class = array();
+    $link['attributes'] = array();
     if ($i == 0) {
-      $extra_class[] = 'first';
+      $link['attributes']['class'] = 'first';
     }
     if ($i == $num_items - 1) {
-      $extra_class[] = 'last';
+      $link['attributes']['class'] = 'last';
     }
-    $extra_class = implode(' ', $extra_class);
     $link = theme('menu_item_link', $data['link']);
     if ($data['below']) {
-      $output .= theme('menu_item', $link, $data['link']['has_children'], menu_tree_output($data['below']), $data['link']['in_active_trail'], $extra_class);
+      $output .= theme('menu_item', $link, $data['link']['has_children'], menu_tree_output($data['below']), $data['link']['in_active_trail']);
     }
     else {
-      $output .= theme('menu_item', $link, $data['link']['has_children'], '', $data['link']['in_active_trail'], $extra_class);
+      $output .= theme('menu_item', $link, $data['link']['has_children'], '', $data['link']['in_active_trail']);
     }
   }
   return $output ? theme('menu_tree', $output) : '';
@@ -1257,12 +1256,13 @@ function _menu_tree_data(&$links, $paren
  *
  * @ingroup themeable
  */
-function theme_menu_item_link($link) {
+function theme_menu_item_link($link = array()) {
   if (empty($link['localized_options'])) {
     $link['localized_options'] = array();
   }
+  $link['value'] = l($link['title'], $link['href'], $link['localized_options']);
 
-  return l($link['title'], $link['href'], $link['localized_options']);
+  return $link;
 }
 
 /**
@@ -1270,8 +1270,9 @@ function theme_menu_item_link($link) {
  *
  * @ingroup themeable
  */
-function theme_menu_tree($tree) {
-  return '<ul class="menu">' . $tree . '</ul>';
+function theme_menu_tree($tree, $attributes = array()) {
+  $attributes['class'][] = 'menu';
+  return '<ul' . drupal_attributes($attributes) . '>' . $tree . '</ul>';
 }
 
 /**
@@ -1285,7 +1286,8 @@ function theme_menu_tree($tree) {
  * @ingroup themeable
  *
  * @param $link
- *   The fully-formatted link for this menu item.
+ *   An array containing the fully-formatted link for this menu item and its
+ *   attributes
  * @param $has_children
  *   Boolean value indicating if this menu item has children.
  * @param $menu
@@ -1294,19 +1296,15 @@ function theme_menu_tree($tree) {
  * @param $in_active_trail
  *   Boolean determining if the current page is below the menu item in the
  *   menu system. Defaults to FALSE.
- * @param $extra_class
- *   Extra classes that should be added to the class of the list item.
- *   Defaults to NULL.
  */
-function theme_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
-  $class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
-  if (!empty($extra_class)) {
-    $class .= ' ' . $extra_class;
-  }
+function theme_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE) {
+  //print_r($link); die;
+  $link['attributes'] = array();
+  $link['attributes']['class'][] = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
   if ($in_active_trail) {
-    $class .= ' active-trail';
+    $link['attributes']['class'][] = 'active-trail';
   }
-  return '<li class="' . $class . '">' . $link . $menu . "</li>\n";
+  return '<li' . drupal_attributes($link['attributes']) . '">' . $link['value'] . $menu . "</li>\n";
 }
 
 /**
@@ -1315,7 +1313,11 @@ function theme_menu_item($link, $has_chi
  * @ingroup themeable
  */
 function theme_menu_local_task($link, $active = FALSE) {
-  return '<li ' . ($active ? 'class="active" ' : '') . '>' . $link . "</li>\n";
+  $link['attributes'] = array();
+  if ($active) {
+    $link['attributes']['class'][] = 'active';
+  }
+  return '<li' . drupal_attributes($link['attributes']) . '>' . $link['value'] . "</li>\n";
 }
 
 /**
@@ -1323,8 +1325,9 @@ function theme_menu_local_task($link, $a
  *
  * @ingroup themeable
  */
-function theme_menu_local_action($link) {
-  return '<li>' . $link . "</li>\n";
+function theme_menu_local_action($link = array()) {
+  $link['attributes'] = array();
+  return '<li' . drupal_attributes($link['attributes']) . '>' . $link['value'] . "</li>\n";
 }
 
 /**
@@ -1444,15 +1447,14 @@ function menu_navigation_links($menu_nam
   $links = array();
   foreach ($tree as $item) {
     if (!$item['link']['hidden']) {
-      $class = '';
       $l = $item['link']['localized_options'];
       $l['href'] = $item['link']['href'];
       $l['title'] = $item['link']['title'];
       if ($item['link']['in_active_trail']) {
-        $class = ' active-trail';
+        $item['attributes']['class'][] = 'active-trail';
       }
       // Keyed with the unique mlid to generate classes in theme_links().
-      $links['menu-' . $item['link']['mlid'] . $class] = $l;
+      $links['menu-' . $item['link']['mlid']] = $l;
     }
   }
   return $links;
@@ -1659,14 +1661,17 @@ function menu_tab_root_path() {
  *
  * @ingroup themeable
  */
-function theme_menu_local_tasks() {
+function theme_menu_local_tasks($attributes = array()) {
   $output = '';
+  $attributes['class'][] = 'tabs';
 
   if ($primary = menu_primary_local_tasks()) {
-    $output .= "<ul class=\"tabs primary\">\n" . $primary . "</ul>\n";
+    $attributes['class'][] = 'primary';
+    $output .= "<ul". drupal_attributes($attributes) .">\n" . $primary . "</ul>\n";
   }
   if ($secondary = menu_secondary_local_tasks()) {
-    $output .= "<ul class=\"tabs secondary\">\n" . $secondary . "</ul>\n";
+    $attributes['class'][] = 'secondary';
+    $output .= "<ul". drupal_attributes($attributes) .">\n" . $secondary . "</ul>\n";
   }
 
   return $output;
