Wähle das Vorschaubild am Medium und nutze es als Standard in der Anzeige und in Modulen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f86032cb5f
commit
8e77defaca
18 files changed
+664
-26
No files matched your search
@@ -20,6 +20,7 @@ class ContentElement extends Model
|
||||
'summary',
|
||||
'thumbnail_path',
|
||||
'thumbnail_alt',
|
||||
'thumbnail_source',
|
||||
'thumbnail_error',
|
||||
'editorial_content_kind_id',
|
||||
'archived_at',
|
||||
|
||||
@@ -24,12 +24,48 @@ public function forElement(ContentElement $element): void
|
||||
}
|
||||
|
||||
if (in_array($element->output_class, ['film', 'audio'], true)) {
|
||||
$this->frame($element, $file);
|
||||
$this->frame($element, $version, $file);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->still($element, Storage::disk('media_derived'), $file, 'element-'.$element->id);
|
||||
$this->rememberElement($element, 'datei');
|
||||
}
|
||||
|
||||
public function forElementUpload(ContentElement $element, string $incoming): void
|
||||
{
|
||||
if (! str_starts_with($incoming, 'vorschau/') || str_contains($incoming, '..')) {
|
||||
$this->fail($element, 'Das Vorschaubild wurde nicht übernommen.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->still($element, Storage::disk('cms_incoming'), $incoming, 'element-'.$element->id);
|
||||
$this->rememberElement($element, 'eigen');
|
||||
}
|
||||
|
||||
public function forElementFrame(ContentElement $element, ContentElementVersion $version, float $seconds): void
|
||||
{
|
||||
if ($version->content_element_id !== $element->id || $element->output_class !== 'film') {
|
||||
$this->fail($element, 'Aus dieser Filmstelle ließ sich kein Vorschaubild erzeugen.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$bytes = $this->jpegAtVersion($version, $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:'.$version->id.'@'.$this->secondText($seconds));
|
||||
}
|
||||
|
||||
public function forCompositionUpload(Composition $composition, string $incoming): void
|
||||
@@ -166,7 +202,7 @@ private function secondText(float $seconds): string
|
||||
return rtrim(rtrim($text, '0'), '.') ?: '0';
|
||||
}
|
||||
|
||||
private function frame(ContentElement $element, string $file): void
|
||||
private function frame(ContentElement $element, ContentElementVersion $version, string $file): void
|
||||
{
|
||||
$binary = (new ExecutableFinder)->find('ffmpeg');
|
||||
$disk = Storage::disk('media_derived');
|
||||
@@ -200,8 +236,13 @@ private function frame(ContentElement $element, string $file): void
|
||||
}
|
||||
|
||||
$element->thumbnail_path = $target;
|
||||
$element->thumbnail_alt = $element->working_title;
|
||||
if (! filled($element->thumbnail_alt)) {
|
||||
$element->thumbnail_alt = $element->working_title;
|
||||
}
|
||||
$element->thumbnail_error = null;
|
||||
if ($element->output_class === 'film') {
|
||||
$element->thumbnail_source = 'frame:'.$version->id.'@0';
|
||||
}
|
||||
$element->save();
|
||||
}
|
||||
|
||||
@@ -243,7 +284,7 @@ private function still(ContentElement|Composition $subject, Filesystem $disk, st
|
||||
Storage::disk('media_derived')->put($path, $bytes);
|
||||
$subject->thumbnail_path = $path;
|
||||
|
||||
if (! ($subject instanceof Composition && filled($subject->thumbnail_alt))) {
|
||||
if (! filled($subject->thumbnail_alt)) {
|
||||
$subject->thumbnail_alt = $subject instanceof Composition ? $subject->designation : $subject->working_title;
|
||||
}
|
||||
|
||||
@@ -251,6 +292,18 @@ private function still(ContentElement|Composition $subject, Filesystem $disk, st
|
||||
$subject->save();
|
||||
}
|
||||
|
||||
private function rememberElement(ContentElement $element, string $source): void
|
||||
{
|
||||
$element->refresh();
|
||||
|
||||
if ($element->thumbnail_error !== null || ! filled($element->thumbnail_path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$element->thumbnail_source = $source;
|
||||
$element->save();
|
||||
}
|
||||
|
||||
private function rememberChoice(Composition $composition, string $source): void
|
||||
{
|
||||
$composition->refresh();
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
class ThumbnailRef
|
||||
{
|
||||
public static function url(string $route, string $kind, int $id, mixed $path): ?string
|
||||
{
|
||||
if (! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return route($route, ['kind' => $kind, 'subject' => $id]);
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,12 @@
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarService;
|
||||
use App\Domain\Catalog\ReleaseContent;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\ElementRevision;
|
||||
use App\Filament\Support\MediaUploadLimit;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use App\Jobs\DeriveThumbnail;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
@@ -102,9 +104,27 @@ public function form(Schema $schema): Schema
|
||||
return $options;
|
||||
})
|
||||
->helperText('Wirkt auf die Suche und legt keine neue Fassung an.'),
|
||||
FileUpload::make('thumbnail_upload')->label('Vorschaubild')
|
||||
Placeholder::make('thumbnail_current')->label('Aktuelles Vorschaubild')->content(function (): HtmlString {
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$url = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
||||
$caption = match ($element->thumbnail_source) {
|
||||
'eigen' => 'Eigenes Vorschaubild.',
|
||||
'datei' => 'Vorschaubild aus der Datei des Mediums.',
|
||||
default => '',
|
||||
};
|
||||
if (is_string($element->thumbnail_source) && preg_match('/^frame:\d+@([\d.]+)$/', $element->thumbnail_source, $match) === 1) {
|
||||
$caption = 'Vorschaubild aus dem Film bei '.$match[1].' Sekunden.';
|
||||
}
|
||||
if ($url === null) {
|
||||
return new HtmlString('Noch kein Vorschaubild. Eine Filmstelle wählst du beim Ansehen des Mediums.');
|
||||
}
|
||||
|
||||
return new HtmlString('<img src="'.e($url).'" alt="" style="width: 16rem; height: auto;">'.($caption !== '' ? '<p>'.e($caption).'</p>' : ''));
|
||||
}),
|
||||
FileUpload::make('thumbnail_upload')->label('Eigenes Vorschaubild')
|
||||
->disk('cms_incoming')->directory('vorschau')->visibility('private')->image()
|
||||
->helperText('Nur die Karte. Die Inhaltsfassung bleibt unverändert.'),
|
||||
->helperText('Gilt für die Anzeige und als Vorschlag in Modulen und Programmen. Eine Filmstelle wählst du beim Ansehen. Speichern legt keine Fassung an.'),
|
||||
CheckboxList::make('pillars')
|
||||
->label('Fachliche Säulen')
|
||||
->options(fn (): array => Pillar::query()->orderBy('name')->pluck('name', 'id')->all())
|
||||
@@ -209,10 +229,9 @@ protected function handleRecordUpdate(Model $record, array $data): Model
|
||||
$record->save();
|
||||
}
|
||||
if (is_string($data['thumbnail_upload'] ?? null) && $data['thumbnail_upload'] !== '') {
|
||||
$record->thumbnail_path = $data['thumbnail_upload'];
|
||||
$record->thumbnail_error = null;
|
||||
$record->thumbnail_alt = $record->working_title;
|
||||
$record->save();
|
||||
DeriveThumbnail::dispatch('element', $record->id, $data['thumbnail_upload']);
|
||||
}
|
||||
if (array_key_exists('dimension_ids', $data)) {
|
||||
$ids = array_map(intval(...), $data['dimension_ids'] ?? []);
|
||||
|
||||
@@ -9,11 +9,13 @@
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarService;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use App\Filament\Support\ElementRevision;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use App\Http\Controllers\ContentPreviewController;
|
||||
use App\Jobs\DeriveThumbnail;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
@@ -23,15 +25,26 @@
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Livewire\WithFileUploads;
|
||||
|
||||
class ViewContentElement extends ViewRecord
|
||||
{
|
||||
use ReportsDomainRules;
|
||||
use WithFileUploads;
|
||||
|
||||
protected static string $resource = ContentElementResource::class;
|
||||
|
||||
public ?int $fassung = null;
|
||||
|
||||
public string $frameSecond = '';
|
||||
|
||||
public string $thumbnailAlt = '';
|
||||
|
||||
public string $pictureFeedback = '';
|
||||
|
||||
public mixed $previewUpload = null;
|
||||
|
||||
public function mount(int|string $record): void
|
||||
{
|
||||
parent::mount($record);
|
||||
@@ -41,6 +54,8 @@ public function mount(int|string $record): void
|
||||
if ($requested > 0) {
|
||||
$this->fassung = $requested;
|
||||
}
|
||||
|
||||
$this->thumbnailAlt = (string) ($this->getRecord()->thumbnail_alt ?? '');
|
||||
}
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
@@ -61,6 +76,125 @@ public function showVersion(int $version): void
|
||||
$this->fassung = $version;
|
||||
}
|
||||
|
||||
public function adoptFrame(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$shown = $this->shownVersion();
|
||||
|
||||
if (! $shown instanceof ContentElementVersion || $element->output_class !== 'film') {
|
||||
$this->pictureFeedback = 'Für dieses Medium gibt es keine Filmstelle.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! is_numeric($this->frameSecond) || trim($this->frameSecond) === '') {
|
||||
$this->pictureFeedback = 'Wähle zuerst eine Zeitposition.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$seconds = (float) $this->frameSecond;
|
||||
|
||||
if ($seconds < 0 || $seconds > 7200) {
|
||||
$this->pictureFeedback = 'Die Zeitposition liegt außerhalb des Films.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->keepAlt($element);
|
||||
$element->thumbnail_error = null;
|
||||
$element->save();
|
||||
DeriveThumbnail::dispatch('element', $element->id, null, null, $shown->id, $seconds);
|
||||
$element->refresh();
|
||||
$this->pictureFeedback = $element->thumbnail_error
|
||||
?: 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.';
|
||||
}
|
||||
|
||||
public function storePreview(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
if (! $this->previewUpload instanceof TemporaryUploadedFile) {
|
||||
$this->pictureFeedback = 'Wähle zuerst eine Bilddatei.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$extension = strtolower($this->previewUpload->getClientOriginalExtension());
|
||||
|
||||
if (! in_array($extension, ['png', 'jpg', 'jpeg', 'webp'], true)) {
|
||||
$this->pictureFeedback = 'Das Vorschaubild muss eine Bilddatei sein.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$path = $this->previewUpload->storeAs(
|
||||
'vorschau',
|
||||
'karte-'.bin2hex(random_bytes(4)).'.'.$extension,
|
||||
'cms_incoming',
|
||||
);
|
||||
$this->previewUpload = null;
|
||||
|
||||
if (! is_string($path)) {
|
||||
$this->pictureFeedback = 'Das Vorschaubild wurde nicht übernommen.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->savePreviewImage($path);
|
||||
}
|
||||
|
||||
public function savePreviewImage(string $path): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$this->keepAlt($element);
|
||||
$element->thumbnail_error = null;
|
||||
$element->save();
|
||||
DeriveThumbnail::dispatch('element', $element->id, $path);
|
||||
$element->refresh();
|
||||
$this->pictureFeedback = $element->thumbnail_error
|
||||
?: 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.';
|
||||
}
|
||||
|
||||
public function useOwnImage(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
if ($element->output_class !== 'bild') {
|
||||
$this->pictureFeedback = 'Die Datei dieses Mediums ist kein Bild. Lade ein Vorschaubild hoch.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->keepAlt($element);
|
||||
$element->thumbnail_error = null;
|
||||
$element->save();
|
||||
DeriveThumbnail::dispatch('element', $element->id);
|
||||
$element->refresh();
|
||||
$this->pictureFeedback = $element->thumbnail_error
|
||||
?: 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.';
|
||||
}
|
||||
|
||||
public function framePreviewUrl(): ?string
|
||||
{
|
||||
$shown = $this->shownVersion();
|
||||
|
||||
if (! $shown instanceof ContentElementVersion || ! is_numeric($this->frameSecond) || trim($this->frameSecond) === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return route('editorial.frame', [
|
||||
'version' => $shown->id,
|
||||
'sekunde' => $this->frameSecond,
|
||||
]);
|
||||
}
|
||||
|
||||
public function deactivateAction(): Action
|
||||
{
|
||||
return Action::make('deactivate')
|
||||
@@ -158,9 +292,52 @@ private function viewerData(): array
|
||||
'pillars' => $element->pillars->pluck('name')->all(),
|
||||
'usage' => app(CatalogReading::class)->elementUsage($element),
|
||||
'canRevise' => ContentElementResource::editor(),
|
||||
'pictureUrl' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
||||
'pictureCaption' => $this->pictureCaption($element),
|
||||
];
|
||||
}
|
||||
|
||||
private function shownVersion(): ?ContentElementVersion
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$versions = $element->versions()->orderByDesc('number')->get();
|
||||
|
||||
return $versions->firstWhere('id', $this->fassung)
|
||||
?? $versions->first(fn (ContentElementVersion $version): bool => $version->status === ContentVersionStatus::Bereit)
|
||||
?? $versions->first();
|
||||
}
|
||||
|
||||
private function keepAlt(ContentElement $element): void
|
||||
{
|
||||
$alt = trim($this->thumbnailAlt);
|
||||
|
||||
if ($alt === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$element->thumbnail_alt = $alt;
|
||||
}
|
||||
|
||||
private function pictureCaption(ContentElement $element): string
|
||||
{
|
||||
$source = $element->thumbnail_source;
|
||||
|
||||
if (! is_string($source) || $source === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (preg_match('/^frame:\d+@([\d.]+)$/', $source, $match) === 1) {
|
||||
return 'Vorschaubild aus dem Film bei '.$match[1].' Sekunden.';
|
||||
}
|
||||
|
||||
return match ($source) {
|
||||
'eigen' => 'Eigenes Vorschaubild.',
|
||||
'datei' => 'Vorschaubild aus der Datei des Mediums.',
|
||||
default => '',
|
||||
};
|
||||
}
|
||||
|
||||
private function ownedVersion(int $id): ?ContentElementVersion
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
|
||||
@@ -645,17 +645,122 @@ public function cover(Composition $composition, array $members): array
|
||||
return ['url' => $own, 'note' => null, 'own' => true];
|
||||
}
|
||||
|
||||
$films = $this->filmPictures($members);
|
||||
$picture = $this->suggestPicture($members);
|
||||
|
||||
if (count($films) === 1) {
|
||||
if ($picture === null) {
|
||||
return ['url' => null, 'note' => null, 'own' => false];
|
||||
}
|
||||
|
||||
return [
|
||||
'url' => $this->cardUrl($picture['kind'], $picture['subject'], 'vorschau/gesetzt'),
|
||||
'note' => $picture['note'],
|
||||
'own' => false,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Das eigene Titelbild, sonst das erste Vorschaubild aus dem freigegebenen Aufbau.
|
||||
*
|
||||
* @return array{kind: string, subject: int, alt: string, note: string}|null
|
||||
*/
|
||||
public function visiblePicture(Composition $composition, ?CompositionVersion $version): ?array
|
||||
{
|
||||
if ($this->cardUrl('komposition', $composition->id, $composition->thumbnail_path) !== null) {
|
||||
return [
|
||||
'url' => $films[0]['image'],
|
||||
'note' => 'Vorschlag aus dem Film '.$films[0]['title'],
|
||||
'own' => false,
|
||||
'kind' => 'komposition',
|
||||
'subject' => $composition->id,
|
||||
'alt' => filled($composition->thumbnail_alt) ? (string) $composition->thumbnail_alt : $this->compositionTitle($composition),
|
||||
'note' => '',
|
||||
];
|
||||
}
|
||||
|
||||
return ['url' => null, 'note' => null, 'own' => false];
|
||||
if ($version === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$version->loadMissing('members');
|
||||
$members = [];
|
||||
|
||||
foreach ($version->members as $member) {
|
||||
$members[] = [
|
||||
'target' => $member->content_element_version_id
|
||||
? 'element:'.$member->content_element_version_id
|
||||
: 'composition:'.$member->nested_composition_version_id,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->suggestPicture($members);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $members
|
||||
* @param list<int> $seen
|
||||
* @return array{kind: string, subject: int, alt: string, note: string}|null
|
||||
*/
|
||||
private function suggestPicture(array $members, array $seen = []): ?array
|
||||
{
|
||||
foreach ($members as $member) {
|
||||
$target = (string) ($member['target'] ?? '');
|
||||
|
||||
if (preg_match('/^element:(\d+)$/', $target, $match) === 1) {
|
||||
$version = ContentElementVersion::query()->with('element')->find((int) $match[1]);
|
||||
$element = $version?->element;
|
||||
|
||||
if (! $element instanceof ContentElement || $this->cardUrl('element', $element->id, $element->thumbnail_path) === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = filled($element->display_title) ? $element->display_title : $element->working_title;
|
||||
|
||||
return [
|
||||
'kind' => 'element',
|
||||
'subject' => $element->id,
|
||||
'alt' => filled($element->thumbnail_alt) ? (string) $element->thumbnail_alt : $title,
|
||||
'note' => $element->output_class === 'film'
|
||||
? 'Vorschlag aus dem Film '.$title
|
||||
: 'Vorschlag aus '.$title,
|
||||
];
|
||||
}
|
||||
|
||||
if (preg_match('/^composition:(\d+)$/', $target, $match) !== 1 || in_array((int) $match[1], $seen, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$version = CompositionVersion::query()->with('composition', 'members')->find((int) $match[1]);
|
||||
|
||||
if (! $version instanceof CompositionVersion) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$nested = $version->composition;
|
||||
|
||||
if ($this->cardUrl('komposition', $nested->id, $nested->thumbnail_path) !== null) {
|
||||
return [
|
||||
'kind' => 'komposition',
|
||||
'subject' => $nested->id,
|
||||
'alt' => filled($nested->thumbnail_alt) ? (string) $nested->thumbnail_alt : $this->compositionTitle($nested),
|
||||
'note' => 'Vorschlag aus '.$this->compositionTitle($nested),
|
||||
];
|
||||
}
|
||||
|
||||
$children = [];
|
||||
|
||||
foreach ($version->members as $child) {
|
||||
$children[] = [
|
||||
'target' => $child->content_element_version_id
|
||||
? 'element:'.$child->content_element_version_id
|
||||
: 'composition:'.$child->nested_composition_version_id,
|
||||
];
|
||||
}
|
||||
|
||||
$picture = $this->suggestPicture($children, [...$seen, $version->id]);
|
||||
|
||||
if ($picture !== null) {
|
||||
return $picture;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function create(string $designation, CompositionKind $kind): Composition
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ReleaseStatus;
|
||||
use App\Domain\Catalog\StructureNode;
|
||||
@@ -14,6 +15,8 @@
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
use App\Domain\Media\MediaRendition;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
@@ -41,6 +44,7 @@ public function index(User $user): array
|
||||
$version = $release?->rootCompositionVersion;
|
||||
|
||||
if ($composition !== null && $version !== null && $this->display->isReleased($version)) {
|
||||
$picture = app(EditorialCatalog::class)->visiblePicture($composition, $version);
|
||||
$card = [
|
||||
'composition' => $composition,
|
||||
'version' => $version,
|
||||
@@ -49,6 +53,11 @@ public function index(User $user): array
|
||||
'kind' => $composition->editorialContentKind?->label
|
||||
?? ($composition->kind?->label()),
|
||||
'coverage' => $this->coverageLabel($user, $composition),
|
||||
'image' => $picture['alt'] ?? null,
|
||||
'image_url' => $picture === null ? null : route('member.thumbnail', [
|
||||
'kind' => $picture['kind'],
|
||||
'subject' => $picture['subject'],
|
||||
]),
|
||||
];
|
||||
$shelf = $composition->editorialContentKind?->slug === 'modul' ? 'modules' : 'programs';
|
||||
if ($shelf === 'modules') {
|
||||
@@ -65,12 +74,15 @@ public function index(User $user): array
|
||||
$key = $composition !== null
|
||||
? 'komposition-'.$composition->id
|
||||
: ($elementId !== null ? 'element-'.$elementId : 'artikel-'.$article->id);
|
||||
$imageUrl = $element === null ? null : ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path);
|
||||
$materials[$key] = [
|
||||
'article' => $article,
|
||||
'title' => app(CourseOutline::class)->title($article),
|
||||
'summary' => $element?->summary ?? $composition?->summary,
|
||||
'kind' => app(CourseOutline::class)->kindLabel($article),
|
||||
'coverage' => 'nutzbar',
|
||||
'image' => $imageUrl === null ? null : ($element->thumbnail_alt ?: $element->working_title),
|
||||
'image_url' => $imageUrl,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -98,6 +110,7 @@ public function program(User $user, Composition $composition): array
|
||||
|
||||
return [
|
||||
'composition' => $composition,
|
||||
'picture' => app(EditorialCatalog::class)->visiblePicture($composition, $version),
|
||||
'title' => filled($composition->display_title) ? $composition->display_title : $composition->designation,
|
||||
'summary' => $composition->summary,
|
||||
'kind' => $composition->editorialContentKind?->label
|
||||
@@ -120,10 +133,16 @@ private function present(User $user, StructureNode $node): array
|
||||
|
||||
$playback = 'file';
|
||||
|
||||
$poster = null;
|
||||
|
||||
if ($node->contentElementVersionId !== null) {
|
||||
$view = $this->open($user, $node->contentElementVersionId, $this->viewAction($node->outputClass));
|
||||
$download = $this->open($user, $node->contentElementVersionId, 'laden');
|
||||
$playback = MediaRendition::masterPath($node->contentElementVersionId) !== null ? 'hls' : 'file';
|
||||
if ($view !== null && $node->contentElementId !== null) {
|
||||
$path = ContentElement::query()->whereKey($node->contentElementId)->value('thumbnail_path');
|
||||
$poster = ThumbnailRef::url('member.thumbnail', 'element', $node->contentElementId, $path);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -133,6 +152,7 @@ private function present(User $user, StructureNode $node): array
|
||||
'output_class' => $node->outputClass,
|
||||
'playback' => $playback,
|
||||
'view_url' => $view,
|
||||
'poster_url' => $poster,
|
||||
'download_url' => $download,
|
||||
'program_url' => $this->programUrl($node),
|
||||
'children' => array_map(
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Media\ThumbnailDeriver;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
@@ -17,6 +18,8 @@ public function __construct(
|
||||
public readonly int $subjectId,
|
||||
public readonly ?string $incoming = null,
|
||||
public readonly ?int $fromElement = null,
|
||||
public readonly ?int $versionId = null,
|
||||
public readonly ?float $atSecond = null,
|
||||
) {}
|
||||
|
||||
public function handle(ThumbnailDeriver $deriver): void
|
||||
@@ -47,8 +50,26 @@ public function handle(ThumbnailDeriver $deriver): void
|
||||
|
||||
$element = ContentElement::query()->find($this->subjectId);
|
||||
|
||||
if ($element !== null) {
|
||||
$deriver->forElement($element);
|
||||
if ($element === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->versionId !== null && $this->atSecond !== null) {
|
||||
$version = ContentElementVersion::query()->find($this->versionId);
|
||||
|
||||
if ($version instanceof ContentElementVersion) {
|
||||
$deriver->forElementFrame($element, $version, $this->atSecond);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_string($this->incoming)) {
|
||||
$deriver->forElementUpload($element, $this->incoming);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$deriver->forElement($element);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user