Completed
Pull Request — master (#3531)
by Julius
15:36
created
apps/theming/lib/ThemingDefaults.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
 	 * @param IL10N $l
61 61
 	 * @param IURLGenerator $urlGenerator
62 62
 	 * @param \OC_Defaults $defaults
63
-	 * @param IRootFolder $appData
63
+	 * @param IAppData $appData
64 64
 	 * @param ICacheFactory $cacheFactory
65 65
 	 * @param Util $util
66 66
 	 */
Please login to merge, or discard this patch.
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -32,242 +32,242 @@
 block discarded – undo
32 32
 
33 33
 class ThemingDefaults extends \OC_Defaults {
34 34
 
35
-	/** @var IConfig */
36
-	private $config;
37
-	/** @var IL10N */
38
-	private $l;
39
-	/** @var IURLGenerator */
40
-	private $urlGenerator;
41
-	/** @var IAppData */
42
-	private $appData;
43
-	/** @var \OC_Defaults */
44
-	private $defaults;
45
-	/** @var ICacheFactory */
46
-	private $cacheFactory;
47
-	/** @var string */
48
-	private $name;
49
-	/** @var string */
50
-	private $url;
51
-	/** @var string */
52
-	private $slogan;
53
-	/** @var string */
54
-	private $color;
35
+    /** @var IConfig */
36
+    private $config;
37
+    /** @var IL10N */
38
+    private $l;
39
+    /** @var IURLGenerator */
40
+    private $urlGenerator;
41
+    /** @var IAppData */
42
+    private $appData;
43
+    /** @var \OC_Defaults */
44
+    private $defaults;
45
+    /** @var ICacheFactory */
46
+    private $cacheFactory;
47
+    /** @var string */
48
+    private $name;
49
+    /** @var string */
50
+    private $url;
51
+    /** @var string */
52
+    private $slogan;
53
+    /** @var string */
54
+    private $color;
55 55
 
56
-	/**
57
-	 * ThemingDefaults constructor.
58
-	 *
59
-	 * @param IConfig $config
60
-	 * @param IL10N $l
61
-	 * @param IURLGenerator $urlGenerator
62
-	 * @param \OC_Defaults $defaults
63
-	 * @param IRootFolder $appData
64
-	 * @param ICacheFactory $cacheFactory
65
-	 * @param Util $util
66
-	 */
67
-	public function __construct(IConfig $config,
68
-								IL10N $l,
69
-								IURLGenerator $urlGenerator,
70
-								\OC_Defaults $defaults,
71
-								IAppData $appData,
72
-								ICacheFactory $cacheFactory,
73
-								Util $util
74
-	) {
75
-		$this->config = $config;
76
-		$this->l = $l;
77
-		$this->urlGenerator = $urlGenerator;
78
-		$this->defaults = $defaults;
79
-		$this->appData = $appData;
80
-		$this->cacheFactory = $cacheFactory;
81
-		$this->util = $util;
56
+    /**
57
+     * ThemingDefaults constructor.
58
+     *
59
+     * @param IConfig $config
60
+     * @param IL10N $l
61
+     * @param IURLGenerator $urlGenerator
62
+     * @param \OC_Defaults $defaults
63
+     * @param IRootFolder $appData
64
+     * @param ICacheFactory $cacheFactory
65
+     * @param Util $util
66
+     */
67
+    public function __construct(IConfig $config,
68
+                                IL10N $l,
69
+                                IURLGenerator $urlGenerator,
70
+                                \OC_Defaults $defaults,
71
+                                IAppData $appData,
72
+                                ICacheFactory $cacheFactory,
73
+                                Util $util
74
+    ) {
75
+        $this->config = $config;
76
+        $this->l = $l;
77
+        $this->urlGenerator = $urlGenerator;
78
+        $this->defaults = $defaults;
79
+        $this->appData = $appData;
80
+        $this->cacheFactory = $cacheFactory;
81
+        $this->util = $util;
82 82
 
83
-		$this->name = $this->defaults->getName();
84
-		$this->url = $this->defaults->getBaseUrl();
85
-		$this->slogan = $this->defaults->getSlogan();
86
-		$this->color = $this->defaults->getMailHeaderColor();
87
-	}
83
+        $this->name = $this->defaults->getName();
84
+        $this->url = $this->defaults->getBaseUrl();
85
+        $this->slogan = $this->defaults->getSlogan();
86
+        $this->color = $this->defaults->getMailHeaderColor();
87
+    }
88 88
 
89
-	public function getName() {
90
-		return strip_tags($this->config->getAppValue('theming', 'name', $this->name));
91
-	}
89
+    public function getName() {
90
+        return strip_tags($this->config->getAppValue('theming', 'name', $this->name));
91
+    }
92 92
 
93
-	public function getHTMLName() {
94
-		return $this->config->getAppValue('theming', 'name', $this->name);
95
-	}
93
+    public function getHTMLName() {
94
+        return $this->config->getAppValue('theming', 'name', $this->name);
95
+    }
96 96
 
97
-	public function getTitle() {
98
-		return $this->getName();
99
-	}
97
+    public function getTitle() {
98
+        return $this->getName();
99
+    }
100 100
 
101
-	public function getEntity() {
102
-		return $this->getName();
103
-	}
101
+    public function getEntity() {
102
+        return $this->getName();
103
+    }
104 104
 
105
-	public function getBaseUrl() {
106
-		return $this->config->getAppValue('theming', 'url', $this->url);
107
-	}
105
+    public function getBaseUrl() {
106
+        return $this->config->getAppValue('theming', 'url', $this->url);
107
+    }
108 108
 
109
-	public function getSlogan() {
110
-		return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan));
111
-	}
109
+    public function getSlogan() {
110
+        return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan));
111
+    }
112 112
 
113
-	public function getShortFooter() {
114
-		$slogan = $this->getSlogan();
115
-		$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
116
-			' rel="noreferrer">' .$this->getEntity() . '</a>'.
117
-			($slogan !== '' ? ' – ' . $slogan : '');
113
+    public function getShortFooter() {
114
+        $slogan = $this->getSlogan();
115
+        $footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
116
+            ' rel="noreferrer">' .$this->getEntity() . '</a>'.
117
+            ($slogan !== '' ? ' – ' . $slogan : '');
118 118
 
119
-		return $footer;
120
-	}
119
+        return $footer;
120
+    }
121 121
 
122
-	/**
123
-	 * Color that is used for the header as well as for mail headers
124
-	 *
125
-	 * @return string
126
-	 */
127
-	public function getMailHeaderColor() {
128
-		return $this->config->getAppValue('theming', 'color', $this->color);
129
-	}
122
+    /**
123
+     * Color that is used for the header as well as for mail headers
124
+     *
125
+     * @return string
126
+     */
127
+    public function getMailHeaderColor() {
128
+        return $this->config->getAppValue('theming', 'color', $this->color);
129
+    }
130 130
 
131
-	/**
132
-	 * Themed logo url
133
-	 *
134
-	 * @return string
135
-	 */
136
-	public function getLogo() {
137
-		try {
138
-			$file = $this->appData->getFolder('images')->getFile('logo');
139
-		} catch (NotFoundException $e) {
140
-			$file = null;
141
-		}
142
-		$logo = $this->config->getAppValue('theming', 'logoMime', false);
143
-		if(!$logo || $file === null) {
144
-			return $this->urlGenerator->imagePath('core','logo.svg');
145
-		} else {
146
-			return $this->urlGenerator->linkToRoute('theming.Theming.getLogo');
147
-		}
148
-	}
131
+    /**
132
+     * Themed logo url
133
+     *
134
+     * @return string
135
+     */
136
+    public function getLogo() {
137
+        try {
138
+            $file = $this->appData->getFolder('images')->getFile('logo');
139
+        } catch (NotFoundException $e) {
140
+            $file = null;
141
+        }
142
+        $logo = $this->config->getAppValue('theming', 'logoMime', false);
143
+        if(!$logo || $file === null) {
144
+            return $this->urlGenerator->imagePath('core','logo.svg');
145
+        } else {
146
+            return $this->urlGenerator->linkToRoute('theming.Theming.getLogo');
147
+        }
148
+    }
149 149
 
150
-	/**
151
-	 * Themed background image url
152
-	 *
153
-	 * @return string
154
-	 */
155
-	public function getBackground() {
156
-		try {
157
-			$file = $this->appData->getFolder('images')->getFile('background');
158
-		} catch (NotFoundException $e) {
159
-			$file = null;
160
-		}
161
-		$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false);
162
-		if(!$backgroundLogo || $file === null) {
163
-			return $this->urlGenerator->imagePath('core','background.jpg');
164
-		} else {
165
-			return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground');
166
-		}
167
-	}
150
+    /**
151
+     * Themed background image url
152
+     *
153
+     * @return string
154
+     */
155
+    public function getBackground() {
156
+        try {
157
+            $file = $this->appData->getFolder('images')->getFile('background');
158
+        } catch (NotFoundException $e) {
159
+            $file = null;
160
+        }
161
+        $backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false);
162
+        if(!$backgroundLogo || $file === null) {
163
+            return $this->urlGenerator->imagePath('core','background.jpg');
164
+        } else {
165
+            return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground');
166
+        }
167
+    }
168 168
 
169 169
 
170
-	/**
171
-	 * @return array scss variables to overwrite
172
-	 */
173
-	public function getScssVariables() {
174
-		$cache = $this->cacheFactory->create('theming');
175
-		if($value = $cache->get('getScssVariables')) {
176
-			return $value;
177
-		}
170
+    /**
171
+     * @return array scss variables to overwrite
172
+     */
173
+    public function getScssVariables() {
174
+        $cache = $this->cacheFactory->create('theming');
175
+        if($value = $cache->get('getScssVariables')) {
176
+            return $value;
177
+        }
178 178
 
179
-		$variables = [
180
-			'theming-cachebuster' => '"'.$this->config->getAppValue('theming', 'cachebuster', '0').'"',
181
-		];
179
+        $variables = [
180
+            'theming-cachebuster' => '"'.$this->config->getAppValue('theming', 'cachebuster', '0').'"',
181
+        ];
182 182
 
183
-		$variables['image-logo'] = "'../../".$this->getLogo()."'";
184
-		$variables['image-login-background'] = "'../../".$this->getBackground()."'";
183
+        $variables['image-logo'] = "'../../".$this->getLogo()."'";
184
+        $variables['image-login-background'] = "'../../".$this->getBackground()."'";
185 185
 
186
-		if ($this->config->getAppValue('theming', 'color', null) !== null) {
187
-			if ($this->util->invertTextColor($this->getMailHeaderColor())) {
188
-				$colorPrimaryText = '#000000';
189
-			} else {
190
-				$colorPrimaryText = '#ffffff';
191
-			}
192
-			$variables['color-primary'] = $this->getMailHeaderColor();
193
-			$variables['color-primary-text'] = $colorPrimaryText;
194
-		}
195
-		$cache->set('getScssVariables', $variables);
196
-		return $variables;
197
-	}
186
+        if ($this->config->getAppValue('theming', 'color', null) !== null) {
187
+            if ($this->util->invertTextColor($this->getMailHeaderColor())) {
188
+                $colorPrimaryText = '#000000';
189
+            } else {
190
+                $colorPrimaryText = '#ffffff';
191
+            }
192
+            $variables['color-primary'] = $this->getMailHeaderColor();
193
+            $variables['color-primary-text'] = $colorPrimaryText;
194
+        }
195
+        $cache->set('getScssVariables', $variables);
196
+        return $variables;
197
+    }
198 198
 
199
-	/**
200
-	 * Check if Imagemagick is enabled and if SVG is supported
201
-	 * otherwise we can't render custom icons
202
-	 *
203
-	 * @return bool
204
-	 */
205
-	public function shouldReplaceIcons() {
206
-		$cache = $this->cacheFactory->create('theming');
207
-		if($value = $cache->get('shouldReplaceIcons')) {
208
-			return (bool)$value;
209
-		}
210
-		$value = false;
211
-		if(extension_loaded('imagick')) {
212
-			$checkImagick = new \Imagick();
213
-			if (count($checkImagick->queryFormats('SVG')) >= 1) {
214
-				$value = true;
215
-			}
216
-			$checkImagick->clear();
217
-		}
218
-		$cache->set('shouldReplaceIcons', $value);
219
-		return $value;
220
-	}
199
+    /**
200
+     * Check if Imagemagick is enabled and if SVG is supported
201
+     * otherwise we can't render custom icons
202
+     *
203
+     * @return bool
204
+     */
205
+    public function shouldReplaceIcons() {
206
+        $cache = $this->cacheFactory->create('theming');
207
+        if($value = $cache->get('shouldReplaceIcons')) {
208
+            return (bool)$value;
209
+        }
210
+        $value = false;
211
+        if(extension_loaded('imagick')) {
212
+            $checkImagick = new \Imagick();
213
+            if (count($checkImagick->queryFormats('SVG')) >= 1) {
214
+                $value = true;
215
+            }
216
+            $checkImagick->clear();
217
+        }
218
+        $cache->set('shouldReplaceIcons', $value);
219
+        return $value;
220
+    }
221 221
 
222
-	/**
223
-	 * Increases the cache buster key
224
-	 */
225
-	private function increaseCacheBuster() {
226
-		$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
227
-		$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
228
-		$this->cacheFactory->create('theming')->clear('getScssVariables');
229
-	}
222
+    /**
223
+     * Increases the cache buster key
224
+     */
225
+    private function increaseCacheBuster() {
226
+        $cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
227
+        $this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
228
+        $this->cacheFactory->create('theming')->clear('getScssVariables');
229
+    }
230 230
 
231
-	/**
232
-	 * Update setting in the database
233
-	 *
234
-	 * @param string $setting
235
-	 * @param string $value
236
-	 */
237
-	public function set($setting, $value) {
238
-		$this->config->setAppValue('theming', $setting, $value);
239
-		$this->increaseCacheBuster();
240
-	}
231
+    /**
232
+     * Update setting in the database
233
+     *
234
+     * @param string $setting
235
+     * @param string $value
236
+     */
237
+    public function set($setting, $value) {
238
+        $this->config->setAppValue('theming', $setting, $value);
239
+        $this->increaseCacheBuster();
240
+    }
241 241
 
242
-	/**
243
-	 * Revert settings to the default value
244
-	 *
245
-	 * @param string $setting setting which should be reverted
246
-	 * @return string default value
247
-	 */
248
-	public function undo($setting) {
249
-		$this->config->deleteAppValue('theming', $setting);
250
-		$this->increaseCacheBuster();
242
+    /**
243
+     * Revert settings to the default value
244
+     *
245
+     * @param string $setting setting which should be reverted
246
+     * @return string default value
247
+     */
248
+    public function undo($setting) {
249
+        $this->config->deleteAppValue('theming', $setting);
250
+        $this->increaseCacheBuster();
251 251
 
252
-		switch ($setting) {
253
-			case 'name':
254
-				$returnValue = $this->getEntity();
255
-				break;
256
-			case 'url':
257
-				$returnValue = $this->getBaseUrl();
258
-				break;
259
-			case 'slogan':
260
-				$returnValue = $this->getSlogan();
261
-				break;
262
-			case 'color':
263
-				$returnValue = $this->getMailHeaderColor();
264
-				break;
265
-			default:
266
-				$returnValue = '';
267
-				break;
268
-		}
252
+        switch ($setting) {
253
+            case 'name':
254
+                $returnValue = $this->getEntity();
255
+                break;
256
+            case 'url':
257
+                $returnValue = $this->getBaseUrl();
258
+                break;
259
+            case 'slogan':
260
+                $returnValue = $this->getSlogan();
261
+                break;
262
+            case 'color':
263
+                $returnValue = $this->getMailHeaderColor();
264
+                break;
265
+            default:
266
+                $returnValue = '';
267
+                break;
268
+        }
269 269
 
270
-		return $returnValue;
271
-	}
270
+        return $returnValue;
271
+    }
272 272
 
273 273
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 
113 113
 	public function getShortFooter() {
114 114
 		$slogan = $this->getSlogan();
115
-		$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
116
-			' rel="noreferrer">' .$this->getEntity() . '</a>'.
117
-			($slogan !== '' ? ' – ' . $slogan : '');
115
+		$footer = '<a href="'.$this->getBaseUrl().'" target="_blank"'.
116
+			' rel="noreferrer">'.$this->getEntity().'</a>'.
117
+			($slogan !== '' ? ' – '.$slogan : '');
118 118
 
119 119
 		return $footer;
120 120
 	}
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 			$file = null;
141 141
 		}
142 142
 		$logo = $this->config->getAppValue('theming', 'logoMime', false);
143
-		if(!$logo || $file === null) {
144
-			return $this->urlGenerator->imagePath('core','logo.svg');
143
+		if (!$logo || $file === null) {
144
+			return $this->urlGenerator->imagePath('core', 'logo.svg');
145 145
 		} else {
146 146
 			return $this->urlGenerator->linkToRoute('theming.Theming.getLogo');
147 147
 		}
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 			$file = null;
160 160
 		}
161 161
 		$backgroundLogo = $this->config->getAppValue('theming', 'backgroundMime', false);
