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