-
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-224 Move login entries history rendering entirely to a component
- Loading branch information
Showing
5 changed files
with
72 additions
and
28 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
55 changes: 55 additions & 0 deletions
55
modules/settings/components/LoginHistory/LoginHistory.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,55 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\Settings\Components\LoginHistory; | ||
|
||
use UniEngine\Engine\Includes\Helpers\Common; | ||
use UniEngine\Engine\Modules\Settings; | ||
|
||
/** | ||
* @param object $props | ||
* @param array $props['loginHistoryEntries'] | ||
* @param number $props['displayItemsCount'] | ||
* @param string $props['currentUserLastIp'] | ||
* @param number $props['currentTimestamp'] | ||
* | ||
* @return object $result | ||
* @return string $result['componentHTML'] | ||
*/ | ||
function render($props) { | ||
global $_Lang; | ||
|
||
$loginHistoryEntries = $props['loginHistoryEntries']; | ||
$displayItemsCount = $props['displayItemsCount']; | ||
$currentUserLastIp = $props['currentUserLastIp']; | ||
$currentTimestamp = $props['currentTimestamp']; | ||
|
||
if (empty($loginHistoryEntries)) { | ||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
$componentHTML = parsetemplate($localTemplateLoader('emptyList'), $_Lang); | ||
|
||
return [ | ||
'componentHTML' => $componentHTML | ||
]; | ||
} | ||
|
||
$limitedLoginHistoryEntries = Common\Collections\firstN($loginHistoryEntries, $displayItemsCount); | ||
|
||
$listElements = array_map_withkeys( | ||
$limitedLoginHistoryEntries, | ||
function ($loginEntry) use ($currentUserLastIp, $currentTimestamp) { | ||
return Settings\Components\LoginHistoryEntry\render([ | ||
'entryData' => $loginEntry, | ||
'userLastIp' => $currentUserLastIp, | ||
'currentTimestamp' => $currentTimestamp, | ||
])['componentHTML']; | ||
} | ||
); | ||
|
||
$componentHTML = implode('', $listElements); | ||
|
||
return [ | ||
'componentHTML' => $componentHTML | ||
]; | ||
} | ||
|
||
?> |
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 @@ | ||
<tr><th colspan="4">{Logons_ListEmpty}</th></tr> |
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