Completed
Pull Request — master (#7953)
by Julius
25:05
created
apps/theming/lib/Controller/ThemingController.php 1 patch
Indentation   +396 added lines, -396 removed lines patch added patch discarded remove patch
@@ -62,389 +62,389 @@  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;
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 83
 
84
-	/**
85
-	 * ThemingController constructor.
86
-	 *
87
-	 * @param string $appName
88
-	 * @param IRequest $request
89
-	 * @param IConfig $config
90
-	 * @param ThemingDefaults $themingDefaults
91
-	 * @param Util $util
92
-	 * @param ITimeFactory $timeFactory
93
-	 * @param IL10N $l
94
-	 * @param ITempManager $tempManager
95
-	 * @param IAppData $appData
96
-	 * @param SCSSCacher $scssCacher
97
-	 * @param IURLGenerator $urlGenerator
98
-	 */
99
-	public function __construct(
100
-		$appName,
101
-		IRequest $request,
102
-		IConfig $config,
103
-		ThemingDefaults $themingDefaults,
104
-		Util $util,
105
-		ITimeFactory $timeFactory,
106
-		IL10N $l,
107
-		ITempManager $tempManager,
108
-		IAppData $appData,
109
-		SCSSCacher $scssCacher,
110
-		IURLGenerator $urlGenerator
111
-	) {
112
-		parent::__construct($appName, $request);
84
+    /**
85
+     * ThemingController constructor.
86
+     *
87
+     * @param string $appName
88
+     * @param IRequest $request
89
+     * @param IConfig $config
90
+     * @param ThemingDefaults $themingDefaults
91
+     * @param Util $util
92
+     * @param ITimeFactory $timeFactory
93
+     * @param IL10N $l
94
+     * @param ITempManager $tempManager
95
+     * @param IAppData $appData
96
+     * @param SCSSCacher $scssCacher
97
+     * @param IURLGenerator $urlGenerator
98
+     */
99
+    public function __construct(
100
+        $appName,
101
+        IRequest $request,
102
+        IConfig $config,
103
+        ThemingDefaults $themingDefaults,
104
+        Util $util,
105
+        ITimeFactory $timeFactory,
106
+        IL10N $l,
107
+        ITempManager $tempManager,
108
+        IAppData $appData,
109
+        SCSSCacher $scssCacher,
110
+        IURLGenerator $urlGenerator
111
+    ) {
112
+        parent::__construct($appName, $request);
113 113
 
114
-		$this->themingDefaults = $themingDefaults;
115
-		$this->util = $util;
116
-		$this->timeFactory = $timeFactory;
117
-		$this->l10n = $l;
118
-		$this->config = $config;
119
-		$this->tempManager = $tempManager;
120
-		$this->appData = $appData;
121
-		$this->scssCacher = $scssCacher;
122
-		$this->urlGenerator = $urlGenerator;
123
-	}
114
+        $this->themingDefaults = $themingDefaults;
115
+        $this->util = $util;
116
+        $this->timeFactory = $timeFactory;
117
+        $this->l10n = $l;
118
+        $this->config = $config;
119
+        $this->tempManager = $tempManager;
120
+        $this->appData = $appData;
121
+        $this->scssCacher = $scssCacher;
122
+        $this->urlGenerator = $urlGenerator;
123
+    }
124 124
 
125
-	/**
126
-	 * @param string $setting
127
-	 * @param string $value
128
-	 * @return DataResponse
129
-	 * @internal param string $color
130
-	 */
131
-	public function updateStylesheet($setting, $value) {
132
-		$value = trim($value);
133
-		switch ($setting) {
134
-			case 'name':
135
-				if (strlen($value) > 250) {
136
-					return new DataResponse([
137
-						'data' => [
138
-							'message' => $this->l10n->t('The given name is too long'),
139
-						],
140
-						'status' => 'error'
141
-					]);
142
-				}
143
-				break;
144
-			case 'url':
145
-				if (strlen($value) > 500) {
146
-					return new DataResponse([
147
-						'data' => [
148
-							'message' => $this->l10n->t('The given web address is too long'),
149
-						],
150
-						'status' => 'error'
151
-					]);
152
-				}
153
-				break;
154
-			case 'slogan':
155
-				if (strlen($value) > 500) {
156
-					return new DataResponse([
157
-						'data' => [
158
-							'message' => $this->l10n->t('The given slogan is too long'),
159
-						],
160
-						'status' => 'error'
161
-					]);
162
-				}
163
-				break;
164
-			case 'color':
165
-				if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
166
-					return new DataResponse([
167
-						'data' => [
168
-							'message' => $this->l10n->t('The given color is invalid'),
169
-						],
170
-						'status' => 'error'
171
-					]);
172
-				}
173
-				break;
174
-		}
125
+    /**
126
+     * @param string $setting
127
+     * @param string $value
128
+     * @return DataResponse
129
+     * @internal param string $color
130
+     */
131
+    public function updateStylesheet($setting, $value) {
132
+        $value = trim($value);
133
+        switch ($setting) {
134
+            case 'name':
135
+                if (strlen($value) > 250) {
136
+                    return new DataResponse([
137
+                        'data' => [
138
+                            'message' => $this->l10n->t('The given name is too long'),
139
+                        ],
140
+                        'status' => 'error'
141
+                    ]);
142
+                }
143
+                break;
144
+            case 'url':
145
+                if (strlen($value) > 500) {
146
+                    return new DataResponse([
147
+                        'data' => [
148
+                            'message' => $this->l10n->t('The given web address is too long'),
149
+                        ],
150
+                        'status' => 'error'
151
+                    ]);
152
+                }
153
+                break;
154
+            case 'slogan':
155
+                if (strlen($value) > 500) {
156
+                    return new DataResponse([
157
+                        'data' => [
158
+                            'message' => $this->l10n->t('The given slogan is too long'),
159
+                        ],
160
+                        'status' => 'error'
161
+                    ]);
162
+                }
163
+                break;
164
+            case 'color':
165
+                if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
166
+                    return new DataResponse([
167
+                        'data' => [
168
+                            'message' => $this->l10n->t('The given color is invalid'),
169
+                        ],
170
+                        'status' => 'error'
171
+                    ]);
172
+                }
173
+                break;
174
+        }
175 175
 
176
-		$this->themingDefaults->set($setting, $value);
176
+        $this->themingDefaults->set($setting, $value);
177 177
 
178
-		// reprocess server scss for preview
179
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/server.scss', 'core');
178
+        // reprocess server scss for preview
179
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/server.scss', 'core');
180 180
 
181
-		return new DataResponse(
182
-			[
183
-				'data' =>
184
-					[
185
-						'message' => $this->l10n->t('Saved'),
186
-						'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
187
-					],
188
-				'status' => 'success'
189
-			]
190
-		);
191
-	}
181
+        return new DataResponse(
182
+            [
183
+                'data' =>
184
+                    [
185
+                        'message' => $this->l10n->t('Saved'),
186
+                        'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
187
+                    ],
188
+                'status' => 'success'
189
+            ]
190
+        );
191
+    }
192 192
 
