Completed
Pull Request — master (#4734)
by Lukas
46:40 queued 32:18
created
lib/public/Defaults.php 1 patch
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -40,176 +40,176 @@
 block discarded – undo
40 40
  */
41 41
 class Defaults {
42 42
 
43
-	/**
44
-	 * \OC_Defaults instance to retrieve the defaults
45
-	 * @since 6.0.0
46
-	 */
47
-	private $defaults;
48
-
49
-	/**
50
-	 * creates a \OC_Defaults instance which is used in all methods to retrieve the
51
-	 * actual defaults
52
-	 * @since 6.0.0
53
-	 */
54
-	public function __construct(\OC_Defaults $defaults = null) {
55
-		if ($defaults === null) {
56
-			$defaults = \OC::$server->getThemingDefaults();
57
-		}
58
-		$this->defaults = $defaults;
59
-	}
60
-
61
-	/**
62
-	 * get base URL for the organisation behind your ownCloud instance
63
-	 * @return string
64
-	 * @since 6.0.0
65
-	 */
66
-	public function getBaseUrl() {
67
-		return $this->defaults->getBaseUrl();
68
-	}
69
-
70
-	/**
71
-	 * link to the desktop sync client
72
-	 * @return string
73
-	 * @since 6.0.0
74
-	 */
75
-	public function getSyncClientUrl() {
76
-		return $this->defaults->getSyncClientUrl();
77
-	}
78
-
79
-	/**
80
-	 * link to the iOS client
81
-	 * @return string
82
-	 * @since 8.0.0
83
-	 */
84
-	public function getiOSClientUrl() {
85
-		return $this->defaults->getiOSClientUrl();
86
-	}
87
-
88
-	/**
89
-	 * link to the Android client
90
-	 * @return string
91
-	 * @since 8.0.0
92
-	 */
93
-	public function getAndroidClientUrl() {
94
-		return $this->defaults->getAndroidClientUrl();
95
-	}
96
-
97
-	/**
98
-	 * base URL to the documentation of your ownCloud instance
99
-	 * @return string
100
-	 * @since 6.0.0
101
-	 */
102
-	public function getDocBaseUrl() {
103
-		return $this->defaults->getDocBaseUrl();
104
-	}
105
-
106
-	/**
107
-	 * name of your ownCloud instance
108
-	 * @return string
109
-	 * @since 6.0.0
110
-	 */
111
-	public function getName() {
112
-		return $this->defaults->getName();
113
-	}
114
-
115
-	/**
116
-	 * name of your ownCloud instance containing HTML styles
117
-	 * @return string
118
-	 * @since 8.0.0
119
-	 */
120
-	public function getHTMLName() {
121
-		return $this->defaults->getHTMLName();
122
-	}
123
-
124
-	/**
125
-	 * Entity behind your onwCloud instance
126
-	 * @return string
127
-	 * @since 6.0.0
128
-	 */
129
-	public function getEntity() {
130
-		return $this->defaults->getEntity();
131
-	}
132
-
133
-	/**
134
-	 * ownCloud slogan
135
-	 * @return string
136
-	 * @since 6.0.0
137
-	 */
138
-	public function getSlogan() {
139
-		return $this->defaults->getSlogan();
140
-	}
141
-
142
-	/**
143
-	 * logo claim
144
-	 * @return string
145
-	 * @since 6.0.0
146
-	 */
147
-	public function getLogoClaim() {
148
-		return $this->defaults->getLogoClaim();
149
-	}
150
-
151
-	/**
152
-	 * footer, short version
153
-	 * @return string
154
-	 * @since 6.0.0
155
-	 */
156
-	public function getShortFooter() {
157
-		return $this->defaults->getShortFooter();
158
-	}
159
-
160
-	/**
161
-	 * footer, long version
162
-	 * @return string
163
-	 * @since 6.0.0
164
-	 */
165
-	public function getLongFooter() {
166
-		return $this->defaults->getLongFooter();
167
-	}
168
-
169
-	/**
170
-	 * Returns the AppId for the App Store for the iOS Client
171
-	 * @return string AppId
172
-	 * @since 8.0.0
173
-	 */
174
-	public function getiTunesAppId() {
175
-		return $this->defaults->getiTunesAppId();
176
-	}
177
-
178
-	/**
179
-	 * Themed logo url
180
-	 *
181
-	 * @param bool $useSvg Whether to point to the SVG image or a fallback
182
-	 * @return string
183
-	 * @since 12.0.0
184
-	 */
185
-	public function getLogo($useSvg = true) {
186
-		return $this->defaults->getLogo($useSvg);
187
-	}
188
-
189
-	/**
190
-	 * Returns primary color
191
-	 * @return string
192
-	 * @since 12.0.0
193
-	 */
194
-	public function getColorPrimary() {
195
-		return $this->defaults->getColorPrimary();
196
-	}
197
-
198
-	/**
199
-	 * @param string $key
200
-	 * @return string URL to doc with key
201
-	 * @since 12.0.0
202
-	 */
203
-	public function buildDocLinkToKey($key) {
204
-		return $this->defaults->buildDocLinkToKey($key);
205
-	}
206
-
207
-	/**
208
-	 * Returns the title
209
-	 * @return string title
210
-	 * @since 12.0.0
211
-	 */
212
-	public function getTitle() {
213
-		return $this->defaults->getTitle();
214
-	}
43
+    /**
44
+     * \OC_Defaults instance to retrieve the defaults
45
+     * @since 6.0.0
46
+     */
47
+    private $defaults;
48
+
49
+    /**
50
+     * creates a \OC_Defaults instance which is used in all methods to retrieve the
51
+     * actual defaults
52
+     * @since 6.0.0
53
+     */
54
+    public function __construct(\OC_Defaults $defaults = null) {
55
+        if ($defaults === null) {
56
+            $defaults = \OC::$server->getThemingDefaults();
57
+        }
58
+        $this->defaults = $defaults;
59
+    }
60
+
61
+    /**
62
+     * get base URL for the organisation behind your ownCloud instance
63
+     * @return string
64
+     * @since 6.0.0
65
+     */
66
+    public function getBaseUrl() {
67
+        return $this->defaults->getBaseUrl();
68
+    }
69
+
70
+    /**
71
+     * link to the desktop sync client
72
+     * @return string
73
+     * @since 6.0.0
74
+     */
75
+    public function getSyncClientUrl() {
76
+        return $this->defaults->getSyncClientUrl();
77
+    }
78
+
79
+    /**
80
+     * link to the iOS client
81
+     * @return string
82
+     * @since 8.0.0
83
+     */
84
+    public function getiOSClientUrl() {
85
+        return $this->defaults->getiOSClientUrl();
86
+    }
87
+
88
+    /**
89
+     * link to the Android client
90
+     * @return string
91
+     * @since 8.0.0
92
+     */
93
+    public function getAndroidClientUrl() {
94
+        return $this->defaults->getAndroidClientUrl();
95
+    }
96
+
97
+    /**
98
+     * base URL to the documentation of your ownCloud instance
99
+     * @return string
100
+     * @since 6.0.0
101
+     */
102
+    public function getDocBaseUrl() {
103
+        return $this->defaults->getDocBaseUrl();
104
+    }
105
+
106
+    /**
107
+     * name of your ownCloud instance
108
+     * @return string
109
+     * @since 6.0.0
110
+     */
111
+    public function getName() {
112
+        return $this->defaults->getName();
113
+    }
114
+
115
+    /**
116
+     * name of your ownCloud instance containing HTML styles
117
+     * @return string
118
+     * @since 8.0.0
119
+     */
120
+    public function getHTMLName() {
121
+        return $this->defaults->getHTMLName();
122
+    }
123
+
124
+    /**
125
+     * Entity behind your onwCloud instance
126
+     * @return string
127
+     * @since 6.0.0
128
+     */
129
+    public function getEntity() {
130
+        return $this->defaults->getEntity();
131
+    }
132
+
133
+    /**
134
+     * ownCloud slogan
135
+     * @return string
136
+     * @since 6.0.0
137
+     */
138
+    public function getSlogan() {
139
+        return $this->defaults->getSlogan();
140
+    }
141
+
142
+    /**
143
+     * logo claim
144
+     * @return string
145
+     * @since 6.0.0
146
+     */
147
+    public function getLogoClaim() {
148
+        return $this->defaults->getLogoClaim();
149
+    }
150
+
151
+    /**
152
+     * footer, short version
153
+     * @return string
154
+     * @since 6.0.0
155
+     */
156
+    public function getShortFooter() {
157
+        return $this->defaults->getShortFooter();
158
+    }
159
+
160
+    /**
161
+     * footer, long version
162
+     * @return string
163
+     * @since 6.0.0
164
+     */
165
+    public function getLongFooter() {
166
+        return $this->defaults->getLongFooter();
167
+    }
168
+
169
+    /**
170
+     * Returns the AppId for the App Store for the iOS Client
171
+     * @return string AppId
172
+     * @since 8.0.0
173
+     */
174
+    public function getiTunesAppId() {
175
+        return $this->defaults->getiTunesAppId();
176
+    }
177
+
178
+    /**
179
+     * Themed logo url
180
+     *
181
+     * @param bool $useSvg Whether to point to the SVG image or a fallback
182
+     * @return string
183
+     * @since 12.0.0
184
+     */
185
+    public function getLogo($useSvg = true) {
186
+        return $this->defaults->getLogo($useSvg);
187
+    }
188
+
189
+    /**
190
+     * Returns primary color
191
+     * @return string
192
+     * @since 12.0.0
193
+     */
194
+    public function getColorPrimary() {
195
+        return $this->defaults->getColorPrimary();
196
+    }
197
+
198
+    /**
199
+     * @param string $key
200
+     * @return string URL to doc with key
201
+     * @since 12.0.0
202
+     */
203
+    public function buildDocLinkToKey($key) {
204
+        return $this->defaults->buildDocLinkToKey($key);
205
+    }
206
+
207
+    /**
208
+     * Returns the title
209
+     * @return string title
210
+     * @since 12.0.0
211
+     */
212
+    public function getTitle() {
213
+        return $this->defaults->getTitle();
214
+    }
215 215
 }
Please login to merge, or discard this patch.
lib/private/legacy/defaults.php 2 patches
Indentation   +260 added lines, -260 removed lines patch added patch discarded remove patch
@@ -31,292 +31,292 @@
 block discarded – undo
31 31
  */
32 32
 class OC_Defaults {
33 33
 
34
-	private $theme;
35
-	private $l;
34
+    private $theme;
35
+    private $l;
36 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
-	private $defaultColorPrimary;
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
+    private $defaultColorPrimary;
50 50
 
51
-	public function __construct() {
52
-		$this->l = \OC::$server->getL10N('lib');
51
+    public function __construct() {
52
+        $this->l = \OC::$server->getL10N('lib');
53 53
 
54
-		$this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */
55
-		$this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */
56
-		$this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */
57
-		$this->defaultBaseUrl = 'https://nextcloud.com';
58
-		$this->defaultSyncClientUrl = 'https://nextcloud.com/install/#install-clients';
59
-		$this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8';
60
-		$this->defaultiTunesAppId = '1125420102';
61
-		$this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.nextcloud.client';
62
-		$this->defaultDocBaseUrl = 'https://docs.nextcloud.com';
63
-		$this->defaultDocVersion = '12'; // used to generate doc links
64
-		$this->defaultSlogan = $this->l->t('a safe home for all your data');
65
-		$this->defaultLogoClaim = '';
66
-		$this->defaultColorPrimary = '#0082c9';
54
+        $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */
55
+        $this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */
56
+        $this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */
57
+        $this->defaultBaseUrl = 'https://nextcloud.com';
58
+        $this->defaultSyncClientUrl = 'https://nextcloud.com/install/#install-clients';
59
+        $this->defaultiOSClientUrl = 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8';
60
+        $this->defaultiTunesAppId = '1125420102';
61
+        $this->defaultAndroidClientUrl = 'https://play.google.com/store/apps/details?id=com.nextcloud.client';
62
+        $this->defaultDocBaseUrl = 'https://docs.nextcloud.com';
63
+        $this->defaultDocVersion = '12'; // used to generate doc links
64
+        $this->defaultSlogan = $this->l->t('a safe home for all your data');
65
+        $this->defaultLogoClaim = '';
66
+        $this->defaultColorPrimary = '#0082c9';
67 67
 
68
-		$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
69
-		if (file_exists($themePath)) {
70
-			// prevent defaults.php from printing output
71
-			ob_start();
72
-			require_once $themePath;
73
-			ob_end_clean();
74
-			if (class_exists('OC_Theme')) {
75
-				$this->theme = new OC_Theme();
76
-			}
77
-		}
78
-	}
68
+        $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
69
+        if (file_exists($themePath)) {
70
+            // prevent defaults.php from printing output
71
+            ob_start();
72
+            require_once $themePath;
73
+            ob_end_clean();
74
+            if (class_exists('OC_Theme')) {
75
+                $this->theme = new OC_Theme();
76
+            }
77
+        }
78
+    }
79 79
 
80
-	/**
81
-	 * @param string $method
82
-	 */
83
-	private function themeExist($method) {
84
-		if (isset($this->theme) && method_exists($this->theme, $method)) {
85
-			return true;
86
-		}
87
-		return false;
88
-	}
80
+    /**
81
+     * @param string $method
82
+     */
83
+    private function themeExist($method) {
84
+        if (isset($this->theme) && method_exists($this->theme, $method)) {
85
+            return true;
86
+        }
87
+        return false;
88
+    }
89 89
 
90
-	/**
91
-	 * Returns the base URL
92
-	 * @return string URL
93
-	 */
94
-	public function getBaseUrl() {
95
-		if ($this->themeExist('getBaseUrl')) {
96
-			return $this->theme->getBaseUrl();
97
-		} else {
98
-			return $this->defaultBaseUrl;
99
-		}
100
-	}
90
+    /**
91
+     * Returns the base URL
92
+     * @return string URL
93
+     */
94
+    public function getBaseUrl() {
95
+        if ($this->themeExist('getBaseUrl')) {
96
+            return $this->theme->getBaseUrl();
97
+        } else {
98
+            return $this->defaultBaseUrl;
99
+        }
100
+    }
101 101
 
102
-	/**
103
-	 * Returns the URL where the sync clients are listed
104
-	 * @return string URL
105
-	 */
106
-	public function getSyncClientUrl() {
107
-		if ($this->themeExist('getSyncClientUrl')) {
108
-			return $this->theme->getSyncClientUrl();
109
-		} else {
110
-			return $this->defaultSyncClientUrl;
111
-		}
112
-	}
102
+    /**
103
+     * Returns the URL where the sync clients are listed
104
+     * @return string URL
105
+     */
106
+    public function getSyncClientUrl() {
107
+        if ($this->themeExist('getSyncClientUrl')) {
108
+            return $this->theme->getSyncClientUrl();
109
+        } else {
110
+            return $this->defaultSyncClientUrl;
111
+        }
112
+    }
113 113
 
114
-	/**
115
-	 * Returns the URL to the App Store for the iOS Client
116
-	 * @return string URL
117
-	 */
118
-	public function getiOSClientUrl() {
119
-		if ($this->themeExist('getiOSClientUrl')) {
120
-			return $this->theme->getiOSClientUrl();
121
-		} else {
122
-			return $this->defaultiOSClientUrl;
123
-		}
124
-	}
114
+    /**
115
+     * Returns the URL to the App Store for the iOS Client
116
+     * @return string URL
117
+     */
118
+    public function getiOSClientUrl() {
119
+        if ($this->themeExist('getiOSClientUrl')) {
120
+            return $this->theme->getiOSClientUrl();
121
+        } else {
122
+            return $this->defaultiOSClientUrl;
123
+        }
124
+    }
125 125
 
126
-	/**
127
-	 * Returns the AppId for the App Store for the iOS Client
128
-	 * @return string AppId
129
-	 */
130
-	public function getiTunesAppId() {
131
-		if ($this->themeExist('getiTunesAppId')) {
132
-			return $this->theme->getiTunesAppId();
133
-		} else {
134
-			return $this->defaultiTunesAppId;
135
-		}
136
-	}
126
+    /**
127
+     * Returns the AppId for the App Store for the iOS Client
128
+     * @return string AppId
129
+     */
130
+    public function getiTunesAppId() {
131
+        if ($this->themeExist('getiTunesAppId')) {
132
+            return $this->theme->getiTunesAppId();
133
+        } else {
134
+            return $this->defaultiTunesAppId;
135
+        }
136
+    }
137 137
 
138
-	/**
139
-	 * Returns the URL to Google Play for the Android Client
140
-	 * @return string URL
141
-	 */
142
-	public function getAndroidClientUrl() {
143
-		if ($this->themeExist('getAndroidClientUrl')) {
144
-			return $this->theme->getAndroidClientUrl();
145
-		} else {
146
-			return $this->defaultAndroidClientUrl;
147
-		}
148
-	}
138
+    /**
139
+     * Returns the URL to Google Play for the Android Client
140
+     * @return string URL
141
+     */
142
+    public function getAndroidClientUrl() {
143
+        if ($this->themeExist('getAndroidClientUrl')) {
144
+            return $this->theme->getAndroidClientUrl();
145
+        } else {
146
+            return $this->defaultAndroidClientUrl;
147
+        }
148
+    }
149 149
 
150
-	/**
151
-	 * Returns the documentation URL
152
-	 * @return string URL
153
-	 */
154
-	public function getDocBaseUrl() {
155
-		if ($this->themeExist('getDocBaseUrl')) {
156
-			return $this->theme->getDocBaseUrl();
157
-		} else {
158
-			return $this->defaultDocBaseUrl;
159
-		}
160
-	}
150
+    /**
151
+     * Returns the documentation URL
152
+     * @return string URL
153
+     */
154
+    public function getDocBaseUrl() {
155
+        if ($this->themeExist('getDocBaseUrl')) {
156
+            return $this->theme->getDocBaseUrl();
157
+        } else {
158
+            return $this->defaultDocBaseUrl;
159
+        }
160
+    }
161 161
 
162
-	/**
163
-	 * Returns the title
164
-	 * @return string title
165
-	 */
166
-	public function getTitle() {
167
-		if ($this->themeExist('getTitle')) {
168
-			return $this->theme->getTitle();
169
-		} else {
170
-			return $this->defaultTitle;
171
-		}
172
-	}
162
+    /**
163
+     * Returns the title
164
+     * @return string title
165
+     */
166
+    public function getTitle() {
167
+        if ($this->themeExist('getTitle')) {
168
+            return $this->theme->getTitle();
169
+        } else {
170
+            return $this->defaultTitle;
171
+        }
172
+    }
173 173
 
174
-	/**
175
-	 * Returns the short name of the software
176
-	 * @return string title
177
-	 */
178
-	public function getName() {
179
-		if ($this->themeExist('getName')) {
180
-			return $this->theme->getName();
181
-		} else {
182
-			return $this->defaultName;
183
-		}
184
-	}
174
+    /**
175
+     * Returns the short name of the software
176
+     * @return string title
177
+     */
178
+    public function getName() {
179
+        if ($this->themeExist('getName')) {
180
+            return $this->theme->getName();
181
+        } else {
182
+            return $this->defaultName;
183
+        }
184
+    }
185 185
 
186
-	/**
187
-	 * Returns the short name of the software containing HTML strings
188
-	 * @return string title
189
-	 */
190
-	public function getHTMLName() {
191
-		if ($this->themeExist('getHTMLName')) {
192
-			return $this->theme->getHTMLName();
193
-		} else {
194
-			return $this->defaultName;
195
-		}
196
-	}
186
+    /**
187
+     * Returns the short name of the software containing HTML strings
188
+     * @return string title
189
+     */
190
+    public function getHTMLName() {
191
+        if ($this->themeExist('getHTMLName')) {
192
+            return $this->theme->getHTMLName();
193
+        } else {
194
+            return $this->defaultName;
195
+        }
196
+    }
197 197
 
198
-	/**
199
-	 * Returns entity (e.g. company name) - used for footer, copyright
200
-	 * @return string entity name
201
-	 */
202
-	public function getEntity() {
203
-		if ($this->themeExist('getEntity')) {
204
-			return $this->theme->getEntity();
205
-		} else {
206
-			return $this->defaultEntity;
207
-		}
208
-	}
198
+    /**
199
+     * Returns entity (e.g. company name) - used for footer, copyright
200
+     * @return string entity name
201
+     */
202
+    public function getEntity() {
203
+        if ($this->themeExist('getEntity')) {
204
+            return $this->theme->getEntity();
205
+        } else {
206
+            return $this->defaultEntity;
207
+        }
208
+    }
209 209
 
210
-	/**
211
-	 * Returns slogan
212
-	 * @return string slogan
213
-	 */
214
-	public function getSlogan() {
215
-		if ($this->themeExist('getSlogan')) {
216
-			return $this->theme->getSlogan();
217
-		} else {
218
-			return $this->defaultSlogan;
219
-		}
220
-	}
210
+    /**
211
+     * Returns slogan
212
+     * @return string slogan
213
+     */
214
+    public function getSlogan() {
215
+        if ($this->themeExist('getSlogan')) {
216
+            return $this->theme->getSlogan();
217
+        } else {
218
+            return $this->defaultSlogan;
219
+        }
220
+    }
221 221
 
222
-	/**
223
-	 * Returns logo claim
224
-	 * @return string logo claim
225
-	 */
226
-	public function getLogoClaim() {
227
-		if ($this->themeExist('getLogoClaim')) {
228
-			return $this->theme->getLogoClaim();
229
-		} else {
230
-			return $this->defaultLogoClaim;
231
-		}
232
-	}
222
+    /**
223
+     * Returns logo claim
224
+     * @return string logo claim
225
+     */
226
+    public function getLogoClaim() {
227
+        if ($this->themeExist('getLogoClaim')) {
228
+            return $this->theme->getLogoClaim();
229
+        } else {
230
+            return $this->defaultLogoClaim;
231
+        }
232
+    }
233 233
 
234
-	/**
235
-	 * Returns short version of the footer
236
-	 * @return string short footer
237
-	 */
238
-	public function getShortFooter() {
239
-		if ($this->themeExist('getShortFooter')) {
240
-			$footer = $this->theme->getShortFooter();
241
-		} else {
242
-			$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
243
-				' rel="noreferrer">' .$this->getEntity() . '</a>'.
244
-				' – ' . $this->getSlogan();
245
-		}
234
+    /**
235
+     * Returns short version of the footer
236
+     * @return string short footer
237
+     */
238
+    public function getShortFooter() {
239
+        if ($this->themeExist('getShortFooter')) {
240
+            $footer = $this->theme->getShortFooter();
241
+        } else {
242
+            $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
243
+                ' rel="noreferrer">' .$this->getEntity() . '</a>'.
244
+                ' – ' . $this->getSlogan();
245
+        }
246 246
 
247
-		return $footer;
248
-	}
247
+        return $footer;
248
+    }
249 249
 
250
-	/**
251
-	 * Returns long version of the footer
252
-	 * @return string long footer
253
-	 */
254
-	public function getLongFooter() {
255
-		if ($this->themeExist('getLongFooter')) {
256
-			$footer = $this->theme->getLongFooter();
257
-		} else {
258
-			$footer = $this->getShortFooter();
259
-		}
250
+    /**
251
+     * Returns long version of the footer
252
+     * @return string long footer
253
+     */
254
+    public function getLongFooter() {
255
+        if ($this->themeExist('getLongFooter')) {
256
+            $footer = $this->theme->getLongFooter();
257
+        } else {
258
+            $footer = $this->getShortFooter();
259
+        }
260 260
 
261
-		return $footer;
262
-	}
261
+        return $footer;
262
+    }
263 263
 
264
-	/**
265
-	 * @param string $key
266
-	 * @return string URL to doc with key
267
-	 */
268
-	public function buildDocLinkToKey($key) {
269
-		if ($this->themeExist('buildDocLinkToKey')) {
270
-			return $this->theme->buildDocLinkToKey($key);
271
-		}
272
-		return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
273
-	}
264
+    /**
265
+     * @param string $key
266
+     * @return string URL to doc with key
267
+     */
268
+    public function buildDocLinkToKey($key) {
269
+        if ($this->themeExist('buildDocLinkToKey')) {
270
+            return $this->theme->buildDocLinkToKey($key);
271
+        }
272
+        return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
273
+    }
274 274
 
275
-	/**
276
-	 * Returns primary color
277
-	 * @return string
278
-	 */
279
-	public function getColorPrimary() {
275
+    /**
276
+     * Returns primary color
277
+     * @return string
278
+     */
279
+    public function getColorPrimary() {
280 280
 
281
-		if ($this->themeExist('getColorPrimary')) {
282
-			return $this->theme->getColorPrimary();
283
-		}
284
-		if ($this->themeExist('getMailHeaderColor')) {
285
-			return $this->theme->getMailHeaderColor();
286
-		}
287
-		return $this->defaultColorPrimary;
288
-	}
281
+        if ($this->themeExist('getColorPrimary')) {
282
+            return $this->theme->getColorPrimary();
283
+        }
284
+        if ($this->themeExist('getMailHeaderColor')) {
285
+            return $this->theme->getMailHeaderColor();
286
+        }
287
+        return $this->defaultColorPrimary;
288
+    }
289 289
 
290
-	/**
291
-	 * @return array scss variables to overwrite
292
-	 */
293
-	public function getScssVariables() {
294
-		if($this->themeExist('getScssVariables')) {
295
-			return $this->theme->getScssVariables();
296
-		}
297
-		return [];
298
-	}
290
+    /**
291
+     * @return array scss variables to overwrite
292
+     */
293
+    public function getScssVariables() {
294
+        if($this->themeExist('getScssVariables')) {
295
+            return $this->theme->getScssVariables();
296
+        }
297
+        return [];
298
+    }
299 299
 
300
-	public function shouldReplaceIcons() {
301
-		return false;
302
-	}
300
+    public function shouldReplaceIcons() {
301
+        return false;
302
+    }
303 303
 
304
-	/**
305
-	 * Themed logo url
306
-	 *
307
-	 * @param bool $useSvg Whether to point to the SVG image or a fallback
308
-	 * @return string
309
-	 */
310
-	public function getLogo($useSvg = true) {
311
-		if ($this->themeExist('getLogo')) {
312
-			return $this->theme->getLogo($useSvg);
313
-		}
304
+    /**
305
+     * Themed logo url
306
+     *
307
+     * @param bool $useSvg Whether to point to the SVG image or a fallback
308
+     * @return string
309
+     */
310
+    public function getLogo($useSvg = true) {
311
+        if ($this->themeExist('getLogo')) {
312
+            return $this->theme->getLogo($useSvg);
313
+        }
314 314
 
315
-		if($useSvg) {
316
-			$logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.svg');
317
-		} else {
318
-			$logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.png');
319
-		}
320
-	    return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion()));
321
-	}
315
+        if($useSvg) {
316
+            $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.svg');
317
+        } else {
318
+            $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.png');
319
+        }
320
+        return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion()));
321
+    }
322 322
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		$this->defaultLogoClaim = '';
66 66
 		$this->defaultColorPrimary = '#0082c9';
67 67
 
68
-		$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
68
+		$themePath = OC::$SERVERROOT.'/themes/'.OC_Util::getTheme().'/defaults.php';
69 69
 		if (file_exists($themePath)) {
70 70
 			// prevent defaults.php from printing output
71 71
 			ob_start();
@@ -239,9 +239,9 @@  discard block
 block discarded – undo
239 239
 		if ($this->themeExist('getShortFooter')) {
240 240
 			$footer = $this->theme->getShortFooter();
241 241
 		} else {
242
-			$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
243
-				' rel="noreferrer">' .$this->getEntity() . '</a>'.
244
-				' – ' . $this->getSlogan();
242
+			$footer = '<a href="'.$this->getBaseUrl().'" target="_blank"'.
243
+				' rel="noreferrer">'.$this->getEntity().'</a>'.
244
+				' – '.$this->getSlogan();
245 245
 		}
246 246
 
247 247
 		return $footer;
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 		if ($this->themeExist('buildDocLinkToKey')) {
270 270
 			return $this->theme->buildDocLinkToKey($key);
271 271
 		}
272
-		return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
272
+		return $this->getDocBaseUrl().'/server/'.$this->defaultDocVersion.'/go.php?to='.$key;
273 273
 	}
274 274
 
275 275
 	/**
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	 * @return array scss variables to overwrite
292 292
 	 */
