';
return($Output);
}
function ShowEditBlock($Context = '')
{
global $Database;
$Table = array(
'Header' => array('Položka', 'Hodnota'),
'Rows' => array(),
);
if($Context != '') $Context = $Context.'-';
foreach($this->Definition['Items'] as $Index => $Item)
{
if($Item['Type'] != TypeHiddenId)
{
if(!array_key_exists($Index, $this->Values) and isset($Item['Value'])) $this->Values[$Index] = $Item['Value'];
$Edit = ExecuteTypeEvent($Item['Type'], 'OnEdit', $Item);
array_push($Table['Rows'], array($Item['Caption'], $Edit));
}
}
return($Table);
}
function ShowHiddenBlock($Context = '')
{
global $Database;
$Output = '';
if($Context != '') $Context = $Context.'-';
foreach($this->Definition['Items'] as $Item)
{
if($Item['Type'] == TypeHiddenId)
{
if(!array_key_exists($Item['Name'], $this->Values) and isset($Item['Value'])) $this->Values[$Item['Name']] = $Item['Value'];
$Edit = ExecuteTypeEvent($Item['Type'], 'OnEdit', $Item);
$Output .= $Edit;
}
}
return($Output);
}
function ShowReadOnlyForm()
{
$Output = '';
$Table = $this->ShowReadOnlyBlock();
$Output .= $this->Definition['Title'].Table($Table).'
';
return($Output);
}
function ShowReadOnlyBlock($Context = '')
{
global $Database;
$Table = array(
'Header' => array('Položka', 'Hodnota'),
'Rows' => array(),
);
if($Context != '') $Context = $Context.'-';
foreach($this->Definition['Items'] as $Item)
{
if(!array_key_exists($Item['Name'], $this->Values) and isset($Item['Value'])) $this->Values[$Item['Name']] = $Item['Value'];
$Edit = ExecuteTypeEvent($Item['Type'], 'OnView', $Item);
array_push($Table['Rows'], array($Item['Caption'], $Edit));
}
return($Table);
}
function LoadValuesFromDatabase($Id)
{
global $Database;
$DbResult = $Database->query('SELECT * FROM '.$this->Definition['Table'].' WHERE Id='.$Id);
$DbRow = $DbResult->fetch_assoc();
foreach($this->Definition['Items'] as $Item)
{
$this->Values[$Item['Name']] = $DbRow[$Item['Name']];
switch($Item['Type'])
{
case 'Password':
if($Item['Type'] == 'Password') $this->Values[$Item['Name']] = ''; // Dont show password
break;
case 'Time':
$this->Values[$Index] == MysqlDateTimeToTime($this->Values[$Item['Name']]);
break;
}
}
}
function SaveValuesToDatabase($Id)
{
global $Database;
foreach($this->Definition['Items'] as $Item)
{
switch($Item['Type'])
{
case 'Password':
if($this->Values[$Item['Name']] == '') unset($this->Values[$Item['Name']]); // Do not modify empty passwords
else $this->Values[$Item['Name']] = sha1($this->Values[$Item['Name']]);
break;
case 'Time':
$this->Values[$Item['Name']] = TimeToMysqlDateTime($this->Values[$Item['Name']]);
break;
}
}
$this->Values['Id'] = $Id;
$DbResult = $Database->replace($this->Definition['Table'], $this->Values);
//echo($Database->LastQuery);
}
function LoadValuesFromForm()
{
$this->Values = $this->LoadValuesFromFormBlock();
}
function LoadValuesFromFormBlock($Context = '')
{
$Values = array();
foreach($this->Definition['Items'] as $Index => $Item)
{
$Values[$Item['Name']] = ExecuteTypeEvent($Item['Type'], 'OnLoad', $Item);
}
//print_r($this->Values);
return($Values);
}
}
function MakeLink($Target, $Title)
{
return(''.$Title.'');
}
function Table($Table)
{
$Result = '';
$Result .= '';
if(array_key_exists('Header', $Table))
{
foreach($Table['Header'] as $Item)
$Result .= ''.$Item.' | ';
$Result .= '
';
}
foreach($Table['Rows'] as $Row)
{
$Result .= '';
foreach($Row as $Index => $Item)
{
if($Index == 0) $Class = ' class="Header"'; else $Class = '';
$Result .= ''.$Item.' | ';
}
$Result .= '
';
}
$Result .= '
';
return($Result);
}
function ShowEditTable($ClassName, $Values)
{
}
?>