aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggMenuBuilder.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/classes/ElggMenuBuilder.php')
-rw-r--r--engine/classes/ElggMenuBuilder.php34
1 files changed, 24 insertions, 10 deletions
diff --git a/engine/classes/ElggMenuBuilder.php b/engine/classes/ElggMenuBuilder.php
index de0017599..f43599999 100644
--- a/engine/classes/ElggMenuBuilder.php
+++ b/engine/classes/ElggMenuBuilder.php
@@ -158,7 +158,7 @@ class ElggMenuBuilder {
// scan looking for a selected item
foreach ($this->menu as $menu_item) {
if ($menu_item->getHref()) {
- if (elgg_http_url_is_identical(full_url(), $menu_item->getHref())) {
+ if (elgg_http_url_is_identical(current_page_url(), $menu_item->getHref())) {
$menu_item->setSelected(true);
return $menu_item;
}
@@ -204,6 +204,9 @@ class ElggMenuBuilder {
// sort each section
foreach ($this->menu as $index => $section) {
+ foreach ($section as $key => $node) {
+ $section[$key]->original_order = $key;
+ }
usort($section, $sort_callback);
$this->menu[$index] = $section;
@@ -232,10 +235,14 @@ class ElggMenuBuilder {
* @return bool
*/
public static function compareByText($a, $b) {
- $a = $a->getText();
- $b = $b->getText();
+ $at = $a->getText();
+ $bt = $b->getText();
- return strnatcmp($a, $b);
+ $result = strnatcmp($at, $bt);
+ if ($result === 0) {
+ return $a->original_order - $b->original_order;
+ }
+ return $result;
}
/**
@@ -246,10 +253,14 @@ class ElggMenuBuilder {
* @return bool
*/
public static function compareByName($a, $b) {
- $a = $a->getName();
- $b = $b->getName();
+ $an = $a->getName();
+ $bn = $b->getName();
- return strcmp($a, $b);
+ $result = strcmp($an, $bn);
+ if ($result === 0) {
+ return $a->original_order - $b->original_order;
+ }
+ return $result;
}
/**
@@ -260,9 +271,12 @@ class ElggMenuBuilder {
* @return bool
*/
public static function compareByWeight($a, $b) {
- $a = $a->getWeight();
- $b = $b->getWeight();
+ $aw = $a->getWeight();
+ $bw = $b->getWeight();
- return $a > $b;
+ if ($aw == $bw) {
+ return $a->original_order - $b->original_order;
+ }
+ return $aw - $bw;
}
}