[xoops-cvslog 1840] CVS update: xoops2jp/html/class

Back to archive index

Minahito minah****@users*****
2006年 1月 18日 (水) 22:11:49 JST


Index: xoops2jp/html/class/XCube_FormFile.class.php
diff -u xoops2jp/html/class/XCube_FormFile.class.php:1.1.2.3 xoops2jp/html/class/XCube_FormFile.class.php:1.1.2.4
--- xoops2jp/html/class/XCube_FormFile.class.php:1.1.2.3	Tue Nov 22 23:33:03 2005
+++ xoops2jp/html/class/XCube_FormFile.class.php	Wed Jan 18 22:11:49 2006
@@ -240,4 +240,60 @@
 	}
 }
 
+class XCube_FormImageFile extends XCube_FormFile
+{
+	function fetch()
+	{
+		parent::fetch();
+		
+		if ($this->hasUploadFile()) {
+			if (!$this->_checkFormat()) {
+				$this->mUploadFileFlag = false;
+			}
+		}
+	}
+	
+	function getWidth()
+	{
+		list($width,$height,$type,$attr)=getimagesize($this->_mTmpFileName);
+		return $width;
+	}
+	
+	function getHeight()
+	{
+		list($width,$height,$type,$attr)=getimagesize($this->_mTmpFileName);
+		return $height;
+	}
+
+	/**
+	 * @return bool
+	 */
+	function _checkFormat()
+	{
+		if(!$this->hasUploadFile())
+			return false;
+		
+		list($width,$height,$type,$attr)=getimagesize($this->_mTmpFileName);
+		
+		switch($type) {
+			case IMAGETYPE_GIF:
+				$this->setExtension("gif");
+				break;
+
+			case IMAGETYPE_JPEG:
+				$this->setExtension("jpg");
+				break;
+
+			case IMAGETYPE_PNG:
+				$this->setExtension("png");
+				break;
+
+			default:
+				return false;
+		}
+		
+		return true;
+	}
+}
+
 ?>
\ No newline at end of file


xoops-cvslog メーリングリストの案内
Back to archive index