162
-		if(!$backgroundLogo || $file === null) {
163
-			return $this->urlGenerator->imagePath('core','background.jpg');
162
+		if (!$backgroundLogo || $file === null) {
163
+			return $this->urlGenerator->imagePath('core', 'background.jpg');
164 164
 		} else {
165 165
 			return $this->urlGenerator->linkToRoute('theming.Theming.getLoginBackground');
166 166
 		}
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 */
173 173
 	public function getScssVariables() {
174 174
 		$cache = $this->cacheFactory->create('theming');
175
-		if($value = $cache->get('getScssVariables')) {
175
+		if ($value = $cache->get('getScssVariables')) {
176 176
 			return $value;
177 177
 		}
178 178
 
@@ -204,11 +204,11 @@  discard block
 block discarded – undo
204 204
 	 */
205 205
 	public function shouldReplaceIcons() {
206 206
 		$cache = $this->cacheFactory->create('theming');
207
-		if($value = $cache->get('shouldReplaceIcons')) {
208
-			return (bool)$value;
207
+		if ($value = $cache->get('shouldReplaceIcons')) {
208
+			return (bool) $value;
209 209
 		}
210 210
 		$value = false;
211
-		if(extension_loaded('imagick')) {
211
+		if (extension_loaded('imagick')) {
212 212
 			$checkImagick = new \Imagick();
213 213
 			if (count($checkImagick->queryFormats('SVG')) >= 1) {
214 214
 				$value = true;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 */
225 225
 	private function increaseCacheBuster() {
226 226
 		$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
227
-		$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
227
+		$this->config->setAppValue('theming', 'cachebuster', (int) $cacheBusterKey + 1);
228 228
 		$this->cacheFactory->create('theming')->clear('getScssVariables');
229 229
 	}
230 230
 
Please login to merge, or discard this patch.
lib/private/Server.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -94,7 +94,6 @@
 block discarded – undo
94 94
 use OC\Session\CryptoWrapper;
95 95
 use OC\Tagging\TagMapper;
96 96
 use OCA\Theming\ThemingDefaults;
97
-
98 97
 use OCP\App\IAppManager;
99 98
 use OCA\Theming\Util;
100 99
 use OCP\Federation\ICloudIdManager;
Please login to merge, or discard this patch.
Indentation   +1586 added lines, -1586 removed lines patch added patch discarded remove patch
@@ -117,1595 +117,1595 @@
 block discarded – undo
117 117
  * TODO: hookup all manager classes
118 118
  */
119 119
 class Server extends ServerContainer implements IServerContainer {
120
-	/** @var string */
121
-	private $webRoot;
122
-
123
-	/**
124
-	 * @param string $webRoot
125
-	 * @param \OC\Config $config
126
-	 */
127
-	public function __construct($webRoot, \OC\Config $config) {
128
-		parent::__construct();
129
-		$this->webRoot = $webRoot;
130
-
131
-		$this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
132
-		$this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
133
-
134
-		$this->registerService(\OCP\IPreview::class, function (Server $c) {
135
-			return new PreviewManager(
136
-				$c->getConfig(),
137
-				$c->getRootFolder(),
138
-				$c->getAppDataDir('preview'),
139
-				$c->getEventDispatcher(),
140
-				$c->getSession()->get('user_id')
141
-			);
142
-		});
143
-		$this->registerAlias('PreviewManager', \OCP\IPreview::class);
144
-
145
-		$this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
146
-			return new \OC\Preview\Watcher(
147
-				$c->getAppDataDir('preview')
148
-			);
149
-		});
150
-
151
-		$this->registerService('EncryptionManager', function (Server $c) {
152
-			$view = new View();
153
-			$util = new Encryption\Util(
154
-				$view,
155
-				$c->getUserManager(),
156
-				$c->getGroupManager(),
157
-				$c->getConfig()
158
-			);
159
-			return new Encryption\Manager(
160
-				$c->getConfig(),
161
-				$c->getLogger(),
162
-				$c->getL10N('core'),
163
-				new View(),
164
-				$util,
165
-				new ArrayCache()
166
-			);
167
-		});
168
-
169
-		$this->registerService('EncryptionFileHelper', function (Server $c) {
170
-			$util = new Encryption\Util(
171
-				new View(),
172
-				$c->getUserManager(),
173
-				$c->getGroupManager(),
174
-				$c->getConfig()
175
-			);
176
-			return new Encryption\File($util);
177
-		});
178
-
179
-		$this->registerService('EncryptionKeyStorage', function (Server $c) {
180
-			$view = new View();
181
-			$util = new Encryption\Util(
182
-				$view,
183
-				$c->getUserManager(),
184
-				$c->getGroupManager(),
185
-				$c->getConfig()
186
-			);
187
-
188
-			return new Encryption\Keys\Storage($view, $util);
189
-		});
190
-		$this->registerService('TagMapper', function (Server $c) {
191
-			return new TagMapper($c->getDatabaseConnection());
192
-		});
193
-
194
-		$this->registerService(\OCP\ITagManager::class, function (Server $c) {
195
-			$tagMapper = $c->query('TagMapper');
196
-			return new TagManager($tagMapper, $c->getUserSession());
197
-		});
198
-		$this->registerAlias('TagManager', \OCP\ITagManager::class);
199
-
200
-		$this->registerService('SystemTagManagerFactory', function (Server $c) {
201
-			$config = $c->getConfig();
202
-			$factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
203
-			/** @var \OC\SystemTag\ManagerFactory $factory */
204
-			$factory = new $factoryClass($this);
205
-			return $factory;
206
-		});
207
-		$this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
208
-			return $c->query('SystemTagManagerFactory')->getManager();
209
-		});
210
-		$this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
211
-
212
-		$this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
213
-			return $c->query('SystemTagManagerFactory')->getObjectMapper();
214
-		});
215
-		$this->registerService('RootFolder', function (Server $c) {
216
-			$manager = \OC\Files\Filesystem::getMountManager(null);
217
-			$view = new View();
218
-			$root = new Root(
219
-				$manager,
220
-				$view,
221
-				null,
222
-				$c->getUserMountCache(),
223
-				$this->getLogger(),
224
-				$this->getUserManager()
225
-			);
226
-			$connector = new HookConnector($root, $view);
227
-			$connector->viewToNode();
228
-
229
-			$previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
230
-			$previewConnector->connectWatcher();
231
-
232
-			return $root;
233
-		});
234
-		$this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
235
-
236
-		$this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) {
237
-			return new LazyRoot(function() use ($c) {
238
-				return $c->query('RootFolder');
239
-			});
240
-		});
241
-		$this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
242
-
243
-		$this->registerService(\OCP\IUserManager::class, function (Server $c) {
244
-			$config = $c->getConfig();
245
-			return new \OC\User\Manager($config);
246
-		});
247
-		$this->registerAlias('UserManager', \OCP\IUserManager::class);
248
-
249
-		$this->registerService(\OCP\IGroupManager::class, function (Server $c) {
250
-			$groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
251
-			$groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
252
-				\OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
253
-			});
254
-			$groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
255
-				\OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
256
-			});
257
-			$groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
258
-				\OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
259
-			});
260
-			$groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
261
-				\OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
262
-			});
263
-			$groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
264
-				\OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
265
-			});
266
-			$groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
267
-				\OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
268
-				//Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
269
-				\OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
270
-			});
271
-			return $groupManager;
272
-		});
273
-		$this->registerAlias('GroupManager', \OCP\IGroupManager::class);
274
-
275
-		$this->registerService(Store::class, function(Server $c) {
276
-			$session = $c->getSession();
277
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
278
-				$tokenProvider = $c->query('OC\Authentication\Token\IProvider');
279
-			} else {
280
-				$tokenProvider = null;
281
-			}
282
-			$logger = $c->getLogger();
283
-			return new Store($session, $logger, $tokenProvider);
284
-		});
285
-		$this->registerAlias(IStore::class, Store::class);
286
-		$this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
287
-			$dbConnection = $c->getDatabaseConnection();
288
-			return new Authentication\Token\DefaultTokenMapper($dbConnection);
289
-		});
290
-		$this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
291
-			$mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
292
-			$crypto = $c->getCrypto();
293
-			$config = $c->getConfig();
294
-			$logger = $c->getLogger();
295
-			$timeFactory = new TimeFactory();
296
-			return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
297
-		});
298
-		$this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
299
-
300
-		$this->registerService(\OCP\IUserSession::class, function (Server $c) {
301
-			$manager = $c->getUserManager();
302
-			$session = new \OC\Session\Memory('');
303
-			$timeFactory = new TimeFactory();
304
-			// Token providers might require a working database. This code
305
-			// might however be called when ownCloud is not yet setup.
306
-			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
307
-				$defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
308
-			} else {
309
-				$defaultTokenProvider = null;
310
-			}
311
-
312
-			$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom());
313
-			$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
314
-				\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
315
-			});
316
-			$userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
317
-				/** @var $user \OC\User\User */
318
-				\OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
319
-			});
320
-			$userSession->listen('\OC\User', 'preDelete', function ($user) {
321
-				/** @var $user \OC\User\User */
322
-				\OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
323
-			});
324
-			$userSession->listen('\OC\User', 'postDelete', function ($user) {
325
-				/** @var $user \OC\User\User */
326
-				\OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
327
-			});
328
-			$userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
329
-				/** @var $user \OC\User\User */
330
-				\OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
331
-			});
332
-			$userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
333
-				/** @var $user \OC\User\User */
334
-				\OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
335
-			});
336
-			$userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
337
-				\OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
338
-			});
339
-			$userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
340
-				/** @var $user \OC\User\User */
341
-				\OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
342
-			});
343
-			$userSession->listen('\OC\User', 'logout', function () {
344
-				\OC_Hook::emit('OC_User', 'logout', array());
345
-			});
346
-			$userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) {
347
-				/** @var $user \OC\User\User */
348
-				\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value));
349
-			});
350
-			return $userSession;
351
-		});
352
-		$this->registerAlias('UserSession', \OCP\IUserSession::class);
353
-
354
-		$this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
355
-			return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
356
-		});
357
-
358
-		$this->registerService(\OCP\INavigationManager::class, function (Server $c) {
359
-			return new \OC\NavigationManager($c->getAppManager(),
360
-				$c->getURLGenerator(),
361
-				$c->getL10NFactory(),
362
-				$c->getUserSession(),
363
-				$c->getGroupManager());
364
-		});
365
-		$this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
366
-
367
-		$this->registerService(\OC\AllConfig::class, function (Server $c) {
368
-			return new \OC\AllConfig(
369
-				$c->getSystemConfig()
370
-			);
371
-		});
372
-		$this->registerAlias('AllConfig', \OC\AllConfig::class);
373
-		$this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
374
-
375
-		$this->registerService('SystemConfig', function ($c) use ($config) {
376
-			return new \OC\SystemConfig($config);
377
-		});
378
-
379
-		$this->registerService(\OC\AppConfig::class, function (Server $c) {
380
-			return new \OC\AppConfig($c->getDatabaseConnection());
381
-		});
382
-		$this->registerAlias('AppConfig', \OC\AppConfig::class);
383
-		$this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
384
-
385
-		$this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
386
-			return new \OC\L10N\Factory(
387
-				$c->getConfig(),
388
-				$c->getRequest(),
389
-				$c->getUserSession(),
390
-				\OC::$SERVERROOT
391
-			);
392
-		});
393
-		$this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
394
-
395
-		$this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
396
-			$config = $c->getConfig();
397
-			$cacheFactory = $c->getMemCacheFactory();
398
-			return new \OC\URLGenerator(
399
-				$config,
400
-				$cacheFactory
401
-			);
402
-		});
403
-		$this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
404
-
405
-		$this->registerService('AppHelper', function ($c) {
406
-			return new \OC\AppHelper();
407
-		});
408
-		$this->registerService('AppFetcher', function ($c) {
409
-			return new AppFetcher(
410
-				$this->getAppDataDir('appstore'),
411
-				$this->getHTTPClientService(),
412
-				$this->query(TimeFactory::class),
413
-				$this->getConfig()
414
-			);
415
-		});
416
-		$this->registerService('CategoryFetcher', function ($c) {
417
-			return new CategoryFetcher(
418
-				$this->getAppDataDir('appstore'),
419
-				$this->getHTTPClientService(),
420
-				$this->query(TimeFactory::class),
421
-				$this->getConfig()
422
-			);
423
-		});
424
-
425
-		$this->registerService(\OCP\ICache::class, function ($c) {
426
-			return new Cache\File();
427
-		});
428
-		$this->registerAlias('UserCache', \OCP\ICache::class);
429
-
430
-		$this->registerService(Factory::class, function (Server $c) {
431
-			$config = $c->getConfig();
432
-
433
-			if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
434
-				$v = \OC_App::getAppVersions();
435
-				$v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
436
-				$version = implode(',', $v);
437
-				$instanceId = \OC_Util::getInstanceId();
438
-				$path = \OC::$SERVERROOT;
439
-				$prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT);
440
-				return new \OC\Memcache\Factory($prefix, $c->getLogger(),
441
-					$config->getSystemValue('memcache.local', null),
442
-					$config->getSystemValue('memcache.distributed', null),
443
-					$config->getSystemValue('memcache.locking', null)
444
-				);
445
-			}
446
-
447
-			return new \OC\Memcache\Factory('', $c->getLogger(),
448
-				'\\OC\\Memcache\\ArrayCache',
449
-				'\\OC\\Memcache\\ArrayCache',
450
-				'\\OC\\Memcache\\ArrayCache'
451
-			);
452
-		});
453
-		$this->registerAlias('MemCacheFactory', Factory::class);
454
-		$this->registerAlias(ICacheFactory::class, Factory::class);
455
-
456
-		$this->registerService('RedisFactory', function (Server $c) {
457
-			$systemConfig = $c->getSystemConfig();
458
-			return new RedisFactory($systemConfig);
459
-		});
460
-
461
-		$this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
462
-			return new \OC\Activity\Manager(
463
-				$c->getRequest(),
464
-				$c->getUserSession(),
465
-				$c->getConfig(),
466
-				$c->query(IValidator::class)
467
-			);
468
-		});
469
-		$this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
470
-
471
-		$this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
472
-			return new \OC\Activity\EventMerger(
473
-				$c->getL10N('lib')
474
-			);
475
-		});
476
-		$this->registerAlias(IValidator::class, Validator::class);
477
-
478
-		$this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
479
-			return new AvatarManager(
480
-				$c->getUserManager(),
481
-				$c->getAppDataDir('avatar'),
482
-				$c->getL10N('lib'),
483
-				$c->getLogger(),
484
-				$c->getConfig()
485
-			);
486
-		});
487
-		$this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
488
-
489
-		$this->registerService(\OCP\ILogger::class, function (Server $c) {
490
-			$logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
491
-			$logger = Log::getLogClass($logType);
492
-			call_user_func(array($logger, 'init'));
493
-
494
-			return new Log($logger);
495
-		});
496
-		$this->registerAlias('Logger', \OCP\ILogger::class);
497
-
498
-		$this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
499
-			$config = $c->getConfig();
500
-			return new \OC\BackgroundJob\JobList(
501
-				$c->getDatabaseConnection(),
502
-				$config,
503
-				new TimeFactory()
504
-			);
505
-		});
506
-		$this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
507
-
508
-		$this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
509
-			$cacheFactory = $c->getMemCacheFactory();
510
-			$logger = $c->getLogger();
511
-			if ($cacheFactory->isAvailable()) {
512
-				$router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
513
-			} else {
514
-				$router = new \OC\Route\Router($logger);
515
-			}
516
-			return $router;
517
-		});
518
-		$this->registerAlias('Router', \OCP\Route\IRouter::class);
519
-
520
-		$this->registerService(\OCP\ISearch::class, function ($c) {
521
-			return new Search();
522
-		});
523
-		$this->registerAlias('Search', \OCP\ISearch::class);
524
-
525
-		$this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
526
-			return new SecureRandom();
527
-		});
528
-		$this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
529
-
530
-		$this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
531
-			return new Crypto($c->getConfig(), $c->getSecureRandom());
532
-		});
533
-		$this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
534
-
535
-		$this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
536
-			return new Hasher($c->getConfig());
537
-		});
538
-		$this->registerAlias('Hasher', \OCP\Security\IHasher::class);
539
-
540
-		$this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
541
-			return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
542
-		});
543
-		$this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
544
-
545
-		$this->registerService(IDBConnection::class, function (Server $c) {
546
-			$systemConfig = $c->getSystemConfig();
547
-			$factory = new \OC\DB\ConnectionFactory($systemConfig);
548
-			$type = $systemConfig->getValue('dbtype', 'sqlite');
549
-			if (!$factory->isValidType($type)) {
550
-				throw new \OC\DatabaseException('Invalid database type');
551
-			}
552
-			$connectionParams = $factory->createConnectionParams();
553
-			$connection = $factory->getConnection($type, $connectionParams);
554
-			$connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
555
-			return $connection;
556
-		});
557
-		$this->registerAlias('DatabaseConnection', IDBConnection::class);
558
-
559
-		$this->registerService('HTTPHelper', function (Server $c) {
560
-			$config = $c->getConfig();
561
-			return new HTTPHelper(
562
-				$config,
563
-				$c->getHTTPClientService()
564
-			);
565
-		});
566
-
567
-		$this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
568
-			$user = \OC_User::getUser();
569
-			$uid = $user ? $user : null;
570
-			return new ClientService(
571
-				$c->getConfig(),
572
-				new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger())
573
-			);
574
-		});
575
-		$this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
576
-
577
-		$this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
578
-			if ($c->getSystemConfig()->getValue('debug', false)) {
579
-				return new EventLogger();
580
-			} else {
581
-				return new NullEventLogger();
582
-			}
583
-		});
584
-		$this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
585
-
586
-		$this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
587
-			if ($c->getSystemConfig()->getValue('debug', false)) {
588
-				return new QueryLogger();
589
-			} else {
590
-				return new NullQueryLogger();
591
-			}
592
-		});
593
-		$this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
594
-
595
-		$this->registerService(TempManager::class, function (Server $c) {
596
-			return new TempManager(
597
-				$c->getLogger(),
598
-				$c->getConfig()
599
-			);
600
-		});
601
-		$this->registerAlias('TempManager', TempManager::class);
602
-		$this->registerAlias(ITempManager::class, TempManager::class);
603
-
604
-		$this->registerService(AppManager::class, function (Server $c) {
605
-			return new \OC\App\AppManager(
606
-				$c->getUserSession(),
607
-				$c->getAppConfig(),
608
-				$c->getGroupManager(),
609
-				$c->getMemCacheFactory(),
610
-				$c->getEventDispatcher()
611
-			);
612
-		});
613
-		$this->registerAlias('AppManager', AppManager::class);
614
-		$this->registerAlias(IAppManager::class, AppManager::class);
615
-
616
-		$this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
617
-			return new DateTimeZone(
618
-				$c->getConfig(),
619
-				$c->getSession()
620
-			);
621
-		});
622
-		$this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
623
-
624
-		$this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
625
-			$language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
626
-
627
-			return new DateTimeFormatter(
628
-				$c->getDateTimeZone()->getTimeZone(),
629
-				$c->getL10N('lib', $language)
630
-			);
631
-		});
632
-		$this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
633
-
634
-		$this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
635
-			$mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
636
-			$listener = new UserMountCacheListener($mountCache);
637
-			$listener->listen($c->getUserManager());
638
-			return $mountCache;
639
-		});
640
-		$this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
641
-
642
-		$this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
643
-			$loader = \OC\Files\Filesystem::getLoader();
644
-			$mountCache = $c->query('UserMountCache');
645
-			$manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
646
-
647
-			// builtin providers
648
-
649
-			$config = $c->getConfig();
650
-			$manager->registerProvider(new CacheMountProvider($config));
651
-			$manager->registerHomeProvider(new LocalHomeMountProvider());
652
-			$manager->registerHomeProvider(new ObjectHomeMountProvider($config));
653
-
654
-			return $manager;
655
-		});
656
-		$this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
657
-
658
-		$this->registerService('IniWrapper', function ($c) {
659
-			return new IniGetWrapper();
660
-		});
661
-		$this->registerService('AsyncCommandBus', function (Server $c) {
662
-			$jobList = $c->getJobList();
663
-			return new AsyncBus($jobList);
664
-		});
665
-		$this->registerService('TrustedDomainHelper', function ($c) {
666
-			return new TrustedDomainHelper($this->getConfig());
667
-		});
668
-		$this->registerService('Throttler', function(Server $c) {
669
-			return new Throttler(
670
-				$c->getDatabaseConnection(),
671
-				new TimeFactory(),
672
-				$c->getLogger(),
673
-				$c->getConfig()
674
-			);
675
-		});
676
-		$this->registerService('IntegrityCodeChecker', function (Server $c) {
677
-			// IConfig and IAppManager requires a working database. This code
678
-			// might however be called when ownCloud is not yet setup.
679
-			if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
680
-				$config = $c->getConfig();
681
-				$appManager = $c->getAppManager();
682
-			} else {
683
-				$config = null;
684
-				$appManager = null;
685
-			}
686
-
687
-			return new Checker(
688
-					new EnvironmentHelper(),
689
-					new FileAccessHelper(),
690
-					new AppLocator(),
691
-					$config,
692
-					$c->getMemCacheFactory(),
693
-					$appManager,
694
-					$c->getTempManager()
695
-			);
696
-		});
697
-		$this->registerService(\OCP\IRequest::class, function ($c) {
698
-			if (isset($this['urlParams'])) {
699
-				$urlParams = $this['urlParams'];
700
-			} else {
701
-				$urlParams = [];
702
-			}
703
-
704
-			if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
705
-				&& in_array('fakeinput', stream_get_wrappers())
706
-			) {
707
-				$stream = 'fakeinput://data';
708
-			} else {
709
-				$stream = 'php://input';
710
-			}
711
-
712
-			return new Request(
713
-				[
714
-					'get' => $_GET,
715
-					'post' => $_POST,
716
-					'files' => $_FILES,
717
-					'server' => $_SERVER,
718
-					'env' => $_ENV,
719
-					'cookies' => $_COOKIE,
720
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
721
-						? $_SERVER['REQUEST_METHOD']
722
-						: null,
723
-					'urlParams' => $urlParams,
724
-				],
725
-				$this->getSecureRandom(),
726
-				$this->getConfig(),
727
-				$this->getCsrfTokenManager(),
728
-				$stream
729
-			);
730
-		});
731
-		$this->registerAlias('Request', \OCP\IRequest::class);
732
-
733
-		$this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
734
-			return new Mailer(
735
-				$c->getConfig(),
736
-				$c->getLogger(),
737
-				$c->getThemingDefaults()
738
-			);
739
-		});
740
-		$this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
741
-
742
-		$this->registerService('LDAPProvider', function(Server $c) {
743
-			$config = $c->getConfig();
744
-			$factoryClass = $config->getSystemValue('ldapProviderFactory', null);
745
-			if(is_null($factoryClass)) {
746
-				throw new \Exception('ldapProviderFactory not set');
747
-			}
748
-			/** @var \OCP\LDAP\ILDAPProviderFactory $factory */
749
-			$factory = new $factoryClass($this);
750
-			return $factory->getLDAPProvider();
751
-		});
752
-		$this->registerService('LockingProvider', function (Server $c) {
753
-			$ini = $c->getIniWrapper();
754
-			$config = $c->getConfig();
755
-			$ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
756
-			if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
757
-				/** @var \OC\Memcache\Factory $memcacheFactory */
758
-				$memcacheFactory = $c->getMemCacheFactory();
759
-				$memcache = $memcacheFactory->createLocking('lock');
760
-				if (!($memcache instanceof \OC\Memcache\NullCache)) {
761
-					return new MemcacheLockingProvider($memcache, $ttl);
762
-				}
763
-				return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
764
-			}
765
-			return new NoopLockingProvider();
766
-		});
767
-
768
-		$this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
769
-			return new \OC\Files\Mount\Manager();
770
-		});
771
-		$this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
772
-
773
-		$this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
774
-			return new \OC\Files\Type\Detection(
775
-				$c->getURLGenerator(),
776
-				\OC::$configDir,
777
-				\OC::$SERVERROOT . '/resources/config/'
778
-			);
779
-		});
780
-		$this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
781
-
782
-		$this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
783
-			return new \OC\Files\Type\Loader(
784
-				$c->getDatabaseConnection()
785
-			);
786
-		});
787
-		$this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
788
-
789
-		$this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
790
-			return new Manager(
791
-				$c->query(IValidator::class)
792
-			);
793
-		});
794
-		$this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
795
-
796
-		$this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
797
-			$manager = new \OC\CapabilitiesManager($c->getLogger());
798
-			$manager->registerCapability(function () use ($c) {
799
-				return new \OC\OCS\CoreCapabilities($c->getConfig());
800
-			});
801
-			return $manager;
802
-		});
803
-		$this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
804
-
805
-		$this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) {
806
-			$config = $c->getConfig();
807
-			$factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
808
-			/** @var \OCP\Comments\ICommentsManagerFactory $factory */
809
-			$factory = new $factoryClass($this);
810
-			return $factory->getManager();
811
-		});
812
-		$this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
813
-
814
-		$this->registerService('ThemingDefaults', function(Server $c) {
815
-			/*
120
+    /** @var string */
121
+    private $webRoot;
122
+
123
+    /**
124
+     * @param string $webRoot
125
+     * @param \OC\Config $config
126
+     */
127
+    public function __construct($webRoot, \OC\Config $config) {
128
+        parent::__construct();
129
+        $this->webRoot = $webRoot;
130
+
131
+        $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
132
+        $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class);
133
+
134
+        $this->registerService(\OCP\IPreview::class, function (Server $c) {
135
+            return new PreviewManager(
136
+                $c->getConfig(),
137
+                $c->getRootFolder(),
138
+                $c->getAppDataDir('preview'),
139
+                $c->getEventDispatcher(),
140
+                $c->getSession()->get('user_id')
141
+            );
142
+        });
143
+        $this->registerAlias('PreviewManager', \OCP\IPreview::class);
144
+
145
+        $this->registerService(\OC\Preview\Watcher::class, function (Server $c) {
146
+            return new \OC\Preview\Watcher(
147
+                $c->getAppDataDir('preview')
148
+            );
149
+        });
150
+
151
+        $this->registerService('EncryptionManager', function (Server $c) {
152
+            $view = new View();
153
+            $util = new Encryption\Util(
154
+                $view,
155
+                $c->getUserManager(),
156
+                $c->getGroupManager(),
157
+                $c->getConfig()
158
+            );
159
+            return new Encryption\Manager(
160
+                $c->getConfig(),
161
+                $c->getLogger(),
162
+                $c->getL10N('core'),
163
+                new View(),
164
+                $util,
165
+                new ArrayCache()
166
+            );
167
+        });
168
+
169
+        $this->registerService('EncryptionFileHelper', function (Server $c) {
170
+            $util = new Encryption\Util(
171
+                new View(),
172
+                $c->getUserManager(),
173
+                $c->getGroupManager(),
174
+                $c->getConfig()
175
+            );
176
+            return new Encryption\File($util);
177
+        });
178
+
179
+        $this->registerService('EncryptionKeyStorage', function (Server $c) {
180
+            $view = new View();
181
+            $util = new Encryption\Util(
182
+                $view,
183
+                $c->getUserManager(),
184
+                $c->getGroupManager(),
185
+                $c->getConfig()
186
+            );
187
+
188
+            return new Encryption\Keys\Storage($view, $util);
189
+        });
190
+        $this->registerService('TagMapper', function (Server $c) {
191
+            return new TagMapper($c->getDatabaseConnection());
192
+        });
193
+
194
+        $this->registerService(\OCP\ITagManager::class, function (Server $c) {
195
+            $tagMapper = $c->query('TagMapper');
196
+            return new TagManager($tagMapper, $c->getUserSession());
197
+        });
198
+        $this->registerAlias('TagManager', \OCP\ITagManager::class);
199
+
200
+        $this->registerService('SystemTagManagerFactory', function (Server $c) {
201
+            $config = $c->getConfig();
202
+            $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory');
203
+            /** @var \OC\SystemTag\ManagerFactory $factory */
204
+            $factory = new $factoryClass($this);
205
+            return $factory;
206
+        });
207
+        $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) {
208
+            return $c->query('SystemTagManagerFactory')->getManager();
209
+        });
210
+        $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class);
211
+
212
+        $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) {
213
+            return $c->query('SystemTagManagerFactory')->getObjectMapper();
214
+        });
215
+        $this->registerService('RootFolder', function (Server $c) {
216
+            $manager = \OC\Files\Filesystem::getMountManager(null);
217
+            $view = new View();
218
+            $root = new Root(
219
+                $manager,
220
+                $view,
221
+                null,
222
+                $c->getUserMountCache(),
223
+                $this->getLogger(),
224
+                $this->getUserManager()
225
+            );
226
+            $connector = new HookConnector($root, $view);
227
+            $connector->viewToNode();
228
+
229
+            $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig());
230
+            $previewConnector->connectWatcher();
231
+
232
+            return $root;
233
+        });
234
+        $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class);
235
+
236
+        $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) {
237
+            return new LazyRoot(function() use ($c) {
238
+                return $c->query('RootFolder');
239
+            });
240
+        });
241
+        $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class);
242
+
243
+        $this->registerService(\OCP\IUserManager::class, function (Server $c) {
244
+            $config = $c->getConfig();
245
+            return new \OC\User\Manager($config);
246
+        });
247
+        $this->registerAlias('UserManager', \OCP\IUserManager::class);
248
+
249
+        $this->registerService(\OCP\IGroupManager::class, function (Server $c) {
250
+            $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger());
251
+            $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
252
+                \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid));
253
+            });
254
+            $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) {
255
+                \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID()));
256
+            });
257
+            $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
258
+                \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID()));
259
+            });
260
+            $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
261
+                \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID()));
262
+            });
263
+            $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
264
+                \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID()));
265
+            });
266
+            $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
267
+                \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
268
+                //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks
269
+                \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID()));
270
+            });
271
+            return $groupManager;
272
+        });
273
+        $this->registerAlias('GroupManager', \OCP\IGroupManager::class);
274
+
275
+        $this->registerService(Store::class, function(Server $c) {
276
+            $session = $c->getSession();
277
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
278
+                $tokenProvider = $c->query('OC\Authentication\Token\IProvider');
279
+            } else {
280
+                $tokenProvider = null;
281
+            }
282
+            $logger = $c->getLogger();
283
+            return new Store($session, $logger, $tokenProvider);
284
+        });
285
+        $this->registerAlias(IStore::class, Store::class);
286
+        $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) {
287
+            $dbConnection = $c->getDatabaseConnection();
288
+            return new Authentication\Token\DefaultTokenMapper($dbConnection);
289
+        });
290
+        $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) {
291
+            $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper');
292
+            $crypto = $c->getCrypto();
293
+            $config = $c->getConfig();
294
+            $logger = $c->getLogger();
295
+            $timeFactory = new TimeFactory();
296
+            return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory);
297
+        });
298
+        $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider');
299
+
300
+        $this->registerService(\OCP\IUserSession::class, function (Server $c) {
301
+            $manager = $c->getUserManager();
302
+            $session = new \OC\Session\Memory('');
303
+            $timeFactory = new TimeFactory();
304
+            // Token providers might require a working database. This code
305
+            // might however be called when ownCloud is not yet setup.
306
+            if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
307
+                $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider');
308
+            } else {
309
+                $defaultTokenProvider = null;
310
+            }
311
+
312
+            $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom());
313
+            $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
314
+                \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
315
+            });
316
+            $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
317
+                /** @var $user \OC\User\User */
318
+                \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password));
319
+            });
320
+            $userSession->listen('\OC\User', 'preDelete', function ($user) {
321
+                /** @var $user \OC\User\User */
322
+                \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID()));
323
+            });
324
+            $userSession->listen('\OC\User', 'postDelete', function ($user) {
325
+                /** @var $user \OC\User\User */
326
+                \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID()));
327
+            });
328
+            $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
329
+                /** @var $user \OC\User\User */
330
+                \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
331
+            });
332
+            $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
333
+                /** @var $user \OC\User\User */
334
+                \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword));
335
+            });
336
+            $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
337
+                \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password));
338
+            });
339
+            $userSession->listen('\OC\User', 'postLogin', function ($user, $password) {
340
+                /** @var $user \OC\User\User */
341
+                \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password));
342
+            });
343
+            $userSession->listen('\OC\User', 'logout', function () {
344
+                \OC_Hook::emit('OC_User', 'logout', array());
345
+            });
346
+            $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) {
347
+                /** @var $user \OC\User\User */
348
+                \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value));
349
+            });
350
+            return $userSession;
351
+        });
352
+        $this->registerAlias('UserSession', \OCP\IUserSession::class);
353
+
354
+        $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) {
355
+            return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger());
356
+        });
357
+
358
+        $this->registerService(\OCP\INavigationManager::class, function (Server $c) {
359
+            return new \OC\NavigationManager($c->getAppManager(),
360
+                $c->getURLGenerator(),
361
+                $c->getL10NFactory(),
362
+                $c->getUserSession(),
363
+                $c->getGroupManager());
364
+        });
365
+        $this->registerAlias('NavigationManager', \OCP\INavigationManager::class);
366
+
367
+        $this->registerService(\OC\AllConfig::class, function (Server $c) {
368
+            return new \OC\AllConfig(
369
+                $c->getSystemConfig()
370
+            );
371
+        });
372
+        $this->registerAlias('AllConfig', \OC\AllConfig::class);
373
+        $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
374
+
375
+        $this->registerService('SystemConfig', function ($c) use ($config) {
376
+            return new \OC\SystemConfig($config);
377
+        });
378
+
379
+        $this->registerService(\OC\AppConfig::class, function (Server $c) {
380
+            return new \OC\AppConfig($c->getDatabaseConnection());
381
+        });
382
+        $this->registerAlias('AppConfig', \OC\AppConfig::class);
383
+        $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class);
384
+
385
+        $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) {
386
+            return new \OC\L10N\Factory(
387
+                $c->getConfig(),
388
+                $c->getRequest(),
389
+                $c->getUserSession(),
390
+                \OC::$SERVERROOT
391
+            );
392
+        });
393
+        $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class);
394
+
395
+        $this->registerService(\OCP\IURLGenerator::class, function (Server $c) {
396
+            $config = $c->getConfig();
397
+            $cacheFactory = $c->getMemCacheFactory();
398
+            return new \OC\URLGenerator(
399
+                $config,
400
+                $cacheFactory
401
+            );
402
+        });
403
+        $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class);
404
+
405
+        $this->registerService('AppHelper', function ($c) {
406
+            return new \OC\AppHelper();
407
+        });
408
+        $this->registerService('AppFetcher', function ($c) {
409
+            return new AppFetcher(
410
+                $this->getAppDataDir('appstore'),
411
+                $this->getHTTPClientService(),
412
+                $this->query(TimeFactory::class),
413
+                $this->getConfig()
414
+            );
415
+        });
416
+        $this->registerService('CategoryFetcher', function ($c) {
417
+            return new CategoryFetcher(
418
+                $this->getAppDataDir('appstore'),
419
+                $this->getHTTPClientService(),
420
+                $this->query(TimeFactory::class),
421
+                $this->getConfig()
422
+            );
423
+        });
424
+
425
+        $this->registerService(\OCP\ICache::class, function ($c) {
426
+            return new Cache\File();
427
+        });
428
+        $this->registerAlias('UserCache', \OCP\ICache::class);
429
+
430
+        $this->registerService(Factory::class, function (Server $c) {
431
+            $config = $c->getConfig();
432
+
433
+            if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
434
+                $v = \OC_App::getAppVersions();
435
+                $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php'));
436
+                $version = implode(',', $v);
437
+                $instanceId = \OC_Util::getInstanceId();
438
+                $path = \OC::$SERVERROOT;
439
+                $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT);
440
+                return new \OC\Memcache\Factory($prefix, $c->getLogger(),
441
+                    $config->getSystemValue('memcache.local', null),
442
+                    $config->getSystemValue('memcache.distributed', null),
443
+                    $config->getSystemValue('memcache.locking', null)
444
+                );
445
+            }
446
+
447
+            return new \OC\Memcache\Factory('', $c->getLogger(),
448
+                '\\OC\\Memcache\\ArrayCache',
449
+                '\\OC\\Memcache\\ArrayCache',
450
+                '\\OC\\Memcache\\ArrayCache'
451
+            );
452
+        });
453
+        $this->registerAlias('MemCacheFactory', Factory::class);
454
+        $this->registerAlias(ICacheFactory::class, Factory::class);
455
+
456
+        $this->registerService('RedisFactory', function (Server $c) {
457
+            $systemConfig = $c->getSystemConfig();
458
+            return new RedisFactory($systemConfig);
459
+        });
460
+
461
+        $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
462
+            return new \OC\Activity\Manager(
463
+                $c->getRequest(),
464
+                $c->getUserSession(),
465
+                $c->getConfig(),
466
+                $c->query(IValidator::class)
467
+            );
468
+        });
469
+        $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class);
470
+
471
+        $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
472
+            return new \OC\Activity\EventMerger(
473
+                $c->getL10N('lib')
474
+            );
475
+        });
476
+        $this->registerAlias(IValidator::class, Validator::class);
477
+
478
+        $this->registerService(\OCP\IAvatarManager::class, function (Server $c) {
479
+            return new AvatarManager(
480
+                $c->getUserManager(),
481
+                $c->getAppDataDir('avatar'),
482
+                $c->getL10N('lib'),
483
+                $c->getLogger(),
484
+                $c->getConfig()
485
+            );
486
+        });
487
+        $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class);
488
+
489
+        $this->registerService(\OCP\ILogger::class, function (Server $c) {
490
+            $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file');
491
+            $logger = Log::getLogClass($logType);
492
+            call_user_func(array($logger, 'init'));
493
+
494
+            return new Log($logger);
495
+        });
496
+        $this->registerAlias('Logger', \OCP\ILogger::class);
497
+
498
+        $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) {
499
+            $config = $c->getConfig();
500
+            return new \OC\BackgroundJob\JobList(
501
+                $c->getDatabaseConnection(),
502
+                $config,
503
+                new TimeFactory()
504
+            );
505
+        });
506
+        $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class);
507
+
508
+        $this->registerService(\OCP\Route\IRouter::class, function (Server $c) {
509
+            $cacheFactory = $c->getMemCacheFactory();
510
+            $logger = $c->getLogger();
511
+            if ($cacheFactory->isAvailable()) {
512
+                $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger);
513
+            } else {
514
+                $router = new \OC\Route\Router($logger);
515
+            }
516
+            return $router;
517
+        });
518
+        $this->registerAlias('Router', \OCP\Route\IRouter::class);
519
+
520
+        $this->registerService(\OCP\ISearch::class, function ($c) {
521
+            return new Search();
522
+        });
523
+        $this->registerAlias('Search', \OCP\ISearch::class);
524
+
525
+        $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) {
526
+            return new SecureRandom();
527
+        });
528
+        $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
529
+
530
+        $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) {
531
+            return new Crypto($c->getConfig(), $c->getSecureRandom());
532
+        });
533
+        $this->registerAlias('Crypto', \OCP\Security\ICrypto::class);
534
+
535
+        $this->registerService(\OCP\Security\IHasher::class, function (Server $c) {
536
+            return new Hasher($c->getConfig());
537
+        });
538
+        $this->registerAlias('Hasher', \OCP\Security\IHasher::class);
539
+
540
+        $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) {
541
+            return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection());
542
+        });
543
+        $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class);
544
+
545
+        $this->registerService(IDBConnection::class, function (Server $c) {
546
+            $systemConfig = $c->getSystemConfig();
547
+            $factory = new \OC\DB\ConnectionFactory($systemConfig);
548
+            $type = $systemConfig->getValue('dbtype', 'sqlite');
549
+            if (!$factory->isValidType($type)) {
550
+                throw new \OC\DatabaseException('Invalid database type');
551
+            }
552
+            $connectionParams = $factory->createConnectionParams();
553
+            $connection = $factory->getConnection($type, $connectionParams);
554
+            $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
555
+            return $connection;
556
+        });
557
+        $this->registerAlias('DatabaseConnection', IDBConnection::class);
558
+
559
+        $this->registerService('HTTPHelper', function (Server $c) {
560
+            $config = $c->getConfig();
561
+            return new HTTPHelper(
562
+                $config,
563
+                $c->getHTTPClientService()
564
+            );
565
+        });
566
+
567
+        $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) {
568
+            $user = \OC_User::getUser();
569
+            $uid = $user ? $user : null;
570
+            return new ClientService(
571
+                $c->getConfig(),
572
+                new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger())
573
+            );
574
+        });
575
+        $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class);
576
+
577
+        $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) {
578
+            if ($c->getSystemConfig()->getValue('debug', false)) {
579
+                return new EventLogger();
580
+            } else {
581
+                return new NullEventLogger();
582
+            }
583
+        });
584
+        $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class);
585
+
586
+        $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) {
587
+            if ($c->getSystemConfig()->getValue('debug', false)) {
588
+                return new QueryLogger();
589
+            } else {
590
+                return new NullQueryLogger();
591
+            }
592
+        });
593
+        $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class);
594
+
595
+        $this->registerService(TempManager::class, function (Server $c) {
596
+            return new TempManager(
597
+                $c->getLogger(),
598
+                $c->getConfig()
599
+            );
600
+        });
601
+        $this->registerAlias('TempManager', TempManager::class);
602
+        $this->registerAlias(ITempManager::class, TempManager::class);
603
+
604
+        $this->registerService(AppManager::class, function (Server $c) {
605
+            return new \OC\App\AppManager(
606
+                $c->getUserSession(),
607
+                $c->getAppConfig(),
608
+                $c->getGroupManager(),
609
+                $c->getMemCacheFactory(),
610
+                $c->getEventDispatcher()
611
+            );
612
+        });
613
+        $this->registerAlias('AppManager', AppManager::class);
614
+        $this->registerAlias(IAppManager::class, AppManager::class);
615
+
616
+        $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) {
617
+            return new DateTimeZone(
618
+                $c->getConfig(),
619
+                $c->getSession()
620
+            );
621
+        });
622
+        $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class);
623
+
624
+        $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) {
625
+            $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null);
626
+
627
+            return new DateTimeFormatter(
628
+                $c->getDateTimeZone()->getTimeZone(),
629
+                $c->getL10N('lib', $language)
630
+            );
631
+        });
632
+        $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class);
633
+
634
+        $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) {
635
+            $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger());
636
+            $listener = new UserMountCacheListener($mountCache);
637
+            $listener->listen($c->getUserManager());
638
+            return $mountCache;
639
+        });
640
+        $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class);
641
+
642
+        $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) {
643
+            $loader = \OC\Files\Filesystem::getLoader();
644
+            $mountCache = $c->query('UserMountCache');
645
+            $manager =  new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
646
+
647
+            // builtin providers
648
+
649
+            $config = $c->getConfig();
650
+            $manager->registerProvider(new CacheMountProvider($config));
651
+            $manager->registerHomeProvider(new LocalHomeMountProvider());
652
+            $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
653
+
654
+            return $manager;
655
+        });
656
+        $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class);
657
+
658
+        $this->registerService('IniWrapper', function ($c) {
659
+            return new IniGetWrapper();
660
+        });
661
+        $this->registerService('AsyncCommandBus', function (Server $c) {
662
+            $jobList = $c->getJobList();
663
+            return new AsyncBus($jobList);
664
+        });
665
+        $this->registerService('TrustedDomainHelper', function ($c) {
666
+            return new TrustedDomainHelper($this->getConfig());
667
+        });
668
+        $this->registerService('Throttler', function(Server $c) {
669
+            return new Throttler(
670
+                $c->getDatabaseConnection(),
671
+                new TimeFactory(),
672
+                $c->getLogger(),
673
+                $c->getConfig()
674
+            );
675
+        });
676
+        $this->registerService('IntegrityCodeChecker', function (Server $c) {
677
+            // IConfig and IAppManager requires a working database. This code
678
+            // might however be called when ownCloud is not yet setup.
679
+            if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
680
+                $config = $c->getConfig();
681
+                $appManager = $c->getAppManager();
682
+            } else {
683
+                $config = null;
684
+                $appManager = null;
685
+            }
686
+
687
+            return new Checker(
688
+                    new EnvironmentHelper(),
689
+                    new FileAccessHelper(),
690
+                    new AppLocator(),
691
+                    $config,
692
+                    $c->getMemCacheFactory(),
693
+                    $appManager,
694
+                    $c->getTempManager()
695
+            );
696
+        });
697
+        $this->registerService(\OCP\IRequest::class, function ($c) {
698
+            if (isset($this['urlParams'])) {
699
+                $urlParams = $this['urlParams'];
700
+            } else {
701
+                $urlParams = [];
702
+            }
703
+
704
+            if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
705
+                && in_array('fakeinput', stream_get_wrappers())
706
+            ) {
707
+                $stream = 'fakeinput://data';
708
+            } else {
709
+                $stream = 'php://input';
710
+            }
711
+
712
+            return new Request(
713
+                [
714
+                    'get' => $_GET,
715
+                    'post' => $_POST,
716
+                    'files' => $_FILES,
717
+                    'server' => $_SERVER,
718
+                    'env' => $_ENV,
719
+                    'cookies' => $_COOKIE,
720
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
721
+                        ? $_SERVER['REQUEST_METHOD']
722
+                        : null,
723
+                    'urlParams' => $urlParams,
724
+                ],
725
+                $this->getSecureRandom(),
726
+                $this->getConfig(),
727
+                $this->getCsrfTokenManager(),
728
+                $stream
729
+            );
730
+        });
731
+        $this->registerAlias('Request', \OCP\IRequest::class);
732
+
733
+        $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) {
734
+            return new Mailer(
735
+                $c->getConfig(),
736
+                $c->getLogger(),
737
+                $c->getThemingDefaults()
738
+            );
739
+        });
740
+        $this->registerAlias('Mailer', \OCP\Mail\IMailer::class);
741
+
742
+        $this->registerService('LDAPProvider', function(Server $c) {
743
+            $config = $c->getConfig();
744
+            $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
745
+            if(is_null($factoryClass)) {
746
+                throw new \Exception('ldapProviderFactory not set');
747
+            }
748
+            /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
749
+            $factory = new $factoryClass($this);
750
+            return $factory->getLDAPProvider();
751
+        });
752
+        $this->registerService('LockingProvider', function (Server $c) {
753
+            $ini = $c->getIniWrapper();
754
+            $config = $c->getConfig();
755
+            $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
756
+            if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
757
+                /** @var \OC\Memcache\Factory $memcacheFactory */
758
+                $memcacheFactory = $c->getMemCacheFactory();
759
+                $memcache = $memcacheFactory->createLocking('lock');
760
+                if (!($memcache instanceof \OC\Memcache\NullCache)) {
761
+                    return new MemcacheLockingProvider($memcache, $ttl);
762
+                }
763
+                return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl);
764
+            }
765
+            return new NoopLockingProvider();
766
+        });
767
+
768
+        $this->registerService(\OCP\Files\Mount\IMountManager::class, function () {
769
+            return new \OC\Files\Mount\Manager();
770
+        });
771
+        $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class);
772
+
773
+        $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) {
774
+            return new \OC\Files\Type\Detection(
775
+                $c->getURLGenerator(),
776
+                \OC::$configDir,
777
+                \OC::$SERVERROOT . '/resources/config/'
778
+            );
779
+        });
780
+        $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class);
781
+
782
+        $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) {
783
+            return new \OC\Files\Type\Loader(
784
+                $c->getDatabaseConnection()
785
+            );
786
+        });
787
+        $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class);
788
+
789
+        $this->registerService(\OCP\Notification\IManager::class, function (Server $c) {
790
+            return new Manager(
791
+                $c->query(IValidator::class)
792
+            );
793
+        });
794
+        $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class);
795
+
796
+        $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) {
797
+            $manager = new \OC\CapabilitiesManager($c->getLogger());
798
+            $manager->registerCapability(function () use ($c) {
799
+                return new \OC\OCS\CoreCapabilities($c->getConfig());
800
+            });
801
+            return $manager;
802
+        });
803
+        $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class);
804
+
805
+        $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) {
806
+            $config = $c->getConfig();
807
+            $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
808
+            /** @var \OCP\Comments\ICommentsManagerFactory $factory */
809
+            $factory = new $factoryClass($this);
810
+            return $factory->getManager();
811
+        });
812
+        $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);
813
+
814
+        $this->registerService('ThemingDefaults', function(Server $c) {
815
+            /*
816 816
 			 * Dark magic for autoloader.
817 817
 			 * If we do a class_exists it will try to load the class which will
818 818
 			 * make composer cache the result. Resulting in errors when enabling
819 819
 			 * the theming app.
820 820
 			 */
821
-			$prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
822
-			if (isset($prefixes['OCA\\Theming\\'])) {
823
-				$classExists = true;
824
-			} else {
825
-				$classExists = false;
826
-			}
827
-
828
-			if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) {
829
-				return new ThemingDefaults(
830
-					$c->getConfig(),
831
-					$c->getL10N('theming'),
832
-					$c->getURLGenerator(),
833
-					new \OC_Defaults(),
834
-					$c->getAppDataDir('theming'),
835
-					$c->getMemCacheFactory(),
836
-					new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager())
837
-				);
838
-			}
839
-			return new \OC_Defaults();
840
-		});
841
-		$this->registerService(EventDispatcher::class, function () {
842
-			return new EventDispatcher();
843
-		});
844
-		$this->registerAlias('EventDispatcher', EventDispatcher::class);
845
-		$this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
846
-
847
-		$this->registerService('CryptoWrapper', function (Server $c) {
848
-			// FIXME: Instantiiated here due to cyclic dependency
849
-			$request = new Request(
850
-				[
851
-					'get' => $_GET,
852
-					'post' => $_POST,
853
-					'files' => $_FILES,
854
-					'server' => $_SERVER,
855
-					'env' => $_ENV,
856
-					'cookies' => $_COOKIE,
857
-					'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
858
-						? $_SERVER['REQUEST_METHOD']
859
-						: null,
860
-				],
861
-				$c->getSecureRandom(),
862
-				$c->getConfig()
863
-			);
864
-
865
-			return new CryptoWrapper(
866
-				$c->getConfig(),
867
-				$c->getCrypto(),
868
-				$c->getSecureRandom(),
869
-				$request
870
-			);
871
-		});
872
-		$this->registerService('CsrfTokenManager', function (Server $c) {
873
-			$tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
874
-
875
-			return new CsrfTokenManager(
876
-				$tokenGenerator,
877
-				$c->query(SessionStorage::class)
878
-			);
879
-		});
880
-		$this->registerService(SessionStorage::class, function (Server $c) {
881
-			return new SessionStorage($c->getSession());
882
-		});
883
-		$this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
884
-			return new ContentSecurityPolicyManager();
885
-		});
886
-		$this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
887
-
888
-		$this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
889
-			return new ContentSecurityPolicyNonceManager(
890
-				$c->getCsrfTokenManager(),
891
-				$c->getRequest()
892
-			);
893
-		});
894
-
895
-		$this->registerService(\OCP\Share\IManager::class, function(Server $c) {
896
-			$config = $c->getConfig();
897
-			$factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
898
-			/** @var \OCP\Share\IProviderFactory $factory */
899
-			$factory = new $factoryClass($this);
900
-
901
-			$manager = new \OC\Share20\Manager(
902
-				$c->getLogger(),
903
-				$c->getConfig(),
904
-				$c->getSecureRandom(),
905
-				$c->getHasher(),
906
-				$c->getMountManager(),
907
-				$c->getGroupManager(),
908
-				$c->getL10N('core'),
909
-				$factory,
910
-				$c->getUserManager(),
911
-				$c->getLazyRootFolder(),
912
-				$c->getEventDispatcher()
913
-			);
914
-
915
-			return $manager;
916
-		});
917
-		$this->registerAlias('ShareManager', \OCP\Share\IManager::class);
918
-
919
-		$this->registerService('SettingsManager', function(Server $c) {
920
-			$manager = new \OC\Settings\Manager(
921
-				$c->getLogger(),
922
-				$c->getDatabaseConnection(),
923
-				$c->getL10N('lib'),
924
-				$c->getConfig(),
925
-				$c->getEncryptionManager(),
926
-				$c->getUserManager(),
927
-				$c->getLockingProvider(),
928
-				$c->getRequest(),
929
-				new \OC\Settings\Mapper($c->getDatabaseConnection()),
930
-				$c->getURLGenerator()
931
-			);
932
-			return $manager;
933
-		});
934
-		$this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
935
-			return new \OC\Files\AppData\Factory(
936
-				$c->getRootFolder(),
937
-				$c->getSystemConfig()
938
-			);
939
-		});
940
-
941
-		$this->registerService('LockdownManager', function (Server $c) {
942
-			return new LockdownManager();
943
-		});
944
-
945
-		$this->registerService(ICloudIdManager::class, function (Server $c) {
946
-			return new CloudIdManager();
947
-		});
948
-
949
-		/* To trick DI since we don't extend the DIContainer here */
950
-		$this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
951
-			return new CleanPreviewsBackgroundJob(
952
-				$c->getRootFolder(),
953
-				$c->getLogger(),
954
-				$c->getJobList(),
955
-				new TimeFactory()
956
-			);
957
-		});
958
-
959
-		$this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
960
-		$this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
961
-
962
-		$this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
963
-		$this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
964
-
965
-		$this->registerService(\OCP\ISession::class, function(SimpleContainer $c) {
966
-			return $c->query(\OCP\IUserSession::class)->getSession();
967
-		});
968
-	}
969
-
970
-	/**
971
-	 * @return \OCP\Contacts\IManager
972
-	 */
973
-	public function getContactsManager() {
974
-		return $this->query('ContactsManager');
975
-	}
976
-
977
-	/**
978
-	 * @return \OC\Encryption\Manager
979
-	 */
980
-	public function getEncryptionManager() {
981
-		return $this->query('EncryptionManager');
982
-	}
983
-
984
-	/**
985
-	 * @return \OC\Encryption\File
986
-	 */
987
-	public function getEncryptionFilesHelper() {
988
-		return $this->query('EncryptionFileHelper');
989
-	}
990
-
991
-	/**
992
-	 * @return \OCP\Encryption\Keys\IStorage
993
-	 */
994
-	public function getEncryptionKeyStorage() {
995
-		return $this->query('EncryptionKeyStorage');
996
-	}
997
-
998
-	/**
999
-	 * The current request object holding all information about the request
1000
-	 * currently being processed is returned from this method.
1001
-	 * In case the current execution was not initiated by a web request null is returned
1002
-	 *
1003
-	 * @return \OCP\IRequest
1004
-	 */
1005
-	public function getRequest() {
1006
-		return $this->query('Request');
1007
-	}
1008
-
1009
-	/**
1010
-	 * Returns the preview manager which can create preview images for a given file
1011
-	 *
1012
-	 * @return \OCP\IPreview
1013
-	 */
1014
-	public function getPreviewManager() {
1015
-		return $this->query('PreviewManager');
1016
-	}
1017
-
1018
-	/**
1019
-	 * Returns the tag manager which can get and set tags for different object types
1020
-	 *
1021
-	 * @see \OCP\ITagManager::load()
1022
-	 * @return \OCP\ITagManager
1023
-	 */
1024
-	public function getTagManager() {
1025
-		return $this->query('TagManager');
1026
-	}
1027
-
1028
-	/**
1029
-	 * Returns the system-tag manager
1030
-	 *
1031
-	 * @return \OCP\SystemTag\ISystemTagManager
1032
-	 *
1033
-	 * @since 9.0.0
1034
-	 */
1035
-	public function getSystemTagManager() {
1036
-		return $this->query('SystemTagManager');
1037
-	}
1038
-
1039
-	/**
1040
-	 * Returns the system-tag object mapper
1041
-	 *
1042
-	 * @return \OCP\SystemTag\ISystemTagObjectMapper
1043
-	 *
1044
-	 * @since 9.0.0
1045
-	 */
1046
-	public function getSystemTagObjectMapper() {
1047
-		return $this->query('SystemTagObjectMapper');
1048
-	}
1049
-
1050
-	/**
1051
-	 * Returns the avatar manager, used for avatar functionality
1052
-	 *
1053
-	 * @return \OCP\IAvatarManager
1054
-	 */
1055
-	public function getAvatarManager() {
1056
-		return $this->query('AvatarManager');
1057
-	}
1058
-
1059
-	/**
1060
-	 * Returns the root folder of ownCloud's data directory
1061
-	 *
1062
-	 * @return \OCP\Files\IRootFolder
1063
-	 */
1064
-	public function getRootFolder() {
1065
-		return $this->query('LazyRootFolder');
1066
-	}
1067
-
1068
-	/**
1069
-	 * Returns the root folder of ownCloud's data directory
1070
-	 * This is the lazy variant so this gets only initialized once it
1071
-	 * is actually used.
1072
-	 *
1073
-	 * @return \OCP\Files\IRootFolder
1074
-	 */
1075
-	public function getLazyRootFolder() {
1076
-		return $this->query('LazyRootFolder');
1077
-	}
1078
-
1079
-	/**
1080
-	 * Returns a view to ownCloud's files folder
1081
-	 *
1082
-	 * @param string $userId user ID
1083
-	 * @return \OCP\Files\Folder|null
1084
-	 */
1085
-	public function getUserFolder($userId = null) {
1086
-		if ($userId === null) {
1087
-			$user = $this->getUserSession()->getUser();
1088
-			if (!$user) {
1089
-				return null;
1090
-			}
1091
-			$userId = $user->getUID();
1092
-		}
1093
-		$root = $this->getRootFolder();
1094
-		return $root->getUserFolder($userId);
1095
-	}
1096
-
1097
-	/**
1098
-	 * Returns an app-specific view in ownClouds data directory
1099
-	 *
1100
-	 * @return \OCP\Files\Folder
1101
-	 * @deprecated since 9.2.0 use IAppData
1102
-	 */
1103
-	public function getAppFolder() {
1104
-		$dir = '/' . \OC_App::getCurrentApp();
1105
-		$root = $this->getRootFolder();
1106
-		if (!$root->nodeExists($dir)) {
1107
-			$folder = $root->newFolder($dir);
1108
-		} else {
1109
-			$folder = $root->get($dir);
1110
-		}
1111
-		return $folder;
1112
-	}
1113
-
1114
-	/**
1115
-	 * @return \OC\User\Manager
1116
-	 */
1117
-	public function getUserManager() {
1118
-		return $this->query('UserManager');
1119
-	}
1120
-
1121
-	/**
1122
-	 * @return \OC\Group\Manager
1123
-	 */
1124
-	public function getGroupManager() {
1125
-		return $this->query('GroupManager');
1126
-	}
1127
-
1128
-	/**
1129
-	 * @return \OC\User\Session
1130
-	 */
1131
-	public function getUserSession() {
1132
-		return $this->query('UserSession');
1133
-	}
1134
-
1135
-	/**
1136
-	 * @return \OCP\ISession
1137
-	 */
1138
-	public function getSession() {
1139
-		return $this->query('UserSession')->getSession();
1140
-	}
1141
-
1142
-	/**
1143
-	 * @param \OCP\ISession $session
1144
-	 */
1145
-	public function setSession(\OCP\ISession $session) {
1146
-		$this->query(SessionStorage::class)->setSession($session);
1147
-		$this->query('UserSession')->setSession($session);
1148
-		$this->query(Store::class)->setSession($session);
1149
-	}
1150
-
1151
-	/**
1152
-	 * @return \OC\Authentication\TwoFactorAuth\Manager
1153
-	 */
1154
-	public function getTwoFactorAuthManager() {
1155
-		return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1156
-	}
1157
-
1158
-	/**
1159
-	 * @return \OC\NavigationManager
1160
-	 */
1161
-	public function getNavigationManager() {
1162
-		return $this->query('NavigationManager');
1163
-	}
1164
-
1165
-	/**
1166
-	 * @return \OCP\IConfig
1167
-	 */
1168
-	public function getConfig() {
1169
-		return $this->query('AllConfig');
1170
-	}
1171
-
1172
-	/**
1173
-	 * @internal For internal use only
1174
-	 * @return \OC\SystemConfig
1175
-	 */
1176
-	public function getSystemConfig() {
1177
-		return $this->query('SystemConfig');
1178
-	}
1179
-
1180
-	/**
1181
-	 * Returns the app config manager
1182
-	 *
1183
-	 * @return \OCP\IAppConfig
1184
-	 */
1185
-	public function getAppConfig() {
1186
-		return $this->query('AppConfig');
1187
-	}
1188
-
1189
-	/**
1190
-	 * @return \OCP\L10N\IFactory
1191
-	 */
1192
-	public function getL10NFactory() {
1193
-		return $this->query('L10NFactory');
1194
-	}
1195
-
1196
-	/**
1197
-	 * get an L10N instance
1198
-	 *
1199
-	 * @param string $app appid
1200
-	 * @param string $lang
1201
-	 * @return IL10N
1202
-	 */
1203
-	public function getL10N($app, $lang = null) {
1204
-		return $this->getL10NFactory()->get($app, $lang);
1205
-	}
1206
-
1207
-	/**
1208
-	 * @return \OCP\IURLGenerator
1209
-	 */
1210
-	public function getURLGenerator() {
1211
-		return $this->query('URLGenerator');
1212
-	}
1213
-
1214
-	/**
1215
-	 * @return \OCP\IHelper
1216
-	 */
1217
-	public function getHelper() {
1218
-		return $this->query('AppHelper');
1219
-	}
1220
-
1221
-	/**
1222
-	 * @return AppFetcher
1223
-	 */
1224
-	public function getAppFetcher() {
1225
-		return $this->query('AppFetcher');
1226
-	}
1227
-
1228
-	/**
1229
-	 * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1230
-	 * getMemCacheFactory() instead.
1231
-	 *
1232
-	 * @return \OCP\ICache
1233
-	 * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1234
-	 */
1235
-	public function getCache() {
1236
-		return $this->query('UserCache');
1237
-	}
1238
-
1239
-	/**
1240
-	 * Returns an \OCP\CacheFactory instance
1241
-	 *
1242
-	 * @return \OCP\ICacheFactory
1243
-	 */
1244
-	public function getMemCacheFactory() {
1245
-		return $this->query('MemCacheFactory');
1246
-	}
1247
-
1248
-	/**
1249
-	 * Returns an \OC\RedisFactory instance
1250
-	 *
1251
-	 * @return \OC\RedisFactory
1252
-	 */
1253
-	public function getGetRedisFactory() {
1254
-		return $this->query('RedisFactory');
1255
-	}
1256
-
1257
-
1258
-	/**
1259
-	 * Returns the current session
1260
-	 *
1261
-	 * @return \OCP\IDBConnection
1262
-	 */
1263
-	public function getDatabaseConnection() {
1264
-		return $this->query('DatabaseConnection');
1265
-	}
1266
-
1267
-	/**
1268
-	 * Returns the activity manager
1269
-	 *
1270
-	 * @return \OCP\Activity\IManager
1271
-	 */
1272
-	public function getActivityManager() {
1273
-		return $this->query('ActivityManager');
1274
-	}
1275
-
1276
-	/**
1277
-	 * Returns an job list for controlling background jobs
1278
-	 *
1279
-	 * @return \OCP\BackgroundJob\IJobList
1280
-	 */
1281
-	public function getJobList() {
1282
-		return $this->query('JobList');
1283
-	}
1284
-
1285
-	/**
1286
-	 * Returns a logger instance
1287
-	 *
1288
-	 * @return \OCP\ILogger
1289
-	 */
1290
-	public function getLogger() {
1291
-		return $this->query('Logger');
1292
-	}
1293
-
1294
-	/**
1295
-	 * Returns a router for generating and matching urls
1296
-	 *
1297
-	 * @return \OCP\Route\IRouter
1298
-	 */
1299
-	public function getRouter() {
1300
-		return $this->query('Router');
1301
-	}
1302
-
1303
-	/**
1304
-	 * Returns a search instance
1305
-	 *
1306
-	 * @return \OCP\ISearch
1307
-	 */
1308
-	public function getSearch() {
1309
-		return $this->query('Search');
1310
-	}
1311
-
1312
-	/**
1313
-	 * Returns a SecureRandom instance
1314
-	 *
1315
-	 * @return \OCP\Security\ISecureRandom
1316
-	 */
1317
-	public function getSecureRandom() {
1318
-		return $this->query('SecureRandom');
1319
-	}
1320
-
1321
-	/**
1322
-	 * Returns a Crypto instance
1323
-	 *
1324
-	 * @return \OCP\Security\ICrypto
1325
-	 */
1326
-	public function getCrypto() {
1327
-		return $this->query('Crypto');
1328
-	}
1329
-
1330
-	/**
1331
-	 * Returns a Hasher instance
1332
-	 *
1333
-	 * @return \OCP\Security\IHasher
1334
-	 */
1335
-	public function getHasher() {
1336
-		return $this->query('Hasher');
1337
-	}
1338
-
1339
-	/**
1340
-	 * Returns a CredentialsManager instance
1341
-	 *
1342
-	 * @return \OCP\Security\ICredentialsManager
1343
-	 */
1344
-	public function getCredentialsManager() {
1345
-		return $this->query('CredentialsManager');
1346
-	}
1347
-
1348
-	/**
1349
-	 * Returns an instance of the HTTP helper class
1350
-	 *
1351
-	 * @deprecated Use getHTTPClientService()
1352
-	 * @return \OC\HTTPHelper
1353
-	 */
1354
-	public function getHTTPHelper() {
1355
-		return $this->query('HTTPHelper');
1356
-	}
1357
-
1358
-	/**
1359
-	 * Get the certificate manager for the user
1360
-	 *
1361
-	 * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1362
-	 * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1363
-	 */
1364
-	public function getCertificateManager($userId = '') {
1365
-		if ($userId === '') {
1366
-			$userSession = $this->getUserSession();
1367
-			$user = $userSession->getUser();
1368
-			if (is_null($user)) {
1369
-				return null;
1370
-			}
1371
-			$userId = $user->getUID();
1372
-		}
1373
-		return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger());
1374
-	}
1375
-
1376
-	/**
1377
-	 * Returns an instance of the HTTP client service
1378
-	 *
1379
-	 * @return \OCP\Http\Client\IClientService
1380
-	 */
1381
-	public function getHTTPClientService() {
1382
-		return $this->query('HttpClientService');
1383
-	}
1384
-
1385
-	/**
1386
-	 * Create a new event source
1387
-	 *
1388
-	 * @return \OCP\IEventSource
1389
-	 */
1390
-	public function createEventSource() {
1391
-		return new \OC_EventSource();
1392
-	}
1393
-
1394
-	/**
1395
-	 * Get the active event logger
1396
-	 *
1397
-	 * The returned logger only logs data when debug mode is enabled
1398
-	 *
1399
-	 * @return \OCP\Diagnostics\IEventLogger
1400
-	 */
1401
-	public function getEventLogger() {
1402
-		return $this->query('EventLogger');
1403
-	}
1404
-
1405
-	/**
1406
-	 * Get the active query logger
1407
-	 *
1408
-	 * The returned logger only logs data when debug mode is enabled
1409
-	 *
1410
-	 * @return \OCP\Diagnostics\IQueryLogger
1411
-	 */
1412
-	public function getQueryLogger() {
1413
-		return $this->query('QueryLogger');
1414
-	}
1415
-
1416
-	/**
1417
-	 * Get the manager for temporary files and folders
1418
-	 *
1419
-	 * @return \OCP\ITempManager
1420
-	 */
1421
-	public function getTempManager() {
1422
-		return $this->query('TempManager');
1423
-	}
1424
-
1425
-	/**
1426
-	 * Get the app manager
1427
-	 *
1428
-	 * @return \OCP\App\IAppManager
1429
-	 */
1430
-	public function getAppManager() {
1431
-		return $this->query('AppManager');
1432
-	}
1433
-
1434
-	/**
1435
-	 * Creates a new mailer
1436
-	 *
1437
-	 * @return \OCP\Mail\IMailer
1438
-	 */
1439
-	public function getMailer() {
1440
-		return $this->query('Mailer');
1441
-	}
1442
-
1443
-	/**
1444
-	 * Get the webroot
1445
-	 *
1446
-	 * @return string
1447
-	 */
1448
-	public function getWebRoot() {
1449
-		return $this->webRoot;
1450
-	}
1451
-
1452
-	/**
1453
-	 * @return \OC\OCSClient
1454
-	 */
1455
-	public function getOcsClient() {
1456
-		return $this->query('OcsClient');
1457
-	}
1458
-
1459
-	/**
1460
-	 * @return \OCP\IDateTimeZone
1461
-	 */
1462
-	public function getDateTimeZone() {
1463
-		return $this->query('DateTimeZone');
1464
-	}
1465
-
1466
-	/**
1467
-	 * @return \OCP\IDateTimeFormatter
1468
-	 */
1469
-	public function getDateTimeFormatter() {
1470
-		return $this->query('DateTimeFormatter');
1471
-	}
1472
-
1473
-	/**
1474
-	 * @return \OCP\Files\Config\IMountProviderCollection
1475
-	 */
1476
-	public function getMountProviderCollection() {
1477
-		return $this->query('MountConfigManager');
1478
-	}
1479
-
1480
-	/**
1481
-	 * Get the IniWrapper
1482
-	 *
1483
-	 * @return IniGetWrapper
1484
-	 */
1485
-	public function getIniWrapper() {
1486
-		return $this->query('IniWrapper');
1487
-	}
1488
-
1489
-	/**
1490
-	 * @return \OCP\Command\IBus
1491
-	 */
1492
-	public function getCommandBus() {
1493
-		return $this->query('AsyncCommandBus');
1494
-	}
1495
-
1496
-	/**
1497
-	 * Get the trusted domain helper
1498
-	 *
1499
-	 * @return TrustedDomainHelper
1500
-	 */
1501
-	public function getTrustedDomainHelper() {
1502
-		return $this->query('TrustedDomainHelper');
1503
-	}
1504
-
1505
-	/**
1506
-	 * Get the locking provider
1507
-	 *
1508
-	 * @return \OCP\Lock\ILockingProvider
1509
-	 * @since 8.1.0
1510
-	 */
1511
-	public function getLockingProvider() {
1512
-		return $this->query('LockingProvider');
1513
-	}
1514
-
1515
-	/**
1516
-	 * @return \OCP\Files\Mount\IMountManager
1517
-	 **/
1518
-	function getMountManager() {
1519
-		return $this->query('MountManager');
1520
-	}
1521
-
1522
-	/** @return \OCP\Files\Config\IUserMountCache */
1523
-	function getUserMountCache() {
1524
-		return $this->query('UserMountCache');
1525
-	}
1526
-
1527
-	/**
1528
-	 * Get the MimeTypeDetector
1529
-	 *
1530
-	 * @return \OCP\Files\IMimeTypeDetector
1531
-	 */
1532
-	public function getMimeTypeDetector() {
1533
-		return $this->query('MimeTypeDetector');
1534
-	}
1535
-
1536
-	/**
1537
-	 * Get the MimeTypeLoader
1538
-	 *
1539
-	 * @return \OCP\Files\IMimeTypeLoader
1540
-	 */
1541
-	public function getMimeTypeLoader() {
1542
-		return $this->query('MimeTypeLoader');
1543
-	}
1544
-
1545
-	/**
1546
-	 * Get the manager of all the capabilities
1547
-	 *
1548
-	 * @return \OC\CapabilitiesManager
1549
-	 */
1550
-	public function getCapabilitiesManager() {
1551
-		return $this->query('CapabilitiesManager');
1552
-	}
1553
-
1554
-	/**
1555
-	 * Get the EventDispatcher
1556
-	 *
1557
-	 * @return EventDispatcherInterface
1558
-	 * @since 8.2.0
1559
-	 */
1560
-	public function getEventDispatcher() {
1561
-		return $this->query('EventDispatcher');
1562
-	}
1563
-
1564
-	/**
1565
-	 * Get the Notification Manager
1566
-	 *
1567
-	 * @return \OCP\Notification\IManager
1568
-	 * @since 8.2.0
1569
-	 */
1570
-	public function getNotificationManager() {
1571
-		return $this->query('NotificationManager');
1572
-	}
1573
-
1574
-	/**
1575
-	 * @return \OCP\Comments\ICommentsManager
1576
-	 */
1577
-	public function getCommentsManager() {
1578
-		return $this->query('CommentsManager');
1579
-	}
1580
-
1581
-	/**
1582
-	 * @return \OC_Defaults
1583
-	 */
1584
-	public function getThemingDefaults() {
1585
-		return $this->query('ThemingDefaults');
1586
-	}
1587
-
1588
-	/**
1589
-	 * @return \OC\IntegrityCheck\Checker
1590
-	 */
1591
-	public function getIntegrityCodeChecker() {
1592
-		return $this->query('IntegrityCodeChecker');
1593
-	}
1594
-
1595
-	/**
1596
-	 * @return \OC\Session\CryptoWrapper
1597
-	 */
1598
-	public function getSessionCryptoWrapper() {
1599
-		return $this->query('CryptoWrapper');
1600
-	}
1601
-
1602
-	/**
1603
-	 * @return CsrfTokenManager
1604
-	 */
1605
-	public function getCsrfTokenManager() {
1606
-		return $this->query('CsrfTokenManager');
1607
-	}
1608
-
1609
-	/**
1610
-	 * @return Throttler
1611
-	 */
1612
-	public function getBruteForceThrottler() {
1613
-		return $this->query('Throttler');
1614
-	}
1615
-
1616
-	/**
1617
-	 * @return IContentSecurityPolicyManager
1618
-	 */
1619
-	public function getContentSecurityPolicyManager() {
1620
-		return $this->query('ContentSecurityPolicyManager');
1621
-	}
1622
-
1623
-	/**
1624
-	 * @return ContentSecurityPolicyNonceManager
1625
-	 */
1626
-	public function getContentSecurityPolicyNonceManager() {
1627
-		return $this->query('ContentSecurityPolicyNonceManager');
1628
-	}
1629
-
1630
-	/**
1631
-	 * Not a public API as of 8.2, wait for 9.0
1632
-	 *
1633
-	 * @return \OCA\Files_External\Service\BackendService
1634
-	 */
1635
-	public function getStoragesBackendService() {
1636
-		return $this->query('OCA\\Files_External\\Service\\BackendService');
1637
-	}
1638
-
1639
-	/**
1640
-	 * Not a public API as of 8.2, wait for 9.0
1641
-	 *
1642
-	 * @return \OCA\Files_External\Service\GlobalStoragesService
1643
-	 */
1644
-	public function getGlobalStoragesService() {
1645
-		return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1646
-	}
1647
-
1648
-	/**
1649
-	 * Not a public API as of 8.2, wait for 9.0
1650
-	 *
1651
-	 * @return \OCA\Files_External\Service\UserGlobalStoragesService
1652
-	 */
1653
-	public function getUserGlobalStoragesService() {
1654
-		return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1655
-	}
1656
-
1657
-	/**
1658
-	 * Not a public API as of 8.2, wait for 9.0
1659
-	 *
1660
-	 * @return \OCA\Files_External\Service\UserStoragesService
1661
-	 */
1662
-	public function getUserStoragesService() {
1663
-		return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1664
-	}
1665
-
1666
-	/**
1667
-	 * @return \OCP\Share\IManager
1668
-	 */
1669
-	public function getShareManager() {
1670
-		return $this->query('ShareManager');
1671
-	}
1672
-
1673
-	/**
1674
-	 * Returns the LDAP Provider
1675
-	 *
1676
-	 * @return \OCP\LDAP\ILDAPProvider
1677
-	 */
1678
-	public function getLDAPProvider() {
1679
-		return $this->query('LDAPProvider');
1680
-	}
1681
-
1682
-	/**
1683
-	 * @return \OCP\Settings\IManager
1684
-	 */
1685
-	public function getSettingsManager() {
1686
-		return $this->query('SettingsManager');
1687
-	}
1688
-
1689
-	/**
1690
-	 * @return \OCP\Files\IAppData
1691
-	 */
1692
-	public function getAppDataDir($app) {
1693
-		/** @var \OC\Files\AppData\Factory $factory */
1694
-		$factory = $this->query(\OC\Files\AppData\Factory::class);
1695
-		return $factory->get($app);
1696
-	}
1697
-
1698
-	/**
1699
-	 * @return \OCP\Lockdown\ILockdownManager
1700
-	 */
1701
-	public function getLockdownManager() {
1702
-		return $this->query('LockdownManager');
1703
-	}
1704
-
1705
-	/**
1706
-	 * @return \OCP\Federation\ICloudIdManager
1707
-	 */
1708
-	public function getCloudIdManager() {
1709
-		return $this->query(ICloudIdManager::class);
1710
-	}
821
+            $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
822
+            if (isset($prefixes['OCA\\Theming\\'])) {
823
+                $classExists = true;
824
+            } else {
825
+                $classExists = false;
826
+            }
827
+
828
+            if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) {
829
+                return new ThemingDefaults(
830
+                    $c->getConfig(),
831
+                    $c->getL10N('theming'),
832
+                    $c->getURLGenerator(),
833
+                    new \OC_Defaults(),
834
+                    $c->getAppDataDir('theming'),
835
+                    $c->getMemCacheFactory(),
836
+                    new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager())
837
+                );
838
+            }
839
+            return new \OC_Defaults();
840
+        });
841
+        $this->registerService(EventDispatcher::class, function () {
842
+            return new EventDispatcher();
843
+        });
844
+        $this->registerAlias('EventDispatcher', EventDispatcher::class);
845
+        $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class);
846
+
847
+        $this->registerService('CryptoWrapper', function (Server $c) {
848
+            // FIXME: Instantiiated here due to cyclic dependency
849
+            $request = new Request(
850
+                [
851
+                    'get' => $_GET,
852
+                    'post' => $_POST,
853
+                    'files' => $_FILES,
854
+                    'server' => $_SERVER,
855
+                    'env' => $_ENV,
856
+                    'cookies' => $_COOKIE,
857
+                    'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
858
+                        ? $_SERVER['REQUEST_METHOD']
859
+                        : null,
860
+                ],
861
+                $c->getSecureRandom(),
862
+                $c->getConfig()
863
+            );
864
+
865
+            return new CryptoWrapper(
866
+                $c->getConfig(),
867
+                $c->getCrypto(),
868
+                $c->getSecureRandom(),
869
+                $request
870
+            );
871
+        });
872
+        $this->registerService('CsrfTokenManager', function (Server $c) {
873
+            $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom());
874
+
875
+            return new CsrfTokenManager(
876
+                $tokenGenerator,
877
+                $c->query(SessionStorage::class)
878
+            );
879
+        });
880
+        $this->registerService(SessionStorage::class, function (Server $c) {
881
+            return new SessionStorage($c->getSession());
882
+        });
883
+        $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) {
884
+            return new ContentSecurityPolicyManager();
885
+        });
886
+        $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class);
887
+
888
+        $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) {
889
+            return new ContentSecurityPolicyNonceManager(
890
+                $c->getCsrfTokenManager(),
891
+                $c->getRequest()
892
+            );
893
+        });
894
+
895
+        $this->registerService(\OCP\Share\IManager::class, function(Server $c) {
896
+            $config = $c->getConfig();
897
+            $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory');
898
+            /** @var \OCP\Share\IProviderFactory $factory */
899
+            $factory = new $factoryClass($this);
900
+
901
+            $manager = new \OC\Share20\Manager(
902
+                $c->getLogger(),
903
+                $c->getConfig(),
904
+                $c->getSecureRandom(),
905
+                $c->getHasher(),
906
+                $c->getMountManager(),
907
+                $c->getGroupManager(),
908
+                $c->getL10N('core'),
909
+                $factory,
910
+                $c->getUserManager(),
911
+                $c->getLazyRootFolder(),
912
+                $c->getEventDispatcher()
913
+            );
914
+
915
+            return $manager;
916
+        });
917
+        $this->registerAlias('ShareManager', \OCP\Share\IManager::class);
918
+
919
+        $this->registerService('SettingsManager', function(Server $c) {
920
+            $manager = new \OC\Settings\Manager(
921
+                $c->getLogger(),
922
+                $c->getDatabaseConnection(),
923
+                $c->getL10N('lib'),
924
+                $c->getConfig(),
925
+                $c->getEncryptionManager(),
926
+                $c->getUserManager(),
927
+                $c->getLockingProvider(),
928
+                $c->getRequest(),
929
+                new \OC\Settings\Mapper($c->getDatabaseConnection()),
930
+                $c->getURLGenerator()
931
+            );
932
+            return $manager;
933
+        });
934
+        $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) {
935
+            return new \OC\Files\AppData\Factory(
936
+                $c->getRootFolder(),
937
+                $c->getSystemConfig()
938
+            );
939
+        });
940
+
941
+        $this->registerService('LockdownManager', function (Server $c) {
942
+            return new LockdownManager();
943
+        });
944
+
945
+        $this->registerService(ICloudIdManager::class, function (Server $c) {
946
+            return new CloudIdManager();
947
+        });
948
+
949
+        /* To trick DI since we don't extend the DIContainer here */
950
+        $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) {
951
+            return new CleanPreviewsBackgroundJob(
952
+                $c->getRootFolder(),
953
+                $c->getLogger(),
954
+                $c->getJobList(),
955
+                new TimeFactory()
956
+            );
957
+        });
958
+
959
+        $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
960
+        $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
961
+
962
+        $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
963
+        $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
964
+
965
+        $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) {
966
+            return $c->query(\OCP\IUserSession::class)->getSession();
967
+        });
968
+    }
969
+
970
+    /**
971
+     * @return \OCP\Contacts\IManager
972
+     */
973
+    public function getContactsManager() {
974
+        return $this->query('ContactsManager');
975
+    }
976
+
977
+    /**
978
+     * @return \OC\Encryption\Manager
979
+     */
980
+    public function getEncryptionManager() {
981
+        return $this->query('EncryptionManager');
982
+    }
983
+
984
+    /**
985
+     * @return \OC\Encryption\File
986
+     */
987
+    public function getEncryptionFilesHelper() {
988
+        return $this->query('EncryptionFileHelper');
989
+    }
990
+
991
+    /**
992
+     * @return \OCP\Encryption\Keys\IStorage
993
+     */
994
+    public function getEncryptionKeyStorage() {
995
+        return $this->query('EncryptionKeyStorage');
996
+    }
997
+
998
+    /**
999
+     * The current request object holding all information about the request
1000
+     * currently being processed is returned from this method.
1001
+     * In case the current execution was not initiated by a web request null is returned
1002
+     *
1003
+     * @return \OCP\IRequest
1004
+     */
1005
+    public function getRequest() {
1006
+        return $this->query('Request');
1007
+    }
1008
+
1009
+    /**
1010
+     * Returns the preview manager which can create preview images for a given file
1011
+     *
1012
+     * @return \OCP\IPreview
1013
+     */
1014
+    public function getPreviewManager() {
1015
+        return $this->query('PreviewManager');
1016
+    }
1017
+
1018
+    /**
1019
+     * Returns the tag manager which can get and set tags for different object types
1020
+     *
1021
+     * @see \OCP\ITagManager::load()
1022
+     * @return \OCP\ITagManager
1023
+     */
1024
+    public function getTagManager() {
1025
+        return $this->query('TagManager');
1026
+    }
1027
+
1028
+    /**
1029
+     * Returns the system-tag manager
1030
+     *
1031
+     * @return \OCP\SystemTag\ISystemTagManager
1032
+     *
1033
+     * @since 9.0.0
1034
+     */
1035
+    public function getSystemTagManager() {
1036
+        return $this->query('SystemTagManager');
1037
+    }
1038
+
1039
+    /**
1040
+     * Returns the system-tag object mapper
1041
+     *
1042
+     * @return \OCP\SystemTag\ISystemTagObjectMapper
1043
+     *
1044
+     * @since 9.0.0
1045
+     */
1046
+    public function getSystemTagObjectMapper() {
1047
+        return $this->query('SystemTagObjectMapper');
1048
+    }
1049
+
1050
+    /**
1051
+     * Returns the avatar manager, used for avatar functionality
1052
+     *
1053
+     * @return \OCP\IAvatarManager
1054
+     */
1055
+    public function getAvatarManager() {
1056
+        return $this->query('AvatarManager');
1057
+    }
1058
+
1059
+    /**
1060
+     * Returns the root folder of ownCloud's data directory
1061
+     *
1062
+     * @return \OCP\Files\IRootFolder
1063
+     */
1064
+    public function getRootFolder() {
1065
+        return $this->query('LazyRootFolder');
1066
+    }
1067
+
1068
+    /**
1069
+     * Returns the root folder of ownCloud's data directory
1070
+     * This is the lazy variant so this gets only initialized once it
1071
+     * is actually used.
1072
+     *
1073
+     * @return \OCP\Files\IRootFolder
1074
+     */
1075
+    public function getLazyRootFolder() {
1076
+        return $this->query('LazyRootFolder');
1077
+    }
1078
+
1079
+    /**
1080
+     * Returns a view to ownCloud's files folder
1081
+     *
1082
+     * @param string $userId user ID
1083
+     * @return \OCP\Files\Folder|null
1084
+     */
1085
+    public function getUserFolder($userId = null) {
1086
+        if ($userId === null) {
1087
+            $user = $this->getUserSession()->getUser();
1088
+            if (!$user) {
1089
+                return null;
1090
+            }
1091
+            $userId = $user->getUID();
1092
+        }
1093
+        $root = $this->getRootFolder();
1094
+        return $root->getUserFolder($userId);
1095
+    }
1096
+
1097
+    /**
1098
+     * Returns an app-specific view in ownClouds data directory
1099
+     *
1100
+     * @return \OCP\Files\Folder
1101
+     * @deprecated since 9.2.0 use IAppData
1102
+     */
1103
+    public function getAppFolder() {
1104
+        $dir = '/' . \OC_App::getCurrentApp();
1105
+        $root = $this->getRootFolder();
1106
+        if (!$root->nodeExists($dir)) {
1107
+            $folder = $root->newFolder($dir);
1108
+        } else {
1109
+            $folder = $root->get($dir);
1110
+        }
1111
+        return $folder;
1112
+    }
1113
+
1114
+    /**
1115
+     * @return \OC\User\Manager
1116
+     */
1117
+    public function getUserManager() {
1118
+        return $this->query('UserManager');
1119
+    }
1120
+
1121
+    /**
1122
+     * @return \OC\Group\Manager
1123
+     */
1124
+    public function getGroupManager() {
1125
+        return $this->query('GroupManager');
1126
+    }
1127
+
1128
+    /**
1129
+     * @return \OC\User\Session
1130
+     */
1131
+    public function getUserSession() {
1132
+        return $this->query('UserSession');
1133
+    }
1134
+
1135
+    /**
1136
+     * @return \OCP\ISession
1137
+     */
1138
+    public function getSession() {
1139
+        return $this->query('UserSession')->getSession();
1140
+    }
1141
+
1142
+    /**
1143
+     * @param \OCP\ISession $session
1144
+     */
1145
+    public function setSession(\OCP\ISession $session) {
1146
+        $this->query(SessionStorage::class)->setSession($session);
1147
+        $this->query('UserSession')->setSession($session);
1148
+        $this->query(Store::class)->setSession($session);
1149
+    }
1150
+
1151
+    /**
1152
+     * @return \OC\Authentication\TwoFactorAuth\Manager
1153
+     */
1154
+    public function getTwoFactorAuthManager() {
1155
+        return $this->query('\OC\Authentication\TwoFactorAuth\Manager');
1156
+    }
1157
+
1158
+    /**
1159
+     * @return \OC\NavigationManager
1160
+     */
1161
+    public function getNavigationManager() {
1162
+        return $this->query('NavigationManager');
1163
+    }
1164
+
1165
+    /**
1166
+     * @return \OCP\IConfig
1167
+     */
1168
+    public function getConfig() {
1169
+        return $this->query('AllConfig');
1170
+    }
1171
+
1172
+    /**
1173
+     * @internal For internal use only
1174
+     * @return \OC\SystemConfig
1175
+     */
1176
+    public function getSystemConfig() {
1177
+        return $this->query('SystemConfig');
1178
+    }
1179
+
1180
+    /**
1181
+     * Returns the app config manager
1182
+     *
1183
+     * @return \OCP\IAppConfig
1184
+     */
1185
+    public function getAppConfig() {
1186
+        return $this->query('AppConfig');
1187
+    }
1188
+
1189
+    /**
1190
+     * @return \OCP\L10N\IFactory
1191
+     */
1192
+    public function getL10NFactory() {
1193
+        return $this->query('L10NFactory');
1194
+    }
1195
+
1196
+    /**
1197
+     * get an L10N instance
1198
+     *
1199
+     * @param string $app appid
1200
+     * @param string $lang
1201
+     * @return IL10N
1202
+     */
1203
+    public function getL10N($app, $lang = null) {
1204
+        return $this->getL10NFactory()->get($app, $lang);
1205
+    }
1206
+
1207
+    /**
1208
+     * @return \OCP\IURLGenerator
1209
+     */
1210
+    public function getURLGenerator() {
1211
+        return $this->query('URLGenerator');
1212
+    }
1213
+
1214
+    /**
1215
+     * @return \OCP\IHelper
1216
+     */
1217
+    public function getHelper() {
1218
+        return $this->query('AppHelper');
1219
+    }
1220
+
1221
+    /**
1222
+     * @return AppFetcher
1223
+     */
1224
+    public function getAppFetcher() {
1225
+        return $this->query('AppFetcher');
1226
+    }
1227
+
1228
+    /**
1229
+     * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
1230
+     * getMemCacheFactory() instead.
1231
+     *
1232
+     * @return \OCP\ICache
1233
+     * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
1234
+     */
1235
+    public function getCache() {
1236
+        return $this->query('UserCache');
1237
+    }
1238
+
1239
+    /**
1240
+     * Returns an \OCP\CacheFactory instance
1241
+     *
1242
+     * @return \OCP\ICacheFactory
1243
+     */
1244
+    public function getMemCacheFactory() {
1245
+        return $this->query('MemCacheFactory');
1246
+    }
1247
+
1248
+    /**
1249
+     * Returns an \OC\RedisFactory instance
1250
+     *
1251
+     * @return \OC\RedisFactory
1252
+     */
1253
+    public function getGetRedisFactory() {
1254
+        return $this->query('RedisFactory');
1255
+    }
1256
+
1257
+
1258
+    /**
1259
+     * Returns the current session
1260
+     *
1261
+     * @return \OCP\IDBConnection
1262
+     */
1263
+    public function getDatabaseConnection() {
1264
+        return $this->query('DatabaseConnection');
1265
+    }
1266
+
1267
+    /**
1268
+     * Returns the activity manager
1269
+     *
1270
+     * @return \OCP\Activity\IManager
1271
+     */
1272
+    public function getActivityManager() {
1273
+        return $this->query('ActivityManager');
1274
+    }
1275
+
1276
+    /**
1277
+     * Returns an job list for controlling background jobs
1278
+     *
1279
+     * @return \OCP\BackgroundJob\IJobList
1280
+     */
1281
+    public function getJobList() {
1282
+        return $this->query('JobList');
1283
+    }
1284
+
1285
+    /**
1286
+     * Returns a logger instance
1287
+     *
1288
+     * @return \OCP\ILogger
1289
+     */
1290
+    public function getLogger() {
1291
+        return $this->query('Logger');
1292
+    }
1293
+
1294
+    /**
1295
+     * Returns a router for generating and matching urls
1296
+     *
1297
+     * @return \OCP\Route\IRouter
1298
+     */
1299
+    public function getRouter() {
1300
+        return $this->query('Router');
1301
+    }
1302
+
1303
+    /**
1304
+     * Returns a search instance
1305
+     *
1306
+     * @return \OCP\ISearch
1307
+     */
1308
+    public function getSearch() {
1309
+        return $this->query('Search');
1310
+    }
1311
+
1312
+    /**
1313
+     * Returns a SecureRandom instance
1314
+     *
1315
+     * @return \OCP\Security\ISecureRandom
1316
+     */
1317
+    public function getSecureRandom() {
1318
+        return $this->query('SecureRandom');
1319
+    }
1320
+
1321
+    /**
1322
+     * Returns a Crypto instance
1323
+     *
1324
+     * @return \OCP\Security\ICrypto
1325
+     */
1326
+    public function getCrypto() {
1327
+        return $this->query('Crypto');
1328
+    }
1329
+
1330
+    /**
1331
+     * Returns a Hasher instance
1332
+     *
1333
+     * @return \OCP\Security\IHasher
1334
+     */
1335
+    public function getHasher() {
1336
+        return $this->query('Hasher');
1337
+    }
1338
+
1339
+    /**
1340
+     * Returns a CredentialsManager instance
1341
+     *
1342
+     * @return \OCP\Security\ICredentialsManager
1343
+     */
1344
+    public function getCredentialsManager() {
1345
+        return $this->query('CredentialsManager');
1346
+    }
1347
+
1348
+    /**
1349
+     * Returns an instance of the HTTP helper class
1350
+     *
1351
+     * @deprecated Use getHTTPClientService()
1352
+     * @return \OC\HTTPHelper
1353
+     */
1354
+    public function getHTTPHelper() {
1355
+        return $this->query('HTTPHelper');
1356
+    }
1357
+
1358
+    /**
1359
+     * Get the certificate manager for the user
1360
+     *
1361
+     * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager
1362
+     * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in
1363
+     */
1364
+    public function getCertificateManager($userId = '') {
1365
+        if ($userId === '') {
1366
+            $userSession = $this->getUserSession();
1367
+            $user = $userSession->getUser();
1368
+            if (is_null($user)) {
1369
+                return null;
1370
+            }
1371
+            $userId = $user->getUID();
1372
+        }
1373
+        return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger());
1374
+    }
1375
+
1376
+    /**
1377
+     * Returns an instance of the HTTP client service
1378
+     *
1379
+     * @return \OCP\Http\Client\IClientService
1380
+     */
1381
+    public function getHTTPClientService() {
1382
+        return $this->query('HttpClientService');
1383
+    }
1384
+
1385
+    /**
1386
+     * Create a new event source
1387
+     *
1388
+     * @return \OCP\IEventSource
1389
+     */
1390
+    public function createEventSource() {
1391
+        return new \OC_EventSource();
1392
+    }
1393
+
1394
+    /**
1395
+     * Get the active event logger
1396
+     *
1397
+     * The returned logger only logs data when debug mode is enabled
1398
+     *
1399
+     * @return \OCP\Diagnostics\IEventLogger
1400
+     */
1401
+    public function getEventLogger() {
1402
+        return $this->query('EventLogger');
1403
+    }
1404
+
1405
+    /**
1406
+     * Get the active query logger
1407
+     *
1408
+     * The returned logger only logs data when debug mode is enabled
1409
+     *
1410
+     * @return \OCP\Diagnostics\IQueryLogger
1411
+     */
1412
+    public function getQueryLogger() {
1413
+        return $this->query('QueryLogger');
1414
+    }
1415
+
1416
+    /**
1417
+     * Get the manager for temporary files and folders
1418
+     *
1419
+     * @return \OCP\ITempManager
1420
+     */
1421
+    public function getTempManager() {
1422
+        return $this->query('TempManager');
1423
+    }
1424
+
1425
+    /**
1426
+     * Get the app manager
1427
+     *
1428
+     * @return \OCP\App\IAppManager
1429
+     */
1430
+    public function getAppManager() {
1431
+        return $this->query('AppManager');
1432
+    }
1433
+
1434
+    /**
1435
+     * Creates a new mailer
1436
+     *
1437
+     * @return \OCP\Mail\IMailer
1438
+     */
1439
+    public function getMailer() {
1440
+        return $this->query('Mailer');
1441
+    }
1442
+
1443
+    /**
1444
+     * Get the webroot
1445
+     *
1446
+     * @return string
1447
+     */
1448
+    public function getWebRoot() {
1449
+        return $this->webRoot;
1450
+    }
1451
+
1452
+    /**
1453
+     * @return \OC\OCSClient
1454
+     */
1455
+    public function getOcsClient() {
1456
+        return $this->query('OcsClient');
1457
+    }
1458
+
1459
+    /**
1460
+     * @return \OCP\IDateTimeZone
1461
+     */
1462
+    public function getDateTimeZone() {
1463
+        return $this->query('DateTimeZone');
1464
+    }
1465
+
1466
+    /**
1467
+     * @return \OCP\IDateTimeFormatter
1468
+     */
1469
+    public function getDateTimeFormatter() {
1470
+        return $this->query('DateTimeFormatter');
1471
+    }
1472
+
1473
+    /**
1474
+     * @return \OCP\Files\Config\IMountProviderCollection
1475
+     */
1476
+    public function getMountProviderCollection() {
1477
+        return $this->query('MountConfigManager');
1478
+    }
1479
+
1480
+    /**
1481
+     * Get the IniWrapper
1482
+     *
1483
+     * @return IniGetWrapper
1484
+     */
1485
+    public function getIniWrapper() {
1486
+        return $this->query('IniWrapper');
1487
+    }
1488
+
1489
+    /**
1490
+     * @return \OCP\Command\IBus
1491
+     */
1492
+    public function getCommandBus() {
1493
+        return $this->query('AsyncCommandBus');
1494
+    }
1495
+
1496
+    /**
1497
+     * Get the trusted domain helper
1498
+     *
1499
+     * @return TrustedDomainHelper
1500
+     */
1501
+    public function getTrustedDomainHelper() {
1502
+        return $this->query('TrustedDomainHelper');
1503
+    }
1504
+
1505
+    /**
1506
+     * Get the locking provider
1507
+     *
1508
+     * @return \OCP\Lock\ILockingProvider
1509
+     * @since 8.1.0
1510
+     */
1511
+    public function getLockingProvider() {
1512
+        return $this->query('LockingProvider');
1513
+    }
1514
+
1515
+    /**
1516
+     * @return \OCP\Files\Mount\IMountManager
1517
+     **/
1518
+    function getMountManager() {
1519
+        return $this->query('MountManager');
1520
+    }
1521
+
1522
+    /** @return \OCP\Files\Config\IUserMountCache */
1523
+    function getUserMountCache() {
1524
+        return $this->query('UserMountCache');
1525
+    }
1526
+
1527
+    /**
1528
+     * Get the MimeTypeDetector
1529
+     *
1530
+     * @return \OCP\Files\IMimeTypeDetector
1531
+     */
1532
+    public function getMimeTypeDetector() {
1533
+        return $this->query('MimeTypeDetector');
1534
+    }
1535
+
1536
+    /**
1537
+     * Get the MimeTypeLoader
1538
+     *
1539
+     * @return \OCP\Files\IMimeTypeLoader
1540
+     */
1541
+    public function getMimeTypeLoader() {
1542
+        return $this->query('MimeTypeLoader');
1543
+    }
1544
+
1545
+    /**
1546
+     * Get the manager of all the capabilities
1547
+     *
1548
+     * @return \OC\CapabilitiesManager
1549
+     */
1550
+    public function getCapabilitiesManager() {
1551
+        return $this->query('CapabilitiesManager');
1552
+    }
1553
+
1554
+    /**
1555
+     * Get the EventDispatcher
1556
+     *
1557
+     * @return EventDispatcherInterface
1558
+     * @since 8.2.0
1559
+     */
1560
+    public function getEventDispatcher() {
1561
+        return $this->query('EventDispatcher');
1562
+    }
1563
+
1564
+    /**
1565
+     * Get the Notification Manager
1566
+     *
1567
+     * @return \OCP\Notification\IManager
1568
+     * @since 8.2.0
1569
+     */
1570
+    public function getNotificationManager() {
1571
+        return $this->query('NotificationManager');
1572
+    }
1573
+
1574
+    /**
1575
+     * @return \OCP\Comments\ICommentsManager
1576
+     */
1577
+    public function getCommentsManager() {
1578
+        return $this->query('CommentsManager');
1579
+    }
1580
+
1581
+    /**
1582
+     * @return \OC_Defaults
1583
+     */
1584
+    public function getThemingDefaults() {
1585
+        return $this->query('ThemingDefaults');
1586
+    }
1587
+
1588
+    /**
1589
+     * @return \OC\IntegrityCheck\Checker
1590
+     */
1591
+    public function getIntegrityCodeChecker() {
1592
+        return $this->query('IntegrityCodeChecker');
1593
+    }
1594
+
1595
+    /**
1596
+     * @return \OC\Session\CryptoWrapper
1597
+     */
1598
+    public function getSessionCryptoWrapper() {
1599
+        return $this->query('CryptoWrapper');
1600
+    }
1601
+
1602
+    /**
1603
+     * @return CsrfTokenManager
1604
+     */
1605
+    public function getCsrfTokenManager() {
1606
+        return $this->query('CsrfTokenManager');
1607
+    }
1608
+
1609
+    /**
1610
+     * @return Throttler
1611
+     */
1612
+    public function getBruteForceThrottler() {
1613
+        return $this->query('Throttler');
1614
+    }
1615
+
1616
+    /**
1617
+     * @return IContentSecurityPolicyManager
1618
+     */
1619
+    public function getContentSecurityPolicyManager() {
1620
+        return $this->query('ContentSecurityPolicyManager');
1621
+    }
1622
+
1623
+    /**
1624
+     * @return ContentSecurityPolicyNonceManager
1625
+     */
1626
+    public function getContentSecurityPolicyNonceManager() {
1627
+        return $this->query('ContentSecurityPolicyNonceManager');
1628
+    }
1629
+
1630
+    /**
1631
+     * Not a public API as of 8.2, wait for 9.0
1632
+     *
1633
+     * @return \OCA\Files_External\Service\BackendService
1634
+     */
1635
+    public function getStoragesBackendService() {
1636
+        return $this->query('OCA\\Files_External\\Service\\BackendService');
1637
+    }
1638
+
1639
+    /**
1640
+     * Not a public API as of 8.2, wait for 9.0
1641
+     *
1642
+     * @return \OCA\Files_External\Service\GlobalStoragesService
1643
+     */
1644
+    public function getGlobalStoragesService() {
1645
+        return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService');
1646
+    }
1647
+
1648
+    /**
1649
+     * Not a public API as of 8.2, wait for 9.0
1650
+     *
1651
+     * @return \OCA\Files_External\Service\UserGlobalStoragesService
1652
+     */
1653
+    public function getUserGlobalStoragesService() {
1654
+        return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService');
1655
+    }
1656
+
1657
+    /**
1658
+     * Not a public API as of 8.2, wait for 9.0
1659
+     *
1660
+     * @return \OCA\Files_External\Service\UserStoragesService
1661
+     */
1662
+    public function getUserStoragesService() {
1663
+        return $this->query('OCA\\Files_External\\Service\\UserStoragesService');
1664
+    }
1665
+
1666
+    /**
1667
+     * @return \OCP\Share\IManager
1668
+     */
1669
+    public function getShareManager() {
1670
+        return $this->query('ShareManager');
1671
+    }
1672
+
1673
+    /**
1674
+     * Returns the LDAP Provider
1675
+     *
1676
+     * @return \OCP\LDAP\ILDAPProvider
1677
+     */
1678
+    public function getLDAPProvider() {
1679
+        return $this->query('LDAPProvider');
1680
+    }
1681
+
1682
+    /**
1683
+     * @return \OCP\Settings\IManager
1684
+     */
1685
+    public function getSettingsManager() {
1686
+        return $this->query('SettingsManager');
1687
+    }
1688
+
1689
+    /**
1690
+     * @return \OCP\Files\IAppData
1691
+     */
1692
+    public function getAppDataDir($app) {
1693
+        /** @var \OC\Files\AppData\Factory $factory */
1694
+        $factory = $this->query(\OC\Files\AppData\Factory::class);
1695
+        return $factory->get($app);
1696
+    }
1697
+
1698
+    /**
1699
+     * @return \OCP\Lockdown\ILockdownManager
1700
+     */
1701
+    public function getLockdownManager() {
1702
+        return $this->query('LockdownManager');
1703
+    }
1704
+
1705
+    /**
1706
+     * @return \OCP\Federation\ICloudIdManager
1707
+     */
1708
+    public function getCloudIdManager() {
1709
+        return $this->query(ICloudIdManager::class);
1710
+    }
1711 1711
 }
