Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a359a5fb69 | ||
|
|
7b325f0d66 | ||
|
|
5590225f4f | ||
|
|
f29ea58fd5 | ||
|
|
c4be6ed8dc | ||
|
|
053a8d4648 | ||
|
|
7c63424ea6 | ||
|
|
13530b8171 | ||
|
|
72130d66c5 | ||
|
|
d37a7093dd | ||
|
|
3e56314cf9 | ||
|
|
8a6678aad7 | ||
|
|
b178939852 | ||
|
|
a08067c078 |
No files matched your search
@@ -11,8 +11,10 @@ class Composition extends Model
|
||||
protected $fillable = [
|
||||
'designation',
|
||||
'display_title',
|
||||
'teaser',
|
||||
'summary',
|
||||
'description',
|
||||
'search_terms',
|
||||
'thumbnail_path',
|
||||
'thumbnail_alt',
|
||||
'thumbnail_source',
|
||||
|
||||
@@ -14,14 +14,21 @@ class ContentElement extends Model
|
||||
'output_class',
|
||||
'working_title',
|
||||
'display_title',
|
||||
'teaser',
|
||||
'description',
|
||||
'usage_note',
|
||||
'license_note',
|
||||
'website_credit',
|
||||
'website_alt',
|
||||
'website_released_at',
|
||||
'website_public_path',
|
||||
'summary',
|
||||
'search_terms',
|
||||
'thumbnail_path',
|
||||
'thumbnail_alt',
|
||||
'thumbnail_source',
|
||||
'thumbnail_error',
|
||||
'preview_path',
|
||||
'editorial_content_kind_id',
|
||||
'archived_at',
|
||||
];
|
||||
@@ -30,6 +37,7 @@ protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'archived_at' => 'datetime',
|
||||
'website_released_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
@@ -13,4 +14,32 @@ public function values(): HasMany
|
||||
{
|
||||
return $this->hasMany(EditorialDimensionValue::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inhaltselemente pflegen Themen über die Säulen, nicht noch einmal über die Dimension.
|
||||
* Module, Programme und Lizenzartikel haben keine Säulenauswahl und behalten die Dimension.
|
||||
*
|
||||
* @return Collection<int, self>
|
||||
*/
|
||||
public static function forSubject(Model $subject): Collection
|
||||
{
|
||||
$query = static::query()->with('values')->orderBy('label');
|
||||
|
||||
if ($subject instanceof ContentElement) {
|
||||
$query->where('slug', '!=', 'saeule');
|
||||
}
|
||||
|
||||
return $query->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
public static function offeredValueIds(Model $subject): array
|
||||
{
|
||||
return static::forSubject($subject)
|
||||
->flatMap(fn (self $dimension) => $dimension->values->pluck('id'))
|
||||
->map(fn ($id): int => (int) $id)
|
||||
->all();
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
@@ -52,4 +52,35 @@ public function matches(Model $subject, array $valueIds): bool
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ersetzt nur die Werte der Dimensionen, die dieses Fachobjekt anbietet.
|
||||
* Nicht angebotene Zuordnungen, etwa gespiegelte Säulen am Inhaltselement, bleiben.
|
||||
*
|
||||
* @param list<int> $valueIds
|
||||
*/
|
||||
public function replaceOffered(Model $subject, array $valueIds): void
|
||||
{
|
||||
$offeredIds = EditorialDimension::offeredValueIds($subject);
|
||||
$ids = array_values(array_intersect(
|
||||
array_values(array_unique(array_map(intval(...), $valueIds))),
|
||||
$offeredIds,
|
||||
));
|
||||
|
||||
$query = IdentityDimensionValue::query()
|
||||
->where('subject_type', $subject->getMorphClass())
|
||||
->where('subject_id', $subject->getKey())
|
||||
->where('origin', 'direkt')
|
||||
->whereIn('editorial_dimension_value_id', $offeredIds === [] ? [0] : $offeredIds);
|
||||
|
||||
if ($ids !== []) {
|
||||
$query->whereNotIn('editorial_dimension_value_id', $ids);
|
||||
}
|
||||
|
||||
$query->delete();
|
||||
|
||||
foreach (EditorialDimensionValue::query()->whereIn('id', $ids)->get() as $value) {
|
||||
$this->assign($subject, $value, 'direkt');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
) {}
|
||||
}
|
||||
@@ -9,11 +9,18 @@
|
||||
* - url: nur ein öffentlich freigegebenes Ziel aus dem Fachobjekt (Themenseite, Programmseite), sonst null.
|
||||
* - public: false heißt „nur in der Redaktionsvorschau“; öffentlich entfällt die Karte dann.
|
||||
* - notice: redaktioneller Hinweis für die Vorschau, warum die Karte öffentlich nicht erscheint.
|
||||
* - visual: Darstellung ohne Kartenbild: 'film' (Medientafel Film), 'material' (Materialsymbol),
|
||||
* 'catalog' (Navy-Tafel Programm/Modul) oder null (Karte ohne Bildbereich).
|
||||
* - previewImage: geschütztes Vorschaubild der Bibliothek (Filmstandbild, Vorschau des Moduls). Nur für die
|
||||
* Redaktionsvorschau (Route editorial.card, nur für angemeldete Redaktion); öffentlich nie ausgegeben, weil es
|
||||
* keine Freigabe für die Website hat.
|
||||
* - missing: was für eine vollständige Karte fehlt, als Hinweis nur in der Redaktionsvorschau.
|
||||
*/
|
||||
final readonly class CardSubject
|
||||
{
|
||||
/**
|
||||
* @param list<string> $meta reine Anzeigetexte aus Fachdaten
|
||||
* @param list<string> $missing Hinweise für die Redaktion
|
||||
*/
|
||||
public function __construct(
|
||||
public string $title,
|
||||
@@ -24,5 +31,29 @@ public function __construct(
|
||||
public ?string $url,
|
||||
public bool $public,
|
||||
public ?string $notice = null,
|
||||
public ?string $visual = null,
|
||||
public ?string $visualLabel = null,
|
||||
public ?string $previewImage = null,
|
||||
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,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,10 @@
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -93,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)
|
||||
@@ -172,43 +177,164 @@ public function entries(array $refs, bool $includeNonPublic): array
|
||||
}
|
||||
|
||||
/**
|
||||
* Anzeigedaten für eine Programm- oder Modulkarte (Premium-Karte). Dieselbe Regel wie entries():
|
||||
* Programme mit Anzeigefreigabe öffentlich mit Programmseite, Module nur in der Redaktionsvorschau.
|
||||
* Die Art („Programm“ oder „Modul“) ist immer benannt. Kein Preis, kein Angebot, keine Kaufaktion.
|
||||
* Für die Programm- oder Modulkarte wählbar: Programm oder Modul, nicht archiviert, mit mindestens einer
|
||||
* bereitgestellten Fassung. Anders als bei den Katalogkarten ist keine Anzeigefreigabe nötig, damit die Redaktion
|
||||
* eine Karte vorbereiten kann; öffentlich gilt unverändert isPublic().
|
||||
*/
|
||||
public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
||||
public function isCardSelectable(Composition $composition): bool
|
||||
{
|
||||
$entry = $this->entries([['type' => 'composition', 'id' => $id]], $includeNonPublic)[0] ?? null;
|
||||
return $composition->archived_at === null
|
||||
&& in_array($composition->editorialContentKind?->slug, self::SELECTABLE_KINDS, true)
|
||||
&& $this->latestReadyVersion($composition) !== null;
|
||||
}
|
||||
|
||||
if ($entry === null) {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function cardSearch(?string $term, int $limit = 25): array
|
||||
{
|
||||
$term = trim((string) $term);
|
||||
|
||||
$meta = [];
|
||||
$composition = Composition::query()->find($entry->id);
|
||||
$version = $composition !== null ? $this->shownVersion($composition) : null;
|
||||
$candidates = Composition::query()
|
||||
->with('editorialContentKind')
|
||||
->whereNull('archived_at')
|
||||
->whereHas('editorialContentKind', fn ($query) => $query->whereIn('slug', self::SELECTABLE_KINDS))
|
||||
->when($term !== '', function ($query) use ($term): void {
|
||||
$like = '%'.mb_strtolower($term).'%';
|
||||
$query->where(fn ($inner) => $inner
|
||||
->whereRaw('LOWER(designation) 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)
|
||||
->get();
|
||||
|
||||
if ($version !== null) {
|
||||
$nested = $version->members()->whereNotNull('nested_composition_version_id')->with('nestedCompositionVersion.composition.editorialContentKind')->get();
|
||||
$modules = $nested->filter(fn ($member): bool => $member->nestedCompositionVersion?->composition?->editorialContentKind?->slug === 'modul')->count();
|
||||
$options = [];
|
||||
foreach ($candidates as $composition) {
|
||||
if (! $this->isCardSelectable($composition)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($modules > 0) {
|
||||
$meta[] = $modules === 1 ? '1 Modul' : $modules.' Module';
|
||||
$options[$composition->id] = $this->cardOptionLabel($composition);
|
||||
|
||||
if (count($options) >= $limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function cardLabelFor(mixed $id): ?string
|
||||
{
|
||||
$composition = is_numeric($id) ? Composition::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
return $composition === null ? null : $this->cardOptionLabel($composition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Anzeigedaten für eine Programm- oder Modulkarte (Premium-Karte).
|
||||
*
|
||||
* - Öffentlich nur Programme mit Anzeigefreigabe (dieselbe Regel wie /programme), mit Programmseite als Ziel.
|
||||
* Module haben keine öffentliche Seitenart (ADR-29) und erscheinen nur in der Redaktionsvorschau, ohne Link.
|
||||
* - Text: Kurzbeschreibung, sonst das Lernziel der gezeigten (öffentlich) bzw. neuesten bereitgestellten Fassung;
|
||||
* das Lernziel steht auf der öffentlichen Programmseite bereits öffentlich.
|
||||
* - Zusatzangaben: Zahl der Module, Dauer. Kein Preis, kein Angebot, keine Kaufaktion; eine Karte ist kein
|
||||
* Lizenzartikel. Das Vorschaubild der Bibliothek erscheint nur in der Redaktionsvorschau.
|
||||
*/
|
||||
public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
||||
{
|
||||
$composition = is_numeric($id) ? Composition::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
if ($composition === null || ! $this->isCardSelectable($composition)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$shown = $this->shownVersion($composition);
|
||||
$public = $shown !== null && $composition->archived_at === null;
|
||||
|
||||
if (! $public && ! $includeNonPublic) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$version = $shown ?? $this->latestReadyVersion($composition);
|
||||
$program = $composition->editorialContentKind?->slug === 'programm';
|
||||
$kind = (string) ($composition->editorialContentKind?->label ?? ($program ? 'Programm' : 'Modul'));
|
||||
$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 = [];
|
||||
|
||||
if ($summary === null) {
|
||||
$missing[] = $goal !== null
|
||||
? 'Keine Kurzbeschreibung gepflegt; die Karte zeigt das Lernziel.'
|
||||
: 'Weder Kurzbeschreibung noch Lernziel gepflegt.';
|
||||
}
|
||||
|
||||
$meta = [];
|
||||
if ($version !== null) {
|
||||
$modules = $version->members()
|
||||
->whereNotNull('nested_composition_version_id')
|
||||
->with('nestedCompositionVersion.composition.editorialContentKind')
|
||||
->get()
|
||||
->filter(fn ($member): bool => $member->nestedCompositionVersion?->composition?->editorialContentKind?->slug === 'modul')
|
||||
->count();
|
||||
|
||||
if ($program && $modules > 0) {
|
||||
$meta[] = $modules === 1 ? '1 Modul' : $modules.' Module';
|
||||
}
|
||||
|
||||
if (is_numeric($version->duration_minutes) && (int) $version->duration_minutes > 0) {
|
||||
$meta[] = 'Dauer '.(int) $version->duration_minutes.' Min.';
|
||||
} else {
|
||||
$missing[] = 'Keine Dauer gepflegt.';
|
||||
}
|
||||
}
|
||||
|
||||
$notice = null;
|
||||
if (! $public) {
|
||||
$notice = 'Nur in der Redaktionsvorschau sichtbar: '.($program
|
||||
? 'Das Programm hat keine Anzeigefreigabe.'
|
||||
: 'Für Module gibt es noch keine öffentliche Seitenart (öffentliches Profil, ADR-29); die Karte erhält deshalb keinen Link.');
|
||||
}
|
||||
|
||||
return new CardSubject(
|
||||
title: $entry->title,
|
||||
summary: $entry->summary,
|
||||
kind: $entry->kindLabel,
|
||||
title: $profile->value('display_title') ?: $this->title($composition),
|
||||
summary: $summary ?? $goal,
|
||||
kind: $kind,
|
||||
badge: null,
|
||||
meta: $meta,
|
||||
url: $entry->url,
|
||||
public: $entry->public,
|
||||
notice: $entry->public ? null : 'Nur in der Redaktionsvorschau sichtbar: Für Module gibt es noch keine öffentliche Seitenart (öffentliches Profil, ADR-29).',
|
||||
url: $public ? route('public.program', $composition) : null,
|
||||
public: $public,
|
||||
notice: $notice,
|
||||
visual: 'catalog',
|
||||
visualLabel: $kind,
|
||||
previewImage: $includeNonPublic ? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path) : null,
|
||||
missing: $missing,
|
||||
);
|
||||
}
|
||||
|
||||
private function latestReadyVersion(Composition $composition): ?CompositionVersion
|
||||
{
|
||||
return $composition->versions()
|
||||
->where('status', ContentVersionStatus::Bereit->value)
|
||||
->orderByDesc('number')
|
||||
->first();
|
||||
}
|
||||
|
||||
private function cardOptionLabel(Composition $composition): string
|
||||
{
|
||||
$visibility = match (true) {
|
||||
$this->isPublic($composition) => 'öffentlich sichtbar',
|
||||
$composition->editorialContentKind?->slug === 'modul' => 'Modul, nur Redaktionsvorschau',
|
||||
default => 'ohne Anzeigefreigabe, nur Redaktionsvorschau',
|
||||
};
|
||||
|
||||
return $this->title($composition).' · '.($composition->editorialContentKind?->label ?? '').' · '.$visibility;
|
||||
}
|
||||
|
||||
private function title(Composition $composition): string
|
||||
{
|
||||
return (string) ($composition->display_title ?: $composition->designation);
|
||||
|
||||
@@ -5,24 +5,31 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* Lesesicht „Medien und Materialien“ für Premium-Karten (Website-CMS-Zielarchitektur 6.2).
|
||||
*
|
||||
* Übergangsregel, solange öffentliche Fachobjektprofile (ADR-29) fehlen:
|
||||
* Ein Medium oder Material hat keine eigene öffentliche Seite. Öffentlich genannt wird es heute nur als Bestandteil
|
||||
* der gezeigten Fassung eines öffentlichen Programms (Programmseite /programme/{id}). Genau dann erscheint auch die
|
||||
* Karte öffentlich, mit Verweis auf diese Programmseite. Sonst ist die Karte nur in der Redaktionsvorschau sichtbar.
|
||||
* Auswahl in der Redaktion: jedes nicht archivierte Inhaltselement mit mindestens einer nicht gesperrten Fassung.
|
||||
*
|
||||
* Gelesen werden nur Anzeigetitel, Inhaltsart und Ausgabeart, nie Kurzbeschreibung, Dateien, Lehrtexte,
|
||||
* Vorschaubilder der Bibliothek oder Ausgabeadressen. Eine Karte gibt kein Medium frei.
|
||||
* Öffentliche Sichtbarkeit (Übergangsregel, solange öffentliche Fachobjektprofile nach ADR-29 fehlen):
|
||||
* Ein Medium hat keine eigene öffentliche Seite. Öffentlich genannt wird es heute nur als Bestandteil der gezeigten
|
||||
* Fassung eines öffentlichen Programms (Programmseite /programme/{id}). Genau dann erscheint auch die Karte
|
||||
* öffentlich, mit Verweis auf diese Programmseite, und nur mit bereitgestellter Fassung. Traineranleitungen erscheinen
|
||||
* nie öffentlich (vertraulich für Trainerinnen und Trainer).
|
||||
*
|
||||
* Die Kurzbeschreibung eines Elements ist heute nirgends öffentlich (die Programmseite nennt nur den Titel). Sie bleibt
|
||||
* deshalb auch auf der Karte aus, bis über öffentliche Profile (ADR-29) entschieden ist (offene Entscheidung, ADR-39).
|
||||
* Öffentlich gelesen werden Anzeigetitel (sonst Arbeitstitel), Kurzbeschreibung, Inhaltsart und Ausgabeart. Nie:
|
||||
* Beschreibung, Einsatzhinweis, Lizenzvermerk, Dateien, Lehrtexte, Ausgabeadressen. Das Vorschaubild (Filmstandbild)
|
||||
* der Bibliothek ist nicht für die Website freigegeben; es erscheint nur in der Redaktionsvorschau.
|
||||
* Eine Karte spielt nichts ab, bietet keinen Download und gibt kein Medium frei.
|
||||
*/
|
||||
class PublicMaterialReader
|
||||
{
|
||||
/** Inhaltsarten, die nie öffentlich auf einer Karte erscheinen. */
|
||||
public const CONFIDENTIAL_KINDS = ['traineranleitung'];
|
||||
|
||||
/** @var array<int, array{id: int, title: string}>|null Element-ID => erstes öffentliches Programm */
|
||||
private ?array $publicIndex = null;
|
||||
|
||||
@@ -31,13 +38,15 @@ public function __construct(
|
||||
private readonly CompositionStructureReader $structure,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Wählbar ist ein nicht archiviertes Element mit mindestens einer bereitgestellten (nicht gesperrten) Fassung.
|
||||
*/
|
||||
public function isSelectable(ContentElement $element): bool
|
||||
{
|
||||
return $element->archived_at === null
|
||||
&& $element->versions()->where('status', ContentVersionStatus::Bereit->value)->exists();
|
||||
&& $element->versions()->where('status', '!=', ContentVersionStatus::Gesperrt->value)->exists();
|
||||
}
|
||||
|
||||
public function isReady(ContentElement $element): bool
|
||||
{
|
||||
return $element->versions()->where('status', ContentVersionStatus::Bereit->value)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,6 +59,14 @@ public function publicProgramFor(ContentElement $element): ?array
|
||||
return $this->publicIndex()[$element->id] ?? null;
|
||||
}
|
||||
|
||||
public function isPublic(ContentElement $element): bool
|
||||
{
|
||||
return $this->isSelectable($element)
|
||||
&& $this->isReady($element)
|
||||
&& ! in_array($element->editorialContentKind?->slug, self::CONFIDENTIAL_KINDS, true)
|
||||
&& $this->publicProgramFor($element) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
@@ -60,7 +77,7 @@ public function search(?string $term, int $limit = 25): array
|
||||
$candidates = ContentElement::query()
|
||||
->with('editorialContentKind')
|
||||
->whereNull('archived_at')
|
||||
->whereHas('versions', fn ($query) => $query->where('status', ContentVersionStatus::Bereit->value))
|
||||
->whereHas('versions', fn ($query) => $query->where('status', '!=', ContentVersionStatus::Gesperrt->value))
|
||||
->when($term !== '', function ($query) use ($term): void {
|
||||
$like = '%'.mb_strtolower($term).'%';
|
||||
$query->where(fn ($inner) => $inner
|
||||
@@ -88,8 +105,10 @@ public function labelFor(mixed $id): ?string
|
||||
|
||||
/**
|
||||
* Anzeigedaten für eine Karte. Öffentlich null, wenn das Element nicht öffentlich genannt wird.
|
||||
*
|
||||
* @param array<string, mixed> $draft ungespeicherte Anzeigedaten, nur für die Redaktionsvorschau
|
||||
*/
|
||||
public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
||||
public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?CardSubject
|
||||
{
|
||||
$element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
@@ -97,29 +116,74 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
||||
return null;
|
||||
}
|
||||
|
||||
$program = $this->publicProgramFor($element);
|
||||
$public = $this->isPublic($element);
|
||||
|
||||
if ($program === null && ! $includeNonPublic) {
|
||||
if (! $public && ! $includeNonPublic) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$output = self::outputLabel((string) $element->output_class);
|
||||
$shown = clone $element;
|
||||
|
||||
foreach (['working_title', 'display_title', 'summary', 'thumbnail_path', 'thumbnail_alt'] as $field) {
|
||||
if (! array_key_exists($field, $draft)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$value = $draft[$field];
|
||||
$shown->setAttribute($field, is_string($value) && trim($value) === '' ? null : $value);
|
||||
}
|
||||
|
||||
$program = $this->publicProgramFor($element);
|
||||
$output = self::outputLabel((string) $shown->output_class);
|
||||
$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) {
|
||||
$meta[] = 'Im Programm „'.$program['title'].'“';
|
||||
}
|
||||
if ($film) {
|
||||
$meta[] = 'Vollständiger Film nur mit Lizenz im Mitgliederbereich';
|
||||
}
|
||||
|
||||
$missing = [];
|
||||
if ($summary === null) {
|
||||
$missing[] = 'Keine Kurzbeschreibung gepflegt (Medium bearbeiten → Kurzbeschreibung).';
|
||||
}
|
||||
if (! filled($shown->display_title)) {
|
||||
$missing[] = 'Kein Anzeigetitel gepflegt; die Karte zeigt den Arbeitstitel.';
|
||||
}
|
||||
|
||||
$previewImage = $includeNonPublic ? ThumbnailRef::url('editorial.card', 'element', (int) $element->id, $shown->thumbnail_path) : null;
|
||||
|
||||
return new CardSubject(
|
||||
title: $this->title($element),
|
||||
summary: null,
|
||||
title: $title,
|
||||
summary: $summary,
|
||||
kind: filled($editorialKind) ? (string) $editorialKind : $output,
|
||||
badge: $output,
|
||||
meta: array_values(array_filter([
|
||||
$output,
|
||||
$program !== null ? 'Im Programm „'.$program['title'].'“' : null,
|
||||
])),
|
||||
url: $program !== null ? route('public.program', $program['id']) : null,
|
||||
public: $program !== null,
|
||||
notice: $program === null
|
||||
? 'Nur in der Redaktionsvorschau sichtbar: Dieses Medium gehört zu keinem öffentlich gezeigten Programm. Medien haben noch keine eigene öffentliche Freigabe (öffentliches Profil, ADR-29).'
|
||||
: null,
|
||||
meta: $meta,
|
||||
url: $public && $program !== null ? route('public.program', $program['id']) : null,
|
||||
public: $public,
|
||||
notice: $public ? null : $this->notice($element, $program),
|
||||
visual: $film ? 'film' : 'material',
|
||||
visualLabel: $output,
|
||||
previewImage: $previewImage,
|
||||
missing: $missing,
|
||||
style: $film ? 'media' : 'material',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -135,17 +199,40 @@ public static function outputLabel(string $outputClass): string
|
||||
};
|
||||
}
|
||||
|
||||
private function title(ContentElement $element): string
|
||||
public function visibilityNote(ContentElement $element): string
|
||||
{
|
||||
return (string) ($element->display_title ?: $element->working_title);
|
||||
if ($this->isPublic($element)) {
|
||||
$program = $this->publicProgramFor($element);
|
||||
|
||||
return 'Öffentlich nur als Teil der Programmseite „'.($program['title'] ?? '').'“. Die Mediendatei wird dabei nicht ausgeliefert.';
|
||||
}
|
||||
|
||||
return $this->notice($element, $this->publicProgramFor($element));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{id: int, title: string}|null $program
|
||||
*/
|
||||
private function notice(ContentElement $element, ?array $program): string
|
||||
{
|
||||
$reason = match (true) {
|
||||
in_array($element->editorialContentKind?->slug, self::CONFIDENTIAL_KINDS, true) => 'Traineranleitungen erscheinen nie öffentlich.',
|
||||
! $this->isReady($element) => 'Das Medium hat noch keine bereitgestellte Fassung.',
|
||||
$program === null => 'Das Medium gehört zu keinem öffentlich gezeigten Programm. Medien haben noch keine eigene öffentliche Freigabe (öffentliches Profil, ADR-29).',
|
||||
default => 'Das Medium ist nicht öffentlich.',
|
||||
};
|
||||
|
||||
return 'Nur in der Redaktionsvorschau sichtbar: '.$reason;
|
||||
}
|
||||
|
||||
private function optionLabel(ContentElement $element): string
|
||||
{
|
||||
$visibility = $this->publicProgramFor($element) !== null ? 'öffentlich über Programmseite' : 'nur Redaktionsvorschau';
|
||||
$visibility = $this->isPublic($element)
|
||||
? 'öffentlich über Programmseite'
|
||||
: ($this->isReady($element) ? 'nur Redaktionsvorschau' : 'Entwurf, nur Redaktionsvorschau');
|
||||
$kind = $element->editorialContentKind?->label ?: self::outputLabel((string) $element->output_class);
|
||||
|
||||
return $this->title($element).' · '.$kind.' · '.$visibility;
|
||||
return (string) ($element->display_title ?: $element->working_title).' · '.$kind.' · '.$visibility;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Domain\Cms\Sections;
|
||||
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
@@ -145,7 +147,7 @@ public function mediaPaths(array $sections): array
|
||||
|
||||
foreach ($sections as $section) {
|
||||
$style = SectionStyle::fromStored($section['style'] ?? []);
|
||||
if ($style['image'] !== null && PublicMedia::isPublicPath($style['image'])) {
|
||||
if (is_string($style['image']) && PublicMedia::isPublicPath($style['image'])) {
|
||||
$paths[] = $style['image'];
|
||||
}
|
||||
}
|
||||
@@ -335,14 +337,17 @@ private function normalizeStyle(array $style, string $prefix, array &$errors): a
|
||||
$result[$key] = $value;
|
||||
}
|
||||
|
||||
$upload = PublicMedia::fromUploadState($style['_upload'] ?? null);
|
||||
$image = $upload ?? PublicMedia::fromUploadState($style['image'] ?? null);
|
||||
|
||||
if ($result['background'] === 'image') {
|
||||
if ($image === null) {
|
||||
$errors["$prefix.style.image"] = ['Bitte ein Hintergrundbild wählen oder hochladen.'];
|
||||
} elseif (! PublicMedia::isPublicPath($image)) {
|
||||
$errors["$prefix.style.image"] = ['Das Hintergrundbild liegt nicht im öffentlichen Medienbereich.'];
|
||||
$widgetErrors = new WidgetErrors;
|
||||
$refs = ImageRefFields::clean(['image' => $style['image'] ?? null, '_upload' => $style['_upload'] ?? null], $widgetErrors, errorKey: 'image');
|
||||
$image = $refs['image'];
|
||||
|
||||
foreach ($widgetErrors->all() as $messages) {
|
||||
$errors["$prefix.style.image"] = $messages;
|
||||
}
|
||||
|
||||
if ($image === null && ! isset($errors["$prefix.style.image"])) {
|
||||
$errors["$prefix.style.image"] = ['Bitte ein Hintergrundbild aus dem Medienmanager wählen oder hochladen.'];
|
||||
}
|
||||
|
||||
$result['image'] = $image;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace App\Domain\Cms\Sections;
|
||||
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetRenderer;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
@@ -56,7 +56,7 @@ public function renderAll(array $sections, RenderContext $context): HtmlString
|
||||
$last = count($rendered) - 1;
|
||||
|
||||
foreach ($rendered as $index => $item) {
|
||||
$html .= $this->renderSection($item['section'], $item['cells'], $index);
|
||||
$html .= $this->renderSection($item['section'], $item['cells'], $index, $context);
|
||||
|
||||
$divider = $item['section']['style']['divider'] ?? 'none';
|
||||
if ($index < $last && in_array($divider, ['line', 'accent'], true)) {
|
||||
@@ -71,11 +71,13 @@ public function renderAll(array $sections, RenderContext $context): HtmlString
|
||||
* @param array<string, mixed> $section
|
||||
* @param list<array{units: int, html: string}> $cells
|
||||
*/
|
||||
private function renderSection(array $section, array $cells, int $index): string
|
||||
private function renderSection(array $section, array $cells, int $index, RenderContext $context): string
|
||||
{
|
||||
$style = SectionStyle::fromStored($section['style'] ?? []);
|
||||
$columns = SectionLayouts::columns(array_column($cells, 'units'));
|
||||
$hasImage = $style['background'] === 'image' && $style['image'] !== null && PublicMedia::isPublicPath($style['image']);
|
||||
// Hintergrundbild aus dem Medienmanager: öffentlich nur mit Website-Freigabe (WebsiteImage → WebsiteMedia).
|
||||
$imageUrl = $style['background'] === 'image' ? app(WebsiteImage::class)->url($style['image'], $context->preview) : null;
|
||||
$hasImage = $imageUrl !== null;
|
||||
|
||||
$classes = [
|
||||
'page-section',
|
||||
@@ -109,7 +111,7 @@ private function renderSection(array $section, array $cells, int $index): string
|
||||
if ($hasImage) {
|
||||
// Das Bild des ersten Abschnitts ist meist das größte sichtbare Element und wird nicht verzögert geladen.
|
||||
$loading = $index === 0 ? 'loading="eager" fetchpriority="high"' : 'loading="lazy"';
|
||||
$html .= '<img class="page-section-image" src="'.e(PublicMedia::url($style['image'])).'" alt="" '.$loading.' decoding="async"'
|
||||
$html .= '<img class="page-section-image" src="'.e($imageUrl).'" alt="" '.$loading.' decoding="async"'
|
||||
.' style="object-position: '.e(SectionStyle::FOCUS_POSITIONS[$style['focus']]).'">';
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Domain\Cms\Sections;
|
||||
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
|
||||
/**
|
||||
* Semantische Abschnittsgestaltung. Jeder Wert ist eine Aufzählung, die auf zentrale Design-Tokens
|
||||
@@ -134,7 +134,7 @@ public static function fromStored(mixed $style): array
|
||||
}
|
||||
}
|
||||
|
||||
$result['image'] = $result['background'] === 'image' && is_string($style['image'] ?? null) ? $style['image'] : null;
|
||||
$result['image'] = $result['background'] === 'image' ? WebsiteImage::normalize($style['image'] ?? null) : null;
|
||||
|
||||
return $result;
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public static function migrateSpacing(array $sections, bool $byVersion = false):
|
||||
$rendered = is_array($section['slots'] ?? null) && array_filter($section['slots'], 'is_array') !== [];
|
||||
|
||||
$background = is_string($style['background'] ?? null) && isset(self::BACKGROUNDS[$style['background']]) ? $style['background'] : 'default';
|
||||
if ($background === 'image' && ! PublicMedia::isPublicPath($style['image'] ?? null)) {
|
||||
if ($background === 'image' && WebsiteImage::normalize($style['image'] ?? null) === null) {
|
||||
$background = 'default';
|
||||
}
|
||||
$divider = in_array($style['divider'] ?? null, ['line', 'accent'], true) ? $style['divider'] : 'none';
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Media\WebsiteMediaAlias;
|
||||
|
||||
/**
|
||||
* Wo ein Medium auf Website-Seiten als Bild verwendet wird (veröffentlichte Fassung und neuester Entwurf).
|
||||
* Für den Medienmanager: Vor dem Zurücknehmen einer Website-Freigabe ist sichtbar, welche Seiten das Bild verlieren.
|
||||
*/
|
||||
class WebsiteImageUsage
|
||||
{
|
||||
/**
|
||||
* @return list<array{path: string, published: bool, draft: bool}>
|
||||
*/
|
||||
public function pages(ContentElement $element): array
|
||||
{
|
||||
$legacy = WebsiteMediaAlias::query()->where('content_element_id', $element->id)->pluck('legacy_path')->all();
|
||||
$usages = [];
|
||||
|
||||
foreach (Page::query()->with(['publishedRevision', 'latestRevision'])->orderBy('path')->get() as $page) {
|
||||
$published = $page->publishedRevision !== null && $this->uses($page->publishedRevision->sections ?? [], $element->id, $legacy);
|
||||
$draft = $page->latestRevision !== null && $page->latestRevision->id !== $page->published_revision_id
|
||||
&& $this->uses($page->latestRevision->sections ?? [], $element->id, $legacy);
|
||||
|
||||
if ($published || $draft) {
|
||||
$usages[] = ['path' => (string) $page->path, 'published' => $published, 'draft' => $draft];
|
||||
}
|
||||
}
|
||||
|
||||
return $usages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $legacy
|
||||
*/
|
||||
private function uses(mixed $value, int $id, array $legacy): bool
|
||||
{
|
||||
if (! is_array($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($value as $key => $item) {
|
||||
if ($key === 'image' && (($item === $id || (is_string($item) && ($item === (string) $id || in_array($item, $legacy, true)))))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_array($item) && $this->uses($item, $id, $legacy)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -5,40 +5,80 @@
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use Filament\Forms\Components\Field;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Illuminate\Support\Str;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
|
||||
/**
|
||||
* Gemeinsame Bildauswahl für Widgets: vorhandenes Bild aus dem öffentlichen Website-Bereich wählen
|
||||
* oder ein neues hochladen. Keine eigene Medienverwaltung.
|
||||
* Gemeinsame Bildauswahl aller Widgets und des Abschnittshintergrunds: Bilder aus dem zentralen Medienmanager
|
||||
* (siehe WebsiteImage, docs/architektur/medienzugriff-fuer-komponenten.md). Keine eigene CMS-Medienverwaltung.
|
||||
*
|
||||
* - Auswahl: durchsuchbare Liste mit Vorschaubild, Titel und Website-Status.
|
||||
* - Neu hochladen: Das Bild wird sofort als Medium im Medienmanager angelegt (WebsiteIntake) und ausgewählt.
|
||||
* - Anzeige des gewählten Mediums mit Status und Verweis auf die Freigabe im Medienmanager.
|
||||
*
|
||||
* Das Bedienmuster folgt der Bildauswahl im Modul- und Programmeditor (Suche, Vorschaubild, Auswählen); jene ist an
|
||||
* die Livewire-Seite des Editors gebunden und lässt sich nicht als Formularfeld im Widget-Dialog einhängen.
|
||||
*/
|
||||
final class ImageRefFields
|
||||
{
|
||||
/**
|
||||
* @param bool $live Änderungen sofort an die Vorschau im Bearbeitungsdialog geben.
|
||||
* @return list<Field>
|
||||
* @param string|null $altField Name des Alternativtext-Felds im selben Formular (für neue Medien), falls vorhanden.
|
||||
* @return list<Field|Placeholder>
|
||||
*/
|
||||
public static function fields(string $label = 'Bild', bool $live = false): array
|
||||
public static function fields(string $label = 'Bild', bool $live = false, string $key = 'image', ?string $altField = null): array
|
||||
{
|
||||
return [
|
||||
Select::make('image')
|
||||
->live($live)
|
||||
->label($label.': vorhandenes Bild')
|
||||
->options(fn (): array => PublicMedia::imageOptions())
|
||||
Select::make($key)
|
||||
->live()
|
||||
->label($label.' aus dem Medienmanager')
|
||||
->searchable()
|
||||
->allowHtml()
|
||||
->options(fn (): array => app(WebsiteImage::class)->options())
|
||||
->getSearchResultsUsing(fn (?string $search): array => app(WebsiteImage::class)->options($search))
|
||||
->getOptionLabelUsing(fn (mixed $value): ?string => app(WebsiteImage::class)->optionHtml($value))
|
||||
->placeholder('Kein Bild')
|
||||
->helperText('Auswahl aus den Bildern, die bereits für die Website hochgeladen wurden.'),
|
||||
->helperText('Alle Bilder des Medienmanagers. Öffentlich erscheint ein Bild nur mit Website-Freigabe.'),
|
||||
FileUpload::make('_upload')
|
||||
->live($live)
|
||||
->label($label.': neu hochladen')
|
||||
->disk('cms_incoming')
|
||||
->directory('cms')
|
||||
->live()
|
||||
->label($label.': neues Bild hochladen')
|
||||
->image()
|
||||
->maxSize(8192)
|
||||
->acceptedFileTypes(['image/jpeg', 'image/png', 'image/webp'])
|
||||
->getUploadedFileNameForStorageUsing(fn (TemporaryUploadedFile $file): string => Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)).'-'.Str::lower(Str::random(6)).'.'.$file->guessExtension())
|
||||
->helperText('Ein neues Bild ersetzt die Auswahl oben. Es wird beim Speichern im öffentlichen Bereich der Website abgelegt.'),
|
||||
->storeFiles(false)
|
||||
->afterStateUpdated(function (mixed $state, Set $set, Get $get) use ($key, $altField): void {
|
||||
$file = is_array($state) ? (array_values($state)[0] ?? null) : $state;
|
||||
|
||||
if (! $file instanceof TemporaryUploadedFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
$element = app(WebsiteImage::class)->accept($file, $altField !== null ? $get($altField) : null);
|
||||
$set('_upload', null);
|
||||
|
||||
if ($element === null) {
|
||||
Notification::make()->danger()->title('Das Bild konnte nicht übernommen werden.')->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$set($key, $element->id);
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Im Medienmanager angelegt: „'.($element->display_title ?: $element->working_title).'“')
|
||||
->body('Das Bild ist ausgewählt. Nach der Verarbeitung wird es automatisch für die Website freigegeben.')
|
||||
->send();
|
||||
})
|
||||
->helperText('Das Bild wird im Medienmanager angelegt und hier ausgewählt. Nur Bilder mit geklärten Rechten hochladen.'),
|
||||
Placeholder::make('_media_status')
|
||||
->label('Gewähltes Bild')
|
||||
->visible(fn (Get $get): bool => WebsiteImage::normalize($get($key)) !== null)
|
||||
->content(fn (Get $get): HtmlString => self::statusHtml($get($key))),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -48,29 +88,49 @@ public static function fields(string $label = 'Bild', bool $live = false): array
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
'image' => ['nullable', 'string', 'max:255'],
|
||||
'image' => ['nullable'],
|
||||
'_upload' => ['nullable'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Übernimmt einen neuen Upload als Bild und prüft, dass das Bild im öffentlichen Bereich liegt.
|
||||
* Prüft das gewählte Bild. Ein früherer CMS-Pfad mit wirksamer Zuordnung wird zur Kennung des Mediums.
|
||||
* Ein noch als Datei übergebener Upload (frühere Formulare) wird über den Medienmanager aufgenommen.
|
||||
*
|
||||
* @param array<string, mixed> $refs
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function clean(array $refs, WidgetErrors $errors, string $key = 'image', ?string $errorKey = null): array
|
||||
{
|
||||
$upload = PublicMedia::fromUploadState($refs['_upload'] ?? null);
|
||||
$image = $upload ?? PublicMedia::fromUploadState($refs[$key] ?? null);
|
||||
$images = app(WebsiteImage::class);
|
||||
$upload = $refs['_upload'] ?? null;
|
||||
$upload = is_array($upload) ? (array_values($upload)[0] ?? null) : $upload;
|
||||
|
||||
if ($image !== null && ! PublicMedia::isPublicPath($image)) {
|
||||
$errors->add($errorKey ?? "refs.$key", 'Das Bild liegt nicht im öffentlichen Medienbereich.');
|
||||
if ($upload instanceof TemporaryUploadedFile) {
|
||||
$element = $images->accept($upload);
|
||||
$refs[$key] = $element?->id ?? $refs[$key] ?? null;
|
||||
}
|
||||
|
||||
$refs[$key] = $image;
|
||||
$refs[$key] = $images->clean($refs[$key] ?? null, $errors, $errorKey ?? "refs.$key");
|
||||
unset($refs['_upload']);
|
||||
|
||||
return $refs;
|
||||
}
|
||||
|
||||
public static function statusHtml(mixed $value): HtmlString
|
||||
{
|
||||
$status = app(WebsiteImage::class)->status($value);
|
||||
|
||||
if ($status === null) {
|
||||
return new HtmlString('');
|
||||
}
|
||||
|
||||
$thumb = $status['thumb'] !== null ? '<img src="'.e($status['thumb']).'" alt="">' : '';
|
||||
$link = $status['manageUrl'] !== null
|
||||
? '<a href="'.e($status['manageUrl']).'" target="_blank" rel="noopener">Im Medienmanager öffnen</a>'
|
||||
: '';
|
||||
|
||||
return new HtmlString('<div class="luf-media-status luf-media-status-'.e($status['state']).'">'.$thumb
|
||||
.'<div><strong>'.e($status['title']).'</strong><p>'.e($status['note']).'</p>'.$link.'</div></div>');
|
||||
}
|
||||
}
|
||||
@@ -98,10 +98,10 @@ public static function focusFields(int $defaultX = 50, int $defaultY = 50): arra
|
||||
public static function altField(): TextInput
|
||||
{
|
||||
return TextInput::make('alt')
|
||||
->label('Alternativtext des Bildes')
|
||||
->label('Alternativtext (optional)')
|
||||
->maxLength(300)
|
||||
->live(onBlur: true)
|
||||
->helperText('Beschreibt, was auf dem Bild zu sehen ist. Pflicht, sobald ein Bild gewählt ist.');
|
||||
->helperText('Leer lassen, dann gilt der Alternativtext des Mediums aus dem Medienmanager. Nur ausfüllen, wenn das Bild hier etwas anderes aussagen soll.');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,10 +127,6 @@ public static function clean(array $data, WidgetErrors $errors, bool $hasImage):
|
||||
$data[$key] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
||||
}
|
||||
|
||||
if ($hasImage && $data['alt'] === null) {
|
||||
$errors->add('data.alt', 'Bitte einen Alternativtext für das Bild angeben.');
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,20 +2,14 @@
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Support;
|
||||
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Öffentlicher Medienbereich der Website ("cms/"). Nur Dateien aus diesem Bereich dürfen in Widgets
|
||||
* verwendet werden. Geschützte Bibliotheksmedien (Inhaltsdateien, Vorschaubilder) sind hier nie wählbar.
|
||||
* Frühere öffentliche CMS-Bilder („cms/“, Route media.public). Neue Bilder kommen aus dem Medienmanager (WebsiteImage);
|
||||
* dieser Bereich bleibt nur für gespeicherte Revisionen mit früheren Pfaden, die (noch) keinem Medium zugeordnet sind.
|
||||
*/
|
||||
final class PublicMedia
|
||||
{
|
||||
public const PREFIX = 'cms/';
|
||||
|
||||
private const IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'webp', 'gif', 'avif'];
|
||||
|
||||
public static function isPublicPath(mixed $path): bool
|
||||
{
|
||||
return is_string($path)
|
||||
@@ -29,36 +23,6 @@ public static function url(string $path): string
|
||||
return route('media.public', ['path' => $path]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bereits vorhandene Bilder im öffentlichen Bereich (veröffentlicht oder zur Veröffentlichung vorgemerkt).
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function imageOptions(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (['media_public', 'cms_incoming'] as $disk) {
|
||||
try {
|
||||
$files = Storage::disk($disk)->allFiles(rtrim(self::PREFIX, '/'));
|
||||
} catch (Throwable) {
|
||||
$files = [];
|
||||
}
|
||||
|
||||
foreach ($files as $file) {
|
||||
$extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
||||
|
||||
if (self::isPublicPath($file) && in_array($extension, self::IMAGE_EXTENSIONS, true)) {
|
||||
$options[$file] = substr($file, strlen(self::PREFIX));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ksort($options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pfad aus dem Zustand eines Upload-Felds (Zeichenkette oder Liste).
|
||||
*/
|
||||
@@ -70,31 +34,4 @@ public static function fromUploadState(mixed $state): ?string
|
||||
|
||||
return is_string($state) && $state !== '' ? $state : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bildadresse für Darstellung und Blockvorschau. In der Vorschau kann ein noch nicht gespeicherter Upload vorliegen.
|
||||
*
|
||||
* @param array<string, mixed> $refs
|
||||
*/
|
||||
public static function imageUrl(array $refs, string $key = 'image'): ?string
|
||||
{
|
||||
$upload = $refs['_upload'] ?? null;
|
||||
$upload = is_array($upload) ? (array_values($upload)[0] ?? null) : $upload;
|
||||
|
||||
if ($upload instanceof TemporaryUploadedFile) {
|
||||
try {
|
||||
return $upload->temporaryUrl();
|
||||
} catch (Throwable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (self::isPublicPath($upload)) {
|
||||
return self::url($upload);
|
||||
}
|
||||
|
||||
$path = $refs[$key] ?? null;
|
||||
|
||||
return self::isPublicPath($path) ? self::url($path) : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Support;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Domain\Media\WebsiteIntake;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Domain\Media\WebsiteMediaAlias;
|
||||
use App\Domain\Media\WebsitePresentation;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Bilder in CMS-Widgets und Abschnittshintergründen aus dem zentralen Medienbestand
|
||||
* (docs/architektur/medienzugriff-fuer-komponenten.md).
|
||||
*
|
||||
* Gespeichert wird im jeweiligen Bildschlüssel (refs.image, style.image, data.items[].image) die Kennung des
|
||||
* Inhaltselements (int). Frühere Werte sind Pfade unter cms/ (string):
|
||||
* - mit wirksamer Zuordnung (WebsiteMediaAlias) gelten sie als das zugeordnete Medium,
|
||||
* - ohne Zuordnung gelten sie weiter als öffentliches CMS-Bild (PublicMedia), bis das Widget umgestellt ist.
|
||||
*
|
||||
* Öffentlich erscheint ein Medium nur über WebsiteMedia (Website-Freigabe, Route website.media). In der
|
||||
* Redaktionsvorschau erscheint ein nicht freigegebenes Bild als Vorschaubild der Bibliothek (Route editorial.card)
|
||||
* mit Hinweis. Eine CMS-Verwendung gibt nichts frei.
|
||||
*
|
||||
* Je Anfrage gebunden (scoped): Ergebnisse werden innerhalb einer Anfrage zwischengespeichert.
|
||||
*/
|
||||
class WebsiteImage
|
||||
{
|
||||
/** @var array<string, int|string|null> */
|
||||
private array $resolved = [];
|
||||
|
||||
/** @var array<int, WebsitePresentation|false> */
|
||||
private array $presentations = [];
|
||||
|
||||
public function __construct(private readonly WebsiteMedia $media) {}
|
||||
|
||||
/**
|
||||
* Gespeicherter oder eingegebener Wert → Kennung (int), früherer Pfad (string) oder null.
|
||||
*/
|
||||
public static function normalize(mixed $value): int|string|null
|
||||
{
|
||||
if (is_array($value)) {
|
||||
$value = array_values($value)[0] ?? null;
|
||||
}
|
||||
|
||||
if (is_int($value) && $value > 0) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (is_string($value) && preg_match('/^[1-9][0-9]*$/', $value) === 1) {
|
||||
return (int) $value;
|
||||
}
|
||||
|
||||
return PublicMedia::isPublicPath($value) ? $value : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kennung des Mediums: gespeicherte Kennung oder wirksam zugeordneter früherer Pfad; sonst null.
|
||||
*/
|
||||
public function elementId(mixed $value): ?int
|
||||
{
|
||||
$value = self::normalize($value);
|
||||
|
||||
if (is_int($value)) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! array_key_exists($value, $this->resolved)) {
|
||||
$this->resolved[$value] = WebsiteMediaAlias::effectiveFor($value)?->content_element_id;
|
||||
}
|
||||
|
||||
$id = $this->resolved[$value];
|
||||
|
||||
return is_int($id) ? $id : null;
|
||||
}
|
||||
|
||||
public function presentation(mixed $value): ?WebsitePresentation
|
||||
{
|
||||
$id = $this->elementId($value);
|
||||
|
||||
if ($id === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! array_key_exists($id, $this->presentations)) {
|
||||
$this->presentations[$id] = $this->media->present($id) ?? false;
|
||||
}
|
||||
|
||||
return $this->presentations[$id] ?: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bildadresse für die Darstellung. Öffentlich nur freigegebene Medien (oder frühere CMS-Bilder ohne Zuordnung);
|
||||
* in der Redaktionsvorschau zusätzlich das Vorschaubild eines nicht freigegebenen Mediums.
|
||||
*/
|
||||
public function url(mixed $value, bool $preview = false): ?string
|
||||
{
|
||||
$presentation = $this->presentation($value);
|
||||
|
||||
if ($presentation !== null) {
|
||||
return $presentation->kind === 'bild' ? $presentation->url : null;
|
||||
}
|
||||
|
||||
$id = $this->elementId($value);
|
||||
|
||||
if ($id !== null) {
|
||||
if (! $preview) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$element = ContentElement::query()->find($id);
|
||||
|
||||
return $element === null ? null : ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
||||
}
|
||||
|
||||
$legacy = self::normalize($value);
|
||||
|
||||
return is_string($legacy) ? PublicMedia::url($legacy) : null;
|
||||
}
|
||||
|
||||
/** Alternativtext: Angabe im Widget, sonst der Alternativtext des Mediums. */
|
||||
public function alt(mixed $value, mixed $override = null): string
|
||||
{
|
||||
if (is_string($override) && trim($override) !== '') {
|
||||
return trim($override);
|
||||
}
|
||||
|
||||
return $this->presentation($value)?->alt ?? '';
|
||||
}
|
||||
|
||||
/** Öffentliche Quellenzeile des Mediums (nur solange es freigegeben ist). */
|
||||
public function credit(mixed $value): ?string
|
||||
{
|
||||
return $this->presentation($value)?->credit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hinweis für die Redaktionsvorschau, wenn das gewählte Bild öffentlich nicht erscheint; sonst null.
|
||||
*/
|
||||
public function previewNotice(mixed $value, string $label = 'Das gewählte Bild'): ?string
|
||||
{
|
||||
$status = $this->status($value);
|
||||
|
||||
if ($status === null || $status['public']) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $label.' „'.$status['title'].'“ erscheint öffentlich nicht: '.$status['note'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Zustand für Editor und Vorschau.
|
||||
*
|
||||
* @return array{public: bool, state: string, title: string, note: string, thumb: ?string, manageUrl: ?string}|null
|
||||
*/
|
||||
public function status(mixed $value): ?array
|
||||
{
|
||||
$value = self::normalize($value);
|
||||
|
||||
if ($value === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$id = $this->elementId($value);
|
||||
|
||||
if ($id === null) {
|
||||
return [
|
||||
'public' => true,
|
||||
'state' => 'legacy',
|
||||
'title' => basename((string) $value),
|
||||
'note' => 'Früheres CMS-Bild, noch nicht in den Medienmanager übernommen.',
|
||||
'thumb' => PublicMedia::url((string) $value),
|
||||
'manageUrl' => null,
|
||||
];
|
||||
}
|
||||
|
||||
$element = ContentElement::query()->with('editorialContentKind')->find($id);
|
||||
|
||||
if ($element === null) {
|
||||
return ['public' => false, 'state' => 'missing', 'title' => 'Medium '.$id, 'note' => 'Das Medium gibt es nicht mehr.', 'thumb' => null, 'manageUrl' => null];
|
||||
}
|
||||
|
||||
$title = (string) ($element->display_title ?: $element->working_title);
|
||||
$thumb = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
||||
$manageUrl = ContentElementResource::getUrl('view', ['record' => $element]);
|
||||
$public = $this->presentation($id) !== null;
|
||||
|
||||
$note = match (true) {
|
||||
$public => 'Für die Website freigegeben.',
|
||||
$element->archived_at !== null => 'Das Medium ist archiviert.',
|
||||
filled($element->thumbnail_error) => 'Die Datei ließ sich nicht verarbeiten: '.Str::limit((string) $element->thumbnail_error, 120),
|
||||
$element->thumbnail_path === null => 'Wird gerade verarbeitet. Danach wird es automatisch für die Website freigegeben.',
|
||||
default => 'Nicht für die Website freigegeben. Die Freigabe steht im Medienmanager beim Medium unter „Beschreibung“ (Website-Freigabe).',
|
||||
};
|
||||
|
||||
return [
|
||||
'public' => $public,
|
||||
'state' => $public ? 'released' : ($element->thumbnail_path === null && ! filled($element->thumbnail_error) ? 'pending' : 'unreleased'),
|
||||
'title' => $title,
|
||||
'note' => $note,
|
||||
'thumb' => $thumb,
|
||||
'manageUrl' => $manageUrl,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft einen Wert beim Speichern. Ein früherer Pfad mit wirksamer Zuordnung wird zur Kennung des Mediums.
|
||||
*/
|
||||
public function clean(mixed $value, WidgetErrors $errors, string $errorKey): int|string|null
|
||||
{
|
||||
$raw = is_array($value) ? (array_values($value)[0] ?? null) : $value;
|
||||
$value = self::normalize($raw);
|
||||
|
||||
if ($value === null) {
|
||||
if ($raw !== null && $raw !== '') {
|
||||
$errors->add($errorKey, 'Bitte ein Bild aus dem Medienmanager wählen.');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (is_string($value)) {
|
||||
return $this->elementId($value) ?? $value;
|
||||
}
|
||||
|
||||
$element = ContentElement::query()->find($value);
|
||||
|
||||
if ($element === null || ! self::isSelectable($element)) {
|
||||
$errors->add($errorKey, 'Dieses Medium ist kein Bild für die Website (nur Bilder aus dem Medienmanager, keine Traineranleitungen).');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $element->id;
|
||||
}
|
||||
|
||||
public static function isSelectable(ContentElement $element): bool
|
||||
{
|
||||
if ($element->output_class !== 'bild' || $element->archived_at !== null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$slug = $element->editorialContentKind?->slug
|
||||
?? ($element->editorial_content_kind_id !== null ? EditorialContentKind::query()->whereKey($element->editorial_content_kind_id)->value('slug') : null);
|
||||
|
||||
return ! in_array($slug, PublicMaterialReader::CONFIDENTIAL_KINDS, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Auswahl für den Medienpicker: Bilder aus dem Medienmanager mit Vorschaubild, Titel und Freigabestatus (HTML).
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function options(?string $search = null, int $limit = 60): array
|
||||
{
|
||||
$search = trim((string) $search);
|
||||
|
||||
$elements = ContentElement::query()
|
||||
->with('editorialContentKind')
|
||||
->where('output_class', 'bild')
|
||||
->whereNull('archived_at')
|
||||
->when($search !== '', function ($query) use ($search): void {
|
||||
$like = '%'.mb_strtolower($search).'%';
|
||||
$query->where(fn ($inner) => $inner
|
||||
->whereRaw('LOWER(working_title) LIKE ?', [$like])
|
||||
->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like]));
|
||||
})
|
||||
->orderByDesc('id')
|
||||
->limit($limit)
|
||||
->get();
|
||||
|
||||
$options = [];
|
||||
foreach ($elements as $element) {
|
||||
if (self::isSelectable($element)) {
|
||||
$options[$element->id] = $this->optionHtml($element->id);
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/** HTML-Bezeichnung einer Option oder des gewählten Werts (auch für frühere Pfade). */
|
||||
public function optionHtml(mixed $value): ?string
|
||||
{
|
||||
$status = $this->status($value);
|
||||
|
||||
if ($status === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$badge = match ($status['state']) {
|
||||
'released' => ['ok', 'Website: freigegeben'],
|
||||
'pending' => ['wait', 'Wird verarbeitet'],
|
||||
'legacy' => ['quiet', 'Früheres CMS-Bild'],
|
||||
default => ['warn', 'Website: nicht freigegeben'],
|
||||
};
|
||||
$thumb = $status['thumb'] !== null
|
||||
? '<img src="'.e($status['thumb']).'" alt="" loading="lazy">'
|
||||
: '<span class="luf-media-option-empty" aria-hidden="true"></span>';
|
||||
|
||||
return '<span class="luf-media-option">'.$thumb
|
||||
.'<span class="luf-media-option-text"><strong>'.e($status['title']).'</strong>'
|
||||
.'<span class="luf-media-badge luf-media-badge-'.$badge[0].'">'.e($badge[1]).'</span></span></span>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Neues Bild direkt aus dem CMS: Datei in den Eingang legen und über WebsiteIntake als Medium anlegen.
|
||||
* Die Warteschlange leitet das Bild ab und gibt die Ableitung für die Website frei.
|
||||
*/
|
||||
public function accept(TemporaryUploadedFile $file, ?string $alt = null): ?ContentElement
|
||||
{
|
||||
$base = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)) ?: 'bild';
|
||||
$name = $base.'-'.Str::lower(Str::random(6)).'.'.($file->guessExtension() ?: 'jpg');
|
||||
|
||||
try {
|
||||
$path = $file->storeAs('cms', $name, 'cms_incoming');
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! is_string($path) || $path === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$actor = auth('staff')->user();
|
||||
|
||||
return app(WebsiteIntake::class)->acceptImage(
|
||||
$path,
|
||||
Str::title(str_replace(['-', '_'], ' ', $base)),
|
||||
null,
|
||||
filled($alt) ? trim((string) $alt) : null,
|
||||
$actor instanceof User ? $actor : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
@@ -84,14 +85,14 @@ public function dataRules(): array
|
||||
'items.*.title' => ['required', 'string', 'max:120'],
|
||||
'items.*.text' => ['nullable', 'string', 'max:500'],
|
||||
'items.*.url' => ['nullable', 'string', 'max:500'],
|
||||
'items.*.image' => ['nullable', 'string', 'max:255'],
|
||||
'items.*.image' => ['nullable'],
|
||||
'items.*._upload' => ['nullable'],
|
||||
];
|
||||
}
|
||||
|
||||
public function dataFields(): array
|
||||
{
|
||||
[$image, $upload] = ImageRefFields::fields('Bild (optional)');
|
||||
[$image, $upload, $status] = ImageRefFields::fields('Bild (optional)');
|
||||
|
||||
return [
|
||||
Repeater::make('items')
|
||||
@@ -106,6 +107,7 @@ public function dataFields(): array
|
||||
->helperText('Seitenpfad wie /praevention oder eine http(s)-Adresse. Leer lassen für eine Karte ohne Link.'),
|
||||
$image,
|
||||
$upload,
|
||||
$status,
|
||||
])
|
||||
->minItems(1)
|
||||
->maxItems(12)
|
||||
@@ -139,7 +141,9 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
|
||||
public function resolve(array $widget, RenderContext $context): array
|
||||
{
|
||||
$images = app(WebsiteImage::class);
|
||||
$items = [];
|
||||
$notices = [];
|
||||
|
||||
foreach ($widget['data']['items'] ?? [] as $item) {
|
||||
if (! is_array($item) || ! filled($item['title'] ?? null)) {
|
||||
@@ -150,11 +154,15 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
'title' => $item['title'],
|
||||
'text' => $item['text'] ?? null,
|
||||
'url' => SafeUrl::isSafe($item['url'] ?? null) ? $item['url'] : null,
|
||||
'imageUrl' => PublicMedia::imageUrl($item),
|
||||
'imageUrl' => $images->url($item['image'] ?? null, $context->preview),
|
||||
];
|
||||
|
||||
if ($context->preview && ($notice = $images->previewNotice($item['image'] ?? null, 'Das Bild der Karte „'.$item['title'].'“')) !== null) {
|
||||
$notices[] = $notice;
|
||||
}
|
||||
}
|
||||
|
||||
return ['items' => $items];
|
||||
return ['items' => $items, 'imageNotice' => $notices === [] ? null : implode(' ', $notices)];
|
||||
}
|
||||
|
||||
public function mediaPaths(array $widget): array
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
@@ -202,8 +203,13 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
{
|
||||
$actions = PremiumFields::actions($widget['data']);
|
||||
|
||||
$images = app(WebsiteImage::class);
|
||||
$image = $widget['refs']['image'] ?? null;
|
||||
|
||||
return [
|
||||
'imageUrl' => PublicMedia::imageUrl($widget['refs']),
|
||||
'imageUrl' => $images->url($image, $context->preview),
|
||||
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
||||
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||
'actions' => $actions,
|
||||
'action' => $actions[0] ?? null,
|
||||
'focus' => PremiumFields::focus($widget['data'], 68, 50),
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\Support\RichText;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
@@ -229,8 +230,13 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
{
|
||||
$surface = $widget['settings']['surface'] ?? 'cream';
|
||||
|
||||
$images = app(WebsiteImage::class);
|
||||
$image = $widget['refs']['image'] ?? null;
|
||||
|
||||
return [
|
||||
'imageUrl' => PublicMedia::imageUrl($widget['refs']),
|
||||
'imageUrl' => $images->url($image, $context->preview),
|
||||
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
||||
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||
'body' => RichText::sanitize(is_string($widget['data']['body'] ?? null) ? $widget['data']['body'] : ''),
|
||||
'actions' => PremiumFields::actions($widget['data']),
|
||||
'focus' => PremiumFields::focus($widget['data'], 64, 43),
|
||||
|
||||
@@ -3,15 +3,16 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* Medien- und Materialkarte (Kit v1.7 „media“): ein Inhaltselement (Film, Dokument, Hörstück …) mit Anzeigetitel,
|
||||
* Kurzbeschreibung, Inhaltsart und Ausgabeart. Öffentlich nur, wenn das Element zur gezeigten Fassung eines
|
||||
* öffentlichen Programms gehört (PublicMaterialReader); die Aktion führt dann auf diese Programmseite.
|
||||
* Die Karte spielt nichts ab, bietet keinen Download und gibt kein geschütztes Medium frei.
|
||||
* Medien- und Materialkarte (Kit v1.7 „media“): ein Inhaltselement mit Anzeigetitel, Kurzbeschreibung, Inhaltsart und
|
||||
* Ausgabeart. Filme erscheinen als Medienkarte (grüne Aktion, Filmtafel ohne freigegebenes Bild), Dokumente und andere
|
||||
* Materialien als Materialkarte (Materialsymbol). Öffentlich nur nach den Regeln von PublicMaterialReader; die Aktion
|
||||
* führt auf die öffentliche Programmseite. Die Karte spielt nichts ab, bietet keinen Download und gibt kein Medium frei.
|
||||
*/
|
||||
class MediaCardWidget extends PremiumCardWidget
|
||||
{
|
||||
@@ -40,15 +41,6 @@ public function schematic(): array
|
||||
return [[2, 2, 56, 32, 'line'], [5, 5, 22, 26, 'image'], [7, 7, 8, 3, 'accent'], [31, 8, 22, 4, 'ink'], [31, 15, 22, 5, 'line'], [31, 25, 14, 5, 'accent']];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
// Ohne Kurzbeschreibung (nicht öffentlich, siehe PublicMaterialReader) gibt es nichts ein- oder auszublenden.
|
||||
$settings = parent::settings();
|
||||
unset($settings['show_summary']);
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
protected function refKey(): string
|
||||
{
|
||||
return 'element';
|
||||
@@ -61,7 +53,7 @@ protected function refLabel(): string
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
return 'Wählbar sind bereitgestellte, nicht archivierte Inhalte. Öffentlich erscheint die Karte nur, wenn der Inhalt zu einem öffentlich gezeigten Programm gehört; sonst nur in der Redaktionsvorschau.';
|
||||
return 'Wählbar sind alle nicht archivierten, nicht gesperrten Filme und Materialien. Öffentlich erscheint die Karte nur mit bereitgestellter Fassung und wenn der Inhalt zu einem öffentlich gezeigten Programm gehört; Traineranleitungen nie. Titel und Kurzbeschreibung pflegen Sie im Medium.';
|
||||
}
|
||||
|
||||
protected function searchSubjects(?string $term): array
|
||||
@@ -80,7 +72,7 @@ protected function rejectSubject(int $id): ?string
|
||||
|
||||
return $element !== null && app(PublicMaterialReader::class)->isSelectable($element)
|
||||
? null
|
||||
: 'Dieser Inhalt ist nicht bereitgestellt oder archiviert.';
|
||||
: 'Dieser Inhalt ist archiviert oder gesperrt.';
|
||||
}
|
||||
|
||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||
@@ -97,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;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use Filament\Forms\Components\Select;
|
||||
@@ -136,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'],
|
||||
@@ -177,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'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -204,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;
|
||||
}
|
||||
|
||||
@@ -213,10 +231,6 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
$data[$field] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
||||
}
|
||||
|
||||
if ($refs['image'] !== null && $data['alt'] === null) {
|
||||
$errors->add('data.alt', 'Bitte einen Alternativtext für das Bild angeben.');
|
||||
}
|
||||
|
||||
return [$data, $refs];
|
||||
}
|
||||
|
||||
@@ -226,11 +240,23 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
$option = fn (string $key, string $default): string => is_string($settings[$key] ?? null) && isset($this->settingOptions()[$key][$settings[$key]]) ? $settings[$key] : $default;
|
||||
$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' => $this->subject($widget['refs'][$this->refKey()] ?? null, $context),
|
||||
'cardStyle' => $this->cardStyle(),
|
||||
'imageUrl' => PublicMedia::imageUrl($widget['refs']),
|
||||
'alt' => is_string($data['alt'] ?? null) ? $data['alt'] : '',
|
||||
'subject' => $subject,
|
||||
'cardStyle' => $subject?->style ?? $this->cardStyle(),
|
||||
'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;
|
||||
@@ -61,26 +62,26 @@ protected function refLabel(): string
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
return 'Nur zur Anzeige freigegebene Programme und Module sind wählbar. Öffentlich erscheinen Programme mit Programmseite; Module nur in der Redaktionsvorschau.';
|
||||
return 'Wählbar sind Programme und Module mit bereitgestellter Fassung. Öffentlich erscheinen nur Programme mit Anzeigefreigabe (mit Programmseite); Module haben keine öffentliche Seite und erscheinen nur in der Redaktionsvorschau.';
|
||||
}
|
||||
|
||||
protected function searchSubjects(?string $term): array
|
||||
{
|
||||
return app(PublicCatalogReader::class)->search($term);
|
||||
return app(PublicCatalogReader::class)->cardSearch($term);
|
||||
}
|
||||
|
||||
protected function subjectLabel(mixed $id): ?string
|
||||
{
|
||||
return app(PublicCatalogReader::class)->labelFor($id);
|
||||
return app(PublicCatalogReader::class)->cardLabelFor($id);
|
||||
}
|
||||
|
||||
protected function rejectSubject(int $id): ?string
|
||||
{
|
||||
$composition = Composition::query()->with('editorialContentKind')->find($id);
|
||||
|
||||
return $composition !== null && app(PublicCatalogReader::class)->isSelectable($composition)
|
||||
return $composition !== null && app(PublicCatalogReader::class)->isCardSelectable($composition)
|
||||
? null
|
||||
: 'Dieses Objekt ist kein zur Anzeige freigegebenes Programm oder Modul.';
|
||||
: 'Dieses Objekt ist kein Programm oder Modul mit bereitgestellter Fassung.';
|
||||
}
|
||||
|
||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -7,9 +7,9 @@
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
|
||||
/**
|
||||
* Redaktionelle Themenkarte (Kit v1.7 „editorial“): ein veröffentlichtes Thema (Säule) mit Name,
|
||||
* öffentlicher Kurzbeschreibung und Verweis auf die Themenseite /themen/{slug}. Ruhige Textaktion mit gelber
|
||||
* Unterstreichung. Ein nicht (mehr) veröffentlichtes Thema erscheint öffentlich nicht.
|
||||
* Redaktionelle Themenkarte (Kit v1.7 „editorial“): ein Thema (fachliche Säule) mit Name, Text für die Website und
|
||||
* Verweis auf die Themenseite /themen/{slug}. Ruhige Textaktion mit gelber Unterstreichung. Wählbar sind alle Säulen;
|
||||
* ein nicht veröffentlichtes Thema erscheint nur in der Redaktionsvorschau, öffentlich nicht.
|
||||
*/
|
||||
class TopicCardWidget extends PremiumCardWidget
|
||||
{
|
||||
@@ -50,7 +50,7 @@ protected function refLabel(): string
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
return 'Nur veröffentlichte Themen sind wählbar. Name und Kurzbeschreibung pflegen Sie im Thema, nicht hier.';
|
||||
return 'Alle fachlichen Säulen sind wählbar. Öffentlich erscheint die Karte nur, wenn das Thema veröffentlicht ist; Name und Text pflegen Sie unter „Fachliche Säulen“, nicht hier.';
|
||||
}
|
||||
|
||||
protected function searchSubjects(?string $term): array
|
||||
@@ -58,11 +58,12 @@ protected function searchSubjects(?string $term): array
|
||||
$term = trim((string) $term);
|
||||
|
||||
return Pillar::query()
|
||||
->published()
|
||||
->orderBy('sort_order')
|
||||
->orderBy('name')
|
||||
->when($term !== '', fn ($query) => $query->whereRaw('LOWER(name) LIKE ?', ['%'.mb_strtolower($term).'%']))
|
||||
->limit(25)
|
||||
->limit(50)
|
||||
->get()
|
||||
->mapWithKeys(fn (Pillar $pillar): array => [$pillar->id => $pillar->name.' · Thema'])
|
||||
->mapWithKeys(fn (Pillar $pillar): array => [$pillar->id => $this->optionLabel($pillar)])
|
||||
->all();
|
||||
}
|
||||
|
||||
@@ -70,39 +71,60 @@ protected function subjectLabel(mixed $id): ?string
|
||||
{
|
||||
$pillar = is_numeric($id) ? Pillar::query()->find((int) $id) : null;
|
||||
|
||||
if ($pillar === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $pillar->name.' · Thema'.($pillar->published_at === null ? ' · nicht veröffentlicht' : '');
|
||||
return $pillar === null ? null : $this->optionLabel($pillar);
|
||||
}
|
||||
|
||||
protected function rejectSubject(int $id): ?string
|
||||
{
|
||||
return Pillar::query()->whereKey($id)->whereNotNull('published_at')->exists()
|
||||
? null
|
||||
: 'Dieses Thema ist nicht veröffentlicht.';
|
||||
return Pillar::query()->whereKey($id)->exists() ? null : 'Dieses Thema gibt es nicht.';
|
||||
}
|
||||
|
||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||
{
|
||||
$pillar = is_numeric($id) ? Pillar::query()->find((int) $id) : null;
|
||||
|
||||
if ($pillar === null || $pillar->published_at === null) {
|
||||
if ($pillar === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$public = self::isPublic($pillar);
|
||||
|
||||
if (! $public && ! $context->preview) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$summary = filled($pillar->public_summary) ? trim((string) $pillar->public_summary) : null;
|
||||
$pages = $pillar->pages()->whereNotNull('published_revision_id')->count();
|
||||
$missing = [];
|
||||
|
||||
if ($summary === null) {
|
||||
$missing[] = 'Kein Text für die Website gepflegt (Fachliche Säulen → Text für die Website).';
|
||||
}
|
||||
|
||||
return new CardSubject(
|
||||
title: (string) $pillar->name,
|
||||
summary: filled($pillar->public_summary) ? (string) $pillar->public_summary : null,
|
||||
summary: $summary,
|
||||
kind: 'Thema',
|
||||
badge: null,
|
||||
meta: [],
|
||||
url: $pillar->publicUrl(),
|
||||
public: true,
|
||||
meta: $pages > 0 ? [$pages === 1 ? '1 Seite zum Thema' : $pages.' Seiten zum Thema'] : [],
|
||||
url: $public ? $pillar->publicUrl() : null,
|
||||
public: $public,
|
||||
notice: $public ? null : 'Nur in der Redaktionsvorschau sichtbar: Das Thema ist nicht veröffentlicht (Fachliche Säulen → Öffentliche Adresse und „Auf der Website veröffentlichen“).',
|
||||
missing: $missing,
|
||||
);
|
||||
}
|
||||
|
||||
/** Öffentlich ist ein Thema mit Veröffentlichung und öffentlicher Adresse (dieselbe Regel wie /themen). */
|
||||
public static function isPublic(Pillar $pillar): bool
|
||||
{
|
||||
return $pillar->published_at !== null && filled($pillar->slug);
|
||||
}
|
||||
|
||||
private function optionLabel(Pillar $pillar): string
|
||||
{
|
||||
return $pillar->name.' · Thema · '.(self::isPublic($pillar) ? 'veröffentlicht' : 'nicht veröffentlicht, nur Redaktionsvorschau');
|
||||
}
|
||||
|
||||
protected function defaultActionLabel(): string
|
||||
{
|
||||
return 'Thema entdecken';
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Legt die technische Ableitung eines Präsentationsmediums an der Medienidentität ab.
|
||||
* Es entsteht keine Inhaltsfassung, keine Freigabe und keine Berechtigung.
|
||||
*/
|
||||
class PresentationFile
|
||||
{
|
||||
public function store(ContentElement $element, string $incoming): void
|
||||
{
|
||||
if (! in_array($element->output_class, ['bild', 'film', 'audio'], true)) {
|
||||
throw new DomainRuleException('Eine Präsentationsdatei ist ein Bild, ein Film oder ein Hörstück.');
|
||||
}
|
||||
|
||||
if ($element->versions()->exists()) {
|
||||
throw new DomainRuleException('Dieses Medium hat bereits eine Inhaltsfassung. Die Präsentationsdatei ersetzt sie nicht.');
|
||||
}
|
||||
|
||||
if (! $this->readable($incoming)) {
|
||||
throw new DomainRuleException('Die Datei liegt nicht im Eingang.');
|
||||
}
|
||||
|
||||
$extension = strtolower(pathinfo($incoming, PATHINFO_EXTENSION));
|
||||
$allowed = match ($element->output_class) {
|
||||
'bild' => ['jpg', 'jpeg', 'png', 'webp', 'gif'],
|
||||
'audio' => ['mp3', 'm4a', 'ogg'],
|
||||
default => ['mp4', 'webm'],
|
||||
};
|
||||
|
||||
if (! in_array($extension, $allowed, true)) {
|
||||
throw new DomainRuleException('Diese Datei ist keine freigebbare Ableitung. Es wird keine Inhaltsfassung angelegt.');
|
||||
}
|
||||
|
||||
$prefix = $element->output_class === 'bild' ? 'vorschau' : 'teaser';
|
||||
$target = $prefix.'/'.$element->id.'/datei.'.$extension;
|
||||
$stream = Storage::disk('cms_incoming')->readStream($incoming);
|
||||
|
||||
if (! is_resource($stream)) {
|
||||
throw new DomainRuleException('Die Datei ließ sich nicht lesen.');
|
||||
}
|
||||
|
||||
try {
|
||||
Storage::disk('media_derived')->writeStream($target, $stream);
|
||||
} finally {
|
||||
fclose($stream);
|
||||
}
|
||||
|
||||
if ($element->output_class === 'bild') {
|
||||
$element->thumbnail_path = $target;
|
||||
$element->thumbnail_source = 'eigen';
|
||||
} else {
|
||||
$element->preview_path = $target;
|
||||
}
|
||||
|
||||
$element->save();
|
||||
}
|
||||
|
||||
private function readable(string $path): bool
|
||||
{
|
||||
return (str_starts_with($path, 'inhalte/') || str_starts_with($path, 'cms/') || str_starts_with($path, 'vorschau/'))
|
||||
&& ! str_contains($path, '..')
|
||||
&& preg_match('#^(inhalte|cms|vorschau)/[A-Za-z0-9._\-/]+$#', $path) === 1
|
||||
&& Storage::disk('cms_incoming')->exists($path);
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,18 @@ public function forElementUpload(ContentElement $element, string $incoming): voi
|
||||
$this->rememberElement($element, 'eigen');
|
||||
}
|
||||
|
||||
public function forWebsiteImage(ContentElement $element, string $incoming): void
|
||||
{
|
||||
if ($element->output_class !== 'bild' || ! $this->incomingIsSafe($incoming)) {
|
||||
$this->fail($element, 'Das Bild für die Website wurde nicht übernommen.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->still($element, Storage::disk('cms_incoming'), $incoming, 'element-'.$element->id);
|
||||
$this->rememberElement($element, 'eigen');
|
||||
}
|
||||
|
||||
public function forElementFrame(ContentElement $element, ContentElementVersion $version, float $seconds): void
|
||||
{
|
||||
if ($version->content_element_id !== $element->id || $element->output_class !== 'film') {
|
||||
@@ -201,6 +213,14 @@ private function readableDerived(mixed $path, string $prefix): bool
|
||||
return Storage::disk('media_derived')->exists($path);
|
||||
}
|
||||
|
||||
private function incomingIsSafe(string $incoming): bool
|
||||
{
|
||||
return (str_starts_with($incoming, 'cms/') || str_starts_with($incoming, 'vorschau/'))
|
||||
&& ! str_contains($incoming, '..')
|
||||
&& preg_match('#^(cms|vorschau)/[A-Za-z0-9._\-/]+$#', $incoming) === 1
|
||||
&& Storage::disk('cms_incoming')->exists($incoming);
|
||||
}
|
||||
|
||||
private function secondText(float $seconds): string
|
||||
{
|
||||
$seconds = max(0, min(7200, $seconds));
|
||||
@@ -271,9 +291,15 @@ private function still(ContentElement|Composition $subject, Filesystem $disk, st
|
||||
|
||||
$width = imagesx($image);
|
||||
$height = imagesy($image);
|
||||
$targetWidth = 640;
|
||||
// Bilder (Ausgabeart „bild“) dienen auch als Website-Ableitung für Einstieg und Hintergrund. 640 px wären dort
|
||||
// sichtbar unscharf; deshalb bis 2400 px, nie vergrößert. Filmstandbilder und Modulvorschauen bleiben bei 640 px.
|
||||
$targetWidth = $subject instanceof ContentElement && $subject->output_class === 'bild'
|
||||
? max(1, min(2400, $width))
|
||||
: 640;
|
||||
$targetHeight = (int) max(1, round($height * ($targetWidth / max(1, $width))));
|
||||
$canvas = imagecreatetruecolor($targetWidth, $targetHeight);
|
||||
// Transparente Flächen (PNG, GIF) werden im JPEG weiß statt schwarz.
|
||||
imagefill($canvas, 0, 0, (int) imagecolorallocate($canvas, 255, 255, 255));
|
||||
imagecopyresampled($canvas, $image, 0, 0, 0, 0, $targetWidth, $targetHeight, $width, $height);
|
||||
ob_start();
|
||||
imagejpeg($canvas, null, 82);
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Jobs\AcceptWebsiteImage;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Nimmt ein neues Website-Bild in den Medienmanager auf.
|
||||
* Die Warteschlange erzeugt danach die Ableitung und gibt sie frei.
|
||||
*/
|
||||
class WebsiteIntake
|
||||
{
|
||||
public function acceptImage(
|
||||
string $incomingPath,
|
||||
string $title,
|
||||
?string $credit = null,
|
||||
?string $alt = null,
|
||||
?User $actor = null,
|
||||
): ContentElement {
|
||||
$title = trim($title);
|
||||
|
||||
if ($title === '') {
|
||||
throw new DomainRuleException('Der Titel fehlt.');
|
||||
}
|
||||
|
||||
if (! $this->incomingIsReadable($incomingPath)) {
|
||||
throw new DomainRuleException('Die Bilddatei liegt nicht im Eingang.');
|
||||
}
|
||||
|
||||
$element = app(ContentService::class)->createElement('bild', 'bild', $title);
|
||||
app(IdentityProfile::class)->fill($element, [
|
||||
'display_title' => $title,
|
||||
'website_credit' => $credit,
|
||||
'website_alt' => $alt,
|
||||
], $actor);
|
||||
AcceptWebsiteImage::dispatch($element->id, $incomingPath, $actor?->id);
|
||||
|
||||
return $element->fresh();
|
||||
}
|
||||
|
||||
private function incomingIsReadable(string $path): bool
|
||||
{
|
||||
return (str_starts_with($path, 'cms/') || str_starts_with($path, 'vorschau/'))
|
||||
&& ! str_contains($path, '..')
|
||||
&& preg_match('#^(cms|vorschau)/[A-Za-z0-9._\-/]+$#', $path) === 1
|
||||
&& Storage::disk('cms_incoming')->exists($path);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Lesesicht für Hero, Teaser und Slideshow.
|
||||
* Liefert nur eine freigegebene öffentliche Ableitung, sonst nichts.
|
||||
*/
|
||||
class WebsiteMedia
|
||||
{
|
||||
public function present(ContentElement|int $element): ?WebsitePresentation
|
||||
{
|
||||
$element = $element instanceof ContentElement
|
||||
? $element
|
||||
: ContentElement::query()->find($element);
|
||||
|
||||
if (! $element instanceof ContentElement || $element->website_released_at === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$path = $element->website_public_path;
|
||||
$expected = '#^website/'.$element->id.'/datei\.[a-z0-9]+$#';
|
||||
|
||||
if (! is_string($path) || preg_match($expected, $path) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! Storage::disk('media_public')->exists($path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$title = trim((string) ($element->display_title ?: $element->working_title));
|
||||
$alt = trim((string) ($element->website_alt ?? ''));
|
||||
|
||||
return new WebsitePresentation(
|
||||
elementId: $element->id,
|
||||
title: $title,
|
||||
alt: $alt !== '' ? $alt : $title,
|
||||
credit: filled($element->website_credit) ? trim((string) $element->website_credit) : null,
|
||||
kind: match ($element->output_class) {
|
||||
'film' => 'film',
|
||||
'audio' => 'audio',
|
||||
default => 'bild',
|
||||
},
|
||||
url: route('website.media', $element),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Slideshow: freigegebene Medien in der angegebenen Reihenfolge. Nicht freigegebene Einträge entfallen.
|
||||
*
|
||||
* @param list<int|string> $ids
|
||||
* @return list<WebsitePresentation>
|
||||
*/
|
||||
public function presentMany(array $ids): array
|
||||
{
|
||||
$presentations = [];
|
||||
|
||||
foreach ($ids as $id) {
|
||||
if (! is_numeric($id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$presentation = $this->present((int) $id);
|
||||
|
||||
if ($presentation !== null) {
|
||||
$presentations[] = $presentation;
|
||||
}
|
||||
}
|
||||
|
||||
return $presentations;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\IdentityChange;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Früherer CMS-Bildpfad (cms/…), der in den Medienmanager übernommen wurde.
|
||||
*
|
||||
* Wirksam ist die Zuordnung erst, wenn das Medium mindestens einmal für die Website freigegeben war. Bis dahin
|
||||
* (Ableitung läuft noch oder ist fehlgeschlagen) bleibt der frühere Pfad gültig, damit keine Seite ihr Bild verliert.
|
||||
* Danach entscheidet allein die Website-Freigabe des Mediums, auch über die frühere Adresse /medien/cms/….
|
||||
*/
|
||||
class WebsiteMediaAlias extends Model
|
||||
{
|
||||
protected $fillable = ['legacy_path', 'content_element_id', 'sha256'];
|
||||
|
||||
public function element(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ContentElement::class, 'content_element_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Wirksame Zuordnung für einen früheren Pfad, sonst null. Zwischengespeichert wird im Aufrufer (WebsiteImage, je Anfrage).
|
||||
*/
|
||||
public static function effectiveFor(mixed $path): ?self
|
||||
{
|
||||
if (! is_string($path) || $path === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$alias = self::query()->with('element')->where('legacy_path', $path)->first();
|
||||
|
||||
return $alias instanceof self && $alias->everReleased() ? $alias : null;
|
||||
}
|
||||
|
||||
public function everReleased(): bool
|
||||
{
|
||||
$element = $this->element;
|
||||
|
||||
if ($element === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($element->website_released_at !== null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return IdentityChange::query()
|
||||
->where('subject_type', $element->getMorphClass())
|
||||
->where('subject_id', $element->id)
|
||||
->where('field', 'website_released_at')
|
||||
->whereNotNull('after')
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
/**
|
||||
* Öffentliche Ableitung eines für die Website freigegebenen Mediums.
|
||||
* Enthält keine internen Vermerke und keine Adresse einer Bestandsdatei.
|
||||
*/
|
||||
final class WebsitePresentation
|
||||
{
|
||||
public function __construct(
|
||||
public readonly int $elementId,
|
||||
public readonly string $title,
|
||||
public readonly string $alt,
|
||||
public readonly ?string $credit,
|
||||
public readonly string $kind,
|
||||
public readonly string $url,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Jobs\PublishWebsiteMedia;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
/**
|
||||
* Gibt eine Ableitung für die Website frei oder nimmt sie zurück.
|
||||
* Legt keinen Lizenzartikel an und ruft DecideAccess nicht auf.
|
||||
* Der Web-Prozess schreibt die öffentliche Datei nicht selbst; das tut die Warteschlange.
|
||||
*/
|
||||
class WebsiteRelease
|
||||
{
|
||||
public function release(ContentElement $element, ?User $actor = null): string
|
||||
{
|
||||
$refusal = $this->refusal($element);
|
||||
|
||||
if ($refusal !== null) {
|
||||
return $refusal;
|
||||
}
|
||||
|
||||
PublishWebsiteMedia::dispatch($element->id, 'release', $actor?->id);
|
||||
|
||||
return 'Für die Website freigegeben. Öffentliche Seiten lesen nur diese Ableitung.';
|
||||
}
|
||||
|
||||
public function withdraw(ContentElement $element, ?User $actor = null): string
|
||||
{
|
||||
PublishWebsiteMedia::dispatch($element->id, 'withdraw', $actor?->id);
|
||||
|
||||
return 'Die Website-Freigabe ist zurückgenommen.';
|
||||
}
|
||||
|
||||
public function refusal(ContentElement $element): ?string
|
||||
{
|
||||
if ($this->isConfidential($element)) {
|
||||
return 'Traineranleitungen werden nicht für die Website freigegeben.';
|
||||
}
|
||||
|
||||
if ($this->derivedPath($element) === null) {
|
||||
return 'Für die Website fehlt eine freigebbare Ableitung. Beim Bild ist das das Vorschaubild. Film und Hörstück ohne Inhaltsfassung nutzen die Datei am Medium unter teaser/. Ein Film mit Inhaltsfassung nutzt die Teaserfassung seiner bereitgestellten Fassung. Die Originaldatei bleibt geschützt.';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function derivedPath(ContentElement $element): ?string
|
||||
{
|
||||
if ($this->isConfidential($element)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($element->output_class === 'bild') {
|
||||
return $this->allowedDerivedPath($element->thumbnail_path, 'vorschau/', ['jpg', 'jpeg', 'png', 'webp', 'gif']);
|
||||
}
|
||||
|
||||
if (in_array($element->output_class, ['film', 'audio'], true)) {
|
||||
$extensions = $element->output_class === 'audio'
|
||||
? ['mp3', 'm4a', 'ogg']
|
||||
: ['mp4', 'webm'];
|
||||
$own = $this->allowedDerivedPath($element->preview_path, 'teaser/', $extensions);
|
||||
|
||||
if ($own !== null) {
|
||||
return $own;
|
||||
}
|
||||
}
|
||||
|
||||
if ($element->output_class !== 'film') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$version = $element->versions()
|
||||
->where('status', ContentVersionStatus::Bereit->value)
|
||||
->orderByDesc('number')
|
||||
->first();
|
||||
|
||||
if ($version === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$path = MediaRendition::query()
|
||||
->where('content_element_version_id', $version->id)
|
||||
->where('role', 'preview')
|
||||
->orderByDesc('id')
|
||||
->value('path');
|
||||
|
||||
return $this->allowedDerivedPath($path, 'teaser/', ['mp4', 'webm']);
|
||||
}
|
||||
|
||||
public function publicPath(ContentElement $element, string $derivedPath): string
|
||||
{
|
||||
$extension = strtolower(pathinfo($derivedPath, PATHINFO_EXTENSION));
|
||||
|
||||
return 'website/'.$element->id.'/datei.'.$extension;
|
||||
}
|
||||
|
||||
private function isConfidential(ContentElement $element): bool
|
||||
{
|
||||
$slug = $element->editorialContentKind?->slug;
|
||||
|
||||
if ($slug === null && $element->editorial_content_kind_id !== null) {
|
||||
$slug = EditorialContentKind::query()->whereKey($element->editorial_content_kind_id)->value('slug');
|
||||
}
|
||||
|
||||
return in_array($slug, PublicMaterialReader::CONFIDENTIAL_KINDS, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $extensions
|
||||
*/
|
||||
private function allowedDerivedPath(mixed $path, string $prefix, array $extensions): ?string
|
||||
{
|
||||
if (! is_string($path) || ! str_starts_with($path, $prefix) || str_contains($path, '..')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||
|
||||
if (! in_array($extension, $extensions, true)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! Storage::disk('media_derived')->exists($path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
@@ -14,14 +14,15 @@
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\EditorialDimension;
|
||||
use App\Domain\Catalog\EditorialDimensionValue;
|
||||
use App\Domain\Catalog\EditorialWorkingDraft;
|
||||
use App\Domain\Catalog\IdentityDimension;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Domain\Catalog\StructureNode;
|
||||
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;
|
||||
@@ -40,6 +41,7 @@
|
||||
|
||||
abstract class EditComposition extends EditRecord
|
||||
{
|
||||
use ManagesEditorialSurface;
|
||||
use WithFileUploads;
|
||||
|
||||
protected string $view = 'filament.editorial.edit';
|
||||
@@ -48,8 +50,12 @@ abstract class EditComposition extends EditRecord
|
||||
|
||||
public string $displayTitle = '';
|
||||
|
||||
public string $teaser = '';
|
||||
|
||||
public string $summary = '';
|
||||
|
||||
public string $searchTerms = '';
|
||||
|
||||
public string $description = '';
|
||||
|
||||
public string $learningGoal = '';
|
||||
@@ -83,10 +89,14 @@ abstract class EditComposition extends EditRecord
|
||||
|
||||
public bool $pickerOpen = false;
|
||||
|
||||
public string $pickerPurpose = 'aufbau';
|
||||
|
||||
public string $pickerQuery = '';
|
||||
|
||||
public string $pickerKind = 'alle';
|
||||
|
||||
public string $pickerLayout = 'kacheln';
|
||||
|
||||
public string $pickerDimension = '';
|
||||
|
||||
public string $pickerSelected = '';
|
||||
@@ -312,11 +322,70 @@ 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('/^medium:(\d+)$/', $target, $mediumMatch) === 1) {
|
||||
$element = ContentElement::query()->find((int) $mediumMatch[1]);
|
||||
|
||||
if (! $element instanceof ContentElement
|
||||
|| $element->archived_at !== null
|
||||
|| ! in_array($element->output_class, ['bild', 'film', 'audio'], true)) {
|
||||
$this->deskFeedback = 'Dieses Präsentationsmedium ist nicht verfügbar.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->rememberAssignment($element->id, null);
|
||||
$this->pickerOpen = false;
|
||||
$this->pickerPurpose = 'aufbau';
|
||||
$this->pickerSelected = '';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -331,6 +400,10 @@ public function pickerResult(): array
|
||||
return ['items' => [], 'more' => false];
|
||||
}
|
||||
|
||||
if ($this->pickerPurpose === 'praesentation') {
|
||||
return app(EditorialCatalog::class)->presentationBrowse($this->pickerQuery);
|
||||
}
|
||||
|
||||
return app(EditorialCatalog::class)->browse(
|
||||
$this->pickerQuery,
|
||||
$this->pickerKind,
|
||||
@@ -351,6 +424,7 @@ public function pickerDetail(): ?array
|
||||
$row = app(EditorialCatalog::class)->rowForTarget(
|
||||
$this->pickerSelected,
|
||||
(int) $this->getRecord()->getKey(),
|
||||
allowDraft: true,
|
||||
);
|
||||
|
||||
if ($row === null) {
|
||||
@@ -360,10 +434,13 @@ public function pickerDetail(): ?array
|
||||
$row['playback'] = null;
|
||||
|
||||
if (preg_match('/^element:(\d+)$/', (string) $row['target'], $match) === 1) {
|
||||
$version = ContentElementVersion::query()->with('element')->find($match[1]);
|
||||
$version = ContentElementVersion::query()->with('element.editorialContentKind')->find($match[1]);
|
||||
$row['playback'] = $version instanceof ContentElementVersion
|
||||
? app(ContentPreviewController::class)->playback($version)
|
||||
: null;
|
||||
if ($version?->element !== null) {
|
||||
$row['visibility'] = app(PublicMaterialReader::class)->visibilityNote($version->element);
|
||||
}
|
||||
}
|
||||
|
||||
return $row;
|
||||
@@ -632,7 +709,7 @@ public function dimensionGroups(): array
|
||||
{
|
||||
$groups = [];
|
||||
|
||||
foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) {
|
||||
foreach (EditorialDimension::forSubject($this->getRecord()) as $dimension) {
|
||||
$values = [];
|
||||
|
||||
foreach ($dimension->values as $value) {
|
||||
@@ -996,7 +1073,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,
|
||||
@@ -1567,7 +1646,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 ?? '');
|
||||
@@ -1795,16 +1876,7 @@ protected function blank(string $value): ?string
|
||||
*/
|
||||
protected function syncDimensions(Composition $composition, array $ids): void
|
||||
{
|
||||
IdentityDimensionValue::query()
|
||||
->where('subject_type', $composition->getMorphClass())
|
||||
->where('subject_id', $composition->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($composition, $value, 'direkt');
|
||||
}
|
||||
app(IdentityDimension::class)->replaceOffered($composition, $ids);
|
||||
}
|
||||
|
||||
protected function persistPresentation(): bool
|
||||
@@ -1822,7 +1894,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());
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
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;
|
||||
@@ -93,7 +92,7 @@ public function form(Schema $schema): Schema
|
||||
CheckboxList::make('dimension_ids')->label('Fachliche Einordnung')
|
||||
->options(function (): array {
|
||||
$options = [];
|
||||
foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) {
|
||||
foreach (EditorialDimension::forSubject($this->getRecord()) as $dimension) {
|
||||
foreach ($dimension->values as $value) {
|
||||
$options[$value->id] = $dimension->label.': '.$value->label;
|
||||
}
|
||||
@@ -233,16 +232,7 @@ protected function handleRecordUpdate(Model $record, array $data): Model
|
||||
DeriveThumbnail::dispatch('element', $record->id, $data['thumbnail_upload']);
|
||||
}
|
||||
if (array_key_exists('dimension_ids', $data)) {
|
||||
$ids = array_map(intval(...), $data['dimension_ids'] ?? []);
|
||||
IdentityDimensionValue::query()
|
||||
->where('subject_type', $record->getMorphClass())
|
||||
->where('subject_id', $record->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($record, $value, 'direkt');
|
||||
}
|
||||
app(IdentityDimension::class)->replaceOffered($record, array_map(intval(...), $data['dimension_ids'] ?? []));
|
||||
}
|
||||
app(PillarService::class)->assign($record, array_map(intval(...), $data['pillars'] ?? []));
|
||||
} catch (DomainRuleException $exception) {
|
||||
|
||||
@@ -2,12 +2,20 @@
|
||||
|
||||
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;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Schemas\Components\RenderHook;
|
||||
use Filament\Schemas\Components\View;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Filament\View\PanelsRenderHook;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Livewire\Attributes\Url;
|
||||
|
||||
class ListContentElements extends ListRecords
|
||||
{
|
||||
@@ -15,9 +23,155 @@ class ListContentElements extends ListRecords
|
||||
|
||||
protected static string $resource = ContentElementResource::class;
|
||||
|
||||
#[Url(as: 'suche', except: '')]
|
||||
public string $suche = '';
|
||||
|
||||
#[Url(as: 'ansicht', except: 'kacheln')]
|
||||
public string $ansicht = 'kacheln';
|
||||
|
||||
#[Url(as: 'art', except: '')]
|
||||
public string $art = '';
|
||||
|
||||
#[Url(as: 'freigabe', except: '')]
|
||||
public string $freigabe = '';
|
||||
|
||||
#[Url(as: 'entwurf', except: '')]
|
||||
public string $entwurf = '';
|
||||
|
||||
#[Url(as: 'fassung', except: '')]
|
||||
public string $fassung = '';
|
||||
|
||||
#[Url(as: 'nutzung', except: '')]
|
||||
public string $nutzung = '';
|
||||
|
||||
#[Url(as: 'saeule', except: '')]
|
||||
public string $saeule = '';
|
||||
|
||||
#[Url(as: 'inhaltsart', except: '')]
|
||||
public string $inhaltsart = '';
|
||||
|
||||
#[Url(as: 'einordnung', except: '')]
|
||||
public string $einordnung = '';
|
||||
|
||||
#[Url(as: 'verarbeitung', except: '')]
|
||||
public string $verarbeitung = '';
|
||||
|
||||
#[Url(as: 'archiv', except: 'aktiv')]
|
||||
public string $archiv = 'aktiv';
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Die Dateien und Texte. Eine Übung, ein Kurs oder eine fachliche Kombination verweist darauf; die Datei wird nicht für jede Verwendung neu hochgeladen.';
|
||||
return 'Die Dateien und Texte. Ein Modul oder ein Programm verweist auf eine Fassung; die Datei wird nicht für jede Verwendung neu hochgeladen.';
|
||||
}
|
||||
|
||||
public function getMaxContentWidth(): Width|string|null
|
||||
{
|
||||
return Width::Full;
|
||||
}
|
||||
|
||||
public function content(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
$this->getTabsContentComponent(),
|
||||
RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_BEFORE),
|
||||
View::make('filament.media.library'),
|
||||
RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_AFTER),
|
||||
]);
|
||||
}
|
||||
|
||||
public function showingList(): bool
|
||||
{
|
||||
return $this->ansicht === 'liste';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function cards(): array
|
||||
{
|
||||
return app(MediaLibrary::class)->cards($this->libraryFilters(), ContentElementResource::editor());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{value: string, label: string}>
|
||||
*/
|
||||
public function typeOptions(): array
|
||||
{
|
||||
return app(MediaLibrary::class)->types();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{id: int, name: string}>
|
||||
*/
|
||||
public function pillarOptions(): array
|
||||
{
|
||||
return app(MediaLibrary::class)->pillars();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{id: int, label: string}>
|
||||
*/
|
||||
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) !== ''
|
||||
|| $this->art !== ''
|
||||
|| $this->freigabe !== ''
|
||||
|| $this->entwurf !== ''
|
||||
|| $this->fassung !== ''
|
||||
|| $this->nutzung !== ''
|
||||
|| $this->saeule !== ''
|
||||
|| $this->einordnung !== ''
|
||||
|| $this->inhaltsart !== ''
|
||||
|| $this->verarbeitung !== ''
|
||||
|| $this->archiv !== 'aktiv';
|
||||
}
|
||||
|
||||
public function resetFilters(): void
|
||||
{
|
||||
$this->suche = '';
|
||||
$this->art = '';
|
||||
$this->freigabe = '';
|
||||
$this->entwurf = '';
|
||||
$this->fassung = '';
|
||||
$this->nutzung = '';
|
||||
$this->saeule = '';
|
||||
$this->einordnung = '';
|
||||
$this->inhaltsart = '';
|
||||
$this->verarbeitung = '';
|
||||
$this->archiv = 'aktiv';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function libraryFilters(): array
|
||||
{
|
||||
return [
|
||||
'suche' => $this->suche,
|
||||
'art' => $this->art,
|
||||
'freigabe' => $this->freigabe,
|
||||
'entwurf' => $this->entwurf,
|
||||
'fassung' => $this->fassung,
|
||||
'nutzung' => $this->nutzung,
|
||||
'saeule' => $this->saeule,
|
||||
'einordnung' => $this->einordnung,
|
||||
'inhaltsart' => $this->inhaltsart,
|
||||
'verarbeitung' => $this->verarbeitung,
|
||||
'archiv' => $this->archiv,
|
||||
];
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
|
||||
@@ -6,23 +6,32 @@
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\IdentityChange;
|
||||
use App\Domain\Catalog\IdentityDimension;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarService;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\WebsiteImageUsage;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
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;
|
||||
use App\Jobs\DeriveThumbnail;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Filament\Schemas\Components\View;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\Collection;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
@@ -30,6 +39,7 @@
|
||||
|
||||
class ViewContentElement extends ViewRecord
|
||||
{
|
||||
use ManagesEditorialSurface;
|
||||
use ReportsDomainRules;
|
||||
use WithFileUploads;
|
||||
|
||||
@@ -47,6 +57,52 @@ class ViewContentElement extends ViewRecord
|
||||
|
||||
public mixed $previewUpload = null;
|
||||
|
||||
public string $bereich = 'inhalt';
|
||||
|
||||
public string $workingTitle = '';
|
||||
|
||||
public string $displayTitle = '';
|
||||
|
||||
public string $teaser = '';
|
||||
|
||||
public string $summary = '';
|
||||
|
||||
public string $searchTerms = '';
|
||||
|
||||
public string $descriptionText = '';
|
||||
|
||||
public string $usageNote = '';
|
||||
|
||||
public string $licenseNote = '';
|
||||
|
||||
public string $websiteCredit = '';
|
||||
|
||||
public string $websiteAlt = '';
|
||||
|
||||
public string $websiteFeedback = '';
|
||||
|
||||
public int|string|null $kindId = null;
|
||||
|
||||
/** @var list<int|string> */
|
||||
public array $pillarIds = [];
|
||||
|
||||
/** @var list<int|string> */
|
||||
public array $dimensionIds = [];
|
||||
|
||||
public string $editorialFeedback = '';
|
||||
|
||||
public string $previewWidth = '640';
|
||||
|
||||
public string $previewSurface = 'website';
|
||||
|
||||
public string $pickerQuery = '';
|
||||
|
||||
public string $pickerContext = 'modul';
|
||||
|
||||
public string $pickerLayout = 'kacheln';
|
||||
|
||||
public string $pickerSelected = '';
|
||||
|
||||
public function mount(int|string $record): void
|
||||
{
|
||||
parent::mount($record);
|
||||
@@ -57,13 +113,28 @@ public function mount(int|string $record): void
|
||||
$this->fassung = $requested;
|
||||
}
|
||||
|
||||
$bereich = (string) request()->query('bereich', 'beschreibung');
|
||||
$this->bereich = in_array($bereich, ['beschreibung', 'inhalt', 'fassungen', 'praesentation', 'verwendung', 'vorschau'], true)
|
||||
? $bereich
|
||||
: 'beschreibung';
|
||||
$this->thumbnailAlt = (string) ($this->getRecord()->thumbnail_alt ?? '');
|
||||
$this->fillEditorial();
|
||||
$this->syncBodyDraft();
|
||||
}
|
||||
|
||||
public function getHeading(): string|Htmlable
|
||||
{
|
||||
return (string) $this->getRecord()->working_title;
|
||||
}
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Jede Fassung hat eine eigene Nummer und bleibt einsehbar. Beschreibung, Arbeitstitel und Säulen gehören zum Medium und ändern keine Fassung. Eine deaktivierte Fassung wird nicht mehr ausgeliefert und lässt sich nicht neu einbauen.';
|
||||
return 'Texte und Vorschaubild ändern keine Fassung. Eine neue Datei oder ein geänderter Lehrtext braucht eine neue Fassung.';
|
||||
}
|
||||
|
||||
public function getMaxContentWidth(): Width|string|null
|
||||
{
|
||||
return Width::Full;
|
||||
}
|
||||
|
||||
public function infolist(Schema $schema): Schema
|
||||
@@ -242,40 +313,6 @@ public function deactivateAction(): Action
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('describe')
|
||||
->label('Beschreibung ändern')
|
||||
->visible(fn (): bool => ContentElementResource::editor())
|
||||
->fillForm(fn (): array => [
|
||||
'working_title' => $this->getRecord()->working_title,
|
||||
'description' => $this->getRecord()->description,
|
||||
'usage_note' => $this->getRecord()->usage_note,
|
||||
'license_note' => $this->getRecord()->license_note,
|
||||
'pillars' => $this->getRecord()->pillars()->pluck('pillars.id')->all(),
|
||||
])
|
||||
->schema([
|
||||
TextInput::make('working_title')->label('Arbeitstitel')->required(),
|
||||
Textarea::make('description')->label('Beschreibung')->rows(4)
|
||||
->helperText('Gilt für das Medium. Speichern legt keine neue Fassung an.'),
|
||||
Textarea::make('usage_note')->label('Hinweise für den Einsatz')->rows(4),
|
||||
Textarea::make('license_note')->label('Interner Lizenzvermerk')->rows(3)
|
||||
->helperText('Nur in der Verwaltung. Nicht in der Bibliothek und nicht auf der Website.'),
|
||||
CheckboxList::make('pillars')
|
||||
->label('Fachliche Säulen')
|
||||
->options(fn (): array => Pillar::query()->orderBy('name')->pluck('name', 'id')->all()),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
app(ContentService::class)->describe($element, (string) $data['working_title'], $data['description'] ?? null);
|
||||
app(IdentityProfile::class)->fill($element, [
|
||||
'usage_note' => $data['usage_note'] ?? null,
|
||||
'license_note' => $data['license_note'] ?? null,
|
||||
], auth()->user());
|
||||
app(PillarService::class)->assign($element, array_map(intval(...), $data['pillars'] ?? []));
|
||||
}, 'Die Beschreibung ist gespeichert.');
|
||||
$this->getRecord()->refresh();
|
||||
}),
|
||||
Action::make('releaseVersion')
|
||||
->label('Fassung freigeben')
|
||||
->modalHeading('Fassung freigeben')
|
||||
@@ -395,6 +432,7 @@ private function pictureCaption(ContentElement $element): string
|
||||
return match ($source) {
|
||||
'eigen' => 'Eigenes Vorschaubild.',
|
||||
'datei' => 'Vorschaubild aus der Datei des Mediums.',
|
||||
'bestand' => 'Vorschaubild aus einem Bild im Bestand. Es ist damit nicht für die Website freigegeben.',
|
||||
default => '',
|
||||
};
|
||||
}
|
||||
@@ -406,4 +444,285 @@ private function ownedVersion(int $id): ?ContentElementVersion
|
||||
|
||||
return $element->versions()->whereKey($id)->first();
|
||||
}
|
||||
|
||||
public function saveEditorial(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$title = trim($this->workingTitle);
|
||||
|
||||
if ($title === '') {
|
||||
$this->editorialFeedback = 'Der Arbeitstitel fehlt.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$versions = $element->versions()->count();
|
||||
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,
|
||||
'website_credit' => $this->websiteCredit,
|
||||
'website_alt' => $this->websiteAlt,
|
||||
'thumbnail_alt' => $this->thumbnailAlt,
|
||||
'editorial_content_kind_id' => filled($this->kindId) ? (int) $this->kindId : null,
|
||||
], auth()->user());
|
||||
app(PillarService::class)->assign($element, array_map(intval(...), $this->pillarIds));
|
||||
app(IdentityDimension::class)->replaceOffered($element, array_map(intval(...), $this->dimensionIds));
|
||||
|
||||
$element->refresh();
|
||||
$this->fillEditorial();
|
||||
$this->editorialFeedback = $element->versions()->count() === $versions
|
||||
? 'Gespeichert. Es gibt keine neue Fassung.'
|
||||
: 'Gespeichert. Prüfe die Fassungen, ihre Zahl hat sich geändert.';
|
||||
}
|
||||
|
||||
public function releaseForWebsite(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
app(IdentityProfile::class)->fill($element, [
|
||||
'website_credit' => $this->websiteCredit,
|
||||
'website_alt' => $this->websiteAlt,
|
||||
], auth()->user());
|
||||
$element->refresh();
|
||||
$this->websiteFeedback = app(WebsiteRelease::class)->release($element, auth()->user());
|
||||
$element->refresh();
|
||||
$this->fillEditorial();
|
||||
}
|
||||
|
||||
public function withdrawWebsite(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$this->websiteFeedback = app(WebsiteRelease::class)->withdraw($element, auth()->user());
|
||||
$element->refresh();
|
||||
$this->fillEditorial();
|
||||
}
|
||||
|
||||
/**
|
||||
* Website-Seiten, die dieses Medium als Bild verwenden (CMS-Widgets und Abschnittshintergründe).
|
||||
*
|
||||
* @return list<array{path: string, published: bool, draft: bool}>
|
||||
*/
|
||||
public function websitePages(): array
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
return app(WebsiteImageUsage::class)->pages($element);
|
||||
}
|
||||
|
||||
public function websiteIsPublic(): bool
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
return app(WebsiteMedia::class)->present($element->fresh()) !== null;
|
||||
}
|
||||
|
||||
public function adoptLibraryImage(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$detail = $this->selectionDetail();
|
||||
$sourceId = (int) ($detail['element_id'] ?? 0);
|
||||
$source = $sourceId > 0 ? ContentElement::query()->find($sourceId) : null;
|
||||
$path = $source?->thumbnail_path;
|
||||
|
||||
if (! $source instanceof ContentElement || $source->output_class !== 'bild' || ! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
||||
$this->pictureFeedback = 'Dieses Bild hat noch kein übernehmbares Vorschaubild.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$versions = $element->versions()->count();
|
||||
app(IdentityProfile::class)->fill($element, [
|
||||
'thumbnail_path' => $path,
|
||||
'thumbnail_alt' => filled($source->thumbnail_alt) ? $source->thumbnail_alt : $source->working_title,
|
||||
'thumbnail_source' => 'bestand',
|
||||
'thumbnail_error' => null,
|
||||
], auth()->user());
|
||||
$element->refresh();
|
||||
$this->thumbnailAlt = (string) ($element->thumbnail_alt ?? '');
|
||||
$this->pictureFeedback = $element->versions()->count() === $versions
|
||||
? 'Vorschaubild übernommen. Es gibt keine neue Fassung. Für die Website ist es damit nicht freigegeben.'
|
||||
: 'Vorschaubild übernommen. Prüfe die Fassungen.';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{items: list<array<string, mixed>>, more: bool}
|
||||
*/
|
||||
public function selection(): array
|
||||
{
|
||||
return app(EditorialCatalog::class)->browse(
|
||||
$this->pickerQuery,
|
||||
$this->pickerContext === 'bild' ? 'bild' : 'alle',
|
||||
'',
|
||||
0,
|
||||
elementsOnly: $this->pickerContext !== 'modul',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>|null
|
||||
*/
|
||||
public function selectionDetail(): ?array
|
||||
{
|
||||
if ($this->pickerSelected === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$row = app(EditorialCatalog::class)->rowForTarget($this->pickerSelected, 0, allowDraft: true);
|
||||
|
||||
if ($row === null || ! isset($row['element_id'])) {
|
||||
return $row;
|
||||
}
|
||||
|
||||
$element = ContentElement::query()->with('editorialContentKind')->find((int) $row['element_id']);
|
||||
|
||||
if ($element instanceof ContentElement) {
|
||||
$row['visibility'] = app(PublicMaterialReader::class)->visibilityNote($element);
|
||||
}
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function previewHtml(): string
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$draft = [
|
||||
'working_title' => $this->workingTitle,
|
||||
'display_title' => $this->displayTitle,
|
||||
'summary' => $this->summary,
|
||||
'thumbnail_alt' => $this->thumbnailAlt,
|
||||
];
|
||||
|
||||
if ($this->previewSurface === 'bibliothek') {
|
||||
$title = trim($this->displayTitle) !== '' ? trim($this->displayTitle) : trim($this->workingTitle);
|
||||
|
||||
return view('member.partials.card', [
|
||||
'href' => '#vorschau',
|
||||
'card' => [
|
||||
'title' => $title !== '' ? $title : $element->working_title,
|
||||
'summary' => trim($this->summary) !== '' ? trim($this->summary) : null,
|
||||
'kind' => PublicMaterialReader::outputLabel((string) $element->output_class),
|
||||
'coverage' => 'offen',
|
||||
'image' => trim($this->thumbnailAlt) !== '' ? trim($this->thumbnailAlt) : $title,
|
||||
'image_url' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
||||
'error' => 'Vorschau der Kartenform. Ob jemand sie öffnen darf, entscheidet die Lizenz.',
|
||||
],
|
||||
])->render();
|
||||
}
|
||||
|
||||
$subject = app(PublicMaterialReader::class)->subject($element->id, true, $draft);
|
||||
|
||||
if ($subject === null) {
|
||||
return '<p class="preview-note">Für dieses Medium liegt noch keine anzeigbare Fassung vor. Die Karte erscheint deshalb auch in der Vorschau nicht.</p>';
|
||||
}
|
||||
|
||||
return view('widgets.premium_card', [
|
||||
'subject' => $subject,
|
||||
'context' => RenderContext::preview(),
|
||||
'cardStyle' => $subject->style ?? 'media',
|
||||
'imageUrl' => null,
|
||||
'alt' => '',
|
||||
'focus' => ['x' => 50, 'y' => 45],
|
||||
'format' => 'landscape',
|
||||
'fit' => 'cover',
|
||||
'headingTag' => 'h3',
|
||||
'show' => ['summary' => true, 'kind' => true, 'meta' => true, 'action' => true],
|
||||
'actionLabel' => 'Ansehen',
|
||||
'note' => null,
|
||||
'stacked' => $this->previewWidth === '390',
|
||||
])->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{field: string, after: string, when: string}>
|
||||
*/
|
||||
public function editorialHistory(): array
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$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',
|
||||
'website_alt' => 'Alternativtext der Website',
|
||||
'website_released_at' => 'Website-Freigabe',
|
||||
'thumbnail_alt' => 'Alternativtext',
|
||||
'thumbnail_path' => 'Vorschaubild',
|
||||
'thumbnail_source' => 'Herkunft des Vorschaubilds',
|
||||
'editorial_content_kind_id' => 'Inhaltsart',
|
||||
];
|
||||
|
||||
return IdentityChange::query()
|
||||
->where('subject_type', $element->getMorphClass())
|
||||
->where('subject_id', $element->id)
|
||||
->latest('occurred_at')
|
||||
->limit(8)
|
||||
->get()
|
||||
->map(fn (IdentityChange $change): array => [
|
||||
'field' => $labels[$change->field] ?? $change->field,
|
||||
'after' => is_scalar($change->after) ? (string) $change->after : '',
|
||||
'when' => $change->occurred_at?->timezone(config('app.timezone'))->format('d.m.Y H:i') ?? '',
|
||||
])
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function usageCard(): array
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
return app(MediaLibrary::class)->cardFor($element, ContentElementResource::editor());
|
||||
}
|
||||
|
||||
private function fillEditorial(): void
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$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 ?? '');
|
||||
$this->websiteCredit = (string) ($element->website_credit ?? '');
|
||||
$this->websiteAlt = (string) ($element->website_alt ?? '');
|
||||
$this->kindId = $element->editorial_content_kind_id;
|
||||
$this->pillarIds = $element->pillars()->pluck('pillars.id')->all();
|
||||
$this->dimensionIds = IdentityDimensionValue::query()
|
||||
->where('subject_type', $element->getMorphClass())
|
||||
->where('subject_id', $element->id)
|
||||
->where('origin', 'direkt')
|
||||
->pluck('editorial_dimension_value_id')
|
||||
->all();
|
||||
}
|
||||
}
|
||||
@@ -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,14 @@
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\EditorialDimension;
|
||||
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 +22,108 @@
|
||||
|
||||
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());
|
||||
|
||||
app(IdentityDimension::class)->replaceOffered($article, array_map(intval(...), $this->dimensionIds));
|
||||
|
||||
$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::forSubject($this->getRecord()) 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 [
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Filament\Resources\Combinations\CombinationResource;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Resources\Courses\CourseResource;
|
||||
use App\Filament\Resources\Exercises\ExerciseResource;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -63,6 +65,10 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
|
||||
return $this->draftCompositionRow((int) $draftMatch[1], $exceptCompositionId, $allowSelf);
|
||||
}
|
||||
|
||||
if (preg_match('/^medium:(\d+)$/', $target, $mediumMatch) === 1) {
|
||||
return $this->rowForPresentationMedium((int) $mediumMatch[1]);
|
||||
}
|
||||
|
||||
if (preg_match('/^(element|composition):(\d+)$/', $target, $match) !== 1) {
|
||||
return null;
|
||||
}
|
||||
@@ -111,7 +117,7 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
|
||||
'identity' => 'medium:'.$element->id,
|
||||
'open_url' => route('content.preview', $version),
|
||||
'open_label' => 'Medium ansehen',
|
||||
'edit_url' => null,
|
||||
'edit_url' => ContentElementResource::getUrl('view', ['record' => $element]),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -208,6 +214,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')
|
||||
@@ -240,6 +248,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);
|
||||
});
|
||||
})
|
||||
@@ -262,7 +272,7 @@ public function search(string $query, string $scope, int $exceptCompositionId):
|
||||
/**
|
||||
* @return array{items: list<array<string, string|null>>, more: bool}
|
||||
*/
|
||||
public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId): array
|
||||
public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId, bool $elementsOnly = false): array
|
||||
{
|
||||
$query = trim($query);
|
||||
$like = '%'.str_replace(['%', '_'], ['', ''], $query).'%';
|
||||
@@ -294,7 +304,7 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($kind, ['alle', 'modul'], true)) {
|
||||
if (! $elementsOnly && in_array($kind, ['alle', 'modul'], true)) {
|
||||
$latestCompositions = CompositionVersion::query()
|
||||
->selectRaw('MAX(id)')
|
||||
->where('status', ContentVersionStatus::Bereit)
|
||||
@@ -315,6 +325,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);
|
||||
});
|
||||
})
|
||||
@@ -372,12 +384,113 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
}
|
||||
}
|
||||
|
||||
$rows = $this->withVisibility($rows);
|
||||
|
||||
return [
|
||||
'items' => array_slice($rows, 0, $limit),
|
||||
'more' => count($rows) > $limit,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Bestandssuche für Präsentationsmedien.
|
||||
* Fassungen bleiben im didaktischen Aufbau. Bilder, Filme und Hörstücke ohne Inhaltsfassung kommen dazu.
|
||||
*
|
||||
* @return array{items: list<array<string, string|null>>, more: bool}
|
||||
*/
|
||||
public function presentationBrowse(string $query): array
|
||||
{
|
||||
$catalog = $this->browse($query, 'alle', '', 0, elementsOnly: true);
|
||||
$seen = [];
|
||||
|
||||
foreach ($catalog['items'] as $item) {
|
||||
if (isset($item['element_id'])) {
|
||||
$seen[(int) $item['element_id']] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$query = trim($query);
|
||||
$like = '%'.str_replace(['%', '_'], ['', ''], $query).'%';
|
||||
$elements = ContentElement::query()
|
||||
->with('editorialContentKind')
|
||||
->whereIn('output_class', ['bild', 'film', 'audio'])
|
||||
->whereNull('archived_at')
|
||||
->whereDoesntHave('versions')
|
||||
->where(function ($builder): void {
|
||||
$builder->whereNull('editorial_content_kind_id')
|
||||
->orWhereDoesntHave('editorialContentKind', function ($kind): void {
|
||||
$kind->where('slug', 'traineranleitung');
|
||||
});
|
||||
})
|
||||
->when($query !== '', function ($builder) use ($like): void {
|
||||
$builder->where(function ($inner) use ($like): void {
|
||||
$inner->where('working_title', 'like', $like)
|
||||
->orWhere('display_title', 'like', $like)
|
||||
->orWhere('teaser', 'like', $like)
|
||||
->orWhere('search_terms', 'like', $like)
|
||||
->orWhere('summary', 'like', $like);
|
||||
});
|
||||
})
|
||||
->orderBy('working_title')
|
||||
->limit(48)
|
||||
->get();
|
||||
|
||||
foreach ($elements as $element) {
|
||||
if (isset($seen[$element->id])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$row = $this->rowForPresentationMedium($element->id);
|
||||
|
||||
if ($row !== null) {
|
||||
$catalog['items'][] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
return $catalog;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string|null>|null
|
||||
*/
|
||||
private function rowForPresentationMedium(int $id): ?array
|
||||
{
|
||||
$element = ContentElement::query()->with('editorialContentKind')->find($id);
|
||||
|
||||
if (! $element instanceof ContentElement
|
||||
|| $element->archived_at !== null
|
||||
|| ! in_array($element->output_class, ['bild', 'film', 'audio'], true)
|
||||
|| $element->editorialContentKind?->slug === 'traineranleitung') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$kind = $element->editorialContentKind?->label ?: $this->outputLabel((string) $element->output_class);
|
||||
$title = filled($element->display_title) ? $element->display_title : $element->working_title;
|
||||
|
||||
return [
|
||||
'target' => 'medium:'.$element->id,
|
||||
'element_id' => (string) $element->id,
|
||||
'title' => $title,
|
||||
'kind' => $kind,
|
||||
'output' => (string) $element->output_class,
|
||||
'body' => '',
|
||||
'summary' => (string) ($element->summary ?: $element->description ?: ''),
|
||||
'medium_description' => (string) ($element->description ?? ''),
|
||||
'usage_note' => (string) ($element->usage_note ?? ''),
|
||||
'license_note' => (string) ($element->license_note ?? ''),
|
||||
'tone' => $this->tone((string) $element->output_class, $kind),
|
||||
'image' => $element->output_class === 'bild'
|
||||
? $this->cardUrl('element', $element->id, $element->thumbnail_path)
|
||||
: null,
|
||||
'version_label' => 'Ohne Inhaltsfassung',
|
||||
'committed' => false,
|
||||
'identity' => 'medium:'.$element->id,
|
||||
'open_url' => ContentElementResource::getUrl('view', ['record' => $element]),
|
||||
'open_label' => 'Medium ansehen',
|
||||
'edit_url' => ContentElementResource::getUrl('view', ['record' => $element]),
|
||||
];
|
||||
}
|
||||
|
||||
public function tone(string $outputClass, string $kindLabel): string
|
||||
{
|
||||
$value = mb_strtolower($outputClass.' '.$kindLabel);
|
||||
@@ -400,6 +513,42 @@ public function cardUrl(string $kind, int $id, ?string $path): ?string
|
||||
return route('editorial.card', ['kind' => $kind, 'subject' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $rows
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
private function withVisibility(array $rows): array
|
||||
{
|
||||
$ids = [];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if (isset($row['element_id'])) {
|
||||
$ids[] = (int) $row['element_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($ids === []) {
|
||||
return $rows;
|
||||
}
|
||||
|
||||
$reader = app(PublicMaterialReader::class);
|
||||
$elements = ContentElement::query()
|
||||
->with('editorialContentKind')
|
||||
->whereIn('id', array_values(array_unique($ids)))
|
||||
->get()
|
||||
->keyBy('id');
|
||||
|
||||
foreach ($rows as $index => $row) {
|
||||
$element = $elements->get((int) ($row['element_id'] ?? 0));
|
||||
|
||||
if ($element instanceof ContentElement) {
|
||||
$rows[$index]['visibility'] = $reader->visibilityNote($element);
|
||||
}
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<ContentElement> $builder
|
||||
*/
|
||||
@@ -408,6 +557,7 @@ private function constrainElement($builder, string $query, string $like, string
|
||||
$outputs = match ($kind) {
|
||||
'film' => ['film'],
|
||||
'text' => ['text'],
|
||||
'bild' => ['bild'],
|
||||
'dokument' => ['pdf', 'document'],
|
||||
default => null,
|
||||
};
|
||||
@@ -427,6 +577,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);
|
||||
});
|
||||
@@ -708,6 +860,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 = false;
|
||||
|
||||
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)->presentationBrowse($this->presentationQuery);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,578 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\CompositionMember;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\EditorialDimension;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\ReleaseContent;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class MediaLibrary
|
||||
{
|
||||
public function __construct(private readonly EditorialCatalog $catalog) {}
|
||||
|
||||
/**
|
||||
* @return list<array{value: string, label: string}>
|
||||
*/
|
||||
public function types(): array
|
||||
{
|
||||
return [
|
||||
['value' => 'film', 'label' => 'Film'],
|
||||
['value' => 'text', 'label' => 'Text'],
|
||||
['value' => 'document', 'label' => 'Dokument'],
|
||||
['value' => 'bild', 'label' => 'Bild'],
|
||||
['value' => 'audio', 'label' => 'Hörstück'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{id: int, name: string}>
|
||||
*/
|
||||
public function pillars(): array
|
||||
{
|
||||
return Pillar::query()
|
||||
->orderBy('name')
|
||||
->get(['id', 'name'])
|
||||
->map(fn (Pillar $pillar): array => ['id' => $pillar->id, 'name' => $pillar->name])
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{id: int, label: string}>
|
||||
*/
|
||||
public function classifications(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) {
|
||||
foreach ($dimension->values->sortBy('label') as $value) {
|
||||
$options[] = [
|
||||
'id' => $value->id,
|
||||
'label' => $dimension->label.': '.$value->label,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $filters
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function cardFor(ContentElement $element, bool $canEdit): array
|
||||
{
|
||||
$element->loadMissing(['versions', 'pillars', 'editorialContentKind']);
|
||||
$versionIds = $element->versions->pluck('id')->all();
|
||||
|
||||
return $this->card(
|
||||
$element,
|
||||
$this->portrait($element),
|
||||
$this->placements($versionIds)[$element->id] ?? [],
|
||||
$this->licenses($versionIds)[$element->id] ?? [],
|
||||
$canEdit,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $filters
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function cards(array $filters, bool $canEdit): array
|
||||
{
|
||||
$filters = $this->normalize($filters);
|
||||
$elements = ContentElement::query()
|
||||
->with(['versions', 'pillars', 'editorialContentKind'])
|
||||
->orderBy('working_title')
|
||||
->get();
|
||||
$versionIds = $elements->flatMap(fn (ContentElement $element) => $element->versions->pluck('id'))->all();
|
||||
$placements = $this->placements($versionIds);
|
||||
$licenses = $this->licenses($versionIds);
|
||||
$classified = $this->classifiedIds();
|
||||
$needle = mb_strtolower($filters['suche']);
|
||||
$cards = [];
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$portrait = $this->portrait($element);
|
||||
$uses = $placements[$element->id] ?? [];
|
||||
$codes = $licenses[$element->id] ?? [];
|
||||
|
||||
if (! $this->matches($element, $portrait, $uses, $filters, $needle, $classified)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$cards[] = $this->card($element, $portrait, $uses, $codes, $canEdit);
|
||||
}
|
||||
|
||||
usort($cards, fn (array $left, array $right): int => strcasecmp(
|
||||
mb_strtolower($left['title']),
|
||||
mb_strtolower($right['title']),
|
||||
));
|
||||
|
||||
return $cards;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, string> $filters
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function normalize(array $filters): array
|
||||
{
|
||||
return [
|
||||
'suche' => trim($filters['suche'] ?? ''),
|
||||
'art' => $this->choice($filters['art'] ?? '', ['film', 'text', 'document', 'bild', 'audio']),
|
||||
'freigabe' => $this->choice($filters['freigabe'] ?? '', ['freigegeben', 'entwurf', 'ohne']),
|
||||
'entwurf' => $this->choice($filters['entwurf'] ?? '', ['offen', 'keiner']),
|
||||
'fassung' => $this->choice($filters['fassung'] ?? '', ['mit', 'nur']),
|
||||
'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'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $allowed
|
||||
*/
|
||||
private function choice(string $value, array $allowed, string $fallback = ''): string
|
||||
{
|
||||
return in_array($value, $allowed, true) ? $value : $fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $versionIds
|
||||
* @return array<int, list<array<string, mixed>>>
|
||||
*/
|
||||
private function placements(array $versionIds): array
|
||||
{
|
||||
if ($versionIds === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$grouped = [];
|
||||
$members = CompositionMember::query()
|
||||
->whereIn('content_element_version_id', $versionIds)
|
||||
->with(['compositionVersion.composition', 'contentElementVersion'])
|
||||
->orderBy('id')
|
||||
->get();
|
||||
|
||||
foreach ($members as $member) {
|
||||
$version = $member->contentElementVersion;
|
||||
$compositionVersion = $member->compositionVersion;
|
||||
$composition = $compositionVersion?->composition;
|
||||
|
||||
if (! $version instanceof ContentElementVersion || $compositionVersion === null || ! $composition instanceof Composition) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$elementId = $version->content_element_id;
|
||||
$key = $composition->id.'-'.$compositionVersion->id.'-'.$version->id;
|
||||
$role = trim((string) $member->role);
|
||||
|
||||
if (! isset($grouped[$elementId][$key])) {
|
||||
$grouped[$elementId][$key] = [
|
||||
'compositionId' => $composition->id,
|
||||
'name' => $this->catalog->compositionTitle($composition),
|
||||
'type' => $this->kindLabel($composition),
|
||||
'mediumVersion' => $this->versionLabel($version),
|
||||
'hostVersion' => 'Fassung '.$compositionVersion->number,
|
||||
'url' => EditorialCatalog::editUrl($composition),
|
||||
'roles' => [],
|
||||
];
|
||||
}
|
||||
|
||||
if ($role !== '' && ! in_array($role, $grouped[$elementId][$key]['roles'], true)) {
|
||||
$grouped[$elementId][$key]['roles'][] = $role;
|
||||
}
|
||||
}
|
||||
|
||||
$placements = [];
|
||||
|
||||
foreach ($grouped as $elementId => $rows) {
|
||||
$list = array_values($rows);
|
||||
usort($list, fn (array $left, array $right): int => [$left['type'], $left['name'], $left['hostVersion']]
|
||||
<=> [$right['type'], $right['name'], $right['hostVersion']]);
|
||||
$placements[$elementId] = $list;
|
||||
}
|
||||
|
||||
return $placements;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $versionIds
|
||||
* @return array<int, list<string>>
|
||||
*/
|
||||
private function licenses(array $versionIds): array
|
||||
{
|
||||
if ($versionIds === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$codes = [];
|
||||
$contents = ReleaseContent::query()
|
||||
->whereIn('content_element_version_id', $versionIds)
|
||||
->with(['release.article', 'elementVersion'])
|
||||
->orderBy('id')
|
||||
->get();
|
||||
|
||||
foreach ($contents as $content) {
|
||||
$version = $content->elementVersion;
|
||||
$code = $content->release?->article?->code;
|
||||
|
||||
if (! $version instanceof ContentElementVersion || ! is_string($code) || $code === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$codes[$version->content_element_id][$code] = $code;
|
||||
}
|
||||
|
||||
return array_map(fn (array $row): array => array_values($row), $codes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, list<int>>
|
||||
*/
|
||||
private function classifiedIds(): array
|
||||
{
|
||||
$map = [];
|
||||
$rows = IdentityDimensionValue::query()
|
||||
->where('subject_type', (new ContentElement)->getMorphClass())
|
||||
->where('origin', 'direkt')
|
||||
->get(['subject_id', 'editorial_dimension_value_id']);
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$map[(int) $row->subject_id][] = (int) $row->editorial_dimension_value_id;
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* ready: ?ContentElementVersion,
|
||||
* draft: ?ContentElementVersion,
|
||||
* blocked: ?ContentElementVersion,
|
||||
* versionCount: int,
|
||||
* archived: bool,
|
||||
* processing: ?string,
|
||||
* stand: string,
|
||||
* standTone: string,
|
||||
* draftNote: ?string,
|
||||
* blockedNote: ?string
|
||||
* }
|
||||
*/
|
||||
private function portrait(ContentElement $element): array
|
||||
{
|
||||
/** @var Collection<int, ContentElementVersion> $versions */
|
||||
$versions = $element->versions->sortByDesc('number')->values();
|
||||
$ready = $versions->first(fn (ContentElementVersion $version): bool => $version->status === ContentVersionStatus::Bereit);
|
||||
$draft = $versions->first(fn (ContentElementVersion $version): bool => $version->status === ContentVersionStatus::Entwurf);
|
||||
$blocked = $versions->first(fn (ContentElementVersion $version): bool => $version->status === ContentVersionStatus::Gesperrt);
|
||||
$processing = $this->processing($versions);
|
||||
|
||||
if ($ready instanceof ContentElementVersion) {
|
||||
$stand = 'Fassung '.$ready->number.' freigegeben';
|
||||
$tone = 'ready';
|
||||
} elseif ($draft instanceof ContentElementVersion) {
|
||||
$stand = 'Entwurf, noch nicht freigegeben';
|
||||
$tone = 'draft';
|
||||
} elseif ($blocked instanceof ContentElementVersion) {
|
||||
$stand = 'Fassung '.$blocked->number.' deaktiviert';
|
||||
$tone = 'blocked';
|
||||
} else {
|
||||
$stand = 'Noch keine Fassung';
|
||||
$tone = 'quiet';
|
||||
}
|
||||
|
||||
return [
|
||||
'ready' => $ready instanceof ContentElementVersion ? $ready : null,
|
||||
'draft' => $draft instanceof ContentElementVersion ? $draft : null,
|
||||
'blocked' => $blocked instanceof ContentElementVersion ? $blocked : null,
|
||||
'versionCount' => $versions->count(),
|
||||
'archived' => $element->archived_at !== null,
|
||||
'processing' => $processing,
|
||||
'stand' => $stand,
|
||||
'standTone' => $tone,
|
||||
'draftNote' => $ready instanceof ContentElementVersion && $draft instanceof ContentElementVersion
|
||||
? 'Entwurf offen'
|
||||
: null,
|
||||
'blockedNote' => $blocked instanceof ContentElementVersion && ($ready instanceof ContentElementVersion || $draft instanceof ContentElementVersion)
|
||||
? 'Fassung '.$blocked->number.' deaktiviert'
|
||||
: null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection<int, ContentElementVersion> $versions
|
||||
*/
|
||||
private function processing(Collection $versions): ?string
|
||||
{
|
||||
foreach ($versions as $version) {
|
||||
$meta = is_array($version->metadata) ? $version->metadata : [];
|
||||
|
||||
if (is_string($meta['error'] ?? null) && trim($meta['error']) !== '') {
|
||||
return 'Verarbeitungsfehler';
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($versions as $version) {
|
||||
$meta = is_array($version->metadata) ? $version->metadata : [];
|
||||
$incoming = $meta['incoming'] ?? null;
|
||||
$hasIncoming = (is_string($incoming) && $incoming !== '') || (is_array($incoming) && $incoming !== []);
|
||||
|
||||
if ($hasIncoming && ! is_string($meta['file'] ?? null)) {
|
||||
return 'Datei wird übernommen';
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $portrait
|
||||
* @param list<array<string, mixed>> $uses
|
||||
* @param array<string, string> $filters
|
||||
* @param array<int, list<int>> $classified
|
||||
*/
|
||||
private function matches(ContentElement $element, array $portrait, array $uses, array $filters, string $needle, array $classified): bool
|
||||
{
|
||||
if ($needle !== '' && ! str_contains($this->haystack($element), $needle)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $this->matchesArt($element, $filters['art'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$onlyBlocked = $portrait['ready'] === null && $portrait['draft'] === null && $portrait['blocked'] !== null;
|
||||
|
||||
if ($onlyBlocked && $filters['fassung'] === '' && $filters['archiv'] === 'aktiv') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['archiv'] === 'aktiv' && $portrait['archived']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['archiv'] === 'archiviert' && ! $portrait['archived']) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['freigabe'] === 'freigegeben' && $portrait['ready'] === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['freigabe'] === 'entwurf' && ($portrait['draft'] === null || $portrait['ready'] !== null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['freigabe'] === 'ohne' && $portrait['ready'] !== null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['entwurf'] === 'offen' && $portrait['draft'] === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['entwurf'] === 'keiner' && $portrait['draft'] !== null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['fassung'] === 'mit' && $portrait['blocked'] === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['fassung'] === 'nur' && ($portrait['blocked'] === null || $portrait['ready'] !== null || $portrait['draft'] !== null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$used = $this->usageCount($uses) > 0;
|
||||
|
||||
if ($filters['nutzung'] === 'verwendet' && ! $used) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['nutzung'] === 'unbenutzt' && $used) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['saeule'] !== '' && ! $element->pillars->contains('id', (int) $filters['saeule'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['einordnung'] !== '' && ! in_array((int) $filters['einordnung'], $classified[$element->id] ?? [], true)) {
|
||||
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;
|
||||
}
|
||||
|
||||
if ($filters['verarbeitung'] === 'uebernahme' && $portrait['processing'] !== 'Datei wird übernommen') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function matchesArt(ContentElement $element, string $art): bool
|
||||
{
|
||||
if ($art === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
$class = (string) $element->output_class;
|
||||
|
||||
if ($art === 'document') {
|
||||
return in_array($class, ['document', 'pdf'], true);
|
||||
}
|
||||
|
||||
return $class === $art;
|
||||
}
|
||||
|
||||
private function haystack(ContentElement $element): string
|
||||
{
|
||||
return mb_strtolower(implode("\n", array_filter([
|
||||
$element->working_title,
|
||||
$element->display_title,
|
||||
$element->description,
|
||||
$element->summary,
|
||||
$element->teaser,
|
||||
$element->search_terms,
|
||||
$element->usage_note,
|
||||
], fn (mixed $value): bool => is_string($value) && trim($value) !== '')));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $portrait
|
||||
* @param list<array<string, mixed>> $uses
|
||||
* @param list<string> $codes
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function card(ContentElement $element, array $portrait, array $uses, array $codes, bool $canEdit): array
|
||||
{
|
||||
$description = trim((string) ($element->description ?: $element->summary ?: ''));
|
||||
$usageNote = trim((string) $element->usage_note);
|
||||
$licenseNote = trim((string) $element->license_note);
|
||||
$typeKey = $this->typeKey((string) $element->output_class);
|
||||
$count = $this->usageCount($uses);
|
||||
|
||||
return [
|
||||
'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,
|
||||
'licenseNote' => $licenseNote === '' ? null : $licenseNote,
|
||||
'image' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
||||
'imageAlt' => trim((string) ($element->thumbnail_alt ?: $element->working_title)),
|
||||
'imageNote' => $this->imageNote($element),
|
||||
'stand' => $portrait['stand'],
|
||||
'standTone' => $portrait['standTone'],
|
||||
'draftNote' => $portrait['draftNote'],
|
||||
'blockedNote' => $portrait['blockedNote'],
|
||||
'processing' => $portrait['processing'],
|
||||
'archived' => $portrait['archived'],
|
||||
'versionCount' => $portrait['versionCount'],
|
||||
'versionLabel' => $this->versionCountLabel($portrait['versionCount']),
|
||||
'usageCount' => $count,
|
||||
'usageLabel' => $count === 0
|
||||
? 'In keinem Modul oder Programm verwendet'
|
||||
: ($count === 1 ? '1 Verwendung' : $count.' Verwendungen'),
|
||||
'usages' => $uses,
|
||||
'licenseText' => $this->licenseText($codes),
|
||||
'url' => ContentElementResource::getUrl('view', ['record' => $element]),
|
||||
'editUrl' => $canEdit ? ContentElementResource::getUrl('edit', ['record' => $element]) : null,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $uses
|
||||
*/
|
||||
private function usageCount(array $uses): int
|
||||
{
|
||||
return count(array_unique(array_column($uses, 'compositionId')));
|
||||
}
|
||||
|
||||
private function versionCountLabel(int $count): ?string
|
||||
{
|
||||
return match ($count) {
|
||||
0 => null,
|
||||
1 => '1 Fassung',
|
||||
default => $count.' Fassungen',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<string> $codes
|
||||
*/
|
||||
private function licenseText(array $codes): ?string
|
||||
{
|
||||
if ($codes === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$named = count($codes) === 1
|
||||
? 'Im Lizenzartikel '.$codes[0].' genannt.'
|
||||
: 'In den Lizenzartikeln '.implode(', ', $codes).' genannt.';
|
||||
|
||||
return $named.' Das belegt keinen Zugriff in der Bibliothek.';
|
||||
}
|
||||
|
||||
private function imageNote(ContentElement $element): ?string
|
||||
{
|
||||
if (is_string($element->thumbnail_error) && trim($element->thumbnail_error) !== '') {
|
||||
return Str::limit(trim($element->thumbnail_error), 180);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function typeKey(string $outputClass): string
|
||||
{
|
||||
return match ($outputClass) {
|
||||
'film' => 'film',
|
||||
'audio' => 'audio',
|
||||
'bild' => 'bild',
|
||||
'document', 'pdf' => 'document',
|
||||
default => 'text',
|
||||
};
|
||||
}
|
||||
|
||||
private function kindLabel(Composition $composition): string
|
||||
{
|
||||
$kind = $composition->kind;
|
||||
|
||||
return ($kind instanceof CompositionKind ? $kind : CompositionKind::from((string) $kind))->deskLabel();
|
||||
}
|
||||
|
||||
private function versionLabel(ContentElementVersion $version): string
|
||||
{
|
||||
return match ($version->status) {
|
||||
ContentVersionStatus::Entwurf => 'Entwurf',
|
||||
ContentVersionStatus::Gesperrt => 'Fassung '.$version->number.', deaktiviert',
|
||||
default => 'Fassung '.$version->number,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,9 @@
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\IdentityProfile;
|
||||
use App\Domain\Media\PresentationFile;
|
||||
use App\Jobs\DeriveThumbnail;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
@@ -39,6 +41,10 @@ public static function fields(bool $creating, ?ContentElement $element = null):
|
||||
$fields[] = self::fileField()
|
||||
->visible(fn ($get): bool => filled($get('shape')) && $get('shape') !== 'text')
|
||||
->required(fn ($get): bool => filled($get('shape')) && $get('shape') !== 'text');
|
||||
$fields[] = Checkbox::make('without_version')
|
||||
->label('Eigenständiges Präsentationsmedium')
|
||||
->helperText('Bild, Film oder Hörstück ohne fachliche Inhaltsfassung. Die Datei bleibt eine technische Ableitung am Medium. Sie wird nicht lizenziert und nicht automatisch für die Website freigegeben.')
|
||||
->visible(fn ($get): bool => in_array($get('shape'), ['film', 'audio', 'bild'], true));
|
||||
} elseif ($element?->output_class === 'text') {
|
||||
$fields[] = Textarea::make('body')->label('Text')->rows(8)->required();
|
||||
}
|
||||
@@ -120,13 +126,17 @@ public static function create(array $data, bool $hold): ContentElement
|
||||
throw new DomainRuleException('Diese Datei passt nicht zur gewählten Art.');
|
||||
}
|
||||
|
||||
$metadata = ['incoming' => $incoming];
|
||||
|
||||
if ($hold) {
|
||||
$metadata['hold'] = true;
|
||||
$service->draftElementVersion($element, null, $metadata);
|
||||
if (! empty($data['without_version']) && in_array($output, ['bild', 'film', 'audio'], true)) {
|
||||
app(PresentationFile::class)->store($element, $incoming);
|
||||
} else {
|
||||
$service->publishElementVersion($element, null, $metadata);
|
||||
$metadata = ['incoming' => $incoming];
|
||||
|
||||
if ($hold) {
|
||||
$metadata['hold'] = true;
|
||||
$service->draftElementVersion($element, null, $metadata);
|
||||
} else {
|
||||
$service->publishElementVersion($element, null, $metadata);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
use App\Domain\Cms\Sections\PageSections;
|
||||
use App\Domain\Cms\Sections\SectionLayouts;
|
||||
use App\Domain\Cms\Sections\SectionStyle;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
@@ -20,7 +19,6 @@
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
|
||||
/**
|
||||
* Seiteneditor für Abschnitte und Slots.
|
||||
@@ -166,25 +164,10 @@ private static function styleFields(): array
|
||||
->options(SectionStyle::DIVIDERS)
|
||||
->default('none')
|
||||
->selectablePlaceholder(false),
|
||||
Select::make('image')
|
||||
->label('Hintergrundbild: vorhandenes Bild')
|
||||
->options(fn (): array => PublicMedia::imageOptions())
|
||||
->searchable()
|
||||
->placeholder('Bitte wählen')
|
||||
->helperText('Nur Bilder aus dem öffentlichen Website-Bereich. Geschützte Filmbilder sind hier nicht wählbar.')
|
||||
->visible(fn (Get $get): bool => $get('background') === 'image')
|
||||
->columnSpan(['default' => 1, 'md' => 2]),
|
||||
FileUpload::make('_upload')
|
||||
->label('Hintergrundbild: neu hochladen')
|
||||
->disk('cms_incoming')
|
||||
->directory('cms')
|
||||
->image()
|
||||
->maxSize(8192)
|
||||
->acceptedFileTypes(['image/jpeg', 'image/png', 'image/webp'])
|
||||
->getUploadedFileNameForStorageUsing(fn (TemporaryUploadedFile $file): string => Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)).'-'.Str::lower(Str::random(6)).'.'.$file->guessExtension())
|
||||
->helperText('Ersetzt die Auswahl links. Nur Bilder mit geklärter Veröffentlichungsfreigabe hochladen.')
|
||||
->visible(fn (Get $get): bool => $get('background') === 'image')
|
||||
->columnSpan(['default' => 1, 'md' => 2]),
|
||||
...array_map(
|
||||
fn ($field) => $field->visible(fn (Get $get): bool => $get('background') === 'image')->columnSpan(['default' => 1, 'md' => 2]),
|
||||
ImageRefFields::fields('Hintergrundbild'),
|
||||
),
|
||||
Select::make('focus')
|
||||
->label('Bildausschnitt (Fokuspunkt)')
|
||||
->options(SectionStyle::FOCUS)
|
||||
|
||||
@@ -2,15 +2,21 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Domain\Media\WebsiteMediaAlias;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class PublicMediaController extends Controller
|
||||
{
|
||||
public function show(string $path): StreamedResponse
|
||||
public function show(string $path, WebsiteMedia $media): StreamedResponse
|
||||
{
|
||||
abort_if(str_contains($path, '..') || ! str_starts_with($path, 'cms/'), 404);
|
||||
|
||||
// Ein in den Medienmanager übernommenes Bild folgt dessen Website-Freigabe, auch unter der früheren Adresse.
|
||||
$alias = WebsiteMediaAlias::effectiveFor($path);
|
||||
abort_if($alias !== null && $media->present($alias->content_element_id) === null, 404);
|
||||
|
||||
foreach (['media_public', 'cms_incoming'] as $disk) {
|
||||
if (Storage::disk($disk)->exists($path)) {
|
||||
return Storage::disk($disk)->response($path);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class WebsiteMediaController extends Controller
|
||||
{
|
||||
public function show(ContentElement $element, WebsiteMedia $media): StreamedResponse
|
||||
{
|
||||
$presentation = $media->present($element);
|
||||
abort_if($presentation === null, 404);
|
||||
|
||||
$path = $element->website_public_path;
|
||||
abort_if(! is_string($path), 404);
|
||||
|
||||
return Storage::disk('media_public')->response($path, null, [
|
||||
'Content-Disposition' => 'inline',
|
||||
'X-Content-Type-Options' => 'nosniff',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Media\ThumbnailDeriver;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class AcceptWebsiteImage implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public int $elementId,
|
||||
public string $incoming,
|
||||
public ?int $actorId = null,
|
||||
) {}
|
||||
|
||||
public function handle(ThumbnailDeriver $deriver, WebsiteRelease $release): void
|
||||
{
|
||||
$element = ContentElement::query()->find($this->elementId);
|
||||
|
||||
if (! $element instanceof ContentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
$deriver->forWebsiteImage($element, $this->incoming);
|
||||
$element->refresh();
|
||||
|
||||
if ($release->derivedPath($element) === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->incomingIsDisposable()) {
|
||||
Storage::disk('cms_incoming')->delete($this->incoming);
|
||||
}
|
||||
|
||||
PublishWebsiteMedia::dispatch($element->id, 'release', $this->actorId);
|
||||
}
|
||||
|
||||
private function incomingIsDisposable(): bool
|
||||
{
|
||||
return (str_starts_with($this->incoming, 'cms/') || str_starts_with($this->incoming, 'vorschau/'))
|
||||
&& ! str_contains($this->incoming, '..');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Domain\Media\WebsiteIntake;
|
||||
use App\Domain\Media\WebsiteMediaAlias;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Übernimmt die bisherigen CMS-Bilder (media_public, cms/…) in den Medienmanager.
|
||||
*
|
||||
* - Bytegleiche Dateien werden ein Medium (SHA-256); jeder frühere Pfad erhält eine Zuordnung (WebsiteMediaAlias).
|
||||
* - Neue Medien entstehen über WebsiteIntake: Die Warteschlange leitet das Bild ab und gibt genau diese Ableitung
|
||||
* für die Website frei. Erst danach wird die Zuordnung wirksam; bis dahin bleibt der frühere Pfad gültig.
|
||||
* - Wiederholbar: Bereits zugeordnete Pfade werden übersprungen. Es wird nichts gelöscht; die Dateien unter cms/
|
||||
* bleiben liegen (frühere Revisionen, Rückweg).
|
||||
*/
|
||||
class ImportCmsImages implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
private const EXTENSIONS = ['jpg', 'jpeg', 'png', 'webp', 'gif'];
|
||||
|
||||
public function handle(WebsiteIntake $intake): void
|
||||
{
|
||||
$public = Storage::disk('media_public');
|
||||
|
||||
try {
|
||||
$files = $public->allFiles('cms');
|
||||
} catch (Throwable) {
|
||||
return;
|
||||
}
|
||||
|
||||
sort($files);
|
||||
|
||||
foreach ($files as $path) {
|
||||
if (! $this->isImage($path) || WebsiteMediaAlias::query()->where('legacy_path', $path)->exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$bytes = $public->get($path);
|
||||
|
||||
if (! is_string($bytes) || $bytes === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$hash = hash('sha256', $bytes);
|
||||
$twin = WebsiteMediaAlias::query()->where('sha256', $hash)->first();
|
||||
|
||||
if ($twin instanceof WebsiteMediaAlias) {
|
||||
WebsiteMediaAlias::query()->create(['legacy_path' => $path, 'content_element_id' => $twin->content_element_id, 'sha256' => $hash]);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
Storage::disk('cms_incoming')->put($path, $bytes);
|
||||
$element = $intake->acceptImage($path, self::titleFor($path));
|
||||
WebsiteMediaAlias::query()->create(['legacy_path' => $path, 'content_element_id' => $element->id, 'sha256' => $hash]);
|
||||
}
|
||||
}
|
||||
|
||||
/** „cms/platzhalter-karte-1-liyjqa.jpg“ → „Platzhalter Karte 1“ (ohne die angehängte Zufallskennung). */
|
||||
public static function titleFor(string $path): string
|
||||
{
|
||||
$name = pathinfo($path, PATHINFO_FILENAME);
|
||||
$name = preg_replace('/-[a-z0-9]{6}$/', '', $name) ?? $name;
|
||||
$title = trim(str_replace(['-', '_'], ' ', $name));
|
||||
|
||||
return $title === '' ? 'Website-Bild' : Str::title($title);
|
||||
}
|
||||
|
||||
private function isImage(string $path): bool
|
||||
{
|
||||
return str_starts_with($path, 'cms/')
|
||||
&& ! str_contains($path, '..')
|
||||
&& preg_match('#^cms/[A-Za-z0-9._\-/]+$#', $path) === 1
|
||||
&& in_array(strtolower(pathinfo($path, PATHINFO_EXTENSION)), self::EXTENSIONS, true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\IdentityChange;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class PublishWebsiteMedia implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public int $elementId,
|
||||
public string $action,
|
||||
public ?int $actorId = null,
|
||||
) {}
|
||||
|
||||
public function handle(WebsiteRelease $release): void
|
||||
{
|
||||
$element = ContentElement::query()->find($this->elementId);
|
||||
|
||||
if (! $element instanceof ContentElement || ! in_array($this->action, ['release', 'withdraw'], true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->action === 'withdraw') {
|
||||
$this->deletePublicFile($element);
|
||||
$this->mark($element, $element->website_released_at?->toIso8601String(), null);
|
||||
$element->forceFill([
|
||||
'website_released_at' => null,
|
||||
'website_public_path' => null,
|
||||
])->save();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$derived = $release->derivedPath($element);
|
||||
|
||||
if ($derived === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$target = $release->publicPath($element, $derived);
|
||||
$previous = $element->website_public_path;
|
||||
|
||||
Storage::disk('media_public')->put($target, Storage::disk('media_derived')->get($derived));
|
||||
|
||||
if (is_string($previous) && $previous !== $target && str_starts_with($previous, 'website/'.$element->id.'/')) {
|
||||
Storage::disk('media_public')->delete($previous);
|
||||
}
|
||||
|
||||
$this->mark($element, $element->website_released_at?->toIso8601String(), now()->toIso8601String());
|
||||
$element->forceFill([
|
||||
'website_released_at' => now(),
|
||||
'website_public_path' => $target,
|
||||
])->save();
|
||||
}
|
||||
|
||||
private function deletePublicFile(ContentElement $element): void
|
||||
{
|
||||
$path = $element->website_public_path;
|
||||
|
||||
if (! is_string($path) || ! str_starts_with($path, 'website/'.$element->id.'/') || str_contains($path, '..')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Storage::disk('media_public')->delete($path);
|
||||
}
|
||||
|
||||
private function mark(ContentElement $element, ?string $before, ?string $after): void
|
||||
{
|
||||
if ($before === $after) {
|
||||
return;
|
||||
}
|
||||
|
||||
IdentityChange::query()->create([
|
||||
'subject_type' => $element->getMorphClass(),
|
||||
'subject_id' => $element->id,
|
||||
'field' => 'website_released_at',
|
||||
'before' => $before,
|
||||
'after' => $after,
|
||||
'actor_id' => $this->actorId,
|
||||
'occurred_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
use App\Domain\Cms\NavigationItemPolicy;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PagePolicy;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use App\Domain\Media\FfmpegFilmTranscoder;
|
||||
use App\Domain\Media\FilmTranscoder;
|
||||
@@ -26,6 +27,7 @@ public function register(): void
|
||||
$this->app->bind(FilmTranscoder::class, FfmpegFilmTranscoder::class);
|
||||
// Je Anfrage einmal den Index der öffentlich genannten Medien bilden, nicht je Karte.
|
||||
$this->app->scoped(PublicMaterialReader::class);
|
||||
$this->app->scoped(WebsiteImage::class);
|
||||
$this->app->singleton(WidgetRegistry::class, fn ($app): WidgetRegistry => new WidgetRegistry(
|
||||
array_map(fn (string $class) => $app->make($class), config('cms.widgets', [])),
|
||||
));
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('content_elements', function (Blueprint $table) {
|
||||
$table->text('website_credit')->nullable()->after('license_note');
|
||||
$table->string('website_alt')->nullable()->after('website_credit');
|
||||
$table->timestamp('website_released_at')->nullable()->after('website_alt');
|
||||
$table->string('website_public_path')->nullable()->after('website_released_at');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('content_elements', function (Blueprint $table) {
|
||||
$table->dropColumn([
|
||||
'website_credit',
|
||||
'website_alt',
|
||||
'website_released_at',
|
||||
'website_public_path',
|
||||
]);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Zuordnung früherer CMS-Bildpfade (cms/…) zu Medien im Medienmanager. Additiv: Gespeicherte Revisionen und
|
||||
* die Dateien unter cms/ bleiben unverändert; die Zuordnung wird beim Darstellen gelesen.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('website_media_aliases', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('legacy_path')->unique();
|
||||
$table->foreignId('content_element_id')->constrained()->restrictOnDelete();
|
||||
$table->string('sha256', 64)->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('website_media_aliases');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use App\Jobs\ImportCmsImages;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
/**
|
||||
* Übernimmt die bisherigen CMS-Bilder (media_public, cms/…) in den Medienmanager. Die Migration läuft im
|
||||
* App-Container, der keine Medien schreibt; sie stößt deshalb nur den Job der Hintergrundverarbeitung an.
|
||||
* Der Job ist wiederholbar und löscht nichts.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
// In Tests liegen echte Medien nicht vor; die Übernahme prüfen eigene Tests mit Testplatten.
|
||||
if (app()->runningUnitTests()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImportCmsImages::dispatch();
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Nichts zurückzunehmen: Die übernommenen Medien und Zuordnungen bleiben; die Tabelle entfernt die vorige Migration.
|
||||
}
|
||||
};
|
||||
@@ -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();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('content_elements', function (Blueprint $table) {
|
||||
$table->string('preview_path')->nullable()->after('thumbnail_error');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('content_elements', function (Blueprint $table) {
|
||||
$table->dropColumn('preview_path');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
# Einheitliche Medienverwaltung im CMS – Bericht
|
||||
|
||||
Branch `feature/cms-medienverwaltung`, Commits `7c63424` (Website-Ableitung) und `053a8d4` (Umstellung). Gearbeitet wurde in einem separaten Worktree, der Deploy lief über `develop` (CI 4859, Deploy 4860). Kein Merge nach `main`.
|
||||
|
||||
- Entscheidung: ADR-40.
|
||||
- Technik: `docs/architektur/medienzugriff-fuer-komponenten.md`, Abschnitt „Umsetzung im CMS“, und `cms-widget-registry.md` §§ 7 und 9.
|
||||
|
||||
## 1. Ergebnis
|
||||
|
||||
**Bildstellen:**
|
||||
- Alle Bildstellen des CMS verwenden den zentralen Medienbestand: Einstieg (Hero), Bild und Text, redaktionelle Karten, Premium-Karten (Kartenbild) und Abschnittshintergrund.
|
||||
- Gespeichert wird die Kennung des Mediums, nicht ein Pfad.
|
||||
- Öffentlich erscheint ein Bild nur mit Website-Freigabe (`WebsiteMedia`, Route `website.media`).
|
||||
- Die CMS-eigene Bildauswahl entfällt.
|
||||
|
||||
**Im Widget-Dialog** (Reiter „Medien“, beim Abschnitt „Gestaltung“):
|
||||
|
||||
| Funktion | Verhalten |
|
||||
|---|---|
|
||||
| Auswahl | Alle Bilder des Medienmanagers, durchsuchbar, mit Vorschaubild, Titel und Website-Status (freigegeben, nicht freigegeben, wird verarbeitet) |
|
||||
| Neues Bild hochladen | Das Bild wird sofort im Medienmanager angelegt (`WebsiteIntake`) und ausgewählt. Nach der Verarbeitung gibt die Warteschlange es automatisch für die Website frei. |
|
||||
| Gewähltes Bild | Vorschaubild, Status mit Begründung und „Im Medienmanager öffnen“ (dort steht die Website-Freigabe) |
|
||||
| Austauschen | Ein anderes Bild in der Auswahl wählen; Bildausschnitt und Darstellung bleiben im Widget |
|
||||
| Alternativtext | Kommt aus dem Medium. Das Feld im Widget ist eine optionale Abweichung. |
|
||||
|
||||
**Medienmanager:** Die Medienansicht nennt jetzt die Website-Seiten, die das Bild verwenden. Beim Zurücknehmen der Freigabe weist sie darauf hin, dass das Bild dort verschwindet.
|
||||
|
||||
**Nicht freigegeben:** Öffentlich entfällt nur das Bild; Überschrift, Text und Schaltflächen des Widgets bleiben. Die Redaktionsvorschau zeigt das Vorschaubild mit dem Hinweis, warum es öffentlich nicht erscheint und wo die Freigabe steht.
|
||||
|
||||
**Website-Ableitung:** Bilder werden bis 2400 px breit abgeleitet statt in 640 px Vorschaugröße und nie vergrößert. Transparente Flächen werden weiß. Filmstandbilder bleiben bei 640 px. Diese Änderung betrifft Lars' `ThumbnailDeriver` und liegt deshalb in einem eigenen Commit.
|
||||
|
||||
## 2. Übernahme der Bestandsmedien (Testinstanz)
|
||||
|
||||
Der Job `ImportCmsImages` wurde beim Deploy von einer Migration angestoßen und von der Warteschlange ausgeführt. Ergebnis, lesend geprüft:
|
||||
|
||||
- **21 frühere Bilddateien** unter `cms/`, bytegleich zusammengefasst zu **9 Medien**: Felix und die Einkäufe (Intro), Lara Felix Park (Original), Platzhalter Bild Text, Platzhalter Karte 1, 2 und 3, Platzhalter Markenbühne, Prüfbild, Testplatzhalter Hintergrund.
|
||||
- Alle 9 Medien sind abgeleitet und freigegeben. Es gibt keine offenen und keine fehlgeschlagenen Jobs.
|
||||
- Gelöscht wurde nichts. Die Dateien unter `cms/` und alle Revisionen bleiben unverändert.
|
||||
- Frühere Pfade gelten über `website_media_aliases` als das jeweilige Medium. Beim nächsten Speichern wird die Kennung eingetragen.
|
||||
|
||||
## 3. Prüfung
|
||||
|
||||
| Prüfung | Ergebnis |
|
||||
|---|---|
|
||||
| Testsuite | 245 grün, davon neu: 8 Tests für die Medienanbindung und 2 für die Ableitungsgröße. Bewusst geändert: Die Alt-Text-Pflicht im Widget entfällt, weil der Alternativtext zum Medium gehört. |
|
||||
| Bestehende Seiten vor und nach Deploy und Übernahme | Geometrie unverändert (16 Messungen: 8 Seiten bei 1440 und 390 px), Texte unverändert (12 Seiten). Alle 16 Bilder auf 5 Seiten kommen jetzt über `/website-medien/`, sind geladen und haben dieselben Maße und Alternativtexte (zuvor `/medien/cms/`). Frühere Revisionen werden damit korrekt dargestellt. |
|
||||
| Browser auf der Testinstanz, Redaktionsablauf (13 von 13) | siehe Liste darunter |
|
||||
| Browser auf der Testinstanz, Freigabe zurücknehmen (8 von 8) | siehe Liste darunter |
|
||||
| Slideshow | Im CMS gibt es keine Slideshow. Neue Widget-Arten waren nicht Teil des Auftrags. `WebsiteMedia::presentMany` ist vorbereitet, aber noch unbenutzt. |
|
||||
|
||||
**Redaktionsablauf, Prüfkonto, regulärer Seitenkonfigurator, Entwurfsseite, nichts veröffentlicht:**
|
||||
- Vorhandenes Bild aus dem Medienmanager im Einstieg gewählt; Picker und Statusanzeige mit Vorschaubild und Verweis.
|
||||
- Übernommene Platzhaltergrafik („Platzhalter Markenbühne“) durch „Platzhalter Bild Text“ ersetzt.
|
||||
- Neues Bild direkt im Dialog hochgeladen: Es war sofort ausgewählt, zuerst mit „Wird gerade verarbeitet“, danach freigegeben. Im Medienmanager per Suche auffindbar; dessen Ansicht nennt die verwendende Seite.
|
||||
- Dasselbe Medium in Einstieg und Karte verwendet.
|
||||
- Gespeichert, wieder geöffnet, Vorschau: alle Bilder über `/website-medien/`, geladen, 1200 bis 1600 px breit.
|
||||
|
||||
**Freigabe zurücknehmen, auf `/premium-referenz`, danach wiederhergestellt:**
|
||||
- Die Medienansicht nennt die Seite.
|
||||
- Nach dem Zurücknehmen fehlt das Bild öffentlich; die übrigen 6 Bilder bleiben.
|
||||
- `/website-medien/15` und die frühere Adresse `/medien/cms/…` liefern 404.
|
||||
- Nach der erneuten Freigabe ist der Ausgangszustand wieder da; Geometrie und Bilder entsprechen dem Stand vorher.
|
||||
|
||||
**Auf der Testinstanz neu angelegt:**
|
||||
- das Medium „Platzhalter Upload Medienpruefung“ (gekennzeichneter Platzhalter),
|
||||
- die Entwurfsseite `/medien-pruefung-entwurf`.
|
||||
|
||||
Beides lässt sich über den Medienmanager bzw. die Seitenverwaltung entfernen.
|
||||
|
||||
## 4. Offene Punkte für Lars
|
||||
|
||||
1. **Bild entfällt oder Widget entfällt?** Entschieden am 19.11.2026: Das Medium wird nicht öffentlich ausgeliefert. Texte und übrige Widget-Inhalte bleiben. Ein Widget ohne verbleibenden Inhalt entfällt. Siehe ADR-40.
|
||||
2. **Bildschlüssel:** Gespeichert wird im bisherigen Schlüssel `image` (`refs.image`, `style.image`, `data.items[].image`), nicht in `refs.element`. Grund: Die Medienkarte nutzt `refs.element` für ihr Fachobjekt. Das Dokument ist entsprechend ergänzt.
|
||||
3. **Originalmotiv freigegeben:** „Lara Felix Park Original“ (`cms/lara-felix-park-original-…png`) lag bereits öffentlich unter `cms/` und ist durch die Übernahme ein freigegebenes Medium. Ist die Veröffentlichung nicht geklärt, im Medienmanager zurücknehmen; `/premium-referenz` zeigt es dann nicht mehr.
|
||||
4. **Titel und Quellenzeilen der übernommenen Medien** kommen aus den Dateinamen, ohne Quellenzeile, zum Beispiel „Platzhalter Markenbuehne“ ohne Umlaut. Beides lässt sich im Medienmanager pflegen.
|
||||
5. **Rollback:** Eine Code-Fassung vor der Umstellung zeigt Bilder nicht, die danach gespeichert wurden (Kennung statt Pfad). Texte bleiben, die Dateien unter `cms/` bleiben (Registry §9).
|
||||
6. **Bedienmuster:** Die Bildauswahl des Modul- und Programmeditors ist an dessen Seite gebunden und ließ sich nicht als Formularfeld wiederverwenden. Das Bedienmuster (Suche, Vorschaubild, Auswahl) ist übernommen, die Abfrage greift auf denselben Bestand zu.
|
||||
@@ -83,3 +83,88 @@ ## 4. Abweichungen vom Kit
|
||||
- Schriftgewicht 600 statt 750, weil nur vorhandene Schnitte verwendet werden.
|
||||
- Bildhöhe höchstens min(70vh, 640 px).
|
||||
- Karten, die nur in der Vorschau erscheinen, mit gestricheltem Rand.
|
||||
|
||||
## 5. Fachliche Nachbesserung nach der Betreiberprüfung (18.11.2026)
|
||||
|
||||
Branch `feature/premium-karten-nachbesserung`, separater Worktree, Deploy nur über `develop`. Keine neue Widget-Art, keine neuen Fachobjekte, keine Migration, keine Änderung an Lizenz- oder Kaufrechten.
|
||||
|
||||
**Ursache „keine Themen“.** Die Themenkarte bot nur veröffentlichte Säulen an. Auf der Testinstanz gibt es fünf Säulen (lesende Abfrage am 18.11.2026), keine ist veröffentlicht, keine hat eine öffentliche Adresse oder einen Text für die Website. Jetzt sind alle Säulen wählbar; öffentlich gilt unverändert die Regel der Themenseiten (veröffentlicht und mit Adresse).
|
||||
|
||||
**Datenstand der Testinstanz (lesend geprüft):**
|
||||
- 5 Säulen, unveröffentlicht, ohne Website-Text; Säule 1 hat ein zugeordnetes Medium, Säule 2 eine veröffentlichte Seite.
|
||||
- Film „Lara im Park“: bereitgestellte Fassung, Filmstandbild (aus dem Film bei 41,5 s), Beschreibung vorhanden, **keine Kurzbeschreibung und kein Anzeigetitel**; Bestandteil von „Programm Abstand“ (über Modul Abstand) und der UX-Prüfung, beide öffentlich.
|
||||
- Zwei weitere Filme nur als Entwurf; Textmaterialien ohne Inhaltsart; eine gesperrte Traineranleitung.
|
||||
- Module mit Lernziel, Dauer und Materialhinweis; zwei Module mit Vorschaubild; keine Kurzbeschreibungen außer einem Entwurfsmodul.
|
||||
- Keine Laufzeiten in den Mediendaten (Metadaten nur `file`, `held`).
|
||||
|
||||
### Themenkarte
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Verfügbare Fachdaten | Name, öffentliche Adresse, Text für die Website, Veröffentlichung, zugeordnete Seiten und Medien |
|
||||
| Dargestellt | Name, Text für die Website, „N Seiten zum Thema“ (veröffentlichte Seiten), Aktion auf `/themen/{slug}` |
|
||||
| Redaktion | alle Säulen wählbar, mit Status „veröffentlicht“ / „nicht veröffentlicht, nur Redaktionsvorschau“; Vorschau mit Hinweisen auf fehlenden Text und fehlendes Kartenbild |
|
||||
| Fehlt | auf der Testinstanz: Veröffentlichung, Adresse und Text aller Säulen (Pflege unter „Fachliche Säulen“) |
|
||||
| Bewusst | kein Themenbild aus Medien des Themas (geschützt); Bild nur als Kartenbild aus dem öffentlichen Website-Bereich |
|
||||
|
||||
### Medien- und Materialkarte
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Verfügbare Fachdaten | Arbeits- und Anzeigetitel, Kurzbeschreibung, Beschreibung, Einsatzhinweis, Lizenzvermerk, Inhaltsart, Ausgabeart, Fassungsstatus, Vorschaubild (Filmstandbild, geschützt), Programmzugehörigkeit |
|
||||
| Dargestellt | **Film:** Titel, Kurzbeschreibung, Inhalts- und Ausgabeart, „Im Programm …“, „Vollständiger Film nur mit Lizenz im Mitgliederbereich“, Filmtafel; Aktion auf die öffentliche Programmseite. **Material:** eigene Darstellung mit Materialsymbol, Titel, Kurzbeschreibung, Art. **Vorschau:** Filmstandbild der Bibliothek mit Marke „Bibliotheksbild · nur Vorschau“ |
|
||||
| Unterschieden | öffentliche Filmvorschau: **gibt es fachlich noch nicht** (keine eigene Ausgabe, keine Freigabe); geschützter vollständiger Film: nie über die Karte, nur Hinweis; Film ohne freigegebenes Vorschaumaterial: öffentlich Filmtafel oder redaktionelles Kartenbild |
|
||||
| Redaktion | Filme und Materialien mit Entwurfs- oder bereitgestellter Fassung wählbar (gesperrte nicht), Sichtbarkeit in der Auswahl; Hinweise auf fehlende Kurzbeschreibung, Anzeigetitel, freigegebenes Bild |
|
||||
| Fehlt | Kurzbeschreibungen und Anzeigetitel in den Medien; Laufzeit in den Mediendaten; Freigabe von Vorschaubildern für die Website; öffentliche Filmvorschau (Erweiterungsbedarf: `cms-widget-registry.md` §13) |
|
||||
| Bewusst | Traineranleitungen nie öffentlich; nie öffentlich: Beschreibung, Einsatzhinweis, Lizenzvermerk, Dateien; kein Abspielen, kein Download |
|
||||
|
||||
### Programm- und Modulkarte
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Verfügbare Fachdaten | Bezeichnung, Anzeigetitel, Kurzbeschreibung, Inhaltsart, Fassungen mit Lernziel, Dauer, Materialhinweis, Anzeigefreigabe, Vorschaubild (geschützt), Bestandteile |
|
||||
| Dargestellt | Titel, Kurzbeschreibung (sonst Lernziel; auf der Programmseite bereits öffentlich), Art „Programm“/„Modul“, Zahl der Module, Dauer, Navy-Tafel; Aktion nur für Programme mit Anzeigefreigabe; Vorschau: Vorschaubild der Bibliothek, markiert |
|
||||
| Redaktion | Programme und Module mit bereitgestellter Fassung wählbar, auch ohne Anzeigefreigabe (nur Vorschau); Hinweise auf fehlende Kurzbeschreibung und Dauer |
|
||||
| Fehlt | Kurzbeschreibungen; öffentliche Modulseite (ADR-29, nicht Teil dieses Auftrags); Freigabe von Vorschaubildern |
|
||||
| Bewusst | kein künstlicher Link für Module; kein Materialhinweis öffentlich; kein Preis, keine Kaufaktion |
|
||||
|
||||
### Prüfungen der Nachbesserung
|
||||
|
||||
| Prüfung | Ergebnis |
|
||||
|---|---|
|
||||
| Testsuite | 214 grün (Kartentests 10, davon neu: Entwurf/ohne Freigabe nur in der Vorschau, unveröffentlichte Themen; erweitert: Film/Material, Traineranleitung, keine internen Felder, Bibliotheksbild nur in der Vorschau) |
|
||||
| Lokaler Redaktionsablauf mit nachgebildetem Datenstand der Testinstanz | 32 von 32: vorhandene Säule, Film, Material, Modul, Programm in 1 + 1 + 2, 2 + 2, 4/4, 1 + 1 + 1 + 1; speichern, wieder öffnen, bearbeiten, speichern; Vorschau bei 1440/1024/768/390 px (alle Karten mindestens 240 px, kein Überlauf, gleiche Höhe je Zeile); Entwurfsseite öffentlich nicht erreichbar. **Gilt nicht als Abnahme auf der Testinstanz.** |
|
||||
| Redaktionsablauf auf der Testinstanz (Prüfkonto, regulärer Seitenkonfigurator) | **32 von 32.** Die Auswahl bietet alle fünf Säulen und alle Filme und Materialien mit Sichtbarkeit an. Gewählt wurden „Meine Grenzen“, „Lara im Park“, ein Textmaterial, die Module „Freigabe mit Anleitung“ und „Modul Abstand“ sowie „Programm Abstand“, verteilt auf 1 + 1 + 2, 2 + 2, 4/4 und 1 + 1 + 1 + 1. Danach: Entwurf angelegt, wieder geöffnet, bearbeitet, gespeichert. Vorschau bei 1440/1024/768/390 px: alle 10 Karten, mindestens 240 px breit, kein Überlauf, gleiche Höhe je Zeile. Das Filmstandbild erscheint nur in der Vorschau, markiert. Die Entwurfsseite `/karten-nachbesserung-entwurf` (Seite 19) ist öffentlich nicht erreichbar (404). Es wurde nichts veröffentlicht. |
|
||||
|
||||
### Was die Karten mit den heutigen Daten der Testinstanz zeigen
|
||||
|
||||
- **Programmkarte „Programm Abstand“** (öffentlich): Titel, Lernziel als Text, „2 Module“, „Dauer 25 Min.“, Navy-Tafel, Aktion auf die Programmseite. Die vollständigste Karte.
|
||||
- **Filmkarte „Lara im Park“** (öffentlich über „Programm Abstand“): Titel, Filmtafel, „Film“, „Im Programm …“, Hinweis auf den geschützten Film, Aktion auf die Programmseite. **Kein Text, weil das Medium keine Kurzbeschreibung hat**; in der Vorschau zusätzlich das Filmstandbild, als nicht öffentlich markiert.
|
||||
- **Materialkarte „Trainerunterlage Abstand“** (öffentlich über „Programm Abstand“): Titel, Materialsymbol, „Text“, Programmbezug.
|
||||
- **Modulkarten**: nur in der Vorschau, mit Lernziel und Dauer; „Mod - eigene Grenzen erkennen“ mit Vorschaubild der Bibliothek (markiert).
|
||||
- **Themenkarten**: nur in der Vorschau, weil keine Säule veröffentlicht ist und keine einen Website-Text hat.
|
||||
|
||||
Die verbleibenden Lücken sind **fehlende Fachdaten, nicht fehlender Code**:
|
||||
|
||||
| Fehlt | Gepflegt unter |
|
||||
|---|---|
|
||||
| Kurzbeschreibung und Anzeigetitel der Medien | Medium bearbeiten → Anzeigetitel, Kurzbeschreibung |
|
||||
| Veröffentlichung, Adresse und Text der Themen | Fachliche Säulen → Öffentliche Adresse, Text für die Website, „Auf der Website veröffentlichen“ |
|
||||
| Kurzbeschreibung der Programme und Module | Programm/Modul → Kurzbeschreibung |
|
||||
| öffentliches Bild | Kartenbild im Reiter „Medien“ (freigegebenes Motiv), später Freigabe von Vorschaubildern (§13 der Registry) |
|
||||
|
||||
### Neu öffentlich und bewusst entschieden
|
||||
|
||||
- **Kurzbeschreibung von Medien** (Betreibervorgabe) und **Dauer von Programmen** („Dauer N Min.“): beide stehen bisher auf keiner öffentlichen Seite. Die Programmseite zeigt das Lernziel, nicht die Dauer.
|
||||
- **Vertraulichkeit hängt an der Inhaltsart.** Nie öffentlich sind Elemente mit der Inhaltsart „Traineranleitung“. „Trainerunterlage Abstand“ hat auf der Testinstanz keine Inhaltsart und gehört zu einem öffentlichen Programm. Die Karte ist deshalb öffentlich zulässig. Heute zeigt sie nur den Titel, der auf der Programmseite ohnehin steht. Eine später gepflegte Kurzbeschreibung würde öffentlich. **Vor dem Pflegen von Kurzbeschreibungen den Trainermaterialien die Inhaltsart „Traineranleitung“ zuordnen.**
|
||||
|
||||
### Offene Fragen an Lars
|
||||
|
||||
1. Soll die vorhandene „Beschreibung“ eines Mediums (zum Beispiel 215 Zeichen bei „Lara im Park“) öffentlich als Ersatz dienen, wenn keine Kurzbeschreibung gepflegt ist? Derzeit nein: Die Beschreibung ist Bibliothekstext.
|
||||
2. Freigabe von Vorschaubildern für die Website und öffentliche Filmvorschauen: minimaler Erweiterungsbedarf in `cms-widget-registry.md` §13.
|
||||
3. Öffentliche Sichtbarkeit auf der Testinstanz ist nicht live gezeigt, weil keine Hilfsseite veröffentlicht werden darf. Die Regeln belegen die Feature-Tests. Alternative: eine echte Seite mit Karten veröffentlichen.
|
||||
4. Die Entwurfsseite `/karten-nachbesserung-entwurf` (Seite 19) bleibt zur Ansicht in der Redaktionsvorschau stehen; danach über die Seitenverwaltung löschen.
|
||||
|
||||
### Prüfskript für die Testinstanz
|
||||
|
||||
Das Prüfskript ist `e2e_karten2.py` (im Arbeitsordner der Sitzung, nicht im Repository). Es veröffentlicht nichts und legt die Entwurfsseite `/karten-nachbesserung-entwurf` an. Diese Seite nach der Prüfung über die Seitenverwaltung löschen.
|
||||
@@ -60,6 +60,8 @@ ## Übersicht der Architekturentscheidungen
|
||||
| ADR-37 | n8n-Anbindung | Option / nicht beschlossen | n8n allenfalls für externe Kanäle, ohne direkten Datenbankzugang |
|
||||
| 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 | Auf Test (19.11.2026, `develop` `f29ea58`); 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 |
|
||||
|
||||
---
|
||||
|
||||
@@ -512,6 +514,33 @@ ## ADR-39 – Premium-Karten mit Fachbezug
|
||||
- Sichtbarkeit (Übergangsregel bis ADR-29): Themen nur veröffentlicht; Programme nach `PublicCatalogReader`; Module nur in der Redaktionsvorschau; Medien und Materialien öffentlich nur, wenn sie zur gezeigten Fassung eines öffentlichen Programms gehören (dort sind sie heute schon öffentlich genannt), sonst nur in der Redaktionsvorschau (`PublicMaterialReader`). Von Medien wird keine Kurzbeschreibung gezeigt.
|
||||
- Gleiche Höhe je Zeile über die gemeinsame Höhe `fill` (ADR-38). Für gemischte Raster sind die Abschnittsraster 1 + 1 + 2 und 2 + 1 + 1 ergänzt (additiv, bestehende Kennungen unverändert).
|
||||
**Alternativen.** Ein Widget mit mehreren Karten und eigenem Spannweitenraster (verworfen: zweites Kartenraster neben dem Abschnittsraster); eine Widget-Art mit Variante je Fachobjekt (verworfen: Verweisschema hinge von der Variante ab); redaktionell gepflegte Kartentexte (verworfen: Kopien von Fachdaten); Vorschaubilder der Bibliothek als Kartenbild (verworfen: geschützt, Paket 6).
|
||||
**Offene Entscheidung (zuerst).** Welche Felder eines Inhaltselements öffentlich auf einer Karte erscheinen dürfen. Heute nennt nur die Programmseite Bestandteile, und zwar mit Titel. Die Medienkarte zeigt deshalb öffentlich Titel (Anzeigetitel, sonst Arbeitstitel), Inhaltsart, Ausgabeart und Programmzugehörigkeit, aber keine Kurzbeschreibung. Zu prüfen ist besonders bei Traineranleitungen, ob schon der Titel öffentlich sein darf.
|
||||
**Nachbesserung (18.11.2026, nach Betreiberprüfung).** Themenkarten bieten alle Säulen an (nicht veröffentlichte nur für die Redaktionsvorschau). Medienkarten zeigen die Kurzbeschreibung des Mediums (auf ausdrücklichen Wunsch), unterscheiden Film (Filmtafel) und Material (Materialsymbol) und zeigen das geschützte Vorschaubild der Bibliothek nur in der Redaktionsvorschau. Traineranleitungen erscheinen nie öffentlich. Programm-/Modulkarten nutzen Lernziel und Dauer und lassen Programme/Module ohne Anzeigefreigabe für die Vorschau zu. Fehlende Inhalte erscheinen nur in der Vorschau als Hinweise.
|
||||
**Offene Entscheidungen.** (1) Freigabe von Vorschaubildern für die Website und öffentliche Filmvorschauen (minimaler Erweiterungsbedarf in `cms-widget-registry.md` §13). (2) Ob bei Traineranleitungen schon der Titel auf der Programmseite öffentlich sein soll (Programmseite, nicht Karte).
|
||||
**Folgen und offene Prüfung.** Keine Migration; bestehende Seiten und Widgets unverändert (gemessen). Mit ADR-29 ersetzen öffentliche Profile die Übergangsregeln in `PublicCatalogReader` und `PublicMaterialReader`; die gespeicherten Karten ändern sich dadurch nicht. Offen: gestalterische Freigabe v1.7, freigegebene Motive statt Platzhaltern, eine kaufbare Angebotskarte (eigenes Fachobjekt „Angebot“ mit Umfang, Zweck und Lizenzbedingungen, nicht Teil dieser Karten).
|
||||
**Quelle.** Brand-UI-Kit v1.7 (`docs/Brand-UI-Kit/13_premium_karten_v1.7_entwurf`, README, `docs/design-config.json`); `docs/architektur/cms-widget-registry.md` §§4, 6, 11, 13; ADR-29, ADR-30, ADR-38.
|
||||
|
||||
## ADR-40 – Zentrale Medienverwaltung im CMS
|
||||
|
||||
**Status am 19.11.2026:** Umgesetzt auf `develop`/Testinstanz (Branch `feature/cms-medienverwaltung`); Abnahme durch den Betreiber offen. Baut auf der Website-Freigabe des Medienmanagers auf (`medienzugriff-fuer-komponenten.md`).
|
||||
**Kontext.** Das CMS hatte eine eigene Bildablage (`cms/`, `PublishPublicMedia`). Redakteure sollen Bilder im Medienmanager, im Modul-/Programmeditor und in CMS-Widgets aus demselben Bestand verwenden; öffentlich darf nur erscheinen, was für die Website freigegeben ist.
|
||||
**Entscheidung.** Alle Bildstellen (Einstieg, Bild und Text, redaktionelle Karten, Premium-Karten, Abschnittshintergrund) speichern die Kennung des Inhaltselements im bisherigen Bildschlüssel `image` und lesen über `WebsiteMedia`. Uploads im Widget-Dialog laufen über `WebsiteIntake`. Frühere CMS-Bilder werden per Warteschlangen-Job übernommen (dedupliziert, nichts gelöscht) und über `website_media_aliases` zugeordnet; die Zuordnung wird erst nach der ersten Website-Freigabe wirksam. Ein nicht freigegebenes Bild entfällt öffentlich, das Widget bleibt.
|
||||
**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); jedes Widget bei fehlender Freigabe ausblenden (verworfen: entfernt Überschriften und H1).
|
||||
**Entscheidung zur fehlenden Freigabe (19.11.2026).** Wird die Website-Freigabe zurückgenommen, wird das Medium nicht mehr öffentlich ausgeliefert. Überschriften, Texte und übrige Widget-Inhalte bleiben. Ein Widget, das danach keinen darstellbaren Inhalt mehr hat, entfällt. Ein reines Medienwidget ohne Medium gehört dazu. Die Redaktionsvorschau darf das nicht freigegebene Bild weiter mit Hinweis zeigen.
|
||||
**Folgen und offene Prüfung.** Rollback zeigt nach der Umstellung gespeicherte Bilder nicht (Registry §9). Website-Bilder werden bis 2400 px abgeleitet. Offen bleiben: ü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:** Auf der Testinstanz (`develop` `7b325f0`, Deploy-Lauf 4868). `PresentationMediaTest` und `EditorialDeskTest` sind grün. **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 die Medienidentität, nicht auf eine Inhaltsfassung. Bilder, Filme und Hörstücke können ohne fachliche Fassung im Medienmanager liegen. `preview_path` hält bei Film und Hörstück die technische Ableitung unter `teaser/`. Eine Zuordnung speichert die Kennung des Mediums. `source_version_id` bleibt leer, solange niemand ausdrücklich eine Inhaltsfassung hinterlegt. Eine neuere Fassung markiert eine solche Bindung als veraltet und erzeugt keinen neuen Clip. Die Zuordnung legt keine Fassung an, erteilt kein Recht und nimmt das Medium nicht in einen Aufbau auf.
|
||||
- **Bisherige Abhängigkeit der Website-Videoauslieferung.** `WebsiteRelease` hat einen Film nur freigegeben, wenn eine bereitgestellte Inhaltsfassung eine `MediaRendition` der Rolle `preview` unter `teaser/` trug. Ein Teaser ohne Fassung blieb damit unfreigebbar. Bilder waren davon unabhängig und nutzen das Vorschaubild am Medium. **Anpassung:** Liegt `preview_path` am Medium, gibt die Website-Freigabe diese Ableitung frei, ohne eine Inhaltsfassung zu erzeugen oder vorauszusetzen. Hat ein Film keine solche Datei, bleibt der bisherige Weg über die bereitgestellte Fassung bestehen. Zurücknehmen löscht nur die öffentliche Kopie. Originale, Master und Traineranleitungen bleiben gesperrt.
|
||||
- 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.** Eine verwaltbare Liste zulässiger Objekttypen je Dimension (die Tabelle führt sie nicht; Inhaltselemente blenden nur die Dimension „Fachliche Säule“ aus, weil Themen dort über die Säulen gepflegt werden). Ob ein öffentliches Profil (ADR-29) die Kartenregeln ersetzt. Ob freie Suchbegriffe später eine verwaltete Schlagwortdimension werden. Die Frage, ob bei zurückgenommener Freigabe das ganze Widget entfällt, ist entschieden, siehe 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.
|
||||
|
||||
@@ -125,10 +125,11 @@ ## 6. Öffentliche Freigabe von Programmen und Modulen (Übergangsregel)
|
||||
|
||||
| Objekt | Im Editor wählbar | Öffentlich sichtbar | Redaktionsvorschau |
|
||||
|---|---|---|---|
|
||||
| Thema (Säule), veröffentlicht | ja (Themenkarte) | ja, mit Link auf `/themen/{slug}` | ja |
|
||||
| Thema, nicht veröffentlicht | nein | nein | Hinweis „nicht mehr veröffentlicht“ |
|
||||
| Medium/Material (Inhaltselement) mit bereitgestellter Fassung, nicht archiviert, Bestandteil der gezeigten Fassung eines öffentlichen Programms | ja (Medienkarte) | ja, mit Link auf die Programmseite (dort ist es bereits öffentlich genannt) | ja |
|
||||
| Medium/Material ohne öffentliches Programm | ja | **nein** | ja, mit Hinweis „Nur in der Redaktionsvorschau sichtbar“ |
|
||||
| Thema (Säule), veröffentlicht mit öffentlicher Adresse | ja (Themenkarte) | ja, mit Link auf `/themen/{slug}` | ja |
|
||||
| Thema, nicht veröffentlicht | ja (Themenkarte) | nein | ja, mit Hinweis „Nur Redaktionsvorschau“ |
|
||||
| Medium/Material, nicht archiviert, mit bereitgestellter Fassung, Bestandteil der gezeigten Fassung eines öffentlichen Programms, keine Traineranleitung | ja (Medienkarte) | ja, mit Link auf die Programmseite (dort ist es bereits öffentlich genannt) | ja |
|
||||
| Medium/Material ohne öffentliches Programm, nur mit Entwurfsfassung oder Traineranleitung | ja (nicht gesperrt) | **nein** | ja, mit Hinweis |
|
||||
| Programm oder Modul mit bereitgestellter Fassung, ohne Anzeigefreigabe | ja (nur Programm-/Modulkarte, nicht Katalogkarten) | nein | ja, mit Hinweis |
|
||||
| Programm mit Anzeigefreigabe, nicht archiviert | ja | ja, mit Link auf `/programme/{id}` (dieselbe Regel wie die bestehende Programmliste) | ja |
|
||||
| Modul mit Anzeigefreigabe, nicht archiviert | ja | **nein** | ja, mit Hinweis „Nur in der Redaktionsvorschau sichtbar“ |
|
||||
| Fassung ohne Anzeigefreigabe, Entwurf, archiviert, ohne Inhaltsart | nein (Speichern wird abgewiesen) | nein | nein |
|
||||
@@ -139,9 +140,12 @@ ## 6. Öffentliche Freigabe von Programmen und Modulen (Übergangsregel)
|
||||
|
||||
## 7. Medien
|
||||
|
||||
- Wählbar sind nur Bilder im öffentlichen Website-Bereich `cms/` (`media_public` bzw. noch nicht übertragene Uploads in `cms_incoming`). Bibliotheksmedien und Filmstandbilder erscheinen nicht, auch nicht als Abschnittshintergrund.
|
||||
- Neue Uploads (Widgets und Abschnittshintergründe) landen im Webprozess in `cms_incoming` (privater Speicher); `PublishPublicMedia` überträgt sie in der Hintergrundverarbeitung nach `media_public`. Der Web-Prozess schreibt nicht in den Medienbestand.
|
||||
- Widget-Bilder sind an einen Alternativtext gebunden (Ausnahme: Kartenbilder gelten als dekorativ, `alt=""`). Abschnittshintergründe sind dekorativ (`alt=""`); tragende Aussagen stehen als HTML-Text in den Widgets.
|
||||
Alle Bilder kommen aus dem zentralen Medienmanager (`docs/architektur/medienzugriff-fuer-komponenten.md`, Abschnitt
|
||||
„Umsetzung im CMS“). Gespeichert wird die Kennung des Mediums in `refs.image`, `data.items[].image` bzw.
|
||||
`style.image`; öffentlich erscheint ein Bild nur mit Website-Freigabe (`WebsiteMedia`, Route `website.media`).
|
||||
Gemeinsame Felder: `ImageRefFields` (Auswahl mit Vorschaubild und Status, Upload über `WebsiteIntake`, Anzeige des
|
||||
gewählten Mediums). Frühere Pfade unter `cms/` gelten über `WebsiteMediaAlias` als das übernommene Medium, ohne
|
||||
Zuordnung weiter als öffentliches CMS-Bild. Bibliotheksmedien ohne Website-Freigabe erscheinen öffentlich nie.
|
||||
|
||||
## 8. Editor und Vorschau
|
||||
|
||||
@@ -163,6 +167,11 @@ ## 8. Editor und Vorschau
|
||||
|
||||
## 9. Rollback und Datenformat (wichtig vor dem Merge nach `main`)
|
||||
|
||||
**Medien aus dem Medienmanager (ADR-40).** Revisionen, die nach der Umstellung gespeichert werden, enthalten im
|
||||
Bildschlüssel eine Kennung (Zahl) statt eines Pfads. Ein Code-Rollback auf eine Fassung davor zeigt diese Bilder nicht
|
||||
(die ältere Fassung kennt nur `cms/`-Pfade); Texte und Gestaltung bleiben. Die Dateien unter `cms/` und frühere
|
||||
Revisionen bleiben unverändert, die Zuordnungstabelle `website_media_aliases` ist additiv.
|
||||
|
||||
**Speicherung.** Jede neue Revision schreibt zwei Spalten:
|
||||
|
||||
| Spalte | Inhalt | Wer liest sie |
|
||||
@@ -287,29 +296,39 @@ ## 12. Responsive Widget-Regeln und gemeinsamer Layoutvertrag (ADR-38)
|
||||
|
||||
## 13. Premium-Karten (Brand-UI-Kit v1.7, ADR-39)
|
||||
|
||||
Drei Widget-Arten auf der gemeinsamen Basis `App\Domain\Cms\Widgets\Types\PremiumCardWidget`, Ansicht `resources/views/widgets/premium_card.blade.php`, Stylesheet `resources/css/components/lf-premium-card.css` (aus `13_premium_karten_v1.7_entwurf/components/lf-premium-card.css` übernommen und angepasst). Das Kit ist ein **Entwurf zur visuellen Freigabe**; die Freigabe steht aus.
|
||||
Drei Widget-Arten auf der gemeinsamen Basis `App\Domain\Cms\Widgets\Types\PremiumCardWidget`, Ansicht `resources/views/widgets/premium_card.blade.php`, Stylesheet `resources/css/components/lf-premium-card.css` (aus `13_premium_karten_v1.7_entwurf/components/lf-premium-card.css` übernommen und angepasst). Das Kit ist ein **Entwurf zur visuellen Freigabe**; die Freigabe steht aus. Stand nach der fachlichen Nachbesserung vom 18.11.2026.
|
||||
|
||||
| Art | Fachobjekt | Gelesen aus | Art/Label | Zusatzangaben | Aktion (Vorgabe) |
|
||||
| Art | Fachobjekt (Lesesicht) | Wählbar | Gelesen | Bildbereich ohne Kartenbild | Aktion |
|
||||
|---|---|---|---|---|---|
|
||||
| Themenkarte `topic_card` | Thema (`Pillar`) | Name, öffentlicher Text | „Thema“ | – | „Thema entdecken“ → `/themen/{slug}` |
|
||||
| Medien- und Materialkarte `media_card` | Inhaltselement (`ContentElement`) über `PublicMaterialReader` | Anzeigetitel (sonst Arbeitstitel); **keine Kurzbeschreibung** (heute nirgends öffentlich, offene Entscheidung) | Inhaltsart (zum Beispiel „Merkblatt“), sonst Ausgabeart; Ausgabeart als Marke auf dem Bild | Ausgabeart, „Im Programm …“ | „Im Programm ansehen“ → Programmseite |
|
||||
| Programm- oder Modulkarte `program_card` | Komposition über `PublicCatalogReader` | Anzeigetitel, Kurzbeschreibung | „Programm“ oder „Modul“, immer sichtbar; ohne Bild als Navy-Tafel | Anzahl Module der gezeigten Fassung | „Programm ansehen“ → `/programme/{id}`; Module ohne Aktion |
|
||||
| Themenkarte `topic_card` | Säule (`Pillar`) | alle Säulen | Name, Text für die Website, Zahl veröffentlichter Seiten zum Thema | keiner | „Thema entdecken“ → `/themen/{slug}`, nur veröffentlicht |
|
||||
| Medien- und Materialkarte `media_card` | Inhaltselement (`PublicMaterialReader`) | nicht archiviert, mindestens eine nicht gesperrte Fassung | Anzeigetitel (sonst Arbeitstitel), Kurzbeschreibung, Inhaltsart, Ausgabeart, Programmzugehörigkeit; Film: Hinweis auf den geschützten vollständigen Film | Film: Filmtafel (Navy, Filmstreifen, kein Abspielsymbol); Material: Materialsymbol (Creme); Redaktionsvorschau: Vorschaubild der Bibliothek, markiert | „Im Programm ansehen“ → Programmseite, nur öffentlich |
|
||||
| Programm- oder Modulkarte `program_card` | Komposition (`PublicCatalogReader::subject`) | Programm/Modul, nicht archiviert, bereitgestellte Fassung | Anzeigetitel, Kurzbeschreibung (sonst Lernziel), Art, Zahl der Module, Dauer | Navy-Tafel mit Art; Redaktionsvorschau: Vorschaubild der Bibliothek, markiert | „Programm ansehen“ → `/programme/{id}`, nur Programme mit Anzeigefreigabe; Module ohne Link |
|
||||
|
||||
**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.
|
||||
**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.
|
||||
|
||||
**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 (nicht bei Medien), Art (nicht bei Programm/Modul), Zusatzangaben und Aktion. Bildhöhe höchstens min(70vh, 640 px), damit breite gestapelte Karten nicht übermäßig hoch werden.
|
||||
**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.
|
||||
|
||||
**Hinweis für die Redaktion.** Eine Karte, die öffentlich nicht erscheint (Modul, Medium ohne öffentliches Programm), lässt ihren Platz entfallen; die übrigen Plätze des Abschnitts teilen sich die Breite. Solche Karten daher in einen eigenen Abschnitt setzen oder mit einem Platz kombinieren, der allein gut aussieht.
|
||||
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. Hat ein Widget danach keinen darstellbaren Inhalt, entfällt es. Eine eingetragene Bildkennung hat Vorrang vor dem zentralen Titelbild. Öffentliche Fachobjektprofile nach ADR-29 bleiben offen. Ein Titelbild kann ein Bild ohne Inhaltsfassung sein.
|
||||
|
||||
**Raster.** Eine Karte je Platz. Gemischte Raster entstehen über die Abschnittsraster, zum Beispiel 1 + 1 + 2 (`u1_1_2`), 2 + 2, 1 + 1 + 1 + 1. Gleiche Höhe: alle Karten einer Zeile auf „An die Zeile angleichen“ stellen; die Aktion steht dann am unteren Rand. Die Einstellung gilt je Karte, nicht je Abschnitt.
|
||||
**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).
|
||||
|
||||
**Sicherheit.** Keine Vorschaubilder oder Filmstandbilder der Bibliothek, keine Adressen unter `/bereich/` oder `/redaktion/`, kein Abspielen, kein Download, kein Preis, keine Kaufaktion (Tests `CmsPremiumCardsTest`). Eine Karte begründet keine Berechtigung.
|
||||
**Redaktionsvorschau.** Nicht öffentliche Karten tragen die Marke „Nur Redaktionsvorschau“. Fehlende Inhalte (Kurzbeschreibung, Text für die Website, Anzeigetitel, Dauer, Laufzeit, Kartenbild) stehen eingeklappt unter „Hinweise für die Redaktion“, mit dem Ort, an dem sie gepflegt werden. Öffentlich erscheinen weder Marke noch Hinweise noch Bibliotheksbilder.
|
||||
|
||||
**Raster.** Eine Karte je Platz. Gemischte Raster entstehen über die Abschnittsraster, zum Beispiel 1 + 1 + 2 (`u1_1_2`), 2 + 2, 1 + 1 + 1 + 1. Gleiche Höhe: alle Karten einer Zeile auf „An die Zeile angleichen“ stellen; die Aktion steht dann am unteren Rand. Eine öffentlich nicht sichtbare Karte lässt ihren Platz entfallen; die übrigen Plätze teilen sich die Breite. Solche Karten daher in einen eigenen Abschnitt setzen oder mit einem Platz kombinieren, der allein gut aussieht.
|
||||
|
||||
**Sicherheit.** Der einzuhaltende Weg steht in `medienzugriff-fuer-komponenten.md`. Vorschaubilder der Bibliothek (Filmstandbilder, Modulvorschau) nur über `editorial.card` (Redaktionsanmeldung) und nur in der Redaktionsvorschau; öffentlich nie. Keine Adressen unter `/bereich/` oder `/redaktion/` auf öffentlichen Seiten, kein Abspielen, kein Download, kein Preis, keine Kaufaktion. Nie öffentlich: Beschreibung, Einsatzhinweis, Lizenzvermerk, Lehrtexte, Traineranleitungen. Eine Karte begründet keine Berechtigung (Tests `CmsPremiumCardsTest`).
|
||||
|
||||
**Erweiterungsbedarf für öffentliche Vorschaubilder und Filmvorschauen (nicht umgesetzt, minimal):**
|
||||
1. *Vorschaubild für die Website freigeben:* je `ContentElement` und `Composition` ein Freigabevermerk (`thumbnail_public_at`, `thumbnail_public_by`, Bezug auf `thumbnail_source`), gesetzt nur durch eine ausdrückliche Aktion „Vorschaubild für die Website freigeben“ in der Medien- bzw. Modulbearbeitung. Die Hintergrundverarbeitung kopiert das freigegebene Standbild nach `media_public` (eigener Pfad, zum Beispiel `katalog/`), Zurücknehmen löscht die Kopie. Die Karte nimmt dieses Bild, wenn kein Kartenbild gewählt ist. Der Web-Prozess schreibt weiterhin nicht in den Medienbestand.
|
||||
2. *Öffentliche Filmvorschau (Trailer, Ausschnitt):* eine eigene Ausgabe (`MediaRendition` mit Rolle `preview`) und eine eigene Freigabe je Fassung, getrennt vom lizenzpflichtigen Film; ausgeliefert ohne Signatur nur nach dieser Freigabe. Bis dahin hat die Karte keine Abspielfunktion.
|
||||
3. *Laufzeit:* ein Feld in den Mediendaten der Fassung (zum Beispiel `metadata.duration_seconds`, beim Transkodieren mit ffprobe ermittelt).
|
||||
Alle drei Erweiterungen hängen mit ADR-29 (öffentliche Profile) zusammen und brauchen eine Entscheidung von Lars.
|
||||
|
||||
**Abweichungen vom Kit (bewusst):**
|
||||
- Kein `.lf-pc-grid`/`.lf-pc-section`/Spannweitenklassen: Das Abschnittsraster ist das einzige Raster.
|
||||
- Umschaltung bei 520 px über den Platz-Container `slot` statt eines eigenen Kartencontainers (eine Karte füllt ihren Platz, die Breite ist dieselbe).
|
||||
- Umschaltung bei 520 px über den Platz-Container `slot` statt eines eigenen Kartencontainers.
|
||||
- Überschriftenebene ohne H1 (Karten sind nie Seiteneinstieg).
|
||||
- Gelber Akzent der Tafel als `components/brand/underline` (SVG, Farbe über Token) statt Bilddatei; Schriftgewichte 600 statt 750 (vorhandene Schnitte von Source Sans 3).
|
||||
- „Nur Redaktionsvorschau“-Karten mit gestricheltem Rand und Hinweis.
|
||||
- Gelber Akzent der Tafel als `components/brand/underline` (SVG); Schriftgewichte 600 statt 750 (vorhandene Schnitte).
|
||||
- Zusätzlich Filmtafel und Materialsymbol für Medien ohne freigegebenes Bild; Tafel neben dem Text mittig statt gestreckt.
|
||||
|
||||
**Grenzen.** Medienkarten öffentlich nur über ein öffentliches Programm; Module nur in der Vorschau (beides bis ADR-29). Zusatzangaben nur, soweit Fachdaten sie hergeben (keine Laufzeit, keine Altersangabe, keine Seitenzahl). Eine **kaufbare Angebotskarte** gibt es nicht; sie braucht ein eigenes Fachobjekt „Angebot“ mit Umfang, Zweck und Lizenzbedingungen und wird gesondert konzipiert.
|
||||
**Grenzen.** Module haben keine öffentliche Seite (ADR-29) und erscheinen nur in der Vorschau. Medien öffentlich nur über ein öffentliches Programm. Keine öffentlichen Vorschaubilder ohne die oben beschriebene Freigabe. Eine **kaufbare Angebotskarte** gibt es nicht; sie braucht ein eigenes Fachobjekt „Angebot“ mit Umfang, Zweck und Lizenzbedingungen und wird gesondert konzipiert.
|
||||
@@ -0,0 +1,140 @@
|
||||
# Medienzugriff für CMS-Komponenten
|
||||
|
||||
**Stand:** 18.11.2026. Beschreibt den vorhandenen Weg. Keine neue Freigabe, kein zweites Rechtesystem.
|
||||
|
||||
Eine CMS-Komponente, die im Medienmanager liegt, ist ein Inhaltselement (`ContentElement`). Sie entscheidet den Zugriff nicht selbst. Sie ruft eine der drei vorhandenen Stellen auf, je nachdem, was sie tut.
|
||||
|
||||
## Drei getrennte Stellen
|
||||
|
||||
| Was die Komponente tut | Stelle | Was sie nicht tut |
|
||||
|---|---|---|
|
||||
| Anzeigedaten auf der Website lesen | `PublicMaterialReader` | keine Datei, keine Ausgabeadresse |
|
||||
| Datei an ein Mitglied ausliefern | `DecideAccess`, erneut bei jedem Abruf | keine eigene Erlaubnis, keine Vereinigung von Berechtigungen |
|
||||
| Ein öffentliches Bild zeigen, das kein Bestandsmedium ist | `PublicMedia` | keinen Pfad aus `originals/` oder `derived/` |
|
||||
|
||||
Die Pflege im Medienmanager ist eine vierte, nur redaktionelle Tür: Ansehen dürfen Redaktion und Katalogverwaltung, Ändern nur die Redaktion (`ContentElementResource`). Diese Tür gibt nichts auf der Website und nichts im Mitgliederbereich frei.
|
||||
|
||||
## Anzeige auf der Website
|
||||
|
||||
`PublicMaterialReader` ist die einzige Lesesicht für ein Medium auf einer öffentlichen Seite. Die Medienkarte nutzt sie bereits.
|
||||
|
||||
Öffentlich genannt wird ein Medium nur, wenn alle Punkte zutreffen:
|
||||
|
||||
- es ist nicht archiviert und hat mindestens eine nicht gesperrte Fassung,
|
||||
- es hat eine bereitgestellte Fassung,
|
||||
- die Inhaltsart ist nicht `traineranleitung`,
|
||||
- es gehört zur gezeigten Fassung eines öffentlich gezeigten Programms.
|
||||
|
||||
Solange öffentliche Profile (ADR-29) fehlen, ist das die Übergangsregel. Ein Medium hat keine eigene öffentliche Seite. Die Karte verweist dann auf die Programmseite.
|
||||
|
||||
Gelesen werden Anzeigename (sonst Arbeitstitel), Kurzbeschreibung, Inhaltsart und Ausgabeart. Nicht gelesen und nicht ausgegeben werden Beschreibung, Einsatzhinweis, Lizenzvermerk, Lehrtext und jede Datei.
|
||||
|
||||
Das Vorschaubild der Bibliothek erscheint nur in der Redaktionsvorschau, über die Route `editorial.card`, und nur für angemeldete Redaktion. Auf einer öffentlichen Seite hat dieses Bild keine Adresse.
|
||||
|
||||
## Auslieferung an Mitglieder
|
||||
|
||||
`DecideAccess` ist die einzige Entscheidung über eine Datei. Sie prüft an genau einer Berechtigung: aktives Konto, passender Artikel-Stand, Fassung im fixierten Inhalt dieses Stands, Fassung nicht gesperrt, Aktion im Rechte-Schnappschuss für die Ausgabeart. Zwei Berechtigungen werden nicht zu einer zusammengefügt.
|
||||
|
||||
Die Bibliothek ruft dieselbe Prüfung beim Aufbau der Seite und erneut beim Abruf auf (`LibraryController::media`, signierte Adresse, Leser gebunden). Eine Signatur, eine Karte oder eine gespeicherte Komponente ersetzen diesen zweiten Aufruf nicht.
|
||||
|
||||
Komponenten liefern Dateien nicht selbst aus. Sie bauen keine Adresse auf `content.file`, `content.preview`, `content.rendition` oder `/bereich/`.
|
||||
|
||||
## Öffentliche Bilder außerhalb des Bestands
|
||||
|
||||
Heute liegen Bilder, die nur zur Website gehören, unter dem Präfix `cms/` und laufen über `PublicMedia` und die Route `media.public`. Der Controller liefert nur Pfade, die mit `cms/` beginnen, von den Platten `media_public` und `cms_incoming`.
|
||||
|
||||
Dieser Pfad ist kein Zugang zum Medienmanager. Ein Inhaltselement wird darüber nicht ausgeliefert. Umgekehrt wird eine geschützte Bestandsdatei nicht in `cms/` gelegt, um sie öffentlich zu machen.
|
||||
|
||||
## Website-Medien für Hero, Teaser und Slideshow
|
||||
|
||||
Hero-Grafiken, Teaserfilme und Slideshows liegen im Medienmanager. Sie werden nicht verkauft. Lizenzartikel, Angebot, Grant und `DecideAccess` bleiben dafür unbenutzt.
|
||||
|
||||
Die Website-Freigabe ist eine eigene Entscheidung am Inhaltselement. Sie hängt nicht daran, dass eine Fassung bereit ist, und nicht daran, dass das Medium in einem öffentlichen Programm liegt. `PublicMaterialReader` bleibt die Lesesicht der Programmkarte. Widgets für Hero, Bild und Slideshow lesen `WebsiteMedia`.
|
||||
|
||||
| Aufruf | Klasse | Ergebnis |
|
||||
|---|---|---|
|
||||
| Ein Medium | `WebsiteMedia::present($elementOderId)` | `WebsitePresentation` oder `null` |
|
||||
| Slideshow, Reihenfolge bleibt | `WebsiteMedia::presentMany([$id, ...])` | nur freigegebene Einträge |
|
||||
|
||||
`WebsitePresentation` enthält `elementId`, `title`, `alt`, `credit`, `kind` (`bild` oder `film`) und `url`. `url` ist die einzige Dateiadresse, Route `website.media`. `credit` ist die öffentliche Quellenzeile. `license_note` steht dort nicht.
|
||||
|
||||
Ein Widget speichert die Kennung des Inhaltselements (`refs.element` oder bei einer Slideshow `refs.elements`), nicht einen kopierten Dateipfad. Ist `present` leer, gibt das Widget nichts aus. Vorhandene Bilder unter `cms/` bleiben gültig, bis das jeweilige Widget umgestellt ist.
|
||||
|
||||
### Neues Bild aus dem CMS
|
||||
|
||||
`WebsiteIntake::acceptImage($pfad, $titel, $quellenzeile, $alternativtext, $redakteur)` legt das Medium an und gibt seine Kennung sofort zurück. `$pfad` ist die bereits hochgeladene Datei auf `cms_incoming` und beginnt mit `cms/` oder `vorschau/`. Titel, Quellenzeile und Alternativtext werden am Medium gespeichert. Eine Inhaltsfassung entsteht dabei nicht.
|
||||
|
||||
Die Warteschlange liest die Datei, schreibt das JPEG nach `vorschau/element-{id}.jpg` und gibt danach genau diese Ableitung frei. `present` bleibt leer, bis das abgeschlossen ist. Eine unlesbare Datei bleibt im Eingang, das Medium trägt `thumbnail_error` und wird nicht freigegeben. Fehlt die Datei, liegt sie außerhalb des Eingangs oder fehlt der Titel, entsteht kein Medium.
|
||||
|
||||
Das CMS ruft dafür nicht `DeriveThumbnail` und nicht `WebsiteRelease` auf.
|
||||
|
||||
Freigeben und Zurücknehmen eines schon abgelegten Mediums stehen in der Medienansicht, Bereich Beschreibung (`WebsiteRelease`). Die Warteschlange kopiert die Ableitung nach `media_public` unter `website/{id}/datei.{endung}` und setzt `website_released_at`. Der Web-Prozess schreibt diese Datei nicht. Zurücknehmen löscht nur diese Kopie.
|
||||
|
||||
Was freigegeben werden kann:
|
||||
|
||||
- Bild: Vorschaubild unter `vorschau/` auf `media_derived`, Endung jpg, jpeg, png, webp oder gif. Eine Inhaltsfassung ist dafür nicht nötig.
|
||||
- Film oder Hörstück ohne Inhaltsfassung: `preview_path` am Medium, unter `teaser/`, Film mp4 oder webm, Hörstück mp3, m4a oder ogg.
|
||||
- Film mit Inhaltsfassung: an der höchsten bereitgestellten Fassung eine Ausgabe mit Rolle `preview` und Pfad unter `teaser/`, Endung mp4 oder webm. Das gilt, wenn am Medium kein `preview_path` liegt.
|
||||
|
||||
Originaldatei, Master-Fassung und Traineranleitungen werden abgelehnt. Eine Quellenzeile (`website_credit`) und ein Alternativtext (`website_alt`) gehören zu den Anzeigedaten und erzeugen keine neue Fassung. Die Quellenzeile erscheint nur, solange die Freigabe besteht. Der interne Vermerk bleibt intern.
|
||||
|
||||
Ein neues Website-Bild nimmt `WebsiteIntake` auf und gibt es nach der Ableitung frei. Ein eigenständiges Präsentationsmedium legt `PresentationFile` ohne Inhaltsfassung an und gibt es nicht von selbst frei. Öffentliche Profile nach ADR-29 sind damit nicht umgesetzt.
|
||||
|
||||
## Was eine Komponente einhält
|
||||
|
||||
1. Identität und Anzeigedaten bleiben am Inhaltselement. Die Komponente speichert die Kennung, nicht eine Kopie von Titel, Text oder Datei.
|
||||
2. Eine Programmkarte liest das Fachobjekt über `PublicMaterialReader` und ein Bild über `WebsiteImage`. Hero, Bild und Text sowie Karten lesen `WebsiteMedia`. Ist das Medium nicht freigegeben, wird es nicht ausgeliefert. Texte und übrige Inhalte des Widgets bleiben. Ein Widget ohne verbleibenden Inhalt entfällt.
|
||||
3. Öffentliche Seiten enthalten keine Adresse unter `/redaktion/` oder `/bereich/` und kein Bibliotheksbild.
|
||||
4. Die Mitgliedsdatei entsteht nur über den Mitgliederabruf, der `DecideAccess` erneut aufruft. Die Website-Ableitung läuft ausschließlich über `website.media`.
|
||||
5. Der Web-Prozess schreibt nicht nach `originals/` und nicht nach `derived/` oder `public/`.
|
||||
|
||||
Eine Karte oder eine Komponente begründet keine Berechtigung.
|
||||
|
||||
## Umsetzung im CMS (19.11.2026, ADR-40)
|
||||
|
||||
Alle Bildstellen des CMS lesen den zentralen Medienbestand: Einstieg (Hero), Bild und Text, redaktionelle Karten,
|
||||
Premium-Karten (Kartenbild) und Abschnittshintergrund. Das CMS hat keine eigene Medienverwaltung mehr.
|
||||
|
||||
- **Gespeichert** wird die Kennung des Inhaltselements im jeweiligen Bildschlüssel: `refs.image` (Einstieg, Bild und
|
||||
Text, Premium-Karten), `data.items[].image` (redaktionelle Karten), `style.image` (Abschnittshintergrund).
|
||||
**Abweichung von `refs.element`:** Die Medienkarte verwendet `refs.element` bereits für ihr Fachobjekt; ein
|
||||
gemeinsamer Bildschlüssel `image` hält alle Widgets gleich und ändert die gespeicherte Struktur nicht.
|
||||
- **Lesen:** `App\Domain\Cms\Widgets\Support\WebsiteImage` ruft `WebsiteMedia::present` auf. Öffentlich erscheint
|
||||
ein Bild nur über `website.media`. In der Redaktionsvorschau erscheint ein nicht freigegebenes Bild als
|
||||
Vorschaubild über `editorial.card` mit Hinweis; öffentlich nie.
|
||||
- **Nicht freigegeben:** Das Medium wird nicht öffentlich ausgeliefert. Überschrift, Text und Schaltflächen bleiben.
|
||||
Ein Widget, das danach keinen Inhalt mehr hat, entfällt. Die Redaktionsvorschau zeigt ein nicht freigegebenes Bild
|
||||
weiter mit Hinweis. Entschieden am 19.11.2026, siehe ADR-40.
|
||||
- **Neu hochladen im Widget-Dialog:** Die Datei geht über `WebsiteIntake::acceptImage` sofort in den Medienmanager
|
||||
und wird ausgewählt. Titel aus dem Dateinamen, ohne Quellenzeile; beides ist im Medienmanager änderbar. Die
|
||||
Warteschlange leitet ab und gibt frei (wie dokumentiert).
|
||||
- **Auswahl:** alle Bilder (`output_class = bild`, nicht archiviert, keine Traineranleitung) mit Vorschaubild, Titel
|
||||
und Website-Status; das gewählte Medium mit Status und Verweis auf den Medienmanager. Die Bildauswahl des
|
||||
Modul-/Programmeditors ist an dessen Livewire-Seite gebunden und lässt sich nicht als Formularfeld einhängen; das
|
||||
Bedienmuster (Suche, Vorschaubild, Auswahl) ist übernommen.
|
||||
- **Alternativtext:** aus dem Medium (`website_alt`, sonst Titel). Das Feld im Widget ist eine optionale Abweichung.
|
||||
- **Website-Ableitung:** Bilder werden bis 2400 px breit abgeleitet (vorher 640 px), nie vergrößert.
|
||||
- **Medienmanager:** Die Medienansicht nennt die Website-Seiten, auf denen ein Bild verwendet wird
|
||||
(`WebsiteImageUsage`), damit vor dem Zurücknehmen sichtbar ist, welche Seiten das Bild verlieren.
|
||||
|
||||
### Übernahme der früheren CMS-Bilder
|
||||
|
||||
- Der Job `ImportCmsImages` (angestoßen von einer Migration, ausgeführt von der Warteschlange) nimmt jede Bilddatei
|
||||
unter `media_public/cms/` über `WebsiteIntake` auf. Bytegleiche Dateien werden ein Medium (SHA-256). Der Titel
|
||||
kommt aus dem Dateinamen ohne Zufallskennung. Nichts wird gelöscht; der Job ist wiederholbar.
|
||||
- `website_media_aliases` ordnet jeden früheren Pfad seinem Medium zu. **Wirksam** wird die Zuordnung erst, wenn das
|
||||
Medium einmal für die Website freigegeben war; bis dahin (oder wenn die Ableitung scheitert) gilt der frühere Pfad
|
||||
weiter, damit keine Seite ihr Bild verliert.
|
||||
- Danach entscheidet die Website-Freigabe des Mediums allein, auch über die frühere Adresse `/medien/cms/…`
|
||||
(404, wenn zurückgenommen).
|
||||
- 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 die Medienidentität. Eine Inhaltsfassung ist dafür nicht erforderlich. `source_version_id` hält nur eine ausdrücklich hinterlegte Fassung fest. Die Rolle ist keine Verwendung im Aufbau, keine Inhaltsart und keine Website-Freigabe. Die Zuordnung macht das Medium nicht lizenzierbar.
|
||||
|
||||
Öffentliche Seiten lesen ein Bild nur über `WebsiteImage` und damit über `WebsiteMedia`. Ein freigegebener Film oder ein Hörstück wird über `website.media` ausgeliefert. Geschützte Originaldateien und Vorschaubilder der Bibliothek bleiben auf diesem Weg geschlossen. Wird die Freigabe zurückgenommen, endet die öffentliche Ausgabe; Überschriften und Texte bleiben. Ein Widget ohne verbleibenden Inhalt entfällt.
|
||||
|
||||
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,53 @@
|
||||
# Redaktionelle Informationsbasis
|
||||
|
||||
**Stand:** 19.11.2026, Testinstanz `develop` `7b325f0` (Deploy-Lauf 4868). 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`. Der Aufbau sucht Fassungen. Die Präsentation sucht zusätzlich Bilder, Filme und Hörstücke ohne Inhaltsfassung |
|
||||
|
||||
## 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. Die Zuordnung verweist auf das Medium. `source_version_id` wird nur gesetzt, wenn eine Inhaltsfassung ausdrücklich festgehalten wird, und danach 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. Im Modul und Programm öffnet „Medium aus dem Bestand auswählen“ denselben Picker wie der Aufbau. Die Übernahme als Präsentation sucht auch Medien ohne Inhaltsfassung und legt keine Fassung an.
|
||||
- `preview_path` an der Medienidentität für die technische Film- oder Audioableitung. Die Website-Freigabe liest sie, ohne eine Inhaltsfassung zu verlangen. Der bisherige Weg über eine `preview`-Rendition der bereitgestellten Fassung bleibt für Unterrichtsfilme.
|
||||
|
||||
## 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. Ein Widget ohne verbleibenden Inhalt entfällt. Bibliotheksvorschaubilder und Originaldateien bleiben geschlossen. Ein freigegebener Teaserfilm wird über `website.media` ausgeliefert und nach dem Zurücknehmen nicht mehr.
|
||||
|
||||
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.
|
||||
- Inhaltselemente bieten die Dimension „Fachliche Säule“ nicht an. Themen liegen dort bei den Säulen. Module, Programme und Lizenzartikel sehen diese Dimension, weil sie keine Säulenauswahl haben. Eine zweite Klassifikation oder eine verwaltbare Objektartenliste gibt es nicht.
|
||||
- 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.
|
||||
@@ -228,6 +228,76 @@ .lf-pc__panel-accent {
|
||||
color: var(--pc-accent);
|
||||
}
|
||||
|
||||
/* Film ohne freigegebenes Bild: Filmtafel (Navy, Filmstreifen-Symbol, kein Abspielsymbol – die Karte spielt nichts ab). */
|
||||
.lf-pc__panel-icon {
|
||||
display: block;
|
||||
inline-size: 44px;
|
||||
block-size: 44px;
|
||||
color: var(--pc-accent);
|
||||
}
|
||||
|
||||
/* Material (Dokument, Text, Hörstück …): ruhige Cremefläche mit Materialsymbol statt Foto. */
|
||||
.lf-pc__panel--material {
|
||||
background: var(--pc-subtle);
|
||||
color: var(--lf-navy);
|
||||
border: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
.lf-pc__panel--material .lf-pc__panel-icon { color: var(--lf-navy); }
|
||||
|
||||
.lf-pc--material .lf-pc__meta {
|
||||
padding-block: 10px;
|
||||
inline-size: 100%;
|
||||
border-block: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
/* Nur Redaktionsvorschau: Vorschaubild der Bibliothek ist markiert, weil es öffentlich nicht erscheint. */
|
||||
.lf-pc__library-flag {
|
||||
position: absolute;
|
||||
inset: auto 12px 12px auto;
|
||||
max-inline-size: calc(100% - 24px);
|
||||
padding: 4px 10px;
|
||||
border-radius: var(--radius-pill);
|
||||
color: var(--lf-white);
|
||||
background: rgb(3 37 81 / 86%);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.lf-pc__editorial {
|
||||
inline-size: 100%;
|
||||
margin: 0;
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
.lf-pc__editorial summary {
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.lf-pc__editorial[open] summary {
|
||||
margin-block-end: 0.4rem;
|
||||
}
|
||||
|
||||
.lf-pc__private-flag {
|
||||
margin: 0;
|
||||
padding: 3px 10px;
|
||||
border-radius: var(--radius-pill);
|
||||
background: var(--color-warning-surface, var(--lf-yellow-tint));
|
||||
color: var(--lf-navy);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.lf-pc__editorial p,
|
||||
.lf-pc__editorial ul {
|
||||
margin: 0 0 0.35rem;
|
||||
}
|
||||
|
||||
.lf-pc__editorial ul {
|
||||
padding-inline-start: 1.1rem;
|
||||
}
|
||||
|
||||
.lf-pc--catalog .lf-pc__kind { color: var(--color-heading); }
|
||||
.lf-pc--catalog .lf-pc__cta { background: var(--lf-navy); color: var(--lf-white); }
|
||||
.lf-pc--catalog .lf-pc__cta:visited { color: var(--lf-white); }
|
||||
@@ -249,9 +319,11 @@ @container slot (min-width: 520px) {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* Neben dem Text wie ein Bild mittig, auch wenn die Karte auf Zeilenhöhe gestreckt ist. */
|
||||
.lf-pc:not(.lf-pc--stacked) .lf-pc__panel {
|
||||
margin: 10px 0 10px 10px;
|
||||
min-block-size: 220px;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.lf-pc--contain:not(.lf-pc--stacked) .lf-pc__visual {
|
||||
|
||||
@@ -54,6 +54,23 @@
|
||||
.luf-sections .fi-fo-repeater-item-header .fi-icon-btn,
|
||||
.luf-sections .fi-fo-builder-item-header .fi-icon-btn { min-width: 2.25rem; min-height: 2.25rem; opacity: 1; }
|
||||
.luf-sections .fi-fo-builder-item-header { flex-wrap: wrap; }
|
||||
/* Medienpicker (Bilder aus dem Medienmanager): Vorschaubild, Titel und Website-Status in der Auswahl. */
|
||||
.luf-media-option { display: flex; align-items: center; gap: .75rem; min-width: 0; }
|
||||
.luf-media-option img, .luf-media-option-empty { flex: none; width: 4.5rem; height: 2.75rem; object-fit: cover; border-radius: .375rem; background: #eef1ee; }
|
||||
.luf-media-option-text { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
|
||||
.luf-media-option-text strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.luf-media-badge { align-self: flex-start; padding: 0 .45rem; border-radius: 999px; font-size: .72rem; line-height: 1.35rem; }
|
||||
.luf-media-badge-ok { background: #e3f0d8; color: #2d5c07; }
|
||||
.luf-media-badge-warn { background: #fff1c7; color: #6b4b00; }
|
||||
.luf-media-badge-wait { background: #e5eef8; color: #18456f; }
|
||||
.luf-media-badge-quiet { background: #eceff1; color: #3e4c5c; }
|
||||
.luf-media-status { display: flex; gap: 1rem; align-items: flex-start; padding: .75rem; border: 1px solid #d5ddd6; border-radius: .5rem; }
|
||||
.luf-media-status img { width: 10rem; height: auto; border-radius: .375rem; }
|
||||
.luf-media-status strong { display: block; }
|
||||
.luf-media-status p { margin: .25rem 0 .4rem; font-size: .875rem; }
|
||||
.luf-media-status a { font-size: .875rem; text-decoration: underline; }
|
||||
.luf-media-status-unreleased, .luf-media-status-missing { border-color: #e7c35a; background: #fffaeb; }
|
||||
.luf-media-status-pending { border-color: #9cbbe0; background: #f3f8fd; }
|
||||
</style>
|
||||
<script>
|
||||
// Vorschau-Iframes an ihren Inhalt anpassen (nach Bildern und Schriften erneut), Höhe begrenzen.
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
verkleinert. So greifen die Container-Abfragen der Widgets wie auf der Website.
|
||||
--}}
|
||||
@php
|
||||
$bodyClass = $bodyClass ?? '';
|
||||
$caption = $caption ?? 'Vorschau bei '.$width.' px Platzbreite, verkleinert. Gleiche Darstellung wie auf der Website.';
|
||||
$document = '<!DOCTYPE html><html lang="de"><head><meta charset="utf-8"><base target="_blank">'
|
||||
.$stylesheets
|
||||
.'<style>html,body{background:#fff;overflow:hidden}html{scrollbar-gutter:auto}body{margin:0;padding:0;min-height:0}main{display:block}</style>'
|
||||
.'</head><body><main class="sheet-preview"><div class="section-slot">'.$html.'</div></main></body></html>';
|
||||
.'</head><body'.($bodyClass !== '' ? ' class="'.e($bodyClass).'"' : '').'><main class="sheet-preview"><div class="section-slot">'.$html.'</div></main></body></html>';
|
||||
@endphp
|
||||
<div class="luf-live-preview">
|
||||
<p class="luf-live-preview-caption">Vorschau bei {{ $width }} px Platzbreite, verkleinert. Gleiche Darstellung wie auf der Website.</p>
|
||||
<p class="luf-live-preview-caption">{{ $caption }}</p>
|
||||
@if (trim($html) === '')
|
||||
<p class="luf-widget-preview-empty">Dieses Widget zeigt mit den aktuellen Angaben öffentlich nichts an.</p>
|
||||
@else
|
||||
|
||||
@@ -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">
|
||||
@@ -502,10 +519,15 @@
|
||||
<input id="picker-suche" type="search" wire:model.live.debounce.250ms="pickerQuery" placeholder="Titel oder Beschreibung">
|
||||
</div>
|
||||
<div class="luf-scopes" role="group" aria-label="Inhaltsart">
|
||||
@foreach (['alle' => 'Alle', 'film' => 'Filme', 'dokument' => 'Dokumente', 'text' => 'Texte', 'modul' => 'Module'] as $value => $label)
|
||||
@foreach (['alle' => 'Alle', 'film' => 'Filme', 'bild' => 'Bilder', 'dokument' => 'Dokumente', 'text' => 'Texte', 'modul' => 'Module'] as $value => $label)
|
||||
<button type="button" class="luf-quiet" wire:click="$set('pickerKind', '{{ $value }}')" aria-pressed="{{ $this->pickerKind === $value ? 'true' : 'false' }}">{{ $label }}</button>
|
||||
@endforeach
|
||||
</div>
|
||||
<div class="luf-scopes" role="group" aria-label="Darstellung">
|
||||
<button type="button" class="luf-quiet" wire:click="$set('pickerLayout', 'kacheln')" aria-pressed="{{ $this->pickerLayout === 'kacheln' ? 'true' : 'false' }}">Kacheln</button>
|
||||
<button type="button" class="luf-quiet" wire:click="$set('pickerLayout', 'liste')" aria-pressed="{{ $this->pickerLayout === 'liste' ? 'true' : 'false' }}">Liste</button>
|
||||
</div>
|
||||
<p class="luf-note">Entwürfe bleiben sichtbar. So kann ein Modul sie weiterhin gemeinsam mit dem Aufbau freigeben. Eine nicht passende Art filterst du hier, ohne die übrigen Medien zu verstecken.</p>
|
||||
<div class="luf-field">
|
||||
<label for="picker-dimension">Fachliche Einordnung</label>
|
||||
<select id="picker-dimension" wire:model.live="pickerDimension">
|
||||
@@ -524,7 +546,7 @@
|
||||
@if ($result['items'] === [])
|
||||
<p class="luf-empty">Nichts gefunden. Ändere die Suche oder erstelle einen neuen Text.</p>
|
||||
@else
|
||||
<ul class="luf-cards">
|
||||
<ul @class(['luf-cards', 'luf-cards-list' => $this->pickerLayout === 'liste'])>
|
||||
@foreach ($result['items'] as $hit)
|
||||
<li wire:key="treffer-{{ $hit['target'] }}">
|
||||
<button type="button" class="luf-card luf-tone-{{ $hit['tone'] ?? 'text' }}" wire:click="$set('pickerSelected', '{{ $hit['target'] }}')" aria-pressed="{{ $this->pickerMatches((string) ($hit['identity'] ?? '')) ? 'true' : 'false' }}">
|
||||
@@ -546,6 +568,9 @@
|
||||
<span class="luf-summary">{{ \Illuminate\Support\Str::limit((string) $hit['summary'], 120) }}</span>
|
||||
@endif
|
||||
<span class="luf-meta">Aktueller Stand · {{ $hit['version_label'] }}</span>
|
||||
@if (filled($hit['visibility'] ?? null))
|
||||
<span class="luf-note">{{ $hit['visibility'] }}</span>
|
||||
@endif
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
@@ -567,7 +592,9 @@
|
||||
<p class="luf-note">Für diese Fassung liegt noch keine abspielbare Datei vor. Ansehen öffnet die vorhandene Vorschau.</p>
|
||||
@endif
|
||||
@endif
|
||||
@if (count($this->pickerVersions()) > 1)
|
||||
@if (($detail['version_label'] ?? '') === 'Ohne Inhaltsfassung')
|
||||
<p class="luf-note">Dieses Medium hat keine Inhaltsfassung. Übernehmen legt keine an.</p>
|
||||
@elseif (count($this->pickerVersions()) > 1)
|
||||
<h3>Fassungen</h3>
|
||||
<p class="luf-note">Standard ist der aktuelle Stand. Eine andere zulässige Fassung wählst du vor dem Übernehmen.</p>
|
||||
<div class="luf-scopes">
|
||||
@@ -578,8 +605,13 @@
|
||||
@else
|
||||
<p class="luf-note">Das ist der aktuelle Stand. Eine weitere zulässige Fassung liegt nicht vor.</p>
|
||||
@endif
|
||||
@if (filled($detail['visibility'] ?? null))
|
||||
<p class="luf-note">{{ $detail['visibility'] }}</p>
|
||||
@endif
|
||||
@if (($detail['version_label'] ?? '') === 'Entwurf')
|
||||
<p class="luf-note">Übernehmen nimmt diesen Entwurf in den Aufbau. Eine Fassung entsteht erst, wenn du das Modul oder Programm freigibst und die gemeinsame Freigabe bestätigst.</p>
|
||||
@elseif (($detail['version_label'] ?? '') === 'Ohne Inhaltsfassung')
|
||||
<p class="luf-note">Übernehmen verweist auf dieses Medium. Es hat keine Inhaltsfassung, und es wird keine angelegt.</p>
|
||||
@else
|
||||
<p class="luf-note">Übernehmen verweist auf diese vorhandene Fassung. Es wird nichts kopiert und keine neue Fassung des Eintrags angelegt.</p>
|
||||
@endif
|
||||
@@ -587,7 +619,14 @@
|
||||
@if ($detail['open_url'])
|
||||
<a class="luf-link" href="{{ $detail['open_url'] }}" target="_blank" rel="noopener">Ansehen</a>
|
||||
@endif
|
||||
<button type="button" class="luf-primary" wire:click="addPart('{{ $detail['target'] }}')">Übernehmen</button>
|
||||
@if ($detail['edit_url'] ?? null)
|
||||
<a class="luf-link" href="{{ $detail['edit_url'] }}">In der Verwaltung öffnen</a>
|
||||
@endif
|
||||
@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'] }}@if (($hit['version_label'] ?? '') === 'Ohne Inhaltsfassung') · ohne Inhaltsfassung @endif
|
||||
</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">
|
||||
Zusätzlich an der aktuellen Inhaltsfassung festhalten. Ohne Haken bleibt die Zuordnung am Medium. 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>
|
||||
@@ -139,6 +139,9 @@
|
||||
.luf-kicker { margin: 0; color: var(--luf-pine); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.78rem; }
|
||||
.luf-blocks, .luf-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; }
|
||||
.luf-cards { grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
|
||||
.luf-cards-list { grid-template-columns: 1fr; }
|
||||
.luf-cards-list .luf-card { flex-direction: row; align-items: stretch; }
|
||||
.luf-cards-list .luf-figure { width: 7.5rem; flex: none; }
|
||||
.luf-block {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
|
||||
@@ -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>
|
||||
@@ -0,0 +1,50 @@
|
||||
<article class="luf-medium luf-tone-{{ $card['typeKey'] }} {{ $list ? 'is-list' : 'is-tile' }}">
|
||||
<a class="luf-medium-figure" href="{{ $card['url'] }}" aria-label="{{ $card['title'] }} ansehen">
|
||||
@if ($card['image'])
|
||||
<img src="{{ $card['image'] }}" alt="{{ $card['imageAlt'] }}">
|
||||
@else
|
||||
@include('filament.media.mark', ['typeKey' => $card['typeKey'], 'type' => $card['type']])
|
||||
@endif
|
||||
@if ($card['imageNote'])
|
||||
<span class="luf-medium-figure-note">{{ $card['imageNote'] }}</span>
|
||||
@endif
|
||||
</a>
|
||||
<div class="luf-medium-body">
|
||||
<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>
|
||||
@endif
|
||||
@if ($card['usageNote'])
|
||||
<p class="luf-medium-copy luf-medium-note"><span class="luf-medium-kicker">Einsatz</span> {{ $card['usageNote'] }}</p>
|
||||
@endif
|
||||
@if ($card['licenseNote'])
|
||||
<p class="luf-medium-copy luf-medium-note"><span class="luf-medium-kicker">Interner Lizenzvermerk</span> {{ $card['licenseNote'] }}</p>
|
||||
@endif
|
||||
<div class="luf-medium-flags">
|
||||
<span class="luf-flag luf-flag-{{ $card['standTone'] }}">{{ $card['stand'] }}</span>
|
||||
@if ($card['draftNote'])
|
||||
<span class="luf-flag luf-flag-draft">{{ $card['draftNote'] }}</span>
|
||||
@endif
|
||||
@if ($card['blockedNote'])
|
||||
<span class="luf-flag luf-flag-blocked">{{ $card['blockedNote'] }}</span>
|
||||
@endif
|
||||
@if ($card['processing'])
|
||||
<span class="luf-flag luf-flag-wait">{{ $card['processing'] }}</span>
|
||||
@endif
|
||||
@if ($card['archived'])
|
||||
<span class="luf-flag luf-flag-quiet">Archiviert</span>
|
||||
@endif
|
||||
@if ($card['versionLabel'])
|
||||
<span class="luf-flag luf-flag-quiet">{{ $card['versionLabel'] }}</span>
|
||||
@endif
|
||||
</div>
|
||||
@include('filament.media.usages', ['card' => $card])
|
||||
<div class="luf-medium-actions">
|
||||
<a class="luf-medium-link" href="{{ $card['url'] }}">Ansehen</a>
|
||||
@if ($card['editUrl'])
|
||||
<a class="luf-medium-link" href="{{ $card['editUrl'] }}">Bearbeiten</a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
@@ -0,0 +1,135 @@
|
||||
@php
|
||||
$fokus = $this->bereich;
|
||||
$editable = \App\Filament\Resources\ContentElements\ContentElementResource::editor();
|
||||
$options = [
|
||||
'kinds' => \App\Domain\Catalog\EditorialContentKind::selectOptions(),
|
||||
'pillars' => \App\Domain\Catalog\Pillar::query()->orderBy('name')->get(['id', 'name']),
|
||||
'dimensions' => \App\Domain\Catalog\EditorialDimension::forSubject($this->getRecord()),
|
||||
];
|
||||
@endphp
|
||||
|
||||
<div>
|
||||
@if ($this->editorialFeedback !== '')
|
||||
<p class="luf-editor-status" role="status">{{ $this->editorialFeedback }}</p>
|
||||
@endif
|
||||
|
||||
@if ($fokus === 'beschreibung')
|
||||
<div class="luf-editor-split">
|
||||
<form wire:submit="saveEditorial">
|
||||
<p class="luf-editor-lead">Karten zeigen den Anzeigenamen und die Kurzbeschreibung. Die ausführliche Beschreibung und der Vermerk bleiben in der Verwaltung.</p>
|
||||
<div class="luf-editor-fields">
|
||||
<label>Arbeitstitel
|
||||
<input type="text" wire:model.live.debounce.300ms="workingTitle" @disabled(! $editable) required>
|
||||
</label>
|
||||
<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>
|
||||
<label>Interner Lizenzvermerk
|
||||
<textarea rows="4" wire:model="licenseNote" @disabled(! $editable)></textarea>
|
||||
</label>
|
||||
<label class="is-wide">Quellenzeile für die Website
|
||||
<textarea rows="2" wire:model="websiteCredit" @disabled(! $editable)></textarea>
|
||||
</label>
|
||||
<label>Alternativtext für die Website
|
||||
<input type="text" wire:model="websiteAlt" @disabled(! $editable)>
|
||||
</label>
|
||||
<label>Inhaltsart
|
||||
<select wire:model.live="kindId" @disabled(! $editable)>
|
||||
<option value="">Keine</option>
|
||||
@foreach ($options['kinds'] as $id => $label)
|
||||
<option value="{{ $id }}">{{ $label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<fieldset>
|
||||
<legend>Fachliche Säulen</legend>
|
||||
<div class="luf-editor-checks">
|
||||
@foreach ($options['pillars'] as $pillar)
|
||||
<label><input type="checkbox" value="{{ $pillar->id }}" wire:model="pillarIds" @disabled(! $editable)> {{ $pillar->name }}</label>
|
||||
@endforeach
|
||||
</div>
|
||||
</fieldset>
|
||||
@foreach ($options['dimensions'] as $dimension)
|
||||
<fieldset>
|
||||
<legend>{{ $dimension->label }}</legend>
|
||||
<div class="luf-editor-checks">
|
||||
@foreach ($dimension->values as $value)
|
||||
<label><input type="checkbox" value="{{ $value->id }}" wire:model="dimensionIds" @disabled(! $editable)> {{ $value->label }}</label>
|
||||
@endforeach
|
||||
</div>
|
||||
</fieldset>
|
||||
@endforeach
|
||||
@if ($editable)
|
||||
<p>
|
||||
<button class="luf-editor-save" type="submit">Speichern</button>
|
||||
@if ($this->websiteIsPublic())
|
||||
<button class="luf-editor-quiet" type="button" wire:click="withdrawWebsite">Website-Freigabe zurücknehmen</button>
|
||||
@else
|
||||
<button class="luf-editor-quiet" type="button" wire:click="releaseForWebsite">Für die Website freigeben</button>
|
||||
@endif
|
||||
</p>
|
||||
<p class="luf-editor-lead">{{ $this->websiteFeedback !== '' ? $this->websiteFeedback : ($this->websiteIsPublic() ? 'Für die Website freigegeben. Öffentliche Seiten lesen nur diese Ableitung.' : 'Noch nicht für die Website freigegeben. Der interne Vermerk bleibt intern.') }}</p>
|
||||
@endif
|
||||
@php($webPages = $this->websitePages())
|
||||
<p class="luf-editor-lead">
|
||||
@if ($webPages === [])
|
||||
Auf keiner Website-Seite als Bild verwendet.
|
||||
@else
|
||||
Als Bild auf der Website verwendet:
|
||||
@foreach ($webPages as $usage)
|
||||
{{ $usage['path'] }} ({{ $usage['published'] ? 'veröffentlicht' : '' }}{{ $usage['published'] && $usage['draft'] ? ', ' : '' }}{{ $usage['draft'] ? 'Entwurf' : '' }}){{ $loop->last ? '' : ',' }}
|
||||
@endforeach
|
||||
@if ($this->websiteIsPublic())
|
||||
– Zurücknehmen entfernt das Bild dort von der öffentlichen Seite.
|
||||
@endif
|
||||
@endif
|
||||
</p>
|
||||
@include('filament.editorial.variants')
|
||||
@php($history = $this->editorialHistory())
|
||||
@if ($history !== [])
|
||||
<details>
|
||||
<summary>Letzte Änderungen</summary>
|
||||
<ul>
|
||||
@foreach ($history as $change)
|
||||
<li>{{ $change['when'] }} · {{ $change['field'] }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</details>
|
||||
@endif
|
||||
</form>
|
||||
@include('filament.media.preview-frame')
|
||||
</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>
|
||||
@include('filament.media.usages', ['card' => $card])
|
||||
@endif
|
||||
|
||||
@if ($fokus === 'vorschau')
|
||||
<p>Die Vorschau nutzt die Website-Karte und die Karte der Bibliothek. Ein Bibliotheksbild ist in der Vorschau sichtbar und damit nicht öffentlich freigegeben. Die ausführliche Beschreibung erscheint auf diesen Karten nicht.</p>
|
||||
@include('filament.media.preview-frame')
|
||||
@endif
|
||||
</div>
|
||||
@@ -0,0 +1,119 @@
|
||||
<style>
|
||||
.luf-editor {
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
color: #1b2838;
|
||||
font-size: 1rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.luf-editor-tabs {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.15rem 0.35rem;
|
||||
border-bottom: 1px solid #c5d2cb;
|
||||
margin: 0 0 1.25rem;
|
||||
}
|
||||
.luf-editor-tabs button {
|
||||
appearance: none;
|
||||
font: inherit;
|
||||
font-weight: 650;
|
||||
color: #1b2838;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
border-bottom: 3px solid transparent;
|
||||
margin: 0 0 -1px;
|
||||
padding: 0.7rem 0.95rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
.luf-editor-tabs button[aria-selected="true"] {
|
||||
color: #0f6e56;
|
||||
background: transparent;
|
||||
border-bottom-color: #0f6e56;
|
||||
}
|
||||
.luf-editor-tabs button:focus-visible {
|
||||
outline: 3px solid #1769aa;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
.luf-editor-lead {
|
||||
margin: 0 0 1rem;
|
||||
color: #3e4c5c;
|
||||
}
|
||||
.luf-editor-split {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(32rem, 1fr) minmax(20rem, 28rem);
|
||||
gap: 1.75rem;
|
||||
align-items: start;
|
||||
}
|
||||
.luf-editor-fields {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0.9rem 1.1rem;
|
||||
}
|
||||
.luf-editor-fields .is-wide { grid-column: 1 / -1; }
|
||||
.luf-editor label {
|
||||
display: grid;
|
||||
gap: 0.3rem;
|
||||
font-weight: 650;
|
||||
}
|
||||
.luf-editor input[type="text"],
|
||||
.luf-editor input[type="search"],
|
||||
.luf-editor textarea,
|
||||
.luf-editor select {
|
||||
font: inherit;
|
||||
font-weight: 450;
|
||||
width: 100%;
|
||||
color: #1b2838;
|
||||
background: #fff;
|
||||
border: 1px solid #c5d2cb;
|
||||
padding: 0.55rem 0.7rem;
|
||||
min-height: 2.75rem;
|
||||
}
|
||||
.luf-editor textarea { min-height: 6.5rem; resize: vertical; }
|
||||
.luf-editor-checks {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.45rem 1.1rem;
|
||||
margin: 0.35rem 0 0;
|
||||
}
|
||||
.luf-editor-checks label {
|
||||
font-weight: 450;
|
||||
grid-auto-flow: column;
|
||||
justify-content: start;
|
||||
align-items: center;
|
||||
}
|
||||
.luf-editor-quiet {
|
||||
font: inherit;
|
||||
font-weight: 650;
|
||||
color: #1b2838;
|
||||
background: #fff;
|
||||
border: 1px solid #c5d2cb;
|
||||
min-height: 2.75rem;
|
||||
padding: 0.55rem 1rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
.luf-editor-save {
|
||||
justify-self: start;
|
||||
font: inherit;
|
||||
font-weight: 650;
|
||||
color: #fff;
|
||||
background: #0f6e56;
|
||||
border: 0;
|
||||
min-height: 2.75rem;
|
||||
padding: 0.55rem 1rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
.luf-editor-status {
|
||||
margin: 0 0 0.8rem;
|
||||
padding: 0.65rem 0.8rem;
|
||||
background: #e7f3ee;
|
||||
border-left: 4px solid #0f6e56;
|
||||
}
|
||||
.luf-live-preview-stage { width: 100%; overflow: hidden; }
|
||||
.luf-live-preview-frame { border: 0; transform-origin: top left; display: block; background: #fff; }
|
||||
@media (max-width: 1100px) {
|
||||
.luf-editor-split { grid-template-columns: 1fr; }
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
.luf-editor-fields { grid-template-columns: 1fr; }
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,259 @@
|
||||
<style>
|
||||
.luf-media {
|
||||
--luf-ink: #1b2838;
|
||||
--luf-pine: #0f6e56;
|
||||
--luf-paper: #f4f7f5;
|
||||
--luf-line: #c5d2cb;
|
||||
--luf-yellow: #e2b43a;
|
||||
--luf-quiet: #3e4c5c;
|
||||
color: var(--luf-ink);
|
||||
font-size: 1rem;
|
||||
line-height: 1.45;
|
||||
min-width: 0;
|
||||
}
|
||||
.luf-media * { box-sizing: border-box; }
|
||||
.luf-media a:focus-visible,
|
||||
.luf-media button:focus-visible,
|
||||
.luf-media input:focus-visible,
|
||||
.luf-media select:focus-visible,
|
||||
.luf-media summary:focus-visible {
|
||||
outline: 3px solid #1769aa;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
.luf-media-bar,
|
||||
.luf-media-reset {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.75rem 1rem;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin: 0 0 0.85rem;
|
||||
}
|
||||
.luf-media-switch { display: flex; flex-wrap: wrap; gap: 0.4rem; }
|
||||
.luf-media-quiet {
|
||||
font: inherit;
|
||||
color: var(--luf-ink);
|
||||
background: #fff;
|
||||
border: 1px solid var(--luf-line);
|
||||
min-height: 2.75rem;
|
||||
padding: 0.35rem 0.8rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
.luf-media-quiet[aria-pressed="true"] {
|
||||
background: var(--luf-ink);
|
||||
color: #fff;
|
||||
border-color: var(--luf-ink);
|
||||
}
|
||||
.luf-media-count { margin: 0; color: var(--luf-quiet); }
|
||||
.luf-media-filters {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr));
|
||||
gap: 0.7rem 0.8rem;
|
||||
margin: 0 0 0.75rem;
|
||||
}
|
||||
.luf-media-field { display: grid; gap: 0.3rem; min-width: 0; }
|
||||
.luf-media-field.is-wide { grid-column: 1 / -1; }
|
||||
@media (min-width: 52rem) {
|
||||
.luf-media-field.is-wide { grid-column: span 2; }
|
||||
}
|
||||
.luf-media-field label { font-weight: 650; }
|
||||
.luf-media input,
|
||||
.luf-media select {
|
||||
width: 100%;
|
||||
min-height: 2.75rem;
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
background: #fff;
|
||||
border: 1px solid var(--luf-line);
|
||||
padding: 0.45rem 0.65rem;
|
||||
}
|
||||
.luf-media-hint,
|
||||
.luf-media-loading {
|
||||
margin: 0 0 0.9rem;
|
||||
color: var(--luf-quiet);
|
||||
}
|
||||
.luf-media-empty {
|
||||
margin: 0 0 0.9rem;
|
||||
padding: 1rem 1.1rem;
|
||||
background: #fff;
|
||||
border: 1px dashed var(--luf-line);
|
||||
color: var(--luf-ink);
|
||||
}
|
||||
.luf-media-grid,
|
||||
.luf-media-rows {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
.luf-media-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(min(100%, 18.5rem), 1fr));
|
||||
gap: 1rem;
|
||||
align-items: stretch;
|
||||
}
|
||||
.luf-media-rows { display: grid; gap: 0.7rem; }
|
||||
.luf-medium {
|
||||
background: #fff;
|
||||
border: 1px solid var(--luf-line);
|
||||
border-top: 4px solid var(--luf-pine);
|
||||
min-width: 0;
|
||||
height: 100%;
|
||||
}
|
||||
.luf-medium.is-tile { display: flex; flex-direction: column; }
|
||||
.luf-medium.is-list {
|
||||
display: grid;
|
||||
grid-template-columns: 7.5rem minmax(0, 1fr);
|
||||
gap: 0.8rem;
|
||||
align-items: start;
|
||||
height: auto;
|
||||
}
|
||||
.luf-tone-film { border-top-color: #1b2838; }
|
||||
.luf-tone-document { border-top-color: #1769aa; }
|
||||
.luf-tone-text { border-top-color: #c4962a; }
|
||||
.luf-tone-audio { border-top-color: #6d4c7d; }
|
||||
.luf-tone-bild { border-top-color: var(--luf-pine); }
|
||||
.luf-medium-figure {
|
||||
display: block;
|
||||
position: relative;
|
||||
aspect-ratio: 16 / 9;
|
||||
background: var(--luf-paper);
|
||||
color: var(--luf-pine);
|
||||
overflow: hidden;
|
||||
text-decoration: none;
|
||||
}
|
||||
.luf-medium.is-list .luf-medium-figure { aspect-ratio: 16 / 10; }
|
||||
.luf-medium-figure img,
|
||||
.luf-medium-mark,
|
||||
.luf-medium-mark svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
}
|
||||
.luf-medium-figure img { object-fit: cover; }
|
||||
.luf-medium-mark {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.luf-medium-mark svg { height: 72%; }
|
||||
.luf-medium-figure-note {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
padding: 0.35rem 0.55rem;
|
||||
background: rgba(27, 40, 56, 0.88);
|
||||
color: #fff;
|
||||
font-size: 0.82rem;
|
||||
}
|
||||
.luf-medium-body {
|
||||
display: grid;
|
||||
gap: 0.4rem;
|
||||
padding: 0.8rem 0.9rem 0.95rem;
|
||||
min-width: 0;
|
||||
}
|
||||
.luf-medium-kind {
|
||||
margin: 0;
|
||||
font-size: 0.78rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
text-transform: uppercase;
|
||||
color: var(--luf-pine);
|
||||
}
|
||||
.luf-medium-title {
|
||||
color: inherit;
|
||||
font-family: Georgia, "Source Serif 4", serif;
|
||||
font-size: 1.28rem;
|
||||
font-weight: 650;
|
||||
letter-spacing: -0.02em;
|
||||
line-height: 1.25;
|
||||
text-decoration: none;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.luf-medium-title:hover { text-decoration: underline; }
|
||||
.luf-medium-copy {
|
||||
margin: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.luf-medium.is-tile .luf-medium-copy {
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 4;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
.luf-medium-note { color: var(--luf-quiet); font-size: 0.92rem; }
|
||||
.luf-medium-kicker { font-weight: 700; color: var(--luf-ink); }
|
||||
.luf-medium-flags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
.luf-flag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 1.7rem;
|
||||
padding: 0.1rem 0.45rem;
|
||||
border: 1px solid var(--luf-line);
|
||||
background: #fff;
|
||||
font-size: 0.86rem;
|
||||
}
|
||||
.luf-flag-ready { background: #e7f3ee; border-color: var(--luf-pine); }
|
||||
.luf-flag-draft { background: #fff8e6; border-color: #c4962a; }
|
||||
.luf-flag-blocked { background: #f8f1ea; border-color: #8a5a2a; }
|
||||
.luf-flag-wait { background: #eef5fb; border-color: #1769aa; }
|
||||
.luf-flag-quiet { color: var(--luf-quiet); }
|
||||
.luf-medium-usage { display: grid; gap: 0.35rem; }
|
||||
.luf-medium-unused,
|
||||
.luf-medium-license { margin: 0; color: var(--luf-quiet); font-size: 0.92rem; }
|
||||
.luf-medium-usage summary {
|
||||
cursor: pointer;
|
||||
min-height: 2.4rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-weight: 650;
|
||||
}
|
||||
.luf-medium-usage ul {
|
||||
list-style: none;
|
||||
margin: 0.2rem 0 0;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
gap: 0.45rem;
|
||||
}
|
||||
.luf-medium-usage li {
|
||||
display: grid;
|
||||
gap: 0.1rem;
|
||||
padding-top: 0.35rem;
|
||||
border-top: 1px solid var(--luf-line);
|
||||
min-width: 0;
|
||||
}
|
||||
.luf-medium-usage a { color: var(--luf-pine); overflow-wrap: anywhere; }
|
||||
.luf-medium-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.75rem 1rem;
|
||||
margin-top: 0.15rem;
|
||||
}
|
||||
.luf-medium-link {
|
||||
color: var(--luf-ink);
|
||||
font-weight: 650;
|
||||
text-underline-offset: 0.18em;
|
||||
}
|
||||
.luf-sr {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
margin: -1px;
|
||||
overflow: hidden;
|
||||
clip: rect(0, 0, 0, 0);
|
||||
border: 0;
|
||||
}
|
||||
@media (max-width: 40rem) {
|
||||
.luf-medium.is-list { grid-template-columns: 5.5rem minmax(0, 1fr); }
|
||||
.luf-medium-title { font-size: 1.12rem; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.luf-media * { scroll-behavior: auto; }
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,144 @@
|
||||
@php
|
||||
$cards = $this->cards();
|
||||
$list = $this->showingList();
|
||||
$count = count($cards);
|
||||
@endphp
|
||||
|
||||
@include('filament.media.library-styles')
|
||||
|
||||
<div class="luf-media">
|
||||
<div class="luf-media-bar">
|
||||
<div class="luf-media-switch" role="group" aria-label="Ansicht">
|
||||
<button type="button" class="luf-media-quiet" wire:click="$set('ansicht', 'kacheln')" aria-pressed="{{ $list ? 'false' : 'true' }}">Kacheln</button>
|
||||
<button type="button" class="luf-media-quiet" wire:click="$set('ansicht', 'liste')" aria-pressed="{{ $list ? 'true' : 'false' }}">Liste</button>
|
||||
</div>
|
||||
<p class="luf-media-count" aria-live="polite">{{ $count === 1 ? '1 Medium' : $count.' Medien' }}</p>
|
||||
</div>
|
||||
|
||||
<div class="luf-media-filters">
|
||||
<div class="luf-media-field is-wide">
|
||||
<label for="medien-suche">Suche</label>
|
||||
<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">Technische Art</label>
|
||||
<select id="medien-art" wire:model.live="art">
|
||||
<option value="">Alle Arten</option>
|
||||
@foreach ($this->typeOptions() as $type)
|
||||
<option value="{{ $type['value'] }}">{{ $type['label'] }}</option>
|
||||
@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">
|
||||
<option value="">Alle Freigaben</option>
|
||||
<option value="freigegeben">Freigegebene Fassung</option>
|
||||
<option value="entwurf">Nur offener Entwurf</option>
|
||||
<option value="ohne">Keine freigegebene Fassung</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="luf-media-field">
|
||||
<label for="medien-entwurf">Entwurf</label>
|
||||
<select id="medien-entwurf" wire:model.live="entwurf">
|
||||
<option value="">Entwurf egal</option>
|
||||
<option value="offen">Offener Entwurf</option>
|
||||
<option value="keiner">Kein offener Entwurf</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="luf-media-field">
|
||||
<label for="medien-fassung">Deaktivierte Fassungen</label>
|
||||
<select id="medien-fassung" wire:model.live="fassung">
|
||||
<option value="">Regulärer Bestand</option>
|
||||
<option value="mit">Mit deaktivierter Fassung</option>
|
||||
<option value="nur">Nur deaktivierte Fassungen</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="luf-media-field">
|
||||
<label for="medien-nutzung">Verwendung</label>
|
||||
<select id="medien-nutzung" wire:model.live="nutzung">
|
||||
<option value="">Verwendung egal</option>
|
||||
<option value="verwendet">Verwendet</option>
|
||||
<option value="unbenutzt">Nicht verwendet</option>
|
||||
</select>
|
||||
</div>
|
||||
@if ($pillars = $this->pillarOptions())
|
||||
<div class="luf-media-field">
|
||||
<label for="medien-saeule">Fachliche Säule</label>
|
||||
<select id="medien-saeule" wire:model.live="saeule">
|
||||
<option value="">Alle Säulen</option>
|
||||
@foreach ($pillars as $pillar)
|
||||
<option value="{{ $pillar['id'] }}">{{ $pillar['name'] }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
@endif
|
||||
@if ($classes = $this->classificationOptions())
|
||||
<div class="luf-media-field">
|
||||
<label for="medien-einordnung">Einordnung</label>
|
||||
<select id="medien-einordnung" wire:model.live="einordnung">
|
||||
<option value="">Alle Einordnungen</option>
|
||||
@foreach ($classes as $class)
|
||||
<option value="{{ $class['id'] }}">{{ $class['label'] }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
@endif
|
||||
<div class="luf-media-field">
|
||||
<label for="medien-verarbeitung">Verarbeitung</label>
|
||||
<select id="medien-verarbeitung" wire:model.live="verarbeitung">
|
||||
<option value="">Verarbeitung egal</option>
|
||||
<option value="fehler">Verarbeitungsfehler</option>
|
||||
<option value="uebernahme">Datei wird übernommen</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="luf-media-field">
|
||||
<label for="medien-archiv">Archiv</label>
|
||||
<select id="medien-archiv" wire:model.live="archiv">
|
||||
<option value="aktiv">Aktive Medien</option>
|
||||
<option value="archiviert">Archivierte Medien</option>
|
||||
<option value="alle">Auch archivierte</option>
|
||||
</select>
|
||||
</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. 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">
|
||||
<button type="button" class="luf-media-quiet" wire:click="resetFilters">Filter zurücksetzen</button>
|
||||
</p>
|
||||
@endif
|
||||
|
||||
<p class="luf-media-loading" wire:loading.delay role="status">Die Übersicht wird aktualisiert.</p>
|
||||
|
||||
<div wire:loading.delay.class="is-pending" aria-busy="false">
|
||||
@if ($cards === [])
|
||||
<div class="luf-media-empty">
|
||||
@if ($this->filtersActive())
|
||||
<p>Keine Medien entsprechen der Auswahl.</p>
|
||||
<button type="button" class="luf-media-quiet" wire:click="resetFilters">Filter zurücksetzen</button>
|
||||
@else
|
||||
<p>Noch keine Medien im regulären Bestand.</p>
|
||||
@endif
|
||||
</div>
|
||||
@else
|
||||
<ul class="{{ $list ? 'luf-media-rows' : 'luf-media-grid' }}" data-ansicht="{{ $list ? 'liste' : 'kacheln' }}">
|
||||
@foreach ($cards as $card)
|
||||
<li wire:key="medium-{{ $card['id'] }}">
|
||||
@include('filament.media.card', ['card' => $card, 'list' => $list])
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,34 @@
|
||||
<span class="luf-medium-mark" data-fallback="{{ $typeKey }}" aria-hidden="true">
|
||||
@switch($typeKey)
|
||||
@case('film')
|
||||
<svg viewBox="0 0 160 90">
|
||||
<rect x="18" y="22" width="124" height="46" fill="none" stroke="currentColor" stroke-width="3"/>
|
||||
<path d="M72 35 L98 45 L72 55 Z" fill="currentColor"/>
|
||||
</svg>
|
||||
@break
|
||||
@case('audio')
|
||||
<svg viewBox="0 0 160 90">
|
||||
<path d="M30 45 H46 L66 28 V62 L46 45 Z" fill="none" stroke="currentColor" stroke-width="3"/>
|
||||
<path d="M80 34 Q96 45 80 56 M96 26 Q122 45 96 64" fill="none" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
@break
|
||||
@case('bild')
|
||||
<svg viewBox="0 0 160 90">
|
||||
<rect x="22" y="18" width="116" height="54" fill="none" stroke="currentColor" stroke-width="3"/>
|
||||
<circle cx="58" cy="38" r="7" fill="none" stroke="currentColor" stroke-width="3"/>
|
||||
<path d="M34 62 L62 44 L84 58 L104 40 L126 62" fill="none" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
@break
|
||||
@case('document')
|
||||
<svg viewBox="0 0 160 90">
|
||||
<path d="M58 16 H96 L112 32 V74 H58 Z" fill="none" stroke="currentColor" stroke-width="3"/>
|
||||
<path d="M96 16 V32 H112 M70 46 H100 M70 58 H100" fill="none" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
@break
|
||||
@default
|
||||
<svg viewBox="0 0 160 90">
|
||||
<path d="M36 28 H124 M36 45 H124 M36 62 H96" fill="none" stroke="currentColor" stroke-width="3"/>
|
||||
</svg>
|
||||
@endswitch
|
||||
<span class="luf-sr">{{ $type }}</span>
|
||||
</span>
|
||||
@@ -0,0 +1,19 @@
|
||||
<div class="luf-ws">
|
||||
<div class="luf-scopes" role="group" aria-label="Darstellung">
|
||||
<button type="button" wire:click="$set('previewSurface', 'website')" aria-pressed="{{ $this->previewSurface === 'website' ? 'true' : 'false' }}">Website-Karte</button>
|
||||
<button type="button" wire:click="$set('previewSurface', 'bibliothek')" aria-pressed="{{ $this->previewSurface === 'bibliothek' ? 'true' : 'false' }}">Bibliothek</button>
|
||||
</div>
|
||||
<div class="luf-scopes" role="group" aria-label="Breite">
|
||||
<button type="button" wire:click="$set('previewWidth', '640')" aria-pressed="{{ $this->previewWidth === '640' ? 'true' : 'false' }}">Desktop</button>
|
||||
<button type="button" wire:click="$set('previewWidth', '390')" aria-pressed="{{ $this->previewWidth === '390' ? 'true' : 'false' }}">Mobil</button>
|
||||
</div>
|
||||
@include('filament.cms.widget-live-preview', [
|
||||
'html' => $this->previewHtml(),
|
||||
'stylesheets' => \App\Filament\Support\WidgetEditor::previewStylesheets(),
|
||||
'width' => (int) $this->previewWidth,
|
||||
'bodyClass' => $this->previewSurface === 'bibliothek' ? 'member' : '',
|
||||
'caption' => $this->previewSurface === 'bibliothek'
|
||||
? 'Bibliothekskarte bei '.$this->previewWidth.' px. Dieselbe Karte wie im Mitgliederbereich.'
|
||||
: 'Website-Karte bei '.$this->previewWidth.' px. Dieselbe Karte wie im öffentlichen Auftritt. Das Bibliotheksbild ist nur hier sichtbar.',
|
||||
])
|
||||
</div>
|
||||
@@ -0,0 +1,21 @@
|
||||
<div class="luf-medium-usage">
|
||||
@if ($card['usages'] === [])
|
||||
<p class="luf-medium-unused">{{ $card['usageLabel'] }}</p>
|
||||
@else
|
||||
<details>
|
||||
<summary>{{ $card['usageLabel'] }}</summary>
|
||||
<ul>
|
||||
@foreach ($card['usages'] as $usage)
|
||||
<li>
|
||||
<span class="luf-medium-kicker">{{ $usage['type'] }}</span>
|
||||
<a href="{{ $usage['url'] }}">{{ $usage['name'] }}</a>
|
||||
<span>Medium {{ $usage['mediumVersion'] }}, eingesetzt in {{ $usage['hostVersion'] }}@if ($usage['roles'] !== []) · {{ implode(', ', $usage['roles']) }}@endif</span>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
</details>
|
||||
@endif
|
||||
@if ($card['licenseText'])
|
||||
<p class="luf-medium-license">{{ $card['licenseText'] }}</p>
|
||||
@endif
|
||||
</div>
|
||||
@@ -1,8 +1,30 @@
|
||||
@php
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
$fokus = $this->bereich;
|
||||
@endphp
|
||||
|
||||
<div class="luf-editor">
|
||||
@include('filament.media.library-styles')
|
||||
@include('filament.media.editor-styles')
|
||||
|
||||
<nav class="luf-editor-tabs" role="tablist" aria-label="Bereiche des Mediums">
|
||||
@foreach ([
|
||||
'beschreibung' => 'Beschreibung',
|
||||
'praesentation' => 'Präsentation',
|
||||
'inhalt' => 'Inhalt',
|
||||
'fassungen' => 'Fassungen',
|
||||
'verwendung' => 'Verwendung',
|
||||
'vorschau' => 'Vorschau',
|
||||
] as $value => $label)
|
||||
<button type="button" role="tab" wire:click="$set('bereich', '{{ $value }}')" aria-selected="{{ $fokus === $value ? 'true' : 'false' }}">{{ $label }}</button>
|
||||
@endforeach
|
||||
</nav>
|
||||
|
||||
@if (in_array($fokus, ['beschreibung', 'praesentation', 'verwendung', 'vorschau'], true))
|
||||
@include('filament.media.editor-panels')
|
||||
@else
|
||||
<div style="display: grid; gap: 1.5rem;">
|
||||
@if ($fokus !== 'fassungen')
|
||||
<section style="display: grid; gap: 0.75rem;">
|
||||
<h2 style="font-size: 1.125rem; font-weight: 600;">{{ $element->working_title }}</h2>
|
||||
@if (filled($element->description))
|
||||
@@ -60,6 +82,7 @@
|
||||
@endif
|
||||
</section>
|
||||
@endif
|
||||
@endif
|
||||
|
||||
<section style="display: grid; gap: 0.75rem;">
|
||||
@if ($shown === null)
|
||||
@@ -127,7 +150,7 @@
|
||||
@endif
|
||||
</section>
|
||||
|
||||
@if ($usage !== [])
|
||||
@if ($fokus !== 'fassungen' && $usage !== [])
|
||||
<section style="display: grid; gap: 0.35rem;">
|
||||
<h2 style="font-size: 1.125rem; font-weight: 600;">Verwendung</h2>
|
||||
@foreach ($usage as $line)
|
||||
@@ -136,3 +159,31 @@
|
||||
</section>
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<script>
|
||||
window.lufLivePreview = window.lufLivePreview || function (frame) {
|
||||
const stage = frame.parentElement;
|
||||
const width = Number(frame.dataset.width) || 640;
|
||||
const fit = () => {
|
||||
const doc = frame.contentDocument;
|
||||
if (!doc || !doc.documentElement || !stage) return;
|
||||
const scale = Math.min(1, stage.clientWidth / width);
|
||||
frame.style.width = width + 'px';
|
||||
const height = doc.documentElement.scrollHeight;
|
||||
frame.style.height = height + 'px';
|
||||
frame.style.transform = 'scale(' + scale + ')';
|
||||
stage.style.height = Math.ceil(height * scale) + 'px';
|
||||
};
|
||||
fit();
|
||||
try {
|
||||
const doc = frame.contentDocument;
|
||||
doc.fonts?.ready.then(fit);
|
||||
if (window.ResizeObserver) {
|
||||
new ResizeObserver(fit).observe(doc.body);
|
||||
new ResizeObserver(fit).observe(stage);
|
||||
}
|
||||
} catch (error) {}
|
||||
};
|
||||
</script>
|
||||
</div>
|
||||
@@ -35,3 +35,4 @@
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
@include('widgets.partials.image-notice')
|
||||
@@ -14,7 +14,7 @@
|
||||
<div class="lf-hero lf-hero--{{ $layout }} lf-hero--height-{{ $heightClass }} lf-hero--accent-{{ $accent }}"
|
||||
style="--lf-hero-focus-x: {{ $focus['x'] }}%; --lf-hero-focus-y: {{ $focus['y'] }}%">
|
||||
@if ($layout === 'photo-split' && $imageUrl)
|
||||
<img class="lf-hero__photo" src="{{ $imageUrl }}" alt="{{ $data['alt'] ?? '' }}" {!! $loading !!} decoding="async">
|
||||
<img class="lf-hero__photo" src="{{ $imageUrl }}" alt="{{ $imageAlt ?? '' }}" {!! $loading !!} decoding="async">
|
||||
@endif
|
||||
<div class="lf-hero__inner">
|
||||
<div class="lf-hero__copy">
|
||||
@@ -43,3 +43,4 @@
|
||||
<span class="lf-hero__bottom" aria-hidden="true"></span>
|
||||
</div>
|
||||
</div>
|
||||
@include('widgets.partials.image-notice')
|
||||
@@ -40,8 +40,9 @@
|
||||
</div>
|
||||
@if ($imageUrl)
|
||||
<div class="lf-bt__media">
|
||||
<img class="lf-bt__image" src="{{ $imageUrl }}" alt="{{ $data['alt'] ?? '' }}" @if (! empty($first)) loading="eager" fetchpriority="high" @else loading="lazy" @endif decoding="async">
|
||||
<img class="lf-bt__image" src="{{ $imageUrl }}" alt="{{ $imageAlt ?? '' }}" @if (! empty($first)) loading="eager" fetchpriority="high" @else loading="lazy" @endif decoding="async">
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@include('widgets.partials.image-notice')
|
||||
@@ -0,0 +1,4 @@
|
||||
{{-- Nur Redaktionsvorschau: Das gewählte Bild erscheint öffentlich nicht (fehlende Website-Freigabe, Verarbeitung). --}}
|
||||
@if (! empty($imageNotice) && $context->preview)
|
||||
<p class="preview-note">{{ $imageNotice }}</p>
|
||||
@endif
|
||||
@@ -1,18 +1,32 @@
|
||||
{{--
|
||||
Premium-Karte (Brand-UI-Kit v1.7, Entwurf zur visuellen Freigabe) für Themen-, Medien- und Programmkarten.
|
||||
Premium-Karte (Brand-UI-Kit v1.7, Entwurf zur visuellen Freigabe) für Themen-, Medien-, Material- und Programmkarten.
|
||||
Alle Texte und das Linkziel kommen aus $subject (Fachdaten zur Laufzeit, PublicCatalogReader/PublicMaterialReader);
|
||||
redaktionell sind nur Bild, Alternativtext, Bildausschnitt, Beschriftung der Aktion und Hinweis.
|
||||
Eine Karte, ein expliziter Link, kein über die ganze Karte gestreckter Link. Breitenabhängig über @container slot.
|
||||
redaktionell sind nur Kartenbild, Alternativtext, Bildausschnitt, Beschriftung der Aktion und Hinweis.
|
||||
|
||||
Bildbereich, in dieser Reihenfolge:
|
||||
1. Kartenbild aus dem öffentlichen Website-Bereich (Reiter „Medien“) – öffentlich und in der Vorschau.
|
||||
2. Nur Redaktionsvorschau: Vorschaubild der Bibliothek (Filmstandbild, Modulvorschau), deutlich als nicht
|
||||
öffentlich markiert. Es hat keine Freigabe für die Website und wird öffentlich nie ausgegeben.
|
||||
3. Tafel nach Fachobjekt: Programm/Modul (Navy), Film (Filmtafel), Material (Materialsymbol); Thema ohne Bildbereich.
|
||||
Hinweise auf fehlende Inhalte stehen nur in der Redaktionsvorschau, öffentlich nie.
|
||||
--}}
|
||||
@if ($subject === null)
|
||||
@if ($context->preview)
|
||||
<p class="preview-note">Kein Objekt verknüpft, oder das verknüpfte Objekt ist nicht mehr veröffentlicht beziehungsweise freigegeben. Öffentlich erscheint diese Karte nicht.</p>
|
||||
<p class="preview-note">Kein Objekt verknüpft, oder das verknüpfte Objekt ist archiviert beziehungsweise gesperrt. Öffentlich erscheint diese Karte nicht.</p>
|
||||
@endif
|
||||
@elseif ($subject->public || $context->preview)
|
||||
@php
|
||||
$hasPanel = $cardStyle === 'catalog' && $imageUrl === null;
|
||||
$libraryImage = $imageUrl === null && $context->preview ? $subject->previewImage : null;
|
||||
$panel = $imageUrl === null && $libraryImage === null ? $subject->visual : null;
|
||||
$action = $show['action'] && $subject->url !== null ? ['url' => $subject->url, 'label' => $actionLabel] : null;
|
||||
$meta = $show['meta'] ? $subject->meta : [];
|
||||
$hints = $subject->missing;
|
||||
$panelName = ['catalog' => 'die Navy-Tafel', 'film' => 'die Filmtafel', 'material' => 'das Materialsymbol'][$subject->visual] ?? 'die Karte ohne Bild';
|
||||
if ($context->preview && $imageUrl === null) {
|
||||
$hints[] = $subject->previewImage !== null
|
||||
? 'Das Vorschaubild der Bibliothek ist nicht für die Website freigegeben; öffentlich erscheint stattdessen '.$panelName.'. Ein freigegebenes Motiv kann im Reiter „Medien“ als Kartenbild gewählt werden.'
|
||||
: 'Kein Kartenbild gewählt; öffentlich erscheint '.$panelName.' (Kartenbild im Reiter „Medien“).';
|
||||
}
|
||||
@endphp
|
||||
<article @class([
|
||||
'lf-pc',
|
||||
@@ -20,19 +34,27 @@
|
||||
'lf-pc--'.$format,
|
||||
'lf-pc--'.$fit,
|
||||
'lf-pc--stacked' => $stacked,
|
||||
'lf-pc--without-visual' => $imageUrl === null && ! $hasPanel,
|
||||
'lf-pc--without-visual' => $imageUrl === null && $libraryImage === null && $panel === null,
|
||||
'lf-pc--internal' => ! $subject->public,
|
||||
]) style="--pc-focus-x: {{ $focus['x'] }}%; --pc-focus-y: {{ $focus['y'] }}%">
|
||||
@if ($imageUrl !== null)
|
||||
@if ($imageUrl !== null || $libraryImage !== null)
|
||||
<div class="lf-pc__visual">
|
||||
<img class="lf-pc__image" src="{{ $imageUrl }}" alt="{{ $alt }}" loading="lazy" decoding="async">
|
||||
<img class="lf-pc__image" src="{{ $imageUrl ?? $libraryImage }}" alt="{{ $imageUrl !== null ? $alt : '' }}" loading="lazy" decoding="async">
|
||||
@if ($show['kind'] && $subject->badge !== null)
|
||||
<span class="lf-pc__badge">{{ $subject->badge }}</span>
|
||||
@endif
|
||||
@if ($libraryImage !== null)
|
||||
<span class="lf-pc__library-flag">Bibliotheksbild · nur Vorschau</span>
|
||||
@endif
|
||||
</div>
|
||||
@elseif ($hasPanel)
|
||||
<div class="lf-pc__panel" aria-hidden="true">
|
||||
<span class="lf-pc__panel-label">{{ $subject->kind }}</span>
|
||||
@elseif ($panel !== null)
|
||||
<div class="lf-pc__panel lf-pc__panel--{{ $panel }}" aria-hidden="true">
|
||||
@if ($panel === 'film')
|
||||
<svg class="lf-pc__panel-icon" viewBox="0 0 48 48" focusable="false"><rect x="6" y="10" width="36" height="28" rx="4" fill="none" stroke="currentColor" stroke-width="3"/><path d="M6 17h36M6 31h36M14 10v7M22 10v7M30 10v7M38 10v7M14 31v7M22 31v7M30 31v7M38 31v7" stroke="currentColor" stroke-width="2.5"/></svg>
|
||||
@elseif ($panel === 'material')
|
||||
<svg class="lf-pc__panel-icon" viewBox="0 0 48 48" focusable="false"><path d="M12 5h17l9 9v29H12z" fill="none" stroke="currentColor" stroke-width="3" stroke-linejoin="round"/><path d="M29 5v9h9M18 24h14M18 30h14M18 36h9" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>
|
||||
@endif
|
||||
<span class="lf-pc__panel-label">{{ $subject->visualLabel ?? $subject->kind }}</span>
|
||||
<x-brand.underline class="lf-pc__panel-accent" />
|
||||
</div>
|
||||
@endif
|
||||
@@ -61,9 +83,26 @@
|
||||
@endif
|
||||
</div>
|
||||
@endif
|
||||
@if (! $subject->public && $subject->notice !== null)
|
||||
<p class="preview-note">{{ $subject->notice }}</p>
|
||||
@if ($context->preview && (! $subject->public || $hints !== []))
|
||||
@unless ($subject->public)
|
||||
<p class="lf-pc__private-flag">Nur Redaktionsvorschau</p>
|
||||
@endunless
|
||||
<details class="preview-note lf-pc__editorial">
|
||||
<summary>Hinweise für die Redaktion ({{ count($hints) + ($subject->public ? 0 : 1) }})</summary>
|
||||
@if (! $subject->public && $subject->notice !== null)
|
||||
<p>{{ $subject->notice }}</p>
|
||||
@endif
|
||||
@if ($hints !== [])
|
||||
<p>Für eine vollständige Karte fehlt:</p>
|
||||
<ul>
|
||||
@foreach ($hints as $hint)
|
||||
<li>{{ $hint }}</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</details>
|
||||
@endif
|
||||
</div>
|
||||
</article>
|
||||
@include('widgets.partials.image-notice')
|
||||
@endif
|
||||
@@ -13,6 +13,7 @@
|
||||
use App\Http\Controllers\PublicCatalogController;
|
||||
use App\Http\Controllers\PublicMediaController;
|
||||
use App\Http\Controllers\ThemeController;
|
||||
use App\Http\Controllers\WebsiteMediaController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/', [PageController::class, 'home'])->name('home');
|
||||
@@ -22,6 +23,7 @@
|
||||
Route::get('/programme/{composition}', [PublicCatalogController::class, 'program'])->name('public.program');
|
||||
Route::get('/themen/{slug}', [ThemeController::class, 'show'])->name('theme')->where('slug', '[a-z0-9]+(?:-[a-z0-9]+)*');
|
||||
Route::get('/medien/{path}', [PublicMediaController::class, 'show'])->where('path', '.*')->name('media.public');
|
||||
Route::get('/website-medien/{element}', [WebsiteMediaController::class, 'show'])->whereNumber('element')->name('website.media');
|
||||
|
||||
Route::middleware('guest')->group(function () {
|
||||
Route::get('/registrieren', [RegistrationController::class, 'create'])->name('register');
|
||||
|
||||
@@ -96,7 +96,7 @@ public function test_catalog_pages_show_contents_packages_and_resolved_rights():
|
||||
$sheet->load('element');
|
||||
|
||||
$this->actingAs($editor, 'staff')
|
||||
->get(ContentElementResource::getUrl('view', ['record' => $sheet->element]))
|
||||
->get(ContentElementResource::getUrl('view', ['record' => $sheet->element]).'?bereich=inhalt')
|
||||
->assertOk()
|
||||
->assertSee('Hinweis für die Prüfung.')
|
||||
->assertSee('Fassung 1')
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\PillarService;
|
||||
use App\Domain\Cms\NavigationItem;
|
||||
use App\Domain\Cms\Page;
|
||||
@@ -269,15 +270,15 @@ public function test_unsafe_link_is_reported_at_the_section_and_nothing_is_saved
|
||||
|
||||
public function test_errors_found_only_by_the_registry_are_announced_with_the_section(): void
|
||||
{
|
||||
Storage::fake('media_public');
|
||||
Storage::fake('cms_incoming');
|
||||
Storage::disk('media_public')->put('cms/bild.jpg', 'bild');
|
||||
// Bewusst geändert: Der Alternativtext ist keine Pflicht mehr (er gehört zum Medium). Fehler, den nur die Registry
|
||||
// findet: ein Medium, das kein Website-Bild ist.
|
||||
$film = app(ContentService::class)->createElement('film', 'film', 'Ein Film');
|
||||
$page = Page::query()->where('path', '/')->firstOrFail();
|
||||
$revisions = $page->revisions()->count();
|
||||
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
|
||||
$state = $component->get('data.sections');
|
||||
$state[(string) Str::uuid()] = $this->sectionState('u4', [
|
||||
['type' => 'hero', 'data' => ['variant' => 'photo_split', 'data' => ['heading' => 'Mit Bild'], 'refs' => ['image' => 'cms/bild.jpg']]],
|
||||
['type' => 'hero', 'data' => ['variant' => 'photo_split', 'data' => ['heading' => 'Mit Bild'], 'refs' => ['image' => $film->id]]],
|
||||
]);
|
||||
|
||||
$component->set('data.sections', $state)
|
||||
|
||||
@@ -61,7 +61,7 @@ public function test_the_three_card_types_are_registered_with_the_layout_contrac
|
||||
}
|
||||
|
||||
$this->assertArrayNotHasKey('show_kind', $registry->get('program_card')->settingOptions(), 'Programm oder Modul bleibt immer benannt.');
|
||||
$this->assertArrayNotHasKey('show_summary', $registry->get('media_card')->settingOptions(), 'Medienkarten zeigen keine Kurzbeschreibung.');
|
||||
$this->assertArrayHasKey('show_summary', $registry->get('media_card')->settingOptions(), 'Medienkarten zeigen die Kurzbeschreibung des Mediums.');
|
||||
}
|
||||
|
||||
public function test_topic_card_shows_a_published_theme_from_the_master_data_only(): void
|
||||
@@ -141,61 +141,149 @@ public function test_program_card_lists_the_number_of_modules_of_the_shown_versi
|
||||
public function test_media_card_is_public_only_as_part_of_a_public_program_and_never_releases_the_medium(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$kind = fn (string $slug) => EditorialContentKind::query()->where('slug', $slug)->value('id');
|
||||
$film = $content->createElement('film', 'film', 'Denkpause Rohschnitt');
|
||||
$film->update(['display_title' => 'Eine Pause, die stark macht', 'summary' => 'Gemeinsam innehalten und über gute nächste Schritte sprechen.', 'thumbnail_path' => 'vorschau/denkpause.jpg']);
|
||||
$film->update(['display_title' => 'Eine Pause, die stark macht', 'summary' => 'Gemeinsam innehalten und über gute nächste Schritte sprechen.', 'description' => 'Interne Beschreibung für die Bibliothek', 'usage_note' => 'Einsatzhinweis intern', 'license_note' => 'Lizenzvermerk intern', 'thumbnail_path' => 'vorschau/denkpause.jpg']);
|
||||
$filmVersion = $content->publishElementVersion($film, 'Filmbeschreibung');
|
||||
$sheet = $content->createElement('text', 'pdf', 'Arbeitsblatt intern');
|
||||
$sheet->update(['editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'merkblatt')->value('id')]);
|
||||
$content->publishElementVersion($sheet, 'Inhalt');
|
||||
$sheet = $content->createElement('text', 'pdf', 'Merkblatt Grenzen');
|
||||
$sheet->update(['editorial_content_kind_id' => $kind('merkblatt'), 'summary' => 'Ein Blatt für Eltern.']);
|
||||
$sheetVersion = $content->publishElementVersion($sheet, 'Inhalt');
|
||||
$guide = $content->createElement('text', 'text', 'Traineranleitung Abstand');
|
||||
$guide->update(['editorial_content_kind_id' => $kind('traineranleitung')]);
|
||||
$guideVersion = $content->publishElementVersion($guide, 'Vertraulich');
|
||||
$loose = $content->createElement('text', 'pdf', 'Arbeitsblatt ohne Programm');
|
||||
$content->publishElementVersion($loose, 'Inhalt');
|
||||
|
||||
$composition = $content->createComposition('Programm Denkpause');
|
||||
$composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'programm')->value('id');
|
||||
$composition->editorial_content_kind_id = $kind('programm');
|
||||
$composition->save();
|
||||
$version = $content->publishComposition($composition, [['role' => 'Film', 'target' => $filmVersion]]);
|
||||
$version = $content->publishComposition($composition, [
|
||||
['role' => 'Film', 'target' => $filmVersion],
|
||||
['role' => 'Merkblatt', 'target' => $sheetVersion],
|
||||
['role' => 'Anleitung', 'target' => $guideVersion],
|
||||
]);
|
||||
app(CompositionDisplayRelease::class)->release($version, User::factory()->create());
|
||||
|
||||
$revision = $this->publish('/medienkarte', [$this->section('u2_2', [
|
||||
$this->card('media_card', ['element' => $film->id], data: ['note' => 'Für die nächste Kursstunde.']),
|
||||
$this->card('media_card', ['element' => $sheet->id]),
|
||||
])]);
|
||||
$revision = $this->publish('/medienkarte', [
|
||||
$this->section('u2_2', [
|
||||
$this->card('media_card', ['element' => $film->id], data: ['note' => 'Für die nächste Kursstunde.']),
|
||||
$this->card('media_card', ['element' => $sheet->id]),
|
||||
]),
|
||||
$this->section('u2_2', [
|
||||
$this->card('media_card', ['element' => $guide->id]),
|
||||
$this->card('media_card', ['element' => $loose->id]),
|
||||
]),
|
||||
]);
|
||||
|
||||
$html = $this->get('/medienkarte')->assertOk()->getContent();
|
||||
$main = $this->mainHtml($html);
|
||||
$main = $this->mainHtml($this->get('/medienkarte')->assertOk()->getContent());
|
||||
// Film: Medienkarte mit Filmtafel, Kurzbeschreibung, Medientyp, Programmbezug und Hinweis auf den geschützten Film.
|
||||
$this->assertStringContainsString('lf-pc lf-pc--media', $main);
|
||||
$this->assertStringContainsString('lf-pc__panel lf-pc__panel--film', $main);
|
||||
$this->assertStringContainsString('Eine Pause, die stark macht', $main);
|
||||
$this->assertStringContainsString('<p class="lf-pc__kind">Film</p>', $main);
|
||||
$this->assertStringContainsString('Gemeinsam innehalten und über gute nächste Schritte sprechen.', $main);
|
||||
$this->assertStringContainsString('<li>Im Programm „Programm Denkpause“</li>', $main);
|
||||
$this->assertStringContainsString('<li>Vollständiger Film nur mit Lizenz im Mitgliederbereich</li>', $main);
|
||||
$this->assertStringContainsString('href="'.route('public.program', $composition->id).'">Im Programm ansehen</a>', $main);
|
||||
$this->assertStringContainsString('Für die nächste Kursstunde.', $main);
|
||||
$this->assertStringNotContainsString('Gemeinsam innehalten', $main, 'Die Kurzbeschreibung eines Elements ist nirgends öffentlich und bleibt aus.');
|
||||
$this->assertStringNotContainsString('Arbeitsblatt intern', $main, 'Nicht Teil eines öffentlichen Programms: öffentlich nicht sichtbar.');
|
||||
// Material: eigene Darstellung mit Materialsymbol.
|
||||
$this->assertStringContainsString('lf-pc lf-pc--material', $main);
|
||||
$this->assertStringContainsString('lf-pc__panel lf-pc__panel--material', $main);
|
||||
$this->assertStringContainsString('<p class="lf-pc__kind">Merkblatt</p>', $main);
|
||||
$this->assertStringContainsString('Ein Blatt für Eltern.', $main);
|
||||
// Vertraulich und nicht öffentlich genannt: öffentlich nicht sichtbar.
|
||||
$this->assertStringNotContainsString('Traineranleitung Abstand', $main, 'Traineranleitungen erscheinen nie öffentlich.');
|
||||
$this->assertStringNotContainsString('Arbeitsblatt ohne Programm', $main);
|
||||
|
||||
foreach (['vorschau/denkpause.jpg', '/bereich/', '/redaktion/', '/ausgabe/', '<video', 'download', 'Filmbeschreibung'] as $protected) {
|
||||
$this->assertStringNotContainsString($protected, $main, "Keine geschützte Ausgabe über die Karte: $protected");
|
||||
foreach (['vorschau/denkpause.jpg', '/bereich/', '/redaktion/', '/ausgabe/', '<video', 'download', 'Filmbeschreibung', 'Interne Beschreibung', 'Einsatzhinweis intern', 'Lizenzvermerk intern', 'Bibliotheksbild', 'Für eine vollständige Karte', 'preview-note'] as $protected) {
|
||||
$this->assertStringNotContainsString($protected, $main, "Keine geschützte oder redaktionelle Ausgabe über die Karte: $protected");
|
||||
}
|
||||
|
||||
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
||||
$this->assertStringContainsString('Arbeitsblatt intern', $preview);
|
||||
$this->assertStringContainsString('<p class="lf-pc__kind">Merkblatt</p>', $preview);
|
||||
$this->assertStringContainsString('Dieses Medium gehört zu keinem öffentlich gezeigten Programm', $preview);
|
||||
// Redaktionsvorschau: Filmstandbild der Bibliothek, deutlich als nicht öffentlich markiert, und Hinweise auf Fehlendes.
|
||||
$this->assertStringContainsString('src="'.route('editorial.card', ['kind' => 'element', 'subject' => $film->id]).'"', $preview);
|
||||
$this->assertStringContainsString('Bibliotheksbild · nur Vorschau', $preview);
|
||||
$this->assertStringContainsString('Das Vorschaubild der Bibliothek ist nicht für die Website freigegeben', $preview);
|
||||
$this->assertStringContainsString('Traineranleitung Abstand', $preview);
|
||||
$this->assertStringContainsString('Traineranleitungen erscheinen nie öffentlich.', $preview);
|
||||
$this->assertStringContainsString('Arbeitsblatt ohne Programm', $preview);
|
||||
$this->assertStringContainsString('Das Medium gehört zu keinem öffentlich gezeigten Programm', $preview);
|
||||
|
||||
$film->update(['archived_at' => now()]);
|
||||
$this->get('/medienkarte')->assertOk()->assertDontSee('Eine Pause, die stark macht');
|
||||
}
|
||||
|
||||
public function test_draft_media_and_unreleased_compositions_can_be_prepared_but_stay_private(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$draftFilm = $content->createElement('film', 'film', 'Felix beim Onkel');
|
||||
$content->draftElementVersion($draftFilm, 'Entwurf');
|
||||
$programComposition = $content->createComposition('Programm ohne Freigabe');
|
||||
$programComposition->forceFill(['editorial_content_kind_id' => EditorialContentKind::query()->where('slug', 'programm')->value('id'), 'thumbnail_path' => 'vorschau/programm.jpg'])->save();
|
||||
$program = $content->publishComposition(
|
||||
$programComposition,
|
||||
[['role' => 'Text', 'target' => $content->publishElementVersion($content->createElement('text', 'text', 'Programmblatt'), 'Inhalt')]],
|
||||
didactic: ['learning_goal' => 'Kinder erkennen eigene Grenzen.', 'duration_minutes' => 25],
|
||||
);
|
||||
$module = $this->composition('Modul Grenzen', 'modul');
|
||||
|
||||
$revision = $this->publish('/vorbereitet', [$this->section('u1_1_2', [
|
||||
$this->card('media_card', ['element' => $draftFilm->id]),
|
||||
$this->card('program_card', ['composition' => $module->composition_id]),
|
||||
$this->card('program_card', ['composition' => $program->composition_id]),
|
||||
])]);
|
||||
|
||||
$this->get('/vorbereitet')->assertOk()->assertDontSee('lf-pc', false);
|
||||
|
||||
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
||||
$this->assertStringContainsString('Felix beim Onkel', $preview);
|
||||
$this->assertStringContainsString('Das Medium hat noch keine bereitgestellte Fassung.', $preview);
|
||||
$this->assertStringContainsString('Das Programm hat keine Anzeigefreigabe.', $preview);
|
||||
$this->assertStringContainsString('Kinder erkennen eigene Grenzen.', $preview, 'Ohne Kurzbeschreibung zeigt die Karte das Lernziel.');
|
||||
$this->assertStringContainsString('<li>Dauer 25 Min.</li>', $preview);
|
||||
$this->assertStringContainsString('src="'.route('editorial.card', ['kind' => 'komposition', 'subject' => $program->composition_id]).'"', $preview);
|
||||
$this->assertStringContainsString('Für Module gibt es noch keine öffentliche Seitenart', $preview);
|
||||
$this->assertStringNotContainsString(route('public.program', $module->composition_id), $preview, 'Module erhalten keinen künstlichen Link.');
|
||||
}
|
||||
|
||||
public function test_unpublished_themes_are_selectable_and_shown_only_in_the_preview(): void
|
||||
{
|
||||
$theme = app(PillarService::class)->create('Meine Grenzen – Ich darf Nein sagen');
|
||||
$type = app(WidgetRegistry::class)->get('topic_card');
|
||||
$search = (new \ReflectionMethod($type, 'searchSubjects'))->invoke($type, null);
|
||||
$this->assertSame([$theme->id => 'Meine Grenzen – Ich darf Nein sagen · Thema · nicht veröffentlicht, nur Redaktionsvorschau'], $search);
|
||||
|
||||
$revision = $this->publish('/thema-vorbereitet', [$this->section('u2_2', [
|
||||
$this->card('topic_card', ['pillar' => $theme->id]),
|
||||
null,
|
||||
])]);
|
||||
|
||||
$this->get('/thema-vorbereitet')->assertOk()->assertDontSee('Meine Grenzen')->assertDontSee('lf-pc', false);
|
||||
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
||||
$this->assertStringContainsString('Meine Grenzen – Ich darf Nein sagen', $preview);
|
||||
$this->assertStringContainsString('Das Thema ist nicht veröffentlicht', $preview);
|
||||
$this->assertStringContainsString('Kein Text für die Website gepflegt', $preview);
|
||||
|
||||
app(PillarService::class)->present($theme->refresh(), $theme->name, 'meine-grenzen', 'Kinder lernen, ihre Grenzen zu spüren.', true, 1);
|
||||
$this->get('/thema-vorbereitet')->assertOk()
|
||||
->assertSee('Kinder lernen, ihre Grenzen zu spüren.')
|
||||
->assertSee(route('theme', ['slug' => 'meine-grenzen']), false)
|
||||
->assertDontSee('nicht veröffentlicht');
|
||||
}
|
||||
|
||||
public function test_cards_reject_unpublished_or_unreleased_objects_and_require_alt_text_for_images(): void
|
||||
{
|
||||
Storage::fake('media_public');
|
||||
Storage::disk('media_public')->put('cms/karte.jpg', 'bild');
|
||||
$hidden = Pillar::query()->create(['name' => 'Entwurfsthema', 'slug' => 'entwurf']);
|
||||
$draft = $this->composition('Programm Entwurf', 'programm', released: false);
|
||||
$archivedProgram = $this->composition('Programm Archiv', 'programm');
|
||||
$archivedProgram->composition->update(['archived_at' => now()]);
|
||||
$archived = app(ContentService::class)->createElement('film', 'film', 'Ohne Fassung');
|
||||
$published = $this->pillar('Grenzen', 'grenzen', null);
|
||||
|
||||
$cases = [
|
||||
[$this->card('topic_card', ['pillar' => $hidden->id]), 'refs.pillar'],
|
||||
[$this->card('program_card', ['composition' => $draft->composition_id]), 'refs.composition'],
|
||||
[$this->card('topic_card', ['pillar' => 999999]), 'refs.pillar'],
|
||||
[$this->card('program_card', ['composition' => $archivedProgram->composition_id]), 'refs.composition'],
|
||||
[$this->card('media_card', ['element' => $archived->id]), 'refs.element'],
|
||||
[$this->card('topic_card', ['pillar' => $published->id, 'image' => 'cms/karte.jpg']), 'data.alt'],
|
||||
[$this->card('topic_card', ['pillar' => $published->id, 'image' => 'bibliothek/geschuetzt.jpg']), 'refs.image'],
|
||||
[$this->card('topic_card', ['pillar' => $published->id], settings: ['format' => 'panorama']), 'settings.format'],
|
||||
[$this->card('topic_card', []), 'refs.pillar'],
|
||||
];
|
||||
@@ -309,7 +397,7 @@ public function test_editor_inserts_configures_saves_and_reopens_all_three_cards
|
||||
$this->assertStringContainsString('>Zum Thema</a>', $html);
|
||||
$this->assertStringContainsString('Programm Abstand', $html);
|
||||
$this->assertStringContainsString('Programm Abstand Blatt', $html, 'Ein Element eines öffentlichen Programms erscheint öffentlich.');
|
||||
$this->assertStringContainsString('lf-pc lf-pc--media lf-pc--landscape lf-pc--cover lf-pc--stacked', $html);
|
||||
$this->assertStringContainsString('lf-pc lf-pc--material lf-pc--landscape lf-pc--cover lf-pc--stacked', $html, 'Ein Textmaterial erscheint als Materialkarte.');
|
||||
$this->assertStringNotContainsString('Im Programm „Programm Abstand“', $html, 'Zusatzangaben ausgeblendet.');
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,275 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageRevision;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Domain\Cms\WebsiteImageUsage;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Media\WebsiteIntake;
|
||||
use App\Domain\Media\WebsiteMediaAlias;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||
use App\Jobs\ImportCmsImages;
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Testing\TestAction;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* CMS-Bilder aus dem zentralen Medienmanager (docs/architektur/medienzugriff-fuer-komponenten.md):
|
||||
* Auswahl per Kennung, öffentliche Ausgabe nur mit Website-Freigabe, Übernahme früherer CMS-Bilder.
|
||||
*/
|
||||
class CmsWebsiteMediaTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Storage::fake('cms_incoming');
|
||||
Storage::fake('media_derived');
|
||||
Storage::fake('media_public');
|
||||
Storage::fake('media_originals');
|
||||
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||
}
|
||||
|
||||
public function test_a_released_medium_is_shown_in_every_widget_through_the_website_route(): void
|
||||
{
|
||||
$medium = $this->releasedImage('Lara im Park', 'Lara sitzt auf einer Parkbank');
|
||||
$url = route('website.media', $medium);
|
||||
|
||||
$revision = $this->publish('/medien-ueberall', [
|
||||
['layout' => 'u4', 'style' => ['background' => 'image', 'image' => $medium->id, 'overlay' => 'light'], 'slots' => [
|
||||
['type' => 'hero', 'v' => 2, 'variant' => 'photo_split', 'data' => ['heading' => 'Einstieg'], 'refs' => ['image' => $medium->id]],
|
||||
]],
|
||||
['layout' => 'u2_2', 'style' => [], 'slots' => [
|
||||
['type' => 'image_text', 'v' => 3, 'variant' => 'image_left', 'data' => ['title' => 'Bild und Text', 'body' => '<p>Text</p>', 'alt' => 'Eigene Beschreibung'], 'refs' => ['image' => $medium->id]],
|
||||
['type' => 'cards', 'v' => 1, 'data' => ['items' => [['title' => 'Karte', 'image' => $medium->id]]]],
|
||||
]],
|
||||
]);
|
||||
|
||||
$this->assertSame($medium->id, $revision->sections[0]['slots'][0]['refs']['image'], 'Gespeichert wird die Kennung, keine Kopie.');
|
||||
$this->assertSame($medium->id, $revision->sections[0]['style']['image']);
|
||||
|
||||
$main = $this->main($this->get('/medien-ueberall')->assertOk()->getContent());
|
||||
$this->assertSame(4, substr_count($main, 'src="'.$url.'"'), 'Hintergrund, Einstieg, Bild und Text, Karte verwenden dasselbe Medium.');
|
||||
$this->assertStringContainsString('alt="Lara sitzt auf einer Parkbank"', $main, 'Alternativtext des Mediums.');
|
||||
$this->assertStringContainsString('alt="Eigene Beschreibung"', $main, 'Abweichender Alternativtext im Widget.');
|
||||
$this->assertStringNotContainsString('/redaktion/', $main);
|
||||
$this->assertStringNotContainsString('/medien/cms/', $main);
|
||||
$this->assertSame([['path' => '/medien-ueberall', 'published' => true, 'draft' => false]], app(WebsiteImageUsage::class)->pages($medium), 'Der Medienmanager zeigt die Verwendung auf Website-Seiten.');
|
||||
}
|
||||
|
||||
public function test_an_unreleased_medium_is_only_shown_in_the_preview_with_a_notice(): void
|
||||
{
|
||||
$medium = $this->unreleasedImage('Noch nicht freigegeben');
|
||||
|
||||
$revision = $this->publish('/nicht-freigegeben', [
|
||||
['layout' => 'u4', 'style' => [], 'slots' => [
|
||||
['type' => 'image_text', 'v' => 3, 'variant' => 'image_left', 'data' => ['title' => 'Mit Bild', 'body' => '<p>Text bleibt sichtbar.</p>'], 'refs' => ['image' => $medium->id]],
|
||||
]],
|
||||
]);
|
||||
|
||||
$main = $this->main($this->get('/nicht-freigegeben')->assertOk()->getContent());
|
||||
$this->assertStringContainsString('Text bleibt sichtbar.', $main, 'Nur das Bild entfällt, nicht das Widget.');
|
||||
$this->assertStringNotContainsString('<img', $main);
|
||||
$this->assertStringContainsString('lf-bt--without-image', $main);
|
||||
|
||||
$preview = $this->actingAs(User::factory()->redakteur()->create(), 'staff')->get(route('pages.preview', $revision))->assertOk()->getContent();
|
||||
$this->assertStringContainsString('src="'.route('editorial.card', ['kind' => 'element', 'subject' => $medium->id]).'"', $preview);
|
||||
$this->assertStringContainsString('Das gewählte Bild „Noch nicht freigegeben“ erscheint öffentlich nicht: Nicht für die Website freigegeben.', $preview);
|
||||
}
|
||||
|
||||
public function test_withdrawing_the_release_removes_the_image_from_pages_and_closes_the_former_address(): void
|
||||
{
|
||||
Storage::disk('media_public')->put('cms/altbild-abc123.jpg', $this->jpeg(1200, 600));
|
||||
$this->publish('/altbild', [
|
||||
['layout' => 'u4', 'style' => [], 'slots' => [
|
||||
['type' => 'hero', 'v' => 2, 'variant' => 'photo_split', 'data' => ['heading' => 'Früher'], 'refs' => ['image' => 'cms/altbild-abc123.jpg']],
|
||||
]],
|
||||
]);
|
||||
(new ImportCmsImages)->handle(app(WebsiteIntake::class));
|
||||
$medium = WebsiteMediaAlias::query()->where('legacy_path', 'cms/altbild-abc123.jpg')->firstOrFail()->element;
|
||||
$this->assertNotNull($medium->website_released_at);
|
||||
$this->refreshScoped();
|
||||
|
||||
$this->get('/altbild')->assertSee('src="'.route('website.media', $medium).'"', false)->assertDontSee('/medien/cms/altbild', false);
|
||||
$this->get('/medien/cms/altbild-abc123.jpg')->assertOk();
|
||||
|
||||
app(WebsiteRelease::class)->withdraw($medium);
|
||||
$this->refreshScoped();
|
||||
|
||||
$this->assertStringNotContainsString('<img', $this->main($this->get('/altbild')->assertOk()->getContent()));
|
||||
$this->get('/medien/cms/altbild-abc123.jpg')->assertNotFound();
|
||||
$this->get(route('website.media', $medium))->assertNotFound();
|
||||
Storage::disk('media_public')->assertExists('cms/altbild-abc123.jpg');
|
||||
}
|
||||
|
||||
public function test_former_cms_images_are_imported_once_deduplicated_and_without_deleting_files(): void
|
||||
{
|
||||
$same = $this->jpeg(800, 400);
|
||||
Storage::disk('media_public')->put('cms/platzhalter-karte-1-aaaaaa.jpg', $same);
|
||||
Storage::disk('media_public')->put('cms/platzhalter-karte-1-bbbbbb.jpg', $same);
|
||||
Storage::disk('media_public')->put('cms/markenbuehne-cccccc.png', $this->jpeg(900, 300));
|
||||
Storage::disk('media_public')->put('cms/notiz.txt', 'kein Bild');
|
||||
|
||||
(new ImportCmsImages)->handle(app(WebsiteIntake::class));
|
||||
(new ImportCmsImages)->handle(app(WebsiteIntake::class));
|
||||
|
||||
$this->assertSame(3, WebsiteMediaAlias::query()->count());
|
||||
$this->assertSame(2, ContentElement::query()->where('output_class', 'bild')->count(), 'Bytegleiche Dateien werden ein Medium.');
|
||||
$this->assertSame(['Markenbuehne', 'Platzhalter Karte 1'], ContentElement::query()->orderBy('working_title')->pluck('working_title')->all());
|
||||
$this->assertSame(
|
||||
WebsiteMediaAlias::query()->where('legacy_path', 'cms/platzhalter-karte-1-aaaaaa.jpg')->value('content_element_id'),
|
||||
WebsiteMediaAlias::query()->where('legacy_path', 'cms/platzhalter-karte-1-bbbbbb.jpg')->value('content_element_id'),
|
||||
);
|
||||
foreach (['cms/platzhalter-karte-1-aaaaaa.jpg', 'cms/platzhalter-karte-1-bbbbbb.jpg', 'cms/markenbuehne-cccccc.png'] as $path) {
|
||||
Storage::disk('media_public')->assertExists($path);
|
||||
}
|
||||
$this->assertTrue(ContentElement::query()->get()->every(fn (ContentElement $element): bool => $element->website_released_at !== null));
|
||||
}
|
||||
|
||||
public function test_an_alias_takes_effect_only_after_the_medium_was_released(): void
|
||||
{
|
||||
Storage::disk('media_public')->put('cms/kaputt-dddddd.jpg', 'keine Bilddaten');
|
||||
$this->publish('/kaputt', [
|
||||
['layout' => 'u4', 'style' => [], 'slots' => [
|
||||
['type' => 'hero', 'v' => 2, 'variant' => 'photo_split', 'data' => ['heading' => 'Bild bleibt'], 'refs' => ['image' => 'cms/kaputt-dddddd.jpg']],
|
||||
]],
|
||||
]);
|
||||
|
||||
(new ImportCmsImages)->handle(app(WebsiteIntake::class));
|
||||
$this->refreshScoped();
|
||||
|
||||
$this->assertNotNull(WebsiteMediaAlias::query()->where('legacy_path', 'cms/kaputt-dddddd.jpg')->first());
|
||||
$this->get('/kaputt')->assertSee('/medien/cms/kaputt-dddddd.jpg', false);
|
||||
}
|
||||
|
||||
public function test_saving_converts_an_imported_path_to_the_medium_and_rejects_other_media(): void
|
||||
{
|
||||
Storage::disk('media_public')->put('cms/umzug-eeeeee.jpg', $this->jpeg(1000, 500));
|
||||
(new ImportCmsImages)->handle(app(WebsiteIntake::class));
|
||||
$medium = WebsiteMediaAlias::query()->firstOrFail()->element;
|
||||
|
||||
$revision = $this->publish('/umzug', [
|
||||
['layout' => 'u4', 'style' => [], 'slots' => [
|
||||
['type' => 'hero', 'v' => 2, 'variant' => 'photo_split', 'data' => ['heading' => 'Umzug'], 'refs' => ['image' => 'cms/umzug-eeeeee.jpg']],
|
||||
]],
|
||||
]);
|
||||
$this->assertSame($medium->id, $revision->sections[0]['slots'][0]['refs']['image']);
|
||||
|
||||
$film = app(ContentService::class)->createElement('film', 'film', 'Film');
|
||||
try {
|
||||
app(PageService::class)->saveRevision(Page::query()->create(['path' => '/film-als-bild']), [
|
||||
['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'hero', 'v' => 2, 'data' => ['heading' => 'X'], 'refs' => ['image' => $film->id]]]],
|
||||
], null, null, null);
|
||||
$this->fail('Ein Film wurde als Bild angenommen.');
|
||||
} catch (ValidationException $exception) {
|
||||
$this->assertArrayHasKey('sections.0.slots.0.refs.image', $exception->errors());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_an_image_uploaded_in_the_widget_dialog_becomes_a_medium_and_is_selected(): void
|
||||
{
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
$page = Page::query()->create(['path' => '/upload']);
|
||||
app(PageService::class)->saveRevision($page, [
|
||||
['layout' => 'u4', 'style' => [], 'slots' => [['type' => 'hero', 'v' => 2, 'variant' => 'photo_split', 'data' => ['heading' => 'Upload'], 'refs' => []]]],
|
||||
], null, null, null);
|
||||
|
||||
$component = Livewire::actingAs($editor, 'staff')->test(EditPage::class, ['record' => $page->id]);
|
||||
$sectionKey = array_key_first($component->get('data.sections'));
|
||||
$slotKey = array_key_first($component->get("data.sections.$sectionKey.slots"));
|
||||
$itemKey = array_key_first($component->get("data.sections.$sectionKey.slots.$slotKey.widget"));
|
||||
|
||||
$component->mountAction(TestAction::make('edit')->schemaComponent("sections.$sectionKey.slots.$slotKey.widget")->arguments(['item' => $itemKey]))
|
||||
->fillForm(['refs._upload' => UploadedFile::fake()->image('lara-im-park.jpg', 1600, 900)])
|
||||
->callMountedAction()
|
||||
->assertHasNoErrors();
|
||||
|
||||
$medium = ContentElement::query()->where('output_class', 'bild')->latest('id')->firstOrFail();
|
||||
$this->assertSame('Lara Im Park', $medium->display_title);
|
||||
$this->assertNotNull($medium->website_released_at, 'Neue Bilder werden nach der Verarbeitung für die Website freigegeben.');
|
||||
$this->assertSame($medium->id, (int) $component->get("data.sections.$sectionKey.slots.$slotKey.widget.$itemKey.data.refs.image"));
|
||||
|
||||
$component->call('save')->assertHasNoFormErrors();
|
||||
$this->assertSame($medium->id, $page->refresh()->latestRevision->sections[0]['slots'][0]['refs']['image']);
|
||||
}
|
||||
|
||||
public function test_the_picker_lists_website_images_with_their_release_state(): void
|
||||
{
|
||||
$released = $this->releasedImage('Freigegeben', null);
|
||||
$unreleased = $this->unreleasedImage('Unfreigegeben');
|
||||
app(ContentService::class)->createElement('film', 'film', 'Film taucht nicht auf');
|
||||
|
||||
$options = app(WebsiteImage::class)->options();
|
||||
$this->assertSame([$unreleased->id, $released->id], array_keys($options));
|
||||
$this->assertStringContainsString('Website: freigegeben', $options[$released->id]);
|
||||
$this->assertStringContainsString('Website: nicht freigegeben', $options[$unreleased->id]);
|
||||
$this->assertStringContainsString(route('editorial.card', ['kind' => 'element', 'subject' => $released->id]), $options[$released->id]);
|
||||
}
|
||||
|
||||
private function releasedImage(string $title, ?string $alt): ContentElement
|
||||
{
|
||||
$path = 'cms/'.Str::slug($title).'.jpg';
|
||||
Storage::disk('cms_incoming')->put($path, $this->jpeg(1600, 800));
|
||||
|
||||
return app(WebsiteIntake::class)->acceptImage($path, $title, 'Foto: Lara und Felix', $alt)->refresh();
|
||||
}
|
||||
|
||||
private function unreleasedImage(string $title): ContentElement
|
||||
{
|
||||
$element = app(ContentService::class)->createElement('bild', 'bild', $title);
|
||||
$element->forceFill(['thumbnail_path' => 'vorschau/element-'.$element->id.'.jpg'])->save();
|
||||
Storage::disk('media_derived')->put($element->thumbnail_path, $this->jpeg(640, 320));
|
||||
|
||||
return $element->refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $sections
|
||||
*/
|
||||
private function publish(string $path, array $sections): PageRevision
|
||||
{
|
||||
$page = Page::query()->firstOrCreate(['path' => $path]);
|
||||
$service = app(PageService::class);
|
||||
$revision = $service->saveRevision($page, $sections, null, null, null);
|
||||
$service->publish($page, $revision);
|
||||
|
||||
return $revision;
|
||||
}
|
||||
|
||||
private function refreshScoped(): void
|
||||
{
|
||||
$this->app->forgetScopedInstances();
|
||||
}
|
||||
|
||||
private function main(string $html): string
|
||||
{
|
||||
preg_match('#<main[^>]*>(.*)</main>#s', $html, $match);
|
||||
|
||||
return $match[1] ?? '';
|
||||
}
|
||||
|
||||
private function jpeg(int $width, int $height): string
|
||||
{
|
||||
$image = imagecreatetruecolor($width, $height);
|
||||
imagefill($image, 0, 0, imagecolorallocate($image, 200, 120, 40));
|
||||
ob_start();
|
||||
imagejpeg($image);
|
||||
|
||||
return (string) ob_get_clean();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,630 @@
|
||||
<?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\Pillar;
|
||||
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\PresentationFile;
|
||||
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->pictureWithoutVersion('Modulbild ohne Fassung');
|
||||
Livewire::test(EditExercise::class, ['record' => $module->getKey()])
|
||||
->assertSet('teaser', 'Kurz in das Modul.')
|
||||
->set('teaser', 'Geändertes Modul.')
|
||||
->call('saveDisplay')
|
||||
->assertSee('Die Fassung bleibt unverändert.')
|
||||
->call('openPresentationPicker')
|
||||
->set('pickerQuery', 'Modulbild ohne')
|
||||
->assertSee('Modulbild ohne Fassung')
|
||||
->call('assignFromPicker', 'medium:'.$cover->id);
|
||||
|
||||
$module->refresh();
|
||||
$version->refresh();
|
||||
$this->assertSame('Geändertes Modul.', $module->teaser);
|
||||
$this->assertSame('Eine Grenze erkennen und sagen.', $version->learning_goal);
|
||||
$this->assertSame(0, $cover->fresh()->versions()->count());
|
||||
$this->assertSame(1, $module->versions()->count());
|
||||
$this->assertNull(PresentationAssignment::query()->where('content_element_id', $cover->id)->value('source_version_id'));
|
||||
$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->pictureWithoutVersion('Artikelbild ohne Fassung');
|
||||
Livewire::test(ViewLicenseArticle::class, ['record' => $article->getKey()])
|
||||
->assertSet('summary', 'Eigene Artikelbeschreibung')
|
||||
->set('descriptionText', 'Nur dieser Artikel')
|
||||
->call('saveLicenseEditorial')
|
||||
->set('presentationQuery', 'Artikelbild ohne')
|
||||
->set('presentationRole', 'titelbild')
|
||||
->set('presentationPick', 'medium:'.$cover->id)
|
||||
->call('assignPickedPresentation')
|
||||
->assertSee('Artikelbild ohne Fassung');
|
||||
|
||||
$overridden = app(EditorialProfileReader::class)->read($article->fresh(), 'artikel');
|
||||
$this->assertSame('eigen', $overridden->origin('description'));
|
||||
$this->assertSame('Nur dieser Artikel', $overridden->value('description'));
|
||||
$this->assertSame('quelle', $overridden->origin('teaser'));
|
||||
$this->assertSame('Teaser der Fassung', $overridden->value('teaser'));
|
||||
$this->assertSame('Lang aus dem Film', $film->fresh()->description);
|
||||
$this->assertSame(0, $cover->fresh()->versions()->count());
|
||||
|
||||
Livewire::test(ViewLicenseArticle::class, ['record' => $article->getKey()])
|
||||
->set('summary', '')
|
||||
->call('saveLicenseEditorial');
|
||||
$restored = app(EditorialProfileReader::class)->read($article->fresh(), 'artikel');
|
||||
$this->assertSame('quelle', $restored->origin('summary'));
|
||||
$this->assertSame('Kurz aus dem Film', $restored->value('summary'));
|
||||
$this->assertSame('eigen', $restored->origin('description'));
|
||||
$this->assertSame($release->id, $article->fresh()->current_release_id);
|
||||
$this->assertSame(1, ArticleRelease::query()->count());
|
||||
$this->assertSame($offers, Offer::query()->count());
|
||||
$this->assertSame(ReleaseStatus::Veroeffentlicht, $release->fresh()->status);
|
||||
|
||||
$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_content_elements_do_not_offer_the_pillar_dimension_a_second_time(): void
|
||||
{
|
||||
$pillar = Pillar::query()->create(['name' => 'Nähe', 'slug' => 'naehe', 'sort_order' => 1]);
|
||||
$dimension = EditorialDimension::query()->where('slug', 'saeule')->firstOrFail();
|
||||
$value = EditorialDimensionValue::query()->create([
|
||||
'editorial_dimension_id' => $dimension->id,
|
||||
'slug' => 'pfeiler-'.$pillar->id,
|
||||
'label' => 'Nähe als Dimension',
|
||||
]);
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->createElement('film', 'film', 'Film mit Säule');
|
||||
$content->publishElementVersion($film, 'Film');
|
||||
app(IdentityDimension::class)->assign($film, $value);
|
||||
$kinder = $this->dimensionValue('zielgruppe', 'kinder');
|
||||
$this->actingAs($this->editor(), 'staff');
|
||||
|
||||
$html = Livewire::test(ViewContentElement::class, ['record' => $film->getKey()])
|
||||
->set('bereich', 'beschreibung')
|
||||
->set('dimensionIds', [$kinder->id])
|
||||
->call('saveEditorial')
|
||||
->html();
|
||||
|
||||
$this->assertStringContainsString('Fachliche Säulen', $html);
|
||||
$this->assertStringNotContainsString('>Fachliche Säule<', $html);
|
||||
$assigned = IdentityDimensionValue::query()
|
||||
->where('subject_type', $film->getMorphClass())
|
||||
->where('subject_id', $film->id)
|
||||
->pluck('editorial_dimension_value_id')
|
||||
->all();
|
||||
$this->assertContains($value->id, $assigned);
|
||||
$this->assertContains($kinder->id, $assigned);
|
||||
|
||||
$module = $content->createComposition('Modul mit Säule');
|
||||
$content->publishComposition($module, [[
|
||||
'role' => 'Film',
|
||||
'target' => $film->versions()->first(),
|
||||
]]);
|
||||
Livewire::test(EditExercise::class, ['record' => $module->getKey()])
|
||||
->call('openModule')
|
||||
->set('moduleTab', 'einordnung')
|
||||
->assertSee('Nähe als Dimension')
|
||||
->assertDontSee('Fachliche Säulen');
|
||||
}
|
||||
|
||||
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 pictureWithoutVersion(string $title): ContentElement
|
||||
{
|
||||
Storage::fake('cms_incoming');
|
||||
$path = 'inhalte/'.md5($title).'.jpg';
|
||||
Storage::disk('cms_incoming')->put($path, 'bild');
|
||||
$element = app(ContentService::class)->createElement('bild', 'bild', $title);
|
||||
$element->display_title = $title;
|
||||
$element->save();
|
||||
app(PresentationFile::class)->store($element, $path);
|
||||
|
||||
return $element->fresh();
|
||||
}
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@ public function test_a_medium_keeps_the_old_version_when_a_new_one_is_saved(): v
|
||||
$this->actingAs($editor, 'staff');
|
||||
|
||||
Livewire::test(ViewContentElement::class, ['record' => $element->getKey()])
|
||||
->set('bereich', 'inhalt')
|
||||
->assertOk()
|
||||
->assertSee('Erste Fassung')
|
||||
->assertSee('Fassung 1')
|
||||
@@ -204,7 +205,7 @@ public function test_a_catalog_keeper_cannot_edit_media(): void
|
||||
$version = app(ContentService::class)->publishElementVersion($element, 'Sichtbarer Text');
|
||||
|
||||
$this->actingAs($keeper, 'staff')
|
||||
->get(ContentElementResource::getUrl('view', ['record' => $element]))
|
||||
->get(ContentElementResource::getUrl('view', ['record' => $element]).'?bereich=inhalt')
|
||||
->assertOk()
|
||||
->assertSee('Fassung 1')
|
||||
->assertSee('Sichtbarer Text')
|
||||
@@ -236,6 +237,7 @@ public function test_a_description_does_not_create_a_version_and_an_older_versio
|
||||
$this->assertSame('Für die Gruppe', $element->fresh()->description);
|
||||
|
||||
Livewire::test(ViewContentElement::class, ['record' => $element->getKey()])
|
||||
->set('bereich', 'inhalt')
|
||||
->assertSee('Fassung 1')
|
||||
->assertSee('Fassung 2')
|
||||
->assertSee('<video', false)
|
||||
@@ -342,6 +344,7 @@ public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?
|
||||
|
||||
Livewire::actingAs($editor, 'staff')
|
||||
->test(ViewContentElement::class, ['record' => $element->getKey()])
|
||||
->set('bereich', 'inhalt')
|
||||
->assertSee('Diese Stelle übernehmen')
|
||||
->call('adoptFrame')
|
||||
->assertSet('pictureFeedback', 'Wähle zuerst eine Zeitposition.')
|
||||
@@ -456,6 +459,7 @@ public function test_staff_players_use_the_stored_film_ladder(): void
|
||||
|
||||
Livewire::actingAs($editor, 'staff')
|
||||
->test(ViewContentElement::class, ['record' => $version->element->getKey()])
|
||||
->set('bereich', 'inhalt')
|
||||
->assertSee('data-hls="'.$playlist.'"', false)
|
||||
->assertSee(route('content.file', $version), false);
|
||||
|
||||
@@ -482,6 +486,7 @@ public function test_a_draft_medium_can_be_released_from_its_editor(): void
|
||||
|
||||
Livewire::actingAs($editor, 'staff')
|
||||
->test(ViewContentElement::class, ['record' => $version->content_element_id])
|
||||
->set('bereich', 'inhalt')
|
||||
->assertSee('noch nicht freigegeben')
|
||||
->mountAction('releaseVersion', ['version' => $version->id])
|
||||
->callMountedAction();
|
||||
@@ -491,6 +496,7 @@ public function test_a_draft_medium_can_be_released_from_its_editor(): void
|
||||
|
||||
Livewire::actingAs($editor, 'staff')
|
||||
->test(ViewContentElement::class, ['record' => $version->content_element_id])
|
||||
->set('bereich', 'inhalt')
|
||||
->assertSee('freigegeben')
|
||||
->assertDontSee('Fassung freigeben');
|
||||
$this->assertSame(1, $version->element->fresh()->versions()->count());
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\IdentityChange;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Filament\Resources\ContentElements\Pages\ViewContentElement;
|
||||
use App\Filament\Resources\Exercises\Pages\EditExercise;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
class MediaEditorTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||
}
|
||||
|
||||
public function test_editorial_text_is_saved_without_a_new_version_and_previewed_on_the_real_cards(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$element = $content->createElement('film', 'film', 'Lara im Park');
|
||||
$version = $content->publishElementVersion($element, 'Film');
|
||||
$editor = $this->editor();
|
||||
$this->actingAs($editor, 'staff');
|
||||
|
||||
Livewire::test(ViewContentElement::class, ['record' => $element->getKey()])
|
||||
->set('bereich', 'beschreibung')
|
||||
->set('displayTitle', 'Lara im Park, neu')
|
||||
->set('summary', 'Ein kurzer Teaser für die Karte')
|
||||
->set('descriptionText', 'Ausführliche Beschreibung nur in der Verwaltung')
|
||||
->call('saveEditorial')
|
||||
->assertSee('Gespeichert. Es gibt keine neue Fassung.')
|
||||
->assertSee('Ein kurzer Teaser für die Karte')
|
||||
->assertSee('lf-pc');
|
||||
|
||||
$element->refresh();
|
||||
$this->assertSame(1, $element->versions()->count());
|
||||
$this->assertSame($version->id, $element->versions()->first()->id);
|
||||
$this->assertSame('Lara im Park, neu', $element->display_title);
|
||||
$this->assertSame('Ein kurzer Teaser für die Karte', $element->summary);
|
||||
$this->assertTrue(
|
||||
IdentityChange::query()->where('subject_id', $element->id)->where('field', 'summary')->exists()
|
||||
);
|
||||
|
||||
$draft = app(PublicMaterialReader::class)->subject($element->id, true, [
|
||||
'summary' => 'Noch nicht gespeichert',
|
||||
]);
|
||||
$this->assertSame('Noch nicht gespeichert', $draft->summary);
|
||||
$this->assertSame('Ein kurzer Teaser für die Karte', $element->fresh()->summary);
|
||||
|
||||
Livewire::test(ViewContentElement::class, ['record' => $element->getKey()])
|
||||
->set('bereich', 'vorschau')
|
||||
->set('summary', 'Noch nicht gespeichert')
|
||||
->set('previewSurface', 'bibliothek')
|
||||
->assertSee('media-card')
|
||||
->assertSee('Noch nicht gespeichert');
|
||||
}
|
||||
|
||||
public function test_the_picker_keeps_drafts_for_modules_and_limits_images_and_website_choices(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->publishElementVersion($content->createElement('film', 'film', 'Lara im Park'), 'Film');
|
||||
$draft = $content->draftElementVersion($content->createElement('text', 'text', 'Offener Entwurf'), 'Text');
|
||||
$image = $content->createElement('bild', 'bild', 'Szenenbild');
|
||||
$image->thumbnail_path = 'vorschau/szenenbild.jpg';
|
||||
$image->save();
|
||||
$content->publishElementVersion($image, null, ['file' => 'inhalte/szenenbild.jpg']);
|
||||
$module = $content->createComposition('Abstand', CompositionKind::Uebung);
|
||||
$editor = $this->editor();
|
||||
$this->actingAs($editor, 'staff');
|
||||
|
||||
$modulePicker = Livewire::test(EditExercise::class, ['record' => $module->id])
|
||||
->call('openPicker')
|
||||
->set('pickerQuery', 'Offener');
|
||||
$titles = array_column($modulePicker->instance()->pickerResult()['items'], 'title');
|
||||
$this->assertContains('Offener Entwurf', $titles);
|
||||
$modulePicker->assertSee('Entwürfe bleiben sichtbar');
|
||||
|
||||
$page = Livewire::test(ViewContentElement::class, ['record' => $film->element->getKey()])
|
||||
->set('pickerContext', 'bild');
|
||||
$imageTitles = array_column($page->instance()->selection()['items'], 'title');
|
||||
$this->assertContains('Szenenbild', $imageTitles);
|
||||
$this->assertNotContains('Lara im Park', $imageTitles);
|
||||
|
||||
$page->set('pickerContext', 'website');
|
||||
$websiteTitles = array_column($page->instance()->selection()['items'], 'title');
|
||||
$this->assertContains('Offener Entwurf', $websiteTitles);
|
||||
$this->assertNotContains('Abstand', $websiteTitles);
|
||||
|
||||
$target = null;
|
||||
foreach ($page->instance()->selection()['items'] as $item) {
|
||||
if ($item['title'] === 'Szenenbild') {
|
||||
$target = $item['target'];
|
||||
}
|
||||
}
|
||||
$page->set('pickerContext', 'bild')
|
||||
->set('pickerSelected', $target)
|
||||
->call('adoptLibraryImage')
|
||||
->assertSet('pictureFeedback', 'Vorschaubild übernommen. Es gibt keine neue Fassung. Für die Website ist es damit nicht freigegeben.');
|
||||
|
||||
$film->element->refresh();
|
||||
$this->assertSame('vorschau/szenenbild.jpg', $film->element->thumbnail_path);
|
||||
$this->assertSame(1, $film->element->versions()->count());
|
||||
$this->assertSame($draft->id, $draft->fresh()->id);
|
||||
}
|
||||
|
||||
public function test_browsing_images_does_not_return_films(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$content->publishElementVersion($content->createElement('film', 'film', 'Nur ein Film'), 'Film');
|
||||
$content->publishElementVersion($content->createElement('bild', 'bild', 'Nur ein Bild'), null, ['file' => 'inhalte/bild.jpg']);
|
||||
|
||||
$titles = array_column(
|
||||
app(EditorialCatalog::class)->browse('', 'bild', '', 0)['items'],
|
||||
'title',
|
||||
);
|
||||
|
||||
$this->assertSame(['Nur ein Bild'], $titles);
|
||||
}
|
||||
|
||||
private function editor(): User
|
||||
{
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
return $editor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\CompositionKind;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\EditorialDimension;
|
||||
use App\Domain\Catalog\IdentityDimension;
|
||||
use App\Domain\Catalog\PillarService;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Resources\ContentElements\Pages\ListContentElements;
|
||||
use App\Filament\Resources\Courses\CourseResource;
|
||||
use App\Filament\Resources\Exercises\ExerciseResource;
|
||||
use App\Filament\Support\MediaLibrary;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
class MediaLibraryTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||
}
|
||||
|
||||
public function test_the_library_opens_as_tiles_and_keeps_filters_when_the_view_changes(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->createElement('film', 'film', 'Lara im Park');
|
||||
$film->description = 'Lara spielt im Park.';
|
||||
$film->thumbnail_path = 'vorschau/element-'.$film->id.'.jpg';
|
||||
$film->thumbnail_alt = 'Lara auf dem Weg';
|
||||
$film->save();
|
||||
$content->publishElementVersion($film, 'Film');
|
||||
$content->createElement('text', 'text', 'Trainerhinweis');
|
||||
|
||||
Livewire::actingAs($this->editor(), 'staff')
|
||||
->test(ListContentElements::class)
|
||||
->assertOk()
|
||||
->assertSee('data-ansicht="kacheln"', false)
|
||||
->assertDontSee('data-ansicht="liste"', false)
|
||||
->assertDontSee('Arbeitstitel')
|
||||
->assertSee('Lara im Park')
|
||||
->assertSee('Film')
|
||||
->assertSee('Lara spielt im Park.')
|
||||
->assertSee('Fassung 1 freigegeben')
|
||||
->assertSee('Lara auf dem Weg')
|
||||
->assertSee(route('editorial.card', ['kind' => 'element', 'subject' => $film->id]), false)
|
||||
->assertSee('Trainerhinweis')
|
||||
->assertSee('Text')
|
||||
->set('suche', 'Park')
|
||||
->assertSee('Lara im Park')
|
||||
->assertDontSee('Trainerhinweis')
|
||||
->set('ansicht', 'liste')
|
||||
->assertSet('suche', 'Park')
|
||||
->assertSee('data-ansicht="liste"', false)
|
||||
->assertDontSee('data-ansicht="kacheln"', false)
|
||||
->assertSee('Lara im Park')
|
||||
->assertDontSee('Trainerhinweis')
|
||||
->assertSee('Ansehen')
|
||||
->assertSee('Bearbeiten')
|
||||
->call('resetFilters')
|
||||
->assertSet('suche', '')
|
||||
->assertSet('ansicht', 'liste')
|
||||
->assertSee('Trainerhinweis');
|
||||
}
|
||||
|
||||
public function test_a_text_medium_is_not_shown_as_a_film_or_as_a_released_version(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$text = $content->createElement('text', 'text', 'Felix beim Onkel');
|
||||
$content->draftElementVersion($text, 'Erst vorlesen.');
|
||||
|
||||
Livewire::actingAs($this->editor(), 'staff')
|
||||
->test(ListContentElements::class)
|
||||
->assertSee('Felix beim Onkel')
|
||||
->assertSee('Text')
|
||||
->assertSee('Entwurf, noch nicht freigegeben')
|
||||
->assertSee('data-fallback="text"', false)
|
||||
->assertDontSee('Fassung 1 freigegeben')
|
||||
->assertDontSee('/redaktion/karte/', false);
|
||||
}
|
||||
|
||||
public function test_filters_combine_and_a_draft_stays_distinct_from_a_released_version(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->createElement('film', 'film', 'Felix und der Autofahrer');
|
||||
$content->publishElementVersion($film, 'Erste Fassung');
|
||||
$content->draftElementVersion($film, 'Neue Schnittfassung');
|
||||
$sheet = $content->createElement('dokument', 'document', 'Traineranleitung Abstand');
|
||||
$content->publishElementVersion($sheet, 'Bitte vorlesen.');
|
||||
$broken = $content->createElement('film', 'film', 'Unlesbare Datei');
|
||||
$content->draftElementVersion($broken, null, ['error' => 'Die Datei ließ sich nicht lesen.']);
|
||||
|
||||
Livewire::actingAs($this->editor(), 'staff')
|
||||
->test(ListContentElements::class)
|
||||
->assertSee('Fassung 1 freigegeben')
|
||||
->assertSee('Entwurf offen')
|
||||
->assertDontSee('Fassung 2 freigegeben')
|
||||
->set('suche', 'Autofahrer')
|
||||
->set('art', 'film')
|
||||
->set('freigabe', 'freigegeben')
|
||||
->set('entwurf', 'offen')
|
||||
->assertSee('Felix und der Autofahrer')
|
||||
->assertDontSee('Traineranleitung Abstand')
|
||||
->assertDontSee('Unlesbare Datei')
|
||||
->set('art', 'document')
|
||||
->assertDontSee('Felix und der Autofahrer')
|
||||
->call('resetFilters')
|
||||
->set('verarbeitung', 'fehler')
|
||||
->assertSee('Unlesbare Datei')
|
||||
->assertSee('Verarbeitungsfehler')
|
||||
->assertDontSee('Felix und der Autofahrer');
|
||||
}
|
||||
|
||||
public function test_a_blocked_version_does_not_mark_the_whole_medium_and_stays_findable(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->createElement('film', 'film', 'Lara im Park');
|
||||
$first = $content->publishElementVersion($film, 'Alt');
|
||||
$content->publishElementVersion($film, 'Neu');
|
||||
$content->block($first, 'Veraltet');
|
||||
$retired = $content->createElement('film', 'film', 'Alter Take');
|
||||
$only = $content->publishElementVersion($retired, 'Take');
|
||||
$content->block($only, 'Nicht verwenden');
|
||||
|
||||
$this->assertSame(ContentVersionStatus::Gesperrt, $first->fresh()->status);
|
||||
$this->assertSame(ContentVersionStatus::Bereit, $film->versions()->where('number', 2)->first()->status);
|
||||
|
||||
Livewire::actingAs($this->editor(), 'staff')
|
||||
->test(ListContentElements::class)
|
||||
->assertSee('Lara im Park')
|
||||
->assertSee('Fassung 2 freigegeben')
|
||||
->assertSee('Fassung 1 deaktiviert')
|
||||
->assertDontSee('Medium deaktiviert')
|
||||
->assertDontSee('Alter Take')
|
||||
->set('fassung', 'nur')
|
||||
->assertSee('Alter Take')
|
||||
->assertSee('Fassung 1 deaktiviert')
|
||||
->assertDontSee('Lara im Park');
|
||||
}
|
||||
|
||||
public function test_usage_follows_older_versions_to_the_module_and_the_program(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->createElement('film', 'film', 'Felix beim Onkel');
|
||||
$first = $content->publishElementVersion($film, 'Erste Fassung');
|
||||
$content->publishElementVersion($film, 'Zweite Fassung');
|
||||
$module = $content->publishComposition(
|
||||
$content->createComposition('Abstand üben', CompositionKind::Uebung),
|
||||
[['role' => 'Film', 'target' => $first]],
|
||||
);
|
||||
$program = $content->publishComposition(
|
||||
$content->createComposition('Vormittag', CompositionKind::Kurs),
|
||||
[['role' => 'Film', 'target' => $first]],
|
||||
);
|
||||
$moduleUrl = ExerciseResource::getUrl('edit', ['record' => $module->composition_id]);
|
||||
$programUrl = CourseResource::getUrl('edit', ['record' => $program->composition_id]);
|
||||
|
||||
Livewire::actingAs($this->editor(), 'staff')
|
||||
->test(ListContentElements::class)
|
||||
->assertSee('2 Verwendungen')
|
||||
->assertSee('Modul')
|
||||
->assertSee('Programm')
|
||||
->assertSee('Abstand üben')
|
||||
->assertSee('Vormittag')
|
||||
->assertSee('Medium Fassung 1', false)
|
||||
->assertSee($moduleUrl, false)
|
||||
->assertSee($programUrl, false);
|
||||
|
||||
$this->assertSame($first->id, $module->members()->first()->content_element_version_id);
|
||||
$this->assertSame($first->id, $program->members()->first()->content_element_version_id);
|
||||
$this->assertSame(2, $film->versions()->count());
|
||||
}
|
||||
|
||||
public function test_a_license_article_is_not_treated_as_library_access_or_as_usage(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$sheet = $content->publishElementVersion(
|
||||
$content->createElement('text', 'text', 'Merkblatt Grenzen'),
|
||||
'Den Abstand ansprechen.',
|
||||
);
|
||||
$article = app(ArticleService::class)->create('grenzen-'.str()->lower(str()->random(4)));
|
||||
app(ArticleService::class)->publishRelease($article, $sheet, 'Dieselbe Ausgabe.');
|
||||
|
||||
Livewire::actingAs($this->editor(), 'staff')
|
||||
->test(ListContentElements::class)
|
||||
->assertSee('In keinem Modul oder Programm verwendet')
|
||||
->assertSee('Im Lizenzartikel '.$article->code.' genannt. Das belegt keinen Zugriff in der Bibliothek.')
|
||||
->set('nutzung', 'verwendet')
|
||||
->assertDontSee('Merkblatt Grenzen')
|
||||
->set('nutzung', 'unbenutzt')
|
||||
->assertSee('Merkblatt Grenzen');
|
||||
}
|
||||
|
||||
public function test_a_pending_file_is_not_shown_as_released_and_archived_media_stay_behind_a_filter(): void
|
||||
{
|
||||
Queue::fake();
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->createElement('film', 'film', 'Felix und der Autofahrer');
|
||||
$content->draftElementVersion($film, null, ['incoming' => 'inhalte/fahrer.mp4', 'hold' => true]);
|
||||
$archived = $content->createElement('text', 'text', 'Alte Anleitung');
|
||||
$content->publishElementVersion($archived, 'Text');
|
||||
$archived->archived_at = now();
|
||||
$archived->save();
|
||||
|
||||
Livewire::actingAs($this->editor(), 'staff')
|
||||
->test(ListContentElements::class)
|
||||
->assertSee('Datei wird übernommen')
|
||||
->assertSee('Entwurf, noch nicht freigegeben')
|
||||
->assertDontSee('Alte Anleitung')
|
||||
->set('archiv', 'archiviert')
|
||||
->assertSee('Alte Anleitung')
|
||||
->assertSee('Archiviert')
|
||||
->assertDontSee('Felix und der Autofahrer');
|
||||
}
|
||||
|
||||
public function test_pillar_and_classification_filters_narrow_the_same_library(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->createElement('film', 'film', 'Lara im Park');
|
||||
$content->publishElementVersion($film, 'Film');
|
||||
$other = $content->createElement('text', 'text', 'Ohne Säule');
|
||||
$content->publishElementVersion($other, 'Text');
|
||||
$pillar = app(PillarService::class)->create('Meine Grenzen');
|
||||
app(PillarService::class)->assign($film, [$pillar->id]);
|
||||
$dimension = EditorialDimension::query()->where('slug', 'zielgruppe')->firstOrFail();
|
||||
$value = $dimension->values()->create(['slug' => 'grundschule', 'label' => 'Grundschule']);
|
||||
app(IdentityDimension::class)->assign($film, $value);
|
||||
|
||||
Livewire::actingAs($this->editor(), 'staff')
|
||||
->test(ListContentElements::class)
|
||||
->set('saeule', (string) $pillar->id)
|
||||
->assertSee('Lara im Park')
|
||||
->assertDontSee('Ohne Säule')
|
||||
->set('saeule', '')
|
||||
->set('einordnung', (string) $value->id)
|
||||
->assertSee('Lara im Park')
|
||||
->assertDontSee('Ohne Säule');
|
||||
}
|
||||
|
||||
public function test_a_catalog_keeper_can_open_the_library_but_cannot_edit(): void
|
||||
{
|
||||
app(ContentService::class)->publishElementVersion(
|
||||
app(ContentService::class)->createElement('text', 'text', 'Hinweis'),
|
||||
'Text',
|
||||
);
|
||||
$keeper = User::factory()->katalogverwalter()->create();
|
||||
$keeper->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
Livewire::actingAs($keeper, 'staff')
|
||||
->test(ListContentElements::class)
|
||||
->assertOk()
|
||||
->assertSee('Hinweis')
|
||||
->assertSee('Ansehen')
|
||||
->assertDontSee('Bearbeiten')
|
||||
->assertDontSee('Medium anlegen');
|
||||
}
|
||||
|
||||
public function test_usage_counts_are_loaded_without_a_query_per_card(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
|
||||
foreach (['Lara im Park', 'Felix beim Onkel', 'Felix und der Autofahrer'] as $title) {
|
||||
$version = $content->publishElementVersion($content->createElement('film', 'film', $title), 'Film');
|
||||
$content->publishComposition(
|
||||
$content->createComposition('Modul '.$title, CompositionKind::Uebung),
|
||||
[['role' => 'Film', 'target' => $version]],
|
||||
);
|
||||
}
|
||||
|
||||
DB::flushQueryLog();
|
||||
DB::enableQueryLog();
|
||||
$cards = app(MediaLibrary::class)->cards([
|
||||
'suche' => '',
|
||||
'art' => '',
|
||||
'freigabe' => '',
|
||||
'entwurf' => '',
|
||||
'fassung' => '',
|
||||
'nutzung' => '',
|
||||
'saeule' => '',
|
||||
'einordnung' => '',
|
||||
'verarbeitung' => '',
|
||||
'archiv' => 'aktiv',
|
||||
], true);
|
||||
$queries = count(DB::getQueryLog());
|
||||
|
||||
$this->assertCount(3, $cards);
|
||||
$this->assertSame(1, $cards[0]['usageCount']);
|
||||
$this->assertLessThan(12, $queries);
|
||||
}
|
||||
|
||||
public function test_an_editor_can_open_a_medium_from_the_library(): void
|
||||
{
|
||||
$element = app(ContentService::class)->createElement('film', 'film', 'Lara im Park');
|
||||
app(ContentService::class)->publishElementVersion($element, 'Film');
|
||||
$editor = $this->editor();
|
||||
|
||||
$this->actingAs($editor, 'staff')
|
||||
->get(ContentElementResource::getUrl('index'))
|
||||
->assertOk()
|
||||
->assertSee(ContentElementResource::getUrl('view', ['record' => $element]), false)
|
||||
->assertSee(ContentElementResource::getUrl('edit', ['record' => $element]), false);
|
||||
}
|
||||
|
||||
private function editor(): User
|
||||
{
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
|
||||
return $editor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
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\EditorialContentKind;
|
||||
use App\Domain\Catalog\PresentationAssignment;
|
||||
use App\Domain\Catalog\PresentationMedia;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetRenderer;
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Media\PresentationFile;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
use App\Filament\Resources\Courses\Pages\EditCourse;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Filament\Support\MediumForm;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PresentationMediaTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
|
||||
Storage::fake('cms_incoming');
|
||||
Storage::fake('media_derived');
|
||||
Storage::fake('media_public');
|
||||
Storage::fake('media_originals');
|
||||
}
|
||||
|
||||
public function test_a_versionless_image_and_teaser_can_be_assigned_released_and_withdrawn(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$program = $content->createComposition('Programm mit Teaser', CompositionKind::Kurs);
|
||||
$program->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'programm')->value('id');
|
||||
$program->display_title = 'Name aus der Redaktion';
|
||||
$program->teaser = 'Teaser aus der Redaktion';
|
||||
$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());
|
||||
|
||||
$image = $this->store('bild', 'Pruefbild ohne Fassung', 'bild-bytes');
|
||||
$teaser = $this->store('film', 'Teaser ohne Fassung', 'teaser-bytes');
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
||||
$this->actingAs($editor, 'staff');
|
||||
|
||||
$found = app(EditorialCatalog::class)->presentationBrowse('ohne Fassung');
|
||||
$targets = array_column($found['items'], 'target');
|
||||
$this->assertContains('medium:'.$image->id, $targets);
|
||||
$this->assertContains('medium:'.$teaser->id, $targets);
|
||||
|
||||
$didactic = app(EditorialCatalog::class)->browse('ohne Fassung', 'alle', '', $program->id);
|
||||
$this->assertNotContains('medium:'.$image->id, array_column($didactic['items'], 'target'));
|
||||
$this->assertNotContains('medium:'.$teaser->id, array_column($didactic['items'], 'target'));
|
||||
|
||||
Livewire::test(EditCourse::class, ['record' => $program->getKey()])
|
||||
->call('openPresentationPicker')
|
||||
->set('pickerQuery', 'Pruefbild ohne')
|
||||
->set('presentationRole', 'titelbild')
|
||||
->call('assignFromPicker', 'medium:'.$image->id)
|
||||
->call('openPresentationPicker')
|
||||
->set('pickerQuery', 'Teaser ohne')
|
||||
->set('presentationRole', 'trailer')
|
||||
->set('bindToVersion', false)
|
||||
->call('assignFromPicker', 'medium:'.$teaser->id)
|
||||
->assertSee('Pruefbild ohne Fassung')
|
||||
->assertSee('Teaser ohne Fassung')
|
||||
->assertSee('Eigenständiges Medium, ohne Bindung an eine Fassung.');
|
||||
|
||||
$this->assertSame(0, $image->fresh()->versions()->count());
|
||||
$this->assertSame(0, $teaser->fresh()->versions()->count());
|
||||
$this->assertSame(1, $program->fresh()->versions()->count());
|
||||
$this->assertSame(0, Grant::query()->count());
|
||||
$this->assertNull(PresentationAssignment::query()->where('content_element_id', $image->id)->value('source_version_id'));
|
||||
$this->assertNull(PresentationAssignment::query()->where('content_element_id', $teaser->id)->value('source_version_id'));
|
||||
$this->assertSame(1, CompositionMember::query()->where('composition_version_id', $version->id)->count());
|
||||
|
||||
app(WebsiteRelease::class)->release($image->fresh());
|
||||
app(WebsiteRelease::class)->release($teaser->fresh());
|
||||
$image->refresh();
|
||||
$teaser->refresh();
|
||||
$this->assertNotNull($image->website_released_at);
|
||||
$this->assertNotNull($teaser->website_released_at);
|
||||
$this->assertSame(0, $image->versions()->count());
|
||||
$this->assertSame(0, $teaser->versions()->count());
|
||||
$this->assertSame(0, Grant::query()->count());
|
||||
Storage::disk('media_public')->assertExists($image->website_public_path);
|
||||
Storage::disk('media_public')->assertExists($teaser->website_public_path);
|
||||
$this->assertStringNotContainsString('originals', (string) $teaser->website_public_path);
|
||||
|
||||
$this->publish('/praesentation-ohne-fassung', [[
|
||||
'layout' => 'u2_2',
|
||||
'style' => [],
|
||||
'slots' => [
|
||||
$this->card('program_card', ['composition' => $program->id]),
|
||||
$this->card('program_card', ['composition' => $program->id], ['heading' => 'Nur diese Karte']),
|
||||
],
|
||||
]]);
|
||||
|
||||
$this->get('/praesentation-ohne-fassung')->assertOk()
|
||||
->assertSee('Name aus der Redaktion')
|
||||
->assertSee('Teaser aus der Redaktion')
|
||||
->assertSee('Nur diese Karte')
|
||||
->assertSee('/website-medien/'.$image->id, false)
|
||||
->assertDontSee('Interne Langfassung');
|
||||
|
||||
$film = app(WebsiteMedia::class)->present($teaser);
|
||||
$this->assertNotNull($film);
|
||||
$this->assertSame('film', $film->kind);
|
||||
$this->get($film->url)->assertOk()->assertStreamedContent('teaser-bytes');
|
||||
|
||||
$program->teaser = 'Teaser nach der zentralen Änderung';
|
||||
$program->save();
|
||||
$this->app->forgetInstance(WebsiteImage::class);
|
||||
$this->get('/praesentation-ohne-fassung')->assertOk()
|
||||
->assertSee('Teaser nach der zentralen Änderung')
|
||||
->assertSee('Nur diese Karte')
|
||||
->assertDontSee('Teaser aus der Redaktion');
|
||||
|
||||
app(WebsiteRelease::class)->withdraw($image->fresh());
|
||||
app(WebsiteRelease::class)->withdraw($teaser->fresh());
|
||||
$this->app->forgetInstance(WebsiteImage::class);
|
||||
|
||||
$after = $this->get('/praesentation-ohne-fassung')->assertOk()->getContent();
|
||||
$this->assertStringNotContainsString('/website-medien/'.$image->id, $after);
|
||||
$this->assertStringContainsString('Teaser nach der zentralen Änderung', $after);
|
||||
$this->assertStringContainsString('Nur diese Karte', $after);
|
||||
$this->get(route('website.media', $teaser))->assertNotFound();
|
||||
$this->get(route('website.media', $image))->assertNotFound();
|
||||
Storage::disk('media_derived')->assertExists($image->thumbnail_path);
|
||||
Storage::disk('media_derived')->assertExists($teaser->preview_path);
|
||||
$this->assertSame(0, $teaser->fresh()->versions()->count());
|
||||
$this->assertSame('Name aus der Redaktion', $program->fresh()->display_title);
|
||||
}
|
||||
|
||||
public function test_creating_a_presentation_film_does_not_open_a_content_version(): void
|
||||
{
|
||||
Storage::disk('cms_incoming')->put('inhalte/teaser.mp4', 'teaser-bytes');
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
$this->actingAs($editor, 'staff');
|
||||
|
||||
$element = MediumForm::create([
|
||||
'working_title' => 'Marketingclip',
|
||||
'shape' => 'film',
|
||||
'incoming' => 'inhalte/teaser.mp4',
|
||||
'without_version' => true,
|
||||
'description' => 'Nur die Website',
|
||||
], hold: false);
|
||||
|
||||
$this->assertSame(0, $element->versions()->count());
|
||||
$this->assertSame('teaser/'.$element->id.'/datei.mp4', $element->preview_path);
|
||||
$this->assertNull($element->website_released_at);
|
||||
$this->assertSame(0, Grant::query()->count());
|
||||
Storage::disk('media_derived')->assertExists($element->preview_path);
|
||||
Storage::disk('media_originals')->assertDirectoryEmpty('/');
|
||||
}
|
||||
|
||||
public function test_a_versionless_audio_preview_is_released_without_a_license(): void
|
||||
{
|
||||
$audio = $this->store('audio', 'Audiovorschau ohne Fassung', 'audio-bytes');
|
||||
$this->assertNull(app(WebsiteMedia::class)->present($audio));
|
||||
|
||||
app(WebsiteRelease::class)->release($audio);
|
||||
$audio->refresh();
|
||||
$presentation = app(WebsiteMedia::class)->present($audio);
|
||||
$this->assertNotNull($presentation);
|
||||
$this->assertSame('audio', $presentation->kind);
|
||||
$this->get($presentation->url)->assertOk()->assertStreamedContent('audio-bytes');
|
||||
$this->assertSame(0, $audio->versions()->count());
|
||||
$this->assertSame(0, Grant::query()->count());
|
||||
|
||||
app(WebsiteRelease::class)->withdraw($audio->fresh());
|
||||
$this->assertNull(app(WebsiteMedia::class)->present($audio->fresh()));
|
||||
$this->get(route('website.media', $audio))->assertNotFound();
|
||||
Storage::disk('media_derived')->assertExists($audio->preview_path);
|
||||
}
|
||||
|
||||
public function test_an_explicit_version_binding_stays_optional(): void
|
||||
{
|
||||
$content = app(ContentService::class);
|
||||
$film = $content->createElement('film', 'film', 'Unterricht');
|
||||
$version = $content->publishElementVersion($film, 'Fassung');
|
||||
$clip = $this->store('film', 'Clip ohne Fassung', 'clip-bytes');
|
||||
|
||||
app(PresentationMedia::class)->assign($film, 'trailer', $clip->id, null);
|
||||
$this->assertNull(PresentationAssignment::query()->value('source_version_id'));
|
||||
|
||||
app(PresentationMedia::class)->assign($film, 'trailer', $clip->id, $version->id);
|
||||
$this->assertSame($version->id, PresentationAssignment::query()->value('source_version_id'));
|
||||
$this->assertSame(0, $clip->fresh()->versions()->count());
|
||||
$this->assertSame(1, $film->fresh()->versions()->count());
|
||||
$this->assertSame(0, Grant::query()->count());
|
||||
}
|
||||
|
||||
public function test_a_widget_with_nothing_but_a_missing_medium_is_omitted(): void
|
||||
{
|
||||
$image = $this->store('bild', 'Nur ein Bild', 'bild-bytes');
|
||||
$html = app(WidgetRenderer::class)->renderAll([
|
||||
['type' => 'heading', 'v' => 1, 'variant' => 'standard', 'settings' => [], 'data' => ['heading' => 'Die Überschrift bleibt'], 'refs' => []],
|
||||
['type' => 'cards', 'v' => 1, 'variant' => 'standard', 'settings' => [], 'data' => ['items' => [
|
||||
['title' => '', 'text' => null, 'url' => null, 'image' => $image->id],
|
||||
]], 'refs' => []],
|
||||
], RenderContext::publicPage())->toHtml();
|
||||
|
||||
$this->assertStringContainsString('Die Überschrift bleibt', $html);
|
||||
$this->assertStringNotContainsString('widget-cards', $html);
|
||||
$this->assertStringNotContainsString('<img', $html);
|
||||
}
|
||||
|
||||
private function store(string $output, string $title, string $bytes): ContentElement
|
||||
{
|
||||
$extension = match ($output) {
|
||||
'bild' => 'jpg',
|
||||
'audio' => 'mp3',
|
||||
default => 'mp4',
|
||||
};
|
||||
$path = 'inhalte/'.md5($title).'.'.$extension;
|
||||
Storage::disk('cms_incoming')->put($path, $bytes);
|
||||
$element = app(ContentService::class)->createElement($output, $output, $title);
|
||||
$element->display_title = $title;
|
||||
$element->save();
|
||||
app(PresentationFile::class)->store($element, $path);
|
||||
|
||||
return $element->fresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $sections
|
||||
*/
|
||||
private function publish(string $path, array $sections): void
|
||||
{
|
||||
$page = Page::query()->create(['path' => $path]);
|
||||
$service = app(PageService::class);
|
||||
$revision = $service->saveRevision($page, $sections, null, null, null);
|
||||
$service->publish($page, $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];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Media\WebsiteIntake;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Website-Bilder dienen als Einstieg und Abschnittshintergrund. Ihre Ableitung darf nicht auf Vorschaugröße (640 px)
|
||||
* schrumpfen, wird aber auch nicht vergrößert. Transparente Flächen werden weiß.
|
||||
*/
|
||||
class WebsiteImageResolutionTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Storage::fake('cms_incoming');
|
||||
Storage::fake('media_derived');
|
||||
Storage::fake('media_public');
|
||||
}
|
||||
|
||||
public function test_large_images_keep_up_to_2400_pixels_and_transparency_becomes_white(): void
|
||||
{
|
||||
$element = $this->accept('cms/gross.png', $this->png(3000, 1500, transparent: true));
|
||||
[$width, $height] = getimagesizefromstring(Storage::disk('media_derived')->get($element->thumbnail_path));
|
||||
$this->assertSame([2400, 1200], [$width, $height]);
|
||||
|
||||
$image = imagecreatefromstring(Storage::disk('media_derived')->get($element->thumbnail_path));
|
||||
$this->assertGreaterThan(240, imagecolorat($image, 5, 5) & 0xFF, 'Transparenz wird weiß, nicht schwarz.');
|
||||
}
|
||||
|
||||
public function test_small_images_are_not_enlarged(): void
|
||||
{
|
||||
$element = $this->accept('cms/klein.png', $this->png(800, 450));
|
||||
[$width, $height] = getimagesizefromstring(Storage::disk('media_derived')->get($element->thumbnail_path));
|
||||
$this->assertSame([800, 450], [$width, $height]);
|
||||
}
|
||||
|
||||
private function accept(string $path, string $bytes): ContentElement
|
||||
{
|
||||
Storage::disk('cms_incoming')->put($path, $bytes);
|
||||
|
||||
return app(WebsiteIntake::class)->acceptImage($path, 'Testbild')->refresh();
|
||||
}
|
||||
|
||||
private function png(int $width, int $height, bool $transparent = false): string
|
||||
{
|
||||
$image = imagecreatetruecolor($width, $height);
|
||||
|
||||
if ($transparent) {
|
||||
imagesavealpha($image, true);
|
||||
imagefill($image, 0, 0, imagecolorallocatealpha($image, 0, 0, 0, 127));
|
||||
} else {
|
||||
imagefill($image, 0, 0, imagecolorallocate($image, 30, 90, 160));
|
||||
}
|
||||
|
||||
ob_start();
|
||||
imagepng($image);
|
||||
|
||||
return (string) ob_get_clean();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Media\WebsiteIntake;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
class WebsiteIntakeTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
Storage::fake('cms_incoming');
|
||||
Storage::fake('media_derived');
|
||||
Storage::fake('media_public');
|
||||
Storage::fake('media_originals');
|
||||
}
|
||||
|
||||
public function test_an_uploaded_image_becomes_a_released_medium(): void
|
||||
{
|
||||
Storage::disk('cms_incoming')->put('cms/hero.png', $this->pngBytes());
|
||||
$editor = User::factory()->redakteur()->create();
|
||||
|
||||
$element = app(WebsiteIntake::class)->acceptImage(
|
||||
'cms/hero.png',
|
||||
'Lara im Park',
|
||||
'Foto: Lara und Felix',
|
||||
'Lara sitzt auf einer Parkbank',
|
||||
$editor,
|
||||
);
|
||||
|
||||
$element->refresh();
|
||||
$this->assertSame(0, $element->versions()->count());
|
||||
$this->assertSame(0, Grant::query()->count());
|
||||
$this->assertSame('Lara im Park', $element->display_title);
|
||||
$this->assertSame('vorschau/element-'.$element->id.'.jpg', $element->thumbnail_path);
|
||||
$this->assertSame('website/'.$element->id.'/datei.jpg', $element->website_public_path);
|
||||
$this->assertNotNull($element->website_released_at);
|
||||
Storage::disk('cms_incoming')->assertMissing('cms/hero.png');
|
||||
Storage::disk('media_derived')->assertExists($element->thumbnail_path);
|
||||
Storage::disk('media_originals')->assertMissing('cms/hero.png');
|
||||
|
||||
$presentation = app(WebsiteMedia::class)->present($element);
|
||||
$this->assertNotNull($presentation);
|
||||
$this->assertSame($element->id, $presentation->elementId);
|
||||
$this->assertSame('Lara sitzt auf einer Parkbank', $presentation->alt);
|
||||
$this->assertSame('Foto: Lara und Felix', $presentation->credit);
|
||||
$this->assertSame('bild', $presentation->kind);
|
||||
$this->assertStringStartsWith("\xFF\xD8", $this->get($presentation->url)->assertOk()->streamedContent());
|
||||
}
|
||||
|
||||
public function test_a_missing_or_misplaced_file_creates_no_medium(): void
|
||||
{
|
||||
$intake = app(WebsiteIntake::class);
|
||||
Storage::disk('cms_incoming')->put('cms/hero.png', $this->pngBytes());
|
||||
|
||||
try {
|
||||
$intake->acceptImage('cms/hero.png', ' ');
|
||||
$this->fail('Der Titel hätte abgelehnt werden müssen.');
|
||||
} catch (DomainRuleException $exception) {
|
||||
$this->assertSame('Der Titel fehlt.', $exception->getMessage());
|
||||
}
|
||||
|
||||
foreach (['cms/fehlt.png', 'originals/geheim.png', 'cms/../originals/geheim.png', ''] as $path) {
|
||||
try {
|
||||
$intake->acceptImage($path, 'Ohne Datei');
|
||||
$this->fail('Die Datei hätte abgelehnt werden müssen.');
|
||||
} catch (DomainRuleException $exception) {
|
||||
$this->assertSame('Die Bilddatei liegt nicht im Eingang.', $exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertSame(0, ContentElement::query()->count());
|
||||
Storage::disk('media_public')->assertMissing('website/1/datei.jpg');
|
||||
}
|
||||
|
||||
public function test_an_unreadable_file_is_kept_but_not_released(): void
|
||||
{
|
||||
Storage::disk('cms_incoming')->put('cms/kaputt.jpg', 'kein bild');
|
||||
|
||||
$element = app(WebsiteIntake::class)->acceptImage('cms/kaputt.jpg', 'Unlesbar', 'Quelle');
|
||||
|
||||
$this->assertNull($element->fresh()->website_released_at);
|
||||
$this->assertNotNull($element->fresh()->thumbnail_error);
|
||||
$this->assertNull(app(WebsiteMedia::class)->present($element));
|
||||
Storage::disk('cms_incoming')->assertExists('cms/kaputt.jpg');
|
||||
Storage::disk('media_public')->assertMissing('website/'.$element->id.'/datei.jpg');
|
||||
}
|
||||
|
||||
private function pngBytes(): string
|
||||
{
|
||||
$image = imagecreatetruecolor(8, 8);
|
||||
ob_start();
|
||||
imagepng($image);
|
||||
$bytes = ob_get_clean();
|
||||
imagedestroy($image);
|
||||
|
||||
return is_string($bytes) ? $bytes : '';
|
||||
}
|
||||
}
|
||||
Loaded 100 of 103 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user