-
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 fleet mission colors form to a component
- Loading branch information
Showing
5 changed files
with
70 additions
and
20 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
57 changes: 57 additions & 0 deletions
57
modules/settings/components/FleetMissionColorsForm/FleetMissionColorsForm.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,57 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\Settings\Components\FleetMissionColorsForm; | ||
|
||
/** | ||
* @param object $props | ||
* @param number $props['missionsColorSettings'] | ||
* | ||
* @return object $result | ||
* @return string $result['componentHTML'] | ||
*/ | ||
function render($props) { | ||
global $_Lang, $_Vars_FleetMissions; | ||
|
||
$missionsColorSettings = ( | ||
!empty($props['missionsColorSettings']) ? | ||
json_decode($props['missionsColorSettings'], true) : | ||
[] | ||
); | ||
|
||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
|
||
$tplBodyCache = [ | ||
'missionRow' => $localTemplateLoader('missionRow'), | ||
]; | ||
|
||
$getMissionColor = function ($missionId, $flightType) use ($missionsColorSettings) { | ||
return ( | ||
isset($missionsColorSettings[$flightType][$missionId]) ? | ||
$missionsColorSettings[$flightType][$missionId] : | ||
null | ||
); | ||
}; | ||
|
||
$missionRows = array_map_withkeys( | ||
$_Vars_FleetMissions['all'], | ||
function ($missionId) use (&$tplBodyCache, &$_Lang, $getMissionColor) { | ||
$tplParams = [ | ||
'MissionName' => $_Lang['type_mission'][$missionId], | ||
'MissionID' => $missionId, | ||
'Value_OwnFly' => $getMissionColor($missionId, 'ownfly'), | ||
'Value_OwnComeback' => $getMissionColor($missionId, 'owncb'), | ||
'Value_NonOwn' => $getMissionColor($missionId, 'nonown'), | ||
]; | ||
|
||
return parsetemplate($tplBodyCache['missionRow'], $tplParams); | ||
} | ||
); | ||
|
||
$componentHTML = implode('', $missionRows); | ||
|
||
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,5 @@ | ||
<?php | ||
|
||
header("Location: ../index.php"); | ||
|
||
?> |
File renamed without changes.
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