Please login to merge, or discard this patch.
themes/example/defaults.php 1 patch
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -20,145 +20,145 @@
 block discarded – undo
20 20
 
21 21
 class OC_Theme {
22 22
 
23
-	/**
24
-	 * Returns the base URL
25
-	 * @return string URL
26
-	 */
27
-	public function getBaseUrl() {
28
-		return 'https://nextcloud.com';
29
-	}
30
-
31
-	/**
32
-	 * Returns the URL where the sync clients are listed
33
-	 * @return string URL
34
-	 */
35
-	public function getSyncClientUrl() {
36
-		return 'https://nextcloud.com/install/#install-clients';
37
-	}
38
-
39
-	/**
40
-	 * Returns the URL to the App Store for the iOS Client
41
-	 * @return string URL
42
-	 */
43
-	public function getiOSClientUrl() {
44
-		return 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8';
45
-	}
46
-
47
-	/**
48
-	 * Returns the AppId for the App Store for the iOS Client
49
-	 * @return string AppId
50
-	 */
51
-	public function getiTunesAppId() {
52
-		return '1125420102';
53
-	}
54
-
55
-	/**
56
-	 * Returns the URL to Google Play for the Android Client
57
-	 * @return string URL
58
-	 */
59
-	public function getAndroidClientUrl() {
60
-		return 'https://play.google.com/store/apps/details?id=com.nextcloud.client';
61
-	}
62
-
63
-	/**
64
-	 * Returns the documentation URL
65
-	 * @return string URL
66
-	 */
67
-	public function getDocBaseUrl() {
68
-		return 'https://docs.nextcloud.com';
69
-	}
70
-
71
-	/**
72
-	 * Returns the title
73
-	 * @return string title
74
-	 */
75
-	public function getTitle() {
76
-		return 'Custom Cloud';
77
-	}
78
-
79
-	/**
80
-	 * Returns the short name of the software
81
-	 * @return string title
82
-	 */
83
-	public function getName() {
84
-		return 'Custom Cloud';
85
-	}
86
-
87
-	/**
88
-	 * Returns the short name of the software containing HTML strings
89
-	 * @return string title
90
-	 */
91
-	public function getHTMLName() {
92
-		return 'Custom Cloud';
93
-	}
94
-
95
-	/**
96
-	 * Returns entity (e.g. company name) - used for footer, copyright
97
-	 * @return string entity name
98
-	 */
99
-	public function getEntity() {
100
-		return 'Custom Cloud Co.';
101
-	}
102
-
103
-	/**
104
-	 * Returns slogan
105
-	 * @return string slogan
106
-	 */
107
-	public function getSlogan() {
108
-		return 'Your custom cloud, personalized for you!';
109
-	}
110
-
111
-	/**
112
-	 * Returns logo claim
113
-	 * @return string logo claim
114
-	 */
115
-	public function getLogoClaim() {
116
-		return '';
117
-	}
118
-
119
-	/**
120
-	 * Returns short version of the footer
121
-	 * @return string short footer
122
-	 */
123
-	public function getShortFooter() {
124
-		$footer = '© 2016 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'.
125
-			'<br/>' . $this->getSlogan();
126
-
127
-		return $footer;
128
-	}
129
-
130
-	/**
131
-	 * Returns long version of the footer
132
-	 * @return string long footer
133
-	 */
134
-	public function getLongFooter() {
135
-		$footer = '© 2016 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'.
136
-			'<br/>' . $this->getSlogan();
137
-
138
-		return $footer;
139
-	}
140
-
141
-	public function buildDocLinkToKey($key) {
142
-		return $this->getDocBaseUrl() . '/server/11/go.php?to=' . $key;
143
-	}
144
-
145
-
146
-	/**
147
-	 * Returns mail header color
148
-	 * @return string
149
-	 */
150
-	public function getMailHeaderColor() {
151
-		return '#745bca';
152
-	}
153
-
154
-	/**
155
-	 * Returns variables to overload defaults from core/css/variables.scss
156
-	 * @return array
157
-	 */
158
-	public function getScssVariables() {
159
-		return [
160
-			'color-primary' => '#745bca'
161
-		];
162
-	}
23
+    /**
24
+     * Returns the base URL
25
+     * @return string URL
26
+     */
27
+    public function getBaseUrl() {
28
+        return 'https://nextcloud.com';
29
+    }
30
+
31
+    /**
32
+     * Returns the URL where the sync clients are listed
33
+     * @return string URL
34
+     */
35
+    public function getSyncClientUrl() {
36
+        return 'https://nextcloud.com/install/#install-clients';
37
+    }
38
+
39
+    /**
40
+     * Returns the URL to the App Store for the iOS Client
41
+     * @return string URL
42
+     */
43
+    public function getiOSClientUrl() {
44
+        return 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8';
45
+    }
46
+
47
+    /**
48
+     * Returns the AppId for the App Store for the iOS Client
49
+     * @return string AppId
50
+     */
51
+    public function getiTunesAppId() {
52
+        return '1125420102';
53
+    }
54
+
55
+    /**
56
+     * Returns the URL to Google Play for the Android Client
57
+     * @return string URL
58
+     */
59
+    public function getAndroidClientUrl() {
60
+        return 'https://play.google.com/store/apps/details?id=com.nextcloud.client';
61
+    }
62
+
63
+    /**
64
+     * Returns the documentation URL
65
+     * @return string URL
66
+     */
67
+    public function getDocBaseUrl() {
68
+        return 'https://docs.nextcloud.com';
69
+    }
70
+
71
+    /**
72
+     * Returns the title
73
+     * @return string title
74
+     */
75
+    public function getTitle() {
76
+        return 'Custom Cloud';
77
+    }
78
+
79
+    /**
80
+     * Returns the short name of the software
81
+     * @return string title
82
+     */
83
+    public function getName() {
84
+        return 'Custom Cloud';
85
+    }
86
+
87
+    /**
88
+     * Returns the short name of the software containing HTML strings
89
+     * @return string title
90
+     */
91
+    public function getHTMLName() {
92
+        return 'Custom Cloud';
93
+    }
94
+
95
+    /**
96
+     * Returns entity (e.g. company name) - used for footer, copyright
97
+     * @return string entity name
98
+     */
99
+    public function getEntity() {
100
+        return 'Custom Cloud Co.';
101
+    }
102
+
103
+    /**
104
+     * Returns slogan
105
+     * @return string slogan
106
+     */
107
+    public function getSlogan() {
108
+        return 'Your custom cloud, personalized for you!';
109
+    }
110
+
111
+    /**
112
+     * Returns logo claim
113
+     * @return string logo claim
114
+     */
115
+    public function getLogoClaim() {
116
+        return '';
117
+    }
118
+
119
+    /**
120
+     * Returns short version of the footer
121
+     * @return string short footer
122
+     */
123
+    public function getShortFooter() {
124
+        $footer = '© 2016 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'.
125
+            '<br/>' . $this->getSlogan();
126
+
127
+        return $footer;
128
+    }
129
+
130
+    /**
131
+     * Returns long version of the footer
132
+     * @return string long footer
133
+     */
134
+    public function getLongFooter() {
135
+        $footer = '© 2016 <a href="'.$this->getBaseUrl().'" target="_blank\">'.$this->getEntity().'</a>'.
136
+            '<br/>' . $this->getSlogan();
137
+
138
+        return $footer;
139
+    }
140
+
141
+    public function buildDocLinkToKey($key) {
142
+        return $this->getDocBaseUrl() . '/server/11/go.php?to=' . $key;
143
+    }
144
+
145
+
146
+    /**
147
+     * Returns mail header color
148
+     * @return string
149
+     */
150
+    public function getMailHeaderColor() {
151
+        return '#745bca';
152
+    }
153
+
154
+    /**
155
+     * Returns variables to overload defaults from core/css/variables.scss
156
+     * @return array
157
+     */
158
+    public function getScssVariables() {
159
+        return [
160
+            'color-primary' => '#745bca'
161
+        ];
162
+    }
163 163
 
164 164
 }
