Passed
Push — master ( df6e91...2ec5d2 )
by Morris
78:37 queued 64:33
created
apps/accessibility/lib/Controller/AccessibilityController.php 1 patch
Indentation   +237 added lines, -237 removed lines patch added patch discarded remove patch
@@ -41,246 +41,246 @@
 block discarded – undo
41 41
 
42 42
 class AccessibilityController extends Controller {
43 43
 
44
-	/** @var string */
45
-	protected $appName;
46
-
47
-	/** @var string */
48
-	protected $serverRoot;
49
-
50
-	/** @var IConfig */
51
-	private $config;
52
-
53
-	/** @var IUserManager */
54
-	private $userManager;
55
-
56
-	/** @var ILogger */
57
-	private $logger;
58
-
59
-	/** @var IURLGenerator */
60
-	private $urlGenerator;
61
-
62
-	/** @var ITimeFactory */
63
-	protected $timeFactory;
64
-
65
-	/** @var IUserSession */
66
-	private $userSession;
67
-
68
-	/** @var IAppManager */
69
-	private $appManager;
70
-
71
-	/** @var IconsCacher */
72
-	protected $iconsCacher;
73
-
74
-	/** @var \OC_Defaults */
75
-	private $defaults;
76
-
77
-	/** @var null|string */
78
-	private $injectedVariables;
79
-
80
-	/**
81
-	 * Account constructor.
82
-	 *
83
-	 * @param string $appName
84
-	 * @param IRequest $request
85
-	 * @param IConfig $config
86
-	 * @param IUserManager $userManager
87
-	 * @param ILogger $logger
88
-	 * @param IURLGenerator $urlGenerator
89
-	 * @param ITimeFactory $timeFactory
90
-	 * @param IUserSession $userSession
91
-	 * @param IAppManager $appManager
92
-	 * @param \OC_Defaults $defaults
93
-	 */
94
-	public function __construct(string $appName,
95
-								IRequest $request,
96
-								IConfig $config,
97
-								IUserManager $userManager,
98
-								ILogger $logger,
99
-								IURLGenerator $urlGenerator,
100
-								ITimeFactory $timeFactory,
101
-								IUserSession $userSession,
102
-								IAppManager $appManager,
103
-								IconsCacher $iconsCacher,
104
-								\OC_Defaults $defaults) {
105
-		parent::__construct($appName, $request);
106
-		$this->appName      = $appName;
107
-		$this->config       = $config;
108
-		$this->userManager  = $userManager;
109
-		$this->logger       = $logger;
110
-		$this->urlGenerator = $urlGenerator;
111
-		$this->timeFactory  = $timeFactory;
112
-		$this->userSession  = $userSession;
113
-		$this->appManager   = $appManager;
114
-		$this->iconsCacher  = $iconsCacher;
115
-		$this->defaults     = $defaults;
116
-
117
-		$this->serverRoot = \OC::$SERVERROOT;
118
-		$this->appRoot    = $this->appManager->getAppPath($this->appName);
119
-	}
120
-
121
-	/**
122
-	 * @NoAdminRequired
123
-	 * @NoCSRFRequired
124
-	 *
125
-	 * @return DataDisplayResponse
126
-	 */
127
-	public function getCss(): DataDisplayResponse {
128
-		$css        = '';
129
-		$imports    = '';
130
-		$userValues = $this->getUserValues();
131
-
132
-		foreach ($userValues as $key => $scssFile) {
133
-			if ($scssFile !== false) {
134
-				$imports .= '@import "' . $scssFile . '";';
135
-			}
136
-		}
137
-
138
-		if ($imports !== '') {
139
-			$scss = new Compiler();
140
-			$scss->setImportPaths([
141
-				$this->appRoot . '/css/',
142
-				$this->serverRoot . '/core/css/'
143
-			]);
144
-
145
-			// Continue after throw
146
-			$scss->setIgnoreErrors(true);
147
-			$scss->setFormatter(Crunched::class);
148
-
149
-			// Import theme, variables and compile css4 variables
150
-			try {
151
-				$css .= $scss->compile(
152
-					$imports .
153
-					$this->getInjectedVariables() .
154
-					'@import "variables.scss";' .
155
-					'@import "css-variables.scss";'
156
-				);
157
-			} catch (ParserException $e) {
158
-				$this->logger->error($e->getMessage(), ['app' => 'core']);
159
-			}
160
-		}
161
-
162
-		// We don't want to override vars with url since path is different
163
-		$css = $this->filterOutRule('/--[a-z-:]+url\([^;]+\)/mi', $css);
164
-
165
-		// Rebase all urls
166
-		$appWebRoot = substr($this->appRoot, strlen($this->serverRoot) - strlen(\OC::$WEBROOT));
167
-		$css        = $this->rebaseUrls($css, $appWebRoot . '/css');
168
-
169
-		if (in_array('themedark', $userValues) && $this->iconsCacher->getCachedCSS() && $this->iconsCacher->getCachedCSS()->getSize() > 0) {
170
-			$iconsCss = $this->invertSvgIconsColor($this->iconsCacher->getCachedCSS()->getContent());
171
-			$css = $css . $iconsCss;
172
-		}
173
-
174
-		$response = new DataDisplayResponse($css, Http::STATUS_OK, ['Content-Type' => 'text/css']);
175
-
176
-		// Set cache control
177
-		$ttl = 31536000;
178
-		$response->addHeader('Cache-Control', 'max-age=' . $ttl . ', immutable');
179
-		$expires = new \DateTime();
180
-		$expires->setTimestamp($this->timeFactory->getTime());
181
-		$expires->add(new \DateInterval('PT' . $ttl . 'S'));
182
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
183
-		$response->addHeader('Pragma', 'cache');
184
-
185
-		// store current cache hash
186
-		$this->config->setUserValue($this->userSession->getUser()->getUID(), $this->appName, 'icons-css', md5($css));
187
-
188
-		return $response;
189
-	}
190
-
191
-	/**
192
-	 * @NoCSRFRequired
193
-	 * @PublicPage
194
-	 *
195
-	 * @return DataDownloadResponse
196
-	 */
197
-	public function getJavascript(): DataDownloadResponse {
198
-		$user = $this->userSession->getUser();
199
-
200
-		if ($user === null) {
201
-			$theme = false;
202
-		} else {
203
-			$theme = $this->config->getUserValue($user->getUID(), $this->appName, 'theme', false);
204
-		}
205
-
206
-		$responseJS = '(function() {
44
+    /** @var string */
45
+    protected $appName;
46
+
47
+    /** @var string */
48
+    protected $serverRoot;
49
+
50
+    /** @var IConfig */
51
+    private $config;
52
+
53
+    /** @var IUserManager */
54
+    private $userManager;
55
+
56
+    /** @var ILogger */
57
+    private $logger;
58
+
59
+    /** @var IURLGenerator */
60
+    private $urlGenerator;
61
+
62
+    /** @var ITimeFactory */
63
+    protected $timeFactory;
64
+
65
+    /** @var IUserSession */
66
+    private $userSession;
67
+
68
+    /** @var IAppManager */
69
+    private $appManager;
70
+
71
+    /** @var IconsCacher */
72
+    protected $iconsCacher;
73
+
74
+    /** @var \OC_Defaults */
75
+    private $defaults;
76
+
77
+    /** @var null|string */
78
+    private $injectedVariables;
79
+
80
+    /**
81
+     * Account constructor.
82
+     *
83
+     * @param string $appName
84
+     * @param IRequest $request
85
+     * @param IConfig $config
86
+     * @param IUserManager $userManager
87
+     * @param ILogger $logger
88
+     * @param IURLGenerator $urlGenerator
89
+     * @param ITimeFactory $timeFactory
90
+     * @param IUserSession $userSession
91
+     * @param IAppManager $appManager
92
+     * @param \OC_Defaults $defaults
93
+     */
94
+    public function __construct(string $appName,
95
+                                IRequest $request,
96
+                                IConfig $config,
97
+                                IUserManager $userManager,
98
+                                ILogger $logger,
99
+                                IURLGenerator $urlGenerator,
100
+                                ITimeFactory $timeFactory,
101
+                                IUserSession $userSession,
102
+                                IAppManager $appManager,
103
+                                IconsCacher $iconsCacher,
104
+                                \OC_Defaults $defaults) {
105
+        parent::__construct($appName, $request);
106
+        $this->appName      = $appName;
107
+        $this->config       = $config;
108
+        $this->userManager  = $userManager;
109
+        $this->logger       = $logger;
110
+        $this->urlGenerator = $urlGenerator;
111
+        $this->timeFactory  = $timeFactory;
112
+        $this->userSession  = $userSession;
113
+        $this->appManager   = $appManager;
114
+        $this->iconsCacher  = $iconsCacher;
115
+        $this->defaults     = $defaults;
116
+
117
+        $this->serverRoot = \OC::$SERVERROOT;
118
+        $this->appRoot    = $this->appManager->getAppPath($this->appName);
119
+    }
120
+
121
+    /**
122
+     * @NoAdminRequired
123
+     * @NoCSRFRequired
124
+     *
125
+     * @return DataDisplayResponse
126
+     */
127
+    public function getCss(): DataDisplayResponse {
128
+        $css        = '';
129
+        $imports    = '';
130
+        $userValues = $this->getUserValues();
131
+
132
+        foreach ($userValues as $key => $scssFile) {
133
+            if ($scssFile !== false) {
134
+                $imports .= '@import "' . $scssFile . '";';
135
+            }
136
+        }
137
+
138
+        if ($imports !== '') {
139
+            $scss = new Compiler();
140
+            $scss->setImportPaths([
141
+                $this->appRoot . '/css/',
142
+                $this->serverRoot . '/core/css/'
143
+            ]);
144
+
145
+            // Continue after throw
146
+            $scss->setIgnoreErrors(true);
147
+            $scss->setFormatter(Crunched::class);
148
+
149
+            // Import theme, variables and compile css4 variables
150
+            try {
151
+                $css .= $scss->compile(
152
+                    $imports .
153
+                    $this->getInjectedVariables() .
154
+                    '@import "variables.scss";' .
155
+                    '@import "css-variables.scss";'
156
+                );
157
+            } catch (ParserException $e) {
158
+                $this->logger->error($e->getMessage(), ['app' => 'core']);
159
+            }
160
+        }
161
+
162
+        // We don't want to override vars with url since path is different
163
+        $css = $this->filterOutRule('/--[a-z-:]+url\([^;]+\)/mi', $css);
164
+
165
+        // Rebase all urls
166
+        $appWebRoot = substr($this->appRoot, strlen($this->serverRoot) - strlen(\OC::$WEBROOT));
167
+        $css        = $this->rebaseUrls($css, $appWebRoot . '/css');
168
+
169
+        if (in_array('themedark', $userValues) && $this->iconsCacher->getCachedCSS() && $this->iconsCacher->getCachedCSS()->getSize() > 0) {
170
+            $iconsCss = $this->invertSvgIconsColor($this->iconsCacher->getCachedCSS()->getContent());
171
+            $css = $css . $iconsCss;
172
+        }
173
+
174
+        $response = new DataDisplayResponse($css, Http::STATUS_OK, ['Content-Type' => 'text/css']);
175
+
176
+        // Set cache control
177
+        $ttl = 31536000;
178
+        $response->addHeader('Cache-Control', 'max-age=' . $ttl . ', immutable');
179
+        $expires = new \DateTime();
180
+        $expires->setTimestamp($this->timeFactory->getTime());
181
+        $expires->add(new \DateInterval('PT' . $ttl . 'S'));
182
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
183
+        $response->addHeader('Pragma', 'cache');
184
+
185
+        // store current cache hash
186
+        $this->config->setUserValue($this->userSession->getUser()->getUID(), $this->appName, 'icons-css', md5($css));
187
+
188
+        return $response;
189
+    }
190
+
191
+    /**
192
+     * @NoCSRFRequired
193
+     * @PublicPage
194
+     *
195
+     * @return DataDownloadResponse
196
+     */
197
+    public function getJavascript(): DataDownloadResponse {
198
+        $user = $this->userSession->getUser();
199
+
200
+        if ($user === null) {
201
+            $theme = false;
202
+        } else {
203
+            $theme = $this->config->getUserValue($user->getUID(), $this->appName, 'theme', false);
204
+        }
205
+
206
+        $responseJS = '(function() {
207 207
 	OCA.Accessibility = {
208 208
 		theme: ' . json_encode($theme) . ',
209 209
 		
210 210
 	};
211 211
 })();';
212
-		$response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
213
-		$response->cacheFor(3600);
214
-		return $response;
215
-	}
216
-
217
-	/**
218
-	 * Return an array with the user theme & font settings
219
-	 *
220
-	 * @return array
221
-	 */
222
-	private function getUserValues(): array{
223
-		$userTheme = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false);
224
-		$userFont  = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false);
225
-
226
-		return [$userTheme, $userFont];
227
-	}
228
-
229
-	/**
230
-	 * Remove all matches from the $rule regex
231
-	 *
232
-	 * @param string $rule regex to match
233
-	 * @param string $css string to parse
234
-	 * @return string
235
-	 */
236
-	private function filterOutRule(string $rule, string $css): string {
237
-		return preg_replace($rule, '', $css);
238
-	}
239
-
240
-	/**
241
-	 * Add the correct uri prefix to make uri valid again
242
-	 *
243
-	 * @param string $css
244
-	 * @param string $webDir
245
-	 * @return string
246
-	 */
247
-	private function rebaseUrls(string $css, string $webDir): string {
248
-		$re    = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x';
249
-		$subst = 'url(\'' . $webDir . '/$1\')';
250
-
251
-		return preg_replace($re, $subst, $css);
252
-	}
253
-
254
-	/**
255
-	 * Remove all matches from the $rule regex
256
-	 *
257
-	 * @param string $css string to parse
258
-	 * @return string
259
-	 */
260
-	private function invertSvgIconsColor(string $css) {
261
-		return str_replace(['/000', '/fff', '/***'], ['/***', '/000', '/fff'], $css);
262
-	}
263
-
264
-	/**
265
-	 * @return string SCSS code for variables from OC_Defaults
266
-	 */
267
-	private function getInjectedVariables(): string {
268
-		if ($this->injectedVariables !== null) {
269
-			return $this->injectedVariables;
270
-		}
271
-		$variables = '';
272
-		foreach ($this->defaults->getScssVariables() as $key => $value) {
273
-			$variables .= '$' . $key . ': ' . $value . ';';
274
-		}
275
-
276
-		// check for valid variables / otherwise fall back to defaults
277
-		try {
278
-			$scss = new Compiler();
279
-			$scss->compile($variables);
280
-			$this->injectedVariables = $variables;
281
-		} catch (ParserException $e) {
282
-			$this->logger->error($e, ['app' => 'core']);
283
-		}
284
-		return $variables;
285
-	}
212
+        $response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
213
+        $response->cacheFor(3600);
214
+        return $response;
215
+    }
216
+
217
+    /**
218
+     * Return an array with the user theme & font settings
219
+     *
220
+     * @return array
221
+     */
222
+    private function getUserValues(): array{
223
+        $userTheme = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false);
224
+        $userFont  = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false);
225
+
226
+        return [$userTheme, $userFont];
227
+    }
228
+
229
+    /**
230
+     * Remove all matches from the $rule regex
231
+     *
232
+     * @param string $rule regex to match
233
+     * @param string $css string to parse
234
+     * @return string
235
+     */
236
+    private function filterOutRule(string $rule, string $css): string {
237
+        return preg_replace($rule, '', $css);
238
+    }
239
+
240
+    /**
241
+     * Add the correct uri prefix to make uri valid again
242
+     *
243
+     * @param string $css
244
+     * @param string $webDir
245
+     * @return string
246
+     */
247
+    private function rebaseUrls(string $css, string $webDir): string {
248
+        $re    = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x';
249
+        $subst = 'url(\'' . $webDir . '/$1\')';
250
+
251
+        return preg_replace($re, $subst, $css);
252
+    }
253
+
254
+    /**
255
+     * Remove all matches from the $rule regex
256
+     *
257
+     * @param string $css string to parse
258
+     * @return string
259
+     */
260
+    private function invertSvgIconsColor(string $css) {
261
+        return str_replace(['/000', '/fff', '/***'], ['/***', '/000', '/fff'], $css);
262
+    }
263
+
264
+    /**
265
+     * @return string SCSS code for variables from OC_Defaults
266
+     */
267
+    private function getInjectedVariables(): string {
268
+        if ($this->injectedVariables !== null) {
269
+            return $this->injectedVariables;
270
+        }
271
+        $variables = '';
272
+        foreach ($this->defaults->getScssVariables() as $key => $value) {
273
+            $variables .= '$' . $key . ': ' . $value . ';';
274
+        }
275
+
276
+        // check for valid variables / otherwise fall back to defaults
277
+        try {
278
+            $scss = new Compiler();
279
+            $scss->compile($variables);
280
+            $this->injectedVariables = $variables;
281
+        } catch (ParserException $e) {
282
+            $this->logger->error($e, ['app' => 'core']);
283
+        }
284
+        return $variables;
285
+    }
286 286
 }
