Completed
Pull Request — master (#9723)
by Julius
33:33 queued 06:24
created
apps/theming/lib/ThemingDefaults.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -142,44 +142,44 @@  discard block
 block discarded – undo
142 142
 	}
143 143
 
144 144
 	public function getImprintUrl() {
145
-		return (string)$this->config->getAppValue('theming', 'imprintUrl', '');
145
+		return (string) $this->config->getAppValue('theming', 'imprintUrl', '');
146 146
 	}
147 147
 
148 148
 	public function getPrivacyUrl() {
149
-		return (string)$this->config->getAppValue('theming', 'privacyUrl', '');
149
+		return (string) $this->config->getAppValue('theming', 'privacyUrl', '');
150 150
 	}
151 151
 
152 152
 	public function getShortFooter() {
153 153
 		$slogan = $this->getSlogan();
154
-		$footer = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
155
-			' rel="noreferrer noopener">' .$this->getEntity() . '</a>'.
156
-			($slogan !== '' ? ' – ' . $slogan : '');
154
+		$footer = '<a href="'.$this->getBaseUrl().'" target="_blank"'.
155
+			' rel="noreferrer noopener">'.$this->getEntity().'</a>'.
156
+			($slogan !== '' ? ' – '.$slogan : '');
157 157
 
158 158
 		$links = [
159 159
 			[
160 160
 				'text' => $this->l->t('Legal notice'),
161
-				'url' => (string)$this->getImprintUrl()
161
+				'url' => (string) $this->getImprintUrl()
162 162
 			],
163 163
 			[
164 164
 				'text' => $this->l->t('Privacy policy'),
165
-				'url' => (string)$this->getPrivacyUrl()
165
+				'url' => (string) $this->getPrivacyUrl()
166 166
 			],
167 167
 		];
168 168
 
169 169
 		$legalLinks = ''; $divider = '';
170
-		foreach($links as $link) {
171
-			if($link['url'] !== ''
170
+		foreach ($links as $link) {
171
+			if ($link['url'] !== ''
172 172
 				&& filter_var($link['url'], FILTER_VALIDATE_URL, [
173 173
 					'flags' => FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED
174 174
 				])
175 175
 			) {
176
-				$legalLinks .= $divider . '<a href="' . $link['url'] . '" class="legal" target="_blank"' .
177
-					' rel="noreferrer noopener">' . $link['text'] . '</a>';
176
+				$legalLinks .= $divider.'<a href="'.$link['url'].'" class="legal" target="_blank"'.
177
+					' rel="noreferrer noopener">'.$link['text'].'</a>';
178 178
 				$divider = ' · ';
179 179
 			}
180 180
 		}
181
-		if($legalLinks !== '' ) {
182
-			$footer .= '<br/>' . $legalLinks;
181
+		if ($legalLinks !== '') {
182
+			$footer .= '<br/>'.$legalLinks;
183 183
 		}
184 184
 
185 185
 		return $footer;
@@ -212,16 +212,16 @@  discard block
 block discarded – undo
212 212
 
213 213
 		$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0');
214 214
 
215
-		if(!$logo || !$logoExists) {
216
-			if($useSvg) {
215
+		if (!$logo || !$logoExists) {
216
+			if ($useSvg) {
217 217
 				$logo = $this->urlGenerator->imagePath('core', 'logo.svg');
218 218
 			} else {
219 219
 				$logo = $this->urlGenerator->imagePath('core', 'logo.png');
220 220
 			}
221
-			return $logo . '?v=' . $cacheBusterCounter;
221
+			return $logo.'?v='.$cacheBusterCounter;
222 222
 		}
223 223
 
224
-		return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => 'logo' ]) . '?v=' . $cacheBusterCounter;
224
+		return $this->urlGenerator->linkToRoute('theming.Theming.getImage', ['key' => 'logo']).'?v='.$cacheBusterCounter;
225 225
 	}
226 226
 
227 227
 	/**
@@ -259,17 +259,17 @@  discard block
 block discarded – undo
259 259
 	 * @return array scss variables to overwrite
260 260
 	 */
261 261
 	public function getScssVariables() {
262
-		$cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl());
262
+		$cache = $this->cacheFactory->createDistributed('theming-'.$this->urlGenerator->getBaseUrl());
263 263
 		if ($value = $cache->get('getScssVariables')) {
264 264
 			return $value;
265 265
 		}
266 266
 
267 267
 		$variables = [
268
-			'theming-cachebuster' => "'" . $this->config->getAppValue('theming', 'cachebuster', '0') . "'",
269
-			'theming-logo-mime' => "'" . $this->config->getAppValue('theming', 'logoMime') . "'",
270
-			'theming-background-mime' => "'" . $this->config->getAppValue('theming', 'backgroundMime') . "'",
271
-			'theming-logoheader-mime' => "'" . $this->config->getAppValue('theming', 'logoheaderMime') . "'",
272
-			'theming-favicon-mime' => "'" . $this->config->getAppValue('theming', 'faviconMime') . "'"
268
+			'theming-cachebuster' => "'".$this->config->getAppValue('theming', 'cachebuster', '0')."'",
269
+			'theming-logo-mime' => "'".$this->config->getAppValue('theming', 'logoMime')."'",
270
+			'theming-background-mime' => "'".$this->config->getAppValue('theming', 'backgroundMime')."'",
271
+			'theming-logoheader-mime' => "'".$this->config->getAppValue('theming', 'logoheaderMime')."'",
272
+			'theming-favicon-mime' => "'".$this->config->getAppValue('theming', 'faviconMime')."'"
273 273
 		];
274 274
 
275 275
 		$variables['image-logo'] = "url('".$this->imageManager->getImageUrl('logo')."')";
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 		}
290 290
 
291 291
 		$variables['has-legal-links'] = 'false';
292
-		if($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') {
292
+		if ($this->getImprintUrl() !== '' || $this->getPrivacyUrl() !== '') {
293 293
 			$variables['has-legal-links'] = 'true';
294 294
 		}
295 295
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 	 * @return bool|string false if image should not replaced, otherwise the location of the image
307 307
 	 */
308 308
 	public function replaceImagePath($app, $image) {
309
-		if($app==='') {
309
+		if ($app === '') {
310 310
 			$app = 'core';
311 311
 		}
312 312
 		$cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0');
@@ -318,19 +318,19 @@  discard block
 block discarded – undo
318 318
 		}
319 319
 
320 320
 		if ($image === 'favicon.ico' && ($customFavicon !== null || $this->shouldReplaceIcons())) {
321
-			return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]) . '?v=' . $cacheBusterValue;
321
+			return $this->urlGenerator->linkToRoute('theming.Icon.getFavicon', ['app' => $app]).'?v='.$cacheBusterValue;
322 322
 		}
323 323
 		if ($image === 'favicon-touch.png' && ($customFavicon !== null || $this->shouldReplaceIcons())) {
324
-			return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]) . '?v=' . $cacheBusterValue;
324
+			return $this->urlGenerator->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]).'?v='.$cacheBusterValue;
325 325
 		}
