Skip to content
Snippets Groups Projects
Commit 1fc188fd authored by stolter's avatar stolter
Browse files

Add theme support to mimetypeIcon through imagePath integration

parent 660aa7ff
No related branches found
No related tags found
No related merge requests found
...@@ -264,39 +264,44 @@ class OC_Helper { ...@@ -264,39 +264,44 @@ class OC_Helper {
if (isset(self::$mimetypeIcons[$mimetype])) { if (isset(self::$mimetypeIcons[$mimetype])) {
return self::$mimetypeIcons[$mimetype]; return self::$mimetypeIcons[$mimetype];
} }
// Replace slash and backslash with a minus // Replace slash and backslash with a minus
$icon = str_replace('/', '-', $mimetype); $icon = str_replace('/', '-', $mimetype);
$icon = str_replace('\\', '-', $icon); $icon = str_replace('\\', '-', $icon);
// Is it a dir? // Is it a dir?
if ($mimetype === 'dir') { if ($mimetype === 'dir') {
self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/folder.png'; self::$mimetypeIcons[$mimetype] = \OC::$server->getURLGenerator()->imagePath('core', 'filetypes/folder.png');
return OC::$WEBROOT . '/core/img/filetypes/folder.png'; return self::$mimetypeIcons[$mimetype];
} }
if ($mimetype === 'dir-shared') { if ($mimetype === 'dir-shared') {
self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/folder-shared.png'; self::$mimetypeIcons[$mimetype] = \OC::$server->getURLGenerator()->imagePath('core', 'filetypes/folder-shared.png');
return OC::$WEBROOT . '/core/img/filetypes/folder-shared.png'; return self::$mimetypeIcons[$mimetype];
} }
if ($mimetype === 'dir-external') { if ($mimetype === 'dir-external') {
self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/folder-external.png'; self::$mimetypeIcons[$mimetype] = \OC::$server->getURLGenerator()->imagePath('core', 'filetypes/folder-external.png');
return OC::$WEBROOT . '/core/img/filetypes/folder-external.png'; return self::$mimetypeIcons[$mimetype];
} }
// Icon exists? // Icon exists?
if (file_exists(OC::$SERVERROOT . '/core/img/filetypes/' . $icon . '.png')) { try {
self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/' . $icon . '.png'; self::$mimetypeIcons[$mimetype] = \OC::$server->getURLGenerator()->imagePath('core', 'filetypes/' . $icon . '.png');
return OC::$WEBROOT . '/core/img/filetypes/' . $icon . '.png'; return self::$mimetypeIcons[$mimetype];
} catch (\RuntimeException $e) {
// Specified image not found
} }
// Try only the first part of the filetype // Try only the first part of the filetype
$mimePart = substr($icon, 0, strpos($icon, '-')); $mimePart = substr($icon, 0, strpos($icon, '-'));
if (file_exists(OC::$SERVERROOT . '/core/img/filetypes/' . $mimePart . '.png')) { try {
self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/' . $mimePart . '.png'; self::$mimetypeIcons[$mimetype] = \OC::$server->getURLGenerator()->imagePath('core', 'filetypes/' . $mimePart . '.png');
return OC::$WEBROOT . '/core/img/filetypes/' . $mimePart . '.png'; return self::$mimetypeIcons[$mimetype];
} else { } catch (\RuntimeException $e) {
self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/file.png'; // Image for the first part of the mimetype not found
return OC::$WEBROOT . '/core/img/filetypes/file.png';
} }
self::$mimetypeIcons[$mimetype] = \OC::$server->getURLGenerator()->imagePath('core', 'filetypes/file.png');
return self::$mimetypeIcons[$mimetype];
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment