Completed
Push — master ( b08fce...a46b5e )
by Phil
16:58
created

OC_Defaults::getPrivacyPolicyUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Björn Schießle <[email protected]>
4
 * @author Jan-Christoph Borchardt <[email protected]>
5
 * @author Joas Schilling <[email protected]>
6
 * @author Jörn Friedrich Dreyer <[email protected]>
7
 * @author Lukas Reschke <[email protected]>
8
 * @author Morris Jobke <[email protected]>
9
 * @author Pascal de Bruijn <[email protected]>
10
 * @author Philipp Schaffrath <[email protected]>
11
 * @author Robin Appelman <[email protected]>
12
 * @author Robin McCorkell <[email protected]>
13
 * @author scolebrook <[email protected]>
14
 * @author Thomas Müller <[email protected]>
15
 * @author Volkan Gezer <[email protected]>
16
 *
17
 * @copyright Copyright (c) 2018, ownCloud GmbH
18
 * @license AGPL-3.0
19
 *
20
 * This code is free software: you can redistribute it and/or modify
21
 * it under the terms of the GNU Affero General Public License, version 3,
22
 * as published by the Free Software Foundation.
23
 *
24
 * This program is distributed in the hope that it will be useful,
25
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27
 * GNU Affero General Public License for more details.
28
 *
29
 * You should have received a copy of the GNU Affero General Public License, version 3,
30
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
31
 *
32
 */
33
class OC_Defaults {
34
	private $theme;
35
	private $l;
36
37
	private $defaultEntity;
38
	private $defaultName;
39
	private $defaultTitle;
40
	private $defaultBaseUrl;
41
	private $defaultSyncClientUrl;
42
	private $defaultiOSClientUrl;
43
	private $defaultiTunesAppId;
44
	private $defaultAndroidClientUrl;
45
	private $defaultDocBaseUrl;
46
	private $defaultDocVersion;
47
	private $defaultSlogan;
48
	private $defaultLogoClaim;
49
	/**
50
	 * @var \OCP\IConfig
51
	 */
52
	private $config;
53
54
	public function __construct() {
55
		$this->l = \OC::$server->getL10N('lib');
56
		$this->config = \OC::$server->getConfig();
57
		$version = \OCP\Util::getVersion();
58
59
		$this->defaultEntity = 'ownCloud'; /* e.g. company name, used for footers and copyright notices */
60
		$this->defaultName = 'ownCloud'; /* short name, used when referring to the software */
61
		$this->defaultTitle = 'ownCloud'; /* can be a longer name, for titles */
62
		$this->defaultBaseUrl = 'https://owncloud.org';
63
		$this->defaultSyncClientUrl = 'https://owncloud.org/install/#install-clients';
64
		$this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/owncloud/id543672169?mt=8';
65
		$this->defaultiTunesAppId = '543672169';
66
		$this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.owncloud.android';
67
		$this->defaultDocBaseUrl = 'https://doc.owncloud.org';
68
		$this->defaultDocVersion = $version[0] . '.' . $version[1]; // used to generate doc links
69
		$this->defaultSlogan = $this->l->t('A safe home for all your data');
70
		$this->defaultLogoClaim = '';
71
		$this->defaultMailHeaderColor = '#1d2d44'; /* header color of mail notifications */
0 ignored issues
show
Bug introduced by
The property defaultMailHeaderColor does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
72
73
		$themePath = OC_Util::getTheme()->getDirectory();
74
75
		$defaultsPath = OC::$SERVERROOT . '/' . $themePath . '/defaults.php';
76
		if (\file_exists($defaultsPath)) {
77
			// prevent defaults.php from printing output
78
			\ob_start();
79
			require_once $defaultsPath;
80
			\ob_end_clean();
81
			if (\class_exists('OC_Theme')) {
82
				$this->theme = new OC_Theme();
83
			}
84
		}
85
	}
86
87
	/**
88
	 * @param string $method
89
	 */
90
	private function themeExist($method) {
91
		if (isset($this->theme) && \method_exists($this->theme, $method)) {
92
			return true;
93
		}
94
		return false;
95
	}
96
97
	/**
98
	 * Returns the base URL
99
	 * @return string URL
100
	 */
101
	public function getBaseUrl() {
102
		if ($this->themeExist('getBaseUrl')) {
103
			return $this->theme->getBaseUrl();
104
		} else {
105
			return $this->defaultBaseUrl;
106
		}
107
	}
108
109
	/**
110
	 * Returns the URL where the sync clients are listed
111
	 * @return string URL
112
	 */
113
	public function getSyncClientUrl() {
114
		if ($this->themeExist('getSyncClientUrl')) {
115
			return $this->theme->getSyncClientUrl();
116
		} else {
117
			return $this->defaultSyncClientUrl;
118
		}
119
	}
120
121
	/**
122
	 * Returns the URL to the App Store for the iOS Client
123
	 * @return string URL
124
	 */
125
	public function getiOSClientUrl() {
126
		if ($this->themeExist('getiOSClientUrl')) {
127
			return $this->theme->getiOSClientUrl();
128
		} else {
129
			return $this->defaultiOSClientUrl;
130
		}
131
	}
132
133
	/**
134
	 * Returns the AppId for the App Store for the iOS Client
135
	 * @return string AppId
136
	 */
137
	public function getiTunesAppId() {
138
		if ($this->themeExist('getiTunesAppId')) {
139
			return $this->theme->getiTunesAppId();
140
		} else {
141
			return $this->defaultiTunesAppId;
142
		}
143
	}
144
145
	/**
146
	 * Returns the URL to Google Play for the Android Client
147
	 * @return string URL
148
	 */
149
	public function getAndroidClientUrl() {
150
		if ($this->themeExist('getAndroidClientUrl')) {
151
			return $this->theme->getAndroidClientUrl();
152
		} else {
153
			return $this->defaultAndroidClientUrl;
154
		}
155
	}
156
157
	/**
158
	 * Returns the documentation URL
159
	 * @return string URL
160
	 */
161
	public function getDocBaseUrl() {
162
		if ($this->themeExist('getDocBaseUrl')) {
163
			return $this->theme->getDocBaseUrl();
164
		} else {
165
			return $this->defaultDocBaseUrl;
166
		}
167
	}
168
169
	/**
170
	 * Returns the title
171
	 * @return string title
172
	 */
173
	public function getTitle() {
174
		if ($this->themeExist('getTitle')) {
175
			return $this->theme->getTitle();
176
		} else {
177
			return $this->defaultTitle;
178
		}
179
	}
180
181
	/**
182
	 * Returns the short name of the software
183
	 * @return string title
184
	 */
185
	public function getName() {
186
		if ($this->themeExist('getName')) {
187
			return $this->theme->getName();
188
		} else {
189
			return $this->defaultName;
190
		}
191
	}
192
193
	/**
194
	 * Returns the short name of the software containing HTML strings
195
	 * @return string title
196
	 */
197
	public function getHTMLName() {
198
		if ($this->themeExist('getHTMLName')) {
199
			return $this->theme->getHTMLName();
200
		} else {
201
			return $this->defaultName;
202
		}
203
	}
204
205
	/**
206
	 * Returns entity (e.g. company name) - used for footer, copyright
207
	 * @return string entity name
208
	 */
209
	public function getEntity() {
210
		if ($this->themeExist('getEntity')) {
211
			return $this->theme->getEntity();
212
		} else {
213
			return $this->defaultEntity;
214
		}
215
	}
216
217
	/**
218
	 * Returns slogan
219
	 * @return string slogan
220
	 */
221
	public function getSlogan() {
222
		if ($this->themeExist('getSlogan')) {
223
			return $this->theme->getSlogan();
224
		} else {
225
			return $this->defaultSlogan;
226
		}
227
	}
228
229
	/**
230
	 * Returns logo claim
231
	 * @return string logo claim
232
	 */
233
	public function getLogoClaim() {
234
		if ($this->themeExist('getLogoClaim')) {
235
			return $this->theme->getLogoClaim();
236
		} else {
237
			return $this->defaultLogoClaim;
238
		}
239
	}
240
241
	/**
242
	 * Returns short version of the footer
243
	 * @return string short footer
244
	 */
245
	public function getShortFooter() {
246
		if ($this->themeExist('getShortFooter')) {
247
			$footer = $this->theme->getShortFooter();
248
		} else {
249
			$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
250
				' rel="noreferrer">' .$this->getEntity() . '</a>'.
251
				' – ' . $this->getSlogan();
252
		}
253
254
		return $footer;
255
	}
256
257
	/**
258
	 * Returns long version of the footer
259
	 * @return string long footer
260
	 */
261
	public function getLongFooter() {
262
		if ($this->themeExist('getLongFooter')) {
263
			$footer = $this->theme->getLongFooter();
264
		} else {
265
			$footer = $this->getShortFooter();
266
		}
267
268
		return $footer;
269
	}
270
271
	/**
272
	 * @param string $key
273
	 */
274
	public function buildDocLinkToKey($key) {
275
		if ($this->themeExist('buildDocLinkToKey')) {
276
			return $this->theme->buildDocLinkToKey($key);
277
		}
278
		return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
279
	}
280
281
	/**
282
	 * Returns mail header color
283
	 * @return string
284
	 */
285
	public function getMailHeaderColor() {
286
		if ($this->themeExist('getMailHeaderColor')) {
287
			return $this->theme->getMailHeaderColor();
288
		} else {
289
			return $this->defaultMailHeaderColor;
290
		}
291
	}
292
293
	/**
294
	 * Returns URL to imprint
295
	 * @return string
296
	 */
297
	public function getImprintUrl() {
298
		return $this->config->getAppValue('core', 'legal.imprint_url', '');
299
	}
300
301
	/**
302
	 * Returns URL to Privacy Policy
303
	 * @return string
304
	 */
305
	public function getPrivacyPolicyUrl() {
306
		return $this->config->getAppValue('core', 'legal.privacy_policy_url', '');
307
	}
308
}
309