summaryrefslogtreecommitdiffstats
path: root/lib/defaults.php
blob: eb531d1e05236ef6fedbc650dd0ef5ee038f766f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<?php

/**
 * Default strings and values which differ between the enterprise and the
 * community edition. Use the get methods to always get the right strings.
 */


if (file_exists(OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php')) {
	require_once 'themes/' . OC_Util::getTheme() . '/defaults.php';
}

class OC_Defaults {

	private $theme;
	private $l;

	private $defaultEntity;
	private $defaultName;
	private $defaultTitle;
	private $defaultBaseUrl;
	private $defaultSyncClientUrl;
	private $defaultDocBaseUrl;
	private $defaultSlogan;
	private $defaultLogoClaim;

	function __construct() {
		$this->l = OC_L10N::get('core');

		$this->defaultEntity = "ownCloud"; /* e.g. company name, used for footers and copyright notices */
		$this->defaultName = "ownCloud"; /* short name, used when referring to the software */
		$this->defaultTitle = "ownCloud"; /* can be a longer name, for titles */
		$this->defaultBaseUrl = "http://owncloud.org";
		$this->defaultSyncClientUrl = " http://owncloud.org/sync-clients/";
		$this->defaultDocBaseUrl = "http://doc.owncloud.org";
		$this->defaultSlogan = $this->l->t("web services under your control");
		$this->defaultLogoClaim = "";

		if (class_exists("OC_Theme")) {
			$this->theme = new OC_Theme();
		}
	}

	private function themeExist($method) {
		if (OC_Util::getTheme() !== '' && method_exists('OC_Theme', $method)) {
			return true;
		}
		return false;
	}

	/**
	 * @brief subject for share notification mail
	 * @param string $user user who shared the item
	 * @pram string $itemName name of the item
	 */
	public function getShareNotificationSubject($user, $itemName) {
		if ($this->themeExist('getShareNotificationSubject')) {
			return $this->theme->getShareNotificationSubject($user, $itemName);
		} else {
			return $this->l->t("%s shared »%s« with you", array($user, $itemName));
		}
	}

	/**
	 * @brief mail body for share notification mail (text only)
	 * @param string $sender owner of the file/folder
	 * @param string $itemName name of the file/folder
	 * @param string $link link directly to the file/folder in your ownCloud
	 * @param string $expiration expiration date
	 */
	public function getShareNotificationTextHtml($sender, $itemName, $link, $expiration=null) {
		if ($this->themeExist('getShareNotificationTextHtml')) {
			return $this->theme->getShareNotificationTextHtml($sender, $itemName, $link, $expiration);
		} else {

			$message = $this->l->t('Hey there,<br><br>just letting you know that %s shared »%s« with you.'.
					'<br><a href="%s">View it!</a>', array($sender, $itemName, $link));

			if ($expiration) {
				$message .= '<br><br>';
				$message .= $this->l->t("The share will expire at %s.", array($expiration));
			}

			$message .= '<br><br>';
			$message .= $this->l->t('Cheers!');

			return $message;
		}
	}

	/**
	 * @brief mail body for share notification mail (text only)
	 * @param string $sender owner of the file/folder
	 * @param string $itemName name of the file/folder
	 * @param string $link link directly to the file/folder in your ownCloud
	 * @param string $expiration expiration date
	 */
	public function getShareNotificationTextAlt($sender, $itemName, $link, $expiration=null) {
		if ($this->themeExist('getShareNotificationTextAlt')) {
			return $this->theme->getShareNotificationTextAlt($sender, $itemName, $link, $expiration);
		} else {

			$message = $this->l->t("Hey there,\n\njust letting you know that %s shared %s with you.\n".
					"View it: %s", array($sender, $itemName, $link));

			if ($expiration) {
				$message .= "\n\n";
				$message .= $this->l->t("The share will expire at %s.", array($expiration));
			}

			$message .= "\n\n";
			$message .= $this->l->t('Cheers!');

			return $message;
		}
	}

	public function getMailFooterHtml() {
		if ($this->themeExist('getMailFooterHtml')) {
			return $this->theme->getMailFooterHtml();
		} else {
			$footer = $this->getName() . ' - ' . $this->getSlogan() .
					'<br>' .
					'<a href="'. $this->getBaseUrl() .'">'.$this->getBaseUrl().'</a>';

			return $footer;
		}
	}

		public function getMailFooterAlt() {
		if ($this->themeExist('getMailFooterAlt')) {
			return $this->theme->getMailFooterAlt();
		} else {
			$footer = $this->getName() . ' - ' . $this->getSlogan() .
					"\n" . $this->getBaseUrl();

			return $footer;
		}
	}

	public function getBaseUrl() {
		if ($this->themeExist('getBaseUrl')) {
			return $this->theme->getBaseUrl();
		} else {
			return $this->defaultBaseUrl;
		}
	}

	public function getSyncClientUrl() {
		if ($this->themeExist('getSyncClientUrl')) {
			return $this->theme->getSyncClientUrl();
		} else {
			return $this->defaultSyncClientUrl;
		}
	}

	public function getDocBaseUrl() {
		if ($this->themeExist('getDocBaseUrl')) {
			return $this->theme->getDocBaseUrl();
		} else {
			return $this->defaultDocBaseUrl;
		}
	}

	public function getTitle() {
		if ($this->themeExist('getTitle')) {
			return $this->theme->getTitle();
		} else {
			return $this->defaultTitle;
		}
	}

	public function getName() {
		if ($this->themeExist('getName')) {
			return $this->theme->getName();
		} else {
			return $this->defaultName;
		}
	}

	public function getEntity() {
		if ($this->themeExist('getEntity')) {
			return $this->theme->getEntity();
		} else {
			return $this->defaultEntity;
		}
	}

	public function getSlogan() {
		if ($this->themeExist('getSlogan')) {
			return $this->theme->getSlogan();
		} else {
			return $this->defaultSlogan;
		}
	}

	public function getLogoClaim() {
		if ($this->themeExist('getLogoClaim')) {
			return $this->theme->getLogoClaim();
		} else {
			return $this->defaultLogoClaim;
		}
	}

	public function getShortFooter() {
		if ($this->themeExist('getShortFooter')) {
			$footer = $this->theme->getShortFooter();
		} else {
			$footer = "<a href=\"". $this->getBaseUrl() . "\" target=\"_blank\">" .$this->getEntity() . "</a>".
				' – ' . $this->getSlogan();
		}

		return $footer;
	}

	public function getLongFooter() {
		if ($this->themeExist('getLongFooter')) {
			$footer = $this->theme->getLongFooter();
		} else {
			$footer = $this->getShortFooter();
		}

		return $footer;
	}

}