Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a359a5fb69 | ||
|
|
7b325f0d66 | ||
|
|
5590225f4f | ||
|
|
f29ea58fd5 | ||
|
|
c4be6ed8dc | ||
|
|
053a8d4648 | ||
|
|
7c63424ea6 | ||
|
|
13530b8171 | ||
|
|
72130d66c5 | ||
|
|
d37a7093dd | ||
|
|
3e56314cf9 | ||
|
|
8a6678aad7 | ||
|
|
b178939852 | ||
|
|
a08067c078 | ||
|
|
bc1f84ac89 | ||
|
|
39ab25d8c6 | ||
|
|
127ea86817 | ||
|
|
cca069be48 | ||
|
|
f511ad10de | ||
|
|
f4d225d0b2 | ||
|
|
89fd95b243 | ||
|
|
87a7ffc45f | ||
|
|
0bfb53463a | ||
|
|
3cdb36e7a3 | ||
|
|
5dccbbce80 | ||
|
|
8a3f6df770 | ||
|
|
656f999d2c | ||
|
|
8387cc90df | ||
|
|
d89d4bdc70 | ||
|
|
7c1caec546 | ||
|
|
8390dcdb41 | ||
|
|
33aaf64024 | ||
|
|
3a5e5290f1 | ||
|
|
c6186fba6e | ||
|
|
dc33f0ee37 | ||
|
|
6152451e2e | ||
|
|
4cad60259a | ||
|
|
2ac2923852 | ||
|
|
480d55989b |
No files matched your search
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageRevision;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Console\Command;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Wiederherstellungsweg vor einem Code-Rollback (docs/architektur/cms-widget-registry.md, Abschnitt Rollback).
|
||||
*
|
||||
* Setzt die veröffentlichte Revision jeder Seite auf die letzte Revision, die vor dem angegebenen Zeitpunkt
|
||||
* gespeichert wurde. Revisionen werden weder geändert noch gelöscht; nur der Veröffentlichungszeiger wechselt.
|
||||
* Ohne --apply wird nur angezeigt, was geschähe.
|
||||
*/
|
||||
class RevertPublishedPages extends Command
|
||||
{
|
||||
protected $signature = 'cms:revert-published
|
||||
{--before= : Zeitpunkt des Deployments, zum Beispiel "2026-11-17 18:00" (Zeitzone der Anwendung)}
|
||||
{--apply : Änderung tatsächlich ausführen}';
|
||||
|
||||
protected $description = 'Setzt veröffentlichte Seiten auf ihren Stand vor einem Zeitpunkt zurück (nur Veröffentlichungszeiger).';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
try {
|
||||
$before = blank($this->option('before')) ? null : CarbonImmutable::parse((string) $this->option('before'));
|
||||
} catch (Throwable) {
|
||||
$before = null;
|
||||
}
|
||||
|
||||
if ($before === null) {
|
||||
$this->error('Bitte --before mit einem gültigen Zeitpunkt angeben.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$apply = (bool) $this->option('apply');
|
||||
$rows = [];
|
||||
|
||||
foreach (Page::query()->whereNotNull('published_revision_id')->with('publishedRevision')->orderBy('path')->get() as $page) {
|
||||
$current = $page->publishedRevision;
|
||||
|
||||
if ($current === null || $current->created_at < $before) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$previous = PageRevision::query()
|
||||
->where('page_id', $page->id)
|
||||
->where('created_at', '<', $before)
|
||||
->latest('id')
|
||||
->first();
|
||||
|
||||
if ($previous === null) {
|
||||
$rows[] = [$page->path, $current->id, '–', 'keine ältere Revision: Seite wird zurückgezogen'];
|
||||
if ($apply) {
|
||||
$page->published_revision_id = null;
|
||||
$page->save();
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$rows[] = [$page->path, $current->id, $previous->id, $apply ? 'zurückgesetzt' : 'würde zurückgesetzt'];
|
||||
if ($apply) {
|
||||
$page->published_revision_id = $previous->id;
|
||||
$page->save();
|
||||
}
|
||||
}
|
||||
|
||||
if ($rows === []) {
|
||||
$this->info('Keine veröffentlichte Seite stammt aus der Zeit ab '.$before->format('d.m.Y H:i').'.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$this->table(['Pfad', 'veröffentlicht', 'neu veröffentlicht', 'Ergebnis'], $rows);
|
||||
|
||||
if (! $apply) {
|
||||
$this->warn('Probelauf. Mit --apply ausführen.');
|
||||
}
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Catalog;
|
||||
|
||||
/**
|
||||
* Anzeigedaten des Fachobjekts hinter einer Premium-Karte (Thema, Medium/Material, Programm/Modul).
|
||||
* Wird zur Laufzeit aus den maßgeblichen Fachdaten gelesen und nie im CMS gespeichert.
|
||||
*
|
||||
* - 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,
|
||||
public ?string $summary,
|
||||
public string $kind,
|
||||
public ?string $badge,
|
||||
public array $meta,
|
||||
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)
|
||||
@@ -171,6 +176,165 @@ public function entries(array $refs, bool $includeNonPublic): array
|
||||
return $entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 isCardSelectable(Composition $composition): bool
|
||||
{
|
||||
return $composition->archived_at === null
|
||||
&& in_array($composition->editorialContentKind?->slug, self::SELECTABLE_KINDS, true)
|
||||
&& $this->latestReadyVersion($composition) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function cardSearch(?string $term, int $limit = 25): array
|
||||
{
|
||||
$term = trim((string) $term);
|
||||
|
||||
$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();
|
||||
|
||||
$options = [];
|
||||
foreach ($candidates as $composition) {
|
||||
if (! $this->isCardSelectable($composition)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$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: $profile->value('display_title') ?: $this->title($composition),
|
||||
summary: $summary ?? $goal,
|
||||
kind: $kind,
|
||||
badge: null,
|
||||
meta: $meta,
|
||||
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);
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Catalog;
|
||||
|
||||
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).
|
||||
*
|
||||
* Auswahl in der Redaktion: jedes nicht archivierte Inhaltselement mit mindestens einer nicht gesperrten Fassung.
|
||||
*
|
||||
* Ö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).
|
||||
*
|
||||
* Ö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;
|
||||
|
||||
public function __construct(
|
||||
private readonly PublicCatalogReader $catalog,
|
||||
private readonly CompositionStructureReader $structure,
|
||||
) {}
|
||||
|
||||
public function isSelectable(ContentElement $element): bool
|
||||
{
|
||||
return $element->archived_at === null
|
||||
&& $element->versions()->where('status', '!=', ContentVersionStatus::Gesperrt->value)->exists();
|
||||
}
|
||||
|
||||
public function isReady(ContentElement $element): bool
|
||||
{
|
||||
return $element->versions()->where('status', ContentVersionStatus::Bereit->value)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Öffentliches Programm, in dessen gezeigter Fassung das Element vorkommt, sonst null.
|
||||
*
|
||||
* @return array{id: int, title: string}|null
|
||||
*/
|
||||
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>
|
||||
*/
|
||||
public function search(?string $term, int $limit = 25): array
|
||||
{
|
||||
$term = trim((string) $term);
|
||||
|
||||
$candidates = ContentElement::query()
|
||||
->with('editorialContentKind')
|
||||
->whereNull('archived_at')
|
||||
->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
|
||||
->whereRaw('LOWER(working_title) LIKE ?', [$like])
|
||||
->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like]));
|
||||
})
|
||||
->orderBy('working_title')
|
||||
->limit($limit)
|
||||
->get();
|
||||
|
||||
$options = [];
|
||||
foreach ($candidates as $element) {
|
||||
$options[$element->id] = $this->optionLabel($element);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function labelFor(mixed $id): ?string
|
||||
{
|
||||
$element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
return $element === null ? null : $this->optionLabel($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, array $draft = []): ?CardSubject
|
||||
{
|
||||
$element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
if ($element === null || ! $this->isSelectable($element)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$public = $this->isPublic($element);
|
||||
|
||||
if (! $public && ! $includeNonPublic) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$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: $title,
|
||||
summary: $summary,
|
||||
kind: filled($editorialKind) ? (string) $editorialKind : $output,
|
||||
badge: $output,
|
||||
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',
|
||||
);
|
||||
}
|
||||
|
||||
/** Bezeichnung der Ausgabeart, wie in der Redaktionsstruktur (CompositionRelease::outputLabel). */
|
||||
public static function outputLabel(string $outputClass): string
|
||||
{
|
||||
return match ($outputClass) {
|
||||
'film' => 'Film',
|
||||
'audio' => 'Hörstück',
|
||||
'bild' => 'Bild',
|
||||
'document', 'pdf' => 'Dokument',
|
||||
default => 'Text',
|
||||
};
|
||||
}
|
||||
|
||||
public function visibilityNote(ContentElement $element): string
|
||||
{
|
||||
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->isPublic($element)
|
||||
? 'öffentlich über Programmseite'
|
||||
: ($this->isReady($element) ? 'nur Redaktionsvorschau' : 'Entwurf, nur Redaktionsvorschau');
|
||||
$kind = $element->editorialContentKind?->label ?: self::outputLabel((string) $element->output_class);
|
||||
|
||||
return (string) ($element->display_title ?: $element->working_title).' · '.$kind.' · '.$visibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index aller Elemente, die in der gezeigten Fassung eines öffentlichen Programms vorkommen (auch verschachtelt).
|
||||
*
|
||||
* @return array<int, array{id: int, title: string}>
|
||||
*/
|
||||
private function publicIndex(): array
|
||||
{
|
||||
if ($this->publicIndex !== null) {
|
||||
return $this->publicIndex;
|
||||
}
|
||||
|
||||
$index = [];
|
||||
|
||||
foreach ($this->catalog->publicPrograms() as $program) {
|
||||
$version = $this->catalog->shownVersion($program);
|
||||
|
||||
if ($version === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$entry = ['id' => (int) $program->id, 'title' => (string) ($program->display_title ?: $program->designation)];
|
||||
|
||||
foreach ($this->elementIds($this->structure->tree($version)) as $elementId) {
|
||||
$index[$elementId] ??= $entry;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->publicIndex = $index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<StructureNode> $nodes
|
||||
* @return list<int>
|
||||
*/
|
||||
private function elementIds(array $nodes): array
|
||||
{
|
||||
$ids = [];
|
||||
|
||||
foreach ($nodes as $node) {
|
||||
if ($node->contentElementId !== null) {
|
||||
$ids[] = (int) $node->contentElementId;
|
||||
}
|
||||
|
||||
array_push($ids, ...$this->elementIds($node->children));
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,25 @@
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class NavigationItem extends Model
|
||||
{
|
||||
/**
|
||||
* Plätze im globalen Website-Gerüst. Die drei Fußbereichsgruppen ersetzen eine eigene Footer-Verwaltung.
|
||||
*/
|
||||
public const PLACEMENTS = [
|
||||
'header' => 'Kopfzeile',
|
||||
'footer' => 'Fußzeile',
|
||||
'header' => 'Kopfzeile (Hauptnavigation)',
|
||||
'footer' => 'Fußbereich: Service',
|
||||
'footer_contact' => 'Fußbereich: Kontakt',
|
||||
'footer_legal' => 'Fußbereich: Rechtliches',
|
||||
];
|
||||
|
||||
/** Spaltenüberschriften im Fußbereich. */
|
||||
public const FOOTER_GROUPS = [
|
||||
'footer' => 'Service',
|
||||
'footer_contact' => 'Kontakt',
|
||||
'footer_legal' => 'Rechtliches',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
@@ -21,8 +34,19 @@ class NavigationItem extends Model
|
||||
'placement',
|
||||
'sort_order',
|
||||
'is_visible',
|
||||
'parent_id',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
// Untermenüs gibt es nur in der Hauptnavigation.
|
||||
static::saving(function (NavigationItem $item): void {
|
||||
if ($item->placement !== 'header' && $item->getAttribute('parent_id') !== null) {
|
||||
$item->parent_id = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
@@ -35,6 +59,16 @@ public function page(): BelongsTo
|
||||
return $this->belongsTo(Page::class);
|
||||
}
|
||||
|
||||
public function parent(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(self::class, 'parent_id');
|
||||
}
|
||||
|
||||
public function children(): HasMany
|
||||
{
|
||||
return $this->hasMany(self::class, 'parent_id')->orderBy('sort_order')->orderBy('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<NavigationItem> $query
|
||||
*/
|
||||
@@ -59,4 +93,22 @@ public function href(): ?string
|
||||
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pfad des Ziels innerhalb der Website (für die Kennzeichnung des aktiven Eintrags); null bei externen Zielen.
|
||||
*/
|
||||
public function targetPath(): ?string
|
||||
{
|
||||
if ($this->page !== null) {
|
||||
return $this->page->path;
|
||||
}
|
||||
|
||||
if (is_string($this->url) && str_starts_with($this->url, '/') && ! str_starts_with($this->url, '//')) {
|
||||
$path = parse_url($this->url, PHP_URL_PATH);
|
||||
|
||||
return is_string($path) ? '/'.trim($path, '/') : null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Domain\Cms;
|
||||
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use App\Domain\Cms\Sections\PageSections;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@@ -14,6 +14,7 @@ class PageRevision extends Model
|
||||
protected $fillable = [
|
||||
'page_id',
|
||||
'blocks',
|
||||
'sections',
|
||||
'seo_title',
|
||||
'seo_description',
|
||||
'created_by',
|
||||
@@ -23,6 +24,7 @@ protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'blocks' => 'array',
|
||||
'sections' => 'array',
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
@@ -38,13 +40,24 @@ public function author(): BelongsTo
|
||||
}
|
||||
|
||||
/**
|
||||
* Bausteine als aktuelle Widget-Hüllen. Die gespeicherten Daten bleiben unverändert.
|
||||
* Abschnitte als aktuelle Hüllen. Revisionen ohne Abschnitte (vor Einführung des Rasters) werden als
|
||||
* einspaltige Abschnitte gelesen. Die gespeicherten Daten bleiben unverändert.
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function sections(): array
|
||||
{
|
||||
return app(PageSections::class)->read($this->sections, $this->blocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Widgets in Lesereihenfolge als aktuelle Hüllen.
|
||||
*
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function widgets(): array
|
||||
{
|
||||
return app(WidgetRegistry::class)->read($this->blocks);
|
||||
return app(PageSections::class)->flatten($this->sections());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,6 +65,6 @@ public function widgets(): array
|
||||
*/
|
||||
public function contentTitle(): ?string
|
||||
{
|
||||
return app(WidgetRegistry::class)->pageTitle($this->blocks);
|
||||
return app(PageSections::class)->pageTitle($this->sections());
|
||||
}
|
||||
}
|
||||
@@ -2,23 +2,35 @@
|
||||
|
||||
namespace App\Domain\Cms;
|
||||
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use App\Domain\Cms\Sections\PageSections;
|
||||
use App\Jobs\PublishPublicMedia;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class PageService
|
||||
{
|
||||
public function __construct(private readonly WidgetRegistry $widgets) {}
|
||||
public function __construct(private readonly PageSections $sections) {}
|
||||
|
||||
/**
|
||||
* Speichert einen Entwurf als neue Revision. Veröffentlicht nichts.
|
||||
*
|
||||
* @param array<int|string, mixed> $blocks Bausteine im Altformat oder als Widget-Hülle
|
||||
* @param array<int|string, mixed> $content Abschnitte mit Slots; flache Widgets (Altformat oder Hülle)
|
||||
* werden als einspaltige Abschnitte übernommen
|
||||
*/
|
||||
public function saveRevision(Page $page, array $blocks, ?string $seoTitle, ?string $seoDescription, ?User $author): PageRevision
|
||||
public function saveRevision(Page $page, array $content, ?string $seoTitle, ?string $seoDescription, ?User $author): PageRevision
|
||||
{
|
||||
return $this->storeRevision($page, $this->widgets->normalize($blocks), $seoTitle, $seoDescription, $author);
|
||||
$sections = $this->sections->normalize($content);
|
||||
$seoTitle = $seoTitle !== null && $seoTitle !== '' ? $seoTitle : null;
|
||||
$seoDescription = $seoDescription !== null && $seoDescription !== '' ? $seoDescription : null;
|
||||
|
||||
// Unveränderter Stand: keine weitere Revision (zum Beispiel „Veröffentlichen“ direkt nach dem Speichern).
|
||||
$latest = $page->revisions()->first();
|
||||
if ($latest !== null && $latest->sections === $sections && $latest->seo_title === $seoTitle && $latest->seo_description === $seoDescription) {
|
||||
return $latest;
|
||||
}
|
||||
|
||||
return $this->storeRevision($page, $this->sections->flatten($sections), $sections, $seoTitle, $seoDescription, $author);
|
||||
}
|
||||
|
||||
public function publish(Page $page, PageRevision $revision): void
|
||||
@@ -34,7 +46,7 @@ public function publish(Page $page, PageRevision $revision): void
|
||||
}
|
||||
|
||||
/**
|
||||
* Legt den Stand einer früheren Revision unverändert als neue Revision an. Die gespeicherten Bausteine
|
||||
* Legt den Stand einer früheren Revision unverändert als neue Revision an. Abschnitte und Bausteine
|
||||
* werden nicht umgeschrieben; ältere Formate werden erst beim Lesen angehoben.
|
||||
*/
|
||||
public function restore(Page $page, PageRevision $source, ?User $author): PageRevision
|
||||
@@ -48,12 +60,33 @@ public function restore(Page $page, PageRevision $source, ?User $author): PageRe
|
||||
return $this->storeRevision(
|
||||
$page,
|
||||
$source->blocks ?? [],
|
||||
$source->sections,
|
||||
$source->seo_title,
|
||||
$source->seo_description,
|
||||
$author,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Legt eine neue, unveröffentlichte Seite mit dem zuletzt gespeicherten Stand einer vorhandenen Seite an.
|
||||
* Die Vorlage bleibt unverändert; spätere Änderungen wirken nicht auf die Kopie.
|
||||
*/
|
||||
public function duplicate(Page $source, string $path, ?User $author): Page
|
||||
{
|
||||
$revision = $source->latestRevision ?? $source->publishedRevision;
|
||||
$page = Page::query()->create(['path' => $this->availablePath($path)]);
|
||||
|
||||
$this->saveRevision(
|
||||
$page,
|
||||
$revision?->sections() ?? [],
|
||||
$revision?->seo_title,
|
||||
$revision?->seo_description,
|
||||
$author,
|
||||
);
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalisiert den Pfad und prüft, dass keine andere Seite ihn verwendet.
|
||||
*/
|
||||
@@ -95,18 +128,30 @@ public function normalizePath(string $path): string
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $blocks
|
||||
* @param array<int|string, mixed> $blocks flache Widget-Liste (Rollback-Fassung)
|
||||
* @param array<int|string, mixed>|null $sections Abschnitte; null bei Revisionen aus der Zeit vor dem Raster
|
||||
*/
|
||||
private function storeRevision(Page $page, array $blocks, ?string $seoTitle, ?string $seoDescription, ?User $author): PageRevision
|
||||
private function storeRevision(Page $page, array $blocks, ?array $sections, ?string $seoTitle, ?string $seoDescription, ?User $author): PageRevision
|
||||
{
|
||||
$revision = $page->revisions()->create([
|
||||
$attributes = [
|
||||
'blocks' => array_values($blocks),
|
||||
'seo_title' => $seoTitle !== null && $seoTitle !== '' ? $seoTitle : null,
|
||||
'seo_description' => $seoDescription !== null && $seoDescription !== '' ? $seoDescription : null,
|
||||
'created_by' => $author?->id,
|
||||
]);
|
||||
];
|
||||
|
||||
foreach ($this->widgets->mediaPaths($revision->blocks) as $path) {
|
||||
// Die Erstbefüllung der Website läuft innerhalb einer frühen Migration, bevor die Spalte existiert.
|
||||
// Solche Revisionen haben keine Abschnitte und werden beim Lesen als einspaltige Abschnitte gelesen.
|
||||
if ($sections !== null && Schema::hasColumn('page_revisions', 'sections')) {
|
||||
$attributes['sections'] = array_values($sections);
|
||||
}
|
||||
|
||||
$revision = $page->revisions()->create($attributes);
|
||||
|
||||
// „Geändert“ in der Seitenliste zeigt die letzte Bearbeitung, nicht das Anlagedatum.
|
||||
$page->touch();
|
||||
|
||||
foreach ($this->sections->mediaPaths($revision->sections()) as $path) {
|
||||
PublishPublicMedia::dispatch($path);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,360 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Abschnitts- und Slotmodell einer Seite: Seite → Abschnitte → Slots → Widget-Instanzen.
|
||||
*
|
||||
* Gespeicherte Hülle eines Abschnitts (Version 1):
|
||||
* {id, v, layout, style: {background, image, focus, overlay, width, spacing_top, spacing_bottom, gap, divider}, slots: [Widget-Hülle|null, …]}
|
||||
*
|
||||
* Version 2 (Abstände): oben, unten und Widget-Abstand sind drei unabhängige Werte. Hüllen der Version 1 werden beim
|
||||
* Lesen übersetzt (SectionStyle::migrateSpacing), ohne die Darstellung zu ändern; gespeicherte Revisionen bleiben.
|
||||
*
|
||||
* Jeder Slot enthält höchstens ein Widget aus dem zentralen Widget-Register. Abschnitte sind nicht verschachtelbar.
|
||||
* Revisionen ohne Abschnitte (Bestand vor dieser Fassung) werden beim Lesen als einspaltige Abschnitte gelesen.
|
||||
*/
|
||||
class PageSections
|
||||
{
|
||||
public const VERSION = 2;
|
||||
|
||||
public const MAX_SECTIONS = 30;
|
||||
|
||||
public const MAX_WIDGETS = 60;
|
||||
|
||||
public function __construct(private readonly WidgetRegistry $widgets) {}
|
||||
|
||||
/**
|
||||
* Lesepfad. Unbekannte Werte fallen auf Vorgaben zurück, unbekannte Widget-Arten entfallen.
|
||||
*
|
||||
* @param array<int|string, mixed>|null $sections gespeicherte Abschnitte (Spalte sections)
|
||||
* @param array<int|string, mixed>|null $blocks flache Bausteinliste (Spalte blocks), nur ohne Abschnitte verwendet
|
||||
* @return list<array{id: ?string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}>
|
||||
*/
|
||||
public function read(?array $sections, ?array $blocks = null): array
|
||||
{
|
||||
if ($sections === null) {
|
||||
return $this->wrapWidgets($blocks ?? []);
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach (SectionStyle::migrateSpacing(array_values(array_filter($sections, 'is_array')), byVersion: true) as $section) {
|
||||
$result[] = $this->upcastSection($section);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schreibpfad: prüft und bereinigt Abschnitte für eine neue Revision. Flache Widgets (ohne „slots“) werden
|
||||
* als einspaltige Abschnitte übernommen. Alle Fehler der Seite werden gesammelt gemeldet; Schlüssel:
|
||||
* „sections.N.layout“, „sections.N.style.image“, „sections.N.slots“, „sections.N.slots.M.data.feld“.
|
||||
*
|
||||
* @param array<int|string, mixed> $content
|
||||
* @return list<array{id: string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}>
|
||||
*/
|
||||
public function normalize(array $content): array
|
||||
{
|
||||
$items = array_values($content);
|
||||
|
||||
if (count($items) > self::MAX_SECTIONS) {
|
||||
throw ValidationException::withMessages([
|
||||
'sections' => 'Eine Seite hat höchstens '.self::MAX_SECTIONS.' Abschnitte.',
|
||||
]);
|
||||
}
|
||||
|
||||
$errors = [];
|
||||
$sections = [];
|
||||
$seenSectionIds = [];
|
||||
$seenWidgetIds = [];
|
||||
$widgetCount = 0;
|
||||
|
||||
// Eingaben mit Abständen der Version 1 (zum Beispiel ältere Aufrufer) werden wie beim Lesen übersetzt.
|
||||
$migrated = SectionStyle::migrateSpacing(array_map(
|
||||
fn ($item) => is_array($item) && array_key_exists('slots', $item) ? $item : ['style' => [], 'slots' => [$item]],
|
||||
$items,
|
||||
));
|
||||
|
||||
foreach ($items as $index => $item) {
|
||||
if (! is_array($item)) {
|
||||
$errors["sections.$index"] = ['Ein Abschnitt ist unvollständig.'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! array_key_exists('slots', $item)) {
|
||||
$item = ['id' => null, 'layout' => SectionLayouts::DEFAULT, 'style' => [], 'slots' => [$item]];
|
||||
} else {
|
||||
$item['style'] = $migrated[$index]['style'] ?? ($item['style'] ?? []);
|
||||
}
|
||||
|
||||
$sections[] = $this->normalizeSection($item, $index, $errors, $seenSectionIds, $seenWidgetIds, $widgetCount);
|
||||
}
|
||||
|
||||
if ($widgetCount > self::MAX_WIDGETS) {
|
||||
$errors['sections'] = ['Eine Seite enthält höchstens '.self::MAX_WIDGETS.' Widgets.'];
|
||||
}
|
||||
|
||||
if ($errors !== []) {
|
||||
throw ValidationException::withMessages($errors);
|
||||
}
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Widgets in Lesereihenfolge (Abschnitt für Abschnitt, Slot für Slot). Wird zusätzlich als flache
|
||||
* Bausteinliste gespeichert, damit ein Code-Rollback auf die Fassung vor den Abschnitten die Inhalte
|
||||
* weiterhin untereinander darstellt.
|
||||
*
|
||||
* @param list<array<string, mixed>> $sections
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function flatten(array $sections): array
|
||||
{
|
||||
$widgets = [];
|
||||
|
||||
foreach ($sections as $section) {
|
||||
$count = SectionLayouts::slotCount($section['layout']);
|
||||
|
||||
foreach (array_slice($section['slots'], 0, $count) as $widget) {
|
||||
if (is_array($widget)) {
|
||||
$widgets[] = $widget;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Öffentliche Medien der Seite: Widget-Bilder und Hintergrundbilder der Abschnitte.
|
||||
*
|
||||
* @param list<array<string, mixed>> $sections
|
||||
* @return list<string>
|
||||
*/
|
||||
public function mediaPaths(array $sections): array
|
||||
{
|
||||
$paths = [];
|
||||
|
||||
foreach ($sections as $section) {
|
||||
$style = SectionStyle::fromStored($section['style'] ?? []);
|
||||
if (is_string($style['image']) && PublicMedia::isPublicPath($style['image'])) {
|
||||
$paths[] = $style['image'];
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->widgets->mediaPaths($this->flatten($sections)) as $path) {
|
||||
$paths[] = $path;
|
||||
}
|
||||
|
||||
return array_values(array_unique($paths));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $sections
|
||||
*/
|
||||
public function pageTitle(array $sections): ?string
|
||||
{
|
||||
return $this->widgets->pageTitle($this->flatten($sections));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int|string, mixed> $blocks
|
||||
* @return list<array{id: ?string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}>
|
||||
*/
|
||||
private function wrapWidgets(array $blocks): array
|
||||
{
|
||||
$sections = [];
|
||||
|
||||
foreach ($this->widgets->read($blocks) as $position => $widget) {
|
||||
$sections[] = [
|
||||
'id' => null,
|
||||
'v' => self::VERSION,
|
||||
'layout' => SectionLayouts::DEFAULT,
|
||||
// Bestand vor dem Raster stand in einem durchgehenden Blatt: kompakte Abstände, zwischen den Widgets
|
||||
// nur einmal (oben kein Abstand ab dem zweiten), wie bisher.
|
||||
'style' => ['spacing_top' => $position === 0 ? 'compact' : 'none', 'spacing_bottom' => 'compact', 'gap' => 'normal'] + SectionStyle::DEFAULTS,
|
||||
'slots' => [$widget],
|
||||
];
|
||||
}
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $section
|
||||
* @return array{id: ?string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}
|
||||
*/
|
||||
private function upcastSection(array $section): array
|
||||
{
|
||||
$layout = SectionLayouts::has($section['layout'] ?? null) ? $section['layout'] : SectionLayouts::DEFAULT;
|
||||
$slots = [];
|
||||
|
||||
foreach (array_values(is_array($section['slots'] ?? null) ? $section['slots'] : []) as $slot) {
|
||||
$slots[] = is_array($slot) ? $this->widgets->upcast($slot) : null;
|
||||
}
|
||||
|
||||
while (count($slots) < SectionLayouts::slotCount($layout)) {
|
||||
$slots[] = null;
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => is_string($section['id'] ?? null) ? $section['id'] : null,
|
||||
'v' => self::VERSION,
|
||||
'layout' => $layout,
|
||||
'style' => SectionStyle::fromStored($section['style'] ?? []),
|
||||
'slots' => $slots,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $section
|
||||
* @param array<string, list<string>> $errors
|
||||
* @param array<string, true> $seenSectionIds
|
||||
* @param array<string, true> $seenWidgetIds
|
||||
* @return array{id: string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}
|
||||
*/
|
||||
private function normalizeSection(array $section, int $index, array &$errors, array &$seenSectionIds, array &$seenWidgetIds, int &$widgetCount): array
|
||||
{
|
||||
$prefix = "sections.$index";
|
||||
|
||||
$layout = $section['layout'] ?? SectionLayouts::DEFAULT;
|
||||
if (! SectionLayouts::has($layout)) {
|
||||
$errors["$prefix.layout"] = ['Dieses Abschnittsraster ist nicht freigegeben.'];
|
||||
$layout = SectionLayouts::DEFAULT;
|
||||
}
|
||||
|
||||
$style = $this->normalizeStyle(is_array($section['style'] ?? null) ? $section['style'] : [], $prefix, $errors);
|
||||
|
||||
$units = SectionLayouts::units($layout);
|
||||
$rawSlots = array_values(is_array($section['slots'] ?? null) ? $section['slots'] : []);
|
||||
$filled = count(array_filter($rawSlots, fn ($slot): bool => is_array($slot)));
|
||||
|
||||
if ($filled > count($units)) {
|
||||
$errors["$prefix.slots"] = [sprintf(
|
||||
'Das Raster „%s“ hat %d %s, der Abschnitt enthält aber %d Widgets. Entfernen Sie ein Widget oder wählen Sie ein Raster mit mehr Plätzen.',
|
||||
SectionLayouts::short($layout),
|
||||
count($units),
|
||||
count($units) === 1 ? 'Platz' : 'Plätze',
|
||||
$filled,
|
||||
)];
|
||||
} elseif (count($rawSlots) > count($units)) {
|
||||
// Überzählige Plätze sind leer: Widgets rücken in Reihenfolge nach vorn, leere Plätze entfallen.
|
||||
$rawSlots = array_values(array_filter($rawSlots, fn ($slot): bool => is_array($slot)));
|
||||
}
|
||||
|
||||
$slots = [];
|
||||
foreach ($units as $position => $slotUnits) {
|
||||
$block = $rawSlots[$position] ?? null;
|
||||
|
||||
if (! is_array($block)) {
|
||||
$slots[] = null;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$widgetCount++;
|
||||
|
||||
try {
|
||||
$widget = $this->widgets->normalizeWidget($block, "$prefix.slots.$position", $seenWidgetIds);
|
||||
} catch (ValidationException $exception) {
|
||||
foreach ($exception->errors() as $key => $messages) {
|
||||
$errors[$key] = $messages;
|
||||
}
|
||||
$slots[] = null;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$type = $this->widgets->get($widget['type']);
|
||||
if (! $type->supportsUnits($slotUnits)) {
|
||||
$errors["$prefix.slots.$position.units"] = [sprintf(
|
||||
'„%s“ ist für Plätze mit %s Rastereinheiten vorgesehen; dieser Platz hat %d. Wählen Sie ein passendes Raster oder einen passenden Platz.',
|
||||
$type->label(),
|
||||
$type->unitsLabel(),
|
||||
$slotUnits,
|
||||
)];
|
||||
}
|
||||
|
||||
$slots[] = $widget;
|
||||
}
|
||||
|
||||
$id = $section['id'] ?? null;
|
||||
if (! is_string($id) || preg_match('/^[A-Za-z0-9-]{1,64}$/', $id) !== 1 || isset($seenSectionIds[$id])) {
|
||||
$id = (string) Str::uuid();
|
||||
}
|
||||
$seenSectionIds[$id] = true;
|
||||
|
||||
return [
|
||||
'id' => $id,
|
||||
'v' => self::VERSION,
|
||||
'layout' => $layout,
|
||||
'style' => $style,
|
||||
'slots' => $slots,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $style
|
||||
* @param array<string, list<string>> $errors
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function normalizeStyle(array $style, string $prefix, array &$errors): array
|
||||
{
|
||||
$result = SectionStyle::DEFAULTS;
|
||||
$enums = SectionStyle::enums();
|
||||
|
||||
foreach ($style as $key => $value) {
|
||||
if ($key === 'image' || str_starts_with((string) $key, '_')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset($enums[$key])) {
|
||||
$errors["$prefix.style.$key"] = ['Diese Gestaltungsoption ist nicht freigegeben.'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($value === null || $value === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_string($value) || ! array_key_exists($value, $enums[$key])) {
|
||||
$errors["$prefix.style.$key"] = ['Dieser Gestaltungswert ist nicht freigegeben.'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[$key] = $value;
|
||||
}
|
||||
|
||||
if ($result['background'] === 'image') {
|
||||
$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;
|
||||
} else {
|
||||
$result['image'] = null;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Sections;
|
||||
|
||||
/**
|
||||
* Freigegebene Abschnittsraster. Ein Raster teilt die Abschnittsbreite in höchstens vier logische Einheiten.
|
||||
* Die Kennungen sind gespeichert und ändern sich nie; neue Raster werden ergänzt, nicht umbenannt.
|
||||
*
|
||||
* Die Einheiten werden nicht als eigenes CSS-Grundraster umgesetzt, sondern als Spaltenverhältnis (fr)
|
||||
* des Abschnittsrasters. Leere Slots entfallen auf der veröffentlichten Seite; die übrigen Slots teilen
|
||||
* sich die Breite im Verhältnis ihrer Einheiten.
|
||||
*/
|
||||
final class SectionLayouts
|
||||
{
|
||||
public const DEFAULT = 'u4';
|
||||
|
||||
/** @var array<string, list<int>> */
|
||||
public const UNITS = [
|
||||
'u4' => [4],
|
||||
'u2_2' => [2, 2],
|
||||
'u1_3' => [1, 3],
|
||||
'u3_1' => [3, 1],
|
||||
'u1_2_1' => [1, 2, 1],
|
||||
'u1_1_1_1' => [1, 1, 1, 1],
|
||||
'u1_1_2' => [1, 1, 2],
|
||||
'u2_1_1' => [2, 1, 1],
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const LABELS = [
|
||||
'u4' => 'Volle Breite',
|
||||
'u2_2' => 'Zwei gleich breit',
|
||||
'u1_3' => 'Schmal und breit',
|
||||
'u3_1' => 'Breit und schmal',
|
||||
'u1_2_1' => 'Mitte betont',
|
||||
'u1_1_1_1' => 'Vier gleich breit',
|
||||
'u1_1_2' => 'Zwei schmal, eins breit',
|
||||
'u2_1_1' => 'Eins breit, zwei schmal',
|
||||
];
|
||||
|
||||
public static function has(mixed $key): bool
|
||||
{
|
||||
return is_string($key) && isset(self::UNITS[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
public static function units(string $key): array
|
||||
{
|
||||
return self::UNITS[$key] ?? self::UNITS[self::DEFAULT];
|
||||
}
|
||||
|
||||
public static function slotCount(string $key): int
|
||||
{
|
||||
return count(self::units($key));
|
||||
}
|
||||
|
||||
/** Kurzform wie „1 + 3“. */
|
||||
public static function short(string $key): string
|
||||
{
|
||||
return implode(' + ', self::units($key));
|
||||
}
|
||||
|
||||
public static function label(string $key): string
|
||||
{
|
||||
return (self::LABELS[$key] ?? self::LABELS[self::DEFAULT]).' ('.self::short($key).')';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public static function options(): array
|
||||
{
|
||||
$options = [];
|
||||
foreach (array_keys(self::UNITS) as $key) {
|
||||
$options[$key] = self::label($key);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spaltenvorlagen für die Slots, die tatsächlich etwas darstellen.
|
||||
*
|
||||
* - Desktop (Abschnitt ab 60rem): Verhältnis der Einheiten.
|
||||
* - Tablet (ab 40rem): gleich breite Slots bleiben nebeneinander (zwei oder drei Spalten, vier Slots als 2 × 2);
|
||||
* ungleiche Raster stapeln, damit kein Slot unter etwa 13rem fällt.
|
||||
* - Smartphone: immer eine Spalte. Die Lese- und Fokusreihenfolge bleibt die Reihenfolge der Slots.
|
||||
*
|
||||
* @param list<int> $units
|
||||
* @return array{lg: string, md: string}
|
||||
*/
|
||||
public static function columns(array $units): array
|
||||
{
|
||||
$units = array_values(array_filter($units, fn ($unit): bool => is_int($unit) && $unit > 0));
|
||||
$count = count($units);
|
||||
|
||||
if ($count <= 1) {
|
||||
return ['lg' => 'minmax(0, 1fr)', 'md' => 'minmax(0, 1fr)'];
|
||||
}
|
||||
|
||||
$lg = implode(' ', array_map(fn (int $unit): string => "minmax(0, {$unit}fr)", $units));
|
||||
$equal = count(array_unique($units)) === 1;
|
||||
|
||||
$md = match (true) {
|
||||
! $equal => 'minmax(0, 1fr)',
|
||||
$count === 3 => 'repeat(3, minmax(0, 1fr))',
|
||||
default => 'repeat(2, minmax(0, 1fr))',
|
||||
};
|
||||
|
||||
return ['lg' => $lg, 'md' => $md];
|
||||
}
|
||||
|
||||
/**
|
||||
* Symbolbild des Rasters für die grafische Auswahl im Editor (rein dekorativ).
|
||||
*/
|
||||
public static function schematicSvg(string $key): string
|
||||
{
|
||||
$units = self::units($key);
|
||||
$gap = 2;
|
||||
$width = 56 - $gap * (count($units) - 1);
|
||||
$x = 2;
|
||||
$rects = '';
|
||||
|
||||
foreach ($units as $unit) {
|
||||
$w = (int) round($width * $unit / 4);
|
||||
$rects .= sprintf('<rect x="%d" y="4" width="%d" height="20" rx="1.5"/>', $x, $w);
|
||||
$x += $w + $gap;
|
||||
}
|
||||
|
||||
return '<svg class="luf-layout-schematic" viewBox="0 0 60 28" width="60" height="28" aria-hidden="true" focusable="false">'.$rects.'</svg>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Sections;
|
||||
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetRenderer;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
/**
|
||||
* Einziger Darstellungsweg für Abschnitte: öffentliche Seite und Seitenvorschau rufen denselben Renderer auf.
|
||||
*
|
||||
* Regeln:
|
||||
* - Leere Slots erzeugen keine Leerfläche; die übrigen Slots teilen sich die Breite im Verhältnis ihrer Einheiten.
|
||||
* - Ein Abschnitt ohne darstellbares Widget entfällt samt Hintergrund und Trenner.
|
||||
* - Das erste dargestellte Widget der Seite ist der Seiteneinstieg (Überschrift erster Ordnung).
|
||||
* - Trenner stehen zwischen Abschnitten, nie nach dem letzten.
|
||||
*/
|
||||
class SectionRenderer
|
||||
{
|
||||
public function __construct(private readonly WidgetRenderer $widgets) {}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $sections gelesene Abschnitte (PageSections::read)
|
||||
*/
|
||||
public function renderAll(array $sections, RenderContext $context): HtmlString
|
||||
{
|
||||
$rendered = [];
|
||||
$first = true;
|
||||
|
||||
foreach ($sections as $section) {
|
||||
$cells = [];
|
||||
$units = SectionLayouts::units($section['layout']);
|
||||
|
||||
foreach ($units as $position => $slotUnits) {
|
||||
$widget = $section['slots'][$position] ?? null;
|
||||
|
||||
if (! is_array($widget)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$html = $this->widgets->renderWidget($widget, $context, $first);
|
||||
|
||||
if ($html !== '') {
|
||||
$first = false;
|
||||
$cells[] = ['units' => $slotUnits, 'html' => $html];
|
||||
}
|
||||
}
|
||||
|
||||
if ($cells !== []) {
|
||||
$rendered[] = ['section' => $section, 'cells' => $cells];
|
||||
}
|
||||
}
|
||||
|
||||
$html = '';
|
||||
$last = count($rendered) - 1;
|
||||
|
||||
foreach ($rendered as $index => $item) {
|
||||
$html .= $this->renderSection($item['section'], $item['cells'], $index, $context);
|
||||
|
||||
$divider = $item['section']['style']['divider'] ?? 'none';
|
||||
if ($index < $last && in_array($divider, ['line', 'accent'], true)) {
|
||||
$html .= '<div class="section-divider section-divider-'.$divider.'" aria-hidden="true"><span></span></div>';
|
||||
}
|
||||
}
|
||||
|
||||
return new HtmlString($html);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $section
|
||||
* @param list<array{units: int, html: string}> $cells
|
||||
*/
|
||||
private function renderSection(array $section, array $cells, int $index, RenderContext $context): string
|
||||
{
|
||||
$style = SectionStyle::fromStored($section['style'] ?? []);
|
||||
$columns = SectionLayouts::columns(array_column($cells, 'units'));
|
||||
// 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',
|
||||
'section-bg-'.($hasImage ? 'image' : ($style['background'] === 'image' ? 'default' : $style['background'])),
|
||||
'section-width-'.$style['width'],
|
||||
'section-space-top-'.$style['spacing_top'],
|
||||
'section-space-bottom-'.$style['spacing_bottom'],
|
||||
'section-gap-'.$style['gap'],
|
||||
'section-layout-'.str_replace('_', '-', $section['layout']),
|
||||
];
|
||||
|
||||
if ($hasImage) {
|
||||
$classes[] = 'section-overlay-'.$style['overlay'];
|
||||
}
|
||||
|
||||
// Bedeutungswerte der Fläche (tokens.css): helle Schrift auf dunklen Flächen, gelber Fokus.
|
||||
$scope = match (true) {
|
||||
$hasImage && $style['overlay'] === 'dark' => 'scope-dark',
|
||||
$hasImage => 'scope-light',
|
||||
$style['background'] === 'dark' => 'scope-dark',
|
||||
$style['background'] === 'accent' => 'scope-accent',
|
||||
default => null,
|
||||
};
|
||||
if ($scope !== null) {
|
||||
$classes[] = $scope;
|
||||
}
|
||||
|
||||
$id = is_string($section['id'] ?? null) ? ' id="bereich-'.e($section['id']).'"' : '';
|
||||
$html = '<div class="'.e(implode(' ', $classes)).'"'.$id.'>';
|
||||
|
||||
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($imageUrl).'" alt="" '.$loading.' decoding="async"'
|
||||
.' style="object-position: '.e(SectionStyle::FOCUS_POSITIONS[$style['focus']]).'">';
|
||||
}
|
||||
|
||||
$html .= '<div class="page-section-inner"><div class="section-grid" data-slots="'.count($cells).'"'
|
||||
.' style="--section-cols-lg: '.e($columns['lg']).'; --section-cols-md: '.e($columns['md']).'">';
|
||||
|
||||
foreach ($cells as $cell) {
|
||||
$html .= '<div class="section-slot" data-units="'.$cell['units'].'">'.$cell['html'].'</div>';
|
||||
}
|
||||
|
||||
return $html.'</div></div></div>';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Sections;
|
||||
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
|
||||
/**
|
||||
* Semantische Abschnittsgestaltung. Jeder Wert ist eine Aufzählung, die auf zentrale Design-Tokens
|
||||
* abgebildet wird (resources/css/app.css, Abschnitt „Abschnitte“). Keine freie CSS- oder Farbangabe.
|
||||
*/
|
||||
final class SectionStyle
|
||||
{
|
||||
/** @var array<string, string> */
|
||||
public const BACKGROUNDS = [
|
||||
'default' => 'Standard (ohne eigene Fläche)',
|
||||
'light' => 'Helle Markenfläche',
|
||||
'dark' => 'Dunkle Markenfläche',
|
||||
'accent' => 'Markenakzent',
|
||||
'image' => 'Hintergrundbild',
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const WIDTHS = [
|
||||
'narrow' => 'Lesebereich',
|
||||
'standard' => 'Standard',
|
||||
'wide' => 'Breit',
|
||||
'full' => 'Vollbreite',
|
||||
];
|
||||
|
||||
/**
|
||||
* Gemeinsame Stufen der drei Abstände eines Abschnitts (Hülle Version 2):
|
||||
* - spacing_top: Abstand vor dem Inhalt (oben),
|
||||
* - spacing_bottom: Abstand nach dem Inhalt (unten),
|
||||
* - gap: Abstand zwischen den Plätzen im Abschnittsraster, nebeneinander und gestapelt.
|
||||
* Zwischen zwei Abschnitten addieren sich „unten“ des ersten und „oben“ des zweiten; es gibt keine weitere
|
||||
* versteckte Vorgabe. Liegt eine eigene Fläche (Hintergrund) vor, liegen oben und unten innerhalb dieser Fläche.
|
||||
* Werte: resources/css/tokens.css (--section-space-*, --section-gap-*).
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public const SPACINGS = [
|
||||
'none' => 'Kein Abstand',
|
||||
'compact' => 'Kompakt',
|
||||
'normal' => 'Normal',
|
||||
'large' => 'Großzügig',
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const DIVIDERS = [
|
||||
'none' => 'Kein Trenner',
|
||||
'line' => 'Dezente Linie',
|
||||
'accent' => 'Markenakzent',
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const OVERLAYS = [
|
||||
'light' => 'Helle Überlagerung (dunkle Schrift)',
|
||||
'dark' => 'Dunkle Überlagerung (helle Schrift)',
|
||||
'none' => 'Keine Überlagerung',
|
||||
];
|
||||
|
||||
/** @var array<string, string> */
|
||||
public const FOCUS = [
|
||||
'center' => 'Mitte',
|
||||
'top' => 'Oben',
|
||||
'bottom' => 'Unten',
|
||||
'left' => 'Links',
|
||||
'right' => 'Rechts',
|
||||
'top_left' => 'Oben links',
|
||||
'top_right' => 'Oben rechts',
|
||||
'bottom_left' => 'Unten links',
|
||||
'bottom_right' => 'Unten rechts',
|
||||
];
|
||||
|
||||
/** Fokuspunkt als Objektposition des Bildes; bestimmt den Zuschnitt auf schmalen Bildschirmen. */
|
||||
public const FOCUS_POSITIONS = [
|
||||
'center' => '50% 50%',
|
||||
'top' => '50% 0%',
|
||||
'bottom' => '50% 100%',
|
||||
'left' => '0% 50%',
|
||||
'right' => '100% 50%',
|
||||
'top_left' => '0% 0%',
|
||||
'top_right' => '100% 0%',
|
||||
'bottom_left' => '0% 100%',
|
||||
'bottom_right' => '100% 100%',
|
||||
];
|
||||
|
||||
public const DEFAULTS = [
|
||||
'background' => 'default',
|
||||
'image' => null,
|
||||
'focus' => 'center',
|
||||
'overlay' => 'light',
|
||||
'width' => 'standard',
|
||||
'spacing_top' => 'compact',
|
||||
'spacing_bottom' => 'compact',
|
||||
'gap' => 'normal',
|
||||
'divider' => 'none',
|
||||
];
|
||||
|
||||
/**
|
||||
* Aufzählungsfelder und ihre zulässigen Werte.
|
||||
*
|
||||
* @return array<string, array<string, string>>
|
||||
*/
|
||||
public static function enums(): array
|
||||
{
|
||||
return [
|
||||
'background' => self::BACKGROUNDS,
|
||||
'focus' => self::FOCUS,
|
||||
'overlay' => self::OVERLAYS,
|
||||
'width' => self::WIDTHS,
|
||||
'spacing_top' => self::SPACINGS,
|
||||
'spacing_bottom' => self::SPACINGS,
|
||||
'gap' => self::SPACINGS,
|
||||
'divider' => self::DIVIDERS,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lesepfad: gespeicherte Werte; Unbekanntes fällt auf die Vorgabe zurück, damit alte oder fremde Daten
|
||||
* nie eine Seite brechen.
|
||||
*
|
||||
* @return array{background: string, image: ?string, focus: string, overlay: string, width: string, spacing_top: string, spacing_bottom: string, gap: string, divider: string}
|
||||
*/
|
||||
public static function fromStored(mixed $style): array
|
||||
{
|
||||
$style = is_array($style) ? $style : [];
|
||||
$result = self::DEFAULTS;
|
||||
|
||||
foreach (self::enums() as $key => $options) {
|
||||
$value = $style[$key] ?? null;
|
||||
if (is_string($value) && array_key_exists($value, $options)) {
|
||||
$result[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$result['image'] = $result['background'] === 'image' ? WebsiteImage::normalize($style['image'] ?? null) : null;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kurzbeschreibung für die Abschnittsliste im Editor.
|
||||
*
|
||||
* @param array<string, mixed> $style
|
||||
*/
|
||||
public static function summary(array $style): string
|
||||
{
|
||||
$style = self::fromStored($style);
|
||||
$parts = [self::BACKGROUNDS[$style['background']]];
|
||||
|
||||
if ($style['width'] !== 'standard') {
|
||||
$parts[] = self::WIDTHS[$style['width']];
|
||||
}
|
||||
|
||||
if ($style['spacing_top'] !== self::DEFAULTS['spacing_top'] || $style['spacing_bottom'] !== self::DEFAULTS['spacing_bottom']) {
|
||||
$parts[] = 'Abstand oben '.mb_strtolower(self::SPACINGS[$style['spacing_top']])
|
||||
.', unten '.mb_strtolower(self::SPACINGS[$style['spacing_bottom']]);
|
||||
}
|
||||
|
||||
if ($style['gap'] !== 'normal') {
|
||||
$parts[] = 'Widget-Abstand '.mb_strtolower(self::SPACINGS[$style['gap']]);
|
||||
}
|
||||
|
||||
if ($style['divider'] !== 'none') {
|
||||
$parts[] = 'Trenner: '.self::DIVIDERS[$style['divider']];
|
||||
}
|
||||
|
||||
return implode(' · ', $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ob eine gespeicherte Gestaltung noch die Abstände der Hülle Version 1 trägt
|
||||
* („Abstand oben und unten“ spacing, Abweichung „Abstand oben“ same/small/none).
|
||||
*
|
||||
* @param array<string, mixed> $style
|
||||
*/
|
||||
public static function hasLegacySpacing(array $style): bool
|
||||
{
|
||||
return array_key_exists('spacing', $style)
|
||||
|| in_array($style['spacing_top'] ?? null, ['same', 'small'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Übersetzt die Abstände der Hülle Version 1 in die drei Werte der Version 2, ohne die Darstellung zu ändern.
|
||||
*
|
||||
* Version 1 rechnete so: jeder Abschnitt oben und unten „spacing“ (Vorgabe normal); die Abweichung
|
||||
* „Abstand oben“ ersetzte nur oben (small/none); und eine versteckte Regel setzte oben auf null, wenn ein Abschnitt
|
||||
* ohne eigene Fläche direkt auf einen Abschnitt ohne eigene Fläche folgte (ohne Linien- oder Akzenttrenner dazwischen).
|
||||
* Diese Regel wird hier als „oben: kein Abstand“ ausgeschrieben. „Gering“ hat keine eigene Stufe mehr und wird
|
||||
* „Kompakt“ (dokumentierte Abweichung). Der Widget-Abstand entspricht dem bisherigen festen Rasterabstand („normal“).
|
||||
*
|
||||
* @param list<array<string, mixed>> $sections Abschnitte in Lesereihenfolge (mit style und slots)
|
||||
* @param bool $byVersion true: jede Hülle mit v < 2 gilt als Version 1 (Lesepfad gespeicherter Revisionen);
|
||||
* false: nur Gestaltungen mit alten Schlüsseln (Eingaben ohne Versionsangabe)
|
||||
* @return list<array<string, mixed>> dieselben Abschnitte mit übersetzter Gestaltung
|
||||
*/
|
||||
public static function migrateSpacing(array $sections, bool $byVersion = false): array
|
||||
{
|
||||
$previous = null;
|
||||
|
||||
foreach ($sections as $index => $section) {
|
||||
$style = is_array($section['style'] ?? null) ? $section['style'] : [];
|
||||
$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' && WebsiteImage::normalize($style['image'] ?? null) === null) {
|
||||
$background = 'default';
|
||||
}
|
||||
$divider = in_array($style['divider'] ?? null, ['line', 'accent'], true) ? $style['divider'] : 'none';
|
||||
|
||||
$legacy = $byVersion ? (int) ($section['v'] ?? 1) < 2 : self::hasLegacySpacing($style);
|
||||
|
||||
if ($legacy) {
|
||||
$level = in_array($style['spacing'] ?? null, ['compact', 'normal', 'large'], true) ? $style['spacing'] : 'normal';
|
||||
$override = $style['spacing_top'] ?? 'same';
|
||||
$collapsed = $background === 'default' && $previous !== null && $previous['background'] === 'default' && ! in_array($previous['divider'], ['line', 'accent'], true);
|
||||
|
||||
$style['spacing_top'] = match (true) {
|
||||
$override === 'none' => 'none',
|
||||
$override === 'small' => 'compact',
|
||||
$collapsed => 'none',
|
||||
default => $level,
|
||||
};
|
||||
$style['spacing_bottom'] = $level;
|
||||
$style['gap'] = 'normal';
|
||||
|
||||
// Trenner „Zusätzlicher Abstand“ (Version 1) fügte unten noch einmal den Abschnittsabstand an.
|
||||
if (($style['divider'] ?? null) === 'space') {
|
||||
$style['spacing_bottom'] = ['compact' => 'normal', 'normal' => 'large', 'large' => 'large'][$level];
|
||||
$style['divider'] = 'none';
|
||||
}
|
||||
unset($style['spacing']);
|
||||
$sections[$index]['style'] = $style;
|
||||
}
|
||||
|
||||
if ($rendered) {
|
||||
$previous = ['background' => $background, 'divider' => $divider];
|
||||
}
|
||||
}
|
||||
|
||||
return $sections;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Baut Kopf- und Fußnavigation aus dem CMS-Navigationsmodell. Keine fest codierten Menüpunkte.
|
||||
*
|
||||
* Die Ausgabe hängt nur von der Navigation und dem angefragten Pfad ab, nie vom Anmeldestatus,
|
||||
* damit öffentliche Seiten für alle Besucher gleich ausgeliefert werden können (ADR-32).
|
||||
*/
|
||||
final class SiteNavigation
|
||||
{
|
||||
/**
|
||||
* @param Collection<int, NavigationItem> $items sichtbare Einträge, sortiert
|
||||
*/
|
||||
public function __construct(private readonly Collection $items, private readonly string $currentPath) {}
|
||||
|
||||
/**
|
||||
* @param Collection<int, NavigationItem> $items
|
||||
*/
|
||||
public static function forPath(Collection $items, string $path): self
|
||||
{
|
||||
return new self($items, '/'.trim($path, '/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Hauptnavigation mit einer Ebene Untermenü. Untereinträge eines ausgeblendeten Eintrags sind ebenfalls verborgen.
|
||||
*
|
||||
* @return list<array{id: int, label: string, href: ?string, current: bool, activeTrail: bool, children: list<array{id: int, label: string, href: string, current: bool}>}>
|
||||
*/
|
||||
public function header(): array
|
||||
{
|
||||
$topLevel = $this->items->where('placement', 'header')->whereNull('parent_id');
|
||||
$entries = [];
|
||||
|
||||
foreach ($topLevel as $item) {
|
||||
$children = [];
|
||||
|
||||
foreach ($this->items->where('parent_id', $item->id) as $child) {
|
||||
$href = $child->href();
|
||||
if ($href !== null) {
|
||||
$children[] = [
|
||||
'id' => $child->id,
|
||||
'label' => $child->label,
|
||||
'href' => $href,
|
||||
'current' => $this->isCurrent($child),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$href = $item->href();
|
||||
if ($href === null && $children === []) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$current = $href !== null && $this->isCurrent($item);
|
||||
|
||||
$entries[] = [
|
||||
'id' => $item->id,
|
||||
'label' => $item->label,
|
||||
'href' => $href,
|
||||
'current' => $current,
|
||||
'activeTrail' => $current || in_array(true, array_column($children, 'current'), true),
|
||||
'children' => $children,
|
||||
];
|
||||
}
|
||||
|
||||
return $entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spalten des Fußbereichs in fester Reihenfolge; Gruppen ohne Einträge entfallen.
|
||||
*
|
||||
* @return list<array{key: string, heading: string, links: list<array{label: string, href: string, current: bool}>}>
|
||||
*/
|
||||
public function footerGroups(): array
|
||||
{
|
||||
$groups = [];
|
||||
|
||||
foreach (NavigationItem::FOOTER_GROUPS as $placement => $heading) {
|
||||
$links = [];
|
||||
|
||||
foreach ($this->items->where('placement', $placement) as $item) {
|
||||
$href = $item->href();
|
||||
if ($href !== null) {
|
||||
$links[] = ['label' => $item->label, 'href' => $href, 'current' => $this->isCurrent($item)];
|
||||
}
|
||||
}
|
||||
|
||||
if ($links !== []) {
|
||||
$groups[] = ['key' => $placement, 'heading' => $heading, 'links' => $links];
|
||||
}
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
private function isCurrent(NavigationItem $item): bool
|
||||
{
|
||||
return $item->targetPath() === $this->currentPath;
|
||||
}
|
||||
}
|
||||
@@ -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,37 +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
|
||||
{
|
||||
/**
|
||||
* @return list<Field>
|
||||
* @param bool $live Änderungen sofort an die Vorschau im Bearbeitungsdialog geben.
|
||||
* @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'): array
|
||||
public static function fields(string $label = 'Bild', bool $live = false, string $key = 'image', ?string $altField = null): array
|
||||
{
|
||||
return [
|
||||
Select::make('image')
|
||||
->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')
|
||||
->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))),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -45,29 +88,49 @@ public static function fields(string $label = 'Bild'): 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>');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Support;
|
||||
|
||||
use App\Domain\Cms\Sections\SectionStyle;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use Filament\Forms\Components\Slider;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
|
||||
/**
|
||||
* Gemeinsame Bausteine der Premium-Widgets (Einstieg, Bild und Text; Brand-UI-Kit v1.6): Label, Überschriftenebene,
|
||||
* Bildfokus in Prozent und zwei Schaltflächen. Alle Werte bleiben in data bzw. settings der bestehenden Hülle.
|
||||
*
|
||||
* Abweichungen vom Kit (bewusst, dokumentiert in cms-widget-registry.md):
|
||||
* - Bildfokus als data.focus_x / data.focus_y (ganze Zahlen 0–100), weil settings nur Aufzählungswerte trägt.
|
||||
* - Überschriftenebene „Automatisch“ statt freier H1: Die Seite hat genau eine H1 (erstes Widget der Seite).
|
||||
* - Linkziele über SafeUrl des Repositorys (Seitenpfad, #Anker, http und https), nicht nur https.
|
||||
*/
|
||||
final class PremiumFields
|
||||
{
|
||||
public const HEADING_LEVELS = [
|
||||
'auto' => 'Automatisch (Seiteneinstieg H1, sonst H2)',
|
||||
'h2' => 'H2',
|
||||
'h3' => 'H3',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function rules(): array
|
||||
{
|
||||
return [
|
||||
'eyebrow' => ['nullable', 'string', 'max:80'],
|
||||
'cta_label' => ['nullable', 'string', 'max:80', 'required_with:data.cta_url'],
|
||||
'cta_url' => ['nullable', 'string', 'max:500', 'required_with:data.cta_label'],
|
||||
'cta2_label' => ['nullable', 'string', 'max:80', 'required_with:data.cta2_url'],
|
||||
'cta2_url' => ['nullable', 'string', 'max:500', 'required_with:data.cta2_label'],
|
||||
'alt' => ['nullable', 'string', 'max:300'],
|
||||
'focus_x' => ['nullable', 'numeric', 'between:0,100'],
|
||||
'focus_y' => ['nullable', 'numeric', 'between:0,100'],
|
||||
];
|
||||
}
|
||||
|
||||
public static function eyebrowField(): TextInput
|
||||
{
|
||||
return TextInput::make('eyebrow')
|
||||
->label('Label über der Überschrift (optional)')
|
||||
->maxLength(80)
|
||||
->live(onBlur: true)
|
||||
->helperText('Kurzer Hinweis, zum Beispiel ein Themenbereich. Kein Pflichtfeld.');
|
||||
}
|
||||
|
||||
public static function ctaFields(): Grid
|
||||
{
|
||||
$url = fn (string $name, string $label, string $pair) => TextInput::make($name)
|
||||
->label($label)
|
||||
->maxLength(500)
|
||||
->rule(SafeUrl::rule())
|
||||
->requiredWith($pair)
|
||||
->live(onBlur: true)
|
||||
->placeholder('/programme');
|
||||
|
||||
return Grid::make(['default' => 1, 'md' => 2])->schema([
|
||||
TextInput::make('cta_label')->label('Hauptschaltfläche: Beschriftung')->maxLength(80)->live(onBlur: true),
|
||||
$url('cta_url', 'Hauptschaltfläche: Linkziel', 'cta_label'),
|
||||
TextInput::make('cta2_label')->label('Zweite Schaltfläche: Beschriftung')->maxLength(80)->live(onBlur: true),
|
||||
$url('cta2_url', 'Zweite Schaltfläche: Linkziel', 'cta2_label'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<Slider>
|
||||
*/
|
||||
public static function focusFields(int $defaultX = 50, int $defaultY = 50): array
|
||||
{
|
||||
// Ohne gespeicherten Wert zeigt der Regler die Vorgabe der Widget-Art, die auch die Darstellung verwendet.
|
||||
$slider = fn (string $name, string $label, int $default) => Slider::make($name)
|
||||
->label($label)
|
||||
->range(0, 100)
|
||||
->step(1)
|
||||
->required(false)
|
||||
->tooltips()
|
||||
->default($default)
|
||||
->afterStateHydrated(function (Slider $component, mixed $state) use ($default): void {
|
||||
if (! is_numeric($state)) {
|
||||
$component->state($default);
|
||||
}
|
||||
})
|
||||
->live();
|
||||
|
||||
return [
|
||||
$slider('focus_x', 'Bildausschnitt waagerecht (0 = links, 100 = rechts)', $defaultX),
|
||||
$slider('focus_y', 'Bildausschnitt senkrecht (0 = oben, 100 = unten)', $defaultY),
|
||||
];
|
||||
}
|
||||
|
||||
public static function altField(): TextInput
|
||||
{
|
||||
return TextInput::make('alt')
|
||||
->label('Alternativtext (optional)')
|
||||
->maxLength(300)
|
||||
->live(onBlur: true)
|
||||
->helperText('Leer lassen, dann gilt der Alternativtext des Mediums aus dem Medienmanager. Nur ausfüllen, wenn das Bild hier etwas anderes aussagen soll.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Bereinigt Label, Schaltflächen, Alternativtext und Fokus; meldet unsichere Linkziele.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function clean(array $data, WidgetErrors $errors, bool $hasImage): array
|
||||
{
|
||||
foreach (['eyebrow', 'cta_label', 'cta_url', 'cta2_label', 'cta2_url', 'alt'] as $key) {
|
||||
$data[$key] = filled($data[$key] ?? null) ? trim((string) $data[$key]) : null;
|
||||
}
|
||||
|
||||
foreach (['cta_url', 'cta2_url'] as $key) {
|
||||
if ($data[$key] !== null && ! SafeUrl::isSafe($data[$key])) {
|
||||
$errors->add("data.$key", SafeUrl::message());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (['focus_x', 'focus_y'] as $key) {
|
||||
$value = $data[$key] ?? null;
|
||||
$data[$key] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schaltflächen mit sicherem Linkziel in Anzeigereihenfolge.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @return list<array{label: string, url: string}>
|
||||
*/
|
||||
public static function actions(array $data): array
|
||||
{
|
||||
$actions = [];
|
||||
|
||||
foreach ([['cta_label', 'cta_url'], ['cta2_label', 'cta2_url']] as [$label, $url]) {
|
||||
if (filled($data[$label] ?? null) && SafeUrl::isSafe($data[$url] ?? null)) {
|
||||
$actions[] = ['label' => (string) $data[$label], 'url' => (string) $data[$url]];
|
||||
}
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bildfokus in Prozent; ohne Angabe die Vorgabe der Widget-Art.
|
||||
*
|
||||
* @param array<string, mixed> $data
|
||||
* @return array{x: int, y: int}
|
||||
*/
|
||||
public static function focus(array $data, int $defaultX = 50, int $defaultY = 50): array
|
||||
{
|
||||
$clamp = fn (mixed $value, int $default): int => is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : $default;
|
||||
|
||||
return ['x' => $clamp($data['focus_x'] ?? null, $defaultX), 'y' => $clamp($data['focus_y'] ?? null, $defaultY)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Übersetzt den früheren Fokuspunkt (Aufzählung wie beim Abschnittshintergrund) in Prozentwerte.
|
||||
*
|
||||
* @return array{focus_x: int|null, focus_y: int|null}
|
||||
*/
|
||||
public static function focusFromEnum(mixed $focus): array
|
||||
{
|
||||
if (! is_string($focus) || ! isset(SectionStyle::FOCUS_POSITIONS[$focus])) {
|
||||
return ['focus_x' => null, 'focus_y' => null];
|
||||
}
|
||||
|
||||
[$x, $y] = array_map(fn (string $part): int => (int) rtrim($part, '%'), explode(' ', SectionStyle::FOCUS_POSITIONS[$focus]));
|
||||
|
||||
return ['focus_x' => $x, 'focus_y' => $y];
|
||||
}
|
||||
|
||||
/**
|
||||
* Überschriftenebene: „auto“ ergibt H1 für das erste Widget der Seite, sonst H2. Eine weitere H1 gibt es nicht.
|
||||
*
|
||||
* @param array<string, mixed> $settings
|
||||
*/
|
||||
public static function headingTag(array $settings, bool $first): string
|
||||
{
|
||||
$level = $settings['heading_level'] ?? 'auto';
|
||||
|
||||
return match (true) {
|
||||
$first => 'h1',
|
||||
$level === 'h3' => 'h3',
|
||||
default => 'h2',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,36 @@ public function description(): string
|
||||
return 'Hervorgehobene Fläche mit Überschrift, Text und einer Schaltfläche.';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Unter 20 rem Slotbreite steht die Schaltfläche in voller Breite; Überschrift, Text und Beschriftung brechen um.';
|
||||
}
|
||||
|
||||
public function heights(): array
|
||||
{
|
||||
return [
|
||||
'auto' => 'Automatisch (nach Inhalt)',
|
||||
'fill' => 'Abschnittshöhe füllen (gleich hoch wie Nachbarplätze)',
|
||||
];
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'fluid' => 'Text und Schaltfläche untereinander, Schaltfläche volle Breite unter 20rem',
|
||||
];
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-megaphone';
|
||||
|
||||
@@ -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;
|
||||
@@ -32,7 +33,30 @@ public function label(): string
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Mehrere Karten mit Titel, Text, Linkziel und optionalem Bild. Als Raster oder kompakte Liste.';
|
||||
return 'Mehrere Karten mit Titel, Text, Linkziel und optionalem Bild. Als Raster, kompakte Liste oder mit hervorgehobener erster Karte.';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Karten stehen untereinander, sobald keine zwei 15 rem breiten Karten nebeneinander passen; die hervorgehobene Karte stapelt Bild und Text.';
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'narrow' => 'eine Karte je Zeile',
|
||||
'wide' => 'so viele Karten nebeneinander, wie bei mindestens 15rem Kartenbreite passen; hervorgehobene Karte ab 44rem mit Bild neben dem Text',
|
||||
];
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
@@ -50,6 +74,7 @@ public function variants(): array
|
||||
return [
|
||||
'standard' => 'Raster',
|
||||
'compact' => 'Kompakte Liste',
|
||||
'featured' => 'Erste Karte hervorgehoben',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -60,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')
|
||||
@@ -82,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)
|
||||
@@ -115,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)) {
|
||||
@@ -126,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
|
||||
|
||||
@@ -37,6 +37,29 @@ public function description(): string
|
||||
return 'Ausgewählte Programme und Module; Titel und Beschreibung kommen automatisch aus den Fachdaten.';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Karten stehen untereinander, die Markentafel über dem Text; lange Titel brechen um.';
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'narrow' => 'eine Karte je Zeile, Symbolfläche über dem Text',
|
||||
'wide' => 'mehrere Karten nebeneinander ab 16rem Kartenbreite',
|
||||
];
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-rectangle-stack';
|
||||
|
||||
@@ -24,6 +24,28 @@ public function description(): string
|
||||
return 'Häufige Fragen mit Antworten.';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [2, 3, 4];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Fragen und Antworten untereinander; Antworten höchstens in Lesebreite.';
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'fluid' => 'Fragen untereinander; Antwortlänge auf Lesebreite begrenzt',
|
||||
];
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-question-mark-circle';
|
||||
|
||||
@@ -23,6 +23,28 @@ public function description(): string
|
||||
return 'Abschnittsüberschrift mit kurzem Einleitungstext.';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Überschriftengröße folgt der Platzbreite; lange Wörter werden getrennt.';
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'fluid' => 'Überschriftgröße folgt der Slotbreite',
|
||||
];
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-h1';
|
||||
|
||||
@@ -4,15 +4,23 @@
|
||||
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
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\SafeUrl;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Group;
|
||||
|
||||
/**
|
||||
* Premium-Einstieg nach Brand-UI-Kit v1.6 (12_premium_widgets_adaptiv_v1.6, Komponente lf-hero).
|
||||
*
|
||||
* Version 2: Varianten photo_split und editorial_solid, Höhen compact/normal/large (Mindesthöhen ab 860 px
|
||||
* Containerbreite), Label, Überschriftenebene, Bildfokus in Prozent, Akzent, zwei Schaltflächen.
|
||||
* Die data-Schlüssel der Version 1 (heading, text, cta_*, alt) bleiben unverändert, damit ältere Revisionen und ein
|
||||
* Code-Rollback darstellbar bleiben.
|
||||
*/
|
||||
class HeroWidget extends WidgetType
|
||||
{
|
||||
public function key(): string
|
||||
@@ -27,7 +35,44 @@ public function label(): string
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Großer Seiteneinstieg mit Überschrift, Beschreibung, optionalem Bild und optionaler Schaltfläche.';
|
||||
return 'Markenprägender Seiteneinstieg: großes Foto mit Textfläche oder dunkle Markenfläche, Überschrift, Beschreibung und bis zu zwei Schaltflächen.';
|
||||
}
|
||||
|
||||
public function version(): int
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [3, 4];
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'wide' => 'ab 860 px Containerbreite: Foto über die ganze Fläche, Text links auf heller Fläche; Mindesthöhe nach Höheneinstellung',
|
||||
'safety' => 'unter 860 px nur technischer Sicherheitsumbruch: Foto 16:9 über dem Text, Schaltflächen ab 440 px untereinander',
|
||||
];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Für breite Plätze (3 oder 4 Einheiten). Unter 860 px Containerbreite steht das Foto über dem Text; die Höhe richtet sich dann nach dem Inhalt.';
|
||||
}
|
||||
|
||||
public function heights(): array
|
||||
{
|
||||
return [
|
||||
'compact' => 'Kompakt (mind. 400 px)',
|
||||
'normal' => 'Normal (mind. 512 px)',
|
||||
'large' => 'Groß (mind. 640 px)',
|
||||
];
|
||||
}
|
||||
|
||||
public function defaultHeight(): ?string
|
||||
{
|
||||
return 'normal';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
@@ -37,26 +82,72 @@ public function icon(): string
|
||||
|
||||
public function schematic(): array
|
||||
{
|
||||
return [[2, 3, 56, 30, 'line'], [6, 8, 26, 6, 'ink'], [6, 17, 24, 3, 'line'], [6, 24, 12, 5, 'accent'], [36, 7, 18, 22, 'image']];
|
||||
return [[2, 3, 56, 30, 'image'], [6, 8, 24, 6, 'ink'], [6, 16, 10, 2, 'accent'], [6, 21, 22, 3, 'line'], [6, 27, 12, 4, 'accent']];
|
||||
}
|
||||
|
||||
public function variants(): array
|
||||
{
|
||||
return [
|
||||
'standard' => 'Standard (Bild neben dem Text)',
|
||||
'highlight' => 'Hervorgehoben (Markenfläche)',
|
||||
'photo_split' => 'Foto mit Textfläche',
|
||||
'editorial_solid' => 'Markenfläche (ohne Foto)',
|
||||
];
|
||||
}
|
||||
|
||||
public function optionIcons(): array
|
||||
{
|
||||
return [
|
||||
'variant' => ['photo_split' => 'heroicon-o-photo', 'editorial_solid' => 'heroicon-o-swatch'],
|
||||
'height' => ['compact' => 'heroicon-o-bars-2', 'normal' => 'heroicon-o-bars-3', 'large' => 'heroicon-o-bars-4'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
'heading_level' => PremiumFields::HEADING_LEVELS,
|
||||
'accent' => ['underline' => 'Gelbe Unterstreichung', 'rays' => 'Unterstreichung und Signalstrahlen', 'none' => 'Ohne Akzent'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'heading_level' => ['Überschriftenebene', 'Der erste Einstieg einer Seite ist immer die Hauptüberschrift (H1).'],
|
||||
'accent' => ['Markenakzent', 'Freigegebene Akzente aus dem Brand-UI-Kit. Vorgabe: gelbe Unterstreichung.'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Version 1 (bis Designiteration 1) → 2: Varianten abbilden, früheren Fokuspunkt in Prozent umrechnen,
|
||||
* nicht mehr vorhandene Einstellungen (focus, text_side) entfernen. Inhalte bleiben unverändert.
|
||||
*/
|
||||
public function upgrade(array $widget, int $from): array
|
||||
{
|
||||
if ($from !== 1) {
|
||||
return parent::upgrade($widget, $from);
|
||||
}
|
||||
|
||||
$widget['variant'] = in_array($widget['variant'] ?? null, ['highlight', 'editorial'], true) ? 'editorial_solid' : 'photo_split';
|
||||
$settings = is_array($widget['settings'] ?? null) ? $widget['settings'] : [];
|
||||
$data = is_array($widget['data'] ?? null) ? $widget['data'] : [];
|
||||
|
||||
if (! isset($data['focus_x'], $data['focus_y'])) {
|
||||
$data = PremiumFields::focusFromEnum($settings['focus'] ?? null) + $data;
|
||||
}
|
||||
|
||||
unset($settings['focus'], $settings['text_side']);
|
||||
$widget['settings'] = $settings;
|
||||
$widget['data'] = $data;
|
||||
|
||||
return $widget;
|
||||
}
|
||||
|
||||
public function dataRules(): array
|
||||
{
|
||||
return [
|
||||
'heading' => ['required', 'string', 'max:200'],
|
||||
'text' => ['nullable', 'string', 'max:600'],
|
||||
'cta_label' => ['nullable', 'string', 'max:80', 'required_with:data.cta_url'],
|
||||
'cta_url' => ['nullable', 'string', 'max:500', 'required_with:data.cta_label'],
|
||||
'alt' => ['nullable', 'string', 'max:300'],
|
||||
];
|
||||
] + PremiumFields::rules();
|
||||
}
|
||||
|
||||
public function refRules(): array
|
||||
@@ -67,66 +158,62 @@ public function refRules(): array
|
||||
public function dataFields(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('heading')->label('Überschrift')->required()->maxLength(200),
|
||||
Textarea::make('text')->label('Beschreibung')->rows(3)->maxLength(600),
|
||||
Grid::make(2)->schema([
|
||||
TextInput::make('cta_label')->label('Schaltfläche: Beschriftung (optional)')->maxLength(80),
|
||||
TextInput::make('cta_url')
|
||||
->label('Schaltfläche: Linkziel')
|
||||
->maxLength(500)
|
||||
->rule(SafeUrl::rule())
|
||||
->requiredWith('cta_label'),
|
||||
]),
|
||||
TextInput::make('alt')
|
||||
->label('Alternativtext des Bildes')
|
||||
->maxLength(300)
|
||||
->helperText('Pflicht, sobald ein Bild gewählt ist.'),
|
||||
PremiumFields::eyebrowField(),
|
||||
TextInput::make('heading')->label('Überschrift')->required()->maxLength(200)->live(onBlur: true),
|
||||
Textarea::make('text')->label('Beschreibung')->rows(3)->maxLength(600)->live(onBlur: true),
|
||||
PremiumFields::ctaFields(),
|
||||
PremiumFields::altField(),
|
||||
...PremiumFields::focusFields(68, 50),
|
||||
];
|
||||
}
|
||||
|
||||
public function refFields(): array
|
||||
{
|
||||
return ImageRefFields::fields();
|
||||
return ImageRefFields::fields(live: true);
|
||||
}
|
||||
|
||||
public function editorSchema(): array
|
||||
{
|
||||
[$heading, $text, $cta, $alt] = $this->dataFields();
|
||||
[$eyebrow, $heading, $text, $ctas] = $this->dataFields();
|
||||
|
||||
return [Group::make([$eyebrow, $heading, $text, $ctas])->statePath('data')];
|
||||
}
|
||||
|
||||
public function mediaSchema(): array
|
||||
{
|
||||
[, , , , $alt, $focusX, $focusY] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make([$heading, $text, $cta])->statePath('data'),
|
||||
Group::make($this->refFields())->statePath('refs'),
|
||||
Group::make([$alt])->statePath('data'),
|
||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
||||
];
|
||||
}
|
||||
|
||||
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
{
|
||||
$refs = ImageRefFields::clean($refs, $errors);
|
||||
|
||||
foreach (['text', 'cta_label', 'cta_url', 'alt'] as $key) {
|
||||
$data[$key] = filled($data[$key] ?? null) ? trim($data[$key]) : null;
|
||||
}
|
||||
|
||||
if ($data['cta_url'] !== null && ! SafeUrl::isSafe($data['cta_url'])) {
|
||||
$errors->add('data.cta_url', SafeUrl::message());
|
||||
}
|
||||
|
||||
if ($refs['image'] !== null && $data['alt'] === null) {
|
||||
$errors->add('data.alt', 'Bitte einen Alternativtext für das Bild angeben.');
|
||||
}
|
||||
$data['heading'] = trim((string) ($data['heading'] ?? ''));
|
||||
$data['text'] = filled($data['text'] ?? null) ? trim((string) $data['text']) : null;
|
||||
$data = PremiumFields::clean($data, $errors, $refs['image'] !== null);
|
||||
|
||||
return [$data, $refs];
|
||||
}
|
||||
|
||||
public function resolve(array $widget, RenderContext $context): array
|
||||
{
|
||||
$data = $widget['data'];
|
||||
$hasAction = filled($data['cta_label'] ?? null) && SafeUrl::isSafe($data['cta_url'] ?? null);
|
||||
$actions = PremiumFields::actions($widget['data']);
|
||||
|
||||
$images = app(WebsiteImage::class);
|
||||
$image = $widget['refs']['image'] ?? null;
|
||||
|
||||
return [
|
||||
'imageUrl' => PublicMedia::imageUrl($widget['refs']),
|
||||
'action' => $hasAction ? ['label' => $data['cta_label'], 'url' => $data['cta_url']] : null,
|
||||
'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),
|
||||
'accent' => in_array($widget['settings']['accent'] ?? null, ['underline', 'rays', 'none'], true) ? $widget['settings']['accent'] : 'underline',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
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\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;
|
||||
@@ -13,10 +15,13 @@
|
||||
use Filament\Schemas\Components\Group;
|
||||
|
||||
/**
|
||||
* Bild und Text.
|
||||
* Bild und Text, Premium-Fassung nach Brand-UI-Kit v1.6 (Komponente lf-bild-text).
|
||||
*
|
||||
* Version 1 (Bestand): data {image, alt, body} mit Klartext.
|
||||
* Version 2: data {title, body (formatierter Text), alt}, refs {image}, Varianten Bild links/rechts.
|
||||
* Version 3: zusätzlich Label, zwei Schaltflächen, Bildfokus in Prozent; Einstellungen Oberfläche, Höhe und
|
||||
* Überschriftenebene. Die Bildseite bleibt die Variante (keine doppelte Einstellung). Die Einstellung
|
||||
* format der Designiteration 1 entfällt; die Bildproportion folgt jetzt der Höhe.
|
||||
*/
|
||||
class ImageTextWidget extends WidgetType
|
||||
{
|
||||
@@ -32,12 +37,50 @@ public function label(): string
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Bild neben formatiertem Text; Bild links oder rechts, auf dem Smartphone untereinander.';
|
||||
return 'Redaktionelle Bild-Text-Komposition mit Label, formatiertem Text und bis zu zwei Schaltflächen; passt sich der Platzbreite an.';
|
||||
}
|
||||
|
||||
public function version(): int
|
||||
{
|
||||
return 2;
|
||||
return 3;
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'stacked' => 'unter 540 px Containerbreite: Bild über dem Text, Schaltflächen untereinander in voller Breite',
|
||||
'band' => '540 bis 899 px: flacher Bildstreifen über dem vollständigen Text (typisch zwei Einheiten)',
|
||||
'wide' => 'ab 900 px: Bild und Text nebeneinander, Bild links oder rechts nach Variante',
|
||||
];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Unter 900 px Containerbreite steht das Bild über dem Text, unabhängig von „Bild links/rechts“; die gespeicherte Seite bleibt erhalten. Text und Schaltflächen werden nie gekürzt.';
|
||||
}
|
||||
|
||||
public function heights(): array
|
||||
{
|
||||
return [
|
||||
'compact' => 'Kompakt (flacheres Bild, engere Abstände)',
|
||||
'normal' => 'Normal',
|
||||
'spacious' => 'Großzügig (höheres Bild, mehr Abstand)',
|
||||
];
|
||||
}
|
||||
|
||||
public function defaultHeight(): ?string
|
||||
{
|
||||
return 'normal';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
@@ -47,7 +90,7 @@ public function icon(): string
|
||||
|
||||
public function schematic(): array
|
||||
{
|
||||
return [[4, 6, 22, 24, 'image'], [30, 7, 24, 4, 'ink'], [30, 15, 26, 3, 'line'], [30, 21, 22, 3, 'line']];
|
||||
return [[4, 6, 22, 24, 'image'], [30, 7, 10, 2, 'accent'], [30, 11, 24, 4, 'ink'], [30, 18, 26, 3, 'line'], [30, 24, 14, 4, 'accent']];
|
||||
}
|
||||
|
||||
public function variants(): array
|
||||
@@ -58,24 +101,64 @@ public function variants(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function optionIcons(): array
|
||||
{
|
||||
return [
|
||||
'variant' => ['image_left' => 'heroicon-o-arrow-left', 'image_right' => 'heroicon-o-arrow-right'],
|
||||
'height' => ['compact' => 'heroicon-o-bars-2', 'normal' => 'heroicon-o-bars-3', 'spacious' => 'heroicon-o-bars-4'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
'surface' => ['cream' => 'Creme (Markenfläche)', 'clear' => 'Ohne eigene Fläche', 'navy' => 'Navy (dunkel)'],
|
||||
'heading_level' => PremiumFields::HEADING_LEVELS,
|
||||
];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'surface' => ['Hintergrund des Widgets', 'Unabhängig vom Abschnittshintergrund. „Ohne eigene Fläche“ übernimmt den Abschnitt.'],
|
||||
'heading_level' => ['Überschriftenebene', 'Steht das Widget als erstes auf der Seite, ist die Überschrift immer H1.'],
|
||||
];
|
||||
}
|
||||
|
||||
public function upgrade(array $widget, int $from): array
|
||||
{
|
||||
if ($from !== 1) {
|
||||
return parent::upgrade($widget, $from);
|
||||
if ($from === 1) {
|
||||
$data = $widget['data'];
|
||||
|
||||
$widget['data'] = [
|
||||
'title' => null,
|
||||
'body' => RichText::fromPlainText(is_string($data['body'] ?? null) ? $data['body'] : ''),
|
||||
'alt' => $data['alt'] ?? null,
|
||||
];
|
||||
$widget['refs'] = [
|
||||
'image' => PublicMedia::fromUploadState($data['image'] ?? null),
|
||||
];
|
||||
|
||||
return $widget;
|
||||
}
|
||||
|
||||
$data = $widget['data'];
|
||||
if ($from === 2) {
|
||||
// Designiteration 1 → Premium: Fokus in Prozent, Bildformat entfällt (Proportion folgt der Höhe).
|
||||
$settings = is_array($widget['settings'] ?? null) ? $widget['settings'] : [];
|
||||
$data = is_array($widget['data'] ?? null) ? $widget['data'] : [];
|
||||
|
||||
$widget['data'] = [
|
||||
'title' => null,
|
||||
'body' => RichText::fromPlainText(is_string($data['body'] ?? null) ? $data['body'] : ''),
|
||||
'alt' => $data['alt'] ?? null,
|
||||
];
|
||||
$widget['refs'] = [
|
||||
'image' => PublicMedia::fromUploadState($data['image'] ?? null),
|
||||
];
|
||||
if (! isset($data['focus_x'], $data['focus_y'])) {
|
||||
$data = PremiumFields::focusFromEnum($settings['focus'] ?? null) + $data;
|
||||
}
|
||||
|
||||
return $widget;
|
||||
unset($settings['focus'], $settings['format']);
|
||||
$widget['settings'] = $settings;
|
||||
$widget['data'] = $data;
|
||||
|
||||
return $widget;
|
||||
}
|
||||
|
||||
return parent::upgrade($widget, $from);
|
||||
}
|
||||
|
||||
public function dataRules(): array
|
||||
@@ -83,8 +166,7 @@ public function dataRules(): array
|
||||
return [
|
||||
'title' => ['nullable', 'string', 'max:160'],
|
||||
'body' => ['required', 'string', 'max:40000'],
|
||||
'alt' => ['nullable', 'string', 'max:300'],
|
||||
];
|
||||
] + PremiumFields::rules();
|
||||
}
|
||||
|
||||
public function refRules(): array
|
||||
@@ -95,31 +177,38 @@ public function refRules(): array
|
||||
public function dataFields(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('title')->label('Titel (optional)')->maxLength(160),
|
||||
PremiumFields::eyebrowField(),
|
||||
TextInput::make('title')->label('Überschrift')->maxLength(160)->live(onBlur: true),
|
||||
RichEditor::make('body')
|
||||
->label('Text')
|
||||
->required()
|
||||
->live(onBlur: true)
|
||||
->toolbarButtons(RichText::TOOLBAR),
|
||||
TextInput::make('alt')
|
||||
->label('Alternativtext des Bildes')
|
||||
->maxLength(300)
|
||||
->helperText('Beschreibt, was auf dem Bild zu sehen ist. Pflicht, sobald ein Bild gewählt ist.'),
|
||||
PremiumFields::ctaFields(),
|
||||
PremiumFields::altField(),
|
||||
...PremiumFields::focusFields(64, 43),
|
||||
];
|
||||
}
|
||||
|
||||
public function refFields(): array
|
||||
{
|
||||
return ImageRefFields::fields();
|
||||
return ImageRefFields::fields(live: true);
|
||||
}
|
||||
|
||||
public function editorSchema(): array
|
||||
{
|
||||
[$title, $body, $alt] = $this->dataFields();
|
||||
[$eyebrow, $title, $body, $ctas] = $this->dataFields();
|
||||
|
||||
return [Group::make([$eyebrow, $title, $body, $ctas])->statePath('data')];
|
||||
}
|
||||
|
||||
public function mediaSchema(): array
|
||||
{
|
||||
[, , , , $alt, $focusX, $focusY] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make([$title, $body])->statePath('data'),
|
||||
Group::make($this->refFields())->statePath('refs'),
|
||||
Group::make([$alt])->statePath('data'),
|
||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -127,25 +216,31 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
{
|
||||
$refs = ImageRefFields::clean($refs, $errors);
|
||||
$data['body'] = RichText::sanitize($data['body'] ?? '');
|
||||
$data['title'] = filled($data['title'] ?? null) ? trim($data['title']) : null;
|
||||
$data['alt'] = filled($data['alt'] ?? null) ? trim($data['alt']) : null;
|
||||
$data['title'] = filled($data['title'] ?? null) ? trim((string) $data['title']) : null;
|
||||
$data = PremiumFields::clean($data, $errors, $refs['image'] !== null);
|
||||
|
||||
if (RichText::isBlank($data['body'])) {
|
||||
$errors->add('data.body', 'Bitte einen Text eingeben.');
|
||||
}
|
||||
|
||||
if ($refs['image'] !== null && $data['alt'] === null) {
|
||||
$errors->add('data.alt', 'Bitte einen Alternativtext für das Bild angeben.');
|
||||
}
|
||||
|
||||
return [$data, $refs];
|
||||
}
|
||||
|
||||
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),
|
||||
'surface' => in_array($surface, ['cream', 'clear', 'navy'], true) ? $surface : 'cream',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
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 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
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'media_card';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Medien- und Materialkarte';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Karte zu einem Film oder Material aus der Bibliothek; Titel und Art kommen aus den Fachdaten, kein Abspielen, kein Download.';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-film';
|
||||
}
|
||||
|
||||
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']];
|
||||
}
|
||||
|
||||
protected function refKey(): string
|
||||
{
|
||||
return 'element';
|
||||
}
|
||||
|
||||
protected function refLabel(): string
|
||||
{
|
||||
return 'Medium oder Material';
|
||||
}
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
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
|
||||
{
|
||||
return app(PublicMaterialReader::class)->search($term);
|
||||
}
|
||||
|
||||
protected function subjectLabel(mixed $id): ?string
|
||||
{
|
||||
return app(PublicMaterialReader::class)->labelFor($id);
|
||||
}
|
||||
|
||||
protected function rejectSubject(int $id): ?string
|
||||
{
|
||||
$element = ContentElement::query()->find($id);
|
||||
|
||||
return $element !== null && app(PublicMaterialReader::class)->isSelectable($element)
|
||||
? null
|
||||
: 'Dieser Inhalt ist archiviert oder gesperrt.';
|
||||
}
|
||||
|
||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||
{
|
||||
return app(PublicMaterialReader::class)->subject($id, includeNonPublic: $context->preview);
|
||||
}
|
||||
|
||||
protected function defaultActionLabel(): string
|
||||
{
|
||||
return 'Im Programm ansehen';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Types;
|
||||
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
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;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Group;
|
||||
|
||||
/**
|
||||
* Gemeinsame Basis der Premium-Karten (Brand-UI-Kit v1.7, Entwurf zur visuellen Freigabe):
|
||||
* Redaktionelle Themenkarte, Medien- und Materialkarte, Modul- und Programmkarte.
|
||||
*
|
||||
* - Eine Karte je Widget, ein Widget je Platz. Das Raster ist das bestehende Abschnittsraster (1 bis 4 Einheiten);
|
||||
* es gibt kein zweites Kartenraster.
|
||||
* - refs: genau ein Fachobjekt (Kennung) und optional ein Bild aus dem öffentlichen Website-Bereich.
|
||||
* Titel, Kurzbeschreibung, Art, Zusatzangaben und Linkziel kommen zur Laufzeit aus den Fachdaten.
|
||||
* - data: nur Redaktionelles, das es im Fachobjekt nicht gibt: Beschriftung der Aktion, Hinweis, Alternativtext,
|
||||
* Bildausschnitt. Ein freies Linkziel gibt es nicht; das Ziel ist immer die öffentliche Seite des Fachobjekts.
|
||||
* - Bilder der Bibliothek (Vorschaubilder, Filmstandbilder) werden nie gezeigt.
|
||||
*/
|
||||
abstract class PremiumCardWidget extends WidgetType
|
||||
{
|
||||
public const SHOW = ['yes' => 'Anzeigen', 'no' => 'Ausblenden'];
|
||||
|
||||
/** Schlüssel des Fachobjekts in refs, zum Beispiel 'pillar'. */
|
||||
abstract protected function refKey(): string;
|
||||
|
||||
abstract protected function refLabel(): string;
|
||||
|
||||
abstract protected function refHelp(): string;
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
abstract protected function searchSubjects(?string $term): array;
|
||||
|
||||
abstract protected function subjectLabel(mixed $id): ?string;
|
||||
|
||||
/** Prüft beim Speichern, ob das Objekt gewählt werden darf; liefert sonst die Fehlermeldung. */
|
||||
abstract protected function rejectSubject(int $id): ?string;
|
||||
|
||||
abstract protected function subject(mixed $id, RenderContext $context): ?CardSubject;
|
||||
|
||||
abstract protected function defaultActionLabel(): string;
|
||||
|
||||
/** Gestaltungsvariante des Kits: editorial, media oder catalog. */
|
||||
abstract protected function cardStyle(): string;
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'widgets.premium_card';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'stacked' => 'unter 520 px Kartenbreite: Bild oder Tafel über dem Text',
|
||||
'side' => 'ab 520 px: Bild links (42 %), Text rechts (58 %); das gewählte Bildformat bleibt erhalten',
|
||||
];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Unter 520 px Kartenbreite steht das Bild über dem Text. Ab etwa 240 px nutzbar, empfohlen ab 280 px (eine Einheit ab Tablet). Texte werden nie gekürzt.';
|
||||
}
|
||||
|
||||
public function heights(): array
|
||||
{
|
||||
return [
|
||||
'auto' => 'Natürliche Höhe',
|
||||
'fill' => 'An die Zeile angleichen',
|
||||
];
|
||||
}
|
||||
|
||||
public function variants(): array
|
||||
{
|
||||
return [
|
||||
'adaptive' => 'Anpassend (ab 520 px Bild neben Text)',
|
||||
'stacked' => 'Bild immer über dem Text',
|
||||
];
|
||||
}
|
||||
|
||||
public function optionIcons(): array
|
||||
{
|
||||
return [
|
||||
'variant' => ['adaptive' => 'heroicon-o-view-columns', 'stacked' => 'heroicon-o-bars-3-bottom-left'],
|
||||
'height' => ['auto' => 'heroicon-o-arrows-pointing-in', 'fill' => 'heroicon-o-arrows-up-down'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
'format' => ['landscape' => 'Querformat 16:9', 'square' => 'Quadrat 1:1', 'portrait' => 'Hochformat 3:4'],
|
||||
'fit' => ['cover' => 'Ausschnitt füllt die Fläche', 'contain' => 'Ganzes Bild zeigen (Dokument, Poster)'],
|
||||
'heading_level' => ['h3' => 'H3', 'h2' => 'H2', 'h4' => 'H4'],
|
||||
'show_summary' => self::SHOW,
|
||||
'show_kind' => self::SHOW,
|
||||
'show_meta' => self::SHOW,
|
||||
'show_action' => self::SHOW,
|
||||
];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'format' => ['Bildformat', 'Vorgabe: Querformat 16:9. Gilt auch neben dem Text; das Motiv wird nicht nachträglich hochkant beschnitten.'],
|
||||
'fit' => ['Bilddarstellung', 'Vorgabe: Ausschnitt. „Ganzes Bild“ zeigt Dokumente und Poster vollständig auf ruhiger Fläche.'],
|
||||
'heading_level' => ['Überschriftenebene', 'Vorgabe: H3, passend unter einer Abschnittsüberschrift (H2).'],
|
||||
'show_summary' => ['Kurzbeschreibung', 'Aus den Fachdaten. Vorgabe: anzeigen.'],
|
||||
'show_kind' => ['Art oder Label', 'Zum Beispiel „Thema“ oder „Merkblatt“. Vorgabe: anzeigen.'],
|
||||
'show_meta' => ['Zusatzangaben', 'Aus den Fachdaten, zum Beispiel Ausgabeart oder Programmzugehörigkeit. Vorgabe: anzeigen.'],
|
||||
'show_action' => ['Aktion', 'Verweis auf die öffentliche Seite des Fachobjekts, falls es eine gibt. Vorgabe: anzeigen.'],
|
||||
];
|
||||
}
|
||||
|
||||
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'],
|
||||
];
|
||||
}
|
||||
|
||||
public function refRules(): array
|
||||
{
|
||||
return [$this->refKey() => ['required', 'integer']] + ImageRefFields::rules();
|
||||
}
|
||||
|
||||
public function dataFields(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('action_label')
|
||||
->label('Beschriftung der Aktion (optional)')
|
||||
->maxLength(60)
|
||||
->placeholder($this->defaultActionLabel())
|
||||
->live(onBlur: true)
|
||||
->helperText('Das Linkziel ist immer die öffentliche Seite des gewählten Objekts und kann nicht frei gesetzt werden.'),
|
||||
TextInput::make('note')
|
||||
->label('Hinweis (optional)')
|
||||
->maxLength(200)
|
||||
->live(onBlur: true)
|
||||
->helperText('Kurzer redaktioneller Satz über der Aktion, zum Beispiel „Für die nächste Kursstunde“. Begründet keine Berechtigung.'),
|
||||
PremiumFields::altField(),
|
||||
...PremiumFields::focusFields(66, 45),
|
||||
];
|
||||
}
|
||||
|
||||
public function refFields(): array
|
||||
{
|
||||
return [$this->subjectField(), ...ImageRefFields::fields(live: true)];
|
||||
}
|
||||
|
||||
public function editorSchema(): array
|
||||
{
|
||||
[$action, $note] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make([$this->subjectField()])->statePath('refs'),
|
||||
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'),
|
||||
];
|
||||
}
|
||||
|
||||
public function mediaSchema(): array
|
||||
{
|
||||
[, , $alt, $focusX, $focusY] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make(ImageRefFields::fields('Kartenbild', live: true))->statePath('refs'),
|
||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
||||
];
|
||||
}
|
||||
|
||||
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
{
|
||||
$key = $this->refKey();
|
||||
$id = (int) $refs[$key];
|
||||
$rejection = $this->rejectSubject($id);
|
||||
|
||||
if ($rejection !== null) {
|
||||
$errors->add("refs.$key", $rejection);
|
||||
}
|
||||
|
||||
$refs[$key] = $id;
|
||||
$refs = ImageRefFields::clean($refs, $errors);
|
||||
|
||||
foreach (['action_label', 'note', 'alt', 'heading', 'summary'] as $field) {
|
||||
$data[$field] = filled($data[$field] ?? null) ? trim((string) $data[$field]) : null;
|
||||
}
|
||||
|
||||
foreach (['focus_x', 'focus_y'] as $field) {
|
||||
$value = $data[$field] ?? null;
|
||||
$data[$field] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
||||
}
|
||||
|
||||
return [$data, $refs];
|
||||
}
|
||||
|
||||
public function resolve(array $widget, RenderContext $context): array
|
||||
{
|
||||
$settings = $widget['settings'];
|
||||
$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' => $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'),
|
||||
'headingTag' => $option('heading_level', 'h3'),
|
||||
'show' => [
|
||||
'summary' => ! array_key_exists('show_summary', $this->settings()) || $option('show_summary', 'yes') === 'yes',
|
||||
'kind' => ! array_key_exists('show_kind', $this->settings()) || $option('show_kind', 'yes') === 'yes',
|
||||
'meta' => $option('show_meta', 'yes') === 'yes',
|
||||
'action' => $option('show_action', 'yes') === 'yes',
|
||||
],
|
||||
'actionLabel' => filled($data['action_label'] ?? null) ? (string) $data['action_label'] : $this->defaultActionLabel(),
|
||||
'note' => filled($data['note'] ?? null) ? (string) $data['note'] : null,
|
||||
'stacked' => $widget['variant'] === 'stacked',
|
||||
];
|
||||
}
|
||||
|
||||
public function mediaPaths(array $widget): array
|
||||
{
|
||||
$image = $widget['refs']['image'] ?? null;
|
||||
|
||||
return PublicMedia::isPublicPath($image) ? [$image] : [];
|
||||
}
|
||||
|
||||
public function summary(array $widget): string
|
||||
{
|
||||
$label = $this->subjectLabel($widget['refs'][$this->refKey()] ?? null);
|
||||
|
||||
return $label ?? 'Kein Objekt gewählt';
|
||||
}
|
||||
|
||||
protected function centralCoverId(mixed $id): ?int
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
private function subjectField(): Select
|
||||
{
|
||||
return Select::make($this->refKey())
|
||||
->label($this->refLabel())
|
||||
->helperText($this->refHelp())
|
||||
->required()
|
||||
->live()
|
||||
->searchable()
|
||||
->getSearchResultsUsing(fn (?string $search): array => $this->searchSubjects($search))
|
||||
->getOptionLabelUsing(fn (mixed $value): ?string => $this->subjectLabel($value))
|
||||
->options(fn (): array => $this->searchSubjects(null));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Modul- und Programmkarte (Kit v1.7 „catalog“): ein Programm oder Modul über PublicCatalogReader, dieselbe
|
||||
* Freigaberegel wie die Programm- und Modulkarten (Programme öffentlich mit Programmseite, Module nur in der
|
||||
* Redaktionsvorschau). Die Art ist immer sichtbar benannt. Ohne Bild trägt eine Navy-Tafel die Art.
|
||||
* Kein Preis, kein Angebot, keine Kaufaktion; eine Karte ist kein Lizenzartikel.
|
||||
*/
|
||||
class ProgramCardWidget extends PremiumCardWidget
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'program_card';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Programm- oder Modulkarte';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Karte zu einem Programm oder Modul; Titel, Beschreibung und Art kommen aus den Fachdaten, ohne Preis und ohne Kaufaktion.';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-academic-cap';
|
||||
}
|
||||
|
||||
public function schematic(): array
|
||||
{
|
||||
return [[2, 2, 56, 32, 'line'], [5, 5, 22, 26, 'ink'], [8, 24, 10, 2, 'accent'], [31, 8, 10, 2, 'line'], [31, 13, 22, 4, 'ink'], [31, 25, 14, 5, 'ink']];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
// Die Art (Programm oder Modul) bleibt immer sichtbar; sie lässt sich nicht ausblenden.
|
||||
$settings = parent::settings();
|
||||
unset($settings['show_kind']);
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
protected function refKey(): string
|
||||
{
|
||||
return 'composition';
|
||||
}
|
||||
|
||||
protected function refLabel(): string
|
||||
{
|
||||
return 'Programm oder Modul';
|
||||
}
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
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)->cardSearch($term);
|
||||
}
|
||||
|
||||
protected function subjectLabel(mixed $id): ?string
|
||||
{
|
||||
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)->isCardSelectable($composition)
|
||||
? null
|
||||
: 'Dieses Objekt ist kein Programm oder Modul mit bereitgestellter Fassung.';
|
||||
}
|
||||
|
||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||
{
|
||||
return app(PublicCatalogReader::class)->subject($id, includeNonPublic: $context->preview);
|
||||
}
|
||||
|
||||
protected function defaultActionLabel(): string
|
||||
{
|
||||
return 'Programm ansehen';
|
||||
}
|
||||
|
||||
protected function cardStyle(): string
|
||||
{
|
||||
return 'catalog';
|
||||
}
|
||||
|
||||
protected function centralCoverId(mixed $id): ?int
|
||||
{
|
||||
$composition = is_numeric($id) ? Composition::query()->find((int) $id) : null;
|
||||
|
||||
return $composition instanceof Composition
|
||||
? app(PresentationMedia::class)->coverElementId($composition)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,28 @@ public function description(): string
|
||||
return 'Längerer Text in Absätzen. Eine Leerzeile beginnt einen neuen Absatz.';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Fließtext bricht um; Zeilen höchstens etwa 70 Zeichen.';
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'fluid' => 'Zeilenlänge höchstens etwa 70 Zeichen',
|
||||
];
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-bars-3-bottom-left';
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Types;
|
||||
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'topic_card';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Themenkarte';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Redaktionelle Karte zu einem veröffentlichten Thema; Name, Kurzbeschreibung und Ziel kommen aus dem Thema.';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-bookmark-square';
|
||||
}
|
||||
|
||||
public function schematic(): array
|
||||
{
|
||||
return [[2, 2, 56, 32, 'line'], [5, 5, 22, 26, 'image'], [31, 8, 10, 2, 'accent'], [31, 13, 22, 4, 'ink'], [31, 20, 20, 3, 'line'], [31, 27, 12, 2, 'accent']];
|
||||
}
|
||||
|
||||
protected function refKey(): string
|
||||
{
|
||||
return 'pillar';
|
||||
}
|
||||
|
||||
protected function refLabel(): string
|
||||
{
|
||||
return 'Thema';
|
||||
}
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
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
|
||||
{
|
||||
$term = trim((string) $term);
|
||||
|
||||
return Pillar::query()
|
||||
->orderBy('sort_order')
|
||||
->orderBy('name')
|
||||
->when($term !== '', fn ($query) => $query->whereRaw('LOWER(name) LIKE ?', ['%'.mb_strtolower($term).'%']))
|
||||
->limit(50)
|
||||
->get()
|
||||
->mapWithKeys(fn (Pillar $pillar): array => [$pillar->id => $this->optionLabel($pillar)])
|
||||
->all();
|
||||
}
|
||||
|
||||
protected function subjectLabel(mixed $id): ?string
|
||||
{
|
||||
$pillar = is_numeric($id) ? Pillar::query()->find((int) $id) : null;
|
||||
|
||||
return $pillar === null ? null : $this->optionLabel($pillar);
|
||||
}
|
||||
|
||||
protected function rejectSubject(int $id): ?string
|
||||
{
|
||||
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) {
|
||||
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: $summary,
|
||||
kind: 'Thema',
|
||||
badge: null,
|
||||
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';
|
||||
}
|
||||
|
||||
protected function cardStyle(): string
|
||||
{
|
||||
return 'editorial';
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,20 @@ public function register(WidgetType $type): void
|
||||
throw new InvalidArgumentException("Widget „{$key}“ braucht eine Schemaversion ab 1.");
|
||||
}
|
||||
|
||||
// Gemeinsamer Layoutvertrag (ADR-38): Breiten, Vorzugsbreite und Höhen aus festen Wertebereichen.
|
||||
$units = $type->supportedUnits();
|
||||
if ($units === [] || array_diff($units, [1, 2, 3, 4]) !== [] || $units !== array_values(array_unique($units)) || ! $type->supportsUnits($type->preferredUnits())) {
|
||||
throw new InvalidArgumentException("Widget „{$key}“ braucht unterstützte Breiten zwischen 1 und 4 Rastereinheiten und eine darin enthaltene Vorzugsbreite.");
|
||||
}
|
||||
|
||||
if (array_diff(array_keys($type->heights()), array_keys(WidgetType::HEIGHTS)) !== []) {
|
||||
throw new InvalidArgumentException("Widget „{$key}“ verwendet eine Höhe außerhalb des gemeinsamen Vokabulars.");
|
||||
}
|
||||
|
||||
if (array_key_exists('height', $type->settings())) {
|
||||
throw new InvalidArgumentException("Widget „{$key}“ deklariert die Höhe über heights(), nicht über settings().");
|
||||
}
|
||||
|
||||
if ($type->variants() === []) {
|
||||
throw new InvalidArgumentException("Widget „{$key}“ braucht mindestens eine Darstellungsvariante.");
|
||||
}
|
||||
@@ -137,7 +151,7 @@ public function upcast(array $block): ?array
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft und bereinigt Bausteine für eine neue Revision.
|
||||
* Prüft und bereinigt eine flache Bausteinliste (Fehlerschlüssel "blocks.N…").
|
||||
*
|
||||
* @param array<int|string, mixed> $blocks
|
||||
* @return list<array{id: string, type: string, v: int, variant: string, settings: array<string, mixed>, data: array<string, mixed>, refs: array<string, mixed>}>
|
||||
@@ -148,42 +162,53 @@ public function normalize(array $blocks): array
|
||||
$seenIds = [];
|
||||
|
||||
foreach (array_values($blocks) as $index => $block) {
|
||||
if (! is_array($block)) {
|
||||
throw ValidationException::withMessages([
|
||||
"blocks.$index" => 'Ein Baustein ist unvollständig.',
|
||||
]);
|
||||
}
|
||||
|
||||
if (! $this->has($block['type'] ?? null)) {
|
||||
throw ValidationException::withMessages([
|
||||
"blocks.$index.type" => 'Dieser Bausteintyp ist nicht freigegeben.',
|
||||
]);
|
||||
}
|
||||
|
||||
$type = $this->get($block['type']);
|
||||
|
||||
if (array_key_exists('v', $block) && (int) $block['v'] > $type->version()) {
|
||||
throw ValidationException::withMessages([
|
||||
"blocks.$index.v" => 'Dieser Baustein stammt aus einer neueren Programmfassung und kann hier nicht gespeichert werden.',
|
||||
]);
|
||||
}
|
||||
|
||||
$requested = $block['variant'] ?? null;
|
||||
$isCurrent = array_key_exists('v', $block) && (int) $block['v'] === $type->version();
|
||||
|
||||
if ($isCurrent && is_string($requested) && $requested !== '' && ! array_key_exists($requested, $type->variants())) {
|
||||
throw ValidationException::withMessages([
|
||||
"blocks.$index.variant" => 'Diese Darstellungsvariante ist für den Baustein nicht freigegeben.',
|
||||
]);
|
||||
}
|
||||
|
||||
$widget = $this->upcast($block);
|
||||
$normalized[] = $this->validateOne($type, $widget, $index, $seenIds);
|
||||
$normalized[] = $this->normalizeWidget($block, "blocks.$index", $seenIds);
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft und bereinigt einen einzelnen Baustein für eine neue Revision. Der Aufrufer führt die Menge
|
||||
* bereits vergebener Kennungen über die ganze Seite, damit kopierte Widgets neue Kennungen erhalten.
|
||||
*
|
||||
* @param array<string, true> $seenIds
|
||||
* @return array{id: string, type: string, v: int, variant: string, settings: array<string, mixed>, data: array<string, mixed>, refs: array<string, mixed>}
|
||||
*/
|
||||
public function normalizeWidget(mixed $block, string $errorPrefix, array &$seenIds): array
|
||||
{
|
||||
if (! is_array($block)) {
|
||||
throw ValidationException::withMessages([
|
||||
$errorPrefix => 'Ein Baustein ist unvollständig.',
|
||||
]);
|
||||
}
|
||||
|
||||
if (! $this->has($block['type'] ?? null)) {
|
||||
throw ValidationException::withMessages([
|
||||
"$errorPrefix.type" => 'Dieser Bausteintyp ist nicht freigegeben.',
|
||||
]);
|
||||
}
|
||||
|
||||
$type = $this->get($block['type']);
|
||||
|
||||
if (array_key_exists('v', $block) && (int) $block['v'] > $type->version()) {
|
||||
throw ValidationException::withMessages([
|
||||
"$errorPrefix.v" => 'Dieser Baustein stammt aus einer neueren Programmfassung und kann hier nicht gespeichert werden.',
|
||||
]);
|
||||
}
|
||||
|
||||
$requested = $block['variant'] ?? null;
|
||||
$isCurrent = array_key_exists('v', $block) && (int) $block['v'] === $type->version();
|
||||
|
||||
if ($isCurrent && is_string($requested) && $requested !== '' && ! array_key_exists($requested, $type->variants())) {
|
||||
throw ValidationException::withMessages([
|
||||
"$errorPrefix.variant" => 'Diese Darstellungsvariante ist für den Baustein nicht freigegeben.',
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->validateOne($type, $this->upcast($block), $errorPrefix, $seenIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gespeicherte Bausteine einer Revision als aktuelle Hüllen; unbekannte Arten entfallen.
|
||||
*
|
||||
@@ -241,7 +266,7 @@ public function mediaPaths(?array $blocks): array
|
||||
* @param array<string, true> $seenIds
|
||||
* @return array{id: string, type: string, v: int, variant: string, settings: array<string, mixed>, data: array<string, mixed>, refs: array<string, mixed>}
|
||||
*/
|
||||
private function validateOne(WidgetType $type, array $widget, int $index, array &$seenIds): array
|
||||
private function validateOne(WidgetType $type, array $widget, string $errorPrefix, array &$seenIds): array
|
||||
{
|
||||
$errors = new WidgetErrors;
|
||||
|
||||
@@ -251,7 +276,7 @@ private function validateOne(WidgetType $type, array $widget, int $index, array
|
||||
}
|
||||
|
||||
$settings = [];
|
||||
$allowedSettings = $type->settings();
|
||||
$allowedSettings = $type->settingOptions();
|
||||
foreach ($widget['settings'] as $key => $value) {
|
||||
if ($value === null || $value === '') {
|
||||
continue;
|
||||
@@ -292,7 +317,7 @@ private function validateOne(WidgetType $type, array $widget, int $index, array
|
||||
if (! $errors->isEmpty()) {
|
||||
$messages = [];
|
||||
foreach ($errors->all() as $key => $list) {
|
||||
$messages["blocks.$index.$key"] = $list;
|
||||
$messages["$errorPrefix.$key"] = $list;
|
||||
}
|
||||
|
||||
throw ValidationException::withMessages($messages);
|
||||
|
||||
@@ -61,6 +61,7 @@ public function renderWidget(array $widget, RenderContext $context, bool $first
|
||||
'refs' => $widget['refs'],
|
||||
'variant' => $widget['variant'],
|
||||
'settings' => $widget['settings'],
|
||||
'height' => $type->height($widget),
|
||||
'first' => $first,
|
||||
'context' => $context,
|
||||
] + $type->resolve($widget, $context))->render());
|
||||
@@ -71,7 +72,11 @@ public function renderWidget(array $widget, RenderContext $context, bool $first
|
||||
|
||||
$id = is_string($widget['id'] ?? null) ? ' id="abschnitt-'.e($widget['id']).'"' : '';
|
||||
|
||||
return '<section class="block widget widget-'.e(str_replace('_', '-', $widget['type'])).' widget-variant-'.e(str_replace('_', '-', $widget['variant'])).'"'.$id.'>'
|
||||
// Gemeinsamer Layoutvertrag (ADR-38): Höhe als Klasse an der Hülle, nur wenn die Art Höhen anbietet.
|
||||
$height = $type->height($widget);
|
||||
$heightClass = $height !== null ? ' widget-height-'.e($height) : '';
|
||||
|
||||
return '<section class="block widget widget-'.e(str_replace('_', '-', $widget['type'])).' widget-variant-'.e(str_replace('_', '-', $widget['variant'])).$heightClass.'"'.$id.'>'
|
||||
.$inner
|
||||
.'</section>';
|
||||
}
|
||||
|
||||
@@ -34,6 +34,113 @@ public function version(): int
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gemeinsames Höhenvokabular aller Widget-Arten (ADR-38). Eine Art bietet davon nur die sinnvollen Werte an
|
||||
* (heights()). Die Höhe ist ein Gestaltungsparameter, nie eine Begrenzung: Inhalte erhalten immer den nötigen Platz.
|
||||
*/
|
||||
public const HEIGHTS = [
|
||||
'auto' => 'Automatisch',
|
||||
'compact' => 'Kompakt',
|
||||
'normal' => 'Normal',
|
||||
'large' => 'Groß',
|
||||
'spacious' => 'Großzügig',
|
||||
'fill' => 'Abschnittshöhe füllen',
|
||||
];
|
||||
|
||||
/**
|
||||
* Gemeinsamer Layoutvertrag (ADR-38), Teil 1: zulässige Platzbreiten in logischen Rastereinheiten (1 bis 4).
|
||||
* Ein Platz mit nicht unterstützter Breite wird beim Speichern abgewiesen. Auf Tablet und Smartphone stapeln die
|
||||
* Plätze; dort bestimmt die tatsächliche Containerbreite die Darstellung (Container-Abfragen), nicht die Einheitenzahl.
|
||||
*
|
||||
* @return list<int>
|
||||
*/
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function supportsUnits(int $units): bool
|
||||
{
|
||||
return in_array($units, $this->supportedUnits(), true);
|
||||
}
|
||||
|
||||
/** Kleinste zulässige Platzbreite; abgeleitet aus supportedUnits(). */
|
||||
public function minUnits(): int
|
||||
{
|
||||
return min($this->supportedUnits());
|
||||
}
|
||||
|
||||
/** Lesbare Angabe der zulässigen Platzbreiten, zum Beispiel „1 bis 4“ oder „3 oder 4“. */
|
||||
public function unitsLabel(): string
|
||||
{
|
||||
$units = $this->supportedUnits();
|
||||
|
||||
if (count($units) === 1) {
|
||||
return (string) $units[0];
|
||||
}
|
||||
|
||||
if ($units === range(min($units), max($units)) && count($units) > 2) {
|
||||
return min($units).' bis '.max($units);
|
||||
}
|
||||
|
||||
$last = array_pop($units);
|
||||
|
||||
return implode(', ', $units).' oder '.$last;
|
||||
}
|
||||
|
||||
/** Empfohlene Slotbreite in Rastereinheiten; Hinweis in der Widget-Auswahl. */
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Darstellungsstufen nach verfügbarer Breite (Container-Abfragen in der Widget-Ansicht): Kennung => Beschreibung.
|
||||
* Dokumentiert, wie sich das Widget an schmale und breite Slots anpasst.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function stages(): array
|
||||
{
|
||||
return ['fluid' => 'passt sich fließend an jede Slotbreite an'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gemeinsamer Layoutvertrag, Teil 2: angebotene Höhen (Schlüssel aus HEIGHTS => Bezeichnung im Editor).
|
||||
* Leer: keine Höhenwahl, die Höhe folgt dem Inhalt. Der erste Eintrag ist die Vorgabe.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function heights(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function defaultHeight(): ?string
|
||||
{
|
||||
$key = array_key_first($this->heights());
|
||||
|
||||
return $key === null ? null : (string) $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wirksame Höhe einer Instanz (gespeicherte Einstellung oder Vorgabe).
|
||||
*
|
||||
* @param array<string, mixed> $widget
|
||||
*/
|
||||
public function height(array $widget): ?string
|
||||
{
|
||||
$height = $widget['settings']['height'] ?? null;
|
||||
|
||||
return is_string($height) && array_key_exists($height, $this->heights()) ? $height : $this->defaultHeight();
|
||||
}
|
||||
|
||||
/** Gemeinsamer Layoutvertrag, Teil 3: Verhalten bei reduziertem Platzangebot (Hinweis im Editor und in der Dokumentation). */
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Text bricht um, nichts wird abgeschnitten.';
|
||||
}
|
||||
|
||||
/** Heroicon-Name für Auswahl und Liste im Editor. */
|
||||
public function icon(): string
|
||||
{
|
||||
@@ -76,6 +183,44 @@ public function settings(): array
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Bezeichnungen der Einstellungen im Editor: Schlüssel => [Bezeichnung, Hilfetext].
|
||||
* Ohne leere Auswahl gilt die Vorgabe der Darstellung.
|
||||
*
|
||||
* @return array<string, array{0: string, 1?: string}>
|
||||
*/
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Alle zulässigen Einstellungen einschließlich der gemeinsamen Höhe. Registry-Prüfung, Editor und Darstellung
|
||||
* verwenden ausschließlich diese Zusammenführung.
|
||||
*
|
||||
* @return array<string, array<string, string>>
|
||||
*/
|
||||
final public function settingOptions(): array
|
||||
{
|
||||
$options = $this->settings();
|
||||
|
||||
if ($this->heights() !== []) {
|
||||
$options['height'] = $this->heights();
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Symbole für die visuelle Auswahl im Editor: 'variant' oder Einstellungsschlüssel => [Wert => Heroicon].
|
||||
*
|
||||
* @return array<string, array<string, string>>
|
||||
*/
|
||||
public function optionIcons(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüfregeln für data. Schlüssel relativ zu data (zum Beispiel 'heading', 'items.*.title').
|
||||
*
|
||||
@@ -116,6 +261,17 @@ public function refFields(): array
|
||||
*
|
||||
* @return list<Component>
|
||||
*/
|
||||
/**
|
||||
* Felder der Gruppe „Medien“ im Bearbeitungsdialog (Bild, Bildausschnitt, Alternativtext). Leer: keine eigene Gruppe;
|
||||
* Verweise stehen dann mit im Inhalt (editorSchema()).
|
||||
*
|
||||
* @return list<Component>
|
||||
*/
|
||||
public function mediaSchema(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function editorSchema(): array
|
||||
{
|
||||
$schema = [];
|
||||
|
||||
@@ -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 [
|
||||
|
||||
@@ -40,7 +40,31 @@ public static function form(Schema $schema): Schema
|
||||
->label('Platz')
|
||||
->options(NavigationItem::PLACEMENTS)
|
||||
->default('header')
|
||||
->required(),
|
||||
->required()
|
||||
->live()
|
||||
->helperText('Kopfzeile: Hauptnavigation. Fußbereich: drei Spalten „Service“, „Kontakt“ und „Rechtliches“.'),
|
||||
Select::make('parent_id')
|
||||
->label('Untermenü von')
|
||||
->placeholder('Oberste Ebene')
|
||||
->options(fn (?NavigationItem $record): array => NavigationItem::query()
|
||||
->where('placement', 'header')
|
||||
->whereNull('parent_id')
|
||||
->when($record !== null, fn ($query) => $query->whereKeyNot($record->getKey()))
|
||||
->orderBy('sort_order')
|
||||
->pluck('label', 'id')
|
||||
->all())
|
||||
->visible(fn (Get $get): bool => $get('placement') === 'header')
|
||||
->disabled(fn (?NavigationItem $record): bool => $record !== null && $record->children()->exists())
|
||||
->helperText('Eine Ebene Untermenü in der Hauptnavigation. Ein Eintrag mit eigenen Untereinträgen bleibt oberste Ebene.')
|
||||
->rule(fn (?NavigationItem $record): Closure => function (string $attribute, mixed $value, Closure $fail) use ($record): void {
|
||||
if (blank($value)) {
|
||||
return;
|
||||
}
|
||||
$parent = NavigationItem::query()->find($value);
|
||||
if ($parent === null || $parent->placement !== 'header' || $parent->parent_id !== null || ($record !== null && $parent->is($record))) {
|
||||
$fail('Untermenüs sind nur unter einem Eintrag der obersten Ebene der Hauptnavigation möglich.');
|
||||
}
|
||||
}),
|
||||
Select::make('page_id')
|
||||
->label('Interne Seite')
|
||||
->options(fn (): array => Page::query()->orderBy('path')->pluck('path', 'id')->all())
|
||||
@@ -51,9 +75,10 @@ public static function form(Schema $schema): Schema
|
||||
->maxLength(500)
|
||||
->helperText('Nur wenn keine Seite gewählt ist: Pfad wie /anmelden oder eine vollständige http(s)-Adresse.')
|
||||
->rule(SafeUrl::rule())
|
||||
->rule(function (Get $get): Closure {
|
||||
return function (string $attribute, mixed $value, Closure $fail) use ($get): void {
|
||||
if (blank($get('page_id')) && blank($value)) {
|
||||
->rule(function (Get $get, ?NavigationItem $record): Closure {
|
||||
return function (string $attribute, mixed $value, Closure $fail) use ($get, $record): void {
|
||||
// Ein Eintrag mit Untereinträgen darf ohne eigenes Ziel nur das Untermenü öffnen.
|
||||
if (blank($get('page_id')) && blank($value) && ! ($record?->children()->exists() ?? false)) {
|
||||
$fail('Wählen Sie eine Seite oder eine Adresse.');
|
||||
}
|
||||
};
|
||||
@@ -75,7 +100,11 @@ public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('label')->label('Beschriftung')->searchable(),
|
||||
TextColumn::make('label')
|
||||
->label('Beschriftung')
|
||||
->searchable()
|
||||
->formatStateUsing(fn (string $state, NavigationItem $record): string => $record->parent_id !== null ? '↳ '.$state : $state)
|
||||
->description(fn (NavigationItem $record): ?string => $record->parent !== null ? 'Untermenü von „'.$record->parent->label.'“' : null),
|
||||
TextColumn::make('target')
|
||||
->label('Ziel')
|
||||
->state(fn (NavigationItem $record): string => $record->page?->path ?? (string) $record->url),
|
||||
@@ -88,7 +117,7 @@ public static function table(Table $table): Table
|
||||
Group::make('placement')
|
||||
->label('Platz')
|
||||
->getTitleFromRecordUsing(fn (NavigationItem $record): string => NavigationItem::PLACEMENTS[$record->placement] ?? $record->placement)
|
||||
->orderQueryUsing(fn ($query, string $direction) => $query->orderByRaw("CASE placement WHEN 'header' THEN 0 ELSE 1 END"))
|
||||
->orderQueryUsing(fn ($query, string $direction) => $query->orderByRaw("CASE placement WHEN 'header' THEN 0 WHEN 'footer' THEN 1 WHEN 'footer_contact' THEN 2 WHEN 'footer_legal' THEN 3 ELSE 4 END"))
|
||||
->collapsible(),
|
||||
)
|
||||
->paginated([50, 100])
|
||||
@@ -110,7 +139,7 @@ public static function table(Table $table): Table
|
||||
->action(fn (NavigationItem $record) => $record->update(['is_visible' => ! $record->is_visible])),
|
||||
EditAction::make(),
|
||||
DeleteAction::make()
|
||||
->modalDescription('Der Eintrag wird aus der Navigation entfernt. Die verlinkte Seite bleibt bestehen.'),
|
||||
->modalDescription('Der Eintrag wird aus der Navigation entfernt. Die verlinkte Seite bleibt bestehen; Untereinträge rücken in die oberste Ebene.'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,11 +4,13 @@
|
||||
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Filament\Resources\Pages\Pages\CreatePage;
|
||||
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||
use App\Filament\Resources\Pages\Pages\ListPages;
|
||||
use App\Filament\Resources\Pages\RelationManagers\RevisionsRelationManager;
|
||||
use App\Filament\Support\WidgetEditor;
|
||||
use App\Filament\Support\SectionEditor;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
@@ -17,6 +19,7 @@
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class PageResource extends Resource
|
||||
{
|
||||
@@ -36,6 +39,8 @@ public static function form(Schema $schema): Schema
|
||||
Section::make('Seite und Suchmaschinen')
|
||||
->description('Adresse, Titel für Suchmaschinen und Zuordnung zu Themenbereichen.')
|
||||
->collapsible()
|
||||
->collapsed(fn (string $operation): bool => $operation === 'edit')
|
||||
->persistCollapsed()
|
||||
->columns(2)
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
@@ -55,13 +60,14 @@ public static function form(Schema $schema): Schema
|
||||
->label('Fachliche Säulen')
|
||||
->options(fn (): array => Pillar::query()->orderBy('name')->pluck('name', 'id')->all())
|
||||
->helperText('Eine veröffentlichte Seite erscheint auf den gewählten Themenbereichen der Website. Eine Seite kann mehreren Säulen zugeordnet sein.')
|
||||
->columns(1),
|
||||
->columns(['default' => 1, 'lg' => 2]),
|
||||
]),
|
||||
Section::make('Inhalt der Seite')
|
||||
->description('Abschnitte hinzufügen, per Klick auf die Vorschau bearbeiten, mit den Pfeilen sortieren. Speichern legt einen Entwurf an; veröffentlicht wird erst über „Veröffentlichen“.')
|
||||
->description('Abschnitt hinzufügen, Raster wählen, Widgets in die Plätze einsetzen. Ein Klick auf die Vorschau eines Widgets öffnet seinen Dialog; Hintergrund, Breite, Abstand und Trenner stehen unter „Gestaltung des Abschnitts“. Speichern legt einen Entwurf an; veröffentlicht wird erst über „Veröffentlichen“.')
|
||||
->columnSpanFull()
|
||||
->extraAttributes(['class' => 'luf-page-content'])
|
||||
->schema([
|
||||
WidgetEditor::builder('blocks'),
|
||||
SectionEditor::repeater('sections'),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
@@ -69,14 +75,48 @@ public static function form(Schema $schema): Schema
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
// Zuletzt bearbeitete Seiten zuerst; jede Seite ist ohne Suche auffindbar (Spalten sortierbar, bis 100 je Seite).
|
||||
->columns([
|
||||
TextColumn::make('path')->label('Pfad')->searchable(),
|
||||
TextColumn::make('path')->label('Pfad')->searchable()->sortable(),
|
||||
TextColumn::make('published_revision_id')
|
||||
->label('Veröffentlicht')
|
||||
->formatStateUsing(fn ($state): string => $state ? 'Ja' : 'Entwurf'),
|
||||
TextColumn::make('updated_at')->label('Geändert')->dateTime('d.m.Y H:i'),
|
||||
TextColumn::make('updated_at')
|
||||
->label('Zuletzt bearbeitet')
|
||||
->dateTime('d.m.Y H:i', timezone: 'Europe/Berlin')
|
||||
->sortable(),
|
||||
])
|
||||
->recordUrl(fn (Page $record): string => static::getUrl('edit', ['record' => $record]));
|
||||
->defaultSort('updated_at', 'desc')
|
||||
->paginated([25, 50, 100])
|
||||
->defaultPaginationPageOption(25)
|
||||
->recordUrl(fn (Page $record): string => static::getUrl('edit', ['record' => $record]))
|
||||
->recordActions([
|
||||
Action::make('duplicate')
|
||||
->label('Duplizieren')
|
||||
->icon('heroicon-o-document-duplicate')
|
||||
->color('gray')
|
||||
->tooltip('Neue, unveröffentlichte Seite mit dem zuletzt gespeicherten Stand dieser Seite anlegen')
|
||||
->authorize(fn (): bool => auth()->user()?->can('create', Page::class) ?? false)
|
||||
->modalHeading(fn (Page $record): string => 'Seite '.$record->path.' duplizieren')
|
||||
->modalDescription('Die Kopie ist ein Entwurf unter neuer Adresse. Die Vorlage bleibt unverändert.')
|
||||
->schema([
|
||||
TextInput::make('path')
|
||||
->label('Pfad der neuen Seite')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->helperText('Zum Beispiel /neue-landingpage'),
|
||||
])
|
||||
->modalSubmitActionLabel('Duplizieren')
|
||||
->action(function (Page $record, array $data, PageService $service) {
|
||||
try {
|
||||
$copy = $service->duplicate($record, $data['path'], auth()->user());
|
||||
} catch (ValidationException $exception) {
|
||||
throw ValidationException::withMessages(['mountedActions.0.data.path' => $exception->errors()['path'] ?? $exception->errors()]);
|
||||
}
|
||||
|
||||
return redirect(static::getUrl('edit', ['record' => $copy]));
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
|
||||
@@ -6,16 +6,26 @@
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Filament\Resources\Pages\PageResource;
|
||||
use App\Filament\Support\WidgetEditor;
|
||||
use App\Filament\Support\ReportsSectionErrors;
|
||||
use App\Filament\Support\SectionEditor;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class CreatePage extends CreateRecord
|
||||
{
|
||||
use ReportsSectionErrors;
|
||||
|
||||
protected static string $resource = PageResource::class;
|
||||
|
||||
/** Breite Arbeitsfläche, damit mehrspaltige Raster im Editor erkennbar bleiben. */
|
||||
protected Width|string|null $maxContentWidth = Width::Full;
|
||||
|
||||
/** Warnt vor dem Verlassen oder Neuladen, wenn Änderungen noch nicht gespeichert sind. */
|
||||
protected ?bool $hasUnsavedDataChangesAlert = true;
|
||||
|
||||
protected static bool $canCreateAnother = false;
|
||||
|
||||
/**
|
||||
@@ -24,17 +34,17 @@ class CreatePage extends CreateRecord
|
||||
protected function handleRecordCreation(array $data): Model
|
||||
{
|
||||
$service = app(PageService::class);
|
||||
$blocks = WidgetEditor::fromBuilderState($data['blocks'] ?? []);
|
||||
$content = SectionEditor::fromEditorState($data['sections'] ?? []);
|
||||
|
||||
try {
|
||||
return DB::transaction(function () use ($service, $data, $blocks): Page {
|
||||
return DB::transaction(function () use ($service, $data, $content): Page {
|
||||
$page = Page::query()->create([
|
||||
'path' => $service->availablePath($data['path']),
|
||||
]);
|
||||
|
||||
$service->saveRevision(
|
||||
$page,
|
||||
$blocks,
|
||||
$content,
|
||||
$data['seo_title'] ?? null,
|
||||
$data['seo_description'] ?? null,
|
||||
auth()->user(),
|
||||
@@ -45,10 +55,10 @@ protected function handleRecordCreation(array $data): Model
|
||||
return $page;
|
||||
});
|
||||
} catch (ValidationException $exception) {
|
||||
WidgetEditor::notifyErrors($exception->errors(), $blocks);
|
||||
SectionEditor::notifyErrors($exception->errors(), $this->data['sections'] ?? []);
|
||||
|
||||
throw ValidationException::withMessages(
|
||||
WidgetEditor::mapErrors($exception->errors(), array_keys($this->data['blocks'] ?? [])),
|
||||
SectionEditor::mapErrors($exception->errors(), $this->data['sections'] ?? []),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,17 +6,27 @@
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Filament\Resources\Pages\PageResource;
|
||||
use App\Filament\Support\WidgetEditor;
|
||||
use App\Filament\Support\ReportsSectionErrors;
|
||||
use App\Filament\Support\SectionEditor;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class EditPage extends EditRecord
|
||||
{
|
||||
use ReportsSectionErrors;
|
||||
|
||||
protected static string $resource = PageResource::class;
|
||||
|
||||
/** Breite Arbeitsfläche, damit mehrspaltige Raster im Editor erkennbar bleiben. */
|
||||
protected Width|string|null $maxContentWidth = Width::Full;
|
||||
|
||||
/** Warnt vor dem Verlassen oder Neuladen, wenn Änderungen noch nicht gespeichert sind. */
|
||||
protected ?bool $hasUnsavedDataChangesAlert = true;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
@@ -37,10 +47,15 @@ protected function getHeaderActions(): array
|
||||
->label('Veröffentlichen')
|
||||
->icon('heroicon-o-globe-alt')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Zuletzt gespeicherten Entwurf veröffentlichen?')
|
||||
->modalDescription(fn (): string => 'Veröffentlicht wird Revision Nr. '.($this->record->latestRevision?->id ?? '–').'. Noch nicht gespeicherte Änderungen werden nicht veröffentlicht.')
|
||||
->modalHeading('Seite veröffentlichen?')
|
||||
->modalDescription('Der aktuelle Stand im Editor wird als Entwurf gespeichert und genau dieser Stand wird veröffentlicht. Enthält er Fehler, wird nichts veröffentlicht.')
|
||||
->modalSubmitActionLabel('Speichern und veröffentlichen')
|
||||
->visible(fn (): bool => auth()->user()?->can('publish', $this->record) ?? false)
|
||||
->action(function (PageService $service): void {
|
||||
// Ungespeicherte Änderungen (zum Beispiel ein eben gewähltes Bild) gingen sonst beim Veröffentlichen verloren.
|
||||
$this->save(shouldRedirect: false, shouldSendSavedNotification: false);
|
||||
|
||||
$this->record->unsetRelation('latestRevision');
|
||||
$revision = $this->record->latestRevision;
|
||||
abort_if($revision === null, 404);
|
||||
$service->publish($this->record, $revision);
|
||||
@@ -85,7 +100,7 @@ protected function afterSave(): void
|
||||
protected function mutateFormDataBeforeFill(array $data): array
|
||||
{
|
||||
$revision = $this->record->latestRevision ?? $this->record->publishedRevision;
|
||||
$data['blocks'] = WidgetEditor::toBuilderState($revision?->blocks);
|
||||
$data['sections'] = SectionEditor::toEditorState($revision?->sections() ?? []);
|
||||
$data['seo_title'] = $revision?->seo_title;
|
||||
$data['seo_description'] = $revision?->seo_description;
|
||||
$data['pillars'] = $this->record->pillars()->pluck('pillars.id')->all();
|
||||
@@ -100,16 +115,16 @@ protected function handleRecordUpdate(Model $record, array $data): Model
|
||||
{
|
||||
/** @var Page $record */
|
||||
$service = app(PageService::class);
|
||||
$blocks = WidgetEditor::fromBuilderState($data['blocks'] ?? []);
|
||||
$content = SectionEditor::fromEditorState($data['sections'] ?? []);
|
||||
|
||||
try {
|
||||
$path = $service->availablePath($data['path'], $record);
|
||||
$service->saveRevision($record, $blocks, $data['seo_title'] ?? null, $data['seo_description'] ?? null, auth()->user());
|
||||
$service->saveRevision($record, $content, $data['seo_title'] ?? null, $data['seo_description'] ?? null, auth()->user());
|
||||
} catch (ValidationException $exception) {
|
||||
WidgetEditor::notifyErrors($exception->errors(), $blocks);
|
||||
SectionEditor::notifyErrors($exception->errors(), $this->data['sections'] ?? []);
|
||||
|
||||
throw ValidationException::withMessages(
|
||||
WidgetEditor::mapErrors($exception->errors(), array_keys($this->data['blocks'] ?? [])),
|
||||
SectionEditor::mapErrors($exception->errors(), $this->data['sections'] ?? []),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,11 @@ public function table(Table $table): Table
|
||||
TextColumn::make('id')->label('Nr.'),
|
||||
TextColumn::make('created_at')->label('Gespeichert')->dateTime('d.m.Y H:i'),
|
||||
TextColumn::make('author.name')->label('Von'),
|
||||
TextColumn::make('sections')
|
||||
TextColumn::make('section_count')
|
||||
->label('Abschnitte')
|
||||
->state(fn (PageRevision $record): int => count($record->sections())),
|
||||
TextColumn::make('widget_count')
|
||||
->label('Widgets')
|
||||
->state(fn (PageRevision $record): int => count($record->widgets())),
|
||||
TextColumn::make('published')
|
||||
->label('Live')
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
* Macht Feldfehler aus Widget-Dialogen am Abschnitt sichtbar. Die Felder eines Widgets liegen in seinem Dialog;
|
||||
* schlägt die Formularprüfung beim Speichern fehl, erscheint eine Meldung mit Abschnitt, Platz und Widget-Art,
|
||||
* und das Platzraster des Abschnitts trägt eine Zusammenfassung.
|
||||
*/
|
||||
trait ReportsSectionErrors
|
||||
{
|
||||
protected function onValidationError(ValidationException $exception): void
|
||||
{
|
||||
parent::onValidationError($exception);
|
||||
|
||||
$state = is_array($this->data['sections'] ?? null) ? $this->data['sections'] : [];
|
||||
$sectionErrors = SectionEditor::sectionErrorsFromForm($exception->errors(), $state);
|
||||
|
||||
if ($sectionErrors === []) {
|
||||
return;
|
||||
}
|
||||
|
||||
SectionEditor::notifyErrors($sectionErrors, $state);
|
||||
|
||||
foreach (SectionEditor::mapErrors($sectionErrors, $state) as $key => $messages) {
|
||||
if (str_ends_with($key, '.slots')) {
|
||||
foreach ((array) $messages as $message) {
|
||||
$exception->validator->errors()->add($key, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,543 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use App\Domain\Cms\Sections\PageSections;
|
||||
use App\Domain\Cms\Sections\SectionLayouts;
|
||||
use App\Domain\Cms\Sections\SectionStyle;
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\Group;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Seiteneditor für Abschnitte und Slots.
|
||||
*
|
||||
* Aufbau: Abschnitte (Repeater) → Raster (grafische Auswahl) → Gestaltung (eingeklappt) → Plätze (Repeater im
|
||||
* Rasterverhältnis) → je Platz ein Widget (Builder mit höchstens einem Eintrag, Auswahl aus dem Widget-Register).
|
||||
* Abschnittseinstellungen stehen im Abschnitt, Widget-Einstellungen im Widget-Dialog: eine Dialogebene.
|
||||
*
|
||||
* Formularzustand eines Abschnitts: {id, layout, style: {...}, slots: {uuid: {widget: {uuid: Builder-Eintrag}}}}.
|
||||
*/
|
||||
class SectionEditor
|
||||
{
|
||||
public static function repeater(string $name = 'sections'): Repeater
|
||||
{
|
||||
return Repeater::make($name)
|
||||
->label('Abschnitte')
|
||||
->hiddenLabel()
|
||||
->schema(self::sectionSchema())
|
||||
->itemLabel(fn (array $state, ?int $index): string => self::sectionLabel($state, $index))
|
||||
->addActionLabel('Abschnitt hinzufügen')
|
||||
->addBetweenActionLabel('Abschnitt hier einfügen')
|
||||
->defaultItems(0)
|
||||
->reorderableWithButtons()
|
||||
->reorderableWithDragAndDrop()
|
||||
->cloneable()
|
||||
->collapsible()
|
||||
->deletable()
|
||||
->maxItems(PageSections::MAX_SECTIONS)
|
||||
->cloneAction(fn (Action $action): Action => $action
|
||||
->tooltip('Abschnitt duplizieren')
|
||||
->action(function (array $arguments, Repeater $component): void {
|
||||
// Die Kopie steht direkt hinter dem Original (Filament hängt sie sonst ans Seitenende).
|
||||
$component->rawState(self::insertCopyAfter($component->getRawState() ?? [], (string) $arguments['item'], (string) $component->generateUuid()));
|
||||
$component->callAfterStateUpdated();
|
||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||
}))
|
||||
->deleteAction(fn (Action $action): Action => $action
|
||||
->tooltip('Abschnitt löschen')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Abschnitt löschen?')
|
||||
->modalDescription('Der Abschnitt und die Widgets darin werden aus dem Entwurf entfernt. Bereits gespeicherte Revisionen bleiben erhalten.')
|
||||
->modalSubmitActionLabel('Löschen'))
|
||||
->moveUpAction(fn (Action $action): Action => $action->tooltip('Abschnitt nach oben'))
|
||||
->moveDownAction(fn (Action $action): Action => $action->tooltip('Abschnitt nach unten'))
|
||||
->reorderAction(fn (Action $action): Action => $action->tooltip('Abschnitt ziehen'))
|
||||
->collapseAction(fn (Action $action): Action => $action->tooltip('Abschnitt einklappen'))
|
||||
->expandAction(fn (Action $action): Action => $action->tooltip('Abschnitt aufklappen'))
|
||||
->extraAttributes(['class' => 'luf-sections'])
|
||||
->columnSpanFull();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<mixed>
|
||||
*/
|
||||
private static function sectionSchema(): array
|
||||
{
|
||||
return [
|
||||
Hidden::make('id'),
|
||||
ToggleButtons::make('layout')
|
||||
->label('Raster')
|
||||
->options(self::layoutOptions())
|
||||
->default(SectionLayouts::DEFAULT)
|
||||
->required()
|
||||
->inline()
|
||||
->live()
|
||||
->disableOptionWhen(fn (string $value, Get $get): bool => self::filledCount($get('slots')) > SectionLayouts::slotCount($value))
|
||||
->helperText(fn (Get $get): ?string => self::filledCount($get('slots')) > 1
|
||||
? 'Raster mit weniger Plätzen als eingesetzten Widgets sind gesperrt. Entfernen oder verschieben Sie zuerst ein Widget; beim Wechsel geht kein Widget verloren.'
|
||||
: null)
|
||||
->afterStateUpdated(function (?string $state, Get $get, Set $set): void {
|
||||
$set('slots', self::arrangeSlots($get('slots'), $state ?? SectionLayouts::DEFAULT));
|
||||
})
|
||||
->extraAttributes(['class' => 'luf-layout-picker']),
|
||||
Section::make('Gestaltung des Abschnitts')
|
||||
->description(fn (Get $get): string => SectionStyle::summary(is_array($get('style')) ? $get('style') : []))
|
||||
->icon('heroicon-o-swatch')
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->compact()
|
||||
->schema([
|
||||
Group::make(self::styleFields())
|
||||
->statePath('style')
|
||||
->columns(['default' => 1, 'md' => 2, 'xl' => 4]),
|
||||
]),
|
||||
Repeater::make('slots')
|
||||
->label('Plätze im Raster')
|
||||
->hiddenLabel()
|
||||
->schema([
|
||||
WidgetEditor::slotBuilder('widget'),
|
||||
])
|
||||
->addable(false)
|
||||
->deletable(false)
|
||||
->reorderableWithDragAndDrop()
|
||||
->reorderableWithButtons(false)
|
||||
->reorderAction(fn (Action $action): Action => $action->tooltip('Widget auf einen anderen Platz ziehen'))
|
||||
->itemLabel(fn (array $state, ?int $index, Get $get): string => self::slotLabel($state, $index, $get('layout')))
|
||||
->default(fn (): array => self::arrangeSlots([], SectionLayouts::DEFAULT))
|
||||
->extraAttributes(fn (Get $get): array => [
|
||||
'class' => 'luf-slots',
|
||||
'style' => '--luf-slot-cols: '.self::editorColumns($get('layout')),
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<mixed>
|
||||
*/
|
||||
private static function styleFields(): array
|
||||
{
|
||||
return [
|
||||
Select::make('background')
|
||||
->label('Hintergrund')
|
||||
->options(SectionStyle::BACKGROUNDS)
|
||||
->default('default')
|
||||
->selectablePlaceholder(false)
|
||||
->live(),
|
||||
Select::make('width')
|
||||
->label('Breite')
|
||||
->options(SectionStyle::WIDTHS)
|
||||
->default('standard')
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Ein Hintergrund reicht immer über die ganze Bildschirmbreite.'),
|
||||
Select::make('spacing_top')
|
||||
->label('Abstand oben')
|
||||
->options(SectionStyle::SPACINGS)
|
||||
->default(SectionStyle::DEFAULTS['spacing_top'])
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Vor dem Inhalt. Zwischen zwei Abschnitten addieren sich „unten“ und „oben“; „Kein Abstand“ lässt einen Einstieg direkt unter der Kopfzeile beginnen.'),
|
||||
Select::make('spacing_bottom')
|
||||
->label('Abstand unten')
|
||||
->options(SectionStyle::SPACINGS)
|
||||
->default(SectionStyle::DEFAULTS['spacing_bottom'])
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Nach dem Inhalt. Bei eigener Fläche liegen beide Abstände innerhalb der Fläche.'),
|
||||
Select::make('gap')
|
||||
->label('Widget-Abstand')
|
||||
->options(SectionStyle::SPACINGS)
|
||||
->default(SectionStyle::DEFAULTS['gap'])
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Zwischen den Plätzen dieses Abschnitts, nebeneinander und gestapelt. Abstände innerhalb eines Widgets bleiben Sache des Widgets.'),
|
||||
Select::make('divider')
|
||||
->label('Trenner zum nächsten Abschnitt')
|
||||
->options(SectionStyle::DIVIDERS)
|
||||
->default('none')
|
||||
->selectablePlaceholder(false),
|
||||
...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)
|
||||
->default('center')
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Dieser Bereich bleibt auf schmalen Bildschirmen sichtbar.')
|
||||
->visible(fn (Get $get): bool => $get('background') === 'image'),
|
||||
Select::make('overlay')
|
||||
->label('Überlagerung')
|
||||
->options(SectionStyle::OVERLAYS)
|
||||
->default('light')
|
||||
->selectablePlaceholder(false)
|
||||
->helperText('Sorgt für lesbaren Text auf dem Bild.')
|
||||
->visible(fn (Get $get): bool => $get('background') === 'image'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gespeicherte Abschnitte (PageSections::read) als Formularzustand.
|
||||
*
|
||||
* @param list<array<string, mixed>> $sections
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public static function toEditorState(array $sections): array
|
||||
{
|
||||
$state = [];
|
||||
|
||||
foreach ($sections as $section) {
|
||||
$slots = [];
|
||||
|
||||
foreach ($section['slots'] as $widget) {
|
||||
$slots[(string) Str::uuid()] = [
|
||||
'widget' => is_array($widget) ? self::keyed(WidgetEditor::toBuilderState([$widget])) : [],
|
||||
];
|
||||
}
|
||||
|
||||
$state[] = [
|
||||
'id' => $section['id'] ?? (string) Str::uuid(),
|
||||
'layout' => $section['layout'],
|
||||
'style' => SectionStyle::fromStored($section['style'] ?? []),
|
||||
'slots' => $slots,
|
||||
];
|
||||
}
|
||||
|
||||
return $state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formularzustand als Abschnitte für PageService::saveRevision().
|
||||
*
|
||||
* @param array<int|string, mixed>|null $state
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public static function fromEditorState(?array $state): array
|
||||
{
|
||||
$sections = [];
|
||||
|
||||
foreach (array_values($state ?? []) as $section) {
|
||||
if (! is_array($section)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$slots = [];
|
||||
foreach (array_values(is_array($section['slots'] ?? null) ? $section['slots'] : []) as $slot) {
|
||||
$items = is_array($slot['widget'] ?? null) ? $slot['widget'] : [];
|
||||
$slots[] = $items === [] ? null : (WidgetEditor::fromBuilderState($items)[0] ?? null);
|
||||
}
|
||||
|
||||
$sections[] = [
|
||||
'id' => $section['id'] ?? null,
|
||||
'layout' => $section['layout'] ?? SectionLayouts::DEFAULT,
|
||||
'style' => is_array($section['style'] ?? null) ? $section['style'] : [],
|
||||
'slots' => $slots,
|
||||
];
|
||||
}
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Übersetzt Fehlerschlüssel aus PageSections ("sections.2.slots.1.data.heading") in Formularpfade.
|
||||
* Widget-Fehler stehen zusätzlich als Zusammenfassung am Platzraster des Abschnitts, weil die Widget-Felder
|
||||
* nach dem Schließen des Dialogs nicht sichtbar sind.
|
||||
*
|
||||
* @param array<string, mixed> $errors
|
||||
* @param array<int|string, mixed> $state roher Formularzustand der Abschnitte
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function mapErrors(array $errors, array $state, string $statePath = 'data.sections'): array
|
||||
{
|
||||
$registry = app(WidgetRegistry::class);
|
||||
$sectionKeys = array_keys($state);
|
||||
$mapped = [];
|
||||
|
||||
foreach ($errors as $key => $messages) {
|
||||
$messages = (array) $messages;
|
||||
|
||||
if (preg_match('/^sections\.(\d+)(?:\.(.*))?$/', (string) $key, $match) !== 1 || ! isset($sectionKeys[(int) $match[1]])) {
|
||||
$mapped[$key === 'sections' ? $statePath : 'data.'.$key] = $messages;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$sectionKey = $sectionKeys[(int) $match[1]];
|
||||
$sectionPath = "$statePath.$sectionKey";
|
||||
$rest = $match[2] ?? '';
|
||||
|
||||
if (preg_match('/^slots\.(\d+)(?:\.(.*))?$/', $rest, $slotMatch) === 1) {
|
||||
$slotKeys = array_keys(is_array($state[$sectionKey]['slots'] ?? null) ? $state[$sectionKey]['slots'] : []);
|
||||
$slotKey = $slotKeys[(int) $slotMatch[1]] ?? null;
|
||||
$field = $slotMatch[2] ?? '';
|
||||
$position = (int) $slotMatch[1] + 1;
|
||||
$widgetItems = $slotKey !== null ? ($state[$sectionKey]['slots'][$slotKey]['widget'] ?? []) : [];
|
||||
$widgetKey = is_array($widgetItems) ? array_key_first($widgetItems) : null;
|
||||
$type = $widgetKey !== null ? ($widgetItems[$widgetKey]['type'] ?? null) : null;
|
||||
$label = $registry->has($type) ? $registry->get($type)->label() : 'Widget';
|
||||
|
||||
$summary = $mapped["$sectionPath.slots"] ?? [];
|
||||
foreach ($messages as $message) {
|
||||
$summary[] = "Platz $position ($label): $message";
|
||||
}
|
||||
$mapped["$sectionPath.slots"] = array_values(array_unique($summary));
|
||||
|
||||
if ($slotKey !== null && $widgetKey !== null && $field !== '' && $field !== 'units') {
|
||||
$field = preg_replace('/\.\d+\..*$/', '', $field);
|
||||
$mapped["$sectionPath.slots.$slotKey.widget.$widgetKey.data.$field"] = $messages;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$mapped[$rest === '' ? $sectionPath : "$sectionPath.$rest"] = $messages;
|
||||
}
|
||||
|
||||
return $mapped;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formularfehler aus Widget-Dialogen ("data.sections.{uuid}.slots.{uuid}.widget.{uuid}.data.data.feld") in
|
||||
* Schlüssel des Abschnittsmodells ("sections.N.slots.M.data.feld") übersetzen.
|
||||
*
|
||||
* @param array<string, mixed> $errors
|
||||
* @param array<int|string, mixed> $state
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
public static function sectionErrorsFromForm(array $errors, array $state, string $statePath = 'data.sections'): array
|
||||
{
|
||||
$sectionKeys = array_flip(array_map('strval', array_keys($state)));
|
||||
$translated = [];
|
||||
$pattern = '/^'.preg_quote($statePath, '/').'\.([^.]+)\.slots\.([^.]+)\.widget\.[^.]+\.data\.(.+)$/';
|
||||
|
||||
foreach ($errors as $key => $messages) {
|
||||
if (preg_match($pattern, (string) $key, $match) !== 1 || ! isset($sectionKeys[$match[1]])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$slotKeys = array_flip(array_map('strval', array_keys(is_array($state[$match[1]]['slots'] ?? null) ? $state[$match[1]]['slots'] : [])));
|
||||
if (! isset($slotKeys[$match[2]])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$translated['sections.'.$sectionKeys[$match[1]].'.slots.'.$slotKeys[$match[2]].'.'.$match[3]] = array_values((array) $messages);
|
||||
}
|
||||
|
||||
return $translated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sichtbare Meldung mit Abschnittsnummer, Platz und Widget-Art.
|
||||
*
|
||||
* @param array<string, list<string>> $errors
|
||||
* @param array<int|string, mixed> $state
|
||||
*/
|
||||
public static function notifyErrors(array $errors, array $state): void
|
||||
{
|
||||
$registry = app(WidgetRegistry::class);
|
||||
$sections = array_values($state);
|
||||
$lines = [];
|
||||
|
||||
foreach ($errors as $key => $messages) {
|
||||
$text = implode(' ', (array) $messages);
|
||||
|
||||
if (preg_match('/^sections\.(\d+)(?:\.slots\.(\d+))?/', (string) $key, $match) === 1) {
|
||||
$line = 'Abschnitt '.((int) $match[1] + 1);
|
||||
|
||||
if (isset($match[2])) {
|
||||
$slots = array_values(is_array($sections[(int) $match[1]]['slots'] ?? null) ? $sections[(int) $match[1]]['slots'] : []);
|
||||
$items = $slots[(int) $match[2]]['widget'] ?? [];
|
||||
$type = is_array($items) && $items !== [] ? (array_values($items)[0]['type'] ?? null) : null;
|
||||
$line .= ', Platz '.((int) $match[2] + 1).($registry->has($type) ? ' ('.$registry->get($type)->label().')' : '');
|
||||
}
|
||||
|
||||
$lines[] = $line.': '.$text;
|
||||
} else {
|
||||
$lines[] = $text;
|
||||
}
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Nicht gespeichert')
|
||||
->body(implode("\n", array_unique($lines)))
|
||||
->danger()
|
||||
->persistent()
|
||||
->send();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ordnet Plätze für ein neues Raster: Widgets behalten ihre Reihenfolge, leere Plätze entfallen zuerst.
|
||||
* Es wird nie ein Widget entfernt; passen nicht alle Widgets, bleiben überzählige Plätze bestehen
|
||||
* (die Auswahl solcher Raster ist im Editor gesperrt, das Speichern weist sie ab).
|
||||
*
|
||||
* @param mixed $slots roher Zustand {uuid: {widget: {...}}}
|
||||
* @return array<string, array{widget: array<string, mixed>}>
|
||||
*/
|
||||
public static function arrangeSlots(mixed $slots, string $layout): array
|
||||
{
|
||||
$slots = is_array($slots) ? $slots : [];
|
||||
$count = SectionLayouts::slotCount(SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT);
|
||||
|
||||
if (count($slots) === $count) {
|
||||
return $slots;
|
||||
}
|
||||
|
||||
$filled = array_filter($slots, fn ($slot): bool => self::slotHasWidget($slot));
|
||||
|
||||
if (count($slots) < $count) {
|
||||
$arranged = $slots;
|
||||
} else {
|
||||
// Leere Plätze am Ende zuerst entfernen, dann übrige leere Plätze, bis die Zahl passt.
|
||||
$arranged = $slots;
|
||||
foreach (array_reverse(array_keys($slots)) as $key) {
|
||||
if (count($arranged) <= $count) {
|
||||
break;
|
||||
}
|
||||
if (! self::slotHasWidget($slots[$key])) {
|
||||
unset($arranged[$key]);
|
||||
}
|
||||
}
|
||||
$arranged = count($arranged) > $count ? $filled : $arranged;
|
||||
}
|
||||
|
||||
while (count($arranged) < $count) {
|
||||
$arranged[(string) Str::uuid()] = ['widget' => []];
|
||||
}
|
||||
|
||||
return $arranged;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt die Kopie eines Abschnitts direkt hinter dem Original ein. Kennungen bleiben gleich; beim Speichern
|
||||
* behält das Original seine Kennungen und die Kopie erhält neue.
|
||||
*
|
||||
* @param array<string, mixed> $items
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public static function insertCopyAfter(array $items, string $key, string $newKey): array
|
||||
{
|
||||
if (! array_key_exists($key, $items)) {
|
||||
return $items;
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($items as $itemKey => $item) {
|
||||
$result[$itemKey] = $item;
|
||||
if ((string) $itemKey === $key) {
|
||||
$result[$newKey] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function filledCount(mixed $slots): int
|
||||
{
|
||||
return count(array_filter(is_array($slots) ? $slots : [], fn ($slot): bool => self::slotHasWidget($slot)));
|
||||
}
|
||||
|
||||
private static function slotHasWidget(mixed $slot): bool
|
||||
{
|
||||
return is_array($slot) && is_array($slot['widget'] ?? null) && $slot['widget'] !== [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, HtmlString>
|
||||
*/
|
||||
private static function layoutOptions(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (SectionLayouts::UNITS as $key => $units) {
|
||||
$options[$key] = new HtmlString(
|
||||
'<span class="luf-layout-option">'.SectionLayouts::schematicSvg($key)
|
||||
.'<span class="luf-layout-option-text">'.e(SectionLayouts::short($key)).'</span>'
|
||||
.'<span class="fi-sr-only">'.e(SectionLayouts::LABELS[$key]).'</span></span>'
|
||||
);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spaltenverhältnis der Plätze im Editor; entspricht dem Desktop-Raster der Website.
|
||||
*/
|
||||
private static function editorColumns(mixed $layout): string
|
||||
{
|
||||
$units = SectionLayouts::units(SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT);
|
||||
|
||||
return implode(' ', array_map(fn (int $unit): string => "minmax(0, {$unit}fr)", $units));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $state
|
||||
*/
|
||||
private static function sectionLabel(array $state, ?int $index): string
|
||||
{
|
||||
$layout = SectionLayouts::has($state['layout'] ?? null) ? $state['layout'] : SectionLayouts::DEFAULT;
|
||||
$registry = app(WidgetRegistry::class);
|
||||
$names = [];
|
||||
|
||||
foreach (is_array($state['slots'] ?? null) ? $state['slots'] : [] as $slot) {
|
||||
$items = is_array($slot['widget'] ?? null) ? $slot['widget'] : [];
|
||||
$type = $items !== [] ? (array_values($items)[0]['type'] ?? null) : null;
|
||||
if ($registry->has($type)) {
|
||||
$names[] = $registry->get($type)->label();
|
||||
}
|
||||
}
|
||||
|
||||
$label = 'Abschnitt '.(($index ?? 0) + 1).' · Raster '.SectionLayouts::short($layout)
|
||||
.' · '.SectionStyle::summary(is_array($state['style'] ?? null) ? $state['style'] : []);
|
||||
|
||||
return $names === [] ? $label.' · noch leer' : $label.' · '.implode(', ', $names);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $state
|
||||
*/
|
||||
private static function slotLabel(array $state, ?int $index, mixed $layout): string
|
||||
{
|
||||
$layout = SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT;
|
||||
$units = SectionLayouts::units($layout);
|
||||
$position = $index ?? 0;
|
||||
$slotUnits = $units[$position] ?? null;
|
||||
|
||||
if ($slotUnits === null) {
|
||||
return 'Platz '.($position + 1).' · außerhalb des Rasters: Widget entfernen oder Raster mit mehr Plätzen wählen';
|
||||
}
|
||||
|
||||
$label = 'Platz '.($position + 1).' · '.$slotUnits.' '.($slotUnits === 1 ? 'Einheit' : 'Einheiten');
|
||||
$items = is_array($state['widget'] ?? null) ? $state['widget'] : [];
|
||||
$type = $items !== [] ? (array_values($items)[0]['type'] ?? null) : null;
|
||||
$registry = app(WidgetRegistry::class);
|
||||
|
||||
if ($registry->has($type) && ! $registry->get($type)->supportsUnits($slotUnits)) {
|
||||
$label .= ' · passt nicht: „'.$registry->get($type)->label().'“ ist für '.$registry->get($type)->unitsLabel().' Einheiten vorgesehen';
|
||||
}
|
||||
|
||||
return $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $items
|
||||
* @return array<string, array<string, mixed>>
|
||||
*/
|
||||
private static function keyed(array $items): array
|
||||
{
|
||||
$keyed = [];
|
||||
foreach ($items as $item) {
|
||||
$keyed[(string) Str::uuid()] = $item;
|
||||
}
|
||||
|
||||
return $keyed;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,13 @@
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\Group;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Components\Text;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\View;
|
||||
use Illuminate\Foundation\Vite;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -53,31 +59,99 @@ public static function builder(string $name = 'blocks'): Builder
|
||||
->columnSpanFull();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ein Platz im Abschnittsraster: höchstens ein Widget. Hinzufügen öffnet die Widget-Auswahl und danach den
|
||||
* Bearbeitungsdialog; die Vorschau zeigt das Widget in der tatsächlichen Platzbreite.
|
||||
*/
|
||||
public static function slotBuilder(string $name = 'widget'): Builder
|
||||
{
|
||||
$registry = app(WidgetRegistry::class);
|
||||
|
||||
return Builder::make($name)
|
||||
->label('Widget')
|
||||
->hiddenLabel()
|
||||
->blocks(array_values(array_map(self::block(...), $registry->all())))
|
||||
->blockPreviews()
|
||||
->blockPickerColumns(['default' => 1, 'md' => 2])
|
||||
->blockPickerWidth('3xl')
|
||||
->addActionLabel('Widget einsetzen')
|
||||
->maxItems(1)
|
||||
->blockNumbers(false)
|
||||
->reorderable(false)
|
||||
->cloneable(false)
|
||||
->deletable()
|
||||
->collapsible(false)
|
||||
->addAction(fn ($action) => $action->modalHeading('Widget einrichten')->modalWidth('4xl')->icon('heroicon-o-plus'))
|
||||
->editAction(fn ($action) => $action->modalHeading('Widget bearbeiten')->modalWidth('4xl')->modalSubmitActionLabel('Übernehmen')->tooltip('Widget bearbeiten'))
|
||||
->deleteAction(fn ($action) => $action->tooltip('Widget aus diesem Platz entfernen')->requiresConfirmation()->modalHeading('Widget entfernen?')->modalDescription('Das Widget wird aus dem Entwurf entfernt. Gespeicherte Revisionen bleiben erhalten.')->modalSubmitActionLabel('Entfernen'))
|
||||
->columnSpanFull();
|
||||
}
|
||||
|
||||
public static function block(WidgetType $type): Block
|
||||
{
|
||||
$variants = $type->variants();
|
||||
$icons = $type->optionIcons();
|
||||
$display = [];
|
||||
|
||||
$schema = [Hidden::make('id')];
|
||||
|
||||
$schema[] = count($variants) > 1
|
||||
? ToggleButtons::make('variant')
|
||||
if (count($type->variants()) > 1) {
|
||||
$display[] = ToggleButtons::make('variant')
|
||||
->label('Darstellung')
|
||||
->options($variants)
|
||||
->options($type->variants())
|
||||
->icons($icons['variant'] ?? [])
|
||||
->default($type->defaultVariant())
|
||||
->inline()
|
||||
->required()
|
||||
: Hidden::make('variant')->default($type->defaultVariant());
|
||||
|
||||
if ($type->settings() !== []) {
|
||||
$settings = [];
|
||||
foreach ($type->settings() as $key => $options) {
|
||||
$settings[] = Select::make($key)->label(Str::headline($key))->options($options);
|
||||
}
|
||||
$schema[] = Group::make($settings)->statePath('settings');
|
||||
->live();
|
||||
}
|
||||
|
||||
foreach ($type->editorSchema() as $component) {
|
||||
$schema[] = $component;
|
||||
$settings = [];
|
||||
$labels = $type->settingLabels();
|
||||
foreach ($type->settingOptions() as $key => $options) {
|
||||
// Gemeinsame Höhe (ADR-38): immer als sichtbare Auswahl mit Vorgabe, nie als freie Eingabe.
|
||||
$settings[] = $key === 'height'
|
||||
? ToggleButtons::make('height')
|
||||
->label('Höhe')
|
||||
->helperText('Gestaltungsparameter, keine Begrenzung: Längere Inhalte erhalten immer den nötigen Platz.')
|
||||
->options($options)
|
||||
->icons($icons['height'] ?? [])
|
||||
->default($type->defaultHeight())
|
||||
->inline()
|
||||
->live()
|
||||
: Select::make($key)
|
||||
->label($labels[$key][0] ?? Str::headline($key))
|
||||
->helperText($labels[$key][1] ?? null)
|
||||
->placeholder('Vorgabe der Darstellung')
|
||||
->options($options)
|
||||
->live();
|
||||
}
|
||||
|
||||
if ($settings !== []) {
|
||||
$display[] = Grid::make(['default' => 1, 'md' => 2])->schema($settings)->statePath('settings');
|
||||
}
|
||||
|
||||
$variantField = count($type->variants()) > 1 ? [] : [Hidden::make('variant')->default($type->defaultVariant())];
|
||||
$content = $type->editorSchema();
|
||||
$media = $type->mediaSchema();
|
||||
|
||||
if ($display === [] && $media === []) {
|
||||
$schema = [Hidden::make('id'), ...$variantField, ...$content];
|
||||
} else {
|
||||
$tabs = [Tab::make('Inhalt')->icon('heroicon-o-pencil-square')->schema($content)];
|
||||
if ($media !== []) {
|
||||
$tabs[] = Tab::make('Medien')->icon('heroicon-o-photo')->schema($media);
|
||||
}
|
||||
if ($display !== []) {
|
||||
$tabs[] = Tab::make('Darstellung')->icon('heroicon-o-adjustments-horizontal')->schema([
|
||||
...$display,
|
||||
Text::make('Platzbreiten: '.$type->unitsLabel().' Rastereinheiten. '.$type->narrowBehavior()),
|
||||
]);
|
||||
}
|
||||
|
||||
$schema = [
|
||||
Hidden::make('id'),
|
||||
...$variantField,
|
||||
Tabs::make('Widget')->tabs($tabs)->contained(false),
|
||||
self::livePreview($type),
|
||||
];
|
||||
}
|
||||
|
||||
return WidgetBlock::make($type->key())
|
||||
@@ -205,6 +279,50 @@ public static function notifyErrors(array $errors, array $blocks): void
|
||||
->send();
|
||||
}
|
||||
|
||||
/** Logische Vorschaubreiten in px: tatsächliche Platzbreiten im Standardabschnitt bei 1440 px Fensterbreite. */
|
||||
public const PREVIEW_UNIT_WIDTHS = [1 => 310, 2 => 640, 3 => 960, 4 => 1300];
|
||||
|
||||
public const PREVIEW_PHONE_WIDTH = 390;
|
||||
|
||||
/**
|
||||
* Live-Vorschau im Bearbeitungsdialog: rendert den ungespeicherten Zustand mit derselben Ansicht wie die Website
|
||||
* in einer wählbaren Platzbreite. Die Breitenwahl (_preview_width) wird nicht gespeichert.
|
||||
*/
|
||||
private static function livePreview(WidgetType $type): Section
|
||||
{
|
||||
$default = (string) self::PREVIEW_UNIT_WIDTHS[$type->preferredUnits()];
|
||||
$widths = [(string) self::PREVIEW_PHONE_WIDTH => 'Smartphone'];
|
||||
foreach ($type->supportedUnits() as $units) {
|
||||
$widths[(string) self::PREVIEW_UNIT_WIDTHS[$units]] = $units.' '.($units === 1 ? 'Einheit' : 'Einheiten');
|
||||
}
|
||||
|
||||
return Section::make('Vorschau')
|
||||
->description('Änderungen erscheinen sofort. Unter 860 px zeigt der Einstieg den Sicherheitsumbruch, Bild und Text ab 900 px zwei Spalten.')
|
||||
->collapsible()
|
||||
->compact()
|
||||
->schema([
|
||||
ToggleButtons::make('_preview_width')
|
||||
->hiddenLabel()
|
||||
->options($widths)
|
||||
->default($default)
|
||||
->inline()
|
||||
->live()
|
||||
->dehydrated(false)
|
||||
->extraAttributes(['class' => 'luf-preview-width']),
|
||||
View::make('filament.cms.widget-live-preview')
|
||||
->viewData(fn (Get $get): array => [
|
||||
'html' => self::renderPreview($type->key(), [
|
||||
'variant' => $get('variant'),
|
||||
'settings' => $get('settings'),
|
||||
'data' => $get('data'),
|
||||
'refs' => $get('refs'),
|
||||
]),
|
||||
'stylesheets' => self::previewStylesheets(),
|
||||
'width' => (int) ($get('_preview_width') ?: $default),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blockvorschau: dieselbe Widget-Ansicht wie öffentlich, aus dem ungespeicherten Zustand.
|
||||
*
|
||||
@@ -252,10 +370,18 @@ private static function pickerLabel(WidgetType $type): HtmlString
|
||||
'<span class="luf-widget-pick">'
|
||||
.self::schematicSvg($type)
|
||||
.'<span class="luf-widget-pick-text"><span class="luf-widget-pick-name">'.e($type->label()).'</span>'
|
||||
.'<span class="luf-widget-pick-desc">'.e($type->description()).'</span></span></span>'
|
||||
.'<span class="luf-widget-pick-desc">'.e($type->description()).'</span>'
|
||||
.'<span class="luf-widget-pick-units">'.e(self::unitsHint($type)).'</span></span></span>'
|
||||
);
|
||||
}
|
||||
|
||||
private static function unitsHint(WidgetType $type): string
|
||||
{
|
||||
return $type->supportedUnits() === [1, 2, 3, 4]
|
||||
? 'Passt in jeden Platz (1 bis 4 Einheiten)'
|
||||
: 'Für Plätze mit '.$type->unitsLabel().' Rastereinheiten';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $state
|
||||
*/
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageRevision;
|
||||
use App\Domain\Cms\PageTemplates;
|
||||
use App\Domain\Cms\Sections\SectionRenderer;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\WidgetRenderer;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
@@ -69,10 +69,11 @@ private function render(Page $page, bool $preview, ?PageRevision $revision = nul
|
||||
'revision' => $revision,
|
||||
'preview' => $preview,
|
||||
'template' => app(PageTemplates::class)->viewFor($page),
|
||||
'content' => app(WidgetRenderer::class)->renderAll($revision->blocks, $context),
|
||||
'content' => app(SectionRenderer::class)->renderAll($revision->sections(), $context),
|
||||
'documentTitle' => $revision->seo_title ?: ($revision->contentTitle() ?? config('app.name')),
|
||||
'documentDescription' => $revision->seo_description,
|
||||
'themes' => $page->path === '/' ? Pillar::query()->published()->get() : collect(),
|
||||
'activePath' => $page->path,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\NavigationItem;
|
||||
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;
|
||||
@@ -23,6 +25,9 @@ class AppServiceProvider extends ServiceProvider
|
||||
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', [])),
|
||||
));
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
use App\Domain\Cms\Widgets\Types\HeadingWidget;
|
||||
use App\Domain\Cms\Widgets\Types\HeroWidget;
|
||||
use App\Domain\Cms\Widgets\Types\ImageTextWidget;
|
||||
use App\Domain\Cms\Widgets\Types\MediaCardWidget;
|
||||
use App\Domain\Cms\Widgets\Types\ProgramCardWidget;
|
||||
use App\Domain\Cms\Widgets\Types\ProseWidget;
|
||||
use App\Domain\Cms\Widgets\Types\TopicCardWidget;
|
||||
|
||||
return [
|
||||
|
||||
@@ -24,6 +27,9 @@
|
||||
ImageTextWidget::class,
|
||||
CardsWidget::class,
|
||||
CatalogCardsWidget::class,
|
||||
TopicCardWidget::class,
|
||||
MediaCardWidget::class,
|
||||
ProgramCardWidget::class,
|
||||
CallToActionWidget::class,
|
||||
FaqWidget::class,
|
||||
],
|
||||
@@ -35,4 +41,13 @@
|
||||
'standard' => 'site.templates.standard',
|
||||
],
|
||||
|
||||
/*
|
||||
| Vorbereiteter Warenkorbzugang in der Kopfzeile. Der Warenkorb ist Teil des kommerziellen Anwendungssystems
|
||||
| und noch nicht umgesetzt; solange enabled false ist, erscheint kein Warenkorbsymbol.
|
||||
*/
|
||||
'cart' => [
|
||||
'enabled' => (bool) env('LUF_CART_ENABLED', false),
|
||||
'url' => env('LUF_CART_URL'),
|
||||
],
|
||||
|
||||
];
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Ergänzend und abwärtskompatibel: Abschnitte mit Raster und Gestaltung liegen in einer neuen Spalte.
|
||||
* Die Spalte blocks bleibt bestehen und erhält bei jeder neuen Revision die Widgets in Lesereihenfolge,
|
||||
* damit ein Code-Rollback weiterhin alle Inhalte darstellt. Bestehende Revisionen bleiben unverändert (sections = null).
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('page_revisions', function (Blueprint $table) {
|
||||
$table->json('sections')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('page_revisions', function (Blueprint $table) {
|
||||
$table->dropColumn('sections');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Ergänzend und abwärtskompatibel: eine Ebene Untermenü für die Hauptnavigation.
|
||||
* Bestehende Einträge bleiben oberste Ebene (parent_id = null). Wird ein übergeordneter Eintrag gelöscht,
|
||||
* rücken seine Untereinträge in die oberste Ebene, statt mitgelöscht zu werden.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('navigation_items', function (Blueprint $table) {
|
||||
$table->foreignId('parent_id')->nullable()->constrained('navigation_items')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('navigation_items', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('parent_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
After Width: | Height: | Size: 2.2 MiB |
|
After Width: | Height: | Size: 2.1 MiB |
|
After Width: | Height: | Size: 217 KiB |
|
After Width: | Height: | Size: 132 KiB |
|
After Width: | Height: | Size: 233 KiB |
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Lara & Felix – Designkonzept Bibliothek</title><meta name="robots" content="noindex,nofollow"><link rel="stylesheet" href="site.css"></head><body class="app-bg"><div class="apphead"><header class="top"><div class="nav wrap"><a class="brand" href="index.html" aria-label="Lara und Felix, Startseite">Lara & Felix<small>Stark im Alltag</small></a><nav class="links" aria-label="Hauptnavigation"><a href="index.html">Start</a><a href="bibliothek.html">Filme & Materialien</a><a href="player.html">Methodik</a><a class="btn outline" href="bibliothek.html">Anmelden</a><a class="btn green" href="bibliothek.html">Mitgliederbereich</a></nav></div></header></div><div class="appwrap"><aside class="side"><a href="index.html">⌂ Übersicht</a><a class="active" href="bibliothek.html">▦ Meine Bibliothek</a><a href="player.html">▷ Filme</a><a href="bibliothek.html">▤ Materialien</a><a href="bibliothek.html">♧ Berechtigungen</a></aside><main class="main"><div class="dash-head"><div><span class="flag">Mitgliederbereich · Layoutentwurf</span><h1>Meine Bibliothek</h1><p>Alles für die nächste Kursstunde an einem Ort.</p></div><div class="search" aria-label="Suche (nur Layoutkonzept)">⌕ Inhalte suchen …</div></div><div class="filters"><span class="filter on">Alle Inhalte</span><span class="filter">Filme</span><span class="filter">Übungen</span><span class="filter">Materialien</span><span class="filter">Programme</span></div><div class="library-grid"><article class="media-card"><a href="player.html"><div class="photo" style="background-image:url('assets/titel_original.webp')"><span class="type">Film</span></div></a><div class="body"><div class="small">DEMO · kein echter Artikel</div><h3>Film zur Erprobung</h3><p>Ein Film kann mit Übungen und Materialien verbunden sein.</p><span class="status">○ Zugang aus Berechtigung</span></div></article><article class="media-card"><a href="player.html"><div class="photo" style="background-image:url('assets/denkpause_original.webp')"><span class="type">Übung</span></div></a><div class="body"><div class="small">DEMO · kein echter Artikel</div><h3>Nachdenken und sprechen</h3><p>Das Material kann in mehreren Kompositionen genutzt werden.</p><span class="status">○ Zugang aus Berechtigung</span></div></article><article class="media-card"><a href="player.html"><div class="photo" style="background-image:url('assets/outro_original.webp')"><span class="type">Dokument</span></div></a><div class="body"><div class="small">DEMO · kein echter Artikel</div><h3>Begleitmaterial</h3><p>Trainerunterlagen erscheinen als eigenständige Medientypen.</p><span class="status">○ Zugang aus Berechtigung</span></div></article></div><div class="notice"><strong>Hinweis zur Lizenzansicht</strong><span>Ein Lizenzartikel soll einmal sichtbar sein, auch wenn mehrere Erwerbsquellen vorhanden sind. Einzelne Rechte bleiben getrennt prüfbar.</span></div></main></div></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Lara & Felix – Designkonzept Startseite</title><meta name="robots" content="noindex,nofollow"><link rel="stylesheet" href="site.css"></head><body><header class="top"><div class="nav wrap"><a class="brand" href="index.html" aria-label="Lara und Felix, Startseite">Lara & Felix<small>Stark im Alltag</small></a><nav class="links" aria-label="Hauptnavigation"><a href="index.html">Start</a><a href="bibliothek.html">Filme & Materialien</a><a href="player.html">Methodik</a><a class="btn outline" href="bibliothek.html">Anmelden</a><a class="btn green" href="bibliothek.html">Mitgliederbereich</a></nav></div></header><main><section class="hero"><div class="hero-picture" role="img" aria-label="Lara und Felix mit Serienlogo im sonnigen Park"></div><div class="hero-text wrap"><span class="flag">Für Trainer und pädagogische Fachkräfte</span><h1>Geschichten, die Kinder stärken.</h1><p>Filme und praxisnahe Materialien für Gewaltprävention, Selbstbehauptung und gemeinsame Gespräche.</p><div class="hero-actions"><a class="btn yellow" href="bibliothek.html">Materialien entdecken →</a><a class="btn outline" href="player.html">Unsere Methode</a></div><p class="hero-note">Gestaltungsvorschau – funktionale Angebote und Aussagen vor Veröffentlichung prüfen.</p></div></section><section class="section"><div class="wrap"><div class="intro-head"><div><span class="flag">Unser Ansatz</span><h2>Aus dem Alltag. Für den Alltag.</h2></div><p>Die Filme schaffen Gesprächsanlässe. Trainer gestalten daraus Übungen, Reflexion und gemeinsames Lernen.</p></div><div class="features"><div class="feature"><div class="sym">▣</div><h3>Geschichten erleben</h3><p>Anschauliche Situationen aus einer vertrauten Lebenswelt als Einstieg in den Kurs.</p></div><div class="feature"><div class="sym">?</div><h3>Gemeinsam nachdenken</h3><p>Bewusste Denkpausen geben Raum für Fragen, Gespräche und eigene Ideen.</p></div><div class="feature"><div class="sym">✓</div><h3>Handeln üben</h3><p>Begleitmaterial und Aufgaben helfen, das Gespräch praktisch fortzuführen.</p></div></div></div></section><section class="section offwhite"><div class="wrap"><div class="intro-head"><div><span class="flag">Einblicke</span><h2>Filme und Materialien</h2></div><p>Beispielhafte Darstellung möglicher Medientypen; keine realen Katalogangebote.</p></div><div class="card-grid"><article class="media-card"><div class="photo" style="background-image:url('assets/titel_original.webp')"><span class="type">Film · Beispiel</span></div><div class="body"><h3>Alltagssituation</h3><p>Videogestützte Einstiege in das gemeinsame Training.</p></div></article><article class="media-card"><div class="photo" style="background-image:url('assets/denkpause_original.webp')"><span class="type">Didaktik · Beispiel</span></div><div class="body"><h3>Denkpause</h3><p>Ein bewusstes Innehalten für Fragen und Austausch.</p></div></article><article class="media-card"><div class="photo" style="background-image:url('assets/outro_original.webp')"><span class="type">Material · Beispiel</span></div><div class="body"><h3>Trainermaterial</h3><p>Praktische Materialien können Filme ergänzen und verbinden.</p></div></article></div></div></section></main><footer class="foot"><div class="wrap"><div><strong>Lara & Felix</strong><small>Stark im Alltag · Designkonzept, keine Live-Webseite</small></div><p>Dieses UI-Kit verwendet konzeptionelle Texte und keine tatsächlichen Preise, Angebote oder Kundenangaben.</p></div></footer></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Lara & Felix – Designkonzept Kursplayer</title><meta name="robots" content="noindex,nofollow"><link rel="stylesheet" href="site.css"></head><body><header class="top"><div class="nav wrap"><a class="brand" href="index.html" aria-label="Lara und Felix, Startseite">Lara & Felix<small>Stark im Alltag</small></a><nav class="links" aria-label="Hauptnavigation"><a href="index.html">Start</a><a href="bibliothek.html">Filme & Materialien</a><a href="player.html">Methodik</a><a class="btn outline" href="bibliothek.html">Anmelden</a><a class="btn green" href="bibliothek.html">Mitgliederbereich</a></nav></div></header><main class="player-wrap"><div class="crumb">Meine Bibliothek / Film / Kursplayer</div><h1>Denkpause: Was würdet ihr tun?</h1><p class="sub">Gestaltungsvorschau · der Player ist nicht mit echten Medien oder Rechten verbunden.</p><div class="player" role="img" aria-label="Denkpause-Grafik mit Lara und Felix"><div class="still"></div><div class="player-controls"><span>❚❚</span><span>0:46</span><div class="progress"></div><span>2:00</span><span>⛶</span></div></div><div class="under-player"><section class="panel"><span class="flag">Didaktischer Moment</span><h3>Gespräch in der Gruppe</h3><p>Die Denkpause bietet einen natürlichen Moment, um mit den Kindern über Handlungsoptionen zu sprechen. Die tatsächliche Fortsetzung wird später im funktionalen Player eingebunden.</p><a class="btn green" href="bibliothek.html">Zur Bibliothek</a></section><section class="panel"><span class="flag">Trainermaterial</span><h3>Begleitende Unterlagen</h3><p>Trainerhinweise, Übungen und Arbeitsblätter werden an dieser Stelle aus der wirklichen Artikelkomposition geladen.</p><span class="pill">Layoutentwurf</span></section></div></main><footer class="foot"><div class="wrap"><div><strong>Lara & Felix</strong><small>Stark im Alltag · Designkonzept, keine Live-Webseite</small></div><p>Dieses UI-Kit verwendet konzeptionelle Texte und keine tatsächlichen Preise, Angebote oder Kundenangaben.</p></div></footer></body></html>
|
||||
|
After Width: | Height: | Size: 363 KiB |
|
After Width: | Height: | Size: 440 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 663 KiB |
|
After Width: | Height: | Size: 928 KiB |
|
After Width: | Height: | Size: 215 KiB |
@@ -0,0 +1,10 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@500;600;700;800;900&family=Nunito+Sans:wght@400;500;600;700;800&display=swap');
|
||||
:root {--navy:#032551;--navy2:#01244c;--green:#5B8625;--yellow:#FCD10A;--cream:#F7F6F2;--paper:#FBFBF7;--muted:#5D6A78;--line:#E0E9E0;--shadow:0 18px 45px rgba(3,37,81,.07)}
|
||||
*,*:before,*:after{box-sizing:border-box}body{margin:0;background:#FBFBF7;color:#162b45;font:16px/1.55 'Nunito Sans','Segoe UI',sans-serif}button,a{font:inherit}a{color:inherit;text-decoration:none}img{max-width:100%}h1,h2,h3{font-family:'Nunito','Trebuchet MS',sans-serif;line-height:1.15;letter-spacing:-.035em;color:var(--navy)}h1{font-size:clamp(34px,4vw,60px)}h2{font-size:clamp(25px,2.5vw,36px)}p{margin:0 0 1rem}.wrap{width:min(1180px,calc(100% - 56px));margin:auto}
|
||||
.top{background:white;border-bottom:1px solid #eef1eb;position:relative;z-index:10}.nav{height:82px;display:flex;align-items:center;justify-content:space-between;gap:28px}.brand{line-height:.92;color:var(--navy);font-family:'Nunito',sans-serif;font-weight:900;letter-spacing:-.05em;font-size:25px;transform:rotate(-1deg)}.brand>small{display:block;width:max-content;background:var(--green);font-size:11px;letter-spacing:0;color:white;padding:5px 11px;border-radius:20px;margin-top:5px}.brand:after{content:'';display:block;width:82%;height:5px;border-radius:90%;background:var(--yellow);transform:rotate(-2deg);margin-top:-25px;position:relative;top:-1px;z-index:-1}.links{display:flex;gap:28px;align-items:center;font-size:14px;font-weight:800;color:#19334c}.links a:focus-visible,.btn:focus-visible{outline:3px solid #1676ac;outline-offset:3px}.links a:not(.btn):hover{color:var(--green)}.btn{display:inline-flex;gap:8px;justify-content:center;align-items:center;border-radius:999px;padding:12px 21px;font-size:14px;font-weight:900;white-space:nowrap;border:1px solid transparent;transition:transform .18s,box-shadow .18s}.btn:hover{transform:translateY(-2px);box-shadow:0 8px 22px rgba(3,37,81,.15)}.btn.primary{background:var(--navy);color:white}.btn.green{background:var(--green);color:white}.btn.outline{background:white;color:var(--navy);border-color:#c8d5d6}.btn.yellow{background:var(--yellow);color:var(--navy)}
|
||||
.flag{font-size:11px;letter-spacing:.11em;text-transform:uppercase;font-weight:900;color:var(--green);display:inline-flex;align-items:center;gap:9px}.flag:before{content:'';width:26px;height:4px;background:var(--yellow);border-radius:4px}.hero{background:#f0f2e8;overflow:hidden}.hero-picture{position:relative;min-height:560px;background-image:url('assets/outro_original.webp');background-position:center;background-size:cover}.hero-text{position:absolute;left:52%;top:24%;max-width:520px;padding:10px}.hero-text h1{font-size:clamp(33px,4vw,61px);margin:10px 0 22px;letter-spacing:-.045em}.hero-text p{font-size:17px;max-width:420px}.hero-actions{display:flex;gap:12px;flex-wrap:wrap;margin-top:24px}.hero-note{font-size:12px;color:var(--muted);margin-top:20px}.section{padding:80px 0}.intro-head{display:flex;align-items:flex-end;justify-content:space-between;gap:30px;margin-bottom:29px}.intro-head h2{margin:8px 0 0}.intro-head>p{max-width:420px;color:var(--muted)}.features{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}.feature{background:white;border:1px solid var(--line);border-radius:22px;padding:28px;min-height:178px;box-shadow:var(--shadow)}.feature .sym{height:46px;width:46px;background:#e6f0dc;border-radius:14px;display:grid;place-items:center;font-size:23px}.feature h3{font-size:21px;margin:18px 0 7px}.feature p{color:var(--muted);font-size:14px}.offwhite{background:#F2F5ED}.card-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:18px}.media-card{background:white;border-radius:20px;overflow:hidden;box-shadow:var(--shadow);border:1px solid var(--line)}.media-card .photo{height:190px;background-size:cover;background-position:center;position:relative}.photo .type{position:absolute;bottom:13px;left:13px;background:#fff;border-radius:20px;padding:5px 10px;color:var(--navy);font-size:12px;font-weight:900}.media-card .body{padding:20px}.media-card h3{margin:0 0 10px;font-size:20px}.media-card p{font-size:14px;color:var(--muted);margin:0}.pill{display:inline-block;background:#eaf1e3;color:#365e1d;padding:6px 11px;border-radius:25px;font-size:12px;font-weight:900}.foot{background:var(--navy);color:#d3e2ed;padding:45px 0}.foot .wrap{display:flex;justify-content:space-between;gap:25px;align-items:center}.foot p{font-size:13px;margin:0}.foot strong{font-family:Nunito,sans-serif;color:white;font-size:21px}.foot small{display:block;color:#c0d7e3}
|
||||
/* library */.app-bg{background:#f4f7f4;min-height:100vh}.apphead{background:white;border-bottom:1px solid #e4e8e6}.appwrap{max-width:1260px;margin:auto;display:grid;grid-template-columns:210px 1fr;min-height:calc(100vh - 82px)}.side{padding:36px 18px 30px;border-right:1px solid #e1e9e8}.side a{display:block;margin:7px 0;padding:11px 14px;border-radius:12px;font-weight:800;font-size:14px}.side a.active{background:#e4efe4;color:var(--green)}.main{padding:37px 40px 70px}.dash-head{display:flex;align-items:flex-end;justify-content:space-between;gap:20px}.dash-head h1{font-size:39px;margin:8px 0}.dash-head p{color:var(--muted)}.search{background:white;border:1px solid #d7e2e0;border-radius:100px;min-width:280px;padding:12px 18px;color:#8995a0;font-size:14px}.filters{display:flex;gap:8px;margin:26px 0 24px;flex-wrap:wrap}.filter{background:white;border:1px solid #dde7e3;border-radius:20px;padding:8px 15px;font-weight:800;font-size:12px}.filter.on{background:var(--navy);color:white}.library-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:18px}.library-grid .photo{height:158px}.media-card .small{color:#55707d;font-weight:700;font-size:12px}.media-card .status{margin-top:15px;display:inline-block;color:#376f1c;background:#edf5e8;padding:6px 10px;border-radius:20px;font-size:12px;font-weight:900}.notice{margin-top:30px;padding:19px 23px;border-radius:18px;background:#e8f0de;display:flex;gap:15px;align-items:center;font-size:14px;color:#35532a}.notice strong{color:#254316}
|
||||
/* player */.player-wrap{max-width:1060px;margin:50px auto 100px;padding:0 28px}.crumb{font-size:13px;font-weight:800;color:#6b7d86}.player-wrap h1{font-size:38px;margin:16px 0 10px}.player-wrap .sub{color:var(--muted);margin-bottom:25px}.player{position:relative;aspect-ratio:16/9;background:var(--navy);border-radius:24px;overflow:hidden;box-shadow:0 20px 56px rgba(3,37,81,.15)}.player .still{position:absolute;inset:0;background:url('assets/denkpause_original.webp') center/cover}.player:after{content:'';position:absolute;inset:65% 0 0;background:linear-gradient(transparent,rgba(3,37,81,.45));pointer-events:none}.player-controls{position:absolute;bottom:18px;left:25px;right:25px;display:flex;align-items:center;gap:15px;z-index:1;color:white;font-weight:800}.progress{height:6px;background:#ffffff78;border-radius:6px;flex:1}.progress:before{content:'';display:block;width:41%;height:100%;background:var(--yellow);border-radius:6px}.under-player{display:grid;grid-template-columns:1.5fr 1fr;gap:18px;margin-top:22px}.panel{padding:28px;background:white;border:1px solid var(--line);border-radius:20px}.panel h3{margin:0 0 12px;font-size:20px}.panel p{font-size:14px;color:var(--muted)}
|
||||
@media (max-width:980px){.nav{height:74px}.links a:not(.btn){display:none}.hero-picture{min-height:500px;background-position:40% center}.hero-text{left:52%;top:19%;max-width:400px}.hero-text h1{font-size:39px}.features,.card-grid,.library-grid{grid-template-columns:repeat(2,1fr)}.appwrap{grid-template-columns:170px 1fr}.main{padding:24px}.under-player{grid-template-columns:1fr}}
|
||||
@media (max-width:680px){.wrap{width:min(100% - 32px,560px)}.brand{font-size:22px}.brand>small{font-size:10px}.links{gap:7px}.links a.btn:first-of-type{display:none}.links a.btn{padding:9px 13px;font-size:12px}.hero-picture{min-height:0;aspect-ratio:1.4/1;background-size:cover;background-position:17% center}.hero-text{position:static;background:#fbfbf7;padding:27px 18px 40px;max-width:none}.hero-text h1{font-size:36px}.hero-text p{font-size:15px}.hero-actions{gap:9px}.hero-note{margin-top:15px}.section{padding:48px 0}.intro-head{display:block}.features,.card-grid,.library-grid{grid-template-columns:1fr}.feature{min-height:auto}.media-card .photo{height:210px}.foot .wrap{display:block}.foot p{margin-top:10px}.appwrap{display:block}.side{display:flex;overflow:auto;padding:10px 16px;gap:5px;border-right:0;border-bottom:1px solid #e1e9e8}.side a{white-space:nowrap}.main{padding:30px 16px}.dash-head{display:block}.dash-head h1{font-size:32px}.search{width:100%;margin-top:18px}.library-grid .photo{height:190px}.player-wrap{margin:25px auto 70px;padding:0 16px}.player-wrap h1{font-size:28px}.player{border-radius:14px}.player-controls{bottom:10px;left:10px;right:10px;font-size:10px;gap:5px}.panel{padding:20px}}
|
||||
@media(prefers-reduced-motion: reduce){*,*:before,*:after{scroll-behavior:auto!important;transition:none!important;animation:none!important}}
|
||||
@@ -0,0 +1,165 @@
|
||||
# Abschlussbericht: MVP-Beauftragung Mitgliederbibliothek
|
||||
|
||||
**Stand:** 16.11.2026
|
||||
**Branch:** `develop`, Commit `30833f6`
|
||||
**Testinstanz:** `luf-test` auf `llm-node`, Port 3011, Image `luf-app-test:30833f62a1e1` und `luf-web-test:30833f62a1e1`
|
||||
**Grundlage:** `docs/analysen/umsetzungsplan-mitgliederbibliothek.md`, Verträge G1–G9, Ergänzung E-W12, die beiden Zusatzaufträge UX/UI des Mitgliederbereichs und fachliche Inhaltsverwaltung
|
||||
|
||||
Dieser Bericht schließt die Beauftragung ab. Er ist keine kommerzielle Freigabe. Der Plan macht Tor B zur Abnahme der Pakete 1 bis 8. Dieser Lauf ist nicht ausgeführt.
|
||||
|
||||
`docs/betrieb/MVP-Stand.md` beschreibt eine frühere Scheibe und ist durch diesen Bericht überholt.
|
||||
|
||||
## Auftrag
|
||||
|
||||
Umgesetzt werden sollten die Pakete 1 bis 9 des Umsetzungsplans, die Verträge G1 bis G9 und die didaktischen Metadaten E-W12. Gearbeitet wurde auf `develop`. Ein Push dorthin deployt die Testinstanz. Produktion und `main` wurden nicht angefasst.
|
||||
|
||||
Zwei Zusatzaufträge gehören dazu:
|
||||
|
||||
1. **Mitgliederbereich.** Der Kursraum für erwachsene Trainer folgt der vorgesehenen Gliederung und den vorhandenen Gestaltungsprinzipien. Nicht freigegebene Markenwerte bleiben austauschbare Tokens. Die Fläche darf nicht wie ein umbenanntes Filament aussehen. Geprüft wird in den Breiten 390, 768 und 1440 Pixel.
|
||||
2. **Fachliche Inhaltsverwaltung.** Eine Person ohne technischen Hintergrund legt in der vorhandenen Verwaltung Medien und Dokumente an, beschreibt und ordnet sie, führt Fassungen, baut Module und Programme mit Lernziel, Zeit, Material und geordneten Bestandteilen, sucht vorhandene Inhalte einschließlich einer konkreten Fassung, ändert Rolle, Reihenfolge und Verschachtelung, sieht die Verwendung, unterscheidet Entwurf, technische Bereitschaft, Anzeigefreigabe und historische Fassungen, prüft die Struktur und gibt sie frei, hängt Lizenzartikel und Angebote an und nutzt die Abdeckungsprüfung. Die Beschriftung ist fachlich. Der Nachweis läuft durch die Oberfläche, nicht durch Seeder oder SQL.
|
||||
|
||||
Bewusst außerhalb bleiben Denkpause, Ablaufsteuerung, Präsentationsmodus, Fortschritt, zweites Gerät, Community, echter Zahlungsdienst, Organisationslizenzen, konkrete Preise, die Marketingstrecke M1–M3, ein Neubau der öffentlichen Website und der Editor-Prototyp W-P als zweites CMS. W-P bleibt der dokumentierte Wegwerfstand auf `feature/w-p-editor-prototype` (`docs/analysen/wp-editor-prototyp-2026-03-15.md`).
|
||||
|
||||
## Ergebnis in einem Satz
|
||||
|
||||
Die Pakete 1 bis 8, E-W12 und beide Zusatzaufträge sind im Code, in der Suite und auf der Testinstanz vorhanden und am Trainingsprogramm **Programm Abstand** durch die Oberfläche benutzbar. Die geplante Abschlussprüfung Tor B und drei eng umrissene Paketpunkte sind offen.
|
||||
|
||||
## Prüfstand
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| Suite vor dem letzten Push | 76 Tests, 406 Zusicherungen, grün |
|
||||
| Gate | `scripts/ci-test.sh`: Pint und `php artisan test` in einem Wegwerf-Container |
|
||||
| Instanz | `http://192.168.2.144:3011/up` antwortet 200 |
|
||||
| Medien | NFS `/srv/luf/test/media`. Der Web-Prozess schreibt die Ableitungen nicht. Die Queue schreibt Vorschaubilder und HLS nach `derived/`. |
|
||||
| Demokatalog | Der Deploy legt ihn nicht mehr an. Der vorherige grüne Deploy hatte ihn einmal neu erzeugt. Diese Zeilen sind auf der Testinstanz wieder entfernt. |
|
||||
|
||||
Der erste Push der Medienableitung (`c997eb5`) ist am Image-Bau gescheitert, weil die Lockdatei mit einer neueren npm-Version geschrieben war als im Image. `295f784` gleicht die Lockdatei mit npm 10.9.9 ab. Danach sind die Images durchgelaufen.
|
||||
|
||||
## Pakete
|
||||
|
||||
| Paket | Stand | Was vorliegt |
|
||||
|---|---|---|
|
||||
| 0 Befund | erledigt, historisch | `docs/analysen/befund-paket-0-testinstanz-2026-03-15.md`. Zum Zeitpunkt des Befunds keine doppelte aktive Angebotsfassung. Der heutige Testbestand ist der Abstand-Graph nach der freigegebenen Löschung der alten Testzeilen. Produktion wurde nicht gelesen. |
|
||||
| 1 Angebotsfassung | umgesetzt | Eine Aktivierung beendet die bisher aktive Fassung desselben Angebots. Registrierung und Kauf lesen eine aktive Fassung. Neue Bestellzeilen speichern die Bezeichnung. Parallelität ist durch einen Test abgedeckt. |
|
||||
| 2 Inhaltsart | umgesetzt | `CompositionKind` bleibt `kurs`, `uebung`, `kombination`. Die Inhaltsart ist eine eigene Achse mit den Werten Programm, Modul, Merkblatt und Traineranleitung. Die Erklärung des Enums enthält weiterhin „Ein Kurs ist keine Übung“. |
|
||||
| 3 Bibliothek | umgesetzt | G1 liest eine ausdrücklich angegebene Fassung unabhängig von der Anzeigefreigabe. G2 gibt Fassungen zur Anzeige frei und nimmt sie zurück. Die Bibliothek zeigt Programme, Module und Material. Teilrechte bleiben sichtbar, nicht getragene Blätter haben keine Datei. `DecideAccess` entscheidet je Abruf. Zwei Grants werden nicht vereinigt. |
|
||||
| 4 Stammdaten | umgesetzt | Anzeigetitel und Kurzbeschreibung liegen an der Identität, mit Protokoll. Sie erzeugen keine neue Lehrfassung. Die Bibliothek liest sie, sobald sie gefüllt sind. |
|
||||
| 5 Dimensionen und Filter | umgesetzt | Dimensionen sind pflegbar. Die fünf Säulen sind Startwerte und bleiben als Spalten erhalten. Direkte Zuordnung an Kompositionen ist von abgeleiteten Themen getrennt. Die Bibliothek sucht und filtert. Eine Säule vergibt keine Berechtigung. |
|
||||
| 6 Vorschaubilder | umgesetzt, mit einer Lücke | Bild an Medium und Zusammenstellung, Alternativtext, Platzhalter, keine öffentliche Route, keine neue Inhaltsfassung. Ein Film liefert ein Bild aus dem ersten Frame. Eine wählbare Zeitposition fehlt. |
|
||||
| 7 Vorschau und Abdeckung | umgesetzt | Die Maske zeigt die Verwendung. Die Redaktion sieht denselben Baum wie das Mitglied. Eine Aktivierung nennt fehlende Blätter und nimmt ein ungedecktes Programm nicht still auf. |
|
||||
| 8 Medienausgabe | umgesetzt, in der vereinbarten Ehrlichkeit | Drei HLS-Stufen, signierte Playlists und Segmente, Nachweis je Ausgabe mit Kopiennummer, Prüfsumme und Kennzeichnung. Ohne Streamrecht keine Variante, ohne Laderecht keine Quelldatei. Eine schon gespeicherte Datei bleibt lesbar, bis eine Ableitung existiert. Texte im Leser tragen die sichtbare Lizenzzeile. Dateibytes von Film und PDF werden nicht gestempelt. |
|
||||
| 9 Tor A / Tor B | nicht bestanden | Die lokale Suite und ein Durchlauf des Abstand-Programms ersetzen den verlangten HTTP-Lauf gegen die Testinstanz nicht. Eine wiederholbare Instanz-Suite (G9) ist nicht angelegt. |
|
||||
|
||||
## Verträge
|
||||
|
||||
| Vertrag | Stand |
|
||||
|---|---|
|
||||
| G1 Strukturleser | eine Klasse neben `ContentResolver`, ohne Person und ohne Berechtigung |
|
||||
| G2 Anzeigefreigabe | je Kompositionsfassung, mit Bearbeiter und Zeitpunkt, unabhängig von `bereit` |
|
||||
| G3 Inhaltsart | konfigurierbare Werte, setzen ändert `kind` und `output_class` nicht |
|
||||
| G4 Anzeigefelder | ein Titel und eine Kurzbeschreibung für die Bibliothek, mit Protokoll |
|
||||
| G5 Dimensionen | stabile Kennungen, Säulen behalten ihre Identität, direkt und abgeleitet bleiben unterscheidbar |
|
||||
| G6 Bildableitung | ein Queue-Auftrag, geschützte Ablage unter `vorschau/` |
|
||||
| G7 Abdeckungsbefund | lesbar vor der Aktivierung |
|
||||
| G8 aktive Angebotsfassung | eine aktive Fassung, bei Alt-Dubletten die höchste Nummer |
|
||||
| G9 Instanz-Suite | nicht gebaut |
|
||||
| E-W12 | Lernziel, Zeitbedarf und Materialbedarf an der Kompositionsfassung; eine Änderung erzeugt eine neue Fassung |
|
||||
|
||||
## Zusatz 1: Mitgliederbereich
|
||||
|
||||
Der Kursraum ist eine eigene Oberfläche, nicht die Verwaltungsoptik. Überschriften, Suche, Säulenfilter, Verfügbarkeit und die Karten sprechen von Programmen, Modulen und Material. Die untere Navigation führt zu Bibliothek, Programmen, Modulen, Material und Lizenzen.
|
||||
|
||||
Die Gestaltung wurde auf der Testinstanz in 390, 768 und 1440 Pixel geprüft. Nach dem Player-Fix wurde die Seite von Programm Abstand erneut bei 390 Pixel geprüft: kein horizontaler Überlauf, der Film lädt. Markenwerte, die nicht freigegeben sind, wurden nicht erfunden. Die Programmkarte zeigt den Platzhalter, weil für dieses Programm kein eigenes Vorschaubild hochgeladen wurde. Das abgeleitete Bild von „Lara im Park“ liegt am Medium.
|
||||
|
||||
## Zusatz 2: Fachliche Inhaltsverwaltung
|
||||
|
||||
Die Redaktion arbeitet weiter unter `/verwaltung`. Die Navigation heißt Medien, Fachliche Kombinationen, Module, Programme, Fachliche Säulen, Lizenzartikel, Pakete, Rechteprofile und Angebote. Die Programmliste erklärt: „Ein Programm aus Modulen und weiteren Inhalten.“ Die gespeicherte Art bleibt Kurs, Übung oder Kombination. Die Maske nennt das Feld Zusammenstellung.
|
||||
|
||||
Auf der Testinstanz wurde der folgende Weg durch die Oberfläche angelegt und danach erneut geöffnet:
|
||||
|
||||
| Schritt | Ergebnis |
|
||||
|---|---|
|
||||
| Trainerunterlage Abstand | Text, Fassung 1: „Im Kurs zuerst den Abstand ansprechen, dann das Blatt austeilen.“ |
|
||||
| Modul Abstand | Unterlage plus Film „Lara im Park“, Fassung 1, Lernziel, 15 Minuten, zur Anzeige freigegeben |
|
||||
| Modul Hilfe | dieselbe Unterlage, Fassung 1, Lernziel, 10 Minuten, freigegeben |
|
||||
| Programm Abstand | beide Module in dieser Reihenfolge, Lernziel, 25 Minuten, Gliederung sichtbar, freigegeben |
|
||||
| Lizenzartikel | `abstand-trainer`, Stand 1, Wurzel ist die Programmfassung |
|
||||
| Rechteprofil | „Abstand ansehen“: Film streamen, Dokument ansehen, Text ansehen |
|
||||
| Angebot | Testangebot Abstand, auf Abruf, Abdeckung gegen die Programmfassung |
|
||||
| Trainer | Abruf in die Bibliothek, Programm nutzbar |
|
||||
|
||||
Ein neues Vorschaubild an einer Zusammenstellung geht über die Queue nach `derived/vorschau/` und erzeugt keine neue Fassung.
|
||||
|
||||
## Was auf der Testinstanz geprüft wurde
|
||||
|
||||
Angemeldet als Prüftrainer:
|
||||
|
||||
- Die Bibliothek zeigt nur Programm Abstand, Status Nutzbar.
|
||||
- Die Programmseite zeigt Lernziel, beide Module, die Unterlage und den Film.
|
||||
- Der Film spielt über hls.js. Bild 854×480, Wiedergabe bereit. Die Master-Playlist verweist auf die Stufen 480, 720 und 1080. Die Signatur gilt für diese Ausgabe.
|
||||
- Die Unterlage zeigt den Text, die Zeile „Lizenziert für …“ mit Lizenzkopie und die Kennzeichnung „ehrenamtlich“.
|
||||
|
||||
Angemeldet in der Verwaltung:
|
||||
|
||||
- Die Programmliste enthält nur Programm Abstand und den fachlichen Erklärungssatz.
|
||||
|
||||
Die Ableitung von „Lara im Park“ wurde nach dem Deploy in die Queue gegeben. Vorschaubild und die vier Playlist-Zeilen (480, 720, 1080, Master) liegen vor. Der Auftrag ist ohne Fehlereintrag durchgelaufen. Die Quelldatei bleibt unter `derived/` liegen.
|
||||
|
||||
## Offen gegenüber dem Plan
|
||||
|
||||
Tor B ist nicht bestanden. Der Plan verlangt auf der Testinstanz, vollständig und nicht nur soweit die Suite es an Wegwerfdaten zeigt:
|
||||
|
||||
- zwei freigegebene Programme, gemeinsamer Film, gemeinsames PDF, unterschiedliche Rollen
|
||||
- eine nur bereite Programmfassung mit demselben Film bleibt unsichtbar
|
||||
- eine Person mit nur einem Modul, eine mit allen Teilen über getrennte Artikel, eine ohne Grant
|
||||
- Stream nur für die berechtigte Person; Laden des Films scheitert ohne dieses Recht
|
||||
- Ansehen und Laden eines PDF sind getrennt
|
||||
- das teilweise Programm ist gekennzeichnet; das vollständige Programm erzeugt keinen zusätzlichen Erwerb
|
||||
- die Materialliste zeigt das gemeinsame PDF einmal
|
||||
- Umbenennung ohne neue Fassung, die gespeicherte Bestellbezeichnung bleibt
|
||||
- Filter und direkte Themen an Modul und Programm
|
||||
- Thumbnail nicht über die öffentliche Route
|
||||
- Abdeckungsverweigerung und dieselbe Struktur in der Vorschau
|
||||
- genau eine aktive Angebotsfassung, auch im Parallelfall
|
||||
|
||||
Diese Fälle sind in der lokalen Suite einzeln vorhanden. Auf der Instanz liegt ein Programm, eine Textunterlage und ein Film. Eine PDF-Datei im Testmedienbestand fehlt. Eine wiederholbare HTTP-Suite gegen `luf-test` fehlt.
|
||||
|
||||
Weitere Lücken im Pakettext:
|
||||
|
||||
- Vorschaubild eines Films: erstes Bild, keine wählbare Zeitposition und keine Vorschau genau dieser Position.
|
||||
- Originale liegen nicht getrennt unter `originals/`. Neue und vorhandene Dateien bleiben in `derived/`. Die Kennzeichnung hängt daran nicht.
|
||||
|
||||
## Zurückgestellt
|
||||
|
||||
Automatische Denkpause, Ablaufsteuerung, Präsentationsmodus, Fortschritt, zweites Gerät. `decision_seconds` bleibt gespeichert und steuert die Bibliothek nicht.
|
||||
|
||||
Organisationslizenzen, Community, echter Zahlungsdienst, kundeneigene Paketkonfiguratoren, konkrete Preise und Tarife. Der Testkaufpreis aus dem früheren Demokatalog ist keine Preisentscheidung; dieser Katalog ist auf der Testinstanz entfernt.
|
||||
|
||||
Designsystem, öffentliche Objektseiten und der Neubau des CMS. Die vorhandenen öffentlichen Seiten und die veröffentlichten Säulen unter `/themen` bleiben. W-P wird nicht in die Verwaltung übernommen.
|
||||
|
||||
## Zugang zur Prüfung
|
||||
|
||||
Nur die Testinstanz, Adresse `http://192.168.2.144:3011`.
|
||||
|
||||
- Trainer: `/anmelden`, Konto `trainer-pruefung@example.test`, das bereits mitgeteilte Prüfkennwort. Bibliothek, Programm Abstand, Film und Unterlage.
|
||||
- Redaktion: `/verwaltung`, Konto `redaktion-pruefung@example.test`, das bereits mitgeteilte Prüfkennwort und der bestehende Authenticator. Rollen Redaktion und Katalog.
|
||||
|
||||
## Commits auf `develop`, die diesen Stand tragen
|
||||
|
||||
| Commit | Inhalt |
|
||||
|---|---|
|
||||
| `7820bec` | Paket 1 |
|
||||
| `1a2b129` | Paket 2 |
|
||||
| `5ed01b9`, `fc08e6d`, `7b54c38` | Paket 3, Bibliothek, Anzeigefreigabe |
|
||||
| `5e763d1` | Pakete 4 bis 7 und der Ausgabenachweis |
|
||||
| `c99a957` | Nutzbarkeit, Didaktik, öffentliche Programmfassung |
|
||||
| `1d8315c`, `9b52181` | Kursraum |
|
||||
| `d6ff881` | fachliche Inhaltsverwaltung |
|
||||
| `c997eb5`, `295f784` | geschützte Vorschaubilder und Filmstufen |
|
||||
| `57802df` | Programmvorschau über die Queue, kein erneutes Seeden |
|
||||
| `30833f6` | HLS über hls.js, wenn der Browser die Fähigkeit nur behauptet |
|
||||
|
||||
## Empfehlung
|
||||
|
||||
Die fachliche Erprobung des Abstand-Programms kann sofort auf der Testinstanz stattfinden. Eine Aussage „MVP abgenommen“ oder „kommerziell freigegeben“ setzt den fehlenden Tor-B-Lauf voraus, einschließlich einer echten PDF-Datei und der zweiten Programmfassung mit getrennten Personen.
|
||||