summaryrefslogtreecommitdiffstats
path: root/lib/private/helper.php
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-07-09 23:02:46 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-07-09 23:02:46 +0200
commitc86e742e6747ae3e41abbe9d0bf2583a20ba9fb0 (patch)
tree29370d4b3f5d708152e821d6d7aaa98f3f34b7f1 /lib/private/helper.php
parent42eb18c747837babc2f53f87106cc02da365f859 (diff)
parent1fc188fd29593f859fccd4b1c0f82d5dcdf77564 (diff)
downloadnextcloud-server-c86e742e6747ae3e41abbe9d0bf2583a20ba9fb0.tar.gz
nextcloud-server-c86e742e6747ae3e41abbe9d0bf2583a20ba9fb0.zip
Merge pull request #15586 from Egari/addThemeSupportToMimeIcon
Add theme support to mimetypeIcon through imagePath integration
Diffstat (limited to 'lib/private/helper.php')
-rw-r--r--lib/private/helper.php35
1 files changed, 20 insertions, 15 deletions
diff --git a/lib/private/helper.php b/lib/private/helper.php
index b7938416fb2..a40b9a23202 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -198,39 +198,44 @@ class OC_Helper {
if (isset(self::$mimetypeIcons[$mimetype])) {
return self::$mimetypeIcons[$mimetype];
}
+
// Replace slash and backslash with a minus
$icon = str_replace('/', '-', $mimetype);
$icon = str_replace('\\', '-', $icon);
// Is it a dir?
if ($mimetype === 'dir') {
- self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/folder.png';
- return OC::$WEBROOT . '/core/img/filetypes/folder.png';
+ self::$mimetypeIcons[$mimetype] = \OC::$server->getURLGenerator()->imagePath('core', 'filetypes/folder.png');
+ return self::$mimetypeIcons[$mimetype];
}
if ($mimetype === 'dir-shared') {
- self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/folder-shared.png';
- return OC::$WEBROOT . '/core/img/filetypes/folder-shared.png';
+ self::$mimetypeIcons[$mimetype] = \OC::$server->getURLGenerator()->imagePath('core', 'filetypes/folder-shared.png');
+ return self::$mimetypeIcons[$mimetype];
}
if ($mimetype === 'dir-external') {
- self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/folder-external.png';
- return OC::$WEBROOT . '/core/img/filetypes/folder-external.png';
+ self::$mimetypeIcons[$mimetype] = \OC::$server->getURLGenerator()->imagePath('core', 'filetypes/folder-external.png');
+ return self::$mimetypeIcons[$mimetype];
}
// Icon exists?
- if (file_exists(OC::$SERVERROOT . '/core/img/filetypes/' . $icon . '.png')) {
- self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/' . $icon . '.png';
- return OC::$WEBROOT . '/core/img/filetypes/' . $icon . '.png';
+ try {
+ self::$mimetypeIcons[$mimetype] = \OC::$server->getURLGenerator()->imagePath('core', 'filetypes/' . $icon . '.png');
+ return self::$mimetypeIcons[$mimetype];
+ } catch (\RuntimeException $e) {
+ // Specified image not found
}
// Try only the first part of the filetype
$mimePart = substr($icon, 0, strpos($icon, '-'));
- if (file_exists(OC::$SERVERROOT . '/core/img/filetypes/' . $mimePart . '.png')) {
- self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/' . $mimePart . '.png';
- return OC::$WEBROOT . '/core/img/filetypes/' . $mimePart . '.png';
- } else {
- self::$mimetypeIcons[$mimetype] = OC::$WEBROOT . '/core/img/filetypes/file.png';
- return OC::$WEBROOT . '/core/img/filetypes/file.png';
+ try {
+ self::$mimetypeIcons[$mimetype] = \OC::$server->getURLGenerator()->imagePath('core', 'filetypes/' . $mimePart . '.png');
+ return self::$mimetypeIcons[$mimetype];
+ } catch (\RuntimeException $e) {
+ // Image for the first part of the mimetype not found
}
+
+ self::$mimetypeIcons[$mimetype] = \OC::$server->getURLGenerator()->imagePath('core', 'filetypes/file.png');
+ return self::$mimetypeIcons[$mimetype];
}
/**