293 293
 	public function getScssVariables() {
294
-		if($this->themeExist('getScssVariables')) {
294
+		if ($this->themeExist('getScssVariables')) {
295 295
 			return $this->theme->getScssVariables();
296 296
 		}
297 297
 		return [];
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
 			return $this->theme->getLogo($useSvg);
313 313
 		}
314 314
 
315
-		if($useSvg) {
315
+		if ($useSvg) {
316 316
 			$logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.svg');
317 317
 		} else {
318 318
 			$logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.png');
319 319
 		}
320
-	    return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion()));
320
+	    return $logo.'?v='.hash('sha1', implode('.', \OCP\Util::getVersion()));
321 321
 	}
322 322
 }
Please login to merge, or discard this patch.
lib/private/Mail/EMailTemplate.php 1 patch
Indentation   +311 added lines, -311 removed lines patch added patch discarded remove patch
@@ -39,27 +39,27 @@  discard block
 block discarded – undo
39 39
  * @package OC\Mail
40 40
  */
41 41
 class EMailTemplate implements IEMailTemplate {
42
-	/** @var Defaults */
43
-	protected $themingDefaults;
44
-	/** @var IURLGenerator */
45
-	protected $urlGenerator;
46
-	/** @var IL10N */
47
-	protected $l10n;
48
-
49
-	/** @var string */
50
-	protected $htmlBody = '';
51
-	/** @var string */
52
-	protected $plainBody = '';
53
-	/** @var bool indicated if the footer is added */
54
-	protected $headerAdded = false;
55
-	/** @var bool indicated if the body is already opened */
56
-	protected $bodyOpened = false;
57
-	/** @var bool indicated if there is a list open in the body */
58
-	protected $bodyListOpened = false;
59
-	/** @var bool indicated if the footer is added */
60
-	protected $footerAdded = false;
61
-
62
-	protected $head = <<<EOF
42
+    /** @var Defaults */
43
+    protected $themingDefaults;
44
+    /** @var IURLGenerator */
45
+    protected $urlGenerator;
46
+    /** @var IL10N */
47
+    protected $l10n;
48
+
49
+    /** @var string */
50
+    protected $htmlBody = '';
51
+    /** @var string */
52
+    protected $plainBody = '';
53
+    /** @var bool indicated if the footer is added */
54
+    protected $headerAdded = false;
55
+    /** @var bool indicated if the body is already opened */
56
+    protected $bodyOpened = false;
57
+    /** @var bool indicated if there is a list open in the body */
58
+    protected $bodyListOpened = false;
59
+    /** @var bool indicated if the footer is added */
60
+    protected $footerAdded = false;
61
+
62
+    protected $head = <<<EOF
63 63
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
64 64
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" style="-webkit-font-smoothing:antialiased;background:#f3f3f3!important">
65 65
 <head>
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 				<center data-parsed="" style="min-width:580px;width:100%">
78 78
 EOF;
79 79
 
80
-	protected $tail = <<<EOF
80
+    protected $tail = <<<EOF
81 81
 					</center>
82 82
 				</td>
83 83
 			</tr>
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 </html>
89 89
 EOF;
90 90
 
91
-	protected $header = <<<EOF
91
+    protected $header = <<<EOF
92 92
 <table align="center" class="wrapper header float-center" style="Margin:0 auto;background:#8a8a8a;background-color:%s;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%%">
93 93
 	<tr style="padding:0;text-align:left;vertical-align:top">
94 94
 		<td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:20px;text-align:left;vertical-align:top;word-wrap:break-word">
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 </table>
122 122
 EOF;
123 123
 
124
-	protected $heading = <<<EOF
124
+    protected $heading = <<<EOF
125 125
 <table align="center" class="container main-heading float-center" style="Margin:0 auto;background:0 0!important;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:580px">
126 126
 	<tbody>
127 127
 	<tr style="padding:0;text-align:left;vertical-align:top">
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 </table>
141 141
 EOF;
142 142
 
143
-	protected $bodyBegin = <<<EOF
143
+    protected $bodyBegin = <<<EOF
144 144
 <table align="center" class="wrapper content float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
145 145
 	<tr style="padding:0;text-align:left;vertical-align:top">
146 146
 		<td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 						</table>
158 158
 EOF;
159 159
 
160
-	protected $bodyText = <<<EOF
160
+    protected $bodyText = <<<EOF
161 161
 <table class="row description" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%%">
162 162
 	<tbody>
163 163
 	<tr style="padding:0;text-align:left;vertical-align:top">
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 </table>
177 177
 EOF;
178 178
 
179
-	protected $listBegin = <<<EOF
179
+    protected $listBegin = <<<EOF
180 180
 <table class="row description" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%%">
181 181
 	<tbody>
182 182
 	<tr style="padding:0;text-align:left;vertical-align:top">
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 			<table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%">
185 185
 EOF;
186 186
 
187
-	protected $listItem = <<<EOF
187
+    protected $listItem = <<<EOF
188 188
 				<tr style="padding:0;text-align:left;vertical-align:top">
189 189
 					<td style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left;width:15px;">
190 190
 						<p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;padding-left:10px;text-align:left">%s</p>
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 				</tr>
197 197
 EOF;
198 198
 
199
-	protected $listEnd = <<<EOF
199
+    protected $listEnd = <<<EOF
200 200
 			</table>
201 201
 		</th>
202 202
 	</tr>
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 </table>
205 205
 EOF;
206 206
 
207
-	protected $buttonGroup = <<<EOF
207
+    protected $buttonGroup = <<<EOF
208 208
 <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%">
209 209
 	<tbody>
210 210
 	<tr style="padding:0;text-align:left;vertical-align:top">
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 </table>
258 258
 EOF;
259 259
 
260
-	protected $button = <<<EOF
260
+    protected $button = <<<EOF
261 261
 <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%%">
262 262
 	<tbody>
263 263
 	<tr style="padding:0;text-align:left;vertical-align:top">
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 </table>
298 298
 EOF;
299 299
 
300
-	protected $bodyEnd = <<<EOF
300
+    protected $bodyEnd = <<<EOF
301 301
 
302 302
 					</td>
303 303
 				</tr>
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 </table>
309 309
 EOF;
310 310
 
311
-	protected $footer = <<<EOF
311
+    protected $footer = <<<EOF
312 312
 <table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%%">
313 313
 	<tbody>
314 314
 	<tr style="padding:0;text-align:left;vertical-align:top">
@@ -334,282 +334,282 @@  discard block
 block discarded – undo
334 334
 </table>
335 335
 EOF;
336 336
 
337
-	/**
338
-	 * @param Defaults $themingDefaults
339
-	 * @param IURLGenerator $urlGenerator
340
-	 * @param IL10N $l10n
341
-	 */
342
-	public function __construct(Defaults $themingDefaults,
343
-								IURLGenerator $urlGenerator,
344
-								IL10N $l10n) {
345
-		$this->themingDefaults = $themingDefaults;
346
-		$this->urlGenerator = $urlGenerator;
347
-		$this->l10n = $l10n;
348
-		$this->htmlBody .= $this->head;
349
-	}
350
-
351
-	/**
352
-	 * Adds a header to the email
353
-	 */
354
-	public function addHeader() {
355
-		if ($this->headerAdded) {
356
-			return;
357
-		}
358
-		$this->headerAdded = true;
359
-
360
-		$logoUrl = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo(false));
361
-		$this->htmlBody .= vsprintf($this->header, [$this->themingDefaults->getColorPrimary(), $logoUrl, $this->themingDefaults->getName()]);
362
-	}
363
-
364
-	/**
365
-	 * Adds a heading to the email
366
-	 *
367
-	 * @param string $title
368
-	 * @param string $plainTitle|bool Title that is used in the plain text email
369
-	 *   if empty the $title is used, if false none will be used
370
-	 */
371
-	public function addHeading($title, $plainTitle = '') {
372
-		if ($this->footerAdded) {
373
-			return;
374
-		}
375
-		if ($plainTitle === '') {
376
-			$plainTitle = $title;
377
-		}
378
-
379
-		$this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]);
380
-		if ($plainTitle !== false) {
381
-			$this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL;
382
-		}
383
-	}
384
-
385
-	/**
386
-	 * Open the HTML body when it is not already
387
-	 */
388
-	protected function ensureBodyIsOpened() {
389
-		if ($this->bodyOpened) {
390
-			return;
391
-		}
392
-
393
-		$this->htmlBody .= $this->bodyBegin;
394
-		$this->bodyOpened = true;
395
-	}
396
-
397
-	/**
398
-	 * Adds a paragraph to the body of the email
399
-	 *
400
-	 * @param string $text
401
-	 * @param string|bool $plainText Text that is used in the plain text email
402
-	 *   if empty the $text is used, if false none will be used
403
-	 */
404
-	public function addBodyText($text, $plainText = '') {
405
-		if ($this->footerAdded) {
406
-			return;
407
-		}
408
-		if ($plainText === '') {
409
-			$plainText = $text;
410
-		}
411
-
412
-		$this->ensureBodyIsOpened();
413
-
414
-		$this->htmlBody .= vsprintf($this->bodyText, [htmlspecialchars($text)]);
415
-		if ($plainText !== false) {
416
-			$this->plainBody .= $plainText . PHP_EOL . PHP_EOL;
417
-		}
418
-	}
419
-
420
-	/**
421
-	 * Adds a list item to the body of the email
422
-	 *
423
-	 * @param string $text
424
-	 * @param string $metaInfo
425
-	 * @param string $icon Absolute path, must be 16*16 pixels
426
-	 * @param string $plainText Text that is used in the plain text email
427
-	 *   if empty the $text is used, if false none will be used
428
-	 * @param string $plainMetaInfo Meta info that is used in the plain text email
429
-	 *   if empty the $metaInfo is used, if false none will be used
430
-	 * @since 12.0.0
431
-	 */
432
-	public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = '') {
433
-		$this->ensureBodyListOpened();
434
-
435
-		if ($plainText === '') {
436
-			$plainText = $text;
437
-		}
438
-		if ($plainMetaInfo === '') {
439
-			$plainMetaInfo = $metaInfo;
440
-		}
441
-
442
-		$htmlText = htmlspecialchars($text);
443
-		if ($metaInfo) {
444
-			$htmlText = '<em style="color:#777;">' . htmlspecialchars($metaInfo) . '</em><br>' . $htmlText;
445
-		}
446
-		if ($icon !== '') {
447
-			$icon = '<img src="' . htmlspecialchars($icon) . '" alt="&bull;">';
448
-		} else {
449
-			$icon = '&bull;';
450
-		}
451
-		$this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]);
452
-		if ($plainText !== false) {
453
-			$this->plainBody .= '  * ' . $plainText;
454
-			if ($plainMetaInfo !== false) {
455
-				$this->plainBody .= ' (' . $plainMetaInfo . ')';
456
-			}
457
-			$this->plainBody .= PHP_EOL;
458
-		}
459
-	}
460
-
461
-	protected function ensureBodyListOpened() {
462
-		if ($this->bodyListOpened) {
463
-			return;
464
-		}
465
-
466
-		$this->ensureBodyIsOpened();
467
-		$this->bodyListOpened = true;
468
-		$this->htmlBody .= $this->listBegin;
469
-	}
470
-
471
-	protected function ensureBodyListClosed() {
472
-		if (!$this->bodyListOpened) {
473
-			return;
474
-		}
475
-
476
-		$this->bodyListOpened = false;
477
-		$this->htmlBody .= $this->listEnd;
478
-	}
479
-
480
-	/**
481
-	 * Adds a button group of two buttons to the body of the email
482
-	 *
483
-	 * @param string $textLeft Text of left button
484
-	 * @param string $urlLeft URL of left button
485
-	 * @param string $textRight Text of right button
486
-	 * @param string $urlRight URL of right button
487
-	 * @param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used
488
-	 * @param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used
489
-	 */
490
-	public function addBodyButtonGroup($textLeft,
491
-									   $urlLeft,
492
-									   $textRight,
493
-									   $urlRight,
494
-									   $plainTextLeft = '',
495
-									   $plainTextRight = '') {
496
-		if ($this->footerAdded) {
497
-			return;
498
-		}
499
-		if ($plainTextLeft === '') {
500
-			$plainTextLeft = $textLeft;
501
-		}
502
-
503
-		if ($plainTextRight === '') {
504
-			$plainTextRight = $textRight;
505
-		}
506
-
507
-		$this->ensureBodyIsOpened();
508
-		$this->ensureBodyListClosed();
509
-
510
-		$color = $this->themingDefaults->getColorPrimary();
511
-
512
-		$this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, htmlspecialchars($textLeft), $urlRight, htmlspecialchars($textRight)]);
513
-		$this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL;
514
-		$this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL;
515
-
516
-	}
517
-
518
-	/**
519
-	 * Adds a button to the body of the email
520
-	 *
521
-	 * @param string $text Text of button
522
-	 * @param string $url URL of button
523
-	 * @param string $plainText Text of button in plain text version
524
-	 * 		if empty the $text is used, if false none will be used
525
-	 *
526
-	 * @since 12.0.0
527
-	 */
528
-	public function addBodyButton($text, $url, $plainText = '') {
529
-		if ($this->footerAdded) {
530
-			return;
531
-		}
532
-
533
-		$this->ensureBodyIsOpened();
534
-		$this->ensureBodyListClosed();
535
-
536
-		if ($plainText === '') {
537
-			$plainText = $text;
538
-		}
539
-
540
-		$color = $this->themingDefaults->getColorPrimary();
541
-		$this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, htmlspecialchars($text)]);
542
-
543
-		if ($plainText !== false) {
544
-			$this->plainBody .= $plainText . ': ';
545
-		}
546
-
547
-		$this->plainBody .=  $url . PHP_EOL;
548
-
549
-	}
550
-
551
-	/**
552
-	 * Close the HTML body when it is open
553
-	 */
554
-	protected function ensureBodyIsClosed() {
555
-		if (!$this->bodyOpened) {
556
-			return;
557
-		}
558
-
559
-		$this->ensureBodyListClosed();
560
-
561
-		$this->htmlBody .= $this->bodyEnd;
562
-		$this->bodyOpened = false;
563
-	}
564
-
565
-	/**
566
-	 * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email
567
-	 *
568
-	 * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used
569
-	 */
570
-	public function addFooter($text = '') {
571
-		if($text === '') {
572
-			$text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.');
573
-		}
574
-
575
-		if ($this->footerAdded) {
576
-			return;
577
-		}
578
-		$this->footerAdded = true;
579
-
580
-		$this->ensureBodyIsClosed();
581
-
582
-		$this->htmlBody .= vsprintf($this->footer, [$text]);
583
-		$this->htmlBody .= $this->tail;
584
-		$this->plainBody .= PHP_EOL . '-- ' . PHP_EOL;
585
-		$this->plainBody .= str_replace('<br>', PHP_EOL, $text);
586
-	}
587
-
588
-	/**
589
-	 * Returns the rendered HTML email as string
590
-	 *
591
-	 * @return string
592
-	 */
593
-	public function renderHtml() {
594
-		if (!$this->footerAdded) {
595
-			$this->footerAdded = true;
596
-			$this->ensureBodyIsClosed();
597
-			$this->htmlBody .= $this->tail;
598
-		}
599
-		return $this->htmlBody;
600
-	}
601
-
602
-	/**
603
-	 * Returns the rendered plain text email as string
604
-	 *
605
-	 * @return string
606
-	 */
607
-	public function renderText() {
608
-		if (!$this->footerAdded) {
609
-			$this->footerAdded = true;
610
-			$this->ensureBodyIsClosed();
611
-			$this->htmlBody .= $this->tail;
612
-		}
613
-		return $this->plainBody;
614
-	}
337
+    /**
338
+     * @param Defaults $themingDefaults
339
+     * @param IURLGenerator $urlGenerator
340
+     * @param IL10N $l10n
341
+     */
342
+    public function __construct(Defaults $themingDefaults,
343
+                                IURLGenerator $urlGenerator,
344
+                                IL10N $l10n) {
345
+        $this->themingDefaults = $themingDefaults;
346
+        $this->urlGenerator = $urlGenerator;
347
+        $this->l10n = $l10n;
348
+        $this->htmlBody .= $this->head;
349
+    }
350
+
351
+    /**
352
+     * Adds a header to the email
353
+     */
354
+    public function addHeader() {
355
+        if ($this->headerAdded) {
356
+            return;
357
+        }
358
+        $this->headerAdded = true;
359
+
360
+        $logoUrl = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo(false));
361
+        $this->htmlBody .= vsprintf($this->header, [$this->themingDefaults->getColorPrimary(), $logoUrl, $this->themingDefaults->getName()]);
362
+    }
363
+
364
+    /**
365
+     * Adds a heading to the email
366
+     *
367
+     * @param string $title
368
+     * @param string $plainTitle|bool Title that is used in the plain text email
369
+     *   if empty the $title is used, if false none will be used
370
+     */
371
+    public function addHeading($title, $plainTitle = '') {
372
+        if ($this->footerAdded) {
373
+            return;
374
+        }
375
+        if ($plainTitle === '') {
376
+            $plainTitle = $title;
377
+        }
378
+
379
+        $this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]);
380
+        if ($plainTitle !== false) {
381
+            $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL;
382
+        }
383
+    }
384
+
385
+    /**
386
+     * Open the HTML body when it is not already
387
+     */
388
+    protected function ensureBodyIsOpened() {
389
+        if ($this->bodyOpened) {
390
+            return;
391
+        }
392
+
393
+        $this->htmlBody .= $this->bodyBegin;
394
+        $this->bodyOpened = true;
395
+    }
396
+
397
+    /**
398
+     * Adds a paragraph to the body of the email
399
+     *
400
+     * @param string $text
401
+     * @param string|bool $plainText Text that is used in the plain text email
402
+     *   if empty the $text is used, if false none will be used
403
+     */
404
+    public function addBodyText($text, $plainText = '') {
405
+        if ($this->footerAdded) {
406
+            return;
407
+        }
408
+        if ($plainText === '') {
409
+            $plainText = $text;
410
+        }
411
+
412
+        $this->ensureBodyIsOpened();
413
+
414
+        $this->htmlBody .= vsprintf($this->bodyText, [htmlspecialchars($text)]);
415
+        if ($plainText !== false) {
416
+            $this->plainBody .= $plainText . PHP_EOL . PHP_EOL;
417
+        }
418
+    }
419
+
420
+    /**
421
+     * Adds a list item to the body of the email
422
+     *
423
+     * @param string $text
424
+     * @param string $metaInfo
425
+     * @param string $icon Absolute path, must be 16*16 pixels
426
+     * @param string $plainText Text that is used in the plain text email
427
+     *   if empty the $text is used, if false none will be used
428
+     * @param string $plainMetaInfo Meta info that is used in the plain text email
429
+     *   if empty the $metaInfo is used, if false none will be used
430
+     * @since 12.0.0
431
+     */
432
+    public function addBodyListItem($text, $metaInfo = '', $icon = '', $plainText = '', $plainMetaInfo = '') {
433
+        $this->ensureBodyListOpened();
434
+
435
+        if ($plainText === '') {
436
+            $plainText = $text;
437
+        }
438
+        if ($plainMetaInfo === '') {
439
+            $plainMetaInfo = $metaInfo;
440
+        }
441
+
442
+        $htmlText = htmlspecialchars($text);
443
+        if ($metaInfo) {
444
+            $htmlText = '<em style="color:#777;">' . htmlspecialchars($metaInfo) . '</em><br>' . $htmlText;
445
+        }
446
+        if ($icon !== '') {
447
+            $icon = '<img src="' . htmlspecialchars($icon) . '" alt="&bull;">';
448
+        } else {
449
+            $icon = '&bull;';
450
+        }
451
+        $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]);
452
+        if ($plainText !== false) {
453
+            $this->plainBody .= '  * ' . $plainText;
454
+            if ($plainMetaInfo !== false) {
455
+                $this->plainBody .= ' (' . $plainMetaInfo . ')';
456
+            }
457
+            $this->plainBody .= PHP_EOL;
458
+        }
459
+    }
460
+
461
+    protected function ensureBodyListOpened() {
462
+        if ($this->bodyListOpened) {
463
+            return;
464
+        }
465
+
466
+        $this->ensureBodyIsOpened();
467
+        $this->bodyListOpened = true;
468
+        $this->htmlBody .= $this->listBegin;
469
+    }
470
+
471
+    protected function ensureBodyListClosed() {
472
+        if (!$this->bodyListOpened) {
473
+            return;
474
+        }
475
+
476
+        $this->bodyListOpened = false;
477
+        $this->htmlBody .= $this->listEnd;
478
+    }
479
+
480
+    /**
481
+     * Adds a button group of two buttons to the body of the email
482
+     *
483
+     * @param string $textLeft Text of left button
484
+     * @param string $urlLeft URL of left button
485
+     * @param string $textRight Text of right button
486
+     * @param string $urlRight URL of right button
487
+     * @param string $plainTextLeft Text of left button that is used in the plain text version - if unset the $textLeft is used
488
+     * @param string $plainTextRight Text of right button that is used in the plain text version - if unset the $textRight is used
489
+     */
490
+    public function addBodyButtonGroup($textLeft,
491
+                                        $urlLeft,
492
+                                        $textRight,
493
+                                        $urlRight,
494
+                                        $plainTextLeft = '',
495
+                                        $plainTextRight = '') {
496
+        if ($this->footerAdded) {
497
+            return;
498
+        }
499
+        if ($plainTextLeft === '') {
500
+            $plainTextLeft = $textLeft;
501
+        }
502
+
503
+        if ($plainTextRight === '') {
504
+            $plainTextRight = $textRight;
505
+        }
506
+
507
+        $this->ensureBodyIsOpened();
508
+        $this->ensureBodyListClosed();
509
+
510
+        $color = $this->themingDefaults->getColorPrimary();
511
+
512
+        $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, htmlspecialchars($textLeft), $urlRight, htmlspecialchars($textRight)]);
513
+        $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL;
514
+        $this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL;
515
+
516
+    }
517
+
518
+    /**
519
+     * Adds a button to the body of the email
520
+     *
521
+     * @param string $text Text of button
522
+     * @param string $url URL of button
523
+     * @param string $plainText Text of button in plain text version
524
+     * 		if empty the $text is used, if false none will be used
525
+     *
526
+     * @since 12.0.0
527
+     */
528
+    public function addBodyButton($text, $url, $plainText = '') {
529
+        if ($this->footerAdded) {
530
+            return;
531
+        }
532
+
533
+        $this->ensureBodyIsOpened();
534
+        $this->ensureBodyListClosed();
535
+
536
+        if ($plainText === '') {
537
+            $plainText = $text;
538
+        }
539
+
540
+        $color = $this->themingDefaults->getColorPrimary();
541
+        $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, htmlspecialchars($text)]);
542
+
543
+        if ($plainText !== false) {
544
+            $this->plainBody .= $plainText . ': ';
545
+        }
546
+
547
+        $this->plainBody .=  $url . PHP_EOL;
548
+
549
+    }
550
+
551
+    /**
552
+     * Close the HTML body when it is open
553
+     */
554
+    protected function ensureBodyIsClosed() {
555
+        if (!$this->bodyOpened) {
556
+            return;
557
+        }
558
+
559
+        $this->ensureBodyListClosed();
560
+
561
+        $this->htmlBody .= $this->bodyEnd;
562
+        $this->bodyOpened = false;
563
+    }
564
+
565
+    /**
566
+     * Adds a logo and a text to the footer. <br> in the text will be replaced by new lines in the plain text email
567
+     *
568
+     * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used
569
+     */
570
+    public function addFooter($text = '') {
571
+        if($text === '') {
572
+            $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.');
573
+        }
574
+
575
+        if ($this->footerAdded) {
576
+            return;
577
+        }
578
+        $this->footerAdded = true;
579
+
580
+        $this->ensureBodyIsClosed();
581
+
582
+        $this->htmlBody .= vsprintf($this->footer, [$text]);
583
+        $this->htmlBody .= $this->tail;
584
+        $this->plainBody .= PHP_EOL . '-- ' . PHP_EOL;
585
+        $this->plainBody .= str_replace('<br>', PHP_EOL, $text);
586
+    }
587
+
588
+    /**
589
+     * Returns the rendered HTML email as string
590
+     *
591
+     * @return string
592
+     */
593
+    public function renderHtml() {
594
+        if (!$this->footerAdded) {
595
+            $this->footerAdded = true;
596
+            $this->ensureBodyIsClosed();
597
+            $this->htmlBody .= $this->tail;
598
+        }
599
+        return $this->htmlBody;
600
+    }
601
+
602
+    /**
603
+     * Returns the rendered plain text email as string
604
+     *
605
+     * @return string
606
+     */
607
+    public function renderText() {
608
+        if (!$this->footerAdded) {
609
+            $this->footerAdded = true;
610
+            $this->ensureBodyIsClosed();
611
+            $this->htmlBody .= $this->tail;
612
+        }
613
+        return $this->plainBody;
614
+    }
615 615
 }
