Completed
Pull Request — master (#6585)
by Julius
12:06
created
apps/theming/lib/Controller/ThemingController.php 1 patch
Indentation   +399 added lines, -399 removed lines patch added patch discarded remove patch
@@ -57,391 +57,391 @@  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 = [
212
-			UPLOAD_ERR_OK => $this->l10n->t('There is no error, the file uploaded with success'),
213
-			UPLOAD_ERR_INI_SIZE => $this->l10n->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
214
-			UPLOAD_ERR_FORM_SIZE => $this->l10n->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
215
-			UPLOAD_ERR_PARTIAL => $this->l10n->t('The uploaded file was only partially uploaded'),
216
-			UPLOAD_ERR_NO_FILE => $this->l10n->t('No file was uploaded'),
217
-			UPLOAD_ERR_NO_TMP_DIR => $this->l10n->t('Missing a temporary folder'),
218
-			UPLOAD_ERR_CANT_WRITE => $this->l10n->t('Failed to write file to disk.'),
219
-			UPLOAD_ERR_EXTENSION => $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 = [
212
+            UPLOAD_ERR_OK => $this->l10n->t('There is no error, the file uploaded with success'),
213
+            UPLOAD_ERR_INI_SIZE => $this->l10n->t('The uploaded file exceeds the upload_max_filesize directive in php.ini'),
214
+            UPLOAD_ERR_FORM_SIZE => $this->l10n->t('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'),
215
+            UPLOAD_ERR_PARTIAL => $this->l10n->t('The uploaded file was only partially uploaded'),
216
+            UPLOAD_ERR_NO_FILE => $this->l10n->t('No file was uploaded'),
217
+            UPLOAD_ERR_NO_TMP_DIR => $this->l10n->t('Missing a temporary folder'),
218
+            UPLOAD_ERR_CANT_WRITE => $this->l10n->t('Failed to write file to disk.'),
219
+            UPLOAD_ERR_EXTENSION => $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
-					'status' => 'failure',
238
-				],
239
-				Http::STATUS_UNPROCESSABLE_ENTITY
240
-			);
241
-		}
231
+        if ($error !== null) {
232
+            return new DataResponse(
233
+                [
234
+                    'data' => [
235
+                        'message' => $error
236
+                    ],
237
+                    'status' => 'failure',
238
+                ],
239
+                Http::STATUS_UNPROCESSABLE_ENTITY
240
+            );
241
+        }
242 242
 
243
-		$name = '';
244
-		try {
245
-			$folder = $this->appData->getFolder('images');
246
-		} catch (NotFoundException $e) {
247
-			$folder = $this->appData->newFolder('images');
248
-		}
243
+        $name = '';
244
+        try {
245
+            $folder = $this->appData->getFolder('images');
246
+        } catch (NotFoundException $e) {
247
+            $folder = $this->appData->newFolder('images');
248
+        }
249 249
 
