@@ -53,6 +53,7 @@ class IconController extends Controller {
5353 /** @var IRootFolder */
5454 private $ rootFolder ;
5555
56+
5657 /**
5758 * IconController constructor.
5859 *
@@ -94,10 +95,10 @@ public function __construct(
9495 * @return StreamResponse|DataResponse
9596 */
9697 public function getThemedIcon ($ app , $ image ) {
97- $ image = $ this ->getAppImage ($ app , $ image );
98+ $ image = $ this ->util -> getAppImage ($ app , $ image );
9899 $ svg = file_get_contents ($ image );
99100 $ color = $ this ->util ->elementColor ($ this ->themingDefaults ->getMailHeaderColor ());
100- $ svg = $ this ->colorizeSvg ($ svg , $ color );
101+ $ svg = $ this ->util -> colorizeSvg ($ svg , $ color );
101102
102103 $ response = new DataDisplayResponse ($ svg , Http::STATUS_OK , ['Content-Type ' => 'image/svg+xml ' ]);
103104 $ response ->cacheFor (86400 );
@@ -152,20 +153,15 @@ public function getTouchIcon($app="core") {
152153 * @return Imagick
153154 */
154155 private function renderAppIcon ($ app ) {
155- $ appIcon = $ this ->getAppIcon ($ app );
156+ $ appIcon = $ this ->util -> getAppIcon ($ app );
156157 $ color = $ this ->themingDefaults ->getMailHeaderColor ();
157158 $ mime = mime_content_type ($ appIcon );
158- // FIXME: test if we need this
159- if ($ color === "" ) {
160- $ color = '#0082c9 ' ;
161- }
162159 // generate background image with rounded corners
163160 $ background = '<?xml version="1.0" encoding="UTF-8"?> ' .
164161 '<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"> ' .
165162 '<rect x="0" y="0" rx="75" ry="75" width="512" height="512" style="fill: ' . $ color . ';" /> ' .
166163 '</svg> ' ;
167164
168-
169165 // resize svg magic as this seems broken in Imagemagick
170166 if ($ mime === "image/svg+xml " ) {
171167 $ svg = file_get_contents ($ appIcon );
@@ -214,76 +210,6 @@ private function renderAppIcon($app) {
214210 return $ finalIconFile ;
215211 }
216212
217- /**
218- * @param $app app name
219- * @return string path to app icon / logo
220- */
221- private function getAppIcon ($ app ) {
222- $ appPath = \OC_App::getAppPath ($ app );
223213
224- $ icon = $ appPath . '/img/ ' . $ app . '.svg ' ;
225- if (file_exists ($ icon )) {
226- return $ icon ;
227- }
228- $ icon = $ appPath . '/img/app.svg ' ;
229- if (file_exists ($ icon )) {
230- return $ icon ;
231- }
232-
233- if ($ this ->rootFolder ->nodeExists ('/themedinstancelogo ' )) {
234- return $ this ->config ->getSystemValue ('datadirectory ' , \OC ::$ SERVERROOT . '/data/ ' ) . '/themedinstancelogo ' ;
235- }
236- return \OC ::$ SERVERROOT . '/core/img/logo.svg ' ;
237- }
238-
239- /**
240- * @param $app app name
241- * @param $image relative path to image in app folder
242- * @return string absolute path to image
243- */
244- private function getAppImage ($ app , $ image ) {
245- $ appPath = \OC_App::getAppPath ($ app );
246-
247- if ($ app ==="core " ) {
248- $ icon = \OC ::$ SERVERROOT . '/core/img/ ' . $ image ;
249- if (file_exists ($ icon )) {
250- return $ icon ;
251- }
252- }
253-
254- $ icon = $ appPath . '/img/ ' . $ image ;
255- if (file_exists ($ icon )) {
256- return $ icon ;
257- }
258- $ icon = $ appPath . '/img/ ' . $ image . '.svg ' ;
259- if (file_exists ($ icon )) {
260- return $ icon ;
261- }
262- $ icon = $ appPath . '/img/ ' . $ image . '.png ' ;
263- if (file_exists ($ icon )) {
264- return $ icon ;
265- }
266- $ icon = $ appPath . '/img/ ' . $ image . '.gif ' ;
267- if (file_exists ($ icon )) {
268- return $ icon ;
269- }
270- $ icon = $ appPath . '/img/ ' . $ image . '.jpg ' ;
271- if (file_exists ($ icon )) {
272- return $ icon ;
273- }
274- return false ;
275- }
276-
277- /**
278- * replace default color with a custom one
279- *
280- * @param $svg content of a svg file
281- * @param $color color to match
282- * @return string
283- */
284- private function colorizeSvg ($ svg , $ color ) {
285- $ svg = preg_replace ('/#0082c9/i ' , $ color , $ svg );
286- return $ svg ;
287- }
288214
289215}
0 commit comments