Changeset 14162 for branches/dev/html/test/adachi/SC_FormParamsManager.php
- Timestamp:
- 2007/06/04 01:21:25 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/dev/html/test/adachi/SC_FormParamsManager.php
r13744 r14162 6 6 * Form¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹ 7 7 */ 8 9 8 class SC_FormParamsManager { 10 9 var $_arrObjParams; 11 var $_arrErr; 10 var $_arrErrorMessage; 11 var $_arrGropus; 12 12 13 13 function SC_FormParamsManager($arrParams = array(), $arrParamsInfo = array()){ 14 $this->_arrObjParams = array(); 15 $this->_arrErr = array(); 16 17 if (count($arrParams) > 0 && count($arrParamsInfo) > 0) { 18 $this->setParams($arrParams, $arrParamsInfo); 19 } 20 } 21 22 function setParams($arrParams, $arrParamsInfo, $useRowParams = false){ 14 $this->_arrObjParams = array(); 15 $this->_arrErrorMessage = array(); 16 $this->_arrGropus = array(); 17 18 $this->setParams($arrParams, $arrParamsInfo); 19 } 20 21 function setParams($arrParams, $arrParamsInfo, $useRawParams = false){ 23 22 foreach ($arrParamsInfo as $_key => $_value) { 24 23 $arrParamsInfo[$_key]['value'] = $arrParams[$_key]; 25 $this->_arrObjParams[ $_key] = new SC_Param($arrParamsInfo[$_key]);26 } 27 // $_POST¡¢$_GET¤Ï¸¶Â§»ÈÍÑ¶Ø»ß 28 if ($useR owParams === true) { return; }24 $this->_arrObjParams[] = new SC_Param($arrParamsInfo[$_key]); 25 } 26 // $_POST¡¢$_GET¤Ï¸¶Â§»ÈÍѶػß(Ê̥᥽¥Ã¥É¤Ë¤¹¤ë¡©) 27 if ($useRawParams === true) { return; } 29 28 unset($_POST, $_GET); 30 29 } 31 30 32 function setGroups($arrGroup){ 33 $this->_groups = $arrGroup; 34 } 35 36 function getGroups(){ 37 return $this->_groups; 38 } 39 31 function serGroups($groupName, $arrTargetName, $arrValidateMethod){ 32 foreach ($arrTargetName as $targetName) { 33 $this->_arrObjParams['group'] = $groupName: 34 ); 35 $this->_arrGroups[$groupName]['validateMethd'] = $arrValidateMethod 36 } 40 37 41 38 function validate(){ 42 $arrGroups = array(); // Ê£¿ô¹àÌÜ¥Á¥§¥Ã¥¯ÍÑ 43 $arrParent = array(); // ¾å°Ì¹àÌÜ¥Á¥§¥Ã¥¯ÍÑ 44 45 46 foreach ($this->_arrObjParams as $_key => $objParam) { 47 // Ê£¿ô¹àÌÜ¥Á¥§¥Ã¥¯ÍÑÇÛÎó¤ò¹½ÃÛ 48 if ($objParam->has_group()) { $arrGroups[$objParam->getGroup()][$_key] = $objParam; } 49 50 // ¾å°Ì¹àÌÜ¥Á¥§¥Ã¥¯ 51 if ($objParam->has_parent()) { 52 $has_parent = true; 53 while ($has_parent) { 54 if ($this->_arrParamsInfo[$objParam->getParent()]->has_parent()) { 55 56 } 39 $arrErrorMessage = array(); // ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸³ÊǼÍÑÇÛÎó 40 $arrGroups = $this->_arrGroups; // Ê£¿ô¹àÌܸ¡¾ÚÍÑÇÛÎó 41 42 foreach ($this->_arrObjParams as $objParam) { 43 $keyname = $objParam->getKeyName(); 44 45 // Ê£¿ô¹àÌܸ¡¾ÚÍÑÇÛÎó¤ò¹½ÃÛ 46 /* 47 if ($objParam->has_group() === true) { 48 $arrGroups[$objParam->getGroupName()][] = $objParam; 49 } 50 */ 51 52 $arrValidateMethod = $objParam->getValidateMethod(); 53 54 // ñÂιàÌܤθ¡¾Ú 55 foreach ($arrValidateMethod as $method => $args) { 56 $objValidator = SC_Validator::factory($method, $args); 57 58 if ($objValidator->validate($objParam) === false) { 59 $arrErrorMessage[$keyname] = $objValidator->getErrorMessage(); 57 60 } 58 61 } 59 60 $arrValidateType = $objParam->getValidateType(); 61 62 // Single Validation 63 foreach ($arrValidateType as $method => $args) { 64 $objValidator = SC_Validate::factory($method, $args); 65 66 if ($objValidator->validate($objParam) == true) { 67 $this->arrErr[$_key] = $objValidator->getErrorMessage(); 68 } 69 } 70 } 71 72 // Group Validation 73 foreach ($arrGroups as $group => $_value) { 62 } 63 64 // Ê£¿ô¹àÌܤθ¡¾Ú 65 foreach ($arrGroups as $groupname => $objParam) { 66 $keyname = $objParam->getKeyName(); 67 74 68 // ´û¤Ë¥¨¥é¡¼¤¬¤¢¤ë¾ì¹ç¤Ïvalidation¤ò¹Ô¤ï¤Ê¤¤ 75 if (array_key_exists( array_keys($_value), $this->arrErr)) {69 if (array_key_exists($keyname, $arrErrorMessage)) { 76 70 continue; 77 71 } 78 72 73 $arrValidateMethod = $objParam->getGroupValidateMethod(); 79 74 $objValidator = SC_Validate::factory('GROUP'); 80 75 if ($objValidator->validate($arrGroups[$group]) === true) { … … 83 78 } 84 79 85 // ¿Æ»Ò validation 86 87 return $this; 80 return $arrErrorMessage; 81 } 82 83 function convert(){ 84 foreach ($this->_arrObjParams as &$objParams) { 85 $objParams->convert(); 86 } 87 } 88 function is_error(){ 89 if (count($this->_arrErrorMessage) > 0) { 90 return true; 91 } else { 92 return false; 93 } 88 94 } 89 95
Note: See TracChangeset
for help on using the changeset viewer.