Completed
Pull Request — master (#9862)
by John
17:51
created
apps/accessibility/templates/settings-personal.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,5 +25,5 @@
 block discarded – undo
25 25
 style('accessibility', 'style');
26 26
 ?>
27 27
 
28
-<span id="serverData" data-server="<?php p(json_encode($_['serverData']));?>"></span>
28
+<span id="serverData" data-server="<?php p(json_encode($_['serverData'])); ?>"></span>
29 29
 <span id="accessibility"></span>
30 30
\ No newline at end of file
Please login to merge, or discard this patch.
apps/accessibility/lib/Settings/PersonalSection.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -29,72 +29,72 @@
 block discarded – undo
29 29
 
30 30
 class PersonalSection implements IIconSection {
31 31
 
32
-	/** @var string */
33
-	protected $appName;
32
+    /** @var string */
33
+    protected $appName;
34 34
 
35
-	/** @var IURLGenerator */
36
-	private $urlGenerator;
35
+    /** @var IURLGenerator */
36
+    private $urlGenerator;
37 37
 
38
-	/** @var IL10N */
39
-	private $l;
38
+    /** @var IL10N */
39
+    private $l;
40 40
 
41
-	/**
42
-	 * Personal Section constructor.
43
-	 *
44
-	 * @param string $appName
45
-	 * @param IURLGenerator $urlGenerator
46
-	 * @param IL10N $l
47
-	 */
48
-	public function __construct(string $appName,
49
-								IURLGenerator $urlGenerator,
50
-								IL10N $l) {
51
-		$this->appName      = $appName;
52
-		$this->urlGenerator = $urlGenerator;
53
-		$this->l            = $l;
54
-	}
41
+    /**
42
+     * Personal Section constructor.
43
+     *
44
+     * @param string $appName
45
+     * @param IURLGenerator $urlGenerator
46
+     * @param IL10N $l
47
+     */
48
+    public function __construct(string $appName,
49
+                                IURLGenerator $urlGenerator,
50
+                                IL10N $l) {
51
+        $this->appName      = $appName;
52
+        $this->urlGenerator = $urlGenerator;
53
+        $this->l            = $l;
54
+    }
55 55
 
56
-	/**
57
-	 * returns the relative path to an 16*16 icon describing the section.
58
-	 * e.g. '/core/img/places/files.svg'
59
-	 *
60
-	 * @returns string
61
-	 * @since 13.0.0
62
-	 */
63
-	public function getIcon() {
64
-		return $this->urlGenerator->imagePath($this->appName, 'app-dark.svg');
65
-	}
56
+    /**
57
+     * returns the relative path to an 16*16 icon describing the section.
58
+     * e.g. '/core/img/places/files.svg'
59
+     *
60
+     * @returns string
61
+     * @since 13.0.0
62
+     */
63
+    public function getIcon() {
64
+        return $this->urlGenerator->imagePath($this->appName, 'app-dark.svg');
65
+    }
66 66
 
67
-	/**
68
-	 * returns the ID of the section. It is supposed to be a lower case string,
69
-	 * e.g. 'ldap'
70
-	 *
71
-	 * @returns string
72
-	 * @since 9.1
73
-	 */
74
-	public function getID() {
75
-		return $this->appName;
76
-	}
67
+    /**
68
+     * returns the ID of the section. It is supposed to be a lower case string,
69
+     * e.g. 'ldap'
70
+     *
71
+     * @returns string
72
+     * @since 9.1
73
+     */
74
+    public function getID() {
75
+        return $this->appName;
76
+    }
77 77
 
78
-	/**
79
-	 * returns the translated name as it should be displayed, e.g. 'LDAP / AD
80
-	 * integration'. Use the L10N service to translate it.
81
-	 *
82
-	 * @return string
83
-	 * @since 9.1
84
-	 */
85
-	public function getName() {
86
-		return $this->l->t('Accessibility');
87
-	}
78
+    /**
79
+     * returns the translated name as it should be displayed, e.g. 'LDAP / AD
80
+     * integration'. Use the L10N service to translate it.
81
+     *
82
+     * @return string
83
+     * @since 9.1
84
+     */
85
+    public function getName() {
86
+        return $this->l->t('Accessibility');
87
+    }
88 88
 
89
-	/**
90
-	 * @return int whether the form should be rather on the top or bottom of
91
-	 * the settings navigation. The sections are arranged in ascending order of
92
-	 * the priority values. It is required to return a value between 0 and 99.
93
-	 *
94
-	 * E.g.: 70
95
-	 * @since 9.1
96
-	 */
97
-	public function getPriority() {
98
-		return 15;
99
-	}
89
+    /**
90
+     * @return int whether the form should be rather on the top or bottom of
91
+     * the settings navigation. The sections are arranged in ascending order of
92
+     * the priority values. It is required to return a value between 0 and 99.
93
+     *
94
+     * E.g.: 70
95
+     * @since 9.1
96
+     */
97
+    public function getPriority() {
98
+        return 15;
99
+    }
100 100
 }
Please login to merge, or discard this patch.
apps/accessibility/lib/Settings/Personal.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -33,81 +33,81 @@
 block discarded – undo
33 33
 
34 34
 class Personal implements ISettings {
35 35
 
36
-	/** @var string */
37
-	protected $appName;
36
+    /** @var string */
37
+    protected $appName;
38 38
 
39
-	/** @var IConfig */
40
-	private $config;
39
+    /** @var IConfig */
40
+    private $config;
41 41
 
42
-	/** @var IUserSession */
43
-	private $userSession;
42
+    /** @var IUserSession */
43
+    private $userSession;
44 44
 
45
-	/** @var IL10N */
46
-	private $l;
45
+    /** @var IL10N */
46
+    private $l;
47 47
 
48
-	/** @var IURLGenerator */
49
-	private $urlGenerator;
48
+    /** @var IURLGenerator */
49
+    private $urlGenerator;
50 50
 
51
-	/** @var AccessibilityProvider */
52
-	private $accessibilityProvider;
51
+    /** @var AccessibilityProvider */
52
+    private $accessibilityProvider;
53 53
 
54
-	/**
55
-	 * Settings constructor.
56
-	 *
57
-	 * @param string $appName
58
-	 * @param IConfig $config
59
-	 * @param IUserSession $userSession
60
-	 * @param IL10N $l
61
-	 * @param IURLGenerator $urlGenerator
62
-	 * @param AccessibilityProvider $accessibilityProvider
63
-	 */
64
-	public function __construct(string $appName,
65
-								IConfig $config,
66
-								IUserSession $userSession,
67
-								IL10N $l,
68
-								IURLGenerator $urlGenerator,
69
-								AccessibilityProvider $accessibilityProvider) {
70
-		$this->appName               = $appName;
71
-		$this->config                = $config;
72
-		$this->userSession           = $userSession;
73
-		$this->l                     = $l;
74
-		$this->urlGenerator          = $urlGenerator;
75
-		$this->accessibilityProvider = $accessibilityProvider;
76
-	}
54
+    /**
55
+     * Settings constructor.
56
+     *
57
+     * @param string $appName
58
+     * @param IConfig $config
59
+     * @param IUserSession $userSession
60
+     * @param IL10N $l
61
+     * @param IURLGenerator $urlGenerator
62
+     * @param AccessibilityProvider $accessibilityProvider
63
+     */
64
+    public function __construct(string $appName,
65
+                                IConfig $config,
66
+                                IUserSession $userSession,
67
+                                IL10N $l,
68
+                                IURLGenerator $urlGenerator,
69
+                                AccessibilityProvider $accessibilityProvider) {
70
+        $this->appName               = $appName;
71
+        $this->config                = $config;
72
+        $this->userSession           = $userSession;
73
+        $this->l                     = $l;
74
+        $this->urlGenerator          = $urlGenerator;
75
+        $this->accessibilityProvider = $accessibilityProvider;
76
+    }
77 77
 
78
-	/**
79
-	 * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
80
-	 * @since 9.1
81
-	 */
82
-	public function getForm() {
78
+    /**
79
+     * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
80
+     * @since 9.1
81
+     */
82
+    public function getForm() {
83 83
 
84
-		$serverData = [
85
-			'themes' => $this->accessibilityProvider->getThemes(),
86
-			'fonts'  => $this->accessibilityProvider->getFonts(),
87
-			'theme'  => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false),
88
-			'font'   => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false)
89
-		];
84
+        $serverData = [
85
+            'themes' => $this->accessibilityProvider->getThemes(),
86
+            'fonts'  => $this->accessibilityProvider->getFonts(),
87
+            'theme'  => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false),
88
+            'font'   => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false)
89
+        ];
90 90
 
