diff options
Diffstat (limited to 'engine/lib')
-rw-r--r-- | engine/lib/elgglib.php | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index e8cc9878d..00a0c83ba 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -540,18 +540,40 @@ function get_submenu() {
$submenu = "";
+ global $CONFIG;
if ($submenu_register = get_register('submenu')) {
- foreach($submenu_register as $item) {
+
+ $preselected = false;
+ $comparevals = array();
+ $maxcompareval = 999999;
+
+ foreach($submenu_register as $key => $item) {
+
+ $comparevals[$key] = (levenshtein($item->value, $_SERVER['REQUEST_URI']));
+ if ($comparevals[$key] < $maxcompareval) {
+ $maxcompareval = $comparevals[$key];
+ $preselected = $key;
+ }
+
+ }
+
+ foreach($submenu_register as $key => $item) {
- if (substr_count($item->value, $_SERVER['REQUEST_URI'])) {
- $selected = true;
+ if (!$preselected) {
+ if (substr_count($item->value, $_SERVER['REQUEST_URI'])) {
+ $selected = true;
+ } else {
+ $selected = false;
+ }
} else {
- $selected = false;
+ if ($key == $preselected) {
+ $selected = true;
+ } else {
+ $selected = false;
+ }
}
- $submenu .= "<!-- {$item->value} {$_SERVER['REQUEST_URI']} -->";
-
$submenu .= elgg_view('canvas_header/submenu_template',
array(
'href' => $item->value,
|