159 lines
6.5 KiB
PHP
159 lines
6.5 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_auth();
|
|
|
|
$service = dashboards();
|
|
$ownerKey = auth_user_key();
|
|
$notice = null;
|
|
$error = null;
|
|
|
|
if (!$service->available() || $ownerKey === '') {
|
|
echo '<div class="module-shell"><div class="module-page-bg"><div class="module-page-stack"><section class="section-box">Seitenmodul-System nicht verfügbar.</section></div></div></div>';
|
|
return;
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$action = trim((string) ($_POST['action'] ?? ''));
|
|
try {
|
|
if ($action === 'create_page_module') {
|
|
$service->createPageModule($ownerKey, [
|
|
'title' => trim((string) ($_POST['title'] ?? '')),
|
|
'slug' => trim((string) ($_POST['slug'] ?? '')),
|
|
'module_type' => trim((string) ($_POST['module_type'] ?? 'link')),
|
|
'target_url' => trim((string) ($_POST['target_url'] ?? '')),
|
|
'description' => trim((string) ($_POST['description'] ?? '')),
|
|
'visibility' => trim((string) ($_POST['visibility'] ?? 'private')),
|
|
'open_mode' => trim((string) ($_POST['open_mode'] ?? 'embed')),
|
|
'is_active' => isset($_POST['is_active']),
|
|
]);
|
|
$notice = 'Seitenmodul angelegt.';
|
|
} elseif ($action === 'delete_page_module') {
|
|
$service->deletePageModule((int) ($_POST['page_module_id'] ?? 0), $ownerKey);
|
|
$notice = 'Seitenmodul gelöscht.';
|
|
}
|
|
} catch (\Throwable $exception) {
|
|
$error = $exception->getMessage();
|
|
}
|
|
}
|
|
|
|
$pageModules = $service->listPageModulesForOwner($ownerKey);
|
|
|
|
$GLOBALS['layout_header_base_title'] = 'Nexus';
|
|
$GLOBALS['layout_header_title'] = 'Nexus';
|
|
$GLOBALS['layout_header_context'] = 'Seitenmodule';
|
|
$GLOBALS['layout_header_text'] = 'On-the-fly angelegte Link- und iFrame-Module ohne eigenen Modulordner.';
|
|
?>
|
|
<div class="module-shell"><div class="module-page-bg"><div class="module-page-stack">
|
|
<header class="module-hero submenu-box">
|
|
<div class="module-hero-top module-hero-top--compact">
|
|
<nav class="module-tabs" aria-label="Seitenmodule Navigation">
|
|
<a class="module-button module-button--tab" href="/dashboard">Dashboard</a>
|
|
<a class="module-button module-button--tab" href="/dashboards">Dashboards</a>
|
|
<a class="module-button module-button--tab" href="/integrations">Integrationen</a>
|
|
<a class="module-button module-button--tab-active" href="/page-modules">Seitenmodule</a>
|
|
</nav>
|
|
<div class="module-hero-actions module-submenu-actions">
|
|
<a class="module-button module-button--secondary module-button--small" href="/">Nexus Übersicht</a>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<?php if ($error !== null): ?>
|
|
<section class="section-box"><?= e($error) ?></section>
|
|
<?php elseif ($notice !== null): ?>
|
|
<section class="section-box"><?= e($notice) ?></section>
|
|
<?php endif; ?>
|
|
|
|
<section class="section-box">
|
|
<h2>Neues Seitenmodul</h2>
|
|
<form method="post" class="setup-form">
|
|
<input type="hidden" name="action" value="create_page_module">
|
|
<div class="setup-grid">
|
|
<label class="setup-field muted">
|
|
<span>Titel</span>
|
|
<input type="text" name="title" required>
|
|
</label>
|
|
<label class="setup-field muted">
|
|
<span>Slug optional</span>
|
|
<input type="text" name="slug">
|
|
</label>
|
|
</div>
|
|
<div class="setup-grid">
|
|
<label class="setup-field muted">
|
|
<span>Typ</span>
|
|
<select name="module_type">
|
|
<option value="link">Link</option>
|
|
<option value="iframe">iFrame</option>
|
|
</select>
|
|
</label>
|
|
<label class="setup-field muted">
|
|
<span>Ziel-URL</span>
|
|
<input type="url" name="target_url" required placeholder="https://...">
|
|
</label>
|
|
</div>
|
|
<div class="setup-grid">
|
|
<label class="setup-field muted">
|
|
<span>Beschreibung</span>
|
|
<input type="text" name="description">
|
|
</label>
|
|
<label class="setup-field muted">
|
|
<span>Öffnen als</span>
|
|
<select name="open_mode">
|
|
<option value="embed">Im Nexus einbetten</option>
|
|
<option value="new_tab">Neuer Tab</option>
|
|
<option value="same_tab">Direkt öffnen</option>
|
|
</select>
|
|
</label>
|
|
</div>
|
|
<div class="setup-grid">
|
|
<label class="setup-field muted">
|
|
<span>Sichtbarkeit</span>
|
|
<select name="visibility">
|
|
<option value="private">Privat</option>
|
|
<option value="public">Öffentlich</option>
|
|
</select>
|
|
</label>
|
|
<label class="setup-field muted">
|
|
<input type="checkbox" name="is_active" value="1" checked>
|
|
<span>Aktiv</span>
|
|
</label>
|
|
</div>
|
|
<div class="setup-actions setup-actions--footer">
|
|
<button class="cta-button" type="submit">Seitenmodul speichern</button>
|
|
</div>
|
|
</form>
|
|
</section>
|
|
|
|
<div class="module-admin-grid">
|
|
<?php foreach ($pageModules as $pageModule): ?>
|
|
<article class="card-box module-admin-card">
|
|
<div class="module-admin-card__head">
|
|
<div class="module-admin-card__title">
|
|
<h2><?= e((string) ($pageModule['title'] ?? 'Seitenmodul')) ?></h2>
|
|
<p><?= e((string) ($pageModule['description'] ?? ($pageModule['target_url'] ?? ''))) ?></p>
|
|
</div>
|
|
</div>
|
|
<div class="module-admin-meta">
|
|
<div class="module-admin-meta__item">
|
|
<span class="module-admin-meta__label">Typ</span>
|
|
<strong class="module-admin-badge"><?= e((string) ($pageModule['module_type'] ?? 'link')) ?></strong>
|
|
</div>
|
|
<div class="module-admin-meta__item">
|
|
<span class="module-admin-meta__label">Öffnen</span>
|
|
<strong class="module-admin-badge"><?= e((string) ($pageModule['open_mode'] ?? 'embed')) ?></strong>
|
|
</div>
|
|
</div>
|
|
<div class="module-admin-actions">
|
|
<a class="module-button module-button--secondary module-button--small" href="/page-modules/view/<?= (int) ($pageModule['id'] ?? 0) ?>">Öffnen</a>
|
|
<form method="post">
|
|
<input type="hidden" name="action" value="delete_page_module">
|
|
<input type="hidden" name="page_module_id" value="<?= (int) ($pageModule['id'] ?? 0) ?>">
|
|
<button class="module-button module-button--secondary module-button--small" type="submit">Löschen</button>
|
|
</form>
|
|
</div>
|
|
</article>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div></div></div>
|