Changeset 14162


Ignore:
Timestamp:
2007/06/04 01:21:25 (17 years ago)
Author:
adati
Message:
 
Location:
branches/dev/html/test/adachi
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/dev/html/test/adachi/SC_FormParamsManager.php

    r13744 r14162  
    66 * Form¥Ñ¥é¥á¡¼¥¿´ÉÍý¥¯¥é¥¹ 
    77 */ 
    8  
    98class SC_FormParamsManager { 
    109    var $_arrObjParams; 
    11     var $_arrErr; 
     10    var $_arrErrorMessage; 
     11    var $_arrGropus; 
    1212     
    1313    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){ 
    2322        foreach ($arrParamsInfo as $_key => $_value) { 
    2423            $arrParamsInfo[$_key]['value'] = $arrParams[$_key]; 
    25             $this->_arrObjParams[$_key] = new SC_Param($arrParamsInfo[$_key]); 
    26         } 
    27         // $_POST¡¢$_GET¤Ï¸¶Â§»ÈÍѶػߠ
    28         if ($useRowParams === true) { return; } 
     24            $this->_arrObjParams[] = new SC_Param($arrParamsInfo[$_key]); 
     25        } 
     26        // $_POST¡¢$_GET¤Ï¸¶Â§»ÈÍѶػß(Ê̥᥽¥Ã¥É¤Ë¤¹¤ë¡©) 
     27        if ($useRawParams === true) { return; } 
    2928        unset($_POST, $_GET); 
    3029    } 
    3130     
    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    } 
    4037     
    4138    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(); 
    5760                } 
    5861            } 
    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             
    7468            // ´û¤Ë¥¨¥é¡¼¤¬¤¢¤ë¾ì¹ç¤Ïvalidation¤ò¹Ô¤ï¤Ê¤¤ 
    75             if (array_key_exists(array_keys($_value), $this->arrErr)) { 
     69            if (array_key_exists($keyname, $arrErrorMessage)) { 
    7670                continue; 
    7771            } 
    7872             
     73            $arrValidateMethod = $objParam->getGroupValidateMethod(); 
    7974            $objValidator = SC_Validate::factory('GROUP'); 
    8075            if ($objValidator->validate($arrGroups[$group]) === true) { 
     
    8378        } 
    8479         
    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        } 
    8894    } 
    8995     
  • branches/dev/html/test/adachi/SC_Param.php

    r13743 r14162  
    2323        foreach ($arrProperties as $property) { 
    2424            $this->$property = isset($arrParamInfo[$property]) 
    25                 ? $arrParamInfo[preg_replace('/^_/', '', $property)] 
    26                 : null; 
     25                ? $this->$property = $arrParamInfo[preg_replace('/^_/', '', $property)] 
     26                : $this->$property = null; 
    2727        } 
    2828    } 
  • branches/dev/html/test/adachi/test2.php

    r13835 r14162  
    33require_once("../../require.php"); 
    44require_once("SC_FormParamsManager.php"); 
     5 
     6error_reporting(E_ALL); 
    57 
    68// Smarty¤Ø¤ÎassignÍÑÏ¢ÁÛÇÛÎó 
Note: See TracChangeset for help on using the changeset viewer.