Text: Einstellung „Text der Karte“ (Automatisch, Teaser, Kurzbeschreibung, Ausführliche Beschreibung). Automatisch bleibt wie bisher (Kurzbeschreibung, sonst Teaser). Eine ausdrückliche Wahl ersetzt nicht still durch ein anderes Feld; ist sie nicht gepflegt, bleibt die Karte ohne Text und die Vorschau nennt, wo sie zu pflegen ist. Der eigene Text der Karte hat weiter Vorrang. Einsatzhinweis und Lizenzvermerk bleiben intern. Film: Im Reiter „Medien“ lässt sich das Vorschaubild des Films oder eine gewählte Stelle als Kartenbild übernehmen. FilmStill zieht das Einzelbild einmal (bis 1600 px, nie vergrößert) und legt es über WebsiteIntake als gewöhnliches Bild-Medium ab; die Warteschlange leitet ab und gibt frei. Dieselbe Stelle ergibt dasselbe Medium (film_still_sources, additive Tabelle). Seitenaufrufe lesen nur die gespeicherte Datei und starten kein ffmpeg. Der Film bleibt geschützt; Traineranleitungen, archivierte und nicht bereitgestellte Filme sind ausgeschlossen. ThumbnailDeriver::jpegAtVersion behält seine Signatur, die Auflösungswahl steht in frameJpeg. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
192 lines
5.9 KiB
PHP
192 lines
5.9 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Support;
|
|
|
|
use App\Domain\Catalog\ContentElement;
|
|
use App\Domain\Catalog\DomainRuleException;
|
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
|
use App\Domain\Media\FilmStill;
|
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
|
use Filament\Notifications\Notification;
|
|
|
|
/**
|
|
* Bildauswahl im CMS über den gemeinsamen visuellen Picker (Dokument 14 §9) statt einer eigenen Auswahlliste.
|
|
* Ein Bildfeld (filament.cms.bild-feld) öffnet den Picker mit seinem Formularpfad; „Bild übernehmen“ schreibt die
|
|
* Kennung des Mediums in genau dieses Feld, auch im geöffneten Bausteindialog. Gespeichert wird weiterhin nur mit dem
|
|
* Seitenentwurf. Die Auswahl gibt kein Bild für die Website frei.
|
|
*/
|
|
trait ChoosesWebsiteImages
|
|
{
|
|
use ChoosesMedia;
|
|
|
|
/** Formularpfad des Bildfelds, in das die Auswahl übernommen wird. */
|
|
public ?string $bildZiel = null;
|
|
|
|
public function openWebsiteImagePicker(string $pfad): void
|
|
{
|
|
if (preg_match('/^(data|mountedActions\.\d+\.data)(\.[A-Za-z0-9_-]+)+$/', $pfad) !== 1) {
|
|
return;
|
|
}
|
|
|
|
$this->resetPicker('website-bild');
|
|
$this->pickerKind = 'bild';
|
|
$this->bildZiel = $pfad;
|
|
$this->forceRenderForPicker();
|
|
}
|
|
|
|
/**
|
|
* Medien- und Materialkarte: das Vorschaubild des Films als Bild für die Website übernehmen. Es entsteht ein Bild
|
|
* im Medienmanager (einmal gespeichert), das im Bildfeld ausgewählt wird. Die Datei des Films bleibt geschützt.
|
|
*/
|
|
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()));
|
|
}
|
|
|
|
/**
|
|
* @param callable(FilmStill, ContentElement): ContentElement $make
|
|
*/
|
|
private function adoptFilmStill(string $pfad, int $elementId, callable $make): void
|
|
{
|
|
abort_unless(ContentElementResource::editor(), 403);
|
|
|
|
if (preg_match('/^(data|mountedActions\.\d+\.data)(\.[A-Za-z0-9_-]+)+\.image$/', $pfad) !== 1) {
|
|
return;
|
|
}
|
|
|
|
$film = ContentElement::query()->with('editorialContentKind')->find($elementId);
|
|
|
|
if (! $film instanceof ContentElement) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
$still = $make(app(FilmStill::class), $film);
|
|
} catch (DomainRuleException $exception) {
|
|
Notification::make()->danger()->title($exception->getMessage())->send();
|
|
|
|
return;
|
|
}
|
|
|
|
data_set($this, $pfad, $still->id);
|
|
Notification::make()
|
|
->success()
|
|
->title('Im Medienmanager angelegt: „'.($still->display_title ?: $still->working_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();
|
|
}
|
|
|
|
/**
|
|
* Filament rendert bei offenen Aktionsdialogen nur den Dialogteil neu; der Picker liegt darüber und braucht die
|
|
* ganze Seite.
|
|
*/
|
|
public function hydrateChoosesWebsiteImages(): void
|
|
{
|
|
if ($this->pickerOpen) {
|
|
$this->forceRenderForPicker();
|
|
}
|
|
}
|
|
|
|
public function pickerAllowsMany(): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public function closePicker(): void
|
|
{
|
|
$this->pickerOpen = false;
|
|
$this->pickerSelected = '';
|
|
$this->pickerInspected = '';
|
|
$this->pickerMarked = [];
|
|
$this->bildZiel = null;
|
|
$this->forceRenderForPicker();
|
|
}
|
|
|
|
public function confirmPicker(): void
|
|
{
|
|
$target = array_key_first($this->pickerMarked);
|
|
$ziel = $this->bildZiel;
|
|
|
|
if ($target === null || $ziel === null) {
|
|
return;
|
|
}
|
|
|
|
$row = app(EditorialCatalog::class)->rowForTarget((string) $target, 0, allowDraft: true);
|
|
$element = isset($row['element_id']) ? ContentElement::query()->find((int) $row['element_id']) : null;
|
|
|
|
if (! $element instanceof ContentElement || ! WebsiteImage::isSelectable($element)) {
|
|
Notification::make()->danger()->title('Dieses Medium kann nicht als Website-Bild gewählt werden.')->send();
|
|
|
|
return;
|
|
}
|
|
|
|
data_set($this, $ziel, $element->id);
|
|
$this->closePicker();
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function pickerKinds(): array
|
|
{
|
|
return ['bild' => 'Bilder'];
|
|
}
|
|
|
|
public function pickerTitle(): string
|
|
{
|
|
return 'Bild aus dem Medienmanager';
|
|
}
|
|
|
|
public function pickerConfirmLabel(): string
|
|
{
|
|
return 'Bild übernehmen';
|
|
}
|
|
|
|
/**
|
|
* @return array{art: string, titel: string}
|
|
*/
|
|
public function pickerKontext(): array
|
|
{
|
|
$pfad = property_exists($this, 'record') && is_object($this->record ?? null) ? (string) ($this->record->path ?? '') : '';
|
|
|
|
return ['art' => 'die Seite', 'titel' => $pfad !== '' ? $pfad : 'neue Seite'];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function presentationRoleOptions(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>|null
|
|
*/
|
|
public function pickerReplacing(): ?array
|
|
{
|
|
return null;
|
|
}
|
|
|
|
private function forceRenderForPicker(): void
|
|
{
|
|
if (method_exists($this, 'forceRender')) {
|
|
$this->forceRender();
|
|
}
|
|
}
|
|
}
|