2018-07-21 19:15:07 +03:00
|
|
|
<?php
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-08-18 23:52:01 +03:00
|
|
|
final class FrontpageAction implements ActionInterface
|
2018-07-21 19:15:07 +03:00
|
|
|
{
|
2022-08-18 23:52:01 +03:00
|
|
|
public function execute(array $request)
|
2022-08-06 23:46:28 +03:00
|
|
|
{
|
2022-08-18 23:52:01 +03:00
|
|
|
$showInactive = (bool) ($request['show_inactive'] ?? null);
|
2022-11-07 20:22:54 +03:00
|
|
|
$activeBridges = 0;
|
2022-08-18 23:52:01 +03:00
|
|
|
|
|
|
|
$bridgeFactory = new BridgeFactory();
|
|
|
|
$bridgeClassNames = $bridgeFactory->getBridgeClassNames();
|
|
|
|
|
|
|
|
$formatFactory = new FormatFactory();
|
|
|
|
$formats = $formatFactory->getFormatNames();
|
|
|
|
|
2022-11-07 20:22:54 +03:00
|
|
|
$body = '';
|
2022-08-18 23:52:01 +03:00
|
|
|
foreach ($bridgeClassNames as $bridgeClassName) {
|
|
|
|
if ($bridgeFactory->isWhitelisted($bridgeClassName)) {
|
|
|
|
$body .= BridgeCard::displayBridgeCard($bridgeClassName, $formats);
|
2022-11-07 20:22:54 +03:00
|
|
|
$activeBridges++;
|
2022-08-18 23:52:01 +03:00
|
|
|
} elseif ($showInactive) {
|
2022-11-07 20:22:54 +03:00
|
|
|
$body .= BridgeCard::displayBridgeCard($bridgeClassName, $formats, false) . PHP_EOL;
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
|
|
|
}
|
2018-07-21 19:15:07 +03:00
|
|
|
|
2022-11-07 20:22:54 +03:00
|
|
|
return render(__DIR__ . '/../templates/frontpage.html.php', [
|
|
|
|
'admin_email' => Configuration::getConfig('admin', 'email'),
|
2022-11-07 20:36:52 +03:00
|
|
|
'admin_telegram' => Configuration::getConfig('admin', 'telegram'),
|
2022-11-07 20:22:54 +03:00
|
|
|
'bridges' => $body,
|
|
|
|
'active_bridges' => $activeBridges,
|
|
|
|
'total_bridges' => count($bridgeClassNames),
|
|
|
|
'show_inactive' => $showInactive,
|
|
|
|
]);
|
2018-07-21 19:15:07 +03:00
|
|
|
}
|
|
|
|
}
|