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.

Capabilities.php 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, Joas Schilling <coding@schilljs.com>
  4. *
  5. * @author Guillaume COMPAGNON <gcompagnon@outlook.com>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Julien Veyssier <eneiluj@posteo.net>
  8. * @author Julius Härtl <jus@bitgrid.net>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. *
  11. * @license GNU AGPL version 3 or any later version
  12. *
  13. * This program is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License as
  15. * published by the Free Software Foundation, either version 3 of the
  16. * License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. *
  26. */
  27. namespace OCA\Theming;
  28. use OCP\Capabilities\IPublicCapability;
  29. use OCP\IConfig;
  30. use OCP\IURLGenerator;
  31. /**
  32. * Class Capabilities
  33. *
  34. * @package OCA\Theming
  35. */
  36. class Capabilities implements IPublicCapability {
  37. /** @var ThemingDefaults */
  38. protected $theming;
  39. /** @var Util */
  40. protected $util;
  41. /** @var IURLGenerator */
  42. protected $url;
  43. /** @var IConfig */
  44. protected $config;
  45. /**
  46. * @param ThemingDefaults $theming
  47. * @param Util $util
  48. * @param IURLGenerator $url
  49. * @param IConfig $config
  50. */
  51. public function __construct(ThemingDefaults $theming, Util $util, IURLGenerator $url, IConfig $config) {
  52. $this->theming = $theming;
  53. $this->util = $util;
  54. $this->url = $url;
  55. $this->config = $config;
  56. }
  57. /**
  58. * Return this classes capabilities
  59. *
  60. * @return array
  61. */
  62. public function getCapabilities() {
  63. $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', '');
  64. $color = $this->theming->getColorPrimary();
  65. return [
  66. 'theming' => [
  67. 'name' => $this->theming->getName(),
  68. 'url' => $this->theming->getBaseUrl(),
  69. 'slogan' => $this->theming->getSlogan(),
  70. 'color' => $color,
  71. 'color-text' => $this->theming->getTextColorPrimary(),
  72. 'color-element' => $this->util->elementColor($color),
  73. 'color-element-bright' => $this->util->elementColor($color),
  74. 'color-element-dark' => $this->util->elementColor($color, false),
  75. 'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()),
  76. 'background' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === '' && $this->theming->getColorPrimary() !== '#0082c9') ?
  77. $this->theming->getColorPrimary() :
  78. $this->url->getAbsoluteURL($this->theming->getBackground()),
  79. 'background-plain' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === '' && $this->theming->getColorPrimary() !== '#0082c9'),
  80. 'background-default' => !$this->util->isBackgroundThemed(),
  81. 'logoheader' => $this->url->getAbsoluteURL($this->theming->getLogo()),
  82. 'favicon' => $this->url->getAbsoluteURL($this->theming->getLogo()),
  83. ],
  84. ];
  85. }
  86. }