← Code-Übersicht

doku-detail.php

Pfad: src/Infrastructure/Http/view/doku-detail.php

Ext: php

Größe: 2935 Bytes

Geändert: 2026-07-16 08:36:26+02

<?php
declare(strict_types=1);

/**
 * Detailseite. Bei $editierbar: In-Place-WYSIWYG mit Speichern und Versionsliste.
 * Sonst: read-only Snapshot einer frueheren Version (ohne Editor/Historie).
 * $inhaltHtml stammt aus MarkdownToHtml (Text bereits escaped) und wird daher
 * bewusst roh geschrieben.
 *
 * @var callable(string):string                 $e
 * @var \Demo\Domain\Dokumentation\Dokumentation $dok
 * @var string                                   $inhaltHtml
 * @var bool                                     $editierbar
 * @var list<\Demo\Domain\Dokumentation\Version> $versionen
 */
?>
        <p><a href="/doku">&larr; Übersicht</a></p>
        <h1><?= $e($dok->titel) ?></h1>
<?php if ($editierbar): ?>
        <form method="post" action="/doku/<?= $e($dok->slug) ?>" id="doku-form">
            <div class="doku-toolbar" id="doku-toolbar">
                <button type="button" data-cmd="formatBlock" data-value="H1">H1</button>
                <button type="button" data-cmd="formatBlock" data-value="H2">H2</button>
                <button type="button" data-cmd="formatBlock" data-value="H3">H3</button>
                <button type="button" data-cmd="formatBlock" data-value="H4">H4</button>
                <button type="button" data-cmd="formatBlock" data-value="H5">H5</button>
                <button type="button" data-cmd="formatBlock" data-value="H6">H6</button>
                <button type="button" data-cmd="formatBlock" data-value="P">P</button>
                <button type="button" data-cmd="bold">Fett</button>
                <button type="button" data-cmd="insertUnorderedList">Liste</button>
                <button type="button" data-cmd="insertOrderedList">Nummeriert</button>
            </div>
            <div class="doku-editor" id="doku-editor" contenteditable="true"><?php echo $inhaltHtml; ?></div>
            <input type="hidden" name="inhalt" id="doku-inhalt">
            <p><button type="submit" class="doku-speichern">Speichern</button></p>
        </form>
        <script src="/assets/doku-editor.js"></script>
<?php if ($versionen !== []): ?>
        <h2>Frühere Versionen</h2>
        <table class="doku-versionen">
            <thead><tr><th>Version</th><th>Zeitpunkt</th><th>Operation</th></tr></thead>
            <tbody>
<?php foreach ($versionen as $v): ?>
                <tr>
                    <td><a href="/doku/<?= $e($dok->slug) ?>/<?= $e((string) $v->id) ?>"><?= $e((string) $v->id) ?></a></td>
                    <td><?= $e($v->geaendertAm) ?></td>
                    <td><?= $e($v->operation) ?></td>
                </tr>
<?php endforeach; ?>
            </tbody>
        </table>
<?php endif; ?>
<?php else: ?>
        <p class="doku-version-hinweis">Frühere Version vom <?= $e($dok->geaendert) ?> &middot; <a href="/doku/<?= $e($dok->slug) ?>">zur aktuellen Fassung</a></p>
        <div class="doku-editor"><?php echo $inhaltHtml; ?></div>
<?php endif; ?>