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.

102 lines
3.0 KiB

9 years ago
9 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Arthur Schiwon <blizzz@arthur-schiwon.de>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  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\Theming\Settings;
  24. use OCA\Theming\ThemingDefaults;
  25. use OCP\AppFramework\Http\TemplateResponse;
  26. use OCP\IConfig;
  27. use OCP\IL10N;
  28. use OCP\IURLGenerator;
  29. use OCP\Settings\ISettings;
  30. class Admin implements ISettings {
  31. /** @var IConfig */
  32. private $config;
  33. /** @var IL10N */
  34. private $l;
  35. /** @var ThemingDefaults */
  36. private $themingDefaults;
  37. /** @var IURLGenerator */
  38. private $urlGenerator;
  39. public function __construct(IConfig $config,
  40. IL10N $l,
  41. ThemingDefaults $themingDefaults,
  42. IURLGenerator $urlGenerator) {
  43. $this->config = $config;
  44. $this->l = $l;
  45. $this->themingDefaults = $themingDefaults;
  46. $this->urlGenerator = $urlGenerator;
  47. }
  48. /**
  49. * @return TemplateResponse
  50. */
  51. public function getForm() {
  52. $path = $this->urlGenerator->linkToRoute('theming.Theming.updateLogo');
  53. $themable = true;
  54. $errorMessage = '';
  55. $theme = $this->config->getSystemValue('theme', '');
  56. if ($theme !== '') {
  57. $themable = false;
  58. $errorMessage = $this->l->t('You already use a custom theme');
  59. }
  60. $parameters = [
  61. 'themable' => $themable,
  62. 'errorMessage' => $errorMessage,
  63. 'name' => $this->themingDefaults->getEntity(),
  64. 'url' => $this->themingDefaults->getBaseUrl(),
  65. 'slogan' => $this->themingDefaults->getSlogan(),
  66. 'color' => $this->themingDefaults->getMailHeaderColor(),
  67. 'logo' => $this->themingDefaults->getLogo(),
  68. 'logoMime' => $this->config->getAppValue('theming', 'logoMime', ''),
  69. 'background' => $this->themingDefaults->getBackground(),
  70. 'backgroundMime' => $this->config->getAppValue('theming', 'backgroundMime', ''),
  71. 'uploadLogoRoute' => $path,
  72. ];
  73. return new TemplateResponse('theming', 'settings-admin', $parameters, '');
  74. }
  75. /**
  76. * @return string the section ID, e.g. 'sharing'
  77. */
  78. public function getSection() {
  79. return 'theming';
  80. }
  81. /**
  82. * @return int whether the form should be rather on the top or bottom of
  83. * the admin section. The forms are arranged in ascending order of the
  84. * priority values. It is required to return a value between 0 and 100.
  85. *
  86. * E.g.: 70
  87. */
  88. public function getPriority() {
  89. return 5;
  90. }
  91. }