91
-		return new TemplateResponse($this->appName, 'settings-personal', ['serverData' => $serverData]);
92
-	}
91
+        return new TemplateResponse($this->appName, 'settings-personal', ['serverData' => $serverData]);
92
+    }
93 93
 
94
-	/**
95
-	 * @return string the section ID, e.g. 'sharing'
96
-	 * @since 9.1
97
-	 */
98
-	public function getSection() {
99
-		return $this->appName;
100
-	}
94
+    /**
95
+     * @return string the section ID, e.g. 'sharing'
96
+     * @since 9.1
97
+     */
98
+    public function getSection() {
99
+        return $this->appName;
100
+    }
101 101
 
102
-	/**
103
-	 * @return int whether the form should be rather on the top or bottom of
104
-	 * the admin section. The forms are arranged in ascending order of the
105
-	 * priority values. It is required to return a value between 0 and 100.
106
-	 *
107
-	 * E.g.: 70
108
-	 * @since 9.1
109
-	 */
110
-	public function getPriority() {
111
-		return 40;
112
-	}
102
+    /**
103
+     * @return int whether the form should be rather on the top or bottom of
104
+     * the admin section. The forms are arranged in ascending order of the
105
+     * priority values. It is required to return a value between 0 and 100.
106
+     *
107
+     * E.g.: 70
108
+     * @since 9.1
109
+     */
110
+    public function getPriority() {
111
+        return 40;
112
+    }
113 113
 }
Please login to merge, or discard this patch.
apps/accessibility/lib/Controller/ConfigController.php 4 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,6 @@
 block discarded – undo
74 74
 	 *
75 75
 	 * Get user accessibility config
76 76
 	 *
77
-	 * @param string $key theme or font
78 77
 	 * @return DataResponse
79 78
 	 */
