diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-09-12 00:39:52 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-09-12 00:39:52 +0200 |
commit | 5af111b0decdc3e922d152dd12322064fc663eba (patch) | |
tree | 6209d7a2f5c82d96a734298d2998d60a9a14f6b7 /apps | |
parent | 3066b44928e43260f72fffa9193dd6b1acfb59c7 (diff) | |
download | nextcloud-server-5af111b0decdc3e922d152dd12322064fc663eba.tar.gz nextcloud-server-5af111b0decdc3e922d152dd12322064fc663eba.zip |
added determineIcon to \OCA\files\lib\Helper
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/lib/helper.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php index 7135ef9f656..9170c6e3fc0 100644 --- a/apps/files/lib/helper.php +++ b/apps/files/lib/helper.php @@ -17,4 +17,33 @@ class Helper 'maxHumanFilesize' => $maxHumanFilesize, 'usedSpacePercent' => (int)$storageInfo['relative']); } + + public static function determineIcon($file) { + if($file['type'] === 'dir') { + $dir = $file['directory']; + $absPath = \OC\Files\Filesystem::getView()->getAbsolutePath($dir.'/'.$file['name']); + $mount = \OC\Files\Filesystem::getMountManager()->find($absPath); + if (!is_null($mount)) { + $sid = $mount->getStorageId(); + if (!is_null($sid)) { + $sid = explode(':', $sid); + if ($sid[0] === 'shared') { + return \OC_Helper::mimetypeIcon('dir-shared'); + } + if ($sid[0] !== 'local') { + return \OC_Helper::mimetypeIcon('dir-external'); + } + } + } + return \OC_Helper::mimetypeIcon('dir'); + } + + if($file['isPreviewAvailable']) { + $relativePath = substr($file['path'], 6); + return \OC_Helper::previewIcon($relativePath); + } + return \OC_Helper::mimetypeIcon($file['mimetype']); + } + + } |