Legend:
- Unmodified
- Added
- Removed
-
forms.php
r8 r9 33 33 if(!array_key_exists($Index, $this->Values) and isset($Item['Value'])) $this->Values[$Index] = $Item['Value']; 34 34 if(is_callable($Type['CallbackEdit'])) $Edit = $Type['CallbackEdit']($Type, $Item); 35 else $Edit = $Type['CallbackEdit']; 36 /* 37 switch($Type[0]) 38 { 39 case 'Boolean': 40 if($this->Values[$Index] == 0) $Checked = ''; else $Checked = ' CHECKED'; 41 $Edit = '<input type="checkbox" name="'.$Context.$Index.'"'.$Checked.'>'; 42 break; 43 case 'String': 44 $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">'; 45 break; 46 case 'Password': 47 $Edit = '<input type="password" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">'; 48 break; 49 case 'Integer': 50 $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">'; 51 break; 52 case 'Float': 53 $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">'; 54 break; 55 case 'Time': 56 if($this->Values[$Index] == 'Now') $this->Values[$Index] = date('j.n.Y'); 57 $Edit = '<input type="text" name="'.$Context.$Index.'" value="'.$this->Values[$Index].'">'; 58 break; 59 case 'Array': 60 $Form = new Form($Item['ItemClass']); 61 $Edit = '<script type="text/javascript" id="syndication">'. 62 "var Count = 0;". 63 "function AddItem() {". 64 "Count = Count + 1;". 65 "var newcontent = document.createElement('div');". 66 "newcontent.id = '".$Context.$Item['ItemClass']."-' + Count;". 67 "newcontent.innerHTML = '<input type=\"hidden\" name=\"".$Context.$Item['ItemClass']."-' + Count + '\">".$Form->ShowEditBlock($Context.$Item['ItemClass']."-' + Count + '")."';". 68 "var scr = document.getElementById('syndication');". 69 "scr.parentNode.insertBefore(newcontent, scr); }". 70 '</script>'; 71 $Edit .= '<form><input type="button" onclick="AddItem();" value="Přidat položku"></form>'; 72 break; 73 default: 74 if(array_key_exists($Item['Type'], $FormTypes)) 75 { 76 // Custom types 77 switch($FormTypes[$Item['Type']]['Type']) 78 { 79 case 'Enumeration': 80 $Edit = '<select name="'.$Context.$Index.'">'; 81 foreach($FormTypes[$Item['Type']]['States'] as $StateIndex => $StateName) 82 $Edit .= '<option value="'.$StateIndex.'">'.$StateName.'</option>'; 83 $Edit .= '</select>'; 84 break; 85 case 'Reference': 86 $Edit = '<select name="'.$Context.$Index.'">'; 87 $DbResult = $Database->select($FormTypes[$Item['Type']]['Table'], $FormTypes[$Item['Type']]['Id'].' as Id, '.$FormTypes[$Item['Type']]['Name'].' as Name', $FormTypes[$Item['Type']]['Filter'].' ORDER BY Name'); 88 while($Row = $DbResult->fetch_array()) 89 $Edit .= '<option value="'.$Row['Id'].'">'.$Row['Name'].'</option>'; 90 $Edit .= '</select>'; 91 break; 92 default: 93 $Edit = 'Neznámý typ'; 94 } 95 } else $Edit = 'Neznámý typ'; 96 } 97 */ 35 else $Edit = $Type['CallbackEdit']; 36 array_push($Table['Rows'], array($Item['Caption'].':', $Edit)); 37 } 38 return($Table); 39 } 40 41 function ShowReadOnlyForm() 42 { 43 $Output = '<center><div align="center">'; 44 $Table = $this->ShowReadOnlyBlock(); 45 $Output .= $this->Definition['Title'].Table($Table).'</div></form>'; 46 return($Output); 47 } 48 49 function ShowReadOnlyBlock($Context = '') 50 { 51 global $Database, $Types; 52 53 $Table = array( 54 'Header' => array('Položka', 'Hodnota'), 55 'Rows' => array(), 56 ); 57 if($Context != '') $Context = $Context.'-'; 58 foreach($this->Definition['Items'] as $Item) 59 { 60 $ItemType = explode(':', $Item['Type']); 61 $Index = $Item['Name']; 62 $Type = $Types[$ItemType[0]]; 63 if(!array_key_exists($Index, $this->Values) and isset($Item['Value'])) $this->Values[$Index] = $Item['Value']; 64 if(is_callable($Type['CallbackView'])) $Edit = $Type['CallbackView']($Type, $Item); 65 else $Edit = $Type['CallbackView']; 98 66 array_push($Table['Rows'], array($Item['Caption'].':', $Edit)); 99 67 }
Note:
See TracChangeset
for help on using the changeset viewer.