1 | <?php
|
---|
2 |
|
---|
3 | class Core extends Application
|
---|
4 | {
|
---|
5 | var $Config;
|
---|
6 | var $PathItems;
|
---|
7 | var $Menu;
|
---|
8 | var $DoNotShowPage;
|
---|
9 | var $OnPageNotFound;
|
---|
10 | var $Pages;
|
---|
11 | /* @var LocaleManager */
|
---|
12 | var $LocaleManager;
|
---|
13 |
|
---|
14 | function __construct()
|
---|
15 | {
|
---|
16 | parent::__construct();
|
---|
17 | $this->Config = array();
|
---|
18 | $this->Menu = array();
|
---|
19 | $this->RSSChannels = array();
|
---|
20 | $this->DoNotShowPage = false;
|
---|
21 | $this->OnPageNotFound = array();
|
---|
22 | $this->Pages = array();
|
---|
23 | }
|
---|
24 |
|
---|
25 | function Init()
|
---|
26 | {
|
---|
27 | global $GlobalLocaleManager, $Config;
|
---|
28 |
|
---|
29 | $this->Config = $Config;
|
---|
30 | date_default_timezone_set($this->Config['Web']['Timezone']);
|
---|
31 |
|
---|
32 | $this->Database->Connect($this->Config['Database']['Host'],
|
---|
33 | $this->Config['Database']['User'], $this->Config['Database']['Password'],
|
---|
34 | $this->Config['Database']['Database']);
|
---|
35 | $this->Database->charset($this->Config['Database']['Charset']);
|
---|
36 | $this->Database->ShowSQLQuery = $this->Config['Web']['ShowSQLQuery'];
|
---|
37 | $this->Database->ShowSQLError = $this->Config['Web']['ShowSQLError'];
|
---|
38 | $this->Database->LogSQLQuery = $this->Config['Web']['LogSQLQuery'];
|
---|
39 |
|
---|
40 | $this->LocaleManager = new LocaleManager($this);
|
---|
41 | $this->LocaleManager->Dir = dirname(dirname(__FILE__)).'/locale';
|
---|
42 | $this->LocaleManager->Available = array(
|
---|
43 | 'cs' => array('Code' => 'cs', 'Title' => 'Česky'),
|
---|
44 | 'en' => array('Code' => 'en', 'Title' => 'English'),
|
---|
45 | );
|
---|
46 | $GlobalLocaleManager = $this->LocaleManager;
|
---|
47 | $this->LinkLocaleExceptions = array('images', 'style', 'tmp', 'files', 'aowow',
|
---|
48 | 'banners'
|
---|
49 | );
|
---|
50 |
|
---|
51 | $this->PathItems = ProcessURL();
|
---|
52 |
|
---|
53 | // Detect interface locale
|
---|
54 | $this->LocaleManager->DefaultLangCode = $this->Config['Web']['Locale'];
|
---|
55 | $this->LocaleManager->LangCode = $this->LocaleManager->DefaultLangCode;
|
---|
56 | if(count($this->PathItems) > 0)
|
---|
57 | {
|
---|
58 | $NewLangCode = $this->PathItems[0];
|
---|
59 | if(array_key_exists($NewLangCode, $this->LocaleManager->Available)) {
|
---|
60 | array_shift($this->PathItems);
|
---|
61 | $this->LocaleManager->LangCode = $NewLangCode;
|
---|
62 | }
|
---|
63 | }
|
---|
64 | if(array_key_exists($this->LocaleManager->LangCode, $this->LocaleManager->Available))
|
---|
65 | $this->LocaleManager->LoadLocale($this->LocaleManager->LangCode);
|
---|
66 |
|
---|
67 | $this->Menu = array
|
---|
68 | (
|
---|
69 | /* array(
|
---|
70 | 'Title' => T('Files'),
|
---|
71 | 'Hint' => 'Stahování různých pomocných souborů a programů',
|
---|
72 | 'Link' => $this->Link('/download.php'),
|
---|
73 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
74 | 'Icon' => '',
|
---|
75 | ),
|
---|
76 | */
|
---|
77 | array(
|
---|
78 | 'Title' => T('IRC chat'),
|
---|
79 | 'Hint' => 'IRC chat pro překladatele',
|
---|
80 | 'Link' => 'http://embed.mibbit.com/?server=game.zdechov.net%3A6667&channel=%23wowpreklad&forcePrompt=true&charset=utf-8',
|
---|
81 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
82 | 'Icon' => '',
|
---|
83 | ),
|
---|
84 | );
|
---|
85 | }
|
---|
86 |
|
---|
87 | function Run()
|
---|
88 | {
|
---|
89 | global $ScriptStartTime, $TranslationTree, $StopAfterUpdateManager,
|
---|
90 | $UpdateManager, $DatabaseRevision;
|
---|
91 |
|
---|
92 | $ScriptStartTime = GetMicrotime();
|
---|
93 | if(GetRemoteAddress() != '') session_start();
|
---|
94 |
|
---|
95 | if(!isset($this->Config)) die('Systém není nainstalován. Pokračujte v instalaci <a href="admin/install.php">zde</a>.');
|
---|
96 |
|
---|
97 | $this->Init();
|
---|
98 |
|
---|
99 | // Check database persistence structure
|
---|
100 | $UpdateManager = new UpdateManager();
|
---|
101 | $UpdateManager->Database = $this->Database;
|
---|
102 | $UpdateManager->Revision = $DatabaseRevision;
|
---|
103 | if(!$UpdateManager->IsInstalled()) die('Systém vyžaduje instalaci databáze. Pokračujte <a href="'.$this->Link('/Application/install.php').'">zde</a>');
|
---|
104 | if(!$UpdateManager->IsUpToDate()) die('Systém vyžaduje aktualizaci databáze. Pokračujte <a href="'.$this->Link('/Application/install.php').'">zde</a>');
|
---|
105 |
|
---|
106 | // SQL injection hack protection
|
---|
107 | foreach($_POST as $Index => $Item)
|
---|
108 | {
|
---|
109 | if(is_array($_POST[$Index]))
|
---|
110 | foreach($_POST[$Index] as $Index2 => $Item2) $_POST[$Index][$Index2] = addslashes($Item2);
|
---|
111 | else $_POST[$Index] = addslashes($_POST[$Index]);
|
---|
112 | }
|
---|
113 | foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]);
|
---|
114 |
|
---|
115 | // TODO: Global initialized variable should be removed
|
---|
116 | $TranslationTree = GetTranslationTree();
|
---|
117 |
|
---|
118 | // Initialize application modules
|
---|
119 | $this->ModuleManager->RegisterModule(new ModuleError($this));
|
---|
120 | $this->ModuleManager->Modules['Error']->ErrorHandler->ShowError = $this->Config['Web']['ShowPHPError'];
|
---|
121 | $this->ModuleManager->RegisterModule(new ModuleLog($this));
|
---|
122 | $this->ModuleManager->RegisterModule(new ModuleUser($this));
|
---|
123 | $this->ModuleManager->RegisterModule(new ModuleAoWoW($this));
|
---|
124 | $this->ModuleManager->RegisterModule(new ModuleReferrer($this));
|
---|
125 | $this->ModuleManager->Modules['Referrer']->Excludes[] = $this->Config['Web']['Host'];
|
---|
126 | $this->ModuleManager->RegisterModule(new ModuleTeam($this));
|
---|
127 | $this->ModuleManager->RegisterModule(new ModuleDictionary($this));
|
---|
128 | $this->ModuleManager->RegisterModule(new ModuleTranslation($this));
|
---|
129 | $this->ModuleManager->RegisterModule(new ModuleImport($this));
|
---|
130 | $this->ModuleManager->RegisterModule(new ModuleExport($this));
|
---|
131 | $this->ModuleManager->RegisterModule(new ModuleServer($this));
|
---|
132 | $this->ModuleManager->RegisterModule(new ModuleClientVersion($this));
|
---|
133 | $this->ModuleManager->RegisterModule(new ModuleShoutBox($this));
|
---|
134 | $this->ModuleManager->RegisterModule(new ModuleNews($this));
|
---|
135 | $this->ModuleManager->RegisterModule(new ModuleWiki($this));
|
---|
136 | $this->ModuleManager->RegisterModule(new ModuleSearch($this));
|
---|
137 | $this->ModuleManager->RegisterModule(new ModuleFrontPage($this));
|
---|
138 | $this->ModuleManager->RegisterModule(new ModuleDownload($this));
|
---|
139 | $this->ModuleManager->RegisterModule(new ModuleForum($this));
|
---|
140 | $this->ModuleManager->RegisterModule(new ModuleRedirection($this));
|
---|
141 | $this->ModuleManager->RegisterModule(new ModuleAdmin($this));
|
---|
142 | $this->ModuleManager->RegisterModule(new ModuleInfo($this));
|
---|
143 | $this->ModuleManager->FileName = dirname(__FILE__).'/../Config/ModulesConfig.php';
|
---|
144 | // TODO: Allow control from web which modules should be installed
|
---|
145 | $this->ModuleManager->InstallAll();
|
---|
146 | $this->ModuleManager->StartAll();
|
---|
147 |
|
---|
148 | $this->BaseView = new BaseView($this);
|
---|
149 | if($this->DoNotShowPage == false)
|
---|
150 | {
|
---|
151 | $this->ShowPage();
|
---|
152 | }
|
---|
153 | }
|
---|
154 |
|
---|
155 | function GetMicrotime()
|
---|
156 | {
|
---|
157 | list($Usec, $Sec) = explode(' ', microtime());
|
---|
158 | return ((float)$Usec + (float)$Sec);
|
---|
159 | }
|
---|
160 |
|
---|
161 | function Link($Target)
|
---|
162 | {
|
---|
163 | $Remaining = substr($Target, count($this->Config['Web']['BaseURL']));
|
---|
164 | $TargetParts = explode('/', $Remaining);
|
---|
165 | if(count($TargetParts) > 0)
|
---|
166 | {
|
---|
167 | if(in_array($TargetParts[0], $this->LinkLocaleExceptions))
|
---|
168 | {
|
---|
169 | return($this->Config['Web']['BaseURL'].$Target);
|
---|
170 | }
|
---|
171 | }
|
---|
172 | return($this->LinkLocale($Target));
|
---|
173 | }
|
---|
174 |
|
---|
175 | function TranslateURL($URL, $Locale)
|
---|
176 | {
|
---|
177 | // Try translate URL directory parts from current locale to target locale
|
---|
178 | $Remaining = $URL;
|
---|
179 | $RemainingParts = explode('?', $Remaining);
|
---|
180 | $Directory = $RemainingParts[0];
|
---|
181 | if(count($RemainingParts) > 1)
|
---|
182 | {
|
---|
183 | $Params = $RemainingParts[1];
|
---|
184 | } else {
|
---|
185 | $Params = '';
|
---|
186 | }
|
---|
187 | $TargetLocaleManager = new LocaleManager($this);
|
---|
188 | $TargetLocaleManager->Dir = $this->LocaleManager->Dir;
|
---|
189 | $TargetLocaleManager->Available = $this->LocaleManager->Available;
|
---|
190 | $TargetLocaleManager->LoadLocale($Locale);
|
---|
191 |
|
---|
192 | $DirectoryParts = explode('/', $Directory);
|
---|
193 | foreach($DirectoryParts as $Index => $Item)
|
---|
194 | {
|
---|
195 | $NewText = $TargetLocaleManager->CurrentLocale->Texts->Translate($Item, 'URL');
|
---|
196 | $DirectoryParts[$Index] = $NewText;
|
---|
197 | }
|
---|
198 | $Directory = implode('/', $DirectoryParts);
|
---|
199 | $Remaining = $Directory;
|
---|
200 | if($Params != '') $Remaining .= '?'.$Params;
|
---|
201 |
|
---|
202 | return($Remaining);
|
---|
203 | }
|
---|
204 |
|
---|
205 | function TranslateReverseURL($URL, $Locale)
|
---|
206 | {
|
---|
207 | // Try translate URL directory parts from current locale to target locale
|
---|
208 | $Remaining = $URL;
|
---|
209 | $RemainingParts = explode('?', $Remaining);
|
---|
210 | $Directory = $RemainingParts[0];
|
---|
211 | if(count($RemainingParts) > 1)
|
---|
212 | {
|
---|
213 | $Params = $RemainingParts[1];
|
---|
214 | } else {
|
---|
215 | $Params = '';
|
---|
216 | }
|
---|
217 | $TargetLocaleManager = new LocaleManager($this);
|
---|
218 | $TargetLocaleManager->Dir = $this->LocaleManager->Dir;
|
---|
219 | $TargetLocaleManager->Available = $this->LocaleManager->Available;
|
---|
220 | $TargetLocaleManager->LoadLocale($Locale);
|
---|
221 |
|
---|
222 | $DirectoryParts = explode('/', $Directory);
|
---|
223 | foreach($DirectoryParts as $Index => $Item)
|
---|
224 | {
|
---|
225 | $NewText = $TargetLocaleManager->CurrentLocale->Texts->TranslateReverse($Item, 'URL');
|
---|
226 | $DirectoryParts[$Index] = $NewText;
|
---|
227 | }
|
---|
228 | $Directory = implode('/', $DirectoryParts);
|
---|
229 | $Remaining = $Directory;
|
---|
230 | if($Params != '') $Remaining .= '?'.$Params;
|
---|
231 |
|
---|
232 | return($Remaining);
|
---|
233 | }
|
---|
234 |
|
---|
235 | function LinkLocale($Target, $Locale = '')
|
---|
236 | {
|
---|
237 | if($Locale == '') $Locale = $this->LocaleManager->LangCode;
|
---|
238 |
|
---|
239 | $Target = $this->TranslateURL($Target, $Locale);
|
---|
240 |
|
---|
241 | if($Locale == $this->LocaleManager->DefaultLangCode)
|
---|
242 | return($this->Config['Web']['BaseURL'].$Target);
|
---|
243 | return($this->Config['Web']['BaseURL'].'/'.$Locale.$Target);
|
---|
244 | }
|
---|
245 |
|
---|
246 | function RegisterPage($Path, $Handler)
|
---|
247 | {
|
---|
248 | if(is_array($Path))
|
---|
249 | {
|
---|
250 | $Page = &$this->Pages;
|
---|
251 | $LastKey = array_pop($Path);
|
---|
252 | foreach($Path as $PathItem)
|
---|
253 | {
|
---|
254 | $Page = &$Page[$PathItem];
|
---|
255 | }
|
---|
256 | if(!is_array($Page)) $Page = array('' => $Page);
|
---|
257 | $Page[$LastKey] = $Handler;
|
---|
258 | } else $this->Pages[$Path] = $Handler;
|
---|
259 | }
|
---|
260 |
|
---|
261 | function RegisterMenuItem($MenuItem, $Pos = NULL)
|
---|
262 | {
|
---|
263 | if(is_null($Pos)) $this->Menu[] = $MenuItem;
|
---|
264 | else {
|
---|
265 | array_splice($this->Menu, $Pos, 0, array($MenuItem));
|
---|
266 | }
|
---|
267 | }
|
---|
268 |
|
---|
269 | function SearchPage($PathItems, $Pages)
|
---|
270 | {
|
---|
271 | if(count($PathItems) == 0) $PathItems = array('');
|
---|
272 | $PathItem = $PathItems[0];
|
---|
273 | $PathItem = $this->LocaleManager->CurrentLocale->Texts->TranslateReverse($PathItem, 'URL');
|
---|
274 |
|
---|
275 | if(array_key_exists($PathItem, $Pages))
|
---|
276 | {
|
---|
277 | if(is_array($Pages[$PathItem]))
|
---|
278 | {
|
---|
279 | array_shift($PathItems);
|
---|
280 | return($this->SearchPage($PathItems, $Pages[$PathItem]));
|
---|
281 | } else
|
---|
282 | {
|
---|
283 | if(count($PathItems) == 1) return($Pages[$PathItem]);
|
---|
284 | else return(''); // Unexpected subpages
|
---|
285 | }
|
---|
286 | } else return('');
|
---|
287 | }
|
---|
288 |
|
---|
289 | function PageNotFound()
|
---|
290 | {
|
---|
291 | // Send correct HTTP status code to signal unknown page
|
---|
292 | if(array_key_exists('SERVER_PROTOCOL', $_SERVER))
|
---|
293 | Header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
|
---|
294 | if(array_key_exists('HTTP_REFERER', $_SERVER)) $Referer = ' Referer: '.$_SERVER['HTTP_REFERER'];
|
---|
295 | else $Referer = '';
|
---|
296 | if(isset($this->ModuleManager->Modules['Log']))
|
---|
297 | $this->ModuleManager->Modules['Log']->WriteLog('Stránka "'.
|
---|
298 | implode('/', $this->PathItems).'" nenalezena'.$Referer, LOG_TYPE_PAGE_NOT_FOUND);
|
---|
299 | return(ShowMessage(sprintf(T('Page "%s" not found'), implode('/', $this->PathItems)), MESSAGE_CRITICAL));
|
---|
300 | }
|
---|
301 |
|
---|
302 | function ShowPage()
|
---|
303 | {
|
---|
304 | $Output = '';
|
---|
305 |
|
---|
306 | /* @var $Page Page */
|
---|
307 | $ClassName = $this->SearchPage($this->PathItems, $this->Pages);
|
---|
308 | if(($ClassName != '') and (class_exists($ClassName)))
|
---|
309 | {
|
---|
310 | $Page = new $ClassName($this);
|
---|
311 | $Output = $Page->GetOutput();
|
---|
312 | $this->BaseView->Title = $Page->Title;
|
---|
313 | if($Page->RawPage == false) $Output = $this->BaseView->ShowPage($Output);
|
---|
314 | } else {
|
---|
315 | $Output2 = '';
|
---|
316 | if((count($this->OnPageNotFound) == 2)
|
---|
317 | and method_exists($this->OnPageNotFound[0], $this->OnPageNotFound[1]))
|
---|
318 | $Output2 = call_user_func_array($this->OnPageNotFound, array());
|
---|
319 | if($Output2 != '') $Output .= $this->BaseView->ShowPage($Output2);
|
---|
320 | else {
|
---|
321 | $Output = $this->PageNotFound();
|
---|
322 | $this->BaseView->Title = T('Page not found');
|
---|
323 | $Output = $this->BaseView->ShowPage($Output);
|
---|
324 | }
|
---|
325 | }
|
---|
326 | echo($Output);
|
---|
327 | }
|
---|
328 | }
|
---|
329 |
|
---|
330 | class BaseView extends View
|
---|
331 | {
|
---|
332 | var $Title;
|
---|
333 |
|
---|
334 | function ShowLocaleSelector()
|
---|
335 | {
|
---|
336 | //$Output .= ' <form action="?setlocale" method="get">';
|
---|
337 | $Output = ' <select onchange="window.location=this.value">';
|
---|
338 | foreach($this->System->LocaleManager->Available as $Locale)
|
---|
339 | {
|
---|
340 | $Remaining = substr($_SERVER["REQUEST_URI"], strlen($this->System->Config['Web']['BaseURL']));
|
---|
341 | if(substr($Remaining, 1, strlen($Locale['Code'].'/')) == $this->System->LocaleManager->LangCode.'/')
|
---|
342 | $Remaining = substr($Remaining, strlen('/'.$Locale['Code']));
|
---|
343 | if($Locale['Code'] == $this->System->LocaleManager->CurrentLocale->Texts->Code) $Selected = ' selected="selected"';
|
---|
344 | else $Selected = '';
|
---|
345 | $Remaining = $this->System->TranslateReverseURL($Remaining, $this->System->LocaleManager->LangCode);
|
---|
346 |
|
---|
347 | $URL = $this->System->LinkLocale($Remaining, $Locale['Code']);
|
---|
348 | $Output .= '<option title="" value="'.$URL.'"'.$Selected.' onchange="this.form.submit()">'.$Locale['Title'].'</option>';
|
---|
349 | }
|
---|
350 | $Output .= '</select><noscript><span><input type="submit" value="Submit"/></span></noscript>';
|
---|
351 |
|
---|
352 | return($Output);
|
---|
353 | }
|
---|
354 |
|
---|
355 | function ShowTopBar()
|
---|
356 | {
|
---|
357 | $Output = '<div class="Menu">';
|
---|
358 | if(!$this->System->User->Licence(LICENCE_USER))
|
---|
359 | $Output .= '<div class="advert">'.$this->System->Config['Web']['Advertisement'].'</div>';
|
---|
360 | $Output .= '<span class="MenuItem"></span><span class="MenuItem2">';
|
---|
361 | if($this->System->User->Licence(LICENCE_USER))
|
---|
362 | {
|
---|
363 | //$DbResult =$this->Database->query('SELECT `Id`, `Name` FROM `Team` WHERE `Id`='.$this->System->User->Team);
|
---|
364 | //$Team = $DbResult->fetch_assoc();
|
---|
365 | //$Output .= ''<span class="MenuItem">Moje překlady: <a href="">Dokončené</a> <a href="">Rozpracované</a> <a href="">Exporty</a> Tým: <a href="">'.$Team['name'].'</a></span>';
|
---|
366 | $Output .= $this->System->User->Name.' <a href="'.$this->System->Link('/?action=logout').'">'.T('Logout').'</a>'.
|
---|
367 | ' <a href="'.$this->System->Link('/user/?user='.$this->System->User->Id).'">'.T('My page').'</a>'.
|
---|
368 | ' <a href="'.$this->System->Link('/options/').'">'.T('Options').'</a>'.
|
---|
369 | ' <a title="Vámi přeložené texty" href="'.$this->System->Link('/TranslationList.php?user='.
|
---|
370 | $this->System->User->Id.'&group=0&state=2&text=&entry=').'">'.T('Translated').'</a>'.
|
---|
371 | ' <a title="Vaše rozpracované text" href="'.$this->System->Link('/TranslationList.php?user='.
|
---|
372 | $this->System->User->Id.'&group=0&state=3&text=&entry=').'">'.T('Unfinished').'</a>'.
|
---|
373 | ' <a title="Nikým nepřeložené texty" href="'.
|
---|
374 | $this->System->Link('/TranslationList.php?user=0&group=0&state=1&text=&entry=').'">'.T('Untranslated').'</a>';
|
---|
375 | } else
|
---|
376 | {
|
---|
377 | $Output .= '<a href="'.$this->System->Link('/login/').'">'.T('Login').'</a> '.
|
---|
378 | '<a href="'.$this->System->Link('/registration/').'">'.T('Registration').'</a>';
|
---|
379 | }
|
---|
380 | $Output .= $this->ShowLocaleSelector();
|
---|
381 | //$Output .= '</form>';
|
---|
382 | $Output .= '</span></div>';
|
---|
383 | return($Output);
|
---|
384 | }
|
---|
385 |
|
---|
386 | function ShowLoginBox()
|
---|
387 | {
|
---|
388 | $Output = '';
|
---|
389 | if($this->System->User->Licence(LICENCE_USER))
|
---|
390 | {
|
---|
391 | // $Output .= 'Jste přihlášen jako: <b>'.$tUser->Id.'</b> <a href="index.php?Logout">Odhlásit</a>';
|
---|
392 | } else
|
---|
393 | {
|
---|
394 | $Output .= '<strong>'.T('Login').':</strong>
|
---|
395 | <form action="" method="post">
|
---|
396 | <table>
|
---|
397 | <tr>
|
---|
398 | <td><input type="text" name="LoginUser" size="13" /></td>
|
---|
399 | </tr>
|
---|
400 | <tr>
|
---|
401 | <td><input type="password" name="LoginPass" size="13" /></td>
|
---|
402 | </tr>
|
---|
403 | <tr>
|
---|
404 | <th><input type="submit" value="'.T('Do login').'" /></th>
|
---|
405 | </tr>
|
---|
406 | </table>
|
---|
407 | </form>';
|
---|
408 | }
|
---|
409 | return($Output);
|
---|
410 | }
|
---|
411 |
|
---|
412 | function ShowSearchBox()
|
---|
413 | {
|
---|
414 | $Output = '<strong>'.T('Search').':</strong>'.
|
---|
415 | '<form action="'.$this->System->Link('/search/').'" method="get"><div>'.
|
---|
416 | '<table>'.
|
---|
417 | '<tr>'.
|
---|
418 | '<td><input type="text" name="text" size="13" /></td>'.
|
---|
419 | '</tr>'.
|
---|
420 | '<tr>'.
|
---|
421 | '<th><input type="submit" value="'.T('Do search').'" /></th>'.
|
---|
422 | '</tr>'.
|
---|
423 | '</table></div>'.
|
---|
424 | '</form>';
|
---|
425 | return($Output);
|
---|
426 | }
|
---|
427 |
|
---|
428 | function ShowMainMenu()
|
---|
429 | {
|
---|
430 | $Output = '<strong>'.T('Menu').':</strong>'.
|
---|
431 | '<div class="verticalmenu"><ul>';
|
---|
432 | foreach($this->System->Menu as $MenuItem)
|
---|
433 | if($this->System->User->Licence($MenuItem['Permission']))
|
---|
434 | {
|
---|
435 | if(isset($MenuItem['Click'])) $OnClick = ' onclick="'.$MenuItem['Click'].'"';
|
---|
436 | else $OnClick = '';
|
---|
437 | if($MenuItem['Icon'] != '') $Icon = '<img src="'.$this->System->Link('/images/menu/'.$MenuItem['Icon']).'"/>';
|
---|
438 | else $Icon = '';
|
---|
439 | $Output .= '<li>'.$Icon.'<a class="verticalmenua" title="'.$MenuItem['Hint'].'" href="'.
|
---|
440 | $MenuItem['Link'].'"'.$OnClick.'>'.$MenuItem['Title'].'</a></li>';
|
---|
441 | }
|
---|
442 | $Output .= '</ul></div>';
|
---|
443 | return($Output);
|
---|
444 | }
|
---|
445 |
|
---|
446 | function ShowTranslatedMenu()
|
---|
447 | {
|
---|
448 | global $TranslationTree;
|
---|
449 |
|
---|
450 | $Output = '<strong>'.T('Translate groups').':</strong><br /><div id="TranslationMenu">';
|
---|
451 | $DbResult = $this->System->Database->select('Group', '`Id`, `Name`', '1 ORDER BY `Name`');
|
---|
452 | while($Group = $DbResult->fetch_assoc())
|
---|
453 | {
|
---|
454 | $Output .= '<div id="menuitem-group'.$Group['Id'].'" onmouseover="show(\'group'.$Group['Id'].'\')" onmouseout="hide(\'group'.$Group['Id'].'\')">'.
|
---|
455 | '<a href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].
|
---|
456 | '&action=filter').'">'.str_replace(' ',' ', T($Group['Name'])).'</a></div>'.
|
---|
457 | '<div id="group'.$Group['Id'].'" class="hidden-menu-item" onmouseover="show(\'group'.$Group['Id'].'\')" onmouseout="hide(\'group'.$Group['Id'].'\')">';
|
---|
458 | $Output .= ' <a title="Zde můžete začít překládat" href="'.
|
---|
459 | $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&state=1&user=0&entry=&text=').'">'.T('Untranslated').'</a><br />'.
|
---|
460 | ' <a title="Přeložené texty, můžete zde hlasovat, nebo opravovat překlady" href="'.
|
---|
461 | $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&state=2&user=0&entry=&text=').'">'.T('Translated').'</a><br />';
|
---|
462 | if($this->System->User->Licence(LICENCE_USER))
|
---|
463 | {
|
---|
464 | $Output .= ' <a title="'.T('Unfinished translations').'" href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&state=3').'">'.T('Unfinished').'</a><br />'.
|
---|
465 | ' <a title="Všechny překlady, které jste přeložil" href="'.
|
---|
466 | $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&state=1&user='.
|
---|
467 | $this->System->User->Id).'&entry=&text=">'.T('Own').'</a><br />';
|
---|
468 | }
|
---|
469 | $Output .= ' <a title="'.T('Compose special filter').'" href="'.
|
---|
470 | $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&action=filter').
|
---|
471 | '">'.T('Filter').'</a><br />';
|
---|
472 | $Output .= '</div>';
|
---|
473 | }
|
---|
474 | $Output .= '</div>';
|
---|
475 | return($Output);
|
---|
476 | }
|
---|
477 |
|
---|
478 | function ShowHeader()
|
---|
479 | {
|
---|
480 | $Output = ''.
|
---|
481 | '<!DOCTYPE html>'.
|
---|
482 | '<html>'.
|
---|
483 | '<head>'.
|
---|
484 | '<meta http-equiv="content-type" content="text/html; charset='.$this->System->Config['Web']['Charset'].'" />'.
|
---|
485 | '<meta name="keywords" content="'.$this->System->Config['Web']['Keywords'].'" />'.
|
---|
486 | '<meta name="description" content="'.$this->System->Config['Web']['Description'].'" />'.
|
---|
487 | '<meta name="robots" content="all" />'.
|
---|
488 | '<link rel="stylesheet" href="'.$this->System->Link('/style/style.css').'" type="text/css" media="all" />'.
|
---|
489 | '<script type="text/javascript" src="'.$this->System->Link('/style/global.js').'"></script>'.
|
---|
490 | '<link rel="shortcut icon" href="'.$this->System->Link('/images/favicon.ico').'" />';
|
---|
491 | $Output .= $this->System->ModuleManager->Modules['News']->ShowRSSHeader();
|
---|
492 | $Title = $this->System->Config['Web']['Title'];
|
---|
493 | if($this->Title != '') $Title = $this->Title.' - '.$Title;
|
---|
494 | $Output .= '<title>'.$Title.'</title>'.
|
---|
495 | '<script src="'.$this->System->Link('/style/respond.js').'"></script>'.
|
---|
496 | '</head><body>';
|
---|
497 |
|
---|
498 | $Output .= $this->ShowTopBar();
|
---|
499 | $Output .= '<table class="page"><tr><td class="menu">';
|
---|
500 | $Output .= $this->ShowMainMenu();
|
---|
501 | $Output .= $this->System->ModuleManager->Modules['User']->ShowOnlineList();
|
---|
502 | $Output .= '<br />';
|
---|
503 | $Output .= $this->ShowSearchBox();
|
---|
504 |
|
---|
505 | $Output .= '</td><td id="border-left"></td><td class="content">';
|
---|
506 | return($Output);
|
---|
507 | }
|
---|
508 |
|
---|
509 | function ShowFooter()
|
---|
510 | {
|
---|
511 | global $ScriptStartTime, $Revision, $ReleaseTime, $Version;
|
---|
512 |
|
---|
513 | $ScriptGenerateDuration = round(GetMicrotime() - $ScriptStartTime, 2);
|
---|
514 |
|
---|
515 | $Output = '</td>'.
|
---|
516 | '<td class="menu2">';
|
---|
517 | $Output .= $this->ShowTranslatedMenu();
|
---|
518 | $Output .= '</td>'.
|
---|
519 | '</tr><tr>'.
|
---|
520 | '<td colspan="4" class="page-bottom">'.T('Version').': '.$Version.' '.T('Revision').': '.$Revision.' ('.HumanDate($ReleaseTime).')'.
|
---|
521 | ' <a href="http://svn.zdechov.net/trac/wowpreklad/browser/trunk">'.T('Source code').'</a> '.
|
---|
522 | '<a href="http://svn.zdechov.net/trac/wowpreklad/log/trunk?verbose=on">'.T('Changelog').'</a> '.
|
---|
523 | $this->System->Config['Web']['WebCounter'];
|
---|
524 |
|
---|
525 | $Output .= '</td></tr>';
|
---|
526 | if($this->System->Config['Web']['ShowRuntimeInfo'] == true)
|
---|
527 | $Output .= '<tr><td colspan="3" style="text-align: center;">'.T('Generating duration').': '.
|
---|
528 | $ScriptGenerateDuration.' s / '.ini_get('max_execution_time').' s '.T('Used memory').': '.
|
---|
529 | HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B <a href="http://validator.w3.org/check?uri='.
|
---|
530 | htmlentities('http://'.$_SERVER['HTTP_HOST'].GetRequestURI().'?'.$_SERVER['QUERY_STRING']).'">HTML validator</a></td></tr>';
|
---|
531 | $Output .= '</table>'.
|
---|
532 | '</body>'.
|
---|
533 | '</html>';
|
---|
534 | return($Output);
|
---|
535 | }
|
---|
536 |
|
---|
537 | function ShowPage($Content)
|
---|
538 | {
|
---|
539 | $Output = $this->ShowHeader().$Content.$this->ShowFooter();
|
---|
540 | if($this->System->Config['Web']['FormatOutput'])
|
---|
541 | $Output = $this->FormatOutput($Output);
|
---|
542 | return($Output);
|
---|
543 | }
|
---|
544 |
|
---|
545 | function FormatOutput($s)
|
---|
546 | {
|
---|
547 | $out = '';
|
---|
548 | $nn = 0;
|
---|
549 | $n = 0;
|
---|
550 | while($s != '')
|
---|
551 | {
|
---|
552 | $start = strpos($s, '<');
|
---|
553 | $end = strpos($s, '>');
|
---|
554 | if($start != 0)
|
---|
555 | {
|
---|
556 | $end = $start - 1;
|
---|
557 | $start = 0;
|
---|
558 | }
|
---|
559 | $line = trim(substr($s, $start, $end + 1));
|
---|
560 | if(strlen($line) > 0)
|
---|
561 | if($line[0] == '<')
|
---|
562 | {
|
---|
563 | if($s[$start + 1] == '/')
|
---|
564 | {
|
---|
565 | $n = $n - 2;
|
---|
566 | $nn = $n;
|
---|
567 | } else
|
---|
568 | {
|
---|
569 | if(strpos($line, ' ')) $cmd = substr($line, 1, strpos($line, ' ') - 1);
|
---|
570 | else $cmd = substr($line, 1, strlen($line) - 2);
|
---|
571 | //echo('['.$cmd.']');
|
---|
572 | if(strpos($s, '</'.$cmd.'>')) $n = $n + 2;
|
---|
573 | }
|
---|
574 | }// else $line = '['.$line.']';
|
---|
575 | //if($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n"));
|
---|
576 | if($nn < 0) $nn = 0;
|
---|
577 | if($line != '') $out .= (str_repeat(' ', $nn).$line."\n");
|
---|
578 | $s = substr($s, $end + 1, strlen($s));
|
---|
579 | $nn = $n;
|
---|
580 | }
|
---|
581 | return($out);
|
---|
582 | }
|
---|
583 | }
|
---|