importer general
All checks were successful
Deploy / deploy-staging (push) Successful in 5s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-04-11 03:25:38 +02:00
parent 37f5b7f5e6
commit 067f962cb2
8 changed files with 277 additions and 25 deletions

View File

@@ -0,0 +1,94 @@
<?php
require_admin();
$service = new \App\ModuleSqlImportService(modules());
$availableModules = $service->importableModules();
$selectedModule = (string) ($_POST['module'] ?? ($_GET['module'] ?? ''));
$error = null;
$notice = null;
$result = null;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
try {
if (!isset($_FILES['sql_file']) || !is_array($_FILES['sql_file'])) {
throw new RuntimeException('Bitte eine SQL-Datei auswaehlen.');
}
$result = $service->importUploadedFile($selectedModule, $_FILES['sql_file']);
$notice = sprintf(
'%s %d Statements aus %s wurden nach %s importiert.',
(string) ($result['message'] ?? 'Import erfolgreich.'),
(int) ($result['statement_count'] ?? 0),
(string) ($result['file'] ?? 'der Datei'),
(string) ($result['target_label'] ?? 'der Ziel-Datenbank')
);
} catch (Throwable $exception) {
$error = $exception->getMessage();
}
}
?>
<div class="card">
<div class="pill">SQL Import</div>
<h1 style="margin-top:.75rem;">Zentraler SQL-Import fuer Module</h1>
<p class="muted">
Diese Seite ist eine gemeinsame Standard-Loesung. Module koennen sie direkt nutzen oder weiterhin einen eigenen spezialisierten Uploader bereitstellen.
</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; ?>
<?php if ($availableModules === []): ?>
<div class="card" style="margin-top:1rem; background:var(--panel-2);">
Aktuell ist kein Modul fuer den generischen SQL-Import vorbereitet.
</div>
<?php else: ?>
<form method="post" enctype="multipart/form-data" class="card" style="margin-top:1rem; background:var(--panel-2);">
<div style="display:grid; gap:1rem;">
<label style="display:grid; gap:.35rem;">
<span>Modul</span>
<select name="module" required>
<option value="">Bitte waehlen</option>
<?php foreach ($availableModules as $module): ?>
<option value="<?= e($module['name']) ?>" <?= $selectedModule === $module['name'] ? 'selected' : '' ?>>
<?= e($module['title']) ?>
</option>
<?php endforeach; ?>
</select>
</label>
<label style="display:grid; gap:.35rem;">
<span>SQL-Datei</span>
<input type="file" name="sql_file" accept=".sql,text/sql,application/sql" required>
</label>
<div class="muted" style="font-size:.95rem;">
Der generische Import nutzt die Standard-Datenbankverbindung des Moduls oder einen optionalen Modul-Callback fuer Spezialfaelle.
</div>
<div style="display:flex; gap:10px; flex-wrap:wrap;">
<button class="cta-button" type="submit">SQL importieren</button>
<a class="nav-link" href="/modules/install">Zur Modulverwaltung</a>
</div>
</div>
</form>
<div style="margin-top:1.25rem;" class="grid">
<?php foreach ($availableModules as $module): ?>
<div class="card" style="background:var(--panel-2);">
<strong><?= e($module['title']) ?></strong>
<div class="muted" style="font-size:.85rem;"><?= e($module['description']) ?></div>
<div style="margin-top:.75rem;">
<a class="nav-link" href="/modules/sql-import?module=<?= e($module['name']) ?>">Fuer dieses Modul importieren</a>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>