Ergänze die gemeinsame redaktionelle Basis an den Fachobjekten.
CI Feature / test (push) Successful in 54s
Deploy Test / test (push) Successful in 47s
Deploy Test / deploy (push) Successful in 24s

Texte, Materialart und Präsentationsmedien bleiben am Medium, Modul, Programm und Lizenzartikel und werden von Verwaltung und Karten aus derselben Quelle gelesen, ohne Fassung oder Lizenz zu verändern.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-11-19 07:54:36 +01:00
1 parent c4be6ed8dc
commit f29ea58fd5
40 files changed
+2311 -20

No files matched your search

+2
View File
@@ -11,8 +11,10 @@ class Composition extends Model
protected $fillable = [
'designation',
'display_title',
'teaser',
'summary',
'description',
'search_terms',
'thumbnail_path',
'thumbnail_alt',
'thumbnail_source',
+2
View File
@@ -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',
+51
View File
@@ -0,0 +1,51 @@
<?php
namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Model;
/**
* Aufgelöste Klasse-A-Angaben eines Fachobjekts.
* Fehlende Felder bleiben leer. Es wird nichts materialisiert.
*/
final readonly class EditorialProfile
{
/**
* @param array<string, ResolvedText> $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',
};
}
}
@@ -0,0 +1,225 @@
<?php
namespace App\Domain\Catalog;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
/**
* Löst die Klasse-A-Texte eines Fachobjekts auf.
*
* Reihenfolge: abweichende Formulierung für den Kontext, eigene Angabe am Objekt,
* bei einem Lizenzartikel die Angabe der eindeutigen fachlichen Quelle.
* Eine Quelle gibt es nur, wenn der aktuelle Artikelstand genau eine Wurzel hat.
* Preise, Rechte und Fassungen werden nicht gelesen und nicht geschrieben.
*/
class EditorialProfileReader
{
public const AUDIENCES = [
'kachel' => 'Ö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(),
]);
}
}
@@ -0,0 +1,16 @@
<?php
namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Model;
class EditorialTextVariant extends Model
{
protected $fillable = [
'subject_type',
'subject_id',
'field',
'audience',
'body',
];
}
+12
View File
@@ -10,6 +10,13 @@ class LicenseArticle extends Model
{
protected $fillable = [
'code',
'working_title',
'display_title',
'teaser',
'summary',
'description',
'search_terms',
'editorial_content_kind_id',
'product_line',
'successor_of_id',
'current_release_id',
@@ -37,4 +44,9 @@ public function successorOf(): BelongsTo
{
return $this->belongsTo(self::class, 'successor_of_id');
}
public function editorialContentKind(): BelongsTo
{
return $this->belongsTo(EditorialContentKind::class);
}
}
@@ -0,0 +1,33 @@
<?php
namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class PresentationAssignment extends Model
{
protected $fillable = [
'subject_type',
'subject_id',
'content_element_id',
'presentation_role_id',
'position',
'source_version_id',
];
public function role(): BelongsTo
{
return $this->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');
}
}
+269
View File
@@ -0,0 +1,269 @@
<?php
namespace App\Domain\Catalog;
use App\Domain\Media\WebsiteMedia;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
/**
* Präsentationsmedien sind Referenzen auf Inhaltselemente.
* Die Rolle gehört zur Zuordnung. Eine Zuordnung gibt nichts frei und ändert keine Fassung.
*/
class PresentationMedia
{
public function __construct(private readonly WebsiteMedia $website) {}
/**
* @return list<array<string, mixed>>
*/
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(),
]);
}
}
+44
View File
@@ -0,0 +1,44 @@
<?php
namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class PresentationRole extends Model
{
/** Rollen, deren Herkunft an einer Film- oder Audiofassung festgehalten werden kann. */
public const BOUND_ROLES = ['trailer', 'vorschauclip', 'audiovorschau'];
/** Reihenfolge, in der ein öffentliches Titelbild gesucht wird. */
public const COVER_ROLES = ['titelbild', 'hero', 'hover', 'titelbild_alternativ', 'galerie'];
protected $fillable = [
'slug',
'label',
'multiple',
'ordered',
'sort_order',
];
protected function casts(): array
{
return [
'multiple' => 'boolean',
'ordered' => 'boolean',
];
}
public function assignments(): HasMany
{
return $this->hasMany(PresentationAssignment::class);
}
/**
* @return array<string, string>
*/
public static function selectOptions(): array
{
return static::query()->orderBy('sort_order')->pluck('label', 'slug')->all();
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php
namespace App\Domain\Catalog;
/**
* Ein aufgelöster redaktioneller Text. Der Wert wird nicht kopiert:
* eigen steht am Fachobjekt, variante ist eine Abweichung für einen Kontext,
* quelle verweist auf das eindeutig zugeordnete Fachobjekt eines Lizenzartikels.
*/
final readonly class ResolvedText
{
public function __construct(
public ?string $value,
public string $origin,
public ?string $label,
) {}
}
+19
View File
@@ -37,4 +37,23 @@ public function __construct(
public array $missing = [],
public ?string $style = null,
) {}
public function withText(?string $title, ?string $summary): self
{
return new self(
title: $title ?? $this->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,
);
}
}
+10 -4
View File
@@ -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,
@@ -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,
@@ -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;
}
}
@@ -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())
@@ -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;
}
}
@@ -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());
@@ -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<int, string>
*/
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,
];
@@ -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 ?? '');
@@ -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'),
]);
}
@@ -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<int|string> */
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<array{label: string, values: list<array{id: int, label: string}>}>
*/
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 [
+10
View File
@@ -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')
@@ -0,0 +1,282 @@
<?php
namespace App\Filament\Support;
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\EditorialProfile;
use App\Domain\Catalog\EditorialProfileReader;
use App\Domain\Catalog\EditorialTextVariant;
use App\Domain\Catalog\PresentationMedia;
use App\Domain\Catalog\PresentationRole;
use App\Domain\Media\WebsiteRelease;
use App\Filament\Resources\ContentElements\ContentElementResource;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
/**
* Gemeinsame Bedienung für Präsentationsmedien und abweichende Formulierungen.
* Die Texte selbst bleiben an den vorhandenen Feldern der jeweiligen Seite.
*/
trait ManagesEditorialSurface
{
public string $presentationRole = 'titelbild';
public string $presentationQuery = '';
public string $presentationPick = '';
public bool $bindToVersion = true;
public string $deskFeedback = '';
public string $variantAudience = 'kachel';
public string $variantField = 'teaser';
public string $variantBody = '';
public function editorialSubject(): Model
{
return $this->getRecord();
}
public function editorialProfile(?string $audience = null): EditorialProfile
{
return app(EditorialProfileReader::class)->read($this->editorialSubject(), $audience);
}
/**
* @return list<string>
*/
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<array<string, mixed>>
*/
public function presentationRows(): array
{
return app(PresentationMedia::class)->rows($this->editorialSubject());
}
/**
* @return array<string, string>
*/
public function presentationRoleOptions(): array
{
return PresentationRole::selectOptions();
}
/**
* @return array{items: list<array<string, mixed>>, 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<EditorialTextVariant>
*/
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();
}
}
}
+10 -2
View File
@@ -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,
@@ -0,0 +1,191 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('content_elements', function (Blueprint $table) {
$table->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();
}
};
@@ -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.
+3 -1
View File
@@ -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).
@@ -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.
@@ -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.
@@ -216,6 +216,14 @@
<button type="button" class="luf-primary" wire:click="openModule">{{ $this->hostLabel() }} bearbeiten</button>
</div>
<h3>Präsentationsmedien</h3>
@include('filament.editorial.presentation')
@if ($this->canEditEditorial())
<div class="luf-actions">
<button type="button" class="luf-quiet" wire:click="openPresentationPicker">Medium aus dem Bestand auswählen</button>
</div>
@endif
<h3>Freigegebene Fassungen</h3>
@if ($this->versionChoices() === [])
<p class="luf-empty">Noch keine freigegebene Fassung. Sie entsteht mit „Fassung freigeben“, nicht beim Speichern des Entwurfs.</p>
@@ -291,6 +299,10 @@
<label for="anzeige">Titel</label>
<input id="anzeige" type="text" wire:model="displayTitle" placeholder="Leer lässt den Namen stehen">
</div>
<div class="luf-field">
<label for="teaser">Teaser</label>
<textarea id="teaser" rows="2" wire:model="teaser"></textarea>
</div>
<div class="luf-field">
<label for="kurz">Kurzbeschreibung</label>
<textarea id="kurz" rows="3" wire:model="summary"></textarea>
@@ -299,6 +311,11 @@
<label for="beschreibung">Ausführliche Beschreibung</label>
<textarea id="beschreibung" rows="8" wire:model="description"></textarea>
</div>
<div class="luf-field">
<label for="suche">Suchbegriffe</label>
<input id="suche" type="text" wire:model="searchTerms" placeholder="Begriffe für die Suche">
</div>
@include('filament.editorial.variants')
@elseif ($this->moduleTab === 'didaktik')
<p class="luf-note">Lernziel, Zeit und Material gehören zum fachlichen Stand. Sie landen im Entwurf und erzeugen erst mit „Fassung freigeben“ eine neue Fassung.</p>
<div class="luf-field">
@@ -601,7 +618,11 @@
@if ($detail['edit_url'] ?? null)
<a class="luf-link" href="{{ $detail['edit_url'] }}">In der Verwaltung öffnen</a>
@endif
<button type="button" class="luf-primary" wire:click="addPart('{{ $detail['target'] }}')">Übernehmen</button>
@if ($this->pickerPurpose === 'praesentation')
<button type="button" class="luf-primary" wire:click="assignFromPicker('{{ $detail['target'] }}')">Als Präsentation übernehmen</button>
@else
<button type="button" class="luf-primary" wire:click="addPart('{{ $detail['target'] }}')">Übernehmen</button>
@endif
</div>
@else
<p class="luf-empty">Wähle einen Eintrag, sieh ihn dir an und übernimm ihn in den Entwurf.</p>
@@ -0,0 +1,61 @@
@php($profile = $this->editorialProfile('artikel'))
@php($editable = $this->canEditEditorial())
<section class="luf-redaktion" aria-label="Redaktion des Lizenzartikels">
<h2>Redaktion</h2>
<p>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.</p>
@if ($profile->source)
<p>Fachliche Quelle: {{ $profile->source->display_title ?: ($profile->source->working_title ?? $profile->source->designation) }}.</p>
@else
<p>Keine eindeutige fachliche Quelle. Es wird nichts aus einem Modul, Programm oder Medium abgeleitet.</p>
@endif
@if ($this->deskFeedback !== '')
<p role="status">{{ $this->deskFeedback }}</p>
@endif
<form wire:submit="saveLicenseEditorial">
<label>Interner Arbeitstitel
<input type="text" wire:model="workingTitle" @disabled(! $editable)>
</label>
<label>Anzeigename
<input type="text" wire:model="displayTitle" placeholder="{{ $profile->origin('display_title') === 'quelle' ? $profile->value('display_title') : '' }}" @disabled(! $editable)>
<span>{{ $profile->originLabel('display_title') }}</span>
</label>
<label>Teaser
<textarea rows="2" wire:model="teaser" placeholder="{{ $profile->origin('teaser') === 'quelle' ? $profile->value('teaser') : '' }}" @disabled(! $editable)></textarea>
<span>{{ $profile->originLabel('teaser') }}</span>
</label>
<label>Kurzbeschreibung
<textarea rows="3" wire:model="summary" placeholder="{{ $profile->origin('summary') === 'quelle' ? $profile->value('summary') : '' }}" @disabled(! $editable)></textarea>
<span>{{ $profile->originLabel('summary') }}</span>
</label>
<label>Ausführliche Beschreibung
<textarea rows="6" wire:model="descriptionText" placeholder="{{ $profile->origin('description') === 'quelle' ? $profile->value('description') : '' }}" @disabled(! $editable)></textarea>
<span>{{ $profile->originLabel('description') }}</span>
</label>
<label>Suchbegriffe
<input type="text" wire:model="searchTerms" @disabled(! $editable)>
</label>
<label>Inhaltsart
<select wire:model="kindId" @disabled(! $editable)>
<option value="">Keine</option>
@foreach (\App\Domain\Catalog\EditorialContentKind::selectOptions() as $id => $label)
<option value="{{ $id }}">{{ $label }}</option>
@endforeach
</select>
</label>
@foreach ($this->licenseDimensionGroups() as $group)
<fieldset>
<legend>{{ $group['label'] }}</legend>
@foreach ($group['values'] as $value)
<label><input type="checkbox" value="{{ $value['id'] }}" wire:model="dimensionIds" @disabled(! $editable)> {{ $value['label'] }}</label>
@endforeach
</fieldset>
@endforeach
@if ($editable)
<button type="submit">Redaktion speichern</button>
@endif
</form>
@include('filament.editorial.variants')
@include('filament.editorial.presentation')
@include('filament.editorial.presentation-picker')
</section>
@@ -0,0 +1,26 @@
<details>
<summary>Medium aus dem Bestand zuordnen</summary>
<p>Dieselbe Bestandssuche wie im Modul und im Programm. Es wird nur verwiesen, nichts kopiert.</p>
<label>Suche
<input type="search" wire:model.live.debounce.300ms="presentationQuery" placeholder="Titel oder Beschreibung">
</label>
@php($choices = $this->presentationChoices())
@if ($choices['items'] === [])
<p>Nichts gefunden.</p>
@else
<ul>
@foreach ($choices['items'] as $hit)
<li wire:key="wahl-{{ $hit['target'] }}">
<label>
<input type="radio" value="{{ $hit['target'] }}" wire:model="presentationPick">
{{ $hit['title'] }} · {{ $hit['kind'] }}
</label>
</li>
@endforeach
</ul>
@if ($choices['more'])
<p>Es gibt weitere Treffer. Grenze die Suche ein.</p>
@endif
<button type="button" wire:click="assignPickedPresentation">Zuordnen</button>
@endif
</details>
@@ -0,0 +1,65 @@
<div class="luf-redaktion">
<p>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.</p>
@if ($gaps = $this->editorialGaps())
<p>Noch ohne Angabe: {{ implode(', ', $gaps) }}.</p>
@endif
@if ($this->deskFeedback !== '')
<p role="status">{{ $this->deskFeedback }}</p>
@endif
@if ($rows = $this->presentationRows())
<ul>
@foreach ($rows as $row)
<li wire:key="praesentation-{{ $row['id'] }}">
<strong>{{ $row['title'] }}</strong>
<span>{{ $row['role_label'] }}@if ($row['standard']) · Standard-Titelbild @endif</span>
@if ($row['kind'])
<span>{{ $row['kind'] }}</span>
@endif
<span>{{ $row['release_label'] }}</span>
@if ($row['binding'])
<span>{{ $row['binding']['label'] }}</span>
@else
<span>Eigenständiges Medium, ohne Bindung an eine Fassung.</span>
@endif
<span>
<a href="{{ \App\Filament\Resources\ContentElements\ContentElementResource::getUrl('view', ['record' => $row['element_id']]) }}">Im Medienmanager öffnen</a>
@if ($this->canEditEditorial())
@if ($row['ordered'])
<button type="button" wire:click="movePresentation({{ $row['id'] }}, -1)">Nach vorn</button>
<button type="button" wire:click="movePresentation({{ $row['id'] }}, 1)">Nach hinten</button>
@endif
<button type="button" wire:click="detachPresentation({{ $row['id'] }})">Zuordnung lösen</button>
@if ($this->canReleasePresentation())
@if ($row['released'])
<button type="button" wire:click="withdrawAssigned({{ $row['element_id'] }})">Website-Freigabe zurücknehmen</button>
@else
<button type="button" wire:click="releaseAssigned({{ $row['element_id'] }})">Für die Website freigeben</button>
@endif
@endif
@endif
</span>
</li>
@endforeach
</ul>
@else
<p>Noch kein Präsentationsmedium. Das Vorschaubild der Bibliothek bleibt davon unabhängig.</p>
@endif
@if ($this->canEditEditorial())
<label>Rolle
<select wire:model.live="presentationRole">
@foreach ($this->presentationRoleOptions() as $slug => $label)
<option value="{{ $slug }}">{{ $label }}</option>
@endforeach
</select>
</label>
@if (in_array($this->presentationRole, \App\Domain\Catalog\PresentationRole::BOUND_ROLES, true))
<label>
<input type="checkbox" wire:model="bindToVersion">
Herkunft an der aktuellen Fassung festhalten. Eine spätere Fassung erzeugt keinen neuen Clip.
</label>
@endif
<p>Die tatsächliche Verwendung steht getrennt davon und wird nicht als Verwendungszweck gespeichert.</p>
@endif
</div>
@@ -0,0 +1,39 @@
<details>
<summary>Abweichende Formulierung für einen Kontext</summary>
<p>Ohne Eintrag gilt die zentrale Angabe. Eine Abweichung gilt nur für den gewählten Kontext und ändert die Quelle nicht.</p>
@if ($variants = $this->variantRows())
<ul>
@foreach ($variants as $variant)
<li wire:key="variante-{{ $variant->id }}">
{{ \App\Domain\Catalog\EditorialProfileReader::AUDIENCES[$variant->audience] ?? $variant->audience }}
· {{ $this->variantFieldLabel($variant->field) }}:
{{ \Illuminate\Support\Str::limit($variant->body, 160) }}
@if ($this->canEditEditorial())
<button type="button" wire:click="forgetVariant({{ $variant->id }})">Entfernen</button>
@endif
</li>
@endforeach
</ul>
@endif
@if ($this->canEditEditorial())
<label>Kontext
<select wire:model="variantAudience">
@foreach (\App\Domain\Catalog\EditorialProfileReader::AUDIENCES as $key => $label)
<option value="{{ $key }}">{{ $label }}</option>
@endforeach
</select>
</label>
<label>Angabe
<select wire:model="variantField">
<option value="display_title">Anzeigename</option>
<option value="teaser">Teaser</option>
<option value="summary">Kurzbeschreibung</option>
<option value="description">Ausführliche Beschreibung</option>
</select>
</label>
<label>Abweichender Text
<textarea rows="3" wire:model="variantBody"></textarea>
</label>
<button type="button" wire:click="saveVariant">Abweichung speichern</button>
@endif
</details>
@@ -10,7 +10,7 @@
@endif
</a>
<div class="luf-medium-body">
<p class="luf-medium-kind">{{ $card['type'] }}</p>
<p class="luf-medium-kind">{{ $card['type'] }}@if (! empty($card['editorialKind'])) · {{ $card['editorialKind'] }}@endif</p>
<a class="luf-medium-title" href="{{ $card['url'] }}">{{ $card['title'] }}</a>
@if ($card['description'])
<p class="luf-medium-copy">{{ $card['description'] }}</p>
@@ -24,12 +24,18 @@
<label>Anzeigename
<input type="text" wire:model.live.debounce.300ms="displayTitle" @disabled(! $editable)>
</label>
<label class="is-wide">Teaser
<textarea rows="2" wire:model.live.debounce.300ms="teaser" @disabled(! $editable)></textarea>
</label>
<label class="is-wide">Kurzbeschreibung
<textarea rows="3" wire:model.live.debounce.300ms="summary" @disabled(! $editable)></textarea>
</label>
<label class="is-wide">Beschreibung
<textarea rows="6" wire:model.live.debounce.300ms="descriptionText" @disabled(! $editable)></textarea>
</label>
<label class="is-wide">Suchbegriffe
<input type="text" wire:model="searchTerms" @disabled(! $editable) placeholder="Begriffe für die Suche, durch Komma getrennt">
</label>
<label>Hinweise für den Einsatz
<textarea rows="4" wire:model.live.debounce.300ms="usageNote" @disabled(! $editable)></textarea>
</label>
@@ -95,6 +101,7 @@
@endif
@endif
</p>
@include('filament.editorial.variants')
@php($history = $this->editorialHistory())
@if ($history !== [])
<details>
@@ -111,6 +118,11 @@
</div>
@endif
@if ($fokus === 'praesentation')
@include('filament.editorial.presentation')
@include('filament.editorial.presentation-picker')
@endif
@if ($fokus === 'verwendung')
@php($card = $this->usageCard())
<p>Eine Verwendung verweist auf eine konkrete Fassung. Die Rolle steht an der Verwendung, nicht als Kopie des Mediums.</p>
@@ -21,7 +21,7 @@
<input id="medien-suche" type="search" wire:model.live.debounce.300ms="suche" placeholder="Titel oder Beschreibung">
</div>
<div class="luf-media-field">
<label for="medien-art">Art</label>
<label for="medien-art">Technische Art</label>
<select id="medien-art" wire:model.live="art">
<option value="">Alle Arten</option>
@foreach ($this->typeOptions() as $type)
@@ -29,6 +29,15 @@
@endforeach
</select>
</div>
<div class="luf-media-field">
<label for="medien-inhaltsart">Fachliche Materialart</label>
<select id="medien-inhaltsart" wire:model.live="inhaltsart">
<option value="">Alle Materialarten</option>
@foreach ($this->contentKindOptions() as $id => $label)
<option value="{{ $id }}">{{ $label }}</option>
@endforeach
</select>
</div>
<div class="luf-media-field">
<label for="medien-freigabe">Freigabe</label>
<select id="medien-freigabe" wire:model.live="freigabe">
@@ -102,7 +111,7 @@
</div>
</div>
<p class="luf-media-hint">Freigabe meint die Fassung des Mediums. Sie ist weder die Veröffentlichung auf der Website noch ein Nachweis, dass jemand das Medium öffnen darf. Medien, die nur noch deaktivierte Fassungen haben, und archivierte Medien bleiben über die Filter auffindbar.</p>
<p class="luf-media-hint">Freigabe meint die Fassung des Mediums. Sie ist weder die Veröffentlichung auf der Website noch ein Nachweis, dass jemand das Medium öffnen darf. Die Materialart und die Einordnung sind die redaktionelle Klassifikation. Verwendung zeigt, wo das Medium tatsächlich referenziert ist, und ist keine Klassifikation. Medien, die nur noch deaktivierte Fassungen haben, und archivierte Medien bleiben über die Filter auffindbar.</p>
@if ($this->filtersActive())
<p class="luf-media-reset">
@@ -10,6 +10,7 @@
<nav class="luf-editor-tabs" role="tablist" aria-label="Bereiche des Mediums">
@foreach ([
'beschreibung' => 'Beschreibung',
'praesentation' => 'Präsentation',
'inhalt' => 'Inhalt',
'fassungen' => 'Fassungen',
'verwendung' => 'Verwendung',
@@ -19,7 +20,7 @@
@endforeach
</nav>
@if (in_array($fokus, ['beschreibung', 'verwendung', 'vorschau'], true))
@if (in_array($fokus, ['beschreibung', 'praesentation', 'verwendung', 'vorschau'], true))
@include('filament.media.editor-panels')
@else
<div style="display: grid; gap: 1.5rem;">
+530
View File
@@ -0,0 +1,530 @@
<?php
namespace Tests\Feature;
use App\Domain\Catalog\ArticleRelease;
use App\Domain\Catalog\ArticleService;
use App\Domain\Catalog\CompositionDisplayRelease;
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\CompositionMember;
use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Catalog\EditorialDimension;
use App\Domain\Catalog\EditorialDimensionValue;
use App\Domain\Catalog\EditorialProfileReader;
use App\Domain\Catalog\IdentityDimension;
use App\Domain\Catalog\IdentityDimensionValue;
use App\Domain\Catalog\Offer;
use App\Domain\Catalog\PresentationAssignment;
use App\Domain\Catalog\PresentationMedia;
use App\Domain\Catalog\ReleaseStatus;
use App\Domain\Cms\Page;
use App\Domain\Cms\PageRevision;
use App\Domain\Cms\PageService;
use App\Domain\Cms\Widgets\Support\WebsiteImage;
use App\Domain\Media\MediaRendition;
use App\Domain\Media\WebsiteMedia;
use App\Domain\Media\WebsiteRelease;
use App\Filament\Resources\ContentElements\Pages\ViewContentElement;
use App\Filament\Resources\Courses\Pages\EditCourse;
use App\Filament\Resources\Exercises\Pages\EditExercise;
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
use App\Filament\Support\MediaLibrary;
use App\Models\User;
use Filament\Facades\Filament;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Storage;
use Livewire\Livewire;
use Tests\Support\BuildsCatalog;
use Tests\TestCase;
class EditorialDeskTest extends TestCase
{
use BuildsCatalog;
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
Storage::fake('media_derived');
Storage::fake('media_public');
Storage::fake('media_originals');
}
public function test_a_film_keeps_its_version_when_editorial_text_and_presentation_change(): void
{
$content = app(ContentService::class);
$film = $content->createElement('film', 'film', 'Lara im Park');
$version = $content->publishElementVersion($film, 'Filmfassung');
$cover = $this->image('Titel Park');
$trailer = $this->trailer('Trailer Park');
$editor = $this->editor();
$this->actingAs($editor, 'staff');
Livewire::test(ViewContentElement::class, ['record' => $film->getKey()])
->set('bereich', 'beschreibung')
->set('displayTitle', 'Lara im Park')
->set('teaser', 'Ein Nachmittag im Park.')
->set('summary', 'Lara übt, ihre Grenze zu sagen.')
->set('descriptionText', 'Ausführlich: die Szene im Park und was sie zeigt.')
->set('searchTerms', 'park, grenze')
->set('kindId', $this->kind('unterrichtsfilm'))
->call('saveEditorial')
->assertSee('Es gibt keine neue Fassung.');
$film->refresh();
$this->assertSame(1, $film->versions()->count());
$this->assertSame($version->id, $film->versions()->first()->id);
$this->assertSame('Ein Nachmittag im Park.', $film->teaser);
$this->assertSame($this->kind('unterrichtsfilm'), $film->editorial_content_kind_id);
$purpose = $this->dimensionValue('verwendungszweck', 'training');
$audience = $this->dimensionValue('zielgruppe', 'kinder');
app(IdentityDimension::class)->assign($film, $purpose);
app(IdentityDimension::class)->assign($film, $audience);
Livewire::test(ViewContentElement::class, ['record' => $film->getKey()])
->set('bereich', 'praesentation')
->set('presentationRole', 'titelbild')
->set('presentationPick', 'element:'.$cover->versions()->first()->id)
->call('assignPickedPresentation')
->set('presentationRole', 'trailer')
->set('presentationPick', 'element:'.$trailer->versions()->first()->id)
->set('bindToVersion', true)
->call('assignPickedPresentation')
->assertSee('Titel Park')
->assertSee('Trailer Park')
->assertSee('Standard-Titelbild')
->call('releaseAssigned', $trailer->id)
->assertSee('Für die Website freigegeben');
$film->refresh();
$trailer->refresh();
$this->assertSame(1, $film->versions()->count());
$this->assertSame($version->id, $film->versions()->value('id'));
$this->assertNotNull($trailer->website_released_at);
$this->assertNotNull(app(WebsiteMedia::class)->present($trailer));
Livewire::test(ViewContentElement::class, ['record' => $film->getKey()])
->call('withdrawAssigned', $trailer->id);
$this->assertNull($trailer->fresh()->website_released_at);
$this->assertNull(app(WebsiteMedia::class)->present($trailer));
$this->assertSame(2, PresentationAssignment::query()->where('subject_id', $film->id)->count());
}
public function test_a_module_description_does_not_version_the_composition_or_create_a_text_medium(): void
{
$content = app(ContentService::class);
$film = $content->publishElementVersion($content->createElement('film', 'film', 'Lara im Park'), 'Film');
$module = $content->createComposition('Eigene Grenzen erkennen');
$module->editorial_content_kind_id = $this->kind('modul');
$module->save();
$version = $content->publishComposition(
$module,
[['role' => 'Film', 'target' => $film]],
didactic: ['learning_goal' => 'Eine Grenze erkennen und sagen.'],
);
$textsBefore = ContentElement::query()->where('output_class', 'text')->count();
$this->actingAs($this->editor(), 'staff');
Livewire::test(EditExercise::class, ['record' => $module->getKey()])
->set('teaser', 'Kurz in das Modul.')
->set('summary', 'Kinder benennen eine eigene Grenze.')
->set('description', 'Ausführliche Modulbeschreibung, kein Lehrtext.')
->set('dimensionIds', [$this->dimensionValue('zielgruppe', 'kinder')->id])
->call('saveDisplay')
->assertSee('Die Fassung bleibt unverändert.');
$module->refresh();
$version->refresh();
$this->assertSame(1, $module->versions()->count());
$this->assertSame('Eine Grenze erkennen und sagen.', $version->learning_goal);
$this->assertSame('Kurz in das Modul.', $module->teaser);
$this->assertTrue(
CompositionMember::query()->where('composition_version_id', $version->id)->where('content_element_version_id', $film->id)->exists()
);
$this->assertSame($textsBefore, ContentElement::query()->where('output_class', 'text')->count());
$cover = $this->image('Modulbild');
app(PresentationMedia::class)->assign($module, 'titelbild', $cover->id, null, $this->editor());
$this->assertSame(1, $module->fresh()->versions()->count());
$this->assertSame(
1,
CompositionMember::query()->where('composition_version_id', $version->id)->count()
);
}
public function test_a_program_keeps_its_own_cover_trailer_and_gallery_order(): void
{
$content = app(ContentService::class);
$program = $content->createComposition('Stark im Alltag', CompositionKind::Kurs);
$program->editorial_content_kind_id = $this->kind('programm');
$program->save();
$content->publishComposition($program, [[
'role' => 'Text',
'target' => $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Inhalt'),
]]);
$cover = $this->image('Programmcover');
$trailer = $this->trailer('Programmtrailer');
$first = $this->image('Galerie eins');
$second = $this->image('Galerie zwei');
$third = $this->image('Galerie drei');
$media = app(PresentationMedia::class);
$actor = $this->editor();
$media->assign($program, 'titelbild', $cover->id, null, $actor);
$media->assign($program, 'trailer', $trailer->id, $trailer->versions()->first()->id, $actor);
$media->assign($program, 'galerie', $first->id, null, $actor);
$media->assign($program, 'galerie', $second->id, null, $actor);
$media->assign($program, 'galerie', $third->id, null, $actor);
$gallery = PresentationAssignment::query()
->where('subject_id', $program->id)
->whereHas('role', fn ($query) => $query->where('slug', 'galerie'))
->orderBy('position')
->pluck('content_element_id')
->all();
$this->assertSame([$first->id, $second->id, $third->id], $gallery);
$firstAssignment = PresentationAssignment::query()->where('content_element_id', $first->id)->where('subject_id', $program->id)->first();
$media->move($program, $firstAssignment->id, 1, $actor);
$gallery = PresentationAssignment::query()
->where('subject_id', $program->id)
->whereHas('role', fn ($query) => $query->where('slug', 'galerie'))
->orderBy('position')
->pluck('content_element_id')
->all();
$this->assertSame([$second->id, $first->id, $third->id], $gallery);
$this->assertSame(1, $program->fresh()->versions()->count());
app(IdentityDimension::class)->assign($program, $this->dimensionValue('zielgruppe', 'eltern'));
$found = app(MediaLibrary::class)->cards([
'suche' => '',
'inhaltsart' => '',
], false);
$this->assertNotContains('Stark im Alltag', array_column($found, 'title'));
$this->actingAs($actor, 'staff');
Livewire::test(EditCourse::class, ['record' => $program->getKey()])
->assertSee('Programmcover')
->assertSee('Galerie zwei')
->assertSee('Standard-Titelbild');
}
public function test_a_license_article_overrides_only_its_own_presentation(): void
{
$content = app(ContentService::class);
$film = $content->createElement('film', 'film', 'Lara im Park');
$film->display_title = 'Lara im Park';
$film->teaser = 'Teaser der Fassung';
$film->summary = 'Kurz aus dem Film';
$film->description = 'Lang aus dem Film';
$film->save();
$version = $content->publishElementVersion($film, 'Film');
$articles = app(ArticleService::class);
$article = $articles->create('LARA-PARK', 'Alltag');
$release = $articles->publishRelease($article, $version, 'Derselbe Unterrichtsfilm');
$offers = Offer::query()->count();
$note = $release->classification_note;
$number = $release->number;
$keeper = User::factory()->katalogverwalter()->create();
$keeper->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
$this->actingAs($keeper, 'staff');
$profile = app(EditorialProfileReader::class)->read($article->fresh(), 'artikel');
$this->assertSame('quelle', $profile->origin('summary'));
$this->assertSame('Kurz aus dem Film', $profile->value('summary'));
$this->assertSame('Lara im Park', $profile->value('display_title'));
Livewire::test(ViewLicenseArticle::class, ['record' => $article->getKey()])
->set('summary', 'Eigene Artikelbeschreibung')
->call('saveLicenseEditorial')
->assertSee('Stand, Preis und Rechte bleiben unverändert.')
->assertSee('Übernommen von Lara im Park')
->assertSee('Eigene Angabe');
$article->refresh();
$release->refresh();
$this->assertSame('Eigene Artikelbeschreibung', $article->summary);
$this->assertNull($article->teaser);
$again = app(EditorialProfileReader::class)->read($article, 'artikel');
$this->assertSame('eigen', $again->origin('summary'));
$this->assertSame('Eigene Artikelbeschreibung', $again->value('summary'));
$this->assertSame('quelle', $again->origin('teaser'));
$this->assertSame('Teaser der Fassung', $again->value('teaser'));
$this->assertSame($number, $release->number);
$this->assertSame($note, $release->classification_note);
$this->assertSame(ReleaseStatus::Veroeffentlicht, $release->status);
$this->assertSame($offers, Offer::query()->count());
$this->assertSame(1, $film->fresh()->versions()->count());
$cover = $this->image('Artikelbild');
app(PresentationMedia::class)->assign($article, 'titelbild', $cover->id, null, $keeper);
$this->assertSame($release->id, $article->fresh()->current_release_id);
$this->assertSame(1, ArticleRelease::query()->count());
$ambiguous = $articles->create('UNDEUTIG');
$program = $content->createComposition('Zweite Wurzel', CompositionKind::Kurs);
$programVersion = $content->publishComposition($program, [['role' => 'Film', 'target' => $version]]);
$ambiguous->releases()->create([
'number' => 1,
'classification_note' => 'zwei Wurzeln',
'status' => ReleaseStatus::Entwurf,
'root_element_version_id' => $version->id,
'root_composition_version_id' => $programVersion->id,
]);
$ambiguous->current_release_id = $ambiguous->releases()->value('id');
$ambiguous->save();
$this->assertNull(app(EditorialProfileReader::class)->sourceOf($ambiguous->fresh()));
$this->assertSame('leer', app(EditorialProfileReader::class)->read($ambiguous->fresh())->origin('summary'));
}
public function test_classification_is_filterable_and_does_not_change_use_or_release(): void
{
$content = app(ContentService::class);
$lesson = $content->createElement('film', 'film', 'Unterricht');
$lesson->editorial_content_kind_id = $this->kind('unterrichtsfilm');
$lesson->teaser = 'sucht-den-unterricht';
$lesson->save();
$content->publishElementVersion($lesson, 'Film');
$clip = $content->createElement('film', 'film', 'Nur Trailer');
$clip->editorial_content_kind_id = $this->kind('trailer');
$clip->save();
$content->publishElementVersion($clip, 'Clip');
$picture = $content->createElement('bild', 'bild', 'Keyvisual');
$picture->editorial_content_kind_id = $this->kind('titelbild');
$picture->thumbnail_path = 'vorschau/key.jpg';
$picture->save();
$content->publishElementVersion($picture, null, ['file' => 'inhalte/key.jpg']);
$backdrop = $content->createElement('bild', 'bild', 'Hintergrund');
$backdrop->editorial_content_kind_id = $this->kind('hintergrundbild');
$backdrop->save();
$content->publishElementVersion($backdrop, null, ['file' => 'inhalte/hintergrund.jpg']);
app(IdentityDimension::class)->assign($lesson, $this->dimensionValue('verwendungszweck', 'training'));
app(IdentityDimension::class)->assign($lesson, $this->dimensionValue('verwendungszweck', 'website'));
app(IdentityDimension::class)->assign($clip, $this->dimensionValue('verwendungszweck', 'website'));
$releasedAt = null;
$lesson->website_released_at = null;
$lesson->save();
$library = app(MediaLibrary::class);
$lessons = array_column($library->cards(['inhaltsart' => (string) $this->kind('unterrichtsfilm')], false), 'title');
$clips = array_column($library->cards(['inhaltsart' => (string) $this->kind('trailer')], false), 'title');
$pictures = array_column($library->cards(['art' => 'bild', 'inhaltsart' => (string) $this->kind('titelbild')], false), 'title');
$backs = array_column($library->cards(['inhaltsart' => (string) $this->kind('hintergrundbild')], false), 'title');
$this->assertSame(['Unterricht'], $lessons);
$this->assertSame(['Nur Trailer'], $clips);
$this->assertSame(['Keyvisual'], $pictures);
$this->assertSame(['Hintergrund'], $backs);
$this->assertNotContains('Nur Trailer', $lessons);
$byPurpose = array_column($library->cards([
'einordnung' => (string) $this->dimensionValue('verwendungszweck', 'training')->id,
'nutzung' => 'unbenutzt',
], false), 'title');
$this->assertContains('Unterricht', $byPurpose);
$this->assertNotContains('Nur Trailer', $byPurpose);
$bySearch = array_column($library->cards(['suche' => 'sucht-den-unterricht'], false), 'title');
$this->assertSame(['Unterricht'], $bySearch);
$lesson->editorial_content_kind_id = $this->kind('interview');
$lesson->save();
$lesson->refresh();
$this->assertSame($releasedAt, $lesson->website_released_at);
$this->assertSame(0, CompositionMember::query()->where('content_element_version_id', $lesson->versions()->first()->id)->count());
$this->assertSame(2, IdentityDimensionValue::query()->where('subject_type', $lesson->getMorphClass())->where('subject_id', $lesson->id)->count());
}
public function test_the_program_card_uses_central_text_and_only_a_released_cover(): void
{
$content = app(ContentService::class);
$program = $content->createComposition('Programm Karte', CompositionKind::Kurs);
$program->editorial_content_kind_id = $this->kind('programm');
$program->display_title = 'Zentraler Programmname';
$program->teaser = 'Zentraler Teaser';
$program->summary = 'Zentrale Kurzbeschreibung';
$program->description = 'Interne Langfassung';
$program->save();
$version = $content->publishComposition($program, [[
'role' => 'Text',
'target' => $content->publishElementVersion($content->createElement('text', 'text', 'Blatt'), 'Inhalt'),
]]);
app(CompositionDisplayRelease::class)->release($version, User::factory()->create());
$cover = $this->image('Öffentliches Cover');
Storage::disk('media_derived')->put('vorschau/oeffentlich.jpg', 'cover-bytes');
$cover->thumbnail_path = 'vorschau/oeffentlich.jpg';
$cover->website_alt = 'Lara auf der Wiese';
$cover->save();
app(WebsiteRelease::class)->release($cover);
app(PresentationMedia::class)->assign($program, 'titelbild', $cover->id, null);
$guide = $content->createElement('text', 'text', 'Geheime Traineranleitung');
$guide->editorial_content_kind_id = $this->kind('traineranleitung');
$guide->description = 'Nur für Trainer, nicht öffentlich.';
$guide->save();
$content->publishElementVersion($guide, 'Interner Lehrtext');
$this->publish('/redaktion-karte', [[
'layout' => 'u2_2',
'style' => [],
'slots' => [
$this->card('program_card', ['composition' => $program->id]),
$this->card('program_card', ['composition' => $program->id], ['heading' => 'Nur diese Karte']),
],
]]);
$html = $this->get('/redaktion-karte')->assertOk()->getContent();
$this->assertStringContainsString('Zentraler Programmname', $html);
$this->assertStringContainsString('Zentraler Teaser', $html);
$this->assertStringContainsString('Nur diese Karte', $html);
$this->assertStringNotContainsString('Interne Langfassung', $html);
$this->assertStringNotContainsString('Nur für Trainer', $html);
$this->assertStringContainsString('/website-medien/'.$cover->id, $html);
$this->assertStringNotContainsString('editorial.card', $html);
$this->assertStringNotContainsString('originals/', $html);
$program->teaser = 'Teaser nach der Änderung';
$program->save();
$this->get('/redaktion-karte')->assertOk()
->assertSee('Teaser nach der Änderung')
->assertSee('Nur diese Karte')
->assertSee('Zentraler Programmname');
app(WebsiteRelease::class)->withdraw($cover->fresh());
$this->assertNull($cover->fresh()->website_released_at);
// WebsiteImage ist je Prozess gebunden. Ein neuer HTTP-Request im selben Testprozess
// bekommt sonst noch die vorherige Freigabe. Auf dem Server endet der Scope mit der Anfrage.
$this->app->forgetInstance(WebsiteImage::class);
$after = $this->get('/redaktion-karte')->assertOk()->getContent();
$this->assertStringNotContainsString('/website-medien/'.$cover->id, $after);
$this->assertStringContainsString('Teaser nach der Änderung', $after);
$this->assertStringContainsString('Nur diese Karte', $after);
$this->assertStringNotContainsString('cover-bytes', $after);
$this->assertSame('Zentraler Programmname', $program->fresh()->display_title);
}
public function test_a_bound_clip_stays_on_its_version_and_a_medium_cannot_present_itself(): void
{
$content = app(ContentService::class);
$film = $content->createElement('film', 'film', 'Lara im Park');
$first = $content->publishElementVersion($film, 'Fassung 1');
$trailer = $this->trailer('Ausschnitt');
$media = app(PresentationMedia::class);
$media->assign($film, 'vorschauclip', $trailer->id, $first->id);
$second = $content->publishElementVersion($film, 'Fassung 2');
$rows = $media->rows($film->fresh());
$this->assertTrue($rows[0]['binding']['stale']);
$this->assertSame($first->id, PresentationAssignment::query()->value('source_version_id'));
$this->assertNotSame($second->id, PresentationAssignment::query()->value('source_version_id'));
$this->expectException(DomainRuleException::class);
$media->assign($film, 'titelbild', $film->id, null);
}
public function test_a_kachel_variant_does_not_replace_the_central_teaser(): void
{
$program = app(ContentService::class)->createComposition('Variante', CompositionKind::Kurs);
$program->editorial_content_kind_id = $this->kind('programm');
$program->teaser = 'Zentral';
$program->save();
app(ContentService::class)->publishComposition($program, [[
'role' => 'Text',
'target' => app(ContentService::class)->publishElementVersion(app(ContentService::class)->createElement('text', 'text', 'Blatt'), 'Inhalt'),
]]);
app(EditorialProfileReader::class)->putVariant($program, 'teaser', 'kachel', 'Nur die Kachel', $this->editor());
$profile = app(EditorialProfileReader::class)->read($program->fresh(), 'kachel');
$plain = app(EditorialProfileReader::class)->read($program->fresh());
$this->assertSame('Nur die Kachel', $profile->value('teaser'));
$this->assertSame('variante', $profile->origin('teaser'));
$this->assertSame('Zentral', $plain->value('teaser'));
$this->assertSame('Zentral', $program->fresh()->teaser);
}
private function image(string $title): ContentElement
{
$content = app(ContentService::class);
$element = $content->createElement('bild', 'bild', $title);
$element->thumbnail_path = 'vorschau/'.md5($title).'.jpg';
$element->save();
Storage::disk('media_derived')->put($element->thumbnail_path, 'bild');
$content->publishElementVersion($element, null, ['file' => 'inhalte/'.md5($title).'.jpg']);
return $element->fresh();
}
private function trailer(string $title): ContentElement
{
$content = app(ContentService::class);
$element = $content->createElement('film', 'film', $title);
$version = $content->publishElementVersion($element, 'Teaser');
$path = 'teaser/'.md5($title).'.mp4';
MediaRendition::query()->create([
'content_element_version_id' => $version->id,
'role' => 'preview',
'label' => 'teaser',
'path' => $path,
]);
Storage::disk('media_derived')->put($path, 'teaser-bytes');
return $element->fresh();
}
private function kind(string $slug): int
{
return (int) EditorialContentKind::query()->where('slug', $slug)->value('id');
}
private function dimensionValue(string $dimension, string $slug): EditorialDimensionValue
{
$id = EditorialDimension::query()->where('slug', $dimension)->value('id');
return EditorialDimensionValue::query()
->where('editorial_dimension_id', $id)
->where('slug', $slug)
->firstOrFail();
}
private function editor(): User
{
$editor = User::factory()->redakteur()->create();
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
return $editor;
}
/**
* @param list<array<string, mixed>> $sections
*/
private function publish(string $path, array $sections): PageRevision
{
$page = Page::query()->create(['path' => $path]);
$service = app(PageService::class);
$revision = $service->saveRevision($page, $sections, null, null, null);
$service->publish($page, $revision);
return $revision;
}
/**
* @param array<string, mixed> $refs
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
private function card(string $type, array $refs, array $data = []): array
{
return ['type' => $type, 'v' => 1, 'variant' => 'adaptive', 'settings' => [], 'data' => $data, 'refs' => $refs];
}
}
+1 -1
View File
@@ -234,7 +234,7 @@ public function test_pillar_and_classification_filters_narrow_the_same_library()
$content->publishElementVersion($other, 'Text');
$pillar = app(PillarService::class)->create('Meine Grenzen');
app(PillarService::class)->assign($film, [$pillar->id]);
$dimension = EditorialDimension::query()->create(['slug' => 'zielgruppe', 'label' => 'Zielgruppe']);
$dimension = EditorialDimension::query()->where('slug', 'zielgruppe')->firstOrFail();
$value = $dimension->values()->create(['slug' => 'grundschule', 'label' => 'Grundschule']);
app(IdentityDimension::class)->assign($film, $value);