columns(1)->components([
Placeholder::make('open')->label('Medium')->content(function (): HtmlString {
$url = ContentElementResource::getUrl('view', ['record' => $this->getRecord()]);
return new HtmlString('Medium und Fassungen ansehen');
}),
TextInput::make('working_title')->label('Arbeitstitel')->required(),
TextInput::make('display_title')->label('Anzeigetitel')
->helperText('Erscheint in der Bibliothek. Leer lässt den Arbeitstitel stehen. Speichern legt keine Fassung an.'),
Textarea::make('summary')->label('Kurzbeschreibung')->rows(3),
Textarea::make('description')->label('Beschreibung')->rows(4)
->helperText('Allgemeine Beschreibung des Mediums. Gilt nicht für eine einzelne Fassung und nicht nur für ein Modul.'),
Textarea::make('usage_note')->label('Hinweise für den Einsatz')->rows(4)
->helperText('Gilt für das Medium in jeder Verwendung. Speichern legt keine Fassung an.'),
Textarea::make('license_note')->label('Interner Lizenzvermerk')->rows(3)
->helperText('Nur in der Verwaltung sichtbar. Erscheint nicht in der Bibliothek und nicht auf der Website.'),
Select::make('editorial_content_kind_id')
->label('Inhaltsart')
->options(fn (): array => EditorialContentKind::selectOptions())
->nullable()
->helperText('Optional für Bibliothek und Website. Ändert weder die Ausgabeart noch eine Fassung.'),
Placeholder::make('usage')->label('Verwendung')->content(function (): HtmlString {
/** @var ContentElement $element */
$element = $this->getRecord();
$versionIds = $element->versions()->pluck('id');
$compositionIds = [];
foreach ($element->versions as $version) {
$compositionIds = [...$compositionIds, ...app(ContentService::class)->containingCompositionIds($version)];
}
$names = Composition::query()->whereIn('id', array_unique($compositionIds))->orderBy('designation')->pluck('designation')->all();
$articles = ReleaseContent::query()
->whereIn('content_element_version_id', $versionIds)
->with('release.article')
->get()
->map(fn (ReleaseContent $content): string => 'Lizenzartikel '.($content->release->article->code ?? ''))
->unique()
->all();
$lines = [...array_map(fn (string $name): string => 'Enthalten in '.$name, $names), ...$articles];
return new HtmlString($lines === [] ? 'Noch in keinem Modul, Programm oder Lizenzartikel.' : implode('
', array_map(e(...), $lines)));
}),
CheckboxList::make('dimension_ids')->label('Fachliche Einordnung')
->options(function (): array {
$options = [];
foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) {
foreach ($dimension->values as $value) {
$options[$value->id] = $dimension->label.': '.$value->label;
}
}
return $options;
})
->helperText('Wirkt auf die Suche und legt keine neue Fassung an.'),
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(''.($caption !== '' ? '
'.e($caption).'
' : '')); }), FileUpload::make('thumbnail_upload')->label('Eigenes Vorschaubild') ->disk('cms_incoming')->directory('vorschau')->visibility('private')->image() ->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()) ->helperText('Ein Medium kann mehreren Säulen zugeordnet sein. Weitere Säulen legst du unter Fachliche Säulen an.') ->columns(1), ]); } public static function uploadField(): FileUpload { return FileUpload::make('incoming') ->label('Datei') ->disk('cms_incoming') ->directory('inhalte') ->visibility('private') ->maxSize(MediaUploadLimit::KILOBYTES) ->helperText('Film, Audio, Bild oder PDF bis 2 GB.'); } protected function getHeaderActions(): array { return [ Action::make('view') ->label('Ansehen') ->url(fn (): string => ContentElementResource::getUrl('view', ['record' => $this->getRecord()])), Action::make('revise') ->label('Neue Fassung anlegen') ->schema(fn (): array => ElementRevision::fields($this->getRecord())) ->action(function (array $data): void { $this->report(function () use ($data): string { /** @var ContentElement $element */ $element = $this->getRecord(); return ElementRevision::publish($element, $data); }, 'Die neue Fassung ist angelegt.'); $this->getRecord()->unsetRelation('versions'); }), Action::make('delete') ->label('Löschen') ->color('danger') ->requiresConfirmation() ->visible(fn (): bool => $this->getRecord()->versions()->doesntExist()) ->action(function (): void { $this->getRecord()->delete(); $this->redirect(ContentElementResource::getUrl('index')); }), ]; } protected function getSaveFormAction(): Action { return parent::getSaveFormAction()->label('Speichern'); } protected function getSavedNotificationTitle(): ?string { return 'Gespeichert. Es gibt keine neue Fassung.'; } /** * @param array