Compare commits

..
Author SHA1 Message Date
LarsandClaude Sonnet 5.5 5233b96c42 Biete in Bild und Text einen Bildanteil, Bild ohne Text und ein Video auf dem Bild an
Deploy Test / test (push) Successful in 5m44s
CI Feature / test (push) Successful in 6m17s
Deploy Test / deploy (push) Successful in 41s
Neue Einstellung "Bildanteil" (Bild zu Text von 1:2 bis 2:1, nur im zweispaltigen Stand ab 900 px; ohne Wert bleibt die bisherige Verteilung). Der Text ist nur noch Pflicht, solange kein Bild gewählt ist; ein Bild darf allein über die ganze Breite stehen. Optional ein Video (refs.video, ein Film aus dem Medienmanager, gewählt über den gemeinsamen Picker): Der für die Website freigegebene Clip spielt auf dem Bild beim Überfahren stumm und per Klick mit Ton wie auf der Medienkarte (CardClip, card-clip.js). Ohne Versionssprung; gespeicherte Seiten bleiben unverändert.

Die Pflichtregel für den Text wird bewusst gelockert: "Bitte einen Text eingeben" gilt nur noch ohne Bild.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-26 11:02:18 +01:00
15 changed files with 603 additions and 19 deletions

No files matched your search

