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