Capabilities.php 2.9 KB

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