1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use OCP\IConfig; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @author Björn Schießle <[email protected]> |
7
|
|
|
* @author Jan-Christoph Borchardt <[email protected]> |
8
|
|
|
* @author Joas Schilling <[email protected]> |
9
|
|
|
* @author Jörn Friedrich Dreyer <[email protected]> |
10
|
|
|
* @author Lukas Reschke <[email protected]> |
11
|
|
|
* @author Morris Jobke <[email protected]> |
12
|
|
|
* @author Pascal de Bruijn <[email protected]> |
13
|
|
|
* @author Philipp Schaffrath <[email protected]> |
14
|
|
|
* @author Robin Appelman <[email protected]> |
15
|
|
|
* @author Robin McCorkell <[email protected]> |
16
|
|
|
* @author scolebrook <[email protected]> |
17
|
|
|
* @author Thomas Müller <[email protected]> |
18
|
|
|
* @author Volkan Gezer <[email protected]> |
19
|
|
|
* |
20
|
|
|
* @copyright Copyright (c) 2018, ownCloud GmbH |
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
|
|
|
private $theme; |
38
|
|
|
private $l; |
39
|
|
|
|
40
|
|
|
private $defaultEntity; |
41
|
|
|
private $defaultName; |
42
|
|
|
private $defaultTitle; |
43
|
|
|
private $defaultBaseUrl; |
44
|
|
|
private $defaultSyncClientUrl; |
45
|
|
|
private $defaultiOSClientUrl; |
46
|
|
|
private $defaultiTunesAppId; |
47
|
|
|
private $defaultAndroidClientUrl; |
48
|
|
|
private $defaultDocBaseUrl; |
49
|
|
|
private $defaultDocVersion; |
50
|
|
|
private $defaultSlogan; |
51
|
|
|
private $defaultLogoClaim; |
52
|
|
|
private $defaultMailHeaderColor; |
53
|
|
|
/** |
54
|
|
|
* @var IConfig |
55
|
|
|
*/ |
56
|
|
|
private $config; |
57
|
|
|
|
58
|
|
|
public function __construct() { |
59
|
|
|
$this->l = \OC::$server->getL10N('lib'); |
60
|
|
|
$this->config = \OC::$server->getConfig(); |
61
|
|
|
$version = \OCP\Util::getVersion(); |
62
|
|
|
|
63
|
|
|
$this->defaultEntity = 'ownCloud'; /* e.g. company name, used for footers and copyright notices */ |
64
|
|
|
$this->defaultName = 'ownCloud'; /* short name, used when referring to the software */ |
65
|
|
|
$this->defaultTitle = 'ownCloud'; /* can be a longer name, for titles */ |
66
|
|
|
$this->defaultBaseUrl = 'https://owncloud.org'; |
67
|
|
|
$this->defaultSyncClientUrl = 'https://owncloud.org/install/#install-clients'; |
68
|
|
|
$this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8'; |
69
|
|
|
$this->defaultiTunesAppId = '543672169'; |
70
|
|
|
$this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.owncloud.android'; |
71
|
|
|
$this->defaultDocBaseUrl = 'https://doc.owncloud.org'; |
72
|
|
|
$this->defaultDocVersion = $version[0] . '.' . $version[1]; // used to generate doc links |
73
|
|
|
$this->defaultSlogan = $this->l->t('A safe home for all your data'); |
74
|
|
|
$this->defaultLogoClaim = ''; |
75
|
|
|
$this->defaultMailHeaderColor = '#1d2d44'; /* header color of mail notifications */ |
76
|
|
|
|
77
|
|
|
$themePath = OC_Util::getTheme()->getDirectory(); |
78
|
|
|
|
79
|
|
|
$defaultsPath = OC::$SERVERROOT . '/' . $themePath . '/defaults.php'; |
80
|
|
|
if (\file_exists($defaultsPath)) { |
81
|
|
|
// prevent defaults.php from printing output |
82
|
|
|
\ob_start(); |
83
|
|
|
require_once $defaultsPath; |
84
|
|
|
\ob_end_clean(); |
85
|
|
|
if (\class_exists('OC_Theme')) { |
86
|
|
|
$this->theme = new OC_Theme(); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param string $method |
93
|
|
|
*/ |
94
|
|
|
private function themeExist($method) { |
95
|
|
|
if (isset($this->theme) && \method_exists($this->theme, $method)) { |
96
|
|
|
return true; |
97
|
|
|
} |
98
|
|
|
return false; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Returns the base URL |
103
|
|
|
* @return string URL |
104
|
|
|
*/ |
105
|
|
|
public function getBaseUrl() { |
106
|
|
|
if ($this->themeExist('getBaseUrl')) { |
107
|
|
|
return $this->theme->getBaseUrl(); |
108
|
|
|
} else { |
109
|
|
|
return $this->defaultBaseUrl; |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* Returns the URL where the sync clients are listed |
115
|
|
|
* @return string URL |
116
|
|
|
*/ |
117
|
|
|
public function getSyncClientUrl() { |
118
|
|
|
if ($this->themeExist('getSyncClientUrl')) { |
119
|
|
|
return $this->theme->getSyncClientUrl(); |
120
|
|
|
} else { |
121
|
|
|
return $this->defaultSyncClientUrl; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Returns the URL to the App Store for the iOS Client |
127
|
|
|
* @return string URL |
128
|
|
|
*/ |
129
|
|
|
public function getiOSClientUrl() { |
130
|
|
|
if ($this->themeExist('getiOSClientUrl')) { |
131
|
|
|
return $this->theme->getiOSClientUrl(); |
132
|
|
|
} else { |
133
|
|
|
return $this->defaultiOSClientUrl; |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Returns the AppId for the App Store for the iOS Client |
139
|
|
|
* @return string AppId |
140
|
|
|
*/ |
141
|
|
|
public function getiTunesAppId() { |
142
|
|
|
if ($this->themeExist('getiTunesAppId')) { |
143
|
|
|
return $this->theme->getiTunesAppId(); |
144
|
|
|
} else { |
145
|
|
|
return $this->defaultiTunesAppId; |
146
|
|
|
} |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Returns the URL to Google Play for the Android Client |
151
|
|
|
* @return string URL |
152
|
|
|
*/ |
153
|
|
|
public function getAndroidClientUrl() { |
154
|
|
|
if ($this->themeExist('getAndroidClientUrl')) { |
155
|
|
|
return $this->theme->getAndroidClientUrl(); |
156
|
|
|
} else { |
157
|
|
|
return $this->defaultAndroidClientUrl; |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Returns the documentation URL |
163
|
|
|
* @return string URL |
164
|
|
|
*/ |
165
|
|
|
public function getDocBaseUrl() { |
166
|
|
|
if ($this->themeExist('getDocBaseUrl')) { |
167
|
|
|
return $this->theme->getDocBaseUrl(); |
168
|
|
|
} else { |
169
|
|
|
return $this->defaultDocBaseUrl; |
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Returns the title |
175
|
|
|
* @return string title |
176
|
|
|
*/ |
177
|
|
|
public function getTitle() { |
178
|
|
|
if ($this->themeExist('getTitle')) { |
179
|
|
|
return $this->theme->getTitle(); |
180
|
|
|
} else { |
181
|
|
|
return $this->defaultTitle; |
182
|
|
|
} |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* Returns the short name of the software |
187
|
|
|
* @return string title |
188
|
|
|
*/ |
189
|
|
|
public function getName() { |
190
|
|
|
if ($this->themeExist('getName')) { |
191
|
|
|
return $this->theme->getName(); |
192
|
|
|
} else { |
193
|
|
|
return $this->defaultName; |
194
|
|
|
} |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* Returns the short name of the software containing HTML strings |
199
|
|
|
* @return string title |
200
|
|
|
*/ |
201
|
|
|
public function getHTMLName() { |
202
|
|
|
if ($this->themeExist('getHTMLName')) { |
203
|
|
|
return $this->theme->getHTMLName(); |
204
|
|
|
} else { |
205
|
|
|
return $this->defaultName; |
206
|
|
|
} |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* Returns entity (e.g. company name) - used for footer, copyright |
211
|
|
|
* @return string entity name |
212
|
|
|
*/ |
213
|
|
|
public function getEntity() { |
214
|
|
|
if ($this->themeExist('getEntity')) { |
215
|
|
|
return $this->theme->getEntity(); |
216
|
|
|
} else { |
217
|
|
|
return $this->defaultEntity; |
218
|
|
|
} |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Returns slogan |
223
|
|
|
* @return string slogan |
224
|
|
|
*/ |
225
|
|
|
public function getSlogan() { |
226
|
|
|
if ($this->themeExist('getSlogan')) { |
227
|
|
|
return $this->theme->getSlogan(); |
228
|
|
|
} else { |
229
|
|
|
return $this->defaultSlogan; |
230
|
|
|
} |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Returns logo claim |
235
|
|
|
* @return string logo claim |
236
|
|
|
*/ |
237
|
|
|
public function getLogoClaim() { |
238
|
|
|
if ($this->themeExist('getLogoClaim')) { |
239
|
|
|
return $this->theme->getLogoClaim(); |
240
|
|
|
} else { |
241
|
|
|
return $this->defaultLogoClaim; |
242
|
|
|
} |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Returns short version of the footer |
247
|
|
|
* @return string short footer |
248
|
|
|
*/ |
249
|
|
|
public function getShortFooter() { |
250
|
|
|
if ($this->themeExist('getShortFooter')) { |
251
|
|
|
$footer = $this->theme->getShortFooter(); |
252
|
|
|
} else { |
253
|
|
|
$footer = '<a href="' . $this->getBaseUrl() . '" target="_blank" rel="noreferrer">' . $this->getEntity() . '</a>'; |
254
|
|
|
$footer .= ' – ' . $this->getSlogan(); |
255
|
|
|
|
256
|
|
|
if ($this->getImprintUrl() !== '') { |
257
|
|
|
$footer .= '<span class="nowrap"> | <a href="' . $this->getImprintUrl() . '" target="_blank">' . $this->l->t('Imprint') . '</a></span>'; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
if ($this->getPrivacyPolicyUrl() !== '') { |
261
|
|
|
$footer .= '<span class="nowrap"> | <a href="'. $this->getPrivacyPolicyUrl() .'" target="_blank">'. $this->l->t('Privacy Policy') .'</a></span>'; |
262
|
|
|
} |
263
|
|
|
} |
264
|
|
|
|
265
|
|
|
return $footer; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
/** |
269
|
|
|
* Returns long version of the footer |
270
|
|
|
* @return string long footer |
271
|
|
|
*/ |
272
|
|
|
public function getLongFooter() { |
273
|
|
|
if ($this->themeExist('getLongFooter')) { |
274
|
|
|
$footer = $this->theme->getLongFooter(); |
275
|
|
|
} else { |
276
|
|
|
$footer = $this->getShortFooter(); |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
return $footer; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* @param string $key |
284
|
|
|
*/ |
285
|
|
|
public function buildDocLinkToKey($key) { |
286
|
|
|
if ($this->themeExist('buildDocLinkToKey')) { |
287
|
|
|
return $this->theme->buildDocLinkToKey($key); |
288
|
|
|
} |
289
|
|
|
return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* Returns mail header color |
294
|
|
|
* @return string |
295
|
|
|
*/ |
296
|
|
|
public function getMailHeaderColor() { |
297
|
|
|
if ($this->themeExist('getMailHeaderColor')) { |
298
|
|
|
return $this->theme->getMailHeaderColor(); |
299
|
|
|
} else { |
300
|
|
|
return $this->defaultMailHeaderColor; |
301
|
|
|
} |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
/** |
305
|
|
|
* Returns URL to imprint |
306
|
|
|
* @return string |
307
|
|
|
*/ |
308
|
|
|
public function getImprintUrl() { |
309
|
|
|
try { |
310
|
|
|
return $this->config->getAppValue('core', 'legal.imprint_url', ''); |
311
|
|
|
} catch (\Exception $e) { |
312
|
|
|
return ''; |
313
|
|
|
} |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
/** |
317
|
|
|
* Returns URL to Privacy Policy |
318
|
|
|
* @return string |
319
|
|
|
*/ |
320
|
|
|
public function getPrivacyPolicyUrl() { |
321
|
|
|
try { |
322
|
|
|
return $this->config->getAppValue('core', 'legal.privacy_policy_url', ''); |
323
|
|
|
} catch (\Exception $e) { |
324
|
|
|
return ''; |
325
|
|
|
} |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* @internal Used for unit tests |
330
|
|
|
* |
331
|
|
|
* @param IConfig $config |
332
|
|
|
*/ |
333
|
|
|
public function setConfig(IConfig $config) { |
334
|
|
|
$this->config = $config; |
335
|
|
|
} |
336
|
|
|
} |
337
|
|
|
|