Passed
Push — master ( 39f0aa...ff8cfb )
by Morris
13:54 queued 12s
created
lib/private/legacy/OC_Defaults.php 2 patches
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -38,306 +38,306 @@
 block discarded – undo
38 38
  */
39 39
 
40 40
 class OC_Defaults {
41
-	private $theme;
41
+    private $theme;
42 42
 
43
-	private $defaultEntity;
44
-	private $defaultName;
45
-	private $defaultTitle;
46
-	private $defaultBaseUrl;
47
-	private $defaultSyncClientUrl;
48
-	private $defaultiOSClientUrl;
49
-	private $defaultiTunesAppId;
50
-	private $defaultAndroidClientUrl;
51
-	private $defaultDocBaseUrl;
52
-	private $defaultDocVersion;
53
-	private $defaultSlogan;
54
-	private $defaultColorPrimary;
55
-	private $defaultTextColorPrimary;
56
-	private $defaultProductName;
43
+    private $defaultEntity;
44
+    private $defaultName;
45
+    private $defaultTitle;
46
+    private $defaultBaseUrl;
47
+    private $defaultSyncClientUrl;
48
+    private $defaultiOSClientUrl;
49
+    private $defaultiTunesAppId;
50
+    private $defaultAndroidClientUrl;
51
+    private $defaultDocBaseUrl;
52
+    private $defaultDocVersion;
53
+    private $defaultSlogan;
54
+    private $defaultColorPrimary;
55
+    private $defaultTextColorPrimary;
56
+    private $defaultProductName;
57 57
 
58
-	public function __construct() {
59
-		$config = \OC::$server->getConfig();
58
+    public function __construct() {
59
+        $config = \OC::$server->getConfig();
60 60
 
61
-		$this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */
62
-		$this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */
63
-		$this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */
64
-		$this->defaultBaseUrl = 'https://nextcloud.com';
65
-		$this->defaultSyncClientUrl = $config->getSystemValue('customclient_desktop', 'https://nextcloud.com/install/#install-clients');
66
-		$this->defaultiOSClientUrl = $config->getSystemValue('customclient_ios', 'https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8');
67
-		$this->defaultiTunesAppId = $config->getSystemValue('customclient_ios_appid', '1125420102');
68
-		$this->defaultAndroidClientUrl = $config->getSystemValue('customclient_android', 'https://play.google.com/store/apps/details?id=com.nextcloud.client');
69
-		$this->defaultDocBaseUrl = 'https://docs.nextcloud.com';
70
-		$this->defaultDocVersion = \OC_Util::getVersion()[0]; // used to generate doc links
71
-		$this->defaultColorPrimary = '#0082c9';
72
-		$this->defaultTextColorPrimary = '#ffffff';
73
-		$this->defaultProductName = 'Nextcloud';
61
+        $this->defaultEntity = 'Nextcloud'; /* e.g. company name, used for footers and copyright notices */
62
+        $this->defaultName = 'Nextcloud'; /* short name, used when referring to the software */
63
+        $this->defaultTitle = 'Nextcloud'; /* can be a longer name, for titles */
64
+        $this->defaultBaseUrl = 'https://nextcloud.com';
65
+        $this->defaultSyncClientUrl = $config->getSystemValue('customclient_desktop', 'https://nextcloud.com/install/#install-clients');
66
+        $this->defaultiOSClientUrl = $config->getSystemValue('customclient_ios', 'https://geo.itunes.apple.com/us/app/nextcloud/id1125420102?mt=8');
67
+        $this->defaultiTunesAppId = $config->getSystemValue('customclient_ios_appid', '1125420102');
68
+        $this->defaultAndroidClientUrl = $config->getSystemValue('customclient_android', 'https://play.google.com/store/apps/details?id=com.nextcloud.client');
69
+        $this->defaultDocBaseUrl = 'https://docs.nextcloud.com';
70
+        $this->defaultDocVersion = \OC_Util::getVersion()[0]; // used to generate doc links
71
+        $this->defaultColorPrimary = '#0082c9';
72
+        $this->defaultTextColorPrimary = '#ffffff';
73
+        $this->defaultProductName = 'Nextcloud';
74 74
 
75
-		$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
76
-		if (file_exists($themePath)) {
77
-			// prevent defaults.php from printing output
78
-			ob_start();
79
-			require_once $themePath;
80
-			ob_end_clean();
81
-			if (class_exists('OC_Theme')) {
82
-				$this->theme = new OC_Theme();
83
-			}
84
-		}
85
-	}
75
+        $themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
76
+        if (file_exists($themePath)) {
77
+            // prevent defaults.php from printing output
78
+            ob_start();
79
+            require_once $themePath;
80
+            ob_end_clean();
81
+            if (class_exists('OC_Theme')) {
82
+                $this->theme = new OC_Theme();
83
+            }
84
+        }
85
+    }
86 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
-	}
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 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
-	}
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 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
-	}
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 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
-	}
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 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
-	}
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 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
-	}
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 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
-	}
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 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
-	}
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 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
-	}
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 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
-	}
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 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
-	}
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 216
 
