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

Back to archive index

Minahito minah****@users*****
2005年 12月 1日 (木) 14:16:33 JST


Index: xoops2jp/html/class/XCube_ActionForm.class.php
diff -u xoops2jp/html/class/XCube_ActionForm.class.php:1.1.2.11 xoops2jp/html/class/XCube_ActionForm.class.php:1.1.2.12
--- xoops2jp/html/class/XCube_ActionForm.class.php:1.1.2.11	Sun Nov 27 16:22:27 2005
+++ xoops2jp/html/class/XCube_ActionForm.class.php	Thu Dec  1 14:16:33 2005
@@ -38,13 +38,25 @@
 	
 	function setVar($key,$val)
 	{
+		//
+		// TODO Follow about array.
+		//
 		if(isset($this->mFormProperties[$key]))
 			$this->mFormProperties[$key]->setValue($val);
 	}
 	
-	function getVar($key)
+	function getVar($key,$index=null)
+	{
+		return isset($this->mFormProperties[$key]) ? $this->mFormProperties[$key]->getValue($index) : null;
+	}
+	
+	/**
+	 * Return form properties of this member property.
+	 * @return XCube_AbstractProperty[]
+	 */
+	function &getFormProperties()
 	{
-		return isset($this->mFormProperties[$key]) ? $this->mFormProperties[$key]->getValue() : null;
+		return $this->mFormProperties;
 	}
 
 	function fetch()
@@ -209,7 +221,7 @@
 		$this->mValue=$val;
 	}
 
-	function getValue()
+	function getValue($index=null)
 	{
 		return $this->mValue;
 	}
@@ -252,6 +264,15 @@
 		else
 			$this->mValue=array();
 	}
+
+	function getValue($index=null)
+	{
+		if($index==null)
+			return $this->mValue;
+
+		return $this->mValue[$index];
+	}
+
 }
 
 class XCube_IntProperty extends XCube_AbstractProperty
@@ -317,6 +338,21 @@
 	}
 }
 
+class XCube_StringArrayProperty extends XCube_AbstractArrayProperty
+{
+	function fetch()
+	{
+		parent::fetch();
+		foreach(array_keys($this->mValue) as $key) {
+			if(preg_match_all("/[\\x00-\\x1f]/",$this->mValue[$key],$matches,PREG_PATTERN_ORDER)) {
+				foreach($matches[0] as $match) {
+					die("Get control code :" . ord($match));
+				}
+			}
+		}
+	}
+}
+
 class XCube_TextProperty extends XCube_AbstractProperty
 {
 	function fetch()
@@ -478,7 +514,7 @@
 
 		$flag = true;
 		foreach($val as $i) {
-			$flag &= !empty($i);
+			$flag &= (strlen($i)!=0);
 		}
 
 		return $flag;
@@ -489,65 +525,135 @@
 {
 	var $mName="minlength";
 	
-	function check($val,$vars)
+	function _check($val,$vars)
 	{
 		if(!empty($val))
 			return strlen($val)>=$vars['minlength'];
 		else
 			return true;
 	}
+
+	function _checkAsArray($val,$vars)
+	{
+		if(!count($val))
+			return false;
+
+		$flag = true;
+		foreach($val as $i) {
+			if(!empty($i))
+				$flag&=(strlen($i)>=$vars['minlength']);
+		}
+		
+		return $flag;
+	}
 }
 
 class XCube_MaxlengthDepend extends XCube_AbstractDepend
 {
 	var $mName="maxlength";
 	
-	function check($val,$vars)
+	function _check($val,$vars)
 	{
 		if(!empty($val))
 			return strlen($val)<=$vars['maxlength'];
 		else
 			return true;
 	}
+
+	function _checkAsArray($val,$vars)
+	{
+		if(!count($val))
+			return false;
+
+		$flag = true;
+		foreach($val as $i) {
+			if(!empty($i))
+				$flag&=(strlen($i)<=$vars['maxlength']);
+		}
+
+		return $flag;
+	}
 }
 
 class XCube_MinDepend extends XCube_AbstractDepend
 {
 	var $mName="min";
 	
-	function check($val,$vars)
+	function _check($val,$vars)
 	{
 		if(!empty($val))
 			return $val>=$vars['min'];
 		else
 			return true;
 	}
+
+	function _checkAsArray($val,$vars)
+	{
+		if(!count($val))
+			return false;
+
+		$flag = true;
+		foreach($val as $i) {
+			if(!empty($i))
+				$flag&=($i>=$vars['min']);
+		}
+
+		return $flag;
+	}
 }
 
 class XCube_MaxDepend extends XCube_AbstractDepend
 {
 	var $mName="max";
 	
-	function check($val,$vars)
+	function _check($val,$vars)
 	{
 		if(!empty($val))
 			return $val<=$vars['max'];
 		else
 			return true;
 	}
+
+	function _checkAsArray($val,$vars)
+	{
+		if(!count($val))
+			return false;
+
+		$flag = true;
+		foreach($val as $i) {
+			if(!empty($i))
+				$flag&=($i<=$vars['max']);
+		}
+
+		return $flag;
+	}
 }
 
 class XCube_IntRangeDepend extends XCube_AbstractDepend
 {
 	var $mName="intRange";
 	
-	function check($val,$vars)
+	function _check($val,$vars)
 	{
 		if(!empty($val))
 			return ($val>=$vars['min'])&&($val<=$vars['max']);
 		else
 			return true;
 	}
+
+	function _checkAsArray($val,$vars)
+	{
+		if(!count($val))
+			return false;
+
+		$flag = true;
+		foreach($val as $i) {
+			if(!empty($i))
+				$flag&=(($i>=$vars['min'])&&($i<=$vars['max']));
+		}
+
+		return $flag;
+	}
 }
 
 ?>
\ No newline at end of file


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