Changeset 605 for trunk/Common/Form
- Timestamp:
- Dec 8, 2013, 4:38:25 PM (11 years ago)
- Location:
- trunk/Common/Form
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Form/Form.php
r581 r605 243 243 return($Values); 244 244 } 245 246 function Validate() 247 { 248 $Values = array(); 249 foreach($this->Definition['Items'] as $Index => $Item) 250 if((!array_key_exists($Item['Type'], $this->FormManager->FormTypes) or 251 (array_key_exists($Item['Type'], $this->FormManager->FormTypes) and 252 ($this->FormManager->FormTypes[$Item['Type']]['Type'] != 'ManyToOne'))) and 253 (!array_key_exists('ReadOnly', $Item) or 254 (array_key_exists('ReadOnly', $Item) and 255 ($Item['ReadOnly'] != true)))) 256 { 257 //if(array_key_exists($Context.$Index, $_POST)) 258 if(array_key_exists($Item['Type'], $this->FormManager->FormTypes)) 259 { 260 if(!array_key_exists($Item['Type'], $this->FormManager->Type->TypeDefinitionList)) 261 $this->FormManager->Type->RegisterType($Item['Type'], '', 262 $this->FormManager->FormTypes[$Item['Type']]); 263 $CustomType = $this->FormManager->FormTypes[$Item['Type']]['Type']; 264 if($CustomType == 'Reference') 265 $UseType = 'OneToMany'; 266 else if($CustomType == 'Enumeration') 267 $UseType = 'Enumeration'; 268 } else $UseType = $Item['Type']; 269 270 $Parameters = array('Value' => $this->Values[$Index]); 271 if(array_key_exists('Null', $Item)) $Parameters['Null'] = $Item['Null']; 272 else $Parameters['Null'] = false; 273 if(!$this->FormManager->Type->ExecuteTypeEvent($UseType, 'Validate', 274 $Parameters)) throw new Exception('not validated'); 275 } 276 return($Values); 277 } 245 278 } 279 246 280 247 281 function MakeLink($Target, $Title) -
trunk/Common/Form/Types/Base.php
r601 r605 60 60 return($Output); 61 61 } 62 63 function Validate($Item) 64 { 65 return(true); 66 } 62 67 } -
trunk/Common/Form/Types/IPv4Address.php
r548 r605 21 21 return($_POST[$Item['Name']]); 22 22 } 23 24 function Validate($Item) 25 { 26 if($Item['Null'] and ($Item['Value'] == '')) return(true); 27 return(filter_var($Item['Value'], FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4))); 28 } 23 29 } -
trunk/Common/Form/Types/Type.php
r574 r605 19 19 include(dirname(__FILE__).'/GPS.php'); 20 20 include(dirname(__FILE__).'/IPv4Address.php'); 21 include(dirname(__FILE__).'/IPv6Address.php'); 21 22 include(dirname(__FILE__).'/Color.php'); 22 23 include(dirname(__FILE__).'/RandomHash.php'); 24 include(dirname(__FILE__).'/MacAddress.php'); 23 25 24 26 class Type … … 52 54 'Color' => array('Name' => 'Color', 'Class' => 'Color', 'ParentType' => '', 'Parameters' => array()), 53 55 'RandomHash' => array('Name' => 'RandomHash', 'Class' => 'RandomHash', 'ParentType' => '', 'Parameters' => array()), 56 'MacAddress' => array('Name' => 'MacAddress', 'Class' => 'MacAddress', 'ParentType' => '', 'Parameters' => array()), 57 'IPv6Address' => array('Name' => 'IPv6Address', 'Class' => 'IPv6Address', 'ParentType' => '', 'Parameters' => array()), 54 58 ); 55 59 }
Note:
See TracChangeset
for help on using the changeset viewer.