Completed
Push — master ( dfe944...0dae49 )
by Morris
12:59
created
core/templates/layout.guest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,27 +13,27 @@
 block discarded – undo
13 13
 		<link rel="icon" href="<?php print_unescaped(image_path('', 'favicon.ico')); /* IE11+ supports png */ ?>">
14 14
 		<link rel="apple-touch-icon-precomposed" href="<?php print_unescaped(image_path('', 'favicon-touch.png')); ?>">
15 15
 		<link rel="mask-icon" sizes="any" href="<?php print_unescaped(image_path('', 'favicon-mask.svg')); ?>" color="<?php p($theme->getColorPrimary()); ?>">
16
-		<?php foreach($_['cssfiles'] as $cssfile): ?>
16
+		<?php foreach ($_['cssfiles'] as $cssfile): ?>
17 17
 			<link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>">
18 18
 		<?php endforeach; ?>
19
-		<?php foreach($_['printcssfiles'] as $cssfile): ?>
19
+		<?php foreach ($_['printcssfiles'] as $cssfile): ?>
20 20
 			<link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>" media="print">
21 21
 		<?php endforeach; ?>
22 22
 		<?php emit_script_loading_tags($_); ?>
23 23
 		<?php print_unescaped($_['headers']); ?>
24 24
 	</head>
25
-	<body id="<?php p($_['bodyid']);?>">
25
+	<body id="<?php p($_['bodyid']); ?>">
26 26
 		<?php include('layout.noscript.warning.php'); ?>
27 27
 		<div class="wrapper">
28 28
 			<div class="v-align">
29
-				<?php if ($_['bodyid'] === 'body-login' ): ?>
29
+				<?php if ($_['bodyid'] === 'body-login'): ?>
30 30
 					<header role="banner">
31 31
 						<div id="header">
32 32
 							<div class="logo">
33 33
 								<h1 class="hidden-visually">
34 34
 									<?php p($theme->getName()); ?>
35 35
 								</h1>
36
-								<?php if(\OC::$server->getConfig()->getSystemValue('installed', false)
36
+								<?php if (\OC::$server->getConfig()->getSystemValue('installed', false)
37 37
 									&& \OC::$server->getConfig()->getAppValue('theming', 'logoMime', false)): ?>
38 38
 									<img src="<?php p($theme->getLogo()); ?>"/>
39 39
 								<?php endif; ?>
Please login to merge, or discard this patch.
core/templates/layout.user.php 1 patch
Spacing   +16 added lines, -16 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,23 +14,23 @@  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->getColorPrimary()); ?>">
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="<?php p($theme->getColorPrimary()); ?>">
23 23
 		<link rel="manifest" href="<?php print_unescaped(image_path($_['appid'], 'manifest.json')); ?>">
24
-		<?php foreach($_['cssfiles'] as $cssfile): ?>
24
+		<?php foreach ($_['cssfiles'] as $cssfile): ?>
25 25
 			<link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>">
26 26
 		<?php endforeach; ?>
27
-		<?php foreach($_['printcssfiles'] as $cssfile): ?>
27
+		<?php foreach ($_['printcssfiles'] as $cssfile): ?>
28 28
 			<link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>" media="print">
29 29
 		<?php endforeach; ?>
30 30
 		<?php emit_script_loading_tags($_); ?>
31 31
 		<?php print_unescaped($_['headers']); ?>
32 32
 	</head>
33
-	<body id="<?php p($_['bodyid']);?>">
33
+	<body id="<?php p($_['bodyid']); ?>">
34 34
 	<?php include('layout.noscript.warning.php'); ?>
35 35
 	<div id="notification-container">
36 36
 		<div id="notification"></div>
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 
49 49
 				<a href="#" class="header-appname-container menutoggle" tabindex="2">
50 50
 					<h1 class="header-appname">
51
-						<?php p(!empty($_['application'])?$_['application']: $l->t('Apps')); ?>
51
+						<?php p(!empty($_['application']) ? $_['application'] : $l->t('Apps')); ?>
52 52
 					</h1>
53 53
 					<div class="icon-caret"></div>
54 54
 				</a>
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 							<a href="<?php print_unescaped($entry['href']); ?>"
60 60
 							   tabindex="3"
61 61
 								<?php if ($entry['active']): ?> class="active"<?php endif; ?>>
62
-								<img src="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>"
62
+								<img src="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>"
63 63
 									 class="app-icon"/>
64 64
 								<div class="icon-loading-small-dark"
65 65
 									 style="display:none;"></div>
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 					<div id="navigation" style="display: none;">
82 82
 						<div id="apps">
83 83
 							<ul>
84
-								<?php foreach($_['navigation'] as $entry): ?>
84
+								<?php foreach ($_['navigation'] as $entry): ?>
85 85
 									<li data-id="<?php p($entry['id']); ?>">
86 86
 									<a href="<?php print_unescaped($entry['href']); ?>" tabindex="3"
87
-										<?php if( $entry['active'] ): ?> class="active"<?php endif; ?>>
87
+										<?php if ($entry['active']): ?> class="active"<?php endif; ?>>
88 88
 										<svg width="16" height="16" viewBox="0 0 16 16">
89 89
 											<defs><filter id="invert-<?php p($entry['id']); ?>"><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>
90
-											<image x="0" y="0" width="16" height="16" preserveAspectRatio="xMinYMin meet" filter="url(#invert-<?php p($entry['id']); ?>)" xlink:href="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>"  class="app-icon"></image>
90
+											<image x="0" y="0" width="16" height="16" preserveAspectRatio="xMinYMin meet" filter="url(#invert-<?php p($entry['id']); ?>)" xlink:href="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>"  class="app-icon"></image>
91 91
 										</svg>
92 92
 										<div class="icon-loading-small-dark" style="display:none;"></div>
93 93
 										<span><?php p($entry['name']); ?></span>
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 			<div id="header-right">
105 105
 				<form class="searchbox" action="#" method="post" role="search" novalidate>
106 106
 					<label for="searchbox" class="hidden-visually">
107
-						<?php p($l->t('Search'));?>
107
+						<?php p($l->t('Search')); ?>
108 108
 					</label>
109 109
 					<input id="searchbox" type="search" name="query"
110 110
 						value="" required
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
 						<div class="avatardiv<?php if ($_['userAvatarSet']) { print_unescaped(' avatardiv-shown'); } else { print_unescaped('" style="display: none'); } ?>">
121 121
 							<?php if ($_['userAvatarSet']): ?>
122 122
 								<img alt="" width="32" height="32"
123
-								src="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 32, 'v' => $_['userAvatarVersion']]));?>"
124
-								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"
123
+								src="<?php p(\OC::$server->getURLGenerator()->linkToRoute('core.avatar.getAvatar', ['userId' => $_['user_uid'], 'size' => 32, 'v' => $_['userAvatarVersion']])); ?>"
124
+								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"
125 125
 								>
126 126
 							<?php endif; ?>
127 127
 						</div>
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
 					</div>
130 130
 					<div id="expanddiv" style="display:none;">
131 131
 					<ul>
132
-					<?php foreach($_['settingsnavigation'] as $entry):?>
132
+					<?php foreach ($_['settingsnavigation'] as $entry):?>
133 133
 						<li>
134 134
 							<a href="<?php print_unescaped($entry['href']); ?>"
135
-								<?php if( $entry["active"] ): ?> class="active"<?php endif; ?>>
136
-								<img alt="" src="<?php print_unescaped($entry['icon'] . '?v=' . $_['versionHash']); ?>">
135
+								<?php if ($entry["active"]): ?> class="active"<?php endif; ?>>
136
+								<img alt="" src="<?php print_unescaped($entry['icon'].'?v='.$_['versionHash']); ?>">
137 137
 								<?php p($entry['name']) ?>
138 138
 							</a>
139 139
 						</li>
Please login to merge, or discard this patch.
core/templates/layout.base.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 		<?php foreach ($_['cssfiles'] as $cssfile): ?>
16 16
 			<link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>">
17 17
 		<?php endforeach; ?>
18
-		<?php foreach($_['printcssfiles'] as $cssfile): ?>
18
+		<?php foreach ($_['printcssfiles'] as $cssfile): ?>
19 19
 			<link rel="stylesheet" href="<?php print_unescaped($cssfile); ?>" media="print">
20 20
 		<?php endforeach; ?>
21 21
 		<?php emit_script_loading_tags($_); ?>