Please login to merge, or discard this patch.
apps/accessibility/lib/Controller/ConfigController.php 2 patches
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -33,101 +33,101 @@
 block discarded – undo
33 33
 
34 34
 class ConfigController extends OCSController {
35 35
 
36
-	/** @var string */
37
-	protected $appName;
38
-
39
-	/** @var string */
40
-	protected $userId;
41
-
42
-	/** @var string */
43
-	protected $serverRoot;
44
-
45
-	/** @var IConfig */
46
-	private $config;
47
-
48
-	/** @var IUserSession */
49
-	private $userSession;
50
-
51
-	/** @var AccessibilityProvider */
52
-	private $accessibilityProvider;
53
-
54
-	/**
55
-	 * Config constructor.
56
-	 *
57
-	 * @param string $appName
58
-	 * @param IRequest $request
59
-	 * @param IConfig $config
60
-	 * @param IUserSession $userSession
61
-	 * @param AccessibilityProvider $accessibilityProvider
62
-	 */
63
-	public function __construct(string $appName,
64
-								IRequest $request,
65
-								IConfig $config,
66
-								IUserSession $userSession,
67
-								AccessibilityProvider $accessibilityProvider) {
68
-		parent::__construct($appName, $request);
69
-		$this->appName               = $appName;
70
-		$this->config                = $config;
71
-		$this->userSession           = $userSession;
72
-		$this->accessibilityProvider = $accessibilityProvider;
73
-		$this->userId				 = $userSession->getUser()->getUID();
74
-	}
75
-
76
-	/**
77
-	 * @NoAdminRequired
78
-	 *
79
-	 * Get user accessibility config
80
-	 *
81
-	 * @param string $key theme or font
82
-	 * @return DataResponse
83
-	 */
84
-	public function getConfig(): DataResponse {
85
-		return new DataResponse([
86
-			'theme' => $this->config->getUserValue($this->userId, $this->appName, 'theme', false),
87
-			'font' => $this->config->getUserValue($this->userId, $this->appName, 'font', false)
88
-		]);
89
-	}
90
-
91
-	/**
92
-	 * @NoAdminRequired
93
-	 *
94
-	 * Set theme or font config
95
-	 *
96
-	 * @param string $key theme or font
97
-	 * @return DataResponse
98
-	 * @throws Exception
99
-	 */
100
-	public function setConfig(string $key, $value): DataResponse {
101
-		if ($key === 'theme' || $key === 'font') {
102
-
103
-			if ($value === false) {
104
-				$this->config->deleteUserValue($this->userId, $this->appName, $key);
105
-				$userValues = $this->config->getUserKeys($this->userId, $this->appName);
106
-
107
-				// remove hash if no settings selected
108
-				if (count($userValues) === 1 && $userValues[0] === 'icons-css') {
109
-					$this->config->deleteUserValue($this->userId, $this->appName, 'icons-css');
110
-				}
111
-
112
-				return new DataResponse();
113
-			}
114
-
115
-			$themes = $this->accessibilityProvider->getThemes();
116
-			$fonts  = $this->accessibilityProvider->getFonts();
117
-
118
-			$availableOptions = array_map(function($option) {
119
-				return $option['id'];
120
-			}, array_merge($themes, $fonts));
121
-
122
-			if (in_array($value, $availableOptions)) {
123
-				$this->config->setUserValue($this->userId, $this->appName, $key, $value);
124
-				return new DataResponse();
125
-			}
126
-
127
-			throw new OCSBadRequestException('Invalid value: ' . $value);
128
-		}
129
-
130
-		throw new OCSBadRequestException('Invalid key: ' . $key);
131
-	}
36
+    /** @var string */
37
+    protected $appName;
38
+
39
+    /** @var string */
40
+    protected $userId;
41
+
42
+    /** @var string */
43
+    protected $serverRoot;
44
+
45
+    /** @var IConfig */
46
+    private $config;
47
+
48
+    /** @var IUserSession */
49
+    private $userSession;
50
+
51
+    /** @var AccessibilityProvider */
52
+    private $accessibilityProvider;
53
+
54
+    /**
55
+     * Config constructor.
56
+     *
57
+     * @param string $appName
58
+     * @param IRequest $request
59
+     * @param IConfig $config
60
+     * @param IUserSession $userSession
61
+     * @param AccessibilityProvider $accessibilityProvider
62
+     */
63
+    public function __construct(string $appName,
64
+                                IRequest $request,
65
+                                IConfig $config,
66
+                                IUserSession $userSession,
67
+                                AccessibilityProvider $accessibilityProvider) {
68
+        parent::__construct($appName, $request);
69
+        $this->appName               = $appName;
70
+        $this->config                = $config;
71
+        $this->userSession           = $userSession;
72
+        $this->accessibilityProvider = $accessibilityProvider;
73
+        $this->userId				 = $userSession->getUser()->getUID();
74
+    }
75
+
76
+    /**
77
+     * @NoAdminRequired
78
+     *
79
+     * Get user accessibility config
80
+     *
81
+     * @param string $key theme or font
82
+     * @return DataResponse
83
+     */
84
+    public function getConfig(): DataResponse {
85
+        return new DataResponse([
86
+            'theme' => $this->config->getUserValue($this->userId, $this->appName, 'theme', false),
87
+            'font' => $this->config->getUserValue($this->userId, $this->appName, 'font', false)
88
+        ]);
89
+    }
90
+
91
+    /**
92
+     * @NoAdminRequired
93
+     *
94
+     * Set theme or font config
95
+     *
96
+     * @param string $key theme or font
97
+     * @return DataResponse
98
+     * @throws Exception
99
+     */
100
+    public function setConfig(string $key, $value): DataResponse {
101
+        if ($key === 'theme' || $key === 'font') {
102
+
103
+            if ($value === false) {
104
+                $this->config->deleteUserValue($this->userId, $this->appName, $key);
105
+                $userValues = $this->config->getUserKeys($this->userId, $this->appName);
106
+
107
+                // remove hash if no settings selected
108
+                if (count($userValues) === 1 && $userValues[0] === 'icons-css') {
109
+                    $this->config->deleteUserValue($this->userId, $this->appName, 'icons-css');
110
+                }
111
+
112
+                return new DataResponse();
113
+            }
114
+
115
+            $themes = $this->accessibilityProvider->getThemes();
116
+            $fonts  = $this->accessibilityProvider->getFonts();
117
+
118
+            $availableOptions = array_map(function($option) {
119
+                return $option['id'];
120
+            }, array_merge($themes, $fonts));
121
+
122
+            if (in_array($value, $availableOptions)) {
123
+                $this->config->setUserValue($this->userId, $this->appName, $key, $value);
124
+                return new DataResponse();
125
+            }
126
+
127
+            throw new OCSBadRequestException('Invalid value: ' . $value);
128
+        }
129
+
130
+        throw new OCSBadRequestException('Invalid key: ' . $key);
131
+    }
132 132
 
133 133
 }
