Legend:
- Unmodified
- Added
- Removed
-
forms.php
r10 r11 9 9 var $OnSubmit = ''; 10 10 11 function DefinitionTextTypeToNumericType() 12 { 13 global $TypeNames; 14 15 foreach($this->Definition['Items'] as $Index => $Definition) 16 if(!is_numeric($Definition['Type'])) $this->Definition['Items'][$Index]['Type'] = $TypeNames[$Definition['Type']]; 17 } 18 11 19 function ShowEditForm() 12 20 { 21 $this->DefinitionTextTypeToNumericType(); 13 22 $Output = '<center><form action="'.$this->OnSubmit.'" method="post"><div align="center">'; 14 23 $Table = $this->ShowEditBlock(); … … 58 67 function ShowReadOnlyForm() 59 68 { 69 $this->DefinitionTextTypeToNumericType(); 70 60 71 $Output = '<center><div align="center">'; 61 72 $Table = $this->ShowReadOnlyBlock(); … … 90 101 foreach($this->Definition['Items'] as $Item) 91 102 { 92 $Index = $Item['Name']; 93 $this->Values[$Index] = $DbRow[$Index]; 103 $this->Values[$Item['Name']] = $DbRow[$Item['Name']]; 94 104 switch($Item['Type']) 95 105 { 96 106 case 'Password': 97 if($Item['Type'] == 'Password') $this->Values[$I ndex] = ''; // Dont show password107 if($Item['Type'] == 'Password') $this->Values[$Item['Name']] = ''; // Dont show password 98 108 break; 99 109 case 'Time': 100 $this->Values[$Index] == MysqlDateTimeToTime($this->Values[$I ndex]);110 $this->Values[$Index] == MysqlDateTimeToTime($this->Values[$Item['Name']]); 101 111 break; 102 112 } … … 110 120 foreach($this->Definition['Items'] as $Item) 111 121 { 112 $Index = $Item['Name'];113 122 switch($Item['Type']) 114 123 { 115 124 case 'Password': 116 if($this->Values[$I ndex] == '') unset($this->Values[$Index]); // Do not modify empty passwords117 else $this->Values[$I ndex] = sha1($this->Values[$Index]);125 if($this->Values[$Item['Name']] == '') unset($this->Values[$Item['Name']]); // Do not modify empty passwords 126 else $this->Values[$Item['Name']] = sha1($this->Values[$Item['Name']]); 118 127 break; 119 128 case 'Time': 120 $this->Values[$I ndex] = TimeToMysqlDateTime($this->Values[$Index]);129 $this->Values[$Item['Name']] = TimeToMysqlDateTime($this->Values[$Item['Name']]); 121 130 break; 122 131 } … … 129 138 function LoadValuesFromForm() 130 139 { 140 $this->DefinitionTextTypeToNumericType(); 131 141 $this->Values = $this->LoadValuesFromFormBlock(); 132 142 } … … 136 146 global $FormTypes; 137 147 138 if($Context != '') $Context = $Context.'-';139 148 $Values = array(); 140 foreach($this->Definition['Items'] as $I tem)149 foreach($this->Definition['Items'] as $Index => $Item) 141 150 { 142 $Index = $Item['Name']; 143 switch($Item['Type']) 144 { 145 case 'Boolean': 146 if(array_key_exists($Context.$Index, $_POST)) $Values[$Index] = 1; 147 else $Values[$Index] = 0; 148 break; 149 case 'String': 150 $Values[$Index] = $_POST[$Context.$Index]; 151 break; 152 case 'Password': 153 $Values[$Index] = $_POST[$Context.$Index]; 154 break; 155 case 'Integer': 156 $Values[$Index] = $_POST[$Context.$Index]; 157 break; 158 case 'Float': 159 $Values[$Index] = $_POST[$Context.$Index]; 160 break; 161 case 'Time': 162 $Values[$Index] = explode('.', $_POST[$Context.$Index]); 163 $Values[$Index] = mktime(0, 0, 0, $Values[$Index][1], $Values[$Index][0], $Values[$Index][2]); 164 break; 165 case 'Array': 166 $I = 1; 167 //echo('Expect: '.$Context.$Item['ItemClass'].'-'.$I.'<br>'); 168 while(isset($_POST[$Context.$Item['ItemClass'].'-'.$I])) 169 { 170 $Form = new Form($Item['ItemClass']); 171 $Values[$Index][] = $Form->LoadValuesFromFormBlock($Context.$Item['ItemClass'].'-'.$I); 172 $I++; 173 } 174 break; 175 default: 176 if(array_key_exists($Item['Type'], $FormTypes)) 177 { 178 // Custom types 179 switch($FormTypes[$Item['Type']]['Type']) 180 { 181 case 'Enumeration': 182 $Values[$Index] = $_POST[$Context.$Index]; 183 break; 184 case 'Reference': 185 $Values[$Index] = $_POST[$Context.$Index]; 186 break; 187 default: 188 } 189 } 190 } 151 $Values[$Item['Name']] = ExecuteTypeEvent($Item['Type'], 'OnLoad', $Item); 191 152 } 153 //print_r($this->Values); 192 154 return($Values); 193 155 }
Note:
See TracChangeset
for help on using the changeset viewer.