1 | <?php
|
---|
2 |
|
---|
3 | class ModuleFrontPage extends Module
|
---|
4 | {
|
---|
5 | function __construct(System $System)
|
---|
6 | {
|
---|
7 | parent::__construct($System);
|
---|
8 | $this->Name = 'FrontPage';
|
---|
9 | $this->Version = '1.0';
|
---|
10 | $this->Creator = 'Chronos';
|
---|
11 | $this->License = 'GNU/GPL';
|
---|
12 | $this->Description = 'Main welcome page';
|
---|
13 | $this->Dependencies = array('News', 'User', 'ShoutBox', 'Translation', 'Log',
|
---|
14 | 'Forum');
|
---|
15 | }
|
---|
16 |
|
---|
17 | function DoStart(): void
|
---|
18 | {
|
---|
19 | $this->System->RegisterPage([''], 'PageFrontPage');
|
---|
20 | Core::Cast($this->System)->RegisterMenuItem(array(
|
---|
21 | 'Title' => T('Home'),
|
---|
22 | 'Hint' => T('Main page'),
|
---|
23 | 'Link' => $this->System->Link('/'),
|
---|
24 | 'Permission' => LICENCE_ANONYMOUS,
|
---|
25 | 'Icon' => '',
|
---|
26 | ), 0);
|
---|
27 | }
|
---|
28 |
|
---|
29 | function HandleLoginForm()
|
---|
30 | {
|
---|
31 | $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
|
---|
32 | global $Message, $MessageType;
|
---|
33 |
|
---|
34 | if (array_key_exists('action', $_GET))
|
---|
35 | {
|
---|
36 | if ($_GET['action'] == 'login')
|
---|
37 | {
|
---|
38 | if (array_key_exists('LoginUser', $_POST) and array_key_exists('LoginPass', $_POST))
|
---|
39 | {
|
---|
40 | if (array_key_exists('StayLogged', $_POST)) $StayLogged = true;
|
---|
41 | else $StayLogged = false;
|
---|
42 | $User->Login($_POST['LoginUser'], $_POST['LoginPass'], $StayLogged);
|
---|
43 | if ($User->Role == LICENCE_ANONYMOUS)
|
---|
44 | {
|
---|
45 | $Message = T('Incorrect name or password');
|
---|
46 | $MessageType = MESSAGE_CRITICAL;
|
---|
47 | } else
|
---|
48 | {
|
---|
49 | $Message = sprintf(T('Login successful. Welcome <strong>%s</strong>!'), $User->Name);
|
---|
50 | $MessageType = MESSAGE_INFORMATION;
|
---|
51 | }
|
---|
52 | } else
|
---|
53 | {
|
---|
54 | $Message = T('User name or password was not entered');
|
---|
55 | $MessageType = MESSAGE_CRITICAL;
|
---|
56 | }
|
---|
57 | } else
|
---|
58 | if ($_GET['action'] == 'logout')
|
---|
59 | {
|
---|
60 | if ($User->Role != LICENCE_ANONYMOUS)
|
---|
61 | {
|
---|
62 | ModuleLog::Cast($this->System->GetModule('Log'))->WriteLog('Odhlášení', LOG_TYPE_USER);
|
---|
63 | $User->Logout();
|
---|
64 | $Message = T('You were logged out');
|
---|
65 | $MessageType = MESSAGE_INFORMATION;
|
---|
66 | }
|
---|
67 | }
|
---|
68 | }
|
---|
69 | }
|
---|
70 | }
|
---|
71 |
|
---|
72 | class PageFrontPage extends Page
|
---|
73 | {
|
---|
74 | function Show(): string
|
---|
75 | {
|
---|
76 | global $Message, $MessageType;
|
---|
77 |
|
---|
78 | $this->Title = T('Home');
|
---|
79 | $this->System->ModuleManager->Modules['FrontPage']->HandleLoginForm();
|
---|
80 | $Output = '';
|
---|
81 | if (isset($Message)) $Output .= ShowMessage($Message, $MessageType);
|
---|
82 |
|
---|
83 | $Output .= ''.
|
---|
84 | '<div class="Home">'.$this->ShowWelcome().
|
---|
85 | '</div>';
|
---|
86 | $Output .= '<div><h3><a href="'.$this->System->Link('/download/').'">'.T('Download files').'</a></h3></div>';
|
---|
87 |
|
---|
88 | $Output .=
|
---|
89 | '<div class="box-left">'.$this->System->ModuleManager->Modules['News']->ShowBox().'</div>'.
|
---|
90 | '<div class="box-right">'.$this->System->ModuleManager->Modules['ShoutBox']->ShowBox().'</div>'.
|
---|
91 | '<div class="box-left">'.$this->System->ModuleManager->Modules['Forum']->ShowBox().'</div>'.
|
---|
92 | '<div class="box-right">'.$this->System->ModuleManager->Modules['Translation']->ShowBox().'</div>';
|
---|
93 | return $Output;
|
---|
94 | }
|
---|
95 |
|
---|
96 | function ShowWelcome()
|
---|
97 | {
|
---|
98 | // Cookies have to be used before any text is sent to output
|
---|
99 | if (!array_key_exists('HideWelcome', $_COOKIE)) $_COOKIE['HideWelcome'] = 0;
|
---|
100 | if (isset($_GET['Action']))
|
---|
101 | {
|
---|
102 | if ($_GET['Action'] == 'HideWelcome')
|
---|
103 | {
|
---|
104 | $_COOKIE['HideWelcome'] = 1;
|
---|
105 | setcookie('HideWelcome', $_COOKIE['HideWelcome'], time() + 3600 * 24 * 365);
|
---|
106 | }
|
---|
107 | if ($_GET['Action'] == 'UnHideWelcome')
|
---|
108 | {
|
---|
109 | $_COOKIE['HideWelcome'] = 0;
|
---|
110 | setcookie('HideWelcome', $_COOKIE['HideWelcome'], time() + 3600 * 24 * 365);
|
---|
111 | }
|
---|
112 | }
|
---|
113 |
|
---|
114 | if (isset($_COOKIE['HideWelcome']) and ($_COOKIE['HideWelcome'] == 1))
|
---|
115 | {
|
---|
116 | $Action = '<a href="?Action=UnHideWelcome">'.T('Show welcome').'</a>';
|
---|
117 | $HideWelcome = 'display: none';
|
---|
118 | } else
|
---|
119 | {
|
---|
120 | $Action = '<a href="?Action=HideWelcome">'.T('Hide welcome').'</a>';
|
---|
121 | $HideWelcome = '';
|
---|
122 | }
|
---|
123 |
|
---|
124 | // Echo text even if it is hidden because of caching by external searching engines
|
---|
125 | return '<div style="'.$HideWelcome.'">'.
|
---|
126 | '<div id="bannertitle">'.Core::Cast($this->System)->Config['Web']['Title'].'</div>'.
|
---|
127 | T('Open web system for translation texts from game World of Warcraft (WoW).<br/>'.
|
---|
128 | '<ul>'.
|
---|
129 | '<li>The project is operated as open and professes princips of freedom and openness. That is why texts are free to download.</li>'.
|
---|
130 | '<li>The project serve for team translation. Anybody can contribute by translating texts and made link public e.g. banner at own web.</li>'.
|
---|
131 | '<li>The project is not focused only to one server but allows collectively translation to people from various servers. Translators can translate in teams by name of own server and export texts only from selected translators.</li>'.
|
---|
132 | '<li>Translated texts can be freely downloaded in various forms like XML, SQL, Addon and Lua. So translated texts can be simply imported to own free server or used in other projects.</li>'.
|
---|
133 | '<li>Aim of the project is to translate all game texts. Not just texts of quests.</li>'.
|
---|
134 | '<li>Thanks for sophisticated system of selectable exports you can download any part of translation, even just quests. And so exclude translation of items, creatures and others.</li>'.
|
---|
135 | '<li>Texts can be translated to multiple languages, e.g. Czech and Slovak.</li>'.
|
---|
136 | '</ul>').'</div>'.$Action;
|
---|
137 | }
|
---|
138 | }
|
---|