***************
*** 127,159 ****
}
/**
- * Generate a links array from a menu tree array.
*
- * Based on menu_navigation_links(). Adds in path based IDs, 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'] = '' . $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'));
$link['html'] = TRUE;
- $class = ' path-' . $id;
if (toolbar_in_active_trail($item['link']['href'])) {
$class .= ' active-trail';
}
- $links['menu-' . $item['link']['mlid'] . $class] = $link;
}
}
return $links;
--- 127,165 ----
}
/**
+ * Generates an array of links from a menu tree array.
*
+ * 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']) {
$link = $item['link']['localized_options'];
$link['href'] = $item['link']['href'];
// Add icon placeholder.
$link['title'] = '' . $item['link']['title'];
+ // Add to-overlay class for the overlay.
+ $link['attributes']['class'][] = 'to-overlay';
$link['html'] = TRUE;
+ // 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';
}
+
+ // 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;