Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e2d64a4a9 | ||
|
|
a12818b752 | ||
|
|
2393000468 | ||
|
|
333e2975d5 | ||
|
|
ef876465f0 | ||
|
|
510ae7944c | ||
|
|
c8d44caa75 | ||
|
|
cbc6b30a6d | ||
|
|
bd6b62b4e3 | ||
|
|
010b4fedd4 | ||
|
|
c5d93737ec | ||
|
|
e29014a8a1 | ||
|
|
c33e47fadd | ||
|
|
04a9a4f83f | ||
|
|
6b43fbb7d1 | ||
|
|
6172364bf8 | ||
|
|
ed53bb1669 | ||
|
|
3a37e8a7a1 | ||
|
|
00b7ce9b3f | ||
|
|
bd91104970 | ||
|
|
57f3a18b82 | ||
|
|
28bd5590bc | ||
|
|
40f8a4afc2 | ||
|
|
79b58903ac | ||
|
|
5233b96c42 | ||
|
|
3cf3e822b8 | ||
|
|
6160e95d57 | ||
|
|
f0ffb47210 | ||
|
|
fbe4226347 | ||
|
|
27c1a52edf | ||
|
|
95a888d1ca | ||
|
|
61c65595e1 | ||
|
|
1af462e1d6 | ||
|
|
0ac70884cc | ||
|
|
db3a6ba779 | ||
|
|
3d76062097 | ||
|
|
28e3342b1f | ||
|
|
657578455f | ||
|
|
3b0b4c955e | ||
|
|
93ae01c986 | ||
|
|
cce22ebd81 | ||
|
|
08f7d0c63d | ||
|
|
1950dc377b | ||
|
|
9041afda80 |
No files matched your search
@@ -42,6 +42,7 @@ class EditorialContentKind extends Model
|
|||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'slug',
|
'slug',
|
||||||
'label',
|
'label',
|
||||||
|
'symbol',
|
||||||
'sort_order',
|
'sort_order',
|
||||||
'is_active',
|
'is_active',
|
||||||
'contexts',
|
'contexts',
|
||||||
|
|||||||
@@ -34,7 +34,17 @@ final class FormattedText
|
|||||||
/** 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'];
|
||||||
|
|
||||||
private static ?HtmlSanitizer $sanitizer = null;
|
/** Schriftgrößen der Website (Schlüssel => Bezeichnung); nur im Profil `$site`. Die Werte stehen in `widgets.css`. */
|
||||||
|
public const SITE_SIZES = ['small' => 'Klein', 'large' => 'Groß', 'xlarge' => 'Sehr groß'];
|
||||||
|
|
||||||
|
/** Schriftfarben der Website (Schlüssel => Bezeichnung); nur im Profil `$site`. Die Farbwerte stehen in `widgets.css`. */
|
||||||
|
public const SITE_COLORS = ['marine' => 'Marine', 'gruen' => 'Grün', 'rot' => 'Rot', 'grau' => 'Grau'];
|
||||||
|
|
||||||
|
/** Ausrichtungen der Website außer der Vorgabe „linksbündig“ (so schreibt der Editor sie: `end` heißt rechtsbündig). */
|
||||||
|
private const SITE_ALIGNMENTS = ['center', 'end'];
|
||||||
|
|
||||||
|
/** @var array<string, HtmlSanitizer> je Profil eine Bereinigung (siehe sanitizer()) */
|
||||||
|
private static array $sanitizers = [];
|
||||||
|
|
||||||
/** Symbolleiste der Editoren; muss zur Auswahl oben passen. */
|
/** Symbolleiste der Editoren; muss zur Auswahl oben passen. */
|
||||||
public const TOOLBAR = [
|
public const TOOLBAR = [
|
||||||
@@ -53,8 +63,14 @@ public static function isHtml(?string $value): bool
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Kanonische Form eines gespeicherten oder eingegebenen Werts (HTML oder Klartext). Leer, wenn kein Text übrig ist.
|
* Kanonische Form eines gespeicherten oder eingegebenen Werts (HTML oder Klartext). Leer, wenn kein Text übrig ist.
|
||||||
|
*
|
||||||
|
* `$site` ist das Profil der Website (CMS): Links auf Seiten der eigenen Website (`/materialien`, `#anker`) bleiben
|
||||||
|
* erhalten, dazu Ausrichtung (zentriert, rechtsbündig), Schriftgröße und Schriftfarbe aus festen Werten
|
||||||
|
* ({@see self::SITE_SIZES}, {@see self::SITE_COLORS}). Verwaltung und PDF kennen nur ausdrückliche Adressen
|
||||||
|
* (http, https, mailto) und keine dieser Auszeichnungen; sie fallen dort beim Speichern weg. Das Profil gehört zum Text:
|
||||||
|
* Wer mit `true` speichert, liest auch mit `true`.
|
||||||
*/
|
*/
|
||||||
public static function canonical(?string $value): string
|
public static function canonical(?string $value, bool $site = false): string
|
||||||
{
|
{
|
||||||
$value = trim((string) $value);
|
$value = trim((string) $value);
|
||||||
|
|
||||||
@@ -62,18 +78,18 @@ public static function canonical(?string $value): string
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::normalize(self::isHtml($value) ? $value : self::legacyToHtml($value));
|
return self::normalize(self::isHtml($value) ? $value : self::legacyToHtml($value), $site);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kanonische Form eines Werts, der sicher HTML ist (zum Beispiel aus der Quelle Shinkan), auch wenn er nicht mit
|
* Kanonische Form eines Werts, der sicher HTML ist (zum Beispiel aus der Quelle Shinkan), auch wenn er nicht mit
|
||||||
* einem Blockelement beginnt.
|
* einem Blockelement beginnt.
|
||||||
*/
|
*/
|
||||||
public static function canonicalHtml(?string $html): string
|
public static function canonicalHtml(?string $html, bool $site = false): string
|
||||||
{
|
{
|
||||||
$html = trim((string) $html);
|
$html = trim((string) $html);
|
||||||
|
|
||||||
return $html === '' ? '' : self::normalize($html);
|
return $html === '' ? '' : self::normalize($html, $site);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,9 +101,9 @@ public static function canonicalHtml(?string $html): string
|
|||||||
*
|
*
|
||||||
* @param (callable(int): ?array{src?: string, alt?: string, note?: string})|null $images
|
* @param (callable(int): ?array{src?: string, alt?: string, note?: string})|null $images
|
||||||
*/
|
*/
|
||||||
public static function html(?string $value, ?callable $images = null): string
|
public static function html(?string $value, ?callable $images = null, bool $site = false): string
|
||||||
{
|
{
|
||||||
return self::renderImages(self::canonical($value), $images);
|
return self::renderImages(self::canonical($value, $site), $images);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -454,10 +470,10 @@ public static function legacyToHtml(?string $text): string
|
|||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function normalize(string $html): string
|
private static function normalize(string $html, bool $site = false): string
|
||||||
{
|
{
|
||||||
$html = self::mapLegacyTags($html);
|
$html = self::mapLegacyTags($html);
|
||||||
$html = trim(self::sanitizer()->sanitize($html));
|
$html = trim(self::sanitizer($site)->sanitize($html));
|
||||||
|
|
||||||
if ($html === '') {
|
if ($html === '') {
|
||||||
return '';
|
return '';
|
||||||
@@ -466,6 +482,10 @@ private static function normalize(string $html): string
|
|||||||
$document = HTMLDocument::createFromString('<body>'.$html.'</body>', LIBXML_NOERROR);
|
$document = HTMLDocument::createFromString('<body>'.$html.'</body>', LIBXML_NOERROR);
|
||||||
$body = $document->body;
|
$body = $document->body;
|
||||||
|
|
||||||
|
if ($site) {
|
||||||
|
self::siteMarks($document);
|
||||||
|
}
|
||||||
|
|
||||||
// Ein Bild steht zwischen den Absätzen, in einem Absatz (so setzt der Editor es) oder in einer Tabellenzelle und braucht
|
// Ein Bild steht zwischen den Absätzen, in einem Absatz (so setzt der Editor es) oder in einer Tabellenzelle und braucht
|
||||||
// seine Bildfassung. Anderswo (Liste, Zitat, Überschrift) entfällt es.
|
// seine Bildfassung. Anderswo (Liste, Zitat, Überschrift) entfällt es.
|
||||||
foreach (iterator_to_array($document->querySelectorAll('img')) as $image) {
|
foreach (iterator_to_array($document->querySelectorAll('img')) as $image) {
|
||||||
@@ -528,7 +548,7 @@ private static function block(Node $node): string
|
|||||||
|
|
||||||
$inner = self::inner($child);
|
$inner = self::inner($child);
|
||||||
|
|
||||||
if (! str_contains($inner, '<p>')) {
|
if (preg_match('/<p[\s>]/', $inner) !== 1) {
|
||||||
$inner = '<p>'.$inner.'</p>';
|
$inner = '<p>'.$inner.'</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,11 +562,67 @@ private static function block(Node $node): string
|
|||||||
|
|
||||||
$inner = self::inner($node);
|
$inner = self::inner($node);
|
||||||
|
|
||||||
if ($name === 'blockquote' && ! str_contains($inner, '<p>')) {
|
if ($name === 'blockquote' && preg_match('/<p[\s>]/', $inner) !== 1) {
|
||||||
$inner = '<p>'.$inner.'</p>';
|
$inner = '<p>'.$inner.'</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::hasContent($inner) ? '<'.$name.'>'.$inner.'</'.$name.'>' : '';
|
// Die Ausrichtung ist im Webprofil schon auf `text-align: center|end` zurückgeführt (siehe siteMarks()).
|
||||||
|
$align = $name !== 'blockquote' && preg_match('/^text-align: (?:'.implode('|', self::SITE_ALIGNMENTS).')$/', (string) $node->getAttribute('style')) === 1
|
||||||
|
? ' style="'.$node->getAttribute('style').'"'
|
||||||
|
: '';
|
||||||
|
|
||||||
|
return self::hasContent($inner) ? '<'.$name.$align.'>'.$inner.'</'.$name.'>' : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Webprofil: Ausrichtung, Größe und Farbe auf feste Werte zurückführen. Stil und Klassen aus dem Editor oder von Hand
|
||||||
|
* sind nie maßgeblich: Ein Span trägt nur noch `class="color" data-color` (bekannter Schlüssel) und/oder `data-size`
|
||||||
|
* (bekannter Schlüssel), sonst entfällt er; Absatz und Zwischenüberschrift nur `style="text-align: center|end"`. So
|
||||||
|
* liest der Editor den Wert beim Öffnen wieder, und ein beliebiger Stil kommt nie auf die Seite.
|
||||||
|
*/
|
||||||
|
private static function siteMarks(HTMLDocument $document): void
|
||||||
|
{
|
||||||
|
foreach (iterator_to_array($document->querySelectorAll('span')) as $span) {
|
||||||
|
$color = (string) $span->getAttribute('data-color');
|
||||||
|
$size = (string) $span->getAttribute('data-size');
|
||||||
|
$color = array_key_exists($color, self::SITE_COLORS) ? $color : '';
|
||||||
|
$size = array_key_exists($size, self::SITE_SIZES) ? $size : '';
|
||||||
|
|
||||||
|
if ($color === '' && $size === '') {
|
||||||
|
while ($span->firstChild !== null) {
|
||||||
|
$span->parentNode->insertBefore($span->firstChild, $span);
|
||||||
|
}
|
||||||
|
|
||||||
|
$span->remove();
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (iterator_to_array($span->attributes) as $attribute) {
|
||||||
|
$span->removeAttribute($attribute->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($color !== '') {
|
||||||
|
$span->setAttribute('class', 'color');
|
||||||
|
$span->setAttribute('data-color', $color);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($size !== '') {
|
||||||
|
$span->setAttribute('data-size', $size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($document->querySelectorAll('p, h3, h4, h5, h6') as $block) {
|
||||||
|
$align = preg_match('/(?:^|;)\s*text-align\s*:\s*(center|end|right)\s*(?:;|$)/i', (string) $block->getAttribute('style'), $match) === 1
|
||||||
|
? (strtolower($match[1]) === 'center' ? 'center' : 'end')
|
||||||
|
: null;
|
||||||
|
|
||||||
|
$block->removeAttribute('style');
|
||||||
|
|
||||||
|
if ($align !== null) {
|
||||||
|
$block->setAttribute('style', 'text-align: '.$align);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -694,16 +770,29 @@ private static function runsText(array $runs): string
|
|||||||
return trim(implode('', array_map(fn (array $run): string => $run['text'], $runs)));
|
return trim(implode('', array_map(fn (array $run): string => $run['text'], $runs)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function sanitizer(): HtmlSanitizer
|
private static function sanitizer(bool $site = false): HtmlSanitizer
|
||||||
{
|
{
|
||||||
return self::$sanitizer ??= new HtmlSanitizer(
|
if (isset(self::$sanitizers[$site ? 'site' : 'catalog'])) {
|
||||||
(new HtmlSanitizerConfig)
|
return self::$sanitizers[$site ? 'site' : 'catalog'];
|
||||||
->allowElement('p')
|
}
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
$text = $site ? ['style'] : [];
|
||||||
|
$config = (new HtmlSanitizerConfig)
|
||||||
|
->allowElement('p', $text)
|
||||||
|
->allowElement('h3', $text)
|
||||||
|
->allowElement('h4', $text)
|
||||||
|
->allowElement('h5', $text)
|
||||||
|
->allowElement('h6', $text);
|
||||||
|
|
||||||
|
if ($site) {
|
||||||
|
$config = $config->allowElement('span', ['class', 'data-color', 'data-size']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::$sanitizers[$site ? 'site' : 'catalog'] = new HtmlSanitizer(
|
||||||
|
$config
|
||||||
->allowElement('br')
|
->allowElement('br')
|
||||||
->allowElement('h3')
|
|
||||||
->allowElement('h4')
|
|
||||||
->allowElement('h5')
|
|
||||||
->allowElement('h6')
|
|
||||||
->allowElement('strong')
|
->allowElement('strong')
|
||||||
->allowElement('em')
|
->allowElement('em')
|
||||||
->allowElement('ul')
|
->allowElement('ul')
|
||||||
@@ -720,7 +809,7 @@ private static function sanitizer(): HtmlSanitizer
|
|||||||
->allowElement('img', ['data-id', 'alt'])
|
->allowElement('img', ['data-id', 'alt'])
|
||||||
->allowElement('a', ['href'])
|
->allowElement('a', ['href'])
|
||||||
->allowLinkSchemes(['http', 'https', 'mailto'])
|
->allowLinkSchemes(['http', 'https', 'mailto'])
|
||||||
->allowRelativeLinks(false)
|
->allowRelativeLinks($site)
|
||||||
->forceAttribute('a', 'rel', 'noopener noreferrer')
|
->forceAttribute('a', 'rel', 'noopener noreferrer')
|
||||||
->withMaxInputLength(100000),
|
->withMaxInputLength(100000),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -22,12 +22,14 @@ class LicenseArticle extends Model
|
|||||||
'successor_of_id',
|
'successor_of_id',
|
||||||
'current_release_id',
|
'current_release_id',
|
||||||
'archived_at',
|
'archived_at',
|
||||||
|
'shop_markers',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected function casts(): array
|
protected function casts(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'archived_at' => 'datetime',
|
'archived_at' => 'datetime',
|
||||||
|
'shop_markers' => 'array',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ class Offer extends Model
|
|||||||
'composition_id',
|
'composition_id',
|
||||||
'option_label',
|
'option_label',
|
||||||
'standalone_bundle',
|
'standalone_bundle',
|
||||||
|
'claim_access',
|
||||||
|
'claim_requires_article_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected function casts(): array
|
protected function casts(): array
|
||||||
@@ -22,12 +24,21 @@ protected function casts(): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Komposition, deren öffentliche Seite die Produktseite dieser Lizenzoption ist. */
|
/**
|
||||||
|
* Altbestand: Programmseite, der eine Option mit mehreren Positionen früher von Hand zugeordnet wurde. Neue Optionen
|
||||||
|
* haben genau eine Position; ihre Produktseite ergibt sich aus ihr (Artikel- oder Paketseite) und wird nicht zugeordnet.
|
||||||
|
*/
|
||||||
public function composition(): BelongsTo
|
public function composition(): BelongsTo
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Composition::class);
|
return $this->belongsTo(Composition::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Freigaben einzelner Konten für den Abruf (nur bei Vergabe „auf Abruf“ mit der Regel „freigeschaltete Konten“). */
|
||||||
|
public function releases(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(OfferRelease::class);
|
||||||
|
}
|
||||||
|
|
||||||
/** Bezeichnung der Option auf der Produktseite. */
|
/** Bezeichnung der Option auf der Produktseite. */
|
||||||
public function optionName(): string
|
public function optionName(): string
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Carbon\CarbonInterface;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Freigabe eines Kontos für ein Angebot „auf Abruf“ (ADR-56). Gilt je Angebot und Konto, wird nie gelöscht, nur entzogen.
|
||||||
|
*/
|
||||||
|
class OfferRelease extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'offer_id',
|
||||||
|
'user_id',
|
||||||
|
'granted_by',
|
||||||
|
'granted_at',
|
||||||
|
'valid_until',
|
||||||
|
'revoked_by',
|
||||||
|
'revoked_at',
|
||||||
|
'reason',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'granted_at' => 'datetime',
|
||||||
|
'valid_until' => 'datetime',
|
||||||
|
'revoked_at' => 'datetime',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function offer(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Offer::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function grantor(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'granted_by');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isActiveAt(CarbonInterface $now): bool
|
||||||
|
{
|
||||||
|
return $this->revoked_at === null
|
||||||
|
&& $this->granted_at->lessThanOrEqualTo($now)
|
||||||
|
&& ($this->valid_until === null || $this->valid_until->greaterThan($now));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -106,9 +106,7 @@ public function activate(Offer $offer, array $lines, array $attributes = []): Of
|
|||||||
'trainer_count' => null,
|
'trainer_count' => null,
|
||||||
], $attributes);
|
], $attributes);
|
||||||
|
|
||||||
if ($offer->standalone_bundle && (count($lines) !== 1 || ! $lines[0]['target'] instanceof BundleVersion)) {
|
$this->assertBuyable($lines, $attributes);
|
||||||
throw new DomainRuleException('Ein Angebot mit eigener Paketseite besteht aus genau einer Paketfassung. Wähle eine Paketfassung oder ordne das Angebot der Seite eines Programms zu.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertAttributes($attributes);
|
$this->assertAttributes($attributes);
|
||||||
[$attributes['licence_scope'], $attributes['trainer_count']] = LicenceScope::normalise($attributes['licence_scope'], $attributes['trainer_count']);
|
[$attributes['licence_scope'], $attributes['trainer_count']] = LicenceScope::normalise($attributes['licence_scope'], $attributes['trainer_count']);
|
||||||
@@ -165,6 +163,68 @@ public function activate(Offer $offer, array $lines, array $attributes = []): Of
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bietet einen Lizenzartikel als Kauf an: legt die Option (Angebot) an und aktiviert ihre erste Fassung in einem
|
||||||
|
* Schritt. Besteht eine Prüfung nicht (Stand, Preis, Rechte), bleibt kein leeres Angebot zurück.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $attributes holder_kind, licence_scope, trainer_count, price_cents
|
||||||
|
*/
|
||||||
|
public function offerArticle(LicenseArticle $article, RightsProfileVersion $rights, array $attributes, string $name, ?string $label = null): OfferVersion
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($article, $rights, $attributes, $name, $label): OfferVersion {
|
||||||
|
$offer = $this->create($name);
|
||||||
|
$this->setOptionLabel($offer, $label);
|
||||||
|
|
||||||
|
return $this->activate($offer, [['target' => $article, 'rights' => $rights]], [...$attributes, 'grant_kind' => 'kauf']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ändert eine Option eines Artikels: Die nächste Fassung wird aktiv, die bisherige bleibt gespeichert. Bedingungen,
|
||||||
|
* die die Maske nicht zeigt (Laufzeit, Steuerklasse), bleiben die der letzten Fassung. Die Option muss den Artikel
|
||||||
|
* als einzige Position verkaufen.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $attributes holder_kind, licence_scope, trainer_count, price_cents
|
||||||
|
*/
|
||||||
|
public function reviseArticleOption(Offer $offer, LicenseArticle $article, RightsProfileVersion $rights, array $attributes, ?string $label = null): OfferVersion
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($offer, $article, $rights, $attributes, $label): OfferVersion {
|
||||||
|
$latest = $offer->versions()->with('lines')->orderByDesc('number')->first();
|
||||||
|
|
||||||
|
if ($latest === null || $latest->lines->count() !== 1 || (int) $latest->lines->first()->license_article_id !== $article->id) {
|
||||||
|
throw new DomainRuleException('Diese Option gehört nicht zu diesem Lizenzartikel.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($latest->grant_kind !== 'kauf') {
|
||||||
|
throw new DomainRuleException('Nur eine Option, die als Kauf angeboten wird, lässt sich so ändern. Vergaben auf Abruf oder bei Registrierung bearbeitest du am Angebot.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->setOptionLabel($offer, $label);
|
||||||
|
|
||||||
|
return $this->activate($offer, [['target' => $article, 'rights' => $rights]], [
|
||||||
|
'term_rule' => $latest->term_rule,
|
||||||
|
'tax_class' => $latest->tax_class,
|
||||||
|
'dynamic' => (bool) $latest->dynamic,
|
||||||
|
...$attributes,
|
||||||
|
'grant_kind' => 'kauf',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vorschlag für die Bezeichnung einer Option, wenn keine eingegeben wird: Nutzerkreis und Eignung.
|
||||||
|
*/
|
||||||
|
public static function defaultOptionLabel(?string $holderKind, ?string $licenceScope, mixed $trainers): string
|
||||||
|
{
|
||||||
|
$scope = match ($licenceScope) {
|
||||||
|
LicenceScope::MULTI => 'Mehrfachlizenz ('.(int) $trainers.' Trainer)',
|
||||||
|
LicenceScope::SINGLE => 'Einzellizenz',
|
||||||
|
default => 'Lizenz',
|
||||||
|
};
|
||||||
|
|
||||||
|
return $scope.' für '.($holderKind === 'organisation' ? 'Organisationen und Vereine' : 'Privatpersonen');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zieht die Option aus dem Verkauf zurück: Die aktive Fassung wird beendet und bleibt gespeichert. Bereits
|
* Zieht die Option aus dem Verkauf zurück: Die aktive Fassung wird beendet und bleibt gespeichert. Bereits
|
||||||
* begründete Berechtigungen und Bestellungen ändern sich nicht; offene Warenkörbe zeigen die Position als
|
* begründete Berechtigungen und Bestellungen ändern sich nicht; offene Warenkörbe zeigen die Position als
|
||||||
@@ -183,21 +243,11 @@ public function end(Offer $offer): OfferVersion
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Produktzuordnung der Option: Die Komposition bestimmt die öffentliche Produktseite und die Alternativgruppe,
|
* Die Bezeichnung der Option auf der Produktseite. Die Seite selbst wird nicht zugeordnet: Sie ist die Seite des
|
||||||
* die Bezeichnung benennt die Option auf dieser Seite. Beides sind keine bindenden Konditionen.
|
* Artikels bzw. des Pakets, das die einzige Position der Fassung verkauft. Die Bezeichnung ist keine bindende Kondition.
|
||||||
*/
|
*/
|
||||||
public function assignProduct(Offer $offer, ?int $compositionId, ?string $optionLabel, bool $ownBundlePage = false): Offer
|
public function setOptionLabel(Offer $offer, ?string $optionLabel): Offer
|
||||||
{
|
{
|
||||||
if ($compositionId !== null) {
|
|
||||||
Composition::query()->findOrFail($compositionId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ownBundlePage && $compositionId !== null) {
|
|
||||||
throw new DomainRuleException('Ein Paket hat entweder eine eigene Paketseite oder die Seite eines Programms, nicht beides.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$offer->composition_id = $compositionId;
|
|
||||||
$offer->standalone_bundle = $ownBundlePage;
|
|
||||||
$offer->option_label = filled($optionLabel) ? trim((string) $optionLabel) : null;
|
$offer->option_label = filled($optionLabel) ? trim((string) $optionLabel) : null;
|
||||||
$offer->save();
|
$offer->save();
|
||||||
|
|
||||||
@@ -212,6 +262,29 @@ public function scopeArticleIds(OfferVersion $version): array
|
|||||||
return $version->resolvedScopes()->orderBy('id')->pluck('license_article_id')->all();
|
return $version->resolvedScopes()->orderBy('id')->pluck('license_article_id')->all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ein Kauf muss im Shop auffindbar und kaufbar sein, sonst lässt er sich nicht aktivieren: Er verkauft genau einen
|
||||||
|
* Artikel oder ein Paket (das ist die Produktseite) und hat einen Preis. Mehrere Artikel gemeinsam verkauft ein
|
||||||
|
* Paket. Vergaben bei Registrierung oder auf Abruf stehen nie im Shop und sind davon ausgenommen.
|
||||||
|
*
|
||||||
|
* @param list<array{target: LicenseArticle|BundleVersion, rights: RightsProfileVersion}> $lines
|
||||||
|
* @param array<string, mixed> $attributes
|
||||||
|
*/
|
||||||
|
private function assertBuyable(array $lines, array $attributes): void
|
||||||
|
{
|
||||||
|
if (($attributes['grant_kind'] ?? null) !== 'kauf') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($lines) !== 1) {
|
||||||
|
throw new DomainRuleException('Ein Kauf verkauft genau einen Artikel oder ein Paket. Mehrere Artikel gemeinsam verkaufst du als Paket (Katalog → Pakete).');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! is_int($attributes['price_cents'] ?? null) || $attributes['price_cents'] <= 0) {
|
||||||
|
throw new DomainRuleException('Ein Kauf braucht einen Preis über 0,00 €.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $attributes
|
* @param array<string, mixed> $attributes
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Domain\Media\ThumbnailRef;
|
use App\Domain\Media\ThumbnailRef;
|
||||||
use App\Domain\Media\WebsiteMedia;
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Domain\Media\WebsitePresentation;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@@ -430,6 +431,32 @@ public function coverElementId(Model $subject): ?int
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Das öffentlich zeigbare Titelbild: das erste Titel- oder Galeriebild in der Reihenfolge der Rollen, das für die
|
||||||
|
* Website freigegeben ist (WebsiteMedia). Ein nicht freigegebenes Bild wird übersprungen, nie ausgeliefert.
|
||||||
|
*/
|
||||||
|
public function coverPresentation(Model $subject): ?WebsitePresentation
|
||||||
|
{
|
||||||
|
$assignments = PresentationAssignment::query()
|
||||||
|
->with('role')
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->orderBy('position')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach (PresentationRole::COVER_ROLES as $slug) {
|
||||||
|
foreach ($assignments->filter(fn (PresentationAssignment $row): bool => $row->role?->slug === $slug) as $row) {
|
||||||
|
$presentation = $this->website->present((int) $row->content_element_id);
|
||||||
|
|
||||||
|
if ($presentation !== null && $presentation->kind === 'bild') {
|
||||||
|
return $presentation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private function owned(Model $subject, int $assignmentId): PresentationAssignment
|
private function owned(Model $subject, int $assignmentId): PresentationAssignment
|
||||||
{
|
{
|
||||||
$assignment = PresentationAssignment::query()
|
$assignment = PresentationAssignment::query()
|
||||||
|
|||||||
@@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Cms;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Sections\PageSections;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interne Linkziele für die Auswahl im CMS: Seiten mit ihrem Veröffentlichungszustand und die Sprungmarken ihrer
|
||||||
|
* Abschnitte. Rein lesend; das Ergebnis ist eine Adresse, die in ein Linkfeld oder einen Menüeintrag geschrieben wird.
|
||||||
|
*
|
||||||
|
* Adressformen: „/pfad“, „/pfad#marke“ (andere Seite) und „#marke“ (dieselbe Seite). Sie bestehen SafeUrl.
|
||||||
|
*/
|
||||||
|
class LinkTargets
|
||||||
|
{
|
||||||
|
public function __construct(private readonly PageSections $sections) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seiten für die Auswahl, nach Adresse sortiert. Suche in Titel und Adresse.
|
||||||
|
*
|
||||||
|
* @return list<array{id: int, titel: string, pfad: string, zustand: array{label: string, ton: string}, marken: int}>
|
||||||
|
*/
|
||||||
|
public function pages(string $search = '', ?int $exceptId = null): array
|
||||||
|
{
|
||||||
|
$needle = mb_strtolower(trim($search));
|
||||||
|
|
||||||
|
return Page::query()->with(['latestRevision', 'publishedRevision'])->orderBy('path')->get()
|
||||||
|
->reject(fn (Page $page): bool => $page->getKey() === $exceptId)
|
||||||
|
->map(fn (Page $page): array => [
|
||||||
|
'id' => (int) $page->getKey(),
|
||||||
|
'titel' => $page->latestRevision?->contentTitle() ?: $page->path,
|
||||||
|
'pfad' => $page->path,
|
||||||
|
'zustand' => $this->state($page),
|
||||||
|
'marken' => count($this->anchorsOf($page->latestRevision?->sections() ?? [])),
|
||||||
|
])
|
||||||
|
->filter(fn (array $page): bool => $needle === '' || str_contains(mb_strtolower($page['titel'].' '.$page['pfad']), $needle))
|
||||||
|
->values()
|
||||||
|
->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{label: string, ton: string}
|
||||||
|
*/
|
||||||
|
public function state(Page $page): array
|
||||||
|
{
|
||||||
|
if ($page->published_revision_id === null) {
|
||||||
|
return ['label' => 'Nur Entwurf, öffentlich nicht erreichbar', 'ton' => 'offen'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $page->latestRevision !== null && $page->latestRevision->id !== $page->published_revision_id
|
||||||
|
? ['label' => 'Veröffentlicht · Entwurf neuer', 'ton' => 'gut']
|
||||||
|
: ['label' => 'Veröffentlicht', 'ton' => 'gut'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sprungmarken einer gespeicherten Seite: die des neuesten Entwurfs, je mit dem Hinweis, ob sie schon
|
||||||
|
* veröffentlicht sind und ob der Abschnitt ausgeblendet ist.
|
||||||
|
*
|
||||||
|
* @return list<array{anchor: string, label: string, hidden: bool, published: bool}>
|
||||||
|
*/
|
||||||
|
public function anchorsForPage(Page $page): array
|
||||||
|
{
|
||||||
|
$published = collect($this->anchorsOf($page->publishedRevision?->sections() ?? []))
|
||||||
|
->filter(fn (array $anchor): bool => ! $anchor['hidden'])
|
||||||
|
->pluck('anchor')
|
||||||
|
->all();
|
||||||
|
|
||||||
|
return array_map(
|
||||||
|
fn (array $anchor): array => $anchor + ['published' => in_array($anchor['anchor'], $published, true)],
|
||||||
|
$this->anchorsOf($page->latestRevision?->sections() ?? $page->publishedRevision?->sections() ?? []),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sprungmarken der Abschnitte im Editor, auch ungespeicherte. Für „diese Seite“.
|
||||||
|
*
|
||||||
|
* @param list<array<string, mixed>> $sections Abschnitte im Modell (nach SectionEditor::fromEditorState)
|
||||||
|
* @return list<array{anchor: string, label: string, hidden: bool, published: bool}>
|
||||||
|
*/
|
||||||
|
public function anchorsInEditor(array $sections): array
|
||||||
|
{
|
||||||
|
return array_map(fn (array $anchor): array => $anchor + ['published' => false], $this->anchorsOf($sections));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<array<string, mixed>> $sections
|
||||||
|
* @return list<array{anchor: string, label: string, hidden: bool}>
|
||||||
|
*/
|
||||||
|
public function anchorsOf(array $sections): array
|
||||||
|
{
|
||||||
|
$anchors = [];
|
||||||
|
|
||||||
|
foreach (array_values($sections) as $position => $section) {
|
||||||
|
$anchor = PageSections::cleanAnchor($section['anchor'] ?? null);
|
||||||
|
|
||||||
|
if ($anchor === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = PageSections::cleanName($section['name'] ?? null);
|
||||||
|
$anchors[] = [
|
||||||
|
'anchor' => $anchor,
|
||||||
|
'label' => $name ?? 'Abschnitt '.($position + 1),
|
||||||
|
'hidden' => PageSections::isHidden($section['hidden'] ?? false),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $anchors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adresse für ein Linkfeld: „/pfad“, „/pfad#marke“ oder (dieselbe Seite) „#marke“.
|
||||||
|
*/
|
||||||
|
public function href(?string $path, ?string $anchor): ?string
|
||||||
|
{
|
||||||
|
$anchor = $anchor !== null && $anchor !== '' ? PageSections::cleanAnchor($anchor) : null;
|
||||||
|
|
||||||
|
if ($path === null) {
|
||||||
|
return $anchor !== null ? '#'.$anchor : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path.($anchor !== null ? '#'.$anchor : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vollständige öffentliche Adresse mit Sprungmarke, für Verweise von außen.
|
||||||
|
*/
|
||||||
|
public function publicUrl(Page $page, ?string $anchor = null): string
|
||||||
|
{
|
||||||
|
return $page->publicUrl().($anchor !== null && $anchor !== '' ? '#'.$anchor : '');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Domain\Cms;
|
namespace App\Domain\Cms;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Sections\PageSections;
|
||||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||||
|
use App\Domain\Commerce\Shop;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
@@ -31,6 +33,7 @@ class NavigationItem extends Model
|
|||||||
'label',
|
'label',
|
||||||
'page_id',
|
'page_id',
|
||||||
'url',
|
'url',
|
||||||
|
'anchor',
|
||||||
'placement',
|
'placement',
|
||||||
'sort_order',
|
'sort_order',
|
||||||
'is_visible',
|
'is_visible',
|
||||||
@@ -79,8 +82,15 @@ public function scopeVisible(Builder $query): void
|
|||||||
|
|
||||||
public function href(): ?string
|
public function href(): ?string
|
||||||
{
|
{
|
||||||
|
// Ein Menüpunkt in den Shop erscheint nicht, solange der Shop nicht sichtbar ist: Er führte ins Leere (404).
|
||||||
|
if ($this->pointsIntoShop() && ! Shop::visible()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->page !== null) {
|
if ($this->page !== null) {
|
||||||
return $this->page->path === '/' ? url('/') : url($this->page->path);
|
$anchor = PageSections::cleanAnchor($this->anchor);
|
||||||
|
|
||||||
|
return ($this->page->path === '/' ? url('/') : url($this->page->path)).($anchor !== null ? '#'.$anchor : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->url === null || $this->url === '' || ! SafeUrl::isSafe($this->url)) {
|
if ($this->url === null || $this->url === '' || ! SafeUrl::isSafe($this->url)) {
|
||||||
@@ -94,6 +104,24 @@ public function href(): ?string
|
|||||||
return $this->url;
|
return $this->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Ziel ist der Shop selbst oder eine seiner Seiten: Übersicht, Produktseiten, Hinweisseite, Warenkorb, Kasse. */
|
||||||
|
private function pointsIntoShop(): bool
|
||||||
|
{
|
||||||
|
$path = $this->targetPath();
|
||||||
|
|
||||||
|
if ($path === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (['/shop', '/warenkorb', '/kasse', '/kauf-noch-nicht-moeglich'] as $prefix) {
|
||||||
|
if ($path === $prefix || str_starts_with($path, $prefix.'/')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pfad des Ziels innerhalb der Website (für die Kennzeichnung des aktiven Eintrags); null bei externen Zielen.
|
* Pfad des Ziels innerhalb der Website (für die Kennzeichnung des aktiven Eintrags); null bei externen Zielen.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -18,6 +18,13 @@
|
|||||||
* Version 2 (Abstände): oben, unten und Widget-Abstand sind drei unabhängige Werte. Hüllen der Version 1 werden beim
|
* Version 2 (Abstände): oben, unten und Widget-Abstand sind drei unabhängige Werte. Hüllen der Version 1 werden beim
|
||||||
* Lesen übersetzt (SectionStyle::migrateSpacing), ohne die Darstellung zu ändern; gespeicherte Revisionen bleiben.
|
* Lesen übersetzt (SectionStyle::migrateSpacing), ohne die Darstellung zu ändern; gespeicherte Revisionen bleiben.
|
||||||
*
|
*
|
||||||
|
* Optionale Felder des Abschnitts (abwärtskompatibel, fehlen in älteren Revisionen):
|
||||||
|
* - name: interner Name zur Orientierung im Seitenaufbau (nie öffentlich), höchstens 80 Zeichen;
|
||||||
|
* - anchor: Sprungmarke, wird als Element-Kennung des Abschnitts ausgegeben (Link „#marke“ oder „/pfad#marke“),
|
||||||
|
* je Seite eindeutig, nur Kleinbuchstaben, Ziffern und Bindestriche;
|
||||||
|
* - hidden: true blendet den Abschnitt auf der Website aus; er bleibt im Entwurf und in den Revisionen erhalten.
|
||||||
|
* Ältere Programmstände kennen „hidden“ nicht und würden einen ausgeblendeten Abschnitt zeigen (siehe Release-Vorbereitung).
|
||||||
|
*
|
||||||
* Jeder Slot enthält höchstens ein Widget aus dem zentralen Widget-Register. Abschnitte sind nicht verschachtelbar.
|
* Jeder Slot enthält höchstens ein Widget aus dem zentralen Widget-Register. Abschnitte sind nicht verschachtelbar.
|
||||||
* Revisionen ohne Abschnitte (Bestand vor dieser Fassung) werden beim Lesen als einspaltige Abschnitte gelesen.
|
* Revisionen ohne Abschnitte (Bestand vor dieser Fassung) werden beim Lesen als einspaltige Abschnitte gelesen.
|
||||||
*/
|
*/
|
||||||
@@ -29,6 +36,20 @@ class PageSections
|
|||||||
|
|
||||||
public const MAX_WIDGETS = 60;
|
public const MAX_WIDGETS = 60;
|
||||||
|
|
||||||
|
public const MAX_NAME = 80;
|
||||||
|
|
||||||
|
public const MAX_ANCHOR = 60;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kennungen, die im Seitengerüst schon vergeben sind (Hauptbereich, Navigation, Fuß) oder als Vorgabe dienen.
|
||||||
|
* Eine Sprungmarke darf sie nicht wiederholen.
|
||||||
|
*
|
||||||
|
* @var list<string>
|
||||||
|
*/
|
||||||
|
public const RESERVED_ANCHORS = ['inhalt', 'main', 'top', 'site-nav', 'fuss-themen', 'mb-account-menu'];
|
||||||
|
|
||||||
|
public const ANCHOR_PATTERN = '/^[a-z0-9]+(?:-[a-z0-9]+)*$/';
|
||||||
|
|
||||||
public function __construct(private readonly WidgetRegistry $widgets) {}
|
public function __construct(private readonly WidgetRegistry $widgets) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,7 +57,7 @@ public function __construct(private readonly WidgetRegistry $widgets) {}
|
|||||||
*
|
*
|
||||||
* @param array<int|string, mixed>|null $sections gespeicherte Abschnitte (Spalte sections)
|
* @param array<int|string, mixed>|null $sections gespeicherte Abschnitte (Spalte sections)
|
||||||
* @param array<int|string, mixed>|null $blocks flache Bausteinliste (Spalte blocks), nur ohne Abschnitte verwendet
|
* @param array<int|string, mixed>|null $blocks flache Bausteinliste (Spalte blocks), nur ohne Abschnitte verwendet
|
||||||
* @return list<array{id: ?string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}>
|
* @return list<array{id: ?string, v: int, name: ?string, anchor: ?string, hidden: bool, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}>
|
||||||
*/
|
*/
|
||||||
public function read(?array $sections, ?array $blocks = null): array
|
public function read(?array $sections, ?array $blocks = null): array
|
||||||
{
|
{
|
||||||
@@ -59,7 +80,7 @@ public function read(?array $sections, ?array $blocks = null): array
|
|||||||
* „sections.N.layout“, „sections.N.style.image“, „sections.N.slots“, „sections.N.slots.M.data.feld“.
|
* „sections.N.layout“, „sections.N.style.image“, „sections.N.slots“, „sections.N.slots.M.data.feld“.
|
||||||
*
|
*
|
||||||
* @param array<int|string, mixed> $content
|
* @param array<int|string, mixed> $content
|
||||||
* @return list<array{id: string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}>
|
* @return list<array{id: string, v: int, name: ?string, anchor: ?string, hidden: bool, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}>
|
||||||
*/
|
*/
|
||||||
public function normalize(array $content): array
|
public function normalize(array $content): array
|
||||||
{
|
{
|
||||||
@@ -75,6 +96,7 @@ public function normalize(array $content): array
|
|||||||
$sections = [];
|
$sections = [];
|
||||||
$seenSectionIds = [];
|
$seenSectionIds = [];
|
||||||
$seenWidgetIds = [];
|
$seenWidgetIds = [];
|
||||||
|
$seenAnchors = [];
|
||||||
$widgetCount = 0;
|
$widgetCount = 0;
|
||||||
|
|
||||||
// Eingaben mit Abständen der Version 1 (zum Beispiel ältere Aufrufer) werden wie beim Lesen übersetzt.
|
// Eingaben mit Abständen der Version 1 (zum Beispiel ältere Aufrufer) werden wie beim Lesen übersetzt.
|
||||||
@@ -96,7 +118,7 @@ public function normalize(array $content): array
|
|||||||
$item['style'] = $migrated[$index]['style'] ?? ($item['style'] ?? []);
|
$item['style'] = $migrated[$index]['style'] ?? ($item['style'] ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sections[] = $this->normalizeSection($item, $index, $errors, $seenSectionIds, $seenWidgetIds, $widgetCount);
|
$sections[] = $this->normalizeSection($item, $index, $errors, $seenSectionIds, $seenWidgetIds, $widgetCount, $seenAnchors);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($widgetCount > self::MAX_WIDGETS) {
|
if ($widgetCount > self::MAX_WIDGETS) {
|
||||||
@@ -164,12 +186,14 @@ public function mediaPaths(array $sections): array
|
|||||||
*/
|
*/
|
||||||
public function pageTitle(array $sections): ?string
|
public function pageTitle(array $sections): ?string
|
||||||
{
|
{
|
||||||
return $this->widgets->pageTitle($this->flatten($sections));
|
// Ein ausgeblendeter Abschnitt liefert keinen Seitentitel; seine Medien bleiben dagegen erfasst (mediaPaths),
|
||||||
|
// damit ihre Bilder nicht als ungenutzt gelten.
|
||||||
|
return $this->widgets->pageTitle($this->flatten(array_values(array_filter($sections, fn (array $section): bool => ! ($section['hidden'] ?? false)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<int|string, mixed> $blocks
|
* @param array<int|string, mixed> $blocks
|
||||||
* @return list<array{id: ?string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}>
|
* @return list<array{id: ?string, v: int, name: ?string, anchor: ?string, hidden: bool, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}>
|
||||||
*/
|
*/
|
||||||
private function wrapWidgets(array $blocks): array
|
private function wrapWidgets(array $blocks): array
|
||||||
{
|
{
|
||||||
@@ -179,6 +203,9 @@ private function wrapWidgets(array $blocks): array
|
|||||||
$sections[] = [
|
$sections[] = [
|
||||||
'id' => null,
|
'id' => null,
|
||||||
'v' => self::VERSION,
|
'v' => self::VERSION,
|
||||||
|
'name' => null,
|
||||||
|
'anchor' => null,
|
||||||
|
'hidden' => false,
|
||||||
'layout' => SectionLayouts::DEFAULT,
|
'layout' => SectionLayouts::DEFAULT,
|
||||||
// Bestand vor dem Raster stand in einem durchgehenden Blatt: kompakte Abstände, zwischen den Widgets
|
// Bestand vor dem Raster stand in einem durchgehenden Blatt: kompakte Abstände, zwischen den Widgets
|
||||||
// nur einmal (oben kein Abstand ab dem zweiten), wie bisher.
|
// nur einmal (oben kein Abstand ab dem zweiten), wie bisher.
|
||||||
@@ -192,7 +219,7 @@ private function wrapWidgets(array $blocks): array
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $section
|
* @param array<string, mixed> $section
|
||||||
* @return array{id: ?string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}
|
* @return array{id: ?string, v: int, name: ?string, anchor: ?string, hidden: bool, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}
|
||||||
*/
|
*/
|
||||||
private function upcastSection(array $section): array
|
private function upcastSection(array $section): array
|
||||||
{
|
{
|
||||||
@@ -210,6 +237,9 @@ private function upcastSection(array $section): array
|
|||||||
return [
|
return [
|
||||||
'id' => is_string($section['id'] ?? null) ? $section['id'] : null,
|
'id' => is_string($section['id'] ?? null) ? $section['id'] : null,
|
||||||
'v' => self::VERSION,
|
'v' => self::VERSION,
|
||||||
|
'name' => self::cleanName($section['name'] ?? null),
|
||||||
|
'anchor' => self::cleanAnchor($section['anchor'] ?? null),
|
||||||
|
'hidden' => self::isHidden($section['hidden'] ?? false),
|
||||||
'layout' => $layout,
|
'layout' => $layout,
|
||||||
'style' => SectionStyle::fromStored($section['style'] ?? []),
|
'style' => SectionStyle::fromStored($section['style'] ?? []),
|
||||||
'slots' => $slots,
|
'slots' => $slots,
|
||||||
@@ -221,9 +251,9 @@ private function upcastSection(array $section): array
|
|||||||
* @param array<string, list<string>> $errors
|
* @param array<string, list<string>> $errors
|
||||||
* @param array<string, true> $seenSectionIds
|
* @param array<string, true> $seenSectionIds
|
||||||
* @param array<string, true> $seenWidgetIds
|
* @param array<string, true> $seenWidgetIds
|
||||||
* @return array{id: string, v: int, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}
|
* @return array{id: string, v: int, name: ?string, anchor: ?string, hidden: bool, layout: string, style: array<string, mixed>, slots: list<array<string, mixed>|null>}
|
||||||
*/
|
*/
|
||||||
private function normalizeSection(array $section, int $index, array &$errors, array &$seenSectionIds, array &$seenWidgetIds, int &$widgetCount): array
|
private function normalizeSection(array $section, int $index, array &$errors, array &$seenSectionIds, array &$seenWidgetIds, int &$widgetCount, array &$seenAnchors): array
|
||||||
{
|
{
|
||||||
$prefix = "sections.$index";
|
$prefix = "sections.$index";
|
||||||
|
|
||||||
@@ -294,15 +324,90 @@ private function normalizeSection(array $section, int $index, array &$errors, ar
|
|||||||
}
|
}
|
||||||
$seenSectionIds[$id] = true;
|
$seenSectionIds[$id] = true;
|
||||||
|
|
||||||
|
[$name, $anchor] = $this->normalizeLabels($section, $prefix, $errors, $seenAnchors);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $id,
|
'id' => $id,
|
||||||
'v' => self::VERSION,
|
'v' => self::VERSION,
|
||||||
|
'name' => $name,
|
||||||
|
'anchor' => $anchor,
|
||||||
|
'hidden' => self::isHidden($section['hidden'] ?? false),
|
||||||
'layout' => $layout,
|
'layout' => $layout,
|
||||||
'style' => $style,
|
'style' => $style,
|
||||||
'slots' => $slots,
|
'slots' => $slots,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name und Sprungmarke eines Abschnitts. Fehler: „sections.N.name“ und „sections.N.anchor“.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $section
|
||||||
|
* @param array<string, list<string>> $errors
|
||||||
|
* @param array<string, true> $seenAnchors
|
||||||
|
* @return array{0: ?string, 1: ?string}
|
||||||
|
*/
|
||||||
|
private function normalizeLabels(array $section, string $prefix, array &$errors, array &$seenAnchors): array
|
||||||
|
{
|
||||||
|
$name = null;
|
||||||
|
$rawName = $section['name'] ?? null;
|
||||||
|
|
||||||
|
if (is_string($rawName) && trim($rawName) !== '') {
|
||||||
|
$name = self::cleanName($rawName);
|
||||||
|
|
||||||
|
if ($name === null) {
|
||||||
|
$errors["$prefix.name"] = ['Der Name darf höchstens '.self::MAX_NAME.' Zeichen lang sein.'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$anchor = null;
|
||||||
|
$rawAnchor = $section['anchor'] ?? null;
|
||||||
|
|
||||||
|
if (is_string($rawAnchor) && trim($rawAnchor) !== '') {
|
||||||
|
$candidate = mb_strtolower(trim($rawAnchor));
|
||||||
|
|
||||||
|
if (strlen($candidate) > self::MAX_ANCHOR || preg_match(self::ANCHOR_PATTERN, $candidate) !== 1) {
|
||||||
|
$errors["$prefix.anchor"] = ['Eine Sprungmarke besteht aus Kleinbuchstaben, Ziffern und einzelnen Bindestrichen (höchstens '.self::MAX_ANCHOR.' Zeichen), zum Beispiel „anmeldung“.'];
|
||||||
|
} 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 {
|
||||||
|
$seenAnchors[$candidate] = true;
|
||||||
|
$anchor = $candidate;
|
||||||
|
}
|
||||||
|
} elseif ($rawAnchor !== null && ! is_string($rawAnchor)) {
|
||||||
|
$errors["$prefix.anchor"] = ['Die Sprungmarke ist ungültig.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$name, $anchor];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Interner Name: Leerraum vereinheitlicht, ohne Steuerzeichen; leer oder über 80 Zeichen ergibt null. */
|
||||||
|
public static function cleanName(mixed $value): ?string
|
||||||
|
{
|
||||||
|
if (! is_string($value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$name = trim((string) preg_replace('/\s+/u', ' ', (string) preg_replace('/[\x00-\x1F\x7F]/u', ' ', $value)));
|
||||||
|
|
||||||
|
return $name === '' || mb_strlen($name) > self::MAX_NAME ? null : $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Lesepfad: eine gespeicherte Sprungmarke nur, wenn sie der Form entspricht. */
|
||||||
|
public static function cleanAnchor(mixed $value): ?string
|
||||||
|
{
|
||||||
|
return is_string($value) && strlen($value) <= self::MAX_ANCHOR && preg_match(self::ANCHOR_PATTERN, $value) === 1
|
||||||
|
&& ! in_array($value, self::RESERVED_ANCHORS, true) && ! str_starts_with($value, 'bereich-')
|
||||||
|
? $value
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isHidden(mixed $value): bool
|
||||||
|
{
|
||||||
|
return $value === true || $value === 1 || $value === '1' || $value === 'true';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $style
|
* @param array<string, mixed> $style
|
||||||
* @param array<string, list<string>> $errors
|
* @param array<string, list<string>> $errors
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
* Die Kennungen sind gespeichert und ändern sich nie; neue Raster werden ergänzt, nicht umbenannt.
|
* Die Kennungen sind gespeichert und ändern sich nie; neue Raster werden ergänzt, nicht umbenannt.
|
||||||
*
|
*
|
||||||
* Die Einheiten werden nicht als eigenes CSS-Grundraster umgesetzt, sondern als Spaltenverhältnis (fr)
|
* Die Einheiten werden nicht als eigenes CSS-Grundraster umgesetzt, sondern als Spaltenverhältnis (fr)
|
||||||
* des Abschnittsrasters. Leere Slots entfallen auf der veröffentlichten Seite; die übrigen Slots teilen
|
* des Abschnittsrasters. Jeder Platz behält seine Stelle und Breite, auch wenn er leer bleibt; die Widgets
|
||||||
* sich die Breite im Verhältnis ihrer Einheiten.
|
* daneben rücken nicht nach.
|
||||||
*/
|
*/
|
||||||
final class SectionLayouts
|
final class SectionLayouts
|
||||||
{
|
{
|
||||||
@@ -81,7 +81,7 @@ public static function options(): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spaltenvorlagen für die Slots, die tatsächlich etwas darstellen.
|
* Spaltenvorlagen für alle Plätze des Rasters (auch leere, damit die übrigen an ihrer Stelle bleiben).
|
||||||
*
|
*
|
||||||
* - Desktop (Abschnitt ab 60rem): Verhältnis der Einheiten.
|
* - Desktop (Abschnitt ab 60rem): Verhältnis der Einheiten.
|
||||||
* - Tablet (ab 40rem): gleich breite Slots bleiben nebeneinander (zwei oder drei Spalten, vier Slots als 2 × 2);
|
* - Tablet (ab 40rem): gleich breite Slots bleiben nebeneinander (zwei oder drei Spalten, vier Slots als 2 × 2);
|
||||||
|
|||||||
@@ -11,10 +11,15 @@
|
|||||||
* Einziger Darstellungsweg für Abschnitte: öffentliche Seite und Seitenvorschau rufen denselben Renderer auf.
|
* Einziger Darstellungsweg für Abschnitte: öffentliche Seite und Seitenvorschau rufen denselben Renderer auf.
|
||||||
*
|
*
|
||||||
* Regeln:
|
* Regeln:
|
||||||
* - Leere Slots erzeugen keine Leerfläche; die übrigen Slots teilen sich die Breite im Verhältnis ihrer Einheiten.
|
* - Jeder Platz des Rasters behält seine Stelle und seine Breite: Ein leerer Platz bleibt als leere Spalte stehen, die
|
||||||
|
* Widgets daneben rücken nicht in ihn hinein. Gestapelt (Smartphone, schmaler Abschnitt) erzeugt ein leerer Platz keine
|
||||||
|
* Lücke.
|
||||||
* - Ein Abschnitt ohne darstellbares Widget entfällt samt Hintergrund und Trenner.
|
* - Ein Abschnitt ohne darstellbares Widget entfällt samt Hintergrund und Trenner.
|
||||||
* - Das erste dargestellte Widget der Seite ist der Seiteneinstieg (Überschrift erster Ordnung).
|
* - Das erste dargestellte Widget der Seite ist der Seiteneinstieg (Überschrift erster Ordnung).
|
||||||
* - Trenner stehen zwischen Abschnitten, nie nach dem letzten.
|
* - Trenner stehen zwischen Abschnitten, nie nach dem letzten.
|
||||||
|
* - Ein ausgeblendeter Abschnitt („hidden“) erscheint nie auf der Website und zählt weder für das erste Widget noch für
|
||||||
|
* Trenner. Nur die Vorschau zeigt an seiner Stelle einen schmalen Hinweis (ohne Inhalt).
|
||||||
|
* - Eine Sprungmarke („anchor“) ist die Element-Kennung des Abschnitts; ohne Sprungmarke gilt „bereich-<Kennung>“.
|
||||||
*/
|
*/
|
||||||
class SectionRenderer
|
class SectionRenderer
|
||||||
{
|
{
|
||||||
@@ -29,37 +34,59 @@ public function renderAll(array $sections, RenderContext $context): HtmlString
|
|||||||
$first = true;
|
$first = true;
|
||||||
|
|
||||||
foreach ($sections as $section) {
|
foreach ($sections as $section) {
|
||||||
|
if ($section['hidden'] ?? false) {
|
||||||
|
if ($context->preview) {
|
||||||
|
$rendered[] = ['note' => $this->hiddenNote($section)];
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$cells = [];
|
$cells = [];
|
||||||
|
$shown = false;
|
||||||
$units = SectionLayouts::units($section['layout']);
|
$units = SectionLayouts::units($section['layout']);
|
||||||
|
|
||||||
foreach ($units as $position => $slotUnits) {
|
foreach ($units as $position => $slotUnits) {
|
||||||
$widget = $section['slots'][$position] ?? null;
|
$widget = $section['slots'][$position] ?? null;
|
||||||
|
$html = is_array($widget) ? $this->widgets->renderWidget($widget, $context, $first) : '';
|
||||||
if (! is_array($widget)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$html = $this->widgets->renderWidget($widget, $context, $first);
|
|
||||||
|
|
||||||
if ($html !== '') {
|
if ($html !== '') {
|
||||||
$first = false;
|
$first = false;
|
||||||
$cells[] = ['units' => $slotUnits, 'html' => $html];
|
$shown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auch ein leerer Platz (oder ein Widget, das nichts darstellt) bleibt eine Zelle, damit die Plätze daneben stehen bleiben.
|
||||||
|
$cells[] = ['units' => $slotUnits, 'html' => $html];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cells !== []) {
|
if ($shown) {
|
||||||
$rendered[] = ['section' => $section, 'cells' => $cells];
|
$rendered[] = ['section' => $section, 'cells' => $cells];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = '';
|
$html = '';
|
||||||
$last = count($rendered) - 1;
|
$last = -1;
|
||||||
|
|
||||||
|
foreach ($rendered as $position => $item) {
|
||||||
|
if (isset($item['section'])) {
|
||||||
|
$last = $position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$index = 0;
|
||||||
|
|
||||||
|
foreach ($rendered as $position => $item) {
|
||||||
|
if (! isset($item['section'])) {
|
||||||
|
$html .= $item['note'];
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($rendered as $index => $item) {
|
|
||||||
$html .= $this->renderSection($item['section'], $item['cells'], $index, $context);
|
$html .= $this->renderSection($item['section'], $item['cells'], $index, $context);
|
||||||
|
$index++;
|
||||||
|
|
||||||
$divider = $item['section']['style']['divider'] ?? 'none';
|
$divider = $item['section']['style']['divider'] ?? 'none';
|
||||||
if ($index < $last && in_array($divider, ['line', 'accent'], true)) {
|
if ($position < $last && in_array($divider, ['line', 'accent'], true)) {
|
||||||
$html .= '<div class="section-divider section-divider-'.$divider.'" aria-hidden="true"><span></span></div>';
|
$html .= '<div class="section-divider section-divider-'.$divider.'" aria-hidden="true"><span></span></div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,8 +95,20 @@ public function renderAll(array $sections, RenderContext $context): HtmlString
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Hinweis der Vorschau an der Stelle eines ausgeblendeten Abschnitts.
|
||||||
|
*
|
||||||
* @param array<string, mixed> $section
|
* @param array<string, mixed> $section
|
||||||
* @param list<array{units: int, html: string}> $cells
|
*/
|
||||||
|
private function hiddenNote(array $section): string
|
||||||
|
{
|
||||||
|
$name = is_string($section['name'] ?? null) && $section['name'] !== '' ? '„'.$section['name'].'“ ' : '';
|
||||||
|
|
||||||
|
return '<div class="section-hidden-note" role="note">Abschnitt '.e($name).'ist für die Website ausgeblendet und erscheint hier nur als Hinweis.</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $section
|
||||||
|
* @param list<array{units: int, html: string}> $cells alle Plätze des Rasters in ihrer Reihenfolge; html '' = leer
|
||||||
*/
|
*/
|
||||||
private function renderSection(array $section, array $cells, int $index, RenderContext $context): string
|
private function renderSection(array $section, array $cells, int $index, RenderContext $context): string
|
||||||
{
|
{
|
||||||
@@ -105,7 +144,11 @@ private function renderSection(array $section, array $cells, int $index, RenderC
|
|||||||
$classes[] = $scope;
|
$classes[] = $scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = is_string($section['id'] ?? null) ? ' id="bereich-'.e($section['id']).'"' : '';
|
// Die Sprungmarke ist die Kennung, die ein Link „#marke“ anspringt; ohne sie bleibt die bisherige Kennung.
|
||||||
|
$anchor = PageSections::cleanAnchor($section['anchor'] ?? null);
|
||||||
|
$id = $anchor !== null
|
||||||
|
? ' id="'.e($anchor).'"'
|
||||||
|
: (is_string($section['id'] ?? null) ? ' id="bereich-'.e($section['id']).'"' : '');
|
||||||
$html = '<div class="'.e(implode(' ', $classes)).'"'.$id.'>';
|
$html = '<div class="'.e(implode(' ', $classes)).'"'.$id.'>';
|
||||||
|
|
||||||
if ($hasImage) {
|
if ($hasImage) {
|
||||||
@@ -115,11 +158,26 @@ private function renderSection(array $section, array $cells, int $index, RenderC
|
|||||||
.' style="object-position: '.e(SectionStyle::FOCUS_POSITIONS[$style['focus']]).'">';
|
.' style="object-position: '.e(SectionStyle::FOCUS_POSITIONS[$style['focus']]).'">';
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= '<div class="page-section-inner"><div class="section-grid" data-slots="'.count($cells).'"'
|
// Auf dem Tablet stehen gleich breite Plätze nebeneinander (zwei oder drei je Zeile); nur dort behalten leere Plätze
|
||||||
|
// ihre Stelle. Eine Zeile, in der alle Plätze leer sind, entfällt auf dem Tablet ganz (sonst bliebe ihr Abstand stehen).
|
||||||
|
$perRow = preg_match('/^repeat\((\d+),/', $columns['md'], $match) === 1 ? (int) $match[1] : 1;
|
||||||
|
$tabletColumns = $perRow > 1 ? ' section-grid-tablet-columns' : '';
|
||||||
|
$emptyRows = [];
|
||||||
|
|
||||||
|
if ($perRow > 1) {
|
||||||
|
foreach (array_chunk(array_keys($cells), $perRow) as $row) {
|
||||||
|
if (array_filter($row, fn (int $position): bool => $cells[$position]['html'] !== '') === []) {
|
||||||
|
$emptyRows = array_merge($emptyRows, $row);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$html .= '<div class="page-section-inner"><div class="section-grid'.$tabletColumns.'" data-slots="'.count($cells).'"'
|
||||||
.' style="--section-cols-lg: '.e($columns['lg']).'; --section-cols-md: '.e($columns['md']).'">';
|
.' style="--section-cols-lg: '.e($columns['lg']).'; --section-cols-md: '.e($columns['md']).'">';
|
||||||
|
|
||||||
foreach ($cells as $cell) {
|
foreach ($cells as $position => $cell) {
|
||||||
$html .= '<div class="section-slot" data-units="'.$cell['units'].'">'.$cell['html'].'</div>';
|
$html .= $cell['html'] === ''
|
||||||
|
? '<div class="section-slot section-slot-empty'.(in_array($position, $emptyRows, true) ? ' section-slot-empty-row' : '').'" data-units="'.$cell['units'].'" aria-hidden="true"></div>'
|
||||||
|
: '<div class="section-slot" data-units="'.$cell['units'].'">'.$cell['html'].'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $html.'</div></div></div>';
|
return $html.'</div></div></div>';
|
||||||
|
|||||||
@@ -62,6 +62,26 @@ public static function symbols(): array
|
|||||||
*/
|
*/
|
||||||
public const TEXT_ALIGN = ['left' => 'Linksbündig', 'center' => 'Zentriert', 'right' => 'Rechtsbündig'];
|
public const TEXT_ALIGN = ['left' => 'Linksbündig', 'center' => 'Zentriert', 'right' => 'Rechtsbündig'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Breite des Texts in Überschrift und Fließtext: Vorgabe ist die volle Breite des Platzes (so viel, wie die Abschnitts-
|
||||||
|
* einstellung dem Widget gibt); die Lesebreite begrenzt Zeilen auf etwa 70 Zeichen (Überschrift 22 Zeichen).
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
public const TEXT_WIDTH = ['full' => 'Volle Breite des Platzes', 'reading' => 'Lesebreite (etwa 70 Zeichen je Zeile)'];
|
||||||
|
|
||||||
|
public const TEXT_WIDTH_LABEL = ['Breite des Texts', 'Volle Breite nutzt den ganzen Platz, den der Abschnitt dem Widget gibt (bei vier von vier Einheiten die ganze Zeile). Lesebreite begrenzt die Zeilen auf etwa 70 Zeichen, das liest sich bei langen Texten leichter. Vorgabe: volle Breite.'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* „reading“ nur bei ausdrücklicher, gültiger Wahl; alles andere ist die volle Breite.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $settings
|
||||||
|
*/
|
||||||
|
public static function textWidth(array $settings): string
|
||||||
|
{
|
||||||
|
return ($settings['text_width'] ?? null) === 'reading' ? 'reading' : 'full';
|
||||||
|
}
|
||||||
|
|
||||||
/** @var array<string, string> */
|
/** @var array<string, string> */
|
||||||
public const LINK_STYLE = ['text' => 'Kleiner Textlink', 'pill' => 'Pille (Schaltfläche)'];
|
public const LINK_STYLE = ['text' => 'Kleiner Textlink', 'pill' => 'Pille (Schaltfläche)'];
|
||||||
|
|
||||||
|
|||||||
@@ -120,6 +120,12 @@ public function resolve(mixed $id, bool $preview): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Ein Film, der nicht archiviert, nicht gesperrt und keine Traineranleitung ist (auch für den Medienwähler). */
|
||||||
|
public function isSelectable(ContentElement $element): bool
|
||||||
|
{
|
||||||
|
return $this->allowed($element);
|
||||||
|
}
|
||||||
|
|
||||||
/** Ein Film, der nicht archiviert, nicht gesperrt und keine Traineranleitung ist. */
|
/** Ein Film, der nicht archiviert, nicht gesperrt und keine Traineranleitung ist. */
|
||||||
private function allowed(ContentElement $element): bool
|
private function allowed(ContentElement $element): bool
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Cms\Widgets\Support;
|
||||||
|
|
||||||
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Illuminate\Support\Js;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Linkfeld für alle Widgets: Die Adresse lässt sich frei eintippen (Seitenpfad, #Sprungmarke oder http(s)-Adresse) oder
|
||||||
|
* über den Dialog „Interne Seite oder Sprungmarke wählen“ aus den Seiten der Website übernehmen
|
||||||
|
* (ChoosesLinkTargets). Der Knopf ruft den Dialog direkt auf; ein Aktionsdialog im Bausteindialog entsteht nicht. Wo die
|
||||||
|
* Seite den Dialog nicht kennt, fehlt der Knopf und das Feld bleibt ein Textfeld.
|
||||||
|
*/
|
||||||
|
final class LinkField
|
||||||
|
{
|
||||||
|
public static function make(string $name, string $label = 'Linkziel'): TextInput
|
||||||
|
{
|
||||||
|
return TextInput::make($name)
|
||||||
|
->label($label)
|
||||||
|
->maxLength(500)
|
||||||
|
->rule(SafeUrl::rule())
|
||||||
|
->suffixAction(Action::make('linkWaehlen')
|
||||||
|
->label('Interne Seite oder Sprungmarke wählen')
|
||||||
|
->tooltip('Interne Seite oder Sprungmarke wählen')
|
||||||
|
->icon('heroicon-o-link')
|
||||||
|
->visible(fn ($livewire): bool => is_object($livewire) && method_exists($livewire, 'openLinkPicker'))
|
||||||
|
->actionJs(fn ($component): string => '$wire.openLinkPicker('.Js::from($component->getStatePath()).')'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -53,10 +53,7 @@ public static function eyebrowField(): TextInput
|
|||||||
|
|
||||||
public static function ctaFields(): Grid
|
public static function ctaFields(): Grid
|
||||||
{
|
{
|
||||||
$url = fn (string $name, string $label, string $pair) => TextInput::make($name)
|
$url = fn (string $name, string $label, string $pair) => LinkField::make($name, $label)
|
||||||
->label($label)
|
|
||||||
->maxLength(500)
|
|
||||||
->rule(SafeUrl::rule())
|
|
||||||
->requiredWith($pair)
|
->requiredWith($pair)
|
||||||
->live(onBlur: true)
|
->live(onBlur: true)
|
||||||
->placeholder('/programme');
|
->placeholder('/programme');
|
||||||
|
|||||||
@@ -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'], ['bulletList', 'orderedList'], ['undo', 'redo']];
|
public const TOOLBAR = [['bold', 'italic', 'link', 'interneSeite'], ['bulletList', 'orderedList'], ['undo', 'redo']];
|
||||||
|
|
||||||
private static ?HtmlSanitizer $sanitizer = null;
|
private static ?HtmlSanitizer $sanitizer = null;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zulässige Linkziele in redaktionellen Inhalten: Seitenpfade ("/...") oder http(s)-Adressen.
|
* Zulässige Linkziele in redaktionellen Inhalten: Seitenpfade ("/...", auch mit "#marke"), Sprungmarken auf der
|
||||||
|
* eigenen Seite ("#marke") oder http(s)-Adressen. Eine Sprungmarke besteht aus Buchstaben, Ziffern, Bindestrich und Unterstrich.
|
||||||
*/
|
*/
|
||||||
final class SafeUrl implements ValidationRule
|
final class SafeUrl implements ValidationRule
|
||||||
{
|
{
|
||||||
@@ -16,6 +17,10 @@ public static function isSafe(mixed $url): bool
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (str_starts_with($url, '#')) {
|
||||||
|
return preg_match('/^#[A-Za-z0-9_-]{1,80}$/', $url) === 1;
|
||||||
|
}
|
||||||
|
|
||||||
$isRelative = str_starts_with($url, '/') && ! str_starts_with($url, '//') && ! str_starts_with($url, '/\\');
|
$isRelative = str_starts_with($url, '/') && ! str_starts_with($url, '//') && ! str_starts_with($url, '/\\');
|
||||||
$isAbsolute = preg_match('#^https?://[^/\s]+#i', $url) === 1;
|
$isAbsolute = preg_match('#^https?://[^/\s]+#i', $url) === 1;
|
||||||
|
|
||||||
@@ -24,7 +29,7 @@ public static function isSafe(mixed $url): bool
|
|||||||
|
|
||||||
public static function message(): string
|
public static function message(): string
|
||||||
{
|
{
|
||||||
return 'Erlaubt sind Seitenpfade (beginnend mit /) oder http(s)-Adressen.';
|
return 'Erlaubt sind Seitenpfade (beginnend mit /), Sprungmarken (#marke) oder http(s)-Adressen.';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Domain\Cms\Widgets\Types;
|
namespace App\Domain\Cms\Widgets\Types;
|
||||||
|
|
||||||
use App\Domain\Cms\Widgets\Support\HeadingAccent;
|
use App\Domain\Cms\Widgets\Support\HeadingAccent;
|
||||||
|
use App\Domain\Cms\Widgets\Support\LinkField;
|
||||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
@@ -82,12 +83,9 @@ public function dataFields(): array
|
|||||||
TextInput::make('heading')->label('Überschrift')->required()->maxLength(200),
|
TextInput::make('heading')->label('Überschrift')->required()->maxLength(200),
|
||||||
Textarea::make('text')->label('Text')->rows(3)->maxLength(1000),
|
Textarea::make('text')->label('Text')->rows(3)->maxLength(1000),
|
||||||
TextInput::make('label')->label('Beschriftung der Schaltfläche')->required()->maxLength(80),
|
TextInput::make('label')->label('Beschriftung der Schaltfläche')->required()->maxLength(80),
|
||||||
TextInput::make('url')
|
LinkField::make('url')
|
||||||
->label('Linkziel')
|
|
||||||
->required()
|
->required()
|
||||||
->maxLength(500)
|
->helperText('Seitenpfad wie /angebote, Sprungmarke wie #kurse oder eine vollständige http(s)-Adresse; oder über das Linksymbol eine Seite oder Sprungmarke wählen.'),
|
||||||
->rule(SafeUrl::rule())
|
|
||||||
->helperText('Seitenpfad wie /angebote oder eine vollständige http(s)-Adresse.'),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,28 +2,79 @@
|
|||||||
|
|
||||||
namespace App\Domain\Cms\Widgets\Types;
|
namespace App\Domain\Cms\Widgets\Types;
|
||||||
|
|
||||||
|
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\ImageRefFields;
|
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||||
|
use App\Domain\Cms\Widgets\Support\LinkField;
|
||||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
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\SymbolField;
|
use App\Filament\Support\SymbolField;
|
||||||
use Filament\Forms\Components\Repeater;
|
use Filament\Forms\Components\Repeater;
|
||||||
use Filament\Forms\Components\Textarea;
|
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redaktionelle Karten. Die Einträge sind freie redaktionelle Verweise, keine Produkte oder Lizenzartikel.
|
* Redaktionelle Karten. Die Einträge sind freie redaktionelle Verweise, keine Produkte oder Lizenzartikel.
|
||||||
*
|
*
|
||||||
* Version 1 umfasst den Bestand (Titel, Text, Adresse). Das optionale Bild je Karte ist eine
|
* Version 1 (Bestand): Titel, Klartext, Adresse; Bild und Symbol je Karte sind abwärtskompatible Ergänzungen derselben
|
||||||
* abwärtskompatible Ergänzung derselben Version: ältere Karten haben schlicht kein Bild.
|
* Version. Version 2: Die Beschreibung ist formatierter Text (HTML, Webprofil von FormattedText wie im Fließtext). Neu je
|
||||||
|
* Karte ist die optionale Dachzeile über dem Titel (sie wird nur gespeichert, wenn sie ausgefüllt ist).
|
||||||
*/
|
*/
|
||||||
class CardsWidget extends WidgetType
|
class CardsWidget extends WidgetType
|
||||||
{
|
{
|
||||||
|
/** Größtes zulässiges Maß des gespeicherten HTML einer Beschreibung. */
|
||||||
|
public const TEXT_MAX_LENGTH = 5000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verteilung der Karten auf die Breite: die Karten wachsen und füllen jede Zeile (Vorgabe) oder behalten ihre Breite,
|
||||||
|
* und die Abstände wachsen. In beiden Fällen sind alle Spalten gleich breit.
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
public const DISTRIBUTION = ['grow' => 'Karten vergrößern sich', 'space' => 'Abstände gleichen aus'];
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
public const DIVIDER = ['line' => 'Feiner Strich zwischen den Karten'];
|
||||||
|
|
||||||
|
private const DEFAULT_LINK_LABEL = 'Mehr erfahren';
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
public const HOVER = ['lift' => 'Karte unter der Maus hervorheben'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gültige Layout-Einstellungen mit Vorgaben; alles andere fällt auf die Vorgabe zurück (Karten wachsen, Symbol über
|
||||||
|
* dem Text, oben, ohne Strich, ohne Pinselstrich, ohne Hervorhebung).
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $settings
|
||||||
|
* @return array{align: string, size: string, position: string, valign: string, distribution: string, divider: bool, brush: bool, hover: bool, link: ?string}
|
||||||
|
*/
|
||||||
|
public static function layout(array $settings): array
|
||||||
|
{
|
||||||
|
$position = $settings['symbol_position'] ?? null;
|
||||||
|
$distribution = $settings['distribution'] ?? null;
|
||||||
|
|
||||||
|
return HeadingAccent::block($settings) + [
|
||||||
|
'position' => is_string($position) && array_key_exists($position, FeaturesWidget::SYMBOL_POSITION) ? $position : 'top',
|
||||||
|
'valign' => HeadingAccent::align($settings),
|
||||||
|
'distribution' => is_string($distribution) && array_key_exists($distribution, self::DISTRIBUTION) ? $distribution : 'grow',
|
||||||
|
'divider' => ($settings['divider'] ?? null) === 'line',
|
||||||
|
'brush' => HeadingAccent::hasBrush($settings),
|
||||||
|
'hover' => ($settings['hover'] ?? null) === 'lift',
|
||||||
|
// Sichtbarer Link unter dem Text (Textlink oder Pille); ohne Einstellung ist der Titel der Link der Karte.
|
||||||
|
'link' => in_array($settings['link_style'] ?? null, array_keys(HeadingAccent::LINK_STYLE), true) ? $settings['link_style'] : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function version(): int
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
{
|
{
|
||||||
return 'cards';
|
return 'cards';
|
||||||
@@ -36,7 +87,7 @@ public function label(): string
|
|||||||
|
|
||||||
public function description(): string
|
public function description(): string
|
||||||
{
|
{
|
||||||
return 'Mehrere Karten mit Titel, Text, Linkziel und optionalem Bild. Als Raster, kompakte Liste oder mit hervorgehobener erster Karte.';
|
return 'Mehrere Karten mit Dachzeile, Titel, formatiertem Text, Symbol, Linkziel und optionalem Bild. Als Raster, kompakte Liste oder mit hervorgehobener erster Karte.';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportedUnits(): array
|
public function supportedUnits(): array
|
||||||
@@ -46,7 +97,7 @@ public function supportedUnits(): array
|
|||||||
|
|
||||||
public function narrowBehavior(): string
|
public function narrowBehavior(): string
|
||||||
{
|
{
|
||||||
return 'Karten stehen untereinander, sobald keine zwei 15 rem breiten Karten nebeneinander passen; die hervorgehobene Karte stapelt Bild und Text.';
|
return 'Die Karten sind mindestens 15 rem breit (mit Symbol neben dem Text 18 rem) und verteilen sich ausgewogen auf Zeilen (zehn Karten als 4, 3 und 3); passen keine zwei Karten nebeneinander, stehen sie untereinander. Bei „Abstände gleichen aus“ behalten sie ihre Breite (höchstens 20 rem). Die hervorgehobene Karte stapelt Bild und Text.';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function preferredUnits(): int
|
public function preferredUnits(): int
|
||||||
@@ -58,7 +109,7 @@ public function stages(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'narrow' => 'eine Karte je Zeile',
|
'narrow' => 'eine Karte je Zeile',
|
||||||
'wide' => 'so viele Karten nebeneinander, wie bei mindestens 15rem Kartenbreite passen; hervorgehobene Karte ab 44rem mit Bild neben dem Text',
|
'wide' => 'so viele Karten nebeneinander, wie bei mindestens 15rem Kartenbreite passen, ausgewogen auf die Zeilen verteilt; hervorgehobene Karte ab 44rem mit Bild neben dem Text',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,9 +136,11 @@ public function dataRules(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'items' => ['required', 'array', 'min:1', 'max:12'],
|
'items' => ['required', 'array', 'min:1', 'max:12'],
|
||||||
|
'items.*.eyebrow' => ['nullable', 'string', 'max:80'],
|
||||||
'items.*.title' => ['required', 'string', 'max:120'],
|
'items.*.title' => ['required', 'string', 'max:120'],
|
||||||
'items.*.text' => ['nullable', 'string', 'max:500'],
|
'items.*.text' => ['nullable', 'string', 'max:'.self::TEXT_MAX_LENGTH],
|
||||||
'items.*.url' => ['nullable', 'string', 'max:500'],
|
'items.*.url' => ['nullable', 'string', 'max:500'],
|
||||||
|
'items.*.link_label' => ['nullable', 'string', 'max:60'],
|
||||||
'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'],
|
||||||
@@ -97,21 +150,40 @@ public function dataRules(): array
|
|||||||
public function settings(): array
|
public function settings(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'symbol_size' => HeadingAccent::STEPS,
|
'distribution' => self::DISTRIBUTION,
|
||||||
'align' => HeadingAccent::TEXT_ALIGN,
|
'align' => HeadingAccent::TEXT_ALIGN,
|
||||||
|
'symbol_size' => HeadingAccent::STEPS,
|
||||||
|
'symbol_position' => FeaturesWidget::SYMBOL_POSITION,
|
||||||
|
'symbol_align' => HeadingAccent::ALIGN,
|
||||||
|
'accent' => HeadingAccent::BRUSH,
|
||||||
|
'divider' => self::DIVIDER,
|
||||||
|
'hover' => self::HOVER,
|
||||||
|
'link_style' => HeadingAccent::LINK_STYLE,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settingGroups(): array
|
public function settingGroups(): array
|
||||||
{
|
{
|
||||||
return ['Aussehen' => ['symbol_size', 'align']];
|
return [
|
||||||
|
'Verteilung' => ['distribution', 'align'],
|
||||||
|
'Symbol' => ['symbol_size', 'symbol_position', 'symbol_align'],
|
||||||
|
'Gestaltung' => ['accent', 'divider', 'hover'],
|
||||||
|
'Link' => ['link_style'],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settingLabels(): array
|
public function settingLabels(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
'distribution' => ['Verteilung der Karten', 'Wie die Karten den verfügbaren Platz füllen. Die Zeilen sind in beiden Fällen ausgewogen (fünf Karten stehen als drei und zwei, zehn als vier, drei und drei) und jede Karte ist mindestens 15 rem breit (mit Symbol neben dem Text 18 rem); wird das unterschritten, wandert eine Karte in die nächste Zeile. „Karten vergrößern sich“ (Vorgabe): Jede Zeile wird ganz ausgefüllt. „Abstände gleichen aus“: Die Karten behalten eine feste Breite (höchstens 20 rem), und der übrige Platz verteilt sich gleichmäßig zwischen und neben den Karten. Möglich sind eine bis zwölf Karten.'],
|
||||||
|
'align' => ['Ausrichtung', 'Richtet Symbol, Dachzeile, Titel, Pinselstrich und Text jeder Karte aus. Vorgabe: linksbündig.'],
|
||||||
'symbol_size' => ['Größe der Symbole', 'Kantenlänge der Symbole auf den Karten, die eins haben: Klein 2,5 rem, Mittel 3,5 rem, Groß 5 rem, Sehr groß 7 rem. Vorgabe: Mittel.'],
|
'symbol_size' => ['Größe der Symbole', 'Kantenlänge der Symbole auf den Karten, die eins haben: Klein 2,5 rem, Mittel 3,5 rem, Groß 5 rem, Sehr groß 7 rem. Vorgabe: Mittel.'],
|
||||||
'align' => ['Ausrichtung', 'Richtet Symbol, Titel und Text jeder Karte aus. Vorgabe: linksbündig.'],
|
'symbol_position' => ['Lage des Symbols', 'Über dem Text (Vorgabe) oder links bzw. rechts neben Dachzeile, Titel und Text jeder Karte. Neben dem Text braucht jede Karte mindestens 18 rem Breite, sonst stehen die Karten untereinander. Vorgabe: über dem Text.'],
|
||||||
|
'symbol_align' => ['Senkrechte Lage des Symbols', 'Wo das Symbol neben dem Text sitzt: oben (Vorgabe), mittig oder unten. Wirkt nur, wenn das Symbol links oder rechts neben dem Text steht.'],
|
||||||
|
'accent' => ['Pinselstrich', 'Gelbe Unterstreichung unter dem Titel jeder Karte (freigegebenes Motiv aus dem Brand-Kit). Vorgabe: ohne.'],
|
||||||
|
'divider' => ['Trennstrich', 'Ein feiner Strich zwischen den Karten: senkrecht zwischen Spalten, waagerecht zwischen Zeilen. Die Karten verlieren dabei ihre Fläche und stehen flach auf dem Abschnitt, wie in der Merkmalszeile. In der kompakten Liste wirkt die Einstellung nicht, sie hat schon Linien. Vorgabe: ohne.'],
|
||||||
|
'link_style' => ['Link unter dem Text', 'Zeigt unter dem Text jeder Karte mit Linkziel einen sichtbaren Link: als kleiner Textlink oder als Pille (Schaltfläche). Die ganze Karte bleibt anklickbar, der Titel ist dann kein eigener Link. Der Linktext steht je Karte (leer: „'.self::DEFAULT_LINK_LABEL.'“). Vorgabe: kein sichtbarer Link, die Karte öffnet sich über den Titel.'],
|
||||||
|
'hover' => ['Hervorhebung unter der Maus', 'Die Karte, über der die Maus steht (oder die per Tastatur erreicht wird), hebt sich leicht ab. Ohne Bewegung, wenn das Betriebssystem reduzierte Bewegung wünscht. Vorgabe: ohne.'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,15 +195,22 @@ public function dataFields(): array
|
|||||||
Repeater::make('items')
|
Repeater::make('items')
|
||||||
->label('Karten')
|
->label('Karten')
|
||||||
->schema([
|
->schema([
|
||||||
|
TextInput::make('eyebrow')
|
||||||
|
->label('Dachzeile (optional)')
|
||||||
|
->maxLength(80)
|
||||||
|
->helperText('Kurzer Hinweis über dem Titel, zum Beispiel ein Themenbereich. Kein Pflichtfeld.'),
|
||||||
TextInput::make('title')->label('Titel')->required()->maxLength(120),
|
TextInput::make('title')->label('Titel')->required()->maxLength(120),
|
||||||
SymbolField::make('symbol', 'Symbol (optional)')
|
SymbolField::make('symbol', 'Symbol (optional)')
|
||||||
->helperText('Kleine Grafik aus dem Brand-Kit über dem Titel. Größe und Ausrichtung im Reiter „Darstellung“.'),
|
->helperText('Kleine Grafik aus dem Brand-Kit. Größe, Lage und senkrechte Ausrichtung im Reiter „Darstellung“.'),
|
||||||
Textarea::make('text')->label('Beschreibung')->rows(2)->maxLength(500),
|
RichField::make('text', 'Beschreibung', website: true)
|
||||||
TextInput::make('url')
|
->helperText('Wie beim Fließtext: Absätze und Zeilenumbrüche (Umschalt + Eingabe), fett, kursiv, Links, Listen, Schriftgröße, Schriftfarbe und Ausrichtung. Die Karten bleiben auch auf dunklen und grünen Abschnitten hell; die Farben entsprechen dort denen auf hellen Flächen.'),
|
||||||
->label('Linkziel')
|
LinkField::make('url')
|
||||||
->maxLength(500)
|
->helperText('Seitenpfad wie /praevention, Sprungmarke wie #kurse oder eine http(s)-Adresse; oder über das Linksymbol wählen. Leer lassen für eine Karte ohne Link.'),
|
||||||
->rule(SafeUrl::rule())
|
TextInput::make('link_label')
|
||||||
->helperText('Seitenpfad wie /praevention oder eine http(s)-Adresse. Leer lassen für eine Karte ohne Link.'),
|
->label('Linktext (optional)')
|
||||||
|
->maxLength(60)
|
||||||
|
->placeholder(self::DEFAULT_LINK_LABEL)
|
||||||
|
->helperText('Nur sichtbar, wenn im Reiter „Darstellung“ ein Link unter dem Text gewählt ist, und nur mit Linkziel. Leer: „'.self::DEFAULT_LINK_LABEL.'“.'),
|
||||||
$image,
|
$image,
|
||||||
$upload,
|
$upload,
|
||||||
$status,
|
$status,
|
||||||
@@ -146,6 +225,36 @@ public function dataFields(): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function upgrade(array $widget, int $from): array
|
||||||
|
{
|
||||||
|
if ($from === 1) {
|
||||||
|
foreach ($widget['data']['items'] ?? [] as $index => $item) {
|
||||||
|
if (is_array($item) && filled($item['text'] ?? null)) {
|
||||||
|
$widget['data']['items'][$index]['text'] = self::plainToHtml((string) $item['text']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::upgrade($widget, $from);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Klartext der Version 1 als formatierter Text: Leerzeilen trennen Absätze, ein einfacher Zeilenumbruch bleibt ein
|
||||||
|
* Zeilenumbruch (so wie in der Überschrift mit Einleitung).
|
||||||
|
*/
|
||||||
|
public static function plainToHtml(string $text): string
|
||||||
|
{
|
||||||
|
$paragraphs = preg_split('/\R\s*\R/u', trim($text)) ?: [];
|
||||||
|
$html = implode('', array_map(
|
||||||
|
fn (string $paragraph): string => trim($paragraph) === '' ? '' : '<p>'.preg_replace('/\R/u', '<br>', e(trim($paragraph))).'</p>',
|
||||||
|
$paragraphs,
|
||||||
|
));
|
||||||
|
|
||||||
|
return FormattedText::canonicalHtml($html, true);
|
||||||
|
}
|
||||||
|
|
||||||
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||||
{
|
{
|
||||||
foreach ($data['items'] as $index => $item) {
|
foreach ($data['items'] as $index => $item) {
|
||||||
@@ -155,11 +264,17 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
|||||||
|
|
||||||
$itemRefs = ImageRefFields::clean(['image' => $item['image'] ?? null, '_upload' => $item['_upload'] ?? null], $errors, errorKey: "data.items.$index.image");
|
$itemRefs = ImageRefFields::clean(['image' => $item['image'] ?? null, '_upload' => $item['_upload'] ?? null], $errors, errorKey: "data.items.$index.image");
|
||||||
|
|
||||||
// Der Schlüssel symbol wird nur gespeichert, wenn ein Symbol gewählt ist: Karten ohne Symbol bleiben byteweise wie zuvor.
|
$text = FormattedText::canonical(is_string($item['text'] ?? null) ? $item['text'] : '', true);
|
||||||
|
|
||||||
|
// Die Schlüssel eyebrow und symbol werden nur gespeichert, wenn sie ausgefüllt sind: Karten ohne sie bleiben
|
||||||
|
// byteweise wie zuvor.
|
||||||
$data['items'][$index] = [
|
$data['items'][$index] = [
|
||||||
|
...(filled($item['eyebrow'] ?? null) ? ['eyebrow' => trim((string) $item['eyebrow'])] : []),
|
||||||
'title' => $item['title'],
|
'title' => $item['title'],
|
||||||
'text' => filled($item['text'] ?? null) ? $item['text'] : null,
|
'text' => $text !== '' ? $text : null,
|
||||||
'url' => filled($item['url'] ?? null) ? $item['url'] : null,
|
'url' => filled($item['url'] ?? null) ? $item['url'] : null,
|
||||||
|
// Ein Linktext ohne Linkziel wird verworfen; ohne Linktext bleibt der Schlüssel weg (Karten bleiben wie zuvor).
|
||||||
|
...(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'],
|
||||||
];
|
];
|
||||||
@@ -180,9 +295,11 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
$items[] = [
|
$items[] = [
|
||||||
|
'eyebrow' => filled($item['eyebrow'] ?? null) ? $item['eyebrow'] : null,
|
||||||
'title' => $item['title'],
|
'title' => $item['title'],
|
||||||
'text' => $item['text'] ?? null,
|
'textHtml' => filled($item['text'] ?? null) ? ProseWidget::render($item['text']) : '',
|
||||||
'url' => SafeUrl::isSafe($item['url'] ?? null) ? $item['url'] : null,
|
'url' => SafeUrl::isSafe($item['url'] ?? null) ? $item['url'] : null,
|
||||||
|
'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),
|
||||||
];
|
];
|
||||||
@@ -194,7 +311,7 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'items' => $items,
|
'items' => $items,
|
||||||
'layout' => HeadingAccent::block($widget['settings'] ?? []),
|
'layout' => self::layout($widget['settings'] ?? []),
|
||||||
'imageNotice' => $notices === [] ? null : implode(' ', $notices),
|
'imageNotice' => $notices === [] ? null : implode(' ', $notices),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,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\LinkField;
|
||||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
@@ -34,18 +35,31 @@ class FeaturesWidget extends WidgetType
|
|||||||
*/
|
*/
|
||||||
public const SYMBOL_SIZE = HeadingAccent::STEPS;
|
public const SYMBOL_SIZE = HeadingAccent::STEPS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lage des Symbols zum Text jedes Merkmals: über dem Text (Vorgabe), links oder rechts daneben.
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
public const SYMBOL_POSITION = ['top' => 'Über dem Text', 'left' => 'Links neben dem Text', 'right' => 'Rechts neben dem Text'];
|
||||||
|
|
||||||
/** @var array<string, string> */
|
/** @var array<string, string> */
|
||||||
public const DIVIDER = ['line' => 'Feiner Strich zwischen den Merkmalen'];
|
public const DIVIDER = ['line' => 'Feiner Strich zwischen den Merkmalen'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gültige Layout-Einstellungen mit Vorgaben (links, mittel, ohne Strich); alles andere fällt auf die Vorgabe zurück.
|
* Gültige Layout-Einstellungen mit Vorgaben (links, mittel, Symbol oben, ohne Strich); alles andere fällt auf die
|
||||||
|
* Vorgabe zurück.
|
||||||
*
|
*
|
||||||
* @param array<string, mixed> $settings
|
* @param array<string, mixed> $settings
|
||||||
* @return array{align: string, size: string, divider: bool}
|
* @return array{align: string, size: string, position: string, divider: bool}
|
||||||
*/
|
*/
|
||||||
public static function layout(array $settings): array
|
public static function layout(array $settings): array
|
||||||
{
|
{
|
||||||
return HeadingAccent::block($settings) + ['divider' => ($settings['divider'] ?? null) === 'line'];
|
$position = $settings['symbol_position'] ?? null;
|
||||||
|
|
||||||
|
return HeadingAccent::block($settings) + [
|
||||||
|
'position' => is_string($position) && array_key_exists($position, self::SYMBOL_POSITION) ? $position : 'top',
|
||||||
|
'divider' => ($settings['divider'] ?? null) === 'line',
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
@@ -70,7 +84,7 @@ public function supportedUnits(): array
|
|||||||
|
|
||||||
public function narrowBehavior(): string
|
public function narrowBehavior(): string
|
||||||
{
|
{
|
||||||
return 'Die Merkmale stehen nebeneinander, solange jedes mindestens 12 rem breit bleibt; darunter stehen sie untereinander.';
|
return 'Die Merkmale stehen nebeneinander, solange jedes mindestens 12 rem breit bleibt (mit Symbol neben dem Text 18 rem); darunter stehen sie untereinander.';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function preferredUnits(): int
|
public function preferredUnits(): int
|
||||||
@@ -113,6 +127,7 @@ public function settings(): array
|
|||||||
return [
|
return [
|
||||||
'align' => self::ALIGN,
|
'align' => self::ALIGN,
|
||||||
'symbol_size' => self::SYMBOL_SIZE,
|
'symbol_size' => self::SYMBOL_SIZE,
|
||||||
|
'symbol_position' => self::SYMBOL_POSITION,
|
||||||
'divider' => self::DIVIDER,
|
'divider' => self::DIVIDER,
|
||||||
'link_style' => HeadingAccent::LINK_STYLE,
|
'link_style' => HeadingAccent::LINK_STYLE,
|
||||||
];
|
];
|
||||||
@@ -120,7 +135,7 @@ public function settings(): array
|
|||||||
|
|
||||||
public function settingGroups(): array
|
public function settingGroups(): array
|
||||||
{
|
{
|
||||||
return ['Aussehen' => ['align', 'symbol_size', 'divider', 'link_style']];
|
return ['Aussehen' => ['align', 'symbol_size', 'symbol_position', 'divider', 'link_style']];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settingLabels(): array
|
public function settingLabels(): array
|
||||||
@@ -128,6 +143,7 @@ public function settingLabels(): array
|
|||||||
return [
|
return [
|
||||||
'align' => ['Ausrichtung', 'Richtet Symbol, Titel, Satz und Link jedes Merkmals aus. Vorgabe: linksbündig.'],
|
'align' => ['Ausrichtung', 'Richtet Symbol, Titel, Satz und Link jedes Merkmals aus. Vorgabe: linksbündig.'],
|
||||||
'symbol_size' => ['Größe der Symbole', 'Kantenlänge der Symbole: Klein 2,5 rem, Mittel 3,5 rem, Groß 5 rem, Sehr groß 7 rem. Vorgabe: Mittel.'],
|
'symbol_size' => ['Größe der Symbole', 'Kantenlänge der Symbole: Klein 2,5 rem, Mittel 3,5 rem, Groß 5 rem, Sehr groß 7 rem. Vorgabe: Mittel.'],
|
||||||
|
'symbol_position' => ['Lage des Symbols', 'Über dem Text (Vorgabe) oder links bzw. rechts neben Titel, Satz und Link jedes Merkmals. Neben dem Text braucht jedes Merkmal mindestens 18 rem Breite, sonst stehen die Merkmale untereinander. Vorgabe: über dem Text.'],
|
||||||
'divider' => ['Trennstrich', 'Ein feiner Strich zwischen den Merkmalen: senkrecht zwischen Spalten, waagerecht zwischen Zeilen und bei untereinander stehenden Merkmalen. Vorgabe: ohne.'],
|
'divider' => ['Trennstrich', 'Ein feiner Strich zwischen den Merkmalen: senkrecht zwischen Spalten, waagerecht zwischen Zeilen und bei untereinander stehenden Merkmalen. Vorgabe: ohne.'],
|
||||||
'link_style' => HeadingAccent::LINK_STYLE_LABEL,
|
'link_style' => HeadingAccent::LINK_STYLE_LABEL,
|
||||||
];
|
];
|
||||||
@@ -142,11 +158,8 @@ public function dataFields(): array
|
|||||||
SymbolField::make('symbol', 'Symbol', required: true),
|
SymbolField::make('symbol', 'Symbol', required: true),
|
||||||
TextInput::make('title')->label('Kurztitel')->required()->maxLength(60),
|
TextInput::make('title')->label('Kurztitel')->required()->maxLength(60),
|
||||||
Textarea::make('text')->label('Satz')->rows(2)->maxLength(200),
|
Textarea::make('text')->label('Satz')->rows(2)->maxLength(200),
|
||||||
TextInput::make('url')
|
LinkField::make('url', 'Linkziel (optional)')
|
||||||
->label('Linkziel (optional)')
|
->helperText('Seitenpfad wie /materialien, Sprungmarke wie #kurse oder eine http(s)-Adresse; oder über das Linksymbol wählen. Leer lassen für ein Merkmal ohne Link.'),
|
||||||
->maxLength(500)
|
|
||||||
->rule(SafeUrl::rule())
|
|
||||||
->helperText('Seitenpfad wie /materialien oder eine http(s)-Adresse. Leer lassen für ein Merkmal ohne Link.'),
|
|
||||||
TextInput::make('link_label')
|
TextInput::make('link_label')
|
||||||
->label('Linktext')
|
->label('Linktext')
|
||||||
->maxLength(60)
|
->maxLength(60)
|
||||||
|
|||||||
@@ -2,13 +2,31 @@
|
|||||||
|
|
||||||
namespace App\Domain\Cms\Widgets\Types;
|
namespace App\Domain\Cms\Widgets\Types;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\FormattedText;
|
||||||
|
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\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
use Filament\Forms\Components\Textarea;
|
use App\Filament\Support\RichField;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Überschrift mit Einleitung. Die Einleitung wird im Editor des Fließtexts geschrieben (Absätze, Zeilenumbrüche, fett,
|
||||||
|
* kursiv, Links, Listen, Schriftgröße, -farbe, Ausrichtung; Webprofil von FormattedText) und so dargestellt wie dort.
|
||||||
|
*
|
||||||
|
* Version 1 (Bestand): Einleitung als Klartext; eine Leerzeile beginnt einen Absatz, ein einfacher Zeilenumbruch bleibt
|
||||||
|
* ein Zeilenumbruch. Version 2: formatierter Text (HTML).
|
||||||
|
*/
|
||||||
class HeadingWidget extends WidgetType
|
class HeadingWidget extends WidgetType
|
||||||
{
|
{
|
||||||
|
/** Größtes zulässiges Maß des gespeicherten HTML der Einleitung. */
|
||||||
|
public const INTRO_MAX_LENGTH = 20000;
|
||||||
|
|
||||||
|
public function version(): int
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
{
|
{
|
||||||
return 'heading';
|
return 'heading';
|
||||||
@@ -60,15 +78,56 @@ public function dataRules(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'heading' => ['required', 'string', 'max:200'],
|
'heading' => ['required', 'string', 'max:200'],
|
||||||
'intro' => ['nullable', 'string', 'max:1000'],
|
'intro' => ['nullable', 'string', 'max:'.self::INTRO_MAX_LENGTH],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function upgrade(array $widget, int $from): array
|
||||||
|
{
|
||||||
|
if ($from === 1) {
|
||||||
|
$intro = $widget['data']['intro'] ?? '';
|
||||||
|
$paragraphs = preg_split("/
|
||||||
|
\s*
|
||||||
|
/", trim(is_string($intro) ? $intro : '')) ?: [];
|
||||||
|
$html = implode('', array_map(
|
||||||
|
fn (string $paragraph): string => trim($paragraph) === '' ? '' : '<p>'.preg_replace('/\R/u', '<br>', e(trim($paragraph))).'</p>',
|
||||||
|
$paragraphs,
|
||||||
|
));
|
||||||
|
|
||||||
|
$widget['data']['intro'] = FormattedText::canonicalHtml($html, true);
|
||||||
|
|
||||||
|
return $widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::upgrade($widget, $from);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||||
|
{
|
||||||
|
$intro = FormattedText::canonical(is_string($data['intro'] ?? null) ? $data['intro'] : '', true);
|
||||||
|
|
||||||
|
if ($intro === '') {
|
||||||
|
unset($data['intro']);
|
||||||
|
} else {
|
||||||
|
$data['intro'] = $intro;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$data, $refs];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolve(array $widget, RenderContext $context): array
|
||||||
|
{
|
||||||
|
$intro = $widget['data']['intro'] ?? null;
|
||||||
|
|
||||||
|
return ['introHtml' => is_string($intro) && trim($intro) !== '' ? ProseWidget::render($intro) : ''];
|
||||||
|
}
|
||||||
|
|
||||||
public function dataFields(): array
|
public function dataFields(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
TextInput::make('heading')->label('Überschrift')->required()->maxLength(200),
|
TextInput::make('heading')->label('Überschrift')->required()->maxLength(200),
|
||||||
Textarea::make('intro')->label('Einleitung')->rows(3)->maxLength(1000),
|
RichField::make('intro', 'Einleitung', website: true)
|
||||||
|
->helperText('Wie beim Fließtext: Absätze und Zeilenumbrüche (Umschalt + Eingabe), fett, kursiv, Links, Listen, Zitate und Tabellen, dazu Schriftgröße, Schriftfarbe (Marine, Grün, Rot, Grau) und Ausrichtung. Auf dunklen und grünen Flächen werden die Farben aufgehellt, damit die Schrift lesbar bleibt.'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,12 +138,13 @@ public function settings(): array
|
|||||||
'symbol_size' => HeadingAccent::SIZE,
|
'symbol_size' => HeadingAccent::SIZE,
|
||||||
'symbol_align' => HeadingAccent::ALIGN,
|
'symbol_align' => HeadingAccent::ALIGN,
|
||||||
'accent' => HeadingAccent::BRUSH,
|
'accent' => HeadingAccent::BRUSH,
|
||||||
|
'text_width' => HeadingAccent::TEXT_WIDTH,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settingGroups(): array
|
public function settingGroups(): array
|
||||||
{
|
{
|
||||||
return ['Aussehen' => ['symbol', 'symbol_size', 'symbol_align', 'accent']];
|
return ['Aussehen' => ['text_width', 'symbol', 'symbol_size', 'symbol_align', 'accent']];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settingLabels(): array
|
public function settingLabels(): array
|
||||||
@@ -94,6 +154,7 @@ public function settingLabels(): array
|
|||||||
'symbol_size' => HeadingAccent::SIZE_LABEL,
|
'symbol_size' => HeadingAccent::SIZE_LABEL,
|
||||||
'symbol_align' => HeadingAccent::ALIGN_LABEL,
|
'symbol_align' => HeadingAccent::ALIGN_LABEL,
|
||||||
'accent' => HeadingAccent::BRUSH_LABEL,
|
'accent' => HeadingAccent::BRUSH_LABEL,
|
||||||
|
'text_width' => HeadingAccent::TEXT_WIDTH_LABEL,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,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\HeroVideo;
|
||||||
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;
|
||||||
@@ -11,8 +12,10 @@
|
|||||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
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 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\Schemas\Components\Group;
|
use Filament\Schemas\Components\Group;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,6 +23,11 @@
|
|||||||
*
|
*
|
||||||
* Version 1 (Bestand): data {image, alt, body} mit Klartext.
|
* Version 1 (Bestand): data {image, alt, body} mit Klartext.
|
||||||
* Version 2: data {title, body (formatierter Text), alt}, refs {image}, Varianten Bild links/rechts.
|
* Version 2: data {title, body (formatierter Text), alt}, refs {image}, Varianten Bild links/rechts.
|
||||||
|
* Ohne Versionssprung ergänzt (ältere Revisionen bleiben unverändert darstellbar): Bildanteil (settings.image_share),
|
||||||
|
* Bild ohne Text (Text ist nicht mehr Pflicht, wenn ein Bild gewählt ist) und ein Video (refs.video, ein Film aus dem
|
||||||
|
* Medienmanager): Das freigegebene Video (Trailer, Vorschauclip oder Website-Datei, Regel CardClip) spielt auf dem Bild
|
||||||
|
* beim Überfahren mit der Maus stumm und per Klick oder Schaltfläche mit Ton, wie auf der Medienkarte.
|
||||||
|
*
|
||||||
* Version 3: zusätzlich Label, zwei Schaltflächen, Bildfokus in Prozent; Einstellungen Oberfläche, Höhe und
|
* Version 3: zusätzlich Label, zwei Schaltflächen, Bildfokus in Prozent; Einstellungen Oberfläche, Höhe und
|
||||||
* Überschriftenebene. Die Bildseite bleibt die Variante (keine doppelte Einstellung). Die Einstellung
|
* Überschriftenebene. Die Bildseite bleibt die Variante (keine doppelte Einstellung). Die Einstellung
|
||||||
* format der Designiteration 1 entfällt; die Bildproportion folgt jetzt der Höhe.
|
* format der Designiteration 1 entfällt; die Bildproportion folgt jetzt der Höhe.
|
||||||
@@ -110,10 +118,25 @@ public function optionIcons(): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bildanteil an der Breite im zweispaltigen Stand (ab 900 px Containerbreite): Bild- und Textspalte als Verhältnis.
|
||||||
|
* Ohne Wert gilt die bisherige Verteilung (Text 1,1 : Bild 0,9, je nach Bildseite).
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
public const IMAGE_SHARE = [
|
||||||
|
'third' => 'Schmales Bild (ein Drittel Bild, zwei Drittel Text)',
|
||||||
|
'two_fifths' => 'Eher schmales Bild (40 % Bild, 60 % Text)',
|
||||||
|
'half' => 'Gleich breit (je die Hälfte)',
|
||||||
|
'three_fifths' => 'Eher breites Bild (60 % Bild, 40 % Text)',
|
||||||
|
'two_thirds' => 'Breites Bild (zwei Drittel Bild, ein Drittel Text)',
|
||||||
|
];
|
||||||
|
|
||||||
public function settings(): array
|
public function settings(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'surface' => ['cream' => 'Creme (Markenfläche)', 'clear' => 'Ohne eigene Fläche', 'navy' => 'Navy (dunkel)'],
|
'surface' => ['cream' => 'Creme (Markenfläche)', 'clear' => 'Ohne eigene Fläche', 'navy' => 'Navy (dunkel)'],
|
||||||
|
'image_share' => self::IMAGE_SHARE,
|
||||||
'heading_level' => PremiumFields::HEADING_LEVELS,
|
'heading_level' => PremiumFields::HEADING_LEVELS,
|
||||||
'symbol' => HeadingAccent::symbols(),
|
'symbol' => HeadingAccent::symbols(),
|
||||||
'symbol_size' => HeadingAccent::SIZE,
|
'symbol_size' => HeadingAccent::SIZE,
|
||||||
@@ -124,7 +147,7 @@ public function settings(): array
|
|||||||
public function settingGroups(): array
|
public function settingGroups(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'Aussehen' => ['surface', 'symbol', 'symbol_size', 'symbol_align'],
|
'Aussehen' => ['surface', 'image_share', 'symbol', 'symbol_size', 'symbol_align'],
|
||||||
'Seitenstruktur' => ['heading_level'],
|
'Seitenstruktur' => ['heading_level'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -133,6 +156,7 @@ 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.'],
|
||||||
|
'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.'],
|
||||||
'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,
|
||||||
@@ -180,13 +204,14 @@ public function dataRules(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'title' => ['nullable', 'string', 'max:160'],
|
'title' => ['nullable', 'string', 'max:160'],
|
||||||
'body' => ['required', 'string', 'max:40000'],
|
// Der Text ist nur Pflicht, solange kein Bild gewählt ist (clean); ein Bild darf allein stehen.
|
||||||
|
'body' => ['nullable', 'string', 'max:40000'],
|
||||||
] + PremiumFields::rules();
|
] + PremiumFields::rules();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function refRules(): array
|
public function refRules(): array
|
||||||
{
|
{
|
||||||
return ImageRefFields::rules();
|
return ImageRefFields::rules() + ['video' => ['nullable']];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataFields(): array
|
public function dataFields(): array
|
||||||
@@ -196,8 +221,9 @@ public function dataFields(): array
|
|||||||
TextInput::make('title')->label('Überschrift')->maxLength(160)->live(onBlur: true),
|
TextInput::make('title')->label('Überschrift')->maxLength(160)->live(onBlur: true),
|
||||||
RichEditor::make('body')
|
RichEditor::make('body')
|
||||||
->label('Text')
|
->label('Text')
|
||||||
->required()
|
->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])
|
||||||
->toolbarButtons(RichText::TOOLBAR),
|
->toolbarButtons(RichText::TOOLBAR),
|
||||||
PremiumFields::ctaFields(),
|
PremiumFields::ctaFields(),
|
||||||
PremiumFields::altField(),
|
PremiumFields::altField(),
|
||||||
@@ -207,7 +233,16 @@ public function dataFields(): array
|
|||||||
|
|
||||||
public function refFields(): array
|
public function refFields(): array
|
||||||
{
|
{
|
||||||
return ImageRefFields::fields(live: true);
|
return [...ImageRefFields::fields(live: true), $this->videoField()];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function videoField(): ViewField
|
||||||
|
{
|
||||||
|
return ViewField::make('video')
|
||||||
|
->live()
|
||||||
|
->label('Video (optional)')
|
||||||
|
->view('filament.cms.video-feld')
|
||||||
|
->helperText('Ein Film aus dem Medienmanager, über denselben Wähler wie das Bild. Das Bild bleibt stehen; das Video spielt darauf beim Überfahren stumm und per Klick oder Schaltfläche mit Ton, nur wenn ein Trailer, Vorschauclip oder die Website-Datei des Films für die Website freigegeben ist. Die Auswahl gibt nichts frei.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function editorSchema(): array
|
public function editorSchema(): array
|
||||||
@@ -234,13 +269,47 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
|||||||
$data['title'] = filled($data['title'] ?? null) ? trim((string) $data['title']) : null;
|
$data['title'] = filled($data['title'] ?? null) ? trim((string) $data['title']) : null;
|
||||||
$data = PremiumFields::clean($data, $errors, $refs['image'] !== null);
|
$data = PremiumFields::clean($data, $errors, $refs['image'] !== null);
|
||||||
|
|
||||||
if (RichText::isBlank($data['body'])) {
|
$video = app(HeroVideo::class)->clean($refs['video'] ?? null, $errors);
|
||||||
$errors->add('data.body', 'Bitte einen Text eingeben.');
|
$video === null ? $refs = array_diff_key($refs, ['video' => true]) : $refs['video'] = $video;
|
||||||
|
|
||||||
|
if ($video !== null && $refs['image'] === null) {
|
||||||
|
$errors->add('refs.image', 'Bitte auch ein Bild wählen: Es steht, bis das Video startet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($refs['image'] === null && ! self::hasCopy($data)) {
|
||||||
|
$errors->add('data.body', 'Bitte einen Text eingeben oder ein Bild wählen.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return [$data, $refs];
|
return [$data, $refs];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ob neben dem Bild etwas zu lesen ist: Text, Überschrift, Label oder Schaltfläche. Ohne bleibt das Bild allein.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $data
|
||||||
|
*/
|
||||||
|
public static function hasCopy(array $data): bool
|
||||||
|
{
|
||||||
|
$body = is_string($data['body'] ?? null) ? RichText::sanitize($data['body']) : '';
|
||||||
|
|
||||||
|
return ! RichText::isBlank($body)
|
||||||
|
|| filled($data['title'] ?? null)
|
||||||
|
|| filled($data['eyebrow'] ?? null)
|
||||||
|
|| PremiumFields::actions($data) !== [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gültiger Bildanteil oder null (bisherige Verteilung).
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $settings
|
||||||
|
*/
|
||||||
|
public static function imageShare(array $settings): ?string
|
||||||
|
{
|
||||||
|
$share = $settings['image_share'] ?? null;
|
||||||
|
|
||||||
|
return is_string($share) && array_key_exists($share, self::IMAGE_SHARE) ? $share : null;
|
||||||
|
}
|
||||||
|
|
||||||
public function resolve(array $widget, RenderContext $context): array
|
public function resolve(array $widget, RenderContext $context): array
|
||||||
{
|
{
|
||||||
$surface = $widget['settings']['surface'] ?? 'cream';
|
$surface = $widget['settings']['surface'] ?? 'cream';
|
||||||
@@ -248,10 +317,23 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
$images = app(WebsiteImage::class);
|
$images = app(WebsiteImage::class);
|
||||||
$image = $widget['refs']['image'] ?? null;
|
$image = $widget['refs']['image'] ?? null;
|
||||||
|
|
||||||
|
$imageUrl = $images->url($image, $context->preview);
|
||||||
|
$imageAlt = $images->alt($image, $widget['data']['alt'] ?? null);
|
||||||
|
$hasCopy = self::hasCopy($widget['data'] ?? []);
|
||||||
|
$video = app(HeroVideo::class)->resolve($widget['refs']['video'] ?? null, $context->preview);
|
||||||
|
|
||||||
|
// Ohne Bild gibt es nichts, worauf das Video stehen könnte; die Redaktion erfährt es in der Vorschau.
|
||||||
|
if ($imageUrl === null && $video['url'] !== null) {
|
||||||
|
$video = ['url' => null, 'title' => $video['title'], 'notice' => $context->preview ? 'Das Video braucht ein Bild: Es steht, bis das Video startet. Bitte ein Bild wählen.' : null];
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'imageUrl' => $images->url($image, $context->preview),
|
'imageUrl' => $imageUrl,
|
||||||
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
'imageAlt' => $imageAlt,
|
||||||
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||||
|
'video' => $video,
|
||||||
|
'hasCopy' => $hasCopy,
|
||||||
|
'imageShare' => self::imageShare($widget['settings'] ?? []),
|
||||||
'body' => RichText::sanitize(is_string($widget['data']['body'] ?? null) ? $widget['data']['body'] : ''),
|
'body' => 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),
|
||||||
@@ -270,6 +352,16 @@ public function summary(array $widget): string
|
|||||||
{
|
{
|
||||||
$title = $widget['data']['title'] ?? null;
|
$title = $widget['data']['title'] ?? null;
|
||||||
|
|
||||||
return filled($title) ? (string) $title : RichText::excerpt($widget['data']['body'] ?? '');
|
if (filled($title)) {
|
||||||
|
return (string) $title;
|
||||||
|
}
|
||||||
|
|
||||||
|
$excerpt = RichText::excerpt($widget['data']['body'] ?? '');
|
||||||
|
|
||||||
|
if ($excerpt !== '') {
|
||||||
|
return $excerpt;
|
||||||
|
}
|
||||||
|
|
||||||
|
return filled($widget['data']['alt'] ?? null) ? 'Bild: '.$widget['data']['alt'] : 'Bild';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,291 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Cms\Widgets\Types;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\FormattedText;
|
||||||
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
|
use App\Domain\Cms\Widgets\Support\HeadingAccent;
|
||||||
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
|
use App\Filament\Support\RichField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hinweiszeile: ein kompakter Hinweis (zum Beispiel „Dieses Bild wurde mit KI erzeugt“) mit formatiertem Text und
|
||||||
|
* optionalem Symbol, wahlweise mit aufklappbarer Kurzdarstellung.
|
||||||
|
*
|
||||||
|
* Drei Darstellungsmodi (Einstellung `mode`), der Text steht immer in beiden Fassungen gespeichert, ein Wechsel des Modus
|
||||||
|
* verliert also nichts:
|
||||||
|
* - full (Vorgabe): der vollständige Hinweis, immer sichtbar, ohne Aufklappen.
|
||||||
|
* - responsive: breit der volle Text; unter einer Widgetbreite (Einstellung `narrow`) die Kurzdarstellung, auf Wunsch erst
|
||||||
|
* dann, wenn der Volltext mehr Zeilen braucht als die Zeilengrenze (`line_limit`). Beim Laden eingeklappt.
|
||||||
|
* - collapsed: immer zuerst die Kurzdarstellung, auf jeder Breite; ein Klick zeigt den vollständigen Text. Breite und
|
||||||
|
* Zeilengrenze bleiben unberücksichtigt.
|
||||||
|
* Ohne Kurztext gibt es nichts einzuklappen: Der Hinweis erscheint dann wie im Modus „Volltext“.
|
||||||
|
*/
|
||||||
|
class NoticeWidget extends WidgetType
|
||||||
|
{
|
||||||
|
/** Größtes zulässiges Maß des gespeicherten HTML je Text. */
|
||||||
|
public const TEXT_MAX_LENGTH = 10000;
|
||||||
|
|
||||||
|
public const SHORT_MAX_LENGTH = 2000;
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
public const MODE = [
|
||||||
|
'full' => 'Volltext: immer vollständig sichtbar',
|
||||||
|
'responsive' => 'Responsiv: auf schmalen Bildschirmen die Kurzdarstellung',
|
||||||
|
'collapsed' => 'Immer mit Kurzdarstellung starten',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auslösegrenze: Der Volltext braucht mehr Zeilen als die Grenze. Die Schlüssel sind keine Zahlen, damit sie als
|
||||||
|
* Zeichenketten erhalten bleiben (ADR-30: nur feste Werte).
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
public const LINE_LIMIT = [
|
||||||
|
'l1' => 'Mehr als 1 Zeile',
|
||||||
|
'l2' => 'Mehr als 2 Zeilen',
|
||||||
|
'l3' => 'Mehr als 3 Zeilen',
|
||||||
|
'l4' => 'Mehr als 4 Zeilen',
|
||||||
|
'l5' => 'Mehr als 5 Zeilen',
|
||||||
|
'l6' => 'Mehr als 6 Zeilen',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Breite des Widgets (nicht des Fensters), unter der „schmal“ gilt, in rem.
|
||||||
|
*
|
||||||
|
* @var array<string, float>
|
||||||
|
*/
|
||||||
|
public const NARROW_REM = ['narrow' => 30.0, 'medium' => 40.0, 'wide' => 56.0];
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
public const NARROW = [
|
||||||
|
'narrow' => 'Nur bei sehr wenig Platz (Widgetbreite unter 30 rem, etwa 480 px)',
|
||||||
|
'medium' => 'Bei wenig Platz (unter 40 rem, etwa 640 px)',
|
||||||
|
'wide' => 'Auch bei mittlerem Platz (unter 56 rem, etwa 900 px)',
|
||||||
|
];
|
||||||
|
|
||||||
|
/** Schriftgrößen: S, M und L sind die Stufen „klein“, „Text“ und „Einleitung“ des Designsystems, XS ist kleiner als diese. */
|
||||||
|
public const SIZE = ['xs' => 'XS (klein, 13 px)', 's' => 'S (Hinweistext des Designsystems)', 'm' => 'M (Fließtext)', 'l' => 'L (Einleitungstext)'];
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
public const SYMBOL_SIZE = ['xs' => 'Sehr klein (1 rem)', 's' => 'Klein (1,25 rem)', 'm' => 'Mittel (1,75 rem)', 'l' => 'Groß (2,5 rem)', 'xl' => 'Sehr groß (3,5 rem)'];
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
public const SURFACE = ['green' => 'Dezentes Grün', 'yellow' => 'Hinweisgelb', 'cream' => 'Creme'];
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
public const BORDER = ['line' => 'Feiner Rahmen'];
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
public const BAR = ['left' => 'Akzentlinie links', 'top' => 'Akzentlinie oben'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gültige Darstellungswerte; alles andere fällt auf die Vorgabe zurück (Volltext, ohne Grenze, mittlere Schwelle, S,
|
||||||
|
* linksbündig, Symbol klein und oben, ohne Fläche, Rahmen und Linie). Ohne Kurztext ist der Modus immer „full“.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $settings
|
||||||
|
* @return array{mode: string, limit: ?int, narrow: float, size: string, align: string, symbol: ?string, symbolSize: string, symbolAlign: string, surface: ?string, border: bool, bar: ?string}
|
||||||
|
*/
|
||||||
|
public static function layout(array $settings, bool $hasShort = true): array
|
||||||
|
{
|
||||||
|
$pick = fn (string $key, array $allowed, ?string $default): ?string => is_string($settings[$key] ?? null) && array_key_exists($settings[$key], $allowed) ? $settings[$key] : $default;
|
||||||
|
|
||||||
|
$mode = $pick('mode', self::MODE, 'full');
|
||||||
|
$limit = $pick('line_limit', self::LINE_LIMIT, null);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'mode' => $hasShort ? $mode : 'full',
|
||||||
|
'limit' => $limit === null ? null : (int) substr($limit, 1),
|
||||||
|
'narrow' => self::NARROW_REM[$pick('narrow', self::NARROW, 'medium')],
|
||||||
|
'size' => $pick('size', self::SIZE, 's'),
|
||||||
|
'align' => $pick('align', HeadingAccent::TEXT_ALIGN, 'left'),
|
||||||
|
'symbol' => HeadingAccent::symbol($settings),
|
||||||
|
'symbolSize' => $pick('symbol_size', self::SYMBOL_SIZE, 's'),
|
||||||
|
'symbolAlign' => $pick('symbol_align', HeadingAccent::ALIGN, 'top'),
|
||||||
|
'surface' => $pick('surface', self::SURFACE, null),
|
||||||
|
'border' => ($settings['border'] ?? null) === 'line',
|
||||||
|
'bar' => $pick('bar', self::BAR, null),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Das Skript der Hinweiszeile (resources/js/notice.js) ohne Kommentare, zum Einbetten in die Seite. Es steht beim ersten
|
||||||
|
* Hinweis einer Seite inline im Quelltext und entscheidet dort über die Darstellung, bevor der Browser die folgenden
|
||||||
|
* Inhalte malt; sonst spränge ein Hinweis nach dem Laden vom vollen Text zur Kurzdarstellung. Dieselbe Datei läuft auch
|
||||||
|
* als Modul (app.js) für dynamisch eingefügte Hinweise.
|
||||||
|
*/
|
||||||
|
public static function bootScript(): string
|
||||||
|
{
|
||||||
|
$file = resource_path('js/notice.js');
|
||||||
|
|
||||||
|
// Fehlt die Datei im Abbild, bleibt die Seite lesbar: Das Modul (app.js) übernimmt, nur ein Sprung beim Laden ist möglich.
|
||||||
|
if (! is_readable($file)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$source = (string) file_get_contents($file);
|
||||||
|
$source = (string) preg_replace('#/\*.*?\*/#s', '', $source);
|
||||||
|
$source = (string) preg_replace('#^\s*//.*$#m', '', $source);
|
||||||
|
|
||||||
|
return trim((string) preg_replace('/\n\s*\n+/', "\n", $source));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function key(): string
|
||||||
|
{
|
||||||
|
return 'notice';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return 'Hinweiszeile';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function description(): string
|
||||||
|
{
|
||||||
|
return 'Kompakter Hinweis mit formatiertem Text und Symbol, wahlweise mit aufklappbarer Kurzdarstellung.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function supportedUnits(): array
|
||||||
|
{
|
||||||
|
return [1, 2, 3, 4];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function preferredUnits(): int
|
||||||
|
{
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function narrowBehavior(): string
|
||||||
|
{
|
||||||
|
return 'Der Text bricht um, nichts wird abgeschnitten. Je nach Modus wechselt der Hinweis bei geringer Widgetbreite zur aufklappbaren Kurzdarstellung; die Breite des Widgets entscheidet, nicht die des Fensters.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'narrow' => 'Modus „Responsiv“: Kurzdarstellung (bei Zeilengrenze nur, wenn der Volltext mehr Zeilen braucht)',
|
||||||
|
'wide' => 'vollständiger Text; im Modus „Immer mit Kurzdarstellung starten“ auch hier zuerst die Kurzdarstellung',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function icon(): string
|
||||||
|
{
|
||||||
|
return 'heroicon-o-information-circle';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function schematic(): array
|
||||||
|
{
|
||||||
|
return [[2, 11, 56, 14, 'line'], [2, 11, 2, 14, 'accent'], [8, 15, 30, 3, 'ink'], [8, 20, 44, 2, 'line']];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataRules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'text' => ['required', 'string', 'max:'.self::TEXT_MAX_LENGTH],
|
||||||
|
'short' => ['nullable', 'string', 'max:'.self::SHORT_MAX_LENGTH],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataFields(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
RichField::make('text', 'Vollständiger Text', website: true)
|
||||||
|
->required()
|
||||||
|
->helperText('Der ganze Hinweis. Wie beim Fließtext: fett, kursiv, Farbmarkierungen (Marine, Grün, Rot, Grau), Links, Listen und Ausrichtung. Im Modus „Volltext“ ist das der einzige Text, der angezeigt wird.'),
|
||||||
|
RichField::make('short', 'Kurztext (optional)', website: true)
|
||||||
|
->helperText('Die Kurzdarstellung für die Modi „Responsiv“ und „Immer mit Kurzdarstellung starten“, am besten ein Satz. Er wird gespeichert, auch wenn der Modus „Volltext“ gewählt ist, und geht beim Wechsel des Modus nicht verloren. Ohne Kurztext erscheint immer der vollständige Text.'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||||
|
{
|
||||||
|
$text = FormattedText::canonical(is_string($data['text'] ?? null) ? $data['text'] : '', true);
|
||||||
|
$short = FormattedText::canonical(is_string($data['short'] ?? null) ? $data['short'] : '', true);
|
||||||
|
|
||||||
|
if ($text === '') {
|
||||||
|
$errors->add('data.text', 'Bitte den vollständigen Text eingeben.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Die Schlüssel stehen nur, wenn sie ausgefüllt sind; ein leerer Kurztext bleibt byteweise ohne Spur.
|
||||||
|
$data['text'] = $text;
|
||||||
|
|
||||||
|
if ($short === '') {
|
||||||
|
unset($data['short']);
|
||||||
|
} else {
|
||||||
|
$data['short'] = $short;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$data, $refs];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolve(array $widget, RenderContext $context): array
|
||||||
|
{
|
||||||
|
$text = $widget['data']['text'] ?? null;
|
||||||
|
$short = $widget['data']['short'] ?? null;
|
||||||
|
$shortHtml = is_string($short) && trim($short) !== '' ? ProseWidget::render($short) : '';
|
||||||
|
$layout = self::layout($widget['settings'] ?? [], $shortHtml !== '');
|
||||||
|
|
||||||
|
return [
|
||||||
|
'textHtml' => is_string($text) && trim($text) !== '' ? ProseWidget::render($text) : '',
|
||||||
|
'shortHtml' => $shortHtml,
|
||||||
|
'layout' => $layout,
|
||||||
|
// Nur die Vorschau weist darauf hin, dass ein gewählter Modus ohne Kurztext nichts einklappen kann.
|
||||||
|
'notice' => $context->preview && $shortHtml === '' && self::layout($widget['settings'] ?? [])['mode'] !== 'full'
|
||||||
|
? 'Der gewählte Modus braucht einen Kurztext. Ohne ihn erscheint der vollständige Text immer.'
|
||||||
|
: null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'mode' => self::MODE,
|
||||||
|
'line_limit' => self::LINE_LIMIT,
|
||||||
|
'narrow' => self::NARROW,
|
||||||
|
'size' => self::SIZE,
|
||||||
|
'align' => HeadingAccent::TEXT_ALIGN,
|
||||||
|
'symbol' => HeadingAccent::symbols(),
|
||||||
|
'symbol_size' => self::SYMBOL_SIZE,
|
||||||
|
'symbol_align' => HeadingAccent::ALIGN,
|
||||||
|
'surface' => self::SURFACE,
|
||||||
|
'border' => self::BORDER,
|
||||||
|
'bar' => self::BAR,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingGroups(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'Darstellungsmodus' => ['mode', 'narrow', 'line_limit'],
|
||||||
|
'Text' => ['size', 'align'],
|
||||||
|
'Symbol' => ['symbol', 'symbol_size', 'symbol_align'],
|
||||||
|
'Fläche' => ['surface', 'border', 'bar'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingLabels(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'mode' => ['Darstellungsmodus', 'Volltext (Vorgabe): Der ganze Hinweis ist immer sichtbar. Responsiv: Breit der ganze Text, bei wenig Platz die Kurzdarstellung mit Pfeil zum Aufklappen. Immer mit Kurzdarstellung starten: Auf jeder Breite zuerst der Kurztext, ein Klick zeigt den ganzen Text, ein weiterer Klick klappt wieder zu. Die Kurzdarstellung ist beim Laden immer eingeklappt. Beide Fassungen bleiben beim Wechsel erhalten; ohne Kurztext erscheint immer der vollständige Text.'],
|
||||||
|
'narrow' => ['Wann gilt „wenig Platz“?', 'Gemessen wird die Breite des Widgets, nicht die des Fensters: Ein Hinweis in einer schmalen Spalte klappt früher ein als derselbe Hinweis über die ganze Seite. Wirkt nur im Modus „Responsiv“. Vorgabe: unter 40 rem (etwa 640 px).'],
|
||||||
|
'line_limit' => ['Zeilengrenze', 'Nur bei wenig Platz und nur im Modus „Responsiv“: Die Kurzdarstellung erscheint, wenn der vollständige Text bei der tatsächlichen Breite mehr Zeilen braucht als gewählt (gezählt werden umgebrochene Textzeilen). Es werden nie Zeilen abgeschnitten. Ohne Grenze (Vorgabe) steht bei wenig Platz immer die Kurzdarstellung. Im Modus „Immer mit Kurzdarstellung starten“ wird die Grenze nicht berücksichtigt.'],
|
||||||
|
'size' => ['Schriftgröße', 'XS, S (Vorgabe), M und L. S, M und L sind die Stufen „klein“, „Text“ und „Einleitung“ des Designsystems; XS ist etwas kleiner (13 px) und nur für Randbemerkungen gedacht.'],
|
||||||
|
'align' => ['Ausrichtung', 'Richtet den Text aus. Vorgabe: linksbündig.'],
|
||||||
|
'symbol' => ['Symbol', 'Kleine Grafik aus dem Brand-Kit vor dem Text. Sie ist reine Zierde und wird von Hilfstechnik nicht vorgelesen. Vorgabe: kein Symbol.'],
|
||||||
|
'symbol_size' => ['Größe des Symbols', 'Unabhängig von der Schriftgröße: von sehr klein (1 rem) bis sehr groß (3,5 rem). Vorgabe: Klein. Wirkt nur, wenn ein Symbol gewählt ist.'],
|
||||||
|
'symbol_align' => ['Senkrechte Lage des Symbols', 'Oben (Vorgabe, auf Höhe der ersten Zeile), Mitte oder Unten. Wirkt nur, wenn ein Symbol gewählt ist.'],
|
||||||
|
'surface' => ['Hintergrundfläche', 'Eine dezente Fläche hinter dem Hinweis (Farben des Designsystems). Auf der Fläche ist die Schrift immer dunkel, auch auf dunklen Abschnitten. Vorgabe: ohne Fläche, der Hinweis steht auf dem Abschnitt.'],
|
||||||
|
'border' => ['Rahmen', 'Ein feiner Rahmen um den Hinweis. Vorgabe: ohne.'],
|
||||||
|
'bar' => ['Akzentlinie', 'Eine farbige Linie links oder oben am Hinweis. Vorgabe: ohne.'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function summary(array $widget): string
|
||||||
|
{
|
||||||
|
$html = FormattedText::canonical(is_string($widget['data']['text'] ?? null) ? $widget['data']['text'] : '', true);
|
||||||
|
$text = trim((string) preg_replace('/\s+/u', ' ', html_entity_decode(strip_tags((string) preg_replace('#</(?:p|li|blockquote)>#', ' $0', $html)), ENT_QUOTES | ENT_HTML5, 'UTF-8')));
|
||||||
|
|
||||||
|
return mb_strlen($text) > 120 ? rtrim(mb_substr($text, 0, 119)).'…' : $text;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,13 +2,32 @@
|
|||||||
|
|
||||||
namespace App\Domain\Cms\Widgets\Types;
|
namespace App\Domain\Cms\Widgets\Types;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\FormattedText;
|
||||||
|
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\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
use Filament\Forms\Components\Textarea;
|
use App\Filament\Support\RichField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fließtext mit dem Editor der Dokumente (ADR-50, ADR-51): Zwischenüberschriften, fett, kursiv, Links, Listen, Zitate und
|
||||||
|
* Tabellen, dazu Schriftgröße, Schriftfarbe und Ausrichtung aus festen Werten (Webprofil von FormattedText). Gespeichert wird bereinigtes HTML (FormattedText, Regel „Links auf eigene Seiten erlaubt“); Skripte, Stile und
|
||||||
|
* Ereignisattribute entfallen. Bilder gibt es im Text nicht: Die Bilder der Website stehen als eigene Bausteine (zum
|
||||||
|
* Beispiel Bild und Text), nicht als Bildfassungen eines Dokuments.
|
||||||
|
*
|
||||||
|
* Version 1 (Bestand): Klartext, eine Leerzeile beginnt einen Absatz. Version 2: formatierter Text (HTML).
|
||||||
|
*/
|
||||||
class ProseWidget extends WidgetType
|
class ProseWidget extends WidgetType
|
||||||
{
|
{
|
||||||
|
/** Größtes zulässiges Maß des gespeicherten HTML (entspricht der Bereinigung des Textbausteins). */
|
||||||
|
public const MAX_LENGTH = 100000;
|
||||||
|
|
||||||
|
public function version(): int
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
public function key(): string
|
public function key(): string
|
||||||
{
|
{
|
||||||
return 'prose';
|
return 'prose';
|
||||||
@@ -21,7 +40,7 @@ public function label(): string
|
|||||||
|
|
||||||
public function description(): string
|
public function description(): string
|
||||||
{
|
{
|
||||||
return 'Längerer Text in Absätzen. Eine Leerzeile beginnt einen neuen Absatz.';
|
return 'Längerer Text mit Zwischenüberschriften, Hervorhebungen, Listen, Zitaten, Tabellen und Links, geschrieben im Editor wie bei den Dokumenten.';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supportedUnits(): array
|
public function supportedUnits(): array
|
||||||
@@ -31,12 +50,12 @@ public function supportedUnits(): array
|
|||||||
|
|
||||||
public function narrowBehavior(): string
|
public function narrowBehavior(): string
|
||||||
{
|
{
|
||||||
return 'Fließtext bricht um; Zeilen höchstens etwa 70 Zeichen.';
|
return 'Fließtext bricht um; Zeilen höchstens etwa 70 Zeichen. Eine Tabelle scrollt bei wenig Platz waagerecht.';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function preferredUnits(): int
|
public function preferredUnits(): int
|
||||||
{
|
{
|
||||||
return 2;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stages(): array
|
public function stages(): array
|
||||||
@@ -51,37 +70,80 @@ public function icon(): string
|
|||||||
return 'heroicon-o-bars-3-bottom-left';
|
return 'heroicon-o-bars-3-bottom-left';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function upgrade(array $widget, int $from): array
|
||||||
|
{
|
||||||
|
if ($from === 1) {
|
||||||
|
// Klartext wird zu Absätzen an den Leerzeilen (wie bisher dargestellt), nicht zu Listen oder Überschriften.
|
||||||
|
$body = $widget['data']['body'] ?? '';
|
||||||
|
$widget['data']['body'] = FormattedText::canonicalHtml(RichText::fromPlainText(is_string($body) ? $body : ''), true);
|
||||||
|
|
||||||
|
return $widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::upgrade($widget, $from);
|
||||||
|
}
|
||||||
|
|
||||||
public function dataRules(): array
|
public function dataRules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'body' => ['required', 'string', 'max:20000'],
|
'body' => ['required', 'string', 'max:'.self::MAX_LENGTH],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataFields(): array
|
public function dataFields(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Textarea::make('body')
|
RichField::make('body', 'Text', website: true)
|
||||||
->label('Text')
|
|
||||||
->rows(10)
|
|
||||||
->required()
|
->required()
|
||||||
->maxLength(20000)
|
->helperText('Zwischenüberschriften (H3 bis H6), fett, kursiv, Links, Listen, Zitate und Tabellen. Dazu Schriftgröße, Schriftfarbe (Marine, Grün, Rot, Grau) und Ausrichtung (linksbündig, zentriert, rechtsbündig) des Absatzes. Auf dunklen und grünen Flächen werden die Farben aufgehellt, damit die Schrift lesbar bleibt. Links auf eigene Seiten wie /materialien oder #anker sind möglich. Eine Tabelle legen Sie über das Tabellensymbol an; die erste Zeile lässt sich als Kopfzeile kennzeichnen.'),
|
||||||
->helperText('Eine Leerzeile beginnt einen neuen Absatz.'),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||||
|
{
|
||||||
|
$data['body'] = FormattedText::canonical(is_string($data['body'] ?? null) ? $data['body'] : '', true);
|
||||||
|
|
||||||
|
if ($data['body'] === '') {
|
||||||
|
$errors->add('data.body', 'Bitte einen Text eingeben.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$data, $refs];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolve(array $widget, RenderContext $context): array
|
||||||
|
{
|
||||||
|
return ['html' => self::render($widget['data']['body'] ?? null)];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sicheres HTML zur Ausgabe. Jede Tabelle steht in einem Rahmen, der bei wenig Platz waagerecht scrollt und mit der
|
||||||
|
* Tastatur erreichbar ist.
|
||||||
|
*/
|
||||||
|
public static function render(mixed $body): string
|
||||||
|
{
|
||||||
|
$html = FormattedText::html(is_string($body) ? $body : '', null, true);
|
||||||
|
|
||||||
|
// Die Ausrichtung steht gespeichert als Stil (so liest der Editor sie); auf der Seite wird sie eine Klasse.
|
||||||
|
return str_replace(
|
||||||
|
['<table>', '</table>', ' style="text-align: center"', ' style="text-align: end"'],
|
||||||
|
['<div class="prose-table" role="region" tabindex="0" aria-label="Tabelle"><table>', '</table></div>', ' class="ta-center"', ' class="ta-end"'],
|
||||||
|
$html,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function settings(): array
|
public function settings(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'symbol' => HeadingAccent::symbols(),
|
'symbol' => HeadingAccent::symbols(),
|
||||||
'symbol_size' => HeadingAccent::SIZE,
|
'symbol_size' => HeadingAccent::SIZE,
|
||||||
'symbol_align' => HeadingAccent::ALIGN,
|
'symbol_align' => HeadingAccent::ALIGN,
|
||||||
|
'text_width' => HeadingAccent::TEXT_WIDTH,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settingGroups(): array
|
public function settingGroups(): array
|
||||||
{
|
{
|
||||||
return ['Aussehen' => ['symbol', 'symbol_size', 'symbol_align']];
|
return ['Aussehen' => ['text_width', 'symbol', 'symbol_size', 'symbol_align']];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settingLabels(): array
|
public function settingLabels(): array
|
||||||
@@ -90,11 +152,16 @@ public function settingLabels(): array
|
|||||||
'symbol' => ['Symbol neben dem Text', 'Kleine Grafik aus dem Brand-Kit links neben dem ganzen Text. Sie ist reine Zierde und wird von Hilfstechnik nicht vorgelesen. Vorgabe: kein Symbol.'],
|
'symbol' => ['Symbol neben dem Text', 'Kleine Grafik aus dem Brand-Kit links neben dem ganzen Text. Sie ist reine Zierde und wird von Hilfstechnik nicht vorgelesen. Vorgabe: kein Symbol.'],
|
||||||
'symbol_size' => ['Größe des Symbols', 'Vorgabe: Mittel. Bei wenig Platz steht das Symbol über dem Text. Wirkt nur, wenn ein Symbol gewählt ist.'],
|
'symbol_size' => ['Größe des Symbols', 'Vorgabe: Mittel. Bei wenig Platz steht das Symbol über dem Text. Wirkt nur, wenn ein Symbol gewählt ist.'],
|
||||||
'symbol_align' => HeadingAccent::ALIGN_LABEL,
|
'symbol_align' => HeadingAccent::ALIGN_LABEL,
|
||||||
|
'text_width' => HeadingAccent::TEXT_WIDTH_LABEL,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function summary(array $widget): string
|
public function summary(array $widget): string
|
||||||
{
|
{
|
||||||
return RichText::excerpt(e((string) ($widget['data']['body'] ?? '')));
|
// Gelesen wird im Webprofil: Das Profil der Verwaltung kennt Spans (Größe, Farbe) nicht und ließe ihren Text weg.
|
||||||
|
$html = FormattedText::canonical(is_string($widget['data']['body'] ?? null) ? $widget['data']['body'] : '', true);
|
||||||
|
$text = trim((string) preg_replace('/\s+/u', ' ', html_entity_decode(strip_tags((string) preg_replace('#</(?:p|h[3-6]|li|td|th|blockquote)>#', ' $0', $html)), ENT_QUOTES | ENT_HTML5, 'UTF-8')));
|
||||||
|
|
||||||
|
return mb_strlen($text) > 120 ? rtrim(mb_substr($text, 0, 119)).'…' : $text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Cms\Widgets\Types;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\EditorialContentKind;
|
||||||
|
use App\Domain\Catalog\Pillar;
|
||||||
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
|
use App\Domain\Commerce\Shop;
|
||||||
|
use App\Domain\Commerce\ShopCatalog;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\Textarea;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shop-Produkte (ADR-55): die kaufbaren Produkte als Kacheln, aus derselben Datenquelle wie die Shopseite (ShopCatalog).
|
||||||
|
*
|
||||||
|
* Gespeichert werden nur Darstellungswahl und Filter (Säule, Materialart); Titel, Bild, Preis und Marker kommen zur
|
||||||
|
* Laufzeit aus den Fachdaten. Das Widget zeigt nichts, solange der Shop nicht sichtbar ist (Schalter „Shop sichtbar“).
|
||||||
|
* Eine Kachel begründet keine Berechtigung. Anders als Programm- und Modulkarten trägt es Preise und führt zur Produktseite.
|
||||||
|
*/
|
||||||
|
class ShopProductsWidget extends WidgetType
|
||||||
|
{
|
||||||
|
public function key(): string
|
||||||
|
{
|
||||||
|
return 'shop_products';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return 'Shop-Produkte';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function description(): string
|
||||||
|
{
|
||||||
|
return 'Die kaufbaren Produkte des Shops als Kacheln mit Bild, Marker und Preis; optional gefiltert und sortiert.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function supportedUnits(): array
|
||||||
|
{
|
||||||
|
return [2, 3, 4];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function minUnits(): int
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function preferredUnits(): int
|
||||||
|
{
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function narrowBehavior(): string
|
||||||
|
{
|
||||||
|
return 'Die Kacheln stehen untereinander; ab etwa 17 rem Kachelbreite mehrere nebeneinander.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'narrow' => 'eine Kachel je Zeile',
|
||||||
|
'wide' => 'mehrere Kacheln nebeneinander ab 17 rem Kachelbreite',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function icon(): string
|
||||||
|
{
|
||||||
|
return 'heroicon-o-shopping-bag';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function schematic(): array
|
||||||
|
{
|
||||||
|
return [[2, 4, 17, 28, 'line'], [21, 4, 17, 28, 'line'], [40, 4, 17, 28, 'line'], [4, 6, 13, 10, 'image'], [23, 6, 13, 10, 'image'], [42, 6, 13, 10, 'image'], [4, 19, 11, 3, 'ink'], [23, 19, 11, 3, 'ink'], [42, 19, 11, 3, 'ink'], [4, 26, 7, 3, 'accent'], [23, 26, 7, 3, 'accent'], [42, 26, 7, 3, 'accent']];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function variants(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'kacheln' => 'Kacheln mit Bild',
|
||||||
|
'liste' => 'Liste mit kleinem Bild',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'sort' => ['name' => 'Alphabetisch', 'neu' => 'Neueste zuerst', 'preis' => 'Preis aufsteigend'],
|
||||||
|
'limit' => ['alle' => 'Alle Produkte', 'n3' => '3 Produkte', 'n6' => '6 Produkte', 'n9' => '9 Produkte', 'n12' => '12 Produkte', 'n24' => '24 Produkte'],
|
||||||
|
'search' => ['aus' => 'Ohne Suchfeld', 'an' => 'Mit Suchfeld'],
|
||||||
|
'filter' => ['aus' => 'Ohne Auswahl', 'an' => 'Mit Suche, Auswahl, Ansicht und Seiten'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingLabels(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'sort' => ['Reihenfolge', 'Ohne Wahl gilt die Reihenfolge der Shopseite: Altbestand, Artikel, Pakete.'],
|
||||||
|
'limit' => ['Anzahl', 'Wie viele Produkte höchstens erscheinen. Ohne Wahl erscheinen alle.'],
|
||||||
|
'search' => ['Suchfeld', 'Ein einfaches Suchfeld über den Kacheln. Es sendet an die Seite, auf der das Widget steht.'],
|
||||||
|
'filter' => ['Auswahl für Besucher', 'Suche, Auswahl nach Thema, Materialart, Eignung und Nutzerkreis, Reihenfolge, Umschalter Kacheln und Liste und Seiten. Sinnvoll auf der Shopseite mit vielen Produkten. Ersetzt das einfache Suchfeld und die Einstellung „Anzahl“.'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingGroups(): array
|
||||||
|
{
|
||||||
|
return ['Auswahl' => ['sort', 'limit', 'search', 'filter']];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataRules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'heading' => ['nullable', 'string', 'max:160'],
|
||||||
|
'intro' => ['nullable', 'string', 'max:400'],
|
||||||
|
'pillar' => ['nullable', 'integer'],
|
||||||
|
'kind' => ['nullable', 'integer'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataFields(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
TextInput::make('heading')->label('Abschnittsüberschrift (optional)')->maxLength(160),
|
||||||
|
Textarea::make('intro')->label('Einleitung (optional)')->rows(2)->maxLength(400),
|
||||||
|
Select::make('pillar')
|
||||||
|
->label('Nur Produkte einer Säule (optional)')
|
||||||
|
->helperText('Nur veröffentlichte Säulen sind wählbar. Ohne Wahl erscheinen alle Produkte.')
|
||||||
|
->options(fn (): array => Pillar::query()->published()->pluck('name', 'id')->all())
|
||||||
|
->placeholder('Alle Säulen')
|
||||||
|
->native(false),
|
||||||
|
Select::make('kind')
|
||||||
|
->label('Nur eine Materialart (optional)')
|
||||||
|
->options(fn (): array => EditorialContentKind::query()->where('is_active', true)->orderBy('sort_order')->get()
|
||||||
|
->filter(fn (EditorialContentKind $kind): bool => in_array('lizenzartikel', (array) ($kind->contexts ?? []), true))
|
||||||
|
->pluck('label', 'id')->all())
|
||||||
|
->placeholder('Alle Materialarten')
|
||||||
|
->native(false),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||||
|
{
|
||||||
|
foreach (['heading', 'intro'] as $key) {
|
||||||
|
$data[$key] = filled($data[$key] ?? null) ? trim((string) $data[$key]) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pillar = filled($data['pillar'] ?? null) ? (int) $data['pillar'] : null;
|
||||||
|
|
||||||
|
if ($pillar !== null && ! Pillar::query()->published()->whereKey($pillar)->exists()) {
|
||||||
|
$errors->add('data.pillar', 'Diese Säule gibt es nicht oder sie ist nicht veröffentlicht.');
|
||||||
|
$pillar = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$kind = filled($data['kind'] ?? null) ? (int) $data['kind'] : null;
|
||||||
|
|
||||||
|
if ($kind !== null && ! EditorialContentKind::query()->whereKey($kind)->exists()) {
|
||||||
|
$errors->add('data.kind', 'Diese Materialart gibt es nicht.');
|
||||||
|
$kind = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['pillar'] = $pillar;
|
||||||
|
$data['kind'] = $kind;
|
||||||
|
|
||||||
|
return [$data, $refs];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolve(array $widget, RenderContext $context): array
|
||||||
|
{
|
||||||
|
if (! Shop::visible()) {
|
||||||
|
return ['listing' => null, 'cards' => [], 'term' => '', 'shopVisible' => false];
|
||||||
|
}
|
||||||
|
|
||||||
|
$settings = is_array($widget['settings'] ?? null) ? $widget['settings'] : [];
|
||||||
|
$filters = ($settings['filter'] ?? 'aus') === 'an';
|
||||||
|
$search = ($settings['search'] ?? 'aus') === 'an';
|
||||||
|
$limit = preg_match('/^n(\\d+)$/', (string) ($settings['limit'] ?? ''), $match) === 1 ? (int) $match[1] : null;
|
||||||
|
$query = $context->preview ? [] : request()->query();
|
||||||
|
$term = ($search || $filters) && isset($query['suche']) && is_string($query['suche']) ? mb_substr(trim($query['suche']), 0, 100) : '';
|
||||||
|
$fixed = [
|
||||||
|
'pillar' => $widget['data']['pillar'] ?? null,
|
||||||
|
'kind' => $widget['data']['kind'] ?? null,
|
||||||
|
'sort' => $settings['sort'] ?? null,
|
||||||
|
'limit' => $filters ? null : $limit,
|
||||||
|
'view' => ($widget['variant'] ?? 'kacheln') === 'liste' ? 'liste' : 'kacheln',
|
||||||
|
'filters' => $filters,
|
||||||
|
];
|
||||||
|
$listing = app(ShopCatalog::class)->listing($filters ? $query : ['suche' => $term], $fixed);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'listing' => $listing,
|
||||||
|
'cards' => $listing['cards'],
|
||||||
|
'term' => $term,
|
||||||
|
'shopVisible' => true,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function summary(array $widget): string
|
||||||
|
{
|
||||||
|
$heading = $widget['data']['heading'] ?? null;
|
||||||
|
|
||||||
|
return trim(($heading ? $heading.' · ' : '').'Shop-Produkte');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -100,6 +100,41 @@ public function add(Offer $offer): string
|
|||||||
return self::ADDED;
|
return self::ADDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Welche der Optionen das Konto schon besitzt (für einen Lizenzinhaber, für den es bestellen darf, mit denselben
|
||||||
|
* Rechten). Ohne Konto ist es leer; die Kasse prüft den Besitz ohnehin noch einmal.
|
||||||
|
*
|
||||||
|
* @param list<Offer> $offers
|
||||||
|
* @return array<int, true>
|
||||||
|
*/
|
||||||
|
public function ownedAmong(?User $user, array $offers): array
|
||||||
|
{
|
||||||
|
if ($user === null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$holders = $this->holders->for($user);
|
||||||
|
$owned = [];
|
||||||
|
|
||||||
|
foreach ($offers as $offer) {
|
||||||
|
$version = $this->purchasable($offer);
|
||||||
|
|
||||||
|
if ($version === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($holders as $holder) {
|
||||||
|
if ($this->suitsHolder($version, $holder) && $this->ownership->covers($holder, $version)) {
|
||||||
|
$owned[$offer->id] = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $owned;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ausdrücklicher Wechsel: die Alternative wird durch die gewählte Option ersetzt.
|
* Ausdrücklicher Wechsel: die Alternative wird durch die gewählte Option ersetzt.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -45,10 +45,18 @@ public function blocks(): bool
|
|||||||
|
|
||||||
public function title(): string
|
public function title(): string
|
||||||
{
|
{
|
||||||
if ($this->offer->standalone_bundle && $this->version !== null) {
|
$products = app(ProductOptions::class);
|
||||||
$bundle = app(ProductOptions::class)->bundleOf($this->version);
|
|
||||||
|
|
||||||
if ($bundle !== null) {
|
if ($this->version !== null) {
|
||||||
|
$article = $products->articleOf($this->version);
|
||||||
|
|
||||||
|
if ($article !== null) {
|
||||||
|
return $products->articleTitle($article);
|
||||||
|
}
|
||||||
|
|
||||||
|
$bundle = $products->bundleOf($this->version);
|
||||||
|
|
||||||
|
if ($bundle !== null && $this->version->lines->count() === 1) {
|
||||||
return (string) $bundle->name;
|
return (string) $bundle->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
use App\Domain\Catalog\DomainRuleException;
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
use App\Domain\Catalog\Offer;
|
use App\Domain\Catalog\Offer;
|
||||||
use App\Domain\Catalog\OfferService;
|
|
||||||
use App\Domain\Catalog\OfferVersion;
|
use App\Domain\Catalog\OfferVersion;
|
||||||
use App\Domain\Commerce\Discount\DiscountCode;
|
use App\Domain\Commerce\Discount\DiscountCode;
|
||||||
use App\Domain\Commerce\Stripe\StripeGateway;
|
use App\Domain\Commerce\Stripe\StripeGateway;
|
||||||
@@ -25,39 +24,10 @@ class Checkout
|
|||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly GrantIssuer $grants,
|
private readonly GrantIssuer $grants,
|
||||||
private readonly OfferService $offers,
|
|
||||||
private readonly OrderHolders $holders,
|
private readonly OrderHolders $holders,
|
||||||
private readonly PaymentJournal $journal,
|
private readonly PaymentJournal $journal,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
|
||||||
* Einzelkauf einer Option als Person (bestehender Weg, ohne Warenkorb).
|
|
||||||
*/
|
|
||||||
public function place(User $user, Offer $offer): Order
|
|
||||||
{
|
|
||||||
$this->assertActive($user);
|
|
||||||
|
|
||||||
// Dieser Einzelkauf kennt weder Zustimmungen noch „Zahlungspflichtig bestellen“. Im Livebetrieb gibt es nur den
|
|
||||||
// Weg über die Kasse mit Pflichtangaben.
|
|
||||||
if (Shop::live()) {
|
|
||||||
throw new DomainRuleException('Bestelle über den Warenkorb und die Kasse.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$version = $this->offers->currentActiveVersion($offer);
|
|
||||||
|
|
||||||
if ($version->grant_kind !== 'kauf' || $version->holder_kind !== 'person') {
|
|
||||||
throw new DomainRuleException('Dieses Angebot kann nicht als persönlicher Kauf bestellt werden.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($version->price_cents === null) {
|
|
||||||
throw new DomainRuleException('Der Kauf braucht einen Preis an der Angebotsfassung.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$holder = $this->holders->resolve($user, null);
|
|
||||||
|
|
||||||
return DB::transaction(fn (): Order => $this->createOrder($user, $holder, [[$offer, $version]], null, null, Shop::driver() === 'stripe' ? 'stripe' : 'test'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bestellung aus dem Warenkorb, erst nach serverseitiger Prüfung. Die Prüfsumme bindet die Bestellung an die
|
* Bestellung aus dem Warenkorb, erst nach serverseitiger Prüfung. Die Prüfsumme bindet die Bestellung an die
|
||||||
* Übersicht, die der Käufer gesehen hat: Hat sich Preis, Fassung oder Bedingung seither geändert, entsteht keine
|
* Übersicht, die der Käufer gesehen hat: Hat sich Preis, Fassung oder Bedingung seither geändert, entsteht keine
|
||||||
|
|||||||
@@ -4,12 +4,14 @@
|
|||||||
|
|
||||||
use App\Domain\Catalog\Bundle;
|
use App\Domain\Catalog\Bundle;
|
||||||
use App\Domain\Catalog\Composition;
|
use App\Domain\Catalog\Composition;
|
||||||
|
use App\Domain\Catalog\CompositionStructureReader;
|
||||||
use App\Domain\Catalog\EditorialProfileReader;
|
use App\Domain\Catalog\EditorialProfileReader;
|
||||||
use App\Domain\Catalog\LicenceScope;
|
use App\Domain\Catalog\LicenceScope;
|
||||||
use App\Domain\Catalog\LicenseArticle;
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
use App\Domain\Catalog\Offer;
|
use App\Domain\Catalog\Offer;
|
||||||
use App\Domain\Catalog\OfferService;
|
use App\Domain\Catalog\OfferService;
|
||||||
use App\Domain\Catalog\OfferVersion;
|
use App\Domain\Catalog\OfferVersion;
|
||||||
|
use App\Domain\Catalog\StructureNode;
|
||||||
use App\Filament\Support\CatalogLabels;
|
use App\Filament\Support\CatalogLabels;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,42 +24,99 @@ class ProductOptions
|
|||||||
public function __construct(private readonly OfferService $offers) {}
|
public function __construct(private readonly OfferService $offers) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Optionen der Produktseite eines Lizenzartikels: Angebote, deren einzige Position dieser Artikel ist.
|
||||||
|
*
|
||||||
* @return list<array<string, mixed>>
|
* @return list<array<string, mixed>>
|
||||||
*/
|
*/
|
||||||
public function forComposition(Composition $composition): array
|
public function forArticle(LicenseArticle $article): array
|
||||||
{
|
{
|
||||||
$options = [];
|
return $this->optionsFor('a:'.$article->id);
|
||||||
|
|
||||||
foreach (Offer::query()->where('composition_id', $composition->id)->orderBy('id')->get() as $offer) {
|
|
||||||
$version = $this->offers->purchasableVersion($offer);
|
|
||||||
|
|
||||||
if ($version !== null) {
|
|
||||||
$options[] = $this->describe($offer, $version);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kaufbare Optionen der eigenen Produktseite eines Pakets: Angebote mit eigener Paketseite, deren aktive Fassung
|
* Alle Optionen, die diesen Artikel als einzige Position verkaufen oder verkauften, auch beendete und solche ohne
|
||||||
* dieses Paket verkauft.
|
* Preis (Verwaltung). Die öffentliche Seite zeigt davon nur die kaufbaren (`forArticle`).
|
||||||
|
*
|
||||||
|
* @return list<Offer>
|
||||||
|
*/
|
||||||
|
public function offersOfArticle(LicenseArticle $article): array
|
||||||
|
{
|
||||||
|
return Offer::query()
|
||||||
|
->whereHas('versions.lines', fn ($query) => $query->where('license_article_id', $article->id))
|
||||||
|
->orderBy('id')
|
||||||
|
->get()
|
||||||
|
->filter(fn (Offer $offer): bool => $this->groupKey($offer) === 'a:'.$article->id)
|
||||||
|
->values()
|
||||||
|
->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kaufbare Optionen der Produktseite eines Pakets: Angebote, deren einzige Position eine Fassung dieses Pakets ist.
|
||||||
*
|
*
|
||||||
* @return list<array<string, mixed>>
|
* @return list<array<string, mixed>>
|
||||||
*/
|
*/
|
||||||
public function forBundle(Bundle $bundle): array
|
public function forBundle(Bundle $bundle): array
|
||||||
{
|
{
|
||||||
$options = [];
|
return $this->optionsFor('b:'.$bundle->id);
|
||||||
|
}
|
||||||
|
|
||||||
foreach (Offer::query()->where('standalone_bundle', true)->orderBy('id')->get() as $offer) {
|
/**
|
||||||
$version = $this->offers->purchasableVersion($offer);
|
* Altbestand: Angebote mit mehreren Positionen, die einer Programmseite zugeordnet wurden. Neue Angebote
|
||||||
|
* haben immer genau eine Position und damit eine Artikel- oder Paketseite.
|
||||||
|
*
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function forComposition(Composition $composition): array
|
||||||
|
{
|
||||||
|
return $this->optionsFor('c:'.$composition->id);
|
||||||
|
}
|
||||||
|
|
||||||
if ($version !== null && $this->bundleOf($version)?->id === $bundle->id) {
|
/**
|
||||||
$options[] = $this->describe($offer, $version);
|
* Der Artikel, den die Fassung als einzige Position verkauft, sonst null.
|
||||||
}
|
*/
|
||||||
}
|
public function articleOf(OfferVersion $version): ?LicenseArticle
|
||||||
|
{
|
||||||
|
$version->loadMissing('lines.article');
|
||||||
|
|
||||||
return $options;
|
return $version->lines->count() === 1 ? $version->lines->first()->article : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aufbau des Inhalts, den der aktuelle Stand des Artikels liefert (Rolle und Titel der Bestandteile). Ein Artikel
|
||||||
|
* mit einem einzelnen Medium als Wurzel hat keine Struktur. Dateien und Lehrtexte kommen hier nie vor.
|
||||||
|
*
|
||||||
|
* @return list<StructureNode>
|
||||||
|
*/
|
||||||
|
public function articleStructure(LicenseArticle $article): array
|
||||||
|
{
|
||||||
|
$version = $article->currentRelease?->rootCompositionVersion;
|
||||||
|
|
||||||
|
return $version === null ? [] : app(CompositionStructureReader::class)->tree($version);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Lernziel des Inhalts im aktuellen Stand des Artikels, wie es schon die öffentliche Programmseite zeigt. */
|
||||||
|
public function articleGoal(LicenseArticle $article): ?string
|
||||||
|
{
|
||||||
|
$goal = $article->currentRelease?->rootCompositionVersion?->learning_goal;
|
||||||
|
|
||||||
|
return filled($goal) ? (string) $goal : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Artikel mit kaufbarer Option, deren Inhalt diese Komposition ist: Die Programmseite verweist auf sie.
|
||||||
|
*
|
||||||
|
* @return list<LicenseArticle>
|
||||||
|
*/
|
||||||
|
public function articlesOf(Composition $composition): array
|
||||||
|
{
|
||||||
|
return LicenseArticle::query()
|
||||||
|
->whereNull('archived_at')
|
||||||
|
->whereHas('currentRelease.rootCompositionVersion', fn ($query) => $query->where('composition_id', $composition->id))
|
||||||
|
->orderBy('code')
|
||||||
|
->get()
|
||||||
|
->filter(fn (LicenseArticle $article): bool => $this->forArticle($article) !== [])
|
||||||
|
->values()
|
||||||
|
->all();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -70,62 +129,139 @@ public function bundleOf(OfferVersion $version): ?Bundle
|
|||||||
return $version->lines->first(fn ($line): bool => $line->bundleVersion !== null)?->bundleVersion?->bundle;
|
return $version->lines->first(fn ($line): bool => $line->bundleVersion !== null)?->bundleVersion?->bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gruppenschlüssel der Alternativen: Produktseite eines Programms oder eigene Paketseite. */
|
/**
|
||||||
|
* Schlüssel der Produktseite, auf der die Option angeboten wird: Artikelseite (`a:`), Paketseite (`b:`) oder, nur
|
||||||
|
* im Altbestand mit mehreren Positionen, die Programmseite (`c:`). Die Seite ergibt sich aus der Angebotsfassung
|
||||||
|
* und wird nirgends von Hand zugeordnet.
|
||||||
|
*/
|
||||||
public function groupKey(Offer $offer): ?string
|
public function groupKey(Offer $offer): ?string
|
||||||
{
|
{
|
||||||
if ($offer->composition_id !== null) {
|
$version = $this->offers->purchasableVersion($offer) ?? $offer->versions()->orderByDesc('number')->first();
|
||||||
return 'c:'.$offer->composition_id;
|
|
||||||
|
return $this->keyFor($offer, $version);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function keyFor(Offer $offer, ?OfferVersion $version): ?string
|
||||||
|
{
|
||||||
|
if ($version !== null && $version->lines()->count() === 1) {
|
||||||
|
$article = $this->articleOf($version);
|
||||||
|
|
||||||
|
if ($article !== null) {
|
||||||
|
return 'a:'.$article->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$bundle = $this->bundleOf($version);
|
||||||
|
|
||||||
|
if ($bundle !== null) {
|
||||||
|
return 'b:'.$bundle->id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($offer->standalone_bundle) {
|
return $offer->composition_id !== null ? 'c:'.$offer->composition_id : null;
|
||||||
$version = $this->offers->purchasableVersion($offer) ?? $offer->versions()->orderByDesc('number')->first();
|
|
||||||
$bundle = $version === null ? null : $this->bundleOf($version);
|
|
||||||
|
|
||||||
return $bundle === null ? null : 'b:'.$bundle->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Adresse der Produktseite, auf der die Option angeboten wird, sonst null. */
|
/** Adresse der Produktseite, auf der die Option angeboten wird, sonst null. */
|
||||||
public function pageUrl(Offer $offer): ?string
|
public function pageUrl(Offer $offer): ?string
|
||||||
{
|
{
|
||||||
if ($offer->composition_id !== null) {
|
|
||||||
return route('public.program', $offer->composition_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
$key = $this->groupKey($offer);
|
$key = $this->groupKey($offer);
|
||||||
|
|
||||||
return $key !== null && str_starts_with($key, 'b:') ? route('public.package', (int) substr($key, 2)) : null;
|
if ($key === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = (int) substr($key, 2);
|
||||||
|
|
||||||
|
return match ($key[0]) {
|
||||||
|
'a' => route('shop.article', $id),
|
||||||
|
'b' => route('public.package', $id),
|
||||||
|
default => route('public.program', $id),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pakete mit eigener Produktseite und kaufbarer Option: Paketkennung => günstigster Preis und Zahl der Optionen.
|
* Kaufbare Optionen je Produktseite: Seitenschlüssel => Angebot und Fassung in der Reihenfolge der Angebote.
|
||||||
*
|
*
|
||||||
* @return array<int, array{from_cents: int, count: int}>
|
* @return array<string, list<array{offer: Offer, version: OfferVersion}>>
|
||||||
*/
|
*/
|
||||||
public function bundleSummaries(): array
|
private function purchasable(): array
|
||||||
|
{
|
||||||
|
$pages = [];
|
||||||
|
|
||||||
|
foreach (Offer::query()->orderBy('id')->get() as $offer) {
|
||||||
|
$version = $this->offers->purchasableVersion($offer);
|
||||||
|
$key = $version === null ? null : $this->keyFor($offer, $version);
|
||||||
|
|
||||||
|
if ($key !== null) {
|
||||||
|
$pages[$key][] = ['offer' => $offer, 'version' => $version];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
private function optionsFor(string $key): array
|
||||||
|
{
|
||||||
|
return array_map(fn (array $row): array => $this->describe($row['offer'], $row['version']), $this->purchasable()[$key] ?? []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Günstigster Preis und Zahl der Optionen je Seite einer Art ('a', 'b' oder 'c'): Kennung => Zusammenfassung.
|
||||||
|
*
|
||||||
|
* @return array<int, array{from_cents: int, count: int, holders: list<string>, scopes: list<string>}>
|
||||||
|
*/
|
||||||
|
private function summariesOf(string $kind): array
|
||||||
{
|
{
|
||||||
$summary = [];
|
$summary = [];
|
||||||
|
|
||||||
foreach (Offer::query()->where('standalone_bundle', true)->orderBy('id')->get() as $offer) {
|
foreach ($this->purchasable() as $key => $rows) {
|
||||||
$version = $this->offers->purchasableVersion($offer);
|
if ($key[0] !== $kind) {
|
||||||
$bundle = $version === null ? null : $this->bundleOf($version);
|
|
||||||
|
|
||||||
if ($bundle === null) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$current = $summary[$bundle->id] ?? ['from_cents' => PHP_INT_MAX, 'count' => 0];
|
$summary[(int) substr($key, 2)] = [
|
||||||
$summary[$bundle->id] = [
|
'from_cents' => min(array_map(fn (array $row): int => (int) $row['version']->price_cents, $rows)),
|
||||||
'from_cents' => min($current['from_cents'], (int) $version->price_cents),
|
'count' => count($rows),
|
||||||
'count' => $current['count'] + 1,
|
'holders' => array_values(array_unique(array_map(fn (array $row): string => (string) $row['version']->holder_kind, $rows))),
|
||||||
|
'scopes' => array_values(array_unique(array_filter(array_map(fn (array $row): ?string => $row['version']->licence_scope, $rows)))),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $summary;
|
return $summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Artikel mit kaufbarer Option: Artikelkennung => günstigster Preis und Zahl der Optionen.
|
||||||
|
*
|
||||||
|
* @return array<int, array{from_cents: int, count: int, holders: list<string>, scopes: list<string>}>
|
||||||
|
*/
|
||||||
|
public function articleSummaries(): array
|
||||||
|
{
|
||||||
|
return $this->summariesOf('a');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pakete mit kaufbarer Option: Paketkennung => günstigster Preis und Zahl der Optionen.
|
||||||
|
*
|
||||||
|
* @return array<int, array{from_cents: int, count: int, holders: list<string>, scopes: list<string>}>
|
||||||
|
*/
|
||||||
|
public function bundleSummaries(): array
|
||||||
|
{
|
||||||
|
return $this->summariesOf('b');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Altbestand: Programmseiten mit kaufbaren Optionen (Angebote mit mehreren Positionen).
|
||||||
|
*
|
||||||
|
* @return array<int, array{from_cents: int, count: int, holders: list<string>, scopes: list<string>}>
|
||||||
|
*/
|
||||||
|
public function summaries(): array
|
||||||
|
{
|
||||||
|
return $this->summariesOf('c');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Der tatsächliche Umfang einer Paketseite: die Artikel aller Optionen ohne Doppelte, in der Reihenfolge der
|
* Der tatsächliche Umfang einer Paketseite: die Artikel aller Optionen ohne Doppelte, in der Reihenfolge der
|
||||||
* Optionen, mit Name und Kurzbeschreibung aus der Redaktion.
|
* Optionen, mit Name und Kurzbeschreibung aus der Redaktion.
|
||||||
@@ -158,32 +294,6 @@ public function bundleContents(array $options): array
|
|||||||
return array_values($contents);
|
return array_values($contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Zeilen für Shop-Suche und Kacheln: je Komposition die günstigste Option.
|
|
||||||
*
|
|
||||||
* @return array<int, array{from_cents: int, count: int}>
|
|
||||||
*/
|
|
||||||
public function summaries(): array
|
|
||||||
{
|
|
||||||
$summary = [];
|
|
||||||
|
|
||||||
foreach (Offer::query()->whereNotNull('composition_id')->orderBy('id')->get() as $offer) {
|
|
||||||
$version = $this->offers->purchasableVersion($offer);
|
|
||||||
|
|
||||||
if ($version === null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$current = $summary[$offer->composition_id] ?? ['from_cents' => PHP_INT_MAX, 'count' => 0];
|
|
||||||
$summary[$offer->composition_id] = [
|
|
||||||
'from_cents' => min($current['from_cents'], (int) $version->price_cents),
|
|
||||||
'count' => $current['count'] + 1,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $summary;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace App\Domain\Commerce;
|
namespace App\Domain\Commerce;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wann der Shop (Warenkorb, Kasse, Kopflink) aktiv ist.
|
* Wann der Shop zu sehen ist (visible) und wann gekauft werden kann (checkoutOpen).
|
||||||
*
|
*
|
||||||
* Test und Sandbox: nicht in Produktion, Zahlungstreiber „test“ oder „stripe“ (Testschlüssel).
|
* Test und Sandbox: nicht in Produktion, Zahlungstreiber „test“ oder „stripe“ (Testschlüssel).
|
||||||
* Produktion: nur mit der ausdrücklichen Produktivfreigabe (`SHOP_LIVE_RELEASE`, Entscheidung von Lars), dem
|
* Produktion: nur mit der ausdrücklichen Produktivfreigabe (`SHOP_LIVE_RELEASE`, Entscheidung von Lars), dem
|
||||||
@@ -27,7 +27,24 @@ public static function live(): bool
|
|||||||
&& SalesTerms::missingPages() === [];
|
&& SalesTerms::missingPages() === [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function enabled(): bool
|
/**
|
||||||
|
* Schalter 1: Der Shop ist zu sehen (Übersicht, Produktseiten, Pakete, Menüeinträge in den Shop).
|
||||||
|
* In Produktion mit `SHOP_PUBLIC` oder mit der Produktivfreigabe, sonst wie der Checkout.
|
||||||
|
*/
|
||||||
|
public static function visible(): bool
|
||||||
|
{
|
||||||
|
if (app()->isProduction()) {
|
||||||
|
return config('shop.public') === true || self::live();
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::checkoutOpen();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schalter 2: Der Kauf läuft (Warenkorb, Kasse, Zahlung). In Produktion nur mit der Produktivfreigabe, sonst mit
|
||||||
|
* dem Testzahlungsweg oder der Stripe-Sandbox.
|
||||||
|
*/
|
||||||
|
public static function checkoutOpen(): bool
|
||||||
{
|
{
|
||||||
if (app()->isProduction()) {
|
if (app()->isProduction()) {
|
||||||
return self::live();
|
return self::live();
|
||||||
@@ -49,7 +66,7 @@ public static function stripe(): bool
|
|||||||
/** Kauf auf Rechnung für Organisationen (manuelle Rechnung, Zahlungseingang durch den Betreiber). */
|
/** Kauf auf Rechnung für Organisationen (manuelle Rechnung, Zahlungseingang durch den Betreiber). */
|
||||||
public static function invoice(): bool
|
public static function invoice(): bool
|
||||||
{
|
{
|
||||||
return self::enabled() && (bool) config('shop.invoice', true);
|
return self::checkoutOpen() && (bool) config('shop.invoice', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function liveKey(): bool
|
private static function liveKey(): bool
|
||||||
|
|||||||
@@ -0,0 +1,333 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Commerce;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Bundle;
|
||||||
|
use App\Domain\Catalog\Composition;
|
||||||
|
use App\Domain\Catalog\EditorialProfileReader;
|
||||||
|
use App\Domain\Catalog\FormattedText;
|
||||||
|
use App\Domain\Catalog\LicenceScope;
|
||||||
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
|
use App\Domain\Catalog\Pillar;
|
||||||
|
use App\Domain\Catalog\PresentationMedia;
|
||||||
|
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||||
|
use App\Support\Brand\SymbolCatalog;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Produkte des Shops als Kacheln: eine Datenquelle für die Shopseite (und später das Widget).
|
||||||
|
*
|
||||||
|
* Gelistet wird, was mindestens eine kaufbare Option hat (Artikel, Pakete mit eigener Seite, Altbestand mit
|
||||||
|
* Programmseite). Jede Kachel trägt nur öffentlich Zeigbares: Titel und Kurztext aus der Redaktion, das Titelbild nur mit
|
||||||
|
* Website-Freigabe, Säulen nur, wenn sie veröffentlicht sind, die Materialart mit ihrem Symbol, die Marker und den
|
||||||
|
* niedrigsten Preis. Nichts davon begründet eine Berechtigung (ADR-52, ADR-54).
|
||||||
|
*
|
||||||
|
* @phpstan-type Card array{key: string, kind: string, url: string, title: string, teaser: string, from: string, from_cents: int, count: int, image: ?array{url: string, alt: string}, kind_label: string, symbol: ?string, pillars: list<string>, markers: list<array{key: string, label: string}>}
|
||||||
|
*/
|
||||||
|
class ShopCatalog
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly ProductOptions $products,
|
||||||
|
private readonly PublicCatalogReader $catalog,
|
||||||
|
private readonly EditorialProfileReader $profiles,
|
||||||
|
private readonly PresentationMedia $presentation,
|
||||||
|
private readonly ShopMarkers $markers,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public const SORTS = ['name' => 'Alphabetisch', 'neu' => 'Neueste zuerst', 'preis' => 'Preis aufsteigend'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array{pillar?: int|null, kind?: int|null, holder?: string|null, scope?: string|null, sort?: string|null, limit?: int|null} $options Filter
|
||||||
|
* nach Säule, Materialart, Eignung und Nutzerkreis, Sortierung (name, neu, preis) und Höchstzahl
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function cards(string $term = '', array $options = []): array
|
||||||
|
{
|
||||||
|
return $this->arrange($this->all($term), $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alle Kacheln zu einem Suchbegriff, ungefiltert und in der Reihenfolge der Quellen.
|
||||||
|
*
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function all(string $term = ''): array
|
||||||
|
{
|
||||||
|
$term = mb_strtolower(mb_substr(trim($term), 0, 100));
|
||||||
|
$cards = [];
|
||||||
|
|
||||||
|
// Altbestand: Angebote mit mehreren Positionen auf einer freigegebenen Programmseite.
|
||||||
|
$summaries = $this->products->summaries();
|
||||||
|
|
||||||
|
foreach (Composition::query()->with(['editorialContentKind', 'pillars'])->whereIn('id', array_keys($summaries))->orderBy('designation')->get() as $composition) {
|
||||||
|
if ($this->catalog->shownVersion($composition) === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = (string) ($composition->display_title ?: $composition->designation);
|
||||||
|
$teaser = (string) ($composition->teaser ?: FormattedText::plain($composition->summary));
|
||||||
|
$pillarMap = $this->publishedPillars($composition->pillars);
|
||||||
|
$pillars = array_values($pillarMap);
|
||||||
|
$card = $this->card('c:'.$composition->id, 'programm', route('public.program', $composition), $title, $teaser, $summaries[$composition->id], 'Programm', null, $pillars, [], $this->image($composition));
|
||||||
|
$card['pillar_ids'] = array_keys($pillarMap);
|
||||||
|
$card['kind_id'] = $composition->editorial_content_kind_id !== null ? (int) $composition->editorial_content_kind_id : null;
|
||||||
|
$card['holders'] = $summaries[$composition->id]['holders'] ?? [];
|
||||||
|
$card['scopes'] = $summaries[$composition->id]['scopes'] ?? [];
|
||||||
|
|
||||||
|
if ($this->matches($term, $title.' '.$teaser.' '.FormattedText::plain($composition->summary).' '.$composition->search_terms.' '.implode(' ', $pillars))) {
|
||||||
|
$cards[] = $card;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lizenzartikel mit kaufbarer Option.
|
||||||
|
$articleSummaries = $this->products->articleSummaries();
|
||||||
|
|
||||||
|
foreach (LicenseArticle::query()->with(['editorialContentKind', 'pillars', 'currentRelease'])->whereIn('id', array_keys($articleSummaries))->whereNull('archived_at')->orderBy('code')->get() as $article) {
|
||||||
|
$profile = $this->profiles->read($article, 'kachel');
|
||||||
|
$title = $this->products->articleTitle($article);
|
||||||
|
$teaser = (string) ($profile->value('teaser') ?: $profile->value('summary'));
|
||||||
|
$kind = $article->editorialContentKind;
|
||||||
|
$pillarMap = $this->publishedPillars($article->pillars);
|
||||||
|
$pillars = array_values($pillarMap);
|
||||||
|
$offerIds = array_map(fn ($offer): int => (int) $offer->id, $this->products->offersOfArticle($article));
|
||||||
|
$card = $this->card(
|
||||||
|
'a:'.$article->id, 'artikel', route('shop.article', $article), $title, $teaser, $articleSummaries[$article->id],
|
||||||
|
(string) ($kind?->label ?? ''), $this->symbol($kind?->symbol), $pillars, $this->markers->visible($article, $offerIds), $this->image($article),
|
||||||
|
);
|
||||||
|
$card['pillar_ids'] = array_keys($pillarMap);
|
||||||
|
$card['kind_id'] = $kind !== null ? (int) $kind->id : null;
|
||||||
|
$card['since'] = $this->markers->firstOffered($offerIds)?->getTimestamp() ?? 0;
|
||||||
|
$card['holders'] = $articleSummaries[$article->id]['holders'] ?? [];
|
||||||
|
$card['scopes'] = $articleSummaries[$article->id]['scopes'] ?? [];
|
||||||
|
|
||||||
|
if ($this->matches($term, $title.' '.$teaser.' '.$profile->value('summary').' '.$profile->searchTerms.' '.($kind?->label ?? '').' '.implode(' ', $pillars))) {
|
||||||
|
$cards[] = $card;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pakete mit eigener Produktseite.
|
||||||
|
$bundleSummaries = $this->products->bundleSummaries();
|
||||||
|
|
||||||
|
foreach (Bundle::query()->whereIn('id', array_keys($bundleSummaries))->orderBy('name')->get() as $bundle) {
|
||||||
|
$contents = $this->products->bundleContents($this->products->forBundle($bundle));
|
||||||
|
$names = implode(', ', array_column($contents, 'title'));
|
||||||
|
$teaser = 'Paket mit '.count($contents).' '.(count($contents) === 1 ? 'Inhalt' : 'Inhalten').($names !== '' ? ': '.$names : '');
|
||||||
|
$card = $this->card('b:'.$bundle->id, 'paket', route('public.package', $bundle), (string) $bundle->name, $teaser, $bundleSummaries[$bundle->id], 'Paket', null, [], [], $this->image($bundle));
|
||||||
|
$card['holders'] = $bundleSummaries[$bundle->id]['holders'] ?? [];
|
||||||
|
$card['scopes'] = $bundleSummaries[$bundle->id]['scopes'] ?? [];
|
||||||
|
|
||||||
|
if ($this->matches($term, $bundle->name.' '.$names)) {
|
||||||
|
$cards[] = $card;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $cards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter, Sortierung und Höchstzahl der Kacheln (Widget und Shopseite). Ohne Angabe bleibt die Reihenfolge der
|
||||||
|
* Datenquelle.
|
||||||
|
*
|
||||||
|
* @param list<array<string, mixed>> $cards
|
||||||
|
* @param array<string, mixed> $options
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function arrange(array $cards, array $options): array
|
||||||
|
{
|
||||||
|
$pillar = isset($options['pillar']) ? (int) $options['pillar'] : 0;
|
||||||
|
$kind = isset($options['kind']) ? (int) $options['kind'] : 0;
|
||||||
|
|
||||||
|
if ($pillar > 0) {
|
||||||
|
$cards = array_filter($cards, fn (array $card): bool => in_array($pillar, $card['pillar_ids'] ?? [], true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($kind > 0) {
|
||||||
|
$cards = array_filter($cards, fn (array $card): bool => ($card['kind_id'] ?? null) === $kind);
|
||||||
|
}
|
||||||
|
|
||||||
|
$holder = (string) ($options['holder'] ?? '');
|
||||||
|
$scope = (string) ($options['scope'] ?? '');
|
||||||
|
|
||||||
|
if ($holder !== '') {
|
||||||
|
$cards = array_filter($cards, fn (array $card): bool => in_array($holder, $card['holders'] ?? [], true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($scope !== '') {
|
||||||
|
$cards = array_filter($cards, fn (array $card): bool => in_array($scope, $card['scopes'] ?? [], true));
|
||||||
|
}
|
||||||
|
|
||||||
|
$cards = array_values($cards);
|
||||||
|
|
||||||
|
match ($options['sort'] ?? null) {
|
||||||
|
'name' => usort($cards, fn (array $a, array $b): int => strcmp(mb_strtolower($a['title']), mb_strtolower($b['title']))),
|
||||||
|
'neu' => usort($cards, fn (array $a, array $b): int => [$b['since'] ?? 0, mb_strtolower($a['title'])] <=> [$a['since'] ?? 0, mb_strtolower($b['title'])]),
|
||||||
|
'preis' => usort($cards, fn (array $a, array $b): int => [$a['from_cents'], mb_strtolower($a['title'])] <=> [$b['from_cents'], mb_strtolower($b['title'])]),
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
|
||||||
|
$limit = isset($options['limit']) ? (int) $options['limit'] : 0;
|
||||||
|
|
||||||
|
return $limit > 0 ? array_slice($cards, 0, $limit) : $cards;
|
||||||
|
}
|
||||||
|
|
||||||
|
public const HOLDERS = ['person' => 'Privatpersonen', 'organisation' => 'Organisationen und Vereine'];
|
||||||
|
|
||||||
|
public const SCOPES = [LicenceScope::SINGLE => 'Einzellizenz', LicenceScope::MULTI => 'Mehrfachlizenz'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Auswahl, die ein Besucher bei diesen Kacheln hat: nur Werte, die es gibt, und nur Auswahlfelder mit mindestens
|
||||||
|
* zwei Werten (sonst filtert nichts).
|
||||||
|
*
|
||||||
|
* @param list<array<string, mixed>> $cards
|
||||||
|
* @return array{pillar: array<int, string>, kind: array<int, string>, holder: array<string, string>, scope: array<string, string>}
|
||||||
|
*/
|
||||||
|
public function facets(array $cards): array
|
||||||
|
{
|
||||||
|
$pillars = [];
|
||||||
|
$kinds = [];
|
||||||
|
$holders = [];
|
||||||
|
$scopes = [];
|
||||||
|
|
||||||
|
foreach ($cards as $card) {
|
||||||
|
foreach (array_values($card['pillar_ids'] ?? []) as $index => $id) {
|
||||||
|
$pillars[(int) $id] = (string) ($card['pillars'][$index] ?? '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($card['kind_id'] ?? null) !== null && ($card['kind_label'] ?? '') !== '') {
|
||||||
|
$kinds[(int) $card['kind_id']] = (string) $card['kind_label'];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($card['holders'] ?? [] as $holder) {
|
||||||
|
if (isset(self::HOLDERS[$holder])) {
|
||||||
|
$holders[$holder] = self::HOLDERS[$holder];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($card['scopes'] ?? [] as $scope) {
|
||||||
|
if (isset(self::SCOPES[$scope])) {
|
||||||
|
$scopes[$scope] = self::SCOPES[$scope];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
asort($pillars);
|
||||||
|
asort($kinds);
|
||||||
|
|
||||||
|
$facets = ['pillar' => $pillars, 'kind' => $kinds, 'holder' => $holders, 'scope' => $scopes];
|
||||||
|
|
||||||
|
return array_map(fn (array $values): array => count($values) >= 2 ? $values : [], $facets);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Produktliste für Shopseite und Widget: Suche, Auswahl des Besuchers (Säule, Materialart, Eignung,
|
||||||
|
* Nutzerkreis), Reihenfolge, Ansicht und Seiten. Alles kommt aus dem Abfragetext und wird gegen feste Werte
|
||||||
|
* geprüft; unbekannte Werte entfallen.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $query Abfrage des Besuchers (suche, saeule, art, eignung, kreis, sort, ansicht, seite)
|
||||||
|
* @param array<string, mixed> $fixed Vorgaben der Seite (pillar, kind, sort, limit, view, filters)
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function listing(array $query, array $fixed = []): array
|
||||||
|
{
|
||||||
|
$text = fn (string $key): string => isset($query[$key]) && (is_string($query[$key]) || is_int($query[$key])) ? trim((string) $query[$key]) : '';
|
||||||
|
$filters = (bool) ($fixed['filters'] ?? true);
|
||||||
|
$term = mb_substr($text('suche'), 0, 100);
|
||||||
|
$base = $this->arrange($this->all($term), array_intersect_key($fixed, ['pillar' => 1, 'kind' => 1]));
|
||||||
|
$facets = $filters ? $this->facets($base) : ['pillar' => [], 'kind' => [], 'holder' => [], 'scope' => []];
|
||||||
|
$pick = function (string $key, string $facet) use ($text, $facets, $filters): int|string|null {
|
||||||
|
$value = $text($key);
|
||||||
|
|
||||||
|
return $filters && $value !== '' && array_key_exists($value, $facets[$facet]) ? (ctype_digit($value) ? (int) $value : $value) : null;
|
||||||
|
};
|
||||||
|
$chosen = [
|
||||||
|
'pillar' => $pick('saeule', 'pillar'),
|
||||||
|
'kind' => $pick('art', 'kind'),
|
||||||
|
'holder' => $pick('eignung', 'holder'),
|
||||||
|
'scope' => $pick('kreis', 'scope'),
|
||||||
|
];
|
||||||
|
$sort = $filters && isset(self::SORTS[$text('sort')]) ? $text('sort') : ($fixed['sort'] ?? null);
|
||||||
|
$view = $filters && in_array($text('ansicht'), ['kacheln', 'liste'], true) ? $text('ansicht') : (string) ($fixed['view'] ?? 'kacheln');
|
||||||
|
$cards = $this->arrange($base, $chosen + ['sort' => $sort, 'limit' => $fixed['limit'] ?? null]);
|
||||||
|
$perPage = max(1, (int) config('shop.per_page', 12));
|
||||||
|
$pages = max(1, (int) ceil(count($cards) / $perPage));
|
||||||
|
$page = $filters ? min($pages, max(1, (int) $text('seite'))) : 1;
|
||||||
|
$shown = $filters ? array_slice($cards, ($page - 1) * $perPage, $perPage) : $cards;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'cards' => $shown,
|
||||||
|
'total' => count($cards),
|
||||||
|
'page' => $page,
|
||||||
|
'pages' => $filters ? $pages : 1,
|
||||||
|
'facets' => $facets,
|
||||||
|
'chosen' => $chosen,
|
||||||
|
'sort' => $sort,
|
||||||
|
'view' => $view,
|
||||||
|
'term' => $term,
|
||||||
|
'filters' => $filters,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array{from_cents: int, count: int} $summary
|
||||||
|
* @param list<string> $pillars
|
||||||
|
* @param list<array{key: string, label: string}> $markers
|
||||||
|
* @param array{url: string, alt: string}|null $image
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function card(string $key, string $kind, string $url, string $title, string $teaser, array $summary, string $kindLabel, ?string $symbol, array $pillars, array $markers, ?array $image): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'key' => $key,
|
||||||
|
'kind' => $kind,
|
||||||
|
'url' => $url,
|
||||||
|
'title' => $title,
|
||||||
|
'teaser' => $teaser,
|
||||||
|
'from' => Money::format($summary['from_cents']),
|
||||||
|
'from_cents' => (int) $summary['from_cents'],
|
||||||
|
'count' => (int) $summary['count'],
|
||||||
|
'image' => $image,
|
||||||
|
'kind_label' => $kindLabel,
|
||||||
|
'symbol' => $symbol,
|
||||||
|
'pillars' => $pillars,
|
||||||
|
'markers' => $markers,
|
||||||
|
'pillar_ids' => [],
|
||||||
|
'kind_id' => null,
|
||||||
|
'since' => 0,
|
||||||
|
'holders' => [],
|
||||||
|
'scopes' => [],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function matches(string $term, string $haystack): bool
|
||||||
|
{
|
||||||
|
return $term === '' || str_contains(mb_strtolower($haystack), $term);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nur veröffentlichte Säulen sind öffentlich (Säulenverwaltung).
|
||||||
|
*
|
||||||
|
* @param Collection<int, Pillar> $pillars
|
||||||
|
* @return array<int, string> Kennung => Name
|
||||||
|
*/
|
||||||
|
private function publishedPillars(Collection $pillars): array
|
||||||
|
{
|
||||||
|
return $pillars->filter(fn (Pillar $pillar): bool => $pillar->published_at !== null)->mapWithKeys(fn (Pillar $pillar): array => [(int) $pillar->id => (string) $pillar->name])->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Ein Symbol zeigt nur, was die Symbolbibliothek kennt (die Auswahl wird an der Materialart geprüft, hier noch einmal). */
|
||||||
|
private function symbol(?string $key): ?string
|
||||||
|
{
|
||||||
|
return is_string($key) && $key !== '' && array_key_exists($key, SymbolCatalog::options()) ? $key : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{url: string, alt: string}|null
|
||||||
|
*/
|
||||||
|
private function image(Model $subject): ?array
|
||||||
|
{
|
||||||
|
$presentation = $this->presentation->coverPresentation($subject);
|
||||||
|
|
||||||
|
return $presentation === null ? null : ['url' => $presentation->url, 'alt' => $presentation->alt];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Commerce;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
|
use App\Domain\Catalog\OfferVersion;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Produktmarker „Neu“, „Aktualisiert“ und „Beliebt“ an einer Kachel (ADR-54).
|
||||||
|
*
|
||||||
|
* „Neu“ und „Aktualisiert“ folgen automatisch den Daten (erstes Angebot als Kauf, neuer Stand), jeweils für eine feste
|
||||||
|
* Zahl Tage (`shop.marker_days`); die Redaktion kann sie auch fest an- oder abschalten. „Beliebt“ setzt die Redaktion
|
||||||
|
* von Hand, solange es keine Verkaufszahlen gibt. Ein Marker trägt immer sein Wort, nie nur Farbe oder Symbol.
|
||||||
|
*/
|
||||||
|
class ShopMarkers
|
||||||
|
{
|
||||||
|
public const KEYS = ['neu' => 'Neu', 'aktualisiert' => 'Aktualisiert', 'beliebt' => 'Beliebt'];
|
||||||
|
|
||||||
|
/** Erlaubte Einstellungen je Marker; der erste Wert ist die Vorgabe. */
|
||||||
|
public const CHOICES = [
|
||||||
|
'neu' => ['auto' => 'Automatisch (zeitlich begrenzt nach dem ersten Angebot)', 'an' => 'Immer anzeigen', 'aus' => 'Nie anzeigen'],
|
||||||
|
'aktualisiert' => ['auto' => 'Automatisch (zeitlich begrenzt nach einem neuen Stand)', 'an' => 'Immer anzeigen', 'aus' => 'Nie anzeigen'],
|
||||||
|
'beliebt' => ['aus' => 'Nicht anzeigen', 'an' => 'Anzeigen'],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Einstellungen des Artikels mit den Vorgaben für fehlende oder ungültige Werte.
|
||||||
|
*
|
||||||
|
* @return array{neu: string, aktualisiert: string, beliebt: string}
|
||||||
|
*/
|
||||||
|
public function settings(LicenseArticle $article): array
|
||||||
|
{
|
||||||
|
$stored = is_array($article->shop_markers) ? $article->shop_markers : [];
|
||||||
|
$settings = [];
|
||||||
|
|
||||||
|
foreach (self::CHOICES as $key => $choices) {
|
||||||
|
$value = $stored[$key] ?? null;
|
||||||
|
$settings[$key] = is_string($value) && array_key_exists($value, $choices) ? $value : array_key_first($choices);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $choices
|
||||||
|
*/
|
||||||
|
public function save(LicenseArticle $article, array $choices): void
|
||||||
|
{
|
||||||
|
$settings = [];
|
||||||
|
|
||||||
|
foreach (self::CHOICES as $key => $allowed) {
|
||||||
|
$value = $choices[$key] ?? array_key_first($allowed);
|
||||||
|
|
||||||
|
if (! is_string($value) || ! array_key_exists($value, $allowed)) {
|
||||||
|
throw new DomainRuleException('Der Marker „'.self::KEYS[$key].'“ hat eine unzulässige Einstellung.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$settings[$key] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$article->shop_markers = $settings;
|
||||||
|
$article->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die anzuzeigenden Marker in fester Reihenfolge.
|
||||||
|
*
|
||||||
|
* @param list<int> $offerIds Angebote dieses Artikels (Optionen)
|
||||||
|
* @return list<array{key: string, label: string}>
|
||||||
|
*/
|
||||||
|
public function visible(LicenseArticle $article, array $offerIds, ?Carbon $now = null): array
|
||||||
|
{
|
||||||
|
$now ??= now();
|
||||||
|
$settings = $this->settings($article);
|
||||||
|
$days = max(1, (int) config('shop.marker_days', 30));
|
||||||
|
$limit = $now->copy()->subDays($days);
|
||||||
|
|
||||||
|
$isNew = match ($settings['neu']) {
|
||||||
|
'an' => true,
|
||||||
|
'aus' => false,
|
||||||
|
default => $this->firstOffered($offerIds)?->greaterThanOrEqualTo($limit) ?? false,
|
||||||
|
};
|
||||||
|
|
||||||
|
$isUpdated = match ($settings['aktualisiert']) {
|
||||||
|
'an' => true,
|
||||||
|
'aus' => false,
|
||||||
|
default => ! $isNew && $this->updatedAt($article)?->greaterThanOrEqualTo($limit) === true,
|
||||||
|
};
|
||||||
|
|
||||||
|
$markers = [];
|
||||||
|
|
||||||
|
foreach (['neu' => $isNew, 'aktualisiert' => $isUpdated, 'beliebt' => $settings['beliebt'] === 'an'] as $key => $shown) {
|
||||||
|
if ($shown) {
|
||||||
|
$markers[] = ['key' => $key, 'label' => self::KEYS[$key]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $markers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Zeitpunkt der ersten Fassung eines Angebots als Kauf. */
|
||||||
|
public function firstOffered(array $offerIds): ?Carbon
|
||||||
|
{
|
||||||
|
if ($offerIds === []) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$first = OfferVersion::query()->whereIn('offer_id', $offerIds)->where('grant_kind', 'kauf')->min('created_at');
|
||||||
|
|
||||||
|
return $first === null ? null : Carbon::parse($first);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Zeitpunkt des neuesten Stands, sofern es nicht der erste ist. */
|
||||||
|
private function updatedAt(LicenseArticle $article): ?Carbon
|
||||||
|
{
|
||||||
|
$release = $article->currentRelease;
|
||||||
|
|
||||||
|
return $release !== null && (int) $release->number > 1 && $release->created_at !== null ? Carbon::parse($release->created_at) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,6 +28,11 @@ public function claim(User $user, Offer $offer): Acquisition
|
|||||||
throw new DomainRuleException('Dieses Angebot richtet sich nicht an Personen.');
|
throw new DomainRuleException('Dieses Angebot richtet sich nicht an Personen.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wer ein Angebot auf Abruf übernehmen darf, bestimmt seine Regel (ADR-56); „bei Registrierung“ kennt keine.
|
||||||
|
if ($version->grant_kind === 'auf_abruf') {
|
||||||
|
app(OfferAccess::class)->assertMayClaim($user, $offer);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->issue($user, $version, AcquisitionType::FreierAbruf, 'offer', $offer->id);
|
return $this->issue($user, $version, AcquisitionType::FreierAbruf, 'offer', $offer->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Entitlement;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ArticleRelease;
|
||||||
|
use App\Domain\Commerce\ProductOptions;
|
||||||
|
use App\Models\User;
|
||||||
|
use Carbon\CarbonInterface;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Neue Stände zu Artikeln, die das Konto bereits besitzt („Neu für dich“, ADR-56).
|
||||||
|
*
|
||||||
|
* Nach der Updatepolitik (ADR-09, OPEN-01) stehen alle später veröffentlichten Stände desselben Artikels dem Inhaber
|
||||||
|
* ohne Aufpreis zu, solange die Lizenz gilt. Sie erscheinen von selbst in der Bibliothek; diese Liste macht sie nur
|
||||||
|
* sichtbar. Es wird nichts vergeben und nichts übernommen.
|
||||||
|
*/
|
||||||
|
class NewStands
|
||||||
|
{
|
||||||
|
/** So lange (in Tagen) nach der Veröffentlichung erscheint ein neuer Stand in der Liste. */
|
||||||
|
public const DAYS = 90;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, array{grant: Grant, title: string, number: int, since: CarbonInterface}>
|
||||||
|
*/
|
||||||
|
public function forUser(User $user): Collection
|
||||||
|
{
|
||||||
|
if ($user->party_id === null) {
|
||||||
|
return collect();
|
||||||
|
}
|
||||||
|
|
||||||
|
$limit = now()->subDays(self::DAYS);
|
||||||
|
$titles = app(ProductOptions::class);
|
||||||
|
|
||||||
|
return Grant::query()
|
||||||
|
->with(['article.currentRelease', 'releaseAtGrant'])
|
||||||
|
->where('status', GrantStatus::Aktiv)
|
||||||
|
->where(fn ($query) => $query->whereNull('valid_until')->orWhere('valid_until', '>', now()))
|
||||||
|
->whereHas('acquisition', fn ($query) => $query->where('party_id', $user->party_id))
|
||||||
|
->whereHas('article', fn ($query) => $query->whereNull('archived_at'))
|
||||||
|
->orderByDesc('id')
|
||||||
|
->get()
|
||||||
|
->filter(function (Grant $grant) use ($limit): bool {
|
||||||
|
$current = $grant->article?->currentRelease;
|
||||||
|
$had = $grant->releaseAtGrant;
|
||||||
|
|
||||||
|
return $current instanceof ArticleRelease
|
||||||
|
&& $had instanceof ArticleRelease
|
||||||
|
&& (int) $current->number > (int) $had->number
|
||||||
|
&& $current->created_at !== null
|
||||||
|
&& $current->created_at->greaterThanOrEqualTo($limit);
|
||||||
|
})
|
||||||
|
->unique('license_article_id')
|
||||||
|
->map(fn (Grant $grant): array => [
|
||||||
|
'grant' => $grant,
|
||||||
|
'title' => $titles->articleTitle($grant->article),
|
||||||
|
'number' => (int) $grant->article->currentRelease->number,
|
||||||
|
'since' => $grant->article->currentRelease->created_at,
|
||||||
|
])
|
||||||
|
->values();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,227 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Entitlement;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
|
use App\Domain\Catalog\Offer;
|
||||||
|
use App\Domain\Catalog\OfferRelease;
|
||||||
|
use App\Domain\Catalog\OfferService;
|
||||||
|
use App\Domain\Catalog\OfferStatus;
|
||||||
|
use App\Domain\Catalog\OfferVersion;
|
||||||
|
use App\Models\User;
|
||||||
|
use Carbon\CarbonInterface;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wer ein Angebot „auf Abruf“ in die Bibliothek übernehmen darf (ADR-56). Drei Regeln, serverseitig beim Abruf geprüft:
|
||||||
|
* alle angemeldeten Mitglieder, nur ausdrücklich freigeschaltete Konten (Freigabe je Angebot und Konto, wie bei
|
||||||
|
* Rabattcodes, nie gelöscht, nur entzogen) oder Mitglieder, die einen bestimmten anderen Artikel besitzen.
|
||||||
|
*
|
||||||
|
* Die Regel gilt nur für Vergaben „auf Abruf“. „Bei Registrierung“ geht automatisch an neue Konten; Kauf ist Sache der
|
||||||
|
* Kasse. Die Regel begründet keinen Zugang, sie begrenzt nur den freien Abruf.
|
||||||
|
*/
|
||||||
|
class OfferAccess
|
||||||
|
{
|
||||||
|
public const ALL = 'alle';
|
||||||
|
|
||||||
|
public const RELEASED = 'konten';
|
||||||
|
|
||||||
|
public const OWNERS = 'besitz';
|
||||||
|
|
||||||
|
public const OPTIONS = [
|
||||||
|
self::ALL => 'Alle angemeldeten Mitglieder',
|
||||||
|
self::RELEASED => 'Nur freigeschaltete Konten',
|
||||||
|
self::OWNERS => 'Mitglieder, die einen bestimmten Artikel besitzen',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function __construct(private readonly OfferService $offers) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Regel eines Angebots festlegen. Der Artikel ist nur bei „besitzt einen Artikel“ gesetzt.
|
||||||
|
*/
|
||||||
|
public function setRule(Offer $offer, string $access, ?int $articleId = null): void
|
||||||
|
{
|
||||||
|
if (! array_key_exists($access, self::OPTIONS)) {
|
||||||
|
throw new DomainRuleException('Diese Regel für den Abruf gibt es nicht.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($access === self::OWNERS) {
|
||||||
|
$article = $articleId === null ? null : LicenseArticle::query()->whereNull('archived_at')->find($articleId);
|
||||||
|
|
||||||
|
if ($article === null) {
|
||||||
|
throw new DomainRuleException('Für diese Regel braucht es einen vorhandenen, nicht archivierten Lizenzartikel.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$articleId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$offer->claim_access = $access;
|
||||||
|
$offer->claim_requires_article_id = $articleId;
|
||||||
|
$offer->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warum das Konto das Angebot nicht abrufen darf; null, wenn es das darf. Regeln gelten nur für Vergaben „auf Abruf“.
|
||||||
|
*/
|
||||||
|
public function refusal(User $user, Offer $offer, ?CarbonInterface $now = null): ?string
|
||||||
|
{
|
||||||
|
$now ??= now();
|
||||||
|
$version = $this->activeVersion($offer);
|
||||||
|
|
||||||
|
if ($version === null || ! in_array($version->grant_kind, ['auf_abruf', 'bei_registrierung'], true) || $version->holder_kind !== 'person') {
|
||||||
|
return 'Dieses Angebot wird nicht frei vergeben.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->party_id === null) {
|
||||||
|
return 'Nur ein Mitgliedskonto kann ein Angebot abrufen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// „Bei Registrierung“ geht automatisch an neue Konten und kennt keine Regel.
|
||||||
|
if ($version->grant_kind !== 'auf_abruf') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return match ((string) $offer->claim_access) {
|
||||||
|
self::RELEASED => $this->activeRelease($offer, $user, $now) === null ? 'Dieses Angebot ist für dein Konto nicht freigeschaltet.' : null,
|
||||||
|
self::OWNERS => $offer->claim_requires_article_id !== null && $this->owns($user, (int) $offer->claim_requires_article_id, $now) ? null : 'Dieses Angebot steht für dein Konto nicht zur Verfügung.',
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mayClaim(User $user, Offer $offer, ?CarbonInterface $now = null): bool
|
||||||
|
{
|
||||||
|
return $this->refusal($user, $offer, $now) === null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assertMayClaim(User $user, Offer $offer): void
|
||||||
|
{
|
||||||
|
$reason = $this->refusal($user, $offer);
|
||||||
|
|
||||||
|
if ($reason !== null) {
|
||||||
|
throw new DomainRuleException($reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Angebote auf Abruf, die das Konto jetzt übernehmen darf und noch nicht übernommen hat.
|
||||||
|
*
|
||||||
|
* @return Collection<int, Offer>
|
||||||
|
*/
|
||||||
|
public function claimable(User $user): Collection
|
||||||
|
{
|
||||||
|
if ($user->party_id === null) {
|
||||||
|
return collect();
|
||||||
|
}
|
||||||
|
|
||||||
|
$taken = Acquisition::query()
|
||||||
|
->where('party_id', $user->party_id)
|
||||||
|
->where('type', AcquisitionType::FreierAbruf)
|
||||||
|
->where('reference_type', 'offer')
|
||||||
|
->pluck('reference_id')
|
||||||
|
->all();
|
||||||
|
|
||||||
|
return Offer::query()
|
||||||
|
->whereHas('versions', fn ($query) => $query->where('status', OfferStatus::Aktiv)->where('holder_kind', 'person')->whereIn('grant_kind', ['auf_abruf', 'bei_registrierung']))
|
||||||
|
->whereNotIn('id', $taken)
|
||||||
|
->orderBy('name')
|
||||||
|
->get()
|
||||||
|
->filter(fn (Offer $offer): bool => $this->mayClaim($user, $offer))
|
||||||
|
->values();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ein Konto für ein Angebot freischalten (Regel „nur freigeschaltete Konten“).
|
||||||
|
*/
|
||||||
|
public function release(Offer $offer, User $member, ?User $actor, ?CarbonInterface $until = null, ?string $reason = null): OfferRelease
|
||||||
|
{
|
||||||
|
if ($offer->claim_access !== self::RELEASED) {
|
||||||
|
throw new DomainRuleException('Freigaben gibt es nur bei der Regel „nur freigeschaltete Konten“.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($member->party_id === null) {
|
||||||
|
throw new DomainRuleException('Nur ein Mitgliedskonto kann für ein Angebot freigeschaltet werden.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return DB::transaction(function () use ($offer, $member, $actor, $until, $reason): OfferRelease {
|
||||||
|
Offer::query()->whereKey($offer->id)->lockForUpdate()->firstOrFail();
|
||||||
|
|
||||||
|
if ($this->activeRelease($offer, $member) !== null) {
|
||||||
|
throw new DomainRuleException('Dieses Konto ist für das Angebot bereits freigeschaltet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($until !== null && $until->lessThanOrEqualTo(now())) {
|
||||||
|
throw new DomainRuleException('Das Ende der Freigabe liegt in der Vergangenheit.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return OfferRelease::query()->create([
|
||||||
|
'offer_id' => $offer->id,
|
||||||
|
'user_id' => $member->id,
|
||||||
|
'granted_by' => $actor?->id,
|
||||||
|
'granted_at' => now(),
|
||||||
|
'valid_until' => $until,
|
||||||
|
'reason' => filled($reason) ? trim((string) $reason) : null,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entzieht die Freigabe. Sie bleibt mit Zeitpunkt, Person und Begründung gespeichert; bereits übernommene Angebote
|
||||||
|
* bleiben in der Bibliothek.
|
||||||
|
*/
|
||||||
|
public function revoke(OfferRelease $release, ?User $actor, ?string $reason = null): OfferRelease
|
||||||
|
{
|
||||||
|
return DB::transaction(function () use ($release, $actor, $reason): OfferRelease {
|
||||||
|
$release = OfferRelease::query()->lockForUpdate()->findOrFail($release->id);
|
||||||
|
|
||||||
|
if ($release->revoked_at !== null) {
|
||||||
|
throw new DomainRuleException('Diese Freigabe ist bereits entzogen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$release->forceFill([
|
||||||
|
'revoked_at' => now(),
|
||||||
|
'revoked_by' => $actor?->id,
|
||||||
|
'reason' => filled($reason) ? trim((string) $reason) : $release->reason,
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
return $release;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function activeRelease(Offer $offer, User $member, ?CarbonInterface $now = null): ?OfferRelease
|
||||||
|
{
|
||||||
|
$now ??= now();
|
||||||
|
|
||||||
|
return OfferRelease::query()
|
||||||
|
->where('offer_id', $offer->id)
|
||||||
|
->where('user_id', $member->id)
|
||||||
|
->whereNull('revoked_at')
|
||||||
|
->where('granted_at', '<=', $now)
|
||||||
|
->where(fn ($query) => $query->whereNull('valid_until')->orWhere('valid_until', '>', $now))
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Das Konto besitzt den Artikel, wenn seine Person eine aktive, gültige Berechtigung darauf hat. */
|
||||||
|
public function owns(User $user, int $articleId, ?CarbonInterface $now = null): bool
|
||||||
|
{
|
||||||
|
$now ??= now();
|
||||||
|
|
||||||
|
if ($user->party_id === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Grant::query()
|
||||||
|
->where('license_article_id', $articleId)
|
||||||
|
->where('status', GrantStatus::Aktiv)
|
||||||
|
->where(fn ($query) => $query->whereNull('valid_from')->orWhere('valid_from', '<=', $now))
|
||||||
|
->where(fn ($query) => $query->whereNull('valid_until')->orWhere('valid_until', '>', $now))
|
||||||
|
->whereHas('acquisition', fn ($query) => $query->where('party_id', $user->party_id))
|
||||||
|
->exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function activeVersion(Offer $offer): ?OfferVersion
|
||||||
|
{
|
||||||
|
return $offer->versions()->where('status', OfferStatus::Aktiv)->orderByDesc('number')->first();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,8 @@
|
|||||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||||
use App\Filament\Resources\Pillars\PillarResource;
|
use App\Filament\Resources\Pillars\PillarResource;
|
||||||
use App\Filament\Support\EditorialCatalog;
|
use App\Filament\Support\EditorialCatalog;
|
||||||
|
use App\Filament\Support\SymbolField;
|
||||||
|
use App\Support\Brand\SymbolCatalog;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Actions\ActionGroup;
|
use Filament\Actions\ActionGroup;
|
||||||
use Filament\Forms\Components\Checkbox;
|
use Filament\Forms\Components\Checkbox;
|
||||||
@@ -261,6 +263,8 @@ private function formular(?Model $record): array
|
|||||||
];
|
];
|
||||||
|
|
||||||
if ($this->istMaterialart()) {
|
if ($this->istMaterialart()) {
|
||||||
|
$felder[] = SymbolField::make('symbol', 'Symbol im Shop')
|
||||||
|
->helperText('Optional. Das Symbol steht auf der Shopkachel bei Artikeln dieser Materialart, auch wenn kein Bild gepflegt ist.');
|
||||||
$system = $record instanceof EditorialContentKind && $record->isSystem();
|
$system = $record instanceof EditorialContentKind && $record->isSystem();
|
||||||
$felder[] = CheckboxList::make('contexts')
|
$felder[] = CheckboxList::make('contexts')
|
||||||
->label('Zulässig für')
|
->label('Zulässig für')
|
||||||
@@ -325,6 +329,7 @@ private function bearbeitenAction(): Action
|
|||||||
->schema(fn (Model $record): array => $this->formular($record))
|
->schema(fn (Model $record): array => $this->formular($record))
|
||||||
->fillForm(fn (Model $record): array => [
|
->fillForm(fn (Model $record): array => [
|
||||||
'label' => $record->label,
|
'label' => $record->label,
|
||||||
|
'symbol' => $record instanceof EditorialContentKind ? $record->symbol : null,
|
||||||
'contexts' => $record instanceof EditorialContentKind ? (array) ($record->contexts ?? []) : [],
|
'contexts' => $record instanceof EditorialContentKind ? (array) ($record->contexts ?? []) : [],
|
||||||
])
|
])
|
||||||
->modalSubmitActionLabel('Speichern')
|
->modalSubmitActionLabel('Speichern')
|
||||||
@@ -337,11 +342,21 @@ private function bearbeitenAction(): Action
|
|||||||
$record->contexts = $this->kontexte((array) $data['contexts']);
|
$record->contexts = $this->kontexte((array) $data['contexts']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($record instanceof EditorialContentKind) {
|
||||||
|
$record->symbol = $this->symbol($data['symbol'] ?? null);
|
||||||
|
}
|
||||||
|
|
||||||
$record->save();
|
$record->save();
|
||||||
Notification::make()->success()->title('Gespeichert')->body('Die neue Bezeichnung gilt sofort in Redaktion, Filtern und Picker.')->send();
|
Notification::make()->success()->title('Gespeichert')->body('Die neue Bezeichnung gilt sofort in Redaktion, Filtern und Picker.')->send();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Ein Symbol wird nur gespeichert, wenn die Symbolbibliothek es kennt; sonst bleibt die Materialart ohne Symbol. */
|
||||||
|
private function symbol(mixed $value): ?string
|
||||||
|
{
|
||||||
|
return is_string($value) && array_key_exists($value, SymbolCatalog::options()) ? $value : null;
|
||||||
|
}
|
||||||
|
|
||||||
private function anlegen(array $data): void
|
private function anlegen(array $data): void
|
||||||
{
|
{
|
||||||
$label = trim((string) $data['label']);
|
$label = trim((string) $data['label']);
|
||||||
@@ -354,6 +369,7 @@ private function anlegen(array $data): void
|
|||||||
'sort_order' => (int) EditorialContentKind::query()->max('sort_order') + 10,
|
'sort_order' => (int) EditorialContentKind::query()->max('sort_order') + 10,
|
||||||
'is_active' => true,
|
'is_active' => true,
|
||||||
'contexts' => $this->kontexte((array) ($data['contexts'] ?? [])),
|
'contexts' => $this->kontexte((array) ($data['contexts'] ?? [])),
|
||||||
|
'symbol' => $this->symbol($data['symbol'] ?? null),
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$dimension = $this->dimension();
|
$dimension = $this->dimension();
|
||||||
|
|||||||
@@ -85,7 +85,8 @@ public function daten(): array
|
|||||||
|
|
||||||
$freigabe = [
|
$freigabe = [
|
||||||
['text' => 'Produktivfreigabe (SHOP_LIVE_RELEASE): '.(config('shop.live_release') === true ? 'gesetzt' : 'nicht gesetzt'), 'neben' => 'Standardmäßig aus. Setzt Lars in der Umgebungsdatei des Servers, wenn er den Verkauf freigibt. Ohne sie bleibt der Shop in Produktion abgeschaltet und Stripe nimmt dort keine Zahlung an.', 'zustand' => config('shop.live_release') === true ? ['label' => 'Gesetzt', 'ton' => 'gut'] : ['label' => 'Aus', 'ton' => 'neutral']],
|
['text' => 'Produktivfreigabe (SHOP_LIVE_RELEASE): '.(config('shop.live_release') === true ? 'gesetzt' : 'nicht gesetzt'), 'neben' => 'Standardmäßig aus. Setzt Lars in der Umgebungsdatei des Servers, wenn er den Verkauf freigibt. Ohne sie bleibt der Shop in Produktion abgeschaltet und Stripe nimmt dort keine Zahlung an.', 'zustand' => config('shop.live_release') === true ? ['label' => 'Gesetzt', 'ton' => 'gut'] : ['label' => 'Aus', 'ton' => 'neutral']],
|
||||||
['text' => 'Umgebung: '.(app()->isProduction() ? 'Produktion' : 'Test oder lokal'), 'neben' => app()->isProduction() ? 'Der Shop ist hier '.(Shop::enabled() ? 'aktiv.' : 'abgeschaltet.') : 'Hier läuft der Shop mit Test- oder Sandbox-Zahlung.', 'zustand' => app()->isProduction() ? (Shop::enabled() ? ['label' => 'Live', 'ton' => 'gut'] : ['label' => 'Abgeschaltet', 'ton' => 'neutral']) : ['label' => 'Test', 'ton' => 'neutral']],
|
['text' => 'Shop sichtbar (SHOP_PUBLIC): '.(config('shop.public') === true ? 'gesetzt' : 'nicht gesetzt'), 'neben' => 'Zweiter Schalter, nur Produktion: Übersicht, Produktseiten und Pakete sind öffentlich zu sehen, „Kaufen“ führt auf die Hinweisseite (der Kauf startet zum Verkaufsstart). Die Produktivfreigabe macht den Shop immer auch sichtbar. Wird wie sie in der Umgebungsdatei des Servers gesetzt.', 'zustand' => Shop::visible() ? ['label' => 'Sichtbar', 'ton' => 'gut'] : ['label' => 'Aus', 'ton' => 'neutral']],
|
||||||
|
['text' => 'Umgebung: '.(app()->isProduction() ? 'Produktion' : 'Test oder lokal'), 'neben' => app()->isProduction() ? 'Der Shop ist hier '.(Shop::checkoutOpen() ? 'aktiv: sichtbar und kaufbar.' : (Shop::visible() ? 'sichtbar, der Kauf ist noch nicht freigegeben.' : 'abgeschaltet.')) : 'Hier läuft der Shop mit Test- oder Sandbox-Zahlung.', 'zustand' => app()->isProduction() ? (Shop::enabled() ? ['label' => 'Live', 'ton' => 'gut'] : ['label' => 'Abgeschaltet', 'ton' => 'neutral']) : ['label' => 'Test', 'ton' => 'neutral']],
|
||||||
];
|
];
|
||||||
|
|
||||||
$angebote = [
|
$angebote = [
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Filament\Pages;
|
namespace App\Filament\Pages;
|
||||||
|
|
||||||
|
use App\Domain\Cms\LinkTargets;
|
||||||
use App\Domain\Cms\NavigationItem;
|
use App\Domain\Cms\NavigationItem;
|
||||||
use App\Domain\Cms\Page as CmsPage;
|
use App\Domain\Cms\Page as CmsPage;
|
||||||
use App\Domain\Cms\PageService;
|
use App\Domain\Cms\PageService;
|
||||||
|
use App\Domain\Cms\Sections\PageSections;
|
||||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||||
use App\Filament\Resources\Pages\PageResource;
|
use App\Filament\Resources\Pages\PageResource;
|
||||||
use App\Filament\Support\Bestand;
|
use App\Filament\Support\Bestand;
|
||||||
@@ -74,7 +76,7 @@ class Webpraesenz extends Page
|
|||||||
/** Ausgewählter Eintrag (Schlüssel „e{id}“ oder „n{zähler}“ für neue Einträge). */
|
/** Ausgewählter Eintrag (Schlüssel „e{id}“ oder „n{zähler}“ für neue Einträge). */
|
||||||
public ?string $auswahl = null;
|
public ?string $auswahl = null;
|
||||||
|
|
||||||
/** @var array<string, array{id: ?int, label: string, page_id: ?int, url: string, placement: string, parent: ?string, is_visible: bool}> */
|
/** @var array<string, array{id: ?int, label: string, page_id: ?int, url: string, anchor: string, placement: string, parent: ?string, is_visible: bool}> */
|
||||||
public array $eintraege = [];
|
public array $eintraege = [];
|
||||||
|
|
||||||
/** Globale Reihenfolge der Schlüssel; entspricht sort_order. @var list<string> */
|
/** Globale Reihenfolge der Schlüssel; entspricht sort_order. @var list<string> */
|
||||||
@@ -103,6 +105,9 @@ class Webpraesenz extends Page
|
|||||||
/** Eintrag, dessen Ziel gerade gewählt wird. */
|
/** Eintrag, dessen Ziel gerade gewählt wird. */
|
||||||
public ?string $zielwahl = null;
|
public ?string $zielwahl = null;
|
||||||
|
|
||||||
|
/** Zweiter Schritt der Zielwahl: gewählte Seite, deren Sprungmarke noch zu wählen ist. */
|
||||||
|
public ?int $zielSeite = null;
|
||||||
|
|
||||||
public string $zielSuche = '';
|
public string $zielSuche = '';
|
||||||
|
|
||||||
public static function canAccess(): bool
|
public static function canAccess(): bool
|
||||||
@@ -327,6 +332,7 @@ public function ladeMenues(): void
|
|||||||
'label' => (string) $item->label,
|
'label' => (string) $item->label,
|
||||||
'page_id' => $item->page_id,
|
'page_id' => $item->page_id,
|
||||||
'url' => (string) ($item->url ?? ''),
|
'url' => (string) ($item->url ?? ''),
|
||||||
|
'anchor' => (string) ($item->anchor ?? ''),
|
||||||
'placement' => (string) $item->placement,
|
'placement' => (string) $item->placement,
|
||||||
'parent' => $item->parent_id !== null ? 'e'.$item->parent_id : null,
|
'parent' => $item->parent_id !== null ? 'e'.$item->parent_id : null,
|
||||||
'is_visible' => (bool) $item->is_visible,
|
'is_visible' => (bool) $item->is_visible,
|
||||||
@@ -364,6 +370,7 @@ private function bereichsStaende(): array
|
|||||||
trim($e['label']),
|
trim($e['label']),
|
||||||
$e['page_id'] !== null ? (int) $e['page_id'] : null,
|
$e['page_id'] !== null ? (int) $e['page_id'] : null,
|
||||||
trim($e['url']),
|
trim($e['url']),
|
||||||
|
trim($e['anchor'] ?? ''),
|
||||||
(bool) $e['is_visible'],
|
(bool) $e['is_visible'],
|
||||||
$this->elternVon($k),
|
$this->elternVon($k),
|
||||||
];
|
];
|
||||||
@@ -562,6 +569,7 @@ public function eintragHinzufuegen(): void
|
|||||||
'label' => '',
|
'label' => '',
|
||||||
'page_id' => null,
|
'page_id' => null,
|
||||||
'url' => '',
|
'url' => '',
|
||||||
|
'anchor' => '',
|
||||||
'placement' => $this->menue,
|
'placement' => $this->menue,
|
||||||
'parent' => null,
|
'parent' => null,
|
||||||
'is_visible' => true,
|
'is_visible' => true,
|
||||||
@@ -595,7 +603,7 @@ public function updatedEintraege(mixed $value, string $pfad): void
|
|||||||
match ($feld) {
|
match ($feld) {
|
||||||
'placement' => $this->bereichGeaendert($k),
|
'placement' => $this->bereichGeaendert($k),
|
||||||
'parent' => $this->elternGeaendert($k),
|
'parent' => $this->elternGeaendert($k),
|
||||||
'page_id' => $this->eintraege[$k]['page_id'] = blank($value) ? null : (int) $value,
|
'page_id' => $this->seiteGeaendert($k, $value),
|
||||||
'is_visible' => $this->eintraege[$k]['is_visible'] = (bool) $value,
|
'is_visible' => $this->eintraege[$k]['is_visible'] = (bool) $value,
|
||||||
default => null,
|
default => null,
|
||||||
};
|
};
|
||||||
@@ -673,10 +681,18 @@ private function ansEnde(string $k): void
|
|||||||
$this->folge = [...array_values(array_filter($this->folge, fn (string $x): bool => $x !== $k)), $k];
|
$this->folge = [...array_values(array_filter($this->folge, fn (string $x): bool => $x !== $k)), $k];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Eine andere Zielseite hat eigene Sprungmarken: Die bisherige Marke entfällt. */
|
||||||
|
private function seiteGeaendert(string $k, mixed $value): void
|
||||||
|
{
|
||||||
|
$this->eintraege[$k]['page_id'] = blank($value) ? null : (int) $value;
|
||||||
|
$this->eintraege[$k]['anchor'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
public function zielAdresseNutzen(string $k): void
|
public function zielAdresseNutzen(string $k): void
|
||||||
{
|
{
|
||||||
if (isset($this->eintraege[$k])) {
|
if (isset($this->eintraege[$k])) {
|
||||||
$this->eintraege[$k]['page_id'] = null;
|
$this->eintraege[$k]['page_id'] = null;
|
||||||
|
$this->eintraege[$k]['anchor'] = '';
|
||||||
$this->js("requestAnimationFrame(() => document.getElementById('menue-adresse')?.focus())");
|
$this->js("requestAnimationFrame(() => document.getElementById('menue-adresse')?.focus())");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -692,6 +708,7 @@ public function oeffneZielwahl(string $k): void
|
|||||||
public function schliesseZielwahl(): void
|
public function schliesseZielwahl(): void
|
||||||
{
|
{
|
||||||
$this->zielwahl = null;
|
$this->zielwahl = null;
|
||||||
|
$this->zielSeite = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function waehleZiel(int $seiteId): void
|
public function waehleZiel(int $seiteId): void
|
||||||
@@ -702,8 +719,48 @@ public function waehleZiel(int $seiteId): void
|
|||||||
|
|
||||||
$this->eintraege[$this->zielwahl]['page_id'] = $seiteId;
|
$this->eintraege[$this->zielwahl]['page_id'] = $seiteId;
|
||||||
$this->eintraege[$this->zielwahl]['url'] = '';
|
$this->eintraege[$this->zielwahl]['url'] = '';
|
||||||
|
$this->eintraege[$this->zielwahl]['anchor'] = '';
|
||||||
$this->resetErrorBag("eintraege.{$this->zielwahl}.url");
|
$this->resetErrorBag("eintraege.{$this->zielwahl}.url");
|
||||||
$this->zielwahl = null;
|
|
||||||
|
// Hat die Seite Sprungmarken, folgt als zweiter Schritt die Wahl der Marke; sonst ist die Auswahl fertig.
|
||||||
|
if ($this->zielMarken($seiteId) !== []) {
|
||||||
|
$this->zielSeite = $seiteId;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->schliesseZielwahl();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zweiter Schritt von „Ziel ändern“: Sprungmarke der gewählten Seite übernehmen (leer = Seitenanfang).
|
||||||
|
*/
|
||||||
|
public function waehleMarke(?string $marke = null): void
|
||||||
|
{
|
||||||
|
if ($this->zielwahl === null || $this->zielSeite === null || ! isset($this->eintraege[$this->zielwahl])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$marke = filled($marke) ? $marke : null;
|
||||||
|
|
||||||
|
if ($marke !== null && ! in_array($marke, array_column($this->zielMarken($this->zielSeite), 'anchor'), true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->eintraege[$this->zielwahl]['anchor'] = $marke ?? '';
|
||||||
|
$this->schliesseZielwahl();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sprungmarken einer Seite für den zweiten Schritt.
|
||||||
|
*
|
||||||
|
* @return list<array{anchor: string, label: string, hidden: bool, published: bool}>
|
||||||
|
*/
|
||||||
|
public function zielMarken(int $seiteId): array
|
||||||
|
{
|
||||||
|
$seite = $this->seitenCache()->get($seiteId);
|
||||||
|
|
||||||
|
return $seite === null ? [] : app(LinkTargets::class)->anchorsForPage($seite);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -755,7 +812,7 @@ public function zielVon(string $k): array
|
|||||||
|
|
||||||
return $seite === null
|
return $seite === null
|
||||||
? ['art' => 'fehlt', 'titel' => null, 'pfad' => null, 'zustand' => ['label' => 'Zielseite nicht mehr vorhanden', 'ton' => 'achtung'], 'seite' => null]
|
? ['art' => 'fehlt', 'titel' => null, 'pfad' => null, 'zustand' => ['label' => 'Zielseite nicht mehr vorhanden', 'ton' => 'achtung'], 'seite' => null]
|
||||||
: ['art' => 'seite', 'titel' => $seite->latestRevision?->contentTitle() ?: $seite->path, 'pfad' => $seite->path, 'zustand' => $this->seitenZustand($seite), 'seite' => $seite];
|
: ['art' => 'seite', 'titel' => $seite->latestRevision?->contentTitle() ?: $seite->path, 'pfad' => $seite->path.(trim($e['anchor'] ?? '') !== '' ? '#'.trim($e['anchor']) : ''), 'zustand' => $this->seitenZustand($seite), 'seite' => $seite];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trim($e['url']) !== '') {
|
if (trim($e['url']) !== '') {
|
||||||
@@ -919,6 +976,7 @@ private function pruefen(): array
|
|||||||
|| $alt->label !== $e['label']
|
|| $alt->label !== $e['label']
|
||||||
|| $alt->page_id !== ($e['page_id'] !== null ? (int) $e['page_id'] : null)
|
|| $alt->page_id !== ($e['page_id'] !== null ? (int) $e['page_id'] : null)
|
||||||
|| (string) ($alt->url ?? '') !== $e['url']
|
|| (string) ($alt->url ?? '') !== $e['url']
|
||||||
|
|| (string) ($alt->anchor ?? '') !== trim($e['anchor'] ?? '')
|
||||||
|| $alt->placement !== $e['placement']
|
|| $alt->placement !== $e['placement']
|
||||||
|| ($alt->parent_id !== null ? 'e'.$alt->parent_id : null) !== $this->elternVon($k)
|
|| ($alt->parent_id !== null ? 'e'.$alt->parent_id : null) !== $this->elternVon($k)
|
||||||
|| (bool) $alt->is_visible !== (bool) $e['is_visible']
|
|| (bool) $alt->is_visible !== (bool) $e['is_visible']
|
||||||
@@ -936,16 +994,19 @@ private function pruefen(): array
|
|||||||
'placement' => $e['placement'],
|
'placement' => $e['placement'],
|
||||||
'page_id' => $e['page_id'],
|
'page_id' => $e['page_id'],
|
||||||
'url' => trim($e['url']) === '' ? null : trim($e['url']),
|
'url' => trim($e['url']) === '' ? null : trim($e['url']),
|
||||||
|
'anchor' => trim($e['anchor'] ?? '') === '' ? null : trim($e['anchor']),
|
||||||
], [
|
], [
|
||||||
'label' => ['required', 'string', 'max:80'],
|
'label' => ['required', 'string', 'max:80'],
|
||||||
'placement' => ['required', 'in:'.implode(',', array_keys(self::BEREICHE))],
|
'placement' => ['required', 'in:'.implode(',', array_keys(self::BEREICHE))],
|
||||||
'page_id' => ['nullable', 'integer', 'exists:pages,id'],
|
'page_id' => ['nullable', 'integer', 'exists:pages,id'],
|
||||||
'url' => ['nullable', 'string', 'max:500', SafeUrl::rule()],
|
'url' => ['nullable', 'string', 'max:500', SafeUrl::rule()],
|
||||||
|
'anchor' => ['nullable', 'string', 'max:'.PageSections::MAX_ANCHOR, 'regex:'.PageSections::ANCHOR_PATTERN],
|
||||||
], [
|
], [
|
||||||
'label.required' => 'Bitte einen Menütext eingeben.',
|
'label.required' => 'Bitte einen Menütext eingeben.',
|
||||||
'label.max' => 'Der Menütext hat höchstens 80 Zeichen.',
|
'label.max' => 'Der Menütext hat höchstens 80 Zeichen.',
|
||||||
'url.max' => 'Die Adresse hat höchstens 500 Zeichen.',
|
'url.max' => 'Die Adresse hat höchstens 500 Zeichen.',
|
||||||
'page_id.exists' => 'Diese Seite gibt es nicht mehr.',
|
'page_id.exists' => 'Diese Seite gibt es nicht mehr.',
|
||||||
|
'anchor.regex' => 'Die Sprungmarke ist ungültig. Bitte über „Ziel ändern“ eine vorhandene wählen.',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$meldungen = $validator->errors()->toArray();
|
$meldungen = $validator->errors()->toArray();
|
||||||
@@ -1044,6 +1105,8 @@ private function schreiben(array $geaendert): array
|
|||||||
'label' => trim($e['label']),
|
'label' => trim($e['label']),
|
||||||
'page_id' => $e['page_id'] !== null ? (int) $e['page_id'] : null,
|
'page_id' => $e['page_id'] !== null ? (int) $e['page_id'] : null,
|
||||||
'url' => trim($e['url']) === '' ? null : trim($e['url']),
|
'url' => trim($e['url']) === '' ? null : trim($e['url']),
|
||||||
|
// Eine Sprungmarke gehört zur Zielseite; ohne Seite (freie Adresse) entfällt sie.
|
||||||
|
'anchor' => $e['page_id'] !== null && trim($e['anchor'] ?? '') !== '' ? trim($e['anchor']) : null,
|
||||||
'placement' => $e['placement'],
|
'placement' => $e['placement'],
|
||||||
'parent_id' => $eltern !== null ? ($ids[$eltern] ?? $this->eintraege[$eltern]['id']) : null,
|
'parent_id' => $eltern !== null ? ($ids[$eltern] ?? $this->eintraege[$eltern]['id']) : null,
|
||||||
'is_visible' => (bool) $e['is_visible'],
|
'is_visible' => (bool) $e['is_visible'],
|
||||||
|
|||||||
@@ -13,20 +13,33 @@
|
|||||||
use App\Domain\Catalog\IdentityDimension;
|
use App\Domain\Catalog\IdentityDimension;
|
||||||
use App\Domain\Catalog\IdentityDimensionValue;
|
use App\Domain\Catalog\IdentityDimensionValue;
|
||||||
use App\Domain\Catalog\IdentityProfile;
|
use App\Domain\Catalog\IdentityProfile;
|
||||||
|
use App\Domain\Catalog\LicenceScope;
|
||||||
use App\Domain\Catalog\LicenseArticle;
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
|
use App\Domain\Catalog\Offer;
|
||||||
|
use App\Domain\Catalog\OfferService;
|
||||||
|
use App\Domain\Catalog\OfferStatus;
|
||||||
|
use App\Domain\Catalog\RightsProfileVersion;
|
||||||
|
use App\Domain\Catalog\StatusValue;
|
||||||
|
use App\Domain\Commerce\Money;
|
||||||
|
use App\Domain\Commerce\ProductOptions;
|
||||||
|
use App\Domain\Commerce\ShopMarkers;
|
||||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||||
|
use App\Filament\Resources\Offers\OfferResource;
|
||||||
use App\Filament\Support\AssignsPillars;
|
use App\Filament\Support\AssignsPillars;
|
||||||
|
use App\Filament\Support\CatalogLabels;
|
||||||
use App\Filament\Support\CatalogOptions;
|
use App\Filament\Support\CatalogOptions;
|
||||||
use App\Filament\Support\EditorialCatalog;
|
use App\Filament\Support\EditorialCatalog;
|
||||||
use App\Filament\Support\ManagesEditorialSurface;
|
use App\Filament\Support\ManagesEditorialSurface;
|
||||||
use App\Filament\Support\ManagesRichFields;
|
use App\Filament\Support\ManagesRichFields;
|
||||||
|
use App\Filament\Support\PublicationReadiness;
|
||||||
use App\Filament\Support\ReportsDomainRules;
|
use App\Filament\Support\ReportsDomainRules;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
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\Resources\Pages\ViewRecord;
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
use Illuminate\Contracts\Support\Htmlable;
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
@@ -409,6 +422,248 @@ public function withdrawAction(): Action
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Optionen dieses Artikels im Shop: Bezeichnung, Preis, Rechte, Nutzerkreis und Zustand je Option. Gelesen wird
|
||||||
|
* die aktive, sonst die letzte Fassung.
|
||||||
|
*
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function optionRows(): array
|
||||||
|
{
|
||||||
|
/** @var LicenseArticle $article */
|
||||||
|
$article = $this->getRecord();
|
||||||
|
$options = app(ProductOptions::class);
|
||||||
|
$offers = app(OfferService::class);
|
||||||
|
$rows = [];
|
||||||
|
|
||||||
|
foreach ($options->offersOfArticle($article) as $offer) {
|
||||||
|
$version = $offers->purchasableVersion($offer)
|
||||||
|
?? $offer->versions()->where('status', OfferStatus::Aktiv)->orderByDesc('number')->first()
|
||||||
|
?? $offer->versions()->orderByDesc('number')->first();
|
||||||
|
|
||||||
|
if ($version === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$version->loadMissing('lines.rights.profile');
|
||||||
|
$active = StatusValue::of($version->status) === OfferStatus::Aktiv->value;
|
||||||
|
$buyable = $active && $offers->purchasableVersion($offer) !== null;
|
||||||
|
$rows[] = [
|
||||||
|
'offer' => $offer->id,
|
||||||
|
'name' => $offer->optionName(),
|
||||||
|
'price' => $version->price_cents === null ? 'kein Preis' : Money::format((int) $version->price_cents),
|
||||||
|
'licence' => LicenceScope::label($version->licence_scope, $version->trainer_count),
|
||||||
|
'for' => $version->holder_kind === 'organisation' ? 'Organisationen und Vereine' : 'Privatpersonen',
|
||||||
|
'rights' => (string) ($version->lines->first()?->rights?->profile?->name ?? '–'),
|
||||||
|
'number' => $version->number,
|
||||||
|
'active' => $active,
|
||||||
|
'kauf' => $version->grant_kind === 'kauf',
|
||||||
|
'buyable' => $buyable,
|
||||||
|
'zustand' => match (true) {
|
||||||
|
$buyable => ['label' => 'Im Shop', 'ton' => 'gut'],
|
||||||
|
$active => ['label' => CatalogLabels::vergabe($version).' · nicht im Shop', 'ton' => 'neutral'],
|
||||||
|
default => ['label' => 'Nicht im Verkauf', 'ton' => 'leise'],
|
||||||
|
},
|
||||||
|
'page' => $buyable ? parse_url((string) $options->pageUrl($offer), PHP_URL_PATH) : null,
|
||||||
|
'url' => OfferResource::getUrl('view', ['record' => $offer]),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Ein Artikel lässt sich anbieten, wenn sein aktueller Stand veröffentlicht ist. */
|
||||||
|
public function canOffer(): bool
|
||||||
|
{
|
||||||
|
return app(PublicationReadiness::class)->articleUsable($this->getRecord());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Option hinzufügen oder ändern: Rechteprofil, Preis, Nutzerkreis und Eignung. Der Artikel steht fest, es gibt keine
|
||||||
|
* Auswahl von Artikel oder Inhalt. Mit dem Argument `offer` ändert die Aktion eine bestehende Option (nächste Fassung).
|
||||||
|
*/
|
||||||
|
public function optionAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('option')
|
||||||
|
->modalWidth('2xl')
|
||||||
|
->modalHeading(fn (array $arguments): string => isset($arguments['offer'])
|
||||||
|
? 'Option „'.$this->optionOf($arguments)->optionName().'“ ändern'
|
||||||
|
: 'Option hinzufügen: so wird der Artikel verkauft')
|
||||||
|
->modalDescription(fn (array $arguments): string => isset($arguments['offer'])
|
||||||
|
? 'Die Maske ist mit der letzten Fassung vorbelegt. Erst „Speichern und anbieten“ schaltet die Änderung öffentlich: Die bisherige Fassung wird beendet und bleibt gespeichert, neue Käufe nutzen die neue. Bereits begründete Berechtigungen und Bestellungen ändern sich nicht. „Abbrechen“ verwirft die Eingaben.'
|
||||||
|
: 'Eine Option ist eine Lizenz mit Rechteprofil und Preis. Der Artikel kann mehrere Optionen haben, zum Beispiel für Privatpersonen und für Vereine. Sie erscheinen gemeinsam auf der Produktseite des Artikels. „Abbrechen“ verwirft die Eingaben.')
|
||||||
|
->modalSubmitActionLabel('Speichern und anbieten')
|
||||||
|
->fillForm(fn (array $arguments): array => $this->optionForm($arguments))
|
||||||
|
->schema([
|
||||||
|
Select::make('rights_id')->label('Rechteprofil')
|
||||||
|
->options(fn (): array => CatalogOptions::rights())
|
||||||
|
->required()
|
||||||
|
->helperText('Was Käufer mit dem Artikel tun dürfen (ansehen, herunterladen, Nutzungszweck).'),
|
||||||
|
TextInput::make('price_euro')->label('Preis in Euro')->suffix('€')->required()
|
||||||
|
->helperText('Zum Beispiel 49,00. Ein Kauf braucht einen Preis über 0,00 €.'),
|
||||||
|
Select::make('holder_kind')->label('Geeignet für')->options([
|
||||||
|
'person' => 'Privatpersonen',
|
||||||
|
'organisation' => 'Organisationen und Vereine',
|
||||||
|
])->required()->live()
|
||||||
|
->helperText('Wähle die Eignung passend zum Rechteprofil: Organisationslizenzen brauchen institutionelle Rechte.'),
|
||||||
|
Select::make('licence_scope')->label('Nutzerkreis')
|
||||||
|
->options(LicenceScope::options())
|
||||||
|
->required()->live()
|
||||||
|
->helperText('Wie viele Trainer die Inhalte einsetzen dürfen. Der Download bleibt beim bestellenden Konto.'),
|
||||||
|
TextInput::make('trainer_count')->label('Anzahl Trainer')
|
||||||
|
->numeric()->minValue(2)->maxValue(LicenceScope::MAX_TRAINERS)->integer()
|
||||||
|
->required(fn (Get $get): bool => $get('licence_scope') === LicenceScope::MULTI)
|
||||||
|
->visible(fn (Get $get): bool => $get('licence_scope') === LicenceScope::MULTI)
|
||||||
|
->live(),
|
||||||
|
TextInput::make('option_label')->label('Bezeichnung der Option')
|
||||||
|
->maxLength(120)
|
||||||
|
->placeholder(fn (Get $get): string => OfferService::defaultOptionLabel($get('holder_kind'), $get('licence_scope'), $get('trainer_count')))
|
||||||
|
->helperText('So heißt die Option auf der Produktseite. Leer lassen übernimmt den grauen Vorschlag.'),
|
||||||
|
])
|
||||||
|
->action(function (array $data, array $arguments): void {
|
||||||
|
$this->report(function () use ($data, $arguments): string {
|
||||||
|
/** @var LicenseArticle $article */
|
||||||
|
$article = $this->getRecord();
|
||||||
|
$rights = RightsProfileVersion::query()->findOrFail($data['rights_id']);
|
||||||
|
$price = Money::parse($data['price_euro'] ?? null);
|
||||||
|
$label = filled($data['option_label'] ?? null)
|
||||||
|
? trim((string) $data['option_label'])
|
||||||
|
: OfferService::defaultOptionLabel($data['holder_kind'], $data['licence_scope'], $data['trainer_count'] ?? null);
|
||||||
|
$attributes = [
|
||||||
|
'holder_kind' => $data['holder_kind'],
|
||||||
|
'licence_scope' => $data['licence_scope'],
|
||||||
|
'trainer_count' => $data['trainer_count'] ?? null,
|
||||||
|
'price_cents' => $price,
|
||||||
|
];
|
||||||
|
$service = app(OfferService::class);
|
||||||
|
|
||||||
|
if (isset($arguments['offer'])) {
|
||||||
|
$offer = $this->optionOf($arguments);
|
||||||
|
$version = $service->reviseArticleOption($offer, $article, $rights, $attributes, $label);
|
||||||
|
} else {
|
||||||
|
$name = app(ProductOptions::class)->articleTitle($article).': '.$label;
|
||||||
|
$version = $service->offerArticle($article, $rights, $attributes, $name, $label);
|
||||||
|
$offer = $version->offer;
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = app(ProductOptions::class)->pageUrl($offer);
|
||||||
|
|
||||||
|
return 'Die Option „'.$offer->optionName().'“ ist als Fassung '.$version->number.' aktiv und im Shop kaufbar'
|
||||||
|
.($page !== null ? ' unter '.parse_url($page, PHP_URL_PATH) : '').'.';
|
||||||
|
}, 'Die Option ist aktiv.');
|
||||||
|
$this->refreshRecord();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Die Marker, die die Kachel im Shop gerade zeigt (Wort je Marker), mit der Einstellung der Redaktion. */
|
||||||
|
public function markerRows(): array
|
||||||
|
{
|
||||||
|
/** @var LicenseArticle $article */
|
||||||
|
$article = $this->getRecord();
|
||||||
|
$markers = app(ShopMarkers::class);
|
||||||
|
$offerIds = array_map(fn (Offer $offer): int => (int) $offer->id, app(ProductOptions::class)->offersOfArticle($article));
|
||||||
|
|
||||||
|
return [
|
||||||
|
'sichtbar' => array_column($markers->visible($article, $offerIds), 'label'),
|
||||||
|
'einstellung' => $markers->settings($article),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marker für die Kachel im Shop: „Neu“ und „Aktualisiert“ folgen automatisch den Daten und lassen sich fest an- oder
|
||||||
|
* abschalten, „Beliebt“ setzt die Redaktion von Hand. Die Aktion speichert nur die Marker, sonst nichts (nicht die
|
||||||
|
* Redaktion des Artikels).
|
||||||
|
*/
|
||||||
|
public function markersAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('markers')
|
||||||
|
->modalWidth('lg')
|
||||||
|
->modalHeading('Marker für die Kachel im Shop')
|
||||||
|
->modalDescription('Marker erscheinen mit ihrem Wort auf der Kachel des Artikels. „Neu“ und „Aktualisiert“ richten sich automatisch nach den Daten; hier kannst du sie fest an- oder abschalten. „Beliebt“ setzt du von Hand, bis es Verkaufszahlen gibt.')
|
||||||
|
->modalSubmitActionLabel('Marker speichern')
|
||||||
|
->fillForm(fn (): array => $this->markerRows()['einstellung'])
|
||||||
|
->schema(collect(ShopMarkers::CHOICES)->map(fn (array $choices, string $key): Select => Select::make($key)
|
||||||
|
->label(ShopMarkers::KEYS[$key])
|
||||||
|
->options($choices)
|
||||||
|
->required()
|
||||||
|
->native(false))->values()->all())
|
||||||
|
->action(function (array $data): void {
|
||||||
|
$this->report(function () use ($data): string {
|
||||||
|
/** @var LicenseArticle $article */
|
||||||
|
$article = $this->getRecord();
|
||||||
|
app(ShopMarkers::class)->save($article, $data);
|
||||||
|
|
||||||
|
return 'Die Marker sind gespeichert.';
|
||||||
|
}, 'Die Marker sind gespeichert.');
|
||||||
|
$this->refreshRecord();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Eine Option aus dem Verkauf nehmen: nur die aktive Fassung dieser Option wird beendet. */
|
||||||
|
public function optionEndAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('optionEnd')
|
||||||
|
->color('danger')
|
||||||
|
->requiresConfirmation()
|
||||||
|
->modalHeading(fn (array $arguments): string => 'Option „'.$this->optionOf($arguments)->optionName().'“ aus dem Verkauf nehmen?')
|
||||||
|
->modalDescription('Die aktive Fassung wird beendet und bleibt gespeichert. Die Option ist danach nicht mehr kaufbar; in vorhandenen Warenkörben bleibt sie mit Hinweis sichtbar und blockiert den Abschluss, bis der Käufer sie entfernt. Bestehende Berechtigungen und Bestellungen ändern sich nicht. Andere Optionen des Artikels bleiben kaufbar.')
|
||||||
|
->modalSubmitActionLabel('Aus dem Verkauf nehmen')
|
||||||
|
->action(function (array $arguments): void {
|
||||||
|
$this->report(function () use ($arguments): string {
|
||||||
|
$offer = $this->optionOf($arguments);
|
||||||
|
$version = app(OfferService::class)->end($offer);
|
||||||
|
|
||||||
|
return 'Die Option „'.$offer->optionName().'“ ist aus dem Verkauf genommen (Fassung '.$version->number.' beendet).';
|
||||||
|
}, 'Die Option ist aus dem Verkauf genommen.');
|
||||||
|
$this->refreshRecord();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Option aus den Argumenten der Aktion, nur wenn sie zu diesem Artikel gehört.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $arguments
|
||||||
|
*/
|
||||||
|
private function optionOf(array $arguments): Offer
|
||||||
|
{
|
||||||
|
/** @var LicenseArticle $article */
|
||||||
|
$article = $this->getRecord();
|
||||||
|
$offer = collect(app(ProductOptions::class)->offersOfArticle($article))->first(fn (Offer $offer): bool => $offer->id === (int) ($arguments['offer'] ?? 0)
|
||||||
|
&& $offer->versions()->orderByDesc('number')->value('grant_kind') === 'kauf');
|
||||||
|
|
||||||
|
// Vergaben auf Abruf oder bei Registrierung sind keine Shop-Optionen und werden am Angebot bearbeitet.
|
||||||
|
return $offer ?? abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $arguments
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function optionForm(array $arguments): array
|
||||||
|
{
|
||||||
|
if (! isset($arguments['offer'])) {
|
||||||
|
$rights = array_keys(CatalogOptions::rights());
|
||||||
|
|
||||||
|
return [
|
||||||
|
'holder_kind' => 'person',
|
||||||
|
'licence_scope' => LicenceScope::SINGLE,
|
||||||
|
'rights_id' => count($rights) === 1 ? $rights[0] : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$offer = $this->optionOf($arguments);
|
||||||
|
$version = $offer->versions()->with('lines')->orderByDesc('number')->firstOrFail();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'rights_id' => $version->lines->first()?->rights_profile_version_id,
|
||||||
|
'price_euro' => $version->price_cents === null ? null : number_format($version->price_cents / 100, 2, ',', ''),
|
||||||
|
'holder_kind' => $version->holder_kind,
|
||||||
|
'licence_scope' => $version->licence_scope,
|
||||||
|
'trainer_count' => $version->trainer_count,
|
||||||
|
'option_label' => $offer->option_label,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
private function isFirstStand(): bool
|
private function isFirstStand(): bool
|
||||||
{
|
{
|
||||||
return ! $this->getRecord()->releases()->exists();
|
return ! $this->getRecord()->releases()->exists();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class ListOffers extends ListRecords
|
|||||||
|
|
||||||
public function getSubheading(): string|Htmlable|null
|
public function getSubheading(): string|Htmlable|null
|
||||||
{
|
{
|
||||||
return 'Ein Angebot verbindet Artikel oder eine Paketfassung mit einem Rechteprofil. Die aufgelösten Berechtigungen stehen auf der Angebotsseite.';
|
return 'Ein Angebot ist eine Option zum Kauf: ein Artikel oder eine Paketfassung mit Rechteprofil und Preis. Optionen eines einzelnen Artikels legst du am Lizenzartikel an („Im Shop verkaufen“); hier stehen alle Angebote, auch die der Pakete.';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
|
|||||||
@@ -2,22 +2,23 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Offers\Pages;
|
namespace App\Filament\Resources\Offers\Pages;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Bundle;
|
||||||
use App\Domain\Catalog\BundleService;
|
use App\Domain\Catalog\BundleService;
|
||||||
use App\Domain\Catalog\BundleVersion;
|
use App\Domain\Catalog\BundleVersion;
|
||||||
use App\Domain\Catalog\Composition;
|
use App\Domain\Catalog\Composition;
|
||||||
use App\Domain\Catalog\CompositionVersion;
|
|
||||||
use App\Domain\Catalog\DomainRuleException;
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
use App\Domain\Catalog\LicenceScope;
|
use App\Domain\Catalog\LicenceScope;
|
||||||
use App\Domain\Catalog\LicenseArticle;
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
use App\Domain\Catalog\Offer;
|
use App\Domain\Catalog\Offer;
|
||||||
|
use App\Domain\Catalog\OfferRelease;
|
||||||
use App\Domain\Catalog\OfferService;
|
use App\Domain\Catalog\OfferService;
|
||||||
use App\Domain\Catalog\OfferStatus;
|
use App\Domain\Catalog\OfferStatus;
|
||||||
use App\Domain\Catalog\OfferVersion;
|
use App\Domain\Catalog\OfferVersion;
|
||||||
use App\Domain\Catalog\RightsProfileVersion;
|
use App\Domain\Catalog\RightsProfileVersion;
|
||||||
use App\Domain\Catalog\StatusValue;
|
use App\Domain\Catalog\StatusValue;
|
||||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
|
||||||
use App\Domain\Commerce\Money;
|
use App\Domain\Commerce\Money;
|
||||||
use App\Domain\Commerce\ProductOptions;
|
use App\Domain\Commerce\ProductOptions;
|
||||||
|
use App\Domain\Entitlement\OfferAccess;
|
||||||
use App\Filament\Pages\Zahlungsjournal;
|
use App\Filament\Pages\Zahlungsjournal;
|
||||||
use App\Filament\Resources\Offers\OfferResource;
|
use App\Filament\Resources\Offers\OfferResource;
|
||||||
use App\Filament\Support\CatalogLabels;
|
use App\Filament\Support\CatalogLabels;
|
||||||
@@ -25,9 +26,12 @@
|
|||||||
use App\Filament\Support\PublicationReadiness;
|
use App\Filament\Support\PublicationReadiness;
|
||||||
use App\Filament\Support\ReportsDomainRules;
|
use App\Filament\Support\ReportsDomainRules;
|
||||||
use App\Filament\Support\ShopAccess;
|
use App\Filament\Support\ShopAccess;
|
||||||
|
use App\Models\User;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Forms\Components\DatePicker;
|
||||||
use Filament\Forms\Components\Repeater;
|
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\Forms\Components\TextInput;
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
use Filament\Schemas\Components\Utilities\Get;
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
@@ -35,6 +39,7 @@
|
|||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Support\Enums\Width;
|
use Filament\Support\Enums\Width;
|
||||||
use Illuminate\Contracts\Support\Htmlable;
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -48,9 +53,6 @@ class ViewOffer extends ViewRecord
|
|||||||
|
|
||||||
protected static string $resource = OfferResource::class;
|
protected static string $resource = OfferResource::class;
|
||||||
|
|
||||||
/** Wert der Auswahl „Produktseite“ für ein Paket mit eigener Seite. */
|
|
||||||
private const OWN_BUNDLE_PAGE = '__paket';
|
|
||||||
|
|
||||||
public function getTitle(): string|Htmlable
|
public function getTitle(): string|Htmlable
|
||||||
{
|
{
|
||||||
return (string) $this->getRecord()->name;
|
return (string) $this->getRecord()->name;
|
||||||
@@ -117,10 +119,6 @@ public function activateAction(): Action
|
|||||||
TextInput::make('option_label')->label('Bezeichnung der Option')
|
TextInput::make('option_label')->label('Bezeichnung der Option')
|
||||||
->helperText('So heißt die Option auf der Produktseite, zum Beispiel „Einzellizenz für Privatpersonen“. Sie ist keine bindende Bedingung, wird aber wie die übrigen Angaben erst mit „Fassung aktivieren“ übernommen.')
|
->helperText('So heißt die Option auf der Produktseite, zum Beispiel „Einzellizenz für Privatpersonen“. Sie ist keine bindende Bedingung, wird aber wie die übrigen Angaben erst mit „Fassung aktivieren“ übernommen.')
|
||||||
->maxLength(120),
|
->maxLength(120),
|
||||||
Select::make('composition_id')->label('Produktseite')
|
|
||||||
->options(fn (): array => $this->productPages())
|
|
||||||
->searchable()
|
|
||||||
->helperText('Optionen derselben Produktseite sind Alternativen; im Warenkorb liegt nur eine davon. Die Beschreibung der Seite wird zentral an der Komposition gepflegt. Die Zuordnung wird mit „Fassung aktivieren“ übernommen.'),
|
|
||||||
Select::make('holder_kind')->label('Geeignet für')->options([
|
Select::make('holder_kind')->label('Geeignet für')->options([
|
||||||
'person' => 'Privatpersonen',
|
'person' => 'Privatpersonen',
|
||||||
'organisation' => 'Organisationen und Vereine',
|
'organisation' => 'Organisationen und Vereine',
|
||||||
@@ -143,18 +141,6 @@ public function activateAction(): Action
|
|||||||
])->required(),
|
])->required(),
|
||||||
TextInput::make('price_euro')->label('Preis in Euro')->suffix('€')
|
TextInput::make('price_euro')->label('Preis in Euro')->suffix('€')
|
||||||
->helperText('Nur bei einem Kauf, zum Beispiel 49,00.'),
|
->helperText('Nur bei einem Kauf, zum Beispiel 49,00.'),
|
||||||
Select::make('composition_version_id')->label('Programmfassung, die abgedeckt sein muss')
|
|
||||||
->options(function (): array {
|
|
||||||
return CompositionVersion::query()
|
|
||||||
->where('status', 'bereit')
|
|
||||||
->with('composition.editorialContentKind')
|
|
||||||
->orderByDesc('id')
|
|
||||||
->get()
|
|
||||||
->mapWithKeys(fn (CompositionVersion $version): array => [$version->id => CatalogOptions::compositionLabel($version)])
|
|
||||||
->all();
|
|
||||||
})
|
|
||||||
->searchable()
|
|
||||||
->helperText('Wenn gewählt, lässt sich die Fassung nur aktivieren, wenn jeder Bestandteil in den Artikeln enthalten ist.'),
|
|
||||||
Repeater::make('lines')->label('Positionen')->schema([
|
Repeater::make('lines')->label('Positionen')->schema([
|
||||||
Select::make('kind')->label('Ziel')->options([
|
Select::make('kind')->label('Ziel')->options([
|
||||||
'article' => 'Lizenzartikel',
|
'article' => 'Lizenzartikel',
|
||||||
@@ -215,12 +201,7 @@ public function activateAction(): Action
|
|||||||
|
|
||||||
$service = app(OfferService::class);
|
$service = app(OfferService::class);
|
||||||
$version = DB::transaction(function () use ($service, $offer, $data, $lines, $kept, $price) {
|
$version = DB::transaction(function () use ($service, $offer, $data, $lines, $kept, $price) {
|
||||||
$service->assignProduct(
|
$service->setOptionLabel($offer, $data['option_label'] ?? null);
|
||||||
$offer,
|
|
||||||
filled($data['composition_id'] ?? null) && $data['composition_id'] !== self::OWN_BUNDLE_PAGE ? (int) $data['composition_id'] : null,
|
|
||||||
$data['option_label'] ?? null,
|
|
||||||
($data['composition_id'] ?? null) === self::OWN_BUNDLE_PAGE,
|
|
||||||
);
|
|
||||||
|
|
||||||
return $service->activate($offer, $lines, [
|
return $service->activate($offer, $lines, [
|
||||||
...$kept,
|
...$kept,
|
||||||
@@ -229,7 +210,6 @@ public function activateAction(): Action
|
|||||||
'trainer_count' => $data['trainer_count'] ?? null,
|
'trainer_count' => $data['trainer_count'] ?? null,
|
||||||
'grant_kind' => $data['grant_kind'],
|
'grant_kind' => $data['grant_kind'],
|
||||||
'price_cents' => $price,
|
'price_cents' => $price,
|
||||||
'composition_version_id' => filled($data['composition_version_id'] ?? null) ? (int) $data['composition_version_id'] : null,
|
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -269,37 +249,194 @@ public function endAction(): Action
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** „ der Produktseite „Titel““ oder leer, wenn die Option noch keiner Produktseite zugeordnet ist. */
|
/** Ein Angebot auf Abruf: nur dafür gibt es Regeln, wer es übernehmen darf (ADR-56). */
|
||||||
private function productPageSuffix(): string
|
private function isOnDemand(): bool
|
||||||
{
|
{
|
||||||
$page = $this->getRecord()->composition;
|
return $this->activeVersion()?->grant_kind === 'auf_abruf';
|
||||||
|
}
|
||||||
return $page === null ? '' : ' der Produktseite „'.($page->display_title ?: $page->designation).'“';
|
|
||||||
|
/**
|
||||||
|
* Wer das Angebot übernehmen darf: alle Mitglieder, nur freigeschaltete Konten oder wer einen Artikel besitzt.
|
||||||
|
*/
|
||||||
|
public function claimRuleAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('claimRule')
|
||||||
|
->label('Regel für den Abruf')
|
||||||
|
->modalHeading(fn (): string => 'Wer darf „'.$this->getRecord()->name.'“ abrufen?')
|
||||||
|
->modalDescription('Die Regel gilt für den kostenlosen Abruf in die Bibliothek und wird beim Abruf geprüft. Sie begrenzt nur den Abruf; sie vergibt nichts. Bereits übernommene Angebote bleiben in der Bibliothek.')
|
||||||
|
->modalSubmitActionLabel('Regel speichern')
|
||||||
|
->visible(fn (): bool => $this->isOnDemand())
|
||||||
|
->fillForm(fn (): array => [
|
||||||
|
'claim_access' => (string) ($this->getRecord()->claim_access ?: OfferAccess::ALL),
|
||||||
|
'claim_requires_article_id' => $this->getRecord()->claim_requires_article_id,
|
||||||
|
])
|
||||||
|
->schema([
|
||||||
|
Select::make('claim_access')->label('Wer darf abrufen')
|
||||||
|
->options(OfferAccess::OPTIONS)
|
||||||
|
->required()->live()->native(false)
|
||||||
|
->helperText('„Nur freigeschaltete Konten“: Du schaltest einzelne Konten auf dieser Seite frei und entziehst die Freigabe wieder. Sie gilt nur für dieses Angebot.'),
|
||||||
|
Select::make('claim_requires_article_id')->label('Artikel, den das Konto besitzen muss')
|
||||||
|
->options(fn (): array => LicenseArticle::query()->whereNull('archived_at')->orderBy('code')->get()
|
||||||
|
->mapWithKeys(fn (LicenseArticle $article): array => [$article->id => app(ProductOptions::class)->articleTitle($article)])->all())
|
||||||
|
->searchable()
|
||||||
|
->required(fn (Get $get): bool => $get('claim_access') === OfferAccess::OWNERS)
|
||||||
|
->visible(fn (Get $get): bool => $get('claim_access') === OfferAccess::OWNERS)
|
||||||
|
->helperText('Das Konto muss eine gültige Berechtigung auf diesen Artikel haben, zum Beispiel durch einen Kauf.'),
|
||||||
|
])
|
||||||
|
->action(function (array $data): void {
|
||||||
|
$this->report(function () use ($data): string {
|
||||||
|
app(OfferAccess::class)->setRule($this->getRecord(), (string) $data['claim_access'], filled($data['claim_requires_article_id'] ?? null) ? (int) $data['claim_requires_article_id'] : null);
|
||||||
|
|
||||||
|
return 'Die Regel für den Abruf ist gespeichert.';
|
||||||
|
}, 'Die Regel ist gespeichert.');
|
||||||
|
$this->getRecord()->unsetRelations();
|
||||||
|
$this->getRecord()->refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function releaseAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('release')
|
||||||
|
->label('Konto freischalten')
|
||||||
|
->modalHeading(fn (): string => 'Konto für „'.$this->getRecord()->name.'“ freischalten')
|
||||||
|
->modalDescription('Das Konto darf genau dieses Angebot abrufen, solange Freigabe und Angebot gelten. Die Freigabe gilt nicht für andere Angebote und bleibt mit dem Entzug im Verlauf stehen.')
|
||||||
|
->modalSubmitActionLabel('Konto freischalten')
|
||||||
|
->visible(fn (): bool => $this->isOnDemand() && $this->getRecord()->claim_access === OfferAccess::RELEASED)
|
||||||
|
->schema([
|
||||||
|
Select::make('user_id')->label('Mitgliedskonto')->required()->searchable()
|
||||||
|
->getSearchResultsUsing(fn (string $search): array => $this->searchMembers($search))
|
||||||
|
->getOptionLabelUsing(fn ($value): ?string => ($user = User::query()->find($value)) === null ? null : $user->name.' ('.$user->email.')')
|
||||||
|
->helperText('Suche nach Name oder E-Mail-Adresse. Nur Konten mit Mitgliedsprofil.'),
|
||||||
|
DatePicker::make('valid_until')->label('Freigabe gültig bis einschließlich')->native(false)->displayFormat('d.m.Y')
|
||||||
|
->helperText('Leer: ohne Ende.'),
|
||||||
|
Textarea::make('reason')->label('Grundlage der Freigabe')->rows(2)->maxLength(500)
|
||||||
|
->helperText('Zum Beispiel „Teilnahme am Seminar am 12.11.2026“. Bleibt im Verlauf stehen.'),
|
||||||
|
])
|
||||||
|
->action(function (array $data): void {
|
||||||
|
$this->report(function () use ($data): string {
|
||||||
|
$member = User::query()->findOrFail($data['user_id']);
|
||||||
|
$until = filled($data['valid_until'] ?? null) ? Carbon::parse((string) $data['valid_until'], config('app.timezone'))->endOfDay() : null;
|
||||||
|
app(OfferAccess::class)->release($this->getRecord(), $member, auth('staff')->user() ?? auth()->user(), $until, $data['reason'] ?? null);
|
||||||
|
|
||||||
|
return 'Das Konto von '.$member->name.' ist für das Angebot freigeschaltet.';
|
||||||
|
}, 'Das Konto ist freigeschaltet.');
|
||||||
|
$this->getRecord()->unsetRelations();
|
||||||
|
$this->getRecord()->refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function revokeAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('revoke')
|
||||||
|
->label('Freigabe entziehen')
|
||||||
|
->color('danger')
|
||||||
|
->requiresConfirmation()
|
||||||
|
->modalHeading('Freigabe entziehen?')
|
||||||
|
->modalDescription('Das Konto kann das Angebot danach nicht mehr abrufen. Bereits übernommene Angebote bleiben in der Bibliothek. Die Freigabe bleibt mit dem Entzug im Verlauf stehen.')
|
||||||
|
->modalSubmitActionLabel('Freigabe entziehen')
|
||||||
|
->schema([
|
||||||
|
Textarea::make('reason')->label('Grund')->rows(2)->maxLength(500),
|
||||||
|
])
|
||||||
|
->action(function (array $data, array $arguments): void {
|
||||||
|
$this->report(function () use ($data, $arguments): string {
|
||||||
|
$release = OfferRelease::query()->where('offer_id', $this->getRecord()->id)->findOrFail((int) ($arguments['release'] ?? 0));
|
||||||
|
app(OfferAccess::class)->revoke($release, auth('staff')->user() ?? auth()->user(), $data['reason'] ?? null);
|
||||||
|
|
||||||
|
return 'Die Freigabe ist entzogen.';
|
||||||
|
}, 'Die Freigabe ist entzogen.');
|
||||||
|
$this->getRecord()->unsetRelations();
|
||||||
|
$this->getRecord()->refresh();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Produktseiten, die als Ziel wählbar sind: Kompositionen mit Bezeichnung und Art.
|
|
||||||
*
|
|
||||||
* @return array<int, string>
|
* @return array<int, string>
|
||||||
*/
|
*/
|
||||||
private function productPages(): array
|
private function searchMembers(string $search): array
|
||||||
{
|
{
|
||||||
$catalog = app(PublicCatalogReader::class);
|
$like = '%'.mb_strtolower(trim($search)).'%';
|
||||||
|
|
||||||
return [self::OWN_BUNDLE_PAGE => 'Eigene Paketseite · zeigt den Umfang des Pakets (nur für ein Angebot aus genau einer Paketfassung)'] + Composition::query()
|
return User::query()
|
||||||
->with('editorialContentKind')
|
->whereNotNull('party_id')
|
||||||
->whereNull('archived_at')
|
->where(fn ($query) => $query->whereRaw('LOWER(name) LIKE ?', [$like])->orWhereRaw('LOWER(email) LIKE ?', [$like]))
|
||||||
->orderBy('designation')
|
->orderBy('name')
|
||||||
|
->limit(20)
|
||||||
->get()
|
->get()
|
||||||
->sortBy(fn (Composition $composition): int => $catalog->shownVersion($composition) !== null ? 0 : 1)
|
->mapWithKeys(fn (User $user): array => [$user->id => $user->name.' ('.$user->email.')'])
|
||||||
->mapWithKeys(fn (Composition $composition): array => [
|
|
||||||
$composition->id => ($composition->display_title ?: $composition->designation)
|
|
||||||
.' ('.($composition->editorialContentKind?->label ?? 'Zusammenstellung').')'
|
|
||||||
.($catalog->shownVersion($composition) !== null ? ' · im Shop auffindbar' : ' · nicht öffentlich, im Shop nicht auffindbar'),
|
|
||||||
])
|
|
||||||
->all();
|
->all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Abschnitte „Wer darf abrufen“ und „Freigeschaltete Konten“ für ein Angebot auf Abruf.
|
||||||
|
*
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
private function abrufAbschnitte(Offer $offer): array
|
||||||
|
{
|
||||||
|
$date = fn ($value): string => $value?->format('d.m.Y') ?? '';
|
||||||
|
$access = (string) ($offer->claim_access ?: OfferAccess::ALL);
|
||||||
|
$article = $offer->claim_requires_article_id !== null ? LicenseArticle::query()->find($offer->claim_requires_article_id) : null;
|
||||||
|
$releases = $offer->releases()->with(['user', 'grantor'])->orderByDesc('id')->get();
|
||||||
|
$active = $releases->filter(fn (OfferRelease $release): bool => $release->revoked_at === null);
|
||||||
|
$past = $releases->filter(fn (OfferRelease $release): bool => $release->revoked_at !== null);
|
||||||
|
$sections = [[
|
||||||
|
'titel' => 'Wer darf abrufen',
|
||||||
|
'hilfe' => 'Diese Regel gilt für den kostenlosen Abruf in die Bibliothek (Mitgliederbereich → Angebote). Sie wird beim Abruf geprüft, nicht nur in der Anzeige.',
|
||||||
|
'zeilen' => [[
|
||||||
|
'text' => OfferAccess::OPTIONS[$access] ?? $access,
|
||||||
|
'neben' => $access === OfferAccess::OWNERS
|
||||||
|
? 'Erforderlich: '.($article !== null ? app(ProductOptions::class)->articleTitle($article) : 'ein Artikel fehlt (Regel prüfen)')
|
||||||
|
: ($access === OfferAccess::RELEASED ? 'Mit „Konto freischalten“ gibst du einzelne Konten frei.' : 'Jedes angemeldete Mitgliedskonto sieht das Angebot und kann es übernehmen.'),
|
||||||
|
]],
|
||||||
|
]];
|
||||||
|
|
||||||
|
if ($access === OfferAccess::RELEASED) {
|
||||||
|
$sections[] = [
|
||||||
|
'titel' => 'Freigeschaltete Konten',
|
||||||
|
'zusatz' => $active->count().' aktiv',
|
||||||
|
'hilfe' => 'Nur diese Konten sehen das Angebot im Mitgliederbereich und können es übernehmen.',
|
||||||
|
'zeilen' => $active->map(fn (OfferRelease $release): array => [
|
||||||
|
'text' => ($release->user?->name ?? 'Konto').' ('.($release->user?->email ?? '').')',
|
||||||
|
'neben' => 'freigeschaltet am '.$date($release->granted_at).($release->grantor ? ' von '.$release->grantor->name : '').($release->valid_until ? ', gültig bis einschließlich '.$date($release->valid_until) : '').(filled($release->reason) ? ' · '.$release->reason : ''),
|
||||||
|
'aktion' => ['label' => 'Entziehen', 'wire' => "mountAction('revoke', { release: ".$release->id.' })'],
|
||||||
|
])->values()->all(),
|
||||||
|
'leer' => ['titel' => 'Noch kein Konto freigeschaltet', 'text' => 'Mit „Konto freischalten“ gibst du ein Konto für dieses Angebot frei.'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($past->isNotEmpty()) {
|
||||||
|
$sections[] = [
|
||||||
|
'titel' => 'Entzogene Freigaben',
|
||||||
|
'hilfe' => 'Der Verlauf bleibt erhalten.',
|
||||||
|
'zeilen' => $past->map(fn (OfferRelease $release): array => [
|
||||||
|
'text' => $release->user?->name ?? 'Konto',
|
||||||
|
'neben' => 'entzogen am '.$date($release->revoked_at).(filled($release->reason) ? ' · '.$release->reason : ''),
|
||||||
|
])->values()->all(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sections;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** „ der Produktseite „Titel““ oder leer, wenn die Option (noch) keine Produktseite hat. */
|
||||||
|
private function productPageSuffix(): string
|
||||||
|
{
|
||||||
|
$key = app(ProductOptions::class)->groupKey($this->getRecord());
|
||||||
|
|
||||||
|
if ($key === null) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = (int) substr($key, 2);
|
||||||
|
$title = match ($key[0]) {
|
||||||
|
'a' => app(ProductOptions::class)->articleTitle(LicenseArticle::query()->find($id)),
|
||||||
|
'b' => (string) Bundle::query()->whereKey($id)->value('name'),
|
||||||
|
default => ($page = Composition::query()->find($id)) === null ? '' : (string) ($page->display_title ?: $page->designation),
|
||||||
|
};
|
||||||
|
|
||||||
|
return $title === '' ? '' : ' der Produktseite „'.$title.'“';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vorbelegung aus der aktiven Fassung; ohne aktive Fassung eine leere Position.
|
* Vorbelegung aus der aktiven Fassung; ohne aktive Fassung eine leere Position.
|
||||||
*
|
*
|
||||||
@@ -310,7 +447,7 @@ private function formFromActive(): array
|
|||||||
$active = $this->activeVersion();
|
$active = $this->activeVersion();
|
||||||
/** @var Offer $offer */
|
/** @var Offer $offer */
|
||||||
$offer = $this->getRecord();
|
$offer = $this->getRecord();
|
||||||
$option = ['option_label' => $offer->option_label, 'composition_id' => $offer->standalone_bundle ? self::OWN_BUNDLE_PAGE : $offer->composition_id];
|
$option = ['option_label' => $offer->option_label];
|
||||||
|
|
||||||
if ($active === null) {
|
if ($active === null) {
|
||||||
return [...$option, 'holder_kind' => 'person', 'licence_scope' => LicenceScope::SINGLE, 'grant_kind' => 'kauf', 'lines' => [['kind' => 'article']]];
|
return [...$option, 'holder_kind' => 'person', 'licence_scope' => LicenceScope::SINGLE, 'grant_kind' => 'kauf', 'lines' => [['kind' => 'article']]];
|
||||||
@@ -368,6 +505,16 @@ private function angebotDaten(): array
|
|||||||
'wire' => "mountAction('end')",
|
'wire' => "mountAction('end')",
|
||||||
'art' => 'line',
|
'art' => 'line',
|
||||||
]] : []),
|
]] : []),
|
||||||
|
...($this->isOnDemand() ? [[
|
||||||
|
'label' => 'Regel für den Abruf',
|
||||||
|
'wire' => "mountAction('claimRule')",
|
||||||
|
'art' => 'line',
|
||||||
|
]] : []),
|
||||||
|
...($this->isOnDemand() && $offer->claim_access === OfferAccess::RELEASED ? [[
|
||||||
|
'label' => 'Konto freischalten',
|
||||||
|
'wire' => "mountAction('release')",
|
||||||
|
'art' => 'line',
|
||||||
|
]] : []),
|
||||||
...(ShopAccess::allowed() ? [[
|
...(ShopAccess::allowed() ? [[
|
||||||
'label' => 'Zahlungen zu diesem Angebot',
|
'label' => 'Zahlungen zu diesem Angebot',
|
||||||
'href' => Zahlungsjournal::getUrl(['angebot' => $offer->id, 'zeitraum' => 'jahr', 'betrieb' => 'alle']),
|
'href' => Zahlungsjournal::getUrl(['angebot' => $offer->id, 'zeitraum' => 'jahr', 'betrieb' => 'alle']),
|
||||||
@@ -378,6 +525,7 @@ private function angebotDaten(): array
|
|||||||
'voraussetzungen' => app(PublicationReadiness::class)->forOffer($offer),
|
'voraussetzungen' => app(PublicationReadiness::class)->forOffer($offer),
|
||||||
'haupt' => [
|
'haupt' => [
|
||||||
...($active !== null ? [$this->optionAbschnitt($offer, $active)] : []),
|
...($active !== null ? [$this->optionAbschnitt($offer, $active)] : []),
|
||||||
|
...($this->isOnDemand() ? $this->abrufAbschnitte($offer) : []),
|
||||||
[
|
[
|
||||||
'titel' => 'Positionen',
|
'titel' => 'Positionen',
|
||||||
'zusatz' => $active !== null ? 'Fassung '.$active->number : null,
|
'zusatz' => $active !== null ? 'Fassung '.$active->number : null,
|
||||||
@@ -425,8 +573,8 @@ private function optionAbschnitt(Offer $offer, OfferVersion $active): array
|
|||||||
->map(fn (array $item): string => $item['purpose'].($item['rights'] === [] ? '' : ': '.implode(', ', $item['rights'])))
|
->map(fn (array $item): string => $item['purpose'].($item['rights'] === [] ? '' : ': '.implode(', ', $item['rights'])))
|
||||||
->unique()
|
->unique()
|
||||||
->implode('; ');
|
->implode('; ');
|
||||||
$seite = $offer->composition;
|
$key = app(ProductOptions::class)->groupKey($offer);
|
||||||
$eigeneSeite = $offer->standalone_bundle;
|
$seite = $key === null ? null : app(ProductOptions::class)->pageUrl($offer);
|
||||||
$kaufbar = app(OfferService::class)->purchasableVersion($offer) !== null;
|
$kaufbar = app(OfferService::class)->purchasableVersion($offer) !== null;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -440,7 +588,7 @@ private function optionAbschnitt(Offer $offer, OfferVersion $active): array
|
|||||||
['text' => 'Rechte: '.($rechte !== '' ? $rechte : 'keine'), 'neben' => null],
|
['text' => 'Rechte: '.($rechte !== '' ? $rechte : 'keine'), 'neben' => null],
|
||||||
['text' => 'Zugrunde liegender Inhalt: '.($inhalt !== '' ? $inhalt : '–'), 'neben' => null],
|
['text' => 'Zugrunde liegender Inhalt: '.($inhalt !== '' ? $inhalt : '–'), 'neben' => null],
|
||||||
['text' => 'Status: '.($kaufbar ? 'Öffentlich kaufbar' : 'Nicht als Kauf angeboten'), 'neben' => $kaufbar ? 'Aktive Fassung '.$active->number : null],
|
['text' => 'Status: '.($kaufbar ? 'Öffentlich kaufbar' : 'Nicht als Kauf angeboten'), 'neben' => $kaufbar ? 'Aktive Fassung '.$active->number : null],
|
||||||
['text' => 'Produktseite: '.($eigeneSeite ? 'eigene Paketseite mit dem Umfang des Pakets' : ($seite !== null ? ($seite->display_title ?: $seite->designation) : 'noch nicht zugeordnet')), 'neben' => $eigeneSeite || $seite !== null ? 'Option „'.$offer->optionName().'“' : 'Mit „Geänderte Fassung aktivieren“ zuordnen.'],
|
['text' => 'Produktseite: '.($kaufbar && $seite !== null ? 'öffentlich unter '.parse_url($seite, PHP_URL_PATH) : 'keine, solange die Option kein Kauf mit Preis ist'), 'neben' => $kaufbar ? 'Option „'.$offer->optionName().'“; Optionen desselben Artikels sind Alternativen im Warenkorb.' : null],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
use App\Domain\Cms\Page;
|
use App\Domain\Cms\Page;
|
||||||
use App\Domain\Cms\PageService;
|
use App\Domain\Cms\PageService;
|
||||||
use App\Filament\Resources\Pages\PageResource;
|
use App\Filament\Resources\Pages\PageResource;
|
||||||
|
use App\Filament\Support\ChoosesLinkTargets;
|
||||||
use App\Filament\Support\ChoosesWebsiteImages;
|
use App\Filament\Support\ChoosesWebsiteImages;
|
||||||
use App\Filament\Support\ReportsSectionErrors;
|
use App\Filament\Support\ReportsSectionErrors;
|
||||||
use App\Filament\Support\SectionEditor;
|
use App\Filament\Support\SectionEditor;
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
|
|
||||||
class CreatePage extends CreateRecord
|
class CreatePage extends CreateRecord
|
||||||
{
|
{
|
||||||
|
use ChoosesLinkTargets;
|
||||||
use ChoosesWebsiteImages;
|
use ChoosesWebsiteImages;
|
||||||
use ReportsSectionErrors;
|
use ReportsSectionErrors;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
use App\Domain\Cms\Page;
|
use App\Domain\Cms\Page;
|
||||||
use App\Domain\Cms\PageService;
|
use App\Domain\Cms\PageService;
|
||||||
use App\Filament\Resources\Pages\PageResource;
|
use App\Filament\Resources\Pages\PageResource;
|
||||||
|
use App\Filament\Support\ChoosesLinkTargets;
|
||||||
use App\Filament\Support\ChoosesWebsiteImages;
|
use App\Filament\Support\ChoosesWebsiteImages;
|
||||||
use App\Filament\Support\ReportsSectionErrors;
|
use App\Filament\Support\ReportsSectionErrors;
|
||||||
use App\Filament\Support\SectionEditor;
|
use App\Filament\Support\SectionEditor;
|
||||||
@@ -22,6 +23,7 @@
|
|||||||
|
|
||||||
class EditPage extends EditRecord
|
class EditPage extends EditRecord
|
||||||
{
|
{
|
||||||
|
use ChoosesLinkTargets;
|
||||||
use ChoosesWebsiteImages;
|
use ChoosesWebsiteImages;
|
||||||
use ReportsSectionErrors;
|
use ReportsSectionErrors;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,215 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Cms\LinkTargets;
|
||||||
|
use App\Domain\Cms\Page;
|
||||||
|
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auswahl interner Linkziele im CMS über einen Dialog (filament.cms.link-picker): erst die Seite, dann auf Wunsch eine
|
||||||
|
* Sprungmarke. Ein Linkfeld (Widgets\Support\LinkField) öffnet den Dialog mit seinem Formularpfad; „übernehmen“ schreibt die Adresse in
|
||||||
|
* genau dieses Feld, auch im geöffneten Bausteindialog. Gespeichert wird weiterhin nur mit dem Seitenentwurf. Die
|
||||||
|
* Auswahl ändert keine Seite und veröffentlicht nichts.
|
||||||
|
*
|
||||||
|
* Die Sprungmarken der Seite, die gerade bearbeitet wird, stammen aus dem Formular und enthalten damit auch
|
||||||
|
* ungespeicherte Marken.
|
||||||
|
*/
|
||||||
|
trait ChoosesLinkTargets
|
||||||
|
{
|
||||||
|
/** Formularpfad des Linkfelds, in das die Adresse übernommen wird; null = Dialog geschlossen. */
|
||||||
|
public ?string $linkZiel = null;
|
||||||
|
|
||||||
|
public string $linkSuche = '';
|
||||||
|
|
||||||
|
/** Gewählte Seite im zweiten Schritt: „diese“ (Seite im Editor) oder die Kennung einer Seite. */
|
||||||
|
public ?string $linkSeite = null;
|
||||||
|
|
||||||
|
public function openLinkPicker(string $pfad): void
|
||||||
|
{
|
||||||
|
if (preg_match('/^(data|mountedActions\.\d+\.data)(\.[A-Za-z0-9_-]+)+$/', $pfad) !== 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->linkZiel = $pfad;
|
||||||
|
$this->linkSuche = '';
|
||||||
|
$this->linkSeite = null;
|
||||||
|
$this->forceRenderForLinkPicker();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function closeLinkPicker(): void
|
||||||
|
{
|
||||||
|
$this->linkZiel = null;
|
||||||
|
$this->linkSeite = null;
|
||||||
|
$this->linkSuche = '';
|
||||||
|
$this->forceRenderForLinkPicker();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function chooseLinkPage(string $key): void
|
||||||
|
{
|
||||||
|
if ($this->linkZiel === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($key === 'diese' ? ! $this->linkHasOwnPage() : ! Page::query()->whereKey((int) $key)->exists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->linkSeite = $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function backToLinkPages(): void
|
||||||
|
{
|
||||||
|
$this->linkSeite = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ?string $anchor Sprungmarke; leer = Seitenanfang (nur für andere Seiten)
|
||||||
|
*/
|
||||||
|
public function applyLink(?string $anchor = null): void
|
||||||
|
{
|
||||||
|
if ($this->linkZiel === null || $this->linkSeite === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$targets = app(LinkTargets::class);
|
||||||
|
$anchor = filled($anchor) ? $anchor : null;
|
||||||
|
|
||||||
|
if ($this->linkSeite === 'diese') {
|
||||||
|
$known = array_column($targets->anchorsInEditor($this->linkEditorSections()), 'anchor');
|
||||||
|
|
||||||
|
if ($anchor === null || ! in_array($anchor, $known, true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$href = $targets->href(null, $anchor);
|
||||||
|
} else {
|
||||||
|
$page = Page::query()->with(['latestRevision', 'publishedRevision'])->find((int) $this->linkSeite);
|
||||||
|
|
||||||
|
if (! $page instanceof Page) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($anchor !== null && ! in_array($anchor, array_column($targets->anchorsForPage($page), 'anchor'), true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$href = $targets->href($page->path, $anchor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! SafeUrl::isSafe($href)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data_set($this, $this->linkZiel, $href);
|
||||||
|
$this->closeLinkPicker();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Seiten im ersten Schritt (ohne die bearbeitete Seite, die als „Diese Seite“ oben steht).
|
||||||
|
*
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function linkPages(): array
|
||||||
|
{
|
||||||
|
return app(LinkTargets::class)->pages($this->linkSuche, $this->linkOwnPageId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Daten des zweiten Schritts: gewählte Seite, ihre Sprungmarken und die vollständige Adresse.
|
||||||
|
*
|
||||||
|
* @return array{titel: string, pfad: ?string, diese: bool, marken: list<array<string, mixed>>, offen: bool, adresse: ?string}|null
|
||||||
|
*/
|
||||||
|
public function linkChosen(): ?array
|
||||||
|
{
|
||||||
|
if ($this->linkSeite === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$targets = app(LinkTargets::class);
|
||||||
|
|
||||||
|
if ($this->linkSeite === 'diese') {
|
||||||
|
$record = $this->linkOwnPage();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'titel' => 'Diese Seite',
|
||||||
|
'pfad' => $record?->path,
|
||||||
|
'diese' => true,
|
||||||
|
'marken' => $targets->anchorsInEditor($this->linkEditorSections()),
|
||||||
|
'offen' => $record === null,
|
||||||
|
'adresse' => $record?->published_revision_id !== null ? $targets->publicUrl($record) : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = Page::query()->with(['latestRevision', 'publishedRevision'])->find((int) $this->linkSeite);
|
||||||
|
|
||||||
|
if (! $page instanceof Page) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'titel' => $page->latestRevision?->contentTitle() ?: $page->path,
|
||||||
|
'pfad' => $page->path,
|
||||||
|
'diese' => false,
|
||||||
|
'marken' => $targets->anchorsForPage($page),
|
||||||
|
'offen' => false,
|
||||||
|
'adresse' => $page->published_revision_id !== null ? $targets->publicUrl($page) : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Hat die Seite im Editor schon Sprungmarken oder eine Adresse? Neue Seiten dürfen auf ihre eigenen Marken zeigen. */
|
||||||
|
public function linkHasOwnPage(): bool
|
||||||
|
{
|
||||||
|
return property_exists($this, 'data');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function linkOwnPage(): ?Page
|
||||||
|
{
|
||||||
|
$record = property_exists($this, 'record') ? ($this->record ?? null) : null;
|
||||||
|
|
||||||
|
return $record instanceof Page ? $record : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sprungmarken der Seite im Editor (auch ungespeicherte).
|
||||||
|
*
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function linkOwnAnchors(): array
|
||||||
|
{
|
||||||
|
return $this->linkHasOwnPage() ? app(LinkTargets::class)->anchorsInEditor($this->linkEditorSections()) : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function linkOwnPageId(): ?int
|
||||||
|
{
|
||||||
|
return $this->linkOwnPage()?->getKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
private function linkEditorSections(): array
|
||||||
|
{
|
||||||
|
$state = is_array($this->data['sections'] ?? null) ? $this->data['sections'] : [];
|
||||||
|
|
||||||
|
return SectionEditor::fromEditorState($state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filament rendert bei offenen Aktionsdialogen nur den Dialogteil neu; der Auswahldialog liegt darüber und braucht
|
||||||
|
* die ganze Seite.
|
||||||
|
*/
|
||||||
|
public function hydrateChoosesLinkTargets(): void
|
||||||
|
{
|
||||||
|
if ($this->linkZiel !== null) {
|
||||||
|
$this->forceRenderForLinkPicker();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function forceRenderForLinkPicker(): void
|
||||||
|
{
|
||||||
|
if (method_exists($this, 'forceRender')) {
|
||||||
|
$this->forceRender();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
use App\Domain\Catalog\EditorialVocabulary;
|
use App\Domain\Catalog\EditorialVocabulary;
|
||||||
use App\Domain\Catalog\Pillar;
|
use App\Domain\Catalog\Pillar;
|
||||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
|
use App\Domain\Cms\Widgets\Support\HeroVideo;
|
||||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
use App\Http\Controllers\ContentPreviewController;
|
use App\Http\Controllers\ContentPreviewController;
|
||||||
|
|
||||||
@@ -127,6 +128,18 @@ public function pickerResult(): array
|
|||||||
$result = app(EditorialCatalog::class)->presentationBrowse($this->pickerQuery, $this->pickerKind);
|
$result = app(EditorialCatalog::class)->presentationBrowse($this->pickerQuery, $this->pickerKind);
|
||||||
$result = $this->filterByMaterialart($result);
|
$result = $this->filterByMaterialart($result);
|
||||||
|
|
||||||
|
// CMS: nur Filme, die als Video wählbar sind (nicht archiviert, nicht gesperrt, keine Traineranleitung).
|
||||||
|
if ($this->pickerPurpose === 'website-video') {
|
||||||
|
$ids = array_values(array_filter(array_map(fn (array $item): int => (int) ($item['element_id'] ?? 0), $result['items'])));
|
||||||
|
$elements = ContentElement::query()->with('editorialContentKind')->whereKey($ids)->get()->keyBy('id');
|
||||||
|
$videos = app(HeroVideo::class);
|
||||||
|
$result['items'] = array_values(array_filter($result['items'], function (array $item) use ($elements, $videos): bool {
|
||||||
|
$element = $elements->get((int) ($item['element_id'] ?? 0));
|
||||||
|
|
||||||
|
return $element !== null && $videos->isSelectable($element);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
// CMS: nur Bilder, die als Website-Bild wählbar sind (keine vertraulichen Arten, nicht archiviert).
|
// CMS: nur Bilder, die als Website-Bild wählbar sind (keine vertraulichen Arten, nicht archiviert).
|
||||||
if ($this->pickerPurpose === 'website-bild') {
|
if ($this->pickerPurpose === 'website-bild') {
|
||||||
$ids = array_values(array_filter(array_map(fn (array $item): int => (int) ($item['element_id'] ?? 0), $result['items'])));
|
$ids = array_values(array_filter(array_map(fn (array $item): int => (int) ($item['element_id'] ?? 0), $result['items'])));
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
use App\Domain\Catalog\Composition;
|
use App\Domain\Catalog\Composition;
|
||||||
use App\Domain\Catalog\ContentElement;
|
use App\Domain\Catalog\ContentElement;
|
||||||
use App\Domain\Catalog\DomainRuleException;
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Cms\Widgets\Support\HeroVideo;
|
||||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
use App\Domain\Media\CompositionStill;
|
use App\Domain\Media\CompositionStill;
|
||||||
use App\Domain\Media\FilmStill;
|
use App\Domain\Media\FilmStill;
|
||||||
@@ -37,6 +38,22 @@ public function openWebsiteImagePicker(string $pfad): void
|
|||||||
$this->forceRenderForPicker();
|
$this->forceRenderForPicker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bild und Text: ein Film aus dem Medienmanager als Video wählen. Gleicher Wähler wie beim Bild, nur mit Filmen; das
|
||||||
|
* Ziel ist ausschließlich ein Videofeld (…video). Die Auswahl gibt nichts frei.
|
||||||
|
*/
|
||||||
|
public function openWebsiteVideoPicker(string $pfad): void
|
||||||
|
{
|
||||||
|
if (preg_match('/^(data|mountedActions\.\d+\.data)(\.[A-Za-z0-9_-]+)+\.video$/', $pfad) !== 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->resetPicker('website-video');
|
||||||
|
$this->pickerKind = 'film';
|
||||||
|
$this->bildZiel = $pfad;
|
||||||
|
$this->forceRenderForPicker();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Medien- und Materialkarte: das Vorschaubild des Films als Bild für die Website übernehmen. Es entsteht ein Bild
|
* Medien- und Materialkarte: das Vorschaubild des Films als Bild für die Website übernehmen. Es entsteht ein Bild
|
||||||
* im Medienmanager (einmal gespeichert), das im Bildfeld ausgewählt wird. Die Datei des Films bleibt geschützt.
|
* im Medienmanager (einmal gespeichert), das im Bildfeld ausgewählt wird. Die Datei des Films bleibt geschützt.
|
||||||
@@ -197,8 +214,10 @@ public function confirmPicker(): void
|
|||||||
$row = app(EditorialCatalog::class)->rowForTarget((string) $target, 0, allowDraft: true);
|
$row = app(EditorialCatalog::class)->rowForTarget((string) $target, 0, allowDraft: true);
|
||||||
$element = isset($row['element_id']) ? ContentElement::query()->find((int) $row['element_id']) : null;
|
$element = isset($row['element_id']) ? ContentElement::query()->find((int) $row['element_id']) : null;
|
||||||
|
|
||||||
if (! $element instanceof ContentElement || ! WebsiteImage::isSelectable($element)) {
|
$video = $this->pickerPurpose === 'website-video';
|
||||||
Notification::make()->danger()->title('Dieses Medium kann nicht als Website-Bild gewählt werden.')->send();
|
|
||||||
|
if ($video ? ! ($element instanceof ContentElement && app(HeroVideo::class)->isSelectable($element)) : ! ($element instanceof ContentElement && WebsiteImage::isSelectable($element))) {
|
||||||
|
Notification::make()->danger()->title($video ? 'Dieser Film kann nicht als Video gewählt werden.' : 'Dieses Medium kann nicht als Website-Bild gewählt werden.')->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -212,17 +231,17 @@ public function confirmPicker(): void
|
|||||||
*/
|
*/
|
||||||
public function pickerKinds(): array
|
public function pickerKinds(): array
|
||||||
{
|
{
|
||||||
return ['bild' => 'Bilder'];
|
return $this->pickerPurpose === 'website-video' ? ['film' => 'Filme'] : ['bild' => 'Bilder'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pickerTitle(): string
|
public function pickerTitle(): string
|
||||||
{
|
{
|
||||||
return 'Bild aus dem Medienmanager';
|
return $this->pickerPurpose === 'website-video' ? 'Video aus dem Medienmanager' : 'Bild aus dem Medienmanager';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function pickerConfirmLabel(): string
|
public function pickerConfirmLabel(): string
|
||||||
{
|
{
|
||||||
return 'Bild übernehmen';
|
return $this->pickerPurpose === 'website-video' ? 'Video übernehmen' : 'Bild übernehmen';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\FormattedText;
|
||||||
|
use App\Filament\Support\TipTap\FontSizeExtension;
|
||||||
|
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\Support\Enums\Width;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schriftgröße für die Texte der Website: ein Werkzeug „Schriftgröße“ mit festen Stufen (kein freies Maß), dazu das
|
||||||
|
* PHP-Modell und die JS-Erweiterung der Auszeichnung. Nur über {@see RichField::make()} mit `website: true`.
|
||||||
|
*/
|
||||||
|
final class FontSizePlugin implements RichContentPlugin
|
||||||
|
{
|
||||||
|
private const SCRIPT = 'js/rich-font-size.js';
|
||||||
|
|
||||||
|
public function getTipTapPhpExtensions(): array
|
||||||
|
{
|
||||||
|
return [new FontSizeExtension];
|
||||||
|
}
|
||||||
|
|
||||||
|
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('fontSize')
|
||||||
|
->label('Schriftgröße')
|
||||||
|
->action(arguments: '{ size: $getEditor().getAttributes(\'fontSize\')[\'data-size\'] ?? null }')
|
||||||
|
->toggle()
|
||||||
|
->icon('fi-o-lead'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEditorActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Action::make('fontSize')
|
||||||
|
->label('Schriftgröße')
|
||||||
|
->modalHeading('Schriftgröße')
|
||||||
|
->modalWidth(Width::Large)
|
||||||
|
->fillForm(fn (array $arguments): array => ['size' => array_key_exists((string) ($arguments['size'] ?? ''), FormattedText::SITE_SIZES) ? $arguments['size'] : 'normal'])
|
||||||
|
->schema([
|
||||||
|
Select::make('size')
|
||||||
|
->label('Größe')
|
||||||
|
->options(['normal' => 'Normal', ...FormattedText::SITE_SIZES])
|
||||||
|
->native(false)
|
||||||
|
->required()
|
||||||
|
->helperText('Gilt für den markierten Text. „Normal“ nimmt die Auszeichnung zurück.'),
|
||||||
|
])
|
||||||
|
->action(function (array $arguments, array $data, RichEditor $component): void {
|
||||||
|
$collapsed = ($arguments['editorSelection']['head'] ?? null) === ($arguments['editorSelection']['anchor'] ?? null);
|
||||||
|
$size = (string) ($data['size'] ?? 'normal');
|
||||||
|
$extend = $collapsed ? [EditorCommand::make('extendMarkRange', arguments: ['fontSize'])] : [];
|
||||||
|
|
||||||
|
$component->runCommands(
|
||||||
|
array_key_exists($size, FormattedText::SITE_SIZES)
|
||||||
|
? [...$extend, EditorCommand::make('setFontSize', arguments: [['size' => $size]])]
|
||||||
|
: [...$extend, EditorCommand::make('unsetFontSize')],
|
||||||
|
editorSelection: $arguments['editorSelection'],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Cms\LinkTargets;
|
||||||
|
use App\Domain\Cms\Page;
|
||||||
|
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||||
|
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\Schemas\Components\Utilities\Get;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Werkzeug „Interne Seite oder Sprungmarke verlinken“ für die Texte der Website: wählt eine Seite der Website und auf
|
||||||
|
* Wunsch eine Sprungmarke und setzt daraus den Link am markierten Text. Es ergänzt das Werkzeug „Link“ (freie Adresse),
|
||||||
|
* ersetzt es nicht. Gleiche Ziele wie der Linkdialog der Felder ({@see ChoosesLinkTargets}); gespeichert wird nur mit dem
|
||||||
|
* Seitenentwurf, veröffentlicht wird nichts.
|
||||||
|
*/
|
||||||
|
final class InternalLinkPlugin implements RichContentPlugin
|
||||||
|
{
|
||||||
|
public function getTipTapPhpExtensions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTipTapJsExtensions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEditorTools(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
RichEditorTool::make('interneSeite')
|
||||||
|
->label('Interne Seite oder Sprungmarke verlinken')
|
||||||
|
->icon(Heroicon::DocumentText)
|
||||||
|
->action(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEditorActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Action::make('interneSeite')
|
||||||
|
->label('Interne Seite oder Sprungmarke verlinken')
|
||||||
|
->modalHeading('Interne Seite oder Sprungmarke verlinken')
|
||||||
|
->modalDescription('Der markierte Text wird zum Link auf eine Seite dieser Website oder auf eine Sprungmarke. Eine freie Adresse setzt das Werkzeug „Link“.')
|
||||||
|
->modalWidth(Width::Large)
|
||||||
|
->modalSubmitActionLabel('Link setzen')
|
||||||
|
->schema([
|
||||||
|
Select::make('seite')
|
||||||
|
->label('Seite')
|
||||||
|
->options(fn ($livewire): array => self::pageOptions($livewire))
|
||||||
|
->searchable()
|
||||||
|
->required()
|
||||||
|
->live()
|
||||||
|
->afterStateUpdated(fn (callable $set) => $set('marke', null)),
|
||||||
|
Select::make('marke')
|
||||||
|
->label('Sprungmarke')
|
||||||
|
->placeholder('Seitenanfang (ohne Sprungmarke)')
|
||||||
|
->options(fn (Get $get, $livewire): array => self::anchorOptions($get('seite'), $livewire))
|
||||||
|
->required(fn (Get $get): bool => $get('seite') === 'diese')
|
||||||
|
->visible(fn (Get $get): bool => filled($get('seite')))
|
||||||
|
->helperText('Ausgeblendete Abschnitte sind gekennzeichnet; ein Link auf sie führt ins Leere.'),
|
||||||
|
])
|
||||||
|
->action(function (array $arguments, array $data, RichEditor $component): void {
|
||||||
|
$href = self::href((string) ($data['seite'] ?? ''), $data['marke'] ?? null, $component->getLivewire());
|
||||||
|
|
||||||
|
if ($href === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$collapsed = ($arguments['editorSelection']['head'] ?? null) === ($arguments['editorSelection']['anchor'] ?? null);
|
||||||
|
|
||||||
|
$component->runCommands([
|
||||||
|
...($collapsed ? [EditorCommand::make('extendMarkRange', arguments: ['link'])] : []),
|
||||||
|
EditorCommand::make('setLink', arguments: [['href' => $href, 'target' => null]]),
|
||||||
|
], editorSelection: $arguments['editorSelection']);
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
private static function pageOptions(mixed $livewire): array
|
||||||
|
{
|
||||||
|
$options = [];
|
||||||
|
|
||||||
|
if (self::editsPage($livewire)) {
|
||||||
|
$options['diese'] = 'Diese Seite';
|
||||||
|
}
|
||||||
|
|
||||||
|
$own = is_object($livewire) && method_exists($livewire, 'linkOwnPage') ? $livewire->linkOwnPage() : null;
|
||||||
|
|
||||||
|
foreach (app(LinkTargets::class)->pages('', $own?->getKey()) as $page) {
|
||||||
|
$options[(string) $page['id']] = $page['titel'].' ('.$page['pfad'].')';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
private static function anchorOptions(mixed $seite, mixed $livewire): array
|
||||||
|
{
|
||||||
|
$anchors = self::anchorsOf((string) $seite, $livewire);
|
||||||
|
|
||||||
|
return collect($anchors)->mapWithKeys(fn (array $anchor): array => [
|
||||||
|
$anchor['anchor'] => $anchor['label'].' (#'.$anchor['anchor'].')'.($anchor['hidden'] ? ' – ausgeblendet' : ''),
|
||||||
|
])->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{anchor: string, label: string, hidden: bool}>
|
||||||
|
*/
|
||||||
|
private static function anchorsOf(string $seite, mixed $livewire): array
|
||||||
|
{
|
||||||
|
$targets = app(LinkTargets::class);
|
||||||
|
|
||||||
|
if ($seite === 'diese') {
|
||||||
|
return self::editsPage($livewire) ? $targets->anchorsInEditor(SectionEditor::fromEditorState(is_array($livewire->data['sections'] ?? null) ? $livewire->data['sections'] : [])) : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$page = Page::query()->with(['latestRevision', 'publishedRevision'])->find((int) $seite);
|
||||||
|
|
||||||
|
return $page instanceof Page ? $targets->anchorsForPage($page) : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function editsPage(mixed $livewire): bool
|
||||||
|
{
|
||||||
|
return is_object($livewire) && method_exists($livewire, 'linkOwnAnchors');
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function href(string $seite, mixed $anchor, mixed $livewire): ?string
|
||||||
|
{
|
||||||
|
$targets = app(LinkTargets::class);
|
||||||
|
$anchor = is_string($anchor) && $anchor !== '' ? $anchor : null;
|
||||||
|
|
||||||
|
if ($anchor !== null && ! in_array($anchor, array_column(self::anchorsOf($seite, $livewire), 'anchor'), true)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($seite === 'diese') {
|
||||||
|
$href = self::editsPage($livewire) ? $targets->href(null, $anchor) : null;
|
||||||
|
} else {
|
||||||
|
$page = Page::query()->find((int) $seite);
|
||||||
|
$href = $page instanceof Page ? $targets->href($page->path, $anchor) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SafeUrl::isSafe($href) ? $href : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
use App\Domain\Catalog\OfferVersion;
|
use App\Domain\Catalog\OfferVersion;
|
||||||
use App\Domain\Catalog\ReleaseStatus;
|
use App\Domain\Catalog\ReleaseStatus;
|
||||||
use App\Domain\Catalog\StatusValue;
|
use App\Domain\Catalog\StatusValue;
|
||||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
|
||||||
use App\Domain\Commerce\Money;
|
use App\Domain\Commerce\Money;
|
||||||
use App\Domain\Commerce\ProductOptions;
|
use App\Domain\Commerce\ProductOptions;
|
||||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||||
@@ -35,7 +34,6 @@ class PublicationReadiness
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly BundleService $bundles,
|
private readonly BundleService $bundles,
|
||||||
private readonly OfferService $offers,
|
private readonly OfferService $offers,
|
||||||
private readonly PublicCatalogReader $catalog,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/** Ein Artikel ist verwendbar, wenn sein aktueller Stand veröffentlicht ist. */
|
/** Ein Artikel ist verwendbar, wenn sein aktueller Stand veröffentlicht ist. */
|
||||||
@@ -157,12 +155,14 @@ public function forArticle(LicenseArticle $article): array
|
|||||||
'aktion' => $this->articleName($article) !== '' ? null : ['label' => 'Redaktion bearbeiten', 'wire' => "openRedaktion('texte')"],
|
'aktion' => $this->articleName($article) !== '' ? null : ['label' => 'Redaktion bearbeiten', 'wire' => "openRedaktion('texte')"],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'titel' => 'In einem Paket oder Angebot verwenden',
|
'titel' => 'Im Shop verkaufen',
|
||||||
'text' => $inUse
|
'text' => $inUse
|
||||||
? 'Der Artikel ist in einem Paket oder Angebot enthalten.'
|
? 'Der Artikel ist in einem Paket oder Angebot enthalten.'
|
||||||
: 'Verkauft wird der Artikel erst über ein Angebot, allein oder in einem Paket.',
|
: 'Verkauft wird der Artikel über eine Option mit Rechteprofil und Preis, allein oder in einem Paket.',
|
||||||
'stand' => $inUse ? 'erledigt' : 'offen',
|
'stand' => $inUse ? 'erledigt' : 'offen',
|
||||||
'aktion' => $inUse ? null : ['label' => 'Angebote öffnen', 'href' => OfferResource::getUrl('index')],
|
'aktion' => $inUse ? null : ($usable
|
||||||
|
? ['label' => 'Option hinzufügen', 'wire' => "mountAction('option')"]
|
||||||
|
: ['label' => 'Angebote öffnen', 'href' => OfferResource::getUrl('index')]),
|
||||||
'pflicht' => false,
|
'pflicht' => false,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
@@ -227,10 +227,7 @@ public function forOffer(Offer $offer): array
|
|||||||
$articleIds = $hasActive ? $active->resolvedScopes()->pluck('license_article_id')->map(fn ($id): int => (int) $id)->all() : [];
|
$articleIds = $hasActive ? $active->resolvedScopes()->pluck('license_article_id')->map(fn ($id): int => (int) $id)->all() : [];
|
||||||
$missing = $this->unusableArticles($articleIds);
|
$missing = $this->unusableArticles($articleIds);
|
||||||
$buyable = $hasActive && $this->offers->purchasableVersion($offer) !== null;
|
$buyable = $hasActive && $this->offers->purchasableVersion($offer) !== null;
|
||||||
$page = $offer->composition;
|
$pageUrl = app(ProductOptions::class)->pageUrl($offer);
|
||||||
$own = (bool) $offer->standalone_bundle;
|
|
||||||
$shown = $own || ($page !== null && $this->catalog->shownVersion($page) !== null);
|
|
||||||
$pageName = $page !== null ? (string) ($page->display_title ?: $page->designation) : '';
|
|
||||||
$activate = ['label' => $hasActive ? 'Geänderte Fassung aktivieren' : 'Angebot konfigurieren', 'wire' => "mountAction('activate')"];
|
$activate = ['label' => $hasActive ? 'Geänderte Fassung aktivieren' : 'Angebot konfigurieren', 'wire' => "mountAction('activate')"];
|
||||||
|
|
||||||
return $this->result([
|
return $this->result([
|
||||||
@@ -272,26 +269,15 @@ public function forOffer(Offer $offer): array
|
|||||||
'pflicht' => false,
|
'pflicht' => false,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'titel' => 'Produktseite zuordnen',
|
'titel' => 'Produktseite im Shop',
|
||||||
'text' => $own
|
'text' => match (true) {
|
||||||
? 'Eigene Paketseite: Sie zeigt den Umfang des Pakets. Optionen desselben Pakets sind Alternativen im Warenkorb.'
|
! $hasActive => 'Die Produktseite ergibt sich aus der Fassung: Sie ist die Seite des Artikels (oder des Pakets), den die Option verkauft. Du ordnest sie nicht zu.',
|
||||||
: ($page !== null
|
$pageUrl !== null && $buyable => 'Die Option erscheint auf der Produktseite '.parse_url($pageUrl, PHP_URL_PATH).' und im Shop. Optionen desselben Artikels sind Alternativen im Warenkorb.',
|
||||||
? 'Zugeordnet: „'.$pageName.'“. Optionen derselben Produktseite sind Alternativen im Warenkorb.'
|
$pageUrl !== null => 'Sobald die Option ein Kauf mit Preis ist, erscheint sie auf '.parse_url($pageUrl, PHP_URL_PATH).'.',
|
||||||
: 'Der Shop zeigt ein Angebot auf der Seite eines Programms. Wähle in der Maske die Produktseite. Ein Paket, das für sich verkauft wird, erhält dort „Eigene Paketseite“ und zeigt seinen Umfang; sonst erscheint es auf der Seite eines fremden Programms.'),
|
default => 'Diese Fassung hat mehrere Positionen und damit keine Produktseite. Verkauft wird genau ein Artikel oder ein Paket; mehrere Artikel gemeinsam verkaufst du als Paket.',
|
||||||
'stand' => $own || $page !== null ? 'erledigt' : 'offen',
|
},
|
||||||
'aktion' => $own || $page !== null ? null : $activate,
|
'stand' => $buyable && $pageUrl !== null ? 'erledigt' : 'offen',
|
||||||
],
|
'aktion' => $hasActive && $pageUrl === null ? $activate : null,
|
||||||
[
|
|
||||||
'titel' => 'Produktseite öffentlich',
|
|
||||||
'text' => ! $own && $page === null
|
|
||||||
? 'Wird geprüft, sobald eine Produktseite zugeordnet ist.'
|
|
||||||
: ($own
|
|
||||||
? 'Die eigene Paketseite ist öffentlich, sobald die aktive Fassung ein Kauf mit Preis ist.'
|
|
||||||
: ($shown
|
|
||||||
? 'Das Programm ist zur Anzeige freigegeben. Das Angebot erscheint in der Shop-Suche und auf der Produktseite.'
|
|
||||||
: 'Das Programm „'.$pageName.'“ ist nicht zur Anzeige freigegeben oder kein Programm. Das Angebot ist dort nicht auffindbar.')),
|
|
||||||
'stand' => $shown ? 'erledigt' : 'offen',
|
|
||||||
'aktion' => $page === null || $shown ? null : ['label' => 'Programm öffnen', 'href' => EditorialCatalog::editUrl($page)],
|
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
use App\Domain\Catalog\FormattedText;
|
use App\Domain\Catalog\FormattedText;
|
||||||
use Filament\Forms\Components\RichEditor;
|
use Filament\Forms\Components\RichEditor;
|
||||||
use Filament\Forms\Components\RichEditor\RichEditorTool;
|
use Filament\Forms\Components\RichEditor\RichEditorTool;
|
||||||
|
use Filament\Forms\Components\RichEditor\TextColor;
|
||||||
use Filament\Support\Icons\Heroicon;
|
use Filament\Support\Icons\Heroicon;
|
||||||
|
use Illuminate\Support\Arr;
|
||||||
use Illuminate\Support\Js;
|
use Illuminate\Support\Js;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,23 +16,45 @@
|
|||||||
*/
|
*/
|
||||||
final class RichField
|
final class RichField
|
||||||
{
|
{
|
||||||
|
/** Farbwerte der Schriftfarben im Editor (Weiß/Cremefläche); auf der Seite bestimmt `widgets.css` je Fläche. */
|
||||||
|
private const SITE_COLOR_VALUES = ['marine' => '#032551', 'gruen' => '#3b7b09', 'rot' => '#a8212b', 'grau' => '#3e4c5c'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ?string $label Bezeichnung des Felds; sie ist auch der Name für Hilfstechnik
|
* @param ?string $label Bezeichnung des Felds; sie ist auch der Name für Hilfstechnik
|
||||||
* @param bool $live Arbeitsplätze gleichen beim Verlassen des Felds ab ({@see ManagesRichFields}); Dialoge nicht
|
* @param bool $live Arbeitsplätze gleichen beim Verlassen des Felds ab ({@see ManagesRichFields}); Dialoge nicht
|
||||||
* @param bool $hideLabel Die Bezeichnung zeigt der Arbeitsplatz selbst
|
* @param bool $hideLabel Die Bezeichnung zeigt der Arbeitsplatz selbst
|
||||||
* @param bool $images Bilder aus dem Medienbestand einfügen; nur auf Seiten mit dem gemeinsamen Picker
|
* @param bool $images Bilder aus dem Medienbestand einfügen; nur auf Seiten mit dem gemeinsamen Picker
|
||||||
* ({@see ManagesEditorialSurface::openTextImagePicker()})
|
* ({@see ManagesEditorialSurface::openTextImagePicker()})
|
||||||
|
* @param bool $website Texte der Website (Fließtext): zusätzlich Schriftgröße, Schriftfarbe und Ausrichtung aus festen
|
||||||
|
* Werten ({@see FormattedText::SITE_SIZES}, {@see FormattedText::SITE_COLORS}); gespeichert wird
|
||||||
|
* mit dem Webprofil von {@see FormattedText}
|
||||||
*/
|
*/
|
||||||
public static function make(string $name, ?string $label = null, bool $live = true, bool $hideLabel = false, bool $images = false): RichEditor
|
public static function make(string $name, ?string $label = null, bool $live = true, bool $hideLabel = false, bool $images = false, bool $website = false): RichEditor
|
||||||
{
|
{
|
||||||
$toolbar = FormattedText::TOOLBAR;
|
$toolbar = FormattedText::TOOLBAR;
|
||||||
|
|
||||||
|
if ($website) {
|
||||||
|
// Interne Seite oder Sprungmarke verlinken, gleich neben dem freien Link.
|
||||||
|
$toolbar[0] = [...$toolbar[0], 'interneSeite'];
|
||||||
|
array_splice($toolbar, 1, 0, [['fontSize', 'textColor'], ['alignStart', 'alignCenter', 'alignEnd']]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($images) {
|
if ($images) {
|
||||||
array_splice($toolbar, count($toolbar) - 1, 0, [['bild']]);
|
array_splice($toolbar, count($toolbar) - 1, 0, [['bild']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$field = RichEditor::make($name)->toolbarButtons($toolbar);
|
$field = RichEditor::make($name)->toolbarButtons($toolbar);
|
||||||
|
|
||||||
|
if ($website) {
|
||||||
|
$field
|
||||||
|
->plugins([new FontSizePlugin, new InternalLinkPlugin])
|
||||||
|
->textColors(Arr::mapWithKeys(
|
||||||
|
FormattedText::SITE_COLORS,
|
||||||
|
fn (string $label, string $key): array => [$key => TextColor::make($label, self::SITE_COLOR_VALUES[$key])],
|
||||||
|
))
|
||||||
|
->customTextColors(false);
|
||||||
|
}
|
||||||
|
|
||||||
if ($images) {
|
if ($images) {
|
||||||
$field->tools([
|
$field->tools([
|
||||||
RichEditorTool::make('bild')
|
RichEditorTool::make('bild')
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
use Filament\Forms\Components\Hidden;
|
use Filament\Forms\Components\Hidden;
|
||||||
use Filament\Forms\Components\Repeater;
|
use Filament\Forms\Components\Repeater;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Components\Toggle;
|
||||||
use Filament\Forms\Components\ToggleButtons;
|
use Filament\Forms\Components\ToggleButtons;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Schemas\Components\Group;
|
use Filament\Schemas\Components\Group;
|
||||||
@@ -27,7 +29,7 @@
|
|||||||
* Rasterverhältnis) → je Platz ein Widget (Builder mit höchstens einem Eintrag, Auswahl aus dem Widget-Register).
|
* Rasterverhältnis) → je Platz ein Widget (Builder mit höchstens einem Eintrag, Auswahl aus dem Widget-Register).
|
||||||
* Abschnittseinstellungen stehen im Abschnitt, Widget-Einstellungen im Widget-Dialog: eine Dialogebene.
|
* Abschnittseinstellungen stehen im Abschnitt, Widget-Einstellungen im Widget-Dialog: eine Dialogebene.
|
||||||
*
|
*
|
||||||
* Formularzustand eines Abschnitts: {id, layout, style: {...}, slots: {uuid: {widget: {uuid: Builder-Eintrag}}}}.
|
* Formularzustand eines Abschnitts: {id, name, anchor, hidden, layout, style: {...}, slots: {uuid: {widget: {uuid: Builder-Eintrag}}}}.
|
||||||
*/
|
*/
|
||||||
class SectionEditor
|
class SectionEditor
|
||||||
{
|
{
|
||||||
@@ -91,6 +93,7 @@ private static function sectionSchema(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Hidden::make('id'),
|
Hidden::make('id'),
|
||||||
|
self::labelSection(),
|
||||||
// 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')
|
||||||
@@ -154,6 +157,68 @@ private static function sectionSchema(): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name, Sprungmarke und Sichtbarkeit: stehen im Seitenaufbau am Abschnitt, damit man sie beim Ordnen der Seite sieht.
|
||||||
|
*/
|
||||||
|
private static function labelSection(): Section
|
||||||
|
{
|
||||||
|
return Section::make('Name, Sprungmarke und Sichtbarkeit')
|
||||||
|
->columnSpanFull()
|
||||||
|
->compact()
|
||||||
|
->collapsible()
|
||||||
|
->collapsed(fn (Get $get): bool => blank($get('name')) && blank($get('anchor')) && ! $get('hidden'))
|
||||||
|
->extraAttributes(['class' => 'luf-abschnitt-bezeichnung'])
|
||||||
|
->schema([
|
||||||
|
TextInput::make('name')
|
||||||
|
->label('Name des Abschnitts')
|
||||||
|
->placeholder('Zum Beispiel „Kursübersicht“')
|
||||||
|
->maxLength(PageSections::MAX_NAME)
|
||||||
|
->live(onBlur: true)
|
||||||
|
->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);
|
||||||
|
})
|
||||||
|
->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')
|
||||||
|
->live()
|
||||||
|
->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]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vollständiger Link zur Sprungmarke (für Verweise von außen); eine neue Seite hat noch keine Adresse.
|
||||||
|
*/
|
||||||
|
private static function anchorLinkText(mixed $anchor, mixed $livewire): ?string
|
||||||
|
{
|
||||||
|
if (! is_string($anchor) || $anchor === '') {
|
||||||
|
return 'Ohne Sprungmarke ist der Abschnitt kein Linkziel.';
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = is_object($livewire) && property_exists($livewire, 'record') && is_object($livewire->record ?? null) ? ($livewire->record->path ?? null) : null;
|
||||||
|
|
||||||
|
return is_string($path) && $path !== ''
|
||||||
|
? 'Link von anderen Seiten: '.($path === '/' ? '' : $path).'#'.$anchor.' · von außen: '.url($path === '/' ? '/' : $path).'#'.$anchor
|
||||||
|
: 'Link auf dieser Seite: #'.$anchor.'. Die Adresse für Verweise von außen steht nach dem ersten Speichern fest.';
|
||||||
|
}
|
||||||
|
|
||||||
private static function onWorkplace(mixed $livewire): bool
|
private static function onWorkplace(mixed $livewire): bool
|
||||||
{
|
{
|
||||||
return is_object($livewire) && method_exists($livewire, 'openAbschnitt');
|
return is_object($livewire) && method_exists($livewire, 'openAbschnitt');
|
||||||
@@ -257,6 +322,9 @@ public static function toEditorState(array $sections): array
|
|||||||
|
|
||||||
$state[] = [
|
$state[] = [
|
||||||
'id' => $section['id'] ?? (string) Str::uuid(),
|
'id' => $section['id'] ?? (string) Str::uuid(),
|
||||||
|
'name' => $section['name'] ?? null,
|
||||||
|
'anchor' => $section['anchor'] ?? null,
|
||||||
|
'hidden' => (bool) ($section['hidden'] ?? false),
|
||||||
'layout' => $section['layout'],
|
'layout' => $section['layout'],
|
||||||
'style' => SectionStyle::fromStored($section['style'] ?? []),
|
'style' => SectionStyle::fromStored($section['style'] ?? []),
|
||||||
'slots' => $slots,
|
'slots' => $slots,
|
||||||
@@ -289,6 +357,9 @@ public static function fromEditorState(?array $state): array
|
|||||||
|
|
||||||
$sections[] = [
|
$sections[] = [
|
||||||
'id' => $section['id'] ?? null,
|
'id' => $section['id'] ?? null,
|
||||||
|
'name' => is_string($section['name'] ?? null) ? $section['name'] : null,
|
||||||
|
'anchor' => is_string($section['anchor'] ?? null) ? $section['anchor'] : null,
|
||||||
|
'hidden' => (bool) ($section['hidden'] ?? false),
|
||||||
'layout' => $section['layout'] ?? SectionLayouts::DEFAULT,
|
'layout' => $section['layout'] ?? SectionLayouts::DEFAULT,
|
||||||
'style' => is_array($section['style'] ?? null) ? $section['style'] : [],
|
'style' => is_array($section['style'] ?? null) ? $section['style'] : [],
|
||||||
'slots' => $slots,
|
'slots' => $slots,
|
||||||
@@ -484,7 +555,12 @@ public static function insertCopyAfter(array $items, string $key, string $newKey
|
|||||||
foreach ($items as $itemKey => $item) {
|
foreach ($items as $itemKey => $item) {
|
||||||
$result[$itemKey] = $item;
|
$result[$itemKey] = $item;
|
||||||
if ((string) $itemKey === $key) {
|
if ((string) $itemKey === $key) {
|
||||||
$result[$newKey] = $item;
|
// Eine Sprungmarke gibt es je Seite nur einmal: Die Kopie bekommt keine, der Name wird kenntlich gemacht.
|
||||||
|
$copy = is_array($item) ? $item : [];
|
||||||
|
$copy['anchor'] = null;
|
||||||
|
$name = is_string($copy['name'] ?? null) ? trim($copy['name']) : '';
|
||||||
|
$copy['name'] = $name !== '' ? Str::limit($name, PageSections::MAX_NAME - 9, '').' (Kopie)' : null;
|
||||||
|
$result[$newKey] = $copy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,13 +638,25 @@ private static function sectionLabel(array $state, ?int $index): HtmlString
|
|||||||
$meta[] = 'noch leer';
|
$meta[] = 'noch leer';
|
||||||
}
|
}
|
||||||
|
|
||||||
$name = 'Abschnitt '.(($index ?? 0) + 1);
|
$number = 'Abschnitt '.(($index ?? 0) + 1);
|
||||||
|
$given = PageSections::cleanName($state['name'] ?? null);
|
||||||
|
$anchor = PageSections::cleanAnchor($state['anchor'] ?? null);
|
||||||
|
$hidden = (bool) ($state['hidden'] ?? false);
|
||||||
$full = 'Raster '.SectionLayouts::short($layout).' · '.SectionStyle::summary($style)
|
$full = 'Raster '.SectionLayouts::short($layout).' · '.SectionStyle::summary($style)
|
||||||
.($names === [] ? ' · noch leer' : ' · '.implode(', ', $names));
|
.($names === [] ? ' · noch leer' : ' · '.implode(', ', $names));
|
||||||
|
|
||||||
return new HtmlString('<span class="luf-abschnitt" title="'.e($full).'"><span class="luf-abschnitt-nr">'.e($name).'</span>'
|
// Der Name steht vorn; die Nummer bleibt als Orientierung daneben. Sprungmarke und „Ausgeblendet“ sind auch
|
||||||
|
// für Screenreader lesbar, die Nummer und die Rastermeta nicht doppelt.
|
||||||
|
$text = $given !== null ? $given : $number;
|
||||||
|
$badges = ($anchor !== null ? '<span class="luf-abschnitt-marke" title="Sprungmarke">#'.e($anchor).'</span>' : '')
|
||||||
|
.($hidden ? '<span class="luf-abschnitt-aus" title="Auf der Website ausgeblendet">Ausgeblendet</span>' : '');
|
||||||
|
$spoken = ($given !== null ? $number.': ' : '').($anchor !== null ? 'Sprungmarke '.$anchor.'. ' : '').($hidden ? 'Auf der Website ausgeblendet. ' : '').$full;
|
||||||
|
|
||||||
|
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>' : '')
|
||||||
|
.$badges
|
||||||
.'<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($full).'</span></span>');
|
.'<span class="vw-sr">: '.e($spoken).'</span></span>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support\TipTap;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\FormattedText;
|
||||||
|
use Tiptap\Core\Mark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schriftgröße als Auszeichnung des Texts (`<span data-size="large">`), Gegenstück zu `public/js/rich-font-size.js`. Der
|
||||||
|
* Editor führt den Wert beim Speichern durch dieses PHP-Modell; eine Auszeichnung, die hier fehlt, ginge verloren.
|
||||||
|
* Welche Größen gelten, entscheidet {@see FormattedText::SITE_SIZES}.
|
||||||
|
*/
|
||||||
|
class FontSizeExtension extends Mark
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public static $name = 'fontSize';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function parseHTML(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'tag' => 'span',
|
||||||
|
'getAttrs' => fn ($DOMNode): bool => $DOMNode->hasAttribute('data-size'),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, array<mixed>>
|
||||||
|
*/
|
||||||
|
public function addAttributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'data-size' => [
|
||||||
|
'parseHTML' => fn ($DOMNode) => $DOMNode->getAttribute('data-size') ?: null,
|
||||||
|
'renderHTML' => function ($attributes) {
|
||||||
|
$value = is_array($attributes) ? ($attributes['data-size'] ?? null) : ($attributes->{'data-size'} ?? null);
|
||||||
|
|
||||||
|
return ['data-size' => $value];
|
||||||
|
},
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param object $mark
|
||||||
|
* @param array<string, mixed> $HTMLAttributes
|
||||||
|
* @return array<mixed>
|
||||||
|
*/
|
||||||
|
public function renderHTML($mark, $HTMLAttributes = []): array
|
||||||
|
{
|
||||||
|
return ['span', $HTMLAttributes, 0];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,9 +31,7 @@ public function show(Request $request, Cart $cart, OrderHolders $holders): View
|
|||||||
|
|
||||||
public function add(Offer $offer, Cart $cart, PublicCatalogReader $catalog): RedirectResponse
|
public function add(Offer $offer, Cart $cart, PublicCatalogReader $catalog): RedirectResponse
|
||||||
{
|
{
|
||||||
$page = $offer->composition;
|
$result = $this->listed($offer, $catalog) ? $cart->add($offer) : Cart::UNAVAILABLE;
|
||||||
$listed = $offer->standalone_bundle || ($page !== null && $catalog->shownVersion($page) !== null);
|
|
||||||
$result = $listed ? $cart->add($offer) : Cart::UNAVAILABLE;
|
|
||||||
$back = $this->productPage($offer);
|
$back = $this->productPage($offer);
|
||||||
|
|
||||||
return match ($result) {
|
return match ($result) {
|
||||||
@@ -44,6 +42,27 @@ public function add(Offer $offer, Cart $cart, PublicCatalogReader $catalog): Red
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* „Jetzt kaufen“: die gewählte Option kommt in den Warenkorb (eine andere Option derselben Produktseite wird
|
||||||
|
* ersetzt, weil der Käufer sich ausdrücklich für diese entschieden hat) und die Bestellübersicht öffnet sich. Es
|
||||||
|
* entsteht keine Bestellung; die Kasse prüft wie immer Zustimmungen, Rabatt und Inhaber, und erst „Zahlungspflichtig
|
||||||
|
* bestellen“ legt sie an. Ohne Anmeldung führt die Kasse zur Anmeldung; der Warenkorb liegt in der Sitzung und bleibt.
|
||||||
|
*/
|
||||||
|
public function buy(Request $request, Offer $offer, Cart $cart, PublicCatalogReader $catalog): RedirectResponse
|
||||||
|
{
|
||||||
|
if (! $this->listed($offer, $catalog) || $cart->purchasable($offer) === null) {
|
||||||
|
return $this->productPage($offer)->withErrors(['shop' => 'Diese Option ist gerade nicht erhältlich.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($cart->ownedAmong($request->user(), [$offer]) !== []) {
|
||||||
|
return $this->productPage($offer)->with('status', 'Diese Lizenz besitzt du bereits. Sie liegt in deiner Bibliothek.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$cart->switchTo($offer);
|
||||||
|
|
||||||
|
return redirect()->route('checkout');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ausdrücklicher Wechsel zwischen Alternativoptionen derselben Produktseite.
|
* Ausdrücklicher Wechsel zwischen Alternativoptionen derselben Produktseite.
|
||||||
*/
|
*/
|
||||||
@@ -79,6 +98,19 @@ public function accept(Offer $offer, Cart $cart): RedirectResponse
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Nur Optionen mit öffentlicher Produktseite sind im Shop kaufbar (bei Altbestand mit Programmseite: freigegeben). */
|
||||||
|
private function listed(Offer $offer, PublicCatalogReader $catalog): bool
|
||||||
|
{
|
||||||
|
$key = app(ProductOptions::class)->groupKey($offer);
|
||||||
|
$page = $offer->composition;
|
||||||
|
|
||||||
|
return match (true) {
|
||||||
|
$key === null => false,
|
||||||
|
$key[0] === 'c' => $page !== null && $catalog->shownVersion($page) !== null,
|
||||||
|
default => true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private function productPage(Offer $offer): RedirectResponse
|
private function productPage(Offer $offer): RedirectResponse
|
||||||
{
|
{
|
||||||
$url = app(ProductOptions::class)->pageUrl($offer);
|
$url = app(ProductOptions::class)->pageUrl($offer);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
use App\Domain\Catalog\DomainRuleException;
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
use App\Domain\Catalog\Offer;
|
use App\Domain\Catalog\Offer;
|
||||||
use App\Domain\Catalog\OfferStatus;
|
|
||||||
use App\Domain\Commerce\Cart;
|
use App\Domain\Commerce\Cart;
|
||||||
use App\Domain\Commerce\Checkout;
|
use App\Domain\Commerce\Checkout;
|
||||||
use App\Domain\Commerce\LedgerEntry;
|
use App\Domain\Commerce\LedgerEntry;
|
||||||
@@ -12,9 +11,12 @@
|
|||||||
use App\Domain\Commerce\OrderHolders;
|
use App\Domain\Commerce\OrderHolders;
|
||||||
use App\Domain\Commerce\SalesTerms;
|
use App\Domain\Commerce\SalesTerms;
|
||||||
use App\Domain\Commerce\Shop;
|
use App\Domain\Commerce\Shop;
|
||||||
|
use App\Domain\Commerce\ShopCatalog;
|
||||||
use App\Domain\Commerce\StaleOverview;
|
use App\Domain\Commerce\StaleOverview;
|
||||||
use App\Domain\Commerce\Stripe\StripeGateway;
|
use App\Domain\Commerce\Stripe\StripeGateway;
|
||||||
use App\Domain\Entitlement\GrantIssuer;
|
use App\Domain\Entitlement\GrantIssuer;
|
||||||
|
use App\Domain\Entitlement\NewStands;
|
||||||
|
use App\Domain\Entitlement\OfferAccess;
|
||||||
use App\Domain\Identity\PartyType;
|
use App\Domain\Identity\PartyType;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
@@ -23,15 +25,22 @@
|
|||||||
|
|
||||||
class CheckoutController extends Controller
|
class CheckoutController extends Controller
|
||||||
{
|
{
|
||||||
public function offers(): View
|
/**
|
||||||
|
* Angebote für das Konto: was sich ohne Kauf in die Bibliothek übernehmen lässt (Regel des Angebots, ADR-56) und
|
||||||
|
* neue Stände zu bereits besessenen Artikeln. Gekauft wird ausschließlich im Shop über Warenkorb oder „Jetzt kaufen“
|
||||||
|
* und die Kasse.
|
||||||
|
*/
|
||||||
|
public function offers(Request $request, OfferAccess $access, NewStands $stands): View
|
||||||
{
|
{
|
||||||
$offers = Offer::query()
|
$user = $request->user();
|
||||||
->whereHas('versions', fn ($query) => $query->where('status', OfferStatus::Aktiv)->where('holder_kind', 'person'))
|
$shop = Shop::visible();
|
||||||
->with(['versions' => fn ($query) => $query->where('status', OfferStatus::Aktiv)])
|
|
||||||
->orderBy('name')
|
|
||||||
->get();
|
|
||||||
|
|
||||||
return view('member.offers', ['offers' => $offers]);
|
return view('member.offers', [
|
||||||
|
'offers' => $access->claimable($user),
|
||||||
|
'stands' => $stands->forUser($user),
|
||||||
|
'shop' => $shop,
|
||||||
|
'cards' => $shop ? app(ShopCatalog::class)->cards('', ['sort' => 'neu', 'limit' => 6]) : [],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function claim(Request $request, Offer $offer, GrantIssuer $issuer): RedirectResponse
|
public function claim(Request $request, Offer $offer, GrantIssuer $issuer): RedirectResponse
|
||||||
@@ -45,17 +54,6 @@ public function claim(Request $request, Offer $offer, GrantIssuer $issuer): Redi
|
|||||||
return redirect()->route('member.library')->with('status', 'Das Angebot liegt in deiner Bibliothek.');
|
return redirect()->route('member.library')->with('status', 'Das Angebot liegt in deiner Bibliothek.');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function place(Request $request, Offer $offer, Checkout $checkout): RedirectResponse
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$order = $checkout->place($request->user(), $offer);
|
|
||||||
} catch (DomainRuleException $exception) {
|
|
||||||
return back()->withErrors(['offer' => $exception->getMessage()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect()->route('member.order', $order);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bestellübersicht: zeigt die geprüften Positionen mit dem Inhaber, für den bestellt wird.
|
* Bestellübersicht: zeigt die geprüften Positionen mit dem Inhaber, für den bestellt wird.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
use App\Domain\Cms\PageTemplates;
|
use App\Domain\Cms\PageTemplates;
|
||||||
use App\Domain\Cms\Sections\SectionRenderer;
|
use App\Domain\Cms\Sections\SectionRenderer;
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
|
use App\Domain\Commerce\Shop;
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
use Illuminate\Support\Facades\Gate;
|
use Illuminate\Support\Facades\Gate;
|
||||||
|
|
||||||
@@ -24,6 +26,21 @@ public function show(string $path): View
|
|||||||
return $this->render(Page::query()->where('path', '/'.$path)->firstOrFail(), preview: false);
|
return $this->render(Page::query()->where('path', '/'.$path)->firstOrFail(), preview: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die frühere Angebotsseite der Website ist der Shop. Solange er nicht sichtbar ist, bleibt eine noch vorhandene
|
||||||
|
* CMS-Seite unter dieser Adresse erreichbar (sonst 404).
|
||||||
|
*/
|
||||||
|
public function offers(): View|RedirectResponse
|
||||||
|
{
|
||||||
|
return Shop::visible() ? redirect()->route('shop') : $this->show('angebote');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Eine veröffentlichte CMS-Seite unter einer festen App-Adresse (der Shop unter /shop). */
|
||||||
|
public function showPage(Page $page): View
|
||||||
|
{
|
||||||
|
return $this->render($page, preview: false);
|
||||||
|
}
|
||||||
|
|
||||||
public function preview(PageRevision $revision): View
|
public function preview(PageRevision $revision): View
|
||||||
{
|
{
|
||||||
$page = $revision->page;
|
$page = $revision->page;
|
||||||
@@ -49,7 +66,9 @@ public function devices(PageRevision $revision): View
|
|||||||
|
|
||||||
public function sitemap(): Response
|
public function sitemap(): Response
|
||||||
{
|
{
|
||||||
$pages = Page::query()->whereNotNull('published_revision_id')->orderBy('path')->get();
|
// Der Shop gehört nicht in die Sitemap, solange man dort nicht kaufen kann (die Seiten sind dann noindex).
|
||||||
|
$pages = Page::query()->whereNotNull('published_revision_id')->orderBy('path')->get()
|
||||||
|
->reject(fn (Page $page): bool => $page->path === '/shop' && ! Shop::checkoutOpen());
|
||||||
$themes = Pillar::query()->published()->get();
|
$themes = Pillar::query()->published()->get();
|
||||||
|
|
||||||
return response()
|
return response()
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
use App\Domain\Catalog\Bundle;
|
use App\Domain\Catalog\Bundle;
|
||||||
use App\Domain\Catalog\Composition;
|
use App\Domain\Catalog\Composition;
|
||||||
use App\Domain\Catalog\CompositionStructureReader;
|
use App\Domain\Catalog\CompositionStructureReader;
|
||||||
|
use App\Domain\Catalog\EditorialProfileReader;
|
||||||
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||||
use App\Domain\Commerce\Cart;
|
use App\Domain\Commerce\Cart;
|
||||||
use App\Domain\Commerce\ProductOptions;
|
use App\Domain\Commerce\ProductOptions;
|
||||||
@@ -24,7 +26,7 @@ public function index(PublicCatalogReader $catalog): View
|
|||||||
*/
|
*/
|
||||||
public function package(Bundle $bundle, ProductOptions $products, Cart $cart): View
|
public function package(Bundle $bundle, ProductOptions $products, Cart $cart): View
|
||||||
{
|
{
|
||||||
abort_unless(Shop::enabled(), 404);
|
abort_unless(Shop::visible(), 404);
|
||||||
$options = $products->forBundle($bundle);
|
$options = $products->forBundle($bundle);
|
||||||
abort_if($options === [], 404);
|
abort_if($options === [], 404);
|
||||||
|
|
||||||
@@ -37,6 +39,28 @@ public function package(Bundle $bundle, ProductOptions $products, Cart $cart): V
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Produktseite eines Lizenzartikels: Titel und Beschreibung aus der Redaktion des Artikels (sonst aus seinem Inhalt),
|
||||||
|
* der Aufbau des verkauften Inhalts und darunter die kaufbaren Lizenzoptionen. Ohne kaufbare Option gibt es sie nicht.
|
||||||
|
*/
|
||||||
|
public function article(LicenseArticle $article, ProductOptions $products, Cart $cart): View
|
||||||
|
{
|
||||||
|
abort_unless(Shop::visible() && $article->archived_at === null, 404);
|
||||||
|
$options = $products->forArticle($article);
|
||||||
|
abort_if($options === [], 404);
|
||||||
|
|
||||||
|
return view('public.article', [
|
||||||
|
'article' => $article,
|
||||||
|
'title' => $products->articleTitle($article),
|
||||||
|
'profile' => app(EditorialProfileReader::class)->read($article, 'detail'),
|
||||||
|
'goal' => $products->articleGoal($article),
|
||||||
|
'nodes' => $products->articleStructure($article),
|
||||||
|
'options' => $options,
|
||||||
|
'cart' => $cart,
|
||||||
|
'switchTo' => session('shop.switch'),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function program(Composition $composition, PublicCatalogReader $catalog, ProductOptions $products, Cart $cart): View
|
public function program(Composition $composition, PublicCatalogReader $catalog, ProductOptions $products, Cart $cart): View
|
||||||
{
|
{
|
||||||
$version = $catalog->shownVersion($composition);
|
$version = $catalog->shownVersion($composition);
|
||||||
@@ -46,7 +70,8 @@ public function program(Composition $composition, PublicCatalogReader $catalog,
|
|||||||
'composition' => $composition,
|
'composition' => $composition,
|
||||||
'version' => $version,
|
'version' => $version,
|
||||||
'nodes' => app(CompositionStructureReader::class)->tree($version),
|
'nodes' => app(CompositionStructureReader::class)->tree($version),
|
||||||
'options' => Shop::enabled() ? $products->forComposition($composition) : [],
|
'options' => Shop::visible() ? $products->forComposition($composition) : [],
|
||||||
|
'articles' => Shop::visible() ? $products->articlesOf($composition) : [],
|
||||||
'cart' => $cart,
|
'cart' => $cart,
|
||||||
'switchTo' => session('shop.switch'),
|
'switchTo' => session('shop.switch'),
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -2,71 +2,39 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Domain\Catalog\Bundle;
|
use App\Domain\Cms\Page;
|
||||||
use App\Domain\Catalog\Composition;
|
use App\Domain\Commerce\Shop;
|
||||||
use App\Domain\Catalog\FormattedText;
|
use App\Domain\Commerce\ShopCatalog;
|
||||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
use Illuminate\Contracts\View\View;
|
||||||
use App\Domain\Commerce\Money;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use App\Domain\Commerce\ProductOptions;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\View\View;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Durchsuchbarer Shop (Etappe 1): macht kaufbare Produkte auffindbar. Treffer öffnen dieselbe öffentliche Produktseite
|
* Durchsuchbarer Shop: macht kaufbare Produkte auffindbar. Treffer öffnen dieselbe öffentliche Produktseite wie die
|
||||||
* wie die Programmkacheln. Gelistet wird nur, was zur Anzeige freigegeben ist und mindestens eine kaufbare Option hat.
|
* Programmkacheln. Gelistet wird nur, was mindestens eine kaufbare Option hat; die Kacheln bildet ShopCatalog.
|
||||||
|
*
|
||||||
|
* Gibt es in der Webpräsenz eine veröffentlichte Seite „shop“, bestimmt sie den Aufbau (Banner, Grafiken, Texte und das
|
||||||
|
* Widget „Shop-Produkte“); sonst zeigt die Anwendung die Standardseite mit Suche und Kacheln (ADR-55).
|
||||||
*/
|
*/
|
||||||
class ShopController extends Controller
|
class ShopController extends Controller
|
||||||
{
|
{
|
||||||
public function index(Request $request, ProductOptions $products, PublicCatalogReader $catalog): View
|
/**
|
||||||
|
* Hinweisseite, solange der Shop sichtbar, der Checkout aber noch nicht freigegeben ist: Wer „Kaufen“ wählt, sieht,
|
||||||
|
* dass der Kauf zum Verkaufsstart möglich wird. Ist der Checkout offen, gibt es sie nicht mehr.
|
||||||
|
*/
|
||||||
|
public function closed(): View|RedirectResponse
|
||||||
{
|
{
|
||||||
$term = trim((string) $request->query('suche', ''));
|
return Shop::checkoutOpen() ? redirect()->route('shop') : view('shop.closed');
|
||||||
$summaries = $products->summaries();
|
}
|
||||||
$cards = [];
|
|
||||||
|
|
||||||
foreach (Composition::query()->whereIn('id', array_keys($summaries))->orderBy('designation')->get() as $composition) {
|
public function index(Request $request, ShopCatalog $catalog, PageController $pages): View
|
||||||
$version = $catalog->shownVersion($composition);
|
{
|
||||||
|
$page = Page::query()->where('path', '/shop')->whereNotNull('published_revision_id')->first();
|
||||||
|
|
||||||
if ($version === null) {
|
if ($page !== null) {
|
||||||
continue;
|
return $pages->showPage($page);
|
||||||
}
|
|
||||||
|
|
||||||
$title = (string) ($composition->display_title ?: $composition->designation);
|
|
||||||
$haystack = mb_strtolower($title.' '.$composition->teaser.' '.FormattedText::plain($composition->summary).' '.$composition->search_terms);
|
|
||||||
|
|
||||||
if ($term !== '' && ! str_contains($haystack, mb_strtolower($term))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$summary = $summaries[$composition->id];
|
|
||||||
$cards[] = [
|
|
||||||
'url' => route('public.program', $composition),
|
|
||||||
'title' => $title,
|
|
||||||
'teaser' => (string) ($composition->teaser ?: FormattedText::plain($composition->summary)),
|
|
||||||
'from' => Money::format($summary['from_cents']),
|
|
||||||
'count' => $summary['count'],
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pakete mit eigener Produktseite: gelistet mit Name und enthaltenen Artikeln.
|
return view('shop.index', ['listing' => $catalog->listing($request->query())]);
|
||||||
foreach (Bundle::query()->whereIn('id', array_keys($products->bundleSummaries()))->orderBy('name')->get() as $bundle) {
|
|
||||||
$options = $products->forBundle($bundle);
|
|
||||||
$contents = $products->bundleContents($options);
|
|
||||||
$names = implode(', ', array_column($contents, 'title'));
|
|
||||||
|
|
||||||
if ($term !== '' && ! str_contains(mb_strtolower($bundle->name.' '.$names), mb_strtolower($term))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$summary = $products->bundleSummaries()[$bundle->id];
|
|
||||||
$cards[] = [
|
|
||||||
'url' => route('public.package', $bundle),
|
|
||||||
'title' => (string) $bundle->name,
|
|
||||||
'teaser' => 'Paket mit '.count($contents).' '.(count($contents) === 1 ? 'Inhalt' : 'Inhalten').($names !== '' ? ': '.$names : ''),
|
|
||||||
'from' => Money::format($summary['from_cents']),
|
|
||||||
'count' => $summary['count'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return view('shop.index', ['cards' => $cards, 'term' => $term]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use App\Domain\Commerce\Shop;
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schalter 2: Warenkorb, Kasse und „Jetzt kaufen“ gibt es nur, wenn der Checkout offen ist (Shop::checkoutOpen).
|
||||||
|
* Ist der Shop sichtbar, aber der Kauf noch nicht freigegeben, führt jede Anfrage (auch ein POST) auf die Hinweisseite.
|
||||||
|
* Dort entsteht nichts: kein Warenkorb, keine Bestellung. Die Prüfung liegt auf dem Server, nicht nur in der Oberfläche.
|
||||||
|
*/
|
||||||
|
class EnsureCheckoutOpen
|
||||||
|
{
|
||||||
|
public function handle(Request $request, Closure $next): Response
|
||||||
|
{
|
||||||
|
if (! Shop::checkoutOpen()) {
|
||||||
|
abort_unless(Shop::visible(), 404);
|
||||||
|
|
||||||
|
return redirect()->route('shop.closed');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,13 +8,14 @@
|
|||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Warenkorb und Kasse gibt es nur mit Testzahlung und nie in Produktion (Etappe 1 erteilt keine Produktivfreigabe).
|
* Schalter 1: Shop, Produktseiten und Hinweisseite gibt es nur, wenn der Shop sichtbar ist (Shop::visible). Sonst
|
||||||
|
* antwortet die Anwendung, als gäbe es sie nicht.
|
||||||
*/
|
*/
|
||||||
class EnsureShopEnabled
|
class EnsureShopVisible
|
||||||
{
|
{
|
||||||
public function handle(Request $request, Closure $next): Response
|
public function handle(Request $request, Closure $next): Response
|
||||||
{
|
{
|
||||||
abort_unless(Shop::enabled(), 404);
|
abort_unless(Shop::visible(), 404);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Http\Middleware\EnsureCheckoutOpen;
|
||||||
use App\Http\Middleware\IgnoreEmptyForwardedHeaders;
|
use App\Http\Middleware\IgnoreEmptyForwardedHeaders;
|
||||||
use App\Http\Middleware\SanitizeIntendedUrl;
|
use App\Http\Middleware\SanitizeIntendedUrl;
|
||||||
use App\Http\Middleware\UseRequestRootUrl;
|
use App\Http\Middleware\UseRequestRootUrl;
|
||||||
use App\Http\Middleware\UseStaffSessionCookie;
|
use App\Http\Middleware\UseStaffSessionCookie;
|
||||||
|
use Illuminate\Contracts\Auth\Middleware\AuthenticatesRequests;
|
||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
use Illuminate\Foundation\Configuration\Exceptions;
|
use Illuminate\Foundation\Configuration\Exceptions;
|
||||||
use Illuminate\Foundation\Configuration\Middleware;
|
use Illuminate\Foundation\Configuration\Middleware;
|
||||||
@@ -23,6 +25,9 @@
|
|||||||
$middleware->prepend(UseRequestRootUrl::class);
|
$middleware->prepend(UseRequestRootUrl::class);
|
||||||
$middleware->prepend(IgnoreEmptyForwardedHeaders::class);
|
$middleware->prepend(IgnoreEmptyForwardedHeaders::class);
|
||||||
$middleware->web(append: SanitizeIntendedUrl::class);
|
$middleware->web(append: SanitizeIntendedUrl::class);
|
||||||
|
// Der Schalter „Checkout offen“ gilt vor der Anmeldung: Ohne ihn soll ein Gast nicht erst zur Anmeldung geschickt
|
||||||
|
// werden (und bei abgeschaltetem Shop nicht erfahren, dass es die Kasse gibt).
|
||||||
|
$middleware->prependToPriorityList(before: AuthenticatesRequests::class, prepend: EnsureCheckoutOpen::class);
|
||||||
$middleware->redirectGuestsTo(function (Request $request) {
|
$middleware->redirectGuestsTo(function (Request $request) {
|
||||||
if ($request->is('verwaltung', 'verwaltung/*')) {
|
if ($request->is('verwaltung', 'verwaltung/*')) {
|
||||||
return '/verwaltung/login';
|
return '/verwaltung/login';
|
||||||
|
|||||||
@@ -9,8 +9,10 @@
|
|||||||
use App\Domain\Cms\Widgets\Types\HeroWidget;
|
use App\Domain\Cms\Widgets\Types\HeroWidget;
|
||||||
use App\Domain\Cms\Widgets\Types\ImageTextWidget;
|
use App\Domain\Cms\Widgets\Types\ImageTextWidget;
|
||||||
use App\Domain\Cms\Widgets\Types\MediaCardWidget;
|
use App\Domain\Cms\Widgets\Types\MediaCardWidget;
|
||||||
|
use App\Domain\Cms\Widgets\Types\NoticeWidget;
|
||||||
use App\Domain\Cms\Widgets\Types\ProgramCardWidget;
|
use App\Domain\Cms\Widgets\Types\ProgramCardWidget;
|
||||||
use App\Domain\Cms\Widgets\Types\ProseWidget;
|
use App\Domain\Cms\Widgets\Types\ProseWidget;
|
||||||
|
use App\Domain\Cms\Widgets\Types\ShopProductsWidget;
|
||||||
use App\Domain\Cms\Widgets\Types\TopicCardWidget;
|
use App\Domain\Cms\Widgets\Types\TopicCardWidget;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@@ -25,6 +27,7 @@
|
|||||||
HeroWidget::class,
|
HeroWidget::class,
|
||||||
HeadingWidget::class,
|
HeadingWidget::class,
|
||||||
ProseWidget::class,
|
ProseWidget::class,
|
||||||
|
NoticeWidget::class,
|
||||||
ImageTextWidget::class,
|
ImageTextWidget::class,
|
||||||
CardsWidget::class,
|
CardsWidget::class,
|
||||||
FeaturesWidget::class,
|
FeaturesWidget::class,
|
||||||
@@ -34,6 +37,7 @@
|
|||||||
ProgramCardWidget::class,
|
ProgramCardWidget::class,
|
||||||
CallToActionWidget::class,
|
CallToActionWidget::class,
|
||||||
FaqWidget::class,
|
FaqWidget::class,
|
||||||
|
ShopProductsWidget::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -45,7 +49,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
| Früher vorbereiteter Warenkorbzugang. Seit Etappe 1 folgt der Eintrag in der Kopfzeile dem Shop
|
| Früher vorbereiteter Warenkorbzugang. Seit Etappe 1 folgt der Eintrag in der Kopfzeile dem Shop
|
||||||
| (App\Domain\Commerce\Shop::enabled: Testzahlung, nie in Produktion). Diese Werte werden nicht mehr gelesen.
|
| (App\Domain\Commerce\Shop::checkoutOpen). Diese Werte werden nicht mehr gelesen.
|
||||||
*/
|
*/
|
||||||
'cart' => [
|
'cart' => [
|
||||||
'enabled' => (bool) env('LUF_CART_ENABLED', false),
|
'enabled' => (bool) env('LUF_CART_ENABLED', false),
|
||||||
|
|||||||
@@ -16,6 +16,27 @@
|
|||||||
|
|
||||||
'live_release' => (bool) env('SHOP_LIVE_RELEASE', false),
|
'live_release' => (bool) env('SHOP_LIVE_RELEASE', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
| Shop sichtbar (zweiter Schalter, nur Produktion): Übersicht, Produktseiten und Pakete sind öffentlich erreichbar,
|
||||||
|
| gekauft werden kann aber erst mit der Produktivfreigabe oben. Wer „Kaufen“ wählt, sieht den Hinweis, dass der Kauf
|
||||||
|
| zum Verkaufsstart startet. Eine Produktivfreigabe macht den Shop immer auch sichtbar. Standardmäßig aus; wie die
|
||||||
|
| Freigabe ausschließlich in /etc/luf/prod.env (SHOP_PUBLIC=true), nie im Repository. Außerhalb der Produktion
|
||||||
|
| richtet sich beides allein nach dem Zahlungstreiber (test oder stripe mit Testschlüssel).
|
||||||
|
*/
|
||||||
|
|
||||||
|
'public' => (bool) env('SHOP_PUBLIC', false),
|
||||||
|
|
||||||
|
/*
|
||||||
|
| Produktmarker „Neu“ und „Aktualisiert“ erscheinen automatisch für diese Zahl Tage (ShopMarkers). Eine Einstellung
|
||||||
|
| der Redaktion am Lizenzartikel hat Vorrang.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'marker_days' => 30,
|
||||||
|
|
||||||
|
/* Produkte je Seite in der Shopliste (Kacheln und Liste). */
|
||||||
|
|
||||||
|
'per_page' => 12,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
| Kauf auf Rechnung für Vereine und Organisationen (PAY-006): auf Anfrage, Rechnung manuell durch den Betreiber.
|
| Kauf auf Rechnung für Vereine und Organisationen (PAY-006): auf Anfrage, Rechnung manuell durch den Betreiber.
|
||||||
| Standardmäßig aus: Das Mitglied sieht die Möglichkeit erst, wenn der Prozess vollständig ist (Rechnungserstellung
|
| Standardmäßig aus: Das Mitglied sieht die Möglichkeit erst, wenn der Prozess vollständig ist (Rechnungserstellung
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shopdarstellung (ADR-54), rein ergänzend: ein Symbol je Materialart (Schlüssel der Symbolbibliothek) und die Marker
|
||||||
|
* „Neu“, „Aktualisiert“, „Beliebt“ je Lizenzartikel. Beide Spalten sind leer zulässig; ein Rollback des Codes lässt sie
|
||||||
|
* unbenutzt liegen.
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('editorial_content_kinds', function (Blueprint $table): void {
|
||||||
|
$table->string('symbol', 60)->nullable()->after('label');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('license_articles', function (Blueprint $table): void {
|
||||||
|
$table->json('shop_markers')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('license_articles', function (Blueprint $table): void {
|
||||||
|
$table->dropColumn('shop_markers');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('editorial_content_kinds', function (Blueprint $table): void {
|
||||||
|
$table->dropColumn('symbol');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Regeln für freie Artikel (ADR-56), rein ergänzend: Wer ein Angebot „auf Abruf“ übernehmen darf (alle Mitglieder,
|
||||||
|
* freigeschaltete Konten oder wer einen bestimmten Artikel besitzt) und die Freigaben je Konto. Freigaben werden nie
|
||||||
|
* gelöscht, nur entzogen; ein Angebot oder Konto mit Freigaben lässt sich nicht löschen (restrict).
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('offers', function (Blueprint $table): void {
|
||||||
|
$table->string('claim_access', 20)->default('alle');
|
||||||
|
$table->foreignId('claim_requires_article_id')->nullable()->constrained('license_articles')->restrictOnDelete();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('offer_releases', function (Blueprint $table): void {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('offer_id')->constrained('offers')->restrictOnDelete();
|
||||||
|
$table->foreignId('user_id')->constrained('users')->restrictOnDelete();
|
||||||
|
$table->foreignId('granted_by')->nullable()->constrained('users')->nullOnDelete();
|
||||||
|
$table->timestamp('granted_at');
|
||||||
|
$table->timestamp('valid_until')->nullable();
|
||||||
|
$table->foreignId('revoked_by')->nullable()->constrained('users')->nullOnDelete();
|
||||||
|
$table->timestamp('revoked_at')->nullable();
|
||||||
|
$table->text('reason')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->index(['offer_id', 'user_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('offer_releases');
|
||||||
|
|
||||||
|
Schema::table('offers', function (Blueprint $table): void {
|
||||||
|
$table->dropConstrainedForeignId('claim_requires_article_id');
|
||||||
|
$table->dropColumn('claim_access');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ergänzend und abwärtskompatibel: Ein Menüeintrag mit Zielseite kann auf eine Sprungmarke dieser Seite zeigen.
|
||||||
|
* Ohne Wert (bisher alle Einträge) führt er zum Seitenanfang. Ältere Programmstände ignorieren die Spalte.
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('navigation_items', function (Blueprint $table) {
|
||||||
|
$table->string('anchor', 60)->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('navigation_items', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('anchor');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -104,21 +104,6 @@ private function pages(): array
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'/angebote' => [
|
|
||||||
'seo_title' => 'Angebote',
|
|
||||||
'seo_description' => 'Lizenzangebote werden aus dem Katalog gelesen, nicht als freier Text gepflegt.',
|
|
||||||
'blocks' => [
|
|
||||||
[
|
|
||||||
'type' => 'heading',
|
|
||||||
'heading' => 'Angebote',
|
|
||||||
'intro' => 'Umfang, Rechte und Preise eines Angebots kommen aus dem Katalog. Sie werden hier nicht als freier Text ersetzt.',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'type' => 'prose',
|
|
||||||
'body' => 'Es sind noch keine Angebote veröffentlicht. Sobald ein Angebot aktiv ist, zeigt diese Seite seinen Umfang aus dem gespeicherten Stand.',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'/trainer' => [
|
'/trainer' => [
|
||||||
'seo_title' => 'Für Trainer und Einrichtungen',
|
'seo_title' => 'Für Trainer und Einrichtungen',
|
||||||
'seo_description' => 'Informationen für Gewaltschutztrainer, Übungsleiter, Fachkräfte, Vereine und Bildungseinrichtungen.',
|
'seo_description' => 'Informationen für Gewaltschutztrainer, Übungsleiter, Fachkräfte, Vereine und Bildungseinrichtungen.',
|
||||||
@@ -191,7 +176,7 @@ private function navigation(): array
|
|||||||
['label' => 'Start', 'path' => '/', 'placement' => 'header'],
|
['label' => 'Start', 'path' => '/', 'placement' => 'header'],
|
||||||
['label' => 'Prävention', 'path' => '/praevention', 'placement' => 'header'],
|
['label' => 'Prävention', 'path' => '/praevention', 'placement' => 'header'],
|
||||||
['label' => 'Materialien', 'path' => '/materialien', 'placement' => 'header'],
|
['label' => 'Materialien', 'path' => '/materialien', 'placement' => 'header'],
|
||||||
['label' => 'Angebote', 'path' => '/angebote', 'placement' => 'header'],
|
['label' => 'Shop', 'url' => '/shop', 'placement' => 'header'],
|
||||||
['label' => 'Trainer und Einrichtungen', 'path' => '/trainer', 'placement' => 'header'],
|
['label' => 'Trainer und Einrichtungen', 'path' => '/trainer', 'placement' => 'header'],
|
||||||
['label' => 'Über das Projekt', 'path' => '/ueber', 'placement' => 'header'],
|
['label' => 'Über das Projekt', 'path' => '/ueber', 'placement' => 'header'],
|
||||||
['label' => 'Anmelden', 'url' => '/anmelden', 'placement' => 'header'],
|
['label' => 'Anmelden', 'url' => '/anmelden', 'placement' => 'header'],
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public function run(): void
|
|||||||
$starter = $bundles->publish($bundle, [$konflikteArticle->fresh(), $grenzenArticle->fresh(), $starterArticle->fresh()]);
|
$starter = $bundles->publish($bundle, [$konflikteArticle->fresh(), $grenzenArticle->fresh(), $starterArticle->fresh()]);
|
||||||
$paket = $offers->create('Starterpaket: Privatlizenz');
|
$paket = $offers->create('Starterpaket: Privatlizenz');
|
||||||
$offers->activate($paket, [['target' => $starter, 'rights' => $privat]], ['grant_kind' => 'kauf', 'price_cents' => 5900, 'holder_kind' => 'person', 'licence_scope' => LicenceScope::SINGLE, 'trainer_count' => 1]);
|
$offers->activate($paket, [['target' => $starter, 'rights' => $privat]], ['grant_kind' => 'kauf', 'price_cents' => 5900, 'holder_kind' => 'person', 'licence_scope' => LicenceScope::SINGLE, 'trainer_count' => 1]);
|
||||||
$offers->assignProduct($paket, $starterVersion->composition_id, 'Starterpaket (zwei Programme und Einführung)');
|
$offers->setOptionLabel($paket, 'Starterpaket (zwei Programme und Einführung)');
|
||||||
|
|
||||||
$tina = $this->account('Tina Trainerin', 'tina.trainerin@example.test');
|
$tina = $this->account('Tina Trainerin', 'tina.trainerin@example.test');
|
||||||
$vera = $this->account('Vera Vorstand', 'vera.vorstand@example.test');
|
$vera = $this->account('Vera Vorstand', 'vera.vorstand@example.test');
|
||||||
@@ -171,7 +171,7 @@ private function offer(OfferService $offers, string $name, string $label, Compos
|
|||||||
'licence_scope' => $scope,
|
'licence_scope' => $scope,
|
||||||
'trainer_count' => $trainers,
|
'trainer_count' => $trainers,
|
||||||
]);
|
]);
|
||||||
$offers->assignProduct($offer, $version->composition_id, $label);
|
$offers->setOptionLabel($offer, $label);
|
||||||
|
|
||||||
return $offer;
|
return $offer;
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 183 KiB |
|
Before Width: | Height: | Size: 172 KiB |
|
Before Width: | Height: | Size: 79 KiB |
@@ -1,9 +0,0 @@
|
|||||||
# PowerPoint – technische Verwendung
|
|
||||||
|
|
||||||
- Einfügen > Bilder > Dieses Gerät: SVG auswählen (aktuelle Desktop-Versionen von Microsoft 365 / PowerPoint). Seitenverhältnis sperren, nicht verzerren.
|
|
||||||
- Für A5 als Startwert 10–12 mm für einfache Symbole, 14–16 mm für komplexere Motive verwenden. Beschriftung als echten Text daneben setzen.
|
|
||||||
- SVG bevorzugen; PNG (256 × 256, transparent) nur als Kompatibilitätsalternative.
|
|
||||||
- Farben nicht beliebig über Grafikfüllung ersetzen: semantische Akzente erhalten.
|
|
||||||
- PDF-Export und Probedruck prüfen, insbesondere Gelb auf Weiß und Graustufen.
|
|
||||||
- Die tatsächliche Trainerkarte und die verwendete PowerPoint-Version lagen nicht vor; Einfügen und Druck wurden nicht praktisch getestet.
|
|
||||||
- Microsoft-Hilfe: https://support.microsoft.com/de-de/office/bearbeiten-von-svg-bildern-in-microsoft-365-69f29d39-194a-4072-8c35-dbe5e7ea528c
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
# Prüfbericht v0.2 – Entwurf, nicht freigegeben
|
|
||||||
|
|
||||||
Grundlage: die 50 SVGs und Symbolmatrix aus v0.1. Bestand unverändert, R-Vorschaubilder sind Rekonstruktionen; Originale nicht Bestandteil des Pakets. 13 neue Dateien, 63 Motive in der Übersicht (inkl. vier nicht ausgewählter Alternativen). Farbwerte und 64×64-Raster aus v0.1 übernommen; keine neue Markenfreigabe.
|
|
||||||
|
|
||||||
Technisch: XML-Parsing und Rendern aller 13 SVGs erfolgreich, ausschließlich SVG-Pfade und Kreise, keine Rasterbilder, keine Schriftobjekte, transparente Fläche. 3,2 Einheiten Grundstrichstärke; stärkere Notfallmarkierung. Die A5-Vorschau (PNG, 300 dpi) zeigt nominelle SVG-Rahmen von 10 und 15 mm sowie eine monochrome 15-mm-Fassung. Tatsächlicher Druck und PowerPoint-Import nicht durchgeführt. Die Vorschauen sind keine Ersatz-Vektordateien. In PowerPoint über Einfügen > Bilder > Dieses Gerät importieren und Seitenverhältnis beibehalten.
|
|
||||||
|
|
||||||
| Motiv | Visueller Befund / verbleibender Vorbehalt |
|
|
||||||
|---|---|
|
|
||||||
| Gefühle | Herz im Körper klar; Unwohlsein allein nicht eindeutig, Textlabel nötig. |
|
|
||||||
| Weggehen | Gehfigur und Richtung klar; keine Notfallsituation impliziert. |
|
|
||||||
| Vertrauensperson | Person mit bestätigender Sprechblase; könnte auch als Beratung gelesen werden, Textlabel nötig. |
|
|
||||||
| Übung unterbrechen | Ausstieg klar, Übungskontext nur durch Beschriftung. |
|
|
||||||
| Absprachen | Handschlag erkennbar, bei 10 mm komplexer; 15 mm bevorzugt. |
|
|
||||||
| Akute Gefahr | Dreieck mit Ausrufezeichen auch monochrom eindeutig als Warnung, Dringlichkeitsstufe per Text. |
|
|
||||||
| Konflikt | Zwei Beteiligte mit Sprechblasen und Blitz; 15 mm bevorzugt, keine Gewalt. |
|
|
||||||
| Geheimnisse | Offenes Schloss in Sprechblase; kann auch Datenschutz bedeuten, Textlabel nötig. |
|
|
||||||
| Zivilcourage | Zuwendung erkennbar, konkretes Eingreifen nicht eindeutig, Textlabel nötig. |
|
|
||||||
| Rollenspiel A | Zwei gestikulierende Figuren mit Spielfläche und Sprechblase, vom Partnerübungsmotiv unterscheidbar; könnte auch Gespräch heißen. |
|
|
||||||
| Freiwilligkeit A | Zwei gleichwertige Optionen an einer Person; abstrakt, ohne Label nicht ausreichend eindeutig. Nicht zur automatischen Übernahme empfohlen. |
|
|
||||||
| Kinderreaktion A | Neutraler Ausdruck und Signalstrahlen, keine negative Wertung; unerwartete Reaktion nur mit Label eindeutig. |
|
|
||||||
| Deeskalation A | Gezackte und ruhige Linie in Sprechblase, unterscheidbar von Streit; medizinische Kurvenassoziation möglich. Nicht ohne Label verwenden. |
|
|
||||||
|
|
||||||
Keine Nutzer-Verständlichkeitsstudie; visuelle Prüfung ersetzt diese nicht. Gelb ist auf Weiß in Kleinstformat kontrastärmer; keine Bedeutung ausschließlich durch Gelb oder Grün vermitteln. Für alle pädagogischen Funktionen sind kurze Textlabels sinnvoll. Alternative Motive bleiben bis zur ausdrücklichen Auswahl parallel bestehen. Nach Freigabe übergreifend im bestehenden ADR-36 dokumentieren, nicht vorher.
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
# Prüfbericht v0.3
|
|
||||||
|
|
||||||
**Prüfstand: 24.11.2026. Entwurf, keine praktische Endabnahme.**
|
|
||||||
|
|
||||||
## 1. Tatsächlich geprüfte Eigenschaften
|
|
||||||
|
|
||||||
| Prüfung | Ergebnis |
|
|
||||||
|---|---|
|
|
||||||
| Quellbestand | Beide Ausgangsarchive gelesen; 50 SVG-Dateien v0.1 und 13 SVG-Dateien v0.2 mit Matrix zugeordnet. |
|
|
||||||
| Bestandsschutz | Alle 63 Quelldateien bytegenau wiedergefunden: 54 im regulären Ordner, 4 bei Alternativen, 5 in der Historie. |
|
|
||||||
| Neue Korrekturen | Exakt fünf versionierte SVG-Dateien, keine zusätzlichen Funktionen/Motive. |
|
|
||||||
| Vektorgrafik | Alle 68 SVG-Dateien als XML geparst und gerendert. Keine eingebetteten Rasterbilder, SVG-Textobjekte, Scripts oder foreignObject-Elemente. Gemeinsame ViewBox 64 × 64. |
|
|
||||||
| Markenstil | Fünf K3-Entwürfe mit unveränderter 3,2er-Konturstärke, dunkelblauen Konturen, grünen beziehungsweise gelben Akzenten, runden Linienenden und transparentem Hintergrund. |
|
|
||||||
| Sichtprüfung | Vergleichstafel der fünf Korrekturen, Vergleich verwandter Motive und Gesamtfamilie betrachtet. Überlagernde Signallinien im Gefühlesymbol vereinfacht, Sitzfigur in Freiwilligkeit verbessert. |
|
|
||||||
| Kleinformat | Bei 118 px (ca. 10 mm) und 177 px (ca. 15 mm) mit 300 dpi gerendert; zusätzlich monochrom bei 15 mm. Finale A5-Tafel visuell betrachtet. |
|
|
||||||
| PowerPoint-Dateistruktur | A4 quer, genau zwei Folien mit 30 bzw. 29 ungruppierten Picture-Objekten. Für jedes eine eigenständige eingebettete SVG-Image-Relationship (`asvg:svgBlip`), exakte SVG-Bytes und PNG-Kompatibilitätsfallback. ZIP-Integrität und Wiederöffnung mit python-pptx geprüft. |
|
|
||||||
| PowerPoint-Rendering | PPTX tatsächlich in LibreOffice Impress gerendert; beide finalen Folienbilder betrachtet. Alle Symbole sichtbar, keine erkennbaren Überlappungen oder abgeschnittenen Beschriftungen. Ungewollte Wortumbrüche und Schattierungen der Trennlinien aus Erstentwurf korrigiert. |
|
|
||||||
| Text und Auswahl | Beschriftungen sind separate bearbeitbare Textfelder. Grafiken sind eigene benannte Bildobjekte, nicht Teil eines Folien-Screenshots und nicht zusammengefasst. |
|
|
||||||
|
|
||||||
## 2. Semantische Bewertung der fünf Korrekturen
|
|
||||||
|
|
||||||
| Korrektur | Befund bei 10–15 mm | Verbleibende Einschränkung |
|
|
||||||
|---|---|---|
|
|
||||||
| Gefühle / Unwohlsein | Körper und innere Wellenlinie klarer als das ursprüngliche Herzmotiv; reduzierte Linienzahl. | Innere Körpersignale statt konkreter Emotion. Kann körperliches Unwohlsein/Schmerz bedeuten; kurze Beschriftung erforderlich. |
|
|
||||||
| Vertrauensperson | Zwei gleichwertige Personen und gemeinsames Herz; deutlich anderer Aufbau als Hilferuf, Schutzschild oder berührende Hilfsgeste. | Ohne Text eher zwischenmenschliche Verbundenheit/Fürsorge als spezifisch Vertrauen. Beschriftung erforderlich. |
|
|
||||||
| Übung unterbrechen | Zwei Figuren mit deutlich sichtbarem Pausenzeichen; kein Ausgangspfeil. | Unterbrechen gut erkennbar, das Recht auf freiwilliges Beenden folgt aus dem pädagogischen Kontext, nicht allein dem Pausenzeichen. |
|
|
||||||
| Freiwilligkeit | Aktive stehende und sitzende Figur als gleichwertige Optionen; auch in S/W unterscheidbar. | Wahlfreiheit ist abstrakt. Bei 10 mm ist die Sitzposition kleinteilig; bevorzugt 15 mm mit Beschriftung. |
|
|
||||||
| Unerwartete Kinderreaktion | Neutraler und lächelnder Gesichtsausdruck statt negativer Emotion, Signalstrahlen als Aufmerksamkeitsimpuls; auch monochrom unterscheidbar. | Vermittelt unterschiedliche Reaktionen; „unerwartet“ und weitere Verhaltensweisen benötigen Kontext. |
|
|
||||||
|
|
||||||
**Rollenspiel und Deeskalation:** Bestehende v0.1-Symbole bleiben in der Hauptauswahl. Die v0.2-Alternativen bleiben getrennt. Die Rollenspiel-Alternative mit zwei interagierenden Figuren ähnelt nun zusätzlich dem K3-Motiv „Übung unterbrechen“; Sprechblase und Pausenzeichen unterscheiden beide, eine Übernahme sollte trotzdem erst nach Nutzerprüfung erfolgen. Keine Neugestaltung anderer Symbole.
|
|
||||||
|
|
||||||
## 3. Nicht geprüft / nicht abschließend geklärt
|
|
||||||
|
|
||||||
- Tatsächliche Interaktion in Microsoft PowerPoint unter Windows (Anklicken, Kopieren in die konkrete Trainerkarte, Größenänderung, Speichern/Wiederöffnen im dortigen Office). Die ungruppierten SVG-Picture-Objekte erfüllen die strukturelle Voraussetzung, das tatsächliche Verhalten in der Zielinstallation ist damit noch nicht praktisch nachgewiesen. PNG-Kompatibilitätsfallback ist kein Ersatz für das SVG; ältere Office-Versionen können allerdings nur den Fallback anzeigen.
|
|
||||||
- Physischer A5-Probedruck. Die Druckvorschau ist als A5 quer bei 300 dpi angelegt und bei 100 % zu drucken; Monitorzoom ist kein Maßstab.
|
|
||||||
- Verständlichkeit ohne Beschriftung durch unabhängige Trainer/Kinder, insbesondere abstrakte pädagogische Begriffe. Die Sichtbewertung ist eine redaktionelle Einschätzung, keine Nutzerstudie.
|
|
||||||
- Original-R-SVGs aus dem Brand-Kit lagen nicht vor; Übereinstimmung mit ihnen konnte nicht geprüft werden. 16 Rekonstruktionen sind im regulären Arbeitsbestand und in der Matrix als R gekennzeichnet.
|
|
||||||
- Praktische Abnahme an „Lara im Park“ und formale Freigabe bleiben dem Auftraggeber vorbehalten.
|
|
||||||
|
|
||||||
## 4. Empfohlene Abnahme
|
|
||||||
|
|
||||||
In der realen Trainerkarte „Lara im Park“ die fünf relevanten K3-Motive in passenden Kontexten ausprobieren, drei SVGs aus der Arbeits-PowerPoint kopieren und in 10/15 mm skalieren; einmal bei 100 % drucken. Auf Erkennbarkeit, Textabstand, Konsistenz und SVG-Erhalt nach Speichern/Wiederöffnen achten. Danach die bestätigten Originale und Korrekturen als versionierte zentrale Symbolbibliothek festlegen.
|
|
||||||
|
Before Width: | Height: | Size: 110 KiB |
|
Before Width: | Height: | Size: 323 KiB |
|
Before Width: | Height: | Size: 239 KiB |
|
Before Width: | Height: | Size: 352 KiB |
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>Deeskalation – Alternative</title><path d="M5 8 H59 V37 H42 L32 47 V37 H5 Z" stroke="#08264D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 22 H17 L21 13 L26 30 L31 22" stroke="#08264D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M35 22 Q40 17 45 22 T55 22" stroke="#397D0D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M24 55 H40" stroke="#397D0D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 659 B |
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>Freiwilligkeit – Alternative</title><circle cx="32" cy="12" r="6" stroke="#08264D" stroke-width="3.2" fill="none"/><path d="M21 55 V37 Q21 26 32 26 Q43 26 43 37 V55 M21 34 L10 28 M43 34 L54 28" stroke="#08264D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><circle cx="8" cy="19" r="5" stroke="#397D0D" stroke-width="3.2" fill="none"/><circle cx="56" cy="19" r="5" stroke="#397D0D" stroke-width="3.2" fill="none"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 545 B |
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>Unerwartete Kinderreaktion – Alternative</title><circle cx="27" cy="32" r="20" stroke="#08264D" stroke-width="3.2" fill="none"/><path d="M19 28 V29 M35 28 V29 M21 40 H33" stroke="#08264D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M49 9 L54 4 M52 17 L60 15 M49 24 L57 28" stroke="#FFCD00" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 511 B |
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>Rollenspiel – Alternative</title><circle cx="15" cy="14" r="5" stroke="#08264D" stroke-width="3.2" fill="none"/><circle cx="49" cy="14" r="5" stroke="#08264D" stroke-width="3.2" fill="none"/><path d="M15 23 V40 M15 40 L8 52 M15 40 L22 52 M15 27 L6 34 M15 27 L27 22 M49 23 V40 M49 40 L42 52 M49 40 L56 52 M49 27 L37 34 M49 27 L56 33" stroke="#08264D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 59 H59 M25 5 H39 V13 H34 L30 18 V13 H25 Z" stroke="#397D0D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 678 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>Alltagsnah</title><path d="M32 22 Q33 15 39 15 Q40 5 49 7 Q57 8 57 17 Q64 20 60 30 Q57 36 50 34 M49 23 V53" stroke="#397D0D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M4 32 L24 13 L44 32 M8 29 V53 H40 V29 M19 53 V38 H29 V53 M4 53 H59" stroke="#08264D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||||
|
After Width: | Height: | Size: 473 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>Altersgerecht</title><g fill="none" stroke="#08264D" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 31 C11 38 16 42 21 42 C27 42 32 37 31 30 L30 27"/><circle cx="46" cy="32" r="9"/><path d="M37 28 C34 22 32 25 30 29 M55 28 C58 22 60 25 62 29"/><path d="M6 56 C6 48 12 43 20.5 43 C28 43 33 49 33 56 C33 49 38 43 46 43 C54 43 60 49 60 56"/><path d="M19 36 Q21 38 24 36 M43 36 Q46 38 49 36" stroke-width="1.5"/></g><g fill="none" stroke="#397D0D" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 30 C11 23 16 19 21 19 C26 19 30 23 31 27 M5 31 L31 27"/></g><g fill="none" stroke="#FFCD00" stroke-width="3.2" stroke-linecap="round"><path d="M27 13 L23 8 M32 11 V4 M38 13 L42 8"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 837 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>Ausgrenzung</title><circle cx="11" cy="23" r="5.5" stroke="#08264D" stroke-width="3.2" fill="none"/><circle cx="25" cy="23" r="5.5" stroke="#08264D" stroke-width="3.2" fill="none"/><path d="M3 49 V41 Q3 31 11 31 Q20 31 20 41 V49 M20 41 Q20 31 25 31 Q33 31 33 41 V49" stroke="#08264D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M41 13 Q31 30 39 53" stroke="#08264D" stroke-width="3.2" fill="none" stroke-dasharray="4 5" stroke-linecap="round" stroke-linejoin="round"/><circle cx="51" cy="33" r="5.5" stroke="#397D0D" stroke-width="3.2" fill="none"/><path d="M42 53 Q42 42 51 42 Q60 42 60 53" stroke="#397D0D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||||
|
After Width: | Height: | Size: 828 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>Eltern</title><circle cx="15" cy="19" r="7" stroke="#08264D" stroke-width="3.2" fill="none"/><circle cx="49" cy="19" r="7" stroke="#08264D" stroke-width="3.2" fill="none"/><path d="M4 48 V42 C4 27 24 27 26 37 M60 48 V42 C60 27 40 27 38 37" stroke="#08264D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><circle cx="32" cy="32" r="5.5" stroke="#397D0D" stroke-width="3.2" fill="none"/><path d="M21 53 V51 C21 35 43 35 43 51 V53" stroke="#397D0D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M24 8 L21 4 M32 7 V2 M40 8 L43 4" stroke="#FFCD00" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||||
|
After Width: | Height: | Size: 792 B |
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<svg baseProfile="full" height="64" version="1.1" viewBox="0 0 64 64" width="64" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink"><defs /><circle cx="20" cy="23" fill="none" r="9" stroke="#08264D" stroke-width="3.2" /><circle cx="43" cy="23" fill="none" r="9" stroke="#08264D" stroke-width="3.2" /><circle cx="17" cy="21" fill="#08264D" r="1.2" /><circle cx="23" cy="21" fill="#08264D" r="1.2" /><circle cx="40" cy="21" fill="#08264D" r="1.2" /><circle cx="46" cy="21" fill="#08264D" r="1.2" /><path d="M16 27 Q20 30.2 24 27" fill="none" stroke="#08264D" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.9" /><path d="M39 27 Q43 30.2 47 27" fill="none" stroke="#08264D" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.9" /><path d="M5 53 Q5 40 14 36" fill="none" stroke="#397D0D" stroke-linecap="round" stroke-width="3.2" /><path d="M54 43 Q60 47 60 53" fill="none" stroke="#397D0D" stroke-linecap="round" stroke-width="3.2" /><path d="M30 53 L27 40 Q29 36 35 35" fill="none" stroke="#08264D" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.2" /><path d="M50 34 Q60 36 57 42 Q54 47 48 43 Q45 41 48 36" fill="none" stroke="#08264D" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.2" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="51" x2="53" y1="8" y2="3" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="56" x2="61" y1="12" y2="8" /></svg>
|
||||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>Geschützt</title><circle cx="32" cy="23" r="6" stroke="#397D0D" stroke-width="3.2" fill="none"/><path d="M21 39 Q23 30 32 30 Q41 30 43 39" stroke="#397D0D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M17 59 V53 L7 44 L4 33 Q3 29 6 28 Q10 27 11 32 L13 41 L23 49 M27 59 V51 Q27 46 22 42 L16 37 Q12 36 13 41 L20 47 M47 59 V53 L57 44 L60 33 Q61 29 58 28 Q54 27 53 32 L51 41 L41 49 M37 59 V51 Q37 46 42 42 L48 37 Q52 36 51 41 L44 47" stroke="#08264D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M23 12 L19 7 M32 10 V3 M41 12 L45 7" stroke="#FFCD00" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||||
|
After Width: | Height: | Size: 808 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>Gewaltschutztrainer</title><circle cx="17" cy="15" r="8" stroke="#08264D" stroke-width="3.2" fill="none"/><path d="M3 53 V39 Q3 28 12 25 M24 25 Q28 26 30 29 M35 26 Q44 24 49 20 Q54 24 61 26 V37 Q60 49 49 56 Q37 49 35 37 Z" stroke="#08264D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M10 26 L17 40 L24 26 M17 45 V50" stroke="#397D0D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><circle cx="17" cy="42" r="3" stroke="#397D0D" stroke-width="3.2" fill="none"/><path d="M43 39 V34 Q43 32 45 32 V38 V29 Q47 27 48 29 V37 V27 Q50 25 51 28 V37 V30 Q53 28 54 31 V39 Q54 46 49 46 Q44 46 41 40 Q40 37 43 39 Z" stroke="#397D0D" stroke-width="1.8" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M51 12 L53 6 M57 15 L61 11" stroke="#FFCD00" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||||
|
After Width: | Height: | Size: 1003 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>Gruppen</title><circle cx="32" cy="14" r="7" stroke="#397D0D" stroke-width="3.2" fill="none"/><circle cx="12" cy="22" r="6" stroke="#08264D" stroke-width="3.2" fill="none"/><circle cx="52" cy="22" r="6" stroke="#08264D" stroke-width="3.2" fill="none"/><path d="M3 48 Q3 32 18 32 M61 48 Q61 32 46 32 M17 50 V44 C17 24 47 24 47 44 V50 Z" stroke="#08264D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||||
|
After Width: | Height: | Size: 528 B |
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<svg baseProfile="full" height="64" version="1.1" viewBox="0 0 64 64" width="64" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink"><defs /><path d="M14 14 H50 V38 H29 L20 47 V38 H14 Z" fill="none" stroke="#08264D" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.2" /><circle cx="24" cy="26" fill="#397D0D" r="2.2" /><line stroke="#397D0D" stroke-linecap="round" stroke-width="3.2" x1="31" x2="43" y1="26" y2="26" /><line stroke="#397D0D" stroke-linecap="round" stroke-width="3.2" x1="31" x2="38" y1="32" y2="32" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="46" x2="50" y1="12" y2="8" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="50" x2="55" y1="18" y2="17" /></svg>
|
||||||
|
After Width: | Height: | Size: 845 B |
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<svg baseProfile="full" height="64" version="1.1" viewBox="0 0 64 64" width="64" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink"><defs /><circle cx="32" cy="28" fill="none" r="15" stroke="#08264D" stroke-width="3.2" /><circle cx="32" cy="21" fill="#397D0D" r="1.8" /><line stroke="#397D0D" stroke-linecap="round" stroke-width="3.2" x1="32" x2="32" y1="27" y2="38" /><line stroke="#08264D" stroke-linecap="round" stroke-width="3.2" x1="28" x2="36" y1="42" y2="42" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="43" x2="48" y1="16" y2="12" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="46" x2="52" y1="22" y2="21" /></svg>
|
||||||
|
After Width: | Height: | Size: 784 B |
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<svg baseProfile="full" height="64" version="1.1" viewBox="0 0 64 64" width="64" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink"><defs /><rect fill="none" height="20" rx="2" ry="2" stroke="#08264D" stroke-width="3.2" width="40" x="12" y="28" /><path d="M10 28 L32 15 L54 28" fill="none" stroke="#08264D" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.2" /><rect fill="none" height="12" stroke="#397D0D" stroke-width="3.2" width="8" x="28" y="36" /><line stroke="#397D0D" stroke-linecap="round" stroke-width="3.2" x1="19" x2="24" y1="40" y2="40" /><line stroke="#397D0D" stroke-linecap="round" stroke-width="3.2" x1="18" x2="24" y1="35" y2="35" /><path d="M40 38 Q42 32 47 35" fill="none" stroke="#397D0D" stroke-linecap="round" stroke-width="3.2" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="44" x2="47" y1="14" y2="9" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="49" x2="53" y1="17" y2="15" /></svg>
|
||||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<svg baseProfile="full" height="64" version="1.1" viewBox="0 0 64 64" width="64" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink"><defs /><path d="M12 22 Q32 14 52 22" fill="none" opacity="0.95" stroke="#FFCD00" stroke-linecap="round" stroke-linejoin="round" stroke-width="4.4" /><path d="M14 27 Q32 20 50 27" fill="none" opacity="0.95" stroke="#FFCD00" stroke-linecap="round" stroke-linejoin="round" stroke-width="4.4" /><path d="M16 32 Q32 26 48 32" fill="none" opacity="0.95" stroke="#FFCD00" stroke-linecap="round" stroke-linejoin="round" stroke-width="4.4" /><path d="M27 17 L37 17 L37 39 L32 34 L27 39 Z" fill="none" stroke="#08264D" stroke-linejoin="round" stroke-width="3.2" /></svg>
|
||||||
|
After Width: | Height: | Size: 805 B |
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<svg baseProfile="full" height="64" version="1.1" viewBox="0 0 64 64" width="64" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink"><defs /><circle cx="13" cy="19" fill="none" r="6.5" stroke="#08264D" stroke-width="3.2" /><circle cx="51" cy="19" fill="none" r="6.5" stroke="#08264D" stroke-width="3.2" /><path d="M3 36 Q4 28 13 27" fill="none" stroke="#08264D" stroke-linecap="round" stroke-width="3.2" /><path d="M61 36 Q60 28 51 27" fill="none" stroke="#08264D" stroke-linecap="round" stroke-width="3.2" /><circle cx="32" cy="32" fill="none" r="8" stroke="#08264D" stroke-width="3.2" /><circle cx="29" cy="30" fill="#08264D" r="1.2" /><circle cx="35" cy="30" fill="#08264D" r="1.2" /><path d="M28 36.8 Q32 33.8 36 36.8" fill="none" stroke="#08264D" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" /><path d="M19 55 Q22 43 32 43 Q42 43 45 55" fill="none" stroke="#08264D" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.2" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="28" x2="26" y1="12" y2="5" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="34" x2="37" y1="12" y2="5" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="39" x2="45" y1="16" y2="12" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="16" x2="21" y1="36" y2="40" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="13" x2="20" y1="45" y2="45" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="48" x2="43" y1="36" y2="40" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="51" x2="44" y1="45" y2="45" /></svg>
|
||||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>Nachhaltigkeit</title><path d="M7 31 A25 25 0 0 1 53 17 M53 9 V18 L44 15 M57 32 A25 25 0 0 1 11 47 M11 55 V46 L20 49" stroke="#397D0D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M24 41 C15 27 35 28 43 19 C46 37 35 48 24 41 Z M22 46 Q25 35 35 30" stroke="#08264D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||||
|
After Width: | Height: | Size: 483 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>Öffentliche Einrichtungen</title><path d="M5 23 L32 8 L59 23 Q59 25 56 25 H8 Q5 25 5 23 Z M10 29 H54 M12 49 H52 M10 53 H54 M14 29 V49 M21 29 V49 M28 29 V49 M36 29 V49 M43 29 V49 M50 29 V49" stroke="#08264D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M5 58 H59" stroke="#397D0D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||||
|
After Width: | Height: | Size: 499 B |
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<svg baseProfile="full" height="64" version="1.1" viewBox="0 0 64 64" width="64" xmlns="http://www.w3.org/2000/svg" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:xlink="http://www.w3.org/1999/xlink"><defs /><path d="M18 14 L46 20 V34 Q46 47 32 53 Q18 47 18 34 Z" fill="none" stroke="#08264D" stroke-linejoin="round" stroke-width="3.2" /><path d="M24 35 L30 29 L35 34 L42 25" fill="none" stroke="#397D0D" stroke-linecap="round" stroke-linejoin="round" stroke-width="3.2" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="30" x2="28" y1="12" y2="7" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="36" x2="38" y1="12" y2="7" /><line stroke="#FFCD00" stroke-linecap="round" stroke-width="3.2" x1="42" x2="46" y1="15" y2="12" /></svg>
|
||||||
|
After Width: | Height: | Size: 818 B |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64"><title>Praxiserprobt</title><path d="M33.80 9.07 L38.07 6.72 L41.95 7.98 L44.02 12.39 L46.94 14.51 L51.77 15.11 L54.17 18.42 L53.25 23.20 L54.36 26.63 L57.92 29.96 L57.92 34.04 L54.36 37.37 L53.25 40.80 L54.17 45.58 L51.77 48.89 L46.94 49.49 L44.02 51.61 L41.95 56.02 L38.07 57.28 L33.80 54.93 L30.20 54.93 L25.93 57.28 L22.05 56.02 L19.98 51.61 L17.06 49.49 L12.23 48.89 L9.83 45.58 L10.75 40.80 L9.64 37.37 L6.08 34.04 L6.08 29.96 L9.64 26.63 L10.75 23.20 L9.83 18.42 L12.23 15.11 L17.06 14.51 L19.98 12.39 L22.05 7.98 L25.93 6.72 L30.20 9.07 Z" stroke="#08264D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/><path d="M21 32 L29 40 L44 24" stroke="#397D0D" stroke-width="3.2" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||||
|
After Width: | Height: | Size: 860 B |