Completed
Pull Request — master (#4888)
by Julius
32:02 queued 15:08
created
apps/theming/lib/IconBuilder.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 			return false;
102 102
 		}
103 103
 
104
-		if($appIconContent === false) {
104
+		if ($appIconContent === false) {
105 105
 			return false;
106 106
 		}
107 107
 
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
 		$mime = mime_content_type($appIcon);
110 110
 
111 111
 		// generate background image with rounded corners
112
-		$background = '<?xml version="1.0" encoding="UTF-8"?>' .
113
-			'<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">' .
114
-			'<rect x="0" y="0" rx="100" ry="100" width="512" height="512" style="fill:' . $color . ';" />' .
112
+		$background = '<?xml version="1.0" encoding="UTF-8"?>'.
113
+			'<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">'.
114
+			'<rect x="0" y="0" rx="100" ry="100" width="512" height="512" style="fill:'.$color.';" />'.
115 115
 			'</svg>';
116 116
 		// resize svg magic as this seems broken in Imagemagick
117
-		if($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") {
118
-			if(substr($appIconContent, 0, 5) !== "<?xml") {
117
+		if ($mime === "image/svg+xml" || substr($appIconContent, 0, 4) === "<svg") {
118
+			if (substr($appIconContent, 0, 5) !== "<?xml") {
119 119
 				$svg = "<?xml version=\"1.0\"?>".$appIconContent;
120 120
 			} else {
121 121
 				$svg = $appIconContent;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 			$res = $tmp->getImageResolution();
128 128
 			$tmp->destroy();
129 129
 
130
-			if($x>$y) {
130
+			if ($x > $y) {
131 131
 				$max = $x;
132 132
 			} else {
133 133
 				$max = $y;
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 
136 136
 			// convert svg to resized image
137 137
 			$appIconFile = new Imagick();
138
-			$resX = (int)(512 * $res['x'] / $max * 2.53);
139
-			$resY = (int)(512 * $res['y'] / $max * 2.53);
138
+			$resX = (int) (512 * $res['x'] / $max * 2.53);
139
+			$resY = (int) (512 * $res['y'] / $max * 2.53);
140 140
 			$appIconFile->setResolution($resX, $resY);
141 141
 			$appIconFile->setBackgroundColor(new ImagickPixel('transparent'));
142 142
 			$appIconFile->readImageBlob($svg);
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
 		}
150 150
 
151 151
 		// offset for icon positioning
152
-		$border_w = (int)($appIconFile->getImageWidth() * 0.05);
153
-		$border_h = (int)($appIconFile->getImageHeight() * 0.05);
154
-		$innerWidth = (int)($appIconFile->getImageWidth() - $border_w * 2);
155
-		$innerHeight = (int)($appIconFile->getImageHeight() - $border_h * 2);
152
+		$border_w = (int) ($appIconFile->getImageWidth() * 0.05);
153
+		$border_h = (int) ($appIconFile->getImageHeight() * 0.05);
154
+		$innerWidth = (int) ($appIconFile->getImageWidth() - $border_w * 2);
155
+		$innerHeight = (int) ($appIconFile->getImageHeight() - $border_h * 2);
156 156
 		$appIconFile->adaptiveResizeImage($innerWidth, $innerHeight);
157 157
 		// center icon
158 158
 		$offset_w = 512 / 2 - $innerWidth / 2;
Please login to merge, or discard this patch.
apps/theming/lib/Controller/IconController.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	public function getThemedIcon($app, $image) {
95 95
 		try {
96
-			$iconFile = $this->imageManager->getCachedImage("icon-" . $app . '-' . str_replace("/","_",$image));
96
+			$iconFile = $this->imageManager->getCachedImage("icon-".$app.'-'.str_replace("/", "_", $image));
97 97
 		} catch (NotFoundException $exception) {
98 98
 			$icon = $this->iconBuilder->colorSvg($app, $image);
99 99
 			if ($icon === false || $icon === "") {
100 100
 				return new NotFoundResponse();
101 101
 			}
102
-			$iconFile = $this->imageManager->setCachedImage("icon-" . $app . '-' . str_replace("/","_",$image), $icon);
102
+			$iconFile = $this->imageManager->setCachedImage("icon-".$app.'-'.str_replace("/", "_", $image), $icon);
103 103
 		}
104 104
 		if ($iconFile !== false) {
105 105
 			$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']);
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
 		$response = null;
129 129
 		if ($this->themingDefaults->shouldReplaceIcons()) {
130 130
 			try {
131
-				$iconFile = $this->imageManager->getCachedImage('favIcon-' . $app);
131
+				$iconFile = $this->imageManager->getCachedImage('favIcon-'.$app);
132 132
 			} catch (NotFoundException $exception) {
133 133
 				$icon = $this->iconBuilder->getFavicon($app);
134
-				$iconFile = $this->imageManager->setCachedImage('favIcon-' . $app, $icon);
134
+				$iconFile = $this->imageManager->setCachedImage('favIcon-'.$app, $icon);
135 135
 			}
136 136
 			if ($iconFile !== false) {
137 137
 				$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/x-icon']);
138 138
 			}
139 139
 		}
140
-		if($response === null) {
141
-			$fallbackLogo = \OC::$SERVERROOT . '/core/img/favicon.png';
140
+		if ($response === null) {
141
+			$fallbackLogo = \OC::$SERVERROOT.'/core/img/favicon.png';
142 142
 			/** @var FileAccessHelper */
143 143
 			$fileAccessHelper = \OC::$server->query(FileAccessHelper::class);
144 144
 			$response = new DataDisplayResponse($fileAccessHelper->file_get_contents($fallbackLogo), Http::STATUS_OK, ['Content-Type' => 'image/x-icon']);
@@ -165,17 +165,17 @@  discard block
 block discarded – undo
165 165
 		$response = null;
166 166
 		if ($this->themingDefaults->shouldReplaceIcons()) {
167 167
 			try {
168
-				$iconFile = $this->imageManager->getCachedImage('touchIcon-' . $app);
168
+				$iconFile = $this->imageManager->getCachedImage('touchIcon-'.$app);
169 169
 			} catch (NotFoundException $exception) {
170 170
 				$icon = $this->iconBuilder->getTouchIcon($app);
171
-				$iconFile = $this->imageManager->setCachedImage('touchIcon-' . $app, $icon);
171
+				$iconFile = $this->imageManager->setCachedImage('touchIcon-'.$app, $icon);
172 172
 			}
173 173
 			if ($iconFile !== false) {
174 174
 				$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/png']);
175 175
 			}
176 176
 		}
177
-		if($response === null) {
178
-			$fallbackLogo = \OC::$SERVERROOT . '/core/img/favicon-touch.png';
177
+		if ($response === null) {
178
+			$fallbackLogo = \OC::$SERVERROOT.'/core/img/favicon-touch.png';
179 179
 			/** @var FileAccessHelper */
180 180
 			$fileAccessHelper = \OC::$server->query(FileAccessHelper::class);
181 181
 			$response = new DataDisplayResponse($fileAccessHelper->file_get_contents($fallbackLogo), Http::STATUS_OK, ['Content-Type' => 'image/png']);
Please login to merge, or discard this patch.