250
-		if (!empty($newLogo)) {
251
-			$target = $folder->newFile('logo');
252
-			$supportedFormats = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml', 'text/svg'];
253
-			if (!in_array($newLogo['type'], $supportedFormats)) {
254
-				return new DataResponse(
255
-					[
256
-						'data' => [
257
-							'message' => $this->l10n->t('Unsupported image type'),
258
-						],
259
-						'status' => 'failure',
260
-					],
261
-					Http::STATUS_UNPROCESSABLE_ENTITY
262
-				);
263
-			}
264
-			$target->putContent(file_get_contents($newLogo['tmp_name'], 'r'));
265
-			$this->themingDefaults->set('logoMime', $newLogo['type']);
266
-			$name = $newLogo['name'];
267
-		}
268
-		if (!empty($newBackgroundLogo)) {
269
-			$target = $folder->newFile('background');
270
-			$image = @imagecreatefromstring(file_get_contents($newBackgroundLogo['tmp_name'], 'r'));
271
-			if ($image === false) {
272
-				return new DataResponse(
273
-					[
274
-						'data' => [
275
-							'message' => $this->l10n->t('Unsupported image type'),
276
-						],
277
-						'status' => 'failure',
278
-					],
279
-					Http::STATUS_UNPROCESSABLE_ENTITY
280
-				);
281
-			}
250
+        if (!empty($newLogo)) {
251
+            $target = $folder->newFile('logo');
252
+            $supportedFormats = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml', 'text/svg'];
253
+            if (!in_array($newLogo['type'], $supportedFormats)) {
254
+                return new DataResponse(
255
+                    [
256
+                        'data' => [
257
+                            'message' => $this->l10n->t('Unsupported image type'),
258
+                        ],
259
+                        'status' => 'failure',
260
+                    ],
261
+                    Http::STATUS_UNPROCESSABLE_ENTITY
262
+                );
263
+            }
264
+            $target->putContent(file_get_contents($newLogo['tmp_name'], 'r'));
265
+            $this->themingDefaults->set('logoMime', $newLogo['type']);
266
+            $name = $newLogo['name'];
267
+        }
268
+        if (!empty($newBackgroundLogo)) {
269
+            $target = $folder->newFile('background');
270
+            $image = @imagecreatefromstring(file_get_contents($newBackgroundLogo['tmp_name'], 'r'));
271
+            if ($image === false) {
272
+                return new DataResponse(
273
+                    [
274
+                        'data' => [
275
+                            'message' => $this->l10n->t('Unsupported image type'),
276
+                        ],
277
+                        'status' => 'failure',
278
+                    ],
279
+                    Http::STATUS_UNPROCESSABLE_ENTITY
280
+                );
281
+            }
282 282
 
283
-			// Optimize the image since some people may upload images that will be
284
-			// either to big or are not progressive rendering.
285
-			$tmpFile = $this->tempManager->getTemporaryFile();
286
-			if (function_exists('imagescale')) {
287
-				// FIXME: Once PHP 5.5.0 is a requirement the above check can be removed
288
-				// Workaround for https://bugs.php.net/bug.php?id=65171
289
-				$newHeight = imagesy($image) / (imagesx($image) / 1920);
290
-				$image = imagescale($image, 1920, $newHeight);
291
-			}
292
-			imageinterlace($image, 1);
293
-			imagejpeg($image, $tmpFile, 75);
294
-			imagedestroy($image);
283
+            // Optimize the image since some people may upload images that will be
284
+            // either to big or are not progressive rendering.
285
+            $tmpFile = $this->tempManager->getTemporaryFile();
286
+            if (function_exists('imagescale')) {
287
+                // FIXME: Once PHP 5.5.0 is a requirement the above check can be removed
288
+                // Workaround for https://bugs.php.net/bug.php?id=65171
289
+                $newHeight = imagesy($image) / (imagesx($image) / 1920);
290
+                $image = imagescale($image, 1920, $newHeight);
291
+            }
292
+            imageinterlace($image, 1);
293
+            imagejpeg($image, $tmpFile, 75);
294
+            imagedestroy($image);
295 295
 
296
-			$target->putContent(file_get_contents($tmpFile, 'r'));
297
-			$this->themingDefaults->set('backgroundMime', $newBackgroundLogo['type']);
298
-			$name = $newBackgroundLogo['name'];
299
-		}
296
+            $target->putContent(file_get_contents($tmpFile, 'r'));
297
+            $this->themingDefaults->set('backgroundMime', $newBackgroundLogo['type']);
298
+            $name = $newBackgroundLogo['name'];
299
+        }
300 300
 
301
-		return new DataResponse(
302
-			[
303
-				'data' =>
304
-					[
305
-						'name' => $name,
306
-						'message' => $this->l10n->t('Saved')
307
-					],
308
-				'status' => 'success'
309
-			]
310
-		);
311
-	}
301
+        return new DataResponse(
302
+            [
303
+                'data' =>
304
+                    [
305
+                        'name' => $name,
306
+                        'message' => $this->l10n->t('Saved')
307
+                    ],
308
+                'status' => 'success'
309
+            ]
310
+        );
311
+    }
312 312
 
