Compare commits

..
Author SHA1 Message Date
LarsandClaude Sonnet 5.5 99122ddfee Zeige formatierte Texte überall als Klartext, wo kein HTML hingehört
Deploy Test / test (push) Successful in 4m27s
Deploy Test / deploy (push) Successful in 40s
Öffentliche Leser, Shop, Medienliste und Bibliothek lesen Kurzbeschreibung,
Beschreibung und Lernziel als Klartext; Mitgliederseiten zu Programm, Inhalt und
Artikel zeigen die formatierte Fassung. Der Editor trägt die deutsche Bezeichnung
des Felds als Namen für Hilfstechnik, der Tastaturfokus landet im Editor, und der
Abgleich merkt sich nur eine Prüfsumme. ADR-50 nennt Rückfall und Suche.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-24 00:01:53 +01:00
LarsandClaude Sonnet 5.5 9fbd933e1e Speichere formatierte Texte als bereinigtes HTML mit einem Editor (ADR-50)
Ein Baustein (FormattedText) bereinigt, bringt Werte in die kanonische Form und
wandelt Klartext des Altbestands; RichField ist der eine Editor, ManagesRichFields
verbindet ihn mit den Arbeitsplätzen. Formatiert sind Texte der Übungen und
Textbausteine, Kurzbeschreibung und Beschreibung, Lernziel und Ausstattung.
Mitgliederansicht und PDF zeigen fett, kursiv, Listen, Überschrift, Zitat und Link
(PDF: schräge Schnitte, nur wenn gebraucht). Das Livewire-Limit für verschachtelte
Pfade steigt auf 30, weil Aufzählungen sonst abgelehnt werden.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 23:45:54 +01:00
LarsandClaude Sonnet 5.5 be24f3bf64 Übernimm Texte aus Shinkan als bereinigtes HTML
Der Abruf wertet text_format aus. Bei html gelten Kurzbeschreibung, Lernziel,
Durchführung, Vorbereitung, Trainerhinweise und die Abweichung der Durchführung
als HTML; Verweise auf Quellmedien entfallen. Vergleich und Dreiwegeabgleich
arbeiten in kanonischer Form, die Vorschau zeigt Klartext. Ohne Angabe bleibt
alles Klartext wie bisher.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 23:45:54 +01:00
Lars 4584dcd013 Merge remote-tracking branch 'origin/develop' into feature/cms-symbole-merkmale
Deploy Test / test (push) Successful in 3m0s
CI Feature / test (push) Failing after 3m16s
Deploy Test / deploy (push) Successful in 30s
2026-11-23 19:14:48 +01:00
LarsandClaude Sonnet 5.5 cf8189623c Füge Symbol vor Überschriften, Pinselstrich und Merkmalszeile ins CMS ein
CI Feature / test (push) Successful in 2m40s
Die Kleingrafiken des Brand-Kits sind jetzt im Redaktionsinhalt wählbar, nicht nur
an Medienkarten:

- Einstellung "Symbol vor der Überschrift" (settings.symbol) an Überschrift,
  Einstieg, Bild und Text und Handlungsaufruf. Feste Auswahl von 14 Symbolen
  (HeadingAccent::SYMBOLS), ein unbekannter Name wird beim Speichern abgewiesen.
- Einstellung "Pinselstrich" (settings.accent = brush) am Widget Überschrift.
- Neues Widget "Merkmalszeile" (features): zwei bis vier Merkmale mit Symbol,
  Kurztitel und Satz; die Anzahl bestimmt die Spalten.
- Auf dunklen Flächen stehen die Symbole auf einer weißen Scheibe, weil sie
  feste Markenfarben mit viel Navy haben.
- brand/symbol erzeugt keine Zeilenumbrüche mehr um das SVG, damit es im
  Fließtext und in Überschriften keine zusätzliche Lücke gibt.

Der Test der Widget-Reihenfolge kennt das neue Widget bewusst (features nach cards).
Stufe 3b (Symbole mitten im Fließtext) bleibt zurückgestellt.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 19:11:43 +01:00
LarsandClaude Sonnet 5.5 9140e731f9 Behandle Übungen aus Shinkan wie jede Übung, ordne die Navigation neu
Deploy Test / test (push) Successful in 2m43s
Deploy Test / deploy (push) Successful in 26s
Importierte Übungen werden im selben Editor bearbeitet und als neue Fassung gespeichert. Lokal bearbeitete Texte und
Felder bleiben bei der nächsten Übernahme erhalten, bei Änderung auf beiden Seiten entscheidet die Redaktion. Ein
Fehler im Editor setzte die Herkunft der Varianten auf lokal und ist behoben. Übungen haben einen Einstieg unter
Inhalte, Fachliche Säulen und Redaktionelle Stammdaten stehen in der Gruppe Stammdaten, die Übernahme ist ein Weg im
Übungsbestand.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 19:05:05 +01:00
LarsandClaude Sonnet 5.5 bb08b9b3fa Nenne bei einem Netzwerkfehler der Shinkan-Anbindung die Ursache
Deploy Test / test (push) Successful in 3m17s
Deploy Test / deploy (push) Successful in 30s
Namensauflösung, abgelehnte Verbindung, Zeitüberschreitung und Zertifikat werden unterschieden. Genannt wird nur der
Servername, nie Pfad, Adresse oder Schlüssel.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 18:48:27 +01:00
LarsandClaude Sonnet 5.5 e5b3eea7de Akzeptiere die Shinkan-Adresse mit und ohne /api-Pfad
Deploy Test / test (push) Successful in 2m28s
Deploy Test / deploy (push) Successful in 25s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 18:19:32 +01:00
89 changed files with 2785 additions and 279 deletions

No files matched your search

