aboutsummaryrefslogtreecommitdiffstats
path: root/apps/accessibility/lib
diff options
context:
space:
mode:
authorJohn Molakvoæ <skjnldsv@protonmail.com>2022-04-20 10:40:09 +0200
committerJohn Molakvoæ <skjnldsv@protonmail.com>2022-04-21 19:00:28 +0200
commit1dee36c761b87ab79bb54cfc561d576d8c72434c (patch)
treef16175b4983c69b0796fafb71d6ccc343cf8bbd7 /apps/accessibility/lib
parent7b686abe7fb53c8475d8295a59167bdab95fccc9 (diff)
downloadnextcloud-server-1dee36c761b87ab79bb54cfc561d576d8c72434c.tar.gz
nextcloud-server-1dee36c761b87ab79bb54cfc561d576d8c72434c.zip
Remove accessibility
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/accessibility/lib')
-rw-r--r--apps/accessibility/lib/AccessibilityProvider.php90
-rw-r--r--apps/accessibility/lib/AppInfo/Application.php84
-rw-r--r--apps/accessibility/lib/Controller/AccessibilityController.php241
-rw-r--r--apps/accessibility/lib/Controller/ConfigController.php139
-rw-r--r--apps/accessibility/lib/Migration/RepairUserConfig.php83
-rw-r--r--apps/accessibility/lib/Service/JSDataService.php66
-rw-r--r--apps/accessibility/lib/Settings/Personal.php110
-rw-r--r--apps/accessibility/lib/Settings/PersonalSection.php100
8 files changed, 0 insertions, 913 deletions
diff --git a/apps/accessibility/lib/AccessibilityProvider.php b/apps/accessibility/lib/AccessibilityProvider.php
deleted file mode 100644
index 80ba4753dfa..00000000000
--- a/apps/accessibility/lib/AccessibilityProvider.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
- * @copyright Copyright (c) 2019 Janis Köhr <janiskoehr@icloud.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Greta Doci <gretadoci@gmail.com>
- * @author Jan-Christoph Borchardt <hey@jancborchardt.net>
- * @author Janis Köhr <janis.koehr@novatec-gmbh.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCA\Accessibility;
-
-use OCP\IL10N;
-use OCP\IURLGenerator;
-
-class AccessibilityProvider {
-
- protected string $appName;
- private IURLGenerator $urlGenerator;
- private IL10N $l;
-
- public function __construct(string $appName,
- IURLGenerator $urlGenerator,
- IL10N $l) {
- $this->appName = $appName;
- $this->urlGenerator = $urlGenerator;
- $this->l = $l;
- }
-
- /**
- * @psalm-return array<array-key, array{id: string, img: string, title: string, enableLabel: string, text: string}>
- */
- public function getThemes(): array {
- return [
- [
- 'id' => 'dark',
- 'img' => $this->urlGenerator->imagePath($this->appName, 'theme-dark.jpg'),
- 'title' => $this->l->t('Dark theme'),
- 'enableLabel' => $this->l->t('Enable dark theme'),
- 'text' => $this->l->t('A dark theme to ease your eyes by reducing the overall luminosity and brightness. It is still under development, so please report any issues you may find.')
- ]
- ];
- }
-
- /**
- * @psalm-return array{id: string, img: string, title: string, enableLabel: string, text: string}
- */
- public function getHighContrast(): array {
- return [
- 'id' => 'highcontrast',
- 'img' => $this->urlGenerator->imagePath($this->appName, 'mode-highcontrast.jpg'),
- 'title' => $this->l->t('High contrast mode'),
- 'enableLabel' => $this->l->t('Enable high contrast mode'),
- 'text' => $this->l->t('A high contrast mode to ease your navigation. Visual quality will be reduced but clarity will be increased.')
- ];
- }
-
- /**
- * @psalm-return array<array-key, array{id: string, img: string, title: string, enableLabel: string, text: string}>
- */
- public function getFonts(): array {
- return [
- [
- 'id' => 'fontdyslexic',
- 'img' => $this->urlGenerator->imagePath($this->appName, 'font-opendyslexic.jpg'),
- 'title' => $this->l->t('Dyslexia font'),
- 'enableLabel' => $this->l->t('Enable dyslexia font'),
- 'text' => $this->l->t('OpenDyslexic is a free typeface/font designed to mitigate some of the common reading errors caused by dyslexia.')
- ]
- ];
- }
-}
diff --git a/apps/accessibility/lib/AppInfo/Application.php b/apps/accessibility/lib/AppInfo/Application.php
deleted file mode 100644
index f7f4801f820..00000000000
--- a/apps/accessibility/lib/AppInfo/Application.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCA\Accessibility\AppInfo;
-
-use OCA\Accessibility\Service\JSDataService;
-use OCP\AppFramework\App;
-use OCP\AppFramework\Bootstrap\IBootContext;
-use OCP\AppFramework\Bootstrap\IBootstrap;
-use OCP\AppFramework\Bootstrap\IRegistrationContext;
-use OCP\IConfig;
-use OCP\IURLGenerator;
-use OCP\IUserSession;
-use function count;
-use function implode;
-use function md5;
-
-class Application extends App implements IBootstrap {
-
- /** @var string */
- public const APP_ID = 'accessibility';
-
- public function __construct() {
- parent::__construct(self::APP_ID);
- }
-
- public function register(IRegistrationContext $context): void {
- $context->registerInitialStateProvider(JSDataService::class);
- }
-
- public function boot(IBootContext $context): void {
- $context->injectFn([$this, 'injectCss']);
- }
-
- public function injectCss(IUserSession $userSession,
- IConfig $config,
- IURLGenerator $urlGenerator) {
- // Inject the fake css on all pages if enabled and user is logged
- $loggedUser = $userSession->getUser();
- if ($loggedUser !== null) {
- $userValues = $config->getUserKeys($loggedUser->getUID(), self::APP_ID);
- // we want to check if any theme or font is enabled.
- if (count($userValues) > 0) {
- $hash = $config->getUserValue($loggedUser->getUID(), self::APP_ID, 'icons-css', md5(implode('-', $userValues)));
- $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]);
- \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]);
- }
- \OCP\Util::addScript('accessibility', 'accessibilityoca');
- } else {
- $userValues = ['dark'];
-
- $hash = md5(implode('-', $userValues));
- $linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.accessibility.getCss', ['md5' => $hash]);
- \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'media' => '(prefers-color-scheme: dark)', 'href' => $linkToCSS]);
- \OCP\Util::addScript('accessibility', 'accessibilityoca');
- }
- }
-}
diff --git a/apps/accessibility/lib/Controller/AccessibilityController.php b/apps/accessibility/lib/Controller/AccessibilityController.php
deleted file mode 100644
index b3063937a1b..00000000000
--- a/apps/accessibility/lib/Controller/AccessibilityController.php
+++ /dev/null
@@ -1,241 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright Copyright (c) 2018 John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
- * @copyright Copyright (c) 2019 Janis Köhr <janiskoehr@icloud.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Janis Köhr <janis.koehr@novatec-gmbh.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Citharel <nextcloud@tcit.fr>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCA\Accessibility\Controller;
-
-use OC\Template\IconsCacher;
-use OCP\App\IAppManager;
-use OCP\AppFramework\Controller;
-use OCP\AppFramework\Http;
-use OCP\AppFramework\Http\DataDisplayResponse;
-use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\IConfig;
-use OCP\IRequest;
-use OCP\IUserSession;
-use Psr\Log\LoggerInterface;
-use ScssPhp\ScssPhp\Compiler;
-use ScssPhp\ScssPhp\Exception\ParserException;
-use ScssPhp\ScssPhp\OutputStyle;
-
-class AccessibilityController extends Controller {
-
- protected string $serverRoot;
- private IConfig $config;
- private LoggerInterface $logger;
- protected ITimeFactory $timeFactory;
- private IUserSession $userSession;
- protected IconsCacher $iconsCacher;
- private \OC_Defaults $defaults;
- private ?string $injectedVariables = null;
- private string $appRoot;
-
- public function __construct(string $appName,
- IRequest $request,
- IConfig $config,
- LoggerInterface $logger,
- ITimeFactory $timeFactory,
- IUserSession $userSession,
- IAppManager $appManager,
- IconsCacher $iconsCacher,
- \OC_Defaults $defaults) {
- parent::__construct($appName, $request);
- $this->appName = $appName;
- $this->config = $config;
- $this->logger = $logger;
- $this->timeFactory = $timeFactory;
- $this->userSession = $userSession;
- $this->iconsCacher = $iconsCacher;
- $this->defaults = $defaults;
-
- $this->serverRoot = \OC::$SERVERROOT;
- $this->appRoot = $appManager->getAppPath($this->appName);
- }
-
- /**
- * @PublicPage
- * @NoCSRFRequired
- * @NoSameSiteCookieRequired
- */
- public function getCss(): DataDisplayResponse {
- $css = '';
- $imports = '';
- if ($this->userSession->isLoggedIn()) {
- $userValues = $this->getUserValues();
- } else {
- $userValues = ['dark'];
- }
-
- foreach ($userValues as $key => $scssFile) {
- if ($scssFile !== false) {
- if ($scssFile === 'highcontrast' && in_array('dark', $userValues)) {
- $scssFile .= 'dark';
- }
- $imports .= '@import "' . $scssFile . '";';
- }
- }
-
- if ($imports !== '') {
- $scss = new Compiler();
- $scss->setImportPaths([
- $this->appRoot . '/css/',
- $this->serverRoot . '/core/css/'
- ]);
-
- // Continue after throw
- $scss->setOutputStyle(OutputStyle::COMPRESSED);
-
- // Import theme, variables and compile css4 variables
- try {
- $css .= $scss->compile(
- $imports .
- $this->getInjectedVariables() .
- '@import "variables.scss";' .
- '@import "css-variables.scss";'
- );
- } catch (ParserException $e) {
- $this->logger->error($e->getMessage(),
- [
- 'app' => 'core',
- 'exception' => $e,
- ]
- );
- }
- }
-
- // We don't want to override vars with url since path is different
- $css = $this->filterOutRule('/--[a-z-:]+url\([^;]+\)/mi', $css);
-
- // Rebase all urls
- $appWebRoot = substr($this->appRoot, strlen($this->serverRoot) - strlen(\OC::$WEBROOT));
- $css = $this->rebaseUrls($css, $appWebRoot . '/css');
-
- if (in_array('dark', $userValues) && $this->iconsCacher->getCachedList() && $this->iconsCacher->getCachedList()->getSize() > 0) {
- $iconsCss = $this->invertSvgIconsColor($this->iconsCacher->getCachedList()->getContent());
- $css = $css . $iconsCss;
- }
-
- $response = new DataDisplayResponse($css, Http::STATUS_OK, ['Content-Type' => 'text/css']);
-
- // Set cache control
- $ttl = 31536000;
- $response->addHeader('Cache-Control', 'max-age=' . $ttl . ', immutable');
- $expires = new \DateTime();
- $expires->setTimestamp($this->timeFactory->getTime());
- $expires->add(new \DateInterval('PT' . $ttl . 'S'));
- $response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
- $response->addHeader('Pragma', 'cache');
-
- // store current cache hash
- if ($this->userSession->isLoggedIn()) {
- $this->config->setUserValue($this->userSession->getUser()->getUID(), $this->appName, 'icons-css', md5($css));
- }
-
- return $response;
- }
-
- /**
- * Return an array with the user theme & font settings
- */
- private function getUserValues(): array {
- $userTheme = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false);
- $userFont = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false);
- $userHighContrast = $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'highcontrast', false);
-
- return [$userTheme, $userHighContrast, $userFont];
- }
-
- /**
- * Remove all matches from the $rule regex
- *
- * @param string $rule regex to match
- * @param string $css string to parse
- * @return string
- */
- private function filterOutRule(string $rule, string $css): string {
- return preg_replace($rule, '', $css);
- }
-
- /**
- * Add the correct uri prefix to make uri valid again
- */
- private function rebaseUrls(string $css, string $webDir): string {
- $re = '/url\([\'"]([^\/][\.\w?=\/-]*)[\'"]\)/x';
- $subst = 'url(\'' . $webDir . '/$1\')';
-
- return preg_replace($re, $subst, $css);
- }
-
- /**
- * Remove all matches from the $rule regex
- *
- * @param string $css string to parse
- */
- private function invertSvgIconsColor(string $css): string {
- return str_replace(
- ['color=000&', 'color=fff&', 'color=***&'],
- ['color=***&', 'color=000&', 'color=fff&'],
- str_replace(
- ['color=000000&', 'color=ffffff&', 'color=******&'],
- ['color=******&', 'color=000000&', 'color=ffffff&'],
- $css
- )
- );
- }
-
- /**
- * @return string SCSS code for variables from OC_Defaults
- */
- private function getInjectedVariables(): string {
- if ($this->injectedVariables !== null) {
- return $this->injectedVariables;
- }
- $variables = '';
- foreach ($this->defaults->getScssVariables() as $key => $value) {
- $variables .= '$' . $key . ': ' . $value . ';';
- }
-
- // check for valid variables / otherwise fall back to defaults
- try {
- $scss = new Compiler();
- $scss->compile($variables);
- $this->injectedVariables = $variables;
- } catch (ParserException $e) {
- $this->logger->error($e->getMessage(),
- [
- 'app' => 'core',
- 'exception' => $e,
- ]
- );
- }
- return $variables;
- }
-}
diff --git a/apps/accessibility/lib/Controller/ConfigController.php b/apps/accessibility/lib/Controller/ConfigController.php
deleted file mode 100644
index 3cc66ed4cb4..00000000000
--- a/apps/accessibility/lib/Controller/ConfigController.php
+++ /dev/null
@@ -1,139 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright Copyright (c) 2018 John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
- * @copyright Copyright (c) 2019 Janis Köhr <janiskoehr@icloud.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Daniel Kesselberg <mail@danielkesselberg.de>
- * @author Janis Köhr <janis.koehr@novatec-gmbh.de>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCA\Accessibility\Controller;
-
-use OCA\Accessibility\AccessibilityProvider;
-use OCP\AppFramework\Http\DataResponse;
-use OCP\AppFramework\OCS\OCSBadRequestException;
-use OCP\AppFramework\OCSController;
-use OCP\IConfig;
-use OCP\IRequest;
-use OCP\IUserSession;
-use OCP\PreConditionNotMetException;
-
-class ConfigController extends OCSController {
-
- protected string $userId;
- private IConfig $config;
- private IUserSession $userSession;
- private AccessibilityProvider $accessibilityProvider;
-
- /**
- * Config constructor.
- */
- public function __construct(string $appName,
- IRequest $request,
- IConfig $config,
- IUserSession $userSession,
- AccessibilityProvider $accessibilityProvider) {
- parent::__construct($appName, $request);
- $this->config = $config;
- $this->userSession = $userSession;
- $this->accessibilityProvider = $accessibilityProvider;
- $this->userId = $userSession->getUser()->getUID();
- }
-
- /**
- * @NoAdminRequired
- *
- * Get user accessibility config
- *
- * @param string $key theme or font
- * @return DataResponse
- */
- public function getConfig(): DataResponse {
- return new DataResponse([
- 'highcontrast' => $this->config->getUserValue($this->userId, $this->appName, 'highcontrast', false),
- 'theme' => $this->config->getUserValue($this->userId, $this->appName, 'theme', false),
- 'font' => $this->config->getUserValue($this->userId, $this->appName, 'font', false)
- ]);
- }
-
- /**
- * @NoAdminRequired
- *
- * Set theme or font config
- *
- * @param string $key the theme or font
- * @param string|false $value the value
- * @return DataResponse
- * @throws OCSBadRequestException|PreConditionNotMetException
- */
- public function setConfig(string $key, $value): DataResponse {
- if ($key === 'theme' || $key === 'font' || $key === 'highcontrast') {
- if ($value === false || $value === '') {
- throw new OCSBadRequestException('Invalid value: ' . $value);
- }
-
- $themes = $this->accessibilityProvider->getThemes();
- $highcontrast = [$this->accessibilityProvider->getHighContrast()];
- $fonts = $this->accessibilityProvider->getFonts();
-
- $availableOptions = array_map(function ($option): string {
- return $option['id'];
- }, array_merge($themes, $highcontrast, $fonts));
-
- if (in_array($value, $availableOptions)) {
- $this->config->setUserValue($this->userId, $this->appName, $key, $value);
- return new DataResponse();
- }
-
- throw new OCSBadRequestException('Invalid value: ' . $value);
- }
-
- throw new OCSBadRequestException('Invalid key: ' . $key);
- }
-
- /**
- * @NoAdminRequired
- *
- * Unset theme or font config
- *
- * @param string $key theme or font
- * @return DataResponse
- * @throws OCSBadRequestException
- */
- public function deleteConfig(string $key): DataResponse {
- if ($key === 'theme' || $key === 'font' || $key === 'highcontrast') {
- $this->config->deleteUserValue($this->userId, $this->appName, $key);
- $userValues = $this->config->getUserKeys($this->userId, $this->appName);
-
- // remove hash if no settings selected
- if (count($userValues) === 1 && $userValues[0] === 'icons-css') {
- $this->config->deleteUserValue($this->userId, $this->appName, 'icons-css');
- }
-
- return new DataResponse();
- }
-
- throw new OCSBadRequestException('Invalid key: ' . $key);
- }
-}
diff --git a/apps/accessibility/lib/Migration/RepairUserConfig.php b/apps/accessibility/lib/Migration/RepairUserConfig.php
deleted file mode 100644
index c15280ae26d..00000000000
--- a/apps/accessibility/lib/Migration/RepairUserConfig.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright Copyright (c) 2019 Janis Köhr <janiskoehr@icloud.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Janis Köhr <janis.koehr@novatec-gmbh.de>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCA\Accessibility\Migration;
-
-use OCA\Accessibility\AppInfo\Application;
-use OCP\IConfig;
-use OCP\IUser;
-use OCP\IUserManager;
-use OCP\Migration\IOutput;
-use OCP\Migration\IRepairStep;
-
-class RepairUserConfig implements IRepairStep {
-
- protected IUserManager $userManager;
- protected IConfig $config;
-
- /**
- * MigrateUserConfig constructor.
- */
- public function __construct(IConfig $config,
- IUserManager $userManager) {
- $this->config = $config;
- $this->userManager = $userManager;
- }
-
- /**
- * Returns the step's name
- *
- * @return string
- * @since 9.1.0
- */
- public function getName() {
- return 'Migrate old user config';
- }
-
- /**
- * Run repair step.
- * Must throw exception on error.
- *
- * @param IOutput $output
- * @throws \Exception in case of failure
- * @since 9.1.0
- */
- public function run(IOutput $output) {
- $output->startProgress();
- $this->userManager->callForSeenUsers(function (IUser $user) use ($output) {
- $theme = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'theme', false);
- if ($theme === 'themedark') {
- $this->config->setUserValue($user->getUID(), Application::APP_ID, 'theme', 'dark');
- }
- if ($theme === 'themehighcontrast') {
- $this->config->setUserValue($user->getUID(), Application::APP_ID, 'highcontrast', 'highcontrast');
- $this->config->deleteUserValue($user->getUID(), Application::APP_ID, 'theme');
- }
- $output->advance();
- });
- $output->finishProgress();
- }
-}
diff --git a/apps/accessibility/lib/Service/JSDataService.php b/apps/accessibility/lib/Service/JSDataService.php
deleted file mode 100644
index e3a562de394..00000000000
--- a/apps/accessibility/lib/Service/JSDataService.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCA\Accessibility\Service;
-
-use OCA\Accessibility\AppInfo\Application;
-use OCP\AppFramework\Services\InitialStateProvider;
-use OCP\IConfig;
-use OCP\IUserSession;
-
-class JSDataService extends InitialStateProvider {
- private IUserSession $userSession;
- private IConfig $config;
-
- public function __construct(
- IUserSession $userSession,
- IConfig $config
- ) {
- $this->userSession = $userSession;
- $this->config = $config;
- }
-
- public function getKey(): string {
- return 'data';
- }
-
- public function getData() {
- $user = $this->userSession->getUser();
-
- if ($user === null) {
- $theme = false;
- $highcontrast = false;
- } else {
- $theme = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'theme', false);
- $highcontrast = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'highcontrast', false) !== false;
- }
-
- return [
- 'checkMedia' => $user === null,
- 'theme' => $theme,
- 'highcontrast' => $highcontrast,
- ];
- }
-}
diff --git a/apps/accessibility/lib/Settings/Personal.php b/apps/accessibility/lib/Settings/Personal.php
deleted file mode 100644
index 00653d48571..00000000000
--- a/apps/accessibility/lib/Settings/Personal.php
+++ /dev/null
@@ -1,110 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
- * @copyright Copyright (c) 2019 Janis Köhr <janiskoehr@icloud.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCA\Accessibility\Settings;
-
-use OCA\Accessibility\AccessibilityProvider;
-use OCP\AppFramework\Http\TemplateResponse;
-use OCP\AppFramework\Services\IInitialState;
-use OCP\IConfig;
-use OCP\IUserSession;
-use OCP\Settings\ISettings;
-use OCP\Util;
-
-class Personal implements ISettings {
-
- /** @var string */
- protected $appName;
-
- /** @var IConfig */
- private $config;
-
- /** @var IUserSession */
- private $userSession;
-
- /** @var AccessibilityProvider */
- private $accessibilityProvider;
-
- /** @var IInitialState */
- private $initialStateService;
-
- public function __construct(string $appName,
- IConfig $config,
- IUserSession $userSession,
- AccessibilityProvider $accessibilityProvider,
- IInitialState $initialStateService) {
- $this->appName = $appName;
- $this->config = $config;
- $this->userSession = $userSession;
- $this->accessibilityProvider = $accessibilityProvider;
- $this->initialStateService = $initialStateService;
- }
-
- /**
- * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
- * @since 9.1
- */
- public function getForm(): TemplateResponse {
- Util::addScript('accessibility', 'accessibility');
- Util::addStyle('accessibility', 'style');
-
- $availableConfig = [
- 'themes' => $this->accessibilityProvider->getThemes(),
- 'fonts' => $this->accessibilityProvider->getFonts(),
- 'highcontrast' => $this->accessibilityProvider->getHighContrast()
- ];
-
- $userConfig = [
- 'highcontrast' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'highcontrast', false),
- 'theme' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false),
- 'font' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false)
- ];
-
- $this->initialStateService->provideInitialState('available-config', $availableConfig);
- $this->initialStateService->provideInitialState('user-config', $userConfig);
-
- return new TemplateResponse($this->appName, 'settings-personal');
- }
-
- /**
- * @return string the section ID, e.g. 'sharing'
- * @since 9.1
- */
- public function getSection(): string {
- return $this->appName;
- }
-
- /**
- * @return int whether the form should be rather on the top or bottom of
- * the admin section. The forms are arranged in ascending order of the
- * priority values. It is required to return a value between 0 and 100.
- *
- * E.g.: 70
- * @since 9.1
- */
- public function getPriority(): int {
- return 40;
- }
-}
diff --git a/apps/accessibility/lib/Settings/PersonalSection.php b/apps/accessibility/lib/Settings/PersonalSection.php
deleted file mode 100644
index 7d8e233b5bb..00000000000
--- a/apps/accessibility/lib/Settings/PersonalSection.php
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCA\Accessibility\Settings;
-
-use OCP\IL10N;
-use OCP\IURLGenerator;
-use OCP\Settings\IIconSection;
-
-class PersonalSection implements IIconSection {
-
- /** @var string */
- protected $appName;
-
- /** @var IURLGenerator */
- private $urlGenerator;
-
- /** @var IL10N */
- private $l;
-
- /**
- * Personal Section constructor.
- *
- * @param string $appName
- * @param IURLGenerator $urlGenerator
- * @param IL10N $l
- */
- public function __construct(string $appName,
- IURLGenerator $urlGenerator,
- IL10N $l) {
- $this->appName = $appName;
- $this->urlGenerator = $urlGenerator;
- $this->l = $l;
- }
-
- /**
- * returns the relative path to an 16*16 icon describing the section.
- * e.g. '/core/img/places/files.svg'
- *
- * @returns string
- * @since 13.0.0
- */
- public function getIcon() {
- return $this->urlGenerator->imagePath($this->appName, 'app-dark.svg');
- }
-
- /**
- * returns the ID of the section. It is supposed to be a lower case string,
- * e.g. 'ldap'
- *
- * @returns string
- * @since 9.1
- */
- public function getID() {
- return $this->appName;
- }
-
- /**
- * returns the translated name as it should be displayed, e.g. 'LDAP / AD
- * integration'. Use the L10N service to translate it.
- *
- * @return string
- * @since 9.1
- */
- public function getName() {
- return $this->l->t('Accessibility');
- }
-
- /**
- * @return int whether the form should be rather on the top or bottom of
- * the settings navigation. The sections are arranged in ascending order of
- * the priority values. It is required to return a value between 0 and 99.
- *
- * E.g.: 70
- * @since 9.1
- */
- public function getPriority() {
- return 15;
- }
-}