Mache die Premium-Karten mit vorhandenen Fachobjekten nutzbar.
- Themenkarte: alle Säulen wählbar; nicht veröffentlichte nur in der Redaktionsvorschau. - Medienkarte: Kurzbeschreibung, Film (Filmtafel, Hinweis auf den geschützten Film) und Material (Materialsymbol) getrennt; Filmstandbild der Bibliothek nur in der Redaktionsvorschau, markiert; Entwürfe wählbar, gesperrte nicht; Traineranleitungen nie öffentlich. - Programm-/Modulkarte: Lernziel als Text, Dauer und Modulzahl; Programme/Module ohne Anzeigefreigabe für die Vorschau wählbar; Module weiterhin ohne Link. - Fehlende Inhalte nur in der Vorschau als eingeklappte Redaktionshinweise. - Tests bewusst angepasst: Medien zeigen jetzt die Kurzbeschreibung (Betreibervorgabe), unveröffentlichte Themen und Programme ohne Freigabe sind wählbar. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bc1f84ac89
commit
a08067c078
13 files changed
+611
-151
No files matched your search
@@ -9,11 +9,18 @@
|
||||
* - url: nur ein öffentlich freigegebenes Ziel aus dem Fachobjekt (Themenseite, Programmseite), sonst null.
|
||||
* - public: false heißt „nur in der Redaktionsvorschau“; öffentlich entfällt die Karte dann.
|
||||
* - notice: redaktioneller Hinweis für die Vorschau, warum die Karte öffentlich nicht erscheint.
|
||||
* - visual: Darstellung ohne Kartenbild: 'film' (Medientafel Film), 'material' (Materialsymbol),
|
||||
* 'catalog' (Navy-Tafel Programm/Modul) oder null (Karte ohne Bildbereich).
|
||||
* - previewImage: geschütztes Vorschaubild der Bibliothek (Filmstandbild, Vorschau des Moduls). Nur für die
|
||||
* Redaktionsvorschau (Route editorial.card, nur für angemeldete Redaktion); öffentlich nie ausgegeben, weil es
|
||||
* keine Freigabe für die Website hat.
|
||||
* - missing: was für eine vollständige Karte fehlt, als Hinweis nur in der Redaktionsvorschau.
|
||||
*/
|
||||
final readonly class CardSubject
|
||||
{
|
||||
/**
|
||||
* @param list<string> $meta reine Anzeigetexte aus Fachdaten
|
||||
* @param list<string> $missing Hinweise für die Redaktion
|
||||
*/
|
||||
public function __construct(
|
||||
public string $title,
|
||||
@@ -24,5 +31,10 @@ public function __construct(
|
||||
public ?string $url,
|
||||
public bool $public,
|
||||
public ?string $notice = null,
|
||||
public ?string $visual = null,
|
||||
public ?string $visualLabel = null,
|
||||
public ?string $previewImage = null,
|
||||
public array $missing = [],
|
||||
public ?string $style = null,
|
||||
) {}
|
||||
}
|
||||
@@ -5,7 +5,9 @@
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
@@ -172,43 +174,161 @@ public function entries(array $refs, bool $includeNonPublic): array
|
||||
}
|
||||
|
||||
/**
|
||||
* Anzeigedaten für eine Programm- oder Modulkarte (Premium-Karte). Dieselbe Regel wie entries():
|
||||
* Programme mit Anzeigefreigabe öffentlich mit Programmseite, Module nur in der Redaktionsvorschau.
|
||||
* Die Art („Programm“ oder „Modul“) ist immer benannt. Kein Preis, kein Angebot, keine Kaufaktion.
|
||||
* Für die Programm- oder Modulkarte wählbar: Programm oder Modul, nicht archiviert, mit mindestens einer
|
||||
* bereitgestellten Fassung. Anders als bei den Katalogkarten ist keine Anzeigefreigabe nötig, damit die Redaktion
|
||||
* eine Karte vorbereiten kann; öffentlich gilt unverändert isPublic().
|
||||
*/
|
||||
public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
||||
public function isCardSelectable(Composition $composition): bool
|
||||
{
|
||||
$entry = $this->entries([['type' => 'composition', 'id' => $id]], $includeNonPublic)[0] ?? null;
|
||||
return $composition->archived_at === null
|
||||
&& in_array($composition->editorialContentKind?->slug, self::SELECTABLE_KINDS, true)
|
||||
&& $this->latestReadyVersion($composition) !== null;
|
||||
}
|
||||
|
||||
if ($entry === null) {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function cardSearch(?string $term, int $limit = 25): array
|
||||
{
|
||||
$term = trim((string) $term);
|
||||
|
||||
$meta = [];
|
||||
$composition = Composition::query()->find($entry->id);
|
||||
$version = $composition !== null ? $this->shownVersion($composition) : null;
|
||||
$candidates = Composition::query()
|
||||
->with('editorialContentKind')
|
||||
->whereNull('archived_at')
|
||||
->whereHas('editorialContentKind', fn ($query) => $query->whereIn('slug', self::SELECTABLE_KINDS))
|
||||
->when($term !== '', function ($query) use ($term): void {
|
||||
$like = '%'.mb_strtolower($term).'%';
|
||||
$query->where(fn ($inner) => $inner
|
||||
->whereRaw('LOWER(designation) LIKE ?', [$like])
|
||||
->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like]));
|
||||
})
|
||||
->orderBy('designation')
|
||||
->limit($limit * 3)
|
||||
->get();
|
||||
|
||||
if ($version !== null) {
|
||||
$nested = $version->members()->whereNotNull('nested_composition_version_id')->with('nestedCompositionVersion.composition.editorialContentKind')->get();
|
||||
$modules = $nested->filter(fn ($member): bool => $member->nestedCompositionVersion?->composition?->editorialContentKind?->slug === 'modul')->count();
|
||||
$options = [];
|
||||
foreach ($candidates as $composition) {
|
||||
if (! $this->isCardSelectable($composition)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($modules > 0) {
|
||||
$meta[] = $modules === 1 ? '1 Modul' : $modules.' Module';
|
||||
$options[$composition->id] = $this->cardOptionLabel($composition);
|
||||
|
||||
if (count($options) >= $limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function cardLabelFor(mixed $id): ?string
|
||||
{
|
||||
$composition = is_numeric($id) ? Composition::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
return $composition === null ? null : $this->cardOptionLabel($composition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Anzeigedaten für eine Programm- oder Modulkarte (Premium-Karte).
|
||||
*
|
||||
* - Öffentlich nur Programme mit Anzeigefreigabe (dieselbe Regel wie /programme), mit Programmseite als Ziel.
|
||||
* Module haben keine öffentliche Seitenart (ADR-29) und erscheinen nur in der Redaktionsvorschau, ohne Link.
|
||||
* - Text: Kurzbeschreibung, sonst das Lernziel der gezeigten (öffentlich) bzw. neuesten bereitgestellten Fassung;
|
||||
* das Lernziel steht auf der öffentlichen Programmseite bereits öffentlich.
|
||||
* - Zusatzangaben: Zahl der Module, Dauer. Kein Preis, kein Angebot, keine Kaufaktion; eine Karte ist kein
|
||||
* Lizenzartikel. Das Vorschaubild der Bibliothek erscheint nur in der Redaktionsvorschau.
|
||||
*/
|
||||
public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
||||
{
|
||||
$composition = is_numeric($id) ? Composition::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
if ($composition === null || ! $this->isCardSelectable($composition)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$shown = $this->shownVersion($composition);
|
||||
$public = $shown !== null && $composition->archived_at === null;
|
||||
|
||||
if (! $public && ! $includeNonPublic) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$version = $shown ?? $this->latestReadyVersion($composition);
|
||||
$program = $composition->editorialContentKind?->slug === 'programm';
|
||||
$kind = (string) ($composition->editorialContentKind?->label ?? ($program ? 'Programm' : 'Modul'));
|
||||
$summary = filled($composition->summary) ? trim((string) $composition->summary) : null;
|
||||
$goal = filled($version?->learning_goal) ? trim((string) $version->learning_goal) : null;
|
||||
$missing = [];
|
||||
|
||||
if ($summary === null) {
|
||||
$missing[] = $goal !== null
|
||||
? 'Keine Kurzbeschreibung gepflegt; die Karte zeigt das Lernziel.'
|
||||
: 'Weder Kurzbeschreibung noch Lernziel gepflegt.';
|
||||
}
|
||||
|
||||
$meta = [];
|
||||
if ($version !== null) {
|
||||
$modules = $version->members()
|
||||
->whereNotNull('nested_composition_version_id')
|
||||
->with('nestedCompositionVersion.composition.editorialContentKind')
|
||||
->get()
|
||||
->filter(fn ($member): bool => $member->nestedCompositionVersion?->composition?->editorialContentKind?->slug === 'modul')
|
||||
->count();
|
||||
|
||||
if ($program && $modules > 0) {
|
||||
$meta[] = $modules === 1 ? '1 Modul' : $modules.' Module';
|
||||
}
|
||||
|
||||
if (is_numeric($version->duration_minutes) && (int) $version->duration_minutes > 0) {
|
||||
$meta[] = 'Dauer '.(int) $version->duration_minutes.' Min.';
|
||||
} else {
|
||||
$missing[] = 'Keine Dauer gepflegt.';
|
||||
}
|
||||
}
|
||||
|
||||
$notice = null;
|
||||
if (! $public) {
|
||||
$notice = 'Nur in der Redaktionsvorschau sichtbar: '.($program
|
||||
? 'Das Programm hat keine Anzeigefreigabe.'
|
||||
: 'Für Module gibt es noch keine öffentliche Seitenart (öffentliches Profil, ADR-29); die Karte erhält deshalb keinen Link.');
|
||||
}
|
||||
|
||||
return new CardSubject(
|
||||
title: $entry->title,
|
||||
summary: $entry->summary,
|
||||
kind: $entry->kindLabel,
|
||||
title: $this->title($composition),
|
||||
summary: $summary ?? $goal,
|
||||
kind: $kind,
|
||||
badge: null,
|
||||
meta: $meta,
|
||||
url: $entry->url,
|
||||
public: $entry->public,
|
||||
notice: $entry->public ? null : 'Nur in der Redaktionsvorschau sichtbar: Für Module gibt es noch keine öffentliche Seitenart (öffentliches Profil, ADR-29).',
|
||||
url: $public ? route('public.program', $composition) : null,
|
||||
public: $public,
|
||||
notice: $notice,
|
||||
visual: 'catalog',
|
||||
visualLabel: $kind,
|
||||
previewImage: $includeNonPublic ? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path) : null,
|
||||
missing: $missing,
|
||||
);
|
||||
}
|
||||
|
||||
private function latestReadyVersion(Composition $composition): ?CompositionVersion
|
||||
{
|
||||
return $composition->versions()
|
||||
->where('status', ContentVersionStatus::Bereit->value)
|
||||
->orderByDesc('number')
|
||||
->first();
|
||||
}
|
||||
|
||||
private function cardOptionLabel(Composition $composition): string
|
||||
{
|
||||
$visibility = match (true) {
|
||||
$this->isPublic($composition) => 'öffentlich sichtbar',
|
||||
$composition->editorialContentKind?->slug === 'modul' => 'Modul, nur Redaktionsvorschau',
|
||||
default => 'ohne Anzeigefreigabe, nur Redaktionsvorschau',
|
||||
};
|
||||
|
||||
return $this->title($composition).' · '.($composition->editorialContentKind?->label ?? '').' · '.$visibility;
|
||||
}
|
||||
|
||||
private function title(Composition $composition): string
|
||||
{
|
||||
return (string) ($composition->display_title ?: $composition->designation);
|
||||
|
||||
@@ -6,23 +6,29 @@
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\StructureNode;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
|
||||
/**
|
||||
* Lesesicht „Medien und Materialien“ für Premium-Karten (Website-CMS-Zielarchitektur 6.2).
|
||||
*
|
||||
* Übergangsregel, solange öffentliche Fachobjektprofile (ADR-29) fehlen:
|
||||
* Ein Medium oder Material hat keine eigene öffentliche Seite. Öffentlich genannt wird es heute nur als Bestandteil
|
||||
* der gezeigten Fassung eines öffentlichen Programms (Programmseite /programme/{id}). Genau dann erscheint auch die
|
||||
* Karte öffentlich, mit Verweis auf diese Programmseite. Sonst ist die Karte nur in der Redaktionsvorschau sichtbar.
|
||||
* Auswahl in der Redaktion: jedes nicht archivierte Inhaltselement mit mindestens einer nicht gesperrten Fassung.
|
||||
*
|
||||
* Gelesen werden nur Anzeigetitel, Inhaltsart und Ausgabeart, nie Kurzbeschreibung, Dateien, Lehrtexte,
|
||||
* Vorschaubilder der Bibliothek oder Ausgabeadressen. Eine Karte gibt kein Medium frei.
|
||||
* Öffentliche Sichtbarkeit (Übergangsregel, solange öffentliche Fachobjektprofile nach ADR-29 fehlen):
|
||||
* Ein Medium hat keine eigene öffentliche Seite. Öffentlich genannt wird es heute nur als Bestandteil der gezeigten
|
||||
* Fassung eines öffentlichen Programms (Programmseite /programme/{id}). Genau dann erscheint auch die Karte
|
||||
* öffentlich, mit Verweis auf diese Programmseite, und nur mit bereitgestellter Fassung. Traineranleitungen erscheinen
|
||||
* nie öffentlich (vertraulich für Trainerinnen und Trainer).
|
||||
*
|
||||
* Die Kurzbeschreibung eines Elements ist heute nirgends öffentlich (die Programmseite nennt nur den Titel). Sie bleibt
|
||||
* deshalb auch auf der Karte aus, bis über öffentliche Profile (ADR-29) entschieden ist (offene Entscheidung, ADR-39).
|
||||
* Öffentlich gelesen werden Anzeigetitel (sonst Arbeitstitel), Kurzbeschreibung, Inhaltsart und Ausgabeart. Nie:
|
||||
* Beschreibung, Einsatzhinweis, Lizenzvermerk, Dateien, Lehrtexte, Ausgabeadressen. Das Vorschaubild (Filmstandbild)
|
||||
* der Bibliothek ist nicht für die Website freigegeben; es erscheint nur in der Redaktionsvorschau.
|
||||
* Eine Karte spielt nichts ab, bietet keinen Download und gibt kein Medium frei.
|
||||
*/
|
||||
class PublicMaterialReader
|
||||
{
|
||||
/** Inhaltsarten, die nie öffentlich auf einer Karte erscheinen. */
|
||||
public const CONFIDENTIAL_KINDS = ['traineranleitung'];
|
||||
|
||||
/** @var array<int, array{id: int, title: string}>|null Element-ID => erstes öffentliches Programm */
|
||||
private ?array $publicIndex = null;
|
||||
|
||||
@@ -31,13 +37,15 @@ public function __construct(
|
||||
private readonly CompositionStructureReader $structure,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Wählbar ist ein nicht archiviertes Element mit mindestens einer bereitgestellten (nicht gesperrten) Fassung.
|
||||
*/
|
||||
public function isSelectable(ContentElement $element): bool
|
||||
{
|
||||
return $element->archived_at === null
|
||||
&& $element->versions()->where('status', ContentVersionStatus::Bereit->value)->exists();
|
||||
&& $element->versions()->where('status', '!=', ContentVersionStatus::Gesperrt->value)->exists();
|
||||
}
|
||||
|
||||
public function isReady(ContentElement $element): bool
|
||||
{
|
||||
return $element->versions()->where('status', ContentVersionStatus::Bereit->value)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,6 +58,14 @@ public function publicProgramFor(ContentElement $element): ?array
|
||||
return $this->publicIndex()[$element->id] ?? null;
|
||||
}
|
||||
|
||||
public function isPublic(ContentElement $element): bool
|
||||
{
|
||||
return $this->isSelectable($element)
|
||||
&& $this->isReady($element)
|
||||
&& ! in_array($element->editorialContentKind?->slug, self::CONFIDENTIAL_KINDS, true)
|
||||
&& $this->publicProgramFor($element) !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
@@ -60,7 +76,7 @@ public function search(?string $term, int $limit = 25): array
|
||||
$candidates = ContentElement::query()
|
||||
->with('editorialContentKind')
|
||||
->whereNull('archived_at')
|
||||
->whereHas('versions', fn ($query) => $query->where('status', ContentVersionStatus::Bereit->value))
|
||||
->whereHas('versions', fn ($query) => $query->where('status', '!=', ContentVersionStatus::Gesperrt->value))
|
||||
->when($term !== '', function ($query) use ($term): void {
|
||||
$like = '%'.mb_strtolower($term).'%';
|
||||
$query->where(fn ($inner) => $inner
|
||||
@@ -97,29 +113,53 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
||||
return null;
|
||||
}
|
||||
|
||||
$program = $this->publicProgramFor($element);
|
||||
$public = $this->isPublic($element);
|
||||
|
||||
if ($program === null && ! $includeNonPublic) {
|
||||
if (! $public && ! $includeNonPublic) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$program = $this->publicProgramFor($element);
|
||||
$output = self::outputLabel((string) $element->output_class);
|
||||
$film = $element->output_class === 'film';
|
||||
$editorialKind = $element->editorialContentKind?->label;
|
||||
$summary = filled($element->summary) ? trim((string) $element->summary) : null;
|
||||
|
||||
$meta = [$output];
|
||||
if ($program !== null) {
|
||||
$meta[] = 'Im Programm „'.$program['title'].'“';
|
||||
}
|
||||
if ($film) {
|
||||
$meta[] = 'Vollständiger Film nur mit Lizenz im Mitgliederbereich';
|
||||
}
|
||||
|
||||
$missing = [];
|
||||
if ($summary === null) {
|
||||
$missing[] = 'Keine Kurzbeschreibung gepflegt (Medium bearbeiten → Kurzbeschreibung).';
|
||||
}
|
||||
if (! filled($element->display_title)) {
|
||||
$missing[] = 'Kein Anzeigetitel gepflegt; die Karte zeigt den Arbeitstitel.';
|
||||
}
|
||||
if ($film) {
|
||||
$missing[] = 'Laufzeit: in den Mediendaten nicht erfasst.';
|
||||
}
|
||||
|
||||
$previewImage = $includeNonPublic ? ThumbnailRef::url('editorial.card', 'element', (int) $element->id, $element->thumbnail_path) : null;
|
||||
|
||||
return new CardSubject(
|
||||
title: $this->title($element),
|
||||
summary: null,
|
||||
title: (string) ($element->display_title ?: $element->working_title),
|
||||
summary: $summary,
|
||||
kind: filled($editorialKind) ? (string) $editorialKind : $output,
|
||||
badge: $output,
|
||||
meta: array_values(array_filter([
|
||||
$output,
|
||||
$program !== null ? 'Im Programm „'.$program['title'].'“' : null,
|
||||
])),
|
||||
url: $program !== null ? route('public.program', $program['id']) : null,
|
||||
public: $program !== null,
|
||||
notice: $program === null
|
||||
? 'Nur in der Redaktionsvorschau sichtbar: Dieses Medium gehört zu keinem öffentlich gezeigten Programm. Medien haben noch keine eigene öffentliche Freigabe (öffentliches Profil, ADR-29).'
|
||||
: null,
|
||||
meta: $meta,
|
||||
url: $public && $program !== null ? route('public.program', $program['id']) : null,
|
||||
public: $public,
|
||||
notice: $public ? null : $this->notice($element, $program),
|
||||
visual: $film ? 'film' : 'material',
|
||||
visualLabel: $output,
|
||||
previewImage: $previewImage,
|
||||
missing: $missing,
|
||||
style: $film ? 'media' : 'material',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -135,17 +175,29 @@ public static function outputLabel(string $outputClass): string
|
||||
};
|
||||
}
|
||||
|
||||
private function title(ContentElement $element): string
|
||||
/**
|
||||
* @param array{id: int, title: string}|null $program
|
||||
*/
|
||||
private function notice(ContentElement $element, ?array $program): string
|
||||
{
|
||||
return (string) ($element->display_title ?: $element->working_title);
|
||||
$reason = match (true) {
|
||||
in_array($element->editorialContentKind?->slug, self::CONFIDENTIAL_KINDS, true) => 'Traineranleitungen erscheinen nie öffentlich.',
|
||||
! $this->isReady($element) => 'Das Medium hat noch keine bereitgestellte Fassung.',
|
||||
$program === null => 'Das Medium gehört zu keinem öffentlich gezeigten Programm. Medien haben noch keine eigene öffentliche Freigabe (öffentliches Profil, ADR-29).',
|
||||
default => 'Das Medium ist nicht öffentlich.',
|
||||
};
|
||||
|
||||
return 'Nur in der Redaktionsvorschau sichtbar: '.$reason;
|
||||
}
|
||||
|
||||
private function optionLabel(ContentElement $element): string
|
||||
{
|
||||
$visibility = $this->publicProgramFor($element) !== null ? 'öffentlich über Programmseite' : 'nur Redaktionsvorschau';
|
||||
$visibility = $this->isPublic($element)
|
||||
? 'öffentlich über Programmseite'
|
||||
: ($this->isReady($element) ? 'nur Redaktionsvorschau' : 'Entwurf, nur Redaktionsvorschau');
|
||||
$kind = $element->editorialContentKind?->label ?: self::outputLabel((string) $element->output_class);
|
||||
|
||||
return $this->title($element).' · '.$kind.' · '.$visibility;
|
||||
return (string) ($element->display_title ?: $element->working_title).' · '.$kind.' · '.$visibility;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
|
||||
/**
|
||||
* Medien- und Materialkarte (Kit v1.7 „media“): ein Inhaltselement (Film, Dokument, Hörstück …) mit Anzeigetitel,
|
||||
* Kurzbeschreibung, Inhaltsart und Ausgabeart. Öffentlich nur, wenn das Element zur gezeigten Fassung eines
|
||||
* öffentlichen Programms gehört (PublicMaterialReader); die Aktion führt dann auf diese Programmseite.
|
||||
* Die Karte spielt nichts ab, bietet keinen Download und gibt kein geschütztes Medium frei.
|
||||
* Medien- und Materialkarte (Kit v1.7 „media“): ein Inhaltselement mit Anzeigetitel, Kurzbeschreibung, Inhaltsart und
|
||||
* Ausgabeart. Filme erscheinen als Medienkarte (grüne Aktion, Filmtafel ohne freigegebenes Bild), Dokumente und andere
|
||||
* Materialien als Materialkarte (Materialsymbol). Öffentlich nur nach den Regeln von PublicMaterialReader; die Aktion
|
||||
* führt auf die öffentliche Programmseite. Die Karte spielt nichts ab, bietet keinen Download und gibt kein Medium frei.
|
||||
*/
|
||||
class MediaCardWidget extends PremiumCardWidget
|
||||
{
|
||||
@@ -40,15 +40,6 @@ public function schematic(): array
|
||||
return [[2, 2, 56, 32, 'line'], [5, 5, 22, 26, 'image'], [7, 7, 8, 3, 'accent'], [31, 8, 22, 4, 'ink'], [31, 15, 22, 5, 'line'], [31, 25, 14, 5, 'accent']];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
// Ohne Kurzbeschreibung (nicht öffentlich, siehe PublicMaterialReader) gibt es nichts ein- oder auszublenden.
|
||||
$settings = parent::settings();
|
||||
unset($settings['show_summary']);
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
protected function refKey(): string
|
||||
{
|
||||
return 'element';
|
||||
@@ -61,7 +52,7 @@ protected function refLabel(): string
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
return 'Wählbar sind bereitgestellte, nicht archivierte Inhalte. Öffentlich erscheint die Karte nur, wenn der Inhalt zu einem öffentlich gezeigten Programm gehört; sonst nur in der Redaktionsvorschau.';
|
||||
return 'Wählbar sind alle nicht archivierten, nicht gesperrten Filme und Materialien. Öffentlich erscheint die Karte nur mit bereitgestellter Fassung und wenn der Inhalt zu einem öffentlich gezeigten Programm gehört; Traineranleitungen nie. Titel und Kurzbeschreibung pflegen Sie im Medium.';
|
||||
}
|
||||
|
||||
protected function searchSubjects(?string $term): array
|
||||
@@ -80,7 +71,7 @@ protected function rejectSubject(int $id): ?string
|
||||
|
||||
return $element !== null && app(PublicMaterialReader::class)->isSelectable($element)
|
||||
? null
|
||||
: 'Dieser Inhalt ist nicht bereitgestellt oder archiviert.';
|
||||
: 'Dieser Inhalt ist archiviert oder gesperrt.';
|
||||
}
|
||||
|
||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||
|
||||
@@ -226,9 +226,11 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
$option = fn (string $key, string $default): string => is_string($settings[$key] ?? null) && isset($this->settingOptions()[$key][$settings[$key]]) ? $settings[$key] : $default;
|
||||
$data = $widget['data'];
|
||||
|
||||
$subject = $this->subject($widget['refs'][$this->refKey()] ?? null, $context);
|
||||
|
||||
return [
|
||||
'subject' => $this->subject($widget['refs'][$this->refKey()] ?? null, $context),
|
||||
'cardStyle' => $this->cardStyle(),
|
||||
'subject' => $subject,
|
||||
'cardStyle' => $subject?->style ?? $this->cardStyle(),
|
||||
'imageUrl' => PublicMedia::imageUrl($widget['refs']),
|
||||
'alt' => is_string($data['alt'] ?? null) ? $data['alt'] : '',
|
||||
'focus' => PremiumFields::focus($data, 66, 45),
|
||||
|
||||
@@ -61,26 +61,26 @@ protected function refLabel(): string
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
return 'Nur zur Anzeige freigegebene Programme und Module sind wählbar. Öffentlich erscheinen Programme mit Programmseite; Module nur in der Redaktionsvorschau.';
|
||||
return 'Wählbar sind Programme und Module mit bereitgestellter Fassung. Öffentlich erscheinen nur Programme mit Anzeigefreigabe (mit Programmseite); Module haben keine öffentliche Seite und erscheinen nur in der Redaktionsvorschau.';
|
||||
}
|
||||
|
||||
protected function searchSubjects(?string $term): array
|
||||
{
|
||||
return app(PublicCatalogReader::class)->search($term);
|
||||
return app(PublicCatalogReader::class)->cardSearch($term);
|
||||
}
|
||||
|
||||
protected function subjectLabel(mixed $id): ?string
|
||||
{
|
||||
return app(PublicCatalogReader::class)->labelFor($id);
|
||||
return app(PublicCatalogReader::class)->cardLabelFor($id);
|
||||
}
|
||||
|
||||
protected function rejectSubject(int $id): ?string
|
||||
{
|
||||
$composition = Composition::query()->with('editorialContentKind')->find($id);
|
||||
|
||||
return $composition !== null && app(PublicCatalogReader::class)->isSelectable($composition)
|
||||
return $composition !== null && app(PublicCatalogReader::class)->isCardSelectable($composition)
|
||||
? null
|
||||
: 'Dieses Objekt ist kein zur Anzeige freigegebenes Programm oder Modul.';
|
||||
: 'Dieses Objekt ist kein Programm oder Modul mit bereitgestellter Fassung.';
|
||||
}
|
||||
|
||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
|
||||
/**
|
||||
* Redaktionelle Themenkarte (Kit v1.7 „editorial“): ein veröffentlichtes Thema (Säule) mit Name,
|
||||
* öffentlicher Kurzbeschreibung und Verweis auf die Themenseite /themen/{slug}. Ruhige Textaktion mit gelber
|
||||
* Unterstreichung. Ein nicht (mehr) veröffentlichtes Thema erscheint öffentlich nicht.
|
||||
* Redaktionelle Themenkarte (Kit v1.7 „editorial“): ein Thema (fachliche Säule) mit Name, Text für die Website und
|
||||
* Verweis auf die Themenseite /themen/{slug}. Ruhige Textaktion mit gelber Unterstreichung. Wählbar sind alle Säulen;
|
||||
* ein nicht veröffentlichtes Thema erscheint nur in der Redaktionsvorschau, öffentlich nicht.
|
||||
*/
|
||||
class TopicCardWidget extends PremiumCardWidget
|
||||
{
|
||||
@@ -50,7 +50,7 @@ protected function refLabel(): string
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
return 'Nur veröffentlichte Themen sind wählbar. Name und Kurzbeschreibung pflegen Sie im Thema, nicht hier.';
|
||||
return 'Alle fachlichen Säulen sind wählbar. Öffentlich erscheint die Karte nur, wenn das Thema veröffentlicht ist; Name und Text pflegen Sie unter „Fachliche Säulen“, nicht hier.';
|
||||
}
|
||||
|
||||
protected function searchSubjects(?string $term): array
|
||||
@@ -58,11 +58,12 @@ protected function searchSubjects(?string $term): array
|
||||
$term = trim((string) $term);
|
||||
|
||||
return Pillar::query()
|
||||
->published()
|
||||
->orderBy('sort_order')
|
||||
->orderBy('name')
|
||||
->when($term !== '', fn ($query) => $query->whereRaw('LOWER(name) LIKE ?', ['%'.mb_strtolower($term).'%']))
|
||||
->limit(25)
|
||||
->limit(50)
|
||||
->get()
|
||||
->mapWithKeys(fn (Pillar $pillar): array => [$pillar->id => $pillar->name.' · Thema'])
|
||||
->mapWithKeys(fn (Pillar $pillar): array => [$pillar->id => $this->optionLabel($pillar)])
|
||||
->all();
|
||||
}
|
||||
|
||||
@@ -70,39 +71,60 @@ protected function subjectLabel(mixed $id): ?string
|
||||
{
|
||||
$pillar = is_numeric($id) ? Pillar::query()->find((int) $id) : null;
|
||||
|
||||
if ($pillar === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $pillar->name.' · Thema'.($pillar->published_at === null ? ' · nicht veröffentlicht' : '');
|
||||
return $pillar === null ? null : $this->optionLabel($pillar);
|
||||
}
|
||||
|
||||
protected function rejectSubject(int $id): ?string
|
||||
{
|
||||
return Pillar::query()->whereKey($id)->whereNotNull('published_at')->exists()
|
||||
? null
|
||||
: 'Dieses Thema ist nicht veröffentlicht.';
|
||||
return Pillar::query()->whereKey($id)->exists() ? null : 'Dieses Thema gibt es nicht.';
|
||||
}
|
||||
|
||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||
{
|
||||
$pillar = is_numeric($id) ? Pillar::query()->find((int) $id) : null;
|
||||
|
||||
if ($pillar === null || $pillar->published_at === null) {
|
||||
if ($pillar === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$public = self::isPublic($pillar);
|
||||
|
||||
if (! $public && ! $context->preview) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$summary = filled($pillar->public_summary) ? trim((string) $pillar->public_summary) : null;
|
||||
$pages = $pillar->pages()->whereNotNull('published_revision_id')->count();
|
||||
$missing = [];
|
||||
|
||||
if ($summary === null) {
|
||||
$missing[] = 'Kein Text für die Website gepflegt (Fachliche Säulen → Text für die Website).';
|
||||
}
|
||||
|
||||
return new CardSubject(
|
||||
title: (string) $pillar->name,
|
||||
summary: filled($pillar->public_summary) ? (string) $pillar->public_summary : null,
|
||||
summary: $summary,
|
||||
kind: 'Thema',
|
||||
badge: null,
|
||||
meta: [],
|
||||
url: $pillar->publicUrl(),
|
||||
public: true,
|
||||
meta: $pages > 0 ? [$pages === 1 ? '1 Seite zum Thema' : $pages.' Seiten zum Thema'] : [],
|
||||
url: $public ? $pillar->publicUrl() : null,
|
||||
public: $public,
|
||||
notice: $public ? null : 'Nur in der Redaktionsvorschau sichtbar: Das Thema ist nicht veröffentlicht (Fachliche Säulen → Öffentliche Adresse und „Auf der Website veröffentlichen“).',
|
||||
missing: $missing,
|
||||
);
|
||||
}
|
||||
|
||||
/** Öffentlich ist ein Thema mit Veröffentlichung und öffentlicher Adresse (dieselbe Regel wie /themen). */
|
||||
public static function isPublic(Pillar $pillar): bool
|
||||
{
|
||||
return $pillar->published_at !== null && filled($pillar->slug);
|
||||
}
|
||||
|
||||
private function optionLabel(Pillar $pillar): string
|
||||
{
|
||||
return $pillar->name.' · Thema · '.(self::isPublic($pillar) ? 'veröffentlicht' : 'nicht veröffentlicht, nur Redaktionsvorschau');
|
||||
}
|
||||
|
||||
protected function defaultActionLabel(): string
|
||||
{
|
||||
return 'Thema entdecken';
|
||||
|
||||
Reference in new issue
Block a user