Die Karte spielt den für die Website freigegebenen Trailer (Rolle Trailer, sonst Vorschauclip, bei einem Film ersatzweise sein Teaser) stumm beim Überfahren mit der Maus ab, am Handy mit Tippen, per Tastatur über die Schaltfläche. Reduzierte Bewegung und Datensparmodus starten nichts von selbst; der Clip wird erst beim ersten Start geladen. Ohne Freigabe bleibt das Kartenbild, die Redaktionsvorschau nennt den Grund. Neue Einstellung "Trailer auf der Karte" je Karte (ADR-43). Die Route website.media beantwortet Bereichsabrufe (206/416) für Filme und Hörstücke, damit Safari und iOS abspielen. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
99 lines
3.9 KiB
PHP
99 lines
3.9 KiB
PHP
<?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];
|
|
}
|
|
}
|