Please login to merge, or discard this patch.
lib/private/legacy/template/functions.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -42,7 +42,6 @@  discard block
 block discarded – undo
42 42
  * Prints a <script> tag with nonce and defer depending on config
43 43
  * @param string $src the source URL, ignored when empty
44 44
  * @param string $script_content the inline script content, ignored when empty
45
- * @param bool $defer_flag deferred loading or not
46 45
 */
47 46
 function emit_script_tag($src, $script_content) {
48 47
 	$defer_str=' defer';
@@ -76,7 +75,7 @@  discard block
 block discarded – undo
76 75
 /**
77 76
  * Prints an unsanitized string - usage of this function may result into XSS.
78 77
  * Consider using p() instead.
79
- * @param string|array $string the string which will be printed as it is
78
+ * @param string $string the string which will be printed as it is
80 79
  */
81 80
 function print_unescaped($string) {
82 81
 	print($string);
@@ -219,7 +218,7 @@  discard block
 block discarded – undo
219 218
  * make preview_icon available as a simple function
220 219
  * Returns the path to the preview of the image.
221 220
  * @param string $path path of file
222
- * @return link to the preview
221
+ * @return string to the preview
223 222
  */
224 223
 function preview_icon( $path ) {
225 224
 	return \OC::$server->getURLGenerator()->linkToRoute('core.Preview.getPreview', ['x' => 32, 'y' => 32, 'file' => $path]);
@@ -227,6 +226,7 @@  discard block
 block discarded – undo
227 226
 
228 227
 /**
229 228
  * @param string $path
229
+ * @param string $token
230 230
  */
231 231
 function publicPreview_icon ( $path, $token ) {
232 232
 	return \OC::$server->getURLGenerator()->linkToRoute('files_sharing.PublicPreview.getPreview', ['x' => 32, 'y' => 32, 'file' => $path, 't' => $token]);
Please login to merge, or discard this patch.
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
  * @param string $string the string which will be escaped and printed
36 36
  */
37 37
 function p($string) {
38
-	print(\OCP\Util::sanitizeHTML($string));
38
+    print(\OCP\Util::sanitizeHTML($string));
39 39
 }
40 40
 
41 41
 /**
@@ -45,32 +45,32 @@  discard block
 block discarded – undo
45 45
  * @param bool $defer_flag deferred loading or not
46 46
 */
47 47
 function emit_script_tag($src, $script_content) {
48
-	$defer_str=' defer';
49
-	$s='<script nonce="' . \OC::$server->getContentSecurityPolicyNonceManager()->getNonce() . '"';
50
-	if (!empty($src)) {
51
-		 // emit script tag for deferred loading from $src
52
-		$s.=$defer_str.' src="' . $src .'">';
53
-	} else if (!empty($script_content)) {
54
-		// emit script tag for inline script from $script_content without defer (see MDN)
55
-		$s.=">\n".$script_content."\n";
56
-	} else {
57
-		// no $src nor $src_content, really useless empty tag
58
-		$s.='>';
59
-	}
60
-	$s.='</script>';
61
-	print_unescaped($s."\n");
48
+    $defer_str=' defer';
49
+    $s='<script nonce="' . \OC::$server->getContentSecurityPolicyNonceManager()->getNonce() . '"';
50
+    if (!empty($src)) {
51
+            // emit script tag for deferred loading from $src
52
+        $s.=$defer_str.' src="' . $src .'">';
53
+    } else if (!empty($script_content)) {
54
+        // emit script tag for inline script from $script_content without defer (see MDN)
55
+        $s.=">\n".$script_content."\n";
56
+    } else {
57
+        // no $src nor $src_content, really useless empty tag
58
+        $s.='>';
59
+    }
60
+    $s.='</script>';
61
+    print_unescaped($s."\n");
62 62
 }
63 63
 
64 64
 /**
65 65
  * @param hash $obj all the script information from template
66 66
 */
67 67
 function emit_script_loading_tags($obj) {
68
-	if (!empty($obj['inline_ocjs'])) {
69
-		emit_script_tag('', $obj['inline_ocjs']);
70
-	}
71
-	foreach($obj['jsfiles'] as $jsfile) {
72
-		emit_script_tag($jsfile, '');
73
-	}
68
+    if (!empty($obj['inline_ocjs'])) {
69
+        emit_script_tag('', $obj['inline_ocjs']);
70
+    }
71
+    foreach($obj['jsfiles'] as $jsfile) {
72
+        emit_script_tag($jsfile, '');
73
+    }
74 74
 }
75 75
 
76 76
 /**
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
  * @param string|array $string the string which will be printed as it is
80 80
  */
81 81
 function print_unescaped($string) {
82
-	print($string);
82
+    print($string);
83 83
 }
84 84
 
85 85
 /**
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
  * if an array is given it will add all scripts
90 90
  */
91 91
 function script($app, $file = null) {
92
-	if(is_array($file)) {
93
-		foreach($file as $f) {
94
-			OC_Util::addScript($app, $f);
95
-		}
96
-	} else {
97
-		OC_Util::addScript($app, $file);
98
-	}
92
+    if(is_array($file)) {
93
+        foreach($file as $f) {
94
+            OC_Util::addScript($app, $f);
95
+        }
96
+    } else {
97
+        OC_Util::addScript($app, $file);
98
+    }
99 99
 }
100 100
 
101 101
 /**
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
  * if an array is given it will add all scripts
106 106
  */
107 107
 function vendor_script($app, $file = null) {
108
-	if(is_array($file)) {
109
-		foreach($file as $f) {
110
-			OC_Util::addVendorScript($app, $f);
111
-		}
112
-	} else {
113
-		OC_Util::addVendorScript($app, $file);
114
-	}
108
+    if(is_array($file)) {
109
+        foreach($file as $f) {
110
+            OC_Util::addVendorScript($app, $f);
111
+        }
112
+    } else {
113
+        OC_Util::addVendorScript($app, $file);
114
+    }
115 115
 }
116 116
 
117 117
 /**
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
  * if an array is given it will add all styles
122 122
  */
123 123
 function style($app, $file = null) {
124
-	if(is_array($file)) {
125
-		foreach($file as $f) {
126
-			OC_Util::addStyle($app, $f);
127
-		}
128
-	} else {
129
-		OC_Util::addStyle($app, $file);
130
-	}
124
+    if(is_array($file)) {
125
+        foreach($file as $f) {
126
+            OC_Util::addStyle($app, $f);
127
+        }
128
+    } else {
129
+        OC_Util::addStyle($app, $file);
130
+    }
131 131
 }
132 132
 
133 133
 /**
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
  * if an array is given it will add all styles
138 138
  */
139 139
 function vendor_style($app, $file = null) {
140
-	if(is_array($file)) {
141
-		foreach($file as $f) {
142
-			OC_Util::addVendorStyle($app, $f);
143
-		}
144
-	} else {
145
-		OC_Util::addVendorStyle($app, $file);
146
-	}
140
+    if(is_array($file)) {
141
+        foreach($file as $f) {
142
+            OC_Util::addVendorStyle($app, $f);
143
+        }
144
+    } else {
145
+        OC_Util::addVendorStyle($app, $file);
146
+    }
147 147
 }
148 148
 
149 149
 /**
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
  * if an array is given it will add all styles
153 153
  */
154 154
 function translation($app) {
155
-	OC_Util::addTranslations($app);
155
+    OC_Util::addTranslations($app);
156 156
 }
157 157
 
158 158
 /**
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
  * if an array is given it will add all components
163 163
  */
164 164
 function component($app, $file) {
165
-	if(is_array($file)) {
166
-		foreach($file as $f) {
167
-			$url = link_to($app, 'component/' . $f . '.html');
168
-			OC_Util::addHeader('link', array('rel' => 'import', 'href' => $url));
169
-		}
170
-	} else {
171
-		$url = link_to($app, 'component/' . $file . '.html');
172
-		OC_Util::addHeader('link', array('rel' => 'import', 'href' => $url));
173
-	}
165
+    if(is_array($file)) {
166
+        foreach($file as $f) {
167
+            $url = link_to($app, 'component/' . $f . '.html');
168
+            OC_Util::addHeader('link', array('rel' => 'import', 'href' => $url));
169
+        }
170
+    } else {
171
+        $url = link_to($app, 'component/' . $file . '.html');
172
+        OC_Util::addHeader('link', array('rel' => 'import', 'href' => $url));
173
+    }
174 174
 }
175 175
 
176 176
 /**
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
  * For further information have a look at \OCP\IURLGenerator::linkTo
184 184
  */
185 185
 function link_to( $app, $file, $args = array() ) {
186
-	return \OC::$server->getURLGenerator()->linkTo($app, $file, $args);
186
+    return \OC::$server->getURLGenerator()->linkTo($app, $file, $args);
187 187
 }
188 188
 
189 189
 /**
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
  * @return string url to the online documentation
192 192
  */
193 193
 function link_to_docs($key) {
194
-	return \OC::$server->getURLGenerator()->linkToDocs($key);
194
+    return \OC::$server->getURLGenerator()->linkToDocs($key);
195 195
 }
196 196
 
197 197
 /**
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
  * For further information have a look at \OCP\IURLGenerator::imagePath
204 204
  */
205 205
 function image_path( $app, $image ) {
206
-	return \OC::$server->getURLGenerator()->imagePath( $app, $image );
206
+    return \OC::$server->getURLGenerator()->imagePath( $app, $image );
207 207
 }
208 208
 
209 209
 /**
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
  * @return string link to the image
213 213
  */
214 214
 function mimetype_icon( $mimetype ) {
215
-	return \OC::$server->getMimeTypeDetector()->mimeTypeIcon( $mimetype );
215
+    return \OC::$server->getMimeTypeDetector()->mimeTypeIcon( $mimetype );
216 216
 }
217 217
 
218 218
 /**
@@ -222,14 +222,14 @@  discard block
 block discarded – undo
222 222
  * @return link to the preview
223 223
  */
224 224
 function preview_icon( $path ) {
225
-	return \OC::$server->getURLGenerator()->linkToRoute('core.Preview.getPreview', ['x' => 32, 'y' => 32, 'file' => $path]);
225
+    return \OC::$server->getURLGenerator()->linkToRoute('core.Preview.getPreview', ['x' => 32, 'y' => 32, 'file' => $path]);
226 226
 }
227 227
 
228 228
 /**
229 229
  * @param string $path
230 230
  */
231 231
 function publicPreview_icon ( $path, $token ) {
232
-	return \OC::$server->getURLGenerator()->linkToRoute('files_sharing.PublicPreview.getPreview', ['x' => 32, 'y' => 32, 'file' => $path, 't' => $token]);
232
+    return \OC::$server->getURLGenerator()->linkToRoute('files_sharing.PublicPreview.getPreview', ['x' => 32, 'y' => 32, 'file' => $path, 't' => $token]);
233 233
 }
234 234
 
235 235
 /**
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
  * For further information have a look at OC_Helper::humanFileSize
241 241
  */
242 242
 function human_file_size( $bytes ) {
243
-	return OC_Helper::humanFileSize( $bytes );
243
+    return OC_Helper::humanFileSize( $bytes );
244 244
 }
245 245
 
246 246
 /**
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
  * @return $timestamp without time value
250 250
  */
251 251
 function strip_time($timestamp){
252
-	$date = new \DateTime("@{$timestamp}");
253
-	$date->setTime(0, 0, 0);
254
-	return intval($date->format('U'));
252
+    $date = new \DateTime("@{$timestamp}");
253
+    $date->setTime(0, 0, 0);
254
+    return intval($date->format('U'));
255 255
 }
256 256
 
257 257
 /**
@@ -263,39 +263,39 @@  discard block
 block discarded – undo
263 263
  * @return string timestamp
264 264
  */
265 265
 function relative_modified_date($timestamp, $fromTime = null, $dateOnly = false) {
266
-	/** @var \OC\DateTimeFormatter $formatter */
267
-	$formatter = \OC::$server->query('DateTimeFormatter');
266
+    /** @var \OC\DateTimeFormatter $formatter */
267
+    $formatter = \OC::$server->query('DateTimeFormatter');
268 268
 
269
-	if ($dateOnly){
270
-		return $formatter->formatDateSpan($timestamp, $fromTime);
271
-	}
272
-	return $formatter->formatTimeSpan($timestamp, $fromTime);
269
+    if ($dateOnly){
270
+        return $formatter->formatDateSpan($timestamp, $fromTime);
271
+    }
272
+    return $formatter->formatTimeSpan($timestamp, $fromTime);
273 273
 }
274 274
 
275 275
 function html_select_options($options, $selected, $params=array()) {
276
-	if (!is_array($selected)) {
277
-		$selected=array($selected);
278
-	}
279
-	if (isset($params['combine']) && $params['combine']) {
280
-		$options = array_combine($options, $options);
281
-	}
282
-	$value_name = $label_name = false;
283
-	if (isset($params['value'])) {
284
-		$value_name = $params['value'];
285
-	}
286
-	if (isset($params['label'])) {
287
-		$label_name = $params['label'];
288
-	}
289
-	$html = '';
290
-	foreach($options as $value => $label) {
291
-		if ($value_name && is_array($label)) {
292
-			$value = $label[$value_name];
293
-		}
294
-		if ($label_name && is_array($label)) {
295
-			$label = $label[$label_name];
296
-		}
297
-		$select = in_array($value, $selected) ? ' selected="selected"' : '';
298
-		$html .= '<option value="' . \OCP\Util::sanitizeHTML($value) . '"' . $select . '>' . \OCP\Util::sanitizeHTML($label) . '</option>'."\n";
299
-	}
300
-	return $html;
276
+    if (!is_array($selected)) {
277
+        $selected=array($selected);
278
+    }
279
+    if (isset($params['combine']) && $params['combine']) {
280
+        $options = array_combine($options, $options);
281
+    }
282
+    $value_name = $label_name = false;
283
+    if (isset($params['value'])) {
284
+        $value_name = $params['value'];
285
+    }
286
+    if (isset($params['label'])) {
287
+        $label_name = $params['label'];
288
+    }
289
+    $html = '';
290
+    foreach($options as $value => $label) {
291
+        if ($value_name && is_array($label)) {
292
+            $value = $label[$value_name];
293
+        }
294
+        if ($label_name && is_array($label)) {
295
+            $label = $label[$label_name];
296
+        }
297
+        $select = in_array($value, $selected) ? ' selected="selected"' : '';
298
+        $html .= '<option value="' . \OCP\Util::sanitizeHTML($value) . '"' . $select . '>' . \OCP\Util::sanitizeHTML($label) . '</option>'."\n";
299
+    }
300
+    return $html;
301 301
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -45,19 +45,19 @@  discard block
 block discarded – undo
45 45
  * @param bool $defer_flag deferred loading or not
46 46
 */
47 47
 function emit_script_tag($src, $script_content) {
48
-	$defer_str=' defer';
49
-	$s='<script nonce="' . \OC::$server->getContentSecurityPolicyNonceManager()->getNonce() . '"';
48
+	$defer_str = ' defer';
49
+	$s = '<script nonce="'.\OC::$server->getContentSecurityPolicyNonceManager()->getNonce().'"';
50 50
 	if (!empty($src)) {
51 51
 		 // emit script tag for deferred loading from $src
52
-		$s.=$defer_str.' src="' . $src .'">';
52
+		$s .= $defer_str.' src="'.$src.'">';
53 53
 	} else if (!empty($script_content)) {
54 54
 		// emit script tag for inline script from $script_content without defer (see MDN)
55
-		$s.=">\n".$script_content."\n";
55
+		$s .= ">\n".$script_content."\n";
56 56
 	} else {
57 57
 		// no $src nor $src_content, really useless empty tag
58
-		$s.='>';
58
+		$s .= '>';
59 59
 	}
60
-	$s.='</script>';
60
+	$s .= '</script>';
61 61
 	print_unescaped($s."\n");
62 62
 }
63 63
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	if (!empty($obj['inline_ocjs'])) {
69 69
 		emit_script_tag('', $obj['inline_ocjs']);
70 70
 	}
71
-	foreach($obj['jsfiles'] as $jsfile) {
71
+	foreach ($obj['jsfiles'] as $jsfile) {
72 72
 		emit_script_tag($jsfile, '');
73 73
 	}
74 74
 }
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
  * if an array is given it will add all scripts
90 90
  */
91 91
 function script($app, $file = null) {
92
-	if(is_array($file)) {
93
-		foreach($file as $f) {
92
+	if (is_array($file)) {
93
+		foreach ($file as $f) {
94 94
 			OC_Util::addScript($app, $f);
95 95
 		}
96 96
 	} else {
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
  * if an array is given it will add all scripts
106 106
  */
107 107
 function vendor_script($app, $file = null) {
108
-	if(is_array($file)) {
109
-		foreach($file as $f) {
108
+	if (is_array($file)) {
109
+		foreach ($file as $f) {
110 110
 			OC_Util::addVendorScript($app, $f);
111 111
 		}
112 112
 	} else {
@@ -121,8 +121,8 @@  discard block
 block discarded – undo
121 121
  * if an array is given it will add all styles
122 122
  */
123 123
 function style($app, $file = null) {
124
-	if(is_array($file)) {
125
-		foreach($file as $f) {
124
+	if (is_array($file)) {
125
+		foreach ($file as $f) {
126 126
 			OC_Util::addStyle($app, $f);
127 127
 		}
128 128
 	} else {
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
  * if an array is given it will add all styles
138 138
  */
139 139
 function vendor_style($app, $file = null) {
140
-	if(is_array($file)) {
141
-		foreach($file as $f) {
140
+	if (is_array($file)) {
141
+		foreach ($file as $f) {
142 142
 			OC_Util::addVendorStyle($app, $f);
143 143
 		}
144 144
 	} else {
@@ -162,13 +162,13 @@  discard block
 block discarded – undo
162 162
  * if an array is given it will add all components
163 163
  */
164 164
 function component($app, $file) {
165
-	if(is_array($file)) {
166
-		foreach($file as $f) {
167
-			$url = link_to($app, 'component/' . $f . '.html');
165
+	if (is_array($file)) {
166
+		foreach ($file as $f) {
167
+			$url = link_to($app, 'component/'.$f.'.html');
168 168
 			OC_Util::addHeader('link', array('rel' => 'import', 'href' => $url));
169 169
 		}
170 170
 	} else {
171
-		$url = link_to($app, 'component/' . $file . '.html');
171
+		$url = link_to($app, 'component/'.$file.'.html');
172 172
 		OC_Util::addHeader('link', array('rel' => 'import', 'href' => $url));
173 173
 	}
174 174
 }
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
  *
183 183
  * For further information have a look at \OCP\IURLGenerator::linkTo
184 184
  */
185
-function link_to( $app, $file, $args = array() ) {
185
+function link_to($app, $file, $args = array()) {
186 186
 	return \OC::$server->getURLGenerator()->linkTo($app, $file, $args);
187 187
 }
188 188
 
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
  *
203 203
  * For further information have a look at \OCP\IURLGenerator::imagePath
204 204
  */
205
-function image_path( $app, $image ) {
206
-	return \OC::$server->getURLGenerator()->imagePath( $app, $image );
205
+function image_path($app, $image) {
206
+	return \OC::$server->getURLGenerator()->imagePath($app, $image);
207 207
 }
208 208
 
209 209
 /**
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
  * @param string $mimetype mimetype
212 212
  * @return string link to the image
213 213
  */
214
-function mimetype_icon( $mimetype ) {
215
-	return \OC::$server->getMimeTypeDetector()->mimeTypeIcon( $mimetype );
214
+function mimetype_icon($mimetype) {
215
+	return \OC::$server->getMimeTypeDetector()->mimeTypeIcon($mimetype);
216 216
 }
217 217
 
218 218
 /**
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
  * @param string $path path of file
222 222
  * @return link to the preview
223 223
  */
224
-function preview_icon( $path ) {
224
+function preview_icon($path) {
225 225
 	return \OC::$server->getURLGenerator()->linkToRoute('core.Preview.getPreview', ['x' => 32, 'y' => 32, 'file' => $path]);
226 226
 }
227 227
 
228 228
 /**
229 229
  * @param string $path
230 230
  */
231
-function publicPreview_icon ( $path, $token ) {
231
+function publicPreview_icon($path, $token) {
232 232
 	return \OC::$server->getURLGenerator()->linkToRoute('files_sharing.PublicPreview.getPreview', ['x' => 32, 'y' => 32, 'file' => $path, 't' => $token]);
233 233
 }
234 234
 
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
  *
240 240
  * For further information have a look at OC_Helper::humanFileSize
241 241
  */
242
-function human_file_size( $bytes ) {
243
-	return OC_Helper::humanFileSize( $bytes );
242
+function human_file_size($bytes) {
243
+	return OC_Helper::humanFileSize($bytes);
244 244
 }
245 245
 
246 246
 /**
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
  * @param int $timestamp UNIX timestamp to strip
249 249
  * @return $timestamp without time value
250 250
  */
251
-function strip_time($timestamp){
251
+function strip_time($timestamp) {
252 252
 	$date = new \DateTime("@{$timestamp}");
253 253
 	$date->setTime(0, 0, 0);
254 254
 	return intval($date->format('U'));
@@ -266,15 +266,15 @@  discard block
 block discarded – undo
266 266
 	/** @var \OC\DateTimeFormatter $formatter */
267 267
 	$formatter = \OC::$server->query('DateTimeFormatter');
268 268
 
269
-	if ($dateOnly){
269
+	if ($dateOnly) {
270 270
 		return $formatter->formatDateSpan($timestamp, $fromTime);
271 271
 	}
272 272
 	return $formatter->formatTimeSpan($timestamp, $fromTime);
273 273
 }
274 274
 
275
-function html_select_options($options, $selected, $params=array()) {
275
+function html_select_options($options, $selected, $params = array()) {
276 276
 	if (!is_array($selected)) {
277
-		$selected=array($selected);
277
+		$selected = array($selected);
278 278
 	}
279 279
 	if (isset($params['combine']) && $params['combine']) {
280 280
 		$options = array_combine($options, $options);
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		$label_name = $params['label'];
288 288
 	}
289 289
 	$html = '';
290
-	foreach($options as $value => $label) {
290
+	foreach ($options as $value => $label) {
291 291
 		if ($value_name && is_array($label)) {
292 292
 			$value = $label[$value_name];
293 293
 		}
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 			$label = $label[$label_name];
296 296
 		}
297 297
 		$select = in_array($value, $selected) ? ' selected="selected"' : '';
298
-		$html .= '<option value="' . \OCP\Util::sanitizeHTML($value) . '"' . $select . '>' . \OCP\Util::sanitizeHTML($label) . '</option>'."\n";
298
+		$html .= '<option value="'.\OCP\Util::sanitizeHTML($value).'"'.$select.'>'.\OCP\Util::sanitizeHTML($label).'</option>'."\n";
299 299
 	}
300 300
 	return $html;
301 301
 }
Please login to merge, or discard this patch.
lib/private/legacy/template.php 2 patches
Indentation   +335 added lines, -335 removed lines patch added patch discarded remove patch
@@ -45,339 +45,339 @@
 block discarded – undo
45 45
  */
46 46
 class OC_Template extends \OC\Template\Base {
47 47
 
48
-	/** @var string */
49
-	private $renderAs; // Create a full page?
50
-
51
-	/** @var string */
52
-	private $path; // The path to the template
53
-
54
-	/** @var array */
55
-	private $headers = array(); //custom headers
56
-
57
-	/** @var string */
58
-	protected $app; // app id
59
-
60
-	protected static $initTemplateEngineFirstRun = true;
61
-
62
-	/**
63
-	 * Constructor
64
-	 *
65
-	 * @param string $app app providing the template
66
-	 * @param string $name of the template file (without suffix)
67
-	 * @param string $renderAs If $renderAs is set, OC_Template will try to
68
-	 *                         produce a full page in the according layout. For
69
-	 *                         now, $renderAs can be set to "guest", "user" or
70
-	 *                         "admin".
71
-	 * @param bool $registerCall = true
72
-	 */
73
-	public function __construct( $app, $name, $renderAs = "", $registerCall = true ) {
74
-		// Read the selected theme from the config file
75
-		self::initTemplateEngine($renderAs);
76
-
77
-		$theme = OC_Util::getTheme();
78
-
79
-		$requestToken = (OC::$server->getSession() && $registerCall) ? \OCP\Util::callRegister() : '';
80
-
81
-		$parts = explode('/', $app); // fix translation when app is something like core/lostpassword
82
-		$l10n = \OC::$server->getL10N($parts[0]);
83
-		/** @var \OCP\Defaults $themeDefaults */
84
-		$themeDefaults = \OC::$server->query(\OCP\Defaults::class);
85
-
86
-		list($path, $template) = $this->findTemplate($theme, $app, $name);
87
-
88
-		// Set the private data
89
-		$this->renderAs = $renderAs;
90
-		$this->path = $path;
91
-		$this->app = $app;
92
-
93
-		parent::__construct($template, $requestToken, $l10n, $themeDefaults);
94
-	}
95
-
96
-	/**
97
-	 * @param string $renderAs
98
-	 */
99
-	public static function initTemplateEngine($renderAs) {
100
-		if (self::$initTemplateEngineFirstRun){
101
-
102
-			//apps that started before the template initialization can load their own scripts/styles
103
-			//so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true
104
-			//meaning the last script/style in this list will be loaded first
105
-			if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) {
106
-				if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') {
107
-					OC_Util::addScript ( 'backgroundjobs', null, true );
108
-				}
109
-			}
110
-
111
-			OC_Util::addStyle('jquery-ui-fixes',null,true);
112
-			OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true);
113
-			OC_Util::addStyle('server', null, true);
114
-			OC_Util::addVendorStyle('select2/select2', null, true);
115
-			OC_Util::addStyle('jquery.ocdialog');
116
-			OC_Util::addTranslations("core", null, true);
117
-			OC_Util::addScript('search', 'search', true);
118
-			OC_Util::addScript('merged-template-prepend', null, true);
119
-			OC_Util::addScript('jquery-ui-fixes');
120
-			OC_Util::addScript('files/fileinfo');
121
-			OC_Util::addScript('files/client');
122
-			OC_Util::addScript('contactsmenu');
123
-
124
-			if (\OC::$server->getConfig()->getSystemValue('debug')) {
125
-				// Add the stuff we need always
126
-				// following logic will import all vendor libraries that are
127
-				// specified in core/js/core.json
128
-				$fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json');
129
-				if($fileContent !== false) {
130
-					$coreDependencies = json_decode($fileContent, true);
131
-					foreach(array_reverse($coreDependencies['vendor']) as $vendorLibrary) {
132
-						//remove trailing ".js" as addVendorScript will append it
133
-						OC_Util::addVendorScript(
134
-							substr($vendorLibrary, 0, strlen($vendorLibrary) - 3),null,true);
135
-						}
136
- 				} else {
137
-					throw new \Exception('Cannot read core/js/core.json');
138
-				}
139
-			} else {
140
-				// Import all (combined) default vendor libraries
141
-				OC_Util::addVendorScript('core', null, true);
142
-			}
143
-
144
-			if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) {
145
-				// polyfill for btoa/atob for IE friends
146
-				OC_Util::addVendorScript('base64/base64');
147
-				// shim for the davclient.js library
148
-				\OCP\Util::addScript('files/iedavclient');
149
-			}
150
-
151
-			self::$initTemplateEngineFirstRun = false;
152
-		}
153
-
154
-	}
155
-
156
-
157
-	/**
158
-	 * find the template with the given name
159
-	 * @param string $name of the template file (without suffix)
160
-	 *
161
-	 * Will select the template file for the selected theme.
162
-	 * Checking all the possible locations.
163
-	 * @param string $theme
164
-	 * @param string $app
165
-	 * @return string[]
166
-	 */
167
-	protected function findTemplate($theme, $app, $name) {
168
-		// Check if it is a app template or not.
169
-		if( $app !== '' ) {
170
-			$dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app));
171
-		} else {
172
-			$dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT);
173
-		}
174
-		$locator = new \OC\Template\TemplateFileLocator( $dirs );
175
-		$template = $locator->find($name);
176
-		$path = $locator->getPath();
177
-		return array($path, $template);
178
-	}
179
-
180
-	/**
181
-	 * Add a custom element to the header
182
-	 * @param string $tag tag name of the element
183
-	 * @param array $attributes array of attributes for the element
184
-	 * @param string $text the text content for the element. If $text is null then the
185
-	 * element will be written as empty element. So use "" to get a closing tag.
186
-	 */
187
-	public function addHeader($tag, $attributes, $text=null) {
188
-		$this->headers[]= array(
189
-			'tag' => $tag,
190
-			'attributes' => $attributes,
191
-			'text' => $text
192
-		);
193
-	}
194
-
195
-	/**
196
-	 * Process the template
197
-	 * @return boolean|string
198
-	 *
199
-	 * This function process the template. If $this->renderAs is set, it
200
-	 * will produce a full page.
201
-	 */
202
-	public function fetchPage($additionalParams = null) {
203
-		$data = parent::fetchPage($additionalParams);
204
-
205
-		if( $this->renderAs ) {
206
-			$page = new TemplateLayout($this->renderAs, $this->app);
207
-
208
-			// Add custom headers
209
-			$headers = '';
210
-			foreach(OC_Util::$headers as $header) {
211
-				$headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']);
212
-				if ( strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes']))) ) {
213
-					$headers .= ' defer';
214
-				}
215
-				foreach($header['attributes'] as $name=>$value) {
216
-					$headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"';
217
-				}
218
-				if ($header['text'] !== null) {
219
-					$headers .= '>'.\OCP\Util::sanitizeHTML($header['text']).'</'.\OCP\Util::sanitizeHTML($header['tag']).'>';
220
-				} else {
221
-					$headers .= '/>';
222
-				}
223
-			}
224
-
225
-			$page->assign('headers', $headers);
226
-
227
-			$page->assign('content', $data);
228
-			return $page->fetchPage();
229
-		}
230
-
231
-		return $data;
232
-	}
233
-
234
-	/**
235
-	 * Include template
236
-	 *
237
-	 * @param string $file
238
-	 * @param array|null $additionalParams
239
-	 * @return string returns content of included template
240
-	 *
241
-	 * Includes another template. use <?php echo $this->inc('template'); ?> to
242
-	 * do this.
243
-	 */
244
-	public function inc( $file, $additionalParams = null ) {
245
-		return $this->load($this->path.$file.'.php', $additionalParams);
246
-	}
247
-
248
-	/**
249
-	 * Shortcut to print a simple page for users
250
-	 * @param string $application The application we render the template for
251
-	 * @param string $name Name of the template
252
-	 * @param array $parameters Parameters for the template
253
-	 * @return boolean|null
254
-	 */
255
-	public static function printUserPage( $application, $name, $parameters = array() ) {
256
-		$content = new OC_Template( $application, $name, "user" );
257
-		foreach( $parameters as $key => $value ) {
258
-			$content->assign( $key, $value );
259
-		}
260
-		print $content->printPage();
261
-	}
262
-
263
-	/**
264
-	 * Shortcut to print a simple page for admins
265
-	 * @param string $application The application we render the template for
266
-	 * @param string $name Name of the template
267
-	 * @param array $parameters Parameters for the template
268
-	 * @return bool
269
-	 */
270
-	public static function printAdminPage( $application, $name, $parameters = array() ) {
271
-		$content = new OC_Template( $application, $name, "admin" );
272
-		foreach( $parameters as $key => $value ) {
273
-			$content->assign( $key, $value );
274
-		}
275
-		return $content->printPage();
276
-	}
277
-
278
-	/**
279
-	 * Shortcut to print a simple page for guests
280
-	 * @param string $application The application we render the template for
281
-	 * @param string $name Name of the template
282
-	 * @param array|string $parameters Parameters for the template
283
-	 * @return bool
284
-	 */
285
-	public static function printGuestPage( $application, $name, $parameters = array() ) {
286
-		$content = new OC_Template( $application, $name, "guest" );
287
-		foreach( $parameters as $key => $value ) {
288
-			$content->assign( $key, $value );
289
-		}
290
-		return $content->printPage();
291
-	}
292
-
293
-	/**
294
-		* Print a fatal error page and terminates the script
295
-		* @param string $error_msg The error message to show
296
-		* @param string $hint An optional hint message - needs to be properly escaped
297
-		*/
298
-	public static function printErrorPage( $error_msg, $hint = '' ) {
299
-		if (\OC_App::isEnabled('theming') && !\OC_App::isAppLoaded('theming')) {
300
-			\OC_App::loadApp('theming');
301
-		}
302
-
303
-
304
-		if ($error_msg === $hint) {
305
-			// If the hint is the same as the message there is no need to display it twice.
306
-			$hint = '';
307
-		}
308
-
309
-		try {
310
-			$content = new \OC_Template( '', 'error', 'error', false );
311
-			$errors = array(array('error' => $error_msg, 'hint' => $hint));
312
-			$content->assign( 'errors', $errors );
313
-			$content->printPage();
314
-		} catch (\Exception $e) {
315
-			$logger = \OC::$server->getLogger();
316
-			$logger->error("$error_msg $hint", ['app' => 'core']);
317
-			$logger->logException($e, ['app' => 'core']);
318
-
319
-			header(self::getHttpProtocol() . ' 500 Internal Server Error');
320
-			header('Content-Type: text/plain; charset=utf-8');
321
-			print("$error_msg $hint");
322
-		}
323
-		die();
324
-	}
325
-
326
-	/**
327
-	 * print error page using Exception details
328
-	 * @param Exception | Throwable $exception
329
-	 */
330
-	public static function printExceptionErrorPage($exception, $fetchPage = false) {
331
-		try {
332
-			$request = \OC::$server->getRequest();
333
-			$content = new \OC_Template('', 'exception', 'error', false);
334
-			$content->assign('errorClass', get_class($exception));
335
-			$content->assign('errorMsg', $exception->getMessage());
336
-			$content->assign('errorCode', $exception->getCode());
337
-			$content->assign('file', $exception->getFile());
338
-			$content->assign('line', $exception->getLine());
339
-			$content->assign('trace', $exception->getTraceAsString());
340
-			$content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false));
341
-			$content->assign('remoteAddr', $request->getRemoteAddress());
342
-			$content->assign('requestID', $request->getId());
343
-			if ($fetchPage) {
344
-				return $content->fetchPage();
345
-			}
346
-			$content->printPage();
347
-		} catch (\Exception $e) {
348
-			$logger = \OC::$server->getLogger();
349
-			$logger->logException($exception, ['app' => 'core']);
350
-			$logger->logException($e, ['app' => 'core']);
351
-
352
-			header(self::getHttpProtocol() . ' 500 Internal Server Error');
353
-			header('Content-Type: text/plain; charset=utf-8');
354
-			print("Internal Server Error\n\n");
355
-			print("The server encountered an internal error and was unable to complete your request.\n");
356
-			print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n");
357
-			print("More details can be found in the server log.\n");
358
-		}
359
-		die();
360
-	}
361
-
362
-	/**
363
-	 * This is only here to reduce the dependencies in case of an exception to
364
-	 * still be able to print a plain error message.
365
-	 *
366
-	 * Returns the used HTTP protocol.
367
-	 *
368
-	 * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0.
369
-	 * @internal Don't use this - use AppFramework\Http\Request->getHttpProtocol instead
370
-	 */
371
-	protected static function getHttpProtocol() {
372
-		$claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']);
373
-		$validProtocols = [
374
-			'HTTP/1.0',
375
-			'HTTP/1.1',
376
-			'HTTP/2',
377
-		];
378
-		if(in_array($claimedProtocol, $validProtocols, true)) {
379
-			return $claimedProtocol;
380
-		}
381
-		return 'HTTP/1.1';
382
-	}
48
+    /** @var string */
49
+    private $renderAs; // Create a full page?
50
+
51
+    /** @var string */
52
+    private $path; // The path to the template
53
+
54
+    /** @var array */
55
+    private $headers = array(); //custom headers
56
+
57
+    /** @var string */
58
+    protected $app; // app id
59
+
60
+    protected static $initTemplateEngineFirstRun = true;
61
+
62
+    /**
63
+     * Constructor
64
+     *
65
+     * @param string $app app providing the template
66
+     * @param string $name of the template file (without suffix)
67
+     * @param string $renderAs If $renderAs is set, OC_Template will try to
68
+     *                         produce a full page in the according layout. For
69
+     *                         now, $renderAs can be set to "guest", "user" or
70
+     *                         "admin".
71
+     * @param bool $registerCall = true
72
+     */
73
+    public function __construct( $app, $name, $renderAs = "", $registerCall = true ) {
74
+        // Read the selected theme from the config file
75
+        self::initTemplateEngine($renderAs);
76
+
77
+        $theme = OC_Util::getTheme();
78
+
79
+        $requestToken = (OC::$server->getSession() && $registerCall) ? \OCP\Util::callRegister() : '';
80
+
81
+        $parts = explode('/', $app); // fix translation when app is something like core/lostpassword
82
+        $l10n = \OC::$server->getL10N($parts[0]);
83
+        /** @var \OCP\Defaults $themeDefaults */
84
+        $themeDefaults = \OC::$server->query(\OCP\Defaults::class);
85
+
86
+        list($path, $template) = $this->findTemplate($theme, $app, $name);
87
+
88
+        // Set the private data
89
+        $this->renderAs = $renderAs;
90
+        $this->path = $path;
91
+        $this->app = $app;
92
+
93
+        parent::__construct($template, $requestToken, $l10n, $themeDefaults);
94
+    }
95
+
96
+    /**
97
+     * @param string $renderAs
98
+     */
99
+    public static function initTemplateEngine($renderAs) {
100
+        if (self::$initTemplateEngineFirstRun){
101
+
102
+            //apps that started before the template initialization can load their own scripts/styles
103
+            //so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true
104
+            //meaning the last script/style in this list will be loaded first
105
+            if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) {
106
+                if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') {
107
+                    OC_Util::addScript ( 'backgroundjobs', null, true );
108
+                }
109
+            }
110
+
111
+            OC_Util::addStyle('jquery-ui-fixes',null,true);
112
+            OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true);
113
+            OC_Util::addStyle('server', null, true);
114
+            OC_Util::addVendorStyle('select2/select2', null, true);
115
+            OC_Util::addStyle('jquery.ocdialog');
116
+            OC_Util::addTranslations("core", null, true);
117
+            OC_Util::addScript('search', 'search', true);
118
+            OC_Util::addScript('merged-template-prepend', null, true);
119
+            OC_Util::addScript('jquery-ui-fixes');
120
+            OC_Util::addScript('files/fileinfo');
121
+            OC_Util::addScript('files/client');
122
+            OC_Util::addScript('contactsmenu');
123
+
124
+            if (\OC::$server->getConfig()->getSystemValue('debug')) {
125
+                // Add the stuff we need always
126
+                // following logic will import all vendor libraries that are
127
+                // specified in core/js/core.json
128
+                $fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json');
129
+                if($fileContent !== false) {
130
+                    $coreDependencies = json_decode($fileContent, true);
131
+                    foreach(array_reverse($coreDependencies['vendor']) as $vendorLibrary) {
132
+                        //remove trailing ".js" as addVendorScript will append it
133
+                        OC_Util::addVendorScript(
134
+                            substr($vendorLibrary, 0, strlen($vendorLibrary) - 3),null,true);
135
+                        }
136
+                    } else {
137
+                    throw new \Exception('Cannot read core/js/core.json');
138
+                }
139
+            } else {
140
+                // Import all (combined) default vendor libraries
141
+                OC_Util::addVendorScript('core', null, true);
142
+            }
143
+
144
+            if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) {
145
+                // polyfill for btoa/atob for IE friends
146
+                OC_Util::addVendorScript('base64/base64');
147
+                // shim for the davclient.js library
148
+                \OCP\Util::addScript('files/iedavclient');
149
+            }
150
+
151
+            self::$initTemplateEngineFirstRun = false;
152
+        }
153
+
154
+    }
155
+
156
+
157
+    /**
158
+     * find the template with the given name
159
+     * @param string $name of the template file (without suffix)
160
+     *
161
+     * Will select the template file for the selected theme.
162
+     * Checking all the possible locations.
163
+     * @param string $theme
164
+     * @param string $app
165
+     * @return string[]
166
+     */
167
+    protected function findTemplate($theme, $app, $name) {
168
+        // Check if it is a app template or not.
169
+        if( $app !== '' ) {
170
+            $dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app));
171
+        } else {
172
+            $dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT);
173
+        }
174
+        $locator = new \OC\Template\TemplateFileLocator( $dirs );
175
+        $template = $locator->find($name);
176
+        $path = $locator->getPath();
177
+        return array($path, $template);
178
+    }
179
+
180
+    /**
181
+     * Add a custom element to the header
182
+     * @param string $tag tag name of the element
183
+     * @param array $attributes array of attributes for the element
184
+     * @param string $text the text content for the element. If $text is null then the
185
+     * element will be written as empty element. So use "" to get a closing tag.
186
+     */
187
+    public function addHeader($tag, $attributes, $text=null) {
188
+        $this->headers[]= array(
189
+            'tag' => $tag,
190
+            'attributes' => $attributes,
191
+            'text' => $text
192
+        );
193
+    }
194
+
195
+    /**
196
+     * Process the template
197
+     * @return boolean|string
198
+     *
199
+     * This function process the template. If $this->renderAs is set, it
200
+     * will produce a full page.
201
+     */
202
+    public function fetchPage($additionalParams = null) {
203
+        $data = parent::fetchPage($additionalParams);
204
+
205
+        if( $this->renderAs ) {
206
+            $page = new TemplateLayout($this->renderAs, $this->app);
207
+
208
+            // Add custom headers
209
+            $headers = '';
210
+            foreach(OC_Util::$headers as $header) {
211
+                $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']);
212
+                if ( strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes']))) ) {
213
+                    $headers .= ' defer';
214
+                }
215
+                foreach($header['attributes'] as $name=>$value) {
216
+                    $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"';
217
+                }
218
+                if ($header['text'] !== null) {
219
+                    $headers .= '>'.\OCP\Util::sanitizeHTML($header['text']).'</'.\OCP\Util::sanitizeHTML($header['tag']).'>';
220
+                } else {
221
+                    $headers .= '/>';
222
+                }
223
+            }
224
+
225
+            $page->assign('headers', $headers);
226
+
227
+            $page->assign('content', $data);
228
+            return $page->fetchPage();
229
+        }
230
+
231
+        return $data;
232
+    }
233
+
234
+    /**
235
+     * Include template
236
+     *
237
+     * @param string $file
238
+     * @param array|null $additionalParams
239
+     * @return string returns content of included template
240
+     *
241
+     * Includes another template. use <?php echo $this->inc('template'); ?> to
242
+     * do this.
243
+     */
244
+    public function inc( $file, $additionalParams = null ) {
245
+        return $this->load($this->path.$file.'.php', $additionalParams);
246
+    }
247
+
248
+    /**
249
+     * Shortcut to print a simple page for users
250
+     * @param string $application The application we render the template for
251
+     * @param string $name Name of the template
252
+     * @param array $parameters Parameters for the template
253
+     * @return boolean|null
254
+     */
255
+    public static function printUserPage( $application, $name, $parameters = array() ) {
256
+        $content = new OC_Template( $application, $name, "user" );
257
+        foreach( $parameters as $key => $value ) {
258
+            $content->assign( $key, $value );
259
+        }
260
+        print $content->printPage();
261
+    }
262
+
263
+    /**
264
+     * Shortcut to print a simple page for admins
265
+     * @param string $application The application we render the template for
266
+     * @param string $name Name of the template
267
+     * @param array $parameters Parameters for the template
268
+     * @return bool
269
+     */
270
+    public static function printAdminPage( $application, $name, $parameters = array() ) {
271
+        $content = new OC_Template( $application, $name, "admin" );
272
+        foreach( $parameters as $key => $value ) {
273
+            $content->assign( $key, $value );
274
+        }
275
+        return $content->printPage();
276
+    }
277
+
278
+    /**
279
+     * Shortcut to print a simple page for guests
280
+     * @param string $application The application we render the template for
281
+     * @param string $name Name of the template
282
+     * @param array|string $parameters Parameters for the template
283
+     * @return bool
284
+     */
285
+    public static function printGuestPage( $application, $name, $parameters = array() ) {
286
+        $content = new OC_Template( $application, $name, "guest" );
287
+        foreach( $parameters as $key => $value ) {
288
+            $content->assign( $key, $value );
289
+        }
290
+        return $content->printPage();
291
+    }
292
+
293
+    /**
294
+     * Print a fatal error page and terminates the script
295
+     * @param string $error_msg The error message to show
296
+     * @param string $hint An optional hint message - needs to be properly escaped
297
+     */
298
+    public static function printErrorPage( $error_msg, $hint = '' ) {
299
+        if (\OC_App::isEnabled('theming') && !\OC_App::isAppLoaded('theming')) {
300
+            \OC_App::loadApp('theming');
301
+        }
302
+
303
+
304
+        if ($error_msg === $hint) {
305
+            // If the hint is the same as the message there is no need to display it twice.
306
+            $hint = '';
307
+        }
308
+
309
+        try {
310
+            $content = new \OC_Template( '', 'error', 'error', false );
311
+            $errors = array(array('error' => $error_msg, 'hint' => $hint));
312
+            $content->assign( 'errors', $errors );
313
+            $content->printPage();
314
+        } catch (\Exception $e) {
315
+            $logger = \OC::$server->getLogger();
316
+            $logger->error("$error_msg $hint", ['app' => 'core']);
317
+            $logger->logException($e, ['app' => 'core']);
318
+
319
+            header(self::getHttpProtocol() . ' 500 Internal Server Error');
320
+            header('Content-Type: text/plain; charset=utf-8');
321
+            print("$error_msg $hint");
322
+        }
323
+        die();
324
+    }
325
+
326
+    /**
327
+     * print error page using Exception details
328
+     * @param Exception | Throwable $exception
329
+     */
330
+    public static function printExceptionErrorPage($exception, $fetchPage = false) {
331
+        try {
332
+            $request = \OC::$server->getRequest();
333
+            $content = new \OC_Template('', 'exception', 'error', false);
334
+            $content->assign('errorClass', get_class($exception));
335
+            $content->assign('errorMsg', $exception->getMessage());
336
+            $content->assign('errorCode', $exception->getCode());
337
+            $content->assign('file', $exception->getFile());
338
+            $content->assign('line', $exception->getLine());
339
+            $content->assign('trace', $exception->getTraceAsString());
340
+            $content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false));
341
+            $content->assign('remoteAddr', $request->getRemoteAddress());
342
+            $content->assign('requestID', $request->getId());
343
+            if ($fetchPage) {
344
+                return $content->fetchPage();
345
+            }
346
+            $content->printPage();
347
+        } catch (\Exception $e) {
348
+            $logger = \OC::$server->getLogger();
349
+            $logger->logException($exception, ['app' => 'core']);
350
+            $logger->logException($e, ['app' => 'core']);
351
+
352
+            header(self::getHttpProtocol() . ' 500 Internal Server Error');
353
+            header('Content-Type: text/plain; charset=utf-8');
354
+            print("Internal Server Error\n\n");
355
+            print("The server encountered an internal error and was unable to complete your request.\n");
356
+            print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n");
357
+            print("More details can be found in the server log.\n");
358
+        }
359
+        die();
360
+    }
361
+
362
+    /**
363
+     * This is only here to reduce the dependencies in case of an exception to
364
+     * still be able to print a plain error message.
365
+     *
366
+     * Returns the used HTTP protocol.
367
+     *
368
+     * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0.
369
+     * @internal Don't use this - use AppFramework\Http\Request->getHttpProtocol instead
370
+     */
371
+    protected static function getHttpProtocol() {
372
+        $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']);
373
+        $validProtocols = [
374
+            'HTTP/1.0',
375
+            'HTTP/1.1',
376
+            'HTTP/2',
377
+        ];
378
+        if(in_array($claimedProtocol, $validProtocols, true)) {
379
+            return $claimedProtocol;
380
+        }
381
+        return 'HTTP/1.1';
382
+    }
383 383
 }
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 *                         "admin".
71 71
 	 * @param bool $registerCall = true
72 72
 	 */
73
-	public function __construct( $app, $name, $renderAs = "", $registerCall = true ) {
73
+	public function __construct($app, $name, $renderAs = "", $registerCall = true) {
74 74
 		// Read the selected theme from the config file
75 75
 		self::initTemplateEngine($renderAs);
76 76
 
@@ -97,19 +97,19 @@  discard block
 block discarded – undo
97 97
 	 * @param string $renderAs
98 98
 	 */
99 99
 	public static function initTemplateEngine($renderAs) {
100
-		if (self::$initTemplateEngineFirstRun){
100
+		if (self::$initTemplateEngineFirstRun) {
101 101
 
102 102
 			//apps that started before the template initialization can load their own scripts/styles
103 103
 			//so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true
104 104
 			//meaning the last script/style in this list will be loaded first
105
-			if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) {
106
-				if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') {
107
-					OC_Util::addScript ( 'backgroundjobs', null, true );
105
+			if (\OC::$server->getSystemConfig()->getValue('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) {
106
+				if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') {
107
+					OC_Util::addScript('backgroundjobs', null, true);
108 108
 				}
109 109
 			}
110 110
 
111
-			OC_Util::addStyle('jquery-ui-fixes',null,true);
112
-			OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true);
111
+			OC_Util::addStyle('jquery-ui-fixes', null, true);
112
+			OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui', null, true);
113 113
 			OC_Util::addStyle('server', null, true);
114 114
 			OC_Util::addVendorStyle('select2/select2', null, true);
115 115
 			OC_Util::addStyle('jquery.ocdialog');
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 				// Add the stuff we need always
126 126
 				// following logic will import all vendor libraries that are
127 127
 				// specified in core/js/core.json
128
-				$fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json');
129
-				if($fileContent !== false) {
128
+				$fileContent = file_get_contents(OC::$SERVERROOT.'/core/js/core.json');
129
+				if ($fileContent !== false) {
130 130
 					$coreDependencies = json_decode($fileContent, true);
131
-					foreach(array_reverse($coreDependencies['vendor']) as $vendorLibrary) {
131
+					foreach (array_reverse($coreDependencies['vendor']) as $vendorLibrary) {
132 132
 						//remove trailing ".js" as addVendorScript will append it
133 133
 						OC_Util::addVendorScript(
134
-							substr($vendorLibrary, 0, strlen($vendorLibrary) - 3),null,true);
134
+							substr($vendorLibrary, 0, strlen($vendorLibrary) - 3), null, true);
135 135
 						}
136 136
  				} else {
137 137
 					throw new \Exception('Cannot read core/js/core.json');
@@ -166,12 +166,12 @@  discard block
 block discarded – undo
166 166
 	 */
167 167
 	protected function findTemplate($theme, $app, $name) {
168 168
 		// Check if it is a app template or not.
169
-		if( $app !== '' ) {
169
+		if ($app !== '') {
170 170
 			$dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app));
171 171
 		} else {
172 172
 			$dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT);
173 173
 		}
174
-		$locator = new \OC\Template\TemplateFileLocator( $dirs );
174
+		$locator = new \OC\Template\TemplateFileLocator($dirs);
175 175
 		$template = $locator->find($name);
176 176
 		$path = $locator->getPath();
177 177
 		return array($path, $template);
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 * @param string $text the text content for the element. If $text is null then the
185 185
 	 * element will be written as empty element. So use "" to get a closing tag.
186 186
 	 */
187
-	public function addHeader($tag, $attributes, $text=null) {
188
-		$this->headers[]= array(
187
+	public function addHeader($tag, $attributes, $text = null) {
188
+		$this->headers[] = array(
189 189
 			'tag' => $tag,
190 190
 			'attributes' => $attributes,
191 191
 			'text' => $text
@@ -202,17 +202,17 @@  discard block
 block discarded – undo
202 202
 	public function fetchPage($additionalParams = null) {
203 203
 		$data = parent::fetchPage($additionalParams);
204 204
 
205
-		if( $this->renderAs ) {
205
+		if ($this->renderAs) {
206 206
 			$page = new TemplateLayout($this->renderAs, $this->app);
207 207
 
208 208
 			// Add custom headers
209 209
 			$headers = '';
210
-			foreach(OC_Util::$headers as $header) {
210
+			foreach (OC_Util::$headers as $header) {
211 211
 				$headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']);
212
-				if ( strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes']))) ) {
212
+				if (strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes'])))) {
213 213
 					$headers .= ' defer';
214 214
 				}
215
-				foreach($header['attributes'] as $name=>$value) {
215
+				foreach ($header['attributes'] as $name=>$value) {
216 216
 					$headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"';
217 217
 				}
218 218
 				if ($header['text'] !== null) {
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 	 * Includes another template. use <?php echo $this->inc('template'); ?> to
242 242
 	 * do this.
243 243
 	 */
244
-	public function inc( $file, $additionalParams = null ) {
244
+	public function inc($file, $additionalParams = null) {
245 245
 		return $this->load($this->path.$file.'.php', $additionalParams);
246 246
 	}
247 247
 
@@ -252,10 +252,10 @@  discard block
 block discarded – undo
252 252
 	 * @param array $parameters Parameters for the template
253 253
 	 * @return boolean|null
254 254
 	 */
255
-	public static function printUserPage( $application, $name, $parameters = array() ) {
256
-		$content = new OC_Template( $application, $name, "user" );
257
-		foreach( $parameters as $key => $value ) {
258
-			$content->assign( $key, $value );
255
+	public static function printUserPage($application, $name, $parameters = array()) {
256
+		$content = new OC_Template($application, $name, "user");
257
+		foreach ($parameters as $key => $value) {
258
+			$content->assign($key, $value);
259 259
 		}
260 260
 		print $content->printPage();
261 261
 	}
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 	 * @param array $parameters Parameters for the template
268 268
 	 * @return bool
269 269
 	 */
270
-	public static function printAdminPage( $application, $name, $parameters = array() ) {
271
-		$content = new OC_Template( $application, $name, "admin" );
272
-		foreach( $parameters as $key => $value ) {
273
-			$content->assign( $key, $value );
270
+	public static function printAdminPage($application, $name, $parameters = array()) {
271
+		$content = new OC_Template($application, $name, "admin");
272
+		foreach ($parameters as $key => $value) {
273
+			$content->assign($key, $value);
274 274
 		}
275 275
 		return $content->printPage();
276 276
 	}
@@ -282,10 +282,10 @@  discard block
 block discarded – undo
282 282
 	 * @param array|string $parameters Parameters for the template
283 283
 	 * @return bool
284 284
 	 */
285
-	public static function printGuestPage( $application, $name, $parameters = array() ) {
286
-		$content = new OC_Template( $application, $name, "guest" );
287
-		foreach( $parameters as $key => $value ) {
288
-			$content->assign( $key, $value );
285
+	public static function printGuestPage($application, $name, $parameters = array()) {
286
+		$content = new OC_Template($application, $name, "guest");
287
+		foreach ($parameters as $key => $value) {
288
+			$content->assign($key, $value);
289 289
 		}
290 290
 		return $content->printPage();
291 291
 	}
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 		* @param string $error_msg The error message to show
296 296
 		* @param string $hint An optional hint message - needs to be properly escaped
297 297
 		*/
298
-	public static function printErrorPage( $error_msg, $hint = '' ) {
298
+	public static function printErrorPage($error_msg, $hint = '') {
299 299
 		if (\OC_App::isEnabled('theming') && !\OC_App::isAppLoaded('theming')) {
300 300
 			\OC_App::loadApp('theming');
301 301
 		}
@@ -307,16 +307,16 @@  discard block
 block discarded – undo
307 307
 		}
308 308
 
309 309
 		try {
310
-			$content = new \OC_Template( '', 'error', 'error', false );
310
+			$content = new \OC_Template('', 'error', 'error', false);
311 311
 			$errors = array(array('error' => $error_msg, 'hint' => $hint));
312
-			$content->assign( 'errors', $errors );
312
+			$content->assign('errors', $errors);
313 313
 			$content->printPage();
314 314
 		} catch (\Exception $e) {
315 315
 			$logger = \OC::$server->getLogger();
316 316
 			$logger->error("$error_msg $hint", ['app' => 'core']);
317 317
 			$logger->logException($e, ['app' => 'core']);
318 318
 
319
-			header(self::getHttpProtocol() . ' 500 Internal Server Error');
319
+			header(self::getHttpProtocol().' 500 Internal Server Error');
320 320
 			header('Content-Type: text/plain; charset=utf-8');
321 321
 			print("$error_msg $hint");
322 322
 		}
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 			$logger->logException($exception, ['app' => 'core']);
350 350
 			$logger->logException($e, ['app' => 'core']);
351 351
 
352
-			header(self::getHttpProtocol() . ' 500 Internal Server Error');
352
+			header(self::getHttpProtocol().' 500 Internal Server Error');
353 353
 			header('Content-Type: text/plain; charset=utf-8');
354 354
 			print("Internal Server Error\n\n");
355 355
 			print("The server encountered an internal error and was unable to complete your request.\n");
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 			'HTTP/1.1',
376 376
 			'HTTP/2',
377 377
 		];
378
-		if(in_array($claimedProtocol, $validProtocols, true)) {
378
+		if (in_array($claimedProtocol, $validProtocols, true)) {
379 379
 			return $claimedProtocol;
380 380
 		}
381 381
 		return 'HTTP/1.1';
Please login to merge, or discard this patch.