From b49f43c3aeca2f437af15b7fc0ccc3d6191f6160 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Thu, 12 Sep 2013 00:13:19 +0200 Subject: move icon generation logic out of the template --- apps/files/templates/part.list.php | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'apps/files') diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index 4076c1bb331..7d1b317e016 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -22,26 +22,7 @@ - - style="background-image:url()" - - - - - style="background-image:url()" - - style="background-image:url()" - - - - style="background-image:url()" - - style="background-image:url()" - - - + style="background-image:url()" > -- cgit v1.2.3 From 3066b44928e43260f72fffa9193dd6b1acfb59c7 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Thu, 12 Sep 2013 00:39:03 +0200 Subject: remove unused $relativePath --- apps/files/templates/part.list.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'apps/files') diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index 7d1b317e016..9e1750faddf 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -1,7 +1,5 @@ 6 - $relativePath = substr($file['path'], 6); // the bigger the file, the darker the shade of grey; megabytes*2 $simple_size_color = intval(160-$file['size']/(1024*1024)*2); if($simple_size_color<0) $simple_size_color = 0; -- cgit v1.2.3 From 5af111b0decdc3e922d152dd12322064fc663eba Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Thu, 12 Sep 2013 00:39:52 +0200 Subject: added determineIcon to \OCA\files\lib\Helper --- apps/files/lib/helper.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'apps/files') 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']); + } + + } -- cgit v1.2.3 From 9d661eab23f9ba284e4a5060b5de5d868b330d45 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Thu, 12 Sep 2013 00:40:35 +0200 Subject: adding calls to \OCA\files\lib\Helper::determineIcon($i) in files, trashbin and sharing --- apps/files/ajax/list.php | 1 + apps/files/index.php | 1 + apps/files_sharing/public.php | 15 +++++++++++++++ apps/files_trashbin/index.php | 1 + 4 files changed, 18 insertions(+) (limited to 'apps/files') diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index c50e96b2429..14ed43cbb3a 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -34,6 +34,7 @@ if($doBreadcrumb) { $files = array(); foreach( \OC\Files\Filesystem::getDirectoryContent( $dir ) as $i ) { $i["date"] = OCP\Util::formatDate($i["mtime"] ); + $i['icon'] = \OCA\files\lib\Helper::determineIcon($i); $files[] = $i; } diff --git a/apps/files/index.php b/apps/files/index.php index f1e120c872c..4443bf5fde0 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -75,6 +75,7 @@ foreach ($content as $i) { } $i['directory'] = $dir; $i['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($i['mimetype']); + $i['icon'] = \OCA\files\lib\Helper::determineIcon($i); $files[] = $i; } diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index ec6b4e815f8..ae3e27cab3f 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -19,6 +19,20 @@ function fileCmp($a, $b) { } } +function determineIcon($file, $sharingRoot, $sharingToken) { + // for folders we simply reuse the files logic + if($file['type'] == 'dir') { + return \OCA\files\lib\Helper::determineIcon($file); + } + + $relativePath = substr($file['path'], 6); + $relativePath = substr($relativePath, strlen($sharingRoot)); + if($file['isPreviewAvailable']) { + return OCP\publicPreview_icon($relativePath, $sharingToken); + } + return OCP\mimetype_icon($file['mimetype']); +} + if (isset($_GET['t'])) { $token = $_GET['t']; $linkItem = OCP\Share::getShareByToken($token); @@ -176,6 +190,7 @@ if (isset($path)) { } $i['directory'] = $getPath; $i['permissions'] = OCP\PERMISSION_READ; + $i['icon'] = determineIcon($i, $basePath, $token); $files[] = $i; } usort($files, "fileCmp"); diff --git a/apps/files_trashbin/index.php b/apps/files_trashbin/index.php index 0baeab1de97..d7eb143f9af 100644 --- a/apps/files_trashbin/index.php +++ b/apps/files_trashbin/index.php @@ -65,6 +65,7 @@ foreach ($result as $r) { } $i['permissions'] = OCP\PERMISSION_READ; $i['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($r['mime']); + $i['icon'] = \OCA\files\lib\Helper::determineIcon($i); $files[] = $i; } -- cgit v1.2.3