Index: modules/toolbar/toolbar.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/toolbar/toolbar.module,v
retrieving revision 1.6
diff -u -r1.6 toolbar.module
--- modules/toolbar/toolbar.module	22 Aug 2009 14:34:22 -0000	1.6
+++ modules/toolbar/toolbar.module	23 Aug 2009 11:33:14 -0000
@@ -127,33 +127,39 @@
 }
 
 /**
- * Generate a links array from a menu tree array.
+ * Generates an array of links from a menu tree array.
  *
- * Based on menu_navigation_links(). Adds in path based IDs, icon placeholders
- * and overlay classes for the links.
+ * Based on menu_navigation_links(). It adds path based CSS classes for the
+ * menu items, icon placeholders and overlay classes for the links.
  */
 function toolbar_menu_navigation_links($tree) {
   $links = array();
   foreach ($tree as $item) {
     if (!$item['link']['hidden'] && $item['link']['access']) {
-      $class = '';
-      // Make sure we have a path specific ID in place, so we can attach icons
-      // and behaviors to the items.
-      $id = str_replace(array('/', '<', '>'), array('-', '', ''), $item['link']['href']);
-
       $link = $item['link']['localized_options'];
       $link['href'] = $item['link']['href'];
       // Add icon placeholder.
       $link['title'] = '<span class="icon"></span>' . $item['link']['title'];
-      // Add admin link ID and to-overlay class for the overlay.
-      $link['attributes'] = array('id' => 'toolbar-link-' . $id, 'class' => array('to-overlay'));
+      // Add to-overlay class for the overlay.
+      $link['attributes']['class'][] = 'to-overlay';
       $link['html'] = TRUE;
 
-      $class = ' path-' . $id;
+      // The querystring of the link is also used to build the path based
+      // CSS class, to be able to theme items pointing to the same path but
+      // with different GET parameters.
+      $full_href = $item['link']['href'] . (isset($item['link']['options']['query']) ? '?' . $item['link']['options']['query'] : '');
+      // Clean up the link desintation to prepare a path based CSS class.
+      $class = strtolower(preg_replace('/[^a-z0-9-_]+/i', '-', strtolower($full_href)));
+      $class = trim(preg_replace('/--+/', '-', $class, '-'), '-');
+      // Prefix the path based CSS class.
+      $class = 'path-' . $class;
       if (toolbar_in_active_trail($item['link']['href'])) {
         $class .= ' active-trail';
       }
-      $links['menu-' . $item['link']['mlid'] . $class] = $link;
+
+      // The keys of the array will be used for list item as classes
+      // by theme_links().
+      $links['menu-' . $item['link']['mlid'] . ' ' . $class] = $link;
     }
   }
   return $links;
