Führe PDF-Vorlagen für Dokumente ein: Titelseite, grafischer Kopf und Fuß, Angaben je Fassung (ADR-51, Nachtrag)
Deploy Test / test (push) Successful in 3m21s
Deploy Test / deploy (push) Successful in 27s

Eine Vorlage ist reines Layout (Titelseite mit allein stehendem Titel, Kopf- und Fußgrafik aus dem Medienbestand,
Herausgeber und Standardvermerk) und wird dem Dokument zugeordnet. Untertitel, Ausgabe, Veröffentlichungsdatum und
Copyright-Vermerk gehören zur Dokumentfassung (document_meta). Ohne Vorlage bleibt das PDF unverändert.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-24 14:28:34 +01:00
1 parent 81037b9868
commit 765b8e779e
31 files changed
+1272 -33

No files matched your search

@@ -4,11 +4,15 @@
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\DocumentGuide;
use App\Domain\Catalog\DocumentMeta;
use App\Domain\Catalog\DocumentPdf;
use App\Domain\Catalog\DocumentReader;
use App\Domain\Catalog\EditorialWorkingDraft;
use App\Domain\Catalog\EmbeddedImages;
use App\Domain\Catalog\FormattedText;
use App\Domain\Catalog\PdfTemplate;
use App\Domain\Identity\StaffRole;
use App\Filament\Support\EditorialCatalog;
use App\Models\User;
@@ -67,20 +71,66 @@ private function guide(Composition $composition): array
];
}
$draft = app(EditorialWorkingDraft::class)->read($composition);
$ready = $composition->versions()->where('status', ContentVersionStatus::Bereit)->orderByDesc('number')->first();
return [
'title' => app(EditorialCatalog::class)->compositionTitle($composition),
'summary_html' => FormattedText::html($composition->summary),
'pdf_template' => $composition->pdfTemplate,
'meta' => DocumentMeta::normalize($draft !== null ? ($draft['document_meta'] ?? null) : $ready?->document_meta),
'chapters' => $chapters,
];
}
private function authorizeStaff(Composition $composition): void
/**
* Muster-PDF einer Vorlage: ein kurzes Handbuch mit Beispielangaben, damit Titelseite, Kopf, Fuß und Seitenzahlen zu sehen
* sind, ohne ein Dokument zu brauchen.
*/
public function template(PdfTemplate $template): Response
{
$this->authorizeUser();
$table = '<table><tbody><tr><th><p>Zeit</p></th><th><p>Inhalt</p></th></tr><tr><td><p>10 Min.</p></td><td><p>Begrüßung</p></td></tr></tbody></table>';
$chapters = [];
foreach (['Grundlagen' => 1, 'Haltung und Abstand' => 1, 'Vertiefung' => 2] as $title => $level) {
$number = count($chapters) + 1;
$chapters[] = [
'number' => (string) ($level === 1 ? count(array_filter($chapters, fn (array $c): bool => $c['level'] === 1)) + 1 : '2.1'),
'level' => $level,
'anchor' => 'muster-'.$number,
'title' => $title,
'allowed' => true,
'blocks' => FormattedText::blocks('<p>'.str_repeat('Mustertext für die Vorschau der Vorlage. ', 30).'</p><h3>Zwischenüberschrift</h3>'.$table),
];
}
$guide = [
'title' => 'Musterhandbuch',
'pdf_template' => $template,
'meta' => ['subtitle' => 'Beispiel für eine Titelseite', 'edition' => 'Ausgabe 1.0 · Muster', 'published_on' => now()->format('Y-m-d')],
'chapters' => $chapters,
];
return response(app(DocumentPdf::class)->render($guide, 'Vorschau der Redaktion', 'vorschau'), 200, [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="muster.pdf"',
'Cache-Control' => 'private, no-store',
]);
}
private function authorizeUser(): void
{
$user = auth('staff')->user();
abort_unless(
$user instanceof User && ($user->hasStaffRole(StaffRole::Redakteur) || $user->hasStaffRole(StaffRole::Katalogverwalter)),
403,
);
}
private function authorizeStaff(Composition $composition): void
{
$this->authorizeUser();
abort_unless($composition->kind === CompositionKind::Document, 404);
}
}