aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggMenuBuilder.php
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2012-11-18 16:07:31 +0100
committerSem <sembrestels@riseup.net>2012-11-18 16:07:31 +0100
commit7f4f57ef1ebd8b97370094da2518dd39e183a43d (patch)
treee0a8518ee22c334ce5741c9247403cf09d179ec4 /engine/classes/ElggMenuBuilder.php
parent47aa87219deb97da16eabe03dee9179999faf2d7 (diff)
parent6623571b615fc5c9d1b82e2607de4cdaee8a818b (diff)
downloadelgg-7f4f57ef1ebd8b97370094da2518dd39e183a43d.tar.gz
elgg-7f4f57ef1ebd8b97370094da2518dd39e183a43d.tar.bz2
Merge tag '1.8.9' of git://github.com/Elgg/Elgg into lorea-preprod
Elgg 1.8.9 release
Diffstat (limited to 'engine/classes/ElggMenuBuilder.php')
-rw-r--r--engine/classes/ElggMenuBuilder.php32
1 files changed, 23 insertions, 9 deletions
diff --git a/engine/classes/ElggMenuBuilder.php b/engine/classes/ElggMenuBuilder.php
index 06000c923..f43599999 100644
--- a/engine/classes/ElggMenuBuilder.php
+++ b/engine/classes/ElggMenuBuilder.php
@@ -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;
}
}