@@ -120,6 +120,12 @@ public function resolve(mixed $id, bool $preview): array
];
}
/** Ein Film, der nicht archiviert, nicht gesperrt und keine Traineranleitung ist (auch für den Medienwähler). */
public function isSelectable(ContentElement $element): bool
{
return $this->allowed($element);
}
/** Ein Film, der nicht archiviert, nicht gesperrt und keine Traineranleitung ist. */
private function allowed(ContentElement $element): bool
{
+100 -10
View File
@@ -4,6 +4,7 @@
use App\Domain\Cms\Widgets\RenderContext;
use App\Domain\Cms\Widgets\Support\HeadingAccent;
use App\Domain\Cms\Widgets\Support\HeroVideo;
use App\Domain\Cms\Widgets\Support\ImageRefFields;
use App\Domain\Cms\Widgets\Support\PremiumFields;
use App\Domain\Cms\Widgets\Support\PublicMedia;
@@ -13,6 +14,7 @@
use App\Domain\Cms\Widgets\WidgetType;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\ViewField;
use Filament\Schemas\Components\Group;
/**
@@ -20,6 +22,11 @@
*
* Version 1 (Bestand): data {image, alt, body} mit Klartext.
* Version 2: data {title, body (formatierter Text), alt}, refs {image}, Varianten Bild links/rechts.
* Ohne Versionssprung ergänzt (ältere Revisionen bleiben unverändert darstellbar): Bildanteil (settings.image_share),
* Bild ohne Text (Text ist nicht mehr Pflicht, wenn ein Bild gewählt ist) und ein Video (refs.video, ein Film aus dem
* Medienmanager): Das freigegebene Video (Trailer, Vorschauclip oder Website-Datei, Regel CardClip) spielt auf dem Bild
* beim Überfahren mit der Maus stumm und per Klick oder Schaltfläche mit Ton, wie auf der Medienkarte.
*
* 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.
@@ -110,10 +117,25 @@ public function optionIcons(): array
];
}
/**
* Bildanteil an der Breite im zweispaltigen Stand (ab 900 px Containerbreite): Bild- und Textspalte als Verhältnis.
* Ohne Wert gilt die bisherige Verteilung (Text 1,1 : Bild 0,9, je nach Bildseite).
*
* @var array<string, string>
*/
public const IMAGE_SHARE = [
'third' => 'Schmales Bild (ein Drittel Bild, zwei Drittel Text)',
'two_fifths' => 'Eher schmales Bild (40 % Bild, 60 % Text)',
'half' => 'Gleich breit (je die Hälfte)',
'three_fifths' => 'Eher breites Bild (60 % Bild, 40 % Text)',
'two_thirds' => 'Breites Bild (zwei Drittel Bild, ein Drittel Text)',
];
public function settings(): array
{
return [
'surface' => ['cream' => 'Creme (Markenfläche)', 'clear' => 'Ohne eigene Fläche', 'navy' => 'Navy (dunkel)'],
'image_share' => self::IMAGE_SHARE,
'heading_level' => PremiumFields::HEADING_LEVELS,
'symbol' => HeadingAccent::symbols(),
'symbol_size' => HeadingAccent::SIZE,
@@ -124,7 +146,7 @@ public function settings(): array
public function settingGroups(): array
{
return [
'Aussehen' => ['surface', 'symbol', 'symbol_size', 'symbol_align'],
'Aussehen' => ['surface', 'image_share', 'symbol', 'symbol_size', 'symbol_align'],
'Seitenstruktur' => ['heading_level'],
];
}
@@ -133,6 +155,7 @@ public function settingLabels(): array
{
return [
'surface' => ['Hintergrund des Widgets', 'Unabhängig vom Abschnittshintergrund. „Ohne eigene Fläche“ übernimmt den Abschnitt.'],
'image_share' => ['Bildanteil', 'Verhältnis von Bild und Text nebeneinander. Gilt erst ab 900 px Breite des Widgets; schmaler steht das Bild über dem Text. Ohne Auswahl bleibt es bei der bisherigen Verteilung (Text etwas breiter als das Bild). Ohne Text füllt das Bild die ganze Breite.'],
'symbol' => HeadingAccent::SYMBOL_LABEL,
'symbol_size' => HeadingAccent::SIZE_LABEL,
'symbol_align' => HeadingAccent::ALIGN_LABEL,
@@ -180,13 +203,14 @@ public function dataRules(): array
{
return [
'title' => ['nullable', 'string', 'max:160'],
'body' => ['required', 'string', 'max:40000'],
// Der Text ist nur Pflicht, solange kein Bild gewählt ist (clean); ein Bild darf allein stehen.
'body' => ['nullable', 'string', 'max:40000'],
] + PremiumFields::rules();
}
public function refRules(): array
{
return ImageRefFields::rules();
return ImageRefFields::rules() + ['video' => ['nullable']];
}
public function dataFields(): array
@@ -196,7 +220,7 @@ public function dataFields(): array
TextInput::make('title')->label('Überschrift')->maxLength(160)->live(onBlur: true),
RichEditor::make('body')
->label('Text')
->required()
->helperText('Leer lassen, wenn nur das Bild gezeigt werden soll. Ohne Text, Überschrift, Label und Schaltflächen füllt das Bild die ganze Breite.')
->live(onBlur: true)
->toolbarButtons(RichText::TOOLBAR),
PremiumFields::ctaFields(),
@@ -207,7 +231,16 @@ public function dataFields(): array
public function refFields(): array
{
return ImageRefFields::fields(live: true);
return [...ImageRefFields::fields(live: true), $this->videoField()];
}
private function videoField(): ViewField
{
return ViewField::make('video')
->live()
->label('Video (optional)')
->view('filament.cms.video-feld')
->helperText('Ein Film aus dem Medienmanager, über denselben Wähler wie das Bild. Das Bild bleibt stehen; das Video spielt darauf beim Überfahren stumm und per Klick oder Schaltfläche mit Ton, nur wenn ein Trailer, Vorschauclip oder die Website-Datei des Films für die Website freigegeben ist. Die Auswahl gibt nichts frei.');
}
public function editorSchema(): array
@@ -234,13 +267,47 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
$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.');
$video = app(HeroVideo::class)->clean($refs['video'] ?? null, $errors);
$video === null ? $refs = array_diff_key($refs, ['video' => true]) : $refs['video'] = $video;
if ($video !== null && $refs['image'] === null) {
$errors->add('refs.image', 'Bitte auch ein Bild wählen: Es steht, bis das Video startet.');
}
if ($refs['image'] === null && ! self::hasCopy($data)) {
$errors->add('data.body', 'Bitte einen Text eingeben oder ein Bild wählen.');
}
return [$data, $refs];
}
/**
* Ob neben dem Bild etwas zu lesen ist: Text, Überschrift, Label oder Schaltfläche. Ohne bleibt das Bild allein.
*
* @param array<string, mixed> $data
*/
public static function hasCopy(array $data): bool
{
$body = is_string($data['body'] ?? null) ? RichText::sanitize($data['body']) : '';
return ! RichText::isBlank($body)
|| filled($data['title'] ?? null)
|| filled($data['eyebrow'] ?? null)
|| PremiumFields::actions($data) !== [];
}
/**
* Gültiger Bildanteil oder null (bisherige Verteilung).
*
* @param array<string, mixed> $settings
*/
public static function imageShare(array $settings): ?string
{
$share = $settings['image_share'] ?? null;
return is_string($share) && array_key_exists($share, self::IMAGE_SHARE) ? $share : null;
}
public function resolve(array $widget, RenderContext $context): array
{
$surface = $widget['settings']['surface'] ?? 'cream';
@@ -248,10 +315,23 @@ public function resolve(array $widget, RenderContext $context): array
$images = app(WebsiteImage::class);
$image = $widget['refs']['image'] ?? null;
$imageUrl = $images->url($image, $context->preview);
$imageAlt = $images->alt($image, $widget['data']['alt'] ?? null);
$hasCopy = self::hasCopy($widget['data'] ?? []);
$video = app(HeroVideo::class)->resolve($widget['refs']['video'] ?? null, $context->preview);
// Ohne Bild gibt es nichts, worauf das Video stehen könnte; die Redaktion erfährt es in der Vorschau.
if ($imageUrl === null && $video['url'] !== null) {
$video = ['url' => null, 'title' => $video['title'], 'notice' => $context->preview ? 'Das Video braucht ein Bild: Es steht, bis das Video startet. Bitte ein Bild wählen.' : null];
}
return [
'imageUrl' => $images->url($image, $context->preview),
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
'imageUrl' => $imageUrl,
'imageAlt' => $imageAlt,
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
'video' => $video,
'hasCopy' => $hasCopy,
'imageShare' => self::imageShare($widget['settings'] ?? []),
'body' => RichText::sanitize(is_string($widget['data']['body'] ?? null) ? $widget['data']['body'] : ''),
'actions' => PremiumFields::actions($widget['data']),
'focus' => PremiumFields::focus($widget['data'], 64, 43),
@@ -270,6 +350,16 @@ public function summary(array $widget): string
{
$title = $widget['data']['title'] ?? null;
return filled($title) ? (string) $title : RichText::excerpt($widget['data']['body'] ?? '');
if (filled($title)) {
return (string) $title;
}
$excerpt = RichText::excerpt($widget['data']['body'] ?? '');
if ($excerpt !== '') {
return $excerpt;
}
return filled($widget['data']['alt'] ?? null) ? 'Bild: '.$widget['data']['alt'] : 'Bild';
}
}
+13
View File
@@ -7,6 +7,7 @@
use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\Pillar;
use App\Domain\Cms\Catalog\PublicMaterialReader;
use App\Domain\Cms\Widgets\Support\HeroVideo;
use App\Domain\Cms\Widgets\Support\WebsiteImage;
use App\Http\Controllers\ContentPreviewController;
@@ -127,6 +128,18 @@ public function pickerResult(): array
$result = app(EditorialCatalog::class)->presentationBrowse($this->pickerQuery, $this->pickerKind);
$result = $this->filterByMaterialart($result);
// CMS: nur Filme, die als Video wählbar sind (nicht archiviert, nicht gesperrt, keine Traineranleitung).
if ($this->pickerPurpose === 'website-video') {
$ids = array_values(array_filter(array_map(fn (array $item): int => (int) ($item['element_id'] ?? 0), $result['items'])));
$elements = ContentElement::query()->with('editorialContentKind')->whereKey($ids)->get()->keyBy('id');
$videos = app(HeroVideo::class);
$result['items'] = array_values(array_filter($result['items'], function (array $item) use ($elements, $videos): bool {
$element = $elements->get((int) ($item['element_id'] ?? 0));
return $element !== null && $videos->isSelectable($element);
}));
}
// CMS: nur Bilder, die als Website-Bild wählbar sind (keine vertraulichen Arten, nicht archiviert).
if ($this->pickerPurpose === 'website-bild') {
$ids = array_values(array_filter(array_map(fn (array $item): int => (int) ($item['element_id'] ?? 0), $result['items'])));
+24 -5
View File
@@ -5,6 +5,7 @@
use App\Domain\Catalog\Composition;
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\DomainRuleException;
use App\Domain\Cms\Widgets\Support\HeroVideo;
use App\Domain\Cms\Widgets\Support\WebsiteImage;
use App\Domain\Media\CompositionStill;
use App\Domain\Media\FilmStill;
@@ -37,6 +38,22 @@ public function openWebsiteImagePicker(string $pfad): void
$this->forceRenderForPicker();
}
/**
* Bild und Text: ein Film aus dem Medienmanager als Video wählen. Gleicher Wähler wie beim Bild, nur mit Filmen; das
* Ziel ist ausschließlich ein Videofeld (…video). Die Auswahl gibt nichts frei.
*/
public function openWebsiteVideoPicker(string $pfad): void
{
if (preg_match('/^(data|mountedActions\.\d+\.data)(\.[A-Za-z0-9_-]+)+\.video$/', $pfad) !== 1) {
return;
}
$this->resetPicker('website-video');
$this->pickerKind = 'film';
$this->bildZiel = $pfad;
$this->forceRenderForPicker();
}
/**
* Medien- und Materialkarte: das Vorschaubild des Films als Bild für die Website übernehmen. Es entsteht ein Bild
* im Medienmanager (einmal gespeichert), das im Bildfeld ausgewählt wird. Die Datei des Films bleibt geschützt.
@@ -197,8 +214,10 @@ public function confirmPicker(): void
$row = app(EditorialCatalog::class)->rowForTarget((string) $target, 0, allowDraft: true);
$element = isset($row['element_id']) ? ContentElement::query()->find((int) $row['element_id']) : null;
if (! $element instanceof ContentElement || ! WebsiteImage::isSelectable($element)) {
Notification::make()->danger()->title('Dieses Medium kann nicht als Website-Bild gewählt werden.')->send();
$video = $this->pickerPurpose === 'website-video';
if ($video ? ! ($element instanceof ContentElement && app(HeroVideo::class)->isSelectable($element)) : ! ($element instanceof ContentElement && WebsiteImage::isSelectable($element))) {
Notification::make()->danger()->title($video ? 'Dieser Film kann nicht als Video gewählt werden.' : 'Dieses Medium kann nicht als Website-Bild gewählt werden.')->send();
return;
}
@@ -212,17 +231,17 @@ public function confirmPicker(): void
*/
public function pickerKinds(): array
{
return ['bild' => 'Bilder'];
return $this->pickerPurpose === 'website-video' ? ['film' => 'Filme'] : ['bild' => 'Bilder'];
}
public function pickerTitle(): string
{
return 'Bild aus dem Medienmanager';
return $this->pickerPurpose === 'website-video' ? 'Video aus dem Medienmanager' : 'Bild aus dem Medienmanager';
}
public function pickerConfirmLabel(): string
{
return 'Bild übernehmen';
return $this->pickerPurpose === 'website-video' ? 'Video übernehmen' : 'Bild übernehmen';
}
/**
+6 -1
View File
@@ -73,7 +73,7 @@ ## 4. Registrierte Widget-Arten
| `hero` | Einstieg (Hero), Premium nach Kit v1.6 | 2 | `photo_split` (Foto mit Textfläche), `editorial_solid` (Navy-Markenfläche) | 3, 4 | `compact` (Kompakt), `normal` (Standard, Vorgabe), `large` (Großzügig); Mindesthöhe aus der Größenskala (ADR-44) | `refs.image`, `refs.video` (optional) |
| `heading` | Überschrift und Einleitung | 1 | `standard` | 1–4 | – | – |
| `prose` | Fließtext | 1 | `standard` | 1–4 | – | – |
| `image_text` | Bild und Text, Premium nach Kit v1.6 | 3 | `image_left`, `image_right` (Bildseite) | 1–4 | `compact` (Kompakt), `normal` (Standard, Vorgabe), `spacious` (Großzügig) | `refs.image` |
| `image_text` | Bild und Text, Premium nach Kit v1.6 | 3 | `image_left`, `image_right` (Bildseite) | 1–4 | `compact` (Kompakt), `normal` (Standard, Vorgabe), `spacious` (Großzügig) | `refs.image`, optional `refs.video` |
| `cards` | Redaktionelle Karten | 1 | `standard` (Raster), `compact` (Liste), `featured` (erste Karte hervorgehoben) | 1–4 | – | Bild je Karte in `data.items[].image` |
| `features` | Merkmalszeile (1–12 Merkmale mit Symbol, Kurztitel, Satz, optionalem Link) | 1 | `standard` | 1–4 | – | – |
| `catalog_cards` | Programm- und Modulkarten | 1 | `standard`, `compact` | 1–4 | – | `refs.items[] = {type: composition, id}` |
@@ -110,6 +110,11 @@ ## 4. Registrierte Widget-Arten
**Merkmalszeile.** `data.items[]` mit `symbol` (Auswahl wie oben), `title` (höchstens 60 Zeichen) und optional `text` (höchstens 200 Zeichen), `url` (über `SafeUrl`) und `link_label` (höchstens 60 Zeichen, Vorgabe „Mehr erfahren“, wird ohne `url` verworfen); ein bis zwölf Einträge, in jeder Platzbreite (1–4 Einheiten). Die Spaltenzahl ergibt sich aus der Anzahl der Einträge und der tatsächlichen Breite (Raster ab 12 rem je Merkmal), nicht aus einer eigenen Einstellung. `settings.link_style` bestimmt für alle Links des Widgets die Darstellung: `text` (kleiner Textlink, Vorgabe) oder `pill` (Pille). Weitere Einstellungen: `settings.align` (`left` Vorgabe, `center`, `right`; richtet Symbol, Titel, Satz und Link aus), `settings.symbol_size` (`small` 2,5 rem, `medium` 3,5 rem Vorgabe, `large` 5 rem, `xlarge` 7 rem) `settings.symbol_position` (`top` über dem Text, Vorgabe; `left` oder `right` neben Titel, Satz und Link; die Klasse `lf-features--symbol-<lage>` erscheint nur bei Abweichung, Titel, Satz und Link stehen dann in `lf-features__body`, das Symbol sitzt oben bündig mit dem Titel, Mindestbreite je Merkmal 18 rem statt 12 rem, darunter stehen die Merkmale untereinander) und `settings.divider` = `line` (feiner Strich in der Mitte der Lücke: senkrecht zwischen Spalten, waagerecht zwischen Zeilen und bei untereinander stehenden Merkmalen; die Liste schneidet die Striche am Rand ab). Ungültige gespeicherte Werte fallen auf die Vorgaben zurück (`FeaturesWidget::layout`). Der zugängliche Name des Links nennt das Merkmal („Mehr erfahren: Kurze Filme“).
**Abweichungen vom Kit (bewusst):**
**Bild und Text: Bildanteil, Bild ohne Text, Video.** Ohne Versionssprung ergänzt; ältere Revisionen und Seiten ohne die neuen Felder stellen sich unverändert dar (Test `CmsImageTextMediaTest`).
- `settings.image_share` = `third`, `two_fifths`, `half`, `three_fifths`, `two_thirds` (Bild : Text = 1:2, 2:3, 1:1, 3:2, 2:1). Wirkt nur im zweispaltigen Stand ab 900 px Containerbreite und nur mit Bild und Text; die Klassen `lf-bt--shared lf-bt--share-<wert>` erscheinen nur dann. Ohne Wert bleibt die bisherige Verteilung (Text 1,1 : Bild 0,9, links/rechts je nach Bildseite). Die Spurbreiten stehen als `fr`-Werte in `--bt-img` und `--bt-txt` (in `calc()` sind `fr`-Einheiten nicht zulässig).
- Bild ohne Text: `data.body` ist nur Pflicht, solange kein Bild gewählt ist. Das Widget braucht Bild oder (Text, Überschrift, Label oder Schaltfläche) (`ImageTextWidget::hasCopy`). Ohne Text, Überschrift, Label und Schaltflächen steht das Bild allein über die ganze Breite (`lf-bt--without-text`, Seitenverhältnis nach der Höhen-Einstellung: Kompakt 3:1, Standard 21:9, Großzügig 16:9 ab 900 px); ein Bildanteil entfällt dann. Ohne Bild und ohne Text rendert das Widget nichts.
- Video: `refs.video` ist die Kennung eines Films aus dem Medienmanager (leer: Schlüssel entfällt). Gewählt wird über denselben visuellen Picker wie das Bild (`ChoosesWebsiteImages::openWebsiteVideoPicker`, Zweck `website-video`, nur Filme; Ziel nur ein Feld `…video`). Geprüft wird wie beim Einstieg (`HeroVideo::clean`: Film, nicht archiviert, keine Traineranleitung), und ein Video braucht ein Bild, das bis zum Start steht. Abgespielt wird nur ein für die Website freigegebener Clip nach der Regel der Medienkarte (`CardClip`: Trailer, sonst Vorschauclip, sonst die eigene Website-Datei des Films); der vollständige Film und nicht freigegebene Clips kommen nie über das Widget, die Auswahl gibt nichts frei. Die Darstellung nutzt `card-clip.js` und die Bausteine der Premium-Karte: Das `<video>` liegt auf dem Bild (`.lf-bt__media[data-card-clip]`), startet beim Überfahren mit der Maus stumm in Schleife und per Klick, Tipp oder Schaltfläche mit Ton (zweiter Klick hält an); bei „reduzierte Bewegung“ und im Datensparmodus nur auf Bedienung. Ohne freigegebenen Clip bleibt es beim Bild; die Redaktionsvorschau erklärt, warum.
- Kennungen bleiben `hero` und `image_text`, nicht `lf-brand-hero`/`lf-editorial-bild-text`; Varianten `photo_split`/`editorial_solid` mit Unterstrich, weil Variantenkennungen `^[a-z][a-z0-9_]*$` folgen.
- Bildseite von Bild und Text bleibt die Variante (`image_left/right`), nicht zusätzlich `settings.image_side`, damit es keine doppelte Einstellung gibt.
- Bildfokus in `data` statt `settings.image_focus`, weil Einstellungen nur Aufzählungswerte tragen.
@@ -0,0 +1,15 @@
# Abnahme: Bild und Text, Bildanteil, Bild ohne Text, Video (2026-11-26)
**Geprüft wurde nur die Ausgabe, lokal und nicht auf luf-test:** Die Ansicht des Widgets wurde mit den gebauten Styles und Skripten in Chromium gerendert (Playwright), mit einem Prüfbild und einem erzeugten Prüfvideo, in 1240 px und 440 px Fensterbreite. Der Seiteneditor (Einstellung „Bildanteil“, Videofeld, Videowähler) wurde noch nicht im Browser geprüft; das steht nach dem Deploy auf Test aus. Den Videowähler deckt ein Livewire-Test ab (`CmsImageTextMediaTest`).
Geprüft:
- **Bildanteil** (ab 900 px Breite): Vorgabe unverändert; Ein Drittel, Gleich breit und Zwei Drittel stellen die Spalten wie benannt, bei Bild links und Bild rechts (siehe Bild „breit“). Unter 900 px bleibt es beim Stapel, der Bildanteil wirkt nicht.
- **Bild ohne Text:** Das Bild steht allein über die ganze Breite, ohne leere Textspalte (Bild „breit“, vorletzter Fall).
- **Video** (mit und ohne Text): Schaltfläche oben rechts auf dem Bild. Beim Überfahren mit der Maus startet der Clip stumm und in Schleife über dem Bild (gleicher Ausschnitt, gleiche Ecken). Ein Klick schaltet auf Ton ohne Schleife, der Clip läuft auch nach dem Verlassen weiter, ein zweiter Klick hält an. Wie auf der Medienkarte.
- Keine Konsolenfehler.
Nicht geprüft: Screenreader, Touch (Tipp), Browser außer Chromium, ein echter freigegebener Clip aus dem Medienmanager.
| Breit | Video läuft | Schmal |
|---|---|---|
| ![Breit](bild-text-medien/breit.png) | ![Video läuft](bild-text-medien/video-laeuft.png) | ![Schmal](bild-text-medien/schmal.png) |
Binary file not shown.

After

Width:  |  Height:  |  Size: 673 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

+36
View File
@@ -182,6 +182,28 @@ .lf-bt--height-compact .lf-bt__image { aspect-ratio: 16 / 9; }
.lf-bt--height-spacious .lf-bt__image { aspect-ratio: 4 / 3; }
.lf-bt--without-image { grid-template-columns: minmax(0, 1fr); }
/*
* Bildanteil (Einstellung „Bildanteil“): Verhältnis der Bild- zur Textspalte, nur im zweispaltigen Stand (ab 900 px, siehe
* unten). Ohne Einstellung bleibt die bisherige Verteilung. Die Klassen erscheinen nur mit Bild und Text.
*/
.lf-bt--share-third { --bt-img: 1fr; --bt-txt: 2fr; }
.lf-bt--share-two_fifths { --bt-img: 2fr; --bt-txt: 3fr; }
.lf-bt--share-half { --bt-img: 1fr; --bt-txt: 1fr; }
.lf-bt--share-three_fifths { --bt-img: 3fr; --bt-txt: 2fr; }
.lf-bt--share-two_thirds { --bt-img: 2fr; --bt-txt: 1fr; }
/* Ohne Text steht das Bild allein über die ganze Breite (Bildanteil entfällt). */
.lf-bt--without-text { grid-template-columns: minmax(0, 1fr); }
/*
* Video auf dem Bild (CardClip, resources/js/card-clip.js, Bausteine der Premium-Karte): Der Clip liegt über dem Bild, mit
* demselben Ausschnitt und denselben Ecken, und blendet erst mit dem ersten Bild ein; bis dahin bleibt das Bild stehen.
*/
.lf-bt__media > .lf-pc__clip {
object-position: var(--bt-focus-x) var(--bt-focus-y);
border-radius: clamp(0.78rem, 1.8cqi, 1.3rem);
}
/* Schmale Plätze: vollständiger Text und Links, keine erzwungene Höhe. */
@container lf-bt (max-width: 539.99px) {
.lf-bt__actions { display: grid; grid-template-columns: minmax(0, 1fr); }
@@ -218,6 +240,20 @@ @container lf-bt (min-width: 900px) {
.lf-bt--image-left .lf-bt__media { order: -1; }
.lf-bt__image { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; max-block-size: none; aspect-ratio: auto; }
.lf-bt--without-image { grid-template-columns: minmax(0, 1fr); }
/* Bildanteil: erste Spur ist die linke; bei „Bild links“ ist das die Bildspalte, sonst die Textspalte. */
.lf-bt--shared.lf-bt--image-left { grid-template-columns: minmax(0, var(--bt-img)) minmax(0, var(--bt-txt)); }
.lf-bt--shared.lf-bt--image-right { grid-template-columns: minmax(0, var(--bt-txt)) minmax(0, var(--bt-img)); }
/*
* Bild ohne Text: Eine Spalte über die volle Breite. Das Bild bestimmt hier seine Höhe selbst (Seitenverhältnis nach
* der Höhen-Einstellung), statt eine Fläche neben dem Text zu füllen.
*/
.lf-bt--without-text { grid-template-columns: minmax(0, 1fr); }
.lf-bt--without-text .lf-bt__media { min-block-size: 0; }
.lf-bt--without-text .lf-bt__image { position: static; inset: auto; block-size: auto; max-block-size: none; aspect-ratio: 21 / 9; }
.lf-bt--without-text.lf-bt--height-compact .lf-bt__image { aspect-ratio: 3 / 1; }
.lf-bt--without-text.lf-bt--height-spacious .lf-bt__image { aspect-ratio: 16 / 9; }
}
@media (prefers-reduced-motion: reduce) {
@@ -1,4 +1,4 @@
{{-- Gemeinsamer Picker für Website-Bilder im CMS (ChoosesWebsiteImages). --}}
@if ($this->pickerOpen && $this->pickerPurpose === 'website-bild')
{{-- Gemeinsamer Picker für Website-Bilder und Videos im CMS (ChoosesWebsiteImages). --}}
@if ($this->pickerOpen && in_array($this->pickerPurpose, ['website-bild', 'website-video'], true))
@include('filament.verwaltung.picker')
@endif
@@ -0,0 +1,26 @@
{{-- Videofeld im CMS (Bild und Text): Auswahl eines Films über den gemeinsamen Picker (ChoosesWebsiteImages::openWebsiteVideoPicker). Gespeichert wird die Kennung des Films; abgespielt wird nur ein für die Website freigegebener Clip (HeroVideo, CardClip). --}}
@php
$wert = $getState();
$pfad = $getStatePath();
$mitPicker = method_exists($getLivewire(), 'openWebsiteVideoPicker');
$titel = filled($wert) ? app(\App\Domain\Cms\Widgets\Support\HeroVideo::class)->labelFor($wert) : null;
@endphp
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
<div class="luf-bild-feld">
@if (blank($wert))
<span class="luf-bild-feld-leer">Kein Video gewählt.</span>
@else
<span class="luf-bild-feld-leer" data-video-status>{{ $titel ?? 'Dieses Medium gibt es nicht mehr.' }}</span>
@endif
@if ($mitPicker)
<x-filament::button color="gray" size="sm" icon="heroicon-o-film" wire:click="openWebsiteVideoPicker({{ \Illuminate\Support\Js::from($pfad) }})">
{{ blank($wert) ? 'Video auswählen' : 'Anderes Video wählen' }}
</x-filament::button>
@endif
@if (filled($wert))
<x-filament::button color="gray" size="sm" outlined wire:click="$set({{ \Illuminate\Support\Js::from($pfad) }}, null)">
Video entfernen
</x-filament::button>
@endif
</div>
</x-dynamic-component>
@@ -243,6 +243,8 @@
{{ $zweck === 'praesentation' ? 'Diese Rolle hat nur ein Medium. ' : '' }}Erst „Austauschen“ ersetzt die Zuordnung an derselben Stelle. Abbrechen lässt sie unverändert.
@elseif ($zweck === 'website-bild')
Das gewählte Bild wird in diesen Platz des Seitenentwurfs übernommen. Öffentlich erscheint es nur mit Website-Freigabe; die Auswahl gibt es nicht frei.
@elseif ($zweck === 'website-video')
Der gewählte Film wird als Video in diesen Platz des Seitenentwurfs übernommen. Öffentlich spielt nur ein für die Website freigegebener Clip (Trailer, Vorschauclip oder Website-Datei); die Auswahl gibt nichts frei.
@elseif ($zweck === 'vorschaubild')
Das gewählte Bild wird als Vorschaubild übernommen. Es wird dadurch nicht für die Website freigegeben.
@elseif ($zweck === 'aufbau')
+19 -1
View File
@@ -3,12 +3,20 @@
Darstellung nach tatsächlicher Containerbreite: unter 540 px gestapelt, 540–899 px flacher Bildstreifen,
ab 900 px zweispaltig mit Bild links oder rechts (Variante). Die Höhe ändert Bildproportion und Abstände,
nie die zulässige Textmenge. Der Text ist bereits bereinigter formatierter Text (RichText::sanitize).
Der Bildanteil (imageShare) gilt nur im zweispaltigen Stand. Ohne Text, Überschrift, Label und Schaltflächen
(hasCopy) steht das Bild allein über die ganze Breite. Ein freigegebenes Video (video.url, CardClip) liegt über dem
Bild und spielt dort wie auf der Medienkarte (resources/js/card-clip.js); ohne freigegebenen Clip bleibt es beim Bild.
--}}
@php
$side = $variant === 'image_left' ? 'left' : 'right';
$heightClass = in_array($height, ['compact', 'normal', 'spacious'], true) ? $height : 'normal';
$tag = \App\Domain\Cms\Widgets\Support\PremiumFields::headingTag($settings, ! empty($first));
$hasCopy = $hasCopy ?? true;
$imageShare = $imageShare ?? null;
$clipUrl = $imageUrl ? ($video['url'] ?? null) : null;
$clipTitle = (string) ($video['title'] ?? '');
@endphp
@if ($imageUrl || $hasCopy)
<div class="lf-bt-host">
<div @class([
'lf-bt',
@@ -16,7 +24,11 @@
'lf-bt--image-'.$side,
'lf-bt--height-'.$heightClass,
'lf-bt--without-image' => ! $imageUrl,
'lf-bt--without-text' => ! $hasCopy,
'lf-bt--shared' => $imageShare !== null && $imageUrl && $hasCopy,
'lf-bt--share-'.$imageShare => $imageShare !== null && $imageUrl && $hasCopy,
]) style="--bt-focus-x: {{ $focus['x'] }}%; --bt-focus-y: {{ $focus['y'] }}%">
@if ($hasCopy)
<div class="lf-bt__copy">
@php($lead = \App\Domain\Cms\Widgets\Support\HeadingAccent::lead($settings))
@if ($lead['side'] !== null)<div class="lf-lead lf-lead--{{ $lead['side'] }} lf-lead--{{ $lead['align'] }}"><x-brand.symbol :name="$lead['symbol']" class="lf-lead__symbol" /><div class="lf-lead__body">@endif
@@ -41,11 +53,17 @@
@endif
@if ($lead['side'] !== null)</div></div>@endif
</div>
@endif
@if ($imageUrl)
<div class="lf-bt__media">
<div class="lf-bt__media" @if ($clipUrl !== null) data-card-clip data-clip-src="{{ $clipUrl }}" data-clip-title="{{ $clipTitle }}" @endif>
<img class="lf-bt__image" src="{{ $imageUrl }}" alt="{{ $imageAlt ?? '' }}" @if (! empty($first)) loading="eager" fetchpriority="high" @else loading="lazy" @endif decoding="async">
@include('widgets.partials.card-clip')
</div>
@endif
</div>
</div>
@endif
@include('widgets.partials.image-notice')
@if ($context->preview && ! empty($video['notice']))
<p class="preview-note">{{ $video['notice'] }}</p>
@endif
+354
View File
@@ -0,0 +1,354 @@
<?php
namespace Tests\Feature;
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Cms\Page;
use App\Domain\Cms\PageRevision;
use App\Domain\Cms\PageService;
use App\Domain\Cms\Widgets\Support\CardClip;
use App\Domain\Cms\Widgets\Support\WebsiteImage;
use App\Domain\Cms\Widgets\Types\ImageTextWidget;
use App\Domain\Cms\Widgets\WidgetRegistry;
use App\Domain\Media\PresentationFile;
use App\Domain\Media\WebsiteMedia;
use App\Domain\Media\WebsiteRelease;
use App\Filament\Resources\Pages\Pages\EditPage;
use App\Models\User;
use Filament\Actions\Testing\TestAction;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Storage;
use Illuminate\Validation\ValidationException;
use Livewire\Livewire;
use Tests\TestCase;
/**
* Bild und Text: Bildanteil, Bild ohne Text und ein Video, das auf dem Bild beim Überfahren und per Klick spielt
* (CardClip, wie auf der Medienkarte). Öffentlich spielt nur ein für die Website freigegebener Clip.
*/
class CmsImageTextMediaTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
Storage::fake('cms_incoming');
Storage::fake('media_derived');
Storage::fake('media_public');
Storage::fake('media_originals');
}
public function test_without_a_share_the_layout_is_unchanged_and_each_share_sets_its_own_class(): void
{
$image = $this->image('Foto Pause');
$this->release($image);
$default = $this->publish('/anteil-vorgabe', $this->widget(['body' => '<p>Text</p>'], ['image' => $image->id]));
$this->assertStringContainsString('class="lf-bt lf-bt--cream lf-bt--image-left lf-bt--height-normal"', $default, 'Ohne Einstellung ändert sich die Darstellung gespeicherter Seiten nicht.');
$this->assertStringNotContainsString('lf-bt--share', $default);
foreach (array_keys(ImageTextWidget::IMAGE_SHARE) as $share) {
$html = $this->publish('/anteil-'.str_replace('_', '-', $share), $this->widget(['body' => '<p>Text</p>'], ['image' => $image->id], ['image_share' => $share]));
$this->assertStringContainsString('lf-bt--shared lf-bt--share-'.$share, $html, $share);
}
}
public function test_the_share_is_ignored_without_image_or_without_text_and_unknown_values_are_rejected(): void
{
$image = $this->image('Foto Pause');
$this->release($image);
$noImage = $this->publish('/anteil-ohne-bild', $this->widget(['body' => '<p>Text</p>'], [], ['image_share' => 'half']));
$this->assertStringNotContainsString('lf-bt--share', $noImage);
$noText = $this->publish('/anteil-ohne-text', $this->widget([], ['image' => $image->id], ['image_share' => 'half']));
$this->assertStringNotContainsString('lf-bt--share', $noText);
try {
app(WidgetRegistry::class)->normalize($this->widget(['body' => '<p>Text</p>'], [], ['image_share' => 'dreiviertel'])[0]['slots']);
$this->fail('Angenommen: unbekannter Bildanteil');
} catch (ValidationException $exception) {
$this->assertStringContainsString('nicht freigegeben', implode(' ', array_merge(...array_values($exception->errors()))));
}
$this->assertNull(ImageTextWidget::imageShare(['image_share' => ['half']]));
$this->assertSame('third', ImageTextWidget::imageShare(['image_share' => 'third']));
}
public function test_an_image_can_stand_alone_without_any_text(): void
{
$image = $this->image('Foto Pause');
$this->release($image);
$html = $this->publish('/nur-bild', $this->widget([], ['image' => $image->id], [], ['alt' => 'Gruppe im Park']));
$this->assertStringContainsString('lf-bt--without-text', $html);
$this->assertStringNotContainsString('lf-bt__copy', $html, 'Ohne Text gibt es keine leere Textspalte.');
$this->assertStringContainsString('<img class="lf-bt__image" src="'.route('website.media', $image).'" alt="Gruppe im Park"', $html);
$normalized = app(WidgetRegistry::class)->normalize($this->widget([], ['image' => $image->id])[0]['slots']);
$this->assertSame($image->id, $normalized[0]['refs']['image']);
}
public function test_a_widget_with_neither_text_nor_image_is_rejected_but_any_text_part_is_enough_without_image(): void
{
try {
app(WidgetRegistry::class)->normalize($this->widget([])[0]['slots']);
$this->fail('Angenommen: leeres Widget');
} catch (ValidationException $exception) {
$this->assertArrayHasKey('blocks.0.data.body', $exception->errors());
$this->assertStringContainsString('Text eingeben oder ein Bild wählen', $exception->errors()['blocks.0.data.body'][0]);
}
foreach ([['title' => 'Nur Überschrift'], ['eyebrow' => 'Nur Label'], ['cta_label' => 'Los', 'cta_url' => '/los'], ['body' => '<p>Nur Text</p>']] as $data) {
$normalized = app(WidgetRegistry::class)->normalize($this->widget($data)[0]['slots']);
$this->assertNotEmpty($normalized, json_encode($data));
}
}
public function test_the_released_trailer_plays_on_the_image_on_hover_and_click(): void
{
$film = $this->clip('Teaser Pause');
$image = $this->image('Foto Pause');
$this->release($film);
$this->release($image);
$html = $this->publish('/bild-video', $this->widget(['body' => '<p>Text</p>'], ['image' => $image->id, 'video' => $film->id]));
$this->assertMatchesRegularExpression('~<div class="lf-bt__media"\s+data-card-clip data-clip-src="'.preg_quote(route('website.media', $film), '~').'" data-clip-title="[^"]+"\s*>~', $html);
$this->assertStringContainsString('<video class="lf-pc__clip" muted loop playsinline preload="none"', $html, 'Stumm, in Schleife, nichts wird vorab geladen.');
$this->assertDoesNotMatchRegularExpression('/<video[^>]* src=/', $html, 'Die Quelle wird erst beim ersten Start gesetzt.');
$this->assertStringNotContainsString('autoplay', $html);
$this->assertStringContainsString('data-clip-toggle', $html, 'Die Schaltfläche steht für Tastatur und Handy bereit.');
$this->assertStringContainsString('lf-bt__image', $html, 'Das Bild bleibt stehen, bis das Video startet.');
$this->assertStringNotContainsString('originals/', $html);
}
public function test_an_image_with_a_video_can_also_stand_without_text(): void
{
$film = $this->clip('Teaser Pause');
$image = $this->image('Foto Pause');
$this->release($film);
$this->release($image);
$html = $this->publish('/bild-video-allein', $this->widget([], ['image' => $image->id, 'video' => $film->id], [], ['alt' => 'Pause']));
$this->assertStringContainsString('lf-bt--without-text', $html);
$this->assertStringContainsString('data-card-clip', $html);
}
public function test_an_unreleased_video_is_not_played_publicly_and_explained_in_the_preview(): void
{
$film = $this->clip('Teaser Pause');
$image = $this->image('Foto Pause');
$this->release($image);
$revision = $this->publishRevision('/bild-video-offen', $this->widget(['body' => '<p>Text</p>'], ['image' => $image->id, 'video' => $film->id]));
$public = $this->get('/bild-video-offen')->assertOk()->getContent();
$this->assertStringNotContainsString('data-card-clip', $public);
$this->assertStringNotContainsString('<video', $public);
$this->assertStringNotContainsString('freigegebenes Video', $public, 'Hinweise für die Redaktion erscheinen öffentlich nie.');
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
$this->assertStringNotContainsString('<video', $preview);
$this->assertStringContainsString('kein für die Website freigegebenes Video', $preview);
}
public function test_withdrawing_the_release_takes_the_video_off_the_page(): void
{
$film = $this->clip('Teaser Pause');
$image = $this->image('Foto Pause');
$this->release($film);
$this->release($image);
$this->publish('/bild-video-zurueck', $this->widget(['body' => '<p>Text</p>'], ['image' => $image->id, 'video' => $film->id]));
$this->assertStringContainsString('data-card-clip', $this->get('/bild-video-zurueck')->getContent());
app(WebsiteRelease::class)->withdraw($film->fresh());
$this->flushScoped();
$this->assertStringNotContainsString('data-card-clip', $this->get('/bild-video-zurueck')->assertOk()->getContent());
}
public function test_a_video_needs_an_image_to_stand_on(): void
{
$film = $this->clip('Teaser Pause');
$this->release($film);
try {
app(WidgetRegistry::class)->normalize($this->widget(['body' => '<p>Text</p>'], ['video' => $film->id])[0]['slots']);
$this->fail('Angenommen: Video ohne Bild');
} catch (ValidationException $exception) {
$this->assertArrayHasKey('blocks.0.refs.image', $exception->errors());
$this->assertStringContainsString('Bitte auch ein Bild wählen', $exception->errors()['blocks.0.refs.image'][0]);
}
}
public function test_the_video_choice_is_validated_and_dropped_when_empty(): void
{
$film = $this->clip('Teaser Pause');
$image = $this->image('Foto Pause');
$archived = $this->clip('Archiv Pause');
$archived->forceFill(['archived_at' => now()])->save();
$confidential = $this->publicFilm('traineranleitung');
$registry = app(WidgetRegistry::class);
$normalized = $registry->normalize($this->widget(['body' => '<p>Text</p>'], ['image' => $image->id, 'video' => $film->id])[0]['slots']);
$this->assertSame($film->id, $normalized[0]['refs']['video']);
$without = $registry->normalize($this->widget(['body' => '<p>Text</p>'], ['image' => $image->id, 'video' => null])[0]['slots']);
$this->assertArrayNotHasKey('video', $without[0]['refs'], 'Ohne Wahl bleibt die gespeicherte Form wie bisher.');
foreach (['kein Film' => $image->id, 'archiviert' => $archived->id, 'Traineranleitung' => $confidential->id, 'unbekannt' => 999999] as $case => $id) {
try {
$registry->normalize($this->widget(['body' => '<p>Text</p>'], ['image' => $image->id, 'video' => $id])[0]['slots']);
$this->fail('Angenommen: '.$case);
} catch (ValidationException $exception) {
$this->assertArrayHasKey('blocks.0.refs.video', $exception->errors(), $case);
}
}
}
public function test_a_video_is_chosen_through_the_shared_picker_which_offers_only_films(): void
{
$film = $this->clip('Teaser Pause');
$image = $this->image('Foto Pause');
$confidential = $this->publicFilm('traineranleitung');
$page = Page::query()->firstOrCreate(['path' => '/video-picker']);
app(PageService::class)->saveRevision($page, $this->widget(['body' => '<p>Text</p>']), null, null, null);
$editor = User::factory()->redakteur()->create();
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
$component = Livewire::actingAs($editor, 'staff')->test(EditPage::class, ['record' => $page->id]);
$sectionKey = array_key_first($component->get('data.sections'));
$slotKey = array_key_first($component->get("data.sections.$sectionKey.slots"));
$widgetKey = array_key_first($component->get("data.sections.$sectionKey.slots.$slotKey.widget"));
$component->mountAction(TestAction::make('edit')->schemaComponent("sections.$sectionKey.slots.$slotKey.widget")->arguments(['item' => $widgetKey]))
->call('openWebsiteVideoPicker', 'mountedActions.0.data.refs.image')
->assertSet('pickerOpen', false)
->call('openWebsiteVideoPicker', 'mountedActions.0.data.refs.video')
->assertSet('pickerOpen', true)
->assertSet('pickerPurpose', 'website-video')
->assertSet('pickerKind', 'film')
->assertSee('Video aus dem Medienmanager')
->assertSee('Teaser Pause');
$items = collect($component->instance()->pickerResult()['items']);
$this->assertNotNull($items->firstWhere('element_id', $film->id), 'Der Film erscheint im gemeinsamen Picker.');
$this->assertNull($items->firstWhere('element_id', $image->id), 'Bilder erscheinen im Videowähler nicht.');
$this->assertNull($items->firstWhere('element_id', $confidential->id), 'Traineranleitungen sind nicht wählbar.');
$component->call('markPicker', $items->firstWhere('element_id', $film->id)['target'], true)
->call('confirmPicker')
->assertSet('pickerOpen', false)
->assertSet('mountedActions.0.data.refs.video', $film->id);
// Der Bildwähler bleibt beim Bild.
$component->call('openWebsiteImagePicker', 'mountedActions.0.data.refs.image')
->assertSet('pickerPurpose', 'website-bild')
->assertSet('pickerKind', 'bild');
}
public function test_an_older_saved_widget_without_the_new_fields_renders_as_before(): void
{
$html = $this->publish('/bild-text-alt', [['layout' => 'u4', 'style' => [], 'slots' => [
['type' => 'image_text', 'v' => 3, 'variant' => 'image_right', 'settings' => ['surface' => 'cream'], 'data' => ['title' => 'Alt', 'body' => '<p>Bestand</p>'], 'refs' => ['image' => 'cms/park.jpg']],
]]]);
$this->assertStringContainsString('class="lf-bt lf-bt--cream lf-bt--image-right lf-bt--height-normal"', $html);
$this->assertStringNotContainsString('data-card-clip', $html);
$this->assertStringContainsString('<p>Bestand</p>', $html);
}
public function test_the_widget_summary_names_an_image_only_widget(): void
{
$widget = app(WidgetRegistry::class)->get('image_text');
$this->assertSame('Bild: Gruppe im Park', $widget->summary(['data' => ['alt' => 'Gruppe im Park']]));
$this->assertSame('Bild', $widget->summary(['data' => []]));
$this->assertSame('Titel', $widget->summary(['data' => ['title' => 'Titel']]));
}
/**
* @param array<string, mixed> $data
* @param array<string, mixed> $refs
* @param array<string, mixed> $settings
* @return list<array<string, mixed>>
*/
private function widget(array $data, array $refs = [], array $settings = [], array $more = []): array
{
return [['layout' => 'u4', 'style' => [], 'slots' => [
['type' => 'image_text', 'v' => 3, 'variant' => 'image_left', 'settings' => $settings, 'data' => $data + $more, 'refs' => $refs],
]]];
}
/**
* @param list<array<string, mixed>> $sections
*/
private function publishRevision(string $path, array $sections): PageRevision
{
$page = Page::query()->create(['path' => $path]);
$service = app(PageService::class);
$revision = $service->saveRevision($page, $sections, null, null, null);
$service->publish($page, $revision);
return $revision;
}
/**
* @param list<array<string, mixed>> $sections
*/
private function publish(string $path, array $sections): string
{
$this->publishRevision($path, $sections);
return $this->get($path)->assertOk()->getContent();
}
private function publicFilm(string $kind = 'unterrichtsfilm'): ContentElement
{
$film = app(ContentService::class)->createElement('film', 'film', 'Denkpause Rohschnitt');
$film->forceFill(['editorial_content_kind_id' => EditorialContentKind::query()->where('slug', $kind)->value('id')])->save();
return $film->refresh();
}
private function clip(string $title): ContentElement
{
return $this->presentation('film', $title, '0123456789abcdefghij', 'mp4');
}
private function image(string $title): ContentElement
{
return $this->presentation('bild', $title, 'bild-bytes', 'jpg');
}
private function presentation(string $output, string $title, string $bytes, string $extension): ContentElement
{
$path = 'inhalte/'.md5($title).'.'.$extension;
Storage::disk('cms_incoming')->put($path, $bytes);
$element = app(ContentService::class)->createElement($output, $output, $title);
$element->display_title = $title;
$element->save();
app(PresentationFile::class)->store($element, $path);
return $element->fresh();
}
private function release(ContentElement $element): void
{
app(WebsiteRelease::class)->release($element->fresh());
$this->flushScoped();
}
private function flushScoped(): void
{
foreach ([WebsiteImage::class, CardClip::class, WebsiteMedia::class] as $class) {
$this->app->forgetInstance($class);
}
}
}