80 79
 	public function getConfig(): DataResponse {
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,6 @@
 block discarded – undo
23 23
 namespace OCA\Accessibility\Controller;
24 24
 
25 25
 use OCA\Accessibility\AccessibilityProvider;
26
-use OCP\AppFramework\Http;
27 26
 use OCP\AppFramework\Http\DataResponse;
28 27
 use OCP\AppFramework\OCSController;
29 28
 use OCP\AppFramework\OCS\OCSBadRequestException;
Please login to merge, or discard this patch.
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -33,89 +33,89 @@
 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 $serverRoot;
41
-
42
-	/** @var IConfig */
43
-	private $config;
44
-
45
-	/** @var IUserSession */
46
-	private $userSession;
47
-
48
-	/** @var AccessibilityProvider */
49
-	private $accessibilityProvider;
50
-
51
-	/**
52
-	 * Config constructor.
53
-	 *
54
-	 * @param string $appName
55
-	 * @param IRequest $request
56
-	 * @param IConfig $config
57
-	 * @param IUserSession $userSession
58
-	 * @param AccessibilityProvider $accessibilityProvider
59
-	 */
60
-	public function __construct(string $appName,
61
-								IRequest $request,
62
-								IConfig $config,
63
-								IUserSession $userSession,
64
-								AccessibilityProvider $accessibilityProvider) {
65
-		parent::__construct($appName, $request);
66
-		$this->appName               = $appName;
67
-		$this->config                = $config;
68
-		$this->userSession           = $userSession;
69
-		$this->accessibilityProvider = $accessibilityProvider;
70
-	}
71
-
72
-	/**
73
-	 * @NoAdminRequired
74
-	 *
75
-	 * Get user accessibility config
76
-	 *
77
-	 * @param string $key theme or font
78
-	 * @return DataResponse
79
-	 */
80
-	public function getConfig(): DataResponse {
81
-		return new DataResponse([
82
-			'theme' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false),
83
-			'font' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false)
84
-		]);
85
-	}
86
-
87
-	/**
88
-	 * @NoAdminRequired
89
-	 *
90
-	 * Set theme or font config
91
-	 *
92
-	 * @param string $key theme or font
93
-	 * @return DataResponse
94
-	 * @throws Exception
95
-	 */
96
-	public function setConfig(string $key, $value): DataResponse {
97
-		if ($key === 'theme' || $key === 'font') {
98
-			$themes = $this->accessibilityProvider->getThemes();
99
-			$fonts  = $this->accessibilityProvider->getFonts();
100
-
101
-			if ($value === false) {
102
-				$this->config->deleteUserValue($this->userSession->getUser()->getUID(), $this->appName, $key);
103
-				return new DataResponse();
104
-			}
105
-
106
-			$availableOptions = array_map(function($option) {
107
-				return $option['id'];
108
-			}, array_merge($themes, $fonts));
109
-
110
-			if (in_array($value, $availableOptions)) {
111
-				$this->config->setUserValue($this->userSession->getUser()->getUID(), $this->appName, $key, $value);
112
-				return new DataResponse();
113
-			}
114
-
115
-			throw new OCSBadRequestException('Invalid value: ' . $value);
116
-		}
117
-
118
-		throw new OCSBadRequestException('Invalid key: ' . $key);
119
-	}
36
+    /** @var string */
37
+    protected $appName;
38
+
39
+    /** @var string */
40
+    protected $serverRoot;
41
+
42
+    /** @var IConfig */
43
+    private $config;
44
+
45
+    /** @var IUserSession */
46
+    private $userSession;
47
+
48
+    /** @var AccessibilityProvider */
49
+    private $accessibilityProvider;
50
+
51
+    /**
52
+     * Config constructor.
53
+     *
54
+     * @param string $appName
55
+     * @param IRequest $request
56
+     * @param IConfig $config
57
+     * @param IUserSession $userSession
58
+     * @param AccessibilityProvider $accessibilityProvider
59
+     */
60
+    public function __construct(string $appName,
61
+                                IRequest $request,
62
+                                IConfig $config,
63
+                                IUserSession $userSession,
64
+                                AccessibilityProvider $accessibilityProvider) {
65
+        parent::__construct($appName, $request);
66
+        $this->appName               = $appName;
67
+        $this->config                = $config;
68
+        $this->userSession           = $userSession;
69
+        $this->accessibilityProvider = $accessibilityProvider;
70
+    }
71
+
72
+    /**
73
+     * @NoAdminRequired
74
+     *
75
+     * Get user accessibility config
76
+     *
77
+     * @param string $key theme or font
78
+     * @return DataResponse
79
+     */
80
+    public function getConfig(): DataResponse {
81
+        return new DataResponse([
82
+            'theme' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false),
83
+            'font' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false)
84
+        ]);
85
+    }
86
+
87
+    /**
88
+     * @NoAdminRequired
89
+     *
90
+     * Set theme or font config
91
+     *
92
+     * @param string $key theme or font
93
+     * @return DataResponse
94
+     * @throws Exception
95
+     */
96
+    public function setConfig(string $key, $value): DataResponse {
97
+        if ($key === 'theme' || $key === 'font') {
98
+            $themes = $this->accessibilityProvider->getThemes();
99
+            $fonts  = $this->accessibilityProvider->getFonts();
100
+
101
+            if ($value === false) {
102
+                $this->config->deleteUserValue($this->userSession->getUser()->getUID(), $this->appName, $key);
103
+                return new DataResponse();
104
+            }
105
+
106
+            $availableOptions = array_map(function($option) {
107
+                return $option['id'];
108
+            }, array_merge($themes, $fonts));
109
+
110
+            if (in_array($value, $availableOptions)) {
111
+                $this->config->setUserValue($this->userSession->getUser()->getUID(), $this->appName, $key, $value);
112
+                return new DataResponse();
113
+            }
114
+
115
+            throw new OCSBadRequestException('Invalid value: ' . $value);
116
+        }
117
+
118
+        throw new OCSBadRequestException('Invalid key: ' . $key);
119
+    }
120 120
 