217
-	/**
218
-	 * Returns slogan
219
-	 * @return string slogan
220
-	 */
221
-	public function getSlogan(?string $lang = null) {
222
-		if ($this->themeExist('getSlogan')) {
223
-			return $this->theme->getSlogan($lang);
224
-		} else {
225
-			if ($this->defaultSlogan === null) {
226
-				$l10n = \OC::$server->getL10N('lib', $lang);
227
-				$this->defaultSlogan = $l10n->t('a safe home for all your data');
228
-			}
229
-			return $this->defaultSlogan;
230
-		}
231
-	}
217
+    /**
218
+     * Returns slogan
219
+     * @return string slogan
220
+     */
221
+    public function getSlogan(?string $lang = null) {
222
+        if ($this->themeExist('getSlogan')) {
223
+            return $this->theme->getSlogan($lang);
224
+        } else {
225
+            if ($this->defaultSlogan === null) {
226
+                $l10n = \OC::$server->getL10N('lib', $lang);
227
+                $this->defaultSlogan = $l10n->t('a safe home for all your data');
228
+            }
229
+            return $this->defaultSlogan;
230
+        }
231
+    }
232 232
 
233
-	/**
234
-	 * Returns logo claim
235
-	 * @return string logo claim
236
-	 * @deprecated 13.0.0
237
-	 */
238
-	public function getLogoClaim() {
239
-		return '';
240
-	}
233
+    /**
234
+     * Returns logo claim
235
+     * @return string logo claim
236
+     * @deprecated 13.0.0
237
+     */
238
+    public function getLogoClaim() {
239
+        return '';
240
+    }
241 241
 
242
-	/**
243
-	 * Returns short version of the footer
244
-	 * @return string short footer
245
-	 */
246
-	public function getShortFooter() {
247
-		if ($this->themeExist('getShortFooter')) {
248
-			$footer = $this->theme->getShortFooter();
249
-		} else {
250
-			$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
251
-				' rel="noreferrer noopener">' .$this->getEntity() . '</a>'.
252
-				' – ' . $this->getSlogan();
253
-		}
242
+    /**
243
+     * Returns short version of the footer
244
+     * @return string short footer
245
+     */
246
+    public function getShortFooter() {
247
+        if ($this->themeExist('getShortFooter')) {
248
+            $footer = $this->theme->getShortFooter();
249
+        } else {
250
+            $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
251
+                ' rel="noreferrer noopener">' .$this->getEntity() . '</a>'.
252
+                ' – ' . $this->getSlogan();
253
+        }
254 254
 
255
-		return $footer;
256
-	}
255
+        return $footer;
256
+    }
257 257
 
258
-	/**
259
-	 * Returns long version of the footer
260
-	 * @return string long footer
261
-	 */
262
-	public function getLongFooter() {
263
-		if ($this->themeExist('getLongFooter')) {
264
-			$footer = $this->theme->getLongFooter();
265
-		} else {
266
-			$footer = $this->getShortFooter();
267
-		}
258
+    /**
259
+     * Returns long version of the footer
260
+     * @return string long footer
261
+     */
262
+    public function getLongFooter() {
263
+        if ($this->themeExist('getLongFooter')) {
264
+            $footer = $this->theme->getLongFooter();
265
+        } else {
266
+            $footer = $this->getShortFooter();
267
+        }
268 268
 
269
-		return $footer;
270
-	}
269
+        return $footer;
270
+    }
271 271
 
272
-	/**
273
-	 * @param string $key
274
-	 * @return string URL to doc with key
275
-	 */
276
-	public function buildDocLinkToKey($key) {
277
-		if ($this->themeExist('buildDocLinkToKey')) {
278
-			return $this->theme->buildDocLinkToKey($key);
279
-		}
280
-		return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
281
-	}
272
+    /**
273
+     * @param string $key
274
+     * @return string URL to doc with key
275
+     */
276
+    public function buildDocLinkToKey($key) {
277
+        if ($this->themeExist('buildDocLinkToKey')) {
278
+            return $this->theme->buildDocLinkToKey($key);
279
+        }
280
+        return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
281
+    }
282 282
 
283
-	/**
284
-	 * Returns primary color
285
-	 * @return string
286
-	 */
287
-	public function getColorPrimary() {
288
-		if ($this->themeExist('getColorPrimary')) {
289
-			return $this->theme->getColorPrimary();
290
-		}
291
-		if ($this->themeExist('getMailHeaderColor')) {
292
-			return $this->theme->getMailHeaderColor();
293
-		}
294
-		return $this->defaultColorPrimary;
295
-	}
283
+    /**
284
+     * Returns primary color
285
+     * @return string
286
+     */
287
+    public function getColorPrimary() {
288
+        if ($this->themeExist('getColorPrimary')) {
289
+            return $this->theme->getColorPrimary();
290
+        }
291
+        if ($this->themeExist('getMailHeaderColor')) {
292
+            return $this->theme->getMailHeaderColor();
293
+        }
294
+        return $this->defaultColorPrimary;
295
+    }
296 296
 
297
-	/**
298
-	 * @return array scss variables to overwrite
299
-	 */
300
-	public function getScssVariables() {
301
-		if ($this->themeExist('getScssVariables')) {
302
-			return $this->theme->getScssVariables();
303
-		}
304
-		return [];
305
-	}
297
+    /**
298
+     * @return array scss variables to overwrite
299
+     */
300
+    public function getScssVariables() {
301
+        if ($this->themeExist('getScssVariables')) {
302
+            return $this->theme->getScssVariables();
303
+        }
304
+        return [];
305
+    }
306 306
 
307
-	public function shouldReplaceIcons() {
308
-		return false;
309
-	}
307
+    public function shouldReplaceIcons() {
308
+        return false;
309
+    }
310 310
 
