diff --git a/app/Domain/Catalog/Composition.php b/app/Domain/Catalog/Composition.php index 196f66d..f5e881a 100644 --- a/app/Domain/Catalog/Composition.php +++ b/app/Domain/Catalog/Composition.php @@ -11,8 +11,10 @@ class Composition extends Model protected $fillable = [ 'designation', 'display_title', + 'teaser', 'summary', 'description', + 'search_terms', 'thumbnail_path', 'thumbnail_alt', 'thumbnail_source', diff --git a/app/Domain/Catalog/ContentElement.php b/app/Domain/Catalog/ContentElement.php index cde9883..9eb736f 100644 --- a/app/Domain/Catalog/ContentElement.php +++ b/app/Domain/Catalog/ContentElement.php @@ -14,6 +14,7 @@ class ContentElement extends Model 'output_class', 'working_title', 'display_title', + 'teaser', 'description', 'usage_note', 'license_note', @@ -22,6 +23,7 @@ class ContentElement extends Model 'website_released_at', 'website_public_path', 'summary', + 'search_terms', 'thumbnail_path', 'thumbnail_alt', 'thumbnail_source', diff --git a/app/Domain/Catalog/EditorialProfile.php b/app/Domain/Catalog/EditorialProfile.php new file mode 100644 index 0000000..a870b53 --- /dev/null +++ b/app/Domain/Catalog/EditorialProfile.php @@ -0,0 +1,51 @@ + $texts + */ + public function __construct( + public ?string $workingTitle, + public array $texts, + public ?string $searchTerms, + public string $searchOrigin, + public ?string $kindLabel, + public ?Model $source, + ) {} + + public function text(string $field): ResolvedText + { + return $this->texts[$field] ?? new ResolvedText(null, 'leer', null); + } + + public function value(string $field): ?string + { + return $this->text($field)->value; + } + + public function origin(string $field): string + { + return $this->text($field)->origin; + } + + public function originLabel(string $field): string + { + $text = $this->text($field); + + return match ($text->origin) { + 'eigen' => 'Eigene Angabe', + 'variante' => 'Abweichung für '.($text->label ?? 'diesen Kontext'), + 'quelle' => 'Übernommen von '.($text->label ?? 'der fachlichen Quelle'), + default => 'Keine Angabe', + }; + } +} diff --git a/app/Domain/Catalog/EditorialProfileReader.php b/app/Domain/Catalog/EditorialProfileReader.php new file mode 100644 index 0000000..aa5d44d --- /dev/null +++ b/app/Domain/Catalog/EditorialProfileReader.php @@ -0,0 +1,225 @@ + 'Öffentliche Kachel', + 'detail' => 'Öffentliche Detailvorstellung', + 'bibliothek' => 'Mitgliederbibliothek', + 'trainer' => 'Fachliche Traineransicht', + 'artikel' => 'Lizenzartikelpräsentation', + 'cms' => 'CMS-Teaser', + 'suche' => 'Suchergebnis', + ]; + + public const TEXT_FIELDS = ['display_title', 'teaser', 'summary', 'description']; + + public function read(Model $subject, ?string $audience = null): EditorialProfile + { + if ($audience !== null && ! array_key_exists($audience, self::AUDIENCES)) { + throw new DomainRuleException('Diese Zielgruppe ist nicht vorgesehen.'); + } + + $source = $subject instanceof LicenseArticle ? $this->sourceOf($subject) : null; + $texts = []; + + foreach (self::TEXT_FIELDS as $field) { + $texts[$field] = $this->resolve($subject, $field, $audience, $source); + } + + $search = $this->own($subject, 'search_terms'); + $searchOrigin = 'eigen'; + + if ($search === null && $source instanceof Model) { + $search = $this->own($source, 'search_terms'); + $searchOrigin = $search === null ? 'leer' : 'quelle'; + } + + if ($search === null) { + $searchOrigin = 'leer'; + } + + return new EditorialProfile( + workingTitle: $this->workingTitle($subject), + texts: $texts, + searchTerms: $search, + searchOrigin: $searchOrigin, + kindLabel: $subject->editorialContentKind?->label + ?? ($source?->editorialContentKind?->label), + source: $source, + ); + } + + public function sourceOf(LicenseArticle $article): ?Model + { + $release = $article->relationLoaded('currentRelease') + ? $article->currentRelease + : $article->currentRelease()->first(); + + if (! $release instanceof ArticleRelease) { + return null; + } + + $elementId = $release->root_element_version_id; + $compositionId = $release->root_composition_version_id; + + if (($elementId === null) === ($compositionId === null)) { + return null; + } + + if ($elementId !== null) { + return ContentElementVersion::query()->with('element.editorialContentKind')->find($elementId)?->element; + } + + return CompositionVersion::query()->with('composition.editorialContentKind')->find($compositionId)?->composition; + } + + public function putVariant(Model $subject, string $field, string $audience, ?string $body, ?User $actor = null): string + { + if (! in_array($field, self::TEXT_FIELDS, true) || ! array_key_exists($audience, self::AUDIENCES)) { + throw new DomainRuleException('Diese Abweichung ist nicht vorgesehen.'); + } + + $body = is_string($body) ? trim($body) : ''; + $existing = $this->variant($subject, $field, $audience); + + if ($body === '') { + if ($existing instanceof EditorialTextVariant) { + $this->record($subject, $audience, $field, $existing->body, null, $actor); + $existing->delete(); + } + + return 'Die abweichende Formulierung ist entfernt. Es gilt wieder die zentrale Angabe.'; + } + + if ($existing instanceof EditorialTextVariant && $existing->body === $body) { + return 'Die abweichende Formulierung ist unverändert.'; + } + + $this->record($subject, $audience, $field, $existing?->body, $body, $actor); + + EditorialTextVariant::query()->updateOrCreate( + [ + 'subject_type' => $subject->getMorphClass(), + 'subject_id' => $subject->getKey(), + 'field' => $field, + 'audience' => $audience, + ], + ['body' => $body], + ); + + return 'Die abweichende Formulierung gilt nur für '.self::AUDIENCES[$audience].'. Die zentrale Angabe bleibt.'; + } + + public function forgetVariant(Model $subject, EditorialTextVariant $variant, ?User $actor = null): void + { + if ($variant->subject_type !== $subject->getMorphClass() || (int) $variant->subject_id !== (int) $subject->getKey()) { + throw new DomainRuleException('Diese Abweichung gehört zu einem anderen Objekt.'); + } + + $this->record($subject, $variant->audience, $variant->field, $variant->body, null, $actor); + $variant->delete(); + } + + private function resolve(Model $subject, string $field, ?string $audience, ?Model $source): ResolvedText + { + if ($audience !== null) { + $variant = $this->variant($subject, $field, $audience); + + if ($variant instanceof EditorialTextVariant && trim($variant->body) !== '') { + return new ResolvedText(trim($variant->body), 'variante', self::AUDIENCES[$audience]); + } + } + + $own = $this->own($subject, $field); + + if ($own !== null) { + return new ResolvedText($own, 'eigen', null); + } + + if ($source instanceof Model) { + $fromSource = $this->resolve($source, $field, $audience, null); + + if ($fromSource->value !== null) { + return new ResolvedText($fromSource->value, 'quelle', $this->sourceLabel($source)); + } + } + + return new ResolvedText(null, 'leer', null); + } + + private function variant(Model $subject, string $field, string $audience): ?EditorialTextVariant + { + return EditorialTextVariant::query() + ->where('subject_type', $subject->getMorphClass()) + ->where('subject_id', $subject->getKey()) + ->where('field', $field) + ->where('audience', $audience) + ->first(); + } + + private function own(Model $subject, string $field): ?string + { + $value = $subject->getAttribute($field); + + if (! is_string($value)) { + return null; + } + + $value = trim($value); + + return $value === '' ? null : $value; + } + + private function workingTitle(Model $subject): ?string + { + if ($subject instanceof Composition) { + return $this->own($subject, 'designation'); + } + + if ($subject instanceof LicenseArticle) { + return $this->own($subject, 'working_title') ?? $this->own($subject, 'code'); + } + + return $this->own($subject, 'working_title'); + } + + private function sourceLabel(Model $source): string + { + if ($source instanceof Composition) { + return (string) ($source->display_title ?: $source->designation); + } + + if ($source instanceof ContentElement) { + return (string) ($source->display_title ?: $source->working_title); + } + + return 'der fachlichen Quelle'; + } + + private function record(Model $subject, string $audience, string $field, ?string $before, ?string $after, ?User $actor): void + { + IdentityChange::query()->create([ + 'subject_type' => $subject->getMorphClass(), + 'subject_id' => $subject->getKey(), + 'field' => 'variante:'.$audience.':'.$field, + 'before' => $before, + 'after' => $after, + 'actor_id' => $actor?->id, + 'occurred_at' => now(), + ]); + } +} diff --git a/app/Domain/Catalog/EditorialTextVariant.php b/app/Domain/Catalog/EditorialTextVariant.php new file mode 100644 index 0000000..a2f5332 --- /dev/null +++ b/app/Domain/Catalog/EditorialTextVariant.php @@ -0,0 +1,16 @@ +belongsTo(self::class, 'successor_of_id'); } + + public function editorialContentKind(): BelongsTo + { + return $this->belongsTo(EditorialContentKind::class); + } } diff --git a/app/Domain/Catalog/PresentationAssignment.php b/app/Domain/Catalog/PresentationAssignment.php new file mode 100644 index 0000000..3bdba06 --- /dev/null +++ b/app/Domain/Catalog/PresentationAssignment.php @@ -0,0 +1,33 @@ +belongsTo(PresentationRole::class, 'presentation_role_id'); + } + + public function element(): BelongsTo + { + return $this->belongsTo(ContentElement::class, 'content_element_id'); + } + + public function sourceVersion(): BelongsTo + { + return $this->belongsTo(ContentElementVersion::class, 'source_version_id'); + } +} diff --git a/app/Domain/Catalog/PresentationMedia.php b/app/Domain/Catalog/PresentationMedia.php new file mode 100644 index 0000000..5b42dec --- /dev/null +++ b/app/Domain/Catalog/PresentationMedia.php @@ -0,0 +1,269 @@ +> + */ + public function rows(Model $subject): array + { + $assignments = PresentationAssignment::query() + ->with(['role', 'element.editorialContentKind', 'sourceVersion']) + ->where('subject_type', $subject->getMorphClass()) + ->where('subject_id', $subject->getKey()) + ->orderBy('position') + ->orderBy('id') + ->get(); + + $rows = []; + + foreach ($assignments as $assignment) { + $element = $assignment->element; + $released = $element instanceof ContentElement && $this->website->present($element) !== null; + $binding = $this->binding($assignment); + + $rows[] = [ + 'id' => $assignment->id, + 'role' => (string) $assignment->role?->slug, + 'role_label' => (string) ($assignment->role?->label ?? ''), + 'ordered' => (bool) $assignment->role?->ordered, + 'position' => (int) $assignment->position, + 'standard' => $assignment->role?->slug === 'titelbild', + 'element_id' => (int) $assignment->content_element_id, + 'title' => $element instanceof ContentElement + ? (string) ($element->display_title ?: $element->working_title) + : 'Medium fehlt', + 'kind' => $element?->editorialContentKind?->label, + 'output' => $element instanceof ContentElement ? (string) $element->output_class : '', + 'released' => $released, + 'release_label' => $released ? 'Für die Website freigegeben' : 'Nicht für die Website freigegeben', + 'binding' => $binding, + ]; + } + + return $rows; + } + + public function assign(Model $subject, string $roleSlug, int $elementId, ?int $sourceVersionId, ?User $actor = null): string + { + $role = PresentationRole::query()->where('slug', $roleSlug)->first(); + $element = ContentElement::query()->find($elementId); + + if (! $role instanceof PresentationRole || ! $element instanceof ContentElement) { + throw new DomainRuleException('Rolle oder Medium fehlt.'); + } + + if ($element->archived_at !== null) { + throw new DomainRuleException('Ein archiviertes Medium wird nicht zugeordnet.'); + } + + if ($subject instanceof ContentElement && (int) $subject->getKey() === (int) $element->id) { + throw new DomainRuleException('Ein Medium kann nicht seine eigene Präsentation sein.'); + } + + $source = $this->checkedSource($subject, $element, $sourceVersionId); + + $existing = PresentationAssignment::query() + ->where('subject_type', $subject->getMorphClass()) + ->where('subject_id', $subject->getKey()) + ->where('presentation_role_id', $role->id) + ->where('content_element_id', $element->id) + ->first(); + + if ($existing instanceof PresentationAssignment) { + if ((int) $existing->source_version_id !== (int) ($source?->id ?? 0) && ($source !== null || $existing->source_version_id !== null)) { + $existing->source_version_id = $source?->id; + $existing->save(); + $this->record($subject, null, $role->label.': '.$element->working_title, $actor); + } + + return $element->working_title.' ist in dieser Rolle bereits zugeordnet.'; + } + + if (! $role->multiple) { + PresentationAssignment::query() + ->where('subject_type', $subject->getMorphClass()) + ->where('subject_id', $subject->getKey()) + ->where('presentation_role_id', $role->id) + ->delete(); + } + + $position = (int) PresentationAssignment::query() + ->where('subject_type', $subject->getMorphClass()) + ->where('subject_id', $subject->getKey()) + ->where('presentation_role_id', $role->id) + ->max('position') + 1; + + PresentationAssignment::query()->create([ + 'subject_type' => $subject->getMorphClass(), + 'subject_id' => $subject->getKey(), + 'content_element_id' => $element->id, + 'presentation_role_id' => $role->id, + 'position' => max(1, $position), + 'source_version_id' => $source?->id, + ]); + + $this->record($subject, null, $role->label.': '.$element->working_title, $actor); + + return $element->working_title.' ist als '.$role->label.' zugeordnet. Es entsteht keine Fassung und keine Freigabe.'; + } + + public function detach(Model $subject, int $assignmentId, ?User $actor = null): string + { + $assignment = $this->owned($subject, $assignmentId); + $label = ($assignment->role?->label ?? 'Präsentation').': '.($assignment->element?->working_title ?? ''); + $assignment->delete(); + $this->record($subject, $label, null, $actor); + + return 'Die Zuordnung ist entfernt. Das Medium bleibt im Bestand.'; + } + + public function move(Model $subject, int $assignmentId, int $direction, ?User $actor = null): void + { + $assignment = $this->owned($subject, $assignmentId); + + if (! $assignment->role?->ordered || $direction === 0) { + return; + } + + $neighbors = PresentationAssignment::query() + ->where('subject_type', $subject->getMorphClass()) + ->where('subject_id', $subject->getKey()) + ->where('presentation_role_id', $assignment->presentation_role_id) + ->orderBy('position') + ->orderBy('id') + ->get() + ->values(); + + $index = $neighbors->search(fn (PresentationAssignment $row): bool => $row->id === $assignment->id); + + if ($index === false) { + return; + } + + $swap = $index + ($direction < 0 ? -1 : 1); + $other = $neighbors->get($swap); + + if (! $other instanceof PresentationAssignment) { + return; + } + + $position = $assignment->position; + $assignment->position = $other->position === $position ? $position + ($direction < 0 ? -1 : 1) : $other->position; + $other->position = $position; + $assignment->save(); + $other->save(); + $this->record($subject, null, 'Reihenfolge '.$assignment->role?->label, $actor); + } + + /** + * Kennung des ersten Titel- oder Galeriebildes. Ob es öffentlich erscheint, entscheidet WebsiteMedia. + */ + public function coverElementId(Model $subject): ?int + { + $assignments = PresentationAssignment::query() + ->with('role') + ->where('subject_type', $subject->getMorphClass()) + ->where('subject_id', $subject->getKey()) + ->orderBy('position') + ->get(); + + foreach (PresentationRole::COVER_ROLES as $slug) { + $match = $assignments->first(fn (PresentationAssignment $row): bool => $row->role?->slug === $slug); + + if ($match instanceof PresentationAssignment) { + return (int) $match->content_element_id; + } + } + + return null; + } + + private function owned(Model $subject, int $assignmentId): PresentationAssignment + { + $assignment = PresentationAssignment::query() + ->with(['role', 'element']) + ->where('subject_type', $subject->getMorphClass()) + ->where('subject_id', $subject->getKey()) + ->whereKey($assignmentId) + ->first(); + + if (! $assignment instanceof PresentationAssignment) { + throw new DomainRuleException('Diese Zuordnung gehört zu einem anderen Objekt.'); + } + + return $assignment; + } + + private function checkedSource(Model $subject, ContentElement $element, ?int $sourceVersionId): ?ContentElementVersion + { + if ($sourceVersionId === null) { + return null; + } + + $version = ContentElementVersion::query()->find($sourceVersionId); + + if (! $version instanceof ContentElementVersion) { + throw new DomainRuleException('Die gebundene Fassung fehlt.'); + } + + $ownsFilm = $subject instanceof ContentElement && (int) $version->content_element_id === (int) $subject->getKey(); + $ownsClip = (int) $version->content_element_id === (int) $element->id; + + if (! $ownsFilm && ! $ownsClip) { + throw new DomainRuleException('Die gebundene Fassung gehört weder zum Fachobjekt noch zum zugeordneten Medium.'); + } + + return $version; + } + + /** + * @return array{label: string, stale: bool}|null + */ + private function binding(PresentationAssignment $assignment): ?array + { + if ($assignment->source_version_id === null || ! $assignment->sourceVersion instanceof ContentElementVersion) { + return null; + } + + $version = $assignment->sourceVersion; + $latestId = ContentElementVersion::query() + ->where('content_element_id', $version->content_element_id) + ->where('status', ContentVersionStatus::Bereit) + ->orderByDesc('number') + ->value('id'); + $stale = $latestId !== null && (int) $latestId !== (int) $version->id; + + return [ + 'label' => $stale + ? 'Gebunden an Fassung '.$version->number.'. Die aktuelle Fassung ist eine andere. Der Clip wurde nicht neu erzeugt.' + : 'Gebunden an Fassung '.$version->number.'.', + 'stale' => $stale, + ]; + } + + private function record(Model $subject, ?string $before, ?string $after, ?User $actor): void + { + IdentityChange::query()->create([ + 'subject_type' => $subject->getMorphClass(), + 'subject_id' => $subject->getKey(), + 'field' => 'praesentation', + 'before' => $before, + 'after' => $after, + 'actor_id' => $actor?->id, + 'occurred_at' => now(), + ]); + } +} diff --git a/app/Domain/Catalog/PresentationRole.php b/app/Domain/Catalog/PresentationRole.php new file mode 100644 index 0000000..7284b9b --- /dev/null +++ b/app/Domain/Catalog/PresentationRole.php @@ -0,0 +1,44 @@ + 'boolean', + 'ordered' => 'boolean', + ]; + } + + public function assignments(): HasMany + { + return $this->hasMany(PresentationAssignment::class); + } + + /** + * @return array + */ + public static function selectOptions(): array + { + return static::query()->orderBy('sort_order')->pluck('label', 'slug')->all(); + } +} diff --git a/app/Domain/Catalog/ResolvedText.php b/app/Domain/Catalog/ResolvedText.php new file mode 100644 index 0000000..6aae73b --- /dev/null +++ b/app/Domain/Catalog/ResolvedText.php @@ -0,0 +1,17 @@ +title, + summary: $summary ?? $this->summary, + kind: $this->kind, + badge: $this->badge, + meta: $this->meta, + url: $this->url, + public: $this->public, + notice: $this->notice, + visual: $this->visual, + visualLabel: $this->visualLabel, + previewImage: $this->previewImage, + missing: $this->missing, + style: $this->style, + ); + } } diff --git a/app/Domain/Cms/Catalog/PublicCatalogReader.php b/app/Domain/Cms/Catalog/PublicCatalogReader.php index ebc6dc1..dd0ab05 100644 --- a/app/Domain/Cms/Catalog/PublicCatalogReader.php +++ b/app/Domain/Cms/Catalog/PublicCatalogReader.php @@ -7,6 +7,7 @@ use App\Domain\Catalog\CompositionVersion; use App\Domain\Catalog\ContentVersionStatus; use App\Domain\Catalog\EditorialContentKind; +use App\Domain\Catalog\EditorialProfileReader; use App\Domain\Media\ThumbnailRef; use Illuminate\Support\Collection; @@ -95,7 +96,9 @@ public function search(?string $term, int $limit = 25): array $like = '%'.mb_strtolower($term).'%'; $query->where(fn ($inner) => $inner ->whereRaw('LOWER(designation) LIKE ?', [$like]) - ->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like])); + ->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like]) + ->orWhereRaw('LOWER(COALESCE(teaser, \'\')) LIKE ?', [$like]) + ->orWhereRaw('LOWER(COALESCE(search_terms, \'\')) LIKE ?', [$like])); }) ->orderBy('designation') ->limit($limit * 3) @@ -200,7 +203,9 @@ public function cardSearch(?string $term, int $limit = 25): array $like = '%'.mb_strtolower($term).'%'; $query->where(fn ($inner) => $inner ->whereRaw('LOWER(designation) LIKE ?', [$like]) - ->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like])); + ->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like]) + ->orWhereRaw('LOWER(COALESCE(teaser, \'\')) LIKE ?', [$like]) + ->orWhereRaw('LOWER(COALESCE(search_terms, \'\')) LIKE ?', [$like])); }) ->orderBy('designation') ->limit($limit * 3) @@ -257,7 +262,8 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject $version = $shown ?? $this->latestReadyVersion($composition); $program = $composition->editorialContentKind?->slug === 'programm'; $kind = (string) ($composition->editorialContentKind?->label ?? ($program ? 'Programm' : 'Modul')); - $summary = filled($composition->summary) ? trim((string) $composition->summary) : null; + $profile = app(EditorialProfileReader::class)->read($composition, 'kachel'); + $summary = $profile->value('teaser') ?: $profile->value('summary'); $goal = filled($version?->learning_goal) ? trim((string) $version->learning_goal) : null; $missing = []; @@ -295,7 +301,7 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject } return new CardSubject( - title: $this->title($composition), + title: $profile->value('display_title') ?: $this->title($composition), summary: $summary ?? $goal, kind: $kind, badge: null, diff --git a/app/Domain/Cms/Catalog/PublicMaterialReader.php b/app/Domain/Cms/Catalog/PublicMaterialReader.php index c5588aa..4e6b8fc 100644 --- a/app/Domain/Cms/Catalog/PublicMaterialReader.php +++ b/app/Domain/Cms/Catalog/PublicMaterialReader.php @@ -5,6 +5,7 @@ use App\Domain\Catalog\CompositionStructureReader; use App\Domain\Catalog\ContentElement; use App\Domain\Catalog\ContentVersionStatus; +use App\Domain\Catalog\EditorialProfileReader; use App\Domain\Catalog\StructureNode; use App\Domain\Media\ThumbnailRef; @@ -137,6 +138,19 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ? $film = $shown->output_class === 'film'; $editorialKind = $element->editorialContentKind?->label; $summary = filled($shown->summary) ? trim((string) $shown->summary) : null; + $profile = app(EditorialProfileReader::class)->read($shown, 'bibliothek'); + + if (! array_key_exists('summary', $draft) && $profile->origin('summary') === 'variante') { + $summary = $profile->value('summary'); + } elseif ($summary === null && filled($shown->teaser)) { + $summary = trim((string) $shown->teaser); + } + + $title = (string) ($shown->display_title ?: $shown->working_title); + + if (! array_key_exists('display_title', $draft) && $profile->origin('display_title') === 'variante') { + $title = (string) $profile->value('display_title'); + } $meta = [$output]; if ($program !== null) { @@ -157,7 +171,7 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ? $previewImage = $includeNonPublic ? ThumbnailRef::url('editorial.card', 'element', (int) $element->id, $shown->thumbnail_path) : null; return new CardSubject( - title: (string) ($shown->display_title ?: $shown->working_title), + title: $title, summary: $summary, kind: filled($editorialKind) ? (string) $editorialKind : $output, badge: $output, diff --git a/app/Domain/Cms/Widgets/Types/MediaCardWidget.php b/app/Domain/Cms/Widgets/Types/MediaCardWidget.php index e09ce0c..39851d6 100644 --- a/app/Domain/Cms/Widgets/Types/MediaCardWidget.php +++ b/app/Domain/Cms/Widgets/Types/MediaCardWidget.php @@ -3,6 +3,7 @@ namespace App\Domain\Cms\Widgets\Types; use App\Domain\Catalog\ContentElement; +use App\Domain\Catalog\PresentationMedia; use App\Domain\Cms\Catalog\CardSubject; use App\Domain\Cms\Catalog\PublicMaterialReader; use App\Domain\Cms\Widgets\RenderContext; @@ -88,4 +89,13 @@ protected function cardStyle(): string { return 'media'; } + + protected function centralCoverId(mixed $id): ?int + { + $element = is_numeric($id) ? ContentElement::query()->find((int) $id) : null; + + return $element instanceof ContentElement + ? app(PresentationMedia::class)->coverElementId($element) + : null; + } } diff --git a/app/Domain/Cms/Widgets/Types/PremiumCardWidget.php b/app/Domain/Cms/Widgets/Types/PremiumCardWidget.php index 5986c57..eb817d3 100644 --- a/app/Domain/Cms/Widgets/Types/PremiumCardWidget.php +++ b/app/Domain/Cms/Widgets/Types/PremiumCardWidget.php @@ -137,6 +137,8 @@ public function dataRules(): array return [ 'action_label' => ['nullable', 'string', 'max:60'], 'note' => ['nullable', 'string', 'max:200'], + 'heading' => ['nullable', 'string', 'max:200'], + 'summary' => ['nullable', 'string', 'max:500'], 'alt' => ['nullable', 'string', 'max:300'], 'focus_x' => ['nullable', 'numeric', 'between:0,100'], 'focus_y' => ['nullable', 'numeric', 'between:0,100'], @@ -178,7 +180,22 @@ public function editorSchema(): array return [ Group::make([$this->subjectField()])->statePath('refs'), - Group::make([$action, $note])->statePath('data'), + Group::make([ + $action, + $note, + TextInput::make('heading') + ->label('Anzeigename nur für diese Karte') + ->maxLength(200) + ->live(onBlur: true) + ->placeholder('Zentraler Anzeigename') + ->helperText('Leer übernimmt den Anzeigenamen des Fachobjekts. Eine Eintragung gilt nur für diese Karte und ändert die Quelle nicht.'), + TextInput::make('summary') + ->label('Teaser nur für diese Karte') + ->maxLength(500) + ->live(onBlur: true) + ->placeholder('Zentraler Teaser oder Kurzbeschreibung') + ->helperText('Leer übernimmt Teaser oder Kurzbeschreibung. Lehrinhalt, Rechte und Preise bleiben unberührt.'), + ])->statePath('data'), ]; } @@ -205,7 +222,7 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array $refs[$key] = $id; $refs = ImageRefFields::clean($refs, $errors); - foreach (['action_label', 'note', 'alt'] as $field) { + foreach (['action_label', 'note', 'alt', 'heading', 'summary'] as $field) { $data[$field] = filled($data[$field] ?? null) ? trim((string) $data[$field]) : null; } @@ -224,13 +241,22 @@ public function resolve(array $widget, RenderContext $context): array $data = $widget['data']; $subject = $this->subject($widget['refs'][$this->refKey()] ?? null, $context); + $heading = filled($data['heading'] ?? null) ? trim((string) $data['heading']) : null; + $lead = filled($data['summary'] ?? null) ? trim((string) $data['summary']) : null; + + if ($subject instanceof CardSubject && ($heading !== null || $lead !== null)) { + $subject = $subject->withText($heading, $lead); + } + + $storedImage = WebsiteImage::normalize($widget['refs']['image'] ?? null); + $imageRef = $storedImage ?? $this->centralCoverId($widget['refs'][$this->refKey()] ?? null); return [ 'subject' => $subject, 'cardStyle' => $subject?->style ?? $this->cardStyle(), - 'imageUrl' => app(WebsiteImage::class)->url($widget['refs']['image'] ?? null, $context->preview), - 'alt' => app(WebsiteImage::class)->alt($widget['refs']['image'] ?? null, $data['alt'] ?? null), - 'imageNotice' => $context->preview ? app(WebsiteImage::class)->previewNotice($widget['refs']['image'] ?? null, 'Das Kartenbild') : null, + 'imageUrl' => app(WebsiteImage::class)->url($imageRef, $context->preview), + 'alt' => app(WebsiteImage::class)->alt($imageRef, $data['alt'] ?? null), + 'imageNotice' => $context->preview ? app(WebsiteImage::class)->previewNotice($imageRef, 'Das Kartenbild') : null, 'focus' => PremiumFields::focus($data, 66, 45), 'format' => $option('format', 'landscape'), 'fit' => $option('fit', 'cover'), @@ -261,6 +287,11 @@ public function summary(array $widget): string return $label ?? 'Kein Objekt gewählt'; } + protected function centralCoverId(mixed $id): ?int + { + return null; + } + private function subjectField(): Select { return Select::make($this->refKey()) diff --git a/app/Domain/Cms/Widgets/Types/ProgramCardWidget.php b/app/Domain/Cms/Widgets/Types/ProgramCardWidget.php index bf15507..89dd33c 100644 --- a/app/Domain/Cms/Widgets/Types/ProgramCardWidget.php +++ b/app/Domain/Cms/Widgets/Types/ProgramCardWidget.php @@ -3,6 +3,7 @@ namespace App\Domain\Cms\Widgets\Types; use App\Domain\Catalog\Composition; +use App\Domain\Catalog\PresentationMedia; use App\Domain\Cms\Catalog\CardSubject; use App\Domain\Cms\Catalog\PublicCatalogReader; use App\Domain\Cms\Widgets\RenderContext; @@ -97,4 +98,13 @@ protected function cardStyle(): string { return 'catalog'; } + + protected function centralCoverId(mixed $id): ?int + { + $composition = is_numeric($id) ? Composition::query()->find((int) $id) : null; + + return $composition instanceof Composition + ? app(PresentationMedia::class)->coverElementId($composition) + : null; + } } diff --git a/app/Filament/Resources/Compositions/Pages/EditComposition.php b/app/Filament/Resources/Compositions/Pages/EditComposition.php index ca1f5a6..40d05f5 100644 --- a/app/Filament/Resources/Compositions/Pages/EditComposition.php +++ b/app/Filament/Resources/Compositions/Pages/EditComposition.php @@ -23,6 +23,7 @@ use App\Domain\Cms\Catalog\PublicMaterialReader; use App\Filament\Resources\ContentElements\ContentElementResource; use App\Filament\Support\EditorialCatalog; +use App\Filament\Support\ManagesEditorialSurface; use App\Filament\Support\MediumForm; use App\Http\Controllers\ContentPreviewController; use App\Jobs\DeriveCompositionFrame; @@ -41,6 +42,7 @@ abstract class EditComposition extends EditRecord { + use ManagesEditorialSurface; use WithFileUploads; protected string $view = 'filament.editorial.edit'; @@ -49,8 +51,12 @@ abstract class EditComposition extends EditRecord public string $displayTitle = ''; + public string $teaser = ''; + public string $summary = ''; + public string $searchTerms = ''; + public string $description = ''; public string $learningGoal = ''; @@ -84,6 +90,8 @@ abstract class EditComposition extends EditRecord public bool $pickerOpen = false; + public string $pickerPurpose = 'aufbau'; + public string $pickerQuery = ''; public string $pickerKind = 'alle'; @@ -315,11 +323,51 @@ public function openPicker(): void $this->closePart(); } + $this->pickerPurpose = 'aufbau'; $this->pickerOpen = true; $this->textOpen = false; $this->pickerSelected = ''; } + public function openPresentationPicker(): void + { + $this->guardEditorial(); + + if ($this->partOpen) { + $this->closePart(); + } + + $this->pickerPurpose = 'praesentation'; + $this->pickerOpen = true; + $this->moduleOpen = false; + $this->textOpen = false; + $this->pickerSelected = ''; + } + + public function assignFromPicker(string $target): void + { + $this->guardEditorial(); + + if (preg_match('/^element:(\d+)$/', $target, $match) !== 1) { + $this->deskFeedback = 'Präsentationsmedien sind Medien aus dem Bestand. Ein Modul bleibt Bestandteil des Aufbaus.'; + + return; + } + + $version = ContentElementVersion::query()->find((int) $match[1]); + + if (! $version instanceof ContentElementVersion) { + $this->deskFeedback = 'Dieses Medium ist nicht verfügbar.'; + + return; + } + + $this->rememberAssignment((int) $version->content_element_id, $target); + $this->pickerOpen = false; + $this->pickerPurpose = 'aufbau'; + $this->pickerSelected = ''; + } + public function closePicker(): void { $this->pickerOpen = false; @@ -1003,7 +1051,9 @@ public function openModule(): void $this->moduleSnapshot = [ 'designation' => $this->designation, 'displayTitle' => $this->displayTitle, + 'teaser' => $this->teaser, 'summary' => $this->summary, + 'searchTerms' => $this->searchTerms, 'description' => $this->description, 'learningGoal' => $this->learningGoal, 'durationMinutes' => $this->durationMinutes, @@ -1574,7 +1624,9 @@ protected function loadEditor(): void $version = $this->currentReadyVersion(); $this->designation = $composition->designation; $this->displayTitle = (string) ($composition->display_title ?? ''); + $this->teaser = (string) ($composition->teaser ?? ''); $this->summary = (string) ($composition->summary ?? ''); + $this->searchTerms = (string) ($composition->search_terms ?? ''); $this->description = (string) ($composition->description ?? ''); $this->thumbnailPath = $composition->thumbnail_path; $this->thumbnailAlt = (string) ($composition->thumbnail_alt ?? ''); @@ -1829,7 +1881,9 @@ protected function persistPresentation(): bool $record->designation = $name; app(IdentityProfile::class)->fill($record, [ 'display_title' => $this->displayTitle, + 'teaser' => $this->teaser, 'summary' => $this->summary, + 'search_terms' => $this->searchTerms, 'description' => $this->description, 'thumbnail_alt' => $this->thumbnailAlt, ], $this->actor()); diff --git a/app/Filament/Resources/ContentElements/Pages/ListContentElements.php b/app/Filament/Resources/ContentElements/Pages/ListContentElements.php index d288d7e..76a6ed0 100644 --- a/app/Filament/Resources/ContentElements/Pages/ListContentElements.php +++ b/app/Filament/Resources/ContentElements/Pages/ListContentElements.php @@ -2,6 +2,7 @@ namespace App\Filament\Resources\ContentElements\Pages; +use App\Domain\Catalog\EditorialContentKind; use App\Filament\Resources\ContentElements\ContentElementResource; use App\Filament\Support\MediaLibrary; use App\Filament\Support\MediumForm; @@ -46,6 +47,9 @@ class ListContentElements extends ListRecords #[Url(as: 'saeule', except: '')] public string $saeule = ''; + #[Url(as: 'inhaltsart', except: '')] + public string $inhaltsart = ''; + #[Url(as: 'einordnung', except: '')] public string $einordnung = ''; @@ -112,6 +116,14 @@ public function classificationOptions(): array return app(MediaLibrary::class)->classifications(); } + /** + * @return array + */ + public function contentKindOptions(): array + { + return EditorialContentKind::selectOptions(); + } + public function filtersActive(): bool { return trim($this->suche) !== '' @@ -122,6 +134,7 @@ public function filtersActive(): bool || $this->nutzung !== '' || $this->saeule !== '' || $this->einordnung !== '' + || $this->inhaltsart !== '' || $this->verarbeitung !== '' || $this->archiv !== 'aktiv'; } @@ -136,6 +149,7 @@ public function resetFilters(): void $this->nutzung = ''; $this->saeule = ''; $this->einordnung = ''; + $this->inhaltsart = ''; $this->verarbeitung = ''; $this->archiv = 'aktiv'; } @@ -154,6 +168,7 @@ private function libraryFilters(): array 'nutzung' => $this->nutzung, 'saeule' => $this->saeule, 'einordnung' => $this->einordnung, + 'inhaltsart' => $this->inhaltsart, 'verarbeitung' => $this->verarbeitung, 'archiv' => $this->archiv, ]; diff --git a/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php b/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php index 79898e0..ea21cd8 100644 --- a/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php +++ b/app/Filament/Resources/ContentElements/Pages/ViewContentElement.php @@ -22,6 +22,7 @@ use App\Filament\Support\CatalogReading; use App\Filament\Support\EditorialCatalog; use App\Filament\Support\ElementRevision; +use App\Filament\Support\ManagesEditorialSurface; use App\Filament\Support\MediaLibrary; use App\Filament\Support\ReportsDomainRules; use App\Http\Controllers\ContentPreviewController; @@ -39,6 +40,7 @@ class ViewContentElement extends ViewRecord { + use ManagesEditorialSurface; use ReportsDomainRules; use WithFileUploads; @@ -62,8 +64,12 @@ class ViewContentElement extends ViewRecord public string $displayTitle = ''; + public string $teaser = ''; + public string $summary = ''; + public string $searchTerms = ''; + public string $descriptionText = ''; public string $usageNote = ''; @@ -109,7 +115,7 @@ public function mount(int|string $record): void } $bereich = (string) request()->query('bereich', 'beschreibung'); - $this->bereich = in_array($bereich, ['beschreibung', 'inhalt', 'fassungen', 'verwendung', 'vorschau'], true) + $this->bereich = in_array($bereich, ['beschreibung', 'inhalt', 'fassungen', 'praesentation', 'verwendung', 'vorschau'], true) ? $bereich : 'beschreibung'; $this->thumbnailAlt = (string) ($this->getRecord()->thumbnail_alt ?? ''); @@ -458,7 +464,9 @@ public function saveEditorial(): void app(IdentityProfile::class)->fill($element, [ 'working_title' => $title, 'display_title' => $this->displayTitle, + 'teaser' => $this->teaser, 'summary' => $this->summary, + 'search_terms' => $this->searchTerms, 'description' => $this->descriptionText, 'usage_note' => $this->usageNote, 'license_note' => $this->licenseNote, @@ -665,8 +673,10 @@ public function editorialHistory(): array $labels = [ 'working_title' => 'Arbeitstitel', 'display_title' => 'Anzeigename', + 'teaser' => 'Teaser', 'description' => 'Beschreibung', 'summary' => 'Kurzbeschreibung', + 'search_terms' => 'Suchbegriffe', 'usage_note' => 'Einsatzhinweis', 'license_note' => 'Interner Lizenzvermerk', 'website_credit' => 'Quellenzeile', @@ -709,7 +719,9 @@ private function fillEditorial(): void $element = $this->getRecord(); $this->workingTitle = (string) $element->working_title; $this->displayTitle = (string) ($element->display_title ?? ''); + $this->teaser = (string) ($element->teaser ?? ''); $this->summary = (string) ($element->summary ?? ''); + $this->searchTerms = (string) ($element->search_terms ?? ''); $this->descriptionText = (string) ($element->description ?? ''); $this->usageNote = (string) ($element->usage_note ?? ''); $this->licenseNote = (string) ($element->license_note ?? ''); diff --git a/app/Filament/Resources/LicenseArticles/LicenseArticleResource.php b/app/Filament/Resources/LicenseArticles/LicenseArticleResource.php index 33b5da1..f67db8f 100644 --- a/app/Filament/Resources/LicenseArticles/LicenseArticleResource.php +++ b/app/Filament/Resources/LicenseArticles/LicenseArticleResource.php @@ -12,6 +12,7 @@ use Filament\Infolists\Components\TextEntry; use Filament\Resources\Resource; use Filament\Schemas\Components\Section; +use Filament\Schemas\Components\View; use Filament\Schemas\Schema; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; @@ -62,6 +63,7 @@ public static function infolist(Schema $schema): Schema TextEntry::make('context')->hiddenLabel()->listWithLineBreaks() ->state(fn (LicenseArticle $record): array => app(CatalogReading::class)->articleContext($record)), ]), + View::make('filament.editorial.license-desk'), ]); } diff --git a/app/Filament/Resources/LicenseArticles/Pages/ViewLicenseArticle.php b/app/Filament/Resources/LicenseArticles/Pages/ViewLicenseArticle.php index b9d69b0..2bd304a 100644 --- a/app/Filament/Resources/LicenseArticles/Pages/ViewLicenseArticle.php +++ b/app/Filament/Resources/LicenseArticles/Pages/ViewLicenseArticle.php @@ -5,9 +5,15 @@ use App\Domain\Catalog\ArticleService; use App\Domain\Catalog\CompositionVersion; use App\Domain\Catalog\ContentElementVersion; +use App\Domain\Catalog\EditorialDimension; +use App\Domain\Catalog\EditorialDimensionValue; +use App\Domain\Catalog\IdentityDimension; +use App\Domain\Catalog\IdentityDimensionValue; +use App\Domain\Catalog\IdentityProfile; use App\Domain\Catalog\LicenseArticle; use App\Filament\Resources\LicenseArticles\LicenseArticleResource; use App\Filament\Support\CatalogOptions; +use App\Filament\Support\ManagesEditorialSurface; use App\Filament\Support\ReportsDomainRules; use Filament\Actions\Action; use Filament\Forms\Components\Select; @@ -17,10 +23,118 @@ class ViewLicenseArticle extends ViewRecord { + use ManagesEditorialSurface; use ReportsDomainRules; protected static string $resource = LicenseArticleResource::class; + public string $workingTitle = ''; + + public string $displayTitle = ''; + + public string $teaser = ''; + + public string $summary = ''; + + public string $descriptionText = ''; + + public string $searchTerms = ''; + + public int|string|null $kindId = null; + + /** @var list */ + public array $dimensionIds = []; + + public function mount(int|string $record): void + { + parent::mount($record); + $this->fillLicenseEditorial(); + } + + public function canEditEditorial(): bool + { + return LicenseArticleResource::keeper(); + } + + public function saveLicenseEditorial(): void + { + $this->guardEditorial(); + + /** @var LicenseArticle $article */ + $article = $this->getRecord(); + $releaseId = $article->current_release_id; + $releases = $article->releases()->count(); + + app(IdentityProfile::class)->fill($article, [ + 'working_title' => $this->workingTitle, + 'display_title' => $this->displayTitle, + 'teaser' => $this->teaser, + 'summary' => $this->summary, + 'description' => $this->descriptionText, + 'search_terms' => $this->searchTerms, + 'editorial_content_kind_id' => filled($this->kindId) ? (int) $this->kindId : null, + ], auth()->user()); + + $ids = array_map(intval(...), $this->dimensionIds); + IdentityDimensionValue::query() + ->where('subject_type', $article->getMorphClass()) + ->where('subject_id', $article->id) + ->where('origin', 'direkt') + ->whereNotIn('editorial_dimension_value_id', $ids === [] ? [0] : $ids) + ->delete(); + + foreach (EditorialDimensionValue::query()->whereIn('id', $ids)->get() as $value) { + app(IdentityDimension::class)->assign($article, $value, 'direkt'); + } + + $article->refresh(); + $this->fillLicenseEditorial(); + $this->deskFeedback = $article->current_release_id === $releaseId && $article->releases()->count() === $releases + ? 'Gespeichert. Stand, Preis und Rechte bleiben unverändert.' + : 'Gespeichert. Prüfe den Artikelstand, er hat sich geändert.'; + } + + /** + * @return list}> + */ + public function licenseDimensionGroups(): array + { + $groups = []; + + foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) { + $values = []; + + foreach ($dimension->values as $value) { + $values[] = ['id' => $value->id, 'label' => $value->label]; + } + + if ($values !== []) { + $groups[] = ['label' => $dimension->label, 'values' => $values]; + } + } + + return $groups; + } + + private function fillLicenseEditorial(): void + { + /** @var LicenseArticle $article */ + $article = $this->getRecord(); + $this->workingTitle = (string) ($article->working_title ?? ''); + $this->displayTitle = (string) ($article->display_title ?? ''); + $this->teaser = (string) ($article->teaser ?? ''); + $this->summary = (string) ($article->summary ?? ''); + $this->descriptionText = (string) ($article->description ?? ''); + $this->searchTerms = (string) ($article->search_terms ?? ''); + $this->kindId = $article->editorial_content_kind_id; + $this->dimensionIds = IdentityDimensionValue::query() + ->where('subject_type', $article->getMorphClass()) + ->where('subject_id', $article->id) + ->where('origin', 'direkt') + ->pluck('editorial_dimension_value_id') + ->all(); + } + protected function getHeaderActions(): array { return [ diff --git a/app/Filament/Support/EditorialCatalog.php b/app/Filament/Support/EditorialCatalog.php index 473a860..3831eee 100644 --- a/app/Filament/Support/EditorialCatalog.php +++ b/app/Filament/Support/EditorialCatalog.php @@ -210,6 +210,8 @@ public function search(string $query, string $scope, int $exceptCompositionId): $builder->where('working_title', 'like', $like) ->orWhere('display_title', 'like', $like) + ->orWhere('teaser', 'like', $like) + ->orWhere('search_terms', 'like', $like) ->orWhere('summary', 'like', $like); }) ->orderByDesc('id') @@ -242,6 +244,8 @@ public function search(string $query, string $scope, int $exceptCompositionId): $builder->where(function ($inner) use ($like): void { $inner->where('designation', 'like', $like) ->orWhere('display_title', 'like', $like) + ->orWhere('teaser', 'like', $like) + ->orWhere('search_terms', 'like', $like) ->orWhere('summary', 'like', $like); }); }) @@ -317,6 +321,8 @@ public function browse(string $query, string $kind, string $dimension, int $exce $builder->where(function ($inner) use ($like): void { $inner->where('designation', 'like', $like) ->orWhere('display_title', 'like', $like) + ->orWhere('teaser', 'like', $like) + ->orWhere('search_terms', 'like', $like) ->orWhere('summary', 'like', $like); }); }) @@ -468,6 +474,8 @@ private function constrainElement($builder, string $query, string $like, string $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) ->orWhere('description', 'like', $like); }); @@ -749,6 +757,8 @@ public function mediaPictures(string $query): array ->where(function ($builder) use ($like): void { $builder->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') diff --git a/app/Filament/Support/ManagesEditorialSurface.php b/app/Filament/Support/ManagesEditorialSurface.php new file mode 100644 index 0000000..e2c6387 --- /dev/null +++ b/app/Filament/Support/ManagesEditorialSurface.php @@ -0,0 +1,282 @@ +getRecord(); + } + + public function editorialProfile(?string $audience = null): EditorialProfile + { + return app(EditorialProfileReader::class)->read($this->editorialSubject(), $audience); + } + + /** + * @return list + */ + public function editorialGaps(): array + { + $profile = $this->editorialProfile(); + $gaps = []; + + foreach ([ + 'display_title' => 'Anzeigename', + 'teaser' => 'Teaser', + 'summary' => 'Kurzbeschreibung', + 'description' => 'Ausführliche Beschreibung', + ] as $field => $label) { + if ($profile->value($field) === null) { + $gaps[] = $label; + } + } + + return $gaps; + } + + /** + * @return list> + */ + public function presentationRows(): array + { + return app(PresentationMedia::class)->rows($this->editorialSubject()); + } + + /** + * @return array + */ + public function presentationRoleOptions(): array + { + return PresentationRole::selectOptions(); + } + + /** + * @return array{items: list>, more: bool} + */ + public function presentationChoices(): array + { + return app(EditorialCatalog::class)->browse($this->presentationQuery, 'alle', '', 0, elementsOnly: true); + } + + public function assignPickedPresentation(): void + { + $this->guardEditorial(); + $row = app(EditorialCatalog::class)->rowForTarget($this->presentationPick, 0, allowDraft: true); + + if ($row === null || ! isset($row['element_id'])) { + $this->deskFeedback = 'Bitte ein Medium aus dem Bestand wählen.'; + + return; + } + + $this->rememberAssignment((int) $row['element_id'], isset($row['target']) ? (string) $row['target'] : null); + $this->presentationPick = ''; + } + + public function detachPresentation(int $assignmentId): void + { + $this->guardEditorial(); + $this->deskFeedback = $this->reportPresentation( + fn (): string => app(PresentationMedia::class)->detach($this->editorialSubject(), $assignmentId, $this->deskActor()), + ); + } + + public function movePresentation(int $assignmentId, int $direction): void + { + $this->guardEditorial(); + $this->deskFeedback = $this->reportPresentation(function () use ($assignmentId, $direction): string { + app(PresentationMedia::class)->move($this->editorialSubject(), $assignmentId, $direction, $this->deskActor()); + + return 'Die Reihenfolge ist gespeichert.'; + }); + } + + public function releaseAssigned(int $elementId): void + { + abort_unless(ContentElementResource::editor(), 403); + $element = ContentElement::query()->find($elementId); + + if (! $element instanceof ContentElement) { + $this->deskFeedback = 'Das Medium fehlt.'; + + return; + } + + $this->deskFeedback = app(WebsiteRelease::class)->release($element, $this->deskActor()); + } + + public function withdrawAssigned(int $elementId): void + { + abort_unless(ContentElementResource::editor(), 403); + $element = ContentElement::query()->find($elementId); + + if (! $element instanceof ContentElement) { + $this->deskFeedback = 'Das Medium fehlt.'; + + return; + } + + $this->deskFeedback = app(WebsiteRelease::class)->withdraw($element, $this->deskActor()); + } + + /** + * @return list + */ + public function variantRows(): array + { + $subject = $this->editorialSubject(); + + return EditorialTextVariant::query() + ->where('subject_type', $subject->getMorphClass()) + ->where('subject_id', $subject->getKey()) + ->orderBy('audience') + ->orderBy('field') + ->get() + ->all(); + } + + public function saveVariant(): void + { + $this->guardEditorial(); + $this->deskFeedback = $this->reportPresentation( + fn (): string => app(EditorialProfileReader::class)->putVariant( + $this->editorialSubject(), + $this->variantField, + $this->variantAudience, + $this->variantBody, + $this->deskActor(), + ), + ); + $this->variantBody = ''; + } + + public function forgetVariant(int $variantId): void + { + $this->guardEditorial(); + $variant = EditorialTextVariant::query()->find($variantId); + + if (! $variant instanceof EditorialTextVariant) { + $this->deskFeedback = 'Diese Abweichung gibt es nicht mehr.'; + + return; + } + + $this->reportPresentation(function () use ($variant): string { + app(EditorialProfileReader::class)->forgetVariant($this->editorialSubject(), $variant, $this->deskActor()); + + return 'Die abweichende Formulierung ist entfernt.'; + }); + $this->deskFeedback = 'Die abweichende Formulierung ist entfernt. Es gilt wieder die zentrale Angabe.'; + } + + public function variantFieldLabel(string $field): string + { + return match ($field) { + 'display_title' => 'Anzeigename', + 'teaser' => 'Teaser', + 'summary' => 'Kurzbeschreibung', + 'description' => 'Ausführliche Beschreibung', + default => $field, + }; + } + + public function canReleasePresentation(): bool + { + return ContentElementResource::editor(); + } + + public function canEditEditorial(): bool + { + return ContentElementResource::editor(); + } + + protected function rememberAssignment(int $elementId, ?string $target): void + { + $sourceId = null; + + if ($this->bindToVersion && in_array($this->presentationRole, PresentationRole::BOUND_ROLES, true)) { + $subject = $this->editorialSubject(); + $sourceId = $subject instanceof ContentElement + ? $subject->versions()->where('status', ContentVersionStatus::Bereit)->orderByDesc('number')->value('id') + : $this->versionIdFromTarget($target); + } + + $this->deskFeedback = $this->reportPresentation( + fn (): string => app(PresentationMedia::class)->assign( + $this->editorialSubject(), + $this->presentationRole, + $elementId, + $sourceId !== null ? (int) $sourceId : null, + $this->deskActor(), + ), + ); + } + + protected function versionIdFromTarget(?string $target): ?int + { + if (is_string($target) && preg_match('/^element:(\d+)$/', $target, $match) === 1) { + return (int) $match[1]; + } + + return null; + } + + protected function guardEditorial(): void + { + abort_unless($this->canEditEditorial(), 403); + } + + protected function deskActor(): ?User + { + $user = auth()->user(); + + return $user instanceof User ? $user : null; + } + + /** + * @param callable(): string $action + */ + protected function reportPresentation(callable $action): string + { + try { + return $action(); + } catch (DomainRuleException $exception) { + return $exception->getMessage(); + } + } +} diff --git a/app/Filament/Support/MediaLibrary.php b/app/Filament/Support/MediaLibrary.php index cde4c8c..ea2fa92 100644 --- a/app/Filament/Support/MediaLibrary.php +++ b/app/Filament/Support/MediaLibrary.php @@ -75,7 +75,7 @@ public function classifications(): array */ public function cardFor(ContentElement $element, bool $canEdit): array { - $element->loadMissing(['versions', 'pillars']); + $element->loadMissing(['versions', 'pillars', 'editorialContentKind']); $versionIds = $element->versions->pluck('id')->all(); return $this->card( @@ -95,7 +95,7 @@ public function cards(array $filters, bool $canEdit): array { $filters = $this->normalize($filters); $elements = ContentElement::query() - ->with(['versions', 'pillars']) + ->with(['versions', 'pillars', 'editorialContentKind']) ->orderBy('working_title') ->get(); $versionIds = $elements->flatMap(fn (ContentElement $element) => $element->versions->pluck('id'))->all(); @@ -140,6 +140,7 @@ private function normalize(array $filters): array 'nutzung' => $this->choice($filters['nutzung'] ?? '', ['verwendet', 'unbenutzt']), 'saeule' => ctype_digit($filters['saeule'] ?? '') ? $filters['saeule'] : '', 'einordnung' => ctype_digit($filters['einordnung'] ?? '') ? $filters['einordnung'] : '', + 'inhaltsart' => ctype_digit($filters['inhaltsart'] ?? '') ? $filters['inhaltsart'] : '', 'verarbeitung' => $this->choice($filters['verarbeitung'] ?? '', ['fehler', 'uebernahme']), 'archiv' => $this->choice($filters['archiv'] ?? '', ['aktiv', 'archiviert', 'alle'], 'aktiv'), ]; @@ -418,6 +419,10 @@ private function matches(ContentElement $element, array $portrait, array $uses, return false; } + if ($filters['inhaltsart'] !== '' && (int) $element->editorial_content_kind_id !== (int) $filters['inhaltsart']) { + return false; + } + if ($filters['verarbeitung'] === 'fehler' && $portrait['processing'] !== 'Verarbeitungsfehler') { return false; } @@ -451,6 +456,8 @@ private function haystack(ContentElement $element): string $element->display_title, $element->description, $element->summary, + $element->teaser, + $element->search_terms, $element->usage_note, ], fn (mixed $value): bool => is_string($value) && trim($value) !== ''))); } @@ -473,6 +480,7 @@ private function card(ContentElement $element, array $portrait, array $uses, arr 'id' => $element->id, 'title' => $element->working_title, 'type' => $this->catalog->outputLabel((string) $element->output_class), + 'editorialKind' => $element->editorialContentKind?->label, 'typeKey' => $typeKey, 'description' => $description === '' ? null : $description, 'usageNote' => $usageNote === '' ? null : $usageNote, diff --git a/database/migrations/2026_11_19_120000_editorial_profile_and_presentation.php b/database/migrations/2026_11_19_120000_editorial_profile_and_presentation.php new file mode 100644 index 0000000..5034935 --- /dev/null +++ b/database/migrations/2026_11_19_120000_editorial_profile_and_presentation.php @@ -0,0 +1,191 @@ +text('teaser')->nullable()->after('display_title'); + $table->text('search_terms')->nullable()->after('summary'); + }); + + Schema::table('compositions', function (Blueprint $table) { + $table->text('teaser')->nullable()->after('display_title'); + $table->text('search_terms')->nullable()->after('description'); + }); + + Schema::table('license_articles', function (Blueprint $table) { + $table->string('working_title')->nullable()->after('code'); + $table->string('display_title')->nullable()->after('working_title'); + $table->text('teaser')->nullable()->after('display_title'); + $table->text('summary')->nullable()->after('teaser'); + $table->text('description')->nullable()->after('summary'); + $table->text('search_terms')->nullable()->after('description'); + $table->foreignId('editorial_content_kind_id') + ->nullable() + ->after('search_terms') + ->constrained('editorial_content_kinds') + ->nullOnDelete(); + }); + + Schema::create('editorial_text_variants', function (Blueprint $table) { + $table->id(); + $table->string('subject_type'); + $table->unsignedBigInteger('subject_id'); + $table->string('field'); + $table->string('audience'); + $table->text('body'); + $table->timestamps(); + $table->unique(['subject_type', 'subject_id', 'field', 'audience'], 'editorial_text_variant_unique'); + }); + + Schema::create('presentation_roles', function (Blueprint $table) { + $table->id(); + $table->string('slug')->unique(); + $table->string('label'); + $table->boolean('multiple')->default(false); + $table->boolean('ordered')->default(false); + $table->unsignedInteger('sort_order')->default(0); + $table->timestamps(); + }); + + Schema::create('presentation_assignments', function (Blueprint $table) { + $table->id(); + $table->string('subject_type'); + $table->unsignedBigInteger('subject_id'); + $table->foreignId('content_element_id')->constrained('content_elements')->cascadeOnDelete(); + $table->foreignId('presentation_role_id')->constrained('presentation_roles')->cascadeOnDelete(); + $table->unsignedInteger('position')->default(1); + $table->foreignId('source_version_id')->nullable()->constrained('content_element_versions')->nullOnDelete(); + $table->timestamps(); + $table->unique( + ['subject_type', 'subject_id', 'presentation_role_id', 'content_element_id'], + 'presentation_assignment_unique', + ); + $table->index(['subject_type', 'subject_id'], 'presentation_assignment_subject'); + }); + + $now = now(); + + foreach ([ + ['slug' => 'unterrichtsfilm', 'label' => 'Unterrichtsfilm', 'sort_order' => 50], + ['slug' => 'kurzfilm', 'label' => 'Kurzfilm / Filmbeispiel', 'sort_order' => 60], + ['slug' => 'trailer', 'label' => 'Trailer / Teaserfilm', 'sort_order' => 70], + ['slug' => 'interview', 'label' => 'Interview', 'sort_order' => 80], + ['slug' => 'arbeitsblatt', 'label' => 'Arbeitsblatt', 'sort_order' => 90], + ['slug' => 'uebungsbeschreibung', 'label' => 'Übungsbeschreibung', 'sort_order' => 100], + ['slug' => 'titelbild', 'label' => 'Titelbild / Keyvisual', 'sort_order' => 110], + ['slug' => 'hintergrundbild', 'label' => 'Hintergrundbild', 'sort_order' => 120], + ['slug' => 'praesentationsbild', 'label' => 'Sonstiges Präsentationsbild', 'sort_order' => 130], + ['slug' => 'audioanleitung', 'label' => 'Audioanleitung', 'sort_order' => 140], + ] as $row) { + DB::table('editorial_content_kinds')->insert($row + ['created_at' => $now, 'updated_at' => $now]); + } + + $dimensions = [ + 'verwendungszweck' => [ + 'label' => 'Redaktioneller Verwendungszweck', + 'values' => [ + 'training' => 'Training / Lehrinhalt', + 'begleitmaterial' => 'Trainer- und Begleitmaterial', + 'website' => 'Website / Marketing', + 'marke' => 'Markenpräsentation', + 'intern' => 'Interne redaktionelle Ressource', + ], + ], + 'zielgruppe' => [ + 'label' => 'Altersbereich und Zielgruppe', + 'values' => [ + 'kinder' => 'Kinder', + 'jugendliche' => 'Jugendliche', + 'erwachsene' => 'Erwachsene', + 'eltern' => 'Eltern', + 'fachkraefte' => 'Fachkräfte', + ], + ], + 'einsatzbereich' => [ + 'label' => 'Einsatzbereich', + 'values' => [ + 'kita' => 'Kita', + 'schule' => 'Schule', + 'familie' => 'Familie', + 'fortbildung' => 'Fortbildung', + ], + ], + ]; + + foreach ($dimensions as $slug => $dimension) { + $dimensionId = DB::table('editorial_dimensions')->insertGetId([ + 'slug' => $slug, + 'label' => $dimension['label'], + 'created_at' => $now, + 'updated_at' => $now, + ]); + + foreach ($dimension['values'] as $valueSlug => $label) { + DB::table('editorial_dimension_values')->insert([ + 'editorial_dimension_id' => $dimensionId, + 'slug' => $valueSlug, + 'label' => $label, + 'created_at' => $now, + 'updated_at' => $now, + ]); + } + } + + foreach ([ + ['slug' => 'titelbild', 'label' => 'Titelbild / Standard-Thumbnail', 'multiple' => false, 'ordered' => false, 'sort_order' => 10], + ['slug' => 'titelbild_alternativ', 'label' => 'Alternatives Titelbild', 'multiple' => true, 'ordered' => true, 'sort_order' => 20], + ['slug' => 'hero', 'label' => 'Hero-Bild', 'multiple' => false, 'ordered' => false, 'sort_order' => 30], + ['slug' => 'hover', 'label' => 'Hoverbild', 'multiple' => false, 'ordered' => false, 'sort_order' => 40], + ['slug' => 'trailer', 'label' => 'Trailer / Teaserfilm', 'multiple' => true, 'ordered' => true, 'sort_order' => 50], + ['slug' => 'vorschauclip', 'label' => 'Vorschauclip', 'multiple' => true, 'ordered' => true, 'sort_order' => 60], + ['slug' => 'audiovorschau', 'label' => 'Audiovorschau', 'multiple' => true, 'ordered' => true, 'sort_order' => 70], + ['slug' => 'interview', 'label' => 'Interview', 'multiple' => true, 'ordered' => true, 'sort_order' => 80], + ['slug' => 'galerie', 'label' => 'Galerieelement', 'multiple' => true, 'ordered' => true, 'sort_order' => 90], + ] as $role) { + DB::table('presentation_roles')->insert($role + ['created_at' => $now, 'updated_at' => $now]); + } + } + + public function down(): void + { + Schema::dropIfExists('presentation_assignments'); + Schema::dropIfExists('presentation_roles'); + Schema::dropIfExists('editorial_text_variants'); + + Schema::table('license_articles', function (Blueprint $table) { + $table->dropConstrainedForeignId('editorial_content_kind_id'); + $table->dropColumn(['working_title', 'display_title', 'teaser', 'summary', 'description', 'search_terms']); + }); + + Schema::table('compositions', function (Blueprint $table) { + $table->dropColumn(['teaser', 'search_terms']); + }); + + Schema::table('content_elements', function (Blueprint $table) { + $table->dropColumn(['teaser', 'search_terms']); + }); + + $dimensionIds = DB::table('editorial_dimensions') + ->whereIn('slug', ['verwendungszweck', 'zielgruppe', 'einsatzbereich']) + ->pluck('id'); + + DB::table('identity_dimension_values')->whereIn( + 'editorial_dimension_value_id', + DB::table('editorial_dimension_values')->whereIn('editorial_dimension_id', $dimensionIds)->pluck('id'), + )->delete(); + DB::table('editorial_dimension_values')->whereIn('editorial_dimension_id', $dimensionIds)->delete(); + DB::table('editorial_dimensions')->whereIn('id', $dimensionIds)->delete(); + + DB::table('editorial_content_kinds')->whereIn('slug', [ + 'unterrichtsfilm', 'kurzfilm', 'trailer', 'interview', 'arbeitsblatt', 'uebungsbeschreibung', + 'titelbild', 'hintergrundbild', 'praesentationsbild', 'audioanleitung', + ])->delete(); + } +}; diff --git a/docs/architektur/12_Entscheidungsprotokoll_ADR.md b/docs/architektur/12_Entscheidungsprotokoll_ADR.md index 808f168..4c54730 100644 --- a/docs/architektur/12_Entscheidungsprotokoll_ADR.md +++ b/docs/architektur/12_Entscheidungsprotokoll_ADR.md @@ -61,6 +61,7 @@ ## Übersicht der Architekturentscheidungen | ADR-38 | Layoutvertrag der Widgets | Umgesetzt auf Test (18.11.2026); UX-Abnahme offen | Zulässige Rasterbreiten, Höhen und Verhalten bei wenig Platz je Widget-Art in der bestehenden Registry; Darstellung nach realer Containerbreite | | ADR-39 | Premium-Karten mit Fachbezug | Umgesetzt auf Test (18.11.2026); gestalterische Freigabe v1.7 offen | Eine Karte je Platz im Abschnittsraster; Inhalte und Linkziel aus Thema, Medium oder Programm/Modul; keine Preise, keine Freigabe geschützter Medien | | ADR-40 | Zentrale Medienverwaltung im CMS | Umgesetzt auf Test (19.11.2026); Abnahme offen | CMS-Bilder sind Medien des Medienmanagers (Kennung statt Pfad), öffentlich nur mit Website-Freigabe; frühere CMS-Bilder übernommen | +| ADR-41 | Gemeinsame Redaktionsbasis | Umgesetzt im Branch `feature/redaktionelle-basis`; Betreiberabnahme offen. Technische Abbildung ist eine Arbeitsannahme, keine neue fachliche Freigabe | Klasse-A-Texte, Fachdimensionen und Präsentationsreferenzen an den bestehenden Fachobjekten; keine zweite Inhalts- oder Produktverwaltung | --- @@ -526,3 +527,18 @@ ## ADR-40 – Zentrale Medienverwaltung im CMS **Alternativen.** Schlüssel `refs.element` wie im Dokument (verworfen: kollidiert mit dem Fachobjekt der Medienkarte); Revisionen per Migration umschreiben (verworfen: Revisionen bleiben unverändert, Rollback); ganzes Widget bei fehlender Freigabe ausblenden (verworfen bis zur Entscheidung: entfernt Überschriften und H1). **Folgen und offene Prüfung.** Rollback zeigt nach der Umstellung gespeicherte Bilder nicht (Registry §9). Website-Bilder werden bis 2400 px abgeleitet. Offen: Entscheidung „Bild entfällt“ vs. „Widget entfällt“; übernommene Medien tragen Dateinamen als Titel und keine Quellenzeile; ein unter `cms/` liegendes Originalmotiv (`lara-felix-park-original`) wurde mit übernommen und ist damit ein freigegebenes Medium – prüfen und gegebenenfalls zurücknehmen. **Quelle.** `docs/architektur/medienzugriff-fuer-komponenten.md`; `cms-widget-registry.md` §§7, 9; ADR-30, ADR-38, ADR-39. + +## ADR-41 – Gemeinsame redaktionelle Informationsbasis + +**Status am 19.11.2026:** Umgesetzt und durch `EditorialDeskTest` belegt; mit dem Merge nach `develop` auf der Testinstanz. **Keine formale Freigabe** durch diesen Eintrag. Die technische Abbildung ist eine Arbeitsannahme aus dem vorhandenen Bestand, soweit unten nicht als Entscheidung gekennzeichnet. +**Kontext.** Redaktionelle Texte, fachliche Auffindbarkeit und Präsentationsmedien sollen an Medium, Modul, Programm und Lizenzartikel gepflegt und von Website, CMS und Verwaltung aus derselben Quelle gelesen werden. Medien, Module, Programme, Lizenzartikel und Angebote bleiben getrennte Fachobjekte (ADR-03, ADR-04). Öffentliche Profile (ADR-29) sind nicht entschieden. Die Website-Freigabe bleibt die von ADR-40. +**Entscheidung (Arbeitsannahme, am Bestand geprüft).** +- Klasse A bleibt an den vorhandenen Feldern: Arbeitstitel bzw. Bezeichnung, Anzeigename, Kurzbeschreibung (`summary`), ausführliche Beschreibung. Neu und leer nachrüstbar sind `teaser` und `search_terms`. Ein Lizenzartikel trägt dieselben Felder als eigene Abweichung. Leer heißt: der Wert wird nicht kopiert, sondern über die eindeutige Wurzel des aktuellen Artikelstands gelesen (`EditorialProfileReader`). Zwei Wurzeln oder keine Wurzel ergeben keine Ableitung. +- Abweichende Formulierungen stehen nur als einzelne Variante (`editorial_text_variants`: Feld und Kontext). Es gibt keine zweite Stammdatenkopie je Zielgruppe. +- Die fachliche Materialart bleibt `editorial_content_kinds`. Ergänzt wurden Unterrichtsfilm, Kurzfilm, Trailer, Interview, Arbeitsblatt, Übungsbeschreibung, Titelbild, Hintergrundbild, Präsentationsbild und Audioanleitung. Der redaktionelle Verwendungszweck, Altersbereiche und Einsatzbereiche sind Werte der vorhandenen Dimensionen und mehrfach zuordenbar. Sie geben nichts frei. +- Präsentationsmedien sind Referenzen (`presentation_assignments`) auf Inhaltselemente mit einer zentralen Rolle. Das Vorschaubild der Bibliothek (`thumbnail_path`) bleibt daneben bestehen. Eine Zuordnung ändert keine Fassung, keine Verwendung im Aufbau und keine Freigabe. Ein Ausschnitt kann die Fassung festhalten, aus der er stammt (`source_version_id`). Eine neuere Fassung markiert die Bindung als veraltet und erzeugt keinen neuen Clip. +- Programm- und Medienkarten lesen Teaser oder Kurzbeschreibung zur Laufzeit. `data.heading` und `data.summary` einer Karte sind eine lokale Abweichung. Ein leeres Kartenbild nimmt das zugeordnete Titelbild, öffentlich nur über `WebsiteImage`. +**Nicht entschieden.** Ob alle Dimensionen je Objektart ausgeblendet werden können (die Tabelle führt keine Objektarten). Ob ein öffentliches Profil (ADR-29) die Kartenregeln ersetzt. Ob freie Suchbegriffe später eine verwaltete Schlagwortdimension werden. Ob bei zurückgenommener Freigabe das ganze Widget entfällt (offen seit ADR-40). +**Folgen.** Klasse B (Fassungen, Lernziele, Mitglieder) und Klasse C (Angebote, Rechte, Bestellstände) werden von dieser Pflege nicht geschrieben. Bestehende Thumbnails, CMS-Kennungen und Revisionen bleiben. Ein Code-Rollback vor dieser Migration lässt die neuen Spalten liegen; die Anwendung davor kennt sie nicht. +**Quelle.** Auftrag gemeinsame Redaktionsverwaltung; `medienzugriff-fuer-komponenten.md`; `cms-widget-registry.md`; ADR-03, ADR-07, ADR-22, ADR-29, ADR-39, ADR-40. + diff --git a/docs/architektur/cms-widget-registry.md b/docs/architektur/cms-widget-registry.md index 62d0ac6..ca4dd96 100644 --- a/docs/architektur/cms-widget-registry.md +++ b/docs/architektur/cms-widget-registry.md @@ -306,7 +306,9 @@ ## 13. Premium-Karten (Brand-UI-Kit v1.7, ADR-39) **Darstellung der Medienkarte nach Ausgabeart:** Film → Variante `lf-pc--media` (grüne Aktion, Metadatenband, Filmtafel); Dokument, Text, Hörstück, Bild → `lf-pc--material` (Materialsymbol). Die Unterscheidung folgt `output_class`, nicht einer redaktionellen Einstellung. -**Gespeichert** (Hülle wie jedes Widget): `refs.{pillar|element|composition}` (Kennung), `refs.image` (öffentlicher Bereich `cms/`), `data.action_label`, `data.note`, `data.alt` (Pflicht bei Bild), `data.focus_x/focus_y` (0–100, Vorgabe 66/45). Kein Titel, kein Text, kein Linkziel. +**Gespeichert** (Hülle wie jedes Widget): `refs.{pillar|element|composition}` (Kennung), `refs.image` (Kennung eines Medienmanager-Bildes, früher ein Pfad unter `cms/`), `data.action_label`, `data.note`, `data.alt` (Abweichung vom Alternativtext des Mediums), `data.heading` und `data.summary` (optionale Abweichung nur für diese Karte; leer übernimmt den zentralen Anzeigenamen bzw. Teaser oder Kurzbeschreibung), `data.focus_x/focus_y` (0–100, Vorgabe 66/45). Kein kopierter Lehrtext, kein Linkziel, kein Preis. + +Ist `refs.image` leer, verwendet die Programm- und die Medienkarte das zentral zugeordnete Titelbild des Fachobjekts (`PresentationMedia`, zuerst Titelbild, dann Hero, Hover, alternatives Titelbild, Galerie). Gelesen wird es über `WebsiteImage`. Ohne Website-Freigabe erscheint öffentlich kein Bild; die Texte bleiben. Eine eingetragene Bildkennung hat Vorrang vor dem zentralen Titelbild. Öffentliche Fachobjektprofile nach ADR-29 bleiben offen. **Darstellung** (Reiter „Darstellung“): Variante `adaptive` (ab 520 px Bild neben Text) oder `stacked` (Bild immer oben); Höhe `auto` oder `fill` („An die Zeile angleichen“); `settings.format` (`landscape` 16:9 Vorgabe, `square`, `portrait` 3:4); `settings.fit` (`cover` Vorgabe, `contain` für Dokumente und Poster); `settings.heading_level` (`h3` Vorgabe, `h2`, `h4`); Anzeigen/Ausblenden von Kurzbeschreibung, Art (nicht bei Programm/Modul), Zusatzangaben und Aktion. Bildhöhe höchstens min(70vh, 640 px). diff --git a/docs/architektur/medienzugriff-fuer-komponenten.md b/docs/architektur/medienzugriff-fuer-komponenten.md index 12b6692..6f98300 100644 --- a/docs/architektur/medienzugriff-fuer-komponenten.md +++ b/docs/architektur/medienzugriff-fuer-komponenten.md @@ -129,3 +129,11 @@ ### Übernahme der früheren CMS-Bilder - Gespeicherte Revisionen bleiben unverändert; frühere Pfade werden beim Darstellen zugeordnet und beim nächsten Speichern durch die Kennung ersetzt. Frühere Pfade ohne Zuordnung bleiben über `PublicMedia` gültig. - Eine Slideshow gibt es im CMS nicht; `WebsiteMedia::presentMany` ist für sie vorbereitet und noch unbenutzt. + +## Präsentationszuordnungen (19.11.2026, ADR-41) + +Ein Titelbild, Trailer oder Galerieelement an einem Film, Modul, Programm oder Lizenzartikel ist eine Referenz (`presentation_assignments`) auf ein Inhaltselement. Die Rolle gehört zur Zuordnung. Sie ist keine Verwendung im Aufbau, keine Inhaltsart und keine Website-Freigabe. + +Öffentliche Seiten lesen ein solches Bild nur über `WebsiteImage` und damit über `WebsiteMedia`. Geschützte Originaldateien und Vorschaubilder der Bibliothek bleiben auf diesem Weg geschlossen. Wird die Freigabe im Medienmanager zurückgenommen, endet die öffentliche Ausgabe; Überschriften und Texte bleiben. + +Die ausführliche Beschreibung, Einsatzhinweise, Lizenzvermerke und Lehrtexte bleiben außerhalb der öffentlichen Karte. `PublicMaterialReader` und `PublicCatalogReader` lesen dafür die Klasse-A-Angaben (`EditorialProfileReader`) und keine Datei. diff --git a/docs/architektur/redaktionelle-informationsbasis.md b/docs/architektur/redaktionelle-informationsbasis.md new file mode 100644 index 0000000..ffaf927 --- /dev/null +++ b/docs/architektur/redaktionelle-informationsbasis.md @@ -0,0 +1,52 @@ +# Redaktionelle Informationsbasis + +**Stand:** 19.11.2026, Branch `feature/redaktionelle-basis`. Arbeitsannahme, keine formale Freigabe. ADR-41. + +Die Pflege bleibt an den bestehenden Fachobjekten. Es gibt keine zweite Medienverwaltung, keine Textmedien für gewöhnliche Beschreibungen und keine neue Produkthierarchie. + +## Vorhanden und weiterverwendet + +| Bedarf | Bestand | +|---|---| +| Arbeitstitel, Anzeigename, Kurz- und Langbeschreibung | `content_elements` und `compositions`; Änderung über `IdentityProfile`, protokolliert in `identity_changes`, ohne neue Fassung | +| Fachliche Materialart | `editorial_content_kinds` | +| Themen, Zielgruppen, Einsatz, Verwendungszweck | `editorial_dimensions` und `identity_dimension_values`, mehrere Werte je Dimension | +| Vorschaubild der Bibliothek | `thumbnail_path`, Route `editorial.card`, nur Redaktion | +| Website-Ausgabe | `WebsiteRelease`, `WebsiteMedia`, `WebsiteImage` (ADR-40) | +| Lehrinhalt und Aufbau | Fassungen, Lernziel, Mitglieder | +| Kommerz | Artikelstand, Angebot, Rechte | +| Auswahl eines Mediums | `EditorialCatalog::browse`, im Modul und Programm der bestehende Picker | + +## Ergänzt + +- `teaser` und `search_terms` an Inhaltselement, Komposition und, als eigene Abweichung, am Lizenzartikel. +- `editorial_text_variants` nur für eine abweichende Formulierung eines Feldes in einem Kontext (`kachel`, `detail`, `bibliothek`, `trainer`, `artikel`, `cms`, `suche`). +- Materialarten: Unterrichtsfilm, Kurzfilm, Trailer, Interview, Arbeitsblatt, Übungsbeschreibung, Titelbild, Hintergrundbild, Präsentationsbild, Audioanleitung. +- Dimensionen: Redaktioneller Verwendungszweck, Altersbereich und Zielgruppe, Einsatzbereich. +- `presentation_roles` und `presentation_assignments`. Rollen: Titelbild, alternatives Titelbild, Hero, Hover, Trailer, Vorschauclip, Audiovorschau, Interview, Galerie. Galerie und mehrfach belegte Rollen haben eine Reihenfolge. `source_version_id` hält die Herkunft eines Ausschnitts fest und wird nicht automatisch nachgezogen. +- Lesen: `EditorialProfileReader`, `PresentationMedia`. Programm- und Medienkarten sowie die Medienübersicht nutzen das. +- Oberfläche: Beschreibung und Präsentation am Medium, Angaben und Präsentation an Modul und Programm, Abschnitt Redaktion am Lizenzartikel. Die Bestandssuche ist `EditorialCatalog`. Im Modul und Programm öffnet „Medium aus dem Bestand auswählen“ denselben Picker wie der Aufbau, mit der Übernahme als Präsentation statt als Mitglied. + +## Auflösung + +1. Variante für den Kontext, wenn sie einen Text enthält. +2. Sonst die eigene Angabe am Objekt. +3. Beim Lizenzartikel sonst die Angabe der eindeutigen Quelle. Quelle ist die eine Wurzel des aktuellen Artikelstands, also entweder eine Inhaltsfassung oder eine Kompositionsfassung. Beides oder keins: keine Ableitung. +4. Sonst leer. + +Eigene Angaben des Lizenzartikels gehen vor. Nicht überschriebene Angaben bleiben an der Quelle. Preise, Rechte und der Artikelstand werden nicht gelesen und nicht geschrieben. + +## Öffentliche Karte + +`PublicCatalogReader` liest für die Kachel den Teaser, sonst die Kurzbeschreibung, sonst das Lernziel. `data.heading` und `data.summary` einer Premium-Karte ersetzen nur diese Karte. Ein leeres Kartenbild nimmt das zugeordnete Titelbild und gibt es nur über `WebsiteImage` aus. Ohne Freigabe entfällt das Bild, der Text bleibt. Bibliotheksvorschaubilder und Originaldateien bleiben geschlossen. + +Die Medienübersicht filtert technische Art, Materialart und Einordnung gemeinsam. „Verwendung“ zählt Aufbauten, nicht die Klassifikation und nicht die Präsentationsrolle. + +## Grenzen + +- ADR-29, öffentliche Profile, ist nicht umgesetzt. Die bisherigen Sichtbarkeitsregeln der Karten gelten. +- Dimensionen lassen sich in der Oberfläche nicht je Objektart ein- und ausblenden. Dafür gibt es kein Feld an der Dimension. +- Es gibt keine neue Schlagwortverwaltung. Freie Suchbegriffe stehen in `search_terms`. Kontrollierte Werte bleiben Dimensionen. +- Kein Videoschnitt und keine neue Transcodierung. Ein gebundener Ausschnitt wird bei einer neueren Fassung nur als veraltet gekennzeichnet. +- Der Medienpicker ist nicht neu gestaltet. Am Medium und am Lizenzartikel liegt dieselbe Bestandssuche als kurze Liste, weil der Picker des Aufbaus an dessen Seite hängt (ADR-40). +- Klasse B und Klasse C sind unverändert. diff --git a/resources/views/filament/editorial/editor.blade.php b/resources/views/filament/editorial/editor.blade.php index d9b919f..2baaa80 100644 --- a/resources/views/filament/editorial/editor.blade.php +++ b/resources/views/filament/editorial/editor.blade.php @@ -216,6 +216,14 @@ +

Präsentationsmedien

+ @include('filament.editorial.presentation') + @if ($this->canEditEditorial()) +
+ +
+ @endif +

Freigegebene Fassungen

@if ($this->versionChoices() === [])

Noch keine freigegebene Fassung. Sie entsteht mit „Fassung freigeben“, nicht beim Speichern des Entwurfs.

@@ -291,6 +299,10 @@ +
+ + +
@@ -299,6 +311,11 @@
+
+ + +
+ @include('filament.editorial.variants') @elseif ($this->moduleTab === 'didaktik')

Lernziel, Zeit und Material gehören zum fachlichen Stand. Sie landen im Entwurf und erzeugen erst mit „Fassung freigeben“ eine neue Fassung.

@@ -601,7 +618,11 @@ @if ($detail['edit_url'] ?? null) In der Verwaltung öffnen @endif - + @if ($this->pickerPurpose === 'praesentation') + + @else + + @endif
@else

Wähle einen Eintrag, sieh ihn dir an und übernimm ihn in den Entwurf.

diff --git a/resources/views/filament/editorial/license-desk.blade.php b/resources/views/filament/editorial/license-desk.blade.php new file mode 100644 index 0000000..27dfbf7 --- /dev/null +++ b/resources/views/filament/editorial/license-desk.blade.php @@ -0,0 +1,61 @@ +@php($profile = $this->editorialProfile('artikel')) +@php($editable = $this->canEditEditorial()) + +
+

Redaktion

+

Eigene Angaben ersetzen nur die Präsentation dieses Lizenzartikels. Leer gelassene Felder bleiben mit der fachlichen Quelle verbunden. Preise, Rechte und der Artikelstand stehen oben und werden hier nicht geändert.

+ @if ($profile->source) +

Fachliche Quelle: {{ $profile->source->display_title ?: ($profile->source->working_title ?? $profile->source->designation) }}.

+ @else +

Keine eindeutige fachliche Quelle. Es wird nichts aus einem Modul, Programm oder Medium abgeleitet.

+ @endif + @if ($this->deskFeedback !== '') +

{{ $this->deskFeedback }}

+ @endif +
+ + + + + + + + @foreach ($this->licenseDimensionGroups() as $group) +
+ {{ $group['label'] }} + @foreach ($group['values'] as $value) + + @endforeach +
+ @endforeach + @if ($editable) + + @endif +
+ @include('filament.editorial.variants') + @include('filament.editorial.presentation') + @include('filament.editorial.presentation-picker') +
diff --git a/resources/views/filament/editorial/presentation-picker.blade.php b/resources/views/filament/editorial/presentation-picker.blade.php new file mode 100644 index 0000000..9b271a0 --- /dev/null +++ b/resources/views/filament/editorial/presentation-picker.blade.php @@ -0,0 +1,26 @@ +
+ Medium aus dem Bestand zuordnen +

Dieselbe Bestandssuche wie im Modul und im Programm. Es wird nur verwiesen, nichts kopiert.

+ + @php($choices = $this->presentationChoices()) + @if ($choices['items'] === []) +

Nichts gefunden.

+ @else +
    + @foreach ($choices['items'] as $hit) +
  • + +
  • + @endforeach +
+ @if ($choices['more']) +

Es gibt weitere Treffer. Grenze die Suche ein.

+ @endif + + @endif +
diff --git a/resources/views/filament/editorial/presentation.blade.php b/resources/views/filament/editorial/presentation.blade.php new file mode 100644 index 0000000..7753a3f --- /dev/null +++ b/resources/views/filament/editorial/presentation.blade.php @@ -0,0 +1,65 @@ +
+

Zugeordnet wird ein Medium aus dem Bestand. Die Rolle gilt nur für diese Zuordnung. Sie gibt das Medium nicht frei und nimmt es nicht in den Lehrinhalt auf.

+ @if ($gaps = $this->editorialGaps()) +

Noch ohne Angabe: {{ implode(', ', $gaps) }}.

+ @endif + @if ($this->deskFeedback !== '') +

{{ $this->deskFeedback }}

+ @endif + + @if ($rows = $this->presentationRows()) +
    + @foreach ($rows as $row) +
  • + {{ $row['title'] }} + {{ $row['role_label'] }}@if ($row['standard']) · Standard-Titelbild @endif + @if ($row['kind']) + {{ $row['kind'] }} + @endif + {{ $row['release_label'] }} + @if ($row['binding']) + {{ $row['binding']['label'] }} + @else + Eigenständiges Medium, ohne Bindung an eine Fassung. + @endif + + Im Medienmanager öffnen + @if ($this->canEditEditorial()) + @if ($row['ordered']) + + + @endif + + @if ($this->canReleasePresentation()) + @if ($row['released']) + + @else + + @endif + @endif + @endif + +
  • + @endforeach +
+ @else +

Noch kein Präsentationsmedium. Das Vorschaubild der Bibliothek bleibt davon unabhängig.

+ @endif + + @if ($this->canEditEditorial()) + + @if (in_array($this->presentationRole, \App\Domain\Catalog\PresentationRole::BOUND_ROLES, true)) + + @endif +

Die tatsächliche Verwendung steht getrennt davon und wird nicht als Verwendungszweck gespeichert.

+ @endif +
diff --git a/resources/views/filament/editorial/variants.blade.php b/resources/views/filament/editorial/variants.blade.php new file mode 100644 index 0000000..c80e199 --- /dev/null +++ b/resources/views/filament/editorial/variants.blade.php @@ -0,0 +1,39 @@ +
+ Abweichende Formulierung für einen Kontext +

Ohne Eintrag gilt die zentrale Angabe. Eine Abweichung gilt nur für den gewählten Kontext und ändert die Quelle nicht.

+ @if ($variants = $this->variantRows()) +
    + @foreach ($variants as $variant) +
  • + {{ \App\Domain\Catalog\EditorialProfileReader::AUDIENCES[$variant->audience] ?? $variant->audience }} + · {{ $this->variantFieldLabel($variant->field) }}: + {{ \Illuminate\Support\Str::limit($variant->body, 160) }} + @if ($this->canEditEditorial()) + + @endif +
  • + @endforeach +
+ @endif + @if ($this->canEditEditorial()) + + + + + @endif +
diff --git a/resources/views/filament/media/card.blade.php b/resources/views/filament/media/card.blade.php index 42c6b9b..906d44c 100644 --- a/resources/views/filament/media/card.blade.php +++ b/resources/views/filament/media/card.blade.php @@ -10,7 +10,7 @@ @endif
-

{{ $card['type'] }}

+

{{ $card['type'] }}@if (! empty($card['editorialKind'])) · {{ $card['editorialKind'] }}@endif

{{ $card['title'] }} @if ($card['description'])

{{ $card['description'] }}

diff --git a/resources/views/filament/media/editor-panels.blade.php b/resources/views/filament/media/editor-panels.blade.php index f593ba0..dcf00ff 100644 --- a/resources/views/filament/media/editor-panels.blade.php +++ b/resources/views/filament/media/editor-panels.blade.php @@ -24,12 +24,18 @@ + + @@ -95,6 +101,7 @@ @endif @endif

+ @include('filament.editorial.variants') @php($history = $this->editorialHistory()) @if ($history !== [])
@@ -111,6 +118,11 @@
@endif + @if ($fokus === 'praesentation') + @include('filament.editorial.presentation') + @include('filament.editorial.presentation-picker') + @endif + @if ($fokus === 'verwendung') @php($card = $this->usageCard())

Eine Verwendung verweist auf eine konkrete Fassung. Die Rolle steht an der Verwendung, nicht als Kopie des Mediums.

diff --git a/resources/views/filament/media/library.blade.php b/resources/views/filament/media/library.blade.php index e7a0e97..dc16d66 100644 --- a/resources/views/filament/media/library.blade.php +++ b/resources/views/filament/media/library.blade.php @@ -21,7 +21,7 @@
- +
+
+ + +