Completed
Pull Request — master (#3385)
by Christoph
13:42
created
lib/private/legacy/template.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 *                         "admin".
70 70
 	 * @param bool $registerCall = true
71 71
 	 */
72
-	public function __construct( $app, $name, $renderAs = "", $registerCall = true ) {
72
+	public function __construct($app, $name, $renderAs = "", $registerCall = true) {
73 73
 		// Read the selected theme from the config file
74 74
 		self::initTemplateEngine($renderAs);
75 75
 
@@ -95,31 +95,31 @@  discard block
 block discarded – undo
95 95
 	 * @param string $renderAs
96 96
 	 */
97 97
 	public static function initTemplateEngine($renderAs) {
98
-		if (self::$initTemplateEngineFirstRun){
98
+		if (self::$initTemplateEngineFirstRun) {
99 99
 
100 100
 			//apps that started before the template initialization can load their own scripts/styles
101 101
 			//so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true
102 102
 			//meaning the last script/style in this list will be loaded first
103
-			if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) {
104
-				if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') {
105
-					OC_Util::addScript ( 'backgroundjobs', null, true );
103
+			if (\OC::$server->getSystemConfig()->getValue('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) {
104
+				if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') {
105
+					OC_Util::addScript('backgroundjobs', null, true);
106 106
 				}
107 107
 			}
108 108
 
109
-			OC_Util::addStyle("tooltip",null,true);
110
-			OC_Util::addStyle('jquery-ui-fixes',null,true);
111
-			OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true);
112
-			OC_Util::addStyle("mobile",null,true);
113
-			OC_Util::addStyle("multiselect",null,true);
114
-			OC_Util::addStyle("fixes",null,true);
115
-			OC_Util::addStyle("global",null,true);
116
-			OC_Util::addStyle("apps",null,true);
117
-			OC_Util::addStyle("fonts",null,true);
118
-			OC_Util::addStyle("icons",null,true);
119
-			OC_Util::addStyle("actions",null,true);
120
-			OC_Util::addStyle("header",null,true);
109
+			OC_Util::addStyle("tooltip", null, true);
110
+			OC_Util::addStyle('jquery-ui-fixes', null, true);
111
+			OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui', null, true);
112
+			OC_Util::addStyle("mobile", null, true);
113
+			OC_Util::addStyle("multiselect", null, true);
114
+			OC_Util::addStyle("fixes", null, true);
115
+			OC_Util::addStyle("global", null, true);
116
+			OC_Util::addStyle("apps", null, true);
117
+			OC_Util::addStyle("fonts", null, true);
118
+			OC_Util::addStyle("icons", null, true);
119
+			OC_Util::addStyle("actions", null, true);
120
+			OC_Util::addStyle("header", null, true);
121 121
 			OC_Util::addStyle("inputs");
122
-			OC_Util::addStyle("styles",null,true);
122
+			OC_Util::addStyle("styles", null, true);
123 123
 
124 124
 			// avatars
125 125
 			\OC_Util::addScript('jquery.avatar', null, true);
@@ -154,13 +154,13 @@  discard block
 block discarded – undo
154 154
 			// Add the stuff we need always
155 155
 			// following logic will import all vendor libraries that are
156 156
 			// specified in core/js/core.json
157
-			$fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json');
158
-			if($fileContent !== false) {
157
+			$fileContent = file_get_contents(OC::$SERVERROOT.'/core/js/core.json');
158
+			if ($fileContent !== false) {
159 159
 				$coreDependencies = json_decode($fileContent, true);
160
-				foreach(array_reverse($coreDependencies['vendor']) as $vendorLibrary) {
160
+				foreach (array_reverse($coreDependencies['vendor']) as $vendorLibrary) {
161 161
 					// remove trailing ".js" as addVendorScript will append it
162 162
 					OC_Util::addVendorScript(
163
-							substr($vendorLibrary, 0, strlen($vendorLibrary) - 3),null,true);
163
+							substr($vendorLibrary, 0, strlen($vendorLibrary) - 3), null, true);
164 164
 				}
165 165
 			} else {
166 166
 				throw new \Exception('Cannot read core/js/core.json');
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
 	 */
192 192
 	protected function findTemplate($theme, $app, $name) {
193 193
 		// Check if it is a app template or not.
194
-		if( $app !== '' ) {
194
+		if ($app !== '') {
195 195
 			$dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app));
196 196
 		} else {
197 197
 			$dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT);
198 198
 		}
199
-		$locator = new \OC\Template\TemplateFileLocator( $dirs );
199
+		$locator = new \OC\Template\TemplateFileLocator($dirs);
200 200
 		$template = $locator->find($name);
201 201
 		$path = $locator->getPath();
202 202
 		return array($path, $template);
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
 	 * @param string $text the text content for the element. If $text is null then the
210 210
 	 * element will be written as empty element. So use "" to get a closing tag.
211 211
 	 */
212
-	public function addHeader($tag, $attributes, $text=null) {
213
-		$this->headers[]= array(
212
+	public function addHeader($tag, $attributes, $text = null) {
213
+		$this->headers[] = array(
214 214
 			'tag' => $tag,
215 215
 			'attributes' => $attributes,
216 216
 			'text' => $text
@@ -227,14 +227,14 @@  discard block
 block discarded – undo
227 227
 	public function fetchPage($additionalParams = null) {
228 228
 		$data = parent::fetchPage($additionalParams);
229 229
 
230
-		if( $this->renderAs ) {
230
+		if ($this->renderAs) {
231 231
 			$page = new TemplateLayout($this->renderAs, $this->app);
232 232
 
233 233
 			// Add custom headers
234 234
 			$headers = '';
235
-			foreach(OC_Util::$headers as $header) {
235
+			foreach (OC_Util::$headers as $header) {
236 236
 				$headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']);
237
-				foreach($header['attributes'] as $name=>$value) {
237
+				foreach ($header['attributes'] as $name=>$value) {
238 238
 					$headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"';
239 239
 				}
240 240
 				if ($header['text'] !== null) {
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
 	 * Includes another template. use <?php echo $this->inc('template'); ?> to
264 264
 	 * do this.
265 265
 	 */
266
-	public function inc( $file, $additionalParams = null ) {
266
+	public function inc($file, $additionalParams = null) {
267 267
 		return $this->load($this->path.$file.'.php', $additionalParams);
268 268
 	}
269 269
 
@@ -274,10 +274,10 @@  discard block
 block discarded – undo
274 274
 	 * @param array $parameters Parameters for the template
275 275
 	 * @return boolean|null
276 276
 	 */
277
-	public static function printUserPage( $application, $name, $parameters = array() ) {
278
-		$content = new OC_Template( $application, $name, "user" );
279
-		foreach( $parameters as $key => $value ) {
280
-			$content->assign( $key, $value );
277
+	public static function printUserPage($application, $name, $parameters = array()) {
278
+		$content = new OC_Template($application, $name, "user");
279
+		foreach ($parameters as $key => $value) {
280
+			$content->assign($key, $value);
281 281
 		}
282 282
 		print $content->printPage();
283 283
 	}
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
 	 * @param array $parameters Parameters for the template
290 290
 	 * @return bool
291 291
 	 */
292
-	public static function printAdminPage( $application, $name, $parameters = array() ) {
293
-		$content = new OC_Template( $application, $name, "admin" );
294
-		foreach( $parameters as $key => $value ) {
295
-			$content->assign( $key, $value );
292
+	public static function printAdminPage($application, $name, $parameters = array()) {
293
+		$content = new OC_Template($application, $name, "admin");
294
+		foreach ($parameters as $key => $value) {
295
+			$content->assign($key, $value);
296 296
 		}
297 297
 		return $content->printPage();
298 298
 	}
@@ -304,10 +304,10 @@  discard block
 block discarded – undo
304 304
 	 * @param array|string $parameters Parameters for the template
305 305
 	 * @return bool
306 306
 	 */
307
-	public static function printGuestPage( $application, $name, $parameters = array() ) {
308
-		$content = new OC_Template( $application, $name, "guest" );
309
-		foreach( $parameters as $key => $value ) {
310
-			$content->assign( $key, $value );
307
+	public static function printGuestPage($application, $name, $parameters = array()) {
308
+		$content = new OC_Template($application, $name, "guest");
309
+		foreach ($parameters as $key => $value) {
310
+			$content->assign($key, $value);
311 311
 		}
312 312
 		return $content->printPage();
313 313
 	}
@@ -317,23 +317,23 @@  discard block
 block discarded – undo
317 317
 		* @param string $error_msg The error message to show
318 318
 		* @param string $hint An optional hint message - needs to be properly escaped
319 319
 		*/
320
-	public static function printErrorPage( $error_msg, $hint = '' ) {
320
+	public static function printErrorPage($error_msg, $hint = '') {
321 321
 		if ($error_msg === $hint) {
322 322
 			// If the hint is the same as the message there is no need to display it twice.
323 323
 			$hint = '';
324 324
 		}
325 325
 
326 326
 		try {
327
-			$content = new \OC_Template( '', 'error', 'error', false );
327
+			$content = new \OC_Template('', 'error', 'error', false);
328 328
 			$errors = array(array('error' => $error_msg, 'hint' => $hint));
329
-			$content->assign( 'errors', $errors );
329
+			$content->assign('errors', $errors);
330 330
 			$content->printPage();
331 331
 		} catch (\Exception $e) {
332 332
 			$logger = \OC::$server->getLogger();
333 333
 			$logger->error("$error_msg $hint", ['app' => 'core']);
334 334
 			$logger->logException($e, ['app' => 'core']);
335 335
 
336
-			header(self::getHttpProtocol() . ' 500 Internal Server Error');
336
+			header(self::getHttpProtocol().' 500 Internal Server Error');
337 337
 			header('Content-Type: text/plain; charset=utf-8');
338 338
 			print("$error_msg $hint");
339 339
 		}
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 			$logger->logException($exception, ['app' => 'core']);
367 367
 			$logger->logException($e, ['app' => 'core']);
368 368
 
369
-			header(self::getHttpProtocol() . ' 500 Internal Server Error');
369
+			header(self::getHttpProtocol().' 500 Internal Server Error');
370 370
 			header('Content-Type: text/plain; charset=utf-8');
371 371
 			print("Internal Server Error\n\n");
372 372
 			print("The server encountered an internal error and was unable to complete your request.\n");
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 			'HTTP/1.1',
393 393
 			'HTTP/2',
394 394
 		];
395
-		if(in_array($claimedProtocol, $validProtocols, true)) {
395
+		if (in_array($claimedProtocol, $validProtocols, true)) {
396 396
 			return $claimedProtocol;
397 397
 		}
398 398
 		return 'HTTP/1.1';
Please login to merge, or discard this patch.
core/templates/layout.user.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 		<meta charset="utf-8">
5 5
 		<title>
6 6
 			<?php
7
-				p(!empty($_['application'])?$_['application'].' - ':'');
7
+				p(!empty($_['application']) ? $_['application'].' - ' : '');
8 8
 				p($theme->getTitle());
9 9
 			?>
10 10
 		</title>
@@ -14,16 +14,16 @@  discard block
 block discarded – undo
14 14
 		<meta name="apple-itunes-app" content="app-id=<?php p($theme->getiTunesAppId()); ?>">
15 15
 		<meta name="apple-mobile-web-app-capable" content="yes">
16 16
 		<meta name="apple-mobile-web-app-status-bar-style" content="black">
17
-		<meta name="apple-mobile-web-app-title" content="<?php p((!empty($_['application']) && $_['appid']!='files')? $_['application']:$theme->getTitle()); ?>">
17
+		<meta name="apple-mobile-web-app-title" content="<?php p((!empty($_['application']) && $_['appid'] != 'files') ? $_['application'] : $theme->getTitle()); ?>">
18 18
 		<meta name="mobile-web-app-capable" content="yes">
19 19
 		<meta name="theme-color" content="<?php p($theme->getMailHeaderColor()); ?>">
20 20
 		<link rel="icon" href="<?php print_unescaped(image_path($_['appid'], 'favicon.ico')); /* IE11+ supports png */ ?>">
21 21
 		<link rel="apple-touch-icon-precomposed" href="<?php print_unescaped(image_path($_['appid'], 'favicon-touch.png')); ?>">
22 22
 		<link rel="mask-icon" sizes="any" href="<?php print_unescaped(image_path($_['appid'], 'favicon-mask.svg')); ?>" color="#0082c9">
23
-		<?php foreach($_['cssfiles'] as $cssfile): ?>
23
+		<?php foreach ($_['cssfiles'] as $cssfile): ?>
24 24
 			<link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>">
25 25
 		<?php endforeach; ?>
26
-		<?php foreach($_['printcssfiles'] as $cssfile): ?>
26
+		<?php foreach ($_['printcssfiles'] as $cssfile): ?>
27 27
 			<link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>" media="print">
28 28
 		<?php endforeach; ?>
29 29
 		<?php if (isset($_['inline_ocjs'])): ?>
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 				<?php print_unescaped($_['inline_ocjs']); ?>
32 32
 			</script>
33 33
 		<?php endif; ?>
34
-		<?php foreach($_['jsfiles'] as $jsfile): ?>
34
+		<?php foreach ($_['jsfiles'] as $jsfile): ?>
35 35
 			<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php print_unescaped($jsfile); ?>"></script>
36 36
 		<?php endforeach; ?>
37 37
 		<?php print_unescaped($_['headers']); ?>
38 38
 	</head>
39
-	<body id="<?php p($_['bodyid']);?>">
39
+	<body id="<?php p($_['bodyid']); ?>">
40 40
 	<?php include('layout.noscript.warning.php'); ?>
41 41
 	<div id="notification-container">
42 42
 		<div id="notification"></div>
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 				<a href="#" class="header-appname-container menutoggle" tabindex="2">
56 56
 					<h1 class="header-appname">
57
-						<?php p(!empty($_['application'])?$_['application']: $l->t('Apps')); ?>
57
+						<?php p(!empty($_['application']) ? $_['application'] : $l->t('Apps')); ?>
58 58
 					</h1>
59 59
 					<span class="icon-caret"></span>
60 60
 				</a>
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 			<div id="header-right">
65 65
 				<form class="searchbox" action="#" method="post" role="search" novalidate>
66 66
 					<label for="searchbox" class="hidden-visually">
67
-						<?php p($l->t('Search'));?>
67
+						<?php p($l->t('Search')); ?>
68 68
 					</label>
69 69
 					<input id="searchbox" type="search" name="query"
70 70
 						value="" required
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 						<div class="avatardiv<?php if ($_['userAvatarSet']) { print_unescaped(' avatardiv-shown'); } else { print_unescaped('" style="display: none'); } ?>">
77 77
 							<?php if ($_['userAvatarSet']): ?>
78 78
 								<img alt="" width="32" height="32"
79
-								src="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 32, 'v' => $_['userAvatarVersion']]));?>"
80
-								srcset="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 64, 'v' => $_['userAvatarVersion']]));?> 2x, <?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 128, 'v' => $_['userAvatarVersion']]));?> 4x"
79
+								src="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 32, 'v' => $_['userAvatarVersion']])); ?>"
80
+								srcset="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 64, 'v' => $_['userAvatarVersion']])); ?> 2x, <?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 128, 'v' => $_['userAvatarVersion']])); ?> 4x"
81 81
 								>
82 82
 							<?php endif; ?>
83 83
 						</div>
@@ -86,19 +86,19 @@  discard block
 block discarded – undo
86 86
 					</div>
87 87
 					<div id="expanddiv">
88 88
 					<ul>
89
-					<?php foreach($_['settingsnavigation'] as $entry):?>
89
+					<?php foreach ($_['settingsnavigation'] as $entry):?>
90 90
 						<li>
91 91
 							<a href="<?php print_unescaped($entry['href']); ?>"
92
-								<?php if( $entry["active"] ): ?> class="active"<?php endif; ?>>
93
-								<img alt="" src="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>">
92
+								<?php if ($entry["active"]): ?> class="active"<?php endif; ?>>
93
+								<img alt="" src="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>">
94 94
 								<?php p($entry['name']) ?>
95 95
 							</a>
96 96
 						</li>
97 97
 					<?php endforeach; ?>
98 98
 						<li>
99 99
 							<a id="logout" <?php print_unescaped(OC_User::getLogoutAttribute()); ?>>
100
-								<img alt="" src="<?php print_unescaped(image_path('', 'actions/logout.svg') . '?v=' . $_['versionHash']); ?>">
101
-								<?php p($l->t('Log out'));?>
100
+								<img alt="" src="<?php print_unescaped(image_path('', 'actions/logout.svg').'?v='.$_['versionHash']); ?>">
101
+								<?php p($l->t('Log out')); ?>
102 102
 							</a>
103 103
 						</li>
104 104
 					</ul>
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
 		<nav role="navigation"><div id="navigation">
111 111
 			<div id="apps">
112 112
 				<ul>
113
-				<?php foreach($_['navigation'] as $entry): ?>
113
+				<?php foreach ($_['navigation'] as $entry): ?>
114 114
 					<li data-id="<?php p($entry['id']); ?>">
115 115
 						<a href="<?php print_unescaped($entry['href']); ?>" tabindex="3"
116
-							<?php if( $entry['active'] ): ?> class="active"<?php endif; ?>>
116
+							<?php if ($entry['active']): ?> class="active"<?php endif; ?>>
117 117
 							<svg width="32" height="32" viewBox="0 0 32 32">
118 118
 								<defs><filter id="invert"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0"></feColorMatrix></filter></defs>
119
-								<image x="0" y="0" width="32" height="32" preserveAspectRatio="xMinYMin meet" filter="url(#invert)" xlink:href="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>"  class="app-icon"></image>
119
+								<image x="0" y="0" width="32" height="32" preserveAspectRatio="xMinYMin meet" filter="url(#invert)" xlink:href="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>"  class="app-icon"></image>
120 120
 							</svg>
121 121
 							<div class="icon-loading-dark" style="display:none;"></div>
122 122
 							<span>
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
 				<?php endforeach; ?>
128 128
 				<?php
129 129
 					/* show "More apps" link to app administration directly in app navigation, as last entry */
130
-					if(OC_User::isAdminUser(OC_User::getUser())):
130
+					if (OC_User::isAdminUser(OC_User::getUser())):
131 131
 				?>
132 132
 					<li id="apps-management">
133 133
 						<a href="<?php print_unescaped(\OC::$server->getURLGenerator()->linkToRoute('settings.AppSettings.viewApps')); ?>" tabindex="4"
134
-							<?php if( $_['appsmanagement_active'] ): ?> class="active"<?php endif; ?>>
134
+							<?php if ($_['appsmanagement_active']): ?> class="active"<?php endif; ?>>
135 135
 							<svg width="32" height="32" viewBox="0 0 32 32" class="app-icon">
136 136
 								<defs><filter id="invert"><feColorMatrix in="SourceGraphic" type="matrix" values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0"></feColorMatrix></filter></defs>
137
-								<image x="0" y="0" width="32" height="32" preserveAspectRatio="xMinYMin meet" filter="url(#invert)" xlink:href="<?php print_unescaped(image_path('settings', 'apps.svg') . '?v=' . $_['versionHash']); ?>"></image>
137
+								<image x="0" y="0" width="32" height="32" preserveAspectRatio="xMinYMin meet" filter="url(#invert)" xlink:href="<?php print_unescaped(image_path('settings', 'apps.svg').'?v='.$_['versionHash']); ?>"></image>
138 138
 							</svg>
139 139
 							<div class="icon-loading-dark" style="display:none;"></div>
140 140
 							<span>
Please login to merge, or discard this patch.