Please login to merge, or discard this patch.
lib/private/legacy/defaults.php 2 patches
Indentation   +240 added lines, -240 removed lines patch added patch discarded remove patch
@@ -31,269 +31,269 @@
 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 $defaultMailHeaderColor;
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 $defaultMailHeaderColor;
50 50
 
51
-	function __construct() {
52
-		$this->l = \OC::$server->getL10N('lib');
51
+    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 = '11'; // used to generate doc links
64
-		$this->defaultSlogan = $this->l->t('a safe home for all your data');
65
-		$this->defaultLogoClaim = '';
66
-		$this->defaultMailHeaderColor = '#0082c9'; /* header color of mail notifications */
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 = '11'; // used to generate doc links
64
+        $this->defaultSlogan = $this->l->t('a safe home for all your data');
65
+        $this->defaultLogoClaim = '';
66
+        $this->defaultMailHeaderColor = '#0082c9'; /* header color of mail notifications */
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
-	 */
267
-	public function buildDocLinkToKey($key) {
268
-		if ($this->themeExist('buildDocLinkToKey')) {
269
-			return $this->theme->buildDocLinkToKey($key);
270
-		}
271
-		return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
272
-	}
264
+    /**
265
+     * @param string $key
266
+     */
267
+    public function buildDocLinkToKey($key) {
268
+        if ($this->themeExist('buildDocLinkToKey')) {
269
+            return $this->theme->buildDocLinkToKey($key);
270
+        }
271
+        return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
272
+    }
273 273
 
274
-	/**
275
-	 * Returns mail header color
276
-	 * @return string
277
-	 */
278
-	public function getMailHeaderColor() {
279
-		if ($this->themeExist('getMailHeaderColor')) {
280
-			return $this->theme->getMailHeaderColor();
281
-		} else {
282
-			return $this->defaultMailHeaderColor;
283
-		}
284
-	}
274
+    /**
275
+     * Returns mail header color
276
+     * @return string
277
+     */
278
+    public function getMailHeaderColor() {
279
+        if ($this->themeExist('getMailHeaderColor')) {
280
+            return $this->theme->getMailHeaderColor();
281
+        } else {
282
+            return $this->defaultMailHeaderColor;
283
+        }
284
+    }
285 285
 
286
-	/**
287
-	 * @return array scss variables to overwrite
288
-	 */
289
-	public function getScssVariables() {
290
-		if($this->themeExist('getScssVariables')) {
291
-			return $this->theme->getScssVariables();
292
-		}
293
-		return [];
294
-	}
286
+    /**
287
+     * @return array scss variables to overwrite
288
+     */
289
+    public function getScssVariables() {
290
+        if($this->themeExist('getScssVariables')) {
291
+            return $this->theme->getScssVariables();
292
+        }
293
+        return [];
294
+    }
295 295
 
296
-	public function shouldReplaceIcons() {
297
-		return false;
298
-	}
296
+    public function shouldReplaceIcons() {
297
+        return false;
298
+    }
299 299
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 		$this->defaultLogoClaim = '';
66 66
 		$this->defaultMailHeaderColor = '#0082c9'; /* header color of mail notifications */
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;
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		if ($this->themeExist('buildDocLinkToKey')) {
269 269
 			return $this->theme->buildDocLinkToKey($key);
270 270
 		}
271
-		return $this->getDocBaseUrl() . '/server/' . $this->defaultDocVersion . '/go.php?to=' . $key;
271
+		return $this->getDocBaseUrl().'/server/'.$this->defaultDocVersion.'/go.php?to='.$key;
272 272
 	}
