@@ -25,5 +25,5 @@ |
||
| 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 |
@@ -29,72 +29,72 @@ |
||
| 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 | } |
@@ -33,81 +33,81 @@ |
||
| 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 | } |
@@ -74,7 +74,6 @@ |
||
| 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 { |
@@ -23,7 +23,6 @@ |
||
| 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; |
@@ -33,89 +33,89 @@ |
||
| 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 |
@@ -1,5 +1,5 @@ discard block |
||
| 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 |
||
| 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 |
@@ -26,15 +26,15 @@ |
||
| 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 | ]; |
@@ -30,34 +30,34 @@ |
||
| 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 | } |
@@ -55,7 +55,7 @@ |
||
| 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 | } |
@@ -1,5 +1,5 @@ |
||
| 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 | * |
@@ -39,164 +39,164 @@ |
||
| 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 | - // Rebase all urls |
|
| 149 | - $appWebRoot = substr($this->appRoot, strlen($this->serverRoot) - strlen(\OC::$WEBROOT)); |
|
| 150 | - $css = $this->rebaseUrls($css, $appWebRoot . '/css'); |
|
| 151 | - |
|
| 152 | - $response = new DataDisplayResponse($css, Http::STATUS_OK, ['Content-Type' => 'text/css']); |
|
| 153 | - |
|
| 154 | - // Set cache control |
|
| 155 | - $ttl = 31536000; |
|
| 156 | - $response->addHeader('Cache-Control', 'max-age=' . $ttl . ', immutable'); |
|
| 157 | - $expires = new \DateTime(); |
|
| 158 | - $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 159 | - $expires->add(new \DateInterval('PT' . $ttl . 'S')); |
|
| 160 | - $response->addHeader('Expires', $expires->format(\DateTime::RFC1123)); |
|
| 161 | - $response->addHeader('Pragma', 'cache'); |
|
| 162 | - |
|
| 163 | - return $response; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * Return an array with the user theme & font settings |
|
| 168 | - * |
|
| 169 | - * @return array |
|
| 170 | - */ |
|
| 171 | - private function getUserValues(): array{ |
|
| 172 | - $userTheme = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false); |
|
| 173 | - $userFont = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false); |
|
| 174 | - |
|
| 175 | - return [$userTheme, $userFont]; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Remove all matches from the $rule regex |
|
| 180 | - * |
|
| 181 | - * @param string $rule regex to match |
|
| 182 | - * @param string $css string to parse |
|
| 183 | - * @return string |
|
| 184 | - */ |
|
| 185 | - private function filterOutRule(string $rule, string $css): string { |
|
| 186 | - return preg_replace($rule, '', $css); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * Add the correct uri prefix to make uri valid again |
|
| 191 | - * |
|
| 192 | - * @param string $css |
|
| 193 | - * @param string $webDir |
|
| 194 | - * @return string |
|
| 195 | - */ |
|
| 196 | - private function rebaseUrls(string $css, string $webDir): string { |
|
| 197 | - $re = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x'; |
|
| 198 | - $subst = 'url(\'' . $webDir . '/$1\')'; |
|
| 199 | - |
|
| 200 | - return preg_replace($re, $subst, $css); |
|
| 201 | - } |
|
| 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 | + // Rebase all urls |
|
| 149 | + $appWebRoot = substr($this->appRoot, strlen($this->serverRoot) - strlen(\OC::$WEBROOT)); |
|
| 150 | + $css = $this->rebaseUrls($css, $appWebRoot . '/css'); |
|
| 151 | + |
|
| 152 | + $response = new DataDisplayResponse($css, Http::STATUS_OK, ['Content-Type' => 'text/css']); |
|
| 153 | + |
|
| 154 | + // Set cache control |
|
| 155 | + $ttl = 31536000; |
|
| 156 | + $response->addHeader('Cache-Control', 'max-age=' . $ttl . ', immutable'); |
|
| 157 | + $expires = new \DateTime(); |
|
| 158 | + $expires->setTimestamp($this->timeFactory->getTime()); |
|
| 159 | + $expires->add(new \DateInterval('PT' . $ttl . 'S')); |
|
| 160 | + $response->addHeader('Expires', $expires->format(\DateTime::RFC1123)); |
|
| 161 | + $response->addHeader('Pragma', 'cache'); |
|
| 162 | + |
|
| 163 | + return $response; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * Return an array with the user theme & font settings |
|
| 168 | + * |
|
| 169 | + * @return array |
|
| 170 | + */ |
|
| 171 | + private function getUserValues(): array{ |
|
| 172 | + $userTheme = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false); |
|
| 173 | + $userFont = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false); |
|
| 174 | + |
|
| 175 | + return [$userTheme, $userFont]; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Remove all matches from the $rule regex |
|
| 180 | + * |
|
| 181 | + * @param string $rule regex to match |
|
| 182 | + * @param string $css string to parse |
|
| 183 | + * @return string |
|
| 184 | + */ |
|
| 185 | + private function filterOutRule(string $rule, string $css): string { |
|
| 186 | + return preg_replace($rule, '', $css); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Add the correct uri prefix to make uri valid again |
|
| 191 | + * |
|
| 192 | + * @param string $css |
|
| 193 | + * @param string $webDir |
|
| 194 | + * @return string |
|
| 195 | + */ |
|
| 196 | + private function rebaseUrls(string $css, string $webDir): string { |
|
| 197 | + $re = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x'; |
|
| 198 | + $subst = 'url(\'' . $webDir . '/$1\')'; |
|
| 199 | + |
|
| 200 | + return preg_replace($re, $subst, $css); |
|
| 201 | + } |
|
| 202 | 202 | } |
@@ -1,5 +1,5 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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) { |
@@ -147,16 +147,16 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | // Rebase all urls |
| 149 | 149 | $appWebRoot = substr($this->appRoot, strlen($this->serverRoot) - strlen(\OC::$WEBROOT)); |
| 150 | - $css = $this->rebaseUrls($css, $appWebRoot . '/css'); |
|
| 150 | + $css = $this->rebaseUrls($css, $appWebRoot.'/css'); |
|
| 151 | 151 | |
| 152 | 152 | $response = new DataDisplayResponse($css, Http::STATUS_OK, ['Content-Type' => 'text/css']); |
| 153 | 153 | |
| 154 | 154 | // Set cache control |
| 155 | 155 | $ttl = 31536000; |
| 156 | - $response->addHeader('Cache-Control', 'max-age=' . $ttl . ', immutable'); |
|
| 156 | + $response->addHeader('Cache-Control', 'max-age='.$ttl.', immutable'); |
|
| 157 | 157 | $expires = new \DateTime(); |
| 158 | 158 | $expires->setTimestamp($this->timeFactory->getTime()); |
| 159 | - $expires->add(new \DateInterval('PT' . $ttl . 'S')); |
|
| 159 | + $expires->add(new \DateInterval('PT'.$ttl.'S')); |
|
| 160 | 160 | $response->addHeader('Expires', $expires->format(\DateTime::RFC1123)); |
| 161 | 161 | $response->addHeader('Pragma', 'cache'); |
| 162 | 162 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | private function rebaseUrls(string $css, string $webDir): string { |
| 197 | 197 | $re = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x'; |
| 198 | - $subst = 'url(\'' . $webDir . '/$1\')'; |
|
| 198 | + $subst = 'url(\''.$webDir.'/$1\')'; |
|
| 199 | 199 | |
| 200 | 200 | return preg_replace($re, $subst, $css); |
| 201 | 201 | } |
@@ -29,55 +29,55 @@ |
||
| 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 | - } |
|
| 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 | + } |
|
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | \ No newline at end of file |