Completed
Push — master ( 60734c...d4a0af )
by Morris
20:02
created
apps/theming/lib/Settings/Admin.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -38,75 +38,75 @@
 block discarded – undo
38 38
 use OCP\Settings\ISettings;
39 39
 
40 40
 class Admin implements ISettings {
41
-	/** @var IConfig */
42
-	private $config;
43
-	/** @var IL10N */
44
-	private $l;
45
-	/** @var ThemingDefaults */
46
-	private $themingDefaults;
47
-	/** @var IURLGenerator */
48
-	private $urlGenerator;
49
-	/** @var ImageManager */
50
-	private $imageManager;
41
+    /** @var IConfig */
42
+    private $config;
43
+    /** @var IL10N */
44
+    private $l;
45
+    /** @var ThemingDefaults */
46
+    private $themingDefaults;
47
+    /** @var IURLGenerator */
48
+    private $urlGenerator;
49
+    /** @var ImageManager */
50
+    private $imageManager;
51 51
 
52
-	public function __construct(IConfig $config,
53
-								IL10N $l,
54
-								ThemingDefaults $themingDefaults,
55
-								IURLGenerator $urlGenerator,
56
-								ImageManager $imageManager) {
57
-		$this->config = $config;
58
-		$this->l = $l;
59
-		$this->themingDefaults = $themingDefaults;
60
-		$this->urlGenerator = $urlGenerator;
61
-		$this->imageManager = $imageManager;
62
-	}
52
+    public function __construct(IConfig $config,
53
+                                IL10N $l,
54
+                                ThemingDefaults $themingDefaults,
55
+                                IURLGenerator $urlGenerator,
56
+                                ImageManager $imageManager) {
57
+        $this->config = $config;
58
+        $this->l = $l;
59
+        $this->themingDefaults = $themingDefaults;
60
+        $this->urlGenerator = $urlGenerator;
61
+        $this->imageManager = $imageManager;
62
+    }
63 63
 
64
-	/**
65
-	 * @return TemplateResponse
66
-	 */
67
-	public function getForm(): TemplateResponse {
68
-		$themable = true;
69
-		$errorMessage = '';
70
-		$theme = $this->config->getSystemValue('theme', '');
71
-		if ($theme !== '') {
72
-			$themable = false;
73
-			$errorMessage = $this->l->t('You are already using a custom theme. Theming app settings might be overwritten by that.');
74
-		}
64
+    /**
65
+     * @return TemplateResponse
66
+     */
67
+    public function getForm(): TemplateResponse {
68
+        $themable = true;
69
+        $errorMessage = '';
70
+        $theme = $this->config->getSystemValue('theme', '');
71
+        if ($theme !== '') {
72
+            $themable = false;
73
+            $errorMessage = $this->l->t('You are already using a custom theme. Theming app settings might be overwritten by that.');
74
+        }
75 75
 
76
-		$parameters = [
77
-			'themable'        => $themable,
78
-			'errorMessage'    => $errorMessage,
79
-			'name'            => $this->themingDefaults->getEntity(),
80
-			'url'             => $this->themingDefaults->getBaseUrl(),
81
-			'slogan'          => $this->themingDefaults->getSlogan(),
82
-			'color'           => $this->themingDefaults->getColorPrimary(),
83
-			'uploadLogoRoute' => $this->urlGenerator->linkToRoute('theming.Theming.uploadImage'),
84
-			'canThemeIcons'   => $this->themingDefaults->shouldReplaceIcons(),
85
-			'iconDocs'        => $this->urlGenerator->linkToDocs('admin-theming-icons'),
86
-			'images'		  => $this->imageManager->getCustomImages(),
87
-			'imprintUrl'      => $this->themingDefaults->getImprintUrl(),
88
-			'privacyUrl'      => $this->themingDefaults->getPrivacyUrl(),
89
-		];
76
+        $parameters = [
77
+            'themable'        => $themable,
78
+            'errorMessage'    => $errorMessage,
79
+            'name'            => $this->themingDefaults->getEntity(),
80
+            'url'             => $this->themingDefaults->getBaseUrl(),
81
+            'slogan'          => $this->themingDefaults->getSlogan(),
82
+            'color'           => $this->themingDefaults->getColorPrimary(),
83
+            'uploadLogoRoute' => $this->urlGenerator->linkToRoute('theming.Theming.uploadImage'),
84
+            'canThemeIcons'   => $this->themingDefaults->shouldReplaceIcons(),
85
+            'iconDocs'        => $this->urlGenerator->linkToDocs('admin-theming-icons'),
86
+            'images'		  => $this->imageManager->getCustomImages(),
87
+            'imprintUrl'      => $this->themingDefaults->getImprintUrl(),
88
+            'privacyUrl'      => $this->themingDefaults->getPrivacyUrl(),
89
+        ];
90 90
 
91
-		return new TemplateResponse('theming', 'settings-admin', $parameters, '');
92
-	}
91
+        return new TemplateResponse('theming', 'settings-admin', $parameters, '');
92
+    }
93 93
 
94
-	/**
95
-	 * @return string the section ID, e.g. 'sharing'
96
-	 */
97
-	public function getSection(): string {
98
-		return 'theming';
99
-	}
94
+    /**
95
+     * @return string the section ID, e.g. 'sharing'
96
+     */
97
+    public function getSection(): string {
98
+        return 'theming';
99
+    }
100 100
 
101
-	/**
102
-	 * @return int whether the form should be rather on the top or bottom of
103
-	 * the admin section. The forms are arranged in ascending order of the
104
-	 * priority values. It is required to return a value between 0 and 100.
105
-	 *
106
-	 * E.g.: 70
107
-	 */
108
-	public function getPriority(): int {
109
-		return 5;
110
-	}
101
+    /**
102
+     * @return int whether the form should be rather on the top or bottom of
103
+     * the admin section. The forms are arranged in ascending order of the
104
+     * priority values. It is required to return a value between 0 and 100.
105
+     *
106
+     * E.g.: 70
107
+     */
108
+    public function getPriority(): int {
109
+        return 5;
110
+    }
111 111
 
112 112
 }
