Completed
Pull Request — master (#4888)
by Julius
15:06
created
apps/theming/lib/Controller/IconController.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -97,13 +97,13 @@  discard block
 block discarded – undo
97 97
 	 */
98 98
 	public function getThemedIcon($app, $image) {
99 99
 		try {
100
-			$iconFile = $this->imageManager->getCachedImage("icon-" . $app . '-' . str_replace("/","_",$image));
100
+			$iconFile = $this->imageManager->getCachedImage("icon-".$app.'-'.str_replace("/", "_", $image));
101 101
 		} catch (NotFoundException $exception) {
102 102
 			$icon = $this->iconBuilder->colorSvg($app, $image);
103 103
 			if ($icon === false || $icon === "") {
104 104
 				return new NotFoundResponse();
105 105
 			}
106
-			$iconFile = $this->imageManager->setCachedImage("icon-" . $app . '-' . str_replace("/","_",$image), $icon);
106
+			$iconFile = $this->imageManager->setCachedImage("icon-".$app.'-'.str_replace("/", "_", $image), $icon);
107 107
 		}
108 108
 		if ($iconFile !== false) {
109 109
 			$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']);
@@ -132,17 +132,17 @@  discard block
 block discarded – undo
132 132
 		$response = null;
133 133
 		if ($this->themingDefaults->shouldReplaceIcons()) {
134 134
 			try {
135
-				$iconFile = $this->imageManager->getCachedImage('favIcon-' . $app);
135
+				$iconFile = $this->imageManager->getCachedImage('favIcon-'.$app);
136 136
 			} catch (NotFoundException $exception) {
137 137
 				$icon = $this->iconBuilder->getFavicon($app);
138
-				$iconFile = $this->imageManager->setCachedImage('favIcon-' . $app, $icon);
138
+				$iconFile = $this->imageManager->setCachedImage('favIcon-'.$app, $icon);
139 139
 			}
140 140
 			if ($iconFile !== false) {
141 141
 				$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']);
142 142
 			}
143 143
 		}
144
-		if($response === null) {
145
-			$fallbackLogo = \OC::$SERVERROOT . '/core/img/favicon.png';
144
+		if ($response === null) {
145
+			$fallbackLogo = \OC::$SERVERROOT.'/core/img/favicon.png';
146 146
 			$response = new DataDisplayResponse($this->fileAccessHelper->file_get_contents($fallbackLogo), Http::STATUS_OK, ['Content-Type' => 'image/x-icon']);
147 147
 		}
148 148
 		$response->cacheFor(86400);
@@ -167,17 +167,17 @@  discard block
 block discarded – undo
167 167
 		$response = null;
168 168
 		if ($this->themingDefaults->shouldReplaceIcons()) {
169 169
 			try {
170
-				$iconFile = $this->imageManager->getCachedImage('touchIcon-' . $app);
170
+				$iconFile = $this->imageManager->getCachedImage('touchIcon-'.$app);
171 171
 			} catch (NotFoundException $exception) {
172 172
 				$icon = $this->iconBuilder->getTouchIcon($app);
173
-				$iconFile = $this->imageManager->setCachedImage('touchIcon-' . $app, $icon);
173
+				$iconFile = $this->imageManager->setCachedImage('touchIcon-'.$app, $icon);
174 174
 			}
175 175
 			if ($iconFile !== false) {
176 176
 				$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/png']);
177 177
 			}
178 178
 		}
179
-		if($response === null) {
180
-			$fallbackLogo = \OC::$SERVERROOT . '/core/img/favicon-touch.png';
179
+		if ($response === null) {
180
+			$fallbackLogo = \OC::$SERVERROOT.'/core/img/favicon-touch.png';
181 181
 			$response = new DataDisplayResponse($this->fileAccessHelper->file_get_contents($fallbackLogo), Http::STATUS_OK, ['Content-Type' => 'image/png']);
182 182
 		}
183 183
 		$response->cacheFor(86400);
Please login to merge, or discard this patch.
apps/theming/lib/IconBuilder.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function renderAppIcon($app, $size) {
98 98
 		$appIcon = $this->util->getAppIcon($app);
99
-		if($appIcon === false) {
99
+		if ($appIcon === false) {
100 100
 			return false;
101 101
 		}
102 102
 		if ($appIcon instanceof ISimpleFile) {
@@ -107,20 +107,20 @@  discard block
 block discarded – undo
107 107
 			$mime = mime_content_type($appIcon);
108 108
 		}
109 109
 
110
-		if($appIconContent === false || $appIconContent === "") {
110
+		if ($appIconContent === false || $appIconContent === "") {
111 111
 			return false;
112 112
 		}
113 113
 
114 114
 		$color = $this->themingDefaults->getColorPrimary();
115 115
 
116 116
 		// generate background image with rounded corners
117
-		$background = '<?xml version="1.0" encoding="UTF-8"?>' .
118
-			'<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:cc="http://creativecommons.org/ns#" width="512" height="512" xmlns:xlink="http://www.w3.org/1999/xlink">' .
119
-			'<rect x="0" y="0" rx="100" ry="100" width="512" height="512" style="fill:' . $color . ';" />' .
117
+		$background = '<?xml version="1.0" encoding="UTF-8"?>'.
118
+			'<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:cc="http://creativecommons.org/ns#" width="512" height="512" xmlns:xlink="http://www.w3.org/1999/xlink">'.
119
+			'<rect x="0" y="0" rx="100" ry="100" width="512" height="512" style="fill:'.$color.';" />'.
120 120
 			'</svg>';
121 121
 		// resize svg magic as this seems broken in Imagemagick
122
-		if($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") {
123
-			if(substr($appIconContent, 0, 5) !== "<?xml") {
122
+		if ($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") {
123
+			if (substr($appIconContent, 0, 5) !== "<?xml") {
124 124
 				$svg = "<?xml version=\"1.0\"?>".$appIconContent;
125 125
 			} else {
126 126
 				$svg = $appIconContent;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 			$res = $tmp->getImageResolution();
133 133
 			$tmp->destroy();
134 134
 
135
-			if($x>$y) {
135
+			if ($x > $y) {
136 136
 				$max = $x;
137 137
 			} else {
138 138
 				$max = $y;
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 
141 141
 			// convert svg to resized image
142 142
 			$appIconFile = new Imagick();
143
-			$resX = (int)(512 * $res['x'] / $max * 2.53);
144
-			$resY = (int)(512 * $res['y'] / $max * 2.53);
143
+			$resX = (int) (512 * $res['x'] / $max * 2.53);
144
+			$resY = (int) (512 * $res['y'] / $max * 2.53);
145 145
 			$appIconFile->setResolution($resX, $resY);
146 146
 			$appIconFile->setBackgroundColor(new ImagickPixel('transparent'));
147 147
 			$appIconFile->readImageBlob($svg);
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
 			$appIconFile->scaleImage(512, 512, true);
154 154
 		}
155 155
 		// offset for icon positioning
156
-		$border_w = (int)($appIconFile->getImageWidth() * 0.05);
157
-		$border_h = (int)($appIconFile->getImageHeight() * 0.05);
158
-		$innerWidth = (int)($appIconFile->getImageWidth() - $border_w * 2);
159
-		$innerHeight = (int)($appIconFile->getImageHeight() - $border_h * 2);
156
+		$border_w = (int) ($appIconFile->getImageWidth() * 0.05);
157
+		$border_h = (int) ($appIconFile->getImageHeight() * 0.05);
158
+		$innerWidth = (int) ($appIconFile->getImageWidth() - $border_w * 2);
159
+		$innerHeight = (int) ($appIconFile->getImageHeight() - $border_h * 2);
160 160
 		$appIconFile->adaptiveResizeImage($innerWidth, $innerHeight);
161 161
 		// center icon
162 162
 		$offset_w = 512 / 2 - $innerWidth / 2;
Please login to merge, or discard this patch.