193
-	/**
194
-	 * Update the logos and background image
195
-	 *
196
-	 * @return DataResponse
197
-	 */
198
-	public function updateLogo() {
199
-		$backgroundColor = $this->request->getParam('backgroundColor', false);
200
-		if($backgroundColor) {
201
-			$this->themingDefaults->set('backgroundMime', 'backgroundColor');
202
-			return new DataResponse(
203
-				[
204
-					'data' =>
205
-						[
206
-							'name' => 'backgroundColor',
207
-							'message' => $this->l10n->t('Saved')
208
-						],
209
-					'status' => 'success'
210
-				]
211
-			);
212
-		}
213
-		$newLogo = $this->request->getUploadedFile('uploadlogo');
214
-		$newBackgroundLogo = $this->request->getUploadedFile('upload-login-background');
215
-		$error = null;
216
-		$phpFileUploadErrors = [
217
-			UPLOAD_ERR_OK => $this->l10n->t('There is no error, the file uploaded with success'),
218
-			UPLOAD_ERR_INI_SIZE => $this->l10n->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
219
-			UPLOAD_ERR_FORM_SIZE => $this->l10n->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
220
-			UPLOAD_ERR_PARTIAL => $this->l10n->t('The uploaded file was only partially uploaded'),
221
-			UPLOAD_ERR_NO_FILE => $this->l10n->t('No file was uploaded'),
222
-			UPLOAD_ERR_NO_TMP_DIR => $this->l10n->t('Missing a temporary folder'),
223
-			UPLOAD_ERR_CANT_WRITE => $this->l10n->t('Failed to write file to disk.'),
224
-			UPLOAD_ERR_EXTENSION => $this->l10n->t('A PHP extension stopped the file upload.'),
225
-		];
226
-		if (empty($newLogo) && empty($newBackgroundLogo)) {
227
-			$error = $this->l10n->t('No file uploaded');
228
-		}
229
-		if (!empty($newLogo) && array_key_exists('error', $newLogo) && $newLogo['error'] !== UPLOAD_ERR_OK) {
230
-			$error = $phpFileUploadErrors[$newLogo['error']];
231
-		}
232
-		if (!empty($newBackgroundLogo) && array_key_exists('error', $newBackgroundLogo) && $newBackgroundLogo['error'] !== UPLOAD_ERR_OK) {
233
-			$error = $phpFileUploadErrors[$newBackgroundLogo['error']];
234
-		}
193
+    /**
194
+     * Update the logos and background image
195
+     *
196
+     * @return DataResponse
197
+     */
198
+    public function updateLogo() {
199
+        $backgroundColor = $this->request->getParam('backgroundColor', false);
200
+        if($backgroundColor) {
201
+            $this->themingDefaults->set('backgroundMime', 'backgroundColor');
202
+            return new DataResponse(
203
+                [
204
+                    'data' =>
205
+                        [
206
+                            'name' => 'backgroundColor',
207
+                            'message' => $this->l10n->t('Saved')
208
+                        ],
209
+                    'status' => 'success'
210
+                ]
211
+            );
212
+        }
213
+        $newLogo = $this->request->getUploadedFile('uploadlogo');
214
+        $newBackgroundLogo = $this->request->getUploadedFile('upload-login-background');
215
+        $error = null;
216
+        $phpFileUploadErrors = [
217
+            UPLOAD_ERR_OK => $this->l10n->t('There is no error, the file uploaded with success'),
218
+            UPLOAD_ERR_INI_SIZE => $this->l10n->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
219
+            UPLOAD_ERR_FORM_SIZE => $this->l10n->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
220
+            UPLOAD_ERR_PARTIAL => $this->l10n->t('The uploaded file was only partially uploaded'),
221
+            UPLOAD_ERR_NO_FILE => $this->l10n->t('No file was uploaded'),
222
+            UPLOAD_ERR_NO_TMP_DIR => $this->l10n->t('Missing a temporary folder'),
223
+            UPLOAD_ERR_CANT_WRITE => $this->l10n->t('Failed to write file to disk.'),
224
+            UPLOAD_ERR_EXTENSION => $this->l10n->t('A PHP extension stopped the file upload.'),
225
+        ];
226
+        if (empty($newLogo) && empty($newBackgroundLogo)) {
227
+            $error = $this->l10n->t('No file uploaded');
228
+        }
229
+        if (!empty($newLogo) && array_key_exists('error', $newLogo) && $newLogo['error'] !== UPLOAD_ERR_OK) {
230
+            $error = $phpFileUploadErrors[$newLogo['error']];
231
+        }
232
+        if (!empty($newBackgroundLogo) && array_key_exists('error', $newBackgroundLogo) && $newBackgroundLogo['error'] !== UPLOAD_ERR_OK) {
233
+            $error = $phpFileUploadErrors[$newBackgroundLogo['error']];
234
+        }
235 235
 
236
-		if ($error !== null) {
237
-			return new DataResponse(
238
-				[
239
-					'data' => [
240
-						'message' => $error
241
-					],
242
-					'status' => 'failure',
243
-				],
244
-				Http::STATUS_UNPROCESSABLE_ENTITY
245
-			);
246
-		}
236
+        if ($error !== null) {
237
+            return new DataResponse(
238
+                [
239
+                    'data' => [
240
+                        'message' => $error
241
+                    ],
242
+                    'status' => 'failure',
243
+                ],
244
+                Http::STATUS_UNPROCESSABLE_ENTITY
245
+            );
246
+        }
247 247
 
248
-		$name = '';
249
-		try {
250
-			$folder = $this->appData->getFolder('images');
251
-		} catch (NotFoundException $e) {
252
-			$folder = $this->appData->newFolder('images');
253
-		}
248
+        $name = '';
249
+        try {
250
+            $folder = $this->appData->getFolder('images');
251
+        } catch (NotFoundException $e) {
252
+            $folder = $this->appData->newFolder('images');
253
+        }
254 254
 
255
-		if (!empty($newLogo)) {
256
-			$target = $folder->newFile('logo');
257
-			$supportedFormats = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml', 'text/svg'];
258
-			if (!in_array($newLogo['type'], $supportedFormats)) {
259
-				return new DataResponse(
260
-					[
261
-						'data' => [
262
-							'message' => $this->l10n->t('Unsupported image type'),
263
-						],
264
-						'status' => 'failure',
265
-					],
266
-					Http::STATUS_UNPROCESSABLE_ENTITY
267
-				);
268
-			}
269
-			$target->putContent(file_get_contents($newLogo['tmp_name'], 'r'));
270
-			$this->themingDefaults->set('logoMime', $newLogo['type']);
271
-			$name = $newLogo['name'];
272
-		}
273
-		if (!empty($newBackgroundLogo)) {
274
-			$target = $folder->newFile('background');
275
-			$image = @imagecreatefromstring(file_get_contents($newBackgroundLogo['tmp_name'], 'r'));
276
-			if ($image === false) {
277
-				return new DataResponse(
278
-					[
279
-						'data' => [
280
-							'message' => $this->l10n->t('Unsupported image type'),
281
-						],
282
-						'status' => 'failure',
283
-					],
284
-					Http::STATUS_UNPROCESSABLE_ENTITY
285
-				);
286
-			}
255
+        if (!empty($newLogo)) {
256
+            $target = $folder->newFile('logo');
257
+            $supportedFormats = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml', 'text/svg'];
258
+            if (!in_array($newLogo['type'], $supportedFormats)) {
259
+                return new DataResponse(
260
+                    [
261
+                        'data' => [
262
+                            'message' => $this->l10n->t('Unsupported image type'),
263
+                        ],
264
+                        'status' => 'failure',
265
+                    ],
266
+                    Http::STATUS_UNPROCESSABLE_ENTITY
267
+                );
268
+            }
269
+            $target->putContent(file_get_contents($newLogo['tmp_name'], 'r'));
270
+            $this->themingDefaults->set('logoMime', $newLogo['type']);
271
+            $name = $newLogo['name'];
272
+        }
273
+        if (!empty($newBackgroundLogo)) {
274
+            $target = $folder->newFile('background');
275
+            $image = @imagecreatefromstring(file_get_contents($newBackgroundLogo['tmp_name'], 'r'));
276
+            if ($image === false) {
277
+                return new DataResponse(
278
+                    [
279
+                        'data' => [
280
+                            'message' => $this->l10n->t('Unsupported image type'),
281
+                        ],
282
+                        'status' => 'failure',
283
+                    ],
284
+                    Http::STATUS_UNPROCESSABLE_ENTITY
285
+                );
286
+            }
287 287
 
288
-			// Optimize the image since some people may upload images that will be
289
-			// either to big or are not progressive rendering.
290
-			$tmpFile = $this->tempManager->getTemporaryFile();
291
-			$newWidth = imagesx($image) < 4096 ? imagesx($image) : 4096;
292
-			$newHeight = imagesy($image) / (imagesx($image) / $newWidth);
293
-			$image = imagescale($image, $newWidth, $newHeight);
288
+            // Optimize the image since some people may upload images that will be
289
+            // either to big or are not progressive rendering.
290
+            $tmpFile = $this->tempManager->getTemporaryFile();
291
+            $newWidth = imagesx($image) < 4096 ? imagesx($image) : 4096;
292
+            $newHeight = imagesy($image) / (imagesx($image) / $newWidth);
293
+            $image = imagescale($image, $newWidth, $newHeight);
294 294
 
295
-			imageinterlace($image, 1);
296
-			imagejpeg($image, $tmpFile, 75);
297
-			imagedestroy($image);
295
+            imageinterlace($image, 1);
296
+            imagejpeg($image, $tmpFile, 75);
297
+            imagedestroy($image);
298 298
 
299
-			$target->putContent(file_get_contents($tmpFile, 'r'));
300
-			$this->themingDefaults->set('backgroundMime', $newBackgroundLogo['type']);
301
-			$name = $newBackgroundLogo['name'];
302
-		}
299
+            $target->putContent(file_get_contents($tmpFile, 'r'));
300
+            $this->themingDefaults->set('backgroundMime', $newBackgroundLogo['type']);
301
+            $name = $newBackgroundLogo['name'];
302
+        }
303 303
 
304
-		return new DataResponse(
305
-			[
306
-				'data' =>
307
-					[
308
-						'name' => $name,
309
-						'message' => $this->l10n->t('Saved')
310
-					],
311
-				'status' => 'success'
312
-			]
313
-		);
314
-	}
304
+        return new DataResponse(
305
+            [
306
+                'data' =>
307
+                    [
308
+                        'name' => $name,
309
+                        'message' => $this->l10n->t('Saved')
310
+                    ],
311
+                'status' => 'success'
312
+            ]
313
+        );
314
+    }
315 315
 
