diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-02-27 18:07:57 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-27 18:07:57 +0300 |
commit | e5cacc0fe3e9c0a9cbe777fb39aac74cd8ce0064 (patch) | |
tree | c50592247bc00cd6bd3ca341ced37ac406288719 /lib | |
parent | 3459ffc4d1bc4fb8fc7bccbb7ae999d165cbb5ad (diff) | |
parent | df3d5e85095620f84e3146ae6ce558e68d0b137e (diff) |
Merge pull request #14343 from nextcloud/bugfix/14052-multiple-navigation-items
Parse multiple navigation items
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/App/InfoParser.php | 16 | ||||
-rw-r--r-- | lib/private/NavigationManager.php | 6 |
2 files changed, 17 insertions, 5 deletions
diff --git a/lib/private/App/InfoParser.php b/lib/private/App/InfoParser.php index e0ed63fc784..ef96156dfed 100644 --- a/lib/private/App/InfoParser.php +++ b/lib/private/App/InfoParser.php @@ -52,7 +52,7 @@ class InfoParser { return null; } - if(!is_null($this->cache)) { + if ($this->cache !== null) { $fileCacheKey = $file . filemtime($file); if ($cachedValue = $this->cache->get($fileCacheKey)) { return json_decode($cachedValue, true); @@ -205,13 +205,25 @@ class InfoParser { $array['settings']['personal-section'] = [$array['settings']['personal-section']]; } - if(!is_null($this->cache)) { + if (isset($array['navigations']['navigation']) && $this->isNavigationItem($array['navigations']['navigation'])) { + $array['navigations']['navigation'] = [$array['navigations']['navigation']]; + } + + if ($this->cache !== null) { $this->cache->set($fileCacheKey, json_encode($array)); } return $array; } /** + * @param $data + * @return bool + */ + private function isNavigationItem($data): bool { + return isset($data['name'], $data['route']); + } + + /** * @param \SimpleXMLElement $xml * @return array */ diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index 1874cd0e4ff..2c41fbd88c2 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -271,10 +271,10 @@ class NavigationManager implements INavigationManager { // load plugins and collections from info.xml $info = $this->appManager->getAppInfo($app); - if (empty($info['navigations'])) { + if (!isset($info['navigations']['navigation'])) { continue; } - foreach ($info['navigations'] as $nav) { + foreach ($info['navigations']['navigation'] as $key => $nav) { if (!isset($nav['name'])) { continue; } @@ -286,7 +286,7 @@ class NavigationManager implements INavigationManager { continue; } $l = $this->l10nFac->get($app); - $id = isset($nav['id']) ? $nav['id'] : $app; + $id = $nav['id'] ?? $app . ($key === 0 ? '' : $key); $order = isset($nav['order']) ? $nav['order'] : 100; $type = isset($nav['type']) ? $nav['type'] : 'link'; $route = $nav['route'] !== '' ? $this->urlGenerator->linkToRoute($nav['route']) : ''; |