Completed
Pull Request — master (#7953)
by Julius
16:05
created
apps/theming/lib/Controller/ThemingController.php 1 patch
Indentation   +399 added lines, -399 removed lines patch added patch discarded remove patch
@@ -62,392 +62,392 @@  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);
292
-			if ($newWidth >= 4096) {
293
-				$newWidth = 4096;
294
-			}
295
-			$newHeight = imagesy($image) / (imagesx($image) / $newWidth);
296
-			$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);
292
+            if ($newWidth >= 4096) {
293
+                $newWidth = 4096;
294
+            }
295
+            $newHeight = imagesy($image) / (imagesx($image) / $newWidth);
296
+            $image = imagescale($image, $newWidth, $newHeight);
297 297
 
298
-			imageinterlace($image, 1);
299
-			imagejpeg($image, $tmpFile, 75);
300
-			imagedestroy($image);
298
+            imageinterlace($image, 1);
299
+            imagejpeg($image, $tmpFile, 75);
300
+            imagedestroy($image);
301 301
 
302
-			$target->putContent(file_get_contents($tmpFile, 'r'));
303
-			$this->themingDefaults->set('backgroundMime', $newBackgroundLogo['type']);
304
-			$name = $newBackgroundLogo['name'];
305
-		}
302
+            $target->putContent(file_get_contents($tmpFile, 'r'));
303
+            $this->themingDefaults->set('backgroundMime', $newBackgroundLogo['type']);
304
+            $name = $newBackgroundLogo['name'];
305
+        }
306 306
 
307
-		return new DataResponse(
308
-			[
309
-				'data' =>
310
-					[
311
-						'name' => $name,
312
-						'message' => $this->l10n->t('Saved')
313
-					],
314
-				'status' => 'success'
315
-			]
316
-		);
317
-	}
307
+        return new DataResponse(
308
+            [
309
+                'data' =>
310
+                    [
311
+                        'name' => $name,
312
+                        'message' => $this->l10n->t('Saved')
313
+                    ],
314
+                'status' => 'success'
315
+            ]
316
+        );
317
+    }
318 318
 
319
-	/**
320
-	 * Revert setting to default value
321
-	 *
322
-	 * @param string $setting setting which should be reverted
323
-	 * @return DataResponse
324
-	 */
325
-	public function undo($setting) {
326
-		$value = $this->themingDefaults->undo($setting);
327
-		// reprocess server scss for preview
328
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/server.scss', 'core');
319
+    /**
320
+     * Revert setting to default value
321
+     *
322
+     * @param string $setting setting which should be reverted
323
+     * @return DataResponse
324
+     */
325
+    public function undo($setting) {
326
+        $value = $this->themingDefaults->undo($setting);
327
+        // reprocess server scss for preview
328
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, 'core/css/server.scss', 'core');
329 329
 
330
-		if($setting === 'logoMime') {
331
-			try {
332
-				$file = $this->appData->getFolder('images')->getFile('logo');
333
-				$file->delete();
334
-			} catch (NotFoundException $e) {
335
-			} catch (NotPermittedException $e) {
336
-			}
337
-		}
338
-		if($setting === 'backgroundMime') {
339
-			try {
340
-				$file = $this->appData->getFolder('images')->getFile('background');
341
-				$file->delete();
342
-			} catch (NotFoundException $e) {
343
-			} catch (NotPermittedException $e) {
344
-			}
345
-		}
330
+        if($setting === 'logoMime') {
331
+            try {
332
+                $file = $this->appData->getFolder('images')->getFile('logo');
333
+                $file->delete();
334
+            } catch (NotFoundException $e) {
335
+            } catch (NotPermittedException $e) {
336
+            }
337
+        }
338
+        if($setting === 'backgroundMime') {
339
+            try {
340
+                $file = $this->appData->getFolder('images')->getFile('background');
341
+                $file->delete();
342
+            } catch (NotFoundException $e) {
343
+            } catch (NotPermittedException $e) {
344
+            }
345
+        }
346 346
 
347
-		return new DataResponse(
348
-			[
349
-				'data' =>
350
-					[
351
-						'value' => $value,
352
-						'message' => $this->l10n->t('Saved'),
353
-						'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
354
-					],
355
-				'status' => 'success'
356
-			]
357
-		);
358
-	}
347
+        return new DataResponse(
348
+            [
349
+                'data' =>
350
+                    [
351
+                        'value' => $value,
352
+                        'message' => $this->l10n->t('Saved'),
353
+                        'serverCssUrl' => $this->urlGenerator->linkTo('', $this->scssCacher->getCachedSCSS('core', '/core/css/server.scss'))
354
+                    ],
355
+                'status' => 'success'
356
+            ]
357
+        );
358
+    }
359 359
 