273 273
 
274 274
 	/**
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 	 * @return array scss variables to overwrite
288 288
 	 */
289 289
 	public function getScssVariables() {
290
-		if($this->themeExist('getScssVariables')) {
290
+		if ($this->themeExist('getScssVariables')) {
291 291
 			return $this->theme->getScssVariables();
292 292
 		}
293 293
 		return [];
Please login to merge, or discard this patch.
lib/private/TemplateLayout.php 1 patch
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -40,231 +40,231 @@
 block discarded – undo
40 40
 
41 41
 class TemplateLayout extends \OC_Template {
42 42
 
43
-	private static $versionHash = '';
43
+    private static $versionHash = '';
44 44
 
45
-	/**
46
-	 * @var \OCP\IConfig
47
-	 */
48
-	private $config;
45
+    /**
46
+     * @var \OCP\IConfig
47
+     */
48
+    private $config;
49 49
 
50
-	/**
51
-	 * @param string $renderAs
52
-	 * @param string $appId application id
53
-	 */
54
-	public function __construct( $renderAs, $appId = '' ) {
50
+    /**
51
+     * @param string $renderAs
52
+     * @param string $appId application id
53
+     */
54
+    public function __construct( $renderAs, $appId = '' ) {
55 55
 
56
-		// yes - should be injected ....
57
-		$this->config = \OC::$server->getConfig();
56
+        // yes - should be injected ....
57
+        $this->config = \OC::$server->getConfig();
58 58
 
59
-		// Decide which page we show
60
-		if($renderAs == 'user') {
61
-			parent::__construct( 'core', 'layout.user' );
62
-			if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
63
-				$this->assign('bodyid', 'body-settings');
64
-			}else{
65
-				$this->assign('bodyid', 'body-user');
66
-			}
59
+        // Decide which page we show
60
+        if($renderAs == 'user') {
61
+            parent::__construct( 'core', 'layout.user' );
62
+            if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
63
+                $this->assign('bodyid', 'body-settings');
64
+            }else{
65
+                $this->assign('bodyid', 'body-user');
66
+            }
67 67
 
68
-			// Code integrity notification
69
-			$integrityChecker = \OC::$server->getIntegrityCodeChecker();
70
-			if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
71
-				\OCP\Util::addScript('core', 'integritycheck-failed-notification');
72
-			}
68
+            // Code integrity notification
69
+            $integrityChecker = \OC::$server->getIntegrityCodeChecker();
70
+            if(\OC_User::isAdminUser(\OC_User::getUser()) && $integrityChecker->isCodeCheckEnforced() && !$integrityChecker->hasPassedCheck()) {
71
+                \OCP\Util::addScript('core', 'integritycheck-failed-notification');
72
+            }
73 73
 
74
-			// Add navigation entry
75
-			$this->assign( 'application', '');
76
-			$this->assign( 'appid', $appId );
77
-			$navigation = \OC_App::getNavigation();
78
-			$this->assign( 'navigation', $navigation);
79
-			$navigation = \OC_App::getHeaderNavigation();
80
-			$this->assign( 'headernavigation', $navigation);
81
-			$settingsNavigation = \OC_App::getSettingsNavigation();
82
-			$this->assign( 'settingsnavigation', $settingsNavigation);
83
-			foreach($navigation as $entry) {
84
-				if ($entry['active']) {
85
-					$this->assign( 'application', $entry['name'] );
86
-					break;
87
-				}
88
-			}
74
+            // Add navigation entry
75
+            $this->assign( 'application', '');
76
+            $this->assign( 'appid', $appId );
77
+            $navigation = \OC_App::getNavigation();
78
+            $this->assign( 'navigation', $navigation);
79
+            $navigation = \OC_App::getHeaderNavigation();
80
+            $this->assign( 'headernavigation', $navigation);
81
+            $settingsNavigation = \OC_App::getSettingsNavigation();
82
+            $this->assign( 'settingsnavigation', $settingsNavigation);
83
+            foreach($navigation as $entry) {
84
+                if ($entry['active']) {
85
+                    $this->assign( 'application', $entry['name'] );
86
+                    break;
87
+                }
88
+            }
89 89
 			
90
-			foreach($settingsNavigation as $entry) {
91
-				if ($entry['active']) {
92
-					$this->assign( 'application', $entry['name'] );
93
-					break;
94
-				}
95
-			}
96
-			$userDisplayName = \OC_User::getDisplayName();
97
-			$appsMgmtActive = strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0;
98
-			if ($appsMgmtActive) {
99
-				$l = \OC::$server->getL10N('lib');
100
-				$this->assign('application', $l->t('Apps'));
101
-			}
102
-			$this->assign('user_displayname', $userDisplayName);
103
-			$this->assign('user_uid', \OC_User::getUser());
104
-			$this->assign('appsmanagement_active', $appsMgmtActive);
90
+            foreach($settingsNavigation as $entry) {
91
+                if ($entry['active']) {
92
+                    $this->assign( 'application', $entry['name'] );
93
+                    break;
94
+                }
95
+            }
96
+            $userDisplayName = \OC_User::getDisplayName();
97
+            $appsMgmtActive = strpos(\OC::$server->getRequest()->getRequestUri(), \OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')) === 0;
98
+            if ($appsMgmtActive) {
99
+                $l = \OC::$server->getL10N('lib');
100
+                $this->assign('application', $l->t('Apps'));
101
+            }
102
+            $this->assign('user_displayname', $userDisplayName);
103
+            $this->assign('user_uid', \OC_User::getUser());
104
+            $this->assign('appsmanagement_active', $appsMgmtActive);
105 105
 
106
-			if (\OC_User::getUser() === false) {
107
-				$this->assign('userAvatarSet', false);
108
-			} else {
109
-				$this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
110
-				$this->assign('userAvatarVersion', \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
111
-			}
106
+            if (\OC_User::getUser() === false) {
107
+                $this->assign('userAvatarSet', false);
108
+            } else {
109
+                $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
110
+                $this->assign('userAvatarVersion', \OC::$server->getConfig()->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
111
+            }
112 112
 
113
-		} else if ($renderAs == 'error') {
114
-			parent::__construct('core', 'layout.guest', '', false);
115
-			$this->assign('bodyid', 'body-login');
116
-		} else if ($renderAs == 'guest') {
117
-			parent::__construct('core', 'layout.guest');
118
-			$this->assign('bodyid', 'body-login');
119
-		} else {
120
-			parent::__construct('core', 'layout.base');
113
+        } else if ($renderAs == 'error') {
114
+            parent::__construct('core', 'layout.guest', '', false);
115
+            $this->assign('bodyid', 'body-login');
116
+        } else if ($renderAs == 'guest') {
117
+            parent::__construct('core', 'layout.guest');
118
+            $this->assign('bodyid', 'body-login');
119
+        } else {
120
+            parent::__construct('core', 'layout.base');
121 121
 
122
-		}
123
-		// Send the language to our layouts
124
-		$this->assign('language', \OC::$server->getL10NFactory()->findLanguage());
122
+        }
123
+        // Send the language to our layouts
124
+        $this->assign('language', \OC::$server->getL10NFactory()->findLanguage());
125 125
 
126
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
127
-			if (empty(self::$versionHash)) {
128
-				$v = \OC_App::getAppVersions();
129
-				$v['core'] = implode('.', \OCP\Util::getVersion());
130
-				self::$versionHash = md5(implode(',', $v));
131
-			}
132
-		} else {
133
-			self::$versionHash = md5('not installed');
134
-		}
126
+        if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
127
+            if (empty(self::$versionHash)) {
128
+                $v = \OC_App::getAppVersions();
129
+                $v['core'] = implode('.', \OCP\Util::getVersion());
130
+                self::$versionHash = md5(implode(',', $v));
131
+            }
132
+        } else {
133
+            self::$versionHash = md5('not installed');
134
+        }
135 135
 
136
-		// Add the js files
137
-		$jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
138
-		$this->assign('jsfiles', array());
139
-		if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
140
-			if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
141
-				$jsConfigHelper = new JSConfigHelper(
142
-					\OC::$server->getL10N('core'),
143
-					\OC::$server->getThemingDefaults(),
144
-					\OC::$server->getAppManager(),
145
-					\OC::$server->getSession(),
146
-					\OC::$server->getUserSession()->getUser(),
147
-					\OC::$server->getConfig(),
148
-					\OC::$server->getGroupManager(),
149
-					\OC::$server->getIniWrapper(),
150
-					\OC::$server->getURLGenerator()
151
-				);
152
-				$this->assign('inline_ocjs', $jsConfigHelper->getConfig());
153
-				$this->assign('foo', 'bar');
154
-			} else {
155
-				$this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
156
-			}
157
-		}
158
-		foreach($jsFiles as $info) {
159
-			$web = $info[1];
160
-			$file = $info[2];
161
-			$this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
162
-		}
136
+        // Add the js files
137
+        $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
138
+        $this->assign('jsfiles', array());
139
+        if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
140
+            if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
141
+                $jsConfigHelper = new JSConfigHelper(
142
+                    \OC::$server->getL10N('core'),
143
+                    \OC::$server->getThemingDefaults(),
144
+                    \OC::$server->getAppManager(),
145
+                    \OC::$server->getSession(),
146
+                    \OC::$server->getUserSession()->getUser(),
147
+                    \OC::$server->getConfig(),
148
+                    \OC::$server->getGroupManager(),
149
+                    \OC::$server->getIniWrapper(),
150
+                    \OC::$server->getURLGenerator()
151
+                );
152
+                $this->assign('inline_ocjs', $jsConfigHelper->getConfig());
153
+                $this->assign('foo', 'bar');
154
+            } else {
155
+                $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
156
+            }
157
+        }
158
+        foreach($jsFiles as $info) {
159
+            $web = $info[1];
160
+            $file = $info[2];
161
+            $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
162
+        }
163 163
 
