diff options
author | Julius Haertl <jus@bitgrid.net> | 2017-03-01 23:04:27 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2017-03-16 11:55:09 +0100 |
commit | a630e4629f2489e9d7678fbe6833cf926e2b968e (patch) | |
tree | bdca715c7274eb4323eabc9e2fda8fa535f8eaf8 /lib | |
parent | e3e4cb3e67fb4d1399b4a9cf229633144008fdcf (diff) | |
download | nextcloud-server-a630e4629f2489e9d7678fbe6833cf926e2b968e.tar.gz nextcloud-server-a630e4629f2489e9d7678fbe6833cf926e2b968e.zip |
Generate seperate menu list for header bar
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/TemplateLayout.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/app.php | 44 |
2 files changed, 43 insertions, 3 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 264e8f5fc60..1cc83888734 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -530,7 +530,6 @@ class OC_App { // This is private as well. It simply works, so don't ask for more details private static function proceedNavigation($list) { - usort($list, function($a, $b) { if (isset($a['order']) && isset($b['order'])) { return ($a['order'] < $b['order']) ? -1 : 1; @@ -552,13 +551,36 @@ class OC_App { } unset($navEntry); - // Move active app to the first position + + foreach ($list as $index => &$navEntry) { + $navEntry['showInHeader'] = false; + if($index < 4) { + $navEntry['showInHeader'] = true; + } + } + + return $list; + } + + public static function proceedAppNavigation($entries) { + $list = self::proceedNavigation($entries); + + $activeApp = OC::$server->getNavigationManager()->getActiveEntry(); + foreach ($list as $index => &$navEntry) { + if ($navEntry['id'] == $activeApp) { + $navEntry['active'] = true; + $activeAppIndex = $index; + } else { + $navEntry['active'] = false; + } + } + $list = array_slice($list, 0, 4); + // move active item to last position if($activeAppIndex > 2) { $active = $list[$activeAppIndex]; unset($list[$activeAppIndex]); array_unshift($list, $active); } - return $list; } @@ -752,6 +774,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 |