360
-	/**
361
-	 * @PublicPage
362
-	 * @NoCSRFRequired
363
-	 *
364
-	 * @return FileDisplayResponse|NotFoundResponse
365
-	 */
366
-	public function getLogo() {
367
-		try {
368
-			/** @var File $file */
369
-			$file = $this->appData->getFolder('images')->getFile('logo');
370
-		} catch (NotFoundException $e) {
371
-			return new NotFoundResponse();
372
-		}
360
+    /**
361
+     * @PublicPage
362
+     * @NoCSRFRequired
363
+     *
364
+     * @return FileDisplayResponse|NotFoundResponse
365
+     */
366
+    public function getLogo() {
367
+        try {
368
+            /** @var File $file */
369
+            $file = $this->appData->getFolder('images')->getFile('logo');
370
+        } catch (NotFoundException $e) {
371
+            return new NotFoundResponse();
372
+        }
373 373
 
374
-		$response = new FileDisplayResponse($file);
375
-		$response->cacheFor(3600);
376
-		$expires = new \DateTime();
377
-		$expires->setTimestamp($this->timeFactory->getTime());
378
-		$expires->add(new \DateInterval('PT24H'));
379
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
380
-		$response->addHeader('Pragma', 'cache');
381
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', ''));
382
-		return $response;
383
-	}
374
+        $response = new FileDisplayResponse($file);
375
+        $response->cacheFor(3600);
376
+        $expires = new \DateTime();
377
+        $expires->setTimestamp($this->timeFactory->getTime());
378
+        $expires->add(new \DateInterval('PT24H'));
379
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
380
+        $response->addHeader('Pragma', 'cache');
381
+        $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', ''));
382
+        return $response;
383
+    }
384 384
 
385
-	/**
386
-	 * @PublicPage
387
-	 * @NoCSRFRequired
388
-	 *
389
-	 * @return FileDisplayResponse|NotFoundResponse
390
-	 */
391
-	public function getLoginBackground() {
392
-		try {
393
-			/** @var File $file */
394
-			$file = $this->appData->getFolder('images')->getFile('background');
395
-		} catch (NotFoundException $e) {
396
-			return new NotFoundResponse();
397
-		}
385
+    /**
386
+     * @PublicPage
387
+     * @NoCSRFRequired
388
+     *
389
+     * @return FileDisplayResponse|NotFoundResponse
390
+     */
391
+    public function getLoginBackground() {
392
+        try {
393
+            /** @var File $file */
394
+            $file = $this->appData->getFolder('images')->getFile('background');
395
+        } catch (NotFoundException $e) {
396
+            return new NotFoundResponse();
397
+        }
398 398
 
399
-		$response = new FileDisplayResponse($file);
400
-		$response->cacheFor(3600);
401
-		$expires = new \DateTime();
402
-		$expires->setTimestamp($this->timeFactory->getTime());
403
-		$expires->add(new \DateInterval('PT24H'));
404
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
405
-		$response->addHeader('Pragma', 'cache');
406
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', ''));
407
-		return $response;
408
-	}
399
+        $response = new FileDisplayResponse($file);
400
+        $response->cacheFor(3600);
401
+        $expires = new \DateTime();
402
+        $expires->setTimestamp($this->timeFactory->getTime());
403
+        $expires->add(new \DateInterval('PT24H'));
404
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
405
+        $response->addHeader('Pragma', 'cache');
406
+        $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', ''));
407
+        return $response;
408
+    }
409 409
 
410
-	/**
411
-	 * @NoCSRFRequired
412
-	 * @PublicPage
413
-	 *
414
-	 * @return FileDisplayResponse|NotFoundResponse
415
-	 */
416
-	public function getStylesheet() {
417
-		$appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1);
418
-		/* SCSSCacher is required here
410
+    /**
411
+     * @NoCSRFRequired
412
+     * @PublicPage
413
+     *
414
+     * @return FileDisplayResponse|NotFoundResponse
415
+     */
416
+    public function getStylesheet() {
417
+        $appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1);
418
+        /* SCSSCacher is required here
419 419
 		 * We cannot rely on automatic caching done by \OC_Util::addStyle,
420 420
 		 * since we need to add the cacheBuster value to the url
421 421
 		 */
422
-		$cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming');
423
-		if(!$cssCached) {
424
-			return new NotFoundResponse();
425
-		}
422
+        $cssCached = $this->scssCacher->process(\OC::$SERVERROOT, $appPath . '/css/theming.scss', 'theming');
423
+        if(!$cssCached) {
424
+            return new NotFoundResponse();
425
+        }
426 426
 
