Quelltext des aktuellen Standes
<?php $this->layout('layouts/admin', [
'page_title' => 'Vorlage bearbeiten',
'current_admin_page' => 'page-templates',
]); ?>
<?php $template = $template ?? []; ?>
<div class="settings-page">
<div class="page-back-nav">
<a href="/admin/page-templates" class="btn btn-sm btn-secondary"><?= $this->te('← Zurรผck zu Vorlagen') ?></a>
</div>
<form action="/admin/page-templates/<?= $template['id'] ?>" method="POST">
<input type="hidden" name="_csrf" value="<?= $this->csrf() ?>">
<input type="hidden" name="_method" value="PUT">
<!-- Vorlagen-Einstellungen -->
<section class="settings-card">
<div class="settings-card-header">
<span class="settings-card-icon"><?= $template['icon'] ?></span>
<div>
<h2><?= $this->e($template['name']) ?></h2>
<p class="settings-card-desc"><?= $this->te('Vorlagen-Einstellungen und Metadaten bearbeiten.') ?></p>
</div>
</div>
<div class="settings-card-body">
<div class="form-row-2">
<div class="form-group">
<label for="tpl-name"><?= $this->te('Name') ?></label>
<input type="text" id="tpl-name" name="name" class="form-control" value="<?= $this->e($template['name']) ?>" required maxlength="255">
</div>
<div class="form-group">
<label for="tpl-category"><?= $this->te('Kategorie') ?></label>
<input type="text" id="tpl-category" name="category" class="form-control" value="<?= $this->e($template['category']) ?>">
</div>
</div>
<div class="form-row-2">
<div class="form-group" style="max-width:220px;">
<label for="tpl-icon"><?= $this->te('Icon') ?></label>
<select id="tpl-icon" name="icon" class="form-control icon-select">
<?php
$icons = [
'๐' => 'Dokument', '๐ฅ' => 'Server', '๐ป' => 'Laptop', '๐จ' => 'PC',
'๐' => 'Netzwerk', '๐' => 'Sicherheit', '๐' => 'Schlรผssel', '๐ง' => 'Werkzeug',
'โ' => 'Zahnrad', '๐' => 'Stecker', '๐ก' => 'Fax/Drucker', 'โ' => 'E-Mail',
'๐' => 'Telefon', '๐ฑ' => 'Smartphone', 'โ' => 'Cloud', '๐' => 'Diagramm',
'๐' => 'Statistik', '๐' => 'Checkliste', '๐' => 'Notiz', '๐' => 'Buecher',
'๐' => 'Suche', '๐' => 'Link', '๐ฎ' => 'Steuerung', '๐ ' => 'Wartung',
'๐' => 'Rakete', 'โ ' => 'Warnung', '๐จ' => 'Alarm', 'โ
' => 'Erledigt',
'โ' => 'Fehler', '๐ค' => 'Person', '๐ฅ' => 'Team', '๐ข' => 'Firma',
'๐ฐ' => 'Finanzen', '๐
' => 'Kalender', '๐' => 'Uhr', '๐พ' => 'Datenbank',
'๐ฆ' => 'Paket', '๐' => 'Formular', '๐ก' => 'Idee', '๐ฏ' => 'Ziel',
];
$currentIcon = $template['icon'] ?? '๐';
$found = false;
foreach ($icons as $emoji => $label):
$sel = ($emoji === $currentIcon) ? 'selected' : '';
if ($sel) $found = true;
?>
<option value="<?= $emoji ?>" <?= $sel ?>><?= $emoji ?> <?= $label ?></option>
<?php endforeach; ?>
<?php if (!$found): ?>
<option value="<?= $this->e($currentIcon) ?>" selected><?= $this->te('{icon} (Aktuell)', ['icon' => $currentIcon]) ?></option>
<?php endif; ?>
</select>
</div>
<div class="form-group" style="max-width:120px;">
<label for="tpl-sort"><?= $this->te('Reihenfolge') ?></label>
<input type="number" id="tpl-sort" name="sort_order" class="form-control" value="<?= $template['sort_order'] ?>" min="0">
</div>
</div>
<div class="form-group">
<label for="tpl-desc"><?= $this->te('Beschreibung') ?></label>
<input type="text" id="tpl-desc" name="description" class="form-control" value="<?= $this->e($template['description'] ?? '') ?>" maxlength="500" placeholder="<?= $this->te('Kurze Beschreibung der Vorlage...') ?>">
<small class="form-hint"><?= $this->te('Wird beim Auswaehlen der Vorlage angezeigt.') ?></small>
</div>
<div class="form-group">
<label class="settings-toggle">
<input type="checkbox" name="is_active" value="1" <?= $template['is_active'] ? 'checked' : '' ?>>
<span class="toggle-text">
<strong><?= $this->te('Aktiv') ?></strong>
<small><?= $this->te('Wird bei neuen Seiten als Vorlage angeboten.') ?></small>
</span>
</label>
</div>
</div>
</section>
<!-- Vorlagen-Inhalt -->
<section class="settings-card">
<div class="settings-card-header">
<span class="settings-card-icon">📝</span>
<div>
<h2><?= $this->te('Vorlagen-Inhalt') ?></h2>
<p class="settings-card-desc"><?= $this->te('Der HTML-Inhalt, der beim Erstellen einer neuen Seite eingefuegt wird.') ?></p>
</div>
</div>
<div class="settings-card-body">
<textarea name="content_html" id="tpl-content"><?= $this->e($template['content_html'] ?? '') ?></textarea>
</div>
</section>
<div class="form-actions-bar">
<button type="submit" class="btn btn-primary"><?= $this->te('Speichern') ?></button>
<a href="/admin/page-templates" class="btn btn-secondary"><?= $this->te('Abbrechen') ?></a>
</div>
</form>
</div>
<?php if (TINYMCE_INSTALLED): ?>
<script src="<?= $this->asset('/assets/tinymce/tinymce.min.js') ?>"></script>
<script>
tinymce.init({
selector: '#tpl-content',
height: 500,
language: 'de',
language_url: '/assets/tinymce/langs/de.js',
plugins: [
'advlist', 'autolink', 'lists', 'link', 'charmap',
'searchreplace', 'visualblocks', 'code', 'fullscreen',
'insertdatetime', 'table', 'help', 'wordcount', 'codesample'
],
toolbar: [
'undo redo | blocks | bold italic underline | forecolor backcolor removeformat',
'alignleft aligncenter alignright | bullist numlist outdent indent | table link codesample | code fullscreen'
],
menubar: false,
promotion: false,
branding: false,
license_key: 'gpl',
content_style: 'body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 16px; line-height: 1.7; color: #1f2937; padding: 1rem; } table { border-collapse: collapse; width: 100%; } th, td { border: 1px solid #d1d5db; padding: 0.75rem; } th { background: #f3f4f6; font-weight: 600; }'
});
</script>
<?php else: ?>
<link rel="stylesheet" href="<?= $this->asset('/assets/css/wysiwyg.css') ?>">
<script src="<?= $this->asset('/assets/js/wysiwyg.js') ?>"></script>
<script>
(function() {
var ta = document.getElementById('tpl-content');
var wrap = document.createElement('div');
wrap.className = 'wysiwyg-editor-container';
ta.parentNode.insertBefore(wrap, ta);
wrap.appendChild(ta);
new OpenNIT.WysiwygEditor(wrap, {
uploadUrl: '/upload/image',
csrfToken: document.querySelector('input[name="_csrf"]')?.value || ''
});
}());
</script>
<?php endif; ?>
<style>
.page-back-nav {
margin-bottom: 1rem;
}
.form-row-2 {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
}
.form-actions-bar {
display: flex;
gap: 0.75rem;
margin-top: 1rem;
}
.settings-toggle {
display: flex;
align-items: flex-start;
gap: 0.5rem;
cursor: pointer;
}
.settings-toggle input {
margin-top: 0.2em;
}
.toggle-text strong {
display: block;
font-size: var(--font-size-sm, 0.875rem);
}
.toggle-text small {
display: block;
color: var(--color-text-muted, var(--gray-500));
font-size: var(--font-size-xs, 0.75rem);
}
@media (max-width: 640px) {
.form-row-2 {
grid-template-columns: 1fr;
}
}
.icon-select {
font-size: 1.1rem;
padding: 0.375rem 0.5rem;
}
</style>