@@ -5,11 +5,11 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | $getUserAvatar = static function (int $size) use ($_): string { |
8 | - return \OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', [ |
|
9 | - 'userId' => $_['user_uid'], |
|
10 | - 'size' => $size, |
|
11 | - 'v' => $_['userAvatarVersion'] |
|
12 | - ]); |
|
8 | + return \OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', [ |
|
9 | + 'userId' => $_['user_uid'], |
|
10 | + 'size' => $size, |
|
11 | + 'v' => $_['userAvatarVersion'] |
|
12 | + ]); |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | ?><!DOCTYPE html> |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | <meta charset="utf-8"> |
19 | 19 | <title> |
20 | 20 | <?php |
21 | - p(!empty($_['application'])?$_['application'].' - ':''); |
|
22 | - p($theme->getTitle()); |
|
23 | - ?> |
|
21 | + p(!empty($_['application'])?$_['application'].' - ':''); |
|
22 | + p($theme->getTitle()); |
|
23 | + ?> |
|
24 | 24 | </title> |
25 | 25 | <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"> |
26 | 26 | <?php if ($theme->getiTunesAppId() !== '') { ?> |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | <?php print_unescaped($_['headers']); ?> |
42 | 42 | </head> |
43 | 43 | <body id="<?php p($_['bodyid']);?>" <?php foreach ($_['enabledThemes'] as $themeId) { |
44 | - p("data-theme-$themeId "); |
|
45 | - }?>> |
|
44 | + p("data-theme-$themeId "); |
|
45 | + }?>> |
|
46 | 46 | <?php include 'layout.noscript.warning.php'; ?> |
47 | 47 | |
48 | 48 | <?php foreach ($_['initialStates'] as $app => $initialState) { ?> |
@@ -148,19 +148,19 @@ discard block |
||
148 | 148 | aria-label="<?php p($l->t('Settings'));?>" |
149 | 149 | aria-haspopup="true" aria-controls="expanddiv" aria-expanded="false"> |
150 | 150 | <div id="avatardiv-menu" class="avatardiv<?php if ($_['userAvatarSet']) { |
151 | - print_unescaped(' avatardiv-shown'); |
|
152 | - } else { |
|
153 | - print_unescaped('" style="display: none'); |
|
154 | - } ?>" |
|
151 | + print_unescaped(' avatardiv-shown'); |
|
152 | + } else { |
|
153 | + print_unescaped('" style="display: none'); |
|
154 | + } ?>" |
|
155 | 155 | data-user="<?php p($_['user_uid']); ?>" |
156 | 156 | data-displayname="<?php p($_['user_displayname']); ?>" |
157 | 157 | <?php |
158 | - if ($_['userAvatarSet']) { |
|
159 | - $avatar32 = $getUserAvatar(32); ?> data-avatar="<?php p($avatar32); ?>" |
|
158 | + if ($_['userAvatarSet']) { |
|
159 | + $avatar32 = $getUserAvatar(32); ?> data-avatar="<?php p($avatar32); ?>" |
|
160 | 160 | <?php |
161 | - } ?>> |
|
161 | + } ?>> |
|
162 | 162 | <?php |
163 | - if ($_['userAvatarSet']) {?> |
|
163 | + if ($_['userAvatarSet']) {?> |
|
164 | 164 | <img alt="" width="32" height="32" |
165 | 165 | src="<?php p($avatar32);?>" |
166 | 166 | srcset="<?php p($getUserAvatar(64));?> 2x, <?php p($getUserAvatar(128));?> 4x" |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * @var array $_ |
5 | 5 | */ |
6 | 6 | |
7 | -$getUserAvatar = static function (int $size) use ($_): string { |
|
7 | +$getUserAvatar = static function(int $size) use ($_): string { |
|
8 | 8 | return \OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', [ |
9 | 9 | 'userId' => $_['user_uid'], |
10 | 10 | 'size' => $size, |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | <meta charset="utf-8"> |
19 | 19 | <title> |
20 | 20 | <?php |
21 | - p(!empty($_['application'])?$_['application'].' - ':''); |
|
21 | + p(!empty($_['application']) ? $_['application'].' - ' : ''); |
|
22 | 22 | p($theme->getTitle()); |
23 | 23 | ?> |
24 | 24 | </title> |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | <?php } ?> |
29 | 29 | <meta name="apple-mobile-web-app-capable" content="yes"> |
30 | 30 | <meta name="apple-mobile-web-app-status-bar-style" content="black"> |
31 | - <meta name="apple-mobile-web-app-title" content="<?php p((!empty($_['application']) && $_['appid'] != 'files')? $_['application']:$theme->getTitle()); ?>"> |
|
31 | + <meta name="apple-mobile-web-app-title" content="<?php p((!empty($_['application']) && $_['appid'] != 'files') ? $_['application'] : $theme->getTitle()); ?>"> |
|
32 | 32 | <meta name="mobile-web-app-capable" content="yes"> |
33 | 33 | <meta name="theme-color" content="<?php p($theme->getColorPrimary()); ?>"> |
34 | 34 | <link rel="icon" href="<?php print_unescaped(image_path($_['appid'], 'favicon.ico')); /* IE11+ supports png */ ?>"> |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | <?php emit_script_loading_tags($_); ?> |
41 | 41 | <?php print_unescaped($_['headers']); ?> |
42 | 42 | </head> |
43 | - <body id="<?php p($_['bodyid']);?>" <?php foreach ($_['enabledThemes'] as $themeId) { |
|
43 | + <body id="<?php p($_['bodyid']); ?>" <?php foreach ($_['enabledThemes'] as $themeId) { |
|
44 | 44 | p("data-theme-$themeId "); |
45 | 45 | }?>> |
46 | 46 | <?php include 'layout.noscript.warning.php'; ?> |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | id="nextcloud"> |
62 | 62 | <div class="logo logo-icon"> |
63 | 63 | <h1 class="hidden-visually"> |
64 | - <?php p($theme->getName()); ?> <?php p(!empty($_['application'])?$_['application']: $l->t('Apps')); ?> |
|
64 | + <?php p($theme->getName()); ?> <?php p(!empty($_['application']) ? $_['application'] : $l->t('Apps')); ?> |
|
65 | 65 | </h1> |
66 | 66 | </div> |
67 | 67 | </a> |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | <circle r="4.5" cx="21" cy="3" fill="black"/> |
81 | 81 | </mask> |
82 | 82 | </defs> |
83 | - <image x="2" y="0" width="20" height="20" preserveAspectRatio="xMinYMin meet" xlink:href="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>" style="<?php if ($entry['unread'] !== 0) { ?>mask: url("#hole");<?php } ?>" class="app-icon"></image> |
|
83 | + <image x="2" y="0" width="20" height="20" preserveAspectRatio="xMinYMin meet" xlink:href="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>" style="<?php if ($entry['unread'] !== 0) { ?>mask: url("#hole");<?php } ?>" class="app-icon"></image> |
|
84 | 84 | <circle class="app-icon-notification" r="3" cx="21" cy="3" fill="red"/> |
85 | 85 | </svg> |
86 | 86 | <div class="unread-counter" aria-hidden="true"><?php p($entry['unread']); ?></div> |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | <circle r="4.5" cx="17" cy="3" fill="black"/> |
118 | 118 | </mask> |
119 | 119 | </defs> |
120 | - <image x="0" y="0" width="16" height="16" preserveAspectRatio="xMinYMin meet" filter="url(#invertMenuMore-<?php p($entry['id']); ?>)" xlink:href="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>" style="<?php if ($entry['unread'] !== 0) { ?>mask: url("#hole");<?php } ?>" class="app-icon"></image> |
|
120 | + <image x="0" y="0" width="16" height="16" preserveAspectRatio="xMinYMin meet" filter="url(#invertMenuMore-<?php p($entry['id']); ?>)" xlink:href="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>" style="<?php if ($entry['unread'] !== 0) { ?>mask: url("#hole");<?php } ?>" class="app-icon"></image> |
|
121 | 121 | <circle class="app-icon-notification" r="3" cx="17" cy="3" fill="red"/> |
122 | 122 | </svg> |
123 | 123 | <div class="unread-counter" aria-hidden="true"><?php p($entry['unread']); ?></div> |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | <div id="contactsmenu"> |
139 | 139 | <div class="icon-contacts menutoggle" tabindex="0" role="button" |
140 | 140 | aria-haspopup="true" aria-controls="contactsmenu-menu" aria-expanded="false"> |
141 | - <span class="hidden-visually"><?php p($l->t('Contacts'));?></span> |
|
141 | + <span class="hidden-visually"><?php p($l->t('Contacts')); ?></span> |
|
142 | 142 | </div> |
143 | 143 | <div id="contactsmenu-menu" class="menu" |
144 | - aria-label="<?php p($l->t('Contacts menu'));?>"></div> |
|
144 | + aria-label="<?php p($l->t('Contacts menu')); ?>"></div> |
|
145 | 145 | </div> |
146 | 146 | <div id="settings"> |
147 | 147 | <div id="expand" tabindex="0" role="button" class="menutoggle" |
148 | - aria-label="<?php p($l->t('Settings'));?>" |
|
148 | + aria-label="<?php p($l->t('Settings')); ?>" |
|
149 | 149 | aria-haspopup="true" aria-controls="expanddiv" aria-expanded="false"> |
150 | 150 | <div id="avatardiv-menu" class="avatardiv<?php if ($_['userAvatarSet']) { |
151 | 151 | print_unescaped(' avatardiv-shown'); |
@@ -162,20 +162,20 @@ discard block |
||
162 | 162 | <?php |
163 | 163 | if ($_['userAvatarSet']) {?> |
164 | 164 | <img alt="" width="32" height="32" |
165 | - src="<?php p($avatar32);?>" |
|
166 | - srcset="<?php p($getUserAvatar(64));?> 2x, <?php p($getUserAvatar(128));?> 4x" |
|
165 | + src="<?php p($avatar32); ?>" |
|
166 | + srcset="<?php p($getUserAvatar(64)); ?> 2x, <?php p($getUserAvatar(128)); ?> 4x" |
|
167 | 167 | > |
168 | 168 | <?php } ?> |
169 | 169 | </div> |
170 | 170 | </div> |
171 | 171 | <nav class="settings-menu" id="expanddiv" style="display:none;" |
172 | - aria-label="<?php p($l->t('Settings menu'));?>"> |
|
172 | + aria-label="<?php p($l->t('Settings menu')); ?>"> |
|
173 | 173 | <ul> |
174 | 174 | <?php foreach ($_['settingsnavigation'] as $entry):?> |
175 | 175 | <li data-id="<?php p($entry['id']); ?>"> |
176 | 176 | <a href="<?php print_unescaped($entry['href']); ?>" |
177 | 177 | <?php if ($entry["active"]): ?> class="active"<?php endif; ?>> |
178 | - <img alt="" src="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>"> |
|
178 | + <img alt="" src="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>"> |
|
179 | 179 | <?php p($entry['name']) ?> |
180 | 180 | </a> |
181 | 181 | </li> |
@@ -28,67 +28,67 @@ |
||
28 | 28 | * |
29 | 29 | */ |
30 | 30 | return [ |
31 | - 'routes' => [ |
|
32 | - [ |
|
33 | - 'name' => 'Theming#updateStylesheet', |
|
34 | - 'url' => '/ajax/updateStylesheet', |
|
35 | - 'verb' => 'POST' |
|
36 | - ], |
|
37 | - [ |
|
38 | - 'name' => 'Theming#undo', |
|
39 | - 'url' => '/ajax/undoChanges', |
|
40 | - 'verb' => 'POST' |
|
41 | - ], |
|
42 | - [ |
|
43 | - 'name' => 'Theming#uploadImage', |
|
44 | - 'url' => '/ajax/uploadImage', |
|
45 | - 'verb' => 'POST' |
|
46 | - ], |
|
47 | - [ |
|
48 | - 'name' => 'Theming#getThemeStylesheet', |
|
49 | - 'url' => '/theme/{themeId}.css', |
|
50 | - 'verb' => 'GET', |
|
51 | - ], |
|
52 | - [ |
|
53 | - 'name' => 'Theming#getImage', |
|
54 | - 'url' => '/image/{key}', |
|
55 | - 'verb' => 'GET', |
|
56 | - ], |
|
57 | - [ |
|
58 | - 'name' => 'Theming#getManifest', |
|
59 | - 'url' => '/manifest/{app}', |
|
60 | - 'verb' => 'GET', |
|
61 | - 'defaults' => ['app' => 'core'] |
|
62 | - ], |
|
63 | - [ |
|
64 | - 'name' => 'Icon#getFavicon', |
|
65 | - 'url' => '/favicon/{app}', |
|
66 | - 'verb' => 'GET', |
|
67 | - 'defaults' => ['app' => 'core'], |
|
68 | - ], |
|
69 | - [ |
|
70 | - 'name' => 'Icon#getTouchIcon', |
|
71 | - 'url' => '/icon/{app}', |
|
72 | - 'verb' => 'GET', |
|
73 | - 'defaults' => ['app' => 'core'], |
|
74 | - ], |
|
75 | - [ |
|
76 | - 'name' => 'Icon#getThemedIcon', |
|
77 | - 'url' => '/img/{app}/{image}', |
|
78 | - 'verb' => 'GET', |
|
79 | - 'requirements' => ['image' => '.+'] |
|
80 | - ], |
|
81 | - ], |
|
82 | - 'ocs' => [ |
|
83 | - [ |
|
84 | - 'name' => 'userTheme#enableTheme', |
|
85 | - 'url' => '/api/v1/theme/{themeId}/enable', |
|
86 | - 'verb' => 'PUT', |
|
87 | - ], |
|
88 | - [ |
|
89 | - 'name' => 'userTheme#disableTheme', |
|
90 | - 'url' => '/api/v1/theme/{themeId}', |
|
91 | - 'verb' => 'DELETE', |
|
92 | - ], |
|
93 | - ] |
|
31 | + 'routes' => [ |
|
32 | + [ |
|
33 | + 'name' => 'Theming#updateStylesheet', |
|
34 | + 'url' => '/ajax/updateStylesheet', |
|
35 | + 'verb' => 'POST' |
|
36 | + ], |
|
37 | + [ |
|
38 | + 'name' => 'Theming#undo', |
|
39 | + 'url' => '/ajax/undoChanges', |
|
40 | + 'verb' => 'POST' |
|
41 | + ], |
|
42 | + [ |
|
43 | + 'name' => 'Theming#uploadImage', |
|
44 | + 'url' => '/ajax/uploadImage', |
|
45 | + 'verb' => 'POST' |
|
46 | + ], |
|
47 | + [ |
|
48 | + 'name' => 'Theming#getThemeStylesheet', |
|
49 | + 'url' => '/theme/{themeId}.css', |
|
50 | + 'verb' => 'GET', |
|
51 | + ], |
|
52 | + [ |
|
53 | + 'name' => 'Theming#getImage', |
|
54 | + 'url' => '/image/{key}', |
|
55 | + 'verb' => 'GET', |
|
56 | + ], |
|
57 | + [ |
|
58 | + 'name' => 'Theming#getManifest', |
|
59 | + 'url' => '/manifest/{app}', |
|
60 | + 'verb' => 'GET', |
|
61 | + 'defaults' => ['app' => 'core'] |
|
62 | + ], |
|
63 | + [ |
|
64 | + 'name' => 'Icon#getFavicon', |
|
65 | + 'url' => '/favicon/{app}', |
|
66 | + 'verb' => 'GET', |
|
67 | + 'defaults' => ['app' => 'core'], |
|
68 | + ], |
|
69 | + [ |
|
70 | + 'name' => 'Icon#getTouchIcon', |
|
71 | + 'url' => '/icon/{app}', |
|
72 | + 'verb' => 'GET', |
|
73 | + 'defaults' => ['app' => 'core'], |
|
74 | + ], |
|
75 | + [ |
|
76 | + 'name' => 'Icon#getThemedIcon', |
|
77 | + 'url' => '/img/{app}/{image}', |
|
78 | + 'verb' => 'GET', |
|
79 | + 'requirements' => ['image' => '.+'] |
|
80 | + ], |
|
81 | + ], |
|
82 | + 'ocs' => [ |
|
83 | + [ |
|
84 | + 'name' => 'userTheme#enableTheme', |
|
85 | + 'url' => '/api/v1/theme/{themeId}/enable', |
|
86 | + 'verb' => 'PUT', |
|
87 | + ], |
|
88 | + [ |
|
89 | + 'name' => 'userTheme#disableTheme', |
|
90 | + 'url' => '/api/v1/theme/{themeId}', |
|
91 | + 'verb' => 'DELETE', |
|
92 | + ], |
|
93 | + ] |
|
94 | 94 | ]; |
@@ -41,71 +41,71 @@ |
||
41 | 41 | |
42 | 42 | class UserThemeController extends OCSController { |
43 | 43 | |
44 | - protected string $userId; |
|
45 | - private IConfig $config; |
|
46 | - private IUserSession $userSession; |
|
47 | - private ThemesService $themesService; |
|
44 | + protected string $userId; |
|
45 | + private IConfig $config; |
|
46 | + private IUserSession $userSession; |
|
47 | + private ThemesService $themesService; |
|
48 | 48 | |
49 | - /** |
|
50 | - * Config constructor. |
|
51 | - */ |
|
52 | - public function __construct(string $appName, |
|
53 | - IRequest $request, |
|
54 | - IConfig $config, |
|
55 | - IUserSession $userSession, |
|
56 | - ThemesService $themesService) { |
|
57 | - parent::__construct($appName, $request); |
|
58 | - $this->config = $config; |
|
59 | - $this->userSession = $userSession; |
|
60 | - $this->themesService = $themesService; |
|
61 | - $this->userId = $userSession->getUser()->getUID(); |
|
62 | - } |
|
49 | + /** |
|
50 | + * Config constructor. |
|
51 | + */ |
|
52 | + public function __construct(string $appName, |
|
53 | + IRequest $request, |
|
54 | + IConfig $config, |
|
55 | + IUserSession $userSession, |
|
56 | + ThemesService $themesService) { |
|
57 | + parent::__construct($appName, $request); |
|
58 | + $this->config = $config; |
|
59 | + $this->userSession = $userSession; |
|
60 | + $this->themesService = $themesService; |
|
61 | + $this->userId = $userSession->getUser()->getUID(); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @NoAdminRequired |
|
66 | - * |
|
67 | - * Enable theme |
|
68 | - * |
|
69 | - * @param string $themeId the theme ID |
|
70 | - * @return DataResponse |
|
71 | - * @throws OCSBadRequestException|PreConditionNotMetException |
|
72 | - */ |
|
73 | - public function enableTheme(string $themeId): DataResponse { |
|
74 | - if ($themeId === '' || !$themeId) { |
|
75 | - throw new OCSBadRequestException('Invalid theme id: ' . $themeId); |
|
76 | - } |
|
64 | + /** |
|
65 | + * @NoAdminRequired |
|
66 | + * |
|
67 | + * Enable theme |
|
68 | + * |
|
69 | + * @param string $themeId the theme ID |
|
70 | + * @return DataResponse |
|
71 | + * @throws OCSBadRequestException|PreConditionNotMetException |
|
72 | + */ |
|
73 | + public function enableTheme(string $themeId): DataResponse { |
|
74 | + if ($themeId === '' || !$themeId) { |
|
75 | + throw new OCSBadRequestException('Invalid theme id: ' . $themeId); |
|
76 | + } |
|
77 | 77 | |
78 | - $themes = $this->themesService->getThemes(); |
|
79 | - if (!isset($themes[$themeId])) { |
|
80 | - throw new OCSBadRequestException('Invalid theme id: ' . $themeId); |
|
81 | - } |
|
78 | + $themes = $this->themesService->getThemes(); |
|
79 | + if (!isset($themes[$themeId])) { |
|
80 | + throw new OCSBadRequestException('Invalid theme id: ' . $themeId); |
|
81 | + } |
|
82 | 82 | |
83 | - // Enable selected theme |
|
84 | - $this->themesService->enableTheme($themes[$themeId]); |
|
85 | - return new DataResponse(); |
|
86 | - } |
|
83 | + // Enable selected theme |
|
84 | + $this->themesService->enableTheme($themes[$themeId]); |
|
85 | + return new DataResponse(); |
|
86 | + } |
|
87 | 87 | |
88 | - /** |
|
89 | - * @NoAdminRequired |
|
90 | - * |
|
91 | - * Disable theme |
|
92 | - * |
|
93 | - * @param string $themeId the theme ID |
|
94 | - * @return DataResponse |
|
95 | - * @throws OCSBadRequestException|PreConditionNotMetException |
|
96 | - */ |
|
97 | - public function disableTheme(string $themeId): DataResponse { |
|
98 | - if ($themeId === '' || !$themeId) { |
|
99 | - throw new OCSBadRequestException('Invalid theme id: ' . $themeId); |
|
100 | - } |
|
88 | + /** |
|
89 | + * @NoAdminRequired |
|
90 | + * |
|
91 | + * Disable theme |
|
92 | + * |
|
93 | + * @param string $themeId the theme ID |
|
94 | + * @return DataResponse |
|
95 | + * @throws OCSBadRequestException|PreConditionNotMetException |
|
96 | + */ |
|
97 | + public function disableTheme(string $themeId): DataResponse { |
|
98 | + if ($themeId === '' || !$themeId) { |
|
99 | + throw new OCSBadRequestException('Invalid theme id: ' . $themeId); |
|
100 | + } |
|
101 | 101 | |
102 | - $themes = $this->themesService->getThemes(); |
|
103 | - if (!isset($themes[$themeId])) { |
|
104 | - throw new OCSBadRequestException('Invalid theme id: ' . $themeId); |
|
105 | - } |
|
102 | + $themes = $this->themesService->getThemes(); |
|
103 | + if (!isset($themes[$themeId])) { |
|
104 | + throw new OCSBadRequestException('Invalid theme id: ' . $themeId); |
|
105 | + } |
|
106 | 106 | |
107 | - // Enable selected theme |
|
108 | - $this->themesService->disableTheme($themes[$themeId]); |
|
109 | - return new DataResponse(); |
|
110 | - } |
|
107 | + // Enable selected theme |
|
108 | + $this->themesService->disableTheme($themes[$themeId]); |
|
109 | + return new DataResponse(); |
|
110 | + } |
|
111 | 111 | } |
@@ -72,12 +72,12 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function enableTheme(string $themeId): DataResponse { |
74 | 74 | if ($themeId === '' || !$themeId) { |
75 | - throw new OCSBadRequestException('Invalid theme id: ' . $themeId); |
|
75 | + throw new OCSBadRequestException('Invalid theme id: '.$themeId); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $themes = $this->themesService->getThemes(); |
79 | 79 | if (!isset($themes[$themeId])) { |
80 | - throw new OCSBadRequestException('Invalid theme id: ' . $themeId); |
|
80 | + throw new OCSBadRequestException('Invalid theme id: '.$themeId); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | // Enable selected theme |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function disableTheme(string $themeId): DataResponse { |
98 | 98 | if ($themeId === '' || !$themeId) { |
99 | - throw new OCSBadRequestException('Invalid theme id: ' . $themeId); |
|
99 | + throw new OCSBadRequestException('Invalid theme id: '.$themeId); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | $themes = $this->themesService->getThemes(); |
103 | 103 | if (!isset($themes[$themeId])) { |
104 | - throw new OCSBadRequestException('Invalid theme id: ' . $themeId); |
|
104 | + throw new OCSBadRequestException('Invalid theme id: '.$themeId); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | // Enable selected theme |
@@ -65,335 +65,335 @@ |
||
65 | 65 | * @package OCA\Theming\Controller |
66 | 66 | */ |
67 | 67 | class ThemingController extends Controller { |
68 | - private ThemingDefaults $themingDefaults; |
|
69 | - private IL10N $l10n; |
|
70 | - private IConfig $config; |
|
71 | - private ITempManager $tempManager; |
|
72 | - private IAppData $appData; |
|
73 | - private IURLGenerator $urlGenerator; |
|
74 | - private IAppManager $appManager; |
|
75 | - private ImageManager $imageManager; |
|
76 | - private ThemesService $themesService; |
|
68 | + private ThemingDefaults $themingDefaults; |
|
69 | + private IL10N $l10n; |
|
70 | + private IConfig $config; |
|
71 | + private ITempManager $tempManager; |
|
72 | + private IAppData $appData; |
|
73 | + private IURLGenerator $urlGenerator; |
|
74 | + private IAppManager $appManager; |
|
75 | + private ImageManager $imageManager; |
|
76 | + private ThemesService $themesService; |
|
77 | 77 | |
78 | - public function __construct( |
|
79 | - $appName, |
|
80 | - IRequest $request, |
|
81 | - IConfig $config, |
|
82 | - ThemingDefaults $themingDefaults, |
|
83 | - IL10N $l, |
|
84 | - ITempManager $tempManager, |
|
85 | - IAppData $appData, |
|
86 | - IURLGenerator $urlGenerator, |
|
87 | - IAppManager $appManager, |
|
88 | - ImageManager $imageManager, |
|
89 | - ThemesService $themesService |
|
90 | - ) { |
|
91 | - parent::__construct($appName, $request); |
|
78 | + public function __construct( |
|
79 | + $appName, |
|
80 | + IRequest $request, |
|
81 | + IConfig $config, |
|
82 | + ThemingDefaults $themingDefaults, |
|
83 | + IL10N $l, |
|
84 | + ITempManager $tempManager, |
|
85 | + IAppData $appData, |
|
86 | + IURLGenerator $urlGenerator, |
|
87 | + IAppManager $appManager, |
|
88 | + ImageManager $imageManager, |
|
89 | + ThemesService $themesService |
|
90 | + ) { |
|
91 | + parent::__construct($appName, $request); |
|
92 | 92 | |
93 | - $this->themingDefaults = $themingDefaults; |
|
94 | - $this->l10n = $l; |
|
95 | - $this->config = $config; |
|
96 | - $this->tempManager = $tempManager; |
|
97 | - $this->appData = $appData; |
|
98 | - $this->urlGenerator = $urlGenerator; |
|
99 | - $this->appManager = $appManager; |
|
100 | - $this->imageManager = $imageManager; |
|
101 | - $this->themesService = $themesService; |
|
102 | - } |
|
93 | + $this->themingDefaults = $themingDefaults; |
|
94 | + $this->l10n = $l; |
|
95 | + $this->config = $config; |
|
96 | + $this->tempManager = $tempManager; |
|
97 | + $this->appData = $appData; |
|
98 | + $this->urlGenerator = $urlGenerator; |
|
99 | + $this->appManager = $appManager; |
|
100 | + $this->imageManager = $imageManager; |
|
101 | + $this->themesService = $themesService; |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * @AuthorizedAdminSetting(settings=OCA\Theming\Settings\Admin) |
|
106 | - * @param string $setting |
|
107 | - * @param string $value |
|
108 | - * @return DataResponse |
|
109 | - * @throws NotPermittedException |
|
110 | - */ |
|
111 | - public function updateStylesheet($setting, $value) { |
|
112 | - $value = trim($value); |
|
113 | - $error = null; |
|
114 | - switch ($setting) { |
|
115 | - case 'name': |
|
116 | - if (strlen($value) > 250) { |
|
117 | - $error = $this->l10n->t('The given name is too long'); |
|
118 | - } |
|
119 | - break; |
|
120 | - case 'url': |
|
121 | - if (strlen($value) > 500) { |
|
122 | - $error = $this->l10n->t('The given web address is too long'); |
|
123 | - } |
|
124 | - if (!$this->isValidUrl($value)) { |
|
125 | - $error = $this->l10n->t('The given web address is not a valid URL'); |
|
126 | - } |
|
127 | - break; |
|
128 | - case 'imprintUrl': |
|
129 | - if (strlen($value) > 500) { |
|
130 | - $error = $this->l10n->t('The given legal notice address is too long'); |
|
131 | - } |
|
132 | - if (!$this->isValidUrl($value)) { |
|
133 | - $error = $this->l10n->t('The given legal notice address is not a valid URL'); |
|
134 | - } |
|
135 | - break; |
|
136 | - case 'privacyUrl': |
|
137 | - if (strlen($value) > 500) { |
|
138 | - $error = $this->l10n->t('The given privacy policy address is too long'); |
|
139 | - } |
|
140 | - if (!$this->isValidUrl($value)) { |
|
141 | - $error = $this->l10n->t('The given privacy policy address is not a valid URL'); |
|
142 | - } |
|
143 | - break; |
|
144 | - case 'slogan': |
|
145 | - if (strlen($value) > 500) { |
|
146 | - $error = $this->l10n->t('The given slogan is too long'); |
|
147 | - } |
|
148 | - break; |
|
149 | - case 'color': |
|
150 | - if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) { |
|
151 | - $error = $this->l10n->t('The given color is invalid'); |
|
152 | - } |
|
153 | - break; |
|
154 | - } |
|
155 | - if ($error !== null) { |
|
156 | - return new DataResponse([ |
|
157 | - 'data' => [ |
|
158 | - 'message' => $error, |
|
159 | - ], |
|
160 | - 'status' => 'error' |
|
161 | - ], Http::STATUS_BAD_REQUEST); |
|
162 | - } |
|
104 | + /** |
|
105 | + * @AuthorizedAdminSetting(settings=OCA\Theming\Settings\Admin) |
|
106 | + * @param string $setting |
|
107 | + * @param string $value |
|
108 | + * @return DataResponse |
|
109 | + * @throws NotPermittedException |
|
110 | + */ |
|
111 | + public function updateStylesheet($setting, $value) { |
|
112 | + $value = trim($value); |
|
113 | + $error = null; |
|
114 | + switch ($setting) { |
|
115 | + case 'name': |
|
116 | + if (strlen($value) > 250) { |
|
117 | + $error = $this->l10n->t('The given name is too long'); |
|
118 | + } |
|
119 | + break; |
|
120 | + case 'url': |
|
121 | + if (strlen($value) > 500) { |
|
122 | + $error = $this->l10n->t('The given web address is too long'); |
|
123 | + } |
|
124 | + if (!$this->isValidUrl($value)) { |
|
125 | + $error = $this->l10n->t('The given web address is not a valid URL'); |
|
126 | + } |
|
127 | + break; |
|
128 | + case 'imprintUrl': |
|
129 | + if (strlen($value) > 500) { |
|
130 | + $error = $this->l10n->t('The given legal notice address is too long'); |
|
131 | + } |
|
132 | + if (!$this->isValidUrl($value)) { |
|
133 | + $error = $this->l10n->t('The given legal notice address is not a valid URL'); |
|
134 | + } |
|
135 | + break; |
|
136 | + case 'privacyUrl': |
|
137 | + if (strlen($value) > 500) { |
|
138 | + $error = $this->l10n->t('The given privacy policy address is too long'); |
|
139 | + } |
|
140 | + if (!$this->isValidUrl($value)) { |
|
141 | + $error = $this->l10n->t('The given privacy policy address is not a valid URL'); |
|
142 | + } |
|
143 | + break; |
|
144 | + case 'slogan': |
|
145 | + if (strlen($value) > 500) { |
|
146 | + $error = $this->l10n->t('The given slogan is too long'); |
|
147 | + } |
|
148 | + break; |
|
149 | + case 'color': |
|
150 | + if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) { |
|
151 | + $error = $this->l10n->t('The given color is invalid'); |
|
152 | + } |
|
153 | + break; |
|
154 | + } |
|
155 | + if ($error !== null) { |
|
156 | + return new DataResponse([ |
|
157 | + 'data' => [ |
|
158 | + 'message' => $error, |
|
159 | + ], |
|
160 | + 'status' => 'error' |
|
161 | + ], Http::STATUS_BAD_REQUEST); |
|
162 | + } |
|
163 | 163 | |
164 | - $this->themingDefaults->set($setting, $value); |
|
164 | + $this->themingDefaults->set($setting, $value); |
|
165 | 165 | |
166 | - return new DataResponse([ |
|
167 | - 'data' => [ |
|
168 | - 'message' => $this->l10n->t('Saved'), |
|
169 | - ], |
|
170 | - 'status' => 'success' |
|
171 | - ]); |
|
172 | - } |
|
166 | + return new DataResponse([ |
|
167 | + 'data' => [ |
|
168 | + 'message' => $this->l10n->t('Saved'), |
|
169 | + ], |
|
170 | + 'status' => 'success' |
|
171 | + ]); |
|
172 | + } |
|
173 | 173 | |
174 | - /** |
|
175 | - * Check that a string is a valid http/https url |
|
176 | - */ |
|
177 | - private function isValidUrl(string $url): bool { |
|
178 | - return ((strpos($url, 'http://') === 0 || strpos($url, 'https://') === 0) && |
|
179 | - filter_var($url, FILTER_VALIDATE_URL) !== false); |
|
180 | - } |
|
174 | + /** |
|
175 | + * Check that a string is a valid http/https url |
|
176 | + */ |
|
177 | + private function isValidUrl(string $url): bool { |
|
178 | + return ((strpos($url, 'http://') === 0 || strpos($url, 'https://') === 0) && |
|
179 | + filter_var($url, FILTER_VALIDATE_URL) !== false); |
|
180 | + } |
|
181 | 181 | |
182 | - /** |
|
183 | - * @AuthorizedAdminSetting(settings=OCA\Theming\Settings\Admin) |
|
184 | - * @return DataResponse |
|
185 | - * @throws NotPermittedException |
|
186 | - */ |
|
187 | - public function uploadImage(): DataResponse { |
|
188 | - $key = $this->request->getParam('key'); |
|
189 | - $image = $this->request->getUploadedFile('image'); |
|
190 | - $error = null; |
|
191 | - $phpFileUploadErrors = [ |
|
192 | - UPLOAD_ERR_OK => $this->l10n->t('The file was uploaded'), |
|
193 | - UPLOAD_ERR_INI_SIZE => $this->l10n->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'), |
|
194 | - UPLOAD_ERR_FORM_SIZE => $this->l10n->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'), |
|
195 | - UPLOAD_ERR_PARTIAL => $this->l10n->t('The file was only partially uploaded'), |
|
196 | - UPLOAD_ERR_NO_FILE => $this->l10n->t('No file was uploaded'), |
|
197 | - UPLOAD_ERR_NO_TMP_DIR => $this->l10n->t('Missing a temporary folder'), |
|
198 | - UPLOAD_ERR_CANT_WRITE => $this->l10n->t('Could not write file to disk'), |
|
199 | - UPLOAD_ERR_EXTENSION => $this->l10n->t('A PHP extension stopped the file upload'), |
|
200 | - ]; |
|
201 | - if (empty($image)) { |
|
202 | - $error = $this->l10n->t('No file uploaded'); |
|
203 | - } |
|
204 | - if (!empty($image) && array_key_exists('error', $image) && $image['error'] !== UPLOAD_ERR_OK) { |
|
205 | - $error = $phpFileUploadErrors[$image['error']]; |
|
206 | - } |
|
182 | + /** |
|
183 | + * @AuthorizedAdminSetting(settings=OCA\Theming\Settings\Admin) |
|
184 | + * @return DataResponse |
|
185 | + * @throws NotPermittedException |
|
186 | + */ |
|
187 | + public function uploadImage(): DataResponse { |
|
188 | + $key = $this->request->getParam('key'); |
|
189 | + $image = $this->request->getUploadedFile('image'); |
|
190 | + $error = null; |
|
191 | + $phpFileUploadErrors = [ |
|
192 | + UPLOAD_ERR_OK => $this->l10n->t('The file was uploaded'), |
|
193 | + UPLOAD_ERR_INI_SIZE => $this->l10n->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'), |
|
194 | + UPLOAD_ERR_FORM_SIZE => $this->l10n->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'), |
|
195 | + UPLOAD_ERR_PARTIAL => $this->l10n->t('The file was only partially uploaded'), |
|
196 | + UPLOAD_ERR_NO_FILE => $this->l10n->t('No file was uploaded'), |
|
197 | + UPLOAD_ERR_NO_TMP_DIR => $this->l10n->t('Missing a temporary folder'), |
|
198 | + UPLOAD_ERR_CANT_WRITE => $this->l10n->t('Could not write file to disk'), |
|
199 | + UPLOAD_ERR_EXTENSION => $this->l10n->t('A PHP extension stopped the file upload'), |
|
200 | + ]; |
|
201 | + if (empty($image)) { |
|
202 | + $error = $this->l10n->t('No file uploaded'); |
|
203 | + } |
|
204 | + if (!empty($image) && array_key_exists('error', $image) && $image['error'] !== UPLOAD_ERR_OK) { |
|
205 | + $error = $phpFileUploadErrors[$image['error']]; |
|
206 | + } |
|
207 | 207 | |
208 | - if ($error !== null) { |
|
209 | - return new DataResponse( |
|
210 | - [ |
|
211 | - 'data' => [ |
|
212 | - 'message' => $error |
|
213 | - ], |
|
214 | - 'status' => 'failure', |
|
215 | - ], |
|
216 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
217 | - ); |
|
218 | - } |
|
208 | + if ($error !== null) { |
|
209 | + return new DataResponse( |
|
210 | + [ |
|
211 | + 'data' => [ |
|
212 | + 'message' => $error |
|
213 | + ], |
|
214 | + 'status' => 'failure', |
|
215 | + ], |
|
216 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
217 | + ); |
|
218 | + } |
|
219 | 219 | |
220 | - try { |
|
221 | - $mime = $this->imageManager->updateImage($key, $image['tmp_name']); |
|
222 | - $this->themingDefaults->set($key . 'Mime', $mime); |
|
223 | - } catch (\Exception $e) { |
|
224 | - return new DataResponse( |
|
225 | - [ |
|
226 | - 'data' => [ |
|
227 | - 'message' => $e->getMessage() |
|
228 | - ], |
|
229 | - 'status' => 'failure', |
|
230 | - ], |
|
231 | - Http::STATUS_UNPROCESSABLE_ENTITY |
|
232 | - ); |
|
233 | - } |
|
220 | + try { |
|
221 | + $mime = $this->imageManager->updateImage($key, $image['tmp_name']); |
|
222 | + $this->themingDefaults->set($key . 'Mime', $mime); |
|
223 | + } catch (\Exception $e) { |
|
224 | + return new DataResponse( |
|
225 | + [ |
|
226 | + 'data' => [ |
|
227 | + 'message' => $e->getMessage() |
|
228 | + ], |
|
229 | + 'status' => 'failure', |
|
230 | + ], |
|
231 | + Http::STATUS_UNPROCESSABLE_ENTITY |
|
232 | + ); |
|
233 | + } |
|
234 | 234 | |
235 | - $name = $image['name']; |
|
235 | + $name = $image['name']; |
|
236 | 236 | |
237 | - return new DataResponse( |
|
238 | - [ |
|
239 | - 'data' => |
|
240 | - [ |
|
241 | - 'name' => $name, |
|
242 | - 'url' => $this->imageManager->getImageUrl($key), |
|
243 | - 'message' => $this->l10n->t('Saved'), |
|
244 | - ], |
|
245 | - 'status' => 'success' |
|
246 | - ] |
|
247 | - ); |
|
248 | - } |
|
237 | + return new DataResponse( |
|
238 | + [ |
|
239 | + 'data' => |
|
240 | + [ |
|
241 | + 'name' => $name, |
|
242 | + 'url' => $this->imageManager->getImageUrl($key), |
|
243 | + 'message' => $this->l10n->t('Saved'), |
|
244 | + ], |
|
245 | + 'status' => 'success' |
|
246 | + ] |
|
247 | + ); |
|
248 | + } |
|
249 | 249 | |
250 | - /** |
|
251 | - * Revert setting to default value |
|
252 | - * @AuthorizedAdminSetting(settings=OCA\Theming\Settings\Admin) |
|
253 | - * |
|
254 | - * @param string $setting setting which should be reverted |
|
255 | - * @return DataResponse |
|
256 | - * @throws NotPermittedException |
|
257 | - */ |
|
258 | - public function undo(string $setting): DataResponse { |
|
259 | - $value = $this->themingDefaults->undo($setting); |
|
250 | + /** |
|
251 | + * Revert setting to default value |
|
252 | + * @AuthorizedAdminSetting(settings=OCA\Theming\Settings\Admin) |
|
253 | + * |
|
254 | + * @param string $setting setting which should be reverted |
|
255 | + * @return DataResponse |
|
256 | + * @throws NotPermittedException |
|
257 | + */ |
|
258 | + public function undo(string $setting): DataResponse { |
|
259 | + $value = $this->themingDefaults->undo($setting); |
|
260 | 260 | |
261 | - return new DataResponse( |
|
262 | - [ |
|
263 | - 'data' => |
|
264 | - [ |
|
265 | - 'value' => $value, |
|
266 | - 'message' => $this->l10n->t('Saved'), |
|
267 | - ], |
|
268 | - 'status' => 'success' |
|
269 | - ] |
|
270 | - ); |
|
271 | - } |
|
261 | + return new DataResponse( |
|
262 | + [ |
|
263 | + 'data' => |
|
264 | + [ |
|
265 | + 'value' => $value, |
|
266 | + 'message' => $this->l10n->t('Saved'), |
|
267 | + ], |
|
268 | + 'status' => 'success' |
|
269 | + ] |
|
270 | + ); |
|
271 | + } |
|
272 | 272 | |
273 | - /** |
|
274 | - * @PublicPage |
|
275 | - * @NoCSRFRequired |
|
276 | - * @NoSameSiteCookieRequired |
|
277 | - * |
|
278 | - * @param string $key |
|
279 | - * @param bool $useSvg |
|
280 | - * @return FileDisplayResponse|NotFoundResponse |
|
281 | - * @throws NotPermittedException |
|
282 | - */ |
|
283 | - public function getImage(string $key, bool $useSvg = true) { |
|
284 | - try { |
|
285 | - $file = $this->imageManager->getImage($key, $useSvg); |
|
286 | - } catch (NotFoundException $e) { |
|
287 | - return new NotFoundResponse(); |
|
288 | - } |
|
273 | + /** |
|
274 | + * @PublicPage |
|
275 | + * @NoCSRFRequired |
|
276 | + * @NoSameSiteCookieRequired |
|
277 | + * |
|
278 | + * @param string $key |
|
279 | + * @param bool $useSvg |
|
280 | + * @return FileDisplayResponse|NotFoundResponse |
|
281 | + * @throws NotPermittedException |
|
282 | + */ |
|
283 | + public function getImage(string $key, bool $useSvg = true) { |
|
284 | + try { |
|
285 | + $file = $this->imageManager->getImage($key, $useSvg); |
|
286 | + } catch (NotFoundException $e) { |
|
287 | + return new NotFoundResponse(); |
|
288 | + } |
|
289 | 289 | |
290 | - $response = new FileDisplayResponse($file); |
|
291 | - $csp = new Http\ContentSecurityPolicy(); |
|
292 | - $csp->allowInlineStyle(); |
|
293 | - $response->setContentSecurityPolicy($csp); |
|
294 | - $response->cacheFor(3600); |
|
295 | - $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', '')); |
|
296 | - $response->addHeader('Content-Disposition', 'attachment; filename="' . $key . '"'); |
|
297 | - if (!$useSvg) { |
|
298 | - $response->addHeader('Content-Type', 'image/png'); |
|
299 | - } else { |
|
300 | - $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', '')); |
|
301 | - } |
|
302 | - return $response; |
|
303 | - } |
|
290 | + $response = new FileDisplayResponse($file); |
|
291 | + $csp = new Http\ContentSecurityPolicy(); |
|
292 | + $csp->allowInlineStyle(); |
|
293 | + $response->setContentSecurityPolicy($csp); |
|
294 | + $response->cacheFor(3600); |
|
295 | + $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', '')); |
|
296 | + $response->addHeader('Content-Disposition', 'attachment; filename="' . $key . '"'); |
|
297 | + if (!$useSvg) { |
|
298 | + $response->addHeader('Content-Type', 'image/png'); |
|
299 | + } else { |
|
300 | + $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', '')); |
|
301 | + } |
|
302 | + return $response; |
|
303 | + } |
|
304 | 304 | |
305 | - /** |
|
306 | - * @NoCSRFRequired |
|
307 | - * @PublicPage |
|
308 | - * @NoSameSiteCookieRequired |
|
309 | - * @NoTwoFactorRequired |
|
310 | - * |
|
311 | - * @return DataDisplayResponse|NotFoundResponse |
|
312 | - */ |
|
313 | - public function getThemeStylesheet(string $themeId, bool $plain = false, bool $withCustomCss = false) { |
|
314 | - $themes = $this->themesService->getThemes(); |
|
315 | - if (!in_array($themeId, array_keys($themes))) { |
|
316 | - return new NotFoundResponse(); |
|
317 | - } |
|
305 | + /** |
|
306 | + * @NoCSRFRequired |
|
307 | + * @PublicPage |
|
308 | + * @NoSameSiteCookieRequired |
|
309 | + * @NoTwoFactorRequired |
|
310 | + * |
|
311 | + * @return DataDisplayResponse|NotFoundResponse |
|
312 | + */ |
|
313 | + public function getThemeStylesheet(string $themeId, bool $plain = false, bool $withCustomCss = false) { |
|
314 | + $themes = $this->themesService->getThemes(); |
|
315 | + if (!in_array($themeId, array_keys($themes))) { |
|
316 | + return new NotFoundResponse(); |
|
317 | + } |
|
318 | 318 | |
319 | - $theme = $themes[$themeId]; |
|
320 | - $customCss = $theme->getCustomCss(); |
|
319 | + $theme = $themes[$themeId]; |
|
320 | + $customCss = $theme->getCustomCss(); |
|
321 | 321 | |
322 | - // Generate variables |
|
323 | - $variables = ''; |
|
324 | - foreach ($theme->getCSSVariables() as $variable => $value) { |
|
325 | - $variables .= "$variable:$value; "; |
|
326 | - }; |
|
322 | + // Generate variables |
|
323 | + $variables = ''; |
|
324 | + foreach ($theme->getCSSVariables() as $variable => $value) { |
|
325 | + $variables .= "$variable:$value; "; |
|
326 | + }; |
|
327 | 327 | |
328 | - // If plain is set, the browser decides of the css priority |
|
329 | - if ($plain) { |
|
330 | - $css = ":root { $variables } " . $customCss; |
|
331 | - } else { |
|
332 | - // If not set, we'll rely on the body class |
|
333 | - $compiler = new Compiler(); |
|
334 | - $compiledCss = $compiler->compileString("body[data-theme-$themeId] { $variables $customCss }"); |
|
335 | - $css = $compiledCss->getCss();; |
|
336 | - } |
|
328 | + // If plain is set, the browser decides of the css priority |
|
329 | + if ($plain) { |
|
330 | + $css = ":root { $variables } " . $customCss; |
|
331 | + } else { |
|
332 | + // If not set, we'll rely on the body class |
|
333 | + $compiler = new Compiler(); |
|
334 | + $compiledCss = $compiler->compileString("body[data-theme-$themeId] { $variables $customCss }"); |
|
335 | + $css = $compiledCss->getCss();; |
|
336 | + } |
|
337 | 337 | |
338 | - try { |
|
339 | - $response = new DataDisplayResponse($css, Http::STATUS_OK, ['Content-Type' => 'text/css']); |
|
340 | - $response->cacheFor(86400); |
|
341 | - return $response; |
|
342 | - } catch (NotFoundException $e) { |
|
343 | - return new NotFoundResponse(); |
|
344 | - } |
|
345 | - } |
|
338 | + try { |
|
339 | + $response = new DataDisplayResponse($css, Http::STATUS_OK, ['Content-Type' => 'text/css']); |
|
340 | + $response->cacheFor(86400); |
|
341 | + return $response; |
|
342 | + } catch (NotFoundException $e) { |
|
343 | + return new NotFoundResponse(); |
|
344 | + } |
|
345 | + } |
|
346 | 346 | |
347 | - /** |
|
348 | - * @NoCSRFRequired |
|
349 | - * @PublicPage |
|
350 | - * |
|
351 | - * @return Http\JSONResponse |
|
352 | - */ |
|
353 | - public function getManifest($app) { |
|
354 | - $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
355 | - if ($app === 'core' || $app === 'settings') { |
|
356 | - $name = $this->themingDefaults->getName(); |
|
357 | - $shortName = $this->themingDefaults->getName(); |
|
358 | - $startUrl = $this->urlGenerator->getBaseUrl(); |
|
359 | - $description = $this->themingDefaults->getSlogan(); |
|
360 | - } else { |
|
361 | - $info = $this->appManager->getAppInfo($app, false, $this->l10n->getLanguageCode()); |
|
362 | - $name = $info['name'] . ' - ' . $this->themingDefaults->getName(); |
|
363 | - $shortName = $info['name']; |
|
364 | - if (strpos($this->request->getRequestUri(), '/index.php/') !== false) { |
|
365 | - $startUrl = $this->urlGenerator->getBaseUrl() . '/index.php/apps/' . $app . '/'; |
|
366 | - } else { |
|
367 | - $startUrl = $this->urlGenerator->getBaseUrl() . '/apps/' . $app . '/'; |
|
368 | - } |
|
369 | - $description = $info['summary'] ?? ''; |
|
370 | - } |
|
371 | - $responseJS = [ |
|
372 | - 'name' => $name, |
|
373 | - 'short_name' => $shortName, |
|
374 | - 'start_url' => $startUrl, |
|
375 | - 'theme_color' => $this->themingDefaults->getColorPrimary(), |
|
376 | - 'background_color' => $this->themingDefaults->getColorPrimary(), |
|
377 | - 'description' => $description, |
|
378 | - 'icons' => |
|
379 | - [ |
|
380 | - [ |
|
381 | - 'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', |
|
382 | - ['app' => $app]) . '?v=' . $cacheBusterValue, |
|
383 | - 'type' => 'image/png', |
|
384 | - 'sizes' => '512x512' |
|
385 | - ], |
|
386 | - [ |
|
387 | - 'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', |
|
388 | - ['app' => $app]) . '?v=' . $cacheBusterValue, |
|
389 | - 'type' => 'image/svg+xml', |
|
390 | - 'sizes' => '16x16' |
|
391 | - ] |
|
392 | - ], |
|
393 | - 'display' => 'standalone' |
|
394 | - ]; |
|
395 | - $response = new Http\JSONResponse($responseJS); |
|
396 | - $response->cacheFor(3600); |
|
397 | - return $response; |
|
398 | - } |
|
347 | + /** |
|
348 | + * @NoCSRFRequired |
|
349 | + * @PublicPage |
|
350 | + * |
|
351 | + * @return Http\JSONResponse |
|
352 | + */ |
|
353 | + public function getManifest($app) { |
|
354 | + $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
355 | + if ($app === 'core' || $app === 'settings') { |
|
356 | + $name = $this->themingDefaults->getName(); |
|
357 | + $shortName = $this->themingDefaults->getName(); |
|
358 | + $startUrl = $this->urlGenerator->getBaseUrl(); |
|
359 | + $description = $this->themingDefaults->getSlogan(); |
|
360 | + } else { |
|
361 | + $info = $this->appManager->getAppInfo($app, false, $this->l10n->getLanguageCode()); |
|
362 | + $name = $info['name'] . ' - ' . $this->themingDefaults->getName(); |
|
363 | + $shortName = $info['name']; |
|
364 | + if (strpos($this->request->getRequestUri(), '/index.php/') !== false) { |
|
365 | + $startUrl = $this->urlGenerator->getBaseUrl() . '/index.php/apps/' . $app . '/'; |
|
366 | + } else { |
|
367 | + $startUrl = $this->urlGenerator->getBaseUrl() . '/apps/' . $app . '/'; |
|
368 | + } |
|
369 | + $description = $info['summary'] ?? ''; |
|
370 | + } |
|
371 | + $responseJS = [ |
|
372 | + 'name' => $name, |
|
373 | + 'short_name' => $shortName, |
|
374 | + 'start_url' => $startUrl, |
|
375 | + 'theme_color' => $this->themingDefaults->getColorPrimary(), |
|
376 | + 'background_color' => $this->themingDefaults->getColorPrimary(), |
|
377 | + 'description' => $description, |
|
378 | + 'icons' => |
|
379 | + [ |
|
380 | + [ |
|
381 | + 'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', |
|
382 | + ['app' => $app]) . '?v=' . $cacheBusterValue, |
|
383 | + 'type' => 'image/png', |
|
384 | + 'sizes' => '512x512' |
|
385 | + ], |
|
386 | + [ |
|
387 | + 'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', |
|
388 | + ['app' => $app]) . '?v=' . $cacheBusterValue, |
|
389 | + 'type' => 'image/svg+xml', |
|
390 | + 'sizes' => '16x16' |
|
391 | + ] |
|
392 | + ], |
|
393 | + 'display' => 'standalone' |
|
394 | + ]; |
|
395 | + $response = new Http\JSONResponse($responseJS); |
|
396 | + $response->cacheFor(3600); |
|
397 | + return $response; |
|
398 | + } |
|
399 | 399 | } |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | try { |
221 | 221 | $mime = $this->imageManager->updateImage($key, $image['tmp_name']); |
222 | - $this->themingDefaults->set($key . 'Mime', $mime); |
|
222 | + $this->themingDefaults->set($key.'Mime', $mime); |
|
223 | 223 | } catch (\Exception $e) { |
224 | 224 | return new DataResponse( |
225 | 225 | [ |
@@ -292,12 +292,12 @@ discard block |
||
292 | 292 | $csp->allowInlineStyle(); |
293 | 293 | $response->setContentSecurityPolicy($csp); |
294 | 294 | $response->cacheFor(3600); |
295 | - $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', '')); |
|
296 | - $response->addHeader('Content-Disposition', 'attachment; filename="' . $key . '"'); |
|
295 | + $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key.'Mime', '')); |
|
296 | + $response->addHeader('Content-Disposition', 'attachment; filename="'.$key.'"'); |
|
297 | 297 | if (!$useSvg) { |
298 | 298 | $response->addHeader('Content-Type', 'image/png'); |
299 | 299 | } else { |
300 | - $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', '')); |
|
300 | + $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key.'Mime', '')); |
|
301 | 301 | } |
302 | 302 | return $response; |
303 | 303 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | } |
318 | 318 | |
319 | 319 | $theme = $themes[$themeId]; |
320 | - $customCss = $theme->getCustomCss(); |
|
320 | + $customCss = $theme->getCustomCss(); |
|
321 | 321 | |
322 | 322 | // Generate variables |
323 | 323 | $variables = ''; |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | |
328 | 328 | // If plain is set, the browser decides of the css priority |
329 | 329 | if ($plain) { |
330 | - $css = ":root { $variables } " . $customCss; |
|
330 | + $css = ":root { $variables } ".$customCss; |
|
331 | 331 | } else { |
332 | 332 | // If not set, we'll rely on the body class |
333 | 333 | $compiler = new Compiler(); |
334 | 334 | $compiledCss = $compiler->compileString("body[data-theme-$themeId] { $variables $customCss }"); |
335 | - $css = $compiledCss->getCss();; |
|
335 | + $css = $compiledCss->getCss(); ; |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | try { |
@@ -359,12 +359,12 @@ discard block |
||
359 | 359 | $description = $this->themingDefaults->getSlogan(); |
360 | 360 | } else { |
361 | 361 | $info = $this->appManager->getAppInfo($app, false, $this->l10n->getLanguageCode()); |
362 | - $name = $info['name'] . ' - ' . $this->themingDefaults->getName(); |
|
362 | + $name = $info['name'].' - '.$this->themingDefaults->getName(); |
|
363 | 363 | $shortName = $info['name']; |
364 | 364 | if (strpos($this->request->getRequestUri(), '/index.php/') !== false) { |
365 | - $startUrl = $this->urlGenerator->getBaseUrl() . '/index.php/apps/' . $app . '/'; |
|
365 | + $startUrl = $this->urlGenerator->getBaseUrl().'/index.php/apps/'.$app.'/'; |
|
366 | 366 | } else { |
367 | - $startUrl = $this->urlGenerator->getBaseUrl() . '/apps/' . $app . '/'; |
|
367 | + $startUrl = $this->urlGenerator->getBaseUrl().'/apps/'.$app.'/'; |
|
368 | 368 | } |
369 | 369 | $description = $info['summary'] ?? ''; |
370 | 370 | } |
@@ -379,13 +379,13 @@ discard block |
||
379 | 379 | [ |
380 | 380 | [ |
381 | 381 | 'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', |
382 | - ['app' => $app]) . '?v=' . $cacheBusterValue, |
|
382 | + ['app' => $app]).'?v='.$cacheBusterValue, |
|
383 | 383 | 'type' => 'image/png', |
384 | 384 | 'sizes' => '512x512' |
385 | 385 | ], |
386 | 386 | [ |
387 | 387 | 'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', |
388 | - ['app' => $app]) . '?v=' . $cacheBusterValue, |
|
388 | + ['app' => $app]).'?v='.$cacheBusterValue, |
|
389 | 389 | 'type' => 'image/svg+xml', |
390 | 390 | 'sizes' => '16x16' |
391 | 391 | ] |
@@ -38,29 +38,29 @@ |
||
38 | 38 | |
39 | 39 | class BeforeTemplateRenderedListener implements IEventListener { |
40 | 40 | |
41 | - private IInitialStateService $initialStateService; |
|
42 | - private IServerContainer $serverContainer; |
|
43 | - private ThemeInjectionService $themeInjectionService; |
|
41 | + private IInitialStateService $initialStateService; |
|
42 | + private IServerContainer $serverContainer; |
|
43 | + private ThemeInjectionService $themeInjectionService; |
|
44 | 44 | |
45 | - public function __construct( |
|
46 | - IInitialStateService $initialStateService, |
|
47 | - IServerContainer $serverContainer, |
|
48 | - ThemeInjectionService $themeInjectionService |
|
49 | - ) { |
|
50 | - $this->initialStateService = $initialStateService; |
|
51 | - $this->serverContainer = $serverContainer; |
|
52 | - $this->themeInjectionService = $themeInjectionService; |
|
53 | - } |
|
45 | + public function __construct( |
|
46 | + IInitialStateService $initialStateService, |
|
47 | + IServerContainer $serverContainer, |
|
48 | + ThemeInjectionService $themeInjectionService |
|
49 | + ) { |
|
50 | + $this->initialStateService = $initialStateService; |
|
51 | + $this->serverContainer = $serverContainer; |
|
52 | + $this->themeInjectionService = $themeInjectionService; |
|
53 | + } |
|
54 | 54 | |
55 | - public function handle(Event $event): void { |
|
56 | - $serverContainer = $this->serverContainer; |
|
57 | - $this->initialStateService->provideLazyInitialState(Application::APP_ID, 'data', function () use ($serverContainer) { |
|
58 | - return $serverContainer->query(JSDataService::class); |
|
59 | - }); |
|
55 | + public function handle(Event $event): void { |
|
56 | + $serverContainer = $this->serverContainer; |
|
57 | + $this->initialStateService->provideLazyInitialState(Application::APP_ID, 'data', function () use ($serverContainer) { |
|
58 | + return $serverContainer->query(JSDataService::class); |
|
59 | + }); |
|
60 | 60 | |
61 | - $this->themeInjectionService->injectHeaders(); |
|
61 | + $this->themeInjectionService->injectHeaders(); |
|
62 | 62 | |
63 | - // Making sure to inject just after core |
|
64 | - \OCP\Util::addScript('theming', 'theming', 'core'); |
|
65 | - } |
|
63 | + // Making sure to inject just after core |
|
64 | + \OCP\Util::addScript('theming', 'theming', 'core'); |
|
65 | + } |
|
66 | 66 | } |
@@ -35,59 +35,59 @@ |
||
35 | 35 | |
36 | 36 | class Personal implements ISettings { |
37 | 37 | |
38 | - protected string $appName; |
|
39 | - private IConfig $config; |
|
40 | - private IUserSession $userSession; |
|
41 | - private ThemesService $themesService; |
|
42 | - private IInitialState $initialStateService; |
|
38 | + protected string $appName; |
|
39 | + private IConfig $config; |
|
40 | + private IUserSession $userSession; |
|
41 | + private ThemesService $themesService; |
|
42 | + private IInitialState $initialStateService; |
|
43 | 43 | |
44 | - public function __construct(string $appName, |
|
45 | - IConfig $config, |
|
46 | - IUserSession $userSession, |
|
47 | - ThemesService $themesService, |
|
48 | - IInitialState $initialStateService) { |
|
49 | - $this->appName = $appName; |
|
50 | - $this->config = $config; |
|
51 | - $this->userSession = $userSession; |
|
52 | - $this->themesService = $themesService; |
|
53 | - $this->initialStateService = $initialStateService; |
|
54 | - } |
|
44 | + public function __construct(string $appName, |
|
45 | + IConfig $config, |
|
46 | + IUserSession $userSession, |
|
47 | + ThemesService $themesService, |
|
48 | + IInitialState $initialStateService) { |
|
49 | + $this->appName = $appName; |
|
50 | + $this->config = $config; |
|
51 | + $this->userSession = $userSession; |
|
52 | + $this->themesService = $themesService; |
|
53 | + $this->initialStateService = $initialStateService; |
|
54 | + } |
|
55 | 55 | |
56 | - public function getForm(): TemplateResponse { |
|
57 | - $themes = array_map(function($theme) { |
|
58 | - return [ |
|
59 | - 'id' => $theme->getId(), |
|
60 | - 'type' => $theme->getType(), |
|
61 | - 'title' => $theme->getTitle(), |
|
62 | - 'enableLabel' => $theme->getEnableLabel(), |
|
63 | - 'description' => $theme->getDescription(), |
|
64 | - 'enabled' => $this->themesService->isEnabled($theme), |
|
65 | - ]; |
|
66 | - }, $this->themesService->getThemes()); |
|
56 | + public function getForm(): TemplateResponse { |
|
57 | + $themes = array_map(function($theme) { |
|
58 | + return [ |
|
59 | + 'id' => $theme->getId(), |
|
60 | + 'type' => $theme->getType(), |
|
61 | + 'title' => $theme->getTitle(), |
|
62 | + 'enableLabel' => $theme->getEnableLabel(), |
|
63 | + 'description' => $theme->getDescription(), |
|
64 | + 'enabled' => $this->themesService->isEnabled($theme), |
|
65 | + ]; |
|
66 | + }, $this->themesService->getThemes()); |
|
67 | 67 | |
68 | - $this->initialStateService->provideInitialState('themes', array_values($themes)); |
|
69 | - Util::addScript($this->appName, 'theming-settings'); |
|
68 | + $this->initialStateService->provideInitialState('themes', array_values($themes)); |
|
69 | + Util::addScript($this->appName, 'theming-settings'); |
|
70 | 70 | |
71 | - return new TemplateResponse($this->appName, 'settings-personal'); |
|
72 | - } |
|
71 | + return new TemplateResponse($this->appName, 'settings-personal'); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return string the section ID, e.g. 'sharing' |
|
76 | - * @since 9.1 |
|
77 | - */ |
|
78 | - public function getSection(): string { |
|
79 | - return $this->appName; |
|
80 | - } |
|
74 | + /** |
|
75 | + * @return string the section ID, e.g. 'sharing' |
|
76 | + * @since 9.1 |
|
77 | + */ |
|
78 | + public function getSection(): string { |
|
79 | + return $this->appName; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return int whether the form should be rather on the top or bottom of |
|
84 | - * the admin section. The forms are arranged in ascending order of the |
|
85 | - * priority values. It is required to return a value between 0 and 100. |
|
86 | - * |
|
87 | - * E.g.: 70 |
|
88 | - * @since 9.1 |
|
89 | - */ |
|
90 | - public function getPriority(): int { |
|
91 | - return 40; |
|
92 | - } |
|
82 | + /** |
|
83 | + * @return int whether the form should be rather on the top or bottom of |
|
84 | + * the admin section. The forms are arranged in ascending order of the |
|
85 | + * priority values. It is required to return a value between 0 and 100. |
|
86 | + * |
|
87 | + * E.g.: 70 |
|
88 | + * @since 9.1 |
|
89 | + */ |
|
90 | + public function getPriority(): int { |
|
91 | + return 40; |
|
92 | + } |
|
93 | 93 | } |
@@ -36,82 +36,82 @@ |
||
36 | 36 | use OCP\Settings\IDelegatedSettings; |
37 | 37 | |
38 | 38 | class Admin implements IDelegatedSettings { |
39 | - private string $appName; |
|
40 | - private IConfig $config; |
|
41 | - private IL10N $l; |
|
42 | - private ThemingDefaults $themingDefaults; |
|
43 | - private IURLGenerator $urlGenerator; |
|
44 | - private ImageManager $imageManager; |
|
39 | + private string $appName; |
|
40 | + private IConfig $config; |
|
41 | + private IL10N $l; |
|
42 | + private ThemingDefaults $themingDefaults; |
|
43 | + private IURLGenerator $urlGenerator; |
|
44 | + private ImageManager $imageManager; |
|
45 | 45 | |
46 | - public function __construct(string $appName, |
|
47 | - IConfig $config, |
|
48 | - IL10N $l, |
|
49 | - ThemingDefaults $themingDefaults, |
|
50 | - IURLGenerator $urlGenerator, |
|
51 | - ImageManager $imageManager) { |
|
52 | - $this->appName = $appName; |
|
53 | - $this->config = $config; |
|
54 | - $this->l = $l; |
|
55 | - $this->themingDefaults = $themingDefaults; |
|
56 | - $this->urlGenerator = $urlGenerator; |
|
57 | - $this->imageManager = $imageManager; |
|
58 | - } |
|
46 | + public function __construct(string $appName, |
|
47 | + IConfig $config, |
|
48 | + IL10N $l, |
|
49 | + ThemingDefaults $themingDefaults, |
|
50 | + IURLGenerator $urlGenerator, |
|
51 | + ImageManager $imageManager) { |
|
52 | + $this->appName = $appName; |
|
53 | + $this->config = $config; |
|
54 | + $this->l = $l; |
|
55 | + $this->themingDefaults = $themingDefaults; |
|
56 | + $this->urlGenerator = $urlGenerator; |
|
57 | + $this->imageManager = $imageManager; |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * @return TemplateResponse |
|
62 | - */ |
|
63 | - public function getForm(): TemplateResponse { |
|
64 | - $themable = true; |
|
65 | - $errorMessage = ''; |
|
66 | - $theme = $this->config->getSystemValue('theme', ''); |
|
67 | - if ($theme !== '') { |
|
68 | - $themable = false; |
|
69 | - $errorMessage = $this->l->t('You are already using a custom theme. Theming app settings might be overwritten by that.'); |
|
70 | - } |
|
60 | + /** |
|
61 | + * @return TemplateResponse |
|
62 | + */ |
|
63 | + public function getForm(): TemplateResponse { |
|
64 | + $themable = true; |
|
65 | + $errorMessage = ''; |
|
66 | + $theme = $this->config->getSystemValue('theme', ''); |
|
67 | + if ($theme !== '') { |
|
68 | + $themable = false; |
|
69 | + $errorMessage = $this->l->t('You are already using a custom theme. Theming app settings might be overwritten by that.'); |
|
70 | + } |
|
71 | 71 | |
72 | - $parameters = [ |
|
73 | - 'themable' => $themable, |
|
74 | - 'errorMessage' => $errorMessage, |
|
75 | - 'name' => $this->themingDefaults->getEntity(), |
|
76 | - 'url' => $this->themingDefaults->getBaseUrl(), |
|
77 | - 'slogan' => $this->themingDefaults->getSlogan(), |
|
78 | - 'color' => $this->themingDefaults->getColorPrimary(), |
|
79 | - 'uploadLogoRoute' => $this->urlGenerator->linkToRoute('theming.Theming.uploadImage'), |
|
80 | - 'canThemeIcons' => $this->imageManager->shouldReplaceIcons(), |
|
81 | - 'iconDocs' => $this->urlGenerator->linkToDocs('admin-theming-icons'), |
|
82 | - 'images' => $this->imageManager->getCustomImages(), |
|
83 | - 'imprintUrl' => $this->themingDefaults->getImprintUrl(), |
|
84 | - 'privacyUrl' => $this->themingDefaults->getPrivacyUrl(), |
|
85 | - ]; |
|
72 | + $parameters = [ |
|
73 | + 'themable' => $themable, |
|
74 | + 'errorMessage' => $errorMessage, |
|
75 | + 'name' => $this->themingDefaults->getEntity(), |
|
76 | + 'url' => $this->themingDefaults->getBaseUrl(), |
|
77 | + 'slogan' => $this->themingDefaults->getSlogan(), |
|
78 | + 'color' => $this->themingDefaults->getColorPrimary(), |
|
79 | + 'uploadLogoRoute' => $this->urlGenerator->linkToRoute('theming.Theming.uploadImage'), |
|
80 | + 'canThemeIcons' => $this->imageManager->shouldReplaceIcons(), |
|
81 | + 'iconDocs' => $this->urlGenerator->linkToDocs('admin-theming-icons'), |
|
82 | + 'images' => $this->imageManager->getCustomImages(), |
|
83 | + 'imprintUrl' => $this->themingDefaults->getImprintUrl(), |
|
84 | + 'privacyUrl' => $this->themingDefaults->getPrivacyUrl(), |
|
85 | + ]; |
|
86 | 86 | |
87 | - return new TemplateResponse($this->appName, 'settings-admin', $parameters, ''); |
|
88 | - } |
|
87 | + return new TemplateResponse($this->appName, 'settings-admin', $parameters, ''); |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return string the section ID, e.g. 'sharing' |
|
92 | - */ |
|
93 | - public function getSection(): string { |
|
94 | - return $this->appName; |
|
95 | - } |
|
90 | + /** |
|
91 | + * @return string the section ID, e.g. 'sharing' |
|
92 | + */ |
|
93 | + public function getSection(): string { |
|
94 | + return $this->appName; |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * @return int whether the form should be rather on the top or bottom of |
|
99 | - * the admin section. The forms are arranged in ascending order of the |
|
100 | - * priority values. It is required to return a value between 0 and 100. |
|
101 | - * |
|
102 | - * E.g.: 70 |
|
103 | - */ |
|
104 | - public function getPriority(): int { |
|
105 | - return 5; |
|
106 | - } |
|
97 | + /** |
|
98 | + * @return int whether the form should be rather on the top or bottom of |
|
99 | + * the admin section. The forms are arranged in ascending order of the |
|
100 | + * priority values. It is required to return a value between 0 and 100. |
|
101 | + * |
|
102 | + * E.g.: 70 |
|
103 | + */ |
|
104 | + public function getPriority(): int { |
|
105 | + return 5; |
|
106 | + } |
|
107 | 107 | |
108 | - public function getName(): ?string { |
|
109 | - return null; // Only one setting in this section |
|
110 | - } |
|
108 | + public function getName(): ?string { |
|
109 | + return null; // Only one setting in this section |
|
110 | + } |
|
111 | 111 | |
112 | - public function getAuthorizedAppConfig(): array { |
|
113 | - return [ |
|
114 | - $this->appName => '/.*/', |
|
115 | - ]; |
|
116 | - } |
|
112 | + public function getAuthorizedAppConfig(): array { |
|
113 | + return [ |
|
114 | + $this->appName => '/.*/', |
|
115 | + ]; |
|
116 | + } |
|
117 | 117 | } |
@@ -29,72 +29,72 @@ |
||
29 | 29 | |
30 | 30 | class PersonalSection implements IIconSection { |
31 | 31 | |
32 | - /** @var string */ |
|
33 | - protected $appName; |
|
32 | + /** @var string */ |
|
33 | + protected $appName; |
|
34 | 34 | |
35 | - /** @var IURLGenerator */ |
|
36 | - private $urlGenerator; |
|
35 | + /** @var IURLGenerator */ |
|
36 | + private $urlGenerator; |
|
37 | 37 | |
38 | - /** @var IL10N */ |
|
39 | - private $l; |
|
38 | + /** @var IL10N */ |
|
39 | + private $l; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Personal Section constructor. |
|
43 | - * |
|
44 | - * @param string $appName |
|
45 | - * @param IURLGenerator $urlGenerator |
|
46 | - * @param IL10N $l |
|
47 | - */ |
|
48 | - public function __construct(string $appName, |
|
49 | - IURLGenerator $urlGenerator, |
|
50 | - IL10N $l) { |
|
51 | - $this->appName = $appName; |
|
52 | - $this->urlGenerator = $urlGenerator; |
|
53 | - $this->l = $l; |
|
54 | - } |
|
41 | + /** |
|
42 | + * Personal Section constructor. |
|
43 | + * |
|
44 | + * @param string $appName |
|
45 | + * @param IURLGenerator $urlGenerator |
|
46 | + * @param IL10N $l |
|
47 | + */ |
|
48 | + public function __construct(string $appName, |
|
49 | + IURLGenerator $urlGenerator, |
|
50 | + IL10N $l) { |
|
51 | + $this->appName = $appName; |
|
52 | + $this->urlGenerator = $urlGenerator; |
|
53 | + $this->l = $l; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * returns the relative path to an 16*16 icon describing the section. |
|
58 | - * e.g. '/core/img/places/files.svg' |
|
59 | - * |
|
60 | - * @returns string |
|
61 | - * @since 13.0.0 |
|
62 | - */ |
|
63 | - public function getIcon() { |
|
64 | - return $this->urlGenerator->imagePath($this->appName, 'app-dark.svg'); |
|
65 | - } |
|
56 | + /** |
|
57 | + * returns the relative path to an 16*16 icon describing the section. |
|
58 | + * e.g. '/core/img/places/files.svg' |
|
59 | + * |
|
60 | + * @returns string |
|
61 | + * @since 13.0.0 |
|
62 | + */ |
|
63 | + public function getIcon() { |
|
64 | + return $this->urlGenerator->imagePath($this->appName, 'app-dark.svg'); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * returns the ID of the section. It is supposed to be a lower case string, |
|
69 | - * e.g. 'ldap' |
|
70 | - * |
|
71 | - * @returns string |
|
72 | - * @since 9.1 |
|
73 | - */ |
|
74 | - public function getID() { |
|
75 | - return $this->appName; |
|
76 | - } |
|
67 | + /** |
|
68 | + * returns the ID of the section. It is supposed to be a lower case string, |
|
69 | + * e.g. 'ldap' |
|
70 | + * |
|
71 | + * @returns string |
|
72 | + * @since 9.1 |
|
73 | + */ |
|
74 | + public function getID() { |
|
75 | + return $this->appName; |
|
76 | + } |
|
77 | 77 | |
78 | - /** |
|
79 | - * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
80 | - * integration'. Use the L10N service to translate it. |
|
81 | - * |
|
82 | - * @return string |
|
83 | - * @since 9.1 |
|
84 | - */ |
|
85 | - public function getName() { |
|
86 | - return $this->l->t('Appearance and accessibility'); |
|
87 | - } |
|
78 | + /** |
|
79 | + * returns the translated name as it should be displayed, e.g. 'LDAP / AD |
|
80 | + * integration'. Use the L10N service to translate it. |
|
81 | + * |
|
82 | + * @return string |
|
83 | + * @since 9.1 |
|
84 | + */ |
|
85 | + public function getName() { |
|
86 | + return $this->l->t('Appearance and accessibility'); |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return int whether the form should be rather on the top or bottom of |
|
91 | - * the settings navigation. The sections are arranged in ascending order of |
|
92 | - * the priority values. It is required to return a value between 0 and 99. |
|
93 | - * |
|
94 | - * E.g.: 70 |
|
95 | - * @since 9.1 |
|
96 | - */ |
|
97 | - public function getPriority() { |
|
98 | - return 15; |
|
99 | - } |
|
89 | + /** |
|
90 | + * @return int whether the form should be rather on the top or bottom of |
|
91 | + * the settings navigation. The sections are arranged in ascending order of |
|
92 | + * the priority values. It is required to return a value between 0 and 99. |
|
93 | + * |
|
94 | + * E.g.: 70 |
|
95 | + * @since 9.1 |
|
96 | + */ |
|
97 | + public function getPriority() { |
|
98 | + return 15; |
|
99 | + } |
|
100 | 100 | } |
@@ -40,84 +40,84 @@ |
||
40 | 40 | |
41 | 41 | class MigrateUserConfig implements IRepairStep { |
42 | 42 | |
43 | - protected IUserManager $userManager; |
|
44 | - protected IConfig $config; |
|
45 | - protected ThemesService $themesService; |
|
46 | - protected DarkTheme $darkTheme; |
|
47 | - protected DarkHighContrastTheme $darkHighContrastTheme; |
|
48 | - protected HighContrastTheme $highContrastTheme; |
|
49 | - protected DyslexiaFont $dyslexiaFont; |
|
43 | + protected IUserManager $userManager; |
|
44 | + protected IConfig $config; |
|
45 | + protected ThemesService $themesService; |
|
46 | + protected DarkTheme $darkTheme; |
|
47 | + protected DarkHighContrastTheme $darkHighContrastTheme; |
|
48 | + protected HighContrastTheme $highContrastTheme; |
|
49 | + protected DyslexiaFont $dyslexiaFont; |
|
50 | 50 | |
51 | - /** |
|
52 | - * MigrateUserConfig constructor. |
|
53 | - */ |
|
54 | - public function __construct(IConfig $config, |
|
55 | - IUserManager $userManager, |
|
56 | - ThemesService $themesService, |
|
57 | - DarkTheme $darkTheme, |
|
58 | - DarkHighContrastTheme $darkHighContrastTheme, |
|
59 | - HighContrastTheme $highContrastTheme, |
|
60 | - DyslexiaFont $dyslexiaFont) { |
|
61 | - $this->config = $config; |
|
62 | - $this->userManager = $userManager; |
|
63 | - $this->themesService = $themesService; |
|
51 | + /** |
|
52 | + * MigrateUserConfig constructor. |
|
53 | + */ |
|
54 | + public function __construct(IConfig $config, |
|
55 | + IUserManager $userManager, |
|
56 | + ThemesService $themesService, |
|
57 | + DarkTheme $darkTheme, |
|
58 | + DarkHighContrastTheme $darkHighContrastTheme, |
|
59 | + HighContrastTheme $highContrastTheme, |
|
60 | + DyslexiaFont $dyslexiaFont) { |
|
61 | + $this->config = $config; |
|
62 | + $this->userManager = $userManager; |
|
63 | + $this->themesService = $themesService; |
|
64 | 64 | |
65 | - $this->darkTheme = $darkTheme; |
|
66 | - $this->darkHighContrastTheme = $darkHighContrastTheme; |
|
67 | - $this->highContrastTheme = $highContrastTheme; |
|
68 | - $this->dyslexiaFont = $dyslexiaFont; |
|
69 | - } |
|
65 | + $this->darkTheme = $darkTheme; |
|
66 | + $this->darkHighContrastTheme = $darkHighContrastTheme; |
|
67 | + $this->highContrastTheme = $highContrastTheme; |
|
68 | + $this->dyslexiaFont = $dyslexiaFont; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Returns the step's name |
|
73 | - * |
|
74 | - * @return string |
|
75 | - * @since 25.0.0 |
|
76 | - */ |
|
77 | - public function getName() { |
|
78 | - return 'Migrate old user accessibility config'; |
|
79 | - } |
|
71 | + /** |
|
72 | + * Returns the step's name |
|
73 | + * |
|
74 | + * @return string |
|
75 | + * @since 25.0.0 |
|
76 | + */ |
|
77 | + public function getName() { |
|
78 | + return 'Migrate old user accessibility config'; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Run repair step. |
|
83 | - * Must throw exception on error. |
|
84 | - * |
|
85 | - * @param IOutput $output |
|
86 | - * @throws \Exception in case of failure |
|
87 | - * @since 25.0.0 |
|
88 | - */ |
|
89 | - public function run(IOutput $output) { |
|
90 | - $output->startProgress(); |
|
91 | - $this->userManager->callForSeenUsers(function (IUser $user) use ($output) { |
|
92 | - $config = []; |
|
81 | + /** |
|
82 | + * Run repair step. |
|
83 | + * Must throw exception on error. |
|
84 | + * |
|
85 | + * @param IOutput $output |
|
86 | + * @throws \Exception in case of failure |
|
87 | + * @since 25.0.0 |
|
88 | + */ |
|
89 | + public function run(IOutput $output) { |
|
90 | + $output->startProgress(); |
|
91 | + $this->userManager->callForSeenUsers(function (IUser $user) use ($output) { |
|
92 | + $config = []; |
|
93 | 93 | |
94 | - $font = $this->config->getUserValue($user->getUID(), 'accessibility', 'font', false); |
|
95 | - $highcontrast = $this->config->getUserValue($user->getUID(), 'accessibility', 'highcontrast', false); |
|
96 | - $theme = $this->config->getUserValue($user->getUID(), 'accessibility', 'theme', false); |
|
94 | + $font = $this->config->getUserValue($user->getUID(), 'accessibility', 'font', false); |
|
95 | + $highcontrast = $this->config->getUserValue($user->getUID(), 'accessibility', 'highcontrast', false); |
|
96 | + $theme = $this->config->getUserValue($user->getUID(), 'accessibility', 'theme', false); |
|
97 | 97 | |
98 | - if ($highcontrast || $theme) { |
|
99 | - if ($theme === 'dark' && $highcontrast === 'highcontrast') { |
|
100 | - $config[] = $this->darkHighContrastTheme->getId(); |
|
101 | - } else if ($theme === 'dark') { |
|
102 | - $config[] = $this->darkTheme->getId(); |
|
103 | - } else if ($highcontrast === 'highcontrast') { |
|
104 | - $config[] = $this->highContrastTheme->getId(); |
|
105 | - } |
|
106 | - } |
|
98 | + if ($highcontrast || $theme) { |
|
99 | + if ($theme === 'dark' && $highcontrast === 'highcontrast') { |
|
100 | + $config[] = $this->darkHighContrastTheme->getId(); |
|
101 | + } else if ($theme === 'dark') { |
|
102 | + $config[] = $this->darkTheme->getId(); |
|
103 | + } else if ($highcontrast === 'highcontrast') { |
|
104 | + $config[] = $this->highContrastTheme->getId(); |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - if ($font === 'fontdyslexic') { |
|
109 | - $config[] = $this->dyslexiaFont->getId(); |
|
110 | - } |
|
108 | + if ($font === 'fontdyslexic') { |
|
109 | + $config[] = $this->dyslexiaFont->getId(); |
|
110 | + } |
|
111 | 111 | |
112 | - if (!empty($config)) { |
|
113 | - $this->config->setUserValue($user->getUID(), Application::APP_ID, 'enabled-themes', json_encode(array_unique($config))); |
|
114 | - } |
|
112 | + if (!empty($config)) { |
|
113 | + $this->config->setUserValue($user->getUID(), Application::APP_ID, 'enabled-themes', json_encode(array_unique($config))); |
|
114 | + } |
|
115 | 115 | |
116 | - $output->advance(); |
|
117 | - }); |
|
116 | + $output->advance(); |
|
117 | + }); |
|
118 | 118 | |
119 | - $this->config->deleteAppFromAllUsers('accessibility'); |
|
119 | + $this->config->deleteAppFromAllUsers('accessibility'); |
|
120 | 120 | |
121 | - $output->finishProgress(); |
|
122 | - } |
|
121 | + $output->finishProgress(); |
|
122 | + } |
|
123 | 123 | } |
@@ -88,7 +88,7 @@ |
||
88 | 88 | */ |
89 | 89 | public function run(IOutput $output) { |
90 | 90 | $output->startProgress(); |
91 | - $this->userManager->callForSeenUsers(function (IUser $user) use ($output) { |
|
91 | + $this->userManager->callForSeenUsers(function(IUser $user) use ($output) { |
|
92 | 92 | $config = []; |
93 | 93 | |
94 | 94 | $font = $this->config->getUserValue($user->getUID(), 'accessibility', 'font', false); |