Lasse Präsentationsmedien ohne Inhaltsfassung zu.
CI Feature / test (push) Successful in 53s
Deploy Test / test (push) Successful in 48s
Deploy Test / deploy (push) Successful in 22s

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:
LarsandCursor committed 2026-11-19 08:20:35 +01:00
1 parent 5590225f4f
commit 7b325f0d66
25 files changed
+734 -93

No files matched your search

+103
View File
@@ -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);