Compare commits
49
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05dc1170aa | ||
|
|
9353e2e38a | ||
|
|
ec8c173053 | ||
|
|
101e7c63c4 | ||
|
|
eb8114abcf | ||
|
|
f07fbae940 | ||
|
|
7f9534d289 | ||
|
|
9e8d0020b3 | ||
|
|
b9da512170 | ||
|
|
345e694933 | ||
|
|
100b4e26c3 | ||
|
|
e6957b79d4 | ||
|
|
adaa68948a | ||
|
|
fd5db90b77 | ||
|
|
f11ff89f2d | ||
|
|
e904b500fb | ||
|
|
67764c3e4f | ||
|
|
66f9275099 | ||
|
|
25b2149d43 | ||
|
|
7b43db2498 | ||
|
|
4817fe9455 | ||
|
|
2b00905f00 | ||
|
|
aca713c6ba | ||
|
|
63ad125859 | ||
|
|
67325285d6 | ||
|
|
31c76113c8 | ||
|
|
87de5a62d4 | ||
|
|
e0ed7b45c9 | ||
|
|
62f3a33541 | ||
|
|
33310463fd | ||
|
|
aa79143910 | ||
|
|
3f81781607 | ||
|
|
5bd72dedab | ||
|
|
7e7019b717 | ||
|
|
61c7c5c3d3 | ||
|
|
edfe743d7d | ||
|
|
a5466896aa | ||
|
|
d03fcfceaf | ||
|
|
63b42b366c | ||
|
|
0492133201 | ||
|
|
23978d26da | ||
|
|
41bf9a0220 | ||
|
|
380a3013c7 | ||
|
|
79c4e877ab | ||
|
|
5bc362d25c | ||
|
|
374fd95576 | ||
|
|
2eca612108 | ||
|
|
7302ac78e9 | ||
|
|
fb479c1b01 |
No files matched your search
@@ -38,6 +38,15 @@ RUN composer dump-autoload --optimize --no-interaction
|
|||||||
ENV APP_ENV=testing
|
ENV APP_ENV=testing
|
||||||
CMD ["sh", "-ec", "if [ -x vendor/bin/pint ]; then vendor/bin/pint --test; fi; php artisan test --compact"]
|
CMD ["sh", "-ec", "if [ -x vendor/bin/pint ]; then vendor/bin/pint --test; fi; php artisan test --compact"]
|
||||||
|
|
||||||
|
# ---- JavaScript-Tests (CI): Vitest für resources/js. Nur das Gate baut dieses Ziel; die ausgelieferten Images
|
||||||
|
# (app, web) enthalten weder Vitest noch die Tests, weil sie nur das Ergebnis von "assets" übernehmen.
|
||||||
|
FROM node:22-alpine AS jstest
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json package-lock.json vitest.config.js ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY resources/js ./resources/js
|
||||||
|
CMD ["npm", "run", "test:js"]
|
||||||
|
|
||||||
# ---- App (php-fpm; derselbe Tag dient für Queue und Scheduler) -------------------------------
|
# ---- App (php-fpm; derselbe Tag dient für Queue und Scheduler) -------------------------------
|
||||||
FROM base AS app
|
FROM base AS app
|
||||||
COPY --from=vendor /var/www/html /var/www/html
|
COPY --from=vendor /var/www/html /var/www/html
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Composition;
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
|
use App\Jobs\DeriveImageVariants;
|
||||||
|
use App\Jobs\DeriveWebsiteVariants;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt für vorhandene Bilder die kleineren Fassungen an (docs/architektur/bildvarianten.md). Neue Bilder bekommen sie beim
|
||||||
|
* Ableiten; dieser Befehl holt den Bestand nach. Die Arbeit macht die Warteschlange (nur sie darf in derived/ und public/
|
||||||
|
* schreiben); mit --now läuft sie hier im Prozess, den man dafür im Queue-Container startet.
|
||||||
|
*/
|
||||||
|
class DeriveMediaVariants extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'media:varianten {--now : Sofort hier ausführen statt in die Warteschlange zu legen} {--pretend : Nur zählen}';
|
||||||
|
|
||||||
|
protected $description = 'Legt für vorhandene Vorschaubilder und freigegebene Website-Bilder die kleineren Fassungen an';
|
||||||
|
|
||||||
|
public function handle(): int
|
||||||
|
{
|
||||||
|
$derived = Storage::disk('media_derived');
|
||||||
|
$paths = [];
|
||||||
|
|
||||||
|
foreach ([ContentElement::query(), Composition::query()] as $query) {
|
||||||
|
$query->where('thumbnail_path', 'like', 'vorschau/%')
|
||||||
|
->pluck('thumbnail_path')
|
||||||
|
->each(function (mixed $path) use (&$paths): void {
|
||||||
|
if (is_string($path)) {
|
||||||
|
$paths[$path] = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$missing = array_values(array_filter(
|
||||||
|
array_keys($paths),
|
||||||
|
fn (string $path): bool => ! str_contains($path, '..')
|
||||||
|
&& ! $derived->exists(ImageVariants::path($path, 'klein'))
|
||||||
|
&& $derived->exists($path),
|
||||||
|
));
|
||||||
|
|
||||||
|
$websiteIds = ContentElement::query()
|
||||||
|
->where('output_class', 'bild')
|
||||||
|
->whereNotNull('website_released_at')
|
||||||
|
->whereNotNull('website_public_path')
|
||||||
|
->pluck('id')
|
||||||
|
->all();
|
||||||
|
|
||||||
|
$this->info(count($missing).' Vorschaubilder ohne Fassungen, '.count($websiteIds).' freigegebene Website-Bilder.');
|
||||||
|
|
||||||
|
if ($this->option('pretend')) {
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($missing as $path) {
|
||||||
|
$this->option('now') ? DeriveImageVariants::dispatchSync($path) : DeriveImageVariants::dispatch($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($websiteIds as $id) {
|
||||||
|
$this->option('now') ? DeriveWebsiteVariants::dispatchSync((int) $id) : DeriveWebsiteVariants::dispatch((int) $id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info($this->option('now') ? 'Fassungen angelegt.' : 'In die Warteschlange gelegt.');
|
||||||
|
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Domain\Catalog;
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use App\Domain\Media\MediaRendition;
|
||||||
use App\Jobs\StoreContentFile;
|
use App\Jobs\StoreContentFile;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@@ -73,6 +74,9 @@ public function publishElementVersion(
|
|||||||
if (is_string($incoming) && $incoming !== '') {
|
if (is_string($incoming) && $incoming !== '') {
|
||||||
StoreContentFile::dispatch($version->id, $incoming);
|
StoreContentFile::dispatch($version->id, $incoming);
|
||||||
$version->refresh();
|
$version->refresh();
|
||||||
|
} elseif (is_string($metadata['file'] ?? null) && $metadata['file'] !== '') {
|
||||||
|
// Gleiche Datei, neue Fassung (Text, Marken, Notiz): die HLS-Stufen der Datei bleiben erhalten.
|
||||||
|
MediaRendition::carryOver($element, $version, $metadata['file']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $version;
|
return $version;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Domain\Catalog;
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Widgets\Support\TextMarkers;
|
||||||
use Dom\HTMLDocument;
|
use Dom\HTMLDocument;
|
||||||
use Dom\Node;
|
use Dom\Node;
|
||||||
use Symfony\Component\HtmlSanitizer\HtmlSanitizer;
|
use Symfony\Component\HtmlSanitizer\HtmlSanitizer;
|
||||||
@@ -31,6 +32,9 @@ final class FormattedText
|
|||||||
/** Blockelemente, mit denen gespeichertes HTML beginnt. */
|
/** Blockelemente, mit denen gespeichertes HTML beginnt. */
|
||||||
private const BLOCKS = ['p', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'blockquote', 'table', 'img'];
|
private const BLOCKS = ['p', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'blockquote', 'table', 'img'];
|
||||||
|
|
||||||
|
/** Zusätzlich zu den Blöcken erkennt der Textanfang h1, h2 und div als HTML; die Bereinigung bildet sie auf h3 und p ab (mapLegacyTags). */
|
||||||
|
private const START_TAGS = ['h1', 'h2', 'div'];
|
||||||
|
|
||||||
/** Angaben der Redaktion, die formatiert gespeichert werden. Suchbegriffe, Titel und Teaser bleiben Klartext. */
|
/** Angaben der Redaktion, die formatiert gespeichert werden. Suchbegriffe, Titel und Teaser bleiben Klartext. */
|
||||||
public const FIELDS = ['summary', 'description'];
|
public const FIELDS = ['summary', 'description'];
|
||||||
|
|
||||||
@@ -58,7 +62,7 @@ final class FormattedText
|
|||||||
/** Wird der Wert als HTML gelesen (sonst als Klartext des Altbestands)? */
|
/** Wird der Wert als HTML gelesen (sonst als Klartext des Altbestands)? */
|
||||||
public static function isHtml(?string $value): bool
|
public static function isHtml(?string $value): bool
|
||||||
{
|
{
|
||||||
return preg_match('/^\s*<(?:'.implode('|', self::BLOCKS).')[\s>\/]/i', (string) $value) === 1;
|
return preg_match('/^\s*<(?:'.implode('|', [...self::BLOCKS, ...self::START_TAGS]).')[\s>\/]/i', (string) $value) === 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -557,7 +561,9 @@ private static function block(Node $node): string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $items === '' ? '' : '<'.$name.'>'.$items.'</'.$name.'>';
|
// Zeichen der Liste (Nummern im Kreis, Symbol): nur Schlüssel, die TextMarkers kennt; im Profil der
|
||||||
|
// Verwaltung hat die Bereinigung sie schon entfernt.
|
||||||
|
return $items === '' ? '' : '<'.$name.TextMarkers::attributes($name, $node).'>'.$items.'</'.$name.'>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$inner = self::inner($node);
|
$inner = self::inner($node);
|
||||||
@@ -571,7 +577,10 @@ private static function block(Node $node): string
|
|||||||
? ' style="'.$node->getAttribute('style').'"'
|
? ' style="'.$node->getAttribute('style').'"'
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
return self::hasContent($inner) ? '<'.$name.$align.'>'.$inner.'</'.$name.'>' : '';
|
// Symbol vor dem Absatz (nur Absätze auf der obersten Ebene, siehe TextMarkers::attributes()).
|
||||||
|
$symbol = $name === 'p' ? TextMarkers::attributes('p', $node) : '';
|
||||||
|
|
||||||
|
return self::hasContent($inner) ? '<'.$name.$align.$symbol.'>'.$inner.'</'.$name.'>' : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -779,8 +788,10 @@ private static function sanitizer(bool $site = false): HtmlSanitizer
|
|||||||
// Das Webprofil lässt zusätzlich Spans (Größe, Farbe) und den Stil an Absätzen und Überschriften zu; siteMarks()
|
// Das Webprofil lässt zusätzlich Spans (Größe, Farbe) und den Stil an Absätzen und Überschriften zu; siteMarks()
|
||||||
// führt beides danach auf feste Werte zurück. Verwaltung und PDF kennen weder Spans noch Stile.
|
// führt beides danach auf feste Werte zurück. Verwaltung und PDF kennen weder Spans noch Stile.
|
||||||
$text = $site ? ['style'] : [];
|
$text = $site ? ['style'] : [];
|
||||||
|
$paragraph = $site ? [...$text, ...TextMarkers::PARAGRAPH_ATTRIBUTES] : [];
|
||||||
|
$list = $site ? TextMarkers::LIST_ATTRIBUTES : [];
|
||||||
$config = (new HtmlSanitizerConfig)
|
$config = (new HtmlSanitizerConfig)
|
||||||
->allowElement('p', $text)
|
->allowElement('p', $paragraph)
|
||||||
->allowElement('h3', $text)
|
->allowElement('h3', $text)
|
||||||
->allowElement('h4', $text)
|
->allowElement('h4', $text)
|
||||||
->allowElement('h5', $text)
|
->allowElement('h5', $text)
|
||||||
@@ -795,8 +806,8 @@ private static function sanitizer(bool $site = false): HtmlSanitizer
|
|||||||
->allowElement('br')
|
->allowElement('br')
|
||||||
->allowElement('strong')
|
->allowElement('strong')
|
||||||
->allowElement('em')
|
->allowElement('em')
|
||||||
->allowElement('ul')
|
->allowElement('ul', $list)
|
||||||
->allowElement('ol')
|
->allowElement('ol', $list)
|
||||||
->allowElement('li')
|
->allowElement('li')
|
||||||
->allowElement('blockquote')
|
->allowElement('blockquote')
|
||||||
->allowElement('table')
|
->allowElement('table')
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public function rows(Model $subject): array
|
|||||||
? (string) ($element->display_title ?: $element->working_title)
|
? (string) ($element->display_title ?: $element->working_title)
|
||||||
: 'Medium fehlt',
|
: 'Medium fehlt',
|
||||||
'image' => $element instanceof ContentElement
|
'image' => $element instanceof ContentElement
|
||||||
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path)
|
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at)
|
||||||
: null,
|
: null,
|
||||||
'kind' => $element?->editorialContentKind?->label,
|
'kind' => $element?->editorialContentKind?->label,
|
||||||
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
|
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
|
||||||
@@ -134,7 +134,7 @@ public function describe(array $staged): array
|
|||||||
? (string) ($element->display_title ?: $element->working_title)
|
? (string) ($element->display_title ?: $element->working_title)
|
||||||
: 'Medium fehlt',
|
: 'Medium fehlt',
|
||||||
'image' => $element instanceof ContentElement
|
'image' => $element instanceof ContentElement
|
||||||
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path)
|
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at)
|
||||||
: null,
|
: null,
|
||||||
'kind' => $element?->editorialContentKind?->label,
|
'kind' => $element?->editorialContentKind?->label,
|
||||||
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
|
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public static function previewUrl(?string $target): ?string
|
|||||||
return route('website.media', $element);
|
return route('website.media', $element);
|
||||||
}
|
}
|
||||||
|
|
||||||
return app(EditorialCatalog::class)->cardUrl('element', $element->id, $element->thumbnail_path);
|
return app(EditorialCatalog::class)->cardUrl('element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
|||||||
notice: $notice,
|
notice: $notice,
|
||||||
visual: 'catalog',
|
visual: 'catalog',
|
||||||
visualLabel: $kind,
|
visualLabel: $kind,
|
||||||
previewImage: $includeNonPublic ? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path) : null,
|
previewImage: $includeNonPublic ? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path, 'mittel', $composition->updated_at) : null,
|
||||||
missing: $missing,
|
missing: $missing,
|
||||||
texts: $texts,
|
texts: $texts,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
|
|||||||
$missing[] = 'Kein Anzeigetitel gepflegt; die Karte zeigt den Arbeitstitel.';
|
$missing[] = 'Kein Anzeigetitel gepflegt; die Karte zeigt den Arbeitstitel.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$previewImage = $includeNonPublic ? ThumbnailRef::url('editorial.card', 'element', (int) $element->id, $shown->thumbnail_path) : null;
|
$previewImage = $includeNonPublic ? ThumbnailRef::url('editorial.card', 'element', (int) $element->id, $shown->thumbnail_path, 'mittel', $shown->updated_at) : null;
|
||||||
|
|
||||||
return new CardSubject(
|
return new CardSubject(
|
||||||
title: $title,
|
title: $title,
|
||||||
|
|||||||
@@ -0,0 +1,174 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Cms;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Sections\PageSections;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Überträgt einen Abschnitt auf eine andere Seite: als Kopie (neue Kennungen) oder als Verschiebung (Kennungen
|
||||||
|
* bleiben). Die Zielseite erhält eine neue, unveröffentlichte Revision; veröffentlicht wird nichts. Das Entfernen
|
||||||
|
* aus der Quellseite beim Verschieben ist Sache des Aufrufers (Seiteneditor), weil dort der Arbeitsstand liegt.
|
||||||
|
*/
|
||||||
|
class SectionTransfer
|
||||||
|
{
|
||||||
|
public const START = 'start';
|
||||||
|
|
||||||
|
public const END = 'end';
|
||||||
|
|
||||||
|
public function __construct(private readonly PageService $pages, private readonly PageSections $sections) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abschnitte, die der Editor der Seite zeigt (Entwurf vor Veröffentlichung).
|
||||||
|
*
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function sectionsOf(Page $page): array
|
||||||
|
{
|
||||||
|
return ($page->latestRevision ?? $page->publishedRevision)?->sections() ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wählbare Positionen auf der Zielseite: Anfang, Ende und hinter jedem vorhandenen Abschnitt.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function positions(Page $target): array
|
||||||
|
{
|
||||||
|
$sections = $this->sectionsOf($target);
|
||||||
|
|
||||||
|
if ($sections === []) {
|
||||||
|
return [self::END => 'Als ersten Abschnitt einfügen (die Seite hat noch keinen)'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = [self::START => 'Am Anfang der Seite', self::END => 'Am Ende der Seite'];
|
||||||
|
|
||||||
|
foreach ($sections as $index => $section) {
|
||||||
|
$options['after:'.($index + 1)] = 'Hinter Abschnitt '.($index + 1).': '.$this->label($section);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name des Abschnitts, sonst die erste Überschrift darin, sonst das Raster.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $section
|
||||||
|
*/
|
||||||
|
public function label(array $section): string
|
||||||
|
{
|
||||||
|
$name = PageSections::cleanName($section['name'] ?? null);
|
||||||
|
|
||||||
|
if ($name !== null) {
|
||||||
|
return Str::limit($name, 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ((array) ($section['slots'] ?? []) as $widget) {
|
||||||
|
$data = is_array($widget) && is_array($widget['data'] ?? null) ? $widget['data'] : [];
|
||||||
|
|
||||||
|
foreach (['heading', 'title', 'headline'] as $field) {
|
||||||
|
if (is_string($data[$field] ?? null) && trim(strip_tags($data[$field])) !== '') {
|
||||||
|
return Str::limit(trim(strip_tags($data[$field])), 50);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'ohne Namen';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fügt den Abschnitt auf der Zielseite ein. Wirft eine ValidationException, wenn die Zielseite damit ungültig
|
||||||
|
* würde (zu viele Abschnitte oder Widgets); dann ist nichts geschrieben.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $section Abschnitt im Modell (wie PageSections::read liefert)
|
||||||
|
* @return array{revision: PageRevision, position: int, anchor: ?string, anchorChanged: bool}
|
||||||
|
*/
|
||||||
|
public function insert(Page $target, array $section, string $position, bool $fresh, ?User $author): array
|
||||||
|
{
|
||||||
|
$plan = $this->plan($target, $section, $position, $fresh);
|
||||||
|
$revision = ($target->latestRevision ?? $target->publishedRevision);
|
||||||
|
|
||||||
|
$saved = $this->pages->saveRevision($target, $plan['content'], $revision?->seo_title, $revision?->seo_description, $author);
|
||||||
|
$target->unsetRelation('latestRevision');
|
||||||
|
|
||||||
|
return ['revision' => $saved, 'position' => $plan['position'], 'anchor' => $plan['anchor'], 'anchorChanged' => $plan['anchorChanged']];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüft, ob die Zielseite mit dem Abschnitt gültig bleibt, ohne zu schreiben.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $section
|
||||||
|
* @return array{content: list<array<string, mixed>>, position: int, anchor: ?string, anchorChanged: bool}
|
||||||
|
*/
|
||||||
|
public function plan(Page $target, array $section, string $position, bool $fresh): array
|
||||||
|
{
|
||||||
|
$existing = $this->sectionsOf($target);
|
||||||
|
|
||||||
|
if (count($existing) >= PageSections::MAX_SECTIONS) {
|
||||||
|
throw ValidationException::withMessages(['sections' => 'Eine Seite hat höchstens '.PageSections::MAX_SECTIONS.' Abschnitte. Die Zielseite ist voll.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($fresh) {
|
||||||
|
$section['id'] = null;
|
||||||
|
$section['slots'] = array_map(fn ($widget) => is_array($widget) ? array_replace($widget, ['id' => null]) : $widget, array_values((array) ($section['slots'] ?? [])));
|
||||||
|
}
|
||||||
|
|
||||||
|
[$anchor, $changed] = $this->freeAnchor($section['anchor'] ?? null, $existing);
|
||||||
|
$section['anchor'] = $anchor;
|
||||||
|
|
||||||
|
$at = $this->index($position, count($existing));
|
||||||
|
array_splice($existing, $at, 0, [$section]);
|
||||||
|
|
||||||
|
// Prüft die ganze Zielseite (Abschnitts- und Widget-Höchstzahl, Regeln der Bausteine); Fehler bricht ab.
|
||||||
|
$this->sections->normalize($existing);
|
||||||
|
|
||||||
|
return ['content' => $existing, 'position' => $at + 1, 'anchor' => $anchor, 'anchorChanged' => $changed];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Sprungmarke bleibt, wenn sie auf der Zielseite frei ist; sonst wird sie mit „-2“, „-3“ … eindeutig gemacht.
|
||||||
|
*
|
||||||
|
* @param list<array<string, mixed>> $existing
|
||||||
|
* @return array{0: ?string, 1: bool}
|
||||||
|
*/
|
||||||
|
private function freeAnchor(mixed $anchor, array $existing): array
|
||||||
|
{
|
||||||
|
$anchor = PageSections::cleanAnchor($anchor);
|
||||||
|
|
||||||
|
if ($anchor === null) {
|
||||||
|
return [null, false];
|
||||||
|
}
|
||||||
|
|
||||||
|
$taken = array_values(array_filter(array_map(fn (array $section): ?string => PageSections::cleanAnchor($section['anchor'] ?? null), $existing)));
|
||||||
|
|
||||||
|
if (PageSections::anchorProblem($anchor, $taken) === null) {
|
||||||
|
return [$anchor, false];
|
||||||
|
}
|
||||||
|
|
||||||
|
for ($number = 2; $number <= 50; $number++) {
|
||||||
|
$suffix = '-'.$number;
|
||||||
|
$candidate = rtrim(substr($anchor, 0, PageSections::MAX_ANCHOR - strlen($suffix)), '-').$suffix;
|
||||||
|
|
||||||
|
if (PageSections::anchorProblem($candidate, $taken) === null) {
|
||||||
|
return [$candidate, true];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [null, true];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function index(string $position, int $count): int
|
||||||
|
{
|
||||||
|
if ($position === self::START) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preg_match('/^after:(\d+)$/', $position, $match) === 1) {
|
||||||
|
return max(0, min($count, (int) $match[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||||
|
use App\Domain\Design\DesignPalette;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
@@ -364,13 +365,10 @@ private function normalizeLabels(array $section, string $prefix, array &$errors,
|
|||||||
|
|
||||||
if (is_string($rawAnchor) && trim($rawAnchor) !== '') {
|
if (is_string($rawAnchor) && trim($rawAnchor) !== '') {
|
||||||
$candidate = mb_strtolower(trim($rawAnchor));
|
$candidate = mb_strtolower(trim($rawAnchor));
|
||||||
|
$problem = self::anchorProblem($candidate, array_keys($seenAnchors));
|
||||||
|
|
||||||
if (strlen($candidate) > self::MAX_ANCHOR || preg_match(self::ANCHOR_PATTERN, $candidate) !== 1) {
|
if ($problem !== null) {
|
||||||
$errors["$prefix.anchor"] = ['Eine Sprungmarke besteht aus Kleinbuchstaben, Ziffern und einzelnen Bindestrichen (höchstens '.self::MAX_ANCHOR.' Zeichen), zum Beispiel „anmeldung“.'];
|
$errors["$prefix.anchor"] = [$problem];
|
||||||
} elseif (in_array($candidate, self::RESERVED_ANCHORS, true) || str_starts_with($candidate, 'bereich-')) {
|
|
||||||
$errors["$prefix.anchor"] = ['Diese Sprungmarke ist im Seitengerüst schon vergeben. Bitte eine andere wählen.'];
|
|
||||||
} elseif (isset($seenAnchors[$candidate])) {
|
|
||||||
$errors["$prefix.anchor"] = ['Diese Sprungmarke gibt es auf der Seite schon. Jede Sprungmarke darf nur einmal vorkommen.'];
|
|
||||||
} else {
|
} else {
|
||||||
$seenAnchors[$candidate] = true;
|
$seenAnchors[$candidate] = true;
|
||||||
$anchor = $candidate;
|
$anchor = $candidate;
|
||||||
@@ -382,6 +380,29 @@ private function normalizeLabels(array $section, string $prefix, array &$errors,
|
|||||||
return [$name, $anchor];
|
return [$name, $anchor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warum eine Sprungmarke nicht zulässig ist (Form, reserviert, schon vergeben), sonst null. Gilt beim Speichern der
|
||||||
|
* Seite und im Einstellungsdialog des Abschnitts mit demselben Wortlaut.
|
||||||
|
*
|
||||||
|
* @param list<string|int> $taken Sprungmarken der übrigen Abschnitte
|
||||||
|
*/
|
||||||
|
public static function anchorProblem(string $candidate, array $taken): ?string
|
||||||
|
{
|
||||||
|
if (strlen($candidate) > self::MAX_ANCHOR || preg_match(self::ANCHOR_PATTERN, $candidate) !== 1) {
|
||||||
|
return 'Eine Sprungmarke besteht aus Kleinbuchstaben, Ziffern und einzelnen Bindestrichen (höchstens '.self::MAX_ANCHOR.' Zeichen), zum Beispiel „anmeldung“.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($candidate, self::RESERVED_ANCHORS, true) || str_starts_with($candidate, 'bereich-')) {
|
||||||
|
return 'Diese Sprungmarke ist im Seitengerüst schon vergeben. Bitte eine andere wählen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($candidate, array_map('strval', $taken), true)) {
|
||||||
|
return 'Diese Sprungmarke gibt es auf der Seite schon. Jede Sprungmarke darf nur einmal vorkommen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/** Interner Name: Leerraum vereinheitlicht, ohne Steuerzeichen; leer oder über 80 Zeichen ergibt null. */
|
/** Interner Name: Leerraum vereinheitlicht, ohne Steuerzeichen; leer oder über 80 Zeichen ergibt null. */
|
||||||
public static function cleanName(mixed $value): ?string
|
public static function cleanName(mixed $value): ?string
|
||||||
{
|
{
|
||||||
@@ -419,7 +440,7 @@ private function normalizeStyle(array $style, string $prefix, array &$errors): a
|
|||||||
$enums = SectionStyle::enums();
|
$enums = SectionStyle::enums();
|
||||||
|
|
||||||
foreach ($style as $key => $value) {
|
foreach ($style as $key => $value) {
|
||||||
if ($key === 'image' || str_starts_with((string) $key, '_')) {
|
if (in_array($key, ['image', 'palette_slot'], true) || str_starts_with((string) $key, '_')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,6 +463,29 @@ private function normalizeStyle(array $style, string $prefix, array &$errors): a
|
|||||||
$result[$key] = $value;
|
$result[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ergänzende Optionen stehen nur bei Abweichung von der Vorgabe im gespeicherten Stand.
|
||||||
|
foreach (SectionStyle::OPTIONAL as $key => $default) {
|
||||||
|
if (($result[$key] ?? $default) === $default) {
|
||||||
|
unset($result[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Die Breite der Fläche gilt nur mit eigenem Hintergrund.
|
||||||
|
if ($result['background'] === 'default') {
|
||||||
|
unset($result['background_width']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Farbe aus der Palette: Der Verweis steht nur bei diesem Hintergrund im gespeicherten Stand.
|
||||||
|
if ($result['background'] === 'palette') {
|
||||||
|
$slot = DesignPalette::find($style['palette_slot'] ?? null);
|
||||||
|
|
||||||
|
if ($slot === null) {
|
||||||
|
$errors["$prefix.style.palette_slot"] = ['Bitte eine Farbe aus der Palette wählen. Die gewählte Farbe gibt es nicht (mehr).'];
|
||||||
|
} else {
|
||||||
|
$result['palette_slot'] = $slot['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($result['background'] === 'image') {
|
if ($result['background'] === 'image') {
|
||||||
$widgetErrors = new WidgetErrors;
|
$widgetErrors = new WidgetErrors;
|
||||||
$refs = ImageRefFields::clean(['image' => $style['image'] ?? null, '_upload' => $style['_upload'] ?? null], $widgetErrors, errorKey: 'image');
|
$refs = ImageRefFields::clean(['image' => $style['image'] ?? null, '_upload' => $style['_upload'] ?? null], $widgetErrors, errorKey: 'image');
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
use App\Domain\Cms\Widgets\WidgetRenderer;
|
use App\Domain\Cms\Widgets\WidgetRenderer;
|
||||||
|
use App\Domain\Design\ColorContrast;
|
||||||
|
use App\Domain\Design\DesignPalette;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,7 +117,7 @@ private function renderSection(array $section, array $cells, int $index, RenderC
|
|||||||
$style = SectionStyle::fromStored($section['style'] ?? []);
|
$style = SectionStyle::fromStored($section['style'] ?? []);
|
||||||
$columns = SectionLayouts::columns(array_column($cells, 'units'));
|
$columns = SectionLayouts::columns(array_column($cells, 'units'));
|
||||||
// Hintergrundbild aus dem Medienmanager: öffentlich nur mit Website-Freigabe (WebsiteImage → WebsiteMedia).
|
// Hintergrundbild aus dem Medienmanager: öffentlich nur mit Website-Freigabe (WebsiteImage → WebsiteMedia).
|
||||||
$imageUrl = $style['background'] === 'image' ? app(WebsiteImage::class)->url($style['image'], $context->preview) : null;
|
$imageUrl = $style['background'] === 'image' ? app(WebsiteImage::class)->url($style['image'], $context->preview, 1920) : null;
|
||||||
$hasImage = $imageUrl !== null;
|
$hasImage = $imageUrl !== null;
|
||||||
|
|
||||||
$classes = [
|
$classes = [
|
||||||
@@ -132,24 +134,54 @@ private function renderSection(array $section, array $cells, int $index, RenderC
|
|||||||
$classes[] = 'section-overlay-'.$style['overlay'];
|
$classes[] = 'section-overlay-'.$style['overlay'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Karten im Abschnitt (ADR-66): nur bei Abweichung von der Vorgabe, damit die Ausgabe bestehender Seiten gleich bleibt.
|
||||||
|
if ($style['cards_height'] === 'equal') {
|
||||||
|
$classes[] = 'section-cards-equal';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($style['cards_links'] === 'bottom') {
|
||||||
|
$classes[] = 'section-cards-links-bottom';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Farbe aus der Palette (ADR-67): Hintergrund- und Schriftfarbe der Farbe; die Bausteine erhalten daraus abgeleitete
|
||||||
|
// Bedeutungswerte. Ist die Farbe nicht (mehr) in der Palette, fällt SectionStyle::fromStored auf „Standard“ zurück.
|
||||||
|
$palette = $style['background'] === 'palette' ? DesignPalette::find($style['palette_slot']) : null;
|
||||||
|
$dark = $palette !== null && ColorContrast::isDarkSurface($palette['fg'], $palette['bg']);
|
||||||
|
|
||||||
// Bedeutungswerte der Fläche (tokens.css): helle Schrift auf dunklen Flächen, gelber Fokus.
|
// Bedeutungswerte der Fläche (tokens.css): helle Schrift auf dunklen Flächen, gelber Fokus.
|
||||||
$scope = match (true) {
|
$scope = match (true) {
|
||||||
$hasImage && $style['overlay'] === 'dark' => 'scope-dark',
|
$hasImage && $style['overlay'] === 'dark' => 'scope-dark',
|
||||||
$hasImage => 'scope-light',
|
$hasImage => 'scope-light',
|
||||||
$style['background'] === 'dark' => 'scope-dark',
|
$style['background'] === 'dark' => 'scope-dark',
|
||||||
$style['background'] === 'accent' => 'scope-accent',
|
$style['background'] === 'accent' => 'scope-accent',
|
||||||
|
$dark => 'scope-dark',
|
||||||
default => null,
|
default => null,
|
||||||
};
|
};
|
||||||
if ($scope !== null) {
|
if ($scope !== null) {
|
||||||
$classes[] = $scope;
|
$classes[] = $scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Breite der Fläche (ADR-67): nur bei „Auf Abschnittsbreite begrenzt“, mit eigener Fläche und schmaler als die volle Breite.
|
||||||
|
$hasSurface = $hasImage || $palette !== null || in_array($style['background'], ['light', 'dark', 'accent'], true);
|
||||||
|
if ($hasSurface && $style['background_width'] === 'section' && $style['width'] !== 'full') {
|
||||||
|
$classes[] = 'section-bg-width-section';
|
||||||
|
}
|
||||||
|
|
||||||
// Die Sprungmarke ist die Kennung, die ein Link „#marke“ anspringt; ohne sie bleibt die bisherige Kennung.
|
// Die Sprungmarke ist die Kennung, die ein Link „#marke“ anspringt; ohne sie bleibt die bisherige Kennung.
|
||||||
$anchor = PageSections::cleanAnchor($section['anchor'] ?? null);
|
$anchor = PageSections::cleanAnchor($section['anchor'] ?? null);
|
||||||
$id = $anchor !== null
|
$id = $anchor !== null
|
||||||
? ' id="'.e($anchor).'"'
|
? ' id="'.e($anchor).'"'
|
||||||
: (is_string($section['id'] ?? null) ? ' id="bereich-'.e($section['id']).'"' : '');
|
: (is_string($section['id'] ?? null) ? ' id="bereich-'.e($section['id']).'"' : '');
|
||||||
$html = '<div class="'.e(implode(' ', $classes)).'"'.$id.'>';
|
$surface = '';
|
||||||
|
if ($palette !== null) {
|
||||||
|
$surface = ' style="';
|
||||||
|
foreach (ColorContrast::surfaceProperties($palette['bg'], $palette['fg']) as $property => $value) {
|
||||||
|
$surface .= '--'.$property.': '.e($value).'; ';
|
||||||
|
}
|
||||||
|
$surface = rtrim($surface).'"';
|
||||||
|
}
|
||||||
|
|
||||||
|
$html = '<div class="'.e(implode(' ', $classes)).'"'.$id.$surface.'>';
|
||||||
|
|
||||||
if ($hasImage) {
|
if ($hasImage) {
|
||||||
// Das Bild des ersten Abschnitts ist meist das größte sichtbare Element und wird nicht verzögert geladen.
|
// Das Bild des ersten Abschnitts ist meist das größte sichtbare Element und wird nicht verzögert geladen.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Domain\Cms\Sections;
|
namespace App\Domain\Cms\Sections;
|
||||||
|
|
||||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
|
use App\Domain\Design\DesignPalette;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Semantische Abschnittsgestaltung. Jeder Wert ist eine Aufzählung, die auf zentrale Design-Tokens
|
* Semantische Abschnittsgestaltung. Jeder Wert ist eine Aufzählung, die auf zentrale Design-Tokens
|
||||||
@@ -16,9 +17,21 @@ final class SectionStyle
|
|||||||
'light' => 'Helle Markenfläche',
|
'light' => 'Helle Markenfläche',
|
||||||
'dark' => 'Dunkle Markenfläche',
|
'dark' => 'Dunkle Markenfläche',
|
||||||
'accent' => 'Markenakzent',
|
'accent' => 'Markenakzent',
|
||||||
|
'palette' => 'Farbe aus der Palette',
|
||||||
'image' => 'Hintergrundbild',
|
'image' => 'Hintergrundbild',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Breite der Fläche eines Abschnitts mit eigenem Hintergrund (Farbe, Palette oder Bild). „Volle Browserbreite“ ist das
|
||||||
|
* bisherige Verhalten; „Auf Abschnittsbreite begrenzt“ zentriert die Fläche in der gewählten Inhaltsbreite.
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
public const BACKGROUND_WIDTHS = [
|
||||||
|
'full' => 'Volle Browserbreite',
|
||||||
|
'section' => 'Auf Abschnittsbreite begrenzt',
|
||||||
|
];
|
||||||
|
|
||||||
/** @var array<string, string> */
|
/** @var array<string, string> */
|
||||||
public const WIDTHS = [
|
public const WIDTHS = [
|
||||||
'narrow' => 'Lesebereich',
|
'narrow' => 'Lesebereich',
|
||||||
@@ -85,6 +98,27 @@ final class SectionStyle
|
|||||||
'bottom_right' => '100% 100%',
|
'bottom_right' => '100% 100%',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Karten im Abschnitt (ADR-66): Höhe aller Karten des Abschnitts. „Gleich hoch“ richtet alle Karten an der größten aus.
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
public const CARD_HEIGHTS = [
|
||||||
|
'auto' => 'Nach Inhalt der Karte',
|
||||||
|
'equal' => 'Alle so hoch wie die größte Karte',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Karten im Abschnitt (ADR-66): Lage des Links in Karten mit eigenem Link (Schaltfläche, „Mehr erfahren“). Links im
|
||||||
|
* Fließtext einer Karte bleiben, wo sie stehen.
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
public const CARD_LINKS = [
|
||||||
|
'text' => 'Direkt unter dem Text',
|
||||||
|
'bottom' => 'Am unteren Rand der Karte',
|
||||||
|
];
|
||||||
|
|
||||||
public const DEFAULTS = [
|
public const DEFAULTS = [
|
||||||
'background' => 'default',
|
'background' => 'default',
|
||||||
'image' => null,
|
'image' => null,
|
||||||
@@ -97,6 +131,16 @@ final class SectionStyle
|
|||||||
'divider' => 'none',
|
'divider' => 'none',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ergänzende Gestaltungsoptionen: Sie stehen nur im gespeicherten Stand, wenn sie von der Vorgabe abweichen, damit
|
||||||
|
* Abschnitte ohne diese Optionen unverändert bleiben (Format und Vergleich mit dem letzten Stand).
|
||||||
|
*/
|
||||||
|
public const OPTIONAL = [
|
||||||
|
'background_width' => 'full',
|
||||||
|
'cards_height' => 'auto',
|
||||||
|
'cards_links' => 'text',
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Aufzählungsfelder und ihre zulässigen Werte.
|
* Aufzählungsfelder und ihre zulässigen Werte.
|
||||||
*
|
*
|
||||||
@@ -106,6 +150,7 @@ public static function enums(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'background' => self::BACKGROUNDS,
|
'background' => self::BACKGROUNDS,
|
||||||
|
'background_width' => self::BACKGROUND_WIDTHS,
|
||||||
'focus' => self::FOCUS,
|
'focus' => self::FOCUS,
|
||||||
'overlay' => self::OVERLAYS,
|
'overlay' => self::OVERLAYS,
|
||||||
'width' => self::WIDTHS,
|
'width' => self::WIDTHS,
|
||||||
@@ -113,6 +158,8 @@ public static function enums(): array
|
|||||||
'spacing_bottom' => self::SPACINGS,
|
'spacing_bottom' => self::SPACINGS,
|
||||||
'gap' => self::SPACINGS,
|
'gap' => self::SPACINGS,
|
||||||
'divider' => self::DIVIDERS,
|
'divider' => self::DIVIDERS,
|
||||||
|
'cards_height' => self::CARD_HEIGHTS,
|
||||||
|
'cards_links' => self::CARD_LINKS,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,12 +167,12 @@ public static function enums(): array
|
|||||||
* Lesepfad: gespeicherte Werte; Unbekanntes fällt auf die Vorgabe zurück, damit alte oder fremde Daten
|
* Lesepfad: gespeicherte Werte; Unbekanntes fällt auf die Vorgabe zurück, damit alte oder fremde Daten
|
||||||
* nie eine Seite brechen.
|
* 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}
|
* @return array{background: string, palette_slot: ?string, background_width: string, image: ?string, focus: string, overlay: string, width: string, spacing_top: string, spacing_bottom: string, gap: string, divider: string, cards_height: string, cards_links: string}
|
||||||
*/
|
*/
|
||||||
public static function fromStored(mixed $style): array
|
public static function fromStored(mixed $style): array
|
||||||
{
|
{
|
||||||
$style = is_array($style) ? $style : [];
|
$style = is_array($style) ? $style : [];
|
||||||
$result = self::DEFAULTS;
|
$result = self::DEFAULTS + self::OPTIONAL;
|
||||||
|
|
||||||
foreach (self::enums() as $key => $options) {
|
foreach (self::enums() as $key => $options) {
|
||||||
$value = $style[$key] ?? null;
|
$value = $style[$key] ?? null;
|
||||||
@@ -136,6 +183,17 @@ public static function fromStored(mixed $style): array
|
|||||||
|
|
||||||
$result['image'] = $result['background'] === 'image' ? WebsiteImage::normalize($style['image'] ?? null) : null;
|
$result['image'] = $result['background'] === 'image' ? WebsiteImage::normalize($style['image'] ?? null) : null;
|
||||||
|
|
||||||
|
// Farbe aus der Palette: Ist die Farbe nicht (mehr) in der Palette, erscheint der Abschnitt ohne eigene Fläche.
|
||||||
|
$result['palette_slot'] = null;
|
||||||
|
if ($result['background'] === 'palette') {
|
||||||
|
$slot = DesignPalette::find($style['palette_slot'] ?? null);
|
||||||
|
if ($slot === null) {
|
||||||
|
$result['background'] = 'default';
|
||||||
|
} else {
|
||||||
|
$result['palette_slot'] = $slot['id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +205,13 @@ public static function fromStored(mixed $style): array
|
|||||||
public static function summary(array $style): string
|
public static function summary(array $style): string
|
||||||
{
|
{
|
||||||
$style = self::fromStored($style);
|
$style = self::fromStored($style);
|
||||||
$parts = [self::BACKGROUNDS[$style['background']]];
|
$parts = [$style['background'] === 'palette'
|
||||||
|
? 'Farbe „'.(DesignPalette::find($style['palette_slot'])['name'] ?? '').'“'
|
||||||
|
: self::BACKGROUNDS[$style['background']]];
|
||||||
|
|
||||||
|
if ($style['background'] !== 'default' && $style['background_width'] === 'section') {
|
||||||
|
$parts[] = 'Hintergrund auf Abschnittsbreite';
|
||||||
|
}
|
||||||
|
|
||||||
if ($style['width'] !== 'standard') {
|
if ($style['width'] !== 'standard') {
|
||||||
$parts[] = self::WIDTHS[$style['width']];
|
$parts[] = self::WIDTHS[$style['width']];
|
||||||
@@ -166,6 +230,14 @@ public static function summary(array $style): string
|
|||||||
$parts[] = 'Trenner: '.self::DIVIDERS[$style['divider']];
|
$parts[] = 'Trenner: '.self::DIVIDERS[$style['divider']];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($style['cards_height'] === 'equal') {
|
||||||
|
$parts[] = 'Karten gleich hoch';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($style['cards_links'] === 'bottom') {
|
||||||
|
$parts[] = 'Kartenlinks unten';
|
||||||
|
}
|
||||||
|
|
||||||
return implode(' · ', $parts);
|
return implode(' · ', $parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,172 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Cms\Widgets\Support;
|
||||||
|
|
||||||
|
use App\Filament\Support\FramingSlider;
|
||||||
|
use Filament\Forms\Components\Slider;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bildausschnitt für Bilder und Videos in Widgets (ADR-70): Fokuspunkt (waagerecht, senkrecht, 0–100 %) und Zoom
|
||||||
|
* (100–250 %). Gespeichert wird in data (`focus_x`, `focus_y`, `zoom`), weil settings nur Aufzählungswerte trägt.
|
||||||
|
*
|
||||||
|
* Der Zoom beginnt bei 100 %: Dann füllt das Bild den Rahmen (object-fit: cover), mehr Verkleinern gäbe es nur mit leeren
|
||||||
|
* Rändern. Darüber wird um den Fokuspunkt vergrößert (`scale`, `transform-origin` = Fokuspunkt). Ein Bild, das mindestens
|
||||||
|
* so groß ist wie der Rahmen und um einen Punkt im Rahmen vergrößert wird, lässt den Rahmen nie frei; es entstehen keine
|
||||||
|
* Ränder. Die Rahmen schneiden ab (overflow: hidden), die Darstellung ist reines CSS, es gibt keine neue Bildfassung.
|
||||||
|
*
|
||||||
|
* Die Karten (CardsWidget) tragen den Ausschnitt je Karte, die übrigen Widgets je Widget (PremiumFields).
|
||||||
|
*/
|
||||||
|
final class ImageFraming
|
||||||
|
{
|
||||||
|
public const ZOOM_MIN = 100;
|
||||||
|
|
||||||
|
public const ZOOM_MAX = 250;
|
||||||
|
|
||||||
|
/** Vorgaben des Fokuspunkts bei Widgets, die ihn nicht selbst vorgeben (Karten: Bildmitte). */
|
||||||
|
public const FOCUS_DEFAULT = 50;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die drei Regler. Ohne gespeicherten Wert zeigen sie die Vorgabe der Widget-Art, die auch die Darstellung verwendet.
|
||||||
|
*
|
||||||
|
* @return list<Slider>
|
||||||
|
*/
|
||||||
|
public static function sliders(int $defaultX = self::FOCUS_DEFAULT, int $defaultY = self::FOCUS_DEFAULT, ?\Closure $visible = null): array
|
||||||
|
{
|
||||||
|
$slider = function (string $name, string $label, int $min, int $max, int $default, ?string $help = null) use ($visible): FramingSlider {
|
||||||
|
$field = FramingSlider::make($name)
|
||||||
|
->label($label)
|
||||||
|
->range($min, $max)
|
||||||
|
->step(1)
|
||||||
|
->required(false)
|
||||||
|
->tooltips()
|
||||||
|
->default($default)
|
||||||
|
->afterStateHydrated(function (FramingSlider $component, mixed $state) use ($default, $min): void {
|
||||||
|
// Ein Regler ohne Wert beginnt bei null; der Zoom darunter ist keine Eingabe, sondern „nicht gesetzt“.
|
||||||
|
if (! is_numeric($state) || $state < $min) {
|
||||||
|
$component->state($default);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->live();
|
||||||
|
|
||||||
|
if ($help !== null) {
|
||||||
|
$field->helperText($help);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $visible !== null ? $field->visible($visible) : $field;
|
||||||
|
};
|
||||||
|
|
||||||
|
return [
|
||||||
|
$slider('focus_x', 'Bildausschnitt waagerecht (0 = links, 100 = rechts)', 0, 100, $defaultX),
|
||||||
|
$slider('focus_y', 'Bildausschnitt senkrecht (0 = oben, 100 = unten)', 0, 100, $defaultY),
|
||||||
|
$slider('zoom', 'Zoom (in Prozent)', self::ZOOM_MIN, self::ZOOM_MAX, self::ZOOM_MIN, 'Bei 100 % füllt das Bild den Rahmen; weiter herauszoomen geht nicht, sonst entstünden leere Ränder. Darüber wird um den gewählten Ausschnitt vergrößert. Gilt auch für das Video auf dem Bild.'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sichtbar, sobald in der Karte ein Bild gewählt ist (Feld `image` desselben Eintrags). */
|
||||||
|
public static function whenImageChosen(): \Closure
|
||||||
|
{
|
||||||
|
return fn (Get $get): bool => filled($get('image'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'focus_x' => ['nullable', 'numeric', 'between:0,100'],
|
||||||
|
'focus_y' => ['nullable', 'numeric', 'between:0,100'],
|
||||||
|
// Nach oben begrenzt; Werte darunter gelten als „kein Zoom“ (zoom() hebt sie auf 100 %).
|
||||||
|
'zoom' => ['nullable', 'numeric', 'min:0', 'max:'.self::ZOOM_MAX],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Zoom in Prozent (100 bis 250); ungültig oder ohne Angabe 100. */
|
||||||
|
public static function zoom(mixed $value): int
|
||||||
|
{
|
||||||
|
return is_numeric($value) ? (int) round(max(self::ZOOM_MIN, min(self::ZOOM_MAX, (float) $value))) : self::ZOOM_MIN;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Fokuspunkt in Prozent, ohne Angabe der Vorgabe. */
|
||||||
|
public static function percent(mixed $value, int $default = self::FOCUS_DEFAULT): int
|
||||||
|
{
|
||||||
|
return is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Speicherform: der Zoom nur, wenn er über 100 % liegt (Widgets ohne Zoom bleiben byteweise wie zuvor).
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $data
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public static function cleanZoom(array $data): array
|
||||||
|
{
|
||||||
|
$zoom = self::zoom($data['zoom'] ?? null);
|
||||||
|
|
||||||
|
if ($zoom > self::ZOOM_MIN) {
|
||||||
|
$data['zoom'] = $zoom;
|
||||||
|
} else {
|
||||||
|
unset($data['zoom']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ausschnitt einer Karte in der Speicherform: Schlüssel nur, wenn sie von der Vorgabe (Mitte, 100 %) abweichen.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $item
|
||||||
|
* @return array<string, int>
|
||||||
|
*/
|
||||||
|
public static function cleanItem(array $item): array
|
||||||
|
{
|
||||||
|
$out = [];
|
||||||
|
|
||||||
|
foreach (['focus_x', 'focus_y'] as $key) {
|
||||||
|
$value = self::percent($item[$key] ?? null);
|
||||||
|
|
||||||
|
if ($value !== self::FOCUS_DEFAULT) {
|
||||||
|
$out[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$zoom = self::zoom($item['zoom'] ?? null);
|
||||||
|
|
||||||
|
if ($zoom > self::ZOOM_MIN) {
|
||||||
|
$out['zoom'] = $zoom;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inline-Stil am Bild einer Karte, nur wenn etwas von der Vorgabe abweicht (sonst null: Ausgabe unverändert).
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $item
|
||||||
|
*/
|
||||||
|
public static function itemStyle(array $item): ?string
|
||||||
|
{
|
||||||
|
$x = self::percent($item['focus_x'] ?? null);
|
||||||
|
$y = self::percent($item['focus_y'] ?? null);
|
||||||
|
$zoom = self::zoom($item['zoom'] ?? null);
|
||||||
|
|
||||||
|
if ($x === self::FOCUS_DEFAULT && $y === self::FOCUS_DEFAULT && $zoom === self::ZOOM_MIN) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'object-position: '.$x.'% '.$y.'%'.($zoom > self::ZOOM_MIN ? '; transform-origin: '.$x.'% '.$y.'%; scale: '.round($zoom / 100, 2) : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `sizes` für `srcset`: Bei Zoom wird ein Teil des Bilds auf die Rahmenbreite vergrößert, der Browser soll deshalb eine
|
||||||
|
* größere Fassung holen.
|
||||||
|
*/
|
||||||
|
public static function sizes(string $sizes, int $zoom): string
|
||||||
|
{
|
||||||
|
if ($zoom <= self::ZOOM_MIN) {
|
||||||
|
return $sizes;
|
||||||
|
}
|
||||||
|
|
||||||
|
$factor = round($zoom / 100, 2);
|
||||||
|
|
||||||
|
return (string) preg_replace_callback('/(\d+(?:\.\d+)?)vw/', fn (array $m): string => 'calc('.$m[1].'vw * '.$factor.')', $sizes);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,9 +37,7 @@ public static function rules(): array
|
|||||||
'cta2_label' => ['nullable', 'string', 'max:80', 'required_with:data.cta2_url'],
|
'cta2_label' => ['nullable', 'string', 'max:80', 'required_with:data.cta2_url'],
|
||||||
'cta2_url' => ['nullable', 'string', 'max:500', 'required_with:data.cta2_label'],
|
'cta2_url' => ['nullable', 'string', 'max:500', 'required_with:data.cta2_label'],
|
||||||
'alt' => ['nullable', 'string', 'max:300'],
|
'alt' => ['nullable', 'string', 'max:300'],
|
||||||
'focus_x' => ['nullable', 'numeric', 'between:0,100'],
|
] + ImageFraming::rules();
|
||||||
'focus_y' => ['nullable', 'numeric', 'between:0,100'],
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function eyebrowField(): TextInput
|
public static function eyebrowField(): TextInput
|
||||||
@@ -67,29 +65,13 @@ public static function ctaFields(): Grid
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Fokus waagerecht und senkrecht sowie Zoom (ImageFraming).
|
||||||
|
*
|
||||||
* @return list<Slider>
|
* @return list<Slider>
|
||||||
*/
|
*/
|
||||||
public static function focusFields(int $defaultX = 50, int $defaultY = 50): array
|
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.
|
return ImageFraming::sliders($defaultX, $defaultY);
|
||||||
$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
|
public static function altField(): TextInput
|
||||||
@@ -124,7 +106,7 @@ public static function clean(array $data, WidgetErrors $errors, bool $hasImage):
|
|||||||
$data[$key] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
$data[$key] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $data;
|
return ImageFraming::cleanZoom($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,6 +141,12 @@ public static function focus(array $data, int $defaultX = 50, int $defaultY = 50
|
|||||||
return ['x' => $clamp($data['focus_x'] ?? null, $defaultX), 'y' => $clamp($data['focus_y'] ?? null, $defaultY)];
|
return ['x' => $clamp($data['focus_x'] ?? null, $defaultX), 'y' => $clamp($data['focus_y'] ?? null, $defaultY)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Zoom in Prozent (100 bis 250); ohne Angabe 100. */
|
||||||
|
public static function zoom(array $data): int
|
||||||
|
{
|
||||||
|
return ImageFraming::zoom($data['zoom'] ?? null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Übersetzt den früheren Fokuspunkt (Aufzählung wie beim Abschnittshintergrund) in Prozentwerte.
|
* Übersetzt den früheren Fokuspunkt (Aufzählung wie beim Abschnittshintergrund) in Prozentwerte.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
final class RichText
|
final class RichText
|
||||||
{
|
{
|
||||||
/** Werkzeugleiste des Editors; muss zur Erlaubnisliste unten passen. */
|
/** Werkzeugleiste des Editors; muss zur Erlaubnisliste unten passen. */
|
||||||
public const TOOLBAR = [['bold', 'italic', 'link', 'interneSeite'], ['bulletList', 'orderedList'], ['undo', 'redo']];
|
public const TOOLBAR = [['bold', 'italic', 'link', 'interneSeite'], ['bulletList', 'orderedList'], ['absatzSymbol', 'listenStil'], ['undo', 'redo']];
|
||||||
|
|
||||||
private static ?HtmlSanitizer $sanitizer = null;
|
private static ?HtmlSanitizer $sanitizer = null;
|
||||||
|
|
||||||
@@ -22,7 +22,8 @@ public static function sanitize(?string $html): string
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return trim(self::sanitizer()->sanitize($html));
|
// Zeichen vor Absätzen und in Listen (ADR-69) bleiben nur mit bekannten Schlüsseln erhalten.
|
||||||
|
return TextMarkers::clean(trim(self::sanitizer()->sanitize($html)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,14 +61,14 @@ private static function sanitizer(): HtmlSanitizer
|
|||||||
{
|
{
|
||||||
return self::$sanitizer ??= new HtmlSanitizer(
|
return self::$sanitizer ??= new HtmlSanitizer(
|
||||||
(new HtmlSanitizerConfig)
|
(new HtmlSanitizerConfig)
|
||||||
->allowElement('p')
|
->allowElement('p', TextMarkers::PARAGRAPH_ATTRIBUTES)
|
||||||
->allowElement('br')
|
->allowElement('br')
|
||||||
->allowElement('strong')
|
->allowElement('strong')
|
||||||
->allowElement('b')
|
->allowElement('b')
|
||||||
->allowElement('em')
|
->allowElement('em')
|
||||||
->allowElement('i')
|
->allowElement('i')
|
||||||
->allowElement('ul')
|
->allowElement('ul', TextMarkers::LIST_ATTRIBUTES)
|
||||||
->allowElement('ol')
|
->allowElement('ol', TextMarkers::LIST_ATTRIBUTES)
|
||||||
->allowElement('li')
|
->allowElement('li')
|
||||||
->allowElement('a', ['href'])
|
->allowElement('a', ['href'])
|
||||||
->allowLinkSchemes(['http', 'https', 'mailto'])
|
->allowLinkSchemes(['http', 'https', 'mailto'])
|
||||||
|
|||||||
@@ -0,0 +1,221 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Cms\Widgets\Support;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\FormattedText;
|
||||||
|
use App\Domain\Design\DesignPalette;
|
||||||
|
use App\Support\Brand\SymbolCatalog;
|
||||||
|
use App\Support\Brand\Symbols;
|
||||||
|
use Dom\Element;
|
||||||
|
use Dom\HTMLDocument;
|
||||||
|
use Dom\Node;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zeichen im formatierten Text der Website (ADR-69): ein Symbol vor einem Absatz, Nummern im farbigen Kreis, Symbole statt
|
||||||
|
* Aufzählungspunkten. Gespeichert werden nur Schlüssel im bereinigten HTML:
|
||||||
|
*
|
||||||
|
* - `<p data-symbol="haken">` (nur Absätze auf der obersten Ebene des Texts),
|
||||||
|
* - `<ol data-marker="circle" data-tone="c1">` (Zahl im Kreis, Farbe aus der Palette oder eine der Markenfarben),
|
||||||
|
* - `<ul data-marker="symbol" data-symbol="haken">`.
|
||||||
|
*
|
||||||
|
* Was nicht zu einem bekannten Schlüssel passt, entfällt beim Speichern. Bilder und Farben stehen nie im gespeicherten
|
||||||
|
* Text: {@see self::decorate()} setzt sie erst bei der Ausgabe ein, die Farbe wird dabei aus der Palette gelesen. Eine
|
||||||
|
* Farbe, die es nicht mehr gibt, fällt auf die Vorgabe zurück.
|
||||||
|
*/
|
||||||
|
final class TextMarkers
|
||||||
|
{
|
||||||
|
/** Attribute, die das Webprofil der Bereinigung an Absätzen und Listen zulässt. */
|
||||||
|
public const PARAGRAPH_ATTRIBUTES = ['data-symbol'];
|
||||||
|
|
||||||
|
public const LIST_ATTRIBUTES = ['data-marker', 'data-symbol', 'data-tone'];
|
||||||
|
|
||||||
|
/** Zeichen der Listen: Nummern im Kreis (geordnet) und Symbol (Aufzählung). */
|
||||||
|
public const MARKER_CIRCLE = 'circle';
|
||||||
|
|
||||||
|
public const MARKER_SYMBOL = 'symbol';
|
||||||
|
|
||||||
|
/** Vorgabefarbe, wenn eine Farbe fehlt oder nicht mehr besteht. */
|
||||||
|
public const DEFAULT_TONE = 'dark';
|
||||||
|
|
||||||
|
/** Die Markenflächen, die neben der Palette als Farbe der Kreise angeboten werden. */
|
||||||
|
private const BRAND_TONES = ['dark', 'accent'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ein gültiger Symbolschlüssel oder null.
|
||||||
|
*/
|
||||||
|
public static function symbol(mixed $value): ?string
|
||||||
|
{
|
||||||
|
return is_string($value) && in_array($value, SymbolCatalog::keys(), true) ? $value : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Farben für die Kreise: Schlüssel => Anzeigename, Fläche, Schrift. Zuerst die Markenfarben, dann die Palette.
|
||||||
|
*
|
||||||
|
* @return array<string, array{label: string, bg: string, fg: string}>
|
||||||
|
*/
|
||||||
|
public static function tones(): array
|
||||||
|
{
|
||||||
|
$tones = [];
|
||||||
|
|
||||||
|
foreach (DesignPalette::builtIns() as $built) {
|
||||||
|
if (in_array($built['key'], self::BRAND_TONES, true)) {
|
||||||
|
$tones[$built['key']] = ['label' => $built['label'], 'bg' => $built['bg'], 'fg' => $built['fg']];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (DesignPalette::slots() as $slot) {
|
||||||
|
$tones[$slot['id']] = ['label' => $slot['name'], 'bg' => $slot['bg'], 'fg' => $slot['fg']];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tones;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die gültigen Attribute eines Absatzes oder einer Liste als Text für das Anfangs-Tag (mit führendem Leerzeichen);
|
||||||
|
* leer, wenn nichts Gültiges übrig bleibt. Die Reihenfolge ist fest, damit die kanonische Form stabil bleibt.
|
||||||
|
*/
|
||||||
|
public static function attributes(string $tag, Element $node): string
|
||||||
|
{
|
||||||
|
if ($tag === 'p') {
|
||||||
|
// Das Symbol steht nur vor einem Absatz des Texts, nicht in Liste, Zitat oder Tabelle.
|
||||||
|
$symbol = $node->parentNode !== null && strtolower($node->parentNode->nodeName) === 'body'
|
||||||
|
? self::symbol($node->getAttribute('data-symbol'))
|
||||||
|
: null;
|
||||||
|
|
||||||
|
return $symbol === null ? '' : ' data-symbol="'.$symbol.'"';
|
||||||
|
}
|
||||||
|
|
||||||
|
$marker = (string) $node->getAttribute('data-marker');
|
||||||
|
$symbol = self::symbol($node->getAttribute('data-symbol'));
|
||||||
|
$tone = (string) $node->getAttribute('data-tone');
|
||||||
|
$tone = array_key_exists($tone, self::tones()) ? $tone : null;
|
||||||
|
|
||||||
|
if ($tag === 'ol' && $marker === self::MARKER_CIRCLE) {
|
||||||
|
return ' data-marker="circle"'.($tone !== null ? ' data-tone="'.$tone.'"' : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($tag === 'ul' && $marker === self::MARKER_SYMBOL && $symbol !== null) {
|
||||||
|
return ' data-marker="symbol" data-symbol="'.$symbol.'"';
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Führt die Attribute eines bereits bereinigten HTML auf gültige Werte zurück (für Texte, die nicht die kanonische
|
||||||
|
* Form von {@see FormattedText} durchlaufen, zum Beispiel „Bild und Text“).
|
||||||
|
*/
|
||||||
|
public static function clean(string $html): string
|
||||||
|
{
|
||||||
|
if (! str_contains($html, 'data-')) {
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
$document = HTMLDocument::createFromString('<body>'.$html.'</body>', LIBXML_NOERROR);
|
||||||
|
|
||||||
|
foreach ($document->querySelectorAll('p, ul, ol') as $node) {
|
||||||
|
$tag = strtolower($node->nodeName);
|
||||||
|
$allowed = [];
|
||||||
|
|
||||||
|
if (preg_match_all('/ ([a-z-]+)="([^"]*)"/', self::attributes($tag, $node), $found, PREG_SET_ORDER) > 0) {
|
||||||
|
foreach ($found as $pair) {
|
||||||
|
$allowed[$pair[1]] = $pair[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (['data-marker', 'data-symbol', 'data-tone'] as $name) {
|
||||||
|
$node->removeAttribute($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($allowed as $name => $value) {
|
||||||
|
$node->setAttribute($name, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return trim($document->body->innerHTML);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setzt die Zeichen bei der Ausgabe ein: Symbol vor dem Absatz, Kreis um die Nummer (Farbe aus der Palette), Symbol
|
||||||
|
* statt Aufzählungspunkt. Ein Text ohne Zeichen bleibt unverändert.
|
||||||
|
*/
|
||||||
|
public static function decorate(string $html): string
|
||||||
|
{
|
||||||
|
if (! str_contains($html, 'data-symbol') && ! str_contains($html, 'data-marker')) {
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
$document = HTMLDocument::createFromString('<body>'.$html.'</body>', LIBXML_NOERROR);
|
||||||
|
$tones = self::tones();
|
||||||
|
|
||||||
|
foreach (iterator_to_array($document->querySelectorAll('p[data-symbol]')) as $paragraph) {
|
||||||
|
$symbol = self::symbol($paragraph->getAttribute('data-symbol'));
|
||||||
|
|
||||||
|
if ($symbol === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$paragraph->setAttribute('class', 'has-symbol');
|
||||||
|
$paragraph->insertBefore(self::symbolNode($document, $symbol, 'text-symbol'), $paragraph->firstChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (iterator_to_array($document->querySelectorAll('ol[data-marker="circle"]')) as $list) {
|
||||||
|
$tone = $tones[(string) $list->getAttribute('data-tone')] ?? $tones[self::DEFAULT_TONE] ?? ['bg' => '#032551', 'fg' => '#f4f6f8'];
|
||||||
|
$list->setAttribute('class', 'text-list-circle');
|
||||||
|
$list->setAttribute('style', '--tone-bg: '.$tone['bg'].'; --tone-fg: '.$tone['fg']);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (iterator_to_array($document->querySelectorAll('ul[data-marker="symbol"]')) as $list) {
|
||||||
|
$symbol = self::symbol($list->getAttribute('data-symbol'));
|
||||||
|
|
||||||
|
if ($symbol === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$list->setAttribute('class', 'text-list-symbol');
|
||||||
|
|
||||||
|
foreach ($list->childNodes as $item) {
|
||||||
|
if ($item->nodeType === XML_ELEMENT_NODE && strtolower($item->nodeName) === 'li') {
|
||||||
|
$item->insertBefore(self::symbolNode($document, $symbol, 'text-list-symbol__mark'), $item->firstChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return trim($document->body->innerHTML);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Kennungen der Palettenfarben, auf die ein Widget in seinen Texten verweist (je Farbe einmal).
|
||||||
|
*
|
||||||
|
* @param array<mixed> $data
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public static function tonesIn(array $data): array
|
||||||
|
{
|
||||||
|
$found = [];
|
||||||
|
|
||||||
|
array_walk_recursive($data, function (mixed $value) use (&$found): void {
|
||||||
|
if (is_string($value) && str_contains($value, 'data-tone') && preg_match_all('/data-tone="([a-z0-9]+)"/', $value, $matches) > 0) {
|
||||||
|
array_push($found, ...$matches[1]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return array_values(array_unique($found));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function symbolNode(HTMLDocument $document, string $symbol, string $class): Node
|
||||||
|
{
|
||||||
|
$span = $document->createElement('span');
|
||||||
|
$span->setAttribute('class', $class);
|
||||||
|
$span->setAttribute('aria-hidden', 'true');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$span->innerHTML = (string) Symbols::symbol($symbol);
|
||||||
|
} catch (Throwable) {
|
||||||
|
// Ein Symbol, das es nicht mehr gibt, lässt nur den Platz leer; der Text bleibt lesbar.
|
||||||
|
}
|
||||||
|
|
||||||
|
return $span;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -86,7 +86,7 @@ public function elementId(mixed $value): ?int
|
|||||||
return is_int($id) ? $id : null;
|
return is_int($id) ? $id : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function presentation(mixed $value): ?WebsitePresentation
|
public function presentation(mixed $value, ?ContentElement $loaded = null): ?WebsitePresentation
|
||||||
{
|
{
|
||||||
$id = $this->elementId($value);
|
$id = $this->elementId($value);
|
||||||
|
|
||||||
@@ -95,7 +95,8 @@ public function presentation(mixed $value): ?WebsitePresentation
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! array_key_exists($id, $this->presentations)) {
|
if (! array_key_exists($id, $this->presentations)) {
|
||||||
$this->presentations[$id] = $this->media->present($id) ?? false;
|
// Ein schon geladenes Medium wird weitergereicht (kein zweiter Zugriff je Eintrag in der Auswahl).
|
||||||
|
$this->presentations[$id] = $this->media->present($loaded?->getKey() === $id ? $loaded : $id) ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->presentations[$id] ?: null;
|
return $this->presentations[$id] ?: null;
|
||||||
@@ -105,12 +106,12 @@ public function presentation(mixed $value): ?WebsitePresentation
|
|||||||
* Bildadresse für die Darstellung. Öffentlich nur freigegebene Medien (oder frühere CMS-Bilder ohne Zuordnung);
|
* 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.
|
* in der Redaktionsvorschau zusätzlich das Vorschaubild eines nicht freigegebenen Mediums.
|
||||||
*/
|
*/
|
||||||
public function url(mixed $value, bool $preview = false): ?string
|
public function url(mixed $value, bool $preview = false, ?int $width = null): ?string
|
||||||
{
|
{
|
||||||
$presentation = $this->presentation($value);
|
$presentation = $this->presentation($value);
|
||||||
|
|
||||||
if ($presentation !== null) {
|
if ($presentation !== null) {
|
||||||
return $presentation->kind === 'bild' ? $presentation->url : null;
|
return $presentation->kind === 'bild' ? $presentation->urlForWidth($width) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $this->elementId($value);
|
$id = $this->elementId($value);
|
||||||
@@ -122,7 +123,7 @@ public function url(mixed $value, bool $preview = false): ?string
|
|||||||
|
|
||||||
$element = ContentElement::query()->find($id);
|
$element = ContentElement::query()->find($id);
|
||||||
|
|
||||||
return $element === null ? null : ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
return $element === null ? null : ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
}
|
}
|
||||||
|
|
||||||
$legacy = self::normalize($value);
|
$legacy = self::normalize($value);
|
||||||
@@ -134,6 +135,14 @@ public function url(mixed $value, bool $preview = false): ?string
|
|||||||
return is_string($legacy) ? PublicMedia::url($legacy) : null;
|
return is_string($legacy) ? PublicMedia::url($legacy) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** `srcset` des freigegebenen Bildes (mehrere Breiten), sonst null. Für Hero, Bild mit Text, Karten. */
|
||||||
|
public function srcset(mixed $value): ?string
|
||||||
|
{
|
||||||
|
$presentation = $this->presentation($value);
|
||||||
|
|
||||||
|
return $presentation !== null && $presentation->kind === 'bild' ? $presentation->srcset : null;
|
||||||
|
}
|
||||||
|
|
||||||
/** Alternativtext: Angabe im Widget, sonst der Alternativtext des Mediums. */
|
/** Alternativtext: Angabe im Widget, sonst der Alternativtext des Mediums. */
|
||||||
public function alt(mixed $value, mixed $override = null): string
|
public function alt(mixed $value, mixed $override = null): string
|
||||||
{
|
{
|
||||||
@@ -169,7 +178,7 @@ public function previewNotice(mixed $value, string $label = 'Das gewählte Bild'
|
|||||||
*
|
*
|
||||||
* @return array{public: bool, state: string, title: string, note: string, thumb: ?string, manageUrl: ?string}|null
|
* @return array{public: bool, state: string, title: string, note: string, thumb: ?string, manageUrl: ?string}|null
|
||||||
*/
|
*/
|
||||||
public function status(mixed $value): ?array
|
public function status(mixed $value, ?ContentElement $loaded = null): ?array
|
||||||
{
|
{
|
||||||
$value = self::normalize($value);
|
$value = self::normalize($value);
|
||||||
|
|
||||||
@@ -194,16 +203,16 @@ public function status(mixed $value): ?array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$element = ContentElement::query()->with('editorialContentKind')->find($id);
|
$element = $loaded?->getKey() === $id ? $loaded : ContentElement::query()->with('editorialContentKind')->find($id);
|
||||||
|
|
||||||
if ($element === null) {
|
if ($element === null) {
|
||||||
return ['public' => false, 'state' => 'missing', 'title' => 'Medium '.$id, 'note' => 'Das Medium gibt es nicht mehr.', 'thumb' => null, 'manageUrl' => 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);
|
$title = (string) ($element->display_title ?: $element->working_title);
|
||||||
$thumb = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
$thumb = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at);
|
||||||
$manageUrl = ContentElementResource::getUrl('view', ['record' => $element]);
|
$manageUrl = ContentElementResource::getUrl('view', ['record' => $element]);
|
||||||
$public = $this->presentation($id) !== null;
|
$public = $this->presentation($id, $element) !== null;
|
||||||
|
|
||||||
$note = match (true) {
|
$note = match (true) {
|
||||||
$public => 'Für die Website freigegeben.',
|
$public => 'Für die Website freigegeben.',
|
||||||
@@ -292,7 +301,7 @@ public function options(?string $search = null, int $limit = 60): array
|
|||||||
$options = [];
|
$options = [];
|
||||||
foreach ($elements as $element) {
|
foreach ($elements as $element) {
|
||||||
if (self::isSelectable($element)) {
|
if (self::isSelectable($element)) {
|
||||||
$options[$element->id] = $this->optionHtml($element->id);
|
$options[$element->id] = $this->optionHtml($element->id, $element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,9 +309,9 @@ public function options(?string $search = null, int $limit = 60): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** HTML-Bezeichnung einer Option oder des gewählten Werts (auch für frühere Pfade). */
|
/** HTML-Bezeichnung einer Option oder des gewählten Werts (auch für frühere Pfade). */
|
||||||
public function optionHtml(mixed $value): ?string
|
public function optionHtml(mixed $value, ?ContentElement $loaded = null): ?string
|
||||||
{
|
{
|
||||||
$status = $this->status($value);
|
$status = $this->status($value, $loaded);
|
||||||
|
|
||||||
if ($status === null) {
|
if ($status === null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -315,7 +324,7 @@ public function optionHtml(mixed $value): ?string
|
|||||||
default => ['warn', 'Website: nicht freigegeben'],
|
default => ['warn', 'Website: nicht freigegeben'],
|
||||||
};
|
};
|
||||||
$thumb = $status['thumb'] !== null
|
$thumb = $status['thumb'] !== null
|
||||||
? '<img src="'.e($status['thumb']).'" alt="" loading="lazy">'
|
? '<img src="'.e($status['thumb']).'" alt="" loading="lazy" decoding="async">'
|
||||||
: '<span class="luf-media-option-empty" aria-hidden="true"></span>';
|
: '<span class="luf-media-option-empty" aria-hidden="true"></span>';
|
||||||
|
|
||||||
return '<span class="luf-media-option">'.$thumb
|
return '<span class="luf-media-option">'.$thumb
|
||||||
|
|||||||
@@ -0,0 +1,143 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Cms\Widgets\Support;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
|
use App\Domain\Design\ColorContrast;
|
||||||
|
use App\Domain\Design\DesignPalette;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gemeinsame Darstellungseinstellungen aller Widgets (ADR-68): Größe der Überschrift, Größe des beschreibenden Texts und
|
||||||
|
* Farbe aus der zentralen Palette. Jede Art erklärt in WidgetType, welche davon sie anbietet (typography(), paletteTarget());
|
||||||
|
* gespeichert werden sie wie jede Einstellung unter settings.
|
||||||
|
*
|
||||||
|
* - Die Größen sind eine einzige, absolute Skala der Designwerte (tokens.css): „Klein“ ist überall dieselbe Größe, egal in welchem
|
||||||
|
* Widget. Ohne Wahl gilt unverändert die bisherige Größe des Widgets, so bleibt die Ausgabe bestehender Seiten gleich.
|
||||||
|
* - Die Farbe verweist auf eine Farbe der Palette (Kennung), nie auf einen Farbwert. Eine nicht mehr vorhandene Farbe fällt beim
|
||||||
|
* Darstellen auf „ohne Farbe“ zurück und wirft nie einen Fehler.
|
||||||
|
* - Die Ausgabe trägt Klassen und gegebenenfalls ein style-Attribut nur dann, wenn ein Wert gesetzt ist.
|
||||||
|
*/
|
||||||
|
final class WidgetAppearance
|
||||||
|
{
|
||||||
|
/** Größen der Überschrift: Schlüssel => Bezeichnung. Abgebildet auf --text-h3, -h2, -h1 und -display. */
|
||||||
|
public const HEADING = ['small' => 'Klein', 'medium' => 'Mittel', 'large' => 'Groß', 'xlarge' => 'Sehr groß'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Größen des beschreibenden Texts. Nach unten gibt es bewusst keine Stufe: Fließtext bleibt mindestens so groß wie die
|
||||||
|
* Grundschrift (Untergrenze 16 px, tokens.css). „Normal“ ist --text-body, „Groß“ --text-lede.
|
||||||
|
*/
|
||||||
|
public const TEXT = ['normal' => 'Normal', 'large' => 'Groß', 'xlarge' => 'Sehr groß'];
|
||||||
|
|
||||||
|
public const HEADING_LABEL = ['Größe der Überschrift', 'Eine feste Stufe der Designgrößen: Klein, Mittel, Groß, Sehr groß sind in jedem Widget gleich groß. Ohne Wahl bleibt die bisherige Größe des Widgets. Bei wenig Platz wird die Überschrift automatisch verkleinert, damit sie nicht überläuft.'];
|
||||||
|
|
||||||
|
public const TEXT_LABEL = ['Größe des Beschreibungstexts', 'Normal entspricht dem Fließtext der Seite, Groß der Einleitung, Sehr groß noch einmal darüber. Ohne Wahl bleibt die bisherige Größe des Widgets. Kleiner als der Fließtext ist bewusst nicht möglich (Lesbarkeit).'];
|
||||||
|
|
||||||
|
public const PALETTE_LABEL = ['Farbe', 'Eine Farbe aus der zentralen Palette. Schrift, Links und Symbole richten sich nach der Farbe. Ohne Wahl bleibt die Fläche des Abschnitts.'];
|
||||||
|
|
||||||
|
public const KEYS = ['heading_size', 'text_size', 'palette'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zusätzliche Einstellungen einer Art: Schlüssel => [Wert => Bezeichnung]. Die Farbauswahl ist die aktuelle Palette.
|
||||||
|
*
|
||||||
|
* @return array<string, array<string, string>>
|
||||||
|
*/
|
||||||
|
public static function options(WidgetType $type): array
|
||||||
|
{
|
||||||
|
$options = [];
|
||||||
|
|
||||||
|
if (in_array('heading', $type->typography(), true)) {
|
||||||
|
$options['heading_size'] = self::HEADING;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array('text', $type->typography(), true)) {
|
||||||
|
$options['text_size'] = self::TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type->paletteTarget() !== null) {
|
||||||
|
$options['palette'] = array_column(DesignPalette::slots(), 'name', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Klassen an der Hülle des Widgets, mit führendem Leerzeichen; leer, wenn nichts gesetzt ist.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $widget Hülle der Instanz (variant, settings)
|
||||||
|
*/
|
||||||
|
public static function classes(WidgetType $type, array $widget): string
|
||||||
|
{
|
||||||
|
$settings = is_array($widget['settings'] ?? null) ? $widget['settings'] : [];
|
||||||
|
$classes = [];
|
||||||
|
|
||||||
|
$heading = self::valid($settings, 'heading_size', self::HEADING, 'heading', $type);
|
||||||
|
if ($heading !== null) {
|
||||||
|
$classes[] = 'widget-hs widget-hs-'.$heading;
|
||||||
|
}
|
||||||
|
|
||||||
|
$text = self::valid($settings, 'text_size', self::TEXT, 'text', $type);
|
||||||
|
if ($text !== null) {
|
||||||
|
$classes[] = 'widget-ts widget-ts-'.$text;
|
||||||
|
}
|
||||||
|
|
||||||
|
$slot = self::slot($type, $widget);
|
||||||
|
if ($slot !== null) {
|
||||||
|
$classes[] = 'widget-palette widget-palette--'.$type->paletteTarget($widget);
|
||||||
|
|
||||||
|
// Dunkel oder hell steht immer ausdrücklich an der Hülle: Ein helles Widget in einem dunklen Abschnitt darf die
|
||||||
|
// Regeln der dunklen Fläche nicht erben (scope-light ist dafür die Gegenmarke, siehe widgets.css).
|
||||||
|
$classes[] = ColorContrast::isDarkSurface($slot['fg'], $slot['bg']) ? 'scope-dark' : 'scope-light';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $classes === [] ? '' : ' '.implode(' ', $classes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eigenschaften der Farbe als style-Attribut mit führendem Leerzeichen; leer ohne Farbe.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $widget Hülle der Instanz (variant, settings)
|
||||||
|
*/
|
||||||
|
public static function style(WidgetType $type, array $widget): string
|
||||||
|
{
|
||||||
|
$slot = self::slot($type, $widget);
|
||||||
|
|
||||||
|
if ($slot === null) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$style = '';
|
||||||
|
foreach (ColorContrast::surfaceProperties($slot['bg'], $slot['fg']) as $property => $value) {
|
||||||
|
$style .= '--'.$property.': '.e($value).'; ';
|
||||||
|
}
|
||||||
|
|
||||||
|
return ' style="'.rtrim($style).'"';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die gewählte Farbe, wenn die Art sie anbietet und sie in der Palette noch vorhanden ist.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $widget Hülle der Instanz (variant, settings)
|
||||||
|
* @return array{id: string, name: string, bg: string, fg: string}|null
|
||||||
|
*/
|
||||||
|
public static function slot(WidgetType $type, array $widget): ?array
|
||||||
|
{
|
||||||
|
$id = is_array($widget['settings'] ?? null) ? ($widget['settings']['palette'] ?? null) : null;
|
||||||
|
|
||||||
|
if ($type->paletteTarget($widget) === null || ! is_string($id)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DesignPalette::find($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $settings
|
||||||
|
* @param array<string, string> $allowed
|
||||||
|
*/
|
||||||
|
private static function valid(array $settings, string $key, array $allowed, string $kind, WidgetType $type): ?string
|
||||||
|
{
|
||||||
|
$value = $settings[$key] ?? null;
|
||||||
|
|
||||||
|
return in_array($kind, $type->typography(), true) && is_string($value) && array_key_exists($value, $allowed) ? $value : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,18 @@
|
|||||||
|
|
||||||
class CallToActionWidget extends WidgetType
|
class CallToActionWidget extends WidgetType
|
||||||
{
|
{
|
||||||
|
/** Größe von Überschrift und beschreibendem Text wählbar (ADR-68). */
|
||||||
|
public function typography(): array
|
||||||
|
{
|
||||||
|
return ['heading', 'text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Farbe aus der Palette wirkt auf die eigene Fläche des Widgets (ADR-68). */
|
||||||
|
public function paletteTarget(array $widget = []): ?string
|
||||||
|
{
|
||||||
|
return 'face';
|
||||||
|
}
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
{
|
{
|
||||||
return 'call_to_action';
|
return 'call_to_action';
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
use App\Domain\Catalog\FormattedText;
|
use App\Domain\Catalog\FormattedText;
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
use App\Domain\Cms\Widgets\Support\HeadingAccent;
|
use App\Domain\Cms\Widgets\Support\HeadingAccent;
|
||||||
|
use App\Domain\Cms\Widgets\Support\ImageFraming;
|
||||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||||
use App\Domain\Cms\Widgets\Support\LinkField;
|
use App\Domain\Cms\Widgets\Support\LinkField;
|
||||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||||
@@ -75,6 +76,23 @@ public function version(): int
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Größe von Überschrift und beschreibendem Text wählbar (ADR-68). */
|
||||||
|
public function typography(): array
|
||||||
|
{
|
||||||
|
return ['heading', 'text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Farbe aus der Palette (ADR-68): Karten mit eigener Fläche nehmen die Farbe selbst an. Die kompakte Liste und Karten mit
|
||||||
|
* Trennstrich haben keine Fläche; dort färbt die Farbe das ganze Widget, sonst stünde helle Schrift auf hellem Grund.
|
||||||
|
*/
|
||||||
|
public function paletteTarget(array $widget = []): ?string
|
||||||
|
{
|
||||||
|
$flat = ($widget['variant'] ?? null) === 'compact' || ($widget['settings']['divider'] ?? null) === 'line';
|
||||||
|
|
||||||
|
return $flat ? 'hull' : 'face';
|
||||||
|
}
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
{
|
{
|
||||||
return 'cards';
|
return 'cards';
|
||||||
@@ -144,6 +162,9 @@ public function dataRules(): array
|
|||||||
'items.*.symbol' => ['nullable', 'string', Rule::in(array_keys(HeadingAccent::symbols()))],
|
'items.*.symbol' => ['nullable', 'string', Rule::in(array_keys(HeadingAccent::symbols()))],
|
||||||
'items.*.image' => ['nullable'],
|
'items.*.image' => ['nullable'],
|
||||||
'items.*._upload' => ['nullable'],
|
'items.*._upload' => ['nullable'],
|
||||||
|
'items.*.focus_x' => ImageFraming::rules()['focus_x'],
|
||||||
|
'items.*.focus_y' => ImageFraming::rules()['focus_y'],
|
||||||
|
'items.*.zoom' => ImageFraming::rules()['zoom'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,6 +235,7 @@ public function dataFields(): array
|
|||||||
$image,
|
$image,
|
||||||
$upload,
|
$upload,
|
||||||
$status,
|
$status,
|
||||||
|
...ImageFraming::sliders(visible: ImageFraming::whenImageChosen()),
|
||||||
])
|
])
|
||||||
->minItems(1)
|
->minItems(1)
|
||||||
->maxItems(12)
|
->maxItems(12)
|
||||||
@@ -277,6 +299,8 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
|||||||
...(filled($item['url'] ?? null) && filled($item['link_label'] ?? null) ? ['link_label' => trim((string) $item['link_label'])] : []),
|
...(filled($item['url'] ?? null) && filled($item['link_label'] ?? null) ? ['link_label' => trim((string) $item['link_label'])] : []),
|
||||||
...(filled($item['symbol'] ?? null) ? ['symbol' => $item['symbol']] : []),
|
...(filled($item['symbol'] ?? null) ? ['symbol' => $item['symbol']] : []),
|
||||||
'image' => $itemRefs['image'],
|
'image' => $itemRefs['image'],
|
||||||
|
// Bildausschnitt (ADR-70) nur, wenn er von der Vorgabe (Mitte, 100 %) abweicht und ein Bild da ist.
|
||||||
|
...($itemRefs['image'] !== null ? ImageFraming::cleanItem($item) : []),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,6 +326,9 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
'linkLabel' => filled($item['link_label'] ?? null) ? $item['link_label'] : self::DEFAULT_LINK_LABEL,
|
'linkLabel' => filled($item['link_label'] ?? null) ? $item['link_label'] : self::DEFAULT_LINK_LABEL,
|
||||||
'symbol' => HeadingAccent::symbol(['symbol' => $item['symbol'] ?? null]),
|
'symbol' => HeadingAccent::symbol(['symbol' => $item['symbol'] ?? null]),
|
||||||
'imageUrl' => $images->url($item['image'] ?? null, $context->preview),
|
'imageUrl' => $images->url($item['image'] ?? null, $context->preview),
|
||||||
|
'imageSrcset' => $images->srcset($item['image'] ?? null),
|
||||||
|
'imageStyle' => ImageFraming::itemStyle($item),
|
||||||
|
'imageSizes' => ImageFraming::sizes('(min-width: 900px) 40vw, 100vw', ImageFraming::zoom($item['zoom'] ?? null)),
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($context->preview && ($notice = $images->previewNotice($item['image'] ?? null, 'Das Bild der Karte „'.$item['title'].'“')) !== null) {
|
if ($context->preview && ($notice = $images->previewNotice($item['image'] ?? null, 'Das Bild der Karte „'.$item['title'].'“')) !== null) {
|
||||||
|
|||||||
@@ -22,6 +22,18 @@
|
|||||||
*/
|
*/
|
||||||
class CatalogCardsWidget extends WidgetType
|
class CatalogCardsWidget extends WidgetType
|
||||||
{
|
{
|
||||||
|
/** Größe von Überschrift und beschreibendem Text wählbar (ADR-68). */
|
||||||
|
public function typography(): array
|
||||||
|
{
|
||||||
|
return ['heading', 'text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Farbe aus der Palette wirkt auf die Fläche des ganzen Widgets (ADR-68). */
|
||||||
|
public function paletteTarget(array $widget = []): ?string
|
||||||
|
{
|
||||||
|
return 'hull';
|
||||||
|
}
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
{
|
{
|
||||||
return 'catalog_cards';
|
return 'catalog_cards';
|
||||||
|
|||||||
@@ -10,6 +10,18 @@
|
|||||||
|
|
||||||
class FaqWidget extends WidgetType
|
class FaqWidget extends WidgetType
|
||||||
{
|
{
|
||||||
|
/** Größe von Überschrift und beschreibendem Text wählbar (ADR-68). */
|
||||||
|
public function typography(): array
|
||||||
|
{
|
||||||
|
return ['heading', 'text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Farbe aus der Palette wirkt auf die Fläche des ganzen Widgets (ADR-68). */
|
||||||
|
public function paletteTarget(array $widget = []): ?string
|
||||||
|
{
|
||||||
|
return 'hull';
|
||||||
|
}
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
{
|
{
|
||||||
return 'faq';
|
return 'faq';
|
||||||
|
|||||||
@@ -62,6 +62,18 @@ public static function layout(array $settings): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Größe von Überschrift und beschreibendem Text wählbar (ADR-68). */
|
||||||
|
public function typography(): array
|
||||||
|
{
|
||||||
|
return ['heading', 'text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Farbe aus der Palette wirkt auf die Fläche des ganzen Widgets (ADR-68). */
|
||||||
|
public function paletteTarget(array $widget = []): ?string
|
||||||
|
{
|
||||||
|
return 'hull';
|
||||||
|
}
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
{
|
{
|
||||||
return 'features';
|
return 'features';
|
||||||
|
|||||||
@@ -27,6 +27,18 @@ public function version(): int
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Größe von Überschrift und beschreibendem Text wählbar (ADR-68). */
|
||||||
|
public function typography(): array
|
||||||
|
{
|
||||||
|
return ['heading', 'text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Farbe aus der Palette wirkt auf die Fläche des ganzen Widgets (ADR-68). */
|
||||||
|
public function paletteTarget(array $widget = []): ?string
|
||||||
|
{
|
||||||
|
return 'hull';
|
||||||
|
}
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
{
|
{
|
||||||
return 'heading';
|
return 'heading';
|
||||||
|
|||||||
@@ -30,6 +30,12 @@
|
|||||||
*/
|
*/
|
||||||
class HeroWidget extends WidgetType
|
class HeroWidget extends WidgetType
|
||||||
{
|
{
|
||||||
|
/** Größe von Überschrift und beschreibendem Text wählbar (ADR-68). */
|
||||||
|
public function typography(): array
|
||||||
|
{
|
||||||
|
return ['heading', 'text'];
|
||||||
|
}
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
{
|
{
|
||||||
return 'hero';
|
return 'hero';
|
||||||
@@ -214,11 +220,11 @@ public function editorSchema(): array
|
|||||||
|
|
||||||
public function mediaSchema(): array
|
public function mediaSchema(): array
|
||||||
{
|
{
|
||||||
[, , , , $alt, $focusX, $focusY] = $this->dataFields();
|
[, , , , $alt, $focusX, $focusY, $zoom] = $this->dataFields();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
Group::make($this->refFields())->statePath('refs'),
|
Group::make($this->refFields())->statePath('refs'),
|
||||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
Group::make([$alt, $focusX, $focusY, $zoom])->statePath('data'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,11 +256,13 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
return [
|
return [
|
||||||
'video' => $video,
|
'video' => $video,
|
||||||
'imageUrl' => $images->url($image, $context->preview),
|
'imageUrl' => $images->url($image, $context->preview),
|
||||||
|
'imageSrcset' => $images->srcset($image),
|
||||||
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
||||||
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||||
'actions' => $actions,
|
'actions' => $actions,
|
||||||
'action' => $actions[0] ?? null,
|
'action' => $actions[0] ?? null,
|
||||||
'focus' => PremiumFields::focus($widget['data'], 68, 50),
|
'focus' => PremiumFields::focus($widget['data'], 68, 50),
|
||||||
|
'zoom' => PremiumFields::zoom($widget['data']),
|
||||||
'accent' => in_array($widget['settings']['accent'] ?? null, ['underline', 'rays', 'none'], true) ? $widget['settings']['accent'] : 'underline',
|
'accent' => in_array($widget['settings']['accent'] ?? null, ['underline', 'rays', 'none'], true) ? $widget['settings']['accent'] : 'underline',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,13 @@
|
|||||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||||
use App\Domain\Cms\Widgets\Support\RichText;
|
use App\Domain\Cms\Widgets\Support\RichText;
|
||||||
|
use App\Domain\Cms\Widgets\Support\TextMarkers;
|
||||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
|
use App\Domain\Cms\Widgets\Support\WidgetAppearance;
|
||||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
use App\Filament\Support\InternalLinkPlugin;
|
use App\Filament\Support\InternalLinkPlugin;
|
||||||
|
use App\Filament\Support\TextMarksPlugin;
|
||||||
use Filament\Forms\Components\RichEditor;
|
use Filament\Forms\Components\RichEditor;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Components\ViewField;
|
use Filament\Forms\Components\ViewField;
|
||||||
@@ -34,6 +37,18 @@
|
|||||||
*/
|
*/
|
||||||
class ImageTextWidget extends WidgetType
|
class ImageTextWidget extends WidgetType
|
||||||
{
|
{
|
||||||
|
/** Größe von Überschrift und beschreibendem Text wählbar (ADR-68). */
|
||||||
|
public function typography(): array
|
||||||
|
{
|
||||||
|
return ['heading', 'text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Farbe aus der Palette wirkt auf die eigene Fläche des Widgets (ADR-68). */
|
||||||
|
public function paletteTarget(array $widget = []): ?string
|
||||||
|
{
|
||||||
|
return 'face';
|
||||||
|
}
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
{
|
{
|
||||||
return 'image_text';
|
return 'image_text';
|
||||||
@@ -141,6 +156,7 @@ public function settings(): array
|
|||||||
'symbol' => HeadingAccent::symbols(),
|
'symbol' => HeadingAccent::symbols(),
|
||||||
'symbol_size' => HeadingAccent::SIZE,
|
'symbol_size' => HeadingAccent::SIZE,
|
||||||
'symbol_align' => HeadingAccent::ALIGN,
|
'symbol_align' => HeadingAccent::ALIGN,
|
||||||
|
'fullscreen' => ['no' => 'Nicht anbieten', 'yes' => 'Anbieten'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,6 +164,7 @@ public function settingGroups(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'Aussehen' => ['surface', 'image_share', 'symbol', 'symbol_size', 'symbol_align'],
|
'Aussehen' => ['surface', 'image_share', 'symbol', 'symbol_size', 'symbol_align'],
|
||||||
|
'Bild und Video' => ['fullscreen'],
|
||||||
'Seitenstruktur' => ['heading_level'],
|
'Seitenstruktur' => ['heading_level'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -155,8 +172,9 @@ public function settingGroups(): array
|
|||||||
public function settingLabels(): array
|
public function settingLabels(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'surface' => ['Hintergrund des Widgets', 'Unabhängig vom Abschnittshintergrund. „Ohne eigene Fläche“ übernimmt den Abschnitt.'],
|
'surface' => ['Hintergrund des Widgets', 'Unabhängig vom Abschnittshintergrund. „Ohne eigene Fläche“ übernimmt den Abschnitt. Eine unter „Farbe“ gewählte Palettenfarbe hat Vorrang.'],
|
||||||
'image_share' => ['Bildanteil', 'Verhältnis von Bild und Text nebeneinander. Gilt erst ab 900 px Breite des Widgets; schmaler steht das Bild über dem Text. Ohne Auswahl bleibt es bei der bisherigen Verteilung (Text etwas breiter als das Bild). Ohne Text füllt das Bild die ganze Breite.'],
|
'image_share' => ['Bildanteil', 'Verhältnis von Bild und Text nebeneinander. Gilt erst ab 900 px Breite des Widgets; schmaler steht das Bild über dem Text. Ohne Auswahl bleibt es bei der bisherigen Verteilung (Text etwas breiter als das Bild). Ohne Text füllt das Bild die ganze Breite.'],
|
||||||
|
'fullscreen' => ['Vollbild für das Video', 'Bietet neben dem Video eine Schaltfläche „Vollbild“ an (auch am Handy, folgt der Neigerichtung des Geräts). Spielt weiterhin nur das freigegebene Video, nie den vollständigen Film. Gilt nur, wenn ein freigegebenes Video gewählt ist. Vorgabe: nicht anbieten.'],
|
||||||
'symbol' => HeadingAccent::SYMBOL_LABEL,
|
'symbol' => HeadingAccent::SYMBOL_LABEL,
|
||||||
'symbol_size' => HeadingAccent::SIZE_LABEL,
|
'symbol_size' => HeadingAccent::SIZE_LABEL,
|
||||||
'symbol_align' => HeadingAccent::ALIGN_LABEL,
|
'symbol_align' => HeadingAccent::ALIGN_LABEL,
|
||||||
@@ -223,7 +241,7 @@ public function dataFields(): array
|
|||||||
->label('Text')
|
->label('Text')
|
||||||
->helperText('Leer lassen, wenn nur das Bild gezeigt werden soll. Ohne Text, Überschrift, Label und Schaltflächen füllt das Bild die ganze Breite.')
|
->helperText('Leer lassen, wenn nur das Bild gezeigt werden soll. Ohne Text, Überschrift, Label und Schaltflächen füllt das Bild die ganze Breite.')
|
||||||
->live(onBlur: true)
|
->live(onBlur: true)
|
||||||
->plugins([new InternalLinkPlugin])
|
->plugins([new InternalLinkPlugin, new TextMarksPlugin])
|
||||||
->toolbarButtons(RichText::TOOLBAR),
|
->toolbarButtons(RichText::TOOLBAR),
|
||||||
PremiumFields::ctaFields(),
|
PremiumFields::ctaFields(),
|
||||||
PremiumFields::altField(),
|
PremiumFields::altField(),
|
||||||
@@ -254,11 +272,11 @@ public function editorSchema(): array
|
|||||||
|
|
||||||
public function mediaSchema(): array
|
public function mediaSchema(): array
|
||||||
{
|
{
|
||||||
[, , , , $alt, $focusX, $focusY] = $this->dataFields();
|
[, , , , $alt, $focusX, $focusY, $zoom] = $this->dataFields();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
Group::make($this->refFields())->statePath('refs'),
|
Group::make($this->refFields())->statePath('refs'),
|
||||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
Group::make([$alt, $focusX, $focusY, $zoom])->statePath('data'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,15 +347,19 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'imageUrl' => $imageUrl,
|
'imageUrl' => $imageUrl,
|
||||||
|
'imageSrcset' => $imageUrl === null ? null : $images->srcset($image),
|
||||||
'imageAlt' => $imageAlt,
|
'imageAlt' => $imageAlt,
|
||||||
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||||
'video' => $video,
|
'video' => $video,
|
||||||
|
'videoFullscreen' => $video['url'] !== null && ($widget['settings']['fullscreen'] ?? 'no') === 'yes',
|
||||||
'hasCopy' => $hasCopy,
|
'hasCopy' => $hasCopy,
|
||||||
'imageShare' => self::imageShare($widget['settings'] ?? []),
|
'imageShare' => self::imageShare($widget['settings'] ?? []),
|
||||||
'body' => RichText::sanitize(is_string($widget['data']['body'] ?? null) ? $widget['data']['body'] : ''),
|
'body' => TextMarkers::decorate(RichText::sanitize(is_string($widget['data']['body'] ?? null) ? $widget['data']['body'] : '')),
|
||||||
'actions' => PremiumFields::actions($widget['data']),
|
'actions' => PremiumFields::actions($widget['data']),
|
||||||
'focus' => PremiumFields::focus($widget['data'], 64, 43),
|
'focus' => PremiumFields::focus($widget['data'], 64, 43),
|
||||||
'surface' => in_array($surface, ['cream', 'clear', 'navy'], true) ? $surface : 'cream',
|
'zoom' => PremiumFields::zoom($widget['data']),
|
||||||
|
// Eine gewählte Farbe aus der Palette (ADR-68) hat Vorrang vor „Hintergrund des Widgets“.
|
||||||
|
'surface' => WidgetAppearance::slot($this, $widget) !== null ? 'palette' : (in_array($surface, ['cream', 'clear', 'navy'], true) ? $surface : 'cream'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,19 +3,34 @@
|
|||||||
namespace App\Domain\Cms\Widgets\Types;
|
namespace App\Domain\Cms\Widgets\Types;
|
||||||
|
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
use App\Domain\Communication\InquiryEntry;
|
use App\Domain\Communication\InquiryEntry;
|
||||||
|
use App\Domain\Communication\InquiryTemplate;
|
||||||
|
use App\Domain\Communication\Keys;
|
||||||
|
use Filament\Forms\Components\Hidden;
|
||||||
|
use Filament\Forms\Components\Repeater;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\Textarea;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Schemas\Components\Text;
|
use Filament\Schemas\Components\Text;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
|
use Filament\Schemas\Components\Utilities\Set;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kontakt-Widget: bindet einen veröffentlichten Anfrage-Einstieg der Kommunikationsverwaltung ein (ADR-60). Das Widget
|
* Kontakt-Widget (ADR-60, ADR-61). Der Redakteur legt fest, welche Anfragegründe auf der Seite angeboten werden und
|
||||||
* speichert ausschließlich die Kennung des Einstiegs. Felder, Auswahlwerte, Bedingungen, Schritte, Texte und
|
* welches veröffentlichte Formular jeder Grund öffnet; Formularführung (Langformular oder mehrstufig) und Darstellung
|
||||||
* Empfänger gibt es im CMS nicht; sie werden in der Kommunikationsverwaltung gepflegt.
|
* (im Abschnitt oder als Dialog) sind zwei getrennte Einstellungen. Der Besucher wählt einen Grund und erhält genau das
|
||||||
|
* zugehörige Formular. Felder, Bedingungen, Texte und Empfänger gibt es im CMS nicht: Sie werden im Formular-Editor der
|
||||||
|
* Kommunikationsverwaltung gepflegt und gelten sofort auf allen Seiten.
|
||||||
|
*
|
||||||
|
* Seiten aus der ersten Fassung (ein Anfrage-Einstieg unter refs.entry) werden weiter dargestellt.
|
||||||
*/
|
*/
|
||||||
class InquiryWidget extends WidgetType
|
class InquiryWidget extends WidgetType
|
||||||
{
|
{
|
||||||
|
public const MAX_REASONS = 8;
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
{
|
{
|
||||||
return 'inquiry';
|
return 'inquiry';
|
||||||
@@ -28,7 +43,7 @@ public function label(): string
|
|||||||
|
|
||||||
public function description(): string
|
public function description(): string
|
||||||
{
|
{
|
||||||
return 'Bindet einen Anfrage-Einstieg aus der Kommunikationsverwaltung ein: Kontaktformular oder mehrstufiger Anfragedialog.';
|
return 'Kontaktformular mit Auswahl des Anfragegrundes: Der Besucher wählt, worum es geht, und erhält genau das passende Formular.';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function icon(): string
|
public function icon(): string
|
||||||
@@ -48,35 +63,122 @@ public function preferredUnits(): int
|
|||||||
|
|
||||||
public function narrowBehavior(): string
|
public function narrowBehavior(): string
|
||||||
{
|
{
|
||||||
return 'Das Formular nutzt die Breite des Platzes; Felder stehen untereinander, der mehrstufige Dialog bleibt einspaltig.';
|
return 'Das Formular nutzt die Breite des Platzes; Felder stehen untereinander, Karten der Grundauswahl stapeln, der Dialog füllt auf dem Smartphone den Bildschirm.';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stages(): array
|
public function stages(): array
|
||||||
{
|
{
|
||||||
return ['fluid' => 'einspaltig, in Lesebreite begrenzt; Felder gleicher Art stehen auf breiten Plätzen nebeneinander'];
|
return ['fluid' => 'einspaltig, in Lesebreite begrenzt; Felder gleicher Art und Karten stehen bei viel Platz nebeneinander'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function schematic(): array
|
public function schematic(): array
|
||||||
{
|
{
|
||||||
return [[6, 4, 24, 3, 'ink'], [6, 10, 48, 5, 'line'], [6, 18, 48, 5, 'line'], [6, 26, 18, 5, 'accent']];
|
return [[6, 4, 24, 3, 'ink'], [6, 10, 22, 6, 'line'], [32, 10, 22, 6, 'line'], [6, 20, 48, 5, 'line'], [6, 28, 18, 5, 'accent']];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formularführung und Präsentation sind unabhängig: Jede Kombination ist zulässig.
|
||||||
|
*
|
||||||
|
* @return array<string, array<string, string>>
|
||||||
|
*/
|
||||||
|
public function settings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'mode' => ['compact' => 'Langes Formular', 'wizard' => 'Mehrstufig, Schritt für Schritt'],
|
||||||
|
'open' => ['inline' => 'Im Abschnitt', 'modal' => 'Im Pop-up-Fenster über der Seite'],
|
||||||
|
'picker' => ['cards' => 'Karten', 'select' => 'Auswahlfeld'],
|
||||||
|
'width' => ['normal' => 'Standard', 'narrow' => 'Schmal', 'wide' => 'Breit'],
|
||||||
|
'spacing' => ['normal' => 'Standard', 'compact' => 'Kompakt', 'airy' => 'Großzügig'],
|
||||||
|
'columns' => ['auto' => 'Automatisch', 'one' => 'Immer eine Spalte'],
|
||||||
|
'button' => ['solid' => 'Gefüllt', 'outline' => 'Umrandet'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingLabels(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'mode' => ['Formularführung', 'Wie das Formular aufgebaut ist, nicht wo es steht. Langes Formular: alle Bereiche stehen untereinander, bedingte Felder erscheinen je nach Eingabe. Mehrstufig: die Bereiche werden Schritt für Schritt mit Fortschrittsanzeige durchlaufen. Ob das Formular im Abschnitt oder in einem Pop-up-Fenster erscheint, legt „Präsentation“ fest. Vorgabe: Langes Formular.'],
|
||||||
|
'open' => ['Präsentation', 'Wo das Formular erscheint, unabhängig von „Formularführung“. Im Abschnitt: das Formular steht direkt auf der Seite. Im Pop-up-Fenster: ein Button öffnet das Formular in einem Fenster über der Seite; auf dem Smartphone füllt es den Bildschirm. Vorgabe: Im Abschnitt.'],
|
||||||
|
'picker' => ['Auswahl des Anfragegrundes', 'Karten zeigen die Gründe mit Beschreibung nebeneinander, das Auswahlfeld braucht wenig Platz. Bei nur einem Grund entfällt die Auswahl. Vorgabe: Karten.'],
|
||||||
|
'width' => ['Breite des Formulars', 'Vorgabe: Standard. Das Formular nutzt höchstens die Breite des Platzes.'],
|
||||||
|
'spacing' => ['Abstände', 'Abstand zwischen den Feldern. Vorgabe: Standard.'],
|
||||||
|
'columns' => ['Anordnung der Felder', 'Automatisch: Felder gleicher Art (zum Beispiel Vor- und Nachname) stehen bei viel Platz nebeneinander. Vorgabe: Automatisch.'],
|
||||||
|
'button' => ['Buttondarstellung', 'Gilt für den Button, der das Pop-up-Fenster öffnet, und für „Weiter“ und „Absenden“. Vorgabe: Gefüllt.'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingGroups(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Formularführung und Präsentation' => ['mode', 'open'],
|
||||||
|
'Gestaltung' => ['picker', 'width', 'spacing', 'columns', 'button'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataRules(): array
|
public function dataRules(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [
|
||||||
|
// Nur die Existenz: Eine später zurückgezogene Vorlage darf eine Seite nicht unspeicherbar machen. Öffentlich
|
||||||
|
// erscheint ein Grund nur, solange sein Formular veröffentlicht ist (resolve()).
|
||||||
|
'reasons' => ['nullable', 'array', 'max:'.self::MAX_REASONS],
|
||||||
|
'reasons.*.key' => ['nullable', 'string', 'max:60'],
|
||||||
|
'reasons.*.label' => ['required', 'string', 'max:80'],
|
||||||
|
'reasons.*.description' => ['nullable', 'string', 'max:200'],
|
||||||
|
'reasons.*.template' => ['required', 'integer', Rule::exists('inquiry_templates', 'id')],
|
||||||
|
'reasons.*.issue' => ['nullable', 'string', 'max:60'],
|
||||||
|
'reasons.*.subissue' => ['nullable', 'string', 'max:60'],
|
||||||
|
'question' => ['nullable', 'string', 'max:160'],
|
||||||
|
'open_label' => ['nullable', 'string', 'max:60'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataFields(): array
|
public function dataFields(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [
|
||||||
|
Repeater::make('reasons')
|
||||||
|
->label('Anfragegründe')
|
||||||
|
->helperText('Diese Gründe bietet die Seite an. Wählt der Besucher einen Grund, erscheint genau das zugeordnete Formular. Bei nur einem Grund entfällt die Auswahl. Ein Button kann einen Grund vorwählen: Adresse der Seite mit „?grund=Kennung“ (die Kennung steht unter dem Grund).')
|
||||||
|
->schema([
|
||||||
|
Hidden::make('key'),
|
||||||
|
TextInput::make('label')->label('Bezeichnung für Besucher')->required()->maxLength(80)->placeholder('Zum Beispiel: Kurse & Workshops'),
|
||||||
|
Textarea::make('description')->label('Kurzbeschreibung (optional)')->rows(2)->maxLength(200)->helperText('Erscheint auf der Karte unter der Bezeichnung.'),
|
||||||
|
Select::make('template')->label('Formular')->required()->searchable()->live()
|
||||||
|
->options(fn (): array => self::templateOptions())
|
||||||
|
->afterStateUpdated(function (Set $set): void {
|
||||||
|
$set('issue', null);
|
||||||
|
$set('subissue', null);
|
||||||
|
})
|
||||||
|
->helperText('Nur veröffentlichte Formulare stehen zur Auswahl. Inhalt, Felder und Bedingungen pflegst du unter „Kommunikation → Formulare & Befragungen“.'),
|
||||||
|
Select::make('issue')->label('Anliegen im Formular vorwählen (optional)')->live()
|
||||||
|
->options(fn (Get $get): array => self::issueOptions((int) $get('template')))
|
||||||
|
->placeholder('Keines: das Formular fragt selbst')
|
||||||
|
->visible(fn (Get $get): bool => self::issueOptions((int) $get('template')) !== [])
|
||||||
|
->afterStateUpdated(fn (Set $set) => $set('subissue', null))
|
||||||
|
->helperText('Mehrere Gründe können dasselbe Formular nutzen und sich im Anliegen unterscheiden. Die Frage nach dem Anliegen entfällt dann.'),
|
||||||
|
Select::make('subissue')->label('Unteranliegen vorwählen (optional)')
|
||||||
|
->options(fn (Get $get): array => self::subissueOptions((int) $get('template'), (string) $get('issue')))
|
||||||
|
->placeholder('Keines')
|
||||||
|
->visible(fn (Get $get): bool => filled($get('issue')) && self::subissueOptions((int) $get('template'), (string) $get('issue')) !== []),
|
||||||
|
Text::make(fn (Get $get): string => filled($get('key')) ? 'Kennung für Links: grund='.$get('key') : 'Die Kennung für Links entsteht beim Speichern.'),
|
||||||
|
])
|
||||||
|
->minItems(1)
|
||||||
|
->maxItems(self::MAX_REASONS)
|
||||||
|
->reorderableWithButtons()
|
||||||
|
->collapsible()
|
||||||
|
->addActionLabel('Anfragegrund hinzufügen')
|
||||||
|
->itemLabel(fn (array $state): ?string => $state['label'] ?? null),
|
||||||
|
TextInput::make('question')->label('Frage zur Auswahl des Grundes')->maxLength(160)->placeholder('Worum geht es?')
|
||||||
|
->helperText('Steht über der Auswahl, wenn mehr als ein Grund angeboten wird. Leer: „Worum geht es?“.'),
|
||||||
|
TextInput::make('open_label')->label('Beschriftung des Buttons (nur Pop-up-Fenster)')->maxLength(60)->placeholder('Anfrage stellen')
|
||||||
|
->helperText('Erscheint nur bei der Präsentation „Im Pop-up-Fenster über der Seite“.'),
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function refRules(): array
|
public function refRules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// Nur die Existenz: Ein später zurückgezogener Einstieg darf eine Seite nicht unspeicherbar machen (Seiten bleiben
|
// Nur die Existenz (Seiten der ersten Fassung): Ein später zurückgezogener Einstieg darf eine Seite nicht unspeicherbar machen.
|
||||||
// konsistent). Auswahl im Editor sind nur veröffentlichte Einstiege; öffentlich erscheint nichts, solange er es nicht ist.
|
'entry' => ['nullable', 'integer', Rule::exists('inquiry_entries', 'id')],
|
||||||
'entry' => ['required', 'integer', Rule::exists('inquiry_entries', 'id')],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,33 +186,167 @@ public function refFields(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Select::make('entry')
|
Select::make('entry')
|
||||||
->label('Anfrage-Einstieg')
|
->label('Bisheriger Anfrage-Einstieg')
|
||||||
->required()
|
|
||||||
->searchable()
|
->searchable()
|
||||||
->options(fn (): array => InquiryEntry::query()->live()->orderBy('name')->pluck('name', 'id')->all())
|
->options(fn (): array => InquiryEntry::query()->orderBy('name')->pluck('name', 'id')->all())
|
||||||
->helperText('Nur veröffentlichte Einstiege stehen zur Auswahl. Anliegen, Felder, Bedingungen, Texte und Empfänger pflegst du in der Kommunikationsverwaltung („Kommunikation → Anfrage-Einstiege“), nicht hier. Eine Änderung dort gilt sofort auf allen Seiten, die diesen Einstieg verwenden.'),
|
->visible(fn (Get $get): bool => filled($get('entry')))
|
||||||
Text::make('Ein Einstieg ist die konkrete Nutzungsvariante einer Anfragevorlage. Mehrere Seiten können denselben Einstieg einbinden.'),
|
->helperText('Diese Seite nutzt noch einen Anfrage-Einstieg der ersten Fassung. Er wird nur angezeigt, solange oben kein Anfragegrund eingetragen ist. Neue Seiten brauchen keinen Einstieg.'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editorSchema(): array
|
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||||
{
|
{
|
||||||
return parent::editorSchema();
|
$reasons = [];
|
||||||
|
$taken = [];
|
||||||
|
|
||||||
|
foreach (array_values((array) ($data['reasons'] ?? [])) as $reason) {
|
||||||
|
$reason = is_array($reason) ? $reason : [];
|
||||||
|
$key = Keys::valid($reason['key'] ?? null) && ! in_array($reason['key'], $taken, true) ? $reason['key'] : Keys::from((string) ($reason['label'] ?? ''), $taken);
|
||||||
|
$taken[] = $key;
|
||||||
|
$reasons[] = [
|
||||||
|
'key' => $key,
|
||||||
|
'label' => trim((string) ($reason['label'] ?? '')),
|
||||||
|
'description' => filled($reason['description'] ?? null) ? trim((string) $reason['description']) : null,
|
||||||
|
'template' => (int) ($reason['template'] ?? 0),
|
||||||
|
'issue' => filled($reason['issue'] ?? null) ? (string) $reason['issue'] : null,
|
||||||
|
'subissue' => filled($reason['issue'] ?? null) && filled($reason['subissue'] ?? null) ? (string) $reason['subissue'] : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['reasons'] = $reasons;
|
||||||
|
|
||||||
|
if ($reasons === [] && ! filled($refs['entry'] ?? null)) {
|
||||||
|
$errors->add('data.reasons', 'Mindestens ein Anfragegrund ist nötig.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$data, $refs];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resolve(array $widget, RenderContext $context): array
|
public function resolve(array $widget, RenderContext $context): array
|
||||||
{
|
{
|
||||||
$id = $widget['refs']['entry'] ?? null;
|
$reasons = array_values(array_filter((array) ($widget['data']['reasons'] ?? []), 'is_array'));
|
||||||
$entry = is_numeric($id) ? InquiryEntry::query()->with('template')->find((int) $id) : null;
|
|
||||||
|
|
||||||
return ['entry' => $entry, 'entryLive' => $entry?->isLive() ?? false];
|
if ($reasons === []) {
|
||||||
|
$id = $widget['refs']['entry'] ?? null;
|
||||||
|
$entry = is_numeric($id) ? InquiryEntry::query()->with('template')->find((int) $id) : null;
|
||||||
|
|
||||||
|
return ['legacy' => true, 'entry' => $entry, 'entryLive' => $entry?->isLive() ?? false, 'config' => null, 'unavailable' => []];
|
||||||
|
}
|
||||||
|
|
||||||
|
$templates = InquiryTemplate::query()->with('publishedVersion')->whereIn('id', array_unique(array_map(fn (array $r): int => (int) ($r['template'] ?? 0), $reasons)))->get()->keyBy('id');
|
||||||
|
$settings = (array) ($widget['settings'] ?? []);
|
||||||
|
$mode = ($settings['mode'] ?? 'compact') === 'wizard' ? 'wizard' : 'compact';
|
||||||
|
$live = [];
|
||||||
|
$unavailable = [];
|
||||||
|
|
||||||
|
foreach ($reasons as $reason) {
|
||||||
|
$template = $templates[(int) ($reason['template'] ?? 0)] ?? null;
|
||||||
|
$label = (string) ($reason['label'] ?? '');
|
||||||
|
|
||||||
|
if ($template === null || $template->archived_at !== null || $template->publishedVersion === null) {
|
||||||
|
$unavailable[] = $label;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = array_filter([
|
||||||
|
'anliegen' => $reason['issue'] ?? null,
|
||||||
|
'unteranliegen' => $reason['subissue'] ?? null,
|
||||||
|
'modus' => $mode,
|
||||||
|
], fn (mixed $value): bool => filled($value));
|
||||||
|
$suffix = '?'.http_build_query($query);
|
||||||
|
|
||||||
|
$live[] = [
|
||||||
|
'key' => (string) ($reason['key'] ?? ''),
|
||||||
|
'label' => $label,
|
||||||
|
'description' => $reason['description'] ?? null,
|
||||||
|
'definitionUrl' => route('inquiry.form.definition', $template).$suffix,
|
||||||
|
'stateUrl' => route('inquiry.form.state', $template).$suffix,
|
||||||
|
'submitUrl' => route('inquiry.form.submit', $template).$suffix,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$config = $live === [] ? null : [
|
||||||
|
'open' => ($settings['open'] ?? 'inline') === 'modal' ? 'modal' : 'inline',
|
||||||
|
'picker' => ($settings['picker'] ?? 'cards') === 'select' ? 'select' : 'cards',
|
||||||
|
'question' => filled($widget['data']['question'] ?? null) ? (string) $widget['data']['question'] : 'Worum geht es?',
|
||||||
|
'openLabel' => filled($widget['data']['open_label'] ?? null) ? (string) $widget['data']['open_label'] : 'Anfrage stellen',
|
||||||
|
'preview' => $context->preview,
|
||||||
|
'reasons' => $live,
|
||||||
|
];
|
||||||
|
|
||||||
|
return ['legacy' => false, 'entry' => null, 'entryLive' => false, 'config' => $config, 'unavailable' => $unavailable];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function summary(array $widget): string
|
public function summary(array $widget): string
|
||||||
{
|
{
|
||||||
$id = $widget['refs']['entry'] ?? null;
|
$reasons = array_values(array_filter((array) ($widget['data']['reasons'] ?? []), 'is_array'));
|
||||||
$name = is_numeric($id) ? InquiryEntry::query()->whereKey((int) $id)->value('name') : null;
|
|
||||||
|
|
||||||
return $name !== null ? 'Anfrage: '.$name : 'Kein Anfrage-Einstieg gewählt';
|
if ($reasons === []) {
|
||||||
|
$id = $widget['refs']['entry'] ?? null;
|
||||||
|
$name = is_numeric($id) ? InquiryEntry::query()->whereKey((int) $id)->value('name') : null;
|
||||||
|
|
||||||
|
return $name !== null ? 'Anfrage: '.$name : 'Kein Anfragegrund gewählt';
|
||||||
|
}
|
||||||
|
|
||||||
|
$labels = array_map(fn (array $reason): string => (string) ($reason['label'] ?? ''), $reasons);
|
||||||
|
$mode = ($widget['settings']['mode'] ?? 'compact') === 'wizard' ? 'mehrstufig' : 'langes Formular';
|
||||||
|
$open = ($widget['settings']['open'] ?? 'inline') === 'modal' ? 'Pop-up' : 'im Abschnitt';
|
||||||
|
|
||||||
|
return 'Anfrage: '.implode(', ', $labels).' ('.$mode.', '.$open.')';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
private static function templateOptions(): array
|
||||||
|
{
|
||||||
|
return InquiryTemplate::query()->whereNotNull('published_version_id')->whereNull('archived_at')->orderBy('name')->pluck('name', 'id')->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
private static function issueOptions(int $templateId): array
|
||||||
|
{
|
||||||
|
$options = [];
|
||||||
|
|
||||||
|
foreach ((array) (self::definition($templateId)['issues'] ?? []) as $issue) {
|
||||||
|
$options[(string) $issue['key']] = (string) $issue['label'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
private static function subissueOptions(int $templateId, string $issue): array
|
||||||
|
{
|
||||||
|
$options = [];
|
||||||
|
|
||||||
|
foreach ((array) (self::definition($templateId)['issues'] ?? []) as $top) {
|
||||||
|
if ($top['key'] !== $issue) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ((array) $top['children'] as $child) {
|
||||||
|
$options[(string) $child['key']] = (string) $child['label'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private static function definition(int $templateId): array
|
||||||
|
{
|
||||||
|
if ($templateId <= 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return (array) (InquiryTemplate::query()->with('publishedVersion')->find($templateId)?->publishedVersion?->definition ?? []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,7 +130,7 @@ protected function filmFieldData(?ContentElement $film): array
|
|||||||
? route('content.website-frame', ['element' => $film])
|
? route('content.website-frame', ['element' => $film])
|
||||||
: null,
|
: null,
|
||||||
'filmHasThumbnail' => $film instanceof ContentElement && is_string($film->thumbnail_path) && $film->thumbnail_path !== '',
|
'filmHasThumbnail' => $film instanceof ContentElement && is_string($film->thumbnail_path) && $film->thumbnail_path !== '',
|
||||||
'filmThumbnailUrl' => $film instanceof ContentElement ? ThumbnailRef::url('editorial.card', 'element', (int) $film->id, $film->thumbnail_path) : null,
|
'filmThumbnailUrl' => $film instanceof ContentElement ? ThumbnailRef::url('editorial.card', 'element', (int) $film->id, $film->thumbnail_path, 'mittel', $film->updated_at) : null,
|
||||||
'filmStartSecond' => $film instanceof ContentElement ? ($stills->thumbnailSecond($film) ?? '0') : '0',
|
'filmStartSecond' => $film instanceof ContentElement ? ($stills->thumbnailSecond($film) ?? '0') : '0',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
use App\Domain\Cms\Catalog\CardSubject;
|
use App\Domain\Cms\Catalog\CardSubject;
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
use App\Domain\Cms\Widgets\Support\CardClip;
|
use App\Domain\Cms\Widgets\Support\CardClip;
|
||||||
|
use App\Domain\Cms\Widgets\Support\ImageFraming;
|
||||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||||
@@ -59,6 +60,18 @@ abstract protected function defaultActionLabel(): string;
|
|||||||
/** Gestaltungsvariante des Kits: editorial, media oder catalog. */
|
/** Gestaltungsvariante des Kits: editorial, media oder catalog. */
|
||||||
abstract protected function cardStyle(): string;
|
abstract protected function cardStyle(): string;
|
||||||
|
|
||||||
|
/** Größe von Überschrift und beschreibendem Text wählbar (ADR-68). */
|
||||||
|
public function typography(): array
|
||||||
|
{
|
||||||
|
return ['heading', 'text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Farbe aus der Palette wirkt auf die Fläche des ganzen Widgets (ADR-68). */
|
||||||
|
public function paletteTarget(array $widget = []): ?string
|
||||||
|
{
|
||||||
|
return 'hull';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Weitere Wege zum Kartenbild im Reiter „Medien“, zum Beispiel ein Bild aus dem Film. Standard: keine.
|
* Weitere Wege zum Kartenbild im Reiter „Medien“, zum Beispiel ein Bild aus dem Film. Standard: keine.
|
||||||
*
|
*
|
||||||
@@ -165,7 +178,7 @@ public function settings(): array
|
|||||||
{
|
{
|
||||||
$choices = $this->textChoices();
|
$choices = $this->textChoices();
|
||||||
|
|
||||||
return ($choices === [] ? [] : ['text_source' => $choices]) + ($this->supportsClip() ? ['clip' => ['yes' => 'Abspielen', 'no' => 'Nicht abspielen'], 'show_body' => self::SHOW] : []) + [
|
return ($choices === [] ? [] : ['text_source' => $choices]) + ($this->supportsClip() ? ['clip' => ['yes' => 'Abspielen', 'no' => 'Nicht abspielen'], 'fullscreen' => ['no' => 'Nicht anbieten', 'yes' => 'Anbieten'], 'show_body' => self::SHOW] : []) + [
|
||||||
'format' => ['landscape' => 'Querformat 16:9', 'square' => 'Quadrat 1:1', 'portrait' => 'Hochformat 3:4'],
|
'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)'],
|
'fit' => ['cover' => 'Ausschnitt füllt die Fläche', 'contain' => 'Ganzes Bild zeigen (Dokument, Poster)'],
|
||||||
'heading_level' => ['h3' => 'H3', 'h2' => 'H2', 'h4' => 'H4'],
|
'heading_level' => ['h3' => 'H3', 'h2' => 'H2', 'h4' => 'H4'],
|
||||||
@@ -179,7 +192,7 @@ public function settings(): array
|
|||||||
public function settingGroups(): array
|
public function settingGroups(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'Bild und Video' => ['format', 'fit', 'clip'],
|
'Bild und Video' => ['format', 'fit', 'clip', 'fullscreen'],
|
||||||
'Texte auf der Karte' => ['show_body', 'text_source', 'show_summary', 'show_kind', 'show_meta', 'show_action'],
|
'Texte auf der Karte' => ['show_body', 'text_source', 'show_summary', 'show_kind', 'show_meta', 'show_action'],
|
||||||
'Seitenstruktur' => ['heading_level'],
|
'Seitenstruktur' => ['heading_level'],
|
||||||
];
|
];
|
||||||
@@ -197,6 +210,7 @@ public function settingLabels(): array
|
|||||||
'format' => ['Bildformat', 'Seitenverhältnis des Bildes oder Videos. Vorgabe: Querformat 16:9. Gilt auch neben dem Text; das Motiv wird nicht nachträglich hochkant beschnitten.'],
|
'format' => ['Bildformat', 'Seitenverhältnis des Bildes oder Videos. Vorgabe: Querformat 16:9. Gilt auch neben dem Text; das Motiv wird nicht nachträglich hochkant beschnitten.'],
|
||||||
'fit' => ['Bildausschnitt', 'Ausschnitt füllt die ganze Fläche; „Ganzes Bild“ zeigt Dokumente und Poster vollständig auf ruhiger Fläche. Vorgabe: Ausschnitt.'],
|
'fit' => ['Bildausschnitt', 'Ausschnitt füllt die ganze Fläche; „Ganzes Bild“ zeigt Dokumente und Poster vollständig auf ruhiger Fläche. Vorgabe: Ausschnitt.'],
|
||||||
'clip' => ['Trailer auf der Karte', 'Spielt den freigegebenen Trailer als stumme Vorschau, solange die Maus auf der Karte steht; ein Klick oder Tipp auf das Bild oder die kleine Schaltfläche (auch per Tastatur) spielt ihn mit Ton. Gewählt wird der Trailer (sonst der Vorschauclip) in der Präsentation des Objekts, bei einem Film ersatzweise sein freigegebener Teaser. Ohne freigegebenen Clip bleibt das Kartenbild. Vorgabe: Abspielen.'],
|
'clip' => ['Trailer auf der Karte', 'Spielt den freigegebenen Trailer als stumme Vorschau, solange die Maus auf der Karte steht; ein Klick oder Tipp auf das Bild oder die kleine Schaltfläche (auch per Tastatur) spielt ihn mit Ton. Gewählt wird der Trailer (sonst der Vorschauclip) in der Präsentation des Objekts, bei einem Film ersatzweise sein freigegebener Teaser. Ohne freigegebenen Clip bleibt das Kartenbild. Vorgabe: Abspielen.'],
|
||||||
|
'fullscreen' => ['Vollbild für den Trailer', 'Bietet neben dem Trailer eine Schaltfläche „Vollbild“ an (auch am Handy, folgt der Neigerichtung des Geräts). Spielt weiterhin nur den freigegebenen Trailer, nie den vollständigen Film. Gilt nur, wenn die Karte einen Trailer abspielt. Vorgabe: nicht anbieten.'],
|
||||||
'show_body' => ['Texte auf der Karte', 'Hauptschalter für alle Texte neben dem Bild. „Ausblenden“ zeigt nur Bild und Video, ohne Titel, Beschreibung, Art, Zusatzangaben und Schaltfläche; die Einzelschalter darunter verschwinden dann. Für Hilfstechnik bleibt der Titel unsichtbar erhalten. Sinnvoll, wenn das Video allein erklärt. Vorgabe: Anzeigen.'],
|
'show_body' => ['Texte auf der Karte', 'Hauptschalter für alle Texte neben dem Bild. „Ausblenden“ zeigt nur Bild und Video, ohne Titel, Beschreibung, Art, Zusatzangaben und Schaltfläche; die Einzelschalter darunter verschwinden dann. Für Hilfstechnik bleibt der Titel unsichtbar erhalten. Sinnvoll, wenn das Video allein erklärt. Vorgabe: Anzeigen.'],
|
||||||
'text_source' => ['Quelle der Beschreibung', 'Welche Angabe aus der Redaktion als Beschreibung erscheint. Vorgabe: Automatisch. Der Text erscheint öffentlich, wenn die Karte öffentlich ist; ist er nicht gepflegt, bleibt die Karte ohne Beschreibung.'],
|
'text_source' => ['Quelle der Beschreibung', 'Welche Angabe aus der Redaktion als Beschreibung erscheint. Vorgabe: Automatisch. Der Text erscheint öffentlich, wenn die Karte öffentlich ist; ist er nicht gepflegt, bleibt die Karte ohne Beschreibung.'],
|
||||||
'show_summary' => ['Beschreibung', 'Der Beschreibungstext unter dem Titel, aus den Fachdaten. Vorgabe: Anzeigen.'],
|
'show_summary' => ['Beschreibung', 'Der Beschreibungstext unter dem Titel, aus den Fachdaten. Vorgabe: Anzeigen.'],
|
||||||
@@ -215,9 +229,7 @@ public function dataRules(): array
|
|||||||
'heading' => ['nullable', 'string', 'max:200'],
|
'heading' => ['nullable', 'string', 'max:200'],
|
||||||
'summary' => ['nullable', 'string', 'max:500'],
|
'summary' => ['nullable', 'string', 'max:500'],
|
||||||
'alt' => ['nullable', 'string', 'max:300'],
|
'alt' => ['nullable', 'string', 'max:300'],
|
||||||
'focus_x' => ['nullable', 'numeric', 'between:0,100'],
|
] + ImageFraming::rules();
|
||||||
'focus_y' => ['nullable', 'numeric', 'between:0,100'],
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function refRules(): array
|
public function refRules(): array
|
||||||
@@ -281,11 +293,11 @@ public function editorSchema(): array
|
|||||||
|
|
||||||
public function mediaSchema(): array
|
public function mediaSchema(): array
|
||||||
{
|
{
|
||||||
[, , $alt, $focusX, $focusY] = $this->dataFields();
|
[, , $alt, $focusX, $focusY, $zoom] = $this->dataFields();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
Group::make([...ImageRefFields::fields('Kartenbild', live: true), ...$this->imageSourceFields()])->statePath('refs'),
|
Group::make([...ImageRefFields::fields('Kartenbild', live: true), ...$this->imageSourceFields()])->statePath('refs'),
|
||||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
Group::make([$alt, $focusX, $focusY, $zoom])->statePath('data'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,7 +323,7 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
|||||||
$data[$field] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
$data[$field] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$data, $refs];
|
return [ImageFraming::cleanZoom($data), $refs];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resolve(array $widget, RenderContext $context): array
|
public function resolve(array $widget, RenderContext $context): array
|
||||||
@@ -347,11 +359,14 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
return [
|
return [
|
||||||
'subject' => $subject,
|
'subject' => $subject,
|
||||||
'clip' => $clip,
|
'clip' => $clip,
|
||||||
|
'clipFullscreen' => $clip !== null && $option('fullscreen', 'no') === 'yes',
|
||||||
'cardStyle' => $subject?->style ?? $this->cardStyle(),
|
'cardStyle' => $subject?->style ?? $this->cardStyle(),
|
||||||
'imageUrl' => app(WebsiteImage::class)->url($imageRef, $context->preview),
|
'imageUrl' => app(WebsiteImage::class)->url($imageRef, $context->preview),
|
||||||
|
'imageSrcset' => app(WebsiteImage::class)->srcset($imageRef),
|
||||||
'alt' => app(WebsiteImage::class)->alt($imageRef, $data['alt'] ?? null),
|
'alt' => app(WebsiteImage::class)->alt($imageRef, $data['alt'] ?? null),
|
||||||
'imageNotice' => $context->preview ? app(WebsiteImage::class)->previewNotice($imageRef, 'Das Kartenbild') : null,
|
'imageNotice' => $context->preview ? app(WebsiteImage::class)->previewNotice($imageRef, 'Das Kartenbild') : null,
|
||||||
'focus' => PremiumFields::focus($data, 66, 45),
|
'focus' => PremiumFields::focus($data, 66, 45),
|
||||||
|
'zoom' => PremiumFields::zoom($data),
|
||||||
'format' => $option('format', 'landscape'),
|
'format' => $option('format', 'landscape'),
|
||||||
'fit' => $option('fit', 'cover'),
|
'fit' => $option('fit', 'cover'),
|
||||||
'headingTag' => $option('heading_level', 'h3'),
|
'headingTag' => $option('heading_level', 'h3'),
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ protected function imageSourceFields(): array
|
|||||||
'composition' => $composition,
|
'composition' => $composition,
|
||||||
'compositionTitle' => $composition instanceof Composition ? (string) ($composition->display_title ?: $composition->designation) : '',
|
'compositionTitle' => $composition instanceof Composition ? (string) ($composition->display_title ?: $composition->designation) : '',
|
||||||
'compositionThumbnailUrl' => $composition instanceof Composition && app(CompositionStill::class)->hasThumbnail($composition)
|
'compositionThumbnailUrl' => $composition instanceof Composition && app(CompositionStill::class)->hasThumbnail($composition)
|
||||||
? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path)
|
? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path, 'mittel', $composition->updated_at)
|
||||||
: null,
|
: null,
|
||||||
];
|
];
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
use App\Domain\Cms\Widgets\Support\HeadingAccent;
|
use App\Domain\Cms\Widgets\Support\HeadingAccent;
|
||||||
use App\Domain\Cms\Widgets\Support\RichText;
|
use App\Domain\Cms\Widgets\Support\RichText;
|
||||||
|
use App\Domain\Cms\Widgets\Support\TextMarkers;
|
||||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
use App\Filament\Support\RichField;
|
use App\Filament\Support\RichField;
|
||||||
@@ -28,6 +29,18 @@ public function version(): int
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Größe von Überschrift und beschreibendem Text wählbar (ADR-68). */
|
||||||
|
public function typography(): array
|
||||||
|
{
|
||||||
|
return ['text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Farbe aus der Palette wirkt auf die Fläche des ganzen Widgets (ADR-68). */
|
||||||
|
public function paletteTarget(array $widget = []): ?string
|
||||||
|
{
|
||||||
|
return 'hull';
|
||||||
|
}
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
{
|
{
|
||||||
return 'prose';
|
return 'prose';
|
||||||
@@ -123,6 +136,9 @@ public static function render(mixed $body): string
|
|||||||
{
|
{
|
||||||
$html = FormattedText::html(is_string($body) ? $body : '', null, true);
|
$html = FormattedText::html(is_string($body) ? $body : '', null, true);
|
||||||
|
|
||||||
|
// Symbole vor Absätzen, Kreise um Nummern und Symbole statt Punkten setzt erst die Ausgabe ein (ADR-69).
|
||||||
|
$html = TextMarkers::decorate($html);
|
||||||
|
|
||||||
// Die Ausrichtung steht gespeichert als Stil (so liest der Editor sie); auf der Seite wird sie eine Klasse.
|
// Die Ausrichtung steht gespeichert als Stil (so liest der Editor sie); auf der Seite wird sie eine Klasse.
|
||||||
return str_replace(
|
return str_replace(
|
||||||
['<table>', '</table>', ' style="text-align: center"', ' style="text-align: end"'],
|
['<table>', '</table>', ' style="text-align: center"', ' style="text-align: end"'],
|
||||||
|
|||||||
@@ -22,6 +22,18 @@
|
|||||||
*/
|
*/
|
||||||
class ShopProductsWidget extends WidgetType
|
class ShopProductsWidget extends WidgetType
|
||||||
{
|
{
|
||||||
|
/** Größe von Überschrift und beschreibendem Text wählbar (ADR-68). */
|
||||||
|
public function typography(): array
|
||||||
|
{
|
||||||
|
return ['heading', 'text'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Farbe aus der Palette wirkt auf die Fläche des ganzen Widgets (ADR-68). */
|
||||||
|
public function paletteTarget(array $widget = []): ?string
|
||||||
|
{
|
||||||
|
return 'hull';
|
||||||
|
}
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
{
|
{
|
||||||
return 'shop_products';
|
return 'shop_products';
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Domain\Cms\Widgets;
|
namespace App\Domain\Cms\Widgets;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Widgets\Support\WidgetAppearance;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Support\Facades\Validator;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
@@ -59,6 +60,14 @@ public function register(WidgetType $type): void
|
|||||||
throw new InvalidArgumentException("Widget „{$key}“ deklariert die Höhe über heights(), nicht über settings().");
|
throw new InvalidArgumentException("Widget „{$key}“ deklariert die Höhe über heights(), nicht über settings().");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_intersect(array_keys($type->settings()), WidgetAppearance::KEYS) !== []) {
|
||||||
|
throw new InvalidArgumentException("Widget „{$key}“ deklariert Schriftgröße oder Farbe über typography() und paletteTarget(), nicht über settings().");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_diff($type->typography(), ['heading', 'text']) !== [] || ! in_array($type->paletteTarget(), [null, 'hull', 'face'], true)) {
|
||||||
|
throw new InvalidArgumentException("Widget „{$key}“ verwendet eine unbekannte Schrift- oder Farbangabe.");
|
||||||
|
}
|
||||||
|
|
||||||
if ($type->variants() === []) {
|
if ($type->variants() === []) {
|
||||||
throw new InvalidArgumentException("Widget „{$key}“ braucht mindestens eine Darstellungsvariante.");
|
throw new InvalidArgumentException("Widget „{$key}“ braucht mindestens eine Darstellungsvariante.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Domain\Cms\Widgets;
|
namespace App\Domain\Cms\Widgets;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Widgets\Support\WidgetAppearance;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,7 +77,11 @@ public function renderWidget(array $widget, RenderContext $context, bool $first
|
|||||||
$height = $type->height($widget);
|
$height = $type->height($widget);
|
||||||
$heightClass = $height !== null ? ' widget-height-'.e($height) : '';
|
$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.'>'
|
// Schriftgrößen und Farbe (ADR-68): Klassen und Eigenschaften nur, wenn ein Wert gesetzt ist; sonst bleibt die Hülle unverändert.
|
||||||
|
$appearance = WidgetAppearance::classes($type, $widget);
|
||||||
|
$surface = WidgetAppearance::style($type, $widget);
|
||||||
|
|
||||||
|
return '<section class="block widget widget-'.e(str_replace('_', '-', $widget['type'])).' widget-variant-'.e(str_replace('_', '-', $widget['variant'])).$heightClass.$appearance.'"'.$id.$surface.'>'
|
||||||
.$inner
|
.$inner
|
||||||
.'</section>';
|
.'</section>';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Domain\Cms\Widgets;
|
namespace App\Domain\Cms\Widgets;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Widgets\Support\WidgetAppearance;
|
||||||
use Filament\Forms\Components\Field;
|
use Filament\Forms\Components\Field;
|
||||||
use Filament\Schemas\Components\Component;
|
use Filament\Schemas\Components\Component;
|
||||||
use Filament\Schemas\Components\Group;
|
use Filament\Schemas\Components\Group;
|
||||||
@@ -218,8 +219,33 @@ public function settingHiddenWhen(): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alle zulässigen Einstellungen einschließlich der gemeinsamen Höhe. Registry-Prüfung, Editor und Darstellung
|
* Gemeinsame Schrifteinstellungen (ADR-68), die diese Art anbietet: 'heading' (Größe der Überschrift) und/oder 'text'
|
||||||
* verwenden ausschließlich diese Zusammenführung.
|
* (Größe des beschreibenden Texts). Leer: keine Wahl, die Größen bleiben wie im Widget festgelegt. Die Darstellung der Art
|
||||||
|
* liest dafür nichts aus den Einstellungen; die Größe wirkt über Klassen an der Hülle (WidgetAppearance) und das CSS.
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function typography(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wo die Farbe aus der Palette (ADR-68) wirkt: 'hull' färbt die Fläche des ganzen Widgets (mit Innenabstand), 'face'
|
||||||
|
* färbt die eigene Fläche des Widgets (Karten, Handlungsaufruf, Bild und Text, Hinweis), damit keine zweite Fläche
|
||||||
|
* dahinter steht. Null: Das Widget bietet keine Farbe an. Eine Art darf nach Variante und Einstellungen des Widgets
|
||||||
|
* entscheiden (Karten ohne eigene Fläche färben das Widget, nicht die Karte); ohne Angabe gilt der Grundwert der Art.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $widget Hülle der Instanz (variant, settings); leer für die Art allgemein
|
||||||
|
*/
|
||||||
|
public function paletteTarget(array $widget = []): ?string
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alle zulässigen Einstellungen einschließlich der gemeinsamen Höhe, der Schriftgrößen und der Farbe. Registry-Prüfung,
|
||||||
|
* Editor und Darstellung verwenden ausschließlich diese Zusammenführung.
|
||||||
*
|
*
|
||||||
* @return array<string, array<string, string>>
|
* @return array<string, array<string, string>>
|
||||||
*/
|
*/
|
||||||
@@ -231,7 +257,7 @@ final public function settingOptions(): array
|
|||||||
$options['height'] = $this->heights();
|
$options['height'] = $this->heights();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $options;
|
return $options + WidgetAppearance::options($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,741 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Communication;
|
||||||
|
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Übersetzung zwischen dem Entwurf einer Vorlage (Schritte mit Feldgruppen und Einzelfeldern, Regeln; ADR-60) und der
|
||||||
|
* flachen Bearbeitungsansicht des Formular-Editors (ADR-61): Bereiche mit Feldern und Teilbereichen, Bedingungen direkt am
|
||||||
|
* Element. Die Engine bleibt unverändert; der Editor schreibt Felder und Teilbereiche in denselben Katalog, aus dem die
|
||||||
|
* Vorlage sie liest, und erzeugt aus den Bedingungen am Element dieselben Regeln wie die Regelliste.
|
||||||
|
*
|
||||||
|
* Ansicht (Builder-Format der Verwaltung):
|
||||||
|
* areas[] {key, title, intro, cond, items[]}
|
||||||
|
* items[] {type: field|section|end|issue, data: {...}} (end: Ende eines Teilbereichs; danach folgen Einzelfelder)
|
||||||
|
* cond {effect, match, conditions[{source, op, values[]}], pos} (leer: keine Bedingung)
|
||||||
|
* rules[] Regeln, die sich nicht an ein Element heften lassen (zusätzliche Regeln desselben Ziels, Vorbelegungen)
|
||||||
|
*
|
||||||
|
* Ein Teilbereich ist eine Überschrift im Fluss: Die Felder bis zum nächsten Teilbereich gehören zu ihm (Feldgruppe).
|
||||||
|
* Neue Elemente tragen eine vorläufige Kennung (tmp_…), die beim Speichern durch eine feste ersetzt wird.
|
||||||
|
*/
|
||||||
|
final class FormEditor
|
||||||
|
{
|
||||||
|
/** Wirkungen, die ein Element selbst trägt, je Art des Ziels. */
|
||||||
|
public const EFFECTS = [
|
||||||
|
'step' => ['show', 'hide', 'skip'],
|
||||||
|
'group' => ['show', 'hide'],
|
||||||
|
'field' => ['show', 'hide', 'require'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $draft
|
||||||
|
* @param ?int $exceptTemplate die bearbeitete Vorlage: Sie zählt nicht als „auch verwendet in“
|
||||||
|
* @return array{issues: list<string>, areas: list<array<string, mixed>>, rules: list<array<string, mixed>>}
|
||||||
|
*/
|
||||||
|
public function expand(array $draft, ?int $exceptTemplate = null): array
|
||||||
|
{
|
||||||
|
$fields = InquiryField::query()->get()->keyBy('key');
|
||||||
|
$groups = InquiryFieldGroup::query()->get()->keyBy('key');
|
||||||
|
$usage = $this->usage($exceptTemplate);
|
||||||
|
|
||||||
|
$byTarget = [];
|
||||||
|
$rules = array_values(array_filter((array) ($draft['rules'] ?? []), 'is_array'));
|
||||||
|
|
||||||
|
foreach ($rules as $index => $rule) {
|
||||||
|
$byTarget[(string) ($rule['target'] ?? '')][] = $index;
|
||||||
|
}
|
||||||
|
|
||||||
|
$consumed = [];
|
||||||
|
$take = function (string $target, string $kind) use (&$byTarget, &$consumed, $rules): array {
|
||||||
|
foreach ($byTarget[$target] ?? [] as $index) {
|
||||||
|
if (isset($consumed[$index]) || ! in_array($rules[$index]['effect'] ?? null, self::EFFECTS[$kind], true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$consumed[$index] = true;
|
||||||
|
|
||||||
|
return $this->cond($rules[$index], $index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
};
|
||||||
|
|
||||||
|
$areas = [];
|
||||||
|
$issueDone = false;
|
||||||
|
|
||||||
|
foreach (array_values((array) ($draft['steps'] ?? [])) as $step) {
|
||||||
|
$step = is_array($step) ? $step : [];
|
||||||
|
$key = (string) ($step['key'] ?? '');
|
||||||
|
$items = [];
|
||||||
|
|
||||||
|
$list = array_values((array) ($step['items'] ?? []));
|
||||||
|
|
||||||
|
foreach ($list as $position => $item) {
|
||||||
|
$item = is_array($item) ? $item : [];
|
||||||
|
$kind = (string) ($item['kind'] ?? '');
|
||||||
|
|
||||||
|
if ($kind === 'issue') {
|
||||||
|
$items[] = ['type' => 'issue', 'data' => ['issues' => $issueDone ? [] : array_values(array_filter((array) ($draft['issues'] ?? []), 'is_string'))]];
|
||||||
|
$issueDone = true;
|
||||||
|
} elseif ($kind === 'group') {
|
||||||
|
$groupKey = (string) ($item['group'] ?? '');
|
||||||
|
$group = $groups[$groupKey] ?? null;
|
||||||
|
$items[] = ['type' => 'section', 'data' => [
|
||||||
|
'key' => $groupKey,
|
||||||
|
'label' => $group === null ? 'Nicht mehr verfügbare Feldgruppe' : ($group->label ?: $group->name),
|
||||||
|
'description' => $group?->description,
|
||||||
|
'missing' => $group === null,
|
||||||
|
'used_in' => implode(', ', $usage['groups'][$groupKey] ?? []),
|
||||||
|
'cond' => $take('group:'.$groupKey, 'group'),
|
||||||
|
]];
|
||||||
|
|
||||||
|
foreach ($group?->itemList() ?? [] as $row) {
|
||||||
|
$field = $fields[$row['field']] ?? null;
|
||||||
|
|
||||||
|
if ($field !== null) {
|
||||||
|
$items[] = ['type' => 'field', 'data' => $this->fieldData($field, $row['required'], $usage, $take)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ein Einzelfeld direkt nach einer Feldgruppe gehört nicht zu ihr: Das Ende des Teilbereichs ist ausdrücklich.
|
||||||
|
if (($list[$position + 1]['kind'] ?? null) === 'field') {
|
||||||
|
$items[] = ['type' => 'end', 'data' => []];
|
||||||
|
}
|
||||||
|
} elseif ($kind === 'field') {
|
||||||
|
$field = $fields[(string) ($item['field'] ?? '')] ?? null;
|
||||||
|
|
||||||
|
if ($field !== null) {
|
||||||
|
$items[] = ['type' => 'field', 'data' => $this->fieldData($field, (bool) ($item['required'] ?? false), $usage, $take)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$areas[] = [
|
||||||
|
'key' => $key,
|
||||||
|
'title' => (string) ($step['title'] ?? ''),
|
||||||
|
'intro' => $step['intro'] ?? null,
|
||||||
|
'cond' => $take('step:'.$key, 'step'),
|
||||||
|
'items' => $items,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$rest = [];
|
||||||
|
|
||||||
|
foreach ($rules as $index => $rule) {
|
||||||
|
if (! isset($consumed[$index])) {
|
||||||
|
$rest[] = $this->cond($rule, $index) + ['target' => (string) ($rule['target'] ?? ''), 'value' => $rule['value'] ?? null];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'issues' => array_values(array_filter((array) ($draft['issues'] ?? []), 'is_string')),
|
||||||
|
'areas' => $areas,
|
||||||
|
'rules' => $rest,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Speichert die Ansicht: legt neue Felder und Teilbereiche im Katalog an, aktualisiert bearbeitete und liefert den
|
||||||
|
* Entwurf (ohne Texte, die der Editor getrennt führt).
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $editor
|
||||||
|
* @return array{issues: list<string>, steps: list<array<string, mixed>>, rules: list<array<string, mixed>>}
|
||||||
|
*/
|
||||||
|
public function persist(array $editor): array
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($editor): array {
|
||||||
|
$takenFields = InquiryField::query()->pluck('key')->all();
|
||||||
|
$takenGroups = InquiryFieldGroup::query()->pluck('key')->all();
|
||||||
|
$existingFields = InquiryField::query()->get()->keyBy('key');
|
||||||
|
$existingGroups = InquiryFieldGroup::query()->get()->keyBy('key');
|
||||||
|
$map = [];
|
||||||
|
$issues = [];
|
||||||
|
$steps = [];
|
||||||
|
$rules = [];
|
||||||
|
$order = 0;
|
||||||
|
|
||||||
|
foreach (array_values((array) ($editor['areas'] ?? [])) as $area) {
|
||||||
|
$area = is_array($area) ? $area : [];
|
||||||
|
$stepKey = Keys::valid($area['key'] ?? null) || preg_match('/^s[a-z0-9]{3,12}$/', (string) ($area['key'] ?? '')) === 1 ? (string) $area['key'] : 's'.Str::lower(Str::random(6));
|
||||||
|
$items = [];
|
||||||
|
$group = null;
|
||||||
|
$flush = function () use (&$group, &$items): void {
|
||||||
|
if ($group !== null) {
|
||||||
|
$items[] = $group;
|
||||||
|
$group = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (array_values((array) ($area['items'] ?? [])) as $block) {
|
||||||
|
$block = is_array($block) ? $block : [];
|
||||||
|
$data = is_array($block['data'] ?? null) ? $block['data'] : [];
|
||||||
|
|
||||||
|
switch ((string) ($block['type'] ?? '')) {
|
||||||
|
case 'issue':
|
||||||
|
$flush();
|
||||||
|
$items[] = ['kind' => 'issue'];
|
||||||
|
|
||||||
|
if ($issues === []) {
|
||||||
|
$issues = array_values(array_filter((array) ($data['issues'] ?? []), 'is_string'));
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'end':
|
||||||
|
$flush();
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'section':
|
||||||
|
$flush();
|
||||||
|
$original = (string) ($data['key'] ?? '');
|
||||||
|
$isMissing = (bool) ($data['missing'] ?? false);
|
||||||
|
$current = isset($existingGroups[$original]) ? $existingGroups[$original] : null;
|
||||||
|
$key = $current?->key ?? Keys::from((string) ($data['label'] ?? ''), $takenGroups);
|
||||||
|
$takenGroups[] = $key;
|
||||||
|
$map[$original] = $key;
|
||||||
|
$group = ['kind' => 'group', 'group' => $key, '_label' => trim((string) ($data['label'] ?? '')), '_description' => $data['description'] ?? null, '_rows' => [], '_current' => $current, '_missing' => $isMissing, '_new' => $current === null];
|
||||||
|
$this->rule($rules, 'group:'.$key, (array) ($data['cond'] ?? []), 'group', $order);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'field':
|
||||||
|
$field = $this->saveField($data, $existingFields, $takenFields);
|
||||||
|
$original = (string) ($data['key'] ?? '');
|
||||||
|
$map[$original] = $field->key;
|
||||||
|
$required = (bool) ($data['required'] ?? false);
|
||||||
|
|
||||||
|
if ($group !== null) {
|
||||||
|
$group['_rows'][] = ['field' => $field->key, 'required' => $required];
|
||||||
|
} else {
|
||||||
|
$items[] = ['kind' => 'field', 'field' => $field->key, 'required' => $required];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->rule($rules, 'field:'.$field->key, (array) ($data['cond'] ?? []), 'field', $order);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$flush();
|
||||||
|
$this->rule($rules, 'step:'.$stepKey, (array) ($area['cond'] ?? []), 'step', $order);
|
||||||
|
|
||||||
|
foreach ($items as $index => $item) {
|
||||||
|
if (($item['kind'] ?? null) !== 'group') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$items[$index] = $this->saveGroup($item, $existingGroups, $takenGroups);
|
||||||
|
}
|
||||||
|
|
||||||
|
$steps[] = [
|
||||||
|
'key' => $stepKey,
|
||||||
|
'title' => mb_substr(trim((string) ($area['title'] ?? '')), 0, 120),
|
||||||
|
'intro' => filled($area['intro'] ?? null) ? mb_substr(trim((string) $area['intro']), 0, 600) : null,
|
||||||
|
'items' => $items,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (array_values((array) ($editor['rules'] ?? [])) as $rule) {
|
||||||
|
$rule = is_array($rule) ? $rule : [];
|
||||||
|
$target = (string) ($rule['target'] ?? '');
|
||||||
|
[$kind, $key] = array_pad(explode(':', $target, 2), 2, '');
|
||||||
|
$rules[] = [
|
||||||
|
'effect' => (string) ($rule['effect'] ?? ''),
|
||||||
|
'target' => $kind === '' ? $target : $kind.':'.($map[$key] ?? $key),
|
||||||
|
'match' => ($rule['match'] ?? 'all') === 'any' ? 'any' : 'all',
|
||||||
|
'conditions' => $this->conditions((array) ($rule['conditions'] ?? []), $map),
|
||||||
|
'value' => filled($rule['value'] ?? null) ? (string) $rule['value'] : null,
|
||||||
|
'_pos' => is_numeric($rule['pos'] ?? null) ? (int) $rule['pos'] : 1000 + $order++,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($rules as $index => $rule) {
|
||||||
|
$rules[$index]['conditions'] = $this->conditions((array) $rule['conditions'], $map);
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($rules, fn (array $a, array $b): int => $a['_pos'] <=> $b['_pos']);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'issues' => $issues,
|
||||||
|
'steps' => $steps,
|
||||||
|
'rules' => array_map(function (array $rule): array {
|
||||||
|
unset($rule['_pos']);
|
||||||
|
|
||||||
|
return $rule;
|
||||||
|
}, $rules),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Beschriftungen der Wirkungen am Element, je Art des Ziels. */
|
||||||
|
public const EFFECT_LABELS = [
|
||||||
|
'step' => ['show' => 'Bereich nur anzeigen, wenn …', 'hide' => 'Bereich ausblenden, wenn …', 'skip' => 'Bereich überspringen, wenn …'],
|
||||||
|
'group' => ['show' => 'Teilbereich nur anzeigen, wenn …', 'hide' => 'Teilbereich ausblenden, wenn …'],
|
||||||
|
'field' => ['show' => 'Feld nur anzeigen, wenn …', 'hide' => 'Feld ausblenden, wenn …', 'require' => 'Pflichtfeld, wenn …'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Baumansicht für die Formularoberfläche (ADR-62): Ein Teilbereich trägt seine Felder selbst (items), die
|
||||||
|
* Ende-Markierung der flachen Ansicht entfällt. Die Umwandlung ist verlustfrei: fromTree(toTree(x)) liefert dieselbe
|
||||||
|
* Struktur, die persist() in denselben Entwurf überführt.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $view Ergebnis von expand()
|
||||||
|
* @return array{areas: list<array<string, mixed>>, rules: list<array<string, mixed>>}
|
||||||
|
*/
|
||||||
|
public static function toTree(array $view): array
|
||||||
|
{
|
||||||
|
$areas = [];
|
||||||
|
|
||||||
|
foreach (array_values((array) ($view['areas'] ?? [])) as $area) {
|
||||||
|
$area = is_array($area) ? $area : [];
|
||||||
|
$items = [];
|
||||||
|
$section = null;
|
||||||
|
|
||||||
|
foreach (array_values((array) ($area['items'] ?? [])) as $block) {
|
||||||
|
$block = is_array($block) ? $block : [];
|
||||||
|
$data = is_array($block['data'] ?? null) ? $block['data'] : [];
|
||||||
|
|
||||||
|
switch ((string) ($block['type'] ?? '')) {
|
||||||
|
case 'issue':
|
||||||
|
$section = null;
|
||||||
|
$items[] = ['kind' => 'issue', 'issues' => array_values(array_filter((array) ($data['issues'] ?? []), 'is_string'))];
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'end':
|
||||||
|
$section = null;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'section':
|
||||||
|
$items[] = ['kind' => 'section', ...$data, 'items' => []];
|
||||||
|
$section = array_key_last($items);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'field':
|
||||||
|
if ($section !== null) {
|
||||||
|
$items[$section]['items'][] = ['kind' => 'field', ...$data];
|
||||||
|
} else {
|
||||||
|
$items[] = ['kind' => 'field', ...$data];
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$areas[] = [...Arr::except($area, ['items']), 'items' => $items];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['areas' => $areas, 'rules' => array_values((array) ($view['rules'] ?? []))];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Umkehrung von toTree(): die flache Ansicht, die persist() erwartet. Nach jedem Teilbereich steht eine
|
||||||
|
* Ende-Markierung, damit folgende Einzelfelder nicht in ihn fallen.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $tree
|
||||||
|
* @return array{areas: list<array<string, mixed>>, rules: list<array<string, mixed>>}
|
||||||
|
*/
|
||||||
|
public static function fromTree(array $tree): array
|
||||||
|
{
|
||||||
|
$areas = [];
|
||||||
|
$field = fn (array $item): array => ['type' => 'field', 'data' => Arr::except($item, ['kind', '_id'])];
|
||||||
|
|
||||||
|
foreach (array_values((array) ($tree['areas'] ?? [])) as $area) {
|
||||||
|
$area = is_array($area) ? $area : [];
|
||||||
|
$blocks = [];
|
||||||
|
|
||||||
|
foreach (array_values((array) ($area['items'] ?? [])) as $item) {
|
||||||
|
$item = is_array($item) ? $item : [];
|
||||||
|
|
||||||
|
switch ((string) ($item['kind'] ?? '')) {
|
||||||
|
case 'issue':
|
||||||
|
$blocks[] = ['type' => 'issue', 'data' => ['issues' => array_values(array_filter((array) ($item['issues'] ?? []), 'is_string'))]];
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'section':
|
||||||
|
$blocks[] = ['type' => 'section', 'data' => Arr::except($item, ['kind', '_id', 'items'])];
|
||||||
|
|
||||||
|
foreach (array_values((array) ($item['items'] ?? [])) as $inner) {
|
||||||
|
$blocks[] = $field(is_array($inner) ? $inner : []);
|
||||||
|
}
|
||||||
|
|
||||||
|
$blocks[] = ['type' => 'end', 'data' => []];
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'field':
|
||||||
|
$blocks[] = $field($item);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$areas[] = [...Arr::except($area, ['items', '_id']), 'items' => $blocks];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['areas' => $areas, 'rules' => array_values((array) ($tree['rules'] ?? []))];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüft die Baumansicht vor dem Speichern. Was nur gekürzt oder ignoriert würde, wird hier benannt, damit die
|
||||||
|
* Verwaltung nichts stillschweigend verliert.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $tree
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function validateTree(array $tree): array
|
||||||
|
{
|
||||||
|
$errors = [];
|
||||||
|
$seen = [];
|
||||||
|
$issueQuestions = 0;
|
||||||
|
$limit = function (string $where, string $what, mixed $value, int $max) use (&$errors): void {
|
||||||
|
if (mb_strlen(trim((string) $value)) > $max) {
|
||||||
|
$errors[] = "$where: $what darf höchstens $max Zeichen lang sein.";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (array_values((array) ($tree['areas'] ?? [])) as $index => $area) {
|
||||||
|
$area = is_array($area) ? $area : [];
|
||||||
|
$title = trim((string) ($area['title'] ?? ''));
|
||||||
|
$where = 'Bereich '.($index + 1).($title !== '' ? ' „'.$title.'“' : '');
|
||||||
|
|
||||||
|
if ($title === '') {
|
||||||
|
$errors[] = "$where: Der Titel fehlt.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$limit($where, 'Der Titel', $title, 120);
|
||||||
|
$limit($where, 'Die Einleitung', $area['intro'] ?? '', 600);
|
||||||
|
|
||||||
|
$checkField = function (array $field) use (&$errors, &$seen, $where, $limit): void {
|
||||||
|
$label = trim((string) ($field['label'] ?? ''));
|
||||||
|
$name = $label !== '' ? '„'.$label.'“' : 'Ein Feld';
|
||||||
|
|
||||||
|
if ($label === '') {
|
||||||
|
$errors[] = "$where: Ein Feld hat keine Frage oder Beschriftung.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$limit($where, "Die Frage $name", $label, 200);
|
||||||
|
$limit($where, "Der Hilfetext von $name", $field['help'] ?? '', 600);
|
||||||
|
$type = FieldType::tryFrom((string) ($field['type'] ?? ''));
|
||||||
|
|
||||||
|
if ($type === null) {
|
||||||
|
$errors[] = "$where: Bei $name fehlt die Art der Antwort.";
|
||||||
|
} elseif ($type->hasOptions()) {
|
||||||
|
$options = array_filter((array) ($field['options'] ?? []), fn (mixed $option): bool => is_array($option) && trim((string) ($option['label'] ?? '')) !== '');
|
||||||
|
|
||||||
|
if ($options === []) {
|
||||||
|
$errors[] = "$where: Bei $name fehlen die Auswahlwerte.";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($options as $option) {
|
||||||
|
$limit($where, "Ein Auswahlwert von $name", $option['label'], 120);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$key = (string) ($field['key'] ?? '');
|
||||||
|
|
||||||
|
if ($key !== '' && ! str_starts_with($key, 'tmp_')) {
|
||||||
|
if (isset($seen[$key])) {
|
||||||
|
$errors[] = "$where: $name steht mehrfach im Formular.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$seen[$key] = true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
foreach (array_values((array) ($area['items'] ?? [])) as $item) {
|
||||||
|
$item = is_array($item) ? $item : [];
|
||||||
|
|
||||||
|
if (($item['kind'] ?? null) === 'issue') {
|
||||||
|
$issueQuestions++;
|
||||||
|
} elseif (($item['kind'] ?? null) === 'section') {
|
||||||
|
$label = trim((string) ($item['label'] ?? ''));
|
||||||
|
|
||||||
|
if ($label === '') {
|
||||||
|
$errors[] = "$where: Ein Teilbereich hat keine Überschrift.";
|
||||||
|
}
|
||||||
|
|
||||||
|
$limit($where, 'Die Überschrift eines Teilbereichs', $label, 200);
|
||||||
|
$limit($where, 'Die Erläuterung eines Teilbereichs', $item['description'] ?? '', 600);
|
||||||
|
|
||||||
|
foreach (array_values((array) ($item['items'] ?? [])) as $inner) {
|
||||||
|
$checkField(is_array($inner) ? $inner : []);
|
||||||
|
}
|
||||||
|
} elseif (($item['kind'] ?? null) === 'field') {
|
||||||
|
$checkField($item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($issueQuestions > 1) {
|
||||||
|
$errors[] = 'Die Frage nach dem Anliegen darf nur einmal im Formular vorkommen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_values(array_unique($errors));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auswahllisten für die Formularoberfläche: Feldarten, Verwendungen, Wirkungen, Vergleiche, Anliegen und die Felder
|
||||||
|
* des Katalogs mit Verwendung in anderen Formularen.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function clientConfig(?int $exceptTemplate = null): array
|
||||||
|
{
|
||||||
|
$usage = $this->usage($exceptTemplate);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'types' => array_map(fn (FieldType $type): array => ['value' => $type->value, 'label' => $type->label(), 'options' => $type->hasOptions(), 'control' => $type->canControl()], FieldType::cases()),
|
||||||
|
'purposes' => array_map(fn (FieldPurpose $purpose): array => ['value' => $purpose->value, 'label' => $purpose->label(), 'types' => array_map(fn (FieldType $type): string => $type->value, $purpose->types())], FieldPurpose::cases()),
|
||||||
|
'effects' => self::EFFECT_LABELS,
|
||||||
|
'operators' => TemplateCompiler::OPERATORS,
|
||||||
|
'issues' => InquiryIssue::tree(),
|
||||||
|
'catalog' => InquiryField::query()->offered()->orderBy('name')->get()->map(fn (InquiryField $field): array => [
|
||||||
|
'key' => $field->key,
|
||||||
|
'name' => $field->name,
|
||||||
|
'label' => $field->label,
|
||||||
|
'help' => $field->help,
|
||||||
|
'type' => $field->type->value,
|
||||||
|
'options' => $field->optionList(),
|
||||||
|
'purpose' => $field->purpose?->value,
|
||||||
|
'used_in' => implode(', ', $usage['fields'][$field->key] ?? []),
|
||||||
|
])->values()->all(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eine neue Zeile in der Karteikarte der Bedingungen (leer: Standardwerte).
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public static function newCondition(): array
|
||||||
|
{
|
||||||
|
return ['source' => null, 'op' => 'eq', 'values' => []];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Vorläufige Kennung eines neuen Feldes oder Teilbereichs. */
|
||||||
|
public static function temporaryKey(): string
|
||||||
|
{
|
||||||
|
return 'tmp_'.Str::lower(Str::random(8));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verwendung von Feldern und Feldgruppen in Vorlagen: [Art => [Kennung => [Vorlagennamen]]]. Zeigt im Editor, wo
|
||||||
|
* eine Änderung noch wirkt (bei der nächsten Veröffentlichung dieser Vorlagen).
|
||||||
|
*
|
||||||
|
* @return array{fields: array<string, list<string>>, groups: array<string, list<string>>}
|
||||||
|
*/
|
||||||
|
public function usage(?int $exceptTemplate = null): array
|
||||||
|
{
|
||||||
|
$groups = InquiryFieldGroup::query()->get()->keyBy('key');
|
||||||
|
$usage = ['fields' => [], 'groups' => []];
|
||||||
|
|
||||||
|
foreach (InquiryTemplate::query()->whereNull('archived_at')->when($exceptTemplate !== null, fn ($query) => $query->whereKeyNot($exceptTemplate))->get() as $template) {
|
||||||
|
foreach ((array) ($template->draft['steps'] ?? []) as $step) {
|
||||||
|
foreach ((array) ($step['items'] ?? []) as $item) {
|
||||||
|
if (($item['kind'] ?? null) === 'field') {
|
||||||
|
$usage['fields'][(string) ($item['field'] ?? '')][$template->id] = $template->name;
|
||||||
|
} elseif (($item['kind'] ?? null) === 'group') {
|
||||||
|
$key = (string) ($item['group'] ?? '');
|
||||||
|
$usage['groups'][$key][$template->id] = $template->name;
|
||||||
|
|
||||||
|
foreach ($groups[$key]?->itemList() ?? [] as $row) {
|
||||||
|
$usage['fields'][$row['field']][$template->id] = $template->name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $usage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $rule
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function cond(array $rule, int $pos): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'effect' => (string) ($rule['effect'] ?? ''),
|
||||||
|
'match' => ($rule['match'] ?? 'all') === 'any' ? 'any' : 'all',
|
||||||
|
'conditions' => array_values(array_map(fn (mixed $condition): array => [
|
||||||
|
'source' => (string) ($condition['source'] ?? ''),
|
||||||
|
'op' => (string) ($condition['op'] ?? 'eq'),
|
||||||
|
'values' => array_values(array_filter((array) ($condition['values'] ?? []), 'is_string')),
|
||||||
|
], array_filter((array) ($rule['conditions'] ?? []), 'is_array'))),
|
||||||
|
'pos' => $pos,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array{fields: array<string, list<string>>, groups: array<string, list<string>>} $usage
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function fieldData(InquiryField $field, bool $required, array $usage, callable $take): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'key' => $field->key,
|
||||||
|
'label' => $field->label,
|
||||||
|
'name' => $field->name,
|
||||||
|
'help' => $field->help,
|
||||||
|
'type' => $field->type->value,
|
||||||
|
'options' => $field->optionList(),
|
||||||
|
'required' => $required,
|
||||||
|
'purpose' => $field->purpose?->value,
|
||||||
|
'used_in' => implode(', ', $usage['fields'][$field->key] ?? []),
|
||||||
|
'cond' => $take('field:'.$field->key, 'field'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<array<string, mixed>> $rules
|
||||||
|
* @param array<string, mixed> $cond
|
||||||
|
*/
|
||||||
|
private function rule(array &$rules, string $target, array $cond, string $kind, int &$order): void
|
||||||
|
{
|
||||||
|
$effect = (string) ($cond['effect'] ?? '');
|
||||||
|
$conditions = array_values(array_filter((array) ($cond['conditions'] ?? []), fn (mixed $c): bool => is_array($c) && filled($c['source'] ?? null)));
|
||||||
|
|
||||||
|
if ($effect === '' || ! in_array($effect, self::EFFECTS[$kind], true) || $conditions === []) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rules[] = [
|
||||||
|
'effect' => $effect,
|
||||||
|
'target' => $target,
|
||||||
|
'match' => ($cond['match'] ?? 'all') === 'any' ? 'any' : 'all',
|
||||||
|
'conditions' => $conditions,
|
||||||
|
'value' => null,
|
||||||
|
'_pos' => is_numeric($cond['pos'] ?? null) ? (int) $cond['pos'] : 1000 + $order++,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<int|string, mixed> $conditions
|
||||||
|
* @param array<string, string> $map
|
||||||
|
* @return list<array{source: string, op: string, values: list<string>}>
|
||||||
|
*/
|
||||||
|
private function conditions(array $conditions, array $map): array
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
|
||||||
|
foreach (array_values($conditions) as $condition) {
|
||||||
|
$condition = is_array($condition) ? $condition : [];
|
||||||
|
$source = (string) ($condition['source'] ?? '');
|
||||||
|
|
||||||
|
if ($source === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result[] = [
|
||||||
|
'source' => $map[$source] ?? $source,
|
||||||
|
'op' => in_array($condition['op'] ?? 'eq', array_keys(TemplateCompiler::OPERATORS), true) ? (string) ($condition['op'] ?? 'eq') : 'eq',
|
||||||
|
'values' => array_values(array_filter((array) ($condition['values'] ?? []), 'is_string')),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $data
|
||||||
|
* @param Collection<string, InquiryField> $existing
|
||||||
|
* @param list<string> $taken
|
||||||
|
*/
|
||||||
|
private function saveField(array $data, $existing, array &$taken): InquiryField
|
||||||
|
{
|
||||||
|
$key = (string) ($data['key'] ?? '');
|
||||||
|
$label = mb_substr(trim((string) ($data['label'] ?? '')), 0, 200);
|
||||||
|
$help = filled($data['help'] ?? null) ? mb_substr(trim((string) $data['help']), 0, 600) : null;
|
||||||
|
$type = FieldType::tryFrom((string) ($data['type'] ?? '')) ?? FieldType::Text;
|
||||||
|
$purpose = FieldPurpose::tryFrom((string) ($data['purpose'] ?? ''));
|
||||||
|
$field = $existing[$key] ?? null;
|
||||||
|
|
||||||
|
if ($field !== null) {
|
||||||
|
$type = $field->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($purpose !== null && ! in_array($type, $purpose->types(), true)) {
|
||||||
|
$purpose = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = $type->hasOptions() ? Keys::withKeys(array_values((array) ($data['options'] ?? []))) : null;
|
||||||
|
|
||||||
|
if ($field === null) {
|
||||||
|
$final = Keys::from($label, $taken);
|
||||||
|
$taken[] = $final;
|
||||||
|
|
||||||
|
return InquiryField::query()->create([
|
||||||
|
'key' => $final,
|
||||||
|
'name' => mb_substr($label, 0, 120),
|
||||||
|
'label' => $label,
|
||||||
|
'help' => $help,
|
||||||
|
'type' => $type->value,
|
||||||
|
'options' => $options,
|
||||||
|
'settings' => null,
|
||||||
|
'purpose' => $purpose?->value,
|
||||||
|
'active' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$field->fill(['label' => $label, 'help' => $help, 'options' => $options ?? $field->options, 'purpose' => $purpose?->value]);
|
||||||
|
|
||||||
|
if ($field->isDirty()) {
|
||||||
|
$field->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $field;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $group Teilbereich mit gesammelten Feldern (_rows)
|
||||||
|
* @param Collection<string, InquiryFieldGroup> $existing
|
||||||
|
* @param list<string> $taken
|
||||||
|
* @return array{kind: string, group: string}
|
||||||
|
*/
|
||||||
|
private function saveGroup(array $group, $existing, array &$taken): array
|
||||||
|
{
|
||||||
|
$item = ['kind' => 'group', 'group' => $group['group']];
|
||||||
|
|
||||||
|
if ($group['_missing']) {
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
$label = mb_substr($group['_label'], 0, 200);
|
||||||
|
$description = filled($group['_description']) ? mb_substr(trim((string) $group['_description']), 0, 600) : null;
|
||||||
|
$current = $group['_current'];
|
||||||
|
|
||||||
|
if ($current === null) {
|
||||||
|
InquiryFieldGroup::query()->create([
|
||||||
|
'key' => $group['group'],
|
||||||
|
'name' => mb_substr($label, 0, 120),
|
||||||
|
'label' => $label,
|
||||||
|
'description' => $description,
|
||||||
|
'items' => $group['_rows'],
|
||||||
|
'sort_order' => ((int) InquiryFieldGroup::query()->max('sort_order')) + 10,
|
||||||
|
'active' => true,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Die Bezeichnung bleibt, wenn der Teilbereich vorher keine eigene öffentliche Überschrift hatte und unverändert ist.
|
||||||
|
$keepLabel = blank($current->label) && $label === $current->name;
|
||||||
|
$current->fill(['label' => $keepLabel ? null : $label, 'description' => $description, 'items' => $group['_rows']]);
|
||||||
|
|
||||||
|
if ($current->isDirty()) {
|
||||||
|
$current->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,7 +28,9 @@ public function evaluate(array $form, array $values): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ((array) $form['steps'] as $step) {
|
foreach ((array) $form['steps'] as $step) {
|
||||||
$stepVisible = ! $this->any($byTarget['step:'.$step['key']] ?? [], 'skip', $context);
|
// Ein Bereich lässt sich wie eine Gruppe anzeigen oder ausblenden; „überspringen“ bleibt für ältere Vorlagen gültig.
|
||||||
|
$stepRules = $byTarget['step:'.$step['key']] ?? [];
|
||||||
|
$stepVisible = ! $this->any($stepRules, 'skip', $context) && $this->visible($stepRules, $context);
|
||||||
$state['steps'][$step['key']] = $stepVisible;
|
$state['steps'][$step['key']] = $stepVisible;
|
||||||
|
|
||||||
foreach ($step['items'] as $item) {
|
foreach ($step['items'] as $item) {
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Communication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Der Anfragegrund, mit dem das Widget „Anfrage“ ein veröffentlichtes Formular lädt (ADR-61): ein vorgewähltes Anliegen,
|
||||||
|
* optional ein Unteranliegen, und die Formularführung. Das ist eine Darstellungs- und Vorauswahlentscheidung, keine
|
||||||
|
* Berechtigung: Alles, was ein Anfragegrund wählen kann, bietet das veröffentlichte Formular ohnehin an. Aus dem Grund
|
||||||
|
* entsteht dieselbe Konfiguration wie bei einem Anfrage-Einstieg, damit Auslieferung, Auswertung und Annahme nur eine
|
||||||
|
* Auslegung haben (FormFactory::effective).
|
||||||
|
*/
|
||||||
|
final class FormReason
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bereinigt die Angaben aus der Adresse oder der Anfrage des Browsers: nur bekannte Schlüssel, nur gültige Kennungen.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $input
|
||||||
|
* @return array{anliegen: ?string, unteranliegen: ?string, modus: ?string}
|
||||||
|
*/
|
||||||
|
public static function clean(array $input): array
|
||||||
|
{
|
||||||
|
$key = fn (mixed $value): ?string => Keys::valid($value) ? $value : null;
|
||||||
|
$mode = $input['modus'] ?? null;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'anliegen' => $key($input['anliegen'] ?? null),
|
||||||
|
'unteranliegen' => $key($input['unteranliegen'] ?? null),
|
||||||
|
'modus' => $mode === 'wizard' || $mode === 'compact' ? $mode : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Konfiguration, die FormFactory::effective erwartet. Ein Anliegen, das die Fassung nicht kennt, schränkt
|
||||||
|
* nichts ein (das Formular fragt dann wie gewohnt).
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $definition aufgelöste Fassung
|
||||||
|
* @param array<string, mixed> $reason
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public static function config(array $definition, array $reason): array
|
||||||
|
{
|
||||||
|
$config = ['mode' => ($reason['modus'] ?? null) === 'wizard' ? 'wizard' : 'compact', 'open' => 'inline'];
|
||||||
|
$issue = $reason['anliegen'] ?? null;
|
||||||
|
|
||||||
|
foreach ((array) ($definition['issues'] ?? []) as $top) {
|
||||||
|
if ($top['key'] !== $issue) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$config['allowed_issues'] = [$issue];
|
||||||
|
$config['defaults'] = ['anliegen' => $issue];
|
||||||
|
$sub = $reason['unteranliegen'] ?? null;
|
||||||
|
|
||||||
|
if ($sub !== null && in_array($sub, array_column((array) $top['children'], 'key'), true)) {
|
||||||
|
$config['allowed_subissues'] = [$sub];
|
||||||
|
$config['defaults']['unteranliegen'] = $sub;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $config;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,9 +16,14 @@
|
|||||||
*/
|
*/
|
||||||
final class FormToken
|
final class FormToken
|
||||||
{
|
{
|
||||||
public static function issue(int $entryId, int $versionId): string
|
/**
|
||||||
|
* @param string $kind 'entry' (Anfrage-Einstieg) oder 'form' (veröffentlichte Vorlage, vom Widget „Anfrage“ gewählt);
|
||||||
|
* $entryId ist dann die Kennung des Einstiegs beziehungsweise der Vorlage
|
||||||
|
*/
|
||||||
|
public static function issue(int $entryId, int $versionId, string $kind = 'entry'): string
|
||||||
{
|
{
|
||||||
return Crypt::encryptString(json_encode([
|
return Crypt::encryptString(json_encode([
|
||||||
|
'k' => $kind === 'form' ? 'form' : 'entry',
|
||||||
'e' => $entryId,
|
'e' => $entryId,
|
||||||
'v' => $versionId,
|
'v' => $versionId,
|
||||||
't' => now()->getTimestamp(),
|
't' => now()->getTimestamp(),
|
||||||
@@ -27,7 +32,7 @@ public static function issue(int $entryId, int $versionId): string
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array{e: int, v: int, t: int, n: string}|null
|
* @return array{k: string, e: int, v: int, t: int, n: string}|null
|
||||||
*/
|
*/
|
||||||
public static function read(mixed $token): ?array
|
public static function read(mixed $token): ?array
|
||||||
{
|
{
|
||||||
@@ -45,6 +50,6 @@ public static function read(mixed $token): ?array
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['e' => (int) $data['e'], 'v' => (int) $data['v'], 't' => (int) $data['t'], 'n' => $data['n']];
|
return ['k' => ($data['k'] ?? 'entry') === 'form' ? 'form' : 'entry', 'e' => (int) $data['e'], 'v' => (int) $data['v'], 't' => (int) $data['t'], 'n' => $data['n']];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,6 +44,20 @@ public function issueTitle(): string
|
|||||||
return trim(implode(' › ', array_filter([$this->issue_label, $this->subissue_label])));
|
return trim(implode(' › ', array_filter([$this->issue_label, $this->subissue_label])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Woher die Anfrage kam: der Anfrage-Einstieg (älterer Weg) oder das Formular, das das Widget „Anfrage“ eingebunden hat.
|
||||||
|
*/
|
||||||
|
public function channelTitle(): string
|
||||||
|
{
|
||||||
|
if ($this->entry !== null) {
|
||||||
|
return $this->entry->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$template = $this->templateVersion?->template;
|
||||||
|
|
||||||
|
return $template !== null ? 'Formular „'.$template->name.'“' : 'Formular gelöscht';
|
||||||
|
}
|
||||||
|
|
||||||
public function contactTitle(): string
|
public function contactTitle(): string
|
||||||
{
|
{
|
||||||
return $this->contact_name ?: ($this->contact_email ?: 'Unbekannt');
|
return $this->contact_name ?: ($this->contact_email ?: 'Unbekannt');
|
||||||
|
|||||||
@@ -50,10 +50,62 @@ public function deliver(InquiryEntry $entry, ?int $versionId = null): ?array
|
|||||||
* @throws SubmissionException
|
* @throws SubmissionException
|
||||||
*/
|
*/
|
||||||
public function submit(InquiryEntry $entry, array $payload): array
|
public function submit(InquiryEntry $entry, array $payload): array
|
||||||
|
{
|
||||||
|
return $this->accept('entry', $entry->id, $entry->id, fn (?int $version): ?array => $this->deliver($entry, $version), $payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Fassung und das wirksame Formular einer veröffentlichten Vorlage für einen Besucher, wie sie das Widget
|
||||||
|
* „Anfrage“ ausliefert. $reason legt den Anfragegrund fest: ein vorgewähltes Anliegen (und Unteranliegen) und die
|
||||||
|
* Formularführung. Null, wenn die Vorlage nicht veröffentlicht oder archiviert ist.
|
||||||
|
*
|
||||||
|
* @param array{anliegen?: ?string, unteranliegen?: ?string, modus?: ?string} $reason
|
||||||
|
* @return array{form: array<string, mixed>, version: InquiryTemplateVersion}|null
|
||||||
|
*/
|
||||||
|
public function deliverForm(InquiryTemplate $template, array $reason = [], ?int $versionId = null): ?array
|
||||||
|
{
|
||||||
|
$template->loadMissing('publishedVersion');
|
||||||
|
|
||||||
|
if ($template->archived_at !== null || $template->publishedVersion === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = $template->publishedVersion;
|
||||||
|
|
||||||
|
if ($versionId !== null && $versionId !== $version->id) {
|
||||||
|
$version = InquiryTemplateVersion::query()->where('template_id', $template->id)->find($versionId) ?? $version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['form' => $this->factory->effective($version->definition, FormReason::config($version->definition, $reason)), 'version' => $version];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nimmt eine Anfrage für eine veröffentlichte Vorlage an (Widget „Anfrage“). Die Verarbeitung ist dieselbe wie über
|
||||||
|
* einen Einstieg; die Anfrage trägt dann keine Einstiegskennung, sondern verweist über ihre Fassung auf die Vorlage.
|
||||||
|
*
|
||||||
|
* @param array{anliegen?: ?string, unteranliegen?: ?string, modus?: ?string} $reason
|
||||||
|
* @param array<string, mixed> $payload
|
||||||
|
* @return array{reference: string, created: bool}
|
||||||
|
*
|
||||||
|
* @throws SubmissionException
|
||||||
|
*/
|
||||||
|
public function submitForm(InquiryTemplate $template, array $reason, array $payload): array
|
||||||
|
{
|
||||||
|
return $this->accept('form', $template->id, null, fn (?int $version): ?array => $this->deliverForm($template, $reason, $version), $payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param callable(?int): (array{form: array<string, mixed>, version: InquiryTemplateVersion}|null) $deliver
|
||||||
|
* @param array<string, mixed> $payload
|
||||||
|
* @return array{reference: string, created: bool}
|
||||||
|
*
|
||||||
|
* @throws SubmissionException
|
||||||
|
*/
|
||||||
|
private function accept(string $kind, int $targetId, ?int $entryId, callable $deliver, array $payload): array
|
||||||
{
|
{
|
||||||
$token = FormToken::read($payload['token'] ?? null);
|
$token = FormToken::read($payload['token'] ?? null);
|
||||||
|
|
||||||
if ($token === null || $token['e'] !== $entry->id) {
|
if ($token === null || $token['k'] !== $kind || $token['e'] !== $targetId) {
|
||||||
throw new SubmissionException('Das Formular ist abgelaufen. Bitte laden Sie die Seite neu; Ihre Eingaben bleiben dabei nicht erhalten.', [], 419);
|
throw new SubmissionException('Das Formular ist abgelaufen. Bitte laden Sie die Seite neu; Ihre Eingaben bleiben dabei nicht erhalten.', [], 419);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +121,7 @@ public function submit(InquiryEntry $entry, array $payload): array
|
|||||||
return ['reference' => $existing->reference, 'created' => false];
|
return ['reference' => $existing->reference, 'created' => false];
|
||||||
}
|
}
|
||||||
|
|
||||||
$delivered = $this->deliver($entry, $token['v']);
|
$delivered = $deliver($token['v']);
|
||||||
|
|
||||||
if ($delivered === null) {
|
if ($delivered === null) {
|
||||||
throw new SubmissionException('Dieses Anfrageformular ist zurzeit nicht verfügbar.', [], 410);
|
throw new SubmissionException('Dieses Anfrageformular ist zurzeit nicht verfügbar.', [], 410);
|
||||||
@@ -101,7 +153,7 @@ public function submit(InquiryEntry $entry, array $payload): array
|
|||||||
try {
|
try {
|
||||||
$inquiry = DB::transaction(fn (): Inquiry => Inquiry::query()->create([
|
$inquiry = DB::transaction(fn (): Inquiry => Inquiry::query()->create([
|
||||||
'reference' => $this->reference(),
|
'reference' => $this->reference(),
|
||||||
'entry_id' => $entry->id,
|
'entry_id' => $entryId,
|
||||||
'template_version_id' => $delivered['version']->id,
|
'template_version_id' => $delivered['version']->id,
|
||||||
'submission_token' => hash('sha256', $token['n']),
|
'submission_token' => hash('sha256', $token['n']),
|
||||||
'issue_key' => $result['issue']['key'] ?? null,
|
'issue_key' => $result['issue']['key'] ?? null,
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ private function rules(array $rules, array $fields, array $tree, bool $hasIssue,
|
|||||||
}
|
}
|
||||||
|
|
||||||
$kindOk = match ($effect) {
|
$kindOk = match ($effect) {
|
||||||
'show', 'hide' => in_array($targetKind, ['group', 'field'], true),
|
'show', 'hide' => in_array($targetKind, ['step', 'group', 'field'], true),
|
||||||
'require', 'preset' => $targetKind === 'field',
|
'require', 'preset' => $targetKind === 'field',
|
||||||
'skip' => $targetKind === 'step',
|
'skip' => $targetKind === 'step',
|
||||||
default => false,
|
default => false,
|
||||||
|
|||||||
@@ -0,0 +1,222 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Design;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Farbrechnung für die Farbpalette (ADR-67): Normalisierung von HEX-Werten, Kontrast nach WCAG 2.2 und die Werte, die ein
|
||||||
|
* Abschnitt mit eigener Farbe an seine Bausteine weitergibt. Reine Funktionen ohne Zugriff auf Datenbank oder Anfrage.
|
||||||
|
*
|
||||||
|
* Die Rechnung steht gleichlautend in resources/views/filament/design/farben.blade.php (Live-Vorschau im Browser); beide
|
||||||
|
* werden gegen dieselben Vergleichswerte geprüft (tests/Unit/ColorContrastTest.php).
|
||||||
|
*/
|
||||||
|
final class ColorContrast
|
||||||
|
{
|
||||||
|
/** Mindestkontrast für normalen Text (WCAG 2.2 AA, 1.4.3). */
|
||||||
|
public const NORMAL_TEXT = 4.5;
|
||||||
|
|
||||||
|
/** Mindestkontrast für großen Text und für Bedienelemente (WCAG 2.2 AA, 1.4.3 und 1.4.11). */
|
||||||
|
public const LARGE_TEXT = 3.0;
|
||||||
|
|
||||||
|
/** Erhöhter Kontrast (AAA) für normalen Text. */
|
||||||
|
public const ENHANCED = 7.0;
|
||||||
|
|
||||||
|
public const NAVY = '#032551';
|
||||||
|
|
||||||
|
public const WHITE = '#ffffff';
|
||||||
|
|
||||||
|
public const YELLOW = '#fcd10a';
|
||||||
|
|
||||||
|
public const GREEN_DEEP = '#3b7b09';
|
||||||
|
|
||||||
|
public const FOCUS_BLUE = '#1769aa';
|
||||||
|
|
||||||
|
public const BLACK = '#000000';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* „#abc“ und „#aabbcc“ (auch ohne Raute, beliebige Schreibweise) → „#aabbcc“ in Kleinbuchstaben; sonst null.
|
||||||
|
*/
|
||||||
|
public static function normalize(mixed $value): ?string
|
||||||
|
{
|
||||||
|
if (! is_string($value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = ltrim(trim($value), '#');
|
||||||
|
|
||||||
|
if (preg_match('/^[0-9a-fA-F]{3}$/', $value) === 1) {
|
||||||
|
$value = $value[0].$value[0].$value[1].$value[1].$value[2].$value[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
return preg_match('/^[0-9a-fA-F]{6}$/', $value) === 1 ? '#'.strtolower($value) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{0: int, 1: int, 2: int}
|
||||||
|
*/
|
||||||
|
public static function rgb(string $hex): array
|
||||||
|
{
|
||||||
|
$hex = self::normalize($hex) ?? self::BLACK;
|
||||||
|
|
||||||
|
return [hexdec(substr($hex, 1, 2)), hexdec(substr($hex, 3, 2)), hexdec(substr($hex, 5, 2))];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Relative Leuchtdichte nach WCAG (0 = Schwarz, 1 = Weiß). */
|
||||||
|
public static function luminance(string $hex): float
|
||||||
|
{
|
||||||
|
[$r, $g, $b] = array_map(static function (int $channel): float {
|
||||||
|
$c = $channel / 255;
|
||||||
|
|
||||||
|
return $c <= 0.03928 ? $c / 12.92 : (($c + 0.055) / 1.055) ** 2.4;
|
||||||
|
}, self::rgb($hex));
|
||||||
|
|
||||||
|
return 0.2126 * $r + 0.7152 * $g + 0.0722 * $b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Kontrastverhältnis zweier Farben (1 bis 21), auf zwei Stellen gerundet. */
|
||||||
|
public static function ratio(string $a, string $b): float
|
||||||
|
{
|
||||||
|
$la = self::luminance($a);
|
||||||
|
$lb = self::luminance($b);
|
||||||
|
|
||||||
|
return round((max($la, $lb) + 0.05) / (min($la, $lb) + 0.05), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüfstatus: „enhanced“ (ab 7:1), „aa“ (ab 4,5:1), „large“ (ab 3:1, nur große Schrift) oder „fail“.
|
||||||
|
*/
|
||||||
|
public static function rating(float $ratio): string
|
||||||
|
{
|
||||||
|
return match (true) {
|
||||||
|
$ratio >= self::ENHANCED => 'enhanced',
|
||||||
|
$ratio >= self::NORMAL_TEXT => 'aa',
|
||||||
|
$ratio >= self::LARGE_TEXT => 'large',
|
||||||
|
default => 'fail',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Ob die Schrift auf dem Hintergrund für normalen Text ausreicht. */
|
||||||
|
public static function passes(string $text, string $background): bool
|
||||||
|
{
|
||||||
|
return self::ratio($text, $background) >= self::NORMAL_TEXT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Empfohlene Schriftfarbe: bevorzugt Marken-Dunkelblau oder Weiß, sonst Schwarz oder Weiß, jeweils die mit dem
|
||||||
|
* höchsten Kontrast, die für normalen Text ausreicht. Nur eine Bedienhilfe: Sie wird nie von selbst gesetzt.
|
||||||
|
*/
|
||||||
|
public static function suggestText(string $background): string
|
||||||
|
{
|
||||||
|
$brand = self::best($background, [self::NAVY, self::WHITE]);
|
||||||
|
|
||||||
|
if (self::passes($brand, $background)) {
|
||||||
|
return $brand;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::best($background, [self::BLACK, self::WHITE]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mischt zwei Farben; $share ist der Anteil von $b (0 bis 1).
|
||||||
|
*/
|
||||||
|
public static function mix(string $a, string $b, float $share): string
|
||||||
|
{
|
||||||
|
$ra = self::rgb($a);
|
||||||
|
$rb = self::rgb($b);
|
||||||
|
$out = '#';
|
||||||
|
|
||||||
|
foreach ([0, 1, 2] as $i) {
|
||||||
|
$out .= str_pad(dechex((int) round($ra[$i] * (1 - $share) + $rb[$i] * $share)), 2, '0', STR_PAD_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ob die Fläche eine dunkle Fläche im Sinn der Bausteine ist: Die Schrift ist heller als der Hintergrund. Dann gelten
|
||||||
|
* die Bedeutungswerte der dunklen Fläche (scope-dark), sonst die der hellen.
|
||||||
|
*/
|
||||||
|
public static function isDarkSurface(string $text, string $background): bool
|
||||||
|
{
|
||||||
|
return self::luminance($text) > self::luminance($background);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bedeutungswerte (CSS-Eigenschaften), die ein Abschnitt mit eigener Farbe an seine Bausteine weitergibt. Alle
|
||||||
|
* abgeleiteten Farben werden gegen den Hintergrund geprüft: Fließtext 4,5:1, Fokus und Schaltfläche 3:1.
|
||||||
|
*
|
||||||
|
* @return array<string, string> Eigenschaft (ohne „--“) => Wert
|
||||||
|
*/
|
||||||
|
public static function surfaceProperties(string $background, string $text): array
|
||||||
|
{
|
||||||
|
$background = self::normalize($background) ?? self::WHITE;
|
||||||
|
$text = self::normalize($text) ?? self::NAVY;
|
||||||
|
$dark = self::isDarkSurface($text, $background);
|
||||||
|
|
||||||
|
// Zurückhaltender Text: ein Stück zum Hintergrund hin, aber nie unter 4,5:1.
|
||||||
|
$muted = self::mix($text, $background, 0.15);
|
||||||
|
if (! self::passes($muted, $background)) {
|
||||||
|
$muted = $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fokus: Marken-Gelb auf dunklen, Marken-Blau auf hellen Flächen; reicht der Kontrast nicht, Weiß oder Schwarz.
|
||||||
|
$focus = self::firstWithRatio($background, $dark
|
||||||
|
? [self::YELLOW, self::WHITE, self::BLACK]
|
||||||
|
: [self::FOCUS_BLUE, self::NAVY, self::BLACK, self::WHITE], self::LARGE_TEXT);
|
||||||
|
|
||||||
|
// Link beim Überfahren: Markenton, wenn er als Text lesbar bleibt, sonst die Schriftfarbe.
|
||||||
|
$linkHover = self::firstWithRatio($background, $dark ? [self::YELLOW] : [self::GREEN_DEEP], self::NORMAL_TEXT) ?? $text;
|
||||||
|
|
||||||
|
// Schaltfläche: Fläche mit 3:1 gegen den Hintergrund, Beschriftung mit 4,5:1 gegen die Schaltfläche.
|
||||||
|
$action = self::firstWithRatio($background, $dark
|
||||||
|
? [self::YELLOW, self::WHITE, self::BLACK]
|
||||||
|
: [self::GREEN_DEEP, self::NAVY, self::BLACK, self::WHITE], self::LARGE_TEXT) ?? $text;
|
||||||
|
$actionText = self::best($action, [self::NAVY, self::WHITE]);
|
||||||
|
if (! self::passes($actionText, $action)) {
|
||||||
|
$actionText = self::best($action, [self::BLACK, self::WHITE]);
|
||||||
|
}
|
||||||
|
// Beim Überfahren etwas vom Beschriftungston wegmischen: Der Kontrast zur Beschriftung wächst.
|
||||||
|
$actionHover = self::mix($action, self::luminance($actionText) > 0.5 ? self::BLACK : self::WHITE, 0.16);
|
||||||
|
|
||||||
|
[$r, $g, $b] = self::rgb($text);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'color-surface' => $background,
|
||||||
|
'color-text' => $text,
|
||||||
|
'color-text-muted' => $muted,
|
||||||
|
'color-heading' => $text,
|
||||||
|
'color-link' => $text,
|
||||||
|
'color-link-hover' => $linkHover,
|
||||||
|
'color-border' => "rgb($r $g $b / 32%)",
|
||||||
|
'color-border-strong' => "rgb($r $g $b / 60%)",
|
||||||
|
'color-focus' => $focus ?? $text,
|
||||||
|
'color-action' => $action,
|
||||||
|
'color-action-hover' => $actionHover,
|
||||||
|
'color-action-text' => $actionText,
|
||||||
|
'color-action-secondary-text' => $text,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $candidates
|
||||||
|
*/
|
||||||
|
private static function best(string $background, array $candidates): string
|
||||||
|
{
|
||||||
|
usort($candidates, static fn (string $a, string $b): int => self::ratio($b, $background) <=> self::ratio($a, $background));
|
||||||
|
|
||||||
|
return $candidates[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $candidates
|
||||||
|
*/
|
||||||
|
private static function firstWithRatio(string $background, array $candidates, float $minimum): ?string
|
||||||
|
{
|
||||||
|
foreach ($candidates as $candidate) {
|
||||||
|
if (self::ratio($candidate, $background) >= $minimum) {
|
||||||
|
return $candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,355 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Design;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Page;
|
||||||
|
use App\Domain\Cms\Sections\SectionStyle;
|
||||||
|
use App\Domain\Cms\Widgets\Support\TextMarkers;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zentrale Farbpalette der Website (ADR-67, Schlüssel „design.palette“ in site_settings): bis zu zehn benannte Farben, jede
|
||||||
|
* mit Hintergrund- und Schriftfarbe. Abschnitte verweisen auf eine Farbe (style.background = „palette“, style.palette_slot =
|
||||||
|
* Kennung); die Farbwerte stehen nur hier.
|
||||||
|
*
|
||||||
|
* - Die Kennung („c1“, „c2“ …) wird nie wieder vergeben, auch nicht nach dem Entfernen einer Farbe.
|
||||||
|
* - Eine Änderung der Farbwerte wirkt sofort auf alle Abschnitte mit dieser Farbe, auch auf veröffentlichten Seiten
|
||||||
|
* (die Revisionen speichern nur den Verweis). Darum zeigt die Verwaltung die betroffenen Seiten vor dem Speichern
|
||||||
|
* (usage), und eine Farbe in Verwendung lässt sich nicht entfernen.
|
||||||
|
* - Neue und geänderte Farben müssen für normalen Text 4,5:1 erreichen (WCAG 2.2 AA).
|
||||||
|
* - Die öffentliche Ausgabe hängt nie am Erfolg dieser Klasse: Fehlt die Tabelle, ist die Datenbank nicht erreichbar oder
|
||||||
|
* sind die Daten beschädigt, gibt es keine Farben, und Abschnitte mit Verweis erscheinen ohne eigene Fläche.
|
||||||
|
*/
|
||||||
|
final class DesignPalette
|
||||||
|
{
|
||||||
|
public const KEY = 'design.palette';
|
||||||
|
|
||||||
|
public const MAX_SLOTS = 10;
|
||||||
|
|
||||||
|
public const MAX_NAME = 40;
|
||||||
|
|
||||||
|
private const CACHE_KEY = 'design.palette.v1';
|
||||||
|
|
||||||
|
/** @var array{next: int, slots: list<array{id: string, name: string, bg: string, fg: string}>}|null */
|
||||||
|
private static ?array $memo = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fest vorgegebene Markenflächen der Abschnitte. Sie sind Teil des Designsystems (tokens.css), keine Palettenfarben,
|
||||||
|
* und bleiben unverändert, damit bestehende Seiten gleich aussehen.
|
||||||
|
*
|
||||||
|
* @return list<array{key: string, label: string, bg: string, fg: string, border: bool}>
|
||||||
|
*/
|
||||||
|
public static function builtIns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['key' => 'default', 'label' => SectionStyle::BACKGROUNDS['default'], 'bg' => '#ffffff', 'fg' => '#15243a', 'border' => true],
|
||||||
|
['key' => 'light', 'label' => SectionStyle::BACKGROUNDS['light'], 'bg' => '#f7f6f2', 'fg' => '#15243a', 'border' => true],
|
||||||
|
['key' => 'dark', 'label' => SectionStyle::BACKGROUNDS['dark'], 'bg' => '#032551', 'fg' => '#f4f6f8', 'border' => false],
|
||||||
|
['key' => 'accent', 'label' => SectionStyle::BACKGROUNDS['accent'], 'bg' => '#3b7b09', 'fg' => '#ffffff', 'border' => false],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{id: string, name: string, bg: string, fg: string}>
|
||||||
|
*/
|
||||||
|
public static function slots(): array
|
||||||
|
{
|
||||||
|
return self::state()['slots'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{id: string, name: string, bg: string, fg: string}|null
|
||||||
|
*/
|
||||||
|
public static function find(mixed $id): ?array
|
||||||
|
{
|
||||||
|
if (! is_string($id)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (self::slots() as $slot) {
|
||||||
|
if ($slot['id'] === $id) {
|
||||||
|
return $slot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Anzahl noch freier Plätze. */
|
||||||
|
public static function free(): int
|
||||||
|
{
|
||||||
|
return max(0, self::MAX_SLOTS - count(self::slots()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüft eine Farbe. Gibt Fehlermeldungen je Feld zurück („name“, „bg“, „fg“, „slot“); leer, wenn sie zulässig ist.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public static function errors(?string $id, mixed $name, mixed $bg, mixed $fg): array
|
||||||
|
{
|
||||||
|
$errors = [];
|
||||||
|
$name = is_string($name) ? trim(preg_replace('/\s+/u', ' ', $name) ?? '') : '';
|
||||||
|
|
||||||
|
if ($name === '') {
|
||||||
|
$errors['name'] = 'Bitte einen Namen eingeben, zum Beispiel „Markengrün“.';
|
||||||
|
} elseif (mb_strlen($name) > self::MAX_NAME) {
|
||||||
|
$errors['name'] = 'Der Name darf höchstens '.self::MAX_NAME.' Zeichen lang sein.';
|
||||||
|
} else {
|
||||||
|
foreach (self::slots() as $slot) {
|
||||||
|
if ($slot['id'] !== $id && mb_strtolower($slot['name']) === mb_strtolower($name)) {
|
||||||
|
$errors['name'] = 'Eine Farbe mit diesem Namen gibt es schon.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$background = ColorContrast::normalize($bg);
|
||||||
|
$text = ColorContrast::normalize($fg);
|
||||||
|
|
||||||
|
if ($background === null) {
|
||||||
|
$errors['bg'] = 'Bitte einen HEX-Wert angeben, zum Beispiel #3b7b09.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($text === null) {
|
||||||
|
$errors['fg'] = 'Bitte einen HEX-Wert angeben, zum Beispiel #ffffff.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($background !== null && $text !== null) {
|
||||||
|
$ratio = ColorContrast::ratio($text, $background);
|
||||||
|
|
||||||
|
if ($ratio < ColorContrast::NORMAL_TEXT) {
|
||||||
|
$errors['fg'] = 'Der Kontrast beträgt nur '.self::number($ratio).' : 1. Für lesbaren Text sind mindestens 4,5 : 1 nötig (WCAG 2.2 AA). Empfehlung: '.ColorContrast::suggestText($background).'.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($id === null && count(self::slots()) >= self::MAX_SLOTS) {
|
||||||
|
$errors['slot'] = 'Die Palette ist voll. Es sind höchstens '.self::MAX_SLOTS.' Farben möglich.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($id !== null && self::find($id) === null) {
|
||||||
|
$errors['slot'] = 'Diese Farbe gibt es nicht mehr.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt eine Farbe an ($id = null) oder ändert sie.
|
||||||
|
*
|
||||||
|
* @return array<string, string> Fehlermeldungen je Feld; leer bei Erfolg
|
||||||
|
*/
|
||||||
|
public static function save(?string $id, mixed $name, mixed $bg, mixed $fg, ?User $by = null): array
|
||||||
|
{
|
||||||
|
$errors = self::errors($id, $name, $bg, $fg);
|
||||||
|
|
||||||
|
if ($errors !== []) {
|
||||||
|
return $errors;
|
||||||
|
}
|
||||||
|
|
||||||
|
$state = self::state();
|
||||||
|
$entry = [
|
||||||
|
'name' => trim(preg_replace('/\s+/u', ' ', (string) $name) ?? ''),
|
||||||
|
'bg' => (string) ColorContrast::normalize($bg),
|
||||||
|
'fg' => (string) ColorContrast::normalize($fg),
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($id === null) {
|
||||||
|
$entry = ['id' => 'c'.$state['next']] + $entry;
|
||||||
|
$state['next']++;
|
||||||
|
$state['slots'][] = $entry;
|
||||||
|
} else {
|
||||||
|
foreach ($state['slots'] as $index => $slot) {
|
||||||
|
if ($slot['id'] === $id) {
|
||||||
|
$state['slots'][$index] = ['id' => $id] + $entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self::write($state, $by);
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entfernt eine Farbe. Solange ein Abschnitt (veröffentlicht oder im Entwurf) sie verwendet, bleibt sie bestehen.
|
||||||
|
*
|
||||||
|
* @return array<string, string> Fehlermeldung unter „slot“; leer bei Erfolg
|
||||||
|
*/
|
||||||
|
public static function remove(string $id, ?User $by = null): array
|
||||||
|
{
|
||||||
|
if (self::find($id) === null) {
|
||||||
|
return ['slot' => 'Diese Farbe gibt es nicht mehr.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$uses = self::usage()[$id] ?? [];
|
||||||
|
|
||||||
|
if ($uses !== []) {
|
||||||
|
return ['slot' => 'Die Farbe wird noch verwendet ('.count($uses).' '.(count($uses) === 1 ? 'Seite' : 'Seiten').'). Wählen Sie dort zuerst eine andere Fläche.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$state = self::state();
|
||||||
|
$state['slots'] = array_values(array_filter($state['slots'], static fn (array $slot): bool => $slot['id'] !== $id));
|
||||||
|
self::write($state, $by);
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verwendung der Farben: je Kennung die Seiten mit Abschnitten dieser Farbe, getrennt nach veröffentlichtem Stand und
|
||||||
|
* Entwurf (neuester Stand, der noch nicht veröffentlicht ist). Ältere Revisionen zählen nicht; sie zeigen beim
|
||||||
|
* Wiederherstellen die aktuelle Farbe.
|
||||||
|
*
|
||||||
|
* @return array<string, list<array{page_id: int, path: string, title: string, published: int, draft: int}>>
|
||||||
|
*/
|
||||||
|
public static function usage(): array
|
||||||
|
{
|
||||||
|
$uses = [];
|
||||||
|
|
||||||
|
foreach (Page::query()->with(['publishedRevision', 'latestRevision'])->orderBy('path')->get() as $page) {
|
||||||
|
$published = $page->publishedRevision;
|
||||||
|
$latest = $page->latestRevision;
|
||||||
|
$draft = $latest !== null && $latest->id !== $published?->id ? $latest : null;
|
||||||
|
|
||||||
|
$countPublished = self::countSections($published?->sections);
|
||||||
|
$countDraft = self::countSections($draft?->sections);
|
||||||
|
|
||||||
|
foreach (array_unique([...array_keys($countPublished), ...array_keys($countDraft)]) as $slotId) {
|
||||||
|
$uses[$slotId][] = [
|
||||||
|
'page_id' => $page->id,
|
||||||
|
'path' => $page->path,
|
||||||
|
'title' => $published !== null ? $page->publicTitle() : ($latest?->contentTitle() ?? $page->path),
|
||||||
|
'published' => $countPublished[$slotId] ?? 0,
|
||||||
|
'draft' => $countDraft[$slotId] ?? 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $uses;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function flush(): void
|
||||||
|
{
|
||||||
|
self::$memo = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Cache::forget(self::CACHE_KEY);
|
||||||
|
} catch (Throwable) {
|
||||||
|
// Der Zwischenspeicher ist nur Beschleunigung.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Zahl mit Komma für Meldungen: 4,05. */
|
||||||
|
public static function number(float $value): string
|
||||||
|
{
|
||||||
|
return rtrim(rtrim(number_format($value, 2, ',', ''), '0'), ',');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<int|string, mixed>|null $sections
|
||||||
|
* @return array<string, int> Kennung => Anzahl Abschnitte
|
||||||
|
*/
|
||||||
|
private static function countSections(?array $sections): array
|
||||||
|
{
|
||||||
|
$count = [];
|
||||||
|
|
||||||
|
foreach ($sections ?? [] as $section) {
|
||||||
|
$style = is_array($section) && is_array($section['style'] ?? null) ? $section['style'] : [];
|
||||||
|
|
||||||
|
if (($style['background'] ?? null) === 'palette' && is_string($style['palette_slot'] ?? null)) {
|
||||||
|
$count[$style['palette_slot']] = ($count[$style['palette_slot']] ?? 0) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Farbe eines Widgets (ADR-68): settings.palette im Platz.
|
||||||
|
foreach (is_array($section) && is_array($section['slots'] ?? null) ? $section['slots'] : [] as $widget) {
|
||||||
|
$slotId = is_array($widget) && is_array($widget['settings'] ?? null) ? ($widget['settings']['palette'] ?? null) : null;
|
||||||
|
|
||||||
|
if (is_string($slotId)) {
|
||||||
|
$count[$slotId] = ($count[$slotId] ?? 0) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Farbe der Zahlenkreise in Texten (ADR-69): data-tone im formatierten Text eines Widgets, je Widget einmal.
|
||||||
|
foreach (is_array($section) && is_array($section['slots'] ?? null) ? $section['slots'] : [] as $widget) {
|
||||||
|
foreach (is_array($widget) && is_array($widget['data'] ?? null) ? TextMarkers::tonesIn($widget['data']) : [] as $slotId) {
|
||||||
|
$count[$slotId] = ($count[$slotId] ?? 0) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{next: int, slots: list<array{id: string, name: string, bg: string, fg: string}>}
|
||||||
|
*/
|
||||||
|
private static function state(): array
|
||||||
|
{
|
||||||
|
if (self::$memo !== null) {
|
||||||
|
return self::$memo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Die Prüfregeln der Widgets lesen die Palette bei jedem Speichern, auch beim Einspielen der Migrationen (Seeder), wenn
|
||||||
|
// site_settings noch fehlt. Eine fehlgeschlagene Abfrage würde dort in PostgreSQL die ganze Transaktion abbrechen
|
||||||
|
// (SQLSTATE 25P02), auch wenn der Fehler abgefangen wird. Deshalb wird vorher geprüft und nichts gemerkt.
|
||||||
|
try {
|
||||||
|
if (! Schema::hasTable('site_settings')) {
|
||||||
|
return self::read([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$stored = Cache::rememberForever(self::CACHE_KEY, static function (): array {
|
||||||
|
$row = SiteSetting::query()->find(self::KEY);
|
||||||
|
|
||||||
|
return $row === null ? [] : (array) $row->value;
|
||||||
|
});
|
||||||
|
} catch (Throwable) {
|
||||||
|
$stored = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$memo = self::read($stored);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lesepfad: Beschädigtes oder Unvollständiges entfällt, nie ein Fehler.
|
||||||
|
*
|
||||||
|
* @param array<int|string, mixed> $stored
|
||||||
|
* @return array{next: int, slots: list<array{id: string, name: string, bg: string, fg: string}>}
|
||||||
|
*/
|
||||||
|
private static function read(array $stored): array
|
||||||
|
{
|
||||||
|
$slots = [];
|
||||||
|
$highest = 0;
|
||||||
|
|
||||||
|
foreach (is_array($stored['slots'] ?? null) ? $stored['slots'] : [] as $slot) {
|
||||||
|
if (! is_array($slot) || ! is_string($slot['id'] ?? null) || preg_match('/^c([1-9][0-9]*)$/', $slot['id'], $match) !== 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$bg = ColorContrast::normalize($slot['bg'] ?? null);
|
||||||
|
$fg = ColorContrast::normalize($slot['fg'] ?? null);
|
||||||
|
$name = is_string($slot['name'] ?? null) ? trim($slot['name']) : '';
|
||||||
|
|
||||||
|
if ($bg === null || $fg === null || $name === '' || count($slots) >= self::MAX_SLOTS) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$highest = max($highest, (int) $match[1]);
|
||||||
|
$slots[] = ['id' => $slot['id'], 'name' => mb_substr($name, 0, self::MAX_NAME), 'bg' => $bg, 'fg' => $fg];
|
||||||
|
}
|
||||||
|
|
||||||
|
$next = is_int($stored['next'] ?? null) ? $stored['next'] : 1;
|
||||||
|
|
||||||
|
return ['next' => max($next, $highest + 1, 1), 'slots' => $slots];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array{next: int, slots: list<array{id: string, name: string, bg: string, fg: string}>} $state
|
||||||
|
*/
|
||||||
|
private static function write(array $state, ?User $by): void
|
||||||
|
{
|
||||||
|
SiteSetting::query()->updateOrCreate(['key' => self::KEY], ['value' => $state, 'updated_by' => $by?->getKey()]);
|
||||||
|
self::flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,6 +37,40 @@ public function write(
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schreibt nur dann, wenn zu diesem Anspruch und dieser Fassung innerhalb des Zeitfensters noch kein Nachweis der
|
||||||
|
* Aktion steht. So zählt eine Wiedergabe einmal, auch wenn der Player nur Erneuerungen und Abschnitte abruft; ein
|
||||||
|
* Abruf, der nie die Hauptliste holt, bleibt trotzdem nicht ohne Nachweis.
|
||||||
|
*
|
||||||
|
* @return bool true, wenn geschrieben wurde
|
||||||
|
*/
|
||||||
|
public function writeUnlessRecent(
|
||||||
|
int $windowSeconds,
|
||||||
|
Grant $grant,
|
||||||
|
LicenseArticle $article,
|
||||||
|
ArticleRelease $release,
|
||||||
|
ContentElementVersion $version,
|
||||||
|
string $action,
|
||||||
|
string $format,
|
||||||
|
string $marking,
|
||||||
|
string|\Closure|null $checksum = null,
|
||||||
|
): bool {
|
||||||
|
$recent = MediaDelivery::query()
|
||||||
|
->where('grant_id', $grant->id)
|
||||||
|
->where('content_element_version_id', $version->id)
|
||||||
|
->where('action', $action)
|
||||||
|
->where('delivered_at', '>=', now()->subSeconds($windowSeconds))
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
if ($recent) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->write($grant, $article, $release, $version, $action, $format, $checksum instanceof \Closure ? $checksum() : $checksum, $marking);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static function newCopyId(): string
|
public static function newCopyId(): string
|
||||||
{
|
{
|
||||||
return 'LK-'.strtoupper(bin2hex(random_bytes(6)));
|
return 'LK-'.strtoupper(bin2hex(random_bytes(6)));
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SHA-256 einer Datei der Medienablage für den Auslieferungsnachweis (08 §7), je Datei einmal berechnet.
|
||||||
|
*
|
||||||
|
* Die Dateien sind nach dem Speichern unveränderlich. Der gemerkte Wert gilt daher für Pfad, Größe und Änderungszeit;
|
||||||
|
* ändert sich eine davon, wird neu gerechnet. Ist die Datei nicht lesbar, ist das Ergebnis null (der Nachweis nennt
|
||||||
|
* dann keine Prüfsumme, statt die Auslieferung zu blockieren).
|
||||||
|
*/
|
||||||
|
class FileChecksum
|
||||||
|
{
|
||||||
|
public function of(string $diskName, string $path): ?string
|
||||||
|
{
|
||||||
|
$disk = Storage::disk($diskName);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (! $disk->exists($path)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$key = 'media-checksum:'.hash('sha256', $diskName.'|'.$path.'|'.$disk->size($path).'|'.$disk->lastModified($path));
|
||||||
|
|
||||||
|
return Cache::rememberForever($key, function () use ($disk, $path): ?string {
|
||||||
|
$stream = $disk->readStream($path);
|
||||||
|
|
||||||
|
if (! is_resource($stream)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$context = hash_init('sha256');
|
||||||
|
hash_update_stream($context, $stream);
|
||||||
|
|
||||||
|
return hash_final($context);
|
||||||
|
} finally {
|
||||||
|
fclose($stream);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (\Throwable) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,12 +19,52 @@ public function rewrite(string $playlist, string $playlistPath, callable $sign):
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$target = str_starts_with($value, 'ableitungen/')
|
$rewritten[] = $sign($this->target($value, $directory));
|
||||||
? $value
|
|
||||||
: ($directory === '.' ? $value : $directory.'/'.$value);
|
|
||||||
$rewritten[] = $sign($target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode("\n", $rewritten)."\n";
|
return implode("\n", $rewritten)."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pfad (auf der Ablage) des ersten Eintrags einer Liste, bei einer Hauptliste also der ersten Teilliste.
|
||||||
|
*/
|
||||||
|
public function firstTarget(string $playlist, string $playlistPath): ?string
|
||||||
|
{
|
||||||
|
$directory = str_replace('\\', '/', dirname($playlistPath));
|
||||||
|
|
||||||
|
foreach (preg_split("/\r\n|\n|\r/", $playlist) ?: [] as $line) {
|
||||||
|
$value = trim($line);
|
||||||
|
|
||||||
|
if ($value !== '' && ! str_starts_with($value, '#')) {
|
||||||
|
return $this->target($value, $directory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dauer einer Teilliste in Sekunden: Summe der #EXTINF-Werte. 0.0, wenn die Liste keine nennt (z. B. Hauptliste).
|
||||||
|
*/
|
||||||
|
public function duration(string $playlist): float
|
||||||
|
{
|
||||||
|
$seconds = 0.0;
|
||||||
|
|
||||||
|
foreach (preg_split("/\r\n|\n|\r/", $playlist) ?: [] as $line) {
|
||||||
|
if (preg_match('/^#EXTINF:\s*([0-9]+(?:\.[0-9]+)?)/', trim($line), $match) === 1) {
|
||||||
|
$seconds += (float) $match[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $seconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function target(string $value, string $directory): string
|
||||||
|
{
|
||||||
|
if (str_starts_with($value, 'ableitungen/')) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $directory === '.' ? $value : $directory.'/'.$value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Größenstufen eines Bildes (docs/architektur/bildvarianten.md).
|
||||||
|
*
|
||||||
|
* Neben der Hauptdatei (`vorschau/element-12.jpg`, „voll“: bis 2400 px bei Bildern, 640 px sonst) liegen daneben
|
||||||
|
* kleinere JPEG-Fassungen, benannt nach der Hauptdatei (`element-12-klein.jpg`). Es gibt keine Spalte dafür: Die Hauptdatei
|
||||||
|
* bleibt `thumbnail_path`, die Fassungen folgen der Namensregel. Fehlt eine Fassung, gilt die Hauptdatei (kein Bruch bei
|
||||||
|
* Bestand, der noch nicht abgeleitet ist).
|
||||||
|
*
|
||||||
|
* Verwaltungsoberfläche (Disk `media_derived`):
|
||||||
|
* - `klein` 360 px: Auswahl, Listen, Karten (Anzeige bis etwa 180 px, doppelt für scharfe Bildschirme)
|
||||||
|
* - `mittel` 960 px: Detailansicht, Vorschau, Titelbild im Editor
|
||||||
|
* - voll: die Hauptdatei
|
||||||
|
*
|
||||||
|
* Website (Disk `media_public`, `website/{id}/datei-{breite}.jpg`): Breiten {@see self::PUBLIC_WIDTHS}, daneben die
|
||||||
|
* Hauptdatei `datei.jpg`. Eine Fassung entsteht nur, wenn die Quelle breiter ist (nie vergrößern).
|
||||||
|
*
|
||||||
|
* Geschrieben wird nur in der Warteschlange; der Web-Prozess liest.
|
||||||
|
*/
|
||||||
|
class ImageVariants
|
||||||
|
{
|
||||||
|
/** @var array<string, int> */
|
||||||
|
public const SIZES = ['klein' => 360, 'mittel' => 960];
|
||||||
|
|
||||||
|
/** @var list<int> */
|
||||||
|
public const PUBLIC_WIDTHS = [640, 1280, 1920];
|
||||||
|
|
||||||
|
private const QUALITY = 80;
|
||||||
|
|
||||||
|
public static function isSize(mixed $size): bool
|
||||||
|
{
|
||||||
|
return is_string($size) && array_key_exists($size, self::SIZES);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isPublicWidth(mixed $width): bool
|
||||||
|
{
|
||||||
|
return is_int($width) && in_array($width, self::PUBLIC_WIDTHS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** `vorschau/element-12.jpg` → `vorschau/element-12-klein.jpg` */
|
||||||
|
public static function path(string $base, string $size): string
|
||||||
|
{
|
||||||
|
$extension = pathinfo($base, PATHINFO_EXTENSION);
|
||||||
|
$stem = $extension === '' ? $base : substr($base, 0, -(strlen($extension) + 1));
|
||||||
|
|
||||||
|
return $stem.'-'.$size.'.jpg';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** `website/12/datei.jpg` → `website/12/datei-640.jpg` */
|
||||||
|
public static function publicPath(string $base, int $width): string
|
||||||
|
{
|
||||||
|
return self::path($base, (string) $width);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pfad, der für die Größe ausgeliefert wird: die Fassung, wenn es sie gibt, sonst die Hauptdatei.
|
||||||
|
*/
|
||||||
|
public static function resolve(Filesystem $disk, string $base, ?string $size): string
|
||||||
|
{
|
||||||
|
if (! self::isSize($size)) {
|
||||||
|
return $base;
|
||||||
|
}
|
||||||
|
|
||||||
|
$variant = self::path($base, (string) $size);
|
||||||
|
|
||||||
|
return $disk->exists($variant) ? $variant : $base;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt die Fassungen der Verwaltungsoberfläche zur Hauptdatei an (Warteschlange). Ist die Quelle nicht breiter als die
|
||||||
|
* Stufe, entfällt die Fassung, und eine ältere wird entfernt.
|
||||||
|
*
|
||||||
|
* @return list<string> Pfade der geschriebenen Fassungen
|
||||||
|
*/
|
||||||
|
public static function generate(Filesystem $disk, string $base): array
|
||||||
|
{
|
||||||
|
$targets = [];
|
||||||
|
|
||||||
|
foreach (self::SIZES as $name => $width) {
|
||||||
|
$targets[self::path($base, $name)] = $width;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::write($disk, $disk, $base, $targets);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt die Breiten für die Website neben der öffentlichen Hauptdatei an. Nur JPEG-Quellen: andere Formate (PNG, GIF,
|
||||||
|
* WebP) können Transparenz tragen, die ein JPEG nicht hält; sie bleiben unverändert.
|
||||||
|
*
|
||||||
|
* @return list<string> Pfade der geschriebenen Fassungen
|
||||||
|
*/
|
||||||
|
public static function generatePublic(Filesystem $source, Filesystem $target, string $sourcePath, string $publicBase): array
|
||||||
|
{
|
||||||
|
if (! in_array(strtolower(pathinfo($publicBase, PATHINFO_EXTENSION)), ['jpg', 'jpeg'], true)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$targets = [];
|
||||||
|
|
||||||
|
foreach (self::PUBLIC_WIDTHS as $width) {
|
||||||
|
$targets[self::publicPath($publicBase, $width)] = $width;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::write($source, $target, $sourcePath, $targets);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Entfernt alle Fassungen zu einer öffentlichen Hauptdatei (Rücknahme, Ersatz). */
|
||||||
|
public static function deletePublic(Filesystem $disk, string $publicBase): void
|
||||||
|
{
|
||||||
|
foreach (self::PUBLIC_WIDTHS as $width) {
|
||||||
|
$disk->delete(self::publicPath($publicBase, $width));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, int> $targets Zielpfad → Breite
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private static function write(Filesystem $source, Filesystem $target, string $sourcePath, array $targets): array
|
||||||
|
{
|
||||||
|
if (! $source->exists($sourcePath)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$bytes = $source->get($sourcePath);
|
||||||
|
$image = is_string($bytes) && $bytes !== '' ? @imagecreatefromstring($bytes) : false;
|
||||||
|
|
||||||
|
if ($image === false) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$width = imagesx($image);
|
||||||
|
$height = imagesy($image);
|
||||||
|
$written = [];
|
||||||
|
|
||||||
|
foreach ($targets as $path => $targetWidth) {
|
||||||
|
if ($width <= $targetWidth) {
|
||||||
|
$target->delete($path);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$encoded = self::scaled($image, $width, $height, $targetWidth);
|
||||||
|
|
||||||
|
if ($encoded !== null && $target->put($path, $encoded)) {
|
||||||
|
$written[] = $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
imagedestroy($image);
|
||||||
|
|
||||||
|
return $written;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function scaled(\GdImage $image, int $width, int $height, int $targetWidth): ?string
|
||||||
|
{
|
||||||
|
$targetHeight = (int) max(1, round($height * ($targetWidth / max(1, $width))));
|
||||||
|
$canvas = imagecreatetruecolor($targetWidth, $targetHeight);
|
||||||
|
imagefill($canvas, 0, 0, (int) imagecolorallocate($canvas, 255, 255, 255));
|
||||||
|
imagecopyresampled($canvas, $image, 0, 0, 0, 0, $targetWidth, $targetHeight, $width, $height);
|
||||||
|
imageinterlace($canvas, true);
|
||||||
|
ob_start();
|
||||||
|
imagejpeg($canvas, null, self::QUALITY);
|
||||||
|
$bytes = ob_get_clean();
|
||||||
|
imagedestroy($canvas);
|
||||||
|
|
||||||
|
return is_string($bytes) && $bytes !== '' ? $bytes : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Domain\Media;
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentElementVersion;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class MediaRendition extends Model
|
class MediaRendition extends Model
|
||||||
@@ -13,6 +15,97 @@ class MediaRendition extends Model
|
|||||||
'path',
|
'path',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Darf diese Fassung die Datei ausliefern? Erlaubt ist das Verzeichnis ihrer eigenen Ableitungen: der Ordner
|
||||||
|
* ableitungen/{Kennung} und der Ordner, in dem ihr Master liegt. Letzterer weicht ab, wenn die Fassung ihre
|
||||||
|
* Stufen von einer früheren Fassung derselben Datei übernommen hat (carryOver). Kein Pfad anderer Fassungen,
|
||||||
|
* kein "..".
|
||||||
|
*/
|
||||||
|
public static function owns(int $versionId, string $path): bool
|
||||||
|
{
|
||||||
|
if ($path === '' || str_contains($path, '..') || str_contains($path, '\\')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$prefixes = ['ableitungen/'.$versionId];
|
||||||
|
$master = static::masterPath($versionId);
|
||||||
|
|
||||||
|
if ($master !== null) {
|
||||||
|
$directory = str_replace('\\', '/', dirname($master));
|
||||||
|
|
||||||
|
if (str_starts_with($directory, 'ableitungen/')) {
|
||||||
|
$prefixes[] = $directory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($prefixes as $prefix) {
|
||||||
|
if ($path === $prefix || str_starts_with($path, $prefix.'/')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eine neue Fassung mit derselben Datei (ohne neuen Upload) behält die Stufen der letzten Fassung dieser Datei.
|
||||||
|
* Die Zeilen zeigen auf dieselben, unveränderten Ableitungen; es wird nichts neu erzeugt oder kopiert.
|
||||||
|
*/
|
||||||
|
public static function carryOver(ContentElement $element, ContentElementVersion $version, string $file): void
|
||||||
|
{
|
||||||
|
$source = ContentElementVersion::query()
|
||||||
|
->where('content_element_id', $element->id)
|
||||||
|
->where('id', '<>', $version->id)
|
||||||
|
->orderByDesc('number')
|
||||||
|
->get()
|
||||||
|
->first(fn (ContentElementVersion $candidate): bool => is_array($candidate->metadata)
|
||||||
|
&& ($candidate->metadata['file'] ?? null) === $file
|
||||||
|
&& static::masterPath($candidate->id) !== null);
|
||||||
|
|
||||||
|
if ($source === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (static::query()->where('content_element_version_id', $source->id)->get() as $row) {
|
||||||
|
static::query()->updateOrCreate(
|
||||||
|
['content_element_version_id' => $version->id, 'label' => $row->label],
|
||||||
|
['role' => $row->role, 'path' => $row->path],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gegenstück zu carryOver: Wurde eine Fassung mit derselben Datei schon gespeichert, bevor die Verarbeitung dieser
|
||||||
|
* Fassung fertig war, bekommt sie die Stufen nachträglich. Nur spätere Fassungen desselben Mediums mit derselben
|
||||||
|
* Datei und ohne eigenen Master; eine andere Datei erbt nichts.
|
||||||
|
*/
|
||||||
|
public static function carryForward(ContentElementVersion $source): void
|
||||||
|
{
|
||||||
|
$file = is_array($source->metadata) ? ($source->metadata['file'] ?? null) : null;
|
||||||
|
|
||||||
|
if (! is_string($file) || $file === '' || static::masterPath($source->id) === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rows = static::query()->where('content_element_version_id', $source->id)->get();
|
||||||
|
|
||||||
|
ContentElementVersion::query()
|
||||||
|
->where('content_element_id', $source->content_element_id)
|
||||||
|
->where('number', '>', $source->number)
|
||||||
|
->get()
|
||||||
|
->filter(fn (ContentElementVersion $later): bool => is_array($later->metadata)
|
||||||
|
&& ($later->metadata['file'] ?? null) === $file
|
||||||
|
&& static::masterPath($later->id) === null)
|
||||||
|
->each(function (ContentElementVersion $later) use ($rows): void {
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
static::query()->updateOrCreate(
|
||||||
|
['content_element_version_id' => $later->id, 'label' => $row->label],
|
||||||
|
['role' => $row->role, 'path' => $row->path],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static function masterPath(int $versionId): ?string
|
public static function masterPath(int $versionId): ?string
|
||||||
{
|
{
|
||||||
$path = static::query()
|
$path = static::query()
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ public function place(ContentElement $element, string $incoming): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($element->output_class === 'bild') {
|
if ($element->output_class === 'bild') {
|
||||||
|
ImageVariants::generate(Storage::disk('media_derived'), $target);
|
||||||
$element->thumbnail_path = $target;
|
$element->thumbnail_path = $target;
|
||||||
$element->thumbnail_source = 'eigen';
|
$element->thumbnail_source = 'eigen';
|
||||||
} else {
|
} else {
|
||||||
@@ -97,6 +98,7 @@ public function place(ContentElement $element, string $incoming): void
|
|||||||
|
|
||||||
$element->thumbnail_error = null;
|
$element->thumbnail_error = null;
|
||||||
$element->save();
|
$element->save();
|
||||||
|
$element->touch();
|
||||||
Storage::disk('cms_incoming')->delete($incoming);
|
Storage::disk('cms_incoming')->delete($incoming);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Laufzeit der Adressen für Teillisten und Abschnitte eines Films (config media.*): Filmlänge plus Reserve, höchstens
|
||||||
|
* die Höchstdauer; ohne lesbare Filmlänge die Ersatzdauer.
|
||||||
|
*/
|
||||||
|
class StreamLifetime
|
||||||
|
{
|
||||||
|
public function __construct(private readonly HlsPlaylist $playlists) {}
|
||||||
|
|
||||||
|
public function seconds(int $versionId): int
|
||||||
|
{
|
||||||
|
$max = max(1, (int) config('media.stream_max_minutes')) * 60;
|
||||||
|
$film = $this->filmSeconds($versionId);
|
||||||
|
$wanted = $film > 0
|
||||||
|
? (int) ceil($film) + max(0, (int) config('media.stream_reserve_minutes')) * 60
|
||||||
|
: max(1, (int) config('media.stream_fallback_minutes')) * 60;
|
||||||
|
|
||||||
|
return min($wanted, $max);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Zeitfenster in Sekunden, in dem Erneuerungen zur selben Wiedergabe zählen. */
|
||||||
|
public function window(): int
|
||||||
|
{
|
||||||
|
return max(1, (int) config('media.stream_max_minutes')) * 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function filmSeconds(int $versionId): float
|
||||||
|
{
|
||||||
|
$disk = Storage::disk('media_derived');
|
||||||
|
$master = MediaRendition::masterPath($versionId);
|
||||||
|
|
||||||
|
if ($master === null || ! $disk->exists($master)) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$variant = $this->playlists->firstTarget((string) $disk->get($master), $master);
|
||||||
|
|
||||||
|
if ($variant === null || ! MediaRendition::owns($versionId, $variant) || ! $disk->exists($variant)) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->playlists->duration((string) $disk->get($variant));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -335,6 +335,7 @@ private function frame(ContentElement $element, ContentElementVersion $version,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImageVariants::generate($disk, $target);
|
||||||
$element->thumbnail_path = $target;
|
$element->thumbnail_path = $target;
|
||||||
if (! filled($element->thumbnail_alt)) {
|
if (! filled($element->thumbnail_alt)) {
|
||||||
$element->thumbnail_alt = $element->working_title;
|
$element->thumbnail_alt = $element->working_title;
|
||||||
@@ -344,6 +345,7 @@ private function frame(ContentElement $element, ContentElementVersion $version,
|
|||||||
$element->thumbnail_source = 'frame:'.$version->id.'@0';
|
$element->thumbnail_source = 'frame:'.$version->id.'@0';
|
||||||
}
|
}
|
||||||
$element->save();
|
$element->save();
|
||||||
|
$element->touch();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function still(ContentElement|Composition $subject, Filesystem $disk, string $file, string $name): void
|
private function still(ContentElement|Composition $subject, Filesystem $disk, string $file, string $name): void
|
||||||
@@ -388,6 +390,7 @@ private function still(ContentElement|Composition $subject, Filesystem $disk, st
|
|||||||
|
|
||||||
$path = 'vorschau/'.$name.'.jpg';
|
$path = 'vorschau/'.$name.'.jpg';
|
||||||
Storage::disk('media_derived')->put($path, $bytes);
|
Storage::disk('media_derived')->put($path, $bytes);
|
||||||
|
ImageVariants::generate(Storage::disk('media_derived'), $path);
|
||||||
$subject->thumbnail_path = $path;
|
$subject->thumbnail_path = $path;
|
||||||
|
|
||||||
if (! filled($subject->thumbnail_alt)) {
|
if (! filled($subject->thumbnail_alt)) {
|
||||||
@@ -396,6 +399,9 @@ private function still(ContentElement|Composition $subject, Filesystem $disk, st
|
|||||||
|
|
||||||
$subject->thumbnail_error = null;
|
$subject->thumbnail_error = null;
|
||||||
$subject->save();
|
$subject->save();
|
||||||
|
// Die Adresse trägt die Version (updated_at) und wird dauerhaft zwischengespeichert: Ein neu abgeleitetes Bild
|
||||||
|
// unter gleichem Pfad muss die Version ändern, auch wenn sonst nichts an der Zeile anders ist.
|
||||||
|
$subject->touch();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function rememberElement(ContentElement $element, string $source): void
|
private function rememberElement(ContentElement $element, string $source): void
|
||||||
|
|||||||
@@ -2,14 +2,37 @@
|
|||||||
|
|
||||||
namespace App\Domain\Media;
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use Carbon\CarbonInterface;
|
||||||
|
|
||||||
class ThumbnailRef
|
class ThumbnailRef
|
||||||
{
|
{
|
||||||
public static function url(string $route, string $kind, int $id, mixed $path): ?string
|
/**
|
||||||
|
* Adresse eines Vorschaubildes.
|
||||||
|
*
|
||||||
|
* @param string|null $size `klein` (Auswahl, Listen, Karten), `mittel` (Detail, Vorschau) oder null für die volle Datei
|
||||||
|
* @param CarbonInterface|int|string|null $version Stand des Bildes (zum Beispiel `updated_at`). Mit Version darf der Browser das Bild
|
||||||
|
* dauerhaft behalten; ohne Version fragt er jedes Mal nach (ETag).
|
||||||
|
*/
|
||||||
|
public static function url(string $route, string $kind, int $id, mixed $path, ?string $size = null, CarbonInterface|int|string|null $version = null): ?string
|
||||||
{
|
{
|
||||||
if (! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
if (! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return route($route, ['kind' => $kind, 'subject' => $id]);
|
$query = [];
|
||||||
|
|
||||||
|
if (ImageVariants::isSize($size)) {
|
||||||
|
$query['g'] = $size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($version instanceof CarbonInterface) {
|
||||||
|
$version = $version->getTimestamp();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($version !== null && $version !== '') {
|
||||||
|
$query['v'] = $version;
|
||||||
|
}
|
||||||
|
|
||||||
|
return route($route, ['kind' => $kind, 'subject' => $id] + $query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,10 +45,37 @@ public function present(ContentElement|int $element): ?WebsitePresentation
|
|||||||
'audio' => 'audio',
|
'audio' => 'audio',
|
||||||
default => 'bild',
|
default => 'bild',
|
||||||
},
|
},
|
||||||
url: route('website.media', $element),
|
// Bilder tragen den Zeitpunkt der Freigabe in der Adresse (dauerhaft zwischenspeicherbar); Film und Hörstück bleiben unverändert.
|
||||||
|
url: $element->output_class === 'film' || $element->output_class === 'audio'
|
||||||
|
? route('website.media', $element)
|
||||||
|
: route('website.media', ['element' => $element, 'v' => $element->website_released_at->getTimestamp()]),
|
||||||
|
srcset: $this->srcset($element, $path),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `srcset` eines freigegebenen JPEG-Bildes: die Breiten aus {@see ImageVariants::PUBLIC_WIDTHS} und die volle Datei.
|
||||||
|
* Fehlt eine Breite noch (Bestand), liefert die Adresse die volle Datei und stößt das Anlegen an; die Beschreibung bleibt
|
||||||
|
* dann ungenau, das Bild aber richtig. PNG, GIF und WebP bleiben ohne Fassungen (Transparenz).
|
||||||
|
*/
|
||||||
|
private function srcset(ContentElement $element, string $path): ?string
|
||||||
|
{
|
||||||
|
if ($element->output_class !== 'bild' || ! in_array(strtolower(pathinfo($path, PATHINFO_EXTENSION)), ['jpg', 'jpeg'], true)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = $element->website_released_at->getTimestamp();
|
||||||
|
$entries = [];
|
||||||
|
|
||||||
|
foreach (ImageVariants::PUBLIC_WIDTHS as $width) {
|
||||||
|
$entries[] = route('website.media', ['element' => $element, 'w' => $width, 'v' => $version]).' '.$width.'w';
|
||||||
|
}
|
||||||
|
|
||||||
|
$entries[] = route('website.media', ['element' => $element, 'v' => $version]).' 2400w';
|
||||||
|
|
||||||
|
return implode(', ', $entries);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Slideshow: freigegebene Medien in der angegebenen Reihenfolge. Nicht freigegebene Einträge entfallen.
|
* Slideshow: freigegebene Medien in der angegebenen Reihenfolge. Nicht freigegebene Einträge entfallen.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -15,5 +15,19 @@ public function __construct(
|
|||||||
public readonly ?string $credit,
|
public readonly ?string $credit,
|
||||||
public readonly string $kind,
|
public readonly string $kind,
|
||||||
public readonly string $url,
|
public readonly string $url,
|
||||||
|
/** Bildadressen in mehreren Breiten für `srcset` (nur Bilder, deren Breiten die Warteschlange anlegt), sonst null. */
|
||||||
|
public readonly ?string $srcset = null,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adresse in einer der Breiten aus {@see ImageVariants::PUBLIC_WIDTHS}; ohne Breiten (oder bei anderer Breite) die volle Datei.
|
||||||
|
*/
|
||||||
|
public function urlForWidth(?int $width): string
|
||||||
|
{
|
||||||
|
if ($width === null || $this->srcset === null || ! ImageVariants::isPublicWidth($width)) {
|
||||||
|
return $this->url;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->url.(str_contains($this->url, '?') ? '&' : '?').'w='.$width;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,261 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Pages;
|
||||||
|
|
||||||
|
use App\Domain\Design\ColorContrast;
|
||||||
|
use App\Domain\Design\DesignPalette;
|
||||||
|
use App\Domain\Identity\StaffRole;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Pages\Page;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Website → Design → Farben (ADR-67): die zentrale Farbpalette mit bis zu zehn benannten Farben (Hintergrund und Schrift).
|
||||||
|
* Die Seite zeigt jede Farbe als Kachel; Anlegen und Bearbeiten laufen in einem Dialog mit Live-Vorschau und Kontrastprüfung.
|
||||||
|
*
|
||||||
|
* Gespeichert wird je Farbe mit „Speichern“ im Dialog. Eine Änderung der Farbwerte wirkt sofort auf alle Abschnitte mit
|
||||||
|
* dieser Farbe, auch auf veröffentlichten Seiten. Darum zeigt die Seite vor dem Speichern, welche Seiten das betrifft, und
|
||||||
|
* verlangt eine Bestätigung. Eine Farbe in Verwendung lässt sich nicht entfernen. Zugriff nur für den Systemverwalter;
|
||||||
|
* Redakteure wählen die Farben im CMS-Editor aus.
|
||||||
|
*/
|
||||||
|
class DesignFarben extends Page
|
||||||
|
{
|
||||||
|
protected static string|\UnitEnum|null $navigationGroup = 'Design';
|
||||||
|
|
||||||
|
protected static ?string $navigationLabel = 'Farben';
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 20;
|
||||||
|
|
||||||
|
protected static ?string $slug = 'design/farben';
|
||||||
|
|
||||||
|
protected static ?string $title = 'Farben';
|
||||||
|
|
||||||
|
protected string $view = 'filament.design.farben';
|
||||||
|
|
||||||
|
/** Offener Dialog: Kennung (null = neu), Name und Farbwerte als Ausgangswerte. @var array{id: ?string, name: string, bg: string, fg: string}|null */
|
||||||
|
public ?array $dialog = null;
|
||||||
|
|
||||||
|
/** Fehlermeldungen des letzten Speicherversuchs je Feld („name“, „bg“, „fg“, „slot“). @var array<string, string> */
|
||||||
|
public array $fehler = [];
|
||||||
|
|
||||||
|
/** Bestätigung: Aktion, Titel, Text, Beschriftung und die betroffenen Seiten. @var array<string, mixed>|null */
|
||||||
|
public ?array $bestaetigung = null;
|
||||||
|
|
||||||
|
/** Eingaben, die auf die Bestätigung warten. @var array{id: ?string, name: string, bg: string, fg: string}|null */
|
||||||
|
public ?array $wartend = null;
|
||||||
|
|
||||||
|
public static function canAccess(): bool
|
||||||
|
{
|
||||||
|
return auth()->user()?->hasStaffRole(StaffRole::Systemverwalter) === true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Die Überschrift steht im gemeinsamen Objektkopf (filament.verwaltung.kopf), nicht doppelt im Seitenkopf. */
|
||||||
|
public function getHeading(): string|Htmlable|null
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMaxContentWidth(): Width|string|null
|
||||||
|
{
|
||||||
|
return Width::SevenExtraLarge;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Dialog „Farbe anlegen“ mit Ausgangswerten (leere Farbe oder eine Markenfläche als Vorlage). */
|
||||||
|
public function neu(?string $vorlage = null): void
|
||||||
|
{
|
||||||
|
$this->pruefeZugriff();
|
||||||
|
$this->fehler = [];
|
||||||
|
|
||||||
|
if (DesignPalette::free() === 0) {
|
||||||
|
Notification::make()->warning()->title('Die Palette ist voll')->body('Es sind höchstens '.DesignPalette::MAX_SLOTS.' Farben möglich. Entfernen Sie zuerst eine nicht verwendete Farbe.')->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$start = ['id' => null, 'name' => '', 'bg' => '#3b7b09', 'fg' => '#ffffff'];
|
||||||
|
|
||||||
|
foreach (DesignPalette::builtIns() as $built) {
|
||||||
|
if ($built['key'] === $vorlage) {
|
||||||
|
$start = ['id' => null, 'name' => $built['label'], 'bg' => $built['bg'], 'fg' => $built['fg']];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->dialog = $start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function bearbeiten(string $id): void
|
||||||
|
{
|
||||||
|
$this->pruefeZugriff();
|
||||||
|
$this->fehler = [];
|
||||||
|
$farbe = DesignPalette::find($id);
|
||||||
|
|
||||||
|
$this->dialog = $farbe === null ? null : ['id' => $farbe['id'], 'name' => $farbe['name'], 'bg' => $farbe['bg'], 'fg' => $farbe['fg']];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function schliessen(): void
|
||||||
|
{
|
||||||
|
$this->dialog = null;
|
||||||
|
$this->wartend = null;
|
||||||
|
$this->bestaetigung = null;
|
||||||
|
$this->fehler = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* „Speichern“ im Dialog. Ändert sich bei einer verwendeten Farbe das Aussehen, folgt zuerst die Bestätigung mit den
|
||||||
|
* betroffenen Seiten.
|
||||||
|
*/
|
||||||
|
public function speichern(string $name, string $bg, string $fg): void
|
||||||
|
{
|
||||||
|
$this->pruefeZugriff();
|
||||||
|
$id = $this->dialog['id'] ?? null;
|
||||||
|
$this->fehler = DesignPalette::errors($id, $name, $bg, $fg);
|
||||||
|
|
||||||
|
if ($this->fehler !== []) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->dialog = ['id' => $id, 'name' => $name, 'bg' => $bg, 'fg' => $fg];
|
||||||
|
$bisher = $id === null ? null : DesignPalette::find($id);
|
||||||
|
$verwendung = $id === null ? [] : (DesignPalette::usage()[$id] ?? []);
|
||||||
|
$aenderung = $bisher !== null && ($bisher['bg'] !== ColorContrast::normalize($bg) || $bisher['fg'] !== ColorContrast::normalize($fg));
|
||||||
|
|
||||||
|
if ($aenderung && $verwendung !== []) {
|
||||||
|
$this->wartend = ['id' => $id, 'name' => $name, 'bg' => $bg, 'fg' => $fg];
|
||||||
|
$this->bestaetigung = [
|
||||||
|
'aktion' => 'wirkung',
|
||||||
|
'titel' => 'Diese Änderung wirkt auf bestehende Seiten',
|
||||||
|
'text' => 'Die Farbe „'.$bisher['name'].'“ wird auf '.$this->zaehlung($verwendung).' verwendet. Mit dem Speichern ändert sich die Darstellung dort sofort, auch auf der veröffentlichten Website. Sie müssen die Seiten nicht erneut veröffentlichen.',
|
||||||
|
'label' => 'Farbe ändern und sofort anwenden',
|
||||||
|
'gefahr' => false,
|
||||||
|
'liste' => $this->seitenliste($verwendung),
|
||||||
|
];
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ausfuehren($id, $name, $bg, $fg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Frage vor dem Entfernen oder Hinweis, warum es nicht geht. */
|
||||||
|
public function entfernenFragen(string $id): void
|
||||||
|
{
|
||||||
|
$this->pruefeZugriff();
|
||||||
|
$farbe = DesignPalette::find($id);
|
||||||
|
|
||||||
|
if ($farbe === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$verwendung = DesignPalette::usage()[$id] ?? [];
|
||||||
|
|
||||||
|
if ($verwendung !== []) {
|
||||||
|
$this->bestaetigung = [
|
||||||
|
'aktion' => 'hinweis',
|
||||||
|
'titel' => 'Die Farbe wird noch verwendet',
|
||||||
|
'text' => '„'.$farbe['name'].'“ lässt sich nicht entfernen, solange sie auf '.$this->zaehlung($verwendung).' steht. Wählen Sie dort zuerst eine andere Fläche.',
|
||||||
|
'label' => 'Verstanden',
|
||||||
|
'gefahr' => false,
|
||||||
|
'liste' => $this->seitenliste($verwendung),
|
||||||
|
];
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->bestaetigung = [
|
||||||
|
'aktion' => 'entfernen',
|
||||||
|
'argument' => $id,
|
||||||
|
'titel' => '„'.$farbe['name'].'“ entfernen?',
|
||||||
|
'text' => 'Die Farbe wird aus der Palette entfernt. Kein Abschnitt verwendet sie. Der Platz wird frei; die Kennung der Farbe wird nicht erneut vergeben.',
|
||||||
|
'label' => 'Farbe entfernen',
|
||||||
|
'gefahr' => true,
|
||||||
|
'liste' => [],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function confirmConfirmation(): void
|
||||||
|
{
|
||||||
|
$frage = $this->bestaetigung;
|
||||||
|
$this->bestaetigung = null;
|
||||||
|
|
||||||
|
match ($frage['aktion'] ?? null) {
|
||||||
|
'wirkung' => $this->wartend === null ? null : $this->ausfuehren($this->wartend['id'], $this->wartend['name'], $this->wartend['bg'], $this->wartend['fg']),
|
||||||
|
'entfernen' => $this->entfernen((string) ($frage['argument'] ?? '')),
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
|
||||||
|
$this->wartend = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cancelConfirmation(): void
|
||||||
|
{
|
||||||
|
$this->bestaetigung = null;
|
||||||
|
$this->wartend = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function entfernen(string $id): void
|
||||||
|
{
|
||||||
|
$this->pruefeZugriff();
|
||||||
|
$fehler = DesignPalette::remove($id, auth()->user());
|
||||||
|
|
||||||
|
if ($fehler !== []) {
|
||||||
|
Notification::make()->danger()->title('Nicht entfernt')->body($fehler['slot'])->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Notification::make()->success()->title('Farbe entfernt')->body('Der Platz in der Palette ist wieder frei.')->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function ausfuehren(?string $id, string $name, string $bg, string $fg): void
|
||||||
|
{
|
||||||
|
$this->fehler = DesignPalette::save($id, $name, $bg, $fg, auth()->user());
|
||||||
|
|
||||||
|
if ($this->fehler !== []) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->dialog = null;
|
||||||
|
Notification::make()->success()
|
||||||
|
->title($id === null ? 'Farbe angelegt' : 'Farbe gespeichert')
|
||||||
|
->body($id === null ? 'Sie steht jetzt im CMS-Editor unter „Hintergrund“ zur Auswahl.' : 'Die Änderung gilt sofort auf der Website und in den CMS-Vorschauen.')
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<array{page_id: int, path: string, title: string, published: int, draft: int}> $verwendung
|
||||||
|
*/
|
||||||
|
private function zaehlung(array $verwendung): string
|
||||||
|
{
|
||||||
|
$veroeffentlicht = count(array_filter($verwendung, static fn (array $use): bool => $use['published'] > 0));
|
||||||
|
$entwurf = count(array_filter($verwendung, static fn (array $use): bool => $use['draft'] > 0));
|
||||||
|
$text = count($verwendung).' '.(count($verwendung) === 1 ? 'Seite' : 'Seiten');
|
||||||
|
|
||||||
|
return $text.' (veröffentlicht: '.$veroeffentlicht.', im Entwurf: '.$entwurf.')';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<array{page_id: int, path: string, title: string, published: int, draft: int}> $verwendung
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function seitenliste(array $verwendung): array
|
||||||
|
{
|
||||||
|
$zeilen = [];
|
||||||
|
|
||||||
|
foreach (array_slice($verwendung, 0, 8) as $use) {
|
||||||
|
$stand = array_filter([$use['published'] > 0 ? 'veröffentlicht' : null, $use['draft'] > 0 ? 'Entwurf' : null]);
|
||||||
|
$zeilen[] = $use['title'].' ('.$use['path'].') – '.implode(' und ', $stand);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($verwendung) > 8) {
|
||||||
|
$zeilen[] = 'und '.(count($verwendung) - 8).' weitere';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $zeilen;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function pruefeZugriff(): void
|
||||||
|
{
|
||||||
|
abort_unless(self::canAccess(), 403);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,10 @@
|
|||||||
use App\Domain\Communication\CommunicationAccess;
|
use App\Domain\Communication\CommunicationAccess;
|
||||||
use App\Domain\Communication\CommunicationSettings;
|
use App\Domain\Communication\CommunicationSettings;
|
||||||
use App\Domain\Communication\ExampleConfiguration;
|
use App\Domain\Communication\ExampleConfiguration;
|
||||||
|
use App\Filament\Resources\Communication\Entries\InquiryEntryResource;
|
||||||
|
use App\Filament\Resources\Communication\Fields\InquiryFieldResource;
|
||||||
|
use App\Filament\Resources\Communication\Groups\InquiryFieldGroupResource;
|
||||||
|
use App\Filament\Resources\Communication\Issues\InquiryIssueResource;
|
||||||
use App\Mail\CommunicationTestMail;
|
use App\Mail\CommunicationTestMail;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\Textarea;
|
use Filament\Forms\Components\Textarea;
|
||||||
@@ -31,7 +35,7 @@ class KommunikationEinstellungen extends Page
|
|||||||
|
|
||||||
protected static ?string $navigationLabel = 'Einstellungen';
|
protected static ?string $navigationLabel = 'Einstellungen';
|
||||||
|
|
||||||
protected static ?int $navigationSort = 7;
|
protected static ?int $navigationSort = 3;
|
||||||
|
|
||||||
protected static ?string $slug = 'kommunikation/einstellungen';
|
protected static ?string $slug = 'kommunikation/einstellungen';
|
||||||
|
|
||||||
@@ -84,6 +88,17 @@ public function form(Schema $schema): Schema
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
]),
|
]),
|
||||||
|
Section::make('Weitere Bausteine')->description('Anliegen und der gemeinsame Feldkatalog gehören zu den Formularen. Im Formular-Editor müssen sie nicht geöffnet werden; hier lassen sie sich einsehen und ordnen.')
|
||||||
|
->visible(fn (): bool => CommunicationAccess::configure())
|
||||||
|
->collapsed()
|
||||||
|
->schema([
|
||||||
|
Actions::make([
|
||||||
|
Action::make('issues')->label('Anliegen')->url(InquiryIssueResource::getUrl('index'))->color('gray'),
|
||||||
|
Action::make('fields')->label('Feldkatalog')->url(InquiryFieldResource::getUrl('index'))->color('gray'),
|
||||||
|
Action::make('groups')->label('Feldgruppen')->url(InquiryFieldGroupResource::getUrl('index'))->color('gray'),
|
||||||
|
Action::make('entries')->label('Anfrage-Einstiege (ältere Seiten)')->url(InquiryEntryResource::getUrl('index'))->color('gray'),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
Section::make('Aufbewahrung')->schema([
|
Section::make('Aufbewahrung')->schema([
|
||||||
TextInput::make('retention_months')->label('Anfragen löschen nach … Monaten')->numeric()->minValue(1)->maxValue(120)
|
TextInput::make('retention_months')->label('Anfragen löschen nach … Monaten')->numeric()->minValue(1)->maxValue(120)
|
||||||
->helperText('Leer: Anfragen werden nicht automatisch gelöscht. Der Befehl „php artisan communication:purge“ löscht Anfragen, die älter sind. Einzelne Anfragen lassen sich jederzeit im Posteingang löschen. Die Dauer ist mit dem Datenschutzkonzept abzustimmen.'),
|
->helperText('Leer: Anfragen werden nicht automatisch gelöscht. Der Befehl „php artisan communication:purge“ löscht Anfragen, die älter sind. Einzelne Anfragen lassen sich jederzeit im Posteingang löschen. Die Dauer ist mit dem Datenschutzkonzept abzustimmen.'),
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ class InquiryEntryResource extends CommunicationResource
|
|||||||
|
|
||||||
protected static ?int $navigationSort = 6;
|
protected static ?int $navigationSort = 6;
|
||||||
|
|
||||||
|
/** Technischer Baustein des Formular-Editors: erreichbar über „Einstellungen“, nicht in der Hauptnavigation (ADR-61). */
|
||||||
|
public static function shouldRegisterNavigation(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
public static function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return $schema->components([
|
return $schema->components([
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ class InquiryFieldResource extends CommunicationResource
|
|||||||
|
|
||||||
protected static ?int $navigationSort = 3;
|
protected static ?int $navigationSort = 3;
|
||||||
|
|
||||||
|
/** Technischer Baustein des Formular-Editors: erreichbar über „Einstellungen“, nicht in der Hauptnavigation (ADR-61). */
|
||||||
|
public static function shouldRegisterNavigation(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return list<Component>
|
* @return list<Component>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ class InquiryFieldGroupResource extends CommunicationResource
|
|||||||
|
|
||||||
protected static ?int $navigationSort = 4;
|
protected static ?int $navigationSort = 4;
|
||||||
|
|
||||||
|
/** Technischer Baustein des Formular-Editors: erreichbar über „Einstellungen“, nicht in der Hauptnavigation (ADR-61). */
|
||||||
|
public static function shouldRegisterNavigation(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
public static function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return $schema->components([
|
return $schema->components([
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public static function infolist(Schema $schema): Schema
|
|||||||
TextEntry::make('status')->label('Bearbeitungsstatus')->badge()
|
TextEntry::make('status')->label('Bearbeitungsstatus')->badge()
|
||||||
->formatStateUsing(fn ($state): string => $state->label())
|
->formatStateUsing(fn ($state): string => $state->label())
|
||||||
->color(fn ($state): string => $state->color()),
|
->color(fn ($state): string => $state->color()),
|
||||||
TextEntry::make('entry.name')->label('Anfrage-Einstieg')->placeholder('Gelöscht'),
|
TextEntry::make('channel')->label('Eingegangen über')->state(fn (Inquiry $record): string => $record->channelTitle()),
|
||||||
TextEntry::make('source_path')->label('Quellseite')->placeholder('Unbekannt'),
|
TextEntry::make('source_path')->label('Quellseite')->placeholder('Unbekannt'),
|
||||||
TextEntry::make('created_at')->label('Eingegangen')->dateTime('d.m.Y H:i'),
|
TextEntry::make('created_at')->label('Eingegangen')->dateTime('d.m.Y H:i'),
|
||||||
TextEntry::make('reference')->label('Kennzeichen')->copyable(),
|
TextEntry::make('reference')->label('Kennzeichen')->copyable(),
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public function bestand(): array
|
|||||||
|
|
||||||
protected function catalogRows(): array
|
protected function catalogRows(): array
|
||||||
{
|
{
|
||||||
$query = Inquiry::query()->with('entry');
|
$query = Inquiry::query()->with(['entry', 'templateVersion.template']);
|
||||||
|
|
||||||
if ($this->anliegen !== 'alle') {
|
if ($this->anliegen !== 'alle') {
|
||||||
$query->where('issue_key', $this->anliegen);
|
$query->where('issue_key', $this->anliegen);
|
||||||
@@ -79,7 +79,7 @@ protected function catalogRows(): array
|
|||||||
$rows[] = [
|
$rows[] = [
|
||||||
'schluessel' => 'q'.$inquiry->id,
|
'schluessel' => 'q'.$inquiry->id,
|
||||||
'titel' => $inquiry->contactTitle().($inquiry->organisation ? ' · '.$inquiry->organisation : ''),
|
'titel' => $inquiry->contactTitle().($inquiry->organisation ? ' · '.$inquiry->organisation : ''),
|
||||||
'meta' => $inquiry->created_at->format('d.m.Y H:i').' · '.($inquiry->issueTitle() ?: 'Ohne Anliegen').' · '.($inquiry->entry->name ?? 'Einstieg gelöscht'),
|
'meta' => $inquiry->created_at->format('d.m.Y H:i').' · '.($inquiry->issueTitle() ?: 'Ohne Anliegen').' · '.$inquiry->channelTitle(),
|
||||||
'text' => Str::limit((string) $inquiry->message, 180),
|
'text' => Str::limit((string) $inquiry->message, 180),
|
||||||
'suchtext' => implode(' ', array_filter([$inquiry->contact_email, $inquiry->reference, $inquiry->contact_phone])),
|
'suchtext' => implode(' ', array_filter([$inquiry->contact_email, $inquiry->reference, $inquiry->contact_phone])),
|
||||||
'symbol' => 'modul',
|
'symbol' => 'modul',
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ class InquiryIssueResource extends CommunicationResource
|
|||||||
|
|
||||||
protected static ?int $navigationSort = 2;
|
protected static ?int $navigationSort = 2;
|
||||||
|
|
||||||
|
/** Technischer Baustein des Formular-Editors: erreichbar über „Einstellungen“, nicht in der Hauptnavigation (ADR-61). */
|
||||||
|
public static function shouldRegisterNavigation(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
public static function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return $schema->components([
|
return $schema->components([
|
||||||
|
|||||||
@@ -13,28 +13,28 @@
|
|||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Anfragevorlagen: ein vollständiger fachlicher Anfrageprozess. Der Entwurf ist frei bearbeitbar; wirksam wird nur eine
|
* Formulare & Befragungen (Anfragevorlagen): ein vollständiger fachlicher Anfrageprozess, bearbeitet im Formular-Editor (ADR-61). Der Entwurf ist frei bearbeitbar; wirksam wird nur eine
|
||||||
* bewusst veröffentlichte, unveränderliche Fassung.
|
* bewusst veröffentlichte, unveränderliche Fassung.
|
||||||
*/
|
*/
|
||||||
class InquiryTemplateResource extends CommunicationResource
|
class InquiryTemplateResource extends CommunicationResource
|
||||||
{
|
{
|
||||||
protected static ?string $model = InquiryTemplate::class;
|
protected static ?string $model = InquiryTemplate::class;
|
||||||
|
|
||||||
protected static ?string $navigationLabel = 'Anfragevorlagen';
|
protected static ?string $navigationLabel = 'Formulare & Befragungen';
|
||||||
|
|
||||||
protected static ?string $modelLabel = 'Anfragevorlage';
|
protected static ?string $modelLabel = 'Formular';
|
||||||
|
|
||||||
protected static ?string $pluralModelLabel = 'Anfragevorlagen';
|
protected static ?string $pluralModelLabel = 'Formulare & Befragungen';
|
||||||
|
|
||||||
protected static ?string $recordTitleAttribute = 'name';
|
protected static ?string $recordTitleAttribute = 'name';
|
||||||
|
|
||||||
protected static ?string $slug = 'kommunikation/vorlagen';
|
protected static ?string $slug = 'kommunikation/vorlagen';
|
||||||
|
|
||||||
protected static ?int $navigationSort = 5;
|
protected static ?int $navigationSort = 2;
|
||||||
|
|
||||||
public static function form(Schema $schema): Schema
|
public static function form(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return $schema->components(TemplateEditor::schema());
|
return $schema->components(TemplateEditor::schema($schema->getRecord()?->getKey()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Communication\Templates\Pages;
|
namespace App\Filament\Resources\Communication\Templates\Pages;
|
||||||
|
|
||||||
|
use App\Domain\Communication\FormEditor;
|
||||||
use App\Domain\Communication\InquiryTemplate;
|
use App\Domain\Communication\InquiryTemplate;
|
||||||
use App\Domain\Communication\Publisher;
|
use App\Domain\Communication\Publisher;
|
||||||
use App\Domain\Communication\TemplateCompiler;
|
use App\Domain\Communication\TemplateCompiler;
|
||||||
@@ -38,7 +39,7 @@ public function getSubheading(): string|Htmlable|null
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! $template->isPublished()) {
|
if (! $template->isPublished()) {
|
||||||
return 'Noch nicht veröffentlicht. Besucher sehen diese Vorlage erst nach „Veröffentlichen“.';
|
return 'Noch nicht veröffentlicht. Besucher sehen dieses Formular erst nach „Veröffentlichen“.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$version = $template->publishedVersion;
|
$version = $template->publishedVersion;
|
||||||
@@ -76,7 +77,7 @@ protected function getHeaderActions(): array
|
|||||||
->label('Veröffentlichen')
|
->label('Veröffentlichen')
|
||||||
->color('primary')
|
->color('primary')
|
||||||
->visible(fn (): bool => $this->getRecord()->archived_at === null)
|
->visible(fn (): bool => $this->getRecord()->archived_at === null)
|
||||||
->modalHeading('Neue Fassung veröffentlichen')
|
->modalHeading('Formular veröffentlichen')
|
||||||
->modalSubmitActionLabel('Jetzt veröffentlichen')
|
->modalSubmitActionLabel('Jetzt veröffentlichen')
|
||||||
->modalWidth('2xl')
|
->modalWidth('2xl')
|
||||||
->schema(fn (): array => [
|
->schema(fn (): array => [
|
||||||
@@ -89,7 +90,7 @@ protected function getHeaderActions(): array
|
|||||||
try {
|
try {
|
||||||
$version = app(Publisher::class)->publishTemplate($this->getRecord(), auth('staff')->user() instanceof User ? auth('staff')->user() : null, $data['note'] ?? null);
|
$version = app(Publisher::class)->publishTemplate($this->getRecord(), auth('staff')->user() instanceof User ? auth('staff')->user() : null, $data['note'] ?? null);
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
Notification::make()->title('Die Vorlage lässt sich nicht veröffentlichen')->body(implode("\n", array_map(fn (string $line): string => '• '.$line, (array) ($e->errors()['draft'] ?? []))))->danger()->persistent()->send();
|
Notification::make()->title('Das Formular lässt sich nicht veröffentlichen')->body(implode("\n", array_map(fn (string $line): string => '• '.$line, (array) ($e->errors()['draft'] ?? []))))->danger()->persistent()->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -107,17 +108,17 @@ private function affectedText(): string
|
|||||||
$rows = app(Publisher::class)->affected($this->getRecord());
|
$rows = app(Publisher::class)->affected($this->getRecord());
|
||||||
|
|
||||||
if ($rows === []) {
|
if ($rows === []) {
|
||||||
return 'Speichert den Entwurf und veröffentlicht ihn als neue Fassung. Noch kein Anfrage-Einstieg verwendet diese Vorlage.';
|
return 'Speichert den Entwurf und veröffentlicht ihn als neue Fassung. Sie gilt sofort überall, wo das Formular im Widget „Anfrage“ eingebunden ist. Die bisherige Fassung bleibt als Verlauf erhalten und lässt sich wieder in Kraft setzen.';
|
||||||
}
|
}
|
||||||
|
|
||||||
$names = array_map(fn (array $row): string => $row['entry']->name.($row['entry']->published_config !== null ? ' (veröffentlicht)' : ' (Entwurf)'), $rows);
|
$names = array_map(fn (array $row): string => $row['entry']->name.($row['entry']->published_config !== null ? ' (veröffentlicht)' : ' (Entwurf)'), $rows);
|
||||||
|
|
||||||
return 'Speichert den Entwurf und veröffentlicht ihn als neue Fassung. Sofort betroffen sind diese Anfrage-Einstiege und damit alle Seiten, die sie einbinden: '.implode(', ', $names).'. Die bisherige Fassung bleibt als Verlauf erhalten und lässt sich wieder in Kraft setzen.';
|
return 'Speichert den Entwurf und veröffentlicht ihn als neue Fassung. Sie gilt sofort überall, wo das Formular im Widget „Anfrage“ eingebunden ist, und für diese Anfrage-Einstiege (ältere Seiten): '.implode(', ', $names).'. Die bisherige Fassung bleibt als Verlauf erhalten und lässt sich wieder in Kraft setzen.';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function archiveNote(): string
|
protected function archiveNote(): string
|
||||||
{
|
{
|
||||||
return 'Die Vorlage wird archiviert. Anfrage-Einstiege, die sie verwenden, liefern dann kein Formular mehr aus. Eingegangene Anfragen bleiben unverändert.';
|
return 'Das Formular wird archiviert. Seiten, die es einbinden, bieten es dann nicht mehr an (auch Anfrage-Einstiege liefern nichts mehr aus). Eingegangene Anfragen bleiben unverändert.';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function archiveAttributes(): array
|
protected function archiveAttributes(): array
|
||||||
@@ -134,16 +135,68 @@ protected function archiveBlocked(): ?string
|
|||||||
{
|
{
|
||||||
$live = $this->getRecord()->entries()->live()->count();
|
$live = $this->getRecord()->entries()->live()->count();
|
||||||
|
|
||||||
return $live > 0 ? "Es gibt noch $live veröffentlichte Anfrage-Einstiege mit dieser Vorlage. Bitte zuerst zurückziehen oder auf eine andere Vorlage umstellen." : null;
|
return $live > 0 ? "Es gibt noch $live veröffentlichte Anfrage-Einstiege mit diesem Formular. Bitte zuerst zurückziehen oder auf ein anderes Formular umstellen." : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function mutateFormDataBeforeFill(array $data): array
|
||||||
|
{
|
||||||
|
$tree = FormEditor::toTree(app(FormEditor::class)->expand((array) ($data['draft'] ?? []), $this->getRecord()->getKey()));
|
||||||
|
|
||||||
|
// Die Formularansicht führt den Baum im Browser und übergibt ihn als Text; die weiteren Regeln bleiben eine Liste.
|
||||||
|
$data['editor'] = ['rules' => $tree['rules']];
|
||||||
|
$data['editor_json'] = json_encode(['areas' => $tree['areas']], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR);
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function mutateFormDataBeforeSave(array $data): array
|
protected function mutateFormDataBeforeSave(array $data): array
|
||||||
{
|
{
|
||||||
$data['draft'] = TemplateDraft::clean((array) ($data['draft'] ?? []));
|
$editor = app(FormEditor::class);
|
||||||
|
$tree = json_decode((string) ($data['editor_json'] ?? ''), true);
|
||||||
|
|
||||||
|
if (! is_array($tree)) {
|
||||||
|
$this->failEditor(['Der Aufbau konnte nicht gelesen werden. Bitte lade die Seite neu und versuche es noch einmal.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$errors = $editor->validateTree($tree);
|
||||||
|
|
||||||
|
if ($errors !== []) {
|
||||||
|
$this->failEditor($errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Der Editor schreibt neue und geänderte Felder und Teilbereiche in den Katalog und liefert den Entwurf.
|
||||||
|
$view = FormEditor::fromTree($tree);
|
||||||
|
$view['rules'] = (array) ($data['editor']['rules'] ?? []);
|
||||||
|
$saved = $editor->persist($view);
|
||||||
|
unset($data['editor'], $data['editor_json']);
|
||||||
|
|
||||||
|
$data['draft'] = TemplateDraft::clean([
|
||||||
|
'texts' => (array) ($data['draft']['texts'] ?? []),
|
||||||
|
'issues' => $saved['issues'],
|
||||||
|
'steps' => $saved['steps'],
|
||||||
|
'rules' => $saved['rules'],
|
||||||
|
]);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $messages
|
||||||
|
* @return never
|
||||||
|
*/
|
||||||
|
private function failEditor(array $messages): void
|
||||||
|
{
|
||||||
|
Notification::make()->title('Das Formular ist noch nicht vollständig')->body(implode("\n", array_map(fn (string $line): string => '• '.$line, $messages)))->danger()->persistent()->send();
|
||||||
|
|
||||||
|
throw ValidationException::withMessages(['data.editor_json' => $messages]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function afterSave(): void
|
||||||
|
{
|
||||||
|
// Neue Felder und Teilbereiche tragen jetzt ihre festen Kennungen. Ohne neues Laden würde ein zweites Speichern sie doppelt anlegen.
|
||||||
|
$this->fillForm();
|
||||||
|
}
|
||||||
|
|
||||||
protected function getRedirectUrl(): ?string
|
protected function getRedirectUrl(): ?string
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -22,19 +22,19 @@ class ListInquiryTemplates extends ListRecords
|
|||||||
|
|
||||||
public function getSubheading(): string|Htmlable|null
|
public function getSubheading(): string|Htmlable|null
|
||||||
{
|
{
|
||||||
return 'Eine Anfragevorlage beschreibt einen vollständigen Anfrageprozess: Schritte, Feldgruppen, Bedingungen und Texte. Änderungen entstehen zunächst als Entwurf und gelten erst nach „Veröffentlichen“. Die Anfrage-Einstiege, die eine Vorlage verwenden, übernehmen jede neu veröffentlichte Fassung.';
|
return 'Hier entstehen Formulare und Befragungen: Bereiche mit Feldern, Bedingungen und Texte, alles in einem Editor. Änderungen sind zunächst ein Entwurf und gelten erst nach „Veröffentlichen“. Im Widget „Anfrage“ einer Seite wählst du, welches Formular zu welchem Anfragegrund gehört.';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Action::make('create')
|
Action::make('create')
|
||||||
->label('Vorlage anlegen')
|
->label('Formular anlegen')
|
||||||
->modalHeading('Neue Anfragevorlage')
|
->modalHeading('Neues Formular')
|
||||||
->modalDescription('Der Aufbau entsteht danach auf der Seite der Vorlage.')
|
->modalDescription('Der Aufbau entsteht danach im Editor des Formulars.')
|
||||||
->modalSubmitActionLabel('Vorlage anlegen')
|
->modalSubmitActionLabel('Formular anlegen')
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('name')->label('Bezeichnung')->required()->maxLength(120),
|
TextInput::make('name')->label('Name des Formulars')->required()->maxLength(120),
|
||||||
Textarea::make('description')->label('Beschreibung (nur Verwaltung, optional)')->rows(2)->maxLength(400),
|
Textarea::make('description')->label('Beschreibung (nur Verwaltung, optional)')->rows(2)->maxLength(400),
|
||||||
])
|
])
|
||||||
->action(function (array $data): void {
|
->action(function (array $data): void {
|
||||||
@@ -48,7 +48,7 @@ protected function getHeaderActions(): array
|
|||||||
'draft' => $draft,
|
'draft' => $draft,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Notification::make()->title('Die Vorlage ist angelegt.')->success()->send();
|
Notification::make()->title('Das Formular ist angelegt.')->success()->send();
|
||||||
$this->redirect(InquiryTemplateResource::getUrl('edit', ['record' => $template]));
|
$this->redirect(InquiryTemplateResource::getUrl('edit', ['record' => $template]));
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
@@ -68,7 +68,7 @@ protected function catalogRows(): array
|
|||||||
$rows[] = [
|
$rows[] = [
|
||||||
'schluessel' => 't'.$template->id,
|
'schluessel' => 't'.$template->id,
|
||||||
'titel' => $template->name,
|
'titel' => $template->name,
|
||||||
'meta' => 'Anfragevorlage · '.$steps.' '.($steps === 1 ? 'Schritt' : 'Schritte').' · '.$template->entries_count.' '.($template->entries_count === 1 ? 'Einstieg' : 'Einstiege'),
|
'meta' => 'Formular · '.$steps.' '.($steps === 1 ? 'Bereich' : 'Bereiche').($template->entries_count > 0 ? ' · '.$template->entries_count.' '.($template->entries_count === 1 ? 'Einstieg' : 'Einstiege').' (ältere Seiten)' : ''),
|
||||||
'text' => (string) ($template->description ?? ''),
|
'text' => (string) ($template->description ?? ''),
|
||||||
'symbol' => 'modul',
|
'symbol' => 'modul',
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
@@ -104,11 +104,11 @@ protected function suchPlatzhalter(): string
|
|||||||
|
|
||||||
protected function einheit(): array
|
protected function einheit(): array
|
||||||
{
|
{
|
||||||
return ['Anfragevorlage', 'Anfragevorlagen'];
|
return ['Formular', 'Formulare'];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function leer(): array
|
protected function leer(): array
|
||||||
{
|
{
|
||||||
return ['titel' => 'Noch keine Anfragevorlagen', 'text' => 'Mit „Vorlage anlegen“ oben entsteht die erste Vorlage. Auf der Seite „Einstellungen“ lässt sich eine Beispielkonfiguration anlegen.'];
|
return ['titel' => 'Noch keine Formulare', 'text' => 'Mit „Formular anlegen“ oben entsteht das erste Formular. Auf der Seite „Einstellungen“ lässt sich eine Beispielkonfiguration anlegen.'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
@@ -33,6 +33,9 @@ public function table(Table $table): Table
|
|||||||
$template = $this->getOwnerRecord();
|
$template = $this->getOwnerRecord();
|
||||||
|
|
||||||
return $table
|
return $table
|
||||||
|
->heading('Fassungen')
|
||||||
|
->emptyStateHeading('Noch keine Fassung veröffentlicht')
|
||||||
|
->emptyStateDescription('Mit „Veröffentlichen“ entsteht die erste Fassung.')
|
||||||
->columns([
|
->columns([
|
||||||
TextColumn::make('version')->label('Fassung')->prefix('Nr. '),
|
TextColumn::make('version')->label('Fassung')->prefix('Nr. '),
|
||||||
TextColumn::make('published_at')->label('Veröffentlicht')->dateTime('d.m.Y H:i'),
|
TextColumn::make('published_at')->label('Veröffentlicht')->dateTime('d.m.Y H:i'),
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public function form(Schema $schema): Schema
|
|||||||
Placeholder::make('thumbnail_current')->label('Aktuelles Vorschaubild')->content(function (): HtmlString {
|
Placeholder::make('thumbnail_current')->label('Aktuelles Vorschaubild')->content(function (): HtmlString {
|
||||||
/** @var ContentElement $element */
|
/** @var ContentElement $element */
|
||||||
$element = $this->getRecord();
|
$element = $this->getRecord();
|
||||||
$url = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
$url = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
$caption = match ($element->thumbnail_source) {
|
$caption = match ($element->thumbnail_source) {
|
||||||
'eigen' => 'Eigenes Vorschaubild.',
|
'eigen' => 'Eigenes Vorschaubild.',
|
||||||
'datei' => 'Vorschaubild aus der Datei des Mediums.',
|
'datei' => 'Vorschaubild aus der Datei des Mediums.',
|
||||||
|
|||||||
@@ -589,7 +589,7 @@ private function viewerData(): array
|
|||||||
&& $element->output_class === 'text'
|
&& $element->output_class === 'text'
|
||||||
&& $shown->status !== ContentVersionStatus::Gesperrt,
|
&& $shown->status !== ContentVersionStatus::Gesperrt,
|
||||||
'bodyCommitted' => $committed,
|
'bodyCommitted' => $committed,
|
||||||
'pictureUrl' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
'pictureUrl' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at),
|
||||||
'pictureCaption' => $this->pictureCaption($element),
|
'pictureCaption' => $this->pictureCaption($element),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -1076,7 +1076,7 @@ public function previewHtml(): string
|
|||||||
'kind' => PublicMaterialReader::outputLabel((string) $element->output_class),
|
'kind' => PublicMaterialReader::outputLabel((string) $element->output_class),
|
||||||
'hide_status' => true,
|
'hide_status' => true,
|
||||||
'image' => trim($this->thumbnailAlt) !== '' ? trim($this->thumbnailAlt) : $title,
|
'image' => trim($this->thumbnailAlt) !== '' ? trim($this->thumbnailAlt) : $title,
|
||||||
'image_url' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
'image_url' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at),
|
||||||
'error' => 'Vorschau der Kartenform. Ob jemand sie öffnen darf, entscheidet die Lizenz.',
|
'error' => 'Vorschau der Kartenform. Ob jemand sie öffnen darf, entscheidet die Lizenz.',
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ protected function catalogRows(): array
|
|||||||
'titel' => $title,
|
'titel' => $title,
|
||||||
'meta' => 'Lizenzartikel · '.$article->code.(filled($article->product_line) ? ' · '.$article->product_line : ''),
|
'meta' => 'Lizenzartikel · '.$article->code.(filled($article->product_line) ? ' · '.$article->product_line : ''),
|
||||||
'text' => trim((string) ($article->teaser ?: $article->summary)),
|
'text' => trim((string) ($article->teaser ?: $article->summary)),
|
||||||
'bild' => $cover !== null ? ThumbnailRef::url('editorial.card', 'element', $cover->id, $cover->thumbnail_path) : null,
|
'bild' => $cover !== null ? ThumbnailRef::url('editorial.card', 'element', $cover->id, $cover->thumbnail_path, 'klein', $cover->updated_at) : null,
|
||||||
'symbol' => 'dokument',
|
'symbol' => 'dokument',
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'chips' => $chips,
|
'chips' => $chips,
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
use App\Domain\Catalog\PillarService;
|
use App\Domain\Catalog\PillarService;
|
||||||
use App\Domain\Cms\Page;
|
use App\Domain\Cms\Page;
|
||||||
use App\Domain\Cms\PageService;
|
use App\Domain\Cms\PageService;
|
||||||
|
use App\Domain\Cms\Sections\PageSections;
|
||||||
|
use App\Domain\Cms\SectionTransfer;
|
||||||
use App\Filament\Resources\Pages\PageResource;
|
use App\Filament\Resources\Pages\PageResource;
|
||||||
use App\Filament\Support\ChoosesLinkTargets;
|
use App\Filament\Support\ChoosesLinkTargets;
|
||||||
use App\Filament\Support\ChoosesWebsiteImages;
|
use App\Filament\Support\ChoosesWebsiteImages;
|
||||||
@@ -176,6 +178,11 @@ public function save(bool $shouldRedirect = true, bool $shouldSendSavedNotificat
|
|||||||
$this->register = str_contains($keys, 'data.sections') ? 'inhalt' : (preg_match('/data\.(path|seo_|pillars)/', $keys) === 1 ? 'einstellungen' : $this->register);
|
$this->register = str_contains($keys, 'data.sections') ? 'inhalt' : (preg_match('/data\.(path|seo_|pillars)/', $keys) === 1 ? 'einstellungen' : $this->register);
|
||||||
$this->showFailingSection(array_keys($exception->errors()));
|
$this->showFailingSection(array_keys($exception->errors()));
|
||||||
|
|
||||||
|
// Name und Sprungmarke stehen im Einstellungsdialog; die Meldung am Abschnitt führt dorthin. Hierher scrollen.
|
||||||
|
if (preg_match('/data\.sections\.[^.]+\.(name|anchor)(\.|\s|$)/', $keys) === 1) {
|
||||||
|
$this->js("requestAnimationFrame(() => requestAnimationFrame(() => document.querySelector('[data-abschnitt-fehler]')?.scrollIntoView({ block: 'center' })))");
|
||||||
|
}
|
||||||
|
|
||||||
throw $exception;
|
throw $exception;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -236,6 +243,103 @@ public function saveFromBlock(): void
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abschnitt auf eine andere Seite kopieren oder verschieben (Schalter im Abschnittskopf). Der Abschnitt stammt aus
|
||||||
|
* dem Arbeitsstand dieser Seite. Die Zielseite erhält eine neue Entwurfsrevision. Beim Verschieben wird er danach
|
||||||
|
* aus dem Arbeitsstand entfernt und die Seite als Entwurf gespeichert. Geprüft wird vor dem ersten Schreiben:
|
||||||
|
* scheitert eine Seite, bleibt beides unverändert.
|
||||||
|
*/
|
||||||
|
public function transferSection(string $key, int $targetId, string $position, bool $move): void
|
||||||
|
{
|
||||||
|
$this->forceRender();
|
||||||
|
$raw = is_array($this->data['sections'] ?? null) ? $this->data['sections'] : [];
|
||||||
|
$target = Page::query()->find($targetId);
|
||||||
|
|
||||||
|
if (! isset($raw[$key]) || $target === null || $target->is($this->record)) {
|
||||||
|
Notification::make()->title('Zielseite oder Abschnitt nicht gefunden')->danger()->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
abort_unless(auth()->user()?->can('update', $target) ?? false, 403);
|
||||||
|
|
||||||
|
// Der Arbeitsstand in der Form wie beim Speichern (formatierte Texte als HTML, Leeres entfernt).
|
||||||
|
try {
|
||||||
|
$state = $this->form->getState()['sections'] ?? [];
|
||||||
|
} catch (ValidationException) {
|
||||||
|
Notification::make()->title($move ? 'Abschnitt nicht verschoben' : 'Abschnitt nicht kopiert')->body('Auf dieser Seite gibt es noch Eingabefehler. Bitte zuerst beheben.')->danger()->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Die Schlüssel des Formulars gehen beim Aufbereiten verloren; die Reihenfolge bleibt.
|
||||||
|
$index = array_search($key, array_map('strval', array_keys($raw)), true);
|
||||||
|
$items = array_values(is_array($state) ? $state : []);
|
||||||
|
|
||||||
|
if ($index === false || ! isset($items[$index])) {
|
||||||
|
Notification::make()->title('Zielseite oder Abschnitt nicht gefunden')->danger()->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$transfer = app(SectionTransfer::class);
|
||||||
|
$section = SectionEditor::fromEditorState([$items[$index]])[0] ?? [];
|
||||||
|
$remaining = $items;
|
||||||
|
unset($remaining[$index]);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$transfer->plan($target, $section, $position, ! $move);
|
||||||
|
|
||||||
|
if ($move) {
|
||||||
|
// Die Quellseite muss ohne den Abschnitt gültig bleiben, sonst wird nichts geschrieben.
|
||||||
|
app(PageSections::class)->normalize(SectionEditor::fromEditorState($remaining));
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $transfer->insert($target, $section, $position, ! $move, auth()->user());
|
||||||
|
} catch (ValidationException $exception) {
|
||||||
|
Notification::make()
|
||||||
|
->title($move ? 'Abschnitt nicht verschoben' : 'Abschnitt nicht kopiert')
|
||||||
|
->body(collect($exception->errors())->flatten()->first() ?? 'Die Seite wäre danach ungültig.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($move) {
|
||||||
|
unset($raw[$key]);
|
||||||
|
$this->data['sections'] = $raw;
|
||||||
|
// Der Kontext „Abschnitt gestalten“ merkt sich eine Position, die sich durch das Entfernen verschiebt.
|
||||||
|
$this->abschnitt = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->save(shouldRedirect: false, shouldSendSavedNotification: false);
|
||||||
|
} catch (ValidationException $exception) {
|
||||||
|
foreach ($exception->errors() as $errorKey => $messages) {
|
||||||
|
foreach ((array) $messages as $message) {
|
||||||
|
$this->addError($errorKey, $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Notification::make()->title('Auf der Zielseite eingefügt, hier nicht gespeichert')->body('Bitte die markierten Fehler beheben und „Entwurf speichern“ wählen; sonst steht der Abschnitt auf beiden Seiten.')->warning()->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$anchorNote = match (true) {
|
||||||
|
! $result['anchorChanged'] => '',
|
||||||
|
$result['anchor'] !== null => ' Die Sprungmarke war dort vergeben und heißt jetzt „'.$result['anchor'].'“.',
|
||||||
|
default => ' Die Sprungmarke war dort vergeben; der Abschnitt hat keine mehr.',
|
||||||
|
};
|
||||||
|
|
||||||
|
Notification::make()
|
||||||
|
->title($move ? 'Abschnitt verschoben' : 'Abschnitt kopiert')
|
||||||
|
->body('Als Abschnitt '.$result['position'].' auf '.$target->path.' eingefügt (Entwurf, noch nicht veröffentlicht).'.$anchorNote)
|
||||||
|
->success()
|
||||||
|
->actions([Action::make('open')->label('Zielseite öffnen')->url(PageResource::getUrl('edit', ['record' => $target]))->button()])
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Design\DesignPalette;
|
||||||
|
use Filament\Forms\Components\ViewField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auswahl des Abschnittshintergrunds als farbige Kacheln statt einer Liste (ADR-67): Standard, die drei festen Markenflächen,
|
||||||
|
* die Farben der zentralen Palette und das Hintergrundbild. Das Feld ist das Feld „background“ der Abschnittsgestaltung;
|
||||||
|
* bei einer Palettenfarbe schreibt es zusätzlich „palette_slot“ (Geschwisterfeld im selben Zustand). Die Bildoptionen
|
||||||
|
* erscheinen wie bisher nur bei „Hintergrundbild“.
|
||||||
|
*/
|
||||||
|
final class BackgroundField
|
||||||
|
{
|
||||||
|
public static function make(string $name = 'background', string $label = 'Hintergrund'): ViewField
|
||||||
|
{
|
||||||
|
return ViewField::make($name)
|
||||||
|
->label($label)
|
||||||
|
->view('filament.cms.hintergrund-wahl')
|
||||||
|
->hiddenLabel()
|
||||||
|
->default('default');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Kacheln in der Reihenfolge der Anzeige. „id“ ist der Wert der Kachel („palette:c1“ für eine Palettenfarbe).
|
||||||
|
*
|
||||||
|
* @return list<array{id: string, value: string, slot: ?string, label: string, bg: ?string, fg: ?string, kind: string}>
|
||||||
|
*/
|
||||||
|
public static function tiles(): array
|
||||||
|
{
|
||||||
|
$tiles = [];
|
||||||
|
|
||||||
|
foreach (DesignPalette::builtIns() as $built) {
|
||||||
|
$tiles[] = ['id' => $built['key'], 'value' => $built['key'], 'slot' => null, 'label' => $built['label'], 'bg' => $built['bg'], 'fg' => $built['fg'], 'kind' => $built['key'] === 'default' ? 'default' : 'brand'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (DesignPalette::slots() as $slot) {
|
||||||
|
$tiles[] = ['id' => 'palette:'.$slot['id'], 'value' => 'palette', 'slot' => $slot['id'], 'label' => $slot['name'], 'bg' => $slot['bg'], 'fg' => $slot['fg'], 'kind' => 'palette'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$tiles[] = ['id' => 'image', 'value' => 'image', 'slot' => null, 'label' => 'Hintergrundbild', 'bg' => null, 'fg' => null, 'kind' => 'image'];
|
||||||
|
|
||||||
|
return $tiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,12 +18,14 @@
|
|||||||
use App\Domain\Catalog\LicenseArticle;
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
use App\Domain\Catalog\OfferStatus;
|
use App\Domain\Catalog\OfferStatus;
|
||||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
|
use App\Domain\Media\ThumbnailRef;
|
||||||
use App\Filament\Resources\Combinations\CombinationResource;
|
use App\Filament\Resources\Combinations\CombinationResource;
|
||||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
use App\Filament\Resources\Courses\CourseResource;
|
use App\Filament\Resources\Courses\CourseResource;
|
||||||
use App\Filament\Resources\Documents\DocumentResource;
|
use App\Filament\Resources\Documents\DocumentResource;
|
||||||
use App\Filament\Resources\Exercises\ExerciseResource;
|
use App\Filament\Resources\Exercises\ExerciseResource;
|
||||||
use App\Filament\Resources\Practices\PracticeResource;
|
use App\Filament\Resources\Practices\PracticeResource;
|
||||||
|
use Carbon\CarbonInterface;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@@ -115,7 +117,7 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
|
|||||||
'usage_note' => (string) ($element->usage_note ?? ''),
|
'usage_note' => (string) ($element->usage_note ?? ''),
|
||||||
'license_note' => (string) ($element->license_note ?? ''),
|
'license_note' => (string) ($element->license_note ?? ''),
|
||||||
'tone' => $this->tone((string) $element->output_class, $kind),
|
'tone' => $this->tone((string) $element->output_class, $kind),
|
||||||
'image' => $this->cardUrl('element', $element->id, $element->thumbnail_path),
|
'image' => $this->cardUrl('element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at),
|
||||||
'version_label' => match ($version->status) {
|
'version_label' => match ($version->status) {
|
||||||
ContentVersionStatus::Entwurf => 'Entwurf',
|
ContentVersionStatus::Entwurf => 'Entwurf',
|
||||||
ContentVersionStatus::Gesperrt => 'deaktiviert',
|
ContentVersionStatus::Gesperrt => 'deaktiviert',
|
||||||
@@ -163,7 +165,7 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
|
|||||||
'kind' => $kind,
|
'kind' => $kind,
|
||||||
'summary' => FormattedText::plain((string) ($composition->summary ?? '')),
|
'summary' => FormattedText::plain((string) ($composition->summary ?? '')),
|
||||||
'tone' => $this->tone('', $kind),
|
'tone' => $this->tone('', $kind),
|
||||||
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path),
|
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path, 'klein', $composition->updated_at),
|
||||||
'version_label' => $version->status === ContentVersionStatus::Gesperrt
|
'version_label' => $version->status === ContentVersionStatus::Gesperrt
|
||||||
? 'deaktiviert'
|
? 'deaktiviert'
|
||||||
: 'Fassung '.$version->number,
|
: 'Fassung '.$version->number,
|
||||||
@@ -198,7 +200,7 @@ private function draftCompositionRow(int $compositionId, int $exceptCompositionI
|
|||||||
'kind' => $kind,
|
'kind' => $kind,
|
||||||
'summary' => FormattedText::plain((string) ($composition->summary ?? '')),
|
'summary' => FormattedText::plain((string) ($composition->summary ?? '')),
|
||||||
'tone' => $this->tone('', $kind),
|
'tone' => $this->tone('', $kind),
|
||||||
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path),
|
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path, 'klein', $composition->updated_at),
|
||||||
'version_label' => 'Entwurf',
|
'version_label' => 'Entwurf',
|
||||||
'identity' => 'zusammenstellung:'.$composition->id,
|
'identity' => 'zusammenstellung:'.$composition->id,
|
||||||
'open_url' => route('editorial.draft-preview', ['composition' => $composition]),
|
'open_url' => route('editorial.draft-preview', ['composition' => $composition]),
|
||||||
@@ -524,7 +526,7 @@ private function rowForPresentationMedium(int $id): ?array
|
|||||||
'license_note' => (string) ($element->license_note ?? ''),
|
'license_note' => (string) ($element->license_note ?? ''),
|
||||||
'tone' => $this->tone((string) $element->output_class, $kind),
|
'tone' => $this->tone((string) $element->output_class, $kind),
|
||||||
'image' => $element->output_class === 'bild'
|
'image' => $element->output_class === 'bild'
|
||||||
? $this->cardUrl('element', $element->id, $element->thumbnail_path)
|
? $this->cardUrl('element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at)
|
||||||
: null,
|
: null,
|
||||||
'version_label' => 'Ohne Inhaltsfassung',
|
'version_label' => 'Ohne Inhaltsfassung',
|
||||||
'committed' => false,
|
'committed' => false,
|
||||||
@@ -548,13 +550,9 @@ public function tone(string $outputClass, string $kindLabel): string
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cardUrl(string $kind, int $id, ?string $path): ?string
|
public function cardUrl(string $kind, int $id, ?string $path, ?string $size = null, CarbonInterface|int|string|null $version = null): ?string
|
||||||
{
|
{
|
||||||
if (! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
return ThumbnailRef::url('editorial.card', $kind, $id, $path, $size, $version);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return route('editorial.card', ['kind' => $kind, 'subject' => $id]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -891,7 +889,7 @@ public function filmPictures(array $members): array
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$image = $this->cardUrl('element', $element->id, $element->thumbnail_path);
|
$image = $this->cardUrl('element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at);
|
||||||
|
|
||||||
if ($image === null || isset($pictures[$element->id])) {
|
if ($image === null || isset($pictures[$element->id])) {
|
||||||
continue;
|
continue;
|
||||||
@@ -933,7 +931,7 @@ public function mediaPictures(string $query): array
|
|||||||
->limit(12)
|
->limit(12)
|
||||||
->get()
|
->get()
|
||||||
->map(function (ContentElement $element): ?array {
|
->map(function (ContentElement $element): ?array {
|
||||||
$image = $this->cardUrl('element', $element->id, $element->thumbnail_path);
|
$image = $this->cardUrl('element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at);
|
||||||
|
|
||||||
if ($image === null) {
|
if ($image === null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -957,7 +955,7 @@ public function mediaPictures(string $query): array
|
|||||||
*/
|
*/
|
||||||
public function cover(Composition $composition, array $members): array
|
public function cover(Composition $composition, array $members): array
|
||||||
{
|
{
|
||||||
$own = $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path);
|
$own = $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path, 'mittel', $composition->updated_at);
|
||||||
|
|
||||||
if ($own !== null) {
|
if ($own !== null) {
|
||||||
return ['url' => $own, 'note' => null, 'own' => true];
|
return ['url' => $own, 'note' => null, 'own' => true];
|
||||||
@@ -970,7 +968,7 @@ public function cover(Composition $composition, array $members): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'url' => $this->cardUrl($picture['kind'], $picture['subject'], 'vorschau/gesetzt'),
|
'url' => $this->cardUrl($picture['kind'], $picture['subject'], 'vorschau/gesetzt', 'mittel'),
|
||||||
'note' => $picture['note'],
|
'note' => $picture['note'],
|
||||||
'own' => false,
|
'own' => false,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use Filament\Forms\Components\Slider;
|
||||||
|
use Filament\Schemas\Components\StateCasts\Contracts\StateCast;
|
||||||
|
use Filament\Schemas\Components\StateCasts\SliderStateCast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regler für Bildfokus und Zoom (ImageFraming). Filaments Regler macht beim Laden aus „kein Wert“ eine 0; der Dialog
|
||||||
|
* zeigte dann bei jedem Widget ohne gespeicherten Ausschnitt „0“ statt der Vorgabe, mit der die Seite tatsächlich
|
||||||
|
* dargestellt wird (Mitte, 100 %). Ohne diese Umwandlung setzt der Regler beim Laden die Vorgabe selbst.
|
||||||
|
*/
|
||||||
|
class FramingSlider extends Slider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return array<StateCast>
|
||||||
|
*/
|
||||||
|
public function getDefaultStateCasts(): array
|
||||||
|
{
|
||||||
|
return array_values(array_filter(
|
||||||
|
parent::getDefaultStateCasts(),
|
||||||
|
fn (object $cast): bool => ! $cast instanceof SliderStateCast,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -553,7 +553,7 @@ private function card(ContentElement $element, array $portrait, array $uses, arr
|
|||||||
'description' => $description === '' ? null : $description,
|
'description' => $description === '' ? null : $description,
|
||||||
'usageNote' => $usageNote === '' ? null : $usageNote,
|
'usageNote' => $usageNote === '' ? null : $usageNote,
|
||||||
'licenseNote' => $licenseNote === '' ? null : $licenseNote,
|
'licenseNote' => $licenseNote === '' ? null : $licenseNote,
|
||||||
'image' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
'image' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at),
|
||||||
'imageAlt' => trim((string) ($element->thumbnail_alt ?: $element->working_title)),
|
'imageAlt' => trim((string) ($element->thumbnail_alt ?: $element->working_title)),
|
||||||
'imageNote' => $this->imageNote($element),
|
'imageNote' => $this->imageNote($element),
|
||||||
'presentation' => $this->isPresentationMedium($element, $portrait['versionCount']),
|
'presentation' => $this->isPresentationMedium($element, $portrait['versionCount']),
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public static function make(string $name, ?string $label = null, bool $live = tr
|
|||||||
if ($website) {
|
if ($website) {
|
||||||
// Interne Seite oder Sprungmarke verlinken, gleich neben dem freien Link.
|
// Interne Seite oder Sprungmarke verlinken, gleich neben dem freien Link.
|
||||||
$toolbar[0] = [...$toolbar[0], 'interneSeite'];
|
$toolbar[0] = [...$toolbar[0], 'interneSeite'];
|
||||||
array_splice($toolbar, 1, 0, [['fontSize', 'textColor'], ['alignStart', 'alignCenter', 'alignEnd']]);
|
array_splice($toolbar, 1, 0, [['fontSize', 'textColor'], ['alignStart', 'alignCenter', 'alignEnd'], ['absatzSymbol', 'listenStil']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($images) {
|
if ($images) {
|
||||||
@@ -47,7 +47,7 @@ public static function make(string $name, ?string $label = null, bool $live = tr
|
|||||||
|
|
||||||
if ($website) {
|
if ($website) {
|
||||||
$field
|
$field
|
||||||
->plugins([new FontSizePlugin, new InternalLinkPlugin])
|
->plugins([new FontSizePlugin, new InternalLinkPlugin, new TextMarksPlugin])
|
||||||
->textColors(Arr::mapWithKeys(
|
->textColors(Arr::mapWithKeys(
|
||||||
FormattedText::SITE_COLORS,
|
FormattedText::SITE_COLORS,
|
||||||
fn (string $label, string $key): array => [$key => TextColor::make($label, self::SITE_COLOR_VALUES[$key])],
|
fn (string $label, string $key): array => [$key => TextColor::make($label, self::SITE_COLOR_VALUES[$key])],
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
use App\Domain\Cms\Sections\SectionStyle;
|
use App\Domain\Cms\Sections\SectionStyle;
|
||||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||||
|
use App\Domain\Design\DesignPalette;
|
||||||
|
use Closure;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\Hidden;
|
use Filament\Forms\Components\Hidden;
|
||||||
use Filament\Forms\Components\Repeater;
|
use Filament\Forms\Components\Repeater;
|
||||||
@@ -19,6 +21,8 @@
|
|||||||
use Filament\Schemas\Components\Section;
|
use Filament\Schemas\Components\Section;
|
||||||
use Filament\Schemas\Components\Utilities\Get;
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
use Filament\Schemas\Components\Utilities\Set;
|
use Filament\Schemas\Components\Utilities\Set;
|
||||||
|
use Filament\Schemas\Components\View;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
@@ -70,6 +74,11 @@ public static function repeater(string $name = 'sections'): Repeater
|
|||||||
->moveDownAction(fn (Action $action): Action => $action->label('Abschnitt nach unten')->tooltip('Abschnitt nach unten'))
|
->moveDownAction(fn (Action $action): Action => $action->label('Abschnitt nach unten')->tooltip('Abschnitt nach unten'))
|
||||||
->reorderAction(fn (Action $action): Action => $action->label('Abschnitt ziehen')->tooltip('Abschnitt ziehen'))
|
->reorderAction(fn (Action $action): Action => $action->label('Abschnitt ziehen')->tooltip('Abschnitt ziehen'))
|
||||||
->extraItemActions([
|
->extraItemActions([
|
||||||
|
// Name, Sprungmarke und Sichtbarkeit: im Dialog statt als Eingabeblock in jedem Abschnitt.
|
||||||
|
self::settingsAction(),
|
||||||
|
// Auf eine andere Seite kopieren oder verschieben (Dialog mit Zielseite und Position).
|
||||||
|
SectionTransferActions::copy(),
|
||||||
|
SectionTransferActions::move(),
|
||||||
// Seiten-Arbeitsplatz (EditPage): Raster und Gestaltung im eigenen Kontext statt an jedem Abschnitt.
|
// Seiten-Arbeitsplatz (EditPage): Raster und Gestaltung im eigenen Kontext statt an jedem Abschnitt.
|
||||||
Action::make('gestalten')
|
Action::make('gestalten')
|
||||||
->label('Abschnitt gestalten')
|
->label('Abschnitt gestalten')
|
||||||
@@ -93,7 +102,11 @@ private static function sectionSchema(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Hidden::make('id'),
|
Hidden::make('id'),
|
||||||
self::labelSection(),
|
// Name, Sprungmarke und Sichtbarkeit werden im Einstellungsdialog geändert; der Zustand bleibt am Abschnitt.
|
||||||
|
Hidden::make('name'),
|
||||||
|
Hidden::make('anchor'),
|
||||||
|
Hidden::make('hidden'),
|
||||||
|
View::make('filament.cms.abschnitt-meldung')->columnSpanFull(),
|
||||||
// Abschnittsgestaltung in drei Gruppen. Im Seiten-Arbeitsplatz nur im Kontext „Abschnitt gestalten“
|
// Abschnittsgestaltung in drei Gruppen. Im Seiten-Arbeitsplatz nur im Kontext „Abschnitt gestalten“
|
||||||
// sichtbar und dort offen; beim Anlegen einer Seite an jedem Abschnitt, eingeklappt.
|
// sichtbar und dort offen; beim Anlegen einer Seite an jedem Abschnitt, eingeklappt.
|
||||||
Section::make('Raster und Breite')
|
Section::make('Raster und Breite')
|
||||||
@@ -136,6 +149,15 @@ private static function sectionSchema(): array
|
|||||||
->schema([
|
->schema([
|
||||||
Group::make(self::spacingFields())->statePath('style')->columns(['default' => 1, 'md' => 2]),
|
Group::make(self::spacingFields())->statePath('style')->columns(['default' => 1, 'md' => 2]),
|
||||||
]),
|
]),
|
||||||
|
Section::make('Karten')
|
||||||
|
->description('Gilt für alle Karten dieses Abschnitts (Karten, Programm-, Modul-, Medien- und Themenkarten).')
|
||||||
|
->extraAttributes(['class' => 'luf-nur-gestalten luf-gestaltung'])
|
||||||
|
->collapsible(fn ($livewire): bool => ! self::onWorkplace($livewire))
|
||||||
|
->collapsed(fn ($livewire): bool => ! self::onWorkplace($livewire))
|
||||||
|
->compact()
|
||||||
|
->schema([
|
||||||
|
Group::make(self::cardFields())->statePath('style')->columns(['default' => 1, 'md' => 2]),
|
||||||
|
]),
|
||||||
Repeater::make('slots')
|
Repeater::make('slots')
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
->label('Plätze im Raster')
|
->label('Plätze im Raster')
|
||||||
@@ -150,57 +172,162 @@ private static function sectionSchema(): array
|
|||||||
->reorderAction(fn (Action $action): Action => $action->label('Baustein auf einen anderen Platz ziehen')->tooltip('Baustein auf einen anderen Platz ziehen'))
|
->reorderAction(fn (Action $action): Action => $action->label('Baustein auf einen anderen Platz ziehen')->tooltip('Baustein auf einen anderen Platz ziehen'))
|
||||||
->itemLabel(fn (array $state, ?int $index, Get $get): HtmlString => self::slotLabel($state, $index, $get('layout')))
|
->itemLabel(fn (array $state, ?int $index, Get $get): HtmlString => self::slotLabel($state, $index, $get('layout')))
|
||||||
->default(fn (): array => self::arrangeSlots([], SectionLayouts::DEFAULT))
|
->default(fn (): array => self::arrangeSlots([], SectionLayouts::DEFAULT))
|
||||||
->extraAttributes(fn (Get $get): array => [
|
->extraAttributes(function (Get $get): array {
|
||||||
'class' => 'luf-slots',
|
// Die eingestellte Hintergrundfarbe steht schon im Seitenaufbau hinter den Plätzen (nur bei eigener Fläche).
|
||||||
'style' => '--luf-slot-cols: '.self::editorColumns($get('layout')),
|
$style = $get('style');
|
||||||
]),
|
$surface = SectionSurface::css(is_array($style) ? $style : []);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'class' => 'luf-slots'.($surface !== '' ? ' luf-flaeche' : ''),
|
||||||
|
'style' => '--luf-slot-cols: '.self::editorColumns($get('layout')).($surface !== '' ? '; '.$surface : ''),
|
||||||
|
];
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name, Sprungmarke und Sichtbarkeit: stehen im Seitenaufbau am Abschnitt, damit man sie beim Ordnen der Seite sieht.
|
* Einstellungsdialog des Abschnitts: Name, Sprungmarke und Sichtbarkeit. „Übernehmen“ ändert nur den Seitenentwurf
|
||||||
|
* (gespeichert wird mit „Entwurf speichern“); Abbrechen, Schließen und Esc verwerfen die Eingaben des Dialogs.
|
||||||
*/
|
*/
|
||||||
private static function labelSection(): Section
|
private static function settingsAction(): Action
|
||||||
{
|
{
|
||||||
return Section::make('Name, Sprungmarke und Sichtbarkeit')
|
return Action::make('einstellungen')
|
||||||
->columnSpanFull()
|
->label('Abschnitt-Einstellungen: Name, Sprungmarke und Sichtbarkeit')
|
||||||
->compact()
|
->tooltip('Name, Sprungmarke und Sichtbarkeit')
|
||||||
->collapsible()
|
->icon('heroicon-o-cog-6-tooth')
|
||||||
->collapsed(fn (Get $get): bool => blank($get('name')) && blank($get('anchor')) && ! $get('hidden'))
|
->iconButton()
|
||||||
->extraAttributes(['class' => 'luf-abschnitt-bezeichnung'])
|
->color('gray')
|
||||||
->schema([
|
->extraAttributes(['data-luf-einstellungen' => ''])
|
||||||
TextInput::make('name')
|
->modalWidth(Width::Large)
|
||||||
->label('Name des Abschnitts')
|
->modalHeading(fn (array $arguments, Repeater $component): string => 'Abschnitt '.self::position($component->getRawState(), (string) ($arguments['item'] ?? '')).': Einstellungen')
|
||||||
->placeholder('Zum Beispiel „Kursübersicht“')
|
->modalDescription('„Übernehmen“ ändert den Seitenentwurf; gespeichert wird mit „Entwurf speichern“. Abbrechen, Schließen und Esc verwerfen die Änderungen.')
|
||||||
->maxLength(PageSections::MAX_NAME)
|
->modalSubmitActionLabel('Übernehmen')
|
||||||
->live(onBlur: true)
|
->modalCancelActionLabel('Abbrechen')
|
||||||
->hintIcon('heroicon-m-information-circle', tooltip: 'Nur zur Orientierung im Seitenaufbau und in der Linkauswahl. Der Name erscheint nie auf der Website.')
|
->fillForm(fn (array $arguments, Repeater $component): array => self::settingsOf($component->getRawState(), (string) ($arguments['item'] ?? '')))
|
||||||
->hintColor('gray'),
|
->schema(fn (array $arguments, Repeater $component): array => self::settingsFields(self::otherAnchors($component->getRawState(), (string) ($arguments['item'] ?? ''))))
|
||||||
TextInput::make('anchor')
|
->action(function (array $data, array $arguments, Repeater $component): void {
|
||||||
->label('Sprungmarke')
|
$item = (string) ($arguments['item'] ?? '');
|
||||||
->prefix('#')
|
$state = $component->getRawState();
|
||||||
->placeholder('zum-beispiel-kurse')
|
|
||||||
->maxLength(PageSections::MAX_ANCHOR)
|
if (! is_array($state) || ! isset($state[$item]) || ! is_array($state[$item])) {
|
||||||
->live(onBlur: true)
|
return;
|
||||||
->afterStateUpdated(function (?string $state, Set $set): void {
|
}
|
||||||
$set('anchor', filled($state) ? Str::slug($state, '-', 'de') : null);
|
|
||||||
})
|
// Nur diese drei Angaben des Abschnitts ändern sich; Raster, Gestaltung und Bausteine bleiben unberührt.
|
||||||
->suffixAction(Action::make('anchorFromName')
|
$state[$item]['name'] = filled($data['name'] ?? null) ? trim((string) $data['name']) : null;
|
||||||
->label('Sprungmarke aus dem Namen vorschlagen')
|
$state[$item]['anchor'] = self::slugAnchor($data['anchor'] ?? null);
|
||||||
->icon('heroicon-o-sparkles')
|
$state[$item]['hidden'] = (bool) ($data['hidden'] ?? false);
|
||||||
->tooltip('Aus dem Namen vorschlagen')
|
|
||||||
->action(fn (Get $get, Set $set) => $set('anchor', Str::limit(Str::slug((string) $get('name'), '-', 'de'), PageSections::MAX_ANCHOR, ''))))
|
$component->rawState($state);
|
||||||
->hintIcon('heroicon-m-information-circle', tooltip: 'Macht den Abschnitt zum Ziel eines Links. Auf derselben Seite genügt „#marke“, von anderen Seiten und von außen „Adresse der Seite#marke“. Nur Kleinbuchstaben, Ziffern und Bindestriche; jede Marke einmal je Seite.')
|
$component->callAfterStateUpdated();
|
||||||
->hintColor('gray')
|
$livewire = $component->getLivewire();
|
||||||
->helperText(fn (Get $get, $livewire): ?string => self::anchorLinkText($get('anchor'), $livewire)),
|
|
||||||
Toggle::make('hidden')
|
// Nach einer Dialogaktion rendert Filament sonst nur den Dialog neu; Kopf und Zusammenfassung blieben alt.
|
||||||
->label('Auf der Website ausblenden')
|
if (method_exists($livewire, 'forceRender')) {
|
||||||
->live()
|
$livewire->forceRender();
|
||||||
->hintIcon('heroicon-m-information-circle', tooltip: 'Der Abschnitt bleibt im Entwurf erhalten, erscheint aber nicht auf der Website. Auch eine Sprungmarke dieses Abschnitts führt dann ins Leere. In der Seitenvorschau steht an seiner Stelle ein Hinweis.')
|
}
|
||||||
->hintColor('gray')
|
});
|
||||||
->columnSpanFull(),
|
}
|
||||||
])
|
|
||||||
->columns(['default' => 1, 'md' => 2]);
|
/**
|
||||||
|
* @return list<Hidden|TextInput|Toggle>
|
||||||
|
*/
|
||||||
|
private static function settingsFields(array $takenAnchors): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
TextInput::make('name')
|
||||||
|
->label('Name des Abschnitts')
|
||||||
|
->placeholder('Zum Beispiel „Kursübersicht“')
|
||||||
|
->maxLength(PageSections::MAX_NAME)
|
||||||
|
->autofocus()
|
||||||
|
->hintIcon('heroicon-m-information-circle', tooltip: 'Nur zur Orientierung im Seitenaufbau und in der Linkauswahl. Der Name erscheint nie auf der Website.')
|
||||||
|
->hintColor('gray'),
|
||||||
|
TextInput::make('anchor')
|
||||||
|
->label('Sprungmarke')
|
||||||
|
->prefix('#')
|
||||||
|
->placeholder('zum-beispiel-kurse')
|
||||||
|
->maxLength(PageSections::MAX_ANCHOR)
|
||||||
|
->live(onBlur: true)
|
||||||
|
->afterStateUpdated(function (?string $state, Set $set): void {
|
||||||
|
$set('anchor', filled($state) ? Str::slug($state, '-', 'de') : null);
|
||||||
|
})
|
||||||
|
->rules([
|
||||||
|
fn (): Closure => function (string $attribute, mixed $value, Closure $fail) use ($takenAnchors): void {
|
||||||
|
$problem = PageSections::anchorProblem((string) self::slugAnchor($value), $takenAnchors);
|
||||||
|
|
||||||
|
if ($problem !== null) {
|
||||||
|
$fail($problem);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
])
|
||||||
|
->suffixAction(Action::make('anchorFromName')
|
||||||
|
->label('Sprungmarke aus dem Namen vorschlagen')
|
||||||
|
->icon('heroicon-o-sparkles')
|
||||||
|
->tooltip('Aus dem Namen vorschlagen')
|
||||||
|
->action(fn (Get $get, Set $set) => $set('anchor', Str::limit(Str::slug((string) $get('name'), '-', 'de'), PageSections::MAX_ANCHOR, ''))))
|
||||||
|
->hintIcon('heroicon-m-information-circle', tooltip: 'Macht den Abschnitt zum Ziel eines Links. Auf derselben Seite genügt „#marke“, von anderen Seiten und von außen „Adresse der Seite#marke“. Nur Kleinbuchstaben, Ziffern und Bindestriche; jede Marke einmal je Seite.')
|
||||||
|
->hintColor('gray')
|
||||||
|
->helperText(fn (Get $get, $livewire): ?string => self::anchorLinkText($get('anchor'), $livewire)),
|
||||||
|
Toggle::make('hidden')
|
||||||
|
->label('Auf der Website ausblenden')
|
||||||
|
->hintIcon('heroicon-m-information-circle', tooltip: 'Der Abschnitt bleibt im Entwurf erhalten, erscheint aber nicht auf der Website. Auch eine Sprungmarke dieses Abschnitts führt dann ins Leere. In der Seitenvorschau steht an seiner Stelle ein Hinweis.')
|
||||||
|
->hintColor('gray'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sprungmarke in die zulässige Form bringen (wie beim Verlassen des Feldes); leer ergibt null.
|
||||||
|
*/
|
||||||
|
private static function slugAnchor(mixed $value): ?string
|
||||||
|
{
|
||||||
|
if (! is_string($value) || trim($value) === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$slug = Str::limit(Str::slug($value, '-', 'de'), PageSections::MAX_ANCHOR, '');
|
||||||
|
|
||||||
|
return $slug === '' ? null : $slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{name: ?string, anchor: ?string, hidden: bool}
|
||||||
|
*/
|
||||||
|
private static function settingsOf(mixed $state, string $item): array
|
||||||
|
{
|
||||||
|
$section = is_array($state) && is_array($state[$item] ?? null) ? $state[$item] : [];
|
||||||
|
|
||||||
|
return [
|
||||||
|
'name' => is_string($section['name'] ?? null) ? $section['name'] : null,
|
||||||
|
'anchor' => is_string($section['anchor'] ?? null) ? $section['anchor'] : null,
|
||||||
|
'hidden' => (bool) ($section['hidden'] ?? false),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sprungmarken der anderen Abschnitte (auch ungespeicherte): Eine Marke gibt es je Seite nur einmal.
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private static function otherAnchors(mixed $state, string $item): array
|
||||||
|
{
|
||||||
|
$anchors = [];
|
||||||
|
|
||||||
|
foreach (is_array($state) ? $state : [] as $key => $section) {
|
||||||
|
if ((string) $key === $item || ! is_array($section) || ! is_string($section['anchor'] ?? null) || trim($section['anchor']) === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$anchors[] = mb_strtolower(trim($section['anchor']));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $anchors;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function position(mixed $state, string $item): int
|
||||||
|
{
|
||||||
|
$index = array_search($item, array_map('strval', array_keys(is_array($state) ? $state : [])), true);
|
||||||
|
|
||||||
|
return $index === false ? 1 : $index + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -231,7 +358,7 @@ private static function widthField(): Select
|
|||||||
->options(SectionStyle::WIDTHS)
|
->options(SectionStyle::WIDTHS)
|
||||||
->default('standard')
|
->default('standard')
|
||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
->hintIcon('heroicon-o-question-mark-circle', 'Ein Hintergrund reicht immer über die ganze Bildschirmbreite.');
|
->hintIcon('heroicon-o-question-mark-circle', 'Breite des Inhalts. Wie breit die Fläche dahinter ist, steht unter „Hintergrund“ (Hintergrundbreite).');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -242,12 +369,18 @@ private static function widthField(): Select
|
|||||||
private static function backgroundFields(): array
|
private static function backgroundFields(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Select::make('background')
|
// Farbige Kacheln (Standard, Markenflächen, Farben der Palette, Hintergrundbild). Bei einer Palettenfarbe
|
||||||
->label('Hintergrund')
|
// schreibt die Kachel zusätzlich „palette_slot“.
|
||||||
->options(SectionStyle::BACKGROUNDS)
|
BackgroundField::make()->columnSpan(['default' => 1, 'md' => 2]),
|
||||||
->default('default')
|
Hidden::make('palette_slot'),
|
||||||
|
Select::make('background_width')
|
||||||
|
->label('Hintergrundbreite')
|
||||||
|
->options(SectionStyle::BACKGROUND_WIDTHS)
|
||||||
|
->default(SectionStyle::OPTIONAL['background_width'])
|
||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
->live(),
|
->hintIcon('heroicon-o-question-mark-circle', '„Volle Browserbreite“ färbt den Hintergrund über die ganze Bildschirmbreite; die Inhaltsbreite bleibt, wie sie unter „Raster und Breite“ gewählt ist. „Auf Abschnittsbreite begrenzt“ lässt den Hintergrund so breit wie den Abschnitt sein und zentriert ihn. Bei der Inhaltsbreite „Vollbreite“ gibt es keinen Unterschied.')
|
||||||
|
->visible(fn (Get $get): bool => $get('background') !== 'default')
|
||||||
|
->columnSpan(['default' => 1, 'md' => 2]),
|
||||||
...array_map(
|
...array_map(
|
||||||
fn ($field) => $field->visible(fn (Get $get): bool => $get('background') === 'image')->columnSpan(['default' => 1, 'md' => 2]),
|
fn ($field) => $field->visible(fn (Get $get): bool => $get('background') === 'image')->columnSpan(['default' => 1, 'md' => 2]),
|
||||||
ImageRefFields::fields('Hintergrundbild'),
|
ImageRefFields::fields('Hintergrundbild'),
|
||||||
@@ -269,6 +402,29 @@ private static function backgroundFields(): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Karten im Abschnitt: Höhe und Lage der Links.
|
||||||
|
*
|
||||||
|
* @return list<mixed>
|
||||||
|
*/
|
||||||
|
private static function cardFields(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Select::make('cards_height')
|
||||||
|
->label('Höhe der Karten')
|
||||||
|
->options(SectionStyle::CARD_HEIGHTS)
|
||||||
|
->default(SectionStyle::OPTIONAL['cards_height'])
|
||||||
|
->selectablePlaceholder(false)
|
||||||
|
->hintIcon('heroicon-o-question-mark-circle', '„Alle so hoch wie die größte Karte“: Karten nebeneinander und untereinander in diesem Abschnitt werden so hoch wie die höchste. Auf schmalen Bildschirmen, wo die Karten untereinander stehen, behalten sie ihre eigene Höhe.'),
|
||||||
|
Select::make('cards_links')
|
||||||
|
->label('Link in der Karte')
|
||||||
|
->options(SectionStyle::CARD_LINKS)
|
||||||
|
->default(SectionStyle::OPTIONAL['cards_links'])
|
||||||
|
->selectablePlaceholder(false)
|
||||||
|
->hintIcon('heroicon-o-question-mark-circle', 'Gilt für Karten mit eigenem Link („Mehr erfahren“, Schaltfläche). „Am unteren Rand“ macht die Karten einer Zeile gleich hoch und setzt die Links auf eine Linie am unteren Kartenrand. Links im Fließtext einer Karte bleiben, wo sie stehen.'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return list<mixed>
|
* @return list<mixed>
|
||||||
*/
|
*/
|
||||||
@@ -626,7 +782,9 @@ private static function sectionLabel(array $state, ?int $index): HtmlString
|
|||||||
$style = SectionStyle::fromStored(is_array($state['style'] ?? null) ? $state['style'] : []);
|
$style = SectionStyle::fromStored(is_array($state['style'] ?? null) ? $state['style'] : []);
|
||||||
$meta = ['Raster '.SectionLayouts::short($layout)];
|
$meta = ['Raster '.SectionLayouts::short($layout)];
|
||||||
if ($style['background'] !== 'default') {
|
if ($style['background'] !== 'default') {
|
||||||
$meta[] = SectionStyle::BACKGROUNDS[$style['background']] ?? $style['background'];
|
$meta[] = $style['background'] === 'palette'
|
||||||
|
? (DesignPalette::find($style['palette_slot'])['name'] ?? 'Farbe')
|
||||||
|
: (SectionStyle::BACKGROUNDS[$style['background']] ?? $style['background']);
|
||||||
}
|
}
|
||||||
if ($style['width'] !== 'standard') {
|
if ($style['width'] !== 'standard') {
|
||||||
$meta[] = SectionStyle::WIDTHS[$style['width']] ?? $style['width'];
|
$meta[] = SectionStyle::WIDTHS[$style['width']] ?? $style['width'];
|
||||||
@@ -655,6 +813,7 @@ private static function sectionLabel(array $state, ?int $index): HtmlString
|
|||||||
return new HtmlString('<span class="luf-abschnitt'.($hidden ? ' is-ausgeblendet' : '').'" title="'.e(($given !== null ? $number.' · ' : '').$full).'"><span class="luf-abschnitt-nr">'.e($text).'</span>'
|
return new HtmlString('<span class="luf-abschnitt'.($hidden ? ' is-ausgeblendet' : '').'" title="'.e(($given !== null ? $number.' · ' : '').$full).'"><span class="luf-abschnitt-nr">'.e($text).'</span>'
|
||||||
.($given !== null ? '<span class="luf-abschnitt-nummer" aria-hidden="true">'.e($number).'</span>' : '')
|
.($given !== null ? '<span class="luf-abschnitt-nummer" aria-hidden="true">'.e($number).'</span>' : '')
|
||||||
.$badges
|
.$badges
|
||||||
|
.SectionSurface::swatch(is_array($state['style'] ?? null) ? $state['style'] : [])
|
||||||
.'<span class="luf-abschnitt-meta" aria-hidden="true">'.e(implode(' · ', $meta)).'</span>'
|
.'<span class="luf-abschnitt-meta" aria-hidden="true">'.e(implode(' · ', $meta)).'</span>'
|
||||||
.'<span class="vw-sr">: '.e($spoken).'</span></span>');
|
.'<span class="vw-sr">: '.e($spoken).'</span></span>');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Sections\SectionStyle;
|
||||||
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
|
use App\Domain\Design\ColorContrast;
|
||||||
|
use App\Domain\Design\DesignPalette;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fläche eines Abschnitts für den Seitenaufbau im Editor: die eingestellte Hintergrundfarbe (feste Markenfläche, Farbe
|
||||||
|
* aus der Palette oder Hintergrundbild), damit sie schon in der Seitenübersicht sichtbar ist und nicht erst in der
|
||||||
|
* Vorschau. Reine Anzeige; die Ausgabe auf der Website steht im SectionRenderer.
|
||||||
|
*/
|
||||||
|
final class SectionSurface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $style Gestaltung des Abschnitts (roh oder gespeichert)
|
||||||
|
* @return array{kind: string, label: string, bg: ?string, fg: ?string, image: ?string, dark: bool}
|
||||||
|
*/
|
||||||
|
public static function of(array $style): array
|
||||||
|
{
|
||||||
|
$style = SectionStyle::fromStored($style);
|
||||||
|
$background = $style['background'];
|
||||||
|
|
||||||
|
if ($background === 'palette') {
|
||||||
|
$slot = DesignPalette::find($style['palette_slot']);
|
||||||
|
|
||||||
|
if ($slot !== null) {
|
||||||
|
return ['kind' => 'palette', 'label' => $slot['name'], 'bg' => $slot['bg'], 'fg' => $slot['fg'], 'image' => null, 'dark' => ColorContrast::isDarkSurface($slot['fg'], $slot['bg'])];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($background === 'image') {
|
||||||
|
// Vorschaubreite aus dem Medienmanager (auch ohne Website-Freigabe, wie die Seitenvorschau).
|
||||||
|
$url = $style['image'] === null ? null : app(WebsiteImage::class)->url($style['image'], true, 640);
|
||||||
|
|
||||||
|
return ['kind' => 'image', 'label' => SectionStyle::BACKGROUNDS['image'], 'bg' => null, 'fg' => null, 'image' => $url, 'dark' => $style['overlay'] === 'dark'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (DesignPalette::builtIns() as $built) {
|
||||||
|
if ($built['key'] === $background) {
|
||||||
|
return ['kind' => $background === 'default' ? 'default' : 'brand', 'label' => $built['label'], 'bg' => $built['bg'], 'fg' => $built['fg'], 'image' => null, 'dark' => ColorContrast::isDarkSurface($built['fg'], $built['bg'])];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['kind' => 'default', 'label' => SectionStyle::BACKGROUNDS['default'], 'bg' => '#ffffff', 'fg' => '#15243a', 'image' => null, 'dark' => false];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eigenschaften für den Platzbereich des Abschnitts. Leer bei „Standard“, damit sich dort nichts ändert.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $style
|
||||||
|
*/
|
||||||
|
public static function css(array $style): string
|
||||||
|
{
|
||||||
|
$surface = self::of($style);
|
||||||
|
|
||||||
|
if ($surface['kind'] === 'default') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($surface['kind'] === 'image') {
|
||||||
|
return $surface['image'] === null
|
||||||
|
? '--luf-fl-bg: #d9dee5'
|
||||||
|
: "--luf-fl-bg: #d9dee5; --luf-fl-img: url('".self::plain($surface['image'])."')";
|
||||||
|
}
|
||||||
|
|
||||||
|
return '--luf-fl-bg: '.$surface['bg'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Farbfeld im Abschnittskopf. Nur bei eigener Fläche; der Name der Fläche steht in der Kurzangabe daneben, das Feld
|
||||||
|
* ist daher nur Schmuck für Screenreader (aria-hidden) und im Titel benannt.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $style
|
||||||
|
*/
|
||||||
|
public static function swatch(array $style): string
|
||||||
|
{
|
||||||
|
$surface = self::of($style);
|
||||||
|
|
||||||
|
if ($surface['kind'] === 'default') {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$css = $surface['kind'] === 'image'
|
||||||
|
? 'background: #d9dee5'.($surface['image'] === null ? '' : " url('".self::plain($surface['image'])."') center / cover")
|
||||||
|
: 'background: '.$surface['bg'].'; color: '.$surface['fg'];
|
||||||
|
|
||||||
|
return '<span class="luf-abschnitt-flaeche" aria-hidden="true" title="Hintergrund: '.e($surface['label']).'" style="'.e($css).'">Aa</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Adresse ohne Zeichen, die einen CSS-Wert verlassen könnten. */
|
||||||
|
private static function plain(string $url): string
|
||||||
|
{
|
||||||
|
return preg_replace('/[\s"\'()\\\\]/', '', $url) ?? '';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Page;
|
||||||
|
use App\Domain\Cms\SectionTransfer;
|
||||||
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Forms\Components\Repeater;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
|
use Filament\Schemas\Components\Utilities\Set;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schalter im Abschnittskopf: Abschnitt auf eine andere Seite kopieren oder verschieben. Beide öffnen einen kleinen
|
||||||
|
* Dialog mit Zielseite und Position; die Arbeit erledigt EditPage::transferSection.
|
||||||
|
*/
|
||||||
|
class SectionTransferActions
|
||||||
|
{
|
||||||
|
public static function copy(): Action
|
||||||
|
{
|
||||||
|
return self::base('auf_seite_kopieren', false)
|
||||||
|
->label('Abschnitt auf eine andere Seite kopieren')
|
||||||
|
->tooltip('Auf andere Seite kopieren')
|
||||||
|
->icon('heroicon-o-document-plus')
|
||||||
|
->modalSubmitActionLabel('Kopieren')
|
||||||
|
->modalDescription('Der Abschnitt bleibt hier erhalten. Auf der Zielseite entsteht ein neuer Abschnitt mit gleichem Inhalt und gleichen Einstellungen. Die Zielseite erhält einen neuen Entwurf; veröffentlicht wird nichts.');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function move(): Action
|
||||||
|
{
|
||||||
|
return self::base('auf_seite_verschieben', true)
|
||||||
|
->label('Abschnitt auf eine andere Seite verschieben')
|
||||||
|
->tooltip('Auf andere Seite verschieben')
|
||||||
|
->icon('heroicon-o-arrow-right-circle')
|
||||||
|
->modalSubmitActionLabel('Verschieben')
|
||||||
|
->modalDescription('Der Abschnitt wird auf die Zielseite gesetzt und von dieser Seite entfernt. Beide Seiten werden als Entwurf gespeichert, auch übrige offene Änderungen dieser Seite. Veröffentlicht wird nichts.');
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function base(string $name, bool $move): Action
|
||||||
|
{
|
||||||
|
return Action::make($name)
|
||||||
|
->iconButton()
|
||||||
|
->color('gray')
|
||||||
|
->extraAttributes(['data-luf-uebertragen' => $move ? 'verschieben' : 'kopieren'])
|
||||||
|
->visible(fn ($livewire): bool => is_object($livewire) && method_exists($livewire, 'transferSection'))
|
||||||
|
->modalWidth(Width::Large)
|
||||||
|
->modalHeading(fn (array $arguments, Repeater $component): string => 'Abschnitt '.self::number($component, $arguments).($move ? ' auf eine andere Seite verschieben' : ' auf eine andere Seite kopieren'))
|
||||||
|
->modalCancelActionLabel('Abbrechen')
|
||||||
|
->schema(fn ($livewire): array => [
|
||||||
|
Select::make('page')
|
||||||
|
->label('Zielseite')
|
||||||
|
->placeholder('Seite wählen')
|
||||||
|
->options(fn (): array => self::pageOptions($livewire))
|
||||||
|
->searchable()
|
||||||
|
->required()
|
||||||
|
->live()
|
||||||
|
->afterStateUpdated(fn (Set $set) => $set('position', SectionTransfer::END)),
|
||||||
|
Select::make('position')
|
||||||
|
->label('Position auf der Zielseite')
|
||||||
|
->options(fn (Get $get): array => self::positionOptions($get('page')))
|
||||||
|
->default(SectionTransfer::END)
|
||||||
|
->selectablePlaceholder(false)
|
||||||
|
->required()
|
||||||
|
->disabled(fn (Get $get): bool => blank($get('page'))),
|
||||||
|
])
|
||||||
|
->action(function (array $data, array $arguments, Repeater $component) use ($move): void {
|
||||||
|
$component->getLivewire()->transferSection((string) ($arguments['item'] ?? ''), (int) ($data['page'] ?? 0), (string) ($data['position'] ?? SectionTransfer::END), $move);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seiten außer der geöffneten, nach Pfad; der Titel hilft beim Erkennen.
|
||||||
|
*
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
private static function pageOptions(mixed $livewire): array
|
||||||
|
{
|
||||||
|
$current = is_object($livewire) && is_object($livewire->record ?? null) ? $livewire->record->getKey() : null;
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
return Page::query()
|
||||||
|
->with(['latestRevision', 'publishedRevision'])
|
||||||
|
->when($current !== null, fn ($query) => $query->whereKeyNot($current))
|
||||||
|
->orderBy('path')
|
||||||
|
->get()
|
||||||
|
->filter(fn (Page $page): bool => $user?->can('update', $page) ?? false)
|
||||||
|
->mapWithKeys(function (Page $page): array {
|
||||||
|
$title = ($page->latestRevision ?? $page->publishedRevision)?->contentTitle();
|
||||||
|
|
||||||
|
return [$page->getKey() => $page->path.(filled($title) ? ' – '.$title : '')];
|
||||||
|
})
|
||||||
|
->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
private static function positionOptions(mixed $pageId): array
|
||||||
|
{
|
||||||
|
$page = filled($pageId) ? Page::query()->with(['latestRevision', 'publishedRevision'])->find($pageId) : null;
|
||||||
|
|
||||||
|
return $page === null ? [SectionTransfer::END => 'Am Ende der Seite'] : app(SectionTransfer::class)->positions($page);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function number(Repeater $component, array $arguments): int
|
||||||
|
{
|
||||||
|
$keys = array_map('strval', array_keys((array) $component->getRawState()));
|
||||||
|
$index = array_search((string) ($arguments['item'] ?? ''), $keys, true);
|
||||||
|
|
||||||
|
return $index === false ? 1 : $index + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,9 +3,9 @@
|
|||||||
namespace App\Filament\Support;
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
use App\Domain\Communication\FieldType;
|
use App\Domain\Communication\FieldType;
|
||||||
|
use App\Domain\Communication\FormEditor;
|
||||||
use App\Domain\Communication\FormTexts;
|
use App\Domain\Communication\FormTexts;
|
||||||
use App\Domain\Communication\InquiryField;
|
use App\Domain\Communication\InquiryField;
|
||||||
use App\Domain\Communication\InquiryFieldGroup;
|
|
||||||
use App\Domain\Communication\InquiryIssue;
|
use App\Domain\Communication\InquiryIssue;
|
||||||
use App\Domain\Communication\TemplateCompiler;
|
use App\Domain\Communication\TemplateCompiler;
|
||||||
use Filament\Forms\Components\Hidden;
|
use Filament\Forms\Components\Hidden;
|
||||||
@@ -13,84 +13,54 @@
|
|||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\Textarea;
|
use Filament\Forms\Components\Textarea;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Components\Toggle;
|
use Filament\Forms\Components\ViewField;
|
||||||
use Filament\Schemas\Components\Component;
|
use Filament\Schemas\Components\Component;
|
||||||
use Filament\Schemas\Components\Section;
|
use Filament\Schemas\Components\Section;
|
||||||
use Filament\Schemas\Components\Tabs;
|
use Filament\Schemas\Components\Tabs;
|
||||||
use Filament\Schemas\Components\Tabs\Tab;
|
use Filament\Schemas\Components\Tabs\Tab;
|
||||||
|
use Filament\Schemas\Components\Text;
|
||||||
use Filament\Schemas\Components\Utilities\Get;
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Formular der Anfragevorlage: Aufbau (Schritte, Feldgruppen, Einzelfelder), Regeln und Texte. Alles sind Auswahlfelder
|
* Formular-Editor (ADR-61): ein Formular wird an einer Stelle bearbeitet. Es besteht aus Bereichen (im mehrstufigen Dialog
|
||||||
* und Listen; es gibt keine freie Eingabe von Ausdrücken oder JSON. Die Auswahllisten der Regeln (Ziele, Quellen, Werte)
|
* je ein Schritt), darin Felder und Teilbereiche, Bedingungen direkt am Element. Felder werden hier angelegt und
|
||||||
* leiten sich aus dem gerade bearbeiteten Aufbau ab.
|
* geändert; sie landen im selben Katalog wie bisher (FormEditor). Die Regelliste bleibt für alles, was sich nicht an ein
|
||||||
|
* Element heften lässt. Alles sind Auswahlfelder und Listen; es gibt keine freie Eingabe von Ausdrücken oder JSON.
|
||||||
*/
|
*/
|
||||||
final class TemplateEditor
|
final class TemplateEditor
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @return list<Component>
|
* @return list<Component>
|
||||||
*/
|
*/
|
||||||
public static function schema(): array
|
public static function schema(?int $templateId = null): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
TextInput::make('name')->label('Bezeichnung der Vorlage')->required()->maxLength(120),
|
TextInput::make('name')->label('Name des Formulars')->required()->maxLength(120)
|
||||||
|
->helperText('So heißt das Formular in der Verwaltung und in der Auswahl des Widgets „Anfrage“.'),
|
||||||
Textarea::make('description')->label('Beschreibung (nur Verwaltung)')->rows(2)->maxLength(400),
|
Textarea::make('description')->label('Beschreibung (nur Verwaltung)')->rows(2)->maxLength(400),
|
||||||
Tabs::make('vorlage')->persistTabInQueryString('bereich')->tabs([
|
Tabs::make('vorlage')->persistTabInQueryString('bereich')->columnSpanFull()->tabs([
|
||||||
Tab::make('Aufbau')->icon('heroicon-o-queue-list')->schema(self::structure()),
|
Tab::make('Aufbau')->icon('heroicon-o-queue-list')->schema(self::structure($templateId)),
|
||||||
Tab::make('Regeln')->icon('heroicon-o-adjustments-horizontal')->schema(self::rules()),
|
|
||||||
Tab::make('Texte')->icon('heroicon-o-chat-bubble-bottom-center-text')->schema(self::texts()),
|
Tab::make('Texte')->icon('heroicon-o-chat-bubble-bottom-center-text')->schema(self::texts()),
|
||||||
|
Tab::make('Weitere Regeln')->icon('heroicon-o-adjustments-horizontal')->schema(self::rules()),
|
||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Der Aufbau ist eine eigene Formularansicht (resources/views/filament/communication/form-editor.blade.php). Sie führt
|
||||||
|
* den Baum aus Bereichen, Teilbereichen und Feldern im Browser und übergibt ihn beim Speichern als Text (editor_json);
|
||||||
|
* FormEditor prüft und speichert ihn.
|
||||||
|
*
|
||||||
* @return list<Component>
|
* @return list<Component>
|
||||||
*/
|
*/
|
||||||
private static function structure(): array
|
private static function structure(?int $templateId): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Select::make('draft.issues')->label('Unterstützte Anliegen')->multiple()->live()
|
ViewField::make('editor_json')
|
||||||
->options(fn (): array => InquiryIssue::query()->offered()->whereNull('parent_id')->orderBy('sort_order')->pluck('label', 'key')->all())
|
->hiddenLabel()
|
||||||
->helperText('Welche Anliegen diese Vorlage kennt. Leer: alle angebotenen. Ein Anfrage-Einstieg kann daraus weiter auswählen.'),
|
->view('filament.communication.form-editor')
|
||||||
Repeater::make('draft.steps')
|
->viewData(['config' => app(FormEditor::class)->clientConfig($templateId)])
|
||||||
->label('Schritte')
|
->columnSpanFull(),
|
||||||
->helperText('Jeder Schritt ist im mehrstufigen Dialog eine Seite. Im Kompaktformular stehen alle Schritte untereinander. Die Reihenfolge von oben nach unten ist die Reihenfolge der Fragen und zugleich die Reihenfolge, in der Bedingungen ausgewertet werden.')
|
|
||||||
->schema([
|
|
||||||
Hidden::make('key')->default(fn (): string => 's'.Str::lower(Str::random(6))),
|
|
||||||
TextInput::make('title')->label('Titel des Schritts')->required()->maxLength(120)->live(onBlur: true),
|
|
||||||
Textarea::make('intro')->label('Einleitung (optional)')->rows(2)->maxLength(600),
|
|
||||||
Repeater::make('items')
|
|
||||||
->label('Inhalt des Schritts')
|
|
||||||
->schema([
|
|
||||||
Select::make('kind')->label('Art')->required()->live()->options([
|
|
||||||
'issue' => 'Auswahl des Anliegens',
|
|
||||||
'group' => 'Feldgruppe',
|
|
||||||
'field' => 'Einzelnes Feld',
|
|
||||||
]),
|
|
||||||
Select::make('group')->label('Feldgruppe')->searchable()->live()
|
|
||||||
->options(fn (): array => InquiryFieldGroup::query()->offered()->orderBy('sort_order')->pluck('name', 'key')->all())
|
|
||||||
->visible(fn (Get $get): bool => $get('kind') === 'group')->required(fn (Get $get): bool => $get('kind') === 'group'),
|
|
||||||
Select::make('field')->label('Feld')->searchable()->live()
|
|
||||||
->options(fn (): array => InquiryField::query()->offered()->orderBy('name')->pluck('name', 'key')->all())
|
|
||||||
->visible(fn (Get $get): bool => $get('kind') === 'field')->required(fn (Get $get): bool => $get('kind') === 'field'),
|
|
||||||
Toggle::make('required')->label('Pflichtfeld')
|
|
||||||
->visible(fn (Get $get): bool => $get('kind') === 'field'),
|
|
||||||
])
|
|
||||||
->reorderableWithButtons()
|
|
||||||
->addActionLabel('Baustein hinzufügen')
|
|
||||||
->itemLabel(fn (array $state): string => match ($state['kind'] ?? null) {
|
|
||||||
'issue' => 'Auswahl des Anliegens',
|
|
||||||
'group' => 'Feldgruppe: '.(InquiryFieldGroup::query()->where('key', $state['group'] ?? '')->value('name') ?? '…'),
|
|
||||||
'field' => 'Feld: '.(InquiryField::query()->where('key', $state['field'] ?? '')->value('name') ?? '…'),
|
|
||||||
default => 'Neuer Baustein',
|
|
||||||
}),
|
|
||||||
])
|
|
||||||
->reorderableWithButtons()
|
|
||||||
->collapsible()
|
|
||||||
->addActionLabel('Schritt hinzufügen')
|
|
||||||
->live()
|
|
||||||
->itemLabel(fn (array $state): string => $state['title'] ?? 'Neuer Schritt'),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,32 +71,33 @@ private static function rules(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Section::make()->schema([
|
Section::make()->schema([
|
||||||
Repeater::make('draft.rules')
|
Text::make('Hier stehen Regeln, die sich nicht an ein einzelnes Feld oder einen Bereich heften lassen: weitere Regeln für dasselbe Ziel und Vorbelegungen. Bedingungen für ein Feld oder einen Bereich legst du direkt am Element an. Eine Bedingung darf nur auf Felder verweisen, die im Formular weiter oben stehen.'),
|
||||||
->label('Regeln')
|
Repeater::make('editor.rules')
|
||||||
->helperText('Eine Regel verändert ein Feld, eine Feldgruppe oder einen Schritt abhängig von Auswahlen davor. Bedingungen können nur auf Felder verweisen, die im Aufbau vor dem Ziel stehen; so entstehen keine Zirkelbezüge.')
|
->label('Weitere Regeln')
|
||||||
->schema([
|
->schema([
|
||||||
|
Hidden::make('pos'),
|
||||||
Select::make('effect')->label('Wirkung')->required()->live()->options(TemplateCompiler::EFFECTS),
|
Select::make('effect')->label('Wirkung')->required()->live()->options(TemplateCompiler::EFFECTS),
|
||||||
Select::make('target')->label('Ziel')->required()->live()->searchable()
|
Select::make('target')->label('Ziel')->required()->live()->searchable()
|
||||||
->options(fn ($livewire, Get $get): array => self::targets((array) ($livewire->data['draft'] ?? []), (string) $get('effect'))),
|
->options(fn ($livewire, Get $get): array => self::targets(self::flat($livewire), (string) $get('effect'))),
|
||||||
Select::make('value')->label('Vorbelegen mit')->live()
|
Select::make('value')->label('Vorbelegen mit')->live()
|
||||||
->options(fn ($livewire, Get $get): array => self::targetValues((array) ($livewire->data['draft'] ?? []), (string) $get('target')))
|
->options(fn (Get $get): array => str_starts_with((string) $get('target'), 'field:') ? self::fieldValues(substr((string) $get('target'), 6)) : [])
|
||||||
->visible(fn (Get $get): bool => $get('effect') === 'preset')->required(fn (Get $get): bool => $get('effect') === 'preset'),
|
->visible(fn (Get $get): bool => $get('effect') === 'preset')->required(fn (Get $get): bool => $get('effect') === 'preset'),
|
||||||
Select::make('match')->label('Es müssen zutreffen')->options(['all' => 'alle Bedingungen', 'any' => 'mindestens eine Bedingung'])->default('all')->required(),
|
Select::make('match')->label('Es müssen zutreffen')->options(['all' => 'alle Bedingungen', 'any' => 'mindestens eine Bedingung'])->default('all')->required(),
|
||||||
Repeater::make('conditions')
|
Repeater::make('conditions')
|
||||||
->label('Bedingungen')
|
->label('Bedingungen')
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('source')->label('Wenn …')->required()->live()->searchable()
|
Select::make('source')->label('Wenn …')->required()->live()->searchable()
|
||||||
->options(fn ($livewire): array => self::sources((array) ($livewire->data['draft'] ?? []))),
|
->options(fn ($livewire): array => self::sources(self::flat($livewire))),
|
||||||
Select::make('op')->label('Vergleich')->required()->options(TemplateCompiler::OPERATORS)->default('eq')->live(),
|
Select::make('op')->label('Vergleich')->required()->options(TemplateCompiler::OPERATORS)->default('eq')->live(),
|
||||||
Select::make('values')->label('Wert')->required()->multiple()
|
Select::make('values')->label('Wert')->required()->multiple()
|
||||||
->options(fn ($livewire, Get $get): array => self::sourceValues((array) ($livewire->data['draft'] ?? []), (string) $get('source'))),
|
->options(fn ($livewire, Get $get): array => self::sourceValues(self::flat($livewire), (string) $get('source'))),
|
||||||
])
|
])
|
||||||
->minItems(1)
|
->minItems(1)
|
||||||
->addActionLabel('Bedingung hinzufügen'),
|
->addActionLabel('Bedingung hinzufügen'),
|
||||||
])
|
])
|
||||||
->collapsible()
|
->collapsible()
|
||||||
->addActionLabel('Regel hinzufügen')
|
->addActionLabel('Regel hinzufügen')
|
||||||
->itemLabel(fn (array $state, $livewire): string => (TemplateCompiler::EFFECTS[$state['effect'] ?? ''] ?? 'Neue Regel').(($state['target'] ?? null) ? ' → '.self::targetName((string) $state['target'], (array) ($livewire->data['draft'] ?? [])) : '')),
|
->itemLabel(fn (array $state, $livewire): string => (TemplateCompiler::EFFECTS[$state['effect'] ?? ''] ?? 'Neue Regel').(($state['target'] ?? null) ? ' → '.self::targetName((string) $state['target'], self::flat($livewire)) : '')),
|
||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -148,68 +119,76 @@ private static function texts(): array
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
Section::make('Texte des Formulars')
|
Section::make('Texte des Formulars')
|
||||||
->description('Alle Texte des Formulars werden hier und in den Anfrage-Einstiegen gepflegt, nie im CMS. Leer lassen: es gilt der grau angezeigte Standardtext. Ein Anfrage-Einstieg kann einzelne Texte überschreiben.')
|
->description('Alle Texte des Formulars werden hier gepflegt, nie im CMS. Leer lassen: es gilt der grau angezeigte Standardtext.')
|
||||||
->schema($fields),
|
->schema($fields),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Felder des Entwurfs in Reihenfolge: [Schlüssel => Name], dazu die Bausteine, aus denen sie stammen.
|
* Der aktuelle Aufbau in der flachen Ansicht (Bereiche, Felder, Teilbereiche, Ende-Markierungen), aus dem Text der Formularansicht.
|
||||||
*
|
*
|
||||||
* @param array<string, mixed> $draft
|
* @return array<string, mixed>
|
||||||
* @return array{steps: array<string, string>, groups: array<string, string>, fields: array<string, string>, hasIssue: bool}
|
|
||||||
*/
|
*/
|
||||||
private static function inventory(array $draft): array
|
private static function flat(mixed $livewire): array
|
||||||
|
{
|
||||||
|
$tree = json_decode((string) ($livewire->data['editor_json'] ?? ''), true);
|
||||||
|
|
||||||
|
return FormEditor::fromTree(is_array($tree) ? $tree : []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inhalt des Formulars in Reihenfolge: Bereiche, Teilbereiche, Felder, und ob die Frage nach dem Anliegen vorkommt.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $editor
|
||||||
|
* @return array{steps: array<string, string>, groups: array<string, string>, fields: array<string, string>, hasIssue: bool, issues: list<string>}
|
||||||
|
*/
|
||||||
|
private static function inventory(array $editor): array
|
||||||
{
|
{
|
||||||
$steps = [];
|
$steps = [];
|
||||||
$groups = [];
|
$groups = [];
|
||||||
$fields = [];
|
$fields = [];
|
||||||
$hasIssue = false;
|
$hasIssue = false;
|
||||||
$names = InquiryField::query()->pluck('name', 'key')->all();
|
$issues = [];
|
||||||
$groupNames = InquiryFieldGroup::query()->get()->keyBy('key');
|
|
||||||
|
|
||||||
foreach (array_values((array) ($draft['steps'] ?? [])) as $step) {
|
foreach (array_values((array) ($editor['areas'] ?? [])) as $area) {
|
||||||
$key = (string) ($step['key'] ?? '');
|
$key = (string) ($area['key'] ?? '');
|
||||||
|
|
||||||
if ($key !== '') {
|
if ($key !== '') {
|
||||||
$steps[$key] = (string) (($step['title'] ?? '') ?: 'Schritt');
|
$steps[$key] = (string) (($area['title'] ?? '') ?: 'Bereich');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (array_values((array) ($step['items'] ?? [])) as $item) {
|
foreach (array_values((array) ($area['items'] ?? [])) as $block) {
|
||||||
$kind = $item['kind'] ?? null;
|
$data = (array) ($block['data'] ?? []);
|
||||||
|
$type = $block['type'] ?? null;
|
||||||
|
|
||||||
if ($kind === 'issue') {
|
if ($type === 'issue') {
|
||||||
$hasIssue = true;
|
$hasIssue = true;
|
||||||
} elseif ($kind === 'group' && isset($groupNames[$item['group'] ?? ''])) {
|
$issues = array_values(array_filter((array) ($data['issues'] ?? []), 'is_string'));
|
||||||
$group = $groupNames[$item['group']];
|
} elseif ($type === 'section' && filled($data['key'] ?? null)) {
|
||||||
$groups[$group->key] = $group->name;
|
$groups[(string) $data['key']] = (string) (($data['label'] ?? '') ?: 'Teilbereich');
|
||||||
|
} elseif ($type === 'field' && filled($data['key'] ?? null)) {
|
||||||
foreach ($group->itemList() as $row) {
|
$fields[(string) $data['key']] = (string) (($data['label'] ?? '') ?: 'Feld');
|
||||||
$fields[$row['field']] = (string) ($names[$row['field']] ?? $row['field']);
|
|
||||||
}
|
|
||||||
} elseif ($kind === 'field' && filled($item['field'] ?? null)) {
|
|
||||||
$fields[$item['field']] = (string) ($names[$item['field']] ?? $item['field']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['steps' => $steps, 'groups' => $groups, 'fields' => $fields, 'hasIssue' => $hasIssue];
|
return ['steps' => $steps, 'groups' => $groups, 'fields' => $fields, 'hasIssue' => $hasIssue, 'issues' => $issues];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $draft
|
* @param array<string, mixed> $editor
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
private static function targets(array $draft, string $effect): array
|
private static function targets(array $editor, string $effect): array
|
||||||
{
|
{
|
||||||
$inventory = self::inventory($draft);
|
$inventory = self::inventory($editor);
|
||||||
$steps = [];
|
$steps = [];
|
||||||
foreach ($inventory['steps'] as $key => $title) {
|
foreach ($inventory['steps'] as $key => $title) {
|
||||||
$steps["step:$key"] = 'Schritt: '.$title;
|
$steps["step:$key"] = 'Bereich: '.$title;
|
||||||
}
|
}
|
||||||
$groups = [];
|
$groups = [];
|
||||||
foreach ($inventory['groups'] as $key => $name) {
|
foreach ($inventory['groups'] as $key => $name) {
|
||||||
$groups["group:$key"] = 'Feldgruppe: '.$name;
|
$groups["group:$key"] = 'Teilbereich: '.$name;
|
||||||
}
|
}
|
||||||
$fields = [];
|
$fields = [];
|
||||||
foreach ($inventory['fields'] as $key => $name) {
|
foreach ($inventory['fields'] as $key => $name) {
|
||||||
@@ -219,47 +198,49 @@ private static function targets(array $draft, string $effect): array
|
|||||||
return match ($effect) {
|
return match ($effect) {
|
||||||
'skip' => $steps,
|
'skip' => $steps,
|
||||||
'require', 'preset' => $fields,
|
'require', 'preset' => $fields,
|
||||||
'show', 'hide' => ['Feldgruppen' => $groups, 'Felder' => $fields],
|
default => ['Bereiche' => $steps, 'Teilbereiche' => $groups, 'Felder' => $fields],
|
||||||
default => ['Schritte' => $steps, 'Feldgruppen' => $groups, 'Felder' => $fields],
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $draft
|
* @param array<string, mixed> $editor
|
||||||
*/
|
*/
|
||||||
private static function targetName(string $target, array $draft = []): string
|
private static function targetName(string $target, array $editor = []): string
|
||||||
{
|
{
|
||||||
[$kind, $key] = array_pad(explode(':', $target, 2), 2, '');
|
[$kind, $key] = array_pad(explode(':', $target, 2), 2, '');
|
||||||
|
$inventory = self::inventory($editor);
|
||||||
|
|
||||||
return match ($kind) {
|
return match ($kind) {
|
||||||
'step' => (string) (self::inventory($draft)['steps'][$key] ?? $key),
|
'step' => (string) ($inventory['steps'][$key] ?? $key),
|
||||||
'field' => (string) (InquiryField::query()->where('key', $key)->value('name') ?? $key),
|
'field' => (string) ($inventory['fields'][$key] ?? InquiryField::query()->where('key', $key)->value('name') ?? $key),
|
||||||
'group' => (string) (InquiryFieldGroup::query()->where('key', $key)->value('name') ?? $key),
|
'group' => (string) ($inventory['groups'][$key] ?? $key),
|
||||||
default => $key,
|
default => $key,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Felder, auf deren Wert sich eine Bedingung stützen darf.
|
* Felder, auf deren Wert sich eine Bedingung stützen darf: gespeicherte Auswahlfelder und Ja/Nein-Felder. Mit
|
||||||
|
* Zustandspfad der Bedingung nur Felder, die im Formular davor stehen (sonst lehnt die Prüfung die Regel ab).
|
||||||
*
|
*
|
||||||
* @param array<string, mixed> $draft
|
* @param array<string, mixed> $editor
|
||||||
* @return array<string, string>
|
* @return array<string, string>
|
||||||
*/
|
*/
|
||||||
private static function sources(array $draft): array
|
private static function sources(array $editor): array
|
||||||
{
|
{
|
||||||
$inventory = self::inventory($draft);
|
$catalog = InquiryField::query()->get()->keyBy('key');
|
||||||
$sources = [];
|
$sources = [];
|
||||||
|
|
||||||
if ($inventory['hasIssue']) {
|
foreach ((array) ($editor['areas'] ?? []) as $area) {
|
||||||
$sources['anliegen'] = 'Anliegen';
|
foreach ((array) ($area['items'] ?? []) as $block) {
|
||||||
$sources['unteranliegen'] = 'Unteranliegen';
|
$data = (array) ($block['data'] ?? []);
|
||||||
}
|
$key = (string) ($data['key'] ?? '');
|
||||||
|
|
||||||
$catalog = InquiryField::query()->whereIn('key', array_keys($inventory['fields']))->get()->keyBy('key');
|
if (($block['type'] ?? null) === 'issue') {
|
||||||
|
$sources['anliegen'] = 'Anliegen';
|
||||||
foreach ($inventory['fields'] as $key => $name) {
|
$sources['unteranliegen'] = 'Unteranliegen';
|
||||||
if (isset($catalog[$key]) && $catalog[$key]->type->canControl()) {
|
} elseif (($block['type'] ?? null) === 'field' && isset($catalog[$key]) && $catalog[$key]->type->canControl()) {
|
||||||
$sources[$key] = $name;
|
$sources[$key] = (string) (($data['label'] ?? '') ?: $catalog[$key]->label);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,13 +248,13 @@ private static function sources(array $draft): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $draft
|
* @param array<string, mixed> $editor
|
||||||
* @return array<string, string>
|
* @return array<string, string>
|
||||||
*/
|
*/
|
||||||
private static function sourceValues(array $draft, string $source): array
|
private static function sourceValues(array $editor, string $source): array
|
||||||
{
|
{
|
||||||
if ($source === 'anliegen' || $source === 'unteranliegen') {
|
if ($source === 'anliegen' || $source === 'unteranliegen') {
|
||||||
$only = array_values(array_filter((array) ($draft['issues'] ?? []), 'is_string'));
|
$only = self::inventory($editor)['issues'];
|
||||||
$options = [];
|
$options = [];
|
||||||
|
|
||||||
foreach (InquiryIssue::tree() as $issue) {
|
foreach (InquiryIssue::tree() as $issue) {
|
||||||
@@ -298,15 +279,6 @@ private static function sourceValues(array $draft, string $source): array
|
|||||||
return self::fieldValues($source);
|
return self::fieldValues($source);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array<string, mixed> $draft
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
private static function targetValues(array $draft, string $target): array
|
|
||||||
{
|
|
||||||
return str_starts_with($target, 'field:') ? self::fieldValues(substr($target, 6)) : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string, string>
|
* @return array<string, string>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,163 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Widgets\Support\TextMarkers;
|
||||||
|
use App\Filament\Support\TipTap\TextMarksExtension;
|
||||||
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Forms\Components\RichEditor;
|
||||||
|
use Filament\Forms\Components\RichEditor\EditorCommand;
|
||||||
|
use Filament\Forms\Components\RichEditor\Plugins\Contracts\RichContentPlugin;
|
||||||
|
use Filament\Forms\Components\RichEditor\RichEditorTool;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
|
use Filament\Schemas\Components\Utilities\Set;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zeichen im Text der Website (ADR-69): zwei Werkzeuge für den Editor.
|
||||||
|
*
|
||||||
|
* - „Symbol vor dem Absatz“: Jeder Absatz auf der obersten Ebene des Texts kann sein eigenes Symbol aus der Symbolbibliothek
|
||||||
|
* tragen. Es steht herausgestellt vor dem Absatz.
|
||||||
|
* - „Listenstil“: Nummerierung mit Zahlen im Kreis (Farbe aus der Palette oder Markenfarbe), Aufzählung mit Symbol statt Punkt.
|
||||||
|
*
|
||||||
|
* Der Editor führt nur Schlüssel; Bild und Farbe setzt die Ausgabe ein ({@see TextMarkers::decorate()}). Gegenstück im
|
||||||
|
* Browser: `public/js/rich-text-marks.js`.
|
||||||
|
*/
|
||||||
|
final class TextMarksPlugin implements RichContentPlugin
|
||||||
|
{
|
||||||
|
private const SCRIPT = 'js/rich-text-marks.js';
|
||||||
|
|
||||||
|
public function getTipTapPhpExtensions(): array
|
||||||
|
{
|
||||||
|
return [new TextMarksExtension];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTipTapJsExtensions(): array
|
||||||
|
{
|
||||||
|
$file = public_path(self::SCRIPT);
|
||||||
|
|
||||||
|
// Die Prüfsumme in der Adresse lässt den Browser eine geänderte Fassung sofort laden.
|
||||||
|
return [asset(self::SCRIPT).(is_file($file) ? '?v='.substr((string) md5_file($file), 0, 10) : '')];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEditorTools(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
RichEditorTool::make('absatzSymbol')
|
||||||
|
->label('Symbol vor dem Absatz')
|
||||||
|
->icon(Heroicon::Star)
|
||||||
|
->action(arguments: '{ symbol: $getEditor().getAttributes(\'paragraph\')[\'data-symbol\'] ?? null, nested: $getEditor().isActive(\'listItem\') || $getEditor().isActive(\'blockquote\') || $getEditor().isActive(\'tableCell\') || $getEditor().isActive(\'tableHeader\') }'),
|
||||||
|
RichEditorTool::make('listenStil')
|
||||||
|
->label('Listenstil: Zahlen im Kreis, Symbol statt Punkt')
|
||||||
|
->icon(Heroicon::ListBullet)
|
||||||
|
->action(arguments: '{ list: $getEditor().isActive(\'orderedList\') ? \'ol\' : ($getEditor().isActive(\'bulletList\') ? \'ul\' : null), marker: $getEditor().getAttributes($getEditor().isActive(\'orderedList\') ? \'orderedList\' : \'bulletList\')[\'data-marker\'] ?? null, symbol: $getEditor().getAttributes($getEditor().isActive(\'orderedList\') ? \'orderedList\' : \'bulletList\')[\'data-symbol\'] ?? null, tone: $getEditor().getAttributes($getEditor().isActive(\'orderedList\') ? \'orderedList\' : \'bulletList\')[\'data-tone\'] ?? null }'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEditorActions(): array
|
||||||
|
{
|
||||||
|
return [$this->paragraphAction(), $this->listAction()];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function paragraphAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('absatzSymbol')
|
||||||
|
->label('Symbol vor dem Absatz')
|
||||||
|
->modalHeading('Symbol vor dem Absatz')
|
||||||
|
->modalDescription('Das Symbol gilt für den Absatz, in dem der Cursor steht, und steht herausgestellt vor dem Text. Jeder Absatz kann ein anderes Symbol haben. Ein leeres Feld nimmt das Symbol zurück.')
|
||||||
|
->modalWidth(Width::ExtraLarge)
|
||||||
|
->modalSubmitActionLabel('Übernehmen')
|
||||||
|
->fillForm(fn (array $arguments): array => ['symbol' => TextMarkers::symbol($arguments['symbol'] ?? null)])
|
||||||
|
->schema([
|
||||||
|
SymbolField::make('symbol', 'Symbol'),
|
||||||
|
])
|
||||||
|
->action(function (array $arguments, array $data, RichEditor $component): void {
|
||||||
|
if (($arguments['nested'] ?? false) === true) {
|
||||||
|
Notification::make()->warning()->title('Kein Symbol an dieser Stelle')->body('Ein Symbol steht nur vor einem Absatz auf der obersten Ebene des Texts, nicht in einer Liste, einem Zitat oder einer Tabelle. In Listen gibt es den Listenstil.')->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$symbol = TextMarkers::symbol($data['symbol'] ?? null);
|
||||||
|
|
||||||
|
$component->runCommands(
|
||||||
|
[EditorCommand::make('updateAttributes', arguments: ['paragraph', ['data-symbol' => $symbol]])],
|
||||||
|
editorSelection: $arguments['editorSelection'],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function listAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('listenStil')
|
||||||
|
->label('Listenstil')
|
||||||
|
->modalHeading('Listenstil')
|
||||||
|
->modalDescription('Gilt für die Liste, in der der Cursor steht. Nummerierungen zeigen die Zahlen im farbigen Kreis, Aufzählungen ein Symbol statt des Punkts. Die Farben kommen aus der Palette.')
|
||||||
|
->modalWidth(Width::ExtraLarge)
|
||||||
|
->modalSubmitActionLabel('Übernehmen')
|
||||||
|
->fillForm(fn (array $arguments): array => [
|
||||||
|
'marker' => in_array($arguments['marker'] ?? null, [TextMarkers::MARKER_CIRCLE, TextMarkers::MARKER_SYMBOL], true) ? $arguments['marker'] : 'none',
|
||||||
|
'symbol' => TextMarkers::symbol($arguments['symbol'] ?? null),
|
||||||
|
'tone' => array_key_exists((string) ($arguments['tone'] ?? ''), TextMarkers::tones()) ? $arguments['tone'] : TextMarkers::DEFAULT_TONE,
|
||||||
|
])
|
||||||
|
->schema(fn (array $arguments): array => match ($arguments['list'] ?? null) {
|
||||||
|
'ol' => [
|
||||||
|
Select::make('marker')
|
||||||
|
->label('Nummern')
|
||||||
|
->options(['none' => 'Einfache Nummern', TextMarkers::MARKER_CIRCLE => 'Zahl im farbigen Kreis'])
|
||||||
|
->native(false)
|
||||||
|
->selectablePlaceholder(false)
|
||||||
|
->live()
|
||||||
|
->afterStateUpdated(fn (Set $set) => $set('tone', TextMarkers::DEFAULT_TONE)),
|
||||||
|
Select::make('tone')
|
||||||
|
->label('Farbe des Kreises')
|
||||||
|
->options(fn (): array => array_map(fn (array $tone): string => $tone['label'], TextMarkers::tones()))
|
||||||
|
->native(false)
|
||||||
|
->selectablePlaceholder(false)
|
||||||
|
->visible(fn (Get $get): bool => $get('marker') === TextMarkers::MARKER_CIRCLE)
|
||||||
|
->helperText('Hintergrund und Schrift des Kreises kommen aus der Farbe; die Farben der Palette pflegt der Systemverwalter unter Website → Design → Farben.'),
|
||||||
|
],
|
||||||
|
'ul' => [
|
||||||
|
Select::make('marker')
|
||||||
|
->label('Aufzählungszeichen')
|
||||||
|
->options(['none' => 'Punkt', TextMarkers::MARKER_SYMBOL => 'Symbol'])
|
||||||
|
->native(false)
|
||||||
|
->selectablePlaceholder(false)
|
||||||
|
->live(),
|
||||||
|
SymbolField::make('symbol', 'Symbol')
|
||||||
|
->visible(fn (Get $get): bool => $get('marker') === TextMarkers::MARKER_SYMBOL)
|
||||||
|
->required(fn (Get $get): bool => $get('marker') === TextMarkers::MARKER_SYMBOL),
|
||||||
|
],
|
||||||
|
default => [],
|
||||||
|
})
|
||||||
|
->action(function (array $arguments, array $data, RichEditor $component): void {
|
||||||
|
$list = $arguments['list'] ?? null;
|
||||||
|
|
||||||
|
if (! in_array($list, ['ol', 'ul'], true)) {
|
||||||
|
Notification::make()->warning()->title('Keine Liste')->body('Der Cursor steht in keiner Aufzählung oder Nummerierung.')->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$marker = $data['marker'] ?? 'none';
|
||||||
|
$circle = $list === 'ol' && $marker === TextMarkers::MARKER_CIRCLE;
|
||||||
|
$symbol = $list === 'ul' && $marker === TextMarkers::MARKER_SYMBOL ? TextMarkers::symbol($data['symbol'] ?? null) : null;
|
||||||
|
$tone = $circle && array_key_exists((string) ($data['tone'] ?? ''), TextMarkers::tones()) ? $data['tone'] : null;
|
||||||
|
|
||||||
|
$component->runCommands(
|
||||||
|
[EditorCommand::make('updateAttributes', arguments: [
|
||||||
|
$list === 'ol' ? 'orderedList' : 'bulletList',
|
||||||
|
[
|
||||||
|
'data-marker' => $circle ? TextMarkers::MARKER_CIRCLE : ($symbol !== null ? TextMarkers::MARKER_SYMBOL : null),
|
||||||
|
'data-symbol' => $symbol,
|
||||||
|
'data-tone' => $tone,
|
||||||
|
],
|
||||||
|
])],
|
||||||
|
editorSelection: $arguments['editorSelection'],
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support\TipTap;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Widgets\Support\TextMarkers;
|
||||||
|
use Tiptap\Core\Extension;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zeichen im Text der Website (ADR-69) als Attribute der Knoten: `data-symbol` am Absatz, `data-marker`, `data-symbol` und
|
||||||
|
* `data-tone` an Aufzählung und Nummerierung. Gegenstück zu `public/js/rich-text-marks.js`; der Editor führt den Wert beim
|
||||||
|
* Speichern durch dieses PHP-Modell, ein Attribut, das hier fehlt, ginge verloren. Welche Werte gelten, entscheidet
|
||||||
|
* {@see TextMarkers} beim Bereinigen.
|
||||||
|
*/
|
||||||
|
class TextMarksExtension extends Extension
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public static $name = 'textMarks';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function addGlobalAttributes()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['types' => ['paragraph'], 'attributes' => ['data-symbol' => self::attribute('data-symbol')]],
|
||||||
|
['types' => ['bulletList', 'orderedList'], 'attributes' => [
|
||||||
|
'data-marker' => self::attribute('data-marker'),
|
||||||
|
'data-symbol' => self::attribute('data-symbol'),
|
||||||
|
'data-tone' => self::attribute('data-tone'),
|
||||||
|
]],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private static function attribute(string $name): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'default' => null,
|
||||||
|
'parseHTML' => fn ($DOMNode) => $DOMNode->getAttribute($name) ?: null,
|
||||||
|
'renderHTML' => function ($attributes) use ($name) {
|
||||||
|
$value = is_array($attributes) ? ($attributes[$name] ?? null) : ($attributes->{$name} ?? null);
|
||||||
|
|
||||||
|
return $value === null || $value === '' ? null : [$name => $value];
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Domain\Cms\Sections\SectionLayouts;
|
use App\Domain\Cms\Sections\SectionLayouts;
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
|
use App\Domain\Cms\Widgets\Support\WidgetAppearance;
|
||||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||||
use App\Domain\Cms\Widgets\WidgetRenderer;
|
use App\Domain\Cms\Widgets\WidgetRenderer;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
@@ -152,7 +153,11 @@ public static function block(WidgetType $type): Block
|
|||||||
}
|
}
|
||||||
|
|
||||||
$options = $type->settingOptions();
|
$options = $type->settingOptions();
|
||||||
$labels = $type->settingLabels();
|
$labels = $type->settingLabels() + [
|
||||||
|
'heading_size' => WidgetAppearance::HEADING_LABEL,
|
||||||
|
'text_size' => WidgetAppearance::TEXT_LABEL,
|
||||||
|
'palette' => WidgetAppearance::PALETTE_LABEL,
|
||||||
|
];
|
||||||
$hiddenWhen = $type->settingHiddenWhen();
|
$hiddenWhen = $type->settingHiddenWhen();
|
||||||
|
|
||||||
$field = function (string $key) use ($options, $labels, $type, $icons, $hiddenWhen): Select|ToggleButtons|ViewField {
|
$field = function (string $key) use ($options, $labels, $type, $icons, $hiddenWhen): Select|ToggleButtons|ViewField {
|
||||||
@@ -171,7 +176,7 @@ public static function block(WidgetType $type): Block
|
|||||||
? SymbolField::make('symbol', $labels[$key][0] ?? 'Symbol')->live()->columnSpanFull()
|
? SymbolField::make('symbol', $labels[$key][0] ?? 'Symbol')->live()->columnSpanFull()
|
||||||
: Select::make($key)
|
: Select::make($key)
|
||||||
->label($labels[$key][0] ?? Str::headline($key))
|
->label($labels[$key][0] ?? Str::headline($key))
|
||||||
->placeholder('Vorgabe der Darstellung')
|
->placeholder(in_array($key, ['heading_size', 'text_size'], true) ? 'Bisherige Größe des Widgets' : 'Vorgabe der Darstellung')
|
||||||
->options($options[$key])
|
->options($options[$key])
|
||||||
->live());
|
->live());
|
||||||
|
|
||||||
@@ -196,6 +201,20 @@ public static function block(WidgetType $type): Block
|
|||||||
$display[] = Section::make('Aufbau')->compact()->schema($layout);
|
$display[] = Section::make('Aufbau')->compact()->schema($layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Schrift und Farbe (ADR-68) gehören allen Arten, die sie anbieten, und stehen in eigenen Gruppen nach „Aufbau“.
|
||||||
|
$sizeKeys = array_values(array_filter(['heading_size', 'text_size'], fn (string $key): bool => isset($options[$key])));
|
||||||
|
if ($sizeKeys !== []) {
|
||||||
|
$display[] = Section::make('Schrift')->compact()->schema([
|
||||||
|
Grid::make(['default' => 1, 'md' => 2])->schema(array_map($field, $sizeKeys))->statePath('settings'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['palette'])) {
|
||||||
|
$display[] = Section::make('Farbe')->compact()->schema([
|
||||||
|
Group::make([WidgetPaletteField::make('palette')->live()])->statePath('settings'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$grouped = [];
|
$grouped = [];
|
||||||
foreach ($type->settingGroups() as $title => $keys) {
|
foreach ($type->settingGroups() as $title => $keys) {
|
||||||
$keys = array_values(array_filter($keys, fn (string $key): bool => isset($options[$key]) && $key !== 'height'));
|
$keys = array_values(array_filter($keys, fn (string $key): bool => isset($options[$key]) && $key !== 'height'));
|
||||||
@@ -207,7 +226,7 @@ public static function block(WidgetType $type): Block
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$rest = array_values(array_filter(array_keys($options), fn (string $key): bool => $key !== 'height' && ! in_array($key, $grouped, true)));
|
$rest = array_values(array_filter(array_keys($options), fn (string $key): bool => $key !== 'height' && ! in_array($key, WidgetAppearance::KEYS, true) && ! in_array($key, $grouped, true)));
|
||||||
if ($rest !== []) {
|
if ($rest !== []) {
|
||||||
$display[] = Section::make($grouped === [] && $layout === [] ? 'Einstellungen' : 'Weitere Einstellungen')->compact()->schema([
|
$display[] = Section::make($grouped === [] && $layout === [] ? 'Einstellungen' : 'Weitere Einstellungen')->compact()->schema([
|
||||||
Grid::make(['default' => 1, 'md' => 2])->schema(array_map($field, $rest))->statePath('settings'),
|
Grid::make(['default' => 1, 'md' => 2])->schema(array_map($field, $rest))->statePath('settings'),
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Widgets\Support\WidgetAppearance;
|
||||||
|
use App\Domain\Design\DesignPalette;
|
||||||
|
use Filament\Forms\Components\ViewField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Farbe eines Widgets als Kacheln (ADR-68): „Ohne Farbe“ und die Farben der zentralen Palette. Das Feld ist das Feld
|
||||||
|
* „palette“ der Einstellungen des Widgets und speichert die Kennung der Farbe (nie einen Farbwert). Die Kacheln sehen aus wie
|
||||||
|
* die des Abschnitts (BackgroundField); sie unterscheiden sich nur dadurch, dass es keine festen Markenflächen und kein
|
||||||
|
* Hintergrundbild gibt.
|
||||||
|
*/
|
||||||
|
final class WidgetPaletteField
|
||||||
|
{
|
||||||
|
public static function make(string $name = 'palette'): ViewField
|
||||||
|
{
|
||||||
|
return ViewField::make($name)
|
||||||
|
->label(WidgetAppearance::PALETTE_LABEL[0])
|
||||||
|
->view('filament.cms.widget-farbe')
|
||||||
|
->hiddenLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{id: string, label: string, bg: ?string, fg: ?string, kind: string}>
|
||||||
|
*/
|
||||||
|
public static function tiles(): array
|
||||||
|
{
|
||||||
|
$tiles = [['id' => '', 'label' => 'Ohne Farbe', 'bg' => null, 'fg' => null, 'kind' => 'default']];
|
||||||
|
|
||||||
|
foreach (DesignPalette::slots() as $slot) {
|
||||||
|
$tiles[] = ['id' => $slot['id'], 'label' => $slot['name'], 'bg' => $slot['bg'], 'fg' => $slot['fg'], 'kind' => 'palette'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Symfony\Component\HttpFoundation\HeaderUtils;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,17 +15,29 @@ trait ServesByteRanges
|
|||||||
{
|
{
|
||||||
private const CHUNK = 262144;
|
private const CHUNK = 262144;
|
||||||
|
|
||||||
protected function respondWithRanges(Request $request, string $diskName, string $path, bool $ranged): StreamedResponse
|
/**
|
||||||
{
|
* @param string|null $name Dateiname für Ansicht oder Download (ohne: Name der Datei)
|
||||||
|
* @param string $disposition inline oder attachment
|
||||||
|
* @param array<string, string> $extra weitere Kopfzeilen
|
||||||
|
*/
|
||||||
|
protected function respondWithRanges(
|
||||||
|
Request $request,
|
||||||
|
string $diskName,
|
||||||
|
string $path,
|
||||||
|
bool $ranged,
|
||||||
|
?string $name = null,
|
||||||
|
string $disposition = 'inline',
|
||||||
|
array $extra = [],
|
||||||
|
): StreamedResponse {
|
||||||
$headers = [
|
$headers = [
|
||||||
'Content-Disposition' => 'inline',
|
'Content-Disposition' => $name === null ? $disposition : $this->disposition($disposition, $name),
|
||||||
'X-Content-Type-Options' => 'nosniff',
|
'X-Content-Type-Options' => 'nosniff',
|
||||||
'Accept-Ranges' => 'bytes',
|
'Accept-Ranges' => 'bytes',
|
||||||
];
|
] + $extra;
|
||||||
$range = $request->header('Range');
|
$range = $request->header('Range');
|
||||||
|
|
||||||
if (! is_string($range) || ! $ranged) {
|
if (! is_string($range) || ! $ranged) {
|
||||||
return Storage::disk($diskName)->response($path, null, $headers);
|
return Storage::disk($diskName)->response($path, $name, $headers, $disposition);
|
||||||
}
|
}
|
||||||
|
|
||||||
$disk = Storage::disk($diskName);
|
$disk = Storage::disk($diskName);
|
||||||
@@ -63,6 +76,13 @@ protected function respondWithRanges(Request $request, string $diskName, string
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function disposition(string $type, string $name): string
|
||||||
|
{
|
||||||
|
$fallback = (string) preg_replace('/[^ -~]|["\\%]/', '_', $name);
|
||||||
|
|
||||||
|
return HeaderUtils::makeDisposition($type, $name, $fallback);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Erster Bereich aus „bytes=a-b“, „bytes=a-“ oder „bytes=-n“; null, wenn er nicht erfüllbar ist.
|
* Erster Bereich aus „bytes=a-b“, „bytes=a-“ oder „bytes=-n“; null, wenn er nicht erfüllbar ist.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Concerns;
|
||||||
|
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
|
use App\Jobs\DeriveImageVariants;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Liefert ein Bild einer Disk mit Zwischenspeicherung aus (docs/architektur/bildvarianten.md).
|
||||||
|
*
|
||||||
|
* Mit Versionsangabe in der Adresse (`?v=`) ändert sich die Adresse, sobald sich das Bild ändert; der Browser darf es
|
||||||
|
* dann ein Jahr behalten. Ohne Version bleibt es bei einer Rückfrage mit ETag und Last-Modified (304 ohne Inhalt).
|
||||||
|
*/
|
||||||
|
trait ServesImages
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param 'public'|'private' $scope `private` für alles, was eine Anmeldung oder Berechtigung voraussetzt
|
||||||
|
*/
|
||||||
|
protected function respondWithImage(Request $request, string $diskName, string $path, string $scope = 'private', bool $versioned = false): Response
|
||||||
|
{
|
||||||
|
$disk = Storage::disk($diskName);
|
||||||
|
$headers = [
|
||||||
|
'Content-Disposition' => 'inline',
|
||||||
|
'X-Content-Type-Options' => 'nosniff',
|
||||||
|
];
|
||||||
|
$response = $disk->response($path, null, $headers);
|
||||||
|
$modified = (int) $disk->lastModified($path);
|
||||||
|
$size = (int) $disk->size($path);
|
||||||
|
|
||||||
|
$response->setEtag(md5($path.'|'.$modified.'|'.$size));
|
||||||
|
$response->setLastModified(Carbon::createFromTimestamp($modified));
|
||||||
|
|
||||||
|
if ($versioned) {
|
||||||
|
$response->headers->set('Cache-Control', $scope.', max-age=31536000, immutable');
|
||||||
|
} else {
|
||||||
|
$response->headers->set('Cache-Control', $scope.', max-age=0, must-revalidate');
|
||||||
|
}
|
||||||
|
|
||||||
|
$response->isNotModified($request);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Pfad der angefragten Größe (`?g=klein|mittel`), sonst die Hauptdatei. */
|
||||||
|
protected function imagePathFor(Request $request, string $diskName, string $path): string
|
||||||
|
{
|
||||||
|
$size = $request->query('g');
|
||||||
|
$resolved = ImageVariants::resolve(Storage::disk($diskName), $path, is_string($size) ? $size : null);
|
||||||
|
|
||||||
|
// Bestand ohne Fassungen: Die Hauptdatei geht hinaus, und die Warteschlange legt die Fassungen an (der Web-Prozess
|
||||||
|
// schreibt nie). Höchstens einmal je Tag und Bild; ist die Quelle schmaler als die Stufe, bleibt es bei der Hauptdatei.
|
||||||
|
if ($resolved === $path && ImageVariants::isSize($size) && Cache::add('bildvarianten.'.md5($path), true, now()->addDay())) {
|
||||||
|
DeriveImageVariants::dispatch($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $resolved;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** `?v=` ist da und eine einfache Zahl (Zeitstempel). */
|
||||||
|
protected function hasImageVersion(Request $request): bool
|
||||||
|
{
|
||||||
|
$version = $request->query('v');
|
||||||
|
|
||||||
|
return is_string($version) && preg_match('/^[0-9]{1,12}$/', $version) === 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -160,9 +160,7 @@ private function storedPath(ContentElementVersion $version): ?string
|
|||||||
|
|
||||||
private function renditionBelongsTo(int $versionId, string $path): bool
|
private function renditionBelongsTo(int $versionId, string $path): bool
|
||||||
{
|
{
|
||||||
$prefix = 'ableitungen/'.$versionId;
|
return MediaRendition::owns($versionId, $path);
|
||||||
|
|
||||||
return ($path === $prefix || str_starts_with($path, $prefix.'/')) && ! str_contains($path, '..');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function authorizeStaff(): void
|
private function authorizeStaff(): void
|
||||||
|
|||||||
@@ -12,15 +12,18 @@
|
|||||||
use App\Domain\Identity\StaffRole;
|
use App\Domain\Identity\StaffRole;
|
||||||
use App\Domain\Media\ThumbnailDeriver;
|
use App\Domain\Media\ThumbnailDeriver;
|
||||||
use App\Filament\Support\EditorialCatalog;
|
use App\Filament\Support\EditorialCatalog;
|
||||||
|
use App\Http\Controllers\Concerns\ServesImages;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
|
||||||
|
|
||||||
class EditorialPreviewController extends Controller
|
class EditorialPreviewController extends Controller
|
||||||
{
|
{
|
||||||
|
use ServesImages;
|
||||||
|
|
||||||
public function show(Composition $composition, ?CompositionVersion $version = null): View
|
public function show(Composition $composition, ?CompositionVersion $version = null): View
|
||||||
{
|
{
|
||||||
$this->authorizeStaff();
|
$this->authorizeStaff();
|
||||||
@@ -104,7 +107,7 @@ public function draft(Composition $composition): View
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function card(string $kind, int $subject): StreamedResponse
|
public function card(Request $request, string $kind, int $subject): SymfonyResponse
|
||||||
{
|
{
|
||||||
$this->authorizeStaff();
|
$this->authorizeStaff();
|
||||||
abort_unless(in_array($kind, ['element', 'komposition'], true), 404);
|
abort_unless(in_array($kind, ['element', 'komposition'], true), 404);
|
||||||
@@ -116,7 +119,13 @@ public function card(string $kind, int $subject): StreamedResponse
|
|||||||
$disk = Storage::disk('media_derived');
|
$disk = Storage::disk('media_derived');
|
||||||
abort_unless($disk->exists($path), 404);
|
abort_unless($disk->exists($path), 404);
|
||||||
|
|
||||||
return $disk->response($path);
|
return $this->respondWithImage(
|
||||||
|
$request,
|
||||||
|
'media_derived',
|
||||||
|
$this->imagePathFor($request, 'media_derived', $path),
|
||||||
|
'private',
|
||||||
|
$this->hasImageVersion($request),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -4,9 +4,11 @@
|
|||||||
|
|
||||||
use App\Domain\Communication\FormEvaluator;
|
use App\Domain\Communication\FormEvaluator;
|
||||||
use App\Domain\Communication\FormPayload;
|
use App\Domain\Communication\FormPayload;
|
||||||
|
use App\Domain\Communication\FormReason;
|
||||||
use App\Domain\Communication\FormToken;
|
use App\Domain\Communication\FormToken;
|
||||||
use App\Domain\Communication\InquiryEntry;
|
use App\Domain\Communication\InquiryEntry;
|
||||||
use App\Domain\Communication\InquiryService;
|
use App\Domain\Communication\InquiryService;
|
||||||
|
use App\Domain\Communication\InquiryTemplate;
|
||||||
use App\Domain\Communication\SubmissionException;
|
use App\Domain\Communication\SubmissionException;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -68,6 +70,59 @@ public function submit(Request $request, InquiryEntry $entry): JsonResponse
|
|||||||
return $this->json(['reference' => $result['reference']], 201);
|
return $this->json(['reference' => $result['reference']], 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Widget „Anfrage“ (ADR-61): das veröffentlichte Formular einer Vorlage für den gewählten Anfragegrund. Der Grund
|
||||||
|
* (Anliegen, Unteranliegen, Formularführung) steht in der Adresse, damit Zustand und Absendung ohne weitere
|
||||||
|
* Angaben dasselbe Formular meinen.
|
||||||
|
*/
|
||||||
|
public function formDefinition(Request $request, InquiryTemplate $template): JsonResponse
|
||||||
|
{
|
||||||
|
$delivered = $this->service->deliverForm($template, FormReason::clean($request->query()));
|
||||||
|
|
||||||
|
if ($delivered === null) {
|
||||||
|
return $this->json(['message' => 'Dieses Anfrageformular ist zurzeit nicht verfügbar.'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->json([
|
||||||
|
...FormPayload::definition($delivered['form'], $this->evaluator),
|
||||||
|
'token' => FormToken::issue($template->id, $delivered['version']->id, 'form'),
|
||||||
|
'csrf' => csrf_token(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function formState(Request $request, InquiryTemplate $template): JsonResponse
|
||||||
|
{
|
||||||
|
$delivered = $this->service->deliverForm($template, FormReason::clean($request->query()));
|
||||||
|
|
||||||
|
if ($delivered === null) {
|
||||||
|
return $this->json(['message' => 'Dieses Anfrageformular ist zurzeit nicht verfügbar.'], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$values = $request->input('values');
|
||||||
|
|
||||||
|
if (! is_array($values) || strlen((string) json_encode($values)) > 40000) {
|
||||||
|
return $this->json(['message' => 'Die Eingaben sind ungültig.'], 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->json(FormPayload::state($delivered['form'], $values, $this->evaluator));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function formSubmit(Request $request, InquiryTemplate $template): JsonResponse
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$result = $this->service->submitForm($template, FormReason::clean($request->query()), [
|
||||||
|
'token' => $request->input('token'),
|
||||||
|
'values' => $request->input('values'),
|
||||||
|
'website' => $request->input('website'),
|
||||||
|
'source' => $request->input('source'),
|
||||||
|
]);
|
||||||
|
} catch (SubmissionException $e) {
|
||||||
|
return $this->json(['message' => $e->getMessage(), 'fields' => (object) $e->fields], $e->getCode() ?: 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->json(['reference' => $result['reference']], 201);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $data
|
* @param array<string, mixed> $data
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -17,25 +17,34 @@
|
|||||||
use App\Domain\Entitlement\Grant;
|
use App\Domain\Entitlement\Grant;
|
||||||
use App\Domain\Entitlement\GrantStatus;
|
use App\Domain\Entitlement\GrantStatus;
|
||||||
use App\Domain\Media\DeliveryLog;
|
use App\Domain\Media\DeliveryLog;
|
||||||
|
use App\Domain\Media\FileChecksum;
|
||||||
use App\Domain\Media\FilmPlayback;
|
use App\Domain\Media\FilmPlayback;
|
||||||
use App\Domain\Media\HlsPlaylist;
|
use App\Domain\Media\HlsPlaylist;
|
||||||
use App\Domain\Media\MediaRendition;
|
use App\Domain\Media\MediaRendition;
|
||||||
|
use App\Domain\Media\StreamLifetime;
|
||||||
|
use App\Http\Controllers\Concerns\ServesByteRanges;
|
||||||
|
use App\Http\Controllers\Concerns\ServesImages;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\CourseOutline;
|
use App\Http\CourseOutline;
|
||||||
use App\Http\LibraryCatalog;
|
use App\Http\LibraryCatalog;
|
||||||
use App\Http\MemberLicenses;
|
use App\Http\MemberLicenses;
|
||||||
use App\Http\SignedLink;
|
use App\Http\SignedLink;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
|
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
class LibraryController extends Controller
|
class LibraryController extends Controller
|
||||||
{
|
{
|
||||||
|
use ServesByteRanges;
|
||||||
|
use ServesImages;
|
||||||
|
|
||||||
/** Inhaltsarten der Bibliothek (Schlüssel der Adresse und des Filters). */
|
/** Inhaltsarten der Bibliothek (Schlüssel der Adresse und des Filters). */
|
||||||
public const TYPES = [
|
public const TYPES = [
|
||||||
'programm' => 'Programme',
|
'programm' => 'Programme',
|
||||||
@@ -246,11 +255,11 @@ public function show(Request $request, LicenseArticle $article): View
|
|||||||
'action' => $action,
|
'action' => $action,
|
||||||
'allowed' => $decision->allowed,
|
'allowed' => $decision->allowed,
|
||||||
'reason' => $decision->reason,
|
'reason' => $decision->reason,
|
||||||
'decision' => is_numeric($metadata['decision_seconds'] ?? null)
|
|
||||||
? (int) $metadata['decision_seconds']
|
|
||||||
: null,
|
|
||||||
'playable' => $decision->allowed && is_string($file) && $file !== '' && ($class === 'film' || $class === 'audio'),
|
'playable' => $decision->allowed && is_string($file) && $file !== '' && ($class === 'film' || $class === 'audio'),
|
||||||
'playback' => app(FilmPlayback::class)->mode($version->id),
|
'playback' => app(FilmPlayback::class)->mode($version->id),
|
||||||
|
'renew_url' => $decision->allowed && $action === 'streamen' && app(FilmPlayback::class)->mode($version->id) === 'hls'
|
||||||
|
? route('member.playback.renew', [$article->id, $release->id, $version->id])
|
||||||
|
: null,
|
||||||
'download_url' => $download->allowed
|
'download_url' => $download->allowed
|
||||||
? SignedLink::temporary('member.media', now()->addMinutes(10), [
|
? SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||||
'article' => $article->id,
|
'article' => $article->id,
|
||||||
@@ -327,7 +336,7 @@ public function media(
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->fileResponse($decision->grant, $article, $release, $version, $action, $file, 'bestand');
|
return $this->fileResponse($request, $decision->grant, $article, $release, $version, $action, $file, 'bestand');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function rendition(
|
public function rendition(
|
||||||
@@ -361,7 +370,64 @@ public function rendition(
|
|||||||
return $disk->response($datei, basename($datei), ['Content-Disposition' => 'inline']);
|
return $disk->response($datei, basename($datei), ['Content-Disposition' => 'inline']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function thumbnail(Request $request, string $kind, int $subject): StreamedResponse
|
/**
|
||||||
|
* Frische Adresse für den Player (Plan Videoplayer 0.1). Ohne "datei" die Hauptliste (deren Abruf ist die
|
||||||
|
* Auslieferung und schreibt den Nachweis), mit "datei" ein Abschnitt oder eine Teilliste dieser Fassung. Geprüft
|
||||||
|
* wird wie beim Abruf selbst: Anmeldung, Konto, Stand und Fassung, Berechtigung (DecideAccess). Die Erneuerung
|
||||||
|
* schreibt keinen Nachweis, außer es gibt innerhalb des Zeitfensters noch keinen: Wer nie die Hauptliste holt, soll
|
||||||
|
* nicht ohne Nachweis streamen.
|
||||||
|
*/
|
||||||
|
public function renew(
|
||||||
|
Request $request,
|
||||||
|
LicenseArticle $article,
|
||||||
|
ArticleRelease $release,
|
||||||
|
ContentElementVersion $version,
|
||||||
|
): JsonResponse {
|
||||||
|
$decision = app(DecideAccess::class)($request->user(), $article, $release, $version, 'streamen');
|
||||||
|
abort_unless($decision->allowed && $decision->grant !== null, 403, $decision->reason);
|
||||||
|
abort_if(MediaRendition::masterPath($version->id) === null, 404);
|
||||||
|
|
||||||
|
$file = $request->query('datei');
|
||||||
|
|
||||||
|
if ($file === null) {
|
||||||
|
$url = SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||||
|
'article' => $article->id,
|
||||||
|
'release' => $release->id,
|
||||||
|
'version' => $version->id,
|
||||||
|
'action' => 'streamen',
|
||||||
|
'reader' => $request->user()->id,
|
||||||
|
]);
|
||||||
|
$seconds = 600;
|
||||||
|
} else {
|
||||||
|
abort_unless(is_string($file) && $this->renditionBelongsTo($version->id, $file), 404);
|
||||||
|
abort_unless(Storage::disk('media_derived')->exists($file), 404);
|
||||||
|
$lifetime = app(StreamLifetime::class);
|
||||||
|
app(DeliveryLog::class)->writeUnlessRecent(
|
||||||
|
$lifetime->window(),
|
||||||
|
$decision->grant,
|
||||||
|
$article,
|
||||||
|
$release,
|
||||||
|
$version,
|
||||||
|
'streamen',
|
||||||
|
'hls',
|
||||||
|
'k0',
|
||||||
|
);
|
||||||
|
$seconds = $lifetime->seconds($version->id);
|
||||||
|
$url = SignedLink::temporary('member.rendition', now()->addSeconds($seconds), [
|
||||||
|
'article' => $article->id,
|
||||||
|
'release' => $release->id,
|
||||||
|
'version' => $version->id,
|
||||||
|
'datei' => $file,
|
||||||
|
'reader' => $request->user()->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()
|
||||||
|
->json(['url' => $url, 'expires_in' => $seconds])
|
||||||
|
->header('Cache-Control', 'no-store, private');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function thumbnail(Request $request, string $kind, int $subject): SymfonyResponse
|
||||||
{
|
{
|
||||||
abort_unless(in_array($kind, ['komposition', 'element'], true), 404);
|
abort_unless(in_array($kind, ['komposition', 'element'], true), 404);
|
||||||
$model = $kind === 'komposition'
|
$model = $kind === 'komposition'
|
||||||
@@ -373,7 +439,13 @@ public function thumbnail(Request $request, string $kind, int $subject): Streame
|
|||||||
$disk = Storage::disk('media_derived');
|
$disk = Storage::disk('media_derived');
|
||||||
abort_unless($disk->exists($path), 404);
|
abort_unless($disk->exists($path), 404);
|
||||||
|
|
||||||
return $disk->response($path);
|
return $this->respondWithImage(
|
||||||
|
$request,
|
||||||
|
'media_derived',
|
||||||
|
$this->imagePathFor($request, 'media_derived', $path),
|
||||||
|
'private',
|
||||||
|
$this->hasImageVersion($request),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -398,10 +470,11 @@ private function playlist(
|
|||||||
abort_unless($this->renditionBelongsTo($version->id, $path), 404);
|
abort_unless($this->renditionBelongsTo($version->id, $path), 404);
|
||||||
$disk = Storage::disk('media_derived');
|
$disk = Storage::disk('media_derived');
|
||||||
abort_unless($disk->exists($path), 404);
|
abort_unless($disk->exists($path), 404);
|
||||||
|
$expires = now()->addSeconds(app(StreamLifetime::class)->seconds($version->id));
|
||||||
$rewritten = app(HlsPlaylist::class)->rewrite(
|
$rewritten = app(HlsPlaylist::class)->rewrite(
|
||||||
$disk->get($path),
|
$disk->get($path),
|
||||||
$path,
|
$path,
|
||||||
fn (string $target): string => SignedLink::temporary('member.rendition', now()->addMinutes(10), [
|
fn (string $target): string => SignedLink::temporary('member.rendition', $expires, [
|
||||||
'article' => $article->id,
|
'article' => $article->id,
|
||||||
'release' => $release->id,
|
'release' => $release->id,
|
||||||
'version' => $version->id,
|
'version' => $version->id,
|
||||||
@@ -432,6 +505,7 @@ private function playlist(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function fileResponse(
|
private function fileResponse(
|
||||||
|
Request $request,
|
||||||
Grant $grant,
|
Grant $grant,
|
||||||
LicenseArticle $article,
|
LicenseArticle $article,
|
||||||
ArticleRelease $release,
|
ArticleRelease $release,
|
||||||
@@ -442,24 +516,27 @@ private function fileResponse(
|
|||||||
): StreamedResponse {
|
): StreamedResponse {
|
||||||
$disk = Storage::disk('media_derived');
|
$disk = Storage::disk('media_derived');
|
||||||
abort_unless($disk->exists($file) && ! str_contains($file, '..'), 404);
|
abort_unless($disk->exists($file) && ! str_contains($file, '..'), 404);
|
||||||
$delivery = app(DeliveryLog::class)->write(
|
$log = app(DeliveryLog::class);
|
||||||
$grant,
|
$checksum = fn (): ?string => app(FileChecksum::class)->of('media_derived', $file);
|
||||||
$article,
|
|
||||||
$release,
|
|
||||||
$version,
|
|
||||||
$action,
|
|
||||||
$format,
|
|
||||||
hash_file('sha256', $disk->path($file)) ?: null,
|
|
||||||
'k0',
|
|
||||||
);
|
|
||||||
|
|
||||||
// Dateiname aus dem Anzeigetitel statt aus der Adresse („laden.mp4“); Laravel setzt Content-Disposition mit
|
// Ein vollständiger Abruf ist eine Auslieferung. Teilabrufe (Springen, Fortsetzen) derselben Wiedergabe zählen
|
||||||
// ASCII-Rückfall und UTF-8-Name.
|
// innerhalb der Laufzeit der Adresse nicht erneut; gibt es noch keinen Nachweis, entsteht genau einer.
|
||||||
return $disk->response(
|
if (is_string($request->header('Range'))) {
|
||||||
|
$log->writeUnlessRecent(600, $grant, $article, $release, $version, $action, $format, 'k0', $checksum);
|
||||||
|
$copy = '';
|
||||||
|
} else {
|
||||||
|
$copy = $log->write($grant, $article, $release, $version, $action, $format, $checksum(), 'k0')->copy_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dateiname aus dem Anzeigetitel statt aus der Adresse („laden.mp4“), mit ASCII-Rückfall und UTF-8-Name.
|
||||||
|
return $this->respondWithRanges(
|
||||||
|
$request,
|
||||||
|
'media_derived',
|
||||||
$file,
|
$file,
|
||||||
|
true,
|
||||||
$this->downloadName($version, $file),
|
$this->downloadName($version, $file),
|
||||||
['X-License-Copy' => $delivery->copy_id],
|
|
||||||
$action === 'laden' ? 'attachment' : 'inline',
|
$action === 'laden' ? 'attachment' : 'inline',
|
||||||
|
$copy === '' ? [] : ['X-License-Copy' => $copy],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,9 +562,7 @@ private function downloadName(ContentElementVersion $version, string $file): str
|
|||||||
|
|
||||||
private function renditionBelongsTo(int $versionId, string $path): bool
|
private function renditionBelongsTo(int $versionId, string $path): bool
|
||||||
{
|
{
|
||||||
$prefix = 'ableitungen/'.$versionId;
|
return MediaRendition::owns($versionId, $path);
|
||||||
|
|
||||||
return ($path === $prefix || str_starts_with($path, $prefix.'/')) && ! str_contains($path, '..');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function maySeeThumbnail(Request $request, string $kind, int $subject): bool
|
private function maySeeThumbnail(Request $request, string $kind, int $subject): bool
|
||||||
|
|||||||
@@ -3,16 +3,22 @@
|
|||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Domain\Catalog\ContentElement;
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
use App\Domain\Media\WebsiteMedia;
|
use App\Domain\Media\WebsiteMedia;
|
||||||
use App\Http\Controllers\Concerns\ServesByteRanges;
|
use App\Http\Controllers\Concerns\ServesByteRanges;
|
||||||
|
use App\Http\Controllers\Concerns\ServesImages;
|
||||||
|
use App\Jobs\DeriveWebsiteVariants;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class WebsiteMediaController extends Controller
|
class WebsiteMediaController extends Controller
|
||||||
{
|
{
|
||||||
use ServesByteRanges;
|
use ServesByteRanges;
|
||||||
|
use ServesImages;
|
||||||
|
|
||||||
public function show(Request $request, ContentElement $element, WebsiteMedia $media): StreamedResponse
|
public function show(Request $request, ContentElement $element, WebsiteMedia $media): Response
|
||||||
{
|
{
|
||||||
$presentation = $media->present($element);
|
$presentation = $media->present($element);
|
||||||
abort_if($presentation === null, 404);
|
abort_if($presentation === null, 404);
|
||||||
@@ -20,6 +26,45 @@ public function show(Request $request, ContentElement $element, WebsiteMedia $me
|
|||||||
$path = $element->website_public_path;
|
$path = $element->website_public_path;
|
||||||
abort_if(! is_string($path), 404);
|
abort_if(! is_string($path), 404);
|
||||||
|
|
||||||
return $this->respondWithRanges($request, 'media_public', $path, $presentation->kind !== 'bild');
|
if ($presentation->kind !== 'bild') {
|
||||||
|
return $this->respondWithRanges($request, 'media_public', $path, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $this->widthPath($request, $element, $path);
|
||||||
|
// Die Adresse trägt den Zeitpunkt der Freigabe. Gilt er noch, ändert sich der Inhalt unter dieser Adresse nicht mehr
|
||||||
|
// (eine neue Freigabe liefert eine neue Adresse); eine veraltete Adresse wird nur kurz vorgehalten und geprüft.
|
||||||
|
$current = $this->hasImageVersion($request)
|
||||||
|
&& (int) $request->query('v') === $element->website_released_at?->getTimestamp();
|
||||||
|
|
||||||
|
return $this->respondWithImage($request, 'media_public', $path, 'public', $current);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die angefragte Breite (`?w=640|1280|1920`), sonst die volle Datei. Fehlt die Breite noch, geht die volle Datei hinaus,
|
||||||
|
* und die Warteschlange legt die Breiten an (höchstens einmal je Stunde und Bild; der Web-Prozess schreibt nie).
|
||||||
|
*/
|
||||||
|
private function widthPath(Request $request, ContentElement $element, string $path): string
|
||||||
|
{
|
||||||
|
$width = $request->query('w');
|
||||||
|
|
||||||
|
if (! is_string($width) || preg_match('/^[0-9]{3,4}$/', $width) !== 1 || ! ImageVariants::isPublicWidth((int) $width)) {
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! in_array(strtolower(pathinfo($path, PATHINFO_EXTENSION)), ['jpg', 'jpeg'], true)) {
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|
||||||
|
$variant = ImageVariants::publicPath($path, (int) $width);
|
||||||
|
|
||||||
|
if (Storage::disk('media_public')->exists($variant)) {
|
||||||
|
return $variant;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Cache::add('bildvarianten.website.'.$element->id, true, now()->addHour())) {
|
||||||
|
DeriveWebsiteVariants::dispatch($element->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+42
-14
@@ -92,6 +92,7 @@ public function index(User $user): array
|
|||||||
'image_url' => $picture === null ? null : route('member.thumbnail', [
|
'image_url' => $picture === null ? null : route('member.thumbnail', [
|
||||||
'kind' => $picture['kind'],
|
'kind' => $picture['kind'],
|
||||||
'subject' => $picture['subject'],
|
'subject' => $picture['subject'],
|
||||||
|
'g' => 'mittel',
|
||||||
]),
|
]),
|
||||||
'url' => route('member.program', $composition),
|
'url' => route('member.program', $composition),
|
||||||
];
|
];
|
||||||
@@ -113,7 +114,7 @@ public function index(User $user): array
|
|||||||
: ($element?->id !== null ? 'element-'.$element->id : 'artikel-'.$article->id);
|
: ($element?->id !== null ? 'element-'.$element->id : 'artikel-'.$article->id);
|
||||||
$subject = $element ?? $composition ?? $article;
|
$subject = $element ?? $composition ?? $article;
|
||||||
$text = $element !== null ? $this->text($element) : null;
|
$text = $element !== null ? $this->text($element) : null;
|
||||||
$imageUrl = $element === null ? null : ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path);
|
$imageUrl = $element === null ? null : ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
$media[$key] = ($media[$key] ?? []) + [
|
$media[$key] = ($media[$key] ?? []) + [
|
||||||
'used_in' => [],
|
'used_in' => [],
|
||||||
'versions' => [],
|
'versions' => [],
|
||||||
@@ -364,6 +365,7 @@ private function present(User $user, StructureNode $node, bool $full, int $rootI
|
|||||||
$view = null;
|
$view = null;
|
||||||
$download = null;
|
$download = null;
|
||||||
$playback = 'file';
|
$playback = 'file';
|
||||||
|
$renew = null;
|
||||||
$poster = null;
|
$poster = null;
|
||||||
$element = $node->contentElementId === null ? null : $this->element($node->contentElementId);
|
$element = $node->contentElementId === null ? null : $this->element($node->contentElementId);
|
||||||
|
|
||||||
@@ -375,8 +377,12 @@ private function present(User $user, StructureNode $node, bool $full, int $rootI
|
|||||||
$playback = app(FilmPlayback::class)->mode($node->contentElementVersionId);
|
$playback = app(FilmPlayback::class)->mode($node->contentElementVersionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($view !== null && $playback === 'hls') {
|
||||||
|
$renew = $this->renewal($user, $node->contentElementVersionId);
|
||||||
|
}
|
||||||
|
|
||||||
if ($view !== null && $element !== null) {
|
if ($view !== null && $element !== null) {
|
||||||
$poster = ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path);
|
$poster = ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path, 'mittel', $element->updated_at);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,6 +404,7 @@ private function present(User $user, StructureNode $node, bool $full, int $rootI
|
|||||||
'kind' => $node->editorialKindLabel ?? $this->outputLabel($node->technicalKindLabel) ?? $node->technicalKindLabel,
|
'kind' => $node->editorialKindLabel ?? $this->outputLabel($node->technicalKindLabel) ?? $node->technicalKindLabel,
|
||||||
'output_class' => $node->outputClass,
|
'output_class' => $node->outputClass,
|
||||||
'playback' => $playback,
|
'playback' => $playback,
|
||||||
|
'renew_url' => $renew,
|
||||||
'view_url' => $view ?? $documentUrl,
|
'view_url' => $view ?? $documentUrl,
|
||||||
'poster_url' => $poster,
|
'poster_url' => $poster,
|
||||||
'download_url' => $download,
|
'download_url' => $download,
|
||||||
@@ -573,6 +580,37 @@ private function viewAction(?string $outputClass): string
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function open(User $user, int $versionId, string $action): ?string
|
private function open(User $user, int $versionId, string $action): ?string
|
||||||
|
{
|
||||||
|
$found = $this->grantedRelease($user, $versionId, $action);
|
||||||
|
|
||||||
|
if ($found === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SignedLink::temporary('member.media', now()->addMinutes(10), [
|
||||||
|
'article' => $found->article->id,
|
||||||
|
'release' => $found->id,
|
||||||
|
'version' => $versionId,
|
||||||
|
'action' => $action,
|
||||||
|
'reader' => $user->id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adresse, unter der der Player eine frische Wiedergabeadresse holt (Plan Videoplayer 0.1). Dieselbe Entscheidung
|
||||||
|
* wie bei open(): derselbe Stand, der die Wiedergabe erlaubt.
|
||||||
|
*/
|
||||||
|
private function renewal(User $user, int $versionId): ?string
|
||||||
|
{
|
||||||
|
$found = $this->grantedRelease($user, $versionId, 'streamen');
|
||||||
|
|
||||||
|
return $found === null ? null : route('member.playback.renew', [$found->article->id, $found->id, $versionId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Der jüngste veröffentlichte Stand, in dem die Fassung steht und der die Aktion für dieses Konto erlaubt.
|
||||||
|
*/
|
||||||
|
private function grantedRelease(User $user, int $versionId, string $action): ?ArticleRelease
|
||||||
{
|
{
|
||||||
$version = ContentElementVersion::query()->with('element')->find($versionId);
|
$version = ContentElementVersion::query()->with('element')->find($versionId);
|
||||||
|
|
||||||
@@ -588,19 +626,9 @@ private function open(User $user, int $versionId, string $action): ?string
|
|||||||
->get();
|
->get();
|
||||||
|
|
||||||
foreach ($releases as $release) {
|
foreach ($releases as $release) {
|
||||||
$decision = ($this->access)($user, $release->article, $release, $version, $action);
|
if (($this->access)($user, $release->article, $release, $version, $action)->allowed) {
|
||||||
|
return $release;
|
||||||
if (! $decision->allowed) {
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return SignedLink::temporary('member.media', now()->addMinutes(10), [
|
|
||||||
'article' => $release->article->id,
|
|
||||||
'release' => $release->id,
|
|
||||||
'version' => $version->id,
|
|
||||||
'action' => $action,
|
|
||||||
'reader' => $user->id,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -129,8 +129,8 @@ private function entry(User $user, Grant $grant): array
|
|||||||
|
|
||||||
if ($grant->status === GrantStatus::Aktiv) {
|
if ($grant->status === GrantStatus::Aktiv) {
|
||||||
$imageUrl = $composition !== null
|
$imageUrl = $composition !== null
|
||||||
? ThumbnailRef::url('member.thumbnail', 'komposition', $composition->id, $composition->thumbnail_path)
|
? ThumbnailRef::url('member.thumbnail', 'komposition', $composition->id, $composition->thumbnail_path, 'klein', $composition->updated_at)
|
||||||
: ($element === null ? null : ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path));
|
: ($element === null ? null : ThumbnailRef::url('member.thumbnail', 'element', $element->id, $element->thumbnail_path, 'klein', $element->updated_at));
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = $composition !== null
|
$title = $composition !== null
|
||||||
|
|||||||
@@ -48,5 +48,8 @@ public function handle(FilmTranscoder $transcoder): void
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fassungen mit derselben Datei, die schon während der Verarbeitung gespeichert wurden, bekommen die Stufen nach.
|
||||||
|
MediaRendition::carryForward($version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt die kleineren Fassungen (klein, mittel) zu einem vorhandenen Vorschaubild an. Läuft nur in der Warteschlange, die in
|
||||||
|
* derived/ schreiben darf. Auslöser: Bestand ohne Fassungen, den die Auslieferung oder der Befehl `media:varianten` findet.
|
||||||
|
*/
|
||||||
|
class DeriveImageVariants implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public function __construct(public readonly string $path) {}
|
||||||
|
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
if (preg_match('#^vorschau/[A-Za-z0-9._\-/]+$#', $this->path) !== 1 || str_contains($this->path, '..')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageVariants::generate(Storage::disk('media_derived'), $this->path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt die Breiten für die Website zu einem bereits freigegebenen Bild an (Bestand von vor den Bildfassungen). Verändert
|
||||||
|
* weder die Freigabe noch den Prüfverlauf; die Freigabe selbst schreibt die Fassungen in {@see PublishWebsiteMedia}.
|
||||||
|
*/
|
||||||
|
class DeriveWebsiteVariants implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public function __construct(public readonly int $elementId) {}
|
||||||
|
|
||||||
|
public function handle(): void
|
||||||
|
{
|
||||||
|
$element = ContentElement::query()->find($this->elementId);
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement || $element->output_class !== 'bild' || $element->website_released_at === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $element->website_public_path;
|
||||||
|
|
||||||
|
if (! is_string($path) || preg_match('#^website/'.$element->id.'/datei\.[a-z0-9]+$#', $path) !== 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$disk = Storage::disk('media_public');
|
||||||
|
ImageVariants::generatePublic($disk, $disk, $path, $path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Domain\Catalog\ContentElement;
|
use App\Domain\Catalog\ContentElement;
|
||||||
use App\Domain\Catalog\IdentityChange;
|
use App\Domain\Catalog\IdentityChange;
|
||||||
|
use App\Domain\Media\ImageVariants;
|
||||||
use App\Domain\Media\WebsiteRelease;
|
use App\Domain\Media\WebsiteRelease;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Queue\Queueable;
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
@@ -51,6 +52,12 @@ public function handle(WebsiteRelease $release): void
|
|||||||
|
|
||||||
if (is_string($previous) && $previous !== $target && str_starts_with($previous, 'website/'.$element->id.'/')) {
|
if (is_string($previous) && $previous !== $target && str_starts_with($previous, 'website/'.$element->id.'/')) {
|
||||||
Storage::disk('media_public')->delete($previous);
|
Storage::disk('media_public')->delete($previous);
|
||||||
|
ImageVariants::deletePublic(Storage::disk('media_public'), $previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($element->output_class === 'bild') {
|
||||||
|
// Breiten für die Website neben der Hauptdatei; ohne sie liefert die Website immer die volle Datei.
|
||||||
|
ImageVariants::generatePublic(Storage::disk('media_derived'), Storage::disk('media_public'), $derived, $target);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->mark($element, $element->website_released_at?->toIso8601String(), now()->toIso8601String());
|
$this->mark($element, $element->website_released_at?->toIso8601String(), now()->toIso8601String());
|
||||||
@@ -69,6 +76,8 @@ private function deletePublicFile(ContentElement $element): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
Storage::disk('media_public')->delete($path);
|
Storage::disk('media_public')->delete($path);
|
||||||
|
// Auch die Breiten: Sonst bliebe ein zurückgenommenes Bild unter dem Namen einer Fassung erreichbar.
|
||||||
|
ImageVariants::deletePublic(Storage::disk('media_public'), $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function mark(ContentElement $element, ?string $before, ?string $after): void
|
private function mark(ContentElement $element, ?string $before, ?string $after): void
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Domain\Catalog\ContentElementVersion;
|
use App\Domain\Catalog\ContentElementVersion;
|
||||||
use App\Domain\Catalog\ContentVersionStatus;
|
use App\Domain\Catalog\ContentVersionStatus;
|
||||||
|
use App\Domain\Media\FileChecksum;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Foundation\Queue\Queueable;
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
@@ -82,6 +83,8 @@ public function handle(): void
|
|||||||
}
|
}
|
||||||
|
|
||||||
$version->save();
|
$version->save();
|
||||||
|
// Prüfsumme für den Auslieferungsnachweis jetzt rechnen, damit die erste Wiedergabe nicht darauf wartet.
|
||||||
|
app(FileChecksum::class)->of('media_derived', $target);
|
||||||
DeriveThumbnail::dispatch('element', $version->content_element_id);
|
DeriveThumbnail::dispatch('element', $version->content_element_id);
|
||||||
DeriveFilmRenditions::dispatch($version->id);
|
DeriveFilmRenditions::dispatch($version->id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wiedergabe über HLS im Mitgliederbereich.
|
||||||
|
*
|
||||||
|
* Die Adressen der Abschnitte und Teillisten gelten so lange wie der Film dauert plus Reserve (Plan
|
||||||
|
* Videoplayer 0.1). Die Filmlänge ergibt sich aus der Summe der #EXTINF-Werte der Teilliste; ist sie nicht lesbar,
|
||||||
|
* gilt die Ersatzdauer. Nach oben begrenzt die Höchstdauer.
|
||||||
|
*
|
||||||
|
* Eine längere Laufzeit verlängert nicht die Nachlaufzeit nach einem Entzug: Jeder Abruf prüft Anmeldung, Konto und
|
||||||
|
* DecideAccess neu. Die Laufzeit begrenzt nur, wie lange eine einmal ausgestellte Adresse als Adresse taugt.
|
||||||
|
* Dieselbe Höchstdauer ist das Zeitfenster, in dem Erneuerungen zur selben Wiedergabe zählen (ein Nachweis je
|
||||||
|
* Wiedergabe, siehe PlaybackRenewal).
|
||||||
|
*
|
||||||
|
* Zum Prüfen auf der Test-Instanz in der Serverdatei kurz setzen, z. B. MEDIA_STREAM_RESERVE_MINUTES=1 und
|
||||||
|
* MEDIA_STREAM_MAX_MINUTES=2.
|
||||||
|
*/
|
||||||
|
return [
|
||||||
|
'stream_reserve_minutes' => (int) env('MEDIA_STREAM_RESERVE_MINUTES', 60),
|
||||||
|
'stream_fallback_minutes' => (int) env('MEDIA_STREAM_FALLBACK_MINUTES', 240),
|
||||||
|
'stream_max_minutes' => (int) env('MEDIA_STREAM_MAX_MINUTES', 720),
|
||||||
|
];
|
||||||
@@ -0,0 +1,281 @@
|
|||||||
|
# Umsetzungsplan: Zentraler Videoplayer (Website-Vollbild und Mitgliederbereich)
|
||||||
|
|
||||||
|
**Stand:** 30.11.2026, Branch `develop` (Commit `f11ff89`).
|
||||||
|
**Status (01.12.2026):** Stufe 0.7 und 1a/2 sind auf `develop` (Commit `e6957b7`, Deployment auf luf-test). Gerätetest von Lars (nur Aussage, keine Tabelle): iPhone und ein Android-Tablet, jeweils auf der normalen Webseite mit den Widgets, „alles klappt“.
|
||||||
|
**Davor (30.11.2026):** Umsetzung begonnen auf `feature/videoplayer-grundlagen`. Lars hat „Dauerhaft laden“ ausgeschlossen und „Vorab laden (Sitzung)“ ausdrücklich eingeplant (Stufe 4; Antwort von Legal aus Entscheidung Nr. 6 steht aus).
|
||||||
|
|
||||||
|
| Stufe | Stand |
|
||||||
|
|---|---|
|
||||||
|
| 0.7 Rendition übernehmen | umgesetzt mit Tests: neue Fassung ohne neue Datei (`MediaRendition::carryOver`), spät fertige Verarbeitung (`carryForward`, Aufruf in `DeriveFilmRenditions`), `renditionBelongsTo` über `MediaRendition::owns`. Bereits betroffene Fassungen bleiben im Dateimodus; der Prüf- und Nachziehbefehl ist **nicht gebaut**. |
|
||||||
|
| 1a/2 Website-Vollbild | umgesetzt: Einstellung `fullscreen` (Vorgabe „Aus“, Entscheidung Nr. 1 wie empfohlen angewendet, **nicht bestätigt**), `resources/js/player/fullscreen.js`, Anbindung in `card-clip.js`, Schaltfläche und CSS, ADR-43-Nachtrag, Registry. Desktop in Edge geprüft (19 Prüfungen, Wegwerf-Prüfstand außerhalb des Repositorys). **Gerätetest 01.12.2026:** iPhone und Android-Tablet bestanden laut Lars (iOS-/Android-Version, Browser und Einzelschritte wie Drehung und Zurück-Geste nicht notiert; **iPad, Windows-/macOS-Browser und Beamer ungeprüft**). **Nicht erledigt:** Abnahme auf luf-test (Screenshots, schmale Breite, Überlagerung mit der Art-Marke), Hero-Video, Entscheidung Nr. 11 (Neigerichtung folgt dem Gerät als Vorgabe). Es gibt noch keinen JS-Test im Repository (Entscheidung Nr. 9). |
|
||||||
|
| 0.1 Signaturerneuerung | **umgesetzt auf `feature/videoplayer-grundlagen` (01.12.2026), noch nicht auf `develop`.** Server: `config/media.php` (Reserve 60 min, Höchstdauer 720 min, Ersatzdauer 240 min; Env `MEDIA_STREAM_RESERVE_MINUTES`, `MEDIA_STREAM_MAX_MINUTES`, `MEDIA_STREAM_FALLBACK_MINUTES`), `StreamLifetime` (Filmlänge = Summe der `#EXTINF`-Werte der ersten Teilliste, keine Migration), Endpunkt `member.playback.renew` mit `DecideAccess` und Tupelprüfung, Nachweis nur wenn im Zeitfenster noch keiner steht (`DeliveryLog::writeUnlessRecent`). Client: `player/renewal.js`, `player/source.js`, `data-hls-renew`; Vitest (24 Tests) im Gate (`jstest`). **Nicht abgedeckt:** Dateimodus (Filme ohne HLS) und Download bleiben bei 10 Minuten (0.2/0.3); die Hauptliste auf der Seite gilt weiter 10 Minuten und wird bei 403 über den Endpunkt erneuert. Der iPhone-Weg (nativ, Wiederaufnahme bei Fehler) ist nur als Logik getestet. Tatsache zum Entzug: Jeder Abruf prüft `DecideAccess`, die längere Laufzeit verlängert die Nachlaufzeit nach Entzug nicht (Test `test_an_expired_segment_link_is_refused_and_a_revoked_grant_stops_a_valid_one_at_once`); damit entfällt die offene Frage der Nachlaufzeit in Nr. 10. |
|
||||||
|
| 0.2, 0.3 Dateimodus und Downloads | **umgesetzt (01.12.2026):** `fileResponse` nutzt `ServesByteRanges` (206/416, `Accept-Ranges`, Dateiname und `attachment` bleiben, Download lässt sich fortsetzen). Nachweis: ein vollständiger Abruf schreibt einen Eintrag, Teilabrufe innerhalb von 10 Minuten (Laufzeit der Adresse) nur, wenn noch keiner steht (`DeliveryLog::writeUnlessRecent`). Prüfsumme je Datei einmal (`FileChecksum`, gemerkt nach Pfad, Größe und Änderungszeit, beim Speichern vorgewärmt); ohne lesbare Datei `null`. **Abweichung vom Plan:** Der Wert liegt im Cache, nicht in `metadata['checksum']` (Fassungen sind unveränderlich, ein Nachtragen würde den Inhaltshash ändern); nach einem Cache-Verlust wird beim nächsten Abruf neu gerechnet. Sicht ungeprüft: Safari/iPhone im Dateimodus. |
|
||||||
|
| 0.8 Entscheidungsmarke | **teilweise:** toter Handler (`data-course-decision`, `data-course-restart`, `data-decision`) aus `app.js` und der ungenutzte Schlüssel `decision` in `LibraryController::show` entfernt. Das Feld `decision_seconds` im Verwaltungsformular (`ElementRevision`) und seine Anzeige (`CatalogReading`) bleiben bis zum Marker-Editor (Stufe 3) als Altwert; `CoursePlayerTest` bleibt bis dahin unverändert. Der Vollbild-Knopf im Mitgliederbereich nutzt jetzt `player/fullscreen.js` (vorher nur `requestFullscreen`, auf dem iPhone ohne Wirkung); auf dem Gerät nicht geprüft. |
|
||||||
|
| 0.4–0.6, 0.9, 1b, 3, 4 | nicht begonnen |
|
||||||
|
|
||||||
|
Ursprünglicher Stand: Vorschlag zur Freigabe; die Entscheidungen in Abschnitt 8 sind bis auf die genannten offen.
|
||||||
|
**Grundlage:** `docs/architektur/08_Medien_Streaming_Kennzeichnung.md` (§3, §5), `docs/architektur/medienzugriff-fuer-komponenten.md`, ADR-43, `docs/analysen/medienauslieferung-performance-2026-11-30.md` (im Folgenden „Performance-Analyse“, Befunde W1…, M1…, Maßnahmen A1…, B1…).
|
||||||
|
|
||||||
|
**Kennzeichnung der Aussagen.** **[Code]** = aus dem Quelltext gelesen, nicht im laufenden System nachgestellt. **[unverifiziert]** = Browser- oder Geräteverhalten, das ohne Gerätetest nicht als Tatsache gelten darf. **[Annahme]** = Planungswert, nicht gemessen.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Zusammenfassung
|
||||||
|
|
||||||
|
**Teil 1, Vollbild für Website-Widgets:** machbar und klein, wenn die Vollbild-Logik als gemeinsames Modul entsteht, das später auch der Mitglieder-Player nutzt. Das Vollbild spielt **nur den freigegebenen Clip** (Trailer, Vorschauclip, Website-Datei), nie den vollständigen Film. Es wird je Widget über eine Einstellung neben „Trailer auf der Karte“ (`clip`) ein- und ausgeschaltet. Das größte technische Risiko ist iPhone-Safari, dort ist die Vollbild-Schnittstelle für Elemente nicht gleich wie auf Android und Desktop **[unverifiziert]**. Das ist ein Gerätetest, keine Annahme. Ohne `faststart` am 85-MB-Clip (Performance-Analyse W1/B1) wird Vollbild auf dem Handy spürbar langsam starten.
|
||||||
|
|
||||||
|
**Teil 2, Mitglieder-Player:** Kapitelmarker, Autostopp und Qualitätswahl sind mit einem **eigenen schlanken Player über dem nativen `<video>` und `hls.js`** (bereits Abhängigkeit) umsetzbar, ohne neue Bibliothek. Zwei Befunde ändern die Reihenfolge:
|
||||||
|
|
||||||
|
1. **Autostopp existiert heute nicht, und das war Absicht.** Der Code in `resources/js/app.js` (`data-course-decision`, `data-decision`) hat keine Gegenstelle in den Ansichten, `CoursePlayerTest` erwartet `assertDontSee('Zur Entscheidungsmarke')`. Der MVP-Plan hat Knopf und Entscheidungsmarke ausdrücklich aus dem Pfad genommen und „automatische Denkpause, Ablaufsteuerung, Präsentationsmodus“ zurückgestellt (`umsetzungsplan-mitgliederbibliothek.md` Zeilen 175–178, 201, 373; `ist-soll-abgleich-mitgliederbibliothek.md` Zeilen 256–260; Commits `4f2e5a5`, `fc08e6d`). Gespeichert wird nur ein einzelner Wert `decision_seconds`, der in `LibraryController::show` berechnet, aber nicht ausgegeben wird **[Code]**. Der Autostopp ist ein Neubau und hebt diese Zurückstellung auf.
|
||||||
|
2. **Die 10-Minuten-Signatur bricht genau den Autostopp-Fall** (Pause, Gespräch, Weiter ergibt 403 bei späteren Abschnitten, Performance-Analyse M4). Signaturerneuerung (A5) ist deshalb **Voraussetzung**, kein Zusatz. Dasselbe gilt für Bereichsabrufe (A2), sichtbare Fehler der HLS-Verarbeitung (A6) und das spätere Laden von `hls.js` (A7).
|
||||||
|
|
||||||
|
**Offline:** „Dauerhaft laden“ ist von Lars **ausgeschlossen** und nicht Teil dieses Plans (Stufe 5 entfällt). Es bleibt **„Vorab laden (Sitzung)“** (Stufe 4):
|
||||||
|
|
||||||
|
- Der Film wird vor der Vorführung vollständig in den Arbeitsspeicher der Seite geladen und läuft danach ohne Verbindung, solange die Seite offen bleibt. Es entsteht keine Datei und kein dauerhafter Speicher. Das deckt „Beamer im Raum mit schlechtem WLAN“ ab und braucht weder HTTPS noch eine neue Aktion im Rechteprofil. Es ist in 08 §3.3 bereits vorgesehen („vor der Stunde vollständig laden“). Ob die Lizenzbedingungen einen vollständig beim Nutzer gehaltenen Film abdecken, **bewertet Legal** (Entscheidung Nr. 6).
|
||||||
|
|
||||||
|
**Reihenfolge:** Teil 1 und Teil 2 sind getrennte Linien. **Teil 1 (Stufe 1a → Stufe 2) wartet nicht auf Stufe 0** und kann zuerst geliefert werden (grob 5–8 Personentage, Schätzung). Teil 2 braucht Stufe 0 (Voraussetzungen), Stufe 1b und Stufe 3 (zusammen grob 25–41 Personentage, Schätzung, nicht gemessen); Stufe 4 folgt. Abhängigkeiten und Aufwand je Stufe in Abschnitt 5.1. **Zehn offene Entscheidungen für Lars** stehen in Abschnitt 8.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Ausgangslage (belegt)
|
||||||
|
|
||||||
|
| Bereich | Stand | Quelle |
|
||||||
|
|---|---|---|
|
||||||
|
| Karten-Clips (Premium-, Medien-, Programm-, Modulkarte, Bild und Text) | `resources/js/card-clip.js`: Hover stumm in Schleife (nur Maus), Klick/Tipp mit Ton, Stopp beim Scrollen (`IntersectionObserver`, Schwelle 0,2), nur ein Clip zugleich, `preload="none"`, Quelle erst beim Start. Das `<video>` ist `aria-hidden`, ohne `controls`, `tabindex="-1"`, `disablepictureinpicture`. | [Code] |
|
||||||
|
| Hero-Video | `resources/js/hero-video.js`: stumm, selbststartend, Schleife, Schaltfläche zum Anhalten (WCAG 2.2.2). Eigene Logik, nicht `card-clip.js`. | [Code] |
|
||||||
|
| Einstellung am Widget | `PremiumCardWidget`: Option `clip` (`yes` = Abspielen, `no`), Vorgabe `yes`, gruppiert unter „Bild und Video“, nur wenn `supportsClip()`. `ImageTextWidget`: Feld `refs.video`, **keine** `clip`-Einstellung. | [Code] |
|
||||||
|
| Clip-Quelle | `CardClip` (Trailer, sonst Vorschauclip, sonst Website-Datei des Films), ausgeliefert über `website.media` mit Bereichsabrufen. Kein Zugriff auf den vollständigen Film. | [Code], ADR-43 |
|
||||||
|
| Mitglieder-Player | `resources/views/content/video.blade.php`: natives `<video controls playsinline>`, bei HLS `data-hls`. Verwendet in `member/content`, `member/article`, `content/player` (Redaktionsvorschau). Vollbild-Knopf `data-fullscreen` ruft `video.requestFullscreen()`. `hls.js` wird für **jedes** `video[data-hls]` sofort und ohne Einstellungen gestartet. | [Code] |
|
||||||
|
| Marken | Nur `metadata['decision_seconds']` an der Filmfassung, ein Wert, nicht ausgegeben. `ElementRevision` legt bei Änderung dieses Werts eine **neue Fassung** an. Die Entscheidungsmarke wurde im MVP bewusst zurückgestellt (siehe Abschnitt 1). | [Code], MVP-Plan |
|
||||||
|
| HLS-Verarbeitung | `FfmpegFilmTranscoder`: 480/720/1080 p nacheinander, feste `BANDWIDTH`-Werte, keine ausgerichteten Keyframes; `DeriveFilmRenditions` wird **nur** aus `StoreContentFile` angestoßen (einzige Aufrufstelle, Zeile 86), verschluckt Fehler. Die Stufen hängen an der **Fassungs-Kennung** (`media_renditions.content_element_version_id`), und beide Controller lassen Dateien nur unter dem Präfix `ableitungen/{Fassungs-Kennung}` zu (`renditionBelongsTo`). | [Code] |
|
||||||
|
| Playlist-Umschreibung | `HlsPlaylist::rewrite` signiert nur Zeilen, die nicht mit `#` beginnen. Adressen in Tags (`#EXT-X-MAP:URI`, `#EXT-X-KEY:URI`) bleiben unsigniert. | [Code] |
|
||||||
|
| Signaturen | Abschnitte und Download-Adressen 10 Minuten. `playlist()` schreibt bei **jedem** Abruf einen `DeliveryLog`-Eintrag (`$record = true`). | [Code] |
|
||||||
|
| Download | Aktion `laden` (individuell gekennzeichnete Datei, Nachweis `DeliveryLog`). Ein Offline-Weg existiert nur darüber. | [Code], 08 §3.3 |
|
||||||
|
|
||||||
|
**Bestehender Fehler (Folgefund aus Fassung und Rendition):** Jede neue Filmfassung **ohne neue Datei** (Textänderung, Änderungsnotiz, Entscheidungsmarke; `ElementRevision` übernimmt nur `file`) erzeugt keine HLS-Stufen, weil `DeriveFilmRenditions` nur aus `StoreContentFile` startet. Die Fassung fällt in den Dateimodus (Prüfsumme über die ganze Datei, keine Bereichsabrufe, Performance-Analyse M1/M2). Das gilt **schon heute**, unabhängig von diesem Plan **[Code, aus den Aufrufstellen abgeleitet, nicht nachgestellt]**. Marken verschärfen es, weil jede Korrektur eine solche Fassung erzeugt. Reparatur in Stufe 0, Punkt 0.7. Ein bloßes Kopieren der `media_renditions`-Zeilen genügt **nicht**: `renditionBelongsTo` prüft den Präfix `ableitungen/{neue Kennung}`, kopierte Zeilen zeigen aber auf den Ordner der alten Fassung und würden bei jedem Abschnitt 404 liefern.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Zielbild und Architektur
|
||||||
|
|
||||||
|
### 3.1 Ein Kern, zwei Oberflächen
|
||||||
|
|
||||||
|
```
|
||||||
|
resources/js/player/
|
||||||
|
source.js Quelle anbinden: MP4 direkt oder HLS; hls.js per dynamischem Import, erst beim Start
|
||||||
|
fullscreen.js Vollbild: Element oder iOS-Rückfall, Ereignisse, Zustandswechsel, Stopp-Wächter
|
||||||
|
clip.js Oberfläche „Clip“ (Website): bisheriges card-clip.js-Verhalten + Vollbild
|
||||||
|
member.js Oberfläche „Mitglied“: eigene Bedienelemente, Marken, Autostopp, Qualität, Tastatur
|
||||||
|
markers.js reine Logik: Marken lesen, Überquerung erkennen, Wiederaufnahme-Schutz
|
||||||
|
quality.js Stufen, Auto/fest, Merken je Gerät
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Blade-Komponente `<x-player>`** ersetzt das Partial `content.video`. Eigenschaften: Quelle (Modus `file`/`hls`/`clip`), Poster, Marken, `skin` (`clip` oder `mitglied`), Größenhinweise. Sie wird von `member/content`, `member/article` und der Redaktionsvorschau (`content/player`) benutzt. Damit prüft die Redaktion Marken mit demselben Player, den Mitglieder sehen.
|
||||||
|
- **Der Kern ist die gemeinsame Schicht** (`source.js`, `fullscreen.js`, `markers.js`), die Oberflächen sind dünn. Das ist die „zentrale Komponente“ aus dem Auftrag, ohne Website-Clips mit Mitglieder-Bedienelementen zu überladen.
|
||||||
|
- **Hero-Video:** Empfehlung **außerhalb** der ersten Lieferung. Es ist eine dekorative Dauerschleife mit eigener Schaltfläche. Wenn Lars Vollbild dort wünscht, ist es nach Stufe 2 eine kleine Ergänzung (Entscheidung 2).
|
||||||
|
- **Eigener Player statt Bibliothek (Empfehlung).** Gründe: Marken auf der Zeitleiste, Autostopp mit Fragekarte, Qualitätsmenü und große Presenter-Bedienelemente sind Kernanforderungen; `hls.js` ist schon im Projekt; keine neue Lizenz und kein neuer Pflegestand zu prüfen. Preis: Barrierefreiheit (Tastatur, ARIA-Schieberegler, Zielgrößen) wird selbst gebaut und getestet. Bibliotheken wie Video.js, Plyr oder Vidstack habe ich **nicht geprüft** [unverifiziert]; vor einer Gegenentscheidung wären Lizenz, Pflegestand und Markerunterstützung zu prüfen.
|
||||||
|
|
||||||
|
### 3.2 Vollbild-Regeln (gelten für beide Oberflächen)
|
||||||
|
|
||||||
|
- **Ziel des Vollbilds:** auf der Website das `<video>` selbst (Clip, native Bedienelemente im Vollbild). Im Mitglieder-Player der **Container** mit eigenen Bedienelementen, damit Marken und Fragekarte sichtbar bleiben.
|
||||||
|
- **Neigerichtung (Entscheidung Nr. 11, Gerätetest):** Grundverhalten ist, dass das Vollbild der Gerätedrehung folgt (Darstellung `object-fit: contain`, Fläche `100dvh`/`100dvw`). Zwei Fälle erfüllen damit „den ganzen Bildschirm nutzen“ **nicht** von selbst: (a) Telefon hochkant gehalten: ein 16:9-Clip erscheint klein mit Rändern, bis das Gerät gedreht wird; (b) Drehsperre des Systems an: das Vollbild bleibt hochkant. Eine Sperre auf Querformat per Screen-Orientation-API (`lock('landscape')`; nach der Spezifikation erlaubt das beide Querrichtungen, nach meinem Kenntnisstand nur im Vollbild und nur in Chromium auf Android) würde beides lösen, nimmt aber die freie Drehung. **[unverifiziert]**, ob die Sperre eine Systemdrehsperre überstimmt und ob beide Querrichtungen frei bleiben. Plan: Der Gerätetest in Stufe 2 (Schritt 2.0) beantwortet das; Lars entscheidet danach zwischen „folgt dem Gerät“ (Vorgabe) und „Querformat-Clips öffnen im Querformat, wo möglich“. Auf dem iPhone gibt es diese Schnittstelle nicht, dort bestimmt das native Vollbild **[unverifiziert]**.
|
||||||
|
- **iPhone:** Für das Element-Vollbild ist auf dem iPhone mit dem nativen Videovollbild (`video.webkitEnterFullscreen()`, braucht geladene Metadaten und eine Bedienung) zu rechnen **[unverifiziert]**. Folgen: (a) die Metadaten müssen vor dem Aufruf da sein, das kollidiert mit der aufgeschobenen Quelle (`preload="none"`); (b) eigene Überlagerungen sind im nativen Vollbild unsichtbar. Der bestehende Knopf „Vollbild“ im Mitgliederbereich hat dieselbe Lücke und wird mit demselben Modul behoben.
|
||||||
|
- **Zustand beim Wechsel (festzulegen, hier die Empfehlung):**
|
||||||
|
|
||||||
|
| Ereignis | Verhalten Clip (Website) |
|
||||||
|
|---|---|
|
||||||
|
| Eintritt | Ton an, keine Schleife, `controls` an, `aria-hidden` und `tabindex` zurückgenommen, Fokus auf das Video bzw. den Beenden-Knopf. Läuft der Clip schon (Hover oder Ton), läuft er weiter, sonst startet er (Ton nicht erlaubt: stumm weiter). Andere Clips werden gestoppt. |
|
||||||
|
| Stopp-Auslöser | Scroll-Wächter (`IntersectionObserver`), `pointerleave` (Hover-Modus) und `visibilitychange` sind im Vollbild **ausgesetzt**. Nach dem Austritt gilt wieder die normale Regel. |
|
||||||
|
| Austritt (Esc, Zurück-Geste, Beenden-Knopf) | Clip hält an und springt in den Kartenzustand zurück (`stop()`): Kartenbild sichtbar, Zeit 0, `controls` und `aria-hidden` wiederhergestellt. |
|
||||||
|
| Ende des Clips | Austritt aus dem Vollbild, danach wie „Austritt“. |
|
||||||
|
| Fehler | Austritt, Schaltfläche ausblenden, Kartenbild bleibt (wie heute). |
|
||||||
|
| Ereignisse | `fullscreenchange` und `webkitfullscreenchange` am Dokument, `webkitbeginfullscreen`/`webkitendfullscreen` am Video (iOS). Außerdem muss der Aufruf **in der Bedienung** (gleiche Aufrufkette wie der Tipp) erfolgen, sonst lehnt der Browser ab. |
|
||||||
|
|
||||||
|
- **Rechte:** Vollbild ist eine Darstellung derselben, bereits freigegebenen Datei über `website.media`. Es gibt keine neue Adresse und keine Freigabe; ein nicht freigegebener Clip hat auch keinen Vollbild-Knopf.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Daten- und Berechtigungsmodell
|
||||||
|
|
||||||
|
### 4.1 Website: Einstellung `fullscreen`
|
||||||
|
|
||||||
|
- **Mechanismus (gelesen):** Widgets deklarieren Einstellungen über `settings()` (Schlüssel → Auswahl), `settingGroups()` und `settingLabels()`; gelesen wird mit `$option('schlüssel', 'vorgabe')`. Bei den Premium-Karten gibt es `clip` (`yes`/`no`, Vorgabe `yes`) **nur**, wenn `supportsClip()` wahr ist (Basisklasse `false`, die Medien-, Programm- und Modulkarte überschreiben es). Das Bild-und-Text-Widget hat **keine** `clip`-Einstellung: Das Video spielt, sobald `refs.video` gesetzt und freigegeben ist. Die neue Option `fullscreen` (`yes`/`no`) kommt in beiden Fällen in die Gruppe „Bild und Video“, bei Bild und Text als neue Einstellung in `settings()`. Wo die gewählten Einstellungen im gespeicherten Widget liegen und ob `version()`/`upgrade()` berührt werden, ist **vor Stufe 2 zu lesen** (nicht geprüft). Erwartet wird keine Schemaänderung der Datenbank.
|
||||||
|
- **Vorgabe für bereits gespeicherte Widgets** ist eine Entscheidung (Nr. 1): `$option('fullscreen', 'no')` verändert keine bestehende Seite; `yes` schaltet sie bei allen Karten mit Clip ein. Ein Unterschied „bestehend/neu“ gibt der Optionsmechanismus mit nur einem Vorgabewert nicht her. **Empfehlung: Vorgabe „Aus“** (keine unangekündigte Änderung), neue Karten bewusst einschalten.
|
||||||
|
- Bedienung auf der Karte: eigene kleine Schaltfläche neben dem Abspielsymbol, nur sichtbar, wenn der Clip bereit ist und die Option gesetzt ist. Der Tipp auf das Bild bleibt unverändert „abspielen mit Ton im Bild“ (der Auftrag nennt das Verhalten als gut gelöst). Mit Tastatur erreichbar, Beschriftung „Vollbild: {Titel}“.
|
||||||
|
- Dokumentation: ADR-43 wird ergänzt (Nachtrag), `cms-widget-registry.md` und `medienzugriff-fuer-komponenten.md` nachgeführt.
|
||||||
|
|
||||||
|
### 4.2 Mitglieder: eine Markenliste je Fassung
|
||||||
|
|
||||||
|
- Eine Liste `metadata['markers']` an der Filmfassung (Architektur 08 §3.3: „Sprungmarken sind Metadaten der Filmfassung“): `[{ "t": 42.0, "label": "Entscheidung", "stop": true, "prompt": "…optionaler Reflexionstext…" }]`. Kapitel sind Marken ohne `stop`. **Eine** Liste, kein zweites Feld für Kapitel.
|
||||||
|
- `decision_seconds` wird als **Altwert gelesen** (eine Marke „Entscheidung“, `stop: true`) und nicht migriert. Ein Leser `PlaybackMarkers::for($version)` ist die einzige Stelle, die beides kennt. Keine Schemaänderung (JSON-Metadaten).
|
||||||
|
- Prüfregeln beim Speichern: Zeit ≥ 0, aufsteigend, keine zwei Marken innerhalb von 1 s, Titel kurz, Fragetext als einfacher Text (kein HTML) oder `FormattedText` mit fester Auswahl (festzulegen). Die Filmlänge ist nur bekannt, wenn `ffprobe` sie liefert **[unverifiziert, ob schon gespeichert]**; ohne sie kann die Obergrenze nicht geprüft werden, die Anzeige blendet Marken jenseits des Endes aus.
|
||||||
|
- **Folge der Bindung an die Fassung:** Eine Korrektur der Marken ist eine **neue Fassung** (heute schon so für `decision_seconds`). Mitglieder sehen sie erst, wenn ein neuer Artikel-Stand die Fassung enthält. Das ist konsistent mit der Unveränderlichkeit (08 §1), aber für „Marke um 3 Sekunden verschieben“ aufwendig. Alternative (nicht empfohlen): Marken als redaktionelle Darstellungsdaten außerhalb der Fassung, dann ohne neuen Stand änderbar, aber ohne Versionierung. Entscheidung Nr. 4.
|
||||||
|
- **Rendition übernehmen (Reparatur eines bestehenden Fehlers, Abschnitt 2):** Beim Anlegen einer Fassung ohne neue Datei werden die `media_renditions`-Zeilen auf die neue Fassung kopiert (gleiche Pfade). Damit die Auslieferung sie akzeptiert, ersetzt `renditionBelongsTo` in `LibraryController` **und** `ContentPreviewController` den festen Präfix `ableitungen/{Kennung}` durch eine Prüfung gegen die **eigenen** `media_renditions`-Zeilen der Fassung (erlaubt ist das Verzeichnis ihres Master-Pfads; weiterhin kein `..`). Die Bindung an genau ein Stream-Format einer Fassung (08 §3.1: Fremdmedium, Prüffall INV-17) bleibt damit erhalten und wird durch einen Test gesichert (Fassung A darf nie Abschnitte von Fassung B abrufen). Bestehende Fassungen ohne Stufen findet ein einmaliger lesender Prüfbefehl; das Nachziehen ist ein einmaliger Auftrag, keine Migration.
|
||||||
|
- Redaktionsmaske: ein Wiederholfeld (Zeit als mm:ss, Titel, „hier anhalten“, optionaler Text) in `ElementRevision::fields()`, dazu „Zeit aus der Vorschau übernehmen“ (aktuelle Position des Vorschau-Players). Vorschau über `<x-player>`.
|
||||||
|
|
||||||
|
### 4.3 Vorab laden: Berechtigung und Nachweis
|
||||||
|
|
||||||
|
- „Vorab laden (Sitzung)“ benutzt dieselben signierten Abschnitts-Adressen wie das Streamen und braucht **keine neue Aktion im Rechteprofil**. Ob die Lizenzbedingungen einen vollständig auf dem Gerät der Nutzerin oder des Nutzers gehaltenen Film abdecken, ist eine Rechtsfrage für Legal (Entscheidung Nr. 6), keine technische.
|
||||||
|
- **Auslieferungsnachweis:** `playlist()` schreibt bei jedem Abruf einen Eintrag. Wiedergabe-Erneuerung (0.1) und „Vorab laden“ würden die Einträge vervielfachen. Plan: Erneuerung und Nachladen rufen `playlist(..., record: false)` bzw. zählen nur den **ersten** Abruf je Wiedergabesitzung; Abschnittsabrufe schreiben nichts. Die genaue Zählweise („was ist eine Auslieferung“) ist Teil von Entscheidung Nr. 10 und von A2 der Performance-Analyse.
|
||||||
|
- „Dauerhaft offline“ ist ausgeschlossen (Stufe 5 entfällt).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. Stufenplan
|
||||||
|
|
||||||
|
### 5.1 Abhängigkeiten und Aufwand
|
||||||
|
|
||||||
|
Aufwand: S unter 1 Tag, M 1–3 Tage, L mehrere Tage. **Alle Zahlen sind Schätzungen, nicht gemessen**; Gerätetests und Abnahme auf luf-test sind eingerechnet, Wartezeiten auf Entscheidungen nicht.
|
||||||
|
|
||||||
|
| Stufe | Braucht | Schätzung (Personentage) |
|
||||||
|
|---|---|---|
|
||||||
|
| 0 Voraussetzungen | Entscheidung Nr. 10 für 0.1; Freigabe von Lars für alles, was `docker-compose.yml` berührt (zweiter Worker) | 12–22 (Summe der Punkte 0.1–0.9) |
|
||||||
|
| 1a Kern Website (`fullscreen.js`, `clip.js`, `source.js`) | nichts aus Stufe 0 | 2–3 |
|
||||||
|
| 1b Kern Mitglieder (`markers.js`, `quality.js`, `<x-player>`) | 1a; Testläufer (Nr. 9) | 3–4 |
|
||||||
|
| 2 Website-Vollbild | **1a**; Entscheidungen Nr. 1, 11; **0.9 empfohlen, nicht zwingend** (sonst Hinweis in der Abnahme) | 3–5 |
|
||||||
|
| 3 Mitglieder-Player | 1b; **0.1, 0.6, 0.7, 0.8 zwingend** (Autostopp); 0.4 und 0.5 für das Qualitätsmenü (3.5); 0.2 und 0.3 für Springen im Dateimodus | 10–15 |
|
||||||
|
| 4 Vorab laden | 3 (Quelle und Lader), 0.1; 0.5 empfohlen; Legal-Antwort aus Nr. 6 vor Auslieferung | 3–4 |
|
||||||
|
|
||||||
|
**Gesamt:** Teil 1 (1a + 2) etwa 5–8 Tage. Teil 2 (0 + 1b + 3) etwa 25–41 Tage. Stufe 4 kommt dazu. Die Spannweite ist groß, weil 0.5 (HLS-Neukodierung mit Bestand) und 3.1 (eigene Bedienelemente) unsichere Posten sind.
|
||||||
|
|
||||||
|
### 5.2 Rahmen für alle Stufen
|
||||||
|
|
||||||
|
Jede Stufe ist ein `feature/*`-Branch, der in `develop` mündet. Jede Verhaltensänderung bringt Tests mit (CLAUDE.md). Migrationen nur additiv. Änderungen an `docker-compose.yml`, `docker/nginx/`, `Dockerfile` und den Workflows nur mit Freigabe von Lars und Nachführung in `docs/betrieb/DEPLOYMENT.md`. Nichts auf `main`, nichts von Hand deployt.
|
||||||
|
|
||||||
|
### Stufe 0: Voraussetzungen (Paket A/B der Performance-Analyse, hier nur der Teil, den der Player braucht)
|
||||||
|
|
||||||
|
| Nr. | Maßnahme | Warum für den Player | Aufwand |
|
||||||
|
|---|---|---|---|
|
||||||
|
| 0.1 | **Signaturerneuerung (A5):** kleiner Endpunkt liefert der angemeldeten Person eine frische signierte Wiedergabeliste (`DecideAccess` erneut, **ohne** neuen `DeliveryLog`-Eintrag, Abschnitt 4.3); der Player holt sie bei Fehler 403 und nach einer Pause über einer Grenze und setzt an der gleichen Stelle fort. Daneben Laufzeit der Abschnitte auf Filmlänge plus Reserve. | Pause am Stoppunkt über 10 Minuten. | M |
|
||||||
|
| 0.2 | **Bereichsabrufe im Mitgliederbereich (A2)** | Springen zu Kapiteln im Dateimodus, Safari/iOS. | M |
|
||||||
|
| 0.3 | **Prüfsumme einmalig (A1)** | Start im Dateimodus ohne Wartezeit. | S–M |
|
||||||
|
| 0.4 | **HLS sichtbar machen (A6):** Status je Film (wird verarbeitet / fertig / fehlgeschlagen), Protokoll, Wiederholung, eigene Warteschlange. | Ohne Stufen kein Qualitätsmenü. | M |
|
||||||
|
| 0.5 | **HLS überarbeiten (B2):** ausgerichtete Keyframes, `-hls_segment_type fmp4`, `-maxrate`/`-bufsize` passend zu `BANDWIDTH`, Quelle einmal lesen. **Neue Ausgabe in neue Pfade** (Unterordner unter `ableitungen/{Kennung}/`, passt zu `renditionBelongsTo`), Umschalten der Master-Zeile erst nach vollständigem Erfolg; Ableitungen sind unveränderlich (08 §1), laufende Wiedergaben dürfen nicht brechen. Nachkodieren des Bestands als einmaliger Auftrag. **Playlist-Umschreibung erweitern:** fMP4-Wiedergabelisten tragen das Initialsegment in `#EXT-X-MAP:URI="…"`, `HlsPlaylist::rewrite` überspringt alle `#`-Zeilen, die Adresse ginge **unsigniert** hinaus. `rewrite` muss URIs in `#EXT-X-MAP` (und für Stufe 5 `#EXT-X-KEY`) erkennen und signieren; Unit-Test mit fMP4-Beispiel in `HlsPlaylistTest`, Test, dass keine unsignierte Adresse der Wiedergabeliste übrig bleibt. | Saubere Qualitätswechsel, brauchbare adaptive Wahl. | M–L |
|
||||||
|
| 0.6 | **`hls.js` aufgeschoben laden (A7):** dynamischer Import, `autoStartLoad: false`, Start erst beim Abspielen; in Listen `preload="none"` mit Poster. | Bundle kleiner, Artikelseite mit mehreren Filmen lädt nicht alle gleichzeitig. | S |
|
||||||
|
| 0.7 | **Rendition übernehmen** beim Anlegen einer Fassung ohne neue Datei, samt angepasster `renditionBelongsTo`-Prüfung in beiden Controllern (Abschnitt 4.2). Ein **bestehender** Fehler, nicht erst durch Marken verursacht. Test zuerst (rot): neue Fassung ohne Datei streamt weiter über HLS; Fassung A erreicht keine Abschnitte von Fassung B. | Markenänderung darf Streaming nicht zerstören. | S–M |
|
||||||
|
| 0.8 | **Zurückgestellte Entscheidungsmarke aufheben und bereinigen:** der MVP-Plan hat Knopf und Marke bewusst entfernt (Abschnitt 1). Die Aufhebung wird im Commit begründet. `data-course-decision`/`data-course-restart`/`data-decision` aus `app.js` (der Rest des Handlers bleibt funktionslos), `assertDontSee('Zur Entscheidungsmarke')` in `CoursePlayerTest` bewusst durch Tests der neuen Marken ersetzen. | Kein zweiter, unverbundener Autostopp-Weg. | S |
|
||||||
|
| 0.9 | **Website-Profil für Clips (B1):** `faststart`, höchstens 720 p, Bitratengrenze, Warnung bei zu großen Dateien. | Vollbild und Handy brauchen schnelle Metadaten, sonst stockt der Start. | M–L |
|
||||||
|
|
||||||
|
**Abnahme Stufe 0:** Tests je Punkt (Feature-Tests für Endpunkt, Berechtigung, Rendition-Übernahme; Unit-Tests für Playlist-Umschreibung); auf luf-test: ein Film über 10 Minuten (oder verkürzte Signaturdauer als Testwert) wird nach Pause fortgesetzt; HLS-Status sichtbar.
|
||||||
|
|
||||||
|
### Stufe 1: Gemeinsamer Kern (1a Website, 1b Mitglieder)
|
||||||
|
|
||||||
|
**1a** liefert `source.js`, `fullscreen.js` und `clip.js` (Voraussetzung für Stufe 2). **1b** liefert `markers.js`, `quality.js` und `<x-player>` (Voraussetzung für Stufe 3). Beide hängen nur von der Datei-Struktur ab, nicht von Stufe 0.
|
||||||
|
|
||||||
|
- `resources/js/player/` mit `source.js`, `fullscreen.js`, `markers.js`, `quality.js`; `<x-player>`; `card-clip.js` wird auf `clip.js` umgestellt **ohne Verhaltensänderung** (bestehende Hover-/Tipp-/Scroll-Regeln bleiben, durch Tests gesichert).
|
||||||
|
- **JS-Tests:** Das Projekt hat bisher keine JS-Testumgebung (`package.json`: nur `vite`, `tailwindcss`). Reine Logik (`markers.js`: Überquerung vorwärts, Wiederaufnahme-Schutz, Seek über eine Marke; Zustandsmaschine des Vollbilds) wird mit einem kleinen Testläufer (z. B. Vitest, neue Entwicklungsabhängigkeit, Entscheidung Nr. 9) geprüft; Browserverhalten mit dem vorhandenen Weg über Playwright/Pest-Browser.
|
||||||
|
- Regel für die Marken-Erkennung: `timeupdate` feuert nur etwa viermal pro Sekunde **[unverifiziert, browserabhängig]**; für die Genauigkeit des Stopps `requestVideoFrameCallback` verwenden, wo vorhanden, sonst Abfrage per `requestAnimationFrame`. Eine Marke löst nur bei natürlichem Vorwärtslauf aus (nicht beim Springen darüber) und wird nach dem Weiter-Drücken für diese Position übersprungen. Erwartete Genauigkeit: einzelne Bilder bis etwa 250 ms (**Planungswert**), ein Stoppen *kurz nach* der Marke ist zulässig, ein Stoppen *vor* der Marke nicht.
|
||||||
|
- **Abnahme:** Gate grün (Pint, `php artisan test`), Karten verhalten sich auf luf-test wie vorher (Screenshots, Vergleich), Bundle-Größe vorher/nachher in den Bericht.
|
||||||
|
|
||||||
|
### Stufe 2: Website-Vollbild (Teil 1 des Auftrags)
|
||||||
|
|
||||||
|
**2.0 Kurzprobe auf echten Geräten (erster Schritt, vor dem Bau der Oberfläche).** Ein Wegwerf-Prototyp (nicht im Repository oder auf einem Wegwerf-`feature`-Branch) mit einem freigegebenen Testclip auf luf-test. Bestanden, wenn auf dem **aktuellen und dem vorherigen** iOS-Hauptstand (iPhone), einem Android-Gerät mit Chrome und einem iPad gilt: (1) Tipp spielt inline mit Ton, (2) Vollbild-Knopf öffnet Vollbild und der Clip läuft weiter oder startet, (3) Drehen hoch/quer nutzt den ganzen Bildschirm bzw. verhält sich wie in Entscheidung Nr. 11 beschrieben, (4) Zurück-Geste oder Beenden führt in den Kartenzustand zurück. Das Ergebnis je Gerät steht als Tabelle im Bericht. Bei einem Fehlschlag auf iOS wird Teil 1 dort eingeschränkt (Schaltfläche ausgeblendet), bevor Aufwand in die Oberfläche fließt.
|
||||||
|
|
||||||
|
1. Option `fullscreen` an `PremiumCardWidget` (Medien-, Programm- und Modulkarte) und am Bild-und-Text-Widget; Hinweistext im Dialog, `cms-widget-registry.md`, ADR-43-Nachtrag.
|
||||||
|
2. Schaltfläche und Zustandsregeln aus Abschnitt 3.2 in `clip.js`; Stopp-Wächter im Vollbild ausgesetzt; Austritt und Ende wie festgelegt.
|
||||||
|
3. iPhone-Rückfall: Metadaten nachladen (bei Karten mit Vollbild `preload="metadata"` erst nach dem ersten Bedienkontakt, nicht beim Seitenaufbau, sonst lädt jede Karte vorab), dann nativer Vollbildaufruf. Ablauf: Bedienung → Quelle setzen → `play()` in der Bedienung → Vollbild bei `loadedmetadata`/`playing`. Bestehen nur nach Gerätetest, sonst Rückfall „Vollbild nicht angeboten“ auf diesem Gerät (die Schaltfläche bleibt ausgeblendet, wenn weder Element-Vollbild noch `webkitEnterFullscreen` verfügbar sind).
|
||||||
|
4. Optional (Entscheidung Nr. 2): Hero-Video bekommt dieselbe Schaltfläche.
|
||||||
|
5. Barrierefreiheit: Fokus, Beschriftung, `prefers-reduced-motion` (Vollbild startet nicht von selbst, nur auf Bedienung, wie heute der Clip).
|
||||||
|
|
||||||
|
**Tests:** Feature-Tests (Option gespeichert, Vorgabe, Ausgabe der Schaltfläche nur mit freigegebenem Clip und gesetzter Option; keine Adresse außerhalb `website.media`); Playwright (Desktop Chromium/Edge: Ein- und Austritt, Esc, Stopp-Wächter im Vollbild, Ende im Vollbild, Rückkehr in den Kartenzustand; Mobil-Emulation nur für Layout).
|
||||||
|
**Abnahme auf luf-test:** Screenshots breit und schmal; **echte Geräte** (Lars oder Testperson): iPhone (iOS-Version notieren), Android-Chrome, iPad, Drehung hoch/quer im Vollbild, Zurück-Geste, Ton. **Emulation beweist das iPhone-Verhalten nicht.**
|
||||||
|
|
||||||
|
### Stufe 3: Mitglieder-Player (Teil 2 des Auftrags)
|
||||||
|
|
||||||
|
| Nr. | Funktion | Umsetzung | Aufwand |
|
||||||
|
|---|---|---|---|
|
||||||
|
| 3.1 | **Bedienelemente** | Eigene Leiste: Abspielen/Pause, Zeitleiste (ARIA-Schieberegler, Tastatur), Lautstärke, Zeit, Qualität, Vollbild. Zielgrößen groß genug für Beamer-Fernbedienung und Touch. Keine eingeblendeten Fremdelemente im Vollbild. | M–L |
|
||||||
|
| 3.2 | **Kapitelmarker** | Striche auf der Zeitleiste mit Titel bei Hover/Fokus, Kapitelliste (Menü), „nächstes/voriges Kapitel“. | M |
|
||||||
|
| 3.3 | **Vollbild** | Container-Vollbild (Leiste und Fragekarte bleiben sichtbar); auf dem iPhone nativer Rückfall (Abschnitt 3.2); Bedienung per Tastatur `F`. | S–M |
|
||||||
|
| 3.4 | **Autostopp** | Marken mit `stop: true` halten an der Stelle an (Abschnitt 3.2/Stufe 1 für die Genauigkeit), zeigen den optionalen Fragetext, „Weiter“ setzt fort. Je Video über die Marken konfiguriert; **Schalter „Automatische Stopps“** im Player (Vorgabe an, gemerkt je Gerät), wie in 08 §3.3 („abschaltbar“). Zusätzlich „Szene erneut“ (zurück zur vorigen Marke). Im **nativen iPhone-Vollbild** (eigene Überlagerung unsichtbar) wird am Stopp angehalten und das native Vollbild verlassen, damit die Fragekarte sichtbar wird **[Verhalten nach Gerätetest festschreiben]**. | M |
|
||||||
|
| 3.5 | **Optimale Auflösung** | `hls.js` mit `capLevelToPlayerSize: true` (Standard bleibt Auto), Neuberechnung beim Wechsel ins Vollbild (Grenze muss nach dem Vergrößern neu gelten, Verhalten prüfen **[unverifiziert]**) und **manuelle Wahl** (Auto / 1080 p / 720 p / 480 p; „Beste Qualität“ sperrt auf die höchste Stufe, für den Beamer). Wahl je Gerät in `localStorage` (alle Zugriffe in `try/catch`, Seite funktioniert ohne). Hinweis: Ein Beamer meldet dem Browser die Auflösung des Ausgangs, ein kleiner eingebetteter Player auf dem Beamer würde bei `capLevelToPlayerSize` eine niedrige Stufe wählen. Darum die Neuberechnung im Vollbild und die manuelle Wahl. Eine Stufe über 1080 p ist **nicht** vorgesehen (Entscheidung Nr. 8). | M |
|
||||||
|
| 3.6 | **Presenter-Tasten** | Leertaste/`K` Abspielen, Pfeile ±5 s, `N`/`P` nächstes/voriges Kapitel, `M` Ton, `F` Vollbild, `Esc` Vollbild verlassen. | S |
|
||||||
|
| 3.7 | **Redaktionsmaske für Marken** | Siehe 4.2; Vorschau mit demselben Player; Übernahme der aktuellen Position. | M |
|
||||||
|
| 3.8 | **Fehler und Wiederaufnahme** | Klare Meldung bei Abbruch, Wiederaufnahme an derselben Stelle (nutzt 0.1). | S–M |
|
||||||
|
|
||||||
|
**Tests:** Feature-Tests (Marken lesen inklusive Altwert `decision_seconds`, Speichern und Prüfregeln, Rechte unverändert über `DecideAccess`, kein Zugriff auf Originale); Unit-Tests der Markenlogik; Playwright-Szenarien (Stopp an der Marke, Weiter, Springen über eine Marke löst nicht aus, Pause über der Signaturdauer, Qualitätsmenü, Tastatur).
|
||||||
|
**Abnahme auf luf-test:** Screenshots Desktop breit/schmal und Mobil nach `docs/ux/mitgliederbereich/abnahme-luftest/`; Test mit **Beamer** (HDMI, 1080 p; vorhandene Auflösung und Seitenverhältnis notieren), Tastatur-/Presenter-Fernbedienung, iPhone und Android.
|
||||||
|
|
||||||
|
### Stufe 4: „Vorab laden (Sitzung)“
|
||||||
|
|
||||||
|
- Schaltfläche „Vor der Stunde laden“: der Player holt alle Abschnitte **einer** gewählten Stufe (Vorgabe: die Stufe, die gerade läuft, oder „Beste Qualität“) über einen eigenen Lader von `hls.js` in eine Zuordnung im Arbeitsspeicher; das Abspielen bedient sich daraus. Ohne Service Worker, ohne Cache-API, ohne dauerhaften Speicher; funktioniert auch über HTTP.
|
||||||
|
- Fortschrittsanzeige, Abbruch, klare Meldung bei Speichermangel; danach läuft der Film bei getrennter Verbindung, solange die Seite offen bleibt (Seite neu laden = verloren). Signaturen sind für diese Zeit unkritisch, weil alle Abschnitte schon geladen sind.
|
||||||
|
- **Speichergröße (Planungswert, nicht gemessen):** Film 10 Minuten bei etwa 5 Mbit/s ≈ 375 MB; 30 Minuten ≈ 1,1 GB. Vor dem Laden wird die erwartete Größe gezeigt, eine **Obergrenze** schützt vor Abstürzen (besonders Mobilgeräte); über der Grenze wird auf die nächstniedrigere Stufe verwiesen. Die Grenze wird in der Stufe gemessen und festgelegt.
|
||||||
|
- **Rechte:** Es entsteht keine Datei und kein Download. Der Nachweis `DeliveryLog` ist der des Streamens.
|
||||||
|
- **Tests:** Unit-Tests des Laders (Zuordnung, Abbruch, Fortschritt), Playwright mit gedrosseltem/abgeschaltetem Netz (Verbindung nach dem Laden trennen, Film läuft; Seite neu laden, Film läuft nicht ohne Verbindung).
|
||||||
|
|
||||||
|
### Stufe 5: Dauerhaftes Offline-Laden (entfällt)
|
||||||
|
|
||||||
|
Von Lars am 30.11.2026 ausgeschlossen. Es gibt keinen Service Worker, keine Cache-API, keine lokale Ablage von Abschnitten oder Schlüsseln und keine Aktion `offline`. Wer ohne Verbindung vorführen muss, nutzt „Vorab laden (Sitzung)“ (Stufe 4) oder, mit entsprechender Berechtigung, den bestehenden Download (`laden`, individuell gekennzeichnete Datei, 08 §3.3). Sollte die Anforderung später wiederkehren, ist sie eine neue Entscheidung mit Legal, Datenschutzbeauftragtem und HTTPS-Testumgebung. Dieser Plan bereitet sie nicht vor, verbaut sie aber auch nicht (HLS-Format und Signierung bleiben dieselben).
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. Risiken
|
||||||
|
|
||||||
|
| Risiko | Wirkung | Gegenmaßnahme |
|
||||||
|
|---|---|---|
|
||||||
|
| iPhone-Vollbild verhält sich anders als erwartet | Teil 1 auf iOS nur eingeschränkt | Gerätetest in Stufe 2 vor dem Bau der Oberfläche (Kurzprobe), Schaltfläche verschwindet, wo nichts geht |
|
||||||
|
| 85-MB-Clip ohne `faststart` | Start im Vollbild auf dem Handy lahm | 0.9 vor Stufe 2 oder Hinweis in der Abnahme |
|
||||||
|
| Eigener Player: Barrierefreiheit und Randfälle | Aufwand höher als Bibliothek | Tastatur- und Screenreader-Prüfung in der Abnahme; Entscheidung Nr. 3 |
|
||||||
|
| Marken-Korrektur = neue Fassung und neuer Stand | Redaktionsaufwand | Entscheidung Nr. 4; Maske zeigt, dass eine neue Fassung entsteht |
|
||||||
|
| Rendition geht bei neuer Fassung verloren | Film fällt in Dateimodus | 0.7 und Prüfbefehl |
|
||||||
|
| Speicherverbrauch „Vorab laden“ | Abbruch auf Mobilgeräten | Größenanzeige, Obergrenze, nur eine Stufe |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 7. Tests und Abnahme (Gesamt)
|
||||||
|
|
||||||
|
- **Gate** (`scripts/ci-test.sh`: Pint und `php artisan test`) für jeden Branch; ein roter Test wird behoben, nicht umgangen (CLAUDE.md). Neue PHP-Tests: `Fakes` für Mail, Zahlung, externe Dienste; keine Tests gegen Prod; keine Zurücksetzung der Schemas von `luf-test`.
|
||||||
|
- **Instanz-Suite** (Pest-Browser/Playwright gegen luf-test) für Browserabläufe, ohne `RefreshDatabase` oder `migrate:fresh` auf `luf-test`. Diese Suite wird laut CLAUDE.md mit U0 angelegt; bis dahin laufen die Browserprüfungen als Abnahme von Hand mit dem vorhandenen Werkzeug (`playwright-core`, `msedge`).
|
||||||
|
- **Gerätematrix (von Lars oder Testpersonen, nicht von mir ausführbar):** iPhone (Safari), Android (Chrome), iPad, Windows (Edge/Chrome/Firefox), macOS (Safari), Beamer über HDMI. Ergebnis je Zeile als Tabelle im Abnahmebericht.
|
||||||
|
- **Nachweis:** Screenshots je UI-Änderung (breit, schmal, Tastaturfokus) unter `docs/ux/mitgliederbereich/abnahme-luftest/` bzw. `docs/ux/verwaltung/abnahme/` (Maske).
|
||||||
|
- **Dokumentation:** ADR-70 „Zentraler Videoplayer“ (nächste freie Nummer; Nachtrag zu ADR-43 und Änderung von 08 §3.3), `medienzugriff-fuer-komponenten.md`, `cms-widget-registry.md`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 8. Entscheidungen für Lars
|
||||||
|
|
||||||
|
| Nr. | Frage | Empfehlung |
|
||||||
|
|---|---|---|
|
||||||
|
| 1 | Vorgabe der Vollbild-Option für **bestehende** Widgets: Aus oder An? Bedienung per eigener Schaltfläche (oder zusätzlich Doppeltipp)? | **Aus**, eigene Schaltfläche; neue Karten bewusst einschalten. Änderung am Verhalten aus ADR-43 als Nachtrag. |
|
||||||
|
| 2 | Hero-Video in den Vollbild-Umfang aufnehmen? | Nicht in der ersten Lieferung; danach klein nachziehbar. |
|
||||||
|
| 3 | Eigener Player (empfohlen) oder Bibliothek (Video.js/Plyr/Vidstack, ungeprüft)? | Eigener Player über `hls.js`. |
|
||||||
|
| 4 | Marken an die **Fassung** binden (neue Fassung und neuer Artikel-Stand je Korrektur) oder als Darstellungsdaten außerhalb? | An die Fassung (Architektur 08, Unveränderlichkeit). |
|
||||||
|
| 5 | Autostopp: nur je Marke im Film konfiguriert, oder zusätzlich ein Schalter für Zuschauende („Automatische Stopps“)? Wirkung im nativen iPhone-Vollbild wie beschrieben? | Beides: je Marke konfigurierbar, Schalter im Player, Vorgabe an. |
|
||||||
|
| 6 | **Vorab laden (Sitzung):** **Legal** klärt vorab, ob die Lizenzbedingungen den Film vollständig im Arbeitsspeicher des Nutzergeräts abdecken (Rechtsfrage, nicht technisch). Wenn nicht, wird Stufe 4 zurückgestellt oder die Bedingung ergänzt. | Stufe 4 erst nach Antwort von Legal. |
|
||||||
|
| 7 | ~~HTTPS-Adresse für die Testinstanz~~ | entfällt mit Stufe 5. |
|
||||||
|
| 8 | Qualitätsstufen: bei 480/720/1080 bleiben, oder 2160 p für Beamer? Welche Auflösung haben die üblichen Beamer? | Bei 1080 p bleiben; Beamer-Auflösungen vorab erheben. |
|
||||||
|
| 9 | Neue Entwicklungsabhängigkeit für JS-Tests (z. B. Vitest) erlaubt? | Ja, nur als Entwicklungsabhängigkeit. |
|
||||||
|
| 10 | Signaturdauer und Erneuerung (A5): Filmlänge plus Reserve plus Erneuerung per Endpunkt, oder nur kurze Prüfung beim Ausstellen? Wie lang darf die Nachlaufzeit nach Entzug sein? **Was zählt als „Auslieferung“ im Nachweis** (erster Abruf je Wiedergabesitzung statt jeder Abruf; Erneuerung und Nachladen schreiben nichts)? Zählweise auch mit dem Datenschutzbeauftragten abstimmen. | Erneuerung per Endpunkt mit `DecideAccess`, Dauer Filmlänge plus Reserve, Nachweis nur beim ersten Abruf. |
|
||||||
|
| 11 | **Neigerichtung im Vollbild:** dem Gerät folgen (Vorgabe) oder Querformat-Clips nach Möglichkeit im Querformat öffnen (Sperre per Schnittstelle, nur wo verfügbar)? Entscheidung nach der Kurzprobe 2.0. | Dem Gerät folgen; Sperre nur, wenn die Probe zeigt, dass Hochkant-Haltung oder Systemsperre das Ergebnis unbrauchbar macht. |
|
||||||
|
|
||||||
|
**Entschieden von Lars am 01.12.2026** (die Empfehlungen oben gelten dort, wo nichts anderes steht):
|
||||||
|
|
||||||
|
| Nr. | Entscheidung |
|
||||||
|
|---|---|
|
||||||
|
| 1, 11 | Bestätigt: Vorgabe „Aus“, Vollbild folgt der Gerätelage, keine Ausrichtungssperre. Nr. 2 (Hero-Video) bleibt außerhalb dieser Lieferung. |
|
||||||
|
| 3 | Eigener Player über `hls.js`. |
|
||||||
|
| 4 | **Marken gehören zur Fassung, mit Arbeitsstand davor (Hybrid).** Lars will nicht für jede kleine Korrektur eine neue Fassung erzeugen; die Variante „Marken außerhalb der Fassung“ wurde erwogen und wegen der Bindung an die konkrete Datei verworfen. Verlangt ist stattdessen eine saubere **Vorabanzeige**, in der Marken explizit gesetzt und kontrolliert werden können, bevor eine Fassung entsteht. Umsetzung (Vorschlag, noch nicht gebaut): Arbeitsstand der Marken am Medium, bearbeitet im Marker-Editor mit Vorschau-Player (Sprung zur Marke, Stopp-Probelauf), analog zur Redaktion („nur Speichern schreibt“). Beim Erzeugen der Fassung wird der Arbeitsstand als `metadata['markers']` in die Fassung geschrieben. Bei neuer Datei wird der Stand der letzten Fassung als Vorschlag übernommen und als „prüfen“ gekennzeichnet. Korrekturen an einer **bereits freigegebenen** Fassung erzeugen weiterhin eine neue Fassung; das ist die akzeptierte Rückfalllösung. Noch zu klären: Berechtigung für den Marker-Editor, ob der Arbeitsstand protokolliert wird. |
|
||||||
|
| 5 | Je Marke konfigurierbar plus Schalter „Automatische Stopps“ im Player, Vorgabe an. |
|
||||||
|
| 8 | Bei 1080 p bleiben; Beamer-Auflösungen vorab erheben (Lars). |
|
||||||
|
| 9 | Vitest als Entwicklungsabhängigkeit. Aufnahme ins Gate ändert `scripts/ci-test.sh`: gezielt, mit Begründung, nachgeführt in `docs/betrieb/DEPLOYMENT.md`. |
|
||||||
|
| 10 | Erneuerung per Endpunkt mit `DecideAccess`, Signaturdauer Filmlänge plus Reserve, Nachweis nur beim ersten Abruf je Wiedergabe. Die Zählweise ist noch mit dem Datenschutzbeauftragten abzustimmen. Nachlaufzeit nach Entzug: keine, solange jeder Abschnittsabruf `DecideAccess` prüft (so umgesetzt und getestet). |
|
||||||
|
| 6 | Weiterhin offen: Antwort von Legal zu „Vorab laden“ (Stufe 4). |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 9. Nicht geprüft
|
||||||
|
|
||||||
|
- **Browser- und Gerätefähigkeiten** (iPhone-Vollbild, Ausrichtungssperre, Neuberechnung von `capLevelToPlayerSize`, `requestVideoFrameCallback`, Service Worker auf iOS, Speicherräumung): bewusst nicht als Tatsache behandelt, siehe [unverifiziert].
|
||||||
|
- **Speicherort der Widget-Einstellungen** (Schlüssel im gespeicherten Widget, `version()`/`upgrade()`): nicht gelesen, wird vor Stufe 2 geprüft.
|
||||||
|
- **Filmlänge in den Metadaten:** nicht geprüft, ob sie gespeichert wird.
|
||||||
|
- **Laufendes System:** keine Anfrage an luf-test oder luf-prod, keine Messung. Alle Aussagen zum Mitgliederbereich stammen aus dem Quelltext.
|
||||||
|
- **Bibliotheken** (Video.js, Plyr, Vidstack): nicht bewertet.
|
||||||
|
|
||||||
|
## 10. Hinweise
|
||||||
|
|
||||||
|
- Das Dokument enthält Betriebsdetails aus der Projektdokumentation. Vor Weitergabe außerhalb des Teams prüfen und freigeben.
|
||||||
|
- Rechtliche Fragen (Lizenztexte, Vorab laden, Download-Lizenz) gehören zu Legal und Compliance, Fragen zu Protokollierung und Aufbewahrung zum Datenschutzbeauftragten. Diese Planung gibt dazu keine Auskunft.
|
||||||
|
|
||||||
|
**Weitere Entscheidungen von Lars (01.12.2026):** Marker-Editor: gleiche Berechtigung wie zum Bearbeiten des Films. Der Arbeitsstand der Marken wird nicht gesondert protokolliert; das Protokoll liefert die Fassung. Reihenfolge: 0.2, 0.3, 0.8, danach Stufe 3.
|
||||||
Loaded 100 of 326 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user