121 121
 }
122 122
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 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
  *
@@ -112,10 +112,10 @@  discard block
 block discarded – undo
112 112
 				return new DataResponse();
113 113
 			}
114 114
 
115
-			throw new OCSBadRequestException('Invalid value: ' . $value);
115
+			throw new OCSBadRequestException('Invalid value: '.$value);
116 116
 		}
117 117
 
118
-		throw new OCSBadRequestException('Invalid key: ' . $key);
118
+		throw new OCSBadRequestException('Invalid key: '.$key);
119 119
 	}
120 120
 
121 121
 }
122 122
\ No newline at end of file
Please login to merge, or discard this patch.
apps/accessibility/appinfo/routes.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,15 +26,15 @@
 block discarded – undo
26 26
         ['name' => 'accessibility#getCss', 'url' => '/css/user-{md5}.css', 'verb' => 'GET'],
27 27
     ],
28 28
     'ocs' => [
29
-		[
30
-			'name' => 'Config#getConfig',
31
-			'url'  => '/api/v1/config',
32
-			'verb' => 'GET',
29
+        [
30
+            'name' => 'Config#getConfig',
31
+            'url'  => '/api/v1/config',
32
+            'verb' => 'GET',
33
+        ],
34
+        [
35
+            'name' => 'Config#setConfig',
36
+            'url'  => '/api/v1/config/{key}',
37
+            'verb' => 'POST',
33 38
         ],
34
-		[
35
-			'name' => 'Config#setConfig',
36
-			'url'  => '/api/v1/config/{key}',
37
-			'verb' => 'POST',
38
-		],
39 39
     ]
40 40
 ];
Please login to merge, or discard this patch.
apps/accessibility/lib/AccessibilityProvider.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -29,61 +29,61 @@
 block discarded – undo
29 29
 
30 30
 class AccessibilityProvider {
31 31
 
32
-	/** @var string */
33
-	protected $appName;
32
+    /** @var string */
33
+    protected $appName;
34 34
 
35
-	/** @var IURLGenerator */
36
-	private $urlGenerator;
35
+    /** @var IURLGenerator */
36
+    private $urlGenerator;
37 37
 
38
-	/** @var IL10N */
39
-	private $l;
38
+    /** @var IL10N */
39
+    private $l;
40 40
 
41
-	/**
42
-	 * Account constructor.
43
-	 *
44
-	 * @param string $appName
45
-	 * @param IURLGenerator $urlGenerator
46
-	 * @param IL10N $l
47
-	 */
48
-	public function __construct(string $appName,
49
-								IURLGenerator $urlGenerator,
50
-								IL10N $l) {
51
-		$this->appName      = $appName;
52
-		$this->urlGenerator = $urlGenerator;
53
-		$this->l            = $l;
54
-	}
41
+    /**
42
+     * Account constructor.
43
+     *
44
+     * @param string $appName
45
+     * @param IURLGenerator $urlGenerator
46
+     * @param IL10N $l
47
+     */
48
+    public function __construct(string $appName,
49
+                                IURLGenerator $urlGenerator,
50
+                                IL10N $l) {
51
+        $this->appName      = $appName;
52
+        $this->urlGenerator = $urlGenerator;
53
+        $this->l            = $l;
54
+    }
55 55
 
56
-	public function getThemes() {
57
-		return array(
58
-			[
59
-				'id'    => 'themehighcontrast',
60
-				'img'   => $this->urlGenerator->imagePath($this->appName, 'theme-highcontrast.jpg'),
61
-				'title' => $this->l->t('High Contrast theme'),
62
-				'text'  => $this->l->t('A high contrast theme to ease your navigation. Visual quality will be reduced but clarity will be increased.')
63
-			], [
64
-				'id'    => 'themedark',
65
-				'img'   => $this->urlGenerator->imagePath($this->appName, 'theme-dark.jpg'),
66
-				'title' => $this->l->t('Dark theme'),
67
-				'text'  => $this->l->t('A dark theme to ease your eyes by reducing the overall luminosity and brightness of your navigation. This is suitable for people who use computes a lot or in low luminosity spaces.')
68
-			]
69
-		);
70
-	}
56
+    public function getThemes() {
57
+        return array(
58
+            [
59
+                'id'    => 'themehighcontrast',
60
+                'img'   => $this->urlGenerator->imagePath($this->appName, 'theme-highcontrast.jpg'),
61
+                'title' => $this->l->t('High Contrast theme'),
62
+                'text'  => $this->l->t('A high contrast theme to ease your navigation. Visual quality will be reduced but clarity will be increased.')
63
+            ], [
64
+                'id'    => 'themedark',
65
+                'img'   => $this->urlGenerator->imagePath($this->appName, 'theme-dark.jpg'),
66
+                'title' => $this->l->t('Dark theme'),
67
+                'text'  => $this->l->t('A dark theme to ease your eyes by reducing the overall luminosity and brightness of your navigation. This is suitable for people who use computes a lot or in low luminosity spaces.')
68
+            ]
69
+        );
70
+    }
71 71
 
72
-	public function getFonts() {
73
-		return array(
74
-			[
75
-				'id'    => 'fontdyslexic',
76
-				'img'   => $this->urlGenerator->imagePath($this->appName, 'font-opendyslexic.jpg'),
77
-				'title' => $this->l->t('Dyslexia font'),
78
-				'text'  => $this->l->t('OpenDyslexic is a free typeface/font designed to mitigate some of the common reading errors caused by dyslexia. The typeface was created by Abelardo Gonzalez, who released it through an open-source license.')
79
-			],
80
-			[
81
-				'id'    => 'fonthighcontrast',
82
-				'img'   => $this->urlGenerator->imagePath($this->appName, 'font-highcontrast.jpg'),
83
-				'title' => $this->l->t('High Contrast font'),
84
-				'text'  => $this->l->t('Increase the weight of the font to improve the readability.')
85
-			]
86
-		);
87
-	}
72
+    public function getFonts() {
73
+        return array(
74
+            [
75
+                'id'    => 'fontdyslexic',
76
+                'img'   => $this->urlGenerator->imagePath($this->appName, 'font-opendyslexic.jpg'),
77
+                'title' => $this->l->t('Dyslexia font'),
78
+                'text'  => $this->l->t('OpenDyslexic is a free typeface/font designed to mitigate some of the common reading errors caused by dyslexia. The typeface was created by Abelardo Gonzalez, who released it through an open-source license.')
79
+            ],
80
+            [
81
+                'id'    => 'fonthighcontrast',
82
+                'img'   => $this->urlGenerator->imagePath($this->appName, 'font-highcontrast.jpg'),
83
+                'title' => $this->l->t('High Contrast font'),
84
+                'text'  => $this->l->t('Increase the weight of the font to improve the readability.')
85
+            ]
86
+        );
87
+    }
88 88
 
89 89
 }
