Completed
Push — master ( c2b1bd...a7ad7c )
by Joas
109:41 queued 92:38
created
lib/private/legacy/template.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *                         "admin".
72 72
 	 * @param bool $registerCall = true
73 73
 	 */
74
-	public function __construct( $app, $name, $renderAs = "", $registerCall = true ) {
74
+	public function __construct($app, $name, $renderAs = "", $registerCall = true) {
75 75
 		// Read the selected theme from the config file
76 76
 		self::initTemplateEngine($renderAs);
77 77
 
@@ -98,20 +98,20 @@  discard block
 block discarded – undo
98 98
 	 * @param string $renderAs
99 99
 	 */
100 100
 	public static function initTemplateEngine($renderAs) {
101
-		if (self::$initTemplateEngineFirstRun){
101
+		if (self::$initTemplateEngineFirstRun) {
102 102
 
103 103
 			//apps that started before the template initialization can load their own scripts/styles
104 104
 			//so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true
105 105
 			//meaning the last script/style in this list will be loaded first
106
-			if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) {
107
-				if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') {
108
-					OC_Util::addScript ( 'backgroundjobs', null, true );
106
+			if (\OC::$server->getSystemConfig()->getValue('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) {
107
+				if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') {
108
+					OC_Util::addScript('backgroundjobs', null, true);
109 109
 				}
110 110
 			}
111 111
 
112 112
 			OC_Util::addStyle('server', null, true);
113
-			OC_Util::addStyle('jquery-ui-fixes',null,true);
114
-			OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true);
113
+			OC_Util::addStyle('jquery-ui-fixes', null, true);
114
+			OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui', null, true);
115 115
 			OC_Util::addVendorStyle('select2/select2', null, true);
116 116
 			OC_Util::addStyle('jquery.ocdialog');
117 117
 			OC_Util::addTranslations("core", null, true);
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
 				// Add the stuff we need always
127 127
 				// following logic will import all vendor libraries that are
128 128
 				// specified in core/js/core.json
129
-				$fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json');
130
-				if($fileContent !== false) {
129
+				$fileContent = file_get_contents(OC::$SERVERROOT.'/core/js/core.json');
130
+				if ($fileContent !== false) {
131 131
 					$coreDependencies = json_decode($fileContent, true);
132
-					foreach(array_reverse($coreDependencies['vendor']) as $vendorLibrary) {
132
+					foreach (array_reverse($coreDependencies['vendor']) as $vendorLibrary) {
133 133
 						//remove trailing ".js" as addVendorScript will append it
134 134
 						OC_Util::addVendorScript(
135
-							substr($vendorLibrary, 0, -3),null,true);
135
+							substr($vendorLibrary, 0, -3), null, true);
136 136
 						}
137 137
  				} else {
138 138
 					throw new \Exception('Cannot read core/js/core.json');
@@ -167,12 +167,12 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	protected function findTemplate($theme, $app, $name) {
169 169
 		// Check if it is a app template or not.
170
-		if( $app !== '' ) {
170
+		if ($app !== '') {
171 171
 			$dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app));
172 172
 		} else {
173 173
 			$dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT);
174 174
 		}
175
-		$locator = new \OC\Template\TemplateFileLocator( $dirs );
175
+		$locator = new \OC\Template\TemplateFileLocator($dirs);
176 176
 		$template = $locator->find($name);
177 177
 		$path = $locator->getPath();
178 178
 		return array($path, $template);
@@ -185,8 +185,8 @@  discard block
 block discarded – undo
185 185
 	 * @param string $text the text content for the element. If $text is null then the
186 186
 	 * element will be written as empty element. So use "" to get a closing tag.
187 187
 	 */
188
-	public function addHeader($tag, $attributes, $text=null) {
189
-		$this->headers[]= array(
188
+	public function addHeader($tag, $attributes, $text = null) {
189
+		$this->headers[] = array(
190 190
 			'tag' => $tag,
191 191
 			'attributes' => $attributes,
192 192
 			'text' => $text
@@ -203,17 +203,17 @@  discard block
 block discarded – undo
203 203
 	public function fetchPage($additionalParams = null) {
204 204
 		$data = parent::fetchPage($additionalParams);
205 205
 
206
-		if( $this->renderAs ) {
206
+		if ($this->renderAs) {
207 207
 			$page = new TemplateLayout($this->renderAs, $this->app);
208 208
 
209 209
 			// Add custom headers
210 210
 			$headers = '';
211
-			foreach(OC_Util::$headers as $header) {
211
+			foreach (OC_Util::$headers as $header) {
212 212
 				$headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']);
213
-				if ( strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes']))) ) {
213
+				if (strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes'])))) {
214 214
 					$headers .= ' defer';
215 215
 				}
216
-				foreach($header['attributes'] as $name=>$value) {
216
+				foreach ($header['attributes'] as $name=>$value) {
217 217
 					$headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"';
218 218
 				}
219 219
 				if ($header['text'] !== null) {
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 * Includes another template. use <?php echo $this->inc('template'); ?> to
243 243
 	 * do this.
244 244
 	 */
245
-	public function inc( $file, $additionalParams = null ) {
245
+	public function inc($file, $additionalParams = null) {
246 246
 		return $this->load($this->path.$file.'.php', $additionalParams);
247 247
 	}
248 248
 
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 	 * @param array $parameters Parameters for the template
254 254
 	 * @return boolean|null
255 255
 	 */
256
-	public static function printUserPage( $application, $name, $parameters = array() ) {
257
-		$content = new OC_Template( $application, $name, "user" );
258
-		foreach( $parameters as $key => $value ) {
259
-			$content->assign( $key, $value );
256
+	public static function printUserPage($application, $name, $parameters = array()) {
257
+		$content = new OC_Template($application, $name, "user");
258
+		foreach ($parameters as $key => $value) {
259
+			$content->assign($key, $value);
260 260
 		}
261 261
 		print $content->printPage();
262 262
 	}
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
 	 * @param array $parameters Parameters for the template
269 269
 	 * @return bool
270 270
 	 */
271
-	public static function printAdminPage( $application, $name, $parameters = array() ) {
272
-		$content = new OC_Template( $application, $name, "admin" );
273
-		foreach( $parameters as $key => $value ) {
274
-			$content->assign( $key, $value );
271
+	public static function printAdminPage($application, $name, $parameters = array()) {
272
+		$content = new OC_Template($application, $name, "admin");
273
+		foreach ($parameters as $key => $value) {
274
+			$content->assign($key, $value);
275 275
 		}
276 276
 		return $content->printPage();
277 277
 	}
@@ -283,10 +283,10 @@  discard block
 block discarded – undo
283 283
 	 * @param array|string $parameters Parameters for the template
284 284
 	 * @return bool
285 285
 	 */
286
-	public static function printGuestPage( $application, $name, $parameters = array() ) {
287
-		$content = new OC_Template( $application, $name, "guest" );
288
-		foreach( $parameters as $key => $value ) {
289
-			$content->assign( $key, $value );
286
+	public static function printGuestPage($application, $name, $parameters = array()) {
287
+		$content = new OC_Template($application, $name, "guest");
288
+		foreach ($parameters as $key => $value) {
289
+			$content->assign($key, $value);
290 290
 		}
291 291
 		return $content->printPage();
292 292
 	}
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 * @param string $hint An optional hint message - needs to be properly escape
298 298
 	 * @suppress PhanAccessMethodInternal
299 299
 	 */
300
-	public static function printErrorPage( $error_msg, $hint = '' ) {
300
+	public static function printErrorPage($error_msg, $hint = '') {
301 301
 		if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) {
302 302
 			\OC_App::loadApp('theming');
303 303
 		}
@@ -309,16 +309,16 @@  discard block
 block discarded – undo
309 309
 		}
310 310
 
311 311
 		try {
312
-			$content = new \OC_Template( '', 'error', 'error', false );
312
+			$content = new \OC_Template('', 'error', 'error', false);
313 313
 			$errors = array(array('error' => $error_msg, 'hint' => $hint));
314
-			$content->assign( 'errors', $errors );
314
+			$content->assign('errors', $errors);
315 315
 			$content->printPage();
316 316
 		} catch (\Exception $e) {
317 317
 			$logger = \OC::$server->getLogger();
318 318
 			$logger->error("$error_msg $hint", ['app' => 'core']);
319 319
 			$logger->logException($e, ['app' => 'core']);
320 320
 
321
-			header(self::getHttpProtocol() . ' 500 Internal Server Error');
321
+			header(self::getHttpProtocol().' 500 Internal Server Error');
322 322
 			header('Content-Type: text/plain; charset=utf-8');
323 323
 			print("$error_msg $hint");
324 324
 		}
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 			$logger->logException($exception, ['app' => 'core']);
355 355
 			$logger->logException($e, ['app' => 'core']);
356 356
 
357
-			header(self::getHttpProtocol() . ' 500 Internal Server Error');
357
+			header(self::getHttpProtocol().' 500 Internal Server Error');
358 358
 			header('Content-Type: text/plain; charset=utf-8');
359 359
 			print("Internal Server Error\n\n");
360 360
 			print("The server encountered an internal error and was unable to complete your request.\n");
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 			'HTTP/1.1',
381 381
 			'HTTP/2',
382 382
 		];
383
-		if(in_array($claimedProtocol, $validProtocols, true)) {
383
+		if (in_array($claimedProtocol, $validProtocols, true)) {
384 384
 			return $claimedProtocol;
385 385
 		}
386 386
 		return 'HTTP/1.1';
Please login to merge, or discard this patch.