316
-	/**
317
-	 * Revert setting to default value
318
-	 *
319
-	 * @param string $setting setting which should be reverted
320
-	 * @return DataResponse
321
-	 */
322
-	public function undo($setting) {
323
-		$value = $this->themingDefaults->undo($setting);
324
-		// reprocess server scss for preview
325
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/server.scss', 'core');
316
+    /**
317
+     * Revert setting to default value
318
+     *
319
+     * @param string $setting setting which should be reverted
320
+     * @return DataResponse
321
+     */
322
+    public function undo($setting) {
323
+        $value = $this->themingDefaults->undo($setting);
324
+        // reprocess server scss for preview
325
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/server.scss', 'core');
326 326
 
327
-		if($setting === 'logoMime') {
328
-			try {
329
-				$file = $this->appData->getFolder('images')->getFile('logo');
330
-				$file->delete();
331
-			} catch (NotFoundException $e) {
332
-			} catch (NotPermittedException $e) {
333
-			}
334
-		}
335
-		if($setting === 'backgroundMime') {
336
-			try {
337
-				$file = $this->appData->getFolder('images')->getFile('background');
338
-				$file->delete();
339
-			} catch (NotFoundException $e) {
340
-			} catch (NotPermittedException $e) {
341
-			}
342
-		}
327
+        if($setting === 'logoMime') {
328
+            try {
329
+                $file = $this->appData->getFolder('images')->getFile('logo');
330
+                $file->delete();
331
+            } catch (NotFoundException $e) {
332
+            } catch (NotPermittedException $e) {
333
+            }
334
+        }
335
+        if($setting === 'backgroundMime') {
336
+            try {
337
+                $file = $this->appData->getFolder('images')->getFile('background');
338
+                $file->delete();
339
+            } catch (NotFoundException $e) {
340
+            } catch (NotPermittedException $e) {
341
+            }
342
+        }
343 343
 
344
-		return new DataResponse(
345
-			[
346
-				'data' =>
347
-					[
348
-						'value' => $value,
349
-						'message' => $this->l10n->t('Saved'),
350
-						'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
351
-					],
352
-				'status' => 'success'
353
-			]
354
-		);
355
-	}
344
+        return new DataResponse(
345
+            [
346
+                'data' =>
347
+                    [
348
+                        'value' => $value,
349
+                        'message' => $this->l10n->t('Saved'),
350
+                        'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
351
+                    ],
352
+                'status' => 'success'
353
+            ]
354
+        );
355
+    }
356 356
 
