1 | <?php
|
---|
2 |
|
---|
3 | include_once('Database.php');
|
---|
4 |
|
---|
5 | class Module
|
---|
6 | {
|
---|
7 | var $Database;
|
---|
8 | var $Config;
|
---|
9 | var $System;
|
---|
10 |
|
---|
11 | function __construct($System)
|
---|
12 | {
|
---|
13 | $this->Database = &$System->Database;
|
---|
14 | $this->Config = &$System->Config;
|
---|
15 | $this->System = &$System;
|
---|
16 | }
|
---|
17 | }
|
---|
18 |
|
---|
19 | class System
|
---|
20 | {
|
---|
21 | var $Database;
|
---|
22 | var $Config;
|
---|
23 | var $ModuleManager;
|
---|
24 | var $PathItems;
|
---|
25 |
|
---|
26 | function __construct()
|
---|
27 | {
|
---|
28 | $this->Config = array();
|
---|
29 | }
|
---|
30 |
|
---|
31 | function Init()
|
---|
32 | {
|
---|
33 | global $Config;
|
---|
34 |
|
---|
35 | $this->Config = $Config;
|
---|
36 | $this->Database = new Database();
|
---|
37 | $this->Database->Connect($this->Config['Database']['Host'],
|
---|
38 | $this->Config['Database']['User'], $this->Config['Database']['Password'],
|
---|
39 | $this->Config['Database']['Database']);
|
---|
40 | $this->Database->charset($this->Config['Database']['Charset']);
|
---|
41 | $this->Database->ShowSQLQuery = $this->Config['Web']['ShowSQLQuery'];
|
---|
42 | $this->Database->ShowSQLError = $this->Config['Web']['ShowSQLError'];
|
---|
43 | $this->Database->LogSQLQuery = $this->Config['Web']['LogSQLQuery'];
|
---|
44 | $this->ModuleManager = new AppModuleManager();
|
---|
45 |
|
---|
46 | $this->Menu = array
|
---|
47 | (
|
---|
48 | array(
|
---|
49 | 'Title' => 'Stav dokončení',
|
---|
50 | 'Hint' => 'Stav dokončení překládů',
|
---|
51 | 'Link' => $this->Link('/statistic.php'),
|
---|
52 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
53 | 'Icon' => '',
|
---|
54 | ),
|
---|
55 | array(
|
---|
56 | 'Title' => 'Exporty',
|
---|
57 | 'Hint' => 'Zde si můžete stáhnout přeložené texty',
|
---|
58 | 'Link' => $this->Link('/export/'),
|
---|
59 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
60 | 'Icon' => '',
|
---|
61 | ),
|
---|
62 | array(
|
---|
63 | 'Title' => 'Soubory',
|
---|
64 | 'Hint' => 'Stahování různých pomocných souborů a programů',
|
---|
65 | 'Link' => $this->Link('/download.php'),
|
---|
66 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
67 | 'Icon' => '',
|
---|
68 | ),
|
---|
69 | array(
|
---|
70 | 'Title' => 'Pokyny',
|
---|
71 | 'Hint' => 'Informace k překladu hry',
|
---|
72 | 'Link' => $this->Link('/info.php'),
|
---|
73 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
74 | 'Icon' => '',
|
---|
75 | ),
|
---|
76 | array(
|
---|
77 | 'Title' => 'Zdroje dat',
|
---|
78 | 'Hint' => 'Informace o překladových skupinách',
|
---|
79 | 'Link' => $this->Link('/TranslationList.php?action=grouplist'),
|
---|
80 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
81 | 'Icon' => '',
|
---|
82 | ),
|
---|
83 | array(
|
---|
84 | 'Title' => 'Prezentace',
|
---|
85 | 'Hint' => 'Prezentace a motivace překladu',
|
---|
86 | 'Link' => $this->Link('/promotion.php'),
|
---|
87 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
88 | 'Icon' => '',
|
---|
89 | ),
|
---|
90 | array(
|
---|
91 | 'Title' => 'Verze hry',
|
---|
92 | 'Hint' => 'Seznam verzí herního klienta',
|
---|
93 | 'Link' => $this->Link('/version.php'),
|
---|
94 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
95 | 'Icon' => '',
|
---|
96 | ),
|
---|
97 | array(
|
---|
98 | 'Title' => 'IRC chat',
|
---|
99 | 'Hint' => 'IRC chat pro překladatele',
|
---|
100 | 'Link' => 'http://embed.mibbit.com/?server=game.zdechov.net%3A6667&channel=%23wowpreklad&forcePrompt=true&charset=utf-8',
|
---|
101 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
102 | 'Icon' => '',
|
---|
103 | ),
|
---|
104 | array(
|
---|
105 | 'Title' => 'Správa',
|
---|
106 | 'Hint' => 'Volby pro správu',
|
---|
107 | 'Link' => $this->Link('/admin/'),
|
---|
108 | 'Permission' => LICENCE_ADMIN,
|
---|
109 | 'Icon' => '',
|
---|
110 | ),
|
---|
111 | );
|
---|
112 |
|
---|
113 | }
|
---|
114 |
|
---|
115 | function GetMicrotime()
|
---|
116 | {
|
---|
117 | list($Usec, $Sec) = explode(' ', microtime());
|
---|
118 | return ((float)$Usec + (float)$Sec);
|
---|
119 | }
|
---|
120 |
|
---|
121 | function Link($Target)
|
---|
122 | {
|
---|
123 | return($this->Config['Web']['BaseURL'].$Target);
|
---|
124 | }
|
---|
125 |
|
---|
126 | function RegisterPage($Path, $Handler)
|
---|
127 | {
|
---|
128 | if(is_array($Path))
|
---|
129 | {
|
---|
130 | $Page = &$this->Pages;
|
---|
131 | $LastKey = array_pop($Path);
|
---|
132 | foreach($Path as $PathItem)
|
---|
133 | {
|
---|
134 | $Page = &$Page[$PathItem];
|
---|
135 | }
|
---|
136 | if(!is_array($Page)) $Page = array('' => $Page);
|
---|
137 | $Page[$LastKey] = $Handler;
|
---|
138 | } else $this->Pages[$Path] = $Handler;
|
---|
139 | }
|
---|
140 |
|
---|
141 | function RegisterMenuItem($MenuItem, $Pos = NULL)
|
---|
142 | {
|
---|
143 | if(is_null($Pos)) $this->Menu[] = $MenuItem;
|
---|
144 | else {
|
---|
145 | array_splice($this->Menu, $Pos, 0, array($MenuItem));
|
---|
146 | }
|
---|
147 | }
|
---|
148 |
|
---|
149 | function SearchPage($PathItems, $Pages)
|
---|
150 | {
|
---|
151 | if(count($PathItems) > 0) $PathItem = $PathItems[0];
|
---|
152 | else $PathItem = '';
|
---|
153 | if(array_key_exists($PathItem, $Pages))
|
---|
154 | {
|
---|
155 | if(is_array($Pages[$PathItem]))
|
---|
156 | {
|
---|
157 | array_shift($PathItems);
|
---|
158 | return($this->SearchPage($PathItems, $Pages[$PathItem]));
|
---|
159 | } else return($Pages[$PathItem]);
|
---|
160 | } else return('');
|
---|
161 | }
|
---|
162 |
|
---|
163 | function PageNotFound()
|
---|
164 | {
|
---|
165 | return('Page '.implode('/', $this->PathItems).' not found.');
|
---|
166 | }
|
---|
167 |
|
---|
168 | function ShowPage()
|
---|
169 | {
|
---|
170 | /* @var $Page Page */
|
---|
171 | $ClassName = $this->SearchPage($this->PathItems, $this->Pages);
|
---|
172 | if($ClassName != '')
|
---|
173 | {
|
---|
174 | $Page = new $ClassName($this);
|
---|
175 | $Page->GetOutput();
|
---|
176 | } else echo($this->PageNotFound());
|
---|
177 | }
|
---|
178 | }
|
---|