|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Björn Schießle <[email protected]> |
|
6
|
|
|
* @author Felix A. Epp <[email protected]> |
|
7
|
|
|
* @author Jan-Christoph Borchardt <[email protected]> |
|
8
|
|
|
* @author Julius Haertl <[email protected]> |
|
9
|
|
|
* @author Julius Härtl <[email protected]> |
|
10
|
|
|
* @author Jörn Friedrich Dreyer <[email protected]> |
|
11
|
|
|
* @author Lukas Reschke <[email protected]> |
|
12
|
|
|
* @author Morris Jobke <[email protected]> |
|
13
|
|
|
* @author Pascal de Bruijn <[email protected]> |
|
14
|
|
|
* @author Robin Appelman <[email protected]> |
|
15
|
|
|
* @author Robin McCorkell <[email protected]> |
|
16
|
|
|
* @author Roeland Jago Douma <[email protected]> |
|
17
|
|
|
* @author scolebrook <[email protected]> |
|
18
|
|
|
* @author Thomas Müller <[email protected]> |
|
19
|
|
|
* @author Volkan Gezer <[email protected]> |
|
20
|
|
|
* |
|
21
|
|
|
* @license AGPL-3.0 |
|
22
|
|
|
* |
|
23
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
24
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
25
|
|
|
* as published by the Free Software Foundation. |
|
26
|
|
|
* |
|
27
|
|
|
* This program is distributed in the hope that it will be useful, |
|
28
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
29
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
30
|
|
|
* GNU Affero General Public License for more details. |
|
31
|
|
|
* |
|
32
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
33
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
34
|
|
|
* |
|
35
|
|
|
*/ |
|
36
|
|
|
class OC_Defaults { |
|
37
|
|
|
|
|
38
|
|
|
private $theme; |
|
39
|
|
|
private $l; |
|
40
|
|
|
|
|
41
|
|
|
private $defaultEntity; |
|
42
|
|
|
private $defaultName; |
|
43
|
|
|
private $defaultTitle; |
|
44
|
|
|
private $defaultBaseUrl; |
|
45
|
|
|
private $defaultSyncClientUrl; |
|
46
|
|
|
private $defaultiOSClientUrl; |
|
47
|
|
|
private $defaultiTunesAppId; |
|
48
|
|
|
private $defaultAndroidClientUrl; |
|
49
|
|
|
private $defaultDocBaseUrl; |
|
50
|
|
|
private $defaultDocVersion; |
|
51
|
|
|
private $defaultSlogan; |
|
52
|
|
|
private $defaultColorPrimary; |
|
53
|
|
|
private $defaultTextColorPrimary; |
|
54
|
|
|
|
|
55
|
|
|
public function __construct() { |
|
56
|
|
|
$this->l = \OC::$server->getL10N('lib'); |
|
57
|
|
|
$config = \OC::$server->getConfig(); |
|
58
|
|
|
|
|
59
|
|
|
$this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */ |
|
60
|
|
|
$this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */ |
|
61
|
|
|
$this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */ |
|
62
|
|
|
$this->defaultBaseUrl = 'https://nextcloud.com'; |
|
63
|
|
|
$this->defaultSyncClientUrl = $config->getSystemValue('customclient_desktop', 'https://nextcloud.com/install/#install-clients'); |
|
64
|
|
|
$this->defaultiOSClientUrl = $config->getSystemValue('customclient_ios', 'https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8'); |
|
65
|
|
|
$this->defaultiTunesAppId = $config->getSystemValue('customclient_ios_appid', '1125420102'); |
|
66
|
|
|
$this->defaultAndroidClientUrl = $config->getSystemValue('customclient_android', 'https://play.google.com/store/apps/details?id=com.nextcloud.client'); |
|
67
|
|
|
$this->defaultDocBaseUrl = 'https://docs.nextcloud.com'; |
|
68
|
|
|
$this->defaultDocVersion = '14'; // used to generate doc links |
|
69
|
|
|
$this->defaultSlogan = $this->l->t('a safe home for all your data'); |
|
70
|
|
|
$this->defaultColorPrimary = '#0082c9'; |
|
71
|
|
|
$this->defaultTextColorPrimary = '#ffffff'; |
|
72
|
|
|
|
|
73
|
|
|
$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php'; |
|
74
|
|
|
if (file_exists($themePath)) { |
|
75
|
|
|
// prevent defaults.php from printing output |
|
76
|
|
|
ob_start(); |
|
77
|
|
|
require_once $themePath; |
|
78
|
|
|
ob_end_clean(); |
|
79
|
|
|
if (class_exists('OC_Theme')) { |
|
80
|
|
|
$this->theme = new OC_Theme(); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @param string $method |
|
87
|
|
|
*/ |
|
88
|
|
|
private function themeExist($method) { |
|
89
|
|
|
if (isset($this->theme) && method_exists($this->theme, $method)) { |
|
90
|
|
|
return true; |
|
91
|
|
|
} |
|
92
|
|
|
return false; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* Returns the base URL |
|
97
|
|
|
* @return string URL |
|
98
|
|
|
*/ |
|
99
|
|
|
public function getBaseUrl() { |
|
100
|
|
|
if ($this->themeExist('getBaseUrl')) { |
|
101
|
|
|
return $this->theme->getBaseUrl(); |
|
102
|
|
|
} else { |
|
103
|
|
|
return $this->defaultBaseUrl; |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Returns the URL where the sync clients are listed |
|
109
|
|
|
* @return string URL |
|
110
|
|
|
*/ |
|
111
|
|
|
public function getSyncClientUrl() { |
|
112
|
|
|
if ($this->themeExist('getSyncClientUrl')) { |
|
113
|
|
|
return $this->theme->getSyncClientUrl(); |
|
114
|
|
|
} else { |
|
115
|
|
|
return $this->defaultSyncClientUrl; |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Returns the URL to the App Store for the iOS Client |
|
121
|
|
|
* @return string URL |
|
122
|
|
|
*/ |
|
123
|
|
|
public function getiOSClientUrl() { |
|
124
|
|
|
if ($this->themeExist('getiOSClientUrl')) { |
|
125
|
|
|
return $this->theme->getiOSClientUrl(); |
|
126
|
|
|
} else { |
|
127
|
|
|
return $this->defaultiOSClientUrl; |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
/** |
|
132
|
|
|
* Returns the AppId for the App Store for the iOS Client |
|
133
|
|
|
* @return string AppId |
|
134
|
|
|
*/ |
|
135
|
|
|
public function getiTunesAppId() { |
|
136
|
|
|
if ($this->themeExist('getiTunesAppId')) { |
|
137
|
|
|
return $this->theme->getiTunesAppId(); |
|
138
|
|
|
} else { |
|
139
|
|
|
return $this->defaultiTunesAppId; |
|
140
|
|
|
} |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Returns the URL to Google Play for the Android Client |
|
145
|
|
|
* @return string URL |
|
146
|
|
|
*/ |
|
147
|
|
|
public function getAndroidClientUrl() { |
|
148
|
|
|
if ($this->themeExist('getAndroidClientUrl')) { |
|
149
|
|
|
return $this->theme->getAndroidClientUrl(); |
|
150
|
|
|
} else { |
|
151
|
|
|
return $this->defaultAndroidClientUrl; |
|
152
|
|
|
} |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Returns the documentation URL |
|
157
|
|
|
* @return string URL |
|
158
|
|
|
*/ |
|
159
|
|
|
public function getDocBaseUrl() { |
|
160
|
|
|
if ($this->themeExist('getDocBaseUrl')) { |
|
161
|
|
|
return $this->theme->getDocBaseUrl(); |
|
162
|
|
|
} else { |
|
163
|
|
|
return $this->defaultDocBaseUrl; |
|
164
|
|
|
} |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* Returns the title |
|
169
|
|
|
* @return string title |
|
170
|
|
|
*/ |
|
171
|
|
|
public function getTitle() { |
|
172
|
|
|
if ($this->themeExist('getTitle')) { |
|
173
|
|
|
return $this->theme->getTitle(); |
|
174
|
|
|
} else { |
|
175
|
|
|
return $this->defaultTitle; |
|
176
|
|
|
} |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* Returns the short name of the software |
|
181
|
|
|
* @return string title |
|
182
|
|
|
*/ |
|
183
|
|
|
public function getName() { |
|
184
|
|
|
if ($this->themeExist('getName')) { |
|
185
|
|
|
return $this->theme->getName(); |
|
186
|
|
|
} else { |
|
187
|
|
|
return $this->defaultName; |
|
188
|
|
|
} |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
/** |
|
192
|
|
|
* Returns the short name of the software containing HTML strings |
|
193
|
|
|
* @return string title |
|
194
|
|
|
*/ |
|
195
|
|
|
public function getHTMLName() { |
|
196
|
|
|
if ($this->themeExist('getHTMLName')) { |
|
197
|
|
|
return $this->theme->getHTMLName(); |
|
198
|
|
|
} else { |
|
199
|
|
|
return $this->defaultName; |
|
200
|
|
|
} |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* Returns entity (e.g. company name) - used for footer, copyright |
|
205
|
|
|
* @return string entity name |
|
206
|
|
|
*/ |
|
207
|
|
|
public function getEntity() { |
|
208
|
|
|
if ($this->themeExist('getEntity')) { |
|
209
|
|
|
return $this->theme->getEntity(); |
|
210
|
|
|
} else { |
|
211
|
|
|
return $this->defaultEntity; |
|
212
|
|
|
} |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
/** |
|
216
|
|
|
* Returns slogan |
|
217
|
|
|
* @return string slogan |
|
218
|
|
|
*/ |
|
219
|
|
|
public function getSlogan() { |
|
220
|
|
|
if ($this->themeExist('getSlogan')) { |
|
221
|
|
|
return $this->theme->getSlogan(); |
|
222
|
|
|
} else { |
|
223
|
|
|
return $this->defaultSlogan; |
|
224
|
|
|
} |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
/** |
|
228
|
|
|
* Returns logo claim |
|
229
|
|
|
* @return string logo claim |
|
230
|
|
|
* @deprecated 13.0.0 |
|
231
|
|
|
*/ |
|
232
|
|
|
public function getLogoClaim() { |
|
233
|
|
|
return ''; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
/** |
|
237
|
|
|
* Returns short version of the footer |
|
238
|
|
|
* @return string short footer |
|
239
|
|
|
*/ |
|
240
|
|
|
public function getShortFooter() { |
|
241
|
|
|
if ($this->themeExist('getShortFooter')) { |
|
242
|
|
|
$footer = $this->theme->getShortFooter(); |
|
243
|
|
|
} else { |
|
244
|
|
|
$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' . |
|
245
|
|
|
' rel="noreferrer noopener">' .$this->getEntity() . '</a>'. |
|
246
|
|
|
' – ' . $this->getSlogan(); |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
return $footer; |
|
250
|
|
|
} |
|
251
|
|
|
|
|
252
|
|
|
/** |
|
253
|
|
|
* Returns long version of the footer |
|
254
|
|
|
* @return string long footer |
|
255
|
|
|
*/ |
|
256
|
|
|
public function getLongFooter() { |
|
257
|
|
|
if ($this->themeExist('getLongFooter')) { |
|
258
|
|
|
$footer = $this->theme->getLongFooter(); |
|
259
|
|
|
} else { |
|
260
|
|
|
$footer = $this->getShortFooter(); |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
return $footer; |
|
264
|
|
|
} |
|
265
|
|
|
|
|
266
|
|
|
/** |
|
267
|
|
|
* @param string $key |
|
268
|
|
|
* @return string URL to doc with key |
|
269
|
|
|
*/ |
|
270
|
|
|
public function buildDocLinkToKey($key) { |
|
271
|
|
|
if ($this->themeExist('buildDocLinkToKey')) { |
|
272
|
|
|
return $this->theme->buildDocLinkToKey($key); |
|
273
|
|
|
} |
|
274
|
|
|
return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key; |
|
275
|
|
|
} |
|
276
|
|
|
|
|
277
|
|
|
/** |
|
278
|
|
|
* Returns primary color |
|
279
|
|
|
* @return string |
|
280
|
|
|
*/ |
|
281
|
|
|
public function getColorPrimary() { |
|
282
|
|
|
|
|
283
|
|
|
if ($this->themeExist('getColorPrimary')) { |
|
284
|
|
|
return $this->theme->getColorPrimary(); |
|
285
|
|
|
} |
|
286
|
|
|
if ($this->themeExist('getMailHeaderColor')) { |
|
287
|
|
|
return $this->theme->getMailHeaderColor(); |
|
288
|
|
|
} |
|
289
|
|
|
return $this->defaultColorPrimary; |
|
290
|
|
|
} |
|
291
|
|
|
|
|
292
|
|
|
/** |
|
293
|
|
|
* @return array scss variables to overwrite |
|
294
|
|
|
*/ |
|
295
|
|
|
public function getScssVariables() { |
|
296
|
|
|
if($this->themeExist('getScssVariables')) { |
|
297
|
|
|
return $this->theme->getScssVariables(); |
|
298
|
|
|
} |
|
299
|
|
|
return []; |
|
300
|
|
|
} |
|
301
|
|
|
|
|
302
|
|
|
public function shouldReplaceIcons() { |
|
303
|
|
|
return false; |
|
304
|
|
|
} |
|
305
|
|
|
|
|
306
|
|
|
/** |
|
307
|
|
|
* Themed logo url |
|
308
|
|
|
* |
|
309
|
|
|
* @param bool $useSvg Whether to point to the SVG image or a fallback |
|
310
|
|
|
* @return string |
|
311
|
|
|
*/ |
|
312
|
|
|
public function getLogo($useSvg = true) { |
|
313
|
|
|
if ($this->themeExist('getLogo')) { |
|
314
|
|
|
return $this->theme->getLogo($useSvg); |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
if($useSvg) { |
|
318
|
|
|
$logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.svg'); |
|
319
|
|
|
} else { |
|
320
|
|
|
$logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.png'); |
|
321
|
|
|
} |
|
322
|
|
|
return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion())); |
|
323
|
|
|
} |
|
324
|
|
|
|
|
325
|
|
|
public function getTextColorPrimary() { |
|
326
|
|
|
if ($this->themeExist('getTextColorPrimary')) { |
|
327
|
|
|
return $this->theme->getTextColorPrimary(); |
|
328
|
|
|
} |
|
329
|
|
|
return $this->defaultTextColorPrimary; |
|
330
|
|
|
} |
|
331
|
|
|
} |
|
332
|
|
|
|