*/ public const BACKGROUNDS = [ 'default' => 'Standard (ohne eigene Fläche)', 'light' => 'Helle Markenfläche', 'dark' => 'Dunkle Markenfläche', 'accent' => 'Markenakzent', 'image' => 'Hintergrundbild', ]; /** @var array */ public const WIDTHS = [ 'narrow' => 'Schmal (Lesebreite)', 'standard' => 'Standard', 'wide' => 'Breit', 'full' => 'Volle Breite', ]; /** @var array */ public const SPACINGS = [ 'compact' => 'Kompakt', 'normal' => 'Normal', 'large' => 'Großzügig', ]; /** @var array */ public const DIVIDERS = [ 'none' => 'Kein Trenner', 'space' => 'Zusätzlicher Abstand', 'line' => 'Dezente Linie', 'accent' => 'Markenakzent', ]; /** @var array */ public const OVERLAYS = [ 'light' => 'Helle Überlagerung (dunkle Schrift)', 'dark' => 'Dunkle Überlagerung (helle Schrift)', 'none' => 'Keine Überlagerung', ]; /** @var array */ public const FOCUS = [ 'center' => 'Mitte', 'top' => 'Oben', 'bottom' => 'Unten', 'left' => 'Links', 'right' => 'Rechts', 'top_left' => 'Oben links', 'top_right' => 'Oben rechts', 'bottom_left' => 'Unten links', 'bottom_right' => 'Unten rechts', ]; /** Fokuspunkt als Objektposition des Bildes; bestimmt den Zuschnitt auf schmalen Bildschirmen. */ public const FOCUS_POSITIONS = [ 'center' => '50% 50%', 'top' => '50% 0%', 'bottom' => '50% 100%', 'left' => '0% 50%', 'right' => '100% 50%', 'top_left' => '0% 0%', 'top_right' => '100% 0%', 'bottom_left' => '0% 100%', 'bottom_right' => '100% 100%', ]; public const DEFAULTS = [ 'background' => 'default', 'image' => null, 'focus' => 'center', 'overlay' => 'light', 'width' => 'standard', 'spacing' => 'normal', 'divider' => 'none', ]; /** * Aufzählungsfelder und ihre zulässigen Werte. * * @return array> */ public static function enums(): array { return [ 'background' => self::BACKGROUNDS, 'focus' => self::FOCUS, 'overlay' => self::OVERLAYS, 'width' => self::WIDTHS, 'spacing' => self::SPACINGS, 'divider' => self::DIVIDERS, ]; } /** * Lesepfad: gespeicherte Werte; Unbekanntes fällt auf die Vorgabe zurück, damit alte oder fremde Daten * nie eine Seite brechen. * * @return array{background: string, image: ?string, focus: string, overlay: string, width: string, spacing: string, divider: string} */ public static function fromStored(mixed $style): array { $style = is_array($style) ? $style : []; $result = self::DEFAULTS; foreach (self::enums() as $key => $options) { $value = $style[$key] ?? null; if (is_string($value) && array_key_exists($value, $options)) { $result[$key] = $value; } } $result['image'] = $result['background'] === 'image' && is_string($style['image'] ?? null) ? $style['image'] : null; return $result; } /** * Kurzbeschreibung für die Abschnittsliste im Editor. * * @param array $style */ public static function summary(array $style): string { $style = self::fromStored($style); $parts = [self::BACKGROUNDS[$style['background']]]; if ($style['width'] !== 'standard') { $parts[] = self::WIDTHS[$style['width']]; } if ($style['spacing'] !== 'normal') { $parts[] = 'Abstand '.mb_strtolower(self::SPACINGS[$style['spacing']]); } if ($style['divider'] !== 'none') { $parts[] = 'Trenner: '.self::DIVIDERS[$style['divider']]; } return implode(' · ', $parts); } }