Passed
Push — master ( 9d8e1e...a5b0f4 )
by Roeland
13:05 queued 14s
created
lib/private/legacy/template.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	 *                         "admin".
73 73
 	 * @param bool $registerCall = true
74 74
 	 */
75
-	public function __construct( $app, $name, $renderAs = "", $registerCall = true ) {
75
+	public function __construct($app, $name, $renderAs = "", $registerCall = true) {
76 76
 		// Read the selected theme from the config file
77 77
 		self::initTemplateEngine($renderAs);
78 78
 
@@ -99,21 +99,21 @@  discard block
 block discarded – undo
99 99
 	 * @param string $renderAs
100 100
 	 */
101 101
 	public static function initTemplateEngine($renderAs) {
102
-		if (self::$initTemplateEngineFirstRun){
102
+		if (self::$initTemplateEngineFirstRun) {
103 103
 
104 104
 			//apps that started before the template initialization can load their own scripts/styles
105 105
 			//so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true
106 106
 			//meaning the last script/style in this list will be loaded first
107
-			if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) {
108
-				if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') {
109
-					OC_Util::addScript ( 'backgroundjobs', null, true );
107
+			if (\OC::$server->getSystemConfig()->getValue('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) {
108
+				if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') {
109
+					OC_Util::addScript('backgroundjobs', null, true);
110 110
 				}
111 111
 			}
112 112
 			OC_Util::addStyle('css-variables', null, true);
113 113
 			OC_Util::addStyle('server', null, true);
114 114
 			OC_Util::addTranslations('core', null, true);
115 115
 
116
-			if (\OC::$server->getSystemConfig()->getValue ('installed', false)) {
116
+			if (\OC::$server->getSystemConfig()->getValue('installed', false)) {
117 117
 				OC_Util::addStyle('search', 'results');
118 118
 				OC_Util::addScript('search', 'search', true);
119 119
 				OC_Util::addScript('search', 'searchprovider');
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
 	 */
147 147
 	protected function findTemplate($theme, $app, $name) {
148 148
 		// Check if it is a app template or not.
149
-		if( $app !== '' ) {
149
+		if ($app !== '') {
150 150
 			$dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app));
151 151
 		} else {
152 152
 			$dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT);
153 153
 		}
154
-		$locator = new \OC\Template\TemplateFileLocator( $dirs );
154
+		$locator = new \OC\Template\TemplateFileLocator($dirs);
155 155
 		$template = $locator->find($name);
156 156
 		$path = $locator->getPath();
157 157
 		return array($path, $template);
@@ -164,8 +164,8 @@  discard block
 block discarded – undo
164 164
 	 * @param string $text the text content for the element. If $text is null then the
165 165
 	 * element will be written as empty element. So use "" to get a closing tag.
166 166
 	 */
167
-	public function addHeader($tag, $attributes, $text=null) {
168
-		$this->headers[]= array(
167
+	public function addHeader($tag, $attributes, $text = null) {
168
+		$this->headers[] = array(
169 169
 			'tag' => $tag,
170 170
 			'attributes' => $attributes,
171 171
 			'text' => $text
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
 	public function fetchPage($additionalParams = null) {
183 183
 		$data = parent::fetchPage($additionalParams);
184 184
 
185
-		if( $this->renderAs ) {
185
+		if ($this->renderAs) {
186 186
 			$page = new TemplateLayout($this->renderAs, $this->app);
187 187
 
188
-			if(is_array($additionalParams)) {
188
+			if (is_array($additionalParams)) {
189 189
 				foreach ($additionalParams as $key => $value) {
190 190
 					$page->assign($key, $value);
191 191
 				}
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 
194 194
 			// Add custom headers
195 195
 			$headers = '';
196
-			foreach(OC_Util::$headers as $header) {
196
+			foreach (OC_Util::$headers as $header) {
197 197
 				$headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']);
198
-				if ( strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes']))) ) {
198
+				if (strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes'])))) {
199 199
 					$headers .= ' defer';
200 200
 				}
201
-				foreach($header['attributes'] as $name=>$value) {
201
+				foreach ($header['attributes'] as $name=>$value) {
202 202
 					$headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"';
203 203
 				}
204 204
 				if ($header['text'] !== null) {
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 * Includes another template. use <?php echo $this->inc('template'); ?> to
228 228
 	 * do this.
229 229
 	 */
230
-	public function inc( $file, $additionalParams = null ) {
230
+	public function inc($file, $additionalParams = null) {
231 231
 		return $this->load($this->path.$file.'.php', $additionalParams);
232 232
 	}
233 233
 
@@ -238,10 +238,10 @@  discard block
 block discarded – undo
238 238
 	 * @param array $parameters Parameters for the template
239 239
 	 * @return boolean|null
240 240
 	 */
241
-	public static function printUserPage( $application, $name, $parameters = array() ) {
242
-		$content = new OC_Template( $application, $name, "user" );
243
-		foreach( $parameters as $key => $value ) {
244
-			$content->assign( $key, $value );
241
+	public static function printUserPage($application, $name, $parameters = array()) {
242
+		$content = new OC_Template($application, $name, "user");
243
+		foreach ($parameters as $key => $value) {
244
+			$content->assign($key, $value);
245 245
 		}
246 246
 		print $content->printPage();
247 247
 	}
@@ -253,10 +253,10 @@  discard block
 block discarded – undo
253 253
 	 * @param array $parameters Parameters for the template
254 254
 	 * @return bool
255 255
 	 */
256
-	public static function printAdminPage( $application, $name, $parameters = array() ) {
257
-		$content = new OC_Template( $application, $name, "admin" );
258
-		foreach( $parameters as $key => $value ) {
259
-			$content->assign( $key, $value );
256
+	public static function printAdminPage($application, $name, $parameters = array()) {
257
+		$content = new OC_Template($application, $name, "admin");
258
+		foreach ($parameters as $key => $value) {
259
+			$content->assign($key, $value);
260 260
 		}
261 261
 		return $content->printPage();
262 262
 	}
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
 	 * @param array|string $parameters Parameters for the template
269 269
 	 * @return bool
270 270
 	 */
271
-	public static function printGuestPage( $application, $name, $parameters = array() ) {
271
+	public static function printGuestPage($application, $name, $parameters = array()) {
272 272
 		$content = new OC_Template($application, $name, $name === 'error' ? $name : 'guest');
273
-		foreach( $parameters as $key => $value ) {
274
-			$content->assign( $key, $value );
273
+		foreach ($parameters as $key => $value) {
274
+			$content->assign($key, $value);
275 275
 		}
276 276
 		return $content->printPage();
277 277
 	}
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	 * @param int $statusCode
284 284
 	 * @suppress PhanAccessMethodInternal
285 285
 	 */
286
-	public static function printErrorPage( $error_msg, $hint = '', $statusCode = 500) {
286
+	public static function printErrorPage($error_msg, $hint = '', $statusCode = 500) {
287 287
 		if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) {
288 288
 			\OC_App::loadApp('theming');
289 289
 		}
@@ -296,9 +296,9 @@  discard block
 block discarded – undo
296 296
 
297 297
 		http_response_code($statusCode);
298 298
 		try {
299
-			$content = new \OC_Template( '', 'error', 'error', false );
299
+			$content = new \OC_Template('', 'error', 'error', false);
300 300
 			$errors = array(array('error' => $error_msg, 'hint' => $hint));
301
-			$content->assign( 'errors', $errors );
301
+			$content->assign('errors', $errors);
302 302
 			$content->printPage();
303 303
 		} catch (\Exception $e) {
304 304
 			$logger = \OC::$server->getLogger();
Please login to merge, or discard this patch.