Passed
Push — master ( b306a8...3e64be )
by Roeland
09:52 queued 10s
created
lib/private/TemplateLayout.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@
 block discarded – undo
61 61
 			parent::__construct( 'core', 'layout.user' );
62 62
 			if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
63 63
 				$this->assign('bodyid', 'body-settings');
64
-			}else{
64
+			} else{
65 65
 				$this->assign('bodyid', 'body-user');
66 66
 			}
67 67
 
Please login to merge, or discard this patch.
Indentation   +309 added lines, -309 removed lines patch added patch discarded remove patch
@@ -47,313 +47,313 @@
 block discarded – undo
47 47
 
48 48
 class TemplateLayout extends \OC_Template {
49 49
 
50
-	private static $versionHash = '';
51
-
52
-	/**
53
-	 * @var \OCP\IConfig
54
-	 */
55
-	private $config;
56
-
57
-	/**
58
-	 * @param string $renderAs
59
-	 * @param string $appId application id
60
-	 */
61
-	public function __construct( $renderAs, $appId = '' ) {
62
-
63
-		// yes - should be injected ....
64
-		$this->config = \OC::$server->getConfig();
65
-
66
-		if(\OCP\Util::isIE()) {
67
-			\OC_Util::addStyle('ie');
68
-		}
69
-
70
-		// Decide which page we show
71
-		if($renderAs === 'user') {
72
-			parent::__construct( 'core', 'layout.user' );
73
-			if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
74
-				$this->assign('bodyid', 'body-settings');
75
-			}else{
76
-				$this->assign('bodyid', 'body-user');
77
-			}
78
-
79
-			// Add navigation entry
80
-			$this->assign( 'application', '');
81
-			$this->assign( 'appid', $appId );
82
-			$navigation = \OC::$server->getNavigationManager()->getAll();
83
-			$this->assign( 'navigation', $navigation);
84
-			$settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings');
85
-			$this->assign( 'settingsnavigation', $settingsNavigation);
86
-			foreach($navigation as $entry) {
87
-				if ($entry['active']) {
88
-					$this->assign( 'application', $entry['name'] );
89
-					break;
90
-				}
91
-			}
92
-
93
-			foreach($settingsNavigation as $entry) {
94
-				if ($entry['active']) {
95
-					$this->assign( 'application', $entry['name'] );
96
-					break;
97
-				}
98
-			}
99
-			$userDisplayName = \OC_User::getDisplayName();
100
-			$this->assign('user_displayname', $userDisplayName);
101
-			$this->assign('user_uid', \OC_User::getUser());
102
-
103
-			if (\OC_User::getUser() === false) {
104
-				$this->assign('userAvatarSet', false);
105
-			} else {
106
-				$this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
107
-				$this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
108
-			}
109
-
110
-			// check if app menu icons should be inverted
111
-			try {
112
-				/** @var \OCA\Theming\Util $util */
113
-				$util = \OC::$server->query(\OCA\Theming\Util::class);
114
-				$this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary()));
115
-			} catch (\OCP\AppFramework\QueryException $e) {
116
-				$this->assign('themingInvertMenu', false);
117
-			} catch (\OCP\AutoloadNotAllowedException $e) {
118
-				$this->assign('themingInvertMenu', false);
119
-			}
120
-
121
-		} else if ($renderAs === 'error') {
122
-			parent::__construct('core', 'layout.guest', '', false);
123
-			$this->assign('bodyid', 'body-login');
124
-			$this->assign('user_displayname', '');
125
-			$this->assign('user_uid', '');
126
-		} else if ($renderAs === 'guest') {
127
-			parent::__construct('core', 'layout.guest');
128
-			\OC_Util::addStyle('guest');
129
-			$this->assign('bodyid', 'body-login');
130
-
131
-			$userDisplayName = \OC_User::getDisplayName();
132
-			$this->assign('user_displayname', $userDisplayName);
133
-			$this->assign('user_uid', \OC_User::getUser());
134
-		} else if ($renderAs === 'public') {
135
-			parent::__construct('core', 'layout.public');
136
-			$this->assign( 'appid', $appId );
137
-			$this->assign('bodyid', 'body-public');
138
-
139
-			/** @var IRegistry $subscription */
140
-			$subscription = \OC::$server->query(IRegistry::class);
141
-			$showSimpleSignup = $this->config->getSystemValueBool('simpleSignUpLink.shown', true);
142
-			if ($showSimpleSignup && $subscription->delegateHasValidSubscription()) {
143
-				$showSimpleSignup = false;
144
-			}
145
-			$this->assign('showSimpleSignUpLink', $showSimpleSignup);
146
-		} else {
147
-			parent::__construct('core', 'layout.base');
148
-
149
-		}
150
-		// Send the language and the locale to our layouts
151
-		$lang = \OC::$server->getL10NFactory()->findLanguage();
152
-		$locale = \OC::$server->getL10NFactory()->findLocale($lang);
153
-
154
-		$lang = str_replace('_', '-', $lang);
155
-		$this->assign('language', $lang);
156
-		$this->assign('locale', $locale);
157
-
158
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
159
-			if (empty(self::$versionHash)) {
160
-				$v = \OC_App::getAppVersions();
161
-				$v['core'] = implode('.', \OCP\Util::getVersion());
162
-				self::$versionHash = substr(md5(implode(',', $v)), 0, 8);
163
-			}
164
-		} else {
165
-			self::$versionHash = md5('not installed');
166
-		}
167
-
168
-		// Add the js files
169
-		$jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
170
-		$this->assign('jsfiles', array());
171
-		if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
172
-			if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
173
-				$jsConfigHelper = new JSConfigHelper(
174
-					\OC::$server->getL10N('lib'),
175
-					\OC::$server->query(Defaults::class),
176
-					\OC::$server->getAppManager(),
177
-					\OC::$server->getSession(),
178
-					\OC::$server->getUserSession()->getUser(),
179
-					$this->config,
180
-					\OC::$server->getGroupManager(),
181
-					\OC::$server->getIniWrapper(),
182
-					\OC::$server->getURLGenerator(),
183
-					\OC::$server->getCapabilitiesManager()
184
-				);
185
-				$this->assign('inline_ocjs', $jsConfigHelper->getConfig());
186
-			} else {
187
-				$this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
188
-			}
189
-		}
190
-		foreach($jsFiles as $info) {
191
-			$web = $info[1];
192
-			$file = $info[2];
193
-			$this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
194
-		}
195
-
196
-		try {
197
-			$pathInfo = \OC::$server->getRequest()->getPathInfo();
198
-		} catch (\Exception $e) {
199
-			$pathInfo = '';
200
-		}
201
-
202
-		// Do not initialise scss appdata until we have a fully installed instance
203
-		// Do not load scss for update, errors, installation or login page
204
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)
205
-			&& !\OCP\Util::needUpgrade()
206
-			&& $pathInfo !== ''
207
-			&& !preg_match('/^\/login/', $pathInfo)
208
-			&& $renderAs !== 'error'
209
-		) {
210
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
211
-		} else {
212
-			// If we ignore the scss compiler,
213
-			// we need to load the guest css fallback
214
-			\OC_Util::addStyle('guest');
215
-			$cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
216
-		}
217
-
218
-		$this->assign('cssfiles', array());
219
-		$this->assign('printcssfiles', []);
220
-		$this->assign('versionHash', self::$versionHash);
221
-		foreach($cssFiles as $info) {
222
-			$web = $info[1];
223
-			$file = $info[2];
224
-
225
-			if (substr($file, -strlen('print.css')) === 'print.css') {
226
-				$this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
227
-			} else {
228
-				$suffix = $this->getVersionHashSuffix($web, $file);
229
-
230
-				if (strpos($file, '?v=') == false) {
231
-					$this->append( 'cssfiles', $web.'/'.$file . $suffix);
232
-				} else {
233
-					$this->append( 'cssfiles', $web.'/'.$file . '-' . substr($suffix, 3));
234
-				}
235
-
236
-			}
237
-		}
238
-
239
-		/** @var InitialStateService $initialState */
240
-		$initialState = \OC::$server->query(InitialStateService::class);
241
-		$this->assign('initialStates', $initialState->getInitialStates());
242
-	}
243
-
244
-	/**
245
-	 * @param string $path
246
- 	 * @param string $file
247
-	 * @return string
248
-	 */
249
-	protected function getVersionHashSuffix($path = false, $file = false) {
250
-		if ($this->config->getSystemValue('debug', false)) {
251
-			// allows chrome workspace mapping in debug mode
252
-			return "";
253
-		}
254
-		$themingSuffix = '';
255
-		$v = [];
256
-
257
-		if ($this->config->getSystemValue('installed', false)) {
258
-			if (\OC::$server->getAppManager()->isInstalled('theming')) {
259
-				$themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
260
-			}
261
-			$v = \OC_App::getAppVersions();
262
-		}
263
-
264
-		// Try the webroot path for a match
265
-		if ($path !== false && $path !== '') {
266
-			$appName = $this->getAppNamefromPath($path);
267
-			if(array_key_exists($appName, $v)) {
268
-				$appVersion = $v[$appName];
269
-				return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
270
-			}
271
-		}
272
-		// fallback to the file path instead
273
-		if ($file !== false && $file !== '') {
274
-			$appName = $this->getAppNamefromPath($file);
275
-			if(array_key_exists($appName, $v)) {
276
-				$appVersion = $v[$appName];
277
-				return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
278
-			}
279
-		}
280
-
281
-		return '?v=' . self::$versionHash . $themingSuffix;
282
-	}
283
-
284
-	/**
285
-	 * @param array $styles
286
-	 * @return array
287
-	 */
288
-	static public function findStylesheetFiles($styles, $compileScss = true) {
289
-		// Read the selected theme from the config file
290
-		$theme = \OC_Util::getTheme();
291
-
292
-		if($compileScss) {
293
-			$SCSSCacher = \OC::$server->query(SCSSCacher::class);
294
-		} else {
295
-			$SCSSCacher = null;
296
-		}
297
-
298
-		$locator = new \OC\Template\CSSResourceLocator(
299
-			\OC::$server->getLogger(),
300
-			$theme,
301
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
302
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
303
-			$SCSSCacher
304
-		);
305
-		$locator->find($styles);
306
-		return $locator->getResources();
307
-	}
308
-
309
-	/**
310
-	 * @param string $path
311
-	 * @return string|boolean
312
-	 */
313
-	public function getAppNamefromPath($path) {
314
-		if ($path !== '' && is_string($path)) {
315
-			$pathParts = explode('/', $path);
316
-			if ($pathParts[0] === 'css') {
317
-				// This is a scss request
318
-				return $pathParts[1];
319
-			}
320
-			return end($pathParts);
321
-		}
322
-		return false;
323
-
324
-	}
325
-
326
-	/**
327
-	 * @param array $scripts
328
-	 * @return array
329
-	 */
330
-	static public function findJavascriptFiles($scripts) {
331
-		// Read the selected theme from the config file
332
-		$theme = \OC_Util::getTheme();
333
-
334
-		$locator = new \OC\Template\JSResourceLocator(
335
-			\OC::$server->getLogger(),
336
-			$theme,
337
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
338
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
339
-			\OC::$server->query(JSCombiner::class)
340
-			);
341
-		$locator->find($scripts);
342
-		return $locator->getResources();
343
-	}
344
-
345
-	/**
346
-	 * Converts the absolute file path to a relative path from \OC::$SERVERROOT
347
-	 * @param string $filePath Absolute path
348
-	 * @return string Relative path
349
-	 * @throws \Exception If $filePath is not under \OC::$SERVERROOT
350
-	 */
351
-	public static function convertToRelativePath($filePath) {
352
-		$relativePath = explode(\OC::$SERVERROOT, $filePath);
353
-		if(count($relativePath) !== 2) {
354
-			throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
355
-		}
356
-
357
-		return $relativePath[1];
358
-	}
50
+    private static $versionHash = '';
51
+
52
+    /**
53
+     * @var \OCP\IConfig
54
+     */
55
+    private $config;
56
+
57
+    /**
58
+     * @param string $renderAs
59
+     * @param string $appId application id
60
+     */
61
+    public function __construct( $renderAs, $appId = '' ) {
62
+
63
+        // yes - should be injected ....
64
+        $this->config = \OC::$server->getConfig();
65
+
66
+        if(\OCP\Util::isIE()) {
67
+            \OC_Util::addStyle('ie');
68
+        }
69
+
70
+        // Decide which page we show
71
+        if($renderAs === 'user') {
72
+            parent::__construct( 'core', 'layout.user' );
73
+            if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
74
+                $this->assign('bodyid', 'body-settings');
75
+            }else{
76
+                $this->assign('bodyid', 'body-user');
77
+            }
78
+
79
+            // Add navigation entry
80
+            $this->assign( 'application', '');
81
+            $this->assign( 'appid', $appId );
82
+            $navigation = \OC::$server->getNavigationManager()->getAll();
83
+            $this->assign( 'navigation', $navigation);
84
+            $settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings');
85
+            $this->assign( 'settingsnavigation', $settingsNavigation);
86
+            foreach($navigation as $entry) {
87
+                if ($entry['active']) {
88
+                    $this->assign( 'application', $entry['name'] );
89
+                    break;
90
+                }
91
+            }
92
+
93
+            foreach($settingsNavigation as $entry) {
94
+                if ($entry['active']) {
95
+                    $this->assign( 'application', $entry['name'] );
96
+                    break;
97
+                }
98
+            }
99
+            $userDisplayName = \OC_User::getDisplayName();
100
+            $this->assign('user_displayname', $userDisplayName);
101
+            $this->assign('user_uid', \OC_User::getUser());
102
+
103
+            if (\OC_User::getUser() === false) {
104
+                $this->assign('userAvatarSet', false);
105
+            } else {
106
+                $this->assign('userAvatarSet', \OC::$server->getAvatarManager()->getAvatar(\OC_User::getUser())->exists());
107
+                $this->assign('userAvatarVersion', $this->config->getUserValue(\OC_User::getUser(), 'avatar', 'version', 0));
108
+            }
109
+
110
+            // check if app menu icons should be inverted
111
+            try {
112
+                /** @var \OCA\Theming\Util $util */
113
+                $util = \OC::$server->query(\OCA\Theming\Util::class);
114
+                $this->assign('themingInvertMenu', $util->invertTextColor(\OC::$server->getThemingDefaults()->getColorPrimary()));
115
+            } catch (\OCP\AppFramework\QueryException $e) {
116
+                $this->assign('themingInvertMenu', false);
117
+            } catch (\OCP\AutoloadNotAllowedException $e) {
118
+                $this->assign('themingInvertMenu', false);
119
+            }
120
+
121
+        } else if ($renderAs === 'error') {
122
+            parent::__construct('core', 'layout.guest', '', false);
123
+            $this->assign('bodyid', 'body-login');
124
+            $this->assign('user_displayname', '');
125
+            $this->assign('user_uid', '');
126
+        } else if ($renderAs === 'guest') {
127
+            parent::__construct('core', 'layout.guest');
128
+            \OC_Util::addStyle('guest');
129
+            $this->assign('bodyid', 'body-login');
130
+
131
+            $userDisplayName = \OC_User::getDisplayName();
132
+            $this->assign('user_displayname', $userDisplayName);
133
+            $this->assign('user_uid', \OC_User::getUser());
134
+        } else if ($renderAs === 'public') {
135
+            parent::__construct('core', 'layout.public');
136
+            $this->assign( 'appid', $appId );
137
+            $this->assign('bodyid', 'body-public');
138
+
139
+            /** @var IRegistry $subscription */
140
+            $subscription = \OC::$server->query(IRegistry::class);
141
+            $showSimpleSignup = $this->config->getSystemValueBool('simpleSignUpLink.shown', true);
142
+            if ($showSimpleSignup && $subscription->delegateHasValidSubscription()) {
143
+                $showSimpleSignup = false;
144
+            }
145
+            $this->assign('showSimpleSignUpLink', $showSimpleSignup);
146
+        } else {
147
+            parent::__construct('core', 'layout.base');
148
+
149
+        }
150
+        // Send the language and the locale to our layouts
151
+        $lang = \OC::$server->getL10NFactory()->findLanguage();
152
+        $locale = \OC::$server->getL10NFactory()->findLocale($lang);
153
+
154
+        $lang = str_replace('_', '-', $lang);
155
+        $this->assign('language', $lang);
156
+        $this->assign('locale', $locale);
157
+
158
+        if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
159
+            if (empty(self::$versionHash)) {
160
+                $v = \OC_App::getAppVersions();
161
+                $v['core'] = implode('.', \OCP\Util::getVersion());
162
+                self::$versionHash = substr(md5(implode(',', $v)), 0, 8);
163
+            }
164
+        } else {
165
+            self::$versionHash = md5('not installed');
166
+        }
167
+
168
+        // Add the js files
169
+        $jsFiles = self::findJavascriptFiles(\OC_Util::$scripts);
170
+        $this->assign('jsfiles', array());
171
+        if ($this->config->getSystemValue('installed', false) && $renderAs != 'error') {
172
+            if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) {
173
+                $jsConfigHelper = new JSConfigHelper(
174
+                    \OC::$server->getL10N('lib'),
175
+                    \OC::$server->query(Defaults::class),
176
+                    \OC::$server->getAppManager(),
177
+                    \OC::$server->getSession(),
178
+                    \OC::$server->getUserSession()->getUser(),
179
+                    $this->config,
180
+                    \OC::$server->getGroupManager(),
181
+                    \OC::$server->getIniWrapper(),
182
+                    \OC::$server->getURLGenerator(),
183
+                    \OC::$server->getCapabilitiesManager()
184
+                );
185
+                $this->assign('inline_ocjs', $jsConfigHelper->getConfig());
186
+            } else {
187
+                $this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
188
+            }
189
+        }
190
+        foreach($jsFiles as $info) {
191
+            $web = $info[1];
192
+            $file = $info[2];
193
+            $this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
194
+        }
195
+
196
+        try {
197
+            $pathInfo = \OC::$server->getRequest()->getPathInfo();
198
+        } catch (\Exception $e) {
199
+            $pathInfo = '';
200
+        }
201
+
202
+        // Do not initialise scss appdata until we have a fully installed instance
203
+        // Do not load scss for update, errors, installation or login page
204
+        if(\OC::$server->getSystemConfig()->getValue('installed', false)
205
+            && !\OCP\Util::needUpgrade()
206
+            && $pathInfo !== ''
207
+            && !preg_match('/^\/login/', $pathInfo)
208
+            && $renderAs !== 'error'
209
+        ) {
210
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles);
211
+        } else {
212
+            // If we ignore the scss compiler,
213
+            // we need to load the guest css fallback
214
+            \OC_Util::addStyle('guest');
215
+            $cssFiles = self::findStylesheetFiles(\OC_Util::$styles, false);
216
+        }
217
+
218
+        $this->assign('cssfiles', array());
219
+        $this->assign('printcssfiles', []);
220
+        $this->assign('versionHash', self::$versionHash);
221
+        foreach($cssFiles as $info) {
222
+            $web = $info[1];
223
+            $file = $info[2];
224
+
225
+            if (substr($file, -strlen('print.css')) === 'print.css') {
226
+                $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
227
+            } else {
228
+                $suffix = $this->getVersionHashSuffix($web, $file);
229
+
230
+                if (strpos($file, '?v=') == false) {
231
+                    $this->append( 'cssfiles', $web.'/'.$file . $suffix);
232
+                } else {
233
+                    $this->append( 'cssfiles', $web.'/'.$file . '-' . substr($suffix, 3));
234
+                }
235
+
236
+            }
237
+        }
238
+
239
+        /** @var InitialStateService $initialState */
240
+        $initialState = \OC::$server->query(InitialStateService::class);
241
+        $this->assign('initialStates', $initialState->getInitialStates());
242
+    }
243
+
244
+    /**
245
+     * @param string $path
246
+     * @param string $file
247
+     * @return string
248
+     */
249
+    protected function getVersionHashSuffix($path = false, $file = false) {
250
+        if ($this->config->getSystemValue('debug', false)) {
251
+            // allows chrome workspace mapping in debug mode
252
+            return "";
253
+        }
254
+        $themingSuffix = '';
255
+        $v = [];
256
+
257
+        if ($this->config->getSystemValue('installed', false)) {
258
+            if (\OC::$server->getAppManager()->isInstalled('theming')) {
259
+                $themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
260
+            }
261
+            $v = \OC_App::getAppVersions();
262
+        }
263
+
264
+        // Try the webroot path for a match
265
+        if ($path !== false && $path !== '') {
266
+            $appName = $this->getAppNamefromPath($path);
267
+            if(array_key_exists($appName, $v)) {
268
+                $appVersion = $v[$appName];
269
+                return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
270
+            }
271
+        }
272
+        // fallback to the file path instead
273
+        if ($file !== false && $file !== '') {
274
+            $appName = $this->getAppNamefromPath($file);
275
+            if(array_key_exists($appName, $v)) {
276
+                $appVersion = $v[$appName];
277
+                return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
278
+            }
279
+        }
280
+
281
+        return '?v=' . self::$versionHash . $themingSuffix;
282
+    }
283
+
284
+    /**
285
+     * @param array $styles
286
+     * @return array
287
+     */
288
+    static public function findStylesheetFiles($styles, $compileScss = true) {
289
+        // Read the selected theme from the config file
290
+        $theme = \OC_Util::getTheme();
291
+
292
+        if($compileScss) {
293
+            $SCSSCacher = \OC::$server->query(SCSSCacher::class);
294
+        } else {
295
+            $SCSSCacher = null;
296
+        }
297
+
298
+        $locator = new \OC\Template\CSSResourceLocator(
299
+            \OC::$server->getLogger(),
300
+            $theme,
301
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
302
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
303
+            $SCSSCacher
304
+        );
305
+        $locator->find($styles);
306
+        return $locator->getResources();
307
+    }
308
+
309
+    /**
310
+     * @param string $path
311
+     * @return string|boolean
312
+     */
313
+    public function getAppNamefromPath($path) {
314
+        if ($path !== '' && is_string($path)) {
315
+            $pathParts = explode('/', $path);
316
+            if ($pathParts[0] === 'css') {
317
+                // This is a scss request
318
+                return $pathParts[1];
319
+            }
320
+            return end($pathParts);
321
+        }
322
+        return false;
323
+
324
+    }
325
+
326
+    /**
327
+     * @param array $scripts
328
+     * @return array
329
+     */
330
+    static public function findJavascriptFiles($scripts) {
331
+        // Read the selected theme from the config file
332
+        $theme = \OC_Util::getTheme();
333
+
334
+        $locator = new \OC\Template\JSResourceLocator(
335
+            \OC::$server->getLogger(),
336
+            $theme,
337
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
338
+            array( \OC::$SERVERROOT => \OC::$WEBROOT ),
339
+            \OC::$server->query(JSCombiner::class)
340
+            );
341
+        $locator->find($scripts);
342
+        return $locator->getResources();
343
+    }
344
+
345
+    /**
346
+     * Converts the absolute file path to a relative path from \OC::$SERVERROOT
347
+     * @param string $filePath Absolute path
348
+     * @return string Relative path
349
+     * @throws \Exception If $filePath is not under \OC::$SERVERROOT
350
+     */
351
+    public static function convertToRelativePath($filePath) {
352
+        $relativePath = explode(\OC::$SERVERROOT, $filePath);
353
+        if(count($relativePath) !== 2) {
354
+            throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
355
+        }
356
+
357
+        return $relativePath[1];
358
+    }
359 359
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -58,41 +58,41 @@  discard block
 block discarded – undo
