Erlaube in Kopf und Fuß einer PDF-Vorlage ein Logo links oder rechts
Kopf und Fuß haben je eine Anordnung: Band in voller Seitenbreite (Vorgabe, wie bisher), Logo links oder Logo rechts am Textrand. Die Logohöhe ist einstellbar (16 bis 100 Punkt, Vorgabe 40); das Logo ist höchstens halb so breit wie der Text, der Text beginnt darunter beziehungsweise endet darüber. Die Titelseite bleibt unberührt. Additive Migration mit Vorgaben; der vorherige Programmstand zeigt jede Grafik weiter als Band. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b942b5331a
commit
9f9370dbf8
10 files changed
+301
-20
No files matched your search
@@ -44,6 +44,20 @@ class PdfVorlagen extends Page
|
||||
|
||||
public bool $showCover = true;
|
||||
|
||||
/**
|
||||
* Anordnung von Kopf und Fuß: `full` (Band in voller Seitenbreite), `left` oder `right` (Logo).
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public array $anordnung = ['header' => 'full', 'footer' => 'full'];
|
||||
|
||||
/**
|
||||
* Höhe des Logos in Punkt, wenn Kopf oder Fuß ein Logo tragen.
|
||||
*
|
||||
* @var array<string, int|string>
|
||||
*/
|
||||
public array $logohoehe = ['header' => PdfTemplate::LOGO_DEFAULT, 'footer' => PdfTemplate::LOGO_DEFAULT];
|
||||
|
||||
/**
|
||||
* Die Bilder je Bildfeld (header, footer, cover) als Ziel des Pickers: `element:<Fassung>` oder `medium:<Medium>`.
|
||||
*
|
||||
@@ -107,14 +121,15 @@ 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) !== [];
|
||||
return $this->name !== '' || $this->publisher !== '' || $this->copyright !== '' || array_filter($this->bilder) !== [] || $this->layouts() !== [PdfTemplate::normalizeLayout(null, null), PdfTemplate::normalizeLayout(null, null)];
|
||||
}
|
||||
|
||||
return $this->name !== $template->name
|
||||
|| $this->publisher !== (string) $template->publisher
|
||||
|| $this->copyright !== (string) $template->copyright
|
||||
|| $this->showCover !== (bool) $template->show_cover
|
||||
|| $this->bilder !== $this->templateSlots($template);
|
||||
|| $this->bilder !== $this->templateSlots($template)
|
||||
|| $this->layouts() !== [$template->layout('header'), $template->layout('footer')];
|
||||
}
|
||||
|
||||
public function save(): void
|
||||
@@ -144,6 +159,10 @@ public function save(): void
|
||||
...PdfTemplate::columns('header', $this->bilder['header']),
|
||||
...PdfTemplate::columns('footer', $this->bilder['footer']),
|
||||
...PdfTemplate::columns('cover', $this->bilder['cover']),
|
||||
'header_align' => $this->layouts()[0]['align'],
|
||||
'header_logo_height' => $this->layouts()[0]['height'],
|
||||
'footer_align' => $this->layouts()[1]['align'],
|
||||
'footer_logo_height' => $this->layouts()[1]['height'],
|
||||
'publisher' => trim($this->publisher) === '' ? null : trim($this->publisher),
|
||||
'copyright' => trim($this->copyright) === '' ? null : trim($this->copyright),
|
||||
];
|
||||
@@ -303,6 +322,21 @@ private function loadTemplate(PdfTemplate $template): void
|
||||
$this->copyright = (string) $template->copyright;
|
||||
$this->showCover = (bool) $template->show_cover;
|
||||
$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']];
|
||||
}
|
||||
|
||||
/**
|
||||
* Anordnung und Logohöhe von Kopf und Fuß, ungültige Eingaben auf gültige Werte gebracht.
|
||||
*
|
||||
* @return list<array{align: string, height: int}>
|
||||
*/
|
||||
private function layouts(): array
|
||||
{
|
||||
return [
|
||||
PdfTemplate::normalizeLayout($this->anordnung['header'] ?? null, $this->logohoehe['header'] ?? null),
|
||||
PdfTemplate::normalizeLayout($this->anordnung['footer'] ?? null, $this->logohoehe['footer'] ?? null),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,6 +355,8 @@ private function clearForm(): void
|
||||
$this->copyright = '';
|
||||
$this->showCover = true;
|
||||
$this->bilder = ['header' => null, 'footer' => null, 'cover' => null];
|
||||
$this->anordnung = ['header' => 'full', 'footer' => 'full'];
|
||||
$this->logohoehe = ['header' => PdfTemplate::LOGO_DEFAULT, 'footer' => PdfTemplate::LOGO_DEFAULT];
|
||||
}
|
||||
|
||||
protected function pickerExceptId(): int
|
||||
|
||||
Reference in new issue
Block a user