Führe Dokumente mit Kapiteln, Fassung, Seite und PDF mit Inhaltsverzeichnis ein (ADR-51)
Ein Dokument ist eine Komposition der Art document, ein Kapitel ein Text mit der automatischen Materialart Dokumentkapitel; die Ebene steht in der Rolle. Der Aufbaueditor bekommt den Kapitelarbeitsplatz (Übersicht, Ordnen als Block, offene Eingaben bleiben beim Wechsel erhalten, Speichern als Entwurf, Bereitstellen als Dokumentfassung). Module und Programme binden eine Fassung über den gemeinsamen Picker ein. Mitglieder lesen sie mit anklickbarem Inhaltsverzeichnis und laden ein PDF mit Inhaltsverzeichnis, Seitenzahlen, Tabellen und Bildern. Ein älterer Stand liefert die gebundene Fassung weiter. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c57a506f85
commit
3e2fd872c2
43 files changed
+2827
-64
No files matched your search
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\DocumentGuide;
|
||||
use App\Domain\Catalog\DocumentPdf;
|
||||
use App\Domain\Catalog\DocumentReader;
|
||||
use App\Domain\Catalog\EmbeddedImages;
|
||||
use App\Domain\Catalog\FormattedText;
|
||||
use App\Domain\Identity\StaffRole;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
* Vorschau eines Dokuments für die Redaktion: der gespeicherte Entwurf, sonst die letzte bereitgestellte Fassung, so wie ein
|
||||
* Mitglied sie als Seite und als PDF sieht (ohne Rechteprüfung und ohne Ausgabenachweis). Ungespeicherte Eingaben im Editor
|
||||
* erscheinen hier erst nach „Entwurf speichern“.
|
||||
*/
|
||||
class DocumentPreviewController extends Controller
|
||||
{
|
||||
public function show(Composition $composition): View
|
||||
{
|
||||
$this->authorizeStaff($composition);
|
||||
$guide = $this->guide($composition);
|
||||
$images = EmbeddedImages::staff();
|
||||
|
||||
foreach ($guide['chapters'] as $index => $chapter) {
|
||||
$guide['chapters'][$index]['html'] = DocumentGuide::shiftHeadings(FormattedText::html($chapter['version']->body, $images));
|
||||
}
|
||||
|
||||
return view('document.preview', ['guide' => $guide, 'composition' => $composition, 'pdfUrl' => route('editorial.document-preview.pdf', $composition)]);
|
||||
}
|
||||
|
||||
public function pdf(Composition $composition): Response
|
||||
{
|
||||
$this->authorizeStaff($composition);
|
||||
$content = app(DocumentPdf::class)->render($this->guide($composition), 'Vorschau der Redaktion', 'vorschau', EmbeddedImages::forStaffPdf());
|
||||
|
||||
return response($content, 200, [
|
||||
'Content-Type' => 'application/pdf',
|
||||
'Content-Disposition' => 'inline; filename="vorschau.pdf"',
|
||||
'Cache-Control' => 'private, no-store',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function guide(Composition $composition): array
|
||||
{
|
||||
$chapters = app(DocumentReader::class)->forStaff($composition);
|
||||
abort_if($chapters === null, 404);
|
||||
|
||||
foreach ($chapters as $index => $chapter) {
|
||||
$chapters[$index] += [
|
||||
'allowed' => true,
|
||||
'grant' => null,
|
||||
'may_download' => true,
|
||||
'download_grant' => null,
|
||||
'state' => 'ok',
|
||||
'html' => null,
|
||||
'blocks' => FormattedText::blocks($chapter['version']->body),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'title' => app(EditorialCatalog::class)->compositionTitle($composition),
|
||||
'summary_html' => FormattedText::html($composition->summary),
|
||||
'chapters' => $chapters,
|
||||
];
|
||||
}
|
||||
|
||||
private function authorizeStaff(Composition $composition): void
|
||||
{
|
||||
$user = auth('staff')->user();
|
||||
abort_unless(
|
||||
$user instanceof User && ($user->hasStaffRole(StaffRole::Redakteur) || $user->hasStaffRole(StaffRole::Katalogverwalter)),
|
||||
403,
|
||||
);
|
||||
abort_unless($composition->kind === CompositionKind::Document, 404);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user