0 && $tree_page) { // Loop through the current level's items until we find one that is in trail. while ($item = array_shift($tree_page)) { if ($item['link']['in_active_trail']) { // If the item is in the active trail, we continue in the subtree. $tree_page = empty($item['below']) ? array() : $item['below']; break; } } } return themename_navigation_links_level($tree_page, $tree_all); } /** * Helper function for themename_navigation_links to recursively create an array of links. * (Both trees are required in order to include every menu item and active trail info.) */ function themename_navigation_links_level($tree_page, $tree_all) { $links = array(); foreach ($tree_all as $key => $item) { $item_page = $tree_page[$key]; $item_all = $tree_all[$key]; if (!$item_all['link']['hidden']) { $class = ''; $l = $item_all['link']['localized_options']; $l['href'] = $item_all['link']['href']; $l['title'] = $item_all['link']['title']; if ($item_page['link']['in_active_trail']) { $class = ' active-trail'; } if ($item_all['below']) { $l['children'] = themename_navigation_links_level($item_page['below'], $item_all['below']); } // Keyed with the unique mlid to generate classes in theme_links(). $links['menu-'. $item_all['link']['mlid'] . $class] = $l; } } return $links; } /** * Helper function to retrieve the primary links using themename_navigation_links(). */ function themename_primary_links() { return themename_navigation_links(variable_get('menu_primary_links_source', 'primary-links')); } /** * Return a themed set of links. (Extended to support multidimensional arrays of links.) * * @param $links * A keyed array of links to be themed. * @param $attributes * A keyed array of attributes * @return * A string containing an unordered list of links. */ function themename_links($links, $attributes = array('class' => 'links')) { $output = ''; if (count($links) > 0) { $output = ''; $num_links = count($links); $i = 1; foreach ($links as $key => $link) { $class = $key; // Add first, last and active classes to the list of links to help out themers. if ($i == 1) { $class .= ' first'; } if ($i == $num_links) { $class .= ' last'; } if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '' && drupal_is_front_page()))) { $class .= ' active'; } // Added: if the link has child items, add a haschildren class if (isset($link['children'])) { $class .= ' haschildren'; } $output .= ' $class)) .'>'; if (isset($link['href'])) { // Pass in $link as $options, they share the same keys. $output .= l($link['title'], $link['href'], $link); } else if (!empty($link['title'])) { // Some links are actually not links, but we wrap these in for adding title and class attributes if (empty($link['html'])) { $link['title'] = check_plain($link['title']); } $span_attributes = ''; if (isset($link['attributes'])) { $span_attributes = drupal_attributes($link['attributes']); } $output .= ''. $link['title'] .''; } // Added: if the link has child items, print them out recursively if (isset($link['children'])) { $output .= "\n" . theme('links', $link['children'], array('class' =>'sublinks')); } $i++; $output .= "\n"; } $output .= ''; } return $output; }