summaryrefslogtreecommitdiffstats
path: root/lib/private/NavigationManager.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-03-26 21:15:25 +0200
committerJoas Schilling <coding@schilljs.com>2017-03-26 21:15:25 +0200
commite0b040d6235e7f8f8e5869e56a9bda1bf346cafd (patch)
tree91bc197d3e598c49838635f2a6983e4aea9ab78f /lib/private/NavigationManager.php
parent7cc5130e8262b8e42df0c2a017cddcca2b6d8c85 (diff)
downloadnextcloud-server-e0b040d6235e7f8f8e5869e56a9bda1bf346cafd.tar.gz
nextcloud-server-e0b040d6235e7f8f8e5869e56a9bda1bf346cafd.zip
Allow multiple navigation links from info.xml
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/NavigationManager.php')
-rw-r--r--lib/private/NavigationManager.php86
1 files changed, 38 insertions, 48 deletions
diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php
index 439e49909d0..27de7c6f360 100644
--- a/lib/private/NavigationManager.php
+++ b/lib/private/NavigationManager.php
@@ -119,23 +119,12 @@ class NavigationManager implements INavigationManager {
}
/**
- * Do not load the default links
- * This is just a hack for the files app
- * @internal
- */
- public function noDefaultLinks() {
- $this->entries = [];
- $this->closureEntries = [];
- $this->init = true;
- }
-
- /**
* removes all the entries
*/
- public function clear() {
+ public function clear($loadDefaultLinks = true) {
$this->entries = [];
$this->closureEntries = [];
- $this->init = false;
+ $this->init = !$loadDefaultLinks;
}
/**
@@ -242,45 +231,46 @@ class NavigationManager implements INavigationManager {
foreach ($this->appManager->getInstalledApps() as $app) {
// load plugins and collections from info.xml
$info = $this->appManager->getAppInfo($app);
- if (!isset($info['navigation'])) {
- continue;
- }
- $nav = $info['navigation'];
- if (!isset($nav['name'])) {
- continue;
- }
- if (!isset($nav['route'])) {
- continue;
- }
- $role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all';
- if ($role === 'admin' && !$this->isAdmin()) {
+ if (empty($info['navigations'])) {
continue;
}
- $l = $this->l10nFac->get($app);
- $order = isset($nav['order']) ? $nav['order'] : 100;
- $type = isset($nav['type']) ? $nav['type'] : 'link';
- $route = $this->urlGenerator->linkToRoute($nav['route']);
- $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg';
- foreach ([$icon, "$app.svg"] as $i) {
- try {
- $icon = $this->urlGenerator->imagePath($app, $i);
- break;
- } catch (\RuntimeException $ex) {
- // no icon? - ignore it then
+ foreach ($info['navigations'] as $nav) {
+ if (!isset($nav['name'])) {
+ continue;
+ }
+ if (!isset($nav['route'])) {
+ continue;
+ }
+ $role = isset($nav['@attributes']['role']) ? $nav['@attributes']['role'] : 'all';
+ if ($role === 'admin' && !$this->isAdmin()) {
+ continue;
+ }
+ $l = $this->l10nFac->get($app);
+ $order = isset($nav['order']) ? $nav['order'] : 100;
+ $type = isset($nav['type']) ? $nav['type'] : 'link';
+ $route = $this->urlGenerator->linkToRoute($nav['route']);
+ $icon = isset($nav['icon']) ? $nav['icon'] : 'app.svg';
+ foreach ([$icon, "$app.svg"] as $i) {
+ try {
+ $icon = $this->urlGenerator->imagePath($app, $i);
+ break;
+ } catch (\RuntimeException $ex) {
+ // no icon? - ignore it then
+ }
+ }
+ if ($icon === null) {
+ $icon = $this->urlGenerator->imagePath('core', 'default-app-icon');
}
- }
- if ($icon === null) {
- $icon = $this->urlGenerator->imagePath('core', 'default-app-icon');
- }
- $this->add([
- 'id' => $app,
- 'order' => $order,
- 'href' => $route,
- 'icon' => $icon,
- 'type' => $type,
- 'name' => $l->t($nav['name']),
- ]);
+ $this->add([
+ 'id' => $app,
+ 'order' => $order,
+ 'href' => $route,
+ 'icon' => $icon,
+ 'type' => $type,
+ 'name' => $l->t($nav['name']),
+ ]);
+ }
}
}