Name = 'FrontPage';
$this->Version = '1.0';
$this->Creator = 'Chronos';
$this->License = 'GNU/GPL';
$this->Description = 'Main welcome page';
$this->Dependencies = array('News', 'User', 'ShoutBox', 'Translation', 'Log',
'Forum');
}
function DoStart(): void
{
$this->System->RegisterPage([''], 'PageFrontPage');
Core::Cast($this->System)->RegisterMenuItem(array(
'Title' => T('Home'),
'Hint' => T('Main page'),
'Link' => $this->System->Link('/'),
'Permission' => LICENCE_ANONYMOUS,
'Icon' => '',
), 0);
}
function HandleLoginForm()
{
$User = ModuleUser::Cast($this->System->GetModule('User'))->User;
global $Message, $MessageType;
if (array_key_exists('action', $_GET))
{
if ($_GET['action'] == 'login')
{
if (array_key_exists('LoginUser', $_POST) and array_key_exists('LoginPass', $_POST))
{
if (array_key_exists('StayLogged', $_POST)) $StayLogged = true;
else $StayLogged = false;
$User->Login($_POST['LoginUser'], $_POST['LoginPass'], $StayLogged);
if ($User->Role == LICENCE_ANONYMOUS)
{
$Message = T('Incorrect name or password');
$MessageType = MESSAGE_CRITICAL;
} else
{
$Message = sprintf(T('Login successful. Welcome %s!'), $User->Name);
$MessageType = MESSAGE_INFORMATION;
}
} else
{
$Message = T('User name or password was not entered');
$MessageType = MESSAGE_CRITICAL;
}
} else
if ($_GET['action'] == 'logout')
{
if ($User->Role != LICENCE_ANONYMOUS)
{
ModuleLog::Cast($this->System->GetModule('Log'))->WriteLog('Odhlášení', LOG_TYPE_USER);
$User->Logout();
$Message = T('You were logged out');
$MessageType = MESSAGE_INFORMATION;
}
}
}
}
}
class PageFrontPage extends Page
{
function Show(): string
{
global $Message, $MessageType;
$this->Title = T('Home');
$this->System->ModuleManager->Modules['FrontPage']->HandleLoginForm();
$Output = '';
if (isset($Message)) $Output .= ShowMessage($Message, $MessageType);
$Output .= ''.
'
'.$this->ShowWelcome().
'
';
$Output .= '';
$Output .=
''.$this->System->ModuleManager->Modules['News']->ShowBox().'
'.
''.$this->System->ModuleManager->Modules['ShoutBox']->ShowBox().'
'.
''.$this->System->ModuleManager->Modules['Forum']->ShowBox().'
'.
''.$this->System->ModuleManager->Modules['Translation']->ShowBox().'
';
return $Output;
}
function ShowWelcome()
{
// Cookies have to be used before any text is sent to output
if (!array_key_exists('HideWelcome', $_COOKIE)) $_COOKIE['HideWelcome'] = 0;
if (isset($_GET['Action']))
{
if ($_GET['Action'] == 'HideWelcome')
{
$_COOKIE['HideWelcome'] = 1;
setcookie('HideWelcome', $_COOKIE['HideWelcome'], time() + 3600 * 24 * 365);
}
if ($_GET['Action'] == 'UnHideWelcome')
{
$_COOKIE['HideWelcome'] = 0;
setcookie('HideWelcome', $_COOKIE['HideWelcome'], time() + 3600 * 24 * 365);
}
}
if (isset($_COOKIE['HideWelcome']) and ($_COOKIE['HideWelcome'] == 1))
{
$Action = ''.T('Show welcome').'';
$HideWelcome = 'display: none';
} else
{
$Action = ''.T('Hide welcome').'';
$HideWelcome = '';
}
// Echo text even if it is hidden because of caching by external searching engines
return ''.
'
'.Core::Cast($this->System)->Config['Web']['Title'].'
'.
T('Open web system for translation texts from game World of Warcraft (WoW).
'.
'
'.
'- The project is operated as open and professes princips of freedom and openness. That is why texts are free to download.
'.
'- The project serve for team translation. Anybody can contribute by translating texts and made link public e.g. banner at own web.
'.
'- 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.
'.
'- 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.
'.
'- Aim of the project is to translate all game texts. Not just texts of quests.
'.
'- 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.
'.
'- Texts can be translated to multiple languages, e.g. Czech and Slovak.
'.
'
').'
'.$Action;
}
}