134 134
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare (strict_types = 1);
2
+declare(strict_types=1);
3 3
 /**
4 4
  * @copyright Copyright (c) 2018 John Molakvoæ (skjnldsv) <[email protected]>
5 5
  *
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 		$this->config                = $config;
71 71
 		$this->userSession           = $userSession;
72 72
 		$this->accessibilityProvider = $accessibilityProvider;
73
-		$this->userId				 = $userSession->getUser()->getUID();
73
+		$this->userId = $userSession->getUser()->getUID();
74 74
 	}
75 75
 
76 76
 	/**
@@ -124,10 +124,10 @@  discard block
 block discarded – undo
124 124
 				return new DataResponse();
125 125
 			}
126 126
 
127
-			throw new OCSBadRequestException('Invalid value: ' . $value);
127
+			throw new OCSBadRequestException('Invalid value: '.$value);
128 128
 		}
129 129
 
130
-		throw new OCSBadRequestException('Invalid key: ' . $key);
130
+		throw new OCSBadRequestException('Invalid key: '.$key);
131 131
 	}
132 132
 
133 133
 }
134 134
\ No newline at end of file
Please login to merge, or discard this patch.
apps/accessibility/lib/AppInfo/Application.php 2 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -30,54 +30,54 @@
 block discarded – undo
30 30
 
31 31
 class Application extends App {
32 32
 
33
-	/** @var string */
34
-	protected $appName = 'accessibility';
33
+    /** @var string */
34
+    protected $appName = 'accessibility';
35 35
 
