[69] | 1 | <?php
|
---|
| 2 |
|
---|
[78] | 3 | include_once(dirname(__FILE__).'/../../Base/View.php');
|
---|
| 4 |
|
---|
| 5 | class EmulatorView extends View
|
---|
[69] | 6 | {
|
---|
| 7 | var $ItemFormClass = array(
|
---|
| 8 | 'Title' => 'Emulátor',
|
---|
| 9 | 'Table' => 'Emulator',
|
---|
| 10 | 'Items' => array(
|
---|
| 11 | 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
|
---|
| 12 | 'Version' => array('Type' => 'String', 'Caption' => 'Verze', 'Default' => ''),
|
---|
| 13 | 'Revision' => array('Type' => 'Integer', 'Caption' => 'Revize', 'Default' => 0),
|
---|
| 14 | 'Client' => array('Type' => 'Client', 'Caption' => 'Verze klienta', 'Default' => 0),
|
---|
| 15 | 'ScriptDev2Revision' => array('Type' => 'Integer', 'Caption' => 'Verze SD2', 'Default' => 0),
|
---|
| 16 | 'ScriptDev2PatchFileName' => array('Type' => 'String', 'Caption' => 'SD2 záplata', 'Default' => ''),
|
---|
| 17 | 'CommitHash' => array('Type' => 'String', 'Caption' => 'Commit HASH', 'Default' => ''),
|
---|
| 18 | ),
|
---|
| 19 | );
|
---|
| 20 | var $ItemListFormClass = array(
|
---|
| 21 | 'Title' => 'Emulátory',
|
---|
| 22 | '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)',
|
---|
| 23 | 'DefaultOrderColumn' => 'Revision',
|
---|
| 24 | 'DefaultOrderDirection' => 1,
|
---|
| 25 | 'Items' => array(
|
---|
| 26 | 'Name' => array('Type' => 'String', 'Caption' => 'Název', 'Default' => ''),
|
---|
| 27 | 'Version' => array('Type' => 'String', 'Caption' => 'Verze', 'Default' => ''),
|
---|
| 28 | 'Revision' => array('Type' => 'Integer', 'Caption' => 'Revize', 'Default' => 0),
|
---|
| 29 | 'ClientVersion' => array('Type' => 'Integer', 'Caption' => 'Verze klienta', 'Default' => 0),
|
---|
| 30 | 'ScriptDev2Revision' => array('Type' => 'Integer', 'Caption' => 'Verze SD2', 'Default' => 0),
|
---|
| 31 | //'ScriptDev2PatchFileName' => array('Type' => 'String', 'Caption' => 'SD2 záplata', 'Default' => ''),
|
---|
| 32 | //'CommitHash' => array('Type' => 'String', 'Caption' => 'Commit HASH', 'Default' => ''),
|
---|
| 33 | ),
|
---|
| 34 | );
|
---|
| 35 |
|
---|
| 36 | function ItemList()
|
---|
| 37 | {
|
---|
| 38 | $Output = '<h4>Seznam verzí emulátoru</h4>';
|
---|
[92] | 39 | $Table = new Table($this->ItemListFormClass, $this->System);
|
---|
[69] | 40 | $Table->Definition['Items']['Id'] = array('Type' => 'Hidden', 'Caption' => '', 'Default' => '');
|
---|
| 41 | $Table->LoadValuesFromDatabase($this->Database);
|
---|
| 42 | $Table->Definition['Items']['Actions'] = array('Type' => 'String', 'Caption' => '', 'Default' => '');
|
---|
| 43 | foreach($Table->Values as $Index => $Item)
|
---|
| 44 | {
|
---|
[72] | 45 | $Table->Values[$Index]['Actions'] = '<a href="?Module=Emulator&Action=Show&Id='.$Item['Id'].'">Podrobnosti</a>';
|
---|
[69] | 46 | unset($Table->Values[$Index]['Id']);
|
---|
| 47 | }
|
---|
| 48 | $Output .= $Table->Show();
|
---|
[77] | 49 | if($this->System->Modules['Permission']->Check('Emulator', 'Add'))
|
---|
[69] | 50 | {
|
---|
[72] | 51 | $Output .= '<br /><div style="text-align: center;"><a href="?Module=Emulator&Action=Add">Přidat emulátor</a></dev>';
|
---|
[69] | 52 | }
|
---|
| 53 | return($Output);
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | function Item()
|
---|
| 57 | {
|
---|
| 58 | $Id = $_GET['Id'];
|
---|
[93] | 59 | //$Server = new Server($this->System, $Id);
|
---|
[69] | 60 | $Output = '<h4>Podrobnosti emulátoru</h4>';
|
---|
[72] | 61 | $Form = new Form($this->System, $this->ItemFormClass);
|
---|
[69] | 62 | $Form->LoadValuesFromDatabase($Id);
|
---|
| 63 | $Output .= $Form->ShowTable();
|
---|
| 64 | $Output .= '<div style="text-align: center">';
|
---|
[93] | 65 | $Emulator = new Emulator($this->System, $Id);
|
---|
[77] | 66 | if($this->System->Modules['Permission']->Check('Emulator', 'Download', $Emulator->Id))
|
---|
[69] | 67 | {
|
---|
[72] | 68 | if($Emulator->Emulator['Lock'] == 0) $Output .= ' <a href="?Module=Emulator&Action=Download&Id='.$Id.'">Stáhnout</a>';
|
---|
[77] | 69 | }
|
---|
| 70 | if($this->System->Modules['Permission']->Check('Emulator', 'Compile', $Emulator->Id))
|
---|
| 71 | {
|
---|
[72] | 72 | if($Emulator->Emulator['Lock'] == 0) $Output .= ' <a href="?Module=Emulator&Action=Compile&Id='.$Id.'">Přeložit</a>';
|
---|
[69] | 73 | }
|
---|
| 74 | $Output .= '</div>';
|
---|
| 75 | return($Output);
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | function Add()
|
---|
| 79 | {
|
---|
[77] | 80 | if($this->System->Modules['Permission']->Check('Emulator', 'Add'))
|
---|
[69] | 81 | {
|
---|
[72] | 82 | $Form = new Form($this->System, $this->ItemFormClass);
|
---|
[69] | 83 | $Form->LoadValuesFromForm();
|
---|
[72] | 84 | $Form->OnSubmit = '?Module=Emulator&Action=AddFinish';
|
---|
[69] | 85 | $Output = $Form->ShowEditForm();
|
---|
| 86 | } else $Output = USER_BAD_ROLE;
|
---|
| 87 | return($Output);
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | function AddFinish()
|
---|
| 91 | {
|
---|
[77] | 92 | if($this->System->Modules['Permission']->Check('Emulator', 'Add'))
|
---|
[69] | 93 | {
|
---|
[72] | 94 | $Form = new Form($this->System, $this->ItemFormClass);
|
---|
[69] | 95 | $Form->LoadValuesFromForm();
|
---|
| 96 | $Form->SaveValuesToDatabase(0);
|
---|
| 97 | $Output = $this->System->SystemMessage('Přidání nového emulátoru', 'Emulátor přidán.');
|
---|
| 98 | } else $Output = USER_BAD_ROLE;
|
---|
| 99 | return($Output);
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | function Download()
|
---|
| 103 | {
|
---|
| 104 | if(array_key_exists('Id', $_GET))
|
---|
| 105 | {
|
---|
[93] | 106 | $Emulator = new Emulator($this->System, $_GET['Id']);
|
---|
[77] | 107 | if($this->System->Modules['Permission']->Check('Emulator', 'Download', $Emulator->Id))
|
---|
| 108 | {
|
---|
| 109 | $Emulator->Download();
|
---|
| 110 | $Output = $this->System->SystemMessage('Stažení emulátoru', 'Úloha zařazena do fronty');
|
---|
| 111 | $TaskView = new TaskView($this->System);
|
---|
| 112 | $Output .= $TaskView->ItemList();
|
---|
| 113 | } else $Output = $this->System->Modules['Permission']->AccessDenied();
|
---|
[69] | 114 | } else $Output = $this->System->SystemMessage('Stažení emulátoru', 'Nebylo zadáno Id');
|
---|
| 115 | return($Output);
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | function Compile()
|
---|
| 119 | {
|
---|
| 120 | if(array_key_exists('Id', $_GET))
|
---|
| 121 | {
|
---|
[93] | 122 | $Emulator = new Emulator($this->System, $_GET['Id']);
|
---|
[77] | 123 | if($this->System->Modules['Permission']->Check('Emulator', 'Download', $Emulator->Id))
|
---|
| 124 | {
|
---|
| 125 | $Emulator->Compile();
|
---|
| 126 | $Output = $this->System->SystemMessage('Překlad emulátoru', 'Úloha zařazena do fronty');
|
---|
| 127 | $TaskView = new TaskView($this->System);
|
---|
| 128 | $Output .= $TaskView->ItemList();
|
---|
| 129 | } else $Output = $this->System->Modules['Permission']->AccessDenied();
|
---|
[69] | 130 | } else $Output = $this->System->SystemMessage('Překlad emulátoru', 'Nebylo zadáno Id');
|
---|
| 131 | return($Output);
|
---|
| 132 | }
|
---|
| 133 | }
|
---|