311
-	/**
312
-	 * Themed logo url
313
-	 *
314
-	 * @param bool $useSvg Whether to point to the SVG image or a fallback
315
-	 * @return string
316
-	 */
317
-	public function getLogo($useSvg = true) {
318
-		if ($this->themeExist('getLogo')) {
319
-			return $this->theme->getLogo($useSvg);
320
-		}
311
+    /**
312
+     * Themed logo url
313
+     *
314
+     * @param bool $useSvg Whether to point to the SVG image or a fallback
315
+     * @return string
316
+     */
317
+    public function getLogo($useSvg = true) {
318
+        if ($this->themeExist('getLogo')) {
319
+            return $this->theme->getLogo($useSvg);
320
+        }
321 321
 
322
-		if ($useSvg) {
323
-			$logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.svg');
324
-		} else {
325
-			$logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.png');
326
-		}
327
-		return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion()));
328
-	}
322
+        if ($useSvg) {
323
+            $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.svg');
324
+        } else {
325
+            $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.png');
326
+        }
327
+        return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion()));
328
+    }
329 329
 
330
-	public function getTextColorPrimary() {
331
-		if ($this->themeExist('getTextColorPrimary')) {
332
-			return $this->theme->getTextColorPrimary();
333
-		}
334
-		return $this->defaultTextColorPrimary;
335
-	}
330
+    public function getTextColorPrimary() {
331
+        if ($this->themeExist('getTextColorPrimary')) {
332
+            return $this->theme->getTextColorPrimary();
333
+        }
334
+        return $this->defaultTextColorPrimary;
335
+    }
336 336
 
337
-	public function getProductName() {
338
-		if ($this->themeExist('getProductName')) {
339
-			return $this->theme->getProductName();
340
-		}
341
-		return $this->defaultProductName;
342
-	}
337
+    public function getProductName() {
338
+        if ($this->themeExist('getProductName')) {
339
+            return $this->theme->getProductName();
340
+        }
341
+        return $this->defaultProductName;
342
+    }
343 343
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		$this->defaultTextColorPrimary = '#ffffff';
73 73
 		$this->defaultProductName = 'Nextcloud';
74 74
 
75
-		$themePath = OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php';
75
+		$themePath = OC::$SERVERROOT.'/themes/'.OC_Util::getTheme().'/defaults.php';
76 76
 		if (file_exists($themePath)) {
77 77
 			// prevent defaults.php from printing output
78 78
 			ob_start();
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 		if ($this->themeExist('getShortFooter')) {
248 248
 			$footer = $this->theme->getShortFooter();
249 249
 		} else {
250
-			$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
251
-				' rel="noreferrer noopener">' .$this->getEntity() . '</a>'.
252
-				' – ' . $this->getSlogan();
250
+			$footer = '<a href="'.$this->getBaseUrl().'" target="_blank"'.
251
+				' rel="noreferrer noopener">'.$this->getEntity().'</a>'.
252
+				' – '.$this->getSlogan();
253 253
 		}
254 254
 
255 255
 		return $footer;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 		if ($this->themeExist('buildDocLinkToKey')) {
278 278
 			return $this->theme->buildDocLinkToKey($key);
279 279
 		}
280
-		return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
280
+		return $this->getDocBaseUrl().'/server/'.$this->defaultDocVersion.'/go.php?to='.$key;
281 281
 	}
282 282
 