36
-	/** @var IConfig */
37
-	private $config;
36
+    /** @var IConfig */
37
+    private $config;
38 38
 
39
-	/** @var IUserSession */
40
-	private $userSession;
39
+    /** @var IUserSession */
40
+    private $userSession;
41 41
 
42
-	/** @var IURLGenerator */
43
-	private $urlGenerator;
42
+    /** @var IURLGenerator */
43
+    private $urlGenerator;
44 44
 
45
-	public function __construct() {
46
-		parent::__construct($this->appName);
47
-		$this->config       = \OC::$server->getConfig();
48
-		$this->userSession  = \OC::$server->getUserSession();
49
-		$this->urlGenerator = \OC::$server->getURLGenerator();
50
-	}
45
+    public function __construct() {
46
+        parent::__construct($this->appName);
47
+        $this->config       = \OC::$server->getConfig();
48
+        $this->userSession  = \OC::$server->getUserSession();
49
+        $this->urlGenerator = \OC::$server->getURLGenerator();
50
+    }
51 51
 
52
-	public function injectCss() {
53
-		// Inject the fake css on all pages if enabled and user is logged
54
-		$loggedUser = $this->userSession->getUser();
55
-		if (!is_null($loggedUser)) {
56
-			$userValues = $this->config->getUserKeys($loggedUser->getUID(), $this->appName);
57
-			// we want to check if any theme or font is enabled.
58
-			if (count($userValues) > 0) {
59
-				$hash = $this->config->getUserValue($loggedUser->getUID(), $this->appName, 'icons-css', md5(implode('-', $userValues)));
60
-				$linkToCSS = $this->urlGenerator->linkToRoute($this->appName . '.accessibility.getCss', ['md5' => $hash]);
61
-				\OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]);
62
-			}
63
-		}
64
-	}
52
+    public function injectCss() {
53
+        // Inject the fake css on all pages if enabled and user is logged
54
+        $loggedUser = $this->userSession->getUser();
55
+        if (!is_null($loggedUser)) {
56
+            $userValues = $this->config->getUserKeys($loggedUser->getUID(), $this->appName);
57
+            // we want to check if any theme or font is enabled.
58
+            if (count($userValues) > 0) {
59
+                $hash = $this->config->getUserValue($loggedUser->getUID(), $this->appName, 'icons-css', md5(implode('-', $userValues)));
60
+                $linkToCSS = $this->urlGenerator->linkToRoute($this->appName . '.accessibility.getCss', ['md5' => $hash]);
61
+                \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]);
62
+            }
63
+        }
64
+    }
65 65
 
