'Emulátor',
'Table' => 'Emulator',
'Items' => array(
'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
'Version' => array('Type' => 'String', 'Caption' => 'Verze', 'Default' => ''),
'Revision' => array('Type' => 'Integer', 'Caption' => 'Revize', 'Default' => 0),
'Client' => array('Type' => 'Client', 'Caption' => 'Verze klienta', 'Default' => 0),
'ScriptDev2Revision' => array('Type' => 'Integer', 'Caption' => 'Verze SD2', 'Default' => 0),
'ScriptDev2PatchFileName' => array('Type' => 'String', 'Caption' => 'SD2 záplata', 'Default' => ''),
'CommitHash' => array('Type' => 'String', 'Caption' => 'Commit HASH', 'Default' => ''),
),
);
var $ItemListFormClass = array(
'Title' => 'Emulátory',
'Table' => '(SELECT `Emulator`.`Name`, `Emulator`.`Id`, `Client`.`Version` AS `ClientVersion`, `Emulator`.`Revision`, `Emulator`.`ScriptDev2Revision`, `Emulator`.`ScriptDev2PatchFileName`, `Emulator`.`Version`, `Emulator`.`CommitHash` FROM `Emulator` JOIN `Client` ON `Client`.`Id` = `Emulator`.`Client` WHERE `Emulator`.`Enable` = 1)',
'DefaultOrderColumn' => 'Revision',
'DefaultOrderDirection' => 1,
'Items' => array(
'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
'Version' => array('Type' => 'String', 'Caption' => 'Verze', 'Default' => ''),
'Revision' => array('Type' => 'Integer', 'Caption' => 'Revize', 'Default' => 0),
'ClientVersion' => array('Type' => 'Integer', 'Caption' => 'Verze klienta', 'Default' => 0),
'ScriptDev2Revision' => array('Type' => 'Integer', 'Caption' => 'Verze SD2', 'Default' => 0),
//'ScriptDev2PatchFileName' => array('Type' => 'String', 'Caption' => 'SD2 záplata', 'Default' => ''),
//'CommitHash' => array('Type' => 'String', 'Caption' => 'Commit HASH', 'Default' => ''),
),
);
function ItemList()
{
$Output = '
Seznam verzí emulátoru
';
$Table = new Table($this->ItemListFormClass, $this->System);
$Table->Definition['Items']['Id'] = array('Type' => 'Hidden', 'Caption' => '', 'Default' => '');
$Table->LoadValuesFromDatabase($this->Database);
$Table->Definition['Items']['Actions'] = array('Type' => 'String', 'Caption' => '', 'Default' => '');
foreach($Table->Values as $Index => $Item)
{
$Table->Values[$Index]['Actions'] = 'Podrobnosti';
unset($Table->Values[$Index]['Id']);
}
$Output .= $Table->Show();
if($this->System->Modules['Permission']->Check('Emulator', 'Add'))
{
$Output .= '
Přidat emulátor';
}
return($Output);
}
function Item()
{
$Id = $_GET['Id'];
//$Server = new Server($this->System, $Id);
$Output = '
Podrobnosti emulátoru
';
$Form = new Form($this->System, $this->ItemFormClass);
$Form->LoadValuesFromDatabase($Id);
$Output .= $Form->ShowTable();
$Output .= '
';
$Emulator = new Emulator($this->System, $Id);
if($this->System->Modules['Permission']->Check('Emulator', 'Download', $Emulator->Id))
{
if($Emulator->Emulator['Lock'] == 0) $Output .= '
Stáhnout';
}
if($this->System->Modules['Permission']->Check('Emulator', 'Compile', $Emulator->Id))
{
if($Emulator->Emulator['Lock'] == 0) $Output .= '
Přeložit';
}
$Output .= '
';
return($Output);
}
function Add()
{
if($this->System->Modules['Permission']->Check('Emulator', 'Add'))
{
$Form = new Form($this->System, $this->ItemFormClass);
$Form->LoadValuesFromForm();
$Form->OnSubmit = '?Module=Emulator&Action=AddFinish';
$Output = $Form->ShowEditForm();
} else $Output = USER_BAD_ROLE;
return($Output);
}
function AddFinish()
{
if($this->System->Modules['Permission']->Check('Emulator', 'Add'))
{
$Form = new Form($this->System, $this->ItemFormClass);
$Form->LoadValuesFromForm();
$Form->SaveValuesToDatabase(0);
$Output = $this->System->SystemMessage('Přidání nového emulátoru', 'Emulátor přidán.');
} else $Output = USER_BAD_ROLE;
return($Output);
}
function Download()
{
if(array_key_exists('Id', $_GET))
{
$Emulator = new Emulator($this->System, $_GET['Id']);
if($this->System->Modules['Permission']->Check('Emulator', 'Download', $Emulator->Id))
{
$Emulator->Download();
$Output = $this->System->SystemMessage('Stažení emulátoru', 'Úloha zařazena do fronty');
$TaskView = new TaskView($this->System);
$Output .= $TaskView->ItemList();
} else $Output = $this->System->Modules['Permission']->AccessDenied();
} else $Output = $this->System->SystemMessage('Stažení emulátoru', 'Nebylo zadáno Id');
return($Output);
}
function Compile()
{
if(array_key_exists('Id', $_GET))
{
$Emulator = new Emulator($this->System, $_GET['Id']);
if($this->System->Modules['Permission']->Check('Emulator', 'Download', $Emulator->Id))
{
$Emulator->Compile();
$Output = $this->System->SystemMessage('Překlad emulátoru', 'Úloha zařazena do fronty');
$TaskView = new TaskView($this->System);
$Output .= $TaskView->ItemList();
} else $Output = $this->System->Modules['Permission']->AccessDenied();
} else $Output = $this->System->SystemMessage('Překlad emulátoru', 'Nebylo zadáno Id');
return($Output);
}
}