313
-	/**
314
-	 * Revert setting to default value
315
-	 *
316
-	 * @param string $setting setting which should be reverted
317
-	 * @return DataResponse
318
-	 */
319
-	public function undo($setting) {
320
-		$value = $this->themingDefaults->undo($setting);
321
-		// reprocess server scss for preview
322
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/server.scss', 'core');
313
+    /**
314
+     * Revert setting to default value
315
+     *
316
+     * @param string $setting setting which should be reverted
317
+     * @return DataResponse
318
+     */
319
+    public function undo($setting) {
320
+        $value = $this->themingDefaults->undo($setting);
321
+        // reprocess server scss for preview
322
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, '/core/css/server.scss', 'core');
323 323
 
324
-		if($setting === 'logoMime') {
325
-			try {
326
-				$file = $this->appData->getFolder('images')->getFile('logo');
327
-				$file->delete();
328
-			} catch (NotFoundException $e) {
329
-			} catch (NotPermittedException $e) {
330
-			}
331
-		}
332
-		if($setting === 'backgroundMime') {
333
-			try {
334
-				$file = $this->appData->getFolder('images')->getFile('background');
335
-				$file->delete();
336
-			} catch (NotFoundException $e) {
337
-			} catch (NotPermittedException $e) {
338
-			}
339
-		}
324
+        if($setting === 'logoMime') {
325
+            try {
326
+                $file = $this->appData->getFolder('images')->getFile('logo');
327
+                $file->delete();
328
+            } catch (NotFoundException $e) {
329
+            } catch (NotPermittedException $e) {
330
+            }
331
+        }
332
+        if($setting === 'backgroundMime') {
333
+            try {
334
+                $file = $this->appData->getFolder('images')->getFile('background');
335
+                $file->delete();
336
+            } catch (NotFoundException $e) {
337
+            } catch (NotPermittedException $e) {
338
+            }
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
-	 * @return FileDisplayResponse|NotFoundResponse
359
-	 */
360
-	public function getLogo() {
361
-		try {
362
-			/** @var File $file */
363
-			$file = $this->appData->getFolder('images')->getFile('logo');
364
-		} catch (NotFoundException $e) {
365
-			return new NotFoundResponse();
366
-		}
354
+    /**
355
+     * @PublicPage
356
+     * @NoCSRFRequired
357
+     *
358
+     * @return FileDisplayResponse|NotFoundResponse
359
+     */
360
+    public function getLogo() {
361
+        try {
362
+            /** @var File $file */
363
+            $file = $this->appData->getFolder('images')->getFile('logo');
364
+        } catch (NotFoundException $e) {
365
+            return new NotFoundResponse();
366
+        }
367 367
 
368
-		$response = new FileDisplayResponse($file);
369
-		$response->cacheFor(3600);
370
-		$expires = new \DateTime();
371
-		$expires->setTimestamp($this->timeFactory->getTime());
372
-		$expires->add(new \DateInterval('PT24H'));
373
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
374
-		$response->addHeader('Pragma', 'cache');
375
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', ''));
376
-		return $response;
377
-	}
368
+        $response = new FileDisplayResponse($file);
369
+        $response->cacheFor(3600);
370
+        $expires = new \DateTime();
371
+        $expires->setTimestamp($this->timeFactory->getTime());
372
+        $expires->add(new \DateInterval('PT24H'));
373
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
374
+        $response->addHeader('Pragma', 'cache');
375
+        $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', ''));
376
+        return $response;
377
+    }
378 378
 
379
-	/**
380
-	 * @PublicPage
381
-	 * @NoCSRFRequired
382
-	 *
383
-	 * @return FileDisplayResponse|NotFoundResponse
384
-	 */
385
-	public function getLoginBackground() {
386
-		try {
387
-			/** @var File $file */
388
-			$file = $this->appData->getFolder('images')->getFile('background');
389
-		} catch (NotFoundException $e) {
390
-			return new NotFoundResponse();
391
-		}
379
+    /**
380
+     * @PublicPage
381
+     * @NoCSRFRequired
382
+     *
383
+     * @return FileDisplayResponse|NotFoundResponse
384
+     */
385
+    public function getLoginBackground() {
386
+        try {
387
+            /** @var File $file */
388
+            $file = $this->appData->getFolder('images')->getFile('background');
389
+        } catch (NotFoundException $e) {
390
+            return new NotFoundResponse();
391
+        }
392 392
 
393
-		$response = new FileDisplayResponse($file);
394
-		$response->cacheFor(3600);
395
-		$expires = new \DateTime();
396
-		$expires->setTimestamp($this->timeFactory->getTime());
397
-		$expires->add(new \DateInterval('PT24H'));
398
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
399
-		$response->addHeader('Pragma', 'cache');
400
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', ''));
401
-		return $response;
402
-	}
393
+        $response = new FileDisplayResponse($file);
394
+        $response->cacheFor(3600);
395
+        $expires = new \DateTime();
396
+        $expires->setTimestamp($this->timeFactory->getTime());
397
+        $expires->add(new \DateInterval('PT24H'));
398
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
399
+        $response->addHeader('Pragma', 'cache');
400
+        $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', ''));
401
+        return $response;
402
+    }
403 403
 
404
-	/**
405
-	 * @NoCSRFRequired
406
-	 * @PublicPage
407
-	 *
408
-	 * @return FileDisplayResponse|NotFoundResponse
409
-	 */
410
-	public function getStylesheet() {
411
-		$appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1);
412
-		/* SCSSCacher is required here
404
+    /**
405
+     * @NoCSRFRequired
406
+     * @PublicPage
407
+     *
408
+     * @return FileDisplayResponse|NotFoundResponse
409
+     */
410
+    public function getStylesheet() {
411
+        $appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1);
412
+        /* SCSSCacher is required here
413 413
 		 * We cannot rely on automatic caching done by \OC_Util::addStyle,
414 414
 		 * since we need to add the cacheBuster value to the url
415 415
 		 */
416
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming');
417
-		if(!$cssCached) {
418
-			return new NotFoundResponse();
419
-		}
416
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming');
417
+        if(!$cssCached) {
418
+            return new NotFoundResponse();
419
+        }
420 420
 
421
-		try {
422
-			$cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css');
423
-			$response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
424
-			$response->cacheFor(86400);
425
-			$expires = new \DateTime();
426
-			$expires->setTimestamp($this->timeFactory->getTime());
427
-			$expires->add(new \DateInterval('PT24H'));
428
-			$response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
429
-			$response->addHeader('Pragma', 'cache');
430
-			return $response;
431
-		} catch (NotFoundException $e) {
432
-			return new NotFoundResponse();
433
-		}
434
-	}
421
+        try {
422
+            $cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css');
423
+            $response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
424
+            $response->cacheFor(86400);
425
+            $expires = new \DateTime();
426
+            $expires->setTimestamp($this->timeFactory->getTime());
427
+            $expires->add(new \DateInterval('PT24H'));
428
+            $response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
429
+            $response->addHeader('Pragma', 'cache');
430
+            return $response;
431
+        } catch (NotFoundException $e) {
432
+            return new NotFoundResponse();
433
+        }
434
+    }
435 435
 
