@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function getThemedIcon(string $app, string $image): Response { |
92 | 92 | try { |
93 | - $iconFile = $this->imageManager->getCachedImage('icon-' . $app . '-' . str_replace('/', '_',$image)); |
|
93 | + $iconFile = $this->imageManager->getCachedImage('icon-'.$app.'-'.str_replace('/', '_', $image)); |
|
94 | 94 | } catch (NotFoundException $exception) { |
95 | 95 | $icon = $this->iconBuilder->colorSvg($app, $image); |
96 | 96 | if ($icon === false || $icon === '') { |
97 | 97 | return new NotFoundResponse(); |
98 | 98 | } |
99 | - $iconFile = $this->imageManager->setCachedImage('icon-' . $app . '-' . str_replace('/', '_',$image), $icon); |
|
99 | + $iconFile = $this->imageManager->setCachedImage('icon-'.$app.'-'.str_replace('/', '_', $image), $icon); |
|
100 | 100 | } |
101 | 101 | if ($iconFile !== false) { |
102 | 102 | $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']); |
@@ -127,17 +127,17 @@ discard block |
||
127 | 127 | } |
128 | 128 | if ($iconFile === null && $this->imageManager->shouldReplaceIcons()) { |
129 | 129 | try { |
130 | - $iconFile = $this->imageManager->getCachedImage('favIcon-' . $app); |
|
130 | + $iconFile = $this->imageManager->getCachedImage('favIcon-'.$app); |
|
131 | 131 | } catch (NotFoundException $exception) { |
132 | 132 | $icon = $this->iconBuilder->getFavicon($app); |
133 | - $iconFile = $this->imageManager->setCachedImage('favIcon-' . $app, $icon); |
|
133 | + $iconFile = $this->imageManager->setCachedImage('favIcon-'.$app, $icon); |
|
134 | 134 | } |
135 | 135 | if ($iconFile !== false) { |
136 | 136 | $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']); |
137 | 137 | } |
138 | 138 | } |
139 | - if($response === null) { |
|
140 | - $fallbackLogo = \OC::$SERVERROOT . '/core/img/favicon.png'; |
|
139 | + if ($response === null) { |
|
140 | + $fallbackLogo = \OC::$SERVERROOT.'/core/img/favicon.png'; |
|
141 | 141 | $response = new DataDisplayResponse($this->fileAccessHelper->file_get_contents($fallbackLogo), Http::STATUS_OK, ['Content-Type' => 'image/x-icon']); |
142 | 142 | } |
143 | 143 | $response->cacheFor(86400); |
@@ -163,17 +163,17 @@ discard block |
||
163 | 163 | } |
164 | 164 | if ($this->imageManager->shouldReplaceIcons()) { |
165 | 165 | try { |
166 | - $iconFile = $this->imageManager->getCachedImage('touchIcon-' . $app); |
|
166 | + $iconFile = $this->imageManager->getCachedImage('touchIcon-'.$app); |
|
167 | 167 | } catch (NotFoundException $exception) { |
168 | 168 | $icon = $this->iconBuilder->getTouchIcon($app); |
169 | - $iconFile = $this->imageManager->setCachedImage('touchIcon-' . $app, $icon); |
|
169 | + $iconFile = $this->imageManager->setCachedImage('touchIcon-'.$app, $icon); |
|
170 | 170 | } |
171 | 171 | if ($iconFile !== false) { |
172 | 172 | $response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/png']); |
173 | 173 | } |
174 | 174 | } |
175 | - if($response === null) { |
|
176 | - $fallbackLogo = \OC::$SERVERROOT . '/core/img/favicon-touch.png'; |
|
175 | + if ($response === null) { |
|
176 | + $fallbackLogo = \OC::$SERVERROOT.'/core/img/favicon-touch.png'; |
|
177 | 177 | $response = new DataDisplayResponse($this->fileAccessHelper->file_get_contents($fallbackLogo), Http::STATUS_OK, ['Content-Type' => 'image/png']); |
178 | 178 | } |
179 | 179 | $response->cacheFor(86400); |
@@ -371,12 +371,12 @@ discard block |
||
371 | 371 | |
372 | 372 | $response = new FileDisplayResponse($file); |
373 | 373 | $response->cacheFor(3600); |
374 | - $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', '')); |
|
375 | - $response->addHeader('Content-Disposition', 'attachment; filename="' . $key . '"'); |
|
374 | + $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key.'Mime', '')); |
|
375 | + $response->addHeader('Content-Disposition', 'attachment; filename="'.$key.'"'); |
|
376 | 376 | if (!$useSvg) { |
377 | 377 | $response->addHeader('Content-Type', 'image/png'); |
378 | 378 | } else { |
379 | - $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', '')); |
|
379 | + $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key.'Mime', '')); |
|
380 | 380 | } |
381 | 381 | return $response; |
382 | 382 | } |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | * since we need to add the cacheBuster value to the url |
399 | 399 | */ |
400 | 400 | $cssCached = $this->scssCacher->process($appPath, 'css/theming.scss', 'theming'); |
401 | - if(!$cssCached) { |
|
401 | + if (!$cssCached) { |
|
402 | 402 | return new NotFoundResponse(); |
403 | 403 | } |
404 | 404 | |
@@ -422,14 +422,14 @@ discard block |
||
422 | 422 | $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
423 | 423 | $responseJS = '(function() { |
424 | 424 | OCA.Theming = { |
425 | - name: ' . json_encode($this->themingDefaults->getName()) . ', |
|
426 | - url: ' . json_encode($this->themingDefaults->getBaseUrl()) . ', |
|
427 | - slogan: ' . json_encode($this->themingDefaults->getSlogan()) . ', |
|
428 | - color: ' . json_encode($this->themingDefaults->getColorPrimary()) . ', |
|
429 | - imprintUrl: ' . json_encode($this->themingDefaults->getImprintUrl()) . ', |
|
430 | - privacyUrl: ' . json_encode($this->themingDefaults->getPrivacyUrl()) . ', |
|
431 | - inverted: ' . json_encode($this->util->invertTextColor($this->themingDefaults->getColorPrimary())) . ', |
|
432 | - cacheBuster: ' . json_encode($cacheBusterValue) . ' |
|
425 | + name: ' . json_encode($this->themingDefaults->getName()).', |
|
426 | + url: ' . json_encode($this->themingDefaults->getBaseUrl()).', |
|
427 | + slogan: ' . json_encode($this->themingDefaults->getSlogan()).', |
|
428 | + color: ' . json_encode($this->themingDefaults->getColorPrimary()).', |
|
429 | + imprintUrl: ' . json_encode($this->themingDefaults->getImprintUrl()).', |
|
430 | + privacyUrl: ' . json_encode($this->themingDefaults->getPrivacyUrl()).', |
|
431 | + inverted: ' . json_encode($this->util->invertTextColor($this->themingDefaults->getColorPrimary())).', |
|
432 | + cacheBuster: ' . json_encode($cacheBusterValue).' |
|
433 | 433 | }; |
434 | 434 | })();'; |
435 | 435 | $response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript'); |
@@ -452,13 +452,13 @@ discard block |
||
452 | 452 | [ |
453 | 453 | [ |
454 | 454 | 'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', |
455 | - ['app' => $app]) . '?v=' . $cacheBusterValue, |
|
455 | + ['app' => $app]).'?v='.$cacheBusterValue, |
|
456 | 456 | 'type'=> 'image/png', |
457 | 457 | 'sizes'=> '128x128' |
458 | 458 | ], |
459 | 459 | [ |
460 | 460 | 'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', |
461 | - ['app' => $app]) . '?v=' . $cacheBusterValue, |
|
461 | + ['app' => $app]).'?v='.$cacheBusterValue, |
|
462 | 462 | 'type' => 'image/svg+xml', |
463 | 463 | 'sizes' => '16x16' |
464 | 464 | ] |
@@ -142,44 +142,44 @@ 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 | - $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
155 | - ' rel="noreferrer noopener">' .$this->getEntity() . '</a>'. |
|
156 | - ($slogan !== '' ? ' – ' . $slogan : ''); |
|
154 | + $footer = '<a href="'.$this->getBaseUrl().'" target="_blank"'. |
|
155 | + ' rel="noreferrer noopener">'.$this->getEntity().'</a>'. |
|
156 | + ($slogan !== '' ? ' – '.$slogan : ''); |
|
157 | 157 | |
158 | 158 | $links = [ |
159 | 159 | [ |
160 | 160 | 'text' => $this->l->t('Legal notice'), |
161 | - 'url' => (string)$this->getImprintUrl() |
|
161 | + 'url' => (string) $this->getImprintUrl() |
|
162 | 162 | ], |
163 | 163 | [ |
164 | 164 | 'text' => $this->l->t('Privacy policy'), |
165 | - 'url' => (string)$this->getPrivacyUrl() |
|
165 | + 'url' => (string) $this->getPrivacyUrl() |
|
166 | 166 | ], |
167 | 167 | ]; |
168 | 168 | |
169 | 169 | $legalLinks = ''; $divider = ''; |
170 | - foreach($links as $link) { |
|
171 | - if($link['url'] !== '' |
|
170 | + foreach ($links as $link) { |
|
171 | + if ($link['url'] !== '' |
|
172 | 172 | && filter_var($link['url'], FILTER_VALIDATE_URL, [ |
173 | 173 | 'flags' => FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED |
174 | 174 | ]) |
175 | 175 | ) { |
176 | - $legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"' . |
|
177 | - ' rel="noreferrer noopener">' . $link['text'] . '</a>'; |
|
176 | + $legalLinks .= $divider.'<a href="'.$link['url'].'" class="legal" target="_blank"'. |
|
177 | + ' rel="noreferrer noopener">'.$link['text'].'</a>'; |
|
178 | 178 | $divider = ' · '; |
179 | 179 | } |
180 | 180 | } |
181 | - if($legalLinks !== '' ) { |
|
182 | - $footer .= '<br/>' . $legalLinks; |
|
181 | + if ($legalLinks !== '') { |
|
182 | + $footer .= '<br/>'.$legalLinks; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | return $footer; |
@@ -212,16 +212,16 @@ discard block |
||
212 | 212 | |
213 | 213 | $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); |
214 | 214 | |
215 | - if(!$logo || !$logoExists) { |
|
216 | - if($useSvg) { |
|
215 | + if (!$logo || !$logoExists) { |
|
216 | + if ($useSvg) { |
|
217 | 217 | $logo = $this->urlGenerator->imagePath('core', 'logo.svg'); |
218 | 218 | } else { |
219 | 219 | $logo = $this->urlGenerator->imagePath('core', 'logo.png'); |
220 | 220 | } |
221 | - return $logo . '?v=' . $cacheBusterCounter; |
|
221 | + return $logo.'?v='.$cacheBusterCounter; |
|
222 | 222 | } |
223 | 223 | |
224 | - return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter ]); |
|
224 | + return $this->urlGenerator->linkToRoute('theming.Theming.getImage', ['key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter]); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -259,17 +259,17 @@ discard block |
||
259 | 259 | * @return array scss variables to overwrite |
260 | 260 | */ |
261 | 261 | public function getScssVariables() { |
262 | - $cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl()); |
|
262 | + $cache = $this->cacheFactory->createDistributed('theming-'.$this->urlGenerator->getBaseUrl()); |
|
263 | 263 | if ($value = $cache->get('getScssVariables')) { |
264 | 264 | return $value; |
265 | 265 | } |
266 | 266 | |
267 | 267 | $variables = [ |
268 | - 'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'", |
|
269 | - 'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime') . "'", |
|
270 | - 'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime') . "'", |
|
271 | - 'theming-logoheader-mime' => "'" . $this->config->getAppValue('theming', 'logoheaderMime') . "'", |
|
272 | - 'theming-favicon-mime' => "'" . $this->config->getAppValue('theming', 'faviconMime') . "'" |
|
268 | + 'theming-cachebuster' => "'".$this->config->getAppValue('theming', 'cachebuster', '0')."'", |
|
269 | + 'theming-logo-mime' => "'".$this->config->getAppValue('theming', 'logoMime')."'", |
|
270 | + 'theming-background-mime' => "'".$this->config->getAppValue('theming', 'backgroundMime')."'", |
|
271 | + 'theming-logoheader-mime' => "'".$this->config->getAppValue('theming', 'logoheaderMime')."'", |
|
272 | + 'theming-favicon-mime' => "'".$this->config->getAppValue('theming', 'faviconMime')."'" |
|
273 | 273 | ]; |
274 | 274 | |
275 | 275 | $variables['image-logo'] = "'".$this->imageManager->getImageUrl('logo')."'"; |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | } |
290 | 290 | |
291 | 291 | $variables['has-legal-links'] = 'false'; |
292 | - if($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') { |
|
292 | + if ($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') { |
|
293 | 293 | $variables['has-legal-links'] = 'true'; |
294 | 294 | } |
295 | 295 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * @return bool|string false if image should not replaced, otherwise the location of the image |
307 | 307 | */ |
308 | 308 | public function replaceImagePath($app, $image) { |
309 | - if($app==='') { |
|
309 | + if ($app === '') { |
|
310 | 310 | $app = 'core'; |
311 | 311 | } |
312 | 312 | $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
@@ -318,19 +318,19 @@ discard block |
||
318 | 318 | } |
319 | 319 | |
320 | 320 | if ($image === 'favicon.ico' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { |
321 | - return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue; |
|
321 | + return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]).'?v='.$cacheBusterValue; |
|
322 | 322 | } |
323 | 323 | if ($image === 'favicon-touch.png' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) { |
324 | - return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue; |
|
324 | + return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]).'?v='.$cacheBusterValue; |
|
325 | 325 | } |
326 | 326 | if ($image === 'manifest.json') { |
327 | 327 | try { |
328 | 328 | $appPath = $this->appManager->getAppPath($app); |
329 | - if (file_exists($appPath . '/img/manifest.json')) { |
|
329 | + if (file_exists($appPath.'/img/manifest.json')) { |
|
330 | 330 | return false; |
331 | 331 | } |
332 | 332 | } catch (AppPathNotFoundException $e) {} |
333 | - return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue; |
|
333 | + return $this->urlGenerator->linkToRoute('theming.Theming.getManifest').'?v='.$cacheBusterValue; |
|
334 | 334 | } |
335 | 335 | return false; |
336 | 336 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | */ |
341 | 341 | private function increaseCacheBuster() { |
342 | 342 | $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0'); |
343 | - $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1); |
|
343 | + $this->config->setAppValue('theming', 'cachebuster', (int) $cacheBusterKey + 1); |
|
344 | 344 | $this->cacheFactory->createDistributed('theming-')->clear(); |
345 | 345 | $this->cacheFactory->createDistributed('imagePath')->clear(); |
346 | 346 |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); |
76 | 76 | try { |
77 | 77 | $image = $this->getImage($key, $useSvg); |
78 | - return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => $key ]) . '?v=' . $cacheBusterCounter; |
|
78 | + return $this->urlGenerator->linkToRoute('theming.Theming.getImage', ['key' => $key]).'?v='.$cacheBusterCounter; |
|
79 | 79 | } catch (NotFoundException $e) { |
80 | 80 | } |
81 | 81 | |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | case 'logo': |
84 | 84 | case 'logoheader': |
85 | 85 | case 'favicon': |
86 | - return $this->urlGenerator->imagePath('core', 'logo.png') . '?v=' . $cacheBusterCounter; |
|
86 | + return $this->urlGenerator->imagePath('core', 'logo.png').'?v='.$cacheBusterCounter; |
|
87 | 87 | case 'background': |
88 | - return $this->urlGenerator->imagePath('core', 'background.png') . '?v=' . $cacheBusterCounter; |
|
88 | + return $this->urlGenerator->imagePath('core', 'background.png').'?v='.$cacheBusterCounter; |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -102,26 +102,26 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function getImage(string $key, bool $useSvg = true): ISimpleFile { |
104 | 104 | $pngFile = null; |
105 | - $logo = $this->config->getAppValue('theming', $key . 'Mime', false); |
|
105 | + $logo = $this->config->getAppValue('theming', $key.'Mime', false); |
|
106 | 106 | $folder = $this->appData->getFolder('images'); |
107 | 107 | if ($logo === false || !$folder->fileExists($key)) { |
108 | 108 | throw new NotFoundException(); |
109 | 109 | } |
110 | 110 | if (!$useSvg && $this->shouldReplaceIcons()) { |
111 | - if (!$folder->fileExists($key . '.png')) { |
|
111 | + if (!$folder->fileExists($key.'.png')) { |
|
112 | 112 | try { |
113 | 113 | $finalIconFile = new \Imagick(); |
114 | 114 | $finalIconFile->setBackgroundColor('none'); |
115 | 115 | $finalIconFile->readImageBlob($folder->getFile($key)->getContent()); |
116 | 116 | $finalIconFile->setImageFormat('png32'); |
117 | - $pngFile = $folder->newFile($key . '.png'); |
|
117 | + $pngFile = $folder->newFile($key.'.png'); |
|
118 | 118 | $pngFile->putContent($finalIconFile->getImageBlob()); |
119 | 119 | } catch (\ImagickException $e) { |
120 | 120 | $this->logger->info('The image was requested to be no SVG file, but converting it to PNG failed.', $e->getMessage()); |
121 | 121 | $pngFile = null; |
122 | 122 | } |
123 | 123 | } else { |
124 | - $pngFile = $folder->getFile($key . '.png'); |
|
124 | + $pngFile = $folder->getFile($key.'.png'); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | if ($pngFile !== null) { |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $images = []; |
135 | 135 | foreach ($this->supportedImageKeys as $key) { |
136 | 136 | $images[$key] = [ |
137 | - 'mime' => $this->config->getAppValue('theming', $key . 'Mime', ''), |
|
137 | + 'mime' => $this->config->getAppValue('theming', $key.'Mime', ''), |
|
138 | 138 | 'url' => $this->getImageUrl($key), |
139 | 139 | ]; |
140 | 140 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | } catch (NotPermittedException $e) { |
201 | 201 | } |
202 | 202 | try { |
203 | - $file = $this->appData->getFolder('images')->getFile($key . '.png'); |
|
203 | + $file = $this->appData->getFolder('images')->getFile($key.'.png'); |
|
204 | 204 | $file->delete(); |
205 | 205 | } catch (NotFoundException $e) { |
206 | 206 | } catch (NotPermittedException $e) { |
@@ -230,12 +230,12 @@ discard block |
||
230 | 230 | * @return bool |
231 | 231 | */ |
232 | 232 | public function shouldReplaceIcons() { |
233 | - $cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl()); |
|
234 | - if($value = $cache->get('shouldReplaceIcons')) { |
|
235 | - return (bool)$value; |
|
233 | + $cache = $this->cacheFactory->createDistributed('theming-'.$this->urlGenerator->getBaseUrl()); |
|
234 | + if ($value = $cache->get('shouldReplaceIcons')) { |
|
235 | + return (bool) $value; |
|
236 | 236 | } |
237 | 237 | $value = false; |
238 | - if(extension_loaded('imagick')) { |
|
238 | + if (extension_loaded('imagick')) { |
|
239 | 239 | if (count(\Imagick::queryFormats('SVG')) >= 1) { |
240 | 240 | $value = true; |
241 | 241 | } |