357
-	/**
358
-	 * @PublicPage
359
-	 * @NoCSRFRequired
360
-	 *
361
-	 * @return FileDisplayResponse|NotFoundResponse
362
-	 */
363
-	public function getLogo() {
364
-		try {
365
-			/** @var File $file */
366
-			$file = $this->appData->getFolder('images')->getFile('logo');
367
-		} catch (NotFoundException $e) {
368
-			return new NotFoundResponse();
369
-		}
357
+    /**
358
+     * @PublicPage
359
+     * @NoCSRFRequired
360
+     *
361
+     * @return FileDisplayResponse|NotFoundResponse
362
+     */
363
+    public function getLogo() {
364
+        try {
365
+            /** @var File $file */
366
+            $file = $this->appData->getFolder('images')->getFile('logo');
367
+        } catch (NotFoundException $e) {
368
+            return new NotFoundResponse();
369
+        }
370 370
 
371
-		$response = new FileDisplayResponse($file);
372
-		$response->cacheFor(3600);
373
-		$expires = new \DateTime();
374
-		$expires->setTimestamp($this->timeFactory->getTime());
375
-		$expires->add(new \DateInterval('PT24H'));
376
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
377
-		$response->addHeader('Pragma', 'cache');
378
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', ''));
379
-		return $response;
380
-	}
371
+        $response = new FileDisplayResponse($file);
372
+        $response->cacheFor(3600);
373
+        $expires = new \DateTime();
374
+        $expires->setTimestamp($this->timeFactory->getTime());
375
+        $expires->add(new \DateInterval('PT24H'));
376
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
377
+        $response->addHeader('Pragma', 'cache');
378
+        $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', ''));
379
+        return $response;
380
+    }
381 381
 
