60 lines
2.2 KiB
PHP
60 lines
2.2 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once dirname(__DIR__) . '/bootstrap.php';
|
|
|
|
$moduleConfig = require dirname(__DIR__) . '/config/module.php';
|
|
$design = module_design('mining-checker');
|
|
$defaultProjectKey = (string) ($moduleConfig['default_project_key'] ?? 'doge-main');
|
|
$sections = is_array($design['sections'] ?? null) ? $design['sections'] : [];
|
|
$activeView = trim((string) ($_GET['view'] ?? 'overview'));
|
|
$allowedViews = [];
|
|
$tabs = [];
|
|
foreach ($sections as $section) {
|
|
if (!is_array($section)) {
|
|
continue;
|
|
}
|
|
$key = trim((string) ($section['key'] ?? ''));
|
|
$label = trim((string) ($section['label'] ?? ''));
|
|
if ($key === '' || $label === '') {
|
|
continue;
|
|
}
|
|
$allowedViews[] = $key;
|
|
$tabs[] = [
|
|
'label' => $label,
|
|
'href' => '/module/mining-checker?view=' . rawurlencode($key),
|
|
'active' => $activeView === $key,
|
|
];
|
|
}
|
|
if ($allowedViews === []) {
|
|
$allowedViews = ['overview'];
|
|
}
|
|
if (!in_array($activeView, $allowedViews, true)) {
|
|
$activeView = $allowedViews[0];
|
|
foreach ($tabs as &$tab) {
|
|
$tab['active'] = str_ends_with((string) ($tab['href'] ?? ''), 'view=' . $activeView);
|
|
}
|
|
unset($tab);
|
|
}
|
|
$sectionsJson = json_encode($sections, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
$moduleCss = file_get_contents(dirname(__DIR__) . '/assets/css/app.css') ?: '';
|
|
$moduleJs = file_get_contents(dirname(__DIR__) . '/assets/js/app.js') ?: '';
|
|
$moduleJs = str_replace('</script>', '<\/script>', $moduleJs);
|
|
?>
|
|
<?= module_shell_header('mining-checker', [
|
|
'title' => 'DOGE Mining-Checker',
|
|
'tabs' => $tabs,
|
|
]) ?>
|
|
<div class="module-flow">
|
|
<div id="mining-checker-app"
|
|
data-default-project-key="<?= e($defaultProjectKey) ?>"
|
|
data-api-base="/api/mining-checker/v1"
|
|
data-active-view="<?= e($activeView) ?>"
|
|
data-sections-json="<?= e(is_string($sectionsJson) ? $sectionsJson : '[]') ?>"></div>
|
|
</div>
|
|
<style><?= $moduleCss ?></style>
|
|
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
|
|
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
|
|
<script><?= $moduleJs ?></script>
|
|
<?= module_shell_footer() ?>
|