66
-	public function injectJavascript() {
67
-		$linkToJs = $this->urlGenerator->linkToRoute(
68
-			$this->appName . '.accessibility.getJavascript',
69
-			[
70
-				'v' => \OC::$server->getConfig()->getAppValue('accessibility', 'cachebuster', '0'),
71
-			]
72
-		);
66
+    public function injectJavascript() {
67
+        $linkToJs = $this->urlGenerator->linkToRoute(
68
+            $this->appName . '.accessibility.getJavascript',
69
+            [
70
+                'v' => \OC::$server->getConfig()->getAppValue('accessibility', 'cachebuster', '0'),
71
+            ]
72
+        );
73 73
 
74
-		\OCP\Util::addHeader(
75
-			'script',
76
-			[
77
-				'src' => $linkToJs,
78
-				'nonce' => \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
79
-			],
80
-			''
81
-		);
82
-	}
74
+        \OCP\Util::addHeader(
75
+            'script',
76
+            [
77
+                'src' => $linkToJs,
78
+                'nonce' => \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
79
+            ],
80
+            ''
81
+        );
82
+    }
83 83
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 			// we want to check if any theme or font is enabled.
58 58
 			if (count($userValues) > 0) {
59 59
 				$hash = $this->config->getUserValue($loggedUser->getUID(), $this->appName, 'icons-css', md5(implode('-', $userValues)));
60
-				$linkToCSS = $this->urlGenerator->linkToRoute($this->appName . '.accessibility.getCss', ['md5' => $hash]);
60
+				$linkToCSS = $this->urlGenerator->linkToRoute($this->appName.'.accessibility.getCss', ['md5' => $hash]);
61 61
 				\OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]);
62 62
 			}
63 63
 		}
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
 	public function injectJavascript() {
67 67
 		$linkToJs = $this->urlGenerator->linkToRoute(
68
-			$this->appName . '.accessibility.getJavascript',
68
+			$this->appName.'.accessibility.getJavascript',
69 69
 			[
70 70
 				'v' => \OC::$server->getConfig()->getAppValue('accessibility', 'cachebuster', '0'),
71 71
 			]
Please login to merge, or discard this patch.