427
-		try {
428
-			$cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css');
429
-			$response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
430
-			$response->cacheFor(86400);
431
-			$expires = new \DateTime();
432
-			$expires->setTimestamp($this->timeFactory->getTime());
433
-			$expires->add(new \DateInterval('PT24H'));
434
-			$response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
435
-			$response->addHeader('Pragma', 'cache');
436
-			return $response;
437
-		} catch (NotFoundException $e) {
438
-			return new NotFoundResponse();
439
-		}
440
-	}
427
+        try {
428
+            $cssFile = $this->scssCacher->getCachedCSS('theming', 'theming.css');
429
+            $response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
430
+            $response->cacheFor(86400);
431
+            $expires = new \DateTime();
432
+            $expires->setTimestamp($this->timeFactory->getTime());
433
+            $expires->add(new \DateInterval('PT24H'));
434
+            $response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
435
+            $response->addHeader('Pragma', 'cache');
436
+            return $response;
437
+        } catch (NotFoundException $e) {
438
+            return new NotFoundResponse();
439
+        }
440
+    }
441 441
 
442
-	/**
443
-	 * @NoCSRFRequired
444
-	 * @PublicPage
445
-	 *
446
-	 * @return DataDownloadResponse
447
-	 */
448
-	public function getJavascript() {
449
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
450
-		$responseJS = '(function() {
442
+    /**
443
+     * @NoCSRFRequired
444
+     * @PublicPage
445
+     *
446
+     * @return DataDownloadResponse
447
+     */
448
+    public function getJavascript() {
449
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
450
+        $responseJS = '(function() {
451 451
 	OCA.Theming = {
452 452
 		name: ' . json_encode($this->themingDefaults->getName()) . ',
453 453
 		url: ' . json_encode($this->themingDefaults->getBaseUrl()) . ',
@@ -457,45 +457,45 @@  discard block
 block discarded – undo
457 457
 		cacheBuster: ' . json_encode($cacheBusterValue) . '
458 458
 	};
459 459
 })();';
460
-		$response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
461
-		$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
462
-		$response->addHeader('Pragma', 'cache');
463
-		$response->cacheFor(3600);
464
-		return $response;
465
-	}
460
+        $response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
461
+        $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
462
+        $response->addHeader('Pragma', 'cache');
463
+        $response->cacheFor(3600);
464
+        return $response;
465
+    }
466 466
 
467
-	/**
468
-	 * @NoCSRFRequired
469
-	 * @PublicPage
470
-	 *
471
-	 * @return Http\JSONResponse
472
-	 */
473
-	public function getManifest($app) {
474
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
475
-		$responseJS = [
476
-			'name' => $this->themingDefaults->getName(),
477
-			'start_url' => $this->urlGenerator->getBaseUrl(),
478
-			'icons' =>
479
-				[
480
-					[
481
-						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
482
-								['app' => $app]) . '?v=' . $cacheBusterValue,
483
-						'type'=> 'image/png',
484
-						'sizes'=> '128x128'
485
-					],
486
-					[
487
-						'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
488
-								['app' => $app]) . '?v=' . $cacheBusterValue,
489
-						'type' => 'image/svg+xml',
490
-						'sizes' => '16x16'
491
-					]
492
-				],
493
-			'display' => 'standalone'
494
-		];
495
-		$response = new Http\JSONResponse($responseJS);
496
-		$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
497
-		$response->addHeader('Pragma', 'cache');
498
-		$response->cacheFor(3600);
499
-		return $response;
500
-	}
467
+    /**
468
+     * @NoCSRFRequired
469
+     * @PublicPage
470
+     *
471
+     * @return Http\JSONResponse
472
+     */
473
+    public function getManifest($app) {
474
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
475
+        $responseJS = [
476
+            'name' => $this->themingDefaults->getName(),
477
+            'start_url' => $this->urlGenerator->getBaseUrl(),
478
+            'icons' =>
479
+                [
480
+                    [
481
+                        'src' => $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon',
482
+                                ['app' => $app]) . '?v=' . $cacheBusterValue,
483
+                        'type'=> 'image/png',
484
+                        'sizes'=> '128x128'
485
+                    ],
486
+                    [
487
+                        'src' => $this->urlGenerator->linkToRoute('theming.Icon.getFavicon',
488
+                                ['app' => $app]) . '?v=' . $cacheBusterValue,
489
+                        'type' => 'image/svg+xml',
490
+                        'sizes' => '16x16'
491
+                    ]
492
+                ],
493
+            'display' => 'standalone'
494
+        ];
495
+        $response = new Http\JSONResponse($responseJS);
496
+        $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
497
+        $response->addHeader('Pragma', 'cache');
498
+        $response->cacheFor(3600);
499
+        return $response;
500
+    }
501 501
 }
Please login to merge, or discard this patch.