summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--i18n_menu/i18n_menu.module38
1 files changed, 23 insertions, 15 deletions
diff --git a/i18n_menu/i18n_menu.module b/i18n_menu/i18n_menu.module
index bfc1163..3c56008 100644
--- a/i18n_menu/i18n_menu.module
+++ b/i18n_menu/i18n_menu.module
@@ -401,21 +401,22 @@ function i18n_menu_localize_elements(&$elements) {
/**
* Return an array of localized links for a navigation menu.
+ *
+ * Localized version of menu_navigation_links()
*/
-function i18n_menu_menu_navigation_links($menu_name, $level = 0) {
+function i18n_menu_navigation_links($menu_name, $level = 0) {
// Don't even bother querying the menu table if no menu is specified.
if (empty($menu_name)) {
return array();
}
// Get the menu hierarchy for the current page.
- $tree = menu_tree_page_data($menu_name);
+ $tree = menu_tree_page_data($menu_name, $level + 1);
$tree = i18n_menu_localize_tree($tree);
// Go down the active trail until the right level is reached.
while ($level-- > 0 && $tree) {
- // Loop through the current level's items until we find one that is in
- // trail.
+ // Loop through the current level's items until we find one that is in trail.
while ($item = array_shift($tree)) {
if ($item['link']['in_active_trail']) {
// If the item is in the active trail, we continue in the subtree.
@@ -426,6 +427,7 @@ function i18n_menu_menu_navigation_links($menu_name, $level = 0) {
}
// Create a single level of links.
+ $router_item = menu_get_item();
$links = array();
foreach ($tree as $item) {
if (!$item['link']['hidden']) {
@@ -435,6 +437,14 @@ function i18n_menu_menu_navigation_links($menu_name, $level = 0) {
$l['title'] = $item['link']['title'];
if ($item['link']['in_active_trail']) {
$class = ' active-trail';
+ $l['attributes']['class'][] = 'active-trail';
+ }
+ // Normally, l() compares the href of every link with $_GET['q'] and sets
+ // the active class accordingly. But local tasks do not appear in menu
+ // trees, so if the current path is a local task, and this link is its
+ // tab root, then we have to set the class manually.
+ if ($item['link']['href'] == $router_item['tab_root_href'] && $item['link']['href'] != $_GET['q']) {
+ $l['attributes']['class'][] = 'active';
}
// Keyed with the unique mlid to generate classes in theme_links().
$links['menu-' . $item['link']['mlid'] . $class] = $l;
@@ -447,19 +457,17 @@ function i18n_menu_menu_navigation_links($menu_name, $level = 0) {
* Replace standard primary and secondary links.
*/
function i18n_menu_preprocess_page(&$vars) {
- if (theme_get_setting('toggle_primary_links')) {
- $vars['primary_links'] = i18n_menu_menu_navigation_links(variable_get('menu_primary_links_source', 'primary-links'));
- }
-
- // If the secondary menu source is set as the primary menu, we display the
- // second level of the primary menu.
-
- if (theme_get_setting('toggle_secondary_links')) {
- if (variable_get('menu_secondary_links_source', 'secondary-links') == variable_get('menu_primary_links_source', 'primary-links')) {
- $vars['secondary_links'] = i18n_menu_menu_navigation_links(variable_get('menu_primary_links_source', 'primary-links'), 1);
+ if (theme_get_setting('toggle_main_menu')) {
+ $vars['main_menu'] = i18n_menu_navigation_links(variable_get('menu_main_links_source', 'main-menu'));;
+ }
+ if (theme_get_setting('toggle_secondary_menu')) {
+ // If the secondary menu source is set as the primary menu, we display the
+ // second level of the primary menu.
+ if (variable_get('menu_secondary_links_source', 'user-menu') == variable_get('menu_main_links_source', 'main-menu')) {
+ $vars['secondary_menu'] = i18n_menu_navigation_links(variable_get('menu_main_links_source', 'main-menu'), 1);
}
else {
- $vars['secondary_links'] = i18n_menu_menu_navigation_links(variable_get('menu_secondary_links_source', 'secondary-links'), 0);
+ $vars['secondary_menu'] = i18n_menu_navigation_links(variable_get('menu_secondary_links_source', 'user-menu'), 0);
}
}
}