164
-		try {
165
-			$pathInfo = \OC::$server->getRequest()->getPathInfo();
166
-		} catch (\Exception $e) {
167
-			$pathInfo = '';
168
-		}
164
+        try {
165
+            $pathInfo = \OC::$server->getRequest()->getPathInfo();
166
+        } catch (\Exception $e) {
167
+            $pathInfo = '';
168
+        }
169 169
 
170
-		// Do not initialise scss appdata until we have a fully installed instance
171
-		// Do not load scss for update, errors, installation or login page
172
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)
173
-			&& !\OCP\Util::needUpgrade()
174
-			&& $pathInfo !== ''
175
-			&& !preg_match('/^\/login/', $pathInfo)) {
176
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
177
-		} else {
178
-			// If we ignore the scss compiler,
179
-			// we need to load the guest css fallback
180
-			\OC_Util::addStyle('guest');
181
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
182
-		}
170
+        // Do not initialise scss appdata until we have a fully installed instance
171
+        // Do not load scss for update, errors, installation or login page
172
+        if(\OC::$server->getSystemConfig()->getValue('installed', false)
173
+            && !\OCP\Util::needUpgrade()
174
+            && $pathInfo !== ''
175
+            && !preg_match('/^\/login/', $pathInfo)) {
176
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
177
+        } else {
178
+            // If we ignore the scss compiler,
179
+            // we need to load the guest css fallback
180
+            \OC_Util::addStyle('guest');
181
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
182
+        }
183 183
 
184
-		$this->assign('cssfiles', array());
185
-		$this->assign('printcssfiles', []);
186
-		$this->assign('versionHash', self::$versionHash);
187
-		foreach($cssFiles as $info) {
188
-			$web = $info[1];
189
-			$file = $info[2];
184
+        $this->assign('cssfiles', array());
185
+        $this->assign('printcssfiles', []);
186
+        $this->assign('versionHash', self::$versionHash);
187
+        foreach($cssFiles as $info) {
188
+            $web = $info[1];
189
+            $file = $info[2];
190 190
 
191
-			if (substr($file, -strlen('print.css')) === 'print.css') {
192
-				$this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
193
-			} else {
194
-				$this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix()  );
195
-			}
196
-		}
197
-	}
191
+            if (substr($file, -strlen('print.css')) === 'print.css') {
192
+                $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
193
+            } else {
194
+                $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix()  );
195
+            }
196
+        }
197
+    }
198 198
 
199
-	protected function getVersionHashSuffix() {
200
-		if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
201
-			// allows chrome workspace mapping in debug mode
202
-			return "";
203
-		}
199
+    protected function getVersionHashSuffix() {
200
+        if(\OC::$server->getConfig()->getSystemValue('debug', false)) {
201
+            // allows chrome workspace mapping in debug mode
202
+            return "";
203
+        }
204 204
 
205
-		return '?v=' . self::$versionHash;
206
-	}
205
+        return '?v=' . self::$versionHash;
206
+    }
207 207
 
208
-	/**
209
-	 * @param array $styles
210
-	 * @return array
211
-	 */
212
-	static public function findStylesheetFiles($styles, $compileScss = true) {
213
-		// Read the selected theme from the config file
214
-		$theme = \OC_Util::getTheme();
208
+    /**
209
+     * @param array $styles
210
+     * @return array
211
+     */
212
+    static public function findStylesheetFiles($styles, $compileScss = true) {
213
+        // Read the selected theme from the config file
214
+        $theme = \OC_Util::getTheme();
215 215
 
216
-		if($compileScss) {
217
-			$SCSSCacher = new SCSSCacher(
218
-				\OC::$server->getLogger(),
219
-				\OC::$server->getAppDataDir('css'),
220
-				\OC::$server->getURLGenerator(),
221
-				\OC::$server->getConfig(),
222
-				\OC::$server->getThemingDefaults(),
223
-				\OC::$SERVERROOT
224
-			);
225
-		} else {
226
-			$SCSSCacher = null;
227
-		}
216
+        if($compileScss) {
217
+            $SCSSCacher = new SCSSCacher(
218
+                \OC::$server->getLogger(),
219
+                \OC::$server->getAppDataDir('css'),
220
+                \OC::$server->getURLGenerator(),
221
+                \OC::$server->getConfig(),
222
+                \OC::$server->getThemingDefaults(),
223
+                \OC::$SERVERROOT
224
+            );
225
+        } else {
226
+            $SCSSCacher = null;
227
+        }
228 228
 
229
-		$locator = new \OC\Template\CSSResourceLocator(
230
-			\OC::$server->getLogger(),
231
-			$theme,
232
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
233
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
234
-			$SCSSCacher);
235
-		$locator->find($styles);
236
-		return $locator->getResources();
237
-	}
229
+        $locator = new \OC\Template\CSSResourceLocator(
230
+            \OC::$server->getLogger(),
231
+            $theme,
232
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
233
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
234
+            $SCSSCacher);
235
+        $locator->find($styles);
236
+        return $locator->getResources();
237
+    }
238 238
 
