-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-150 Move login page's display logic to a separate module
- Loading branch information
Showing
10 changed files
with
184 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
// TODO: Migrate to IIFE once PHP 5 support is removed | ||
call_user_func(function () { | ||
global $_EnginePath; | ||
|
||
$includePath = $_EnginePath . 'modules/session/'; | ||
|
||
include($includePath . './screens/LoginView/LoginView.component.php'); | ||
include($includePath . './screens/LoginView/components/LoginForm/LoginForm.component.php'); | ||
|
||
}); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
header("Location: ../index.php"); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\Session\Screens\LoginView; | ||
|
||
// Arguments | ||
// - $props (Object) | ||
// | ||
// Returns: Object | ||
// - componentHTML (String) | ||
// | ||
function render ($props) { | ||
includeLang('login'); | ||
|
||
// Handle user input | ||
// $cmdResult = Session\Input\UserCommands\handleCommands( | ||
// $input, | ||
// [] | ||
// ); | ||
// if ($cmdResult['isSuccess']) { | ||
// // TODO: do something | ||
// } else { | ||
// // TODO: collect errors to display | ||
// } | ||
|
||
$viewProps = []; | ||
$viewComponent = Components\LoginForm\render($viewProps); | ||
|
||
return [ | ||
'componentHTML' => $viewComponent['componentHTML'], | ||
]; | ||
} | ||
|
||
?> |
68 changes: 68 additions & 0 deletions
68
modules/session/screens/LoginView/components/LoginForm/LoginForm.component.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\Session\Screens\LoginView\Components\LoginForm; | ||
|
||
// Arguments | ||
// - $props (Object) | ||
// | ||
// Returns: Object | ||
// - componentHTML (String) | ||
// | ||
function render ($props) { | ||
global $_Lang, $_GameConfig; | ||
|
||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
|
||
$tplBodyCache = [ | ||
'pageBody' => $localTemplateLoader('form_body'), | ||
]; | ||
|
||
$renderLangSelectorOptions = function () use ($_Lang) { | ||
$options = []; | ||
|
||
foreach (UNIENGINE_LANGS_AVAILABLE as $langKey) { | ||
$langData = $_Lang['LanguagesAvailable'][$langKey]; | ||
|
||
$options[] = ( | ||
"<a href='?lang={$langKey}' title='{$langData['name']}'>" . | ||
"{$langData['flag_emoji']}" . | ||
"</a>" | ||
); | ||
} | ||
|
||
return implode(' ', $options); | ||
}; | ||
|
||
$isGameDisabled = $_GameConfig['game_disable']; | ||
$gameDisabledReason = $_GameConfig['close_reason']; | ||
|
||
$additionalTplData = [ | ||
'PHP_InsertUniCode' => LOGINPAGE_UNIVERSUMCODE, | ||
'PHP_Insert_LangSelectors' => $renderLangSelectorOptions(), | ||
|
||
'type' => ( | ||
$isGameDisabled ? | ||
'button" onclick="alert(\'' . str_replace('<br/>', "\n", $gameDisabledReason) . '\')' : | ||
'submit' | ||
), | ||
'LoginButton' => ( | ||
$isGameDisabled ? | ||
$_Lang['Body_ServerOffline'] : | ||
$_Lang['Body_Submit'] | ||
), | ||
]; | ||
|
||
$componentHTML = parsetemplate( | ||
$tplBodyCache['pageBody'], | ||
array_merge( | ||
$_Lang, | ||
$additionalTplData | ||
) | ||
); | ||
|
||
return [ | ||
'componentHTML' => $componentHTML | ||
]; | ||
} | ||
|
||
?> |
40 changes: 40 additions & 0 deletions
40
modules/session/screens/LoginView/components/LoginForm/form_body.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<form action="" method="post"> | ||
<input type="hidden" name="uniSelect" value="{PHP_InsertUniCode}"/> | ||
<table width="500" style="margin-top: 100px;"> | ||
<tr> | ||
<td class="c center" colspan="2">{Page_Title}</td> | ||
</tr> | ||
<tr> | ||
<th class="pad5" style="width: 200px;"><label for="uname">{Body_Username}:</label></th> | ||
<th class="pad5"><input id="uname" name="username" value="" type="text" class="pad5" style="width: 200px;"/></th> | ||
</tr> | ||
<tr> | ||
<th class="pad5" style="width: 200px;"><label for="upass">{Body_Password}:</label></th> | ||
<th class="pad5"><input id="upass" name="password" value="" type="password" class="pad5" style="width: 200px;"/></th> | ||
</tr> | ||
<tr> | ||
<th colspan="2" class="pad5"><input type="{type}" name="submit" value="{LoginButton}" style="width: 100%; font-weight: bold;" class="pad5 lime"/></th> | ||
</tr> | ||
<tr style="visibility: hidden;"><td style="font-size: 5px;"> </td></tr> | ||
<tr> | ||
<th colspan="2" class="pad5"><a href="lostpassword.php">{Body_LostPass}</a><br /><a href="lostcode.php">{Body_LostCode}</a></th> | ||
</tr> | ||
<tr> | ||
<th colspan="2" class="pad5"> | ||
<a href="reg_mainpage.php">{Body_Register}</a> | <a href="contact.php">{Body_Contact}</a> | ||
</th> | ||
</tr> | ||
<tr style="visibility: hidden;"><td style="font-size: 5px;"> </td></tr> | ||
<tr> | ||
<th colspan="2" class="pad5"> | ||
{PHP_Insert_LangSelectors} | ||
</th> | ||
</tr> | ||
<tr style="visibility: hidden;"><td style="font-size: 5px;"> </td></tr> | ||
<tr> | ||
<th colspan="2" class="pad5"> | ||
<a href="https://github.com/mdziekon/UniEngine" target="_blank" class="skyblue">Powered by UniEngine</a> | ||
</th> | ||
</tr> | ||
</table> | ||
</form> |
5 changes: 5 additions & 0 deletions
5
modules/session/screens/LoginView/components/LoginForm/index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
header("Location: ../index.php"); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
header("Location: ../index.php"); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
header("Location: ../index.php"); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
header("Location: ../index.php"); | ||
|
||
?> |