From b4552cd9770a0f6084c11e3e2a62909c1c76c956 Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Sat, 10 Dec 2005 20:01:55 +0000 Subject: [PATCH] - Patch #40512 by Richard: fixed coding style + performance improvements. --- includes/menu.inc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/includes/menu.inc b/includes/menu.inc index dbf485ab5e81..aecc7fcc6618 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -780,7 +780,7 @@ function menu_primary_links($start_level = 1, $pid = 0) { } } - // special case - provide link to admin/menu if primary links is empty. + // Special case - provide link to admin/menu if primary links is empty. if (is_null($links) && $start_level == 1 && $pid == variable_get('menu_primary_menu', 0)) { $links['1-1'] = l(t('edit primary links'),'admin/menu'); } @@ -875,12 +875,11 @@ function _menu_get_active_trail() { */ function _menu_get_active_trail_in_submenu($pid) { static $trails; - static $built; - if (!$built) { + if (!isset($trails)) { // Find all menu items which point to the current node and for each // follow the parents up the chain to build an active trail. - $built = TRUE; + $trails = array(); $menu = menu_get_menu(); $path = $_GET['q']; $count = 0; @@ -893,7 +892,7 @@ function _menu_get_active_trail_in_submenu($pid) { array_unshift($trails[$count], $mid); $mid = $menu['items'][$mid]['pid']; } - $count ++; + $count ++; } } $path = substr($path, 0, strrpos($path, '/')); @@ -901,13 +900,14 @@ function _menu_get_active_trail_in_submenu($pid) { } if ($trails) { - foreach ($trails as $key => $trail) { - for ($i = 0 ; $i < count($trail); $i++) { + foreach ($trails as $trail) { + $count_trail = count($trail); + for ($i = 0; $i < $count_trail; $i++) { if ($trail[$i] == $pid) { - // create a trail from $pid to the current page inclusive. - for ( ; $i < count($trail) ; $i++) { - $subtrail[] = $trail[$i]; - } + // Return a trail from $pid down to the current page inclusive. + for ( ; $i < $count_trail; $i++) { + $subtrail[] = $trail[$i]; + } return $subtrail; } } -- GitLab