Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4be6ed8dc | ||
|
|
053a8d4648 | ||
|
|
7c63424ea6 | ||
|
|
13530b8171 | ||
|
|
72130d66c5 | ||
|
|
d37a7093dd | ||
|
|
3e56314cf9 | ||
|
|
8a6678aad7 | ||
|
|
b178939852 | ||
|
|
a08067c078 | ||
|
|
bc1f84ac89 | ||
|
|
39ab25d8c6 | ||
|
|
127ea86817 | ||
|
|
cca069be48 | ||
|
|
f511ad10de | ||
|
|
f4d225d0b2 | ||
|
|
89fd95b243 | ||
|
|
87a7ffc45f | ||
|
|
0bfb53463a | ||
|
|
3cdb36e7a3 | ||
|
|
5dccbbce80 | ||
|
|
8a3f6df770 | ||
|
|
656f999d2c | ||
|
|
8387cc90df | ||
|
|
d89d4bdc70 | ||
|
|
7c1caec546 | ||
|
|
8390dcdb41 | ||
|
|
33aaf64024 | ||
|
|
3a5e5290f1 | ||
|
|
c6186fba6e | ||
|
|
dc33f0ee37 | ||
|
|
6152451e2e | ||
|
|
4cad60259a | ||
|
|
2ac2923852 | ||
|
|
480d55989b |
No files matched your search
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageRevision;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Console\Command;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Wiederherstellungsweg vor einem Code-Rollback (docs/architektur/cms-widget-registry.md, Abschnitt Rollback).
|
||||
*
|
||||
* Setzt die veröffentlichte Revision jeder Seite auf die letzte Revision, die vor dem angegebenen Zeitpunkt
|
||||
* gespeichert wurde. Revisionen werden weder geändert noch gelöscht; nur der Veröffentlichungszeiger wechselt.
|
||||
* Ohne --apply wird nur angezeigt, was geschähe.
|
||||
*/
|
||||
class RevertPublishedPages extends Command
|
||||
{
|
||||
protected $signature = 'cms:revert-published
|
||||
{--before= : Zeitpunkt des Deployments, zum Beispiel "2026-11-17 18:00" (Zeitzone der Anwendung)}
|
||||
{--apply : Änderung tatsächlich ausführen}';
|
||||
|
||||
protected $description = 'Setzt veröffentlichte Seiten auf ihren Stand vor einem Zeitpunkt zurück (nur Veröffentlichungszeiger).';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
try {
|
||||
$before = blank($this->option('before')) ? null : CarbonImmutable::parse((string) $this->option('before'));
|
||||
} catch (Throwable) {
|
||||
$before = null;
|
||||
}
|
||||
|
||||
if ($before === null) {
|
||||
$this->error('Bitte --before mit einem gültigen Zeitpunkt angeben.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$apply = (bool) $this->option('apply');
|
||||
$rows = [];
|
||||
|
||||
foreach (Page::query()->whereNotNull('published_revision_id')->with('publishedRevision')->orderBy('path')->get() as $page) {
|
||||
$current = $page->publishedRevision;
|
||||
|
||||
if ($current === null || $current->created_at < $before) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$previous = PageRevision::query()
|
||||
->where('page_id', $page->id)
|
||||
->where('created_at', '<', $before)
|
||||
->latest('id')
|
||||
->first();
|
||||
|
||||
if ($previous === null) {
|
||||
$rows[] = [$page->path, $current->id, '–', 'keine ältere Revision: Seite wird zurückgezogen'];
|
||||
if ($apply) {
|
||||
$page->published_revision_id = null;
|
||||
$page->save();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$rows[] = [$page->path, $current->id, $previous->id, $apply ? 'zurückgesetzt' : 'würde zurückgesetzt'];
|
||||
if ($apply) {
|
||||
$page->published_revision_id = $previous->id;
|
||||
$page->save();
|
||||
}
|
||||
}
|
||||
|
||||
if ($rows === []) {
|
||||
$this->info('Keine veröffentlichte Seite stammt aus der Zeit ab '.$before->format('d.m.Y H:i').'.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$this->table(['Pfad', 'veröffentlicht', 'neu veröffentlicht', 'Ergebnis'], $rows);
|
||||
|
||||
if (! $apply) {
|
||||
$this->warn('Probelauf. Mit --apply ausführen.');
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,10 @@ class ContentElement extends Model
|
||||
'description',
|
||||
'usage_note',
|
||||
'license_note',
|
||||
'website_credit',
|
||||
'website_alt',
|
||||
'website_released_at',
|
||||
'website_public_path',
|
||||
'summary',
|
||||
'thumbnail_path',
|
||||
'thumbnail_alt',
|
||||
@@ -30,6 +34,7 @@ protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'archived_at' => 'datetime',
|
||||
'website_released_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Catalog;
|
||||
|
||||
/**
|
||||
* Anzeigedaten des Fachobjekts hinter einer Premium-Karte (Thema, Medium/Material, Programm/Modul).
|
||||
* Wird zur Laufzeit aus den maßgeblichen Fachdaten gelesen und nie im CMS gespeichert.
|
||||
*
|
||||
* - url: nur ein öffentlich freigegebenes Ziel aus dem Fachobjekt (Themenseite, Programmseite), sonst null.
|
||||
* - public: false heißt „nur in der Redaktionsvorschau“; öffentlich entfällt die Karte dann.
|
||||
* - notice: redaktioneller Hinweis für die Vorschau, warum die Karte öffentlich nicht erscheint.
|
||||
* - visual: Darstellung ohne Kartenbild: 'film' (Medientafel Film), 'material' (Materialsymbol),
|
||||
* 'catalog' (Navy-Tafel Programm/Modul) oder null (Karte ohne Bildbereich).
|
||||
* - previewImage: geschütztes Vorschaubild der Bibliothek (Filmstandbild, Vorschau des Moduls). Nur für die
|
||||
* Redaktionsvorschau (Route editorial.card, nur für angemeldete Redaktion); öffentlich nie ausgegeben, weil es
|
||||
* keine Freigabe für die Website hat.
|
||||
* - missing: was für eine vollständige Karte fehlt, als Hinweis nur in der Redaktionsvorschau.
|
||||
*/
|
||||
final readonly class CardSubject
|
||||
{
|
||||
/**
|
||||
* @param list<string> $meta reine Anzeigetexte aus Fachdaten
|
||||
* @param list<string> $missing Hinweise für die Redaktion
|
||||
*/
|
||||
public function __construct(
|
||||
public string $title,
|
||||
public ?string $summary,
|
||||
public string $kind,
|
||||
public ?string $badge,
|
||||
public array $meta,
|
||||
public ?string $url,
|
||||
public bool $public,
|
||||
public ?string $notice = null,
|
||||
public ?string $visual = null,
|
||||
public ?string $visualLabel = null,
|
||||
public ?string $previewImage = null,
|
||||
public array $missing = [],
|
||||
public ?string $style = null,
|
||||
) {}
|
||||
}
|
||||
@@ -5,7 +5,9 @@
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
@@ -171,6 +173,162 @@ public function entries(array $refs, bool $includeNonPublic): array
|
||||
return $entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Für die Programm- oder Modulkarte wählbar: Programm oder Modul, nicht archiviert, mit mindestens einer
|
||||
* bereitgestellten Fassung. Anders als bei den Katalogkarten ist keine Anzeigefreigabe nötig, damit die Redaktion
|
||||
* eine Karte vorbereiten kann; öffentlich gilt unverändert isPublic().
|
||||
*/
|
||||
public function isCardSelectable(Composition $composition): bool
|
||||
{
|
||||
return $composition->archived_at === null
|
||||
&& in_array($composition->editorialContentKind?->slug, self::SELECTABLE_KINDS, true)
|
||||
&& $this->latestReadyVersion($composition) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function cardSearch(?string $term, int $limit = 25): array
|
||||
{
|
||||
$term = trim((string) $term);
|
||||
|
||||
$candidates = Composition::query()
|
||||
->with('editorialContentKind')
|
||||
->whereNull('archived_at')
|
||||
->whereHas('editorialContentKind', fn ($query) => $query->whereIn('slug', self::SELECTABLE_KINDS))
|
||||
->when($term !== '', function ($query) use ($term): void {
|
||||
$like = '%'.mb_strtolower($term).'%';
|
||||
$query->where(fn ($inner) => $inner
|
||||
->whereRaw('LOWER(designation) LIKE ?', [$like])
|
||||
->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like]));
|
||||
})
|
||||
->orderBy('designation')
|
||||
->limit($limit * 3)
|
||||
->get();
|
||||
|
||||
$options = [];
|
||||
foreach ($candidates as $composition) {
|
||||
if (! $this->isCardSelectable($composition)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$options[$composition->id] = $this->cardOptionLabel($composition);
|
||||
|
||||
if (count($options) >= $limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function cardLabelFor(mixed $id): ?string
|
||||
{
|
||||
$composition = is_numeric($id) ? Composition::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
return $composition === null ? null : $this->cardOptionLabel($composition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Anzeigedaten für eine Programm- oder Modulkarte (Premium-Karte).
|
||||
*
|
||||
* - Öffentlich nur Programme mit Anzeigefreigabe (dieselbe Regel wie /programme), mit Programmseite als Ziel.
|
||||
* Module haben keine öffentliche Seitenart (ADR-29) und erscheinen nur in der Redaktionsvorschau, ohne Link.
|
||||
* - Text: Kurzbeschreibung, sonst das Lernziel der gezeigten (öffentlich) bzw. neuesten bereitgestellten Fassung;
|
||||
* das Lernziel steht auf der öffentlichen Programmseite bereits öffentlich.
|
||||
* - Zusatzangaben: Zahl der Module, Dauer. Kein Preis, kein Angebot, keine Kaufaktion; eine Karte ist kein
|
||||
* Lizenzartikel. Das Vorschaubild der Bibliothek erscheint nur in der Redaktionsvorschau.
|
||||
*/
|
||||
public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
||||
{
|
||||
$composition = is_numeric($id) ? Composition::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
if ($composition === null || ! $this->isCardSelectable($composition)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$shown = $this->shownVersion($composition);
|
||||
$public = $shown !== null && $composition->archived_at === null;
|
||||
|
||||
if (! $public && ! $includeNonPublic) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$version = $shown ?? $this->latestReadyVersion($composition);
|
||||
$program = $composition->editorialContentKind?->slug === 'programm';
|
||||
$kind = (string) ($composition->editorialContentKind?->label ?? ($program ? 'Programm' : 'Modul'));
|
||||
$summary = filled($composition->summary) ? trim((string) $composition->summary) : null;
|
||||
$goal = filled($version?->learning_goal) ? trim((string) $version->learning_goal) : null;
|
||||
$missing = [];
|
||||
|
||||
if ($summary === null) {
|
||||
$missing[] = $goal !== null
|
||||
? 'Keine Kurzbeschreibung gepflegt; die Karte zeigt das Lernziel.'
|
||||
: 'Weder Kurzbeschreibung noch Lernziel gepflegt.';
|
||||
}
|
||||
|
||||
$meta = [];
|
||||
if ($version !== null) {
|
||||
$modules = $version->members()
|
||||
->whereNotNull('nested_composition_version_id')
|
||||
->with('nestedCompositionVersion.composition.editorialContentKind')
|
||||
->get()
|
||||
->filter(fn ($member): bool => $member->nestedCompositionVersion?->composition?->editorialContentKind?->slug === 'modul')
|
||||
->count();
|
||||
|
||||
if ($program && $modules > 0) {
|
||||
$meta[] = $modules === 1 ? '1 Modul' : $modules.' Module';
|
||||
}
|
||||
|
||||
if (is_numeric($version->duration_minutes) && (int) $version->duration_minutes > 0) {
|
||||
$meta[] = 'Dauer '.(int) $version->duration_minutes.' Min.';
|
||||
} else {
|
||||
$missing[] = 'Keine Dauer gepflegt.';
|
||||
}
|
||||
}
|
||||
|
||||
$notice = null;
|
||||
if (! $public) {
|
||||
$notice = 'Nur in der Redaktionsvorschau sichtbar: '.($program
|
||||
? 'Das Programm hat keine Anzeigefreigabe.'
|
||||
: 'Für Module gibt es noch keine öffentliche Seitenart (öffentliches Profil, ADR-29); die Karte erhält deshalb keinen Link.');
|
||||
}
|
||||
|
||||
return new CardSubject(
|
||||
title: $this->title($composition),
|
||||
summary: $summary ?? $goal,
|
||||
kind: $kind,
|
||||
badge: null,
|
||||
meta: $meta,
|
||||
url: $public ? route('public.program', $composition) : null,
|
||||
public: $public,
|
||||
notice: $notice,
|
||||
visual: 'catalog',
|
||||
visualLabel: $kind,
|
||||
previewImage: $includeNonPublic ? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path) : null,
|
||||
missing: $missing,
|
||||
);
|
||||
}
|
||||
|
||||
private function latestReadyVersion(Composition $composition): ?CompositionVersion
|
||||
{
|
||||
return $composition->versions()
|
||||
->where('status', ContentVersionStatus::Bereit->value)
|
||||
->orderByDesc('number')
|
||||
->first();
|
||||
}
|
||||
|
||||
private function cardOptionLabel(Composition $composition): string
|
||||
{
|
||||
$visibility = match (true) {
|
||||
$this->isPublic($composition) => 'öffentlich sichtbar',
|
||||
$composition->editorialContentKind?->slug === 'modul' => 'Modul, nur Redaktionsvorschau',
|
||||
default => 'ohne Anzeigefreigabe, nur Redaktionsvorschau',
|
||||
};
|
||||
|
||||
return $this->title($composition).' · '.($composition->editorialContentKind?->label ?? '').' · '.$visibility;
|
||||
}
|
||||
|
||||
private function title(Composition $composition): string
|
||||
{
|
||||
return (string) ($composition->display_title ?: $composition->designation);
|
||||
|
||||
@@ -0,0 +1,272 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Catalog;
|
||||
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\StructureNode;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
|
||||
/**
|
||||
* Lesesicht „Medien und Materialien“ für Premium-Karten (Website-CMS-Zielarchitektur 6.2).
|
||||
*
|
||||
* Auswahl in der Redaktion: jedes nicht archivierte Inhaltselement mit mindestens einer nicht gesperrten Fassung.
|
||||
*
|
||||
* Öffentliche Sichtbarkeit (Übergangsregel, solange öffentliche Fachobjektprofile nach ADR-29 fehlen):
|
||||
* Ein Medium hat keine eigene öffentliche Seite. Öffentlich genannt wird es heute nur als Bestandteil der gezeigten
|
||||
* Fassung eines öffentlichen Programms (Programmseite /programme/{id}). Genau dann erscheint auch die Karte
|
||||
* öffentlich, mit Verweis auf diese Programmseite, und nur mit bereitgestellter Fassung. Traineranleitungen erscheinen
|
||||
* nie öffentlich (vertraulich für Trainerinnen und Trainer).
|
||||
*
|
||||
* Öffentlich gelesen werden Anzeigetitel (sonst Arbeitstitel), Kurzbeschreibung, Inhaltsart und Ausgabeart. Nie:
|
||||
* Beschreibung, Einsatzhinweis, Lizenzvermerk, Dateien, Lehrtexte, Ausgabeadressen. Das Vorschaubild (Filmstandbild)
|
||||
* der Bibliothek ist nicht für die Website freigegeben; es erscheint nur in der Redaktionsvorschau.
|
||||
* Eine Karte spielt nichts ab, bietet keinen Download und gibt kein Medium frei.
|
||||
*/
|
||||
class PublicMaterialReader
|
||||
{
|
||||
/** Inhaltsarten, die nie öffentlich auf einer Karte erscheinen. */
|
||||
public const CONFIDENTIAL_KINDS = ['traineranleitung'];
|
||||
|
||||
/** @var array<int, array{id: int, title: string}>|null Element-ID => erstes öffentliches Programm */
|
||||
private ?array $publicIndex = null;
|
||||
|
||||
public function __construct(
|
||||
private readonly PublicCatalogReader $catalog,
|
||||
private readonly CompositionStructureReader $structure,
|
||||
) {}
|
||||
|
||||
public function isSelectable(ContentElement $element): bool
|
||||
{
|
||||
return $element->archived_at === null
|
||||
&& $element->versions()->where('status', '!=', ContentVersionStatus::Gesperrt->value)->exists();
|
||||
}
|
||||
|
||||
public function isReady(ContentElement $element): bool
|
||||
{
|
||||
return $element->versions()->where('status', ContentVersionStatus::Bereit->value)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Öffentliches Programm, in dessen gezeigter Fassung das Element vorkommt, sonst null.
|
||||
*
|
||||
* @return array{id: int, title: string}|null
|
||||
*/
|
||||
public function publicProgramFor(ContentElement $element): ?array
|
||||
{
|
||||
return $this->publicIndex()[$element->id] ?? null;
|
||||
}
|
||||
|
||||
public function isPublic(ContentElement $element): bool
|
||||
{
|
||||
return $this->isSelectable($element)
|
||||
&& $this->isReady($element)
|
||||
&& ! in_array($element->editorialContentKind?->slug, self::CONFIDENTIAL_KINDS, true)
|
||||
&& $this->publicProgramFor($element) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function search(?string $term, int $limit = 25): array
|
||||
{
|
||||
$term = trim((string) $term);
|
||||
|
||||
$candidates = ContentElement::query()
|
||||
->with('editorialContentKind')
|
||||
->whereNull('archived_at')
|
||||
->whereHas('versions', fn ($query) => $query->where('status', '!=', ContentVersionStatus::Gesperrt->value))
|
||||
->when($term !== '', function ($query) use ($term): void {
|
||||
$like = '%'.mb_strtolower($term).'%';
|
||||
$query->where(fn ($inner) => $inner
|
||||
->whereRaw('LOWER(working_title) LIKE ?', [$like])
|
||||
->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like]));
|
||||
})
|
||||
->orderBy('working_title')
|
||||
->limit($limit)
|
||||
->get();
|
||||
|
||||
$options = [];
|
||||
foreach ($candidates as $element) {
|
||||
$options[$element->id] = $this->optionLabel($element);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function labelFor(mixed $id): ?string
|
||||
{
|
||||
$element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
return $element === null ? null : $this->optionLabel($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Anzeigedaten für eine Karte. Öffentlich null, wenn das Element nicht öffentlich genannt wird.
|
||||
*
|
||||
* @param array<string, mixed> $draft ungespeicherte Anzeigedaten, nur für die Redaktionsvorschau
|
||||
*/
|
||||
public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?CardSubject
|
||||
{
|
||||
$element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
if ($element === null || ! $this->isSelectable($element)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$public = $this->isPublic($element);
|
||||
|
||||
if (! $public && ! $includeNonPublic) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$shown = clone $element;
|
||||
|
||||
foreach (['working_title', 'display_title', 'summary', 'thumbnail_path', 'thumbnail_alt'] as $field) {
|
||||
if (! array_key_exists($field, $draft)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = $draft[$field];
|
||||
$shown->setAttribute($field, is_string($value) && trim($value) === '' ? null : $value);
|
||||
}
|
||||
|
||||
$program = $this->publicProgramFor($element);
|
||||
$output = self::outputLabel((string) $shown->output_class);
|
||||
$film = $shown->output_class === 'film';
|
||||
$editorialKind = $element->editorialContentKind?->label;
|
||||
$summary = filled($shown->summary) ? trim((string) $shown->summary) : null;
|
||||
|
||||
$meta = [$output];
|
||||
if ($program !== null) {
|
||||
$meta[] = 'Im Programm „'.$program['title'].'“';
|
||||
}
|
||||
if ($film) {
|
||||
$meta[] = 'Vollständiger Film nur mit Lizenz im Mitgliederbereich';
|
||||
}
|
||||
|
||||
$missing = [];
|
||||
if ($summary === null) {
|
||||
$missing[] = 'Keine Kurzbeschreibung gepflegt (Medium bearbeiten → Kurzbeschreibung).';
|
||||
}
|
||||
if (! filled($shown->display_title)) {
|
||||
$missing[] = 'Kein Anzeigetitel gepflegt; die Karte zeigt den Arbeitstitel.';
|
||||
}
|
||||
|
||||
$previewImage = $includeNonPublic ? ThumbnailRef::url('editorial.card', 'element', (int) $element->id, $shown->thumbnail_path) : null;
|
||||
|
||||
return new CardSubject(
|
||||
title: (string) ($shown->display_title ?: $shown->working_title),
|
||||
summary: $summary,
|
||||
kind: filled($editorialKind) ? (string) $editorialKind : $output,
|
||||
badge: $output,
|
||||
meta: $meta,
|
||||
url: $public && $program !== null ? route('public.program', $program['id']) : null,
|
||||
public: $public,
|
||||
notice: $public ? null : $this->notice($element, $program),
|
||||
visual: $film ? 'film' : 'material',
|
||||
visualLabel: $output,
|
||||
previewImage: $previewImage,
|
||||
missing: $missing,
|
||||
style: $film ? 'media' : 'material',
|
||||
);
|
||||
}
|
||||
|
||||
/** Bezeichnung der Ausgabeart, wie in der Redaktionsstruktur (CompositionRelease::outputLabel). */
|
||||
public static function outputLabel(string $outputClass): string
|
||||
{
|
||||
return match ($outputClass) {
|
||||
'film' => 'Film',
|
||||
'audio' => 'Hörstück',
|
||||
'bild' => 'Bild',
|
||||
'document', 'pdf' => 'Dokument',
|
||||
default => 'Text',
|
||||
};
|
||||
}
|
||||
|
||||
public function visibilityNote(ContentElement $element): string
|
||||
{
|
||||
if ($this->isPublic($element)) {
|
||||
$program = $this->publicProgramFor($element);
|
||||
|
||||
return 'Öffentlich nur als Teil der Programmseite „'.($program['title'] ?? '').'“. Die Mediendatei wird dabei nicht ausgeliefert.';
|
||||
}
|
||||
|
||||
return $this->notice($element, $this->publicProgramFor($element));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{id: int, title: string}|null $program
|
||||
*/
|
||||
private function notice(ContentElement $element, ?array $program): string
|
||||
{
|
||||
$reason = match (true) {
|
||||
in_array($element->editorialContentKind?->slug, self::CONFIDENTIAL_KINDS, true) => 'Traineranleitungen erscheinen nie öffentlich.',
|
||||
! $this->isReady($element) => 'Das Medium hat noch keine bereitgestellte Fassung.',
|
||||
$program === null => 'Das Medium gehört zu keinem öffentlich gezeigten Programm. Medien haben noch keine eigene öffentliche Freigabe (öffentliches Profil, ADR-29).',
|
||||
default => 'Das Medium ist nicht öffentlich.',
|
||||
};
|
||||
|
||||
return 'Nur in der Redaktionsvorschau sichtbar: '.$reason;
|
||||
}
|
||||
|
||||
private function optionLabel(ContentElement $element): string
|
||||
{
|
||||
$visibility = $this->isPublic($element)
|
||||
? 'öffentlich über Programmseite'
|
||||
: ($this->isReady($element) ? 'nur Redaktionsvorschau' : 'Entwurf, nur Redaktionsvorschau');
|
||||
$kind = $element->editorialContentKind?->label ?: self::outputLabel((string) $element->output_class);
|
||||
|
||||
return (string) ($element->display_title ?: $element->working_title).' · '.$kind.' · '.$visibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index aller Elemente, die in der gezeigten Fassung eines öffentlichen Programms vorkommen (auch verschachtelt).
|
||||
*
|
||||
* @return array<int, array{id: int, title: string}>
|
||||
*/
|
||||
private function publicIndex(): array
|
||||
{
|
||||
if ($this->publicIndex !== null) {
|
||||
return $this->publicIndex;
|
||||
}
|
||||
|
||||
$index = [];
|
||||
|
||||
foreach ($this->catalog->publicPrograms() as $program) {
|
||||
$version = $this->catalog->shownVersion($program);
|
||||
|
||||
if ($version === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$entry = ['id' => (int) $program->id, 'title' => (string) ($program->display_title ?: $program->designation)];
|
||||
|
||||
foreach ($this->elementIds($this->structure->tree($version)) as $elementId) {
|
||||
$index[$elementId] ??= $entry;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->publicIndex = $index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<StructureNode> $nodes
|
||||
* @return list<int>
|
||||
*/
|
||||
private function elementIds(array $nodes): array
|
||||
{
|
||||
$ids = [];
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
if ($node->contentElementId !== null) {
|
||||
$ids[] = (int) $node->contentElementId;
|
||||
}
|
||||
|
||||
array_push($ids, ...$this->elementIds($node->children));
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,25 @@
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class NavigationItem extends Model
|
||||
{
|
||||
/**
|
||||
* Plätze im globalen Website-Gerüst. Die drei Fußbereichsgruppen ersetzen eine eigene Footer-Verwaltung.
|
||||
*/
|
||||
public const PLACEMENTS = [
|
||||
'header' => 'Kopfzeile',
|
||||
'footer' => 'Fußzeile',
|
||||
'header' => 'Kopfzeile (Hauptnavigation)',
|
||||
'footer' => 'Fußbereich: Service',
|
||||
'footer_contact' => 'Fußbereich: Kontakt',
|
||||
'footer_legal' => 'Fußbereich: Rechtliches',
|
||||
];
|
||||
|
||||
/** Spaltenüberschriften im Fußbereich. */
|
||||
public const FOOTER_GROUPS = [
|
||||
'footer' => 'Service',
|
||||
'footer_contact' => 'Kontakt',
|
||||
'footer_legal' => 'Rechtliches',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
@@ -21,8 +34,19 @@ class NavigationItem extends Model
|
||||
'placement',
|
||||
'sort_order',
|
||||
'is_visible',
|
||||
'parent_id',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
// Untermenüs gibt es nur in der Hauptnavigation.
|
||||
static::saving(function (NavigationItem $item): void {
|
||||
if ($item->placement !== 'header' && $item->getAttribute('parent_id') !== null) {
|
||||
$item->parent_id = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
@@ -35,6 +59,16 @@ public function page(): BelongsTo
|
||||
return $this->belongsTo(Page::class);
|
||||
}
|
||||
|
||||
public function parent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(self::class, 'parent_id')->orderBy('sort_order')->orderBy('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<NavigationItem> $query
|
||||
*/
|
||||
@@ -59,4 +93,22 @@ public function href(): ?string
|
||||
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pfad des Ziels innerhalb der Website (für die Kennzeichnung des aktiven Eintrags); null bei externen Zielen.
|
||||
*/
|
||||
public function targetPath(): ?string
|
||||
{
|
||||
if ($this->page !== null) {
|
||||
return $this->page->path;
|
||||
}
|
||||
|
||||
if (is_string($this->url) && str_starts_with($this->url, '/') && ! str_starts_with($this->url, '//')) {
|
||||
$path = parse_url($this->url, PHP_URL_PATH);
|
||||
|
||||
return is_string($path) ? '/'.trim($path, '/') : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Domain\Cms;
|
||||
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use App\Domain\Cms\Sections\PageSections;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -14,6 +14,7 @@ class PageRevision extends Model
|
||||
protected $fillable = [
|
||||
'page_id',
|
||||
'blocks',
|
||||
'sections',
|
||||
'seo_title',
|
||||
'seo_description',
|
||||
'created_by',
|
||||
@@ -23,6 +24,7 @@ protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'blocks' => 'array',
|
||||
'sections' => 'array',
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
@@ -38,13 +40,24 @@ public function author(): BelongsTo
|
||||
}
|
||||
|
||||
/**
|
||||
* Bausteine als aktuelle Widget-Hüllen. Die gespeicherten Daten bleiben unverändert.
|
||||
* Abschnitte als aktuelle Hüllen. Revisionen ohne Abschnitte (vor Einführung des Rasters) werden als
|
||||
* einspaltige Abschnitte gelesen. Die gespeicherten Daten bleiben unverändert.
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function sections(): array
|
||||
{
|
||||
return app(PageSections::class)->read($this->sections, $this->blocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Widgets in Lesereihenfolge als aktuelle Hüllen.
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function widgets(): array
|
||||
{
|
||||
return app(WidgetRegistry::class)->read($this->blocks);
|
||||
return app(PageSections::class)->flatten($this->sections());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,6 +65,6 @@ public function widgets(): array
|
||||
*/
|
||||
public function contentTitle(): ?string
|
||||
{
|
||||
return app(WidgetRegistry::class)->pageTitle($this->blocks);
|
||||
return app(PageSections::class)->pageTitle($this->sections());
|
||||
}
|
||||
}
|
||||
@@ -2,23 +2,35 @@
|
||||
|
||||
namespace App\Domain\Cms;
|
||||
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use App\Domain\Cms\Sections\PageSections;
|
||||
use App\Jobs\PublishPublicMedia;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class PageService
|
||||
{
|
||||
public function __construct(private readonly WidgetRegistry $widgets) {}
|
||||
public function __construct(private readonly PageSections $sections) {}
|
||||
|
||||
/**
|
||||
* Speichert einen Entwurf als neue Revision. Veröffentlicht nichts.
|
||||
*
|
||||
* @param array<int|string, mixed> $blocks Bausteine im Altformat oder als Widget-Hülle
|
||||
* @param array<int|string, mixed> $content Abschnitte mit Slots; flache Widgets (Altformat oder Hülle)
|
||||
* werden als einspaltige Abschnitte übernommen
|
||||
*/
|
||||
public function saveRevision(Page $page, array $blocks, ?string $seoTitle, ?string $seoDescription, ?User $author): PageRevision
|
||||
public function saveRevision(Page $page, array $content, ?string $seoTitle, ?string $seoDescription, ?User $author): PageRevision
|
||||
{
|
||||
return $this->storeRevision($page, $this->widgets->normalize($blocks), $seoTitle, $seoDescription, $author);
|
||||
$sections = $this->sections->normalize($content);
|
||||
$seoTitle = $seoTitle !== null && $seoTitle !== '' ? $seoTitle : null;
|
||||
$seoDescription = $seoDescription !== null && $seoDescription !== '' ? $seoDescription : null;
|
||||
|
||||
// Unveränderter Stand: keine weitere Revision (zum Beispiel „Veröffentlichen“ direkt nach dem Speichern).
|
||||
$latest = $page->revisions()->first();
|
||||
if ($latest !== null && $latest->sections === $sections && $latest->seo_title === $seoTitle && $latest->seo_description === $seoDescription) {
|
||||
return $latest;
|
||||
}
|
||||
|
||||
return $this->storeRevision($page, $this->sections->flatten($sections), $sections, $seoTitle, $seoDescription, $author);
|
||||
}
|
||||
|
||||
public function publish(Page $page, PageRevision $revision): void
|
||||
@@ -34,7 +46,7 @@ public function publish(Page $page, PageRevision $revision): void
|
||||
}
|
||||
|
||||
/**
|
||||
* Legt den Stand einer früheren Revision unverändert als neue Revision an. Die gespeicherten Bausteine
|
||||
* Legt den Stand einer früheren Revision unverändert als neue Revision an. Abschnitte und Bausteine
|
||||
* werden nicht umgeschrieben; ältere Formate werden erst beim Lesen angehoben.
|
||||
*/
|
||||
public function restore(Page $page, PageRevision $source, ?User $author): PageRevision
|
||||
@@ -48,12 +60,33 @@ public function restore(Page $page, PageRevision $source, ?User $author): PageRe
|
||||
return $this->storeRevision(
|
||||
$page,
|
||||
$source->blocks ?? [],
|
||||
$source->sections,
|
||||
$source->seo_title,
|
||||
$source->seo_description,
|
||||
$author,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Legt eine neue, unveröffentlichte Seite mit dem zuletzt gespeicherten Stand einer vorhandenen Seite an.
|
||||
* Die Vorlage bleibt unverändert; spätere Änderungen wirken nicht auf die Kopie.
|
||||
*/
|
||||
public function duplicate(Page $source, string $path, ?User $author): Page
|
||||
{
|
||||
$revision = $source->latestRevision ?? $source->publishedRevision;
|
||||
$page = Page::query()->create(['path' => $this->availablePath($path)]);
|
||||
|
||||
$this->saveRevision(
|
||||
$page,
|
||||
$revision?->sections() ?? [],
|
||||
$revision?->seo_title,
|
||||
$revision?->seo_description,
|
||||
$author,
|
||||
);
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalisiert den Pfad und prüft, dass keine andere Seite ihn verwendet.
|
||||
*/
|
||||
@@ -95,18 +128,30 @@ public function normalizePath(string $path): string
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $blocks
|
||||
* @param array<int|string, mixed> $blocks flache Widget-Liste (Rollback-Fassung)
|
||||
* @param array<int|string, mixed>|null $sections Abschnitte; null bei Revisionen aus der Zeit vor dem Raster
|
||||
*/
|
||||
private function storeRevision(Page $page, array $blocks, ?string $seoTitle, ?string $seoDescription, ?User $author): PageRevision
|
||||
private function storeRevision(Page $page, array $blocks, ?array $sections, ?string $seoTitle, ?string $seoDescription, ?User $author): PageRevision
|
||||
{
|
||||
$revision = $page->revisions()->create([
|
||||
$attributes = [
|
||||
'blocks' => array_values($blocks),
|
||||
'seo_title' => $seoTitle !== null && $seoTitle !== '' ? $seoTitle : null,
|
||||
'seo_description' => $seoDescription !== null && $seoDescription !== '' ? $seoDescription : null,
|
||||
'created_by' => $author?->id,
|
||||
]);
|
||||
];
|
||||
|
||||
foreach ($this->widgets->mediaPaths($revision->blocks) as $path) {
|
||||
// Die Erstbefüllung der Website läuft innerhalb einer frühen Migration, bevor die Spalte existiert.
|
||||
// Solche Revisionen haben keine Abschnitte und werden beim Lesen als einspaltige Abschnitte gelesen.
|
||||
if ($sections !== null && Schema::hasColumn('page_revisions', 'sections')) {
|
||||
$attributes['sections'] = array_values($sections);
|
||||
}
|
||||
|
||||
$revision = $page->revisions()->create($attributes);
|
||||
|
||||
// „Geändert“ in der Seitenliste zeigt die letzte Bearbeitung, nicht das Anlagedatum.
|
||||
$page->touch();
|
||||
|
||||
foreach ($this->sections->mediaPaths($revision->sections()) as $path) {
|
||||
PublishPublicMedia::dispatch($path);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,360 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Sections;
|
||||
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
* Abschnitts- und Slotmodell einer Seite: Seite → Abschnitte → Slots → Widget-Instanzen.
|
||||
*
|
||||
* Gespeicherte Hülle eines Abschnitts (Version 1):
|
||||
* {id, v, layout, style: {background, image, focus, overlay, width, spacing_top, spacing_bottom, gap, divider}, slots: [Widget-Hülle|null, …]}
|
||||
*
|
||||
* Version 2 (Abstände): oben, unten und Widget-Abstand sind drei unabhängige Werte. Hüllen der Version 1 werden beim
|
||||
* Lesen übersetzt (SectionStyle::migrateSpacing), ohne die Darstellung zu ändern; gespeicherte Revisionen bleiben.
|
||||
*
|
||||
* Jeder Slot enthält höchstens ein Widget aus dem zentralen Widget-Register. Abschnitte sind nicht verschachtelbar.
|
||||
* Revisionen ohne Abschnitte (Bestand vor dieser Fassung) werden beim Lesen als einspaltige Abschnitte gelesen.
|
||||
*/
|
||||
class PageSections
|
||||
{
|
||||
public const VERSION = 2;
|
||||
|
||||
public const MAX_SECTIONS = 30;
|
||||
|
||||
public const MAX_WIDGETS = 60;
|
||||
|
||||
public function __construct(private readonly WidgetRegistry $widgets) {}
|
||||
|
||||
/**
|
||||
* Lesepfad. Unbekannte Werte fallen auf Vorgaben zurück, unbekannte Widget-Arten entfallen.
|
||||
*
|
||||
* @param array<int|string, mixed>|null $sections gespeicherte Abschnitte (Spalte sections)
|
||||
* @param array<int|string, mixed>|null $blocks flache Bausteinliste (Spalte blocks), nur ohne Abschnitte verwendet
|
||||
* @return list<array{id: ?string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}>
|
||||
*/
|
||||
public function read(?array $sections, ?array $blocks = null): array
|
||||
{
|
||||
if ($sections === null) {
|
||||
return $this->wrapWidgets($blocks ?? []);
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach (SectionStyle::migrateSpacing(array_values(array_filter($sections, 'is_array')), byVersion: true) as $section) {
|
||||
$result[] = $this->upcastSection($section);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schreibpfad: prüft und bereinigt Abschnitte für eine neue Revision. Flache Widgets (ohne „slots“) werden
|
||||
* als einspaltige Abschnitte übernommen. Alle Fehler der Seite werden gesammelt gemeldet; Schlüssel:
|
||||
* „sections.N.layout“, „sections.N.style.image“, „sections.N.slots“, „sections.N.slots.M.data.feld“.
|
||||
*
|
||||
* @param array<int|string, mixed> $content
|
||||
* @return list<array{id: string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}>
|
||||
*/
|
||||
public function normalize(array $content): array
|
||||
{
|
||||
$items = array_values($content);
|
||||
|
||||
if (count($items) > self::MAX_SECTIONS) {
|
||||
throw ValidationException::withMessages([
|
||||
'sections' => 'Eine Seite hat höchstens '.self::MAX_SECTIONS.' Abschnitte.',
|
||||
]);
|
||||
}
|
||||
|
||||
$errors = [];
|
||||
$sections = [];
|
||||
$seenSectionIds = [];
|
||||
$seenWidgetIds = [];
|
||||
$widgetCount = 0;
|
||||
|
||||
// Eingaben mit Abständen der Version 1 (zum Beispiel ältere Aufrufer) werden wie beim Lesen übersetzt.
|
||||
$migrated = SectionStyle::migrateSpacing(array_map(
|
||||
fn ($item) => is_array($item) && array_key_exists('slots', $item) ? $item : ['style' => [], 'slots' => [$item]],
|
||||
$items,
|
||||
));
|
||||
|
||||
foreach ($items as $index => $item) {
|
||||
if (! is_array($item)) {
|
||||
$errors["sections.$index"] = ['Ein Abschnitt ist unvollständig.'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! array_key_exists('slots', $item)) {
|
||||
$item = ['id' => null, 'layout' => SectionLayouts::DEFAULT, 'style' => [], 'slots' => [$item]];
|
||||
} else {
|
||||
$item['style'] = $migrated[$index]['style'] ?? ($item['style'] ?? []);
|
||||
}
|
||||
|
||||
$sections[] = $this->normalizeSection($item, $index, $errors, $seenSectionIds, $seenWidgetIds, $widgetCount);
|
||||
}
|
||||
|
||||
if ($widgetCount > self::MAX_WIDGETS) {
|
||||
$errors['sections'] = ['Eine Seite enthält höchstens '.self::MAX_WIDGETS.' Widgets.'];
|
||||
}
|
||||
|
||||
if ($errors !== []) {
|
||||
throw ValidationException::withMessages($errors);
|
||||
}
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Widgets in Lesereihenfolge (Abschnitt für Abschnitt, Slot für Slot). Wird zusätzlich als flache
|
||||
* Bausteinliste gespeichert, damit ein Code-Rollback auf die Fassung vor den Abschnitten die Inhalte
|
||||
* weiterhin untereinander darstellt.
|
||||
*
|
||||
* @param list<array<string, mixed>> $sections
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function flatten(array $sections): array
|
||||
{
|
||||
$widgets = [];
|
||||
|
||||
foreach ($sections as $section) {
|
||||
$count = SectionLayouts::slotCount($section['layout']);
|
||||
|
||||
foreach (array_slice($section['slots'], 0, $count) as $widget) {
|
||||
if (is_array($widget)) {
|
||||
$widgets[] = $widget;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Öffentliche Medien der Seite: Widget-Bilder und Hintergrundbilder der Abschnitte.
|
||||
*
|
||||
* @param list<array<string, mixed>> $sections
|
||||
* @return list<string>
|
||||
*/
|
||||
public function mediaPaths(array $sections): array
|
||||
{
|
||||
$paths = [];
|
||||
|
||||
foreach ($sections as $section) {
|
||||
$style = SectionStyle::fromStored($section['style'] ?? []);
|
||||
if (is_string($style['image']) && PublicMedia::isPublicPath($style['image'])) {
|
||||
$paths[] = $style['image'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->widgets->mediaPaths($this->flatten($sections)) as $path) {
|
||||
$paths[] = $path;
|
||||
}
|
||||
|
||||
return array_values(array_unique($paths));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $sections
|
||||
*/
|
||||
public function pageTitle(array $sections): ?string
|
||||
{
|
||||
return $this->widgets->pageTitle($this->flatten($sections));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $blocks
|
||||
* @return list<array{id: ?string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}>
|
||||
*/
|
||||
private function wrapWidgets(array $blocks): array
|
||||
{
|
||||
$sections = [];
|
||||
|
||||
foreach ($this->widgets->read($blocks) as $position => $widget) {
|
||||
$sections[] = [
|
||||
'id' => null,
|
||||
'v' => self::VERSION,
|
||||
'layout' => SectionLayouts::DEFAULT,
|
||||
// Bestand vor dem Raster stand in einem durchgehenden Blatt: kompakte Abstände, zwischen den Widgets
|
||||
// nur einmal (oben kein Abstand ab dem zweiten), wie bisher.
|
||||
'style' => ['spacing_top' => $position === 0 ? 'compact' : 'none', 'spacing_bottom' => 'compact', 'gap' => 'normal'] + SectionStyle::DEFAULTS,
|
||||
'slots' => [$widget],
|
||||
];
|
||||
}
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $section
|
||||
* @return array{id: ?string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}
|
||||
*/
|
||||
private function upcastSection(array $section): array
|
||||
{
|
||||
$layout = SectionLayouts::has($section['layout'] ?? null) ? $section['layout'] : SectionLayouts::DEFAULT;
|
||||
$slots = [];
|
||||
|
||||
foreach (array_values(is_array($section['slots'] ?? null) ? $section['slots'] : []) as $slot) {
|
||||
$slots[] = is_array($slot) ? $this->widgets->upcast($slot) : null;
|
||||
}
|
||||
|
||||
while (count($slots) < SectionLayouts::slotCount($layout)) {
|
||||
$slots[] = null;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => is_string($section['id'] ?? null) ? $section['id'] : null,
|
||||
'v' => self::VERSION,
|
||||
'layout' => $layout,
|
||||
'style' => SectionStyle::fromStored($section['style'] ?? []),
|
||||
'slots' => $slots,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $section
|
||||
* @param array<string, list<string>> $errors
|
||||
* @param array<string, true> $seenSectionIds
|
||||
* @param array<string, true> $seenWidgetIds
|
||||
* @return array{id: string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}
|
||||
*/
|
||||
private function normalizeSection(array $section, int $index, array &$errors, array &$seenSectionIds, array &$seenWidgetIds, int &$widgetCount): array
|
||||
{
|
||||
$prefix = "sections.$index";
|
||||
|
||||
$layout = $section['layout'] ?? SectionLayouts::DEFAULT;
|
||||
if (! SectionLayouts::has($layout)) {
|
||||
$errors["$prefix.layout"] = ['Dieses Abschnittsraster ist nicht freigegeben.'];
|
||||
$layout = SectionLayouts::DEFAULT;
|
||||
}
|
||||
|
||||
$style = $this->normalizeStyle(is_array($section['style'] ?? null) ? $section['style'] : [], $prefix, $errors);
|
||||
|
||||
$units = SectionLayouts::units($layout);
|
||||
$rawSlots = array_values(is_array($section['slots'] ?? null) ? $section['slots'] : []);
|
||||
$filled = count(array_filter($rawSlots, fn ($slot): bool => is_array($slot)));
|
||||
|
||||
if ($filled > count($units)) {
|
||||
$errors["$prefix.slots"] = [sprintf(
|
||||
'Das Raster „%s“ hat %d %s, der Abschnitt enthält aber %d Widgets. Entfernen Sie ein Widget oder wählen Sie ein Raster mit mehr Plätzen.',
|
||||
SectionLayouts::short($layout),
|
||||
count($units),
|
||||
count($units) === 1 ? 'Platz' : 'Plätze',
|
||||
$filled,
|
||||
)];
|
||||
} elseif (count($rawSlots) > count($units)) {
|
||||
// Überzählige Plätze sind leer: Widgets rücken in Reihenfolge nach vorn, leere Plätze entfallen.
|
||||
$rawSlots = array_values(array_filter($rawSlots, fn ($slot): bool => is_array($slot)));
|
||||
}
|
||||
|
||||
$slots = [];
|
||||
foreach ($units as $position => $slotUnits) {
|
||||
$block = $rawSlots[$position] ?? null;
|
||||
|
||||
if (! is_array($block)) {
|
||||
$slots[] = null;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$widgetCount++;
|
||||
|
||||
try {
|
||||
$widget = $this->widgets->normalizeWidget($block, "$prefix.slots.$position", $seenWidgetIds);
|
||||
} catch (ValidationException $exception) {
|
||||
foreach ($exception->errors() as $key => $messages) {
|
||||
$errors[$key] = $messages;
|
||||
}
|
||||
$slots[] = null;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$type = $this->widgets->get($widget['type']);
|
||||
if (! $type->supportsUnits($slotUnits)) {
|
||||
$errors["$prefix.slots.$position.units"] = [sprintf(
|
||||
'„%s“ ist für Plätze mit %s Rastereinheiten vorgesehen; dieser Platz hat %d. Wählen Sie ein passendes Raster oder einen passenden Platz.',
|
||||
$type->label(),
|
||||
$type->unitsLabel(),
|
||||
$slotUnits,
|
||||
)];
|
||||
}
|
||||
|
||||
$slots[] = $widget;
|
||||
}
|
||||
|
||||
$id = $section['id'] ?? null;
|
||||
if (! is_string($id) || preg_match('/^[A-Za-z0-9-]{1,64}$/', $id) !== 1 || isset($seenSectionIds[$id])) {
|
||||
$id = (string) Str::uuid();
|
||||
}
|
||||
$seenSectionIds[$id] = true;
|
||||
|
||||
return [
|
||||
'id' => $id,
|
||||
'v' => self::VERSION,
|
||||
'layout' => $layout,
|
||||
'style' => $style,
|
||||
'slots' => $slots,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $style
|
||||
* @param array<string, list<string>> $errors
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function normalizeStyle(array $style, string $prefix, array &$errors): array
|
||||
{
|
||||
$result = SectionStyle::DEFAULTS;
|
||||
$enums = SectionStyle::enums();
|
||||
|
||||
foreach ($style as $key => $value) {
|
||||
if ($key === 'image' || str_starts_with((string) $key, '_')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset($enums[$key])) {
|
||||
$errors["$prefix.style.$key"] = ['Diese Gestaltungsoption ist nicht freigegeben.'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($value === null || $value === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_string($value) || ! array_key_exists($value, $enums[$key])) {
|
||||
$errors["$prefix.style.$key"] = ['Dieser Gestaltungswert ist nicht freigegeben.'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[$key] = $value;
|
||||
}
|
||||
|
||||
if ($result['background'] === 'image') {
|
||||
$widgetErrors = new WidgetErrors;
|
||||
$refs = ImageRefFields::clean(['image' => $style['image'] ?? null, '_upload' => $style['_upload'] ?? null], $widgetErrors, errorKey: 'image');
|
||||
$image = $refs['image'];
|
||||
|
||||
foreach ($widgetErrors->all() as $messages) {
|
||||
$errors["$prefix.style.image"] = $messages;
|
||||
}
|
||||
|
||||
if ($image === null && ! isset($errors["$prefix.style.image"])) {
|
||||
$errors["$prefix.style.image"] = ['Bitte ein Hintergrundbild aus dem Medienmanager wählen oder hochladen.'];
|
||||
}
|
||||
|
||||
$result['image'] = $image;
|
||||
} else {
|
||||
$result['image'] = null;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Sections;
|
||||
|
||||
/**
|
||||
* Freigegebene Abschnittsraster. Ein Raster teilt die Abschnittsbreite in höchstens vier logische Einheiten.
|
||||
* Die Kennungen sind gespeichert und ändern sich nie; neue Raster werden ergänzt, nicht umbenannt.
|
||||
*
|
||||
* Die Einheiten werden nicht als eigenes CSS-Grundraster umgesetzt, sondern als Spaltenverhältnis (fr)
|
||||
* des Abschnittsrasters. Leere Slots entfallen auf der veröffentlichten Seite; die übrigen Slots teilen
|
||||
* sich die Breite im Verhältnis ihrer Einheiten.
|
||||
*/
|
||||
final class SectionLayouts
|
||||
{
|
||||
public const DEFAULT = 'u4';
|
||||
|
||||
/** @var array<string, list<int>> */
|
||||
public const UNITS = [
|
||||
'u4' => [4],
|
||||
'u2_2' => [2, 2],
|
||||
'u1_3' => [1, 3],
|
||||
'u3_1' => [3, 1],
|
||||
'u1_2_1' => [1, 2, 1],
|
||||
'u1_1_1_1' => [1, 1, 1, 1],
|
||||
'u1_1_2' => [1, 1, 2],
|
||||
'u2_1_1' => [2, 1, 1],
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const LABELS = [
|
||||
'u4' => 'Volle Breite',
|
||||
'u2_2' => 'Zwei gleich breit',
|
||||
'u1_3' => 'Schmal und breit',
|
||||
'u3_1' => 'Breit und schmal',
|
||||
'u1_2_1' => 'Mitte betont',
|
||||
'u1_1_1_1' => 'Vier gleich breit',
|
||||
'u1_1_2' => 'Zwei schmal, eins breit',
|
||||
'u2_1_1' => 'Eins breit, zwei schmal',
|
||||
];
|
||||
|
||||
public static function has(mixed $key): bool
|
||||
{
|
||||
return is_string($key) && isset(self::UNITS[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
public static function units(string $key): array
|
||||
{
|
||||
return self::UNITS[$key] ?? self::UNITS[self::DEFAULT];
|
||||
}
|
||||
|
||||
public static function slotCount(string $key): int
|
||||
{
|
||||
return count(self::units($key));
|
||||
}
|
||||
|
||||
/** Kurzform wie „1 + 3“. */
|
||||
public static function short(string $key): string
|
||||
{
|
||||
return implode(' + ', self::units($key));
|
||||
}
|
||||
|
||||
public static function label(string $key): string
|
||||
{
|
||||
return (self::LABELS[$key] ?? self::LABELS[self::DEFAULT]).' ('.self::short($key).')';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function options(): array
|
||||
{
|
||||
$options = [];
|
||||
foreach (array_keys(self::UNITS) as $key) {
|
||||
$options[$key] = self::label($key);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spaltenvorlagen für die Slots, die tatsächlich etwas darstellen.
|
||||
*
|
||||
* - Desktop (Abschnitt ab 60rem): Verhältnis der Einheiten.
|
||||
* - Tablet (ab 40rem): gleich breite Slots bleiben nebeneinander (zwei oder drei Spalten, vier Slots als 2 × 2);
|
||||
* ungleiche Raster stapeln, damit kein Slot unter etwa 13rem fällt.
|
||||
* - Smartphone: immer eine Spalte. Die Lese- und Fokusreihenfolge bleibt die Reihenfolge der Slots.
|
||||
*
|
||||
* @param list<int> $units
|
||||
* @return array{lg: string, md: string}
|
||||
*/
|
||||
public static function columns(array $units): array
|
||||
{
|
||||
$units = array_values(array_filter($units, fn ($unit): bool => is_int($unit) && $unit > 0));
|
||||
$count = count($units);
|
||||
|
||||
if ($count <= 1) {
|
||||
return ['lg' => 'minmax(0, 1fr)', 'md' => 'minmax(0, 1fr)'];
|
||||
}
|
||||
|
||||
$lg = implode(' ', array_map(fn (int $unit): string => "minmax(0, {$unit}fr)", $units));
|
||||
$equal = count(array_unique($units)) === 1;
|
||||
|
||||
$md = match (true) {
|
||||
! $equal => 'minmax(0, 1fr)',
|
||||
$count === 3 => 'repeat(3, minmax(0, 1fr))',
|
||||
default => 'repeat(2, minmax(0, 1fr))',
|
||||
};
|
||||
|
||||
return ['lg' => $lg, 'md' => $md];
|
||||
}
|
||||
|
||||
/**
|
||||
* Symbolbild des Rasters für die grafische Auswahl im Editor (rein dekorativ).
|
||||
*/
|
||||
public static function schematicSvg(string $key): string
|
||||
{
|
||||
$units = self::units($key);
|
||||
$gap = 2;
|
||||
$width = 56 - $gap * (count($units) - 1);
|
||||
$x = 2;
|
||||
$rects = '';
|
||||
|
||||
foreach ($units as $unit) {
|
||||
$w = (int) round($width * $unit / 4);
|
||||
$rects .= sprintf('<rect x="%d" y="4" width="%d" height="20" rx="1.5"/>', $x, $w);
|
||||
$x += $w + $gap;
|
||||
}
|
||||
|
||||
return '<svg class="luf-layout-schematic" viewBox="0 0 60 28" width="60" height="28" aria-hidden="true" focusable="false">'.$rects.'</svg>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Sections;
|
||||
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetRenderer;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
/**
|
||||
* Einziger Darstellungsweg für Abschnitte: öffentliche Seite und Seitenvorschau rufen denselben Renderer auf.
|
||||
*
|
||||
* Regeln:
|
||||
* - Leere Slots erzeugen keine Leerfläche; die übrigen Slots teilen sich die Breite im Verhältnis ihrer Einheiten.
|
||||
* - Ein Abschnitt ohne darstellbares Widget entfällt samt Hintergrund und Trenner.
|
||||
* - Das erste dargestellte Widget der Seite ist der Seiteneinstieg (Überschrift erster Ordnung).
|
||||
* - Trenner stehen zwischen Abschnitten, nie nach dem letzten.
|
||||
*/
|
||||
class SectionRenderer
|
||||
{
|
||||
public function __construct(private readonly WidgetRenderer $widgets) {}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $sections gelesene Abschnitte (PageSections::read)
|
||||
*/
|
||||
public function renderAll(array $sections, RenderContext $context): HtmlString
|
||||
{
|
||||
$rendered = [];
|
||||
$first = true;
|
||||
|
||||
foreach ($sections as $section) {
|
||||
$cells = [];
|
||||
$units = SectionLayouts::units($section['layout']);
|
||||
|
||||
foreach ($units as $position => $slotUnits) {
|
||||
$widget = $section['slots'][$position] ?? null;
|
||||
|
||||
if (! is_array($widget)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$html = $this->widgets->renderWidget($widget, $context, $first);
|
||||
|
||||
if ($html !== '') {
|
||||
$first = false;
|
||||
$cells[] = ['units' => $slotUnits, 'html' => $html];
|
||||
}
|
||||
}
|
||||
|
||||
if ($cells !== []) {
|
||||
$rendered[] = ['section' => $section, 'cells' => $cells];
|
||||
}
|
||||
}
|
||||
|
||||
$html = '';
|
||||
$last = count($rendered) - 1;
|
||||
|
||||
foreach ($rendered as $index => $item) {
|
||||
$html .= $this->renderSection($item['section'], $item['cells'], $index, $context);
|
||||
|
||||
$divider = $item['section']['style']['divider'] ?? 'none';
|
||||
if ($index < $last && in_array($divider, ['line', 'accent'], true)) {
|
||||
$html .= '<div class="section-divider section-divider-'.$divider.'" aria-hidden="true"><span></span></div>';
|
||||
}
|
||||
}
|
||||
|
||||
return new HtmlString($html);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $section
|
||||
* @param list<array{units: int, html: string}> $cells
|
||||
*/
|
||||
private function renderSection(array $section, array $cells, int $index, RenderContext $context): string
|
||||
{
|
||||
$style = SectionStyle::fromStored($section['style'] ?? []);
|
||||
$columns = SectionLayouts::columns(array_column($cells, 'units'));
|
||||
// Hintergrundbild aus dem Medienmanager: öffentlich nur mit Website-Freigabe (WebsiteImage → WebsiteMedia).
|
||||
$imageUrl = $style['background'] === 'image' ? app(WebsiteImage::class)->url($style['image'], $context->preview) : null;
|
||||
$hasImage = $imageUrl !== null;
|
||||
|
||||
$classes = [
|
||||
'page-section',
|
||||
'section-bg-'.($hasImage ? 'image' : ($style['background'] === 'image' ? 'default' : $style['background'])),
|
||||
'section-width-'.$style['width'],
|
||||
'section-space-top-'.$style['spacing_top'],
|
||||
'section-space-bottom-'.$style['spacing_bottom'],
|
||||
'section-gap-'.$style['gap'],
|
||||
'section-layout-'.str_replace('_', '-', $section['layout']),
|
||||
];
|
||||
|
||||
if ($hasImage) {
|
||||
$classes[] = 'section-overlay-'.$style['overlay'];
|
||||
}
|
||||
|
||||
// Bedeutungswerte der Fläche (tokens.css): helle Schrift auf dunklen Flächen, gelber Fokus.
|
||||
$scope = match (true) {
|
||||
$hasImage && $style['overlay'] === 'dark' => 'scope-dark',
|
||||
$hasImage => 'scope-light',
|
||||
$style['background'] === 'dark' => 'scope-dark',
|
||||
$style['background'] === 'accent' => 'scope-accent',
|
||||
default => null,
|
||||
};
|
||||
if ($scope !== null) {
|
||||
$classes[] = $scope;
|
||||
}
|
||||
|
||||
$id = is_string($section['id'] ?? null) ? ' id="bereich-'.e($section['id']).'"' : '';
|
||||
$html = '<div class="'.e(implode(' ', $classes)).'"'.$id.'>';
|
||||
|
||||
if ($hasImage) {
|
||||
// Das Bild des ersten Abschnitts ist meist das größte sichtbare Element und wird nicht verzögert geladen.
|
||||
$loading = $index === 0 ? 'loading="eager" fetchpriority="high"' : 'loading="lazy"';
|
||||
$html .= '<img class="page-section-image" src="'.e($imageUrl).'" alt="" '.$loading.' decoding="async"'
|
||||
.' style="object-position: '.e(SectionStyle::FOCUS_POSITIONS[$style['focus']]).'">';
|
||||
}
|
||||
|
||||
$html .= '<div class="page-section-inner"><div class="section-grid" data-slots="'.count($cells).'"'
|
||||
.' style="--section-cols-lg: '.e($columns['lg']).'; --section-cols-md: '.e($columns['md']).'">';
|
||||
|
||||
foreach ($cells as $cell) {
|
||||
$html .= '<div class="section-slot" data-units="'.$cell['units'].'">'.$cell['html'].'</div>';
|
||||
}
|
||||
|
||||
return $html.'</div></div></div>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Sections;
|
||||
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
|
||||
/**
|
||||
* Semantische Abschnittsgestaltung. Jeder Wert ist eine Aufzählung, die auf zentrale Design-Tokens
|
||||
* abgebildet wird (resources/css/app.css, Abschnitt „Abschnitte“). Keine freie CSS- oder Farbangabe.
|
||||
*/
|
||||
final class SectionStyle
|
||||
{
|
||||
/** @var array<string, string> */
|
||||
public const BACKGROUNDS = [
|
||||
'default' => 'Standard (ohne eigene Fläche)',
|
||||
'light' => 'Helle Markenfläche',
|
||||
'dark' => 'Dunkle Markenfläche',
|
||||
'accent' => 'Markenakzent',
|
||||
'image' => 'Hintergrundbild',
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const WIDTHS = [
|
||||
'narrow' => 'Lesebereich',
|
||||
'standard' => 'Standard',
|
||||
'wide' => 'Breit',
|
||||
'full' => 'Vollbreite',
|
||||
];
|
||||
|
||||
/**
|
||||
* Gemeinsame Stufen der drei Abstände eines Abschnitts (Hülle Version 2):
|
||||
* - spacing_top: Abstand vor dem Inhalt (oben),
|
||||
* - spacing_bottom: Abstand nach dem Inhalt (unten),
|
||||
* - gap: Abstand zwischen den Plätzen im Abschnittsraster, nebeneinander und gestapelt.
|
||||
* Zwischen zwei Abschnitten addieren sich „unten“ des ersten und „oben“ des zweiten; es gibt keine weitere
|
||||
* versteckte Vorgabe. Liegt eine eigene Fläche (Hintergrund) vor, liegen oben und unten innerhalb dieser Fläche.
|
||||
* Werte: resources/css/tokens.css (--section-space-*, --section-gap-*).
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public const SPACINGS = [
|
||||
'none' => 'Kein Abstand',
|
||||
'compact' => 'Kompakt',
|
||||
'normal' => 'Normal',
|
||||
'large' => 'Großzügig',
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const DIVIDERS = [
|
||||
'none' => 'Kein Trenner',
|
||||
'line' => 'Dezente Linie',
|
||||
'accent' => 'Markenakzent',
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const OVERLAYS = [
|
||||
'light' => 'Helle Überlagerung (dunkle Schrift)',
|
||||
'dark' => 'Dunkle Überlagerung (helle Schrift)',
|
||||
'none' => 'Keine Überlagerung',
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
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_top' => 'compact',
|
||||
'spacing_bottom' => 'compact',
|
||||
'gap' => 'normal',
|
||||
'divider' => 'none',
|
||||
];
|
||||
|
||||
/**
|
||||
* Aufzählungsfelder und ihre zulässigen Werte.
|
||||
*
|
||||
* @return array<string, array<string, string>>
|
||||
*/
|
||||
public static function enums(): array
|
||||
{
|
||||
return [
|
||||
'background' => self::BACKGROUNDS,
|
||||
'focus' => self::FOCUS,
|
||||
'overlay' => self::OVERLAYS,
|
||||
'width' => self::WIDTHS,
|
||||
'spacing_top' => self::SPACINGS,
|
||||
'spacing_bottom' => self::SPACINGS,
|
||||
'gap' => 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_top: string, spacing_bottom: string, gap: 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' ? WebsiteImage::normalize($style['image'] ?? null) : null;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kurzbeschreibung für die Abschnittsliste im Editor.
|
||||
*
|
||||
* @param array<string, mixed> $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_top'] !== self::DEFAULTS['spacing_top'] || $style['spacing_bottom'] !== self::DEFAULTS['spacing_bottom']) {
|
||||
$parts[] = 'Abstand oben '.mb_strtolower(self::SPACINGS[$style['spacing_top']])
|
||||
.', unten '.mb_strtolower(self::SPACINGS[$style['spacing_bottom']]);
|
||||
}
|
||||
|
||||
if ($style['gap'] !== 'normal') {
|
||||
$parts[] = 'Widget-Abstand '.mb_strtolower(self::SPACINGS[$style['gap']]);
|
||||
}
|
||||
|
||||
if ($style['divider'] !== 'none') {
|
||||
$parts[] = 'Trenner: '.self::DIVIDERS[$style['divider']];
|
||||
}
|
||||
|
||||
return implode(' · ', $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ob eine gespeicherte Gestaltung noch die Abstände der Hülle Version 1 trägt
|
||||
* („Abstand oben und unten“ spacing, Abweichung „Abstand oben“ same/small/none).
|
||||
*
|
||||
* @param array<string, mixed> $style
|
||||
*/
|
||||
public static function hasLegacySpacing(array $style): bool
|
||||
{
|
||||
return array_key_exists('spacing', $style)
|
||||
|| in_array($style['spacing_top'] ?? null, ['same', 'small'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Übersetzt die Abstände der Hülle Version 1 in die drei Werte der Version 2, ohne die Darstellung zu ändern.
|
||||
*
|
||||
* Version 1 rechnete so: jeder Abschnitt oben und unten „spacing“ (Vorgabe normal); die Abweichung
|
||||
* „Abstand oben“ ersetzte nur oben (small/none); und eine versteckte Regel setzte oben auf null, wenn ein Abschnitt
|
||||
* ohne eigene Fläche direkt auf einen Abschnitt ohne eigene Fläche folgte (ohne Linien- oder Akzenttrenner dazwischen).
|
||||
* Diese Regel wird hier als „oben: kein Abstand“ ausgeschrieben. „Gering“ hat keine eigene Stufe mehr und wird
|
||||
* „Kompakt“ (dokumentierte Abweichung). Der Widget-Abstand entspricht dem bisherigen festen Rasterabstand („normal“).
|
||||
*
|
||||
* @param list<array<string, mixed>> $sections Abschnitte in Lesereihenfolge (mit style und slots)
|
||||
* @param bool $byVersion true: jede Hülle mit v < 2 gilt als Version 1 (Lesepfad gespeicherter Revisionen);
|
||||
* false: nur Gestaltungen mit alten Schlüsseln (Eingaben ohne Versionsangabe)
|
||||
* @return list<array<string, mixed>> dieselben Abschnitte mit übersetzter Gestaltung
|
||||
*/
|
||||
public static function migrateSpacing(array $sections, bool $byVersion = false): array
|
||||
{
|
||||
$previous = null;
|
||||
|
||||
foreach ($sections as $index => $section) {
|
||||
$style = is_array($section['style'] ?? null) ? $section['style'] : [];
|
||||
$rendered = is_array($section['slots'] ?? null) && array_filter($section['slots'], 'is_array') !== [];
|
||||
|
||||
$background = is_string($style['background'] ?? null) && isset(self::BACKGROUNDS[$style['background']]) ? $style['background'] : 'default';
|
||||
if ($background === 'image' && WebsiteImage::normalize($style['image'] ?? null) === null) {
|
||||
$background = 'default';
|
||||
}
|
||||
$divider = in_array($style['divider'] ?? null, ['line', 'accent'], true) ? $style['divider'] : 'none';
|
||||
|
||||
$legacy = $byVersion ? (int) ($section['v'] ?? 1) < 2 : self::hasLegacySpacing($style);
|
||||
|
||||
if ($legacy) {
|
||||
$level = in_array($style['spacing'] ?? null, ['compact', 'normal', 'large'], true) ? $style['spacing'] : 'normal';
|
||||
$override = $style['spacing_top'] ?? 'same';
|
||||
$collapsed = $background === 'default' && $previous !== null && $previous['background'] === 'default' && ! in_array($previous['divider'], ['line', 'accent'], true);
|
||||
|
||||
$style['spacing_top'] = match (true) {
|
||||
$override === 'none' => 'none',
|
||||
$override === 'small' => 'compact',
|
||||
$collapsed => 'none',
|
||||
default => $level,
|
||||
};
|
||||
$style['spacing_bottom'] = $level;
|
||||
$style['gap'] = 'normal';
|
||||
|
||||
// Trenner „Zusätzlicher Abstand“ (Version 1) fügte unten noch einmal den Abschnittsabstand an.
|
||||
if (($style['divider'] ?? null) === 'space') {
|
||||
$style['spacing_bottom'] = ['compact' => 'normal', 'normal' => 'large', 'large' => 'large'][$level];
|
||||
$style['divider'] = 'none';
|
||||
}
|
||||
unset($style['spacing']);
|
||||
$sections[$index]['style'] = $style;
|
||||
}
|
||||
|
||||
if ($rendered) {
|
||||
$previous = ['background' => $background, 'divider' => $divider];
|
||||
}
|
||||
}
|
||||
|
||||
return $sections;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Baut Kopf- und Fußnavigation aus dem CMS-Navigationsmodell. Keine fest codierten Menüpunkte.
|
||||
*
|
||||
* Die Ausgabe hängt nur von der Navigation und dem angefragten Pfad ab, nie vom Anmeldestatus,
|
||||
* damit öffentliche Seiten für alle Besucher gleich ausgeliefert werden können (ADR-32).
|
||||
*/
|
||||
final class SiteNavigation
|
||||
{
|
||||
/**
|
||||
* @param Collection<int, NavigationItem> $items sichtbare Einträge, sortiert
|
||||
*/
|
||||
public function __construct(private readonly Collection $items, private readonly string $currentPath) {}
|
||||
|
||||
/**
|
||||
* @param Collection<int, NavigationItem> $items
|
||||
*/
|
||||
public static function forPath(Collection $items, string $path): self
|
||||
{
|
||||
return new self($items, '/'.trim($path, '/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Hauptnavigation mit einer Ebene Untermenü. Untereinträge eines ausgeblendeten Eintrags sind ebenfalls verborgen.
|
||||
*
|
||||
* @return list<array{id: int, label: string, href: ?string, current: bool, activeTrail: bool, children: list<array{id: int, label: string, href: string, current: bool}>}>
|
||||
*/
|
||||
public function header(): array
|
||||
{
|
||||
$topLevel = $this->items->where('placement', 'header')->whereNull('parent_id');
|
||||
$entries = [];
|
||||
|
||||
foreach ($topLevel as $item) {
|
||||
$children = [];
|
||||
|
||||
foreach ($this->items->where('parent_id', $item->id) as $child) {
|
||||
$href = $child->href();
|
||||
if ($href !== null) {
|
||||
$children[] = [
|
||||
'id' => $child->id,
|
||||
'label' => $child->label,
|
||||
'href' => $href,
|
||||
'current' => $this->isCurrent($child),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$href = $item->href();
|
||||
if ($href === null && $children === []) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$current = $href !== null && $this->isCurrent($item);
|
||||
|
||||
$entries[] = [
|
||||
'id' => $item->id,
|
||||
'label' => $item->label,
|
||||
'href' => $href,
|
||||
'current' => $current,
|
||||
'activeTrail' => $current || in_array(true, array_column($children, 'current'), true),
|
||||
'children' => $children,
|
||||
];
|
||||
}
|
||||
|
||||
return $entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spalten des Fußbereichs in fester Reihenfolge; Gruppen ohne Einträge entfallen.
|
||||
*
|
||||
* @return list<array{key: string, heading: string, links: list<array{label: string, href: string, current: bool}>}>
|
||||
*/
|
||||
public function footerGroups(): array
|
||||
{
|
||||
$groups = [];
|
||||
|
||||
foreach (NavigationItem::FOOTER_GROUPS as $placement => $heading) {
|
||||
$links = [];
|
||||
|
||||
foreach ($this->items->where('placement', $placement) as $item) {
|
||||
$href = $item->href();
|
||||
if ($href !== null) {
|
||||
$links[] = ['label' => $item->label, 'href' => $href, 'current' => $this->isCurrent($item)];
|
||||
}
|
||||
}
|
||||
|
||||
if ($links !== []) {
|
||||
$groups[] = ['key' => $placement, 'heading' => $heading, 'links' => $links];
|
||||
}
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
private function isCurrent(NavigationItem $item): bool
|
||||
{
|
||||
return $item->targetPath() === $this->currentPath;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Media\WebsiteMediaAlias;
|
||||
|
||||
/**
|
||||
* Wo ein Medium auf Website-Seiten als Bild verwendet wird (veröffentlichte Fassung und neuester Entwurf).
|
||||
* Für den Medienmanager: Vor dem Zurücknehmen einer Website-Freigabe ist sichtbar, welche Seiten das Bild verlieren.
|
||||
*/
|
||||
class WebsiteImageUsage
|
||||
{
|
||||
/**
|
||||
* @return list<array{path: string, published: bool, draft: bool}>
|
||||
*/
|
||||
public function pages(ContentElement $element): array
|
||||
{
|
||||
$legacy = WebsiteMediaAlias::query()->where('content_element_id', $element->id)->pluck('legacy_path')->all();
|
||||
$usages = [];
|
||||
|
||||
foreach (Page::query()->with(['publishedRevision', 'latestRevision'])->orderBy('path')->get() as $page) {
|
||||
$published = $page->publishedRevision !== null && $this->uses($page->publishedRevision->sections ?? [], $element->id, $legacy);
|
||||
$draft = $page->latestRevision !== null && $page->latestRevision->id !== $page->published_revision_id
|
||||
&& $this->uses($page->latestRevision->sections ?? [], $element->id, $legacy);
|
||||
|
||||
if ($published || $draft) {
|
||||
$usages[] = ['path' => (string) $page->path, 'published' => $published, 'draft' => $draft];
|
||||
}
|
||||
}
|
||||
|
||||
return $usages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $legacy
|
||||
*/
|
||||
private function uses(mixed $value, int $id, array $legacy): bool
|
||||
{
|
||||
if (! is_array($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($value as $key => $item) {
|
||||
if ($key === 'image' && (($item === $id || (is_string($item) && ($item === (string) $id || in_array($item, $legacy, true)))))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_array($item) && $this->uses($item, $id, $legacy)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -5,37 +5,80 @@
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use Filament\Forms\Components\Field;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Illuminate\Support\Str;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
|
||||
/**
|
||||
* Gemeinsame Bildauswahl für Widgets: vorhandenes Bild aus dem öffentlichen Website-Bereich wählen
|
||||
* oder ein neues hochladen. Keine eigene Medienverwaltung.
|
||||
* Gemeinsame Bildauswahl aller Widgets und des Abschnittshintergrunds: Bilder aus dem zentralen Medienmanager
|
||||
* (siehe WebsiteImage, docs/architektur/medienzugriff-fuer-komponenten.md). Keine eigene CMS-Medienverwaltung.
|
||||
*
|
||||
* - Auswahl: durchsuchbare Liste mit Vorschaubild, Titel und Website-Status.
|
||||
* - Neu hochladen: Das Bild wird sofort als Medium im Medienmanager angelegt (WebsiteIntake) und ausgewählt.
|
||||
* - Anzeige des gewählten Mediums mit Status und Verweis auf die Freigabe im Medienmanager.
|
||||
*
|
||||
* Das Bedienmuster folgt der Bildauswahl im Modul- und Programmeditor (Suche, Vorschaubild, Auswählen); jene ist an
|
||||
* die Livewire-Seite des Editors gebunden und lässt sich nicht als Formularfeld im Widget-Dialog einhängen.
|
||||
*/
|
||||
final class ImageRefFields
|
||||
{
|
||||
/**
|
||||
* @return list<Field>
|
||||
* @param bool $live Änderungen sofort an die Vorschau im Bearbeitungsdialog geben.
|
||||
* @param string|null $altField Name des Alternativtext-Felds im selben Formular (für neue Medien), falls vorhanden.
|
||||
* @return list<Field|Placeholder>
|
||||
*/
|
||||
public static function fields(string $label = 'Bild'): array
|
||||
public static function fields(string $label = 'Bild', bool $live = false, string $key = 'image', ?string $altField = null): array
|
||||
{
|
||||
return [
|
||||
Select::make('image')
|
||||
->label($label.': vorhandenes Bild')
|
||||
->options(fn (): array => PublicMedia::imageOptions())
|
||||
Select::make($key)
|
||||
->live()
|
||||
->label($label.' aus dem Medienmanager')
|
||||
->searchable()
|
||||
->allowHtml()
|
||||
->options(fn (): array => app(WebsiteImage::class)->options())
|
||||
->getSearchResultsUsing(fn (?string $search): array => app(WebsiteImage::class)->options($search))
|
||||
->getOptionLabelUsing(fn (mixed $value): ?string => app(WebsiteImage::class)->optionHtml($value))
|
||||
->placeholder('Kein Bild')
|
||||
->helperText('Auswahl aus den Bildern, die bereits für die Website hochgeladen wurden.'),
|
||||
->helperText('Alle Bilder des Medienmanagers. Öffentlich erscheint ein Bild nur mit Website-Freigabe.'),
|
||||
FileUpload::make('_upload')
|
||||
->label($label.': neu hochladen')
|
||||
->disk('cms_incoming')
|
||||
->directory('cms')
|
||||
->live()
|
||||
->label($label.': neues Bild hochladen')
|
||||
->image()
|
||||
->maxSize(8192)
|
||||
->acceptedFileTypes(['image/jpeg', 'image/png', 'image/webp'])
|
||||
->getUploadedFileNameForStorageUsing(fn (TemporaryUploadedFile $file): string => Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)).'-'.Str::lower(Str::random(6)).'.'.$file->guessExtension())
|
||||
->helperText('Ein neues Bild ersetzt die Auswahl oben. Es wird beim Speichern im öffentlichen Bereich der Website abgelegt.'),
|
||||
->storeFiles(false)
|
||||
->afterStateUpdated(function (mixed $state, Set $set, Get $get) use ($key, $altField): void {
|
||||
$file = is_array($state) ? (array_values($state)[0] ?? null) : $state;
|
||||
|
||||
if (! $file instanceof TemporaryUploadedFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
$element = app(WebsiteImage::class)->accept($file, $altField !== null ? $get($altField) : null);
|
||||
$set('_upload', null);
|
||||
|
||||
if ($element === null) {
|
||||
Notification::make()->danger()->title('Das Bild konnte nicht übernommen werden.')->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$set($key, $element->id);
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Im Medienmanager angelegt: „'.($element->display_title ?: $element->working_title).'“')
|
||||
->body('Das Bild ist ausgewählt. Nach der Verarbeitung wird es automatisch für die Website freigegeben.')
|
||||
->send();
|
||||
})
|
||||
->helperText('Das Bild wird im Medienmanager angelegt und hier ausgewählt. Nur Bilder mit geklärten Rechten hochladen.'),
|
||||
Placeholder::make('_media_status')
|
||||
->label('Gewähltes Bild')
|
||||
->visible(fn (Get $get): bool => WebsiteImage::normalize($get($key)) !== null)
|
||||
->content(fn (Get $get): HtmlString => self::statusHtml($get($key))),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -45,29 +88,49 @@ public static function fields(string $label = 'Bild'): array
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
'image' => ['nullable', 'string', 'max:255'],
|
||||
'image' => ['nullable'],
|
||||
'_upload' => ['nullable'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Übernimmt einen neuen Upload als Bild und prüft, dass das Bild im öffentlichen Bereich liegt.
|
||||
* Prüft das gewählte Bild. Ein früherer CMS-Pfad mit wirksamer Zuordnung wird zur Kennung des Mediums.
|
||||
* Ein noch als Datei übergebener Upload (frühere Formulare) wird über den Medienmanager aufgenommen.
|
||||
*
|
||||
* @param array<string, mixed> $refs
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function clean(array $refs, WidgetErrors $errors, string $key = 'image', ?string $errorKey = null): array
|
||||
{
|
||||
$upload = PublicMedia::fromUploadState($refs['_upload'] ?? null);
|
||||
$image = $upload ?? PublicMedia::fromUploadState($refs[$key] ?? null);
|
||||
$images = app(WebsiteImage::class);
|
||||
$upload = $refs['_upload'] ?? null;
|
||||
$upload = is_array($upload) ? (array_values($upload)[0] ?? null) : $upload;
|
||||
|
||||
if ($image !== null && ! PublicMedia::isPublicPath($image)) {
|
||||
$errors->add($errorKey ?? "refs.$key", 'Das Bild liegt nicht im öffentlichen Medienbereich.');
|
||||
if ($upload instanceof TemporaryUploadedFile) {
|
||||
$element = $images->accept($upload);
|
||||
$refs[$key] = $element?->id ?? $refs[$key] ?? null;
|
||||
}
|
||||
|
||||
$refs[$key] = $image;
|
||||
$refs[$key] = $images->clean($refs[$key] ?? null, $errors, $errorKey ?? "refs.$key");
|
||||
unset($refs['_upload']);
|
||||
|
||||
return $refs;
|
||||
}
|
||||
|
||||
public static function statusHtml(mixed $value): HtmlString
|
||||
{
|
||||
$status = app(WebsiteImage::class)->status($value);
|
||||
|
||||
if ($status === null) {
|
||||
return new HtmlString('');
|
||||
}
|
||||
|
||||
$thumb = $status['thumb'] !== null ? '<img src="'.e($status['thumb']).'" alt="">' : '';
|
||||
$link = $status['manageUrl'] !== null
|
||||
? '<a href="'.e($status['manageUrl']).'" target="_blank" rel="noopener">Im Medienmanager öffnen</a>'
|
||||
: '';
|
||||
|
||||
return new HtmlString('<div class="luf-media-status luf-media-status-'.e($status['state']).'">'.$thumb
|
||||
.'<div><strong>'.e($status['title']).'</strong><p>'.e($status['note']).'</p>'.$link.'</div></div>');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Support;
|
||||
|
||||
use App\Domain\Cms\Sections\SectionStyle;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use Filament\Forms\Components\Slider;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
|
||||
/**
|
||||
* Gemeinsame Bausteine der Premium-Widgets (Einstieg, Bild und Text; Brand-UI-Kit v1.6): Label, Überschriftenebene,
|
||||
* Bildfokus in Prozent und zwei Schaltflächen. Alle Werte bleiben in data bzw. settings der bestehenden Hülle.
|
||||
*
|
||||
* Abweichungen vom Kit (bewusst, dokumentiert in cms-widget-registry.md):
|
||||
* - Bildfokus als data.focus_x / data.focus_y (ganze Zahlen 0–100), weil settings nur Aufzählungswerte trägt.
|
||||
* - Überschriftenebene „Automatisch“ statt freier H1: Die Seite hat genau eine H1 (erstes Widget der Seite).
|
||||
* - Linkziele über SafeUrl des Repositorys (Seitenpfad, #Anker, http und https), nicht nur https.
|
||||
*/
|
||||
final class PremiumFields
|
||||
{
|
||||
public const HEADING_LEVELS = [
|
||||
'auto' => 'Automatisch (Seiteneinstieg H1, sonst H2)',
|
||||
'h2' => 'H2',
|
||||
'h3' => 'H3',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
'eyebrow' => ['nullable', 'string', 'max:80'],
|
||||
'cta_label' => ['nullable', 'string', 'max:80', 'required_with:data.cta_url'],
|
||||
'cta_url' => ['nullable', 'string', 'max:500', 'required_with:data.cta_label'],
|
||||
'cta2_label' => ['nullable', 'string', 'max:80', 'required_with:data.cta2_url'],
|
||||
'cta2_url' => ['nullable', 'string', 'max:500', 'required_with:data.cta2_label'],
|
||||
'alt' => ['nullable', 'string', 'max:300'],
|
||||
'focus_x' => ['nullable', 'numeric', 'between:0,100'],
|
||||
'focus_y' => ['nullable', 'numeric', 'between:0,100'],
|
||||
];
|
||||
}
|
||||
|
||||
public static function eyebrowField(): TextInput
|
||||
{
|
||||
return TextInput::make('eyebrow')
|
||||
->label('Label über der Überschrift (optional)')
|
||||
->maxLength(80)
|
||||
->live(onBlur: true)
|
||||
->helperText('Kurzer Hinweis, zum Beispiel ein Themenbereich. Kein Pflichtfeld.');
|
||||
}
|
||||
|
||||
public static function ctaFields(): Grid
|
||||
{
|
||||
$url = fn (string $name, string $label, string $pair) => TextInput::make($name)
|
||||
->label($label)
|
||||
->maxLength(500)
|
||||
->rule(SafeUrl::rule())
|
||||
->requiredWith($pair)
|
||||
->live(onBlur: true)
|
||||
->placeholder('/programme');
|
||||
|
||||
return Grid::make(['default' => 1, 'md' => 2])->schema([
|
||||
TextInput::make('cta_label')->label('Hauptschaltfläche: Beschriftung')->maxLength(80)->live(onBlur: true),
|
||||
$url('cta_url', 'Hauptschaltfläche: Linkziel', 'cta_label'),
|
||||
TextInput::make('cta2_label')->label('Zweite Schaltfläche: Beschriftung')->maxLength(80)->live(onBlur: true),
|
||||
$url('cta2_url', 'Zweite Schaltfläche: Linkziel', 'cta2_label'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<Slider>
|
||||
*/
|
||||
public static function focusFields(int $defaultX = 50, int $defaultY = 50): array
|
||||
{
|
||||
// Ohne gespeicherten Wert zeigt der Regler die Vorgabe der Widget-Art, die auch die Darstellung verwendet.
|
||||
$slider = fn (string $name, string $label, int $default) => Slider::make($name)
|
||||
->label($label)
|
||||
->range(0, 100)
|
||||
->step(1)
|
||||
->required(false)
|
||||
->tooltips()
|
||||
->default($default)
|
||||
->afterStateHydrated(function (Slider $component, mixed $state) use ($default): void {
|
||||
if (! is_numeric($state)) {
|
||||
$component->state($default);
|
||||
}
|
||||
})
|
||||
->live();
|
||||
|
||||
return [
|
||||
$slider('focus_x', 'Bildausschnitt waagerecht (0 = links, 100 = rechts)', $defaultX),
|
||||
$slider('focus_y', 'Bildausschnitt senkrecht (0 = oben, 100 = unten)', $defaultY),
|
||||
];
|
||||
}
|
||||
|
||||
public static function altField(): TextInput
|
||||
{
|
||||
return TextInput::make('alt')
|
||||
->label('Alternativtext (optional)')
|
||||
->maxLength(300)
|
||||
->live(onBlur: true)
|
||||
->helperText('Leer lassen, dann gilt der Alternativtext des Mediums aus dem Medienmanager. Nur ausfüllen, wenn das Bild hier etwas anderes aussagen soll.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Bereinigt Label, Schaltflächen, Alternativtext und Fokus; meldet unsichere Linkziele.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function clean(array $data, WidgetErrors $errors, bool $hasImage): array
|
||||
{
|
||||
foreach (['eyebrow', 'cta_label', 'cta_url', 'cta2_label', 'cta2_url', 'alt'] as $key) {
|
||||
$data[$key] = filled($data[$key] ?? null) ? trim((string) $data[$key]) : null;
|
||||
}
|
||||
|
||||
foreach (['cta_url', 'cta2_url'] as $key) {
|
||||
if ($data[$key] !== null && ! SafeUrl::isSafe($data[$key])) {
|
||||
$errors->add("data.$key", SafeUrl::message());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (['focus_x', 'focus_y'] as $key) {
|
||||
$value = $data[$key] ?? null;
|
||||
$data[$key] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schaltflächen mit sicherem Linkziel in Anzeigereihenfolge.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @return list<array{label: string, url: string}>
|
||||
*/
|
||||
public static function actions(array $data): array
|
||||
{
|
||||
$actions = [];
|
||||
|
||||
foreach ([['cta_label', 'cta_url'], ['cta2_label', 'cta2_url']] as [$label, $url]) {
|
||||
if (filled($data[$label] ?? null) && SafeUrl::isSafe($data[$url] ?? null)) {
|
||||
$actions[] = ['label' => (string) $data[$label], 'url' => (string) $data[$url]];
|
||||
}
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bildfokus in Prozent; ohne Angabe die Vorgabe der Widget-Art.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @return array{x: int, y: int}
|
||||
*/
|
||||
public static function focus(array $data, int $defaultX = 50, int $defaultY = 50): array
|
||||
{
|
||||
$clamp = fn (mixed $value, int $default): int => is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : $default;
|
||||
|
||||
return ['x' => $clamp($data['focus_x'] ?? null, $defaultX), 'y' => $clamp($data['focus_y'] ?? null, $defaultY)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Übersetzt den früheren Fokuspunkt (Aufzählung wie beim Abschnittshintergrund) in Prozentwerte.
|
||||
*
|
||||
* @return array{focus_x: int|null, focus_y: int|null}
|
||||
*/
|
||||
public static function focusFromEnum(mixed $focus): array
|
||||
{
|
||||
if (! is_string($focus) || ! isset(SectionStyle::FOCUS_POSITIONS[$focus])) {
|
||||
return ['focus_x' => null, 'focus_y' => null];
|
||||
}
|
||||
|
||||
[$x, $y] = array_map(fn (string $part): int => (int) rtrim($part, '%'), explode(' ', SectionStyle::FOCUS_POSITIONS[$focus]));
|
||||
|
||||
return ['focus_x' => $x, 'focus_y' => $y];
|
||||
}
|
||||
|
||||
/**
|
||||
* Überschriftenebene: „auto“ ergibt H1 für das erste Widget der Seite, sonst H2. Eine weitere H1 gibt es nicht.
|
||||
*
|
||||
* @param array<string, mixed> $settings
|
||||
*/
|
||||
public static function headingTag(array $settings, bool $first): string
|
||||
{
|
||||
$level = $settings['heading_level'] ?? 'auto';
|
||||
|
||||
return match (true) {
|
||||
$first => 'h1',
|
||||
$level === 'h3' => 'h3',
|
||||
default => 'h2',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -2,20 +2,14 @@
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Support;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Öffentlicher Medienbereich der Website ("cms/"). Nur Dateien aus diesem Bereich dürfen in Widgets
|
||||
* verwendet werden. Geschützte Bibliotheksmedien (Inhaltsdateien, Vorschaubilder) sind hier nie wählbar.
|
||||
* Frühere öffentliche CMS-Bilder („cms/“, Route media.public). Neue Bilder kommen aus dem Medienmanager (WebsiteImage);
|
||||
* dieser Bereich bleibt nur für gespeicherte Revisionen mit früheren Pfaden, die (noch) keinem Medium zugeordnet sind.
|
||||
*/
|
||||
final class PublicMedia
|
||||
{
|
||||
public const PREFIX = 'cms/';
|
||||
|
||||
private const IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'webp', 'gif', 'avif'];
|
||||
|
||||
public static function isPublicPath(mixed $path): bool
|
||||
{
|
||||
return is_string($path)
|
||||
@@ -29,36 +23,6 @@ public static function url(string $path): string
|
||||
return route('media.public', ['path' => $path]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bereits vorhandene Bilder im öffentlichen Bereich (veröffentlicht oder zur Veröffentlichung vorgemerkt).
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function imageOptions(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (['media_public', 'cms_incoming'] as $disk) {
|
||||
try {
|
||||
$files = Storage::disk($disk)->allFiles(rtrim(self::PREFIX, '/'));
|
||||
} catch (Throwable) {
|
||||
$files = [];
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
$extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
||||
|
||||
if (self::isPublicPath($file) && in_array($extension, self::IMAGE_EXTENSIONS, true)) {
|
||||
$options[$file] = substr($file, strlen(self::PREFIX));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ksort($options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pfad aus dem Zustand eines Upload-Felds (Zeichenkette oder Liste).
|
||||
*/
|
||||
@@ -70,31 +34,4 @@ public static function fromUploadState(mixed $state): ?string
|
||||
|
||||
return is_string($state) && $state !== '' ? $state : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bildadresse für Darstellung und Blockvorschau. In der Vorschau kann ein noch nicht gespeicherter Upload vorliegen.
|
||||
*
|
||||
* @param array<string, mixed> $refs
|
||||
*/
|
||||
public static function imageUrl(array $refs, string $key = 'image'): ?string
|
||||
{
|
||||
$upload = $refs['_upload'] ?? null;
|
||||
$upload = is_array($upload) ? (array_values($upload)[0] ?? null) : $upload;
|
||||
|
||||
if ($upload instanceof TemporaryUploadedFile) {
|
||||
try {
|
||||
return $upload->temporaryUrl();
|
||||
} catch (Throwable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (self::isPublicPath($upload)) {
|
||||
return self::url($upload);
|
||||
}
|
||||
|
||||
$path = $refs[$key] ?? null;
|
||||
|
||||
return self::isPublicPath($path) ? self::url($path) : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Support;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Domain\Media\WebsiteIntake;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Domain\Media\WebsiteMediaAlias;
|
||||
use App\Domain\Media\WebsitePresentation;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Bilder in CMS-Widgets und Abschnittshintergründen aus dem zentralen Medienbestand
|
||||
* (docs/architektur/medienzugriff-fuer-komponenten.md).
|
||||
*
|
||||
* Gespeichert wird im jeweiligen Bildschlüssel (refs.image, style.image, data.items[].image) die Kennung des
|
||||
* Inhaltselements (int). Frühere Werte sind Pfade unter cms/ (string):
|
||||
* - mit wirksamer Zuordnung (WebsiteMediaAlias) gelten sie als das zugeordnete Medium,
|
||||
* - ohne Zuordnung gelten sie weiter als öffentliches CMS-Bild (PublicMedia), bis das Widget umgestellt ist.
|
||||
*
|
||||
* Öffentlich erscheint ein Medium nur über WebsiteMedia (Website-Freigabe, Route website.media). In der
|
||||
* Redaktionsvorschau erscheint ein nicht freigegebenes Bild als Vorschaubild der Bibliothek (Route editorial.card)
|
||||
* mit Hinweis. Eine CMS-Verwendung gibt nichts frei.
|
||||
*
|
||||
* Je Anfrage gebunden (scoped): Ergebnisse werden innerhalb einer Anfrage zwischengespeichert.
|
||||
*/
|
||||
class WebsiteImage
|
||||
{
|
||||
/** @var array<string, int|string|null> */
|
||||
private array $resolved = [];
|
||||
|
||||
/** @var array<int, WebsitePresentation|false> */
|
||||
private array $presentations = [];
|
||||
|
||||
public function __construct(private readonly WebsiteMedia $media) {}
|
||||
|
||||
/**
|
||||
* Gespeicherter oder eingegebener Wert → Kennung (int), früherer Pfad (string) oder null.
|
||||
*/
|
||||
public static function normalize(mixed $value): int|string|null
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$value = array_values($value)[0] ?? null;
|
||||
}
|
||||
|
||||
if (is_int($value) && $value > 0) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (is_string($value) && preg_match('/^[1-9][0-9]*$/', $value) === 1) {
|
||||
return (int) $value;
|
||||
}
|
||||
|
||||
return PublicMedia::isPublicPath($value) ? $value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kennung des Mediums: gespeicherte Kennung oder wirksam zugeordneter früherer Pfad; sonst null.
|
||||
*/
|
||||
public function elementId(mixed $value): ?int
|
||||
{
|
||||
$value = self::normalize($value);
|
||||
|
||||
if (is_int($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! array_key_exists($value, $this->resolved)) {
|
||||
$this->resolved[$value] = WebsiteMediaAlias::effectiveFor($value)?->content_element_id;
|
||||
}
|
||||
|
||||
$id = $this->resolved[$value];
|
||||
|
||||
return is_int($id) ? $id : null;
|
||||
}
|
||||
|
||||
public function presentation(mixed $value): ?WebsitePresentation
|
||||
{
|
||||
$id = $this->elementId($value);
|
||||
|
||||
if ($id === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! array_key_exists($id, $this->presentations)) {
|
||||
$this->presentations[$id] = $this->media->present($id) ?? false;
|
||||
}
|
||||
|
||||
return $this->presentations[$id] ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bildadresse für die Darstellung. Öffentlich nur freigegebene Medien (oder frühere CMS-Bilder ohne Zuordnung);
|
||||
* in der Redaktionsvorschau zusätzlich das Vorschaubild eines nicht freigegebenen Mediums.
|
||||
*/
|
||||
public function url(mixed $value, bool $preview = false): ?string
|
||||
{
|
||||
$presentation = $this->presentation($value);
|
||||
|
||||
if ($presentation !== null) {
|
||||
return $presentation->kind === 'bild' ? $presentation->url : null;
|
||||
}
|
||||
|
||||
$id = $this->elementId($value);
|
||||
|
||||
if ($id !== null) {
|
||||
if (! $preview) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$element = ContentElement::query()->find($id);
|
||||
|
||||
return $element === null ? null : ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
||||
}
|
||||
|
||||
$legacy = self::normalize($value);
|
||||
|
||||
return is_string($legacy) ? PublicMedia::url($legacy) : null;
|
||||
}
|
||||
|
||||
/** Alternativtext: Angabe im Widget, sonst der Alternativtext des Mediums. */
|
||||
public function alt(mixed $value, mixed $override = null): string
|
||||
{
|
||||
if (is_string($override) && trim($override) !== '') {
|
||||
return trim($override);
|
||||
}
|
||||
|
||||
return $this->presentation($value)?->alt ?? '';
|
||||
}
|
||||
|
||||
/** Öffentliche Quellenzeile des Mediums (nur solange es freigegeben ist). */
|
||||
public function credit(mixed $value): ?string
|
||||
{
|
||||
return $this->presentation($value)?->credit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hinweis für die Redaktionsvorschau, wenn das gewählte Bild öffentlich nicht erscheint; sonst null.
|
||||
*/
|
||||
public function previewNotice(mixed $value, string $label = 'Das gewählte Bild'): ?string
|
||||
{
|
||||
$status = $this->status($value);
|
||||
|
||||
if ($status === null || $status['public']) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $label.' „'.$status['title'].'“ erscheint öffentlich nicht: '.$status['note'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Zustand für Editor und Vorschau.
|
||||
*
|
||||
* @return array{public: bool, state: string, title: string, note: string, thumb: ?string, manageUrl: ?string}|null
|
||||
*/
|
||||
public function status(mixed $value): ?array
|
||||
{
|
||||
$value = self::normalize($value);
|
||||
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$id = $this->elementId($value);
|
||||
|
||||
if ($id === null) {
|
||||
return [
|
||||
'public' => true,
|
||||
'state' => 'legacy',
|
||||
'title' => basename((string) $value),
|
||||
'note' => 'Früheres CMS-Bild, noch nicht in den Medienmanager übernommen.',
|
||||
'thumb' => PublicMedia::url((string) $value),
|
||||
'manageUrl' => null,
|
||||
];
|
||||
}
|
||||
|
||||
$element = ContentElement::query()->with('editorialContentKind')->find($id);
|
||||
|
||||
if ($element === null) {
|
||||
return ['public' => false, 'state' => 'missing', 'title' => 'Medium '.$id, 'note' => 'Das Medium gibt es nicht mehr.', 'thumb' => null, 'manageUrl' => null];
|
||||
}
|
||||
|
||||
$title = (string) ($element->display_title ?: $element->working_title);
|
||||
$thumb = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
||||
$manageUrl = ContentElementResource::getUrl('view', ['record' => $element]);
|
||||
$public = $this->presentation($id) !== null;
|
||||
|
||||
$note = match (true) {
|
||||
$public => 'Für die Website freigegeben.',
|
||||
$element->archived_at !== null => 'Das Medium ist archiviert.',
|
||||
filled($element->thumbnail_error) => 'Die Datei ließ sich nicht verarbeiten: '.Str::limit((string) $element->thumbnail_error, 120),
|
||||
$element->thumbnail_path === null => 'Wird gerade verarbeitet. Danach wird es automatisch für die Website freigegeben.',
|
||||
default => 'Nicht für die Website freigegeben. Die Freigabe steht im Medienmanager beim Medium unter „Beschreibung“ (Website-Freigabe).',
|
||||
};
|
||||
|
||||
return [
|
||||
'public' => $public,
|
||||
'state' => $public ? 'released' : ($element->thumbnail_path === null && ! filled($element->thumbnail_error) ? 'pending' : 'unreleased'),
|
||||
'title' => $title,
|
||||
'note' => $note,
|
||||
'thumb' => $thumb,
|
||||
'manageUrl' => $manageUrl,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft einen Wert beim Speichern. Ein früherer Pfad mit wirksamer Zuordnung wird zur Kennung des Mediums.
|
||||
*/
|
||||
public function clean(mixed $value, WidgetErrors $errors, string $errorKey): int|string|null
|
||||
{
|
||||
$raw = is_array($value) ? (array_values($value)[0] ?? null) : $value;
|
||||
$value = self::normalize($raw);
|
||||
|
||||
if ($value === null) {
|
||||
if ($raw !== null && $raw !== '') {
|
||||
$errors->add($errorKey, 'Bitte ein Bild aus dem Medienmanager wählen.');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (is_string($value)) {
|
||||
return $this->elementId($value) ?? $value;
|
||||
}
|
||||
|
||||
$element = ContentElement::query()->find($value);
|
||||
|
||||
if ($element === null || ! self::isSelectable($element)) {
|
||||
$errors->add($errorKey, 'Dieses Medium ist kein Bild für die Website (nur Bilder aus dem Medienmanager, keine Traineranleitungen).');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $element->id;
|
||||
}
|
||||
|
||||
public static function isSelectable(ContentElement $element): bool
|
||||
{
|
||||
if ($element->output_class !== 'bild' || $element->archived_at !== null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$slug = $element->editorialContentKind?->slug
|
||||
?? ($element->editorial_content_kind_id !== null ? EditorialContentKind::query()->whereKey($element->editorial_content_kind_id)->value('slug') : null);
|
||||
|
||||
return ! in_array($slug, PublicMaterialReader::CONFIDENTIAL_KINDS, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Auswahl für den Medienpicker: Bilder aus dem Medienmanager mit Vorschaubild, Titel und Freigabestatus (HTML).
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function options(?string $search = null, int $limit = 60): array
|
||||
{
|
||||
$search = trim((string) $search);
|
||||
|
||||
$elements = ContentElement::query()
|
||||
->with('editorialContentKind')
|
||||
->where('output_class', 'bild')
|
||||
->whereNull('archived_at')
|
||||
->when($search !== '', function ($query) use ($search): void {
|
||||
$like = '%'.mb_strtolower($search).'%';
|
||||
$query->where(fn ($inner) => $inner
|
||||
->whereRaw('LOWER(working_title) LIKE ?', [$like])
|
||||
->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like]));
|
||||
})
|
||||
->orderByDesc('id')
|
||||
->limit($limit)
|
||||
->get();
|
||||
|
||||
$options = [];
|
||||
foreach ($elements as $element) {
|
||||
if (self::isSelectable($element)) {
|
||||
$options[$element->id] = $this->optionHtml($element->id);
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/** HTML-Bezeichnung einer Option oder des gewählten Werts (auch für frühere Pfade). */
|
||||
public function optionHtml(mixed $value): ?string
|
||||
{
|
||||
$status = $this->status($value);
|
||||
|
||||
if ($status === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$badge = match ($status['state']) {
|
||||
'released' => ['ok', 'Website: freigegeben'],
|
||||
'pending' => ['wait', 'Wird verarbeitet'],
|
||||
'legacy' => ['quiet', 'Früheres CMS-Bild'],
|
||||
default => ['warn', 'Website: nicht freigegeben'],
|
||||
};
|
||||
$thumb = $status['thumb'] !== null
|
||||
? '<img src="'.e($status['thumb']).'" alt="" loading="lazy">'
|
||||
: '<span class="luf-media-option-empty" aria-hidden="true"></span>';
|
||||
|
||||
return '<span class="luf-media-option">'.$thumb
|
||||
.'<span class="luf-media-option-text"><strong>'.e($status['title']).'</strong>'
|
||||
.'<span class="luf-media-badge luf-media-badge-'.$badge[0].'">'.e($badge[1]).'</span></span></span>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Neues Bild direkt aus dem CMS: Datei in den Eingang legen und über WebsiteIntake als Medium anlegen.
|
||||
* Die Warteschlange leitet das Bild ab und gibt die Ableitung für die Website frei.
|
||||
*/
|
||||
public function accept(TemporaryUploadedFile $file, ?string $alt = null): ?ContentElement
|
||||
{
|
||||
$base = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)) ?: 'bild';
|
||||
$name = $base.'-'.Str::lower(Str::random(6)).'.'.($file->guessExtension() ?: 'jpg');
|
||||
|
||||
try {
|
||||
$path = $file->storeAs('cms', $name, 'cms_incoming');
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! is_string($path) || $path === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$actor = auth('staff')->user();
|
||||
|
||||
return app(WebsiteIntake::class)->acceptImage(
|
||||
$path,
|
||||
Str::title(str_replace(['-', '_'], ' ', $base)),
|
||||
null,
|
||||
filled($alt) ? trim((string) $alt) : null,
|
||||
$actor instanceof User ? $actor : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,36 @@ public function description(): string
|
||||
return 'Hervorgehobene Fläche mit Überschrift, Text und einer Schaltfläche.';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Unter 20 rem Slotbreite steht die Schaltfläche in voller Breite; Überschrift, Text und Beschriftung brechen um.';
|
||||
}
|
||||
|
||||
public function heights(): array
|
||||
{
|
||||
return [
|
||||
'auto' => 'Automatisch (nach Inhalt)',
|
||||
'fill' => 'Abschnittshöhe füllen (gleich hoch wie Nachbarplätze)',
|
||||
];
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'fluid' => 'Text und Schaltfläche untereinander, Schaltfläche volle Breite unter 20rem',
|
||||
];
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-megaphone';
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
@@ -32,7 +33,30 @@ public function label(): string
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Mehrere Karten mit Titel, Text, Linkziel und optionalem Bild. Als Raster oder kompakte Liste.';
|
||||
return 'Mehrere Karten mit Titel, Text, Linkziel und optionalem Bild. Als Raster, kompakte Liste oder mit hervorgehobener erster Karte.';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Karten stehen untereinander, sobald keine zwei 15 rem breiten Karten nebeneinander passen; die hervorgehobene Karte stapelt Bild und Text.';
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'narrow' => 'eine Karte je Zeile',
|
||||
'wide' => 'so viele Karten nebeneinander, wie bei mindestens 15rem Kartenbreite passen; hervorgehobene Karte ab 44rem mit Bild neben dem Text',
|
||||
];
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
@@ -50,6 +74,7 @@ public function variants(): array
|
||||
return [
|
||||
'standard' => 'Raster',
|
||||
'compact' => 'Kompakte Liste',
|
||||
'featured' => 'Erste Karte hervorgehoben',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -60,14 +85,14 @@ public function dataRules(): array
|
||||
'items.*.title' => ['required', 'string', 'max:120'],
|
||||
'items.*.text' => ['nullable', 'string', 'max:500'],
|
||||
'items.*.url' => ['nullable', 'string', 'max:500'],
|
||||
'items.*.image' => ['nullable', 'string', 'max:255'],
|
||||
'items.*.image' => ['nullable'],
|
||||
'items.*._upload' => ['nullable'],
|
||||
];
|
||||
}
|
||||
|
||||
public function dataFields(): array
|
||||
{
|
||||
[$image, $upload] = ImageRefFields::fields('Bild (optional)');
|
||||
[$image, $upload, $status] = ImageRefFields::fields('Bild (optional)');
|
||||
|
||||
return [
|
||||
Repeater::make('items')
|
||||
@@ -82,6 +107,7 @@ public function dataFields(): array
|
||||
->helperText('Seitenpfad wie /praevention oder eine http(s)-Adresse. Leer lassen für eine Karte ohne Link.'),
|
||||
$image,
|
||||
$upload,
|
||||
$status,
|
||||
])
|
||||
->minItems(1)
|
||||
->maxItems(12)
|
||||
@@ -115,7 +141,9 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
|
||||
public function resolve(array $widget, RenderContext $context): array
|
||||
{
|
||||
$images = app(WebsiteImage::class);
|
||||
$items = [];
|
||||
$notices = [];
|
||||
|
||||
foreach ($widget['data']['items'] ?? [] as $item) {
|
||||
if (! is_array($item) || ! filled($item['title'] ?? null)) {
|
||||
@@ -126,11 +154,15 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
'title' => $item['title'],
|
||||
'text' => $item['text'] ?? null,
|
||||
'url' => SafeUrl::isSafe($item['url'] ?? null) ? $item['url'] : null,
|
||||
'imageUrl' => PublicMedia::imageUrl($item),
|
||||
'imageUrl' => $images->url($item['image'] ?? null, $context->preview),
|
||||
];
|
||||
|
||||
if ($context->preview && ($notice = $images->previewNotice($item['image'] ?? null, 'Das Bild der Karte „'.$item['title'].'“')) !== null) {
|
||||
$notices[] = $notice;
|
||||
}
|
||||
}
|
||||
|
||||
return ['items' => $items];
|
||||
return ['items' => $items, 'imageNotice' => $notices === [] ? null : implode(' ', $notices)];
|
||||
}
|
||||
|
||||
public function mediaPaths(array $widget): array
|
||||
|
||||
@@ -37,6 +37,29 @@ public function description(): string
|
||||
return 'Ausgewählte Programme und Module; Titel und Beschreibung kommen automatisch aus den Fachdaten.';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Karten stehen untereinander, die Markentafel über dem Text; lange Titel brechen um.';
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'narrow' => 'eine Karte je Zeile, Symbolfläche über dem Text',
|
||||
'wide' => 'mehrere Karten nebeneinander ab 16rem Kartenbreite',
|
||||
];
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-rectangle-stack';
|
||||
|
||||
@@ -24,6 +24,28 @@ public function description(): string
|
||||
return 'Häufige Fragen mit Antworten.';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [2, 3, 4];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Fragen und Antworten untereinander; Antworten höchstens in Lesebreite.';
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'fluid' => 'Fragen untereinander; Antwortlänge auf Lesebreite begrenzt',
|
||||
];
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-question-mark-circle';
|
||||
|
||||
@@ -23,6 +23,28 @@ public function description(): string
|
||||
return 'Abschnittsüberschrift mit kurzem Einleitungstext.';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Überschriftengröße folgt der Platzbreite; lange Wörter werden getrennt.';
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'fluid' => 'Überschriftgröße folgt der Slotbreite',
|
||||
];
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-h1';
|
||||
|
||||
@@ -4,15 +4,23 @@
|
||||
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Group;
|
||||
|
||||
/**
|
||||
* Premium-Einstieg nach Brand-UI-Kit v1.6 (12_premium_widgets_adaptiv_v1.6, Komponente lf-hero).
|
||||
*
|
||||
* Version 2: Varianten photo_split und editorial_solid, Höhen compact/normal/large (Mindesthöhen ab 860 px
|
||||
* Containerbreite), Label, Überschriftenebene, Bildfokus in Prozent, Akzent, zwei Schaltflächen.
|
||||
* Die data-Schlüssel der Version 1 (heading, text, cta_*, alt) bleiben unverändert, damit ältere Revisionen und ein
|
||||
* Code-Rollback darstellbar bleiben.
|
||||
*/
|
||||
class HeroWidget extends WidgetType
|
||||
{
|
||||
public function key(): string
|
||||
@@ -27,7 +35,44 @@ public function label(): string
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Großer Seiteneinstieg mit Überschrift, Beschreibung, optionalem Bild und optionaler Schaltfläche.';
|
||||
return 'Markenprägender Seiteneinstieg: großes Foto mit Textfläche oder dunkle Markenfläche, Überschrift, Beschreibung und bis zu zwei Schaltflächen.';
|
||||
}
|
||||
|
||||
public function version(): int
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [3, 4];
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'wide' => 'ab 860 px Containerbreite: Foto über die ganze Fläche, Text links auf heller Fläche; Mindesthöhe nach Höheneinstellung',
|
||||
'safety' => 'unter 860 px nur technischer Sicherheitsumbruch: Foto 16:9 über dem Text, Schaltflächen ab 440 px untereinander',
|
||||
];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Für breite Plätze (3 oder 4 Einheiten). Unter 860 px Containerbreite steht das Foto über dem Text; die Höhe richtet sich dann nach dem Inhalt.';
|
||||
}
|
||||
|
||||
public function heights(): array
|
||||
{
|
||||
return [
|
||||
'compact' => 'Kompakt (mind. 400 px)',
|
||||
'normal' => 'Normal (mind. 512 px)',
|
||||
'large' => 'Groß (mind. 640 px)',
|
||||
];
|
||||
}
|
||||
|
||||
public function defaultHeight(): ?string
|
||||
{
|
||||
return 'normal';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
@@ -37,26 +82,72 @@ public function icon(): string
|
||||
|
||||
public function schematic(): array
|
||||
{
|
||||
return [[2, 3, 56, 30, 'line'], [6, 8, 26, 6, 'ink'], [6, 17, 24, 3, 'line'], [6, 24, 12, 5, 'accent'], [36, 7, 18, 22, 'image']];
|
||||
return [[2, 3, 56, 30, 'image'], [6, 8, 24, 6, 'ink'], [6, 16, 10, 2, 'accent'], [6, 21, 22, 3, 'line'], [6, 27, 12, 4, 'accent']];
|
||||
}
|
||||
|
||||
public function variants(): array
|
||||
{
|
||||
return [
|
||||
'standard' => 'Standard (Bild neben dem Text)',
|
||||
'highlight' => 'Hervorgehoben (Markenfläche)',
|
||||
'photo_split' => 'Foto mit Textfläche',
|
||||
'editorial_solid' => 'Markenfläche (ohne Foto)',
|
||||
];
|
||||
}
|
||||
|
||||
public function optionIcons(): array
|
||||
{
|
||||
return [
|
||||
'variant' => ['photo_split' => 'heroicon-o-photo', 'editorial_solid' => 'heroicon-o-swatch'],
|
||||
'height' => ['compact' => 'heroicon-o-bars-2', 'normal' => 'heroicon-o-bars-3', 'large' => 'heroicon-o-bars-4'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
'heading_level' => PremiumFields::HEADING_LEVELS,
|
||||
'accent' => ['underline' => 'Gelbe Unterstreichung', 'rays' => 'Unterstreichung und Signalstrahlen', 'none' => 'Ohne Akzent'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'heading_level' => ['Überschriftenebene', 'Der erste Einstieg einer Seite ist immer die Hauptüberschrift (H1).'],
|
||||
'accent' => ['Markenakzent', 'Freigegebene Akzente aus dem Brand-UI-Kit. Vorgabe: gelbe Unterstreichung.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Version 1 (bis Designiteration 1) → 2: Varianten abbilden, früheren Fokuspunkt in Prozent umrechnen,
|
||||
* nicht mehr vorhandene Einstellungen (focus, text_side) entfernen. Inhalte bleiben unverändert.
|
||||
*/
|
||||
public function upgrade(array $widget, int $from): array
|
||||
{
|
||||
if ($from !== 1) {
|
||||
return parent::upgrade($widget, $from);
|
||||
}
|
||||
|
||||
$widget['variant'] = in_array($widget['variant'] ?? null, ['highlight', 'editorial'], true) ? 'editorial_solid' : 'photo_split';
|
||||
$settings = is_array($widget['settings'] ?? null) ? $widget['settings'] : [];
|
||||
$data = is_array($widget['data'] ?? null) ? $widget['data'] : [];
|
||||
|
||||
if (! isset($data['focus_x'], $data['focus_y'])) {
|
||||
$data = PremiumFields::focusFromEnum($settings['focus'] ?? null) + $data;
|
||||
}
|
||||
|
||||
unset($settings['focus'], $settings['text_side']);
|
||||
$widget['settings'] = $settings;
|
||||
$widget['data'] = $data;
|
||||
|
||||
return $widget;
|
||||
}
|
||||
|
||||
public function dataRules(): array
|
||||
{
|
||||
return [
|
||||
'heading' => ['required', 'string', 'max:200'],
|
||||
'text' => ['nullable', 'string', 'max:600'],
|
||||
'cta_label' => ['nullable', 'string', 'max:80', 'required_with:data.cta_url'],
|
||||
'cta_url' => ['nullable', 'string', 'max:500', 'required_with:data.cta_label'],
|
||||
'alt' => ['nullable', 'string', 'max:300'],
|
||||
];
|
||||
] + PremiumFields::rules();
|
||||
}
|
||||
|
||||
public function refRules(): array
|
||||
@@ -67,66 +158,62 @@ public function refRules(): array
|
||||
public function dataFields(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('heading')->label('Überschrift')->required()->maxLength(200),
|
||||
Textarea::make('text')->label('Beschreibung')->rows(3)->maxLength(600),
|
||||
Grid::make(2)->schema([
|
||||
TextInput::make('cta_label')->label('Schaltfläche: Beschriftung (optional)')->maxLength(80),
|
||||
TextInput::make('cta_url')
|
||||
->label('Schaltfläche: Linkziel')
|
||||
->maxLength(500)
|
||||
->rule(SafeUrl::rule())
|
||||
->requiredWith('cta_label'),
|
||||
]),
|
||||
TextInput::make('alt')
|
||||
->label('Alternativtext des Bildes')
|
||||
->maxLength(300)
|
||||
->helperText('Pflicht, sobald ein Bild gewählt ist.'),
|
||||
PremiumFields::eyebrowField(),
|
||||
TextInput::make('heading')->label('Überschrift')->required()->maxLength(200)->live(onBlur: true),
|
||||
Textarea::make('text')->label('Beschreibung')->rows(3)->maxLength(600)->live(onBlur: true),
|
||||
PremiumFields::ctaFields(),
|
||||
PremiumFields::altField(),
|
||||
...PremiumFields::focusFields(68, 50),
|
||||
];
|
||||
}
|
||||
|
||||
public function refFields(): array
|
||||
{
|
||||
return ImageRefFields::fields();
|
||||
return ImageRefFields::fields(live: true);
|
||||
}
|
||||
|
||||
public function editorSchema(): array
|
||||
{
|
||||
[$heading, $text, $cta, $alt] = $this->dataFields();
|
||||
[$eyebrow, $heading, $text, $ctas] = $this->dataFields();
|
||||
|
||||
return [Group::make([$eyebrow, $heading, $text, $ctas])->statePath('data')];
|
||||
}
|
||||
|
||||
public function mediaSchema(): array
|
||||
{
|
||||
[, , , , $alt, $focusX, $focusY] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make([$heading, $text, $cta])->statePath('data'),
|
||||
Group::make($this->refFields())->statePath('refs'),
|
||||
Group::make([$alt])->statePath('data'),
|
||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
||||
];
|
||||
}
|
||||
|
||||
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
{
|
||||
$refs = ImageRefFields::clean($refs, $errors);
|
||||
|
||||
foreach (['text', 'cta_label', 'cta_url', 'alt'] as $key) {
|
||||
$data[$key] = filled($data[$key] ?? null) ? trim($data[$key]) : null;
|
||||
}
|
||||
|
||||
if ($data['cta_url'] !== null && ! SafeUrl::isSafe($data['cta_url'])) {
|
||||
$errors->add('data.cta_url', SafeUrl::message());
|
||||
}
|
||||
|
||||
if ($refs['image'] !== null && $data['alt'] === null) {
|
||||
$errors->add('data.alt', 'Bitte einen Alternativtext für das Bild angeben.');
|
||||
}
|
||||
$data['heading'] = trim((string) ($data['heading'] ?? ''));
|
||||
$data['text'] = filled($data['text'] ?? null) ? trim((string) $data['text']) : null;
|
||||
$data = PremiumFields::clean($data, $errors, $refs['image'] !== null);
|
||||
|
||||
return [$data, $refs];
|
||||
}
|
||||
|
||||
public function resolve(array $widget, RenderContext $context): array
|
||||
{
|
||||
$data = $widget['data'];
|
||||
$hasAction = filled($data['cta_label'] ?? null) && SafeUrl::isSafe($data['cta_url'] ?? null);
|
||||
$actions = PremiumFields::actions($widget['data']);
|
||||
|
||||
$images = app(WebsiteImage::class);
|
||||
$image = $widget['refs']['image'] ?? null;
|
||||
|
||||
return [
|
||||
'imageUrl' => PublicMedia::imageUrl($widget['refs']),
|
||||
'action' => $hasAction ? ['label' => $data['cta_label'], 'url' => $data['cta_url']] : null,
|
||||
'imageUrl' => $images->url($image, $context->preview),
|
||||
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
||||
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||
'actions' => $actions,
|
||||
'action' => $actions[0] ?? null,
|
||||
'focus' => PremiumFields::focus($widget['data'], 68, 50),
|
||||
'accent' => in_array($widget['settings']['accent'] ?? null, ['underline', 'rays', 'none'], true) ? $widget['settings']['accent'] : 'underline',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\Support\RichText;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
@@ -13,10 +15,13 @@
|
||||
use Filament\Schemas\Components\Group;
|
||||
|
||||
/**
|
||||
* Bild und Text.
|
||||
* Bild und Text, Premium-Fassung nach Brand-UI-Kit v1.6 (Komponente lf-bild-text).
|
||||
*
|
||||
* Version 1 (Bestand): data {image, alt, body} mit Klartext.
|
||||
* Version 2: data {title, body (formatierter Text), alt}, refs {image}, Varianten Bild links/rechts.
|
||||
* Version 3: zusätzlich Label, zwei Schaltflächen, Bildfokus in Prozent; Einstellungen Oberfläche, Höhe und
|
||||
* Überschriftenebene. Die Bildseite bleibt die Variante (keine doppelte Einstellung). Die Einstellung
|
||||
* format der Designiteration 1 entfällt; die Bildproportion folgt jetzt der Höhe.
|
||||
*/
|
||||
class ImageTextWidget extends WidgetType
|
||||
{
|
||||
@@ -32,12 +37,50 @@ public function label(): string
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Bild neben formatiertem Text; Bild links oder rechts, auf dem Smartphone untereinander.';
|
||||
return 'Redaktionelle Bild-Text-Komposition mit Label, formatiertem Text und bis zu zwei Schaltflächen; passt sich der Platzbreite an.';
|
||||
}
|
||||
|
||||
public function version(): int
|
||||
{
|
||||
return 2;
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'stacked' => 'unter 540 px Containerbreite: Bild über dem Text, Schaltflächen untereinander in voller Breite',
|
||||
'band' => '540 bis 899 px: flacher Bildstreifen über dem vollständigen Text (typisch zwei Einheiten)',
|
||||
'wide' => 'ab 900 px: Bild und Text nebeneinander, Bild links oder rechts nach Variante',
|
||||
];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Unter 900 px Containerbreite steht das Bild über dem Text, unabhängig von „Bild links/rechts“; die gespeicherte Seite bleibt erhalten. Text und Schaltflächen werden nie gekürzt.';
|
||||
}
|
||||
|
||||
public function heights(): array
|
||||
{
|
||||
return [
|
||||
'compact' => 'Kompakt (flacheres Bild, engere Abstände)',
|
||||
'normal' => 'Normal',
|
||||
'spacious' => 'Großzügig (höheres Bild, mehr Abstand)',
|
||||
];
|
||||
}
|
||||
|
||||
public function defaultHeight(): ?string
|
||||
{
|
||||
return 'normal';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
@@ -47,7 +90,7 @@ public function icon(): string
|
||||
|
||||
public function schematic(): array
|
||||
{
|
||||
return [[4, 6, 22, 24, 'image'], [30, 7, 24, 4, 'ink'], [30, 15, 26, 3, 'line'], [30, 21, 22, 3, 'line']];
|
||||
return [[4, 6, 22, 24, 'image'], [30, 7, 10, 2, 'accent'], [30, 11, 24, 4, 'ink'], [30, 18, 26, 3, 'line'], [30, 24, 14, 4, 'accent']];
|
||||
}
|
||||
|
||||
public function variants(): array
|
||||
@@ -58,24 +101,64 @@ public function variants(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function optionIcons(): array
|
||||
{
|
||||
return [
|
||||
'variant' => ['image_left' => 'heroicon-o-arrow-left', 'image_right' => 'heroicon-o-arrow-right'],
|
||||
'height' => ['compact' => 'heroicon-o-bars-2', 'normal' => 'heroicon-o-bars-3', 'spacious' => 'heroicon-o-bars-4'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
'surface' => ['cream' => 'Creme (Markenfläche)', 'clear' => 'Ohne eigene Fläche', 'navy' => 'Navy (dunkel)'],
|
||||
'heading_level' => PremiumFields::HEADING_LEVELS,
|
||||
];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'surface' => ['Hintergrund des Widgets', 'Unabhängig vom Abschnittshintergrund. „Ohne eigene Fläche“ übernimmt den Abschnitt.'],
|
||||
'heading_level' => ['Überschriftenebene', 'Steht das Widget als erstes auf der Seite, ist die Überschrift immer H1.'],
|
||||
];
|
||||
}
|
||||
|
||||
public function upgrade(array $widget, int $from): array
|
||||
{
|
||||
if ($from !== 1) {
|
||||
return parent::upgrade($widget, $from);
|
||||
if ($from === 1) {
|
||||
$data = $widget['data'];
|
||||
|
||||
$widget['data'] = [
|
||||
'title' => null,
|
||||
'body' => RichText::fromPlainText(is_string($data['body'] ?? null) ? $data['body'] : ''),
|
||||
'alt' => $data['alt'] ?? null,
|
||||
];
|
||||
$widget['refs'] = [
|
||||
'image' => PublicMedia::fromUploadState($data['image'] ?? null),
|
||||
];
|
||||
|
||||
return $widget;
|
||||
}
|
||||
|
||||
$data = $widget['data'];
|
||||
if ($from === 2) {
|
||||
// Designiteration 1 → Premium: Fokus in Prozent, Bildformat entfällt (Proportion folgt der Höhe).
|
||||
$settings = is_array($widget['settings'] ?? null) ? $widget['settings'] : [];
|
||||
$data = is_array($widget['data'] ?? null) ? $widget['data'] : [];
|
||||
|
||||
$widget['data'] = [
|
||||
'title' => null,
|
||||
'body' => RichText::fromPlainText(is_string($data['body'] ?? null) ? $data['body'] : ''),
|
||||
'alt' => $data['alt'] ?? null,
|
||||
];
|
||||
$widget['refs'] = [
|
||||
'image' => PublicMedia::fromUploadState($data['image'] ?? null),
|
||||
];
|
||||
if (! isset($data['focus_x'], $data['focus_y'])) {
|
||||
$data = PremiumFields::focusFromEnum($settings['focus'] ?? null) + $data;
|
||||
}
|
||||
|
||||
return $widget;
|
||||
unset($settings['focus'], $settings['format']);
|
||||
$widget['settings'] = $settings;
|
||||
$widget['data'] = $data;
|
||||
|
||||
return $widget;
|
||||
}
|
||||
|
||||
return parent::upgrade($widget, $from);
|
||||
}
|
||||
|
||||
public function dataRules(): array
|
||||
@@ -83,8 +166,7 @@ public function dataRules(): array
|
||||
return [
|
||||
'title' => ['nullable', 'string', 'max:160'],
|
||||
'body' => ['required', 'string', 'max:40000'],
|
||||
'alt' => ['nullable', 'string', 'max:300'],
|
||||
];
|
||||
] + PremiumFields::rules();
|
||||
}
|
||||
|
||||
public function refRules(): array
|
||||
@@ -95,31 +177,38 @@ public function refRules(): array
|
||||
public function dataFields(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('title')->label('Titel (optional)')->maxLength(160),
|
||||
PremiumFields::eyebrowField(),
|
||||
TextInput::make('title')->label('Überschrift')->maxLength(160)->live(onBlur: true),
|
||||
RichEditor::make('body')
|
||||
->label('Text')
|
||||
->required()
|
||||
->live(onBlur: true)
|
||||
->toolbarButtons(RichText::TOOLBAR),
|
||||
TextInput::make('alt')
|
||||
->label('Alternativtext des Bildes')
|
||||
->maxLength(300)
|
||||
->helperText('Beschreibt, was auf dem Bild zu sehen ist. Pflicht, sobald ein Bild gewählt ist.'),
|
||||
PremiumFields::ctaFields(),
|
||||
PremiumFields::altField(),
|
||||
...PremiumFields::focusFields(64, 43),
|
||||
];
|
||||
}
|
||||
|
||||
public function refFields(): array
|
||||
{
|
||||
return ImageRefFields::fields();
|
||||
return ImageRefFields::fields(live: true);
|
||||
}
|
||||
|
||||
public function editorSchema(): array
|
||||
{
|
||||
[$title, $body, $alt] = $this->dataFields();
|
||||
[$eyebrow, $title, $body, $ctas] = $this->dataFields();
|
||||
|
||||
return [Group::make([$eyebrow, $title, $body, $ctas])->statePath('data')];
|
||||
}
|
||||
|
||||
public function mediaSchema(): array
|
||||
{
|
||||
[, , , , $alt, $focusX, $focusY] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make([$title, $body])->statePath('data'),
|
||||
Group::make($this->refFields())->statePath('refs'),
|
||||
Group::make([$alt])->statePath('data'),
|
||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -127,25 +216,31 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
{
|
||||
$refs = ImageRefFields::clean($refs, $errors);
|
||||
$data['body'] = RichText::sanitize($data['body'] ?? '');
|
||||
$data['title'] = filled($data['title'] ?? null) ? trim($data['title']) : null;
|
||||
$data['alt'] = filled($data['alt'] ?? null) ? trim($data['alt']) : null;
|
||||
$data['title'] = filled($data['title'] ?? null) ? trim((string) $data['title']) : null;
|
||||
$data = PremiumFields::clean($data, $errors, $refs['image'] !== null);
|
||||
|
||||
if (RichText::isBlank($data['body'])) {
|
||||
$errors->add('data.body', 'Bitte einen Text eingeben.');
|
||||
}
|
||||
|
||||
if ($refs['image'] !== null && $data['alt'] === null) {
|
||||
$errors->add('data.alt', 'Bitte einen Alternativtext für das Bild angeben.');
|
||||
}
|
||||
|
||||
return [$data, $refs];
|
||||
}
|
||||
|
||||
public function resolve(array $widget, RenderContext $context): array
|
||||
{
|
||||
$surface = $widget['settings']['surface'] ?? 'cream';
|
||||
|
||||
$images = app(WebsiteImage::class);
|
||||
$image = $widget['refs']['image'] ?? null;
|
||||
|
||||
return [
|
||||
'imageUrl' => PublicMedia::imageUrl($widget['refs']),
|
||||
'imageUrl' => $images->url($image, $context->preview),
|
||||
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
||||
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||
'body' => RichText::sanitize(is_string($widget['data']['body'] ?? null) ? $widget['data']['body'] : ''),
|
||||
'actions' => PremiumFields::actions($widget['data']),
|
||||
'focus' => PremiumFields::focus($widget['data'], 64, 43),
|
||||
'surface' => in_array($surface, ['cream', 'clear', 'navy'], true) ? $surface : 'cream',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Types;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
|
||||
/**
|
||||
* Medien- und Materialkarte (Kit v1.7 „media“): ein Inhaltselement mit Anzeigetitel, Kurzbeschreibung, Inhaltsart und
|
||||
* Ausgabeart. Filme erscheinen als Medienkarte (grüne Aktion, Filmtafel ohne freigegebenes Bild), Dokumente und andere
|
||||
* Materialien als Materialkarte (Materialsymbol). Öffentlich nur nach den Regeln von PublicMaterialReader; die Aktion
|
||||
* führt auf die öffentliche Programmseite. Die Karte spielt nichts ab, bietet keinen Download und gibt kein Medium frei.
|
||||
*/
|
||||
class MediaCardWidget extends PremiumCardWidget
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'media_card';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Medien- und Materialkarte';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Karte zu einem Film oder Material aus der Bibliothek; Titel und Art kommen aus den Fachdaten, kein Abspielen, kein Download.';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-film';
|
||||
}
|
||||
|
||||
public function schematic(): array
|
||||
{
|
||||
return [[2, 2, 56, 32, 'line'], [5, 5, 22, 26, 'image'], [7, 7, 8, 3, 'accent'], [31, 8, 22, 4, 'ink'], [31, 15, 22, 5, 'line'], [31, 25, 14, 5, 'accent']];
|
||||
}
|
||||
|
||||
protected function refKey(): string
|
||||
{
|
||||
return 'element';
|
||||
}
|
||||
|
||||
protected function refLabel(): string
|
||||
{
|
||||
return 'Medium oder Material';
|
||||
}
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
return 'Wählbar sind alle nicht archivierten, nicht gesperrten Filme und Materialien. Öffentlich erscheint die Karte nur mit bereitgestellter Fassung und wenn der Inhalt zu einem öffentlich gezeigten Programm gehört; Traineranleitungen nie. Titel und Kurzbeschreibung pflegen Sie im Medium.';
|
||||
}
|
||||
|
||||
protected function searchSubjects(?string $term): array
|
||||
{
|
||||
return app(PublicMaterialReader::class)->search($term);
|
||||
}
|
||||
|
||||
protected function subjectLabel(mixed $id): ?string
|
||||
{
|
||||
return app(PublicMaterialReader::class)->labelFor($id);
|
||||
}
|
||||
|
||||
protected function rejectSubject(int $id): ?string
|
||||
{
|
||||
$element = ContentElement::query()->find($id);
|
||||
|
||||
return $element !== null && app(PublicMaterialReader::class)->isSelectable($element)
|
||||
? null
|
||||
: 'Dieser Inhalt ist archiviert oder gesperrt.';
|
||||
}
|
||||
|
||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||
{
|
||||
return app(PublicMaterialReader::class)->subject($id, includeNonPublic: $context->preview);
|
||||
}
|
||||
|
||||
protected function defaultActionLabel(): string
|
||||
{
|
||||
return 'Im Programm ansehen';
|
||||
}
|
||||
|
||||
protected function cardStyle(): string
|
||||
{
|
||||
return 'media';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Types;
|
||||
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Group;
|
||||
|
||||
/**
|
||||
* Gemeinsame Basis der Premium-Karten (Brand-UI-Kit v1.7, Entwurf zur visuellen Freigabe):
|
||||
* Redaktionelle Themenkarte, Medien- und Materialkarte, Modul- und Programmkarte.
|
||||
*
|
||||
* - Eine Karte je Widget, ein Widget je Platz. Das Raster ist das bestehende Abschnittsraster (1 bis 4 Einheiten);
|
||||
* es gibt kein zweites Kartenraster.
|
||||
* - refs: genau ein Fachobjekt (Kennung) und optional ein Bild aus dem öffentlichen Website-Bereich.
|
||||
* Titel, Kurzbeschreibung, Art, Zusatzangaben und Linkziel kommen zur Laufzeit aus den Fachdaten.
|
||||
* - data: nur Redaktionelles, das es im Fachobjekt nicht gibt: Beschriftung der Aktion, Hinweis, Alternativtext,
|
||||
* Bildausschnitt. Ein freies Linkziel gibt es nicht; das Ziel ist immer die öffentliche Seite des Fachobjekts.
|
||||
* - Bilder der Bibliothek (Vorschaubilder, Filmstandbilder) werden nie gezeigt.
|
||||
*/
|
||||
abstract class PremiumCardWidget extends WidgetType
|
||||
{
|
||||
public const SHOW = ['yes' => 'Anzeigen', 'no' => 'Ausblenden'];
|
||||
|
||||
/** Schlüssel des Fachobjekts in refs, zum Beispiel 'pillar'. */
|
||||
abstract protected function refKey(): string;
|
||||
|
||||
abstract protected function refLabel(): string;
|
||||
|
||||
abstract protected function refHelp(): string;
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
abstract protected function searchSubjects(?string $term): array;
|
||||
|
||||
abstract protected function subjectLabel(mixed $id): ?string;
|
||||
|
||||
/** Prüft beim Speichern, ob das Objekt gewählt werden darf; liefert sonst die Fehlermeldung. */
|
||||
abstract protected function rejectSubject(int $id): ?string;
|
||||
|
||||
abstract protected function subject(mixed $id, RenderContext $context): ?CardSubject;
|
||||
|
||||
abstract protected function defaultActionLabel(): string;
|
||||
|
||||
/** Gestaltungsvariante des Kits: editorial, media oder catalog. */
|
||||
abstract protected function cardStyle(): string;
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'widgets.premium_card';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'stacked' => 'unter 520 px Kartenbreite: Bild oder Tafel über dem Text',
|
||||
'side' => 'ab 520 px: Bild links (42 %), Text rechts (58 %); das gewählte Bildformat bleibt erhalten',
|
||||
];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Unter 520 px Kartenbreite steht das Bild über dem Text. Ab etwa 240 px nutzbar, empfohlen ab 280 px (eine Einheit ab Tablet). Texte werden nie gekürzt.';
|
||||
}
|
||||
|
||||
public function heights(): array
|
||||
{
|
||||
return [
|
||||
'auto' => 'Natürliche Höhe',
|
||||
'fill' => 'An die Zeile angleichen',
|
||||
];
|
||||
}
|
||||
|
||||
public function variants(): array
|
||||
{
|
||||
return [
|
||||
'adaptive' => 'Anpassend (ab 520 px Bild neben Text)',
|
||||
'stacked' => 'Bild immer über dem Text',
|
||||
];
|
||||
}
|
||||
|
||||
public function optionIcons(): array
|
||||
{
|
||||
return [
|
||||
'variant' => ['adaptive' => 'heroicon-o-view-columns', 'stacked' => 'heroicon-o-bars-3-bottom-left'],
|
||||
'height' => ['auto' => 'heroicon-o-arrows-pointing-in', 'fill' => 'heroicon-o-arrows-up-down'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
'format' => ['landscape' => 'Querformat 16:9', 'square' => 'Quadrat 1:1', 'portrait' => 'Hochformat 3:4'],
|
||||
'fit' => ['cover' => 'Ausschnitt füllt die Fläche', 'contain' => 'Ganzes Bild zeigen (Dokument, Poster)'],
|
||||
'heading_level' => ['h3' => 'H3', 'h2' => 'H2', 'h4' => 'H4'],
|
||||
'show_summary' => self::SHOW,
|
||||
'show_kind' => self::SHOW,
|
||||
'show_meta' => self::SHOW,
|
||||
'show_action' => self::SHOW,
|
||||
];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'format' => ['Bildformat', 'Vorgabe: Querformat 16:9. Gilt auch neben dem Text; das Motiv wird nicht nachträglich hochkant beschnitten.'],
|
||||
'fit' => ['Bilddarstellung', 'Vorgabe: Ausschnitt. „Ganzes Bild“ zeigt Dokumente und Poster vollständig auf ruhiger Fläche.'],
|
||||
'heading_level' => ['Überschriftenebene', 'Vorgabe: H3, passend unter einer Abschnittsüberschrift (H2).'],
|
||||
'show_summary' => ['Kurzbeschreibung', 'Aus den Fachdaten. Vorgabe: anzeigen.'],
|
||||
'show_kind' => ['Art oder Label', 'Zum Beispiel „Thema“ oder „Merkblatt“. Vorgabe: anzeigen.'],
|
||||
'show_meta' => ['Zusatzangaben', 'Aus den Fachdaten, zum Beispiel Ausgabeart oder Programmzugehörigkeit. Vorgabe: anzeigen.'],
|
||||
'show_action' => ['Aktion', 'Verweis auf die öffentliche Seite des Fachobjekts, falls es eine gibt. Vorgabe: anzeigen.'],
|
||||
];
|
||||
}
|
||||
|
||||
public function dataRules(): array
|
||||
{
|
||||
return [
|
||||
'action_label' => ['nullable', 'string', 'max:60'],
|
||||
'note' => ['nullable', 'string', 'max:200'],
|
||||
'alt' => ['nullable', 'string', 'max:300'],
|
||||
'focus_x' => ['nullable', 'numeric', 'between:0,100'],
|
||||
'focus_y' => ['nullable', 'numeric', 'between:0,100'],
|
||||
];
|
||||
}
|
||||
|
||||
public function refRules(): array
|
||||
{
|
||||
return [$this->refKey() => ['required', 'integer']] + ImageRefFields::rules();
|
||||
}
|
||||
|
||||
public function dataFields(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('action_label')
|
||||
->label('Beschriftung der Aktion (optional)')
|
||||
->maxLength(60)
|
||||
->placeholder($this->defaultActionLabel())
|
||||
->live(onBlur: true)
|
||||
->helperText('Das Linkziel ist immer die öffentliche Seite des gewählten Objekts und kann nicht frei gesetzt werden.'),
|
||||
TextInput::make('note')
|
||||
->label('Hinweis (optional)')
|
||||
->maxLength(200)
|
||||
->live(onBlur: true)
|
||||
->helperText('Kurzer redaktioneller Satz über der Aktion, zum Beispiel „Für die nächste Kursstunde“. Begründet keine Berechtigung.'),
|
||||
PremiumFields::altField(),
|
||||
...PremiumFields::focusFields(66, 45),
|
||||
];
|
||||
}
|
||||
|
||||
public function refFields(): array
|
||||
{
|
||||
return [$this->subjectField(), ...ImageRefFields::fields(live: true)];
|
||||
}
|
||||
|
||||
public function editorSchema(): array
|
||||
{
|
||||
[$action, $note] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make([$this->subjectField()])->statePath('refs'),
|
||||
Group::make([$action, $note])->statePath('data'),
|
||||
];
|
||||
}
|
||||
|
||||
public function mediaSchema(): array
|
||||
{
|
||||
[, , $alt, $focusX, $focusY] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make(ImageRefFields::fields('Kartenbild', live: true))->statePath('refs'),
|
||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
||||
];
|
||||
}
|
||||
|
||||
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
{
|
||||
$key = $this->refKey();
|
||||
$id = (int) $refs[$key];
|
||||
$rejection = $this->rejectSubject($id);
|
||||
|
||||
if ($rejection !== null) {
|
||||
$errors->add("refs.$key", $rejection);
|
||||
}
|
||||
|
||||
$refs[$key] = $id;
|
||||
$refs = ImageRefFields::clean($refs, $errors);
|
||||
|
||||
foreach (['action_label', 'note', 'alt'] as $field) {
|
||||
$data[$field] = filled($data[$field] ?? null) ? trim((string) $data[$field]) : null;
|
||||
}
|
||||
|
||||
foreach (['focus_x', 'focus_y'] as $field) {
|
||||
$value = $data[$field] ?? null;
|
||||
$data[$field] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
||||
}
|
||||
|
||||
return [$data, $refs];
|
||||
}
|
||||
|
||||
public function resolve(array $widget, RenderContext $context): array
|
||||
{
|
||||
$settings = $widget['settings'];
|
||||
$option = fn (string $key, string $default): string => is_string($settings[$key] ?? null) && isset($this->settingOptions()[$key][$settings[$key]]) ? $settings[$key] : $default;
|
||||
$data = $widget['data'];
|
||||
|
||||
$subject = $this->subject($widget['refs'][$this->refKey()] ?? null, $context);
|
||||
|
||||
return [
|
||||
'subject' => $subject,
|
||||
'cardStyle' => $subject?->style ?? $this->cardStyle(),
|
||||
'imageUrl' => app(WebsiteImage::class)->url($widget['refs']['image'] ?? null, $context->preview),
|
||||
'alt' => app(WebsiteImage::class)->alt($widget['refs']['image'] ?? null, $data['alt'] ?? null),
|
||||
'imageNotice' => $context->preview ? app(WebsiteImage::class)->previewNotice($widget['refs']['image'] ?? null, 'Das Kartenbild') : null,
|
||||
'focus' => PremiumFields::focus($data, 66, 45),
|
||||
'format' => $option('format', 'landscape'),
|
||||
'fit' => $option('fit', 'cover'),
|
||||
'headingTag' => $option('heading_level', 'h3'),
|
||||
'show' => [
|
||||
'summary' => ! array_key_exists('show_summary', $this->settings()) || $option('show_summary', 'yes') === 'yes',
|
||||
'kind' => ! array_key_exists('show_kind', $this->settings()) || $option('show_kind', 'yes') === 'yes',
|
||||
'meta' => $option('show_meta', 'yes') === 'yes',
|
||||
'action' => $option('show_action', 'yes') === 'yes',
|
||||
],
|
||||
'actionLabel' => filled($data['action_label'] ?? null) ? (string) $data['action_label'] : $this->defaultActionLabel(),
|
||||
'note' => filled($data['note'] ?? null) ? (string) $data['note'] : null,
|
||||
'stacked' => $widget['variant'] === 'stacked',
|
||||
];
|
||||
}
|
||||
|
||||
public function mediaPaths(array $widget): array
|
||||
{
|
||||
$image = $widget['refs']['image'] ?? null;
|
||||
|
||||
return PublicMedia::isPublicPath($image) ? [$image] : [];
|
||||
}
|
||||
|
||||
public function summary(array $widget): string
|
||||
{
|
||||
$label = $this->subjectLabel($widget['refs'][$this->refKey()] ?? null);
|
||||
|
||||
return $label ?? 'Kein Objekt gewählt';
|
||||
}
|
||||
|
||||
private function subjectField(): Select
|
||||
{
|
||||
return Select::make($this->refKey())
|
||||
->label($this->refLabel())
|
||||
->helperText($this->refHelp())
|
||||
->required()
|
||||
->live()
|
||||
->searchable()
|
||||
->getSearchResultsUsing(fn (?string $search): array => $this->searchSubjects($search))
|
||||
->getOptionLabelUsing(fn (mixed $value): ?string => $this->subjectLabel($value))
|
||||
->options(fn (): array => $this->searchSubjects(null));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Types;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
|
||||
/**
|
||||
* Modul- und Programmkarte (Kit v1.7 „catalog“): ein Programm oder Modul über PublicCatalogReader, dieselbe
|
||||
* Freigaberegel wie die Programm- und Modulkarten (Programme öffentlich mit Programmseite, Module nur in der
|
||||
* Redaktionsvorschau). Die Art ist immer sichtbar benannt. Ohne Bild trägt eine Navy-Tafel die Art.
|
||||
* Kein Preis, kein Angebot, keine Kaufaktion; eine Karte ist kein Lizenzartikel.
|
||||
*/
|
||||
class ProgramCardWidget extends PremiumCardWidget
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'program_card';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Programm- oder Modulkarte';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Karte zu einem Programm oder Modul; Titel, Beschreibung und Art kommen aus den Fachdaten, ohne Preis und ohne Kaufaktion.';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-academic-cap';
|
||||
}
|
||||
|
||||
public function schematic(): array
|
||||
{
|
||||
return [[2, 2, 56, 32, 'line'], [5, 5, 22, 26, 'ink'], [8, 24, 10, 2, 'accent'], [31, 8, 10, 2, 'line'], [31, 13, 22, 4, 'ink'], [31, 25, 14, 5, 'ink']];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
// Die Art (Programm oder Modul) bleibt immer sichtbar; sie lässt sich nicht ausblenden.
|
||||
$settings = parent::settings();
|
||||
unset($settings['show_kind']);
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
protected function refKey(): string
|
||||
{
|
||||
return 'composition';
|
||||
}
|
||||
|
||||
protected function refLabel(): string
|
||||
{
|
||||
return 'Programm oder Modul';
|
||||
}
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
return 'Wählbar sind Programme und Module mit bereitgestellter Fassung. Öffentlich erscheinen nur Programme mit Anzeigefreigabe (mit Programmseite); Module haben keine öffentliche Seite und erscheinen nur in der Redaktionsvorschau.';
|
||||
}
|
||||
|
||||
protected function searchSubjects(?string $term): array
|
||||
{
|
||||
return app(PublicCatalogReader::class)->cardSearch($term);
|
||||
}
|
||||
|
||||
protected function subjectLabel(mixed $id): ?string
|
||||
{
|
||||
return app(PublicCatalogReader::class)->cardLabelFor($id);
|
||||
}
|
||||
|
||||
protected function rejectSubject(int $id): ?string
|
||||
{
|
||||
$composition = Composition::query()->with('editorialContentKind')->find($id);
|
||||
|
||||
return $composition !== null && app(PublicCatalogReader::class)->isCardSelectable($composition)
|
||||
? null
|
||||
: 'Dieses Objekt ist kein Programm oder Modul mit bereitgestellter Fassung.';
|
||||
}
|
||||
|
||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||
{
|
||||
return app(PublicCatalogReader::class)->subject($id, includeNonPublic: $context->preview);
|
||||
}
|
||||
|
||||
protected function defaultActionLabel(): string
|
||||
{
|
||||
return 'Programm ansehen';
|
||||
}
|
||||
|
||||
protected function cardStyle(): string
|
||||
{
|
||||
return 'catalog';
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,28 @@ public function description(): string
|
||||
return 'Längerer Text in Absätzen. Eine Leerzeile beginnt einen neuen Absatz.';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Fließtext bricht um; Zeilen höchstens etwa 70 Zeichen.';
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'fluid' => 'Zeilenlänge höchstens etwa 70 Zeichen',
|
||||
];
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-bars-3-bottom-left';
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Types;
|
||||
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
|
||||
/**
|
||||
* Redaktionelle Themenkarte (Kit v1.7 „editorial“): ein Thema (fachliche Säule) mit Name, Text für die Website und
|
||||
* Verweis auf die Themenseite /themen/{slug}. Ruhige Textaktion mit gelber Unterstreichung. Wählbar sind alle Säulen;
|
||||
* ein nicht veröffentlichtes Thema erscheint nur in der Redaktionsvorschau, öffentlich nicht.
|
||||
*/
|
||||
class TopicCardWidget extends PremiumCardWidget
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'topic_card';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Themenkarte';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Redaktionelle Karte zu einem veröffentlichten Thema; Name, Kurzbeschreibung und Ziel kommen aus dem Thema.';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-bookmark-square';
|
||||
}
|
||||
|
||||
public function schematic(): array
|
||||
{
|
||||
return [[2, 2, 56, 32, 'line'], [5, 5, 22, 26, 'image'], [31, 8, 10, 2, 'accent'], [31, 13, 22, 4, 'ink'], [31, 20, 20, 3, 'line'], [31, 27, 12, 2, 'accent']];
|
||||
}
|
||||
|
||||
protected function refKey(): string
|
||||
{
|
||||
return 'pillar';
|
||||
}
|
||||
|
||||
protected function refLabel(): string
|
||||
{
|
||||
return 'Thema';
|
||||
}
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
return 'Alle fachlichen Säulen sind wählbar. Öffentlich erscheint die Karte nur, wenn das Thema veröffentlicht ist; Name und Text pflegen Sie unter „Fachliche Säulen“, nicht hier.';
|
||||
}
|
||||
|
||||
protected function searchSubjects(?string $term): array
|
||||
{
|
||||
$term = trim((string) $term);
|
||||
|
||||
return Pillar::query()
|
||||
->orderBy('sort_order')
|
||||
->orderBy('name')
|
||||
->when($term !== '', fn ($query) => $query->whereRaw('LOWER(name) LIKE ?', ['%'.mb_strtolower($term).'%']))
|
||||
->limit(50)
|
||||
->get()
|
||||
->mapWithKeys(fn (Pillar $pillar): array => [$pillar->id => $this->optionLabel($pillar)])
|
||||
->all();
|
||||
}
|
||||
|
||||
protected function subjectLabel(mixed $id): ?string
|
||||
{
|
||||
$pillar = is_numeric($id) ? Pillar::query()->find((int) $id) : null;
|
||||
|
||||
return $pillar === null ? null : $this->optionLabel($pillar);
|
||||
}
|
||||
|
||||
protected function rejectSubject(int $id): ?string
|
||||
{
|
||||
return Pillar::query()->whereKey($id)->exists() ? null : 'Dieses Thema gibt es nicht.';
|
||||
}
|
||||
|
||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||
{
|
||||
$pillar = is_numeric($id) ? Pillar::query()->find((int) $id) : null;
|
||||
|
||||
if ($pillar === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$public = self::isPublic($pillar);
|
||||
|
||||
if (! $public && ! $context->preview) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$summary = filled($pillar->public_summary) ? trim((string) $pillar->public_summary) : null;
|
||||
$pages = $pillar->pages()->whereNotNull('published_revision_id')->count();
|
||||
$missing = [];
|
||||
|
||||
if ($summary === null) {
|
||||
$missing[] = 'Kein Text für die Website gepflegt (Fachliche Säulen → Text für die Website).';
|
||||
}
|
||||
|
||||
return new CardSubject(
|
||||
title: (string) $pillar->name,
|
||||
summary: $summary,
|
||||
kind: 'Thema',
|
||||
badge: null,
|
||||
meta: $pages > 0 ? [$pages === 1 ? '1 Seite zum Thema' : $pages.' Seiten zum Thema'] : [],
|
||||
url: $public ? $pillar->publicUrl() : null,
|
||||
public: $public,
|
||||
notice: $public ? null : 'Nur in der Redaktionsvorschau sichtbar: Das Thema ist nicht veröffentlicht (Fachliche Säulen → Öffentliche Adresse und „Auf der Website veröffentlichen“).',
|
||||
missing: $missing,
|
||||
);
|
||||
}
|
||||
|
||||
/** Öffentlich ist ein Thema mit Veröffentlichung und öffentlicher Adresse (dieselbe Regel wie /themen). */
|
||||
public static function isPublic(Pillar $pillar): bool
|
||||
{
|
||||
return $pillar->published_at !== null && filled($pillar->slug);
|
||||
}
|
||||
|
||||
private function optionLabel(Pillar $pillar): string
|
||||
{
|
||||
return $pillar->name.' · Thema · '.(self::isPublic($pillar) ? 'veröffentlicht' : 'nicht veröffentlicht, nur Redaktionsvorschau');
|
||||
}
|
||||
|
||||
protected function defaultActionLabel(): string
|
||||
{
|
||||
return 'Thema entdecken';
|
||||
}
|
||||
|
||||
protected function cardStyle(): string
|
||||
{
|
||||
return 'editorial';
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,20 @@ public function register(WidgetType $type): void
|
||||
throw new InvalidArgumentException("Widget „{$key}“ braucht eine Schemaversion ab 1.");
|
||||
}
|
||||
|
||||
// Gemeinsamer Layoutvertrag (ADR-38): Breiten, Vorzugsbreite und Höhen aus festen Wertebereichen.
|
||||
$units = $type->supportedUnits();
|
||||
if ($units === [] || array_diff($units, [1, 2, 3, 4]) !== [] || $units !== array_values(array_unique($units)) || ! $type->supportsUnits($type->preferredUnits())) {
|
||||
throw new InvalidArgumentException("Widget „{$key}“ braucht unterstützte Breiten zwischen 1 und 4 Rastereinheiten und eine darin enthaltene Vorzugsbreite.");
|
||||
}
|
||||
|
||||
if (array_diff(array_keys($type->heights()), array_keys(WidgetType::HEIGHTS)) !== []) {
|
||||
throw new InvalidArgumentException("Widget „{$key}“ verwendet eine Höhe außerhalb des gemeinsamen Vokabulars.");
|
||||
}
|
||||
|
||||
if (array_key_exists('height', $type->settings())) {
|
||||
throw new InvalidArgumentException("Widget „{$key}“ deklariert die Höhe über heights(), nicht über settings().");
|
||||
}
|
||||
|
||||
if ($type->variants() === []) {
|
||||
throw new InvalidArgumentException("Widget „{$key}“ braucht mindestens eine Darstellungsvariante.");
|
||||
}
|
||||
@@ -137,7 +151,7 @@ public function upcast(array $block): ?array
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft und bereinigt Bausteine für eine neue Revision.
|
||||
* Prüft und bereinigt eine flache Bausteinliste (Fehlerschlüssel "blocks.N…").
|
||||
*
|
||||
* @param array<int|string, mixed> $blocks
|
||||
* @return list<array{id: string, type: string, v: int, variant: string, settings: array<string, mixed>, data: array<string, mixed>, refs: array<string, mixed>}>
|
||||
@@ -148,42 +162,53 @@ public function normalize(array $blocks): array
|
||||
$seenIds = [];
|
||||
|
||||
foreach (array_values($blocks) as $index => $block) {
|
||||
if (! is_array($block)) {
|
||||
throw ValidationException::withMessages([
|
||||
"blocks.$index" => 'Ein Baustein ist unvollständig.',
|
||||
]);
|
||||
}
|
||||
|
||||
if (! $this->has($block['type'] ?? null)) {
|
||||
throw ValidationException::withMessages([
|
||||
"blocks.$index.type" => 'Dieser Bausteintyp ist nicht freigegeben.',
|
||||
]);
|
||||
}
|
||||
|
||||
$type = $this->get($block['type']);
|
||||
|
||||
if (array_key_exists('v', $block) && (int) $block['v'] > $type->version()) {
|
||||
throw ValidationException::withMessages([
|
||||
"blocks.$index.v" => 'Dieser Baustein stammt aus einer neueren Programmfassung und kann hier nicht gespeichert werden.',
|
||||
]);
|
||||
}
|
||||
|
||||
$requested = $block['variant'] ?? null;
|
||||
$isCurrent = array_key_exists('v', $block) && (int) $block['v'] === $type->version();
|
||||
|
||||
if ($isCurrent && is_string($requested) && $requested !== '' && ! array_key_exists($requested, $type->variants())) {
|
||||
throw ValidationException::withMessages([
|
||||
"blocks.$index.variant" => 'Diese Darstellungsvariante ist für den Baustein nicht freigegeben.',
|
||||
]);
|
||||
}
|
||||
|
||||
$widget = $this->upcast($block);
|
||||
$normalized[] = $this->validateOne($type, $widget, $index, $seenIds);
|
||||
$normalized[] = $this->normalizeWidget($block, "blocks.$index", $seenIds);
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft und bereinigt einen einzelnen Baustein für eine neue Revision. Der Aufrufer führt die Menge
|
||||
* bereits vergebener Kennungen über die ganze Seite, damit kopierte Widgets neue Kennungen erhalten.
|
||||
*
|
||||
* @param array<string, true> $seenIds
|
||||
* @return array{id: string, type: string, v: int, variant: string, settings: array<string, mixed>, data: array<string, mixed>, refs: array<string, mixed>}
|
||||
*/
|
||||
public function normalizeWidget(mixed $block, string $errorPrefix, array &$seenIds): array
|
||||
{
|
||||
if (! is_array($block)) {
|
||||
throw ValidationException::withMessages([
|
||||
$errorPrefix => 'Ein Baustein ist unvollständig.',
|
||||
]);
|
||||
}
|
||||
|
||||
if (! $this->has($block['type'] ?? null)) {
|
||||
throw ValidationException::withMessages([
|
||||
"$errorPrefix.type" => 'Dieser Bausteintyp ist nicht freigegeben.',
|
||||
]);
|
||||
}
|
||||
|
||||
$type = $this->get($block['type']);
|
||||
|
||||
if (array_key_exists('v', $block) && (int) $block['v'] > $type->version()) {
|
||||
throw ValidationException::withMessages([
|
||||
"$errorPrefix.v" => 'Dieser Baustein stammt aus einer neueren Programmfassung und kann hier nicht gespeichert werden.',
|
||||
]);
|
||||
}
|
||||
|
||||
$requested = $block['variant'] ?? null;
|
||||
$isCurrent = array_key_exists('v', $block) && (int) $block['v'] === $type->version();
|
||||
|
||||
if ($isCurrent && is_string($requested) && $requested !== '' && ! array_key_exists($requested, $type->variants())) {
|
||||
throw ValidationException::withMessages([
|
||||
"$errorPrefix.variant" => 'Diese Darstellungsvariante ist für den Baustein nicht freigegeben.',
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->validateOne($type, $this->upcast($block), $errorPrefix, $seenIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gespeicherte Bausteine einer Revision als aktuelle Hüllen; unbekannte Arten entfallen.
|
||||
*
|
||||
@@ -241,7 +266,7 @@ public function mediaPaths(?array $blocks): array
|
||||
* @param array<string, true> $seenIds
|
||||
* @return array{id: string, type: string, v: int, variant: string, settings: array<string, mixed>, data: array<string, mixed>, refs: array<string, mixed>}
|
||||
*/
|
||||
private function validateOne(WidgetType $type, array $widget, int $index, array &$seenIds): array
|
||||
private function validateOne(WidgetType $type, array $widget, string $errorPrefix, array &$seenIds): array
|
||||
{
|
||||
$errors = new WidgetErrors;
|
||||
|
||||
@@ -251,7 +276,7 @@ private function validateOne(WidgetType $type, array $widget, int $index, array
|
||||
}
|
||||
|
||||
$settings = [];
|
||||
$allowedSettings = $type->settings();
|
||||
$allowedSettings = $type->settingOptions();
|
||||
foreach ($widget['settings'] as $key => $value) {
|
||||
if ($value === null || $value === '') {
|
||||
continue;
|
||||
@@ -292,7 +317,7 @@ private function validateOne(WidgetType $type, array $widget, int $index, array
|
||||
if (! $errors->isEmpty()) {
|
||||
$messages = [];
|
||||
foreach ($errors->all() as $key => $list) {
|
||||
$messages["blocks.$index.$key"] = $list;
|
||||
$messages["$errorPrefix.$key"] = $list;
|
||||
}
|
||||
|
||||
throw ValidationException::withMessages($messages);
|
||||
|
||||
@@ -61,6 +61,7 @@ public function renderWidget(array $widget, RenderContext $context, bool $first
|
||||
'refs' => $widget['refs'],
|
||||
'variant' => $widget['variant'],
|
||||
'settings' => $widget['settings'],
|
||||
'height' => $type->height($widget),
|
||||
'first' => $first,
|
||||
'context' => $context,
|
||||
] + $type->resolve($widget, $context))->render());
|
||||
@@ -71,7 +72,11 @@ public function renderWidget(array $widget, RenderContext $context, bool $first
|
||||
|
||||
$id = is_string($widget['id'] ?? null) ? ' id="abschnitt-'.e($widget['id']).'"' : '';
|
||||
|
||||
return '<section class="block widget widget-'.e(str_replace('_', '-', $widget['type'])).' widget-variant-'.e(str_replace('_', '-', $widget['variant'])).'"'.$id.'>'
|
||||
// Gemeinsamer Layoutvertrag (ADR-38): Höhe als Klasse an der Hülle, nur wenn die Art Höhen anbietet.
|
||||
$height = $type->height($widget);
|
||||
$heightClass = $height !== null ? ' widget-height-'.e($height) : '';
|
||||
|
||||
return '<section class="block widget widget-'.e(str_replace('_', '-', $widget['type'])).' widget-variant-'.e(str_replace('_', '-', $widget['variant'])).$heightClass.'"'.$id.'>'
|
||||
.$inner
|
||||
.'</section>';
|
||||
}
|
||||
|
||||
@@ -34,6 +34,113 @@ public function version(): int
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gemeinsames Höhenvokabular aller Widget-Arten (ADR-38). Eine Art bietet davon nur die sinnvollen Werte an
|
||||
* (heights()). Die Höhe ist ein Gestaltungsparameter, nie eine Begrenzung: Inhalte erhalten immer den nötigen Platz.
|
||||
*/
|
||||
public const HEIGHTS = [
|
||||
'auto' => 'Automatisch',
|
||||
'compact' => 'Kompakt',
|
||||
'normal' => 'Normal',
|
||||
'large' => 'Groß',
|
||||
'spacious' => 'Großzügig',
|
||||
'fill' => 'Abschnittshöhe füllen',
|
||||
];
|
||||
|
||||
/**
|
||||
* Gemeinsamer Layoutvertrag (ADR-38), Teil 1: zulässige Platzbreiten in logischen Rastereinheiten (1 bis 4).
|
||||
* Ein Platz mit nicht unterstützter Breite wird beim Speichern abgewiesen. Auf Tablet und Smartphone stapeln die
|
||||
* Plätze; dort bestimmt die tatsächliche Containerbreite die Darstellung (Container-Abfragen), nicht die Einheitenzahl.
|
||||
*
|
||||
* @return list<int>
|
||||
*/
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function supportsUnits(int $units): bool
|
||||
{
|
||||
return in_array($units, $this->supportedUnits(), true);
|
||||
}
|
||||
|
||||
/** Kleinste zulässige Platzbreite; abgeleitet aus supportedUnits(). */
|
||||
public function minUnits(): int
|
||||
{
|
||||
return min($this->supportedUnits());
|
||||
}
|
||||
|
||||
/** Lesbare Angabe der zulässigen Platzbreiten, zum Beispiel „1 bis 4“ oder „3 oder 4“. */
|
||||
public function unitsLabel(): string
|
||||
{
|
||||
$units = $this->supportedUnits();
|
||||
|
||||
if (count($units) === 1) {
|
||||
return (string) $units[0];
|
||||
}
|
||||
|
||||
if ($units === range(min($units), max($units)) && count($units) > 2) {
|
||||
return min($units).' bis '.max($units);
|
||||
}
|
||||
|
||||
$last = array_pop($units);
|
||||
|
||||
return implode(', ', $units).' oder '.$last;
|
||||
}
|
||||
|
||||
/** Empfohlene Slotbreite in Rastereinheiten; Hinweis in der Widget-Auswahl. */
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Darstellungsstufen nach verfügbarer Breite (Container-Abfragen in der Widget-Ansicht): Kennung => Beschreibung.
|
||||
* Dokumentiert, wie sich das Widget an schmale und breite Slots anpasst.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function stages(): array
|
||||
{
|
||||
return ['fluid' => 'passt sich fließend an jede Slotbreite an'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gemeinsamer Layoutvertrag, Teil 2: angebotene Höhen (Schlüssel aus HEIGHTS => Bezeichnung im Editor).
|
||||
* Leer: keine Höhenwahl, die Höhe folgt dem Inhalt. Der erste Eintrag ist die Vorgabe.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function heights(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function defaultHeight(): ?string
|
||||
{
|
||||
$key = array_key_first($this->heights());
|
||||
|
||||
return $key === null ? null : (string) $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wirksame Höhe einer Instanz (gespeicherte Einstellung oder Vorgabe).
|
||||
*
|
||||
* @param array<string, mixed> $widget
|
||||
*/
|
||||
public function height(array $widget): ?string
|
||||
{
|
||||
$height = $widget['settings']['height'] ?? null;
|
||||
|
||||
return is_string($height) && array_key_exists($height, $this->heights()) ? $height : $this->defaultHeight();
|
||||
}
|
||||
|
||||
/** Gemeinsamer Layoutvertrag, Teil 3: Verhalten bei reduziertem Platzangebot (Hinweis im Editor und in der Dokumentation). */
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Text bricht um, nichts wird abgeschnitten.';
|
||||
}
|
||||
|
||||
/** Heroicon-Name für Auswahl und Liste im Editor. */
|
||||
public function icon(): string
|
||||
{
|
||||
@@ -76,6 +183,44 @@ public function settings(): array
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Bezeichnungen der Einstellungen im Editor: Schlüssel => [Bezeichnung, Hilfetext].
|
||||
* Ohne leere Auswahl gilt die Vorgabe der Darstellung.
|
||||
*
|
||||
* @return array<string, array{0: string, 1?: string}>
|
||||
*/
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Alle zulässigen Einstellungen einschließlich der gemeinsamen Höhe. Registry-Prüfung, Editor und Darstellung
|
||||
* verwenden ausschließlich diese Zusammenführung.
|
||||
*
|
||||
* @return array<string, array<string, string>>
|
||||
*/
|
||||
final public function settingOptions(): array
|
||||
{
|
||||
$options = $this->settings();
|
||||
|
||||
if ($this->heights() !== []) {
|
||||
$options['height'] = $this->heights();
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Symbole für die visuelle Auswahl im Editor: 'variant' oder Einstellungsschlüssel => [Wert => Heroicon].
|
||||
*
|
||||
* @return array<string, array<string, string>>
|
||||
*/
|
||||
public function optionIcons(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüfregeln für data. Schlüssel relativ zu data (zum Beispiel 'heading', 'items.*.title').
|
||||
*
|
||||
@@ -116,6 +261,17 @@ public function refFields(): array
|
||||
*
|
||||
* @return list<Component>
|
||||
*/
|
||||
/**
|
||||
* Felder der Gruppe „Medien“ im Bearbeitungsdialog (Bild, Bildausschnitt, Alternativtext). Leer: keine eigene Gruppe;
|
||||
* Verweise stehen dann mit im Inhalt (editorSchema()).
|
||||
*
|
||||
* @return list<Component>
|
||||
*/
|
||||
public function mediaSchema(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function editorSchema(): array
|
||||
{
|
||||
$schema = [];
|
||||
|
||||
@@ -52,6 +52,18 @@ public function forElementUpload(ContentElement $element, string $incoming): voi
|
||||
$this->rememberElement($element, 'eigen');
|
||||
}
|
||||
|
||||
public function forWebsiteImage(ContentElement $element, string $incoming): void
|
||||
{
|
||||
if ($element->output_class !== 'bild' || ! $this->incomingIsSafe($incoming)) {
|
||||
$this->fail($element, 'Das Bild für die Website wurde nicht übernommen.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->still($element, Storage::disk('cms_incoming'), $incoming, 'element-'.$element->id);
|
||||
$this->rememberElement($element, 'eigen');
|
||||
}
|
||||
|
||||
public function forElementFrame(ContentElement $element, ContentElementVersion $version, float $seconds): void
|
||||
{
|
||||
if ($version->content_element_id !== $element->id || $element->output_class !== 'film') {
|
||||
@@ -201,6 +213,14 @@ private function readableDerived(mixed $path, string $prefix): bool
|
||||
return Storage::disk('media_derived')->exists($path);
|
||||
}
|
||||
|
||||
private function incomingIsSafe(string $incoming): bool
|
||||
{
|
||||
return (str_starts_with($incoming, 'cms/') || str_starts_with($incoming, 'vorschau/'))
|
||||
&& ! str_contains($incoming, '..')
|
||||
&& preg_match('#^(cms|vorschau)/[A-Za-z0-9._\-/]+$#', $incoming) === 1
|
||||
&& Storage::disk('cms_incoming')->exists($incoming);
|
||||
}
|
||||
|
||||
private function secondText(float $seconds): string
|
||||
{
|
||||
$seconds = max(0, min(7200, $seconds));
|
||||
@@ -271,9 +291,15 @@ private function still(ContentElement|Composition $subject, Filesystem $disk, st
|
||||
|
||||
$width = imagesx($image);
|
||||
$height = imagesy($image);
|
||||
$targetWidth = 640;
|
||||
// Bilder (Ausgabeart „bild“) dienen auch als Website-Ableitung für Einstieg und Hintergrund. 640 px wären dort
|
||||
// sichtbar unscharf; deshalb bis 2400 px, nie vergrößert. Filmstandbilder und Modulvorschauen bleiben bei 640 px.
|
||||
$targetWidth = $subject instanceof ContentElement && $subject->output_class === 'bild'
|
||||
? max(1, min(2400, $width))
|
||||
: 640;
|
||||
$targetHeight = (int) max(1, round($height * ($targetWidth / max(1, $width))));
|
||||
$canvas = imagecreatetruecolor($targetWidth, $targetHeight);
|
||||
// Transparente Flächen (PNG, GIF) werden im JPEG weiß statt schwarz.
|
||||
imagefill($canvas, 0, 0, (int) imagecolorallocate($canvas, 255, 255, 255));
|
||||
imagecopyresampled($canvas, $image, 0, 0, 0, 0, $targetWidth, $targetHeight, $width, $height);
|
||||
ob_start();
|
||||
imagejpeg($canvas, null, 82);
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Jobs\AcceptWebsiteImage;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Nimmt ein neues Website-Bild in den Medienmanager auf.
|
||||
* Die Warteschlange erzeugt danach die Ableitung und gibt sie frei.
|
||||
*/
|
||||
class WebsiteIntake
|
||||
{
|
||||
public function acceptImage(
|
||||
string $incomingPath,
|
||||
string $title,
|
||||
?string $credit = null,
|
||||
?string $alt = null,
|
||||
?User $actor = null,
|
||||
): ContentElement {
|
||||
$title = trim($title);
|
||||
|
||||
if ($title === '') {
|
||||
throw new DomainRuleException('Der Titel fehlt.');
|
||||
}
|
||||
|
||||
if (! $this->incomingIsReadable($incomingPath)) {
|
||||
throw new DomainRuleException('Die Bilddatei liegt nicht im Eingang.');
|
||||
}
|
||||
|
||||
$element = app(ContentService::class)->createElement('bild', 'bild', $title);
|
||||
app(IdentityProfile::class)->fill($element, [
|
||||
'display_title' => $title,
|
||||
'website_credit' => $credit,
|
||||
'website_alt' => $alt,
|
||||
], $actor);
|
||||
AcceptWebsiteImage::dispatch($element->id, $incomingPath, $actor?->id);
|
||||
|
||||
return $element->fresh();
|
||||
}
|
||||
|
||||
private function incomingIsReadable(string $path): bool
|
||||
{
|
||||
return (str_starts_with($path, 'cms/') || str_starts_with($path, 'vorschau/'))
|
||||
&& ! str_contains($path, '..')
|
||||
&& preg_match('#^(cms|vorschau)/[A-Za-z0-9._\-/]+$#', $path) === 1
|
||||
&& Storage::disk('cms_incoming')->exists($path);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Lesesicht für Hero, Teaser und Slideshow.
|
||||
* Liefert nur eine freigegebene öffentliche Ableitung, sonst nichts.
|
||||
*/
|
||||
class WebsiteMedia
|
||||
{
|
||||
public function present(ContentElement|int $element): ?WebsitePresentation
|
||||
{
|
||||
$element = $element instanceof ContentElement
|
||||
? $element
|
||||
: ContentElement::query()->find($element);
|
||||
|
||||
if (! $element instanceof ContentElement || $element->website_released_at === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$path = $element->website_public_path;
|
||||
$expected = '#^website/'.$element->id.'/datei\.[a-z0-9]+$#';
|
||||
|
||||
if (! is_string($path) || preg_match($expected, $path) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! Storage::disk('media_public')->exists($path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$title = trim((string) ($element->display_title ?: $element->working_title));
|
||||
$alt = trim((string) ($element->website_alt ?? ''));
|
||||
|
||||
return new WebsitePresentation(
|
||||
elementId: $element->id,
|
||||
title: $title,
|
||||
alt: $alt !== '' ? $alt : $title,
|
||||
credit: filled($element->website_credit) ? trim((string) $element->website_credit) : null,
|
||||
kind: $element->output_class === 'film' ? 'film' : 'bild',
|
||||
url: route('website.media', $element),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Slideshow: freigegebene Medien in der angegebenen Reihenfolge. Nicht freigegebene Einträge entfallen.
|
||||
*
|
||||
* @param list<int|string> $ids
|
||||
* @return list<WebsitePresentation>
|
||||
*/
|
||||
public function presentMany(array $ids): array
|
||||
{
|
||||
$presentations = [];
|
||||
|
||||
foreach ($ids as $id) {
|
||||
if (! is_numeric($id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$presentation = $this->present((int) $id);
|
||||
|
||||
if ($presentation !== null) {
|
||||
$presentations[] = $presentation;
|
||||
}
|
||||
}
|
||||
|
||||
return $presentations;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\IdentityChange;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Früherer CMS-Bildpfad (cms/…), der in den Medienmanager übernommen wurde.
|
||||
*
|
||||
* Wirksam ist die Zuordnung erst, wenn das Medium mindestens einmal für die Website freigegeben war. Bis dahin
|
||||
* (Ableitung läuft noch oder ist fehlgeschlagen) bleibt der frühere Pfad gültig, damit keine Seite ihr Bild verliert.
|
||||
* Danach entscheidet allein die Website-Freigabe des Mediums, auch über die frühere Adresse /medien/cms/….
|
||||
*/
|
||||
class WebsiteMediaAlias extends Model
|
||||
{
|
||||
protected $fillable = ['legacy_path', 'content_element_id', 'sha256'];
|
||||
|
||||
public function element(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ContentElement::class, 'content_element_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Wirksame Zuordnung für einen früheren Pfad, sonst null. Zwischengespeichert wird im Aufrufer (WebsiteImage, je Anfrage).
|
||||
*/
|
||||
public static function effectiveFor(mixed $path): ?self
|
||||
{
|
||||
if (! is_string($path) || $path === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$alias = self::query()->with('element')->where('legacy_path', $path)->first();
|
||||
|
||||
return $alias instanceof self && $alias->everReleased() ? $alias : null;
|
||||
}
|
||||
|
||||
public function everReleased(): bool
|
||||
{
|
||||
$element = $this->element;
|
||||
|
||||
if ($element === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($element->website_released_at !== null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return IdentityChange::query()
|
||||
->where('subject_type', $element->getMorphClass())
|
||||
->where('subject_id', $element->id)
|
||||
->where('field', 'website_released_at')
|
||||
->whereNotNull('after')
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
/**
|
||||
* Öffentliche Ableitung eines für die Website freigegebenen Mediums.
|
||||
* Enthält keine internen Vermerke und keine Adresse einer Bestandsdatei.
|
||||
*/
|
||||
final class WebsitePresentation
|
||||
{
|
||||
public function __construct(
|
||||
public readonly int $elementId,
|
||||
public readonly string $title,
|
||||
public readonly string $alt,
|
||||
public readonly ?string $credit,
|
||||
public readonly string $kind,
|
||||
public readonly string $url,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Jobs\PublishWebsiteMedia;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Gibt eine Ableitung für die Website frei oder nimmt sie zurück.
|
||||
* Legt keinen Lizenzartikel an und ruft DecideAccess nicht auf.
|
||||
* Der Web-Prozess schreibt die öffentliche Datei nicht selbst; das tut die Warteschlange.
|
||||
*/
|
||||
class WebsiteRelease
|
||||
{
|
||||
public function release(ContentElement $element, ?User $actor = null): string
|
||||
{
|
||||
$refusal = $this->refusal($element);
|
||||
|
||||
if ($refusal !== null) {
|
||||
return $refusal;
|
||||
}
|
||||
|
||||
PublishWebsiteMedia::dispatch($element->id, 'release', $actor?->id);
|
||||
|
||||
return 'Für die Website freigegeben. Öffentliche Seiten lesen nur diese Ableitung.';
|
||||
}
|
||||
|
||||
public function withdraw(ContentElement $element, ?User $actor = null): string
|
||||
{
|
||||
PublishWebsiteMedia::dispatch($element->id, 'withdraw', $actor?->id);
|
||||
|
||||
return 'Die Website-Freigabe ist zurückgenommen.';
|
||||
}
|
||||
|
||||
public function refusal(ContentElement $element): ?string
|
||||
{
|
||||
if ($this->isConfidential($element)) {
|
||||
return 'Traineranleitungen werden nicht für die Website freigegeben.';
|
||||
}
|
||||
|
||||
if ($this->derivedPath($element) === null) {
|
||||
return 'Für die Website fehlt eine freigebbare Ableitung. Beim Bild ist das das Vorschaubild, beim Film eine Teaserfassung unter teaser/. Die Originaldatei bleibt geschützt.';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function derivedPath(ContentElement $element): ?string
|
||||
{
|
||||
if ($this->isConfidential($element)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($element->output_class === 'bild') {
|
||||
return $this->allowedDerivedPath($element->thumbnail_path, 'vorschau/');
|
||||
}
|
||||
|
||||
if ($element->output_class !== 'film') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$version = $element->versions()
|
||||
->where('status', ContentVersionStatus::Bereit->value)
|
||||
->orderByDesc('number')
|
||||
->first();
|
||||
|
||||
if ($version === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$path = MediaRendition::query()
|
||||
->where('content_element_version_id', $version->id)
|
||||
->where('role', 'preview')
|
||||
->orderByDesc('id')
|
||||
->value('path');
|
||||
|
||||
return $this->allowedDerivedPath($path, 'teaser/');
|
||||
}
|
||||
|
||||
public function publicPath(ContentElement $element, string $derivedPath): string
|
||||
{
|
||||
$extension = strtolower(pathinfo($derivedPath, PATHINFO_EXTENSION));
|
||||
|
||||
return 'website/'.$element->id.'/datei.'.$extension;
|
||||
}
|
||||
|
||||
private function isConfidential(ContentElement $element): bool
|
||||
{
|
||||
$slug = $element->editorialContentKind?->slug;
|
||||
|
||||
if ($slug === null && $element->editorial_content_kind_id !== null) {
|
||||
$slug = EditorialContentKind::query()->whereKey($element->editorial_content_kind_id)->value('slug');
|
||||
}
|
||||
|
||||
return in_array($slug, PublicMaterialReader::CONFIDENTIAL_KINDS, true);
|
||||
}
|
||||
|
||||
private function allowedDerivedPath(mixed $path, string $prefix): ?string
|
||||
{
|
||||
if (! is_string($path) || ! str_starts_with($path, $prefix) || str_contains($path, '..')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||
|
||||
if (! in_array($extension, ['jpg', 'jpeg', 'png', 'webp', 'gif', 'mp4', 'webm'], true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! Storage::disk('media_derived')->exists($path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Domain\Catalog\StructureNode;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Filament\Support\MediumForm;
|
||||
@@ -87,6 +88,8 @@ abstract class EditComposition extends EditRecord
|
||||
|
||||
public string $pickerKind = 'alle';
|
||||
|
||||
public string $pickerLayout = 'kacheln';
|
||||
|
||||
public string $pickerDimension = '';
|
||||
|
||||
public string $pickerSelected = '';
|
||||
@@ -351,6 +354,7 @@ public function pickerDetail(): ?array
|
||||
$row = app(EditorialCatalog::class)->rowForTarget(
|
||||
$this->pickerSelected,
|
||||
(int) $this->getRecord()->getKey(),
|
||||
allowDraft: true,
|
||||
);
|
||||
|
||||
if ($row === null) {
|
||||
@@ -360,10 +364,13 @@ public function pickerDetail(): ?array
|
||||
$row['playback'] = null;
|
||||
|
||||
if (preg_match('/^element:(\d+)$/', (string) $row['target'], $match) === 1) {
|
||||
$version = ContentElementVersion::query()->with('element')->find($match[1]);
|
||||
$version = ContentElementVersion::query()->with('element.editorialContentKind')->find($match[1]);
|
||||
$row['playback'] = $version instanceof ContentElementVersion
|
||||
? app(ContentPreviewController::class)->playback($version)
|
||||
: null;
|
||||
if ($version?->element !== null) {
|
||||
$row['visibility'] = app(PublicMaterialReader::class)->visibilityNote($version->element);
|
||||
}
|
||||
}
|
||||
|
||||
return $row;
|
||||
|
||||
@@ -3,11 +3,18 @@
|
||||
namespace App\Filament\Resources\ContentElements\Pages;
|
||||
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\MediaLibrary;
|
||||
use App\Filament\Support\MediumForm;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Schemas\Components\RenderHook;
|
||||
use Filament\Schemas\Components\View;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\View\PanelsRenderHook;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Livewire\Attributes\Url;
|
||||
|
||||
class ListContentElements extends ListRecords
|
||||
{
|
||||
@@ -15,9 +22,141 @@ class ListContentElements extends ListRecords
|
||||
|
||||
protected static string $resource = ContentElementResource::class;
|
||||
|
||||
#[Url(as: 'suche', except: '')]
|
||||
public string $suche = '';
|
||||
|
||||
#[Url(as: 'ansicht', except: 'kacheln')]
|
||||
public string $ansicht = 'kacheln';
|
||||
|
||||
#[Url(as: 'art', except: '')]
|
||||
public string $art = '';
|
||||
|
||||
#[Url(as: 'freigabe', except: '')]
|
||||
public string $freigabe = '';
|
||||
|
||||
#[Url(as: 'entwurf', except: '')]
|
||||
public string $entwurf = '';
|
||||
|
||||
#[Url(as: 'fassung', except: '')]
|
||||
public string $fassung = '';
|
||||
|
||||
#[Url(as: 'nutzung', except: '')]
|
||||
public string $nutzung = '';
|
||||
|
||||
#[Url(as: 'saeule', except: '')]
|
||||
public string $saeule = '';
|
||||
|
||||
#[Url(as: 'einordnung', except: '')]
|
||||
public string $einordnung = '';
|
||||
|
||||
#[Url(as: 'verarbeitung', except: '')]
|
||||
public string $verarbeitung = '';
|
||||
|
||||
#[Url(as: 'archiv', except: 'aktiv')]
|
||||
public string $archiv = 'aktiv';
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Die Dateien und Texte. Eine Übung, ein Kurs oder eine fachliche Kombination verweist darauf; die Datei wird nicht für jede Verwendung neu hochgeladen.';
|
||||
return 'Die Dateien und Texte. Ein Modul oder ein Programm verweist auf eine Fassung; die Datei wird nicht für jede Verwendung neu hochgeladen.';
|
||||
}
|
||||
|
||||
public function getMaxContentWidth(): Width|string|null
|
||||
{
|
||||
return Width::Full;
|
||||
}
|
||||
|
||||
public function content(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
$this->getTabsContentComponent(),
|
||||
RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_BEFORE),
|
||||
View::make('filament.media.library'),
|
||||
RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_AFTER),
|
||||
]);
|
||||
}
|
||||
|
||||
public function showingList(): bool
|
||||
{
|
||||
return $this->ansicht === 'liste';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function cards(): array
|
||||
{
|
||||
return app(MediaLibrary::class)->cards($this->libraryFilters(), ContentElementResource::editor());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{value: string, label: string}>
|
||||
*/
|
||||
public function typeOptions(): array
|
||||
{
|
||||
return app(MediaLibrary::class)->types();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{id: int, name: string}>
|
||||
*/
|
||||
public function pillarOptions(): array
|
||||
{
|
||||
return app(MediaLibrary::class)->pillars();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{id: int, label: string}>
|
||||
*/
|
||||
public function classificationOptions(): array
|
||||
{
|
||||
return app(MediaLibrary::class)->classifications();
|
||||
}
|
||||
|
||||
public function filtersActive(): bool
|
||||
{
|
||||
return trim($this->suche) !== ''
|
||||
|| $this->art !== ''
|
||||
|| $this->freigabe !== ''
|
||||
|| $this->entwurf !== ''
|
||||
|| $this->fassung !== ''
|
||||
|| $this->nutzung !== ''
|
||||
|| $this->saeule !== ''
|
||||
|| $this->einordnung !== ''
|
||||
|| $this->verarbeitung !== ''
|
||||
|| $this->archiv !== 'aktiv';
|
||||
}
|
||||
|
||||
public function resetFilters(): void
|
||||
{
|
||||
$this->suche = '';
|
||||
$this->art = '';
|
||||
$this->freigabe = '';
|
||||
$this->entwurf = '';
|
||||
$this->fassung = '';
|
||||
$this->nutzung = '';
|
||||
$this->saeule = '';
|
||||
$this->einordnung = '';
|
||||
$this->verarbeitung = '';
|
||||
$this->archiv = 'aktiv';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function libraryFilters(): array
|
||||
{
|
||||
return [
|
||||
'suche' => $this->suche,
|
||||
'art' => $this->art,
|
||||
'freigabe' => $this->freigabe,
|
||||
'entwurf' => $this->entwurf,
|
||||
'fassung' => $this->fassung,
|
||||
'nutzung' => $this->nutzung,
|
||||
'saeule' => $this->saeule,
|
||||
'einordnung' => $this->einordnung,
|
||||
'verarbeitung' => $this->verarbeitung,
|
||||
'archiv' => $this->archiv,
|
||||
];
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
|
||||
@@ -6,23 +6,32 @@
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\EditorialDimensionValue;
|
||||
use App\Domain\Catalog\IdentityChange;
|
||||
use App\Domain\Catalog\IdentityDimension;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarService;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\WebsiteImageUsage;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Filament\Support\ElementRevision;
|
||||
use App\Filament\Support\MediaLibrary;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use App\Http\Controllers\ContentPreviewController;
|
||||
use App\Jobs\DeriveThumbnail;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Filament\Schemas\Components\View;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
@@ -47,6 +56,48 @@ class ViewContentElement extends ViewRecord
|
||||
|
||||
public mixed $previewUpload = null;
|
||||
|
||||
public string $bereich = 'inhalt';
|
||||
|
||||
public string $workingTitle = '';
|
||||
|
||||
public string $displayTitle = '';
|
||||
|
||||
public string $summary = '';
|
||||
|
||||
public string $descriptionText = '';
|
||||
|
||||
public string $usageNote = '';
|
||||
|
||||
public string $licenseNote = '';
|
||||
|
||||
public string $websiteCredit = '';
|
||||
|
||||
public string $websiteAlt = '';
|
||||
|
||||
public string $websiteFeedback = '';
|
||||
|
||||
public int|string|null $kindId = null;
|
||||
|
||||
/** @var list<int|string> */
|
||||
public array $pillarIds = [];
|
||||
|
||||
/** @var list<int|string> */
|
||||
public array $dimensionIds = [];
|
||||
|
||||
public string $editorialFeedback = '';
|
||||
|
||||
public string $previewWidth = '640';
|
||||
|
||||
public string $previewSurface = 'website';
|
||||
|
||||
public string $pickerQuery = '';
|
||||
|
||||
public string $pickerContext = 'modul';
|
||||
|
||||
public string $pickerLayout = 'kacheln';
|
||||
|
||||
public string $pickerSelected = '';
|
||||
|
||||
public function mount(int|string $record): void
|
||||
{
|
||||
parent::mount($record);
|
||||
@@ -57,13 +108,28 @@ public function mount(int|string $record): void
|
||||
$this->fassung = $requested;
|
||||
}
|
||||
|
||||
$bereich = (string) request()->query('bereich', 'beschreibung');
|
||||
$this->bereich = in_array($bereich, ['beschreibung', 'inhalt', 'fassungen', 'verwendung', 'vorschau'], true)
|
||||
? $bereich
|
||||
: 'beschreibung';
|
||||
$this->thumbnailAlt = (string) ($this->getRecord()->thumbnail_alt ?? '');
|
||||
$this->fillEditorial();
|
||||
$this->syncBodyDraft();
|
||||
}
|
||||
|
||||
public function getHeading(): string|Htmlable
|
||||
{
|
||||
return (string) $this->getRecord()->working_title;
|
||||
}
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Jede Fassung hat eine eigene Nummer und bleibt einsehbar. Beschreibung, Arbeitstitel und Säulen gehören zum Medium und ändern keine Fassung. Eine deaktivierte Fassung wird nicht mehr ausgeliefert und lässt sich nicht neu einbauen.';
|
||||
return 'Texte und Vorschaubild ändern keine Fassung. Eine neue Datei oder ein geänderter Lehrtext braucht eine neue Fassung.';
|
||||
}
|
||||
|
||||
public function getMaxContentWidth(): Width|string|null
|
||||
{
|
||||
return Width::Full;
|
||||
}
|
||||
|
||||
public function infolist(Schema $schema): Schema
|
||||
@@ -242,40 +308,6 @@ public function deactivateAction(): Action
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('describe')
|
||||
->label('Beschreibung ändern')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->fillForm(fn (): array => [
|
||||
'working_title' => $this->getRecord()->working_title,
|
||||
'description' => $this->getRecord()->description,
|
||||
'usage_note' => $this->getRecord()->usage_note,
|
||||
'license_note' => $this->getRecord()->license_note,
|
||||
'pillars' => $this->getRecord()->pillars()->pluck('pillars.id')->all(),
|
||||
])
|
||||
->schema([
|
||||
TextInput::make('working_title')->label('Arbeitstitel')->required(),
|
||||
Textarea::make('description')->label('Beschreibung')->rows(4)
|
||||
->helperText('Gilt für das Medium. Speichern legt keine neue Fassung an.'),
|
||||
Textarea::make('usage_note')->label('Hinweise für den Einsatz')->rows(4),
|
||||
Textarea::make('license_note')->label('Interner Lizenzvermerk')->rows(3)
|
||||
->helperText('Nur in der Verwaltung. Nicht in der Bibliothek und nicht auf der Website.'),
|
||||
CheckboxList::make('pillars')
|
||||
->label('Fachliche Säulen')
|
||||
->options(fn (): array => Pillar::query()->orderBy('name')->pluck('name', 'id')->all()),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
app(ContentService::class)->describe($element, (string) $data['working_title'], $data['description'] ?? null);
|
||||
app(IdentityProfile::class)->fill($element, [
|
||||
'usage_note' => $data['usage_note'] ?? null,
|
||||
'license_note' => $data['license_note'] ?? null,
|
||||
], auth()->user());
|
||||
app(PillarService::class)->assign($element, array_map(intval(...), $data['pillars'] ?? []));
|
||||
}, 'Die Beschreibung ist gespeichert.');
|
||||
$this->getRecord()->refresh();
|
||||
}),
|
||||
Action::make('releaseVersion')
|
||||
->label('Fassung freigeben')
|
||||
->modalHeading('Fassung freigeben')
|
||||
@@ -395,6 +427,7 @@ private function pictureCaption(ContentElement $element): string
|
||||
return match ($source) {
|
||||
'eigen' => 'Eigenes Vorschaubild.',
|
||||
'datei' => 'Vorschaubild aus der Datei des Mediums.',
|
||||
'bestand' => 'Vorschaubild aus einem Bild im Bestand. Es ist damit nicht für die Website freigegeben.',
|
||||
default => '',
|
||||
};
|
||||
}
|
||||
@@ -406,4 +439,289 @@ private function ownedVersion(int $id): ?ContentElementVersion
|
||||
|
||||
return $element->versions()->whereKey($id)->first();
|
||||
}
|
||||
|
||||
public function saveEditorial(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$title = trim($this->workingTitle);
|
||||
|
||||
if ($title === '') {
|
||||
$this->editorialFeedback = 'Der Arbeitstitel fehlt.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$versions = $element->versions()->count();
|
||||
app(IdentityProfile::class)->fill($element, [
|
||||
'working_title' => $title,
|
||||
'display_title' => $this->displayTitle,
|
||||
'summary' => $this->summary,
|
||||
'description' => $this->descriptionText,
|
||||
'usage_note' => $this->usageNote,
|
||||
'license_note' => $this->licenseNote,
|
||||
'website_credit' => $this->websiteCredit,
|
||||
'website_alt' => $this->websiteAlt,
|
||||
'thumbnail_alt' => $this->thumbnailAlt,
|
||||
'editorial_content_kind_id' => filled($this->kindId) ? (int) $this->kindId : null,
|
||||
], auth()->user());
|
||||
app(PillarService::class)->assign($element, array_map(intval(...), $this->pillarIds));
|
||||
$ids = array_map(intval(...), $this->dimensionIds);
|
||||
IdentityDimensionValue::query()
|
||||
->where('subject_type', $element->getMorphClass())
|
||||
->where('subject_id', $element->id)
|
||||
->where('origin', 'direkt')
|
||||
->whereNotIn('editorial_dimension_value_id', $ids === [] ? [0] : $ids)
|
||||
->delete();
|
||||
|
||||
foreach (EditorialDimensionValue::query()->whereIn('id', $ids)->get() as $value) {
|
||||
app(IdentityDimension::class)->assign($element, $value, 'direkt');
|
||||
}
|
||||
|
||||
$element->refresh();
|
||||
$this->fillEditorial();
|
||||
$this->editorialFeedback = $element->versions()->count() === $versions
|
||||
? 'Gespeichert. Es gibt keine neue Fassung.'
|
||||
: 'Gespeichert. Prüfe die Fassungen, ihre Zahl hat sich geändert.';
|
||||
}
|
||||
|
||||
public function releaseForWebsite(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
app(IdentityProfile::class)->fill($element, [
|
||||
'website_credit' => $this->websiteCredit,
|
||||
'website_alt' => $this->websiteAlt,
|
||||
], auth()->user());
|
||||
$element->refresh();
|
||||
$this->websiteFeedback = app(WebsiteRelease::class)->release($element, auth()->user());
|
||||
$element->refresh();
|
||||
$this->fillEditorial();
|
||||
}
|
||||
|
||||
public function withdrawWebsite(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$this->websiteFeedback = app(WebsiteRelease::class)->withdraw($element, auth()->user());
|
||||
$element->refresh();
|
||||
$this->fillEditorial();
|
||||
}
|
||||
|
||||
/**
|
||||
* Website-Seiten, die dieses Medium als Bild verwenden (CMS-Widgets und Abschnittshintergründe).
|
||||
*
|
||||
* @return list<array{path: string, published: bool, draft: bool}>
|
||||
*/
|
||||
public function websitePages(): array
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
return app(WebsiteImageUsage::class)->pages($element);
|
||||
}
|
||||
|
||||
public function websiteIsPublic(): bool
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
return app(WebsiteMedia::class)->present($element->fresh()) !== null;
|
||||
}
|
||||
|
||||
public function adoptLibraryImage(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$detail = $this->selectionDetail();
|
||||
$sourceId = (int) ($detail['element_id'] ?? 0);
|
||||
$source = $sourceId > 0 ? ContentElement::query()->find($sourceId) : null;
|
||||
$path = $source?->thumbnail_path;
|
||||
|
||||
if (! $source instanceof ContentElement || $source->output_class !== 'bild' || ! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
||||
$this->pictureFeedback = 'Dieses Bild hat noch kein übernehmbares Vorschaubild.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$versions = $element->versions()->count();
|
||||
app(IdentityProfile::class)->fill($element, [
|
||||
'thumbnail_path' => $path,
|
||||
'thumbnail_alt' => filled($source->thumbnail_alt) ? $source->thumbnail_alt : $source->working_title,
|
||||
'thumbnail_source' => 'bestand',
|
||||
'thumbnail_error' => null,
|
||||
], auth()->user());
|
||||
$element->refresh();
|
||||
$this->thumbnailAlt = (string) ($element->thumbnail_alt ?? '');
|
||||
$this->pictureFeedback = $element->versions()->count() === $versions
|
||||
? 'Vorschaubild übernommen. Es gibt keine neue Fassung. Für die Website ist es damit nicht freigegeben.'
|
||||
: 'Vorschaubild übernommen. Prüfe die Fassungen.';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{items: list<array<string, mixed>>, more: bool}
|
||||
*/
|
||||
public function selection(): array
|
||||
{
|
||||
return app(EditorialCatalog::class)->browse(
|
||||
$this->pickerQuery,
|
||||
$this->pickerContext === 'bild' ? 'bild' : 'alle',
|
||||
'',
|
||||
0,
|
||||
elementsOnly: $this->pickerContext !== 'modul',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>|null
|
||||
*/
|
||||
public function selectionDetail(): ?array
|
||||
{
|
||||
if ($this->pickerSelected === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$row = app(EditorialCatalog::class)->rowForTarget($this->pickerSelected, 0, allowDraft: true);
|
||||
|
||||
if ($row === null || ! isset($row['element_id'])) {
|
||||
return $row;
|
||||
}
|
||||
|
||||
$element = ContentElement::query()->with('editorialContentKind')->find((int) $row['element_id']);
|
||||
|
||||
if ($element instanceof ContentElement) {
|
||||
$row['visibility'] = app(PublicMaterialReader::class)->visibilityNote($element);
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function previewHtml(): string
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$draft = [
|
||||
'working_title' => $this->workingTitle,
|
||||
'display_title' => $this->displayTitle,
|
||||
'summary' => $this->summary,
|
||||
'thumbnail_alt' => $this->thumbnailAlt,
|
||||
];
|
||||
|
||||
if ($this->previewSurface === 'bibliothek') {
|
||||
$title = trim($this->displayTitle) !== '' ? trim($this->displayTitle) : trim($this->workingTitle);
|
||||
|
||||
return view('member.partials.card', [
|
||||
'href' => '#vorschau',
|
||||
'card' => [
|
||||
'title' => $title !== '' ? $title : $element->working_title,
|
||||
'summary' => trim($this->summary) !== '' ? trim($this->summary) : null,
|
||||
'kind' => PublicMaterialReader::outputLabel((string) $element->output_class),
|
||||
'coverage' => 'offen',
|
||||
'image' => trim($this->thumbnailAlt) !== '' ? trim($this->thumbnailAlt) : $title,
|
||||
'image_url' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
||||
'error' => 'Vorschau der Kartenform. Ob jemand sie öffnen darf, entscheidet die Lizenz.',
|
||||
],
|
||||
])->render();
|
||||
}
|
||||
|
||||
$subject = app(PublicMaterialReader::class)->subject($element->id, true, $draft);
|
||||
|
||||
if ($subject === null) {
|
||||
return '<p class="preview-note">Für dieses Medium liegt noch keine anzeigbare Fassung vor. Die Karte erscheint deshalb auch in der Vorschau nicht.</p>';
|
||||
}
|
||||
|
||||
return view('widgets.premium_card', [
|
||||
'subject' => $subject,
|
||||
'context' => RenderContext::preview(),
|
||||
'cardStyle' => $subject->style ?? 'media',
|
||||
'imageUrl' => null,
|
||||
'alt' => '',
|
||||
'focus' => ['x' => 50, 'y' => 45],
|
||||
'format' => 'landscape',
|
||||
'fit' => 'cover',
|
||||
'headingTag' => 'h3',
|
||||
'show' => ['summary' => true, 'kind' => true, 'meta' => true, 'action' => true],
|
||||
'actionLabel' => 'Ansehen',
|
||||
'note' => null,
|
||||
'stacked' => $this->previewWidth === '390',
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{field: string, after: string, when: string}>
|
||||
*/
|
||||
public function editorialHistory(): array
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$labels = [
|
||||
'working_title' => 'Arbeitstitel',
|
||||
'display_title' => 'Anzeigename',
|
||||
'description' => 'Beschreibung',
|
||||
'summary' => 'Kurzbeschreibung',
|
||||
'usage_note' => 'Einsatzhinweis',
|
||||
'license_note' => 'Interner Lizenzvermerk',
|
||||
'website_credit' => 'Quellenzeile',
|
||||
'website_alt' => 'Alternativtext der Website',
|
||||
'website_released_at' => 'Website-Freigabe',
|
||||
'thumbnail_alt' => 'Alternativtext',
|
||||
'thumbnail_path' => 'Vorschaubild',
|
||||
'thumbnail_source' => 'Herkunft des Vorschaubilds',
|
||||
'editorial_content_kind_id' => 'Inhaltsart',
|
||||
];
|
||||
|
||||
return IdentityChange::query()
|
||||
->where('subject_type', $element->getMorphClass())
|
||||
->where('subject_id', $element->id)
|
||||
->latest('occurred_at')
|
||||
->limit(8)
|
||||
->get()
|
||||
->map(fn (IdentityChange $change): array => [
|
||||
'field' => $labels[$change->field] ?? $change->field,
|
||||
'after' => is_scalar($change->after) ? (string) $change->after : '',
|
||||
'when' => $change->occurred_at?->timezone(config('app.timezone'))->format('d.m.Y H:i') ?? '',
|
||||
])
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function usageCard(): array
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
return app(MediaLibrary::class)->cardFor($element, ContentElementResource::editor());
|
||||
}
|
||||
|
||||
private function fillEditorial(): void
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$this->workingTitle = (string) $element->working_title;
|
||||
$this->displayTitle = (string) ($element->display_title ?? '');
|
||||
$this->summary = (string) ($element->summary ?? '');
|
||||
$this->descriptionText = (string) ($element->description ?? '');
|
||||
$this->usageNote = (string) ($element->usage_note ?? '');
|
||||
$this->licenseNote = (string) ($element->license_note ?? '');
|
||||
$this->websiteCredit = (string) ($element->website_credit ?? '');
|
||||
$this->websiteAlt = (string) ($element->website_alt ?? '');
|
||||
$this->kindId = $element->editorial_content_kind_id;
|
||||
$this->pillarIds = $element->pillars()->pluck('pillars.id')->all();
|
||||
$this->dimensionIds = IdentityDimensionValue::query()
|
||||
->where('subject_type', $element->getMorphClass())
|
||||
->where('subject_id', $element->id)
|
||||
->where('origin', 'direkt')
|
||||
->pluck('editorial_dimension_value_id')
|
||||
->all();
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,31 @@ public static function form(Schema $schema): Schema
|
||||
->label('Platz')
|
||||
->options(NavigationItem::PLACEMENTS)
|
||||
->default('header')
|
||||
->required(),
|
||||
->required()
|
||||
->live()
|
||||
->helperText('Kopfzeile: Hauptnavigation. Fußbereich: drei Spalten „Service“, „Kontakt“ und „Rechtliches“.'),
|
||||
Select::make('parent_id')
|
||||
->label('Untermenü von')
|
||||
->placeholder('Oberste Ebene')
|
||||
->options(fn (?NavigationItem $record): array => NavigationItem::query()
|
||||
->where('placement', 'header')
|
||||
->whereNull('parent_id')
|
||||
->when($record !== null, fn ($query) => $query->whereKeyNot($record->getKey()))
|
||||
->orderBy('sort_order')
|
||||
->pluck('label', 'id')
|
||||
->all())
|
||||
->visible(fn (Get $get): bool => $get('placement') === 'header')
|
||||
->disabled(fn (?NavigationItem $record): bool => $record !== null && $record->children()->exists())
|
||||
->helperText('Eine Ebene Untermenü in der Hauptnavigation. Ein Eintrag mit eigenen Untereinträgen bleibt oberste Ebene.')
|
||||
->rule(fn (?NavigationItem $record): Closure => function (string $attribute, mixed $value, Closure $fail) use ($record): void {
|
||||
if (blank($value)) {
|
||||
return;
|
||||
}
|
||||
$parent = NavigationItem::query()->find($value);
|
||||
if ($parent === null || $parent->placement !== 'header' || $parent->parent_id !== null || ($record !== null && $parent->is($record))) {
|
||||
$fail('Untermenüs sind nur unter einem Eintrag der obersten Ebene der Hauptnavigation möglich.');
|
||||
}
|
||||
}),
|
||||
Select::make('page_id')
|
||||
->label('Interne Seite')
|
||||
->options(fn (): array => Page::query()->orderBy('path')->pluck('path', 'id')->all())
|
||||
@@ -51,9 +75,10 @@ public static function form(Schema $schema): Schema
|
||||
->maxLength(500)
|
||||
->helperText('Nur wenn keine Seite gewählt ist: Pfad wie /anmelden oder eine vollständige http(s)-Adresse.')
|
||||
->rule(SafeUrl::rule())
|
||||
->rule(function (Get $get): Closure {
|
||||
return function (string $attribute, mixed $value, Closure $fail) use ($get): void {
|
||||
if (blank($get('page_id')) && blank($value)) {
|
||||
->rule(function (Get $get, ?NavigationItem $record): Closure {
|
||||
return function (string $attribute, mixed $value, Closure $fail) use ($get, $record): void {
|
||||
// Ein Eintrag mit Untereinträgen darf ohne eigenes Ziel nur das Untermenü öffnen.
|
||||
if (blank($get('page_id')) && blank($value) && ! ($record?->children()->exists() ?? false)) {
|
||||
$fail('Wählen Sie eine Seite oder eine Adresse.');
|
||||
}
|
||||
};
|
||||
@@ -75,7 +100,11 @@ public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('label')->label('Beschriftung')->searchable(),
|
||||
TextColumn::make('label')
|
||||
->label('Beschriftung')
|
||||
->searchable()
|
||||
->formatStateUsing(fn (string $state, NavigationItem $record): string => $record->parent_id !== null ? '↳ '.$state : $state)
|
||||
->description(fn (NavigationItem $record): ?string => $record->parent !== null ? 'Untermenü von „'.$record->parent->label.'“' : null),
|
||||
TextColumn::make('target')
|
||||
->label('Ziel')
|
||||
->state(fn (NavigationItem $record): string => $record->page?->path ?? (string) $record->url),
|
||||
@@ -88,7 +117,7 @@ public static function table(Table $table): Table
|
||||
Group::make('placement')
|
||||
->label('Platz')
|
||||
->getTitleFromRecordUsing(fn (NavigationItem $record): string => NavigationItem::PLACEMENTS[$record->placement] ?? $record->placement)
|
||||
->orderQueryUsing(fn ($query, string $direction) => $query->orderByRaw("CASE placement WHEN 'header' THEN 0 ELSE 1 END"))
|
||||
->orderQueryUsing(fn ($query, string $direction) => $query->orderByRaw("CASE placement WHEN 'header' THEN 0 WHEN 'footer' THEN 1 WHEN 'footer_contact' THEN 2 WHEN 'footer_legal' THEN 3 ELSE 4 END"))
|
||||
->collapsible(),
|
||||
)
|
||||
->paginated([50, 100])
|
||||
@@ -110,7 +139,7 @@ public static function table(Table $table): Table
|
||||
->action(fn (NavigationItem $record) => $record->update(['is_visible' => ! $record->is_visible])),
|
||||
EditAction::make(),
|
||||
DeleteAction::make()
|
||||
->modalDescription('Der Eintrag wird aus der Navigation entfernt. Die verlinkte Seite bleibt bestehen.'),
|
||||
->modalDescription('Der Eintrag wird aus der Navigation entfernt. Die verlinkte Seite bleibt bestehen; Untereinträge rücken in die oberste Ebene.'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Filament\Resources\Pages\Pages\CreatePage;
|
||||
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||
use App\Filament\Resources\Pages\Pages\ListPages;
|
||||
use App\Filament\Resources\Pages\RelationManagers\RevisionsRelationManager;
|
||||
use App\Filament\Support\WidgetEditor;
|
||||
use App\Filament\Support\SectionEditor;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@@ -17,6 +19,7 @@
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class PageResource extends Resource
|
||||
{
|
||||
@@ -36,6 +39,8 @@ public static function form(Schema $schema): Schema
|
||||
Section::make('Seite und Suchmaschinen')
|
||||
->description('Adresse, Titel für Suchmaschinen und Zuordnung zu Themenbereichen.')
|
||||
->collapsible()
|
||||
->collapsed(fn (string $operation): bool => $operation === 'edit')
|
||||
->persistCollapsed()
|
||||
->columns(2)
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
@@ -55,13 +60,14 @@ public static function form(Schema $schema): Schema
|
||||
->label('Fachliche Säulen')
|
||||
->options(fn (): array => Pillar::query()->orderBy('name')->pluck('name', 'id')->all())
|
||||
->helperText('Eine veröffentlichte Seite erscheint auf den gewählten Themenbereichen der Website. Eine Seite kann mehreren Säulen zugeordnet sein.')
|
||||
->columns(1),
|
||||
->columns(['default' => 1, 'lg' => 2]),
|
||||
]),
|
||||
Section::make('Inhalt der Seite')
|
||||
->description('Abschnitte hinzufügen, per Klick auf die Vorschau bearbeiten, mit den Pfeilen sortieren. Speichern legt einen Entwurf an; veröffentlicht wird erst über „Veröffentlichen“.')
|
||||
->description('Abschnitt hinzufügen, Raster wählen, Widgets in die Plätze einsetzen. Ein Klick auf die Vorschau eines Widgets öffnet seinen Dialog; Hintergrund, Breite, Abstand und Trenner stehen unter „Gestaltung des Abschnitts“. Speichern legt einen Entwurf an; veröffentlicht wird erst über „Veröffentlichen“.')
|
||||
->columnSpanFull()
|
||||
->extraAttributes(['class' => 'luf-page-content'])
|
||||
->schema([
|
||||
WidgetEditor::builder('blocks'),
|
||||
SectionEditor::repeater('sections'),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
@@ -69,14 +75,48 @@ public static function form(Schema $schema): Schema
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
// Zuletzt bearbeitete Seiten zuerst; jede Seite ist ohne Suche auffindbar (Spalten sortierbar, bis 100 je Seite).
|
||||
->columns([
|
||||
TextColumn::make('path')->label('Pfad')->searchable(),
|
||||
TextColumn::make('path')->label('Pfad')->searchable()->sortable(),
|
||||
TextColumn::make('published_revision_id')
|
||||
->label('Veröffentlicht')
|
||||
->formatStateUsing(fn ($state): string => $state ? 'Ja' : 'Entwurf'),
|
||||
TextColumn::make('updated_at')->label('Geändert')->dateTime('d.m.Y H:i'),
|
||||
TextColumn::make('updated_at')
|
||||
->label('Zuletzt bearbeitet')
|
||||
->dateTime('d.m.Y H:i', timezone: 'Europe/Berlin')
|
||||
->sortable(),
|
||||
])
|
||||
->recordUrl(fn (Page $record): string => static::getUrl('edit', ['record' => $record]));
|
||||
->defaultSort('updated_at', 'desc')
|
||||
->paginated([25, 50, 100])
|
||||
->defaultPaginationPageOption(25)
|
||||
->recordUrl(fn (Page $record): string => static::getUrl('edit', ['record' => $record]))
|
||||
->recordActions([
|
||||
Action::make('duplicate')
|
||||
->label('Duplizieren')
|
||||
->icon('heroicon-o-document-duplicate')
|
||||
->color('gray')
|
||||
->tooltip('Neue, unveröffentlichte Seite mit dem zuletzt gespeicherten Stand dieser Seite anlegen')
|
||||
->authorize(fn (): bool => auth()->user()?->can('create', Page::class) ?? false)
|
||||
->modalHeading(fn (Page $record): string => 'Seite '.$record->path.' duplizieren')
|
||||
->modalDescription('Die Kopie ist ein Entwurf unter neuer Adresse. Die Vorlage bleibt unverändert.')
|
||||
->schema([
|
||||
TextInput::make('path')
|
||||
->label('Pfad der neuen Seite')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->helperText('Zum Beispiel /neue-landingpage'),
|
||||
])
|
||||
->modalSubmitActionLabel('Duplizieren')
|
||||
->action(function (Page $record, array $data, PageService $service) {
|
||||
try {
|
||||
$copy = $service->duplicate($record, $data['path'], auth()->user());
|
||||
} catch (ValidationException $exception) {
|
||||
throw ValidationException::withMessages(['mountedActions.0.data.path' => $exception->errors()['path'] ?? $exception->errors()]);
|
||||
}
|
||||
|
||||
return redirect(static::getUrl('edit', ['record' => $copy]));
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
|
||||
@@ -6,16 +6,26 @@
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Filament\Resources\Pages\PageResource;
|
||||
use App\Filament\Support\WidgetEditor;
|
||||
use App\Filament\Support\ReportsSectionErrors;
|
||||
use App\Filament\Support\SectionEditor;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class CreatePage extends CreateRecord
|
||||
{
|
||||
use ReportsSectionErrors;
|
||||
|
||||
protected static string $resource = PageResource::class;
|
||||
|
||||
/** Breite Arbeitsfläche, damit mehrspaltige Raster im Editor erkennbar bleiben. */
|
||||
protected Width|string|null $maxContentWidth = Width::Full;
|
||||
|
||||
/** Warnt vor dem Verlassen oder Neuladen, wenn Änderungen noch nicht gespeichert sind. */
|
||||
protected ?bool $hasUnsavedDataChangesAlert = true;
|
||||
|
||||
protected static bool $canCreateAnother = false;
|
||||
|
||||
/**
|
||||
@@ -24,17 +34,17 @@ class CreatePage extends CreateRecord
|
||||
protected function handleRecordCreation(array $data): Model
|
||||
{
|
||||
$service = app(PageService::class);
|
||||
$blocks = WidgetEditor::fromBuilderState($data['blocks'] ?? []);
|
||||
$content = SectionEditor::fromEditorState($data['sections'] ?? []);
|
||||
|
||||
try {
|
||||
return DB::transaction(function () use ($service, $data, $blocks): Page {
|
||||
return DB::transaction(function () use ($service, $data, $content): Page {
|
||||
$page = Page::query()->create([
|
||||
'path' => $service->availablePath($data['path']),
|
||||
]);
|
||||
|
||||
$service->saveRevision(
|
||||
$page,
|
||||
$blocks,
|
||||
$content,
|
||||
$data['seo_title'] ?? null,
|
||||
$data['seo_description'] ?? null,
|
||||
auth()->user(),
|
||||
@@ -45,10 +55,10 @@ protected function handleRecordCreation(array $data): Model
|
||||
return $page;
|
||||
});
|
||||
} catch (ValidationException $exception) {
|
||||
WidgetEditor::notifyErrors($exception->errors(), $blocks);
|
||||
SectionEditor::notifyErrors($exception->errors(), $this->data['sections'] ?? []);
|
||||
|
||||
throw ValidationException::withMessages(
|
||||
WidgetEditor::mapErrors($exception->errors(), array_keys($this->data['blocks'] ?? [])),
|
||||
SectionEditor::mapErrors($exception->errors(), $this->data['sections'] ?? []),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,27 @@
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Filament\Resources\Pages\PageResource;
|
||||
use App\Filament\Support\WidgetEditor;
|
||||
use App\Filament\Support\ReportsSectionErrors;
|
||||
use App\Filament\Support\SectionEditor;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class EditPage extends EditRecord
|
||||
{
|
||||
use ReportsSectionErrors;
|
||||
|
||||
protected static string $resource = PageResource::class;
|
||||
|
||||
/** Breite Arbeitsfläche, damit mehrspaltige Raster im Editor erkennbar bleiben. */
|
||||
protected Width|string|null $maxContentWidth = Width::Full;
|
||||
|
||||
/** Warnt vor dem Verlassen oder Neuladen, wenn Änderungen noch nicht gespeichert sind. */
|
||||
protected ?bool $hasUnsavedDataChangesAlert = true;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
@@ -37,10 +47,15 @@ protected function getHeaderActions(): array
|
||||
->label('Veröffentlichen')
|
||||
->icon('heroicon-o-globe-alt')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Zuletzt gespeicherten Entwurf veröffentlichen?')
|
||||
->modalDescription(fn (): string => 'Veröffentlicht wird Revision Nr. '.($this->record->latestRevision?->id ?? '–').'. Noch nicht gespeicherte Änderungen werden nicht veröffentlicht.')
|
||||
->modalHeading('Seite veröffentlichen?')
|
||||
->modalDescription('Der aktuelle Stand im Editor wird als Entwurf gespeichert und genau dieser Stand wird veröffentlicht. Enthält er Fehler, wird nichts veröffentlicht.')
|
||||
->modalSubmitActionLabel('Speichern und veröffentlichen')
|
||||
->visible(fn (): bool => auth()->user()?->can('publish', $this->record) ?? false)
|
||||
->action(function (PageService $service): void {
|
||||
// Ungespeicherte Änderungen (zum Beispiel ein eben gewähltes Bild) gingen sonst beim Veröffentlichen verloren.
|
||||
$this->save(shouldRedirect: false, shouldSendSavedNotification: false);
|
||||
|
||||
$this->record->unsetRelation('latestRevision');
|
||||
$revision = $this->record->latestRevision;
|
||||
abort_if($revision === null, 404);
|
||||
$service->publish($this->record, $revision);
|
||||
@@ -85,7 +100,7 @@ protected function afterSave(): void
|
||||
protected function mutateFormDataBeforeFill(array $data): array
|
||||
{
|
||||
$revision = $this->record->latestRevision ?? $this->record->publishedRevision;
|
||||
$data['blocks'] = WidgetEditor::toBuilderState($revision?->blocks);
|
||||
$data['sections'] = SectionEditor::toEditorState($revision?->sections() ?? []);
|
||||
$data['seo_title'] = $revision?->seo_title;
|
||||
$data['seo_description'] = $revision?->seo_description;
|
||||
$data['pillars'] = $this->record->pillars()->pluck('pillars.id')->all();
|
||||
@@ -100,16 +115,16 @@ protected function handleRecordUpdate(Model $record, array $data): Model
|
||||
{
|
||||
/** @var Page $record */
|
||||
$service = app(PageService::class);
|
||||
$blocks = WidgetEditor::fromBuilderState($data['blocks'] ?? []);
|
||||
$content = SectionEditor::fromEditorState($data['sections'] ?? []);
|
||||
|
||||
try {
|
||||
$path = $service->availablePath($data['path'], $record);
|
||||
$service->saveRevision($record, $blocks, $data['seo_title'] ?? null, $data['seo_description'] ?? null, auth()->user());
|
||||
$service->saveRevision($record, $content, $data['seo_title'] ?? null, $data['seo_description'] ?? null, auth()->user());
|
||||
} catch (ValidationException $exception) {
|
||||
WidgetEditor::notifyErrors($exception->errors(), $blocks);
|
||||
SectionEditor::notifyErrors($exception->errors(), $this->data['sections'] ?? []);
|
||||
|
||||
throw ValidationException::withMessages(
|
||||
WidgetEditor::mapErrors($exception->errors(), array_keys($this->data['blocks'] ?? [])),
|
||||
SectionEditor::mapErrors($exception->errors(), $this->data['sections'] ?? []),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,11 @@ public function table(Table $table): Table
|
||||
TextColumn::make('id')->label('Nr.'),
|
||||
TextColumn::make('created_at')->label('Gespeichert')->dateTime('d.m.Y H:i'),
|
||||
TextColumn::make('author.name')->label('Von'),
|
||||
TextColumn::make('sections')
|
||||
TextColumn::make('section_count')
|
||||
->label('Abschnitte')
|
||||
->state(fn (PageRevision $record): int => count($record->sections())),
|
||||
TextColumn::make('widget_count')
|
||||
->label('Widgets')
|
||||
->state(fn (PageRevision $record): int => count($record->widgets())),
|
||||
TextColumn::make('published')
|
||||
->label('Live')
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Filament\Resources\Combinations\CombinationResource;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Resources\Courses\CourseResource;
|
||||
use App\Filament\Resources\Exercises\ExerciseResource;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -111,7 +113,7 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
|
||||
'identity' => 'medium:'.$element->id,
|
||||
'open_url' => route('content.preview', $version),
|
||||
'open_label' => 'Medium ansehen',
|
||||
'edit_url' => null,
|
||||
'edit_url' => ContentElementResource::getUrl('view', ['record' => $element]),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -262,7 +264,7 @@ public function search(string $query, string $scope, int $exceptCompositionId):
|
||||
/**
|
||||
* @return array{items: list<array<string, string|null>>, more: bool}
|
||||
*/
|
||||
public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId): array
|
||||
public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId, bool $elementsOnly = false): array
|
||||
{
|
||||
$query = trim($query);
|
||||
$like = '%'.str_replace(['%', '_'], ['', ''], $query).'%';
|
||||
@@ -294,7 +296,7 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($kind, ['alle', 'modul'], true)) {
|
||||
if (! $elementsOnly && in_array($kind, ['alle', 'modul'], true)) {
|
||||
$latestCompositions = CompositionVersion::query()
|
||||
->selectRaw('MAX(id)')
|
||||
->where('status', ContentVersionStatus::Bereit)
|
||||
@@ -372,6 +374,8 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
}
|
||||
}
|
||||
|
||||
$rows = $this->withVisibility($rows);
|
||||
|
||||
return [
|
||||
'items' => array_slice($rows, 0, $limit),
|
||||
'more' => count($rows) > $limit,
|
||||
@@ -400,6 +404,42 @@ public function cardUrl(string $kind, int $id, ?string $path): ?string
|
||||
return route('editorial.card', ['kind' => $kind, 'subject' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $rows
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
private function withVisibility(array $rows): array
|
||||
{
|
||||
$ids = [];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if (isset($row['element_id'])) {
|
||||
$ids[] = (int) $row['element_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($ids === []) {
|
||||
return $rows;
|
||||
}
|
||||
|
||||
$reader = app(PublicMaterialReader::class);
|
||||
$elements = ContentElement::query()
|
||||
->with('editorialContentKind')
|
||||
->whereIn('id', array_values(array_unique($ids)))
|
||||
->get()
|
||||
->keyBy('id');
|
||||
|
||||
foreach ($rows as $index => $row) {
|
||||
$element = $elements->get((int) ($row['element_id'] ?? 0));
|
||||
|
||||
if ($element instanceof ContentElement) {
|
||||
$rows[$index]['visibility'] = $reader->visibilityNote($element);
|
||||
}
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<ContentElement> $builder
|
||||
*/
|
||||
@@ -408,6 +448,7 @@ private function constrainElement($builder, string $query, string $like, string
|
||||
$outputs = match ($kind) {
|
||||
'film' => ['film'],
|
||||
'text' => ['text'],
|
||||
'bild' => ['bild'],
|
||||
'dokument' => ['pdf', 'document'],
|
||||
default => null,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,570 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\CompositionMember;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\EditorialDimension;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\ReleaseContent;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class MediaLibrary
|
||||
{
|
||||
public function __construct(private readonly EditorialCatalog $catalog) {}
|
||||
|
||||
/**
|
||||
* @return list<array{value: string, label: string}>
|
||||
*/
|
||||
public function types(): array
|
||||
{
|
||||
return [
|
||||
['value' => 'film', 'label' => 'Film'],
|
||||
['value' => 'text', 'label' => 'Text'],
|
||||
['value' => 'document', 'label' => 'Dokument'],
|
||||
['value' => 'bild', 'label' => 'Bild'],
|
||||
['value' => 'audio', 'label' => 'Hörstück'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{id: int, name: string}>
|
||||
*/
|
||||
public function pillars(): array
|
||||
{
|
||||
return Pillar::query()
|
||||
->orderBy('name')
|
||||
->get(['id', 'name'])
|
||||
->map(fn (Pillar $pillar): array => ['id' => $pillar->id, 'name' => $pillar->name])
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{id: int, label: string}>
|
||||
*/
|
||||
public function classifications(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) {
|
||||
foreach ($dimension->values->sortBy('label') as $value) {
|
||||
$options[] = [
|
||||
'id' => $value->id,
|
||||
'label' => $dimension->label.': '.$value->label,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $filters
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function cardFor(ContentElement $element, bool $canEdit): array
|
||||
{
|
||||
$element->loadMissing(['versions', 'pillars']);
|
||||
$versionIds = $element->versions->pluck('id')->all();
|
||||
|
||||
return $this->card(
|
||||
$element,
|
||||
$this->portrait($element),
|
||||
$this->placements($versionIds)[$element->id] ?? [],
|
||||
$this->licenses($versionIds)[$element->id] ?? [],
|
||||
$canEdit,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $filters
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function cards(array $filters, bool $canEdit): array
|
||||
{
|
||||
$filters = $this->normalize($filters);
|
||||
$elements = ContentElement::query()
|
||||
->with(['versions', 'pillars'])
|
||||
->orderBy('working_title')
|
||||
->get();
|
||||
$versionIds = $elements->flatMap(fn (ContentElement $element) => $element->versions->pluck('id'))->all();
|
||||
$placements = $this->placements($versionIds);
|
||||
$licenses = $this->licenses($versionIds);
|
||||
$classified = $this->classifiedIds();
|
||||
$needle = mb_strtolower($filters['suche']);
|
||||
$cards = [];
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$portrait = $this->portrait($element);
|
||||
$uses = $placements[$element->id] ?? [];
|
||||
$codes = $licenses[$element->id] ?? [];
|
||||
|
||||
if (! $this->matches($element, $portrait, $uses, $filters, $needle, $classified)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$cards[] = $this->card($element, $portrait, $uses, $codes, $canEdit);
|
||||
}
|
||||
|
||||
usort($cards, fn (array $left, array $right): int => strcasecmp(
|
||||
mb_strtolower($left['title']),
|
||||
mb_strtolower($right['title']),
|
||||
));
|
||||
|
||||
return $cards;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $filters
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function normalize(array $filters): array
|
||||
{
|
||||
return [
|
||||
'suche' => trim($filters['suche'] ?? ''),
|
||||
'art' => $this->choice($filters['art'] ?? '', ['film', 'text', 'document', 'bild', 'audio']),
|
||||
'freigabe' => $this->choice($filters['freigabe'] ?? '', ['freigegeben', 'entwurf', 'ohne']),
|
||||
'entwurf' => $this->choice($filters['entwurf'] ?? '', ['offen', 'keiner']),
|
||||
'fassung' => $this->choice($filters['fassung'] ?? '', ['mit', 'nur']),
|
||||
'nutzung' => $this->choice($filters['nutzung'] ?? '', ['verwendet', 'unbenutzt']),
|
||||
'saeule' => ctype_digit($filters['saeule'] ?? '') ? $filters['saeule'] : '',
|
||||
'einordnung' => ctype_digit($filters['einordnung'] ?? '') ? $filters['einordnung'] : '',
|
||||
'verarbeitung' => $this->choice($filters['verarbeitung'] ?? '', ['fehler', 'uebernahme']),
|
||||
'archiv' => $this->choice($filters['archiv'] ?? '', ['aktiv', 'archiviert', 'alle'], 'aktiv'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $allowed
|
||||
*/
|
||||
private function choice(string $value, array $allowed, string $fallback = ''): string
|
||||
{
|
||||
return in_array($value, $allowed, true) ? $value : $fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $versionIds
|
||||
* @return array<int, list<array<string, mixed>>>
|
||||
*/
|
||||
private function placements(array $versionIds): array
|
||||
{
|
||||
if ($versionIds === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$grouped = [];
|
||||
$members = CompositionMember::query()
|
||||
->whereIn('content_element_version_id', $versionIds)
|
||||
->with(['compositionVersion.composition', 'contentElementVersion'])
|
||||
->orderBy('id')
|
||||
->get();
|
||||
|
||||
foreach ($members as $member) {
|
||||
$version = $member->contentElementVersion;
|
||||
$compositionVersion = $member->compositionVersion;
|
||||
$composition = $compositionVersion?->composition;
|
||||
|
||||
if (! $version instanceof ContentElementVersion || $compositionVersion === null || ! $composition instanceof Composition) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$elementId = $version->content_element_id;
|
||||
$key = $composition->id.'-'.$compositionVersion->id.'-'.$version->id;
|
||||
$role = trim((string) $member->role);
|
||||
|
||||
if (! isset($grouped[$elementId][$key])) {
|
||||
$grouped[$elementId][$key] = [
|
||||
'compositionId' => $composition->id,
|
||||
'name' => $this->catalog->compositionTitle($composition),
|
||||
'type' => $this->kindLabel($composition),
|
||||
'mediumVersion' => $this->versionLabel($version),
|
||||
'hostVersion' => 'Fassung '.$compositionVersion->number,
|
||||
'url' => EditorialCatalog::editUrl($composition),
|
||||
'roles' => [],
|
||||
];
|
||||
}
|
||||
|
||||
if ($role !== '' && ! in_array($role, $grouped[$elementId][$key]['roles'], true)) {
|
||||
$grouped[$elementId][$key]['roles'][] = $role;
|
||||
}
|
||||
}
|
||||
|
||||
$placements = [];
|
||||
|
||||
foreach ($grouped as $elementId => $rows) {
|
||||
$list = array_values($rows);
|
||||
usort($list, fn (array $left, array $right): int => [$left['type'], $left['name'], $left['hostVersion']]
|
||||
<=> [$right['type'], $right['name'], $right['hostVersion']]);
|
||||
$placements[$elementId] = $list;
|
||||
}
|
||||
|
||||
return $placements;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $versionIds
|
||||
* @return array<int, list<string>>
|
||||
*/
|
||||
private function licenses(array $versionIds): array
|
||||
{
|
||||
if ($versionIds === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$codes = [];
|
||||
$contents = ReleaseContent::query()
|
||||
->whereIn('content_element_version_id', $versionIds)
|
||||
->with(['release.article', 'elementVersion'])
|
||||
->orderBy('id')
|
||||
->get();
|
||||
|
||||
foreach ($contents as $content) {
|
||||
$version = $content->elementVersion;
|
||||
$code = $content->release?->article?->code;
|
||||
|
||||
if (! $version instanceof ContentElementVersion || ! is_string($code) || $code === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$codes[$version->content_element_id][$code] = $code;
|
||||
}
|
||||
|
||||
return array_map(fn (array $row): array => array_values($row), $codes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, list<int>>
|
||||
*/
|
||||
private function classifiedIds(): array
|
||||
{
|
||||
$map = [];
|
||||
$rows = IdentityDimensionValue::query()
|
||||
->where('subject_type', (new ContentElement)->getMorphClass())
|
||||
->where('origin', 'direkt')
|
||||
->get(['subject_id', 'editorial_dimension_value_id']);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$map[(int) $row->subject_id][] = (int) $row->editorial_dimension_value_id;
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* ready: ?ContentElementVersion,
|
||||
* draft: ?ContentElementVersion,
|
||||
* blocked: ?ContentElementVersion,
|
||||
* versionCount: int,
|
||||
* archived: bool,
|
||||
* processing: ?string,
|
||||
* stand: string,
|
||||
* standTone: string,
|
||||
* draftNote: ?string,
|
||||
* blockedNote: ?string
|
||||
* }
|
||||
*/
|
||||
private function portrait(ContentElement $element): array
|
||||
{
|
||||
/** @var Collection<int, ContentElementVersion> $versions */
|
||||
$versions = $element->versions->sortByDesc('number')->values();
|
||||
$ready = $versions->first(fn (ContentElementVersion $version): bool => $version->status === ContentVersionStatus::Bereit);
|
||||
$draft = $versions->first(fn (ContentElementVersion $version): bool => $version->status === ContentVersionStatus::Entwurf);
|
||||
$blocked = $versions->first(fn (ContentElementVersion $version): bool => $version->status === ContentVersionStatus::Gesperrt);
|
||||
$processing = $this->processing($versions);
|
||||
|
||||
if ($ready instanceof ContentElementVersion) {
|
||||
$stand = 'Fassung '.$ready->number.' freigegeben';
|
||||
$tone = 'ready';
|
||||
} elseif ($draft instanceof ContentElementVersion) {
|
||||
$stand = 'Entwurf, noch nicht freigegeben';
|
||||
$tone = 'draft';
|
||||
} elseif ($blocked instanceof ContentElementVersion) {
|
||||
$stand = 'Fassung '.$blocked->number.' deaktiviert';
|
||||
$tone = 'blocked';
|
||||
} else {
|
||||
$stand = 'Noch keine Fassung';
|
||||
$tone = 'quiet';
|
||||
}
|
||||
|
||||
return [
|
||||
'ready' => $ready instanceof ContentElementVersion ? $ready : null,
|
||||
'draft' => $draft instanceof ContentElementVersion ? $draft : null,
|
||||
'blocked' => $blocked instanceof ContentElementVersion ? $blocked : null,
|
||||
'versionCount' => $versions->count(),
|
||||
'archived' => $element->archived_at !== null,
|
||||
'processing' => $processing,
|
||||
'stand' => $stand,
|
||||
'standTone' => $tone,
|
||||
'draftNote' => $ready instanceof ContentElementVersion && $draft instanceof ContentElementVersion
|
||||
? 'Entwurf offen'
|
||||
: null,
|
||||
'blockedNote' => $blocked instanceof ContentElementVersion && ($ready instanceof ContentElementVersion || $draft instanceof ContentElementVersion)
|
||||
? 'Fassung '.$blocked->number.' deaktiviert'
|
||||
: null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection<int, ContentElementVersion> $versions
|
||||
*/
|
||||
private function processing(Collection $versions): ?string
|
||||
{
|
||||
foreach ($versions as $version) {
|
||||
$meta = is_array($version->metadata) ? $version->metadata : [];
|
||||
|
||||
if (is_string($meta['error'] ?? null) && trim($meta['error']) !== '') {
|
||||
return 'Verarbeitungsfehler';
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($versions as $version) {
|
||||
$meta = is_array($version->metadata) ? $version->metadata : [];
|
||||
$incoming = $meta['incoming'] ?? null;
|
||||
$hasIncoming = (is_string($incoming) && $incoming !== '') || (is_array($incoming) && $incoming !== []);
|
||||
|
||||
if ($hasIncoming && ! is_string($meta['file'] ?? null)) {
|
||||
return 'Datei wird übernommen';
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $portrait
|
||||
* @param list<array<string, mixed>> $uses
|
||||
* @param array<string, string> $filters
|
||||
* @param array<int, list<int>> $classified
|
||||
*/
|
||||
private function matches(ContentElement $element, array $portrait, array $uses, array $filters, string $needle, array $classified): bool
|
||||
{
|
||||
if ($needle !== '' && ! str_contains($this->haystack($element), $needle)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $this->matchesArt($element, $filters['art'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$onlyBlocked = $portrait['ready'] === null && $portrait['draft'] === null && $portrait['blocked'] !== null;
|
||||
|
||||
if ($onlyBlocked && $filters['fassung'] === '' && $filters['archiv'] === 'aktiv') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['archiv'] === 'aktiv' && $portrait['archived']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['archiv'] === 'archiviert' && ! $portrait['archived']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['freigabe'] === 'freigegeben' && $portrait['ready'] === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['freigabe'] === 'entwurf' && ($portrait['draft'] === null || $portrait['ready'] !== null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['freigabe'] === 'ohne' && $portrait['ready'] !== null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['entwurf'] === 'offen' && $portrait['draft'] === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['entwurf'] === 'keiner' && $portrait['draft'] !== null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['fassung'] === 'mit' && $portrait['blocked'] === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['fassung'] === 'nur' && ($portrait['blocked'] === null || $portrait['ready'] !== null || $portrait['draft'] !== null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$used = $this->usageCount($uses) > 0;
|
||||
|
||||
if ($filters['nutzung'] === 'verwendet' && ! $used) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['nutzung'] === 'unbenutzt' && $used) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['saeule'] !== '' && ! $element->pillars->contains('id', (int) $filters['saeule'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['einordnung'] !== '' && ! in_array((int) $filters['einordnung'], $classified[$element->id] ?? [], true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['verarbeitung'] === 'fehler' && $portrait['processing'] !== 'Verarbeitungsfehler') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['verarbeitung'] === 'uebernahme' && $portrait['processing'] !== 'Datei wird übernommen') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function matchesArt(ContentElement $element, string $art): bool
|
||||
{
|
||||
if ($art === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
$class = (string) $element->output_class;
|
||||
|
||||
if ($art === 'document') {
|
||||
return in_array($class, ['document', 'pdf'], true);
|
||||
}
|
||||
|
||||
return $class === $art;
|
||||
}
|
||||
|
||||
private function haystack(ContentElement $element): string
|
||||
{
|
||||
return mb_strtolower(implode("\n", array_filter([
|
||||
$element->working_title,
|
||||
$element->display_title,
|
||||
$element->description,
|
||||
$element->summary,
|
||||
$element->usage_note,
|
||||
], fn (mixed $value): bool => is_string($value) && trim($value) !== '')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $portrait
|
||||
* @param list<array<string, mixed>> $uses
|
||||
* @param list<string> $codes
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function card(ContentElement $element, array $portrait, array $uses, array $codes, bool $canEdit): array
|
||||
{
|
||||
$description = trim((string) ($element->description ?: $element->summary ?: ''));
|
||||
$usageNote = trim((string) $element->usage_note);
|
||||
$licenseNote = trim((string) $element->license_note);
|
||||
$typeKey = $this->typeKey((string) $element->output_class);
|
||||
$count = $this->usageCount($uses);
|
||||
|
||||
return [
|
||||
'id' => $element->id,
|
||||
'title' => $element->working_title,
|
||||
'type' => $this->catalog->outputLabel((string) $element->output_class),
|
||||
'typeKey' => $typeKey,
|
||||
'description' => $description === '' ? null : $description,
|
||||
'usageNote' => $usageNote === '' ? null : $usageNote,
|
||||
'licenseNote' => $licenseNote === '' ? null : $licenseNote,
|
||||
'image' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
||||
'imageAlt' => trim((string) ($element->thumbnail_alt ?: $element->working_title)),
|
||||
'imageNote' => $this->imageNote($element),
|
||||
'stand' => $portrait['stand'],
|
||||
'standTone' => $portrait['standTone'],
|
||||
'draftNote' => $portrait['draftNote'],
|
||||
'blockedNote' => $portrait['blockedNote'],
|
||||
'processing' => $portrait['processing'],
|
||||
'archived' => $portrait['archived'],
|
||||
'versionCount' => $portrait['versionCount'],
|
||||
'versionLabel' => $this->versionCountLabel($portrait['versionCount']),
|
||||
'usageCount' => $count,
|
||||
'usageLabel' => $count === 0
|
||||
? 'In keinem Modul oder Programm verwendet'
|
||||
: ($count === 1 ? '1 Verwendung' : $count.' Verwendungen'),
|
||||
'usages' => $uses,
|
||||
'licenseText' => $this->licenseText($codes),
|
||||
'url' => ContentElementResource::getUrl('view', ['record' => $element]),
|
||||
'editUrl' => $canEdit ? ContentElementResource::getUrl('edit', ['record' => $element]) : null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $uses
|
||||
*/
|
||||
private function usageCount(array $uses): int
|
||||
{
|
||||
return count(array_unique(array_column($uses, 'compositionId')));
|
||||
}
|
||||
|
||||
private function versionCountLabel(int $count): ?string
|
||||
{
|
||||
return match ($count) {
|
||||
0 => null,
|
||||
1 => '1 Fassung',
|
||||
default => $count.' Fassungen',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $codes
|
||||
*/
|
||||
private function licenseText(array $codes): ?string
|
||||
{
|
||||
if ($codes === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$named = count($codes) === 1
|
||||
? 'Im Lizenzartikel '.$codes[0].' genannt.'
|
||||
: 'In den Lizenzartikeln '.implode(', ', $codes).' genannt.';
|
||||
|
||||
return $named.' Das belegt keinen Zugriff in der Bibliothek.';
|
||||
}
|
||||
|
||||
private function imageNote(ContentElement $element): ?string
|
||||
{
|
||||
if (is_string($element->thumbnail_error) && trim($element->thumbnail_error) !== '') {
|
||||
return Str::limit(trim($element->thumbnail_error), 180);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function typeKey(string $outputClass): string
|
||||
{
|
||||
return match ($outputClass) {
|
||||
'film' => 'film',
|
||||
'audio' => 'audio',
|
||||
'bild' => 'bild',
|
||||
'document', 'pdf' => 'document',
|
||||
default => 'text',
|
||||
};
|
||||
}
|
||||
|
||||
private function kindLabel(Composition $composition): string
|
||||
{
|
||||
$kind = $composition->kind;
|
||||
|
||||
return ($kind instanceof CompositionKind ? $kind : CompositionKind::from((string) $kind))->deskLabel();
|
||||
}
|
||||
|
||||
private function versionLabel(ContentElementVersion $version): string
|
||||
{
|
||||
return match ($version->status) {
|
||||
ContentVersionStatus::Entwurf => 'Entwurf',
|
||||
ContentVersionStatus::Gesperrt => 'Fassung '.$version->number.', deaktiviert',
|
||||
default => 'Fassung '.$version->number,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
* Macht Feldfehler aus Widget-Dialogen am Abschnitt sichtbar. Die Felder eines Widgets liegen in seinem Dialog;
|
||||
* schlägt die Formularprüfung beim Speichern fehl, erscheint eine Meldung mit Abschnitt, Platz und Widget-Art,
|
||||
* und das Platzraster des Abschnitts trägt eine Zusammenfassung.
|
||||
*/
|
||||
trait ReportsSectionErrors
|
||||
{
|
||||
protected function onValidationError(ValidationException $exception): void
|
||||
{
|
||||
parent::onValidationError($exception);
|
||||
|
||||
$state = is_array($this->data['sections'] ?? null) ? $this->data['sections'] : [];
|
||||
$sectionErrors = SectionEditor::sectionErrorsFromForm($exception->errors(), $state);
|
||||
|
||||
if ($sectionErrors === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
SectionEditor::notifyErrors($sectionErrors, $state);
|
||||
|
||||
foreach (SectionEditor::mapErrors($sectionErrors, $state) as $key => $messages) {
|
||||
if (str_ends_with($key, '.slots')) {
|
||||
foreach ((array) $messages as $message) {
|
||||
$exception->validator->errors()->add($key, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,543 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use App\Domain\Cms\Sections\PageSections;
|
||||
use App\Domain\Cms\Sections\SectionLayouts;
|
||||
use App\Domain\Cms\Sections\SectionStyle;
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\Group;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Seiteneditor für Abschnitte und Slots.
|
||||
*
|
||||
* Aufbau: Abschnitte (Repeater) → Raster (grafische Auswahl) → Gestaltung (eingeklappt) → Plätze (Repeater im
|
||||
* Rasterverhältnis) → je Platz ein Widget (Builder mit höchstens einem Eintrag, Auswahl aus dem Widget-Register).
|
||||
* Abschnittseinstellungen stehen im Abschnitt, Widget-Einstellungen im Widget-Dialog: eine Dialogebene.
|
||||
*
|
||||
* Formularzustand eines Abschnitts: {id, layout, style: {...}, slots: {uuid: {widget: {uuid: Builder-Eintrag}}}}.
|
||||
*/
|
||||
class SectionEditor
|
||||
{
|
||||
public static function repeater(string $name = 'sections'): Repeater
|
||||
{
|
||||
return Repeater::make($name)
|
||||
->label('Abschnitte')
|
||||
->hiddenLabel()
|
||||
->schema(self::sectionSchema())
|
||||
->itemLabel(fn (array $state, ?int $index): string => self::sectionLabel($state, $index))
|
||||
->addActionLabel('Abschnitt hinzufügen')
|
||||
->addBetweenActionLabel('Abschnitt hier einfügen')
|
||||
->defaultItems(0)
|
||||
->reorderableWithButtons()
|
||||
->reorderableWithDragAndDrop()
|
||||
->cloneable()
|
||||
->collapsible()
|
||||
->deletable()
|
||||
->maxItems(PageSections::MAX_SECTIONS)
|
||||
->cloneAction(fn (Action $action): Action => $action
|
||||
->tooltip('Abschnitt duplizieren')
|
||||
->action(function (array $arguments, Repeater $component): void {
|
||||
// Die Kopie steht direkt hinter dem Original (Filament hängt sie sonst ans Seitenende).
|
||||
$component->rawState(self::insertCopyAfter($component->getRawState() ?? [], (string) $arguments['item'], (string) $component->generateUuid()));
|
||||
$component->callAfterStateUpdated();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
}))
|
||||
->deleteAction(fn (Action $action): Action => $action
|
||||
->tooltip('Abschnitt löschen')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Abschnitt löschen?')
|
||||
->modalDescription('Der Abschnitt und die Widgets darin werden aus dem Entwurf entfernt. Bereits gespeicherte Revisionen bleiben erhalten.')
|
||||
->modalSubmitActionLabel('Löschen'))
|
||||
->moveUpAction(fn (Action $action): Action => $action->tooltip('Abschnitt nach oben'))
|
||||
->moveDownAction(fn (Action $action): Action => $action->tooltip('Abschnitt nach unten'))
|
||||
->reorderAction(fn (Action $action): Action => $action->tooltip('Abschnitt ziehen'))
|
||||
->collapseAction(fn (Action $action): Action => $action->tooltip('Abschnitt einklappen'))
|
||||
->expandAction(fn (Action $action): Action => $action->tooltip('Abschnitt aufklappen'))
|
||||
->extraAttributes(['class' => 'luf-sections'])
|
||||
->columnSpanFull();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<mixed>
|
||||
*/
|
||||
private static function sectionSchema(): array
|
||||
{
|
||||
return [
|
||||
Hidden::make('id'),
|
||||
ToggleButtons::make('layout')
|
||||
->label('Raster')
|
||||
->options(self::layoutOptions())
|
||||
->default(SectionLayouts::DEFAULT)
|
||||
->required()
|
||||
->inline()
|
||||
->live()
|
||||
->disableOptionWhen(fn (string $value, Get $get): bool => self::filledCount($get('slots')) > SectionLayouts::slotCount($value))
|
||||
->helperText(fn (Get $get): ?string => self::filledCount($get('slots')) > 1
|
||||
? 'Raster mit weniger Plätzen als eingesetzten Widgets sind gesperrt. Entfernen oder verschieben Sie zuerst ein Widget; beim Wechsel geht kein Widget verloren.'
|
||||
: null)
|
||||
->afterStateUpdated(function (?string $state, Get $get, Set $set): void {
|
||||
$set('slots', self::arrangeSlots($get('slots'), $state ?? SectionLayouts::DEFAULT));
|
||||
})
|
||||
->extraAttributes(['class' => 'luf-layout-picker']),
|
||||
Section::make('Gestaltung des Abschnitts')
|
||||
->description(fn (Get $get): string => SectionStyle::summary(is_array($get('style')) ? $get('style') : []))
|
||||
->icon('heroicon-o-swatch')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->compact()
|
||||
->schema([
|
||||
Group::make(self::styleFields())
|
||||
->statePath('style')
|
||||
->columns(['default' => 1, 'md' => 2, 'xl' => 4]),
|
||||
]),
|
||||
Repeater::make('slots')
|
||||
->label('Plätze im Raster')
|
||||
->hiddenLabel()
|
||||
->schema([
|
||||
WidgetEditor::slotBuilder('widget'),
|
||||
])
|
||||
->addable(false)
|
||||
->deletable(false)
|
||||
->reorderableWithDragAndDrop()
|
||||
->reorderableWithButtons(false)
|
||||
->reorderAction(fn (Action $action): Action => $action->tooltip('Widget auf einen anderen Platz ziehen'))
|
||||
->itemLabel(fn (array $state, ?int $index, Get $get): string => self::slotLabel($state, $index, $get('layout')))
|
||||
->default(fn (): array => self::arrangeSlots([], SectionLayouts::DEFAULT))
|
||||
->extraAttributes(fn (Get $get): array => [
|
||||
'class' => 'luf-slots',
|
||||
'style' => '--luf-slot-cols: '.self::editorColumns($get('layout')),
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<mixed>
|
||||
*/
|
||||
private static function styleFields(): array
|
||||
{
|
||||
return [
|
||||
Select::make('background')
|
||||
->label('Hintergrund')
|
||||
->options(SectionStyle::BACKGROUNDS)
|
||||
->default('default')
|
||||
->selectablePlaceholder(false)
|
||||
->live(),
|
||||
Select::make('width')
|
||||
->label('Breite')
|
||||
->options(SectionStyle::WIDTHS)
|
||||
->default('standard')
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Ein Hintergrund reicht immer über die ganze Bildschirmbreite.'),
|
||||
Select::make('spacing_top')
|
||||
->label('Abstand oben')
|
||||
->options(SectionStyle::SPACINGS)
|
||||
->default(SectionStyle::DEFAULTS['spacing_top'])
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Vor dem Inhalt. Zwischen zwei Abschnitten addieren sich „unten“ und „oben“; „Kein Abstand“ lässt einen Einstieg direkt unter der Kopfzeile beginnen.'),
|
||||
Select::make('spacing_bottom')
|
||||
->label('Abstand unten')
|
||||
->options(SectionStyle::SPACINGS)
|
||||
->default(SectionStyle::DEFAULTS['spacing_bottom'])
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Nach dem Inhalt. Bei eigener Fläche liegen beide Abstände innerhalb der Fläche.'),
|
||||
Select::make('gap')
|
||||
->label('Widget-Abstand')
|
||||
->options(SectionStyle::SPACINGS)
|
||||
->default(SectionStyle::DEFAULTS['gap'])
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Zwischen den Plätzen dieses Abschnitts, nebeneinander und gestapelt. Abstände innerhalb eines Widgets bleiben Sache des Widgets.'),
|
||||
Select::make('divider')
|
||||
->label('Trenner zum nächsten Abschnitt')
|
||||
->options(SectionStyle::DIVIDERS)
|
||||
->default('none')
|
||||
->selectablePlaceholder(false),
|
||||
...array_map(
|
||||
fn ($field) => $field->visible(fn (Get $get): bool => $get('background') === 'image')->columnSpan(['default' => 1, 'md' => 2]),
|
||||
ImageRefFields::fields('Hintergrundbild'),
|
||||
),
|
||||
Select::make('focus')
|
||||
->label('Bildausschnitt (Fokuspunkt)')
|
||||
->options(SectionStyle::FOCUS)
|
||||
->default('center')
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Dieser Bereich bleibt auf schmalen Bildschirmen sichtbar.')
|
||||
->visible(fn (Get $get): bool => $get('background') === 'image'),
|
||||
Select::make('overlay')
|
||||
->label('Überlagerung')
|
||||
->options(SectionStyle::OVERLAYS)
|
||||
->default('light')
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Sorgt für lesbaren Text auf dem Bild.')
|
||||
->visible(fn (Get $get): bool => $get('background') === 'image'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gespeicherte Abschnitte (PageSections::read) als Formularzustand.
|
||||
*
|
||||
* @param list<array<string, mixed>> $sections
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public static function toEditorState(array $sections): array
|
||||
{
|
||||
$state = [];
|
||||
|
||||
foreach ($sections as $section) {
|
||||
$slots = [];
|
||||
|
||||
foreach ($section['slots'] as $widget) {
|
||||
$slots[(string) Str::uuid()] = [
|
||||
'widget' => is_array($widget) ? self::keyed(WidgetEditor::toBuilderState([$widget])) : [],
|
||||
];
|
||||
}
|
||||
|
||||
$state[] = [
|
||||
'id' => $section['id'] ?? (string) Str::uuid(),
|
||||
'layout' => $section['layout'],
|
||||
'style' => SectionStyle::fromStored($section['style'] ?? []),
|
||||
'slots' => $slots,
|
||||
];
|
||||
}
|
||||
|
||||
return $state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formularzustand als Abschnitte für PageService::saveRevision().
|
||||
*
|
||||
* @param array<int|string, mixed>|null $state
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public static function fromEditorState(?array $state): array
|
||||
{
|
||||
$sections = [];
|
||||
|
||||
foreach (array_values($state ?? []) as $section) {
|
||||
if (! is_array($section)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$slots = [];
|
||||
foreach (array_values(is_array($section['slots'] ?? null) ? $section['slots'] : []) as $slot) {
|
||||
$items = is_array($slot['widget'] ?? null) ? $slot['widget'] : [];
|
||||
$slots[] = $items === [] ? null : (WidgetEditor::fromBuilderState($items)[0] ?? null);
|
||||
}
|
||||
|
||||
$sections[] = [
|
||||
'id' => $section['id'] ?? null,
|
||||
'layout' => $section['layout'] ?? SectionLayouts::DEFAULT,
|
||||
'style' => is_array($section['style'] ?? null) ? $section['style'] : [],
|
||||
'slots' => $slots,
|
||||
];
|
||||
}
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Übersetzt Fehlerschlüssel aus PageSections ("sections.2.slots.1.data.heading") in Formularpfade.
|
||||
* Widget-Fehler stehen zusätzlich als Zusammenfassung am Platzraster des Abschnitts, weil die Widget-Felder
|
||||
* nach dem Schließen des Dialogs nicht sichtbar sind.
|
||||
*
|
||||
* @param array<string, mixed> $errors
|
||||
* @param array<int|string, mixed> $state roher Formularzustand der Abschnitte
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function mapErrors(array $errors, array $state, string $statePath = 'data.sections'): array
|
||||
{
|
||||
$registry = app(WidgetRegistry::class);
|
||||
$sectionKeys = array_keys($state);
|
||||
$mapped = [];
|
||||
|
||||
foreach ($errors as $key => $messages) {
|
||||
$messages = (array) $messages;
|
||||
|
||||
if (preg_match('/^sections\.(\d+)(?:\.(.*))?$/', (string) $key, $match) !== 1 || ! isset($sectionKeys[(int) $match[1]])) {
|
||||
$mapped[$key === 'sections' ? $statePath : 'data.'.$key] = $messages;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$sectionKey = $sectionKeys[(int) $match[1]];
|
||||
$sectionPath = "$statePath.$sectionKey";
|
||||
$rest = $match[2] ?? '';
|
||||
|
||||
if (preg_match('/^slots\.(\d+)(?:\.(.*))?$/', $rest, $slotMatch) === 1) {
|
||||
$slotKeys = array_keys(is_array($state[$sectionKey]['slots'] ?? null) ? $state[$sectionKey]['slots'] : []);
|
||||
$slotKey = $slotKeys[(int) $slotMatch[1]] ?? null;
|
||||
$field = $slotMatch[2] ?? '';
|
||||
$position = (int) $slotMatch[1] + 1;
|
||||
$widgetItems = $slotKey !== null ? ($state[$sectionKey]['slots'][$slotKey]['widget'] ?? []) : [];
|
||||
$widgetKey = is_array($widgetItems) ? array_key_first($widgetItems) : null;
|
||||
$type = $widgetKey !== null ? ($widgetItems[$widgetKey]['type'] ?? null) : null;
|
||||
$label = $registry->has($type) ? $registry->get($type)->label() : 'Widget';
|
||||
|
||||
$summary = $mapped["$sectionPath.slots"] ?? [];
|
||||
foreach ($messages as $message) {
|
||||
$summary[] = "Platz $position ($label): $message";
|
||||
}
|
||||
$mapped["$sectionPath.slots"] = array_values(array_unique($summary));
|
||||
|
||||
if ($slotKey !== null && $widgetKey !== null && $field !== '' && $field !== 'units') {
|
||||
$field = preg_replace('/\.\d+\..*$/', '', $field);
|
||||
$mapped["$sectionPath.slots.$slotKey.widget.$widgetKey.data.$field"] = $messages;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$mapped[$rest === '' ? $sectionPath : "$sectionPath.$rest"] = $messages;
|
||||
}
|
||||
|
||||
return $mapped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formularfehler aus Widget-Dialogen ("data.sections.{uuid}.slots.{uuid}.widget.{uuid}.data.data.feld") in
|
||||
* Schlüssel des Abschnittsmodells ("sections.N.slots.M.data.feld") übersetzen.
|
||||
*
|
||||
* @param array<string, mixed> $errors
|
||||
* @param array<int|string, mixed> $state
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
public static function sectionErrorsFromForm(array $errors, array $state, string $statePath = 'data.sections'): array
|
||||
{
|
||||
$sectionKeys = array_flip(array_map('strval', array_keys($state)));
|
||||
$translated = [];
|
||||
$pattern = '/^'.preg_quote($statePath, '/').'\.([^.]+)\.slots\.([^.]+)\.widget\.[^.]+\.data\.(.+)$/';
|
||||
|
||||
foreach ($errors as $key => $messages) {
|
||||
if (preg_match($pattern, (string) $key, $match) !== 1 || ! isset($sectionKeys[$match[1]])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$slotKeys = array_flip(array_map('strval', array_keys(is_array($state[$match[1]]['slots'] ?? null) ? $state[$match[1]]['slots'] : [])));
|
||||
if (! isset($slotKeys[$match[2]])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$translated['sections.'.$sectionKeys[$match[1]].'.slots.'.$slotKeys[$match[2]].'.'.$match[3]] = array_values((array) $messages);
|
||||
}
|
||||
|
||||
return $translated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sichtbare Meldung mit Abschnittsnummer, Platz und Widget-Art.
|
||||
*
|
||||
* @param array<string, list<string>> $errors
|
||||
* @param array<int|string, mixed> $state
|
||||
*/
|
||||
public static function notifyErrors(array $errors, array $state): void
|
||||
{
|
||||
$registry = app(WidgetRegistry::class);
|
||||
$sections = array_values($state);
|
||||
$lines = [];
|
||||
|
||||
foreach ($errors as $key => $messages) {
|
||||
$text = implode(' ', (array) $messages);
|
||||
|
||||
if (preg_match('/^sections\.(\d+)(?:\.slots\.(\d+))?/', (string) $key, $match) === 1) {
|
||||
$line = 'Abschnitt '.((int) $match[1] + 1);
|
||||
|
||||
if (isset($match[2])) {
|
||||
$slots = array_values(is_array($sections[(int) $match[1]]['slots'] ?? null) ? $sections[(int) $match[1]]['slots'] : []);
|
||||
$items = $slots[(int) $match[2]]['widget'] ?? [];
|
||||
$type = is_array($items) && $items !== [] ? (array_values($items)[0]['type'] ?? null) : null;
|
||||
$line .= ', Platz '.((int) $match[2] + 1).($registry->has($type) ? ' ('.$registry->get($type)->label().')' : '');
|
||||
}
|
||||
|
||||
$lines[] = $line.': '.$text;
|
||||
} else {
|
||||
$lines[] = $text;
|
||||
}
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Nicht gespeichert')
|
||||
->body(implode("\n", array_unique($lines)))
|
||||
->danger()
|
||||
->persistent()
|
||||
->send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ordnet Plätze für ein neues Raster: Widgets behalten ihre Reihenfolge, leere Plätze entfallen zuerst.
|
||||
* Es wird nie ein Widget entfernt; passen nicht alle Widgets, bleiben überzählige Plätze bestehen
|
||||
* (die Auswahl solcher Raster ist im Editor gesperrt, das Speichern weist sie ab).
|
||||
*
|
||||
* @param mixed $slots roher Zustand {uuid: {widget: {...}}}
|
||||
* @return array<string, array{widget: array<string, mixed>}>
|
||||
*/
|
||||
public static function arrangeSlots(mixed $slots, string $layout): array
|
||||
{
|
||||
$slots = is_array($slots) ? $slots : [];
|
||||
$count = SectionLayouts::slotCount(SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT);
|
||||
|
||||
if (count($slots) === $count) {
|
||||
return $slots;
|
||||
}
|
||||
|
||||
$filled = array_filter($slots, fn ($slot): bool => self::slotHasWidget($slot));
|
||||
|
||||
if (count($slots) < $count) {
|
||||
$arranged = $slots;
|
||||
} else {
|
||||
// Leere Plätze am Ende zuerst entfernen, dann übrige leere Plätze, bis die Zahl passt.
|
||||
$arranged = $slots;
|
||||
foreach (array_reverse(array_keys($slots)) as $key) {
|
||||
if (count($arranged) <= $count) {
|
||||
break;
|
||||
}
|
||||
if (! self::slotHasWidget($slots[$key])) {
|
||||
unset($arranged[$key]);
|
||||
}
|
||||
}
|
||||
$arranged = count($arranged) > $count ? $filled : $arranged;
|
||||
}
|
||||
|
||||
while (count($arranged) < $count) {
|
||||
$arranged[(string) Str::uuid()] = ['widget' => []];
|
||||
}
|
||||
|
||||
return $arranged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt die Kopie eines Abschnitts direkt hinter dem Original ein. Kennungen bleiben gleich; beim Speichern
|
||||
* behält das Original seine Kennungen und die Kopie erhält neue.
|
||||
*
|
||||
* @param array<string, mixed> $items
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function insertCopyAfter(array $items, string $key, string $newKey): array
|
||||
{
|
||||
if (! array_key_exists($key, $items)) {
|
||||
return $items;
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($items as $itemKey => $item) {
|
||||
$result[$itemKey] = $item;
|
||||
if ((string) $itemKey === $key) {
|
||||
$result[$newKey] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function filledCount(mixed $slots): int
|
||||
{
|
||||
return count(array_filter(is_array($slots) ? $slots : [], fn ($slot): bool => self::slotHasWidget($slot)));
|
||||
}
|
||||
|
||||
private static function slotHasWidget(mixed $slot): bool
|
||||
{
|
||||
return is_array($slot) && is_array($slot['widget'] ?? null) && $slot['widget'] !== [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, HtmlString>
|
||||
*/
|
||||
private static function layoutOptions(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (SectionLayouts::UNITS as $key => $units) {
|
||||
$options[$key] = new HtmlString(
|
||||
'<span class="luf-layout-option">'.SectionLayouts::schematicSvg($key)
|
||||
.'<span class="luf-layout-option-text">'.e(SectionLayouts::short($key)).'</span>'
|
||||
.'<span class="fi-sr-only">'.e(SectionLayouts::LABELS[$key]).'</span></span>'
|
||||
);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spaltenverhältnis der Plätze im Editor; entspricht dem Desktop-Raster der Website.
|
||||
*/
|
||||
private static function editorColumns(mixed $layout): string
|
||||
{
|
||||
$units = SectionLayouts::units(SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT);
|
||||
|
||||
return implode(' ', array_map(fn (int $unit): string => "minmax(0, {$unit}fr)", $units));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $state
|
||||
*/
|
||||
private static function sectionLabel(array $state, ?int $index): string
|
||||
{
|
||||
$layout = SectionLayouts::has($state['layout'] ?? null) ? $state['layout'] : SectionLayouts::DEFAULT;
|
||||
$registry = app(WidgetRegistry::class);
|
||||
$names = [];
|
||||
|
||||
foreach (is_array($state['slots'] ?? null) ? $state['slots'] : [] as $slot) {
|
||||
$items = is_array($slot['widget'] ?? null) ? $slot['widget'] : [];
|
||||
$type = $items !== [] ? (array_values($items)[0]['type'] ?? null) : null;
|
||||
if ($registry->has($type)) {
|
||||
$names[] = $registry->get($type)->label();
|
||||
}
|
||||
}
|
||||
|
||||
$label = 'Abschnitt '.(($index ?? 0) + 1).' · Raster '.SectionLayouts::short($layout)
|
||||
.' · '.SectionStyle::summary(is_array($state['style'] ?? null) ? $state['style'] : []);
|
||||
|
||||
return $names === [] ? $label.' · noch leer' : $label.' · '.implode(', ', $names);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $state
|
||||
*/
|
||||
private static function slotLabel(array $state, ?int $index, mixed $layout): string
|
||||
{
|
||||
$layout = SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT;
|
||||
$units = SectionLayouts::units($layout);
|
||||
$position = $index ?? 0;
|
||||
$slotUnits = $units[$position] ?? null;
|
||||
|
||||
if ($slotUnits === null) {
|
||||
return 'Platz '.($position + 1).' · außerhalb des Rasters: Widget entfernen oder Raster mit mehr Plätzen wählen';
|
||||
}
|
||||
|
||||
$label = 'Platz '.($position + 1).' · '.$slotUnits.' '.($slotUnits === 1 ? 'Einheit' : 'Einheiten');
|
||||
$items = is_array($state['widget'] ?? null) ? $state['widget'] : [];
|
||||
$type = $items !== [] ? (array_values($items)[0]['type'] ?? null) : null;
|
||||
$registry = app(WidgetRegistry::class);
|
||||
|
||||
if ($registry->has($type) && ! $registry->get($type)->supportsUnits($slotUnits)) {
|
||||
$label .= ' · passt nicht: „'.$registry->get($type)->label().'“ ist für '.$registry->get($type)->unitsLabel().' Einheiten vorgesehen';
|
||||
}
|
||||
|
||||
return $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $items
|
||||
* @return array<string, array<string, mixed>>
|
||||
*/
|
||||
private static function keyed(array $items): array
|
||||
{
|
||||
$keyed = [];
|
||||
foreach ($items as $item) {
|
||||
$keyed[(string) Str::uuid()] = $item;
|
||||
}
|
||||
|
||||
return $keyed;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,13 @@
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\Group;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Components\Text;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\View;
|
||||
use Illuminate\Foundation\Vite;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -53,31 +59,99 @@ public static function builder(string $name = 'blocks'): Builder
|
||||
->columnSpanFull();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ein Platz im Abschnittsraster: höchstens ein Widget. Hinzufügen öffnet die Widget-Auswahl und danach den
|
||||
* Bearbeitungsdialog; die Vorschau zeigt das Widget in der tatsächlichen Platzbreite.
|
||||
*/
|
||||
public static function slotBuilder(string $name = 'widget'): Builder
|
||||
{
|
||||
$registry = app(WidgetRegistry::class);
|
||||
|
||||
return Builder::make($name)
|
||||
->label('Widget')
|
||||
->hiddenLabel()
|
||||
->blocks(array_values(array_map(self::block(...), $registry->all())))
|
||||
->blockPreviews()
|
||||
->blockPickerColumns(['default' => 1, 'md' => 2])
|
||||
->blockPickerWidth('3xl')
|
||||
->addActionLabel('Widget einsetzen')
|
||||
->maxItems(1)
|
||||
->blockNumbers(false)
|
||||
->reorderable(false)
|
||||
->cloneable(false)
|
||||
->deletable()
|
||||
->collapsible(false)
|
||||
->addAction(fn ($action) => $action->modalHeading('Widget einrichten')->modalWidth('4xl')->icon('heroicon-o-plus'))
|
||||
->editAction(fn ($action) => $action->modalHeading('Widget bearbeiten')->modalWidth('4xl')->modalSubmitActionLabel('Übernehmen')->tooltip('Widget bearbeiten'))
|
||||
->deleteAction(fn ($action) => $action->tooltip('Widget aus diesem Platz entfernen')->requiresConfirmation()->modalHeading('Widget entfernen?')->modalDescription('Das Widget wird aus dem Entwurf entfernt. Gespeicherte Revisionen bleiben erhalten.')->modalSubmitActionLabel('Entfernen'))
|
||||
->columnSpanFull();
|
||||
}
|
||||
|
||||
public static function block(WidgetType $type): Block
|
||||
{
|
||||
$variants = $type->variants();
|
||||
$icons = $type->optionIcons();
|
||||
$display = [];
|
||||
|
||||
$schema = [Hidden::make('id')];
|
||||
|
||||
$schema[] = count($variants) > 1
|
||||
? ToggleButtons::make('variant')
|
||||
if (count($type->variants()) > 1) {
|
||||
$display[] = ToggleButtons::make('variant')
|
||||
->label('Darstellung')
|
||||
->options($variants)
|
||||
->options($type->variants())
|
||||
->icons($icons['variant'] ?? [])
|
||||
->default($type->defaultVariant())
|
||||
->inline()
|
||||
->required()
|
||||
: Hidden::make('variant')->default($type->defaultVariant());
|
||||
|
||||
if ($type->settings() !== []) {
|
||||
$settings = [];
|
||||
foreach ($type->settings() as $key => $options) {
|
||||
$settings[] = Select::make($key)->label(Str::headline($key))->options($options);
|
||||
}
|
||||
$schema[] = Group::make($settings)->statePath('settings');
|
||||
->live();
|
||||
}
|
||||
|
||||
foreach ($type->editorSchema() as $component) {
|
||||
$schema[] = $component;
|
||||
$settings = [];
|
||||
$labels = $type->settingLabels();
|
||||
foreach ($type->settingOptions() as $key => $options) {
|
||||
// Gemeinsame Höhe (ADR-38): immer als sichtbare Auswahl mit Vorgabe, nie als freie Eingabe.
|
||||
$settings[] = $key === 'height'
|
||||
? ToggleButtons::make('height')
|
||||
->label('Höhe')
|
||||
->helperText('Gestaltungsparameter, keine Begrenzung: Längere Inhalte erhalten immer den nötigen Platz.')
|
||||
->options($options)
|
||||
->icons($icons['height'] ?? [])
|
||||
->default($type->defaultHeight())
|
||||
->inline()
|
||||
->live()
|
||||
: Select::make($key)
|
||||
->label($labels[$key][0] ?? Str::headline($key))
|
||||
->helperText($labels[$key][1] ?? null)
|
||||
->placeholder('Vorgabe der Darstellung')
|
||||
->options($options)
|
||||
->live();
|
||||
}
|
||||
|
||||
if ($settings !== []) {
|
||||
$display[] = Grid::make(['default' => 1, 'md' => 2])->schema($settings)->statePath('settings');
|
||||
}
|
||||
|
||||
$variantField = count($type->variants()) > 1 ? [] : [Hidden::make('variant')->default($type->defaultVariant())];
|
||||
$content = $type->editorSchema();
|
||||
$media = $type->mediaSchema();
|
||||
|
||||
if ($display === [] && $media === []) {
|
||||
$schema = [Hidden::make('id'), ...$variantField, ...$content];
|
||||
} else {
|
||||
$tabs = [Tab::make('Inhalt')->icon('heroicon-o-pencil-square')->schema($content)];
|
||||
if ($media !== []) {
|
||||
$tabs[] = Tab::make('Medien')->icon('heroicon-o-photo')->schema($media);
|
||||
}
|
||||
if ($display !== []) {
|
||||
$tabs[] = Tab::make('Darstellung')->icon('heroicon-o-adjustments-horizontal')->schema([
|
||||
...$display,
|
||||
Text::make('Platzbreiten: '.$type->unitsLabel().' Rastereinheiten. '.$type->narrowBehavior()),
|
||||
]);
|
||||
}
|
||||
|
||||
$schema = [
|
||||
Hidden::make('id'),
|
||||
...$variantField,
|
||||
Tabs::make('Widget')->tabs($tabs)->contained(false),
|
||||
self::livePreview($type),
|
||||
];
|
||||
}
|
||||
|
||||
return WidgetBlock::make($type->key())
|
||||
@@ -205,6 +279,50 @@ public static function notifyErrors(array $errors, array $blocks): void
|
||||
->send();
|
||||
}
|
||||
|
||||
/** Logische Vorschaubreiten in px: tatsächliche Platzbreiten im Standardabschnitt bei 1440 px Fensterbreite. */
|
||||
public const PREVIEW_UNIT_WIDTHS = [1 => 310, 2 => 640, 3 => 960, 4 => 1300];
|
||||
|
||||
public const PREVIEW_PHONE_WIDTH = 390;
|
||||
|
||||
/**
|
||||
* Live-Vorschau im Bearbeitungsdialog: rendert den ungespeicherten Zustand mit derselben Ansicht wie die Website
|
||||
* in einer wählbaren Platzbreite. Die Breitenwahl (_preview_width) wird nicht gespeichert.
|
||||
*/
|
||||
private static function livePreview(WidgetType $type): Section
|
||||
{
|
||||
$default = (string) self::PREVIEW_UNIT_WIDTHS[$type->preferredUnits()];
|
||||
$widths = [(string) self::PREVIEW_PHONE_WIDTH => 'Smartphone'];
|
||||
foreach ($type->supportedUnits() as $units) {
|
||||
$widths[(string) self::PREVIEW_UNIT_WIDTHS[$units]] = $units.' '.($units === 1 ? 'Einheit' : 'Einheiten');
|
||||
}
|
||||
|
||||
return Section::make('Vorschau')
|
||||
->description('Änderungen erscheinen sofort. Unter 860 px zeigt der Einstieg den Sicherheitsumbruch, Bild und Text ab 900 px zwei Spalten.')
|
||||
->collapsible()
|
||||
->compact()
|
||||
->schema([
|
||||
ToggleButtons::make('_preview_width')
|
||||
->hiddenLabel()
|
||||
->options($widths)
|
||||
->default($default)
|
||||
->inline()
|
||||
->live()
|
||||
->dehydrated(false)
|
||||
->extraAttributes(['class' => 'luf-preview-width']),
|
||||
View::make('filament.cms.widget-live-preview')
|
||||
->viewData(fn (Get $get): array => [
|
||||
'html' => self::renderPreview($type->key(), [
|
||||
'variant' => $get('variant'),
|
||||
'settings' => $get('settings'),
|
||||
'data' => $get('data'),
|
||||
'refs' => $get('refs'),
|
||||
]),
|
||||
'stylesheets' => self::previewStylesheets(),
|
||||
'width' => (int) ($get('_preview_width') ?: $default),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blockvorschau: dieselbe Widget-Ansicht wie öffentlich, aus dem ungespeicherten Zustand.
|
||||
*
|
||||
@@ -252,10 +370,18 @@ private static function pickerLabel(WidgetType $type): HtmlString
|
||||
'<span class="luf-widget-pick">'
|
||||
.self::schematicSvg($type)
|
||||
.'<span class="luf-widget-pick-text"><span class="luf-widget-pick-name">'.e($type->label()).'</span>'
|
||||
.'<span class="luf-widget-pick-desc">'.e($type->description()).'</span></span></span>'
|
||||
.'<span class="luf-widget-pick-desc">'.e($type->description()).'</span>'
|
||||
.'<span class="luf-widget-pick-units">'.e(self::unitsHint($type)).'</span></span></span>'
|
||||
);
|
||||
}
|
||||
|
||||
private static function unitsHint(WidgetType $type): string
|
||||
{
|
||||
return $type->supportedUnits() === [1, 2, 3, 4]
|
||||
? 'Passt in jeden Platz (1 bis 4 Einheiten)'
|
||||
: 'Für Plätze mit '.$type->unitsLabel().' Rastereinheiten';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $state
|
||||
*/
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageRevision;
|
||||
use App\Domain\Cms\PageTemplates;
|
||||
use App\Domain\Cms\Sections\SectionRenderer;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\WidgetRenderer;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
@@ -69,10 +69,11 @@ private function render(Page $page, bool $preview, ?PageRevision $revision = nul
|
||||
'revision' => $revision,
|
||||
'preview' => $preview,
|
||||
'template' => app(PageTemplates::class)->viewFor($page),
|
||||
'content' => app(WidgetRenderer::class)->renderAll($revision->blocks, $context),
|
||||
'content' => app(SectionRenderer::class)->renderAll($revision->sections(), $context),
|
||||
'documentTitle' => $revision->seo_title ?: ($revision->contentTitle() ?? config('app.name')),
|
||||
'documentDescription' => $revision->seo_description,
|
||||
'themes' => $page->path === '/' ? Pillar::query()->published()->get() : collect(),
|
||||
'activePath' => $page->path,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,21 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Domain\Media\WebsiteMediaAlias;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class PublicMediaController extends Controller
|
||||
{
|
||||
public function show(string $path): StreamedResponse
|
||||
public function show(string $path, WebsiteMedia $media): StreamedResponse
|
||||
{
|
||||
abort_if(str_contains($path, '..') || ! str_starts_with($path, 'cms/'), 404);
|
||||
|
||||
// Ein in den Medienmanager übernommenes Bild folgt dessen Website-Freigabe, auch unter der früheren Adresse.
|
||||
$alias = WebsiteMediaAlias::effectiveFor($path);
|
||||
abort_if($alias !== null && $media->present($alias->content_element_id) === null, 404);
|
||||
|
||||
foreach (['media_public', 'cms_incoming'] as $disk) {
|
||||
if (Storage::disk($disk)->exists($path)) {
|
||||
return Storage::disk($disk)->response($path);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class WebsiteMediaController extends Controller
|
||||
{
|
||||
public function show(ContentElement $element, WebsiteMedia $media): StreamedResponse
|
||||
{
|
||||
$presentation = $media->present($element);
|
||||
abort_if($presentation === null, 404);
|
||||
|
||||
$path = $element->website_public_path;
|
||||
abort_if(! is_string($path), 404);
|
||||
|
||||
return Storage::disk('media_public')->response($path, null, [
|
||||
'Content-Disposition' => 'inline',
|
||||
'X-Content-Type-Options' => 'nosniff',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Media\ThumbnailDeriver;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class AcceptWebsiteImage implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public int $elementId,
|
||||
public string $incoming,
|
||||
public ?int $actorId = null,
|
||||
) {}
|
||||
|
||||
public function handle(ThumbnailDeriver $deriver, WebsiteRelease $release): void
|
||||
{
|
||||
$element = ContentElement::query()->find($this->elementId);
|
||||
|
||||
if (! $element instanceof ContentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
$deriver->forWebsiteImage($element, $this->incoming);
|
||||
$element->refresh();
|
||||
|
||||
if ($release->derivedPath($element) === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->incomingIsDisposable()) {
|
||||
Storage::disk('cms_incoming')->delete($this->incoming);
|
||||
}
|
||||
|
||||
PublishWebsiteMedia::dispatch($element->id, 'release', $this->actorId);
|
||||
}
|
||||
|
||||
private function incomingIsDisposable(): bool
|
||||
{
|
||||
return (str_starts_with($this->incoming, 'cms/') || str_starts_with($this->incoming, 'vorschau/'))
|
||||
&& ! str_contains($this->incoming, '..');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Domain\Media\WebsiteIntake;
|
||||
use App\Domain\Media\WebsiteMediaAlias;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Übernimmt die bisherigen CMS-Bilder (media_public, cms/…) in den Medienmanager.
|
||||
*
|
||||
* - Bytegleiche Dateien werden ein Medium (SHA-256); jeder frühere Pfad erhält eine Zuordnung (WebsiteMediaAlias).
|
||||
* - Neue Medien entstehen über WebsiteIntake: Die Warteschlange leitet das Bild ab und gibt genau diese Ableitung
|
||||
* für die Website frei. Erst danach wird die Zuordnung wirksam; bis dahin bleibt der frühere Pfad gültig.
|
||||
* - Wiederholbar: Bereits zugeordnete Pfade werden übersprungen. Es wird nichts gelöscht; die Dateien unter cms/
|
||||
* bleiben liegen (frühere Revisionen, Rückweg).
|
||||
*/
|
||||
class ImportCmsImages implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
private const EXTENSIONS = ['jpg', 'jpeg', 'png', 'webp', 'gif'];
|
||||
|
||||
public function handle(WebsiteIntake $intake): void
|
||||
{
|
||||
$public = Storage::disk('media_public');
|
||||
|
||||
try {
|
||||
$files = $public->allFiles('cms');
|
||||
} catch (Throwable) {
|
||||
return;
|
||||
}
|
||||
|
||||
sort($files);
|
||||
|
||||
foreach ($files as $path) {
|
||||
if (! $this->isImage($path) || WebsiteMediaAlias::query()->where('legacy_path', $path)->exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$bytes = $public->get($path);
|
||||
|
||||
if (! is_string($bytes) || $bytes === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$hash = hash('sha256', $bytes);
|
||||
$twin = WebsiteMediaAlias::query()->where('sha256', $hash)->first();
|
||||
|
||||
if ($twin instanceof WebsiteMediaAlias) {
|
||||
WebsiteMediaAlias::query()->create(['legacy_path' => $path, 'content_element_id' => $twin->content_element_id, 'sha256' => $hash]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
Storage::disk('cms_incoming')->put($path, $bytes);
|
||||
$element = $intake->acceptImage($path, self::titleFor($path));
|
||||
WebsiteMediaAlias::query()->create(['legacy_path' => $path, 'content_element_id' => $element->id, 'sha256' => $hash]);
|
||||
}
|
||||
}
|
||||
|
||||
/** „cms/platzhalter-karte-1-liyjqa.jpg“ → „Platzhalter Karte 1“ (ohne die angehängte Zufallskennung). */
|
||||
public static function titleFor(string $path): string
|
||||
{
|
||||
$name = pathinfo($path, PATHINFO_FILENAME);
|
||||
$name = preg_replace('/-[a-z0-9]{6}$/', '', $name) ?? $name;
|
||||
$title = trim(str_replace(['-', '_'], ' ', $name));
|
||||
|
||||
return $title === '' ? 'Website-Bild' : Str::title($title);
|
||||
}
|
||||
|
||||
private function isImage(string $path): bool
|
||||
{
|
||||
return str_starts_with($path, 'cms/')
|
||||
&& ! str_contains($path, '..')
|
||||
&& preg_match('#^cms/[A-Za-z0-9._\-/]+$#', $path) === 1
|
||||
&& in_array(strtolower(pathinfo($path, PATHINFO_EXTENSION)), self::EXTENSIONS, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\IdentityChange;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class PublishWebsiteMedia implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public int $elementId,
|
||||
public string $action,
|
||||
public ?int $actorId = null,
|
||||
) {}
|
||||
|
||||
public function handle(WebsiteRelease $release): void
|
||||
{
|
||||
$element = ContentElement::query()->find($this->elementId);
|
||||
|
||||
if (! $element instanceof ContentElement || ! in_array($this->action, ['release', 'withdraw'], true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->action === 'withdraw') {
|
||||
$this->deletePublicFile($element);
|
||||
$this->mark($element, $element->website_released_at?->toIso8601String(), null);
|
||||
$element->forceFill([
|
||||
'website_released_at' => null,
|
||||
'website_public_path' => null,
|
||||
])->save();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$derived = $release->derivedPath($element);
|
||||
|
||||
if ($derived === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$target = $release->publicPath($element, $derived);
|
||||
$previous = $element->website_public_path;
|
||||
|
||||
Storage::disk('media_public')->put($target, Storage::disk('media_derived')->get($derived));
|
||||
|
||||
if (is_string($previous) && $previous !== $target && str_starts_with($previous, 'website/'.$element->id.'/')) {
|
||||
Storage::disk('media_public')->delete($previous);
|
||||
}
|
||||
|
||||
$this->mark($element, $element->website_released_at?->toIso8601String(), now()->toIso8601String());
|
||||
$element->forceFill([
|
||||
'website_released_at' => now(),
|
||||
'website_public_path' => $target,
|
||||
])->save();
|
||||
}
|
||||
|
||||
private function deletePublicFile(ContentElement $element): void
|
||||
{
|
||||
$path = $element->website_public_path;
|
||||
|
||||
if (! is_string($path) || ! str_starts_with($path, 'website/'.$element->id.'/') || str_contains($path, '..')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Storage::disk('media_public')->delete($path);
|
||||
}
|
||||
|
||||
private function mark(ContentElement $element, ?string $before, ?string $after): void
|
||||
{
|
||||
if ($before === $after) {
|
||||
return;
|
||||
}
|
||||
|
||||
IdentityChange::query()->create([
|
||||
'subject_type' => $element->getMorphClass(),
|
||||
'subject_id' => $element->id,
|
||||
'field' => 'website_released_at',
|
||||
'before' => $before,
|
||||
'after' => $after,
|
||||
'actor_id' => $this->actorId,
|
||||
'occurred_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\NavigationItem;
|
||||
use App\Domain\Cms\NavigationItemPolicy;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PagePolicy;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use App\Domain\Media\FfmpegFilmTranscoder;
|
||||
use App\Domain\Media\FilmTranscoder;
|
||||
@@ -23,6 +25,9 @@ class AppServiceProvider extends ServiceProvider
|
||||
public function register(): void
|
||||
{
|
||||
$this->app->bind(FilmTranscoder::class, FfmpegFilmTranscoder::class);
|
||||
// Je Anfrage einmal den Index der öffentlich genannten Medien bilden, nicht je Karte.
|
||||
$this->app->scoped(PublicMaterialReader::class);
|
||||
$this->app->scoped(WebsiteImage::class);
|
||||
$this->app->singleton(WidgetRegistry::class, fn ($app): WidgetRegistry => new WidgetRegistry(
|
||||
array_map(fn (string $class) => $app->make($class), config('cms.widgets', [])),
|
||||
));
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
use App\Domain\Cms\Widgets\Types\HeadingWidget;
|
||||
use App\Domain\Cms\Widgets\Types\HeroWidget;
|
||||
use App\Domain\Cms\Widgets\Types\ImageTextWidget;
|
||||
use App\Domain\Cms\Widgets\Types\MediaCardWidget;
|
||||
use App\Domain\Cms\Widgets\Types\ProgramCardWidget;
|
||||
use App\Domain\Cms\Widgets\Types\ProseWidget;
|
||||
use App\Domain\Cms\Widgets\Types\TopicCardWidget;
|
||||
|
||||
return [
|
||||
|
||||
@@ -24,6 +27,9 @@
|
||||
ImageTextWidget::class,
|
||||
CardsWidget::class,
|
||||
CatalogCardsWidget::class,
|
||||
TopicCardWidget::class,
|
||||
MediaCardWidget::class,
|
||||
ProgramCardWidget::class,
|
||||
CallToActionWidget::class,
|
||||
FaqWidget::class,
|
||||
],
|
||||
@@ -35,4 +41,13 @@
|
||||
'standard' => 'site.templates.standard',
|
||||
],
|
||||
|
||||
/*
|
||||
| Vorbereiteter Warenkorbzugang in der Kopfzeile. Der Warenkorb ist Teil des kommerziellen Anwendungssystems
|
||||
| und noch nicht umgesetzt; solange enabled false ist, erscheint kein Warenkorbsymbol.
|
||||
*/
|
||||
'cart' => [
|
||||
'enabled' => (bool) env('LUF_CART_ENABLED', false),
|
||||
'url' => env('LUF_CART_URL'),
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Ergänzend und abwärtskompatibel: Abschnitte mit Raster und Gestaltung liegen in einer neuen Spalte.
|
||||
* Die Spalte blocks bleibt bestehen und erhält bei jeder neuen Revision die Widgets in Lesereihenfolge,
|
||||
* damit ein Code-Rollback weiterhin alle Inhalte darstellt. Bestehende Revisionen bleiben unverändert (sections = null).
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('page_revisions', function (Blueprint $table) {
|
||||
$table->json('sections')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('page_revisions', function (Blueprint $table) {
|
||||
$table->dropColumn('sections');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Ergänzend und abwärtskompatibel: eine Ebene Untermenü für die Hauptnavigation.
|
||||
* Bestehende Einträge bleiben oberste Ebene (parent_id = null). Wird ein übergeordneter Eintrag gelöscht,
|
||||
* rücken seine Untereinträge in die oberste Ebene, statt mitgelöscht zu werden.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('navigation_items', function (Blueprint $table) {
|
||||
$table->foreignId('parent_id')->nullable()->constrained('navigation_items')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('navigation_items', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('parent_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('content_elements', function (Blueprint $table) {
|
||||
$table->text('website_credit')->nullable()->after('license_note');
|
||||
$table->string('website_alt')->nullable()->after('website_credit');
|
||||
$table->timestamp('website_released_at')->nullable()->after('website_alt');
|
||||
$table->string('website_public_path')->nullable()->after('website_released_at');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('content_elements', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'website_credit',
|
||||
'website_alt',
|
||||
'website_released_at',
|
||||
'website_public_path',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Zuordnung früherer CMS-Bildpfade (cms/…) zu Medien im Medienmanager. Additiv: Gespeicherte Revisionen und
|
||||
* die Dateien unter cms/ bleiben unverändert; die Zuordnung wird beim Darstellen gelesen.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('website_media_aliases', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('legacy_path')->unique();
|
||||
$table->foreignId('content_element_id')->constrained()->restrictOnDelete();
|
||||
$table->string('sha256', 64)->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('website_media_aliases');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use App\Jobs\ImportCmsImages;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Übernimmt die bisherigen CMS-Bilder (media_public, cms/…) in den Medienmanager. Die Migration läuft im
|
||||
* App-Container, der keine Medien schreibt; sie stößt deshalb nur den Job der Hintergrundverarbeitung an.
|
||||
* Der Job ist wiederholbar und löscht nichts.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// In Tests liegen echte Medien nicht vor; die Übernahme prüfen eigene Tests mit Testplatten.
|
||||
if (app()->runningUnitTests()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImportCmsImages::dispatch();
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Nichts zurückzunehmen: Die übernommenen Medien und Zuordnungen bleiben; die Tabelle entfernt die vorige Migration.
|
||||
}
|
||||
};
|
||||
|
After Width: | Height: | Size: 2.2 MiB |
|
After Width: | Height: | Size: 2.1 MiB |
|
After Width: | Height: | Size: 217 KiB |
|
After Width: | Height: | Size: 132 KiB |
|
After Width: | Height: | Size: 233 KiB |
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Lara & Felix – Designkonzept Bibliothek</title><meta name="robots" content="noindex,nofollow"><link rel="stylesheet" href="site.css"></head><body class="app-bg"><div class="apphead"><header class="top"><div class="nav wrap"><a class="brand" href="index.html" aria-label="Lara und Felix, Startseite">Lara & Felix<small>Stark im Alltag</small></a><nav class="links" aria-label="Hauptnavigation"><a href="index.html">Start</a><a href="bibliothek.html">Filme & Materialien</a><a href="player.html">Methodik</a><a class="btn outline" href="bibliothek.html">Anmelden</a><a class="btn green" href="bibliothek.html">Mitgliederbereich</a></nav></div></header></div><div class="appwrap"><aside class="side"><a href="index.html">⌂ Übersicht</a><a class="active" href="bibliothek.html">▦ Meine Bibliothek</a><a href="player.html">▷ Filme</a><a href="bibliothek.html">▤ Materialien</a><a href="bibliothek.html">♧ Berechtigungen</a></aside><main class="main"><div class="dash-head"><div><span class="flag">Mitgliederbereich · Layoutentwurf</span><h1>Meine Bibliothek</h1><p>Alles für die nächste Kursstunde an einem Ort.</p></div><div class="search" aria-label="Suche (nur Layoutkonzept)">⌕ Inhalte suchen …</div></div><div class="filters"><span class="filter on">Alle Inhalte</span><span class="filter">Filme</span><span class="filter">Übungen</span><span class="filter">Materialien</span><span class="filter">Programme</span></div><div class="library-grid"><article class="media-card"><a href="player.html"><div class="photo" style="background-image:url('assets/titel_original.webp')"><span class="type">Film</span></div></a><div class="body"><div class="small">DEMO · kein echter Artikel</div><h3>Film zur Erprobung</h3><p>Ein Film kann mit Übungen und Materialien verbunden sein.</p><span class="status">○ Zugang aus Berechtigung</span></div></article><article class="media-card"><a href="player.html"><div class="photo" style="background-image:url('assets/denkpause_original.webp')"><span class="type">Übung</span></div></a><div class="body"><div class="small">DEMO · kein echter Artikel</div><h3>Nachdenken und sprechen</h3><p>Das Material kann in mehreren Kompositionen genutzt werden.</p><span class="status">○ Zugang aus Berechtigung</span></div></article><article class="media-card"><a href="player.html"><div class="photo" style="background-image:url('assets/outro_original.webp')"><span class="type">Dokument</span></div></a><div class="body"><div class="small">DEMO · kein echter Artikel</div><h3>Begleitmaterial</h3><p>Trainerunterlagen erscheinen als eigenständige Medientypen.</p><span class="status">○ Zugang aus Berechtigung</span></div></article></div><div class="notice"><strong>Hinweis zur Lizenzansicht</strong><span>Ein Lizenzartikel soll einmal sichtbar sein, auch wenn mehrere Erwerbsquellen vorhanden sind. Einzelne Rechte bleiben getrennt prüfbar.</span></div></main></div></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Lara & Felix – Designkonzept Startseite</title><meta name="robots" content="noindex,nofollow"><link rel="stylesheet" href="site.css"></head><body><header class="top"><div class="nav wrap"><a class="brand" href="index.html" aria-label="Lara und Felix, Startseite">Lara & Felix<small>Stark im Alltag</small></a><nav class="links" aria-label="Hauptnavigation"><a href="index.html">Start</a><a href="bibliothek.html">Filme & Materialien</a><a href="player.html">Methodik</a><a class="btn outline" href="bibliothek.html">Anmelden</a><a class="btn green" href="bibliothek.html">Mitgliederbereich</a></nav></div></header><main><section class="hero"><div class="hero-picture" role="img" aria-label="Lara und Felix mit Serienlogo im sonnigen Park"></div><div class="hero-text wrap"><span class="flag">Für Trainer und pädagogische Fachkräfte</span><h1>Geschichten, die Kinder stärken.</h1><p>Filme und praxisnahe Materialien für Gewaltprävention, Selbstbehauptung und gemeinsame Gespräche.</p><div class="hero-actions"><a class="btn yellow" href="bibliothek.html">Materialien entdecken →</a><a class="btn outline" href="player.html">Unsere Methode</a></div><p class="hero-note">Gestaltungsvorschau – funktionale Angebote und Aussagen vor Veröffentlichung prüfen.</p></div></section><section class="section"><div class="wrap"><div class="intro-head"><div><span class="flag">Unser Ansatz</span><h2>Aus dem Alltag. Für den Alltag.</h2></div><p>Die Filme schaffen Gesprächsanlässe. Trainer gestalten daraus Übungen, Reflexion und gemeinsames Lernen.</p></div><div class="features"><div class="feature"><div class="sym">▣</div><h3>Geschichten erleben</h3><p>Anschauliche Situationen aus einer vertrauten Lebenswelt als Einstieg in den Kurs.</p></div><div class="feature"><div class="sym">?</div><h3>Gemeinsam nachdenken</h3><p>Bewusste Denkpausen geben Raum für Fragen, Gespräche und eigene Ideen.</p></div><div class="feature"><div class="sym">✓</div><h3>Handeln üben</h3><p>Begleitmaterial und Aufgaben helfen, das Gespräch praktisch fortzuführen.</p></div></div></div></section><section class="section offwhite"><div class="wrap"><div class="intro-head"><div><span class="flag">Einblicke</span><h2>Filme und Materialien</h2></div><p>Beispielhafte Darstellung möglicher Medientypen; keine realen Katalogangebote.</p></div><div class="card-grid"><article class="media-card"><div class="photo" style="background-image:url('assets/titel_original.webp')"><span class="type">Film · Beispiel</span></div><div class="body"><h3>Alltagssituation</h3><p>Videogestützte Einstiege in das gemeinsame Training.</p></div></article><article class="media-card"><div class="photo" style="background-image:url('assets/denkpause_original.webp')"><span class="type">Didaktik · Beispiel</span></div><div class="body"><h3>Denkpause</h3><p>Ein bewusstes Innehalten für Fragen und Austausch.</p></div></article><article class="media-card"><div class="photo" style="background-image:url('assets/outro_original.webp')"><span class="type">Material · Beispiel</span></div><div class="body"><h3>Trainermaterial</h3><p>Praktische Materialien können Filme ergänzen und verbinden.</p></div></article></div></div></section></main><footer class="foot"><div class="wrap"><div><strong>Lara & Felix</strong><small>Stark im Alltag · Designkonzept, keine Live-Webseite</small></div><p>Dieses UI-Kit verwendet konzeptionelle Texte und keine tatsächlichen Preise, Angebote oder Kundenangaben.</p></div></footer></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Lara & Felix – Designkonzept Kursplayer</title><meta name="robots" content="noindex,nofollow"><link rel="stylesheet" href="site.css"></head><body><header class="top"><div class="nav wrap"><a class="brand" href="index.html" aria-label="Lara und Felix, Startseite">Lara & Felix<small>Stark im Alltag</small></a><nav class="links" aria-label="Hauptnavigation"><a href="index.html">Start</a><a href="bibliothek.html">Filme & Materialien</a><a href="player.html">Methodik</a><a class="btn outline" href="bibliothek.html">Anmelden</a><a class="btn green" href="bibliothek.html">Mitgliederbereich</a></nav></div></header><main class="player-wrap"><div class="crumb">Meine Bibliothek / Film / Kursplayer</div><h1>Denkpause: Was würdet ihr tun?</h1><p class="sub">Gestaltungsvorschau · der Player ist nicht mit echten Medien oder Rechten verbunden.</p><div class="player" role="img" aria-label="Denkpause-Grafik mit Lara und Felix"><div class="still"></div><div class="player-controls"><span>❚❚</span><span>0:46</span><div class="progress"></div><span>2:00</span><span>⛶</span></div></div><div class="under-player"><section class="panel"><span class="flag">Didaktischer Moment</span><h3>Gespräch in der Gruppe</h3><p>Die Denkpause bietet einen natürlichen Moment, um mit den Kindern über Handlungsoptionen zu sprechen. Die tatsächliche Fortsetzung wird später im funktionalen Player eingebunden.</p><a class="btn green" href="bibliothek.html">Zur Bibliothek</a></section><section class="panel"><span class="flag">Trainermaterial</span><h3>Begleitende Unterlagen</h3><p>Trainerhinweise, Übungen und Arbeitsblätter werden an dieser Stelle aus der wirklichen Artikelkomposition geladen.</p><span class="pill">Layoutentwurf</span></section></div></main><footer class="foot"><div class="wrap"><div><strong>Lara & Felix</strong><small>Stark im Alltag · Designkonzept, keine Live-Webseite</small></div><p>Dieses UI-Kit verwendet konzeptionelle Texte und keine tatsächlichen Preise, Angebote oder Kundenangaben.</p></div></footer></body></html>
|
||||
|
After Width: | Height: | Size: 363 KiB |
|
After Width: | Height: | Size: 440 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 663 KiB |
|
After Width: | Height: | Size: 928 KiB |
|
After Width: | Height: | Size: 215 KiB |
@@ -0,0 +1,10 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@500;600;700;800;900&family=Nunito+Sans:wght@400;500;600;700;800&display=swap');
|
||||
:root {--navy:#032551;--navy2:#01244c;--green:#5B8625;--yellow:#FCD10A;--cream:#F7F6F2;--paper:#FBFBF7;--muted:#5D6A78;--line:#E0E9E0;--shadow:0 18px 45px rgba(3,37,81,.07)}
|
||||
*,*:before,*:after{box-sizing:border-box}body{margin:0;background:#FBFBF7;color:#162b45;font:16px/1.55 'Nunito Sans','Segoe UI',sans-serif}button,a{font:inherit}a{color:inherit;text-decoration:none}img{max-width:100%}h1,h2,h3{font-family:'Nunito','Trebuchet MS',sans-serif;line-height:1.15;letter-spacing:-.035em;color:var(--navy)}h1{font-size:clamp(34px,4vw,60px)}h2{font-size:clamp(25px,2.5vw,36px)}p{margin:0 0 1rem}.wrap{width:min(1180px,calc(100% - 56px));margin:auto}
|
||||
.top{background:white;border-bottom:1px solid #eef1eb;position:relative;z-index:10}.nav{height:82px;display:flex;align-items:center;justify-content:space-between;gap:28px}.brand{line-height:.92;color:var(--navy);font-family:'Nunito',sans-serif;font-weight:900;letter-spacing:-.05em;font-size:25px;transform:rotate(-1deg)}.brand>small{display:block;width:max-content;background:var(--green);font-size:11px;letter-spacing:0;color:white;padding:5px 11px;border-radius:20px;margin-top:5px}.brand:after{content:'';display:block;width:82%;height:5px;border-radius:90%;background:var(--yellow);transform:rotate(-2deg);margin-top:-25px;position:relative;top:-1px;z-index:-1}.links{display:flex;gap:28px;align-items:center;font-size:14px;font-weight:800;color:#19334c}.links a:focus-visible,.btn:focus-visible{outline:3px solid #1676ac;outline-offset:3px}.links a:not(.btn):hover{color:var(--green)}.btn{display:inline-flex;gap:8px;justify-content:center;align-items:center;border-radius:999px;padding:12px 21px;font-size:14px;font-weight:900;white-space:nowrap;border:1px solid transparent;transition:transform .18s,box-shadow .18s}.btn:hover{transform:translateY(-2px);box-shadow:0 8px 22px rgba(3,37,81,.15)}.btn.primary{background:var(--navy);color:white}.btn.green{background:var(--green);color:white}.btn.outline{background:white;color:var(--navy);border-color:#c8d5d6}.btn.yellow{background:var(--yellow);color:var(--navy)}
|
||||
.flag{font-size:11px;letter-spacing:.11em;text-transform:uppercase;font-weight:900;color:var(--green);display:inline-flex;align-items:center;gap:9px}.flag:before{content:'';width:26px;height:4px;background:var(--yellow);border-radius:4px}.hero{background:#f0f2e8;overflow:hidden}.hero-picture{position:relative;min-height:560px;background-image:url('assets/outro_original.webp');background-position:center;background-size:cover}.hero-text{position:absolute;left:52%;top:24%;max-width:520px;padding:10px}.hero-text h1{font-size:clamp(33px,4vw,61px);margin:10px 0 22px;letter-spacing:-.045em}.hero-text p{font-size:17px;max-width:420px}.hero-actions{display:flex;gap:12px;flex-wrap:wrap;margin-top:24px}.hero-note{font-size:12px;color:var(--muted);margin-top:20px}.section{padding:80px 0}.intro-head{display:flex;align-items:flex-end;justify-content:space-between;gap:30px;margin-bottom:29px}.intro-head h2{margin:8px 0 0}.intro-head>p{max-width:420px;color:var(--muted)}.features{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}.feature{background:white;border:1px solid var(--line);border-radius:22px;padding:28px;min-height:178px;box-shadow:var(--shadow)}.feature .sym{height:46px;width:46px;background:#e6f0dc;border-radius:14px;display:grid;place-items:center;font-size:23px}.feature h3{font-size:21px;margin:18px 0 7px}.feature p{color:var(--muted);font-size:14px}.offwhite{background:#F2F5ED}.card-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:18px}.media-card{background:white;border-radius:20px;overflow:hidden;box-shadow:var(--shadow);border:1px solid var(--line)}.media-card .photo{height:190px;background-size:cover;background-position:center;position:relative}.photo .type{position:absolute;bottom:13px;left:13px;background:#fff;border-radius:20px;padding:5px 10px;color:var(--navy);font-size:12px;font-weight:900}.media-card .body{padding:20px}.media-card h3{margin:0 0 10px;font-size:20px}.media-card p{font-size:14px;color:var(--muted);margin:0}.pill{display:inline-block;background:#eaf1e3;color:#365e1d;padding:6px 11px;border-radius:25px;font-size:12px;font-weight:900}.foot{background:var(--navy);color:#d3e2ed;padding:45px 0}.foot .wrap{display:flex;justify-content:space-between;gap:25px;align-items:center}.foot p{font-size:13px;margin:0}.foot strong{font-family:Nunito,sans-serif;color:white;font-size:21px}.foot small{display:block;color:#c0d7e3}
|
||||
/* library */.app-bg{background:#f4f7f4;min-height:100vh}.apphead{background:white;border-bottom:1px solid #e4e8e6}.appwrap{max-width:1260px;margin:auto;display:grid;grid-template-columns:210px 1fr;min-height:calc(100vh - 82px)}.side{padding:36px 18px 30px;border-right:1px solid #e1e9e8}.side a{display:block;margin:7px 0;padding:11px 14px;border-radius:12px;font-weight:800;font-size:14px}.side a.active{background:#e4efe4;color:var(--green)}.main{padding:37px 40px 70px}.dash-head{display:flex;align-items:flex-end;justify-content:space-between;gap:20px}.dash-head h1{font-size:39px;margin:8px 0}.dash-head p{color:var(--muted)}.search{background:white;border:1px solid #d7e2e0;border-radius:100px;min-width:280px;padding:12px 18px;color:#8995a0;font-size:14px}.filters{display:flex;gap:8px;margin:26px 0 24px;flex-wrap:wrap}.filter{background:white;border:1px solid #dde7e3;border-radius:20px;padding:8px 15px;font-weight:800;font-size:12px}.filter.on{background:var(--navy);color:white}.library-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:18px}.library-grid .photo{height:158px}.media-card .small{color:#55707d;font-weight:700;font-size:12px}.media-card .status{margin-top:15px;display:inline-block;color:#376f1c;background:#edf5e8;padding:6px 10px;border-radius:20px;font-size:12px;font-weight:900}.notice{margin-top:30px;padding:19px 23px;border-radius:18px;background:#e8f0de;display:flex;gap:15px;align-items:center;font-size:14px;color:#35532a}.notice strong{color:#254316}
|
||||
/* player */.player-wrap{max-width:1060px;margin:50px auto 100px;padding:0 28px}.crumb{font-size:13px;font-weight:800;color:#6b7d86}.player-wrap h1{font-size:38px;margin:16px 0 10px}.player-wrap .sub{color:var(--muted);margin-bottom:25px}.player{position:relative;aspect-ratio:16/9;background:var(--navy);border-radius:24px;overflow:hidden;box-shadow:0 20px 56px rgba(3,37,81,.15)}.player .still{position:absolute;inset:0;background:url('assets/denkpause_original.webp') center/cover}.player:after{content:'';position:absolute;inset:65% 0 0;background:linear-gradient(transparent,rgba(3,37,81,.45));pointer-events:none}.player-controls{position:absolute;bottom:18px;left:25px;right:25px;display:flex;align-items:center;gap:15px;z-index:1;color:white;font-weight:800}.progress{height:6px;background:#ffffff78;border-radius:6px;flex:1}.progress:before{content:'';display:block;width:41%;height:100%;background:var(--yellow);border-radius:6px}.under-player{display:grid;grid-template-columns:1.5fr 1fr;gap:18px;margin-top:22px}.panel{padding:28px;background:white;border:1px solid var(--line);border-radius:20px}.panel h3{margin:0 0 12px;font-size:20px}.panel p{font-size:14px;color:var(--muted)}
|
||||
@media (max-width:980px){.nav{height:74px}.links a:not(.btn){display:none}.hero-picture{min-height:500px;background-position:40% center}.hero-text{left:52%;top:19%;max-width:400px}.hero-text h1{font-size:39px}.features,.card-grid,.library-grid{grid-template-columns:repeat(2,1fr)}.appwrap{grid-template-columns:170px 1fr}.main{padding:24px}.under-player{grid-template-columns:1fr}}
|
||||
@media (max-width:680px){.wrap{width:min(100% - 32px,560px)}.brand{font-size:22px}.brand>small{font-size:10px}.links{gap:7px}.links a.btn:first-of-type{display:none}.links a.btn{padding:9px 13px;font-size:12px}.hero-picture{min-height:0;aspect-ratio:1.4/1;background-size:cover;background-position:17% center}.hero-text{position:static;background:#fbfbf7;padding:27px 18px 40px;max-width:none}.hero-text h1{font-size:36px}.hero-text p{font-size:15px}.hero-actions{gap:9px}.hero-note{margin-top:15px}.section{padding:48px 0}.intro-head{display:block}.features,.card-grid,.library-grid{grid-template-columns:1fr}.feature{min-height:auto}.media-card .photo{height:210px}.foot .wrap{display:block}.foot p{margin-top:10px}.appwrap{display:block}.side{display:flex;overflow:auto;padding:10px 16px;gap:5px;border-right:0;border-bottom:1px solid #e1e9e8}.side a{white-space:nowrap}.main{padding:30px 16px}.dash-head{display:block}.dash-head h1{font-size:32px}.search{width:100%;margin-top:18px}.library-grid .photo{height:190px}.player-wrap{margin:25px auto 70px;padding:0 16px}.player-wrap h1{font-size:28px}.player{border-radius:14px}.player-controls{bottom:10px;left:10px;right:10px;font-size:10px;gap:5px}.panel{padding:20px}}
|
||||
@media(prefers-reduced-motion: reduce){*,*:before,*:after{scroll-behavior:auto!important;transition:none!important;animation:none!important}}
|
||||
@@ -0,0 +1,165 @@
|
||||
# Abschlussbericht: MVP-Beauftragung Mitgliederbibliothek
|
||||
|
||||
**Stand:** 16.11.2026
|
||||
**Branch:** `develop`, Commit `30833f6`
|
||||
**Testinstanz:** `luf-test` auf `llm-node`, Port 3011, Image `luf-app-test:30833f62a1e1` und `luf-web-test:30833f62a1e1`
|
||||
**Grundlage:** `docs/analysen/umsetzungsplan-mitgliederbibliothek.md`, Verträge G1–G9, Ergänzung E-W12, die beiden Zusatzaufträge UX/UI des Mitgliederbereichs und fachliche Inhaltsverwaltung
|
||||
|
||||
Dieser Bericht schließt die Beauftragung ab. Er ist keine kommerzielle Freigabe. Der Plan macht Tor B zur Abnahme der Pakete 1 bis 8. Dieser Lauf ist nicht ausgeführt.
|
||||
|
||||
`docs/betrieb/MVP-Stand.md` beschreibt eine frühere Scheibe und ist durch diesen Bericht überholt.
|
||||
|
||||
## Auftrag
|
||||
|
||||
Umgesetzt werden sollten die Pakete 1 bis 9 des Umsetzungsplans, die Verträge G1 bis G9 und die didaktischen Metadaten E-W12. Gearbeitet wurde auf `develop`. Ein Push dorthin deployt die Testinstanz. Produktion und `main` wurden nicht angefasst.
|
||||
|
||||
Zwei Zusatzaufträge gehören dazu:
|
||||
|
||||
1. **Mitgliederbereich.** Der Kursraum für erwachsene Trainer folgt der vorgesehenen Gliederung und den vorhandenen Gestaltungsprinzipien. Nicht freigegebene Markenwerte bleiben austauschbare Tokens. Die Fläche darf nicht wie ein umbenanntes Filament aussehen. Geprüft wird in den Breiten 390, 768 und 1440 Pixel.
|
||||
2. **Fachliche Inhaltsverwaltung.** Eine Person ohne technischen Hintergrund legt in der vorhandenen Verwaltung Medien und Dokumente an, beschreibt und ordnet sie, führt Fassungen, baut Module und Programme mit Lernziel, Zeit, Material und geordneten Bestandteilen, sucht vorhandene Inhalte einschließlich einer konkreten Fassung, ändert Rolle, Reihenfolge und Verschachtelung, sieht die Verwendung, unterscheidet Entwurf, technische Bereitschaft, Anzeigefreigabe und historische Fassungen, prüft die Struktur und gibt sie frei, hängt Lizenzartikel und Angebote an und nutzt die Abdeckungsprüfung. Die Beschriftung ist fachlich. Der Nachweis läuft durch die Oberfläche, nicht durch Seeder oder SQL.
|
||||
|
||||
Bewusst außerhalb bleiben Denkpause, Ablaufsteuerung, Präsentationsmodus, Fortschritt, zweites Gerät, Community, echter Zahlungsdienst, Organisationslizenzen, konkrete Preise, die Marketingstrecke M1–M3, ein Neubau der öffentlichen Website und der Editor-Prototyp W-P als zweites CMS. W-P bleibt der dokumentierte Wegwerfstand auf `feature/w-p-editor-prototype` (`docs/analysen/wp-editor-prototyp-2026-03-15.md`).
|
||||
|
||||
## Ergebnis in einem Satz
|
||||
|
||||
Die Pakete 1 bis 8, E-W12 und beide Zusatzaufträge sind im Code, in der Suite und auf der Testinstanz vorhanden und am Trainingsprogramm **Programm Abstand** durch die Oberfläche benutzbar. Die geplante Abschlussprüfung Tor B und drei eng umrissene Paketpunkte sind offen.
|
||||
|
||||
## Prüfstand
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Suite vor dem letzten Push | 76 Tests, 406 Zusicherungen, grün |
|
||||
| Gate | `scripts/ci-test.sh`: Pint und `php artisan test` in einem Wegwerf-Container |
|
||||
| Instanz | `http://192.168.2.144:3011/up` antwortet 200 |
|
||||
| Medien | NFS `/srv/luf/test/media`. Der Web-Prozess schreibt die Ableitungen nicht. Die Queue schreibt Vorschaubilder und HLS nach `derived/`. |
|
||||
| Demokatalog | Der Deploy legt ihn nicht mehr an. Der vorherige grüne Deploy hatte ihn einmal neu erzeugt. Diese Zeilen sind auf der Testinstanz wieder entfernt. |
|
||||
|
||||
Der erste Push der Medienableitung (`c997eb5`) ist am Image-Bau gescheitert, weil die Lockdatei mit einer neueren npm-Version geschrieben war als im Image. `295f784` gleicht die Lockdatei mit npm 10.9.9 ab. Danach sind die Images durchgelaufen.
|
||||
|
||||
## Pakete
|
||||
|
||||
| Paket | Stand | Was vorliegt |
|
||||
|---|---|---|
|
||||
| 0 Befund | erledigt, historisch | `docs/analysen/befund-paket-0-testinstanz-2026-03-15.md`. Zum Zeitpunkt des Befunds keine doppelte aktive Angebotsfassung. Der heutige Testbestand ist der Abstand-Graph nach der freigegebenen Löschung der alten Testzeilen. Produktion wurde nicht gelesen. |
|
||||
| 1 Angebotsfassung | umgesetzt | Eine Aktivierung beendet die bisher aktive Fassung desselben Angebots. Registrierung und Kauf lesen eine aktive Fassung. Neue Bestellzeilen speichern die Bezeichnung. Parallelität ist durch einen Test abgedeckt. |
|
||||
| 2 Inhaltsart | umgesetzt | `CompositionKind` bleibt `kurs`, `uebung`, `kombination`. Die Inhaltsart ist eine eigene Achse mit den Werten Programm, Modul, Merkblatt und Traineranleitung. Die Erklärung des Enums enthält weiterhin „Ein Kurs ist keine Übung“. |
|
||||
| 3 Bibliothek | umgesetzt | G1 liest eine ausdrücklich angegebene Fassung unabhängig von der Anzeigefreigabe. G2 gibt Fassungen zur Anzeige frei und nimmt sie zurück. Die Bibliothek zeigt Programme, Module und Material. Teilrechte bleiben sichtbar, nicht getragene Blätter haben keine Datei. `DecideAccess` entscheidet je Abruf. Zwei Grants werden nicht vereinigt. |
|
||||
| 4 Stammdaten | umgesetzt | Anzeigetitel und Kurzbeschreibung liegen an der Identität, mit Protokoll. Sie erzeugen keine neue Lehrfassung. Die Bibliothek liest sie, sobald sie gefüllt sind. |
|
||||
| 5 Dimensionen und Filter | umgesetzt | Dimensionen sind pflegbar. Die fünf Säulen sind Startwerte und bleiben als Spalten erhalten. Direkte Zuordnung an Kompositionen ist von abgeleiteten Themen getrennt. Die Bibliothek sucht und filtert. Eine Säule vergibt keine Berechtigung. |
|
||||
| 6 Vorschaubilder | umgesetzt, mit einer Lücke | Bild an Medium und Zusammenstellung, Alternativtext, Platzhalter, keine öffentliche Route, keine neue Inhaltsfassung. Ein Film liefert ein Bild aus dem ersten Frame. Eine wählbare Zeitposition fehlt. |
|
||||
| 7 Vorschau und Abdeckung | umgesetzt | Die Maske zeigt die Verwendung. Die Redaktion sieht denselben Baum wie das Mitglied. Eine Aktivierung nennt fehlende Blätter und nimmt ein ungedecktes Programm nicht still auf. |
|
||||
| 8 Medienausgabe | umgesetzt, in der vereinbarten Ehrlichkeit | Drei HLS-Stufen, signierte Playlists und Segmente, Nachweis je Ausgabe mit Kopiennummer, Prüfsumme und Kennzeichnung. Ohne Streamrecht keine Variante, ohne Laderecht keine Quelldatei. Eine schon gespeicherte Datei bleibt lesbar, bis eine Ableitung existiert. Texte im Leser tragen die sichtbare Lizenzzeile. Dateibytes von Film und PDF werden nicht gestempelt. |
|
||||
| 9 Tor A / Tor B | nicht bestanden | Die lokale Suite und ein Durchlauf des Abstand-Programms ersetzen den verlangten HTTP-Lauf gegen die Testinstanz nicht. Eine wiederholbare Instanz-Suite (G9) ist nicht angelegt. |
|
||||
|
||||
## Verträge
|
||||
|
||||
| Vertrag | Stand |
|
||||
|---|---|
|
||||
| G1 Strukturleser | eine Klasse neben `ContentResolver`, ohne Person und ohne Berechtigung |
|
||||
| G2 Anzeigefreigabe | je Kompositionsfassung, mit Bearbeiter und Zeitpunkt, unabhängig von `bereit` |
|
||||
| G3 Inhaltsart | konfigurierbare Werte, setzen ändert `kind` und `output_class` nicht |
|
||||
| G4 Anzeigefelder | ein Titel und eine Kurzbeschreibung für die Bibliothek, mit Protokoll |
|
||||
| G5 Dimensionen | stabile Kennungen, Säulen behalten ihre Identität, direkt und abgeleitet bleiben unterscheidbar |
|
||||
| G6 Bildableitung | ein Queue-Auftrag, geschützte Ablage unter `vorschau/` |
|
||||
| G7 Abdeckungsbefund | lesbar vor der Aktivierung |
|
||||
| G8 aktive Angebotsfassung | eine aktive Fassung, bei Alt-Dubletten die höchste Nummer |
|
||||
| G9 Instanz-Suite | nicht gebaut |
|
||||
| E-W12 | Lernziel, Zeitbedarf und Materialbedarf an der Kompositionsfassung; eine Änderung erzeugt eine neue Fassung |
|
||||
|
||||
## Zusatz 1: Mitgliederbereich
|
||||
|
||||
Der Kursraum ist eine eigene Oberfläche, nicht die Verwaltungsoptik. Überschriften, Suche, Säulenfilter, Verfügbarkeit und die Karten sprechen von Programmen, Modulen und Material. Die untere Navigation führt zu Bibliothek, Programmen, Modulen, Material und Lizenzen.
|
||||
|
||||
Die Gestaltung wurde auf der Testinstanz in 390, 768 und 1440 Pixel geprüft. Nach dem Player-Fix wurde die Seite von Programm Abstand erneut bei 390 Pixel geprüft: kein horizontaler Überlauf, der Film lädt. Markenwerte, die nicht freigegeben sind, wurden nicht erfunden. Die Programmkarte zeigt den Platzhalter, weil für dieses Programm kein eigenes Vorschaubild hochgeladen wurde. Das abgeleitete Bild von „Lara im Park“ liegt am Medium.
|
||||
|
||||
## Zusatz 2: Fachliche Inhaltsverwaltung
|
||||
|
||||
Die Redaktion arbeitet weiter unter `/verwaltung`. Die Navigation heißt Medien, Fachliche Kombinationen, Module, Programme, Fachliche Säulen, Lizenzartikel, Pakete, Rechteprofile und Angebote. Die Programmliste erklärt: „Ein Programm aus Modulen und weiteren Inhalten.“ Die gespeicherte Art bleibt Kurs, Übung oder Kombination. Die Maske nennt das Feld Zusammenstellung.
|
||||
|
||||
Auf der Testinstanz wurde der folgende Weg durch die Oberfläche angelegt und danach erneut geöffnet:
|
||||
|
||||
| Schritt | Ergebnis |
|
||||
|---|---|
|
||||
| Trainerunterlage Abstand | Text, Fassung 1: „Im Kurs zuerst den Abstand ansprechen, dann das Blatt austeilen.“ |
|
||||
| Modul Abstand | Unterlage plus Film „Lara im Park“, Fassung 1, Lernziel, 15 Minuten, zur Anzeige freigegeben |
|
||||
| Modul Hilfe | dieselbe Unterlage, Fassung 1, Lernziel, 10 Minuten, freigegeben |
|
||||
| Programm Abstand | beide Module in dieser Reihenfolge, Lernziel, 25 Minuten, Gliederung sichtbar, freigegeben |
|
||||
| Lizenzartikel | `abstand-trainer`, Stand 1, Wurzel ist die Programmfassung |
|
||||
| Rechteprofil | „Abstand ansehen“: Film streamen, Dokument ansehen, Text ansehen |
|
||||
| Angebot | Testangebot Abstand, auf Abruf, Abdeckung gegen die Programmfassung |
|
||||
| Trainer | Abruf in die Bibliothek, Programm nutzbar |
|
||||
|
||||
Ein neues Vorschaubild an einer Zusammenstellung geht über die Queue nach `derived/vorschau/` und erzeugt keine neue Fassung.
|
||||
|
||||
## Was auf der Testinstanz geprüft wurde
|
||||
|
||||
Angemeldet als Prüftrainer:
|
||||
|
||||
- Die Bibliothek zeigt nur Programm Abstand, Status Nutzbar.
|
||||
- Die Programmseite zeigt Lernziel, beide Module, die Unterlage und den Film.
|
||||
- Der Film spielt über hls.js. Bild 854×480, Wiedergabe bereit. Die Master-Playlist verweist auf die Stufen 480, 720 und 1080. Die Signatur gilt für diese Ausgabe.
|
||||
- Die Unterlage zeigt den Text, die Zeile „Lizenziert für …“ mit Lizenzkopie und die Kennzeichnung „ehrenamtlich“.
|
||||
|
||||
Angemeldet in der Verwaltung:
|
||||
|
||||
- Die Programmliste enthält nur Programm Abstand und den fachlichen Erklärungssatz.
|
||||
|
||||
Die Ableitung von „Lara im Park“ wurde nach dem Deploy in die Queue gegeben. Vorschaubild und die vier Playlist-Zeilen (480, 720, 1080, Master) liegen vor. Der Auftrag ist ohne Fehlereintrag durchgelaufen. Die Quelldatei bleibt unter `derived/` liegen.
|
||||
|
||||
## Offen gegenüber dem Plan
|
||||
|
||||
Tor B ist nicht bestanden. Der Plan verlangt auf der Testinstanz, vollständig und nicht nur soweit die Suite es an Wegwerfdaten zeigt:
|
||||
|
||||
- zwei freigegebene Programme, gemeinsamer Film, gemeinsames PDF, unterschiedliche Rollen
|
||||
- eine nur bereite Programmfassung mit demselben Film bleibt unsichtbar
|
||||
- eine Person mit nur einem Modul, eine mit allen Teilen über getrennte Artikel, eine ohne Grant
|
||||
- Stream nur für die berechtigte Person; Laden des Films scheitert ohne dieses Recht
|
||||
- Ansehen und Laden eines PDF sind getrennt
|
||||
- das teilweise Programm ist gekennzeichnet; das vollständige Programm erzeugt keinen zusätzlichen Erwerb
|
||||
- die Materialliste zeigt das gemeinsame PDF einmal
|
||||
- Umbenennung ohne neue Fassung, die gespeicherte Bestellbezeichnung bleibt
|
||||
- Filter und direkte Themen an Modul und Programm
|
||||
- Thumbnail nicht über die öffentliche Route
|
||||
- Abdeckungsverweigerung und dieselbe Struktur in der Vorschau
|
||||
- genau eine aktive Angebotsfassung, auch im Parallelfall
|
||||
|
||||
Diese Fälle sind in der lokalen Suite einzeln vorhanden. Auf der Instanz liegt ein Programm, eine Textunterlage und ein Film. Eine PDF-Datei im Testmedienbestand fehlt. Eine wiederholbare HTTP-Suite gegen `luf-test` fehlt.
|
||||
|
||||
Weitere Lücken im Pakettext:
|
||||
|
||||
- Vorschaubild eines Films: erstes Bild, keine wählbare Zeitposition und keine Vorschau genau dieser Position.
|
||||
- Originale liegen nicht getrennt unter `originals/`. Neue und vorhandene Dateien bleiben in `derived/`. Die Kennzeichnung hängt daran nicht.
|
||||
|
||||
## Zurückgestellt
|
||||
|
||||
Automatische Denkpause, Ablaufsteuerung, Präsentationsmodus, Fortschritt, zweites Gerät. `decision_seconds` bleibt gespeichert und steuert die Bibliothek nicht.
|
||||
|
||||
Organisationslizenzen, Community, echter Zahlungsdienst, kundeneigene Paketkonfiguratoren, konkrete Preise und Tarife. Der Testkaufpreis aus dem früheren Demokatalog ist keine Preisentscheidung; dieser Katalog ist auf der Testinstanz entfernt.
|
||||
|
||||
Designsystem, öffentliche Objektseiten und der Neubau des CMS. Die vorhandenen öffentlichen Seiten und die veröffentlichten Säulen unter `/themen` bleiben. W-P wird nicht in die Verwaltung übernommen.
|
||||
|
||||
## Zugang zur Prüfung
|
||||
|
||||
Nur die Testinstanz, Adresse `http://192.168.2.144:3011`.
|
||||
|
||||
- Trainer: `/anmelden`, Konto `trainer-pruefung@example.test`, das bereits mitgeteilte Prüfkennwort. Bibliothek, Programm Abstand, Film und Unterlage.
|
||||
- Redaktion: `/verwaltung`, Konto `redaktion-pruefung@example.test`, das bereits mitgeteilte Prüfkennwort und der bestehende Authenticator. Rollen Redaktion und Katalog.
|
||||
|
||||
## Commits auf `develop`, die diesen Stand tragen
|
||||
|
||||
| Commit | Inhalt |
|
||||
|---|---|
|
||||
| `7820bec` | Paket 1 |
|
||||
| `1a2b129` | Paket 2 |
|
||||
| `5ed01b9`, `fc08e6d`, `7b54c38` | Paket 3, Bibliothek, Anzeigefreigabe |
|
||||
| `5e763d1` | Pakete 4 bis 7 und der Ausgabenachweis |
|
||||
| `c99a957` | Nutzbarkeit, Didaktik, öffentliche Programmfassung |
|
||||
| `1d8315c`, `9b52181` | Kursraum |
|
||||
| `d6ff881` | fachliche Inhaltsverwaltung |
|
||||
| `c997eb5`, `295f784` | geschützte Vorschaubilder und Filmstufen |
|
||||
| `57802df` | Programmvorschau über die Queue, kein erneutes Seeden |
|
||||
| `30833f6` | HLS über hls.js, wenn der Browser die Fähigkeit nur behauptet |
|
||||
|
||||
## Empfehlung
|
||||
|
||||
Die fachliche Erprobung des Abstand-Programms kann sofort auf der Testinstanz stattfinden. Eine Aussage „MVP abgenommen“ oder „kommerziell freigegeben“ setzt den fehlenden Tor-B-Lauf voraus, einschließlich einer echten PDF-Datei und der zweiten Programmfassung mit getrennten Personen.
|
||||
@@ -0,0 +1,315 @@
|
||||
# Abschlussbericht: Adaptive Widgets und Premium-Design v1.6
|
||||
|
||||
Stand: 18.11.2026.
|
||||
- Branch: `feature/adaptive-widgets`, abgezweigt vom Stand `feature/design-iteration-1` einschließlich der beiden Doku-Commits von Lars.
|
||||
- Per Fast-Forward auf `develop` übernommen und über `deploy-test.yml` auf der Testinstanz bereitgestellt.
|
||||
- **Kein Merge nach `main`.** `develop` liegt 73 Commits vor `main`.
|
||||
|
||||
| Schritt | Stand |
|
||||
|---|---|
|
||||
| Commit Umsetzung | `0bfb534` |
|
||||
| CI Feature-Branch | Lauf 4834 grün |
|
||||
| Deploy Testinstanz | Lauf 4835 erfolgreich, `/up` 200 |
|
||||
| Bericht | dieser Commit |
|
||||
|
||||
Entscheidung: ADR-38 im zentralen Protokoll. Technische Dokumentation:
|
||||
- `docs/architektur/cms-widget-registry.md` §§2–4, 8, 9, 12
|
||||
- `docs/architektur/designsystem.md` §13
|
||||
|
||||
## 1. Grundlage und Abweichungen vom Kit
|
||||
|
||||
Grundlage war der Repository-Stand `docs/Brand-UI-Kit/12_premium_widgets_adaptiv_v1.6`: Komponenten, CSS, `layout-profiles.json`, Registry-Hinweise, Beispiele und Referenzscreenshots. Die Ordner 07–12 sind im Repository nicht versioniert (untracked). Übernommen wurden Code und CSS, angepasst an die tatsächliche Struktur. Die Kit-Ordner selbst wurden nicht eingecheckt.
|
||||
|
||||
| Kit v1.6 | Umsetzung | Grund |
|
||||
|---|---|---|
|
||||
| Kennungen `lf-brand-hero`, `lf-editorial-bild-text` | bestehende Kennungen `hero` und `image_text` als kompatible Weiterentwicklung | Kennungen und Revisionen bleiben erhalten |
|
||||
| Varianten `photo-split`, `editorial-solid` | `photo_split`, `editorial_solid` | Variantenkennungen der Registry: `^[a-z][a-z0-9_]*$` |
|
||||
| `settings.image_side` | Variante `image_left` / `image_right` | keine doppelte Einstellung |
|
||||
| `settings.image_focus {x,y}` | `data.focus_x`, `data.focus_y` (0–100) | `settings` trägt nur Aufzählungswerte |
|
||||
| Überschriftenebene H1/H2/H3 frei | „Automatisch“ (erstes Widget der Seite = H1), H2, H3 | Regel „genau eine H1 je Seite“; Widerspruch nicht still aufgelöst, sondern dokumentiert |
|
||||
| Linkziele nur `https`, Pfad, Anker | bestehende `SafeUrl`-Regel (zusätzlich `http`) | Repository-Regel gilt |
|
||||
| Einstiegsbild immer sofort laden | nur das erste Widget der Seite sofort, alle anderen verzögert | bestehende Ladeprioritäten |
|
||||
| CSS v1.6 | übernommen nach `resources/css/components/lf-hero.css` und `lf-bild-text.css` | zusätzlich: Überschriften erben Farbe (globale h1–h3-Regeln), Unterstreichung als Block, Fläche „clear“ übernimmt die Farben dunkler Abschnitte, Strahlen-Akzent, Fokusfarbe aus den Tokens |
|
||||
|
||||
Das frühere Hero- und Bild-und-Text-CSS sowie der Randlos-Mechanismus der Designiteration 1 sind entfernt. Es laden keine alten und neuen Stylesheets parallel.
|
||||
|
||||
## 2. Gemeinsamer Layoutmechanismus (ADR-38)
|
||||
|
||||
In der bestehenden Registry (`WidgetType`) erklärt jede Art:
|
||||
- **zulässige Rasterbreiten** (`supportedUnits()`); die Mindestbreite ist daraus abgeleitet;
|
||||
- **Höhen** aus einem gemeinsamen Vokabular (`auto`, `compact`, `normal`, `large`, `spacious`, `fill`). Sie werden als `settings.height` gespeichert und wie jede Einstellung geprüft;
|
||||
- **Darstellungsmodi** (`stages()`) und das **Verhalten bei wenig Platz** (`narrowBehavior()`).
|
||||
|
||||
Wirkung:
|
||||
- Ein Platz mit nicht unterstützter Breite wird beim Speichern abgewiesen: „… ist für Plätze mit 3 oder 4 Rastereinheiten vorgesehen; dieser Platz hat 2“.
|
||||
- Der Platzkopf im Editor warnt vorher, und die Widget-Auswahl nennt die zulässigen Breiten.
|
||||
- Die Höhe erscheint als Klasse `widget-height-*` an der Hülle.
|
||||
- Die Ansichten reagieren über Container-Abfragen auf die tatsächliche Breite.
|
||||
- Es gibt keine zweite Registry, kein zweites Abschnittsmodell und keine Migration.
|
||||
|
||||
| Widget | Breiten | Höhen |
|
||||
|---|---|---|
|
||||
| Einstieg (Hero) | 3, 4 | compact (mind. 400 px), normal (512 px), large (640 px) |
|
||||
| Bild und Text | 1–4 | compact, normal, spacious |
|
||||
| Handlungsaufruf | 1–4 | auto, fill (gleich hoch wie die Nachbarplätze) |
|
||||
| Überschrift, Fließtext, Karten, Programmkarten | 1–4 | – (nach Inhalt) |
|
||||
| FAQ | 2–4 | – |
|
||||
|
||||
Die Gestaltung der Bestandswidgets bleibt unverändert. Für schmale Plätze kamen hinzu:
|
||||
- Umbruch langer Wörter und Adressen;
|
||||
- Schaltflächen mit `overflow-wrap`, `max-width: 100 %` und mittig ausgerichtetem Text.
|
||||
|
||||
## 3. Premium-Widgets
|
||||
|
||||
**Einstieg (`hero` Version 2):**
|
||||
- Varianten „Foto mit Textfläche“ und „Markenfläche“.
|
||||
- Drei Höhen, Label, Überschrift und Ebene, Beschreibung, Bild aus dem öffentlichen Medienbereich (Auswahl oder Hochladen).
|
||||
- Bildfokus (zwei Schieberegler) und Alternativtext.
|
||||
- Zwei Schaltflächen und ein Akzent: Unterstreichung, Unterstreichung mit Signalstrahlen oder keiner.
|
||||
- Ab 860 px Containerbreite die Komposition aus dem Kit, darunter der technische Sicherheitsumbruch (Foto 16:9 über dem Text).
|
||||
|
||||
**Bild und Text (`image_text` Version 3):**
|
||||
- Fläche creme, ohne eigene Fläche oder navy.
|
||||
- Bild links oder rechts, drei Höhen, Label, Überschrift und Ebene.
|
||||
- Formatierter Text (bereinigt), Bild, Fokus, Alternativtext, zwei Schaltflächen.
|
||||
- Darstellung nach Containerbreite:
|
||||
|
||||
| Containerbreite | Darstellung |
|
||||
|---|---|
|
||||
| unter 540 px | gestapelt |
|
||||
| 540–899 px | flacher Bildstreifen |
|
||||
| ab 900 px | zweispaltig |
|
||||
|
||||
Die Grenzwerte aus dem Kit haben sich im CMS bewährt und sind unverändert.
|
||||
|
||||
**Bestehende Daten:**
|
||||
- `hero` Version 1 wird beim Lesen angehoben: `standard`/`stage` → `photo_split`, `highlight`/`editorial` → `editorial_solid`. Der Fokuspunkt wird in Prozent umgerechnet, und nicht mehr vorhandene Einstellungen entfallen.
|
||||
- `image_text` Version 2 wird ebenso angehoben: Bildformat entfällt, Fokus in Prozent.
|
||||
- Gespeicherte Revisionen bleiben unverändert. Die data-Schlüssel sind gleich geblieben, damit ein Code-Rollback darstellbar bleibt (siehe `cms-widget-registry.md` §9).
|
||||
|
||||
## 4. Editor
|
||||
|
||||
- **Bearbeitungsdialog:** Reiter **Inhalt**, **Medien** und **Darstellung**, generisch aus der Registry.
|
||||
- Varianten und Höhen sind Auswahlknöpfe mit Symbol.
|
||||
- Der Bildfokus wird mit Schiebereglern eingestellt.
|
||||
- Weitere Darstellungsparameter sind Auswahllisten mit dem Hinweis „Vorgabe der Darstellung“.
|
||||
- Der Reiter Darstellung nennt die zulässigen Platzbreiten und das Verhalten bei wenig Platz.
|
||||
- **Live-Vorschau im Dialog:**
|
||||
- Derselbe Renderer wie die Website, in wählbarer Platzbreite: Smartphone 390 px oder die zulässigen Einheiten mit 310, 640, 960 bzw. 1300 px.
|
||||
- Verkleinert auf die Dialogbreite; Änderungen erscheinen sofort.
|
||||
- **Abschnitts- und Widget-Einstellungen sind getrennt:**
|
||||
- Abschnitt: Raster, Hintergrund, Breite, Abstand, Trenner.
|
||||
- Widget: Anordnung, Fläche, Höhe, Bild, Fokus, Texte, Schaltflächen, Akzent.
|
||||
|
||||
## 5. Tests und praktische Abnahme
|
||||
|
||||
| Prüfung | Ergebnis |
|
||||
|---|---|
|
||||
| `php artisan test` | 199 Tests grün |
|
||||
| Pint (Code-Pfade) | sauber |
|
||||
| Build | erfolgreich (Nunito 900 zusätzlich lokal ausgeliefert) |
|
||||
| CI | 4834 grün |
|
||||
| Deploy | 4835 erfolgreich |
|
||||
| 12 bestehende öffentliche Seiten (Status, Titel, Text) vor und nach dem Deploy | unverändert |
|
||||
| Szenario 1: `/designreferenz`, `/praevention-im-alltag`, `/referenz-abschnitte`, `/t1-landingpage` im Editor geöffnet und unverändert gespeichert | 4/4 ohne Fehler |
|
||||
| Redaktionsablauf auf Test (`/premium-referenz`, über die Oberfläche) | 16 von 18 Prüfungen im Skript bestanden; die beiden Abweichungen sind Prüffehler, nicht Anwendungsfehler (siehe unten) |
|
||||
| Matrix lokal (`/pruefmatrix`, mit Kit-Motiven) und auf Test (`/premium-referenz`), 390/768/1200/1440/1920 px | kein seitlicher Überlauf, kein abgeschnittener Text oder Button, genau eine H1 |
|
||||
| Rahmen (Kopfzeile, Menü, Tastatur, CLS, Bewegung reduzieren) auf Test | 18/18 |
|
||||
|
||||
**Neue Tests in der Suite:**
|
||||
- `CmsPremiumWidgetsTest`: Upgrades, Varianten, Höhen, Akzente, Fläche, Sanitizing, unsichere Links, Fokusgrenzen, alle Widgets in jeder zulässigen bzw. unzulässigen Breite, Höhe „fill“.
|
||||
- Editortest: Premium-Einstieg mit Höhe, Ebene, Akzent, Fokus und zwei Schaltflächen speichern und veröffentlichen; Dialogfelder und Live-Vorschau.
|
||||
- Registry-Tests zum Layoutvertrag.
|
||||
|
||||
**Bewusst angepasste Tests:**
|
||||
- Einstieg braucht 3 oder 4 statt mindestens 2 Einheiten.
|
||||
- `image_text` ist Version 3.
|
||||
- Klassen der neuen Ansichten.
|
||||
- Die Hero- und Bild-Tests der Designiteration 1 sind ersetzt.
|
||||
|
||||
**Redaktionsablauf auf der Testinstanz (Szenarien 2–11):**
|
||||
- Angelegt über die Oberfläche: Einstieg in 4/4 (groß, normal) und 3/4 (kompakt, Markenfläche, H3, lange Überschrift und Schaltfläche), Aufruf mit voller Höhe, Bild und Text in 4/4, 3/4, 2/4 und 1/4 mit allen Höhen und Flächen, gemischt mit Überschrift, Fließtext und Karten.
|
||||
- Danach im Editor geändert: Überschrift, Beschriftung, Höhe und Fokus.
|
||||
- Die Live-Vorschau zeigt Höhe, Fokus (80/30 %) und Text sofort.
|
||||
- Die Smartphone-Breite zeigt den Sicherheitsumbruch.
|
||||
- Veröffentlicht; die öffentliche Seite zeigt alle Änderungen.
|
||||
|
||||
**Die zwei Abweichungen im Skript:**
|
||||
- Es erwartete 15 Widgets; angelegt waren 13. Die Zahl im Skript war falsch.
|
||||
- Der Vergleich Vorschau gegen öffentliche Seite meldete einen Unterschied. Das genaue Diff zeigt als einzigen Unterschied den beabsichtigten Vorschauhinweis „Vorschau einer unveröffentlichten Revision“. Das Markup der Widgets ist identisch.
|
||||
|
||||
**Bilder:**
|
||||
- Lokal wurden die Kit-Motive (`09_hero_widget/assets/lara-felix-park-hero.webp`, `10_bild_text_widget/assets/lara-felix-park.webp`) für den Sichtvergleich mit den Kit-Screenshots verwendet; die Darstellung entspricht ihnen.
|
||||
- Auf der Testinstanz stehen gekennzeichnete Platzhalter. Begründung: Alles, was im Editor gespeichert wird, ist über `/medien/cms/…` öffentlich abrufbar, und die öffentliche Bildverwendung ist laut Kit nicht freigegeben.
|
||||
|
||||
**Screenshots** (Testinstanz, Platzhalter) unter `docs/analysen/adaptive-widgets-screenshots/`:
|
||||
- Referenzseite bei 1440, 768 und 390 px
|
||||
- Dialog „Darstellung“
|
||||
- Live-Vorschau bei 390 und 1300 px
|
||||
|
||||
## 6. Verbleibende Einschränkungen
|
||||
|
||||
- **Kit-Dateien verändert (mein Fehler):**
|
||||
- Ein Pint-Lauf ohne Pfadangabe hat vier untracked PHP-Beispieldateien im Kit umformatiert (nur Leerraum und Klammern):
|
||||
- `11_bild_text_widget_v1.5/laravel/app/Support/LfBildTextPayload.php`
|
||||
- `11_bild_text_widget_v1.5/laravel/examples/registry-adapter.example.php`
|
||||
- `11_bild_text_widget_v1.5/laravel/tests/LfBildTextPayloadTest.php`
|
||||
- `12_premium_widgets_adaptiv_v1.6/laravel/app/Support/LfBildTextPayload.php`
|
||||
- Die übrigen 112 Kit-Dateien sind bytegleich mit dem Archiv.
|
||||
- Das Zurückschreiben aus `Downloads/Lara_Felix_Brand_UI_Kit_v1.6_Adaptive_Premium_Widgets.zip` wurde von der Rechteprüfung blockiert. Bitte diese vier Dateien aus dem Archiv wiederherstellen.
|
||||
- **Freigaben:** Die öffentliche Verwendung der Lara-&-Felix-Motive ist nicht freigegeben. Die Testseiten zeigen deshalb Platzhalter.
|
||||
- **Validierungsmeldungen auf Englisch:** Es gibt kein deutsches Sprachpaket (`lang/de` fehlt), zum Beispiel „The … field is required when … is present“. Das betrifft die ganze Anwendung.
|
||||
- **Livewire-Timing:** Werden Felder schneller ausgefüllt, als die Live-Aktualisierung zurückkommt (unter etwa 0,5 s, nur bei automatischer Eingabe beobachtet), kann ein gerade verlassenes Feld überschrieben werden. Bei menschlichem Tempo trat das nicht auf.
|
||||
- **Eingeklappter Abschnitt bei der Neuanlage:** „Seite und Suchmaschinen“ bleibt nach dem Bearbeiten einer Seite auch beim Anlegen eingeklappt, weil Filament den Zustand merkt. Das Verhalten stammt aus Iteration 2.
|
||||
- **Vorschau im Platz:** Sie ist über 28 rem gekürzt; der Einstieg wird dort beschnitten. Vollständig zeigen ihn die Live-Vorschau im Dialog und die Seitenvorschau.
|
||||
- **Keine responsiven Bildvarianten:** `srcset` fehlt; die Ableitungen gehören in die Hintergrundverarbeitung.
|
||||
- **Code-Rollback auf die Designiteration:** Ältere Software stellt `hero` v2 und `image_text` v3 „bestmöglich“ dar, kann sie aber nicht speichern (§9 der Registry-Dokumentation).
|
||||
- **Größe der Repository-Historie:** Mit dem Fast-Forward sind Lars' Commits `5dccbbc` und `3cdb36e` auf `develop` gelandet. Sie enthalten die Kit-Originalbilder und das Kit-ZIP (27,7 MB) in der Historie. Das ZIP ist in `3cdb36e` wieder entfernt, bleibt aber in der Historie.
|
||||
- **UX-Abnahme:** Die Bedienung durch den Betreiber steht aus (ADR-38 „UX-Abnahme offen“).
|
||||
|
||||
## 7. Auf der Testinstanz angelegt
|
||||
|
||||
- Seite `/premium-referenz` (veröffentlicht), mit Platzhalterbildern `cms/platzhalter-*` (Dateinamen mit Zufallssuffix).
|
||||
- Neue Entwurfsrevisionen (nicht veröffentlicht) auf `/designreferenz`, `/praevention-im-alltag`, `/referenz-abschnitte` und `/t1-landingpage` aus dem Speichertest. Die veröffentlichten Stände sind unverändert.
|
||||
|
||||
## 8. Nachprüfung vom 18.11.2026 (Seitenliste, Abstand oben, Wortmarke)
|
||||
|
||||
Branch `feature/cms-liste-logo-abstand`, Commit `89fd95b`; CI 4838, Deploy 4839 auf der Testinstanz. Gearbeitet wurde in einem separaten Worktree; der offene Branch `designkit` und das Arbeitsverzeichnis wurden nicht verändert.
|
||||
|
||||
### Befund zu `/premium-referenz`
|
||||
|
||||
`/premium-referenz` war und ist ein **regulärer CMS-Seitendatensatz**:
|
||||
|
||||
| Merkmal | Wert |
|
||||
|---|---|
|
||||
| Tabelle und Kennung | `pages`, Kennung 17 |
|
||||
| Bearbeitungsadresse | `/verwaltung/pages/17/edit` |
|
||||
| Inhalt | 7 Abschnitte, 13 Widgets, mehrere Revisionen |
|
||||
| Öffentliche Auslieferung | über die normale Seitenroute (`PageController`) |
|
||||
|
||||
Es gibt keine Sonderroute, keine Testimplementierung und keine andere Datenquelle. Angelegt wurde die Seite tatsächlich über die Editoroberfläche; diese Aussage des Berichts stimmt. Unvollständig war sie in einem Punkt: Ohne Suche war die Seite nicht zu finden.
|
||||
|
||||
**Ursache:**
|
||||
- Die Seitenliste hatte keine Sortierung und zeigte 10 Einträge je Seite in Anlagereihenfolge.
|
||||
- Die zuletzt angelegte Seite stand deshalb auf Listenseite 2 von 2.
|
||||
- Die Spalte „Geändert“ zeigte das Anlagedatum in UTC, weil gespeicherte Revisionen die Seite nicht als geändert markierten.
|
||||
- Filter, Status, Berechtigungen, Seitentyp oder eine Bereichszuordnung spielten keine Rolle; die Liste hat keine Filter.
|
||||
|
||||
**Behoben:**
|
||||
- Die Liste zeigt die zuletzt bearbeiteten Seiten zuerst; Pfad und Datum sind sortierbar.
|
||||
- Je Seite stehen 25, 50 oder 100 Einträge.
|
||||
- Die Spalte heißt „Zuletzt bearbeitet“ und zeigt deutsche Zeit.
|
||||
- Jede gespeicherte Revision und jede Veröffentlichung aktualisiert die Seite.
|
||||
|
||||
**Geprüfter Weg auf der Testinstanz** (Skript über die normale Oberfläche, ohne direkte Datenbankänderung und ohne Hilfsrouten):
|
||||
1. Anmeldung mit dem Prüfkonto.
|
||||
2. Verwaltung → Seitenleiste „Seiten“. `/premium-referenz` steht in Zeile 1, ohne Suche.
|
||||
3. Klick auf die Zeile → `/verwaltung/pages/17/edit`.
|
||||
4. Alle 13 Widgets nacheinander über „Bearbeiten“ geöffnet und ein Textfeld geändert: Einstieg (3), Handlungsaufruf, Bild und Text (6), Fließtext, Überschrift und Einleitung, Redaktionelle Karten.
|
||||
5. Erster Abschnitt: „Gestaltung des Abschnitts“ → „Abstand oben: Kein Abstand“.
|
||||
6. „Entwurf speichern“ → Meldung „Entwurf gespeichert“.
|
||||
7. „Vorschau“ zeigt alle 13 Änderungen und den Abstand.
|
||||
8. „Veröffentlichen“ → die öffentliche Seite zeigt alle 13 Änderungen und den Abstand.
|
||||
9. Dasselbe Vorgehen für `/praevention-im-alltag` (Zeile 3, `/verwaltung/pages/9/edit`), dort „Abstand oben: Gering“.
|
||||
|
||||
Ergebnis: 22 von 22 Prüfungen, keine Konsolenfehler. Ein zweiter Durchlauf hat die Prüfmarken in den Texten über die Oberfläche wieder entfernt (ebenfalls 22/22).
|
||||
|
||||
### Abstand zwischen Kopfzeile und erstem Abschnitt
|
||||
|
||||
- Bisher ließ sich der Abstand oben nur über „Abstand oben und unten“ verkleinern, und zwar auf höchstens „Kompakt“ (etwa 24–48 px), nie auf null.
|
||||
- Neu ist in der Abschnittsgestaltung „Abstand oben“ mit drei Werten:
|
||||
- „Wie ‚Abstand oben und unten‘“ (Vorgabe)
|
||||
- „Gering“ (etwa 12–20 px)
|
||||
- „Kein Abstand“
|
||||
- Gespeichert wird der Wert als `style.spacing_top`. Er wirkt nur auf den gewählten Abschnitt und nur oben.
|
||||
- Der Abstand unten und alle anderen Abschnitte bleiben unverändert. Es gibt keine globale Regel und keine Änderung an bestehenden Seiten, solange niemand die Einstellung wählt.
|
||||
|
||||
### Wortmarke in Kopfzeile und Fußbereich
|
||||
|
||||
- **Quelle:** `docs/Brand-UI-Kit/08_freigegebene_logovarianten/logo_lara_felix_kompakt.png`, gelesen aus Lars' lokalem Commit `1223dc8` (Branch `designkit`), weil die Kit-Ordner im Arbeitsverzeichnis fehlen.
|
||||
- **Freistellung:** Die Datei hat entgegen der Kit-README einen transparenten Hintergrund. Auf Weiß und auf Navy wirkt sie sauber, das ist im Browser geprüft. Die Standardfassung ist größtenteils halbtransparent und wird nicht verwendet.
|
||||
- **Eingebunden:** zugeschnittene WebP-Ableitungen `public/images/brand/lara-felix-logo-kompakt-128.webp` und `-256.webp` (1x/2x). Die Originaldatei bleibt unverändert.
|
||||
- **Größen:**
|
||||
|
||||
| Ort | Logohöhe |
|
||||
|---|---|
|
||||
| Kopfzeile, Ausgangszustand | etwa 80 px (Box unverändert 104 px) |
|
||||
| Kopfzeile, kompakt beim Scrollen | 60 px in der 72-px-Leiste |
|
||||
| Smartphone | 48 px |
|
||||
| Fußbereich | 72 px |
|
||||
|
||||
- **Stabilität:** Breite und Höhe stehen im Markup; die Navigation misst dadurch schon vor dem Laden des Bildes richtig.
|
||||
- **Mitgliederbereich:** unverändert (Schriftzug).
|
||||
- **Prüfung auf der Testinstanz:**
|
||||
- Kopfzeile 18/18.
|
||||
- Fünf Seiten bei 1920/1440/1366/1280/390 px: je Breite eine Höhe sowie eine Wortmarken- und Navigationsposition.
|
||||
- Erster Frame ohne Layoutverschiebung (CLS 0).
|
||||
|
||||
**Abnahme-Screenshots** (Testinstanz) unter `docs/analysen/adaptive-widgets-screenshots/`:
|
||||
- `07`–`09`: `/premium-referenz` bei 1440 px (Ausgangszustand und kompakt) und bei 390 px
|
||||
- `10`, `11`: `/praevention-im-alltag` bei 1440 und 390 px
|
||||
- `12`, `13`: `/praevention` bei 1440 und 390 px
|
||||
- `14`: Seitenkonfigurator, Seite 17
|
||||
- `15`: Abschnittsgestaltung mit „Abstand oben“
|
||||
|
||||
**Tests:**
|
||||
- 203 grün; neu ist `CmsPageListAndSpacingTest` (Sortierung der Liste, Bearbeitungsdatum, Abstand oben, Aufzählungsprüfung).
|
||||
- Bewusst angepasst: Erwartung an die Wortmarke (`brand-logo` statt `brand-lockup`).
|
||||
|
||||
**Offen:**
|
||||
- Eine Vektorfassung der Wortmarke fehlt; die Rasterfassung ist für die gezeigten Größen scharf (2x-Ableitung).
|
||||
- Bitte die Wortmarke in Kopf- und Fußbereich visuell abnehmen.
|
||||
|
||||
## 9. Korrektur: Abschnittsabstände vereinfacht (18.11.2026)
|
||||
|
||||
Branch `feature/abschnittsabstaende`, Commit `f511ad1`; CI 4842, Deploy 4843 auf `develop`, gearbeitet in einem separaten Worktree. Kein Merge nach `main`.
|
||||
|
||||
**Ersetzt** wurden:
|
||||
- „Abstand oben und unten“,
|
||||
- die Abweichung „Abstand oben“,
|
||||
- die versteckte Regel, die oben zwischen zwei Abschnitten ohne Fläche auf null setzte,
|
||||
- der Trenner „Zusätzlicher Abstand“.
|
||||
|
||||
**Neu** sind genau drei unabhängige Einstellungen: **Abstand oben**, **Abstand unten** und **Widget-Abstand**, jeweils mit den Stufen Kein Abstand, Kompakt, Normal und Großzügig. Gespeichert werden sie in der Abschnittshülle Version 2; Einzelheiten stehen in `cms-widget-registry.md` §11.
|
||||
|
||||
**Bestehende Seiten:** Hüllen der Version 1 werden beim Lesen übersetzt.
|
||||
|
||||
| Seite | Breiten | Ergebnis vor und nach dem Deploy |
|
||||
|---|---|---|
|
||||
| `/`, `/praevention`, `/designreferenz`, `/referenz-abschnitte`, `/premium-referenz`, `/t1-landingpage` | 1440 und 390 px | pixelgleich: Seitenhöhe, Lage jedes Abschnitts und Rasters, Innenabstände, Rasterabstände, Platzpositionen |
|
||||
| `/praevention-im-alltag` | 1440 und 390 px | erster Abschnitt oben +24,5 px bzw. +12 px, weil „Gering“ jetzt „Kompakt“ ist (gewollte Folge der vier Stufen) |
|
||||
|
||||
**Prüfung über den regulären Seitenkonfigurator:**
|
||||
- Angelegt wurde `/abstand-pruefung` (Seite 18) mit aufeinanderfolgenden Abschnitten:
|
||||
|
||||
| Abschnitt | Raster | oben / unten / Widget-Abstand |
|
||||
|---|---|---|
|
||||
| 1 | 4/4 | 0 / 0 / 0 |
|
||||
| 2 | 3:1 | 0 / 0 / 0 |
|
||||
| 3 | 4/4 | Kompakt / Normal / Normal |
|
||||
| 4 | 3:1 | Großzügig / 0 / Großzügig |
|
||||
| 5 | 3:1 | 0 / Kompakt / Kompakt |
|
||||
|
||||
- Die Gestaltung zeigt genau die drei Felder, „Abstand oben und unten“ gibt es nicht mehr.
|
||||
- Berechnete CSS-Werte (26 von 26 Prüfungen):
|
||||
|
||||
| Prüfung | 1440 px | 390 px |
|
||||
|---|---|---|
|
||||
| Stufen oben/unten (Kompakt / Normal / Großzügig) | 44,8 / 89,6 / 120 px | 24 / 48 / 72 px |
|
||||
| Stufen Widget-Abstand (Kompakt / Normal / Großzügig) | 18 / 36 / 56 px | 12 / 20 / 32 px |
|
||||
| Innenabstände und Rasterabstand je Abschnitt | wie eingestellt, Außenabstand jeweils 0 | wie eingestellt, Außenabstand jeweils 0 |
|
||||
| Inhalt 1 → 2 (0 + 0) | 0,0 px | 0,0 px |
|
||||
| Inhalt 2 → 3 (0 + Kompakt) | 44,8 px | 24 px |
|
||||
| Inhalt 3 → 4 (Normal + Großzügig) | 209,6 px | 120 px |
|
||||
| Inhalt 4 → 5 (0 + 0) | 0,0 px | 0,0 px |
|
||||
| Widget-Abstand 3:1 | nebeneinander 0 / 56 / 18 px | gestapelt 0 / 32 / 12 px |
|
||||
|
||||
**Tests:** 204 grün.
|
||||
- Neu:
|
||||
- Addition und Vorgaben,
|
||||
- Übersetzung aller Fälle der Version 1 (Abweichung, versteckte Regel, eigene Fläche, Linientrenner, leerer Abschnitt, Zusatzabstand),
|
||||
- Abweisung freier Werte für alle drei Felder.
|
||||
- Bewusst angepasst: Hüllenversion 2, neue Klassen, Prüfung freier Werte über die neuen Schlüssel.
|
||||
|
||||
**Vorgabe für neue Abschnitte:** oben und unten Kompakt, Widget-Abstand Normal. Damit bleibt der Abstand zwischen zwei neuen Abschnitten so groß wie bisher, und ein neuer erster Abschnitt beginnt näher an der Kopfzeile als vorher.
|
||||
|
||||
|
After Width: | Height: | Size: 260 KiB |
|
After Width: | Height: | Size: 362 KiB |
|
After Width: | Height: | Size: 257 KiB |
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 87 KiB |
|
After Width: | Height: | Size: 91 KiB |
|
After Width: | Height: | Size: 89 KiB |
|
After Width: | Height: | Size: 102 KiB |
|
After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 66 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 99 KiB |
|
After Width: | Height: | Size: 100 KiB |
@@ -0,0 +1,163 @@
|
||||
# Abschlussbericht CMS-Iteration 2: Website-Gerüst, Abschnittsraster, Seiteneditor
|
||||
|
||||
Stand: 17.11.2026. Branch `feature/cms-sections`, auf `develop` übernommen (Fast-Forward) und über `deploy-test.yml` auf der Testinstanz (Port 3011) bereitgestellt. **Kein Merge nach `main`, keine Produktivsetzung.** Entwicklerdokumentation: `docs/architektur/cms-widget-registry.md` (Abschnitte, Editor, Rollback), `docs/architektur/designsystem.md` (Tokens, Komponenten, Marke).
|
||||
|
||||
Commits: `480d559` (Umsetzung), `2ac2923` (Dokumentation), `4cad602` (Speicherlimit der Testsuite), `6152451` (Duplizieren direkt hinter dem Original), `dc33f0e` (Bericht), `c6186fb` (Veröffentlichen speichert zuerst, Warnung bei ungespeicherten Änderungen), dazu diese Berichtskorrektur.
|
||||
|
||||
## Ausgangslage und Grundlagen
|
||||
|
||||
Geprüft: Implementierung der Iteration 1 (Widget-Registry, acht Widget-Arten, Editor, Vorschau, Revisionen, Navigation, Katalogverweise) im Code; ADR-22, -28, -29, -30, -32, -36 (`12_Entscheidungsprotokoll_ADR.md`, Arbeitsstand mit lokalen Änderungen, nicht verändert); `design-prinzipien.md`; Website-Zielkonzept (§§5–8, Designanalyse und Designsystem); Website-Zielarchitektur (§§4.5, 5.2–5.6); `trainingskonzept-und-produktstruktur.md`; `produktkonfiguration-und-mitgliederbereich.md`; Fachkonzept v1.1; Brand-UI-Kit mit Quellenmanifest. **`00_LUF_Projektkompass.md` ist im Repository nicht vorhanden** (auch nicht unter anderem Pfad).
|
||||
|
||||
## 1. Umgesetzte Funktionen
|
||||
|
||||
- **Abschnittsmodell**: Seite → Abschnitte → Plätze → je Platz höchstens ein Widget aus dem bestehenden Register. Sechs Raster (4, 2+2, 1+3, 3+1, 1+2+1, 1+1+1+1), Abschnittsgestaltung über Aufzählungswerte, stabile Kennungen, versionierte Hülle.
|
||||
- **Adaptive Widgets**: Mindest- und Vorzugsbreite je Widget-Art im Register; Widget-Ansichten mit Container-Abfragen; Prüfung „zu schmal“ beim Speichern und Hinweis im Editor.
|
||||
- **Abschnittsgestaltung**: Hintergrund (Standard, helle Markenfläche, dunkle Markenfläche, Markenakzent, Hintergrundbild mit Fokuspunkt und Überlagerung), Breite (schmal, Standard, breit, volle Breite), Abstand (kompakt, normal, großzügig), Trenner (Abstand, Linie, Markenakzent).
|
||||
- **Editor**: volle Arbeitsbreite; Abschnitte mit grafischer Rasterauswahl, Plätzen im Rasterverhältnis, Widget-Vorschau in echter Platzbreite ohne Bildlaufleiste; Hinzufügen, Duplizieren (direkt hinter dem Original), Verschieben (Pfeile und Ziehen), Löschen mit Rückfrage; Rasterwechsel ohne Widget-Verlust; Fehlermeldungen mit Abschnitt, Platz und Widget-Art; Seite duplizieren.
|
||||
- **Globales Website-Gerüst**: klebende kompakte Kopfzeile mit vorläufiger Wortmarke, CMS-Hauptnavigation mit aktivem Eintrag und einer Ebene Untermenü, Kontozugang „Mitgliederbereich“, vorbereiteter (abgeschalteter) Warenkorbzugang, mobile Navigation ohne untere Leiste; Fußbereich mit Themenbereichen und den CMS-Gruppen Service, Kontakt, Rechtliches.
|
||||
- **Gemeinsames Designsystem**: zweistufige Tokens, Grundkomponenten, lokal ausgelieferte Schriften; Mitgliederbereich nutzt dieselben Tokens und dieselbe Wortmarke.
|
||||
- **Wiederherstellungsweg**: flache Rollback-Fassung je Revision und Befehl `cms:revert-published`.
|
||||
|
||||
## 2. Verwendete und erweiterte Komponenten
|
||||
|
||||
| Bestand | Erweiterung |
|
||||
|---|---|
|
||||
| `WidgetRegistry`, `WidgetType`, acht Widget-Arten | `normalizeWidget()` für seitenweite Prüfung; `minUnits()`, `preferredUnits()`, `stages()` |
|
||||
| `WidgetRenderer`, Widget-Ansichten | unverändert als Renderweg je Widget; Handlungsaufruf nutzt die gemeinsame Schaltfläche |
|
||||
| `PageService`, `PageRevision` | speichert Abschnitte und Rollback-Fassung; `sections()`, `duplicate()` |
|
||||
| `PageController`, Vorschaurouten | rendern über `SectionRenderer` |
|
||||
| `WidgetEditor`, `WidgetBlock` | `slotBuilder()` für Plätze, Mindestbreite in der Auswahl |
|
||||
| `NavigationItem`, `NavigationItemResource` | Fußbereichsgruppen als Platzwerte, `parent_id` für Untermenüs |
|
||||
| Layouts `site`/`member`, `components/site/*` | Kopfzeile, Fußbereich, Wortmarke, Warenkorbzugang neu gefasst |
|
||||
| `resources/css/app.css` | aufgeteilt in Tokens, Grundelemente, Komponenten, Gerüst, Abschnitte, Widgets |
|
||||
| Neu | `PageSections`, `SectionLayouts`, `SectionStyle`, `SectionRenderer`, `SiteNavigation`, `SectionEditor`, `ReportsSectionErrors`, `RevertPublishedPages`, `site-nav.js` |
|
||||
|
||||
Zwei ergänzende Migrationen: `page_revisions.sections` (JSON, nullable) und `navigation_items.parent_id` (nullable, beim Löschen des Elterneintrags `null`). Keine Daten werden geändert oder gelöscht.
|
||||
|
||||
## 3. Abschnitts- und Slot-Modell
|
||||
|
||||
Siehe `cms-widget-registry.md` §11. Kurz: Ein Abschnitt hat Kennung, Version, Raster, Gestaltung und genau so viele Plätze, wie das Raster Einheiten-Gruppen hat. Ein Platz enthält eine Widget-Hülle oder ist leer. Leere Plätze gibt es im Editor; öffentlich entfallen sie, die übrigen Plätze teilen sich die Breite im Verhältnis ihrer Einheiten; Abschnitte ohne Inhalt entfallen ganz. Mehr Widgets als Plätze werden beim Speichern abgewiesen, nie abgeschnitten. Keine Verschachtelung.
|
||||
|
||||
## 4. Responsive Widget-Regeln
|
||||
|
||||
Siehe `cms-widget-registry.md` §§11–12. Abschnitte stapeln unter 40 rem Abschnittsbreite immer, ab 40 rem bleiben gleich breite Plätze nebeneinander (4 Plätze als 2 × 2), ab 60 rem gilt das Rasterverhältnis. Gestapelt wird in Platzreihenfolge, die Lese- und Fokusreihenfolge bleibt gleich. Mindestbreiten: Einstieg und Bild-und-Text sowie FAQ 2 Einheiten, alle übrigen 1 Einheit (abgeleitet aus rund 276 px je Einheit auf dem Desktop).
|
||||
|
||||
## 5. Gemeinsames Designsystem
|
||||
|
||||
Siehe `designsystem.md`. Markenwerte (Navy `#032551`, Grün `#5b8625`/`#3b7b09`, Gelb `#fcd10a`, Creme `#f7f6f2`, Tinte `#15243a`) aus dem Brand-UI-Kit, ausdrücklich **vorläufig**. Bedeutungswerte für Text, Flächen, Linien, Fokus, Aktion, Erfolg, Warnung, Fehler, Information, Deaktiviert; Flächen setzen sie neu. Alle Textpaare erreichen mindestens 4,5 : 1 (gerechnet); Fokus mindestens 3 : 1.
|
||||
|
||||
## 6. Kopfzeile, Navigation, Fußbereich
|
||||
|
||||
- Kopfzeile 64/72 px, klebend mit Schatten beim Scrollen; Hauptnavigation ab 75 rem in einer Zeile, darunter Menü-Schaltfläche.
|
||||
- Kontozugang und Kopfzeile sind für Gäste und Mitglieder **identisch** (vorher zeigte die Kopfzeile je nach Anmeldestatus „Registrieren“ oder „Mitgliederbereich“). Gäste gelangen über den Zugang zur Anmeldung. Eine Registrierung ist weiterhin über die Anmeldeseite erreichbar.
|
||||
- Mobile Navigation: Fläche unter der Kopfzeile, 48 px hohe Einträge, Untermenü eingerückt, Fokusführung und Escape; ohne JavaScript bleibt die Liste sichtbar. Keine feste untere Leiste auf der Website.
|
||||
- Warenkorb: `config/cms.php` → `cart.enabled` (Vorgabe aus). Solange aus, erscheint nichts.
|
||||
- Fußbereich: Wortmarke, „Themenbereiche“ (veröffentlichte Säulen), Gruppen aus der CMS-Navigation. Keine erfundenen Kontakt- oder Rechtstexte; bisher gibt es nur die Gruppe „Service“ mit Impressum und Datenschutz.
|
||||
|
||||
## 7. Schnittstellen zum Mitgliederbereich
|
||||
|
||||
Gemeinsam: Tokens (über die bisherigen Variablennamen des Mitgliederbereichs, Werte unverändert), Schriften, Fokusregeln, Wortmarke, Schaltflächen, Formulare, Statusanzeigen. Unverändert: Layout, Seitenleiste, Bibliotheksnavigation, bestehende untere Leiste `member-dock`, Berechtigungen, Suche, Kursplayer. Sichtbare Änderung: Überschriften in Nunito statt Source Serif 4; Zusatz „Mitgliederbereich“ in der dunklen Seitenleiste jetzt kontraststark (vorher dunkle Schrift auf Navy). Geprüft: alle Mitglieder-Tests grün, Sichtprüfung lokal bei 390 und 1440 px ohne horizontalen Überlauf. Auf der Testinstanz stand kein Mitgliedskonto zur Verfügung.
|
||||
|
||||
## 8. Automatisierte Tests
|
||||
|
||||
| Prüfung | Ergebnis |
|
||||
|---|---|
|
||||
| Suite lokal | 185 Tests grün (Iteration 1: 145); neu `PageSectionsTest` (17), `CmsSectionRenderingTest` (13), `CmsRollbackCommandTest` (2), erweitert `CmsEditorTest`, `WidgetRegistryTest` |
|
||||
| Pint | sauber |
|
||||
| CI Feature-Branch | Läufe 4808/4809 rot, 4810/4811/4813/4815 grün |
|
||||
| Deploy Testinstanz | Läufe 4812, 4814, 4816 erfolgreich, `/up` 200 |
|
||||
|
||||
Abgedeckt: Registrierung und Mindestbreiten, Abschnitte und Plätze, Rastervalidierung, Layoutwechsel ohne Datenverlust (Editor und Speicherpfad), Abschnittshintergründe und öffentliche Medienfreigabe, freie Werte abgewiesen, Revisionen, Wiederherstellen und Rollback-Fassung, Navigation (Untermenü, Fußgruppen, ausgeblendete Eltern, Löschen), identische Ausgabe für Gäste und Mitglieder, keine Fremd-Schriftserver, Zugriffsschutz der Vorschau, Kompatibilität mit Altbestand (Text der Startseite unverändert nach Speichern im neuen Format).
|
||||
|
||||
**Ursache der roten CI-Läufe:** Das Test-Image läuft mit dem PHP-Standardlimit von 128 MB; die gesamte Suite überschritt es kumulativ (Fatal Error). `phpunit.xml` setzt nun 512 MB wie `docker/php.ini` der Anwendung. Messung: Eine Bearbeitung einer Seite mit 20 Abschnitten à 2 Plätzen braucht rund 74 MB zusätzlich. Keine Prüfung wurde abgeschwächt.
|
||||
|
||||
## 9. Browserprüfung auf der Testinstanz
|
||||
|
||||
Mit dem Prüfkonto über die Oberfläche (Playwright, Chromium), nicht gegen Prod. Die Durchläufe dieses Abschnitts (25/25, 8/8, T1–T9) liefen auf Stand `6152451`, also vor der Änderung an „Veröffentlichen“ (`c6186fb`). Danach geprüft: die Suite, der gemeldete Ablauf (direkt veröffentlichen mit neuem Bild) und dass die Warnung bei ungespeicherten Änderungen ohne Änderung nicht erscheint (Neuladen, nach Speichern, Wiederherstellen, Navigation). Die Prüfskripte erwarten im Bestätigungsdialog noch die alte Schaltflächenbeschriftung und müssen für eine Wiederholung angepasst werden (neu: „Speichern und veröffentlichen“).
|
||||
|
||||
| Prüfung | Ergebnis |
|
||||
|---|---|
|
||||
| Bestehende 12 öffentliche Seiten vor/nach Deploy (Status, Titel, Haupttext) | 12/12 unverändert |
|
||||
| Referenzseite `/referenz-abschnitte` anlegen, gestalten, Layoutwechsel, Duplizieren, Reihenfolge, Löschen, Vorschau 390/768/1440, Veröffentlichen, Ändern, Revision wiederherstellen, mobile Navigation, Übergang zur Anmeldung | 25/25 |
|
||||
| Untermenü über die Navigationsverwaltung, Tastatur (Enter, Tab, Escape), mobil, wieder entfernt | 8/8 |
|
||||
| Kein horizontaler Überlauf bei 1440/768/390 px; genau eine H1 | ja |
|
||||
|
||||
Die Referenzseite enthält: Einstieg über volle Breite auf Hintergrundbild (gekennzeichneter Testplatzhalter, dunkle Überlagerung), 2 + 2 auf heller Fläche, 1 + 3 auf dunkler Fläche, 1 + 1 + 1 + 1 auf Markenakzent, 3 + 1 mit dynamischer Programmreferenz; Trenner Markenakzent und Linie; Varianten Kompakte Liste, Bild rechts, Standard.
|
||||
|
||||
**ADR-28, neun Bedienaufgaben** (automatisiert mit Zeitmessung; ersetzt nicht die Abnahme durch den Betreiber):
|
||||
|
||||
| Nr. | Ergebnis | Zeit | Hinweis |
|
||||
|---|---|---|---|
|
||||
| T1 Landingpage aus Vorlage | bestanden | 19 s | „Vorlage“ = vorhandene Seite über „Duplizieren“; Vorlage unverändert |
|
||||
| T2 Bild und Text, Bild, Alternativtext, Variante | bestanden | 10 s | Widget-Vorschau zeigt „Bild rechts“ vor dem Speichern |
|
||||
| T3 umsortieren, duplizieren | bestanden | 2 s | erster Durchlauf scheiterte am Messskript (Aktionen ohne Warten auf Livewire), Wiederholung bestanden |
|
||||
| T4 zwei Programme wählen, tauschen | bestanden | 15 s | Titel aus den Fachdaten |
|
||||
| T5 zu langer Titel bei 390 px | bestanden (eingeschränkt) | – | kein Überlauf, Silbentrennung greift; „Erkennen ohne Hinweis“ ist nur mit Menschen prüfbar |
|
||||
| T6 globalen Abschnitt ändern | **nicht bestanden** | – | globale Abschnitte sind nicht umgesetzt |
|
||||
| T7 frühere Revision wiederherstellen | bestanden | 5 s | |
|
||||
| T8 20 Abschnitte öffnen, ändern, speichern | bestanden | 2,0 / 0,3 / 1,4 / 2,3 s | Öffnen/Dialog/Übernehmen/Speichern; erste Messung 4,0 s enthielt Wartezeiten des Skripts. Mehrspaltige Seite (6 Abschnitte, 12 Plätze): 1,4 / 1,6 s |
|
||||
| T9 Pflichtfeld leer | bestanden | 6 s | Dialog bleibt offen; Speicherfehler „Abschnitt 1, Platz 1 (Einstieg): braucht mindestens 2 Rastereinheiten“ als Meldung und am Abschnitt |
|
||||
|
||||
Ergebnis: 8 von 9 Aufgaben technisch bestanden, darunter T1, T4, T8. Die Entscheidungsregel verlangt zusätzlich die Durchführung durch den Betreiber und dessen Aussage „so würde ich wöchentlich arbeiten“; das steht aus.
|
||||
|
||||
Weitere Beobachtungen: Eine Konsolenmeldung 403 während der Bearbeitung (vermutlich Upload-Vorschau, nicht eingegrenzt); alle Bilder der veröffentlichten Seite liefern 200. Bildschirmleser und echte Mobilgeräte wurden nicht geprüft.
|
||||
|
||||
**Rückmeldung des Auftraggebers während der Prüfung:** „Bild im Widget gewählt oder hochgeladen, im Editor sichtbar, nach Veröffentlichen nicht auf der Website und nach Neuladen im Editor weg.“ Auswahl, Upload, neue und vorhandene Widgets (Einstieg, Bild und Text, Karten) speicherten auf der Testinstanz jeweils korrekt, sobald „Entwurf speichern“ geklickt wurde. Ein Verlust ließ sich in keinem Ablauf mit „Entwurf speichern“ reproduzieren. Reproduzierbar war nur der Ablauf *Übernehmen → Veröffentlichen ohne Speichern*: „Veröffentlichen“ stellte die zuletzt gespeicherte Revision live, die ungespeicherte Änderung ging beim Neuladen verloren (Hinweis nur im Bestätigungsdialog). Das ist die wahrscheinliche Ursache, nicht nachgewiesen. Vor Deploy 4812 lief auf der Testinstanz noch der Code der Iteration 1. Behoben: „Veröffentlichen“ speichert zuerst und veröffentlicht genau diesen Stand; unveränderte Stände erzeugen keine weitere Revision; der Editor warnt beim Verlassen oder Neuladen mit ungespeicherten Änderungen. Tests: zwei neue Editor-Tests (zuerst rot, dann grün), Browserprüfung des gemeldeten Ablaufs auf der Testinstanz.
|
||||
|
||||
## 10. Bekannte Einschränkungen
|
||||
|
||||
- Keine globalen Abschnitte (T6), keine Seitentypen oder echten Vorlagen; „Duplizieren“ deckt den Vorlagenfall teilweise ab.
|
||||
- Widget-Vorschauen im Editor zeigen die Abschnittsfläche nicht (heller Grund); die Seitenvorschau zeigt sie.
|
||||
- Hintergrundbilder werden in Originalgröße ausgeliefert (kein `srcset`, keine abgeleiteten Zuschnitte); Fokuspunkt nur in neun Stufen.
|
||||
- Mindestbreite gilt je Platz auf dem Desktop; die Widget-Auswahl bietet auch zu breite Widgets an und warnt erst im Platzkopf und beim Speichern.
|
||||
- Raster mit weniger Plätzen sind gesperrt, solange mehr Widgets eingesetzt sind; ein automatisches „überzählige Widgets in neuen Abschnitt verschieben“ gibt es nicht.
|
||||
- Öffentliche Seiten werden noch nicht zwischengespeichert (ADR-32 offen); sie sind aber anmeldeunabhängig gerendert.
|
||||
- Seitenliste der Verwaltung zeigt 10 Einträge je Seite (Bestand).
|
||||
|
||||
## 11. Marken- und Assetfreigaben
|
||||
|
||||
| Asset / Wert | Verwendet | Status |
|
||||
|---|---|---|
|
||||
| Markenfarben aus Brand-UI-Kit (`tokens.json`) | ja | **vorläufig**, Freigabe fehlt |
|
||||
| Nunito (Auszeichnung), Source Sans 3 (Lesen) | ja, lokal ausgeliefert | **vorläufig** (Zielkonzept 7.2, offen); Lizenz als frei angenommen, nicht geprüft |
|
||||
| Wortmarke als Weblogo | **nein**, fehlt | vorläufiger Schriftzug, gekennzeichnet `data-brand-status="vorlaeufig"` |
|
||||
| Titel-, Denkpause-, Outro-Motiv | nein | Originale vorhanden, öffentliche Nutzung laut Quellenmanifest nicht freigegeben |
|
||||
| Figurenreferenzen | nein | nur intern |
|
||||
| SVG-Entwürfe, KI-Konzeptgrafiken | nein | nicht freigegeben |
|
||||
| Themensignaturen (5) | Platz vorbereitet (Nummer + Name, neutrale Tönung) | Symbole und Tönungen nicht entworfen |
|
||||
| Hintergrundbild Referenzseite | gekennzeichneter Testplatzhalter | nur Testinstanz |
|
||||
|
||||
## 12. Rollback- und Wiederherstellungsweg
|
||||
|
||||
Siehe `cms-widget-registry.md` §9. Zusammengefasst: Ein reiner Code-Rollback ist nach Änderungen im neuen Editor **nicht sicher**. Auf Iteration 1 zeigt er alle Inhalte ohne Raster und Flächen; auf den heutigen Prod-Stand (vor der Registry) scheitert er an den neu gespeicherten Seiten. Vor jedem Rollback: `php artisan cms:revert-published --before="<Deploy-Zeitpunkt>"` (Probelauf), dann `--apply`; der Befehl setzt nur Veröffentlichungszeiger zurück. SQL-Gegenstück für den Fall, dass der neue Code nicht mehr läuft, ist dokumentiert. Migrationen müssen nicht zurückgenommen werden.
|
||||
|
||||
Für den späteren Merge nach `main`: `main` liegt jetzt 62 Commits hinter `develop` (einschließlich dieser Berichtskorrektur 63) (Iteration 1 und 2 sowie die früheren Bibliothekspakete). Nach dem Prod-Deploy sollte vor der ersten Bearbeitung im Editor der Deploy-Zeitpunkt notiert werden.
|
||||
|
||||
## 13. Empfehlungen für die visuelle Veredelung
|
||||
|
||||
1. Freigaben einholen: Wortmarke als SVG, Farbwerte (mit gemessenem Kontrast), Schriften, Bildmotive mit Rechten und textfreien Zuschnitten.
|
||||
2. Dann nur `tokens.css` und `components/site/brand.blade.php` ändern; Sichtprüfung 390/768/1440.
|
||||
3. Widgets einzeln mit Design-Skills veredeln (Ansicht + `widgets.css`), Daten und Klassen bleiben stabil; zuerst Einstieg, Programmkarten (mit Themensignaturen statt Inhaltsart-Fläche), Bild und Text.
|
||||
4. Themensignaturen-Familie entwerfen und je Säule pflegbar machen.
|
||||
5. Abgeleitete Bildgrößen für Abschnittshintergründe über die Hintergrundverarbeitung.
|
||||
6. UX-Abnahme T1–T9 mit dem Betreiber; anschließend über ADR-28 entscheiden.
|
||||
|
||||
## Auswirkungen auf ADR-28, ADR-30, ADR-36
|
||||
|
||||
| ADR | Auswirkung | Status |
|
||||
|---|---|---|
|
||||
| ADR-28 Ausbau des Eigen-CMS | Abschnittsraster, Gestaltung und Seiten-Duplikat mit Filament-Bordmitteln ohne Zusatzpaket umgesetzt; 8 von 9 Bedienaufgaben technisch bestanden, T6 (globale Abschnitte) offen | **technisch gestützt, UX-Abnahme durch den Betreiber offen**; keine Freigabe durch diesen Bericht |
|
||||
| ADR-30 Widget-Register | Vertrag unverändert, um Breitenmetadaten ergänzt; Abschnitte als zweite versionierte Hülle über dem Register, kein zweites Register; Editor und Vorschau nutzen weiterhin dieselbe Darstellung | bestätigt im umgesetzten Umfang |
|
||||
| ADR-36 Designsystem | zweistufige Tokens im Repository, gemeinsame Basis für Website und Mitgliederbereich | Struktur umgesetzt; **Markenwerte und Schriften weiterhin unter Freigabevorbehalt** |
|
||||
| ADR-32 (berührt) | öffentliche Ausgabe anmeldeunabhängig, Test belegt identisches HTML | Zwischenspeicher weiterhin offen |
|
||||
|
||||
## Auf der Testinstanz angelegt oder geändert
|
||||
|
||||
- Seite `/referenz-abschnitte` (veröffentlicht, Prüftexte, Testplatzhalter als Hintergrund `cms/testplatzhalter-hintergrund-*.jpg`).
|
||||
- Seiten `/t1-landingpage` und `/t1-landingpage-b` (veröffentlicht, aus den Bedienaufgaben T1/T7).
|
||||
- Neue Revision der Messseite `/pruefung-zwanzig-abschnitte` (weiterhin unveröffentlicht).
|
||||
- Seiten `/bildpruefung-select` und `/bildpruefung-upload` (veröffentlicht, Bildprüfung zur Rückmeldung), mehrere Revisionen darin; auf `/bildpruefung-select` zuletzt eine wiederhergestellte, unveröffentlichte Revision.
|
||||
- `/referenz-abschnitte`: Abschnitt 3 („Bild und Text“) hat nachträglich ein Bild erhalten und wurde neu veröffentlicht.
|
||||
- Mehrere Testbilder `cms/testplatzhalter-hintergrund-*.jpg` im öffentlichen Medienbereich der Testinstanz.
|
||||
- Ein Navigations-Prüfeintrag wurde angelegt und wieder gelöscht. Keine sonstigen Navigationsänderungen.
|
||||
- Keine Bereinigung bestehender Testinhalte: Die vorhandenen Seiten werden unverändert dargestellt und sind im neuen Editor bearbeitbar; eine Bereinigung war nicht nötig.
|
||||
@@ -0,0 +1,77 @@
|
||||
# Einheitliche Medienverwaltung im CMS – Bericht
|
||||
|
||||
Branch `feature/cms-medienverwaltung`, Commits `7c63424` (Website-Ableitung) und `053a8d4` (Umstellung). Gearbeitet wurde in einem separaten Worktree, der Deploy lief über `develop` (CI 4859, Deploy 4860). Kein Merge nach `main`.
|
||||
|
||||
- Entscheidung: ADR-40.
|
||||
- Technik: `docs/architektur/medienzugriff-fuer-komponenten.md`, Abschnitt „Umsetzung im CMS“, und `cms-widget-registry.md` §§ 7 und 9.
|
||||
|
||||
## 1. Ergebnis
|
||||
|
||||
**Bildstellen:**
|
||||
- Alle Bildstellen des CMS verwenden den zentralen Medienbestand: Einstieg (Hero), Bild und Text, redaktionelle Karten, Premium-Karten (Kartenbild) und Abschnittshintergrund.
|
||||
- Gespeichert wird die Kennung des Mediums, nicht ein Pfad.
|
||||
- Öffentlich erscheint ein Bild nur mit Website-Freigabe (`WebsiteMedia`, Route `website.media`).
|
||||
- Die CMS-eigene Bildauswahl entfällt.
|
||||
|
||||
**Im Widget-Dialog** (Reiter „Medien“, beim Abschnitt „Gestaltung“):
|
||||
|
||||
| Funktion | Verhalten |
|
||||
|---|---|
|
||||
| Auswahl | Alle Bilder des Medienmanagers, durchsuchbar, mit Vorschaubild, Titel und Website-Status (freigegeben, nicht freigegeben, wird verarbeitet) |
|
||||
| Neues Bild hochladen | Das Bild wird sofort im Medienmanager angelegt (`WebsiteIntake`) und ausgewählt. Nach der Verarbeitung gibt die Warteschlange es automatisch für die Website frei. |
|
||||
| Gewähltes Bild | Vorschaubild, Status mit Begründung und „Im Medienmanager öffnen“ (dort steht die Website-Freigabe) |
|
||||
| Austauschen | Ein anderes Bild in der Auswahl wählen; Bildausschnitt und Darstellung bleiben im Widget |
|
||||
| Alternativtext | Kommt aus dem Medium. Das Feld im Widget ist eine optionale Abweichung. |
|
||||
|
||||
**Medienmanager:** Die Medienansicht nennt jetzt die Website-Seiten, die das Bild verwenden. Beim Zurücknehmen der Freigabe weist sie darauf hin, dass das Bild dort verschwindet.
|
||||
|
||||
**Nicht freigegeben:** Öffentlich entfällt nur das Bild; Überschrift, Text und Schaltflächen des Widgets bleiben. Die Redaktionsvorschau zeigt das Vorschaubild mit dem Hinweis, warum es öffentlich nicht erscheint und wo die Freigabe steht.
|
||||
|
||||
**Website-Ableitung:** Bilder werden bis 2400 px breit abgeleitet statt in 640 px Vorschaugröße und nie vergrößert. Transparente Flächen werden weiß. Filmstandbilder bleiben bei 640 px. Diese Änderung betrifft Lars' `ThumbnailDeriver` und liegt deshalb in einem eigenen Commit.
|
||||
|
||||
## 2. Übernahme der Bestandsmedien (Testinstanz)
|
||||
|
||||
Der Job `ImportCmsImages` wurde beim Deploy von einer Migration angestoßen und von der Warteschlange ausgeführt. Ergebnis, lesend geprüft:
|
||||
|
||||
- **21 frühere Bilddateien** unter `cms/`, bytegleich zusammengefasst zu **9 Medien**: Felix und die Einkäufe (Intro), Lara Felix Park (Original), Platzhalter Bild Text, Platzhalter Karte 1, 2 und 3, Platzhalter Markenbühne, Prüfbild, Testplatzhalter Hintergrund.
|
||||
- Alle 9 Medien sind abgeleitet und freigegeben. Es gibt keine offenen und keine fehlgeschlagenen Jobs.
|
||||
- Gelöscht wurde nichts. Die Dateien unter `cms/` und alle Revisionen bleiben unverändert.
|
||||
- Frühere Pfade gelten über `website_media_aliases` als das jeweilige Medium. Beim nächsten Speichern wird die Kennung eingetragen.
|
||||
|
||||
## 3. Prüfung
|
||||
|
||||
| Prüfung | Ergebnis |
|
||||
|---|---|
|
||||
| Testsuite | 245 grün, davon neu: 8 Tests für die Medienanbindung und 2 für die Ableitungsgröße. Bewusst geändert: Die Alt-Text-Pflicht im Widget entfällt, weil der Alternativtext zum Medium gehört. |
|
||||
| Bestehende Seiten vor und nach Deploy und Übernahme | Geometrie unverändert (16 Messungen: 8 Seiten bei 1440 und 390 px), Texte unverändert (12 Seiten). Alle 16 Bilder auf 5 Seiten kommen jetzt über `/website-medien/`, sind geladen und haben dieselben Maße und Alternativtexte (zuvor `/medien/cms/`). Frühere Revisionen werden damit korrekt dargestellt. |
|
||||
| Browser auf der Testinstanz, Redaktionsablauf (13 von 13) | siehe Liste darunter |
|
||||
| Browser auf der Testinstanz, Freigabe zurücknehmen (8 von 8) | siehe Liste darunter |
|
||||
| Slideshow | Im CMS gibt es keine Slideshow. Neue Widget-Arten waren nicht Teil des Auftrags. `WebsiteMedia::presentMany` ist vorbereitet, aber noch unbenutzt. |
|
||||
|
||||
**Redaktionsablauf, Prüfkonto, regulärer Seitenkonfigurator, Entwurfsseite, nichts veröffentlicht:**
|
||||
- Vorhandenes Bild aus dem Medienmanager im Einstieg gewählt; Picker und Statusanzeige mit Vorschaubild und Verweis.
|
||||
- Übernommene Platzhaltergrafik („Platzhalter Markenbühne“) durch „Platzhalter Bild Text“ ersetzt.
|
||||
- Neues Bild direkt im Dialog hochgeladen: Es war sofort ausgewählt, zuerst mit „Wird gerade verarbeitet“, danach freigegeben. Im Medienmanager per Suche auffindbar; dessen Ansicht nennt die verwendende Seite.
|
||||
- Dasselbe Medium in Einstieg und Karte verwendet.
|
||||
- Gespeichert, wieder geöffnet, Vorschau: alle Bilder über `/website-medien/`, geladen, 1200 bis 1600 px breit.
|
||||
|
||||
**Freigabe zurücknehmen, auf `/premium-referenz`, danach wiederhergestellt:**
|
||||
- Die Medienansicht nennt die Seite.
|
||||
- Nach dem Zurücknehmen fehlt das Bild öffentlich; die übrigen 6 Bilder bleiben.
|
||||
- `/website-medien/15` und die frühere Adresse `/medien/cms/…` liefern 404.
|
||||
- Nach der erneuten Freigabe ist der Ausgangszustand wieder da; Geometrie und Bilder entsprechen dem Stand vorher.
|
||||
|
||||
**Auf der Testinstanz neu angelegt:**
|
||||
- das Medium „Platzhalter Upload Medienpruefung“ (gekennzeichneter Platzhalter),
|
||||
- die Entwurfsseite `/medien-pruefung-entwurf`.
|
||||
|
||||
Beides lässt sich über den Medienmanager bzw. die Seitenverwaltung entfernen.
|
||||
|
||||
## 4. Offene Punkte für Lars
|
||||
|
||||
1. **Bild entfällt oder Widget entfällt?** Die Dokumentation sagt, eine Komponente ohne freigegebenes Medium „erscheint öffentlich nicht“. Umgesetzt ist, dass nur das Bild entfällt, damit eine zurückgenommene Freigabe keine Überschrift (H1) von einer Seite entfernt.
|
||||
2. **Bildschlüssel:** Gespeichert wird im bisherigen Schlüssel `image` (`refs.image`, `style.image`, `data.items[].image`), nicht in `refs.element`. Grund: Die Medienkarte nutzt `refs.element` für ihr Fachobjekt. Das Dokument ist entsprechend ergänzt.
|
||||
3. **Originalmotiv freigegeben:** „Lara Felix Park Original“ (`cms/lara-felix-park-original-…png`) lag bereits öffentlich unter `cms/` und ist durch die Übernahme ein freigegebenes Medium. Ist die Veröffentlichung nicht geklärt, im Medienmanager zurücknehmen; `/premium-referenz` zeigt es dann nicht mehr.
|
||||
4. **Titel und Quellenzeilen der übernommenen Medien** kommen aus den Dateinamen, ohne Quellenzeile, zum Beispiel „Platzhalter Markenbuehne“ ohne Umlaut. Beides lässt sich im Medienmanager pflegen.
|
||||
5. **Rollback:** Eine Code-Fassung vor der Umstellung zeigt Bilder nicht, die danach gespeichert wurden (Kennung statt Pfad). Texte bleiben, die Dateien unter `cms/` bleiben (Registry §9).
|
||||
6. **Bedienmuster:** Die Bildauswahl des Modul- und Programmeditors ist an dessen Seite gebunden und ließ sich nicht als Formularfeld wiederverwenden. Das Bedienmuster (Suche, Vorschaubild, Auswahl) ist übernommen, die Abfrage greift auf denselben Bestand zu.
|
||||
@@ -0,0 +1,167 @@
|
||||
# Abschlussbericht Designiteration 1: Markenintegration, Website-Gerüst, Premium-Widgets
|
||||
|
||||
Stand: 18.11.2026. Branch `feature/design-iteration-1` (von `develop`), per Fast-Forward auf `develop` übernommen und über `deploy-test.yml` auf der Testinstanz (Port 3011) bereitgestellt, zuletzt Lauf 4829. **Kein Merge nach `main`.** Commits: `33aaf64` (Umsetzung), `8390dcd` und `7c1caec` (Breitenmessung der Navigation), `d89d4bd` (Markenstrich), `8387cc9` (Bericht), `656f999` (Breitenstufen vor dem ersten Zeichnen, Vorschau, Fußbereichslinie), dazu diese Berichtskorrektur.
|
||||
|
||||
Fachliche Dokumentation: `docs/architektur/designsystem.md` (Tokens, Breitenmodell, Kopfzeile, Markenassets) und `docs/architektur/cms-widget-registry.md` (Varianten, Einstellungen, Randlos-Darstellung, Rollback).
|
||||
|
||||
## 1. Quellen
|
||||
|
||||
Geprüft: `docs/prinzipien/design-prinzipien.md` (mit Vorrang), `docs/strategie/website-cms-seo-marketing-zielkonzept.md`, `docs/architektur/website-cms-marketing-zielarchitektur.md`, `docs/architektur/12_Entscheidungsprotokoll_ADR.md` (lokaler Arbeitsstand, nicht verändert), `docs/architektur/cms-widget-registry.md`, das Brand-UI-Kit unter `docs/Brand-UI-Kit/` (ZIP und entpackte Ordner `01`–`06`, README, Quellenmanifest, Cursor-Übergabe).
|
||||
|
||||
**`00_LUF_Projektkompass.md` liegt weiterhin nicht im Repository.**
|
||||
|
||||
## 2. Ist-Befund vor der Umsetzung
|
||||
|
||||
Gemessen mit echten Scrollbalken (Chromium, lokale Kopie und Testinstanz):
|
||||
|
||||
| Beobachtung | Ursache im Code |
|
||||
|---|---|
|
||||
| Kopfzeile wechselt zwischen 73 und 93 px Höhe | Die Navigation brach mit `flex-wrap: wrap` zwischen etwa 1200 und 1410 px in zwei Zeilen um. Ob sie umbrach, hing davon ab, ob die Seite einen Scrollbalken hatte: Bei 1400 px war die Kopfzeile auf langen Seiten 93 px, auf kurzen 73 px hoch. |
|
||||
| Wortmarke und Inhalt springen waagerecht | Kein `scrollbar-gutter`: Lange Seiten waren 15 px schmaler, der zentrierte Inhalt verschob sich um 7,5 px. |
|
||||
| Wortmarke fluchtet nicht mit dem Inhalt | Kopfzeile im breiten Container (90 rem), Inhalt im Standardcontainer (75 rem): bei 1440 px 32 px gegenüber 112 px Abstand vom Rand. |
|
||||
| Große Bildschirme kaum genutzt | Keine randlosen Bildflächen; die Widgets waren gleichförmige Grundmuster. |
|
||||
| Farben und Schriften | Bereits aus dem Kit übernommen (Iteration 2) und zentral in `tokens.css`; kein zweites Token-System. |
|
||||
| Widgets | Acht Arten mit schlichter Darstellung; nur `hero`, `cards`, `image_text`, `catalog_cards` hatten Varianten. |
|
||||
| Assets | Alle Originale laut Quellenmanifest „public usage not independently verified“. Keine freigegebene Logodatei. SVG-Entwürfe sind neue Vorschläge. |
|
||||
|
||||
Brand-Kit-Ansichten: Der Homepage-Entwurf (`04_visuelle_entwuerfe`) zeigt weiße Kopfzeile mit Wortmarke, große Bildbühne mit Text rechts, gelbe Hauptschaltfläche, Navy-Fußbereich mit grünem Bogen. Die Web-Vorschau (`05_web_preview`) zeigt die Textmarke mit grünem Schild. Die Mobilansicht der Web-Vorschau zeigt das Bild oben und den Text darunter auf heller Fläche; so verhält sich die Markenbühne in schmalen Plätzen. Beide Entwürfe sind laut README nicht freigegeben und enthalten teils erfundene Inhalte; übernommen wurden nur Gestaltungsprinzipien, keine Texte, Preise oder Motive.
|
||||
|
||||
## 3. Aus dem Brand-Kit übernommen
|
||||
|
||||
| Element | Herkunft | Umsetzung |
|
||||
|---|---|---|
|
||||
| Markenfarben Navy, Grün, Grün dunkel, Gelb, Creme | `02_design_tokens` | unverändert in `tokens.css` (seit Iteration 2); Kontraste neu nachgerechnet |
|
||||
| Schriften | Kit-Vorschlag Nunito, Lesetext Source Sans 3 | Nunito 700/800 und Source Sans 3 400/600, beim Build lokal abgelegt, keine Anfrage an Fremdserver |
|
||||
| Textmarke mit grünem Schild „Stark im Alltag“ | `05_web_preview` | Wortmarken-Variante `lockup` für Kopf- und Fußbereich, gekennzeichnet `data-brand-status="vorlaeufig"` |
|
||||
| Gelbe Unterstreichung | `03_svg_entwuerfe/yellow-underline.svg` | Komponente `x-brand.underline`: Markenstrich unter Einstiegs- und Abschnittsüberschriften, aktiver Navigationseintrag |
|
||||
| Signalstrahlen | `03_svg_entwuerfe/yellow-rays.svg` | Komponente `x-brand.rays`: an Bild- und Tafelecken, auf Programmtafeln |
|
||||
| Grüner Bogen | Homepage-Entwurf | Komponente `x-brand.arc`: Abschluss des Fußbereichs |
|
||||
| Bildbühne mit Text auf einer Seite, gelbe Hauptschaltfläche, Outline-Nebenschaltfläche | Homepage-Entwurf | Hero-Variante „Markenbühne“, `.button-brand` |
|
||||
|
||||
Bewusst nicht übernommen: Monogramm (kein Logo, auch nicht als Favicon), Denkblase und Hand (didaktische Symbole der Denkpause, kein Dekor), KI-Konzeptgrafiken und deren Texte, Preise und Produktnamen, eine Nachzeichnung der Filmwortmarke.
|
||||
|
||||
## 4. Verwendete Originalassets
|
||||
|
||||
**Keine.** Die Originalmotive sind nicht zur Veröffentlichung freigegeben. Die Referenzseite auf der Testinstanz verwendet ausschließlich selbst erzeugte, sichtbar beschriftete Platzhalter („PLATZHALTER – Originalmotiv noch nicht freigegeben“, Format und Fokus im Bild).
|
||||
|
||||
Eine lokale Designvorschau mit den verkleinerten Kopien aus `05_web_preview/assets` war vorgesehen. Sie wurde nicht erstellt: Das Kopieren der Motive in den lokalen öffentlichen Medienordner wurde von der Sicherheitsprüfung der Arbeitsumgebung blockiert. Die Wirkung mit echten Motiven ist daher nicht geprüft.
|
||||
|
||||
## 5. Vorläufig oder nicht freigegeben
|
||||
|
||||
| Entscheidung | Status | Freigabe durch |
|
||||
|---|---|---|
|
||||
| Wortmarke (Textmarke mit grünem Schild) | vorläufig; keine Logodatei vorhanden | Lars: finale SVG-/PNG-Wortmarke |
|
||||
| Farbwerte | vorläufig (aus Motiven abgeleitet) | Lars |
|
||||
| Schriften Nunito und Source Sans 3 | vorläufig, Lizenz OFL, lokal ausgeliefert | Lars |
|
||||
| Unterstreichung, Strahlen, Bogen | Kit-Entwürfe, nicht freigegeben | Lars |
|
||||
| Bildmotive für Markenbühne, Bild und Text, Karten | nicht freigegeben; Nutzungsrechte offen | Lars (Rechte, Auswahl, Zuschnitte) |
|
||||
| Themensignaturen der fünf Bereiche | nicht entworfen | Gestaltung und Freigabe offen |
|
||||
| Breitenstufen (44/82/96 rem) und Kopfzeilenhöhen (104/72/64 px) | technische Festlegung dieser Iteration | Abnahme durch Lars |
|
||||
|
||||
## 6. Änderungen am globalen Layout
|
||||
|
||||
- **Konstante Kopfzeile.** Die Box ist immer gleich hoch (104 px ab 75 rem, sonst 64 px) und klebt mit negativem Abstand; die innere Leiste (72 px) klebt oben. Beim Scrollen bleibt nur die kompakte Leiste sichtbar, die Wortmarke wird per `transform` von 1,16-facher auf normale Größe verkleinert. Der Seitenfluss ändert sich nie. Unter `prefers-reduced-motion` gibt es keinen Übergang. Ohne JavaScript klebt die Kopfzeile genauso.
|
||||
- **Navigation bricht nie um.** Stufen: Navigation und Kontozugang mit Beschriftung; sonst Kontozugang nur als Symbol; sonst und immer unter 75 rem Menümodus. Gemessen wird die Desktop-Darstellung an der echten Navigation, und zwar inline direkt nach der Kopfzeile (`window.lufHeaderMode`, nach dem Stylesheet, vor dem Zeichnen). Schon der erste Frame zeigt deshalb die richtige Stufe; `site-nav.js` wiederholt die Messung bei Größenänderungen und nach dem Laden der Schriften. Eine erste Fassung setzte die Stufe erst im Modul; bei 1280 bis 1920 px zeigten die ersten Frames dann kurz die überlaufende Navigation. Das ist behoben.
|
||||
- **Stabile Breite.** `scrollbar-gutter: stable`; ein gemeinsames Breitenmodell (Lesebereich 44 rem, Standard 82 rem, Breit 96 rem, Vollbreite). Kopfzeile, Fußbereich und Inhalt fluchten im Standardraster. `--frame-inset` richtet Inhalte in randlosen Flächen am Raster aus, ohne `100vw`. Die Breitenschlüssel des Editors bleiben, die Bezeichnungen lauten jetzt Lesebereich, Standard, Breit, Vollbreite.
|
||||
- **Menümodus.** Die Fläche beginnt unter dem sichtbaren Teil der Kopfzeile; keine untere Navigationsleiste. Behoben wurde ein schon vorher vorhandener Fehler: Vom Knopf „Schließen“ sprang der Tabulator in den Seiteninhalt. Jetzt läuft der Fokus im Kreis.
|
||||
- **Fußbereich.** Navy-Fläche, Textmarke, Gruppen aus der CMS-Navigation, „Rechtliches“ in einer Grundzeile, grüner Bogen. Endet die Seite mit einer dunklen Fläche, trennt eine feine Linie sie vom Fußbereich. Keine zweite Inhaltsverwaltung, keine erfundenen Texte.
|
||||
- **Widget-Vorschau im Editor.** Ohne Scrollbalken-Reserve (`scrollbar-gutter: auto`); in Chromium war ohnehin kein Rand reserviert, die Angabe sichert andere Browser ab.
|
||||
- **Mitgliederbereich.** Unverändert: schlichte Wortmarke, eigene Navigation. Die Tokens bleiben gemeinsam.
|
||||
|
||||
## 7. Änderungen an den Widgets
|
||||
|
||||
Alle Änderungen sind additiv. Es gibt keine neue Schemaversion und keine Migration, und gespeicherte Widgets bleiben gültig.
|
||||
|
||||
| Widget | Neu |
|
||||
|---|---|
|
||||
| Einstieg (Hero) | **Markenbühne**: Bild über die volle Breite, randlos wenn allein im Abschnitt. Der Text steht auf einer hellen Tafel (Kontrast 14:1 unabhängig vom Motiv), wahlweise links oder rechts. Schmal: Bild 4:3 mit überlappender Tafel. **Editorial**: große Überschrift, Beschreibung und Schaltflächen nebeneinander, optional ein Bildband 21:9. Für alle Varianten: zweite Schaltfläche, Bildausschnitt. Die erste Schaltfläche ist die gelbe Markenschaltfläche. Das Bild des ersten Widgets lädt sofort mit hoher Priorität, alle anderen verzögert. |
|
||||
| Bild und Text | Bildformat (Quer-, Hochformat, Quadrat, Original) und Bildausschnitt; versetzte Markenfläche hinter dem Bild; ab 56 rem Bild betont (7:5); Markenstrich unter dem Titel |
|
||||
| Redaktionelle Karten | Variante **erste Karte hervorgehoben**: ganze Zeile, ab 44 rem Bild neben dem Text. Raster mit großen Bildflächen; Karten ohne Bild bekommen eine gelbe Kante. Kompakte Liste mit kleinem Bild. Die ganze Karte ist über den Titellink klickbar (ein Tabstopp). |
|
||||
| Programm- und Modulkarten | Markentafel statt erfundener Bilder (Navy, auf dunklen Flächen Grün dunkel). Eine einzelne Karte ist ab 40 rem breit, mit Tafel neben dem Text. Unverändert: Fachdaten zur Laufzeit, keine Kopie im CMS, Freigabelogik (ADR-29), keine öffentlichen Modulprofile. |
|
||||
|
||||
Einstellungen sind nur Aufzählungswerte; freie Werte werden abgewiesen. Der Editor zeigt sie mit deutschen Bezeichnungen und dem Hinweis „Vorgabe der Darstellung“.
|
||||
|
||||
**Rollback:** Ein Code-Rollback auf Iteration 2 stellt die neuen Varianten mit der Vorgabe dar; Daten gehen nicht verloren. Der Wiederherstellungsweg aus `cms-widget-registry.md` §9 bleibt für einen Rollback hinter Iteration 2 nötig.
|
||||
|
||||
## 8. Design-Referenzseite
|
||||
|
||||
`/designreferenz` auf der Testinstanz, über die Editoroberfläche angelegt und veröffentlicht. Die Texte stammen aus den Design-Prinzipien (Themenbereiche, Methode, Zielgruppe). Keine Produkte, Preise, Kurse oder Filmfreigaben; Bilder sind gekennzeichnete Platzhalter.
|
||||
|
||||
| Abschnitt | Zeigt |
|
||||
|---|---|
|
||||
| 1 | Markenbühne randlos, zwei Schaltflächen, Bildausschnitt links |
|
||||
| 2 | Bild und Text (breit), Trenner Markenakzent |
|
||||
| 3 | Raster 1 + 3 auf heller Fläche: Überschrift und hervorgehobene Karten (fünf Themenbereiche) |
|
||||
| 4 | Programmkarte aus den Fachdaten auf dunkler Fläche |
|
||||
| 5 | Editorial-Einstieg, großzügiger Abstand, Trenner Linie |
|
||||
| 6 | Raster 2 + 2 auf Markenakzent: Text und kompakte Karten |
|
||||
| Rahmen | Markenkopfzeile, Fußbereich mit Bogen |
|
||||
|
||||
## 9. Tests und Prüfungen
|
||||
|
||||
| Prüfung | Ergebnis |
|
||||
|---|---|
|
||||
| Testsuite lokal (`php artisan test`) | 194 Tests grün, davon 9 neu (`CmsDesignIterationTest` 8, Editortest Markenbühne 1). Bewusst angepasst: zwei Erwartungen an Klassen (`brand brand-lockup`, `button button-brand`). |
|
||||
| Pint | sauber |
|
||||
| CI Feature-Branch | Läufe 4819, 4821, 4823, 4825, 4827, 4828 grün |
|
||||
| Deploy Testinstanz | Läufe 4820, 4822, 4824, 4826, 4829 erfolgreich, `/up` 200 |
|
||||
| Bestehende Seiten (12, Status, Titel, Haupttext) | vor und nach dem Deploy unverändert |
|
||||
| Referenzseite über die Oberfläche (Testinstanz) | 11/11 |
|
||||
| Browser-QA (Testinstanz und lokal) | 18/18 |
|
||||
| Untermenü mit Maus und Tastatur (Testinstanz) | 8/8; der Prüfeintrag ist wieder entfernt |
|
||||
| Geometrie über 5 Seiten bei 1920/1440/1400/1366/1280/1200/390 px (Testinstanz, Lauf 4829) | je Breite genau eine Kopfzeilenhöhe, eine Wortmarken- und eine Navigationsposition |
|
||||
| Erster gezeichneter Frame bei 1280/1366/1440/1920 px, CPU vierfach gedrosselt (Testinstanz) | richtige Stufe ab dem ersten Frame, kein Überlauf, CLS 0 |
|
||||
| Schmale Plätze (lokal): Markenbühne und Bild und Text in 2 + 2, Programmkarten in 1 + 3, kompakte Listen in 1 + 1 + 1 + 1 | sichtbar geprüft bei 1440 und 768 px, ohne Befund; ein Einstieg in einem Platz mit einer Einheit wird beim Speichern abgewiesen |
|
||||
| Fenstergröße ändern 1280 → 1440 → 1100 → 1920 → 390 → 1440 | Moduswechsel korrekt, keine Konsolenfehler, eine Navigation im DOM |
|
||||
|
||||
Die Browser-QA umfasst:
|
||||
- Layoutverschiebung beim Kaltstart und Scrollen (CLS 0 bei 1440 und 390 px)
|
||||
- Ausgangszustand und kompakten Zustand der Kopfzeile bei unverändertem Seitenfluss
|
||||
- Reduced Motion
|
||||
- Mobilmenü mit Fokusfalle und Escape
|
||||
- Tabulatorreihenfolge und sichtbaren Fokus
|
||||
- Ladeverhalten der Bilder (erstes eager/high, Rest lazy)
|
||||
- kein horizontales Scrollen bei 390, 768, 1440 und 2560 px
|
||||
|
||||
Kontraste (berechnet): Navy auf Gelb 10,3:1, Navy auf Creme 14:1, Weiß auf Grün dunkel 5,2:1, Grün dunkel auf Weiß 5,2:1, Fußbereichslinks auf Navy 11:1. Die Grundzeilen-Links erreichen auch auf dem grünen Bogen 4,8:1.
|
||||
|
||||
## 10. Screenshots
|
||||
|
||||
Alle von der Testinstanz mit Platzhaltern, unter `docs/analysen/designiteration-1-screenshots/`:
|
||||
|
||||
1. `01-1440-kopfzeile-markenbuehne.jpg`: Ausgangszustand der Kopfzeile, Markenbühne
|
||||
2. `02-1440-kopfzeile-kompakt.jpg`: kompakte Kopfzeile beim Scrollen
|
||||
3. `03-1440-referenzseite-gesamt.jpg`: ganze Referenzseite, Desktop
|
||||
4. `04-2560-breiter-bildschirm.jpg`: breiter Bildschirm, Bühne randlos, Tafel im Standardraster
|
||||
5. `05-768-referenzseite-gesamt.jpg`: Tablet
|
||||
6. `06-390-referenzseite-gesamt.jpg`: Smartphone
|
||||
7. `07-390-mobilmenue.jpg`: geöffnetes Mobilmenü
|
||||
8. `08-1440-kurze-seite.jpg`: kurze Seite, gleiche Kopfzeile
|
||||
|
||||
## 11. Bekannte Einschränkungen
|
||||
|
||||
- **Navigation der Testinstanz.** Sie hat acht teils lange Einträge. Damit zeigt die Kopfzeile den Kontozugang als Symbol und schaltet zwischen 1280 und 1366 px in den Menümodus. Mit fünf bis sechs kurzen Einträgen wie im Kit-Entwurf bleibt die Navigation bis 75 rem in der Zeile.
|
||||
- **Schriften nachgeladen.** Die Stufe wird vor dem Laden der Webschriften gemessen und danach erneut geprüft. Weicht die Breite der Ersatzschrift stark ab, kann die Stufe einmal wechseln; in den Messungen trat das nicht auf.
|
||||
- **Kopfzeilenverhalten nicht in der Testsuite.** Breitenstufen, Fokusfalle, kompakter Zustand und erster Frame sind nur durch Browser-Skripte geprüft (Playwright, außerhalb des Repositorys). Empfehlung: diese Skripte als Ausgangspunkt der Instanz-Suite (U0) übernehmen, mit Zugangsdaten aus der Umgebung statt aus einer Datei.
|
||||
- **Keine echten Motive.** Wirkung und Zuschnitte mit echten Motiven sind nicht geprüft (siehe Abschnitt 4).
|
||||
- **Keine responsiven Bildvarianten.** Es gibt noch kein `srcset`; Bilder werden in Originalgröße ausgeliefert. Feste Formate verhindern Verschiebungen, nicht aber die Ladegröße. Die Ableitungen gehören in die Hintergrundverarbeitung, weil der Webprozess keine Medien schreibt.
|
||||
- **Programmkarten.** Sie zeigen nur Titel, Kurzbeschreibung und Art. Zuordnung zu Themenbereichen und Umfang stehen nicht im `CatalogEntry` und wären eine Erweiterung des Fachlesers.
|
||||
- **Karten-Raster.** Bei vier Karten neben einer hervorgehobenen ergibt sich je nach Breite eine einzelne Karte in der letzten Zeile.
|
||||
- **Vorschau im Editor.** Die Markenbühne ist höher als die Vorschaufläche (22 rem) und wird dort beschnitten (mit Hinweis). Die Gerätevorschau zeigt sie vollständig.
|
||||
- **Build-Warnung.** `npm run build` meldet „Some chunks are larger than 500 kB“. Ob die Warnung schon vor dieser Iteration auftrat, ist nicht geprüft; diese Iteration ergänzt nur wenige Kilobyte Skript.
|
||||
|
||||
## 12. Empfehlungen für die nächste Designiteration
|
||||
|
||||
1. **Freigaben einholen:** Wortmarke als SVG, Farbwerte, Schriften, drei bis fünf Motive mit geklärten Rechten (Titel und Outro eignen sich für die Markenbühne, das Outro mit freier rechter Fläche besonders). Dann nur `tokens.css`, `components/site/brand.blade.php` und die Medien austauschen.
|
||||
2. **Bildableitungen in der Hintergrundverarbeitung:** WebP/AVIF in 3–4 Breiten mit `srcset`/`sizes` und Fokuspunkt; Einstieg mit `preload`.
|
||||
3. **Themensignaturen:** fünf Symbole und Tönungen gestalten, dann in Karten, Programmtafeln und Themenseiten einsetzen.
|
||||
4. **Programmkarten erweitern:** Themenbereiche und Umfang aus dem veröffentlichten Fachstand im Leser ergänzen; Test, dass nichts Unveröffentlichtes durchsickert.
|
||||
5. **Navigation redaktionell auf fünf bis sechs Hauptpunkte straffen** (Design-Prinzipien §7: Konzept, Themenbereiche, Programme, Anwendung, Angebote, Mitgliederbereich).
|
||||
6. **Startseite** aus der Referenz ableiten (redaktionelle Entscheidung, keine technische).
|
||||
7. Messung mit Prüfwerkzeug (axe, Lighthouse) an der gerenderten Seite vor der Farbfreigabe.
|
||||
|
||||
## 13. Auf der Testinstanz angelegt
|
||||
|
||||
- Seite `/designreferenz` (veröffentlicht, eine Revision).
|
||||
- Platzhalterbilder im öffentlichen Medienbereich: `cms/platzhalter-markenbuehne-*`, `cms/platzhalter-bild-text-*`, `cms/platzhalter-karte-1/2/3-*` (Dateinamen mit Zufallssuffix).
|
||||
- Prüfeintrag „Referenz Abschnitte (Prüfeintrag)“ in der Navigation: zweimal angelegt und jeweils wieder gelöscht. Ein Durchlauf brach ab und hinterließ den Eintrag kurzzeitig; der nächste Durchlauf hat ihn entfernt.
|
||||