+1
View File
@@ -65,5 +65,6 @@ ## Verwaltungsoberfläche
- Maßgeblich sind `docs/ux/verwaltung/14-verwaltungsstandard.md` (Design und Interaktion) und `15-umbauauftrag.md` (Auftrag, Nachweise). Keine neue allgemeine Designabstimmung verlangen. Einstieg für alle Agenten: `AGENTS.md`, `.cursor/rules/verwaltung-ux.mdc`. - Maßgeblich sind `docs/ux/verwaltung/14-verwaltungsstandard.md` (Design und Interaktion) und `15-umbauauftrag.md` (Auftrag, Nachweise). Keine neue allgemeine Designabstimmung verlangen. Einstieg für alle Agenten: `AGENTS.md`, `.cursor/rules/verwaltung-ux.mdc`.
- Gemeinsame Bausteine wiederverwenden statt neue Masken bauen: `resources/views/filament/verwaltung/` (`kopf`, `redaktion`, `texte`, `praesentation`, `einordnung`, `picker`, `bestaetigung`, `abgang`, `aufbau`, `bestand`) mit dem Trait `App\Filament\Support\ManagesEditorialSurface`. Listen nutzen `verwaltung/bestand` mit `ShowsBestand` (bzw. `ListsCompositions`, `ListsCatalog`) und den Eintrag `<x-vw.eintrag>`, den auch der Picker verwendet; Katalogobjekte die Seite `catalog/objekt`. CMS: Seitenkopf `cms/seite-kopf` (Register, Kontexte „Abschnitt gestalten“ und „Konfigurieren“); Seiten und Menüs in der Webpräsenz (`App\Filament\Pages\Webpraesenz`, Menüs als Arbeitsstand mit einer Speicherhandlung). Der Picker liegt im Trait `ChoosesMedia` (Redaktion über `ManagesEditorialSurface`, CMS-Bilder über `ChoosesWebsiteImages`); keine eigenen Auswahllisten für Medien bauen. Redaktionelle Auswahlwerte (Materialart, Einordnung) nur über `App\Domain\Catalog\EditorialVocabulary` anbieten und prüfen (aktiv, zulässiger Kontext, vorhandene Zuordnungen erhalten); gepflegt werden sie unter „Redaktionelle Stammdaten“. Fachliche Säulen gibt es nur in der Säulenverwaltung (`pillars`); Zuordnung über `PillarService::assign`, nie über eine Dimension. Ersetzt eine Seite die Filament-Tabelle, muss sie den Dialogbereich ausgeben (in `bestand` enthalten), sonst öffnen „… anlegen“-Dialoge nicht. Gestaltungswerte nur in `verwaltung/styles.blade.php` (Tokens `--vw-…`, dokumentiert in `docs/ux/verwaltung/tokens.md`). - Gemeinsame Bausteine wiederverwenden statt neue Masken bauen: `resources/views/filament/verwaltung/` (`kopf`, `redaktion`, `texte`, `praesentation`, `einordnung`, `picker`, `bestaetigung`, `abgang`, `aufbau`, `bestand`) mit dem Trait `App\Filament\Support\ManagesEditorialSurface`. Listen nutzen `verwaltung/bestand` mit `ShowsBestand` (bzw. `ListsCompositions`, `ListsCatalog`) und den Eintrag `<x-vw.eintrag>`, den auch der Picker verwendet; Katalogobjekte die Seite `catalog/objekt`. CMS: Seitenkopf `cms/seite-kopf` (Register, Kontexte „Abschnitt gestalten“ und „Konfigurieren“); Seiten und Menüs in der Webpräsenz (`App\Filament\Pages\Webpraesenz`, Menüs als Arbeitsstand mit einer Speicherhandlung). Der Picker liegt im Trait `ChoosesMedia` (Redaktion über `ManagesEditorialSurface`, CMS-Bilder über `ChoosesWebsiteImages`); keine eigenen Auswahllisten für Medien bauen. Redaktionelle Auswahlwerte (Materialart, Einordnung) nur über `App\Domain\Catalog\EditorialVocabulary` anbieten und prüfen (aktiv, zulässiger Kontext, vorhandene Zuordnungen erhalten); gepflegt werden sie unter „Redaktionelle Stammdaten“. Fachliche Säulen gibt es nur in der Säulenverwaltung (`pillars`); Zuordnung über `PillarService::assign`, nie über eine Dimension. Ersetzt eine Seite die Filament-Tabelle, muss sie den Dialogbereich ausgeben (in `bestand` enthalten), sonst öffnen „… anlegen“-Dialoge nicht. Gestaltungswerte nur in `verwaltung/styles.blade.php` (Tokens `--vw-…`, dokumentiert in `docs/ux/verwaltung/tokens.md`).
- Formatierte Texte (ADR-50): gespeichert wird bereinigtes HTML aus fester Auswahl, bearbeitet mit dem einen Editor `App\Filament\Support\RichField`, in den Arbeitsplätzen über `ManagesRichFields` (`richFelder()`, `kind => 'rich'`). Ausgabe nur über `App\Domain\Catalog\FormattedText` (`html()`, `display()`, `plain()`, `blocks()` fürs PDF), nie ungeprüft; verglichen wird nur `FormattedText::same()`/`canonical()`. Klartext des Altbestands bleibt in der Datenbank, bis jemand ihn ändert. Keine eigenen Textfelder mit `textarea` für Texte, die formatiert sein sollen.
- Die Redaktion ist ein Arbeitsstand: nur „Redaktion speichern“ schreibt Texte, Einordnung, Präsentationsmedien und Abweichungen. Kein verdecktes Mitspeichern aus anderen Dialogen, offene Eingaben bleiben beim Wechsel erhalten. - Die Redaktion ist ein Arbeitsstand: nur „Redaktion speichern“ schreibt Texte, Einordnung, Präsentationsmedien und Abweichungen. Kein verdecktes Mitspeichern aus anderen Dialogen, offene Eingaben bleiben beim Wechsel erhalten.
- Jede UI-Änderung in der echten Anwendung prüfen (luf-test, breite und schmale Fenster, Tastatur) und mit Screenshots in `docs/ux/verwaltung/abnahme/` belegen. Stand der Abnahme: `abnahme/teil-a.md`, `abnahme/teil-b.md`, `abnahme/teil-c.md`, `abnahme/stammdaten.md`. - Jede UI-Änderung in der echten Anwendung prüfen (luf-test, breite und schmale Fenster, Tastatur) und mit Screenshots in `docs/ux/verwaltung/abnahme/` belegen. Stand der Abnahme: `abnahme/teil-a.md`, `abnahme/teil-b.md`, `abnahme/teil-c.md`, `abnahme/stammdaten.md`.
+23
View File
@@ -27,11 +27,34 @@ public function text(string $field): ResolvedText
return $this->texts[$field] ?? new ResolvedText(null, 'leer', null); return $this->texts[$field] ?? new ResolvedText(null, 'leer', null);
} }
/**
* Text einer Angabe. Formatierte Angaben (Kurzbeschreibung, Beschreibung) kommen hier als Klartext, damit nirgends
* Auszeichnung in Karten, Listen, Suchergebnisse oder Meta-Angaben gelangt; wer die Formatierung zeigt, nutzt
* {@see self::html()}.
*/
public function value(string $field): ?string public function value(string $field): ?string
{
$value = $this->text($field)->value;
if ($value !== null && in_array($field, FormattedText::FIELDS, true)) {
return FormattedText::plain($value) ?: null;
}
return $value;
}
/** Gespeicherter Wert unverändert (HTML oder Klartext des Altbestands), für Bearbeitung und Vergleich. */
public function raw(string $field): ?string
{ {
return $this->text($field)->value; return $this->text($field)->value;
} }
/** Sicheres HTML einer formatierten Angabe; leer, wenn nichts da ist. */
public function html(string $field): string
{
return FormattedText::html($this->text($field)->value);
}
public function origin(string $field): string public function origin(string $field): string
{ {
return $this->text($field)->origin; return $this->text($field)->origin;
+3 -1
View File
@@ -145,7 +145,8 @@ public function build(User $user, LicenseArticle $article, ArticleRelease $relea
'grant' => $decision->grant, 'grant' => $decision->grant,
'download_grant' => $download?->grant, 'download_grant' => $download?->grant,
'state' => $decision->allowed ? 'ok' : ($version->status === ContentVersionStatus::Gesperrt ? 'gesperrt' : 'nicht_lizenziert'), 'state' => $decision->allowed ? 'ok' : ($version->status === ContentVersionStatus::Gesperrt ? 'gesperrt' : 'nicht_lizenziert'),
'blocks' => $decision->allowed && $class === 'text' ? GuideText::blocks($version->body) : null, 'blocks' => $decision->allowed && $class === 'text' ? FormattedText::blocks($version->body) : null,
'html' => $decision->allowed && $class === 'text' ? FormattedText::html($version->body) : null,
]; ];
} }
@@ -169,6 +170,7 @@ public function build(User $user, LicenseArticle $article, ArticleRelease $relea
'exercise' => $exercise, 'exercise' => $exercise,
'title' => $library->text($exercise->composition)['title'], 'title' => $library->text($exercise->composition)['title'],
'summary' => $library->text($exercise->composition)['summary'], 'summary' => $library->text($exercise->composition)['summary'],
'summary_html' => $library->text($exercise->composition)['summary_html'],
'learning_goal' => $exercise->learning_goal, 'learning_goal' => $exercise->learning_goal,
'duration_minutes' => $exercise->duration_minutes, 'duration_minutes' => $exercise->duration_minutes,
'duration_max' => $exercise->duration_max, 'duration_max' => $exercise->duration_max,
+156 -28
View File
@@ -77,17 +77,18 @@ public function render(array $guide, array $sections, string $licensee, string $
$this->write(self::printable('Variante: '.$variantName), 11, true, 6); $this->write(self::printable('Variante: '.$variantName), 11, true, 6);
} }
$facts = array_filter([ $this->fact('Lernziel', $guide['learning_goal']);
filled($guide['learning_goal']) ? 'Lernziel: '.$guide['learning_goal'] : null,
$guide['duration_minutes'] !== null ? 'Dauer: '.$guide['duration_minutes'].($guide['duration_max'] !== null ? ' bis '.$guide['duration_max'] : '').' Minuten' : null,
filled($guide['prerequisites']) ? 'Voraussetzungen: '.$guide['prerequisites'] : null,
filled($guide['material_note']) ? 'Ausstattung: '.$guide['material_note'] : null,
]);
foreach ($facts as $fact) { if ($guide['duration_minutes'] !== null) {
$this->write(self::printable($fact), 10.5, false, 4); $this->write(self::printable('Dauer: '.$guide['duration_minutes'].($guide['duration_max'] !== null ? ' bis '.$guide['duration_max'] : '').' Minuten'), 10.5, false, 4);
} }
if (filled($guide['prerequisites'])) {
$this->write(self::printable('Voraussetzungen: '.$guide['prerequisites']), 10.5, false, 4);
}
$this->fact('Ausstattung', $guide['material_note']);
$this->y -= 6; $this->y -= 6;
foreach ($sections as $section) { foreach ($sections as $section) {
@@ -137,41 +138,168 @@ private function section(array $section, string $guideUrl): void
$this->write($title, 12.5, true, 5); $this->write($title, 12.5, true, 5);
foreach ($section['blocks'] ?? [] as $block) { $this->formatted($section['blocks'] ?? []);
match ($block['type']) {
'heading' => $this->write(self::printable($block['text']), 11, true, 4),
'paragraph' => $this->write(self::printable($block['text']), 10.5, false, 5),
'bullets' => $this->items($block['items'], fn (int $n): string => '•'),
'numbered' => $this->items($block['items'], fn (int $n): string => $n.'.'),
};
}
$this->y -= 4; $this->y -= 4;
} }
/** Angabe mit Bezeichnung; formatierte Angaben stehen unter der Bezeichnung, einfache dahinter. */
private function fact(string $label, ?string $value): void
{
$blocks = FormattedText::blocks($value);
if ($blocks === []) {
return;
}
if (count($blocks) === 1 && $blocks[0]['type'] === 'paragraph') {
$this->runs([['text' => $label.': ', 'bold' => true, 'italic' => false, 'href' => null], ...$blocks[0]['runs']], self::LEFT, 10.5, after: 4);
return;
}
$this->write(self::printable($label.':'), 10.5, true, 2);
$this->formatted($blocks);
}
/** /**
* @param list<string> $items * Blöcke aus {@see FormattedText::blocks()}: Absatz, Zwischenüberschrift, Zitat und Listen mit fett und kursiv.
*
* @param list<array<string, mixed>> $blocks
*/ */
private function items(array $items, callable $marker): void private function formatted(array $blocks): void
{
foreach ($blocks as $block) {
match ($block['type']) {
'heading' => $this->runs($block['runs'], self::LEFT, 11, bold: true, after: 4),
'quote' => $this->runs($block['runs'], self::LEFT + 14, 10.5, italic: true, after: 5),
'bullets' => $this->listItems($block['items'], fn (int $n): string => '•'),
'numbered' => $this->listItems($block['items'], fn (int $n): string => $n.'.'),
default => $this->runs($block['runs'] ?? [], self::LEFT, 10.5, after: 5),
};
}
}
/**
* @param list<list<array{text: string, bold: bool, italic: bool, href: ?string}>> $items
*/
private function listItems(array $items, callable $marker): void
{ {
foreach ($items as $index => $item) { foreach ($items as $index => $item) {
$lines = PdfDocument::wrap(self::printable($item), self::RIGHT - self::LEFT - 18, 10.5);
foreach ($lines as $line => $text) {
$this->room(14); $this->room(14);
if ($line === 0) {
$this->pdf->text(self::LEFT + 4, $this->y, $marker($index + 1), 10.5); $this->pdf->text(self::LEFT + 4, $this->y, $marker($index + 1), 10.5);
} $this->runs($item, self::LEFT + 18, 10.5, after: 1);
$this->pdf->text(self::LEFT + 18, $this->y, $text, 10.5);
$this->y -= 14;
}
} }
$this->y -= 3; $this->y -= 3;
} }
/**
* Setzt Textabschnitte mit fett und kursiv in Zeilen um. Die Breite kommt aus den Schriftbreiten der Helvetica
* ({@see PdfDocument::exactWidth()}), damit verschiedene Schnitte in einer Zeile ohne Lücken aneinanderstoßen.
* Links erscheinen mit ausgeschriebener Adresse, weil sie auf Papier sonst verloren gehen.
*
* @param list<array{text: string, bold: bool, italic: bool, href: ?string}> $runs
*/
private function runs(array $runs, float $x, float $size, bool $bold = false, bool $italic = false, float $after = 0): void
{
$maxWidth = self::RIGHT - $x;
$lines = [];
$line = [];
$width = 0.0;
$pendingSpace = false;
$count = count($runs);
$flush = function () use (&$lines, &$line, &$width, &$pendingSpace): void {
if ($line !== []) {
$lines[] = $line;
}
$line = [];
$width = 0.0;
$pendingSpace = false;
};
$place = function (string $word, bool $isBold, bool $isItalic) use (&$line, &$width, &$pendingSpace, $maxWidth, $size, $flush): void {
$space = $pendingSpace && $line !== [] ? ' ' : '';
$need = PdfDocument::exactWidth($space.$word, $size, $isBold);
if ($line !== [] && $width + $need > $maxWidth) {
$flush();
$space = '';
$need = PdfDocument::exactWidth($word, $size, $isBold);
}
while ($need > $maxWidth && mb_strlen($word) > 1) {
$cut = mb_strlen($word) - 1;
while ($cut > 1 && PdfDocument::exactWidth(mb_substr($word, 0, $cut), $size, $isBold) > $maxWidth) {
$cut--;
}
$line[] = [mb_substr($word, 0, $cut), $isBold, $isItalic];
$flush();
$word = mb_substr($word, $cut);
$need = PdfDocument::exactWidth($word, $size, $isBold);
}
$last = $line === [] ? null : $line[array_key_last($line)];
if ($last !== null && $last[1] === $isBold && $last[2] === $isItalic) {
$line[array_key_last($line)][0] .= $space.$word;
} else {
$line[] = [$space.$word, $isBold, $isItalic];
}
$width += $need;
$pendingSpace = false;
};
foreach ($runs as $index => $run) {
$isBold = $bold || $run['bold'];
$isItalic = $italic || $run['italic'];
foreach (preg_split('/(\s+)/u', self::printable($run['text']), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) ?: [] as $token) {
if (trim($token) !== '') {
$place($token, $isBold, $isItalic);
continue;
}
if (str_contains($token, "\n")) {
$flush();
continue;
}
$pendingSpace = true;
}
$nextHref = $index + 1 < $count ? $runs[$index + 1]['href'] : null;
if ($run['href'] !== null && $nextHref !== $run['href'] && ! str_contains($run['text'], $run['href'])) {
$pendingSpace = true;
$place('('.self::printable($run['href']).')', false, false);
}
}
$flush();
foreach ($lines as $row) {
$this->room($size + 4);
$cursor = $x;
foreach ($row as [$text, $isBold, $isItalic]) {
$this->pdf->text($cursor, $this->y, $text, $size, $isBold, $isItalic);
$cursor += PdfDocument::exactWidth($text, $size, $isBold);
}
$this->y -= $size + 4;
}
$this->y -= $after;
}
private function write(string $text, float $size, bool $bold, float $after): void private function write(string $text, float $size, bool $bold, float $after): void
{ {
foreach (PdfDocument::wrap($text, self::RIGHT - self::LEFT, $size, $bold) as $line) { foreach (PdfDocument::wrap($text, self::RIGHT - self::LEFT, $size, $bold) as $line) {
+375
View File
@@ -0,0 +1,375 @@
<?php
namespace App\Domain\Catalog;
use Dom\HTMLDocument;
use Dom\Node;
use Symfony\Component\HtmlSanitizer\HtmlSanitizer;
use Symfony\Component\HtmlSanitizer\HtmlSanitizerConfig;
/**
* Formatierter Text in der Verwaltung und im Mitgliederbereich (ADR-50).
*
* Gespeichert wird bereinigtes HTML aus einer festen Auswahl: Absatz, Zwischenüberschrift (h3), fett, kursiv, Aufzählung,
* nummerierte Liste, Zitat, Link und Zeilenumbruch. Alles andere fällt beim Speichern weg, auch Skripte, Ereignis­attribute
* und Links auf andere Schemata als http, https und mailto.
*
* Klartext aus dem Altbestand bleibt unverändert in der Datenbank. Er wird erst beim Anzeigen oder Bearbeiten in dieselbe
* Form gebracht ({@see self::html()}) und erst beim Speichern als HTML abgelegt. Erkannt wird HTML an einer Regel: Der
* Text beginnt (nach Leerraum) mit einem der Blockelemente dieser Auswahl. Gespeichertes HTML ist kanonisch und beginnt
* deshalb immer so; Klartext beginnt nie mit einem solchen Tag, wenn er nicht von Hand so geschrieben wurde.
*
* Verglichen und gehasht wird immer nur die kanonische Form ({@see self::canonical()}), damit das Öffnen im Editor oder
* eine andere Schreibweise desselben Inhalts keine neue Fassung und keinen Scheinkonflikt erzeugt.
*/
final class FormattedText
{
/** Blockelemente, mit denen gespeichertes HTML beginnt. */
private const BLOCKS = ['p', 'h3', 'ul', 'ol', 'blockquote'];
/** Angaben der Redaktion, die formatiert gespeichert werden. Suchbegriffe, Titel und Teaser bleiben Klartext. */
public const FIELDS = ['summary', 'description'];
private static ?HtmlSanitizer $sanitizer = null;
/** Symbolleiste der Editoren; muss zur Auswahl oben passen. */
public const TOOLBAR = [['bold', 'italic', 'link'], ['h3'], ['bulletList', 'orderedList', 'blockquote'], ['undo', 'redo']];
/** Wird der Wert als HTML gelesen (sonst als Klartext des Altbestands)? */
public static function isHtml(?string $value): bool
{
return preg_match('/^\s*<(?:'.implode('|', self::BLOCKS).')[\s>\/]/i', (string) $value) === 1;
}
/**
* Kanonische Form eines gespeicherten oder eingegebenen Werts (HTML oder Klartext). Leer, wenn kein Text übrig ist.
*/
public static function canonical(?string $value): string
{
$value = trim((string) $value);
if ($value === '') {
return '';
}
return self::normalize(self::isHtml($value) ? $value : self::legacyToHtml($value));
}
/**
* Kanonische Form eines Werts, der sicher HTML ist (zum Beispiel aus der Quelle Shinkan), auch wenn er nicht mit
* einem Blockelement beginnt.
*/
public static function canonicalHtml(?string $html): string
{
$html = trim((string) $html);
return $html === '' ? '' : self::normalize($html);
}
/** Sicheres HTML zur Ausgabe (für `{!! !!}`); Klartext des Altbestands wird dabei umgewandelt. */
public static function html(?string $value): string
{
return self::canonical($value);
}
/**
* Sicheres HTML zur Ausgabe an Stellen, die Klartext des Altbestands bisher mit Zeilenumbrüchen zeigten: HTML wird
* bereinigt ausgegeben, Klartext bleibt, wie er war (maskiert, Zeilenumbrüche erhalten).
*/
public static function display(?string $value): string
{
$value = (string) $value;
return self::isHtml($value) ? self::canonical($value) : nl2br(e($value));
}
public static function isBlank(?string $value): bool
{
return self::canonical($value) === '';
}
/** Sind beide Werte inhaltlich gleich (unabhängig von Klartext oder Schreibweise des HTML)? */
public static function same(?string $a, ?string $b): bool
{
return self::canonical($a) === self::canonical($b);
}
/**
* Text ohne Auszeichnung für Orte, die kein HTML vertragen (Zahlungsdienst, Meta-Beschreibung, Listen). Absätze sind
* durch Leerzeilen getrennt, Listenpunkte beginnen mit „- “ beziehungsweise „1. “.
*/
public static function plain(?string $value): string
{
$out = [];
foreach (self::blocks($value) as $block) {
$out[] = match ($block['type']) {
'bullets' => implode("\n", array_map(fn (array $item): string => '- '.self::runsText($item), $block['items'])),
'numbered' => implode("\n", array_map(fn (array $item, int $n): string => ($n + 1).'. '.self::runsText($item), $block['items'], array_keys($block['items']))),
default => self::runsText($block['runs']),
};
}
return trim(implode("\n\n", $out));
}
/** Kurzer Text für Listen und Karten. */
public static function excerpt(?string $value, int $length = 120): string
{
$text = trim((string) preg_replace('/\s+/u', ' ', self::plain($value)));
return mb_strlen($text) > $length ? rtrim(mb_substr($text, 0, $length - 1)).'…' : $text;
}
/**
* Zerlegung in Blöcke mit Textabschnitten für das PDF. Ein Textabschnitt (Run) trägt `text`, `bold`, `italic` und
* `href`.
*
* @return list<array{type: 'paragraph'|'heading'|'quote'|'bullets'|'numbered', runs?: list<array{text: string, bold: bool, italic: bool, href: ?string}>, items?: list<list<array{text: string, bold: bool, italic: bool, href: ?string}>>}>
*/
public static function blocks(?string $value): array
{
$html = self::canonical($value);
if ($html === '') {
return [];
}
$document = HTMLDocument::createFromString('<body>'.$html.'</body>', LIBXML_NOERROR);
$blocks = [];
foreach ($document->body->childNodes as $node) {
if ($node->nodeType !== XML_ELEMENT_NODE) {
continue;
}
$name = strtolower($node->nodeName);
if (in_array($name, ['ul', 'ol'], true)) {
$items = [];
foreach ($node->childNodes as $item) {
if ($item->nodeType === XML_ELEMENT_NODE && strtolower($item->nodeName) === 'li') {
$items[] = self::runs($item);
}
}
$blocks[] = ['type' => $name === 'ul' ? 'bullets' : 'numbered', 'items' => $items];
continue;
}
$blocks[] = [
'type' => match ($name) {
'h3' => 'heading',
'blockquote' => 'quote',
default => 'paragraph',
},
'runs' => self::runs($node),
];
}
return $blocks;
}
/**
* Klartext des Altbestands als HTML: Absätze an Leerzeilen, Listen mit „- “, „• “ oder „1. “, Zwischenüberschriften
* mit „## “. Dieselben Konventionen wie {@see GuideText}.
*/
public static function legacyToHtml(?string $text): string
{
$html = '';
foreach (GuideText::blocks($text) as $block) {
$html .= match ($block['type']) {
'heading' => '<h3>'.e($block['text']).'</h3>',
'bullets' => '<ul>'.implode('', array_map(fn (string $item): string => '<li><p>'.e($item).'</p></li>', $block['items'])).'</ul>',
'numbered' => '<ol>'.implode('', array_map(fn (string $item): string => '<li><p>'.e($item).'</p></li>', $block['items'])).'</ol>',
default => '<p>'.e($block['text']).'</p>',
};
}
return $html;
}
private static function normalize(string $html): string
{
$html = self::mapLegacyTags($html);
$html = trim(self::sanitizer()->sanitize($html));
if ($html === '') {
return '';
}
$document = HTMLDocument::createFromString('<body>'.$html.'</body>', LIBXML_NOERROR);
$body = $document->body;
$out = '';
$loose = '';
$flush = function () use (&$out, &$loose): void {
$loose = trim($loose);
if ($loose !== '' && trim(strip_tags(str_replace(['<br>', '<br/>', '<br />'], '', $loose))) !== '') {
$out .= '<p>'.$loose.'</p>';
}
$loose = '';
};
foreach ($body->childNodes as $node) {
if ($node->nodeType === XML_ELEMENT_NODE && in_array(strtolower($node->nodeName), self::BLOCKS, true)) {
$flush();
$out .= self::block($node);
continue;
}
$loose .= $document->saveHtml($node);
}
$flush();
return self::hasText($out) ? $out : '';
}
/** Ein Blockelement ohne Leerraum zwischen den Kindern; Listenpunkte tragen ihren Text immer in einem Absatz. */
private static function block(Node $node): string
{
$name = strtolower($node->nodeName);
if (in_array($name, ['ul', 'ol'], true)) {
$items = '';
foreach ($node->childNodes as $child) {
if ($child->nodeType !== XML_ELEMENT_NODE || strtolower($child->nodeName) !== 'li') {
continue;
}
$inner = self::inner($child);
if (! str_contains($inner, '<p>')) {
$inner = '<p>'.$inner.'</p>';
}
if (self::hasText($inner)) {
$items .= '<li>'.$inner.'</li>';
}
}
return $items === '' ? '' : '<'.$name.'>'.$items.'</'.$name.'>';
}
$inner = self::inner($node);
if ($name === 'blockquote' && ! str_contains($inner, '<p>')) {
$inner = '<p>'.$inner.'</p>';
}
return self::hasText($inner) ? '<'.$name.'>'.$inner.'</'.$name.'>' : '';
}
private static function inner(Node $node): string
{
$html = '';
foreach ($node->childNodes as $child) {
if ($child->nodeType === XML_ELEMENT_NODE && in_array(strtolower($child->nodeName), ['ul', 'ol', 'p', 'blockquote'], true)) {
$html .= self::block($child);
continue;
}
$html .= $node->ownerDocument->saveHtml($child);
}
return trim($html);
}
private static function hasText(string $html): bool
{
return trim(html_entity_decode(strip_tags($html), ENT_QUOTES | ENT_HTML5, 'UTF-8')) !== '';
}
/** b, i und andere Überschriftsstufen der Quelle werden auf die feste Auswahl abgebildet; der Rest fällt in der Bereinigung weg. */
private static function mapLegacyTags(string $html): string
{
$html = (string) preg_replace('/<(\/?)b(?=[\s>\/])/i', '<$1strong', $html);
$html = (string) preg_replace('/<(\/?)i(?=[\s>\/])/i', '<$1em', $html);
$html = (string) preg_replace('/<(\/?)h[1-6](?=[\s>\/])/i', '<$1h3', $html);
return (string) preg_replace('/<(\/?)div(?=[\s>\/])/i', '<$1p', $html);
}
/**
* @return list<array{text: string, bold: bool, italic: bool, href: ?string}>
*/
private static function runs(Node $node, bool $bold = false, bool $italic = false, ?string $href = null): array
{
$runs = [];
foreach ($node->childNodes as $child) {
if ($child->nodeType === XML_TEXT_NODE) {
$runs[] = ['text' => (string) $child->textContent, 'bold' => $bold, 'italic' => $italic, 'href' => $href];
continue;
}
if ($child->nodeType !== XML_ELEMENT_NODE) {
continue;
}
$name = strtolower($child->nodeName);
if ($name === 'br') {
$runs[] = ['text' => "\n", 'bold' => $bold, 'italic' => $italic, 'href' => $href];
continue;
}
if (in_array($name, ['p', 'ul', 'ol', 'blockquote'], true)) {
// Verschachtelte Blöcke (Absatz im Listenpunkt) werden zu Fließtext.
$runs = [...$runs, ...self::runs($child, $bold, $italic, $href)];
continue;
}
$runs = [...$runs, ...self::runs(
$child,
$bold || $name === 'strong',
$italic || $name === 'em',
$name === 'a' ? ((string) $child->getAttribute('href') ?: $href) : $href,
)];
}
return $runs;
}
/**
* @param list<array{text: string, bold: bool, italic: bool, href: ?string}> $runs
*/
private static function runsText(array $runs): string
{
return trim(implode('', array_map(fn (array $run): string => $run['text'], $runs)));
}
private static function sanitizer(): HtmlSanitizer
{
return self::$sanitizer ??= new HtmlSanitizer(
(new HtmlSanitizerConfig)
->allowElement('p')
->allowElement('br')
->allowElement('h3')
->allowElement('strong')
->allowElement('em')
->allowElement('ul')
->allowElement('ol')
->allowElement('li')
->allowElement('blockquote')
->allowElement('a', ['href'])
->allowLinkSchemes(['http', 'https', 'mailto'])
->allowRelativeLinks(false)
->forceAttribute('a', 'rel', 'noopener noreferrer')
->withMaxInputLength(100000),
);
}
}
+10 -1
View File
@@ -27,7 +27,16 @@ public function url(): ?string
{ {
$value = config('services.shinkan.url'); $value = config('services.shinkan.url');
return is_string($value) && trim($value) !== '' ? rtrim(trim($value), '/') : null; if (! is_string($value) || trim($value) === '') {
return null;
}
// Die Adresse ist die der Shinkan-Installation. Der Pfad `/api/distribution/v1` hängt der Abruf selbst an; wer ihn
// (oder nur `/api`) mit einträgt, bekommt trotzdem die richtige Adresse und keinen doppelten Pfad.
$base = rtrim(trim($value), '/');
$base = (string) preg_replace('#/api(/distribution(/v1)?)?$#', '', $base);
return $base === '' ? null : $base;
} }
public function apiKey(): ?string public function apiKey(): ?string
+305 -58
View File
@@ -33,6 +33,20 @@ class ShinkanImport
'trainer_notes' => 'Trainerhinweise', 'trainer_notes' => 'Trainerhinweise',
]; ];
/** Felder, die Shinkan bei `text_format: html` als HTML liefert (ADR-50). Ohne diese Angabe sind alle Texte Klartext. */
private const HTML_FIELDS = ['summary', 'goal', 'execution', 'preparation', 'trainer_notes'];
/** Änderungshinweis der Textfassungen, die die Übernahme angelegt hat. Alles andere ist eine lokale Bearbeitung. */
private const IMPORT_NOTE = 'Übernahme aus Shinkan';
/** Fassungsfelder der Quelle: Katalogfeld => [Feld der lokalen Fassung, Bezeichnung]. */
private const FIELDS = [
'goal' => ['learning_goal', 'Lernziel'],
'duration_min' => ['duration_minutes', 'Dauer (von)'],
'duration_max' => ['duration_max', 'Dauer (bis)'],
'equipment' => ['material_note', 'Ausstattung'],
];
public function configured(): bool public function configured(): bool
{ {
return app(ShinkanConnection::class)->configured(); return app(ShinkanConnection::class)->configured();
@@ -201,8 +215,8 @@ public function preview(ExerciseSource $source): array
$sections = []; $sections = [];
foreach (self::SECTIONS as $field => $label) { foreach (self::SECTIONS as $field => $label) {
if (trim((string) ($document[$field] ?? '')) !== '') { if ($this->value($document, $field) !== '') {
$sections[] = ['label' => $label, 'text' => mb_strimwidth(trim((string) $document[$field]), 0, 280, '…')]; $sections[] = ['label' => $label, 'text' => FormattedText::excerpt($this->value($document, $field), 280)];
} }
} }
@@ -212,20 +226,22 @@ public function preview(ExerciseSource $source): array
'hash' => $snapshot?->content_hash, 'hash' => $snapshot?->content_hash,
'state' => $state, 'state' => $state,
'title' => (string) ($document['title'] ?? $source->title), 'title' => (string) ($document['title'] ?? $source->title),
'summary' => (string) ($document['summary'] ?? ''), 'summary' => FormattedText::plain($this->value($document, 'summary')),
'goal' => (string) ($document['goal'] ?? ''), 'goal' => FormattedText::plain($this->value($document, 'goal')),
'duration' => $this->duration($document), 'duration' => $this->duration($document),
'equipment' => (string) ($document['equipment'] ?? ''), 'equipment' => FormattedText::plain($this->value($document, 'equipment')),
'sections' => $sections, 'sections' => $sections,
'variants' => array_map(fn (array $variant): array => [ 'variants' => array_map(fn (array $variant): array => [
'key' => (string) ($variant['id'] ?? ''), 'key' => (string) ($variant['id'] ?? ''),
'name' => (string) ($variant['name'] ?? ''), 'name' => (string) ($variant['name'] ?? ''),
'description' => (string) ($variant['description'] ?? ''), 'description' => (string) ($variant['description'] ?? ''),
'changes' => trim((string) ($variant['execution_changes'] ?? '')) !== '', 'changes' => $this->variantChanges($document, $variant) !== '',
], array_values(array_filter((array) ($document['variants'] ?? []), 'is_array'))), ], array_values(array_filter((array) ($document['variants'] ?? []), 'is_array'))),
'media' => array_map(fn (array $media): string => ($media['title'] ?? 'Medium').' ('.($media['media_type'] ?? '').')', array_values(array_filter((array) ($document['media'] ?? []), 'is_array'))), 'media' => array_map(fn (array $media): string => ($media['title'] ?? 'Medium').' ('.($media['media_type'] ?? '').')', array_values(array_filter((array) ($document['media'] ?? []), 'is_array'))),
'changes' => $previous === null ? [] : $this->changes($previous->payload, $document, $source), 'changes' => $previous === null ? [] : $this->changes($previous->payload, $document, $source),
'conflicts' => $snapshot === null ? [] : $this->conflicts($source, $document), 'conflicts' => $snapshot === null ? [] : $this->conflicts($source, $document),
'text_conflicts' => $snapshot === null ? [] : $this->textDecisions($source, $document, 'conflict'),
'kept_local' => $snapshot === null ? [] : array_column($this->textDecisions($source, $document, 'keep_local'), 'label'),
'identical' => $snapshot !== null && $snapshot->adopted_version_id !== null, 'identical' => $snapshot !== null && $snapshot->adopted_version_id !== null,
'excluded' => $source->availability === ExerciseSource::WITHDRAWN, 'excluded' => $source->availability === ExerciseSource::WITHDRAWN,
]; ];
@@ -247,7 +263,7 @@ public function changes(array $before, array $after, ?ExerciseSource $source = n
] + self::SECTIONS; ] + self::SECTIONS;
foreach ($labels as $field => $label) { foreach ($labels as $field => $label) {
if (trim((string) ($before[$field] ?? '')) !== trim((string) ($after[$field] ?? ''))) { if (! $this->sameValue($field, $before, $after)) {
$lines[] = $label.' geändert'; $lines[] = $label.' geändert';
} }
} }
@@ -269,7 +285,7 @@ public function changes(array $before, array $after, ?ExerciseSource $source = n
} }
if (trim((string) ($variant['description'] ?? '')) !== trim((string) ($old[$key]['description'] ?? '')) if (trim((string) ($variant['description'] ?? '')) !== trim((string) ($old[$key]['description'] ?? ''))
|| trim((string) ($variant['execution_changes'] ?? '')) !== trim((string) ($old[$key]['execution_changes'] ?? ''))) { || ! FormattedText::same($this->variantChanges($after, $variant), $this->variantChanges($before, (array) $old[$key]))) {
$lines[] = 'Variante „'.($variant['name'] ?? '').'“ geändert'; $lines[] = 'Variante „'.($variant['name'] ?? '').'“ geändert';
} }
} }
@@ -285,7 +301,7 @@ public function changes(array $before, array $after, ?ExerciseSource $source = n
$lines[] = 'Der Titel wurde lokal geändert und bleibt unverändert'; $lines[] = 'Der Titel wurde lokal geändert und bleibt unverändert';
} }
if (($before['summary'] ?? '') !== ($after['summary'] ?? '') && filled($source->composition->summary) && $source->composition->summary !== ($before['summary'] ?? '')) { if (! $this->sameValue('summary', $before, $after) && filled($source->composition->summary) && ! FormattedText::same($source->composition->summary, $this->value($before, 'summary'))) {
$lines[] = 'Die Kurzbeschreibung wurde lokal geändert und bleibt unverändert'; $lines[] = 'Die Kurzbeschreibung wurde lokal geändert und bleibt unverändert';
} }
} }
@@ -327,14 +343,54 @@ public function conflicts(ExerciseSource $source, array $document): array
return array_values($open); return array_values($open);
} }
/**
* Texte und Felder, die lokal bearbeitet wurden: `keep_local` bleiben erhalten, bei `conflict` hat auch die Quelle
* geändert und die Redaktion entscheidet.
*
* @param array<string, mixed> $document
* @return list<array{key: string, label: string}>
*/
public function textDecisions(ExerciseSource $source, array $document, string $wanted): array
{
$previousSnapshot = $this->lastAdopted($source);
if ($previousSnapshot === null || $source->composition === null) {
return [];
}
$previousSource = $previousSnapshot->payload;
$result = [];
foreach ($this->plan($source, $document, $previousSource) as $item) {
if ($item['kind'] === 'text' && $item['decision'] === $wanted) {
$result[] = ['key' => $item['key'], 'label' => $item['label']];
}
}
$latest = $source->composition->versions()->orderByDesc('number')->first();
foreach (self::FIELDS as $field => [$column, $label]) {
$isText = in_array($field, ['goal', 'equipment'], true);
$old = $isText ? ($this->value($previousSource, $field) ?: null) : ($previousSource[$field] ?? null);
$new = $isText ? ($this->value($document, $field) ?: null) : ($document[$field] ?? null);
if ($latest !== null && $this->classifyField($latest->{$column}, $old, $new, $isText) === $wanted) {
$result[] = ['key' => $field, 'label' => $label];
}
}
return $result;
}
/** /**
* Übernimmt genau den Stand, den die Redaktion in der Vorschau gesehen hat. Hat sich der Stand seither geändert oder * Übernimmt genau den Stand, den die Redaktion in der Vorschau gesehen hat. Hat sich der Stand seither geändert oder
* wurde die Quelle ausgeblendet, wird nichts übernommen. Identische bereits übernommene Stände ergeben keine Fassung. * wurde die Quelle ausgeblendet, wird nichts übernommen. Identische bereits übernommene Stände ergeben keine Fassung.
* *
* @param array<string, string> $reassign neue Zuordnung entfallener Quellvarianten: alter Schlüssel => neuer Schlüssel oder '' * @param array<string, string> $reassign neue Zuordnung entfallener Quellvarianten: alter Schlüssel => neuer Schlüssel oder ''
* @param array<string, string> $choices bei lokal und in der Quelle geänderten Angaben: Schlüssel => `lokal` oder `quelle`
* @return array{status: string, message: string, version?: CompositionVersion} * @return array{status: string, message: string, version?: CompositionVersion}
*/ */
public function adoptPreviewed(ExerciseSource $source, int $previewedSnapshot, array $reassign = [], ?User $actor = null): array public function adoptPreviewed(ExerciseSource $source, int $previewedSnapshot, array $reassign = [], ?User $actor = null, array $choices = []): array
{ {
$source->refresh(); $source->refresh();
$latest = $source->latestSnapshot(); $latest = $source->latestSnapshot();
@@ -352,7 +408,7 @@ public function adoptPreviewed(ExerciseSource $source, int $previewedSnapshot, a
} }
try { try {
$version = $this->adopt($latest, $actor, $reassign); $version = $this->adopt($latest, $actor, $reassign, $choices);
} catch (DomainRuleException $exception) { } catch (DomainRuleException $exception) {
return ['status' => 'fehler', 'message' => $exception->getMessage()]; return ['status' => 'fehler', 'message' => $exception->getMessage()];
} }
@@ -362,11 +418,17 @@ public function adoptPreviewed(ExerciseSource $source, int $previewedSnapshot, a
/** /**
* Die bewusste Übernahme: aus dem Inhaltsstand wird eine neue, unveränderliche lokale Fassung. Wiederholt man sie, * Die bewusste Übernahme: aus dem Inhaltsstand wird eine neue, unveränderliche lokale Fassung. Wiederholt man sie,
* entsteht keine zweite Fassung. Lokale Ergänzungen der bisherigen Fassung werden übernommen. * entsteht keine zweite Fassung.
*
* Eine importierte Übung ist eine Übung wie jede andere und lässt sich bearbeiten. Lokal bearbeitete Texte und Felder
* bleiben deshalb erhalten, solange die Quelle sie nicht ebenfalls geändert hat. Haben beide Seiten geändert, legt die
* Redaktion fest, welcher Stand gilt (`$choices`). Lokale Ergänzungen bleiben erhalten; entfällt ihre Quellvariante,
* legt die Redaktion die neue Zuordnung fest (`$reassign`).
* *
* @param array<string, string> $reassign * @param array<string, string> $reassign
* @param array<string, string> $choices Schlüssel => `lokal` oder `quelle`
*/ */
public function adopt(ExerciseSourceSnapshot $snapshot, ?User $actor = null, array $reassign = []): CompositionVersion public function adopt(ExerciseSourceSnapshot $snapshot, ?User $actor = null, array $reassign = [], array $choices = []): CompositionVersion
{ {
$snapshot->refresh(); $snapshot->refresh();
@@ -374,57 +436,74 @@ public function adopt(ExerciseSourceSnapshot $snapshot, ?User $actor = null, arr
return $snapshot->adoptedVersion; return $snapshot->adoptedVersion;
} }
return DB::transaction(function () use ($snapshot, $actor, $reassign): CompositionVersion { return DB::transaction(function () use ($snapshot, $actor, $reassign, $choices): CompositionVersion {
$source = $snapshot->source; $source = $snapshot->source;
$document = $snapshot->payload; $document = $snapshot->payload;
$content = app(ContentService::class); $content = app(ContentService::class);
$title = trim((string) ($document['title'] ?? '')) ?: 'Übung aus Shinkan'; $title = trim((string) ($document['title'] ?? '')) ?: 'Übung aus Shinkan';
$previousSnapshot = $this->lastAdopted($source); $previousSnapshot = $this->lastAdopted($source);
$composition = $source->composition ?? $this->createComposition($title, (string) ($document['summary'] ?? '')); $previousSource = $previousSnapshot?->payload ?? [];
$composition = $source->composition ?? $this->createComposition($title, $this->value($document, 'summary'));
if ($source->composition !== null && $previousSnapshot !== null) { if ($source->composition !== null && $previousSnapshot !== null) {
$this->carryOverTexts($composition, $previousSnapshot->payload, $document); $this->carryOverTexts($composition, $previousSource, $document);
} }
$previous = $composition->versions()->orderByDesc('number')->with('members.variant', 'variants')->first(); $previous = $composition->versions()->orderByDesc('number')->with('members.variant', 'variants')->first();
$variants = []; $variants = [];
$members = []; $members = [];
foreach (self::SECTIONS as $field => $label) { foreach ($this->plan($source, $document, $previousSource) as $item) {
$text = trim((string) ($document[$field] ?? '')); if ($item['kind'] === 'variant') {
$variants[] = $item['variant'];
if ($text !== '') {
$members[] = [
'role' => $label,
'target' => $this->section($source, $field, $title.' · '.$label, $text),
'origin' => 'quelle',
];
}
}
foreach ((array) ($document['variants'] ?? []) as $variant) {
$key = (string) ($variant['id'] ?? '');
if ($key === '') {
continue; continue;
} }
$variants[] = [ $latest = $item['latest'];
'key' => $key, $decision = $item['decision'];
'name' => (string) ($variant['name'] ?? '') ?: 'Variante',
'description' => (string) ($variant['description'] ?? ''),
'origin' => 'quelle',
];
$changes = trim((string) ($variant['execution_changes'] ?? ''));
if ($changes !== '') { if ($decision === 'conflict') {
$members[] = [ $decision = ($choices[$item['key']] ?? null) === 'lokal' ? 'keep_local'
'role' => 'Abweichung der Durchführung', : (($choices[$item['key']] ?? null) === 'quelle' ? 'source' : 'conflict');
'target' => $this->section($source, 'variant:'.$key, $title.' · '.($variant['name'] ?? 'Variante').' · Abweichung', $changes),
'variant' => $key,
'origin' => 'quelle',
];
} }
if ($decision === 'conflict') {
throw new DomainRuleException('„'.$item['label'].'“ wurde lokal und in der Quelle geändert. Lege fest, welcher Stand gilt.');
}
$keepLocal = $decision === 'keep_local' && $latest !== null;
$target = $keepLocal ? $latest : $this->sectionVersion($source, $item['field'], $item['title'], $item['text'], $latest);
$members[] = array_filter([
'role' => $item['role'],
'target' => $target,
'variant' => $item['variant_key'],
'origin' => $keepLocal || ($latest !== null && $latest->id === $target->id && $latest->change_note !== self::IMPORT_NOTE) ? 'lokal' : 'quelle',
], fn ($value): bool => $value !== null);
}
// Fassungsfelder: lokal geändert bleibt erhalten, solange die Quelle den Wert nicht ebenfalls geändert hat.
$fields = [];
foreach (self::FIELDS as $field => [$column, $label]) {
$isText = in_array($field, ['goal', 'equipment'], true);
$value = $isText ? ($this->value($document, $field) ?: null) : ($document[$field] ?? null);
if ($previous !== null && $previousSnapshot !== null) {
$decision = $this->classifyField($previous->{$column}, $isText ? ($this->value($previousSource, $field) ?: null) : ($previousSource[$field] ?? null), $value, $isText);
if ($decision === 'conflict') {
$decision = ($choices[$field] ?? null) === 'lokal' ? 'keep_local' : (($choices[$field] ?? null) === 'quelle' ? 'source' : 'conflict');
}
if ($decision === 'conflict') {
throw new DomainRuleException('„'.$label.'“ wurde lokal und in der Quelle geändert. Lege fest, welcher Stand gilt.');
}
$value = $decision === 'keep_local' ? $previous->{$column} : $value;
}
$fields[$column] = $value;
} }
[$localMembers, $localVariants] = $this->localAdditions($previous, array_column($variants, 'key'), $reassign); [$localMembers, $localVariants] = $this->localAdditions($previous, array_column($variants, 'key'), $reassign);
@@ -432,12 +511,12 @@ public function adopt(ExerciseSourceSnapshot $snapshot, ?User $actor = null, arr
$composition, $composition,
[...$members, ...$localMembers], [...$members, ...$localMembers],
$actor, $actor,
'Übernahme aus Shinkan', self::IMPORT_NOTE,
[ [
'learning_goal' => $document['goal'] ?? null, 'learning_goal' => $fields['learning_goal'],
'duration_minutes' => $document['duration_min'] ?? null, 'duration_minutes' => $fields['duration_minutes'],
'duration_max' => $document['duration_max'] ?? null, 'duration_max' => $fields['duration_max'],
'material_note' => $document['equipment'] ?? null, 'material_note' => $fields['material_note'],
'source_snapshot_id' => $snapshot->id, 'source_snapshot_id' => $snapshot->id,
], ],
[...$variants, ...$localVariants], [...$variants, ...$localVariants],
@@ -450,6 +529,148 @@ public function adopt(ExerciseSourceSnapshot $snapshot, ?User $actor = null, arr
}); });
} }
/**
* Was die Übernahme aus dem Quellstand anlegen würde, mit der Entscheidung je Text: `source` (Quelltext gilt),
* `keep_local` (lokal bearbeitet, die Quelle hat sich nicht geändert) oder `conflict` (beide haben geändert).
*
* @param array<string, mixed> $document
* @param array<string, mixed> $previousSource
* @return list<array<string, mixed>>
*/
private function plan(ExerciseSource $source, array $document, array $previousSource): array
{
$plan = [];
$title = trim((string) ($document['title'] ?? '')) ?: 'Übung aus Shinkan';
foreach (self::SECTIONS as $field => $label) {
$text = $this->value($document, $field);
if ($text !== '') {
$plan[] = $this->textItem($source, $field, $label, $title.' · '.$label, $label, $text, null, $this->value($previousSource, $field) ?: null);
}
}
foreach ((array) ($document['variants'] ?? []) as $variant) {
$key = (string) ($variant['id'] ?? '');
if ($key === '') {
continue;
}
$name = (string) ($variant['name'] ?? '') ?: 'Variante';
$plan[] = [
'kind' => 'variant',
'variant' => ['key' => $key, 'name' => $name, 'description' => (string) ($variant['description'] ?? ''), 'origin' => 'quelle'],
];
$changes = $this->variantChanges($document, $variant);
if ($changes !== '') {
$before = collect((array) ($previousSource['variants'] ?? []))->firstWhere('id', $key);
$plan[] = $this->textItem(
$source,
'variant:'.$key,
'Abweichung der Durchführung ('.$name.')',
$title.' · '.$name.' · Abweichung',
'Abweichung der Durchführung',
$changes,
$key,
is_array($before) ? ($this->variantChanges($previousSource, $before) ?: null) : null,
'variant_'.$key,
);
}
}
return $plan;
}
/**
* @return array<string, mixed>
*/
private function textItem(ExerciseSource $source, string $field, string $label, string $title, string $role, string $text, ?string $variantKey, ?string $previousText, ?string $key = null): array
{
$element = ContentElement::query()->where('source_ref', 'shinkan:'.$source->source_id.':'.$field)->first();
$latest = $element?->versions()->where('status', ContentVersionStatus::Bereit)->orderByDesc('number')->first();
return [
'kind' => 'text',
'key' => $key ?? $field,
'field' => $field,
'label' => $label,
'title' => $title,
'role' => $role,
'text' => $text,
'variant_key' => $variantKey,
'latest' => $latest,
'decision' => $this->classifyText($latest, $text, $previousText),
];
}
private function classifyText(?ContentElementVersion $latest, string $text, ?string $previousText): string
{
if ($latest === null || FormattedText::same($latest->body, $text) || $latest->change_note === self::IMPORT_NOTE) {
return 'source';
}
return $previousText === null || ! FormattedText::same($previousText, $text) ? 'conflict' : 'keep_local';
}
private function classifyField(mixed $local, mixed $previousSource, mixed $new, bool $text = false): string
{
$same = $text
? fn (mixed $a, mixed $b): bool => FormattedText::same($a === null ? null : (string) $a, $b === null ? null : (string) $b)
: fn (mixed $a, mixed $b): bool => ($a === null ? '' : trim((string) $a)) === ($b === null ? '' : trim((string) $b));
if ($same($local, $new) || $same($local, $previousSource)) {
return 'source';
}
return ! $same($previousSource, $new) ? 'conflict' : 'keep_local';
}
/**
* Text eines Felds der Quelle in der Form, in der er übernommen wird: Bei `text_format: html` wird das HTML bereinigt
* und kanonisch, sonst bleibt der Klartext, wie er geliefert wird.
*
* @param array<string, mixed> $document
*/
private function value(array $document, string $field): string
{
$raw = trim((string) ($document[$field] ?? ''));
return ($document['text_format'] ?? null) === 'html' && in_array($field, self::HTML_FIELDS, true)
? FormattedText::canonicalHtml($raw)
: $raw;
}
/**
* Abweichung der Durchführung einer Variante, im Format des Dokuments.
*
* @param array<string, mixed> $document
* @param array<string, mixed> $variant
*/
private function variantChanges(array $document, array $variant): string
{
$raw = trim((string) ($variant['execution_changes'] ?? ''));
return ($document['text_format'] ?? null) === 'html' ? FormattedText::canonicalHtml($raw) : $raw;
}
/**
* Ist das Feld in beiden Quellständen inhaltlich gleich? Texte werden als kanonischer Text verglichen, alles andere
* ohne führenden und folgenden Leerraum.
*
* @param array<string, mixed> $before
* @param array<string, mixed> $after
*/
private function sameValue(string $field, array $before, array $after): bool
{
if (in_array($field, [...self::HTML_FIELDS, 'equipment'], true)) {
return FormattedText::same($this->value($before, $field), $this->value($after, $field));
}
return trim((string) ($before[$field] ?? '')) === trim((string) ($after[$field] ?? ''));
}
/** /**
* Titel und Kurzbeschreibung gehören zur Übung und nicht zur Fassung. Sie folgen der Quelle, solange die Redaktion sie * Titel und Kurzbeschreibung gehören zur Übung und nicht zur Fassung. Sie folgen der Quelle, solange die Redaktion sie
* nicht lokal geändert hat; ein lokal geänderter Wert bleibt. * nicht lokal geändert hat; ein lokal geänderter Wert bleibt.
@@ -463,8 +684,8 @@ private function carryOverTexts(Composition $composition, array $before, array $
$composition->designation = trim((string) $after['title']); $composition->designation = trim((string) $after['title']);
} }
if (array_key_exists('summary', $after) && ((string) $composition->summary === '' || $composition->summary === ($before['summary'] ?? null))) { if (array_key_exists('summary', $after) && ((string) $composition->summary === '' || FormattedText::same($composition->summary, $this->value($before, 'summary')))) {
$composition->summary = trim((string) $after['summary']) ?: null; $composition->summary = $this->value($after, 'summary') ?: null;
} }
$composition->save(); $composition->save();
@@ -529,7 +750,7 @@ private function localAdditions(?CompositionVersion $previous, array $sourceVari
/** /**
* Die Textfassung eines Abschnitts der Quelle. Unveränderter Text bleibt dieselbe Fassung. * Die Textfassung eines Abschnitts der Quelle. Unveränderter Text bleibt dieselbe Fassung.
*/ */
private function section(ExerciseSource $source, string $field, string $title, string $text): ContentElementVersion private function sectionVersion(ExerciseSource $source, string $field, string $title, string $text, ?ContentElementVersion $latest): ContentElementVersion
{ {
$content = app(ContentService::class); $content = app(ContentService::class);
$ref = 'shinkan:'.$source->source_id.':'.$field; $ref = 'shinkan:'.$source->source_id.':'.$field;
@@ -541,11 +762,9 @@ private function section(ExerciseSource $source, string $field, string $title, s
$element->save(); $element->save();
} }
$latest = $element->versions()->where('status', ContentVersionStatus::Bereit)->orderByDesc('number')->first(); return $latest !== null && FormattedText::same($latest->body, $text)
return $latest !== null && trim((string) $latest->body) === $text
? $latest ? $latest
: $content->publishElementVersion($element, $text, [], 'Übernahme aus Shinkan'); : $content->publishElementVersion($element, $text, [], self::IMPORT_NOTE);
} }
private function createComposition(string $title, string $summary): Composition private function createComposition(string $title, string $summary): Composition
@@ -629,6 +848,34 @@ private function plain(Throwable $exception): string
}; };
} }
return $exception instanceof DomainRuleException ? $exception->getMessage() : 'Die Quelle ist nicht erreichbar.'; if ($exception instanceof DomainRuleException) {
return $exception->getMessage();
}
return $this->networkCause($exception);
}
/**
* Benennt die Ursache eines Netzwerkfehlers, ohne Adresse, Pfad oder Schlüssel auszugeben. Genannt wird nur der
* Servername, damit die Redaktion erkennt, ob die richtige Quelle gemeint ist.
*/
private function networkCause(Throwable $exception): string
{
$host = app(ShinkanConnection::class)->url();
$host = $host === null ? 'der Quelle' : (string) (parse_url($host, PHP_URL_HOST) ?: 'der Quelle');
preg_match('/cURL error (\d+)/', $exception->getMessage(), $match);
$code = isset($match[1]) ? (int) $match[1] : null;
$cause = match (true) {
$code === 6 => 'Der Servername konnte von diesem Server aus nicht aufgelöst werden (Namensauflösung, DNS).',
$code === 7 => 'Der Server nimmt die Verbindung nicht an (abgelehnt, falscher Port oder Firewall).',
$code === 28 => 'Die Verbindung hat die Zeit überschritten (ausgehende Verbindungen sind möglicherweise blockiert).',
in_array($code, [35, 51, 58, 60, 77, 83], true) => 'Das Zertifikat oder die verschlüsselte Verbindung wird nicht akzeptiert.',
$code === 56 || $code === 52 => 'Die Verbindung wurde unterbrochen.',
$code !== null => 'Netzwerkfehler (cURL '.$code.').',
default => 'Netzwerkfehler.',
};
return 'Die Quelle '.$host.' ist von diesem Server aus nicht erreichbar. '.$cause;
} }
} }
@@ -8,6 +8,7 @@
use App\Domain\Catalog\ContentVersionStatus; use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\EditorialContentKind; use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Catalog\EditorialProfileReader; use App\Domain\Catalog\EditorialProfileReader;
use App\Domain\Catalog\FormattedText;
use App\Domain\Media\ThumbnailRef; use App\Domain\Media\ThumbnailRef;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@@ -166,7 +167,7 @@ public function entries(array $refs, bool $includeNonPublic): array
$entries[] = new CatalogEntry( $entries[] = new CatalogEntry(
id: $composition->id, id: $composition->id,
title: $this->title($composition), title: $this->title($composition),
summary: filled($composition->summary) ? (string) $composition->summary : null, summary: FormattedText::plain($composition->summary) ?: null,
kindLabel: (string) ($composition->editorialContentKind?->label ?? ''), kindLabel: (string) ($composition->editorialContentKind?->label ?? ''),
url: $public ? route('public.program', $composition) : null, url: $public ? route('public.program', $composition) : null,
public: $public, public: $public,
@@ -264,7 +265,7 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
$kind = (string) ($composition->editorialContentKind?->label ?? ($program ? 'Programm' : 'Modul')); $kind = (string) ($composition->editorialContentKind?->label ?? ($program ? 'Programm' : 'Modul'));
$profile = app(EditorialProfileReader::class)->read($composition, 'kachel'); $profile = app(EditorialProfileReader::class)->read($composition, 'kachel');
$summary = $profile->value('teaser') ?: $profile->value('summary'); $summary = $profile->value('teaser') ?: $profile->value('summary');
$goal = filled($version?->learning_goal) ? trim((string) $version->learning_goal) : null; $goal = FormattedText::plain($version?->learning_goal) ?: null;
// Zentrale Texte, aus denen die Redaktion den Kartentext wählen kann (Zielgruppe „Öffentliche Kachel“). // Zentrale Texte, aus denen die Redaktion den Kartentext wählen kann (Zielgruppe „Öffentliche Kachel“).
$texts = [ $texts = [
'teaser' => $profile->value('teaser'), 'teaser' => $profile->value('teaser'),
@@ -6,6 +6,7 @@
use App\Domain\Catalog\ContentElement; use App\Domain\Catalog\ContentElement;
use App\Domain\Catalog\ContentVersionStatus; use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\EditorialProfileReader; use App\Domain\Catalog\EditorialProfileReader;
use App\Domain\Catalog\FormattedText;
use App\Domain\Catalog\MaterialTag; use App\Domain\Catalog\MaterialTag;
use App\Domain\Catalog\StructureNode; use App\Domain\Catalog\StructureNode;
use App\Domain\Media\ThumbnailRef; use App\Domain\Media\ThumbnailRef;
@@ -175,7 +176,7 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
$output = self::outputLabel((string) $shown->output_class); $output = self::outputLabel((string) $shown->output_class);
$film = $shown->output_class === 'film'; $film = $shown->output_class === 'film';
$editorialKind = $element->editorialContentKind?->label; $editorialKind = $element->editorialContentKind?->label;
$summary = filled($shown->summary) ? trim((string) $shown->summary) : null; $summary = FormattedText::plain($shown->summary) ?: null;
$profile = app(EditorialProfileReader::class)->read($shown, 'bibliothek'); $profile = app(EditorialProfileReader::class)->read($shown, 'bibliothek');
if (! array_key_exists('summary', $draft) && $profile->origin('summary') === 'variante') { if (! array_key_exists('summary', $draft) && $profile->origin('summary') === 'variante') {
@@ -187,7 +188,8 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
$texts = []; $texts = [];
foreach (['teaser', 'summary', 'description'] as $field) { foreach (['teaser', 'summary', 'description'] as $field) {
$own = filled($shown->getAttribute($field)) ? trim((string) $shown->getAttribute($field)) : null; $own = filled($shown->getAttribute($field)) ? trim(in_array($field, FormattedText::FIELDS, true) ? FormattedText::plain((string) $shown->getAttribute($field)) : (string) $shown->getAttribute($field)) : null;
$own = $own === '' ? null : $own;
if (! array_key_exists($field, $draft) && $profile->origin($field) === 'variante') { if (! array_key_exists($field, $draft) && $profile->origin($field) === 'variante') {
$own = $profile->value($field); $own = $profile->value($field);
@@ -0,0 +1,58 @@
<?php
namespace App\Domain\Cms\Widgets\Support;
/**
* Zulässige Kleingrafiken des Brand-Kits als Auswahl im CMS (ADR-30: nur feste Werte, nie freie Dateinamen).
*
* Die Schlüssel sind Dateinamen aus resources/svg/brand/symbole/. Nicht angeboten werden die gelbe Unterstreichung
* (eigene Einstellung „Pinselstrich“) und die Signalstrahlen (Markenakzent des Einstiegs). Eine Prüfung im Test stellt
* sicher, dass jeder Schlüssel eine vorhandene Datei hat.
*/
final class HeadingAccent
{
/** @var array<string, string> */
public const SYMBOLS = [
'bildung' => 'Bildung',
'buch' => 'Buch',
'download' => 'Download',
'filmklappe' => 'Filmklappe',
'filmstreifen' => 'Filmstreifen',
'gruppe' => 'Gruppe',
'merkblatt' => 'Merkblatt',
'muskelarm' => 'Starker Arm',
'paket' => 'Paket',
'pause-hand' => 'Pause (Hand)',
'play' => 'Abspielen',
'schutzschild' => 'Schutzschild',
'sprechblase-fragezeichen' => 'Frage (Sprechblase)',
'uebungsblatt' => 'Übungsblatt',
];
/** @var array<string, string> */
public const BRUSH = ['brush' => 'Gelber Pinselstrich unter der Überschrift'];
public const SYMBOL_LABEL = ['Symbol vor der Überschrift', 'Kleine Grafik aus dem Brand-Kit vor dem Text. Sie ist reine Zierde und wird von Hilfstechnik nicht vorgelesen. Vorgabe: kein Symbol.'];
public const BRUSH_LABEL = ['Pinselstrich', 'Gelbe Unterstreichung unter der Überschrift (freigegebenes Motiv aus dem Brand-Kit). Vorgabe: ohne.'];
/**
* Gültiger Symbolname aus den Einstellungen eines Widgets oder null.
*
* @param array<string, mixed> $settings
*/
public static function symbol(array $settings): ?string
{
$name = $settings['symbol'] ?? null;
return is_string($name) && array_key_exists($name, self::SYMBOLS) ? $name : null;
}
/**
* @param array<string, mixed> $settings
*/
public static function hasBrush(array $settings): bool
{
return ($settings['accent'] ?? null) === 'brush';
}
}
@@ -2,6 +2,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\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;
@@ -90,6 +91,21 @@ public function dataFields(): array
]; ];
} }
public function settings(): array
{
return ['symbol' => HeadingAccent::SYMBOLS];
}
public function settingGroups(): array
{
return ['Aussehen' => ['symbol']];
}
public function settingLabels(): array
{
return ['symbol' => HeadingAccent::SYMBOL_LABEL];
}
public function clean(array $data, array $refs, WidgetErrors $errors): array public function clean(array $data, array $refs, WidgetErrors $errors): array
{ {
if (! SafeUrl::isSafe($data['url'] ?? null)) { if (! SafeUrl::isSafe($data['url'] ?? null)) {
@@ -0,0 +1,139 @@
<?php
namespace App\Domain\Cms\Widgets\Types;
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 Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Illuminate\Validation\Rule;
/**
* Merkmalszeile nach den Entwürfen des Brand-Kits (04_visuelle_entwuerfe): zwei bis vier Merkmale nebeneinander,
* je mit Symbol, Kurztitel und einem Satz. Die Anzahl der Einträge bestimmt die Spaltenzahl; es gibt keine
* zweite Einstellung dafür. Das Symbol stammt aus der festen Auswahl (HeadingAccent::SYMBOLS), nie aus einem
* freien Dateinamen.
*/
class FeaturesWidget extends WidgetType
{
public function key(): string
{
return 'features';
}
public function label(): string
{
return 'Merkmalszeile';
}
public function description(): string
{
return 'Zwei bis vier Merkmale nebeneinander, je mit Symbol, Kurztitel und einem Satz.';
}
public function supportedUnits(): array
{
return [2, 3, 4];
}
public function narrowBehavior(): string
{
return 'Die Merkmale stehen nebeneinander, solange jedes mindestens 12 rem breit bleibt; darunter stehen sie untereinander.';
}
public function preferredUnits(): int
{
return 4;
}
public function stages(): array
{
return [
'narrow' => 'ein Merkmal je Zeile',
'wide' => 'so viele Merkmale nebeneinander, wie bei mindestens 12rem Breite passen',
];
}
public function icon(): string
{
return 'heroicon-o-sparkles';
}
public function schematic(): array
{
return [[3, 6, 14, 14, 'accent'], [23, 6, 14, 14, 'accent'], [43, 6, 14, 14, 'accent'], [3, 24, 14, 3, 'ink'], [23, 24, 14, 3, 'ink'], [43, 24, 14, 3, 'ink'], [3, 29, 14, 2, 'line'], [23, 29, 14, 2, 'line'], [43, 29, 14, 2, 'line']];
}
public function dataRules(): array
{
return [
'items' => ['required', 'array', 'min:2', 'max:4'],
'items.*.symbol' => ['required', 'string', Rule::in(array_keys(HeadingAccent::SYMBOLS))],
'items.*.title' => ['required', 'string', 'max:60'],
'items.*.text' => ['nullable', 'string', 'max:200'],
];
}
public function dataFields(): array
{
return [
Repeater::make('items')
->label('Merkmale')
->schema([
Select::make('symbol')->label('Symbol')->options(HeadingAccent::SYMBOLS)->required(),
TextInput::make('title')->label('Kurztitel')->required()->maxLength(60),
Textarea::make('text')->label('Satz')->rows(2)->maxLength(200),
])
->minItems(2)
->maxItems(4)
->reorderableWithButtons()
->collapsible()
->itemLabel(fn (array $state): ?string => $state['title'] ?? null)
->addActionLabel('Merkmal hinzufügen')
->helperText('Die Anzahl der Merkmale bestimmt die Spalten: zwei, drei oder vier.'),
];
}
public function clean(array $data, array $refs, WidgetErrors $errors): array
{
foreach ($data['items'] as $index => $item) {
$data['items'][$index] = [
'symbol' => $item['symbol'],
'title' => $item['title'],
'text' => filled($item['text'] ?? null) ? $item['text'] : null,
];
}
return [$data, $refs];
}
public function resolve(array $widget, RenderContext $context): array
{
$items = [];
foreach ($widget['data']['items'] ?? [] as $item) {
if (! is_array($item) || ! filled($item['title'] ?? null)) {
continue;
}
$items[] = [
'symbol' => HeadingAccent::symbol(['symbol' => $item['symbol'] ?? null]),
'title' => $item['title'],
'text' => $item['text'] ?? null,
];
}
return ['items' => $items];
}
public function summary(array $widget): string
{
$titles = array_filter(array_map(fn ($item) => is_array($item) ? ($item['title'] ?? null) : null, $widget['data']['items'] ?? []));
return count($titles).' Merkmale: '.implode(', ', $titles);
}
}
@@ -2,6 +2,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\WidgetType; use App\Domain\Cms\Widgets\WidgetType;
use Filament\Forms\Components\Textarea; use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
@@ -71,6 +72,27 @@ public function dataFields(): array
]; ];
} }
public function settings(): array
{
return [
'symbol' => HeadingAccent::SYMBOLS,
'accent' => HeadingAccent::BRUSH,
];
}
public function settingGroups(): array
{
return ['Aussehen' => ['symbol', 'accent']];
}
public function settingLabels(): array
{
return [
'symbol' => HeadingAccent::SYMBOL_LABEL,
'accent' => HeadingAccent::BRUSH_LABEL,
];
}
public function summary(array $widget): string public function summary(array $widget): string
{ {
return (string) ($widget['data']['heading'] ?? ''); return (string) ($widget['data']['heading'] ?? '');
+4 -1
View File
@@ -3,6 +3,7 @@
namespace App\Domain\Cms\Widgets\Types; namespace App\Domain\Cms\Widgets\Types;
use App\Domain\Cms\Widgets\RenderContext; use App\Domain\Cms\Widgets\RenderContext;
use App\Domain\Cms\Widgets\Support\HeadingAccent;
use App\Domain\Cms\Widgets\Support\HeroVideo; 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;
@@ -112,13 +113,14 @@ public function settings(): array
return [ return [
'heading_level' => PremiumFields::HEADING_LEVELS, 'heading_level' => PremiumFields::HEADING_LEVELS,
'accent' => ['underline' => 'Gelbe Unterstreichung', 'rays' => 'Unterstreichung und Signalstrahlen', 'none' => 'Ohne Akzent'], 'accent' => ['underline' => 'Gelbe Unterstreichung', 'rays' => 'Unterstreichung und Signalstrahlen', 'none' => 'Ohne Akzent'],
'symbol' => HeadingAccent::SYMBOLS,
]; ];
} }
public function settingGroups(): array public function settingGroups(): array
{ {
return [ return [
'Aussehen' => ['accent'], 'Aussehen' => ['accent', 'symbol'],
'Seitenstruktur' => ['heading_level'], 'Seitenstruktur' => ['heading_level'],
]; ];
} }
@@ -128,6 +130,7 @@ public function settingLabels(): array
return [ return [
'heading_level' => ['Überschriftenebene', 'Betrifft nur die Gliederung für Suchmaschinen und Hilfstechnik, nicht das Aussehen. Der erste Einstieg einer Seite ist immer die Hauptüberschrift (H1).'], 'heading_level' => ['Überschriftenebene', 'Betrifft nur die Gliederung für Suchmaschinen und Hilfstechnik, nicht das Aussehen. Der erste Einstieg einer Seite ist immer die Hauptüberschrift (H1).'],
'accent' => ['Markenakzent', 'Freigegebene Akzente aus dem Brand-UI-Kit. Vorgabe: gelbe Unterstreichung.'], 'accent' => ['Markenakzent', 'Freigegebene Akzente aus dem Brand-UI-Kit. Vorgabe: gelbe Unterstreichung.'],
'symbol' => HeadingAccent::SYMBOL_LABEL,
]; ];
} }
@@ -3,6 +3,7 @@
namespace App\Domain\Cms\Widgets\Types; namespace App\Domain\Cms\Widgets\Types;
use App\Domain\Cms\Widgets\RenderContext; use App\Domain\Cms\Widgets\RenderContext;
use App\Domain\Cms\Widgets\Support\HeadingAccent;
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;
@@ -114,13 +115,14 @@ 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)'],
'heading_level' => PremiumFields::HEADING_LEVELS, 'heading_level' => PremiumFields::HEADING_LEVELS,
'symbol' => HeadingAccent::SYMBOLS,
]; ];
} }
public function settingGroups(): array public function settingGroups(): array
{ {
return [ return [
'Aussehen' => ['surface'], 'Aussehen' => ['surface', 'symbol'],
'Seitenstruktur' => ['heading_level'], 'Seitenstruktur' => ['heading_level'],
]; ];
} }
@@ -129,6 +131,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.'],
'symbol' => HeadingAccent::SYMBOL_LABEL,
'heading_level' => ['Überschriftenebene', 'Betrifft nur die Gliederung für Suchmaschinen und Hilfstechnik, nicht das Aussehen. Steht das Widget als erstes auf der Seite, ist die Überschrift immer H1.'], 'heading_level' => ['Überschriftenebene', 'Betrifft nur die Gliederung für Suchmaschinen und Hilfstechnik, nicht das Aussehen. Steht das Widget als erstes auf der Seite, ist die Überschrift immer H1.'],
]; ];
} }
+42 -3
View File
@@ -17,14 +17,44 @@ final class PdfDocument
/** @var list<string> */ /** @var list<string> */
private array $pages = []; private array $pages = [];
/** Schräge Schnitte werden nur eingebunden, wenn das Dokument sie braucht (Belege bleiben unverändert). */
private bool $usesItalic = false;
/** Breiten der Helvetica (Tausendstel der Schrifthöhe) für Zeichen 32 bis 126; schräg wie aufrecht. */
private const REGULAR = [278, 278, 355, 556, 556, 889, 667, 191, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 278, 278, 584, 584, 584, 556, 1015, 667, 667, 722, 722, 667, 611, 778, 722, 278, 500, 667, 556, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 278, 278, 278, 469, 556, 333, 556, 556, 500, 556, 556, 278, 556, 556, 222, 222, 500, 222, 833, 556, 556, 556, 556, 333, 500, 278, 556, 500, 722, 500, 500, 500, 334, 260, 334, 584];
/** Breiten der Helvetica-Bold für Zeichen 32 bis 126; schräg wie aufrecht. */
private const BOLD = [278, 333, 474, 556, 556, 889, 722, 238, 333, 333, 389, 584, 278, 333, 278, 278, 556, 556, 556, 556, 556, 556, 556, 556, 556, 556, 333, 333, 584, 584, 584, 611, 975, 722, 722, 722, 722, 667, 611, 778, 722, 278, 556, 722, 611, 833, 722, 778, 667, 778, 722, 667, 611, 722, 667, 944, 667, 667, 611, 333, 278, 333, 584, 556, 333, 556, 611, 556, 611, 556, 333, 611, 611, 278, 278, 556, 278, 889, 611, 611, 611, 611, 389, 556, 333, 611, 556, 778, 556, 556, 500, 389, 280, 389, 584];
public function addPage(): void public function addPage(): void
{ {
$this->pages[] = ''; $this->pages[] = '';
} }
public function text(float $x, float $y, string $text, float $size = 10, bool $bold = false): void public function text(float $x, float $y, string $text, float $size = 10, bool $bold = false, bool $italic = false): void
{ {
$this->append(sprintf("BT /%s %s Tf %s %s Td (%s) Tj ET\n", $bold ? 'F2' : 'F1', $this->n($size), $this->n($x), $this->n($y), self::escape($text))); $font = $italic ? ($bold ? 'F4' : 'F3') : ($bold ? 'F2' : 'F1');
$this->usesItalic = $this->usesItalic || $italic;
$this->append(sprintf("BT /%s %s Tf %s %s Td (%s) Tj ET\n", $font, $this->n($size), $this->n($x), $this->n($y), self::escape($text)));
}
/**
* Genaue Breite in Punkt nach den Schriftbreiten der Helvetica, damit Textabschnitte mit verschiedenen Schnitten in
* einer Zeile ohne Lücken aneinanderstoßen. Umlaute zählen wie ihr Grundbuchstabe, das ß wie ein kleines b, jedes
* andere Zeichen außerhalb von ASCII wie eine Ziffer.
*/
public static function exactWidth(string $text, float $size = 10, bool $bold = false): float
{
$table = $bold ? self::BOLD : self::REGULAR;
$units = 0;
$text = strtr($text, ['ä' => 'a', 'ö' => 'o', 'ü' => 'u', 'Ä' => 'A', 'Ö' => 'O', 'Ü' => 'U', 'ß' => 'b', "\u{2019}" => "'", "\u{2026}" => '...', "\u{00A0}" => ' ']);
foreach (mb_str_split($text) as $char) {
$code = strlen($char) === 1 ? ord($char) : 0;
$units += $code >= 32 && $code <= 126 ? $table[$code - 32] : 556;
}
return $units / 1000 * $size;
} }
public function textRight(float $xRight, float $y, string $text, float $size = 10, bool $bold = false): void public function textRight(float $xRight, float $y, string $text, float $size = 10, bool $bold = false): void
@@ -117,11 +147,20 @@ public function output(string $title, ?string $keywords = null): string
foreach ($pages as $stream) { foreach ($pages as $stream) {
$kids[] = $next.' 0 R'; $kids[] = $next.' 0 R';
$objects[$next] = '<< /Type /Page /Parent 2 0 R /MediaBox [0 0 '.self::WIDTH.' '.self::HEIGHT.'] /Resources << /Font << /F1 3 0 R /F2 4 0 R >> >> /Contents '.($next + 1).' 0 R >>'; $objects[$next] = '<< /Type /Page /Parent 2 0 R /MediaBox [0 0 '.self::WIDTH.' '.self::HEIGHT.'] /Resources << /Font << /F1 3 0 R /F2 4 0 R'.($this->usesItalic ? ' /F3 %ITALIC% 0 R /F4 %BOLDITALIC% 0 R' : '').' >> >> /Contents '.($next + 1).' 0 R >>';
$objects[$next + 1] = '<< /Length '.strlen($stream)." >>\nstream\n".$stream.'endstream'; $objects[$next + 1] = '<< /Length '.strlen($stream)." >>\nstream\n".$stream.'endstream';
$next += 2; $next += 2;
} }
if ($this->usesItalic) {
$objects[$next] = '<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Oblique /Encoding /WinAnsiEncoding >>';
$objects[$next + 1] = '<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-BoldOblique /Encoding /WinAnsiEncoding >>';
foreach ($objects as $number => $body) {
$objects[$number] = str_replace(['%ITALIC%', '%BOLDITALIC%'], [(string) $next, (string) ($next + 1)], $body);
}
}
$objects[2] = '<< /Type /Pages /Kids ['.implode(' ', $kids).'] /Count '.count($pages).' >>'; $objects[2] = '<< /Type /Pages /Kids ['.implode(' ', $kids).'] /Count '.count($pages).' >>';
$objects[3] = '<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>'; $objects[3] = '<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >>';
$objects[4] = '<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>'; $objects[4] = '<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >>';
@@ -52,11 +52,11 @@ class RedaktionelleStammdaten extends Page implements HasTable
{ {
use InteractsWithTable; use InteractsWithTable;
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte'; protected static string|\UnitEnum|null $navigationGroup = 'Stammdaten';
protected static ?string $navigationLabel = 'Redaktionelle Stammdaten'; protected static ?string $navigationLabel = 'Redaktionelle Stammdaten';
protected static ?int $navigationSort = 6; protected static ?int $navigationSort = 2;
protected static ?string $slug = 'stammdaten'; protected static ?string $slug = 'stammdaten';
+20 -2
View File
@@ -56,6 +56,9 @@ class Uebernahme extends Page
/** @var array<int|string, array<string, string>> Quellübung => (entfallene Quellvariante => neue Zuordnung) */ /** @var array<int|string, array<string, string>> Quellübung => (entfallene Quellvariante => neue Zuordnung) */
public array $reassign = []; public array $reassign = [];
/** @var array<int|string, array<string, string>> Quellübung => (Text oder Feld => `lokal` oder `quelle`) */
public array $textChoice = [];
/** @var list<array<string, mixed>> */ /** @var list<array<string, mixed>> */
public array $results = []; public array $results = [];
@@ -63,6 +66,15 @@ class Uebernahme extends Page
public bool $feedbackError = false; public bool $feedbackError = false;
/**
* Die Übernahme ist ein Weg im Übungsbestand („Aus Shinkan übernehmen“) und kein eigener Einstieg. Nur wer die
* Anbindung pflegen darf, aber den Übungsbestand nicht sieht, bekommt den Eintrag in der Navigation.
*/
public static function shouldRegisterNavigation(): bool
{
return static::canConfigure() && ! ContentElementResource::editor();
}
public static function canAccess(): bool public static function canAccess(): bool
{ {
return ContentElementResource::editor() || static::canConfigure(); return ContentElementResource::editor() || static::canConfigure();
@@ -180,6 +192,12 @@ public function confirm(): void
$changed[] = $entry['title']; $changed[] = $entry['title'];
} }
foreach ($entry['text_conflicts'] as $conflict) {
if (! in_array($this->textChoice[$entry['source']][$conflict['key']] ?? 'offen', ['lokal', 'quelle'], true)) {
$open[] = $entry['title'].': '.$conflict['label'];
}
}
foreach ($entry['conflicts'] as $conflict) { foreach ($entry['conflicts'] as $conflict) {
if (! isset($this->reassign[$entry['source']][$conflict['key']]) || $this->reassign[$entry['source']][$conflict['key']] === 'offen') { if (! isset($this->reassign[$entry['source']][$conflict['key']]) || $this->reassign[$entry['source']][$conflict['key']] === 'offen') {
$open[] = $entry['title'].': '.implode(', ', $conflict['members']); $open[] = $entry['title'].': '.implode(', ', $conflict['members']);
@@ -195,7 +213,7 @@ public function confirm(): void
} }
if ($open !== []) { if ($open !== []) {
$this->say('Lege zuerst die neue Zuordnung der lokalen Ergänzungen fest: '.implode('; ', $open).'.', true); $this->say('Lege zuerst fest, was gilt: '.implode('; ', $open).'.', true);
return; return;
} }
@@ -205,7 +223,7 @@ public function confirm(): void
foreach ($this->preview as $entry) { foreach ($this->preview as $entry) {
$source = ExerciseSource::query()->findOrFail($entry['source']); $source = ExerciseSource::query()->findOrFail($entry['source']);
$reassign = array_map(fn (string $value): string => $value === 'gemeinsam' ? '' : $value, $this->reassign[$entry['source']] ?? []); $reassign = array_map(fn (string $value): string => $value === 'gemeinsam' ? '' : $value, $this->reassign[$entry['source']] ?? []);
$result = $import->adoptPreviewed($source, (int) $entry['snapshot'], $reassign, $this->actor()); $result = $import->adoptPreviewed($source, (int) $entry['snapshot'], $reassign, $this->actor(), $this->textChoice[$entry['source']] ?? []);
$source->refresh(); $source->refresh();
$this->results[] = [ $this->results[] = [
'title' => $entry['title'], 'title' => $entry['title'],
@@ -17,7 +17,7 @@ class CombinationResource extends CompositionKindResource
protected static ?string $pluralModelLabel = 'Fachliche Kombinationen'; protected static ?string $pluralModelLabel = 'Fachliche Kombinationen';
protected static ?int $navigationSort = 2; protected static ?int $navigationSort = 5;
public static function kind(): CompositionKind public static function kind(): CompositionKind
{ {
@@ -16,6 +16,7 @@
use App\Domain\Catalog\EditorialVocabulary; use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\EditorialWorkingDraft; use App\Domain\Catalog\EditorialWorkingDraft;
use App\Domain\Catalog\ForeignCompositions; use App\Domain\Catalog\ForeignCompositions;
use App\Domain\Catalog\FormattedText;
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;
@@ -26,6 +27,7 @@
use App\Filament\Support\AssignsPillars; use App\Filament\Support\AssignsPillars;
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\MediumForm; use App\Filament\Support\MediumForm;
use App\Filament\Support\WidgetEditor; use App\Filament\Support\WidgetEditor;
use App\Http\Controllers\ContentPreviewController; use App\Http\Controllers\ContentPreviewController;
@@ -48,6 +50,7 @@ abstract class EditComposition extends EditRecord
{ {
use AssignsPillars; use AssignsPillars;
use ManagesEditorialSurface; use ManagesEditorialSurface;
use ManagesRichFields;
use WithFileUploads; use WithFileUploads;
protected string $view = 'filament.editorial.edit'; protected string $view = 'filament.editorial.edit';
@@ -382,6 +385,21 @@ public function redaktionTitel(): string
return $title !== '' ? $title : $this->hostLabel(); return $title !== '' ? $title : $this->hostLabel();
} }
/**
* @return array<string, string>
*/
protected function richFelder(): array
{
return [
'summary' => 'Kurzbeschreibung',
'description' => 'Ausführliche Beschreibung',
'learningGoal' => 'Lernziel',
'materialNote' => $this->isExercise() ? 'Ausstattung' : 'Materialbedarf',
'partBody' => 'Inhalt des Textes',
'newTextBody' => 'Inhalt des neuen Textes',
];
}
/** /**
* @return list<array<string, mixed>> * @return list<array<string, mixed>>
*/ */
@@ -395,8 +413,8 @@ public function redaktionFelder(): array
['id' => 'name', 'label' => 'Name in der Verwaltung', 'model' => 'designation', 'kind' => 'text', 'stored' => $stored('designation'), 'required' => true, 'hilfe' => 'Pflichtangabe. Erscheint in Listen der Verwaltung.'], ['id' => 'name', 'label' => 'Name in der Verwaltung', 'model' => 'designation', 'kind' => 'text', 'stored' => $stored('designation'), 'required' => true, 'hilfe' => 'Pflichtangabe. Erscheint in Listen der Verwaltung.'],
['id' => 'titel', 'label' => 'Titel', 'model' => 'displayTitle', 'kind' => 'text', 'stored' => $stored('display_title'), 'hilfe' => 'Erscheint auf Karten und in der Bibliothek. Leer zeigt den Namen.'], ['id' => 'titel', 'label' => 'Titel', 'model' => 'displayTitle', 'kind' => 'text', 'stored' => $stored('display_title'), 'hilfe' => 'Erscheint auf Karten und in der Bibliothek. Leer zeigt den Namen.'],
['id' => 'teaser', 'label' => 'Teaser', 'model' => 'teaser', 'kind' => 'textarea', 'rows' => 2, 'stored' => $stored('teaser')], ['id' => 'teaser', 'label' => 'Teaser', 'model' => 'teaser', 'kind' => 'textarea', 'rows' => 2, 'stored' => $stored('teaser')],
['id' => 'kurz', 'label' => 'Kurzbeschreibung', 'model' => 'summary', 'kind' => 'textarea', 'rows' => 3, 'stored' => $stored('summary')], ['id' => 'kurz', 'label' => 'Kurzbeschreibung', 'model' => 'summary', 'kind' => 'rich', 'stored' => $stored('summary')],
['id' => 'beschreibung', 'label' => 'Ausführliche Beschreibung', 'model' => 'description', 'kind' => 'textarea', 'rows' => 8, 'stored' => $stored('description'), 'hilfe' => 'Beschreibt das Angebot. Kein Lehrtext und kein Lernziel.'], ['id' => 'beschreibung', 'label' => 'Ausführliche Beschreibung', 'model' => 'description', 'kind' => 'rich', 'stored' => $stored('description'), 'hilfe' => 'Beschreibt das Angebot. Kein Lehrtext und kein Lernziel.'],
['id' => 'suche', 'label' => 'Suchbegriffe', 'model' => 'searchTerms', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('search_terms'), 'placeholder' => 'Begriffe, durch Komma getrennt'], ['id' => 'suche', 'label' => 'Suchbegriffe', 'model' => 'searchTerms', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('search_terms'), 'placeholder' => 'Begriffe, durch Komma getrennt'],
]; ];
} }
@@ -1248,7 +1266,7 @@ public function loadTemplate(int $versionId): void
public function addText(): void public function addText(): void
{ {
$title = trim($this->newTextTitle); $title = trim($this->newTextTitle);
$body = trim($this->newTextBody); $body = FormattedText::canonical($this->newTextBody);
if ($title === '' || $body === '') { if ($title === '' || $body === '') {
$this->feedback = 'Der Text braucht einen Titel und einen Inhalt.'; $this->feedback = 'Der Text braucht einen Titel und einen Inhalt.';
@@ -1578,7 +1596,7 @@ private function writePartText(): string|false
} }
$title = trim($this->partTitle); $title = trim($this->partTitle);
$body = trim($this->partBody); $body = FormattedText::canonical($this->partBody);
if ($title === '' || $body === '') { if ($title === '' || $body === '') {
$this->feedback = 'Der Text braucht einen Titel und einen Inhalt.'; $this->feedback = 'Der Text braucht einen Titel und einen Inhalt.';
@@ -1598,7 +1616,7 @@ private function writePartText(): string|false
return false; return false;
} }
$changed = $title !== (string) ($member['title'] ?? '') || $body !== trim((string) $version->body); $changed = $title !== (string) ($member['title'] ?? '') || ! FormattedText::same($body, $version->body);
if (! $changed) { if (! $changed) {
return ''; return '';
@@ -1755,10 +1773,10 @@ public function publishRevision(): bool
$this->actor(), $this->actor(),
$note !== '' ? $note : null, $note !== '' ? $note : null,
[ [
'learning_goal' => $this->blank($this->learningGoal), 'learning_goal' => $this->richBlank('learningGoal'),
'duration_minutes' => $minutes, 'duration_minutes' => $minutes,
'duration_max' => $this->blank($this->durationMax), 'duration_max' => $this->blank($this->durationMax),
'material_note' => $this->blank($this->materialNote), 'material_note' => $this->richBlank('materialNote'),
'prerequisites' => $this->blank($this->prerequisites), 'prerequisites' => $this->blank($this->prerequisites),
], ],
$this->releaseConsent, $this->releaseConsent,
@@ -1956,7 +1974,7 @@ protected function applyVersion(CompositionVersion $version): void
{ {
$this->members = app(EditorialCatalog::class)->rows($version, (int) $this->getRecord()->getKey()); $this->members = app(EditorialCatalog::class)->rows($version, (int) $this->getRecord()->getKey());
$this->variants = $this->normalizeVariants($version->variants->map(fn ($variant): array => [ $this->variants = $this->normalizeVariants($version->variants->map(fn ($variant): array => [
'key' => $variant->key, 'name' => $variant->name, 'description' => (string) $variant->description, 'key' => $variant->key, 'name' => $variant->name, 'description' => (string) $variant->description, 'origin' => $variant->origin,
])->all()); ])->all());
$this->durationMax = $version->duration_max === null ? '' : (string) $version->duration_max; $this->durationMax = $version->duration_max === null ? '' : (string) $version->duration_max;
$this->prerequisites = (string) ($version->prerequisites ?? ''); $this->prerequisites = (string) ($version->prerequisites ?? '');
@@ -2076,11 +2094,11 @@ protected function didacticChanged(CompositionVersion $version): bool
$storedMinutes = $version->duration_minutes === null ? null : (int) $version->duration_minutes; $storedMinutes = $version->duration_minutes === null ? null : (int) $version->duration_minutes;
$storedVariants = $this->normalizeVariants($version->variants->map(fn ($variant): array => [ $storedVariants = $this->normalizeVariants($version->variants->map(fn ($variant): array => [
'key' => $variant->key, 'name' => $variant->name, 'description' => (string) $variant->description, 'key' => $variant->key, 'name' => $variant->name, 'description' => (string) $variant->description, 'origin' => $variant->origin,
])->all()); ])->all());
return $version->learning_goal !== $this->blank($this->learningGoal) return ! FormattedText::same($version->learning_goal, $this->learningGoal)
|| $version->material_note !== $this->blank($this->materialNote) || ! FormattedText::same($version->material_note, $this->materialNote)
|| $version->prerequisites !== $this->blank($this->prerequisites) || $version->prerequisites !== $this->blank($this->prerequisites)
|| ($version->duration_max === null ? null : (string) $version->duration_max) !== $this->blank($this->durationMax) || ($version->duration_max === null ? null : (string) $version->duration_max) !== $this->blank($this->durationMax)
|| $storedVariants !== $this->normalizeVariants($this->variants) || $storedVariants !== $this->normalizeVariants($this->variants)
@@ -2104,6 +2122,14 @@ protected function minutes(string $value): int|false|null
return $minutes > 0 ? $minutes : false; return $minutes > 0 ? $minutes : false;
} }
/** Formatierte Eigenschaft in kanonischer Form für das Speichern; leer wird null. */
protected function richBlank(string $name): ?string
{
$value = $this->richWert($name);
return $value === '' ? null : $value;
}
protected function blank(string $value): ?string protected function blank(string $value): ?string
{ {
$value = trim($value); $value = trim($value);
@@ -2138,9 +2164,9 @@ protected function persistRedaktion(): bool
app(IdentityProfile::class)->fill($record, [ app(IdentityProfile::class)->fill($record, [
'display_title' => $this->displayTitle, 'display_title' => $this->displayTitle,
'teaser' => $this->teaser, 'teaser' => $this->teaser,
'summary' => $this->summary, 'summary' => $this->richStore('summary', $record->summary),
'search_terms' => $this->searchTerms, 'search_terms' => $this->searchTerms,
'description' => $this->description, 'description' => $this->richStore('description', $record->description),
], $this->actor()); ], $this->actor());
$this->syncDimensions($record, array_map(intval(...), $this->dimensionIds)); $this->syncDimensions($record, array_map(intval(...), $this->dimensionIds));
$this->persistPillarIds($record); $this->persistPillarIds($record);
@@ -2291,9 +2317,9 @@ protected function payload(): array
$minutes = $this->minutes($this->durationMinutes); $minutes = $this->minutes($this->durationMinutes);
return [ return [
'learning_goal' => $this->blank($this->learningGoal), 'learning_goal' => $this->richBlank('learningGoal'),
'duration_minutes' => $minutes === false ? $this->durationMinutes : $minutes, 'duration_minutes' => $minutes === false ? $this->durationMinutes : $minutes,
'material_note' => $this->blank($this->materialNote), 'material_note' => $this->richBlank('materialNote'),
'duration_max' => $this->blank($this->durationMax), 'duration_max' => $this->blank($this->durationMax),
'prerequisites' => $this->blank($this->prerequisites), 'prerequisites' => $this->blank($this->prerequisites),
'variants' => $this->normalizeVariants($this->variants), 'variants' => $this->normalizeVariants($this->variants),
@@ -2392,9 +2418,10 @@ protected function normalizePayload(array $payload): array
} }
return [ return [
'learning_goal' => $payload['learning_goal'] ?? null, // Formatierte Angaben nur in kanonischer Form vergleichen: Klartext des Altbestands und dasselbe als HTML sind gleich.
'learning_goal' => FormattedText::canonical($payload['learning_goal'] ?? null) ?: null,
'duration_minutes' => $payload['duration_minutes'] ?? null, 'duration_minutes' => $payload['duration_minutes'] ?? null,
'material_note' => $payload['material_note'] ?? null, 'material_note' => FormattedText::canonical($payload['material_note'] ?? null) ?: null,
'duration_max' => isset($payload['duration_max']) && $payload['duration_max'] !== '' ? (string) $payload['duration_max'] : null, 'duration_max' => isset($payload['duration_max']) && $payload['duration_max'] !== '' ? (string) $payload['duration_max'] : null,
'prerequisites' => $payload['prerequisites'] ?? null, 'prerequisites' => $payload['prerequisites'] ?? null,
'variants' => $this->normalizeVariants($payload['variants'] ?? []), 'variants' => $this->normalizeVariants($payload['variants'] ?? []),
@@ -8,6 +8,7 @@
use App\Domain\Catalog\ContentService; use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\DomainRuleException; use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\EditorialVocabulary; use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\FormattedText;
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;
@@ -19,13 +20,13 @@
use App\Filament\Support\ElementRevision; use App\Filament\Support\ElementRevision;
use App\Filament\Support\MediumForm; use App\Filament\Support\MediumForm;
use App\Filament\Support\ReportsDomainRules; use App\Filament\Support\ReportsDomainRules;
use App\Filament\Support\RichField;
use App\Jobs\DeriveThumbnail; use App\Jobs\DeriveThumbnail;
use Filament\Actions\Action; use Filament\Actions\Action;
use Filament\Forms\Components\CheckboxList; use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\FileUpload; use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Placeholder; use Filament\Forms\Components\Placeholder;
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\Notifications\Notification; use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord; use Filament\Resources\Pages\EditRecord;
@@ -71,7 +72,7 @@ public function form(Schema $schema): Schema
...MediumForm::fields(creating: false, element: $element), ...MediumForm::fields(creating: false, element: $element),
TextInput::make('display_title')->label('Anzeigetitel') TextInput::make('display_title')->label('Anzeigetitel')
->helperText('Erscheint in der Bibliothek. Leer lässt den Arbeitstitel stehen. Speichern legt keine Fassung an.'), ->helperText('Erscheint in der Bibliothek. Leer lässt den Arbeitstitel stehen. Speichern legt keine Fassung an.'),
Textarea::make('summary')->label('Kurzbeschreibung')->rows(3), RichField::make('summary', 'Kurzbeschreibung', live: false),
Select::make('editorial_content_kind_id') Select::make('editorial_content_kind_id')
->label('Fachliche Materialart') ->label('Fachliche Materialart')
->options(fn (): array => app(EditorialVocabulary::class)->kindOptions('medium', $this->getRecord()->editorial_content_kind_id !== null ? (int) $this->getRecord()->editorial_content_kind_id : null)) ->options(fn (): array => app(EditorialVocabulary::class)->kindOptions('medium', $this->getRecord()->editorial_content_kind_id !== null ? (int) $this->getRecord()->editorial_content_kind_id : null))
@@ -194,12 +195,12 @@ protected function mutateFormDataBeforeFill(array $data): array
return [ return [
'working_title' => $this->getRecord()->working_title, 'working_title' => $this->getRecord()->working_title,
'thumbnail_alt' => $this->getRecord()->thumbnail_alt, 'thumbnail_alt' => $this->getRecord()->thumbnail_alt,
'body' => $this->getRecord()->versions()->orderByDesc('number')->first()?->body, 'body' => FormattedText::html($this->getRecord()->versions()->orderByDesc('number')->first()?->body),
'display_title' => $this->getRecord()->display_title, 'display_title' => $this->getRecord()->display_title,
'description' => $this->getRecord()->description, 'description' => FormattedText::html($this->getRecord()->description),
'usage_note' => $this->getRecord()->usage_note, 'usage_note' => $this->getRecord()->usage_note,
'license_note' => $this->getRecord()->license_note, 'license_note' => $this->getRecord()->license_note,
'summary' => $this->getRecord()->summary, 'summary' => FormattedText::html($this->getRecord()->summary),
'editorial_content_kind_id' => $this->getRecord()->editorial_content_kind_id, 'editorial_content_kind_id' => $this->getRecord()->editorial_content_kind_id,
'dimension_ids' => IdentityDimensionValue::query() 'dimension_ids' => IdentityDimensionValue::query()
->where('subject_type', $this->getRecord()->getMorphClass()) ->where('subject_type', $this->getRecord()->getMorphClass())
@@ -218,10 +219,15 @@ protected function handleRecordUpdate(Model $record, array $data): Model
{ {
/** @var ContentElement $record */ /** @var ContentElement $record */
try { try {
app(ContentService::class)->describe($record, (string) $data['working_title'], $data['description'] ?? null); $description = FormattedText::same((string) ($data['description'] ?? ''), $record->description)
? $record->description
: (FormattedText::canonical((string) ($data['description'] ?? '')) ?: null);
app(ContentService::class)->describe($record, (string) $data['working_title'], $description);
app(IdentityProfile::class)->fill($record, [ app(IdentityProfile::class)->fill($record, [
'display_title' => $data['display_title'] ?? null, 'display_title' => $data['display_title'] ?? null,
'summary' => $data['summary'] ?? null, 'summary' => FormattedText::same((string) ($data['summary'] ?? ''), $record->summary)
? $record->summary
: (FormattedText::canonical((string) ($data['summary'] ?? '')) ?: null),
'usage_note' => $data['usage_note'] ?? null, 'usage_note' => $data['usage_note'] ?? null,
'license_note' => $data['license_note'] ?? null, 'license_note' => $data['license_note'] ?? null,
'thumbnail_alt' => $data['thumbnail_alt'] ?? null, 'thumbnail_alt' => $data['thumbnail_alt'] ?? null,
@@ -229,8 +235,8 @@ protected function handleRecordUpdate(Model $record, array $data): Model
if ($record->output_class === 'text' && is_string($data['body'] ?? null)) { if ($record->output_class === 'text' && is_string($data['body'] ?? null)) {
$latest = $record->versions()->orderByDesc('number')->first(); $latest = $record->versions()->orderByDesc('number')->first();
if ($latest instanceof ContentElementVersion) { if ($latest instanceof ContentElementVersion && ! FormattedText::same($data['body'], $latest->body)) {
app(ContentService::class)->reviseElementContent($latest, $data['body']); app(ContentService::class)->reviseElementContent($latest, FormattedText::canonical($data['body']));
} }
} }
if (array_key_exists('editorial_content_kind_id', $data)) { if (array_key_exists('editorial_content_kind_id', $data)) {
@@ -8,6 +8,7 @@
use App\Domain\Catalog\ContentVersionStatus; use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\DomainRuleException; use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\EditorialVocabulary; use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\FormattedText;
use App\Domain\Catalog\IdentityChange; use App\Domain\Catalog\IdentityChange;
use App\Domain\Catalog\IdentityDimension; use App\Domain\Catalog\IdentityDimension;
use App\Domain\Catalog\IdentityDimensionValue; use App\Domain\Catalog\IdentityDimensionValue;
@@ -26,6 +27,7 @@
use App\Filament\Support\EditorialCatalog; use App\Filament\Support\EditorialCatalog;
use App\Filament\Support\ElementRevision; use App\Filament\Support\ElementRevision;
use App\Filament\Support\ManagesEditorialSurface; use App\Filament\Support\ManagesEditorialSurface;
use App\Filament\Support\ManagesRichFields;
use App\Filament\Support\MediaLibrary; use App\Filament\Support\MediaLibrary;
use App\Filament\Support\ReportsDomainRules; use App\Filament\Support\ReportsDomainRules;
use App\Http\Controllers\ContentPreviewController; use App\Http\Controllers\ContentPreviewController;
@@ -45,6 +47,7 @@
class ViewContentElement extends ViewRecord class ViewContentElement extends ViewRecord
{ {
use ManagesEditorialSurface; use ManagesEditorialSurface;
use ManagesRichFields;
use ReportsDomainRules; use ReportsDomainRules;
use WithFileUploads; use WithFileUploads;
@@ -211,7 +214,7 @@ public function textUnsaved(): bool
return $shown instanceof ContentElementVersion return $shown instanceof ContentElementVersion
&& $this->getRecord()->output_class === 'text' && $this->getRecord()->output_class === 'text'
&& $shown->status !== ContentVersionStatus::Gesperrt && $shown->status !== ContentVersionStatus::Gesperrt
&& trim($this->bodyDraft) !== trim((string) $shown->body); && ! FormattedText::same($this->bodyDraft, $shown->body);
} }
public function discardShownText(): void public function discardShownText(): void
@@ -243,7 +246,7 @@ public function saveShownText(): void
} }
try { try {
$saved = app(ContentService::class)->reviseElementContent($shown, $this->bodyDraft); $saved = app(ContentService::class)->reviseElementContent($shown, FormattedText::canonical($this->bodyDraft));
} catch (DomainRuleException $exception) { } catch (DomainRuleException $exception) {
$this->fassungFeedback = $exception->getMessage(); $this->fassungFeedback = $exception->getMessage();
$this->fassungFeedbackError = true; $this->fassungFeedbackError = true;
@@ -687,9 +690,9 @@ protected function saveRedaktionTexte(): bool
'working_title' => $title, 'working_title' => $title,
'display_title' => $this->displayTitle, 'display_title' => $this->displayTitle,
'teaser' => $this->teaser, 'teaser' => $this->teaser,
'summary' => $this->summary, 'summary' => $this->richStore('summary', $element->summary),
'search_terms' => $this->searchTerms, 'search_terms' => $this->searchTerms,
'description' => $this->descriptionText, 'description' => $this->richStore('descriptionText', $element->description),
'usage_note' => $this->usageNote, 'usage_note' => $this->usageNote,
'license_note' => $this->licenseNote, 'license_note' => $this->licenseNote,
'website_credit' => $this->websiteCredit, 'website_credit' => $this->websiteCredit,
@@ -780,6 +783,14 @@ public function redaktionTitel(): string
return $title !== '' ? $title : (string) $this->getRecord()->working_title; return $title !== '' ? $title : (string) $this->getRecord()->working_title;
} }
/**
* @return array<string, string>
*/
protected function richFelder(): array
{
return ['summary' => 'Kurzbeschreibung', 'descriptionText' => 'Ausführliche Beschreibung', 'bodyDraft' => 'Text der Fassung'];
}
/** /**
* @return list<array<string, mixed>> * @return list<array<string, mixed>>
*/ */
@@ -793,8 +804,8 @@ public function redaktionFelder(): array
['id' => 'arbeitstitel', 'label' => 'Arbeitstitel', 'model' => 'workingTitle', 'kind' => 'text', 'stored' => $stored('working_title'), 'required' => true, 'hilfe' => 'Bezeichnung in der Verwaltung. Pflichtangabe.'], ['id' => 'arbeitstitel', 'label' => 'Arbeitstitel', 'model' => 'workingTitle', 'kind' => 'text', 'stored' => $stored('working_title'), 'required' => true, 'hilfe' => 'Bezeichnung in der Verwaltung. Pflichtangabe.'],
['id' => 'anzeigename', 'label' => 'Anzeigename', 'model' => 'displayTitle', 'kind' => 'text', 'stored' => $stored('display_title'), 'hilfe' => 'Erscheint auf Karten und in der Bibliothek. Leer zeigt den Arbeitstitel.'], ['id' => 'anzeigename', 'label' => 'Anzeigename', 'model' => 'displayTitle', 'kind' => 'text', 'stored' => $stored('display_title'), 'hilfe' => 'Erscheint auf Karten und in der Bibliothek. Leer zeigt den Arbeitstitel.'],
['id' => 'teaser', 'label' => 'Teaser', 'model' => 'teaser', 'kind' => 'textarea', 'rows' => 2, 'stored' => $stored('teaser')], ['id' => 'teaser', 'label' => 'Teaser', 'model' => 'teaser', 'kind' => 'textarea', 'rows' => 2, 'stored' => $stored('teaser')],
['id' => 'kurz', 'label' => 'Kurzbeschreibung', 'model' => 'summary', 'kind' => 'textarea', 'rows' => 3, 'stored' => $stored('summary'), 'hilfe' => 'Erscheint auf Website- und Bibliothekskarten.'], ['id' => 'kurz', 'label' => 'Kurzbeschreibung', 'model' => 'summary', 'kind' => 'rich', 'stored' => $stored('summary'), 'hilfe' => 'Erscheint auf Website- und Bibliothekskarten.'],
['id' => 'beschreibung', 'label' => 'Ausführliche Beschreibung', 'model' => 'descriptionText', 'kind' => 'textarea', 'rows' => 8, 'stored' => $stored('description'), 'hilfe' => 'Bleibt in der Verwaltung und in Detailansichten. Kein Lehrtext.'], ['id' => 'beschreibung', 'label' => 'Ausführliche Beschreibung', 'model' => 'descriptionText', 'kind' => 'rich', 'stored' => $stored('description'), 'hilfe' => 'Bleibt in der Verwaltung und in Detailansichten. Kein Lehrtext.'],
['id' => 'suche', 'label' => 'Suchbegriffe', 'model' => 'searchTerms', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('search_terms'), 'placeholder' => 'Begriffe, durch Komma getrennt'], ['id' => 'suche', 'label' => 'Suchbegriffe', 'model' => 'searchTerms', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('search_terms'), 'placeholder' => 'Begriffe, durch Komma getrennt'],
['id' => 'einsatz', 'label' => 'Hinweise für den Einsatz', 'model' => 'usageNote', 'kind' => 'textarea', 'rows' => 3, 'gruppe' => 'weitere', 'stored' => $stored('usage_note')], ['id' => 'einsatz', 'label' => 'Hinweise für den Einsatz', 'model' => 'usageNote', 'kind' => 'textarea', 'rows' => 3, 'gruppe' => 'weitere', 'stored' => $stored('usage_note')],
['id' => 'lizenz', 'label' => 'Interner Lizenzvermerk', 'model' => 'licenseNote', 'kind' => 'textarea', 'rows' => 3, 'gruppe' => 'weitere', 'stored' => $stored('license_note'), 'hilfe' => 'Nur intern sichtbar.'], ['id' => 'lizenz', 'label' => 'Interner Lizenzvermerk', 'model' => 'licenseNote', 'kind' => 'textarea', 'rows' => 3, 'gruppe' => 'weitere', 'stored' => $stored('license_note'), 'hilfe' => 'Nur intern sichtbar.'],
@@ -1040,7 +1051,7 @@ public function previewHtml(): string
$draft = [ $draft = [
'working_title' => $this->workingTitle, 'working_title' => $this->workingTitle,
'display_title' => $this->displayTitle, 'display_title' => $this->displayTitle,
'summary' => $this->summary, 'summary' => FormattedText::plain($this->summary),
'thumbnail_alt' => $this->thumbnailAlt, 'thumbnail_alt' => $this->thumbnailAlt,
]; ];
@@ -1053,7 +1064,7 @@ public function previewHtml(): string
'type' => $element->output_class === 'film' ? 'film' : 'material', 'type' => $element->output_class === 'film' ? 'film' : 'material',
'url' => '#vorschau', 'url' => '#vorschau',
'title' => $title !== '' ? $title : $element->working_title, 'title' => $title !== '' ? $title : $element->working_title,
'summary' => trim($this->summary) !== '' ? trim($this->summary) : null, 'summary' => FormattedText::plain($this->summary) !== '' ? FormattedText::plain($this->summary) : null,
'kind' => PublicMaterialReader::outputLabel((string) $element->output_class), 'kind' => PublicMaterialReader::outputLabel((string) $element->output_class),
'hide_status' => true, 'hide_status' => true,
'image' => trim($this->thumbnailAlt) !== '' ? trim($this->thumbnailAlt) : $title, 'image' => trim($this->thumbnailAlt) !== '' ? trim($this->thumbnailAlt) : $title,
@@ -20,6 +20,7 @@
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\ReportsDomainRules; use App\Filament\Support\ReportsDomainRules;
use Filament\Actions\Action; use Filament\Actions\Action;
use Filament\Forms\Components\Select; use Filament\Forms\Components\Select;
@@ -33,6 +34,7 @@ class ViewLicenseArticle extends ViewRecord
{ {
use AssignsPillars; use AssignsPillars;
use ManagesEditorialSurface; use ManagesEditorialSurface;
use ManagesRichFields;
use ReportsDomainRules; use ReportsDomainRules;
protected static string $resource = LicenseArticleResource::class; protected static string $resource = LicenseArticleResource::class;
@@ -110,8 +112,8 @@ protected function saveRedaktionTexte(): bool
'working_title' => $this->workingTitle, 'working_title' => $this->workingTitle,
'display_title' => $this->displayTitle, 'display_title' => $this->displayTitle,
'teaser' => $this->teaser, 'teaser' => $this->teaser,
'summary' => $this->summary, 'summary' => $this->richStore('summary', $article->summary),
'description' => $this->descriptionText, 'description' => $this->richStore('descriptionText', $article->description),
'search_terms' => $this->searchTerms, 'search_terms' => $this->searchTerms,
'editorial_content_kind_id' => filled($this->kindId) ? (int) $this->kindId : null, 'editorial_content_kind_id' => filled($this->kindId) ? (int) $this->kindId : null,
], auth()->user()); ], auth()->user());
@@ -199,6 +201,14 @@ public function redaktionTitel(): string
return $source !== null ? $this->sourceTitle($source) : (string) $this->getRecord()->code; return $source !== null ? $this->sourceTitle($source) : (string) $this->getRecord()->code;
} }
/**
* @return array<string, string>
*/
protected function richFelder(): array
{
return ['summary' => 'Kurzbeschreibung', 'descriptionText' => 'Beschreibung'];
}
/** /**
* @return list<array<string, mixed>> * @return list<array<string, mixed>>
*/ */
@@ -218,8 +228,8 @@ public function redaktionFelder(): array
['id' => 'arbeitstitel', 'label' => 'Interner Arbeitstitel', 'model' => 'workingTitle', 'kind' => 'text', 'stored' => $stored('working_title'), 'hilfe' => 'Nur in der Verwaltung sichtbar.'], ['id' => 'arbeitstitel', 'label' => 'Interner Arbeitstitel', 'model' => 'workingTitle', 'kind' => 'text', 'stored' => $stored('working_title'), 'hilfe' => 'Nur in der Verwaltung sichtbar.'],
['id' => 'anzeigename', 'label' => 'Name', 'model' => 'displayTitle', 'kind' => 'text', 'stored' => $stored('display_title'), 'quelle' => $quelle('display_title')], ['id' => 'anzeigename', 'label' => 'Name', 'model' => 'displayTitle', 'kind' => 'text', 'stored' => $stored('display_title'), 'quelle' => $quelle('display_title')],
['id' => 'teaser', 'label' => 'Teaser', 'model' => 'teaser', 'kind' => 'textarea', 'rows' => 2, 'stored' => $stored('teaser'), 'quelle' => $quelle('teaser')], ['id' => 'teaser', 'label' => 'Teaser', 'model' => 'teaser', 'kind' => 'textarea', 'rows' => 2, 'stored' => $stored('teaser'), 'quelle' => $quelle('teaser')],
['id' => 'kurz', 'label' => 'Kurzbeschreibung', 'model' => 'summary', 'kind' => 'textarea', 'rows' => 4, 'stored' => $stored('summary'), 'quelle' => $quelle('summary')], ['id' => 'kurz', 'label' => 'Kurzbeschreibung', 'model' => 'summary', 'kind' => 'rich', 'stored' => $stored('summary'), 'quelle' => $quelle('summary')],
['id' => 'beschreibung', 'label' => 'Beschreibung', 'model' => 'descriptionText', 'kind' => 'textarea', 'rows' => 6, 'stored' => $stored('description'), 'quelle' => $quelle('description')], ['id' => 'beschreibung', 'label' => 'Beschreibung', 'model' => 'descriptionText', 'kind' => 'rich', 'stored' => $stored('description'), 'quelle' => $quelle('description')],
['id' => 'suche', 'label' => 'Suchbegriffe', 'model' => 'searchTerms', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('search_terms'), 'quelle' => $quelle('search_terms')], ['id' => 'suche', 'label' => 'Suchbegriffe', 'model' => 'searchTerms', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('search_terms'), 'quelle' => $quelle('search_terms')],
]; ];
} }
@@ -20,7 +20,7 @@ class PillarResource extends Resource
{ {
protected static ?string $model = Pillar::class; protected static ?string $model = Pillar::class;
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte'; protected static string|\UnitEnum|null $navigationGroup = 'Stammdaten';
protected static ?string $navigationLabel = 'Fachliche Säulen'; protected static ?string $navigationLabel = 'Fachliche Säulen';
@@ -32,7 +32,7 @@ class PillarResource extends Resource
protected static ?string $slug = 'saeulen'; protected static ?string $slug = 'saeulen';
protected static ?int $navigationSort = 5; protected static ?int $navigationSort = 1;
public static function canViewAny(): bool public static function canViewAny(): bool
{ {
@@ -21,7 +21,7 @@ class PracticeResource extends CompositionKindResource
protected static ?string $pluralModelLabel = 'Übungen'; protected static ?string $pluralModelLabel = 'Übungen';
protected static ?int $navigationSort = 5; protected static ?int $navigationSort = 2;
public static function kind(): CompositionKind public static function kind(): CompositionKind
{ {
+7 -6
View File
@@ -13,6 +13,7 @@
use App\Domain\Catalog\ContentService; use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\ContentVersionStatus; use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\EditorialContentKind; use App\Domain\Catalog\EditorialContentKind;
use App\Domain\Catalog\FormattedText;
use App\Domain\Catalog\IdentityDimensionValue; use App\Domain\Catalog\IdentityDimensionValue;
use App\Domain\Catalog\LicenseArticle; use App\Domain\Catalog\LicenseArticle;
use App\Domain\Catalog\OfferStatus; use App\Domain\Catalog\OfferStatus;
@@ -108,8 +109,8 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
'kind' => $kind, 'kind' => $kind,
'output' => (string) $element->output_class, 'output' => (string) $element->output_class,
'body' => (string) ($version->body ?? ''), 'body' => (string) ($version->body ?? ''),
'summary' => (string) ($element->summary ?: $element->description ?: ''), 'summary' => FormattedText::plain((string) ($element->summary ?: $element->description ?: '')),
'medium_description' => (string) ($element->description ?? ''), 'medium_description' => FormattedText::plain((string) ($element->description ?? '')),
'usage_note' => (string) ($element->usage_note ?? ''), 'usage_note' => (string) ($element->usage_note ?? ''),
'license_note' => (string) ($element->license_note ?? ''), 'license_note' => (string) ($element->license_note ?? ''),
'tone' => $this->tone((string) $element->output_class, $kind), 'tone' => $this->tone((string) $element->output_class, $kind),
@@ -159,7 +160,7 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
'target' => 'composition:'.$version->id, 'target' => 'composition:'.$version->id,
'title' => $this->compositionTitle($composition), 'title' => $this->compositionTitle($composition),
'kind' => $kind, 'kind' => $kind,
'summary' => (string) ($composition->summary ?? ''), 'summary' => FormattedText::plain((string) ($composition->summary ?? '')),
'tone' => $this->tone('', $kind), 'tone' => $this->tone('', $kind),
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path), 'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path),
'version_label' => $version->status === ContentVersionStatus::Gesperrt 'version_label' => $version->status === ContentVersionStatus::Gesperrt
@@ -194,7 +195,7 @@ private function draftCompositionRow(int $compositionId, int $exceptCompositionI
'target' => 'composition-draft:'.$composition->id, 'target' => 'composition-draft:'.$composition->id,
'title' => $this->compositionTitle($composition), 'title' => $this->compositionTitle($composition),
'kind' => $kind, 'kind' => $kind,
'summary' => (string) ($composition->summary ?? ''), 'summary' => FormattedText::plain((string) ($composition->summary ?? '')),
'tone' => $this->tone('', $kind), 'tone' => $this->tone('', $kind),
'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path), 'image' => $this->cardUrl('komposition', $composition->id, $composition->thumbnail_path),
'version_label' => 'Entwurf', 'version_label' => 'Entwurf',
@@ -510,8 +511,8 @@ private function rowForPresentationMedium(int $id): ?array
'kind' => $kind, 'kind' => $kind,
'output' => (string) $element->output_class, 'output' => (string) $element->output_class,
'body' => '', 'body' => '',
'summary' => (string) ($element->summary ?: $element->description ?: ''), 'summary' => FormattedText::plain((string) ($element->summary ?: $element->description ?: '')),
'medium_description' => (string) ($element->description ?? ''), 'medium_description' => FormattedText::plain((string) ($element->description ?? '')),
'usage_note' => (string) ($element->usage_note ?? ''), 'usage_note' => (string) ($element->usage_note ?? ''),
'license_note' => (string) ($element->license_note ?? ''), 'license_note' => (string) ($element->license_note ?? ''),
'tone' => $this->tone((string) $element->output_class, $kind), 'tone' => $this->tone((string) $element->output_class, $kind),
+4 -4
View File
@@ -6,9 +6,9 @@
use App\Domain\Catalog\ContentElementVersion; use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Catalog\ContentService; use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\DomainRuleException; use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\FormattedText;
use App\Filament\Resources\ContentElements\Pages\EditContentElement; use App\Filament\Resources\ContentElements\Pages\EditContentElement;
use Filament\Forms\Components\Component; use Filament\Forms\Components\Component;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle; use Filament\Forms\Components\Toggle;
@@ -37,14 +37,14 @@ public static function publish(ContentElement $record, array $data): string
$metadata['decision_seconds'] = $decision; $metadata['decision_seconds'] = $decision;
} }
$body = is_string($data['body'] ?? null) ? $data['body'] : null; $body = is_string($data['body'] ?? null) ? (FormattedText::canonical($data['body']) ?: null) : null;
$note = is_string($data['change_note'] ?? null) ? $data['change_note'] : null; $note = is_string($data['change_note'] ?? null) ? $data['change_note'] : null;
$previousDecision = is_array($latest?->metadata) && is_numeric($latest->metadata['decision_seconds'] ?? null) $previousDecision = is_array($latest?->metadata) && is_numeric($latest->metadata['decision_seconds'] ?? null)
? (int) $latest->metadata['decision_seconds'] ? (int) $latest->metadata['decision_seconds']
: null; : null;
$changed = $incoming !== null $changed = $incoming !== null
|| $dropFile || $dropFile
|| trim((string) $body) !== trim((string) $latest?->body) || ! FormattedText::same($body, $latest?->body)
|| $decision !== $previousDecision || $decision !== $previousDecision
|| (is_string($note) && trim($note) !== ''); || (is_string($note) && trim($note) !== '');
@@ -71,7 +71,7 @@ public static function fields(ContentElement $element): array
$latest = $element->versions()->orderByDesc('number')->first(); $latest = $element->versions()->orderByDesc('number')->first();
return [ return [
Textarea::make('body')->label('Text')->rows(8)->default($latest?->body), RichField::make('body', 'Text', live: false)->default(FormattedText::html($latest?->body)),
EditContentElement::uploadField(), EditContentElement::uploadField(),
Toggle::make('drop_file') Toggle::make('drop_file')
->label('Datei in der neuen Fassung nicht mehr verwenden') ->label('Datei in der neuen Fassung nicht mehr verwenden')
+4 -3
View File
@@ -8,6 +8,7 @@
use App\Domain\Catalog\ContentVersionStatus; use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\EditorialVocabulary; use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\ExerciseSource; use App\Domain\Catalog\ExerciseSource;
use App\Domain\Catalog\FormattedText;
use App\Domain\Catalog\IdentityDimensionValue; use App\Domain\Catalog\IdentityDimensionValue;
use App\Domain\Catalog\Pillar; use App\Domain\Catalog\Pillar;
use App\Domain\Catalog\PillarFilterCompat; use App\Domain\Catalog\PillarFilterCompat;
@@ -183,8 +184,8 @@ public function entries(): array
} }
$title = $catalog->compositionTitle($composition); $title = $catalog->compositionTitle($composition);
$summary = trim((string) ($composition->summary ?? '')); $summary = FormattedText::plain((string) ($composition->summary ?? ''));
$haystack = mb_strtolower($title.' '.$composition->designation.' '.$summary.' '.(string) $composition->description); $haystack = mb_strtolower($title.' '.$composition->designation.' '.$summary.' '.FormattedText::plain((string) $composition->description));
if ($needle !== '' && ! str_contains($haystack, $needle)) { if ($needle !== '' && ! str_contains($haystack, $needle)) {
continue; continue;
@@ -235,7 +236,7 @@ private function exerciseOrigin(Composition $composition, array $shinkan): strin
$latest = $composition->versions->sortByDesc('number')->first(); $latest = $composition->versions->sortByDesc('number')->first();
$local = $latest !== null && CompositionMember::query()->where('composition_version_id', $latest->id)->where('origin', 'lokal')->exists(); $local = $latest !== null && CompositionMember::query()->where('composition_version_id', $latest->id)->where('origin', 'lokal')->exists();
return $local ? 'Shinkan, lokal ergänzt' : 'Shinkan'; return $local ? 'Shinkan, lokal bearbeitet' : 'Shinkan';
} }
/** /**
@@ -9,6 +9,7 @@
use App\Domain\Catalog\EditorialProfile; use App\Domain\Catalog\EditorialProfile;
use App\Domain\Catalog\EditorialProfileReader; use App\Domain\Catalog\EditorialProfileReader;
use App\Domain\Catalog\EditorialTextVariant; use App\Domain\Catalog\EditorialTextVariant;
use App\Domain\Catalog\FormattedText;
use App\Domain\Catalog\PresentationMedia; use App\Domain\Catalog\PresentationMedia;
use App\Domain\Catalog\PresentationRole; use App\Domain\Catalog\PresentationRole;
use App\Domain\Media\WebsiteRelease; use App\Domain\Media\WebsiteRelease;
@@ -310,6 +311,10 @@ public function feldGeaendert(array $feld): bool
{ {
$model = (string) $feld['model']; $model = (string) $feld['model'];
if (($feld['kind'] ?? null) === 'rich') {
return ! FormattedText::same((string) $this->{$model}, (string) ($feld['stored'] ?? ''));
}
return trim((string) $this->{$model}) !== trim((string) ($feld['stored'] ?? '')); return trim((string) $this->{$model}) !== trim((string) ($feld['stored'] ?? ''));
} }
+132
View File
@@ -0,0 +1,132 @@
<?php
namespace App\Filament\Support;
use App\Domain\Catalog\FormattedText;
use Filament\Forms\Components\RichEditor;
use Filament\Schemas\Components\Component;
use Filament\Schemas\Schema;
/**
* Formatierte Textfelder in den Arbeitsplätzen der Verwaltung (ADR-50).
*
* Die Arbeitsplätze halten ihre Texte als einfache Zeichenketten in öffentlichen Eigenschaften. Der Editor von Filament
* hält dagegen ein Dokument in seinem eigenen Zustand (`rich.<feld>`). Diese Eigenschaft ist der einzige Ort, an dem beide
* zusammenkommen:
*
* - Die Zeichenkette bleibt maßgeblich. Eine Eingabe im Editor wird beim Verlassen des Felds in kanonisches HTML gewandelt
* und in die Eigenschaft geschrieben ({@see self::updatedRich()}).
* - Setzt der Server eine Eigenschaft selbst (Laden, Zurücknehmen, Wechsel des Abschnitts), gleicht der Editor sich vor
* dem nächsten Rendern an ({@see self::renderingManagesRichFields()}). Klartext des Altbestands erscheint dabei
* formatiert, ohne dass etwas gespeichert wird.
*
* Verglichen wird nur in kanonischer Form ({@see FormattedText::canonical()}): Das Öffnen eines Felds im Editor ändert
* nichts am Arbeitsstand.
*/
trait ManagesRichFields
{
/** @var array<string, mixed> Zustand der Editoren (Dokumente) je Eigenschaft */
public array $rich = [];
/** @var array<string, string> Prüfsumme des zuletzt abgeglichenen kanonischen Werts je Eigenschaft */
public array $richSeen = [];
/**
* Eigenschaften dieser Seite, die mit dem Editor bearbeitet werden, mit ihrer Bezeichnung (Name für Hilfstechnik).
*
* @return array<string, string>
*/
protected function richFelder(): array
{
return [];
}
/** @return list<string> */
protected function richNamen(): array
{
return array_keys($this->richFelder());
}
public function richTextSchema(Schema $schema): Schema
{
return $schema
->statePath('rich')
->components(array_map(fn (string $name, string $label): RichEditor => RichField::make($name, $label, hideLabel: true), $this->richNamen(), $this->richFelder()));
}
public function richKomponente(string $name): ?Component
{
return $this->getSchema('richTextSchema')?->getFlatComponents()[$name] ?? null;
}
/** Eingabe im Editor übernehmen. */
public function updatedRich(mixed $value = null, ?string $key = null): void
{
$name = explode('.', (string) $key)[0];
if ($name !== '' && in_array($name, $this->richNamen(), true)) {
$this->richPull($name);
}
}
/** Wert aus dem Editor in die Eigenschaft schreiben. */
protected function richPull(string $name): void
{
$component = $this->richKomponente($name);
if ($component === null) {
return;
}
$html = FormattedText::canonicalHtml((string) $component->getState());
$this->{$name} = $html;
$this->richSeen[$name] = md5($html);
}
/** Wert der Eigenschaft in den Editor schreiben. */
protected function richPush(string $name): void
{
$component = $this->richKomponente($name);
if ($component === null) {
return;
}
$canonical = FormattedText::canonical((string) $this->{$name});
$component->state($canonical === '' ? null : $canonical);
$this->richSeen[$name] = md5($canonical);
}
/** Vor dem Rendern: Eigenschaften, die der Server geändert hat, in den Editor übernehmen. */
public function renderingManagesRichFields(): void
{
foreach ($this->richNamen() as $name) {
$canonical = FormattedText::canonical((string) $this->{$name});
if (! array_key_exists($name, $this->richSeen) || $this->richSeen[$name] !== md5($canonical)) {
$this->richPush($name);
}
}
}
/**
* Wert zum Schreiben in eine Spalte. Ist der Text inhaltlich der gespeicherte, bleibt der gespeicherte Wert, wie er
* ist: Klartext des Altbestands wird nicht allein durch das Öffnen im Editor zu HTML und erzeugt keine Änderung.
*/
protected function richStore(string $name, ?string $stored): ?string
{
if (FormattedText::same((string) $this->{$name}, $stored)) {
return ($stored === null || trim($stored) === '') ? null : $stored;
}
$value = $this->richWert($name);
return $value === '' ? null : $value;
}
/** Kanonischer Wert einer Eigenschaft für Speichern und Vergleichen. */
protected function richWert(string $name): string
{
return FormattedText::canonical((string) $this->{$name});
}
}
+4 -3
View File
@@ -9,6 +9,7 @@
use App\Domain\Catalog\ContentElementVersion; use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Catalog\ContentVersionStatus; use App\Domain\Catalog\ContentVersionStatus;
use App\Domain\Catalog\EditorialVocabulary; use App\Domain\Catalog\EditorialVocabulary;
use App\Domain\Catalog\FormattedText;
use App\Domain\Catalog\IdentityDimensionValue; use App\Domain\Catalog\IdentityDimensionValue;
use App\Domain\Catalog\Pillar; use App\Domain\Catalog\Pillar;
use App\Domain\Catalog\PillarFilterCompat; use App\Domain\Catalog\PillarFilterCompat;
@@ -488,8 +489,8 @@ private function haystack(ContentElement $element): string
return mb_strtolower(implode("\n", array_filter([ return mb_strtolower(implode("\n", array_filter([
$element->working_title, $element->working_title,
$element->display_title, $element->display_title,
$element->description, FormattedText::plain($element->description),
$element->summary, FormattedText::plain($element->summary),
$element->teaser, $element->teaser,
$element->search_terms, $element->search_terms,
$element->usage_note, $element->usage_note,
@@ -504,7 +505,7 @@ private function haystack(ContentElement $element): string
*/ */
private function card(ContentElement $element, array $portrait, array $uses, array $codes, bool $canEdit): array private function card(ContentElement $element, array $portrait, array $uses, array $codes, bool $canEdit): array
{ {
$description = trim((string) ($element->description ?: $element->summary ?: '')); $description = FormattedText::plain((string) ($element->description ?: $element->summary ?: ''));
$usageNote = trim((string) $element->usage_note); $usageNote = trim((string) $element->usage_note);
$licenseNote = trim((string) $element->license_note); $licenseNote = trim((string) $element->license_note);
$typeKey = $this->typeKey((string) $element->output_class); $typeKey = $this->typeKey((string) $element->output_class);
+12 -8
View File
@@ -6,6 +6,7 @@
use App\Domain\Catalog\ContentElementVersion; use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Catalog\ContentService; use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\DomainRuleException; use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\FormattedText;
use App\Domain\Catalog\IdentityProfile; use App\Domain\Catalog\IdentityProfile;
use App\Domain\Media\PresentationFile; use App\Domain\Media\PresentationFile;
use App\Jobs\DeriveThumbnail; use App\Jobs\DeriveThumbnail;
@@ -35,7 +36,7 @@ public static function fields(bool $creating, ?ContentElement $element = null):
'document' => 'Dokument', 'document' => 'Dokument',
'text' => 'Text', 'text' => 'Text',
])->required()->live(); ])->required()->live();
$fields[] = Textarea::make('body')->label('Text')->rows(8) $fields[] = RichField::make('body', 'Text', live: false)
->visible(fn ($get): bool => $get('shape') === 'text') ->visible(fn ($get): bool => $get('shape') === 'text')
->required(fn ($get): bool => $get('shape') === 'text'); ->required(fn ($get): bool => $get('shape') === 'text');
$fields[] = self::fileField() $fields[] = self::fileField()
@@ -46,12 +47,12 @@ public static function fields(bool $creating, ?ContentElement $element = null):
->helperText('Bild, Film oder Hörstück ohne fachliche Inhaltsfassung, zum Beispiel ein Trailer, der ungeschützt auf der Website laufen soll. Der Film muss dafür MP4 (H.264) oder WebM sein. Er wird nicht lizenziert und erst nach „Für die Website freigeben“ öffentlich.') ->helperText('Bild, Film oder Hörstück ohne fachliche Inhaltsfassung, zum Beispiel ein Trailer, der ungeschützt auf der Website laufen soll. Der Film muss dafür MP4 (H.264) oder WebM sein. Er wird nicht lizenziert und erst nach „Für die Website freigeben“ öffentlich.')
->visible(fn ($get): bool => in_array($get('shape'), ['film', 'audio', 'bild'], true)); ->visible(fn ($get): bool => in_array($get('shape'), ['film', 'audio', 'bild'], true));
} elseif ($element?->output_class === 'text') { } elseif ($element?->output_class === 'text') {
$fields[] = Textarea::make('body')->label('Text')->rows(8)->required(); $fields[] = RichField::make('body', 'Text', live: false)->required();
} }
return [ return [
...$fields, ...$fields,
Textarea::make('description')->label('Beschreibung')->rows(4) RichField::make('description', 'Beschreibung', live: false)
->helperText('Gilt für das Medium, nicht nur für diese eine Stelle.'), ->helperText('Gilt für das Medium, nicht nur für diese eine Stelle.'),
Textarea::make('usage_note')->label('Hinweise für den Einsatz')->rows(3), Textarea::make('usage_note')->label('Hinweise für den Einsatz')->rows(3),
Textarea::make('license_note')->label('Interner Lizenzvermerk')->rows(3) Textarea::make('license_note')->label('Interner Lizenzvermerk')->rows(3)
@@ -125,7 +126,7 @@ public static function create(array $data, bool $hold): ContentElement
self::remember($element, $data); self::remember($element, $data);
if ($output === 'text') { if ($output === 'text') {
$body = trim((string) ($data['body'] ?? '')); $body = FormattedText::canonical((string) ($data['body'] ?? ''));
if ($body === '') { if ($body === '') {
throw new DomainRuleException('Der Text braucht einen Inhalt.'); throw new DomainRuleException('Der Text braucht einen Inhalt.');
@@ -164,7 +165,7 @@ public static function update(ContentElement $element, array $data): ?ContentEle
if ($element->output_class === 'text') { if ($element->output_class === 'text') {
$latest = $element->versions()->orderByDesc('number')->first(); $latest = $element->versions()->orderByDesc('number')->first();
$body = trim((string) ($data['body'] ?? '')); $body = FormattedText::canonical((string) ($data['body'] ?? ''));
if ($latest instanceof ContentElementVersion && $body !== '') { if ($latest instanceof ContentElementVersion && $body !== '') {
$revised = app(ContentService::class)->reviseElementContent($latest, $body); $revised = app(ContentService::class)->reviseElementContent($latest, $body);
@@ -185,11 +186,11 @@ public static function fill(ContentElement $element): array
return [ return [
'working_title' => $element->working_title, 'working_title' => $element->working_title,
'description' => $element->description, 'description' => FormattedText::html($element->description),
'usage_note' => $element->usage_note, 'usage_note' => $element->usage_note,
'license_note' => $element->license_note, 'license_note' => $element->license_note,
'thumbnail_alt' => $element->thumbnail_alt, 'thumbnail_alt' => $element->thumbnail_alt,
'body' => $latest?->body, 'body' => FormattedText::html($latest?->body),
]; ];
} }
@@ -198,7 +199,10 @@ public static function fill(ContentElement $element): array
*/ */
public static function remember(ContentElement $element, array $data): void public static function remember(ContentElement $element, array $data): void
{ {
app(ContentService::class)->describe($element, (string) $data['working_title'], $data['description'] ?? null); $description = FormattedText::same((string) ($data['description'] ?? ''), $element->description)
? $element->description
: (FormattedText::canonical((string) ($data['description'] ?? '')) ?: null);
app(ContentService::class)->describe($element, (string) $data['working_title'], $description);
app(IdentityProfile::class)->fill($element, [ app(IdentityProfile::class)->fill($element, [
'usage_note' => $data['usage_note'] ?? null, 'usage_note' => $data['usage_note'] ?? null,
'license_note' => $data['license_note'] ?? null, 'license_note' => $data['license_note'] ?? null,
+33
View File
@@ -0,0 +1,33 @@
<?php
namespace App\Filament\Support;
use App\Domain\Catalog\FormattedText;
use Filament\Forms\Components\RichEditor;
/**
* Der eine Editor für formatierte Texte (ADR-50): immer dieselbe Symbolleiste, dasselbe Ergebnis (bereinigtes HTML).
* Neue formatierte Felder nutzen diesen Baustein und keinen eigenen Editor.
*/
final class RichField
{
/**
* @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 $hideLabel Die Bezeichnung zeigt der Arbeitsplatz selbst
*/
public static function make(string $name, ?string $label = null, bool $live = true, bool $hideLabel = false): RichEditor
{
$field = RichEditor::make($name)->toolbarButtons(FormattedText::TOOLBAR);
if ($live) {
$field->live(onBlur: true);
}
if ($label !== null) {
$field->label($label);
}
return $label === null || $hideLabel ? $field->hiddenLabel() : $field;
}
}
+3 -2
View File
@@ -4,6 +4,7 @@
use App\Domain\Catalog\Bundle; use App\Domain\Catalog\Bundle;
use App\Domain\Catalog\Composition; use App\Domain\Catalog\Composition;
use App\Domain\Catalog\FormattedText;
use App\Domain\Cms\Catalog\PublicCatalogReader; 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;
@@ -30,7 +31,7 @@ public function index(Request $request, ProductOptions $products, PublicCatalogR
} }
$title = (string) ($composition->display_title ?: $composition->designation); $title = (string) ($composition->display_title ?: $composition->designation);
$haystack = mb_strtolower($title.' '.$composition->teaser.' '.$composition->summary.' '.$composition->search_terms); $haystack = mb_strtolower($title.' '.$composition->teaser.' '.FormattedText::plain($composition->summary).' '.$composition->search_terms);
if ($term !== '' && ! str_contains($haystack, mb_strtolower($term))) { if ($term !== '' && ! str_contains($haystack, mb_strtolower($term))) {
continue; continue;
@@ -40,7 +41,7 @@ public function index(Request $request, ProductOptions $products, PublicCatalogR
$cards[] = [ $cards[] = [
'url' => route('public.program', $composition), 'url' => route('public.program', $composition),
'title' => $title, 'title' => $title,
'teaser' => (string) ($composition->teaser ?: $composition->summary), 'teaser' => (string) ($composition->teaser ?: FormattedText::plain($composition->summary)),
'from' => Money::format($summary['from_cents']), 'from' => Money::format($summary['from_cents']),
'count' => $summary['count'], 'count' => $summary['count'],
]; ];
+11 -3
View File
@@ -12,6 +12,7 @@
use App\Domain\Catalog\ContentElementVersion; use App\Domain\Catalog\ContentElementVersion;
use App\Domain\Catalog\EditorialProfileReader; use App\Domain\Catalog\EditorialProfileReader;
use App\Domain\Catalog\ExerciseGuide; use App\Domain\Catalog\ExerciseGuide;
use App\Domain\Catalog\FormattedText;
use App\Domain\Catalog\ReleaseStatus; use App\Domain\Catalog\ReleaseStatus;
use App\Domain\Catalog\StructureNode; use App\Domain\Catalog\StructureNode;
use App\Domain\Entitlement\DecideAccess; use App\Domain\Entitlement\DecideAccess;
@@ -125,7 +126,7 @@ public function index(User $user): array
'article' => $article, 'article' => $article,
'subject' => $subject, 'subject' => $subject,
'title' => $text['title'] ?? app(CourseOutline::class)->title($article), 'title' => $text['title'] ?? app(CourseOutline::class)->title($article),
'summary' => $text['summary'] ?? $element?->summary ?? $composition?->summary, 'summary' => $text['summary'] ?? FormattedText::plain($element?->summary ?? $composition?->summary) ?: null,
'kind' => app(CourseOutline::class)->kindLabel($article) ?? ($element === null ? null : $this->outputLabel($element->output_class)), 'kind' => app(CourseOutline::class)->kindLabel($article) ?? ($element === null ? null : $this->outputLabel($element->output_class)),
'coverage' => 'nutzbar', 'coverage' => 'nutzbar',
'image' => $imageUrl === null ? null : ($element->thumbnail_alt ?: ($text['title'] ?? $element->working_title)), 'image' => $imageUrl === null ? null : ($element->thumbnail_alt ?: ($text['title'] ?? $element->working_title)),
@@ -170,6 +171,8 @@ public function program(User $user, Composition $composition): array
'title' => $text['title'], 'title' => $text['title'],
'summary' => $text['summary'], 'summary' => $text['summary'],
'description' => $text['description'], 'description' => $text['description'],
'summary_html' => $text['summary_html'],
'description_html' => $text['description_html'],
'kind' => $composition->editorialContentKind?->label 'kind' => $composition->editorialContentKind?->label
?? ($composition->kind?->label()), ?? ($composition->kind?->label()),
'is_module' => $composition->editorialContentKind?->slug === 'modul', 'is_module' => $composition->editorialContentKind?->slug === 'modul',
@@ -209,7 +212,7 @@ public function content(User $user, Composition $composition, int $elementVersio
$node = $found['node']; $node = $found['node'];
$element = $node['element_id'] === null ? null : $this->element($node['element_id']); $element = $node['element_id'] === null ? null : $this->element($node['element_id']);
$text = $element === null ? ['title' => $node['title'], 'summary' => null, 'description' => null] : $this->text($element); $text = $element === null ? ['title' => $node['title'], 'summary' => null, 'description' => null, 'summary_html' => '', 'description_html' => ''] : $this->text($element);
$rootText = $this->text($composition); $rootText = $this->text($composition);
$trail = [['label' => $rootText['title'], 'url' => route('member.program', $composition)]]; $trail = [['label' => $rootText['title'], 'url' => route('member.program', $composition)]];
@@ -234,6 +237,8 @@ public function content(User $user, Composition $composition, int $elementVersio
'title' => $text['title'], 'title' => $text['title'],
'summary' => $text['summary'], 'summary' => $text['summary'],
'description' => $text['description'], 'description' => $text['description'],
'summary_html' => $text['summary_html'],
'description_html' => $text['description_html'],
'trail' => $trail, 'trail' => $trail,
'back' => $trail[array_key_last($trail)], 'back' => $trail[array_key_last($trail)],
'companions' => $companions, 'companions' => $companions,
@@ -245,7 +250,7 @@ public function content(User $user, Composition $composition, int $elementVersio
* Anzeigetitel und -texte für die Mitgliederbibliothek: Abweichung für „Mitgliederbibliothek“, sonst die zentrale Angabe, * Anzeigetitel und -texte für die Mitgliederbibliothek: Abweichung für „Mitgliederbibliothek“, sonst die zentrale Angabe,
* zuletzt die interne Bezeichnung. Nichts wird kopiert oder ergänzt. * zuletzt die interne Bezeichnung. Nichts wird kopiert oder ergänzt.
* *
* @return array{title: string, summary: ?string, description: ?string} * @return array{title: string, summary: ?string, description: ?string, summary_html: string, description_html: string}
*/ */
public function text(Model $subject): array public function text(Model $subject): array
{ {
@@ -261,6 +266,9 @@ public function text(Model $subject): array
'title' => $profile->value('display_title') ?? $profile->workingTitle ?? '', 'title' => $profile->value('display_title') ?? $profile->workingTitle ?? '',
'summary' => $profile->value('summary') ?? $profile->value('teaser'), 'summary' => $profile->value('summary') ?? $profile->value('teaser'),
'description' => $profile->value('description'), 'description' => $profile->value('description'),
// Formatierte Fassung für Seiten, die sie zeigen; sonst gilt der Klartext oben.
'summary_html' => $profile->html('summary') ?: ($profile->value('teaser') !== null ? '<p>'.e($profile->value('teaser')).'</p>' : ''),
'description_html' => $profile->html('description'),
]; ];
} }
+2
View File
@@ -4,6 +4,7 @@
use App\Domain\Cms\Widgets\Types\CardsWidget; use App\Domain\Cms\Widgets\Types\CardsWidget;
use App\Domain\Cms\Widgets\Types\CatalogCardsWidget; use App\Domain\Cms\Widgets\Types\CatalogCardsWidget;
use App\Domain\Cms\Widgets\Types\FaqWidget; use App\Domain\Cms\Widgets\Types\FaqWidget;
use App\Domain\Cms\Widgets\Types\FeaturesWidget;
use App\Domain\Cms\Widgets\Types\HeadingWidget; use App\Domain\Cms\Widgets\Types\HeadingWidget;
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;
@@ -26,6 +27,7 @@
ProseWidget::class, ProseWidget::class,
ImageTextWidget::class, ImageTextWidget::class,
CardsWidget::class, CardsWidget::class,
FeaturesWidget::class,
CatalogCardsWidget::class, CatalogCardsWidget::class,
TopicCardWidget::class, TopicCardWidget::class,
MediaCardWidget::class, MediaCardWidget::class,
+24
View File
@@ -0,0 +1,24 @@
<?php
/**
* Nur die abweichenden Werte; alles andere gilt wie im Paket (`vendor/livewire/livewire/config/livewire.php`).
*/
return [
/*
|---------------------------------------------------------------------------
| Payload Guards
|---------------------------------------------------------------------------
|
| Der Editor für formatierte Texte hält sein Dokument als verschachtelte Daten. Eine Aufzählung liegt dort elf Ebenen
| tief (rich.feld.content.1.content.1.content.0.content.0.text), verschachtelte Listen noch tiefer. Die Vorgabe von 10
| Ebenen lehnt solche Texte ab (ADR-50). Die übrigen Grenzen bleiben wie im Paket.
|
*/
'payload' => [
'max_size' => 1024 * 1024,
'max_nesting_depth' => 30,
'max_calls' => 50,
'max_components' => 200,
],
];
Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

@@ -36,6 +36,18 @@ ## 1a. Stand der Umsetzung Stufe 1 und 2 (Branch `feature/kleingrafiken-symbole-
- **Mitgliederbereich unverändert.** Das freigegebene Design (Kit 14) hat eigene Art-Marken (grüne Großbuchstaben mit Linien-Symbol, `x-member.type`). Die pastellfarbenen Tags würden davon abweichen; ob sie dort gewollt sind, ist deine Entscheidung. - **Mitgliederbereich unverändert.** Das freigegebene Design (Kit 14) hat eigene Art-Marken (grüne Großbuchstaben mit Linien-Symbol, `x-member.type`). Die pastellfarbenen Tags würden davon abweichen; ob sie dort gewollt sind, ist deine Entscheidung.
- **Katalogkarten (Programm/Modul) ohne Tag.** Es gibt keinen eindeutigen Schlüssel, und „Paket“ meint möglicherweise das Angebotspaket (Bundle) statt des Programms. „Film + Übungen“ und „Film + Merkblatt“ werden ebenfalls nicht automatisch vergeben. Die Komponente kann alle sechs Tags darstellen. - **Katalogkarten (Programm/Modul) ohne Tag.** Es gibt keinen eindeutigen Schlüssel, und „Paket“ meint möglicherweise das Angebotspaket (Bundle) statt des Programms. „Film + Übungen“ und „Film + Merkblatt“ werden ebenfalls nicht automatisch vergeben. Die Komponente kann alle sechs Tags darstellen.
## 1b. Stand der Umsetzung Stufe 3: Gestaltung im Redaktionsinhalt (Branch `feature/cms-symbole-merkmale`)
Die Tags auf den Medienkarten sind nur ein Nebenschauplatz. Der eigentliche Nutzen liegt im Text, deshalb gibt es jetzt:
- **Symbol vor der Überschrift** als Einstellung „Symbol vor der Überschrift“ (`settings.symbol`) an den Widgets Überschrift und Einleitung, Einstieg, Bild und Text und Handlungsaufruf. Auswahl: 14 Kleingrafiken (alle Symbole außer gelber Unterstreichung und Signalstrahlen), Vorgabe keines. Es sind nur feste Werte zulässig (ADR-30); ein unbekannter Name wird beim Speichern abgewiesen.
- **Pinselstrich** (`settings.accent` = `brush`) unter der Überschrift des Widgets Überschrift und Einleitung, mit dem freigegebenen Motiv „gelbe-unterstreichung“.
- **Merkmalszeile** (neues Widget `features`): zwei bis vier Merkmale mit Symbol, Kurztitel und einem Satz. Die Anzahl der Einträge bestimmt die Spalten; bei wenig Platz stehen sie untereinander.
- **Dunkle Flächen:** Die Symbole haben feste Markenfarben mit viel Marineblau. Auf `scope-dark`, `scope-accent`, dem Navy-Bild-und-Text und dem Navy-Einstieg stehen sie deshalb auf einer weißen Scheibe.
- **Beleg:** `16_Lara-Felix-Kleingrafiken/abnahme/cms-symbole-merkmale-breit.png` und `…-schmal.png` (lokal aus den echten Ansichten und dem gebauten Stylesheet gerendert). Die Prüfung im Editor und auf luf-test steht noch aus.
Nicht umgesetzt: Symbole mitten im Fließtext (Stufe 3b, braucht einen Symbol-Knopf im Editor) und die Lernbausteine im Player (Stufe 4).
## 2. Bestandsaufnahme der 32 Motive ## 2. Bestandsaufnahme der 32 Motive
Technische Prüfung der SVG-Dateien (belegt durch Auswertung der Dateien, nicht nur Sichtprüfung): Technische Prüfung der SVG-Dateien (belegt durch Auswertung der Dateien, nicht nur Sichtprüfung):
@@ -706,3 +706,24 @@ ## ADR-49 – Übungsverwaltung: Übung als Komposition mit Varianten, Medienspe
**Folgen.** Alle Migrationen sind additiv; der Rückfall setzt nur den Code zurück. Nach einem Rückfall werden Übungen im vorherigen Stand nicht bearbeitet oder veröffentlicht. Der Rückfallschutz (Teil 0) muss auf `main` liegen, bevor auf Prod die erste Übung entsteht. **Folgen.** Alle Migrationen sind additiv; der Rückfall setzt nur den Code zurück. Nach einem Rückfall werden Übungen im vorherigen Stand nicht bearbeitet oder veröffentlicht. Der Rückfallschutz (Teil 0) muss auf `main` liegen, bevor auf Prod die erste Übung entsteht.
**Nachtrag (23.11.2026): Zugangsschlüssel in der Verwaltung hinterlegen und ersetzen.** Der Zugangsschlüssel der Shinkan-Anbindung lässt sich auf der Seite „Übungen aus Shinkan“ hinterlegen, ersetzen und prüfen (nur Katalogverwalter und Systemverwalter), damit ein Wechsel keine Änderung der Serverdatei und keinen neuen Container braucht. Die **Adresse bleibt je Umgebung vorgegeben** (`SHINKAN_DISTRIBUTION_URL`). Rangfolge beim Schlüssel: Ein Schlüssel aus der Umgebung des Servers (`SHINKAN_DISTRIBUTION_KEY`) hat Vorrang und bleibt die bestehende Anbindung; fehlt er dort, gilt der in der Verwaltung hinterlegte. Der hinterlegte Schlüssel liegt je Umgebung getrennt mit dem Anwendungsschlüssel verschlüsselt in `site_settings`, wird nie an den Browser zurückgegeben, nie angezeigt, nie protokolliert und steht in keiner Fehlermeldung oder Adresse. Die Redaktion sieht nur den Zustand („hinterlegt“, Herkunft) und arbeitet mit der Anbindung. **Das nimmt genau diesen Schlüssel von der Regel „Geheimnisse nur in den Env-Dateien der Server“ aus** (angepasst in `CLAUDE.md`, „Server und Umgebungen“). Folge: Wer `APP_KEY` wechselt, muss den Schlüssel neu hinterlegen; ein Rückfall des Codes lässt die Einstellung unberührt. **Nachtrag (23.11.2026): Zugangsschlüssel in der Verwaltung hinterlegen und ersetzen.** Der Zugangsschlüssel der Shinkan-Anbindung lässt sich auf der Seite „Übungen aus Shinkan“ hinterlegen, ersetzen und prüfen (nur Katalogverwalter und Systemverwalter), damit ein Wechsel keine Änderung der Serverdatei und keinen neuen Container braucht. Die **Adresse bleibt je Umgebung vorgegeben** (`SHINKAN_DISTRIBUTION_URL`). Rangfolge beim Schlüssel: Ein Schlüssel aus der Umgebung des Servers (`SHINKAN_DISTRIBUTION_KEY`) hat Vorrang und bleibt die bestehende Anbindung; fehlt er dort, gilt der in der Verwaltung hinterlegte. Der hinterlegte Schlüssel liegt je Umgebung getrennt mit dem Anwendungsschlüssel verschlüsselt in `site_settings`, wird nie an den Browser zurückgegeben, nie angezeigt, nie protokolliert und steht in keiner Fehlermeldung oder Adresse. Die Redaktion sieht nur den Zustand („hinterlegt“, Herkunft) und arbeitet mit der Anbindung. **Das nimmt genau diesen Schlüssel von der Regel „Geheimnisse nur in den Env-Dateien der Server“ aus** (angepasst in `CLAUDE.md`, „Server und Umgebungen“). Folge: Wer `APP_KEY` wechselt, muss den Schlüssel neu hinterlegen; ein Rückfall des Codes lässt die Einstellung unberührt.
## ADR-50 – Formatierte Texte: bereinigtes HTML als einziges Format, ein Editor, eine kanonische Form
**Status:** umgesetzt, fachlich zu bestätigen. **Datum:** 23.11.2026. **Anlass:** Shinkan liefert Übungstexte jetzt als HTML (`text_format: html`); Lars verlangt für alle Textfelder Editoren mit Symbolleiste und visueller Darstellung.
**Entscheidung.**
- **Format.** Formatierte Texte werden als **bereinigtes HTML** aus einer festen Auswahl gespeichert: Absatz, Zwischenüberschrift (`h3`), fett, kursiv, Aufzählung, nummerierte Liste, Zitat, Link (http, https, mailto) und Zeilenumbruch. Alles andere fällt beim Speichern weg (Skripte, Ereignisattribute, andere Schemata, Bilder, Tabellen, Unterstreichung). Markdown wurde verworfen: Die Editoren arbeiten mit einem Dokumentmodell, das HTML-nah ist, die Quelle liefert HTML und das CMS speichert HTML bereits. Eine Umwandlung in beide Richtungen wäre verlustbehaftet.
- **Ein Baustein.** `App\Domain\Catalog\FormattedText` bereinigt, bringt Werte in die **kanonische Form**, wandelt Klartext des Altbestands und liefert Klartext, Auszug und Blöcke mit Auszeichnung (für das PDF). `App\Filament\Support\RichField` ist der eine Editor (Filament `RichEditor`, immer dieselbe Symbolleiste). Neue formatierte Felder nutzen ihn.
- **Kanonische Form.** Es wird nur in kanonischer Form verglichen, gehasht und gespeichert: Das Öffnen eines Felds im Editor, andere Schreibweise desselben Inhalts (`b`/`strong`, Zeilenumbrüche zwischen Blöcken, Listenpunkte mit oder ohne Absatz) und Klartext gegen HTML erzeugen weder „Geändert“-Markierungen noch neue Fassungen noch Scheinkonflikte beim Abgleich mit Shinkan. Lesbar und prüfbar ist das mit `FormattedText::same()`.
- **Erkennung statt Spalte.** Es gibt keine Formatspalte und keine Datenmigration. Ein Wert ist HTML, wenn er (nach Leerraum) mit einem Blockelement der Auswahl beginnt (`p`, `h3`, `ul`, `ol`, `blockquote`); gespeichertes HTML ist kanonisch und beginnt immer so. Klartext des Altbestands bleibt unverändert, bis jemand ihn ändert. Beim Anzeigen und Bearbeiten wird er nach den bekannten Konventionen (Leerzeile, „- “, „1. “, „## “) umgewandelt; Zeilenumbrüche an Stellen, die sie bisher zeigten, bleiben dort erhalten (`FormattedText::display`).
- **Arbeitsplätze.** Die Arbeitsplätze halten Texte als Zeichenketten; der Editor hält ein Dokument. `ManagesRichFields` verbindet beides: Die Zeichenkette ist maßgeblich, der Editor gleicht sich vor dem Rendern an, wenn der Server sie geändert hat, und schreibt beim Verlassen des Felds kanonisches HTML zurück. Beim Speichern einer Spalte bleibt ein inhaltlich unveränderter Altwert unverändert (`richStore`).
- **Formatiert sind:** Texte der Übungen und Textbausteine, Kurzbeschreibung und Beschreibung von Modulen, Programmen, Übungen, Medien und Lizenzartikeln, Lernziel und Ausstattung (Material) der Fassungen, Text einer Textfassung. **Klartext bleiben:** Titel, Teaser, Suchbegriffe, Variantenname und -beschreibung, interne Notizen, Lizenzvermerk, Änderungsnotizen, Voraussetzungen, Abweichungen je Zielgruppe.
- **Sichere Voreinstellung.** `EditorialProfile::value()` liefert für Kurzbeschreibung und Beschreibung **Klartext** (Karten, Listen, Suche, Zahlungsdienst, Meta-Angaben); wer formatiert zeigt, ruft `html()` auf. So gelangt keine Auszeichnung an eine Stelle, die kein HTML kennt.
- **Ausgabe.** Seiten geben das bereinigte HTML aus (nur nach `FormattedText::html()` oder `display()`, nie ungeprüft). Das PDF liest dieselben Blöcke und setzt fett und kursiv mit den Helvetica-Schnitten (neu: Oblique und Bold-Oblique, nur eingebunden, wenn das Dokument sie braucht; Belege bleiben byte-gleich). Links erscheinen auf Papier mit ausgeschriebener Adresse.
- **Shinkan.** Der Abruf wertet `text_format` aus. `html` gilt für Kurzbeschreibung, Lernziel, Durchführung, Vorbereitung, Trainerhinweise und die Abweichung der Durchführung einer Variante; ohne Angabe sind alle Texte Klartext wie bisher. Verweise auf Quellmedien im Text (`data-shinkan-exercise-media`) entfallen, weil keine Quellmedien übernommen werden. Vergleich und Dreiwegeabgleich arbeiten in kanonischer Form.
**Alternativen.** Markdown als Speicherformat (verworfen, siehe oben); Dokument-JSON des Editors (verworfen: Quelle und CMS liefern HTML, Hashes und Vergleiche wären an die Editorversion gebunden); Formatspalte je Feld (verworfen: Migration ohne Gewinn, die Erkennung ist eindeutig, weil gespeichertes HTML kanonisch ist).
**Folgen.** Keine Migration. **Rückfall:** Sobald jemand mit diesem Stand einen Text in Modul, Programm, Übung, Medium oder Lizenzartikel speichert, liegt dort HTML. Setzt man danach nur den Code zurück, zeigt der vorherige Stand diese Texte mit sichtbaren Tags (Karten, Bibliothek, Shop, Mitgliederansicht); Daten gehen nicht verloren, denn die alten Felder speichern die Zeichenkette unverändert, und der neue Stand liest sie wieder richtig. Das gilt für den ganzen Katalog, nicht nur für Übungen; es gehört in die Zusammenfassung für den Merge `develop` → `main`. **Suche:** Datenbanksuchen mit `LIKE` über diese Spalten (Auswahl im Aufbau, Medienliste) treffen auch Bezeichnungen wie `strong` oder `li` und verfehlen Text mit `&`, weil er als `&amp;` gespeichert ist. Die Suche in der Liste der Übungen und Module und im Shop vergleicht dagegen Klartext (`FormattedText::plain`). Die Datenbanksuchen bleiben eine bekannte Einschränkung. Die erste Übernahme mit HTML zählt für jeden Textabschnitt als Änderung der Quelle (die Formatierung kommt hinzu); wo ein Abschnitt lokal bearbeitet wurde, fragt die Vorschau nach. Das CMS nutzt weiter `RichText` (eigene Auswahl); die Umstellung auf denselben Baustein ist ein späterer Schritt.
**Quelle.** Anfragen von Lars vom 23.11.2026 (Formatierung der Übungstexte, Editoren für alle Textfelder); Shinkan-Commit „Deliver stored exercise HTML on the catalog API“.
+5
View File
@@ -75,6 +75,7 @@ ## 4. Registrierte Widget-Arten
| `prose` | Fließtext | 1 | `standard` | 1–4 | – | – | | `prose` | Fließtext | 1 | `standard` | 1–4 | – | – |
| `image_text` | Bild und Text, Premium nach Kit v1.6 | 3 | `image_left`, `image_right` (Bildseite) | 1–4 | `compact` (Kompakt), `normal` (Standard, Vorgabe), `spacious` (Großzügig) | `refs.image` | | `image_text` | Bild und Text, Premium nach Kit v1.6 | 3 | `image_left`, `image_right` (Bildseite) | 1–4 | `compact` (Kompakt), `normal` (Standard, Vorgabe), `spacious` (Großzügig) | `refs.image` |
| `cards` | Redaktionelle Karten | 1 | `standard` (Raster), `compact` (Liste), `featured` (erste Karte hervorgehoben) | 1–4 | – | Bild je Karte in `data.items[].image` | | `cards` | Redaktionelle Karten | 1 | `standard` (Raster), `compact` (Liste), `featured` (erste Karte hervorgehoben) | 1–4 | – | Bild je Karte in `data.items[].image` |
| `features` | Merkmalszeile (2–4 Merkmale mit Symbol, Kurztitel, Satz) | 1 | `standard` | 2–4 | – | – |
| `catalog_cards` | Programm- und Modulkarten | 1 | `standard`, `compact` | 1–4 | – | `refs.items[] = {type: composition, id}` | | `catalog_cards` | Programm- und Modulkarten | 1 | `standard`, `compact` | 1–4 | – | `refs.items[] = {type: composition, id}` |
| `topic_card` | Themenkarte, Premium-Karte nach Kit v1.7 | 1 | `adaptive`, `stacked` | 1–4 | `auto` (Vorgabe), `fill` | `refs.pillar`, `refs.image` | | `topic_card` | Themenkarte, Premium-Karte nach Kit v1.7 | 1 | `adaptive`, `stacked` | 1–4 | `auto` (Vorgabe), `fill` | `refs.pillar`, `refs.image` |
| `media_card` | Medien- und Materialkarte, Kit v1.7 | 1 | `adaptive`, `stacked` | 1–4 | `auto` (Vorgabe), `fill` | `refs.element`, `refs.image` | | `media_card` | Medien- und Materialkarte, Kit v1.7 | 1 | `adaptive`, `stacked` | 1–4 | `auto` (Vorgabe), `fill` | `refs.element`, `refs.image` |
@@ -97,6 +98,10 @@ ## 4. Registrierte Widget-Arten
| Überschriftenebene | `settings.heading_level` | `auto` (Vorgabe), `h2`, `h3`; das erste Widget der Seite ist immer H1 | | Überschriftenebene | `settings.heading_level` | `auto` (Vorgabe), `h2`, `h3`; das erste Widget der Seite ist immer H1 |
| Akzent (Einstieg) | `settings.accent` | `underline` (Vorgabe), `rays`, `none` | | Akzent (Einstieg) | `settings.accent` | `underline` (Vorgabe), `rays`, `none` |
| Fläche (Bild und Text) | `settings.surface` | `cream` (Vorgabe), `clear` (übernimmt den Abschnitt), `navy` | | Fläche (Bild und Text) | `settings.surface` | `cream` (Vorgabe), `clear` (übernimmt den Abschnitt), `navy` |
| Symbol vor der Überschrift | `settings.symbol` | Einstieg, Überschrift, Bild und Text, Handlungsaufruf. Feste Auswahl `App\Domain\Cms\Widgets\Support\HeadingAccent::SYMBOLS` (14 Kleingrafiken des Brand-Kits), Vorgabe keines. Zierde (`aria-hidden`); auf dunklen Flächen steht das Symbol auf einer weißen Scheibe |
| Pinselstrich (Überschrift) | `settings.accent` = `brush` | nur Widget „Überschrift und Einleitung“; Motiv „gelbe-unterstreichung“ des Kits |
**Merkmalszeile.** `data.items[]` mit `symbol` (Auswahl wie oben), `title` (höchstens 60 Zeichen) und optional `text` (höchstens 200 Zeichen); zwei bis vier Einträge. Die Spaltenzahl ergibt sich aus der Anzahl der Einträge und der tatsächlichen Breite (Raster ab 12 rem je Merkmal), nicht aus einer eigenen Einstellung.
| Höhe | `settings.height` | gemeinsamer Layoutvertrag (§12) | | Höhe | `settings.height` | gemeinsamer Layoutvertrag (§12) |
**Abweichungen vom Kit (bewusst):** **Abweichungen vom Kit (bewusst):**
@@ -35,8 +35,12 @@ ## 1. Felder, die der Katalog liefert und die Lara & Felix übernimmt
| Variante `sequence_order` | `variants[].sequence_order` | Position der Variante (Reihenfolge der Antwort) | Kundenansicht | | Variante `sequence_order` | `variants[].sequence_order` | Position der Variante (Reihenfolge der Antwort) | Kundenansicht |
| Medien `public_id`, `media_type`, `title`, `sort_order` | `media[]` | **Nur Quellenangabe**: gespeichert im Stand der Quelle, gezeigt in der Vorschau. Nie Medienausgabe, nie Teil eines Artikel-Stands | Übernahme (Vorschau) | | Medien `public_id`, `media_type`, `title`, `sort_order` | `media[]` | **Nur Quellenangabe**: gespeichert im Stand der Quelle, gezeigt in der Vorschau. Nie Medienausgabe, nie Teil eines Artikel-Stands | Übernahme (Vorschau) |
Klartext: Der Katalog liefert Texte als Klartext (`plaintext`). Absätze und Listen entstehen aus den Konventionen der Textformat: Der Katalog nennt das Format mit `text_format`. Bei `html` (Stand Shinkan vom 23.11.2026) sind Kurzbeschreibung,
Lernziel, Durchführung, Vorbereitung, Trainerhinweise und die Abweichung der Durchführung einer Variante bereinigtes HTML
(Absatz, Zwischenüberschrift, fett, kursiv, Listen, Link, Zeilenumbruch; ADR-50). Verweise auf Quellmedien im Text entfallen.
Titel, Variantenbeschreibung und Ausstattung bleiben Text. Fehlt die Angabe, sind alle Texte Klartext mit den Konventionen der
Anleitung (Leerzeilen, „- “, „1. “). Zeichen außerhalb von Windows-1252 erscheinen im PDF lesbar ersetzt, sonst als „?“. Anleitung (Leerzeilen, „- “, „1. “). Zeichen außerhalb von Windows-1252 erscheinen im PDF lesbar ersetzt, sonst als „?“.
Fixtures: `katalog-detail.json` (Klartext) und `katalog-detail-html.json` (HTML).
## 2. Verhalten beim Fassungswechsel ## 2. Verhalten beim Fassungswechsel
@@ -46,6 +50,7 @@ ## 2. Verhalten beim Fassungswechsel
| Titel | Gehört zur Übung, nicht zur Fassung. Er folgt der Quelle, **solange er lokal nicht geändert wurde**. Ein lokal geänderter Titel bleibt; die Vorschau nennt das. | | Titel | Gehört zur Übung, nicht zur Fassung. Er folgt der Quelle, **solange er lokal nicht geändert wurde**. Ein lokal geänderter Titel bleibt; die Vorschau nennt das. |
| Kurzbeschreibung | Wie der Titel. | | Kurzbeschreibung | Wie der Titel. |
| Varianten | Neu hinzugekommene und entfallene Varianten sowie Umbenennungen und Änderungen werden in der Vorschau genannt. Die **Reihenfolge** der neuen Fassung folgt der Quelle. Eine Änderung der Reihenfolge wird in der Vorschau genannt. | | Varianten | Neu hinzugekommene und entfallene Varianten sowie Umbenennungen und Änderungen werden in der Vorschau genannt. Die **Reihenfolge** der neuen Fassung folgt der Quelle. Eine Änderung der Reihenfolge wird in der Vorschau genannt. |
| Lokale Bearbeitung | Lokal bearbeitete Texte und Felder bleiben erhalten, solange die Quelle sie nicht ebenfalls geändert hat. Bei einer Änderung auf beiden Seiten entscheidet die Redaktion je Text oder Feld (lokale Fassung behalten oder Quellfassung übernehmen). Die bisherigen Fassungen bleiben immer unverändert. Lokal entfernte Quellabschnitte erscheinen mit der nächsten Übernahme wieder. |
| Lokale Ergänzung | Bleibt bei der neuen Fassung erhalten. Entfällt die Quellvariante, der sie zugeordnet ist, legt die Redaktion die neue Zuordnung ausdrücklich fest (gemeinsamer Teil oder eine Variante). Ohne diese Festlegung wird nichts übernommen. | | Lokale Ergänzung | Bleibt bei der neuen Fassung erhalten. Entfällt die Quellvariante, der sie zugeordnet ist, legt die Redaktion die neue Zuordnung ausdrücklich fest (gemeinsamer Teil oder eine Variante). Ohne diese Festlegung wird nichts übernommen. |
| Medienhinweise | Bleiben Quellenangabe. Ein geänderter Hinweis ändert keine lokale Fassung. | | Medienhinweise | Bleiben Quellenangabe. Ein geänderter Hinweis ändert keine lokale Fassung. |
@@ -77,7 +82,7 @@ ## 4. Lücken bei der Übernahme verfügbarer Felder
| `sequence_order` der Varianten | nicht als eigener Wert gespeichert, die Position folgt der Reihenfolge der Antwort | gleichwertig, solange der Katalog nach `sequence_order` sortiert liefert (`catalog_document` tut das) | | `sequence_order` der Varianten | nicht als eigener Wert gespeichert, die Position folgt der Reihenfolge der Antwort | gleichwertig, solange der Katalog nach `sequence_order` sortiert liefert (`catalog_document` tut das) |
| Variante ohne `execution_changes` | erzeugt keinen Abschnitt | gewollt; die Variante bleibt mit Name und Beschreibung sichtbar | | Variante ohne `execution_changes` | erzeugt keinen Abschnitt | gewollt; die Variante bleibt mit Name und Beschreibung sichtbar |
| Titel und Kurzbeschreibung | folgen der Quelle nur, solange sie lokal nicht geändert wurden | siehe Abschnitt 2 | | Titel und Kurzbeschreibung | folgen der Quelle nur, solange sie lokal nicht geändert wurden | siehe Abschnitt 2 |
| Abgleich mit lokalen Änderungen am Quelltext | Ein lokal bearbeiteter Quellabschnitt wird nicht erkannt, weil lokale Änderungen eine neue lokale Fassung mit eigenem Text sind und die Quellabschnitte unverändert bleiben | Bei der nächsten Übernahme gilt wieder der Quelltext, die Redaktion ergänzt lokal über eigene Bestandteile | | Lokal bearbeitete Quellangaben | Eine importierte Übung ist eine Übung wie jede andere und wird im selben Editor bearbeitet und als neue Fassung gespeichert. Bei der nächsten Übernahme bleiben lokal bearbeitete Texte und Felder (Lernziel, Dauer, Ausstattung) erhalten, solange die Quelle sie nicht ebenfalls geändert hat. Haben beide geändert, legt die Redaktion fest, ob die lokale oder die Quellfassung gilt. | Die Vorschau nennt „Lokal bearbeitet, bleibt erhalten“ und fragt bei einem Konflikt nach. |
## 5. Offene Entscheidungen ## 5. Offene Entscheidungen
@@ -0,0 +1,30 @@
# Abnahme: formatierte Texte (ADR-50)
Stand: 23.11.2026. **Geprüft lokal im Browser** (Arbeitsbaum, SQLite, Playwright), **nicht auf luf-test**. Die Prüfung auf luf-test steht nach dem Deployment aus.
## Was geprüft ist
| Nachweis | Befund |
|---|---|
| `formatierte-texte/01-editor-kurzbeschreibung.png` | Der Editor erscheint im Feld „Kurzbeschreibung“ der Redaktion mit Symbolleiste: fett, kursiv, Link, Zwischenüberschrift, Liste, nummerierte Liste, Zitat, Rückgängig, Wiederholen. Der Klartext des Altbestands steht im Editor; das Öffnen setzt weder die Markierung „Geändert“ noch „Ungespeicherte Änderungen“. |
| `02-anzeige-mit-liste.png` | Nach „Fertig“ steht der Text formatiert (fett, Liste mit Punkten). „Geändert“ erscheint erst nach der Eingabe; „Redaktion speichern“ legt kanonisches HTML ab (`<p>…<strong>fett</strong>…</p><ul><li><p>…</p></li></ul>`). |
| `03-lernziel-ausstattung.png` | Lernziel und Ausstattung (Material) sind im Aufbau formatierbar. Der Entwurf speichert HTML; bei geöffnetem Altbestand meldet der Arbeitsplatz keine ungespeicherten Änderungen. |
| `04-neuer-text.png` | Ein neuer Text entsteht im Dialog mit dem Editor und wird als HTML gespeichert; die Quelle des Textes ist im Reiter „Quelle“ ebenfalls im Editor bearbeitbar. |
| `05-mitgliederansicht-prosa.png` | Darstellung im Mitgliederbereich mit dem gebauten Stylesheet (Abschnitt „Durchführung“, Lernziel und Ausstattung): Absatz, Zwischenüberschrift, Listen mit Punkten und Nummern, Zitat, Link, fett und kursiv. Die Seite wurde als statisches Beispiel mit den echten Klassen und dem echten CSS gerendert, nicht mit einem Mitgliedskonto. |
Automatisch (Gate): Bereinigung und kanonische Form (`FormattedTextTest`), Anbindung des Editors an die Arbeitsplätze und Altbestand ohne Änderungsmarkierung (`FormatierteTexteEditorTest`), Mitgliederansicht und PDF mit fett und kursiv (`UebungAusgabeTest`), Übernahme aus Shinkan als HTML (`ShinkanUebernahmeTest`).
**Tastatur und Hilfstechnik (lokal):** „Bearbeiten“ per Enter setzt den Fokus in den Editor (`role=textbox`, Name = Bezeichnung des Felds, zum Beispiel „Ausführliche Beschreibung“). Escape schließt das Feld. Ein langer Text (80 Absätze, rund 37 KB) wird gespeichert, ohne die Grenze der Anfragegröße zu berühren.
## Gefundene und behobene Fehler
- Das Livewire-Limit für verschachtelte Pfade (10 Ebenen) lehnte Texte mit Aufzählung ab: `config/livewire.php` setzt 30. Der Test `test_a_list_and_a_nested_list_pass_the_payload_depth_guard` belegt es.
- Das Öffnen eines Altbestands meldete „Es gibt ungespeicherte Änderungen“, weil Klartext und HTML verglichen wurden. Der Vergleich arbeitet jetzt in kanonischer Form.
- Listenpunkte fehlten in der Anzeige (Stilrücksetzung), im Mitgliederbereich liefen Listen im Faktenblock inline. Die Stile stehen in `verwaltung/styles.blade.php` und `lf-member.css`.
## Offen
- Prüfung auf luf-test nach dem Deployment (breite **und schmale** Fenster, Tastatur im Editor). Schmale Fenster sind noch nirgends geprüft.
- Echter Abruf aus Shinkan mit HTML, sobald die produktive Quelle `text_format: html` liefert (nicht geprüft).
- Mitgliederansicht und PDF mit einem Testkonto auf luf-test (siehe `uebungen.md`).
- Nicht umgestellt: CMS-Texte (eigene Auswahl `RichText`), Abweichungen je Zielgruppe, Variantenbeschreibung.
Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

+73
View File
@@ -57,3 +57,76 @@ .brand-tag--paket {
--brand-tag-bg: var(--lf-tag-package-bg); --brand-tag-bg: var(--lf-tag-package-bg);
--brand-tag-ink: var(--lf-tag-package-ink); --brand-tag-ink: var(--lf-tag-package-ink);
} }
/*
* Gestaltung im Text (CMS): Symbol vor der Überschrift, Pinselstrich, Merkmalszeile.
* Die Symbole haben feste Markenfarben mit viel Navy; auf dunklen Flächen stehen sie deshalb auf einer weißen Scheibe,
* sonst verschwänden die Linien.
*/
.lf-heading-symbol {
display: inline-block;
inline-size: 1.2em;
block-size: 1.2em;
margin-inline-end: 0.35em;
vertical-align: -0.2em;
overflow: visible;
}
.lf-heading-brush {
display: block;
inline-size: 7rem;
max-inline-size: 60%;
block-size: auto;
margin-block: 0.2rem var(--space-2);
}
.scope-dark .lf-heading-symbol,
.scope-accent .lf-heading-symbol,
.lf-bt--navy .lf-heading-symbol,
.lf-hero--editorial-solid .lf-heading-symbol,
.scope-dark .lf-features__symbol,
.scope-accent .lf-features__symbol {
box-sizing: content-box;
padding: 0.14em;
border-radius: 50%;
background: var(--lf-white);
}
.lf-features {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
gap: var(--space-5) var(--space-4);
margin: 0;
padding: 0;
list-style: none;
}
.lf-features__item {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: var(--space-2);
min-inline-size: 0;
}
.lf-features__symbol {
inline-size: 3.5rem;
block-size: 3.5rem;
flex: none;
overflow: visible;
}
.lf-features__title {
margin: 0;
color: var(--color-heading);
font-size: var(--text-h3);
font-weight: 700;
line-height: 1.25;
overflow-wrap: anywhere;
}
.lf-features__text {
margin: 0;
max-inline-size: var(--measure);
overflow-wrap: anywhere;
}
+79
View File
@@ -1014,6 +1014,37 @@ .mb-facts svg {
height: 1.1rem; height: 1.1rem;
} }
/* Angaben einer Übung (Lernziel, Dauer, Ausstattung): Bezeichnung und formatierter Text untereinander */
.mb-exercise .mb-facts {
display: grid;
align-items: start;
gap: var(--space-3);
margin-block: var(--space-4);
font-size: var(--text-body);
font-weight: 400;
}
.mb-exercise .mb-facts > div {
display: grid;
gap: var(--space-1);
}
.mb-exercise .mb-facts dt {
font-size: var(--text-small);
font-weight: 700;
}
.mb-exercise .mb-facts dd {
margin: 0;
}
@media (min-width: 40rem) {
.mb-exercise .mb-facts > div {
grid-template-columns: 9rem minmax(0, 1fr);
gap: var(--space-3);
}
}
.mb-note { .mb-note {
padding: var(--space-2) var(--space-3); padding: var(--space-2) var(--space-3);
border-left: 4px solid currentColor; border-left: 4px solid currentColor;
@@ -1100,6 +1131,54 @@ .mb-prose > :last-child {
margin-bottom: 0; margin-bottom: 0;
} }
/* Formatierte Texte (ADR-50): Absatz, Zwischenüberschrift, Listen, Zitat, Link */
.mb-prose p {
margin: 0 0 var(--space-3);
}
.mb-prose h3 {
margin: var(--space-4) 0 var(--space-2);
font-size: var(--text-body);
}
.mb-prose ul,
.mb-prose ol {
margin: 0 0 var(--space-3);
padding-left: 1.4rem;
}
.mb-prose ul {
list-style: disc;
}
.mb-prose ol {
list-style: decimal;
}
.mb-prose li {
display: list-item;
}
.mb-prose li > p {
margin: 0 0 var(--space-1);
}
.mb-prose a {
color: var(--lf-green-deep);
text-decoration: underline;
text-underline-offset: 0.15em;
}
.mb-prose blockquote {
margin: 0 0 var(--space-3);
padding-left: var(--space-3);
border-left: 3px solid var(--color-accent);
}
.mb-prose blockquote > p {
margin-bottom: var(--space-2);
}
.mb-reading { .mb-reading {
max-width: var(--measure); max-width: var(--measure);
padding: var(--pad-card); padding: var(--pad-card);
@@ -0,0 +1,2 @@
@props(['settings' => []])
@if (\App\Domain\Cms\Widgets\Support\HeadingAccent::hasBrush(is_array($settings) ? $settings : []))<x-brand.symbol name="gelbe-unterstreichung" class="lf-heading-brush" />@endif
@@ -0,0 +1 @@
@props(['settings' => []])@php($symbol = \App\Domain\Cms\Widgets\Support\HeadingAccent::symbol(is_array($settings) ? $settings : []))@if ($symbol !== null)<x-brand.symbol :name="$symbol" class="lf-heading-symbol" />@endif
@@ -1,7 +1 @@
{{-- @props(['name']){!! \App\Support\Brand\Symbols::symbol($name, $attributes->class(['brand-symbol'])->toHtml()) !!}
Markensymbol aus dem Kit (resources/svg/brand/symbole), inline und rein dekorativ (aria-hidden).
Die Größe wird per Klasse oder Style gesetzt (Standard: 1.5em). Beispiel: <x-brand.symbol name="filmklappe" />.
Ein unbekannter Name wirft einen Fehler.
--}}
@props(['name'])
{!! \App\Support\Brand\Symbols::symbol($name, $attributes->class(['brand-symbol'])->toHtml()) !!}
+1 -1
View File
@@ -27,6 +27,6 @@
@if (filled($version->body)) @if (filled($version->body))
<article class="prose"> <article class="prose">
{!! nl2br(e($version->body)) !!} {!! \App\Domain\Catalog\FormattedText::display($version->body) !!}
</article> </article>
@endif @endif
@@ -145,9 +145,10 @@
<label class="vw-feldlabel">Titel <label class="vw-feldlabel">Titel
<input id="text-titel" class="vw-eingabe" type="text" wire:model="newTextTitle" required autofocus> <input id="text-titel" class="vw-eingabe" type="text" wire:model="newTextTitle" required autofocus>
</label> </label>
<label class="vw-feldlabel">Inhalt <div class="vw-feldlabel" role="group" aria-labelledby="text-inhalt-neu-label">
<textarea id="text-inhalt" class="vw-eingabe" rows="8" wire:model="newTextBody" required></textarea> <span id="text-inhalt-neu-label">Inhalt</span>
</label> <div class="vw-rich-eingabe">{{ $this->richKomponente('newTextBody') }}</div>
</div>
</div> </div>
<div class="vw-dialog-fuss"> <div class="vw-dialog-fuss">
<div class="vw-dialog-fuss-zeile"> <div class="vw-dialog-fuss-zeile">
@@ -34,22 +34,22 @@
@endif @endif
<h1>{{ $title }}</h1> <h1>{{ $title }}</h1>
@if (filled($summary)) @if (filled($summary))
<p>{{ $summary }}</p> <div>{!! \App\Domain\Catalog\FormattedText::display($summary) !!}</div>
@endif @endif
@if (filled($description ?? null)) @if (filled($description ?? null))
<h2>Beschreibung</h2> <h2>Beschreibung</h2>
<p>{{ $description }}</p> <div>{!! \App\Domain\Catalog\FormattedText::display($description) !!}</div>
@endif @endif
@if (filled($learningGoal)) @if (filled($learningGoal))
<h2>Lernziel</h2> <h2>Lernziel</h2>
<p>{{ $learningGoal }}</p> <div>{!! \App\Domain\Catalog\FormattedText::display($learningGoal) !!}</div>
@endif @endif
@if ($durationMinutes) @if ($durationMinutes)
<p>Zeit: {{ $durationMinutes }} Minuten</p> <p>Zeit: {{ $durationMinutes }} Minuten</p>
@endif @endif
@if (filled($materialNote)) @if (filled($materialNote))
<h2>Material</h2> <h2>Material</h2>
<p>{{ $materialNote }}</p> <div>{!! \App\Domain\Catalog\FormattedText::display($materialNote) !!}</div>
@endif @endif
<h2>Aufbau</h2> <h2>Aufbau</h2>
@include('filament.editorial.preview-nodes', ['nodes' => $nodes]) @include('filament.editorial.preview-nodes', ['nodes' => $nodes])
@@ -177,8 +177,8 @@
<div class="vw-detail-inhalt"> <div class="vw-detail-inhalt">
@if ($canEditBody) @if ($canEditBody)
<label class="vw-feldlabel" for="fassung-text">Text der Fassung</label> <span class="vw-feldlabel" id="fassung-text-label">Text der Fassung</span>
<textarea id="fassung-text" class="vw-eingabe" rows="14" wire:model.live.blur="bodyDraft"></textarea> <div id="fassung-text" class="vw-rich-eingabe">{{ $this->richKomponente('bodyDraft') }}</div>
<p class="vw-feld-hilfe"> <p class="vw-feld-hilfe">
@if ($bodyCommitted) @if ($bodyCommitted)
Fassung {{ $shown->number }} ist freigegeben und wird verwendet. Sie bleibt unverändert, „Text speichern“ legt Fassung {{ $naechste }} an. Fassung {{ $shown->number }} ist freigegeben und wird verwendet. Sie bleibt unverändert, „Text speichern“ legt Fassung {{ $naechste }} an.
@@ -129,6 +129,19 @@
<h4 class="vw-abschnitt-titel">Medienhinweise der Quelle</h4> <h4 class="vw-abschnitt-titel">Medienhinweise der Quelle</h4>
<p class="vw-feld-hilfe">Quellenangaben ohne Datei. Sie werden nicht ausgeliefert und begründen keine Nutzungsberechtigung: {{ implode(', ', $eintrag['media']) }}</p> <p class="vw-feld-hilfe">Quellenangaben ohne Datei. Sie werden nicht ausgeliefert und begründen keine Nutzungsberechtigung: {{ implode(', ', $eintrag['media']) }}</p>
@endif @endif
@if ($eintrag['kept_local'] !== [])
<p class="vw-band"><span><strong>Lokal bearbeitet, bleibt erhalten:</strong> {{ implode(', ', $eintrag['kept_local']) }}. Die Quelle hat diese Angaben nicht geändert.</span></p>
@endif
@foreach ($eintrag['text_conflicts'] as $konflikt)
<label class="vw-feldlabel">{{ $konflikt['label'] }}: lokal und in der Quelle geändert
<select class="vw-eingabe" wire:model.live="textChoice.{{ $eintrag['source'] }}.{{ $konflikt['key'] }}">
<option value="offen">Bitte festlegen …</option>
<option value="lokal">Lokale Fassung behalten</option>
<option value="quelle">Quellfassung übernehmen (die lokale Änderung entfällt in der neuen Fassung)</option>
</select>
<span class="vw-feld-hilfe">Die bisherigen Fassungen bleiben unverändert erhalten.</span>
</label>
@endforeach
@foreach ($eintrag['conflicts'] as $konflikt) @foreach ($eintrag['conflicts'] as $konflikt)
<label class="vw-feldlabel">Neue Zuordnung für lokale Ergänzung ({{ implode(', ', $konflikt['members']) }}) <label class="vw-feldlabel">Neue Zuordnung für lokale Ergänzung ({{ implode(', ', $konflikt['members']) }})
<select class="vw-eingabe" wire:model.live="reassign.{{ $eintrag['source'] }}.{{ $konflikt['key'] }}"> <select class="vw-eingabe" wire:model.live="reassign.{{ $eintrag['source'] }}.{{ $konflikt['key'] }}">
@@ -8,9 +8,10 @@
<section class="vw-medien-haupt" aria-labelledby="didaktik-titel"> <section class="vw-medien-haupt" aria-labelledby="didaktik-titel">
<h2 id="didaktik-titel" class="vw-abschnitt-titel">Didaktik</h2> <h2 id="didaktik-titel" class="vw-abschnitt-titel">Didaktik</h2>
<p class="vw-feld-hilfe">Lernziel, Zeit und Material gehören zum fachlichen Stand {{ $ort }}. Sie werden mit „Entwurf speichern“ gesichert und erst mit „Fassung freigeben“ Teil einer neuen Fassung.</p> <p class="vw-feld-hilfe">Lernziel, Zeit und Material gehören zum fachlichen Stand {{ $ort }}. Sie werden mit „Entwurf speichern“ gesichert und erst mit „Fassung freigeben“ Teil einer neuen Fassung.</p>
<label class="vw-feldlabel">Lernziel <div class="vw-feldlabel" role="group" aria-labelledby="lernziel-label">
<textarea class="vw-eingabe" rows="4" wire:model.live.blur="learningGoal"></textarea> <span id="lernziel-label">Lernziel</span>
</label> <div class="vw-rich-eingabe">{{ $this->richKomponente('learningGoal') }}</div>
</div>
<div class="vw-raster-2"> <div class="vw-raster-2">
<label class="vw-feldlabel">Zeitbedarf in Minuten <label class="vw-feldlabel">Zeitbedarf in Minuten
<input class="vw-eingabe" type="text" inputmode="numeric" wire:model.live.blur="durationMinutes"> <input class="vw-eingabe" type="text" inputmode="numeric" wire:model.live.blur="durationMinutes">
@@ -19,9 +20,10 @@
<input class="vw-eingabe" type="text" wire:model.live.blur="revisionNote"> <input class="vw-eingabe" type="text" wire:model.live.blur="revisionNote">
</label> </label>
</div> </div>
<label class="vw-feldlabel">{{ $this->isExercise() ? 'Ausstattung' : 'Materialbedarf' }} <div class="vw-feldlabel" role="group" aria-labelledby="material-label">
<textarea class="vw-eingabe" rows="3" wire:model.live.blur="materialNote"></textarea> <span id="material-label">{{ $this->isExercise() ? 'Ausstattung' : 'Materialbedarf' }}</span>
</label> <div class="vw-rich-eingabe">{{ $this->richKomponente('materialNote') }}</div>
</div>
@if ($this->isExercise()) @if ($this->isExercise())
<div class="vw-raster-2"> <div class="vw-raster-2">
<label class="vw-feldlabel">Zeitbedarf bis (Minuten) <label class="vw-feldlabel">Zeitbedarf bis (Minuten)
@@ -147,9 +147,10 @@
<label class="vw-feldlabel">Titel <label class="vw-feldlabel">Titel
<input class="vw-eingabe" type="text" wire:model="partTitle"> <input class="vw-eingabe" type="text" wire:model="partTitle">
</label> </label>
<label class="vw-feldlabel">Inhalt <div class="vw-feldlabel" role="group" aria-labelledby="text-inhalt-label">
<textarea class="vw-eingabe" rows="8" wire:model="partBody"></textarea> <span id="text-inhalt-label">Inhalt</span>
</label> <div class="vw-rich-eingabe">{{ $this->richKomponente('partBody') }}</div>
</div>
<p class="vw-feld-hilfe"> <p class="vw-feld-hilfe">
@if (! empty($gewaehlt['committed'])) @if (! empty($gewaehlt['committed']))
Diese Fassung ist freigegeben und wird verwendet. Speichern legt eine neue Fassung an; die bisherige bleibt in den freigegebenen Aufbauten. Diese Fassung ist freigegeben und wird verwendet. Speichern legt eine neue Fassung an; die bisherige bleibt in den freigegebenen Aufbauten.
@@ -167,6 +167,18 @@
.vw-feld-kopf .vw-feld-aktion { margin-left: auto; } .vw-feld-kopf .vw-feld-aktion { margin-left: auto; }
.vw-feld-wert { white-space: pre-line; overflow-wrap: anywhere; } .vw-feld-wert { white-space: pre-line; overflow-wrap: anywhere; }
.vw-feld-wert.is-uebernommen { color: var(--vw-quiet); } .vw-feld-wert.is-uebernommen { color: var(--vw-quiet); }
/* Formatierte Texte (ADR-50): Anzeige und Editor */
.vw-feld-wert.vw-rich { white-space: normal; }
.vw-rich p { margin: 0 0 0.5rem; }
.vw-rich h3 { margin: 0.75rem 0 0.35rem; font-size: 1rem; }
.vw-rich ul, .vw-rich ol { margin: 0 0 0.5rem; padding-left: 1.4rem; }
.vw-rich ul { list-style: disc; }
.vw-rich ol { list-style: decimal; }
.vw-rich li > p { margin: 0 0 0.2rem; }
.vw-rich blockquote { margin: 0 0 0.5rem; padding-left: 0.8rem; border-left: 3px solid var(--vw-line, #d5ddd6); }
.vw-rich > :last-child { margin-bottom: 0; }
.vw-rich-eingabe { display: block; margin-top: 0.3rem; font-weight: 400; }
.vw-rich-eingabe .fi-fo-rich-editor { min-width: 0; }
.vw-feld-wert.is-leer { color: var(--vw-muted); font-style: italic; } .vw-feld-wert.is-leer { color: var(--vw-muted); font-style: italic; }
.vw-feld-wert.is-kurz:not(.is-voll) { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; } .vw-feld-wert.is-kurz:not(.is-voll) { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.vw-feld-edit { display: grid; gap: 0.45rem; } .vw-feld-edit { display: grid; gap: 0.45rem; }
@@ -6,8 +6,9 @@
$uebernommen = $wert === '' && $quelleWert !== ''; $uebernommen = $wert === '' && $quelleWert !== '';
$geaendert = $this->feldGeaendert($feld); $geaendert = $this->feldGeaendert($feld);
$fehler = $this->redaktionFehlerFeld === $model; $fehler = $this->redaktionFehlerFeld === $model;
$lang = mb_strlen($uebernommen ? $quelleWert : $wert) > 220;
$kind = $feld['kind'] ?? 'text'; $kind = $feld['kind'] ?? 'text';
$rich = $kind === 'rich';
$lang = mb_strlen($rich ? \App\Domain\Catalog\FormattedText::plain($uebernommen ? $quelleWert : $wert) : ($uebernommen ? $quelleWert : $wert)) > 220;
$id = 'feld-'.$feld['id']; $id = 'feld-'.$feld['id'];
@endphp @endphp
<section @class(['vw-feld', 'is-fehler' => $fehler]) wire:key="feld-{{ $feld['id'] }}" x-data="{ offen: @js($fehler), voll: false }"> <section @class(['vw-feld', 'is-fehler' => $fehler]) wire:key="feld-{{ $feld['id'] }}" x-data="{ offen: @js($fehler), voll: false }">
@@ -24,7 +25,7 @@
<span class="vw-kapsel is-geaendert">Geändert</span> <span class="vw-kapsel is-geaendert">Geändert</span>
@endif @endif
@if ($editable) @if ($editable)
<button type="button" class="vw-link vw-feld-aktion" x-on:click="offen = ! offen; if (offen) $nextTick(() => $refs.eingabe.focus())" x-bind:aria-expanded="offen" aria-controls="{{ $id }}"> <button type="button" class="vw-link vw-feld-aktion" x-on:click="offen = ! offen; if (offen) $nextTick(() => ($refs.eingabe.matches('input, textarea') ? $refs.eingabe : $refs.eingabe.querySelector('[contenteditable=true]') ?? $refs.eingabe).focus())" x-bind:aria-expanded="offen" aria-controls="{{ $id }}">
<span x-show="! offen">@include('filament.verwaltung.icon', ['name' => 'stift'])</span> <span x-show="! offen">@include('filament.verwaltung.icon', ['name' => 'stift'])</span>
<span x-text="offen ? 'Fertig' : '{{ $uebernommen || $wert === '' ? ($quelleTitel !== null ? 'Eigene Angabe' : 'Ergänzen') : 'Bearbeiten' }}'">Bearbeiten</span> <span x-text="offen ? 'Fertig' : '{{ $uebernommen || $wert === '' ? ($quelleTitel !== null ? 'Eigene Angabe' : 'Ergänzen') : 'Bearbeiten' }}'">Bearbeiten</span>
</button> </button>
@@ -34,8 +35,12 @@
<div x-show="! offen"> <div x-show="! offen">
@if ($wert === '' && ! $uebernommen) @if ($wert === '' && ! $uebernommen)
<p class="vw-feld-wert is-leer">Keine Angabe</p> <p class="vw-feld-wert is-leer">Keine Angabe</p>
@else
@if ($rich)
<div @class(['vw-feld-wert', 'vw-rich', 'is-uebernommen' => $uebernommen, 'is-kurz' => $lang]) x-bind:class="{ 'is-voll': voll }">{!! \App\Domain\Catalog\FormattedText::html($uebernommen ? $quelleWert : $wert) !!}</div>
@else @else
<p @class(['vw-feld-wert', 'is-uebernommen' => $uebernommen, 'is-kurz' => $lang]) x-bind:class="{ 'is-voll': voll }">{{ $uebernommen ? $quelleWert : $wert }}</p> <p @class(['vw-feld-wert', 'is-uebernommen' => $uebernommen, 'is-kurz' => $lang]) x-bind:class="{ 'is-voll': voll }">{{ $uebernommen ? $quelleWert : $wert }}</p>
@endif
@if ($lang) @if ($lang)
<button type="button" class="vw-link is-quiet" x-on:click="voll = ! voll" x-text="voll ? 'Weniger anzeigen' : 'Ganzen Text anzeigen'">Ganzen Text anzeigen</button> <button type="button" class="vw-link is-quiet" x-on:click="voll = ! voll" x-text="voll ? 'Weniger anzeigen' : 'Ganzen Text anzeigen'">Ganzen Text anzeigen</button>
@endif @endif
@@ -44,8 +49,12 @@
@if ($editable) @if ($editable)
<div class="vw-feld-edit" id="{{ $id }}" x-show="offen" x-cloak> <div class="vw-feld-edit" id="{{ $id }}" x-show="offen" x-cloak>
@unless ($rich)
<label class="vw-sr" for="{{ $id }}-eingabe">{{ $feld['label'] }}</label> <label class="vw-sr" for="{{ $id }}-eingabe">{{ $feld['label'] }}</label>
@if ($kind === 'textarea') @endunless
@if ($rich)
<div id="{{ $id }}-eingabe" x-ref="eingabe" class="vw-rich-eingabe" role="group" aria-labelledby="{{ $id }}-titel" x-on:keydown.escape.stop="offen = false">{{ $this->richKomponente($model) }}</div>
@elseif ($kind === 'textarea')
<textarea id="{{ $id }}-eingabe" x-ref="eingabe" rows="{{ $feld['rows'] ?? 4 }}" wire:model.live.blur="{{ $model }}" placeholder="{{ $uebernommen || $wert === '' ? ($quelleWert !== '' ? $quelleWert : ($feld['placeholder'] ?? '')) : ($feld['placeholder'] ?? '') }}" @if ($fehler) aria-invalid="true" aria-describedby="{{ $id }}-fehler" @endif x-on:keydown.escape.stop="offen = false"></textarea> <textarea id="{{ $id }}-eingabe" x-ref="eingabe" rows="{{ $feld['rows'] ?? 4 }}" wire:model.live.blur="{{ $model }}" placeholder="{{ $uebernommen || $wert === '' ? ($quelleWert !== '' ? $quelleWert : ($feld['placeholder'] ?? '')) : ($feld['placeholder'] ?? '') }}" @if ($fehler) aria-invalid="true" aria-describedby="{{ $id }}-fehler" @endif x-on:keydown.escape.stop="offen = false"></textarea>
@else @else
<input id="{{ $id }}-eingabe" x-ref="eingabe" type="text" wire:model.live.blur="{{ $model }}" placeholder="{{ $uebernommen || $wert === '' ? ($quelleWert !== '' ? $quelleWert : ($feld['placeholder'] ?? '')) : ($feld['placeholder'] ?? '') }}" @if ($fehler) aria-invalid="true" aria-describedby="{{ $id }}-fehler" @endif x-on:keydown.escape.stop="offen = false" x-on:keydown.enter.prevent="$el.blur(); offen = false"> <input id="{{ $id }}-eingabe" x-ref="eingabe" type="text" wire:model.live.blur="{{ $model }}" placeholder="{{ $uebernommen || $wert === '' ? ($quelleWert !== '' ? $quelleWert : ($feld['placeholder'] ?? '')) : ($feld['placeholder'] ?? '') }}" @if ($fehler) aria-invalid="true" aria-describedby="{{ $id }}-fehler" @endif x-on:keydown.escape.stop="offen = false" x-on:keydown.enter.prevent="$el.blur(); offen = false">
+2 -2
View File
@@ -27,7 +27,7 @@
<div class="mb-outline-main"> <div class="mb-outline-main">
<h2 class="mb-outline-title">{{ $entry['title'] === $entry['role'] ? $entry['title'] : $entry['role'].': '.$entry['title'] }}</h2> <h2 class="mb-outline-title">{{ $entry['title'] === $entry['role'] ? $entry['title'] : $entry['role'].': '.$entry['title'] }}</h2>
@if (filled($entry['version']->element->description)) @if (filled($entry['version']->element->description))
<p class="mb-outline-text">{{ $entry['version']->element->description }}</p> <div class="mb-outline-text mb-prose">{!! \App\Domain\Catalog\FormattedText::display($entry['version']->element->description) !!}</div>
@endif @endif
</div> </div>
@if ($entry['playable']) @if ($entry['playable'])
@@ -60,7 +60,7 @@
@endif @endif
@if (filled($entry['version']->body)) @if (filled($entry['version']->body))
<article class="mb-prose"> <article class="mb-prose">
{!! nl2br(e($entry['version']->body)) !!} {!! \App\Domain\Catalog\FormattedText::display($entry['version']->body) !!}
</article> </article>
@endif @endif
</li> </li>
+5 -5
View File
@@ -78,14 +78,14 @@
</div> </div>
<aside class="mb-content-side"> <aside class="mb-content-side">
@if (filled($summary) || filled($description)) @if (filled($summary_html) || filled($description_html))
<section class="mb-side-card" aria-labelledby="kurz"> <section class="mb-side-card" aria-labelledby="kurz">
<h2 id="kurz">Kurzbeschreibung</h2> <h2 id="kurz">Kurzbeschreibung</h2>
@if (filled($summary)) @if (filled($summary_html))
<p>{{ $summary }}</p> <div class="mb-prose">{!! $summary_html !!}</div>
@endif @endif
@if (filled($description)) @if (filled($description_html))
<div class="mb-prose">{!! nl2br(e($description)) !!}</div> <div class="mb-prose">{!! $description_html !!}</div>
@endif @endif
</section> </section>
@endif @endif
+5 -5
View File
@@ -13,8 +13,8 @@
<article class="mb-reading mb-exercise"> <article class="mb-reading mb-exercise">
<header class="mb-content-head"> <header class="mb-content-head">
<h1 class="mb-title">{{ $guide['title'] }}</h1> <h1 class="mb-title">{{ $guide['title'] }}</h1>
@if (filled($guide['summary'])) @if (filled($guide['summary_html']))
<p class="mb-lead">{{ $guide['summary'] }}</p> <div class="mb-lead mb-prose">{!! $guide['summary_html'] !!}</div>
@endif @endif
</header> </header>
@@ -24,7 +24,7 @@
<dl class="mb-facts"> <dl class="mb-facts">
@if (filled($guide['learning_goal'])) @if (filled($guide['learning_goal']))
<div><dt>Lernziel</dt><dd>{{ $guide['learning_goal'] }}</dd></div> <div><dt>Lernziel</dt><dd class="mb-prose">{!! \App\Domain\Catalog\FormattedText::display($guide['learning_goal']) !!}</dd></div>
@endif @endif
@if ($guide['duration_minutes'] !== null) @if ($guide['duration_minutes'] !== null)
<div><dt>Dauer</dt><dd>{{ $guide['duration_minutes'] }}@if ($guide['duration_max'] !== null) bis {{ $guide['duration_max'] }}@endif Minuten</dd></div> <div><dt>Dauer</dt><dd>{{ $guide['duration_minutes'] }}@if ($guide['duration_max'] !== null) bis {{ $guide['duration_max'] }}@endif Minuten</dd></div>
@@ -33,7 +33,7 @@
<div><dt>Voraussetzungen</dt><dd>{{ $guide['prerequisites'] }}</dd></div> <div><dt>Voraussetzungen</dt><dd>{{ $guide['prerequisites'] }}</dd></div>
@endif @endif
@if (filled($guide['material_note'])) @if (filled($guide['material_note']))
<div><dt>Ausstattung</dt><dd>{{ $guide['material_note'] }}</dd></div> <div><dt>Ausstattung</dt><dd class="mb-prose">{!! \App\Domain\Catalog\FormattedText::display($guide['material_note']) !!}</dd></div>
@endif @endif
</dl> </dl>
@@ -71,7 +71,7 @@
@if ($entry['allowed'] && $entry['class'] === 'text') @if ($entry['allowed'] && $entry['class'] === 'text')
<h2>{{ $entry['title'] }}</h2> <h2>{{ $entry['title'] }}</h2>
<div class="mb-prose"> <div class="mb-prose">
@include('member.partials.guide-blocks', ['blocks' => $entry['blocks']]) {!! $entry['html'] !!}
</div> </div>
@elseif ($entry['allowed']) @elseif ($entry['allowed'])
<h2>{{ $entry['title'] }}</h2> <h2>{{ $entry['title'] }}</h2>
@@ -1,23 +0,0 @@
@foreach ($blocks as $block)
@switch ($block['type'])
@case ('heading')
<h3>{{ $block['text'] }}</h3>
@break
@case ('bullets')
<ul>
@foreach ($block['items'] as $item)
<li>{{ $item }}</li>
@endforeach
</ul>
@break
@case ('numbered')
<ol>
@foreach ($block['items'] as $item)
<li>{{ $item }}</li>
@endforeach
</ol>
@break
@default
<p>{{ $block['text'] }}</p>
@endswitch
@endforeach
+8 -8
View File
@@ -10,7 +10,7 @@
--}} --}}
@section('content') @section('content')
@php @php
$hasOverview = filled($description) || filled($learning_goal); $hasOverview = filled($description_html) || filled($learning_goal);
$hasUse = filled($material_note); $hasUse = filled($material_note);
$facts = []; $facts = [];
if ($module_count > 0) { if ($module_count > 0) {
@@ -40,8 +40,8 @@
<div class="mb-detail-copy"> <div class="mb-detail-copy">
<x-member.type :type="$is_module ? 'modul' : 'programm'" :label="$kind" /> <x-member.type :type="$is_module ? 'modul' : 'programm'" :label="$kind" />
<h1 class="mb-title">{{ $title }} <x-brand.underline class="mb-title-line" /></h1> <h1 class="mb-title">{{ $title }} <x-brand.underline class="mb-title-line" /></h1>
@if (filled($summary)) @if (filled($summary_html))
<p class="mb-lede">{{ $summary }}</p> <div class="mb-lede mb-prose">{!! $summary_html !!}</div>
@endif @endif
<ul class="mb-facts"> <ul class="mb-facts">
@foreach ($facts as $fact) @foreach ($facts as $fact)
@@ -69,17 +69,17 @@
@endif @endif
@if ($hasOverview) @if ($hasOverview)
<section class="mb-section mb-overview {{ filled($description) && filled($learning_goal) ? '' : 'mb-overview-single' }}" id="ueberblick" aria-label="Überblick"> <section class="mb-section mb-overview {{ filled($description_html) && filled($learning_goal) ? '' : 'mb-overview-single' }}" id="ueberblick" aria-label="Überblick">
@if (filled($description)) @if (filled($description_html))
<div class="mb-overview-text"> <div class="mb-overview-text">
<h2 id="ueberblick-titel">Darum geht es</h2> <h2 id="ueberblick-titel">Darum geht es</h2>
<div class="mb-prose">{!! nl2br(e($description)) !!}</div> <div class="mb-prose">{!! $description_html !!}</div>
</div> </div>
@endif @endif
@if (filled($learning_goal)) @if (filled($learning_goal))
<aside class="mb-goal" aria-labelledby="lernziel-titel"> <aside class="mb-goal" aria-labelledby="lernziel-titel">
<h3 id="lernziel-titel"><x-heroicon-o-check-circle aria-hidden="true" /> Lernziele</h3> <h3 id="lernziel-titel"><x-heroicon-o-check-circle aria-hidden="true" /> Lernziele</h3>
<div class="mb-prose">{!! nl2br(e($learning_goal)) !!}</div> <div class="mb-prose">{!! \App\Domain\Catalog\FormattedText::display($learning_goal) !!}</div>
</aside> </aside>
@endif @endif
</section> </section>
@@ -104,7 +104,7 @@
<h2 id="einsatz-titel">Einsatz &amp; Vorbereitung</h2> <h2 id="einsatz-titel">Einsatz &amp; Vorbereitung</h2>
<div class="mb-note-card"> <div class="mb-note-card">
<h3>Material</h3> <h3>Material</h3>
<div class="mb-prose">{!! nl2br(e($material_note)) !!}</div> <div class="mb-prose">{!! \App\Domain\Catalog\FormattedText::display($material_note) !!}</div>
</div> </div>
</section> </section>
@endif @endif
+1 -1
View File
@@ -14,7 +14,7 @@
<p class="state state-hinweis">Lizenzkennzeichnung: {{ $license }}</p> <p class="state state-hinweis">Lizenzkennzeichnung: {{ $license }}</p>
@endif @endif
<div class="mb-prose"> <div class="mb-prose">
{!! nl2br(e($version->body)) !!} {!! \App\Domain\Catalog\FormattedText::display($version->body) !!}
</div> </div>
</article> </article>
@endsection @endsection
+2 -2
View File
@@ -6,10 +6,10 @@
<p><a href="{{ route('public.programs') }}">Programme</a></p> <p><a href="{{ route('public.programs') }}">Programme</a></p>
<h1>{{ $composition->display_title ?: $composition->designation }}</h1> <h1>{{ $composition->display_title ?: $composition->designation }}</h1>
@if (filled($composition->summary)) @if (filled($composition->summary))
<p class="lede">{{ $composition->summary }}</p> <div class="lede">{!! \App\Domain\Catalog\FormattedText::display($composition->summary) !!}</div>
@endif @endif
@if (filled($version->learning_goal)) @if (filled($version->learning_goal))
<p>Lernziel: {{ $version->learning_goal }}</p> <div><strong>Lernziel:</strong> {!! \App\Domain\Catalog\FormattedText::display($version->learning_goal) !!}</div>
@endif @endif
<ol class="course"> <ol class="course">
@foreach ($nodes as $node) @foreach ($nodes as $node)
@@ -1,5 +1,5 @@
<div class="cta"> <div class="cta">
<h2>{{ $data['heading'] ?? '' }}</h2> <h2><x-brand.heading-symbol :settings="$settings" />{{ $data['heading'] ?? '' }}</h2>
@if (filled($data['text'] ?? null)) @if (filled($data['text'] ?? null))
<p>{{ $data['text'] }}</p> <p>{{ $data['text'] }}</p>
@endif @endif
@@ -0,0 +1,19 @@
{{--
Merkmalszeile: zwei bis vier Merkmale mit Symbol, Kurztitel und Satz. Die Spaltenzahl folgt der Anzahl der Einträge
und der tatsächlichen Breite (Raster mit Mindestbreite). Die Symbole sind Zierde; der Kurztitel trägt die Aussage.
--}}
@if ($items !== [])
<ul class="lf-features lf-features--{{ count($items) }}">
@foreach ($items as $item)
<li class="lf-features__item">
@if ($item['symbol'] !== null)
<x-brand.symbol :name="$item['symbol']" class="lf-features__symbol" />
@endif
<p class="lf-features__title">{{ $item['title'] }}</p>
@if (filled($item['text']))
<p class="lf-features__text">{{ $item['text'] }}</p>
@endif
</li>
@endforeach
</ul>
@endif
+3 -2
View File
@@ -1,8 +1,9 @@
@if (! empty($first)) @if (! empty($first))
<h1>{{ $data['heading'] ?? '' }}</h1> <h1><x-brand.heading-symbol :settings="$settings" />{{ $data['heading'] ?? '' }}</h1>
@else @else
<h2>{{ $data['heading'] ?? '' }}</h2> <h2><x-brand.heading-symbol :settings="$settings" />{{ $data['heading'] ?? '' }}</h2>
@endif @endif
<x-brand.heading-brush :settings="$settings" />
@if (filled($data['intro'] ?? null)) @if (filled($data['intro'] ?? null))
<p class="lede">{{ $data['intro'] }}</p> <p class="lede">{{ $data['intro'] }}</p>
@endif @endif
+1 -1
View File
@@ -38,7 +38,7 @@
@if (filled($data['eyebrow'] ?? null)) @if (filled($data['eyebrow'] ?? null))
<p class="lf-hero__eyebrow">{{ $data['eyebrow'] }}</p> <p class="lf-hero__eyebrow">{{ $data['eyebrow'] }}</p>
@endif @endif
<{{ $tag }} class="lf-hero__title">{{ $data['heading'] ?? '' }}</{{ $tag }}> <{{ $tag }} class="lf-hero__title"><x-brand.heading-symbol :settings="$settings" />{{ $data['heading'] ?? '' }}</{{ $tag }}>
@if ($accent !== 'none') @if ($accent !== 'none')
<span class="lf-hero__title-accent" aria-hidden="true"></span> <span class="lf-hero__title-accent" aria-hidden="true"></span>
@endif @endif
+1 -1
View File
@@ -22,7 +22,7 @@
<p class="lf-bt__eyebrow">{{ $data['eyebrow'] }}</p> <p class="lf-bt__eyebrow">{{ $data['eyebrow'] }}</p>
@endif @endif
@if (filled($data['title'] ?? null)) @if (filled($data['title'] ?? null))
<{{ $tag }} class="lf-bt__headline">{{ $data['title'] }}</{{ $tag }}> <{{ $tag }} class="lf-bt__headline"><x-brand.heading-symbol :settings="$settings" />{{ $data['title'] }}</{{ $tag }}>
<span class="lf-bt__accent" aria-hidden="true"></span> <span class="lf-bt__accent" aria-hidden="true"></span>
@endif @endif
<div class="lf-bt__body">{!! $body !!}</div> <div class="lf-bt__body">{!! $body !!}</div>
+133
View File
@@ -0,0 +1,133 @@
<?php
namespace Tests\Feature;
use App\Domain\Cms\Page;
use App\Domain\Cms\PageService;
use App\Domain\Cms\Widgets\WidgetRegistry;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Validation\ValidationException;
use Tests\TestCase;
/**
* Kleingrafiken des Brand-Kits im Redaktionsinhalt: Symbol vor der Überschrift (Überschrift, Einstieg, Bild und Text,
* Handlungsaufruf), Pinselstrich unter der Überschrift und die Merkmalszeile.
*/
class CmsBrandSymbolsTest extends TestCase
{
use RefreshDatabase;
/**
* @param array<string, mixed> $widget
* @return array<string, mixed>
*/
private function widget(string $type, array $data, array $settings = [], string $variant = 'standard'): array
{
$registry = app(WidgetRegistry::class);
return ['type' => $type, 'v' => $registry->get($type)->version(), 'variant' => $variant, 'settings' => $settings, 'data' => $data];
}
/**
* @param array<string, mixed> $widget
*/
private function publish(string $path, array $widget, string $layout = 'u4'): string
{
$page = Page::query()->create(['path' => $path]);
$service = app(PageService::class);
$content = [['type' => 'heading', 'v' => 1, 'data' => ['heading' => 'Seite']], ['layout' => $layout, 'style' => [], 'slots' => [$widget]]];
$service->publish($page, $service->saveRevision($page, $content, null, null, null));
return $this->get($path)->assertOk()->getContent();
}
public function test_a_heading_shows_its_symbol_inside_the_heading_and_the_brush_below(): void
{
$html = $this->publish('/symbol', $this->widget('heading', ['heading' => 'Filme', 'intro' => 'Kurz erklärt'], ['symbol' => 'filmklappe', 'accent' => 'brush']));
$this->assertMatchesRegularExpression('~<h2><svg[^>]*aria-hidden="true"[^>]*class="brand-symbol lf-heading-symbol"[^>]*>.*?</svg>Filme</h2>~s', $html);
$this->assertMatchesRegularExpression('~<svg[^>]*class="brand-symbol lf-heading-brush"~', $html);
$this->assertStringNotContainsString('motif-title', $html, 'Die Kit-ID darf nie auf der Seite stehen.');
}
public function test_without_settings_the_heading_is_unchanged(): void
{
$html = $this->publish('/ohne', $this->widget('heading', ['heading' => 'Filme']));
$this->assertStringContainsString('<h2>Filme</h2>', $html);
$this->assertStringNotContainsString('lf-heading-symbol', $html);
$this->assertStringNotContainsString('lf-heading-brush', $html);
}
public function test_hero_image_text_and_call_to_action_show_the_symbol_too(): void
{
$hero = $this->publish('/hero', $this->widget('hero', ['heading' => 'Einstieg'], ['symbol' => 'schutzschild'], 'editorial_solid'));
$this->assertMatchesRegularExpression('~class="lf-hero__title"><svg[^>]*lf-heading-symbol~', $hero);
$imageText = $this->publish('/bild-text', $this->widget('image_text', ['title' => 'Ansatz', 'body' => '<p>Text</p>'], ['symbol' => 'buch'], 'image_left'));
$this->assertMatchesRegularExpression('~class="lf-bt__headline"><svg[^>]*lf-heading-symbol~', $imageText);
$cta = $this->publish('/aufruf', $this->widget('call_to_action', ['heading' => 'Jetzt', 'label' => 'Los', 'url' => '/angebote'], ['symbol' => 'paket']));
$this->assertMatchesRegularExpression('~<h2><svg[^>]*lf-heading-symbol~', $cta);
}
public function test_an_image_text_without_a_symbol_keeps_its_exact_headline_markup(): void
{
$html = $this->publish('/bild-text-ohne', $this->widget('image_text', ['title' => 'Geschichten', 'body' => '<p>Text</p>'], [], 'image_left'));
$this->assertStringContainsString('<h2 class="lf-bt__headline">Geschichten</h2>', $html);
}
public function test_unknown_symbols_and_accents_are_rejected_when_saving(): void
{
foreach ([['symbol' => '../../.env'], ['symbol' => 'signalstrahlen'], ['symbol' => 'gelbe-unterstreichung'], ['accent' => 'rays']] as $settings) {
try {
$this->publish('/abgelehnt-'.md5(json_encode($settings)), $this->widget('heading', ['heading' => 'Filme'], $settings));
$this->fail('Angenommen: '.json_encode($settings));
} catch (ValidationException $exception) {
$this->assertStringContainsString('nicht freigegeben', implode(' ', array_merge(...array_values($exception->errors()))));
}
}
}
public function test_the_features_row_renders_symbols_titles_and_text_with_one_column_per_item(): void
{
$items = [
['symbol' => 'filmklappe', 'title' => 'Film', 'text' => 'Kurz erklärt'],
['symbol' => 'uebungsblatt', 'title' => 'Übung', 'text' => null],
['symbol' => 'merkblatt', 'title' => 'Merkblatt', 'text' => 'Zum Mitnehmen'],
];
$html = $this->publish('/merkmale', $this->widget('features', ['items' => $items]));
$this->assertStringContainsString('class="lf-features lf-features--3"', $html);
$this->assertSame(3, substr_count($html, 'class="lf-features__item"'));
$this->assertSame(3, preg_match_all('~<svg[^>]*aria-hidden="true"[^>]*class="brand-symbol lf-features__symbol"~', $html));
$this->assertStringContainsString('<p class="lf-features__title">Übung</p>', $html);
$this->assertStringContainsString('<p class="lf-features__text">Zum Mitnehmen</p>', $html);
$this->assertSame(2, substr_count($html, 'lf-features__text'), 'Ohne Satz gibt es keinen leeren Absatz.');
$this->assertStringNotContainsString('motif-title', $html);
}
public function test_the_features_row_needs_two_to_four_items_with_a_known_symbol(): void
{
$item = fn (string $symbol = 'buch'): array => ['symbol' => $symbol, 'title' => 'Titel', 'text' => null];
foreach ([[$item()], array_fill(0, 5, $item()), [$item(), $item('nicht-vorhanden')], [$item(), ['symbol' => 'buch', 'title' => '', 'text' => null]]] as $index => $items) {
try {
$this->publish('/merkmale-falsch-'.$index, $this->widget('features', ['items' => $items]));
$this->fail("Fall $index wurde angenommen.");
} catch (ValidationException $exception) {
$this->assertNotEmpty($exception->errors(), "Fall $index");
}
}
$this->assertStringContainsString('lf-features--2', $this->publish('/merkmale-zwei', $this->widget('features', ['items' => [$item(), $item('gruppe')]])));
$this->assertStringContainsString('lf-features--4', $this->publish('/merkmale-vier', $this->widget('features', ['items' => array_fill(0, 4, $item())])));
}
public function test_the_features_row_is_not_offered_in_a_single_unit_slot(): void
{
$this->assertFalse(app(WidgetRegistry::class)->get('features')->supportsUnits(1));
$this->assertTrue(app(WidgetRegistry::class)->get('features')->supportsUnits(2));
}
}
+2 -2
View File
@@ -273,7 +273,7 @@ public function test_a_license_article_overrides_only_its_own_presentation(): vo
$article->refresh(); $article->refresh();
$release->refresh(); $release->refresh();
$this->assertSame('Eigene Artikelbeschreibung', $article->summary); $this->assertSame('<p>Eigene Artikelbeschreibung</p>', $article->summary);
$this->assertNull($article->teaser); $this->assertNull($article->teaser);
$again = app(EditorialProfileReader::class)->read($article, 'artikel'); $again = app(EditorialProfileReader::class)->read($article, 'artikel');
$this->assertSame('eigen', $again->origin('summary')); $this->assertSame('eigen', $again->origin('summary'));
@@ -288,7 +288,7 @@ public function test_a_license_article_overrides_only_its_own_presentation(): vo
$cover = $this->pictureWithoutVersion('Artikelbild ohne Fassung'); $cover = $this->pictureWithoutVersion('Artikelbild ohne Fassung');
Livewire::test(ViewLicenseArticle::class, ['record' => $article->getKey()]) Livewire::test(ViewLicenseArticle::class, ['record' => $article->getKey()])
->assertSet('summary', 'Eigene Artikelbeschreibung') ->assertSet('summary', '<p>Eigene Artikelbeschreibung</p>')
->call('openRedaktion') ->call('openRedaktion')
->set('descriptionText', 'Nur dieser Artikel') ->set('descriptionText', 'Nur dieser Artikel')
->call('openPresentationPicker', 'titelbild') ->call('openPresentationPicker', 'titelbild')
+12 -12
View File
@@ -84,7 +84,7 @@ public function test_display_data_does_not_create_a_version_and_a_module_works_w
$this->assertSame('Sichtbar ohne Film', $module->display_title); $this->assertSame('Sichtbar ohne Film', $module->display_title);
$this->assertSame(1, $module->versions()->count()); $this->assertSame(1, $module->versions()->count());
$this->assertSame('Den Abstand erklären', $module->versions()->first()->learning_goal); $this->assertSame('<p>Den Abstand erklären</p>', $module->versions()->first()->learning_goal);
$this->assertSame(1, $module->versions()->first()->members()->count()); $this->assertSame(1, $module->versions()->first()->members()->count());
} }
@@ -259,18 +259,18 @@ public function test_saving_a_draft_ten_times_creates_one_version_only_when_rele
$module->refresh(); $module->refresh();
$this->assertSame(0, $module->versions()->count()); $this->assertSame(0, $module->versions()->count());
$this->assertSame('Durchgang 10', $module->working_draft['learning_goal']); $this->assertSame('<p>Durchgang 10</p>', $module->working_draft['learning_goal']);
Livewire::actingAs($editor, 'staff') Livewire::actingAs($editor, 'staff')
->test(EditExercise::class, ['record' => $module->id]) ->test(EditExercise::class, ['record' => $module->id])
->assertSet('learningGoal', 'Durchgang 10') ->assertSet('learningGoal', '<p>Durchgang 10</p>')
->set('releaseConsent', true) ->set('releaseConsent', true)
->call('publishRevision') ->call('publishRevision')
->assertSet('feedback', 'Fassung 1 ist freigegeben. Der Entwurf ist geschlossen und die bisherige Fassung bleibt erhalten. Die Mitgliederbibliothek ändert sich dadurch nicht.'); ->assertSet('feedback', 'Fassung 1 ist freigegeben. Der Entwurf ist geschlossen und die bisherige Fassung bleibt erhalten. Die Mitgliederbibliothek ändert sich dadurch nicht.');
$module->refresh(); $module->refresh();
$this->assertSame(1, $module->versions()->count()); $this->assertSame(1, $module->versions()->count());
$this->assertSame('Durchgang 10', $module->versions()->first()->learning_goal); $this->assertSame('<p>Durchgang 10</p>', $module->versions()->first()->learning_goal);
$this->assertNull($module->working_draft); $this->assertNull($module->working_draft);
Livewire::actingAs($editor, 'staff') Livewire::actingAs($editor, 'staff')
@@ -280,8 +280,8 @@ public function test_saving_a_draft_ten_times_creates_one_version_only_when_rele
$module->refresh(); $module->refresh();
$this->assertSame(1, $module->versions()->count()); $this->assertSame(1, $module->versions()->count());
$this->assertSame('Durchgang 10', $module->versions()->first()->fresh()->learning_goal); $this->assertSame('<p>Durchgang 10</p>', $module->versions()->first()->fresh()->learning_goal);
$this->assertSame('Nur Entwurf', $module->working_draft['learning_goal']); $this->assertSame('<p>Nur Entwurf</p>', $module->working_draft['learning_goal']);
} }
public function test_the_picker_finds_a_film_by_title(): void public function test_the_picker_finds_a_film_by_title(): void
@@ -393,7 +393,7 @@ public function test_a_chosen_picture_and_description_do_not_create_a_version():
$this->assertSame(1, $composition->versions()->count()); $this->assertSame(1, $composition->versions()->count());
$this->assertSame('vorschau/komposition-'.$composition->id.'.jpg', $composition->thumbnail_path); $this->assertSame('vorschau/komposition-'.$composition->id.'.jpg', $composition->thumbnail_path);
$this->assertSame('element:'.$first->element->id, $composition->thumbnail_source); $this->assertSame('element:'.$first->element->id, $composition->thumbnail_source);
$this->assertSame('Eine fachliche Beschreibung für die Bibliothek.', $composition->description); $this->assertSame('<p>Eine fachliche Beschreibung für die Bibliothek.</p>', $composition->description);
Storage::disk('media_derived')->assertExists($composition->thumbnail_path); Storage::disk('media_derived')->assertExists($composition->thumbnail_path);
$this->get('/medien/'.$composition->thumbnail_path)->assertNotFound(); $this->get('/medien/'.$composition->thumbnail_path)->assertNotFound();
} }
@@ -429,7 +429,7 @@ public function test_texts_save_in_the_redaktion_and_the_dialog_keeps_didactics_
$composition = $version->composition->fresh(); $composition = $version->composition->fresh();
$this->assertSame(1, $composition->versions()->count()); $this->assertSame(1, $composition->versions()->count());
$this->assertSame('Ausführlicher Dialogtext', $composition->description); $this->assertSame('<p>Ausführlicher Dialogtext</p>', $composition->description);
$this->assertNull($composition->working_draft); $this->assertNull($composition->working_draft);
Livewire::actingAs($editor, 'staff') Livewire::actingAs($editor, 'staff')
@@ -441,7 +441,7 @@ public function test_texts_save_in_the_redaktion_and_the_dialog_keeps_didactics_
$composition->refresh(); $composition->refresh();
$this->assertSame(1, $composition->versions()->count()); $this->assertSame(1, $composition->versions()->count());
$this->assertSame(ContentVersionStatus::Bereit, $composition->versions()->first()->status); $this->assertSame(ContentVersionStatus::Bereit, $composition->versions()->first()->status);
$this->assertSame('Nur im Entwurf', $composition->working_draft['learning_goal']); $this->assertSame('<p>Nur im Entwurf</p>', $composition->working_draft['learning_goal']);
$this->assertSame(9, $composition->working_draft['duration_minutes']); $this->assertSame(9, $composition->working_draft['duration_minutes']);
} }
@@ -621,7 +621,7 @@ public function test_a_module_text_stays_editable_until_it_is_released_and_used(
$version = $element->versions()->sole(); $version = $element->versions()->sole();
$this->assertSame(ContentVersionStatus::Entwurf, $version->status); $this->assertSame(ContentVersionStatus::Entwurf, $version->status);
$this->assertSame('Geänderter Wortlaut', $version->body); $this->assertSame('<p>Geänderter Wortlaut</p>', $version->body);
$this->assertSame(1, $element->versions()->count()); $this->assertSame(1, $element->versions()->count());
$this->actingAs($editor, 'staff') $this->actingAs($editor, 'staff')
@@ -643,7 +643,7 @@ public function test_a_module_text_stays_editable_until_it_is_released_and_used(
->call('saveDraft'); ->call('saveDraft');
$this->assertSame(2, $element->fresh()->versions()->count()); $this->assertSame(2, $element->fresh()->versions()->count());
$this->assertSame('Geänderter Wortlaut', $version->fresh()->body); $this->assertSame('<p>Geänderter Wortlaut</p>', $version->fresh()->body);
$this->assertSame($version->id, $module->fresh()->versions()->first()->members()->first()->content_element_version_id); $this->assertSame($version->id, $module->fresh()->versions()->first()->members()->first()->content_element_version_id);
$this->assertSame('element:'.$element->versions()->orderByDesc('number')->first()->id, $module->fresh()->working_draft['members'][0]['target']); $this->assertSame('element:'.$element->versions()->orderByDesc('number')->first()->id, $module->fresh()->working_draft['members'][0]['target']);
} }
@@ -685,7 +685,7 @@ public function test_a_file_can_be_created_inside_the_module(): void
$version = $element->versions()->sole(); $version = $element->versions()->sole();
$this->assertSame('document', $element->output_class); $this->assertSame('document', $element->output_class);
$this->assertSame('Für die Gruppe', $element->description); $this->assertSame('<p>Für die Gruppe</p>', $element->description);
$this->assertSame('Vorher lesen', $element->usage_note); $this->assertSame('Vorher lesen', $element->usage_note);
$this->assertSame(ContentVersionStatus::Entwurf, $version->status); $this->assertSame(ContentVersionStatus::Entwurf, $version->status);
$this->assertSame('eigen', $element->fresh()->thumbnail_source); $this->assertSame('eigen', $element->fresh()->thumbnail_source);
@@ -0,0 +1,207 @@
<?php
namespace Tests\Feature;
use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\EditorialProfileReader;
use App\Domain\Catalog\FormattedText;
use App\Domain\Catalog\IdentityChange;
use App\Filament\Resources\ContentElements\Pages\ViewContentElement;
use App\Filament\Resources\Practices\Pages\EditPractice;
use App\Filament\Support\EditorialCatalog;
use App\Http\LibraryCatalog;
use App\Models\User;
use Filament\Facades\Filament;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Livewire;
use Tests\Support\BuildsExercises;
use Tests\TestCase;
/**
* Formatierte Textfelder im Arbeitsplatz (ADR-50): Der Editor schreibt kanonisches HTML in die Eigenschaft, Klartext des
* Altbestands erscheint formatiert, ohne dass das Öffnen etwas als geändert markiert.
*/
class FormatierteTexteEditorTest extends TestCase
{
use BuildsExercises;
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
}
public function test_the_editor_state_reaches_the_property_as_canonical_html_and_back(): void
{
$practice = app(EditorialCatalog::class)->create('Stopp sagen', CompositionKind::Exercise);
$component = Livewire::actingAs($this->editor(), 'staff')
->test(EditPractice::class, ['record' => $practice->getKey()])
->assertOk();
$component->set('rich.summary', [
'type' => 'doc',
'content' => [['type' => 'paragraph', 'content' => [['type' => 'text', 'text' => 'Fester ', 'marks' => []], ['type' => 'text', 'text' => 'Stand', 'marks' => [['type' => 'bold']]]]]],
]);
$this->assertSame('<p>Fester <strong>Stand</strong></p>', $component->get('summary'));
$component->set('summary', '<p>Vom Server</p>')->assertOk();
$this->assertSame('doc', $component->get('rich.summary.type'));
$this->assertSame('Vom Server', $component->get('rich.summary.content.0.content.0.text'));
}
public function test_legacy_plain_text_appears_formatted_but_opening_it_changes_nothing(): void
{
$practice = app(EditorialCatalog::class)->create('Stopp sagen', CompositionKind::Exercise);
$practice->forceFill(['summary' => "Erste Zeile.\n\n- Punkt A\n- Punkt B"])->save();
$component = Livewire::actingAs($this->editor(), 'staff')
->test(EditPractice::class, ['record' => $practice->getKey()])
->assertOk();
$this->assertSame("Erste Zeile.\n\n- Punkt A\n- Punkt B", $component->get('summary'), 'Die Eigenschaft bleibt, was gespeichert ist.');
$this->assertSame('bulletList', $component->get('rich.summary.content.1.type'), 'Der Editor zeigt die Liste.');
$this->assertFalse($component->instance()->textFieldsChanged(), 'Öffnen markiert nichts als geändert.');
$this->assertSame("Erste Zeile.\n\n- Punkt A\n- Punkt B", $practice->fresh()->summary);
}
public function test_saving_stores_canonical_html_and_an_untouched_legacy_field_is_not_reported_as_changed(): void
{
$practice = app(EditorialCatalog::class)->create('Stopp sagen', CompositionKind::Exercise);
$component = Livewire::actingAs($this->editor(), 'staff')
->test(EditPractice::class, ['record' => $practice->getKey()])
->set('summary', '<p>Kurz <b>fett</b></p>')
->set('description', '<p>Lang</p><script>x()</script>');
$this->assertTrue($component->instance()->textFieldsChanged());
$component->call('saveRedaktion');
$practice->refresh();
$this->assertSame(FormattedText::canonicalHtml('<p>Kurz <strong>fett</strong></p>'), $practice->summary);
$this->assertSame('<p>Lang</p>', $practice->description);
}
public function test_a_list_and_a_nested_list_pass_the_payload_depth_guard(): void
{
$practice = app(EditorialCatalog::class)->create('Stopp sagen', CompositionKind::Exercise);
$item = fn (string $text, array $more = []): array => ['type' => 'listItem', 'content' => [['type' => 'paragraph', 'content' => [['type' => 'text', 'text' => $text]]], ...$more]];
$component = Livewire::actingAs($this->editor(), 'staff')
->test(EditPractice::class, ['record' => $practice->getKey()])
->set('rich.summary', ['type' => 'doc', 'content' => [['type' => 'paragraph', 'content' => [['type' => 'text', 'text' => 'Davor']]], ['type' => 'bulletList', 'content' => [$item('Eins', [['type' => 'bulletList', 'content' => [$item('Eins eins')]]]), $item('Zwei')]]]])
->assertHasNoErrors();
$this->assertSame('<p>Davor</p><ul><li><p>Eins</p><ul><li><p>Eins eins</p></li></ul></li><li><p>Zwei</p></li></ul>', $component->get('summary'));
$component->set('rich.summary.content.1.content.0.content.0.content.0.text', 'Geändert');
$this->assertStringContainsString('Geändert', $component->get('summary'));
}
public function test_a_formatted_summary_reads_as_plain_text_wherever_a_card_or_list_uses_it(): void
{
$practice = app(EditorialCatalog::class)->create('Stopp sagen', CompositionKind::Exercise);
$practice->forceFill([
'summary' => '<p>Kurz <strong>fett</strong> &amp; klar</p><ul><li><p>Eins</p></li><li><p>Zwei</p></li></ul>',
'description' => '<p>Lang <em>erklärt</em></p>',
])->save();
$text = app(LibraryCatalog::class)->text($practice->fresh());
$this->assertSame('Kurz fett & klar
- Eins
- Zwei', $text['summary']);
$this->assertSame('Lang erklärt', $text['description']);
$this->assertStringContainsString('<strong>fett</strong>', $text['summary_html']);
$this->assertStringContainsString('<em>erklärt</em>', $text['description_html']);
$profile = app(EditorialProfileReader::class)->read($practice->fresh(), 'bibliothek');
$this->assertStringNotContainsString('<', (string) $profile->value('summary'));
$this->assertStringContainsString('<ul>', $profile->html('summary'));
}
public function test_opening_a_legacy_exercise_reports_no_unsaved_changes(): void
{
$exercise = $this->exercise('Altbestand');
$composition = $exercise['version']->composition;
$component = Livewire::actingAs($this->editor(), 'staff')
->test(EditPractice::class, ['record' => $composition->getKey()])
->assertOk();
$this->assertStringNotContainsString('ungespeicherte', $component->instance()->editorStatus());
$this->assertSame('Nein sagen und Abstand halten', $component->get('rich.learningGoal.content.0.content.0.text'), 'Das Lernziel steht im Editor.');
$this->assertFalse($component->instance()->textFieldsChanged());
}
public function test_an_untouched_legacy_exercise_creates_no_new_version_when_released_again(): void
{
$exercise = $this->exercise('Altbestand');
$composition = $exercise['version']->composition;
Livewire::actingAs($this->editor(), 'staff')
->test(EditPractice::class, ['record' => $composition->getKey()])
->call('saveDraft')
->call('armRelease')
->set('releaseConsent', true)
->call('publishRevision');
$this->assertSame(1, $composition->versions()->count());
$this->assertSame('Nein sagen und Abstand halten', $composition->versions()->first()->learning_goal, 'Der Altbestand bleibt Klartext.');
}
public function test_formatting_the_learning_goal_is_a_real_change_and_creates_a_version(): void
{
$exercise = $this->exercise('Altbestand');
$composition = $exercise['version']->composition;
Livewire::actingAs($this->editor(), 'staff')
->test(EditPractice::class, ['record' => $composition->getKey()])
->set('learningGoal', '<p>Nein sagen und <strong>Abstand</strong> halten</p>')
->call('saveDraft')
->call('armRelease')
->set('releaseConsent', true)
->call('publishRevision');
$this->assertSame(2, $composition->versions()->count());
$this->assertSame('<p>Nein sagen und <strong>Abstand</strong> halten</p>', $composition->versions()->orderByDesc('number')->first()->learning_goal);
$this->assertSame('Nein sagen und Abstand halten', $composition->versions()->orderBy('number')->first()->learning_goal, 'Die frühere Fassung bleibt unverändert.');
}
public function test_a_medium_keeps_its_plain_description_unless_it_is_edited_and_stores_edits_as_clean_html(): void
{
$content = app(ContentService::class);
$element = $content->createElement('text', 'text', 'Trainerunterlage');
$content->publishElementVersion($element, 'Der Wortlaut');
$content->describe($element, 'Trainerunterlage', 'Alt und schlicht.
- Punkt');
$before = IdentityChange::query()->count();
$component = Livewire::actingAs($this->editor(), 'staff')
->test(ViewContentElement::class, ['record' => $element->getKey()])
->call('openRedaktion')
->call('saveRedaktion');
$this->assertSame('Alt und schlicht.
- Punkt', $element->fresh()->description, 'Speichern ohne Änderung lässt den Altbestand, wie er ist.');
$this->assertSame($before, IdentityChange::query()->count());
$component->set('descriptionText', '<p>Neu <b>fett</b></p><script>x()</script>')->call('saveRedaktion');
$this->assertSame('<p>Neu <strong>fett</strong></p>', $element->fresh()->description);
}
private function editor(): User
{
$editor = User::factory()->redakteur()->create();
$editor->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
return $editor;
}
}
+3 -3
View File
@@ -61,7 +61,7 @@ public function test_a_medium_keeps_the_old_version_when_a_new_one_is_saved(): v
$this->assertCount(2, $versions); $this->assertCount(2, $versions);
$this->assertSame('Erste Fassung', $versions[0]->body); $this->assertSame('Erste Fassung', $versions[0]->body);
$this->assertSame('Zweite Fassung', $versions[1]->body); $this->assertSame('<p>Zweite Fassung</p>', $versions[1]->body);
$this->assertSame(ContentVersionStatus::Bereit, $versions[0]->status); $this->assertSame(ContentVersionStatus::Bereit, $versions[0]->status);
} }
@@ -152,7 +152,7 @@ public function test_an_exercise_can_gain_and_drop_a_medium_without_losing_the_o
->call('publishRevision') ->call('publishRevision')
->assertSet('feedback', 'Fassung 3 ist freigegeben. Der Entwurf ist geschlossen und die bisherige Fassung bleibt erhalten. Die Mitgliederbibliothek ändert sich dadurch nicht.'); ->assertSet('feedback', 'Fassung 3 ist freigegeben. Der Entwurf ist geschlossen und die bisherige Fassung bleibt erhalten. Die Mitgliederbibliothek ändert sich dadurch nicht.');
$this->assertSame('Den Abstand üben', $exercise->composition->versions()->orderByDesc('number')->first()->learning_goal); $this->assertSame('<p>Den Abstand üben</p>', $exercise->composition->versions()->orderByDesc('number')->first()->learning_goal);
$this->assertSame(3, $exercise->composition->versions()->count()); $this->assertSame(3, $exercise->composition->versions()->count());
} }
@@ -232,7 +232,7 @@ public function test_a_description_does_not_create_a_version_and_an_older_versio
->assertSee('Es gibt keine neue Fassung.'); ->assertSee('Es gibt keine neue Fassung.');
$this->assertSame(2, $element->versions()->count()); $this->assertSame(2, $element->versions()->count());
$this->assertSame('Für die Gruppe', $element->fresh()->description); $this->assertSame('<p>Für die Gruppe</p>', $element->fresh()->description);
Livewire::test(ViewContentElement::class, ['record' => $element->getKey()]) Livewire::test(ViewContentElement::class, ['record' => $element->getKey()])
->set('bereich', 'inhalt') ->set('bereich', 'inhalt')
+2 -2
View File
@@ -49,7 +49,7 @@ public function test_editorial_text_is_saved_without_a_new_version_and_previewed
$this->assertSame(1, $element->versions()->count()); $this->assertSame(1, $element->versions()->count());
$this->assertSame($version->id, $element->versions()->first()->id); $this->assertSame($version->id, $element->versions()->first()->id);
$this->assertSame('Lara im Park, neu', $element->display_title); $this->assertSame('Lara im Park, neu', $element->display_title);
$this->assertSame('Ein kurzer Teaser für die Karte', $element->summary); $this->assertSame('<p>Ein kurzer Teaser für die Karte</p>', $element->summary);
$this->assertTrue( $this->assertTrue(
IdentityChange::query()->where('subject_id', $element->id)->where('field', 'summary')->exists() IdentityChange::query()->where('subject_id', $element->id)->where('field', 'summary')->exists()
); );
@@ -58,7 +58,7 @@ public function test_editorial_text_is_saved_without_a_new_version_and_previewed
'summary' => 'Noch nicht gespeichert', 'summary' => 'Noch nicht gespeichert',
]); ]);
$this->assertSame('Noch nicht gespeichert', $draft->summary); $this->assertSame('Noch nicht gespeichert', $draft->summary);
$this->assertSame('Ein kurzer Teaser für die Karte', $element->fresh()->summary); $this->assertSame('<p>Ein kurzer Teaser für die Karte</p>', $element->fresh()->summary);
Livewire::test(ViewContentElement::class, ['record' => $element->getKey()]) Livewire::test(ViewContentElement::class, ['record' => $element->getKey()])
->set('bereich', 'vorschau') ->set('bereich', 'vorschau')
+250 -3
View File
@@ -5,6 +5,7 @@
use App\Domain\Catalog\ArticleService; use App\Domain\Catalog\ArticleService;
use App\Domain\Catalog\Composition; use App\Domain\Catalog\Composition;
use App\Domain\Catalog\CompositionKind; use App\Domain\Catalog\CompositionKind;
use App\Domain\Catalog\CompositionVersion;
use App\Domain\Catalog\ContentService; use App\Domain\Catalog\ContentService;
use App\Domain\Catalog\DomainRuleException; use App\Domain\Catalog\DomainRuleException;
use App\Domain\Catalog\ExerciseImportRun; use App\Domain\Catalog\ExerciseImportRun;
@@ -14,10 +15,12 @@
use App\Domain\Catalog\ShinkanImport; use App\Domain\Catalog\ShinkanImport;
use App\Domain\Design\SiteSetting; use App\Domain\Design\SiteSetting;
use App\Filament\Pages\Uebernahme; use App\Filament\Pages\Uebernahme;
use App\Filament\Resources\Practices\Pages\EditPractice;
use App\Filament\Resources\Practices\Pages\ListPractices; use App\Filament\Resources\Practices\Pages\ListPractices;
use App\Models\User; use App\Models\User;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Http\Client\Factory; use Illuminate\Http\Client\Factory;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Livewire\Livewire; use Livewire\Livewire;
@@ -131,6 +134,81 @@ public function test_the_representative_catalog_answer_lands_in_the_documented_p
$this->assertSame(['Quellvideo Sicherer Stand (video)'], $preview['media'], 'Medien bleiben Quellenangabe ohne Datei.'); $this->assertSame(['Quellvideo Sicherer Stand (video)'], $preview['media'], 'Medien bleiben Quellenangabe ohne Datei.');
} }
public function test_the_representative_html_answer_lands_formatted_in_the_documented_places(): void
{
$document = json_decode((string) file_get_contents(base_path('tests/Fixtures/shinkan/katalog-detail-html.json')), true, 512, JSON_THROW_ON_ERROR);
$import = app(ShinkanImport::class);
$version = $import->adopt($import->record($document));
$body = fn (string $role): string => (string) $version->members->firstWhere('role', $role)->contentElementVersion->body;
$this->assertSame('<p>Die Kinder üben einen <strong>sicheren Stand</strong> und ein deutliches Stopp.</p>', $version->composition->summary);
$this->assertSame('<p>Die Kinder können mit fester Stimme und sicherem Stand Stopp sagen.</p>', $version->learning_goal);
$this->assertSame('Matten, Pratzen', $version->material_note);
$this->assertStringContainsString('<ol><li><p>Sicheren Stand einnehmen</p></li>', $body('Durchführung'));
$this->assertStringContainsString('<em>wie sich der Stand angefühlt hat</em>', $body('Durchführung'));
$this->assertStringNotContainsString('data-shinkan', $body('Durchführung'), 'Der Verweis auf ein Quellmedium entfällt.');
$this->assertSame('<p>Matten im Kreis auslegen.<br>Genug Platz für Abstand zwischen den Kindern lassen.</p>', str_replace('<br />', '<br>', $body('Vorbereitung')));
$this->assertStringContainsString('<ul><li><p>Leise Kinder ermutigen</p></li>', $body('Trainerhinweise'));
$this->assertSame('<p>Die Kinder bilden Paare und üben <em>abwechselnd</em>.</p>', $body('Abweichung der Durchführung'));
}
public function test_html_from_the_source_is_cleaned_and_lands_as_formatted_text(): void
{
$import = app(ShinkanImport::class);
$document = $this->htmlDocument('h1');
$version = $import->adopt($import->record($document));
$body = fn (string $role): string => (string) $version->members->firstWhere('role', $role)->contentElementVersion->body;
$this->assertSame('<p>Kurz <strong>erklärt</strong>.</p>', $version->composition->summary);
$this->assertSame('<p>Ziel:</p><ul><li><p>Stand</p></li><li><p>Stimme</p></li></ul>', $version->learning_goal);
$this->assertSame('Matten, Pratzen', $version->material_note, 'Das Material bleibt Text.');
$this->assertSame('<p>Die Kinder <strong>stehen</strong> sicher.</p><h3>Ablauf</h3><ul><li><p>Stimme einsetzen</p></li></ul>', $body('Durchführung'), 'Skript und Medienverweis fallen weg, Absatz, Hervorhebung und Liste bleiben.');
$this->assertStringNotContainsString('script', $body('Durchführung'));
$this->assertStringNotContainsString('data-shinkan', $body('Durchführung'));
$this->assertSame('<p>Mit <em>Partner</em> üben.</p>', $body('Abweichung der Durchführung'));
$preview = $import->preview(ExerciseSource::query()->firstOrFail());
$this->assertSame('Kurz erklärt.', $preview['summary'], 'Die Vorschau zeigt Klartext.');
$this->assertSame('Ziel:
- Stand
- Stimme', $preview['goal']);
$this->assertStringNotContainsString('<', json_encode($preview['sections']));
}
public function test_the_same_html_again_creates_no_new_text_version_and_a_formatting_only_change_is_noticed(): void
{
$import = app(ShinkanImport::class);
$first = $import->adopt($import->record($this->htmlDocument('h1')));
$again = $this->htmlDocument('h2');
$again['execution'] = '<div>Die Kinder <b>stehen</b> sicher.<span data-shinkan-exercise-media="9"></span></div>
<h2>Ablauf</h2><ul><li>Stimme einsetzen</li></ul>';
$second = $import->adopt($import->record($again));
$this->assertSame(
$first->members->firstWhere('role', 'Durchführung')->content_element_version_id,
$second->members->firstWhere('role', 'Durchführung')->content_element_version_id,
'Andere Schreibweise desselben Inhalts ist keine neue Textfassung.',
);
$changed = $this->htmlDocument('h3');
$changed['execution'] = '<p>Die Kinder stehen sicher.</p><h3>Ablauf</h3><ul><li>Stimme einsetzen</li></ul>';
$preview = $import->preview(ExerciseSource::query()->firstOrFail());
$import->record($changed);
$this->assertContains('Durchführung geändert', $import->preview(ExerciseSource::query()->firstOrFail())['changes'], 'Fett entfernt ist eine Änderung.');
}
public function test_a_plain_text_document_is_still_taken_as_plain_text(): void
{
$import = app(ShinkanImport::class);
$version = $import->adopt($import->record($this->document('h1')));
$this->assertSame('Kurz erklärt.', $version->composition->summary);
$this->assertSame('Nein sagen üben', $version->learning_goal);
}
public function test_a_changed_variant_is_recognised_and_a_new_version_keeps_the_local_addition(): void public function test_a_changed_variant_is_recognised_and_a_new_version_keeps_the_local_addition(): void
{ {
$import = app(ShinkanImport::class); $import = app(ShinkanImport::class);
@@ -452,6 +530,44 @@ public function test_the_key_from_the_server_environment_wins_and_an_existing_co
$this->assertFalse(app(ShinkanImport::class)->configured()); $this->assertFalse(app(ShinkanImport::class)->configured());
} }
public function test_the_address_may_name_the_installation_or_its_api_path_without_doubling_the_path(): void
{
foreach (['https://dev.shinkan.jinkendo.de', 'https://dev.shinkan.jinkendo.de/', 'https://dev.shinkan.jinkendo.de/api', 'https://dev.shinkan.jinkendo.de/api/', 'https://dev.shinkan.jinkendo.de/api/distribution/v1'] as $configured) {
config(['services.shinkan.url' => $configured]);
$this->freshHttp();
Http::fake(['dev.shinkan.jinkendo.de/*' => Http::response(['exercises' => [], 'changes' => [], 'next_cursor' => 'c'])]);
$this->assertTrue(app(ShinkanImport::class)->check()['ok'], $configured);
Http::assertSent(fn ($request): bool => $request->url() === 'https://dev.shinkan.jinkendo.de/api/distribution/v1/catalog'
&& $request->hasHeader('Authorization', 'Bearer geheim-fuer-den-test'));
}
}
public function test_a_network_failure_names_the_cause_and_the_host_but_no_address_path_or_key(): void
{
config(['services.shinkan.url' => 'https://dev.shinkan.jinkendo.de']);
$cases = [
'cURL error 6: Could not resolve host: dev.shinkan.jinkendo.de (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://dev.shinkan.jinkendo.de/api/distribution/v1/catalog' => 'Namensauflösung',
'cURL error 7: Failed to connect to dev.shinkan.jinkendo.de port 443' => 'Firewall',
'cURL error 28: Connection timed out after 20001 milliseconds' => 'Zeit überschritten',
'cURL error 60: SSL certificate problem' => 'Zertifikat',
'irgendetwas anderes' => 'Netzwerkfehler.',
];
foreach ($cases as $message => $expected) {
$this->freshHttp();
Http::fake(fn () => throw new ConnectionException($message));
$result = app(ShinkanImport::class)->check();
$this->assertFalse($result['ok']);
$this->assertStringContainsString('dev.shinkan.jinkendo.de', $result['message']);
$this->assertStringContainsString($expected, $result['message']);
$this->assertStringNotContainsString('/api/', $result['message']);
$this->assertStringNotContainsString('geheim-fuer-den-test', $result['message']);
}
}
public function test_the_exercise_list_leads_to_the_takeover_page(): void public function test_the_exercise_list_leads_to_the_takeover_page(): void
{ {
Livewire::actingAs($this->staff('redakteur'), 'staff') Livewire::actingAs($this->staff('redakteur'), 'staff')
@@ -593,7 +709,7 @@ public function test_the_ui_requires_the_reassignment_before_confirming_and_then
->call('review') ->call('review')
->assertSee('Neue Zuordnung für lokale Ergänzung (Eigenes Video)') ->assertSee('Neue Zuordnung für lokale Ergänzung (Eigenes Video)')
->call('confirm') ->call('confirm')
->assertSee('Lege zuerst die neue Zuordnung der lokalen Ergänzungen fest') ->assertSee('Lege zuerst fest, was gilt')
->assertSet('step', 'vorschau'); ->assertSet('step', 'vorschau');
$this->assertSame(2, $first->composition->versions()->count()); $this->assertSame(2, $first->composition->versions()->count());
@@ -615,13 +731,122 @@ public function test_the_exercise_list_names_the_origin_of_each_exercise(): void
$page = Livewire::actingAs($this->staff('redakteur'), 'staff')->test(ListPractices::class) $page = Livewire::actingAs($this->staff('redakteur'), 'staff')->test(ListPractices::class)
->assertSee('Herkunft: Shinkan') ->assertSee('Herkunft: Shinkan')
->assertSee('Herkunft: lokal') ->assertSee('Herkunft: lokal')
->assertDontSee('lokal ergänzt'); ->assertDontSee('lokal bearbeitet');
$members = $first->members->map(fn ($m): array => ['role' => $m->role, 'target' => $m->contentElementVersion, 'variant' => $m->variant?->key, 'origin' => $m->origin])->all(); $members = $first->members->map(fn ($m): array => ['role' => $m->role, 'target' => $m->contentElementVersion, 'variant' => $m->variant?->key, 'origin' => $m->origin])->all();
$members[] = ['role' => 'Eigenes Video', 'target' => $this->film('Eigenes Video'), 'origin' => 'lokal']; $members[] = ['role' => 'Eigenes Video', 'target' => $this->film('Eigenes Video'), 'origin' => 'lokal'];
app(ContentService::class)->publishComposition($first->composition, $members, null, null, [], $first->variants->map(fn ($v): array => ['key' => $v->key, 'name' => $v->name, 'description' => $v->description, 'origin' => $v->origin])->all()); app(ContentService::class)->publishComposition($first->composition, $members, null, null, [], $first->variants->map(fn ($v): array => ['key' => $v->key, 'name' => $v->name, 'description' => $v->description, 'origin' => $v->origin])->all());
Livewire::actingAs($this->staff('redakteur'), 'staff')->test(ListPractices::class)->assertSee('Herkunft: Shinkan, lokal ergänzt'); Livewire::actingAs($this->staff('redakteur'), 'staff')->test(ListPractices::class)->assertSee('Herkunft: Shinkan, lokal bearbeitet');
}
public function test_an_imported_exercise_is_edited_like_any_other_and_the_local_edit_survives_an_unrelated_source_change(): void
{
$import = app(ShinkanImport::class);
$first = $import->adopt($import->record($this->document('h1')));
$composition = $first->composition;
// Bearbeitung in der Verwaltung: Text der Durchführung und Lernziel, als neue Fassung gespeichert.
Livewire::actingAs($this->staff('redakteur'), 'staff')
->test(EditPractice::class, ['record' => $composition->getKey()])
->call('selectPart', 1)
->set('partBody', 'Unsere eigene Durchführung.')
->call('saveSourceText')
->set('learningGoal', 'Unser Lernziel')
->call('saveDraft')
->call('armRelease')
->set('releaseConsent', true)
->call('publishRevision');
$second = $composition->versions()->orderByDesc('number')->firstOrFail();
$this->assertSame(2, $second->number);
$this->assertSame('<p>Unsere eigene Durchführung.</p>', $second->members->firstWhere('role', 'Durchführung')->contentElementVersion->body);
$this->assertSame('<p>Unser Lernziel</p>', $second->learning_goal);
$this->assertSame('Nein sagen üben', $first->fresh()->learning_goal, 'Die frühere Fassung bleibt unverändert.');
// Die Quelle ändert nur die Trainerhinweise.
$changed = $this->document('h2');
$changed['trainer_notes'] = 'Neue Hinweise der Quelle.';
$snapshot = $import->record($changed);
$source = ExerciseSource::query()->firstOrFail();
$preview = $import->preview($source);
$this->assertSame([], $preview['text_conflicts']);
$this->assertEqualsCanonicalizing(['Durchführung', 'Lernziel'], $preview['kept_local']);
$third = $import->adopt($snapshot);
$this->assertSame('<p>Unsere eigene Durchführung.</p>', $third->members->firstWhere('role', 'Durchführung')->contentElementVersion->body);
$this->assertSame('lokal', $third->members->firstWhere('role', 'Durchführung')->origin);
$this->assertSame('Neue Hinweise der Quelle.', $third->members->firstWhere('role', 'Trainerhinweise')->contentElementVersion->body);
$this->assertSame('quelle', $third->members->firstWhere('role', 'Trainerhinweise')->origin);
$this->assertSame('<p>Unser Lernziel</p>', $third->learning_goal);
}
public function test_a_text_changed_locally_and_in_the_source_needs_a_deliberate_choice(): void
{
$import = app(ShinkanImport::class);
$first = $this->withLocalExecution($import, 'Lokale Durchführung.');
$changed = $this->document('h2');
$changed['execution'] = 'Neue Durchführung der Quelle.';
$snapshot = $import->record($changed);
$source = ExerciseSource::query()->firstOrFail();
$this->assertSame([['key' => 'execution', 'label' => 'Durchführung']], $import->preview($source)['text_conflicts']);
try {
$import->adopt($snapshot);
$this->fail('Ohne Entscheidung darf nichts übernommen werden.');
} catch (DomainRuleException $exception) {
$this->assertStringContainsString('Lege fest, welcher Stand gilt', $exception->getMessage());
}
$kept = $import->adoptPreviewed($source, $snapshot->id, [], null, ['execution' => 'lokal']);
$this->assertSame('uebernommen', $kept['status']);
$this->assertSame('Lokale Durchführung.', $kept['version']->members->firstWhere('role', 'Durchführung')->contentElementVersion->body);
$again = $this->document('h3');
$again['execution'] = 'Noch eine Durchführung der Quelle.';
$next = $import->record($again);
$taken = $import->adoptPreviewed($source->fresh(), $next->id, [], null, ['execution' => 'quelle']);
$this->assertSame('Noch eine Durchführung der Quelle.', $taken['version']->members->firstWhere('role', 'Durchführung')->contentElementVersion->body);
$this->assertSame('quelle', $taken['version']->members->firstWhere('role', 'Durchführung')->origin);
$this->assertSame(4, $first->composition->versions()->count(), 'Übernahme, lokale Bearbeitung und zwei weitere Übernahmen.');
}
public function test_the_ui_asks_for_the_choice_on_a_double_change(): void
{
$import = app(ShinkanImport::class);
$first = $this->withLocalExecution($import, 'Lokale Durchführung.');
$changed = $this->document('h2');
$changed['execution'] = 'Neue Durchführung der Quelle.';
$import->record($changed);
$sourceId = (string) ExerciseSource::query()->value('id');
$page = Livewire::actingAs($this->staff('redakteur'), 'staff')->test(Uebernahme::class)
->set('selected', [$sourceId])
->call('review')
->assertSee('Durchführung: lokal und in der Quelle geändert')
->call('confirm')
->assertSee('Lege zuerst fest, was gilt')
->assertSet('step', 'vorschau');
$page->set('textChoice.'.$sourceId.'.execution', 'lokal')->call('confirm')->assertSet('step', 'ergebnis');
$this->assertSame('Lokale Durchführung.', $first->composition->versions()->orderByDesc('number')->firstOrFail()->members->firstWhere('role', 'Durchführung')->contentElementVersion->body);
}
/** Übernommene Übung, deren Durchführung lokal als neue Fassung bearbeitet wurde. */
private function withLocalExecution(ShinkanImport $import, string $text): CompositionVersion
{
$first = $import->adopt($import->record($this->document('h1')));
$content = app(ContentService::class);
$local = $content->publishElementVersion($first->members->firstWhere('role', 'Durchführung')->contentElementVersion->element, $text);
$content->publishComposition($first->composition, $first->members->map(fn ($m): array => [
'role' => $m->role, 'target' => $m->role === 'Durchführung' ? $local : $m->contentElementVersion, 'variant' => $m->variant?->key, 'origin' => $m->origin,
])->all(), null, null, ['learning_goal' => 'Nein sagen üben', 'duration_minutes' => 10, 'duration_max' => 15, 'material_note' => 'Matten, Pratzen'], $first->variants->map(fn ($v): array => ['key' => $v->key, 'name' => $v->name, 'description' => $v->description, 'origin' => $v->origin])->all());
return $first;
} }
private function staff(string $role): User private function staff(string $role): User
@@ -656,6 +881,28 @@ private function fake(array $details, array $changes, string $cursor, ?array $li
Http::fake($fakes); Http::fake($fakes);
} }
/**
* Antwort der Quelle mit `text_format: html`, wie sie Shinkan liefert.
*
* @return array<string, mixed>
*/
private function htmlDocument(string $hash): array
{
return [
...$this->document($hash),
'text_format' => 'html',
'summary' => '<p>Kurz <b>erklärt</b>.</p>',
'goal' => '<p>Ziel:</p><ul><li>Stand</li><li>Stimme</li></ul>',
'execution' => '<p>Die Kinder <strong>stehen</strong> sicher.<span data-shinkan-exercise-media="7" class="shinkan-inline-media"></span></p><h3>Ablauf</h3><ul><li>Stimme einsetzen</li></ul><script>alert(1)</script>',
'preparation' => '<p>Matten auslegen.</p>',
'trainer_notes' => '<p>Auf Abstand achten.</p>',
'variants' => [
['id' => self::VARIANT_A, 'name' => 'Mit Partner', 'description' => 'Zu zweit', 'execution_changes' => '<p>Mit <i>Partner</i> üben.</p>', 'sequence_order' => 1],
['id' => self::VARIANT_B, 'name' => 'Allein', 'description' => 'Einzeln', 'execution_changes' => '', 'sequence_order' => 2],
],
];
}
/** /**
* @return array<string, mixed> * @return array<string, mixed>
*/ */
+54
View File
@@ -258,6 +258,60 @@ public function test_the_path_finds_the_place_even_when_the_exercise_sits_deeper
$this->assertNull($guide->pathTo($outer, 999999)); $this->assertNull($guide->pathTo($outer, 999999));
} }
public function test_formatted_text_appears_formatted_in_the_guide_and_the_pdf_and_never_carries_markup_that_could_run(): void
{
$content = app(ContentService::class);
$text = $this->section('Formatiert', '<p>Erster Absatz mit <strong>fettem</strong> und <em>schrägem</em> Text.</p><h3>Ablauf</h3><ol><li><p>Erst <strong>aufwärmen</strong></p></li><li><p>Dann üben</p></li></ol><ul><li><p>Matten</p></li></ul><blockquote><p>Ein Zitat</p></blockquote><p><a href="https://example.org/regeln">Regeln</a><script>alert(1)</script></p>');
$composition = $this->exerciseComposition('Formatierte Übung');
$version = $content->publishComposition($composition, [['role' => 'Durchführung', 'target' => $text]], null, null, [
'learning_goal' => '<p>Das <strong>Ziel</strong>:</p><ul><li><p>Stand</p></li><li><p>Stimme</p></li></ul>',
'material_note' => '<p>Matten und <em>Pratzen</em></p>',
]);
$module = $this->moduleWith('Modul formatiert', $version);
$articles = app(ArticleService::class);
$article = $articles->create('formatiert');
$release = $articles->publishRelease($article, $module, 'Formatiert.');
$member = $this->grantTo($this->full(), [$article]);
$page = $this->actingAs($member)->get($this->page($article, $release));
$page->assertOk()
->assertSee('<strong>fettem</strong>', false)
->assertSee('<em>schrägem</em>', false)
->assertSee('<h3>Ablauf</h3>', false)
->assertSee('<li><p>Erst <strong>aufwärmen</strong></p></li>', false)
->assertSee('<blockquote>', false)
->assertSee('<strong>Ziel</strong>', false)
->assertSee('<em>Pratzen</em>', false)
->assertSee('rel="noopener noreferrer"', false)
->assertDontSee('alert(1)', false);
$response = $this->actingAs($member)->get($this->pdf($article, $release, null, $member));
$response->assertOk();
$pdf = $response->getContent();
$text = $this->pdfText($pdf);
$this->assertStringContainsString('/BaseFont /Helvetica-Oblique', $pdf, 'Kursiv braucht die schräge Schrift.');
$this->assertMatchesRegularExpression('/\/F2 [0-9.]+ Tf [0-9. ]+ Td \( ?fettem\)/', $pdf, 'Fettes Wort in fetter Schrift.');
$this->assertMatchesRegularExpression('/\/F3 [0-9.]+ Tf [0-9. ]+ Td \( ?schr\xE4gem\)/', $pdf, 'Kursives Wort in schräger Schrift.');
$this->assertStringContainsString('Ablauf', $text);
$this->assertStringContainsString('Erst', $text);
$this->assertStringContainsString('Ein Zitat', $text);
$this->assertStringContainsString('(https://example.org/regeln)', $text, 'Der Link erscheint auf Papier mit Adresse.');
$this->assertStringNotContainsString('alert(1)', $text);
$this->assertStringContainsString('Lernziel:', $text);
$this->assertStringContainsString('Ausstattung:', $text);
$this->assertStringNotContainsString('<strong>', $text, 'Im PDF steht keine Auszeichnung als Text.');
}
public function test_legacy_plain_text_reads_exactly_as_before(): void
{
$this->actingAs($this->member)
->get($this->page($this->moduleArticle, $this->moduleRelease))
->assertOk()
->assertSee('<ul><li><p>Sicher stehen</p></li><li><p>Deutlich sprechen</p></li></ul>', false)
->assertSee('Nein sagen und Abstand halten');
}
private function page(LicenseArticle $article, ArticleRelease $release): string private function page(LicenseArticle $article, ArticleRelease $release): string
{ {
return route('member.exercise', ['article' => $article, 'release' => $release, 'path' => '1']); return route('member.exercise', ['article' => $article, 'release' => $release, 'path' => '1']);
+71
View File
@@ -0,0 +1,71 @@
<?php
namespace Tests\Feature;
use App\Filament\Pages\RedaktionelleStammdaten;
use App\Filament\Pages\Uebernahme;
use App\Filament\Resources\Combinations\CombinationResource;
use App\Filament\Resources\Courses\CourseResource;
use App\Filament\Resources\Exercises\ExerciseResource;
use App\Filament\Resources\Pillars\PillarResource;
use App\Filament\Resources\Practices\PracticeResource;
use App\Models\User;
use Filament\Facades\Filament;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
/**
* Navigation der Verwaltung: Übungen haben einen Einstieg im Bereich Inhalte, Säulen und redaktionelle Stammdaten stehen
* in einer eigenen Gruppe Stammdaten, und die Übernahme aus Shinkan ist ein Weg im Übungsbestand.
*/
class UebungNavigationTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
}
public function test_exercises_have_one_entry_in_the_content_group_next_to_media_modules_and_programs(): void
{
$this->assertSame('Inhalte', PracticeResource::getNavigationGroup());
$this->assertSame('Übungen', PracticeResource::getNavigationLabel());
$order = collect([PracticeResource::class, ExerciseResource::class, CourseResource::class, CombinationResource::class])
->sortBy(fn (string $resource): int => $resource::getNavigationSort())
->map(fn (string $resource): string => $resource::getNavigationLabel())
->values()
->all();
$this->assertSame(['Übungen', 'Module', 'Programme', 'Fachliche Kombinationen'], $order);
}
public function test_pillars_and_editorial_master_data_share_the_master_data_group(): void
{
$this->assertSame('Stammdaten', PillarResource::getNavigationGroup());
$this->assertSame('Stammdaten', RedaktionelleStammdaten::getNavigationGroup());
$this->assertNotSame('Inhalte', PillarResource::getNavigationGroup());
}
public function test_the_takeover_page_is_no_second_entry_for_the_editorial_staff(): void
{
$this->actingAs($this->staff('redakteur'), 'staff');
$this->assertFalse(Uebernahme::shouldRegisterNavigation());
$this->assertTrue(Uebernahme::canAccess());
// Wer nur die Anbindung pflegt und den Übungsbestand nicht sieht, findet die Seite in der Navigation.
$this->actingAs($this->staff('katalogverwalter'), 'staff');
$this->assertTrue(Uebernahme::shouldRegisterNavigation());
}
private function staff(string $role): User
{
$user = User::factory()->{$role}()->create();
$user->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
return $user;
}
}
+2 -2
View File
@@ -656,7 +656,7 @@ public function test_saving_a_released_text_selects_the_new_version(): void
->assertSee('Fassung 3 ist angelegt. Fassung 1 bleibt erhalten.'); ->assertSee('Fassung 3 ist angelegt. Fassung 1 bleibt erhalten.');
$third = $text->versions()->where('number', 3)->firstOrFail(); $third = $text->versions()->where('number', 3)->firstOrFail();
$component->assertSet('fassung', $third->id)->assertSet('bodyDraft', 'Dritter Wortlaut'); $component->assertSet('fassung', $third->id)->assertSet('bodyDraft', '<p>Dritter Wortlaut</p>');
$this->assertSame('Erster Wortlaut', $first->fresh()->body); $this->assertSame('Erster Wortlaut', $first->fresh()->body);
} }
@@ -739,7 +739,7 @@ public function test_a_new_version_from_the_dialog_is_shown_with_its_own_text():
$second = $text->versions()->where('number', 2)->firstOrFail(); $second = $text->versions()->where('number', 2)->firstOrFail();
$component->assertSet('fassung', $second->id) $component->assertSet('fassung', $second->id)
->assertSet('bodyDraft', 'Neuer Wortlaut') ->assertSet('bodyDraft', '<p>Neuer Wortlaut</p>')
->assertDontSee('Text der Fassung nicht gespeichert'); ->assertDontSee('Text der Fassung nicht gespeichert');
} }
@@ -0,0 +1,38 @@
{
"source_id": "6f1c1c52-0a53-4f6b-8e0e-3f0c2f6b9a11",
"title": "Sicher stehen und Stopp sagen",
"summary": "<p>Die Kinder üben einen <strong>sicheren Stand</strong> und ein deutliches Stopp.</p>",
"goal": "<p>Die Kinder können mit fester Stimme und sicherem Stand Stopp sagen.</p>",
"execution": "<p>Die Kinder stellen sich im Kreis auf.</p><ol><li>Sicheren Stand einnehmen</li><li>Arme nach vorn, Handflächen zeigen nach vorn</li><li>Laut und deutlich „Stopp!“ sagen</li></ol><p>Zum Abschluss besprechen alle, <em>wie sich der Stand angefühlt hat</em>.</p><p><span data-shinkan-exercise-media=\"1\" data-shinkan-exercise-media-size=\"medium\" class=\"shinkan-inline-media\"></span></p>",
"preparation": "<p>Matten im Kreis auslegen.<br>Genug Platz für Abstand zwischen den Kindern lassen.</p>",
"trainer_notes": "<p>Auf <strong>Abstand</strong> achten.</p><ul><li>Leise Kinder ermutigen</li><li>Laute Kinder zum Zuhören anhalten</li></ul>",
"equipment": "Matten, Pratzen",
"duration_min": 10,
"duration_max": 15,
"variants": [
{
"id": "11111111-1111-4111-8111-111111111111",
"name": "Mit Partner",
"description": "Zu zweit üben, ein Kind spielt die Rolle des Gegenübers.",
"execution_changes": "<p>Die Kinder bilden Paare und üben <em>abwechselnd</em>.</p>",
"sequence_order": 1
},
{
"id": "22222222-2222-4222-8222-222222222222",
"name": "Allein vor dem Spiegel",
"description": "Einzelübung ohne Partner.",
"execution_changes": "",
"sequence_order": 2
}
],
"media": [
{
"id": "33333333-3333-4333-8333-333333333333",
"media_type": "video",
"title": "Quellvideo Sicherer Stand",
"sort_order": 1
}
],
"content_hash": "6c1b0e1c9f6a4d7e8f21c3b4a5d6e7f8091a2b3c4d5e6f708192a3b4c5d6e7f9",
"text_format": "html"
}
+104
View File
@@ -0,0 +1,104 @@
<?php
namespace Tests\Unit;
use App\Domain\Catalog\FormattedText;
use Tests\TestCase;
class FormattedTextTest extends TestCase
{
public function test_unsafe_markup_is_removed_and_the_text_stays_readable(): void
{
$html = FormattedText::canonical('<p onclick="x()">Hallo <script>alert(1)</script><strong>Welt</strong></p><p><a href="javascript:alert(1)">Link</a> <a href="https://example.org/a?b=1&c=2">Gut</a> <a href="/intern">Relativ</a></p><iframe src="https://evil.example"></iframe><p><img src="x" onerror="y()">Bild</p>');
$this->assertStringNotContainsString('<script', $html);
$this->assertStringNotContainsString('onclick', $html);
$this->assertStringNotContainsString('onerror', $html);
$this->assertStringNotContainsString('javascript:', $html);
$this->assertStringNotContainsString('<iframe', $html);
$this->assertStringNotContainsString('<img', $html);
$this->assertStringContainsString('<strong>Welt</strong>', $html);
$this->assertStringContainsString('href="https://example.org/a?b=1&amp;c=2"', $html);
$this->assertStringContainsString('rel="noopener noreferrer"', $html);
$this->assertStringContainsString('Bild', $html);
}
public function test_canonical_form_is_stable_and_ignores_spelling_of_the_same_content(): void
{
$samples = [
'<p>Eins</p>'."\n\n".'<p>Zwei <b>fett</b> und <i>schräg</i></p>',
'<div>Lose <strong>Zeile</strong></div><ul><li>Punkt A</li><li><p>Punkt B</p></li></ul>',
'<h2>Titel</h2><ol><li>Erst</li><li>Dann</li></ol><blockquote>Zitat</blockquote>',
'Text <b>ohne</b> Block',
];
foreach ($samples as $sample) {
$once = FormattedText::canonicalHtml($sample);
$this->assertNotSame('', $once);
$this->assertSame($once, FormattedText::canonical($once), 'Zweimal kanonisch ändert nichts: '.$sample);
$this->assertTrue(FormattedText::isHtml($once));
}
$this->assertSame(
FormattedText::canonicalHtml('<p>A <b>B</b></p>'),
FormattedText::canonicalHtml("<p>A <strong>B</strong></p>\n"),
);
$this->assertTrue(FormattedText::same('<p>A</p>', "<p>A</p>\n\n"));
$this->assertSame('', FormattedText::canonical("<p></p>\n<p> </p>"));
$this->assertSame('', FormattedText::canonical(' '));
$this->assertSame('', FormattedText::canonical(null));
}
public function test_list_items_always_carry_their_text_in_a_paragraph_like_the_editor_writes_them(): void
{
$this->assertSame('<ul><li><p>A</p></li><li><p>B</p></li></ul>', FormattedText::canonicalHtml('<ul><li>A</li><li>B</li></ul>'));
$this->assertSame('<ul><li><p>A</p></li></ul>', FormattedText::canonicalHtml('<ul><li><p>A</p></li></ul>'));
}
public function test_legacy_plain_text_keeps_its_paragraphs_lists_and_headings(): void
{
$plain = "Einleitung mit < und & Zeichen.\n\n## Ablauf\n\n1. Stand einnehmen\n2. Arme nach vorn\n\n- Leise ermutigen\n- Laute anhalten\n\nSchluss.";
$this->assertFalse(FormattedText::isHtml($plain));
$html = FormattedText::canonical($plain);
$this->assertSame(
'<p>Einleitung mit &lt; und &amp; Zeichen.</p><h3>Ablauf</h3><ol><li><p>Stand einnehmen</p></li><li><p>Arme nach vorn</p></li></ol><ul><li><p>Leise ermutigen</p></li><li><p>Laute anhalten</p></li></ul><p>Schluss.</p>',
$html,
);
$this->assertSame($html, FormattedText::canonical($html));
$this->assertSame(FormattedText::html($plain), $html);
}
public function test_plain_text_that_only_looks_like_markup_stays_plain(): void
{
$this->assertFalse(FormattedText::isHtml('<3 Training & Spaß'));
$this->assertSame('<p>&lt;3 Training &amp; Spaß</p>', FormattedText::canonical('<3 Training & Spaß'));
$this->assertFalse(FormattedText::isHtml('Preis < 5 und > 3'));
}
public function test_plain_text_and_excerpt_drop_markup_but_keep_structure(): void
{
$html = '<p>Erster <strong>Absatz</strong><br>mit Umbruch</p><ul><li><p>Eins</p></li><li><p>Zwei</p></li></ul><ol><li><p>A</p></li><li><p>B</p></li></ol>';
$this->assertSame("Erster Absatz\nmit Umbruch\n\n- Eins\n- Zwei\n\n1. A\n2. B", FormattedText::plain($html));
$this->assertSame('Erster Absatz mit Umbruch - Eins - Zwei 1. A 2. B', FormattedText::excerpt($html, 200));
$this->assertSame('Erster Absatz…', FormattedText::excerpt($html, 14));
}
public function test_blocks_carry_the_emphasis_for_the_pdf(): void
{
$blocks = FormattedText::blocks('<h3>Titel</h3><p>Normal <strong>fett</strong> <em>schräg</em> <a href="https://example.org/">Link</a></p><ul><li><p>Eins <strong>fett</strong></p></li></ul>');
$this->assertSame('heading', $blocks[0]['type']);
$this->assertSame('Titel', $blocks[0]['runs'][0]['text']);
$this->assertSame('paragraph', $blocks[1]['type']);
$this->assertSame(
[['Normal ', false, false, null], ['fett', true, false, null], [' ', false, false, null], ['schräg', false, true, null], [' ', false, false, null], ['Link', false, false, 'https://example.org/']],
array_map(fn (array $run): array => [$run['text'], $run['bold'], $run['italic'], $run['href']], $blocks[1]['runs']),
);
$this->assertSame('bullets', $blocks[2]['type']);
$this->assertTrue($blocks[2]['items'][0][1]['bold']);
}
}
+43
View File
@@ -0,0 +1,43 @@
<?php
namespace Tests\Unit;
use App\Domain\Cms\Widgets\Support\HeadingAccent;
use App\Support\Brand\Symbols;
use Tests\TestCase;
class HeadingAccentTest extends TestCase
{
public function test_every_offered_symbol_has_a_file_and_only_the_two_accents_are_withheld(): void
{
$files = Symbols::names();
$offered = array_keys(HeadingAccent::SYMBOLS);
$this->assertSame([], array_values(array_diff($offered, $files)), 'Jede Auswahl braucht eine vorhandene Datei.');
$this->assertSame(['gelbe-unterstreichung', 'signalstrahlen'], array_values(array_diff($files, $offered)), 'Unterstreichung und Strahlen haben eigene Einstellungen.');
}
public function test_labels_are_present_for_every_symbol(): void
{
foreach (HeadingAccent::SYMBOLS as $name => $label) {
$this->assertNotSame('', trim($label), $name);
}
}
public function test_only_known_names_are_accepted(): void
{
$this->assertSame('buch', HeadingAccent::symbol(['symbol' => 'buch']));
$this->assertNull(HeadingAccent::symbol([]));
$this->assertNull(HeadingAccent::symbol(['symbol' => '']));
$this->assertNull(HeadingAccent::symbol(['symbol' => '../../.env']));
$this->assertNull(HeadingAccent::symbol(['symbol' => 'signalstrahlen']));
$this->assertNull(HeadingAccent::symbol(['symbol' => ['buch']]));
}
public function test_the_brush_needs_the_exact_value(): void
{
$this->assertTrue(HeadingAccent::hasBrush(['accent' => 'brush']));
$this->assertFalse(HeadingAccent::hasBrush(['accent' => 'rays']));
$this->assertFalse(HeadingAccent::hasBrush([]));
}
}
+1 -1
View File
@@ -28,7 +28,7 @@ public function test_all_configured_widgets_are_registered_with_complete_contrac
$types = $this->registry()->all(); $types = $this->registry()->all();
$this->assertSame( $this->assertSame(
['hero', 'heading', 'prose', 'image_text', 'cards', 'catalog_cards', 'topic_card', 'media_card', 'program_card', 'call_to_action', 'faq'], ['hero', 'heading', 'prose', 'image_text', 'cards', 'features', 'catalog_cards', 'topic_card', 'media_card', 'program_card', 'call_to_action', 'faq'],
array_keys($types), array_keys($types),
); );