2016-09-05 15:25:51 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2016, Joas Schilling <coding@schilljs.com>
|
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Guillaume COMPAGNON <gcompagnon@outlook.com>
|
2016-09-05 15:25:51 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2020-12-16 16:54:15 +03:00
|
|
|
* @author Julien Veyssier <eneiluj@posteo.net>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Julius Härtl <jus@bitgrid.net>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2016-09-05 15:25:51 +03:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2016-09-05 15:25:51 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace OCA\Theming;
|
|
|
|
|
2017-06-30 12:08:54 +03:00
|
|
|
use OCP\Capabilities\IPublicCapability;
|
2017-05-17 14:16:44 +03:00
|
|
|
use OCP\IConfig;
|
2016-09-06 09:55:22 +03:00
|
|
|
use OCP\IURLGenerator;
|
2016-09-05 15:25:51 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class Capabilities
|
|
|
|
*
|
|
|
|
* @package OCA\Theming
|
|
|
|
*/
|
2017-06-30 12:08:54 +03:00
|
|
|
class Capabilities implements IPublicCapability {
|
2016-09-05 15:25:51 +03:00
|
|
|
|
|
|
|
/** @var ThemingDefaults */
|
|
|
|
protected $theming;
|
|
|
|
|
2017-08-15 14:33:14 +03:00
|
|
|
/** @var Util */
|
|
|
|
protected $util;
|
|
|
|
|
2016-09-06 09:55:22 +03:00
|
|
|
/** @var IURLGenerator */
|
|
|
|
protected $url;
|
|
|
|
|
2017-05-17 14:16:44 +03:00
|
|
|
/** @var IConfig */
|
|
|
|
protected $config;
|
|
|
|
|
2016-09-05 15:25:51 +03:00
|
|
|
/**
|
|
|
|
* @param ThemingDefaults $theming
|
2017-08-15 14:33:14 +03:00
|
|
|
* @param Util $util
|
2016-09-06 09:55:22 +03:00
|
|
|
* @param IURLGenerator $url
|
2017-05-17 14:16:44 +03:00
|
|
|
* @param IConfig $config
|
2016-09-05 15:25:51 +03:00
|
|
|
*/
|
2017-08-15 14:33:14 +03:00
|
|
|
public function __construct(ThemingDefaults $theming, Util $util, IURLGenerator $url, IConfig $config) {
|
2016-09-05 15:25:51 +03:00
|
|
|
$this->theming = $theming;
|
2017-08-15 14:33:14 +03:00
|
|
|
$this->util = $util;
|
2016-09-06 09:55:22 +03:00
|
|
|
$this->url = $url;
|
2017-05-17 14:16:44 +03:00
|
|
|
$this->config = $config;
|
2016-09-05 15:25:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return this classes capabilities
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getCapabilities() {
|
2020-10-20 13:36:41 +03:00
|
|
|
$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', '');
|
2017-11-07 14:31:23 +03:00
|
|
|
$color = $this->theming->getColorPrimary();
|
2016-09-05 15:25:51 +03:00
|
|
|
return [
|
|
|
|
'theming' => [
|
|
|
|
'name' => $this->theming->getName(),
|
|
|
|
'url' => $this->theming->getBaseUrl(),
|
|
|
|
'slogan' => $this->theming->getSlogan(),
|
2017-11-07 14:31:23 +03:00
|
|
|
'color' => $color,
|
2017-12-08 14:16:05 +03:00
|
|
|
'color-text' => $this->theming->getTextColorPrimary(),
|
2017-11-07 14:31:23 +03:00
|
|
|
'color-element' => $this->util->elementColor($color),
|
2020-06-26 10:58:45 +03:00
|
|
|
'color-element-bright' => $this->util->elementColor($color),
|
|
|
|
'color-element-dark' => $this->util->elementColor($color, false),
|
2016-09-06 09:55:22 +03:00
|
|
|
'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()),
|
2020-10-20 13:36:41 +03:00
|
|
|
'background' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === '' && $this->theming->getColorPrimary() !== '#0082c9') ?
|
2017-05-17 14:16:44 +03:00
|
|
|
$this->theming->getColorPrimary() :
|
|
|
|
$this->url->getAbsoluteURL($this->theming->getBackground()),
|
2020-10-20 13:36:41 +03:00
|
|
|
'background-plain' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === '' && $this->theming->getColorPrimary() !== '#0082c9'),
|
2018-01-10 01:11:49 +03:00
|
|
|
'background-default' => !$this->util->isBackgroundThemed(),
|
2019-08-21 18:18:23 +03:00
|
|
|
'logoheader' => $this->url->getAbsoluteURL($this->theming->getLogo()),
|
|
|
|
'favicon' => $this->url->getAbsoluteURL($this->theming->getLogo()),
|
2016-09-05 15:25:51 +03:00
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|