@@ -31,38 +31,38 @@ |
||
| 31 | 31 | use OCP\IUserSession; |
| 32 | 32 | |
| 33 | 33 | class JSDataService extends InitialStateProvider { |
| 34 | - /** @var IUserSession */ |
|
| 35 | - private $userSession; |
|
| 36 | - /** @var IConfig */ |
|
| 37 | - private $config; |
|
| 34 | + /** @var IUserSession */ |
|
| 35 | + private $userSession; |
|
| 36 | + /** @var IConfig */ |
|
| 37 | + private $config; |
|
| 38 | 38 | |
| 39 | - public function __construct( |
|
| 40 | - IUserSession $userSession, |
|
| 41 | - IConfig $config |
|
| 42 | - ) { |
|
| 43 | - $this->userSession = $userSession; |
|
| 44 | - $this->config = $config; |
|
| 45 | - } |
|
| 39 | + public function __construct( |
|
| 40 | + IUserSession $userSession, |
|
| 41 | + IConfig $config |
|
| 42 | + ) { |
|
| 43 | + $this->userSession = $userSession; |
|
| 44 | + $this->config = $config; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public function getKey(): string { |
|
| 48 | - return 'data'; |
|
| 49 | - } |
|
| 47 | + public function getKey(): string { |
|
| 48 | + return 'data'; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - public function getData() { |
|
| 52 | - $user = $this->userSession->getUser(); |
|
| 51 | + public function getData() { |
|
| 52 | + $user = $this->userSession->getUser(); |
|
| 53 | 53 | |
| 54 | - if ($user === null) { |
|
| 55 | - $theme = false; |
|
| 56 | - $highcontrast = false; |
|
| 57 | - } else { |
|
| 58 | - $theme = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'theme', false); |
|
| 59 | - $highcontrast = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'highcontrast', false) !== false; |
|
| 60 | - } |
|
| 54 | + if ($user === null) { |
|
| 55 | + $theme = false; |
|
| 56 | + $highcontrast = false; |
|
| 57 | + } else { |
|
| 58 | + $theme = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'theme', false); |
|
| 59 | + $highcontrast = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'highcontrast', false) !== false; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return [ |
|
| 63 | - 'checkMedia' => $user === null, |
|
| 64 | - 'theme' => $theme, |
|
| 65 | - 'highcontrast' => $highcontrast, |
|
| 66 | - ]; |
|
| 67 | - } |
|
| 62 | + return [ |
|
| 63 | + 'checkMedia' => $user === null, |
|
| 64 | + 'theme' => $theme, |
|
| 65 | + 'highcontrast' => $highcontrast, |
|
| 66 | + ]; |
|
| 67 | + } |
|
| 68 | 68 | } |
@@ -43,42 +43,42 @@ |
||
| 43 | 43 | |
| 44 | 44 | class Application extends App implements IBootstrap { |
| 45 | 45 | |
| 46 | - /** @var string */ |
|
| 47 | - public const APP_ID = 'accessibility'; |
|
| 46 | + /** @var string */ |
|
| 47 | + public const APP_ID = 'accessibility'; |
|
| 48 | 48 | |
| 49 | - public function __construct() { |
|
| 50 | - parent::__construct(self::APP_ID); |
|
| 51 | - } |
|
| 49 | + public function __construct() { |
|
| 50 | + parent::__construct(self::APP_ID); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function register(IRegistrationContext $context): void { |
|
| 54 | - $context->registerInitialStateProvider(JSDataService::class); |
|
| 55 | - } |
|
| 53 | + public function register(IRegistrationContext $context): void { |
|
| 54 | + $context->registerInitialStateProvider(JSDataService::class); |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - public function boot(IBootContext $context): void { |
|
| 58 | - $context->injectFn([$this, 'injectCss']); |
|
| 59 | - } |
|
| 57 | + public function boot(IBootContext $context): void { |
|
| 58 | + $context->injectFn([$this, 'injectCss']); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function injectCss(IUserSession $userSession, |
|
| 62 | - IConfig $config, |
|
| 63 | - IURLGenerator $urlGenerator) { |
|
| 64 | - // Inject the fake css on all pages if enabled and user is logged |
|
| 65 | - $loggedUser = $userSession->getUser(); |
|
| 66 | - if ($loggedUser !== null) { |
|
| 67 | - $userValues = $config->getUserKeys($loggedUser->getUID(), self::APP_ID); |
|
| 68 | - // we want to check if any theme or font is enabled. |
|
| 69 | - if (count($userValues) > 0) { |
|
| 70 | - $hash = $config->getUserValue($loggedUser->getUID(), self::APP_ID, 'icons-css', md5(implode('-', $userValues))); |
|
| 71 | - $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]); |
|
| 72 | - \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]); |
|
| 73 | - } |
|
| 74 | - \OCP\Util::addScript('accessibility', 'accessibilityoca'); |
|
| 75 | - } else { |
|
| 76 | - $userValues = ['dark']; |
|
| 61 | + public function injectCss(IUserSession $userSession, |
|
| 62 | + IConfig $config, |
|
| 63 | + IURLGenerator $urlGenerator) { |
|
| 64 | + // Inject the fake css on all pages if enabled and user is logged |
|
| 65 | + $loggedUser = $userSession->getUser(); |
|
| 66 | + if ($loggedUser !== null) { |
|
| 67 | + $userValues = $config->getUserKeys($loggedUser->getUID(), self::APP_ID); |
|
| 68 | + // we want to check if any theme or font is enabled. |
|
| 69 | + if (count($userValues) > 0) { |
|
| 70 | + $hash = $config->getUserValue($loggedUser->getUID(), self::APP_ID, 'icons-css', md5(implode('-', $userValues))); |
|
| 71 | + $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]); |
|
| 72 | + \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]); |
|
| 73 | + } |
|
| 74 | + \OCP\Util::addScript('accessibility', 'accessibilityoca'); |
|
| 75 | + } else { |
|
| 76 | + $userValues = ['dark']; |
|
| 77 | 77 | |
| 78 | - $hash = md5(implode('-', $userValues)); |
|
| 79 | - $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]); |
|
| 80 | - \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'media' => '(prefers-color-scheme: dark)', 'href' => $linkToCSS]); |
|
| 81 | - \OCP\Util::addScript('accessibility', 'accessibilityoca'); |
|
| 82 | - } |
|
| 83 | - } |
|
| 78 | + $hash = md5(implode('-', $userValues)); |
|
| 79 | + $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]); |
|
| 80 | + \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'media' => '(prefers-color-scheme: dark)', 'href' => $linkToCSS]); |
|
| 81 | + \OCP\Util::addScript('accessibility', 'accessibilityoca'); |
|
| 82 | + } |
|
| 83 | + } |
|
| 84 | 84 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | // we want to check if any theme or font is enabled. |
| 69 | 69 | if (count($userValues) > 0) { |
| 70 | 70 | $hash = $config->getUserValue($loggedUser->getUID(), self::APP_ID, 'icons-css', md5(implode('-', $userValues))); |
| 71 | - $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]); |
|
| 71 | + $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID.'.accessibility.getCss', ['md5' => $hash]); |
|
| 72 | 72 | \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]); |
| 73 | 73 | } |
| 74 | 74 | \OCP\Util::addScript('accessibility', 'accessibilityoca'); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $userValues = ['dark']; |
| 77 | 77 | |
| 78 | 78 | $hash = md5(implode('-', $userValues)); |
| 79 | - $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]); |
|
| 79 | + $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID.'.accessibility.getCss', ['md5' => $hash]); |
|
| 80 | 80 | \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'media' => '(prefers-color-scheme: dark)', 'href' => $linkToCSS]); |
| 81 | 81 | \OCP\Util::addScript('accessibility', 'accessibilityoca'); |
| 82 | 82 | } |