Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2094961b6e | ||
|
|
7ef58e0e6e | ||
|
|
94eda30298 | ||
|
|
bff17a9e8e | ||
|
|
73126fec0c | ||
|
|
437bb394b2 | ||
|
|
5e28538551 | ||
|
|
be932c113a | ||
|
|
ef3af0e036 | ||
|
|
936c85ef5e | ||
|
|
c61869f8aa | ||
|
|
9f7c645baf | ||
|
|
08d03d0f56 | ||
|
|
ea4244487f | ||
|
|
fc40aba26c | ||
|
|
32837639e6 | ||
|
|
3825f53a9b | ||
|
|
604e1791c5 | ||
|
|
cd66561ca9 | ||
|
|
886715af96 | ||
|
|
05bd36509c |
No files matched your search
@@ -15,6 +15,8 @@
|
|||||||
* Redaktionsvorschau (Route editorial.card, nur für angemeldete Redaktion); öffentlich nie ausgegeben, weil es
|
* Redaktionsvorschau (Route editorial.card, nur für angemeldete Redaktion); öffentlich nie ausgegeben, weil es
|
||||||
* keine Freigabe für die Website hat.
|
* keine Freigabe für die Website hat.
|
||||||
* - missing: was für eine vollständige Karte fehlt, als Hinweis nur in der Redaktionsvorschau.
|
* - missing: was für eine vollständige Karte fehlt, als Hinweis nur in der Redaktionsvorschau.
|
||||||
|
* - texts: die zentralen Texte des Fachobjekts, aus denen die Karte einen wählen kann (teaser, summary, description).
|
||||||
|
* summary bleibt der Text der Vorgabe („Automatisch“); texts wird nur gelesen, wenn die Redaktion einen wählt.
|
||||||
*/
|
*/
|
||||||
final readonly class CardSubject
|
final readonly class CardSubject
|
||||||
{
|
{
|
||||||
@@ -36,24 +38,39 @@ public function __construct(
|
|||||||
public ?string $previewImage = null,
|
public ?string $previewImage = null,
|
||||||
public array $missing = [],
|
public array $missing = [],
|
||||||
public ?string $style = null,
|
public ?string $style = null,
|
||||||
|
public array $texts = [],
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function withText(?string $title, ?string $summary): self
|
public function withText(?string $title, ?string $summary): self
|
||||||
{
|
{
|
||||||
return new self(
|
return $this->copy(['title' => $title ?? $this->title, 'summary' => $summary ?? $this->summary]);
|
||||||
title: $title ?? $this->title,
|
}
|
||||||
summary: $summary ?? $this->summary,
|
|
||||||
kind: $this->kind,
|
/**
|
||||||
badge: $this->badge,
|
* Text der Karte aus einem zentralen Text des Fachobjekts. Ist er nicht gepflegt, bleibt die Karte ohne Text
|
||||||
meta: $this->meta,
|
* (kein stiller Ersatz aus einem anderen Feld); in der Redaktionsvorschau steht dann ein Hinweis.
|
||||||
url: $this->url,
|
*/
|
||||||
public: $this->public,
|
public function withTextChoice(string $field, string $missingHint): self
|
||||||
notice: $this->notice,
|
{
|
||||||
visual: $this->visual,
|
if (! array_key_exists($field, $this->texts)) {
|
||||||
visualLabel: $this->visualLabel,
|
return $this;
|
||||||
previewImage: $this->previewImage,
|
}
|
||||||
missing: $this->missing,
|
|
||||||
style: $this->style,
|
$text = $this->texts[$field];
|
||||||
);
|
$missing = array_values(array_filter($this->missing, fn (string $hint): bool => ! str_contains($hint, 'Kurzbeschreibung')));
|
||||||
|
|
||||||
|
if ($text === null) {
|
||||||
|
$missing[] = $missingHint;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->copy(['summary' => $text, 'missing' => $missing]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $changes
|
||||||
|
*/
|
||||||
|
private function copy(array $changes): self
|
||||||
|
{
|
||||||
|
return new self(...array_merge(get_object_vars($this), $changes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,6 +265,13 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
|||||||
$profile = app(EditorialProfileReader::class)->read($composition, 'kachel');
|
$profile = app(EditorialProfileReader::class)->read($composition, 'kachel');
|
||||||
$summary = $profile->value('teaser') ?: $profile->value('summary');
|
$summary = $profile->value('teaser') ?: $profile->value('summary');
|
||||||
$goal = filled($version?->learning_goal) ? trim((string) $version->learning_goal) : null;
|
$goal = filled($version?->learning_goal) ? trim((string) $version->learning_goal) : null;
|
||||||
|
// Zentrale Texte, aus denen die Redaktion den Kartentext wählen kann (Zielgruppe „Öffentliche Kachel“).
|
||||||
|
$texts = [
|
||||||
|
'teaser' => $profile->value('teaser'),
|
||||||
|
'summary' => $profile->value('summary'),
|
||||||
|
'description' => $profile->value('description'),
|
||||||
|
'goal' => $goal,
|
||||||
|
];
|
||||||
$missing = [];
|
$missing = [];
|
||||||
|
|
||||||
if ($summary === null) {
|
if ($summary === null) {
|
||||||
@@ -313,6 +320,7 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
|||||||
visualLabel: $kind,
|
visualLabel: $kind,
|
||||||
previewImage: $includeNonPublic ? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path) : null,
|
previewImage: $includeNonPublic ? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path) : null,
|
||||||
missing: $missing,
|
missing: $missing,
|
||||||
|
texts: $texts,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,13 @@
|
|||||||
use App\Domain\Catalog\EditorialProfileReader;
|
use App\Domain\Catalog\EditorialProfileReader;
|
||||||
use App\Domain\Catalog\StructureNode;
|
use App\Domain\Catalog\StructureNode;
|
||||||
use App\Domain\Media\ThumbnailRef;
|
use App\Domain\Media\ThumbnailRef;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lesesicht „Medien und Materialien“ für Premium-Karten (Website-CMS-Zielarchitektur 6.2).
|
* 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.
|
* Auswahl in der Redaktion: jedes nicht archivierte Inhaltselement mit mindestens einer nicht gesperrten Fassung, dazu
|
||||||
|
* jeder Film, der nur aus einer Website-Datei besteht (Medium ohne Inhaltsfassung, z. B. ein Teaser).
|
||||||
*
|
*
|
||||||
* Öffentliche Sichtbarkeit (Übergangsregel, solange öffentliche Fachobjektprofile nach ADR-29 fehlen):
|
* Ö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
|
* Ein Medium hat keine eigene öffentliche Seite. Öffentlich genannt wird es heute nur als Bestandteil der gezeigten
|
||||||
@@ -20,10 +22,17 @@
|
|||||||
* öffentlich, mit Verweis auf diese Programmseite, und nur mit bereitgestellter Fassung. Traineranleitungen erscheinen
|
* öffentlich, mit Verweis auf diese Programmseite, und nur mit bereitgestellter Fassung. Traineranleitungen erscheinen
|
||||||
* nie öffentlich (vertraulich für Trainerinnen und Trainer).
|
* nie öffentlich (vertraulich für Trainerinnen und Trainer).
|
||||||
*
|
*
|
||||||
* Öffentlich gelesen werden Anzeigetitel (sonst Arbeitstitel), Kurzbeschreibung, Inhaltsart und Ausgabeart. Nie:
|
* Ein Film nur mit Website-Datei hat weder Fassung noch Programm. Er erscheint öffentlich, sobald seine Website-Datei
|
||||||
* Beschreibung, Einsatzhinweis, Lizenzvermerk, Dateien, Lehrtexte, Ausgabeadressen. Das Vorschaubild (Filmstandbild)
|
* für die Website freigegeben ist (die Freigabe ist die ausdrückliche Entscheidung der Redaktion), ohne Verweis auf
|
||||||
* der Bibliothek ist nicht für die Website freigegeben; es erscheint nur in der Redaktionsvorschau.
|
* eine Programmseite und damit ohne Aktion. Ohne Freigabe bleibt er auf die Redaktionsvorschau beschränkt.
|
||||||
* Eine Karte spielt nichts ab, bietet keinen Download und gibt kein Medium frei.
|
*
|
||||||
|
* Öffentlich gelesen werden Anzeigetitel (sonst Arbeitstitel), Inhaltsart und Ausgabeart sowie einer der Texte
|
||||||
|
* Teaser, Kurzbeschreibung oder ausführliche Beschreibung. Welcher Text erscheint, entscheidet die Redaktion je Karte
|
||||||
|
* (Einstellung „Text der Karte“); ohne Wahl gilt die Kurzbeschreibung, sonst der Teaser. Die ausführliche Beschreibung
|
||||||
|
* erscheint nur, wenn die Redaktion sie ausdrücklich wählt. Nie: Einsatzhinweis, Lizenzvermerk, Dateien, Lehrtexte,
|
||||||
|
* Ausgabeadressen. Das Vorschaubild der Bibliothek ist nicht für die Website freigegeben; es erscheint nur in der
|
||||||
|
* Redaktionsvorschau und kann in der Karte ausdrücklich als Website-Bild übernommen werden (FilmStill).
|
||||||
|
* Eine Karte spielt höchstens den für die Website freigegebenen Trailer ab (CardClip), bietet keinen Download und gibt kein Medium frei.
|
||||||
*/
|
*/
|
||||||
class PublicMaterialReader
|
class PublicMaterialReader
|
||||||
{
|
{
|
||||||
@@ -41,14 +50,36 @@ public function __construct(
|
|||||||
public function isSelectable(ContentElement $element): bool
|
public function isSelectable(ContentElement $element): bool
|
||||||
{
|
{
|
||||||
return $element->archived_at === null
|
return $element->archived_at === null
|
||||||
&& $element->versions()->where('status', '!=', ContentVersionStatus::Gesperrt->value)->exists();
|
&& ($element->versions()->where('status', '!=', ContentVersionStatus::Gesperrt->value)->exists()
|
||||||
|
|| $this->isWebsiteOnlyFilm($element));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ein Film ohne jede Inhaltsfassung, der nur die Website-Datei (`teaser/…`) hat, zum Beispiel ein Teaser. Er kann
|
||||||
|
* auf der Medienkarte gewählt werden; was daraus öffentlich wird, bestimmt allein die Freigabe der Datei.
|
||||||
|
*/
|
||||||
|
public function isWebsiteOnlyFilm(ContentElement $element): bool
|
||||||
|
{
|
||||||
|
return $element->output_class === 'film'
|
||||||
|
&& filled($element->preview_path)
|
||||||
|
&& ! $element->versions()->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isReady(ContentElement $element): bool
|
public function isReady(ContentElement $element): bool
|
||||||
{
|
{
|
||||||
|
if ($this->isWebsiteOnlyFilm($element)) {
|
||||||
|
return $this->isWebsiteReleased($element);
|
||||||
|
}
|
||||||
|
|
||||||
return $element->versions()->where('status', ContentVersionStatus::Bereit->value)->exists();
|
return $element->versions()->where('status', ContentVersionStatus::Bereit->value)->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Die Website-Datei des Films ist freigegeben und wird tatsächlich ausgeliefert (WebsiteMedia). */
|
||||||
|
private function isWebsiteReleased(ContentElement $element): bool
|
||||||
|
{
|
||||||
|
return app(WebsiteMedia::class)->present($element)?->kind === 'film';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Öffentliches Programm, in dessen gezeigter Fassung das Element vorkommt, sonst null.
|
* Öffentliches Programm, in dessen gezeigter Fassung das Element vorkommt, sonst null.
|
||||||
*
|
*
|
||||||
@@ -64,7 +95,7 @@ public function isPublic(ContentElement $element): bool
|
|||||||
return $this->isSelectable($element)
|
return $this->isSelectable($element)
|
||||||
&& $this->isReady($element)
|
&& $this->isReady($element)
|
||||||
&& ! in_array($element->editorialContentKind?->slug, self::CONFIDENTIAL_KINDS, true)
|
&& ! in_array($element->editorialContentKind?->slug, self::CONFIDENTIAL_KINDS, true)
|
||||||
&& $this->publicProgramFor($element) !== null;
|
&& ($this->publicProgramFor($element) !== null || $this->isWebsiteOnlyFilm($element));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,7 +108,13 @@ public function search(?string $term, int $limit = 25): array
|
|||||||
$candidates = ContentElement::query()
|
$candidates = ContentElement::query()
|
||||||
->with('editorialContentKind')
|
->with('editorialContentKind')
|
||||||
->whereNull('archived_at')
|
->whereNull('archived_at')
|
||||||
->whereHas('versions', fn ($query) => $query->where('status', '!=', ContentVersionStatus::Gesperrt->value))
|
->where(fn ($selectable) => $selectable
|
||||||
|
->whereHas('versions', fn ($query) => $query->where('status', '!=', ContentVersionStatus::Gesperrt->value))
|
||||||
|
->orWhere(fn ($websiteOnly) => $websiteOnly
|
||||||
|
->where('output_class', 'film')
|
||||||
|
->whereNotNull('preview_path')
|
||||||
|
->where('preview_path', '!=', '')
|
||||||
|
->whereDoesntHave('versions')))
|
||||||
->when($term !== '', function ($query) use ($term): void {
|
->when($term !== '', function ($query) use ($term): void {
|
||||||
$like = '%'.mb_strtolower($term).'%';
|
$like = '%'.mb_strtolower($term).'%';
|
||||||
$query->where(fn ($inner) => $inner
|
$query->where(fn ($inner) => $inner
|
||||||
@@ -124,7 +161,7 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
|
|||||||
|
|
||||||
$shown = clone $element;
|
$shown = clone $element;
|
||||||
|
|
||||||
foreach (['working_title', 'display_title', 'summary', 'thumbnail_path', 'thumbnail_alt'] as $field) {
|
foreach (['working_title', 'display_title', 'teaser', 'summary', 'description', 'thumbnail_path', 'thumbnail_alt'] as $field) {
|
||||||
if (! array_key_exists($field, $draft)) {
|
if (! array_key_exists($field, $draft)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -146,17 +183,30 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
|
|||||||
$summary = trim((string) $shown->teaser);
|
$summary = trim((string) $shown->teaser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$texts = [];
|
||||||
|
|
||||||
|
foreach (['teaser', 'summary', 'description'] as $field) {
|
||||||
|
$own = filled($shown->getAttribute($field)) ? trim((string) $shown->getAttribute($field)) : null;
|
||||||
|
|
||||||
|
if (! array_key_exists($field, $draft) && $profile->origin($field) === 'variante') {
|
||||||
|
$own = $profile->value($field);
|
||||||
|
}
|
||||||
|
|
||||||
|
$texts[$field] = $own;
|
||||||
|
}
|
||||||
|
|
||||||
$title = (string) ($shown->display_title ?: $shown->working_title);
|
$title = (string) ($shown->display_title ?: $shown->working_title);
|
||||||
|
|
||||||
if (! array_key_exists('display_title', $draft) && $profile->origin('display_title') === 'variante') {
|
if (! array_key_exists('display_title', $draft) && $profile->origin('display_title') === 'variante') {
|
||||||
$title = (string) $profile->value('display_title');
|
$title = (string) $profile->value('display_title');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$websiteOnly = $this->isWebsiteOnlyFilm($element);
|
||||||
$meta = [$output];
|
$meta = [$output];
|
||||||
if ($program !== null) {
|
if ($program !== null) {
|
||||||
$meta[] = 'Im Programm „'.$program['title'].'“';
|
$meta[] = 'Im Programm „'.$program['title'].'“';
|
||||||
}
|
}
|
||||||
if ($film) {
|
if ($film && ! $websiteOnly) {
|
||||||
$meta[] = 'Vollständiger Film nur mit Lizenz im Mitgliederbereich';
|
$meta[] = 'Vollständiger Film nur mit Lizenz im Mitgliederbereich';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +234,7 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
|
|||||||
previewImage: $previewImage,
|
previewImage: $previewImage,
|
||||||
missing: $missing,
|
missing: $missing,
|
||||||
style: $film ? 'media' : 'material',
|
style: $film ? 'media' : 'material',
|
||||||
|
texts: $texts,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +255,11 @@ public function visibilityNote(ContentElement $element): string
|
|||||||
if ($this->isPublic($element)) {
|
if ($this->isPublic($element)) {
|
||||||
$program = $this->publicProgramFor($element);
|
$program = $this->publicProgramFor($element);
|
||||||
|
|
||||||
return 'Öffentlich nur als Teil der Programmseite „'.($program['title'] ?? '').'“. Die Mediendatei wird dabei nicht ausgeliefert.';
|
if ($program === null) {
|
||||||
|
return 'Öffentlich mit der für die Website freigegebenen Datei, ohne Verweis auf eine Programmseite. Die Originaldatei wird nie ausgeliefert.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'Öffentlich nur als Teil der Programmseite „'.$program['title'].'“. Die Mediendatei wird dabei nicht ausgeliefert.';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->notice($element, $this->publicProgramFor($element));
|
return $this->notice($element, $this->publicProgramFor($element));
|
||||||
@@ -217,6 +272,7 @@ private function notice(ContentElement $element, ?array $program): string
|
|||||||
{
|
{
|
||||||
$reason = match (true) {
|
$reason = match (true) {
|
||||||
in_array($element->editorialContentKind?->slug, self::CONFIDENTIAL_KINDS, true) => 'Traineranleitungen erscheinen nie öffentlich.',
|
in_array($element->editorialContentKind?->slug, self::CONFIDENTIAL_KINDS, true) => 'Traineranleitungen erscheinen nie öffentlich.',
|
||||||
|
$this->isWebsiteOnlyFilm($element) => 'Die Website-Datei ist nicht für die Website freigegeben (Medium öffnen → Reiter „Website“ → freigeben).',
|
||||||
! $this->isReady($element) => 'Das Medium hat noch keine bereitgestellte Fassung.',
|
! $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).',
|
$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.',
|
default => 'Das Medium ist nicht öffentlich.',
|
||||||
@@ -227,9 +283,14 @@ private function notice(ContentElement $element, ?array $program): string
|
|||||||
|
|
||||||
private function optionLabel(ContentElement $element): string
|
private function optionLabel(ContentElement $element): string
|
||||||
{
|
{
|
||||||
$visibility = $this->isPublic($element)
|
$visibility = match (true) {
|
||||||
? 'öffentlich über Programmseite'
|
$this->isWebsiteOnlyFilm($element) => $this->isPublic($element)
|
||||||
: ($this->isReady($element) ? 'nur Redaktionsvorschau' : 'Entwurf, nur Redaktionsvorschau');
|
? 'öffentlich mit Website-Datei'
|
||||||
|
: 'Website-Datei nicht freigegeben, nur Redaktionsvorschau',
|
||||||
|
$this->isPublic($element) => 'öffentlich über Programmseite',
|
||||||
|
$this->isReady($element) => 'nur Redaktionsvorschau',
|
||||||
|
default => 'Entwurf, nur Redaktionsvorschau',
|
||||||
|
};
|
||||||
$kind = $element->editorialContentKind?->label ?: self::outputLabel((string) $element->output_class);
|
$kind = $element->editorialContentKind?->label ?: self::outputLabel((string) $element->output_class);
|
||||||
|
|
||||||
return (string) ($element->display_title ?: $element->working_title).' · '.$kind.' · '.$visibility;
|
return (string) ($element->display_title ?: $element->working_title).' · '.$kind.' · '.$visibility;
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Cms\Widgets\Support;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\PresentationAssignment;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Der kurze Clip, den eine Premium-Karte beim Überfahren oder Antippen abspielt.
|
||||||
|
*
|
||||||
|
* Gelesen wird nur, was die Redaktion ohnehin für die Website freigegeben hat (WebsiteMedia, Route website.media):
|
||||||
|
* 1. der Trailer des Fachobjekts (Präsentationsrolle „Trailer“), sonst der Vorschauclip,
|
||||||
|
* 2. bei einem Film ersatzweise dessen eigener freigegebener Teaser.
|
||||||
|
* Der vollständige Film, die Originaldatei und nicht freigegebene Clips kommen nie über die Karte. Die Karte gibt
|
||||||
|
* nichts frei; ohne freigegebenen Clip bleibt es beim Kartenbild.
|
||||||
|
*
|
||||||
|
* In der Redaktionsvorschau erklärt `notice`, warum kein Clip läuft (zugeordnet, aber nicht freigegeben).
|
||||||
|
*/
|
||||||
|
class CardClip
|
||||||
|
{
|
||||||
|
/** Rollen in der Reihenfolge, in der ein Clip gesucht wird. */
|
||||||
|
public const ROLES = ['trailer', 'vorschauclip'];
|
||||||
|
|
||||||
|
public function __construct(private readonly WebsiteMedia $media) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{url: string|null, title: string, source: string, notice: string|null, hint: string|null}
|
||||||
|
*/
|
||||||
|
public function for(Model $subject, bool $preview): array
|
||||||
|
{
|
||||||
|
$assigned = PresentationAssignment::query()
|
||||||
|
->with(['role', 'element'])
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->whereHas('role', fn ($query) => $query->whereIn('slug', self::ROLES))
|
||||||
|
->orderBy('position')
|
||||||
|
->orderBy('id')
|
||||||
|
->get()
|
||||||
|
->sortBy(fn (PresentationAssignment $row): int => (int) array_search($row->role?->slug, self::ROLES, true))
|
||||||
|
->values();
|
||||||
|
|
||||||
|
$unreleased = null;
|
||||||
|
|
||||||
|
foreach ($assigned as $assignment) {
|
||||||
|
$element = $assignment->element;
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement || $element->archived_at !== null || $element->output_class !== 'film') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$present = $this->media->present($element);
|
||||||
|
|
||||||
|
if ($present !== null && $present->kind === 'film') {
|
||||||
|
return $this->found($present->url, $present->title, $assignment->role?->slug === 'trailer' ? 'trailer' : 'vorschauclip');
|
||||||
|
}
|
||||||
|
|
||||||
|
$unreleased ??= $element;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($subject instanceof ContentElement && $subject->output_class === 'film') {
|
||||||
|
$own = $this->media->present($subject);
|
||||||
|
|
||||||
|
if ($own !== null && $own->kind === 'film') {
|
||||||
|
return $this->found($own->url, $own->title, 'teaser');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $preview) {
|
||||||
|
return $this->none();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($unreleased instanceof ContentElement) {
|
||||||
|
$title = (string) ($unreleased->display_title ?: $unreleased->working_title);
|
||||||
|
|
||||||
|
return $this->none('Der Trailer „'.$title.'“ ist nicht für die Website freigegeben; öffentlich bleibt es beim Kartenbild (Medium öffnen → Reiter „Website“ → freigeben).');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->none(null, 'Kein Trailer zugeordnet; die Karte zeigt nur das Bild (Rolle „Trailer“ in der Präsentation des Mediums).');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{url: string|null, title: string, source: string, notice: string|null, hint: string|null}
|
||||||
|
*/
|
||||||
|
private function found(string $url, string $title, string $source): array
|
||||||
|
{
|
||||||
|
return ['url' => $url, 'title' => $title, 'source' => $source, 'notice' => null, 'hint' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{url: string|null, title: string, source: string, notice: string|null, hint: string|null}
|
||||||
|
*/
|
||||||
|
private function none(?string $notice = null, ?string $hint = null): array
|
||||||
|
{
|
||||||
|
return ['url' => null, 'title' => '', 'source' => 'none', 'notice' => $notice, 'hint' => $hint];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Cms\Widgets\Support;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Das Video des Einstiegs (Hero): ein stummer Clip auf der Fläche des Fotos.
|
||||||
|
*
|
||||||
|
* Gewählt wird ein Film aus dem Medienmanager. Abgespielt wird nur, was die Redaktion für die Website freigegeben hat,
|
||||||
|
* und zwar nach derselben Regel wie auf der Karte (CardClip): Trailer des Films, sonst sein Vorschauclip, sonst seine
|
||||||
|
* eigene freigegebene Website-Datei. Der vollständige Film, die Originaldatei und nicht freigegebene Clips kommen nie
|
||||||
|
* über den Einstieg. Ohne freigegebenen Clip bleibt es beim Foto; die Auswahl gibt nichts frei.
|
||||||
|
*/
|
||||||
|
final class HeroVideo
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly CardClip $clips,
|
||||||
|
private readonly PublicMaterialReader $materials,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auswahlliste: Filme, die auf der Website gezeigt werden dürfen, mit dem Stand ihrer Freigabe.
|
||||||
|
*
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public function options(?string $term, int $limit = 25): array
|
||||||
|
{
|
||||||
|
$term = trim((string) $term);
|
||||||
|
|
||||||
|
$candidates = ContentElement::query()
|
||||||
|
->with('editorialContentKind')
|
||||||
|
->where('output_class', 'film')
|
||||||
|
->whereNull('archived_at')
|
||||||
|
->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 * 2)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$options = [];
|
||||||
|
|
||||||
|
foreach ($candidates as $element) {
|
||||||
|
if (! $this->allowed($element)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$options[$element->id] = $this->label($element);
|
||||||
|
|
||||||
|
if (count($options) >= $limit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function labelFor(mixed $id): ?string
|
||||||
|
{
|
||||||
|
$element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||||
|
|
||||||
|
return $element instanceof ContentElement ? $this->label($element) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüft die gewählte Kennung. Gibt die Kennung zurück oder null, wenn keine gewählt ist oder die Wahl ungültig ist.
|
||||||
|
*/
|
||||||
|
public function clean(mixed $value, WidgetErrors $errors, string $key = 'refs.video'): ?int
|
||||||
|
{
|
||||||
|
if ($value === null || $value === '' || $value === false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$element = is_numeric($value) ? ContentElement::query()->with('editorialContentKind')->find((int) $value) : null;
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement || ! $this->allowed($element)) {
|
||||||
|
$errors->add($key, 'Bitte einen Film aus dem Medienmanager wählen (nicht archiviert, nicht gesperrt, keine Traineranleitung).');
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $element->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{url: string|null, title: string, notice: string|null}
|
||||||
|
*/
|
||||||
|
public function resolve(mixed $id, bool $preview): array
|
||||||
|
{
|
||||||
|
$element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement) {
|
||||||
|
return ['url' => null, 'title' => '', 'notice' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = (string) ($element->display_title ?: $element->working_title);
|
||||||
|
|
||||||
|
if (! $this->allowed($element)) {
|
||||||
|
return ['url' => null, 'title' => $title, 'notice' => $preview ? 'Das gewählte Medium „'.$title.'“ ist archiviert oder gesperrt; es erscheint kein Video.' : null];
|
||||||
|
}
|
||||||
|
|
||||||
|
$clip = $this->clips->for($element, $preview);
|
||||||
|
|
||||||
|
if ($clip['url'] !== null) {
|
||||||
|
return ['url' => $clip['url'], 'title' => $clip['title'] !== '' ? $clip['title'] : $title, 'notice' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'url' => null,
|
||||||
|
'title' => $title,
|
||||||
|
'notice' => $preview
|
||||||
|
? 'Für „'.$title.'“ gibt es kein für die Website freigegebenes Video (Trailer, Vorschauclip oder freigegebene Website-Datei des Mediums); öffentlich bleibt es beim Foto. Freigabe: Medium öffnen → Reiter „Website“.'
|
||||||
|
: null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Ein Film, der nicht archiviert, nicht gesperrt und keine Traineranleitung ist. */
|
||||||
|
private function allowed(ContentElement $element): bool
|
||||||
|
{
|
||||||
|
return $element->output_class === 'film'
|
||||||
|
&& $this->materials->isSelectable($element)
|
||||||
|
&& ! in_array($element->editorialContentKind?->slug, PublicMaterialReader::CONFIDENTIAL_KINDS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function label(ContentElement $element): string
|
||||||
|
{
|
||||||
|
$state = $this->clips->for($element, false)['url'] !== null ? 'Video freigegeben' : 'noch kein freigegebenes Video';
|
||||||
|
|
||||||
|
return (string) ($element->display_title ?: $element->working_title).' · '.$state;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -127,6 +127,10 @@ public function url(mixed $value, bool $preview = false): ?string
|
|||||||
|
|
||||||
$legacy = self::normalize($value);
|
$legacy = self::normalize($value);
|
||||||
|
|
||||||
|
if (is_string($legacy) && WebsiteMediaAlias::isRetired($legacy)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return is_string($legacy) ? PublicMedia::url($legacy) : null;
|
return is_string($legacy) ? PublicMedia::url($legacy) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,6 +179,10 @@ public function status(mixed $value): ?array
|
|||||||
|
|
||||||
$id = $this->elementId($value);
|
$id = $this->elementId($value);
|
||||||
|
|
||||||
|
if ($id === null && WebsiteMediaAlias::isRetired($value)) {
|
||||||
|
return ['public' => false, 'state' => 'missing', 'title' => basename((string) $value), 'note' => 'Das Medium wurde gelöscht.', 'thumb' => null, 'manageUrl' => null];
|
||||||
|
}
|
||||||
|
|
||||||
if ($id === null) {
|
if ($id === null) {
|
||||||
return [
|
return [
|
||||||
'public' => true,
|
'public' => true,
|
||||||
|
|||||||
@@ -3,12 +3,14 @@
|
|||||||
namespace App\Domain\Cms\Widgets\Types;
|
namespace App\Domain\Cms\Widgets\Types;
|
||||||
|
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
|
use App\Domain\Cms\Widgets\Support\HeroVideo;
|
||||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\Textarea;
|
use Filament\Forms\Components\Textarea;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Schemas\Components\Group;
|
use Filament\Schemas\Components\Group;
|
||||||
@@ -20,6 +22,10 @@
|
|||||||
* Containerbreite), Label, Überschriftenebene, Bildfokus in Prozent, Akzent, zwei Schaltflächen.
|
* 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
|
* Die data-Schlüssel der Version 1 (heading, text, cta_*, alt) bleiben unverändert, damit ältere Revisionen und ein
|
||||||
* Code-Rollback darstellbar bleiben.
|
* Code-Rollback darstellbar bleiben.
|
||||||
|
*
|
||||||
|
* Optional ein Video (refs.video, ein Film aus dem Medienmanager): In der Variante „Foto mit Textfläche“ läuft ein
|
||||||
|
* stummer, für die Website freigegebener Clip auf der Fläche des Fotos (HeroVideo, resources/js/hero-video.js). Neuer
|
||||||
|
* Schlüssel ohne Versionssprung; ältere Revisionen ohne `video` bleiben unverändert darstellbar.
|
||||||
*/
|
*/
|
||||||
class HeroWidget extends WidgetType
|
class HeroWidget extends WidgetType
|
||||||
{
|
{
|
||||||
@@ -152,7 +158,7 @@ public function dataRules(): array
|
|||||||
|
|
||||||
public function refRules(): array
|
public function refRules(): array
|
||||||
{
|
{
|
||||||
return ImageRefFields::rules();
|
return ImageRefFields::rules() + ['video' => ['nullable']];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataFields(): array
|
public function dataFields(): array
|
||||||
@@ -169,7 +175,19 @@ public function dataFields(): array
|
|||||||
|
|
||||||
public function refFields(): array
|
public function refFields(): array
|
||||||
{
|
{
|
||||||
return ImageRefFields::fields(live: true);
|
return [...ImageRefFields::fields(live: true), $this->videoField()];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function videoField(): Select
|
||||||
|
{
|
||||||
|
return Select::make('video')
|
||||||
|
->label('Video (optional)')
|
||||||
|
->helperText('Ein Film aus dem Medienmanager. Läuft stumm auf der Fläche des Fotos, nur in der Variante „Foto mit Textfläche“ und nur, wenn ein Trailer, Vorschauclip oder die Website-Datei des Films für die Website freigegeben ist. Das Foto bleibt als Rückfall, bei „reduzierte Bewegung“ und im Datensparmodus startet das Video nur auf Wunsch. Die Auswahl gibt nichts frei.')
|
||||||
|
->live()
|
||||||
|
->searchable()
|
||||||
|
->getSearchResultsUsing(fn (?string $search): array => app(HeroVideo::class)->options($search))
|
||||||
|
->getOptionLabelUsing(fn (mixed $value): ?string => app(HeroVideo::class)->labelFor($value))
|
||||||
|
->options(fn (): array => app(HeroVideo::class)->options(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editorSchema(): array
|
public function editorSchema(): array
|
||||||
@@ -192,6 +210,8 @@ public function mediaSchema(): array
|
|||||||
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||||
{
|
{
|
||||||
$refs = ImageRefFields::clean($refs, $errors);
|
$refs = ImageRefFields::clean($refs, $errors);
|
||||||
|
$video = app(HeroVideo::class)->clean($refs['video'] ?? null, $errors);
|
||||||
|
$video === null ? $refs = array_diff_key($refs, ['video' => true]) : $refs['video'] = $video;
|
||||||
$data['heading'] = trim((string) ($data['heading'] ?? ''));
|
$data['heading'] = trim((string) ($data['heading'] ?? ''));
|
||||||
$data['text'] = filled($data['text'] ?? null) ? trim((string) $data['text']) : null;
|
$data['text'] = filled($data['text'] ?? null) ? trim((string) $data['text']) : null;
|
||||||
$data = PremiumFields::clean($data, $errors, $refs['image'] !== null);
|
$data = PremiumFields::clean($data, $errors, $refs['image'] !== null);
|
||||||
@@ -205,8 +225,15 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
|
|
||||||
$images = app(WebsiteImage::class);
|
$images = app(WebsiteImage::class);
|
||||||
$image = $widget['refs']['image'] ?? null;
|
$image = $widget['refs']['image'] ?? null;
|
||||||
|
$video = app(HeroVideo::class)->resolve($widget['refs']['video'] ?? null, $context->preview);
|
||||||
|
$photoSplit = ($widget['variant'] ?? 'photo_split') !== 'editorial_solid';
|
||||||
|
|
||||||
|
if (! $photoSplit && $video['title'] !== '') {
|
||||||
|
$video = ['url' => null, 'title' => $video['title'], 'notice' => $context->preview ? 'Das Video erscheint nur in der Variante „Foto mit Textfläche“; die Markenfläche zeigt kein Video.' : null];
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
'video' => $video,
|
||||||
'imageUrl' => $images->url($image, $context->preview),
|
'imageUrl' => $images->url($image, $context->preview),
|
||||||
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
||||||
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||||
|
|||||||
@@ -7,12 +7,17 @@
|
|||||||
use App\Domain\Cms\Catalog\CardSubject;
|
use App\Domain\Cms\Catalog\CardSubject;
|
||||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
|
use App\Domain\Media\FilmStill;
|
||||||
|
use App\Domain\Media\ThumbnailRef;
|
||||||
|
use Filament\Forms\Components\ViewField;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Medien- und Materialkarte (Kit v1.7 „media“): ein Inhaltselement mit Anzeigetitel, Kurzbeschreibung, Inhaltsart und
|
* 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
|
* 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
|
* 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.
|
* führt auf die öffentliche Programmseite. Die Karte spielt höchstens den für die Website freigegebenen Trailer ab (CardClip), bietet keinen Download und gibt kein Medium frei.
|
||||||
*/
|
*/
|
||||||
class MediaCardWidget extends PremiumCardWidget
|
class MediaCardWidget extends PremiumCardWidget
|
||||||
{
|
{
|
||||||
@@ -28,7 +33,7 @@ public function label(): string
|
|||||||
|
|
||||||
public function description(): string
|
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.';
|
return 'Karte zu einem Film oder Material aus der Bibliothek; Titel und Art kommen aus den Fachdaten, Trailer nur wenn freigegeben, kein Download.';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function icon(): string
|
public function icon(): string
|
||||||
@@ -53,7 +58,7 @@ protected function refLabel(): string
|
|||||||
|
|
||||||
protected function refHelp(): string
|
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.';
|
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; ein Film nur mit Website-Datei (zum Beispiel ein Teaser) erscheint, sobald diese Datei für die Website freigegeben ist. Traineranleitungen nie. Titel, Teaser, Kurzbeschreibung und Beschreibung pflegen Sie im Medium; welcher Text auf der Karte erscheint, wählen Sie unter „Darstellung“.';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function searchSubjects(?string $term): array
|
protected function searchSubjects(?string $term): array
|
||||||
@@ -90,6 +95,69 @@ protected function cardStyle(): string
|
|||||||
return 'media';
|
return 'media';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bei einem Film: das Vorschaubild des Films oder eine Stelle des Films als Kartenbild übernehmen. Das Bild wird
|
||||||
|
* einmal als Bild-Medium abgelegt (FilmStill) und wie jedes andere Bild ausgewählt; die Karte liest nur diese Datei.
|
||||||
|
*/
|
||||||
|
protected function imageSourceFields(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ViewField::make('_filmbild')
|
||||||
|
->label('Bild aus dem Film')
|
||||||
|
->view('filament.cms.filmbild-feld')
|
||||||
|
->dehydrated(false)
|
||||||
|
->visible(fn (Get $get): bool => $this->filmFor($get('element')) !== null)
|
||||||
|
->viewData(function (Get $get): array {
|
||||||
|
$film = $this->filmFor($get('element'));
|
||||||
|
$stills = app(FilmStill::class);
|
||||||
|
$version = $film instanceof ContentElement ? $stills->version($film) : null;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'film' => $film,
|
||||||
|
'filmTitle' => $film instanceof ContentElement ? (string) ($film->display_title ?: $film->working_title) : '',
|
||||||
|
'filmVersionId' => $version?->id,
|
||||||
|
'filmHasThumbnail' => $film instanceof ContentElement && is_string($film->thumbnail_path) && $film->thumbnail_path !== '',
|
||||||
|
'filmThumbnailUrl' => $film instanceof ContentElement ? ThumbnailRef::url('editorial.card', 'element', (int) $film->id, $film->thumbnail_path) : null,
|
||||||
|
'filmStartSecond' => $film instanceof ContentElement ? ($stills->thumbnailSecond($film) ?? '0') : '0',
|
||||||
|
];
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filmFor(mixed $id): ?ContentElement
|
||||||
|
{
|
||||||
|
$element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||||
|
|
||||||
|
return $element instanceof ContentElement && app(FilmStill::class)->refusal($element) === null ? $element : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function subjectNoun(): string
|
||||||
|
{
|
||||||
|
return 'Medium';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function textChoices(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'auto' => 'Automatisch (Kurzbeschreibung, sonst Teaser)',
|
||||||
|
'teaser' => 'Teaser',
|
||||||
|
'summary' => 'Kurzbeschreibung',
|
||||||
|
'description' => 'Ausführliche Beschreibung (erscheint öffentlich)',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function supportsClip(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function clipSubject(mixed $id): ?Model
|
||||||
|
{
|
||||||
|
$element = is_numeric($id) ? ContentElement::query()->find((int) $id) : null;
|
||||||
|
|
||||||
|
return $element instanceof ContentElement ? $element : null;
|
||||||
|
}
|
||||||
|
|
||||||
protected function centralCoverId(mixed $id): ?int
|
protected function centralCoverId(mixed $id): ?int
|
||||||
{
|
{
|
||||||
$element = is_numeric($id) ? ContentElement::query()->find((int) $id) : null;
|
$element = is_numeric($id) ? ContentElement::query()->find((int) $id) : null;
|
||||||
|
|||||||
@@ -4,16 +4,19 @@
|
|||||||
|
|
||||||
use App\Domain\Cms\Catalog\CardSubject;
|
use App\Domain\Cms\Catalog\CardSubject;
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
|
use App\Domain\Cms\Widgets\Support\CardClip;
|
||||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
|
use Filament\Forms\Components\Field;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Schemas\Components\Group;
|
use Filament\Schemas\Components\Group;
|
||||||
use Filament\Schemas\Components\Utilities\Get;
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,6 +59,56 @@ abstract protected function defaultActionLabel(): string;
|
|||||||
/** Gestaltungsvariante des Kits: editorial, media oder catalog. */
|
/** Gestaltungsvariante des Kits: editorial, media oder catalog. */
|
||||||
abstract protected function cardStyle(): string;
|
abstract protected function cardStyle(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Weitere Wege zum Kartenbild im Reiter „Medien“, zum Beispiel ein Bild aus dem Film. Standard: keine.
|
||||||
|
*
|
||||||
|
* @return list<Field>
|
||||||
|
*/
|
||||||
|
protected function imageSourceFields(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fachobjekt, dessen Trailer die Karte beim Überfahren oder Antippen abspielt (Medium, Programm, Modul).
|
||||||
|
* Null: diese Karte hat keinen Clip (Thema). Der Clip kommt aus der Präsentation des Objekts (CardClip).
|
||||||
|
*/
|
||||||
|
protected function clipSubject(mixed $id): ?Model
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zentrale Texte des Fachobjekts, aus denen die Redaktion den Kartentext wählen kann: Wert => Bezeichnung.
|
||||||
|
* Leer: keine Wahl (die Karte nimmt den Text ihrer Vorgabe). Mit Wahl gilt „auto“ als Vorgabe.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
protected function textChoices(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Was die Redaktion bearbeitet, um einen Text zu pflegen („Medium“, „Programm oder Modul“); für Hinweise. */
|
||||||
|
protected function subjectNoun(): string
|
||||||
|
{
|
||||||
|
return 'Objekt';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Hinweis der Redaktionsvorschau, wenn der gewählte zentrale Text nicht gepflegt ist. */
|
||||||
|
private function missingTextHint(string $field): string
|
||||||
|
{
|
||||||
|
$noun = $this->subjectNoun();
|
||||||
|
|
||||||
|
return match ($field) {
|
||||||
|
'teaser' => 'Kein Teaser gepflegt ('.$noun.' bearbeiten → Teaser).',
|
||||||
|
'summary' => 'Keine Kurzbeschreibung gepflegt ('.$noun.' bearbeiten → Kurzbeschreibung).',
|
||||||
|
'description' => 'Keine ausführliche Beschreibung gepflegt ('.$noun.' bearbeiten → Beschreibung).',
|
||||||
|
'goal' => 'Kein Lernziel gepflegt ('.$noun.' bearbeiten → Lernziel der Fassung).',
|
||||||
|
default => '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public function view(): string
|
public function view(): string
|
||||||
{
|
{
|
||||||
return 'widgets.premium_card';
|
return 'widgets.premium_card';
|
||||||
@@ -110,7 +163,9 @@ public function optionIcons(): array
|
|||||||
|
|
||||||
public function settings(): array
|
public function settings(): array
|
||||||
{
|
{
|
||||||
return [
|
$choices = $this->textChoices();
|
||||||
|
|
||||||
|
return ($choices === [] ? [] : ['text_source' => $choices]) + ($this->supportsClip() ? ['clip' => ['yes' => 'Abspielen', 'no' => 'Nicht abspielen']] : []) + [
|
||||||
'format' => ['landscape' => 'Querformat 16:9', 'square' => 'Quadrat 1:1', 'portrait' => 'Hochformat 3:4'],
|
'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)'],
|
'fit' => ['cover' => 'Ausschnitt füllt die Fläche', 'contain' => 'Ganzes Bild zeigen (Dokument, Poster)'],
|
||||||
'heading_level' => ['h3' => 'H3', 'h2' => 'H2', 'h4' => 'H4'],
|
'heading_level' => ['h3' => 'H3', 'h2' => 'H2', 'h4' => 'H4'],
|
||||||
@@ -124,10 +179,12 @@ public function settings(): array
|
|||||||
public function settingLabels(): array
|
public function settingLabels(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'text_source' => ['Text der Karte', 'Welche Angabe aus der Redaktion die Karte zeigt. Vorgabe: Automatisch. Der gewählte Text erscheint öffentlich, wenn die Karte öffentlich ist; ist er nicht gepflegt, bleibt die Karte ohne Text.'],
|
||||||
|
'clip' => ['Trailer auf der Karte', 'Spielt den freigegebenen Trailer stumm ab, solange die Maus auf der Karte steht; am Handy mit Tippen auf das Bild, per Tastatur über die Schaltfläche am Bild. Gewählt wird der Trailer (sonst der Vorschauclip) in der Präsentation des Objekts, bei einem Film ersatzweise sein freigegebener Teaser. Ohne freigegebenen Clip bleibt das Kartenbild. Vorgabe: Abspielen.'],
|
||||||
'format' => ['Bildformat', 'Vorgabe: Querformat 16:9. Gilt auch neben dem Text; das Motiv wird nicht nachträglich hochkant beschnitten.'],
|
'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.'],
|
'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).'],
|
'heading_level' => ['Überschriftenebene', 'Vorgabe: H3, passend unter einer Abschnittsüberschrift (H2).'],
|
||||||
'show_summary' => ['Kurzbeschreibung', 'Aus den Fachdaten. Vorgabe: anzeigen.'],
|
'show_summary' => ['Text anzeigen', 'Aus den Fachdaten. Vorgabe: anzeigen.'],
|
||||||
'show_kind' => ['Art oder Label', 'Zum Beispiel „Thema“ oder „Merkblatt“. 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_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.'],
|
'show_action' => ['Aktion', 'Verweis auf die öffentliche Seite des Fachobjekts, falls es eine gibt. Vorgabe: anzeigen.'],
|
||||||
@@ -195,13 +252,13 @@ public function editorSchema(): array
|
|||||||
->hintColor(fn (?string $state): string => filled($state) ? 'warning' : 'gray')
|
->hintColor(fn (?string $state): string => filled($state) ? 'warning' : 'gray')
|
||||||
->helperText('Leer übernimmt den Anzeigenamen des Fachobjekts. Eine Eintragung gilt nur für diese Karte und ändert die Quelle nicht.'),
|
->helperText('Leer übernimmt den Anzeigenamen des Fachobjekts. Eine Eintragung gilt nur für diese Karte und ändert die Quelle nicht.'),
|
||||||
TextInput::make('summary')
|
TextInput::make('summary')
|
||||||
->label('Teaser nur für diese Karte')
|
->label('Text nur für diese Karte')
|
||||||
->maxLength(500)
|
->maxLength(500)
|
||||||
->live(onBlur: true)
|
->live(onBlur: true)
|
||||||
->placeholder(fn (Get $get): string => $this->centralText($get('../refs.'.$this->refKey()), 'summary') ?? 'Zentraler Teaser oder Kurzbeschreibung')
|
->placeholder(fn (Get $get): string => $this->centralText($get('../refs.'.$this->refKey()), 'summary', $get('../settings.text_source')) ?? 'Zentraler Text aus der Redaktion')
|
||||||
->hint(fn (?string $state): string => filled($state) ? 'Eigene Angabe für diese Karte' : 'Aus der Redaktion')
|
->hint(fn (?string $state): string => filled($state) ? 'Eigene Angabe für diese Karte' : 'Aus der Redaktion')
|
||||||
->hintColor(fn (?string $state): string => filled($state) ? 'warning' : 'gray')
|
->hintColor(fn (?string $state): string => filled($state) ? 'warning' : 'gray')
|
||||||
->helperText('Leer übernimmt Teaser oder Kurzbeschreibung. Lehrinhalt, Rechte und Preise bleiben unberührt.'),
|
->helperText('Leer übernimmt den Text, den „Text der Karte“ (Darstellung) wählt. Lehrinhalt, Rechte und Preise bleiben unberührt.'),
|
||||||
])->statePath('data'),
|
])->statePath('data'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -211,7 +268,7 @@ public function mediaSchema(): array
|
|||||||
[, , $alt, $focusX, $focusY] = $this->dataFields();
|
[, , $alt, $focusX, $focusY] = $this->dataFields();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
Group::make(ImageRefFields::fields('Kartenbild', live: true))->statePath('refs'),
|
Group::make([...ImageRefFields::fields('Kartenbild', live: true), ...$this->imageSourceFields()])->statePath('refs'),
|
||||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -248,6 +305,12 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
$data = $widget['data'];
|
$data = $widget['data'];
|
||||||
|
|
||||||
$subject = $this->subject($widget['refs'][$this->refKey()] ?? null, $context);
|
$subject = $this->subject($widget['refs'][$this->refKey()] ?? null, $context);
|
||||||
|
$textSource = $option('text_source', 'auto');
|
||||||
|
|
||||||
|
if ($subject instanceof CardSubject && $textSource !== 'auto' && isset($this->textChoices()[$textSource])) {
|
||||||
|
$subject = $subject->withTextChoice($textSource, $this->missingTextHint($textSource));
|
||||||
|
}
|
||||||
|
|
||||||
$heading = filled($data['heading'] ?? null) ? trim((string) $data['heading']) : null;
|
$heading = filled($data['heading'] ?? null) ? trim((string) $data['heading']) : null;
|
||||||
$lead = filled($data['summary'] ?? null) ? trim((string) $data['summary']) : null;
|
$lead = filled($data['summary'] ?? null) ? trim((string) $data['summary']) : null;
|
||||||
|
|
||||||
@@ -258,8 +321,16 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
$storedImage = WebsiteImage::normalize($widget['refs']['image'] ?? null);
|
$storedImage = WebsiteImage::normalize($widget['refs']['image'] ?? null);
|
||||||
$imageRef = $storedImage ?? $this->centralCoverId($widget['refs'][$this->refKey()] ?? null);
|
$imageRef = $storedImage ?? $this->centralCoverId($widget['refs'][$this->refKey()] ?? null);
|
||||||
|
|
||||||
|
$clip = null;
|
||||||
|
|
||||||
|
if ($this->supportsClip() && $option('clip', 'yes') === 'yes' && $subject instanceof CardSubject) {
|
||||||
|
$owner = $this->clipSubject($widget['refs'][$this->refKey()] ?? null);
|
||||||
|
$clip = $owner instanceof Model ? app(CardClip::class)->for($owner, $context->preview) : null;
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'subject' => $subject,
|
'subject' => $subject,
|
||||||
|
'clip' => $clip,
|
||||||
'cardStyle' => $subject?->style ?? $this->cardStyle(),
|
'cardStyle' => $subject?->style ?? $this->cardStyle(),
|
||||||
'imageUrl' => app(WebsiteImage::class)->url($imageRef, $context->preview),
|
'imageUrl' => app(WebsiteImage::class)->url($imageRef, $context->preview),
|
||||||
'alt' => app(WebsiteImage::class)->alt($imageRef, $data['alt'] ?? null),
|
'alt' => app(WebsiteImage::class)->alt($imageRef, $data['alt'] ?? null),
|
||||||
@@ -299,10 +370,15 @@ protected function centralCoverId(mixed $id): ?int
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function supportsClip(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zentraler Anzeigename oder Teaser des gewählten Objekts (Redaktionsstand) für Platzhalter im Editor.
|
* Zentraler Anzeigename oder Teaser des gewählten Objekts (Redaktionsstand) für Platzhalter im Editor.
|
||||||
*/
|
*/
|
||||||
private function centralText(mixed $id, string $field): ?string
|
private function centralText(mixed $id, string $field, mixed $textSource = null): ?string
|
||||||
{
|
{
|
||||||
if (blank($id)) {
|
if (blank($id)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -314,6 +390,10 @@ private function centralText(mixed $id, string $field): ?string
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($subject instanceof CardSubject && is_string($textSource) && isset($this->textChoices()[$textSource]) && $textSource !== 'auto') {
|
||||||
|
$subject = $subject->withTextChoice($textSource, $this->missingTextHint($textSource));
|
||||||
|
}
|
||||||
|
|
||||||
$text = $subject?->{$field};
|
$text = $subject?->{$field};
|
||||||
|
|
||||||
return is_string($text) && trim($text) !== '' ? Str::limit(trim($text), 120) : null;
|
return is_string($text) && trim($text) !== '' ? Str::limit(trim($text), 120) : null;
|
||||||
|
|||||||
@@ -7,6 +7,11 @@
|
|||||||
use App\Domain\Cms\Catalog\CardSubject;
|
use App\Domain\Cms\Catalog\CardSubject;
|
||||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
|
use App\Domain\Media\CompositionStill;
|
||||||
|
use App\Domain\Media\ThumbnailRef;
|
||||||
|
use Filament\Forms\Components\ViewField;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modul- und Programmkarte (Kit v1.7 „catalog“): ein Programm oder Modul über PublicCatalogReader, dieselbe
|
* Modul- und Programmkarte (Kit v1.7 „catalog“): ein Programm oder Modul über PublicCatalogReader, dieselbe
|
||||||
@@ -41,6 +46,59 @@ 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']];
|
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']];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Das Vorschaubild des Programms oder Moduls als Kartenbild übernehmen. Es wird einmal als Bild-Medium abgelegt
|
||||||
|
* (CompositionStill) und wie jedes andere Bild ausgewählt; die Karte liest nur diese Datei.
|
||||||
|
*/
|
||||||
|
protected function imageSourceFields(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ViewField::make('_programmbild')
|
||||||
|
->label('Bild aus dem Programm oder Modul')
|
||||||
|
->view('filament.cms.kompositionsbild-feld')
|
||||||
|
->dehydrated(false)
|
||||||
|
->visible(fn (Get $get): bool => $this->compositionFor($get('composition')) !== null)
|
||||||
|
->viewData(function (Get $get): array {
|
||||||
|
$composition = $this->compositionFor($get('composition'));
|
||||||
|
|
||||||
|
return [
|
||||||
|
'composition' => $composition,
|
||||||
|
'compositionTitle' => $composition instanceof Composition ? (string) ($composition->display_title ?: $composition->designation) : '',
|
||||||
|
'compositionThumbnailUrl' => $composition instanceof Composition && app(CompositionStill::class)->hasThumbnail($composition)
|
||||||
|
? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path)
|
||||||
|
: null,
|
||||||
|
];
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function compositionFor(mixed $id): ?Composition
|
||||||
|
{
|
||||||
|
$composition = is_numeric($id) ? Composition::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||||
|
|
||||||
|
return $composition instanceof Composition && app(PublicCatalogReader::class)->isCardSelectable($composition) ? $composition : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function subjectNoun(): string
|
||||||
|
{
|
||||||
|
return 'Programm oder Modul';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wählbare Texte: die zentralen Texte des Programms oder Moduls und das Lernziel der Fassung. „Automatisch“ bleibt
|
||||||
|
* wie bisher: Teaser, sonst Kurzbeschreibung, sonst Lernziel. Die ausführliche Beschreibung erscheint nur auf Wahl.
|
||||||
|
*/
|
||||||
|
protected function textChoices(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'auto' => 'Automatisch (Teaser, sonst Kurzbeschreibung, sonst Lernziel)',
|
||||||
|
'teaser' => 'Teaser',
|
||||||
|
'summary' => 'Kurzbeschreibung',
|
||||||
|
'description' => 'Ausführliche Beschreibung (erscheint öffentlich)',
|
||||||
|
'goal' => 'Lernziel der Fassung',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function settings(): array
|
public function settings(): array
|
||||||
{
|
{
|
||||||
// Die Art (Programm oder Modul) bleibt immer sichtbar; sie lässt sich nicht ausblenden.
|
// Die Art (Programm oder Modul) bleibt immer sichtbar; sie lässt sich nicht ausblenden.
|
||||||
@@ -99,6 +157,18 @@ protected function cardStyle(): string
|
|||||||
return 'catalog';
|
return 'catalog';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function supportsClip(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function clipSubject(mixed $id): ?Model
|
||||||
|
{
|
||||||
|
$composition = is_numeric($id) ? Composition::query()->find((int) $id) : null;
|
||||||
|
|
||||||
|
return $composition instanceof Composition ? $composition : null;
|
||||||
|
}
|
||||||
|
|
||||||
protected function centralCoverId(mixed $id): ?int
|
protected function centralCoverId(mixed $id): ?int
|
||||||
{
|
{
|
||||||
$composition = is_numeric($id) ? Composition::query()->find((int) $id) : null;
|
$composition = is_numeric($id) ? Composition::query()->find((int) $id) : null;
|
||||||
|
|||||||
@@ -140,6 +140,27 @@ private function createOrder(User $user, Party $holder, array $pairs): Order
|
|||||||
public function confirmTestPayment(Order $order, string $reference): Order
|
public function confirmTestPayment(Order $order, string $reference): Order
|
||||||
{
|
{
|
||||||
$this->assertTestDriver();
|
$this->assertTestDriver();
|
||||||
|
|
||||||
|
return $this->settle($order, 'test', $reference);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zahlung eines Anbieters (Stripe): wie die Testzahlung, aber erst nach Prüfung von Betrag und Währung gegen die
|
||||||
|
* Bestellung. Wiederholte Meldungen sind wirkungslos.
|
||||||
|
*/
|
||||||
|
public function confirmProviderPayment(Order $order, string $provider, string $reference, int $amountCents, string $currency): Order
|
||||||
|
{
|
||||||
|
$expected = (int) ($order->total_cents ?? $order->lines()->sum('price_cents'));
|
||||||
|
|
||||||
|
if ($amountCents !== $expected || strtoupper($currency) !== strtoupper((string) ($order->currency ?? 'EUR'))) {
|
||||||
|
throw new DomainRuleException('Der gezahlte Betrag weicht von der Bestellung ab.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->settle($order, $provider, $reference);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function settle(Order $order, string $provider, string $reference): Order
|
||||||
|
{
|
||||||
$reference = trim($reference);
|
$reference = trim($reference);
|
||||||
|
|
||||||
if ($reference === '') {
|
if ($reference === '') {
|
||||||
@@ -147,7 +168,7 @@ public function confirmTestPayment(Order $order, string $reference): Order
|
|||||||
}
|
}
|
||||||
|
|
||||||
$paidNow = false;
|
$paidNow = false;
|
||||||
$order = DB::transaction(function () use ($order, $reference, &$paidNow): Order {
|
$order = DB::transaction(function () use ($order, $provider, $reference, &$paidNow): Order {
|
||||||
$order = Order::query()->lockForUpdate()->findOrFail($order->id);
|
$order = Order::query()->lockForUpdate()->findOrFail($order->id);
|
||||||
|
|
||||||
if ($order->status === 'bezahlt') {
|
if ($order->status === 'bezahlt') {
|
||||||
@@ -158,11 +179,11 @@ public function confirmTestPayment(Order $order, string $reference): Order
|
|||||||
throw new DomainRuleException('Diese Bestellung nimmt keine Zahlung mehr an.');
|
throw new DomainRuleException('Diese Bestellung nimmt keine Zahlung mehr an.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$order->payments()->create([
|
// Eine bei Stripe angelegte offene Zahlung mit derselben Referenz wird bestätigt statt doppelt geführt.
|
||||||
'provider' => 'test',
|
$order->payments()->updateOrCreate(
|
||||||
'status' => 'bestaetigt',
|
['provider_reference' => $reference],
|
||||||
'provider_reference' => $reference,
|
['provider' => $provider, 'status' => 'bestaetigt'],
|
||||||
]);
|
);
|
||||||
$order->status = 'bezahlt';
|
$order->status = 'bezahlt';
|
||||||
$order->save();
|
$order->save();
|
||||||
$paidNow = true;
|
$paidNow = true;
|
||||||
|
|||||||
@@ -9,8 +9,19 @@
|
|||||||
*/
|
*/
|
||||||
final class Shop
|
final class Shop
|
||||||
{
|
{
|
||||||
|
public static function driver(): string
|
||||||
|
{
|
||||||
|
return (string) config('services.payment.driver');
|
||||||
|
}
|
||||||
|
|
||||||
public static function enabled(): bool
|
public static function enabled(): bool
|
||||||
{
|
{
|
||||||
return ! app()->isProduction() && config('services.payment.driver') === 'test';
|
return ! app()->isProduction() && in_array(self::driver(), ['test', 'stripe'], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Stripe-Kasse (Etappe 1: nur Testmodus, nie in Produktion). */
|
||||||
|
public static function stripe(): bool
|
||||||
|
{
|
||||||
|
return ! app()->isProduction() && self::driver() === 'stripe';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,148 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Commerce\Stripe;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Commerce\Order;
|
||||||
|
use Illuminate\Http\Client\ConnectionException;
|
||||||
|
use Illuminate\Http\Client\PendingRequest;
|
||||||
|
use Illuminate\Http\Client\Response;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stripe-Kasse (Checkout Session) für die Testzahlung in Etappe 1. Ausschließlich Testschlüssel: Ein Live-Schlüssel
|
||||||
|
* oder die Produktionsumgebung werden abgewiesen, bevor ein Aufruf an Stripe geht. Bezahlt wird bei Stripe; Kartendaten
|
||||||
|
* berühren diese Anwendung nie. Die Freischaltung erfolgt allein über die signierte Meldung (StripeWebhook).
|
||||||
|
*/
|
||||||
|
class StripeGateway
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Legt für die Bestellung eine Checkout Session an oder liefert die noch offene wieder.
|
||||||
|
*
|
||||||
|
* @return array{id: string, url: string}
|
||||||
|
*/
|
||||||
|
public function checkoutFor(Order $order): array
|
||||||
|
{
|
||||||
|
$this->assertSandbox();
|
||||||
|
$order->loadMissing('lines', 'user');
|
||||||
|
|
||||||
|
if ($order->status !== 'offen') {
|
||||||
|
throw new DomainRuleException('Diese Bestellung nimmt keine Zahlung mehr an.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$open = $this->reusableSession($order);
|
||||||
|
|
||||||
|
if ($open !== null) {
|
||||||
|
return $open;
|
||||||
|
}
|
||||||
|
|
||||||
|
$attempt = $order->payments()->where('provider', 'stripe')->count() + 1;
|
||||||
|
$params = [
|
||||||
|
'mode' => 'payment',
|
||||||
|
'client_reference_id' => (string) $order->id,
|
||||||
|
'customer_email' => $order->user->email,
|
||||||
|
'locale' => 'de',
|
||||||
|
'success_url' => route('member.order', $order).'?zahlung=zurueck',
|
||||||
|
'cancel_url' => route('member.order', $order).'?zahlung=abbruch',
|
||||||
|
'metadata' => ['order_id' => (string) $order->id],
|
||||||
|
'payment_intent_data' => ['metadata' => ['order_id' => (string) $order->id]],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($order->lines->values() as $index => $line) {
|
||||||
|
$params['line_items'][$index] = [
|
||||||
|
'quantity' => 1,
|
||||||
|
'price_data' => [
|
||||||
|
'currency' => strtolower((string) ($line->currency ?? $order->currency ?? 'EUR')),
|
||||||
|
'unit_amount' => (int) $line->price_cents,
|
||||||
|
'product_data' => ['name' => filled($line->offer_name) ? (string) $line->offer_name : 'Lizenz'],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = $this->request()
|
||||||
|
->withHeaders(['Idempotency-Key' => 'luf-order-'.$order->id.'-'.$attempt])
|
||||||
|
->post('/v1/checkout/sessions', $params);
|
||||||
|
|
||||||
|
$this->assertOk($response, 'angelegt');
|
||||||
|
$id = (string) $response->json('id');
|
||||||
|
$url = (string) $response->json('url');
|
||||||
|
|
||||||
|
if ($id === '' || $url === '') {
|
||||||
|
throw new DomainRuleException('Stripe hat keine Kasse geliefert. Bitte versuche es später noch einmal.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$order->payments()->create(['provider' => 'stripe', 'status' => 'offen', 'provider_reference' => $id]);
|
||||||
|
|
||||||
|
return ['id' => $id, 'url' => $url];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertSandbox(): void
|
||||||
|
{
|
||||||
|
$secret = (string) config('services.stripe.secret');
|
||||||
|
|
||||||
|
if (app()->isProduction()) {
|
||||||
|
throw new DomainRuleException('Stripe ist in Produktion nicht freigegeben.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($secret === '') {
|
||||||
|
throw new DomainRuleException('Stripe ist nicht eingerichtet: Der Schlüssel fehlt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! str_starts_with($secret, 'sk_test_') && ! str_starts_with($secret, 'rk_test_')) {
|
||||||
|
throw new DomainRuleException('Etappe 1 erlaubt nur den Stripe-Testmodus (Schlüssel sk_test_).');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{id: string, url: string}|null
|
||||||
|
*/
|
||||||
|
private function reusableSession(Order $order): ?array
|
||||||
|
{
|
||||||
|
$payment = $order->payments()->where('provider', 'stripe')->where('status', 'offen')->latest('id')->first();
|
||||||
|
|
||||||
|
if ($payment === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = $this->request()->get('/v1/checkout/sessions/'.$payment->provider_reference);
|
||||||
|
} catch (ConnectionException) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response->successful() && $response->json('status') === 'open' && filled($response->json('url'))) {
|
||||||
|
return ['id' => (string) $payment->provider_reference, 'url' => (string) $response->json('url')];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function request(): PendingRequest
|
||||||
|
{
|
||||||
|
return Http::baseUrl(rtrim((string) config('services.stripe.api_base'), '/'))
|
||||||
|
->withToken((string) config('services.stripe.secret'))
|
||||||
|
->asForm()
|
||||||
|
->acceptJson()
|
||||||
|
->timeout(15);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function assertOk(Response $response, string $what): void
|
||||||
|
{
|
||||||
|
if ($response->successful()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Statuscode, Fehlertyp, Code, betroffener Parameter und Begründung von Stripe, damit die Ursache lesbar ist.
|
||||||
|
// Nie Schlüssel oder Kundendaten; die Begründung wird gekürzt.
|
||||||
|
Log::warning('Stripe-Anfrage fehlgeschlagen', [
|
||||||
|
'status' => $response->status(),
|
||||||
|
'type' => $response->json('error.type'),
|
||||||
|
'code' => $response->json('error.code'),
|
||||||
|
'param' => $response->json('error.param'),
|
||||||
|
'message' => mb_substr((string) $response->json('error.message'), 0, 300),
|
||||||
|
]);
|
||||||
|
|
||||||
|
throw new DomainRuleException('Die Zahlung konnte bei Stripe nicht '.$what.' werden. Bitte versuche es später noch einmal.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Commerce\Stripe;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüft die Signatur einer Stripe-Meldung (Header „Stripe-Signature“: t=Zeit, v1=HMAC-SHA256 über „t.Nutzlast“).
|
||||||
|
* Eine Meldung ohne gültige Signatur oder außerhalb der Zeittoleranz wird abgewiesen.
|
||||||
|
*/
|
||||||
|
class StripeSignature
|
||||||
|
{
|
||||||
|
public const TOLERANCE_SECONDS = 300;
|
||||||
|
|
||||||
|
public function verify(string $payload, ?string $header, ?int $now = null): void
|
||||||
|
{
|
||||||
|
$secret = (string) config('services.stripe.webhook_secret');
|
||||||
|
|
||||||
|
if ($secret === '') {
|
||||||
|
throw new DomainRuleException('Das Webhook-Geheimnis ist nicht eingerichtet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($header === null || trim($header) === '') {
|
||||||
|
throw new DomainRuleException('Die Signatur fehlt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$timestamp = null;
|
||||||
|
$signatures = [];
|
||||||
|
|
||||||
|
foreach (explode(',', $header) as $part) {
|
||||||
|
[$key, $value] = array_pad(explode('=', trim($part), 2), 2, '');
|
||||||
|
|
||||||
|
if ($key === 't') {
|
||||||
|
$timestamp = ctype_digit($value) ? (int) $value : null;
|
||||||
|
} elseif ($key === 'v1' && $value !== '') {
|
||||||
|
$signatures[] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($timestamp === null || $signatures === []) {
|
||||||
|
throw new DomainRuleException('Die Signatur ist unvollständig.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$expected = hash_hmac('sha256', $timestamp.'.'.$payload, $secret);
|
||||||
|
$valid = false;
|
||||||
|
|
||||||
|
foreach ($signatures as $signature) {
|
||||||
|
$valid = hash_equals($expected, $signature) || $valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $valid) {
|
||||||
|
throw new DomainRuleException('Die Signatur stimmt nicht.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (abs(($now ?? now()->getTimestamp()) - $timestamp) > self::TOLERANCE_SECONDS) {
|
||||||
|
throw new DomainRuleException('Die Meldung ist zu alt.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Composition;
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Übernimmt das Vorschaubild eines Programms oder Moduls als gewöhnliches Bild-Medium im Medienmanager
|
||||||
|
* (Programm- und Modulkarte), nach demselben Prinzip wie FilmStill.
|
||||||
|
*
|
||||||
|
* - Ausdrückliche Handlung der Redaktion. Das Vorschaubild ist ein geschütztes Bibliotheksbild; erst die Übernahme
|
||||||
|
* legt ein Medium an, das für die Website freigegeben werden kann (WebsiteIntake, Warteschlange).
|
||||||
|
* - Die Datei wird einmal kopiert. Dieselbe Vorschaudatei ergibt dasselbe Medium (composition_still_sources).
|
||||||
|
* - Es entsteht keine Fassung, keine Berechtigung, kein Lizenzartikel.
|
||||||
|
*/
|
||||||
|
class CompositionStill
|
||||||
|
{
|
||||||
|
/** Wahr, wenn der letzte Aufruf ein schon vorhandenes Bild geliefert hat. */
|
||||||
|
public bool $reused = false;
|
||||||
|
|
||||||
|
public function __construct(private readonly WebsiteIntake $intake) {}
|
||||||
|
|
||||||
|
public function refusal(Composition $composition): ?string
|
||||||
|
{
|
||||||
|
if ($composition->archived_at !== null) {
|
||||||
|
return 'Das Programm oder Modul ist archiviert.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasThumbnail(Composition $composition): bool
|
||||||
|
{
|
||||||
|
$path = $composition->thumbnail_path;
|
||||||
|
|
||||||
|
return is_string($path) && str_starts_with($path, 'vorschau/') && ! str_contains($path, '..')
|
||||||
|
&& Storage::disk('media_derived')->exists($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function fromThumbnail(Composition $composition, ?User $actor = null): ContentElement
|
||||||
|
{
|
||||||
|
$this->reused = false;
|
||||||
|
$refusal = $this->refusal($composition);
|
||||||
|
|
||||||
|
if ($refusal !== null) {
|
||||||
|
throw new DomainRuleException($refusal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->hasThumbnail($composition)) {
|
||||||
|
throw new DomainRuleException('Dieses Programm oder Modul hat noch kein Vorschaubild. Setzen Sie es im Redaktionsmanager.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$bytes = Storage::disk('media_derived')->get((string) $composition->thumbnail_path);
|
||||||
|
|
||||||
|
if (! is_string($bytes) || $bytes === '') {
|
||||||
|
throw new DomainRuleException('Das Vorschaubild ließ sich nicht lesen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$key = 'file:'.hash('sha256', $bytes);
|
||||||
|
$existing = $this->existing($composition, $key);
|
||||||
|
|
||||||
|
if ($existing instanceof ContentElement) {
|
||||||
|
$this->reused = true;
|
||||||
|
|
||||||
|
return $existing;
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = (string) ($composition->display_title ?: $composition->designation);
|
||||||
|
$path = 'cms/titelbild-'.$composition->id.'-'.Str::lower(Str::random(8)).'.jpg';
|
||||||
|
Storage::disk('cms_incoming')->put($path, $bytes);
|
||||||
|
|
||||||
|
$still = $this->intake->acceptImage($path, 'Titelbild: '.$title, null, 'Titelbild zu „'.$title.'“', $actor);
|
||||||
|
|
||||||
|
try {
|
||||||
|
CompositionStillSource::query()->updateOrCreate(
|
||||||
|
['composition_id' => $composition->id, 'source_key' => $key],
|
||||||
|
['still_element_id' => $still->id, 'actor_id' => $actor?->id],
|
||||||
|
);
|
||||||
|
} catch (QueryException) {
|
||||||
|
return $this->existing($composition, $key) ?? $still;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $still;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function existing(Composition $composition, string $key): ?ContentElement
|
||||||
|
{
|
||||||
|
$source = CompositionStillSource::query()->with('still')->where('composition_id', $composition->id)->where('source_key', $key)->first();
|
||||||
|
$still = $source?->still;
|
||||||
|
|
||||||
|
// Ein archiviertes oder bei der Verarbeitung gescheitertes Bild wird nicht wiederverwendet.
|
||||||
|
return $still instanceof ContentElement && $still->archived_at === null && ! filled($still->thumbnail_error) ? $still : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Composition;
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Herkunft eines Bild-Mediums aus dem Vorschaubild eines Programms oder Moduls (source_key file:{SHA-256}).
|
||||||
|
*/
|
||||||
|
class CompositionStillSource extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['composition_id', 'still_element_id', 'source_key', 'actor_id'];
|
||||||
|
|
||||||
|
public function composition(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Composition::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function still(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(ContentElement::class, 'still_element_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,213 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentElementVersion;
|
||||||
|
use App\Domain\Catalog\ContentVersionStatus;
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\QueryException;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt ein Bild aus einem Film als gewöhnliches Bild-Medium im Medienmanager ab (Medien- und Materialkarte).
|
||||||
|
*
|
||||||
|
* - Zwei Wege: das Vorschaubild des Films übernehmen oder eine Stelle (Sekunde) wählen. Beides ist eine
|
||||||
|
* ausdrückliche Handlung der Redaktion; erst dadurch entsteht ein Bild, das für die Website freigegeben werden kann.
|
||||||
|
* - Das Bild wird einmal gezogen und gespeichert (WebsiteIntake legt es an, die Warteschlange leitet es ab und gibt
|
||||||
|
* es frei). Seitenaufrufe lesen nur die gespeicherte Datei und starten nie ffmpeg.
|
||||||
|
* - Dieselbe Stelle (oder dieselbe Vorschaudatei) ergibt dasselbe Medium (film_still_sources).
|
||||||
|
* - Es wird nie der Film selbst, nur ein Einzelbild bis 1600 px Breite abgelegt. Traineranleitungen und
|
||||||
|
* archivierte oder gesperrte Filme sind ausgeschlossen. Eine Rechte- oder Lizenzentscheidung entsteht nicht.
|
||||||
|
*/
|
||||||
|
class FilmStill
|
||||||
|
{
|
||||||
|
/** Breite eines übernommenen Standbilds; die kleine Filmstufe (640 px) wäre auf der Website sichtbar unscharf. */
|
||||||
|
public const WIDTH = 1600;
|
||||||
|
|
||||||
|
/** Wahr, wenn der letzte Aufruf ein schon vorhandenes Bild geliefert hat (keine neue Extraktion). */
|
||||||
|
public bool $reused = false;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
private readonly ThumbnailDeriver $deriver,
|
||||||
|
private readonly WebsiteIntake $intake,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
/** Grund, warum aus diesem Medium kein Standbild übernommen wird, sonst null. */
|
||||||
|
public function refusal(ContentElement $film): ?string
|
||||||
|
{
|
||||||
|
if ($film->output_class !== 'film') {
|
||||||
|
return 'Nur aus einem Film lässt sich ein Bild übernehmen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($film->archived_at !== null) {
|
||||||
|
return 'Der Film ist archiviert.';
|
||||||
|
}
|
||||||
|
|
||||||
|
$slug = $film->editorialContentKind?->slug;
|
||||||
|
|
||||||
|
if (in_array($slug, PublicMaterialReader::CONFIDENTIAL_KINDS, true)) {
|
||||||
|
return 'Aus Traineranleitungen werden keine Bilder für die Website übernommen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Die bereitgestellte Fassung, aus der Stellen gezogen werden (die höchste). */
|
||||||
|
public function version(ContentElement $film): ?ContentElementVersion
|
||||||
|
{
|
||||||
|
return $film->versions()
|
||||||
|
->where('status', ContentVersionStatus::Bereit->value)
|
||||||
|
->orderByDesc('number')
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sekunde der Stelle, aus der das aktuelle Vorschaubild des Films stammt, sonst null. */
|
||||||
|
public function thumbnailSecond(ContentElement $film): ?string
|
||||||
|
{
|
||||||
|
$source = $film->thumbnail_source;
|
||||||
|
|
||||||
|
return is_string($source) && preg_match('/^frame:\d+@([\d.]+)$/', $source, $match) === 1 ? $match[1] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function fromSecond(ContentElement $film, float $seconds, ?User $actor = null): ContentElement
|
||||||
|
{
|
||||||
|
$this->reused = false;
|
||||||
|
$this->guard($film);
|
||||||
|
|
||||||
|
if ($seconds < 0 || $seconds > 7200) {
|
||||||
|
throw new DomainRuleException('Die Zeitposition liegt außerhalb des Films.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = $this->version($film);
|
||||||
|
|
||||||
|
if (! $version instanceof ContentElementVersion) {
|
||||||
|
throw new DomainRuleException('Der Film hat noch keine bereitgestellte Fassung.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->fromFrame($film, $version, $seconds, $actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function fromThumbnail(ContentElement $film, ?User $actor = null): ContentElement
|
||||||
|
{
|
||||||
|
$this->reused = false;
|
||||||
|
$this->guard($film);
|
||||||
|
|
||||||
|
// Stammt das Vorschaubild aus einer Filmstelle, wird dieselbe Stelle in voller Auflösung gezogen.
|
||||||
|
$second = $this->thumbnailSecond($film);
|
||||||
|
|
||||||
|
if ($second !== null && preg_match('/^frame:(\d+)@/', (string) $film->thumbnail_source, $match) === 1) {
|
||||||
|
$version = ContentElementVersion::query()->find((int) $match[1]);
|
||||||
|
|
||||||
|
if ($version instanceof ContentElementVersion
|
||||||
|
&& (int) $version->content_element_id === (int) $film->id
|
||||||
|
&& $version->status !== ContentVersionStatus::Gesperrt) {
|
||||||
|
try {
|
||||||
|
return $this->fromFrame($film, $version, (float) $second, $actor);
|
||||||
|
} catch (DomainRuleException) {
|
||||||
|
// Die Stelle lässt sich nicht mehr ziehen: das gespeicherte Vorschaubild selbst übernehmen.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $film->thumbnail_path;
|
||||||
|
|
||||||
|
if (! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..') || ! Storage::disk('media_derived')->exists($path)) {
|
||||||
|
throw new DomainRuleException('Dieser Film hat noch kein Vorschaubild. Setzen Sie es im Medienmanager oder wählen Sie eine Stelle.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$bytes = Storage::disk('media_derived')->get($path);
|
||||||
|
|
||||||
|
if (! is_string($bytes) || $bytes === '') {
|
||||||
|
throw new DomainRuleException('Das Vorschaubild ließ sich nicht lesen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$key = 'file:'.hash('sha256', $bytes);
|
||||||
|
$existing = $this->existing($film, $key);
|
||||||
|
|
||||||
|
if ($existing instanceof ContentElement) {
|
||||||
|
$this->reused = true;
|
||||||
|
|
||||||
|
return $existing;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->store($film, $key, $bytes, 'Vorschaubild', $actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fromFrame(ContentElement $film, ContentElementVersion $version, float $seconds, ?User $actor): ContentElement
|
||||||
|
{
|
||||||
|
$second = $this->secondText($seconds);
|
||||||
|
$key = 'frame:'.$version->id.'@'.$second;
|
||||||
|
$existing = $this->existing($film, $key);
|
||||||
|
|
||||||
|
if ($existing instanceof ContentElement) {
|
||||||
|
$this->reused = true;
|
||||||
|
|
||||||
|
return $existing;
|
||||||
|
}
|
||||||
|
|
||||||
|
$bytes = $this->deriver->frameJpeg($version, (float) $second, self::WIDTH, original: true);
|
||||||
|
|
||||||
|
if (! is_string($bytes)) {
|
||||||
|
throw new DomainRuleException('Aus dieser Filmstelle ließ sich kein Bild erzeugen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->store($film, $key, $bytes, 'Fassung '.$version->number.', '.str_replace('.', ',', $second).' s', $actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function guard(ContentElement $film): void
|
||||||
|
{
|
||||||
|
$refusal = $this->refusal($film);
|
||||||
|
|
||||||
|
if ($refusal !== null) {
|
||||||
|
throw new DomainRuleException($refusal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function existing(ContentElement $film, string $key): ?ContentElement
|
||||||
|
{
|
||||||
|
$source = FilmStillSource::query()->with('still')->where('film_element_id', $film->id)->where('source_key', $key)->first();
|
||||||
|
$still = $source?->still;
|
||||||
|
|
||||||
|
// Ein archiviertes oder an der Verarbeitung gescheitertes Bild wird nicht wiederverwendet; die Stelle kann neu
|
||||||
|
// übernommen werden (store() ordnet dann das neue Bild zu).
|
||||||
|
return $still instanceof ContentElement && $still->archived_at === null && ! filled($still->thumbnail_error) ? $still : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function store(ContentElement $film, string $key, string $bytes, string $label, ?User $actor): ContentElement
|
||||||
|
{
|
||||||
|
$title = (string) ($film->display_title ?: $film->working_title);
|
||||||
|
$path = 'cms/standbild-'.$film->id.'-'.Str::lower(Str::random(8)).'.jpg';
|
||||||
|
Storage::disk('cms_incoming')->put($path, $bytes);
|
||||||
|
|
||||||
|
$still = $this->intake->acceptImage(
|
||||||
|
$path,
|
||||||
|
'Standbild: '.$title.' ('.$label.')',
|
||||||
|
filled($film->website_credit) ? (string) $film->website_credit : null,
|
||||||
|
'Szene aus dem Film „'.$title.'“',
|
||||||
|
$actor,
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
FilmStillSource::query()->updateOrCreate(
|
||||||
|
['film_element_id' => $film->id, 'source_key' => $key],
|
||||||
|
['still_element_id' => $still->id, 'actor_id' => $actor?->id],
|
||||||
|
);
|
||||||
|
} catch (QueryException) {
|
||||||
|
// Gleichzeitige Übernahme derselben Stelle: das zuerst angelegte Bild gilt.
|
||||||
|
return $this->existing($film, $key) ?? $still;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $still;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function secondText(float $seconds): string
|
||||||
|
{
|
||||||
|
$text = number_format(max(0, min(7200, $seconds)), 3, '.', '');
|
||||||
|
|
||||||
|
return rtrim(rtrim($text, '0'), '.') ?: '0';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Herkunft eines Standbilds: aus welchem Film und welcher Stelle (frame:{Fassung}@{Sekunde}) oder aus welcher Datei
|
||||||
|
* (file:{SHA-256}) das Bild-Medium stammt.
|
||||||
|
*/
|
||||||
|
class FilmStillSource extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['film_element_id', 'still_element_id', 'source_key', 'actor_id'];
|
||||||
|
|
||||||
|
public function film(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(ContentElement::class, 'film_element_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function still(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(ContentElement::class, 'still_element_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,39 +4,72 @@
|
|||||||
|
|
||||||
use App\Domain\Catalog\ContentElement;
|
use App\Domain\Catalog\ContentElement;
|
||||||
use App\Domain\Catalog\DomainRuleException;
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Jobs\StorePresentationFile;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Legt die technische Ableitung eines Präsentationsmediums an der Medienidentität ab.
|
* Legt die technische Ableitung eines Präsentationsmediums (Website-Datei) an der Medienidentität ab.
|
||||||
* Es entsteht keine Inhaltsfassung, keine Freigabe und keine Berechtigung.
|
* Es entsteht keine Inhaltsfassung, keine Freigabe und keine Berechtigung. Eine vorhandene Inhaltsfassung bleibt
|
||||||
|
* unverändert und geschützt; die Website-Datei ist eine eigene, bewusst gewählte Datei daneben.
|
||||||
|
*
|
||||||
|
* Der Web-Prozess hat `derived/` nur lesend. Er prüft deshalb nur und gibt das Kopieren an die Warteschlange
|
||||||
|
* (`StorePresentationFile`, ruft `place()` auf).
|
||||||
*/
|
*/
|
||||||
class PresentationFile
|
class PresentationFile
|
||||||
{
|
{
|
||||||
public function store(ContentElement $element, string $incoming): void
|
/**
|
||||||
|
* Dateiendungen, die ein Browser auf der Website abspielen kann.
|
||||||
|
*
|
||||||
|
* @var array<string, list<string>>
|
||||||
|
*/
|
||||||
|
public const EXTENSIONS = [
|
||||||
|
'bild' => ['jpg', 'jpeg', 'png', 'webp', 'gif'],
|
||||||
|
'audio' => ['mp3', 'm4a', 'ogg'],
|
||||||
|
'film' => ['mp4', 'webm'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüft die Datei im Eingang, ohne etwas zu verändern. Wirft eine verständliche Regelverletzung.
|
||||||
|
*/
|
||||||
|
public function validate(string $outputClass, string $incoming): void
|
||||||
{
|
{
|
||||||
if (! in_array($element->output_class, ['bild', 'film', 'audio'], true)) {
|
if (! isset(self::EXTENSIONS[$outputClass])) {
|
||||||
throw new DomainRuleException('Eine Präsentationsdatei ist ein Bild, ein Film oder ein Hörstück.');
|
throw new DomainRuleException('Eine Präsentationsdatei ist ein Bild, ein Film oder ein Hörstück.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($element->versions()->exists()) {
|
$extension = strtolower(pathinfo($incoming, PATHINFO_EXTENSION));
|
||||||
throw new DomainRuleException('Dieses Medium hat bereits eine Inhaltsfassung. Die Präsentationsdatei ersetzt sie nicht.');
|
|
||||||
|
if (! in_array($extension, self::EXTENSIONS[$outputClass], true)) {
|
||||||
|
throw new DomainRuleException(sprintf(
|
||||||
|
'Für die Website geht nur %s. Eine %s-Datei kann der Browser nicht direkt abspielen; wandle sie vorher um oder lade sie ohne „Eigenständiges Präsentationsmedium“ hoch.',
|
||||||
|
$this->formats($outputClass),
|
||||||
|
$extension === '' ? 'Datei ohne Endung' : '.'.$extension,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->readable($incoming)) {
|
if (! $this->readable($incoming)) {
|
||||||
throw new DomainRuleException('Die Datei liegt nicht im Eingang.');
|
throw new DomainRuleException('Die Datei liegt nicht im Eingang.');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(ContentElement $element, string $incoming): void
|
||||||
|
{
|
||||||
|
$this->validate((string) $element->output_class, $incoming);
|
||||||
|
|
||||||
|
$element->thumbnail_error = null;
|
||||||
|
$element->save();
|
||||||
|
|
||||||
|
StorePresentationFile::dispatch($element->id, $incoming);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kopiert die Datei nach `derived/`. Läuft nur in der Warteschlange, die dort schreiben darf.
|
||||||
|
*/
|
||||||
|
public function place(ContentElement $element, string $incoming): void
|
||||||
|
{
|
||||||
|
$this->validate((string) $element->output_class, $incoming);
|
||||||
|
|
||||||
$extension = strtolower(pathinfo($incoming, PATHINFO_EXTENSION));
|
$extension = strtolower(pathinfo($incoming, PATHINFO_EXTENSION));
|
||||||
$allowed = match ($element->output_class) {
|
|
||||||
'bild' => ['jpg', 'jpeg', 'png', 'webp', 'gif'],
|
|
||||||
'audio' => ['mp3', 'm4a', 'ogg'],
|
|
||||||
default => ['mp4', 'webm'],
|
|
||||||
};
|
|
||||||
|
|
||||||
if (! in_array($extension, $allowed, true)) {
|
|
||||||
throw new DomainRuleException('Diese Datei ist keine freigebbare Ableitung. Es wird keine Inhaltsfassung angelegt.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$prefix = $element->output_class === 'bild' ? 'vorschau' : 'teaser';
|
$prefix = $element->output_class === 'bild' ? 'vorschau' : 'teaser';
|
||||||
$target = $prefix.'/'.$element->id.'/datei.'.$extension;
|
$target = $prefix.'/'.$element->id.'/datei.'.$extension;
|
||||||
$stream = Storage::disk('cms_incoming')->readStream($incoming);
|
$stream = Storage::disk('cms_incoming')->readStream($incoming);
|
||||||
@@ -46,11 +79,15 @@ public function store(ContentElement $element, string $incoming): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Storage::disk('media_derived')->writeStream($target, $stream);
|
$written = Storage::disk('media_derived')->writeStream($target, $stream);
|
||||||
} finally {
|
} finally {
|
||||||
fclose($stream);
|
fclose($stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($written === false) {
|
||||||
|
throw new DomainRuleException('Die Datei ließ sich nicht ablegen.');
|
||||||
|
}
|
||||||
|
|
||||||
if ($element->output_class === 'bild') {
|
if ($element->output_class === 'bild') {
|
||||||
$element->thumbnail_path = $target;
|
$element->thumbnail_path = $target;
|
||||||
$element->thumbnail_source = 'eigen';
|
$element->thumbnail_source = 'eigen';
|
||||||
@@ -58,7 +95,18 @@ public function store(ContentElement $element, string $incoming): void
|
|||||||
$element->preview_path = $target;
|
$element->preview_path = $target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$element->thumbnail_error = null;
|
||||||
$element->save();
|
$element->save();
|
||||||
|
Storage::disk('cms_incoming')->delete($incoming);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function formats(string $outputClass): string
|
||||||
|
{
|
||||||
|
return match ($outputClass) {
|
||||||
|
'bild' => 'JPG, PNG, WebP oder GIF',
|
||||||
|
'audio' => 'MP3, M4A oder OGG',
|
||||||
|
default => 'MP4 (H.264) oder WebM',
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private function readable(string $path): bool
|
private function readable(string $path): bool
|
||||||
|
|||||||
@@ -87,6 +87,27 @@ public function forElementFrame(ContentElement $element, ContentElementVersion $
|
|||||||
$this->rememberElement($element, 'frame:'.$version->id.'@'.$this->secondText($seconds));
|
$this->rememberElement($element, 'frame:'.$version->id.'@'.$this->secondText($seconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vorschaubild aus einer Stelle der Website-Datei. Die Herkunft steht als `frame:0@{Sekunde}`; die 0 steht für die
|
||||||
|
* Website-Datei (es gibt keine Fassung), alle Leser der Herkunft kommen damit zurecht.
|
||||||
|
*/
|
||||||
|
public function forElementWebsiteFrame(ContentElement $element, float $seconds): void
|
||||||
|
{
|
||||||
|
$bytes = $this->jpegAtWebsiteFile($element, $seconds);
|
||||||
|
|
||||||
|
if (! is_string($bytes)) {
|
||||||
|
$this->fail($element, 'Aus dieser Filmstelle ließ sich kein Vorschaubild erzeugen.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = 'element-'.$element->id;
|
||||||
|
$path = 'vorschau/'.$name.'.jpg';
|
||||||
|
Storage::disk('media_derived')->put($path, $bytes);
|
||||||
|
$this->still($element, Storage::disk('media_derived'), $path, $name);
|
||||||
|
$this->rememberElement($element, 'frame:0@'.$this->secondText($seconds));
|
||||||
|
}
|
||||||
|
|
||||||
public function forCompositionUpload(Composition $composition, string $incoming): void
|
public function forCompositionUpload(Composition $composition, string $incoming): void
|
||||||
{
|
{
|
||||||
if (! str_starts_with($incoming, 'vorschau/') || str_contains($incoming, '..')) {
|
if (! str_starts_with($incoming, 'vorschau/') || str_contains($incoming, '..')) {
|
||||||
@@ -138,8 +159,20 @@ public function forCompositionFrame(Composition $composition, ContentElementVers
|
|||||||
$this->rememberChoice($composition, 'frame:'.$version->id.'@'.$this->secondText($seconds));
|
$this->rememberChoice($composition, 'frame:'.$version->id.'@'.$this->secondText($seconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function frameInput(ContentElementVersion $version): ?string
|
/**
|
||||||
|
* Datei, aus der ein Bild gezogen wird. Vorgabe: die kleine Filmstufe (schnell, für die Vorschau). Mit $original
|
||||||
|
* zuerst die Mediendatei selbst, damit ein übernommenes Standbild nicht aus der kleinen Stufe hochgerechnet wird.
|
||||||
|
*/
|
||||||
|
public function frameInput(ContentElementVersion $version, bool $original = false): ?string
|
||||||
{
|
{
|
||||||
|
if ($original) {
|
||||||
|
$master = is_array($version->metadata) ? ($version->metadata['file'] ?? null) : null;
|
||||||
|
|
||||||
|
if ($this->readableDerived($master, 'inhalte/')) {
|
||||||
|
return $master;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$proxy = MediaRendition::query()
|
$proxy = MediaRendition::query()
|
||||||
->where('content_element_version_id', $version->id)
|
->where('content_element_version_id', $version->id)
|
||||||
->where('role', 'variant')
|
->where('role', 'variant')
|
||||||
@@ -155,15 +188,46 @@ public function frameInput(ContentElementVersion $version): ?string
|
|||||||
return $this->readableDerived($file, 'inhalte/') ? $file : null;
|
return $this->readableDerived($file, 'inhalte/') ? $file : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Einzelbild einer Filmstelle als JPEG, 640 px breit aus der kleinen Stufe (Vorschau im Editor und Vorschaubild).
|
||||||
|
*/
|
||||||
public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?string
|
public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?string
|
||||||
|
{
|
||||||
|
return $this->frameJpeg($version, $seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Einzelbild einer Filmstelle als JPEG. Ein übernommenes Standbild (FilmStill) wird mit $width und $original aus der
|
||||||
|
* Mediendatei gezogen statt aus der kleinen Stufe und dabei nie über die Breite der Quelle hinaus vergrößert.
|
||||||
|
*/
|
||||||
|
public function frameJpeg(ContentElementVersion $version, float $seconds, int $width = 640, bool $original = false): ?string
|
||||||
{
|
{
|
||||||
if ($seconds < 0 || $seconds > 7200) {
|
if ($seconds < 0 || $seconds > 7200) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = $this->frameInput($version);
|
$file = $this->frameInput($version, $original);
|
||||||
|
|
||||||
if ($file === null) {
|
return $file === null ? null : $this->jpegFromFile($file, $seconds, $width);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Einzelbild aus der Website-Datei eines Films (`teaser/`), für Medien ohne Inhaltsfassung.
|
||||||
|
*/
|
||||||
|
public function jpegAtWebsiteFile(ContentElement $element, float $seconds): ?string
|
||||||
|
{
|
||||||
|
$file = $element->preview_path;
|
||||||
|
|
||||||
|
if ($element->output_class !== 'film' || ! $this->readableDerived($file, 'teaser/')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->jpegFromFile($file, $seconds, 640);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function jpegFromFile(string $file, float $seconds, int $width): ?string
|
||||||
|
{
|
||||||
|
if ($seconds < 0 || $seconds > 7200) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,7 +250,7 @@ public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?
|
|||||||
'-frames:v',
|
'-frames:v',
|
||||||
'1',
|
'1',
|
||||||
'-vf',
|
'-vf',
|
||||||
'scale=640:-2',
|
$width === 640 ? 'scale=640:-2' : 'scale=min('.max(160, min(2400, $width)).'\,iw):-2',
|
||||||
'-f',
|
'-f',
|
||||||
'image2pipe',
|
'image2pipe',
|
||||||
'-vcodec',
|
'-vcodec',
|
||||||
|
|||||||
@@ -37,6 +37,16 @@ public static function effectiveFor(mixed $path): ?self
|
|||||||
return $alias instanceof self && $alias->everReleased() ? $alias : null;
|
return $alias instanceof self && $alias->everReleased() ? $alias : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Früherer Pfad, dessen übernommenes Medium inzwischen gelöscht wurde. Die Datei unter cms/ bleibt liegen, wird aber
|
||||||
|
* weder ausgeliefert noch als Bild gezeigt: Das Löschen des Mediums gilt auch für die frühere Adresse.
|
||||||
|
*/
|
||||||
|
public static function isRetired(mixed $path): bool
|
||||||
|
{
|
||||||
|
return is_string($path) && $path !== ''
|
||||||
|
&& self::query()->where('legacy_path', $path)->whereNull('content_element_id')->exists();
|
||||||
|
}
|
||||||
|
|
||||||
public function everReleased(): bool
|
public function everReleased(): bool
|
||||||
{
|
{
|
||||||
$element = $this->element;
|
$element = $this->element;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public function refusal(ContentElement $element): ?string
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->derivedPath($element) === null) {
|
if ($this->derivedPath($element) === null) {
|
||||||
return 'Für die Website fehlt eine freigebbare Ableitung. Beim Bild ist das das Vorschaubild. Film und Hörstück ohne Inhaltsfassung nutzen die Datei am Medium unter teaser/. Ein Film mit Inhaltsfassung nutzt die Teaserfassung seiner bereitgestellten Fassung. Die Originaldatei bleibt geschützt.';
|
return 'Für die Website fehlt eine freigebbare Datei. Beim Bild ist das das Vorschaubild. Bei Film und Hörstück lädst du unter „Website-Freigabe“ eine Website-Datei hoch (Film als MP4 oder WebM); die geschützte Originaldatei bleibt unberührt.';
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ class ListContentElements extends ListRecords
|
|||||||
#[Url(as: 'freigabe', except: '')]
|
#[Url(as: 'freigabe', except: '')]
|
||||||
public string $freigabe = '';
|
public string $freigabe = '';
|
||||||
|
|
||||||
|
#[Url(as: 'schutz', except: '')]
|
||||||
|
public string $schutz = '';
|
||||||
|
|
||||||
#[Url(as: 'entwurf', except: '')]
|
#[Url(as: 'entwurf', except: '')]
|
||||||
public string $entwurf = '';
|
public string $entwurf = '';
|
||||||
|
|
||||||
@@ -85,7 +88,7 @@ public function content(Schema $schema): Schema
|
|||||||
|
|
||||||
protected function bestandFilterEigenschaften(): array
|
protected function bestandFilterEigenschaften(): array
|
||||||
{
|
{
|
||||||
return ['suche', 'art', 'freigabe', 'entwurf', 'fassung', 'nutzung', 'saeule', 'inhaltsart', 'einordnung', 'verarbeitung', 'archiv'];
|
return ['suche', 'art', 'schutz', 'freigabe', 'entwurf', 'fassung', 'nutzung', 'saeule', 'inhaltsart', 'einordnung', 'verarbeitung', 'archiv'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showingList(): bool
|
public function showingList(): bool
|
||||||
@@ -138,6 +141,7 @@ public function filtersActive(): bool
|
|||||||
return trim($this->suche) !== ''
|
return trim($this->suche) !== ''
|
||||||
|| $this->art !== ''
|
|| $this->art !== ''
|
||||||
|| $this->freigabe !== ''
|
|| $this->freigabe !== ''
|
||||||
|
|| $this->schutz !== ''
|
||||||
|| $this->entwurf !== ''
|
|| $this->entwurf !== ''
|
||||||
|| $this->fassung !== ''
|
|| $this->fassung !== ''
|
||||||
|| $this->nutzung !== ''
|
|| $this->nutzung !== ''
|
||||||
@@ -153,6 +157,7 @@ public function resetFilters(): void
|
|||||||
$this->suche = '';
|
$this->suche = '';
|
||||||
$this->art = '';
|
$this->art = '';
|
||||||
$this->freigabe = '';
|
$this->freigabe = '';
|
||||||
|
$this->schutz = '';
|
||||||
$this->entwurf = '';
|
$this->entwurf = '';
|
||||||
$this->fassung = '';
|
$this->fassung = '';
|
||||||
$this->nutzung = '';
|
$this->nutzung = '';
|
||||||
@@ -200,11 +205,12 @@ public function bestand(): array
|
|||||||
'suche' => ['eigenschaft' => 'suche', 'label' => 'Suche', 'platzhalter' => 'Titel, Beschreibung oder Suchbegriff'],
|
'suche' => ['eigenschaft' => 'suche', 'label' => 'Suche', 'platzhalter' => 'Titel, Beschreibung oder Suchbegriff'],
|
||||||
'filter' => [
|
'filter' => [
|
||||||
['eigenschaft' => 'art', 'label' => 'Technische Art', 'vorgabe' => '', 'alle' => 'Alle Arten', 'optionen' => $optionen($this->typeOptions(), 'value', 'label')],
|
['eigenschaft' => 'art', 'label' => 'Technische Art', 'vorgabe' => '', 'alle' => 'Alle Arten', 'optionen' => $optionen($this->typeOptions(), 'value', 'label')],
|
||||||
|
['eigenschaft' => 'schutz', 'label' => 'Schutz', 'vorgabe' => '', 'alle' => 'Alle Medien', 'optionen' => ['geschuetzt' => 'Geschützte Medien', 'oeffentlich' => 'Öffentliche Medien', 'website' => 'Auf der Website frei']],
|
||||||
['eigenschaft' => 'freigabe', 'label' => 'Freigabe', 'vorgabe' => '', 'alle' => 'Alle Freigaben', 'optionen' => ['freigegeben' => 'Freigegebene Fassung', 'entwurf' => 'Nur offener Entwurf', 'ohne' => 'Keine freigegebene Fassung']],
|
['eigenschaft' => 'freigabe', 'label' => 'Freigabe', 'vorgabe' => '', 'alle' => 'Alle Freigaben', 'optionen' => ['freigegeben' => 'Freigegebene Fassung', 'entwurf' => 'Nur offener Entwurf', 'ohne' => 'Keine freigegebene Fassung']],
|
||||||
['eigenschaft' => 'nutzung', 'label' => 'Verwendung', 'vorgabe' => '', 'alle' => 'Verwendung egal', 'optionen' => ['verwendet' => 'Verwendet', 'unbenutzt' => 'Nicht verwendet']],
|
['eigenschaft' => 'nutzung', 'label' => 'Verwendung', 'vorgabe' => '', 'alle' => 'Verwendung egal', 'optionen' => ['verwendet' => 'Verwendet', 'unbenutzt' => 'Nicht verwendet']],
|
||||||
],
|
],
|
||||||
'weitere' => $weitere,
|
'weitere' => $weitere,
|
||||||
'hinweis' => 'Freigabe meint die Fassung des Mediums, nicht die Website und keinen Zugriff. Materialart und Einordnung sind die redaktionelle Klassifikation; Verwendung zeigt, wo das Medium tatsächlich eingebunden ist. Deaktivierte und archivierte Medien bleiben über „Weitere Filter“ auffindbar.',
|
'hinweis' => 'Freigabe meint die Fassung des Mediums, nicht die Website und keinen Zugriff. Geschützte Medien haben eine Inhaltsfassung und laufen über Lizenzen. Öffentliche Medien sind eigenständige Präsentationsmedien ohne Fassung für die Website; ob sie freigegeben sind, zeigt die Kennzeichnung an der Zeile. Materialart und Einordnung sind die redaktionelle Klassifikation; Verwendung zeigt, wo das Medium tatsächlich eingebunden ist. Deaktivierte und archivierte Medien bleiben über „Weitere Filter“ auffindbar.',
|
||||||
'zeilen' => array_map($this->zeile(...), $this->cards()),
|
'zeilen' => array_map($this->zeile(...), $this->cards()),
|
||||||
'einheit' => ['Medium', 'Medien'],
|
'einheit' => ['Medium', 'Medien'],
|
||||||
'leer' => ['titel' => 'Noch keine Medien', 'text' => 'Mit „Medium anlegen“ oben lädst du eine Datei hoch oder schreibst einen Text.'],
|
'leer' => ['titel' => 'Noch keine Medien', 'text' => 'Mit „Medium anlegen“ oben lädst du eine Datei hoch oder schreibst einen Text.'],
|
||||||
@@ -218,13 +224,19 @@ public function bestand(): array
|
|||||||
*/
|
*/
|
||||||
private function zeile(array $card): array
|
private function zeile(array $card): array
|
||||||
{
|
{
|
||||||
$chips = [['label' => $card['stand'], 'ton' => match ($card['standTone']) {
|
$chips = [['label' => $card['presentation'] ? 'Präsentationsmedium, ohne Inhaltsfassung' : $card['stand'], 'ton' => match ($card['standTone']) {
|
||||||
'ready' => 'gut',
|
'ready' => 'gut',
|
||||||
'draft' => 'offen',
|
'draft' => 'offen',
|
||||||
'blocked' => 'achtung',
|
'blocked' => 'achtung',
|
||||||
default => 'leise',
|
default => 'leise',
|
||||||
}]];
|
}]];
|
||||||
|
|
||||||
|
if ($card['websiteReleased']) {
|
||||||
|
$chips[] = ['label' => 'Für die Website freigegeben', 'ton' => 'gut'];
|
||||||
|
} elseif ($card['presentation']) {
|
||||||
|
$chips[] = ['label' => 'Nicht für die Website freigegeben', 'ton' => 'offen'];
|
||||||
|
}
|
||||||
|
|
||||||
foreach ([['draftNote', 'offen'], ['blockedNote', 'achtung'], ['processing', 'offen'], ['versionLabel', 'leise']] as [$feld, $ton]) {
|
foreach ([['draftNote', 'offen'], ['blockedNote', 'achtung'], ['processing', 'offen'], ['versionLabel', 'leise']] as [$feld, $ton]) {
|
||||||
if (filled($card[$feld] ?? null)) {
|
if (filled($card[$feld] ?? null)) {
|
||||||
$chips[] = ['label' => (string) $card[$feld], 'ton' => $ton];
|
$chips[] = ['label' => (string) $card[$feld], 'ton' => $ton];
|
||||||
@@ -272,6 +284,7 @@ private function libraryFilters(): array
|
|||||||
'suche' => $this->suche,
|
'suche' => $this->suche,
|
||||||
'art' => $this->art,
|
'art' => $this->art,
|
||||||
'freigabe' => $this->freigabe,
|
'freigabe' => $this->freigabe,
|
||||||
|
'schutz' => $this->schutz,
|
||||||
'entwurf' => $this->entwurf,
|
'entwurf' => $this->entwurf,
|
||||||
'fassung' => $this->fassung,
|
'fassung' => $this->fassung,
|
||||||
'nutzung' => $this->nutzung,
|
'nutzung' => $this->nutzung,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
use App\Domain\Cms\WebsiteImageUsage;
|
use App\Domain\Cms\WebsiteImageUsage;
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
|
use App\Domain\Media\PresentationFile;
|
||||||
use App\Domain\Media\ThumbnailRef;
|
use App\Domain\Media\ThumbnailRef;
|
||||||
use App\Domain\Media\WebsiteMedia;
|
use App\Domain\Media\WebsiteMedia;
|
||||||
use App\Domain\Media\WebsiteRelease;
|
use App\Domain\Media\WebsiteRelease;
|
||||||
@@ -92,6 +93,9 @@ class ViewContentElement extends ViewRecord
|
|||||||
|
|
||||||
public string $websiteFeedback = '';
|
public string $websiteFeedback = '';
|
||||||
|
|
||||||
|
/** Gewählte Website-Datei für Film oder Hörstück (ungeschützt, getrennt von der Inhaltsfassung). */
|
||||||
|
public mixed $websiteUpload = null;
|
||||||
|
|
||||||
public int|string|null $kindId = null;
|
public int|string|null $kindId = null;
|
||||||
|
|
||||||
/** @var list<int|string> */
|
/** @var list<int|string> */
|
||||||
@@ -262,8 +266,9 @@ public function adoptFrame(): void
|
|||||||
/** @var ContentElement $element */
|
/** @var ContentElement $element */
|
||||||
$element = $this->getRecord();
|
$element = $this->getRecord();
|
||||||
$shown = $this->shownVersion();
|
$shown = $this->shownVersion();
|
||||||
|
$fromWebsiteFile = ! $shown instanceof ContentElementVersion && $this->hasWebsiteFilm($element);
|
||||||
|
|
||||||
if (! $shown instanceof ContentElementVersion || $element->output_class !== 'film') {
|
if ((! $shown instanceof ContentElementVersion && ! $fromWebsiteFile) || $element->output_class !== 'film') {
|
||||||
$this->pictureFeedback = 'Für dieses Medium gibt es keine Filmstelle.';
|
$this->pictureFeedback = 'Für dieses Medium gibt es keine Filmstelle.';
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -286,7 +291,9 @@ public function adoptFrame(): void
|
|||||||
$this->keepAlt($element);
|
$this->keepAlt($element);
|
||||||
$element->thumbnail_error = null;
|
$element->thumbnail_error = null;
|
||||||
$element->save();
|
$element->save();
|
||||||
DeriveThumbnail::dispatch('element', $element->id, null, null, $shown->id, $seconds);
|
$fromWebsiteFile
|
||||||
|
? DeriveThumbnail::dispatch('element', $element->id, null, null, null, $seconds, true)
|
||||||
|
: DeriveThumbnail::dispatch('element', $element->id, null, null, $shown->id, $seconds);
|
||||||
$element->refresh();
|
$element->refresh();
|
||||||
$this->pictureFeedback = $element->thumbnail_error
|
$this->pictureFeedback = $element->thumbnail_error
|
||||||
?: 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.';
|
?: 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.';
|
||||||
@@ -361,10 +368,24 @@ public function useOwnImage(): void
|
|||||||
?: 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.';
|
?: 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Ein Film ohne Inhaltsfassung, aber mit Website-Datei: die Filmstelle kommt aus dieser Datei. */
|
||||||
|
public function hasWebsiteFilm(?ContentElement $element = null): bool
|
||||||
|
{
|
||||||
|
$element ??= $this->getRecord();
|
||||||
|
|
||||||
|
return $element->output_class === 'film'
|
||||||
|
&& filled($element->preview_path)
|
||||||
|
&& ! $element->versions()->exists();
|
||||||
|
}
|
||||||
|
|
||||||
public function framePreviewUrl(): ?string
|
public function framePreviewUrl(): ?string
|
||||||
{
|
{
|
||||||
$shown = $this->shownVersion();
|
$shown = $this->shownVersion();
|
||||||
|
|
||||||
|
if (! $shown instanceof ContentElementVersion && $this->hasWebsiteFilm() && is_numeric($this->frameSecond) && trim($this->frameSecond) !== '') {
|
||||||
|
return route('content.website-frame', ['element' => $this->getRecord(), 'sekunde' => $this->frameSecond]);
|
||||||
|
}
|
||||||
|
|
||||||
if (! $shown instanceof ContentElementVersion || ! is_numeric($this->frameSecond) || trim($this->frameSecond) === '') {
|
if (! $shown instanceof ContentElementVersion || ! is_numeric($this->frameSecond) || trim($this->frameSecond) === '') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -844,6 +865,61 @@ public function releaseForWebsite(): void
|
|||||||
$element->refresh();
|
$element->refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt die Datei ab, die auf der Website laufen soll (zum Beispiel ein Trailer). Die geschützte Inhaltsfassung
|
||||||
|
* bleibt unberührt; öffentlich wird die Datei erst mit der Website-Freigabe.
|
||||||
|
*/
|
||||||
|
public function storeWebsiteFile(): void
|
||||||
|
{
|
||||||
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
|
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
|
||||||
|
if (! in_array($element->output_class, ['film', 'audio'], true)) {
|
||||||
|
$this->websiteFeedback = 'Eine Website-Datei gibt es nur für Filme und Hörstücke.';
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->websiteUpload instanceof TemporaryUploadedFile) {
|
||||||
|
$this->websiteFeedback = 'Wähle zuerst eine Datei.';
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$files = app(PresentationFile::class);
|
||||||
|
$extension = strtolower($this->websiteUpload->getClientOriginalExtension());
|
||||||
|
|
||||||
|
if (! in_array($extension, PresentationFile::EXTENSIONS[$element->output_class], true)) {
|
||||||
|
$this->websiteFeedback = 'Für die Website geht nur '.$files->formats($element->output_class).'. Eine .'.$extension.'-Datei kann der Browser nicht direkt abspielen.';
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $this->websiteUpload->storeAs('inhalte', 'web-'.bin2hex(random_bytes(6)).'.'.$extension, 'cms_incoming');
|
||||||
|
$this->websiteUpload = null;
|
||||||
|
|
||||||
|
if (! is_string($path)) {
|
||||||
|
$this->websiteFeedback = 'Die Datei wurde nicht übernommen.';
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$files->store($element, $path);
|
||||||
|
} catch (DomainRuleException $e) {
|
||||||
|
$this->websiteFeedback = $e->getMessage();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$element->refresh();
|
||||||
|
$this->websiteFeedback = filled($element->thumbnail_error)
|
||||||
|
? (string) $element->thumbnail_error
|
||||||
|
: 'Die Website-Datei ist übernommen. Sie ist erst nach „Für die Website freigeben“ öffentlich. Ein bereits freigegebenes Medium zeigt danach die neue Datei.';
|
||||||
|
}
|
||||||
|
|
||||||
public function withdrawWebsite(): void
|
public function withdrawWebsite(): void
|
||||||
{
|
{
|
||||||
abort_unless(ContentElementResource::editor(), 403);
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
|
|||||||
@@ -2,8 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Filament\Support;
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Composition;
|
||||||
use App\Domain\Catalog\ContentElement;
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
|
use App\Domain\Media\CompositionStill;
|
||||||
|
use App\Domain\Media\FilmStill;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,6 +37,128 @@ public function openWebsiteImagePicker(string $pfad): void
|
|||||||
$this->forceRenderForPicker();
|
$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.
|
||||||
|
*/
|
||||||
|
public function adoptFilmThumbnail(string $pfad, int $elementId): void
|
||||||
|
{
|
||||||
|
$this->adoptFilmStill($pfad, $elementId, fn (FilmStill $stills, ContentElement $film): ContentElement => $stills->fromThumbnail($film, auth('staff')->user()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Medien- und Materialkarte: eine Stelle des Films wählen und als Bild für die Website übernehmen.
|
||||||
|
*/
|
||||||
|
public function adoptFilmFrame(string $pfad, int $elementId, string $sekunde): void
|
||||||
|
{
|
||||||
|
if (! is_numeric($sekunde)) {
|
||||||
|
Notification::make()->danger()->title('Bitte eine Zeitposition in Sekunden angeben.')->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->adoptFilmStill($pfad, $elementId, fn (FilmStill $stills, ContentElement $film): ContentElement => $stills->fromSecond($film, (float) $sekunde, auth('staff')->user()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Programm- und Modulkarte: das Vorschaubild des Programms oder Moduls als Bild für die Website übernehmen
|
||||||
|
* (Bild-Medium im Medienmanager, einmal kopiert).
|
||||||
|
*/
|
||||||
|
public function adoptCompositionThumbnail(string $pfad, int $compositionId): void
|
||||||
|
{
|
||||||
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
|
|
||||||
|
if ($this->imageTargetIsInvalid($pfad)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$composition = Composition::query()->find($compositionId);
|
||||||
|
|
||||||
|
if (! $composition instanceof Composition) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stills = app(CompositionStill::class);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$still = $stills->fromThumbnail($composition, auth('staff')->user());
|
||||||
|
} catch (DomainRuleException $exception) {
|
||||||
|
Notification::make()->danger()->title($exception->getMessage())->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data_set($this, $pfad, $still->id);
|
||||||
|
$this->announceAdoptedStill($still, $stills->reused, 'Dieses Vorschaubild war schon übernommen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param callable(FilmStill, ContentElement): ContentElement $make
|
||||||
|
*/
|
||||||
|
private function adoptFilmStill(string $pfad, int $elementId, callable $make): void
|
||||||
|
{
|
||||||
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
|
|
||||||
|
if ($this->imageTargetIsInvalid($pfad)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$film = ContentElement::query()->with('editorialContentKind')->find($elementId);
|
||||||
|
|
||||||
|
if (! $film instanceof ContentElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stills = app(FilmStill::class);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$still = $make($stills, $film);
|
||||||
|
} catch (DomainRuleException $exception) {
|
||||||
|
Notification::make()->danger()->title($exception->getMessage())->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data_set($this, $pfad, $still->id);
|
||||||
|
$this->announceAdoptedStill($still, $stills->reused, 'Diese Stelle war schon übernommen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Nur das Bildfeld eines Widgets oder Abschnitts ist ein zulässiges Ziel (…image). */
|
||||||
|
private function imageTargetIsInvalid(string $pfad): bool
|
||||||
|
{
|
||||||
|
return preg_match('/^(data|mountedActions\.\d+\.data)(\.[A-Za-z0-9_-]+)+\.image$/', $pfad) !== 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Meldung nach dem tatsächlichen Stand des Bildes: neu angelegt, schon vorhanden und freigegeben, wird verarbeitet
|
||||||
|
* oder Website-Freigabe zurückgenommen (bleibt zurückgenommen).
|
||||||
|
*/
|
||||||
|
private function announceAdoptedStill(ContentElement $still, bool $reused, string $reusedText): void
|
||||||
|
{
|
||||||
|
$title = ($still->display_title ?: $still->working_title);
|
||||||
|
|
||||||
|
if (! $reused) {
|
||||||
|
Notification::make()
|
||||||
|
->success()
|
||||||
|
->title('Im Medienmanager angelegt: „'.$title.'“')
|
||||||
|
->body('Das Bild ist als Kartenbild ausgewählt. Nach der Verarbeitung wird es für die Website freigegeben; dort lässt sich die Freigabe auch zurücknehmen.')
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app(WebsiteMedia::class)->present($still) !== null) {
|
||||||
|
Notification::make()->success()->title('Bereits im Medienmanager: „'.$title.'“')->body($reusedText.' Das Bild ist als Kartenbild ausgewählt.')->send();
|
||||||
|
} elseif (blank($still->thumbnail_path) && blank($still->thumbnail_error)) {
|
||||||
|
Notification::make()->success()->title('Bereits im Medienmanager: „'.$title.'“')->body('Das Bild wird noch verarbeitet und danach für die Website freigegeben.')->send();
|
||||||
|
} else {
|
||||||
|
Notification::make()->warning()->title('Bild ausgewählt, aber nicht für die Website freigegeben: „'.$title.'“')
|
||||||
|
->body($reusedText.' Die Website-Freigabe wurde zurückgenommen. Das Bild erscheint öffentlich erst wieder, wenn sie im Medienmanager (Reiter „Website“) erneut gegeben wird.')
|
||||||
|
->persistent()
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filament rendert bei offenen Aktionsdialogen nur den Dialogteil neu; der Picker liegt darüber und braucht die
|
* Filament rendert bei offenen Aktionsdialogen nur den Dialogteil neu; der Picker liegt darüber und braucht die
|
||||||
* ganze Seite.
|
* ganze Seite.
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ private function normalize(array $filters): array
|
|||||||
'suche' => trim($filters['suche'] ?? ''),
|
'suche' => trim($filters['suche'] ?? ''),
|
||||||
'art' => $this->choice($filters['art'] ?? '', ['film', 'text', 'document', 'bild', 'audio']),
|
'art' => $this->choice($filters['art'] ?? '', ['film', 'text', 'document', 'bild', 'audio']),
|
||||||
'freigabe' => $this->choice($filters['freigabe'] ?? '', ['freigegeben', 'entwurf', 'ohne']),
|
'freigabe' => $this->choice($filters['freigabe'] ?? '', ['freigegeben', 'entwurf', 'ohne']),
|
||||||
|
'schutz' => $this->choice($filters['schutz'] ?? '', ['geschuetzt', 'oeffentlich', 'website']),
|
||||||
'entwurf' => $this->choice($filters['entwurf'] ?? '', ['offen', 'keiner']),
|
'entwurf' => $this->choice($filters['entwurf'] ?? '', ['offen', 'keiner']),
|
||||||
'fassung' => $this->choice($filters['fassung'] ?? '', ['mit', 'nur']),
|
'fassung' => $this->choice($filters['fassung'] ?? '', ['mit', 'nur']),
|
||||||
'nutzung' => $this->choice($filters['nutzung'] ?? '', ['verwendet', 'unbenutzt']),
|
'nutzung' => $this->choice($filters['nutzung'] ?? '', ['verwendet', 'unbenutzt']),
|
||||||
@@ -383,6 +384,20 @@ private function matches(ContentElement $element, array $portrait, array $uses,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$presentation = $this->isPresentationMedium($element, $portrait['versionCount']);
|
||||||
|
|
||||||
|
if ($filters['schutz'] === 'geschuetzt' && $presentation) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['schutz'] === 'oeffentlich' && ! $presentation) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['schutz'] === 'website' && $element->website_released_at === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ($filters['freigabe'] === 'freigegeben' && $portrait['ready'] === null) {
|
if ($filters['freigabe'] === 'freigegeben' && $portrait['ready'] === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -444,6 +459,15 @@ private function matches(ContentElement $element, array $portrait, array $uses,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eigenständiges Präsentationsmedium: Bild, Film oder Hörstück ohne Inhaltsfassung. Es ist für die Website
|
||||||
|
* bestimmt und nicht lizenziert; alles mit einer Inhaltsfassung gilt als geschützt.
|
||||||
|
*/
|
||||||
|
private function isPresentationMedium(ContentElement $element, int $versionCount): bool
|
||||||
|
{
|
||||||
|
return $versionCount === 0 && in_array($element->output_class, ['bild', 'film', 'audio'], true);
|
||||||
|
}
|
||||||
|
|
||||||
private function matchesArt(ContentElement $element, string $art): bool
|
private function matchesArt(ContentElement $element, string $art): bool
|
||||||
{
|
{
|
||||||
if ($art === '') {
|
if ($art === '') {
|
||||||
@@ -498,6 +522,8 @@ private function card(ContentElement $element, array $portrait, array $uses, arr
|
|||||||
'image' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
'image' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
||||||
'imageAlt' => trim((string) ($element->thumbnail_alt ?: $element->working_title)),
|
'imageAlt' => trim((string) ($element->thumbnail_alt ?: $element->working_title)),
|
||||||
'imageNote' => $this->imageNote($element),
|
'imageNote' => $this->imageNote($element),
|
||||||
|
'presentation' => $this->isPresentationMedium($element, $portrait['versionCount']),
|
||||||
|
'websiteReleased' => $element->website_released_at !== null,
|
||||||
'stand' => $portrait['stand'],
|
'stand' => $portrait['stand'],
|
||||||
'standTone' => $portrait['standTone'],
|
'standTone' => $portrait['standTone'],
|
||||||
'draftNote' => $portrait['draftNote'],
|
'draftNote' => $portrait['draftNote'],
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public static function fields(bool $creating, ?ContentElement $element = null):
|
|||||||
->required(fn ($get): bool => filled($get('shape')) && $get('shape') !== 'text');
|
->required(fn ($get): bool => filled($get('shape')) && $get('shape') !== 'text');
|
||||||
$fields[] = Checkbox::make('without_version')
|
$fields[] = Checkbox::make('without_version')
|
||||||
->label('Eigenständiges Präsentationsmedium')
|
->label('Eigenständiges Präsentationsmedium')
|
||||||
->helperText('Bild, Film oder Hörstück ohne fachliche Inhaltsfassung. Die Datei bleibt eine technische Ableitung am Medium. Sie wird nicht lizenziert und nicht automatisch für die Website freigegeben.')
|
->helperText('Bild, Film oder Hörstück ohne fachliche Inhaltsfassung, zum Beispiel ein Trailer, der ungeschützt auf der Website laufen soll. Der Film muss dafür MP4 (H.264) oder WebM sein. Er wird nicht lizenziert und erst nach „Für die Website freigeben“ öffentlich.')
|
||||||
->visible(fn ($get): bool => in_array($get('shape'), ['film', 'audio', 'bild'], true));
|
->visible(fn ($get): bool => in_array($get('shape'), ['film', 'audio', 'bild'], true));
|
||||||
} elseif ($element?->output_class === 'text') {
|
} elseif ($element?->output_class === 'text') {
|
||||||
$fields[] = Textarea::make('body')->label('Text')->rows(8)->required();
|
$fields[] = Textarea::make('body')->label('Text')->rows(8)->required();
|
||||||
@@ -94,20 +94,10 @@ public static function create(array $data, bool $hold): ContentElement
|
|||||||
{
|
{
|
||||||
$service = app(ContentService::class);
|
$service = app(ContentService::class);
|
||||||
[$kind, $output] = self::shape($data['shape'] ?? null);
|
[$kind, $output] = self::shape($data['shape'] ?? null);
|
||||||
$element = $service->createElement($kind, $output, (string) $data['working_title']);
|
$incoming = null;
|
||||||
self::remember($element, $data);
|
|
||||||
|
|
||||||
if ($output === 'text') {
|
if ($output !== 'text') {
|
||||||
$body = trim((string) ($data['body'] ?? ''));
|
// Alles prüfen, bevor etwas angelegt wird: Eine abgelehnte Datei darf kein leeres Medium hinterlassen.
|
||||||
|
|
||||||
if ($body === '') {
|
|
||||||
throw new DomainRuleException('Der Text braucht einen Inhalt.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$hold
|
|
||||||
? $service->draftElementVersion($element, $body)
|
|
||||||
: $service->publishElementVersion($element, $body);
|
|
||||||
} else {
|
|
||||||
$incoming = IncomingFile::store($data['incoming'] ?? null);
|
$incoming = IncomingFile::store($data['incoming'] ?? null);
|
||||||
|
|
||||||
if ($incoming === null) {
|
if ($incoming === null) {
|
||||||
@@ -126,6 +116,25 @@ public static function create(array $data, bool $hold): ContentElement
|
|||||||
throw new DomainRuleException('Diese Datei passt nicht zur gewählten Art.');
|
throw new DomainRuleException('Diese Datei passt nicht zur gewählten Art.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['without_version']) && in_array($output, ['bild', 'film', 'audio'], true)) {
|
||||||
|
app(PresentationFile::class)->validate($output, $incoming);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$element = $service->createElement($kind, $output, (string) $data['working_title']);
|
||||||
|
self::remember($element, $data);
|
||||||
|
|
||||||
|
if ($output === 'text') {
|
||||||
|
$body = trim((string) ($data['body'] ?? ''));
|
||||||
|
|
||||||
|
if ($body === '') {
|
||||||
|
throw new DomainRuleException('Der Text braucht einen Inhalt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$hold
|
||||||
|
? $service->draftElementVersion($element, $body)
|
||||||
|
: $service->publishElementVersion($element, $body);
|
||||||
|
} else {
|
||||||
if (! empty($data['without_version']) && in_array($output, ['bild', 'film', 'audio'], true)) {
|
if (! empty($data['without_version']) && in_array($output, ['bild', 'film', 'audio'], true)) {
|
||||||
app(PresentationFile::class)->store($element, $incoming);
|
app(PresentationFile::class)->store($element, $incoming);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Concerns;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Liefert eine Datei einer Disk aus, bei Filmen und Hörstücken mit Bereichsabrufen (206/416). Safari und iOS spielen
|
||||||
|
* sonst nicht ab, und ohne Bereiche ist kein Springen möglich.
|
||||||
|
*/
|
||||||
|
trait ServesByteRanges
|
||||||
|
{
|
||||||
|
private const CHUNK = 262144;
|
||||||
|
|
||||||
|
protected function respondWithRanges(Request $request, string $diskName, string $path, bool $ranged): StreamedResponse
|
||||||
|
{
|
||||||
|
$headers = [
|
||||||
|
'Content-Disposition' => 'inline',
|
||||||
|
'X-Content-Type-Options' => 'nosniff',
|
||||||
|
'Accept-Ranges' => 'bytes',
|
||||||
|
];
|
||||||
|
$range = $request->header('Range');
|
||||||
|
|
||||||
|
if (! is_string($range) || ! $ranged) {
|
||||||
|
return Storage::disk($diskName)->response($path, null, $headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
$disk = Storage::disk($diskName);
|
||||||
|
$size = (int) $disk->size($path);
|
||||||
|
$bounds = $this->bounds($range, $size);
|
||||||
|
|
||||||
|
if ($bounds === null) {
|
||||||
|
return response()->stream(fn () => null, 416, $headers + ['Content-Range' => 'bytes */'.$size]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[$start, $end] = $bounds;
|
||||||
|
$length = $end - $start + 1;
|
||||||
|
$stream = $disk->readStream($path);
|
||||||
|
abort_if(! is_resource($stream), 404);
|
||||||
|
|
||||||
|
return response()->stream(function () use ($stream, $start, $length): void {
|
||||||
|
fseek($stream, $start);
|
||||||
|
$left = $length;
|
||||||
|
|
||||||
|
while ($left > 0 && ! feof($stream)) {
|
||||||
|
$chunk = fread($stream, min(self::CHUNK, $left));
|
||||||
|
|
||||||
|
if ($chunk === false || $chunk === '') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $chunk;
|
||||||
|
$left -= strlen($chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose($stream);
|
||||||
|
}, 206, $headers + [
|
||||||
|
'Content-Type' => (string) ($disk->mimeType($path) ?: 'application/octet-stream'),
|
||||||
|
'Content-Length' => (string) $length,
|
||||||
|
'Content-Range' => 'bytes '.$start.'-'.$end.'/'.$size,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Erster Bereich aus „bytes=a-b“, „bytes=a-“ oder „bytes=-n“; null, wenn er nicht erfüllbar ist.
|
||||||
|
*
|
||||||
|
* @return array{0: int, 1: int}|null
|
||||||
|
*/
|
||||||
|
private function bounds(string $header, int $size): ?array
|
||||||
|
{
|
||||||
|
if ($size < 1 || preg_match('/^bytes=(\d*)-(\d*)(?:,.*)?$/', trim($header), $match) !== 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
[, $from, $to] = $match;
|
||||||
|
|
||||||
|
if ($from === '' && $to === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($from === '') {
|
||||||
|
$suffix = min((int) $to, $size);
|
||||||
|
|
||||||
|
return $suffix < 1 ? null : [$size - $suffix, $size - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$start = (int) $from;
|
||||||
|
$end = $to === '' ? $size - 1 : min((int) $to, $size - 1);
|
||||||
|
|
||||||
|
return $start > $end || $start >= $size ? null : [$start, $end];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,12 +2,16 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
use App\Domain\Catalog\ContentElementVersion;
|
use App\Domain\Catalog\ContentElementVersion;
|
||||||
use App\Domain\Identity\StaffRole;
|
use App\Domain\Identity\StaffRole;
|
||||||
use App\Domain\Media\FilmPlayback;
|
use App\Domain\Media\FilmPlayback;
|
||||||
use App\Domain\Media\HlsPlaylist;
|
use App\Domain\Media\HlsPlaylist;
|
||||||
use App\Domain\Media\MediaRendition;
|
use App\Domain\Media\MediaRendition;
|
||||||
|
use App\Domain\Media\ThumbnailDeriver;
|
||||||
|
use App\Http\Controllers\Concerns\ServesByteRanges;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
@@ -15,6 +19,27 @@
|
|||||||
|
|
||||||
class ContentPreviewController extends Controller
|
class ContentPreviewController extends Controller
|
||||||
{
|
{
|
||||||
|
use ServesByteRanges;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Website-Datei eines Films oder Hörstücks, damit die Redaktion sie vor der Freigabe ansehen kann. Nur für
|
||||||
|
* angemeldete Redakteure; öffentlich ist erst die freigegebene Kopie (`website.media`).
|
||||||
|
*/
|
||||||
|
public function websiteFile(Request $request, ContentElement $element): StreamedResponse
|
||||||
|
{
|
||||||
|
$this->authorizeStaff();
|
||||||
|
$path = $element->preview_path;
|
||||||
|
|
||||||
|
abort_unless(
|
||||||
|
is_string($path) && str_starts_with($path, 'teaser/') && ! str_contains($path, '..')
|
||||||
|
&& in_array($element->output_class, ['film', 'audio'], true)
|
||||||
|
&& Storage::disk('media_derived')->exists($path),
|
||||||
|
404,
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->respondWithRanges($request, 'media_derived', $path, true);
|
||||||
|
}
|
||||||
|
|
||||||
public function show(ContentElementVersion $version): View
|
public function show(ContentElementVersion $version): View
|
||||||
{
|
{
|
||||||
$this->authorizeStaff();
|
$this->authorizeStaff();
|
||||||
@@ -38,6 +63,24 @@ public function file(ContentElementVersion $version): StreamedResponse
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Einzelbild einer Stelle der Website-Datei, zur Auswahl des Vorschaubilds.
|
||||||
|
*/
|
||||||
|
public function websiteFrame(Request $request, ContentElement $element, ThumbnailDeriver $deriver): Response
|
||||||
|
{
|
||||||
|
$this->authorizeStaff();
|
||||||
|
$seconds = $request->query('sekunde');
|
||||||
|
abort_unless(is_numeric($seconds), 404);
|
||||||
|
|
||||||
|
$bytes = $deriver->jpegAtWebsiteFile($element, (float) $seconds);
|
||||||
|
abort_unless(is_string($bytes), 404);
|
||||||
|
|
||||||
|
return response($bytes, 200, [
|
||||||
|
'Content-Type' => 'image/jpeg',
|
||||||
|
'Cache-Control' => 'private, no-store',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function fileUrl(ContentElementVersion $version): ?string
|
public function fileUrl(ContentElementVersion $version): ?string
|
||||||
{
|
{
|
||||||
return $this->storedPath($version) === null ? null : route('content.file', $version);
|
return $this->storedPath($version) === null ? null : route('content.file', $version);
|
||||||
|
|||||||
@@ -9,7 +9,9 @@
|
|||||||
use App\Domain\Commerce\Checkout;
|
use App\Domain\Commerce\Checkout;
|
||||||
use App\Domain\Commerce\Order;
|
use App\Domain\Commerce\Order;
|
||||||
use App\Domain\Commerce\OrderHolders;
|
use App\Domain\Commerce\OrderHolders;
|
||||||
|
use App\Domain\Commerce\Shop;
|
||||||
use App\Domain\Commerce\StaleOverview;
|
use App\Domain\Commerce\StaleOverview;
|
||||||
|
use App\Domain\Commerce\Stripe\StripeGateway;
|
||||||
use App\Domain\Entitlement\GrantIssuer;
|
use App\Domain\Entitlement\GrantIssuer;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
@@ -99,9 +101,26 @@ public function show(Request $request, Order $order): View
|
|||||||
return view('member.order', [
|
return view('member.order', [
|
||||||
'order' => $order,
|
'order' => $order,
|
||||||
'testPayment' => ! app()->isProduction() && config('services.payment.driver') === 'test',
|
'testPayment' => ! app()->isProduction() && config('services.payment.driver') === 'test',
|
||||||
|
'stripePayment' => Shop::stripe(),
|
||||||
|
'zahlung' => $request->query('zahlung'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Leitet zur Stripe-Kasse (Testmodus). Freigeschaltet wird erst durch die signierte Meldung von Stripe. */
|
||||||
|
public function pay(Request $request, Order $order, StripeGateway $stripe): RedirectResponse
|
||||||
|
{
|
||||||
|
abort_unless($order->user_id === $request->user()->id, 403);
|
||||||
|
abort_unless(Shop::stripe(), 404);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$session = $stripe->checkoutFor($order);
|
||||||
|
} catch (DomainRuleException $exception) {
|
||||||
|
return back()->withErrors(['payment' => $exception->getMessage()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->away($session['url']);
|
||||||
|
}
|
||||||
|
|
||||||
public function confirm(Request $request, Order $order, Checkout $checkout): RedirectResponse
|
public function confirm(Request $request, Order $order, Checkout $checkout): RedirectResponse
|
||||||
{
|
{
|
||||||
abort_unless($order->user_id === $request->user()->id, 403);
|
abort_unless($order->user_id === $request->user()->id, 403);
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ public function show(string $path, WebsiteMedia $media): StreamedResponse
|
|||||||
abort_if(str_contains($path, '..') || ! str_starts_with($path, 'cms/'), 404);
|
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.
|
// Ein in den Medienmanager übernommenes Bild folgt dessen Website-Freigabe, auch unter der früheren Adresse.
|
||||||
|
abort_if(WebsiteMediaAlias::isRetired($path), 404);
|
||||||
|
|
||||||
$alias = WebsiteMediaAlias::effectiveFor($path);
|
$alias = WebsiteMediaAlias::effectiveFor($path);
|
||||||
abort_if($alias !== null && $media->present($alias->content_element_id) === null, 404);
|
abort_if($alias !== null && $media->present($alias->content_element_id) === null, 404);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Commerce\Checkout;
|
||||||
|
use App\Domain\Commerce\Order;
|
||||||
|
use App\Domain\Commerce\Payment;
|
||||||
|
use App\Domain\Commerce\Shop;
|
||||||
|
use App\Domain\Commerce\Stripe\StripeSignature;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empfängt die signierten Meldungen von Stripe (Etappe 1: Testmodus). Ohne gültige Signatur geschieht nichts. Die
|
||||||
|
* Freischaltung nutzt denselben geprüften Weg wie die Testzahlung und ist bei Wiederholung wirkungslos.
|
||||||
|
* Antworten: 404 wenn Stripe nicht aktiv ist, 400 bei ungültiger Signatur, sonst 200 (Stripe wiederholt sonst).
|
||||||
|
*/
|
||||||
|
class StripeWebhookController extends Controller
|
||||||
|
{
|
||||||
|
public function __invoke(Request $request, StripeSignature $signature, Checkout $checkout): JsonResponse
|
||||||
|
{
|
||||||
|
abort_unless(Shop::stripe(), 404);
|
||||||
|
|
||||||
|
$payload = $request->getContent();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$signature->verify($payload, $request->header('Stripe-Signature'));
|
||||||
|
} catch (DomainRuleException $exception) {
|
||||||
|
Log::warning('Stripe-Meldung abgewiesen', ['grund' => $exception->getMessage()]);
|
||||||
|
|
||||||
|
return response()->json(['error' => 'Ungültige Signatur.'], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$event = json_decode($payload, true);
|
||||||
|
|
||||||
|
if (! is_array($event) || ! isset($event['type'])) {
|
||||||
|
return response()->json(['error' => 'Ungültige Nutzlast.'], 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
$session = (array) ($event['data']['object'] ?? []);
|
||||||
|
|
||||||
|
return match ($event['type']) {
|
||||||
|
'checkout.session.completed', 'checkout.session.async_payment_succeeded' => $this->paid($session, $checkout),
|
||||||
|
'checkout.session.expired', 'checkout.session.async_payment_failed' => $this->notPaid($session, (string) $event['type']),
|
||||||
|
default => response()->json(['received' => true, 'handled' => false]),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $session
|
||||||
|
*/
|
||||||
|
private function paid(array $session, Checkout $checkout): JsonResponse
|
||||||
|
{
|
||||||
|
if (($session['payment_status'] ?? null) !== 'paid') {
|
||||||
|
return response()->json(['received' => true, 'handled' => false]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$order = $this->orderOf($session);
|
||||||
|
$reference = (string) ($session['id'] ?? '');
|
||||||
|
|
||||||
|
if ($order === null || $reference === '') {
|
||||||
|
Log::warning('Stripe-Zahlung ohne zugehörige Bestellung', ['session' => $reference]);
|
||||||
|
|
||||||
|
return response()->json(['received' => true, 'handled' => false]);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$checkout->confirmProviderPayment(
|
||||||
|
$order,
|
||||||
|
'stripe',
|
||||||
|
$reference,
|
||||||
|
(int) ($session['amount_total'] ?? -1),
|
||||||
|
(string) ($session['currency'] ?? ''),
|
||||||
|
);
|
||||||
|
} catch (DomainRuleException $exception) {
|
||||||
|
// Dauerhafter Fehler (Betragsabweichung, Bestellung nicht mehr offen): nichts freischalten, Zahlung zur
|
||||||
|
// Prüfung festhalten und 200 antworten, damit Stripe nicht endlos wiederholt.
|
||||||
|
Log::warning('Stripe-Zahlung nicht übernommen', ['order' => $order->id, 'session' => $reference, 'grund' => $exception->getMessage()]);
|
||||||
|
$order->payments()->updateOrCreate(['provider_reference' => $reference], ['provider' => 'stripe', 'status' => 'zu_pruefen']);
|
||||||
|
|
||||||
|
return response()->json(['received' => true, 'handled' => false]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['received' => true, 'handled' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $session
|
||||||
|
*/
|
||||||
|
private function notPaid(array $session, string $type): JsonResponse
|
||||||
|
{
|
||||||
|
$payment = Payment::query()->where('provider', 'stripe')->where('provider_reference', (string) ($session['id'] ?? ''))->first();
|
||||||
|
|
||||||
|
// Die Bestellung bleibt offen und lässt sich erneut bezahlen; nur diese Kasse gilt nicht mehr.
|
||||||
|
if ($payment !== null && $payment->status === 'offen') {
|
||||||
|
$payment->status = $type === 'checkout.session.expired' ? 'abgelaufen' : 'fehlgeschlagen';
|
||||||
|
$payment->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['received' => true, 'handled' => $payment !== null]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $session
|
||||||
|
*/
|
||||||
|
private function orderOf(array $session): ?Order
|
||||||
|
{
|
||||||
|
$id = $session['client_reference_id'] ?? ($session['metadata']['order_id'] ?? null);
|
||||||
|
|
||||||
|
return is_numeric($id) ? Order::query()->find((int) $id) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,12 +4,15 @@
|
|||||||
|
|
||||||
use App\Domain\Catalog\ContentElement;
|
use App\Domain\Catalog\ContentElement;
|
||||||
use App\Domain\Media\WebsiteMedia;
|
use App\Domain\Media\WebsiteMedia;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use App\Http\Controllers\Concerns\ServesByteRanges;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
class WebsiteMediaController extends Controller
|
class WebsiteMediaController extends Controller
|
||||||
{
|
{
|
||||||
public function show(ContentElement $element, WebsiteMedia $media): StreamedResponse
|
use ServesByteRanges;
|
||||||
|
|
||||||
|
public function show(Request $request, ContentElement $element, WebsiteMedia $media): StreamedResponse
|
||||||
{
|
{
|
||||||
$presentation = $media->present($element);
|
$presentation = $media->present($element);
|
||||||
abort_if($presentation === null, 404);
|
abort_if($presentation === null, 404);
|
||||||
@@ -17,9 +20,6 @@ public function show(ContentElement $element, WebsiteMedia $media): StreamedResp
|
|||||||
$path = $element->website_public_path;
|
$path = $element->website_public_path;
|
||||||
abort_if(! is_string($path), 404);
|
abort_if(! is_string($path), 404);
|
||||||
|
|
||||||
return Storage::disk('media_public')->response($path, null, [
|
return $this->respondWithRanges($request, 'media_public', $path, $presentation->kind !== 'bild');
|
||||||
'Content-Disposition' => 'inline',
|
|
||||||
'X-Content-Type-Options' => 'nosniff',
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,7 @@ public function __construct(
|
|||||||
public readonly ?int $fromElement = null,
|
public readonly ?int $fromElement = null,
|
||||||
public readonly ?int $versionId = null,
|
public readonly ?int $versionId = null,
|
||||||
public readonly ?float $atSecond = null,
|
public readonly ?float $atSecond = null,
|
||||||
|
public readonly bool $websiteFile = false,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function handle(ThumbnailDeriver $deriver): void
|
public function handle(ThumbnailDeriver $deriver): void
|
||||||
@@ -54,6 +55,12 @@ public function handle(ThumbnailDeriver $deriver): void
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->websiteFile && $this->atSecond !== null) {
|
||||||
|
$deriver->forElementWebsiteFrame($element, $this->atSecond);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->versionId !== null && $this->atSecond !== null) {
|
if ($this->versionId !== null && $this->atSecond !== null) {
|
||||||
$version = ContentElementVersion::query()->find($this->versionId);
|
$version = ContentElementVersion::query()->find($this->versionId);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Media\PresentationFile;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kopiert die Website-Datei eines Mediums nach `derived/`. Nur die Warteschlange darf dort schreiben.
|
||||||
|
* Ein Fehler wird am Medium vermerkt (`thumbnail_error`), damit die Verwaltung ihn zeigen kann.
|
||||||
|
*/
|
||||||
|
class StorePresentationFile implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public int $timeout = 3600;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public int $elementId,
|
||||||
|
public string $incoming,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function handle(PresentationFile $file): void
|
||||||
|
{
|
||||||
|
$element = ContentElement::query()->find($this->elementId);
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$file->place($element, $this->incoming);
|
||||||
|
|
||||||
|
// Ein schon freigegebenes Medium zeigt sonst weiter die alte öffentliche Kopie.
|
||||||
|
if ($element->website_released_at !== null) {
|
||||||
|
PublishWebsiteMedia::dispatch($element->id, 'release');
|
||||||
|
}
|
||||||
|
} catch (DomainRuleException $e) {
|
||||||
|
$this->remember($element, $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function failed(\Throwable $e): void
|
||||||
|
{
|
||||||
|
$element = ContentElement::query()->find($this->elementId);
|
||||||
|
|
||||||
|
if ($element instanceof ContentElement) {
|
||||||
|
$this->remember($element, 'Die Datei ließ sich nicht übernehmen: '.Str::limit($e->getMessage(), 120));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function remember(ContentElement $element, string $message): void
|
||||||
|
{
|
||||||
|
$element->thumbnail_error = $message;
|
||||||
|
$element->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,8 @@
|
|||||||
)
|
)
|
||||||
->withMiddleware(function (Middleware $middleware): void {
|
->withMiddleware(function (Middleware $middleware): void {
|
||||||
$middleware->trustProxies(at: '*');
|
$middleware->trustProxies(at: '*');
|
||||||
|
// Stripe sendet ohne Sitzung und CSRF-Token; die Signatur der Meldung ersetzt beides.
|
||||||
|
$middleware->validateCsrfTokens(except: ['stripe/webhook']);
|
||||||
$middleware->prepend(UseStaffSessionCookie::class);
|
$middleware->prepend(UseStaffSessionCookie::class);
|
||||||
$middleware->prepend(UseRequestRootUrl::class);
|
$middleware->prepend(UseRequestRootUrl::class);
|
||||||
$middleware->prepend(IgnoreEmptyForwardedHeaders::class);
|
$middleware->prepend(IgnoreEmptyForwardedHeaders::class);
|
||||||
|
|||||||
@@ -29,9 +29,16 @@
|
|||||||
],
|
],
|
||||||
|
|
||||||
'payment' => [
|
'payment' => [
|
||||||
|
// test: Testweg ohne Anbieter. stripe: Stripe-Kasse, in Etappe 1 nur mit Testschlüsseln (sk_test_).
|
||||||
'driver' => env('PAYMENT_DRIVER', 'test'),
|
'driver' => env('PAYMENT_DRIVER', 'test'),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'stripe' => [
|
||||||
|
'secret' => env('STRIPE_SECRET'),
|
||||||
|
'webhook_secret' => env('STRIPE_WEBHOOK_SECRET'),
|
||||||
|
'api_base' => env('STRIPE_API_BASE', 'https://api.stripe.com'),
|
||||||
|
],
|
||||||
|
|
||||||
'slack' => [
|
'slack' => [
|
||||||
'notifications' => [
|
'notifications' => [
|
||||||
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Herkunft der Standbilder, die aus einem Film als Bild-Medium übernommen wurden (Medien- und Materialkarte).
|
||||||
|
* Additiv. Sie verhindert, dass dieselbe Filmstelle mehrfach als neues Medium entsteht, und hält fest, woher das
|
||||||
|
* Bild kommt. Das Standbild selbst ist ein gewöhnliches Medium (output_class bild) mit eigener Website-Freigabe.
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('film_still_sources', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('film_element_id')->constrained('content_elements')->restrictOnDelete();
|
||||||
|
$table->foreignId('still_element_id')->constrained('content_elements')->restrictOnDelete();
|
||||||
|
$table->string('source_key', 120);
|
||||||
|
$table->unsignedBigInteger('actor_id')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->unique(['film_element_id', 'source_key']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('film_still_sources');
|
||||||
|
}
|
||||||
|
};
|
||||||
+44
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* „Medium löschen“ (Medien ohne Fassung) muss auch Standbilder aus Filmen und übernommene CMS-Bilder erreichen.
|
||||||
|
*
|
||||||
|
* - film_still_sources: Die Herkunftszeile eines gelöschten Standbilds entfällt (cascade); dieselbe Stelle kann neu
|
||||||
|
* übernommen werden.
|
||||||
|
* - website_media_aliases: Die Zuordnung bleibt als Sperre bestehen (content_element_id wird leer). Ein früherer Pfad
|
||||||
|
* mit gelöschtem Medium wird nicht wieder über /medien/cms/… ausgeliefert und nicht mehr als Bild gezeigt.
|
||||||
|
*
|
||||||
|
* Lockert nur Fremdschlüssel; bestehende Daten bleiben unverändert (rückwärtskompatibel).
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('film_still_sources', function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['still_element_id']);
|
||||||
|
});
|
||||||
|
Schema::table('film_still_sources', function (Blueprint $table) {
|
||||||
|
$table->foreign('still_element_id')->references('id')->on('content_elements')->cascadeOnDelete();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('website_media_aliases', function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['content_element_id']);
|
||||||
|
});
|
||||||
|
Schema::table('website_media_aliases', function (Blueprint $table) {
|
||||||
|
$table->unsignedBigInteger('content_element_id')->nullable()->change();
|
||||||
|
});
|
||||||
|
Schema::table('website_media_aliases', function (Blueprint $table) {
|
||||||
|
$table->foreign('content_element_id')->references('id')->on('content_elements')->nullOnDelete();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Bewusst leer: Die gelockerten Fremdschlüssel schaden älterem Code nicht, und leere Zuordnungen
|
||||||
|
// (gelöschte Medien) ließen sich nicht in den strengeren Zustand zurückführen.
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Herkunft der Bild-Medien, die aus dem Vorschaubild eines Programms oder Moduls übernommen wurden
|
||||||
|
* (Programm- und Modulkarte). Additiv. Verhindert, dass dasselbe Vorschaubild mehrfach als neues Medium entsteht.
|
||||||
|
* Das übernommene Bild ist ein gewöhnliches Medium (output_class bild) mit eigener Website-Freigabe.
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('composition_still_sources', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('composition_id')->constrained('compositions')->cascadeOnDelete();
|
||||||
|
$table->foreignId('still_element_id')->constrained('content_elements')->cascadeOnDelete();
|
||||||
|
$table->string('source_key', 120);
|
||||||
|
$table->unsignedBigInteger('actor_id')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->unique(['composition_id', 'source_key']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('composition_still_sources');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -27,7 +27,10 @@ MAIL_MAILER=log
|
|||||||
MAIL_FROM_ADDRESS="noreply@example.invalid"
|
MAIL_FROM_ADDRESS="noreply@example.invalid"
|
||||||
MAIL_FROM_NAME="${APP_NAME}"
|
MAIL_FROM_NAME="${APP_NAME}"
|
||||||
|
|
||||||
# test bleibt der lokale Testweg. Ein echter Zahlungsdienst ist noch nicht festgelegt.
|
# test: lokaler Testweg ohne Anbieter. stripe: Stripe-Kasse, in Etappe 1 nur mit Testschlüsseln und nie in Produktion.
|
||||||
|
# Die Schlüssel stehen nur in /etc/luf/<umgebung>.env auf dem Server, nie im Repo.
|
||||||
PAYMENT_DRIVER=test
|
PAYMENT_DRIVER=test
|
||||||
|
# STRIPE_SECRET=sk_test_... (Entwickler > API-Schlüssel, Testmodus)
|
||||||
|
# STRIPE_WEBHOOK_SECRET=whsec_... (Entwickler > Webhooks > Endpunkt > Signiergeheimnis)
|
||||||
|
|
||||||
# Medienpfade setzt Compose auf den Host-Mount (/srv/luf/<env>/media/...). Hier nichts eintragen.
|
# Medienpfade setzt Compose auf den Host-Mount (/srv/luf/<env>/media/...). Hier nichts eintragen.
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# Programm- und Modulkarte: Textwahl und Bild, Filmbild-Regler – Bericht (21.11.2026)
|
||||||
|
|
||||||
|
Branch `feature/karten-text-und-bild-programm`, separater Worktree, Deploy ausschließlich über `develop` (Testinstanz), kein Merge nach `main`. Baut auf `medienkarte-text-und-filmbild-bericht-2026-11-21.md` auf. Technik: `medienzugriff-fuer-komponenten.md`, Registry §13, ADR-39.
|
||||||
|
|
||||||
|
## 1. Rückmeldung aus der Abnahme und Umsetzung
|
||||||
|
|
||||||
|
| Rückmeldung | Umsetzung |
|
||||||
|
|---|---|
|
||||||
|
| Der Bildwähler aus dem Film ist nicht gelungen; im Medienmanager gibt es einen Regler, der das Bild fast in Echtzeit zeigt | Der Dialog arbeitet jetzt wie der Medienmanager: Regler und Zahlenfeld zeigen dieselbe Zeitposition, das Bild der Stelle folgt dem Regler nach kurzer Pause (ohne weiteren Knopf), „Diese Stelle übernehmen“ legt genau die angezeigte Stelle ab. Das im Medienmanager gesetzte Vorschaubild des Films lässt sich mit kleiner Ansicht daneben übernehmen. Der Regler reicht bis 120 s und wächst mit dem Zahlenfeld (bis 7200 s). |
|
||||||
|
| Textwahl soll auch an der Programm- und Modulkarte gelten | „Text der Karte“: Automatisch (wie bisher: Teaser, sonst Kurzbeschreibung, sonst Lernziel), Teaser, Kurzbeschreibung, Ausführliche Beschreibung, **Lernziel der Fassung**. Gelesen mit der Zielgruppe „Öffentliche Kachel“. Eine ausdrückliche Wahl ersetzt nicht still; die Vorschau nennt „Programm oder Modul bearbeiten → …“. |
|
||||||
|
| Die übrigen Anpassungen auch für Programm und Modul | Das Vorschaubild des Programms oder Moduls lässt sich als Bild-Medium übernehmen („Vorschaubild übernehmen“, `CompositionStill`), einmal kopiert, dieselbe Datei ergibt dasselbe Medium, ehrliche Meldung auch bei zurückgenommener Freigabe. |
|
||||||
|
|
||||||
|
Die Themenkarte hat nur einen Text („Text für die Website“) und bekommt deshalb keine Wahl.
|
||||||
|
|
||||||
|
## 2. Prüfung
|
||||||
|
|
||||||
|
| Prüfung | Ergebnis |
|
||||||
|
|---|---|
|
||||||
|
| Testsuite, Pint | 459 grün, Pint sauber (neu: 6 Tests Programm- und Modulkarte; bewusst geändert: die Programmkarte hat jetzt eine Textwahl) |
|
||||||
|
| CI und Deploy | CI 4987, Deploy 4988 (Commit `3825f53`) |
|
||||||
|
| Oberfläche lokal, echter Test-Film | Filmkarte 19/19 (Regler bewegt, Bild folgt, Zahl und Regler gleich), Programmkarte 13/13 |
|
||||||
|
| Testinstanz, Filmkarte „Lara im Park“, regulärer Seitenkonfigurator | **23 von 23**: Regler und Bild sofort da, Bild folgt dem Regler, Zahleneingabe führt es nach, Stelle übernommen (1600 px), dieselbe Stelle ergibt dasselbe Medium, vier Textstufen entsprechen den gepflegten Feldern, interne Angaben nie sichtbar, Rücknahme der Freigabe verifiziert (404) |
|
||||||
|
| Testinstanz, Modul „UX-Pilot Entwurf“ (Kurzbeschreibung, Beschreibung, Lernziel, Vorschaubild) | **15 von 15**: Vorschaubild übernommen und wiederverwendet, Textwahl mit Lernziel, nicht gepflegter Teaser zeigt keinen Text, Karten nennen „Modul“, Entwurf öffentlich nicht erreichbar |
|
||||||
|
| Aufräumen auf der Testinstanz | die angelegten Bilder 27, 28, 29 über „Medium löschen“ entfernt, Herkunftszeilen mit gelöscht (Datenbank geprüft) |
|
||||||
|
| Bestehende Seiten vor und nach dem Deploy | unverändert (16 Messungen, 12 Textvergleiche) |
|
||||||
|
|
||||||
|
**Nicht live gezeigt:** die öffentliche Darstellung der Karten auf einer veröffentlichten Seite der Testinstanz (nur Entwürfe); die öffentlichen Regeln belegen die Feature-Tests.
|
||||||
|
|
||||||
|
## 3. Auf der Testinstanz zurückgeblieben
|
||||||
|
|
||||||
|
- Entwürfe `/medienkarte-regler-entwurf` (Seite 24) und `/programmkarte-regler-entwurf` (Seite 25) sowie ältere Prüfentwürfe. Seiten lassen sich nicht löschen.
|
||||||
|
- Das Standbild „Standbild: Felix beim Onkel (Fassung 1, 22,5 s)“ (Medium 26, freigegeben) stammt nicht von dieser Arbeit (angelegt 19:51, vermutlich bei der Abnahme); unangetastet.
|
||||||
|
|
||||||
|
## 4. Grenzen
|
||||||
|
|
||||||
|
- Das übernommene Programm-Vorschaubild hat die Größe der Vorschaudatei (640 px); für ein breites Kartenbild reicht das, für ein Hero nicht. Ein Film-Standbild kommt bis 1600 px aus der Mediendatei.
|
||||||
|
- Eine Filmstelle direkt für ein Programm zu wählen gibt es nicht; das Vorschaubild des Programms lässt sich im Redaktionsmanager aus einem Film setzen und dann übernehmen.
|
||||||
|
- Das übernommene Bild folgt späteren Änderungen am Vorschaubild nicht (eigenes Medium).
|
||||||
|
|
||||||
|
## 5. Prod
|
||||||
|
|
||||||
|
Die Vorbereitung des Merges `develop` → `main` (Inhalt, Migrationen, Prod-Stand, Entscheidungen) steht in `docs/betrieb/Release-Vorbereitung_2026-11-21.md`. Den Merge löst Lars in Gitea aus.
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
# Medien- und Materialkarte: Textwahl und Bild aus dem Film – Bericht (21.11.2026)
|
||||||
|
|
||||||
|
Branch `feature/medienkarte-text-und-filmbild`, gearbeitet in einem separaten Worktree, Deploy ausschließlich über `develop` (Testinstanz). Kein Merge nach `main`. Technik: `docs/architektur/medienzugriff-fuer-komponenten.md`, Abschnitt „Text der Medien- und Materialkarte, Bild aus dem Film“, und `cms-widget-registry.md` §13.
|
||||||
|
|
||||||
|
## 1. Anforderung 1: Text der Karte wählen
|
||||||
|
|
||||||
|
**Ausgangslage.** Die Karte nahm immer die Kurzbeschreibung, den Teaser nur als Ersatz, die ausführliche Beschreibung nie.
|
||||||
|
|
||||||
|
**Jetzt.** Im Reiter „Darstellung“ der Medienkarte gibt es „Text der Karte“:
|
||||||
|
|
||||||
|
| Wahl | Text |
|
||||||
|
|---|---|
|
||||||
|
| Automatisch (Vorgabe) | Kurzbeschreibung, sonst Teaser, unverändert zu vorher; bestehende Karten ändern sich nicht |
|
||||||
|
| Teaser | `teaser` |
|
||||||
|
| Kurzbeschreibung | `summary` |
|
||||||
|
| Ausführliche Beschreibung | `description`, der Dialog nennt „erscheint öffentlich“ |
|
||||||
|
|
||||||
|
- Eine ausdrückliche Wahl ersetzt **nicht still** durch ein anderes Feld. Ist der Text nicht gepflegt, bleibt die Karte ohne Text; die Redaktionsvorschau nennt, wo er zu pflegen ist (öffentlich nie ein Hinweis).
|
||||||
|
- Der eigene Text der Karte („Text nur für diese Karte“) hat weiter Vorrang. Sein Platzhalter im Editor zeigt jetzt den gewählten zentralen Text.
|
||||||
|
- Einsatzhinweis und Lizenzvermerk sind nicht wählbar und erscheinen nie.
|
||||||
|
- Die Wahl gibt es nur an der Medienkarte, nicht an Themen- und Programmkarte.
|
||||||
|
|
||||||
|
**Entschieden durch diese Arbeit:** Die **ausführliche Beschreibung ist auf ausdrückliche Wahl öffentlich**, bisher war sie Bibliothekstext. Die Doku (`medienzugriff-fuer-komponenten.md`) stand dem entgegen und ist angepasst. Öffentlich ist die Karte weiterhin nur, wenn das Medium zu einem öffentlich gezeigten Programm gehört.
|
||||||
|
|
||||||
|
## 2. Anforderung 2: Bild aus dem Film
|
||||||
|
|
||||||
|
**Ursache der Sperre.** Das Vorschaubild eines Films ist ein geschütztes Bibliotheksbild und für die Website nicht freigegeben. `WebsiteRelease` kann bei Filmen nur ein Teaser-Video freigeben, kein Standbild. Die Karte zeigte es deshalb nur in der Redaktionsvorschau.
|
||||||
|
|
||||||
|
**Lösung, ohne neue Freigabelogik.** Im Reiter „Medien“ der Medienkarte erscheint bei einem Film das Feld „Bild aus dem Film“:
|
||||||
|
|
||||||
|
1. **„Vorschaubild des Films übernehmen“**: übernimmt das im Medienmanager gesetzte Vorschaubild. Stammt es aus einer Filmstelle, wird dieselbe Stelle in voller Auflösung neu gezogen.
|
||||||
|
2. **Stelle wählen**: Zeitposition eingeben, „Anzeigen“ (Vorschau), „Dieses Bild übernehmen“.
|
||||||
|
|
||||||
|
`FilmStill` zieht das Einzelbild **einmal** und legt es über das vorhandene `WebsiteIntake` als gewöhnliches Bild-Medium im Medienmanager ab. Die Warteschlange leitet es ab und gibt es frei, wie bei jedem Upload aus dem CMS. Die Karte speichert nur dessen Kennung in `refs.image`.
|
||||||
|
|
||||||
|
- **Kein Neuziehen bei Seitenaufrufen:** Die Karte liest nur die gespeicherte Datei. Ein Test zählt die Extraktionen: Drei Seitenaufrufe starten keine.
|
||||||
|
- **Einmal je Stelle:** Dieselbe Stelle (auch über den anderen Weg) ergibt dasselbe Medium. Eine neue Tabelle `film_still_sources` (additiv) hält die Herkunft fest.
|
||||||
|
- **Auflösung:** bis 1600 px Breite aus der Mediendatei, nie über die Breite der Quelle hinaus vergrößert. Geprüft mit echten Videos: 1280 px bleiben 1280, 2560 px werden 1600. Auf der Testinstanz kamen Bilder mit 1600 px aus dem Film.
|
||||||
|
- **Rechte:** Es wird nie der Film abgelegt, nur ein Einzelbild; keine Fassung, keine Berechtigung, kein Lizenzartikel. Ausgeschlossen sind Traineranleitungen, archivierte Filme und Filme ohne bereitgestellte Fassung. Die Handlung ist ausdrücklich (Redakteur, dieselbe Rolle wie beim Upload). Das entstandene Bild lässt sich im Medienmanager („Website“) wieder zurücknehmen.
|
||||||
|
- **Das Bild ist ein eigenes Medium** („Standbild: {Film} (Fassung n, x s)“, Alternativtext „Szene aus dem Film …“, Quellenzeile des Films). Es folgt späteren Änderungen am Vorschaubild des Films nicht. Wer es als Titelbild des Films für alle Karten nutzen will, ordnet es im Medienmanager als Präsentationsmedium zu.
|
||||||
|
|
||||||
|
## 3. Prüfung
|
||||||
|
|
||||||
|
| Prüfung | Ergebnis |
|
||||||
|
|---|---|
|
||||||
|
| Testsuite | 453 grün (davon neu: 4 Textwahl, 9 Filmbild einschließlich Wiederverwendung, gescheiterte Verarbeitung, Löschen). Die Extraktion (`ffmpeg`) ist dort gestubbt. |
|
||||||
|
| CI und Deploy | CI 4983 und Deploy 4984 für den ersten Stand (Commit `886715a`); die Korrektur (`cd66561`) steht in der Übergabe. |
|
||||||
|
| `ffmpeg`-Skalierung | mit echten Videos geprüft (siehe oben) |
|
||||||
|
| Bestehende Seiten vor und nach dem Deploy | unverändert: 16 Messungen der Geometrie, 12 Textvergleiche, 16 Bilder |
|
||||||
|
| Oberfläche lokal (echter Test-Film) | 16 von 16 |
|
||||||
|
| Oberfläche auf der Testinstanz, regulärer Seitenkonfigurator, Film „Lara im Park“ mit allen drei Texten | **16 von 16**: Vorschaubild übernommen (Stelle 41,5 s), eine Stelle gewählt (12 s), dieselbe Stelle noch einmal ergab dasselbe Medium, Textwahl in allen vier Stufen entspricht den gepflegten Feldern, Einsatzhinweis und Lizenzvermerk erschienen nie, wieder geöffnet, Vorschau zeigt das gespeicherte Bild über `/website-medien/…` (1600 px), Entwurf öffentlich nicht erreichbar |
|
||||||
|
| Rücknahme der angelegten Bilder auf der Testinstanz | beide Medien zurückgenommen, `/website-medien/…` liefert 404 |
|
||||||
|
|
||||||
|
**Nicht live gezeigt:** Die öffentliche Darstellung der Karte auf einer veröffentlichten Seite der Testinstanz. Es durfte nur ein Entwurf entstehen. Die öffentlichen Regeln belegen die Feature-Tests.
|
||||||
|
|
||||||
|
**Beim Prüfen gefunden und behoben (Commit `cd66561`):**
|
||||||
|
- Wählt die Redaktion eine schon übernommene, inzwischen zurückgenommene Stelle erneut, bekam sie dasselbe Bild zurück, die Meldung versprach aber eine Freigabe. Jetzt nennt die Meldung den tatsächlichen Stand (bereits freigegeben, wird verarbeitet, Freigabe zurückgenommen) und weist auf den Medienmanager hin. Ein bei der Verarbeitung gescheitertes oder archiviertes Bild wird nicht wiederverwendet.
|
||||||
|
- „Medium löschen“ wäre bei Standbildern und, aus meiner früheren Umstellung, bei übernommenen CMS-Bildern an einem Fremdschlüssel gescheitert. Das Löschen funktioniert jetzt; ein gelöschtes übernommenes Medium macht seine frühere Adresse nicht wieder öffentlich (404, kein Bild).
|
||||||
|
|
||||||
|
## 4. Auf der Testinstanz zurückgeblieben
|
||||||
|
|
||||||
|
- Entwurf `/medienkarte-pruefung-entwurf` (Seite 23); seine Karte A verweist auf das zurückgenommene Standbild.
|
||||||
|
- Die Medien „Standbild: Lara im Park (Fassung 1, 41,5 s)“ und „… (Fassung 1, 12 s)“, beide zurückgenommen.
|
||||||
|
- Aus früheren Prüfungen: die Entwürfe `/karten-nachbesserung-entwurf` und `/medien-pruefung-entwurf` sowie das Medium „Platzhalter Upload Medienpruefung“.
|
||||||
|
|
||||||
|
Seiten lassen sich nicht löschen; die Medien über „Medium löschen“ im Medienmanager.
|
||||||
|
|
||||||
|
## 5. Grenzen und offene Fragen
|
||||||
|
|
||||||
|
1. **Vorschau und übernommenes Bild:** Die Vorschau im Dialog kommt aus der kleinen Stufe (640 px), das übernommene Bild aus der Mediendatei. Beim Springen auf dieselbe Sekunde können beide minimal abweichen.
|
||||||
|
2. **Das Bild folgt dem Film nicht.** Ändert die Redaktion später das Vorschaubild des Films, bleibt die Karte beim übernommenen Bild.
|
||||||
|
3. **Das übernommene Bild ist ein eigenes Medium und hat eigene Rechte:** Wird der Film zurückgezogen, bleibt das Bild, solange es nicht ausdrücklich zurückgenommen wird.
|
||||||
|
4. **Frage:** Sollen Karten die Zielgruppe `cms` („CMS-Teaser“) statt `bibliothek` für abweichende Formulierungen lesen? Heute wird `cms` nirgends gelesen; ein Wechsel würde bestehende Karten ändern.
|
||||||
|
5. **Frage:** Die Programmkarte nimmt zuerst den Teaser, die Medienkarte zuerst die Kurzbeschreibung. Soll das einheitlich werden?
|
||||||
|
6. **Weiter offen:** eine öffentliche Filmvorschau (Trailer, Ausschnitt) und die Laufzeit, siehe Registry §13.
|
||||||
@@ -63,6 +63,7 @@ ## Übersicht der Architekturentscheidungen
|
|||||||
| ADR-40 | Zentrale Medienverwaltung im CMS | Umgesetzt auf Test (19.11.2026); Abnahme offen | CMS-Bilder sind Medien des Medienmanagers (Kennung statt Pfad), öffentlich nur mit Website-Freigabe; frühere CMS-Bilder übernommen |
|
| ADR-40 | Zentrale Medienverwaltung im CMS | Umgesetzt auf Test (19.11.2026); Abnahme offen | CMS-Bilder sind Medien des Medienmanagers (Kennung statt Pfad), öffentlich nur mit Website-Freigabe; frühere CMS-Bilder übernommen |
|
||||||
| ADR-41 | Gemeinsame Redaktionsbasis | Auf Test (19.11.2026, `develop` `f29ea58`); Betreiberabnahme offen. Technische Abbildung ist eine Arbeitsannahme, keine neue fachliche Freigabe | Klasse-A-Texte, Fachdimensionen und Präsentationsreferenzen an den bestehenden Fachobjekten; keine zweite Inhalts- oder Produktverwaltung |
|
| ADR-41 | Gemeinsame Redaktionsbasis | Auf Test (19.11.2026, `develop` `f29ea58`); Betreiberabnahme offen. Technische Abbildung ist eine Arbeitsannahme, keine neue fachliche Freigabe | Klasse-A-Texte, Fachdimensionen und Präsentationsreferenzen an den bestehenden Fachobjekten; keine zweite Inhalts- oder Produktverwaltung |
|
||||||
| ADR-42 | Angebot und Warenkorb | Fachlich beschlossen | Gemeinsame Angebotsseite mit Lizenzwahl, Mehrangebotswarenkorb und Geltung der Bestellfassung je Position |
|
| ADR-42 | Angebot und Warenkorb | Fachlich beschlossen | Gemeinsame Angebotsseite mit Lizenzwahl, Mehrangebotswarenkorb und Geltung der Bestellfassung je Position |
|
||||||
|
| ADR-43 | Trailer auf Karten | Umgesetzt auf Test (21.11.2026); Abnahme offen | Medien-, Programm- und Modulkarte spielen den für die Website freigegebenen Trailer beim Überfahren oder Antippen; ohne Freigabe nur das Bild |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -518,6 +519,8 @@ ## ADR-39 – Premium-Karten mit Fachbezug
|
|||||||
- Gleiche Höhe je Zeile über die gemeinsame Höhe `fill` (ADR-38). Für gemischte Raster sind die Abschnittsraster 1 + 1 + 2 und 2 + 1 + 1 ergänzt (additiv, bestehende Kennungen unverändert).
|
- Gleiche Höhe je Zeile über die gemeinsame Höhe `fill` (ADR-38). Für gemischte Raster sind die Abschnittsraster 1 + 1 + 2 und 2 + 1 + 1 ergänzt (additiv, bestehende Kennungen unverändert).
|
||||||
**Alternativen.** Ein Widget mit mehreren Karten und eigenem Spannweitenraster (verworfen: zweites Kartenraster neben dem Abschnittsraster); eine Widget-Art mit Variante je Fachobjekt (verworfen: Verweisschema hinge von der Variante ab); redaktionell gepflegte Kartentexte (verworfen: Kopien von Fachdaten); Vorschaubilder der Bibliothek als Kartenbild (verworfen: geschützt, Paket 6).
|
**Alternativen.** Ein Widget mit mehreren Karten und eigenem Spannweitenraster (verworfen: zweites Kartenraster neben dem Abschnittsraster); eine Widget-Art mit Variante je Fachobjekt (verworfen: Verweisschema hinge von der Variante ab); redaktionell gepflegte Kartentexte (verworfen: Kopien von Fachdaten); Vorschaubilder der Bibliothek als Kartenbild (verworfen: geschützt, Paket 6).
|
||||||
**Nachbesserung (18.11.2026, nach Betreiberprüfung).** Themenkarten bieten alle Säulen an (nicht veröffentlichte nur für die Redaktionsvorschau). Medienkarten zeigen die Kurzbeschreibung des Mediums (auf ausdrücklichen Wunsch), unterscheiden Film (Filmtafel) und Material (Materialsymbol) und zeigen das geschützte Vorschaubild der Bibliothek nur in der Redaktionsvorschau. Traineranleitungen erscheinen nie öffentlich. Programm-/Modulkarten nutzen Lernziel und Dauer und lassen Programme/Module ohne Anzeigefreigabe für die Vorschau zu. Fehlende Inhalte erscheinen nur in der Vorschau als Hinweise.
|
**Nachbesserung (18.11.2026, nach Betreiberprüfung).** Themenkarten bieten alle Säulen an (nicht veröffentlichte nur für die Redaktionsvorschau). Medienkarten zeigen die Kurzbeschreibung des Mediums (auf ausdrücklichen Wunsch), unterscheiden Film (Filmtafel) und Material (Materialsymbol) und zeigen das geschützte Vorschaubild der Bibliothek nur in der Redaktionsvorschau. Traineranleitungen erscheinen nie öffentlich. Programm-/Modulkarten nutzen Lernziel und Dauer und lassen Programme/Module ohne Anzeigefreigabe für die Vorschau zu. Fehlende Inhalte erscheinen nur in der Vorschau als Hinweise.
|
||||||
|
**Nachbesserung 2 (21.11.2026, Betreiberwunsch).** Die Medienkarte wählt ihren Text je Karte (Automatisch, Teaser, Kurzbeschreibung, Ausführliche Beschreibung; `settings.text_source`). Die ausführliche Beschreibung ist damit auf ausdrückliche Wahl öffentlich (vorher nie). Ein Film liefert über `FilmStill` ein Einzelbild für die Karte: das Vorschaubild des Films oder eine gewählte Stelle, einmal gezogen (bis 1600 px) und als gewöhnliches Bild-Medium abgelegt, mit eigener Website-Freigabe; der Film bleibt geschützt. Additive Tabelle `film_still_sources`.
|
||||||
|
**Nachbesserung 3 (21.11.2026, nach Betreiberprüfung).** Der Bildwähler im Dialog arbeitet wie im Medienmanager (Regler, Zahlenfeld, Live-Bild). Die Textwahl gilt auch an der Programm- und Modulkarte (zusätzlich Lernziel); deren Vorschaubild lässt sich wie ein Filmbild als Bild-Medium übernehmen (`CompositionStill`, additive Tabelle `composition_still_sources`).
|
||||||
**Offene Entscheidungen.** (1) Freigabe von Vorschaubildern für die Website und öffentliche Filmvorschauen (minimaler Erweiterungsbedarf in `cms-widget-registry.md` §13). (2) Ob bei Traineranleitungen schon der Titel auf der Programmseite öffentlich sein soll (Programmseite, nicht Karte).
|
**Offene Entscheidungen.** (1) Freigabe von Vorschaubildern für die Website und öffentliche Filmvorschauen (minimaler Erweiterungsbedarf in `cms-widget-registry.md` §13). (2) Ob bei Traineranleitungen schon der Titel auf der Programmseite öffentlich sein soll (Programmseite, nicht Karte).
|
||||||
**Folgen und offene Prüfung.** Keine Migration; bestehende Seiten und Widgets unverändert (gemessen). Mit ADR-29 ersetzen öffentliche Profile die Übergangsregeln in `PublicCatalogReader` und `PublicMaterialReader`; die gespeicherten Karten ändern sich dadurch nicht. Offen: gestalterische Freigabe v1.7, freigegebene Motive statt Platzhaltern, eine kaufbare Angebotskarte (eigenes Fachobjekt „Angebot“ mit Umfang, Zweck und Lizenzbedingungen, nicht Teil dieser Karten).
|
**Folgen und offene Prüfung.** Keine Migration; bestehende Seiten und Widgets unverändert (gemessen). Mit ADR-29 ersetzen öffentliche Profile die Übergangsregeln in `PublicCatalogReader` und `PublicMaterialReader`; die gespeicherten Karten ändern sich dadurch nicht. Offen: gestalterische Freigabe v1.7, freigegebene Motive statt Platzhaltern, eine kaufbare Angebotskarte (eigenes Fachobjekt „Angebot“ mit Umfang, Zweck und Lizenzbedingungen, nicht Teil dieser Karten).
|
||||||
**Quelle.** Brand-UI-Kit v1.7 (`docs/Brand-UI-Kit/13_premium_karten_v1.7_entwurf`, README, `docs/design-config.json`); `docs/architektur/cms-widget-registry.md` §§4, 6, 11, 13; ADR-29, ADR-30, ADR-38.
|
**Quelle.** Brand-UI-Kit v1.7 (`docs/Brand-UI-Kit/13_premium_karten_v1.7_entwurf`, README, `docs/design-config.json`); `docs/architektur/cms-widget-registry.md` §§4, 6, 11, 13; ADR-29, ADR-30, ADR-38.
|
||||||
@@ -560,3 +563,20 @@ ## ADR-42 – Öffentliche Angebotsdarstellung und Mehrangebotswarenkorb
|
|||||||
Die bestehende vorbelegte Angebotsmaske bleibt für Etappe 1 maßgeblich. Neue Fassungen werden ausdrücklich aktiviert. Abbrechen verwirft offene Eingaben. Im Warenkorb bleibt eine identisch bereits erworbene Lizenz gekennzeichnet und entfernbar. Sie geht weder in die Kaufsumme noch in die Bestellpositionen ein. Der ursprüngliche Erwerb bleibt der Nachweis.
|
Die bestehende vorbelegte Angebotsmaske bleibt für Etappe 1 maßgeblich. Neue Fassungen werden ausdrücklich aktiviert. Abbrechen verwirft offene Eingaben. Im Warenkorb bleibt eine identisch bereits erworbene Lizenz gekennzeichnet und entfernbar. Sie geht weder in die Kaufsumme noch in die Bestellpositionen ein. Der ursprüngliche Erwerb bleibt der Nachweis.
|
||||||
|
|
||||||
Pro Bestellung gilt höchstens ein Rabattcode. Allgemeine und produktspezifische Geltung sowie ein mehrfach nutzbarer Zertifizierungscode für geprüfte Konten gehören zum Verkaufsumfang. Verkaufskreis ist Deutschland einschließlich Privatkunden, Vereinen und Organisationen. Der Startumfang enthält keine freiwilligen Teilerstattungen und behandelt Bundles bei Rückgabe als Einheit. Zahlungs- und Rechnungsregeln stehen in ADR-14 und ADR-21.
|
Pro Bestellung gilt höchstens ein Rabattcode. Allgemeine und produktspezifische Geltung sowie ein mehrfach nutzbarer Zertifizierungscode für geprüfte Konten gehören zum Verkaufsumfang. Verkaufskreis ist Deutschland einschließlich Privatkunden, Vereinen und Organisationen. Der Startumfang enthält keine freiwilligen Teilerstattungen und behandelt Bundles bei Rückgabe als Einheit. Zahlungs- und Rechnungsregeln stehen in ADR-14 und ADR-21.
|
||||||
|
|
||||||
|
## ADR-43 – Trailer auf Karten
|
||||||
|
|
||||||
|
**Status am 21.11.2026:** Umgesetzt auf `develop`/Testinstanz (Branch `feature/karten-trailer`); Abnahme durch den Betreiber offen.
|
||||||
|
**Kontext.** FACH-46 fordert öffentliche Teaservideos; die Rollen Trailer und Vorschauclip gibt es im Medienmanager, ein freigegebener Clip wird über `website.media` ausgeliefert. Auf einer Karte war bisher nur ein Bild vorgesehen („kein Abspielen“, ADR-39). Die Grenze galt dem vollständigen Film und dem Bibliotheksmaterial, nicht einem für die Website bestimmten Trailer. Ein Trailer ist kein Lizenzelement; er braucht keine Lizenzentscheidung, nur die Website-Freigabe nach ADR-40.
|
||||||
|
**Entscheidung.**
|
||||||
|
- **Welche Karten:** Medien- und Materialkarte, Programm- und Modulkarte. Die Themenkarte hat keinen Trailer.
|
||||||
|
- **Welcher Clip:** der Trailer des Fachobjekts (Präsentationsrolle „Trailer“), sonst der Vorschauclip. Bei einem Film ersatzweise sein eigener für die Website freigegebener Teaser. Gewählt wird einmal in der Präsentation des Mediums, Programms oder Moduls; alle Karten desselben Objekts zeigen denselben Clip. Je Karte lässt sich der Trailer ausschalten (Darstellung → „Trailer auf der Karte“, Vorgabe: Abspielen).
|
||||||
|
- **Wann er läuft:** Am Desktop spielt er stumm und in Schleife, solange die Maus auf der Karte steht, und endet beim Verlassen. Am Handy und auf Wunsch auch am Desktop startet und stoppt ihn ein Tipp auf das Bild oder die Schaltfläche „Trailer“ am Bild, die auch die Tastatur bedient (`aria-pressed`). Es spielt nie mehr als ein Clip zugleich; er hält an, wenn die Karte aus dem Bild scrollt oder die Seite verdeckt wird.
|
||||||
|
- **Rücksicht:** Bei „reduzierte Bewegung“ und im Datensparmodus startet nichts von selbst, nur auf ausdrückliche Bedienung und dann ohne Schleife. Der Clip wird erst beim ersten Start geladen (`preload="none"`, Quelle erst dann gesetzt). Ohne JavaScript bleibt es beim Kartenbild.
|
||||||
|
- **Rechte:** Es spielt nur ein für die Website freigegebener Clip. Der vollständige Film, die Originaldatei und nicht freigegebene Clips kommen nie über eine Karte, auch nicht in der Redaktionsvorschau; diese nennt stattdessen, dass der Trailer nicht freigegeben ist. Die Karte gibt nichts frei und bietet keinen Download. Die Karte einer Traineranleitung erscheint weiter öffentlich nie.
|
||||||
|
- **Auslieferung:** Die Route `website.media` beantwortet Bereichsabrufe (`Range`, Antwort 206/416) für Filme und Hörstücke. Safari und iOS spielen sonst nicht ab.
|
||||||
|
**Alternativen.** Clip je Karte frei wählen (verworfen: mehrere Wege, doppelte Pflege); Autoplay mit Ton oder ohne Bedienung (verworfen: Barrierefreiheit, Datenvolumen); Clip aus dem vollständigen Film erzeugen (verworfen: Rechte, kein freigegebener Clip).
|
||||||
|
**Folgen.** Neue Einstellung `clip` an der Medien-, Programm- und Modulkarte, Klasse `CardClip`, Skript `resources/js/card-clip.js`; keine Migration. Bereits gespeicherte Karten ohne Wahl spielen einen freigegebenen Trailer ab (Vorgabe Abspielen). Hinweis „Mit Ton starten“ nicht vorgesehen.
|
||||||
|
**Nachtrag Hero (22.11.2026).** Das Hero-Widget (Variante „Foto mit Textfläche“) kann ein Video zeigen: optionale Auswahl `refs.video` (ein Film aus dem Medienmanager, Klasse `HeroVideo`, Skript `resources/js/hero-video.js`). Der Clip folgt derselben Regel wie auf der Karte (Trailer, sonst Vorschauclip, sonst die freigegebene Website-Datei des Films; nie der vollständige Film, nie ein nicht freigegebener Clip). Er läuft stumm auf der Fläche des Fotos und startet nach dem Laden der Seite von selbst, sobald der Einstieg im Bild ist; das Foto bleibt darunter, bis das erste Videobild da ist, und ist der Rückfall bei Fehlern. Eine Schaltfläche „Video“ hält an und spielt ab (WCAG 2.2.2). Bei „reduzierte Bewegung“, im Datensparmodus und bei 2G startet nichts von selbst, nur auf Bedienung und ohne Schleife. Er hält an, wenn der Einstieg aus dem Bild scrollt, und läuft nur weiter, wenn er von selbst lief und nicht angehalten wurde. In der Markenfläche (`editorial_solid`) gibt es kein Video. Neuer Schlüssel ohne Versionssprung, keine Migration. Hinweis „Mit Ton starten“ und Video als Seitenhintergrund bleiben ausgeschlossen.
|
||||||
|
**Quelle.** `docs/ux/verwaltung/04-fachliche-anforderungen.md` FACH-46; `medienzugriff-fuer-komponenten.md`; `cms-widget-registry.md`; ADR-39, ADR-40, ADR-41.
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ ## 4. Registrierte Widget-Arten
|
|||||||
|
|
||||||
| Kennung | Name | Version | Varianten | Breiten (Einheiten) | Höhen | Verweise |
|
| Kennung | Name | Version | Varianten | Breiten (Einheiten) | Höhen | Verweise |
|
||||||
|---|---|---|---|---|---|---|
|
|---|---|---|---|---|---|---|
|
||||||
| `hero` | Einstieg (Hero), Premium nach Kit v1.6 | 2 | `photo_split` (Foto mit Textfläche), `editorial_solid` (Navy-Markenfläche) | 3, 4 | `compact` (mind. 400 px), `normal` (512 px, Vorgabe), `large` (640 px) | `refs.image` |
|
| `hero` | Einstieg (Hero), Premium nach Kit v1.6 | 2 | `photo_split` (Foto mit Textfläche), `editorial_solid` (Navy-Markenfläche) | 3, 4 | `compact` (mind. 400 px), `normal` (512 px, Vorgabe), `large` (640 px) | `refs.image`, `refs.video` (optional) |
|
||||||
| `heading` | Überschrift und Einleitung | 1 | `standard` | 1–4 | – | – |
|
| `heading` | Überschrift und Einleitung | 1 | `standard` | 1–4 | – | – |
|
||||||
| `prose` | Fließtext | 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`, `normal` (Vorgabe), `spacious` | `refs.image` |
|
| `image_text` | Bild und Text, Premium nach Kit v1.6 | 3 | `image_left`, `image_right` (Bildseite) | 1–4 | `compact`, `normal` (Vorgabe), `spacious` | `refs.image` |
|
||||||
@@ -312,15 +312,23 @@ ## 13. Premium-Karten (Brand-UI-Kit v1.7, ADR-39)
|
|||||||
|
|
||||||
**Darstellung** (Reiter „Darstellung“): Variante `adaptive` (ab 520 px Bild neben Text) oder `stacked` (Bild immer oben); Höhe `auto` oder `fill` („An die Zeile angleichen“); `settings.format` (`landscape` 16:9 Vorgabe, `square`, `portrait` 3:4); `settings.fit` (`cover` Vorgabe, `contain` für Dokumente und Poster); `settings.heading_level` (`h3` Vorgabe, `h2`, `h4`); Anzeigen/Ausblenden von Kurzbeschreibung, Art (nicht bei Programm/Modul), Zusatzangaben und Aktion. Bildhöhe höchstens min(70vh, 640 px).
|
**Darstellung** (Reiter „Darstellung“): Variante `adaptive` (ab 520 px Bild neben Text) oder `stacked` (Bild immer oben); Höhe `auto` oder `fill` („An die Zeile angleichen“); `settings.format` (`landscape` 16:9 Vorgabe, `square`, `portrait` 3:4); `settings.fit` (`cover` Vorgabe, `contain` für Dokumente und Poster); `settings.heading_level` (`h3` Vorgabe, `h2`, `h4`); Anzeigen/Ausblenden von Kurzbeschreibung, Art (nicht bei Programm/Modul), Zusatzangaben und Aktion. Bildhöhe höchstens min(70vh, 640 px).
|
||||||
|
|
||||||
|
**Video im Einstieg (Hero, Variante `photo_split`).** Optional `refs.video`: ein Film aus dem Medienmanager (Auswahl über `HeroVideo`, geprüft: Film, nicht archiviert, nicht gesperrt, keine Traineranleitung). Gespielt wird der freigegebene Clip nach der Regel der Karte (`CardClip`: Trailer, Vorschauclip, sonst die freigegebene Website-Datei des Films). Das Video liegt stumm auf der Fläche des Fotos, startet nach dem Laden von selbst (nicht bei „reduzierte Bewegung“, Datensparmodus, 2G), hat eine Schaltfläche zum Anhalten und fällt bei Fehlern auf das Foto zurück; `resources/js/hero-video.js`. Die Markenfläche zeigt kein Video. Entscheidung: ADR-43 (Nachtrag).
|
||||||
|
|
||||||
|
**Trailer auf der Karte (Medien-, Programm- und Modulkarte).** Einstellung `settings.clip` (`yes` Vorgabe, `no`). Der Clip ist der Trailer des Objekts (Präsentationsrolle „Trailer“, sonst „Vorschauclip“, bei einem Film ersatzweise sein freigegebener Teaser), nur wenn er für die Website freigegeben ist (`CardClip`). Er liegt stumm über dem Kartenbild und startet beim Überfahren mit der Maus, am Handy mit Tippen, per Tastatur über die Schaltfläche am Bild; `resources/js/card-clip.js`. Ohne Freigabe bleibt das Bild; die Redaktionsvorschau nennt den Grund. Entscheidung: ADR-43.
|
||||||
|
|
||||||
|
**Text der Karte.** Einstellung `settings.text_source` (`auto` Vorgabe, `teaser`, `summary`, `description`; an der Programm- und Modulkarte zusätzlich `goal`, das Lernziel der Fassung). `auto` entspricht dem bisherigen Verhalten je Karte (Medien: Kurzbeschreibung, sonst Teaser; Programm und Modul: Teaser, sonst Kurzbeschreibung, sonst Lernziel); die Themenkarte hat nur einen Text und keine Wahl. Eine ausdrückliche Wahl ersetzt nicht still durch ein anderes Feld. Die ausführliche Beschreibung erscheint nur auf diese Wahl (öffentlich, sofern die Karte öffentlich ist). Der eigene Text der Karte (`data.summary`) hat Vorrang.
|
||||||
|
|
||||||
|
**Bild aus dem Film (Medienkarte).** Reiter „Medien“, nur bei einem Film: eine Stelle mit Regler und Live-Bild wählen („Diese Stelle übernehmen“) oder „Vorschaubild des Films übernehmen“. An der Programm- und Modulkarte entsprechend „Vorschaubild übernehmen“ (`CompositionStill`). `FilmStill` legt das Einzelbild (bis 1600 px) einmal als Bild-Medium ab; `refs.image` trägt dessen Kennung. Details und Grenzen: `medienzugriff-fuer-komponenten.md`, Abschnitt „Text der Medien- und Materialkarte, Bild aus dem Film“.
|
||||||
|
|
||||||
**Redaktionsvorschau.** Nicht öffentliche Karten tragen die Marke „Nur Redaktionsvorschau“. Fehlende Inhalte (Kurzbeschreibung, Text für die Website, Anzeigetitel, Dauer, Laufzeit, Kartenbild) stehen eingeklappt unter „Hinweise für die Redaktion“, mit dem Ort, an dem sie gepflegt werden. Öffentlich erscheinen weder Marke noch Hinweise noch Bibliotheksbilder.
|
**Redaktionsvorschau.** Nicht öffentliche Karten tragen die Marke „Nur Redaktionsvorschau“. Fehlende Inhalte (Kurzbeschreibung, Text für die Website, Anzeigetitel, Dauer, Laufzeit, Kartenbild) stehen eingeklappt unter „Hinweise für die Redaktion“, mit dem Ort, an dem sie gepflegt werden. Öffentlich erscheinen weder Marke noch Hinweise noch Bibliotheksbilder.
|
||||||
|
|
||||||
**Raster.** Eine Karte je Platz. Gemischte Raster entstehen über die Abschnittsraster, zum Beispiel 1 + 1 + 2 (`u1_1_2`), 2 + 2, 1 + 1 + 1 + 1. Gleiche Höhe: alle Karten einer Zeile auf „An die Zeile angleichen“ stellen; die Aktion steht dann am unteren Rand. Eine öffentlich nicht sichtbare Karte lässt ihren Platz entfallen; die übrigen Plätze teilen sich die Breite. Solche Karten daher in einen eigenen Abschnitt setzen oder mit einem Platz kombinieren, der allein gut aussieht.
|
**Raster.** Eine Karte je Platz. Gemischte Raster entstehen über die Abschnittsraster, zum Beispiel 1 + 1 + 2 (`u1_1_2`), 2 + 2, 1 + 1 + 1 + 1. Gleiche Höhe: alle Karten einer Zeile auf „An die Zeile angleichen“ stellen; die Aktion steht dann am unteren Rand. Eine öffentlich nicht sichtbare Karte lässt ihren Platz entfallen; die übrigen Plätze teilen sich die Breite. Solche Karten daher in einen eigenen Abschnitt setzen oder mit einem Platz kombinieren, der allein gut aussieht.
|
||||||
|
|
||||||
**Sicherheit.** Der einzuhaltende Weg steht in `medienzugriff-fuer-komponenten.md`. Vorschaubilder der Bibliothek (Filmstandbilder, Modulvorschau) nur über `editorial.card` (Redaktionsanmeldung) und nur in der Redaktionsvorschau; öffentlich nie. Keine Adressen unter `/bereich/` oder `/redaktion/` auf öffentlichen Seiten, kein Abspielen, kein Download, kein Preis, keine Kaufaktion. Nie öffentlich: Beschreibung, Einsatzhinweis, Lizenzvermerk, Lehrtexte, Traineranleitungen. Eine Karte begründet keine Berechtigung (Tests `CmsPremiumCardsTest`).
|
**Sicherheit.** Der einzuhaltende Weg steht in `medienzugriff-fuer-komponenten.md`. Vorschaubilder der Bibliothek (Filmstandbilder, Modulvorschau) nur über `editorial.card` (Redaktionsanmeldung) und nur in der Redaktionsvorschau; öffentlich nie. Keine Adressen unter `/bereich/` oder `/redaktion/` auf öffentlichen Seiten, kein Abspielen außer eines für die Website freigegebenen Trailers (ADR-43), kein Download, kein Preis, keine Kaufaktion. Nie öffentlich: Beschreibung, Einsatzhinweis, Lizenzvermerk, Lehrtexte, Traineranleitungen. Eine Karte begründet keine Berechtigung (Tests `CmsPremiumCardsTest`).
|
||||||
|
|
||||||
**Erweiterungsbedarf für öffentliche Vorschaubilder und Filmvorschauen (nicht umgesetzt, minimal):**
|
**Erweiterungsbedarf für öffentliche Vorschaubilder und Filmvorschauen (nicht umgesetzt, minimal):**
|
||||||
1. *Vorschaubild für die Website freigeben:* je `ContentElement` und `Composition` ein Freigabevermerk (`thumbnail_public_at`, `thumbnail_public_by`, Bezug auf `thumbnail_source`), gesetzt nur durch eine ausdrückliche Aktion „Vorschaubild für die Website freigeben“ in der Medien- bzw. Modulbearbeitung. Die Hintergrundverarbeitung kopiert das freigegebene Standbild nach `media_public` (eigener Pfad, zum Beispiel `katalog/`), Zurücknehmen löscht die Kopie. Die Karte nimmt dieses Bild, wenn kein Kartenbild gewählt ist. Der Web-Prozess schreibt weiterhin nicht in den Medienbestand.
|
1. *Vorschaubild für die Website freigeben:* je `ContentElement` und `Composition` ein Freigabevermerk (`thumbnail_public_at`, `thumbnail_public_by`, Bezug auf `thumbnail_source`), gesetzt nur durch eine ausdrückliche Aktion „Vorschaubild für die Website freigeben“ in der Medien- bzw. Modulbearbeitung. Die Hintergrundverarbeitung kopiert das freigegebene Standbild nach `media_public` (eigener Pfad, zum Beispiel `katalog/`), Zurücknehmen löscht die Kopie. Die Karte nimmt dieses Bild, wenn kein Kartenbild gewählt ist. Der Web-Prozess schreibt weiterhin nicht in den Medienbestand.
|
||||||
2. *Öffentliche Filmvorschau (Trailer, Ausschnitt):* eine eigene Ausgabe (`MediaRendition` mit Rolle `preview`) und eine eigene Freigabe je Fassung, getrennt vom lizenzpflichtigen Film; ausgeliefert ohne Signatur nur nach dieser Freigabe. Bis dahin hat die Karte keine Abspielfunktion.
|
2. *Öffentliche Filmvorschau (Trailer, Ausschnitt; ein Einzelbild aus dem Film ist seit 21.11.2026 über FilmStill möglich):* eine eigene Ausgabe (`MediaRendition` mit Rolle `preview`) und eine eigene Freigabe je Fassung, getrennt vom lizenzpflichtigen Film; ausgeliefert ohne Signatur nur nach dieser Freigabe. Bis dahin hat die Karte keine Abspielfunktion.
|
||||||
3. *Laufzeit:* ein Feld in den Mediendaten der Fassung (zum Beispiel `metadata.duration_seconds`, beim Transkodieren mit ffprobe ermittelt).
|
3. *Laufzeit:* ein Feld in den Mediendaten der Fassung (zum Beispiel `metadata.duration_seconds`, beim Transkodieren mit ffprobe ermittelt).
|
||||||
Alle drei Erweiterungen hängen mit ADR-29 (öffentliche Profile) zusammen und brauchen eine Entscheidung von Lars.
|
Alle drei Erweiterungen hängen mit ADR-29 (öffentliche Profile) zusammen und brauchen eine Entscheidung von Lars.
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ ## Anzeige auf der Website
|
|||||||
|
|
||||||
Solange öffentliche Profile (ADR-29) fehlen, ist das die Übergangsregel. Ein Medium hat keine eigene öffentliche Seite. Die Karte verweist dann auf die Programmseite.
|
Solange öffentliche Profile (ADR-29) fehlen, ist das die Übergangsregel. Ein Medium hat keine eigene öffentliche Seite. Die Karte verweist dann auf die Programmseite.
|
||||||
|
|
||||||
Gelesen werden Anzeigename (sonst Arbeitstitel), Kurzbeschreibung, Inhaltsart und Ausgabeart. Nicht gelesen und nicht ausgegeben werden Beschreibung, Einsatzhinweis, Lizenzvermerk, Lehrtext und jede Datei.
|
Gelesen werden Anzeigename (sonst Arbeitstitel), Inhaltsart und Ausgabeart sowie genau einer der Texte Teaser, Kurzbeschreibung oder ausführliche Beschreibung (siehe „Text der Medien- und Materialkarte“). Nicht gelesen und nicht ausgegeben werden Einsatzhinweis, Lizenzvermerk, Lehrtext und jede Datei.
|
||||||
|
|
||||||
Das Vorschaubild der Bibliothek erscheint nur in der Redaktionsvorschau, über die Route `editorial.card`, und nur für angemeldete Redaktion. Auf einer öffentlichen Seite hat dieses Bild keine Adresse.
|
Das Vorschaubild der Bibliothek erscheint nur in der Redaktionsvorschau, über die Route `editorial.card`, und nur für angemeldete Redaktion. Auf einer öffentlichen Seite hat dieses Bild keine Adresse.
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ ### Neues Bild aus dem CMS
|
|||||||
|
|
||||||
Originaldatei, Master-Fassung und Traineranleitungen werden abgelehnt. Eine Quellenzeile (`website_credit`) und ein Alternativtext (`website_alt`) gehören zu den Anzeigedaten und erzeugen keine neue Fassung. Die Quellenzeile erscheint nur, solange die Freigabe besteht. Der interne Vermerk bleibt intern.
|
Originaldatei, Master-Fassung und Traineranleitungen werden abgelehnt. Eine Quellenzeile (`website_credit`) und ein Alternativtext (`website_alt`) gehören zu den Anzeigedaten und erzeugen keine neue Fassung. Die Quellenzeile erscheint nur, solange die Freigabe besteht. Der interne Vermerk bleibt intern.
|
||||||
|
|
||||||
Ein neues Website-Bild nimmt `WebsiteIntake` auf und gibt es nach der Ableitung frei. Ein eigenständiges Präsentationsmedium legt `PresentationFile` ohne Inhaltsfassung an und gibt es nicht von selbst frei. Öffentliche Profile nach ADR-29 sind damit nicht umgesetzt.
|
Ein neues Website-Bild nimmt `WebsiteIntake` auf und gibt es nach der Ableitung frei. Ein eigenständiges Präsentationsmedium legt `PresentationFile` ohne Inhaltsfassung an und gibt es nicht von selbst frei. Der Web-Prozess liest `derived/` nur; er prüft die Datei (Film: MP4 oder WebM, Hörstück: MP3, M4A oder OGG) und übergibt das Kopieren an die Warteschlange (`StorePresentationFile`). Dieselbe Website-Datei lässt sich unter „Website-Freigabe“ am Medium auch zu einem Film mit geschützter Inhaltsfassung hinzufügen, zum Beispiel für einen ungeschützten Trailer; die Fassung bleibt dabei unverändert. Öffentliche Profile nach ADR-29 sind damit nicht umgesetzt.
|
||||||
|
|
||||||
## Was eine Komponente einhält
|
## Was eine Komponente einhält
|
||||||
|
|
||||||
@@ -129,6 +129,7 @@ ### Übernahme der früheren CMS-Bilder
|
|||||||
(404, wenn zurückgenommen).
|
(404, wenn zurückgenommen).
|
||||||
- Gespeicherte Revisionen bleiben unverändert; frühere Pfade werden beim Darstellen zugeordnet und beim nächsten
|
- Gespeicherte Revisionen bleiben unverändert; frühere Pfade werden beim Darstellen zugeordnet und beim nächsten
|
||||||
Speichern durch die Kennung ersetzt. Frühere Pfade ohne Zuordnung bleiben über `PublicMedia` gültig.
|
Speichern durch die Kennung ersetzt. Frühere Pfade ohne Zuordnung bleiben über `PublicMedia` gültig.
|
||||||
|
- Wird ein übernommenes Medium gelöscht, bleibt die Zuordnung als Sperre bestehen (`content_element_id` leer): Der frühere Pfad wird weder über `/medien/cms/…` ausgeliefert noch als Bild gezeigt; die Datei unter `cms/` bleibt liegen. Die Karte oder das Widget bleibt ohne Bild.
|
||||||
- Eine Slideshow gibt es im CMS nicht; `WebsiteMedia::presentMany` ist für sie vorbereitet und noch unbenutzt.
|
- Eine Slideshow gibt es im CMS nicht; `WebsiteMedia::presentMany` ist für sie vorbereitet und noch unbenutzt.
|
||||||
|
|
||||||
## Präsentationszuordnungen (19.11.2026, ADR-41)
|
## Präsentationszuordnungen (19.11.2026, ADR-41)
|
||||||
@@ -137,4 +138,53 @@ ## Präsentationszuordnungen (19.11.2026, ADR-41)
|
|||||||
|
|
||||||
Öffentliche Seiten lesen ein Bild nur über `WebsiteImage` und damit über `WebsiteMedia`. Ein freigegebener Film oder ein Hörstück wird über `website.media` ausgeliefert. Geschützte Originaldateien und Vorschaubilder der Bibliothek bleiben auf diesem Weg geschlossen. Wird die Freigabe zurückgenommen, endet die öffentliche Ausgabe; Überschriften und Texte bleiben. Ein Widget ohne verbleibenden Inhalt entfällt.
|
Öffentliche Seiten lesen ein Bild nur über `WebsiteImage` und damit über `WebsiteMedia`. Ein freigegebener Film oder ein Hörstück wird über `website.media` ausgeliefert. Geschützte Originaldateien und Vorschaubilder der Bibliothek bleiben auf diesem Weg geschlossen. Wird die Freigabe zurückgenommen, endet die öffentliche Ausgabe; Überschriften und Texte bleiben. Ein Widget ohne verbleibenden Inhalt entfällt.
|
||||||
|
|
||||||
Die ausführliche Beschreibung, Einsatzhinweise, Lizenzvermerke und Lehrtexte bleiben außerhalb der öffentlichen Karte. `PublicMaterialReader` und `PublicCatalogReader` lesen dafür die Klasse-A-Angaben (`EditorialProfileReader`) und keine Datei.
|
Einsatzhinweise, Lizenzvermerke und Lehrtexte bleiben außerhalb der öffentlichen Karte. Die ausführliche Beschreibung erscheint nur, wenn die Redaktion sie für diese Karte ausdrücklich wählt (siehe unten). `PublicMaterialReader` und `PublicCatalogReader` lesen dafür die Klasse-A-Angaben (`EditorialProfileReader`) und keine Datei.
|
||||||
|
|
||||||
|
## Text der Medien- und Materialkarte, Bild aus dem Film (21.11.2026)
|
||||||
|
|
||||||
|
### Text
|
||||||
|
|
||||||
|
Die Redaktion wählt je Karte in der Darstellung „Text der Karte“:
|
||||||
|
|
||||||
|
| Wahl | Text |
|
||||||
|
|---|---|
|
||||||
|
| Automatisch (Vorgabe) | Kurzbeschreibung, sonst Teaser (wie bisher) |
|
||||||
|
| Teaser | `teaser` |
|
||||||
|
| Kurzbeschreibung | `summary` |
|
||||||
|
| Ausführliche Beschreibung | `description` |
|
||||||
|
|
||||||
|
- Jede Wahl liest dieselbe Quelle wie die übrige Karte: das Medium, mit einer Abweichung für die Mitgliederbibliothek (`EditorialProfileReader`, Zielgruppe `bibliothek`), wenn es sie gibt. Die Zielgruppe `cms` („CMS-Teaser“) wird weiterhin nirgends gelesen; ein Wechsel würde bestehende Karten ändern und ist eine offene Frage.
|
||||||
|
- Eine ausdrückliche Wahl ersetzt nicht still durch ein anderes Feld. Ist der gewählte Text nicht gepflegt, bleibt die Karte ohne Text; die Redaktionsvorschau nennt, wo er zu pflegen ist. Öffentlich erscheint nie ein Hinweis.
|
||||||
|
- Der eigene Text der Karte (`data.summary`, „Text nur für diese Karte“) hat Vorrang vor der Wahl.
|
||||||
|
- **Neu öffentlich auf ausdrückliche Wahl:** die ausführliche Beschreibung, die bisher Bibliothekstext war. Der Dialog sagt das („erscheint öffentlich“). Einsatzhinweis und Lizenzvermerk sind nicht wählbar. Öffentlich ist die Karte weiterhin nur, wenn das Medium zu einem öffentlich gezeigten Programm gehört.
|
||||||
|
- Die Wahl gibt es an der Medien- und Materialkarte und an der Programm- und Modulkarte. Ein Thema hat nur einen Text („Text für die Website“); dort gibt es nichts zu wählen.
|
||||||
|
- **Programm- und Modulkarte:** Wahl Automatisch (Teaser, sonst Kurzbeschreibung, sonst Lernziel, wie bisher), Teaser, Kurzbeschreibung, Ausführliche Beschreibung oder **Lernziel der Fassung** (steht auf der öffentlichen Programmseite bereits öffentlich). Die Texte werden mit der Zielgruppe „Öffentliche Kachel“ gelesen. Auch hier ersetzt eine ausdrückliche Wahl nicht still durch ein anderes Feld; die Vorschau nennt, wo der Text zu pflegen ist („Programm oder Modul bearbeiten“).
|
||||||
|
|
||||||
|
### Bild aus dem Film
|
||||||
|
|
||||||
|
Das Vorschaubild eines Films (Medienmanager) und jede Filmstelle sind geschützt und erscheinen öffentlich nie. Für die Karte gibt es einen ausdrücklichen Weg, daraus ein Website-Bild zu machen. Im Reiter „Medien“ der Medienkarte, bei einem Film:
|
||||||
|
|
||||||
|
1. eine Stelle wählen: Regler und Zahlenfeld zeigen dieselbe Zeitposition, das Bild der Stelle folgt dem Regler nach kurzer Pause (wie im Medienmanager); „Diese Stelle übernehmen“ legt genau die angezeigte Stelle ab, oder
|
||||||
|
2. „Vorschaubild des Films übernehmen“ (das im Medienmanager gesetzte Vorschaubild; mit kleiner Ansicht daneben).
|
||||||
|
|
||||||
|
`FilmStill` zieht das Einzelbild **einmal** und legt es über `WebsiteIntake` als gewöhnliches Bild-Medium (`output_class = bild`) im Medienmanager ab. Die Warteschlange leitet es ab und gibt genau diese Ableitung frei, wie bei jedem Upload aus dem CMS. Die Karte speichert die Kennung dieses Bildes in `refs.image`.
|
||||||
|
|
||||||
|
- **Kein Neuziehen:** Seitenaufrufe lesen nur die gespeicherte Datei; `ffmpeg` läuft nur beim Übernehmen und in der Vorschau des Dialogs (Route `editorial.frame`, nur angemeldete Redaktion). Test: `FilmStillTest` zählt die Extraktionen.
|
||||||
|
- **Einmal je Stelle:** `film_still_sources` (additive Tabelle) ordnet Film, Quelle (`frame:{Fassung}@{Sekunde}` oder `file:{SHA-256}`) und Bild zu. Dieselbe Stelle, auch über „Vorschaubild übernehmen“ eines Filmbilds aus derselben Stelle, ergibt dasselbe Medium. Ein archiviertes oder bei der Verarbeitung gescheitertes Bild wird nicht wiederverwendet; die Stelle lässt sich dann neu übernehmen.
|
||||||
|
- **Wiederverwendung ehrlich melden:** Wird ein schon übernommenes Bild gewählt, sagt die Meldung, wie es steht (bereits freigegeben, wird verarbeitet oder Website-Freigabe zurückgenommen). Eine zurückgenommene Freigabe bleibt zurückgenommen; das Bild erscheint öffentlich erst nach erneuter Freigabe im Medienmanager (Reiter „Website“).
|
||||||
|
- **Löschen:** „Medium löschen“ (Medien ohne Fassung) entfernt auch ein Standbild; die Herkunftszeile entfällt (Migration `allow_deleting_media_with_stills_and_aliases`), dieselbe Stelle lässt sich neu übernehmen.
|
||||||
|
- **Auflösung:** Aus der Mediendatei (`inhalte/`) bis 1600 px Breite, nie über die Breite der Quelle hinaus vergrößert; ohne Mediendatei aus der kleinen Stufe (480 p). Die Vorschau im Dialog und das Vorschaubild des Medienmanagers bleiben bei 640 px.
|
||||||
|
- **Rechte:** Es wird nie der Film abgelegt, nur ein Einzelbild; keine Fassung, keine Berechtigung, kein Lizenzartikel. Ausgeschlossen sind Traineranleitungen, archivierte Filme und Filme ohne bereitgestellte Fassung. Die Handlung ist ausdrücklich (Redakteur, wie beim Upload); die Freigabe des entstandenen Bildes lässt sich im Medienmanager zurücknehmen (Wirkung: das Bild entfällt auf allen Seiten).
|
||||||
|
- **Das Bild ist ein eigenes Medium** mit Titel „Standbild: {Film} (Fassung n, x s)“, Alternativtext „Szene aus dem Film …“ und der Quellenzeile des Films. Es folgt späteren Änderungen des Film-Vorschaubilds nicht; wer es als Titelbild des Films verwenden will, ordnet es im Medienmanager als Präsentationsmedium zu (dann nutzen alle Karten des Films es automatisch).
|
||||||
|
- **Nicht umgesetzt:** eine öffentliche Filmvorschau (Trailer, Ausschnitt) und die Laufzeit. Beides bleibt Erweiterungsbedarf (Registry §13).
|
||||||
|
|
||||||
|
### Vorschaubild eines Programms oder Moduls (Programm- und Modulkarte)
|
||||||
|
|
||||||
|
Das Vorschaubild eines Programms oder Moduls (Redaktionsmanager) ist ebenfalls ein geschütztes Bibliotheksbild. Im Reiter „Medien“ der Programm- und Modulkarte übernimmt „Vorschaubild übernehmen“ es als Bild-Medium („Titelbild: {Titel}“); `CompositionStill` arbeitet wie `FilmStill`: einmal kopiert (bis zur Größe der Vorschaudatei, 640 px), über `WebsiteIntake` abgelegt, Herkunft in `composition_still_sources` (dasselbe Vorschaubild ergibt dasselbe Medium), ein gescheitertes oder archiviertes Bild wird nicht wiederverwendet, die Meldung nennt den tatsächlichen Stand (auch bei zurückgenommener Freigabe). Ein Programm ohne Vorschaubild zeigt den Hinweis, es im Redaktionsmanager zu setzen. Eine Stelle aus einem Film des Programms zu wählen gibt es hier nicht; das Vorschaubild des Programms selbst lässt sich im Redaktionsmanager aus einem Film setzen.
|
||||||
|
|
||||||
|
### Trailer auf Medien-, Programm- und Modulkarten
|
||||||
|
|
||||||
|
Ein Trailer ist ein eigenes Medium (Film ohne Fassung, Ableitung unter `teaser/`), das im Medienmanager einem Medium, Programm oder Modul in der Präsentation mit der Rolle „Trailer“ oder „Vorschauclip“ zugeordnet wird. Die Karte spielt ihn ab, wenn er für die Website freigegeben ist (Reiter „Website“ am Trailer). Lesende Klasse: `CardClip` (Trailer, sonst Vorschauclip, bei einem Film ersatzweise sein eigener freigegebener Teaser). Ausgeliefert wird über `website.media`, die Bereichsabrufe (`Range`) beantwortet. Nicht freigegebene Clips, der vollständige Film und Originale kommen nie über die Karte. Die Redaktionsvorschau spielt ebenfalls nur freigegebene Clips und nennt sonst den Grund. Verhalten (Maus, Tipp, Tastatur, reduzierte Bewegung, Datensparmodus): ADR-43.
|
||||||
|
|
||||||
|
Ein Film, der nur aus einer Website-Datei besteht (Medium ohne Fassung, zum Beispiel ein Teaser), ist auf der Medienkarte wählbar (`PublicMaterialReader::isWebsiteOnlyFilm`). Öffentlich erscheint die Karte, sobald diese Datei für die Website freigegeben ist, ohne Verweis auf eine Programmseite und damit ohne Aktion; ohne Freigabe nur in der Redaktionsvorschau. Dasselbe freigegebene Video nutzt der Einstieg (Hero, `HeroVideo`).
|
||||||
|
|
||||||
@@ -27,6 +27,30 @@ ## Env-Datei ändern (zum Beispiel Mail, `APP_URL`)
|
|||||||
|
|
||||||
**nginx findet die neue App selbst (seit 21.11.2026).** Der Web-Container löst den Namen `app` über Dockers DNS zur Laufzeit auf (`resolver 127.0.0.11` in `docker/nginx/default.conf`). Vorher war die Adresse beim Start von nginx festgeschrieben: Ein erneuter Lauf mit unverändertem Code erzeugte die App neu, nicht aber den Web-Container, und Prod antwortete mit 502, bis `luf-prod-web-1` neu gestartet wurde (20.11.2026). Ein Test (`tests/Unit/NginxConfigTest.php`) hält die Konfiguration fest.
|
**nginx findet die neue App selbst (seit 21.11.2026).** Der Web-Container löst den Namen `app` über Dockers DNS zur Laufzeit auf (`resolver 127.0.0.11` in `docker/nginx/default.conf`). Vorher war die Adresse beim Start von nginx festgeschrieben: Ein erneuter Lauf mit unverändertem Code erzeugte die App neu, nicht aber den Web-Container, und Prod antwortete mit 502, bis `luf-prod-web-1` neu gestartet wurde (20.11.2026). Ein Test (`tests/Unit/NginxConfigTest.php`) hält die Konfiguration fest.
|
||||||
|
|
||||||
|
## Stripe-Sandbox (nur Test, Etappe 1)
|
||||||
|
|
||||||
|
Die Stripe-Kasse läuft ausschließlich im Testmodus und nie in Produktion. Sie ist nur aktiv, wenn `PAYMENT_DRIVER=stripe` gesetzt ist; sonst bleibt es beim Testweg (`test`). Ein Schlüssel ohne `sk_test_` (oder `rk_test_`) wird abgewiesen, in Produktion lehnt die Anwendung Stripe ganz ab. Kartendaten berühren die Anwendung nie, bezahlt wird bei Stripe.
|
||||||
|
|
||||||
|
**Ablauf:** Bestellung anlegen, „Jetzt bezahlen (Stripe-Testmodus)“, Weiterleitung zur Stripe-Kasse. Freigeschaltet wird erst durch die signierte Meldung von Stripe an `POST /stripe/webhook` (Ereignis `checkout.session.completed`). Betrag und Währung werden gegen die Bestellung geprüft; wiederholte Meldungen schalten nichts doppelt frei. Eine Zahlung mit falschem Betrag oder auf eine nicht mehr offene Bestellung schaltet nichts frei und steht als Zahlung mit Status `zu_pruefen` in der Bestellung.
|
||||||
|
|
||||||
|
**Einrichten (Test):**
|
||||||
|
|
||||||
|
1. In Stripe den Testmodus („Sandbox“) wählen. Unter Entwickler > API-Schlüssel den Geheimschlüssel `sk_test_…` kopieren.
|
||||||
|
2. Unter Entwickler > Webhooks einen Endpunkt anlegen: URL `https://dev.laraundfelix.de/stripe/webhook`, Ereignisse `checkout.session.completed`, `checkout.session.expired`, `checkout.session.async_payment_succeeded`, `checkout.session.async_payment_failed`. Das Signiergeheimnis `whsec_…` des Endpunkts kopieren.
|
||||||
|
3. Auf llm-node in `/etc/luf/test.env` eintragen (Rechte `640`, nichts davon ins Repo, in Commits, Logs oder Chat):
|
||||||
|
|
||||||
|
```
|
||||||
|
PAYMENT_DRIVER=stripe
|
||||||
|
STRIPE_SECRET=sk_test_...
|
||||||
|
STRIPE_WEBHOOK_SECRET=whsec_...
|
||||||
|
```
|
||||||
|
|
||||||
|
4. In Gitea den letzten Lauf von „Deploy Test“ erneut starten (siehe „Env-Datei ändern“). `docker exec luf-test-app-1 printenv PAYMENT_DRIVER` muss `stripe` zeigen.
|
||||||
|
5. Testkauf mit der Stripe-Testkarte `4242 4242 4242 4242` (beliebiges künftiges Ablaufdatum, beliebige Prüfziffer). In Stripe unter Entwickler > Webhooks > Endpunkt > Ereignisse ist jede Zustellung samt Antwortcode zu sehen.
|
||||||
|
|
||||||
|
**Zurück zum Testweg:** `PAYMENT_DRIVER=test` setzen und neu ausrollen. Offene Stripe-Bestellungen bleiben offen.
|
||||||
|
|
||||||
|
**Grenzen:** Erstattungen laufen nicht über Stripe. Die Schaltfläche „Widerrufen“ ist im Stripe-Modus ausgeblendet; die Rückzahlung gehört zum Verkaufsstart (Live-Stripe, Belegprozess, Rückabwicklung). Steuer, Rechnung, Rabattcodes und Rechtstexte sind nicht Teil der Sandbox.
|
||||||
## Trennung Test und Prod (beide auf llm-node)
|
## Trennung Test und Prod (beide auf llm-node)
|
||||||
|
|
||||||
| | Test | Prod |
|
| | Test | Prod |
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
# Release-Vorbereitung develop → main (21.11.2026)
|
||||||
|
|
||||||
|
Vorbereitet von Claude. **Den Merge nach `main` löst Lars in Gitea aus** (Pull Request `develop` → `main`, nach Prüfung des Teststands). Claude merged, pusht und deployt nicht nach `main`. Ein Merge löst über `deploy-prod.yml` sofort das Produktiv-Deployment aus.
|
||||||
|
|
||||||
|
Stand: `develop` mit der Programm- und Modulkarte (Commit `3825f53` plus die Dokumentation dieser Übergabe), `main` auf `759b3e1` (PR #2).
|
||||||
|
|
||||||
|
## 1. Inhalt (Stand 21.11.2026 abends: 22 Commits seit `main`)
|
||||||
|
|
||||||
|
| Bereich | Inhalt | Von |
|
||||||
|
|---|---|---|
|
||||||
|
| Medien- und Materialkarte | Text der Karte wählen (Teaser, Kurzbeschreibung, Ausführliche Beschreibung); Bild aus dem Film (Regler mit Live-Bild, Vorschaubild übernehmen) | Claude |
|
||||||
|
| Programm- und Modulkarte | Text der Karte wählen (zusätzlich Lernziel); Vorschaubild als Website-Bild übernehmen | Claude |
|
||||||
|
| Trailer auf Karten | Medien-, Programm- und Modulkarte spielen den für die Website freigegebenen Trailer (Rolle Trailer, sonst Vorschauclip, bei Filmen ersatzweise der eigene Teaser) stumm beim Überfahren mit der Maus oder per Tipp ab; je Karte abschaltbar; die Medienroute beantwortet Bereichsabrufe (ADR-43). Auf luf-test mit einem echten Clip geprüft. Keine Migration | Claude |
|
||||||
|
| Medienkarte: Film nur mit Website-Datei | Ein Medium ohne Fassung (z. B. Teaser) ist auf der Medienkarte wählbar und erscheint öffentlich, sobald die Datei für die Website freigegeben ist (ohne Programmseite, ohne Aktion). Keine Migration | Claude |
|
||||||
|
| Hero mit Video | Der Einstieg (Variante Foto mit Textfläche) spielt auf Wunsch ein freigegebenes Video stumm auf der Fläche des Fotos ab, mit Schaltfläche zum Anhalten; Foto als Rückfall (ADR-43 Nachtrag). Keine Migration | Claude |
|
||||||
|
| Website-Datei eines Films | Ablage der Datei eines eigenständigen Präsentationsmediums über die Warteschlange, nachträgliches Hochladen am Medium (Behebung: der Web-Prozess darf `derived/` nicht schreiben) | Lars (anderer Rechner) |
|
||||||
|
| Medienmanager | „Medium löschen“ erreicht Standbilder und übernommene CMS-Bilder (Fremdschlüssel gelockert) | Claude |
|
||||||
|
| Fachliche Säulen | Vereinheitlichung auf die zentrale Säulenverwaltung | Lars (anderer Rechner) |
|
||||||
|
| Shop | Shop-Verwaltung, Warenkorb, Artikel/Paket/Angebot mit Voraussetzungen, Mehrpositionen-Kasse, Organisationskäufe | Lars (anderer Rechner) |
|
||||||
|
| Dokumentation | Anforderungen FACH-56 bis FACH-59, Brand-UI-Kit 1.2 bis 1.7 ohne Originalmotive, Berichte | beide |
|
||||||
|
|
||||||
|
Der Shop-Teil ist umfangreich (neue Tabellen, Routen, Kasse, Tests). Ich habe ihn nicht inhaltlich geprüft; die Abnahme steht in `docs/ux/verwaltung/abnahme/`.
|
||||||
|
|
||||||
|
**Fakten zum Shop nach dem Merge (aus dem Code geprüft):**
|
||||||
|
- **In Produktion nicht erreichbar.** `/shop`, `/warenkorb…` und `/kasse` liegen hinter `EnsureShopEnabled`; `Shop::enabled()` ist nur wahr, wenn die Umgebung **nicht** Produktion ist und der Zahlungstreiber `test` gilt („Etappe 1 erteilt keine Produktivfreigabe“). Prod läuft als `APP_ENV=production` (lesend bestätigt): Alle Shop-Adressen antworten dort mit 404, der Kopflink erscheint nicht.
|
||||||
|
- **Keine neuen Umgebungsschlüssel.** Gegenüber `main` gibt es keinen neuen `env()`-Zugriff, `.env.example`, `docker-compose.yml` und `scripts/deploy.sh` sind unverändert. `/etc/luf/prod.env` braucht nichts Neues (die Datei selbst habe ich nicht geöffnet). Die bisherigen Werte `LUF_CART_ENABLED` und `LUF_CART_URL` werden nicht mehr gelesen.
|
||||||
|
- **Folge:** Der Shop schadet in Prod nicht, ist aber auch nicht nutzbar. Er wird dort erst mit einer späteren Produktivfreigabe aktiv.
|
||||||
|
- **Entscheidung für Lars:** Mit diesem Merge nach Prod, oder die Shop-Commits erst später? (Eine Trennung wäre nur über einen eigenen Branch ohne die Shop-Commits möglich.)
|
||||||
|
|
||||||
|
## 2. Teststand
|
||||||
|
|
||||||
|
- Testsuite lokal: 459 grün, Pint sauber. Gate in Gitea (`ci-feature`, `develop`): CI 4987 und Deploy 4988 grün für den Stand der Karten.
|
||||||
|
- Die neuen Karten und Bildwähler sind in einem echten Browser gegen die Testinstanz (`luf-test`) im regulären Seitenkonfigurator geprüft (Berichte `docs/analysen/medienkarte-text-und-filmbild-bericht-2026-11-21.md` und `karten-text-und-bild-programm-bericht-2026-11-21.md`).
|
||||||
|
- Nicht gezeigt: die öffentliche Darstellung der neuen Karten auf einer veröffentlichten Seite der Testinstanz (nur Entwurf); die öffentlichen Regeln belegen die Feature-Tests.
|
||||||
|
|
||||||
|
## 3. Migrationen (Prod steht bei der 32. Migration `2026_11_20_200000_editorial_master_data_management`)
|
||||||
|
|
||||||
|
| Migration | Wirkung | Rückwärtskompatibel |
|
||||||
|
|---|---|---|
|
||||||
|
| `2026_11_21_100000_unify_pillar_assignments` | neue Tabellen `composition_pillar`, `license_article_pillar`, Anpassung `editorial_dimension_values` | ja, additiv |
|
||||||
|
| `2026_11_21_120000_create_film_still_sources` | neue Tabelle | ja |
|
||||||
|
| `2026_11_21_130000_add_shop_foundation` | Spalten an `offers`, `orders`, `order_lines`, `acquisitions`, neue Tabelle `memberships`, Rückrechnung bestehender Bestellungen | additiv; Daten werden berechnet, nicht gelöscht |
|
||||||
|
| `2026_11_21_130000_allow_deleting_media_with_stills_and_aliases` | lockert zwei Fremdschlüssel (`film_still_sources`, `website_media_aliases`) | ja, lockert nur |
|
||||||
|
| `2026_11_21_140000_create_composition_still_sources` | neue Tabelle | ja |
|
||||||
|
|
||||||
|
Keine bestehende Migration wurde geändert. Verglichen mit der Migrationstabelle von Prod (lesend): Prod hat 32 angewendet, `develop` 37 Dateien, **genau diese fünf sind ausstehend**, nichts auf Prod fehlt in `develop`. Prod hat 0 Bestellungen; die Rückrechnung in `add_shop_foundation` hat dort nichts zu tun. Der Rollback des Deploy-Skripts setzt nur den Code zurück, nicht die Datenbank; die neuen Tabellen und gelockerten Schlüssel stören älteren Code nicht.
|
||||||
|
|
||||||
|
## 4. Stand von Prod (lesend geprüft, 21.11.2026)
|
||||||
|
|
||||||
|
- 8 Seiten, alle veröffentlicht; 2 Medien (1 Bild, 1 Film), 1 davon für die Website freigegeben; **keine fachlichen Säulen** (Themenkarte hat dort noch nichts zur Auswahl); keine früheren CMS-Bilder unter `cms/` (die Bildübernahme früherer Bilder ist dort ohne Wirkung).
|
||||||
|
- Alle Container laufen; der Queue-Container startet planmäßig stündlich neu.
|
||||||
|
- Voraussetzungen für Bilder aus dem Film: `ffmpeg` ist im Image (`Dockerfile`); Warteschlange schreibt `public/derived/originals` (wie bisher).
|
||||||
|
|
||||||
|
## 5. Was Lars nach dem Deploy für die Pflege der Webseite wissen sollte
|
||||||
|
|
||||||
|
- Themenkarte: erst Säulen anlegen und veröffentlichen (mit Adresse und „Text für die Website“), sonst bleibt sie leer.
|
||||||
|
- Medienkarte und Programm-/Modulkarte erscheinen öffentlich nur, wenn das Medium bzw. Programm die Freigaberegeln erfüllt (Medium im öffentlichen Programm, Programm mit Anzeigefreigabe; Module nie).
|
||||||
|
- **Ausführliche Beschreibung** wird öffentlich, sobald sie als Kartentext gewählt wird. Trainermaterialien vorher als „Traineranleitung“ einordnen (die erscheinen nie öffentlich).
|
||||||
|
- Ein Bild aus einem Film oder aus dem Vorschaubild eines Programms entsteht als eigenes Bild im Medienmanager und wird nach der Verarbeitung automatisch für die Website freigegeben; die Freigabe lässt sich im Medienmanager (Reiter „Website“) zurücknehmen.
|
||||||
|
|
||||||
|
## 6. Ablauf (nur Lars)
|
||||||
|
|
||||||
|
1. Teststand und Shop-Entscheidung prüfen.
|
||||||
|
2. Pull Request `develop` → `main` in Gitea anlegen und nach Prüfung zusammenführen.
|
||||||
|
3. Der Workflow `deploy-prod.yml` testet und deployt; den Verlauf in Gitea beobachten.
|
||||||
|
4. Nach dem Deploy: Prod-Seiten und die neuen Karten ansehen (`/`, eine Seite mit Karte).
|
||||||
|
|
||||||
|
## 7. Hinweis zum Trailer nach dem Deploy
|
||||||
|
|
||||||
|
In Prod gibt es noch keinen Trailer. Ablauf für die Pflege: Medium anlegen (Film, „Eigenständiges Präsentationsmedium“, MP4 H.264 oder WebM) → im Reiter „Website“ freigeben → am Film, Programm oder Modul unter „Präsentationsmedien“ als Trailer zuordnen → „Redaktion speichern“. Bis ein Trailer freigegeben ist, ändert sich auf keiner Karte etwas.
|
||||||
@@ -48,6 +48,52 @@ .lf-hero__photo {
|
|||||||
border-radius: inherit;
|
border-radius: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Video auf der Fläche des Fotos (nur photo_split, resources/js/hero-video.js). Das Foto bleibt darunter sichtbar, bis
|
||||||
|
* das erste Videobild da ist; ohne JavaScript, bei Fehlern und ohne freigegebenen Clip bleibt es beim Foto.
|
||||||
|
*/
|
||||||
|
.lf-hero__video {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
z-index: -2;
|
||||||
|
inline-size: 100%;
|
||||||
|
block-size: 100%;
|
||||||
|
max-inline-size: none;
|
||||||
|
object-fit: cover;
|
||||||
|
object-position: var(--lf-hero-focus-x) var(--lf-hero-focus-y);
|
||||||
|
border-radius: inherit;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.4s ease;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lf-hero.is-hero-started .lf-hero__video { opacity: 1; }
|
||||||
|
|
||||||
|
.lf-hero__video-toggle {
|
||||||
|
position: absolute;
|
||||||
|
inset: 12px 12px auto auto;
|
||||||
|
z-index: 2;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
min-block-size: 44px;
|
||||||
|
padding: 8px 14px 8px 10px;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 999px;
|
||||||
|
color: #fff;
|
||||||
|
background: rgb(3 37 81 / 86%);
|
||||||
|
font: 600 0.8125rem/1.2 var(--lf-font-ui, system-ui, sans-serif);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lf-hero__video-toggle[hidden] { display: none; }
|
||||||
|
.lf-hero__video-toggle:hover { background: var(--lf-navy-deep, var(--lf-hero-navy)); }
|
||||||
|
.lf-hero__video-toggle:focus-visible { outline: 3px solid var(--lf-hero-yellow); outline-offset: 3px; }
|
||||||
|
.lf-hero__video-icon { inline-size: 20px; block-size: 20px; }
|
||||||
|
.lf-hero__video-pause,
|
||||||
|
.lf-hero__video-toggle[aria-pressed="true"] .lf-hero__video-play { display: none; }
|
||||||
|
.lf-hero__video-toggle[aria-pressed="true"] .lf-hero__video-pause { display: inline; }
|
||||||
|
|
||||||
.lf-hero--photo-split::before {
|
.lf-hero--photo-split::before {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -189,6 +235,7 @@ @container lf-hero (max-width: 859.99px) {
|
|||||||
.lf-hero--height-normal,
|
.lf-hero--height-normal,
|
||||||
.lf-hero--height-large { min-block-size: 0; }
|
.lf-hero--height-large { min-block-size: 0; }
|
||||||
.lf-hero__photo { position: relative; display: block; block-size: auto; aspect-ratio: 16 / 9; }
|
.lf-hero__photo { position: relative; display: block; block-size: auto; aspect-ratio: 16 / 9; }
|
||||||
|
.lf-hero__video { inset: 0 0 auto 0; block-size: auto; aspect-ratio: 16 / 9; border-radius: inherit; }
|
||||||
.lf-hero--photo-split::before { display: none; }
|
.lf-hero--photo-split::before { display: none; }
|
||||||
.lf-hero__inner { padding: clamp(1.2rem, 3.5cqi, 2rem); padding-block-end: 2.4rem; }
|
.lf-hero__inner { padding: clamp(1.2rem, 3.5cqi, 2rem); padding-block-end: 2.4rem; }
|
||||||
.lf-hero__copy { max-inline-size: 100%; }
|
.lf-hero__copy { max-inline-size: 100%; }
|
||||||
@@ -204,6 +251,7 @@ @container lf-hero (max-width: 440px) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (prefers-reduced-motion: reduce) {
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.lf-hero__video { transition: none; }
|
||||||
.lf-hero__button { transition: none; }
|
.lf-hero__button { transition: none; }
|
||||||
.lf-hero__button:hover { transform: none; }
|
.lf-hero__button:hover { transform: none; }
|
||||||
}
|
}
|
||||||
@@ -120,6 +120,7 @@ .lf-pc .lf-pc__title {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.lf-pc__summary {
|
.lf-pc__summary {
|
||||||
|
white-space: pre-line;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
color: var(--color-text-muted);
|
color: var(--color-text-muted);
|
||||||
}
|
}
|
||||||
@@ -228,7 +229,7 @@ .lf-pc__panel-accent {
|
|||||||
color: var(--pc-accent);
|
color: var(--pc-accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Film ohne freigegebenes Bild: Filmtafel (Navy, Filmstreifen-Symbol, kein Abspielsymbol – die Karte spielt nichts ab). */
|
/* Film ohne freigegebenes Bild: Filmtafel (Navy, Filmstreifen-Symbol, der Clip, falls freigegeben, liegt über dem Bildbereich). */
|
||||||
.lf-pc__panel-icon {
|
.lf-pc__panel-icon {
|
||||||
display: block;
|
display: block;
|
||||||
inline-size: 44px;
|
inline-size: 44px;
|
||||||
@@ -339,3 +340,93 @@ @container slot (min-width: 520px) {
|
|||||||
@media (prefers-reduced-motion: reduce) {
|
@media (prefers-reduced-motion: reduce) {
|
||||||
.lf-pc__cta { transition: none; }
|
.lf-pc__cta { transition: none; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Trailer (CardClip, resources/js/card-clip.js): Der Clip liegt über dem Bildbereich und blendet erst mit dem ersten
|
||||||
|
* Bild ein; bis dahin und danach bleibt das Kartenbild stehen. Ohne JavaScript erscheint die Schaltfläche nicht.
|
||||||
|
* Bei einem Film ohne Kartenbild liegt der Clip über der Filmtafel (lf-pc__visual--panel).
|
||||||
|
*/
|
||||||
|
.lf-pc__visual--panel {
|
||||||
|
display: flex;
|
||||||
|
align-self: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lf-pc .lf-pc__visual--panel > .lf-pc__panel {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-inline-size: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lf-pc__clip {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
inline-size: 100%;
|
||||||
|
block-size: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
object-position: var(--pc-focus-x, 66%) var(--pc-focus-y, 45%);
|
||||||
|
border-radius: var(--radius-card);
|
||||||
|
background: var(--lf-navy);
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
transition: opacity 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lf-pc--contain .lf-pc__clip {
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-clip-playing > .lf-pc__clip {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lf-pc__clip-toggle {
|
||||||
|
position: absolute;
|
||||||
|
inset: 12px 12px auto auto;
|
||||||
|
display: none;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
min-block-size: 44px;
|
||||||
|
padding: 8px 14px 8px 10px;
|
||||||
|
border: 0;
|
||||||
|
border-radius: var(--radius-pill);
|
||||||
|
color: var(--lf-white);
|
||||||
|
background: rgb(3 37 81 / 86%);
|
||||||
|
font: 600 0.8125rem/1.2 var(--font-reading);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-clip-ready > .lf-pc__clip-toggle {
|
||||||
|
display: inline-flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lf-pc__clip-toggle:hover {
|
||||||
|
background: var(--lf-navy-deep, var(--lf-navy));
|
||||||
|
}
|
||||||
|
|
||||||
|
.lf-pc__clip-toggle:focus-visible {
|
||||||
|
outline: 3px solid var(--color-focus);
|
||||||
|
outline-offset: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lf-pc__clip-icon {
|
||||||
|
inline-size: 20px;
|
||||||
|
block-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lf-pc__clip-pause,
|
||||||
|
.lf-pc__clip-toggle[aria-pressed="true"] .lf-pc__clip-play {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lf-pc__clip-toggle[aria-pressed="true"] .lf-pc__clip-pause {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.is-clip-playing > .lf-pc__badge {
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.lf-pc__clip { transition: none; }
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
import Hls from 'hls.js';
|
import Hls from 'hls.js';
|
||||||
import './site-nav.js';
|
import './site-nav.js';
|
||||||
|
import './card-clip.js';
|
||||||
|
import './hero-video.js';
|
||||||
|
|
||||||
function attachPlayback(video) {
|
function attachPlayback(video) {
|
||||||
if (!(video instanceof HTMLVideoElement) || video.dataset.playbackReady === '1') {
|
if (!(video instanceof HTMLVideoElement) || video.dataset.playbackReady === '1') {
|
||||||
|
|||||||
@@ -0,0 +1,180 @@
|
|||||||
|
/*
|
||||||
|
* Trailer auf Premium-Karten (Medien-, Programm- und Modulkarte).
|
||||||
|
*
|
||||||
|
* Eine Karte mit [data-card-clip] trägt einen für die Website freigegebenen Clip (data-clip-src). Der Clip
|
||||||
|
* - startet beim Überfahren mit der Maus und endet beim Verlassen (nur Zeigergeräte mit Maus),
|
||||||
|
* - startet am Handy und auf Wunsch auch am Desktop mit der Schaltfläche oder einem Tipp auf das Bild und endet mit dem nächsten,
|
||||||
|
* - läuft stumm; solange er nicht spielt, bleibt das Kartenbild sichtbar (der Clip blendet erst mit dem ersten Bild ein),
|
||||||
|
* - spielt bei „reduzierte Bewegung“ und im Datensparmodus nie von selbst, sondern nur auf ausdrückliche Bedienung, dann ohne Schleife,
|
||||||
|
* - wird erst beim ersten Start geladen (preload="none", Quelle erst dann gesetzt),
|
||||||
|
* - hält an, sobald die Karte aus dem Bild scrollt, und es spielt immer nur ein Clip zugleich.
|
||||||
|
* Ohne JavaScript bleibt es beim Kartenbild; die Schaltfläche erscheint erst, wenn dieses Skript sie freigibt.
|
||||||
|
*/
|
||||||
|
const REDUCED = window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : { matches: false };
|
||||||
|
|
||||||
|
let active = null;
|
||||||
|
|
||||||
|
function saveData() {
|
||||||
|
return Boolean(navigator.connection && navigator.connection.saveData);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup(card) {
|
||||||
|
if (card.dataset.clipReady === '1') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const video = card.querySelector('video.lf-pc__clip');
|
||||||
|
const toggle = card.querySelector('[data-clip-toggle]');
|
||||||
|
const source = card.dataset.clipSrc;
|
||||||
|
|
||||||
|
if (!(video instanceof HTMLVideoElement) || !toggle || !source) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
card.dataset.clipReady = '1';
|
||||||
|
|
||||||
|
const title = card.dataset.clipTitle || '';
|
||||||
|
const host = card.closest('.lf-pc') || card;
|
||||||
|
let mode = 'off'; // off | hover | manual
|
||||||
|
let failed = false;
|
||||||
|
|
||||||
|
function label(playing) {
|
||||||
|
toggle.setAttribute('aria-pressed', playing ? 'true' : 'false');
|
||||||
|
toggle.setAttribute('aria-label', (playing ? 'Trailer anhalten: ' : 'Trailer abspielen: ') + title);
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop() {
|
||||||
|
mode = 'off';
|
||||||
|
card.classList.remove('is-clip-playing');
|
||||||
|
video.pause();
|
||||||
|
|
||||||
|
try {
|
||||||
|
video.currentTime = 0;
|
||||||
|
} catch (error) {
|
||||||
|
// Noch keine Daten geladen: nichts zurückzusetzen.
|
||||||
|
}
|
||||||
|
|
||||||
|
label(false);
|
||||||
|
|
||||||
|
if (active === stop) {
|
||||||
|
active = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function start(nextMode) {
|
||||||
|
if (failed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (active && active !== stop) {
|
||||||
|
active();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!video.getAttribute('src')) {
|
||||||
|
video.src = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
video.muted = true;
|
||||||
|
video.loop = !REDUCED.matches;
|
||||||
|
mode = nextMode;
|
||||||
|
active = stop;
|
||||||
|
label(true);
|
||||||
|
|
||||||
|
const attempt = video.play();
|
||||||
|
|
||||||
|
if (attempt && typeof attempt.catch === 'function') {
|
||||||
|
attempt.catch(() => {
|
||||||
|
if (mode === nextMode) {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
video.addEventListener('playing', () => {
|
||||||
|
if (mode !== 'off') {
|
||||||
|
card.classList.add('is-clip-playing');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
video.addEventListener('ended', stop);
|
||||||
|
|
||||||
|
video.addEventListener('error', () => {
|
||||||
|
failed = true;
|
||||||
|
stop();
|
||||||
|
card.classList.add('is-clip-failed');
|
||||||
|
toggle.hidden = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
toggle.addEventListener('click', (event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
if (mode === 'off') {
|
||||||
|
start('manual');
|
||||||
|
} else {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Tipp auf das Bild (Handy): wie die Schaltfläche.
|
||||||
|
card.addEventListener('click', (event) => {
|
||||||
|
if (event.target.closest('a, button')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mode === 'off') {
|
||||||
|
start('manual');
|
||||||
|
} else {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
host.addEventListener('pointerenter', (event) => {
|
||||||
|
if (event.pointerType !== 'mouse' || REDUCED.matches || saveData() || mode !== 'off') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
start('hover');
|
||||||
|
});
|
||||||
|
|
||||||
|
host.addEventListener('pointerleave', (event) => {
|
||||||
|
if (event.pointerType === 'mouse' && mode === 'hover') {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if ('IntersectionObserver' in window) {
|
||||||
|
new IntersectionObserver((entries) => {
|
||||||
|
entries.forEach((entry) => {
|
||||||
|
if (!entry.isIntersecting && mode !== 'off') {
|
||||||
|
stop();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, { threshold: 0.2 }).observe(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
label(false);
|
||||||
|
card.classList.add('is-clip-ready');
|
||||||
|
}
|
||||||
|
|
||||||
|
function scan(root) {
|
||||||
|
if (root instanceof Element) {
|
||||||
|
if (root.matches('[data-card-clip]')) {
|
||||||
|
setup(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
root.querySelectorAll('[data-card-clip]').forEach(setup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scan(document.documentElement);
|
||||||
|
|
||||||
|
new MutationObserver((records) => {
|
||||||
|
records.forEach((record) => record.addedNodes.forEach(scan));
|
||||||
|
}).observe(document.documentElement, { childList: true, subtree: true });
|
||||||
|
|
||||||
|
document.addEventListener('visibilitychange', () => {
|
||||||
|
if (document.hidden && active) {
|
||||||
|
active();
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -0,0 +1,203 @@
|
|||||||
|
/*
|
||||||
|
* Video im Einstieg (Hero, Variante „Foto mit Textfläche“).
|
||||||
|
*
|
||||||
|
* Ein Einstieg mit [data-hero-video] trägt einen für die Website freigegebenen Clip (data-clip-src). Der Clip
|
||||||
|
* - startet stumm von selbst, sobald die Seite geladen ist (die Quelle wird erst dann gesetzt, preload="none"),
|
||||||
|
* - lässt das Foto stehen, bis das erste Videobild da ist (Klasse is-hero-started), und fällt bei Fehlern auf das Foto zurück,
|
||||||
|
* - startet bei „reduzierte Bewegung“, im Datensparmodus und bei sehr langsamer Verbindung nie von selbst, sondern nur
|
||||||
|
* auf ausdrückliche Bedienung, dann ohne Schleife,
|
||||||
|
* - hat immer eine Schaltfläche zum Anhalten und Abspielen (WCAG 2.2.2),
|
||||||
|
* - hält an, sobald der Einstieg aus dem Bild scrollt oder der Tab verborgen ist, und läuft danach nur weiter, wenn
|
||||||
|
* er von selbst lief und nicht angehalten wurde.
|
||||||
|
* Ohne JavaScript bleibt es beim Foto; die Schaltfläche erscheint erst, wenn dieses Skript sie freigibt.
|
||||||
|
*/
|
||||||
|
const REDUCED = window.matchMedia ? window.matchMedia('(prefers-reduced-motion: reduce)') : { matches: false };
|
||||||
|
|
||||||
|
function connection() {
|
||||||
|
return navigator.connection || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function mayAutoplay() {
|
||||||
|
const link = connection();
|
||||||
|
|
||||||
|
if (REDUCED.matches) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (link && (link.saveData || /(^|-)2g$/.test(String(link.effectiveType || '')))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function whenLoaded(callback) {
|
||||||
|
const run = () => {
|
||||||
|
if ('requestIdleCallback' in window) {
|
||||||
|
window.requestIdleCallback(callback, { timeout: 2500 });
|
||||||
|
} else {
|
||||||
|
window.setTimeout(callback, 200);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (document.readyState === 'complete') {
|
||||||
|
run();
|
||||||
|
} else {
|
||||||
|
window.addEventListener('load', run, { once: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setup(hero) {
|
||||||
|
if (hero.dataset.heroVideoReady === '1') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const video = hero.querySelector('video.lf-hero__video');
|
||||||
|
const toggle = hero.querySelector('[data-hero-toggle]');
|
||||||
|
const source = hero.dataset.clipSrc;
|
||||||
|
|
||||||
|
if (!(video instanceof HTMLVideoElement) || !toggle || !source) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hero.dataset.heroVideoReady = '1';
|
||||||
|
|
||||||
|
const title = hero.dataset.clipTitle || '';
|
||||||
|
let playing = false;
|
||||||
|
let wantsPlay = false; // läuft (oder lief) nach Absicht der Besucherin oder des Besuchers bzw. von selbst
|
||||||
|
let failed = false;
|
||||||
|
let armed = mayAutoplay(); // darf noch von selbst starten (einmal, sobald geladen und im Bild)
|
||||||
|
let loaded = false;
|
||||||
|
|
||||||
|
function inView() {
|
||||||
|
const box = hero.getBoundingClientRect();
|
||||||
|
|
||||||
|
return box.bottom > 0 && box.top < window.innerHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
function label() {
|
||||||
|
toggle.setAttribute('aria-pressed', playing ? 'true' : 'false');
|
||||||
|
toggle.setAttribute('aria-label', (playing ? 'Video anhalten: ' : 'Video abspielen: ') + title);
|
||||||
|
}
|
||||||
|
|
||||||
|
function play(auto) {
|
||||||
|
if (failed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!video.getAttribute('src')) {
|
||||||
|
video.src = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
video.muted = true;
|
||||||
|
video.loop = !REDUCED.matches;
|
||||||
|
wantsPlay = true;
|
||||||
|
playing = true;
|
||||||
|
label();
|
||||||
|
|
||||||
|
const attempt = video.play();
|
||||||
|
|
||||||
|
if (attempt && typeof attempt.catch === 'function') {
|
||||||
|
attempt.catch(() => {
|
||||||
|
// Vom Browser nicht erlaubt: das Foto bleibt, die Schaltfläche bietet das Abspielen an.
|
||||||
|
playing = false;
|
||||||
|
wantsPlay = false;
|
||||||
|
label();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
hero.dataset.heroAuto = auto ? '1' : '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
function pause(byUser) {
|
||||||
|
playing = false;
|
||||||
|
|
||||||
|
if (byUser) {
|
||||||
|
wantsPlay = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
video.pause();
|
||||||
|
label();
|
||||||
|
}
|
||||||
|
|
||||||
|
video.addEventListener('playing', () => hero.classList.add('is-hero-started'));
|
||||||
|
|
||||||
|
video.addEventListener('ended', () => {
|
||||||
|
playing = false;
|
||||||
|
wantsPlay = false;
|
||||||
|
hero.classList.remove('is-hero-started');
|
||||||
|
label();
|
||||||
|
});
|
||||||
|
|
||||||
|
video.addEventListener('error', () => {
|
||||||
|
failed = true;
|
||||||
|
playing = false;
|
||||||
|
hero.classList.remove('is-hero-started');
|
||||||
|
hero.classList.add('is-hero-failed');
|
||||||
|
toggle.hidden = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
toggle.addEventListener('click', () => {
|
||||||
|
if (playing) {
|
||||||
|
pause(true);
|
||||||
|
} else {
|
||||||
|
play(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if ('IntersectionObserver' in window) {
|
||||||
|
new IntersectionObserver((entries) => {
|
||||||
|
entries.forEach((entry) => {
|
||||||
|
if (entry.isIntersecting) {
|
||||||
|
if (armed && loaded && !wantsPlay && !document.hidden) {
|
||||||
|
armed = false;
|
||||||
|
play(true);
|
||||||
|
} else if (wantsPlay && !playing && !document.hidden) {
|
||||||
|
play(hero.dataset.heroAuto === '1');
|
||||||
|
}
|
||||||
|
} else if (playing) {
|
||||||
|
pause(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, { threshold: 0.15 }).observe(hero);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('visibilitychange', () => {
|
||||||
|
if (document.hidden && playing) {
|
||||||
|
pause(false);
|
||||||
|
} else if (!document.hidden && wantsPlay && !playing && inView()) {
|
||||||
|
play(hero.dataset.heroAuto === '1');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
label();
|
||||||
|
toggle.hidden = false;
|
||||||
|
hero.classList.add('is-hero-ready');
|
||||||
|
|
||||||
|
if (armed) {
|
||||||
|
whenLoaded(() => {
|
||||||
|
loaded = true;
|
||||||
|
|
||||||
|
if (armed && !failed && !wantsPlay && inView() && !document.hidden) {
|
||||||
|
armed = false;
|
||||||
|
play(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function scan(root) {
|
||||||
|
if (root instanceof Element) {
|
||||||
|
if (root.matches('[data-hero-video]')) {
|
||||||
|
setup(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
root.querySelectorAll('[data-hero-video]').forEach(setup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scan(document.documentElement);
|
||||||
|
|
||||||
|
new MutationObserver((records) => {
|
||||||
|
records.forEach((record) => record.addedNodes.forEach(scan));
|
||||||
|
}).observe(document.documentElement, { childList: true, subtree: true });
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
{{--
|
||||||
|
Medien- und Materialkarte, Reiter „Medien“: ein Bild aus dem Film als Kartenbild übernehmen.
|
||||||
|
Bedienung wie im Medienmanager: Regler und Zahlenfeld zeigen dieselbe Zeitposition, das Bild der Stelle folgt
|
||||||
|
dem Regler nach kurzer Pause (Route editorial.frame, nur angemeldete Redaktion). „Diese Stelle übernehmen“ legt genau
|
||||||
|
die angezeigte Stelle einmal als Bild-Medium im Medienmanager ab (FilmStill) und wählt es als Kartenbild.
|
||||||
|
Die Datei des Films bleibt geschützt; übernommen wird nur ein Einzelbild bis 1600 px Breite.
|
||||||
|
--}}
|
||||||
|
@php
|
||||||
|
$pfad = $getStatePath();
|
||||||
|
$ziel = preg_replace('/[^.]+$/', 'image', $pfad);
|
||||||
|
$framePfad = $filmVersionId !== null ? route('editorial.frame', ['version' => $filmVersionId]) : null;
|
||||||
|
@endphp
|
||||||
|
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
|
||||||
|
<div class="luf-filmbild"
|
||||||
|
x-data="{ second: @js((string) $filmStartSecond), shown: @js((string) $filmStartSecond), base: @js($framePfad), ziel: @js($ziel), id: {{ (int) $film->id }},
|
||||||
|
show() { if (this.second !== '' && ! isNaN(Number(this.second)) && Number(this.second) >= 0) { this.shown = this.second; } } }">
|
||||||
|
<p class="luf-filmbild-lead">
|
||||||
|
Aus dem Film „{{ $filmTitle }}“ ein Bild für die Website übernehmen. Das Bild wird einmal gespeichert und im
|
||||||
|
Medienmanager als Bild angelegt. Der Film selbst wird nicht veröffentlicht; die Karte spielt nichts ab.
|
||||||
|
</p>
|
||||||
|
@if ($framePfad !== null)
|
||||||
|
<div class="luf-filmbild-regler">
|
||||||
|
<label class="luf-filmbild-label" for="filmbild-stelle-{{ $film->id }}">Zeitposition in Sekunden</label>
|
||||||
|
<input id="filmbild-stelle-{{ $film->id }}" type="range" min="0" step="0.5"
|
||||||
|
:max="Math.max(120, Math.ceil(Number(second) || 0))" x-model="second" x-on:input.debounce.250ms="show()">
|
||||||
|
<input type="number" min="0" max="7200" step="0.1" class="luf-filmbild-second" aria-label="Zeitposition als Zahl"
|
||||||
|
x-model="second" x-on:input.debounce.250ms="show()">
|
||||||
|
</div>
|
||||||
|
<img class="luf-filmbild-bild" :src="base + '?sekunde=' + encodeURIComponent(shown)" alt="Vorschau der gewählten Filmstelle">
|
||||||
|
<div>
|
||||||
|
<x-filament::button color="primary" size="sm" icon="heroicon-o-check-circle" type="button" wire:loading.attr="disabled"
|
||||||
|
x-on:click="$wire.adoptFilmFrame(ziel, id, String(shown))">
|
||||||
|
Diese Stelle übernehmen
|
||||||
|
</x-filament::button>
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<p class="luf-filmbild-lead">Der Film hat noch keine bereitgestellte Fassung; eine Stelle lässt sich erst danach wählen.</p>
|
||||||
|
@endif
|
||||||
|
@if ($filmHasThumbnail)
|
||||||
|
<div class="luf-filmbild-aktuell">
|
||||||
|
@if ($filmThumbnailUrl)
|
||||||
|
<img src="{{ $filmThumbnailUrl }}" alt="Aktuelles Vorschaubild des Films">
|
||||||
|
@endif
|
||||||
|
<div>
|
||||||
|
<p class="luf-filmbild-lead">Oder das Vorschaubild übernehmen, das im Medienmanager für diesen Film gesetzt ist.</p>
|
||||||
|
<x-filament::button color="gray" size="sm" icon="heroicon-o-photo" type="button" wire:loading.attr="disabled"
|
||||||
|
wire:click="adoptFilmThumbnail({{ \Illuminate\Support\Js::from($ziel) }}, {{ (int) $film->id }})">
|
||||||
|
Vorschaubild des Films übernehmen
|
||||||
|
</x-filament::button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</x-dynamic-component>
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
{{--
|
||||||
|
Programm- und Modulkarte, Reiter „Medien“: das Vorschaubild des Programms oder Moduls als Kartenbild übernehmen.
|
||||||
|
Das Vorschaubild ist ein geschütztes Bibliotheksbild und erscheint öffentlich nie. „Vorschaubild übernehmen“ legt es
|
||||||
|
einmal als Bild-Medium im Medienmanager ab (CompositionStill) und wählt es als Kartenbild; die Website-Freigabe
|
||||||
|
geschieht dort nach der Verarbeitung automatisch und lässt sich zurücknehmen.
|
||||||
|
--}}
|
||||||
|
@php
|
||||||
|
$ziel = preg_replace('/[^.]+$/', 'image', $getStatePath());
|
||||||
|
@endphp
|
||||||
|
<x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
|
||||||
|
<div class="luf-filmbild">
|
||||||
|
@if ($compositionThumbnailUrl)
|
||||||
|
<div class="luf-filmbild-aktuell">
|
||||||
|
<img src="{{ $compositionThumbnailUrl }}" alt="Aktuelles Vorschaubild von „{{ $compositionTitle }}“">
|
||||||
|
<div>
|
||||||
|
<p class="luf-filmbild-lead">
|
||||||
|
Das Vorschaubild von „{{ $compositionTitle }}“ aus dem Redaktionsmanager als Bild für die Website
|
||||||
|
übernehmen. Es wird einmal gespeichert und im Medienmanager als Bild angelegt.
|
||||||
|
</p>
|
||||||
|
<x-filament::button color="gray" size="sm" icon="heroicon-o-photo" type="button" wire:loading.attr="disabled"
|
||||||
|
wire:click="adoptCompositionThumbnail({{ \Illuminate\Support\Js::from($ziel) }}, {{ (int) $composition->id }})">
|
||||||
|
Vorschaubild übernehmen
|
||||||
|
</x-filament::button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<p class="luf-filmbild-lead">
|
||||||
|
„{{ $compositionTitle }}“ hat noch kein Vorschaubild. Es lässt sich im Redaktionsmanager setzen und danach hier übernehmen,
|
||||||
|
oder ein anderes Bild oben auswählen.
|
||||||
|
</p>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</x-dynamic-component>
|
||||||
@@ -86,6 +86,19 @@
|
|||||||
.luf-media-badge-warn { background: #fff1c7; color: #6b4b00; }
|
.luf-media-badge-warn { background: #fff1c7; color: #6b4b00; }
|
||||||
.luf-media-badge-wait { background: #e5eef8; color: #18456f; }
|
.luf-media-badge-wait { background: #e5eef8; color: #18456f; }
|
||||||
.luf-media-badge-quiet { background: #eceff1; color: #3e4c5c; }
|
.luf-media-badge-quiet { background: #eceff1; color: #3e4c5c; }
|
||||||
|
/* Medien- und Materialkarte: Bild aus dem Film übernehmen. */
|
||||||
|
.luf-filmbild { display: flex; flex-direction: column; gap: .75rem; padding: .75rem; border: 1px solid #d5ddd6; border-radius: .5rem; }
|
||||||
|
.luf-filmbild-lead { margin: 0; font-size: .875rem; }
|
||||||
|
.luf-filmbild-frame { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; }
|
||||||
|
.luf-filmbild-label { display: flex; flex-direction: column; gap: .25rem; font-size: .875rem; }
|
||||||
|
.luf-filmbild-second { width: 8rem; padding: .35rem .5rem; border: 1px solid #b9c4bd; border-radius: .375rem; }
|
||||||
|
.luf-filmbild-regler { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
|
||||||
|
.luf-filmbild-regler input[type=range] { flex: 1 1 14rem; min-width: 10rem; }
|
||||||
|
.luf-filmbild-bild { width: 100%; max-width: 28rem; height: auto; border-radius: .375rem; background: #eef1ee; }
|
||||||
|
.luf-filmbild-aktuell { display: flex; gap: .75rem; align-items: flex-start; padding-top: .5rem; border-top: 1px solid #e3e8e4; }
|
||||||
|
.luf-filmbild-aktuell img { width: 9rem; height: auto; border-radius: .375rem; background: #eef1ee; }
|
||||||
|
.luf-filmbild-preview { display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; width: 100%; }
|
||||||
|
.luf-filmbild-preview img { width: 100%; max-width: 28rem; height: auto; border-radius: .375rem; background: #eef1ee; }
|
||||||
.luf-media-status { display: flex; gap: 1rem; align-items: flex-start; padding: .75rem; border: 1px solid #d5ddd6; border-radius: .5rem; }
|
.luf-media-status { display: flex; gap: 1rem; align-items: flex-start; padding: .75rem; border: 1px solid #d5ddd6; border-radius: .5rem; }
|
||||||
.luf-media-status img { width: 10rem; height: auto; border-radius: .375rem; }
|
.luf-media-status img { width: 10rem; height: auto; border-radius: .375rem; }
|
||||||
.luf-media-status strong { display: block; }
|
.luf-media-status strong { display: block; }
|
||||||
|
|||||||
@@ -97,6 +97,7 @@
|
|||||||
@if ($fokus === 'inhalt')
|
@if ($fokus === 'inhalt')
|
||||||
@if ($versions->isEmpty())
|
@if ($versions->isEmpty())
|
||||||
{{-- Viele Medien sind reine Präsentationsmedien ohne Fassung: kein leerer Strukturbereich. --}}
|
{{-- Viele Medien sind reine Präsentationsmedien ohne Fassung: kein leerer Strukturbereich. --}}
|
||||||
|
@include('filament.media.website-datei')
|
||||||
<div class="vw vw-leer vw-leer-breit">
|
<div class="vw vw-leer vw-leer-breit">
|
||||||
<strong>Noch keine Inhaltsfassung</strong>
|
<strong>Noch keine Inhaltsfassung</strong>
|
||||||
<p>Dieses Medium wird ohne Fassung verwendet, zum Beispiel als Präsentationsbild auf Karten und Seiten. Eine Fassung brauchst du erst, wenn die Datei oder ein Lehrtext in Modulen und Programmen eingesetzt werden soll.</p>
|
<p>Dieses Medium wird ohne Fassung verwendet, zum Beispiel als Präsentationsbild auf Karten und Seiten. Eine Fassung brauchst du erst, wenn die Datei oder ein Lehrtext in Modulen und Programmen eingesetzt werden soll.</p>
|
||||||
@@ -247,7 +248,7 @@
|
|||||||
@if ($canRevise)
|
@if ($canRevise)
|
||||||
<aside class="vw-medien-seite" aria-labelledby="bildwahl-titel">
|
<aside class="vw-medien-seite" aria-labelledby="bildwahl-titel">
|
||||||
<h2 id="bildwahl-titel" class="vw-abschnitt-titel">Vorschaubild ändern</h2>
|
<h2 id="bildwahl-titel" class="vw-abschnitt-titel">Vorschaubild ändern</h2>
|
||||||
@php $ausFilm = $element->output_class === 'film' && $shown; @endphp
|
@php $ausWebsiteDatei = ! $shown && $this->hasWebsiteFilm(); $ausFilm = $element->output_class === 'film' && ($shown || $ausWebsiteDatei); @endphp
|
||||||
@if ($ausFilm)
|
@if ($ausFilm)
|
||||||
<div class="vw-segment" role="group" aria-label="Quelle des Vorschaubilds">
|
<div class="vw-segment" role="group" aria-label="Quelle des Vorschaubilds">
|
||||||
<button type="button" wire:click="$set('bildQuelle', 'film')" aria-pressed="{{ $this->bildQuelle === 'film' ? 'true' : 'false' }}">Stelle aus dem Film</button>
|
<button type="button" wire:click="$set('bildQuelle', 'film')" aria-pressed="{{ $this->bildQuelle === 'film' ? 'true' : 'false' }}">Stelle aus dem Film</button>
|
||||||
@@ -255,11 +256,11 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
@if ($ausFilm && $this->bildQuelle === 'film')
|
@if ($ausFilm && $this->bildQuelle === 'film')
|
||||||
<p class="vw-feld-hilfe">Aus Fassung {{ $shown->number }}. Die Vorschau nimmt die kleine Filmstufe, sofern sie vorliegt. Die Filmdatei bleibt unverändert.</p>
|
<p class="vw-feld-hilfe">@if ($shown)Aus Fassung {{ $shown->number }}. Die Vorschau nimmt die kleine Filmstufe, sofern sie vorliegt.@else Aus der Website-Datei dieses Mediums.@endif Die Filmdatei bleibt unverändert.</p>
|
||||||
{{-- Regler und Zahl zeigen immer denselben Wert; übernommen wird genau die angezeigte Stelle. --}}
|
{{-- Regler und Zahl zeigen immer denselben Wert; übernommen wird genau die angezeigte Stelle. --}}
|
||||||
@php
|
@php
|
||||||
// Ohne eigene Wahl beginnt der Regler bei der Stelle des aktuellen Vorschaubilds aus dieser Fassung.
|
// Ohne eigene Wahl beginnt der Regler bei der Stelle des aktuellen Vorschaubilds aus dieser Fassung.
|
||||||
$aktuelleStelle = preg_match('/^frame:'.$shown->id.'@([\d.]+)$/', (string) $element->thumbnail_source, $treffer) === 1 ? $treffer[1] : '0';
|
$aktuelleStelle = preg_match('/^frame:'.($shown?->id ?? 0).'@([\d.]+)$/', (string) $element->thumbnail_source, $treffer) === 1 ? $treffer[1] : '0';
|
||||||
@endphp
|
@endphp
|
||||||
<div x-data="{ second: {{ json_encode($this->frameSecond !== '' ? $this->frameSecond : $aktuelleStelle) }} }" style="display: grid; gap: 0.4rem;">
|
<div x-data="{ second: {{ json_encode($this->frameSecond !== '' ? $this->frameSecond : $aktuelleStelle) }} }" style="display: grid; gap: 0.4rem;">
|
||||||
<label class="vw-feldlabel" for="filmstelle">Zeitposition in Sekunden</label>
|
<label class="vw-feldlabel" for="filmstelle">Zeitposition in Sekunden</label>
|
||||||
@@ -340,6 +341,29 @@
|
|||||||
@if ($this->websiteFeedback !== '')
|
@if ($this->websiteFeedback !== '')
|
||||||
<p class="vw-meldung" role="status"><span>{{ $this->websiteFeedback }}</span></p>
|
<p class="vw-meldung" role="status"><span>{{ $this->websiteFeedback }}</span></p>
|
||||||
@endif
|
@endif
|
||||||
|
@if (in_array($element->output_class, ['film', 'audio'], true))
|
||||||
|
@php
|
||||||
|
$webDatei = filled($element->preview_path);
|
||||||
|
$webTypen = $element->output_class === 'audio' ? '.mp3,.m4a,.ogg' : '.mp4,.webm';
|
||||||
|
@endphp
|
||||||
|
@include('filament.media.website-datei')
|
||||||
|
<dl class="vw-angaben">
|
||||||
|
<dt>Website-Datei</dt>
|
||||||
|
<dd>{{ $webDatei ? 'Vorhanden (ungeschützte Datei für die Website)' : 'Noch keine. Ohne sie lässt sich nur eine bereitgestellte Fassung mit Teaser freigeben.' }}</dd>
|
||||||
|
</dl>
|
||||||
|
@if ($editable)
|
||||||
|
<div style="display: grid; gap: 0.4rem; max-width: 34rem;">
|
||||||
|
<label class="vw-feld-label" for="website-datei">{{ $webDatei ? 'Website-Datei ersetzen' : 'Website-Datei hochladen' }}</label>
|
||||||
|
<input id="website-datei" type="file" accept="{{ $webTypen }}" wire:model="websiteUpload">
|
||||||
|
<p class="vw-feld-hilfe">{{ $element->output_class === 'audio' ? 'MP3, M4A oder OGG.' : 'MP4 (H.264) oder WebM; andere Formate spielt der Browser nicht.' }} Die Datei ist nicht geschützt und läuft ohne Lizenz. Die geschützte Fassung bleibt unverändert.</p>
|
||||||
|
@if ($this->websiteUpload instanceof \Livewire\Features\SupportFileUploads\TemporaryUploadedFile)
|
||||||
|
<p class="vw-feld-hilfe">Ausgewählt, noch nicht übernommen: {{ $this->websiteUpload->getClientOriginalName() }}
|
||||||
|
<button type="button" class="vw-link is-quiet" wire:click="$set('websiteUpload', null)">Auswahl verwerfen</button></p>
|
||||||
|
@endif
|
||||||
|
<div><button type="button" class="vw-btn" wire:click="storeWebsiteFile">Website-Datei übernehmen</button></div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@endif
|
||||||
@if ($editable)
|
@if ($editable)
|
||||||
<div>
|
<div>
|
||||||
@if ($webOffen)
|
@if ($webOffen)
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
@php
|
||||||
|
/** Die Website-Datei eines Films oder Hörstücks: Ansicht für die Redaktion, öffentlich erst nach der Freigabe. */
|
||||||
|
$datei = in_array($element->output_class, ['film', 'audio'], true) && filled($element->preview_path);
|
||||||
|
$fehler = in_array($element->output_class, ['film', 'audio'], true) && ! $datei && filled($element->thumbnail_error) ? $element->thumbnail_error : null;
|
||||||
|
@endphp
|
||||||
|
@if ($datei)
|
||||||
|
<figure class="vw-website-datei" style="margin: 0; display: grid; gap: 0.4rem; max-width: 52rem;">
|
||||||
|
@if ($element->output_class === 'audio')
|
||||||
|
<audio controls preload="metadata" src="{{ route('content.website-file', $element) }}" style="width: 100%;">Dein Browser spielt diese Datei nicht ab.</audio>
|
||||||
|
@else
|
||||||
|
<video controls preload="metadata" playsinline src="{{ route('content.website-file', $element) }}" style="width: 100%; max-height: 28rem; background: #000;">Dein Browser spielt diese Datei nicht ab.</video>
|
||||||
|
@endif
|
||||||
|
<figcaption class="vw-feld-hilfe">Website-Datei, ungeschützt. Sie ist {{ $webOffen ? 'für die Website freigegeben' : 'noch nicht für die Website freigegeben' }}.</figcaption>
|
||||||
|
</figure>
|
||||||
|
@elseif ($fehler)
|
||||||
|
<p class="vw-meldung is-fehler" role="alert"><span>Die Website-Datei wurde nicht übernommen: {{ $fehler }}</span></p>
|
||||||
|
@endif
|
||||||
@@ -19,6 +19,11 @@
|
|||||||
<div class="errors" role="alert">{{ $errors->first() }}</div>
|
<div class="errors" role="alert">{{ $errors->first() }}</div>
|
||||||
@endif
|
@endif
|
||||||
<p class="state">Status: {{ $statusText }}</p>
|
<p class="state">Status: {{ $statusText }}</p>
|
||||||
|
@if ($order->status === 'offen' && $zahlung === 'zurueck')
|
||||||
|
<p class="state" role="status">Danke. Wir warten auf die Bestätigung von Stripe. Sobald sie da ist, steht die Bestellung auf „Bezahlt“. <a href="{{ route('member.order', $order) }}">Status neu laden</a></p>
|
||||||
|
@elseif ($order->status === 'offen' && $zahlung === 'abbruch')
|
||||||
|
<p class="state" role="status">Die Zahlung wurde abgebrochen. Es wurde nichts abgebucht. Du kannst erneut bezahlen.</p>
|
||||||
|
@endif
|
||||||
<dl class="facts">
|
<dl class="facts">
|
||||||
<div><dt>Lizenzinhaber</dt><dd>{{ $order->party?->display_name }}</dd></div>
|
<div><dt>Lizenzinhaber</dt><dd>{{ $order->party?->display_name }}</dd></div>
|
||||||
<div><dt>Bestellt von</dt><dd>{{ $order->user?->name }}</dd></div>
|
<div><dt>Bestellt von</dt><dd>{{ $order->user?->name }}</dd></div>
|
||||||
@@ -32,6 +37,12 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</ul>
|
</ul>
|
||||||
<p class="state">Summe: {{ \App\Domain\Commerce\Money::format($order->total_cents ?? $order->lines->sum('price_cents')) }}</p>
|
<p class="state">Summe: {{ \App\Domain\Commerce\Money::format($order->total_cents ?? $order->lines->sum('price_cents')) }}</p>
|
||||||
|
@if ($stripePayment && $order->status === 'offen')
|
||||||
|
<form method="post" action="{{ route('member.order.pay', $order) }}">
|
||||||
|
@csrf
|
||||||
|
<button class="button" type="submit">Jetzt bezahlen (Stripe-Testmodus)</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
@if ($testPayment && $order->status === 'offen')
|
@if ($testPayment && $order->status === 'offen')
|
||||||
<form method="post" action="{{ route('member.order.confirm', $order) }}">
|
<form method="post" action="{{ route('member.order.confirm', $order) }}">
|
||||||
@csrf
|
@csrf
|
||||||
@@ -44,9 +55,11 @@
|
|||||||
@endif
|
@endif
|
||||||
@if ($order->status === 'bezahlt')
|
@if ($order->status === 'bezahlt')
|
||||||
<p><a class="button" href="{{ route('member.library') }}">Zur Bibliothek</a></p>
|
<p><a class="button" href="{{ route('member.library') }}">Zur Bibliothek</a></p>
|
||||||
<form method="post" action="{{ route('member.order.refund', $order) }}">
|
@if (! $stripePayment)
|
||||||
@csrf
|
<form method="post" action="{{ route('member.order.refund', $order) }}">
|
||||||
<button class="button button-quiet" type="submit">Widerrufen</button>
|
@csrf
|
||||||
</form>
|
<button class="button button-quiet" type="submit">Widerrufen</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
@endsection
|
@endsection
|
||||||
@@ -3,19 +3,33 @@
|
|||||||
Varianten: photo_split (Foto mit heller Textfläche), editorial_solid (Navy-Markenfläche ohne Foto).
|
Varianten: photo_split (Foto mit heller Textfläche), editorial_solid (Navy-Markenfläche ohne Foto).
|
||||||
Höhen compact/normal/large sind Mindesthöhen ab 860 px Containerbreite; darunter Sicherheitsumbruch.
|
Höhen compact/normal/large sind Mindesthöhen ab 860 px Containerbreite; darunter Sicherheitsumbruch.
|
||||||
Das Bild des ersten Widgets der Seite wird sofort geladen, alle anderen verzögert.
|
Das Bild des ersten Widgets der Seite wird sofort geladen, alle anderen verzögert.
|
||||||
|
Video (nur photo_split): stummer, freigegebener Clip auf der Fläche des Fotos (HeroVideo). Das <video> bekommt seine
|
||||||
|
Quelle erst nach dem Laden der Seite (resources/js/hero-video.js, preload="none"); das Foto bleibt Rückfall.
|
||||||
|
Der Clip ist Beiwerk; Überschrift und Text stehen daneben, das Video ist für Hilfstechnik verborgen und die
|
||||||
|
Schaltfläche trägt die Bedeutung.
|
||||||
--}}
|
--}}
|
||||||
@php
|
@php
|
||||||
$layout = $variant === 'editorial_solid' ? 'editorial-solid' : 'photo-split';
|
$layout = $variant === 'editorial_solid' ? 'editorial-solid' : 'photo-split';
|
||||||
$heightClass = in_array($height, ['compact', 'normal', 'large'], true) ? $height : 'normal';
|
$heightClass = in_array($height, ['compact', 'normal', 'large'], true) ? $height : 'normal';
|
||||||
$tag = \App\Domain\Cms\Widgets\Support\PremiumFields::headingTag($settings, ! empty($first));
|
$tag = \App\Domain\Cms\Widgets\Support\PremiumFields::headingTag($settings, ! empty($first));
|
||||||
$loading = ! empty($first) ? 'loading="eager" fetchpriority="high"' : 'loading="lazy"';
|
$loading = ! empty($first) ? 'loading="eager" fetchpriority="high"' : 'loading="lazy"';
|
||||||
|
$videoUrl = $layout === 'photo-split' ? ($video['url'] ?? null) : null;
|
||||||
|
$videoTitle = $video['title'] ?? '';
|
||||||
@endphp
|
@endphp
|
||||||
<div class="lf-hero-host">
|
<div class="lf-hero-host">
|
||||||
<div class="lf-hero lf-hero--{{ $layout }} lf-hero--height-{{ $heightClass }} lf-hero--accent-{{ $accent }}"
|
<div class="lf-hero lf-hero--{{ $layout }} lf-hero--height-{{ $heightClass }} lf-hero--accent-{{ $accent }}"
|
||||||
style="--lf-hero-focus-x: {{ $focus['x'] }}%; --lf-hero-focus-y: {{ $focus['y'] }}%">
|
style="--lf-hero-focus-x: {{ $focus['x'] }}%; --lf-hero-focus-y: {{ $focus['y'] }}%"
|
||||||
|
@if ($videoUrl !== null) data-hero-video data-clip-src="{{ $videoUrl }}" data-clip-title="{{ $videoTitle }}" @endif>
|
||||||
@if ($layout === 'photo-split' && $imageUrl)
|
@if ($layout === 'photo-split' && $imageUrl)
|
||||||
<img class="lf-hero__photo" src="{{ $imageUrl }}" alt="{{ $imageAlt ?? '' }}" {!! $loading !!} decoding="async">
|
<img class="lf-hero__photo" src="{{ $imageUrl }}" alt="{{ $imageAlt ?? '' }}" {!! $loading !!} decoding="async">
|
||||||
@endif
|
@endif
|
||||||
|
@if ($videoUrl !== null)
|
||||||
|
<video class="lf-hero__video" muted loop playsinline preload="none" disablepictureinpicture disableremoteplayback tabindex="-1" aria-hidden="true"></video>
|
||||||
|
<button type="button" class="lf-hero__video-toggle" aria-pressed="false" data-hero-toggle aria-label="Video abspielen: {{ $videoTitle }}" hidden>
|
||||||
|
<svg class="lf-hero__video-icon" viewBox="0 0 24 24" focusable="false" aria-hidden="true"><path class="lf-hero__video-play" d="M8 5.5v13l11-6.5z" fill="currentColor"/><path class="lf-hero__video-pause" d="M7 5h4v14H7zM13 5h4v14h-4z" fill="currentColor"/></svg>
|
||||||
|
<span aria-hidden="true">Video</span>
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
<div class="lf-hero__inner">
|
<div class="lf-hero__inner">
|
||||||
<div class="lf-hero__copy">
|
<div class="lf-hero__copy">
|
||||||
@if ($accent === 'rays')
|
@if ($accent === 'rays')
|
||||||
@@ -44,3 +58,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@include('widgets.partials.image-notice')
|
@include('widgets.partials.image-notice')
|
||||||
|
@if ($context->preview && ! empty($video['notice']))
|
||||||
|
<p class="preview-note">{{ $video['notice'] }}</p>
|
||||||
|
@endif
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{{--
|
||||||
|
Trailer der Premium-Karte (CardClip): stummer Clip über dem Kartenbild plus Schaltfläche. Das <video> bekommt seine
|
||||||
|
Quelle erst beim ersten Start (resources/js/card-clip.js, preload="none"). Der Clip ist Beiwerk; Titel und Text der
|
||||||
|
Karte stehen daneben, deshalb ist das Video für Hilfstechnik verborgen und die Schaltfläche trägt die Bedeutung.
|
||||||
|
--}}
|
||||||
|
@if (($clipUrl ?? null) !== null)
|
||||||
|
<video class="lf-pc__clip" muted loop playsinline preload="none" disablepictureinpicture disableremoteplayback tabindex="-1" aria-hidden="true"></video>
|
||||||
|
<button type="button" class="lf-pc__clip-toggle" aria-pressed="false" data-clip-toggle aria-label="Trailer abspielen: {{ $clipTitle }}">
|
||||||
|
<svg class="lf-pc__clip-icon" viewBox="0 0 24 24" focusable="false" aria-hidden="true"><path class="lf-pc__clip-play" d="M8 5.5v13l11-6.5z" fill="currentColor"/><path class="lf-pc__clip-pause" d="M7 5h4v14H7zM13 5h4v14h-4z" fill="currentColor"/></svg>
|
||||||
|
<span class="lf-pc__clip-label" aria-hidden="true">Trailer</span>
|
||||||
|
</button>
|
||||||
|
@endif
|
||||||
@@ -9,6 +9,11 @@
|
|||||||
öffentlich markiert. Es hat keine Freigabe für die Website und wird öffentlich nie ausgegeben.
|
öffentlich markiert. Es hat keine Freigabe für die Website und wird öffentlich nie ausgegeben.
|
||||||
3. Tafel nach Fachobjekt: Programm/Modul (Navy), Film (Filmtafel), Material (Materialsymbol); Thema ohne Bildbereich.
|
3. Tafel nach Fachobjekt: Programm/Modul (Navy), Film (Filmtafel), Material (Materialsymbol); Thema ohne Bildbereich.
|
||||||
Hinweise auf fehlende Inhalte stehen nur in der Redaktionsvorschau, öffentlich nie.
|
Hinweise auf fehlende Inhalte stehen nur in der Redaktionsvorschau, öffentlich nie.
|
||||||
|
|
||||||
|
Trailer: Ist für das Objekt ein für die Website freigegebener Clip da ($clip['url'], CardClip), liegt er stumm und
|
||||||
|
unsichtbar über dem Bildbereich und startet beim Überfahren mit der Maus, am Handy mit Tippen auf das Bild, per
|
||||||
|
Tastatur über die Schaltfläche (resources/js/card-clip.js). Ohne JavaScript bleibt es beim Bild. Der Clip wird erst
|
||||||
|
beim ersten Start geladen.
|
||||||
--}}
|
--}}
|
||||||
@if ($subject === null)
|
@if ($subject === null)
|
||||||
@if ($context->preview)
|
@if ($context->preview)
|
||||||
@@ -21,10 +26,15 @@
|
|||||||
$action = $show['action'] && $subject->url !== null ? ['url' => $subject->url, 'label' => $actionLabel] : null;
|
$action = $show['action'] && $subject->url !== null ? ['url' => $subject->url, 'label' => $actionLabel] : null;
|
||||||
$meta = $show['meta'] ? $subject->meta : [];
|
$meta = $show['meta'] ? $subject->meta : [];
|
||||||
$hints = $subject->missing;
|
$hints = $subject->missing;
|
||||||
|
$clipUrl = $clip['url'] ?? null;
|
||||||
|
$clipTitle = (string) ($clip['title'] ?? '') !== '' ? $clip['title'] : $subject->title;
|
||||||
|
if ($context->preview && ! empty($clip['hint'])) {
|
||||||
|
$hints[] = $clip['hint'];
|
||||||
|
}
|
||||||
$panelName = ['catalog' => 'die Navy-Tafel', 'film' => 'die Filmtafel', 'material' => 'das Materialsymbol'][$subject->visual] ?? 'die Karte ohne Bild';
|
$panelName = ['catalog' => 'die Navy-Tafel', 'film' => 'die Filmtafel', 'material' => 'das Materialsymbol'][$subject->visual] ?? 'die Karte ohne Bild';
|
||||||
if ($context->preview && $imageUrl === null) {
|
if ($context->preview && $imageUrl === null) {
|
||||||
$hints[] = $subject->previewImage !== null
|
$hints[] = $subject->previewImage !== null
|
||||||
? 'Das Vorschaubild der Bibliothek ist nicht für die Website freigegeben; öffentlich erscheint stattdessen '.$panelName.'. Ein freigegebenes Motiv kann im Reiter „Medien“ als Kartenbild gewählt werden.'
|
? 'Das Vorschaubild der Bibliothek ist nicht für die Website freigegeben; öffentlich erscheint stattdessen '.$panelName.'. Ein freigegebenes Motiv kann im Reiter „Medien“ als Kartenbild gewählt werden'.($subject->visual === 'film' ? '; bei einem Film genügt „Vorschaubild des Films übernehmen“.' : '.')
|
||||||
: 'Kein Kartenbild gewählt; öffentlich erscheint '.$panelName.' (Kartenbild im Reiter „Medien“).';
|
: 'Kein Kartenbild gewählt; öffentlich erscheint '.$panelName.' (Kartenbild im Reiter „Medien“).';
|
||||||
}
|
}
|
||||||
@endphp
|
@endphp
|
||||||
@@ -38,8 +48,9 @@
|
|||||||
'lf-pc--internal' => ! $subject->public,
|
'lf-pc--internal' => ! $subject->public,
|
||||||
]) style="--pc-focus-x: {{ $focus['x'] }}%; --pc-focus-y: {{ $focus['y'] }}%">
|
]) style="--pc-focus-x: {{ $focus['x'] }}%; --pc-focus-y: {{ $focus['y'] }}%">
|
||||||
@if ($imageUrl !== null || $libraryImage !== null)
|
@if ($imageUrl !== null || $libraryImage !== null)
|
||||||
<div class="lf-pc__visual">
|
<div class="lf-pc__visual" @if ($clipUrl !== null) data-card-clip data-clip-src="{{ $clipUrl }}" data-clip-title="{{ $clipTitle }}" @endif>
|
||||||
<img class="lf-pc__image" src="{{ $imageUrl ?? $libraryImage }}" alt="{{ $imageUrl !== null ? $alt : '' }}" loading="lazy" decoding="async">
|
<img class="lf-pc__image" src="{{ $imageUrl ?? $libraryImage }}" alt="{{ $imageUrl !== null ? $alt : '' }}" loading="lazy" decoding="async">
|
||||||
|
@include('widgets.partials.card-clip')
|
||||||
@if ($show['kind'] && $subject->badge !== null)
|
@if ($show['kind'] && $subject->badge !== null)
|
||||||
<span class="lf-pc__badge">{{ $subject->badge }}</span>
|
<span class="lf-pc__badge">{{ $subject->badge }}</span>
|
||||||
@endif
|
@endif
|
||||||
@@ -47,6 +58,14 @@
|
|||||||
<span class="lf-pc__library-flag">Bibliotheksbild · nur Vorschau</span>
|
<span class="lf-pc__library-flag">Bibliotheksbild · nur Vorschau</span>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
|
@elseif ($panel !== null && $clipUrl !== null)
|
||||||
|
<div class="lf-pc__visual lf-pc__visual--panel" data-card-clip data-clip-src="{{ $clipUrl }}" data-clip-title="{{ $clipTitle }}">
|
||||||
|
<div class="lf-pc__panel lf-pc__panel--{{ $panel }}" aria-hidden="true">
|
||||||
|
<span class="lf-pc__panel-label">{{ $subject->visualLabel ?? $subject->kind }}</span>
|
||||||
|
<x-brand.underline class="lf-pc__panel-accent" />
|
||||||
|
</div>
|
||||||
|
@include('widgets.partials.card-clip')
|
||||||
|
</div>
|
||||||
@elseif ($panel !== null)
|
@elseif ($panel !== null)
|
||||||
<div class="lf-pc__panel lf-pc__panel--{{ $panel }}" aria-hidden="true">
|
<div class="lf-pc__panel lf-pc__panel--{{ $panel }}" aria-hidden="true">
|
||||||
@if ($panel === 'film')
|
@if ($panel === 'film')
|
||||||
@@ -105,4 +124,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
@include('widgets.partials.image-notice')
|
@include('widgets.partials.image-notice')
|
||||||
|
@if ($context->preview && ! empty($clip['notice']))
|
||||||
|
<p class="preview-note">{{ $clip['notice'] }}</p>
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
use App\Http\Controllers\PublicCatalogController;
|
use App\Http\Controllers\PublicCatalogController;
|
||||||
use App\Http\Controllers\PublicMediaController;
|
use App\Http\Controllers\PublicMediaController;
|
||||||
use App\Http\Controllers\ShopController;
|
use App\Http\Controllers\ShopController;
|
||||||
|
use App\Http\Controllers\StripeWebhookController;
|
||||||
use App\Http\Controllers\ThemeController;
|
use App\Http\Controllers\ThemeController;
|
||||||
use App\Http\Controllers\WebsiteMediaController;
|
use App\Http\Controllers\WebsiteMediaController;
|
||||||
use App\Http\Middleware\EnsureShopEnabled;
|
use App\Http\Middleware\EnsureShopEnabled;
|
||||||
@@ -42,6 +43,8 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::post('/stripe/webhook', StripeWebhookController::class)->name('stripe.webhook');
|
||||||
|
|
||||||
Route::middleware('guest')->group(function () {
|
Route::middleware('guest')->group(function () {
|
||||||
Route::get('/registrieren', [RegistrationController::class, 'create'])->name('register');
|
Route::get('/registrieren', [RegistrationController::class, 'create'])->name('register');
|
||||||
Route::post('/registrieren', [RegistrationController::class, 'store']);
|
Route::post('/registrieren', [RegistrationController::class, 'store']);
|
||||||
@@ -77,6 +80,14 @@
|
|||||||
->whereIn('kind', ['element', 'komposition'])
|
->whereIn('kind', ['element', 'komposition'])
|
||||||
->whereNumber('subject')
|
->whereNumber('subject')
|
||||||
->name('editorial.card');
|
->name('editorial.card');
|
||||||
|
Route::get('/redaktion/website-datei/{element}', [ContentPreviewController::class, 'websiteFile'])
|
||||||
|
->middleware('auth:staff')
|
||||||
|
->whereNumber('element')
|
||||||
|
->name('content.website-file');
|
||||||
|
Route::get('/redaktion/website-datei/{element}/bild', [ContentPreviewController::class, 'websiteFrame'])
|
||||||
|
->middleware('auth:staff')
|
||||||
|
->whereNumber('element')
|
||||||
|
->name('content.website-frame');
|
||||||
Route::get('/redaktion/inhalt/{version}', [ContentPreviewController::class, 'show'])
|
Route::get('/redaktion/inhalt/{version}', [ContentPreviewController::class, 'show'])
|
||||||
->middleware('auth:staff')
|
->middleware('auth:staff')
|
||||||
->name('content.preview');
|
->name('content.preview');
|
||||||
@@ -121,6 +132,7 @@
|
|||||||
Route::post('/angebote/{offer}/abrufen', [CheckoutController::class, 'claim'])->name('offers.claim');
|
Route::post('/angebote/{offer}/abrufen', [CheckoutController::class, 'claim'])->name('offers.claim');
|
||||||
Route::post('/angebote/{offer}/kaufen', [CheckoutController::class, 'place'])->name('offers.buy');
|
Route::post('/angebote/{offer}/kaufen', [CheckoutController::class, 'place'])->name('offers.buy');
|
||||||
Route::get('/bestellung/{order}', [CheckoutController::class, 'show'])->name('order');
|
Route::get('/bestellung/{order}', [CheckoutController::class, 'show'])->name('order');
|
||||||
|
Route::post('/bestellung/{order}/bezahlen', [CheckoutController::class, 'pay'])->name('order.pay');
|
||||||
Route::post('/bestellung/{order}/bestaetigen', [CheckoutController::class, 'confirm'])->name('order.confirm');
|
Route::post('/bestellung/{order}/bestaetigen', [CheckoutController::class, 'confirm'])->name('order.confirm');
|
||||||
Route::post('/bestellung/{order}/ablehnen', [CheckoutController::class, 'fail'])->name('order.fail');
|
Route::post('/bestellung/{order}/ablehnen', [CheckoutController::class, 'fail'])->name('order.fail');
|
||||||
Route::post('/bestellung/{order}/widerrufen', [CheckoutController::class, 'refund'])->name('order.refund');
|
Route::post('/bestellung/{order}/widerrufen', [CheckoutController::class, 'refund'])->name('order.refund');
|
||||||
|
|||||||
@@ -0,0 +1,389 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Composition;
|
||||||
|
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentService;
|
||||||
|
use App\Domain\Catalog\EditorialContentKind;
|
||||||
|
use App\Domain\Catalog\PresentationAssignment;
|
||||||
|
use App\Domain\Catalog\PresentationRole;
|
||||||
|
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\WidgetRegistry;
|
||||||
|
use App\Domain\Media\PresentationFile;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trailer auf Medien-, Programm- und Modulkarte: Die Karte spielt beim Überfahren oder Antippen nur einen für die
|
||||||
|
* Website freigegebenen Clip ab (Präsentationsrolle „Trailer“, sonst „Vorschauclip“, bei einem Film ersatzweise sein
|
||||||
|
* freigegebener Teaser). Ohne freigegebenen Clip bleibt es beim Bild; der Film selbst kommt nie über die Karte.
|
||||||
|
*/
|
||||||
|
class CmsCardTrailerTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
private const BYTES = '0123456789abcdefghij';
|
||||||
|
|
||||||
|
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_a_released_trailer_is_offered_on_the_public_media_card(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm();
|
||||||
|
$trailer = $this->clip('Trailer Denkpause');
|
||||||
|
$this->assign($film, 'trailer', $trailer);
|
||||||
|
$this->release($trailer);
|
||||||
|
|
||||||
|
$this->publish('/trailer', [$this->mediaCard($film)]);
|
||||||
|
|
||||||
|
$card = $this->card($this->get('/trailer')->assertOk()->getContent());
|
||||||
|
$this->assertStringContainsString('data-card-clip', $card);
|
||||||
|
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $card);
|
||||||
|
$this->assertStringContainsString('<video class="lf-pc__clip" muted loop playsinline preload="none"', $card, 'Stumm, nur Schleife, nichts wird vorab geladen.');
|
||||||
|
$this->assertDoesNotMatchRegularExpression('/<video[^>]* src=/', $card, 'Die Quelle wird erst beim ersten Start gesetzt.');
|
||||||
|
$this->assertStringNotContainsString('autoplay', $card);
|
||||||
|
$this->assertStringContainsString('aria-label="Trailer abspielen: Trailer Denkpause"', $card);
|
||||||
|
$this->assertStringContainsString('lf-pc__visual--panel', $card, 'Ohne Kartenbild liegt der Clip über der Filmtafel.');
|
||||||
|
$this->assertStringNotContainsString('originals/', $card);
|
||||||
|
$this->assertStringNotContainsString('teaser/', $card);
|
||||||
|
$this->assertStringNotContainsString('Der Trailer', $card, 'Hinweise für die Redaktion erscheinen öffentlich nie.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_trailer_lies_over_the_card_image_when_there_is_one(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm();
|
||||||
|
$trailer = $this->clip('Trailer Denkpause');
|
||||||
|
$image = $this->image('Kartenbild Denkpause');
|
||||||
|
$this->assign($film, 'trailer', $trailer);
|
||||||
|
$this->release($trailer);
|
||||||
|
$this->release($image);
|
||||||
|
|
||||||
|
$this->publish('/trailer-bild', [$this->mediaCard($film, ['image' => $image->id])]);
|
||||||
|
|
||||||
|
$card = $this->card($this->get('/trailer-bild')->assertOk()->getContent());
|
||||||
|
$this->assertStringContainsString('<img class="lf-pc__image" src="'.route('website.media', $image).'"', $card);
|
||||||
|
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $card);
|
||||||
|
$this->assertStringNotContainsString('lf-pc__visual--panel', $card);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_unreleased_trailer_is_not_played_publicly_and_explained_in_the_preview(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm();
|
||||||
|
$trailer = $this->clip('Trailer ohne Freigabe');
|
||||||
|
$this->assign($film, 'trailer', $trailer);
|
||||||
|
|
||||||
|
$revision = $this->publish('/trailer-offen', [$this->mediaCard($film)]);
|
||||||
|
|
||||||
|
$public = $this->get('/trailer-offen')->assertOk()->getContent();
|
||||||
|
$this->assertStringNotContainsString('data-card-clip', $public);
|
||||||
|
$this->assertStringNotContainsString('<video', $public);
|
||||||
|
$this->assertStringNotContainsString('Trailer ohne Freigabe', $public);
|
||||||
|
$this->get(route('website.media', $trailer))->assertNotFound();
|
||||||
|
|
||||||
|
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
||||||
|
$this->assertStringNotContainsString('<video', $preview, 'Auch die Redaktionsvorschau spielt keinen nicht freigegebenen Clip.');
|
||||||
|
$this->assertStringContainsString('Der Trailer „Trailer ohne Freigabe“ ist nicht für die Website freigegeben', $preview);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_withdrawing_the_release_removes_the_trailer_from_the_page(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm();
|
||||||
|
$trailer = $this->clip('Trailer Denkpause');
|
||||||
|
$this->assign($film, 'trailer', $trailer);
|
||||||
|
$this->release($trailer);
|
||||||
|
$this->publish('/trailer-zurueck', [$this->mediaCard($film)]);
|
||||||
|
|
||||||
|
$this->assertStringContainsString('data-card-clip', $this->get('/trailer-zurueck')->getContent());
|
||||||
|
|
||||||
|
app(WebsiteRelease::class)->withdraw($trailer->fresh());
|
||||||
|
$this->flushScoped();
|
||||||
|
|
||||||
|
$this->assertStringNotContainsString('data-card-clip', $this->get('/trailer-zurueck')->assertOk()->getContent());
|
||||||
|
$this->get(route('website.media', $trailer))->assertNotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_trailer_role_wins_over_the_preview_clip_and_the_film_teaser_is_the_last_resort(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm();
|
||||||
|
$clip = $this->clip('Vorschauclip Denkpause');
|
||||||
|
$trailer = $this->clip('Trailer Denkpause');
|
||||||
|
$this->assign($film, 'vorschauclip', $clip);
|
||||||
|
$this->assign($film, 'trailer', $trailer);
|
||||||
|
$this->release($clip);
|
||||||
|
$this->release($trailer);
|
||||||
|
$this->publish('/trailer-rollen', [$this->mediaCard($film)]);
|
||||||
|
|
||||||
|
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $this->get('/trailer-rollen')->getContent());
|
||||||
|
|
||||||
|
app(WebsiteRelease::class)->withdraw($trailer->fresh());
|
||||||
|
$this->flushScoped();
|
||||||
|
$this->assertStringContainsString('data-clip-src="'.route('website.media', $clip).'"', $this->get('/trailer-rollen')->getContent(), 'Ohne freigegebenen Trailer gilt der Vorschauclip.');
|
||||||
|
|
||||||
|
PresentationAssignment::query()->delete();
|
||||||
|
$this->flushScoped();
|
||||||
|
$this->assertStringNotContainsString('data-card-clip', $this->get('/trailer-rollen')->getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_film_released_for_the_website_is_its_own_teaser_clip(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm();
|
||||||
|
$film->forceFill(['preview_path' => 'teaser/film-'.$film->id.'.mp4'])->save();
|
||||||
|
Storage::disk('media_derived')->put($film->preview_path, self::BYTES);
|
||||||
|
$this->release($film);
|
||||||
|
|
||||||
|
$this->publish('/trailer-teaser', [$this->mediaCard($film)]);
|
||||||
|
|
||||||
|
$this->assertStringContainsString('data-clip-src="'.route('website.media', $film).'"', $this->get('/trailer-teaser')->assertOk()->getContent(), 'Ersatzweise der eigene freigegebene Teaser des Films.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_other_roles_and_images_never_become_a_clip(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm();
|
||||||
|
$interview = $this->clip('Interview Denkpause');
|
||||||
|
$image = $this->image('Bild als Trailer');
|
||||||
|
$this->assign($film, 'interview', $interview);
|
||||||
|
$this->assign($film, 'trailer', $image);
|
||||||
|
$this->release($interview);
|
||||||
|
$this->release($image);
|
||||||
|
|
||||||
|
$this->publish('/trailer-falsch', [$this->mediaCard($film)]);
|
||||||
|
|
||||||
|
$this->assertStringNotContainsString('data-card-clip', $this->get('/trailer-falsch')->assertOk()->getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_editor_can_switch_the_trailer_off_per_card_and_the_choice_is_validated(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm();
|
||||||
|
$trailer = $this->clip('Trailer Denkpause');
|
||||||
|
$this->assign($film, 'trailer', $trailer);
|
||||||
|
$this->release($trailer);
|
||||||
|
|
||||||
|
$this->publish('/trailer-aus', [[
|
||||||
|
'layout' => 'u1_1_1_1',
|
||||||
|
'style' => [],
|
||||||
|
'slots' => [
|
||||||
|
$this->mediaCard($film, [], ['clip' => 'yes'])['slots'][0],
|
||||||
|
$this->mediaCard($film, [], ['clip' => 'no'])['slots'][0],
|
||||||
|
$this->mediaCard($film)['slots'][0],
|
||||||
|
],
|
||||||
|
]]);
|
||||||
|
|
||||||
|
$cards = $this->cards($this->get('/trailer-aus')->assertOk()->getContent());
|
||||||
|
$this->assertCount(3, $cards);
|
||||||
|
$this->assertStringContainsString('data-card-clip', $cards[0]);
|
||||||
|
$this->assertStringNotContainsString('data-card-clip', $cards[1], 'Ausgeschaltet bleibt es beim Bild.');
|
||||||
|
$this->assertStringContainsString('data-card-clip', $cards[2], 'Vorgabe: Abspielen, auch für schon gespeicherte Karten ohne Wahl.');
|
||||||
|
|
||||||
|
$registry = app(WidgetRegistry::class);
|
||||||
|
$this->assertSame(['yes', 'no'], array_keys($registry->get('media_card')->settingOptions()['clip']));
|
||||||
|
$this->assertSame(['yes', 'no'], array_keys($registry->get('program_card')->settingOptions()['clip']));
|
||||||
|
$this->assertArrayNotHasKey('clip', $registry->get('topic_card')->settingOptions(), 'Ein Thema hat keinen Trailer.');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$registry->normalize([['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => ['clip' => 'immer'], 'data' => [], 'refs' => ['element' => $film->id]]]);
|
||||||
|
$this->fail('Eine unbekannte Trailer-Wahl wurde angenommen.');
|
||||||
|
} catch (ValidationException $exception) {
|
||||||
|
$this->assertArrayHasKey('blocks.0.settings.clip', $exception->errors());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_program_card_plays_the_trailer_of_the_program(): void
|
||||||
|
{
|
||||||
|
$program = $this->program('Programm Mut');
|
||||||
|
$trailer = $this->clip('Trailer Mut');
|
||||||
|
$this->assign($program, 'trailer', $trailer);
|
||||||
|
$this->release($trailer);
|
||||||
|
|
||||||
|
$this->publish('/trailer-programm', [['layout' => 'u4', 'style' => [], 'slots' => [
|
||||||
|
['type' => 'program_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => [], 'data' => [], 'refs' => ['composition' => $program->id]],
|
||||||
|
]]]);
|
||||||
|
|
||||||
|
$card = $this->card($this->get('/trailer-programm')->assertOk()->getContent());
|
||||||
|
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $card);
|
||||||
|
$this->assertStringContainsString('lf-pc__visual--panel', $card);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_confidential_film_never_offers_a_trailer(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm(kind: 'traineranleitung');
|
||||||
|
$trailer = $this->clip('Trailer Denkpause');
|
||||||
|
$this->assign($film, 'trailer', $trailer);
|
||||||
|
$this->release($trailer);
|
||||||
|
|
||||||
|
$this->publish('/trailer-vertraulich', [$this->mediaCard($film)]);
|
||||||
|
|
||||||
|
$html = $this->get('/trailer-vertraulich')->assertOk()->getContent();
|
||||||
|
$this->assertStringNotContainsString('data-card-clip', $html);
|
||||||
|
$this->assertStringNotContainsString('Denkpause', $html, 'Die Karte einer Traineranleitung erscheint öffentlich nie.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_media_route_serves_byte_ranges_for_clips(): void
|
||||||
|
{
|
||||||
|
$trailer = $this->clip('Trailer Denkpause');
|
||||||
|
$this->release($trailer);
|
||||||
|
$url = route('website.media', $trailer);
|
||||||
|
|
||||||
|
$whole = $this->get($url)->assertOk();
|
||||||
|
$this->assertSame('bytes', $whole->headers->get('Accept-Ranges'));
|
||||||
|
$whole->assertStreamedContent(self::BYTES);
|
||||||
|
|
||||||
|
$part = $this->get($url, ['Range' => 'bytes=2-5'])->assertStatus(206);
|
||||||
|
$this->assertSame('bytes 2-5/20', $part->headers->get('Content-Range'));
|
||||||
|
$this->assertSame('4', $part->headers->get('Content-Length'));
|
||||||
|
$part->assertStreamedContent('2345');
|
||||||
|
|
||||||
|
$this->get($url, ['Range' => 'bytes=15-'])->assertStatus(206)->assertStreamedContent('fghij');
|
||||||
|
$this->get($url, ['Range' => 'bytes=-3'])->assertStatus(206)->assertStreamedContent('hij');
|
||||||
|
$this->get($url, ['Range' => 'bytes=0-999'])->assertStatus(206)->assertStreamedContent(self::BYTES);
|
||||||
|
|
||||||
|
$unsatisfiable = $this->get($url, ['Range' => 'bytes=40-50'])->assertStatus(416);
|
||||||
|
$this->assertSame('bytes */20', $unsatisfiable->headers->get('Content-Range'));
|
||||||
|
$this->get($url, ['Range' => 'bytes=abc'])->assertStatus(416);
|
||||||
|
|
||||||
|
app(WebsiteRelease::class)->withdraw($trailer->fresh());
|
||||||
|
$this->get($url, ['Range' => 'bytes=0-3'])->assertNotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_images_ignore_range_requests(): void
|
||||||
|
{
|
||||||
|
$image = $this->image('Bild ohne Bereich');
|
||||||
|
$this->release($image);
|
||||||
|
|
||||||
|
$this->get(route('website.media', $image), ['Range' => 'bytes=0-3'])->assertOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function publicFilm(string $kind = 'unterrichtsfilm'): ContentElement
|
||||||
|
{
|
||||||
|
$content = app(ContentService::class);
|
||||||
|
$film = $content->createElement('film', 'film', 'Denkpause Rohschnitt');
|
||||||
|
$film->update(['display_title' => 'Eine Pause, die stark macht', 'summary' => 'KURZ-TEXT']);
|
||||||
|
$film->forceFill(['editorial_content_kind_id' => EditorialContentKind::query()->where('slug', $kind)->value('id')])->save();
|
||||||
|
$version = $content->publishElementVersion($film, 'Film');
|
||||||
|
$composition = $content->createComposition('Programm Denkpause');
|
||||||
|
$composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'programm')->value('id');
|
||||||
|
$composition->save();
|
||||||
|
$shown = $content->publishComposition($composition, [['role' => 'Film', 'target' => $version]]);
|
||||||
|
app(CompositionDisplayRelease::class)->release($shown, User::factory()->create());
|
||||||
|
|
||||||
|
return $film->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function program(string $designation): Composition
|
||||||
|
{
|
||||||
|
$content = app(ContentService::class);
|
||||||
|
$composition = $content->createComposition($designation);
|
||||||
|
$composition->forceFill(['editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'programm')->value('id'), 'summary' => 'KURZ-TEXT'])->save();
|
||||||
|
$version = $content->publishComposition(
|
||||||
|
$composition,
|
||||||
|
[['role' => 'Text', 'target' => $content->publishElementVersion($content->createElement('text', 'text', $designation.' Blatt'), 'Inhalt')]],
|
||||||
|
);
|
||||||
|
app(CompositionDisplayRelease::class)->release($version, User::factory()->create());
|
||||||
|
|
||||||
|
return $composition->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Ein kurzer Clip als eigenes Medium ohne Fassung, wie ihn die Präsentation anlegt. */
|
||||||
|
private function clip(string $title): ContentElement
|
||||||
|
{
|
||||||
|
return $this->presentation('film', $title, self::BYTES, '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 assign(Composition|ContentElement $subject, string $role, ContentElement $clip): void
|
||||||
|
{
|
||||||
|
PresentationAssignment::query()->create([
|
||||||
|
'subject_type' => $subject->getMorphClass(),
|
||||||
|
'subject_id' => $subject->getKey(),
|
||||||
|
'content_element_id' => $clip->id,
|
||||||
|
'presentation_role_id' => PresentationRole::query()->where('slug', $role)->value('id'),
|
||||||
|
'position' => 1,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $refs
|
||||||
|
* @param array<string, string> $settings
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function mediaCard(ContentElement $film, array $refs = [], array $settings = []): array
|
||||||
|
{
|
||||||
|
return ['layout' => 'u4', 'style' => [], 'slots' => [
|
||||||
|
['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => $settings, 'data' => [], 'refs' => ['element' => $film->id] + $refs],
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<array<string, mixed>> $sections
|
||||||
|
*/
|
||||||
|
private function publish(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function card(string $html): string
|
||||||
|
{
|
||||||
|
return $this->cards($html)[0] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function cards(string $html): array
|
||||||
|
{
|
||||||
|
preg_match_all('#<article class="lf-pc .*?</article>#s', $html, $matches);
|
||||||
|
|
||||||
|
return $matches[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,286 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentService;
|
||||||
|
use App\Domain\Catalog\EditorialContentKind;
|
||||||
|
use App\Domain\Catalog\PresentationAssignment;
|
||||||
|
use App\Domain\Catalog\PresentationRole;
|
||||||
|
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\HeroVideo;
|
||||||
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
|
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||||
|
use App\Domain\Media\PresentationFile;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Video im Einstieg (Hero): In der Variante „Foto mit Textfläche“ läuft auf der Fläche des Fotos ein stummer Clip, aber
|
||||||
|
* nur ein für die Website freigegebener (Trailer, Vorschauclip oder Website-Datei des gewählten Films). Der Film selbst
|
||||||
|
* und nicht freigegebene Clips kommen nie über den Einstieg; ohne Clip bleibt es beim Foto.
|
||||||
|
*/
|
||||||
|
class CmsHeroVideoTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
private const BYTES = '0123456789abcdefghij';
|
||||||
|
|
||||||
|
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_the_released_trailer_of_the_chosen_film_plays_on_the_hero(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm();
|
||||||
|
$trailer = $this->clip('Trailer Denkpause');
|
||||||
|
$image = $this->image('Foto Denkpause');
|
||||||
|
$this->assign($film, 'trailer', $trailer);
|
||||||
|
$this->release($trailer);
|
||||||
|
$this->release($image);
|
||||||
|
|
||||||
|
$this->publish('/hero-video', $this->hero($film, ['image' => $image->id]));
|
||||||
|
|
||||||
|
$html = $this->get('/hero-video')->assertOk()->getContent();
|
||||||
|
$hero = $this->heroHtml($html);
|
||||||
|
$this->assertStringContainsString('data-hero-video', $hero);
|
||||||
|
$this->assertStringContainsString('data-clip-src="'.route('website.media', $trailer).'"', $hero);
|
||||||
|
$this->assertStringContainsString('<video class="lf-hero__video" muted loop playsinline preload="none"', $hero, 'Stumm, in Schleife, nichts wird vorab geladen.');
|
||||||
|
$this->assertDoesNotMatchRegularExpression('/<video[^>]* src=/', $hero, 'Die Quelle wird erst nach dem Laden der Seite gesetzt.');
|
||||||
|
$this->assertStringNotContainsString('autoplay', $hero);
|
||||||
|
$this->assertStringContainsString('lf-hero__photo', $hero, 'Das Foto bleibt als Rückfall unter dem Video.');
|
||||||
|
$this->assertStringContainsString('aria-label="Video abspielen: Trailer Denkpause"', $hero);
|
||||||
|
$this->assertStringContainsString('data-hero-toggle', $hero, 'Es gibt immer eine Schaltfläche zum Anhalten.');
|
||||||
|
$this->assertStringNotContainsString('teaser/', $html);
|
||||||
|
$this->assertStringNotContainsString('originals/', $html);
|
||||||
|
$this->assertStringNotContainsString('freigegebenes Video', $html, 'Hinweise für die Redaktion erscheinen öffentlich nie.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_film_with_only_a_released_website_file_is_its_own_hero_video(): void
|
||||||
|
{
|
||||||
|
$teaser = $this->clip('Teaser Denkpause');
|
||||||
|
$this->release($teaser);
|
||||||
|
|
||||||
|
$this->publish('/hero-teaser', $this->hero($teaser));
|
||||||
|
|
||||||
|
$hero = $this->heroHtml($this->get('/hero-teaser')->assertOk()->getContent());
|
||||||
|
$this->assertStringContainsString('data-clip-src="'.route('website.media', $teaser).'"', $hero);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_unreleased_video_is_not_played_publicly_and_explained_in_the_preview(): void
|
||||||
|
{
|
||||||
|
$teaser = $this->clip('Teaser Denkpause');
|
||||||
|
$revision = $this->publish('/hero-nicht-frei', $this->hero($teaser));
|
||||||
|
|
||||||
|
$public = $this->get('/hero-nicht-frei')->assertOk()->getContent();
|
||||||
|
$this->assertStringNotContainsString('data-hero-video', $public);
|
||||||
|
$this->assertStringNotContainsString('<video', $public);
|
||||||
|
$this->assertStringNotContainsString('freigegebenes Video', $public);
|
||||||
|
|
||||||
|
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
||||||
|
$this->assertStringNotContainsString('<video', $preview, 'Auch die Redaktionsvorschau spielt keinen nicht freigegebenen Clip.');
|
||||||
|
$this->assertStringContainsString('kein für die Website freigegebenes Video', $preview);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_withdrawing_the_release_takes_the_video_off_the_page(): void
|
||||||
|
{
|
||||||
|
$teaser = $this->clip('Teaser Denkpause');
|
||||||
|
$this->release($teaser);
|
||||||
|
$this->publish('/hero-zurueck', $this->hero($teaser));
|
||||||
|
$this->assertStringContainsString('data-hero-video', $this->get('/hero-zurueck')->getContent());
|
||||||
|
|
||||||
|
app(WebsiteRelease::class)->withdraw($teaser->fresh());
|
||||||
|
$this->flushScoped();
|
||||||
|
|
||||||
|
$this->assertStringNotContainsString('data-hero-video', $this->get('/hero-zurueck')->assertOk()->getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_film_with_versions_but_without_a_released_clip_stays_with_the_photo(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm();
|
||||||
|
$this->publish('/hero-film', $this->hero($film));
|
||||||
|
|
||||||
|
$this->assertStringNotContainsString('data-hero-video', $this->get('/hero-film')->assertOk()->getContent(), 'Der vollständige Film läuft nie über den Einstieg.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_brand_surface_variant_shows_no_video(): void
|
||||||
|
{
|
||||||
|
$teaser = $this->clip('Teaser Denkpause');
|
||||||
|
$this->release($teaser);
|
||||||
|
$this->publish('/hero-solid', $this->hero($teaser, [], 'editorial_solid'));
|
||||||
|
|
||||||
|
$this->assertStringNotContainsString('data-hero-video', $this->get('/hero-solid')->assertOk()->getContent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_hero_without_video_is_unchanged(): void
|
||||||
|
{
|
||||||
|
$this->publish('/hero-ohne', $this->hero(null));
|
||||||
|
|
||||||
|
$html = $this->get('/hero-ohne')->assertOk()->getContent();
|
||||||
|
$this->assertStringNotContainsString('data-hero-video', $html);
|
||||||
|
$this->assertStringNotContainsString('<video', $html);
|
||||||
|
$this->assertStringContainsString('Neue Wege', $html);
|
||||||
|
|
||||||
|
$widgets = app(WidgetRegistry::class)->normalize($this->hero(null)[0]['slots']);
|
||||||
|
$this->assertArrayNotHasKey('video', $widgets[0]['refs'], 'Ohne Wahl bleibt die gespeicherte Form wie bisher.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_choice_is_validated(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm();
|
||||||
|
$image = $this->image('Foto Denkpause');
|
||||||
|
$archived = $this->clip('Archiv Denkpause');
|
||||||
|
$archived->forceFill(['archived_at' => now()])->save();
|
||||||
|
$confidential = $this->publicFilm('traineranleitung');
|
||||||
|
$registry = app(WidgetRegistry::class);
|
||||||
|
|
||||||
|
$this->assertSame($film->id, $registry->normalize($this->hero($film)[0]['slots'])[0]['refs']['video']);
|
||||||
|
|
||||||
|
foreach (['kein Film' => $image->id, 'archiviert' => $archived->id, 'Traineranleitung' => $confidential->id, 'unbekannt' => 999999] as $case => $id) {
|
||||||
|
try {
|
||||||
|
$registry->normalize([['type' => 'hero', 'v' => 2, 'variant' => 'photo_split', 'settings' => [], 'data' => ['heading' => 'X'], 'refs' => ['video' => $id]]]);
|
||||||
|
$this->fail('Angenommen: '.$case);
|
||||||
|
} catch (ValidationException $exception) {
|
||||||
|
$this->assertArrayHasKey('blocks.0.refs.video', $exception->errors(), $case);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_selection_offers_only_films_and_says_whether_a_video_is_released(): void
|
||||||
|
{
|
||||||
|
$released = $this->clip('Teaser Frei');
|
||||||
|
$this->release($released);
|
||||||
|
$open = $this->clip('Teaser Offen');
|
||||||
|
$image = $this->image('Teaser Bild');
|
||||||
|
$archived = $this->clip('Teaser Archiv');
|
||||||
|
$archived->forceFill(['archived_at' => now()])->save();
|
||||||
|
|
||||||
|
$options = app(HeroVideo::class)->options('Teaser');
|
||||||
|
|
||||||
|
$this->assertStringContainsString('Video freigegeben', $options[$released->id]);
|
||||||
|
$this->assertStringContainsString('noch kein freigegebenes Video', $options[$open->id]);
|
||||||
|
$this->assertArrayNotHasKey($image->id, $options);
|
||||||
|
$this->assertArrayNotHasKey($archived->id, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_confidential_film_never_plays_on_the_hero_even_with_a_saved_choice(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm(kind: 'traineranleitung');
|
||||||
|
$trailer = $this->clip('Trailer Denkpause');
|
||||||
|
$this->assign($film, 'trailer', $trailer);
|
||||||
|
$this->release($trailer);
|
||||||
|
|
||||||
|
$resolved = app(HeroVideo::class)->resolve($film->id, false);
|
||||||
|
|
||||||
|
$this->assertNull($resolved['url']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $refs
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
private function hero(?ContentElement $video, array $refs = [], string $variant = 'photo_split'): array
|
||||||
|
{
|
||||||
|
return [['layout' => 'u4', 'style' => [], 'slots' => [
|
||||||
|
['type' => 'hero', 'v' => 2, 'variant' => $variant, 'settings' => [], 'data' => ['heading' => 'Neue Wege'], 'refs' => ($video !== null ? ['video' => $video->id] : []) + $refs],
|
||||||
|
]]];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function heroHtml(string $html): string
|
||||||
|
{
|
||||||
|
preg_match('#<div class="lf-hero .*?<span class="lf-hero__bottom"#s', $html, $match);
|
||||||
|
|
||||||
|
return $match[0] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<array<string, mixed>> $sections
|
||||||
|
*/
|
||||||
|
private function publish(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function publicFilm(string $kind = 'unterrichtsfilm'): ContentElement
|
||||||
|
{
|
||||||
|
$content = app(ContentService::class);
|
||||||
|
$film = $content->createElement('film', 'film', 'Denkpause Rohschnitt');
|
||||||
|
$film->update(['display_title' => 'Eine Pause, die stark macht', 'summary' => 'KURZ-TEXT']);
|
||||||
|
$film->forceFill(['editorial_content_kind_id' => EditorialContentKind::query()->where('slug', $kind)->value('id')])->save();
|
||||||
|
$version = $content->publishElementVersion($film, 'Film');
|
||||||
|
$composition = $content->createComposition('Programm Denkpause');
|
||||||
|
$composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'programm')->value('id');
|
||||||
|
$composition->save();
|
||||||
|
$shown = $content->publishComposition($composition, [['role' => 'Film', 'target' => $version]]);
|
||||||
|
app(CompositionDisplayRelease::class)->release($shown, User::factory()->create());
|
||||||
|
|
||||||
|
return $film->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Ein kurzer Clip als eigenes Medium ohne Fassung, wie ihn die Präsentation anlegt. */
|
||||||
|
private function clip(string $title): ContentElement
|
||||||
|
{
|
||||||
|
return $this->presentation('film', $title, self::BYTES, '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 assign(ContentElement $subject, string $role, ContentElement $clip): void
|
||||||
|
{
|
||||||
|
PresentationAssignment::query()->create([
|
||||||
|
'subject_type' => $subject->getMorphClass(),
|
||||||
|
'subject_id' => $subject->getKey(),
|
||||||
|
'content_element_id' => $clip->id,
|
||||||
|
'presentation_role_id' => PresentationRole::query()->where('slug', $role)->value('id'),
|
||||||
|
'position' => 1,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,175 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||||
|
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\WidgetRegistry;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Tests\Support\BuildsCatalog;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Medien- und Materialkarte: Die Redaktion wählt, welcher zentrale Text (Teaser, Kurzbeschreibung, ausführliche
|
||||||
|
* Beschreibung) auf der Karte erscheint. Ohne Wahl gilt wie bisher die Kurzbeschreibung, sonst der Teaser.
|
||||||
|
*/
|
||||||
|
class CmsMediaCardTextTest extends TestCase
|
||||||
|
{
|
||||||
|
use BuildsCatalog;
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
public function test_the_card_shows_the_text_the_editor_chose_and_the_default_stays_unchanged(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm();
|
||||||
|
|
||||||
|
$this->publish('/textwahl', [
|
||||||
|
$this->card($film, []),
|
||||||
|
$this->card($film, ['text_source' => 'auto']),
|
||||||
|
$this->card($film, ['text_source' => 'teaser']),
|
||||||
|
$this->card($film, ['text_source' => 'summary']),
|
||||||
|
$this->card($film, ['text_source' => 'description']),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$cards = $this->cards($this->get('/textwahl')->assertOk()->getContent());
|
||||||
|
$this->assertCount(5, $cards);
|
||||||
|
$this->assertStringContainsString('KURZ-TEXT', $cards[0]);
|
||||||
|
$this->assertStringContainsString('KURZ-TEXT', $cards[1]);
|
||||||
|
$this->assertStringContainsString('TEASER-TEXT', $cards[2]);
|
||||||
|
$this->assertStringNotContainsString('KURZ-TEXT', $cards[2]);
|
||||||
|
$this->assertStringContainsString('KURZ-TEXT', $cards[3]);
|
||||||
|
$this->assertStringContainsString('LANG-TEXT', $cards[4]);
|
||||||
|
$this->assertStringContainsString('zweiter Absatz', $cards[4]);
|
||||||
|
|
||||||
|
foreach ($cards as $index => $card) {
|
||||||
|
foreach (['EINSATZ-INTERN', 'LIZENZ-INTERN'] as $internal) {
|
||||||
|
$this->assertStringNotContainsString($internal, $card, "Karte $index: Einsatzhinweis und Lizenzvermerk bleiben intern.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ([0, 1, 2, 3] as $index) {
|
||||||
|
$this->assertStringNotContainsString('LANG-TEXT', $cards[$index], 'Die ausführliche Beschreibung erscheint nur auf ausdrückliche Wahl.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_default_falls_back_to_the_teaser_but_an_explicit_choice_does_not(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm(['summary' => null]);
|
||||||
|
|
||||||
|
$revision = $this->publish('/textwahl-ersatz', [
|
||||||
|
$this->card($film, []),
|
||||||
|
$this->card($film, ['text_source' => 'summary']),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$cards = $this->cards($this->get('/textwahl-ersatz')->assertOk()->getContent());
|
||||||
|
$this->assertStringContainsString('TEASER-TEXT', $cards[0], 'Vorgabe: ohne Kurzbeschreibung der Teaser, wie bisher.');
|
||||||
|
$this->assertStringNotContainsString('lf-pc__summary', $cards[1], 'Gewählte, nicht gepflegte Kurzbeschreibung: kein stiller Ersatz.');
|
||||||
|
$this->assertStringNotContainsString('TEASER-TEXT', $cards[1]);
|
||||||
|
|
||||||
|
$this->assertStringNotContainsString('Keine Kurzbeschreibung gepflegt', $this->get('/textwahl-ersatz')->getContent(), 'Hinweise erscheinen öffentlich nie.');
|
||||||
|
$this->assertStringNotContainsString('Für eine vollständige Karte', $this->get('/textwahl-ersatz')->getContent());
|
||||||
|
|
||||||
|
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
||||||
|
$this->assertStringContainsString('Keine Kurzbeschreibung gepflegt (Medium bearbeiten → Kurzbeschreibung).', $preview);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_own_text_of_the_card_wins_over_the_chosen_central_text(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm();
|
||||||
|
|
||||||
|
$this->publish('/textwahl-eigen', [
|
||||||
|
$this->card($film, ['text_source' => 'description'], ['summary' => 'EIGENER-KARTENTEXT']),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$card = $this->cards($this->get('/textwahl-eigen')->assertOk()->getContent())[0];
|
||||||
|
$this->assertStringContainsString('EIGENER-KARTENTEXT', $card);
|
||||||
|
$this->assertStringNotContainsString('LANG-TEXT', $card);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_choice_is_limited_to_the_three_central_texts_and_to_the_media_card(): void
|
||||||
|
{
|
||||||
|
$film = $this->publicFilm();
|
||||||
|
$registry = app(WidgetRegistry::class);
|
||||||
|
|
||||||
|
$this->assertSame(['auto', 'teaser', 'summary', 'description'], array_keys($registry->get('media_card')->settingOptions()['text_source']));
|
||||||
|
// Seit 21.11.2026 hat auch die Programm- und Modulkarte die Wahl (mit Lernziel); ein Thema hat nur einen Text.
|
||||||
|
$this->assertSame(['auto', 'teaser', 'summary', 'description', 'goal'], array_keys($registry->get('program_card')->settingOptions()['text_source']));
|
||||||
|
$this->assertArrayNotHasKey('text_source', $registry->get('topic_card')->settingOptions());
|
||||||
|
|
||||||
|
foreach (['usage_note', 'license_note', 'working_title'] as $internal) {
|
||||||
|
try {
|
||||||
|
$registry->normalize([['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => ['text_source' => $internal], 'data' => [], 'refs' => ['element' => $film->id]]]);
|
||||||
|
$this->fail("Der interne Text $internal wurde als Kartentext angenommen.");
|
||||||
|
} catch (ValidationException $exception) {
|
||||||
|
$this->assertArrayHasKey('blocks.0.settings.text_source', $exception->errors());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $extra
|
||||||
|
*/
|
||||||
|
private function publicFilm(array $extra = []): ContentElement
|
||||||
|
{
|
||||||
|
$content = app(ContentService::class);
|
||||||
|
$kind = fn (string $slug) => EditorialContentKind::query()->where('slug', $slug)->value('id');
|
||||||
|
$film = $content->createElement('film', 'film', 'Denkpause Rohschnitt');
|
||||||
|
$film->update($extra + [
|
||||||
|
'display_title' => 'Eine Pause, die stark macht',
|
||||||
|
'teaser' => 'TEASER-TEXT',
|
||||||
|
'summary' => 'KURZ-TEXT',
|
||||||
|
'description' => "LANG-TEXT erster Absatz\n\nzweiter Absatz",
|
||||||
|
'usage_note' => 'EINSATZ-INTERN',
|
||||||
|
'license_note' => 'LIZENZ-INTERN',
|
||||||
|
]);
|
||||||
|
$version = $content->publishElementVersion($film, 'Film');
|
||||||
|
$composition = $content->createComposition('Programm Denkpause');
|
||||||
|
$composition->editorial_content_kind_id = $kind('programm');
|
||||||
|
$composition->save();
|
||||||
|
$shown = $content->publishComposition($composition, [['role' => 'Film', 'target' => $version]]);
|
||||||
|
app(CompositionDisplayRelease::class)->release($shown, User::factory()->create());
|
||||||
|
|
||||||
|
return $film->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $settings
|
||||||
|
* @param array<string, mixed> $data
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function card(ContentElement $film, array $settings, array $data = []): array
|
||||||
|
{
|
||||||
|
return ['layout' => 'u4', 'style' => [], 'slots' => [
|
||||||
|
['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => $settings, 'data' => $data, 'refs' => ['element' => $film->id]],
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<array<string, mixed>> $sections
|
||||||
|
*/
|
||||||
|
private function publish(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function cards(string $html): array
|
||||||
|
{
|
||||||
|
preg_match_all('#<article class="lf-pc .*?</article>#s', $html, $matches);
|
||||||
|
|
||||||
|
return $matches[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,252 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Composition;
|
||||||
|
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentService;
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
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\WidgetRegistry;
|
||||||
|
use App\Domain\Media\CompositionStill;
|
||||||
|
use App\Domain\Media\CompositionStillSource;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
|
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||||
|
use App\Models\User;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Programm- und Modulkarte: Die Redaktion wählt den Kartentext (Teaser, Kurzbeschreibung, ausführliche Beschreibung,
|
||||||
|
* Lernziel) und kann das Vorschaubild des Programms oder Moduls als Website-Bild übernehmen.
|
||||||
|
*/
|
||||||
|
class CmsProgramCardTextAndImageTest 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');
|
||||||
|
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_card_shows_the_chosen_text_and_the_default_keeps_its_order(): void
|
||||||
|
{
|
||||||
|
$program = $this->program('Programm Selbstvertrauen', [
|
||||||
|
'teaser' => 'TEASER-TEXT',
|
||||||
|
'summary' => 'KURZ-TEXT',
|
||||||
|
'description' => "LANG-TEXT erster Absatz\n\nzweiter Absatz",
|
||||||
|
], goal: 'LERNZIEL-TEXT');
|
||||||
|
|
||||||
|
$this->publish('/programmtext', [
|
||||||
|
$this->card($program, []),
|
||||||
|
$this->card($program, ['text_source' => 'auto']),
|
||||||
|
$this->card($program, ['text_source' => 'teaser']),
|
||||||
|
$this->card($program, ['text_source' => 'summary']),
|
||||||
|
$this->card($program, ['text_source' => 'description']),
|
||||||
|
$this->card($program, ['text_source' => 'goal']),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$cards = $this->cards($this->get('/programmtext')->assertOk()->getContent());
|
||||||
|
$this->assertCount(6, $cards);
|
||||||
|
$this->assertStringContainsString('TEASER-TEXT', $cards[0], 'Automatisch: Teaser vor Kurzbeschreibung, wie bisher.');
|
||||||
|
$this->assertStringContainsString('TEASER-TEXT', $cards[1]);
|
||||||
|
$this->assertStringContainsString('TEASER-TEXT', $cards[2]);
|
||||||
|
$this->assertStringContainsString('KURZ-TEXT', $cards[3]);
|
||||||
|
$this->assertStringNotContainsString('TEASER-TEXT', $cards[3]);
|
||||||
|
$this->assertStringContainsString('LANG-TEXT', $cards[4]);
|
||||||
|
$this->assertStringContainsString('zweiter Absatz', $cards[4]);
|
||||||
|
$this->assertStringContainsString('LERNZIEL-TEXT', $cards[5]);
|
||||||
|
$this->assertStringNotContainsString('LANG-TEXT', $cards[0], 'Die ausführliche Beschreibung erscheint nur auf ausdrückliche Wahl.');
|
||||||
|
$this->assertStringNotContainsString('LANG-TEXT', $cards[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_automatic_falls_back_to_summary_then_goal_but_an_explicit_choice_does_not(): void
|
||||||
|
{
|
||||||
|
$withSummary = $this->program('Programm Nur Kurz', ['summary' => 'KURZ-TEXT'], goal: 'LERNZIEL-TEXT');
|
||||||
|
$onlyGoal = $this->program('Programm Nur Lernziel', [], goal: 'LERNZIEL-TEXT');
|
||||||
|
|
||||||
|
$revision = $this->publish('/programmtext-ersatz', [
|
||||||
|
$this->card($withSummary, []),
|
||||||
|
$this->card($onlyGoal, []),
|
||||||
|
$this->card($onlyGoal, ['text_source' => 'teaser']),
|
||||||
|
$this->card($onlyGoal, ['text_source' => 'description']),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$cards = $this->cards($this->get('/programmtext-ersatz')->assertOk()->getContent());
|
||||||
|
$this->assertStringContainsString('KURZ-TEXT', $cards[0]);
|
||||||
|
$this->assertStringContainsString('LERNZIEL-TEXT', $cards[1], 'Automatisch: ohne Teaser und Kurzbeschreibung das Lernziel, wie bisher.');
|
||||||
|
$this->assertStringNotContainsString('lf-pc__summary', $cards[2], 'Gewählter, nicht gepflegter Teaser: kein stiller Ersatz.');
|
||||||
|
$this->assertStringNotContainsString('lf-pc__summary', $cards[3]);
|
||||||
|
|
||||||
|
$public = $this->get('/programmtext-ersatz')->getContent();
|
||||||
|
$this->assertStringNotContainsString('Kein Teaser gepflegt', $public, 'Hinweise erscheinen öffentlich nie.');
|
||||||
|
|
||||||
|
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
||||||
|
$this->assertStringContainsString('Kein Teaser gepflegt (Programm oder Modul bearbeiten → Teaser).', $preview);
|
||||||
|
$this->assertStringContainsString('Keine ausführliche Beschreibung gepflegt (Programm oder Modul bearbeiten → Beschreibung).', $preview);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_text_choice_is_offered_on_the_program_card_only_with_its_own_choices(): void
|
||||||
|
{
|
||||||
|
$registry = app(WidgetRegistry::class);
|
||||||
|
|
||||||
|
$this->assertSame(['auto', 'teaser', 'summary', 'description', 'goal'], array_keys($registry->get('program_card')->settingOptions()['text_source']));
|
||||||
|
$this->assertArrayNotHasKey('text_source', $registry->get('topic_card')->settingOptions(), 'Ein Thema hat nur einen Text.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_thumbnail_of_a_program_becomes_one_image_medium_for_the_website(): void
|
||||||
|
{
|
||||||
|
$program = $this->program('Programm Mut', ['summary' => 'x'], thumbnail: true);
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
|
||||||
|
$still = app(CompositionStill::class)->fromThumbnail($program, $editor)->refresh();
|
||||||
|
|
||||||
|
$this->assertSame('bild', $still->output_class);
|
||||||
|
$this->assertSame('Titelbild: Programm Mut', $still->display_title);
|
||||||
|
$this->assertSame('Titelbild zu „Programm Mut“', $still->website_alt);
|
||||||
|
$this->assertSame(0, $still->versions()->count());
|
||||||
|
$this->assertNotNull($still->website_released_at, 'Die Warteschlange gibt das abgeleitete Bild für die Website frei.');
|
||||||
|
$this->assertSame($still->id, CompositionStillSource::query()->where('composition_id', $program->id)->value('still_element_id'));
|
||||||
|
|
||||||
|
$stills = app(CompositionStill::class);
|
||||||
|
$this->assertSame($still->id, $stills->fromThumbnail($program)->id, 'Dasselbe Vorschaubild ergibt dasselbe Medium.');
|
||||||
|
$this->assertTrue($stills->reused);
|
||||||
|
$this->assertSame(1, ContentElement::query()->where('output_class', 'bild')->count());
|
||||||
|
|
||||||
|
$still->forceFill(['thumbnail_error' => 'Die Bilddatei ließ sich nicht lesen.'])->save();
|
||||||
|
$this->assertNotSame($still->id, $stills->fromThumbnail($program)->id, 'Ein gescheitertes Bild wird nicht wiederverwendet.');
|
||||||
|
|
||||||
|
$this->get(route('website.media', $still))->assertOk();
|
||||||
|
$still->delete();
|
||||||
|
$this->assertSame(1, CompositionStillSource::query()->count(), 'Nur die Herkunft des gelöschten Bildes entfällt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_programs_without_thumbnail_or_archived_yield_no_image(): void
|
||||||
|
{
|
||||||
|
$without = $this->program('Programm Ohne Bild', ['summary' => 'x']);
|
||||||
|
$archived = $this->program('Programm Archiv', ['summary' => 'x'], thumbnail: true);
|
||||||
|
$archived->update(['archived_at' => now()]);
|
||||||
|
|
||||||
|
foreach ([[$without, 'noch kein Vorschaubild'], [$archived, 'archiviert']] as [$composition, $message]) {
|
||||||
|
try {
|
||||||
|
app(CompositionStill::class)->fromThumbnail($composition);
|
||||||
|
$this->fail("Erwartete Ablehnung: $message");
|
||||||
|
} catch (DomainRuleException $exception) {
|
||||||
|
$this->assertStringContainsString($message, $exception->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertSame(0, ContentElement::query()->where('output_class', 'bild')->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_editor_adopts_the_thumbnail_into_the_image_field_and_says_when_the_release_was_withdrawn(): void
|
||||||
|
{
|
||||||
|
$program = $this->program('Programm Park', ['summary' => 'x'], thumbnail: true);
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||||
|
$page = Page::query()->create(['path' => '/programmbild-editor']);
|
||||||
|
app(PageService::class)->saveRevision($page, [
|
||||||
|
['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'program_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => [], 'data' => [], 'refs' => ['composition' => $program->id]]]],
|
||||||
|
], null, null, null);
|
||||||
|
$component = Livewire::actingAs($editor, 'staff')->test(EditPage::class, ['record' => $page->id]);
|
||||||
|
|
||||||
|
$component->call('adoptCompositionThumbnail', 'data.ziel.image', $program->id);
|
||||||
|
$still = ContentElement::query()->where('output_class', 'bild')->latest('id')->firstOrFail();
|
||||||
|
$component->assertNotified('Im Medienmanager angelegt: „Titelbild: Programm Park“');
|
||||||
|
$this->assertSame($still->id, $component->get('data.ziel.image'));
|
||||||
|
|
||||||
|
$component->call('adoptCompositionThumbnail', 'data.ziel2.image', $program->id);
|
||||||
|
$component->assertNotified('Bereits im Medienmanager: „Titelbild: Programm Park“');
|
||||||
|
|
||||||
|
app(WebsiteRelease::class)->withdraw($still);
|
||||||
|
$component->call('adoptCompositionThumbnail', 'data.ziel3.image', $program->id);
|
||||||
|
$component->assertNotified('Bild ausgewählt, aber nicht für die Website freigegeben: „Titelbild: Programm Park“');
|
||||||
|
|
||||||
|
$before = ContentElement::query()->count();
|
||||||
|
$component->call('adoptCompositionThumbnail', 'umgebung.geheim', $program->id);
|
||||||
|
$component->call('adoptCompositionThumbnail', 'data.ziel4.bild', $program->id);
|
||||||
|
$component->call('adoptCompositionThumbnail', 'data.ziel5.image', 999999);
|
||||||
|
$this->assertSame($before, ContentElement::query()->count(), 'Fremde Ziele und fehlende Programme legen nichts an.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $texts
|
||||||
|
*/
|
||||||
|
private function program(string $designation, array $texts, ?string $goal = null, bool $thumbnail = false): Composition
|
||||||
|
{
|
||||||
|
$content = app(ContentService::class);
|
||||||
|
$composition = $content->createComposition($designation);
|
||||||
|
$composition->forceFill(['editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'programm')->value('id')] + $texts)->save();
|
||||||
|
|
||||||
|
if ($thumbnail) {
|
||||||
|
$composition->forceFill(['thumbnail_path' => 'vorschau/komposition-'.$composition->id.'.jpg', 'thumbnail_source' => 'eigen'])->save();
|
||||||
|
Storage::disk('media_derived')->put($composition->thumbnail_path, $this->jpeg());
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = $content->publishComposition(
|
||||||
|
$composition,
|
||||||
|
[['role' => 'Text', 'target' => $content->publishElementVersion($content->createElement('text', 'text', $designation.' Blatt'), 'Inhalt')]],
|
||||||
|
didactic: $goal !== null ? ['learning_goal' => $goal] : [],
|
||||||
|
);
|
||||||
|
app(CompositionDisplayRelease::class)->release($version, User::factory()->create());
|
||||||
|
|
||||||
|
return $composition->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $settings
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function card(Composition $program, array $settings): array
|
||||||
|
{
|
||||||
|
return ['layout' => 'u4', 'style' => [], 'slots' => [
|
||||||
|
['type' => 'program_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => $settings, 'data' => [], 'refs' => ['composition' => $program->id]],
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<array<string, mixed>> $sections
|
||||||
|
*/
|
||||||
|
private function publish(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function cards(string $html): array
|
||||||
|
{
|
||||||
|
preg_match_all('#<article class="lf-pc .*?</article>#s', $html, $matches);
|
||||||
|
|
||||||
|
return $matches[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function jpeg(): string
|
||||||
|
{
|
||||||
|
$image = imagecreatetruecolor(800, 450);
|
||||||
|
imagefill($image, 0, 0, imagecolorallocate($image, 20, 80, 150));
|
||||||
|
ob_start();
|
||||||
|
imagejpeg($image);
|
||||||
|
|
||||||
|
return (string) ob_get_clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -136,7 +136,7 @@ public function test_public_page_is_identical_for_guests_and_members(): void
|
|||||||
public function test_global_layout_has_header_navigation_mobile_menu_and_footer(): void
|
public function test_global_layout_has_header_navigation_mobile_menu_and_footer(): void
|
||||||
{
|
{
|
||||||
// Der Warenkorb gehört zum Shop (Etappe 1, nur Testzahlung). Ohne aktiven Shop erscheint kein Kaufknopf.
|
// Der Warenkorb gehört zum Shop (Etappe 1, nur Testzahlung). Ohne aktiven Shop erscheint kein Kaufknopf.
|
||||||
config(['services.payment.driver' => 'stripe']);
|
config(['services.payment.driver' => 'unbekannt']);
|
||||||
$html = $this->get('/praevention')->assertOk()->getContent();
|
$html = $this->get('/praevention')->assertOk()->getContent();
|
||||||
|
|
||||||
$this->assertStringContainsString('<a class="skip" href="#inhalt">', $html);
|
$this->assertStringContainsString('<a class="skip" href="#inhalt">', $html);
|
||||||
@@ -161,7 +161,7 @@ public function test_cart_entry_appears_only_when_the_shop_is_enabled(): void
|
|||||||
// statt der früheren Vorbereitung über cms.cart.*.
|
// statt der früheren Vorbereitung über cms.cart.*.
|
||||||
$this->get('/praevention')->assertSee('Warenkorb')->assertSee('href="'.route('cart').'"', false);
|
$this->get('/praevention')->assertSee('Warenkorb')->assertSee('href="'.route('cart').'"', false);
|
||||||
|
|
||||||
config(['services.payment.driver' => 'stripe']);
|
config(['services.payment.driver' => 'unbekannt']);
|
||||||
$this->get('/praevention')->assertDontSee('Warenkorb');
|
$this->get('/praevention')->assertDontSee('Warenkorb');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,6 +140,31 @@ public function test_former_cms_images_are_imported_once_deduplicated_and_withou
|
|||||||
$this->assertTrue(ContentElement::query()->get()->every(fn (ContentElement $element): bool => $element->website_released_at !== null));
|
$this->assertTrue(ContentElement::query()->get()->every(fn (ContentElement $element): bool => $element->website_released_at !== null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_deleting_an_imported_medium_keeps_the_former_file_closed_and_shows_no_image(): void
|
||||||
|
{
|
||||||
|
Storage::disk('media_public')->put('cms/geloescht-ffffff.jpg', $this->jpeg(1000, 500));
|
||||||
|
$this->publish('/geloescht', [
|
||||||
|
['layout' => 'u4', 'style' => [], 'slots' => [
|
||||||
|
['type' => 'hero', 'v' => 2, 'variant' => 'photo_split', 'data' => ['heading' => 'Ohne Bild'], 'refs' => ['image' => 'cms/geloescht-ffffff.jpg']],
|
||||||
|
]],
|
||||||
|
]);
|
||||||
|
(new ImportCmsImages)->handle(app(WebsiteIntake::class));
|
||||||
|
$medium = WebsiteMediaAlias::query()->firstOrFail()->element;
|
||||||
|
$this->refreshScoped();
|
||||||
|
$this->get('/geloescht')->assertSee('src="'.route('website.media', $medium).'"', false);
|
||||||
|
|
||||||
|
$medium->delete();
|
||||||
|
$this->refreshScoped();
|
||||||
|
|
||||||
|
$this->assertNull(WebsiteMediaAlias::query()->sole()->content_element_id, 'Die Zuordnung bleibt als Sperre bestehen.');
|
||||||
|
$main = $this->main($this->get('/geloescht')->assertOk()->getContent());
|
||||||
|
$this->assertStringContainsString('Ohne Bild', $main, 'Das Widget bleibt.');
|
||||||
|
$this->assertStringNotContainsString('<img', $main);
|
||||||
|
$this->assertStringNotContainsString('/medien/cms/geloescht', $main);
|
||||||
|
$this->get('/medien/cms/geloescht-ffffff.jpg')->assertNotFound();
|
||||||
|
Storage::disk('media_public')->assertExists('cms/geloescht-ffffff.jpg');
|
||||||
|
}
|
||||||
|
|
||||||
public function test_an_alias_takes_effect_only_after_the_medium_was_released(): void
|
public function test_an_alias_takes_effect_only_after_the_medium_was_released(): void
|
||||||
{
|
{
|
||||||
Storage::disk('media_public')->put('cms/kaputt-dddddd.jpg', 'keine Bilddaten');
|
Storage::disk('media_public')->put('cms/kaputt-dddddd.jpg', 'keine Bilddaten');
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentService;
|
||||||
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
|
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\WidgetRegistry;
|
||||||
|
use App\Domain\Media\PresentationFile;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ein Film, der nur aus einer Website-Datei besteht (Medium ohne Inhaltsfassung, z. B. ein Teaser), ist auf der
|
||||||
|
* Medienkarte wählbar. Öffentlich erscheint die Karte erst, wenn die Datei für die Website freigegeben ist; ein
|
||||||
|
* Programm ist dafür nicht nötig, die Karte hat dann keine Aktion.
|
||||||
|
*/
|
||||||
|
class CmsWebsiteOnlyFilmCardTest 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_a_film_with_only_a_website_file_is_offered_in_the_card_dropdown(): void
|
||||||
|
{
|
||||||
|
$teaser = $this->websiteFilm('Teaser Denkpause');
|
||||||
|
|
||||||
|
$options = app(PublicMaterialReader::class)->search('Teaser Denk');
|
||||||
|
|
||||||
|
$this->assertArrayHasKey($teaser->id, $options);
|
||||||
|
$this->assertStringContainsString('Website-Datei nicht freigegeben', $options[$teaser->id]);
|
||||||
|
$this->assertArrayHasKey($teaser->id, app(PublicMaterialReader::class)->search(null), 'Auch ohne Suchbegriff.');
|
||||||
|
$this->assertTrue(app(PublicMaterialReader::class)->isSelectable($teaser));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_dropdown_label_says_when_the_file_is_released(): void
|
||||||
|
{
|
||||||
|
$teaser = $this->websiteFilm('Teaser Denkpause');
|
||||||
|
$this->release($teaser);
|
||||||
|
|
||||||
|
$options = app(PublicMaterialReader::class)->search('Teaser Denk');
|
||||||
|
|
||||||
|
$this->assertStringContainsString('öffentlich mit Website-Datei', $options[$teaser->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_card_endpoint_accepts_such_a_film_as_its_medium(): void
|
||||||
|
{
|
||||||
|
$teaser = $this->websiteFilm('Teaser Denkpause');
|
||||||
|
$widget = app(WidgetRegistry::class)->get('media_card');
|
||||||
|
|
||||||
|
$options = (new \ReflectionMethod($widget, 'rejectSubject'))->invoke($widget, $teaser->id);
|
||||||
|
|
||||||
|
$this->assertNull($options, 'Die Auswahl wird nicht mit „archiviert oder gesperrt“ abgelehnt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_released_website_film_shows_publicly_with_its_clip_and_without_an_action(): void
|
||||||
|
{
|
||||||
|
$teaser = $this->websiteFilm('Teaser Denkpause');
|
||||||
|
$this->release($teaser);
|
||||||
|
$this->publish('/teaser-karte', $teaser);
|
||||||
|
|
||||||
|
$html = $this->get('/teaser-karte')->assertOk()->getContent();
|
||||||
|
|
||||||
|
$this->assertStringContainsString('Teaser Denkpause', $html);
|
||||||
|
$this->assertStringContainsString('data-clip-src="'.route('website.media', $teaser).'"', $html, 'Das freigegebene Video ist der Clip der Karte.');
|
||||||
|
$this->assertStringNotContainsString('lf-pc__cta', $html, 'Ohne Programmseite gibt es keine Aktion.');
|
||||||
|
$this->assertStringNotContainsString('teaser/', $html);
|
||||||
|
$this->assertStringNotContainsString('originals/', $html);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_unreleased_website_film_stays_out_of_the_public_page_but_shows_in_the_preview(): void
|
||||||
|
{
|
||||||
|
$teaser = $this->websiteFilm('Teaser Denkpause');
|
||||||
|
$this->publish('/teaser-nicht-frei', $teaser);
|
||||||
|
|
||||||
|
$this->get('/teaser-nicht-frei')->assertOk()->assertDontSee('Teaser Denkpause');
|
||||||
|
|
||||||
|
$subject = app(PublicMaterialReader::class)->subject($teaser->id, includeNonPublic: true);
|
||||||
|
$this->assertNotNull($subject);
|
||||||
|
$this->assertFalse($subject->public);
|
||||||
|
$this->assertStringContainsString('nicht für die Website freigegeben', (string) $subject->notice);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_withdrawing_the_release_takes_the_card_off_the_public_page(): void
|
||||||
|
{
|
||||||
|
$teaser = $this->websiteFilm('Teaser Denkpause');
|
||||||
|
$this->release($teaser);
|
||||||
|
$this->publish('/teaser-zurueck', $teaser);
|
||||||
|
$this->get('/teaser-zurueck')->assertSee('Teaser Denkpause');
|
||||||
|
|
||||||
|
app(WebsiteRelease::class)->withdraw($teaser->fresh());
|
||||||
|
$this->flushScoped();
|
||||||
|
|
||||||
|
$this->get('/teaser-zurueck')->assertOk()->assertDontSee('Teaser Denkpause');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_archived_website_film_is_never_offered(): void
|
||||||
|
{
|
||||||
|
$archived = $this->websiteFilm('Archiv Denkpause');
|
||||||
|
$archived->forceFill(['archived_at' => now()])->save();
|
||||||
|
|
||||||
|
$this->assertArrayNotHasKey($archived->id, app(PublicMaterialReader::class)->search('Archiv'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_image_without_a_version_is_not_offered_as_medium(): void
|
||||||
|
{
|
||||||
|
$path = 'inhalte/bild.jpg';
|
||||||
|
Storage::disk('cms_incoming')->put($path, 'bild-bytes');
|
||||||
|
$image = app(ContentService::class)->createElement('bild', 'bild', 'Bild Denkpause');
|
||||||
|
app(PresentationFile::class)->store($image, $path);
|
||||||
|
|
||||||
|
$this->assertArrayNotHasKey($image->id, app(PublicMaterialReader::class)->search('Bild Denk'), 'Nur Filme ohne Fassung zählen als Medium der Karte.');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function websiteFilm(string $title): ContentElement
|
||||||
|
{
|
||||||
|
$path = 'inhalte/'.md5($title).'.mp4';
|
||||||
|
Storage::disk('cms_incoming')->put($path, '0123456789abcdefghij');
|
||||||
|
$element = app(ContentService::class)->createElement('film', 'film', $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, PublicMaterialReader::class] as $class) {
|
||||||
|
$this->app->forgetInstance($class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function publish(string $path, ContentElement $film): PageRevision
|
||||||
|
{
|
||||||
|
$page = Page::query()->create(['path' => $path]);
|
||||||
|
$service = app(PageService::class);
|
||||||
|
$revision = $service->saveRevision($page, [['layout' => 'u4', 'style' => [], 'slots' => [
|
||||||
|
['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => [], 'data' => [], 'refs' => ['element' => $film->id]],
|
||||||
|
]]], null, null, null);
|
||||||
|
$service->publish($page, $revision);
|
||||||
|
|
||||||
|
return $revision;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,320 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentElementVersion;
|
||||||
|
use App\Domain\Catalog\ContentService;
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Catalog\EditorialContentKind;
|
||||||
|
use App\Domain\Cms\Page;
|
||||||
|
use App\Domain\Cms\PageService;
|
||||||
|
use App\Domain\Entitlement\Grant;
|
||||||
|
use App\Domain\Media\FilmStill;
|
||||||
|
use App\Domain\Media\FilmStillSource;
|
||||||
|
use App\Domain\Media\ThumbnailDeriver;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
|
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||||
|
use App\Models\User;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bild aus einem Film für die Medien- und Materialkarte: einmal als Bild-Medium ablegen, danach nur lesen.
|
||||||
|
* Die Bildextraktion (ffmpeg) wird durch einen Stub ersetzt und mitgezählt.
|
||||||
|
*/
|
||||||
|
class FilmStillTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
/** @var object{calls: list<array{second: float, width: int, original: bool}>, fail: bool} */
|
||||||
|
private object $extractor;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
Storage::fake('cms_incoming');
|
||||||
|
Storage::fake('media_derived');
|
||||||
|
Storage::fake('media_public');
|
||||||
|
Storage::fake('media_originals');
|
||||||
|
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||||
|
|
||||||
|
$jpeg = $this->jpeg(1600, 900);
|
||||||
|
$this->extractor = new class($jpeg) extends ThumbnailDeriver
|
||||||
|
{
|
||||||
|
/** @var list<array{second: float, width: int, original: bool}> */
|
||||||
|
public array $calls = [];
|
||||||
|
|
||||||
|
public bool $fail = false;
|
||||||
|
|
||||||
|
public function __construct(private readonly string $jpeg) {}
|
||||||
|
|
||||||
|
public function frameJpeg(ContentElementVersion $version, float $seconds, int $width = 640, bool $original = false): ?string
|
||||||
|
{
|
||||||
|
$this->calls[] = ['second' => $seconds, 'width' => $width, 'original' => $original];
|
||||||
|
|
||||||
|
return $this->fail ? null : $this->jpeg;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$this->app->instance(ThumbnailDeriver::class, $this->extractor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_chosen_frame_becomes_one_image_medium_that_is_released_for_the_website(): void
|
||||||
|
{
|
||||||
|
$film = $this->film();
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
|
||||||
|
$still = app(FilmStill::class)->fromSecond($film, 41.5, $editor)->refresh();
|
||||||
|
|
||||||
|
$this->assertSame('bild', $still->output_class);
|
||||||
|
$this->assertSame('Standbild: Lara im Park (Fassung 1, 41,5 s)', $still->display_title);
|
||||||
|
$this->assertSame('Szene aus dem Film „Lara im Park“', $still->website_alt);
|
||||||
|
$this->assertSame('Foto: Lara und Felix', $still->website_credit, 'Die Quellenzeile des Films wird übernommen.');
|
||||||
|
$this->assertSame(0, $still->versions()->count(), 'Es entsteht keine Inhaltsfassung.');
|
||||||
|
$this->assertSame(0, Grant::query()->count(), 'Es entsteht keine Berechtigung.');
|
||||||
|
$this->assertNotNull($still->website_released_at, 'Die Warteschlange gibt das abgeleitete Bild für die Website frei.');
|
||||||
|
$this->assertSame([['second' => 41.5, 'width' => 1600, 'original' => true]], $this->extractor->calls, 'Aus der Mediendatei in voller Auflösung, nicht aus der kleinen Stufe.');
|
||||||
|
$this->assertSame($still->id, FilmStillSource::query()->where('film_element_id', $film->id)->value('still_element_id'));
|
||||||
|
$this->assertSame($editor->id, FilmStillSource::query()->value('actor_id'));
|
||||||
|
$this->assertSame(1, ContentElement::query()->where('output_class', 'film')->count(), 'Der Film bleibt unverändert.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_same_frame_is_never_extracted_or_stored_twice(): void
|
||||||
|
{
|
||||||
|
$film = $this->film();
|
||||||
|
$first = app(FilmStill::class)->fromSecond($film, 12);
|
||||||
|
$second = app(FilmStill::class)->fromSecond($film, 12.0);
|
||||||
|
$other = app(FilmStill::class)->fromSecond($film, 13);
|
||||||
|
|
||||||
|
$this->assertSame($first->id, $second->id);
|
||||||
|
$this->assertNotSame($first->id, $other->id);
|
||||||
|
$this->assertCount(2, $this->extractor->calls, 'Die zweite Anforderung derselben Stelle liest das gespeicherte Bild.');
|
||||||
|
$this->assertSame(2, ContentElement::query()->where('output_class', 'bild')->count());
|
||||||
|
|
||||||
|
$first->update(['archived_at' => now()]);
|
||||||
|
$this->assertNotSame($first->id, app(FilmStill::class)->fromSecond($film, 12)->id, 'Ein archiviertes Bild wird nicht wiederverwendet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_thumbnail_of_the_film_is_taken_over_in_full_resolution_or_as_its_own_file(): void
|
||||||
|
{
|
||||||
|
$film = $this->film();
|
||||||
|
$film->forceFill(['thumbnail_path' => 'vorschau/element-'.$film->id.'.jpg', 'thumbnail_source' => 'frame:'.$film->versions()->value('id').'@41.5'])->save();
|
||||||
|
Storage::disk('media_derived')->put($film->thumbnail_path, $this->jpeg(640, 360));
|
||||||
|
|
||||||
|
$fromFrame = app(FilmStill::class)->fromThumbnail($film);
|
||||||
|
$this->assertSame([['second' => 41.5, 'width' => 1600, 'original' => true]], $this->extractor->calls, 'Eine Filmstelle wird in voller Auflösung neu gezogen.');
|
||||||
|
$this->assertSame($fromFrame->id, app(FilmStill::class)->fromSecond($film, 41.5)->id, 'Dieselbe Stelle ergibt dasselbe Medium, egal auf welchem Weg.');
|
||||||
|
$this->assertCount(1, $this->extractor->calls);
|
||||||
|
|
||||||
|
$own = $this->film('Interview');
|
||||||
|
$own->forceFill(['thumbnail_path' => 'vorschau/element-'.$own->id.'.jpg', 'thumbnail_source' => 'eigen'])->save();
|
||||||
|
Storage::disk('media_derived')->put($own->thumbnail_path, $this->jpeg(800, 450));
|
||||||
|
|
||||||
|
$copied = app(FilmStill::class)->fromThumbnail($own);
|
||||||
|
$this->assertSame($copied->id, app(FilmStill::class)->fromThumbnail($own)->id, 'Dieselbe Vorschaudatei ergibt dasselbe Medium.');
|
||||||
|
$this->assertCount(1, $this->extractor->calls, 'Ein eigenes Vorschaubild wird kopiert, nicht aus dem Film gezogen.');
|
||||||
|
$this->assertStringStartsWith('Standbild: Interview (Vorschaubild)', $copied->refresh()->display_title);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_confidential_blocked_or_unusable_films_yield_no_image(): void
|
||||||
|
{
|
||||||
|
$content = app(ContentService::class);
|
||||||
|
$guide = $this->film('Traineranleitung als Film');
|
||||||
|
$guide->update(['editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'traineranleitung')->value('id')]);
|
||||||
|
$archived = $this->film('Archiviert');
|
||||||
|
$archived->update(['archived_at' => now()]);
|
||||||
|
$draftOnly = $content->createElement('film', 'film', 'Nur Entwurf');
|
||||||
|
$content->draftElementVersion($draftOnly, 'Entwurf');
|
||||||
|
$text = $content->createElement('text', 'text', 'Ein Text');
|
||||||
|
$noThumbnail = $this->film('Ohne Vorschaubild');
|
||||||
|
|
||||||
|
$cases = [
|
||||||
|
[fn () => app(FilmStill::class)->fromSecond($guide, 5), 'Traineranleitungen'],
|
||||||
|
[fn () => app(FilmStill::class)->fromSecond($archived, 5), 'archiviert'],
|
||||||
|
[fn () => app(FilmStill::class)->fromSecond($draftOnly, 5), 'bereitgestellte Fassung'],
|
||||||
|
[fn () => app(FilmStill::class)->fromSecond($text, 5), 'Nur aus einem Film'],
|
||||||
|
[fn () => app(FilmStill::class)->fromSecond($noThumbnail, -1), 'außerhalb des Films'],
|
||||||
|
[fn () => app(FilmStill::class)->fromSecond($noThumbnail, 7201), 'außerhalb des Films'],
|
||||||
|
[fn () => app(FilmStill::class)->fromThumbnail($noThumbnail), 'noch kein Vorschaubild'],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($cases as [$call, $message]) {
|
||||||
|
try {
|
||||||
|
$call();
|
||||||
|
$this->fail("Erwartete Ablehnung: $message");
|
||||||
|
} catch (DomainRuleException $exception) {
|
||||||
|
$this->assertStringContainsString($message, $exception->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->extractor->fail = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
app(FilmStill::class)->fromSecond($noThumbnail, 5);
|
||||||
|
$this->fail('Eine nicht ziehbare Stelle wurde angenommen.');
|
||||||
|
} catch (DomainRuleException $exception) {
|
||||||
|
$this->assertStringContainsString('kein Bild erzeugen', $exception->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertSame(0, ContentElement::query()->where('output_class', 'bild')->count(), 'Bei einer Ablehnung entsteht kein Medium.');
|
||||||
|
$this->assertSame(0, FilmStillSource::query()->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_card_shows_the_stored_image_and_a_page_view_never_extracts_a_frame(): void
|
||||||
|
{
|
||||||
|
$film = $this->film();
|
||||||
|
$still = app(FilmStill::class)->fromSecond($film, 41.5)->refresh();
|
||||||
|
$this->assertCount(1, $this->extractor->calls);
|
||||||
|
$this->publishInProgram($film);
|
||||||
|
|
||||||
|
$page = Page::query()->create(['path' => '/filmkarte']);
|
||||||
|
$service = app(PageService::class);
|
||||||
|
$service->publish($page, $service->saveRevision($page, [
|
||||||
|
['layout' => 'u4', 'style' => [], 'slots' => [
|
||||||
|
['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => [], 'data' => [], 'refs' => ['element' => $film->id, 'image' => $still->id]],
|
||||||
|
]],
|
||||||
|
], null, null, null));
|
||||||
|
|
||||||
|
for ($i = 0; $i < 3; $i++) {
|
||||||
|
$html = $this->get('/filmkarte')->assertOk()->getContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertStringContainsString('src="'.route('website.media', $still).'"', $html);
|
||||||
|
$this->assertStringContainsString('alt="Szene aus dem Film „Lara im Park“"', htmlspecialchars_decode($html));
|
||||||
|
$this->assertStringNotContainsString('lf-pc__panel--film', $html, 'Mit freigegebenem Bild erscheint keine Filmtafel.');
|
||||||
|
$this->assertStringNotContainsString('/redaktion/', $html);
|
||||||
|
$this->assertCount(1, $this->extractor->calls, 'Seitenaufrufe lesen nur die gespeicherte Datei und starten keine Bildextraktion.');
|
||||||
|
|
||||||
|
app(WebsiteRelease::class)->withdraw($still);
|
||||||
|
$this->app->forgetScopedInstances();
|
||||||
|
$this->assertStringNotContainsString('<img', $this->main($this->get('/filmkarte')->getContent()), 'Zurückgenommen: das Bild entfällt, die Karte bleibt (Filmtafel).');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_editor_adopts_a_frame_into_the_image_field_and_rejects_foreign_targets(): void
|
||||||
|
{
|
||||||
|
$film = $this->film();
|
||||||
|
$film->forceFill(['thumbnail_path' => 'vorschau/element-'.$film->id.'.jpg', 'thumbnail_source' => 'eigen'])->save();
|
||||||
|
Storage::disk('media_derived')->put($film->thumbnail_path, $this->jpeg(640, 360));
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||||
|
$page = Page::query()->create(['path' => '/filmbild-editor']);
|
||||||
|
app(PageService::class)->saveRevision($page, [
|
||||||
|
['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => [], 'data' => [], 'refs' => ['element' => $film->id]]]],
|
||||||
|
], null, null, null);
|
||||||
|
|
||||||
|
$component = Livewire::actingAs($editor, 'staff')->test(EditPage::class, ['record' => $page->id]);
|
||||||
|
|
||||||
|
$component->call('adoptFilmFrame', 'data.ziel.image', $film->id, '12.5');
|
||||||
|
$frame = ContentElement::query()->where('output_class', 'bild')->latest('id')->firstOrFail();
|
||||||
|
$this->assertSame($frame->id, $component->get('data.ziel.image'));
|
||||||
|
$this->assertSame('Standbild: Lara im Park (Fassung 1, 12,5 s)', $frame->display_title);
|
||||||
|
|
||||||
|
$component->call('adoptFilmThumbnail', 'data.ziel2.image', $film->id);
|
||||||
|
$this->assertNotNull($component->get('data.ziel2.image'));
|
||||||
|
|
||||||
|
$before = ContentElement::query()->count();
|
||||||
|
$component->call('adoptFilmFrame', 'data.ziel3.image', $film->id, 'abc');
|
||||||
|
$component->call('adoptFilmFrame', 'umgebung.geheim', $film->id, '5');
|
||||||
|
$component->call('adoptFilmFrame', 'data.ziel4.bild', $film->id, '5');
|
||||||
|
$component->call('adoptFilmFrame', 'data.ziel5.image', 999999, '5');
|
||||||
|
$this->assertSame($before, ContentElement::query()->count(), 'Fremde Ziele, falsche Eingaben und fehlende Filme legen nichts an.');
|
||||||
|
$this->assertNull($component->get('data.ziel3.image'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_withdrawn_still_is_reused_but_the_message_says_it_is_not_public(): void
|
||||||
|
{
|
||||||
|
$film = $this->film();
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||||
|
$page = Page::query()->create(['path' => '/zurueckgenommen']);
|
||||||
|
app(PageService::class)->saveRevision($page, [
|
||||||
|
['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'media_card', 'v' => 1, 'variant' => 'adaptive', 'settings' => [], 'data' => [], 'refs' => ['element' => $film->id]]]],
|
||||||
|
], null, null, null);
|
||||||
|
$component = Livewire::actingAs($editor, 'staff')->test(EditPage::class, ['record' => $page->id]);
|
||||||
|
|
||||||
|
$component->call('adoptFilmFrame', 'data.ziel.image', $film->id, '12.5');
|
||||||
|
$still = ContentElement::query()->where('output_class', 'bild')->latest('id')->firstOrFail();
|
||||||
|
$title = 'Standbild: Lara im Park (Fassung 1, 12,5 s)';
|
||||||
|
$component->assertNotified('Im Medienmanager angelegt: „'.$title.'“');
|
||||||
|
|
||||||
|
$component->call('adoptFilmFrame', 'data.ziel2.image', $film->id, '12.5');
|
||||||
|
$component->assertNotified('Bereits im Medienmanager: „'.$title.'“');
|
||||||
|
$this->assertSame($still->id, $component->get('data.ziel2.image'));
|
||||||
|
$this->assertCount(1, $this->extractor->calls, 'Die zweite Übernahme zieht nichts neu.');
|
||||||
|
|
||||||
|
app(WebsiteRelease::class)->withdraw($still);
|
||||||
|
|
||||||
|
$component->call('adoptFilmFrame', 'data.ziel3.image', $film->id, '12.5');
|
||||||
|
$component->assertNotified('Bild ausgewählt, aber nicht für die Website freigegeben: „'.$title.'“');
|
||||||
|
$this->assertSame($still->id, $component->get('data.ziel3.image'), 'Das zurückgenommene Bild bleibt ein und dasselbe Medium.');
|
||||||
|
$this->assertCount(1, $this->extractor->calls);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_still_that_failed_during_processing_is_replaced_by_a_new_one_for_the_same_frame(): void
|
||||||
|
{
|
||||||
|
$film = $this->film();
|
||||||
|
$first = app(FilmStill::class)->fromSecond($film, 7);
|
||||||
|
$first->forceFill(['thumbnail_error' => 'Die Bilddatei ließ sich nicht lesen.'])->save();
|
||||||
|
|
||||||
|
$second = app(FilmStill::class)->fromSecond($film, 7);
|
||||||
|
|
||||||
|
$this->assertNotSame($first->id, $second->id, 'Ein gescheitertes Bild blockiert die Stelle nicht.');
|
||||||
|
$this->assertSame($second->id, FilmStillSource::query()->where('film_element_id', $film->id)->sole()->still_element_id, 'Die Herkunft zeigt auf das neue Bild.');
|
||||||
|
$this->assertSame($second->id, app(FilmStill::class)->fromSecond($film, 7)->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_deleting_a_still_in_the_media_manager_works_and_the_frame_can_be_taken_over_again(): void
|
||||||
|
{
|
||||||
|
$film = $this->film();
|
||||||
|
$still = app(FilmStill::class)->fromSecond($film, 3);
|
||||||
|
|
||||||
|
$still->delete();
|
||||||
|
|
||||||
|
$this->assertSame(0, FilmStillSource::query()->count(), 'Die Herkunftszeile entfällt mit dem Bild.');
|
||||||
|
$this->assertSame($film->id, ContentElement::query()->where('output_class', 'film')->value('id'), 'Der Film bleibt.');
|
||||||
|
$again = app(FilmStill::class)->fromSecond($film, 3);
|
||||||
|
$this->assertNotSame($still->id, $again->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function film(string $title = 'Lara im Park'): ContentElement
|
||||||
|
{
|
||||||
|
$content = app(ContentService::class);
|
||||||
|
$film = $content->createElement('film', 'film', $title);
|
||||||
|
$film->update(['website_credit' => 'Foto: Lara und Felix']);
|
||||||
|
$content->publishElementVersion($film, 'Film');
|
||||||
|
|
||||||
|
return $film->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function publishInProgram(ContentElement $film): void
|
||||||
|
{
|
||||||
|
$content = app(ContentService::class);
|
||||||
|
$composition = $content->createComposition('Programm Park');
|
||||||
|
$composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'programm')->value('id');
|
||||||
|
$composition->save();
|
||||||
|
$version = $content->publishComposition($composition, [['role' => 'Film', 'target' => $film->versions()->firstOrFail()]]);
|
||||||
|
app(CompositionDisplayRelease::class)->release($version, User::factory()->create());
|
||||||
|
}
|
||||||
|
|
||||||
|
private function main(string $html): string
|
||||||
|
{
|
||||||
|
preg_match('#<main[^>]*>(.*)</main>#s', $html, $match);
|
||||||
|
|
||||||
|
return $match[1] ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function jpeg(int $width, int $height): string
|
||||||
|
{
|
||||||
|
$image = imagecreatetruecolor($width, $height);
|
||||||
|
imagefill($image, 0, 0, imagecolorallocate($image, 40, 120, 90));
|
||||||
|
ob_start();
|
||||||
|
imagejpeg($image);
|
||||||
|
|
||||||
|
return (string) ob_get_clean();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentService;
|
||||||
|
use App\Filament\Resources\ContentElements\Pages\ListContentElements;
|
||||||
|
use App\Models\User;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Medienübersicht: Kennzeichnung eigenständiger Präsentationsmedien und Website-Freigabe, Filter „Schutz“.
|
||||||
|
*/
|
||||||
|
class MediaOverviewProtectionTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||||
|
$content = app(ContentService::class);
|
||||||
|
|
||||||
|
// Öffentlich: Präsentationsmedien ohne Inhaltsfassung, eines davon für die Website freigegeben.
|
||||||
|
$content->createElement('film', 'film', 'Trailer frei');
|
||||||
|
$released = $content->createElement('film', 'film', 'Trailer online');
|
||||||
|
$released->website_released_at = now();
|
||||||
|
$released->save();
|
||||||
|
$content->createElement('bild', 'bild', 'Titelbild offen');
|
||||||
|
|
||||||
|
// Geschützt: mit Inhaltsfassung.
|
||||||
|
$content->publishElementVersion($content->createElement('film', 'film', 'Unterrichtsfilm geschützt'), null, ['file' => 'inhalte/f.mp4']);
|
||||||
|
$content->publishElementVersion($content->createElement('text', 'text', 'Lehrtext geschützt'), 'Inhalt');
|
||||||
|
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||||
|
$this->actingAs($editor, 'staff');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_overview_marks_presentation_media_and_the_website_release(): void
|
||||||
|
{
|
||||||
|
Livewire::test(ListContentElements::class)
|
||||||
|
->assertSee('Präsentationsmedium, ohne Inhaltsfassung')
|
||||||
|
->assertSee('Für die Website freigegeben')
|
||||||
|
->assertSee('Nicht für die Website freigegeben')
|
||||||
|
->assertSee('Fassung 1 freigegeben');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_filter_shows_all_protected_or_public_media_in_both_directions(): void
|
||||||
|
{
|
||||||
|
$page = Livewire::test(ListContentElements::class)
|
||||||
|
->assertSee('Trailer frei')->assertSee('Unterrichtsfilm geschützt');
|
||||||
|
|
||||||
|
$page->set('schutz', 'oeffentlich')
|
||||||
|
->assertSee('Trailer frei')->assertSee('Trailer online')->assertSee('Titelbild offen')
|
||||||
|
->assertDontSee('Unterrichtsfilm geschützt')->assertDontSee('Lehrtext geschützt');
|
||||||
|
|
||||||
|
$page->set('schutz', 'geschuetzt')
|
||||||
|
->assertSee('Unterrichtsfilm geschützt')->assertSee('Lehrtext geschützt')
|
||||||
|
->assertDontSee('Trailer frei')->assertDontSee('Titelbild offen');
|
||||||
|
|
||||||
|
$page->set('schutz', 'website')
|
||||||
|
->assertSee('Trailer online')
|
||||||
|
->assertDontSee('Trailer frei')->assertDontSee('Unterrichtsfilm geschützt');
|
||||||
|
|
||||||
|
$page->set('schutz', '')
|
||||||
|
->assertSee('Trailer frei')->assertSee('Unterrichtsfilm geschützt')->assertSee('Lehrtext geschützt');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_unknown_protection_value_is_ignored_and_the_filter_can_be_reset(): void
|
||||||
|
{
|
||||||
|
Livewire::test(ListContentElements::class)
|
||||||
|
->set('schutz', 'unsinn')
|
||||||
|
->assertSee('Trailer frei')->assertSee('Unterrichtsfilm geschützt')
|
||||||
|
->set('schutz', 'oeffentlich')
|
||||||
|
->call('resetFilters')
|
||||||
|
->assertSet('schutz', '')
|
||||||
|
->assertSee('Unterrichtsfilm geschützt');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -98,7 +98,8 @@ public function test_the_shop_exists_only_with_test_payment_and_never_in_product
|
|||||||
{
|
{
|
||||||
$this->assertTrue(Shop::enabled());
|
$this->assertTrue(Shop::enabled());
|
||||||
|
|
||||||
config(['services.payment.driver' => 'stripe']);
|
// Ein nicht freigegebener Zahlungsweg (Stripe ist seit der Sandbox-Anbindung freigegeben, siehe StripeSandboxTest).
|
||||||
|
config(['services.payment.driver' => 'unbekannt']);
|
||||||
$this->get(route('shop'))->assertNotFound();
|
$this->get(route('shop'))->assertNotFound();
|
||||||
$this->get(route('cart'))->assertNotFound();
|
$this->get(route('cart'))->assertNotFound();
|
||||||
$this->post(route('cart.add', $this->privateKonflikte()))->assertNotFound();
|
$this->post(route('cart.add', $this->privateKonflikte()))->assertNotFound();
|
||||||
|
|||||||
@@ -0,0 +1,321 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Commerce\Order;
|
||||||
|
use App\Domain\Commerce\Shop;
|
||||||
|
use App\Domain\Entitlement\Acquisition;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Http\Client\Request as HttpRequest;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Testing\TestResponse;
|
||||||
|
use Tests\Support\BuildsShop;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stripe-Sandbox (Etappe 1): Kasse über eine Checkout Session, Freischaltung nur durch die signierte Meldung.
|
||||||
|
* Alle Aufrufe an Stripe sind gefälscht (Http::fake); es geht nie ein echter Aufruf hinaus.
|
||||||
|
*/
|
||||||
|
class StripeSandboxTest extends TestCase
|
||||||
|
{
|
||||||
|
use BuildsShop;
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
private const WEBHOOK_SECRET = 'whsec_testgeheimnis_nur_fuer_tests';
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->seedShop();
|
||||||
|
config([
|
||||||
|
'services.payment.driver' => 'stripe',
|
||||||
|
'services.stripe.secret' => 'sk_test_nur_fuer_tests',
|
||||||
|
'services.stripe.webhook_secret' => self::WEBHOOK_SECRET,
|
||||||
|
'services.stripe.api_base' => 'https://stripe.test',
|
||||||
|
]);
|
||||||
|
$this->travelTo('2026-11-22 10:00:00');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_stripe_is_a_shop_driver_but_never_in_production(): void
|
||||||
|
{
|
||||||
|
$this->assertTrue(Shop::enabled());
|
||||||
|
$this->assertTrue(Shop::stripe());
|
||||||
|
|
||||||
|
$this->app['env'] = 'production';
|
||||||
|
$this->assertFalse(Shop::enabled());
|
||||||
|
$this->assertFalse(Shop::stripe());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_order_page_offers_stripe_and_not_the_test_buttons(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
|
||||||
|
$this->actingAs($this->tina())->get(route('member.order', $order))
|
||||||
|
->assertOk()
|
||||||
|
->assertSee('Jetzt bezahlen (Stripe-Testmodus)')
|
||||||
|
->assertDontSee('Testzahlung bestätigen')
|
||||||
|
->assertDontSee('Testzahlung ablehnen');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_paying_creates_a_checkout_session_with_the_order_amounts_and_redirects(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte(), $this->privateGrenzen()]);
|
||||||
|
Http::fake(['stripe.test/v1/checkout/sessions' => Http::response(['id' => 'cs_test_1', 'url' => 'https://checkout.stripe.test/c/pay/cs_test_1'])]);
|
||||||
|
|
||||||
|
$this->actingAs($this->tina())->post(route('member.order.pay', $order))
|
||||||
|
->assertRedirect('https://checkout.stripe.test/c/pay/cs_test_1');
|
||||||
|
|
||||||
|
Http::assertSent(function (HttpRequest $request) use ($order): bool {
|
||||||
|
parse_str($request->body(), $body);
|
||||||
|
|
||||||
|
return $request->url() === 'https://stripe.test/v1/checkout/sessions'
|
||||||
|
&& $request->hasHeader('Authorization', 'Bearer sk_test_nur_fuer_tests')
|
||||||
|
&& $request->hasHeader('Idempotency-Key', 'luf-order-'.$order->id.'-1')
|
||||||
|
&& $body['mode'] === 'payment'
|
||||||
|
&& $body['client_reference_id'] === (string) $order->id
|
||||||
|
&& $body['metadata']['order_id'] === (string) $order->id
|
||||||
|
&& $body['line_items'][0]['price_data']['currency'] === 'eur'
|
||||||
|
&& (int) $body['line_items'][0]['price_data']['unit_amount'] === 4900
|
||||||
|
&& (int) $body['line_items'][1]['price_data']['unit_amount'] === 2900
|
||||||
|
&& str_ends_with($body['success_url'], '?zahlung=zurueck')
|
||||||
|
&& str_ends_with($body['cancel_url'], '?zahlung=abbruch');
|
||||||
|
});
|
||||||
|
$this->assertSame('offen', $order->payments()->where('provider', 'stripe')->value('status'));
|
||||||
|
$this->assertSame('offen', $order->fresh()->status, 'Bezahlt wird erst durch die signierte Meldung.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_open_session_is_reused(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
$order->payments()->create(['provider' => 'stripe', 'status' => 'offen', 'provider_reference' => 'cs_test_alt']);
|
||||||
|
|
||||||
|
Http::fake(['stripe.test/v1/checkout/sessions/cs_test_alt' => Http::response(['id' => 'cs_test_alt', 'status' => 'open', 'url' => 'https://checkout.stripe.test/alt'])]);
|
||||||
|
$this->actingAs($this->tina())->post(route('member.order.pay', $order))->assertRedirect('https://checkout.stripe.test/alt');
|
||||||
|
Http::assertNotSent(fn (HttpRequest $request): bool => $request->method() === 'POST');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_expired_session_is_replaced_by_a_new_one(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
$order->payments()->create(['provider' => 'stripe', 'status' => 'offen', 'provider_reference' => 'cs_test_alt']);
|
||||||
|
|
||||||
|
Http::fake([
|
||||||
|
'stripe.test/v1/checkout/sessions/cs_test_alt' => Http::response(['id' => 'cs_test_alt', 'status' => 'expired']),
|
||||||
|
'stripe.test/v1/checkout/sessions' => Http::response(['id' => 'cs_test_neu', 'url' => 'https://checkout.stripe.test/neu']),
|
||||||
|
]);
|
||||||
|
$this->actingAs($this->tina())->post(route('member.order.pay', $order))->assertRedirect('https://checkout.stripe.test/neu');
|
||||||
|
Http::assertSent(fn (HttpRequest $request): bool => $request->hasHeader('Idempotency-Key', 'luf-order-'.$order->id.'-2'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_only_the_buyer_pays_and_only_an_open_order(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
Http::fake();
|
||||||
|
|
||||||
|
$this->actingAs($this->max())->post(route('member.order.pay', $order))->assertForbidden();
|
||||||
|
Http::assertNothingSent();
|
||||||
|
|
||||||
|
$order->forceFill(['status' => 'bezahlt'])->save();
|
||||||
|
$this->actingAs($this->tina())->post(route('member.order.pay', $order))
|
||||||
|
->assertSessionHasErrors('payment');
|
||||||
|
Http::assertNothingSent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_only_test_keys_reach_stripe(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
Http::fake();
|
||||||
|
|
||||||
|
foreach (['sk_live_abc', '', 'pk_test_abc'] as $secret) {
|
||||||
|
config(['services.stripe.secret' => $secret]);
|
||||||
|
$this->actingAs($this->tina())->post(route('member.order.pay', $order))->assertSessionHasErrors('payment');
|
||||||
|
}
|
||||||
|
|
||||||
|
Http::assertNothingSent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_stripe_error_leaves_the_order_open_and_shows_a_plain_message(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
Log::spy();
|
||||||
|
Http::fake(['stripe.test/*' => Http::response(['error' => ['type' => 'invalid_request_error', 'param' => 'success_url', 'message' => 'Not a valid URL']], 400)]);
|
||||||
|
|
||||||
|
$this->actingAs($this->tina())->post(route('member.order.pay', $order))
|
||||||
|
->assertSessionHasErrors(['payment' => 'Die Zahlung konnte bei Stripe nicht angelegt werden. Bitte versuche es später noch einmal.']);
|
||||||
|
$this->assertSame('offen', $order->fresh()->status);
|
||||||
|
$this->assertSame(0, $order->payments()->count());
|
||||||
|
Log::shouldHaveReceived('warning')->withArgs(fn (string $message, array $context): bool => $message === 'Stripe-Anfrage fehlgeschlagen'
|
||||||
|
&& $context['status'] === 400
|
||||||
|
&& $context['param'] === 'success_url'
|
||||||
|
&& $context['message'] === 'Not a valid URL'
|
||||||
|
&& ! str_contains(json_encode($context), 'sk_test'))->once();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_signed_paid_event_grants_every_line_once_even_when_repeated(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte(), $this->privateGrenzen()]);
|
||||||
|
$payload = $this->sessionEvent('checkout.session.completed', $order, 'cs_test_bezahlt', 7800);
|
||||||
|
|
||||||
|
$this->webhook($payload)->assertOk()->assertJson(['handled' => true]);
|
||||||
|
$this->webhook($payload)->assertOk();
|
||||||
|
|
||||||
|
$this->assertSame('bezahlt', $order->fresh()->status);
|
||||||
|
$this->assertSame(2, Acquisition::query()->where('reference_type', 'order_line')->whereIn('reference_id', $order->lines()->pluck('id'))->count(), 'Je Position genau ein Erwerb.');
|
||||||
|
$this->assertSame(1, $order->payments()->count());
|
||||||
|
$payment = $order->payments()->first();
|
||||||
|
$this->assertSame('stripe', $payment->provider);
|
||||||
|
$this->assertSame('bestaetigt', $payment->status);
|
||||||
|
$this->assertSame('cs_test_bezahlt', $payment->provider_reference);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_paid_event_confirms_the_open_payment_row_instead_of_adding_one(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
$order->payments()->create(['provider' => 'stripe', 'status' => 'offen', 'provider_reference' => 'cs_test_zeile']);
|
||||||
|
|
||||||
|
$this->webhook($this->sessionEvent('checkout.session.completed', $order, 'cs_test_zeile', 4900))->assertOk();
|
||||||
|
|
||||||
|
$this->assertSame(1, $order->payments()->count());
|
||||||
|
$this->assertSame('bestaetigt', $order->payments()->first()->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_unsigned_wrongly_signed_or_stale_message_does_nothing(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
$payload = $this->sessionEvent('checkout.session.completed', $order, 'cs_test_x', 4900);
|
||||||
|
$before = Acquisition::query()->count();
|
||||||
|
|
||||||
|
$this->call('POST', route('stripe.webhook'), [], [], [], ['CONTENT_TYPE' => 'application/json'], $payload)->assertStatus(400);
|
||||||
|
$this->webhook($payload, 'sig-falsch')->assertStatus(400);
|
||||||
|
$this->webhook($payload, 't='.now()->getTimestamp().',v1=abc')->assertStatus(400);
|
||||||
|
$this->webhook($payload, $this->signature($payload, now()->subMinutes(10)->getTimestamp()))->assertStatus(400);
|
||||||
|
$this->webhook($payload.' ', $this->signature($payload))->assertStatus(400);
|
||||||
|
|
||||||
|
$this->assertSame('offen', $order->fresh()->status);
|
||||||
|
$this->assertSame($before, Acquisition::query()->count(), 'Es wird nichts freigeschaltet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_wrong_amount_or_currency_grants_nothing_and_is_marked_for_review(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
|
||||||
|
$this->webhook($this->sessionEvent('checkout.session.completed', $order, 'cs_test_zuwenig', 100))->assertOk()->assertJson(['handled' => false]);
|
||||||
|
$this->webhook($this->sessionEvent('checkout.session.completed', $order, 'cs_test_usd', 4900, 'usd'))->assertOk()->assertJson(['handled' => false]);
|
||||||
|
|
||||||
|
$this->assertSame('offen', $order->fresh()->status);
|
||||||
|
$this->assertSame(['zu_pruefen', 'zu_pruefen'], $order->payments()->orderBy('id')->pluck('status')->all());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_unpaid_session_an_unknown_order_and_unknown_events_are_ignored(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
|
||||||
|
$this->webhook($this->sessionEvent('checkout.session.completed', $order, 'cs_test_offen', 4900, 'eur', 'unpaid'))->assertOk()->assertJson(['handled' => false]);
|
||||||
|
$this->webhook($this->event('checkout.session.completed', ['id' => 'cs_x', 'client_reference_id' => '999999', 'payment_status' => 'paid', 'amount_total' => 1, 'currency' => 'eur']))->assertOk()->assertJson(['handled' => false]);
|
||||||
|
$this->webhook($this->event('customer.created', ['id' => 'cus_1']))->assertOk()->assertJson(['handled' => false]);
|
||||||
|
|
||||||
|
$this->assertSame('offen', $order->fresh()->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_an_expired_session_keeps_the_order_open_and_payable(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
$order->payments()->create(['provider' => 'stripe', 'status' => 'offen', 'provider_reference' => 'cs_test_abgelaufen']);
|
||||||
|
|
||||||
|
$this->webhook($this->sessionEvent('checkout.session.expired', $order, 'cs_test_abgelaufen', 4900, 'eur', 'unpaid'))->assertOk();
|
||||||
|
|
||||||
|
$this->assertSame('offen', $order->fresh()->status);
|
||||||
|
$this->assertSame('abgelaufen', $order->payments()->first()->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_payment_for_an_order_that_is_no_longer_open_is_not_applied(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
$order->forceFill(['status' => 'fehlgeschlagen'])->save();
|
||||||
|
|
||||||
|
$this->webhook($this->sessionEvent('checkout.session.completed', $order, 'cs_test_spaet', 4900))->assertOk()->assertJson(['handled' => false]);
|
||||||
|
|
||||||
|
$this->assertSame('fehlgeschlagen', $order->fresh()->status);
|
||||||
|
$this->assertSame('zu_pruefen', $order->payments()->first()->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_webhook_does_not_exist_outside_stripe_mode_or_in_production(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
$payload = $this->sessionEvent('checkout.session.completed', $order, 'cs_test_x', 4900);
|
||||||
|
|
||||||
|
config(['services.payment.driver' => 'test']);
|
||||||
|
$this->webhook($payload)->assertNotFound();
|
||||||
|
|
||||||
|
config(['services.payment.driver' => 'stripe']);
|
||||||
|
$this->app['env'] = 'production';
|
||||||
|
$this->webhook($payload)->assertNotFound();
|
||||||
|
$this->assertSame('offen', $order->fresh()->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_without_a_webhook_secret_every_message_is_refused(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
$payload = $this->sessionEvent('checkout.session.completed', $order, 'cs_test_x', 4900);
|
||||||
|
$header = $this->signature($payload);
|
||||||
|
config(['services.stripe.webhook_secret' => '']);
|
||||||
|
|
||||||
|
$this->webhook($payload, $header)->assertStatus(400);
|
||||||
|
$this->assertSame('offen', $order->fresh()->status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_return_page_explains_waiting_and_cancelling(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
|
||||||
|
$this->actingAs($this->tina())->get(route('member.order', $order).'?zahlung=zurueck')->assertSee('Wir warten auf die Bestätigung von Stripe');
|
||||||
|
$this->actingAs($this->tina())->get(route('member.order', $order).'?zahlung=abbruch')->assertSee('Es wurde nichts abgebucht');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_paid_order_offers_the_library_and_no_withdrawal_that_would_not_refund_money(): void
|
||||||
|
{
|
||||||
|
$order = $this->orderOf($this->tina(), [$this->privateKonflikte()]);
|
||||||
|
$this->webhook($this->sessionEvent('checkout.session.completed', $order, 'cs_test_ok', 4900))->assertOk();
|
||||||
|
|
||||||
|
$this->actingAs($this->tina())->get(route('member.order', $order))
|
||||||
|
->assertSee('Zur Bibliothek')
|
||||||
|
->assertDontSee('Widerrufen');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $object
|
||||||
|
*/
|
||||||
|
private function event(string $type, array $object): string
|
||||||
|
{
|
||||||
|
return json_encode(['id' => 'evt_'.$type, 'object' => 'event', 'type' => $type, 'data' => ['object' => $object]], JSON_THROW_ON_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sessionEvent(string $type, Order $order, string $sessionId, int $amount, string $currency = 'eur', string $paymentStatus = 'paid'): string
|
||||||
|
{
|
||||||
|
return $this->event($type, [
|
||||||
|
'id' => $sessionId,
|
||||||
|
'object' => 'checkout.session',
|
||||||
|
'client_reference_id' => (string) $order->id,
|
||||||
|
'payment_status' => $paymentStatus,
|
||||||
|
'amount_total' => $amount,
|
||||||
|
'currency' => $currency,
|
||||||
|
'metadata' => ['order_id' => (string) $order->id],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function signature(string $payload, ?int $timestamp = null): string
|
||||||
|
{
|
||||||
|
$timestamp ??= now()->getTimestamp();
|
||||||
|
|
||||||
|
return 't='.$timestamp.',v1='.hash_hmac('sha256', $timestamp.'.'.$payload, self::WEBHOOK_SECRET);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function webhook(string $payload, ?string $signature = null): TestResponse
|
||||||
|
{
|
||||||
|
return $this->call('POST', route('stripe.webhook'), [], [], [], [
|
||||||
|
'CONTENT_TYPE' => 'application/json',
|
||||||
|
'HTTP_STRIPE_SIGNATURE' => $signature ?? $this->signature($payload),
|
||||||
|
], $payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,261 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentService;
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Entitlement\Grant;
|
||||||
|
use App\Domain\Media\PresentationFile;
|
||||||
|
use App\Domain\Media\ThumbnailDeriver;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
|
use App\Filament\Resources\ContentElements\Pages\ViewContentElement;
|
||||||
|
use App\Filament\Support\MediumForm;
|
||||||
|
use App\Jobs\PublishWebsiteMedia;
|
||||||
|
use App\Jobs\StorePresentationFile;
|
||||||
|
use App\Models\User;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Http\UploadedFile;
|
||||||
|
use Illuminate\Support\Facades\Queue;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Livewire\Livewire;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Website-Datei eines Films (zum Beispiel ein Trailer ohne Schutz). Der Web-Prozess hat `derived/` nur lesend
|
||||||
|
* (docker-compose.yml); die Datei muss deshalb die Warteschlange ablegen.
|
||||||
|
*/
|
||||||
|
class WebsiteFileTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||||
|
Storage::fake('cms_incoming');
|
||||||
|
Storage::fake('media_derived');
|
||||||
|
Storage::fake('media_public');
|
||||||
|
Storage::fake('media_originals');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_web_process_does_not_write_to_the_derived_store_but_hands_the_copy_to_the_queue(): void
|
||||||
|
{
|
||||||
|
Queue::fake();
|
||||||
|
Storage::disk('cms_incoming')->put('inhalte/trailer.mp4', 'trailer-bytes');
|
||||||
|
$this->actingAs($this->editor(), 'staff');
|
||||||
|
|
||||||
|
$element = MediumForm::create([
|
||||||
|
'working_title' => 'Trailer',
|
||||||
|
'shape' => 'film',
|
||||||
|
'incoming' => 'inhalte/trailer.mp4',
|
||||||
|
'without_version' => true,
|
||||||
|
], hold: false);
|
||||||
|
|
||||||
|
Queue::assertPushed(StorePresentationFile::class, fn (StorePresentationFile $job): bool => $job->elementId === $element->id);
|
||||||
|
$this->assertEmpty(Storage::disk('media_derived')->allFiles());
|
||||||
|
$this->assertNull($element->fresh()->preview_path);
|
||||||
|
$this->assertSame(0, $element->versions()->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_queue_places_the_file_and_the_film_can_then_be_released_without_a_license(): void
|
||||||
|
{
|
||||||
|
Storage::disk('cms_incoming')->put('inhalte/trailer.mp4', 'trailer-bytes');
|
||||||
|
$this->actingAs($this->editor(), 'staff');
|
||||||
|
|
||||||
|
$element = MediumForm::create([
|
||||||
|
'working_title' => 'Trailer',
|
||||||
|
'shape' => 'film',
|
||||||
|
'incoming' => 'inhalte/trailer.mp4',
|
||||||
|
'without_version' => true,
|
||||||
|
], hold: false)->fresh();
|
||||||
|
|
||||||
|
$this->assertSame('teaser/'.$element->id.'/datei.mp4', $element->preview_path);
|
||||||
|
Storage::disk('media_derived')->assertExists($element->preview_path);
|
||||||
|
Storage::disk('cms_incoming')->assertMissing('inhalte/trailer.mp4');
|
||||||
|
|
||||||
|
$this->assertNull(app(WebsiteRelease::class)->refusal($element));
|
||||||
|
app(WebsiteRelease::class)->release($element);
|
||||||
|
$this->assertNotNull(app(WebsiteMedia::class)->present($element->fresh()));
|
||||||
|
$this->assertSame(0, Grant::query()->count());
|
||||||
|
Storage::disk('media_originals')->assertDirectoryEmpty('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_film_format_the_browser_cannot_play_is_refused_before_anything_is_created(): void
|
||||||
|
{
|
||||||
|
Storage::disk('cms_incoming')->put('inhalte/trailer.mov', 'mov-bytes');
|
||||||
|
$this->actingAs($this->editor(), 'staff');
|
||||||
|
|
||||||
|
try {
|
||||||
|
MediumForm::create([
|
||||||
|
'working_title' => 'Trailer als MOV',
|
||||||
|
'shape' => 'film',
|
||||||
|
'incoming' => 'inhalte/trailer.mov',
|
||||||
|
'without_version' => true,
|
||||||
|
], hold: false);
|
||||||
|
$this->fail('Eine MOV-Datei darf keine Website-Datei werden.');
|
||||||
|
} catch (DomainRuleException $e) {
|
||||||
|
$this->assertStringContainsString('.mov', $e->getMessage());
|
||||||
|
$this->assertStringContainsString('MP4', $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertSame(0, ContentElement::query()->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_failed_copy_is_shown_at_the_medium_instead_of_getting_lost(): void
|
||||||
|
{
|
||||||
|
$element = app(ContentService::class)->createElement('film', 'film', 'Trailer');
|
||||||
|
|
||||||
|
(new StorePresentationFile($element->id, 'inhalte/fehlt.mp4'))->handle(app(PresentationFile::class));
|
||||||
|
|
||||||
|
$this->assertStringContainsString('nicht im Eingang', (string) $element->fresh()->thumbnail_error);
|
||||||
|
$this->assertNull($element->fresh()->preview_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_film_with_a_protected_version_gets_a_separate_unprotected_website_file(): void
|
||||||
|
{
|
||||||
|
Queue::fake([PublishWebsiteMedia::class]);
|
||||||
|
$content = app(ContentService::class);
|
||||||
|
$film = $content->createElement('film', 'film', 'Unterrichtsfilm');
|
||||||
|
$version = $content->publishElementVersion($film, null, ['incoming' => 'inhalte/ganz.mp4']);
|
||||||
|
$this->assertNotNull(app(WebsiteRelease::class)->refusal($film->fresh()));
|
||||||
|
|
||||||
|
$this->actingAs($this->editor(), 'staff');
|
||||||
|
Livewire::test(ViewContentElement::class, ['record' => $film->getKey()])
|
||||||
|
->set('bereich', 'website')
|
||||||
|
->set('websiteUpload', UploadedFile::fake()->create('trailer.mp4', 100, 'video/mp4'))
|
||||||
|
->call('storeWebsiteFile')
|
||||||
|
->assertSee('Die Website-Datei ist übernommen');
|
||||||
|
|
||||||
|
$film = $film->fresh();
|
||||||
|
$this->assertSame('teaser/'.$film->id.'/datei.mp4', $film->preview_path);
|
||||||
|
$this->assertSame([$version->id], $film->versions()->pluck('id')->all());
|
||||||
|
$this->assertNull(app(WebsiteRelease::class)->refusal($film));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_upload_in_the_viewer_refuses_wrong_formats_and_missing_files(): void
|
||||||
|
{
|
||||||
|
$film = app(ContentService::class)->createElement('film', 'film', 'Film');
|
||||||
|
$this->actingAs($this->editor(), 'staff');
|
||||||
|
|
||||||
|
Livewire::test(ViewContentElement::class, ['record' => $film->getKey()])
|
||||||
|
->set('bereich', 'website')
|
||||||
|
->call('storeWebsiteFile')
|
||||||
|
->assertSee('Wähle zuerst eine Datei.')
|
||||||
|
->set('websiteUpload', UploadedFile::fake()->create('trailer.mov', 10))
|
||||||
|
->call('storeWebsiteFile')
|
||||||
|
->assertSee('kann der Browser nicht direkt abspielen');
|
||||||
|
|
||||||
|
$this->assertNull($film->fresh()->preview_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_replacing_the_file_of_a_released_film_publishes_the_new_copy(): void
|
||||||
|
{
|
||||||
|
Storage::disk('cms_incoming')->put('inhalte/neu.mp4', 'neu');
|
||||||
|
$film = app(ContentService::class)->createElement('film', 'film', 'Trailer');
|
||||||
|
$film->website_released_at = now();
|
||||||
|
$film->save();
|
||||||
|
Queue::fake([PublishWebsiteMedia::class]);
|
||||||
|
|
||||||
|
app(PresentationFile::class)->store($film, 'inhalte/neu.mp4');
|
||||||
|
|
||||||
|
Queue::assertPushed(PublishWebsiteMedia::class, fn (PublishWebsiteMedia $job): bool => $job->elementId === $film->id && $job->action === 'release');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_versionless_film_shows_its_website_file_in_the_media_manager(): void
|
||||||
|
{
|
||||||
|
Storage::disk('cms_incoming')->put('inhalte/trailer.mp4', '0123456789');
|
||||||
|
$this->actingAs($this->editor(), 'staff');
|
||||||
|
$film = MediumForm::create([
|
||||||
|
'working_title' => 'Trailer',
|
||||||
|
'shape' => 'film',
|
||||||
|
'incoming' => 'inhalte/trailer.mp4',
|
||||||
|
'without_version' => true,
|
||||||
|
], hold: false)->fresh();
|
||||||
|
$url = route('content.website-file', $film);
|
||||||
|
|
||||||
|
Livewire::test(ViewContentElement::class, ['record' => $film->getKey()])
|
||||||
|
->assertSeeHtml('<video controls')
|
||||||
|
->assertSeeHtml($url)
|
||||||
|
->assertSee('noch nicht für die Website freigegeben');
|
||||||
|
|
||||||
|
$this->get($url)->assertOk()->assertStreamedContent('0123456789');
|
||||||
|
$this->get($url, ['Range' => 'bytes=2-4'])->assertStatus(206)->assertStreamedContent('234');
|
||||||
|
$this->get($url, ['Range' => 'bytes=50-60'])->assertStatus(416);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_a_film_frame_of_the_website_file_becomes_the_preview_image(): void
|
||||||
|
{
|
||||||
|
$image = imagecreatetruecolor(4, 4);
|
||||||
|
ob_start();
|
||||||
|
imagejpeg($image);
|
||||||
|
$jpeg = ob_get_clean();
|
||||||
|
imagedestroy($image);
|
||||||
|
$this->app->bind(ThumbnailDeriver::class, fn () => new class($jpeg) extends ThumbnailDeriver
|
||||||
|
{
|
||||||
|
public function __construct(private string $jpeg) {}
|
||||||
|
|
||||||
|
public function jpegAtWebsiteFile(ContentElement $element, float $seconds): ?string
|
||||||
|
{
|
||||||
|
return $this->jpeg;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$film = app(ContentService::class)->createElement('film', 'film', 'Trailer');
|
||||||
|
$film->preview_path = 'teaser/'.$film->id.'/datei.mp4';
|
||||||
|
$film->save();
|
||||||
|
Storage::disk('media_derived')->put($film->preview_path, 'x');
|
||||||
|
$this->actingAs($this->editor(), 'staff');
|
||||||
|
|
||||||
|
Livewire::test(ViewContentElement::class, ['record' => $film->getKey()])
|
||||||
|
->set('bereich', 'vorschaubild')
|
||||||
|
->assertSee('Diese Stelle übernehmen')
|
||||||
|
->assertSee('Aus der Website-Datei')
|
||||||
|
->set('frameSecond', '12.5')
|
||||||
|
->call('adoptFrame')
|
||||||
|
->assertSet('pictureFeedback', 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.');
|
||||||
|
|
||||||
|
$film->refresh();
|
||||||
|
$this->assertSame('vorschau/element-'.$film->id.'.jpg', $film->thumbnail_path);
|
||||||
|
$this->assertSame('frame:0@12.5', $film->thumbnail_source);
|
||||||
|
$this->assertSame(0, $film->versions()->count());
|
||||||
|
Storage::disk('media_derived')->assertExists($film->thumbnail_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_frame_of_the_website_file_is_only_available_to_editors_and_for_a_film_with_a_file(): void
|
||||||
|
{
|
||||||
|
$film = app(ContentService::class)->createElement('film', 'film', 'Ohne Datei');
|
||||||
|
|
||||||
|
$this->get(route('content.website-frame', ['element' => $film, 'sekunde' => 3]))->assertRedirect();
|
||||||
|
|
||||||
|
$this->actingAs($this->editor(), 'staff');
|
||||||
|
$this->get(route('content.website-frame', ['element' => $film, 'sekunde' => 3]))->assertNotFound();
|
||||||
|
$this->get(route('content.website-frame', ['element' => $film]))->assertNotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_the_website_file_is_not_served_to_guests_or_without_a_file(): void
|
||||||
|
{
|
||||||
|
Storage::disk('media_derived')->put('teaser/1/datei.mp4', 'x');
|
||||||
|
$film = app(ContentService::class)->createElement('film', 'film', 'Trailer');
|
||||||
|
$film->preview_path = 'teaser/'.$film->id.'/datei.mp4';
|
||||||
|
$film->save();
|
||||||
|
Storage::disk('media_derived')->put($film->preview_path, 'x');
|
||||||
|
$leer = app(ContentService::class)->createElement('film', 'film', 'Ohne Datei');
|
||||||
|
|
||||||
|
$this->get(route('content.website-file', $film))->assertRedirect();
|
||||||
|
|
||||||
|
$this->actingAs($this->editor(), 'staff');
|
||||||
|
$this->get(route('content.website-file', $film))->assertOk();
|
||||||
|
$this->get(route('content.website-file', $leer))->assertNotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function editor(): User
|
||||||
|
{
|
||||||
|
$editor = User::factory()->redakteur()->create();
|
||||||
|
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||||
|
|
||||||
|
return $editor;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user