90 90
\ No newline at end of file
Please login to merge, or discard this patch.
apps/accessibility/lib/AppInfo/Application.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -30,34 +30,34 @@
 block discarded – undo
30 30
 
31 31
 class Application extends App {
32 32
 
33
-	/** @var string */
34
-	protected $appName = 'accessibility';
35
-
36
-	/** @var IConfig */
37
-	private $config;
38
-
39
-	/** @var IUserSession */
40
-	private $userSession;
41
-
42
-	/** @var IURLGenerator */
43
-	private $urlGenerator;
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
-	}
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
-			if (count($userValues) > 0) {
58
-				$linkToCSS = $this->urlGenerator->linkToRoute($this->appName . '.accessibility.getCss', ['md5' => md5(implode('-', $userValues))]);
59
-				\OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]);
60
-			}
61
-		}
62
-	}
33
+    /** @var string */
34
+    protected $appName = 'accessibility';
35
+
36
+    /** @var IConfig */
37
+    private $config;
38
+
39
+    /** @var IUserSession */
40
+    private $userSession;
41
+
42
+    /** @var IURLGenerator */
43
+    private $urlGenerator;
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
+    }
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
+            if (count($userValues) > 0) {
58
+                $linkToCSS = $this->urlGenerator->linkToRoute($this->appName . '.accessibility.getCss', ['md5' => md5(implode('-', $userValues))]);
59
+                \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]);
60
+            }
61
+        }
62
+    }
63 63
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 		if (!is_null($loggedUser)) {
56 56
 			$userValues = $this->config->getUserKeys($loggedUser->getUID(), $this->appName);
57 57
 			if (count($userValues) > 0) {
58
-				$linkToCSS = $this->urlGenerator->linkToRoute($this->appName . '.accessibility.getCss', ['md5' => md5(implode('-', $userValues))]);
58
+				$linkToCSS = $this->urlGenerator->linkToRoute($this->appName.'.accessibility.getCss', ['md5' => md5(implode('-', $userValues))]);
59 59
 				\OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]);
60 60
 			}
61 61
 		}
Please login to merge, or discard this patch.
apps/accessibility/appinfo/app.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 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æ <[email protected]>
5 5
  *
Please login to merge, or discard this patch.
apps/accessibility/lib/Controller/AccessibilityController.php 2 patches
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -39,190 +39,190 @@
 block discarded – undo
39 39
 
