-
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.
Browse files
Browse the repository at this point in the history
GH-230 | Overview - Various components refactor (part 1)
- Loading branch information
Showing
39 changed files
with
854 additions
and
186 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
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
30 changes: 30 additions & 0 deletions
30
...reens/Overview/components/AccountActivationInfoBox/AccountActivationInfoBox.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,30 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\Overview\Screens\Overview\Components\AccountActivationInfoBox; | ||
|
||
/** | ||
* @param array $props | ||
* @param arrayRef $props['user'] | ||
*/ | ||
function render($props) { | ||
global $_Lang; | ||
|
||
if (isUserAccountActivated($props['user'])) { | ||
return [ | ||
'componentHTML' => '', | ||
]; | ||
} | ||
|
||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
|
||
$componentHTML = parsetemplate( | ||
$localTemplateLoader('body'), | ||
$_Lang | ||
); | ||
|
||
return [ | ||
'componentHTML' => $componentHTML, | ||
]; | ||
} | ||
|
||
?> |
8 changes: 8 additions & 0 deletions
8
modules/overview/screens/Overview/components/AccountActivationInfoBox/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,8 @@ | ||
<tr> | ||
<th class="c pad5 orange" colspan="3"> | ||
{ActivationInfo_Text} | ||
</th> | ||
</tr> | ||
<tr> | ||
<th style="visibility: hidden;"> </th> | ||
</tr> |
5 changes: 5 additions & 0 deletions
5
modules/overview/screens/Overview/components/AccountActivationInfoBox/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"); | ||
|
||
?> |
118 changes: 118 additions & 0 deletions
118
modules/overview/screens/Overview/components/CombatStatsList/CombatStatsList.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,118 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\Overview\Screens\Overview\Components\CombatStatsList; | ||
|
||
use UniEngine\Engine\Modules\Overview\Screens\Overview\Components\CombatStatsList; | ||
|
||
/** | ||
* @param array $props | ||
* @param number $props['userId'] | ||
*/ | ||
function render($props) { | ||
global $_Lang; | ||
|
||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
$tplBodyCache = [ | ||
'body' => $localTemplateLoader('body'), | ||
'statCategoryRow' => $localTemplateLoader('statCategoryRow'), | ||
]; | ||
|
||
$statsData = CombatStatsList\Utils\getUserCombatStats([ | ||
'userId' => $props['userId'], | ||
]); | ||
|
||
$categories = [ | ||
'allBattles' => [ | ||
'label' => $_Lang['Box_battlesAll'], | ||
'statsTableKeys' => [ | ||
'ustat_raids_won', | ||
'ustat_raids_draw', | ||
'ustat_raids_lost', | ||
'ustat_raids_inAlly', | ||
], | ||
], | ||
'battlesWon' => [ | ||
'label' => $_Lang['Box_battlesWon'], | ||
'statsTableKeys' => [ | ||
'ustat_raids_won', | ||
], | ||
], | ||
'battlesWonUnited' => [ | ||
'label' => $_Lang['Box_battlesACSWon'], | ||
'statsTableKeys' => [ | ||
'ustat_raids_acs_won', | ||
], | ||
'colorClass' => 'orange', | ||
], | ||
'battlesDrawn' => [ | ||
'label' => $_Lang['Box_battlesDraw'], | ||
'statsTableKeys' => [ | ||
'ustat_raids_draw', | ||
], | ||
], | ||
'battlesLost' => [ | ||
'label' => $_Lang['Box_battlesLost'], | ||
'statsTableKeys' => [ | ||
'ustat_raids_lost', | ||
], | ||
], | ||
'battlesInAlly' => [ | ||
'label' => $_Lang['Box_battlesInAlly'], | ||
'statsTableKeys' => [ | ||
'ustat_raids_inAlly', | ||
], | ||
], | ||
'missileStrikes' => [ | ||
'label' => $_Lang['Box_missileAttacks'], | ||
'statsTableKeys' => [ | ||
'ustat_raids_missileAttack', | ||
], | ||
], | ||
]; | ||
|
||
$categoriesHTML = []; | ||
|
||
foreach ($categories as $categoryKey => $category) { | ||
$categorySubValues = array_map_withkeys($category['statsTableKeys'], function ($key) use ($statsData) { | ||
return $statsData[$key]; | ||
}); | ||
$categoryTotalValue = array_sum($categorySubValues); | ||
|
||
$categoryTplBodyParams = [ | ||
'statCategoryColorClass' => ( | ||
!empty($category['colorClass']) ? | ||
$category['colorClass'] : | ||
'' | ||
), | ||
'statCategoryLabel' => $category['label'], | ||
'statCategoryValue' => prettyNumber($categoryTotalValue), | ||
]; | ||
|
||
$categoriesHTML[$categoryKey] = parsetemplate( | ||
$tplBodyCache['statCategoryRow'], | ||
$categoryTplBodyParams | ||
); | ||
} | ||
|
||
$tplBodyParams = [ | ||
'categoryRow_allBattles' => $categoriesHTML['allBattles'], | ||
'categoryRow_battlesWon' => $categoriesHTML['battlesWon'], | ||
'categoryRow_battlesWonUnited' => $categoriesHTML['battlesWonUnited'], | ||
'categoryRow_battlesDrawn' => $categoriesHTML['battlesDrawn'], | ||
'categoryRow_battlesLost' => $categoriesHTML['battlesLost'], | ||
'categoryRow_battlesInAlly' => $categoriesHTML['battlesInAlly'], | ||
'categoryRow_missileStrikes' => $categoriesHTML['missileStrikes'], | ||
]; | ||
$tplBodyParams = array_merge($_Lang, $tplBodyParams); | ||
|
||
$componentHTML = parsetemplate( | ||
$tplBodyCache['body'], | ||
$tplBodyParams | ||
); | ||
|
||
return [ | ||
'componentHTML' => $componentHTML, | ||
]; | ||
} | ||
|
||
?> |
30 changes: 30 additions & 0 deletions
30
modules/overview/screens/Overview/components/CombatStatsList/CombatStatsList.utils.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,30 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\Overview\Screens\Overview\Components\CombatStatsList\Utils; | ||
|
||
/** | ||
* @param array $props | ||
* @param array $props['userId'] | ||
*/ | ||
function getUserCombatStats($props) { | ||
$userId = $props['userId']; | ||
|
||
$query = ( | ||
"SELECT " . | ||
"`ustat_raids_won`, " . | ||
"`ustat_raids_draw`, " . | ||
"`ustat_raids_lost`, " . | ||
"`ustat_raids_acs_won`, " . | ||
"`ustat_raids_inAlly`, " . | ||
"`ustat_raids_missileAttack` " . | ||
"FROM {{table}} " . | ||
"WHERE " . | ||
"`A_UserID` = {$userId} " . | ||
"LIMIT 1 " . | ||
";" | ||
); | ||
|
||
return doquery($query, 'achievements_stats', true); | ||
} | ||
|
||
?> |
18 changes: 18 additions & 0 deletions
18
modules/overview/screens/Overview/components/CombatStatsList/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,18 @@ | ||
<table width="100%" align="center"> | ||
<tr> | ||
<td colspan="2" class="c pad3">{YourBattles}</td> | ||
</tr> | ||
{categoryRow_allBattles} | ||
<tr> | ||
<th class="invNF"> </th> | ||
</tr> | ||
{categoryRow_battlesWon} | ||
{categoryRow_battlesWonUnited} | ||
{categoryRow_battlesDrawn} | ||
{categoryRow_battlesLost} | ||
{categoryRow_battlesInAlly} | ||
<tr> | ||
<th class="invNF"> </th> | ||
</tr> | ||
{categoryRow_missileStrikes} | ||
</table> |
5 changes: 5 additions & 0 deletions
5
modules/overview/screens/Overview/components/CombatStatsList/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"); | ||
|
||
?> |
4 changes: 4 additions & 0 deletions
4
modules/overview/screens/Overview/components/CombatStatsList/statCategoryRow.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,4 @@ | ||
<tr> | ||
<th class="{statCategoryColorClass}">{statCategoryLabel}</th> | ||
<th>{statCategoryValue}</th> | ||
</tr> |
39 changes: 39 additions & 0 deletions
39
...screens/Overview/components/FeedbackMessagesDisplay/FeedbackMessagesDisplay.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,39 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\Overview\Screens\Overview\Components\FeedbackMessagesDisplay; | ||
|
||
use UniEngine\Engine\Modules\Overview\Screens\Overview\Components\FeedbackMessagesDisplay; | ||
|
||
/** | ||
* @param array $props | ||
* @param arrayRef $props['input'] | ||
*/ | ||
function render($props) { | ||
$messages = FeedbackMessagesDisplay\Utils\getMessagesToDisplay($props); | ||
|
||
if (empty($messages)) { | ||
return [ | ||
'componentHTML' => '', | ||
]; | ||
} | ||
|
||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
$tplBodyCache = [ | ||
'messageRow' => $localTemplateLoader('messageRow'), | ||
]; | ||
|
||
$parsedMessages = array_map_withkeys($messages, function ($message) use (&$tplBodyCache) { | ||
return parsetemplate( | ||
$tplBodyCache['messageRow'], | ||
$message | ||
); | ||
}); | ||
|
||
$componentHTML = implode('', $parsedMessages); | ||
|
||
return [ | ||
'componentHTML' => $componentHTML, | ||
]; | ||
} | ||
|
||
?> |
29 changes: 29 additions & 0 deletions
29
...iew/screens/Overview/components/FeedbackMessagesDisplay/FeedbackMessagesDisplay.utils.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,29 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\Overview\Screens\Overview\Components\FeedbackMessagesDisplay\Utils; | ||
|
||
/** | ||
* @param array $props | ||
* @param arrayRef $props['input'] | ||
*/ | ||
function getMessagesToDisplay($props) { | ||
global $_Lang; | ||
|
||
$input = &$props['input']; | ||
|
||
$messages = []; | ||
|
||
if ( | ||
!empty($input['showmsg']) && | ||
$input['showmsg'] == 'abandon' | ||
) { | ||
$messages[] = [ | ||
'messageContent' => $_Lang['Abandon_ColonyAbandoned'], | ||
'colorClass' => 'lime', | ||
]; | ||
} | ||
|
||
return $messages; | ||
} | ||
|
||
?> |
5 changes: 5 additions & 0 deletions
5
modules/overview/screens/Overview/components/FeedbackMessagesDisplay/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"); | ||
|
||
?> |
5 changes: 5 additions & 0 deletions
5
modules/overview/screens/Overview/components/FeedbackMessagesDisplay/messageRow.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,5 @@ | ||
<tr> | ||
<th colspan="3" class="pad5 {colorClass}"> | ||
{messageContent} | ||
</th> | ||
</tr> |
Oops, something went wrong.