Please login to merge, or discard this patch.
apps/theming/lib/ThemingDefaults.php 2 patches
Indentation   +257 added lines, -257 removed lines patch added patch discarded remove patch
@@ -31,262 +31,262 @@
 block discarded – undo
31 31
 
32 32
 class ThemingDefaults extends \OC_Defaults {
33 33
 
34
-	/** @var IConfig */
35
-	private $config;
36
-	/** @var IL10N */
37
-	private $l;
38
-	/** @var IURLGenerator */
39
-	private $urlGenerator;
40
-	/** @var IAppData */
41
-	private $appData;
42
-	/** @var ICacheFactory */
43
-	private $cacheFactory;
44
-	/** @var string */
45
-	private $name;
46
-	/** @var string */
47
-	private $url;
48
-	/** @var string */
49
-	private $slogan;
50
-	/** @var string */
51
-	private $color;
52
-	/** @var Util */
53
-	private $util;
54
-
55
-	/**
56
-	 * ThemingDefaults constructor.
57
-	 *
58
-	 * @param IConfig $config
59
-	 * @param IL10N $l
60
-	 * @param IURLGenerator $urlGenerator
61
-	 * @param \OC_Defaults $defaults
62
-	 * @param IAppData $appData
63
-	 * @param ICacheFactory $cacheFactory
64
-	 * @param Util $util
65
-	 */
66
-	public function __construct(IConfig $config,
67
-								IL10N $l,
68
-								IURLGenerator $urlGenerator,
69
-								IAppData $appData,
70
-								ICacheFactory $cacheFactory,
71
-								Util $util
72
-	) {
73
-		parent::__construct();
74
-		$this->config = $config;
75
-		$this->l = $l;
76
-		$this->urlGenerator = $urlGenerator;
77
-		$this->appData = $appData;
78
-		$this->cacheFactory = $cacheFactory;
79
-		$this->util = $util;
80
-
81
-		$this->name = parent::getName();
82
-		$this->url = parent::getBaseUrl();
83
-		$this->slogan = parent::getSlogan();
84
-		$this->color = parent::getColorPrimary();
85
-	}
86
-
87
-	public function getName() {
88
-		return strip_tags($this->config->getAppValue('theming', 'name', $this->name));
89
-	}
90
-
91
-	public function getHTMLName() {
92
-		return $this->config->getAppValue('theming', 'name', $this->name);
93
-	}
94
-
95
-	public function getTitle() {
96
-		return $this->getName();
97
-	}
98
-
99
-	public function getEntity() {
100
-		return $this->getName();
101
-	}
102
-
103
-	public function getBaseUrl() {
104
-		return $this->config->getAppValue('theming', 'url', $this->url);
105
-	}
106
-
107
-	public function getSlogan() {
108
-		return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan));
109
-	}
110
-
111
-	public function getShortFooter() {
112
-		$slogan = $this->getSlogan();
113
-		$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
114
-			' rel="noreferrer">' .$this->getEntity() . '</a>'.
115
-			($slogan !== '' ? ' – ' . $slogan : '');
116
-
117
-		return $footer;
118
-	}
119
-
120
-	/**
121
-	 * Color that is used for the header as well as for mail headers
122
-	 *
123
-	 * @return string
124
-	 */
125
-	public function getColorPrimary() {
126
-		return $this->config->getAppValue('theming', 'color', $this->color);
127
-	}
128
-
129
-	/**
130
-	 * Themed logo url
131
-	 *
132
-	 * @param bool $useSvg Whether to point to the SVG image or a fallback
133
-	 * @return string
134
-	 */
135
-	public function getLogo($useSvg = true) {
136
-		$logo = $this->config->getAppValue('theming', 'logoMime', false);
137
-
138
-		$logoExists = true;
139
-		try {
140
-			$this->appData->getFolder('images')->getFile('logo');
141
-		} catch (\Exception $e) {
142
-			$logoExists = false;
143
-		}
144
-
145
-		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
146
-
147
-		if(!$logo || !$logoExists) {
148
-			if($useSvg) {
149
-				$logo = $this->urlGenerator->imagePath('core', 'logo.svg');
150
-			} else {
151
-				$logo = $this->urlGenerator->imagePath('core', 'logo.png');
152
-			}
153
-			return $logo . '?v=' . $cacheBusterCounter;
154
-		}
155
-
156
-		return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter;
157
-	}
158
-
159
-	/**
160
-	 * Themed background image url
161
-	 *
162
-	 * @return string
163
-	 */
164
-	public function getBackground() {
165
-		$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false);
166
-
167
-		$backgroundExists = true;
168
-		try {
169
-			$this->appData->getFolder('images')->getFile('background');
170
-		} catch (\Exception $e) {
171
-			$backgroundExists = false;
172
-		}
173
-
174
-		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
175
-
176
-		if(!$backgroundLogo || !$backgroundExists) {
177
-			return $this->urlGenerator->imagePath('core','background.jpg') . '?v=' . $cacheBusterCounter;
178
-		}
179
-
180
-		return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground') . '?v=' . $cacheBusterCounter;
181
-	}
182
-
183
-
184
-	/**
185
-	 * @return array scss variables to overwrite
186
-	 */
187
-	public function getScssVariables() {
188
-		$cache = $this->cacheFactory->create('theming');
189
-		if ($value = $cache->get('getScssVariables')) {
190
-			return $value;
191
-		}
192
-
193
-		$variables = [
194
-			'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'",
195
-		];
196
-
197
-		$variables['image-logo'] = "'".$this->urlGenerator->getAbsoluteURL($this->getLogo())."'";
198
-		$variables['image-login-background'] = "'".$this->urlGenerator->getAbsoluteURL($this->getBackground())."'";
199
-		$variables['image-login-plain'] = 'false';
200
-
201
-		if ($this->config->getAppValue('theming', 'color', null) !== null) {
202
-			if ($this->util->invertTextColor($this->getColorPrimary())) {
203
-				$colorPrimaryText = '#000000';
204
-			} else {
205
-				$colorPrimaryText = '#ffffff';
206
-			}
207
-			$variables['color-primary'] = $this->getColorPrimary();
208
-			$variables['color-primary-text'] = $colorPrimaryText;
209
-		}
210
-
211
-		if ($this->config->getAppValue('theming', 'backgroundMime', null) === 'backgroundColor') {
212
-			$variables['image-login-plain'] = 'true';
213
-		}
214
-		$cache->set('getScssVariables', $variables);
215
-		return $variables;
216
-	}
217
-
218
-	/**
219
-	 * Check if Imagemagick is enabled and if SVG is supported
220
-	 * otherwise we can't render custom icons
221
-	 *
222
-	 * @return bool
223
-	 */
224
-	public function shouldReplaceIcons() {
225
-		$cache = $this->cacheFactory->create('theming');
226
-		if($value = $cache->get('shouldReplaceIcons')) {
227
-			return (bool)$value;
228
-		}
229
-		$value = false;
230
-		if(extension_loaded('imagick')) {
231
-			$checkImagick = new \Imagick();
232
-			if (count($checkImagick->queryFormats('SVG')) >= 1) {
233
-				$value = true;
234
-			}
235
-			$checkImagick->clear();
236
-		}
237
-		$cache->set('shouldReplaceIcons', $value);
238
-		return $value;
239
-	}
240
-
241
-	/**
242
-	 * Increases the cache buster key
243
-	 */
244
-	private function increaseCacheBuster() {
245
-		$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
246
-		$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
247
-		$this->cacheFactory->create('theming')->clear('getScssVariables');
248
-	}
249
-
250
-	/**
251
-	 * Update setting in the database
252
-	 *
253
-	 * @param string $setting
254
-	 * @param string $value
255
-	 */
256
-	public function set($setting, $value) {
257
-		$this->config->setAppValue('theming', $setting, $value);
258
-		$this->increaseCacheBuster();
259
-	}
260
-
261
-	/**
262
-	 * Revert settings to the default value
263
-	 *
264
-	 * @param string $setting setting which should be reverted
265
-	 * @return string default value
266
-	 */
267
-	public function undo($setting) {
268
-		$this->config->deleteAppValue('theming', $setting);
269
-		$this->increaseCacheBuster();
270
-
271
-		switch ($setting) {
272
-			case 'name':
273
-				$returnValue = $this->getEntity();
274
-				break;
275
-			case 'url':
276
-				$returnValue = $this->getBaseUrl();
277
-				break;
278
-			case 'slogan':
279
-				$returnValue = $this->getSlogan();
280
-				break;
281
-			case 'color':
282
-				$returnValue = $this->getColorPrimary();
283
-				break;
284
-			default:
285
-				$returnValue = '';
286
-				break;
287
-		}
288
-
289
-		return $returnValue;
290
-	}
34
+    /** @var IConfig */
35
+    private $config;
36
+    /** @var IL10N */
37
+    private $l;
38
+    /** @var IURLGenerator */
39
+    private $urlGenerator;
40
+    /** @var IAppData */
41
+    private $appData;
42
+    /** @var ICacheFactory */
43
+    private $cacheFactory;
44
+    /** @var string */
45
+    private $name;
46
+    /** @var string */
47
+    private $url;
48
+    /** @var string */
49
+    private $slogan;
50
+    /** @var string */
51
+    private $color;
52
+    /** @var Util */
53
+    private $util;
54
+
55
+    /**
56
+     * ThemingDefaults constructor.
57
+     *
58
+     * @param IConfig $config
59
+     * @param IL10N $l
60
+     * @param IURLGenerator $urlGenerator
61
+     * @param \OC_Defaults $defaults
62
+     * @param IAppData $appData
63
+     * @param ICacheFactory $cacheFactory
64
+     * @param Util $util
65
+     */
66
+    public function __construct(IConfig $config,
67
+                                IL10N $l,
68
+                                IURLGenerator $urlGenerator,
69
+                                IAppData $appData,
70
+                                ICacheFactory $cacheFactory,
71
+                                Util $util
72
+    ) {
73
+        parent::__construct();
74
+        $this->config = $config;
75
+        $this->l = $l;
76
+        $this->urlGenerator = $urlGenerator;
77
+        $this->appData = $appData;
78
+        $this->cacheFactory = $cacheFactory;
79
+        $this->util = $util;
80
+
81
+        $this->name = parent::getName();
82
+        $this->url = parent::getBaseUrl();
83
+        $this->slogan = parent::getSlogan();
84
+        $this->color = parent::getColorPrimary();
85
+    }
86
+
87
+    public function getName() {
88
+        return strip_tags($this->config->getAppValue('theming', 'name', $this->name));
89
+    }
90
+
91
+    public function getHTMLName() {
92
+        return $this->config->getAppValue('theming', 'name', $this->name);
93
+    }
94
+
95
+    public function getTitle() {
96
+        return $this->getName();
97
+    }
98
+
99
+    public function getEntity() {
100
+        return $this->getName();
101
+    }
102
+
103
+    public function getBaseUrl() {
104
+        return $this->config->getAppValue('theming', 'url', $this->url);
105
+    }
106
+
107
+    public function getSlogan() {
108
+        return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan));
109
+    }
110
+
111
+    public function getShortFooter() {
112
+        $slogan = $this->getSlogan();
113
+        $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
114
+            ' rel="noreferrer">' .$this->getEntity() . '</a>'.
115
+            ($slogan !== '' ? ' – ' . $slogan : '');
116
+
117
+        return $footer;
118
+    }
119
+
120
+    /**
121
+     * Color that is used for the header as well as for mail headers
122
+     *
123
+     * @return string
124
+     */
125
+    public function getColorPrimary() {
126
+        return $this->config->getAppValue('theming', 'color', $this->color);
127
+    }
128
+
129
+    /**
130
+     * Themed logo url
131
+     *
132
+     * @param bool $useSvg Whether to point to the SVG image or a fallback
133
+     * @return string
134
+     */
135
+    public function getLogo($useSvg = true) {
136
+        $logo = $this->config->getAppValue('theming', 'logoMime', false);
137
+
138
+        $logoExists = true;
139
+        try {
140
+            $this->appData->getFolder('images')->getFile('logo');
141
+        } catch (\Exception $e) {
142
+            $logoExists = false;
143
+        }
144
+
145
+        $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
146
+
147
+        if(!$logo || !$logoExists) {
148
+            if($useSvg) {
149
+                $logo = $this->urlGenerator->imagePath('core', 'logo.svg');
150
+            } else {
151
+                $logo = $this->urlGenerator->imagePath('core', 'logo.png');
152
+            }
153
+            return $logo . '?v=' . $cacheBusterCounter;
154
+        }
155
+
156
+        return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter;
157
+    }
158
+
159
+    /**
160
+     * Themed background image url
161
+     *
162
+     * @return string
163
+     */
164
+    public function getBackground() {
165
+        $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false);
166
+
167
+        $backgroundExists = true;
168
+        try {
169
+            $this->appData->getFolder('images')->getFile('background');
170
+        } catch (\Exception $e) {
171
+            $backgroundExists = false;
172
+        }
173
+
174
+        $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
175
+
176
+        if(!$backgroundLogo || !$backgroundExists) {
177
+            return $this->urlGenerator->imagePath('core','background.jpg') . '?v=' . $cacheBusterCounter;
178
+        }
179
+
180
+        return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground') . '?v=' . $cacheBusterCounter;
181
+    }
182
+
183
+
184
+    /**
185
+     * @return array scss variables to overwrite
186
+     */
187
+    public function getScssVariables() {
188
+        $cache = $this->cacheFactory->create('theming');
189
+        if ($value = $cache->get('getScssVariables')) {
190
+            return $value;
191
+        }
192
+
193
+        $variables = [
194
+            'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'",
195
+        ];
196
+
197
+        $variables['image-logo'] = "'".$this->urlGenerator->getAbsoluteURL($this->getLogo())."'";
198
+        $variables['image-login-background'] = "'".$this->urlGenerator->getAbsoluteURL($this->getBackground())."'";
199
+        $variables['image-login-plain'] = 'false';
200
+
201
+        if ($this->config->getAppValue('theming', 'color', null) !== null) {
202
+            if ($this->util->invertTextColor($this->getColorPrimary())) {
203
+                $colorPrimaryText = '#000000';
204
+            } else {
205
+                $colorPrimaryText = '#ffffff';
206
+            }
207
+            $variables['color-primary'] = $this->getColorPrimary();
208
+            $variables['color-primary-text'] = $colorPrimaryText;
209
+        }
210
+
211
+        if ($this->config->getAppValue('theming', 'backgroundMime', null) === 'backgroundColor') {
212
+            $variables['image-login-plain'] = 'true';
213
+        }
214
+        $cache->set('getScssVariables', $variables);
215
+        return $variables;
216
+    }
217
+
218
+    /**
219
+     * Check if Imagemagick is enabled and if SVG is supported
220
+     * otherwise we can't render custom icons
221
+     *
222
+     * @return bool
223
+     */
224
+    public function shouldReplaceIcons() {
225
+        $cache = $this->cacheFactory->create('theming');
226
+        if($value = $cache->get('shouldReplaceIcons')) {
227
+            return (bool)$value;
228
+        }
229
+        $value = false;
230
+        if(extension_loaded('imagick')) {
231
+            $checkImagick = new \Imagick();
232
+            if (count($checkImagick->queryFormats('SVG')) >= 1) {
233
+                $value = true;
234
+            }
235
+            $checkImagick->clear();
236
+        }
237
+        $cache->set('shouldReplaceIcons', $value);
238
+        return $value;
239
+    }
240
+
241
+    /**
242
+     * Increases the cache buster key
243
+     */
244
+    private function increaseCacheBuster() {
245
+        $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
246
+        $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
247
+        $this->cacheFactory->create('theming')->clear('getScssVariables');
248
+    }
249
+
250
+    /**
251
+     * Update setting in the database
252
+     *
253
+     * @param string $setting
254
+     * @param string $value
255
+     */
256
+    public function set($setting, $value) {
257
+        $this->config->setAppValue('theming', $setting, $value);
258
+        $this->increaseCacheBuster();
259
+    }
260
+
261
+    /**
262
+     * Revert settings to the default value
263
+     *
264
+     * @param string $setting setting which should be reverted
265
+     * @return string default value
266
+     */
267
+    public function undo($setting) {
268
+        $this->config->deleteAppValue('theming', $setting);
269
+        $this->increaseCacheBuster();
270
+
271
+        switch ($setting) {
272
+            case 'name':
273
+                $returnValue = $this->getEntity();
274
+                break;
275
+            case 'url':
276
+                $returnValue = $this->getBaseUrl();
277
+                break;
278
+            case 'slogan':
279
+                $returnValue = $this->getSlogan();
280
+                break;
281
+            case 'color':
282
+                $returnValue = $this->getColorPrimary();
283
+                break;
284
+            default:
285
+                $returnValue = '';
286
+                break;
287
+        }
288
+
289
+        return $returnValue;
290
+    }
291 291
 
