Skip to content

Commit f46dee6

Browse files
committed
GH-230 Move gift items infobox to its own component
1 parent c050b3c commit f46dee6

File tree

5 files changed

+66
-5
lines changed

5 files changed

+66
-5
lines changed

modules/overview/_includes.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
include($includePath . './screens/Overview/components/AccountActivationInfoBox/AccountActivationInfoBox.component.php');
2828
include($includePath . './screens/Overview/components/AdminAlerts/AdminAlerts.component.php');
2929
include($includePath . './screens/Overview/components/EmailChangeInfo/EmailChangeInfo.component.php');
30+
include($includePath . './screens/Overview/components/GiftItemsInfoBox/GiftItemsInfoBox.component.php');
3031
include($includePath . './screens/Overview/components/Morale/Morale.component.php');
3132
include($includePath . './screens/Overview/components/Morale/Morale.utils.php');
3233
include($includePath . './screens/Overview/components/NewMessagesInfo/NewMessagesInfo.component.php');
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
namespace UniEngine\Engine\Modules\Overview\Screens\Overview\Components\GiftItemsInfoBox;
4+
5+
/**
6+
* @param array $props
7+
* @param number $props['userId']
8+
*/
9+
function render($props) {
10+
global $_Lang;
11+
12+
$userId = $props['userId'];
13+
14+
$getGiftItemsDataQuery = (
15+
"SELECT " .
16+
"COUNT(`ID`) as `Count` " .
17+
"FROM {{table}} " .
18+
"WHERE " .
19+
"`UserID` = {$userId} AND " .
20+
"`Used` = false " .
21+
";"
22+
);
23+
$giftItemsData = doquery($getGiftItemsDataQuery, 'premium_free', true);
24+
25+
if ($giftItemsData['Count'] == 0) {
26+
return [
27+
'componentHTML' => '',
28+
];
29+
}
30+
31+
$localTemplateLoader = createLocalTemplateLoader(__DIR__);
32+
33+
$content = sprintf(
34+
$_Lang['FreePremItem_Text'],
35+
$giftItemsData['Count']
36+
);
37+
38+
$componentHTML = parsetemplate(
39+
$localTemplateLoader('body'),
40+
[
41+
'content' => $content,
42+
]
43+
);
44+
45+
return [
46+
'componentHTML' => $componentHTML,
47+
];
48+
}
49+
50+
?>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<tr>
2+
<th colspan="3">
3+
<a class="orange" href="galacticshop.php?show=free">
4+
{content}
5+
</a>
6+
</th>
7+
</tr>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
header("Location: ../index.php");
4+
5+
?>

overview.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,9 @@
9393
$parse['P_SFBInfobox'] = FlightControl\Components\SmartFleetBlockadeInfoBox\render()['componentHTML'];
9494

9595
// --- Free Premium Items Info Box -----------------------------------------------------------------------
96-
$GetFreeItems = doquery("SELECT COUNT(`ID`) as `Count` FROM {{table}} WHERE `UserID` = {$_User['id']} AND `Used` = false;", 'premium_free', true);
97-
if($GetFreeItems['Count'] > 0)
98-
{
99-
$parse['FreePremiumItemsBox'] = '<tr><th colspan="3"><a class="orange" href="galacticshop.php?show=free">'.sprintf($_Lang['FreePremItem_Text'], $GetFreeItems['Count']).'</a></th></tr>';
100-
}
96+
$parse['FreePremiumItemsBox'] = Overview\Screens\Overview\Components\GiftItemsInfoBox\render([
97+
'userId' => $_User['id'],
98+
])['componentHTML'];
10199

102100
// --- System Messages Box -------------------------------------------------------------------------------
103101
if(!empty($_GET['showmsg']))

0 commit comments

Comments
 (0)