Please login to merge, or discard this patch.
apps/theming/lib/ThemingDefaults.php 2 patches
Indentation   +375 added lines, -375 removed lines patch added patch discarded remove patch
@@ -44,379 +44,379 @@
 block discarded – undo
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
-		$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
155
-			' rel="noreferrer noopener">' .$this->getEntity() . '</a>'.
156
-			($slogan !== '' ? ' – ' . $slogan : '');
157
-
158
-		$links = [
159
-			[
160
-				'text' => $this->l->t('Legal notice'),
161
-				'url' => (string)$this->getImprintUrl()
162
-			],
163
-			[
164
-				'text' => $this->l->t('Privacy policy'),
165
-				'url' => (string)$this->getPrivacyUrl()
166
-			],
167
-		];
168
-
169
-		$legalLinks = ''; $divider = '';
170
-		foreach($links as $link) {
171
-			if($link['url'] !== ''
172
-				&& filter_var($link['url'], FILTER_VALIDATE_URL, [
173
-					'flags' => FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED
174
-				])
175
-			) {
176
-				$legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"' .
177
-					' rel="noreferrer noopener">' . $link['text'] . '</a>';
178
-				$divider = ' · ';
179
-			}
180
-		}
181
-		if($legalLinks !== '' ) {
182
-			$footer .= '<br/>' . $legalLinks;
183
-		}
184
-
185
-		return $footer;
186
-	}
187
-
188
-	/**
189
-	 * Color that is used for the header as well as for mail headers
190
-	 *
191
-	 * @return string
192
-	 */
193
-	public function getColorPrimary() {
194
-		return $this->config->getAppValue('theming', 'color', $this->color);
195
-	}
196
-
197
-	/**
198
-	 * Themed logo url
199
-	 *
200
-	 * @param bool $useSvg Whether to point to the SVG image or a fallback
201
-	 * @return string
202
-	 */
203
-	public function getLogo($useSvg = true): string {
204
-		$logo = $this->config->getAppValue('theming', 'logoMime', false);
205
-
206
-		$logoExists = true;
207
-		try {
208
-			$this->imageManager->getImage('logo');
209
-		} catch (\Exception $e) {
210
-			$logoExists = false;
211
-		}
212
-
213
-		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
214
-
215
-		if(!$logo || !$logoExists) {
216
-			if($useSvg) {
217
-				$logo = $this->urlGenerator->imagePath('core', 'logo.svg');
218
-			} else {
219
-				$logo = $this->urlGenerator->imagePath('core', 'logo.png');
220
-			}
221
-			return $logo . '?v=' . $cacheBusterCounter;
222
-		}
223
-
224
-		return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo' ]) . '?v=' . $cacheBusterCounter;
225
-	}
226
-
227
-	/**
228
-	 * Themed background image url
229
-	 *
230
-	 * @return string
231
-	 */
232
-	public function getBackground(): string {
233
-		return $this->imageManager->getImageUrl('background');
234
-	}
235
-
236
-	/**
237
-	 * @return string
238
-	 */
239
-	public function getiTunesAppId() {
240
-		return $this->config->getAppValue('theming', 'iTunesAppId', $this->iTunesAppId);
241
-	}
242
-
243
-	/**
244
-	 * @return string
245
-	 */
246
-	public function getiOSClientUrl() {
247
-		return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl);
248
-	}
249
-
250
-	/**
251
-	 * @return string
252
-	 */
253
-	public function getAndroidClientUrl() {
254
-		return $this->config->getAppValue('theming', 'AndroidClientUrl', $this->AndroidClientUrl);
255
-	}
256
-
257
-
258
-	/**
259
-	 * @return array scss variables to overwrite
260
-	 */
261
-	public function getScssVariables() {
262
-		$cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl());
263
-		if ($value = $cache->get('getScssVariables')) {
264
-			return $value;
265
-		}
266
-
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') . "'"
273
-		];
274
-
275
-		$variables['image-logo'] = "'".$this->imageManager->getImageUrl('logo')."'";
276
-		$variables['image-logoheader'] = "'".$this->imageManager->getImageUrl('logoheader')."'";
277
-		$variables['image-favicon'] = "'".$this->imageManager->getImageUrl('favicon')."'";
278
-		$variables['image-login-background'] = "'".$this->imageManager->getImageUrl('background')."'";
279
-		$variables['image-login-plain'] = 'false';
280
-
281
-		if ($this->config->getAppValue('theming', 'color', null) !== null) {
282
-			$variables['color-primary'] = $this->getColorPrimary();
283
-			$variables['color-primary-text'] = $this->getTextColorPrimary();
284
-			$variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary());
285
-		}
286
-
287
-		if ($this->config->getAppValue('theming', 'backgroundMime', null) === 'backgroundColor') {
288
-			$variables['image-login-plain'] = 'true';
289
-		}
290
-
291
-		$variables['has-legal-links'] = 'false';
292
-		if($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') {
293
-			$variables['has-legal-links'] = 'true';
294
-		}
295
-
296
-		$cache->set('getScssVariables', $variables);
297
-		return $variables;
298
-	}
299
-
300
-	/**
301
-	 * Check if the image should be replaced by the theming app
302
-	 * and return the new image location then
303
-	 *
304
-	 * @param string $app name of the app
305
-	 * @param string $image filename of the image
306
-	 * @return bool|string false if image should not replaced, otherwise the location of the image
307
-	 */
308
-	public function replaceImagePath($app, $image) {
309
-		if($app==='') {
310
-			$app = 'core';
311
-		}
312
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
313
-
314
-		try {
315
-			$customFavicon = $this->imageManager->getImage('favicon');
316
-		} catch (NotFoundException $e) {
317
-			$customFavicon = null;
318
-		}
319
-
320
-		if ($image === 'favicon.ico' && ($customFavicon !== null || $this->shouldReplaceIcons())) {
321
-			return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue;
322
-		}
323
-		if ($image === 'favicon-touch.png' && ($customFavicon !== null || $this->shouldReplaceIcons())) {
324
-			return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue;
325
-		}
326
-		if ($image === 'manifest.json') {
327
-			try {
328
-				$appPath = $this->appManager->getAppPath($app);
329
-				if (file_exists($appPath . '/img/manifest.json')) {
330
-					return false;
331
-				}
332
-			} catch (AppPathNotFoundException $e) {}
333
-			return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue;
334
-		}
335
-		return false;
336
-	}
337
-
338
-	/**
339
-	 * Check if Imagemagick is enabled and if SVG is supported
340
-	 * otherwise we can't render custom icons
341
-	 *
342
-	 * @return bool
343
-	 */
344
-	public function shouldReplaceIcons() {
345
-		$cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl());
346
-		if($value = $cache->get('shouldReplaceIcons')) {
347
-			return (bool)$value;
348
-		}
349
-		$value = false;
350
-		if(extension_loaded('imagick')) {
351
-			$checkImagick = new \Imagick();
352
-			if (count($checkImagick->queryFormats('SVG')) >= 1) {
353
-				$value = true;
354
-			}
355
-			$checkImagick->clear();
356
-		}
357
-		$cache->set('shouldReplaceIcons', $value);
358
-		return $value;
359
-	}
360
-
361
-	/**
362
-	 * Increases the cache buster key
363
-	 */
364
-	private function increaseCacheBuster() {
365
-		$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
366
-		$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
367
-		$this->cacheFactory->createDistributed('theming-')->clear();
368
-		$this->cacheFactory->createDistributed('imagePath')->clear();
369
-
370
-	}
371
-
372
-	/**
373
-	 * Update setting in the database
374
-	 *
375
-	 * @param string $setting
376
-	 * @param string $value
377
-	 */
378
-	public function set($setting, $value) {
379
-		$this->config->setAppValue('theming', $setting, $value);
380
-		$this->increaseCacheBuster();
381
-	}
382
-
383
-	/**
384
-	 * Revert settings to the default value
385
-	 *
386
-	 * @param string $setting setting which should be reverted
387
-	 * @return string default value
388
-	 */
389
-	public function undo($setting) {
390
-		$this->config->deleteAppValue('theming', $setting);
391
-		$this->increaseCacheBuster();
392
-
393
-		switch ($setting) {
394
-			case 'name':
395
-				$returnValue = $this->getEntity();
396
-				break;
397
-			case 'url':
398
-				$returnValue = $this->getBaseUrl();
399
-				break;
400
-			case 'slogan':
401
-				$returnValue = $this->getSlogan();
402
-				break;
403
-			case 'color':
404
-				$returnValue = $this->getColorPrimary();
405
-				break;
406
-			default:
407
-				$returnValue = '';
408
-				break;
409
-		}
410
-
411
-		return $returnValue;
412
-	}
413
-
414
-	/**
415
-	 * Color of text in the header and primary buttons
416
-	 *
417
-	 * @return string
418
-	 */
419
-	public function getTextColorPrimary() {
420
-		return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#ffffff';
421
-	}
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
+        $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
155
+            ' rel="noreferrer noopener">' .$this->getEntity() . '</a>'.
156
+            ($slogan !== '' ? ' – ' . $slogan : '');
157
+
158
+        $links = [
159
+            [
160
+                'text' => $this->l->t('Legal notice'),
161
+                'url' => (string)$this->getImprintUrl()
162
+            ],
163
+            [
164
+                'text' => $this->l->t('Privacy policy'),
165
+                'url' => (string)$this->getPrivacyUrl()
166
+            ],
167
+        ];
168
+
169
+        $legalLinks = ''; $divider = '';
170
+        foreach($links as $link) {
171
+            if($link['url'] !== ''
172
+                && filter_var($link['url'], FILTER_VALIDATE_URL, [
173
+                    'flags' => FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED
174
+                ])
175
+            ) {
176
+                $legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"' .
177
+                    ' rel="noreferrer noopener">' . $link['text'] . '</a>';
178
+                $divider = ' · ';
179
+            }
180
+        }
181
+        if($legalLinks !== '' ) {
182
+            $footer .= '<br/>' . $legalLinks;
183
+        }
184
+
185
+        return $footer;
186
+    }
187
+
188
+    /**
189
+     * Color that is used for the header as well as for mail headers
190
+     *
191
+     * @return string
192
+     */
193
+    public function getColorPrimary() {
194
+        return $this->config->getAppValue('theming', 'color', $this->color);
195
+    }
196
+
197
+    /**
198
+     * Themed logo url
199
+     *
200
+     * @param bool $useSvg Whether to point to the SVG image or a fallback
201
+     * @return string
202
+     */
203
+    public function getLogo($useSvg = true): string {
204
+        $logo = $this->config->getAppValue('theming', 'logoMime', false);
205
+
206
+        $logoExists = true;
207
+        try {
208
+            $this->imageManager->getImage('logo');
209
+        } catch (\Exception $e) {
210
+            $logoExists = false;
211
+        }
212
+
213
+        $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
214
+
215
+        if(!$logo || !$logoExists) {
216
+            if($useSvg) {
217
+                $logo = $this->urlGenerator->imagePath('core', 'logo.svg');
218
+            } else {
219
+                $logo = $this->urlGenerator->imagePath('core', 'logo.png');
220
+            }
221
+            return $logo . '?v=' . $cacheBusterCounter;
222
+        }
223
+
224
+        return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo' ]) . '?v=' . $cacheBusterCounter;
225
+    }
226
+
227
+    /**
228
+     * Themed background image url
229
+     *
230
+     * @return string
231
+     */
232
+    public function getBackground(): string {
233
+        return $this->imageManager->getImageUrl('background');
234
+    }
235
+
236
+    /**
237
+     * @return string
238
+     */
239
+    public function getiTunesAppId() {
240
+        return $this->config->getAppValue('theming', 'iTunesAppId', $this->iTunesAppId);
241
+    }
242
+
243
+    /**
244
+     * @return string
245
+     */
246
+    public function getiOSClientUrl() {
247
+        return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl);
248
+    }
249
+
250
+    /**
251
+     * @return string
252
+     */
253
+    public function getAndroidClientUrl() {
254
+        return $this->config->getAppValue('theming', 'AndroidClientUrl', $this->AndroidClientUrl);
255
+    }
256
+
257
+
258
+    /**
259
+     * @return array scss variables to overwrite
260
+     */
261
+    public function getScssVariables() {
262
+        $cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl());
263
+        if ($value = $cache->get('getScssVariables')) {
264
+            return $value;
265
+        }
266
+
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') . "'"
273
+        ];
274
+
275
+        $variables['image-logo'] = "'".$this->imageManager->getImageUrl('logo')."'";
276
+        $variables['image-logoheader'] = "'".$this->imageManager->getImageUrl('logoheader')."'";
277
+        $variables['image-favicon'] = "'".$this->imageManager->getImageUrl('favicon')."'";
278
+        $variables['image-login-background'] = "'".$this->imageManager->getImageUrl('background')."'";
279
+        $variables['image-login-plain'] = 'false';
280
+
281
+        if ($this->config->getAppValue('theming', 'color', null) !== null) {
282
+            $variables['color-primary'] = $this->getColorPrimary();
283
+            $variables['color-primary-text'] = $this->getTextColorPrimary();
284
+            $variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary());
285
+        }
286
+
287
+        if ($this->config->getAppValue('theming', 'backgroundMime', null) === 'backgroundColor') {
288
+            $variables['image-login-plain'] = 'true';
289
+        }
290
+
291
+        $variables['has-legal-links'] = 'false';
292
+        if($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') {
293
+            $variables['has-legal-links'] = 'true';
294
+        }
295
+
296
+        $cache->set('getScssVariables', $variables);
297
+        return $variables;
298
+    }
299
+
300
+    /**
301
+     * Check if the image should be replaced by the theming app
302
+     * and return the new image location then
303
+     *
304
+     * @param string $app name of the app
305
+     * @param string $image filename of the image
306
+     * @return bool|string false if image should not replaced, otherwise the location of the image
307
+     */
308
+    public function replaceImagePath($app, $image) {
309
+        if($app==='') {
310
+            $app = 'core';
311
+        }
312
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
313
+
314
+        try {
315
+            $customFavicon = $this->imageManager->getImage('favicon');
316
+        } catch (NotFoundException $e) {
317
+            $customFavicon = null;
318
+        }
319
+
320
+        if ($image === 'favicon.ico' && ($customFavicon !== null || $this->shouldReplaceIcons())) {
321
+            return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue;
322
+        }
323
+        if ($image === 'favicon-touch.png' && ($customFavicon !== null || $this->shouldReplaceIcons())) {
324
+            return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue;
325
+        }
326
+        if ($image === 'manifest.json') {
327
+            try {
328
+                $appPath = $this->appManager->getAppPath($app);
329
+                if (file_exists($appPath . '/img/manifest.json')) {
330
+                    return false;
331
+                }
332
+            } catch (AppPathNotFoundException $e) {}
333
+            return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue;
334
+        }
335
+        return false;
336
+    }
337
+
338
+    /**
339
+     * Check if Imagemagick is enabled and if SVG is supported
340
+     * otherwise we can't render custom icons
341
+     *
342
+     * @return bool
343
+     */
344
+    public function shouldReplaceIcons() {
345
+        $cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl());
346
+        if($value = $cache->get('shouldReplaceIcons')) {
347
+            return (bool)$value;
348
+        }
349
+        $value = false;
350
+        if(extension_loaded('imagick')) {
351
+            $checkImagick = new \Imagick();
352
+            if (count($checkImagick->queryFormats('SVG')) >= 1) {
353
+                $value = true;
354
+            }
355
+            $checkImagick->clear();
356
+        }
357
+        $cache->set('shouldReplaceIcons', $value);
358
+        return $value;
359
+    }
360
+
361
+    /**
362
+     * Increases the cache buster key
363
+     */
364
+    private function increaseCacheBuster() {
365
+        $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
366
+        $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
367
+        $this->cacheFactory->createDistributed('theming-')->clear();
368
+        $this->cacheFactory->createDistributed('imagePath')->clear();
369
+
370
+    }
371
+
372
+    /**
373
+     * Update setting in the database
374
+     *
375
+     * @param string $setting
376
+     * @param string $value
377
+     */
378
+    public function set($setting, $value) {
379
+        $this->config->setAppValue('theming', $setting, $value);
380
+        $this->increaseCacheBuster();
381
+    }
382
+
383
+    /**
384
+     * Revert settings to the default value
385
+     *
386
+     * @param string $setting setting which should be reverted
387
+     * @return string default value
388
+     */
389
+    public function undo($setting) {
390
+        $this->config->deleteAppValue('theming', $setting);
391
+        $this->increaseCacheBuster();
392
+
393
+        switch ($setting) {
394
+            case 'name':
395
+                $returnValue = $this->getEntity();
396
+                break;
397
+            case 'url':
398
+                $returnValue = $this->getBaseUrl();
399
+                break;
400
+            case 'slogan':
401
+                $returnValue = $this->getSlogan();
402
+                break;
403
+            case 'color':
404
+                $returnValue = $this->getColorPrimary();
405
+                break;
406
+            default:
407
+                $returnValue = '';
408
+                break;
409
+        }
410
+
411
+        return $returnValue;
412
+    }
413
+
414
+    /**
415
+     * Color of text in the header and primary buttons
416
+     *
417
+     * @return string
418
+     */
419
+    public function getTextColorPrimary() {
420
+        return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#ffffff';
421
+    }
422 422
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -142,44 +142,44 @@  discard block
 block discarded – undo
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
 block discarded – undo
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' ]) . '?v=' . $cacheBusterCounter;
224
+		return $this->urlGenerator->linkToRoute('theming.Theming.getImage', ['key' => 'logo']).'?v='.$cacheBusterCounter;
225 225
 	}
