You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Admin.php 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Bjoern Schiessle <bjoern@schiessle.org>
  7. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  8. * @author Julius Härtl <jus@bitgrid.net>
  9. * @author Lukas Reschke <lukas@statuscode.ch>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. *
  12. * @license GNU AGPL version 3 or any later version
  13. *
  14. * This program is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License as
  16. * published by the Free Software Foundation, either version 3 of the
  17. * License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  26. *
  27. */
  28. namespace OCA\Theming\Settings;
  29. use OCA\Theming\ImageManager;
  30. use OCA\Theming\ThemingDefaults;
  31. use OCP\AppFramework\Http\TemplateResponse;
  32. use OCP\IConfig;
  33. use OCP\IL10N;
  34. use OCP\IURLGenerator;
  35. use OCP\Settings\ISettings;
  36. class Admin implements ISettings {
  37. /** @var IConfig */
  38. private $config;
  39. /** @var IL10N */
  40. private $l;
  41. /** @var ThemingDefaults */
  42. private $themingDefaults;
  43. /** @var IURLGenerator */
  44. private $urlGenerator;
  45. /** @var ImageManager */
  46. private $imageManager;
  47. public function __construct(IConfig $config,
  48. IL10N $l,
  49. ThemingDefaults $themingDefaults,
  50. IURLGenerator $urlGenerator,
  51. ImageManager $imageManager) {
  52. $this->config = $config;
  53. $this->l = $l;
  54. $this->themingDefaults = $themingDefaults;
  55. $this->urlGenerator = $urlGenerator;
  56. $this->imageManager = $imageManager;
  57. }
  58. /**
  59. * @return TemplateResponse
  60. */
  61. public function getForm(): TemplateResponse {
  62. $themable = true;
  63. $errorMessage = '';
  64. $theme = $this->config->getSystemValue('theme', '');
  65. if ($theme !== '') {
  66. $themable = false;
  67. $errorMessage = $this->l->t('You are already using a custom theme. Theming app settings might be overwritten by that.');
  68. }
  69. $parameters = [
  70. 'themable' => $themable,
  71. 'errorMessage' => $errorMessage,
  72. 'name' => $this->themingDefaults->getEntity(),
  73. 'url' => $this->themingDefaults->getBaseUrl(),
  74. 'slogan' => $this->themingDefaults->getSlogan(),
  75. 'color' => $this->themingDefaults->getColorPrimary(),
  76. 'uploadLogoRoute' => $this->urlGenerator->linkToRoute('theming.Theming.uploadImage'),
  77. 'canThemeIcons' => $this->imageManager->shouldReplaceIcons(),
  78. 'iconDocs' => $this->urlGenerator->linkToDocs('admin-theming-icons'),
  79. 'images' => $this->imageManager->getCustomImages(),
  80. 'imprintUrl' => $this->themingDefaults->getImprintUrl(),
  81. 'privacyUrl' => $this->themingDefaults->getPrivacyUrl(),
  82. ];
  83. return new TemplateResponse('theming', 'settings-admin', $parameters, '');
  84. }
  85. /**
  86. * @return string the section ID, e.g. 'sharing'
  87. */
  88. public function getSection(): string {
  89. return 'theming';
  90. }
  91. /**
  92. * @return int whether the form should be rather on the top or bottom of
  93. * the admin section. The forms are arranged in ascending order of the
  94. * priority values. It is required to return a value between 0 and 100.
  95. *
  96. * E.g.: 70
  97. */
  98. public function getPriority(): int {
  99. return 5;
  100. }
  101. }