source: trunk/www/Application/View/Emulator.php@ 72

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