Integriere die Premium-Karten v1.7 als Themen-, Medien- und Programmkarte.
- Drei Widget-Arten (topic_card, media_card, program_card) auf gemeinsamer Basis, eine Karte je Platz im bestehenden Abschnittsraster; kein zweites Kartenraster. - Titel, Kurzbeschreibung, Art, Zusatzangaben und Linkziel kommen zur Laufzeit aus Thema, Inhaltselement bzw. Programm/Modul; im CMS stehen nur Kennungen, Bild, Bildausschnitt, Beschriftung und Hinweis. - Medienkarten sind öffentlich nur als Bestandteil eines öffentlichen Programms (PublicMaterialReader), Module nur in der Redaktionsvorschau; keine Bibliotheksbilder, kein Preis, keine Kaufaktion. - Gleiche Höhe je Zeile über die gemeinsame Höhe „fill“; Raster 1 + 1 + 2 und 2 + 1 + 1 ergänzt. - Tests zu Raster- und Widgetliste bewusst um die neuen Raster und Arten erweitert. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cca069be48
commit
127ea86817
16 files changed
+1579
-3
No files matched your search
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Types;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
|
||||
/**
|
||||
* Medien- und Materialkarte (Kit v1.7 „media“): ein Inhaltselement (Film, Dokument, Hörstück …) mit Anzeigetitel,
|
||||
* Kurzbeschreibung, Inhaltsart und Ausgabeart. Öffentlich nur, wenn das Element zur gezeigten Fassung eines
|
||||
* öffentlichen Programms gehört (PublicMaterialReader); die Aktion führt dann auf diese Programmseite.
|
||||
* Die Karte spielt nichts ab, bietet keinen Download und gibt kein geschütztes Medium frei.
|
||||
*/
|
||||
class MediaCardWidget extends PremiumCardWidget
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'media_card';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Medien- und Materialkarte';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Karte zu einem Film oder Material aus der Bibliothek; Titel und Art kommen aus den Fachdaten, kein Abspielen, kein Download.';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-film';
|
||||
}
|
||||
|
||||
public function schematic(): array
|
||||
{
|
||||
return [[2, 2, 56, 32, 'line'], [5, 5, 22, 26, 'image'], [7, 7, 8, 3, 'accent'], [31, 8, 22, 4, 'ink'], [31, 15, 22, 5, 'line'], [31, 25, 14, 5, 'accent']];
|
||||
}
|
||||
|
||||
protected function refKey(): string
|
||||
{
|
||||
return 'element';
|
||||
}
|
||||
|
||||
protected function refLabel(): string
|
||||
{
|
||||
return 'Medium oder Material';
|
||||
}
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
return 'Wählbar sind bereitgestellte, nicht archivierte Inhalte. Öffentlich erscheint die Karte nur, wenn der Inhalt zu einem öffentlich gezeigten Programm gehört; sonst nur in der Redaktionsvorschau.';
|
||||
}
|
||||
|
||||
protected function searchSubjects(?string $term): array
|
||||
{
|
||||
return app(PublicMaterialReader::class)->search($term);
|
||||
}
|
||||
|
||||
protected function subjectLabel(mixed $id): ?string
|
||||
{
|
||||
return app(PublicMaterialReader::class)->labelFor($id);
|
||||
}
|
||||
|
||||
protected function rejectSubject(int $id): ?string
|
||||
{
|
||||
$element = ContentElement::query()->find($id);
|
||||
|
||||
return $element !== null && app(PublicMaterialReader::class)->isSelectable($element)
|
||||
? null
|
||||
: 'Dieser Inhalt ist nicht bereitgestellt oder archiviert.';
|
||||
}
|
||||
|
||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||
{
|
||||
return app(PublicMaterialReader::class)->subject($id, includeNonPublic: $context->preview);
|
||||
}
|
||||
|
||||
protected function defaultActionLabel(): string
|
||||
{
|
||||
return 'Im Programm ansehen';
|
||||
}
|
||||
|
||||
protected function cardStyle(): string
|
||||
{
|
||||
return 'media';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Types;
|
||||
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Group;
|
||||
|
||||
/**
|
||||
* Gemeinsame Basis der Premium-Karten (Brand-UI-Kit v1.7, Entwurf zur visuellen Freigabe):
|
||||
* Redaktionelle Themenkarte, Medien- und Materialkarte, Modul- und Programmkarte.
|
||||
*
|
||||
* - Eine Karte je Widget, ein Widget je Platz. Das Raster ist das bestehende Abschnittsraster (1 bis 4 Einheiten);
|
||||
* es gibt kein zweites Kartenraster.
|
||||
* - refs: genau ein Fachobjekt (Kennung) und optional ein Bild aus dem öffentlichen Website-Bereich.
|
||||
* Titel, Kurzbeschreibung, Art, Zusatzangaben und Linkziel kommen zur Laufzeit aus den Fachdaten.
|
||||
* - data: nur Redaktionelles, das es im Fachobjekt nicht gibt: Beschriftung der Aktion, Hinweis, Alternativtext,
|
||||
* Bildausschnitt. Ein freies Linkziel gibt es nicht; das Ziel ist immer die öffentliche Seite des Fachobjekts.
|
||||
* - Bilder der Bibliothek (Vorschaubilder, Filmstandbilder) werden nie gezeigt.
|
||||
*/
|
||||
abstract class PremiumCardWidget extends WidgetType
|
||||
{
|
||||
public const SHOW = ['yes' => 'Anzeigen', 'no' => 'Ausblenden'];
|
||||
|
||||
/** Schlüssel des Fachobjekts in refs, zum Beispiel 'pillar'. */
|
||||
abstract protected function refKey(): string;
|
||||
|
||||
abstract protected function refLabel(): string;
|
||||
|
||||
abstract protected function refHelp(): string;
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
abstract protected function searchSubjects(?string $term): array;
|
||||
|
||||
abstract protected function subjectLabel(mixed $id): ?string;
|
||||
|
||||
/** Prüft beim Speichern, ob das Objekt gewählt werden darf; liefert sonst die Fehlermeldung. */
|
||||
abstract protected function rejectSubject(int $id): ?string;
|
||||
|
||||
abstract protected function subject(mixed $id, RenderContext $context): ?CardSubject;
|
||||
|
||||
abstract protected function defaultActionLabel(): string;
|
||||
|
||||
/** Gestaltungsvariante des Kits: editorial, media oder catalog. */
|
||||
abstract protected function cardStyle(): string;
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'widgets.premium_card';
|
||||
}
|
||||
|
||||
public function supportedUnits(): array
|
||||
{
|
||||
return [1, 2, 3, 4];
|
||||
}
|
||||
|
||||
public function preferredUnits(): int
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public function stages(): array
|
||||
{
|
||||
return [
|
||||
'stacked' => 'unter 520 px Kartenbreite: Bild oder Tafel über dem Text',
|
||||
'side' => 'ab 520 px: Bild links (42 %), Text rechts (58 %); das gewählte Bildformat bleibt erhalten',
|
||||
];
|
||||
}
|
||||
|
||||
public function narrowBehavior(): string
|
||||
{
|
||||
return 'Unter 520 px Kartenbreite steht das Bild über dem Text. Ab etwa 240 px nutzbar, empfohlen ab 280 px (eine Einheit ab Tablet). Texte werden nie gekürzt.';
|
||||
}
|
||||
|
||||
public function heights(): array
|
||||
{
|
||||
return [
|
||||
'auto' => 'Natürliche Höhe',
|
||||
'fill' => 'An die Zeile angleichen',
|
||||
];
|
||||
}
|
||||
|
||||
public function variants(): array
|
||||
{
|
||||
return [
|
||||
'adaptive' => 'Anpassend (ab 520 px Bild neben Text)',
|
||||
'stacked' => 'Bild immer über dem Text',
|
||||
];
|
||||
}
|
||||
|
||||
public function optionIcons(): array
|
||||
{
|
||||
return [
|
||||
'variant' => ['adaptive' => 'heroicon-o-view-columns', 'stacked' => 'heroicon-o-bars-3-bottom-left'],
|
||||
'height' => ['auto' => 'heroicon-o-arrows-pointing-in', 'fill' => 'heroicon-o-arrows-up-down'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
'format' => ['landscape' => 'Querformat 16:9', 'square' => 'Quadrat 1:1', 'portrait' => 'Hochformat 3:4'],
|
||||
'fit' => ['cover' => 'Ausschnitt füllt die Fläche', 'contain' => 'Ganzes Bild zeigen (Dokument, Poster)'],
|
||||
'heading_level' => ['h3' => 'H3', 'h2' => 'H2', 'h4' => 'H4'],
|
||||
'show_summary' => self::SHOW,
|
||||
'show_kind' => self::SHOW,
|
||||
'show_meta' => self::SHOW,
|
||||
'show_action' => self::SHOW,
|
||||
];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'format' => ['Bildformat', 'Vorgabe: Querformat 16:9. Gilt auch neben dem Text; das Motiv wird nicht nachträglich hochkant beschnitten.'],
|
||||
'fit' => ['Bilddarstellung', 'Vorgabe: Ausschnitt. „Ganzes Bild“ zeigt Dokumente und Poster vollständig auf ruhiger Fläche.'],
|
||||
'heading_level' => ['Überschriftenebene', 'Vorgabe: H3, passend unter einer Abschnittsüberschrift (H2).'],
|
||||
'show_summary' => ['Kurzbeschreibung', 'Aus den Fachdaten. Vorgabe: anzeigen.'],
|
||||
'show_kind' => ['Art oder Label', 'Zum Beispiel „Thema“ oder „Merkblatt“. Vorgabe: anzeigen.'],
|
||||
'show_meta' => ['Zusatzangaben', 'Aus den Fachdaten, zum Beispiel Ausgabeart oder Programmzugehörigkeit. Vorgabe: anzeigen.'],
|
||||
'show_action' => ['Aktion', 'Verweis auf die öffentliche Seite des Fachobjekts, falls es eine gibt. Vorgabe: anzeigen.'],
|
||||
];
|
||||
}
|
||||
|
||||
public function dataRules(): array
|
||||
{
|
||||
return [
|
||||
'action_label' => ['nullable', 'string', 'max:60'],
|
||||
'note' => ['nullable', 'string', 'max:200'],
|
||||
'alt' => ['nullable', 'string', 'max:300'],
|
||||
'focus_x' => ['nullable', 'numeric', 'between:0,100'],
|
||||
'focus_y' => ['nullable', 'numeric', 'between:0,100'],
|
||||
];
|
||||
}
|
||||
|
||||
public function refRules(): array
|
||||
{
|
||||
return [$this->refKey() => ['required', 'integer']] + ImageRefFields::rules();
|
||||
}
|
||||
|
||||
public function dataFields(): array
|
||||
{
|
||||
return [
|
||||
TextInput::make('action_label')
|
||||
->label('Beschriftung der Aktion (optional)')
|
||||
->maxLength(60)
|
||||
->placeholder($this->defaultActionLabel())
|
||||
->live(onBlur: true)
|
||||
->helperText('Das Linkziel ist immer die öffentliche Seite des gewählten Objekts und kann nicht frei gesetzt werden.'),
|
||||
TextInput::make('note')
|
||||
->label('Hinweis (optional)')
|
||||
->maxLength(200)
|
||||
->live(onBlur: true)
|
||||
->helperText('Kurzer redaktioneller Satz über der Aktion, zum Beispiel „Für die nächste Kursstunde“. Begründet keine Berechtigung.'),
|
||||
PremiumFields::altField(),
|
||||
...PremiumFields::focusFields(66, 45),
|
||||
];
|
||||
}
|
||||
|
||||
public function refFields(): array
|
||||
{
|
||||
return [$this->subjectField(), ...ImageRefFields::fields(live: true)];
|
||||
}
|
||||
|
||||
public function editorSchema(): array
|
||||
{
|
||||
[$action, $note] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make([$this->subjectField()])->statePath('refs'),
|
||||
Group::make([$action, $note])->statePath('data'),
|
||||
];
|
||||
}
|
||||
|
||||
public function mediaSchema(): array
|
||||
{
|
||||
[, , $alt, $focusX, $focusY] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make(ImageRefFields::fields('Kartenbild', live: true))->statePath('refs'),
|
||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
||||
];
|
||||
}
|
||||
|
||||
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
{
|
||||
$key = $this->refKey();
|
||||
$id = (int) $refs[$key];
|
||||
$rejection = $this->rejectSubject($id);
|
||||
|
||||
if ($rejection !== null) {
|
||||
$errors->add("refs.$key", $rejection);
|
||||
}
|
||||
|
||||
$refs[$key] = $id;
|
||||
$refs = ImageRefFields::clean($refs, $errors);
|
||||
|
||||
foreach (['action_label', 'note', 'alt'] as $field) {
|
||||
$data[$field] = filled($data[$field] ?? null) ? trim((string) $data[$field]) : null;
|
||||
}
|
||||
|
||||
foreach (['focus_x', 'focus_y'] as $field) {
|
||||
$value = $data[$field] ?? null;
|
||||
$data[$field] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
||||
}
|
||||
|
||||
if ($refs['image'] !== null && $data['alt'] === null) {
|
||||
$errors->add('data.alt', 'Bitte einen Alternativtext für das Bild angeben.');
|
||||
}
|
||||
|
||||
return [$data, $refs];
|
||||
}
|
||||
|
||||
public function resolve(array $widget, RenderContext $context): array
|
||||
{
|
||||
$settings = $widget['settings'];
|
||||
$option = fn (string $key, string $default): string => is_string($settings[$key] ?? null) && isset($this->settingOptions()[$key][$settings[$key]]) ? $settings[$key] : $default;
|
||||
$data = $widget['data'];
|
||||
|
||||
return [
|
||||
'subject' => $this->subject($widget['refs'][$this->refKey()] ?? null, $context),
|
||||
'cardStyle' => $this->cardStyle(),
|
||||
'imageUrl' => PublicMedia::imageUrl($widget['refs']),
|
||||
'alt' => is_string($data['alt'] ?? null) ? $data['alt'] : '',
|
||||
'focus' => PremiumFields::focus($data, 66, 45),
|
||||
'format' => $option('format', 'landscape'),
|
||||
'fit' => $option('fit', 'cover'),
|
||||
'headingTag' => $option('heading_level', 'h3'),
|
||||
'show' => [
|
||||
'summary' => $option('show_summary', 'yes') === 'yes',
|
||||
'kind' => ! array_key_exists('show_kind', $this->settings()) || $option('show_kind', 'yes') === 'yes',
|
||||
'meta' => $option('show_meta', 'yes') === 'yes',
|
||||
'action' => $option('show_action', 'yes') === 'yes',
|
||||
],
|
||||
'actionLabel' => filled($data['action_label'] ?? null) ? (string) $data['action_label'] : $this->defaultActionLabel(),
|
||||
'note' => filled($data['note'] ?? null) ? (string) $data['note'] : null,
|
||||
'stacked' => $widget['variant'] === 'stacked',
|
||||
];
|
||||
}
|
||||
|
||||
public function mediaPaths(array $widget): array
|
||||
{
|
||||
$image = $widget['refs']['image'] ?? null;
|
||||
|
||||
return PublicMedia::isPublicPath($image) ? [$image] : [];
|
||||
}
|
||||
|
||||
public function summary(array $widget): string
|
||||
{
|
||||
$label = $this->subjectLabel($widget['refs'][$this->refKey()] ?? null);
|
||||
|
||||
return $label ?? 'Kein Objekt gewählt';
|
||||
}
|
||||
|
||||
private function subjectField(): Select
|
||||
{
|
||||
return Select::make($this->refKey())
|
||||
->label($this->refLabel())
|
||||
->helperText($this->refHelp())
|
||||
->required()
|
||||
->live()
|
||||
->searchable()
|
||||
->getSearchResultsUsing(fn (?string $search): array => $this->searchSubjects($search))
|
||||
->getOptionLabelUsing(fn (mixed $value): ?string => $this->subjectLabel($value))
|
||||
->options(fn (): array => $this->searchSubjects(null));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Types;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
|
||||
/**
|
||||
* Modul- und Programmkarte (Kit v1.7 „catalog“): ein Programm oder Modul über PublicCatalogReader, dieselbe
|
||||
* Freigaberegel wie die Programm- und Modulkarten (Programme öffentlich mit Programmseite, Module nur in der
|
||||
* Redaktionsvorschau). Die Art ist immer sichtbar benannt. Ohne Bild trägt eine Navy-Tafel die Art.
|
||||
* Kein Preis, kein Angebot, keine Kaufaktion; eine Karte ist kein Lizenzartikel.
|
||||
*/
|
||||
class ProgramCardWidget extends PremiumCardWidget
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'program_card';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Programm- oder Modulkarte';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Karte zu einem Programm oder Modul; Titel, Beschreibung und Art kommen aus den Fachdaten, ohne Preis und ohne Kaufaktion.';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-academic-cap';
|
||||
}
|
||||
|
||||
public function schematic(): array
|
||||
{
|
||||
return [[2, 2, 56, 32, 'line'], [5, 5, 22, 26, 'ink'], [8, 24, 10, 2, 'accent'], [31, 8, 10, 2, 'line'], [31, 13, 22, 4, 'ink'], [31, 25, 14, 5, 'ink']];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
// Die Art (Programm oder Modul) bleibt immer sichtbar; sie lässt sich nicht ausblenden.
|
||||
$settings = parent::settings();
|
||||
unset($settings['show_kind']);
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
protected function refKey(): string
|
||||
{
|
||||
return 'composition';
|
||||
}
|
||||
|
||||
protected function refLabel(): string
|
||||
{
|
||||
return 'Programm oder Modul';
|
||||
}
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
return 'Nur zur Anzeige freigegebene Programme und Module sind wählbar. Öffentlich erscheinen Programme mit Programmseite; Module nur in der Redaktionsvorschau.';
|
||||
}
|
||||
|
||||
protected function searchSubjects(?string $term): array
|
||||
{
|
||||
return app(PublicCatalogReader::class)->search($term);
|
||||
}
|
||||
|
||||
protected function subjectLabel(mixed $id): ?string
|
||||
{
|
||||
return app(PublicCatalogReader::class)->labelFor($id);
|
||||
}
|
||||
|
||||
protected function rejectSubject(int $id): ?string
|
||||
{
|
||||
$composition = Composition::query()->with('editorialContentKind')->find($id);
|
||||
|
||||
return $composition !== null && app(PublicCatalogReader::class)->isSelectable($composition)
|
||||
? null
|
||||
: 'Dieses Objekt ist kein zur Anzeige freigegebenes Programm oder Modul.';
|
||||
}
|
||||
|
||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||
{
|
||||
return app(PublicCatalogReader::class)->subject($id, includeNonPublic: $context->preview);
|
||||
}
|
||||
|
||||
protected function defaultActionLabel(): string
|
||||
{
|
||||
return 'Programm ansehen';
|
||||
}
|
||||
|
||||
protected function cardStyle(): string
|
||||
{
|
||||
return 'catalog';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Types;
|
||||
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
|
||||
/**
|
||||
* Redaktionelle Themenkarte (Kit v1.7 „editorial“): ein veröffentlichtes Thema (Säule) mit Name,
|
||||
* öffentlicher Kurzbeschreibung und Verweis auf die Themenseite /themen/{slug}. Ruhige Textaktion mit gelber
|
||||
* Unterstreichung. Ein nicht (mehr) veröffentlichtes Thema erscheint öffentlich nicht.
|
||||
*/
|
||||
class TopicCardWidget extends PremiumCardWidget
|
||||
{
|
||||
public function key(): string
|
||||
{
|
||||
return 'topic_card';
|
||||
}
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return 'Themenkarte';
|
||||
}
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Redaktionelle Karte zu einem veröffentlichten Thema; Name, Kurzbeschreibung und Ziel kommen aus dem Thema.';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
{
|
||||
return 'heroicon-o-bookmark-square';
|
||||
}
|
||||
|
||||
public function schematic(): array
|
||||
{
|
||||
return [[2, 2, 56, 32, 'line'], [5, 5, 22, 26, 'image'], [31, 8, 10, 2, 'accent'], [31, 13, 22, 4, 'ink'], [31, 20, 20, 3, 'line'], [31, 27, 12, 2, 'accent']];
|
||||
}
|
||||
|
||||
protected function refKey(): string
|
||||
{
|
||||
return 'pillar';
|
||||
}
|
||||
|
||||
protected function refLabel(): string
|
||||
{
|
||||
return 'Thema';
|
||||
}
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
return 'Nur veröffentlichte Themen sind wählbar. Name und Kurzbeschreibung pflegen Sie im Thema, nicht hier.';
|
||||
}
|
||||
|
||||
protected function searchSubjects(?string $term): array
|
||||
{
|
||||
$term = trim((string) $term);
|
||||
|
||||
return Pillar::query()
|
||||
->published()
|
||||
->when($term !== '', fn ($query) => $query->whereRaw('LOWER(name) LIKE ?', ['%'.mb_strtolower($term).'%']))
|
||||
->limit(25)
|
||||
->get()
|
||||
->mapWithKeys(fn (Pillar $pillar): array => [$pillar->id => $pillar->name.' · Thema'])
|
||||
->all();
|
||||
}
|
||||
|
||||
protected function subjectLabel(mixed $id): ?string
|
||||
{
|
||||
$pillar = is_numeric($id) ? Pillar::query()->find((int) $id) : null;
|
||||
|
||||
if ($pillar === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $pillar->name.' · Thema'.($pillar->published_at === null ? ' · nicht veröffentlicht' : '');
|
||||
}
|
||||
|
||||
protected function rejectSubject(int $id): ?string
|
||||
{
|
||||
return Pillar::query()->whereKey($id)->whereNotNull('published_at')->exists()
|
||||
? null
|
||||
: 'Dieses Thema ist nicht veröffentlicht.';
|
||||
}
|
||||
|
||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||
{
|
||||
$pillar = is_numeric($id) ? Pillar::query()->find((int) $id) : null;
|
||||
|
||||
if ($pillar === null || $pillar->published_at === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new CardSubject(
|
||||
title: (string) $pillar->name,
|
||||
summary: filled($pillar->public_summary) ? (string) $pillar->public_summary : null,
|
||||
kind: 'Thema',
|
||||
badge: null,
|
||||
meta: [],
|
||||
url: $pillar->publicUrl(),
|
||||
public: true,
|
||||
);
|
||||
}
|
||||
|
||||
protected function defaultActionLabel(): string
|
||||
{
|
||||
return 'Thema entdecken';
|
||||
}
|
||||
|
||||
protected function cardStyle(): string
|
||||
{
|
||||
return 'editorial';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user