]> source.dussan.org Git - nextcloud-server.git/commitdiff
added determineIcon to \OCA\files\lib\Helper
authorThomas Müller <thomas.mueller@tmit.eu>
Wed, 11 Sep 2013 22:39:52 +0000 (00:39 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Wed, 11 Sep 2013 22:39:52 +0000 (00:39 +0200)
apps/files/lib/helper.php

index 7135ef9f656525fbc18b3fd7c87b95873ce481a2..9170c6e3fc0b3c4265f0364096c3d95b199c60ec 100644 (file)
@@ -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']);
+       }
+
+
 }