226 226
 
227 227
 	/**
@@ -259,17 +259,17 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
318 318
 		}
319 319
 
320 320
 		if ($image === 'favicon.ico' && ($customFavicon !== null || $this->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->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
 	}
@@ -342,12 +342,12 @@  discard block
 block discarded – undo
342 342
 	 * @return bool
343 343
 	 */
344 344
 	public function shouldReplaceIcons() {
345
-		$cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl());
346
-		if($value = $cache->get('shouldReplaceIcons')) {
347
-			return (bool)$value;
345
+		$cache = $this->cacheFactory->createDistributed('theming-'.$this->urlGenerator->getBaseUrl());
346
+		if ($value = $cache->get('shouldReplaceIcons')) {
347
+			return (bool) $value;
348 348
 		}
349 349
 		$value = false;
350
-		if(extension_loaded('imagick')) {
350
+		if (extension_loaded('imagick')) {
351 351
 			$checkImagick = new \Imagick();
352 352
 			if (count($checkImagick->queryFormats('SVG')) >= 1) {
353 353
 				$value = true;
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	 */
364 364
 	private function increaseCacheBuster() {
365 365
 		$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
366
-		$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
366
+		$this->config->setAppValue('theming', 'cachebuster', (int) $cacheBusterKey + 1);
367 367
 		$this->cacheFactory->createDistributed('theming-')->clear();
368 368
 		$this->cacheFactory->createDistributed('imagePath')->clear();
369 369
 
Please login to merge, or discard this patch.
apps/theming/lib/Controller/ThemingController.php 2 patches
Indentation   +372 added lines, -372 removed lines patch added patch discarded remove patch
@@ -62,367 +62,367 @@  discard block
 block discarded – undo
62 62
  * @package OCA\Theming\Controller
63 63
  */
64 64
 class ThemingController extends Controller {
65
-	/** @var ThemingDefaults */
66
-	private $themingDefaults;
67
-	/** @var Util */
68
-	private $util;
69
-	/** @var ITimeFactory */
70
-	private $timeFactory;
71
-	/** @var IL10N */
72
-	private $l10n;
73
-	/** @var IConfig */
74
-	private $config;
75
-	/** @var ITempManager */
76
-	private $tempManager;
77
-	/** @var IAppData */
78
-	private $appData;
79
-	/** @var SCSSCacher */
80
-	private $scssCacher;
81
-	/** @var IURLGenerator */
82
-	private $urlGenerator;
83
-	/** @var IAppManager */
84
-	private $appManager;
85
-	/** @var ImageManager */
86
-	private $imageManager;
65
+    /** @var ThemingDefaults */
66
+    private $themingDefaults;
67
+    /** @var Util */
68
+    private $util;
69
+    /** @var ITimeFactory */
70
+    private $timeFactory;
71
+    /** @var IL10N */
72
+    private $l10n;
73
+    /** @var IConfig */
74
+    private $config;
75
+    /** @var ITempManager */
76
+    private $tempManager;
77
+    /** @var IAppData */
78
+    private $appData;
79
+    /** @var SCSSCacher */
80
+    private $scssCacher;
81
+    /** @var IURLGenerator */
82
+    private $urlGenerator;
83
+    /** @var IAppManager */
84
+    private $appManager;
85
+    /** @var ImageManager */
86
+    private $imageManager;
87 87
 
88
-	/**
89
-	 * ThemingController constructor.
90
-	 *
91
-	 * @param string $appName
92
-	 * @param IRequest $request
93
-	 * @param IConfig $config
94
-	 * @param ThemingDefaults $themingDefaults
95
-	 * @param Util $util
96
-	 * @param ITimeFactory $timeFactory
97
-	 * @param IL10N $l
98
-	 * @param ITempManager $tempManager
99
-	 * @param IAppData $appData
100
-	 * @param SCSSCacher $scssCacher
101
-	 * @param IURLGenerator $urlGenerator
102
-	 * @param IAppManager $appManager
103
-	 * @param ImageManager $imageManager
104
-	 */
105
-	public function __construct(
106
-		$appName,
107
-		IRequest $request,
108
-		IConfig $config,
109
-		ThemingDefaults $themingDefaults,
110
-		Util $util,
111
-		ITimeFactory $timeFactory,
112
-		IL10N $l,
113
-		ITempManager $tempManager,
114
-		IAppData $appData,
115
-		SCSSCacher $scssCacher,
116
-		IURLGenerator $urlGenerator,
117
-		IAppManager $appManager,
118
-		ImageManager $imageManager
119
-	) {
120
-		parent::__construct($appName, $request);
88
+    /**
89
+     * ThemingController constructor.
90
+     *
91
+     * @param string $appName
92
+     * @param IRequest $request
93
+     * @param IConfig $config
94
+     * @param ThemingDefaults $themingDefaults
95
+     * @param Util $util
96
+     * @param ITimeFactory $timeFactory
97
+     * @param IL10N $l
98
+     * @param ITempManager $tempManager
99
+     * @param IAppData $appData
100
+     * @param SCSSCacher $scssCacher
101
+     * @param IURLGenerator $urlGenerator
102
+     * @param IAppManager $appManager
103
+     * @param ImageManager $imageManager
104
+     */
105
+    public function __construct(
106
+        $appName,
107
+        IRequest $request,
108
+        IConfig $config,
109
+        ThemingDefaults $themingDefaults,
110
+        Util $util,
111
+        ITimeFactory $timeFactory,
112
+        IL10N $l,
113
+        ITempManager $tempManager,
114
+        IAppData $appData,
115
+        SCSSCacher $scssCacher,
116
+        IURLGenerator $urlGenerator,
117
+        IAppManager $appManager,
118
+        ImageManager $imageManager
119
+    ) {
120
+        parent::__construct($appName, $request);
121 121
 
122
-		$this->themingDefaults = $themingDefaults;
123
-		$this->util = $util;
124
-		$this->timeFactory = $timeFactory;
125
-		$this->l10n = $l;
126
-		$this->config = $config;
127
-		$this->tempManager = $tempManager;
128
-		$this->appData = $appData;
129
-		$this->scssCacher = $scssCacher;
130
-		$this->urlGenerator = $urlGenerator;
131
-		$this->appManager = $appManager;
132
-		$this->imageManager = $imageManager;
133
-	}
122
+        $this->themingDefaults = $themingDefaults;
123
+        $this->util = $util;
124
+        $this->timeFactory = $timeFactory;
125
+        $this->l10n = $l;
126
+        $this->config = $config;
127
+        $this->tempManager = $tempManager;
128
+        $this->appData = $appData;
129
+        $this->scssCacher = $scssCacher;
130
+        $this->urlGenerator = $urlGenerator;
131
+        $this->appManager = $appManager;
132
+        $this->imageManager = $imageManager;
133
+    }
134 134
 
135
-	/**
136
-	 * @param string $setting
137
-	 * @param string $value
138
-	 * @return DataResponse
139
-	 * @throws NotPermittedException
140
-	 */
141
-	public function updateStylesheet($setting, $value) {
142
-		$value = trim($value);
143
-		switch ($setting) {
144
-			case 'name':
145
-				if (strlen($value) > 250) {
146
-					return new DataResponse([
147
-						'data' => [
148
-							'message' => $this->l10n->t('The given name is too long'),
149
-						],
150
-						'status' => 'error'
151
-					]);
152
-				}
153
-				break;
154
-			case 'url':
155
-				if (strlen($value) > 500) {
156
-					return new DataResponse([
157
-						'data' => [
158
-							'message' => $this->l10n->t('The given web address is too long'),
159
-						],
160
-						'status' => 'error'
161
-					]);
162
-				}
163
-				break;
164
-			case 'imprintUrl':
165
-				if (strlen($value) > 500) {
166
-					return new DataResponse([
167
-						'data' => [
168
-							'message' => $this->l10n->t('The given legal notice address is too long'),
169
-						],
170
-						'status' => 'error'
171
-					]);
172
-				}
173
-				break;
174
-			case 'privacyUrl':
175
-				if (strlen($value) > 500) {
176
-					return new DataResponse([
177
-						'data' => [
178
-							'message' => $this->l10n->t('The given privacy policy address is too long'),
179
-						],
180
-						'status' => 'error'
181
-					]);
182
-				}
183
-				break;
184
-			case 'slogan':
185
-				if (strlen($value) > 500) {
186
-					return new DataResponse([
187
-						'data' => [
188
-							'message' => $this->l10n->t('The given slogan is too long'),
189
-						],
190
-						'status' => 'error'
191
-					]);
192
-				}
193
-				break;
194
-			case 'color':
195
-				if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
196
-					return new DataResponse([
197
-						'data' => [
198
-							'message' => $this->l10n->t('The given color is invalid'),
199
-						],
200
-						'status' => 'error'
201
-					]);
202
-				}
203
-				break;
204
-		}
135
+    /**
136
+     * @param string $setting
137
+     * @param string $value
138
+     * @return DataResponse
139
+     * @throws NotPermittedException
140
+     */
141
+    public function updateStylesheet($setting, $value) {
142
+        $value = trim($value);
143
+        switch ($setting) {
144
+            case 'name':
145
+                if (strlen($value) > 250) {
146
+                    return new DataResponse([
147
+                        'data' => [
148
+                            'message' => $this->l10n->t('The given name is too long'),
149
+                        ],
150
+                        'status' => 'error'
151
+                    ]);
152
+                }
153
+                break;
154
+            case 'url':
155
+                if (strlen($value) > 500) {
156
+                    return new DataResponse([
157
+                        'data' => [
158
+                            'message' => $this->l10n->t('The given web address is too long'),
159
+                        ],
160
+                        'status' => 'error'
161
+                    ]);
162
+                }
163
+                break;
164
+            case 'imprintUrl':
165
+                if (strlen($value) > 500) {
166
+                    return new DataResponse([
167
+                        'data' => [
168
+                            'message' => $this->l10n->t('The given legal notice address is too long'),
169
+                        ],
170
+                        'status' => 'error'
171
+                    ]);
172
+                }
173
+                break;
174
+            case 'privacyUrl':
175
+                if (strlen($value) > 500) {
176
+                    return new DataResponse([
177
+                        'data' => [
178
+                            'message' => $this->l10n->t('The given privacy policy address is too long'),
179
+                        ],
180
+                        'status' => 'error'
181
+                    ]);
182
+                }
183
+                break;
184
+            case 'slogan':
185
+                if (strlen($value) > 500) {
186
+                    return new DataResponse([
187
+                        'data' => [
188
+                            'message' => $this->l10n->t('The given slogan is too long'),
189
+                        ],
190
+                        'status' => 'error'
191
+                    ]);
192
+                }
193
+                break;
194
+            case 'color':
195
+                if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
196
+                    return new DataResponse([
197
+                        'data' => [
198
+                            'message' => $this->l10n->t('The given color is invalid'),
199
+                        ],
200
+                        'status' => 'error'
201
+                    ]);
202
+                }
203
+                break;
204
+        }
205 205
 
206
-		$this->themingDefaults->set($setting, $value);
206
+        $this->themingDefaults->set($setting, $value);
207 207
 
208
-		// reprocess server scss for preview
209
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/server.scss', 'core');
208
+        // reprocess server scss for preview
209
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/server.scss', 'core');
210 210
 
211
-		return new DataResponse(
212
-			[
213
-				'data' =>
214
-					[
215
-						'message' => $this->l10n->t('Saved'),
216
-						'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
217
-					],
218
-				'status' => 'success'
219
-			]
220
-		);
221
-	}
211
+        return new DataResponse(
212
+            [
213
+                'data' =>
214
+                    [
215
+                        'message' => $this->l10n->t('Saved'),
216
+                        'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
217
+                    ],
218
+                'status' => 'success'
219
+            ]
220
+        );
221
+    }
222 222
 
223
-	/**
224
-	 * @return DataResponse
225
-	 * @throws NotPermittedException
226
-	 */
227
-	public function uploadImage(): DataResponse {
228
-		// logo / background
229
-		// new: favicon logo-header
230
-		//
231
-		$key = $this->request->getParam('key');
232
-		$image = $this->request->getUploadedFile('image');
233
-		$error = null;
234
-		$phpFileUploadErrors = [
235
-			UPLOAD_ERR_OK => $this->l10n->t('The file was uploaded'),
236
-			UPLOAD_ERR_INI_SIZE => $this->l10n->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
237
-			UPLOAD_ERR_FORM_SIZE => $this->l10n->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
238
-			UPLOAD_ERR_PARTIAL => $this->l10n->t('The file was only partially uploaded'),
239
-			UPLOAD_ERR_NO_FILE => $this->l10n->t('No file was uploaded'),
240
-			UPLOAD_ERR_NO_TMP_DIR => $this->l10n->t('Missing a temporary folder'),
241
-			UPLOAD_ERR_CANT_WRITE => $this->l10n->t('Could not write file to disk'),
242
-			UPLOAD_ERR_EXTENSION => $this->l10n->t('A PHP extension stopped the file upload'),
243
-		];
244
-		if (empty($image)) {
245
-			$error = $this->l10n->t('No file uploaded');
246
-		}
247
-		if (!empty($image) && array_key_exists('error', $image) && $image['error'] !== UPLOAD_ERR_OK) {
248
-			$error = $phpFileUploadErrors[$image['error']];
249
-		}
223
+    /**
224
+     * @return DataResponse
225
+     * @throws NotPermittedException
226
+     */
227
+    public function uploadImage(): DataResponse {
228
+        // logo / background
229
+        // new: favicon logo-header
230
+        //
231
+        $key = $this->request->getParam('key');
232
+        $image = $this->request->getUploadedFile('image');
233
+        $error = null;
234
+        $phpFileUploadErrors = [
235
+            UPLOAD_ERR_OK => $this->l10n->t('The file was uploaded'),
236
+            UPLOAD_ERR_INI_SIZE => $this->l10n->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
237
+            UPLOAD_ERR_FORM_SIZE => $this->l10n->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
238
+            UPLOAD_ERR_PARTIAL => $this->l10n->t('The file was only partially uploaded'),
239
+            UPLOAD_ERR_NO_FILE => $this->l10n->t('No file was uploaded'),
240
+            UPLOAD_ERR_NO_TMP_DIR => $this->l10n->t('Missing a temporary folder'),
241
+            UPLOAD_ERR_CANT_WRITE => $this->l10n->t('Could not write file to disk'),
242
+            UPLOAD_ERR_EXTENSION => $this->l10n->t('A PHP extension stopped the file upload'),
243
+        ];
244
+        if (empty($image)) {
245
+            $error = $this->l10n->t('No file uploaded');
246
+        }
247
+        if (!empty($image) && array_key_exists('error', $image) && $image['error'] !== UPLOAD_ERR_OK) {
248
+            $error = $phpFileUploadErrors[$image['error']];
249
+        }
250 250
 
251
-		if ($error !== null) {
252
-			return new DataResponse(
253
-				[
254
-					'data' => [
255
-						'message' => $error
256
-					],
257
-					'status' => 'failure',
258
-				],
259
-				Http::STATUS_UNPROCESSABLE_ENTITY
260
-			);
261
-		}
251
+        if ($error !== null) {
252
+            return new DataResponse(
253
+                [
254
+                    'data' => [
255
+                        'message' => $error
256
+                    ],
257
+                    'status' => 'failure',
258
+                ],
259
+                Http::STATUS_UNPROCESSABLE_ENTITY
260
+            );
261
+        }
262 262
 
263
-		$name = '';
264
-		try {
265
-			$folder = $this->appData->getFolder('images');
266
-		} catch (NotFoundException $e) {
267
-			$folder = $this->appData->newFolder('images');
268
-		}
263
+        $name = '';
264
+        try {
265
+            $folder = $this->appData->getFolder('images');
266
+        } catch (NotFoundException $e) {
267
+            $folder = $this->appData->newFolder('images');
268
+        }
269 269
 
270
-		$target = $folder->newFile($key);
271
-		$supportedFormats = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml', 'image/svg'];
272
-		$detectedMimeType = mime_content_type($image['tmp_name']);
273
-		if (!in_array($image['type'], $supportedFormats) || !in_array($detectedMimeType, $supportedFormats)) {
274
-			return new DataResponse(
275
-				[
276
-					'data' => [
277
-						'message' => $this->l10n->t('Unsupported image type'),
278
-					],
279
-					'status' => 'failure',
280
-				],
281
-				Http::STATUS_UNPROCESSABLE_ENTITY
282
-			);
283
-		}
270
+        $target = $folder->newFile($key);
271
+        $supportedFormats = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml', 'image/svg'];
272
+        $detectedMimeType = mime_content_type($image['tmp_name']);
273
+        if (!in_array($image['type'], $supportedFormats) || !in_array($detectedMimeType, $supportedFormats)) {
274
+            return new DataResponse(
275
+                [
276
+                    'data' => [
277
+                        'message' => $this->l10n->t('Unsupported image type'),
278
+                    ],
279
+                    'status' => 'failure',
280
+                ],
281
+                Http::STATUS_UNPROCESSABLE_ENTITY
282
+            );
283
+        }
284 284
 
285
-		$resizeKeys = ['background'];
286
-		if (in_array($key, $resizeKeys, true)) {
287
-			// Optimize the image since some people may upload images that will be
288
-			// either to big or are not progressive rendering.
289
-			$newImage = @imagecreatefromstring(file_get_contents($image['tmp_name'], 'r'));
285
+        $resizeKeys = ['background'];
286
+        if (in_array($key, $resizeKeys, true)) {
287
+            // Optimize the image since some people may upload images that will be
288
+            // either to big or are not progressive rendering.
289
+            $newImage = @imagecreatefromstring(file_get_contents($image['tmp_name'], 'r'));
290 290
 
291
-			$tmpFile = $this->tempManager->getTemporaryFile();
292
-			$newWidth = imagesx($newImage) < 4096 ? imagesx($newImage) : 4096;
293
-			$newHeight = imagesy($newImage) / (imagesx($newImage) / $newWidth);
294
-			$outputImage = imagescale($newImage, $newWidth, $newHeight);
291
+            $tmpFile = $this->tempManager->getTemporaryFile();
292
+            $newWidth = imagesx($newImage) < 4096 ? imagesx($newImage) : 4096;
293
+            $newHeight = imagesy($newImage) / (imagesx($newImage) / $newWidth);
294
+            $outputImage = imagescale($newImage, $newWidth, $newHeight);
295 295
 
296
-			imageinterlace($outputImage, 1);
297
-			imagejpeg($outputImage, $tmpFile, 75);
298
-			imagedestroy($outputImage);
296
+            imageinterlace($outputImage, 1);
297
+            imagejpeg($outputImage, $tmpFile, 75);
298
+            imagedestroy($outputImage);
299 299
 
300
-			$target->putContent(file_get_contents($tmpFile, 'r'));
301
-		} else {
302
-			$target->putContent(file_get_contents($image['tmp_name'], 'r'));
303
-		}
304
-		$name = $image['name'];
300
+            $target->putContent(file_get_contents($tmpFile, 'r'));
301
+        } else {
302
+            $target->putContent(file_get_contents($image['tmp_name'], 'r'));
303
+        }
304
+        $name = $image['name'];
305 305
 
306
-		$this->themingDefaults->set($key.'Mime', $image['type']);
306
+        $this->themingDefaults->set($key.'Mime', $image['type']);
307 307
 
308
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/server.scss', 'core');
308
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/server.scss', 'core');
309 309
 
310
-		return new DataResponse(
311
-			[
312
-				'data' =>
313
-					[
314
-						'name' => $name,
315
-						'url' => $this->imageManager->getImageUrl($key),
316
-						'message' => $this->l10n->t('Saved'),
317
-						'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
318
-					],
319
-				'status' => 'success'
320
-			]
321
-		);
322
-	}
310
+        return new DataResponse(
311
+            [
312
+                'data' =>
313
+                    [
314
+                        'name' => $name,
315
+                        'url' => $this->imageManager->getImageUrl($key),
316
+                        'message' => $this->l10n->t('Saved'),
317
+                        'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
318
+                    ],
319
+                'status' => 'success'
320
+            ]
321
+        );
322
+    }
323 323
 
324
-	/**
325
-	 * Revert setting to default value
326
-	 *
327
-	 * @param string $setting setting which should be reverted
328
-	 * @return DataResponse
329
-	 * @throws NotPermittedException
330
-	 */
331
-	public function undo(string $setting): DataResponse {
332
-		$value = $this->themingDefaults->undo($setting);
333
-		// reprocess server scss for preview
334
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/server.scss', 'core');
324
+    /**
325
+     * Revert setting to default value
326
+     *
327
+     * @param string $setting setting which should be reverted
328
+     * @return DataResponse
329
+     * @throws NotPermittedException
330
+     */
331
+    public function undo(string $setting): DataResponse {
332
+        $value = $this->themingDefaults->undo($setting);
333
+        // reprocess server scss for preview
334
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/server.scss', 'core');
335 335
 
336
-		if (strpos($setting, 'Mime') !== -1) {
337
-			$imageKey = str_replace('Mime', '', $setting);
338
-			$this->imageManager->delete($imageKey);
339
-		}
336
+        if (strpos($setting, 'Mime') !== -1) {
337
+            $imageKey = str_replace('Mime', '', $setting);
338
+            $this->imageManager->delete($imageKey);
339
+        }
340 340
 
341
-		return new DataResponse(
342
-			[
343
-				'data' =>
344
-					[
345
-						'value' => $value,
346
-						'message' => $this->l10n->t('Saved'),
347
-						'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
348
-					],
349
-				'status' => 'success'
350
-			]
351
-		);
352
-	}
341
+        return new DataResponse(
342
+            [
343
+                'data' =>
344
+                    [
345
+                        'value' => $value,
346
+                        'message' => $this->l10n->t('Saved'),
347
+                        'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
348
+                    ],
349
+                'status' => 'success'
350
+            ]
351
+        );
352
+    }
353 353
 
354
-	/**
355
-	 * @PublicPage
356
-	 * @NoCSRFRequired
357
-	 *
358
-	 * @param string $key
359
-	 * @return FileDisplayResponse|NotFoundResponse
360
-	 * @throws \Exception
361
-	 */
362
-	public function getImage(string $key) {
363
-		try {
364
-			$file = $this->imageManager->getImage($key);
365
-		} catch (NotFoundException $e) {
366
-			return new NotFoundResponse();
367
-		}
354
+    /**
355
+     * @PublicPage
356
+     * @NoCSRFRequired
357
+     *
358
+     * @param string $key
359
+     * @return FileDisplayResponse|NotFoundResponse
360
+     * @throws \Exception
361
+     */
362
+    public function getImage(string $key) {
363
+        try {
364
+            $file = $this->imageManager->getImage($key);
365
+        } catch (NotFoundException $e) {
366
+            return new NotFoundResponse();
367
+        }
368 368
 
369
-		$response = new FileDisplayResponse($file);
370
-		$response->cacheFor(3600);
371
-		$expires = new \DateTime();
372
-		$expires->setTimestamp($this->timeFactory->getTime());
373
-		$expires->add(new \DateInterval('PT24H'));
374
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
375
-		$response->addHeader('Pragma', 'cache');
376
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', ''));
377
-		$response->addHeader('Content-Disposition', 'attachment; filename="' . $key . '"');
378
-		return $response;
379
-	}
369
+        $response = new FileDisplayResponse($file);
370
+        $response->cacheFor(3600);
371
+        $expires = new \DateTime();
372
+        $expires->setTimestamp($this->timeFactory->getTime());
373
+        $expires->add(new \DateInterval('PT24H'));
374
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
375
+        $response->addHeader('Pragma', 'cache');
376
+        $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', ''));
377
+        $response->addHeader('Content-Disposition', 'attachment; filename="' . $key . '"');
378
+        return $response;
379
+    }
380 380
 
381
-	/**
382
-	 * @NoCSRFRequired
383
-	 * @PublicPage
384
-	 *
385
-	 * @return FileDisplayResponse|NotFoundResponse
386
-	 * @throws NotPermittedException
387
-	 * @throws \Exception
388
-	 * @throws \OCP\App\AppPathNotFoundException
389
-	 */
390
-	public function getStylesheet() {
391
-		$appPath = $this->appManager->getAppPath('theming');
381
+    /**
382
+     * @NoCSRFRequired
383
+     * @PublicPage
384
+     *
385
+     * @return FileDisplayResponse|NotFoundResponse
386
+     * @throws NotPermittedException
387
+     * @throws \Exception
388
+     * @throws \OCP\App\AppPathNotFoundException
389
+     */
390
+    public function getStylesheet() {
391
+        $appPath = $this->appManager->getAppPath('theming');
392 392
 
393
-		/* SCSSCacher is required here
393
+        /* SCSSCacher is required here
394 394
 		 * We cannot rely on automatic caching done by \OC_Util::addStyle,
395 395
 		 * since we need to add the cacheBuster value to the url
396 396
 		 */
397
-		$cssCached = $this->scssCacher->process($appPath, 'css/theming.scss', 'theming');
398
-		if(!$cssCached) {
399
-			return new NotFoundResponse();
400
-		}
397
+        $cssCached = $this->scssCacher->process($appPath, 'css/theming.scss', 'theming');
398
+        if(!$cssCached) {
399
+            return new NotFoundResponse();
400
+        }
401 401
 
402
-		try {
403
-			$cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css');
404
-			$response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
405
-			$response->cacheFor(86400);
406
-			$expires = new \DateTime();
407
-			$expires->setTimestamp($this->timeFactory->getTime());
408
-			$expires->add(new \DateInterval('PT24H'));
409
-			$response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
410
-			$response->addHeader('Pragma', 'cache');
411
-			return $response;
412
-		} catch (NotFoundException $e) {
413
-			return new NotFoundResponse();
414
-		}
415
-	}
402
+        try {
403
+            $cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css');
404
+            $response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
405
+            $response->cacheFor(86400);
406
+            $expires = new \DateTime();
407
+            $expires->setTimestamp($this->timeFactory->getTime());
408
+            $expires->add(new \DateInterval('PT24H'));
409
+            $response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
410
+            $response->addHeader('Pragma', 'cache');
411
+            return $response;
412
+        } catch (NotFoundException $e) {
413
+            return new NotFoundResponse();
414
+        }
415
+    }
416 416
 
417
-	/**
418
-	 * @NoCSRFRequired
419
-	 * @PublicPage
420
-	 *
421
-	 * @return DataDownloadResponse
422
-	 */
423
-	public function getJavascript() {
424
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
425
-		$responseJS = '(function() {
417
+    /**
418
+     * @NoCSRFRequired
419
+     * @PublicPage
420
+     *
421
+     * @return DataDownloadResponse
422
+     */
423
+    public function getJavascript() {
424
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
425
+        $responseJS = '(function() {
426 426
 	OCA.Theming = {
427 427
 		name: ' . json_encode($this->themingDefaults->getName()) . ',
428 428
 		url: ' . json_encode($this->themingDefaults->getBaseUrl()) . ',
@@ -434,45 +434,45 @@  discard block
 block discarded – undo
434 434
 		cacheBuster: ' . json_encode($cacheBusterValue) . '
435 435
 	};
436 436
 })();';
437
-		$response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
438
-		$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
439
-		$response->addHeader('Pragma', 'cache');
440
-		$response->cacheFor(3600);
441
-		return $response;
442
-	}
437
+        $response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
438
+        $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
439
+        $response->addHeader('Pragma', 'cache');
440
+        $response->cacheFor(3600);
441
+        return $response;
442
+    }
443 443
 
444
-	/**
445
-	 * @NoCSRFRequired
446
-	 * @PublicPage
447
-	 *
448
-	 * @return Http\JSONResponse
449
-	 */
450
-	public function getManifest($app) {
451
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
452
-		$responseJS = [
453
-			'name' => $this->themingDefaults->getName(),
454
-			'start_url' => $this->urlGenerator->getBaseUrl(),
455
-			'icons' =>
456
-				[
457
-					[
458
-						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
459
-								['app' => $app]) . '?v=' . $cacheBusterValue,
460
-						'type'=> 'image/png',
461
-						'sizes'=> '128x128'
462
-					],
463
-					[
464
-						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
465
-								['app' => $app]) . '?v=' . $cacheBusterValue,
466
-						'type' => 'image/svg+xml',
467
-						'sizes' => '16x16'
468
-					]
469
-				],
470
-			'display' => 'standalone'
471
-		];
472
-		$response = new Http\JSONResponse($responseJS);
473
-		$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
474
-		$response->addHeader('Pragma', 'cache');
475
-		$response->cacheFor(3600);
476
-		return $response;
477
-	}
444
+    /**
445
+     * @NoCSRFRequired
446
+     * @PublicPage
447
+     *
448
+     * @return Http\JSONResponse
449
+     */
450
+    public function getManifest($app) {
451
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
452
+        $responseJS = [
453
+            'name' => $this->themingDefaults->getName(),
454
+            'start_url' => $this->urlGenerator->getBaseUrl(),
455
+            'icons' =>
456
+                [
457
+                    [
458
+                        'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
459
+                                ['app' => $app]) . '?v=' . $cacheBusterValue,
460
+                        'type'=> 'image/png',
461
+                        'sizes'=> '128x128'
462
+                    ],
463
+                    [
464
+                        'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
465
+                                ['app' => $app]) . '?v=' . $cacheBusterValue,
466
+                        'type' => 'image/svg+xml',
467
+                        'sizes' => '16x16'
468
+                    ]
469
+                ],
470
+            'display' => 'standalone'
471
+        ];
472
+        $response = new Http\JSONResponse($responseJS);
473
+        $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
474
+        $response->addHeader('Pragma', 'cache');
475
+        $response->cacheFor(3600);
476
+        return $response;
477
+    }
478 478
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 		$expires->add(new \DateInterval('PT24H'));
374 374
 		$response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
