From 60513799a1c483b3a28c0243665d7c1f6f05a2ae Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 30 Jun 2004 20:45:45 +0000 Subject: - Patch #8941 by JonBob: allow local tasks to be ordered by weight, as well as simplifying the theming of local tasks so they can be more easily rendered in a non-tab manner. --- includes/menu.inc | 121 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 74 insertions(+), 47 deletions(-) (limited to 'includes') diff --git a/includes/menu.inc b/includes/menu.inc index 9021c8c80..f6d12bf50 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -103,9 +103,20 @@ function menu_get_menu() { global $user; if (!isset($_menu['items'])) { + // _menu_build() may indirectly call this function, so prevent infinite loops. + $_menu['items'] = array(); _menu_build(); } + // Don't cache the local task tree, as it varies by location and tasks are + // allowed to be dynamically determined. + if (!isset($_menu['local tasks'])) { + // _menu_build_local_tasks() may indirectly call this function, so prevent + // infinite loops. + $_menu['local tasks'] = array(); + _menu_build_local_tasks(); + } + return $_menu; } @@ -420,32 +431,23 @@ function theme_menu_item($mid) { * them as tabs. */ function theme_menu_local_tasks() { + $menu = menu_get_menu(); + $output = ''; + if (count($menu['local tasks'][0]['children'])) { + $output .= "\n"; - if ($mid = menu_get_active_nontask_item()) { - $menu = menu_get_menu(); - $active_mid = $mid; - - if ($children = $menu['items'][$mid]['children']) { - foreach ($menu['items'][$mid]['children'] as $cid) { - if (($menu['items'][$cid]['type'] & MENU_IS_LOCAL_TASK) && _menu_item_is_accessible($cid)) { - if (menu_in_active_trail($cid)) { - $tabs[] = theme('menu_local_task', $cid, TRUE); - $active_mid = $cid; - } - else { - $tabs[] = theme('menu_local_task', $cid, FALSE); - } + foreach ($menu['local tasks'][0]['children'] as $mid) { + if (menu_in_active_trail($mid) && count($menu['local tasks'][$mid]['children'])) { + $output .= "