1
0

Capabilities.php 2.5 KB

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