summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/TemplateLayout.php2
-rw-r--r--lib/private/legacy/app.php83
2 files changed, 77 insertions, 8 deletions
diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php
index ccd53c9cafa..3f8c75adc84 100644
--- a/lib/private/TemplateLayout.php
+++ b/lib/private/TemplateLayout.php
@@ -76,6 +76,8 @@ class TemplateLayout extends \OC_Template {
$this->assign( 'appid', $appId );
$navigation = \OC_App::getNavigation();
$this->assign( 'navigation', $navigation);
+ $navigation = \OC_App::getHeaderNavigation();
+ $this->assign( 'headernavigation', $navigation);
$settingsNavigation = \OC_App::getSettingsNavigation();
$this->assign( 'settingsnavigation', $settingsNavigation);
foreach($navigation as $entry) {
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index f89f32f069a..c82d620882d 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -529,25 +529,76 @@ class OC_App {
// This is private as well. It simply works, so don't ask for more details
private static function proceedNavigation($list) {
+ $headerIconCount = 8;
+ if(OC_User::isAdminUser(OC_User::getUser())) {
+ $headerIconCount--;
+ }
+ 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;
+ }
+ });
+
+ $activeAppIndex = -1;
$activeApp = OC::$server->getNavigationManager()->getActiveEntry();
- foreach ($list as &$navEntry) {
+ foreach ($list as $index => &$navEntry) {
if ($navEntry['id'] == $activeApp) {
$navEntry['active'] = true;
+ $activeAppIndex = $index;
} else {
$navEntry['active'] = false;
}
}
unset($navEntry);
- 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;
+ if($activeAppIndex > ($headerIconCount-1)) {
+ $active = $list[$activeAppIndex];
+ $lastInHeader = $list[$headerIconCount-1];
+ $list[$headerIconCount-1] = $active;
+ $list[$activeAppIndex] = $lastInHeader;
+ }
+
+ foreach ($list as $index => &$navEntry) {
+ $navEntry['showInHeader'] = false;
+ if($index < $headerIconCount) {
+ $navEntry['showInHeader'] = true;
+ }
+ }
+
+
+
+ return $list;
+ }
+
+ public static function proceedAppNavigation($entries) {
+ $headerIconCount = 8;
+ if(OC_User::isAdminUser(OC_User::getUser())) {
+ $headerIconCount--;
+ }
+ $activeAppIndex = -1;
+ $list = self::proceedNavigation($entries);
+
+ $activeApp = OC::$server->getNavigationManager()->getActiveEntry();
+ foreach ($list as $index => &$navEntry) {
+ if ($navEntry['id'] == $activeApp) {
+ $navEntry['active'] = true;
+ $activeAppIndex = $index;
} else {
- return ($a['name'] < $b['name']) ? -1 : 1;
+ $navEntry['active'] = false;
}
- });
+ }
+ // move active item to last position
+ if($activeAppIndex > ($headerIconCount-1)) {
+ $active = $list[$activeAppIndex];
+ $lastInHeader = $list[$headerIconCount-1];
+ $list[$headerIconCount-1] = $active;
+ $list[$activeAppIndex] = $lastInHeader;
+ }
+ $list = array_slice($list, 0, $headerIconCount);
return $list;
}
@@ -742,6 +793,22 @@ class OC_App {
}
/**
+ * Returns the navigation inside the header bar
+ *
+ * @return array
+ *
+ * This function returns an array containing all entries added. The
+ * entries are sorted by the key 'order' ascending. Additional to the keys
+ * given for each app the following keys exist:
+ * - active: boolean, signals if the user is on this navigation entry
+ */
+ public static function getHeaderNavigation() {
+ $entries = OC::$server->getNavigationManager()->getAll();
+ $navigation = self::proceedAppNavigation($entries);
+ return $navigation;
+ }
+
+ /**
* get the id of loaded app
*
* @return string