@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); |
70 | 70 | try { |
71 | 71 | $image = $this->getImage($key, $useSvg); |
72 | - return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => $key ]) . '?v=' . $cacheBusterCounter; |
|
72 | + return $this->urlGenerator->linkToRoute('theming.Theming.getImage', ['key' => $key]).'?v='.$cacheBusterCounter; |
|
73 | 73 | } catch (NotFoundException $e) { |
74 | 74 | } |
75 | 75 | |
@@ -77,9 +77,9 @@ discard block |
||
77 | 77 | case 'logo': |
78 | 78 | case 'logoheader': |
79 | 79 | case 'favicon': |
80 | - return $this->urlGenerator->imagePath('core', 'logo.png') . '?v=' . $cacheBusterCounter; |
|
80 | + return $this->urlGenerator->imagePath('core', 'logo.png').'?v='.$cacheBusterCounter; |
|
81 | 81 | case 'background': |
82 | - return $this->urlGenerator->imagePath('core', 'background.png') . '?v=' . $cacheBusterCounter; |
|
82 | + return $this->urlGenerator->imagePath('core', 'background.png').'?v='.$cacheBusterCounter; |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -95,24 +95,24 @@ discard block |
||
95 | 95 | * @throws NotPermittedException |
96 | 96 | */ |
97 | 97 | public function getImage(string $key, bool $useSvg = true): ISimpleFile { |
98 | - $logo = $this->config->getAppValue('theming', $key . 'Mime', false); |
|
98 | + $logo = $this->config->getAppValue('theming', $key.'Mime', false); |
|
99 | 99 | $folder = $this->appData->getFolder('images'); |
100 | 100 | if ($logo === false || !$folder->fileExists($key)) { |
101 | 101 | throw new NotFoundException(); |
102 | 102 | } |
103 | 103 | if (!$useSvg && $this->shouldReplaceIcons()) { |
104 | - if (!$folder->fileExists($key . '.png')) { |
|
104 | + if (!$folder->fileExists($key.'.png')) { |
|
105 | 105 | try { |
106 | 106 | $finalIconFile = new \Imagick(); |
107 | 107 | $finalIconFile->setBackgroundColor('none'); |
108 | 108 | $finalIconFile->readImageBlob($folder->getFile($key)->getContent()); |
109 | 109 | $finalIconFile->setImageFormat('png32'); |
110 | - $pngFile = $folder->newFile($key . '.png'); |
|
110 | + $pngFile = $folder->newFile($key.'.png'); |
|
111 | 111 | $pngFile->putContent($finalIconFile->getImageBlob()); |
112 | 112 | } catch (\ImagickException $e) { |
113 | 113 | } |
114 | 114 | } else { |
115 | - $pngFile = $folder->getFile($key . '.png'); |
|
115 | + $pngFile = $folder->getFile($key.'.png'); |
|
116 | 116 | } |
117 | 117 | return $pngFile; |
118 | 118 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $images = []; |
124 | 124 | foreach ($this->supportedImageKeys as $key) { |
125 | 125 | $images[$key] = [ |
126 | - 'mime' => $this->config->getAppValue('theming', $key . 'Mime', ''), |
|
126 | + 'mime' => $this->config->getAppValue('theming', $key.'Mime', ''), |
|
127 | 127 | 'url' => $this->getImageUrl($key), |
128 | 128 | ]; |
129 | 129 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } catch (NotPermittedException $e) { |
189 | 189 | } |
190 | 190 | try { |
191 | - $file = $this->appData->getFolder('images')->getFile($key . '.png'); |
|
191 | + $file = $this->appData->getFolder('images')->getFile($key.'.png'); |
|
192 | 192 | $file->delete(); |
193 | 193 | } catch (NotFoundException $e) { |
194 | 194 | } catch (NotPermittedException $e) { |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | * @return bool |
219 | 219 | */ |
220 | 220 | public function shouldReplaceIcons() { |
221 | - $cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl()); |
|
222 | - if($value = $cache->get('shouldReplaceIcons')) { |
|
223 | - return (bool)$value; |
|
221 | + $cache = $this->cacheFactory->createDistributed('theming-'.$this->urlGenerator->getBaseUrl()); |
|
222 | + if ($value = $cache->get('shouldReplaceIcons')) { |
|
223 | + return (bool) $value; |
|
224 | 224 | } |
225 | 225 | $value = false; |
226 | - if(extension_loaded('imagick')) { |
|
226 | + if (extension_loaded('imagick')) { |
|
227 | 227 | if (count(\Imagick::queryFormats('SVG')) >= 1) { |
228 | 228 | $value = true; |
229 | 229 | } |
@@ -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 |