58 58
 	 * @param string $renderAs
59 59
 	 * @param string $appId application id
60 60
 	 */
61
-	public function __construct( $renderAs, $appId = '' ) {
61
+	public function __construct($renderAs, $appId = '') {
62 62
 
63 63
 		// yes - should be injected ....
64 64
 		$this->config = \OC::$server->getConfig();
65 65
 
66
-		if(\OCP\Util::isIE()) {
66
+		if (\OCP\Util::isIE()) {
67 67
 			\OC_Util::addStyle('ie');
68 68
 		}
69 69
 
70 70
 		// Decide which page we show
71
-		if($renderAs === 'user') {
72
-			parent::__construct( 'core', 'layout.user' );
73
-			if(in_array(\OC_App::getCurrentApp(), ['settings','admin', 'help']) !== false) {
71
+		if ($renderAs === 'user') {
72
+			parent::__construct('core', 'layout.user');
73
+			if (in_array(\OC_App::getCurrentApp(), ['settings', 'admin', 'help']) !== false) {
74 74
 				$this->assign('bodyid', 'body-settings');
75
-			}else{
75
+			} else {
76 76
 				$this->assign('bodyid', 'body-user');
77 77
 			}
78 78
 
79 79
 			// Add navigation entry
80
-			$this->assign( 'application', '');
81
-			$this->assign( 'appid', $appId );
80
+			$this->assign('application', '');
81
+			$this->assign('appid', $appId);
82 82
 			$navigation = \OC::$server->getNavigationManager()->getAll();
83
-			$this->assign( 'navigation', $navigation);
83
+			$this->assign('navigation', $navigation);
84 84
 			$settingsNavigation = \OC::$server->getNavigationManager()->getAll('settings');
85
-			$this->assign( 'settingsnavigation', $settingsNavigation);
86
-			foreach($navigation as $entry) {
85
+			$this->assign('settingsnavigation', $settingsNavigation);
86
+			foreach ($navigation as $entry) {
87 87
 				if ($entry['active']) {
88
-					$this->assign( 'application', $entry['name'] );
88
+					$this->assign('application', $entry['name']);
89 89
 					break;
90 90
 				}
91 91
 			}
92 92
 
93
-			foreach($settingsNavigation as $entry) {
93
+			foreach ($settingsNavigation as $entry) {
94 94
 				if ($entry['active']) {
95
-					$this->assign( 'application', $entry['name'] );
95
+					$this->assign('application', $entry['name']);
96 96
 					break;
97 97
 				}
98 98
 			}
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 			$this->assign('user_uid', \OC_User::getUser());
134 134
 		} else if ($renderAs === 'public') {
135 135
 			parent::__construct('core', 'layout.public');
136
-			$this->assign( 'appid', $appId );
136
+			$this->assign('appid', $appId);
137 137
 			$this->assign('bodyid', 'body-public');
138 138
 
139 139
 			/** @var IRegistry $subscription */
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 		$this->assign('language', $lang);
156 156
 		$this->assign('locale', $locale);
157 157
 
158
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)) {
158
+		if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
159 159
 			if (empty(self::$versionHash)) {
160 160
 				$v = \OC_App::getAppVersions();
161 161
 				$v['core'] = implode('.', \OCP\Util::getVersion());
@@ -187,10 +187,10 @@  discard block
 block discarded – undo
187 187
 				$this->append('jsfiles', \OC::$server->getURLGenerator()->linkToRoute('core.OCJS.getConfig', ['v' => self::$versionHash]));
188 188
 			}
189 189
 		}
190
-		foreach($jsFiles as $info) {
190
+		foreach ($jsFiles as $info) {
191 191
 			$web = $info[1];
192 192
 			$file = $info[2];
193
-			$this->append( 'jsfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
193
+			$this->append('jsfiles', $web.'/'.$file.$this->getVersionHashSuffix());
194 194
 		}
195 195
 
196 196
 		try {
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
 		// Do not initialise scss appdata until we have a fully installed instance
203 203
 		// Do not load scss for update, errors, installation or login page
204
-		if(\OC::$server->getSystemConfig()->getValue('installed', false)
204
+		if (\OC::$server->getSystemConfig()->getValue('installed', false)
205 205
 			&& !\OCP\Util::needUpgrade()
206 206
 			&& $pathInfo !== ''
207 207
 			&& !preg_match('/^\/login/', $pathInfo)
@@ -218,19 +218,19 @@  discard block
 block discarded – undo
218 218
 		$this->assign('cssfiles', array());
219 219
 		$this->assign('printcssfiles', []);
220 220
 		$this->assign('versionHash', self::$versionHash);
221
-		foreach($cssFiles as $info) {
221
+		foreach ($cssFiles as $info) {
222 222
 			$web = $info[1];
223 223
 			$file = $info[2];
224 224
 
225 225
 			if (substr($file, -strlen('print.css')) === 'print.css') {
226
-				$this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
226
+				$this->append('printcssfiles', $web.'/'.$file.$this->getVersionHashSuffix());
227 227
 			} else {
228 228
 				$suffix = $this->getVersionHashSuffix($web, $file);
229 229
 
230 230
 				if (strpos($file, '?v=') == false) {
231
-					$this->append( 'cssfiles', $web.'/'.$file . $suffix);
231
+					$this->append('cssfiles', $web.'/'.$file.$suffix);
232 232
 				} else {
233
-					$this->append( 'cssfiles', $web.'/'.$file . '-' . substr($suffix, 3));
233
+					$this->append('cssfiles', $web.'/'.$file.'-'.substr($suffix, 3));
234 234
 				}
235 235
 
236 236
 			}
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
 		if ($this->config->getSystemValue('installed', false)) {
258 258
 			if (\OC::$server->getAppManager()->isInstalled('theming')) {
259
-				$themingSuffix = '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
259
+				$themingSuffix = '-'.$this->config->getAppValue('theming', 'cachebuster', '0');
260 260
 			}
261 261
 			$v = \OC_App::getAppVersions();
262 262
 		}
@@ -264,21 +264,21 @@  discard block
 block discarded – undo
264 264
 		// Try the webroot path for a match
265 265
 		if ($path !== false && $path !== '') {
266 266
 			$appName = $this->getAppNamefromPath($path);
267
-			if(array_key_exists($appName, $v)) {
267
+			if (array_key_exists($appName, $v)) {
268 268
 				$appVersion = $v[$appName];
269
-				return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
269
+				return '?v='.substr(md5($appVersion), 0, 8).$themingSuffix;
270 270
 			}
271 271
 		}
272 272
 		// fallback to the file path instead
273 273
 		if ($file !== false && $file !== '') {
274 274
 			$appName = $this->getAppNamefromPath($file);
275
-			if(array_key_exists($appName, $v)) {
275
+			if (array_key_exists($appName, $v)) {
276 276
 				$appVersion = $v[$appName];
277
-				return '?v=' . substr(md5($appVersion), 0, 8) . $themingSuffix;
277
+				return '?v='.substr(md5($appVersion), 0, 8).$themingSuffix;
278 278
 			}
279 279
 		}
280 280
 
281
-		return '?v=' . self::$versionHash . $themingSuffix;
281
+		return '?v='.self::$versionHash.$themingSuffix;
282 282
 	}
283 283
 
284 284
 	/**
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		// Read the selected theme from the config file
290 290
 		$theme = \OC_Util::getTheme();
291 291
 
292
-		if($compileScss) {
292
+		if ($compileScss) {
293 293
 			$SCSSCacher = \OC::$server->query(SCSSCacher::class);
294 294
 		} else {
295 295
 			$SCSSCacher = null;
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 		$locator = new \OC\Template\CSSResourceLocator(
299 299
 			\OC::$server->getLogger(),
300 300
 			$theme,
301
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
302
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
301
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
302
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
303 303
 			$SCSSCacher
304 304
 		);
305 305
 		$locator->find($styles);
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
 		$locator = new \OC\Template\JSResourceLocator(
335 335
 			\OC::$server->getLogger(),
336 336
 			$theme,
337
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
338
-			array( \OC::$SERVERROOT => \OC::$WEBROOT ),
337
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
338
+			array(\OC::$SERVERROOT => \OC::$WEBROOT),
339 339
 			\OC::$server->query(JSCombiner::class)
340 340
 			);
341 341
 		$locator->find($scripts);
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 	 */
351 351
 	public static function convertToRelativePath($filePath) {
352 352
 		$relativePath = explode(\OC::$SERVERROOT, $filePath);
353
-		if(count($relativePath) !== 2) {
353
+		if (count($relativePath) !== 2) {
354 354
 			throw new \Exception('$filePath is not under the \OC::$SERVERROOT');
355 355
 		}
356 356
 
Please login to merge, or discard this patch.
lib/private/Migration/BackgroundRepair.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	public function execute($jobList, ILogger $logger = null) {
59 59
 		// add an interval of 15 mins
60
-		$this->setInterval(15*60);
60
+		$this->setInterval(15 * 60);
61 61
 
62 62
 		$this->jobList = $jobList;
63 63
 		$this->logger = $logger;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		try {
91 91
 			$repair->addStep($step);
92 92
 		} catch (\Exception $ex) {
93
-			$this->logger->logException($ex,[
93
+			$this->logger->logException($ex, [
94 94
 				'app' => 'migration'
95 95
 			]);
96 96
 
Please login to merge, or discard this patch.
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -39,82 +39,82 @@
 block discarded – undo
39 39
  */
40 40
 class BackgroundRepair extends TimedJob {
41 41
 
42
-	/** @var IJobList */
43
-	private $jobList;
44
-
45
-	/** @var ILogger */
46
-	private $logger;
47
-
48
-	/** @var EventDispatcherInterface */
49
-	private $dispatcher;
50
-
51
-	public function __construct(EventDispatcherInterface $dispatcher) {
52
-		$this->dispatcher = $dispatcher;
53
-	}
54
-
55
-	/**
56
-	 * run the job, then remove it from the job list
57
-	 *
58
-	 * @param JobList $jobList
59
-	 * @param ILogger|null $logger
60
-	 */
61
-	public function execute($jobList, ILogger $logger = null) {
62
-		// add an interval of 15 mins
63
-		$this->setInterval(15*60);
64
-
65
-		$this->jobList = $jobList;
66
-		$this->logger = $logger;
67
-		parent::execute($jobList, $logger);
68
-	}
69
-
70
-	/**
71
-	 * @param array $argument
72
-	 * @throws \Exception
73
-	 * @throws \OC\NeedsUpdateException
74
-	 */
75
-	protected function run($argument) {
76
-		if (!isset($argument['app']) || !isset($argument['step'])) {
77
-			// remove the job - we can never execute it
78
-			$this->jobList->remove($this, $this->argument);
79
-			return;
80
-		}
81
-		$app = $argument['app'];
82
-
83
-		try {
84
-			$this->loadApp($app);
85
-		} catch (NeedsUpdateException $ex) {
86
-			// as long as the app is not yet done with it's offline migration
87
-			// we better not start with the live migration
88
-			return;
89
-		}
90
-
91
-		$step = $argument['step'];
92
-		$repair = new Repair([], $this->dispatcher);
93
-		try {
94
-			$repair->addStep($step);
95
-		} catch (\Exception $ex) {
96
-			$this->logger->logException($ex,[
97
-				'app' => 'migration'
98
-			]);
99
-
100
-			// remove the job - we can never execute it
101
-			$this->jobList->remove($this, $this->argument);
102
-			return;
103
-		}
104
-
105
-		// execute the repair step
106
-		$repair->run();
107
-
108
-		// remove the job once executed successfully
109
-		$this->jobList->remove($this, $this->argument);
110
-	}
111
-
112
-	/**
113
-	 * @codeCoverageIgnore
114
-	 * @param $app
115
-	 * @throws NeedsUpdateException
116
-	 */
117
-	protected function loadApp($app) {
118
-		OC_App::loadApp($app);
119
-	}
42
+    /** @var IJobList */
43
+    private $jobList;
44
+
45
+    /** @var ILogger */
46
+    private $logger;
47
+
48
+    /** @var EventDispatcherInterface */
49
+    private $dispatcher;
50
+
51
+    public function __construct(EventDispatcherInterface $dispatcher) {
52
+        $this->dispatcher = $dispatcher;
53
+    }
54
+
55
+    /**
56
+     * run the job, then remove it from the job list
57
+     *
58
+     * @param JobList $jobList
59
+     * @param ILogger|null $logger
60
+     */
61
+    public function execute($jobList, ILogger $logger = null) {
62
+        // add an interval of 15 mins
63
+        $this->setInterval(15*60);
64
+
65
+        $this->jobList = $jobList;
66
+        $this->logger = $logger;
67
+        parent::execute($jobList, $logger);
68
+    }
69
+
70
+    /**
71
+     * @param array $argument
72
+     * @throws \Exception
73
+     * @throws \OC\NeedsUpdateException
74
+     */
75
+    protected function run($argument) {
76
+        if (!isset($argument['app']) || !isset($argument['step'])) {
77
+            // remove the job - we can never execute it
78
+            $this->jobList->remove($this, $this->argument);
79
+            return;
80
+        }
81
+        $app = $argument['app'];
82
+
83
+        try {
84
+            $this->loadApp($app);
85
+        } catch (NeedsUpdateException $ex) {
86
+            // as long as the app is not yet done with it's offline migration
87
+            // we better not start with the live migration
88
+            return;
89
+        }
90
+
91
+        $step = $argument['step'];
92
+        $repair = new Repair([], $this->dispatcher);
93
+        try {
94
+            $repair->addStep($step);
95
+        } catch (\Exception $ex) {
96
+            $this->logger->logException($ex,[
97
+                'app' => 'migration'
98
+            ]);
99
+
100
+            // remove the job - we can never execute it
101
+            $this->jobList->remove($this, $this->argument);
102
+            return;
103
+        }
104
+
105
+        // execute the repair step
106
+        $repair->run();
107
+
108
+        // remove the job once executed successfully
109
+        $this->jobList->remove($this, $this->argument);
110
+    }
111
+
112
+    /**
113
+     * @codeCoverageIgnore
114
+     * @param $app
115
+     * @throws NeedsUpdateException
116
+     */
117
+    protected function loadApp($app) {
118
+        OC_App::loadApp($app);
119
+    }
120 120
 }
Please login to merge, or discard this patch.
lib/private/Command/QueueBus.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 		if ($command instanceof ICommand) {
56 56
 			// ensure the command can be serialized
57 57
 			$serialized = serialize($command);
58
-			if(strlen($serialized) > 4000) {
58
+			if (strlen($serialized) > 4000) {
59 59
 				throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)');
60 60
 			}
61 61
 			$unserialized = unserialize($serialized);
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -26,48 +26,48 @@
 block discarded – undo
26 26
 use OCP\Command\ICommand;
27 27
 
28 28
 class QueueBus implements IBus {
29
-	/**
30
-	 * @var ICommand[]|callable[]
31
-	 */
32
-	private $queue = [];
29
+    /**
30
+     * @var ICommand[]|callable[]
31
+     */
32
+    private $queue = [];
33 33
 
34
-	/**
35
-	 * Schedule a command to be fired
36
-	 *
37
-	 * @param \OCP\Command\ICommand | callable $command
38
-	 */
39
-	public function push($command) {
40
-		$this->queue[] = $command;
41
-	}
34
+    /**
35
+     * Schedule a command to be fired
36
+     *
37
+     * @param \OCP\Command\ICommand | callable $command
38
+     */
39
+    public function push($command) {
40
+        $this->queue[] = $command;
41
+    }
42 42
 
43
-	/**
44
-	 * Require all commands using a trait to be run synchronous
45
-	 *
46
-	 * @param string $trait
47
-	 */
48
-	public function requireSync($trait) {
49
-	}
43
+    /**
44
+     * Require all commands using a trait to be run synchronous
45
+     *
46
+     * @param string $trait
47
+     */
48
+    public function requireSync($trait) {
49
+    }
50 50
 
51
-	/**
52
-	 * @param \OCP\Command\ICommand | callable $command
53
-	 */
54
-	private function runCommand($command) {
55
-		if ($command instanceof ICommand) {
56
-			// ensure the command can be serialized
57
-			$serialized = serialize($command);
58
-			if(strlen($serialized) > 4000) {
59
-				throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)');
60
-			}
61
-			$unserialized = unserialize($serialized);
62
-			$unserialized->handle();
63
-		} else {
64
-			$command();
65
-		}
66
-	}
51
+    /**
52
+     * @param \OCP\Command\ICommand | callable $command
53
+     */
54
+    private function runCommand($command) {
55
+        if ($command instanceof ICommand) {
56
+            // ensure the command can be serialized
57
+            $serialized = serialize($command);
58
+            if(strlen($serialized) > 4000) {
59
+                throw new \InvalidArgumentException('Trying to push a command which serialized form can not be stored in the database (>4000 character)');
60
+            }
61
+            $unserialized = unserialize($serialized);
62
+            $unserialized->handle();
63
+        } else {
64
+            $command();
65
+        }
66
+    }
67 67
 
68
-	public function run() {
69
-		while ($command = array_shift($this->queue)) {
70
-			$this->runCommand($command);
71
-		}
72
-	}
68
+    public function run() {
69
+        while ($command = array_shift($this->queue)) {
70
+            $this->runCommand($command);
71
+        }
72
+    }
73 73
 }
Please login to merge, or discard this patch.
lib/private/Command/CallableJob.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@
 block discarded – undo
25 25
 use OC\BackgroundJob\QueuedJob;
26 26
 
27 27
 class CallableJob extends QueuedJob {
28
-	protected function run($serializedCallable) {
29
-		$callable = unserialize($serializedCallable);
30
-		if (is_callable($callable)) {
31
-			$callable();
32
-		} else {
33
-			throw new \InvalidArgumentException('Invalid serialized callable');
34
-		}
35
-	}
28
+    protected function run($serializedCallable) {
29
+        $callable = unserialize($serializedCallable);
30
+        if (is_callable($callable)) {
31
+            $callable();
32
+        } else {
33
+            throw new \InvalidArgumentException('Invalid serialized callable');
34
+        }
35
+    }
36 36
 }
Please login to merge, or discard this patch.
lib/private/Command/ClosureJob.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@
 block discarded – undo
26 26
 use SuperClosure\Serializer;
27 27
 
28 28
 class ClosureJob extends QueuedJob {
29
-	protected function run($serializedCallable) {
30
-		$serializer = new Serializer();
31
-		$callable = $serializer->unserialize($serializedCallable);
32
-		if (is_callable($callable)) {
33
-			$callable();
34
-		} else {
35
-			throw new \InvalidArgumentException('Invalid serialized callable');
36
-		}
37
-	}
29
+    protected function run($serializedCallable) {
30
+        $serializer = new Serializer();
31
+        $callable = $serializer->unserialize($serializedCallable);
32
+        if (is_callable($callable)) {
33
+            $callable();
34
+        } else {
35
+            throw new \InvalidArgumentException('Invalid serialized callable');
36
+        }
37
+    }
38 38
 }
Please login to merge, or discard this patch.
lib/private/Command/FileAccess.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -25,12 +25,12 @@
 block discarded – undo
25 25
 use OCP\IUser;
26 26
 
27 27
 trait FileAccess {
28
-	protected function setupFS(IUser $user){
29
-		\OC_Util::setupFS($user->getUID());
30
-	}
28
+    protected function setupFS(IUser $user){
29
+        \OC_Util::setupFS($user->getUID());
30
+    }
31 31
 
32
-	protected function getUserFolder(IUser $user) {
33
-		$this->setupFS($user);
34
-		return \OC::$server->getUserFolder($user->getUID());
35
-	}
32
+    protected function getUserFolder(IUser $user) {
33
+        $this->setupFS($user);
34
+        return \OC::$server->getUserFolder($user->getUID());
35
+    }
36 36
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 use OCP\IUser;
26 26
 
27 27
 trait FileAccess {
28
-	protected function setupFS(IUser $user){
28
+	protected function setupFS(IUser $user) {
29 29
 		\OC_Util::setupFS($user->getUID());
30 30
 	}
31 31
 
Please login to merge, or discard this patch.
lib/private/Command/CommandJob.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@
 block discarded – undo
29 29
  * Wrap a command in the background job interface
30 30
  */
31 31
 class CommandJob extends QueuedJob {
32
-	protected function run($serializedCommand) {
33
-		$command = unserialize($serializedCommand);
34
-		if ($command instanceof ICommand) {
35
-			$command->handle();
36
-		} else {
37
-			throw new \InvalidArgumentException('Invalid serialized command');
38
-		}
39
-	}
32
+    protected function run($serializedCommand) {
33
+        $command = unserialize($serializedCommand);
34
+        if ($command instanceof ICommand) {
35
+            $command->handle();
36
+        } else {
37
+            throw new \InvalidArgumentException('Invalid serialized command');
38
+        }
39
+    }
40 40
 }
Please login to merge, or discard this patch.
lib/private/Template/Base.php 3 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -114,8 +114,7 @@  discard block
 block discarded – undo
114 114
 	public function append( $key, $value ) {
115 115
 		if( array_key_exists( $key, $this->vars )) {
116 116
 			$this->vars[$key][] = $value;
117
-		}
118
-		else{
117
+		} else{
119 118
 			$this->vars[$key] = array( $value );
120 119
 		}
121 120
 	}
@@ -130,8 +129,7 @@  discard block
 block discarded – undo
130 129
 		$data = $this->fetchPage();
131 130
 		if( $data === false ) {
132 131
 			return false;
133
-		}
134
-		else{
132
+		} else{
135 133
 			print $data;
136 134
 			return true;
137 135
 		}
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * @param \OCP\IL10N $l10n
47 47
 	 * @param Defaults $theme
48 48
 	 */
49
-	public function __construct($template, $requestToken, $l10n, $theme ) {
49
+	public function __construct($template, $requestToken, $l10n, $theme) {
50 50
 		$this->vars = array();
51 51
 		$this->vars['requesttoken'] = $requestToken;
52 52
 		$this->l10n = $l10n;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 */
64 64
 	protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) {
65 65
 		// Check if the app is in the app folder or in the root
66
-		if( file_exists($app_dir.'/templates/' )) {
66
+		if (file_exists($app_dir.'/templates/')) {
67 67
 			return [
68 68
 				$serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/',
69 69
 				$app_dir.'/templates/',
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * If the key existed before, it will be overwritten
100 100
 	 */
101
-	public function assign( $key, $value) {
101
+	public function assign($key, $value) {
102 102
 		$this->vars[$key] = $value;
103 103
 		return true;
104 104
 	}
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 	 * exists, the value will be appended. It can be accessed via
114 114
 	 * $_[$key][$position] in the template.
115 115
 	 */
116
-	public function append( $key, $value ) {
117
-		if( array_key_exists( $key, $this->vars )) {
116
+	public function append($key, $value) {
117
+		if (array_key_exists($key, $this->vars)) {
118 118
 			$this->vars[$key][] = $value;
119 119
 		}
120
-		else{
121
-			$this->vars[$key] = array( $value );
120
+		else {
121
+			$this->vars[$key] = array($value);
122 122
 		}
123 123
 	}
124 124
 
@@ -130,10 +130,10 @@  discard block
 block discarded – undo
130 130
 	 */
131 131
 	public function printPage() {
132 132
 		$data = $this->fetchPage();
133
-		if( $data === false ) {
133
+		if ($data === false) {
134 134
 			return false;
135 135
 		}
136
-		else{
136
+		else {
137 137
 			print $data;
138 138
 			return true;
139 139
 		}
@@ -166,8 +166,8 @@  discard block
 block discarded – undo
166 166
 		$l = $this->l10n;
167 167
 		$theme = $this->theme;
168 168
 
169
-		if(!is_null($additionalParams)) {
170
-			$_ = array_merge( $additionalParams, $this->vars );
169
+		if (!is_null($additionalParams)) {
170
+			$_ = array_merge($additionalParams, $this->vars);
171 171
 			foreach ($_ as $var => $value) {
172 172
 				${$var} = $value;
173 173
 			}
Please login to merge, or discard this patch.
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -31,160 +31,160 @@
 block discarded – undo
31 31
 use OCP\Defaults;
32 32
 
33 33
 class Base {
34
-	private $template; // The template
35
-	private $vars; // Vars
36
-
37
-	/** @var \OCP\IL10N */
38
-	private $l10n;
39
-
40
-	/** @var Defaults */
41
-	private $theme;
42
-
43
-	/**
44
-	 * @param string $template
45
-	 * @param string $requestToken
46
-	 * @param \OCP\IL10N $l10n
47
-	 * @param Defaults $theme
48
-	 */
49
-	public function __construct($template, $requestToken, $l10n, $theme ) {
50
-		$this->vars = array();
51
-		$this->vars['requesttoken'] = $requestToken;
52
-		$this->l10n = $l10n;
53
-		$this->template = $template;
54
-		$this->theme = $theme;
55
-	}
56
-
57
-	/**
58
-	 * @param string $serverRoot
59
-	 * @param string|false $app_dir
60
-	 * @param string $theme
61
-	 * @param string $app
62
-	 * @return string[]
63
-	 */
64
-	protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) {
65
-		// Check if the app is in the app folder or in the root
66
-		if( file_exists($app_dir.'/templates/' )) {
67
-			return [
68
-				$serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/',
69
-				$app_dir.'/templates/',
70
-			];
71
-		}
72
-		return [
73
-			$serverRoot.'/themes/'.$theme.'/'.$app.'/templates/',
74
-			$serverRoot.'/'.$app.'/templates/',
75
-		];
76
-	}
77
-
78
-	/**
79
-	 * @param string $serverRoot
80
-	 * @param string $theme
81
-	 * @return string[]
82
-	 */
83
-	protected function getCoreTemplateDirs($theme, $serverRoot) {
84
-		return [
85
-			$serverRoot.'/themes/'.$theme.'/core/templates/',
86
-			$serverRoot.'/core/templates/',
87
-		];
88
-	}
89
-
90
-	/**
91
-	 * Assign variables
92
-	 * @param string $key key
93
-	 * @param array|bool|integer|string $value value
94
-	 * @return bool
95
-	 *
96
-	 * This function assigns a variable. It can be accessed via $_[$key] in
97
-	 * the template.
98
-	 *
99
-	 * If the key existed before, it will be overwritten
100
-	 */
101
-	public function assign( $key, $value) {
102
-		$this->vars[$key] = $value;
103
-		return true;
104
-	}
105
-
106
-	/**
107
-	 * Appends a variable
108
-	 * @param string $key key
109
-	 * @param mixed $value value
110
-	 *
111
-	 * This function assigns a variable in an array context. If the key already
112
-	 * exists, the value will be appended. It can be accessed via
113
-	 * $_[$key][$position] in the template.
114
-	 */
115
-	public function append( $key, $value ) {
116
-		if( array_key_exists( $key, $this->vars )) {
117
-			$this->vars[$key][] = $value;
118
-		}
119
-		else{
120
-			$this->vars[$key] = array( $value );
121
-		}
122
-	}
123
-
124
-	/**
125
-	 * Prints the proceeded template
126
-	 * @return bool
127
-	 *
128
-	 * This function proceeds the template and prints its output.
129
-	 */
130
-	public function printPage() {
131
-		$data = $this->fetchPage();
132
-		if( $data === false ) {
133
-			return false;
134
-		}
135
-		else{
136
-			print $data;
137
-			return true;
138
-		}
139
-	}
140
-
141
-	/**
142
-	 * Process the template
143
-	 *
144
-	 * @param array|null $additionalParams
145
-	 * @return string This function processes the template.
146
-	 *
147
-	 * This function processes the template.
148
-	 */
149
-	public function fetchPage($additionalParams = null) {
150
-		return $this->load($this->template, $additionalParams);
151
-	}
152
-
153
-	/**
154
-	 * doing the actual work
155
-	 *
156
-	 * @param string $file
157
-	 * @param array|null $additionalParams
158
-	 * @return string content
159
-	 *
160
-	 * Includes the template file, fetches its output
161
-	 */
162
-	protected function load($file, $additionalParams = null) {
163
-		// Register the variables
164
-		$_ = $this->vars;
165
-		$l = $this->l10n;
166
-		$theme = $this->theme;
167
-
168
-		if(!is_null($additionalParams)) {
169
-			$_ = array_merge( $additionalParams, $this->vars );
170
-			foreach ($_ as $var => $value) {
171
-				${$var} = $value;
172
-			}
173
-		}
174
-
175
-		// Include
176
-		ob_start();
177
-		try {
178
-			include $file;
179
-			$data = ob_get_contents();
180
-		} catch (\Exception $e) {
181
-			@ob_end_clean();
182
-			throw $e;
183
-		}
184
-		@ob_end_clean();
185
-
186
-		// Return data
187
-		return $data;
188
-	}
34
+    private $template; // The template
35
+    private $vars; // Vars
36
+
37
+    /** @var \OCP\IL10N */
38
+    private $l10n;
39
+
40
+    /** @var Defaults */
41
+    private $theme;
42
+
43
+    /**
44
+     * @param string $template
45
+     * @param string $requestToken
46
+     * @param \OCP\IL10N $l10n
47
+     * @param Defaults $theme
48
+     */
49
+    public function __construct($template, $requestToken, $l10n, $theme ) {
50
+        $this->vars = array();
51
+        $this->vars['requesttoken'] = $requestToken;
52
+        $this->l10n = $l10n;
53
+        $this->template = $template;
54
+        $this->theme = $theme;
55
+    }
56
+
57
+    /**
58
+     * @param string $serverRoot
59
+     * @param string|false $app_dir
60
+     * @param string $theme
61
+     * @param string $app
62
+     * @return string[]
63
+     */
64
+    protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) {
65
+        // Check if the app is in the app folder or in the root
66
+        if( file_exists($app_dir.'/templates/' )) {
67
+            return [
68
+                $serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/',
69
+                $app_dir.'/templates/',
70
+            ];
71
+        }
72
+        return [
73
+            $serverRoot.'/themes/'.$theme.'/'.$app.'/templates/',
74
+            $serverRoot.'/'.$app.'/templates/',
75
+        ];
76
+    }
77
+
78
+    /**
79
+     * @param string $serverRoot
80
+     * @param string $theme
81
+     * @return string[]
82
+     */
83
+    protected function getCoreTemplateDirs($theme, $serverRoot) {
84
+        return [
85
+            $serverRoot.'/themes/'.$theme.'/core/templates/',
86
+            $serverRoot.'/core/templates/',
87
+        ];
88
+    }
89
+
90
+    /**
91
+     * Assign variables
92
+     * @param string $key key
93
+     * @param array|bool|integer|string $value value
94
+     * @return bool
95
+     *
96
+     * This function assigns a variable. It can be accessed via $_[$key] in
97
+     * the template.
98
+     *
99
+     * If the key existed before, it will be overwritten
100
+     */
101
+    public function assign( $key, $value) {
102
+        $this->vars[$key] = $value;
103
+        return true;
104
+    }
105
+
106
+    /**
107
+     * Appends a variable
108
+     * @param string $key key
109
+     * @param mixed $value value
110
+     *
111
+     * This function assigns a variable in an array context. If the key already
112
+     * exists, the value will be appended. It can be accessed via
113
+     * $_[$key][$position] in the template.
114
+     */
115
+    public function append( $key, $value ) {
116
+        if( array_key_exists( $key, $this->vars )) {
117
+            $this->vars[$key][] = $value;
118
+        }
119
+        else{
120
+            $this->vars[$key] = array( $value );
121
+        }
122
+    }
123
+
124
+    /**
125
+     * Prints the proceeded template
126
+     * @return bool
127
+     *
128
+     * This function proceeds the template and prints its output.
129
+     */
130
+    public function printPage() {
131
+        $data = $this->fetchPage();
132
+        if( $data === false ) {
133
+            return false;
134
+        }
135
+        else{
136
+            print $data;
137
+            return true;
138
+        }
139
+    }
140
+
141
+    /**
142
+     * Process the template
143
+     *
144
+     * @param array|null $additionalParams
145
+     * @return string This function processes the template.
146
+     *
147
+     * This function processes the template.
148
+     */
149
+    public function fetchPage($additionalParams = null) {
150
+        return $this->load($this->template, $additionalParams);
151
+    }
152
+
153
+    /**
154
+     * doing the actual work
155
+     *
156
+     * @param string $file
157
+     * @param array|null $additionalParams
158
+     * @return string content
159
+     *
160
+     * Includes the template file, fetches its output
161
+     */
162
+    protected function load($file, $additionalParams = null) {
163
+        // Register the variables
164
+        $_ = $this->vars;
165
+        $l = $this->l10n;
166
+        $theme = $this->theme;
167
+
168
+        if(!is_null($additionalParams)) {
169
+            $_ = array_merge( $additionalParams, $this->vars );
170
+            foreach ($_ as $var => $value) {
171
+                ${$var} = $value;
172
+            }
173
+        }
174
+
175
+        // Include
176
+        ob_start();
177
+        try {
178
+            include $file;
179
+            $data = ob_get_contents();
180
+        } catch (\Exception $e) {
181
+            @ob_end_clean();
182
+            throw $e;
183
+        }
184
+        @ob_end_clean();
185
+
186
+        // Return data
187
+        return $data;
188
+    }
189 189
 
190 190
 }
Please login to merge, or discard this patch.
lib/private/Template/ResourceNotFoundException.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -24,23 +24,23 @@
 block discarded – undo
24 24
 namespace OC\Template;
25 25
 
26 26
 class ResourceNotFoundException extends \LogicException {
27
-	protected $resource;
28
-	protected $webPath;
27
+    protected $resource;
28
+    protected $webPath;
29 29
 
30
-	/**
31
-	 * @param string $resource
32
-	 * @param string $webPath
33
-	 */
34
-	public function __construct($resource, $webPath) {
35
-		parent::__construct('Resource not found');
36
-		$this->resource = $resource;
37
-		$this->webPath = $webPath;
38
-	}
30
+    /**
31
+     * @param string $resource
32
+     * @param string $webPath
33
+     */
34
+    public function __construct($resource, $webPath) {
35
+        parent::__construct('Resource not found');
36
+        $this->resource = $resource;
37
+        $this->webPath = $webPath;
38
+    }
39 39
 
40
-	/**
41
-	 * @return string
42
-	 */
43
-	public function getResourcePath() {
44
-		return $this->webPath . '/' . $this->resource;
45
-	}
40
+    /**
41
+     * @return string
42
+     */
43
+    public function getResourcePath() {
44
+        return $this->webPath . '/' . $this->resource;
45
+    }
46 46
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,6 +41,6 @@
 block discarded – undo
41 41
 	 * @return string
42 42
 	 */
43 43
 	public function getResourcePath() {
44
-		return $this->webPath . '/' . $this->resource;
44
+		return $this->webPath.'/'.$this->resource;
45 45
 	}
46 46
 }
Please login to merge, or discard this patch.