382
-	/**
383
-	 * @PublicPage
384
-	 * @NoCSRFRequired
385
-	 *
386
-	 * @return FileDisplayResponse|NotFoundResponse
387
-	 */
388
-	public function getLoginBackground() {
389
-		try {
390
-			/** @var File $file */
391
-			$file = $this->appData->getFolder('images')->getFile('background');
392
-		} catch (NotFoundException $e) {
393
-			return new NotFoundResponse();
394
-		}
382
+    /**
383
+     * @PublicPage
384
+     * @NoCSRFRequired
385
+     *
386
+     * @return FileDisplayResponse|NotFoundResponse
387
+     */
388
+    public function getLoginBackground() {
389
+        try {
390
+            /** @var File $file */
391
+            $file = $this->appData->getFolder('images')->getFile('background');
392
+        } catch (NotFoundException $e) {
393
+            return new NotFoundResponse();
394
+        }
395 395
 
396
-		$response = new FileDisplayResponse($file);
397
-		$response->cacheFor(3600);
398
-		$expires = new \DateTime();
399
-		$expires->setTimestamp($this->timeFactory->getTime());
400
-		$expires->add(new \DateInterval('PT24H'));
401
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
402
-		$response->addHeader('Pragma', 'cache');
403
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', ''));
404
-		return $response;
405
-	}
396
+        $response = new FileDisplayResponse($file);
397
+        $response->cacheFor(3600);
398
+        $expires = new \DateTime();
399
+        $expires->setTimestamp($this->timeFactory->getTime());
400
+        $expires->add(new \DateInterval('PT24H'));
401
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
402
+        $response->addHeader('Pragma', 'cache');
403
+        $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', ''));
404
+        return $response;
405
+    }
406 406
 