239
-	/**
240
-	 * @param array $scripts
241
-	 * @return array
242
-	 */
243
-	static public function findJavascriptFiles($scripts) {
244
-		// Read the selected theme from the config file
245
-		$theme = \OC_Util::getTheme();
239
+    /**
240
+     * @param array $scripts
241
+     * @return array
242
+     */
243
+    static public function findJavascriptFiles($scripts) {
244
+        // Read the selected theme from the config file
245
+        $theme = \OC_Util::getTheme();
246 246
 
247
-		$locator = new \OC\Template\JSResourceLocator(
248
-			\OC::$server->getLogger(),
249
-			$theme,
250
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
251
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ));
252
-		$locator->find($scripts);
253
-		return $locator->getResources();
254
-	}
247
+        $locator = new \OC\Template\JSResourceLocator(
248
+            \OC::$server->getLogger(),
249
+            $theme,
250
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
251
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ));
252
+        $locator->find($scripts);
253
+        return $locator->getResources();
254
+    }
255 255
 
256
-	/**
257
-	 * Converts the absolute file path to a relative path from \OC::$SERVERROOT
258
-	 * @param string $filePath Absolute path
259
-	 * @return string Relative path
260
-	 * @throws \Exception If $filePath is not under \OC::$SERVERROOT
261
-	 */
262
-	public static function convertToRelativePath($filePath) {
263
-		$relativePath = explode(\OC::$SERVERROOT, $filePath);
264
-		if(count($relativePath) !== 2) {
265
-			throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
266
-		}
256
+    /**
257
+     * Converts the absolute file path to a relative path from \OC::$SERVERROOT
258
+     * @param string $filePath Absolute path
259
+     * @return string Relative path
260
+     * @throws \Exception If $filePath is not under \OC::$SERVERROOT
261
+     */
262
+    public static function convertToRelativePath($filePath) {
263
+        $relativePath = explode(\OC::$SERVERROOT, $filePath);
264
+        if(count($relativePath) !== 2) {
265
+            throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
266
+        }
267 267
 
268
-		return $relativePath[1];
269
-	}
268
+        return $relativePath[1];
269
+    }
270 270
 }
Please login to merge, or discard this patch.
lib/private/Template/SCSSCacher.php 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -125,8 +125,6 @@
 block discarded – undo
125 125
 
126 126
 	/**
127 127
 	 * Check if the variables file has changed
128
-	 * @param string $fileNameCSS
129
-	 * @param ISimpleFolder $folder
130 128
 	 * @return bool
131 129
 	 */
132 130
 	private function variablesChanged() {
Please login to merge, or discard this patch.
Indentation   +217 added lines, -217 removed lines patch added patch discarded remove patch
@@ -35,221 +35,221 @@
 block discarded – undo
35 35
 
36 36
 class SCSSCacher {
37 37
 
38
-	/** @var ILogger */
39
-	protected $logger;
40
-
41
-	/** @var IAppData */
42
-	protected $appData;
43
-
44
-	/** @var IURLGenerator */
45
-	protected $urlGenerator;
46
-
47
-	/** @var IConfig */
48
-	protected $config;
49
-
50
-	/** @var string */
51
-	protected $serverRoot;
52
-
53
-	/**
54
-	 * @param ILogger $logger
55
-	 * @param IAppData $appData
56
-	 * @param IURLGenerator $urlGenerator
57
-	 * @param IConfig $config
58
-	 * @param \OC_Defaults $defaults
59
-	 * @param string $serverRoot
60
-	 */
61
-	public function __construct(ILogger $logger, IAppData $appData, IURLGenerator $urlGenerator, IConfig $config, \OC_Defaults $defaults, $serverRoot) {
62
-		$this->logger = $logger;
63
-		$this->appData = $appData;
64
-		$this->urlGenerator = $urlGenerator;
65
-		$this->config = $config;
66
-		$this->defaults = $defaults;
67
-		$this->serverRoot = $serverRoot;
68
-	}
69
-
70
-	/**
71
-	 * Process the caching process if needed
72
-	 * @param string $root Root path to the nextcloud installation
73
-	 * @param string $file
74
-	 * @param string $app The app name
75
-	 * @return boolean
76
-	 */
77
-	public function process($root, $file, $app) {
78
-		$path = explode('/', $root . '/' . $file);
79
-
80
-		$fileNameSCSS = array_pop($path);
81
-		$fileNameCSS = str_replace('.scss', '.css', $fileNameSCSS);
82
-
83
-		$path = implode('/', $path);
84
-
85
-		$webDir = substr($path, strlen($this->serverRoot)+1);
86
-
87
-		try {
88
-			$folder = $this->appData->getFolder($app);
89
-		} catch(NotFoundException $e) {
90
-			// creating css appdata folder
91
-			$folder = $this->appData->newFolder($app);
92
-		}
93
-
94
-		if(!$this->variablesChanged() && $this->isCached($fileNameCSS, $folder, $path)) {
95
-			return true;
96
-		}
97
-		return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir);
98
-	}
99
-
100
-	/**
101
-	 * Check if the file is cached or not
102
-	 * @param string $fileNameCSS
103
-	 * @param ISimpleFolder $folder
104
-	 * @param string $path
105
-	 * @return boolean
106
-	 */
107
-	private function isCached($fileNameCSS, ISimpleFolder $folder, $path) {
108
-		try {
109
-			$cachedFile = $folder->getFile($fileNameCSS);
110
-			if ($cachedFile->getSize() > 0) {
111
-				$depFile = $folder->getFile($fileNameCSS . '.deps');
112
-				$deps = json_decode($depFile->getContent(), true);
113
-
114
-				foreach ($deps as $file=>$mtime) {
115
-					if (!file_exists($file) || filemtime($file) > $mtime) {
116
-						return false;
117
-					}
118
-				}
119
-			}
120
-			return true;
121
-		} catch(NotFoundException $e) {
122
-			return false;
123
-		}
124
-	}
125
-
126
-	/**
127
-	 * Check if the variables file has changed
128
-	 * @param string $fileNameCSS
129
-	 * @param ISimpleFolder $folder
130
-	 * @return bool
131
-	 */
132
-	private function variablesChanged() {
133
-		$injectedVariables = $this->getInjectedVariables();
134
-		if($injectedVariables !== '' && $this->config->getAppValue('core', 'scss.variables') !== md5($injectedVariables)) {
135
-			$this->resetCache();
136
-			$this->config->setAppValue('core', 'scss.variables', md5($injectedVariables));
137
-			return true;
138
-		}
139
-		return false;
140
-	}
141
-
142
-	/**
143
-	 * Cache the file with AppData
144
-	 * @param string $path
145
-	 * @param string $fileNameCSS
146
-	 * @param string $fileNameSCSS
147
-	 * @param ISimpleFolder $folder
148
-	 * @param string $webDir
149
-	 * @return boolean
150
-	 */
151
-	private function cache($path, $fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $webDir) {
152
-		$scss = new Compiler();
153
-		$scss->setImportPaths([
154
-			$path,
155
-			\OC::$SERVERROOT . '/core/css/',
156
-		]);
157
-		if($this->config->getSystemValue('debug')) {
158
-			// Debug mode
159
-			$scss->setFormatter(Expanded::class);
160
-			$scss->setLineNumberStyle(Compiler::LINE_COMMENTS);
161
-		} else {
162
-			// Compression
163
-			$scss->setFormatter(Crunched::class);
164
-		}
165
-
166
-		try {
167
-			$cachedfile = $folder->getFile($fileNameCSS);
168
-		} catch(NotFoundException $e) {
169
-			$cachedfile = $folder->newFile($fileNameCSS);
170
-		}
171
-
172
-		$depFileName = $fileNameCSS . '.deps';
173
-		try {
174
-			$depFile = $folder->getFile($depFileName);
175
-		} catch (NotFoundException $e) {
176
-			$depFile = $folder->newFile($depFileName);
177
-		}
178
-
179
-		// Compile
180
-		try {
181
-			$compiledScss = $scss->compile(
182
-				'@import "variables.scss";' .
183
-				$this->getInjectedVariables() .
184
-				'@import "'.$fileNameSCSS.'";');
185
-		} catch(ParserException $e) {
186
-			$this->logger->error($e, ['app' => 'core']);
187
-			return false;
188
-		}
189
-
190
-		try {
191
-			$cachedfile->putContent($this->rebaseUrls($compiledScss, $webDir));
192
-			$depFile->putContent(json_encode($scss->getParsedFiles()));
193
-			$this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']);
194
-			return true;
195
-		} catch(NotPermittedException $e) {
196
-			return false;
197
-		}
198
-	}
199
-
200
-	/**
201
-	 * Reset scss cache by deleting all generated css files
202
-	 * We need to regenerate all files when variables change
203
-	 */
204
-	private function resetCache() {
205
-		foreach ($this->appData->getDirectoryListing() as $folder) {
206
-			foreach ($folder->getDirectoryListing() as $file) {
207
-				if(substr($file->getName(), -3) === "css" || substr($file->getName(), -4) === "deps") {
208
-					$file->delete();
209
-				}
210
-			}
211
-		}
212
-	}
213
-
214
-	/**
215
-	 * @return string SCSS code for variables from OC_Defaults
216
-	 */
217
-	private function getInjectedVariables() {
218
-		$variables = '';
219
-		foreach ($this->defaults->getScssVariables() as $key => $value) {
220
-			$variables .= '$' . $key . ': ' . $value . ';';
221
-		}
222
-		return $variables;
223
-	}
224
-
225
-	/**
226
-	 * Add the correct uri prefix to make uri valid again
227
-	 * @param string $css
228
-	 * @param string $webDir
229
-	 * @return string
230
-	 */
231
-	private function rebaseUrls($css, $webDir) {
232
-		$re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x';
233
-		// OC\Route\Router:75
234
-		if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
235
-			$subst = 'url(\'../../'.$webDir.'/$1\')';	
236
-		} else {
237
-			$subst = 'url(\'../../../'.$webDir.'/$1\')';
238
-		}
239
-		return preg_replace($re, $subst, $css);
240
-	}
241
-
242
-	/**
243
-	 * Return the cached css file uri
244
-	 * @param string $appName the app name
245
-	 * @param string $fileName
246
-	 * @return string
247
-	 */
248
-	public function getCachedSCSS($appName, $fileName) {
249
-		$tmpfileLoc = explode('/', $fileName);
250
-		$fileName = array_pop($tmpfileLoc);
251
-		$fileName = str_replace('.scss', '.css', $fileName);
252
-
253
-		return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1);
254
-	}
38
+    /** @var ILogger */
39
+    protected $logger;
40
+
41
+    /** @var IAppData */
42
+    protected $appData;
43
+
44
+    /** @var IURLGenerator */
45
+    protected $urlGenerator;
46
+
47
+    /** @var IConfig */
48
+    protected $config;
49
+
50
+    /** @var string */
51
+    protected $serverRoot;
52
+
53
+    /**
54
+     * @param ILogger $logger
55
+     * @param IAppData $appData
56
+     * @param IURLGenerator $urlGenerator
57
+     * @param IConfig $config
58
+     * @param \OC_Defaults $defaults
59
+     * @param string $serverRoot
60
+     */
61
+    public function __construct(ILogger $logger, IAppData $appData, IURLGenerator $urlGenerator, IConfig $config, \OC_Defaults $defaults, $serverRoot) {
62
+        $this->logger = $logger;
63
+        $this->appData = $appData;
64
+        $this->urlGenerator = $urlGenerator;
65
+        $this->config = $config;
66
+        $this->defaults = $defaults;
67
+        $this->serverRoot = $serverRoot;
68
+    }
69
+
70
+    /**
71
+     * Process the caching process if needed
72
+     * @param string $root Root path to the nextcloud installation
73
+     * @param string $file
74
+     * @param string $app The app name
75
+     * @return boolean
76
+     */
77
+    public function process($root, $file, $app) {
78
+        $path = explode('/', $root . '/' . $file);
79
+
80
+        $fileNameSCSS = array_pop($path);
81
+        $fileNameCSS = str_replace('.scss', '.css', $fileNameSCSS);
82
+
83
+        $path = implode('/', $path);
84
+
85
+        $webDir = substr($path, strlen($this->serverRoot)+1);
86
+
87
+        try {
88
+            $folder = $this->appData->getFolder($app);
89
+        } catch(NotFoundException $e) {
90
+            // creating css appdata folder
91
+            $folder = $this->appData->newFolder($app);
92
+        }
93
+
94
+        if(!$this->variablesChanged() && $this->isCached($fileNameCSS, $folder, $path)) {
95
+            return true;
96
+        }
97
+        return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir);
98
+    }
99
+
100
+    /**
101
+     * Check if the file is cached or not
102
+     * @param string $fileNameCSS
103
+     * @param ISimpleFolder $folder
104
+     * @param string $path
105
+     * @return boolean
106
+     */
107
+    private function isCached($fileNameCSS, ISimpleFolder $folder, $path) {
108
+        try {
109
+            $cachedFile = $folder->getFile($fileNameCSS);
110
+            if ($cachedFile->getSize() > 0) {
111
+                $depFile = $folder->getFile($fileNameCSS . '.deps');
112
+                $deps = json_decode($depFile->getContent(), true);
113
+
114
+                foreach ($deps as $file=>$mtime) {
115
+                    if (!file_exists($file) || filemtime($file) > $mtime) {
116
+                        return false;
117
+                    }
118
+                }
119
+            }
120
+            return true;
121
+        } catch(NotFoundException $e) {
122
+            return false;
123
+        }
124
+    }
125
+
126
+    /**
127
+     * Check if the variables file has changed
128
+     * @param string $fileNameCSS
129
+     * @param ISimpleFolder $folder
130
+     * @return bool
131
+     */
132
+    private function variablesChanged() {
133
+        $injectedVariables = $this->getInjectedVariables();
134
+        if($injectedVariables !== '' && $this->config->getAppValue('core', 'scss.variables') !== md5($injectedVariables)) {
135
+            $this->resetCache();
136
+            $this->config->setAppValue('core', 'scss.variables', md5($injectedVariables));
137
+            return true;
138
+        }
139
+        return false;
140
+    }
141
+
142
+    /**
143
+     * Cache the file with AppData
144
+     * @param string $path
145
+     * @param string $fileNameCSS
146
+     * @param string $fileNameSCSS
147
+     * @param ISimpleFolder $folder
148
+     * @param string $webDir
149
+     * @return boolean
150
+     */
151
+    private function cache($path, $fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $webDir) {
152
+        $scss = new Compiler();
153
+        $scss->setImportPaths([
154
+            $path,
155
+            \OC::$SERVERROOT . '/core/css/',
156
+        ]);
157
+        if($this->config->getSystemValue('debug')) {
158
+            // Debug mode
159
+            $scss->setFormatter(Expanded::class);
160
+            $scss->setLineNumberStyle(Compiler::LINE_COMMENTS);
161
+        } else {
162
+            // Compression
163
+            $scss->setFormatter(Crunched::class);
164
+        }
165
+
166
+        try {
167
+            $cachedfile = $folder->getFile($fileNameCSS);
168
+        } catch(NotFoundException $e) {
169
+            $cachedfile = $folder->newFile($fileNameCSS);
170
+        }
171
+
172
+        $depFileName = $fileNameCSS . '.deps';
173
+        try {
174
+            $depFile = $folder->getFile($depFileName);
175
+        } catch (NotFoundException $e) {
176
+            $depFile = $folder->newFile($depFileName);
177
+        }
178
+
179
+        // Compile
180
+        try {
181
+            $compiledScss = $scss->compile(
182
+                '@import "variables.scss";' .
183
+                $this->getInjectedVariables() .
184
+                '@import "'.$fileNameSCSS.'";');
185
+        } catch(ParserException $e) {
186
+            $this->logger->error($e, ['app' => 'core']);
187
+            return false;
188
+        }
189
+
190
+        try {
191
+            $cachedfile->putContent($this->rebaseUrls($compiledScss, $webDir));
192
+            $depFile->putContent(json_encode($scss->getParsedFiles()));
193
+            $this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']);
194
+            return true;
195
+        } catch(NotPermittedException $e) {
196
+            return false;
197
+        }
198
+    }
199
+
200
+    /**
201
+     * Reset scss cache by deleting all generated css files
202
+     * We need to regenerate all files when variables change
203
+     */
204
+    private function resetCache() {
205
+        foreach ($this->appData->getDirectoryListing() as $folder) {
206
+            foreach ($folder->getDirectoryListing() as $file) {
207
+                if(substr($file->getName(), -3) === "css" || substr($file->getName(), -4) === "deps") {
208
+                    $file->delete();
209
+                }
210
+            }
211
+        }
212
+    }
213
+
214
+    /**
215
+     * @return string SCSS code for variables from OC_Defaults
216
+     */
217
+    private function getInjectedVariables() {
218
+        $variables = '';
219
+        foreach ($this->defaults->getScssVariables() as $key => $value) {
220
+            $variables .= '$' . $key . ': ' . $value . ';';
221
+        }
222
+        return $variables;
223
+    }
224
+
225
+    /**
226
+     * Add the correct uri prefix to make uri valid again
227
+     * @param string $css
228
+     * @param string $webDir
229
+     * @return string
230
+     */
231
+    private function rebaseUrls($css, $webDir) {
232
+        $re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x';
233
+        // OC\Route\Router:75
234
+        if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
235
+            $subst = 'url(\'../../'.$webDir.'/$1\')';	
236
+        } else {
237
+            $subst = 'url(\'../../../'.$webDir.'/$1\')';
238
+        }
239
+        return preg_replace($re, $subst, $css);
240
+    }
241
+
242
+    /**
243
+     * Return the cached css file uri
244
+     * @param string $appName the app name
245
+     * @param string $fileName
246
+     * @return string
247
+     */
248
+    public function getCachedSCSS($appName, $fileName) {
249
+        $tmpfileLoc = explode('/', $fileName);
250
+        $fileName = array_pop($tmpfileLoc);
251
+        $fileName = str_replace('.scss', '.css', $fileName);
252
+
253
+        return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1);
254
+    }
255 255
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -75,23 +75,23 @@  discard block
 block discarded – undo
75 75
 	 * @return boolean
76 76
 	 */
