summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/files/templates/part.list.php12
-rwxr-xr-xlib/preview.php18
-rw-r--r--lib/public/preview.php38
3 files changed, 38 insertions, 30 deletions
diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php
index 9e62c991975..b87000a8993 100644
--- a/apps/files/templates/part.list.php
+++ b/apps/files/templates/part.list.php
@@ -34,9 +34,17 @@ $totalsize = 0; ?>
<?php
$relativePath = substr($relativePath, strlen($_['sharingroot']));
?>
- style="background-image:url(<?php print_unescaped(OCP\publicPreview_icon($relativePath, $_['sharingtoken'])); ?>)"
+ <?php if(\OCP\Preview::isMimeSupported($file['mimetype'])): ?>
+ style="background-image:url(<?php print_unescaped(OCP\publicPreview_icon($relativePath, $_['sharingtoken'])); ?>)" class="preview-icon"
+ <?php else: ?>
+ style="background-image:url(<?php print_unescaped(OCP\mimetype_icon($file['mimetype'])); ?>)"
+ <?php endif; ?>
<?php else: ?>
- style="background-image:url(<?php print_unescaped(OCP\preview_icon($relativePath)); ?>)"
+ <?php if(\OCP\Preview::isMimeSupported($file['mimetype'])): ?>
+ style="background-image:url(<?php print_unescaped(OCP\preview_icon($relativePath)); ?>)" class="preview-icon"
+ <?php else: ?>
+ style="background-image:url(<?php print_unescaped(OCP\mimetype_icon($file['mimetype'])); ?>)"
+ <?php endif; ?>
<?php endif; ?>
<?php endif; ?>
>
diff --git a/lib/preview.php b/lib/preview.php
index 113b200c29b..245ad64014e 100755
--- a/lib/preview.php
+++ b/lib/preview.php
@@ -771,7 +771,23 @@ class Preview {
$preview = new Preview(\OC_User::getUser(), 'files/', $path, 0, 0, false, true);
$preview->deleteAllPreviews();
}
-
+
+ public static function isMimeSupported($mimetype) {
+ //check if there are preview backends
+ if(empty(self::$providers)) {
+ self::initProviders();
+ }
+
+ //remove last element because it has the mimetype *
+ $providers = array_slice(self::$providers, 0, -1);
+ foreach($providers as $supportedmimetype => $provider) {
+ if(preg_match($supportedmimetype, $mimetype)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
private static function showErrorPreview() {
$path = \OC::$SERVERROOT . '/core/img/actions/delete.png';
$preview = new \OC_Image($path);
diff --git a/lib/public/preview.php b/lib/public/preview.php
index a7487c485f1..e488eade4da 100644
--- a/lib/public/preview.php
+++ b/lib/public/preview.php
@@ -1,33 +1,11 @@
<?php
/**
-* ownCloud
-*
-* @author Frank Karlitschek
-* @copyright 2012 Frank Karlitschek frank@owncloud.org
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
-* License as published by the Free Software Foundation; either
-* version 3 of the License, or any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
-*
-* You should have received a copy of the GNU Affero General Public
-* License along with this library. If not, see <http://www.gnu.org/licenses/>.
-*
-*/
-
-/**
- * Public interface of ownCloud for apps to use.
- * Preview Class.
- *
+ * Copyright (c) 2013 Frank Karlitschek frank@owncloud.org
+ * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
*/
-
-// use OCP namespace for all classes that are considered public.
-// This means that they should be used by apps instead of the internal ownCloud classes
namespace OCP;
/**
@@ -47,4 +25,10 @@ class Preview {
return(\OC_Preview::show($file,$maxX,$maxY,$scaleup));
}
+
+
+ public static function isMimeSupported($mimetype='*') {
+ return \OC\Preview::isMimeSupported($mimetype);
+ }
+
}