292 292
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -110,9 +110,9 @@  discard block
 block discarded – undo
110 110
 
111 111
 	public function getShortFooter() {
112 112
 		$slogan = $this->getSlogan();
113
-		$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
114
-			' rel="noreferrer">' .$this->getEntity() . '</a>'.
115
-			($slogan !== '' ? ' – ' . $slogan : '');
113
+		$footer = '<a href="'.$this->getBaseUrl().'" target="_blank"'.
114
+			' rel="noreferrer">'.$this->getEntity().'</a>'.
115
+			($slogan !== '' ? ' – '.$slogan : '');
116 116
 
117 117
 		return $footer;
118 118
 	}
@@ -144,16 +144,16 @@  discard block
 block discarded – undo
144 144
 
145 145
 		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
146 146
 
147
-		if(!$logo || !$logoExists) {
148
-			if($useSvg) {
147
+		if (!$logo || !$logoExists) {
148
+			if ($useSvg) {
149 149
 				$logo = $this->urlGenerator->imagePath('core', 'logo.svg');
150 150
 			} else {
151 151
 				$logo = $this->urlGenerator->imagePath('core', 'logo.png');
152 152
 			}
153
-			return $logo . '?v=' . $cacheBusterCounter;
153
+			return $logo.'?v='.$cacheBusterCounter;
154 154
 		}
155 155
 
156
-		return $this->urlGenerator->linkToRoute('theming.Theming.getLogo') . '?v=' . $cacheBusterCounter;
156
+		return $this->urlGenerator->linkToRoute('theming.Theming.getLogo').'?v='.$cacheBusterCounter;
157 157
 	}
158 158
 
159 159
 	/**
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * @return string
163 163
 	 */
164 164
 	public function getBackground() {
165
-		$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime',false);
165
+		$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false);
166 166
 
167 167
 		$backgroundExists = true;
168 168
 		try {
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 
174 174
 		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
175 175
 
176
-		if(!$backgroundLogo || !$backgroundExists) {
177
-			return $this->urlGenerator->imagePath('core','background.jpg') . '?v=' . $cacheBusterCounter;
176
+		if (!$backgroundLogo || !$backgroundExists) {
177
+			return $this->urlGenerator->imagePath('core', 'background.jpg').'?v='.$cacheBusterCounter;
178 178
 		}
179 179
 
180
-		return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground') . '?v=' . $cacheBusterCounter;
180
+		return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground').'?v='.$cacheBusterCounter;
181 181
 	}
182 182
 
183 183
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 		}
192 192
 
193 193
 		$variables = [
194
-			'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'",
194
+			'theming-cachebuster' => "'".$this->config->getAppValue('theming', 'cachebuster', '0')."'",
195 195
 		];
196 196
 
197 197
 		$variables['image-logo'] = "'".$this->urlGenerator->getAbsoluteURL($this->getLogo())."'";
@@ -223,11 +223,11 @@  discard block
 block discarded – undo
223 223
 	 */
224 224
 	public function shouldReplaceIcons() {
225 225
 		$cache = $this->cacheFactory->create('theming');
226
-		if($value = $cache->get('shouldReplaceIcons')) {
227
-			return (bool)$value;
226
+		if ($value = $cache->get('shouldReplaceIcons')) {
227
+			return (bool) $value;
228 228
 		}
229 229
 		$value = false;
230
-		if(extension_loaded('imagick')) {
230
+		if (extension_loaded('imagick')) {
231 231
 			$checkImagick = new \Imagick();
232 232
 			if (count($checkImagick->queryFormats('SVG')) >= 1) {
233 233
 				$value = true;
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 */
244 244
 	private function increaseCacheBuster() {
245 245
 		$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
246
-		$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
246
+		$this->config->setAppValue('theming', 'cachebuster', (int) $cacheBusterKey + 1);
247 247
 		$this->cacheFactory->create('theming')->clear('getScssVariables');
248 248
 	}
249 249
 
Please login to merge, or discard this patch.