Definition = $FormClass; foreach($this->Definition['Items'] as $Index => $Item) { $this->Values[$Index] = ''; } } function ShowTable() { $Output = $this->ShowTableBlock(); return($Output); } function ShowTableBlock($Context = '') { global $FormTypes; $Table = array( 'Header' => array('Položka', 'Hodnota'), 'Rows' => array(), ); if($Context != '') $Context = $Context.'-'; foreach($this->Definition['Items'] as $Index => $Item) { if($Item['Type'] != 'Hidden') { if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; $Edit = ExecuteTypeEvent($this->System, $Item['Type'], 'OnView', array('Name' => $Index, 'Value' => $this->Values[$Index], 'Type' => $Item['Type'])); array_push($Table['Rows'], array($Item['Caption'], $Edit)); } } $Html = new Html(); $Output = '
'.$this->Definition['Title'].'
'.$Html->Table($Table, 'WideTable'); return($Output); } function ShowEditForm() { if(!array_key_exists('SubmitText', $this->Definition)) $this->Definition['SubmitText'] = 'Uložit'; $Output = '
'.$this->ShowEditBlock().'
'; return($Output); } function ShowEditBlock($Context = '') { global $FormTypes; $Table = array( //'Header' => array('Položka', 'Hodnota'), 'Rows' => array(), ); if($Context != '') $Context = $Context.'-'; foreach($this->Definition['Items'] as $Index => $Item) { if($Item['Type'] != 'Hidden') { if(!array_key_exists($Index, $this->Values) and isset($Item['Default'])) $this->Values[$Index] = $Item['Default']; $Edit = ExecuteTypeEvent($this->System, $Item['Type'], 'OnEdit', array('Name' => $Index, 'Value' => $this->Values[$Index], 'Type' => $Item['Type'])); array_push($Table['Rows'], array($Item['Caption'].':', $Edit)); } } $Html = new Html(); $Output = '
'.$this->Definition['Title'].''.$Html->Table($Table, 'BasicTable'). '
'; foreach($this->Definition['Items'] as $Index => $Item) if($Item['Type'] == 'Hidden') $Output .= ExecuteTypeEvent($this->System, $Item['Type'], 'OnEdit', array('Name' => $Index, 'Value' => $this->Values[$Index], 'Type' => $Item['Type'])); return($Output); } function LoadValuesFromDatabase($Id) { $DbResult = $this->Database->query('SELECT T.* FROM '.$this->Definition['Table'].' AS T WHERE T.Id='.$Id); if($DbResult->num_rows > 0) $DbRow = $DbResult->fetch_assoc(); foreach($this->Definition['Items'] as $Index => $Item) { if($Item['Type'] != 'Hidden') if($DbResult->num_rows > 0) $this->Values[$Index] = $DbRow[$Index]; else $this->Values[$Index] = ''; } return($DbResult->num_rows > 0); } function SaveValuesToDatabase($Id) { if($Id == 0) { $this->Values['Id'] = $Id; $DbResult = $this->Database->replace($this->Definition['Table'], $this->Values); } else $DbResult = $this->Database->update($this->Definition['Table'], 'Id='.$Id, $this->Values); } function LoadValuesFromForm() { $this->Values = $this->LoadValuesFromFormBlock(); } function LoadValuesFromFormBlock($Context = '') { global $FormTypes; if($Context != '') $Context = $Context.'-'; $Values = array(); foreach($this->Definition['Items'] as $Index => $Item) { if(array_key_exists($Context.$Index, $_POST)) $Values[$Index] = ExecuteTypeEvent($this->System, $Item['Type'], 'OnLoad', array('Name' => $Index, 'Type' => $Item['Type'])); } return($Values); } }