Minahito
minah****@users*****
2006年 1月 18日 (水) 22:11:11 JST
Index: xoops2jp/html/class/XCube_ActionForm.class.php diff -u xoops2jp/html/class/XCube_ActionForm.class.php:1.1.2.21 xoops2jp/html/class/XCube_ActionForm.class.php:1.1.2.22 --- xoops2jp/html/class/XCube_ActionForm.class.php:1.1.2.21 Sun Jan 15 03:27:39 2006 +++ xoops2jp/html/class/XCube_ActionForm.class.php Wed Jan 18 22:11:10 2006 @@ -1,4 +1,8 @@ <?php +// +// TODO The difference of array and no-array is too big. +// TODO Form object should have getValue(), isNull(), toString(). +// define("XCUBE_TOKEN_TYPE_SINGLE",1); define("XCUBE_TOKEN_TYPE_MULTI",2); @@ -367,6 +371,32 @@ } } +class XCube_FileProperty extends XCube_AbstractProperty +{ + function XCube_FileProperty($name) + { + parent::XCube_AbstractProperty($name); + $this->mValue =& new XCube_FormFile($name); + } + + function fetch() + { + $this->mValue->fetch(); + if ($this->mValue->hasUploadFile()) { + $this->mValue = null; + } + } +} + +class XCube_ImageFileProperty extends XCube_FileProperty +{ + function XCube_FileProperty($name) + { + parent::XCube_AbstractProperty($name); + $this->mValue =& new XCube_FormImageFile($name); + } +} + class XCube_FieldProperty { var $mForm; @@ -655,4 +685,125 @@ } } +class XCube_EmailDepend extends XCube_AbstractDepend +{ + var $mName = "email"; + + function _check($val,$vars) + { + if(!empty($val)) { + return preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i", $val); + } + return true; + } + + function _checkAsArray($val,$vars) + { + if(!count($val)) + return false; + + $flag = true; + foreach($val as $i) { + if(!empty($i)) { + $flag &= $this->_check($i, $vars); + } + } + + return $flag; + } +} + +class XCube_MaskDepend extends XCube_AbstractDepend +{ + var $mName = "mask"; + + function _check($val,$vars) + { + if(!empty($val)) { + return preg_match($vars['mask'], $val); + } + return true; + } + + function _checkAsArray($val,$vars) + { + if(!count($val)) + return false; + + $flag = true; + foreach($val as $i) { + if(!empty($i)) { + $flag &= $this->_check($i, $vars); + } + } + + return $flag; + } +} + +class XCube_ExtensionDepend extends XCube_AbstractDepend +{ + var $mName = "extension"; + + function _check($val, $vars) + { + if (!is_a($val, "XCube_FormFile")) { + return true; + } + + $extArr = explode(",", $vars['extension']); + foreach ($extArr as $ext) { + if (strtolower($val->getExtension()) == strtolower($ext)) { + return true; + } + } + + return false; + } + + function _checkAsArray($val,$vars) + { + if(!count($val)) + return false; + + $flag = true; + foreach($val as $i) { + if(!empty($i)) { + $flag &= $this->_check($i, $vars); + } + } + + return $flag; + } +} + +class XCube_MaxfilesizeDepend extends XCube_AbstractDepend +{ + var $mName = "maxfilesize"; + + function _check($val, $vars) + { + if (!is_a($val, "XCube_FormFile")) { + return true; + } + + return ($val->getFileSize() < $vars['maxfilesize']); + } + + function _checkAsArray($val,$vars) + { + if(!count($val)) + return false; + + $flag = true; + foreach($val as $i) { + if(!empty($i)) { + $flag &= $this->_check($i, $vars); + } + } + + return $flag; + } +} + ?> \ No newline at end of file