Mache Anzeige und Tiefe des PDF-Inhaltsverzeichnisses in der Vorlage einstellbar
Die PDF-Vorlage bestimmt, ob das gedruckte Verzeichnis erscheint (automatisch ab zwei Einträgen, immer, nie) und bis zu welcher Stufe es reicht (nur Kapitel, bis Überschrift 3 bis 6). Ohne Verzeichnis beginnt das erste Kapitel auf Seite 1 beziehungsweise nach der Titelseite, ohne leere Seite. Lesezeichen im PDF und das Verzeichnis der Seitenansicht zeigen weiter alle Ebenen. Dokumente ohne Vorlage nutzen automatisch mit voller Tiefe. Additive Migration mit Vorgaben. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9f9370dbf8
commit
e72c9ddb8d
10 files changed
+333
-9
No files matched your search
@@ -44,6 +44,12 @@ class PdfVorlagen extends Page
|
||||
|
||||
public bool $showCover = true;
|
||||
|
||||
/** Inhaltsverzeichnis im PDF: `auto` (nur bei mehr als einem Eintrag), `always`, `never`. */
|
||||
public string $tocModus = 'auto';
|
||||
|
||||
/** Tiefe des Verzeichnisses: 2 = nur Kapitel, 3 bis 6 = bis zu dieser Überschriftenstufe. */
|
||||
public int $tocTiefe = PdfTemplate::TOC_DEPTH_MAX;
|
||||
|
||||
/**
|
||||
* Anordnung von Kopf und Fuß: `full` (Band in voller Seitenbreite), `left` oder `right` (Logo).
|
||||
*
|
||||
@@ -121,7 +127,7 @@ public function changed(): bool
|
||||
$template = $this->templateId > 0 ? PdfTemplate::query()->find($this->templateId) : null;
|
||||
|
||||
if (! $template instanceof PdfTemplate) {
|
||||
return $this->name !== '' || $this->publisher !== '' || $this->copyright !== '' || array_filter($this->bilder) !== [] || $this->layouts() !== [PdfTemplate::normalizeLayout(null, null), PdfTemplate::normalizeLayout(null, null)];
|
||||
return $this->name !== '' || $this->publisher !== '' || $this->copyright !== '' || array_filter($this->bilder) !== [] || $this->layouts() !== [PdfTemplate::normalizeLayout(null, null), PdfTemplate::normalizeLayout(null, null)] || $this->tocSetting() !== PdfTemplate::normalizeToc(null, null);
|
||||
}
|
||||
|
||||
return $this->name !== $template->name
|
||||
@@ -129,7 +135,8 @@ public function changed(): bool
|
||||
|| $this->copyright !== (string) $template->copyright
|
||||
|| $this->showCover !== (bool) $template->show_cover
|
||||
|| $this->bilder !== $this->templateSlots($template)
|
||||
|| $this->layouts() !== [$template->layout('header'), $template->layout('footer')];
|
||||
|| $this->layouts() !== [$template->layout('header'), $template->layout('footer')]
|
||||
|| $this->tocSetting() !== $template->toc();
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
@@ -163,6 +170,8 @@ public function save(): void
|
||||
'header_logo_height' => $this->layouts()[0]['height'],
|
||||
'footer_align' => $this->layouts()[1]['align'],
|
||||
'footer_logo_height' => $this->layouts()[1]['height'],
|
||||
'toc_mode' => $this->tocSetting()['mode'],
|
||||
'toc_depth' => $this->tocSetting()['depth'],
|
||||
'publisher' => trim($this->publisher) === '' ? null : trim($this->publisher),
|
||||
'copyright' => trim($this->copyright) === '' ? null : trim($this->copyright),
|
||||
];
|
||||
@@ -324,6 +333,16 @@ private function loadTemplate(PdfTemplate $template): void
|
||||
$this->bilder = $this->templateSlots($template);
|
||||
$this->anordnung = ['header' => $template->layout('header')['align'], 'footer' => $template->layout('footer')['align']];
|
||||
$this->logohoehe = ['header' => $template->layout('header')['height'], 'footer' => $template->layout('footer')['height']];
|
||||
$this->tocModus = $template->toc()['mode'];
|
||||
$this->tocTiefe = $template->toc()['depth'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{mode: string, depth: int}
|
||||
*/
|
||||
private function tocSetting(): array
|
||||
{
|
||||
return PdfTemplate::normalizeToc($this->tocModus, $this->tocTiefe);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -357,6 +376,8 @@ private function clearForm(): void
|
||||
$this->bilder = ['header' => null, 'footer' => null, 'cover' => null];
|
||||
$this->anordnung = ['header' => 'full', 'footer' => 'full'];
|
||||
$this->logohoehe = ['header' => PdfTemplate::LOGO_DEFAULT, 'footer' => PdfTemplate::LOGO_DEFAULT];
|
||||
$this->tocModus = 'auto';
|
||||
$this->tocTiefe = PdfTemplate::TOC_DEPTH_MAX;
|
||||
}
|
||||
|
||||
protected function pickerExceptId(): int
|
||||
|
||||
Reference in new issue
Block a user