283 283
 	/**
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 		} else {
325 325
 			$logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.png');
326 326
 		}
327
-		return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion()));
327
+		return $logo.'?v='.hash('sha1', implode('.', \OCP\Util::getVersion()));
328 328
 	}
329 329
 
330 330
 	public function getTextColorPrimary() {
Please login to merge, or discard this patch.
apps/theming/lib/ThemingDefaults.php 1 patch
Indentation   +397 added lines, -397 removed lines patch added patch discarded remove patch
@@ -51,401 +51,401 @@
 block discarded – undo
51 51
 
52 52
 class ThemingDefaults extends \OC_Defaults {
53 53
 
54
-	/** @var IConfig */
55
-	private $config;
56
-	/** @var IL10N */
57
-	private $l;
58
-	/** @var ImageManager */
59
-	private $imageManager;
60
-	/** @var IURLGenerator */
61
-	private $urlGenerator;
62
-	/** @var ICacheFactory */
63
-	private $cacheFactory;
64
-	/** @var Util */
65
-	private $util;
66
-	/** @var IAppManager */
67
-	private $appManager;
68
-	/** @var INavigationManager */
69
-	private $navigationManager;
70
-
71
-	/** @var string */
72
-	private $name;
73
-	/** @var string */
74
-	private $title;
75
-	/** @var string */
76
-	private $entity;
77
-	/** @var string */
78
-	private $productName;
79
-	/** @var string */
80
-	private $url;
81
-	/** @var string */
82
-	private $color;
83
-
84
-	/** @var string */
85
-	private $iTunesAppId;
86
-	/** @var string */
87
-	private $iOSClientUrl;
88
-	/** @var string */
89
-	private $AndroidClientUrl;
90
-
91
-	/**
92
-	 * ThemingDefaults constructor.
93
-	 *
94
-	 * @param IConfig $config
95
-	 * @param IL10N $l
96
-	 * @param ImageManager $imageManager
97
-	 * @param IURLGenerator $urlGenerator
98
-	 * @param ICacheFactory $cacheFactory
99
-	 * @param Util $util
100
-	 * @param IAppManager $appManager
101
-	 */
102
-	public function __construct(IConfig $config,
103
-								IL10N $l,
104
-								IURLGenerator $urlGenerator,
105
-								ICacheFactory $cacheFactory,
106
-								Util $util,
107
-								ImageManager $imageManager,
108
-								IAppManager $appManager,
109
-								INavigationManager $navigationManager
110
-	) {
111
-		parent::__construct();
112
-		$this->config = $config;
113
-		$this->l = $l;
114
-		$this->imageManager = $imageManager;
115
-		$this->urlGenerator = $urlGenerator;
116
-		$this->cacheFactory = $cacheFactory;
117
-		$this->util = $util;
118
-		$this->appManager = $appManager;
119
-		$this->navigationManager = $navigationManager;
120
-
121
-		$this->name = parent::getName();
122
-		$this->title = parent::getTitle();
123
-		$this->entity = parent::getEntity();
124
-		$this->productName = parent::getProductName();
125
-		$this->url = parent::getBaseUrl();
126
-		$this->color = parent::getColorPrimary();
127
-		$this->iTunesAppId = parent::getiTunesAppId();
128
-		$this->iOSClientUrl = parent::getiOSClientUrl();
129
-		$this->AndroidClientUrl = parent::getAndroidClientUrl();
130
-	}
131
-
132
-	public function getName() {
133
-		return strip_tags($this->config->getAppValue('theming', 'name', $this->name));
134
-	}
135
-
136
-	public function getHTMLName() {
137
-		return $this->config->getAppValue('theming', 'name', $this->name);
138
-	}
139
-
140
-	public function getTitle() {
141
-		return strip_tags($this->config->getAppValue('theming', 'name', $this->title));
142
-	}
143
-
144
-	public function getEntity() {
145
-		return strip_tags($this->config->getAppValue('theming', 'name', $this->entity));
146
-	}
147
-
148
-	public function getProductName() {
149
-		return strip_tags($this->config->getAppValue('theming', 'productName', $this->productName));
150
-	}
151
-
152
-	public function getBaseUrl() {
153
-		return $this->config->getAppValue('theming', 'url', $this->url);
154
-	}
155
-
156
-	public function getSlogan(?string $lang = null) {
157
-		return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', parent::getSlogan($lang)));
158
-	}
159
-
160
-	public function getImprintUrl() {
161
-		return (string)$this->config->getAppValue('theming', 'imprintUrl', '');
162
-	}
163
-
164
-	public function getPrivacyUrl() {
165
-		return (string)$this->config->getAppValue('theming', 'privacyUrl', '');
166
-	}
167
-
168
-	public function getShortFooter() {
169
-		$slogan = $this->getSlogan();
170
-		$baseUrl = $this->getBaseUrl();
171
-		if ($baseUrl !== '') {
172
-			$footer = '<a href="' . $baseUrl . '" target="_blank"' .
173
-				' rel="noreferrer noopener" class="entity-name">' . $this->getEntity() . '</a>';
174
-		} else {
175
-			$footer = '<span class="entity-name">' .$this->getEntity() . '</span>';
176
-		}
177
-		$footer .= ($slogan !== '' ? ' – ' . $slogan : '');
178
-
179
-		$links = [
180
-			[
181
-				'text' => $this->l->t('Legal notice'),
182
-				'url' => (string)$this->getImprintUrl()
183
-			],
184
-			[
185
-				'text' => $this->l->t('Privacy policy'),
186
-				'url' => (string)$this->getPrivacyUrl()
187
-			],
188
-		];
189
-
190
-		$navigation = $this->navigationManager->getAll(INavigationManager::TYPE_GUEST);
191
-		$guestNavigation = array_map(function ($nav) {
192
-			return [
193
-				'text' => $nav['name'],
194
-				'url' => $nav['href']
195
-			];
196
-		}, $navigation);
197
-		$links = array_merge($links, $guestNavigation);
198
-
199
-		$legalLinks = '';
200
-		$divider = '';
201
-		foreach ($links as $link) {
202
-			if ($link['url'] !== ''
203
-				&& filter_var($link['url'], FILTER_VALIDATE_URL)
204
-			) {
205
-				$legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"' .
206
-					' rel="noreferrer noopener">' . $link['text'] . '</a>';
207
-				$divider = ' · ';
208
-			}
209
-		}
210
-		if ($legalLinks !== '') {
211
-			$footer .= '<br/>' . $legalLinks;
212
-		}
213
-
214
-		return $footer;
215
-	}
216
-
217
-	/**
218
-	 * Color that is used for the header as well as for mail headers
219
-	 *
220
-	 * @return string
221
-	 */
222
-	public function getColorPrimary() {
223
-		return $this->config->getAppValue('theming', 'color', $this->color);
224
-	}
225
-
226
-	/**
227
-	 * Themed logo url
228
-	 *
229
-	 * @param bool $useSvg Whether to point to the SVG image or a fallback
230
-	 * @return string
231
-	 */
232
-	public function getLogo($useSvg = true): string {
233
-		$logo = $this->config->getAppValue('theming', 'logoMime', '');
234
-
235
-		// short cut to avoid setting up the filesystem just to check if the logo is there
236
-		//
237
-		// explanation: if an SVG is requested and the app config value for logoMime is set then the logo is there.
238
-		// otherwise we need to check it and maybe also generate a PNG from the SVG (that's done in getImage() which
239
-		// needs to be called then)
240
-		if ($useSvg === true && $logo !== false) {
241
-			$logoExists = true;
242
-		} else {
243
-			try {
244
-				$this->imageManager->getImage('logo', $useSvg);
245
-				$logoExists = true;
246
-			} catch (\Exception $e) {
247
-				$logoExists = false;
248
-			}
249
-		}
250
-
251
-		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
252
-
253
-		if (!$logo || !$logoExists) {
254
-			if ($useSvg) {
255
-				$logo = $this->urlGenerator->imagePath('core', 'logo/logo.svg');
256
-			} else {
257
-				$logo = $this->urlGenerator->imagePath('core', 'logo/logo.png');
258
-			}
259
-			return $logo . '?v=' . $cacheBusterCounter;
260
-		}
261
-
262
-		return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter ]);
263
-	}
264
-
265
-	/**
266
-	 * Themed background image url
267
-	 *
268
-	 * @return string
269
-	 */
270
-	public function getBackground(): string {
271
-		return $this->imageManager->getImageUrl('background');
272
-	}
273
-
274
-	/**
275
-	 * @return string
276
-	 */
277
-	public function getiTunesAppId() {
278
-		return $this->config->getAppValue('theming', 'iTunesAppId', $this->iTunesAppId);
279
-	}
280
-
281
-	/**
282
-	 * @return string
283
-	 */
284
-	public function getiOSClientUrl() {
285
-		return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl);
286
-	}
287
-
288
-	/**
289
-	 * @return string
290
-	 */
291
-	public function getAndroidClientUrl() {
292
-		return $this->config->getAppValue('theming', 'AndroidClientUrl', $this->AndroidClientUrl);
293
-	}
294
-
295
-
296
-	/**
297
-	 * @return array scss variables to overwrite
298
-	 */
299
-	public function getScssVariables() {
300
-		$cacheBuster = $this->config->getAppValue('theming', 'cachebuster', '0');
301
-		$cache = $this->cacheFactory->createDistributed('theming-' . $cacheBuster . '-' . $this->urlGenerator->getBaseUrl());
302
-		if ($value = $cache->get('getScssVariables')) {
303
-			return $value;
304
-		}
305
-
306
-		$variables = [
307
-			'theming-cachebuster' => "'" . $cacheBuster . "'",
308
-			'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime') . "'",
309
-			'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime') . "'",
310
-			'theming-logoheader-mime' => "'" . $this->config->getAppValue('theming', 'logoheaderMime') . "'",
311
-			'theming-favicon-mime' => "'" . $this->config->getAppValue('theming', 'faviconMime') . "'"
312
-		];
313
-
314
-		$variables['image-logo'] = "url('".$this->imageManager->getImageUrl('logo')."')";
315
-		$variables['image-logoheader'] = "url('".$this->imageManager->getImageUrl('logoheader')."')";
316
-		$variables['image-favicon'] = "url('".$this->imageManager->getImageUrl('favicon')."')";
317
-		$variables['image-login-background'] = "url('".$this->imageManager->getImageUrl('background')."')";
318
-		$variables['image-login-plain'] = 'false';
319
-
320
-		if ($this->config->getAppValue('theming', 'color', '') !== '') {
321
-			$variables['color-primary'] = $this->getColorPrimary();
322
-			$variables['color-primary-text'] = $this->getTextColorPrimary();
323
-			$variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary());
324
-		}
325
-
326
-		if ($this->config->getAppValue('theming', 'backgroundMime', '') === 'backgroundColor') {
327
-			$variables['image-login-plain'] = 'true';
328
-		}
329
-
330
-		$variables['has-legal-links'] = 'false';
331
-		if ($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') {
332
-			$variables['has-legal-links'] = 'true';
333
-		}
334
-
335
-		$cache->set('getScssVariables', $variables);
336
-		return $variables;
337
-	}
338
-
339
-	/**
340
-	 * Check if the image should be replaced by the theming app
341
-	 * and return the new image location then
342
-	 *
343
-	 * @param string $app name of the app
344
-	 * @param string $image filename of the image
345
-	 * @return bool|string false if image should not replaced, otherwise the location of the image
346
-	 */
347
-	public function replaceImagePath($app, $image) {
348
-		if ($app === '' || $app === 'files_sharing') {
349
-			$app = 'core';
350
-		}
351
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
352
-
353
-		try {
354
-			$customFavicon = $this->imageManager->getImage('favicon');
355
-		} catch (NotFoundException $e) {
356
-			$customFavicon = null;
357
-		}
358
-
359
-		$route = false;
360
-		if ($image === 'favicon.ico' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) {
361
-			$route = $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]);
362
-		}
363
-		if (($image === 'favicon-touch.png' || $image === 'favicon-fb.png') && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) {
364
-			$route = $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]);
365
-		}
366
-		if ($image === 'manifest.json') {
367
-			try {
368
-				$appPath = $this->appManager->getAppPath($app);
369
-				if (file_exists($appPath . '/img/manifest.json')) {
370
-					return false;
371
-				}
372
-			} catch (AppPathNotFoundException $e) {
373
-			}
374
-			$route = $this->urlGenerator->linkToRoute('theming.Theming.getManifest');
375
-		}
376
-		if (strpos($image, 'filetypes/') === 0 && file_exists(\OC::$SERVERROOT . '/core/img/' . $image)) {
377
-			$route = $this->urlGenerator->linkToRoute('theming.Icon.getThemedIcon', ['app' => $app, 'image' => $image]);
378
-		}
379
-
380
-		if ($route) {
381
-			return $route . '?v=' . $cacheBusterValue;
382
-		}
383
-
384
-		return false;
385
-	}
386
-
387
-	/**
388
-	 * Increases the cache buster key
389
-	 */
390
-	private function increaseCacheBuster() {
391
-		$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
392
-		$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey + 1);
393
-		$this->cacheFactory->createDistributed('theming-')->clear();
394
-		$this->cacheFactory->createDistributed('imagePath')->clear();
395
-	}
396
-
397
-	/**
398
-	 * Update setting in the database
399
-	 *
400
-	 * @param string $setting
401
-	 * @param string $value
402
-	 */
403
-	public function set($setting, $value) {
404
-		$this->config->setAppValue('theming', $setting, $value);
405
-		$this->increaseCacheBuster();
406
-	}
407
-
408
-	/**
409
-	 * Revert settings to the default value
410
-	 *
411
-	 * @param string $setting setting which should be reverted
412
-	 * @return string default value
413
-	 */
414
-	public function undo($setting) {
415
-		$this->config->deleteAppValue('theming', $setting);
416
-		$this->increaseCacheBuster();
417
-
418
-		$returnValue = '';
419
-		switch ($setting) {
420
-			case 'name':
421
-				$returnValue = $this->getEntity();
422
-				break;
423
-			case 'url':
424
-				$returnValue = $this->getBaseUrl();
425
-				break;
426
-			case 'slogan':
427
-				$returnValue = $this->getSlogan();
428
-				break;
429
-			case 'color':
430
-				$returnValue = $this->getColorPrimary();
431
-				break;
432
-			case 'logo':
433
-			case 'logoheader':
434
-			case 'background':
435
-			case 'favicon':
436
-				$this->imageManager->delete($setting);
437
-				break;
438
-		}
439
-
440
-		return $returnValue;
441
-	}
442
-
443
-	/**
444
-	 * Color of text in the header and primary buttons
445
-	 *
446
-	 * @return string
447
-	 */
448
-	public function getTextColorPrimary() {
449
-		return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#ffffff';
450
-	}
54
+    /** @var IConfig */
55
+    private $config;
56
+    /** @var IL10N */
57
+    private $l;
58
+    /** @var ImageManager */
59
+    private $imageManager;
60
+    /** @var IURLGenerator */
61
+    private $urlGenerator;
62
+    /** @var ICacheFactory */
63
+    private $cacheFactory;
64
+    /** @var Util */
65
+    private $util;
66
+    /** @var IAppManager */
67
+    private $appManager;
68
+    /** @var INavigationManager */
69
+    private $navigationManager;
70
+
71
+    /** @var string */
72
+    private $name;
73
+    /** @var string */
74
+    private $title;
75
+    /** @var string */
76
+    private $entity;
77
+    /** @var string */
78
+    private $productName;
79
+    /** @var string */
80
+    private $url;
81
+    /** @var string */
82
+    private $color;
83
+
84
+    /** @var string */
85
+    private $iTunesAppId;
86
+    /** @var string */
87
+    private $iOSClientUrl;
88
+    /** @var string */
89
+    private $AndroidClientUrl;
90
+
91
+    /**
92
+     * ThemingDefaults constructor.
93
+     *
94
+     * @param IConfig $config
95
+     * @param IL10N $l
96
+     * @param ImageManager $imageManager
97
+     * @param IURLGenerator $urlGenerator
98
+     * @param ICacheFactory $cacheFactory
99
+     * @param Util $util
100
+     * @param IAppManager $appManager
101
+     */
102
+    public function __construct(IConfig $config,
103
+                                IL10N $l,
104
+                                IURLGenerator $urlGenerator,
105
+                                ICacheFactory $cacheFactory,
106
+                                Util $util,
107
+                                ImageManager $imageManager,
108
+                                IAppManager $appManager,
109
+                                INavigationManager $navigationManager
110
+    ) {
111
+        parent::__construct();
112
+        $this->config = $config;
113
+        $this->l = $l;
114
+        $this->imageManager = $imageManager;
115
+        $this->urlGenerator = $urlGenerator;
116
+        $this->cacheFactory = $cacheFactory;
117
+        $this->util = $util;
118
+        $this->appManager = $appManager;
119
+        $this->navigationManager = $navigationManager;
120
+
121
+        $this->name = parent::getName();
122
+        $this->title = parent::getTitle();
123
+        $this->entity = parent::getEntity();
124
+        $this->productName = parent::getProductName();
125
+        $this->url = parent::getBaseUrl();
126
+        $this->color = parent::getColorPrimary();
127
+        $this->iTunesAppId = parent::getiTunesAppId();
128
+        $this->iOSClientUrl = parent::getiOSClientUrl();
129
+        $this->AndroidClientUrl = parent::getAndroidClientUrl();
130
+    }
131
+
132
+    public function getName() {
133
+        return strip_tags($this->config->getAppValue('theming', 'name', $this->name));
134
+    }
135
+
136
+    public function getHTMLName() {
137
+        return $this->config->getAppValue('theming', 'name', $this->name);
138
+    }
139
+
140
+    public function getTitle() {
141
+        return strip_tags($this->config->getAppValue('theming', 'name', $this->title));
142
+    }
143
+
144
+    public function getEntity() {
145
+        return strip_tags($this->config->getAppValue('theming', 'name', $this->entity));
146
+    }
147
+
148
+    public function getProductName() {
149
+        return strip_tags($this->config->getAppValue('theming', 'productName', $this->productName));
150
+    }
151
+
152
+    public function getBaseUrl() {
153
+        return $this->config->getAppValue('theming', 'url', $this->url);
154
+    }
155
+
156
+    public function getSlogan(?string $lang = null) {
157
+        return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', parent::getSlogan($lang)));
158
+    }
159
+
160
+    public function getImprintUrl() {
161
+        return (string)$this->config->getAppValue('theming', 'imprintUrl', '');
162
+    }
163
+
164
+    public function getPrivacyUrl() {
165
+        return (string)$this->config->getAppValue('theming', 'privacyUrl', '');
166
+    }
167
+
168
+    public function getShortFooter() {
169
+        $slogan = $this->getSlogan();
170
+        $baseUrl = $this->getBaseUrl();
171
+        if ($baseUrl !== '') {
172
+            $footer = '<a href="' . $baseUrl . '" target="_blank"' .
173
+                ' rel="noreferrer noopener" class="entity-name">' . $this->getEntity() . '</a>';
174
+        } else {
175
+            $footer = '<span class="entity-name">' .$this->getEntity() . '</span>';
176
+        }
177
+        $footer .= ($slogan !== '' ? ' – ' . $slogan : '');
178
+
179
+        $links = [
180
+            [
181
+                'text' => $this->l->t('Legal notice'),
182
+                'url' => (string)$this->getImprintUrl()
183
+            ],
184
+            [
185
+                'text' => $this->l->t('Privacy policy'),
186
+                'url' => (string)$this->getPrivacyUrl()
187
+            ],
188
+        ];
189
+
190
+        $navigation = $this->navigationManager->getAll(INavigationManager::TYPE_GUEST);
191
+        $guestNavigation = array_map(function ($nav) {
192
+            return [
193
+                'text' => $nav['name'],
194
+                'url' => $nav['href']
195
+            ];
196
+        }, $navigation);
197
+        $links = array_merge($links, $guestNavigation);
198
+
199
+        $legalLinks = '';
200
+        $divider = '';
201
+        foreach ($links as $link) {
202
+            if ($link['url'] !== ''
203
+                && filter_var($link['url'], FILTER_VALIDATE_URL)
204
+            ) {
205
+                $legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"' .
206
+                    ' rel="noreferrer noopener">' . $link['text'] . '</a>';
207
+                $divider = ' · ';
208
+            }
209
+        }
210
+        if ($legalLinks !== '') {
211
+            $footer .= '<br/>' . $legalLinks;
212
+        }
213
+
214
+        return $footer;
215
+    }
216
+
217
+    /**
218
+     * Color that is used for the header as well as for mail headers
219
+     *
220
+     * @return string
221
+     */
222
+    public function getColorPrimary() {
223
+        return $this->config->getAppValue('theming', 'color', $this->color);
224
+    }
225
+
226
+    /**
227
+     * Themed logo url
228
+     *
229
+     * @param bool $useSvg Whether to point to the SVG image or a fallback
230
+     * @return string
231
+     */
232
+    public function getLogo($useSvg = true): string {
233
+        $logo = $this->config->getAppValue('theming', 'logoMime', '');
234
+
235
+        // short cut to avoid setting up the filesystem just to check if the logo is there
236
+        //
237
+        // explanation: if an SVG is requested and the app config value for logoMime is set then the logo is there.
238
+        // otherwise we need to check it and maybe also generate a PNG from the SVG (that's done in getImage() which
239
+        // needs to be called then)
240
+        if ($useSvg === true && $logo !== false) {
241
+            $logoExists = true;
242
+        } else {
243
+            try {
244
+                $this->imageManager->getImage('logo', $useSvg);
245
+                $logoExists = true;
246
+            } catch (\Exception $e) {
247
+                $logoExists = false;
248
+            }
249
+        }
250
+
251
+        $cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
252
+
253
+        if (!$logo || !$logoExists) {
254
+            if ($useSvg) {
255
+                $logo = $this->urlGenerator->imagePath('core', 'logo/logo.svg');
256
+            } else {
257
+                $logo = $this->urlGenerator->imagePath('core', 'logo/logo.png');
258
+            }
259
+            return $logo . '?v=' . $cacheBusterCounter;
260
+        }
261
+
262
+        return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo', 'useSvg' => $useSvg, 'v' => $cacheBusterCounter ]);
263
+    }
264
+
265
+    /**
266
+     * Themed background image url
267
+     *
268
+     * @return string
269
+     */
270
+    public function getBackground(): string {
271
+        return $this->imageManager->getImageUrl('background');
272
+    }
273
+
274
+    /**
275
+     * @return string
276
+     */
277
+    public function getiTunesAppId() {
278
+        return $this->config->getAppValue('theming', 'iTunesAppId', $this->iTunesAppId);
279
+    }
280
+
281
+    /**
282
+     * @return string
283
+     */
284
+    public function getiOSClientUrl() {
285
+        return $this->config->getAppValue('theming', 'iOSClientUrl', $this->iOSClientUrl);
286
+    }
287
+
288
+    /**
289
+     * @return string
290
+     */
291
+    public function getAndroidClientUrl() {
292
+        return $this->config->getAppValue('theming', 'AndroidClientUrl', $this->AndroidClientUrl);
293
+    }
294
+
295
+
296
+    /**
297
+     * @return array scss variables to overwrite
298
+     */
299
+    public function getScssVariables() {
300
+        $cacheBuster = $this->config->getAppValue('theming', 'cachebuster', '0');
301
+        $cache = $this->cacheFactory->createDistributed('theming-' . $cacheBuster . '-' . $this->urlGenerator->getBaseUrl());
302
+        if ($value = $cache->get('getScssVariables')) {
303
+            return $value;
304
+        }
305
+
306
+        $variables = [
307
+            'theming-cachebuster' => "'" . $cacheBuster . "'",
308
+            'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime') . "'",
309
+            'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime') . "'",
310
+            'theming-logoheader-mime' => "'" . $this->config->getAppValue('theming', 'logoheaderMime') . "'",
311
+            'theming-favicon-mime' => "'" . $this->config->getAppValue('theming', 'faviconMime') . "'"
312
+        ];
313
+
314
+        $variables['image-logo'] = "url('".$this->imageManager->getImageUrl('logo')."')";
315
+        $variables['image-logoheader'] = "url('".$this->imageManager->getImageUrl('logoheader')."')";
316
+        $variables['image-favicon'] = "url('".$this->imageManager->getImageUrl('favicon')."')";
317
+        $variables['image-login-background'] = "url('".$this->imageManager->getImageUrl('background')."')";
318
+        $variables['image-login-plain'] = 'false';
319
+
320
+        if ($this->config->getAppValue('theming', 'color', '') !== '') {
321
+            $variables['color-primary'] = $this->getColorPrimary();
322
+            $variables['color-primary-text'] = $this->getTextColorPrimary();
323
+            $variables['color-primary-element'] = $this->util->elementColor($this->getColorPrimary());
324
+        }
325
+
326
+        if ($this->config->getAppValue('theming', 'backgroundMime', '') === 'backgroundColor') {
327
+            $variables['image-login-plain'] = 'true';
328
+        }
329
+
330
+        $variables['has-legal-links'] = 'false';
331
+        if ($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') {
332
+            $variables['has-legal-links'] = 'true';
333
+        }
334
+
335
+        $cache->set('getScssVariables', $variables);
336
+        return $variables;
337
+    }
338
+
339
+    /**
340
+     * Check if the image should be replaced by the theming app
341
+     * and return the new image location then
342
+     *
343
+     * @param string $app name of the app
344
+     * @param string $image filename of the image
345
+     * @return bool|string false if image should not replaced, otherwise the location of the image
346
+     */
347
+    public function replaceImagePath($app, $image) {
348
+        if ($app === '' || $app === 'files_sharing') {
349
+            $app = 'core';
350
+        }
351
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
352
+
353
+        try {
354
+            $customFavicon = $this->imageManager->getImage('favicon');
355
+        } catch (NotFoundException $e) {
356
+            $customFavicon = null;
357
+        }
358
+
359
+        $route = false;
360
+        if ($image === 'favicon.ico' && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) {
361
+            $route = $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]);
362
+        }
363
+        if (($image === 'favicon-touch.png' || $image === 'favicon-fb.png') && ($customFavicon !== null || $this->imageManager->shouldReplaceIcons())) {
364
+            $route = $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]);
365
+        }
366
+        if ($image === 'manifest.json') {
367
+            try {
368
+                $appPath = $this->appManager->getAppPath($app);
369
+                if (file_exists($appPath . '/img/manifest.json')) {
370
+                    return false;
371
+                }
372
+            } catch (AppPathNotFoundException $e) {
373
+            }
374
+            $route = $this->urlGenerator->linkToRoute('theming.Theming.getManifest');
375
+        }
376
+        if (strpos($image, 'filetypes/') === 0 && file_exists(\OC::$SERVERROOT . '/core/img/' . $image)) {
377
+            $route = $this->urlGenerator->linkToRoute('theming.Icon.getThemedIcon', ['app' => $app, 'image' => $image]);
378
+        }
379
+
380
+        if ($route) {
381
+            return $route . '?v=' . $cacheBusterValue;
382
+        }
383
+
384
+        return false;
385
+    }
386
+
387
+    /**
388
+     * Increases the cache buster key
389
+     */
390
+    private function increaseCacheBuster() {
391
+        $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
392
+        $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey + 1);
393
+        $this->cacheFactory->createDistributed('theming-')->clear();
394
+        $this->cacheFactory->createDistributed('imagePath')->clear();
395
+    }
396
+
397
+    /**
398
+     * Update setting in the database
399
+     *
400
+     * @param string $setting
401
+     * @param string $value
402
+     */
403
+    public function set($setting, $value) {
404
+        $this->config->setAppValue('theming', $setting, $value);
405
+        $this->increaseCacheBuster();
406
+    }
407
+
408
+    /**
409
+     * Revert settings to the default value
410
+     *
411
+     * @param string $setting setting which should be reverted
412
+     * @return string default value
413
+     */
414
+    public function undo($setting) {
415
+        $this->config->deleteAppValue('theming', $setting);
416
+        $this->increaseCacheBuster();
417
+
418
+        $returnValue = '';
419
+        switch ($setting) {
420
+            case 'name':
421
+                $returnValue = $this->getEntity();
422
+                break;
423
+            case 'url':
424
+                $returnValue = $this->getBaseUrl();
425
+                break;
426
+            case 'slogan':
427
+                $returnValue = $this->getSlogan();
428
+                break;
429
+            case 'color':
430
+                $returnValue = $this->getColorPrimary();
431
+                break;
432
+            case 'logo':
433
+            case 'logoheader':
434
+            case 'background':
435
+            case 'favicon':
436
+                $this->imageManager->delete($setting);
437
+                break;
438
+        }
439
+
440
+        return $returnValue;
441
+    }
442
+
443
+    /**
444
+     * Color of text in the header and primary buttons
445
+     *
446
+     * @return string
447
+     */
448
+    public function getTextColorPrimary() {
449
+        return $this->util->invertTextColor($this->getColorPrimary()) ? '#000000' : '#ffffff';
450
+    }
451 451
 }
Please login to merge, or discard this patch.