aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/NavigationManager.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/NavigationManager.php')
-rw-r--r--lib/private/NavigationManager.php42
1 files changed, 38 insertions, 4 deletions
diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php
index 31d147a3b80..36bb9b5ee19 100644
--- a/lib/private/NavigationManager.php
+++ b/lib/private/NavigationManager.php
@@ -115,15 +115,49 @@ class NavigationManager implements INavigationManager {
}
$this->closureEntries = array();
- if ($type === 'all') {
- return $this->entries;
+ $result = $this->entries;
+ if ($type !== 'all') {
+ $result = array_filter($this->entries, function($entry) use ($type) {
+ return $entry['type'] === $type;
+ });
}
- return array_filter($this->entries, function($entry) use ($type) {
- return $entry['type'] === $type;
+ return $this->proceedNavigation($result);
+ }
+
+ /**
+ * Sort navigation entries by order, name and set active flag
+ *
+ * @param $list
+ * @return mixed
+ */
+ private function proceedNavigation($list) {
+ usort($list, function($a, $b) {
+ if (isset($a['order']) && isset($b['order'])) {
+ return ($a['order'] < $b['order']) ? -1 : 1;
+ } else if (isset($a['order']) || isset($b['order'])) {
+ return isset($a['order']) ? -1 : 1;
+ } else {
+ return ($a['name'] < $b['name']) ? -1 : 1;
+ }
});
+
+ $activeApp = $this->getActiveEntry();
+ if ($activeApp !== null) {
+ foreach ($list as $index => &$navEntry) {
+ if ($navEntry['id'] == $activeApp) {
+ $navEntry['active'] = true;
+ } else {
+ $navEntry['active'] = false;
+ }
+ }
+ unset($navEntry);
+ }
+
+ return $list;
}
+
/**
* removes all the entries
*/