40 40
 class AccessibilityController extends Controller {
41 41
 
42
-	/** @var string */
43
-	protected $appName;
44
-
45
-	/** @var string */
46
-	protected $serverRoot;
47
-
48
-	/** @var IConfig */
49
-	private $config;
50
-
51
-	/** @var IUserManager */
52
-	private $userManager;
53
-
54
-	/** @var ILogger */
55
-	private $logger;
56
-
57
-	/** @var IURLGenerator */
58
-	private $urlGenerator;
59
-
60
-	/** @var ITimeFactory */
61
-	protected $timeFactory;
62
-
63
-	/** @var IUserSession */
64
-	private $userSession;
65
-
66
-	/** @var IAppManager */
67
-	private $appManager;
68
-
69
-	/**
70
-	 * Account constructor.
71
-	 *
72
-	 * @param string $appName
73
-	 * @param IRequest $request
74
-	 * @param IConfig $config
75
-	 * @param IUserManager $userManager
76
-	 * @param ILogger $logger
77
-	 * @param IURLGenerator $urlGenerator
78
-	 * @param ITimeFactory $timeFactory
79
-	 * @param IUserSession $userSession
80
-	 * @param IAppManager $appManager
81
-	 */
82
-	public function __construct(string $appName,
83
-								IRequest $request,
84
-								IConfig $config,
85
-								IUserManager $userManager,
86
-								ILogger $logger,
87
-								IURLGenerator $urlGenerator,
88
-								ITimeFactory $timeFactory,
89
-								IUserSession $userSession,
90
-								IAppManager $appManager) {
91
-		parent::__construct($appName, $request);
92
-		$this->appName      = $appName;
93
-		$this->config       = $config;
94
-		$this->userManager  = $userManager;
95
-		$this->logger       = $logger;
96
-		$this->urlGenerator = $urlGenerator;
97
-		$this->timeFactory  = $timeFactory;
98
-		$this->userSession  = $userSession;
99
-		$this->appManager   = $appManager;
100
-
101
-		$this->serverRoot = \OC::$SERVERROOT;
102
-		$this->appRoot    = $this->appManager->getAppPath($this->appName);
103
-	}
104
-
105
-	/**
106
-	 * @NoAdminRequired
107
-	 * @NoCSRFRequired
108
-	 *
109
-	 * @return DataDisplayResponse
110
-	 */
111
-	public function getCss(): DataDisplayResponse {
112
-		$css     = '';
113
-		$imports = '';
114
-		$userValues = $this->getUserValues();
115
-
116
-		foreach ($userValues as $key => $scssFile) {
117
-			if ($scssFile !== false) {
118
-				$imports .= '@import "' . $scssFile . '";';
119
-			}
120
-		}
121
-
122
-		if ($imports !== '') {
123
-			$scss = new Compiler();
124
-			$scss->setImportPaths([
125
-				$this->appRoot . '/css/',
126
-				$this->serverRoot . '/core/css/'
127
-			]);
128
-
129
-			// Continue after throw
130
-			$scss->setIgnoreErrors(true);
131
-			$scss->setFormatter(Crunched::class);
132
-
133
-			// Import theme, variables and compile css4 variables
134
-			try {
135
-				$css .= $scss->compile(
136
-					$imports .
137
-					'@import "variables.scss";' .
138
-					'@import "css-variables.scss";'
139
-				);
140
-			} catch (ParserException $e) {
141
-				$this->logger->error($e->getMessage(), ['app' => 'core']);
142
-			}
143
-		}
144
-
145
-		// We don't want to override vars with url since path is different
146
-		$css = $this->filterOutRule('/--[a-z-:]+url\([^;]+\)/mi', $css);
147
-
148
-		// Calculate exact absolute path to file
149
-		$path = $this->urlGenerator->linkToRoute($this->appName . '.accessibility.getCss', ['md5' => md5(implode('-', $userValues))]);
150
-		$path = explode('/', $this->serverRoot . $path);
151
-		array_pop($path);
152
-		$path = implode('/', $path);
153
-		$webDir = $this->getWebDir($path, $this->appName, $this->serverRoot, \OC::$WEBROOT);
154
-
155
-		// Rebase all urls
156
-		$css = $this->rebaseUrls($css, $webDir);
157
-
158
-		$response = new DataDisplayResponse($css, Http::STATUS_OK, ['Content-Type' => 'text/css']);
159
-
160
-		// Set cache control
161
-		$ttl = 31536000;
162
-		$response->addHeader('Cache-Control', 'max-age=' . $ttl . ', immutable');
163
-		$expires = new \DateTime();
164
-		$expires->setTimestamp($this->timeFactory->getTime());
165
-		$expires->add(new \DateInterval('PT' . $ttl . 'S'));
166
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
167
-		$response->addHeader('Pragma', 'cache');
168
-
169
-		return $response;
170
-	}
171
-
172
-	/**
173
-	 * Return an array with the user theme & font settings
174
-	 *
175
-	 * @return array
176
-	 */
177
-	private function getUserValues(): array{
178
-		$userTheme = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false);
179
-		$userFont  = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false);
180
-
181
-		return [$userTheme, $userFont];
182
-	}
183
-
184
-	/**
185
-	 * Remove all matches from the $rule regex
186
-	 *
187
-	 * @param string $rule regex to match
188
-	 * @param string $css string to parse
189
-	 * @return string
190
-	 */
191
-	private function filterOutRule(string $rule, string $css): string {
192
-		return preg_replace($rule, '', $css);
193
-	}
194
-
195
-	/**
196
-	 * Add the correct uri prefix to make uri valid again
197
-	 *
198
-	 * @param string $css
199
-	 * @param string $webDir
200
-	 * @return string
201
-	 */
202
-	private function rebaseUrls(string $css, string $webDir): string {
203
-		$re    = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x';
204
-		$subst = 'url(\'' . $webDir . '/$1\')';
205
-
206
-		return preg_replace($re, $subst, $css);
207
-	}
208
-
209
-	/**
210
-	 * Get WebDir root
211
-	 * @param string $path the css file path
212
-	 * @param string $appName the app name
213
-	 * @param string $serverRoot the server root path
214
-	 * @param string $webRoot the nextcloud installation root path
215
-	 * @return string the webDir
216
-	 */
217
-	private function getWebDir(string $path, string $appName, string $serverRoot, string $webRoot): string {
218
-		// Detect if path is within server root AND if path is within an app path
219
-		if ( strpos($path, $serverRoot) === false && $appWebPath = \OC_App::getAppWebPath($appName)) {
220
-			// Get the file path within the app directory
221
-			$appDirectoryPath = explode($appName, $path)[1];
222
-			// Remove the webroot
223
-			return str_replace($webRoot, '', $appWebPath.$appDirectoryPath);
224
-		}
225
-		return $webRoot.substr($path, strlen($serverRoot));
226
-	}
42
+    /** @var string */
43
+    protected $appName;
44
+
45
+    /** @var string */
46
+    protected $serverRoot;
47
+
48
+    /** @var IConfig */
49
+    private $config;
50
+
51
+    /** @var IUserManager */
52
+    private $userManager;
53
+
54
+    /** @var ILogger */
55
+    private $logger;
56
+
57
+    /** @var IURLGenerator */
58
+    private $urlGenerator;
59
+
60
+    /** @var ITimeFactory */
61
+    protected $timeFactory;
62
+
63
+    /** @var IUserSession */
64
+    private $userSession;
65
+
66
+    /** @var IAppManager */
67
+    private $appManager;
68
+
69
+    /**
70
+     * Account constructor.
71
+     *
72
+     * @param string $appName
73
+     * @param IRequest $request
74
+     * @param IConfig $config
75
+     * @param IUserManager $userManager
76
+     * @param ILogger $logger
77
+     * @param IURLGenerator $urlGenerator
78
+     * @param ITimeFactory $timeFactory
79
+     * @param IUserSession $userSession
80
+     * @param IAppManager $appManager
81
+     */
82
+    public function __construct(string $appName,
83
+                                IRequest $request,
84
+                                IConfig $config,
85
+                                IUserManager $userManager,
86
+                                ILogger $logger,
87
+                                IURLGenerator $urlGenerator,
88
+                                ITimeFactory $timeFactory,
89
+                                IUserSession $userSession,
90
+                                IAppManager $appManager) {
91
+        parent::__construct($appName, $request);
92
+        $this->appName      = $appName;
93
+        $this->config       = $config;
94
+        $this->userManager  = $userManager;
95
+        $this->logger       = $logger;
96
+        $this->urlGenerator = $urlGenerator;
97
+        $this->timeFactory  = $timeFactory;
98
+        $this->userSession  = $userSession;
99
+        $this->appManager   = $appManager;
100
+
101
+        $this->serverRoot = \OC::$SERVERROOT;
102
+        $this->appRoot    = $this->appManager->getAppPath($this->appName);
103
+    }
104
+
105
+    /**
106
+     * @NoAdminRequired
107
+     * @NoCSRFRequired
108
+     *
109
+     * @return DataDisplayResponse
110
+     */
111
+    public function getCss(): DataDisplayResponse {
112
+        $css     = '';
113
+        $imports = '';
114
+        $userValues = $this->getUserValues();
115
+
116
+        foreach ($userValues as $key => $scssFile) {
117
+            if ($scssFile !== false) {
118
+                $imports .= '@import "' . $scssFile . '";';
119
+            }
120
+        }
121
+
122
+        if ($imports !== '') {
123
+            $scss = new Compiler();
124
+            $scss->setImportPaths([
125
+                $this->appRoot . '/css/',
126
+                $this->serverRoot . '/core/css/'
127
+            ]);
128
+
129
+            // Continue after throw
130
+            $scss->setIgnoreErrors(true);
131
+            $scss->setFormatter(Crunched::class);
132
+
133
+            // Import theme, variables and compile css4 variables
134
+            try {
135
+                $css .= $scss->compile(
136
+                    $imports .
137
+                    '@import "variables.scss";' .
138
+                    '@import "css-variables.scss";'
139
+                );
140
+            } catch (ParserException $e) {
141
+                $this->logger->error($e->getMessage(), ['app' => 'core']);
142
+            }
143
+        }
144
+
145
+        // We don't want to override vars with url since path is different
146
+        $css = $this->filterOutRule('/--[a-z-:]+url\([^;]+\)/mi', $css);
147
+
148
+        // Calculate exact absolute path to file
149
+        $path = $this->urlGenerator->linkToRoute($this->appName . '.accessibility.getCss', ['md5' => md5(implode('-', $userValues))]);
150
+        $path = explode('/', $this->serverRoot . $path);
151
+        array_pop($path);
152
+        $path = implode('/', $path);
153
+        $webDir = $this->getWebDir($path, $this->appName, $this->serverRoot, \OC::$WEBROOT);
154
+
155
+        // Rebase all urls
156
+        $css = $this->rebaseUrls($css, $webDir);
157
+
158
+        $response = new DataDisplayResponse($css, Http::STATUS_OK, ['Content-Type' => 'text/css']);
159
+
160
+        // Set cache control
161
+        $ttl = 31536000;
162
+        $response->addHeader('Cache-Control', 'max-age=' . $ttl . ', immutable');
163
+        $expires = new \DateTime();
164
+        $expires->setTimestamp($this->timeFactory->getTime());
165
+        $expires->add(new \DateInterval('PT' . $ttl . 'S'));
166
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
167
+        $response->addHeader('Pragma', 'cache');
168
+
169
+        return $response;
170
+    }
171
+
172
+    /**
173
+     * Return an array with the user theme & font settings
174
+     *
175
+     * @return array
176
+     */
177
+    private function getUserValues(): array{
178
+        $userTheme = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false);
179
+        $userFont  = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false);
180
+
181
+        return [$userTheme, $userFont];
182
+    }
183
+
184
+    /**
185
+     * Remove all matches from the $rule regex
186
+     *
187
+     * @param string $rule regex to match
188
+     * @param string $css string to parse
189
+     * @return string
190
+     */
191
+    private function filterOutRule(string $rule, string $css): string {
192
+        return preg_replace($rule, '', $css);
193
+    }
194
+
195
+    /**
196
+     * Add the correct uri prefix to make uri valid again
197
+     *
198
+     * @param string $css
199
+     * @param string $webDir
200
+     * @return string
201
+     */
202
+    private function rebaseUrls(string $css, string $webDir): string {
203
+        $re    = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x';
204
+        $subst = 'url(\'' . $webDir . '/$1\')';
205
+
206
+        return preg_replace($re, $subst, $css);
207
+    }
208
+
209
+    /**
210
+     * Get WebDir root
211
+     * @param string $path the css file path
212
+     * @param string $appName the app name
213
+     * @param string $serverRoot the server root path
214
+     * @param string $webRoot the nextcloud installation root path
215
+     * @return string the webDir
216
+     */
217
+    private function getWebDir(string $path, string $appName, string $serverRoot, string $webRoot): string {
218
+        // Detect if path is within server root AND if path is within an app path
219
+        if ( strpos($path, $serverRoot) === false && $appWebPath = \OC_App::getAppWebPath($appName)) {
220
+            // Get the file path within the app directory
221
+            $appDirectoryPath = explode($appName, $path)[1];
222
+            // Remove the webroot
223
+            return str_replace($webRoot, '', $appWebPath.$appDirectoryPath);
224
+        }
225
+        return $webRoot.substr($path, strlen($serverRoot));
226
+    }
227 227
 