77 77
 	public function process($root, $file, $app) {
78
-		$path = explode('/', $root . '/' . $file);
78
+		$path = explode('/', $root.'/'.$file);
79 79
 
80 80
 		$fileNameSCSS = array_pop($path);
81 81
 		$fileNameCSS = str_replace('.scss', '.css', $fileNameSCSS);
82 82
 
83 83
 		$path = implode('/', $path);
84 84
 
85
-		$webDir = substr($path, strlen($this->serverRoot)+1);
85
+		$webDir = substr($path, strlen($this->serverRoot) + 1);
86 86
 
87 87
 		try {
88 88
 			$folder = $this->appData->getFolder($app);
89
-		} catch(NotFoundException $e) {
89
+		} catch (NotFoundException $e) {
90 90
 			// creating css appdata folder
91 91
 			$folder = $this->appData->newFolder($app);
92 92
 		}
93 93
 
94
-		if(!$this->variablesChanged() && $this->isCached($fileNameCSS, $folder, $path)) {
94
+		if (!$this->variablesChanged() && $this->isCached($fileNameCSS, $folder, $path)) {
95 95
 			return true;
96 96
 		}
97 97
 		return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir);
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		try {
109 109
 			$cachedFile = $folder->getFile($fileNameCSS);
110 110
 			if ($cachedFile->getSize() > 0) {
111
-				$depFile = $folder->getFile($fileNameCSS . '.deps');
111
+				$depFile = $folder->getFile($fileNameCSS.'.deps');
112 112
 				$deps = json_decode($depFile->getContent(), true);
113 113
 
114 114
 				foreach ($deps as $file=>$mtime) {
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 				}
119 119
 			}
120 120
 			return true;
121
-		} catch(NotFoundException $e) {
121
+		} catch (NotFoundException $e) {
122 122
 			return false;
123 123
 		}
124 124
 	}
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 */
132 132
 	private function variablesChanged() {
133 133
 		$injectedVariables = $this->getInjectedVariables();
134
-		if($injectedVariables !== '' && $this->config->getAppValue('core', 'scss.variables') !== md5($injectedVariables)) {
134
+		if ($injectedVariables !== '' && $this->config->getAppValue('core', 'scss.variables') !== md5($injectedVariables)) {
135 135
 			$this->resetCache();
136 136
 			$this->config->setAppValue('core', 'scss.variables', md5($injectedVariables));
137 137
 			return true;
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 		$scss = new Compiler();
153 153
 		$scss->setImportPaths([
154 154
 			$path,
155
-			\OC::$SERVERROOT . '/core/css/',
155
+			\OC::$SERVERROOT.'/core/css/',
156 156
 		]);
157
-		if($this->config->getSystemValue('debug')) {
157
+		if ($this->config->getSystemValue('debug')) {
158 158
 			// Debug mode
159 159
 			$scss->setFormatter(Expanded::class);
160 160
 			$scss->setLineNumberStyle(Compiler::LINE_COMMENTS);
@@ -165,11 +165,11 @@  discard block
 block discarded – undo
165 165
 
166 166
 		try {
167 167
 			$cachedfile = $folder->getFile($fileNameCSS);
168
-		} catch(NotFoundException $e) {
168
+		} catch (NotFoundException $e) {
169 169
 			$cachedfile = $folder->newFile($fileNameCSS);
170 170
 		}
171 171
 
172
-		$depFileName = $fileNameCSS . '.deps';
172
+		$depFileName = $fileNameCSS.'.deps';
173 173
 		try {
174 174
 			$depFile = $folder->getFile($depFileName);
175 175
 		} catch (NotFoundException $e) {
@@ -179,10 +179,10 @@  discard block
 block discarded – undo
179 179
 		// Compile
180 180
 		try {
181 181
 			$compiledScss = $scss->compile(
182
-				'@import "variables.scss";' .
183
-				$this->getInjectedVariables() .
182
+				'@import "variables.scss";'.
183
+				$this->getInjectedVariables().
184 184
 				'@import "'.$fileNameSCSS.'";');
185
-		} catch(ParserException $e) {
185
+		} catch (ParserException $e) {
186 186
 			$this->logger->error($e, ['app' => 'core']);
187 187
 			return false;
188 188
 		}
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 			$depFile->putContent(json_encode($scss->getParsedFiles()));
193 193
 			$this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']);
194 194
 			return true;
195
-		} catch(NotPermittedException $e) {
195
+		} catch (NotPermittedException $e) {
196 196
 			return false;
197 197
 		}
198 198
 	}
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	private function resetCache() {
205 205
 		foreach ($this->appData->getDirectoryListing() as $folder) {
206 206
 			foreach ($folder->getDirectoryListing() as $file) {
207
-				if(substr($file->getName(), -3) === "css" || substr($file->getName(), -4) === "deps") {
207
+				if (substr($file->getName(), -3) === "css" || substr($file->getName(), -4) === "deps") {
208 208
 					$file->delete();
209 209
 				}
210 210
 			}
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	private function getInjectedVariables() {
218 218
 		$variables = '';
219 219
 		foreach ($this->defaults->getScssVariables() as $key => $value) {
220
-			$variables .= '$' . $key . ': ' . $value . ';';
220
+			$variables .= '$'.$key.': '.$value.';';
221 221
 		}
222 222
 		return $variables;
223 223
 	}
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	private function rebaseUrls($css, $webDir) {
232 232
 		$re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x';
233 233
 		// OC\Route\Router:75
234
-		if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
234
+		if (($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
235 235
 			$subst = 'url(\'../../'.$webDir.'/$1\')';	
236 236
 		} else {
237 237
 			$subst = 'url(\'../../../'.$webDir.'/$1\')';
Please login to merge, or discard this patch.
apps/theming/lib/Controller/ThemingController.php 2 patches
Indentation   +310 added lines, -310 removed lines patch added patch discarded remove patch
@@ -56,332 +56,332 @@  discard block
 block discarded – undo
56 56
  * @package OCA\Theming\Controller
57 57
  */
58 58
 class ThemingController extends Controller {
59
-	/** @var ThemingDefaults */
60
-	private $themingDefaults;
61
-	/** @var Util */
62
-	private $util;
63
-	/** @var ITimeFactory */
64
-	private $timeFactory;
65
-	/** @var IL10N */
66
-	private $l;
67
-	/** @var IConfig */
68
-	private $config;
69
-	/** @var ITempManager */
70
-	private $tempManager;
71
-	/** @var IAppData */
72
-	private $appData;
73
-	/** @var IURLGenerator */
74
-	private $urlGenerator;
75
-	/** @var Factory */
76
-	private $appDataFactory;
77
-	/** @var ILogger */
78
-	private $logger;
59
+    /** @var ThemingDefaults */
60
+    private $themingDefaults;
61
+    /** @var Util */
62
+    private $util;
63
+    /** @var ITimeFactory */
64
+    private $timeFactory;
65
+    /** @var IL10N */
66
+    private $l;
67
+    /** @var IConfig */
68
+    private $config;
69
+    /** @var ITempManager */
70
+    private $tempManager;
71
+    /** @var IAppData */
72
+    private $appData;
73
+    /** @var IURLGenerator */
74
+    private $urlGenerator;
75
+    /** @var Factory */
76
+    private $appDataFactory;
77
+    /** @var ILogger */
78
+    private $logger;
79 79
 
80
-	/**
81
-	 * ThemingController constructor.
82
-	 *
83
-	 * @param string $appName
84
-	 * @param IRequest $request
85
-	 * @param IConfig $config
86
-	 * @param ThemingDefaults $themingDefaults
87
-	 * @param Util $util
88
-	 * @param ITimeFactory $timeFactory
89
-	 * @param IL10N $l
90
-	 * @param ITempManager $tempManager
91
-	 * @param IAppData $appData
92
-	 */
93
-	public function __construct(
94
-		$appName,
95
-		IRequest $request,
96
-		IConfig $config,
97
-		ThemingDefaults $themingDefaults,
98
-		Util $util,
99
-		ITimeFactory $timeFactory,
100
-		IL10N $l,
101
-		ITempManager $tempManager,
102
-		IAppData $appData,
103
-		Factory $factory,
104
-		ILogger $logger,
105
-		IURLGenerator $urlGenerator
106
-	) {
107
-		parent::__construct($appName, $request);
80
+    /**
81
+     * ThemingController constructor.
82
+     *
83
+     * @param string $appName
84
+     * @param IRequest $request
85
+     * @param IConfig $config
86
+     * @param ThemingDefaults $themingDefaults
87
+     * @param Util $util
88
+     * @param ITimeFactory $timeFactory
89
+     * @param IL10N $l
90
+     * @param ITempManager $tempManager
91
+     * @param IAppData $appData
92
+     */
93
+    public function __construct(
94
+        $appName,
95
+        IRequest $request,
96
+        IConfig $config,
97
+        ThemingDefaults $themingDefaults,
98
+        Util $util,
99
+        ITimeFactory $timeFactory,
100
+        IL10N $l,
101
+        ITempManager $tempManager,
102
+        IAppData $appData,
103
+        Factory $factory,
104
+        ILogger $logger,
105
+        IURLGenerator $urlGenerator
106
+    ) {
107
+        parent::__construct($appName, $request);
108 108
 
109
-		$this->themingDefaults = $themingDefaults;
110
-		$this->util = $util;
111
-		$this->timeFactory = $timeFactory;
112
-		$this->l = $l;
113
-		$this->config = $config;
114
-		$this->tempManager = $tempManager;
115
-		$this->appData = $appData;
116
-		$this->appDataFactory = $factory;
117
-		$this->logger = $logger;
118
-		$this->urlGenerator = $urlGenerator;
119
-	}
109
+        $this->themingDefaults = $themingDefaults;
110
+        $this->util = $util;
111
+        $this->timeFactory = $timeFactory;
112
+        $this->l = $l;
113
+        $this->config = $config;
114
+        $this->tempManager = $tempManager;
115
+        $this->appData = $appData;
116
+        $this->appDataFactory = $factory;
117
+        $this->logger = $logger;
118
+        $this->urlGenerator = $urlGenerator;
119
+    }
120 120
 
121
-	/**
122
-	 * @param string $setting
123
-	 * @param string $value
124
-	 * @return DataResponse
125
-	 * @internal param string $color
126
-	 */
127
-	public function updateStylesheet($setting, $value) {
128
-		$value = trim($value);
129
-		switch ($setting) {
130
-			case 'name':
131
-				if (strlen($value) > 250) {
132
-					return new DataResponse([
133
-						'data' => [
134
-							'message' => $this->l->t('The given name is too long'),
135
-						],
136
-						'status' => 'error'
137
-					]);
138
-				}
139
-				break;
140
-			case 'url':
141
-				if (strlen($value) > 500) {
142
-					return new DataResponse([
143
-						'data' => [
144
-							'message' => $this->l->t('The given web address is too long'),
145
-						],
146
-						'status' => 'error'
147
-					]);
148
-				}
149
-				break;
150
-			case 'slogan':
151
-				if (strlen($value) > 500) {
152
-					return new DataResponse([
153
-						'data' => [
154
-							'message' => $this->l->t('The given slogan is too long'),
155
-						],
156
-						'status' => 'error'
157
-					]);
158
-				}
159
-				break;
160
-			case 'color':
161
-				if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
162
-					return new DataResponse([
163
-						'data' => [
164
-							'message' => $this->l->t('The given color is invalid'),
165
-						],
166
-						'status' => 'error'
167
-					]);
168
-				}
169
-				break;
170
-		}
121
+    /**
122
+     * @param string $setting
123
+     * @param string $value
124
+     * @return DataResponse
125
+     * @internal param string $color
126
+     */
127
+    public function updateStylesheet($setting, $value) {
128
+        $value = trim($value);
129
+        switch ($setting) {
130
+            case 'name':
131
+                if (strlen($value) > 250) {
132
+                    return new DataResponse([
133
+                        'data' => [
134
+                            'message' => $this->l->t('The given name is too long'),
135
+                        ],
136
+                        'status' => 'error'
137
+                    ]);
138
+                }
139
+                break;
140
+            case 'url':
141
+                if (strlen($value) > 500) {
142
+                    return new DataResponse([
143
+                        'data' => [
144
+                            'message' => $this->l->t('The given web address is too long'),
145
+                        ],
146
+                        'status' => 'error'
147
+                    ]);
148
+                }
149
+                break;
150
+            case 'slogan':
151
+                if (strlen($value) > 500) {
152
+                    return new DataResponse([
153
+                        'data' => [
154
+                            'message' => $this->l->t('The given slogan is too long'),
155
+                        ],
156
+                        'status' => 'error'
157
+                    ]);
158
+                }
159
+                break;
160
+            case 'color':
161
+                if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
162
+                    return new DataResponse([
163
+                        'data' => [
164
+                            'message' => $this->l->t('The given color is invalid'),
165
+                        ],
166
+                        'status' => 'error'
167
+                    ]);
168
+                }
169
+                break;
170
+        }
171 171
 
172
-		$this->themingDefaults->set($setting, $value);
173
-		return new DataResponse(
174
-			[
175
-				'data' =>
176
-					[
177
-						'message' => $this->l->t('Saved')
178
-					],
179
-				'status' => 'success'
180
-			]
181
-		);
182
-	}
172
+        $this->themingDefaults->set($setting, $value);
173
+        return new DataResponse(
174
+            [
175
+                'data' =>
176
+                    [
177
+                        'message' => $this->l->t('Saved')
178
+                    ],
179
+                'status' => 'success'
180
+            ]
181
+        );
182
+    }
183 183
 
184
-	/**
185
-	 * Update the logos and background image
186
-	 *
187
-	 * @return DataResponse
188
-	 */
189
-	public function updateLogo() {
190
-		$newLogo = $this->request->getUploadedFile('uploadlogo');
191
-		$newBackgroundLogo = $this->request->getUploadedFile('upload-login-background');
192
-		if (empty($newLogo) && empty($newBackgroundLogo)) {
193
-			return new DataResponse(
194
-				[
195
-					'data' => [
196
-						'message' => $this->l->t('No file uploaded')
197
-					]
198
-				],
199
-				Http::STATUS_UNPROCESSABLE_ENTITY
200
-			);
201
-		}
184
+    /**
185
+     * Update the logos and background image
186
+     *
187
+     * @return DataResponse
188
+     */
189
+    public function updateLogo() {
190
+        $newLogo = $this->request->getUploadedFile('uploadlogo');
191
+        $newBackgroundLogo = $this->request->getUploadedFile('upload-login-background');
192
+        if (empty($newLogo) && empty($newBackgroundLogo)) {
193
+            return new DataResponse(
194
+                [
195
+                    'data' => [
196
+                        'message' => $this->l->t('No file uploaded')
197
+                    ]
198
+                ],
199
+                Http::STATUS_UNPROCESSABLE_ENTITY
200
+            );
201
+        }
202 202
 
203
-		$name = '';
204
-		try {
205
-			$folder = $this->appData->getFolder('images');
206
-		} catch (NotFoundException $e) {
207
-			$folder = $this->appData->newFolder('images');
208
-		}
203
+        $name = '';
204
+        try {
205
+            $folder = $this->appData->getFolder('images');
206
+        } catch (NotFoundException $e) {
207
+            $folder = $this->appData->newFolder('images');
208
+        }
209 209
 
210
-		if (!empty($newLogo)) {
211
-			$target = $folder->newFile('logo');
212
-			$target->putContent(file_get_contents($newLogo['tmp_name'], 'r'));
213
-			$this->themingDefaults->set('logoMime', $newLogo['type']);
214
-			$name = $newLogo['name'];
215
-		}
216
-		if (!empty($newBackgroundLogo)) {
217
-			$target = $folder->newFile('background');
218
-			$image = @imagecreatefromstring(file_get_contents($newBackgroundLogo['tmp_name'], 'r'));
219
-			if ($image === false) {
220
-				return new DataResponse(
221
-					[
222
-						'data' => [
223
-							'message' => $this->l->t('Unsupported image type'),
224
-						],
225
-						'status' => 'failure',
226
-					],
227
-					Http::STATUS_UNPROCESSABLE_ENTITY
228
-				);
229
-			}
210
+        if (!empty($newLogo)) {
211
+            $target = $folder->newFile('logo');
212
+            $target->putContent(file_get_contents($newLogo['tmp_name'], 'r'));
213
+            $this->themingDefaults->set('logoMime', $newLogo['type']);
214
+            $name = $newLogo['name'];
215
+        }
216
+        if (!empty($newBackgroundLogo)) {
217
+            $target = $folder->newFile('background');
218
+            $image = @imagecreatefromstring(file_get_contents($newBackgroundLogo['tmp_name'], 'r'));
219
+            if ($image === false) {
220
+                return new DataResponse(
221
+                    [
222
+                        'data' => [
223
+                            'message' => $this->l->t('Unsupported image type'),
224
+                        ],
225
+                        'status' => 'failure',
226
+                    ],
227
+                    Http::STATUS_UNPROCESSABLE_ENTITY
228
+                );
229
+            }
230 230
 
231
-			// Optimize the image since some people may upload images that will be
232
-			// either to big or are not progressive rendering.
233
-			$tmpFile = $this->tempManager->getTemporaryFile();
234
-			if (function_exists('imagescale')) {
235
-				// FIXME: Once PHP 5.5.0 is a requirement the above check can be removed
236
-				// Workaround for https://bugs.php.net/bug.php?id=65171
237
-				$newHeight = imagesy($image) / (imagesx($image) / 1920);
238
-				$image = imagescale($image, 1920, $newHeight);
239
-			}
240
-			imageinterlace($image, 1);
241
-			imagejpeg($image, $tmpFile, 75);
242
-			imagedestroy($image);
231
+            // Optimize the image since some people may upload images that will be
232
+            // either to big or are not progressive rendering.
233
+            $tmpFile = $this->tempManager->getTemporaryFile();
234
+            if (function_exists('imagescale')) {
235
+                // FIXME: Once PHP 5.5.0 is a requirement the above check can be removed
236
+                // Workaround for https://bugs.php.net/bug.php?id=65171
237
+                $newHeight = imagesy($image) / (imagesx($image) / 1920);
238
+                $image = imagescale($image, 1920, $newHeight);
239
+            }
240
+            imageinterlace($image, 1);
241
+            imagejpeg($image, $tmpFile, 75);
242
+            imagedestroy($image);
243 243
 
244
-			$target->putContent(file_get_contents($tmpFile, 'r'));
245
-			$this->themingDefaults->set('backgroundMime', $newBackgroundLogo['type']);
246
-			$name = $newBackgroundLogo['name'];
247
-		}
244
+            $target->putContent(file_get_contents($tmpFile, 'r'));
245
+            $this->themingDefaults->set('backgroundMime', $newBackgroundLogo['type']);
246
+            $name = $newBackgroundLogo['name'];
247
+        }
248 248
 
249
-		return new DataResponse(
250
-			[
251
-				'data' =>
252
-					[
253
-						'name' => $name,
254
-						'message' => $this->l->t('Saved')
255
-					],
256
-				'status' => 'success'
257
-			]
258
-		);
259
-	}
249
+        return new DataResponse(
250
+            [
251
+                'data' =>
252
+                    [
253
+                        'name' => $name,
254
+                        'message' => $this->l->t('Saved')
255
+                    ],
256
+                'status' => 'success'
257
+            ]
258
+        );
259
+    }
260 260
 
261
-	/**
262
-	 * Revert setting to default value
263
-	 *
264
-	 * @param string $setting setting which should be reverted
265
-	 * @return DataResponse
266
-	 */
267
-	public function undo($setting) {
268
-		$value = $this->themingDefaults->undo($setting);
269
-		return new DataResponse(
270
-			[
271
-				'data' =>
272
-					[
273
-						'value' => $value,
274
-						'message' => $this->l->t('Saved')
275
-					],
276
-				'status' => 'success'
277
-			]
278
-		);
279
-	}
261
+    /**
262
+     * Revert setting to default value
263
+     *
264
+     * @param string $setting setting which should be reverted
265
+     * @return DataResponse
266
+     */
267
+    public function undo($setting) {
268
+        $value = $this->themingDefaults->undo($setting);
269
+        return new DataResponse(
270
+            [
271
+                'data' =>
272
+                    [
273
+                        'value' => $value,
274
+                        'message' => $this->l->t('Saved')
275
+                    ],
276
+                'status' => 'success'
277
+            ]
278
+        );
279
+    }
280 280
 
281
-	/**
282
-	 * @PublicPage
283
-	 * @NoCSRFRequired
284
-	 *
285
-	 * @return FileDisplayResponse|NotFoundResponse
286
-	 */
287
-	public function getLogo() {
288
-		try {
289
-			/** @var File $file */
290
-			$file = $this->appData->getFolder('images')->getFile('logo');
291
-		} catch (NotFoundException $e) {
292
-			return new NotFoundResponse();
293
-		}
281
+    /**
282
+     * @PublicPage
283
+     * @NoCSRFRequired
284
+     *
285
+     * @return FileDisplayResponse|NotFoundResponse
286
+     */
287
+    public function getLogo() {
288
+        try {
289
+            /** @var File $file */
290
+            $file = $this->appData->getFolder('images')->getFile('logo');
291
+        } catch (NotFoundException $e) {
292
+            return new NotFoundResponse();
293
+        }
294 294
 
295
-		$response = new FileDisplayResponse($file);
296
-		$response->cacheFor(3600);
297
-		$expires = new \DateTime();
298
-		$expires->setTimestamp($this->timeFactory->getTime());
299
-		$expires->add(new \DateInterval('PT24H'));
300
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
301
-		$response->addHeader('Pragma', 'cache');
302
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', ''));
303
-		return $response;
304
-	}
295
+        $response = new FileDisplayResponse($file);
296
+        $response->cacheFor(3600);
297
+        $expires = new \DateTime();
298
+        $expires->setTimestamp($this->timeFactory->getTime());
299
+        $expires->add(new \DateInterval('PT24H'));
300
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
301
+        $response->addHeader('Pragma', 'cache');
302
+        $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'logoMime', ''));
303
+        return $response;
304
+    }
305 305
 
306
-	/**
307
-	 * @PublicPage
308
-	 * @NoCSRFRequired
309
-	 *
310
-	 * @return FileDisplayResponse|NotFoundResponse
311
-	 */
312
-	public function getLoginBackground() {
313
-		try {
314
-			/** @var File $file */
315
-			$file = $this->appData->getFolder('images')->getFile('background');
316
-		} catch (NotFoundException $e) {
317
-			return new NotFoundResponse();
318
-		}
306
+    /**
307
+     * @PublicPage
308
+     * @NoCSRFRequired
309
+     *
310
+     * @return FileDisplayResponse|NotFoundResponse
311
+     */
312
+    public function getLoginBackground() {
313
+        try {
314
+            /** @var File $file */
315
+            $file = $this->appData->getFolder('images')->getFile('background');
316
+        } catch (NotFoundException $e) {
317
+            return new NotFoundResponse();
318
+        }
319 319
 
320
-		$response = new FileDisplayResponse($file);
321
-		$response->cacheFor(3600);
322
-		$expires = new \DateTime();
323
-		$expires->setTimestamp($this->timeFactory->getTime());
324
-		$expires->add(new \DateInterval('PT24H'));
325
-		$response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
326
-		$response->addHeader('Pragma', 'cache');
327
-		$response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', ''));
328
-		return $response;
329
-	}
320
+        $response = new FileDisplayResponse($file);
321
+        $response->cacheFor(3600);
322
+        $expires = new \DateTime();
323
+        $expires->setTimestamp($this->timeFactory->getTime());
324
+        $expires->add(new \DateInterval('PT24H'));
325
+        $response->addHeader('Expires', $expires->format(\DateTime::RFC2822));
326
+        $response->addHeader('Pragma', 'cache');
327
+        $response->addHeader('Content-Type', $this->config->getAppValue($this->appName, 'backgroundMime', ''));
328
+        return $response;
329
+    }
330 330
 
331
-	/**
332
-	 * @NoCSRFRequired
333
-	 * @PublicPage
334
-	 *
335
-	 * @return FileDisplayResponse|NotFoundResponse
336
-	 */
337
-	public function getStylesheet() {
338
-		$appDataCss = $this->appDataFactory->get('css');
339
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
331
+    /**
332
+     * @NoCSRFRequired
333
+     * @PublicPage
334
+     *
335
+     * @return FileDisplayResponse|NotFoundResponse
336
+     */
337
+    public function getStylesheet() {
338
+        $appDataCss = $this->appDataFactory->get('css');
339
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
340 340
 
341
-		/* SCSSCacher is required here
341
+        /* SCSSCacher is required here
342 342
 		 * We cannot rely on automatic caching done by \OC_Util::addStyle,
343 343
 		 * since we need to add the cacheBuster value to the url
344 344
 		 */
345
-		$SCSSCacher = new SCSSCacher(
346
-			$this->logger,
347
-			$appDataCss,
348
-			$this->urlGenerator,
349
-			$this->config,
350
-			$this->themingDefaults,
351
-			\OC::$SERVERROOT
352
-		);
353
-		$appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1);
354
-		$SCSSCacher->process(
355
-			\OC::$SERVERROOT,
356
-			$appPath . '/css/theming.scss',
357
-			$cacheBusterValue
358
-		);
345
+        $SCSSCacher = new SCSSCacher(
346
+            $this->logger,
347
+            $appDataCss,
348
+            $this->urlGenerator,
349
+            $this->config,
350
+            $this->themingDefaults,
351
+            \OC::$SERVERROOT
352
+        );
353
+        $appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1);
354
+        $SCSSCacher->process(
355
+            \OC::$SERVERROOT,
356
+            $appPath . '/css/theming.scss',
357
+            $cacheBusterValue
358
+        );
359 359
 
360
-		try {
361
-			$folder = $appDataCss->getFolder($cacheBusterValue);
362
-			$cssFile = $folder->getFile('theming.css');
363
-			$response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
364
-			$response->cacheFor(86400);
365
-			$expires = new \DateTime();
366
-			$expires->setTimestamp($this->timeFactory->getTime());
367
-			$expires->add(new \DateInterval('PT24H'));
368
-			$response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
369
-			$response->addHeader('Pragma', 'cache');
370
-			return $response;
371
-		} catch (NotFoundException $e) {
372
-			return new NotFoundResponse();
373
-		}
374
-	}
360
+        try {
361
+            $folder = $appDataCss->getFolder($cacheBusterValue);
362
+            $cssFile = $folder->getFile('theming.css');
363
+            $response = new FileDisplayResponse($cssFile, Http::STATUS_OK, ['Content-Type' => 'text/css']);
364
+            $response->cacheFor(86400);
365
+            $expires = new \DateTime();
366
+            $expires->setTimestamp($this->timeFactory->getTime());
367
+            $expires->add(new \DateInterval('PT24H'));
368
+            $response->addHeader('Expires', $expires->format(\DateTime::RFC1123));
369
+            $response->addHeader('Pragma', 'cache');
370
+            return $response;
371
+        } catch (NotFoundException $e) {
372
+            return new NotFoundResponse();
373
+        }
374
+    }
375 375
 
376
-	/**
377
-	 * @NoCSRFRequired
378
-	 * @PublicPage
379
-	 *
380
-	 * @return DataDownloadResponse
381
-	 */
382
-	public function getJavascript() {
383
-		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
384
-		$responseJS = '(function() {
376
+    /**
377
+     * @NoCSRFRequired
378
+     * @PublicPage
379
+     *
380
+     * @return DataDownloadResponse
381
+     */
382
+    public function getJavascript() {
383
+        $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
384
+        $responseJS = '(function() {
385 385
 	OCA.Theming = {
386 386
 		name: ' . json_encode($this->themingDefaults->getName()) . ',
387 387
 		url: ' . json_encode($this->themingDefaults->getBaseUrl()) . ',
@@ -391,10 +391,10 @@  discard block
 block discarded – undo
391 391
 		cacheBuster: ' . json_encode($cacheBusterValue) . '
392 392
 	};
393 393
 })();';
394
-		$response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
395
-		$response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
396
-		$response->addHeader('Pragma', 'cache');
397
-		$response->cacheFor(3600);
398
-		return $response;
399
-	}
394
+        $response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
395
+        $response->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
396
+        $response->addHeader('Pragma', 'cache');
397
+        $response->cacheFor(3600);
398
+        return $response;
399
+    }
400 400
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		$appPath = substr(\OC::$server->getAppManager()->getAppPath('theming'), strlen(\OC::$SERVERROOT) + 1);
354 354
 		$SCSSCacher->process(
355 355
 			\OC::$SERVERROOT,
356
-			$appPath . '/css/theming.scss',
356
+			$appPath.'/css/theming.scss',
357 357
 			$cacheBusterValue
358 358
 		);
359 359
 
@@ -383,12 +383,12 @@  discard block
 block discarded – undo
383 383
 		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
384 384
 		$responseJS = '(function() {
385 385
 	OCA.Theming = {
386
-		name: ' . json_encode($this->themingDefaults->getName()) . ',
387
-		url: ' . json_encode($this->themingDefaults->getBaseUrl()) . ',
388
-		slogan: ' . json_encode($this->themingDefaults->getSlogan()) . ',
389
-		color: ' . json_encode($this->themingDefaults->getMailHeaderColor()) . ',
390
-		inverted: ' . json_encode($this->util->invertTextColor($this->themingDefaults->getMailHeaderColor())) . ',
391
-		cacheBuster: ' . json_encode($cacheBusterValue) . '
386
+		name: ' . json_encode($this->themingDefaults->getName()).',
387
+		url: ' . json_encode($this->themingDefaults->getBaseUrl()).',
388
+		slogan: ' . json_encode($this->themingDefaults->getSlogan()).',
389
+		color: ' . json_encode($this->themingDefaults->getMailHeaderColor()).',
390
+		inverted: ' . json_encode($this->util->invertTextColor($this->themingDefaults->getMailHeaderColor())).',
391
+		cacheBuster: ' . json_encode($cacheBusterValue).'
392 392
 	};
393 393
 })();';
394 394
 		$response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
Please login to merge, or discard this patch.