From 1e4ec2ac276b15232824da056b6253696d324d42 Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Mon, 29 Jul 2013 15:47:17 +0200 Subject: [PATCH] add class='preview-icon' to rows in file app that make use of previews --- apps/files/templates/part.list.php | 12 ++++++++-- lib/preview.php | 18 +++++++++++++- lib/public/preview.php | 38 +++++++++--------------------- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php index 9e62c99197..b87000a899 100644 --- a/apps/files/templates/part.list.php +++ b/apps/files/templates/part.list.php @@ -34,9 +34,17 @@ $totalsize = 0; ?> - style="background-image:url()" + + style="background-image:url()" class="preview-icon" + + style="background-image:url()" + - style="background-image:url()" + + style="background-image:url()" class="preview-icon" + + style="background-image:url()" + > diff --git a/lib/preview.php b/lib/preview.php index 113b200c29..245ad64014 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 a7487c485f..e488eade4d 100644 --- a/lib/public/preview.php +++ b/lib/public/preview.php @@ -1,33 +1,11 @@ . -* -*/ - -/** - * 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); + } + }