436
-	/**
437
-	 * @NoCSRFRequired
438
-	 * @PublicPage
439
-	 *
440
-	 * @return DataDownloadResponse
441
-	 */
442
-	public function getJavascript() {
443
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
444
-		$responseJS = '(function() {
436
+    /**
437
+     * @NoCSRFRequired
438
+     * @PublicPage
439
+     *
440
+     * @return DataDownloadResponse
441
+     */
442
+    public function getJavascript() {
443
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
444
+        $responseJS = '(function() {
445 445
 	OCA.Theming = {
446 446
 		name: ' . json_encode($this->themingDefaults->getName()) . ',
447 447
 		url: ' . json_encode($this->themingDefaults->getBaseUrl()) . ',
@@ -451,45 +451,45 @@  discard block
 block discarded – undo
451 451
 		cacheBuster: ' . json_encode($cacheBusterValue) . '
452 452
 	};
453 453
 })();';
454
-		$response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
455
-		$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
456
-		$response->addHeader('Pragma', 'cache');
457
-		$response->cacheFor(3600);
458
-		return $response;
459
-	}
454
+        $response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
455
+        $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
456
+        $response->addHeader('Pragma', 'cache');
457
+        $response->cacheFor(3600);
458
+        return $response;
459
+    }
460 460
 
461
-	/**
462
-	 * @NoCSRFRequired
463
-	 * @PublicPage
464
-	 *
465
-	 * @return Http\JSONResponse
466
-	 */
467
-	public function getManifest($app) {
468
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
469
-		$responseJS = [
470
-			'name' => $this->themingDefaults->getName(),
471
-			'start_url' => $this->urlGenerator->getBaseUrl(),
472
-			'icons' =>
473
-				[
474
-					[
475
-						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
476
-								['app' => $app]) . '?v=' . $cacheBusterValue,
477
-						'type'=> 'image/png',
478
-						'sizes'=> '128x128'
479
-					],
480
-					[
481
-						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
482
-								['app' => $app]) . '?v=' . $cacheBusterValue,
483
-						'type' => 'image/svg+xml',
484
-						'sizes' => '16x16'
485
-					]
486
-				],
487
-			'display' => 'standalone'
488
-		];
489
-		$response = new Http\JSONResponse($responseJS);
490
-		$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
491
-		$response->addHeader('Pragma', 'cache');
492
-		$response->cacheFor(3600);
493
-		return $response;
494
-	}
461
+    /**
462
+     * @NoCSRFRequired
463
+     * @PublicPage
464
+     *
465
+     * @return Http\JSONResponse
466
+     */
467
+    public function getManifest($app) {
468
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
469
+        $responseJS = [
470
+            'name' => $this->themingDefaults->getName(),
471
+            'start_url' => $this->urlGenerator->getBaseUrl(),
472
+            'icons' =>
473
+                [
474
+                    [
475
+                        'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
476
+                                ['app' => $app]) . '?v=' . $cacheBusterValue,
477
+                        'type'=> 'image/png',
478
+                        'sizes'=> '128x128'
479
+                    ],
480
+                    [
481
+                        'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
482
+                                ['app' => $app]) . '?v=' . $cacheBusterValue,
483
+                        'type' => 'image/svg+xml',
484
+                        'sizes' => '16x16'
485
+                    ]
486
+                ],
487
+            'display' => 'standalone'
488
+        ];
489
+        $response = new Http\JSONResponse($responseJS);
490
+        $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
491
+        $response->addHeader('Pragma', 'cache');
492
+        $response->cacheFor(3600);
493
+        return $response;
494
+    }
495 495
 }
Please login to merge, or discard this patch.