1
0

Personal.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
  4. *
  5. * @author John Molakvoæ <skjnldsv@protonmail.com>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace OCA\Accessibility\Settings;
  24. use OCA\Accessibility\AccessibilityProvider;
  25. use OCP\AppFramework\Http\TemplateResponse;
  26. use OCP\IConfig;
  27. use OCP\IL10N;
  28. use OCP\IURLGenerator;
  29. use OCP\IUserSession;
  30. use OCP\Settings\ISettings;
  31. class Personal implements ISettings {
  32. /** @var string */
  33. protected $appName;
  34. /** @var IConfig */
  35. private $config;
  36. /** @var IUserSession */
  37. private $userSession;
  38. /** @var IL10N */
  39. private $l;
  40. /** @var IURLGenerator */
  41. private $urlGenerator;
  42. /** @var AccessibilityProvider */
  43. private $accessibilityProvider;
  44. /**
  45. * Settings constructor.
  46. *
  47. * @param string $appName
  48. * @param IConfig $config
  49. * @param IUserSession $userSession
  50. * @param IL10N $l
  51. * @param IURLGenerator $urlGenerator
  52. * @param AccessibilityProvider $accessibilityProvider
  53. */
  54. public function __construct(string $appName,
  55. IConfig $config,
  56. IUserSession $userSession,
  57. IL10N $l,
  58. IURLGenerator $urlGenerator,
  59. AccessibilityProvider $accessibilityProvider) {
  60. $this->appName = $appName;
  61. $this->config = $config;
  62. $this->userSession = $userSession;
  63. $this->l = $l;
  64. $this->urlGenerator = $urlGenerator;
  65. $this->accessibilityProvider = $accessibilityProvider;
  66. }
  67. /**
  68. * @return TemplateResponse returns the instance with all parameters set, ready to be rendered
  69. * @since 9.1
  70. */
  71. public function getForm() {
  72. $serverData = [
  73. 'themes' => $this->accessibilityProvider->getThemes(),
  74. 'fonts' => $this->accessibilityProvider->getFonts(),
  75. 'theme' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false),
  76. 'font' => $this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'font', false)
  77. ];
  78. return new TemplateResponse($this->appName, 'settings-personal', ['serverData' => $serverData]);
  79. }
  80. /**
  81. * @return string the section ID, e.g. 'sharing'
  82. * @since 9.1
  83. */
  84. public function getSection() {
  85. return $this->appName;
  86. }
  87. /**
  88. * @return int whether the form should be rather on the top or bottom of
  89. * the admin section. The forms are arranged in ascending order of the
  90. * priority values. It is required to return a value between 0 and 100.
  91. *
  92. * E.g.: 70
  93. * @since 9.1
  94. */
  95. public function getPriority() {
  96. return 40;
  97. }
  98. }