[Pkg-owncloud-commits] [owncloud] 03/50: make it possible to influence output type of \OC_Image

David Prévot taffit at moszumanska.debian.org
Fri Oct 17 03:12:11 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to annotated tag v6.0.6RC1
in repository owncloud.

commit 8f45e8107aa5557f5d0bbe8b164cfba5674a3222
Author: Georg Ehrke <developer at georgehrke.com>
Date:   Fri Mar 14 11:13:45 2014 +0100

    make it possible to influence output type of \OC_Image
    
    Conflicts:
    	lib/private/image.php
---
 lib/private/image.php | 48 ++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 8 deletions(-)

diff --git a/lib/private/image.php b/lib/private/image.php
index 7761a3c..b704e28 100644
--- a/lib/private/image.php
+++ b/lib/private/image.php
@@ -155,9 +155,12 @@ class OC_Image {
 	* @brief Outputs the image.
 	* @returns bool
 	*/
-	public function show() {
-		header('Content-Type: '.$this->mimeType());
-		return $this->_output();
+	public function show($mimeType=null) {
+		if($mimeType === null) {
+			$mimeType = $this->mimeType();
+		}
+		header('Content-Type: '.$mimeType);
+		return $this->_output(null, $mimeType);
 	}
 
 	/**
@@ -165,20 +168,23 @@ class OC_Image {
 	* @returns bool
 	*/
 
-	public function save($filePath=null) {
+	public function save($filePath=null, $mimeType=null) {
+		if($mimeType === null) {
+			$mimeType = $this->mimeType();
+		}
 		if($filePath === null && $this->filePath === null) {
 			OC_Log::write('core', __METHOD__.'(): called with no path.', OC_Log::ERROR);
 			return false;
 		} elseif($filePath === null && $this->filePath !== null) {
 			$filePath = $this->filePath;
 		}
-		return $this->_output($filePath);
+		return $this->_output($filePath, $mimeType);
 	}
 
 	/**
 	* @brief Outputs/saves the image.
 	*/
-	private function _output($filePath=null) {
+	private function _output($filePath=null, $mimeType=null) {
 		if($filePath) {
 			if (!file_exists(dirname($filePath)))
 				mkdir(dirname($filePath), 0777, true);
@@ -196,8 +202,34 @@ class OC_Image {
 			return false;
 		}
 
-		$retVal = false;
-		switch($this->imageType) {
+		$imageType = null;
+		if($mimeType !== null) {
+			switch($mimeType) {
+				case 'image/gif':
+					$this->imageType = IMAGETYPE_GIF;
+					break;
+				case 'image/jpeg':
+				case 'image/pjpeg':
+					$this->imageType = IMAGETYPE_JPEG;
+					break;
+				case 'image/png':
+					$this->imageType = IMAGETYPE_PNG;
+					break;
+				case 'image/x-xbitmap':
+					$this->imageType = IMAGETYPE_XBM;
+					break;
+				case 'image/bmp':
+					$this->imageType = IMAGETYPE_BMP;
+					break;
+				default:
+					$this->imageType = IMAGETYPE_PNG;
+					break;
+			}
+		} else {
+			$imageType = $this->imageType;
+		}
+
+		switch($imageType) {
 			case IMAGETYPE_GIF:
 				$retVal = imagegif($this->resource, $filePath);
 				break;

-- 
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