@@ -34,91 +34,91 @@ |
||
34 | 34 | use OCP\Security\ISecureRandom; |
35 | 35 | |
36 | 36 | class SettingsController extends Controller { |
37 | - /** @var ClientMapper */ |
|
38 | - private $clientMapper; |
|
39 | - /** @var ISecureRandom */ |
|
40 | - private $secureRandom; |
|
41 | - /** @var AccessTokenMapper */ |
|
42 | - private $accessTokenMapper; |
|
43 | - /** @var DefaultTokenMapper */ |
|
44 | - private $defaultTokenMapper; |
|
45 | - /** @var IL10N */ |
|
46 | - private $l; |
|
37 | + /** @var ClientMapper */ |
|
38 | + private $clientMapper; |
|
39 | + /** @var ISecureRandom */ |
|
40 | + private $secureRandom; |
|
41 | + /** @var AccessTokenMapper */ |
|
42 | + private $accessTokenMapper; |
|
43 | + /** @var DefaultTokenMapper */ |
|
44 | + private $defaultTokenMapper; |
|
45 | + /** @var IL10N */ |
|
46 | + private $l; |
|
47 | 47 | |
48 | - const validChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
48 | + const validChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param string $appName |
|
52 | - * @param IRequest $request |
|
53 | - * @param ClientMapper $clientMapper |
|
54 | - * @param ISecureRandom $secureRandom |
|
55 | - * @param AccessTokenMapper $accessTokenMapper |
|
56 | - * @param DefaultTokenMapper $defaultTokenMapper |
|
57 | - */ |
|
58 | - public function __construct(string $appName, |
|
59 | - IRequest $request, |
|
60 | - ClientMapper $clientMapper, |
|
61 | - ISecureRandom $secureRandom, |
|
62 | - AccessTokenMapper $accessTokenMapper, |
|
63 | - DefaultTokenMapper $defaultTokenMapper, |
|
64 | - IL10N $l |
|
65 | - ) { |
|
66 | - parent::__construct($appName, $request); |
|
67 | - $this->secureRandom = $secureRandom; |
|
68 | - $this->clientMapper = $clientMapper; |
|
69 | - $this->accessTokenMapper = $accessTokenMapper; |
|
70 | - $this->defaultTokenMapper = $defaultTokenMapper; |
|
71 | - $this->l = $l; |
|
72 | - } |
|
50 | + /** |
|
51 | + * @param string $appName |
|
52 | + * @param IRequest $request |
|
53 | + * @param ClientMapper $clientMapper |
|
54 | + * @param ISecureRandom $secureRandom |
|
55 | + * @param AccessTokenMapper $accessTokenMapper |
|
56 | + * @param DefaultTokenMapper $defaultTokenMapper |
|
57 | + */ |
|
58 | + public function __construct(string $appName, |
|
59 | + IRequest $request, |
|
60 | + ClientMapper $clientMapper, |
|
61 | + ISecureRandom $secureRandom, |
|
62 | + AccessTokenMapper $accessTokenMapper, |
|
63 | + DefaultTokenMapper $defaultTokenMapper, |
|
64 | + IL10N $l |
|
65 | + ) { |
|
66 | + parent::__construct($appName, $request); |
|
67 | + $this->secureRandom = $secureRandom; |
|
68 | + $this->clientMapper = $clientMapper; |
|
69 | + $this->accessTokenMapper = $accessTokenMapper; |
|
70 | + $this->defaultTokenMapper = $defaultTokenMapper; |
|
71 | + $this->l = $l; |
|
72 | + } |
|
73 | 73 | |
74 | - public function addClient(string $name, |
|
75 | - string $redirectUri): JSONResponse { |
|
74 | + public function addClient(string $name, |
|
75 | + string $redirectUri): JSONResponse { |
|
76 | 76 | |
77 | - if (filter_var($redirectUri, FILTER_VALIDATE_URL) === false) { |
|
78 | - return new JSONResponse(['message' => $this->l->t('Your redirect URL needs to be a full URL for example: https://yourdomain.com/path')], Http::STATUS_BAD_REQUEST); |
|
79 | - } |
|
77 | + if (filter_var($redirectUri, FILTER_VALIDATE_URL) === false) { |
|
78 | + return new JSONResponse(['message' => $this->l->t('Your redirect URL needs to be a full URL for example: https://yourdomain.com/path')], Http::STATUS_BAD_REQUEST); |
|
79 | + } |
|
80 | 80 | |
81 | - $client = new Client(); |
|
82 | - $client->setName($name); |
|
83 | - $client->setRedirectUri($redirectUri); |
|
84 | - $client->setSecret($this->secureRandom->generate(64, self::validChars)); |
|
85 | - $client->setClientIdentifier($this->secureRandom->generate(64, self::validChars)); |
|
86 | - $client = $this->clientMapper->insert($client); |
|
81 | + $client = new Client(); |
|
82 | + $client->setName($name); |
|
83 | + $client->setRedirectUri($redirectUri); |
|
84 | + $client->setSecret($this->secureRandom->generate(64, self::validChars)); |
|
85 | + $client->setClientIdentifier($this->secureRandom->generate(64, self::validChars)); |
|
86 | + $client = $this->clientMapper->insert($client); |
|
87 | 87 | |
88 | - $result = [ |
|
89 | - 'id' => $client->getId(), |
|
90 | - 'name' => $client->getName(), |
|
91 | - 'redirectUri' => $client->getRedirectUri(), |
|
92 | - 'clientId' => $client->getClientIdentifier(), |
|
93 | - 'clientSecret' => $client->getSecret(), |
|
94 | - ]; |
|
88 | + $result = [ |
|
89 | + 'id' => $client->getId(), |
|
90 | + 'name' => $client->getName(), |
|
91 | + 'redirectUri' => $client->getRedirectUri(), |
|
92 | + 'clientId' => $client->getClientIdentifier(), |
|
93 | + 'clientSecret' => $client->getSecret(), |
|
94 | + ]; |
|
95 | 95 | |
96 | - return new JSONResponse($result); |
|
97 | - } |
|
96 | + return new JSONResponse($result); |
|
97 | + } |
|
98 | 98 | |
99 | - public function deleteClient(int $id): JSONResponse { |
|
100 | - $client = $this->clientMapper->getByUid($id); |
|
101 | - $this->accessTokenMapper->deleteByClientId($id); |
|
102 | - $this->defaultTokenMapper->deleteByName($client->getName()); |
|
103 | - $this->clientMapper->delete($client); |
|
104 | - return new JSONResponse([]); |
|
105 | - } |
|
99 | + public function deleteClient(int $id): JSONResponse { |
|
100 | + $client = $this->clientMapper->getByUid($id); |
|
101 | + $this->accessTokenMapper->deleteByClientId($id); |
|
102 | + $this->defaultTokenMapper->deleteByName($client->getName()); |
|
103 | + $this->clientMapper->delete($client); |
|
104 | + return new JSONResponse([]); |
|
105 | + } |
|
106 | 106 | |
107 | - public function getClients(): JSONResponse { |
|
108 | - $clients = $this->clientMapper->getClients(); |
|
107 | + public function getClients(): JSONResponse { |
|
108 | + $clients = $this->clientMapper->getClients(); |
|
109 | 109 | |
110 | - $result = []; |
|
110 | + $result = []; |
|
111 | 111 | |
112 | - foreach ($clients as $client) { |
|
113 | - $result[] = [ |
|
114 | - 'id' => $client->getId(), |
|
115 | - 'name' => $client->getName(), |
|
116 | - 'redirectUri' => $client->getRedirectUri(), |
|
117 | - 'clientId' => $client->getClientIdentifier(), |
|
118 | - 'clientSecret' => $client->getSecret(), |
|
119 | - ]; |
|
120 | - } |
|
112 | + foreach ($clients as $client) { |
|
113 | + $result[] = [ |
|
114 | + 'id' => $client->getId(), |
|
115 | + 'name' => $client->getName(), |
|
116 | + 'redirectUri' => $client->getRedirectUri(), |
|
117 | + 'clientId' => $client->getClientIdentifier(), |
|
118 | + 'clientSecret' => $client->getSecret(), |
|
119 | + ]; |
|
120 | + } |
|
121 | 121 | |
122 | - return new JSONResponse($result); |
|
123 | - } |
|
122 | + return new JSONResponse($result); |
|
123 | + } |
|
124 | 124 | } |
@@ -44,359 +44,359 @@ |
||
44 | 44 | |
45 | 45 | class ThemingDefaults extends \OC_Defaults { |
46 | 46 | |
47 | - /** @var IConfig */ |
|
48 | - private $config; |
|
49 | - /** @var IL10N */ |
|
50 | - private $l; |
|
51 | - /** @var ImageManager */ |
|
52 | - private $imageManager; |
|
53 | - /** @var IURLGenerator */ |
|
54 | - private $urlGenerator; |
|
55 | - /** @var ICacheFactory */ |
|
56 | - private $cacheFactory; |
|
57 | - /** @var Util */ |
|
58 | - private $util; |
|
59 | - /** @var IAppManager */ |
|
60 | - private $appManager; |
|
61 | - /** @var string */ |
|
62 | - private $name; |
|
63 | - /** @var string */ |
|
64 | - private $title; |
|
65 | - /** @var string */ |
|
66 | - private $entity; |
|
67 | - /** @var string */ |
|
68 | - private $url; |
|
69 | - /** @var string */ |
|
70 | - private $slogan; |
|
71 | - /** @var string */ |
|
72 | - private $color; |
|
73 | - |
|
74 | - /** @var string */ |
|
75 | - private $iTunesAppId; |
|
76 | - /** @var string */ |
|
77 | - private $iOSClientUrl; |
|
78 | - /** @var string */ |
|
79 | - private $AndroidClientUrl; |
|
80 | - |
|
81 | - /** |
|
82 | - * ThemingDefaults constructor. |
|
83 | - * |
|
84 | - * @param IConfig $config |
|
85 | - * @param IL10N $l |
|
86 | - * @param ImageManager $imageManager |
|
87 | - * @param IURLGenerator $urlGenerator |
|
88 | - * @param ICacheFactory $cacheFactory |
|
89 | - * @param Util $util |
|
90 | - * @param IAppManager $appManager |
|
91 | - */ |
|
92 | - public function __construct(IConfig $config, |
|
93 | - IL10N $l, |
|
94 | - IURLGenerator $urlGenerator, |
|
95 | - ICacheFactory $cacheFactory, |
|
96 | - Util $util, |
|
97 | - ImageManager $imageManager, |
|
98 | - IAppManager $appManager |
|
99 | - ) { |
|
100 | - parent::__construct(); |
|
101 | - $this->config = $config; |
|
102 | - $this->l = $l; |
|
103 | - $this->imageManager = $imageManager; |
|
104 | - $this->urlGenerator = $urlGenerator; |
|
105 | - $this->cacheFactory = $cacheFactory; |
|
106 | - $this->util = $util; |
|
107 | - $this->appManager = $appManager; |
|
108 | - |
|
109 | - $this->name = parent::getName(); |
|
110 | - $this->title = parent::getTitle(); |
|
111 | - $this->entity = parent::getEntity(); |
|
112 | - $this->url = parent::getBaseUrl(); |
|
113 | - $this->slogan = parent::getSlogan(); |
|
114 | - $this->color = parent::getColorPrimary(); |
|
115 | - $this->iTunesAppId = parent::getiTunesAppId(); |
|
116 | - $this->iOSClientUrl = parent::getiOSClientUrl(); |
|
117 | - $this->AndroidClientUrl = parent::getAndroidClientUrl(); |
|
118 | - } |
|
119 | - |
|
120 | - public function getName() { |
|
121 | - return strip_tags($this->config->getAppValue('theming', 'name', $this->name)); |
|
122 | - } |
|
123 | - |
|
124 | - public function getHTMLName() { |
|
125 | - return $this->config->getAppValue('theming', 'name', $this->name); |
|
126 | - } |
|
127 | - |
|
128 | - public function getTitle() { |
|
129 | - return strip_tags($this->config->getAppValue('theming', 'name', $this->title)); |
|
130 | - } |
|
131 | - |
|
132 | - public function getEntity() { |
|
133 | - return strip_tags($this->config->getAppValue('theming', 'name', $this->entity)); |
|
134 | - } |
|
135 | - |
|
136 | - public function getBaseUrl() { |
|
137 | - return $this->config->getAppValue('theming', 'url', $this->url); |
|
138 | - } |
|
139 | - |
|
140 | - public function getSlogan() { |
|
141 | - return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan)); |
|
142 | - } |
|
143 | - |
|
144 | - public function getImprintUrl() { |
|
145 | - return (string)$this->config->getAppValue('theming', 'imprintUrl', ''); |
|
146 | - } |
|
147 | - |
|
148 | - public function getPrivacyUrl() { |
|
149 | - return (string)$this->config->getAppValue('theming', 'privacyUrl', ''); |
|
150 | - } |
|
151 | - |
|
152 | - public function getShortFooter() { |
|
153 | - $slogan = $this->getSlogan(); |
|
154 | - $baseUrl = $this->getBaseUrl(); |
|
155 | - if ($baseUrl !== '') { |
|
156 | - $footer = '<a href="' . $baseUrl . '" target="_blank"' . |
|
157 | - ' rel="noreferrer noopener" class="entity-name">' . $this->getEntity() . '</a>'; |
|
158 | - } else { |
|
159 | - $footer = '<span class="entity-name">' .$this->getEntity() . '</span>'; |
|
160 | - } |
|
161 | - $footer .= ($slogan !== '' ? ' – ' . $slogan : ''); |
|
162 | - |
|
163 | - $links = [ |
|
164 | - [ |
|
165 | - 'text' => $this->l->t('Legal notice'), |
|
166 | - 'url' => (string)$this->getImprintUrl() |
|
167 | - ], |
|
168 | - [ |
|
169 | - 'text' => $this->l->t('Privacy policy'), |
|
170 | - 'url' => (string)$this->getPrivacyUrl() |
|
171 | - ], |
|
172 | - ]; |
|
173 | - |
|
174 | - $legalLinks = ''; $divider = ''; |
|
175 | - foreach($links as $link) { |
|
176 | - if($link['url'] !== '' |
|
177 | - && filter_var($link['url'], FILTER_VALIDATE_URL) |
|
178 | - ) { |
|
179 | - $legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"' . |
|
180 | - ' rel="noreferrer noopener">' . $link['text'] . '</a>'; |
|
181 | - $divider = ' · '; |
|
182 | - } |
|
183 | - } |
|
184 | - if($legalLinks !== '' ) { |
|
185 | - $footer .= '<br/>' . $legalLinks; |
|
186 | - } |
|
187 | - |
|
188 | - return $footer; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Color that is used for the header as well as for mail headers |
|
193 | - * |
|
194 | - * @return string |
|
195 | - */ |
|
196 | - public function getColorPrimary() { |
|
197 | - return $this->config->getAppValue('theming', 'color', $this->color); |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * Themed logo url |
|
202 | - * |
|
203 | - * @param bool $useSvg Whether to point to the SVG image or a fallback |
|
204 | - * @return string |
|
205 | - */ |
|
206 | - public function getLogo($useSvg = true): string { |
|
207 | - $logo = $this->config->getAppValue('theming', 'logoMime', false); |
|
208 | - |
|
209 | - $logoExists = true; |
|
210 | - try { |
|
211 | - $this->imageManager->getImage('logo', $useSvg); |
|
212 | - } catch (\Exception $e) { |
|
213 | - $logoExists = false; |
|
214 | - } |
|
215 | - |
|
216 | - $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
217 | - |
|
218 | - if(!$logo || !$logoExists) { |
|
219 | - if($useSvg) { |
|
220 | - $logo = $this->urlGenerator->imagePath('core', 'logo.svg'); |
|
221 | - } else { |
|
222 | - $logo = $this->urlGenerator->imagePath('core', 'logo.png'); |
|
223 | - } |
|
224 | - return $logo . '?v=' . $cacheBusterCounter; |
|
225 | - } |
|
226 | - |
|
227 | - return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter ]); |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Themed background image url |
|
232 | - * |
|
233 | - * @return string |
|
234 | - */ |
|
235 | - public function getBackground(): string { |
|
236 | - return $this->imageManager->getImageUrl('background'); |
|
237 | - } |
|
238 | - |
|
239 | - /** |
|
240 | - * @return string |
|
241 | - */ |
|
242 | - public function getiTunesAppId() { |
|
243 | - return $this->config->getAppValue('theming', 'iTunesAppId', $this->iTunesAppId); |
|
244 | - } |
|
245 | - |
|
246 | - /** |
|
247 | - * @return string |
|
248 | - */ |
|
249 | - public function getiOSClientUrl() { |
|
250 | - return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl); |
|
251 | - } |
|
252 | - |
|
253 | - /** |
|
254 | - * @return string |
|
255 | - */ |
|
256 | - public function getAndroidClientUrl() { |
|
257 | - return $this->config->getAppValue('theming', 'AndroidClientUrl', $this->AndroidClientUrl); |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * @return array scss variables to overwrite |
|
263 | - */ |
|
264 | - public function getScssVariables() { |
|
265 | - $cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl()); |
|
266 | - if ($value = $cache->get('getScssVariables')) { |
|
267 | - return $value; |
|
268 | - } |
|
269 | - |
|
270 | - $variables = [ |
|
271 | - 'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'", |
|
272 | - 'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime') . "'", |
|
273 | - 'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime') . "'", |
|
274 | - 'theming-logoheader-mime' => "'" . $this->config->getAppValue('theming', 'logoheaderMime') . "'", |
|
275 | - 'theming-favicon-mime' => "'" . $this->config->getAppValue('theming', 'faviconMime') . "'" |
|
276 | - ]; |
|
277 | - |
|
278 | - $variables['image-logo'] = "url('".$this->imageManager->getImageUrl('logo')."')"; |
|
279 | - $variables['image-logoheader'] = "'".$this->imageManager->getImageUrl('logoheader')."'"; |
|
280 | - $variables['image-favicon'] = "'".$this->imageManager->getImageUrl('favicon')."'"; |
|
281 | - $variables['image-login-background'] = "url('".$this->imageManager->getImageUrl('background')."')"; |
|
282 | - $variables['image-login-plain'] = 'false'; |
|
283 | - |
|
284 | - if ($this->config->getAppValue('theming', 'color', null) !== null) { |
|
285 | - $variables['color-primary'] = $this->getColorPrimary(); |
|
286 | - $variables['color-primary-text'] = $this->getTextColorPrimary(); |
|
287 | - $variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary()); |
|
288 | - } |
|
289 | - |
|
290 | - if ($this->config->getAppValue('theming', 'backgroundMime', null) === 'backgroundColor') { |
|
291 | - $variables['image-login-plain'] = 'true'; |
|
292 | - } |
|
293 | - |
|
294 | - $variables['has-legal-links'] = 'false'; |
|
295 | - if($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') { |
|
296 | - $variables['has-legal-links'] = 'true'; |
|
297 | - } |
|
298 | - |
|
299 | - $cache->set('getScssVariables', $variables); |
|
300 | - return $variables; |
|
301 | - } |
|
302 | - |
|
303 | - /** |
|
304 | - * Check if the image should be replaced by the theming app |
|
305 | - * and return the new image location then |
|
306 | - * |
|
307 | - * @param string $app name of the app |
|
308 | - * @param string $image filename of the image |
|
309 | - * @return bool|string false if image should not replaced, otherwise the location of the image |
|
310 | - */ |
|
311 | - public function replaceImagePath($app, $image) { |
|
312 | - if($app==='') { |
|
313 | - $app = 'core'; |
|
314 | - } |
|
315 | - $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
316 | - |
|
317 | - try { |
|
318 | - $customFavicon = $this->imageManager->getImage('favicon'); |
|
319 | - } catch (NotFoundException $e) { |
|
320 | - $customFavicon = null; |
|
321 | - } |
|
322 | - |
|
323 | - if ($image === 'favicon.ico' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { |
|
324 | - return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue; |
|
325 | - } |
|
326 | - if ($image === 'favicon-touch.png' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { |
|
327 | - return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue; |
|
328 | - } |
|
329 | - if ($image === 'manifest.json') { |
|
330 | - try { |
|
331 | - $appPath = $this->appManager->getAppPath($app); |
|
332 | - if (file_exists($appPath . '/img/manifest.json')) { |
|
333 | - return false; |
|
334 | - } |
|
335 | - } catch (AppPathNotFoundException $e) {} |
|
336 | - return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue; |
|
337 | - } |
|
338 | - return false; |
|
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * Increases the cache buster key |
|
343 | - */ |
|
344 | - private function increaseCacheBuster() { |
|
345 | - $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
346 | - $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); |
|
347 | - $this->cacheFactory->createDistributed('theming-')->clear(); |
|
348 | - $this->cacheFactory->createDistributed('imagePath')->clear(); |
|
349 | - |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * Update setting in the database |
|
354 | - * |
|
355 | - * @param string $setting |
|
356 | - * @param string $value |
|
357 | - */ |
|
358 | - public function set($setting, $value) { |
|
359 | - $this->config->setAppValue('theming', $setting, $value); |
|
360 | - $this->increaseCacheBuster(); |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * Revert settings to the default value |
|
365 | - * |
|
366 | - * @param string $setting setting which should be reverted |
|
367 | - * @return string default value |
|
368 | - */ |
|
369 | - public function undo($setting) { |
|
370 | - $this->config->deleteAppValue('theming', $setting); |
|
371 | - $this->increaseCacheBuster(); |
|
372 | - |
|
373 | - switch ($setting) { |
|
374 | - case 'name': |
|
375 | - $returnValue = $this->getEntity(); |
|
376 | - break; |
|
377 | - case 'url': |
|
378 | - $returnValue = $this->getBaseUrl(); |
|
379 | - break; |
|
380 | - case 'slogan': |
|
381 | - $returnValue = $this->getSlogan(); |
|
382 | - break; |
|
383 | - case 'color': |
|
384 | - $returnValue = $this->getColorPrimary(); |
|
385 | - break; |
|
386 | - default: |
|
387 | - $returnValue = ''; |
|
388 | - break; |
|
389 | - } |
|
390 | - |
|
391 | - return $returnValue; |
|
392 | - } |
|
393 | - |
|
394 | - /** |
|
395 | - * Color of text in the header and primary buttons |
|
396 | - * |
|
397 | - * @return string |
|
398 | - */ |
|
399 | - public function getTextColorPrimary() { |
|
400 | - return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#ffffff'; |
|
401 | - } |
|
47 | + /** @var IConfig */ |
|
48 | + private $config; |
|
49 | + /** @var IL10N */ |
|
50 | + private $l; |
|
51 | + /** @var ImageManager */ |
|
52 | + private $imageManager; |
|
53 | + /** @var IURLGenerator */ |
|
54 | + private $urlGenerator; |
|
55 | + /** @var ICacheFactory */ |
|
56 | + private $cacheFactory; |
|
57 | + /** @var Util */ |
|
58 | + private $util; |
|
59 | + /** @var IAppManager */ |
|
60 | + private $appManager; |
|
61 | + /** @var string */ |
|
62 | + private $name; |
|
63 | + /** @var string */ |
|
64 | + private $title; |
|
65 | + /** @var string */ |
|
66 | + private $entity; |
|
67 | + /** @var string */ |
|
68 | + private $url; |
|
69 | + /** @var string */ |
|
70 | + private $slogan; |
|
71 | + /** @var string */ |
|
72 | + private $color; |
|
73 | + |
|
74 | + /** @var string */ |
|
75 | + private $iTunesAppId; |
|
76 | + /** @var string */ |
|
77 | + private $iOSClientUrl; |
|
78 | + /** @var string */ |
|
79 | + private $AndroidClientUrl; |
|
80 | + |
|
81 | + /** |
|
82 | + * ThemingDefaults constructor. |
|
83 | + * |
|
84 | + * @param IConfig $config |
|
85 | + * @param IL10N $l |
|
86 | + * @param ImageManager $imageManager |
|
87 | + * @param IURLGenerator $urlGenerator |
|
88 | + * @param ICacheFactory $cacheFactory |
|
89 | + * @param Util $util |
|
90 | + * @param IAppManager $appManager |
|
91 | + */ |
|
92 | + public function __construct(IConfig $config, |
|
93 | + IL10N $l, |
|
94 | + IURLGenerator $urlGenerator, |
|
95 | + ICacheFactory $cacheFactory, |
|
96 | + Util $util, |
|
97 | + ImageManager $imageManager, |
|
98 | + IAppManager $appManager |
|
99 | + ) { |
|
100 | + parent::__construct(); |
|
101 | + $this->config = $config; |
|
102 | + $this->l = $l; |
|
103 | + $this->imageManager = $imageManager; |
|
104 | + $this->urlGenerator = $urlGenerator; |
|
105 | + $this->cacheFactory = $cacheFactory; |
|
106 | + $this->util = $util; |
|
107 | + $this->appManager = $appManager; |
|
108 | + |
|
109 | + $this->name = parent::getName(); |
|
110 | + $this->title = parent::getTitle(); |
|
111 | + $this->entity = parent::getEntity(); |
|
112 | + $this->url = parent::getBaseUrl(); |
|
113 | + $this->slogan = parent::getSlogan(); |
|
114 | + $this->color = parent::getColorPrimary(); |
|
115 | + $this->iTunesAppId = parent::getiTunesAppId(); |
|
116 | + $this->iOSClientUrl = parent::getiOSClientUrl(); |
|
117 | + $this->AndroidClientUrl = parent::getAndroidClientUrl(); |
|
118 | + } |
|
119 | + |
|
120 | + public function getName() { |
|
121 | + return strip_tags($this->config->getAppValue('theming', 'name', $this->name)); |
|
122 | + } |
|
123 | + |
|
124 | + public function getHTMLName() { |
|
125 | + return $this->config->getAppValue('theming', 'name', $this->name); |
|
126 | + } |
|
127 | + |
|
128 | + public function getTitle() { |
|
129 | + return strip_tags($this->config->getAppValue('theming', 'name', $this->title)); |
|
130 | + } |
|
131 | + |
|
132 | + public function getEntity() { |
|
133 | + return strip_tags($this->config->getAppValue('theming', 'name', $this->entity)); |
|
134 | + } |
|
135 | + |
|
136 | + public function getBaseUrl() { |
|
137 | + return $this->config->getAppValue('theming', 'url', $this->url); |
|
138 | + } |
|
139 | + |
|
140 | + public function getSlogan() { |
|
141 | + return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan)); |
|
142 | + } |
|
143 | + |
|
144 | + public function getImprintUrl() { |
|
145 | + return (string)$this->config->getAppValue('theming', 'imprintUrl', ''); |
|
146 | + } |
|
147 | + |
|
148 | + public function getPrivacyUrl() { |
|
149 | + return (string)$this->config->getAppValue('theming', 'privacyUrl', ''); |
|
150 | + } |
|
151 | + |
|
152 | + public function getShortFooter() { |
|
153 | + $slogan = $this->getSlogan(); |
|
154 | + $baseUrl = $this->getBaseUrl(); |
|
155 | + if ($baseUrl !== '') { |
|
156 | + $footer = '<a href="' . $baseUrl . '" target="_blank"' . |
|
157 | + ' rel="noreferrer noopener" class="entity-name">' . $this->getEntity() . '</a>'; |
|
158 | + } else { |
|
159 | + $footer = '<span class="entity-name">' .$this->getEntity() . '</span>'; |
|
160 | + } |
|
161 | + $footer .= ($slogan !== '' ? ' – ' . $slogan : ''); |
|
162 | + |
|
163 | + $links = [ |
|
164 | + [ |
|
165 | + 'text' => $this->l->t('Legal notice'), |
|
166 | + 'url' => (string)$this->getImprintUrl() |
|
167 | + ], |
|
168 | + [ |
|
169 | + 'text' => $this->l->t('Privacy policy'), |
|
170 | + 'url' => (string)$this->getPrivacyUrl() |
|
171 | + ], |
|
172 | + ]; |
|
173 | + |
|
174 | + $legalLinks = ''; $divider = ''; |
|
175 | + foreach($links as $link) { |
|
176 | + if($link['url'] !== '' |
|
177 | + && filter_var($link['url'], FILTER_VALIDATE_URL) |
|
178 | + ) { |
|
179 | + $legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"' . |
|
180 | + ' rel="noreferrer noopener">' . $link['text'] . '</a>'; |
|
181 | + $divider = ' · '; |
|
182 | + } |
|
183 | + } |
|
184 | + if($legalLinks !== '' ) { |
|
185 | + $footer .= '<br/>' . $legalLinks; |
|
186 | + } |
|
187 | + |
|
188 | + return $footer; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Color that is used for the header as well as for mail headers |
|
193 | + * |
|
194 | + * @return string |
|
195 | + */ |
|
196 | + public function getColorPrimary() { |
|
197 | + return $this->config->getAppValue('theming', 'color', $this->color); |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * Themed logo url |
|
202 | + * |
|
203 | + * @param bool $useSvg Whether to point to the SVG image or a fallback |
|
204 | + * @return string |
|
205 | + */ |
|
206 | + public function getLogo($useSvg = true): string { |
|
207 | + $logo = $this->config->getAppValue('theming', 'logoMime', false); |
|
208 | + |
|
209 | + $logoExists = true; |
|
210 | + try { |
|
211 | + $this->imageManager->getImage('logo', $useSvg); |
|
212 | + } catch (\Exception $e) { |
|
213 | + $logoExists = false; |
|
214 | + } |
|
215 | + |
|
216 | + $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
217 | + |
|
218 | + if(!$logo || !$logoExists) { |
|
219 | + if($useSvg) { |
|
220 | + $logo = $this->urlGenerator->imagePath('core', 'logo.svg'); |
|
221 | + } else { |
|
222 | + $logo = $this->urlGenerator->imagePath('core', 'logo.png'); |
|
223 | + } |
|
224 | + return $logo . '?v=' . $cacheBusterCounter; |
|
225 | + } |
|
226 | + |
|
227 | + return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter ]); |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Themed background image url |
|
232 | + * |
|
233 | + * @return string |
|
234 | + */ |
|
235 | + public function getBackground(): string { |
|
236 | + return $this->imageManager->getImageUrl('background'); |
|
237 | + } |
|
238 | + |
|
239 | + /** |
|
240 | + * @return string |
|
241 | + */ |
|
242 | + public function getiTunesAppId() { |
|
243 | + return $this->config->getAppValue('theming', 'iTunesAppId', $this->iTunesAppId); |
|
244 | + } |
|
245 | + |
|
246 | + /** |
|
247 | + * @return string |
|
248 | + */ |
|
249 | + public function getiOSClientUrl() { |
|
250 | + return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl); |
|
251 | + } |
|
252 | + |
|
253 | + /** |
|
254 | + * @return string |
|
255 | + */ |
|
256 | + public function getAndroidClientUrl() { |
|
257 | + return $this->config->getAppValue('theming', 'AndroidClientUrl', $this->AndroidClientUrl); |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * @return array scss variables to overwrite |
|
263 | + */ |
|
264 | + public function getScssVariables() { |
|
265 | + $cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl()); |
|
266 | + if ($value = $cache->get('getScssVariables')) { |
|
267 | + return $value; |
|
268 | + } |
|
269 | + |
|
270 | + $variables = [ |
|
271 | + 'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'", |
|
272 | + 'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime') . "'", |
|
273 | + 'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime') . "'", |
|
274 | + 'theming-logoheader-mime' => "'" . $this->config->getAppValue('theming', 'logoheaderMime') . "'", |
|
275 | + 'theming-favicon-mime' => "'" . $this->config->getAppValue('theming', 'faviconMime') . "'" |
|
276 | + ]; |
|
277 | + |
|
278 | + $variables['image-logo'] = "url('".$this->imageManager->getImageUrl('logo')."')"; |
|
279 | + $variables['image-logoheader'] = "'".$this->imageManager->getImageUrl('logoheader')."'"; |
|
280 | + $variables['image-favicon'] = "'".$this->imageManager->getImageUrl('favicon')."'"; |
|
281 | + $variables['image-login-background'] = "url('".$this->imageManager->getImageUrl('background')."')"; |
|
282 | + $variables['image-login-plain'] = 'false'; |
|
283 | + |
|
284 | + if ($this->config->getAppValue('theming', 'color', null) !== null) { |
|
285 | + $variables['color-primary'] = $this->getColorPrimary(); |
|
286 | + $variables['color-primary-text'] = $this->getTextColorPrimary(); |
|
287 | + $variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary()); |
|
288 | + } |
|
289 | + |
|
290 | + if ($this->config->getAppValue('theming', 'backgroundMime', null) === 'backgroundColor') { |
|
291 | + $variables['image-login-plain'] = 'true'; |
|
292 | + } |
|
293 | + |
|
294 | + $variables['has-legal-links'] = 'false'; |
|
295 | + if($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') { |
|
296 | + $variables['has-legal-links'] = 'true'; |
|
297 | + } |
|
298 | + |
|
299 | + $cache->set('getScssVariables', $variables); |
|
300 | + return $variables; |
|
301 | + } |
|
302 | + |
|
303 | + /** |
|
304 | + * Check if the image should be replaced by the theming app |
|
305 | + * and return the new image location then |
|
306 | + * |
|
307 | + * @param string $app name of the app |
|
308 | + * @param string $image filename of the image |
|
309 | + * @return bool|string false if image should not replaced, otherwise the location of the image |
|
310 | + */ |
|
311 | + public function replaceImagePath($app, $image) { |
|
312 | + if($app==='') { |
|
313 | + $app = 'core'; |
|
314 | + } |
|
315 | + $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
316 | + |
|
317 | + try { |
|
318 | + $customFavicon = $this->imageManager->getImage('favicon'); |
|
319 | + } catch (NotFoundException $e) { |
|
320 | + $customFavicon = null; |
|
321 | + } |
|
322 | + |
|
323 | + if ($image === 'favicon.ico' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { |
|
324 | + return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue; |
|
325 | + } |
|
326 | + if ($image === 'favicon-touch.png' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { |
|
327 | + return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue; |
|
328 | + } |
|
329 | + if ($image === 'manifest.json') { |
|
330 | + try { |
|
331 | + $appPath = $this->appManager->getAppPath($app); |
|
332 | + if (file_exists($appPath . '/img/manifest.json')) { |
|
333 | + return false; |
|
334 | + } |
|
335 | + } catch (AppPathNotFoundException $e) {} |
|
336 | + return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue; |
|
337 | + } |
|
338 | + return false; |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * Increases the cache buster key |
|
343 | + */ |
|
344 | + private function increaseCacheBuster() { |
|
345 | + $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); |
|
346 | + $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); |
|
347 | + $this->cacheFactory->createDistributed('theming-')->clear(); |
|
348 | + $this->cacheFactory->createDistributed('imagePath')->clear(); |
|
349 | + |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * Update setting in the database |
|
354 | + * |
|
355 | + * @param string $setting |
|
356 | + * @param string $value |
|
357 | + */ |
|
358 | + public function set($setting, $value) { |
|
359 | + $this->config->setAppValue('theming', $setting, $value); |
|
360 | + $this->increaseCacheBuster(); |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * Revert settings to the default value |
|
365 | + * |
|
366 | + * @param string $setting setting which should be reverted |
|
367 | + * @return string default value |
|
368 | + */ |
|
369 | + public function undo($setting) { |
|
370 | + $this->config->deleteAppValue('theming', $setting); |
|
371 | + $this->increaseCacheBuster(); |
|
372 | + |
|
373 | + switch ($setting) { |
|
374 | + case 'name': |
|
375 | + $returnValue = $this->getEntity(); |
|
376 | + break; |
|
377 | + case 'url': |
|
378 | + $returnValue = $this->getBaseUrl(); |
|
379 | + break; |
|
380 | + case 'slogan': |
|
381 | + $returnValue = $this->getSlogan(); |
|
382 | + break; |
|
383 | + case 'color': |
|
384 | + $returnValue = $this->getColorPrimary(); |
|
385 | + break; |
|
386 | + default: |
|
387 | + $returnValue = ''; |
|
388 | + break; |
|
389 | + } |
|
390 | + |
|
391 | + return $returnValue; |
|
392 | + } |
|
393 | + |
|
394 | + /** |
|
395 | + * Color of text in the header and primary buttons |
|
396 | + * |
|
397 | + * @return string |
|
398 | + */ |
|
399 | + public function getTextColorPrimary() { |
|
400 | + return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#ffffff'; |
|
401 | + } |
|
402 | 402 | } |
@@ -142,47 +142,47 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | public function getImprintUrl() { |
145 | - return (string)$this->config->getAppValue('theming', 'imprintUrl', ''); |
|
145 | + return (string) $this->config->getAppValue('theming', 'imprintUrl', ''); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | public function getPrivacyUrl() { |
149 | - return (string)$this->config->getAppValue('theming', 'privacyUrl', ''); |
|
149 | + return (string) $this->config->getAppValue('theming', 'privacyUrl', ''); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | public function getShortFooter() { |
153 | 153 | $slogan = $this->getSlogan(); |
154 | 154 | $baseUrl = $this->getBaseUrl(); |
155 | 155 | if ($baseUrl !== '') { |
156 | - $footer = '<a href="' . $baseUrl . '" target="_blank"' . |
|
157 | - ' rel="noreferrer noopener" class="entity-name">' . $this->getEntity() . '</a>'; |
|
156 | + $footer = '<a href="'.$baseUrl.'" target="_blank"'. |
|
157 | + ' rel="noreferrer noopener" class="entity-name">'.$this->getEntity().'</a>'; |
|
158 | 158 | } else { |
159 | - $footer = '<span class="entity-name">' .$this->getEntity() . '</span>'; |
|
159 | + $footer = '<span class="entity-name">'.$this->getEntity().'</span>'; |
|
160 | 160 | } |
161 | - $footer .= ($slogan !== '' ? ' – ' . $slogan : ''); |
|
161 | + $footer .= ($slogan !== '' ? ' – '.$slogan : ''); |
|
162 | 162 | |
163 | 163 | $links = [ |
164 | 164 | [ |
165 | 165 | 'text' => $this->l->t('Legal notice'), |
166 | - 'url' => (string)$this->getImprintUrl() |
|
166 | + 'url' => (string) $this->getImprintUrl() |
|
167 | 167 | ], |
168 | 168 | [ |
169 | 169 | 'text' => $this->l->t('Privacy policy'), |
170 | - 'url' => (string)$this->getPrivacyUrl() |
|
170 | + 'url' => (string) $this->getPrivacyUrl() |
|
171 | 171 | ], |
172 | 172 | ]; |
173 | 173 | |
174 | 174 | $legalLinks = ''; $divider = ''; |
175 | - foreach($links as $link) { |
|
176 | - if($link['url'] !== '' |
|
175 | + foreach ($links as $link) { |
|
176 | + if ($link['url'] !== '' |
|
177 | 177 | && filter_var($link['url'], FILTER_VALIDATE_URL) |
178 | 178 | ) { |
179 | - $legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"' . |
|
180 | - ' rel="noreferrer noopener">' . $link['text'] . '</a>'; |
|
179 | + $legalLinks .= $divider.'<a href="'.$link['url'].'" class="legal" target="_blank"'. |
|
180 | + ' rel="noreferrer noopener">'.$link['text'].'</a>'; |
|
181 | 181 | $divider = ' · '; |
182 | 182 | } |
183 | 183 | } |
184 | - if($legalLinks !== '' ) { |
|
185 | - $footer .= '<br/>' . $legalLinks; |
|
184 | + if ($legalLinks !== '') { |
|
185 | + $footer .= '<br/>'.$legalLinks; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | return $footer; |
@@ -215,16 +215,16 @@ discard block |
||
215 | 215 | |
216 | 216 | $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); |
217 | 217 | |
218 | - if(!$logo || !$logoExists) { |
|
219 | - if($useSvg) { |
|
218 | + if (!$logo || !$logoExists) { |
|
219 | + if ($useSvg) { |
|
220 | 220 | $logo = $this->urlGenerator->imagePath('core', 'logo.svg'); |
221 | 221 | } else { |
222 | 222 | $logo = $this->urlGenerator->imagePath('core', 'logo.png'); |
223 | 223 | } |
224 | - return $logo . '?v=' . $cacheBusterCounter; |
|
224 | + return $logo.'?v='.$cacheBusterCounter; |
|
225 | 225 | } |
226 | 226 | |
227 | - return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter ]); |
|
227 | + return $this->urlGenerator->linkToRoute('theming.Theming.getImage', ['key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter]); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -262,17 +262,17 @@ discard block |
||
262 | 262 | * @return array scss variables to overwrite |
263 | 263 | */ |
264 | 264 | public function getScssVariables() { |
265 | - $cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl()); |
|
265 | + $cache = $this->cacheFactory->createDistributed('theming-'.$this->urlGenerator->getBaseUrl()); |
|
266 | 266 | if ($value = $cache->get('getScssVariables')) { |
267 | 267 | return $value; |
268 | 268 | } |
269 | 269 | |
270 | 270 | $variables = [ |
271 | - 'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'", |
|
272 | - 'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime') . "'", |
|
273 | - 'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime') . "'", |
|
274 | - 'theming-logoheader-mime' => "'" . $this->config->getAppValue('theming', 'logoheaderMime') . "'", |
|
275 | - 'theming-favicon-mime' => "'" . $this->config->getAppValue('theming', 'faviconMime') . "'" |
|
271 | + 'theming-cachebuster' => "'".$this->config->getAppValue('theming', 'cachebuster', '0')."'", |
|
272 | + 'theming-logo-mime' => "'".$this->config->getAppValue('theming', 'logoMime')."'", |
|
273 | + 'theming-background-mime' => "'".$this->config->getAppValue('theming', 'backgroundMime')."'", |
|
274 | + 'theming-logoheader-mime' => "'".$this->config->getAppValue('theming', 'logoheaderMime')."'", |
|
275 | + 'theming-favicon-mime' => "'".$this->config->getAppValue('theming', 'faviconMime')."'" |
|
276 | 276 | ]; |
277 | 277 | |
278 | 278 | $variables['image-logo'] = "url('".$this->imageManager->getImageUrl('logo')."')"; |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | } |
293 | 293 | |
294 | 294 | $variables['has-legal-links'] = 'false'; |
295 | - if($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') { |
|
295 | + if ($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') { |
|
296 | 296 | $variables['has-legal-links'] = 'true'; |
297 | 297 | } |
298 | 298 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @return bool|string false if image should not replaced, otherwise the location of the image |
310 | 310 | */ |
311 | 311 | public function replaceImagePath($app, $image) { |
312 | - if($app==='') { |
|
312 | + if ($app === '') { |
|
313 | 313 | $app = 'core'; |
314 | 314 | } |
315 | 315 | $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
@@ -321,19 +321,19 @@ discard block |
||
321 | 321 | } |
322 | 322 | |
323 | 323 | if ($image === 'favicon.ico' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { |
324 | - return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue; |
|
324 | + return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]).'?v='.$cacheBusterValue; |
|
325 | 325 | } |
326 | 326 | if ($image === 'favicon-touch.png' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { |
327 | - return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue; |
|
327 | + return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]).'?v='.$cacheBusterValue; |
|
328 | 328 | } |
329 | 329 | if ($image === 'manifest.json') { |
330 | 330 | try { |
331 | 331 | $appPath = $this->appManager->getAppPath($app); |
332 | - if (file_exists($appPath . '/img/manifest.json')) { |
|
332 | + if (file_exists($appPath.'/img/manifest.json')) { |
|
333 | 333 | return false; |
334 | 334 | } |
335 | 335 | } catch (AppPathNotFoundException $e) {} |
336 | - return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue; |
|
336 | + return $this->urlGenerator->linkToRoute('theming.Theming.getManifest').'?v='.$cacheBusterValue; |
|
337 | 337 | } |
338 | 338 | return false; |
339 | 339 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | */ |
344 | 344 | private function increaseCacheBuster() { |
345 | 345 | $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); |
346 | - $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); |
|
346 | + $this->config->setAppValue('theming', 'cachebuster', (int) $cacheBusterKey + 1); |
|
347 | 347 | $this->cacheFactory->createDistributed('theming-')->clear(); |
348 | 348 | $this->cacheFactory->createDistributed('imagePath')->clear(); |
349 | 349 |