407
-	/**
408
-	 * @NoCSRFRequired
409
-	 * @PublicPage
410
-	 *
411
-	 * @return FileDisplayResponse|NotFoundResponse
412
-	 */
413
-	public function getStylesheet() {
414
-		$appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1);
415
-		/* SCSSCacher is required here
407
+    /**
408
+     * @NoCSRFRequired
409
+     * @PublicPage
410
+     *
411
+     * @return FileDisplayResponse|NotFoundResponse
412
+     */
413
+    public function getStylesheet() {
414
+        $appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1);
415
+        /* SCSSCacher is required here
416 416
 		 * We cannot rely on automatic caching done by \OC_Util::addStyle,
417 417
 		 * since we need to add the cacheBuster value to the url
418 418
 		 */
419
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming');
420
-		if(!$cssCached) {
421
-			return new NotFoundResponse();
422
-		}
419
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming');
420
+        if(!$cssCached) {
421
+            return new NotFoundResponse();
422
+        }
423 423
 
424
-		try {
425
-			$cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css');
426
-			$response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
427
-			$response->cacheFor(86400);
428
-			$expires = new \DateTime();
429
-			$expires->setTimestamp($this->timeFactory->getTime());
430
-			$expires->add(new \DateInterval('PT24H'));
431
-			$response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
432
-			$response->addHeader('Pragma', 'cache');
433
-			return $response;
434
-		} catch (NotFoundException $e) {
435
-			return new NotFoundResponse();
436
-		}
437
-	}
424
+        try {
425
+            $cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css');
426
+            $response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
427
+            $response->cacheFor(86400);
428
+            $expires = new \DateTime();
429
+            $expires->setTimestamp($this->timeFactory->getTime());
430
+            $expires->add(new \DateInterval('PT24H'));
431
+            $response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
432
+            $response->addHeader('Pragma', 'cache');
433
+            return $response;
434
+        } catch (NotFoundException $e) {
435
+            return new NotFoundResponse();
436
+        }
437
+    }
438 438
 