326 326
 		if ($image === 'manifest.json') {
327 327
 			try {
328 328
 				$appPath = $this->appManager->getAppPath($app);
329
-				if (file_exists($appPath . '/img/manifest.json')) {
329
+				if (file_exists($appPath.'/img/manifest.json')) {
330 330
 					return false;
331 331
 				}
332 332
 			} catch (AppPathNotFoundException $e) {}
333
-			return $this->urlGenerator->linkToRoute('theming.Theming.getManifest') . '?v=' . $cacheBusterValue;
333
+			return $this->urlGenerator->linkToRoute('theming.Theming.getManifest').'?v='.$cacheBusterValue;
334 334
 		}
335 335
 		return false;
336 336
 	}
@@ -342,12 +342,12 @@  discard block
 block discarded – undo
342 342
 	 * @return bool
343 343
 	 */
344 344
 	public function shouldReplaceIcons() {
345
-		$cache = $this->cacheFactory->createDistributed('theming-' . $this->urlGenerator->getBaseUrl());
346
-		if($value = $cache->get('shouldReplaceIcons')) {
347
-			return (bool)$value;
345
+		$cache = $this->cacheFactory->createDistributed('theming-'.$this->urlGenerator->getBaseUrl());
346
+		if ($value = $cache->get('shouldReplaceIcons')) {
347
+			return (bool) $value;
348 348
 		}
349 349
 		$value = false;
350
-		if(extension_loaded('imagick')) {
350
+		if (extension_loaded('imagick')) {
351 351
 			$checkImagick = new \Imagick();
352 352
 			if (count($checkImagick->queryFormats('SVG')) >= 1) {
353 353
 				$value = true;
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	 */
364 364
 	private function increaseCacheBuster() {
365 365
 		$cacheBusterKey = $this->config->getAppValue('theming', 'cachebuster', '0');
366
-		$this->config->setAppValue('theming', 'cachebuster', (int)$cacheBusterKey+1);
366
+		$this->config->setAppValue('theming', 'cachebuster', (int) $cacheBusterKey + 1);
367 367
 		$this->cacheFactory->createDistributed('theming-')->clear();
368 368
 		$this->cacheFactory->createDistributed('imagePath')->clear();
369 369
 
Please login to merge, or discard this patch.
lib/private/legacy/template.php 1 patch
Spacing   +39 added lines, -39 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,21 +98,21 @@  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('css-variables', null, true);
113 113
 			OC_Util::addStyle('server', null, true);
114
-			OC_Util::addStyle('jquery-ui-fixes',null,true);
115
-			OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true);
114
+			OC_Util::addStyle('jquery-ui-fixes', null, true);
115
+			OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui', null, true);
116 116
 			OC_Util::addVendorStyle('select2/select2', null, true);
117 117
 			OC_Util::addStyle('jquery.ocdialog');
118 118
 			OC_Util::addTranslations("core", null, true);
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
 				// Add the stuff we need always
128 128
 				// following logic will import all vendor libraries that are
129 129
 				// specified in core/js/core.json
130
-				$fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json');
131
-				if($fileContent !== false) {
130
+				$fileContent = file_get_contents(OC::$SERVERROOT.'/core/js/core.json');
131
+				if ($fileContent !== false) {
132 132
 					$coreDependencies = json_decode($fileContent, true);
133
-					foreach(array_reverse($coreDependencies['vendor']) as $vendorLibrary) {
133
+					foreach (array_reverse($coreDependencies['vendor']) as $vendorLibrary) {
134 134
 						//remove trailing ".js" as addVendorScript will append it
135 135
 						OC_Util::addVendorScript(
136
-							substr($vendorLibrary, 0, -3),null,true);
136
+							substr($vendorLibrary, 0, -3), null, true);
137 137
 						}
138 138
  				} else {
139 139
 					throw new \Exception('Cannot read core/js/core.json');
@@ -168,12 +168,12 @@  discard block
 block discarded – undo
168 168
 	 */
169 169
 	protected function findTemplate($theme, $app, $name) {
170 170
 		// Check if it is a app template or not.
171
-		if( $app !== '' ) {
171
+		if ($app !== '') {
172 172
 			$dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app));
173 173
 		} else {
174 174
 			$dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT);
175 175
 		}
176
-		$locator = new \OC\Template\TemplateFileLocator( $dirs );
176
+		$locator = new \OC\Template\TemplateFileLocator($dirs);
177 177
 		$template = $locator->find($name);
178 178
 		$path = $locator->getPath();
179 179
 		return array($path, $template);
@@ -186,8 +186,8 @@  discard block
 block discarded – undo
186 186
 	 * @param string $text the text content for the element. If $text is null then the
187 187
 	 * element will be written as empty element. So use "" to get a closing tag.
188 188
 	 */
189
-	public function addHeader($tag, $attributes, $text=null) {
190
-		$this->headers[]= array(
189
+	public function addHeader($tag, $attributes, $text = null) {
190
+		$this->headers[] = array(
191 191
 			'tag' => $tag,
192 192
 			'attributes' => $attributes,
193 193
 			'text' => $text
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
 	public function fetchPage($additionalParams = null) {
205 205
 		$data = parent::fetchPage($additionalParams);
206 206
 
207
-		if( $this->renderAs ) {
207
+		if ($this->renderAs) {
208 208
 			$page = new TemplateLayout($this->renderAs, $this->app);
209 209
 
210
-			if(is_array($additionalParams)) {
210
+			if (is_array($additionalParams)) {
211 211
 				foreach ($additionalParams as $key => $value) {
212 212
 					$page->assign($key, $value);
213 213
 				}
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 
216 216
 			// Add custom headers
217 217
 			$headers = '';
218
-			foreach(OC_Util::$headers as $header) {
218
+			foreach (OC_Util::$headers as $header) {
219 219
 				$headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']);
220
-				if ( strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes']))) ) {
220
+				if (strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes'])))) {
221 221
 					$headers .= ' defer';
222 222
 				}
223
-				foreach($header['attributes'] as $name=>$value) {
223
+				foreach ($header['attributes'] as $name=>$value) {
224 224
 					$headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"';
225 225
 				}
226 226
 				if ($header['text'] !== null) {
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 	 * Includes another template. use <?php echo $this->inc('template'); ?> to
250 250
 	 * do this.
251 251
 	 */
252
-	public function inc( $file, $additionalParams = null ) {
252
+	public function inc($file, $additionalParams = null) {
253 253
 		return $this->load($this->path.$file.'.php', $additionalParams);
254 254
 	}
255 255
 
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 	 * @param array $parameters Parameters for the template
261 261
 	 * @return boolean|null
262 262
 	 */
263
-	public static function printUserPage( $application, $name, $parameters = array() ) {
264
-		$content = new OC_Template( $application, $name, "user" );
265
-		foreach( $parameters as $key => $value ) {
266
-			$content->assign( $key, $value );
263
+	public static function printUserPage($application, $name, $parameters = array()) {
264
+		$content = new OC_Template($application, $name, "user");
265
+		foreach ($parameters as $key => $value) {
266
+			$content->assign($key, $value);
267 267
 		}
268 268
 		print $content->printPage();
269 269
 	}
@@ -275,10 +275,10 @@  discard block
 block discarded – undo
275 275
 	 * @param array $parameters Parameters for the template
276 276
 	 * @return bool
277 277
 	 */
278
-	public static function printAdminPage( $application, $name, $parameters = array() ) {
279
-		$content = new OC_Template( $application, $name, "admin" );
280
-		foreach( $parameters as $key => $value ) {
281
-			$content->assign( $key, $value );
278
+	public static function printAdminPage($application, $name, $parameters = array()) {
279
+		$content = new OC_Template($application, $name, "admin");
280
+		foreach ($parameters as $key => $value) {
281
+			$content->assign($key, $value);
282 282
 		}
283 283
 		return $content->printPage();
284 284
 	}
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 	 * @param array|string $parameters Parameters for the template
291 291
 	 * @return bool
292 292
 	 */
293
-	public static function printGuestPage( $application, $name, $parameters = array() ) {
294
-		$content = new OC_Template( $application, $name, "guest" );
295
-		foreach( $parameters as $key => $value ) {
296
-			$content->assign( $key, $value );
293
+	public static function printGuestPage($application, $name, $parameters = array()) {
294
+		$content = new OC_Template($application, $name, "guest");
295
+		foreach ($parameters as $key => $value) {
296
+			$content->assign($key, $value);
297 297
 		}
298 298
 		return $content->printPage();
299 299
 	}
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	 * @param string $hint An optional hint message - needs to be properly escape
305 305
 	 * @suppress PhanAccessMethodInternal
306 306
 	 */
307
-	public static function printErrorPage( $error_msg, $hint = '' ) {
307
+	public static function printErrorPage($error_msg, $hint = '') {
308 308
 		if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) {
309 309
 			\OC_App::loadApp('theming');
310 310
 		}
@@ -316,16 +316,16 @@  discard block
 block discarded – undo
316 316
 		}
317 317
 
318 318
 		try {
319
-			$content = new \OC_Template( '', 'error', 'error', false );
319
+			$content = new \OC_Template('', 'error', 'error', false);
320 320
 			$errors = array(array('error' => $error_msg, 'hint' => $hint));
321
-			$content->assign( 'errors', $errors );
321
+			$content->assign('errors', $errors);
322 322
 			$content->printPage();
323 323
 		} catch (\Exception $e) {
324 324
 			$logger = \OC::$server->getLogger();
325 325
 			$logger->error("$error_msg $hint", ['app' => 'core']);
326 326
 			$logger->logException($e, ['app' => 'core']);
327 327
 
328
-			header(self::getHttpProtocol() . ' 500 Internal Server Error');
328
+			header(self::getHttpProtocol().' 500 Internal Server Error');
329 329
 			header('Content-Type: text/plain; charset=utf-8');
330 330
 			print("$error_msg $hint");
331 331
 		}
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 			$logger->logException($exception, ['app' => 'core']);
362 362
 			$logger->logException($e, ['app' => 'core']);
363 363
 
364
-			header(self::getHttpProtocol() . ' 500 Internal Server Error');
364
+			header(self::getHttpProtocol().' 500 Internal Server Error');
365 365
 			header('Content-Type: text/plain; charset=utf-8');
366 366
 			print("Internal Server Error\n\n");
367 367
 			print("The server encountered an internal error and was unable to complete your request.\n");
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 			'HTTP/1.1',
388 388
 			'HTTP/2',
389 389
 		];
390
-		if(in_array($claimedProtocol, $validProtocols, true)) {
390
+		if (in_array($claimedProtocol, $validProtocols, true)) {
391 391
 			return $claimedProtocol;
392 392
 		}
393 393
 		return 'HTTP/1.1';
Please login to merge, or discard this patch.