228 228
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 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
  *
@@ -115,15 +115,15 @@  discard block
 block discarded – undo
115 115
 
116 116
 		foreach ($userValues as $key => $scssFile) {
117 117
 			if ($scssFile !== false) {
118
-				$imports .= '@import "' . $scssFile . '";';
118
+				$imports .= '@import "'.$scssFile.'";';
119 119
 			}
120 120
 		}
121 121
 
122 122
 		if ($imports !== '') {
123 123
 			$scss = new Compiler();
124 124
 			$scss->setImportPaths([
125
-				$this->appRoot . '/css/',
126
-				$this->serverRoot . '/core/css/'
125
+				$this->appRoot.'/css/',
126
+				$this->serverRoot.'/core/css/'
127 127
 			]);
128 128
 
129 129
 			// Continue after throw
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
 			// Import theme, variables and compile css4 variables
134 134
 			try {
135 135
 				$css .= $scss->compile(
136
-					$imports .
137
-					'@import "variables.scss";' .
136
+					$imports.
137
+					'@import "variables.scss";'.
138 138
 					'@import "css-variables.scss";'
139 139
 				);
140 140
 			} catch (ParserException $e) {
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 		$css = $this->filterOutRule('/--[a-z-:]+url\([^;]+\)/mi', $css);
147 147
 
148 148
 		// Calculate exact absolute path to file
149
-		$path = $this->urlGenerator->linkToRoute($this->appName . '.accessibility.getCss', ['md5' => md5(implode('-', $userValues))]);
150
-		$path = explode('/', $this->serverRoot . $path);
149
+		$path = $this->urlGenerator->linkToRoute($this->appName.'.accessibility.getCss', ['md5' => md5(implode('-', $userValues))]);
150
+		$path = explode('/', $this->serverRoot.$path);
151 151
 		array_pop($path);
152 152
 		$path = implode('/', $path);
153 153
 		$webDir = $this->getWebDir($path, $this->appName, $this->serverRoot, \OC::$WEBROOT);
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
 
160 160
 		// Set cache control
161 161
 		$ttl = 31536000;
162
-		$response->addHeader('Cache-Control', 'max-age=' . $ttl . ', immutable');
162
+		$response->addHeader('Cache-Control', 'max-age='.$ttl.', immutable');
163 163
 		$expires = new \DateTime();
164 164
 		$expires->setTimestamp($this->timeFactory->getTime());
165
-		$expires->add(new \DateInterval('PT' . $ttl . 'S'));
165
+		$expires->add(new \DateInterval('PT'.$ttl.'S'));
166 166
 		$response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
167 167
 		$response->addHeader('Pragma', 'cache');
168 168
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 */
202 202
 	private function rebaseUrls(string $css, string $webDir): string {
203 203
 		$re    = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x';
204
-		$subst = 'url(\'' . $webDir . '/$1\')';
204
+		$subst = 'url(\''.$webDir.'/$1\')';
205 205
 
206 206
 		return preg_replace($re, $subst, $css);
207 207
 	}
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 */
217 217
 	private function getWebDir(string $path, string $appName, string $serverRoot, string $webRoot): string {
218 218
 		// Detect if path is within server root AND if path is within an app path
219
-		if ( strpos($path, $serverRoot) === false && $appWebPath = \OC_App::getAppWebPath($appName)) {
219
+		if (strpos($path, $serverRoot) === false && $appWebPath = \OC_App::getAppWebPath($appName)) {
220 220
 			// Get the file path within the app directory
221 221
 			$appDirectoryPath = explode($appName, $path)[1];
222 222
 			// Remove the webroot
Please login to merge, or discard this patch.