diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-03-05 17:06:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-05 17:06:23 +0300 |
commit | 45af4e6ea337a5eabed59cd82682e836cffaf77e (patch) | |
tree | f651f51454c4a194c088aed6b6a1ff27ecf8e12d /lib | |
parent | f7af3af72a42ff35611330e171dbf500321114e7 (diff) | |
parent | b7570092f7279a7982ca82fe73d7f0f8d2d4b6fa (diff) |
Merge pull request #14417 from nextcloud/backport/14343/stable14
[stable14] 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']) : ''; |