439
-	/**
440
-	 * @NoCSRFRequired
441
-	 * @PublicPage
442
-	 *
443
-	 * @return DataDownloadResponse
444
-	 */
445
-	public function getJavascript() {
446
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
447
-		$responseJS = '(function() {
439
+    /**
440
+     * @NoCSRFRequired
441
+     * @PublicPage
442
+     *
443
+     * @return DataDownloadResponse
444
+     */
445
+    public function getJavascript() {
446
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
447
+        $responseJS = '(function() {
448 448
 	OCA.Theming = {
449 449
 		name: ' . json_encode($this->themingDefaults->getName()) . ',
450 450
 		url: ' . json_encode($this->themingDefaults->getBaseUrl()) . ',
@@ -454,45 +454,45 @@  discard block
 block discarded – undo
454 454
 		cacheBuster: ' . json_encode($cacheBusterValue) . '
455 455
 	};
456 456
 })();';
457
-		$response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
458
-		$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
459
-		$response->addHeader('Pragma', 'cache');
460
-		$response->cacheFor(3600);
461
-		return $response;
462
-	}
457
+        $response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
458
+        $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
459
+        $response->addHeader('Pragma', 'cache');
460
+        $response->cacheFor(3600);
461
+        return $response;
462
+    }
463 463
 
464
-	/**
465
-	 * @NoCSRFRequired
466
-	 * @PublicPage
467
-	 *
468
-	 * @return Http\JSONResponse
469
-	 */
470
-	public function getManifest($app) {
471
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
472
-		$responseJS = [
473
-			'name' => $this->themingDefaults->getName(),
474
-			'start_url' => $this->urlGenerator->getBaseUrl(),
475
-			'icons' =>
476
-				[
477
-					[
478
-						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
479
-								['app' => $app]) . '?v=' . $cacheBusterValue,
480
-						'type'=> 'image/png',
481
-						'sizes'=> '128x128'
482
-					],
483
-					[
484
-						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
485
-								['app' => $app]) . '?v=' . $cacheBusterValue,
486
-						'type' => 'image/svg+xml',
487
-						'sizes' => '16x16'
488
-					]
489
-				],
490
-			'display' => 'standalone'
491
-		];
492
-		$response = new Http\JSONResponse($responseJS);
493
-		$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
494
-		$response->addHeader('Pragma', 'cache');
495
-		$response->cacheFor(3600);
496
-		return $response;
497
-	}
464
+    /**
465
+     * @NoCSRFRequired
466
+     * @PublicPage
467
+     *
468
+     * @return Http\JSONResponse
469
+     */
470
+    public function getManifest($app) {
471
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
472
+        $responseJS = [
473
+            'name' => $this->themingDefaults->getName(),
474
+            'start_url' => $this->urlGenerator->getBaseUrl(),
475
+            'icons' =>
476
+                [
477
+                    [
478
+                        'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
479
+                                ['app' => $app]) . '?v=' . $cacheBusterValue,
480
+                        'type'=> 'image/png',
481
+                        'sizes'=> '128x128'
482
+                    ],
483
+                    [
484
+                        'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
485
+                                ['app' => $app]) . '?v=' . $cacheBusterValue,
486
+                        'type' => 'image/svg+xml',
487
+                        'sizes' => '16x16'
488
+                    ]
489
+                ],
490
+            'display' => 'standalone'
491
+        ];
492
+        $response = new Http\JSONResponse($responseJS);
493
+        $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
494
+        $response->addHeader('Pragma', 'cache');
495
+        $response->cacheFor(3600);
496
+        return $response;
497
+    }
498 498
 }
Please login to merge, or discard this patch.