Skip to content

Commit f8a7b91

Browse files
committed
Parse multiple navigation items
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
1 parent 2083103 commit f8a7b91

File tree

7 files changed

+355
-11
lines changed

7 files changed

+355
-11
lines changed

lib/private/App/InfoParser.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function parse($file) {
5252
return null;
5353
}
5454

55-
if(!is_null($this->cache)) {
55+
if ($this->cache !== null) {
5656
$fileCacheKey = $file . filemtime($file);
5757
if ($cachedValue = $this->cache->get($fileCacheKey)) {
5858
return json_decode($cachedValue, true);
@@ -205,12 +205,24 @@ public function parse($file) {
205205
$array['settings']['personal-section'] = [$array['settings']['personal-section']];
206206
}
207207

208-
if(!is_null($this->cache)) {
208+
if (isset($array['navigations']['navigation']) && $this->isNavigationItem($array['navigations']['navigation'])) {
209+
$array['navigations']['navigation'] = [$array['navigations']['navigation']];
210+
}
211+
212+
if ($this->cache !== null) {
209213
$this->cache->set($fileCacheKey, json_encode($array));
210214
}
211215
return $array;
212216
}
213217

218+
/**
219+
* @param $data
220+
* @return bool
221+
*/
222+
private function isNavigationItem($data): bool {
223+
return isset($data['name'], $data['route']);
224+
}
225+
214226
/**
215227
* @param \SimpleXMLElement $xml
216228
* @return array

lib/private/NavigationManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ private function init() {
271271

272272
// load plugins and collections from info.xml
273273
$info = $this->appManager->getAppInfo($app);
274-
if (empty($info['navigations'])) {
274+
if (!isset($info['navigations']['navigation'])) {
275275
continue;
276276
}
277-
foreach ($info['navigations'] as $nav) {
277+
foreach ($info['navigations']['navigation'] as $nav) {
278278
if (!isset($nav['name'])) {
279279
continue;
280280
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"id": "activity",
3+
"name": "Activity",
4+
"summary": "This application enables users to view actions related to their files in Nextcloud.",
5+
"description": "\n\t\tThis application enables users to view actions related to their files in Nextcloud.\n\t\tOnce enabled, users will see a new icon \u201cActivity\u201d in their apps menu.\n\t\tWhen clicked, a new page appears for users to track the activity related to files \u2013 from new files, to deleted files, move, rename, updates and shared activity.\n\t\tThe user can configure their individual activity settings in their personal menu.\n\t\tThis sets the type of activity to record, as well as whether to the user sees their own activities,\n\t\twhether these are only available online, and whether they get an email digest on a regular basis.\n\t\tMore information is available in the Activity documentation.\n\t",
6+
"version": "2.9.0",
7+
"licence": "agpl",
8+
"author": [
9+
"Frank Karlitschek",
10+
"Joas Schilling"
11+
],
12+
"default_enable": "",
13+
"types": [
14+
"filesystem"
15+
],
16+
"documentation": {
17+
"admin": "https:\/\/docs.nextcloud.org\/server\/14\/admin_manual\/configuration_server\/activity_configuration.html"
18+
},
19+
"category": [
20+
"monitoring",
21+
"social"
22+
],
23+
"website": "https:\/\/github.com\/nextcloud\/activity\/",
24+
"bugs": "https:\/\/github.com\/nextcloud\/activity\/issues",
25+
"repository": "https:\/\/github.com\/nextcloud\/activity.git",
26+
"dependencies": {
27+
"nextcloud": {
28+
"@attributes": {
29+
"min-version": "16",
30+
"max-version": "16"
31+
}
32+
}
33+
},
34+
"background-jobs": [
35+
"OCA\\Activity\\BackgroundJob\\EmailNotification",
36+
"OCA\\Activity\\BackgroundJob\\ExpireActivities"
37+
],
38+
"commands": {
39+
"command": "OCA\\Activity\\Command\\SendEmails"
40+
},
41+
"settings": {
42+
"admin": [
43+
"OCA\\Activity\\Settings\\Admin"
44+
],
45+
"admin-section": [
46+
"OCA\\Activity\\Settings\\AdminSection"
47+
],
48+
"personal": [
49+
"OCA\\Activity\\Settings\\Personal"
50+
],
51+
"personal-section": [
52+
"OCA\\Activity\\Settings\\PersonalSection"
53+
]
54+
},
55+
"activity": {
56+
"filters": [
57+
"OCA\\Activity\\Filter\\AllFilter",
58+
"OCA\\Activity\\Filter\\SelfFilter",
59+
"OCA\\Activity\\Filter\\ByFilter"
60+
],
61+
"settings": [],
62+
"providers": []
63+
},
64+
"navigations": {
65+
"navigation": [
66+
{
67+
"name": "Activity",
68+
"route": "activity.Activities.showList",
69+
"icon": "activity.svg",
70+
"order": "1"
71+
}
72+
]
73+
},
74+
"info": [],
75+
"remote": [],
76+
"public": [],
77+
"repair-steps": {
78+
"install": [],
79+
"pre-migration": [],
80+
"post-migration": [],
81+
"live-migration": [],
82+
"uninstall": []
83+
},
84+
"two-factor-providers": []
85+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0"?>
2+
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
4+
<id>activity</id>
5+
<name>Activity</name>
6+
<summary>This application enables users to view actions related to their files in Nextcloud.</summary>
7+
<description>
8+
This application enables users to view actions related to their files in Nextcloud.
9+
Once enabled, users will see a new icon “Activity” in their apps menu.
10+
When clicked, a new page appears for users to track the activity related to files – from new files, to deleted files, move, rename, updates and shared activity.
11+
The user can configure their individual activity settings in their personal menu.
12+
This sets the type of activity to record, as well as whether to the user sees their own activities,
13+
whether these are only available online, and whether they get an email digest on a regular basis.
14+
More information is available in the Activity documentation.
15+
</description>
16+
17+
<version>2.9.0</version>
18+
<licence>agpl</licence>
19+
<author>Frank Karlitschek</author>
20+
<author>Joas Schilling</author>
21+
22+
<default_enable/>
23+
<types>
24+
<filesystem/>
25+
</types>
26+
27+
<documentation>
28+
<admin>https://docs.nextcloud.org/server/14/admin_manual/configuration_server/activity_configuration.html</admin>
29+
</documentation>
30+
31+
<category>monitoring</category>
32+
<category>social</category>
33+
34+
<website>https://github.com/nextcloud/activity/</website>
35+
<bugs>https://github.com/nextcloud/activity/issues</bugs>
36+
<repository>https://github.com/nextcloud/activity.git</repository>
37+
38+
<dependencies>
39+
<nextcloud min-version="16" max-version="16"/>
40+
</dependencies>
41+
42+
<background-jobs>
43+
<job>OCA\Activity\BackgroundJob\EmailNotification</job>
44+
<job>OCA\Activity\BackgroundJob\ExpireActivities</job>
45+
</background-jobs>
46+
47+
<commands>
48+
<command>OCA\Activity\Command\SendEmails</command>
49+
</commands>
50+
51+
<settings>
52+
<admin>OCA\Activity\Settings\Admin</admin>
53+
<admin-section>OCA\Activity\Settings\AdminSection</admin-section>
54+
<personal>OCA\Activity\Settings\Personal</personal>
55+
<personal-section>OCA\Activity\Settings\PersonalSection</personal-section>
56+
</settings>
57+
58+
<activity>
59+
<filters>
60+
<filter>OCA\Activity\Filter\AllFilter</filter>
61+
<filter>OCA\Activity\Filter\SelfFilter</filter>
62+
<filter>OCA\Activity\Filter\ByFilter</filter>
63+
</filters>
64+
</activity>
65+
66+
<navigations>
67+
<navigation>
68+
<name>Activity</name>
69+
<route>activity.Activities.showList</route>
70+
<icon>activity.svg</icon>
71+
<order>1</order>
72+
</navigation>
73+
</navigations>
74+
</info>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"id": "activity",
3+
"name": "Activity",
4+
"summary": "This application enables users to view actions related to their files in Nextcloud.",
5+
"description": "\n\t\tThis application enables users to view actions related to their files in Nextcloud.\n\t\tOnce enabled, users will see a new icon \u201cActivity\u201d in their apps menu.\n\t\tWhen clicked, a new page appears for users to track the activity related to files \u2013 from new files, to deleted files, move, rename, updates and shared activity.\n\t\tThe user can configure their individual activity settings in their personal menu.\n\t\tThis sets the type of activity to record, as well as whether to the user sees their own activities,\n\t\twhether these are only available online, and whether they get an email digest on a regular basis.\n\t\tMore information is available in the Activity documentation.\n\t",
6+
"version": "2.9.0",
7+
"licence": "agpl",
8+
"author": [
9+
"Frank Karlitschek",
10+
"Joas Schilling"
11+
],
12+
"default_enable": "",
13+
"types": [
14+
"filesystem"
15+
],
16+
"documentation": {
17+
"admin": "https:\/\/docs.nextcloud.org\/server\/14\/admin_manual\/configuration_server\/activity_configuration.html"
18+
},
19+
"category": [
20+
"monitoring",
21+
"social"
22+
],
23+
"website": "https:\/\/github.com\/nextcloud\/activity\/",
24+
"bugs": "https:\/\/github.com\/nextcloud\/activity\/issues",
25+
"repository": "https:\/\/github.com\/nextcloud\/activity.git",
26+
"dependencies": {
27+
"nextcloud": {
28+
"@attributes": {
29+
"min-version": "16",
30+
"max-version": "16"
31+
}
32+
}
33+
},
34+
"background-jobs": [
35+
"OCA\\Activity\\BackgroundJob\\EmailNotification",
36+
"OCA\\Activity\\BackgroundJob\\ExpireActivities"
37+
],
38+
"commands": {
39+
"command": "OCA\\Activity\\Command\\SendEmails"
40+
},
41+
"settings": {
42+
"admin": [
43+
"OCA\\Activity\\Settings\\Admin"
44+
],
45+
"admin-section": [
46+
"OCA\\Activity\\Settings\\AdminSection"
47+
],
48+
"personal": [
49+
"OCA\\Activity\\Settings\\Personal"
50+
],
51+
"personal-section": [
52+
"OCA\\Activity\\Settings\\PersonalSection"
53+
]
54+
},
55+
"activity": {
56+
"filters": [
57+
"OCA\\Activity\\Filter\\AllFilter",
58+
"OCA\\Activity\\Filter\\SelfFilter",
59+
"OCA\\Activity\\Filter\\ByFilter"
60+
],
61+
"settings": [],
62+
"providers": []
63+
},
64+
"navigations": {
65+
"navigation": [
66+
{
67+
"name": "Activity",
68+
"route": "activity.Activities.showList",
69+
"icon": "activity.svg",
70+
"order": "1"
71+
},
72+
{
73+
"name": "Activity-Test",
74+
"route": "activity.Activities.showList",
75+
"icon": "activity.svg",
76+
"order": "2"
77+
}
78+
]
79+
},
80+
"info": [],
81+
"remote": [],
82+
"public": [],
83+
"repair-steps": {
84+
"install": [],
85+
"pre-migration": [],
86+
"post-migration": [],
87+
"live-migration": [],
88+
"uninstall": []
89+
},
90+
"two-factor-providers": []
91+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?xml version="1.0"?>
2+
<info xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://apps.nextcloud.com/schema/apps/info.xsd">
4+
<id>activity</id>
5+
<name>Activity</name>
6+
<summary>This application enables users to view actions related to their files in Nextcloud.</summary>
7+
<description>
8+
This application enables users to view actions related to their files in Nextcloud.
9+
Once enabled, users will see a new icon “Activity” in their apps menu.
10+
When clicked, a new page appears for users to track the activity related to files – from new files, to deleted files, move, rename, updates and shared activity.
11+
The user can configure their individual activity settings in their personal menu.
12+
This sets the type of activity to record, as well as whether to the user sees their own activities,
13+
whether these are only available online, and whether they get an email digest on a regular basis.
14+
More information is available in the Activity documentation.
15+
</description>
16+
17+
<version>2.9.0</version>
18+
<licence>agpl</licence>
19+
<author>Frank Karlitschek</author>
20+
<author>Joas Schilling</author>
21+
22+
<default_enable/>
23+
<types>
24+
<filesystem/>
25+
</types>
26+
27+
<documentation>
28+
<admin>https://docs.nextcloud.org/server/14/admin_manual/configuration_server/activity_configuration.html</admin>
29+
</documentation>
30+
31+
<category>monitoring</category>
32+
<category>social</category>
33+
34+
<website>https://github.com/nextcloud/activity/</website>
35+
<bugs>https://github.com/nextcloud/activity/issues</bugs>
36+
<repository>https://github.com/nextcloud/activity.git</repository>
37+
38+
<dependencies>
39+
<nextcloud min-version="16" max-version="16"/>
40+
</dependencies>
41+
42+
<background-jobs>
43+
<job>OCA\Activity\BackgroundJob\EmailNotification</job>
44+
<job>OCA\Activity\BackgroundJob\ExpireActivities</job>
45+
</background-jobs>
46+
47+
<commands>
48+
<command>OCA\Activity\Command\SendEmails</command>
49+
</commands>
50+
51+
<settings>
52+
<admin>OCA\Activity\Settings\Admin</admin>
53+
<admin-section>OCA\Activity\Settings\AdminSection</admin-section>
54+
<personal>OCA\Activity\Settings\Personal</personal>
55+
<personal-section>OCA\Activity\Settings\PersonalSection</personal-section>
56+
</settings>
57+
58+
<activity>
59+
<filters>
60+
<filter>OCA\Activity\Filter\AllFilter</filter>
61+
<filter>OCA\Activity\Filter\SelfFilter</filter>
62+
<filter>OCA\Activity\Filter\ByFilter</filter>
63+
</filters>
64+
</activity>
65+
66+
<navigations>
67+
<navigation>
68+
<name>Activity</name>
69+
<route>activity.Activities.showList</route>
70+
<icon>activity.svg</icon>
71+
<order>1</order>
72+
</navigation>
73+
<navigation>
74+
<name>Activity-Test</name>
75+
<route>activity.Activities.showList</route>
76+
<icon>activity.svg</icon>
77+
<order>2</order>
78+
</navigation>
79+
</navigations>
80+
</info>

0 commit comments

Comments
 (0)