aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Beckett <beck24@gmail.com>2012-07-15 01:40:02 -0600
committerMatt Beckett <beck24@gmail.com>2012-07-15 01:40:02 -0600
commitb134c8c70cc310e8170da44d1e2291f507cb31ff (patch)
tree1fd95dfa1efe74913e40b4717adbd9589d7145cd
parent4859e56edf1b17092751a6e9d7d89b03113253db (diff)
downloadelgg-b134c8c70cc310e8170da44d1e2291f507cb31ff.tar.gz
elgg-b134c8c70cc310e8170da44d1e2291f507cb31ff.tar.bz2
persist 'selected' state of site menu
-rw-r--r--engine/lib/navigation.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/engine/lib/navigation.php b/engine/lib/navigation.php
index 4ff009bfb..8845d5164 100644
--- a/engine/lib/navigation.php
+++ b/engine/lib/navigation.php
@@ -308,6 +308,41 @@ function elgg_site_menu_setup($hook, $type, $return, $params) {
$return['more'] = array_splice($return['default'], $max_display_items);
}
}
+
+ // check if we have anything selected
+ $selected = false;
+ foreach ($return as $section_name => $section) {
+ foreach ($section as $key => $item) {
+ if ($item->getSelected()) {
+ $selected = true;
+ break 2;
+ }
+ }
+ }
+
+ if (!$selected) {
+ // nothing selected, match by handler
+ $handler = get_input('handler');
+
+ foreach ($return as $section_name => $section) {
+ foreach ($section as $key => $item) {
+ // determine the 'handler' of this url, if there is one
+ if (strpos($item->getHref(), elgg_get_site_url()) === 0) {
+ // this is an internal link, so it has a page handler
+ $path = array(str_replace(elgg_get_site_url(), '', $item->getHref()));
+ $separators = array('/', '?', '#');
+ foreach ($separators as $separator) {
+ $path = explode($separator, $path[0]);
+ }
+
+ if ($path[0] == $handler) {
+ $return[$section_name][$key]->setSelected(true);
+ break 2;
+ }
+ }
+ }
+ }
+ }
return $return;
}