1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 2016, Joas Schilling <[email protected]> |
4
|
|
|
* |
5
|
|
|
* @author Guillaume COMPAGNON <[email protected]> |
6
|
|
|
* @author Joas Schilling <[email protected]> |
7
|
|
|
* @author Julius Härtl <[email protected]> |
8
|
|
|
* @author Morris Jobke <[email protected]> |
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
|
|
|
|
27
|
|
|
namespace OCA\Theming; |
28
|
|
|
|
29
|
|
|
use OCP\Capabilities\IPublicCapability; |
30
|
|
|
use OCP\IConfig; |
31
|
|
|
use OCP\IURLGenerator; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Class Capabilities |
35
|
|
|
* |
36
|
|
|
* @package OCA\Theming |
37
|
|
|
*/ |
38
|
|
|
class Capabilities implements IPublicCapability { |
39
|
|
|
|
40
|
|
|
/** @var ThemingDefaults */ |
41
|
|
|
protected $theming; |
42
|
|
|
|
43
|
|
|
/** @var Util */ |
44
|
|
|
protected $util; |
45
|
|
|
|
46
|
|
|
/** @var IURLGenerator */ |
47
|
|
|
protected $url; |
48
|
|
|
|
49
|
|
|
/** @var IConfig */ |
50
|
|
|
protected $config; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param ThemingDefaults $theming |
54
|
|
|
* @param Util $util |
55
|
|
|
* @param IURLGenerator $url |
56
|
|
|
* @param IConfig $config |
57
|
|
|
*/ |
58
|
|
|
public function __construct(ThemingDefaults $theming, Util $util, IURLGenerator $url, IConfig $config) { |
59
|
|
|
$this->theming = $theming; |
60
|
|
|
$this->util = $util; |
61
|
|
|
$this->url = $url; |
62
|
|
|
$this->config = $config; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Return this classes capabilities |
67
|
|
|
* |
68
|
|
|
* @return array |
69
|
|
|
*/ |
70
|
|
|
public function getCapabilities() { |
71
|
|
|
$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false); |
|
|
|
|
72
|
|
|
$color = $this->theming->getColorPrimary(); |
73
|
|
|
return [ |
74
|
|
|
'theming' => [ |
75
|
|
|
'name' => $this->theming->getName(), |
76
|
|
|
'url' => $this->theming->getBaseUrl(), |
77
|
|
|
'slogan' => $this->theming->getSlogan(), |
78
|
|
|
'color' => $color, |
79
|
|
|
'color-text' => $this->theming->getTextColorPrimary(), |
80
|
|
|
'color-element' => $this->util->elementColor($color), |
81
|
|
|
'color-element-bright' => $this->util->elementColor($color), |
82
|
|
|
'color-element-dark' => $this->util->elementColor($color, false), |
83
|
|
|
'logo' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
84
|
|
|
'background' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === false && $this->theming->getColorPrimary() !== '#0082c9') ? |
85
|
|
|
$this->theming->getColorPrimary() : |
86
|
|
|
$this->url->getAbsoluteURL($this->theming->getBackground()), |
87
|
|
|
'background-plain' => $backgroundLogo === 'backgroundColor' || ($backgroundLogo === false && $this->theming->getColorPrimary() !== '#0082c9'), |
88
|
|
|
'background-default' => !$this->util->isBackgroundThemed(), |
89
|
|
|
'logoheader' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
90
|
|
|
'favicon' => $this->url->getAbsoluteURL($this->theming->getLogo()), |
91
|
|
|
], |
92
|
|
|
]; |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|