@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare (strict_types = 1); |
|
2 | +declare(strict_types=1); |
|
3 | 3 | /** |
4 | 4 | * @copyright Copyright (c) 2018, John Molakvoæ ([email protected]) |
5 | 5 | * |
@@ -115,24 +115,24 @@ discard block |
||
115 | 115 | $cachedVarsCssFile = $this->folder->newFile($this->fileName); |
116 | 116 | } |
117 | 117 | |
118 | - $icons = $this->getIconsFromCss($currentData . $css); |
|
118 | + $icons = $this->getIconsFromCss($currentData.$css); |
|
119 | 119 | |
120 | 120 | $data = ''; |
121 | 121 | $list = ''; |
122 | 122 | foreach ($icons as $icon => $url) { |
123 | 123 | $list .= "--$icon: url('$url');"; |
124 | - list($location,$color) = $this->parseUrl($url); |
|
124 | + list($location, $color) = $this->parseUrl($url); |
|
125 | 125 | $svg = false; |
126 | 126 | if ($location !== '' && \file_exists($location)) { |
127 | 127 | $svg = \file_get_contents($location); |
128 | 128 | } |
129 | 129 | if ($svg === false) { |
130 | - $this->logger->debug('Failed to get icon file ' . $location); |
|
130 | + $this->logger->debug('Failed to get icon file '.$location); |
|
131 | 131 | $data .= "--$icon: url('$url');"; |
132 | 132 | continue; |
133 | 133 | } |
134 | 134 | $encode = base64_encode($this->colorizeSvg($svg, $color)); |
135 | - $data .= '--' . $icon . ': url(data:image/svg+xml;base64,' . $encode . ');'; |
|
135 | + $data .= '--'.$icon.': url(data:image/svg+xml;base64,'.$encode.');'; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | if (\strlen($data) > 0 && \strlen($list) > 0) { |
@@ -154,20 +154,20 @@ discard block |
||
154 | 154 | private function parseUrl($url): array { |
155 | 155 | $location = ''; |
156 | 156 | $color = ''; |
157 | - $base = $this->getRoutePrefix() . '/svg/'; |
|
157 | + $base = $this->getRoutePrefix().'/svg/'; |
|
158 | 158 | $cleanUrl = \substr($url, \strlen($base)); |
159 | - if (\strpos($url, $base . 'core') === 0) { |
|
159 | + if (\strpos($url, $base.'core') === 0) { |
|
160 | 160 | $cleanUrl = \substr($cleanUrl, \strlen('core')); |
161 | 161 | if (\preg_match('/\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) { |
162 | - list(,$cleanUrl,$color) = $matches; |
|
163 | - $location = \OC::$SERVERROOT . '/core/img/' . $cleanUrl . '.svg'; |
|
162 | + list(,$cleanUrl, $color) = $matches; |
|
163 | + $location = \OC::$SERVERROOT.'/core/img/'.$cleanUrl.'.svg'; |
|
164 | 164 | } |
165 | 165 | } elseif (\strpos($url, $base) === 0) { |
166 | - if(\preg_match('/([A-z0-9\_\-]+)\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) { |
|
167 | - list(,$app,$cleanUrl, $color) = $matches; |
|
168 | - $location = \OC_App::getAppPath($app) . '/img/' . $cleanUrl . '.svg'; |
|
166 | + if (\preg_match('/([A-z0-9\_\-]+)\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) { |
|
167 | + list(,$app, $cleanUrl, $color) = $matches; |
|
168 | + $location = \OC_App::getAppPath($app).'/img/'.$cleanUrl.'.svg'; |
|
169 | 169 | if ($app === 'settings') { |
170 | - $location = \OC::$SERVERROOT . '/settings/img/' . $cleanUrl . '.svg'; |
|
170 | + $location = \OC::$SERVERROOT.'/settings/img/'.$cleanUrl.'.svg'; |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
@@ -191,17 +191,17 @@ discard block |
||
191 | 191 | |
192 | 192 | // add fill (fill is not present on black elements) |
193 | 193 | $fillRe = '/<((circle|rect|path)((?!fill)[a-z0-9 =".\-#():;,])+)\/>/mi'; |
194 | - $svg = preg_replace($fillRe, '<$1 fill="#' . $color . '"/>', $svg); |
|
194 | + $svg = preg_replace($fillRe, '<$1 fill="#'.$color.'"/>', $svg); |
|
195 | 195 | |
196 | 196 | // replace any fill or stroke colors |
197 | - $svg = preg_replace('/stroke="#([a-z0-9]{3,6})"/mi', 'stroke="#' . $color . '"', $svg); |
|
198 | - $svg = preg_replace('/fill="#([a-z0-9]{3,6})"/mi', 'fill="#' . $color . '"', $svg); |
|
197 | + $svg = preg_replace('/stroke="#([a-z0-9]{3,6})"/mi', 'stroke="#'.$color.'"', $svg); |
|
198 | + $svg = preg_replace('/fill="#([a-z0-9]{3,6})"/mi', 'fill="#'.$color.'"', $svg); |
|
199 | 199 | return $svg; |
200 | 200 | } |
201 | 201 | |
202 | 202 | private function getRoutePrefix() { |
203 | 203 | $frontControllerActive = (\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); |
204 | - $prefix = \OC::$WEBROOT . '/index.php'; |
|
204 | + $prefix = \OC::$WEBROOT.'/index.php'; |
|
205 | 205 | if ($frontControllerActive) { |
206 | 206 | $prefix = \OC::$WEBROOT; |
207 | 207 | } |