From 583942ee08e987fa7e9e68d4c67b9b9590fa2b0f Mon Sep 17 00:00:00 2001 From: cash Date: Thu, 17 Dec 2009 12:43:00 +0000 Subject: get_submenu was throwing out tons of notices - this should be fixed now git-svn-id: http://code.elgg.org/elgg/trunk@3763 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'engine') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 94d270327..150dcb502 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -917,31 +917,44 @@ function get_submenu() { if ($item->selected === NULL) { $uri_info = parse_url($_SERVER['REQUEST_URI']); $item_info = parse_url($item->value); - + // don't want to mangle already encoded queries but want to // make sure we're comparing encoded to encoded. // for the record, queries *should* be encoded - $uri_info['query'] = html_entity_decode($uri_info['query']); - $item_info['query'] = html_entity_decode($item_info['query']); - - parse_str($uri_info['query'], $uri_params); - parse_str($item_info['query'], $item_params); - + $uri_params = array(); + $item_params = array(); + if (isset($uri_info['query'])) { + $uri_info['query'] = html_entity_decode($uri_info['query']); + parse_str($uri_info['query'], $uri_params); + } + if (isset($item_info['query'])) { + $item_info['query'] = html_entity_decode($item_info['query']); + parse_str($item_info['query'], $item_params); + } + $uri_info['path'] = trim($uri_info['path'], '/'); $item_info['path'] = trim($item_info['path'], '/'); // only if we're on the same path // can't check server because sometimes it's not set in REQUEST_URI if ($uri_info['path'] == $item_info['path']) { - if ($uri_info['query'] == $item_info['query']) { - //var_dump("Good on 1"); - $selected_key = $key; - $selected_group = $groupname; - $selected = TRUE; - } elseif (!count(array_diff($uri_params, $item_params))) { + + // if no query terms, we have a match + if (!isset($uri_info['query']) && !isset($item_info['query'])) { $selected_key = $key; $selected_group = $groupname; $selected = TRUE; + } else { + if ($uri_info['query'] == $item_info['query']) { + //var_dump("Good on 1"); + $selected_key = $key; + $selected_group = $groupname; + $selected = TRUE; + } elseif (!count(array_diff($uri_params, $item_params))) { + $selected_key = $key; + $selected_group = $groupname; + $selected = TRUE; + } } } // if TRUE or FALSE, set selected to this item. -- cgit v1.2.3