Lasse Präsentationsmedien ohne Inhaltsfassung zu.
Bilder, Filme und Hörstücke lassen sich zuordnen und für die Website freigeben, ohne eine fachliche Fassung anzulegen. Unterrichtsfilme behalten die Teaserfassung an ihrer bereitgestellten Fassung. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
5590225f4f
commit
7b325f0d66
25 files changed
+734
-93
No files matched your search
@@ -65,6 +65,10 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
|
||||
return $this->draftCompositionRow((int) $draftMatch[1], $exceptCompositionId, $allowSelf);
|
||||
}
|
||||
|
||||
if (preg_match('/^medium:(\d+)$/', $target, $mediumMatch) === 1) {
|
||||
return $this->rowForPresentationMedium((int) $mediumMatch[1]);
|
||||
}
|
||||
|
||||
if (preg_match('/^(element|composition):(\d+)$/', $target, $match) !== 1) {
|
||||
return null;
|
||||
}
|
||||
@@ -388,6 +392,105 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Bestandssuche für Präsentationsmedien.
|
||||
* Fassungen bleiben im didaktischen Aufbau. Bilder, Filme und Hörstücke ohne Inhaltsfassung kommen dazu.
|
||||
*
|
||||
* @return array{items: list<array<string, string|null>>, more: bool}
|
||||
*/
|
||||
public function presentationBrowse(string $query): array
|
||||
{
|
||||
$catalog = $this->browse($query, 'alle', '', 0, elementsOnly: true);
|
||||
$seen = [];
|
||||
|
||||
foreach ($catalog['items'] as $item) {
|
||||
if (isset($item['element_id'])) {
|
||||
$seen[(int) $item['element_id']] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$query = trim($query);
|
||||
$like = '%'.str_replace(['%', '_'], ['', ''], $query).'%';
|
||||
$elements = ContentElement::query()
|
||||
->with('editorialContentKind')
|
||||
->whereIn('output_class', ['bild', 'film', 'audio'])
|
||||
->whereNull('archived_at')
|
||||
->whereDoesntHave('versions')
|
||||
->where(function ($builder): void {
|
||||
$builder->whereNull('editorial_content_kind_id')
|
||||
->orWhereDoesntHave('editorialContentKind', function ($kind): void {
|
||||
$kind->where('slug', 'traineranleitung');
|
||||
});
|
||||
})
|
||||
->when($query !== '', function ($builder) use ($like): void {
|
||||
$builder->where(function ($inner) use ($like): void {
|
||||
$inner->where('working_title', 'like', $like)
|
||||
->orWhere('display_title', 'like', $like)
|
||||
->orWhere('teaser', 'like', $like)
|
||||
->orWhere('search_terms', 'like', $like)
|
||||
->orWhere('summary', 'like', $like);
|
||||
});
|
||||
})
|
||||
->orderBy('working_title')
|
||||
->limit(48)
|
||||
->get();
|
||||
|
||||
foreach ($elements as $element) {
|
||||
if (isset($seen[$element->id])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$row = $this->rowForPresentationMedium($element->id);
|
||||
|
||||
if ($row !== null) {
|
||||
$catalog['items'][] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
return $catalog;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string|null>|null
|
||||
*/
|
||||
private function rowForPresentationMedium(int $id): ?array
|
||||
{
|
||||
$element = ContentElement::query()->with('editorialContentKind')->find($id);
|
||||
|
||||
if (! $element instanceof ContentElement
|
||||
|| $element->archived_at !== null
|
||||
|| ! in_array($element->output_class, ['bild', 'film', 'audio'], true)
|
||||
|| $element->editorialContentKind?->slug === 'traineranleitung') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$kind = $element->editorialContentKind?->label ?: $this->outputLabel((string) $element->output_class);
|
||||
$title = filled($element->display_title) ? $element->display_title : $element->working_title;
|
||||
|
||||
return [
|
||||
'target' => 'medium:'.$element->id,
|
||||
'element_id' => (string) $element->id,
|
||||
'title' => $title,
|
||||
'kind' => $kind,
|
||||
'output' => (string) $element->output_class,
|
||||
'body' => '',
|
||||
'summary' => (string) ($element->summary ?: $element->description ?: ''),
|
||||
'medium_description' => (string) ($element->description ?? ''),
|
||||
'usage_note' => (string) ($element->usage_note ?? ''),
|
||||
'license_note' => (string) ($element->license_note ?? ''),
|
||||
'tone' => $this->tone((string) $element->output_class, $kind),
|
||||
'image' => $element->output_class === 'bild'
|
||||
? $this->cardUrl('element', $element->id, $element->thumbnail_path)
|
||||
: null,
|
||||
'version_label' => 'Ohne Inhaltsfassung',
|
||||
'committed' => false,
|
||||
'identity' => 'medium:'.$element->id,
|
||||
'open_url' => ContentElementResource::getUrl('view', ['record' => $element]),
|
||||
'open_label' => 'Medium ansehen',
|
||||
'edit_url' => ContentElementResource::getUrl('view', ['record' => $element]),
|
||||
];
|
||||
}
|
||||
|
||||
public function tone(string $outputClass, string $kindLabel): string
|
||||
{
|
||||
$value = mb_strtolower($outputClass.' '.$kindLabel);
|
||||
|
||||
@@ -27,7 +27,7 @@ trait ManagesEditorialSurface
|
||||
|
||||
public string $presentationPick = '';
|
||||
|
||||
public bool $bindToVersion = true;
|
||||
public bool $bindToVersion = false;
|
||||
|
||||
public string $deskFeedback = '';
|
||||
|
||||
@@ -90,7 +90,7 @@ public function presentationRoleOptions(): array
|
||||
*/
|
||||
public function presentationChoices(): array
|
||||
{
|
||||
return app(EditorialCatalog::class)->browse($this->presentationQuery, 'alle', '', 0, elementsOnly: true);
|
||||
return app(EditorialCatalog::class)->presentationBrowse($this->presentationQuery);
|
||||
}
|
||||
|
||||
public function assignPickedPresentation(): void
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Domain\Media\PresentationFile;
|
||||
use App\Jobs\DeriveThumbnail;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
@@ -39,6 +41,10 @@ public static function fields(bool $creating, ?ContentElement $element = null):
|
||||
$fields[] = self::fileField()
|
||||
->visible(fn ($get): bool => filled($get('shape')) && $get('shape') !== 'text')
|
||||
->required(fn ($get): bool => filled($get('shape')) && $get('shape') !== 'text');
|
||||
$fields[] = Checkbox::make('without_version')
|
||||
->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.')
|
||||
->visible(fn ($get): bool => in_array($get('shape'), ['film', 'audio', 'bild'], true));
|
||||
} elseif ($element?->output_class === 'text') {
|
||||
$fields[] = Textarea::make('body')->label('Text')->rows(8)->required();
|
||||
}
|
||||
@@ -120,13 +126,17 @@ public static function create(array $data, bool $hold): ContentElement
|
||||
throw new DomainRuleException('Diese Datei passt nicht zur gewählten Art.');
|
||||
}
|
||||
|
||||
$metadata = ['incoming' => $incoming];
|
||||
|
||||
if ($hold) {
|
||||
$metadata['hold'] = true;
|
||||
$service->draftElementVersion($element, null, $metadata);
|
||||
if (! empty($data['without_version']) && in_array($output, ['bild', 'film', 'audio'], true)) {
|
||||
app(PresentationFile::class)->store($element, $incoming);
|
||||
} else {
|
||||
$service->publishElementVersion($element, null, $metadata);
|
||||
$metadata = ['incoming' => $incoming];
|
||||
|
||||
if ($hold) {
|
||||
$metadata['hold'] = true;
|
||||
$service->draftElementVersion($element, null, $metadata);
|
||||
} else {
|
||||
$service->publishElementVersion($element, null, $metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user