rebuild to module
This commit is contained in:
@@ -134,6 +134,21 @@ body {
|
||||
padding: 24px;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
.card input,
|
||||
.card textarea {
|
||||
background: #0f121b;
|
||||
border: 1px solid var(--line);
|
||||
color: var(--text);
|
||||
padding: 10px 12px;
|
||||
border-radius: 10px;
|
||||
font-family: inherit;
|
||||
}
|
||||
.card input:focus,
|
||||
.card textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
box-shadow: 0 0 0 2px rgba(255, 94, 91, 0.2);
|
||||
}
|
||||
.muted { color: var(--muted); }
|
||||
.pill {
|
||||
display: inline-flex;
|
||||
@@ -172,9 +187,6 @@ body {
|
||||
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
|
||||
.py-5 { padding-top: 1.25rem; padding-bottom: 1.25rem; }
|
||||
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
|
||||
.sm\\:px-0 {}
|
||||
.sm\\:px-6 {}
|
||||
.sm\\:rounded-lg {}
|
||||
@media (min-width: 640px) {
|
||||
.sm\\:px-0 { padding-left: 0; padding-right: 0; }
|
||||
.sm\\:px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
|
||||
|
||||
@@ -28,8 +28,21 @@ if (str_contains($uriPath, '..')) {
|
||||
exit('Bad request');
|
||||
}
|
||||
|
||||
// Root → page/index.php
|
||||
if ($uriPath === '' || $uriPath === 'index' || $uriPath === 'index.php') {
|
||||
// Spezialrouten für Module
|
||||
if (str_starts_with($uriPath, 'modules/setup/')) {
|
||||
$_GET['module'] = trim(substr($uriPath, strlen('modules/setup/')), '/');
|
||||
$target = __DIR__ . '/page/modules_setup.php';
|
||||
} elseif (preg_match('~^module/([a-zA-Z0-9_-]+)(?:/(.+))?$~', $uriPath, $m)) {
|
||||
$module = $m[1];
|
||||
$page = isset($m[2]) && $m[2] !== '' ? trim($m[2], '/') : 'index';
|
||||
$modulePage = app()->modules()->resolvePage($module, $page);
|
||||
if ($modulePage) {
|
||||
$target = $modulePage;
|
||||
} else {
|
||||
http_response_code(404);
|
||||
$target = __DIR__ . '/page/404.php';
|
||||
}
|
||||
} elseif ($uriPath === '' || $uriPath === 'index' || $uriPath === 'index.php') {
|
||||
$target = __DIR__ . '/page/index.php';
|
||||
} else {
|
||||
$base = __DIR__ . '/page/' . $uriPath;
|
||||
|
||||
@@ -1,22 +1,34 @@
|
||||
<?php
|
||||
use App\Database;
|
||||
use App\Repository\KeaHostRepository;
|
||||
$modules = modules()->all();
|
||||
?>
|
||||
<div class="card">
|
||||
<div class="pill">Core</div>
|
||||
<h1 style="margin-top:.75rem;">Nexus Basis-System</h1>
|
||||
<p class="muted">Aktive Module verwalten und neue Module initialisieren.</p>
|
||||
|
||||
global $appConfig;
|
||||
<div style="margin-top:1rem;">
|
||||
<a class="nav-link" href="/modules">Module verwalten</a>
|
||||
</div>
|
||||
|
||||
$pdo = Database::createPdo($appConfig);
|
||||
$hosts = [];
|
||||
$error = null;
|
||||
|
||||
if ($pdo) {
|
||||
try {
|
||||
$repo = new KeaHostRepository($pdo);
|
||||
$hosts = $repo->findAll(50);
|
||||
} catch (\Exception $e) {
|
||||
$error = "Datenbankfehler: " . $e->getMessage();
|
||||
}
|
||||
} else {
|
||||
$error = "Datenbankverbindung ist nicht konfiguriert oder deaktiviert.";
|
||||
}
|
||||
|
||||
tpl('kea_dashboard', 'landing', compact('hosts', 'error'));
|
||||
<div style="margin-top:1.5rem;" class="grid">
|
||||
<?php foreach ($modules as $module): ?>
|
||||
<div class="card" style="background:var(--panel-2);">
|
||||
<div style="display:flex; align-items:center; justify-content:space-between; gap:12px;">
|
||||
<div>
|
||||
<strong><?= e($module['title']) ?></strong>
|
||||
<div class="muted" style="font-size:.85rem;"><?= e($module['description'] ?? '') ?></div>
|
||||
</div>
|
||||
<?php if (!empty($module['enabled'])): ?>
|
||||
<span class="pill" style="border-color:var(--accent-2); color:var(--accent-2);">aktiv</span>
|
||||
<?php else: ?>
|
||||
<span class="pill">inaktiv</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div style="margin-top:.75rem; display:flex; gap:10px; flex-wrap:wrap;">
|
||||
<a class="nav-link" href="/module/<?= e($module['name']) ?>">Öffnen</a>
|
||||
<a class="nav-link" href="/modules/setup/<?= e($module['name']) ?>">Setup</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
63
public/page/modules.php
Normal file
63
public/page/modules.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
$modules = modules()->all();
|
||||
$error = null;
|
||||
$notice = null;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$name = (string)($_POST['module'] ?? '');
|
||||
$action = (string)($_POST['action'] ?? '');
|
||||
|
||||
if ($name !== '' && ($action === 'enable' || $action === 'disable')) {
|
||||
$enabled = $action === 'enable';
|
||||
modules()->setEnabled($name, $enabled);
|
||||
$notice = $enabled ? 'Modul aktiviert.' : 'Modul deaktiviert.';
|
||||
$modules = modules()->all();
|
||||
} else {
|
||||
$error = 'Ungültige Aktion.';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="card">
|
||||
<div class="pill">Module</div>
|
||||
<h1 style="margin-top:.75rem;">Module verwalten</h1>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="bg-red-900 border-l-4 border-red-500 text-red-100 p-4 mb-6" role="alert">
|
||||
<?= e($error) ?>
|
||||
</div>
|
||||
<?php elseif ($notice): ?>
|
||||
<div class="card" style="margin-top:1rem; border-color:var(--accent-2);">
|
||||
<?= e($notice) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div style="margin-top:1rem;" class="grid">
|
||||
<?php foreach ($modules as $module): ?>
|
||||
<div class="card" style="background:var(--panel-2);">
|
||||
<div style="display:flex; align-items:center; justify-content:space-between; gap:12px;">
|
||||
<div>
|
||||
<strong><?= e($module['title']) ?></strong>
|
||||
<div class="muted" style="font-size:.85rem;"><?= e($module['description'] ?? '') ?></div>
|
||||
</div>
|
||||
<?php if (!empty($module['enabled'])): ?>
|
||||
<span class="pill" style="border-color:var(--accent-2); color:var(--accent-2);">aktiv</span>
|
||||
<?php else: ?>
|
||||
<span class="pill">inaktiv</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div style="margin-top:.75rem; display:flex; gap:10px; flex-wrap:wrap;">
|
||||
<a class="nav-link" href="/module/<?= e($module['name']) ?>">Öffnen</a>
|
||||
<a class="nav-link" href="/modules/setup/<?= e($module['name']) ?>">Setup</a>
|
||||
<form method="post" style="margin:0;">
|
||||
<input type="hidden" name="module" value="<?= e($module['name']) ?>">
|
||||
<?php if (!empty($module['enabled'])): ?>
|
||||
<button class="cta-button" name="action" value="disable" style="background:var(--panel); color:var(--text);">Deaktivieren</button>
|
||||
<?php else: ?>
|
||||
<button class="cta-button" name="action" value="enable">Aktivieren</button>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
108
public/page/modules_setup.php
Normal file
108
public/page/modules_setup.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
$moduleName = (string)($_GET['module'] ?? '');
|
||||
$module = modules()->get($moduleName);
|
||||
$error = null;
|
||||
$notice = null;
|
||||
|
||||
if (!$module) {
|
||||
http_response_code(404);
|
||||
echo '<div class="card">Modul nicht gefunden.</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
$fields = (array)($module['setup']['fields'] ?? []);
|
||||
$current = modules()->settings($moduleName);
|
||||
$defaults = $module['db_defaults'] ?? [];
|
||||
if (empty($current['db']) && is_array($defaults)) {
|
||||
$current['db'] = $defaults;
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$payload = [];
|
||||
$db = $current['db'] ?? [];
|
||||
|
||||
foreach ($fields as $field) {
|
||||
$name = (string)($field['name'] ?? '');
|
||||
if ($name === '') {
|
||||
continue;
|
||||
}
|
||||
$value = $_POST[$name] ?? null;
|
||||
if (is_array($value)) {
|
||||
continue;
|
||||
}
|
||||
$value = is_string($value) ? trim($value) : $value;
|
||||
|
||||
if ($name === 'kea_auto_init') {
|
||||
$payload[$name] = $value === '1';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (str_starts_with($name, 'db.')) {
|
||||
$key = substr($name, 3);
|
||||
$db[$key] = $value;
|
||||
continue;
|
||||
}
|
||||
|
||||
$payload[$name] = $value;
|
||||
}
|
||||
|
||||
if (!empty($db)) {
|
||||
$payload['db'] = $db;
|
||||
}
|
||||
|
||||
modules()->saveSettings($moduleName, $payload);
|
||||
$notice = 'Setup gespeichert.';
|
||||
$current = modules()->settings($moduleName);
|
||||
}
|
||||
?>
|
||||
<div class="card">
|
||||
<div class="pill">Setup</div>
|
||||
<h1 style="margin-top:.75rem;"><?= e($module['title']) ?> – Einrichtung</h1>
|
||||
<p class="muted">Trage die benötigten Informationen für das Modul ein.</p>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="bg-red-900 border-l-4 border-red-500 text-red-100 p-4 mb-6" role="alert">
|
||||
<?= e($error) ?>
|
||||
</div>
|
||||
<?php elseif ($notice): ?>
|
||||
<div class="card" style="margin-top:1rem; border-color:var(--accent-2);">
|
||||
<?= e($notice) ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<form method="post" style="margin-top:1rem; display:grid; gap:14px; max-width:520px;">
|
||||
<?php foreach ($fields as $field): ?>
|
||||
<?php
|
||||
$name = (string)($field['name'] ?? '');
|
||||
$label = (string)($field['label'] ?? $name);
|
||||
$type = (string)($field['type'] ?? 'text');
|
||||
$required = !empty($field['required']);
|
||||
|
||||
$value = '';
|
||||
if ($name === 'kea_auto_init') {
|
||||
$value = !empty($current[$name]) ? '1' : '0';
|
||||
} elseif (str_starts_with($name, 'db.')) {
|
||||
$key = substr($name, 3);
|
||||
$value = (string)($current['db'][$key] ?? '');
|
||||
} else {
|
||||
$value = (string)($current[$name] ?? '');
|
||||
}
|
||||
?>
|
||||
<label class="muted" style="display:grid; gap:6px;">
|
||||
<span><?= e($label) ?></span>
|
||||
<?php if ($type === 'textarea'): ?>
|
||||
<textarea name="<?= e($name) ?>" rows="3" <?= $required ? 'required' : '' ?>><?= e($value) ?></textarea>
|
||||
<?php elseif ($type === 'checkbox'): ?>
|
||||
<input type="checkbox" name="<?= e($name) ?>" value="1" <?= $value === '1' ? 'checked' : '' ?>>
|
||||
<?php else: ?>
|
||||
<input type="<?= e($type) ?>" name="<?= e($name) ?>" value="<?= e($value) ?>" <?= $required ? 'required' : '' ?>>
|
||||
<?php endif; ?>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<div style="display:flex; gap:10px;">
|
||||
<button class="cta-button" type="submit">Speichern</button>
|
||||
<a class="nav-link" href="/modules">Zurück</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user