|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace UniEngine\Engine\Modules\Overview\Screens\Overview\Components\NoobProtectionInfoBox; |
| 4 | + |
| 5 | +use UniEngine\Engine\Modules\Overview\Screens\Overview\Components\NoobProtectionInfoBox; |
| 6 | + |
| 7 | +/** |
| 8 | + * @param array $params |
| 9 | + * @param arrayRef $params['input'] |
| 10 | + * @param arrayRef $params['user'] |
| 11 | + * @param number $params['currentTimestamp'] |
| 12 | + */ |
| 13 | +function render($props) { |
| 14 | + global $_Lang; |
| 15 | + |
| 16 | + $input = &$props['input']; |
| 17 | + $user = &$props['user']; |
| 18 | + $currentTimestamp = $props['currentTimestamp']; |
| 19 | + |
| 20 | + $isProtectedByNoobProtection = NoobProtectionInfoBox\Utils\isProtectedByNoobProtection([ |
| 21 | + 'user' => &$user, |
| 22 | + 'currentTimestamp' => $currentTimestamp, |
| 23 | + ]); |
| 24 | + |
| 25 | + if (!$isProtectedByNoobProtection) { |
| 26 | + return [ |
| 27 | + 'componentHTML' => '', |
| 28 | + 'globalJS' => '', |
| 29 | + ]; |
| 30 | + } |
| 31 | + |
| 32 | + $effectsResult = NoobProtectionInfoBox\runEffects([ |
| 33 | + 'input' => &$input, |
| 34 | + 'user' => &$user, |
| 35 | + 'currentTimestamp' => $currentTimestamp, |
| 36 | + ]); |
| 37 | + |
| 38 | + $localTemplateLoader = createLocalTemplateLoader(__DIR__); |
| 39 | + |
| 40 | + if ( |
| 41 | + $effectsResult['isSuccess'] && |
| 42 | + $effectsResult['payload']['protectionTurnedOff'] |
| 43 | + ) { |
| 44 | + $componentHTML = parsetemplate( |
| 45 | + $localTemplateLoader('turnOffMessage'), |
| 46 | + $_Lang |
| 47 | + ); |
| 48 | + |
| 49 | + return [ |
| 50 | + 'componentHTML' => $componentHTML, |
| 51 | + 'globalJS' => '', |
| 52 | + ]; |
| 53 | + } |
| 54 | + |
| 55 | + $protectionTimeLeft = $user['NoobProtection_EndTime'] - $currentTimestamp; |
| 56 | + |
| 57 | + $componentHTML = parsetemplate( |
| 58 | + $localTemplateLoader('body'), |
| 59 | + [ |
| 60 | + 'data_ProtectionCounterMessage' => sprintf( |
| 61 | + $_Lang['NewUserProtection_Text'], |
| 62 | + pretty_time($protectionTimeLeft, true, 'dhms') |
| 63 | + ) |
| 64 | + ] |
| 65 | + ); |
| 66 | + |
| 67 | + $protectionCountdownJS = InsertJavaScriptChronoApplet('newprotect', '', $protectionTimeLeft); |
| 68 | + |
| 69 | + return [ |
| 70 | + 'componentHTML' => $componentHTML, |
| 71 | + 'globalJS' => $protectionCountdownJS, |
| 72 | + ]; |
| 73 | +} |
| 74 | + |
| 75 | +?> |
0 commit comments