375 375
 		$response->addHeader('Pragma', 'cache');
376
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key . 'Mime', ''));
377
-		$response->addHeader('Content-Disposition', 'attachment; filename="' . $key . '"');
376
+		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, $key.'Mime', ''));
377
+		$response->addHeader('Content-Disposition', 'attachment; filename="'.$key.'"');
378 378
 		return $response;
379 379
 	}
380 380
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 		 * since we need to add the cacheBuster value to the url
396 396
 		 */
397 397
 		$cssCached = $this->scssCacher->process($appPath, 'css/theming.scss', 'theming');
398
-		if(!$cssCached) {
398
+		if (!$cssCached) {
399 399
 			return new NotFoundResponse();
400 400
 		}
401 401
 
@@ -424,14 +424,14 @@  discard block
 block discarded – undo
424 424
 		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
425 425
 		$responseJS = '(function() {
426 426
 	OCA.Theming = {
427
-		name: ' . json_encode($this->themingDefaults->getName()) . ',
428
-		url: ' . json_encode($this->themingDefaults->getBaseUrl()) . ',
429
-		slogan: ' . json_encode($this->themingDefaults->getSlogan()) . ',
430
-		color: ' . json_encode($this->themingDefaults->getColorPrimary()) . ',
431
-		imprintUrl: ' . json_encode($this->themingDefaults->getImprintUrl()) . ',
432
-		privacyUrl: ' . json_encode($this->themingDefaults->getPrivacyUrl()) . ',
433
-		inverted: ' . json_encode($this->util->invertTextColor($this->themingDefaults->getColorPrimary())) . ',
434
-		cacheBuster: ' . json_encode($cacheBusterValue) . '
427
+		name: ' . json_encode($this->themingDefaults->getName()).',
428
+		url: ' . json_encode($this->themingDefaults->getBaseUrl()).',
429
+		slogan: ' . json_encode($this->themingDefaults->getSlogan()).',
430
+		color: ' . json_encode($this->themingDefaults->getColorPrimary()).',
431
+		imprintUrl: ' . json_encode($this->themingDefaults->getImprintUrl()).',
432
+		privacyUrl: ' . json_encode($this->themingDefaults->getPrivacyUrl()).',
433
+		inverted: ' . json_encode($this->util->invertTextColor($this->themingDefaults->getColorPrimary())).',
434
+		cacheBuster: ' . json_encode($cacheBusterValue).'
435 435
 	};
436 436
 })();';
437 437
 		$response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
@@ -456,13 +456,13 @@  discard block
 block discarded – undo
456 456
 				[
457 457
 					[
458 458
 						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
459
-								['app' => $app]) . '?v=' . $cacheBusterValue,
459
+								['app' => $app]).'?v='.$cacheBusterValue,
460 460
 						'type'=> 'image/png',
461 461
 						'sizes'=> '128x128'
462 462
 					],
463 463
 					[
464 464
 						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
465
-								['app' => $app]) . '?v=' . $cacheBusterValue,
465
+								['app' => $app]).'?v='.$cacheBusterValue,
466 466
 						'type' => 'image/svg+xml',
467 467
 						'sizes' => '16x16'
468 468
 					]
Please login to merge, or discard this patch.