[Pkg-owncloud-commits] [owncloud] 21/52: we need to be able to set the mimetype manually
David Prévot
taffit at moszumanska.debian.org
Mon Dec 2 01:49:38 UTC 2013
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository owncloud.
commit eeb31420fe2185b4caf2fbf564b5ac6177d348c3
Author: Bjoern Schiessle <schiessle at owncloud.com>
Date: Thu Nov 28 18:52:58 2013 +0100
we need to be able to set the mimetype manually
---
lib/private/preview.php | 37 ++++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/lib/private/preview.php b/lib/private/preview.php
index 266f779..7f21985 100755
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -9,7 +9,7 @@
* Thumbnails:
* structure of filename:
* /data/user/thumbnails/pathhash/x-y.png
- *
+ *
*/
namespace OC;
@@ -40,6 +40,7 @@ class Preview {
private $maxX;
private $maxY;
private $scalingup;
+ private $mimetype;
//preview images object
/**
@@ -59,11 +60,18 @@ class Preview {
* @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
* @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
* @param bool $scalingUp Disable/Enable upscaling of previews
- * @return mixed (bool / string)
+ * @return mixed (bool / string)
* false if thumbnail does not exist
* path to thumbnail if thumbnail exists
*/
public function __construct($user='', $root='/', $file='', $maxX=1, $maxY=1, $scalingUp=true) {
+ //init fileviews
+ if($user === ''){
+ $user = \OC_User::getUser();
+ }
+ $this->fileView = new \OC\Files\View('/' . $user . '/' . $root);
+ $this->userView = new \OC\Files\View('/' . $user);
+
//set config
$this->configMaxX = \OC_Config::getValue('preview_max_x', null);
$this->configMaxY = \OC_Config::getValue('preview_max_y', null);
@@ -75,13 +83,6 @@ class Preview {
$this->setMaxY($maxY);
$this->setScalingUp($scalingUp);
- //init fileviews
- if($user === ''){
- $user = \OC_User::getUser();
- }
- $this->fileView = new \OC\Files\View('/' . $user . '/' . $root);
- $this->userView = new \OC\Files\View('/' . $user);
-
$this->preview = null;
//check if there are preview backends
@@ -166,9 +167,16 @@ class Preview {
*/
public function setFile($file) {
$this->file = $file;
+ if ($file !== '') {
+ $this->mimetype = $this->fileView->getMimeType($this->file);
+ }
return $this;
}
+ public function setMimetype($mimetype) {
+ $this->mimetype = $mimetype;
+ }
+
/**
* @brief set the the max width of the preview
* @param int $maxX
@@ -265,7 +273,7 @@ class Preview {
$fileInfo = $this->fileView->getFileInfo($file);
$fileId = $fileInfo['fileid'];
-
+
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
$this->userView->deleteAll($previewPath);
$this->userView->rmdir($previewPath);
@@ -274,7 +282,7 @@ class Preview {
/**
* @brief check if thumbnail or bigger version of thumbnail of file is cached
- * @return mixed (bool / string)
+ * @return mixed (bool / string)
* false if thumbnail does not exist
* path to thumbnail if thumbnail exists
*/
@@ -386,11 +394,10 @@ class Preview {
}
if(is_null($this->preview)) {
- $mimetype = $this->fileView->getMimeType($file);
$preview = null;
foreach(self::$providers as $supportedMimetype => $provider) {
- if(!preg_match($supportedMimetype, $mimetype)) {
+ if(!preg_match($supportedMimetype, $this->mimetype)) {
continue;
}
@@ -516,7 +523,7 @@ class Preview {
$cropY = 0;
$image->crop($cropX, $cropY, $x, $y);
-
+
$this->preview = $image;
return;
}
@@ -598,7 +605,7 @@ class Preview {
public static function post_write($args) {
self::post_delete($args);
}
-
+
public static function post_delete($args) {
$path = $args['path'];
if(substr($path, 0, 1) === '/') {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git
More information about the Pkg-owncloud-commits
mailing list