@@ -45,50 +45,50 @@ |
||
| 45 | 45 | |
| 46 | 46 | class Application extends App implements IBootstrap { |
| 47 | 47 | |
| 48 | - /** @var string */ |
|
| 49 | - public const APP_ID = 'accessibility'; |
|
| 48 | + /** @var string */ |
|
| 49 | + public const APP_ID = 'accessibility'; |
|
| 50 | 50 | |
| 51 | - public function __construct() { |
|
| 52 | - parent::__construct(self::APP_ID); |
|
| 53 | - } |
|
| 51 | + public function __construct() { |
|
| 52 | + parent::__construct(self::APP_ID); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public function register(IRegistrationContext $context): void { |
|
| 56 | - } |
|
| 55 | + public function register(IRegistrationContext $context): void { |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function boot(IBootContext $context): void { |
|
| 59 | - $context->injectFn([$this, 'injectCss']); |
|
| 60 | - $context->injectFn([$this, 'registerInitialState']); |
|
| 61 | - } |
|
| 58 | + public function boot(IBootContext $context): void { |
|
| 59 | + $context->injectFn([$this, 'injectCss']); |
|
| 60 | + $context->injectFn([$this, 'registerInitialState']); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function injectCss(IUserSession $userSession, |
|
| 64 | - IConfig $config, |
|
| 65 | - IURLGenerator $urlGenerator) { |
|
| 66 | - // Inject the fake css on all pages if enabled and user is logged |
|
| 67 | - $loggedUser = $userSession->getUser(); |
|
| 68 | - if ($loggedUser !== null) { |
|
| 69 | - $userValues = $config->getUserKeys($loggedUser->getUID(), self::APP_ID); |
|
| 70 | - // we want to check if any theme or font is enabled. |
|
| 71 | - if (count($userValues) > 0) { |
|
| 72 | - $hash = $config->getUserValue($loggedUser->getUID(), self::APP_ID, 'icons-css', md5(implode('-', $userValues))); |
|
| 73 | - $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]); |
|
| 74 | - \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]); |
|
| 75 | - } |
|
| 76 | - \OCP\Util::addScript('accessibility', 'accessibilityoca'); |
|
| 77 | - } else { |
|
| 78 | - $userValues = ['dark']; |
|
| 63 | + public function injectCss(IUserSession $userSession, |
|
| 64 | + IConfig $config, |
|
| 65 | + IURLGenerator $urlGenerator) { |
|
| 66 | + // Inject the fake css on all pages if enabled and user is logged |
|
| 67 | + $loggedUser = $userSession->getUser(); |
|
| 68 | + if ($loggedUser !== null) { |
|
| 69 | + $userValues = $config->getUserKeys($loggedUser->getUID(), self::APP_ID); |
|
| 70 | + // we want to check if any theme or font is enabled. |
|
| 71 | + if (count($userValues) > 0) { |
|
| 72 | + $hash = $config->getUserValue($loggedUser->getUID(), self::APP_ID, 'icons-css', md5(implode('-', $userValues))); |
|
| 73 | + $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]); |
|
| 74 | + \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]); |
|
| 75 | + } |
|
| 76 | + \OCP\Util::addScript('accessibility', 'accessibilityoca'); |
|
| 77 | + } else { |
|
| 78 | + $userValues = ['dark']; |
|
| 79 | 79 | |
| 80 | - $hash = md5(implode('-', $userValues)); |
|
| 81 | - $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]); |
|
| 82 | - \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'media' => '(prefers-color-scheme: dark)', 'href' => $linkToCSS]); |
|
| 83 | - } |
|
| 84 | - } |
|
| 80 | + $hash = md5(implode('-', $userValues)); |
|
| 81 | + $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]); |
|
| 82 | + \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'media' => '(prefers-color-scheme: dark)', 'href' => $linkToCSS]); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - public function registerInitialState(IInitialStateService $initialState, |
|
| 87 | - IAppContainer $container) { |
|
| 88 | - $initialState->provideLazyInitialState(self::APP_ID, 'data', function () use ($container) { |
|
| 89 | - /** @var JSDataService $data */ |
|
| 90 | - $data = $container->query(JSDataService::class); |
|
| 91 | - return $data; |
|
| 92 | - }); |
|
| 93 | - } |
|
| 86 | + public function registerInitialState(IInitialStateService $initialState, |
|
| 87 | + IAppContainer $container) { |
|
| 88 | + $initialState->provideLazyInitialState(self::APP_ID, 'data', function () use ($container) { |
|
| 89 | + /** @var JSDataService $data */ |
|
| 90 | + $data = $container->query(JSDataService::class); |
|
| 91 | + return $data; |
|
| 92 | + }); |
|
| 93 | + } |
|
| 94 | 94 | } |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | // we want to check if any theme or font is enabled. |
| 71 | 71 | if (count($userValues) > 0) { |
| 72 | 72 | $hash = $config->getUserValue($loggedUser->getUID(), self::APP_ID, 'icons-css', md5(implode('-', $userValues))); |
| 73 | - $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]); |
|
| 73 | + $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID.'.accessibility.getCss', ['md5' => $hash]); |
|
| 74 | 74 | \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]); |
| 75 | 75 | } |
| 76 | 76 | \OCP\Util::addScript('accessibility', 'accessibilityoca'); |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | $userValues = ['dark']; |
| 79 | 79 | |
| 80 | 80 | $hash = md5(implode('-', $userValues)); |
| 81 | - $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]); |
|
| 81 | + $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID.'.accessibility.getCss', ['md5' => $hash]); |
|
| 82 | 82 | \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'media' => '(prefers-color-scheme: dark)', 'href' => $linkToCSS]); |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | public function registerInitialState(IInitialStateService $initialState, |
| 87 | 87 | IAppContainer $container) { |
| 88 | - $initialState->provideLazyInitialState(self::APP_ID, 'data', function () use ($container) { |
|
| 88 | + $initialState->provideLazyInitialState(self::APP_ID, 'data', function() use ($container) { |
|
| 89 | 89 | /** @var JSDataService $data */ |
| 90 | 90 | $data = $container->query(JSDataService::class); |
| 91 | 91 | return $data; |