Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90c74ac03d | ||
|
|
b714dc8219 | ||
|
|
b7502ef696 | ||
|
|
45ea56b52d | ||
|
|
09889da099 | ||
|
|
3c7a71532f | ||
|
|
ad581cb545 | ||
|
|
99122ddfee | ||
|
|
9fbd933e1e | ||
|
|
be24f3bf64 | ||
|
|
4584dcd013 | ||
|
|
cf8189623c | ||
|
|
9140e731f9 | ||
|
|
bb08b9b3fa | ||
|
|
e5b3eea7de | ||
|
|
b901b02cce | ||
|
|
79998f6347 | ||
|
|
26ca79cd22 | ||
|
|
bcda189267 | ||
|
|
bc140a0e83 | ||
|
|
ad03eee41f | ||
|
|
0022fd50cb | ||
|
|
1d1f0ebb1f |
No files matched your search
@@ -71,6 +71,7 @@ MEDIA_PUBLIC_PATH=
|
|||||||
MEDIA_DERIVED_PATH=
|
MEDIA_DERIVED_PATH=
|
||||||
MEDIA_ORIGINALS_PATH=
|
MEDIA_ORIGINALS_PATH=
|
||||||
|
|
||||||
# Übernahme von Übungen aus Shinkan (Test: erst nach Freigabe der Anbindung eintragen; Werte nie ins Repository)
|
# Übernahme von Übungen aus Shinkan. Die Adresse ist je Umgebung vorgegeben. Der Zugangsschlüssel kann hier stehen (hat
|
||||||
|
# Vorrang) oder in der Verwaltung hinterlegt werden (Inhalte -> Übungen aus Shinkan). Werte nie ins Repository.
|
||||||
SHINKAN_DISTRIBUTION_URL=
|
SHINKAN_DISTRIBUTION_URL=
|
||||||
SHINKAN_DISTRIBUTION_KEY=
|
SHINKAN_DISTRIBUTION_KEY=
|
||||||
@@ -41,6 +41,7 @@ ## Server und Umgebungen
|
|||||||
|
|
||||||
- Test und Prod laufen vorerst **beide auf `llm-node` (192.168.2.144)**, getrennt durch Compose-Projekt (`luf-test`, `luf-prod`), Verzeichnis, Env-Datei, Volumes und Zugangsdaten. Der Raspberry Pi ist als späteres Testsystem vorgesehen (Umzug über die Variablen in `deploy-test.yml`).
|
- Test und Prod laufen vorerst **beide auf `llm-node` (192.168.2.144)**, getrennt durch Compose-Projekt (`luf-test`, `luf-prod`), Verzeichnis, Env-Datei, Volumes und Zugangsdaten. Der Raspberry Pi ist als späteres Testsystem vorgesehen (Umzug über die Variablen in `deploy-test.yml`).
|
||||||
- Secrets liegen nur in `/etc/luf/test.env` und `/etc/luf/prod.env` auf dem Server. **Keine Secrets, Passwörter, Keys oder `.env`-Dateien ins Repo, in Commits, Logs oder Chat-Ausgaben.**
|
- Secrets liegen nur in `/etc/luf/test.env` und `/etc/luf/prod.env` auf dem Server. **Keine Secrets, Passwörter, Keys oder `.env`-Dateien ins Repo, in Commits, Logs oder Chat-Ausgaben.**
|
||||||
|
- **Ausnahme Shinkan-Zugangsschlüssel (ADR-49, Nachtrag vom 23.11.2026):** Dieser eine Schlüssel darf zusätzlich von Katalog- und Systemverwaltern in der Verwaltung hinterlegt werden (Inhalte → Übungen aus Shinkan). Er liegt je Umgebung getrennt mit dem Anwendungsschlüssel verschlüsselt in der Datenbank, wird nie angezeigt, zurückgegeben oder protokolliert. Ein Wert in `SHINKAN_DISTRIBUTION_KEY` (Serverdatei) hat Vorrang. Die Adresse (`SHINKAN_DISTRIBUTION_URL`) bleibt je Umgebung in der Serverdatei. Für alle anderen Schlüssel gilt die Regel unverändert.
|
||||||
- **Auf Servern wird nur nach ausdrücklicher Freigabe geschrieben.** Rein lesende Abfragen über vorhandene SSH-Zugänge sind erlaubt. Keine SSH-Schlüssel, Benutzer, Firewall-, Proxy- oder Runner-Änderungen. Andere Anwendungen auf den Servern (Shinkan, Gitea, mindnet, qdrant, …) dürfen nicht verändert werden.
|
- **Auf Servern wird nur nach ausdrücklicher Freigabe geschrieben.** Rein lesende Abfragen über vorhandene SSH-Zugänge sind erlaubt. Keine SSH-Schlüssel, Benutzer, Firewall-, Proxy- oder Runner-Änderungen. Andere Anwendungen auf den Servern (Shinkan, Gitea, mindnet, qdrant, …) dürfen nicht verändert werden.
|
||||||
- Ports werden nicht geraten: Vor jedem neuen Host-Port die tatsächliche Belegung prüfen (`ss`, `docker ps`). Aktuell vorgesehen: Test 3011, Prod 3010 (Stand 2026-11-15). Datenbank und PHP-FPM veröffentlichen keine Host-Ports.
|
- Ports werden nicht geraten: Vor jedem neuen Host-Port die tatsächliche Belegung prüfen (`ss`, `docker ps`). Aktuell vorgesehen: Test 3011, Prod 3010 (Stand 2026-11-15). Datenbank und PHP-FPM veröffentlichen keine Host-Ports.
|
||||||
- Der Reverse Proxy (Synology NAS) wird von Lars verwaltet.
|
- Der Reverse Proxy (Synology NAS) wird von Lars verwaltet.
|
||||||
@@ -64,5 +65,7 @@ ## 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.
|
||||||
|
- Filter mit Mehrfachauswahl in Bestandslisten (z. B. Medienmanager): Baustein `verwaltung/bestand-filterdialog` über den Eintrag `filterdialog` in `bestand()` (Filterknopf neben der Suche, Pillen je wirksamem Feld, Dialog mit Entwurf der Auswahl: „Anwenden“ übernimmt, „Abbrechen“ verwirft). Mehrere Werte eines Felds gelten als ODER, verschiedene Felder als UND. Die Häkchen sind per `wire:model` an eine Liste im Entwurf gebunden (nie `wire:click` mit `@checked`: nach einer Serverantwort stimmt sonst die Anzeige nicht). Persönliche Standardfilter je Konto liegen in `user_view_defaults` (`UserViewDefault`). Texte, die für eine Übung angelegt werden, erhalten über `ExerciseSections::mark` die Materialart „Übungsabschnitt“ und den Verweis auf ihre Übung.
|
||||||
- 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`.
|
||||||
@@ -32,6 +32,7 @@ class ContentElement extends Model
|
|||||||
'editorial_content_kind_id',
|
'editorial_content_kind_id',
|
||||||
'archived_at',
|
'archived_at',
|
||||||
'source_ref',
|
'source_ref',
|
||||||
|
'origin_composition_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected function casts(): array
|
protected function casts(): array
|
||||||
@@ -47,6 +48,12 @@ public function editorialContentKind(): BelongsTo
|
|||||||
return $this->belongsTo(EditorialContentKind::class);
|
return $this->belongsTo(EditorialContentKind::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Die Übung, für die dieser Textabschnitt angelegt wurde (nur bei Übungsabschnitten). */
|
||||||
|
public function originComposition(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Composition::class, 'origin_composition_id');
|
||||||
|
}
|
||||||
|
|
||||||
public function versions(): HasMany
|
public function versions(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(ContentElementVersion::class);
|
return $this->hasMany(ContentElementVersion::class);
|
||||||
|
|||||||
@@ -27,7 +27,13 @@ class EditorialContentKind extends Model
|
|||||||
* Modulen (programm, modul), Vertraulichkeit von Traineranleitungen (traineranleitung). Ihre Bezeichnung bleibt
|
* Modulen (programm, modul), Vertraulichkeit von Traineranleitungen (traineranleitung). Ihre Bezeichnung bleibt
|
||||||
* pflegbar; deaktivieren, Kontexte ändern und löschen sind gesperrt.
|
* pflegbar; deaktivieren, Kontexte ändern und löschen sind gesperrt.
|
||||||
*/
|
*/
|
||||||
public const SYSTEM_SLUGS = ['programm', 'modul', 'uebung', 'traineranleitung'];
|
public const SYSTEM_SLUGS = ['programm', 'modul', 'uebung', 'traineranleitung', self::EXERCISE_SECTION_SLUG];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Textabschnitte einer Übung. Die Materialart wird nur automatisch gesetzt (ExerciseSections) und hat deshalb
|
||||||
|
* keinen wählbaren Kontext.
|
||||||
|
*/
|
||||||
|
public const EXERCISE_SECTION_SLUG = 'uebungsabschnitt';
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'slug',
|
'slug',
|
||||||
@@ -74,6 +80,12 @@ public function allows(string $context): bool
|
|||||||
return in_array($context, (array) ($this->contexts ?? []), true);
|
return in_array($context, (array) ($this->contexts ?? []), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Wird nie von Hand gewählt, sondern von der Übungsverwaltung gesetzt. */
|
||||||
|
public function isAutomatic(): bool
|
||||||
|
{
|
||||||
|
return $this->slug === self::EXERCISE_SECTION_SLUG;
|
||||||
|
}
|
||||||
|
|
||||||
public function isSystem(): bool
|
public function isSystem(): bool
|
||||||
{
|
{
|
||||||
return in_array($this->slug, self::SYSTEM_SLUGS, true);
|
return in_array($this->slug, self::SYSTEM_SLUGS, true);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -124,10 +124,52 @@ public function kindFilterOptions(string $context, string $selected = ''): array
|
|||||||
|
|
||||||
public function kindLabel(EditorialContentKind $kind, string $context): string
|
public function kindLabel(EditorialContentKind $kind, string $context): string
|
||||||
{
|
{
|
||||||
|
// Die automatische Art hat bewusst keinen wählbaren Kontext; das ist kein Mangel der Zuordnung.
|
||||||
|
if ($kind->isAutomatic() && $kind->is_active) {
|
||||||
|
return (string) $kind->label;
|
||||||
|
}
|
||||||
|
|
||||||
return (string) $kind->label
|
return (string) $kind->label
|
||||||
.(! $kind->is_active ? self::INACTIVE_SUFFIX : (! $kind->allows($context) ? self::OUT_OF_CONTEXT_SUFFIX : ''));
|
.(! $kind->is_active ? self::INACTIVE_SUFFIX : (! $kind->allows($context) ? self::OUT_OF_CONTEXT_SUFFIX : ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Materialarten für die Mehrfachauswahl im Medienmanager: im Kontext zulässige Arten, Arten, die bei Medien
|
||||||
|
* tatsächlich vorkommen, und die automatische Art „Übungsabschnitt“. Die Reihenfolge folgt der Pflege, die
|
||||||
|
* automatische Art steht zuletzt. „Ohne Materialart“ ergänzt der Medienmanager.
|
||||||
|
*
|
||||||
|
* @param list<int> $selectedIds bereits gewählte Arten bleiben sichtbar
|
||||||
|
* @return list<array{id: int, label: string, automatic: bool}>
|
||||||
|
*/
|
||||||
|
public function mediumKindChoices(array $selectedIds = []): array
|
||||||
|
{
|
||||||
|
$used = $this->usedKindIds('medium');
|
||||||
|
$regular = [];
|
||||||
|
$automatic = [];
|
||||||
|
|
||||||
|
foreach (EditorialContentKind::query()->orderBy('sort_order')->orderBy('id')->get() as $kind) {
|
||||||
|
$id = (int) $kind->id;
|
||||||
|
$show = $kind->isAutomatic()
|
||||||
|
|| ($kind->allows('medium') && $kind->is_active)
|
||||||
|
|| in_array($id, $used, true)
|
||||||
|
|| in_array($id, $selectedIds, true);
|
||||||
|
|
||||||
|
if (! $show) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = ['id' => $id, 'label' => $this->kindLabel($kind, 'medium'), 'automatic' => $kind->isAutomatic()];
|
||||||
|
|
||||||
|
if ($kind->isAutomatic()) {
|
||||||
|
$automatic[] = $row;
|
||||||
|
} else {
|
||||||
|
$regular[] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...$regular, ...$automatic];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return list<int>
|
* @return list<int>
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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);
|
$this->room(14);
|
||||||
|
$this->pdf->text(self::LEFT + 4, $this->y, $marker($index + 1), 10.5);
|
||||||
foreach ($lines as $line => $text) {
|
$this->runs($item, self::LEFT + 18, 10.5, after: 1);
|
||||||
$this->room(14);
|
|
||||||
|
|
||||||
if ($line === 0) {
|
|
||||||
$this->pdf->text(self::LEFT + 4, $this->y, $marker($index + 1), 10.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
$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) {
|
||||||
|
|||||||
@@ -0,0 +1,132 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Übungsabschnitte: Textabschnitte, die für eine bestimmte Übung angelegt wurden, im Übungseditor oder bei der
|
||||||
|
* Übernahme aus Shinkan. Sie liegen im gemeinsamen Medienbestand und tragen dort die Materialart „Übungsabschnitt“
|
||||||
|
* und einen Verweis auf ihre Übung (`origin_composition_id`). Die Texte nutzen die gemeinsame Inhalts- und
|
||||||
|
* Fassungsverwaltung; bearbeitet werden sie im Übungseditor.
|
||||||
|
*/
|
||||||
|
final class ExerciseSections
|
||||||
|
{
|
||||||
|
public const KIND_SLUG = EditorialContentKind::EXERCISE_SECTION_SLUG;
|
||||||
|
|
||||||
|
public function kindId(): ?int
|
||||||
|
{
|
||||||
|
$id = EditorialContentKind::query()->where('slug', self::KIND_SLUG)->value('id');
|
||||||
|
|
||||||
|
return $id === null ? null : (int) $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ordnet einen Abschnitt seiner Übung zu und gibt ihm die Materialart. Eine bereits gesetzte Materialart bleibt:
|
||||||
|
* Sie ist eine bewusste Einordnung der Redaktion.
|
||||||
|
*/
|
||||||
|
public function mark(ContentElement $element, Composition $exercise): void
|
||||||
|
{
|
||||||
|
$element->origin_composition_id = $exercise->getKey();
|
||||||
|
|
||||||
|
if ($element->editorial_content_kind_id === null) {
|
||||||
|
$element->editorial_content_kind_id = $this->kindId();
|
||||||
|
}
|
||||||
|
|
||||||
|
$element->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ordnet vorhandene Texte nur dann zu, wenn ihre Herkunft belegt ist:
|
||||||
|
*
|
||||||
|
* - Ein Abschnitt aus der Übernahme aus Shinkan (`source_ref` = `shinkan:<Quell-ID>:<Feld>`) gehört zur lokalen
|
||||||
|
* Übung dieser Quelle.
|
||||||
|
* - Ein anderer Text gilt als Abschnitt, wenn er ohne Materialart ist, ausschließlich in genau einer Übung
|
||||||
|
* vorkommt und nirgends in einem Modul oder Programm direkt verwendet wird.
|
||||||
|
*
|
||||||
|
* Ein bereits gesetzter Materialtyp bleibt in jedem Fall erhalten, ebenso unklare Fälle.
|
||||||
|
*
|
||||||
|
* @return int Anzahl der Texte, die jetzt einer Übung zugeordnet sind
|
||||||
|
*/
|
||||||
|
public function backfill(): int
|
||||||
|
{
|
||||||
|
$kindId = $this->kindId();
|
||||||
|
|
||||||
|
if ($kindId === null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$assigned = 0;
|
||||||
|
|
||||||
|
foreach ($this->fromSource() + $this->fromUse() as $elementId => $compositionId) {
|
||||||
|
DB::table('content_elements')->where('id', $elementId)->whereNull('origin_composition_id')->update(['origin_composition_id' => $compositionId]);
|
||||||
|
DB::table('content_elements')->where('id', $elementId)->whereNull('editorial_content_kind_id')->update(['editorial_content_kind_id' => $kindId]);
|
||||||
|
$assigned++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $assigned;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, int> Element-ID => Übung
|
||||||
|
*/
|
||||||
|
private function fromSource(): array
|
||||||
|
{
|
||||||
|
$byRef = [];
|
||||||
|
|
||||||
|
foreach (DB::table('exercise_sources')->whereNotNull('composition_id')->get(['source_id', 'composition_id']) as $source) {
|
||||||
|
$byRef[(string) $source->source_id] = (int) $source->composition_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$found = [];
|
||||||
|
|
||||||
|
foreach (DB::table('content_elements')->where('output_class', 'text')->where('source_ref', 'like', 'shinkan:%')->get(['id', 'source_ref']) as $element) {
|
||||||
|
$parts = explode(':', (string) $element->source_ref);
|
||||||
|
|
||||||
|
if (count($parts) === 3 && isset($byRef[$parts[1]])) {
|
||||||
|
$found[(int) $element->id] = $byRef[$parts[1]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $found;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, int> Element-ID => Übung
|
||||||
|
*/
|
||||||
|
private function fromUse(): array
|
||||||
|
{
|
||||||
|
$exerciseKind = CompositionKind::Exercise->value;
|
||||||
|
$uses = DB::table('composition_members as m')
|
||||||
|
->join('content_element_versions as v', 'v.id', '=', 'm.content_element_version_id')
|
||||||
|
->join('content_elements as e', 'e.id', '=', 'v.content_element_id')
|
||||||
|
->join('composition_versions as cv', 'cv.id', '=', 'm.composition_version_id')
|
||||||
|
->join('compositions as c', 'c.id', '=', 'cv.composition_id')
|
||||||
|
->where('e.output_class', 'text')
|
||||||
|
->whereNull('e.editorial_content_kind_id')
|
||||||
|
->whereNull('e.origin_composition_id')
|
||||||
|
->select('e.id as element_id', 'c.id as composition_id', 'c.kind as composition_kind')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$exercises = [];
|
||||||
|
$elsewhere = [];
|
||||||
|
|
||||||
|
foreach ($uses as $use) {
|
||||||
|
if ($use->composition_kind === $exerciseKind) {
|
||||||
|
$exercises[(int) $use->element_id][(int) $use->composition_id] = true;
|
||||||
|
} else {
|
||||||
|
$elsewhere[(int) $use->element_id] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$found = [];
|
||||||
|
|
||||||
|
foreach ($exercises as $elementId => $compositions) {
|
||||||
|
if (count($compositions) === 1 && ! isset($elsewhere[$elementId])) {
|
||||||
|
$found[$elementId] = array_key_first($compositions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $found;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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, Ereignisattribute
|
||||||
|
* 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),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Material-Tags des Brand-Kits (Film, Übung, PDF, Paket, Film + Übungen, Film + Merkblatt).
|
||||||
|
*
|
||||||
|
* Die Zuordnung hängt an Schlüsseln (Ausgabeklasse des Mediums, Kennung der redaktionellen Art), nie an Beschriftungen.
|
||||||
|
* Was nicht eindeutig zuzuordnen ist, bekommt kein Tag und bleibt Text:
|
||||||
|
* - „Paket“ und die beiden Kombinationen werden nicht automatisch vergeben (offen: Paket als Angebot oder als Programm;
|
||||||
|
* Kombinationen aus dem Modulaufbau berechnen oder redaktionell wählen). Die Komponente kann sie darstellen.
|
||||||
|
* - „Dokument“ ist nicht automatisch PDF; das Tag PDF gibt es nur für die Ausgabeklasse „pdf“.
|
||||||
|
*/
|
||||||
|
enum MaterialTag: string
|
||||||
|
{
|
||||||
|
case Film = 'film';
|
||||||
|
case Uebung = 'uebung';
|
||||||
|
case Pdf = 'pdf';
|
||||||
|
case Paket = 'paket';
|
||||||
|
case FilmUebungen = 'film-uebungen';
|
||||||
|
case FilmMerkblatt = 'film-merkblatt';
|
||||||
|
|
||||||
|
private const FILM_KINDS = ['unterrichtsfilm', 'kurzfilm', 'trailer', 'interview'];
|
||||||
|
|
||||||
|
private const EXERCISE_KINDS = ['arbeitsblatt', 'uebungsbeschreibung'];
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::Film => 'Film',
|
||||||
|
self::Uebung => 'Übung',
|
||||||
|
self::Pdf => 'PDF',
|
||||||
|
self::Paket => 'Paket',
|
||||||
|
self::FilmUebungen => 'Film + Übungen',
|
||||||
|
self::FilmMerkblatt => 'Film + Merkblatt',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Name des Zeichens im Satz „glyphen“ (resources/svg/brand/glyphen). */
|
||||||
|
public function glyph(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::Film => 'film',
|
||||||
|
self::Uebung => 'uebung',
|
||||||
|
self::Pdf, self::FilmMerkblatt => 'dokument',
|
||||||
|
self::Paket => 'paket',
|
||||||
|
self::FilmUebungen => 'filmstreifen',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromContent(?string $outputClass, ?string $editorialKindSlug = null): ?self
|
||||||
|
{
|
||||||
|
return match (true) {
|
||||||
|
$outputClass === 'film' => self::Film,
|
||||||
|
$outputClass === 'pdf' => self::Pdf,
|
||||||
|
in_array($editorialKindSlug, self::FILM_KINDS, true) => self::Film,
|
||||||
|
in_array($editorialKindSlug, self::EXERCISE_KINDS, true) => self::Uebung,
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use App\Domain\Design\SiteSetting;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Contracts\Encryption\DecryptException;
|
||||||
|
use Illuminate\Support\Facades\Crypt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zugang zum Shinkan-Katalog. Die Adresse ist je Umgebung vorgegeben (`SHINKAN_DISTRIBUTION_URL`). Der Zugangsschlüssel
|
||||||
|
* kommt aus der Umgebung des Servers (`SHINKAN_DISTRIBUTION_KEY`, hat Vorrang und bleibt die bestehende Anbindung) oder
|
||||||
|
* ist in der Verwaltung hinterlegt. So lässt sich der Schlüssel ersetzen, ohne die Umgebung des Servers anzufassen.
|
||||||
|
*
|
||||||
|
* Der in der Verwaltung hinterlegte Schlüssel liegt je Umgebung getrennt und mit dem Anwendungsschlüssel verschlüsselt in
|
||||||
|
* den Einstellungen. Er wird nie zurückgegeben, nie angezeigt und nie protokolliert und steht in keiner Fehlermeldung.
|
||||||
|
*/
|
||||||
|
final class ShinkanConnection
|
||||||
|
{
|
||||||
|
public const SETTING = 'shinkan.anbindung';
|
||||||
|
|
||||||
|
public const SERVER = 'server';
|
||||||
|
|
||||||
|
public const ADMIN = 'verwaltung';
|
||||||
|
|
||||||
|
public function url(): ?string
|
||||||
|
{
|
||||||
|
$value = config('services.shinkan.url');
|
||||||
|
|
||||||
|
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
|
||||||
|
{
|
||||||
|
$server = $this->serverKey();
|
||||||
|
|
||||||
|
if ($server !== null) {
|
||||||
|
return $server;
|
||||||
|
}
|
||||||
|
|
||||||
|
$encrypted = $this->stored()['key'] ?? null;
|
||||||
|
|
||||||
|
if (! is_string($encrypted) || $encrypted === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return Crypt::decryptString($encrypted);
|
||||||
|
} catch (DecryptException) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Woher kommt der Schlüssel? `server`, `verwaltung` oder null.
|
||||||
|
*/
|
||||||
|
public function keySource(): ?string
|
||||||
|
{
|
||||||
|
if ($this->serverKey() !== null) {
|
||||||
|
return self::SERVER;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->apiKey() !== null ? self::ADMIN : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function configured(): bool
|
||||||
|
{
|
||||||
|
return $this->url() !== null && $this->apiKey() !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hinterlegt oder ersetzt den Schlüssel. Der Schlüssel aus der Umgebung des Servers behält den Vorrang.
|
||||||
|
*/
|
||||||
|
public function saveKey(string $key, ?User $by = null): void
|
||||||
|
{
|
||||||
|
$key = trim($key);
|
||||||
|
|
||||||
|
if ($key === '') {
|
||||||
|
throw new DomainRuleException('Der Zugangsschlüssel fehlt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->write(['key' => Crypt::encryptString($key)], $by);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function forgetKey(?User $by = null): void
|
||||||
|
{
|
||||||
|
$this->write([], $by);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
private function stored(): array
|
||||||
|
{
|
||||||
|
$value = SiteSetting::query()->find(self::SETTING)?->value;
|
||||||
|
|
||||||
|
return is_array($value) ? $value : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $stored
|
||||||
|
*/
|
||||||
|
private function write(array $stored, ?User $by): void
|
||||||
|
{
|
||||||
|
SiteSetting::query()->updateOrCreate(['key' => self::SETTING], ['value' => $stored, 'updated_by' => $by?->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function serverKey(): ?string
|
||||||
|
{
|
||||||
|
$value = config('services.shinkan.key');
|
||||||
|
|
||||||
|
return is_string($value) && trim($value) !== '' ? trim($value) : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,26 +15,85 @@
|
|||||||
* Grundsätze:
|
* Grundsätze:
|
||||||
* - Die Quellübung ist an ihre stabile Kennung gebunden. Jeder Inhaltsstand (Prüfsumme der Quelle) wird genau einmal
|
* - Die Quellübung ist an ihre stabile Kennung gebunden. Jeder Inhaltsstand (Prüfsumme der Quelle) wird genau einmal
|
||||||
* festgehalten; ein wiederholter Abruf erzeugt nichts Neues.
|
* festgehalten; ein wiederholter Abruf erzeugt nichts Neues.
|
||||||
* - Eine lokale Fassung entsteht nur durch die bewusste Übernahme ({@see adopt}) und ist danach unveränderlich. Lokale
|
* - Eine lokale Fassung entsteht nur durch die bewusste Übernahme ({@see adoptPreviewed}) und ist danach unveränderlich.
|
||||||
* Ergänzungen (Herkunft „lokal“) bleiben bei einer neuen Quellfassung erhalten.
|
* Lokale Ergänzungen (Herkunft „lokal“) bleiben bei einer neuen Quellfassung erhalten. Entfällt die Quellvariante einer
|
||||||
|
* lokalen Ergänzung, legt die Redaktion die neue Zuordnung fest.
|
||||||
* - Das Ausblenden an der Quelle setzt nur die Verfügbarkeit. Lokale Fassungen und Verwendungen bleiben unberührt; eine
|
* - Das Ausblenden an der Quelle setzt nur die Verfügbarkeit. Lokale Fassungen und Verwendungen bleiben unberührt; eine
|
||||||
* rechtliche Sperre ist der lokale `block`.
|
* rechtliche Sperre ist der lokale `block`. Ausgeblendete Quellen sind von der Übernahme ausgeschlossen.
|
||||||
* - Medien des Katalogs sind Metadaten ohne Datei. Sie begründen weder eine Ausgabe noch eine Nutzungsberechtigung und
|
* - Medien des Katalogs sind Metadaten ohne Datei. Sie begründen weder eine Ausgabe noch eine Nutzungsberechtigung und
|
||||||
* stehen nie in einem Artikel-Stand.
|
* stehen nie in einem Artikel-Stand.
|
||||||
* - Ein fehlgeschlagener Abruf verändert den gespeicherten Stand nicht und rückt den Cursor nicht vor.
|
* - Ein fehlgeschlagener Abruf verändert den gespeicherten Stand nicht und rückt den Cursor nicht vor.
|
||||||
*/
|
*/
|
||||||
class ShinkanImport
|
class ShinkanImport
|
||||||
{
|
{
|
||||||
/** Abschnitte der Quelle in Lesereihenfolge: Feld => [Bezeichnung, Rolle]. */
|
/** Abschnitte der Quelle in Lesereihenfolge: Feld => Bezeichnung. */
|
||||||
private const SECTIONS = [
|
public const SECTIONS = [
|
||||||
'preparation' => 'Vorbereitung',
|
'preparation' => 'Vorbereitung',
|
||||||
'execution' => 'Durchführung',
|
'execution' => 'Durchführung',
|
||||||
'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 filled(config('services.shinkan.url')) && filled(config('services.shinkan.key'));
|
return app(ShinkanConnection::class)->configured();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zustand der Anbindung ohne Werte: ob Adresse und Schlüssel vorhanden sind und woher der Schlüssel kommt.
|
||||||
|
*
|
||||||
|
* @return array{url: bool, key: bool, host: string|null, key_source: string|null}
|
||||||
|
*/
|
||||||
|
public function status(): array
|
||||||
|
{
|
||||||
|
$connection = app(ShinkanConnection::class);
|
||||||
|
$url = $connection->url();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'url' => $url !== null,
|
||||||
|
'key' => $connection->apiKey() !== null,
|
||||||
|
'host' => $url !== null ? (parse_url($url, PHP_URL_HOST) ?: null) : null,
|
||||||
|
'key_source' => $connection->keySource(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verbindung prüfen, ohne etwas zu speichern. Mit `$candidateKey` wird ein noch nicht hinterlegter Schlüssel
|
||||||
|
* geprüft. Der Katalogabruf legt auf der Seite von Shinkan einen Stand an; hier wird nur gezählt.
|
||||||
|
*
|
||||||
|
* @return array{ok: bool, message: string}
|
||||||
|
*/
|
||||||
|
public function check(?string $candidateKey = null): array
|
||||||
|
{
|
||||||
|
$connection = app(ShinkanConnection::class);
|
||||||
|
$key = filled($candidateKey) ? trim((string) $candidateKey) : $connection->apiKey();
|
||||||
|
|
||||||
|
if ($connection->url() === null || $key === null) {
|
||||||
|
return ['ok' => false, 'message' => 'Die Anbindung ist nicht eingerichtet. Adresse oder Zugangsschlüssel fehlen.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$catalog = $this->get('/catalog', [], $key);
|
||||||
|
} catch (Throwable $exception) {
|
||||||
|
return ['ok' => false, 'message' => 'Die Verbindung ist fehlgeschlagen: '.$this->plain($exception)];
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = count((array) ($catalog['exercises'] ?? []));
|
||||||
|
|
||||||
|
return ['ok' => true, 'message' => 'Die Verbindung funktioniert. Die Quelle stellt '.$count.($count === 1 ? ' Übung' : ' Übungen').' bereit. Es wurde nichts übernommen.'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fetch(): ExerciseImportRun
|
public function fetch(): ExerciseImportRun
|
||||||
@@ -42,7 +101,7 @@ public function fetch(): ExerciseImportRun
|
|||||||
$run = ExerciseImportRun::query()->create(['status' => 'laeuft', 'started_at' => now()]);
|
$run = ExerciseImportRun::query()->create(['status' => 'laeuft', 'started_at' => now()]);
|
||||||
|
|
||||||
if (! $this->configured()) {
|
if (! $this->configured()) {
|
||||||
return $this->finish($run, 'fehler', error: 'Die Anbindung ist nicht eingerichtet. Adresse und Schlüssel fehlen in der Umgebung.');
|
return $this->finish($run, 'fehler', error: 'Die Anbindung ist nicht eingerichtet. Adresse oder Zugangsschlüssel fehlen.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$previous = ExerciseImportRun::query()->where('status', 'ok')->orderByDesc('id')->value('cursor');
|
$previous = ExerciseImportRun::query()->where('status', 'ok')->orderByDesc('id')->value('cursor');
|
||||||
@@ -142,10 +201,234 @@ public function state(ExerciseSource $source): string
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Die bewusste Übernahme: aus dem Inhaltsstand wird eine neue, unveränderliche lokale Fassung. Wiederholt man sie,
|
* Vorschau der geplanten Übernahme: verfügbare Texte, Varianten und Medienhinweise, bei einer neuen Quellfassung die
|
||||||
* entsteht keine zweite Fassung. Lokale Ergänzungen der bisherigen Fassung werden übernommen.
|
* fachlich relevanten Änderungen zur zuletzt übernommenen Fassung und offene Zuordnungen lokaler Ergänzungen.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function adopt(ExerciseSourceSnapshot $snapshot, ?User $actor = null): CompositionVersion
|
public function preview(ExerciseSource $source): array
|
||||||
|
{
|
||||||
|
$snapshot = $source->latestSnapshot();
|
||||||
|
$state = $this->state($source);
|
||||||
|
$document = $snapshot?->payload ?? [];
|
||||||
|
$previous = $this->lastAdopted($source);
|
||||||
|
$sections = [];
|
||||||
|
|
||||||
|
foreach (self::SECTIONS as $field => $label) {
|
||||||
|
if ($this->value($document, $field) !== '') {
|
||||||
|
$sections[] = ['label' => $label, 'text' => FormattedText::excerpt($this->value($document, $field), 280)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'source' => $source->id,
|
||||||
|
'snapshot' => $snapshot?->id,
|
||||||
|
'hash' => $snapshot?->content_hash,
|
||||||
|
'state' => $state,
|
||||||
|
'title' => (string) ($document['title'] ?? $source->title),
|
||||||
|
'summary' => FormattedText::plain($this->value($document, 'summary')),
|
||||||
|
'goal' => FormattedText::plain($this->value($document, 'goal')),
|
||||||
|
'duration' => $this->duration($document),
|
||||||
|
'equipment' => FormattedText::plain($this->value($document, 'equipment')),
|
||||||
|
'sections' => $sections,
|
||||||
|
'variants' => array_map(fn (array $variant): array => [
|
||||||
|
'key' => (string) ($variant['id'] ?? ''),
|
||||||
|
'name' => (string) ($variant['name'] ?? ''),
|
||||||
|
'description' => (string) ($variant['description'] ?? ''),
|
||||||
|
'changes' => $this->variantChanges($document, $variant) !== '',
|
||||||
|
], 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'))),
|
||||||
|
'changes' => $previous === null ? [] : $this->changes($previous->payload, $document, $source),
|
||||||
|
'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,
|
||||||
|
'excluded' => $source->availability === ExerciseSource::WITHDRAWN,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fachlich relevante Änderungen einer neuen Quellfassung zur zuletzt übernommenen.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $before
|
||||||
|
* @param array<string, mixed> $after
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public function changes(array $before, array $after, ?ExerciseSource $source = null): array
|
||||||
|
{
|
||||||
|
$lines = [];
|
||||||
|
$labels = [
|
||||||
|
'title' => 'Titel', 'summary' => 'Kurzbeschreibung', 'goal' => 'Lernziel', 'equipment' => 'Ausstattung',
|
||||||
|
'duration_min' => 'Dauer (von)', 'duration_max' => 'Dauer (bis)',
|
||||||
|
] + self::SECTIONS;
|
||||||
|
|
||||||
|
foreach ($labels as $field => $label) {
|
||||||
|
if (! $this->sameValue($field, $before, $after)) {
|
||||||
|
$lines[] = $label.' geändert';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$old = collect((array) ($before['variants'] ?? []))->keyBy(fn (array $variant): string => (string) ($variant['id'] ?? ''));
|
||||||
|
$new = collect((array) ($after['variants'] ?? []))->keyBy(fn (array $variant): string => (string) ($variant['id'] ?? ''));
|
||||||
|
|
||||||
|
foreach ($new->diffKeys($old) as $variant) {
|
||||||
|
$lines[] = 'Variante „'.($variant['name'] ?? '').'“ neu';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($old->diffKeys($new) as $variant) {
|
||||||
|
$lines[] = 'Variante „'.($variant['name'] ?? '').'“ entfällt';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($new->intersectByKeys($old) as $key => $variant) {
|
||||||
|
if (($variant['name'] ?? '') !== ($old[$key]['name'] ?? '')) {
|
||||||
|
$lines[] = 'Variante „'.($old[$key]['name'] ?? '').'“ heißt jetzt „'.($variant['name'] ?? '').'“';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trim((string) ($variant['description'] ?? '')) !== trim((string) ($old[$key]['description'] ?? ''))
|
||||||
|
|| ! FormattedText::same($this->variantChanges($after, $variant), $this->variantChanges($before, (array) $old[$key]))) {
|
||||||
|
$lines[] = 'Variante „'.($variant['name'] ?? '').'“ geändert';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$common = $old->keys()->intersect($new->keys())->values()->all();
|
||||||
|
|
||||||
|
if ($common !== [] && $common !== $new->keys()->intersect($old->keys())->values()->all()) {
|
||||||
|
$lines[] = 'Reihenfolge der Varianten geändert';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($source?->composition !== null) {
|
||||||
|
if (($before['title'] ?? '') !== ($after['title'] ?? '') && $source->composition->designation !== ($before['title'] ?? '')) {
|
||||||
|
$lines[] = 'Der Titel wurde lokal geändert und bleibt unverändert';
|
||||||
|
}
|
||||||
|
|
||||||
|
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';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $lines;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lokal ergänzte Bestandteile, die einer Quellvariante zugeordnet sind, die die neue Quellfassung nicht mehr kennt.
|
||||||
|
* Die Redaktion legt deren neue Zuordnung fest.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $document
|
||||||
|
* @return list<array{key: string, name: string, members: list<string>}>
|
||||||
|
*/
|
||||||
|
public function conflicts(ExerciseSource $source, array $document): array
|
||||||
|
{
|
||||||
|
$latest = $source->composition?->versions()->orderByDesc('number')->with('members.variant', 'variants')->first();
|
||||||
|
|
||||||
|
if ($latest === null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$keep = array_merge(
|
||||||
|
array_map(fn (array $variant): string => (string) ($variant['id'] ?? ''), array_filter((array) ($document['variants'] ?? []), 'is_array')),
|
||||||
|
$latest->variants->where('origin', 'lokal')->pluck('key')->all(),
|
||||||
|
);
|
||||||
|
$open = [];
|
||||||
|
|
||||||
|
foreach ($latest->members->where('origin', 'lokal') as $member) {
|
||||||
|
$key = $member->variant?->key;
|
||||||
|
|
||||||
|
if ($key !== null && ! in_array($key, $keep, true)) {
|
||||||
|
$open[$key]['key'] = $key;
|
||||||
|
$open[$key]['name'] = $member->variant->name;
|
||||||
|
$open[$key]['members'][] = $member->role;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
* 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> $choices bei lokal und in der Quelle geänderten Angaben: Schlüssel => `lokal` oder `quelle`
|
||||||
|
* @return array{status: string, message: string, version?: CompositionVersion}
|
||||||
|
*/
|
||||||
|
public function adoptPreviewed(ExerciseSource $source, int $previewedSnapshot, array $reassign = [], ?User $actor = null, array $choices = []): array
|
||||||
|
{
|
||||||
|
$source->refresh();
|
||||||
|
$latest = $source->latestSnapshot();
|
||||||
|
|
||||||
|
if ($source->availability === ExerciseSource::WITHDRAWN) {
|
||||||
|
return ['status' => 'ausgeschlossen', 'message' => 'Die Quelle stellt diese Übung nicht mehr bereit. Sie wird nicht übernommen.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($latest === null || $latest->id !== $previewedSnapshot) {
|
||||||
|
return ['status' => 'geaendert', 'message' => 'Der Quellstand hat sich seit der Vorschau geändert. Prüfe die aktualisierte Vorschau und bestätige den neuen Stand.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($latest->adopted_version_id !== null) {
|
||||||
|
return ['status' => 'unveraendert', 'message' => 'Dieser Stand ist bereits übernommen. Es entsteht keine weitere Fassung.', 'version' => $latest->adoptedVersion];
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$version = $this->adopt($latest, $actor, $reassign, $choices);
|
||||||
|
} catch (DomainRuleException $exception) {
|
||||||
|
return ['status' => 'fehler', 'message' => $exception->getMessage()];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['status' => 'uebernommen', 'message' => 'Fassung '.$version->number.' ist lokal angelegt und unveränderlich.', 'version' => $version];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die bewusste Übernahme: aus dem Inhaltsstand wird eine neue, unveränderliche lokale Fassung. Wiederholt man sie,
|
||||||
|
* 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> $choices Schlüssel => `lokal` oder `quelle`
|
||||||
|
*/
|
||||||
|
public function adopt(ExerciseSourceSnapshot $snapshot, ?User $actor = null, array $reassign = [], array $choices = []): CompositionVersion
|
||||||
{
|
{
|
||||||
$snapshot->refresh();
|
$snapshot->refresh();
|
||||||
|
|
||||||
@@ -153,65 +436,87 @@ public function adopt(ExerciseSourceSnapshot $snapshot, ?User $actor = null): Co
|
|||||||
return $snapshot->adoptedVersion;
|
return $snapshot->adoptedVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DB::transaction(function () use ($snapshot, $actor): 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';
|
||||||
$composition = $source->composition ?? $this->createComposition($title, (string) ($document['summary'] ?? ''));
|
$previousSnapshot = $this->lastAdopted($source);
|
||||||
$previous = $composition->versions()->orderByDesc('number')->with('members.variant', 'variants')->first();
|
$previousSource = $previousSnapshot?->payload ?? [];
|
||||||
|
$composition = $source->composition ?? $this->createComposition($title, $this->value($document, 'summary'));
|
||||||
|
|
||||||
|
if ($source->composition !== null && $previousSnapshot !== null) {
|
||||||
|
$this->carryOverTexts($composition, $previousSource, $document);
|
||||||
|
}
|
||||||
|
|
||||||
|
$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, $composition, $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);
|
||||||
}
|
}
|
||||||
|
|
||||||
[$localMembers, $localVariants] = $this->localAdditions($previous, array_column($variants, 'key'));
|
// 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);
|
||||||
$version = $content->publishComposition(
|
$version = $content->publishComposition(
|
||||||
$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],
|
||||||
@@ -224,14 +529,182 @@ public function adopt(ExerciseSourceSnapshot $snapshot, ?User $actor = null): Co
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* nicht lokal geändert hat; ein lokal geänderter Wert bleibt.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $before
|
||||||
|
* @param array<string, mixed> $after
|
||||||
|
*/
|
||||||
|
private function carryOverTexts(Composition $composition, array $before, array $after): void
|
||||||
|
{
|
||||||
|
if (trim((string) ($after['title'] ?? '')) !== '' && $composition->designation === ($before['title'] ?? null)) {
|
||||||
|
$composition->designation = trim((string) $after['title']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('summary', $after) && ((string) $composition->summary === '' || FormattedText::same($composition->summary, $this->value($before, 'summary')))) {
|
||||||
|
$composition->summary = $this->value($after, 'summary') ?: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$composition->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function lastAdopted(ExerciseSource $source): ?ExerciseSourceSnapshot
|
||||||
|
{
|
||||||
|
return $source->snapshots()->reorder()->whereNotNull('adopted_version_id')->orderByDesc('id')->first();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Was die Redaktion lokal ergänzt hat, bleibt bei einer neuen Quellfassung erhalten. Eine lokale Zuordnung zu einer
|
* Was die Redaktion lokal ergänzt hat, bleibt bei einer neuen Quellfassung erhalten. Eine lokale Zuordnung zu einer
|
||||||
* Quellvariante, die es nicht mehr gibt, wandert in den gemeinsamen Teil, damit nichts verloren geht.
|
* Quellvariante, die es nicht mehr gibt, braucht eine ausdrücklich festgelegte neue Zuordnung.
|
||||||
*
|
*
|
||||||
* @param list<string> $sourceVariantKeys
|
* @param list<string> $sourceVariantKeys
|
||||||
|
* @param array<string, string> $reassign
|
||||||
* @return array{0: list<array<string, mixed>>, 1: list<array<string, mixed>>}
|
* @return array{0: list<array<string, mixed>>, 1: list<array<string, mixed>>}
|
||||||
*/
|
*/
|
||||||
private function localAdditions(?CompositionVersion $previous, array $sourceVariantKeys): array
|
private function localAdditions(?CompositionVersion $previous, array $sourceVariantKeys, array $reassign): array
|
||||||
{
|
{
|
||||||
if ($previous === null) {
|
if ($previous === null) {
|
||||||
return [[], []];
|
return [[], []];
|
||||||
@@ -245,11 +718,26 @@ private function localAdditions(?CompositionVersion $previous, array $sourceVari
|
|||||||
|
|
||||||
foreach ($previous->members->where('origin', 'lokal') as $member) {
|
foreach ($previous->members->where('origin', 'lokal') as $member) {
|
||||||
$variant = $member->variant?->key;
|
$variant = $member->variant?->key;
|
||||||
|
|
||||||
|
if ($variant !== null && ! in_array($variant, $known, true)) {
|
||||||
|
if (! array_key_exists($variant, $reassign)) {
|
||||||
|
throw new DomainRuleException('Die lokale Ergänzung „'.$member->role.'“ gehört zur Quellvariante „'.$member->variant->name.'“, die es nicht mehr gibt. Lege ihre neue Zuordnung fest.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$target = (string) $reassign[$variant];
|
||||||
|
|
||||||
|
if ($target !== '' && ! in_array($target, $known, true)) {
|
||||||
|
throw new DomainRuleException('Die gewählte neue Zuordnung gibt es in der neuen Fassung nicht.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$variant = $target === '' ? null : $target;
|
||||||
|
}
|
||||||
|
|
||||||
$members[] = [
|
$members[] = [
|
||||||
'role' => $member->role,
|
'role' => $member->role,
|
||||||
'note' => $member->placement_note,
|
'note' => $member->placement_note,
|
||||||
'target' => $member->content_element_version_id !== null ? $member->contentElementVersion : $member->nestedCompositionVersion,
|
'target' => $member->content_element_version_id !== null ? $member->contentElementVersion : $member->nestedCompositionVersion,
|
||||||
'variant' => $variant !== null && in_array($variant, $known, true) ? $variant : null,
|
'variant' => $variant,
|
||||||
'requirement' => $member->requirement,
|
'requirement' => $member->requirement,
|
||||||
'selection' => $member->variant_selection,
|
'selection' => $member->variant_selection,
|
||||||
'origin' => 'lokal',
|
'origin' => 'lokal',
|
||||||
@@ -262,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, Composition $composition, 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;
|
||||||
@@ -274,11 +762,12 @@ private function section(ExerciseSource $source, string $field, string $title, s
|
|||||||
$element->save();
|
$element->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
$latest = $element->versions()->where('status', ContentVersionStatus::Bereit)->orderByDesc('number')->first();
|
// Der Abschnitt gehört zu dieser Übung und liegt als „Übungsabschnitt“ im gemeinsamen Medienbestand.
|
||||||
|
app(ExerciseSections::class)->mark($element, $composition);
|
||||||
|
|
||||||
return $latest !== null && trim((string) $latest->body) === $text
|
return $latest !== null && FormattedText::same($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
|
||||||
@@ -295,16 +784,33 @@ private function createComposition(string $title, string $summary): Composition
|
|||||||
return $composition;
|
return $composition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $document
|
||||||
|
*/
|
||||||
|
private function duration(array $document): string
|
||||||
|
{
|
||||||
|
$min = $document['duration_min'] ?? null;
|
||||||
|
$max = $document['duration_max'] ?? null;
|
||||||
|
|
||||||
|
return match (true) {
|
||||||
|
$min !== null && $max !== null && $min !== $max => $min.' bis '.$max.' Minuten',
|
||||||
|
$min !== null => $min.' Minuten',
|
||||||
|
$max !== null => $max.' Minuten',
|
||||||
|
default => '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $query
|
* @param array<string, mixed> $query
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
private function get(string $path, array $query = []): array
|
private function get(string $path, array $query = [], ?string $key = null): array
|
||||||
{
|
{
|
||||||
$response = Http::withToken((string) config('services.shinkan.key'))
|
$connection = app(ShinkanConnection::class);
|
||||||
|
$response = Http::withToken((string) ($key ?? $connection->apiKey()))
|
||||||
->acceptJson()
|
->acceptJson()
|
||||||
->timeout(20)
|
->timeout(20)
|
||||||
->get(rtrim((string) config('services.shinkan.url'), '/').'/api/distribution/v1'.$path, $query)
|
->get((string) $connection->url().'/api/distribution/v1'.$path, $query)
|
||||||
->throw();
|
->throw();
|
||||||
|
|
||||||
$json = $response->json();
|
$json = $response->json();
|
||||||
@@ -338,9 +844,41 @@ private function finish(ExerciseImportRun $run, string $status, array $counts =
|
|||||||
private function plain(Throwable $exception): string
|
private function plain(Throwable $exception): string
|
||||||
{
|
{
|
||||||
if ($exception instanceof RequestException) {
|
if ($exception instanceof RequestException) {
|
||||||
return 'Die Quelle antwortete mit Status '.$exception->response->status().'.';
|
return match ($exception->response->status()) {
|
||||||
|
401, 403 => 'Shinkan akzeptiert den Zugangsschlüssel nicht (Status '.$exception->response->status().').',
|
||||||
|
404 => 'Der Katalog ist unter dieser Adresse nicht erreichbar oder die Distribution ist in Shinkan nicht aktiv (Status 404).',
|
||||||
|
default => 'Die Quelle antwortete mit Status '.$exception->response->status().'.',
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,8 @@
|
|||||||
* Redaktionsvorschau (Route editorial.card, nur für angemeldete Redaktion); öffentlich nie ausgegeben, weil es
|
* Redaktionsvorschau (Route editorial.card, nur für angemeldete Redaktion); öffentlich nie ausgegeben, weil es
|
||||||
* keine Freigabe für die Website hat.
|
* keine Freigabe für die Website hat.
|
||||||
* - missing: was für eine vollständige Karte fehlt, als Hinweis nur in der Redaktionsvorschau.
|
* - missing: was für eine vollständige Karte fehlt, als Hinweis nur in der Redaktionsvorschau.
|
||||||
|
* - tag: Schlüssel eines Material-Tags (App\Domain\Catalog\MaterialTag), nur wenn die Art eindeutig zuzuordnen ist;
|
||||||
|
* sonst null, und die Karte zeigt die Art als Text wie bisher.
|
||||||
* - texts: die zentralen Texte des Fachobjekts, aus denen die Karte einen wählen kann (teaser, summary, description).
|
* - texts: die zentralen Texte des Fachobjekts, aus denen die Karte einen wählen kann (teaser, summary, description).
|
||||||
* summary bleibt der Text der Vorgabe („Automatisch“); texts wird nur gelesen, wenn die Redaktion einen wählt.
|
* summary bleibt der Text der Vorgabe („Automatisch“); texts wird nur gelesen, wenn die Redaktion einen wählt.
|
||||||
*/
|
*/
|
||||||
@@ -39,6 +41,7 @@ public function __construct(
|
|||||||
public array $missing = [],
|
public array $missing = [],
|
||||||
public ?string $style = null,
|
public ?string $style = null,
|
||||||
public array $texts = [],
|
public array $texts = [],
|
||||||
|
public ?string $tag = null,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function withText(?string $title, ?string $summary): self
|
public function withText(?string $title, ?string $summary): self
|
||||||
|
|||||||
@@ -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,8 @@
|
|||||||
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\StructureNode;
|
use App\Domain\Catalog\StructureNode;
|
||||||
use App\Domain\Media\ThumbnailRef;
|
use App\Domain\Media\ThumbnailRef;
|
||||||
use App\Domain\Media\WebsiteMedia;
|
use App\Domain\Media\WebsiteMedia;
|
||||||
@@ -36,8 +38,8 @@
|
|||||||
*/
|
*/
|
||||||
class PublicMaterialReader
|
class PublicMaterialReader
|
||||||
{
|
{
|
||||||
/** Inhaltsarten, die nie öffentlich auf einer Karte erscheinen. */
|
/** Inhaltsarten, die nie öffentlich auf einer Karte erscheinen: Anleitungen für Trainer und die Textabschnitte der Übungen. */
|
||||||
public const CONFIDENTIAL_KINDS = ['traineranleitung'];
|
public const CONFIDENTIAL_KINDS = ['traineranleitung', 'uebungsabschnitt'];
|
||||||
|
|
||||||
/** @var array<int, array{id: int, title: string}>|null Element-ID => erstes öffentliches Programm */
|
/** @var array<int, array{id: int, title: string}>|null Element-ID => erstes öffentliches Programm */
|
||||||
private ?array $publicIndex = null;
|
private ?array $publicIndex = null;
|
||||||
@@ -174,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') {
|
||||||
@@ -186,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);
|
||||||
@@ -235,6 +238,7 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
|
|||||||
missing: $missing,
|
missing: $missing,
|
||||||
style: $film ? 'media' : 'material',
|
style: $film ? 'media' : 'material',
|
||||||
texts: $texts,
|
texts: $texts,
|
||||||
|
tag: MaterialTag::fromContent((string) $shown->output_class, $element->editorialContentKind?->slug)?->value,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,110 @@
|
|||||||
|
<?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.'];
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
public const SIZE = [
|
||||||
|
'medium' => 'Mittel, links neben dem ganzen Absatz',
|
||||||
|
'large' => 'Groß, links neben dem ganzen Absatz',
|
||||||
|
'xlarge' => 'Sehr groß, links neben dem ganzen Absatz',
|
||||||
|
];
|
||||||
|
|
||||||
|
public const SIZE_LABEL = ['Größe des Symbols', 'Vorgabe: klein, vor der Überschrift. Mittel, Groß und Sehr groß stellen das Symbol links neben Überschrift und Text; bei wenig Platz steht es darüber. Wirkt nur, wenn ein Symbol gewählt ist.'];
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
public const ALIGN = ['top' => 'Oben', 'center' => 'Mitte', 'bottom' => 'Unten'];
|
||||||
|
|
||||||
|
public const ALIGN_LABEL = ['Ausrichtung des Symbols', 'Senkrechte Lage des Symbols neben dem Absatz. Vorgabe: oben. Wirkt nur bei Symbolen neben dem Absatz (Mittel, Groß, Sehr groß).'];
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
public const LINK_STYLE = ['text' => 'Kleiner Textlink', 'pill' => 'Pille (Schaltfläche)'];
|
||||||
|
|
||||||
|
public const LINK_STYLE_LABEL = ['Darstellung der Links', 'Wie die Links der Merkmale aussehen. Vorgabe: kleiner Textlink. Merkmale ohne Link zeigen nichts.'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Größenstufe eines Symbols links neben dem ganzen Absatz (medium, large, xlarge) oder null, wenn das Symbol klein
|
||||||
|
* vor der Überschrift steht. Nur mit gültigem Symbol und gültiger Stufe.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $settings
|
||||||
|
*/
|
||||||
|
public static function sideSize(array $settings): ?string
|
||||||
|
{
|
||||||
|
$size = $settings['symbol_size'] ?? null;
|
||||||
|
|
||||||
|
return self::symbol($settings) !== null && is_string($size) && array_key_exists($size, self::SIZE) ? $size : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Senkrechte Ausrichtung des Symbols neben dem Absatz; ungültig oder leer ergibt oben.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $settings
|
||||||
|
*/
|
||||||
|
public static function align(array $settings): string
|
||||||
|
{
|
||||||
|
$align = $settings['symbol_align'] ?? null;
|
||||||
|
|
||||||
|
return is_string($align) && array_key_exists($align, self::ALIGN) ? $align : 'top';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $settings
|
||||||
|
*/
|
||||||
|
public static function linkStyle(array $settings): string
|
||||||
|
{
|
||||||
|
return ($settings['link_style'] ?? null) === 'pill' ? 'pill' : 'text';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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, 'symbol_size' => HeadingAccent::SIZE, 'symbol_align' => HeadingAccent::ALIGN];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingGroups(): array
|
||||||
|
{
|
||||||
|
return ['Aussehen' => ['symbol', 'symbol_size', 'symbol_align']];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingLabels(): array
|
||||||
|
{
|
||||||
|
return ['symbol' => HeadingAccent::SYMBOL_LABEL, 'symbol_size' => HeadingAccent::SIZE_LABEL, 'symbol_align' => HeadingAccent::ALIGN_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,223 @@
|
|||||||
|
<?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\Support\SafeUrl;
|
||||||
|
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): ein bis zwölf Merkmale nebeneinander,
|
||||||
|
* je mit Symbol, Kurztitel und einem Satz. Die Spaltenzahl folgt der Anzahl der Einträge und der Breite; 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
|
||||||
|
{
|
||||||
|
private const DEFAULT_LINK_LABEL = 'Mehr erfahren';
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
public const ALIGN = ['left' => 'Linksbündig', 'center' => 'Zentriert', 'right' => 'Rechtsbündig'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kantenlänge des Symbolquadrats: klein 2,5 rem, mittel 3,5 rem (Vorgabe), groß 5 rem, sehr groß 7 rem.
|
||||||
|
*
|
||||||
|
* @var array<string, string>
|
||||||
|
*/
|
||||||
|
public const SYMBOL_SIZE = ['small' => 'Klein', 'medium' => 'Mittel', 'large' => 'Groß', 'xlarge' => 'Sehr groß'];
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
public const DIVIDER = ['line' => 'Feiner Strich zwischen den Merkmalen'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gültige Layout-Einstellungen mit Vorgaben (links, mittel, ohne Strich); alles andere fällt auf die Vorgabe zurück.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $settings
|
||||||
|
* @return array{align: string, size: string, divider: bool}
|
||||||
|
*/
|
||||||
|
public static function layout(array $settings): array
|
||||||
|
{
|
||||||
|
$align = $settings['align'] ?? null;
|
||||||
|
$size = $settings['symbol_size'] ?? null;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'align' => is_string($align) && array_key_exists($align, self::ALIGN) ? $align : 'left',
|
||||||
|
'size' => is_string($size) && array_key_exists($size, self::SYMBOL_SIZE) ? $size : 'medium',
|
||||||
|
'divider' => ($settings['divider'] ?? null) === 'line',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function key(): string
|
||||||
|
{
|
||||||
|
return 'features';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return 'Merkmalszeile';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function description(): string
|
||||||
|
{
|
||||||
|
return 'Ein bis zwölf Merkmale nebeneinander (bei wenig Platz untereinander), je mit Symbol, Kurztitel, einem Satz und optionalem Link.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function supportedUnits(): array
|
||||||
|
{
|
||||||
|
return [1, 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:1', 'max:12'],
|
||||||
|
'items.*.symbol' => ['required', 'string', Rule::in(array_keys(HeadingAccent::SYMBOLS))],
|
||||||
|
'items.*.title' => ['required', 'string', 'max:60'],
|
||||||
|
'items.*.text' => ['nullable', 'string', 'max:200'],
|
||||||
|
'items.*.url' => ['nullable', 'string', 'max:500'],
|
||||||
|
'items.*.link_label' => ['nullable', 'string', 'max:60'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'align' => self::ALIGN,
|
||||||
|
'symbol_size' => self::SYMBOL_SIZE,
|
||||||
|
'divider' => self::DIVIDER,
|
||||||
|
'link_style' => HeadingAccent::LINK_STYLE,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingGroups(): array
|
||||||
|
{
|
||||||
|
return ['Aussehen' => ['align', 'symbol_size', 'divider', 'link_style']];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingLabels(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'align' => ['Ausrichtung', 'Richtet Symbol, Titel, Satz und Link jedes Merkmals aus. Vorgabe: linksbündig.'],
|
||||||
|
'symbol_size' => ['Größe der Symbole', 'Kantenlänge der Symbole: Klein 2,5 rem, Mittel 3,5 rem, Groß 5 rem, Sehr groß 7 rem. Vorgabe: Mittel.'],
|
||||||
|
'divider' => ['Trennstrich', 'Ein feiner Strich zwischen den Merkmalen: senkrecht zwischen Spalten, waagerecht zwischen Zeilen und bei untereinander stehenden Merkmalen. Vorgabe: ohne.'],
|
||||||
|
'link_style' => HeadingAccent::LINK_STYLE_LABEL,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
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),
|
||||||
|
TextInput::make('url')
|
||||||
|
->label('Linkziel (optional)')
|
||||||
|
->maxLength(500)
|
||||||
|
->rule(SafeUrl::rule())
|
||||||
|
->helperText('Seitenpfad wie /materialien oder eine http(s)-Adresse. Leer lassen für ein Merkmal ohne Link.'),
|
||||||
|
TextInput::make('link_label')
|
||||||
|
->label('Linktext')
|
||||||
|
->maxLength(60)
|
||||||
|
->placeholder(self::DEFAULT_LINK_LABEL)
|
||||||
|
->helperText('Nur mit Linkziel. Leer: „'.self::DEFAULT_LINK_LABEL.'“.'),
|
||||||
|
])
|
||||||
|
->minItems(1)
|
||||||
|
->maxItems(12)
|
||||||
|
->reorderableWithButtons()
|
||||||
|
->collapsible()
|
||||||
|
->itemLabel(fn (array $state): ?string => $state['title'] ?? null)
|
||||||
|
->addActionLabel('Merkmal hinzufügen')
|
||||||
|
->helperText('Ein bis zwölf Merkmale. Sie stehen nebeneinander, solange jedes mindestens 12 rem breit bleibt, und brechen sonst um.'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||||
|
{
|
||||||
|
foreach ($data['items'] as $index => $item) {
|
||||||
|
$hasUrl = filled($item['url'] ?? null);
|
||||||
|
|
||||||
|
if ($hasUrl && ! SafeUrl::isSafe($item['url'])) {
|
||||||
|
$errors->add("data.items.$index.url", SafeUrl::message());
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['items'][$index] = [
|
||||||
|
'symbol' => $item['symbol'],
|
||||||
|
'title' => $item['title'],
|
||||||
|
'text' => filled($item['text'] ?? null) ? $item['text'] : null,
|
||||||
|
'url' => $hasUrl ? $item['url'] : null,
|
||||||
|
// Ein Linktext ohne Linkziel wird verworfen, damit nichts Verstecktes gespeichert bleibt.
|
||||||
|
'link_label' => $hasUrl && filled($item['link_label'] ?? null) ? $item['link_label'] : 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,
|
||||||
|
'url' => SafeUrl::isSafe($item['url'] ?? null) ? $item['url'] : null,
|
||||||
|
'linkLabel' => filled($item['link_label'] ?? null) ? $item['link_label'] : self::DEFAULT_LINK_LABEL,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$settings = $widget['settings'] ?? [];
|
||||||
|
|
||||||
|
return ['items' => $items, 'linkStyle' => HeadingAccent::linkStyle($settings), 'layout' => self::layout($settings)];
|
||||||
|
}
|
||||||
|
|
||||||
|
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,31 @@ public function dataFields(): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function settings(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'symbol' => HeadingAccent::SYMBOLS,
|
||||||
|
'symbol_size' => HeadingAccent::SIZE,
|
||||||
|
'symbol_align' => HeadingAccent::ALIGN,
|
||||||
|
'accent' => HeadingAccent::BRUSH,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingGroups(): array
|
||||||
|
{
|
||||||
|
return ['Aussehen' => ['symbol', 'symbol_size', 'symbol_align', 'accent']];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingLabels(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'symbol' => HeadingAccent::SYMBOL_LABEL,
|
||||||
|
'symbol_size' => HeadingAccent::SIZE_LABEL,
|
||||||
|
'symbol_align' => HeadingAccent::ALIGN_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'] ?? '');
|
||||||
|
|||||||
@@ -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.'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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';
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,9 @@
|
|||||||
use App\Domain\Catalog\DomainRuleException;
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
use App\Domain\Catalog\ExerciseImportRun;
|
use App\Domain\Catalog\ExerciseImportRun;
|
||||||
use App\Domain\Catalog\ExerciseSource;
|
use App\Domain\Catalog\ExerciseSource;
|
||||||
use App\Domain\Catalog\ExerciseSourceSnapshot;
|
use App\Domain\Catalog\ShinkanConnection;
|
||||||
use App\Domain\Catalog\ShinkanImport;
|
use App\Domain\Catalog\ShinkanImport;
|
||||||
|
use App\Domain\Identity\StaffRole;
|
||||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
use App\Filament\Resources\Practices\PracticeResource;
|
use App\Filament\Resources\Practices\PracticeResource;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
@@ -16,31 +17,76 @@
|
|||||||
use Illuminate\Contracts\Support\Htmlable;
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Übernahme aus Shinkan: Welche Übungen stellt die Quelle bereit, was ist neu oder geändert, was ist übernommen und was
|
* Übungen aus Shinkan übernehmen: abrufen, suchen und nach Zustand filtern, markieren, vor der Übernahme prüfen und
|
||||||
* stellt die Quelle nicht mehr bereit? Abrufen verändert nur den Quellenstand; erst „Übernehmen“ legt eine lokale
|
* ausdrücklich bestätigen. Abrufen verändert nur den Quellenstand; erst die Bestätigung legt lokale Fassungen an, und
|
||||||
* Fassung an, und erst eine Produktveröffentlichung setzt sie ein.
|
* erst eine Produktveröffentlichung setzt sie ein.
|
||||||
|
*
|
||||||
|
* Den Zugangsschlüssel hinterlegen und ersetzen nur Katalog- und Systemverwalter. Die Redaktion sieht den Zustand der
|
||||||
|
* Anbindung und arbeitet mit ihr; der Schlüssel wird nie an den Browser zurückgegeben.
|
||||||
*/
|
*/
|
||||||
class Uebernahme extends Page
|
class Uebernahme extends Page
|
||||||
{
|
{
|
||||||
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte';
|
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte';
|
||||||
|
|
||||||
protected static ?string $navigationLabel = 'Übernahme (Shinkan)';
|
protected static ?string $navigationLabel = 'Übungen aus Shinkan';
|
||||||
|
|
||||||
protected static ?int $navigationSort = 6;
|
protected static ?int $navigationSort = 6;
|
||||||
|
|
||||||
protected static ?string $slug = 'uebernahme';
|
protected static ?string $slug = 'uebernahme';
|
||||||
|
|
||||||
protected static ?string $title = 'Übernahme aus Shinkan';
|
protected static ?string $title = 'Übungen aus Shinkan übernehmen';
|
||||||
|
|
||||||
protected string $view = 'filament.pages.uebernahme';
|
protected string $view = 'filament.pages.uebernahme';
|
||||||
|
|
||||||
|
public string $apiKey = '';
|
||||||
|
|
||||||
|
public string $search = '';
|
||||||
|
|
||||||
|
public string $statusFilter = 'alle';
|
||||||
|
|
||||||
|
/** @var list<int|string> Markierte Quellübungen (Kennung in der Datenbank) */
|
||||||
|
public array $selected = [];
|
||||||
|
|
||||||
|
/** auswahl | vorschau | ergebnis */
|
||||||
|
public string $step = 'auswahl';
|
||||||
|
|
||||||
|
/** @var list<array<string, mixed>> */
|
||||||
|
public array $preview = [];
|
||||||
|
|
||||||
|
/** @var array<int|string, array<string, string>> Quellübung => (entfallene Quellvariante => neue Zuordnung) */
|
||||||
|
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>> */
|
||||||
|
public array $results = [];
|
||||||
|
|
||||||
public string $feedback = '';
|
public string $feedback = '';
|
||||||
|
|
||||||
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();
|
return ContentElementResource::editor() || static::canConfigure();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Den Schlüssel ändern dürfen nur Katalogverwalter und Systemverwalter. */
|
||||||
|
public static function canConfigure(): bool
|
||||||
|
{
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
return $user instanceof User
|
||||||
|
&& ($user->hasStaffRole(StaffRole::Katalogverwalter) || $user->hasStaffRole(StaffRole::Systemverwalter));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeading(): string|Htmlable|null
|
public function getHeading(): string|Htmlable|null
|
||||||
@@ -53,30 +99,151 @@ public function getMaxContentWidth(): Width|string|null
|
|||||||
return Width::Full;
|
return Width::Full;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function saveKey(): void
|
||||||
|
{
|
||||||
|
abort_unless(static::canConfigure(), 403);
|
||||||
|
|
||||||
|
try {
|
||||||
|
app(ShinkanConnection::class)->saveKey($this->apiKey, $this->actor());
|
||||||
|
$this->say('Der Zugangsschlüssel ist gespeichert. Prüfe jetzt die Verbindung. Der Schlüssel wird nie wieder angezeigt.');
|
||||||
|
} catch (DomainRuleException $exception) {
|
||||||
|
$this->say($exception->getMessage(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->apiKey = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function removeKey(): void
|
||||||
|
{
|
||||||
|
abort_unless(static::canConfigure(), 403);
|
||||||
|
|
||||||
|
app(ShinkanConnection::class)->forgetKey($this->actor());
|
||||||
|
$this->say('Der in der Verwaltung hinterlegte Zugangsschlüssel ist entfernt. Ein Schlüssel aus der Umgebung des Servers bleibt davon unberührt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüft die Verbindung. Ein eingetragener, noch nicht gespeicherter Schlüssel wird mitgeprüft (nur Verwalter).
|
||||||
|
*/
|
||||||
|
public function check(): void
|
||||||
|
{
|
||||||
|
abort_unless(static::canAccess(), 403);
|
||||||
|
|
||||||
|
$candidate = static::canConfigure() ? $this->apiKey : '';
|
||||||
|
$result = app(ShinkanImport::class)->check($candidate);
|
||||||
|
$this->apiKey = '';
|
||||||
|
$this->say($result['message'], ! $result['ok']);
|
||||||
|
}
|
||||||
|
|
||||||
public function fetch(): void
|
public function fetch(): void
|
||||||
{
|
{
|
||||||
abort_unless(static::canAccess(), 403);
|
abort_unless(static::canAccess(), 403);
|
||||||
|
|
||||||
$run = app(ShinkanImport::class)->fetch();
|
$run = app(ShinkanImport::class)->fetch();
|
||||||
$this->feedbackError = $run->status !== 'ok';
|
$this->say(
|
||||||
$this->feedback = $run->status === 'ok'
|
$run->status === 'ok'
|
||||||
? 'Abruf abgeschlossen: '.$run->added.' neu, '.$run->updated.' geändert, '.$run->removed.' nicht mehr bereitgestellt. Es wurde noch keine lokale Fassung angelegt.'
|
? 'Abruf abgeschlossen: '.$run->added.' neu, '.$run->updated.' geändert, '.$run->removed.' nicht mehr bereitgestellt. Es wurde noch keine lokale Fassung angelegt.'
|
||||||
: (string) $run->error;
|
: (string) $run->error,
|
||||||
|
$run->status !== 'ok',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function adopt(int $snapshotId): void
|
public function review(): void
|
||||||
{
|
{
|
||||||
abort_unless(static::canAccess(), 403);
|
abort_unless(static::canAccess(), 403);
|
||||||
|
|
||||||
try {
|
$ids = array_values(array_unique(array_map('intval', $this->selected)));
|
||||||
$user = Filament::auth()->user();
|
|
||||||
$version = app(ShinkanImport::class)->adopt(ExerciseSourceSnapshot::query()->findOrFail($snapshotId), $user instanceof User ? $user : null);
|
if ($ids === []) {
|
||||||
$this->feedbackError = false;
|
$this->say('Markiere mindestens eine Übung.', true);
|
||||||
$this->feedback = 'Fassung '.$version->number.' ist lokal angelegt und unveränderlich. Produkte verwenden sie erst, wenn du sie dort bewusst einsetzt und das Produkt veröffentlichst.';
|
|
||||||
} catch (DomainRuleException $exception) {
|
return;
|
||||||
$this->feedbackError = true;
|
|
||||||
$this->feedback = $exception->getMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->buildPreview($ids);
|
||||||
|
$this->step = 'vorschau';
|
||||||
|
$this->say('');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function backToSelection(): void
|
||||||
|
{
|
||||||
|
$this->step = 'auswahl';
|
||||||
|
$this->preview = [];
|
||||||
|
$this->say('');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function confirm(): void
|
||||||
|
{
|
||||||
|
abort_unless(static::canAccess(), 403);
|
||||||
|
|
||||||
|
$import = app(ShinkanImport::class);
|
||||||
|
$changed = [];
|
||||||
|
$open = [];
|
||||||
|
|
||||||
|
foreach ($this->preview as $entry) {
|
||||||
|
$source = ExerciseSource::query()->find($entry['source']);
|
||||||
|
|
||||||
|
if ($source === null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$latest = $source->latestSnapshot();
|
||||||
|
|
||||||
|
if (($source->availability === ExerciseSource::WITHDRAWN) !== (bool) $entry['excluded'] || $latest?->id !== $entry['snapshot']) {
|
||||||
|
$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) {
|
||||||
|
if (! isset($this->reassign[$entry['source']][$conflict['key']]) || $this->reassign[$entry['source']][$conflict['key']] === 'offen') {
|
||||||
|
$open[] = $entry['title'].': '.implode(', ', $conflict['members']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($changed !== []) {
|
||||||
|
$this->buildPreview(array_map(fn (array $entry): int => (int) $entry['source'], $this->preview));
|
||||||
|
$this->say('Der Quellstand hat sich seit der Vorschau geändert ('.implode(', ', $changed).'). Die Vorschau ist aktualisiert. Prüfe sie und bestätige den neuen Stand bewusst. Es wurde nichts übernommen.', true);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($open !== []) {
|
||||||
|
$this->say('Lege zuerst fest, was gilt: '.implode('; ', $open).'.', true);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->results = [];
|
||||||
|
|
||||||
|
foreach ($this->preview as $entry) {
|
||||||
|
$source = ExerciseSource::query()->findOrFail($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(), $this->textChoice[$entry['source']] ?? []);
|
||||||
|
$source->refresh();
|
||||||
|
$this->results[] = [
|
||||||
|
'title' => $entry['title'],
|
||||||
|
'status' => $result['status'],
|
||||||
|
'message' => $result['message'],
|
||||||
|
'url' => $source->composition === null ? null : PracticeResource::getUrl('edit', ['record' => $source->composition]),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->selected = [];
|
||||||
|
$this->preview = [];
|
||||||
|
$this->step = 'ergebnis';
|
||||||
|
$this->say('');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function done(): void
|
||||||
|
{
|
||||||
|
$this->step = 'auswahl';
|
||||||
|
$this->results = [];
|
||||||
|
$this->say('');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,25 +253,32 @@ public function daten(): array
|
|||||||
{
|
{
|
||||||
$import = app(ShinkanImport::class);
|
$import = app(ShinkanImport::class);
|
||||||
$labels = [
|
$labels = [
|
||||||
'neu' => ['Neu bei der Quelle', 'offen'],
|
'neu' => ['Neu', 'is-neu'],
|
||||||
'geaendert' => ['Neue Quellfassung zur Übernahme', 'offen'],
|
'geaendert' => ['Geänderter Quellstand', 'is-geaendert'],
|
||||||
'uebernommen' => ['Übernommen', 'gut'],
|
'uebernommen' => ['Übernommen', 'is-eigen'],
|
||||||
'nicht_mehr_bereitgestellt' => ['An der Quelle nicht mehr bereitgestellt', 'leise'],
|
'nicht_mehr_bereitgestellt' => ['Nicht mehr bereitgestellt', ''],
|
||||||
];
|
];
|
||||||
|
$needle = mb_strtolower(trim($this->search));
|
||||||
$rows = [];
|
$rows = [];
|
||||||
|
$total = 0;
|
||||||
|
|
||||||
foreach (ExerciseSource::query()->with('composition')->orderBy('title')->get() as $source) {
|
foreach (ExerciseSource::query()->with('composition')->orderBy('title')->get() as $source) {
|
||||||
|
$total++;
|
||||||
$state = $import->state($source);
|
$state = $import->state($source);
|
||||||
$latest = $source->latestSnapshot();
|
|
||||||
$payload = $latest?->payload ?? [];
|
if (($this->statusFilter !== 'alle' && $this->statusFilter !== $state)
|
||||||
|
|| ($needle !== '' && ! str_contains(mb_strtolower(($source->title ?? '').' '.$source->source_id), $needle))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$rows[] = [
|
$rows[] = [
|
||||||
|
'id' => $source->id,
|
||||||
'titel' => $source->title ?: $source->source_id,
|
'titel' => $source->title ?: $source->source_id,
|
||||||
'zustand' => $labels[$state][0],
|
'zustand' => $labels[$state][0],
|
||||||
'ton' => $labels[$state][1],
|
'ton' => $labels[$state][1],
|
||||||
'snapshot' => $latest !== null && $latest->adopted_version_id === null ? $latest->id : null,
|
'state' => $state,
|
||||||
|
'markierbar' => $state !== 'nicht_mehr_bereitgestellt',
|
||||||
'lokal' => $source->composition === null ? null : PracticeResource::getUrl('edit', ['record' => $source->composition]),
|
'lokal' => $source->composition === null ? null : PracticeResource::getUrl('edit', ['record' => $source->composition]),
|
||||||
'varianten' => count($payload['variants'] ?? []),
|
|
||||||
'quellmedien' => array_map(fn (array $media): string => ($media['title'] ?? '').' ('.($media['media_type'] ?? '').')', (array) ($payload['media'] ?? [])),
|
|
||||||
'hinweis' => $state === 'nicht_mehr_bereitgestellt'
|
'hinweis' => $state === 'nicht_mehr_bereitgestellt'
|
||||||
? 'Lokale Fassungen und Verwendungen bleiben unverändert. Eine rechtliche Sperre ist ein eigener Vorgang am Medium.'
|
? 'Lokale Fassungen und Verwendungen bleiben unverändert. Eine rechtliche Sperre ist ein eigener Vorgang am Medium.'
|
||||||
: null,
|
: null,
|
||||||
@@ -113,8 +287,38 @@ public function daten(): array
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'zeilen' => $rows,
|
'zeilen' => $rows,
|
||||||
'eingerichtet' => app(ShinkanImport::class)->configured(),
|
'gesamt' => $total,
|
||||||
|
'optionen' => ['alle' => 'Alle Zustände', 'neu' => 'Neu', 'geaendert' => 'Geänderter Quellstand', 'uebernommen' => 'Übernommen', 'nicht_mehr_bereitgestellt' => 'Nicht mehr bereitgestellt'],
|
||||||
|
'eingerichtet' => $import->configured(),
|
||||||
|
'anbindung' => $import->status(),
|
||||||
|
'darfAendern' => static::canConfigure(),
|
||||||
'letzterLauf' => ExerciseImportRun::query()->orderByDesc('id')->first(),
|
'letzterLauf' => ExerciseImportRun::query()->orderByDesc('id')->first(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<int> $ids
|
||||||
|
*/
|
||||||
|
private function buildPreview(array $ids): void
|
||||||
|
{
|
||||||
|
$import = app(ShinkanImport::class);
|
||||||
|
$this->preview = [];
|
||||||
|
|
||||||
|
foreach (ExerciseSource::query()->whereIn('id', $ids)->orderBy('title')->get() as $source) {
|
||||||
|
$this->preview[] = $import->preview($source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function actor(): ?User
|
||||||
|
{
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
return $user instanceof User ? $user : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function say(string $message, bool $error = false): void
|
||||||
|
{
|
||||||
|
$this->feedback = $message;
|
||||||
|
$this->feedbackError = $error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,9 @@
|
|||||||
use App\Domain\Catalog\DomainRuleException;
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
use App\Domain\Catalog\EditorialVocabulary;
|
use App\Domain\Catalog\EditorialVocabulary;
|
||||||
use App\Domain\Catalog\EditorialWorkingDraft;
|
use App\Domain\Catalog\EditorialWorkingDraft;
|
||||||
|
use App\Domain\Catalog\ExerciseSections;
|
||||||
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 +28,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 +51,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 +386,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 +414,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 +1267,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.';
|
||||||
@@ -1260,6 +1279,11 @@ public function addText(): void
|
|||||||
$service = app(ContentService::class);
|
$service = app(ContentService::class);
|
||||||
$element = $service->createElement('text', 'text', $title);
|
$element = $service->createElement('text', 'text', $title);
|
||||||
$version = $service->draftElementVersion($element, $body);
|
$version = $service->draftElementVersion($element, $body);
|
||||||
|
|
||||||
|
// Ein Abschnitt, der im Übungseditor entsteht, gehört zu dieser Übung (Materialart „Übungsabschnitt“).
|
||||||
|
if ($this->isExercise()) {
|
||||||
|
app(ExerciseSections::class)->mark($element, $this->getRecord());
|
||||||
|
}
|
||||||
} catch (DomainRuleException $exception) {
|
} catch (DomainRuleException $exception) {
|
||||||
$this->feedback = $exception->getMessage();
|
$this->feedback = $exception->getMessage();
|
||||||
|
|
||||||
@@ -1578,7 +1602,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 +1622,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 +1779,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 +1980,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 +2100,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 +2128,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 +2170,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 +2323,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 +2424,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'] ?? []),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Domain\Catalog\CompositionKind;
|
use App\Domain\Catalog\CompositionKind;
|
||||||
use App\Domain\Catalog\ContentService;
|
use App\Domain\Catalog\ContentService;
|
||||||
|
use App\Filament\Pages\Uebernahme;
|
||||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
use App\Filament\Support\ListsCompositions;
|
use App\Filament\Support\ListsCompositions;
|
||||||
use App\Filament\Support\ReportsDomainRules;
|
use App\Filament\Support\ReportsDomainRules;
|
||||||
@@ -55,6 +56,18 @@ public function content(Schema $schema): Schema
|
|||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
|
if ($this->kind() === CompositionKind::Exercise) {
|
||||||
|
return [
|
||||||
|
$this->createCompositionAction($this->kind()),
|
||||||
|
Action::make('shinkan')
|
||||||
|
->label('Aus Shinkan übernehmen')
|
||||||
|
->icon('heroicon-o-arrow-down-tray')
|
||||||
|
->color('gray')
|
||||||
|
->visible(fn (): bool => ContentElementResource::editor())
|
||||||
|
->url(fn (): string => Uebernahme::getUrl()),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->onDesk()) {
|
if ($this->onDesk()) {
|
||||||
return [$this->createCompositionAction($this->kind())];
|
return [$this->createCompositionAction($this->kind())];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)) {
|
||||||
|
|||||||
@@ -6,11 +6,15 @@
|
|||||||
use App\Domain\Catalog\PillarFilterCompat;
|
use App\Domain\Catalog\PillarFilterCompat;
|
||||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
use App\Filament\Support\Bestand;
|
use App\Filament\Support\Bestand;
|
||||||
|
use App\Filament\Support\MaterialKindSelection;
|
||||||
use App\Filament\Support\MediaLibrary;
|
use App\Filament\Support\MediaLibrary;
|
||||||
use App\Filament\Support\MediumForm;
|
use App\Filament\Support\MediumForm;
|
||||||
use App\Filament\Support\ReportsDomainRules;
|
use App\Filament\Support\ReportsDomainRules;
|
||||||
use App\Filament\Support\ShowsBestand;
|
use App\Filament\Support\ShowsBestand;
|
||||||
|
use App\Models\UserViewDefault;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
use Filament\Schemas\Components\RenderHook;
|
use Filament\Schemas\Components\RenderHook;
|
||||||
use Filament\Schemas\Components\View;
|
use Filament\Schemas\Components\View;
|
||||||
@@ -55,9 +59,34 @@ class ListContentElements extends ListRecords
|
|||||||
#[Url(as: 'saeule', except: '')]
|
#[Url(as: 'saeule', except: '')]
|
||||||
public string $saeule = '';
|
public string $saeule = '';
|
||||||
|
|
||||||
|
/** Frühere Adresse mit einer einzelnen Materialart (zum Beispiel aus den Stammdaten); wird zu `arten`. */
|
||||||
#[Url(as: 'inhaltsart', except: '')]
|
#[Url(as: 'inhaltsart', except: '')]
|
||||||
public string $inhaltsart = '';
|
public string $inhaltsart = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mehrfachauswahl der fachlichen Materialarten (MaterialKindSelection). Leer heißt: allgemeine Startansicht, also
|
||||||
|
* alle Materialarten und Medien ohne Materialart, aber ohne Übungsabschnitte.
|
||||||
|
*/
|
||||||
|
#[Url(as: 'arten', except: '')]
|
||||||
|
public string $arten = '';
|
||||||
|
|
||||||
|
/** Der Filterdialog ist offen. */
|
||||||
|
public bool $filterOffen = false;
|
||||||
|
|
||||||
|
/** Das Filterfeld, bei dem der Dialog beginnt (leer: beim ersten Feld). */
|
||||||
|
public string $filterFokus = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Arbeitsstand des Dialogs: die Auswahl seit dem Öffnen. Erst „Anwenden“ übernimmt sie in die Filter der Liste,
|
||||||
|
* „Abbrechen“ verwirft sie.
|
||||||
|
*
|
||||||
|
* @var array<string, mixed>
|
||||||
|
*/
|
||||||
|
public array $filterDraft = [];
|
||||||
|
|
||||||
|
/** Filterfelder mit mehreren Werten (ODER); verschiedene Felder gelten zusammen (UND). */
|
||||||
|
private const MULTI_FIELDS = ['art', 'freigabe', 'nutzung'];
|
||||||
|
|
||||||
#[Url(as: 'einordnung', except: '')]
|
#[Url(as: 'einordnung', except: '')]
|
||||||
public string $einordnung = '';
|
public string $einordnung = '';
|
||||||
|
|
||||||
@@ -67,6 +96,27 @@ class ListContentElements extends ListRecords
|
|||||||
#[Url(as: 'archiv', except: 'aktiv')]
|
#[Url(as: 'archiv', except: 'aktiv')]
|
||||||
public string $archiv = 'aktiv';
|
public string $archiv = 'aktiv';
|
||||||
|
|
||||||
|
/** Eigenschaften, die der persönliche Standard festhält. Die Suche gehört nicht dazu: Sie ist Teil der Arbeit, kein Zustand der Ansicht. */
|
||||||
|
private const DEFAULT_FILTERS = ['arten', 'art', 'freigabe', 'schutz', 'entwurf', 'fassung', 'nutzung', 'saeule', 'einordnung', 'verarbeitung', 'archiv', 'ansicht'];
|
||||||
|
|
||||||
|
public function mount(): void
|
||||||
|
{
|
||||||
|
parent::mount();
|
||||||
|
|
||||||
|
if ($this->inhaltsart !== '' && $this->arten === '') {
|
||||||
|
$this->arten = ctype_digit($this->inhaltsart) ? MaterialKindSelection::encode([MaterialKindSelection::key((int) $this->inhaltsart)]) : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->inhaltsart = '';
|
||||||
|
|
||||||
|
// Ohne eigene Vorgaben in der Adresse startet der Medienmanager mit dem persönlichen Standard.
|
||||||
|
$given = array_intersect(array_keys(request()->query()), ['suche', 'ansicht', 'art', 'arten', 'inhaltsart', 'freigabe', 'schutz', 'entwurf', 'fassung', 'nutzung', 'saeule', 'einordnung', 'verarbeitung', 'archiv']);
|
||||||
|
|
||||||
|
if ($given === [] && ($saved = $this->savedDefault()) !== null) {
|
||||||
|
$this->applyFilters($saved);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getSubheading(): string|Htmlable|null
|
public function getSubheading(): string|Htmlable|null
|
||||||
{
|
{
|
||||||
return 'Die Dateien und Texte. Ein Modul oder ein Programm verweist auf eine Fassung; die Datei wird nicht für jede Verwendung neu hochgeladen.';
|
return 'Die Dateien und Texte. Ein Modul oder ein Programm verweist auf eine Fassung; die Datei wird nicht für jede Verwendung neu hochgeladen.';
|
||||||
@@ -88,7 +138,7 @@ public function content(Schema $schema): Schema
|
|||||||
|
|
||||||
protected function bestandFilterEigenschaften(): array
|
protected function bestandFilterEigenschaften(): array
|
||||||
{
|
{
|
||||||
return ['suche', 'art', 'schutz', 'freigabe', 'entwurf', 'fassung', 'nutzung', 'saeule', 'inhaltsart', 'einordnung', 'verarbeitung', 'archiv'];
|
return ['suche', 'art', 'arten', 'schutz', 'freigabe', 'entwurf', 'fassung', 'nutzung', 'saeule', 'inhaltsart', 'einordnung', 'verarbeitung', 'archiv'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showingList(): bool
|
public function showingList(): bool
|
||||||
@@ -128,14 +178,6 @@ public function classificationOptions(): array
|
|||||||
return app(MediaLibrary::class)->classifications(ctype_digit($this->einordnung) ? [(int) $this->einordnung] : []);
|
return app(MediaLibrary::class)->classifications(ctype_digit($this->einordnung) ? [(int) $this->einordnung] : []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array<int, string>
|
|
||||||
*/
|
|
||||||
public function contentKindOptions(): array
|
|
||||||
{
|
|
||||||
return app(EditorialVocabulary::class)->kindFilterOptions('medium', $this->inhaltsart);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function filtersActive(): bool
|
public function filtersActive(): bool
|
||||||
{
|
{
|
||||||
return trim($this->suche) !== ''
|
return trim($this->suche) !== ''
|
||||||
@@ -147,7 +189,7 @@ public function filtersActive(): bool
|
|||||||
|| $this->nutzung !== ''
|
|| $this->nutzung !== ''
|
||||||
|| $this->saeule !== ''
|
|| $this->saeule !== ''
|
||||||
|| $this->einordnung !== ''
|
|| $this->einordnung !== ''
|
||||||
|| $this->inhaltsart !== ''
|
|| $this->arten !== ''
|
||||||
|| $this->verarbeitung !== ''
|
|| $this->verarbeitung !== ''
|
||||||
|| $this->archiv !== 'aktiv';
|
|| $this->archiv !== 'aktiv';
|
||||||
}
|
}
|
||||||
@@ -164,13 +206,346 @@ public function resetFilters(): void
|
|||||||
$this->saeule = '';
|
$this->saeule = '';
|
||||||
$this->einordnung = '';
|
$this->einordnung = '';
|
||||||
$this->inhaltsart = '';
|
$this->inhaltsart = '';
|
||||||
|
$this->arten = '';
|
||||||
$this->verarbeitung = '';
|
$this->verarbeitung = '';
|
||||||
$this->archiv = 'aktiv';
|
$this->archiv = 'aktiv';
|
||||||
$this->bestandGrenze = Bestand::SCHRITT;
|
$this->bestandGrenze = Bestand::SCHRITT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- Materialarten und persönlicher Standard
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gemeinsame Bestandsliste: Suche und häufige Filter sichtbar, die übrigen unter „Weitere Filter“.
|
* Die wählbaren Materialarten mit Schlüssel: die Arten der redaktionellen Stammdaten, „Übungsabschnitt“ und „Ohne
|
||||||
|
* Materialart“.
|
||||||
|
*
|
||||||
|
* @return array<string, array{label: string, automatic: bool}>
|
||||||
|
*/
|
||||||
|
public function artChoices(): array
|
||||||
|
{
|
||||||
|
$chosen = array_map(
|
||||||
|
fn (string $key): int => (int) substr($key, 1),
|
||||||
|
array_filter(MaterialKindSelection::decode($this->arten) ?? [], fn (string $key): bool => $key !== MaterialKindSelection::WITHOUT),
|
||||||
|
);
|
||||||
|
$choices = [];
|
||||||
|
|
||||||
|
foreach (app(EditorialVocabulary::class)->mediumKindChoices(array_values($chosen)) as $kind) {
|
||||||
|
$choices[MaterialKindSelection::key($kind['id'])] = ['label' => $kind['label'], 'automatic' => $kind['automatic']];
|
||||||
|
}
|
||||||
|
|
||||||
|
$choices[MaterialKindSelection::WITHOUT] = ['label' => 'Ohne Materialart', 'automatic' => false];
|
||||||
|
|
||||||
|
return $choices;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allgemeine Startansicht: alle Materialarten und Medien ohne Materialart, ohne Übungsabschnitte.
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function defaultArten(): array
|
||||||
|
{
|
||||||
|
return array_keys(array_filter($this->artChoices(), fn (array $choice): bool => ! $choice['automatic']));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string> die gerade gewählten Schlüssel
|
||||||
|
*/
|
||||||
|
public function selectedArten(): array
|
||||||
|
{
|
||||||
|
return MaterialKindSelection::decode($this->arten) ?? $this->defaultArten();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $keys
|
||||||
|
*/
|
||||||
|
private function storeArten(array $keys): void
|
||||||
|
{
|
||||||
|
$default = $this->defaultArten();
|
||||||
|
sort($keys);
|
||||||
|
sort($default);
|
||||||
|
|
||||||
|
// Die allgemeine Startansicht bleibt ohne Eintrag in der Adresse.
|
||||||
|
$this->arten = $keys === $default ? '' : MaterialKindSelection::encode($keys);
|
||||||
|
$this->bestandGrenze = Bestand::SCHRITT;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function userId(): ?int
|
||||||
|
{
|
||||||
|
$id = Filament::auth()->id();
|
||||||
|
|
||||||
|
return $id === null ? null : (int) $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>|null
|
||||||
|
*/
|
||||||
|
private function savedDefault(): ?array
|
||||||
|
{
|
||||||
|
return UserViewDefault::filtersFor($this->userId(), UserViewDefault::MEDIA);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasSavedDefault(): bool
|
||||||
|
{
|
||||||
|
return $this->savedDefault() !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die aktuellen Filter (ohne Suche) als persönlicher Standard dieses Kontos.
|
||||||
|
*/
|
||||||
|
public function saveDefault(): void
|
||||||
|
{
|
||||||
|
$userId = $this->userId();
|
||||||
|
|
||||||
|
if ($userId === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$filters = [];
|
||||||
|
|
||||||
|
foreach (self::DEFAULT_FILTERS as $name) {
|
||||||
|
$filters[$name] = (string) $this->{$name};
|
||||||
|
}
|
||||||
|
|
||||||
|
UserViewDefault::remember($userId, UserViewDefault::MEDIA, $filters);
|
||||||
|
$this->filterOffen = false;
|
||||||
|
Notification::make()->title('Standard gespeichert')->body('Der Medienmanager startet für dich mit diesen Filtern.')->success()->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function restoreDefault(): void
|
||||||
|
{
|
||||||
|
$saved = $this->savedDefault();
|
||||||
|
|
||||||
|
if ($saved === null) {
|
||||||
|
Notification::make()->title('Kein persönlicher Standard gespeichert')->warning()->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->suche = '';
|
||||||
|
$this->applyFilters($saved);
|
||||||
|
$this->filterOffen = false;
|
||||||
|
Notification::make()->title('Dein Standard ist geladen')->success()->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteDefault(): void
|
||||||
|
{
|
||||||
|
$userId = $this->userId();
|
||||||
|
|
||||||
|
if ($userId !== null) {
|
||||||
|
UserViewDefault::forget($userId, UserViewDefault::MEDIA);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->resetFilters();
|
||||||
|
$this->ansicht = 'liste';
|
||||||
|
$this->filterOffen = false;
|
||||||
|
Notification::make()->title('Persönlicher Standard gelöscht')->body('Der Medienmanager startet wieder mit der allgemeinen Auswahl.')->success()->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $filters
|
||||||
|
*/
|
||||||
|
private function applyFilters(array $filters): void
|
||||||
|
{
|
||||||
|
foreach (self::DEFAULT_FILTERS as $name) {
|
||||||
|
if (array_key_exists($name, $filters)) {
|
||||||
|
$this->{$name} = (string) $filters[$name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->ansicht = $this->ansicht === 'kacheln' ? 'kacheln' : 'liste';
|
||||||
|
$this->archiv = in_array($this->archiv, ['aktiv', 'archiviert', 'alle'], true) ? $this->archiv : 'aktiv';
|
||||||
|
$this->bestandGrenze = Bestand::SCHRITT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------- Filterdialog
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filterfelder mit Checkboxen (Mehrfachauswahl). Mehrere Werte eines Felds gelten als ODER.
|
||||||
|
*
|
||||||
|
* @return array<string, array{label: string, kurz: string, optionen: array<string, string>}>
|
||||||
|
*/
|
||||||
|
private function multiFields(): array
|
||||||
|
{
|
||||||
|
$arten = array_map(fn (array $choice): string => $choice['label'], $this->artChoices());
|
||||||
|
|
||||||
|
return [
|
||||||
|
'arten' => ['label' => 'Fachliche Materialart', 'kurz' => 'Materialart', 'optionen' => $arten],
|
||||||
|
'art' => ['label' => 'Technische Art', 'kurz' => 'Technische Art', 'optionen' => collect($this->typeOptions())->mapWithKeys(fn (array $type): array => [$type['value'] => $type['label']])->all()],
|
||||||
|
'freigabe' => ['label' => 'Freigabe', 'kurz' => 'Freigabe', 'optionen' => ['freigegeben' => 'Freigegebene Fassung', 'entwurf' => 'Nur offener Entwurf', 'ohne' => 'Keine freigegebene Fassung']],
|
||||||
|
'nutzung' => ['label' => 'Verwendung', 'kurz' => 'Verwendung', 'optionen' => ['verwendet' => 'Verwendet', 'unbenutzt' => 'Nicht verwendet']],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Weitere Kriterien mit einem Wert je Feld, unter „Weitere Filter“ im Dialog.
|
||||||
|
*
|
||||||
|
* @return array<string, array{label: string, vorgabe: string, alle: string|null, optionen: array<string, string>}>
|
||||||
|
*/
|
||||||
|
private function singleFields(): array
|
||||||
|
{
|
||||||
|
$optionen = fn (array $liste, string $wert, string $label): array => collect($liste)
|
||||||
|
->mapWithKeys(fn (array $eintrag): array => [(string) $eintrag[$wert] => $eintrag[$label]])
|
||||||
|
->all();
|
||||||
|
$fields = [
|
||||||
|
'schutz' => ['label' => 'Schutz', 'vorgabe' => '', 'alle' => 'Alle Medien', 'optionen' => ['geschuetzt' => 'Geschützte Medien', 'oeffentlich' => 'Öffentliche Medien', 'website' => 'Auf der Website frei']],
|
||||||
|
'entwurf' => ['label' => 'Entwurf', 'vorgabe' => '', 'alle' => 'Entwurf egal', 'optionen' => ['offen' => 'Offener Entwurf', 'keiner' => 'Kein offener Entwurf']],
|
||||||
|
'fassung' => ['label' => 'Deaktivierte Fassungen', 'vorgabe' => '', 'alle' => 'Regulärer Bestand', 'optionen' => ['mit' => 'Mit deaktivierter Fassung', 'nur' => 'Nur deaktivierte Fassungen']],
|
||||||
|
];
|
||||||
|
|
||||||
|
if (($pillars = $this->pillarOptions()) !== []) {
|
||||||
|
$fields['saeule'] = ['label' => 'Fachliche Säule', 'vorgabe' => '', 'alle' => 'Alle Säulen', 'optionen' => $optionen($pillars, 'id', 'name')];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($classes = $this->classificationOptions()) !== []) {
|
||||||
|
$fields['einordnung'] = ['label' => 'Einordnung', 'vorgabe' => '', 'alle' => 'Alle Einordnungen', 'optionen' => $optionen($classes, 'id', 'label')];
|
||||||
|
}
|
||||||
|
|
||||||
|
$fields['verarbeitung'] = ['label' => 'Verarbeitung', 'vorgabe' => '', 'alle' => 'Verarbeitung egal', 'optionen' => ['fehler' => 'Verarbeitungsfehler', 'uebernahme' => 'Datei wird übernommen']];
|
||||||
|
$fields['archiv'] = ['label' => 'Archiv', 'vorgabe' => 'aktiv', 'alle' => null, 'optionen' => ['aktiv' => 'Aktive Medien', 'archiviert' => 'Archivierte Medien', 'alle' => 'Auch archivierte']];
|
||||||
|
|
||||||
|
return $fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function appliedList(string $field): array
|
||||||
|
{
|
||||||
|
$value = trim((string) $this->{$field});
|
||||||
|
|
||||||
|
return $value === '' ? [] : array_values(array_filter(array_map('trim', explode(',', $value)), fn (string $part): bool => $part !== ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Auswahl der Liste als Arbeitsstand des Dialogs.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function draftFromApplied(): array
|
||||||
|
{
|
||||||
|
$draft = ['arten' => $this->selectedArten()];
|
||||||
|
|
||||||
|
foreach (self::MULTI_FIELDS as $field) {
|
||||||
|
$draft[$field] = $this->appliedList($field);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (array_keys($this->singleFields()) as $field) {
|
||||||
|
$draft[$field] = (string) $this->{$field};
|
||||||
|
}
|
||||||
|
|
||||||
|
return $draft;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function openFilter(string $field = ''): void
|
||||||
|
{
|
||||||
|
$this->filterDraft = $this->draftFromApplied();
|
||||||
|
$this->filterFokus = $field;
|
||||||
|
$this->filterOffen = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Verwirft die Auswahl seit dem Öffnen. */
|
||||||
|
public function cancelFilter(): void
|
||||||
|
{
|
||||||
|
$this->filterOffen = false;
|
||||||
|
$this->filterDraft = [];
|
||||||
|
$this->filterFokus = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Alle Materialarten im Dialog ankreuzen, auch Übungsabschnitte und „Ohne Materialart“. */
|
||||||
|
public function draftAlleArten(): void
|
||||||
|
{
|
||||||
|
$this->filterDraft['arten'] = array_keys($this->artChoices());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Übernimmt die Auswahl des Dialogs in die Liste. */
|
||||||
|
public function applyFilter(): void
|
||||||
|
{
|
||||||
|
$this->applyDraft();
|
||||||
|
$this->filterOffen = false;
|
||||||
|
$this->filterDraft = [];
|
||||||
|
$this->filterFokus = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Übernimmt die Auswahl des Dialogs und merkt sie als persönlichen Standard. */
|
||||||
|
public function saveDefaultFromDialog(): void
|
||||||
|
{
|
||||||
|
$this->applyDraft();
|
||||||
|
$this->filterDraft = [];
|
||||||
|
$this->filterFokus = '';
|
||||||
|
$this->saveDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function applyDraft(): void
|
||||||
|
{
|
||||||
|
$draft = $this->filterDraft;
|
||||||
|
$known = array_keys($this->artChoices());
|
||||||
|
$this->storeArten(array_values(array_intersect($known, array_map('strval', (array) ($draft['arten'] ?? [])))));
|
||||||
|
$options = $this->multiFields();
|
||||||
|
|
||||||
|
foreach (self::MULTI_FIELDS as $field) {
|
||||||
|
$allowed = array_keys($options[$field]['optionen']);
|
||||||
|
$chosen = array_values(array_intersect($allowed, array_map('strval', (array) ($draft[$field] ?? []))));
|
||||||
|
// Alle Werte angekreuzt heißt: keine Einschränkung.
|
||||||
|
$this->{$field} = count($chosen) === count($allowed) ? '' : implode(',', $chosen);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->singleFields() as $field => $definition) {
|
||||||
|
$value = (string) ($draft[$field] ?? $definition['vorgabe']);
|
||||||
|
$this->{$field} = array_key_exists($value, $definition['optionen']) ? $value : $definition['vorgabe'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->bestandGrenze = Bestand::SCHRITT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die wirksamen Filter als Pillen unter der Suche. Ein Klick öffnet den Dialog beim Filterfeld. In der allgemeinen
|
||||||
|
* Startansicht erklärt eine Pille, warum Übungsabschnitte fehlen.
|
||||||
|
*
|
||||||
|
* @return list<array{feld: string, label: string, info: bool}>
|
||||||
|
*/
|
||||||
|
private function filterPills(): array
|
||||||
|
{
|
||||||
|
$pills = [];
|
||||||
|
$short = function (array $labels): string {
|
||||||
|
$joined = implode(', ', $labels);
|
||||||
|
|
||||||
|
return count($labels) <= 3 && mb_strlen($joined) <= 40 ? $joined : count($labels).' gewählt';
|
||||||
|
};
|
||||||
|
$multi = $this->multiFields();
|
||||||
|
|
||||||
|
if ($this->arten === '') {
|
||||||
|
$pills[] = ['feld' => 'arten', 'label' => 'Übungsabschnitte ausgeblendet', 'info' => true];
|
||||||
|
} else {
|
||||||
|
$selected = $this->selectedArten();
|
||||||
|
|
||||||
|
if ($selected === []) {
|
||||||
|
$pills[] = ['feld' => 'arten', 'label' => 'Materialart · keine gewählt', 'info' => false];
|
||||||
|
} elseif (count($selected) < count($multi['arten']['optionen'])) {
|
||||||
|
$pills[] = ['feld' => 'arten', 'label' => 'Materialart · '.$short(array_map(fn (string $key): string => $multi['arten']['optionen'][$key] ?? $key, $selected)), 'info' => false];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (self::MULTI_FIELDS as $field) {
|
||||||
|
$values = $this->appliedList($field);
|
||||||
|
|
||||||
|
if ($values !== []) {
|
||||||
|
$pills[] = ['feld' => $field, 'label' => $multi[$field]['kurz'].' · '.$short(array_map(fn (string $value): string => $multi[$field]['optionen'][$value] ?? $value, $values)), 'info' => false];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->singleFields() as $field => $definition) {
|
||||||
|
$value = (string) $this->{$field};
|
||||||
|
|
||||||
|
if ($value !== $definition['vorgabe']) {
|
||||||
|
$pills[] = ['feld' => $field, 'label' => $definition['label'].' · '.($definition['optionen'][$value] ?? $value), 'info' => false];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pills;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gemeinsame Bestandsliste: Suche mit Filterknopf, wirksame Filter als Pillen, alle Kriterien im Filterdialog.
|
||||||
*
|
*
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
@@ -181,38 +556,27 @@ public function bestand(): array
|
|||||||
[$this->saeule, $this->einordnung] = [(string) $pillar, ''];
|
[$this->saeule, $this->einordnung] = [(string) $pillar, ''];
|
||||||
}
|
}
|
||||||
|
|
||||||
$optionen = fn (array $liste, string $wert, string $label): array => collect($liste)
|
$pills = $this->filterPills();
|
||||||
->mapWithKeys(fn (array $eintrag): array => [(string) $eintrag[$wert] => $eintrag[$label]])
|
$keine = $this->selectedArten() === [];
|
||||||
->all();
|
$gespeichert = $this->hasSavedDefault();
|
||||||
$weitere = [
|
$dialog = [
|
||||||
['eigenschaft' => 'inhaltsart', 'label' => 'Fachliche Materialart', 'vorgabe' => '', 'alle' => 'Alle Materialarten', 'optionen' => $this->contentKindOptions()],
|
'offen' => $this->filterOffen,
|
||||||
['eigenschaft' => 'entwurf', 'label' => 'Entwurf', 'vorgabe' => '', 'alle' => 'Entwurf egal', 'optionen' => ['offen' => 'Offener Entwurf', 'keiner' => 'Kein offener Entwurf']],
|
'fokus' => $this->filterFokus,
|
||||||
['eigenschaft' => 'fassung', 'label' => 'Deaktivierte Fassungen', 'vorgabe' => '', 'alle' => 'Regulärer Bestand', 'optionen' => ['mit' => 'Mit deaktivierter Fassung', 'nur' => 'Nur deaktivierte Fassungen']],
|
'pillen' => $pills,
|
||||||
|
'anzahl' => count(array_filter($pills, fn (array $pill): bool => ! $pill['info'])),
|
||||||
|
'felder' => $this->multiFields(),
|
||||||
|
'weitere' => $this->singleFields(),
|
||||||
|
'entwurf' => 'filterDraft',
|
||||||
|
'gespeichert' => $gespeichert,
|
||||||
|
'hinweis' => 'Mehrere Werte eines Felds zeigen Medien, auf die einer davon zutrifft. Verschiedene Felder gelten zusammen. Freigabe meint die Fassung des Mediums, nicht die Website und keinen Zugriff. Geschützte Medien haben eine Inhaltsfassung und laufen über Lizenzen. Öffentliche Medien sind eigenständige Präsentationsmedien ohne Fassung für die Website. Materialart und Einordnung sind die redaktionelle Klassifikation; Verwendung zeigt, wo das Medium tatsächlich eingebunden ist. Übungsabschnitte, die Texte der Übungen, erscheinen erst, wenn du sie unter Materialart ankreuzt. „Als Standard speichern“ merkt die Filter für dein Konto, ohne die Suche.',
|
||||||
];
|
];
|
||||||
|
|
||||||
if (($pillars = $this->pillarOptions()) !== []) {
|
|
||||||
$weitere[] = ['eigenschaft' => 'saeule', 'label' => 'Fachliche Säule', 'vorgabe' => '', 'alle' => 'Alle Säulen', 'optionen' => $optionen($pillars, 'id', 'name')];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($classes = $this->classificationOptions()) !== []) {
|
|
||||||
$weitere[] = ['eigenschaft' => 'einordnung', 'label' => 'Einordnung', 'vorgabe' => '', 'alle' => 'Alle Einordnungen', 'optionen' => $optionen($classes, 'id', 'label')];
|
|
||||||
}
|
|
||||||
|
|
||||||
$weitere[] = ['eigenschaft' => 'verarbeitung', 'label' => 'Verarbeitung', 'vorgabe' => '', 'alle' => 'Verarbeitung egal', 'optionen' => ['fehler' => 'Verarbeitungsfehler', 'uebernahme' => 'Datei wird übernommen']];
|
|
||||||
$weitere[] = ['eigenschaft' => 'archiv', 'label' => 'Archiv', 'vorgabe' => 'aktiv', 'optionen' => ['aktiv' => 'Aktive Medien', 'archiviert' => 'Archivierte Medien', 'alle' => 'Auch archivierte']];
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'suche' => ['eigenschaft' => 'suche', 'label' => 'Suche', 'platzhalter' => 'Titel, Beschreibung oder Suchbegriff'],
|
'suche' => ['eigenschaft' => 'suche', 'label' => 'Suche', 'platzhalter' => 'Titel, Beschreibung oder Suchbegriff'],
|
||||||
'filter' => [
|
'filterdialog' => $dialog,
|
||||||
['eigenschaft' => 'art', 'label' => 'Technische Art', 'vorgabe' => '', 'alle' => 'Alle Arten', 'optionen' => $optionen($this->typeOptions(), 'value', 'label')],
|
|
||||||
['eigenschaft' => 'schutz', 'label' => 'Schutz', 'vorgabe' => '', 'alle' => 'Alle Medien', 'optionen' => ['geschuetzt' => 'Geschützte Medien', 'oeffentlich' => 'Öffentliche Medien', 'website' => 'Auf der Website frei']],
|
|
||||||
['eigenschaft' => 'freigabe', 'label' => 'Freigabe', 'vorgabe' => '', 'alle' => 'Alle Freigaben', 'optionen' => ['freigegeben' => 'Freigegebene Fassung', 'entwurf' => 'Nur offener Entwurf', 'ohne' => 'Keine freigegebene Fassung']],
|
|
||||||
['eigenschaft' => 'nutzung', 'label' => 'Verwendung', 'vorgabe' => '', 'alle' => 'Verwendung egal', 'optionen' => ['verwendet' => 'Verwendet', 'unbenutzt' => 'Nicht verwendet']],
|
|
||||||
],
|
|
||||||
'weitere' => $weitere,
|
|
||||||
'hinweis' => 'Freigabe meint die Fassung des Mediums, nicht die Website und keinen Zugriff. Geschützte Medien haben eine Inhaltsfassung und laufen über Lizenzen. Öffentliche Medien sind eigenständige Präsentationsmedien ohne Fassung für die Website; ob sie freigegeben sind, zeigt die Kennzeichnung an der Zeile. Materialart und Einordnung sind die redaktionelle Klassifikation; Verwendung zeigt, wo das Medium tatsächlich eingebunden ist. Deaktivierte und archivierte Medien bleiben über „Weitere Filter“ auffindbar.',
|
|
||||||
'zeilen' => array_map($this->zeile(...), $this->cards()),
|
'zeilen' => array_map($this->zeile(...), $this->cards()),
|
||||||
'einheit' => ['Medium', 'Medien'],
|
'einheit' => ['Medium', 'Medien'],
|
||||||
|
'leerHinweis' => $keine ? 'Öffne den Filter und wähle mindestens eine Materialart aus, um Medien zu sehen. „Alle auswählen“ zeigt alles, auch die Übungsabschnitte.' : null,
|
||||||
'leer' => ['titel' => 'Noch keine Medien', 'text' => 'Mit „Medium anlegen“ oben lädst du eine Datei hoch oder schreibst einen Text.'],
|
'leer' => ['titel' => 'Noch keine Medien', 'text' => 'Mit „Medium anlegen“ oben lädst du eine Datei hoch oder schreibst einen Text.'],
|
||||||
'ansicht' => 'ansicht',
|
'ansicht' => 'ansicht',
|
||||||
];
|
];
|
||||||
@@ -250,7 +614,7 @@ private function zeile(array $card): array
|
|||||||
return [
|
return [
|
||||||
'schluessel' => 'm'.$card['id'],
|
'schluessel' => 'm'.$card['id'],
|
||||||
'titel' => $card['title'],
|
'titel' => $card['title'],
|
||||||
'meta' => $card['type'].(filled($card['editorialKind'] ?? null) ? ' · '.$card['editorialKind'] : ''),
|
'meta' => $card['type'].(filled($card['editorialKind'] ?? null) ? ' · '.$card['editorialKind'] : '').($card['exercise'] !== null ? ' · Übung: '.$card['exercise']['title'] : ''),
|
||||||
'text' => $card['description'],
|
'text' => $card['description'],
|
||||||
'bild' => $card['image'],
|
'bild' => $card['image'],
|
||||||
'bildAlt' => $card['imageAlt'],
|
'bildAlt' => $card['imageAlt'],
|
||||||
@@ -271,6 +635,7 @@ private function zeile(array $card): array
|
|||||||
'aktionen' => array_values(array_filter([
|
'aktionen' => array_values(array_filter([
|
||||||
['label' => 'Ansehen', 'href' => $card['url'], 'icon' => 'auge'],
|
['label' => 'Ansehen', 'href' => $card['url'], 'icon' => 'auge'],
|
||||||
$card['editUrl'] ? ['label' => 'Redaktion', 'href' => $card['editUrl'], 'icon' => 'stift'] : null,
|
$card['editUrl'] ? ['label' => 'Redaktion', 'href' => $card['editUrl'], 'icon' => 'stift'] : null,
|
||||||
|
($card['exercise']['url'] ?? null) ? ['label' => 'Zur Übung', 'href' => $card['exercise']['url'], 'icon' => 'stift'] : null,
|
||||||
])),
|
])),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -291,6 +656,7 @@ private function libraryFilters(): array
|
|||||||
'saeule' => $this->saeule,
|
'saeule' => $this->saeule,
|
||||||
'einordnung' => $this->einordnung,
|
'einordnung' => $this->einordnung,
|
||||||
'inhaltsart' => $this->inhaltsart,
|
'inhaltsart' => $this->inhaltsart,
|
||||||
|
'arten' => $this->arten === '' ? MaterialKindSelection::encode($this->defaultArten()) : $this->arten,
|
||||||
'verarbeitung' => $this->verarbeitung,
|
'verarbeitung' => $this->verarbeitung,
|
||||||
'archiv' => $this->archiv,
|
'archiv' => $this->archiv,
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -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
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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),
|
||||||
|
|||||||
@@ -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,8 +4,11 @@
|
|||||||
|
|
||||||
use App\Domain\Catalog\Composition;
|
use App\Domain\Catalog\Composition;
|
||||||
use App\Domain\Catalog\CompositionKind;
|
use App\Domain\Catalog\CompositionKind;
|
||||||
|
use App\Domain\Catalog\CompositionMember;
|
||||||
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\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;
|
||||||
@@ -151,6 +154,10 @@ public function entries(): array
|
|||||||
$canEdit = ContentElementResource::editor();
|
$canEdit = ContentElementResource::editor();
|
||||||
$rows = [];
|
$rows = [];
|
||||||
|
|
||||||
|
$shinkan = $kinds === [CompositionKind::Exercise] || in_array(CompositionKind::Exercise, $kinds, true)
|
||||||
|
? ExerciseSource::query()->whereNotNull('composition_id')->pluck('composition_id')->all()
|
||||||
|
: [];
|
||||||
|
|
||||||
$compositions = Composition::query()
|
$compositions = Composition::query()
|
||||||
->whereIn('kind', $kinds)
|
->whereIn('kind', $kinds)
|
||||||
->with(['editorialContentKind', 'versions.members.contentElementVersion.element'])
|
->with(['editorialContentKind', 'versions.members.contentElementVersion.element'])
|
||||||
@@ -177,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;
|
||||||
@@ -189,7 +196,7 @@ public function entries(): array
|
|||||||
$rows[] = [
|
$rows[] = [
|
||||||
'schluessel' => 'c'.$composition->id,
|
'schluessel' => 'c'.$composition->id,
|
||||||
'titel' => $title,
|
'titel' => $title,
|
||||||
'meta' => $kind->deskLabel().($title !== $composition->designation ? ' · '.$composition->designation : '').($kind === CompositionKind::Exercise ? ' · Herkunft: lokal' : ''),
|
'meta' => $kind->deskLabel().($title !== $composition->designation ? ' · '.$composition->designation : '').($kind === CompositionKind::Exercise ? ' · Herkunft: '.$this->exerciseOrigin($composition, $shinkan) : ''),
|
||||||
'text' => $summary,
|
'text' => $summary,
|
||||||
'bild' => $cover['url'],
|
'bild' => $cover['url'],
|
||||||
'bildFehlt' => 'Kein Titelbild',
|
'bildFehlt' => 'Kein Titelbild',
|
||||||
@@ -215,6 +222,23 @@ public function entries(): array
|
|||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Herkunft einer Übung: lokal angelegt, aus Shinkan übernommen oder aus Shinkan übernommen und lokal ergänzt.
|
||||||
|
*
|
||||||
|
* @param list<int> $shinkan Übungen mit Quellbindung
|
||||||
|
*/
|
||||||
|
private function exerciseOrigin(Composition $composition, array $shinkan): string
|
||||||
|
{
|
||||||
|
if (! in_array($composition->id, $shinkan, true)) {
|
||||||
|
return 'lokal';
|
||||||
|
}
|
||||||
|
|
||||||
|
$latest = $composition->versions->sortByDesc('number')->first();
|
||||||
|
$local = $latest !== null && CompositionMember::query()->where('composition_version_id', $latest->id)->where('origin', 'lokal')->exists();
|
||||||
|
|
||||||
|
return $local ? 'Shinkan, lokal bearbeitet' : 'Shinkan';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Anlegedialog für Module und Programme; derselbe auf dem Arbeitsplatz und in den Listen.
|
* Anlegedialog für Module und Programme; derselbe auf dem Arbeitsplatz und in den Listen.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -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'] ?? ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auswahl der fachlichen Materialarten im Medienmanager, als Zeichenkette für die Adresse und den persönlichen
|
||||||
|
* Standard. Ein Schlüssel ist `k<ID>` für eine Materialart oder `ohne` für Medien ohne Materialart.
|
||||||
|
*
|
||||||
|
* - Leer: keine Einschränkung (so rufen andere Stellen die Medienbibliothek auf).
|
||||||
|
* - `keine`: ausdrücklich nichts ausgewählt, die Liste ist dann leer.
|
||||||
|
* - sonst: die Schlüssel, durch Komma getrennt.
|
||||||
|
*/
|
||||||
|
final class MaterialKindSelection
|
||||||
|
{
|
||||||
|
public const WITHOUT = 'ohne';
|
||||||
|
|
||||||
|
public const NONE = 'keine';
|
||||||
|
|
||||||
|
public static function key(?int $kindId): string
|
||||||
|
{
|
||||||
|
return $kindId === null ? self::WITHOUT : 'k'.$kindId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $keys
|
||||||
|
*/
|
||||||
|
public static function encode(array $keys): string
|
||||||
|
{
|
||||||
|
$keys = self::clean($keys);
|
||||||
|
|
||||||
|
return $keys === [] ? self::NONE : implode(',', $keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>|null null = keine Einschränkung
|
||||||
|
*/
|
||||||
|
public static function decode(string $value): ?array
|
||||||
|
{
|
||||||
|
$value = trim($value);
|
||||||
|
|
||||||
|
if ($value === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value === self::NONE ? [] : self::clean(explode(',', $value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $keys
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private static function clean(array $keys): array
|
||||||
|
{
|
||||||
|
$keys = array_filter(array_map('trim', $keys), fn (string $key): bool => $key === self::WITHOUT || preg_match('/^k\d+$/', $key) === 1);
|
||||||
|
|
||||||
|
return array_values(array_unique($keys));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,12 +9,14 @@
|
|||||||
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;
|
||||||
use App\Domain\Catalog\ReleaseContent;
|
use App\Domain\Catalog\ReleaseContent;
|
||||||
use App\Domain\Media\ThumbnailRef;
|
use App\Domain\Media\ThumbnailRef;
|
||||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
|
use App\Filament\Resources\Practices\PracticeResource;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
@@ -77,7 +79,7 @@ public function classifications(array $selectedIds = []): array
|
|||||||
*/
|
*/
|
||||||
public function cardFor(ContentElement $element, bool $canEdit): array
|
public function cardFor(ContentElement $element, bool $canEdit): array
|
||||||
{
|
{
|
||||||
$element->loadMissing(['versions', 'pillars', 'editorialContentKind']);
|
$element->loadMissing(['versions', 'pillars', 'editorialContentKind', 'originComposition']);
|
||||||
$versionIds = $element->versions->pluck('id')->all();
|
$versionIds = $element->versions->pluck('id')->all();
|
||||||
|
|
||||||
return $this->card(
|
return $this->card(
|
||||||
@@ -97,7 +99,7 @@ public function cards(array $filters, bool $canEdit): array
|
|||||||
{
|
{
|
||||||
$filters = $this->normalize($filters);
|
$filters = $this->normalize($filters);
|
||||||
$elements = ContentElement::query()
|
$elements = ContentElement::query()
|
||||||
->with(['versions', 'pillars', 'editorialContentKind'])
|
->with(['versions', 'pillars', 'editorialContentKind', 'originComposition'])
|
||||||
->orderBy('working_title')
|
->orderBy('working_title')
|
||||||
->get();
|
->get();
|
||||||
$versionIds = $elements->flatMap(fn (ContentElement $element) => $element->versions->pluck('id'))->all();
|
$versionIds = $elements->flatMap(fn (ContentElement $element) => $element->versions->pluck('id'))->all();
|
||||||
@@ -142,20 +144,34 @@ private function normalize(array $filters): array
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'suche' => trim($filters['suche'] ?? ''),
|
'suche' => trim($filters['suche'] ?? ''),
|
||||||
'art' => $this->choice($filters['art'] ?? '', ['film', 'text', 'document', 'bild', 'audio']),
|
'art' => $this->choices($filters['art'] ?? '', ['film', 'text', 'document', 'bild', 'audio']),
|
||||||
'freigabe' => $this->choice($filters['freigabe'] ?? '', ['freigegeben', 'entwurf', 'ohne']),
|
'freigabe' => $this->choices($filters['freigabe'] ?? '', ['freigegeben', 'entwurf', 'ohne']),
|
||||||
'schutz' => $this->choice($filters['schutz'] ?? '', ['geschuetzt', 'oeffentlich', 'website']),
|
'schutz' => $this->choice($filters['schutz'] ?? '', ['geschuetzt', 'oeffentlich', 'website']),
|
||||||
'entwurf' => $this->choice($filters['entwurf'] ?? '', ['offen', 'keiner']),
|
'entwurf' => $this->choice($filters['entwurf'] ?? '', ['offen', 'keiner']),
|
||||||
'fassung' => $this->choice($filters['fassung'] ?? '', ['mit', 'nur']),
|
'fassung' => $this->choice($filters['fassung'] ?? '', ['mit', 'nur']),
|
||||||
'nutzung' => $this->choice($filters['nutzung'] ?? '', ['verwendet', 'unbenutzt']),
|
'nutzung' => $this->choices($filters['nutzung'] ?? '', ['verwendet', 'unbenutzt']),
|
||||||
'saeule' => $saeule,
|
'saeule' => $saeule,
|
||||||
'einordnung' => $einordnung,
|
'einordnung' => $einordnung,
|
||||||
'inhaltsart' => ctype_digit($filters['inhaltsart'] ?? '') ? $filters['inhaltsart'] : '',
|
'inhaltsart' => ctype_digit($filters['inhaltsart'] ?? '') ? $filters['inhaltsart'] : '',
|
||||||
|
// Mehrfachauswahl der Materialarten (MaterialKindSelection); leer = keine Einschränkung.
|
||||||
|
'arten' => trim((string) ($filters['arten'] ?? '')),
|
||||||
'verarbeitung' => $this->choice($filters['verarbeitung'] ?? '', ['fehler', 'uebernahme']),
|
'verarbeitung' => $this->choice($filters['verarbeitung'] ?? '', ['fehler', 'uebernahme']),
|
||||||
'archiv' => $this->choice($filters['archiv'] ?? '', ['aktiv', 'archiviert', 'alle'], 'aktiv'),
|
'archiv' => $this->choice($filters['archiv'] ?? '', ['aktiv', 'archiviert', 'alle'], 'aktiv'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mehrere Werte eines Filterfelds, durch Komma getrennt. Sie gelten als ODER; leer heißt keine Einschränkung.
|
||||||
|
* Ein einzelner Wert, wie ihn ältere Adressen und gespeicherte Standards enthalten, ist ein gültiger Sonderfall.
|
||||||
|
*
|
||||||
|
* @param list<string> $allowed
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function choices(string $value, array $allowed): array
|
||||||
|
{
|
||||||
|
return array_values(array_intersect($allowed, array_map('trim', explode(',', $value))));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param list<string> $allowed
|
* @param list<string> $allowed
|
||||||
*/
|
*/
|
||||||
@@ -357,7 +373,7 @@ private function processing(Collection $versions): ?string
|
|||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $portrait
|
* @param array<string, mixed> $portrait
|
||||||
* @param list<array<string, mixed>> $uses
|
* @param list<array<string, mixed>> $uses
|
||||||
* @param array<string, string> $filters
|
* @param array<string, mixed> $filters
|
||||||
* @param array<int, list<int>> $classified
|
* @param array<int, list<int>> $classified
|
||||||
*/
|
*/
|
||||||
private function matches(ContentElement $element, array $portrait, array $uses, array $filters, string $needle, array $classified): bool
|
private function matches(ContentElement $element, array $portrait, array $uses, array $filters, string $needle, array $classified): bool
|
||||||
@@ -366,7 +382,7 @@ private function matches(ContentElement $element, array $portrait, array $uses,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->matchesArt($element, $filters['art'])) {
|
if ($filters['art'] !== [] && ! $this->matchesAnyArt($element, $filters['art'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -398,16 +414,16 @@ private function matches(ContentElement $element, array $portrait, array $uses,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filters['freigabe'] === 'freigegeben' && $portrait['ready'] === null) {
|
if ($filters['freigabe'] !== []) {
|
||||||
return false;
|
$passes = [
|
||||||
}
|
'freigegeben' => $portrait['ready'] !== null,
|
||||||
|
'entwurf' => $portrait['draft'] !== null && $portrait['ready'] === null,
|
||||||
|
'ohne' => $portrait['ready'] === null,
|
||||||
|
];
|
||||||
|
|
||||||
if ($filters['freigabe'] === 'entwurf' && ($portrait['draft'] === null || $portrait['ready'] !== null)) {
|
if (! in_array(true, array_intersect_key($passes, array_flip($filters['freigabe'])), true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filters['freigabe'] === 'ohne' && $portrait['ready'] !== null) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($filters['entwurf'] === 'offen' && $portrait['draft'] === null) {
|
if ($filters['entwurf'] === 'offen' && $portrait['draft'] === null) {
|
||||||
@@ -428,11 +444,7 @@ private function matches(ContentElement $element, array $portrait, array $uses,
|
|||||||
|
|
||||||
$used = $this->usageCount($uses) > 0;
|
$used = $this->usageCount($uses) > 0;
|
||||||
|
|
||||||
if ($filters['nutzung'] === 'verwendet' && ! $used) {
|
if ($filters['nutzung'] !== [] && ! in_array($used ? 'verwendet' : 'unbenutzt', $filters['nutzung'], true)) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($filters['nutzung'] === 'unbenutzt' && $used) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,6 +460,14 @@ private function matches(ContentElement $element, array $portrait, array $uses,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($filters['arten'] !== '') {
|
||||||
|
$keys = MaterialKindSelection::decode($filters['arten']) ?? [];
|
||||||
|
|
||||||
|
if (! in_array(MaterialKindSelection::key($element->editorial_content_kind_id === null ? null : (int) $element->editorial_content_kind_id), $keys, true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($filters['verarbeitung'] === 'fehler' && $portrait['processing'] !== 'Verarbeitungsfehler') {
|
if ($filters['verarbeitung'] === 'fehler' && $portrait['processing'] !== 'Verarbeitungsfehler') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -468,6 +488,20 @@ private function isPresentationMedium(ContentElement $element, int $versionCount
|
|||||||
return $versionCount === 0 && in_array($element->output_class, ['bild', 'film', 'audio'], true);
|
return $versionCount === 0 && in_array($element->output_class, ['bild', 'film', 'audio'], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $arts
|
||||||
|
*/
|
||||||
|
private function matchesAnyArt(ContentElement $element, array $arts): bool
|
||||||
|
{
|
||||||
|
foreach ($arts as $art) {
|
||||||
|
if ($this->matchesArt($element, $art)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private function matchesArt(ContentElement $element, string $art): bool
|
private function matchesArt(ContentElement $element, string $art): bool
|
||||||
{
|
{
|
||||||
if ($art === '') {
|
if ($art === '') {
|
||||||
@@ -488,8 +522,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 +538,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);
|
||||||
@@ -515,6 +549,7 @@ private function card(ContentElement $element, array $portrait, array $uses, arr
|
|||||||
'title' => $element->working_title,
|
'title' => $element->working_title,
|
||||||
'type' => $this->catalog->outputLabel((string) $element->output_class),
|
'type' => $this->catalog->outputLabel((string) $element->output_class),
|
||||||
'editorialKind' => $element->editorialContentKind?->label,
|
'editorialKind' => $element->editorialContentKind?->label,
|
||||||
|
'exercise' => $this->exerciseOf($element, $canEdit),
|
||||||
'typeKey' => $typeKey,
|
'typeKey' => $typeKey,
|
||||||
'description' => $description === '' ? null : $description,
|
'description' => $description === '' ? null : $description,
|
||||||
'usageNote' => $usageNote === '' ? null : $usageNote,
|
'usageNote' => $usageNote === '' ? null : $usageNote,
|
||||||
@@ -543,6 +578,25 @@ private function card(ContentElement $element, array $portrait, array $uses, arr
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Übung, für die ein Textabschnitt angelegt wurde: Titel und, für die Redaktion, der Weg zum Übungseditor.
|
||||||
|
*
|
||||||
|
* @return array{title: string, url: string|null}|null
|
||||||
|
*/
|
||||||
|
private function exerciseOf(ContentElement $element, bool $canEdit): ?array
|
||||||
|
{
|
||||||
|
$exercise = $element->originComposition;
|
||||||
|
|
||||||
|
if (! $exercise instanceof Composition) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'title' => (string) ($exercise->display_title ?: $exercise->designation),
|
||||||
|
'url' => $canEdit ? PracticeResource::getUrl('edit', ['record' => $exercise]) : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param list<array<string, mixed>> $uses
|
* @param list<array<string, mixed>> $uses
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
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\EditorialVocabulary;
|
||||||
|
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;
|
||||||
@@ -28,14 +30,19 @@ public static function fields(bool $creating, ?ContentElement $element = null):
|
|||||||
];
|
];
|
||||||
|
|
||||||
if ($creating) {
|
if ($creating) {
|
||||||
$fields[] = Select::make('shape')->label('Was ist das?')->options([
|
$fields[] = Select::make('editorial_content_kind_id')
|
||||||
|
->label('Fachliche Materialart')
|
||||||
|
->options(fn (): array => app(EditorialVocabulary::class)->kindOptions('medium'))
|
||||||
|
->required()
|
||||||
|
->helperText('Die redaktionelle Einordnung, zum Beispiel Merkblatt. Sie steht in der Medienliste und lässt sich dort filtern. Die technische Art wählst du darunter.');
|
||||||
|
$fields[] = Select::make('shape')->label('Technische Art')->options([
|
||||||
'film' => 'Film',
|
'film' => 'Film',
|
||||||
'audio' => 'Hörstück',
|
'audio' => 'Hörstück',
|
||||||
'bild' => 'Bild',
|
'bild' => 'Bild',
|
||||||
'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 +53,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)
|
||||||
@@ -94,6 +101,7 @@ public static function create(array $data, bool $hold): ContentElement
|
|||||||
{
|
{
|
||||||
$service = app(ContentService::class);
|
$service = app(ContentService::class);
|
||||||
[$kind, $output] = self::shape($data['shape'] ?? null);
|
[$kind, $output] = self::shape($data['shape'] ?? null);
|
||||||
|
$kindId = self::contentKindId($data);
|
||||||
$incoming = null;
|
$incoming = null;
|
||||||
|
|
||||||
if ($output !== 'text') {
|
if ($output !== 'text') {
|
||||||
@@ -122,10 +130,12 @@ public static function create(array $data, bool $hold): ContentElement
|
|||||||
}
|
}
|
||||||
|
|
||||||
$element = $service->createElement($kind, $output, (string) $data['working_title']);
|
$element = $service->createElement($kind, $output, (string) $data['working_title']);
|
||||||
|
$element->editorial_content_kind_id = $kindId;
|
||||||
|
$element->save();
|
||||||
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.');
|
||||||
@@ -154,6 +164,28 @@ public static function create(array $data, bool $hold): ContentElement
|
|||||||
return $element->fresh() ?? $element;
|
return $element->fresh() ?? $element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die fachliche Materialart ist beim Anlegen Pflicht und muss für Medien zulässig und aktiv sein.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $data
|
||||||
|
*/
|
||||||
|
private static function contentKindId(array $data): int
|
||||||
|
{
|
||||||
|
$id = $data['editorial_content_kind_id'] ?? null;
|
||||||
|
|
||||||
|
if (! filled($id) || ! ctype_digit((string) $id)) {
|
||||||
|
throw new DomainRuleException('Die fachliche Materialart fehlt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$error = app(EditorialVocabulary::class)->kindError('medium', (int) $id, null);
|
||||||
|
|
||||||
|
if ($error !== null) {
|
||||||
|
throw new DomainRuleException($error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int) $id;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $data
|
* @param array<string, mixed> $data
|
||||||
*/
|
*/
|
||||||
@@ -164,7 +196,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 +217,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 +230,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,
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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'],
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -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'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Persönlicher Standard der Filter einer Verwaltungsansicht, je Konto und Ansicht (zum Beispiel `medien`). Er gilt
|
||||||
|
* nur für das eigene Konto und überdauert die Anmeldung.
|
||||||
|
*/
|
||||||
|
class UserViewDefault extends Model
|
||||||
|
{
|
||||||
|
public const MEDIA = 'medien';
|
||||||
|
|
||||||
|
protected $fillable = ['user_id', 'view', 'filters'];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return ['filters' => 'array'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function user(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>|null
|
||||||
|
*/
|
||||||
|
public static function filtersFor(?int $userId, string $view): ?array
|
||||||
|
{
|
||||||
|
if ($userId === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = static::query()->where('user_id', $userId)->where('view', $view)->first();
|
||||||
|
|
||||||
|
return $row === null ? null : array_map('strval', (array) $row->filters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $filters
|
||||||
|
*/
|
||||||
|
public static function remember(int $userId, string $view, array $filters): void
|
||||||
|
{
|
||||||
|
static::query()->updateOrCreate(['user_id' => $userId, 'view' => $view], ['filters' => $filters]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function forget(int $userId, string $view): void
|
||||||
|
{
|
||||||
|
static::query()->where('user_id', $userId)->where('view', $view)->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -67,6 +67,12 @@ public function panel(Panel $panel): Panel
|
|||||||
->authMiddleware([
|
->authMiddleware([
|
||||||
Authenticate::class,
|
Authenticate::class,
|
||||||
])
|
])
|
||||||
|
// Favicon zur Anfragezeit: ->favicon(asset(...)) würde beim Start der Anwendung berechnet, vor der
|
||||||
|
// Auswertung von Proxy-Kopfzeilen und geöffneter Adresse, und könnte auf einen falschen Host zeigen.
|
||||||
|
->renderHook(
|
||||||
|
PanelsRenderHook::HEAD_END,
|
||||||
|
fn (): string => view('components.site.favicon')->render(),
|
||||||
|
)
|
||||||
->renderHook(
|
->renderHook(
|
||||||
PanelsRenderHook::STYLES_AFTER,
|
PanelsRenderHook::STYLES_AFTER,
|
||||||
fn (): string => view('filament.cms.styles')->render().view('filament.verwaltung.styles')->render(),
|
fn (): string => view('filament.cms.styles')->render().view('filament.verwaltung.styles')->render(),
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Support\Brand;
|
||||||
|
|
||||||
|
use Illuminate\Support\HtmlString;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kleingrafiken des Brand-Kits (docs/Brand-UI-Kit/16_Lara-Felix-Kleingrafiken) als Inline-SVG.
|
||||||
|
*
|
||||||
|
* - Nur Dateien aus resources/svg/brand/<Satz>/ sind zulässig; ein unbekannter Name ist ein Fehler, kein stiller Leerplatz.
|
||||||
|
* - Die Kit-Dateien tragen alle dieselbe ID (motif-title) und einen Titel. Beim Einbetten werden ID, Titel, Rolle und feste
|
||||||
|
* Größe entfernt, damit mehrere Symbole auf einer Seite keine doppelten IDs erzeugen. Symbole sind Beiwerk
|
||||||
|
* (aria-hidden); die Aussage trägt immer der danebenstehende Text.
|
||||||
|
* - Sätze: „symbole“ (Symbole und Akzente aus dem Kit, feste Markenfarben) und „glyphen“ (kleine Zeichen für Tags, Farbe
|
||||||
|
* über currentColor, Geometrie aus den Tag-Dateien des Kits).
|
||||||
|
* - Nicht enthalten: die Motive mit Text als Pfad (Pinsel, Pillen, Tags, Kompositionen). Text bleibt HTML.
|
||||||
|
*/
|
||||||
|
final class Symbols
|
||||||
|
{
|
||||||
|
public const SET_SYMBOLS = 'symbole';
|
||||||
|
|
||||||
|
public const SET_GLYPHS = 'glyphen';
|
||||||
|
|
||||||
|
/** @var array<string, string> */
|
||||||
|
private static array $cache = [];
|
||||||
|
|
||||||
|
/** @var array<string, array<string, float>>|null */
|
||||||
|
private static ?array $bounds = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public static function names(string $set = self::SET_SYMBOLS): array
|
||||||
|
{
|
||||||
|
$files = glob(self::directory($set).'/*.svg') ?: [];
|
||||||
|
$names = array_map(fn (string $file): string => basename($file, '.svg'), $files);
|
||||||
|
sort($names);
|
||||||
|
|
||||||
|
return $names;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function symbol(string $name, string $attributes = ''): HtmlString
|
||||||
|
{
|
||||||
|
return self::render(self::SET_SYMBOLS, $name, $attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function glyph(string $name, string $attributes = ''): HtmlString
|
||||||
|
{
|
||||||
|
return self::render(self::SET_GLYPHS, $name, $attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $attributes bereits maskierte Attribute (aus der Attributtasche der Komponente)
|
||||||
|
*/
|
||||||
|
private static function render(string $set, string $name, string $attributes): HtmlString
|
||||||
|
{
|
||||||
|
if (! preg_match('/^[a-z0-9-]+$/', $name) || ! in_array($name, self::names($set), true)) {
|
||||||
|
throw new InvalidArgumentException("Unbekanntes Markensymbol „{$name}“ im Satz „{$set}“.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$svg = self::$cache["$set/$name"] ??= self::clean((string) file_get_contents(self::directory($set)."/$name.svg"), $set === self::SET_SYMBOLS ? self::bounds($name) : null);
|
||||||
|
$extra = trim($attributes) === '' ? '' : ' '.trim($attributes);
|
||||||
|
|
||||||
|
return new HtmlString(preg_replace('/^<svg\b/', '<svg aria-hidden="true" focusable="false"'.$extra, $svg, 1) ?? $svg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sichtbare Zeichnung eines Symbols in Einheiten seiner ursprünglichen Zeichenfläche: x, y, w (Breite), h (Höhe).
|
||||||
|
* Die Kit-Dateien haben einen unsichtbaren Rand um die Zeichnung (je nach Symbol 5 bis 20 % der Fläche). Beim
|
||||||
|
* Einbetten wird die Zeichenfläche auf diese Grenzen zugeschnitten, damit die Oberkante der Zeichnung bündig mit der
|
||||||
|
* Oberkante von Text oder Rahmen abschließt. Gemessen mit scripts/brand-symbol-bounds.py (Datei _grenzen.json).
|
||||||
|
*
|
||||||
|
* @return array{x: float, y: float, w: float, h: float}|null
|
||||||
|
*/
|
||||||
|
public static function bounds(string $name): ?array
|
||||||
|
{
|
||||||
|
self::$bounds ??= (function (): array {
|
||||||
|
$file = self::directory(self::SET_SYMBOLS).'/_grenzen.json';
|
||||||
|
$data = is_file($file) ? json_decode((string) file_get_contents($file), true) : null;
|
||||||
|
|
||||||
|
return is_array($data) ? $data : [];
|
||||||
|
})();
|
||||||
|
|
||||||
|
$box = self::$bounds[$name] ?? null;
|
||||||
|
|
||||||
|
return is_array($box) && isset($box['x'], $box['y'], $box['w'], $box['h']) && $box['w'] > 0 && $box['h'] > 0 ? $box : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array{x: float, y: float, w: float, h: float}|null $bounds
|
||||||
|
*/
|
||||||
|
private static function clean(string $svg, ?array $bounds = null): string
|
||||||
|
{
|
||||||
|
$svg = trim($svg);
|
||||||
|
$svg = preg_replace('#<title\b[^>]*>.*?</title>#s', '', $svg) ?? $svg;
|
||||||
|
$svg = preg_replace('/\r?\n\s*/', '', $svg) ?? $svg;
|
||||||
|
|
||||||
|
return (string) preg_replace_callback('/^<svg\b[^>]*>/', function (array $root) use ($bounds): string {
|
||||||
|
$tag = (string) preg_replace('/\s(?:id|role|aria-labelledby|width|height)="[^"]*"/', '', $root[0]);
|
||||||
|
|
||||||
|
if ($bounds !== null) {
|
||||||
|
$tag = (string) preg_replace('/\sviewBox="[^"]*"/', ' viewBox="'.implode(' ', [$bounds['x'], $bounds['y'], $bounds['w'], $bounds['h']]).'"', $tag, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tag;
|
||||||
|
}, $svg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function directory(string $set): string
|
||||||
|
{
|
||||||
|
if (! in_array($set, [self::SET_SYMBOLS, self::SET_GLYPHS], true)) {
|
||||||
|
throw new InvalidArgumentException("Unbekannter Symbolsatz „{$set}“.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return resource_path("svg/brand/$set");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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,
|
||||||
|
|||||||
@@ -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,
|
||||||
|
],
|
||||||
|
];
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ExerciseSections;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Übungsabschnitte im gemeinsamen Medienbestand (Auftrag Übungsverwaltung, Abschnitt 9), rein additiv:
|
||||||
|
*
|
||||||
|
* - `content_elements.origin_composition_id` hält fest, für welche Übung ein Textabschnitt angelegt wurde.
|
||||||
|
* - Die fachliche Materialart `uebungsabschnitt` entsteht als System-Art ohne wählbaren Kontext: Sie wird nur
|
||||||
|
* automatisch gesetzt.
|
||||||
|
* - `user_view_defaults` hält den persönlichen Standard der Filter je Konto und Ansicht.
|
||||||
|
*
|
||||||
|
* Der Rückfall auf den vorherigen Programmstand setzt nur den Code zurück. Dieser kennt die Spalte und die Tabelle nicht
|
||||||
|
* und behandelt die neue Materialart wie jede andere Zeile der redaktionellen Stammdaten. Texte bleiben lesbar,
|
||||||
|
* auslieferbar und bearbeitbar; es geht nichts verloren.
|
||||||
|
*
|
||||||
|
* Bestehende Texte werden nur zugeordnet, wenn ihre Herkunft belegt ist (siehe ExerciseSections::backfill()).
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('content_elements', function (Blueprint $table) {
|
||||||
|
$table->foreignId('origin_composition_id')->nullable()->constrained('compositions')->nullOnDelete();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('user_view_defaults', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->string('view');
|
||||||
|
$table->json('filters');
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->unique(['user_id', 'view']);
|
||||||
|
});
|
||||||
|
|
||||||
|
$now = now();
|
||||||
|
DB::table('editorial_content_kinds')->insertOrIgnore([
|
||||||
|
'slug' => 'uebungsabschnitt',
|
||||||
|
'label' => 'Übungsabschnitt',
|
||||||
|
'sort_order' => 26,
|
||||||
|
'is_active' => true,
|
||||||
|
'contexts' => json_encode([]),
|
||||||
|
'created_at' => $now,
|
||||||
|
'updated_at' => $now,
|
||||||
|
]);
|
||||||
|
|
||||||
|
app(ExerciseSections::class)->backfill();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
DB::table('content_elements')
|
||||||
|
->whereIn('editorial_content_kind_id', DB::table('editorial_content_kinds')->where('slug', 'uebungsabschnitt')->select('id'))
|
||||||
|
->update(['editorial_content_kind_id' => null]);
|
||||||
|
DB::table('editorial_content_kinds')->where('slug', 'uebungsabschnitt')->delete();
|
||||||
|
|
||||||
|
Schema::dropIfExists('user_view_defaults');
|
||||||
|
Schema::table('content_elements', function (Blueprint $table) {
|
||||||
|
$table->dropConstrainedForeignId('origin_composition_id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
After Width: | Height: | Size: 36 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 835 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 44 KiB |
@@ -0,0 +1,9 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 64 64" role="img" aria-labelledby="favicon-title">
|
||||||
|
<title id="favicon-title">Lara & Felix</title>
|
||||||
|
<rect x="1" y="1" width="62" height="62" rx="15" fill="#032551" stroke="#426184" stroke-width="2"/>
|
||||||
|
<g fill="none" stroke="#fff" stroke-width="8.4" stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
<path d="M14.8 20 Q14 31 14.8 39 Q20.6 39 25.4 37.8"/>
|
||||||
|
<path d="M37.4 38.8 Q36.8 29.1 37.8 18.6 Q44.6 17.1 50.1 18.2 M37.5 28.7 Q43 27.9 47.4 28.1"/>
|
||||||
|
</g>
|
||||||
|
<path d="M13 51 Q31 44.2 51 49.3" fill="none" stroke="#FCD10A" stroke-width="5.5" stroke-linecap="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 661 B |
|
After Width: | Height: | Size: 40 KiB |
|
After Width: | Height: | Size: 8.5 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 7.3 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 32 KiB |
|
After Width: | Height: | Size: 31 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 9.1 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 7.7 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 43 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 8.4 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 6.9 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 6.6 KiB |
|
After Width: | Height: | Size: 90 KiB |
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 118 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 250 129" width="250" height="129" role="img" aria-labelledby="motif-title">
|
||||||
|
<title id="motif-title">Alltagssituationen</title>
|
||||||
|
<g transform="translate(81 2) scale(.92)"><g transform="translate(0 5) rotate(-7 36 54)"><rect x="10" y="47" width="53" height="33" rx="4.7" fill="none" stroke="#032551" stroke-width="3.9"/><g transform="translate(16.9 44.8) scale(.38)"><path d="M37 26 Q37 22 41 24 L72 43 Q77 47 72 51 L41 70 Q37 73 37 68Z" fill="#032551"/></g><g transform="rotate(-11 11 48)"><rect x="10" y="36" width="53" height="12" rx="3.7" fill="none" stroke="#032551" stroke-width="3.8"/><path d="M16 46 L22 37 M27 47 L33 37 M39 47 L45 37 M51 47 L57 37" fill="none" stroke="#032551" stroke-width="3.6" stroke-linecap="round" stroke-linejoin="round"/></g></g><g transform="translate(61 2) rotate(8 16 20) scale(.86)"><path d="M5 23 L9 9 M16 26 L28 16 M20 35 L35 33" fill="none" stroke="#FCD10A" stroke-width="5.5" stroke-linecap="round" stroke-linejoin="round"/></g></g><path d="M36.25 115.08Q36.33 115.33 36.33 115.57Q36.33 115.9 36.19 116.16Q36.05 116.43 35.82 116.61Q35.59 116.79 35.3 116.89Q35 116.99 34.7 116.99Q34.25 116.99 33.85 116.74Q33.45 116.49 33.32 115.95L32.05 112.69H24.22L22.97 115.95Q22.82 116.5 22.44 116.74Q22.05 116.99 21.61 116.99Q21.32 116.99 21.03 116.89Q20.73 116.79 20.51 116.61Q20.28 116.43 20.14 116.17Q20 115.91 20 115.6Q20 115.47 20.02 115.35Q20.04 115.22 20.1 115.08L25.23 102.27Q25.53 101.41 25.84 100.87Q26.14 100.33 26.49 100.01Q26.84 99.7 27.25 99.58Q27.65 99.46 28.16 99.46Q28.67 99.46 29.08 99.59Q29.5 99.71 29.85 100.03Q30.19 100.35 30.5 100.89Q30.8 101.44 31.1 102.27ZM28.12 101.96 24.9 110.64H31.38L28.17 101.96ZM38.85 100.87Q38.85 100.52 38.97 100.26Q39.1 100 39.3 99.82Q39.5 99.64 39.76 99.55Q40.02 99.46 40.29 99.46Q40.56 99.46 40.82 99.55Q41.07 99.64 41.27 99.82Q41.48 100 41.6 100.26Q41.72 100.52 41.72 100.87V115.58Q41.72 115.94 41.59 116.2Q41.46 116.46 41.26 116.64Q41.06 116.82 40.8 116.91Q40.54 117 40.27 117Q40 117 39.74 116.91Q39.49 116.83 39.29 116.65Q39.1 116.48 38.97 116.21Q38.85 115.94 38.85 115.58ZM45.21 100.87Q45.21 100.52 45.34 100.26Q45.46 100 45.66 99.82Q45.86 99.64 46.12 99.55Q46.39 99.46 46.65 99.46Q46.92 99.46 47.18 99.55Q47.44 99.64 47.64 99.82Q47.84 100 47.96 100.26Q48.08 100.52 48.08 100.87V115.58Q48.08 115.94 47.95 116.2Q47.83 116.46 47.62 116.64Q47.42 116.82 47.16 116.91Q46.9 117 46.63 117Q46.36 117 46.11 116.91Q45.85 116.83 45.65 116.65Q45.46 116.48 45.34 116.21Q45.21 115.94 45.21 115.58ZM52.65 104.78 52.88 101.5Q52.91 101.23 53.04 101.01Q53.16 100.8 53.36 100.65Q53.55 100.51 53.79 100.44Q54.02 100.36 54.25 100.36Q54.69 100.36 55.03 100.63Q55.37 100.9 55.37 101.47V104.78H57.24Q57.74 104.78 58 105.09Q58.25 105.4 58.25 105.77Q58.25 106.14 58 106.44Q57.75 106.75 57.24 106.75H55.37V111.82Q55.37 112.69 55.4 113.29Q55.43 113.89 55.56 114.26Q55.69 114.63 55.97 114.8Q56.24 114.96 56.73 114.96Q56.85 114.96 57 114.95Q57.14 114.94 57.29 114.92Q57.44 114.9 57.56 114.89Q57.69 114.88 57.77 114.88Q58.23 114.88 58.49 115.18Q58.74 115.49 58.74 115.86Q58.74 116.26 58.5 116.5Q58.27 116.74 57.88 116.89Q57.5 117.04 57.02 117.09Q56.55 117.15 56.06 117.15Q55.2 117.15 54.54 116.93Q53.88 116.71 53.43 116.2Q52.98 115.69 52.74 114.86Q52.5 114.03 52.5 112.83V106.75H51.32Q50.81 106.75 50.56 106.44Q50.31 106.14 50.31 105.77Q50.31 105.4 50.56 105.09Q50.82 104.78 51.33 104.78ZM67.95 108.87Q67.95 108.25 67.77 107.83Q67.6 107.42 67.28 107.16Q66.96 106.9 66.52 106.79Q66.07 106.69 65.53 106.69Q64.92 106.69 64.42 106.75Q63.92 106.82 63.49 106.94Q63.05 107.06 62.68 107.22Q62.3 107.37 61.93 107.54Q61.75 107.61 61.57 107.61Q61.39 107.61 61.24 107.55Q61.09 107.48 60.97 107.36Q60.86 107.25 60.79 107.09Q60.72 106.94 60.72 106.78Q60.72 106.65 60.77 106.54Q60.81 106.44 60.89 106.31Q61.48 105.43 62.71 105.03Q63.95 104.63 65.69 104.63Q66.75 104.63 67.66 104.88Q68.57 105.12 69.23 105.65Q69.89 106.18 70.26 107.03Q70.64 107.88 70.64 109.09V115.74Q70.62 116.06 70.51 116.29Q70.39 116.52 70.2 116.68Q70.01 116.84 69.77 116.92Q69.54 117 69.29 117Q69.06 117 68.83 116.93Q68.61 116.85 68.43 116.71Q68.25 116.56 68.14 116.34Q68.03 116.12 68.02 115.83V114.91Q67.77 115.35 67.35 115.8Q66.92 116.24 66.38 116.54Q65.84 116.84 65.23 116.99Q64.62 117.15 63.99 117.15Q63.12 117.15 62.35 116.9Q61.59 116.66 61.03 116.19Q60.48 115.73 60.16 115.05Q59.84 114.36 59.84 113.64Q59.84 112.52 60.33 111.73Q60.81 110.95 61.71 110.45Q62.6 109.96 63.87 109.74Q65.14 109.52 66.72 109.52Q66.96 109.52 67.32 109.52Q67.68 109.53 67.95 109.54ZM67.94 111.14Q67.84 111.14 67.7 111.15Q67.56 111.15 67.41 111.15Q67.25 111.15 67.1 111.15Q66.95 111.15 66.83 111.15Q66.06 111.15 65.29 111.24Q64.52 111.32 63.9 111.57Q63.29 111.82 62.9 112.28Q62.52 112.74 62.52 113.47Q62.52 113.84 62.7 114.23Q62.88 114.62 63.19 114.88Q63.51 115.13 63.93 115.26Q64.36 115.39 64.85 115.4Q65.5 115.39 66.05 115.17Q66.61 114.95 67.02 114.52Q67.44 114.08 67.67 113.52Q67.91 112.96 67.94 112.12ZM82.83 110.92Q82.83 109.97 82.67 109.23Q82.5 108.49 82.12 107.88Q81.75 107.26 81.12 106.9Q80.49 106.54 79.56 106.54Q78.66 106.54 78.07 106.88Q77.47 107.22 77.11 107.83Q76.75 108.43 76.61 109.25Q76.46 110.07 76.46 110.88Q76.46 112.03Line truncated
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 19 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" width="96" height="96" role="img" aria-labelledby="motif-title">
|
||||||
|
<title id="motif-title">Bildung</title>
|
||||||
|
<path d="M25 47 V64 C37 75 59 75 71 64 V47 M82 44 V65" fill="none" stroke="#032551" stroke-width="4.2" stroke-linecap="round" stroke-linejoin="round"/><path d="M9 37 L48 22 L87 37 L48 53Z" fill="none" stroke="#3B7B09" stroke-width="4.6" stroke-linecap="round" stroke-linejoin="round"/><circle cx="82" cy="68" r="3.6" fill="#FCD10A" stroke="none" stroke-width="0"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 541 B |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" width="96" height="96" role="img" aria-labelledby="motif-title">
|
||||||
|
<title id="motif-title">Aufgeschlagenes Buch</title>
|
||||||
|
<path d="M19 29 C29 24 39 25 48 32 C57 25 67 24 77 29 V66 C65 62 55 64 48 70 C41 64 31 62 19 66Z M48 32 V70" fill="none" stroke="#032551" stroke-width="4.3" stroke-linecap="round" stroke-linejoin="round"/><path d="M19 33 H12 V75 C24 70 37 71 48 77 C59 71 72 70 84 75 V33 H77" fill="none" stroke="#3B7B09" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 560 B |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 176 71" width="176" height="71" role="img" aria-labelledby="motif-title">
|
||||||
|
<title id="motif-title">Das ist nicht okay!</title>
|
||||||
|
<rect x="5" y="5" width="166" height="61" rx="30.5" fill="#FFF2F1" stroke="#E6BDC1" stroke-width="1.5"/><circle cx="37" cy="35.5" r="22.5" fill="#BC2335" stroke="none" stroke-width="0"/><g transform="translate(9.2 7.7) scale(.58)"><path d="M33 33 L63 63 M63 33 L33 63" fill="none" stroke="#FFFFFF" stroke-width="7.5" stroke-linecap="round" stroke-linejoin="round"/></g><path d="M70.7 31Q70.45 31 70.23 30.91Q70 30.82 69.84 30.65Q69.67 30.49 69.57 30.27Q69.48 30.05 69.48 29.81V19Q69.48 18.75 69.57 18.53Q69.67 18.31 69.84 18.15Q70 17.99 70.23 17.9Q70.45 17.8 70.7 17.8H73.97Q75.75 17.8 77.07 18.24Q78.39 18.69 79.27 19.54Q80.14 20.39 80.58 21.63Q81.01 22.87 81.01 24.45Q81.01 26.04 80.53 27.26Q80.06 28.48 79.17 29.32Q78.28 30.15 76.99 30.57Q75.69 31 74.06 31ZM71.92 29.32H73.99Q75.19 29.32 76.03 28.99Q76.87 28.65 77.4 28.02Q77.93 27.38 78.18 26.47Q78.42 25.57 78.42 24.41Q78.42 23.13 78.11 22.21Q77.79 21.28 77.19 20.67Q76.58 20.07 75.69 19.78Q74.8 19.49 73.65 19.49H71.92ZM88.75 24.89Q88.75 24.42 88.62 24.11Q88.48 23.79 88.24 23.6Q88 23.41 87.67 23.33Q87.33 23.24 86.93 23.24Q86.47 23.24 86.1 23.29Q85.72 23.34 85.39 23.44Q85.07 23.53 84.78 23.64Q84.5 23.76 84.22 23.89Q84.09 23.94 83.95 23.94Q83.82 23.94 83.7 23.89Q83.59 23.84 83.5 23.75Q83.41 23.67 83.36 23.55Q83.31 23.44 83.31 23.32Q83.31 23.22 83.35 23.14Q83.38 23.06 83.44 22.96Q83.88 22.3 84.81 22Q85.74 21.7 87.05 21.7Q87.85 21.7 88.53 21.88Q89.22 22.07 89.71 22.47Q90.21 22.87 90.49 23.5Q90.77 24.14 90.77 25.05V30.05Q90.76 30.29 90.67 30.47Q90.58 30.64 90.44 30.76Q90.3 30.88 90.12 30.94Q89.94 31 89.76 31Q89.58 31 89.41 30.94Q89.24 30.89 89.11 30.78Q88.98 30.67 88.9 30.5Q88.81 30.34 88.8 30.12V29.43Q88.61 29.76 88.29 30.1Q87.98 30.43 87.57 30.66Q87.16 30.88 86.7 31Q86.24 31.11 85.77 31.11Q85.11 31.11 84.54 30.93Q83.97 30.74 83.55 30.39Q83.13 30.05 82.89 29.53Q82.65 29.02 82.65 28.48Q82.65 27.63 83.02 27.04Q83.38 26.45 84.05 26.08Q84.73 25.7 85.68 25.54Q86.64 25.37 87.82 25.37Q88 25.37 88.28 25.38Q88.55 25.38 88.75 25.39ZM88.74 26.59Q88.67 26.59 88.56 26.6Q88.45 26.6 88.34 26.6Q88.23 26.6 88.11 26.6Q88 26.6 87.9 26.6Q87.33 26.6 86.75 26.67Q86.17 26.73 85.71 26.92Q85.24 27.11 84.95 27.45Q84.66 27.8 84.66 28.35Q84.66 28.62 84.8 28.92Q84.94 29.21 85.17 29.4Q85.41 29.6 85.73 29.69Q86.05 29.79 86.42 29.8Q86.9 29.79 87.32 29.62Q87.74 29.46 88.05 29.13Q88.36 28.81 88.54 28.38Q88.72 27.96 88.74 27.33ZM95.08 24.18Q95.08 24.46 95.24 24.66Q95.41 24.85 95.69 24.99Q95.97 25.13 96.36 25.24Q96.75 25.34 97.2 25.44Q97.65 25.54 98.14 25.68Q98.63 25.81 99.11 25.98Q99.99 26.24 100.49 26.79Q100.99 27.34 100.99 28.16Q100.99 28.84 100.67 29.41Q100.34 29.98 99.78 30.36Q99.22 30.73 98.48 30.92Q97.73 31.11 96.87 31.11Q96.1 31.11 95.41 30.98Q94.72 30.85 94.19 30.63Q93.67 30.41 93.36 30.12Q93.06 29.82 93.06 29.49Q93.06 29.24 93.26 29.06Q93.46 28.89 93.77 28.89Q93.96 28.89 94.27 29.01Q94.58 29.13 95 29.29Q95.42 29.46 95.94 29.58Q96.45 29.7 97.05 29.7Q97.42 29.7 97.76 29.62Q98.11 29.54 98.38 29.37Q98.66 29.2 98.82 28.94Q98.99 28.68 98.99 28.32Q98.99 27.99 98.7 27.7Q98.41 27.41 97.88 27.25Q97.27 27.08 96.68 26.95Q96.09 26.82 95.55 26.68Q95.01 26.54 94.56 26.36Q94.1 26.17 93.78 25.89Q93.45 25.61 93.26 25.21Q93.07 24.8 93.07 24.23Q93.07 23.67 93.37 23.17Q93.66 22.67 94.18 22.34Q94.7 22.01 95.41 21.86Q96.11 21.7 96.94 21.7Q97.8 21.7 98.44 21.83Q99.09 21.96 99.51 22.16Q99.94 22.37 100.15 22.63Q100.36 22.89 100.36 23.16Q100.36 23.42 100.16 23.56Q99.96 23.7 99.67 23.7Q99.56 23.7 99.46 23.68Q99.35 23.66 99.25 23.6Q98.88 23.39 98.35 23.26Q97.81 23.13 97.03 23.13Q96.59 23.13 96.23 23.19Q95.86 23.25 95.61 23.39Q95.36 23.53 95.22 23.77Q95.08 24.01 95.08 24.18ZM111.14 18.76Q111.14 19.21 110.79 19.5Q110.43 19.79 109.87 19.79Q109.59 19.79 109.36 19.71Q109.12 19.64 108.95 19.5Q108.78 19.36 108.69 19.17Q108.59 18.98 108.59 18.76Q108.59 18.54 108.69 18.35Q108.78 18.17 108.95 18.03Q109.12 17.89 109.36 17.81Q109.6 17.74 109.88 17.74Q110.15 17.74 110.39 17.81Q110.62 17.89 110.79 18.03Q110.95 18.17 111.05 18.35Q111.14 18.54 111.14 18.76ZM108.79 22.88Q108.79 22.61 108.89 22.41Q108.98 22.22 109.13 22.08Q109.28 21.95 109.48 21.88Q109.68 21.81 109.88 21.81Q110.08 21.81 110.27 21.88Q110.46 21.95 110.62 22.08Q110.77 22.22 110.86 22.41Q110.95 22.61 110.95 22.88V29.94Q110.95 30.2 110.86 30.4Q110.76 30.6 110.61 30.73Q110.46 30.86 110.26 30.93Q110.06 31 109.86 31Q109.66 31 109.46 30.94Q109.27 30.87 109.12 30.74Q108.98 30.61 108.89 30.4Q108.79 30.2 108.79 29.94ZM115.3 24.18Q115.3 24.46 115.46 24.66Q115.63 24.85 115.91 24.99Q116.2 25.13 116.58 25.24Q116.97 25.34 117.42 25.44Q117.87 25.54 118.36 25.68Q118.85 25.81 119.33 25.98Q120.21 26.24 120.71 26.79Q121.21 27.34 121.21 28.16Q121.21 28.84 120.89 29.41Q120.56 29.98 120 30.36Q119.44 30.73 118.7 30.92Q117.95 31.11 117.09 31.11Q116.32 31.11 115.63 30.98Q114.94 30.85 114.41 30.63Q113.89 30.41 113.58 30.12Q113.28 29.82 113.28 29.49Q113.28 29.24 113.48 29.06Q113.68 28.89 113.99 28.89Q114.18 28.89 114.49 29.01Q114.8 29.13 115.22 29.29Q115.64 29.46 116.16 29.58Q116.67 29.7 117.27 29.7Q1Line truncated
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 176 71" width="176" height="71" role="img" aria-labelledby="motif-title">
|
||||||
|
<title id="motif-title">Das ist okay!</title>
|
||||||
|
<rect x="5" y="5" width="166" height="61" rx="30.5" fill="#F1F6E9" stroke="#B8CDA7" stroke-width="1.5"/><circle cx="37" cy="35.5" r="22.5" fill="#3B7B09" stroke="none" stroke-width="0"/><g transform="translate(9.2 7.7) scale(.58)"><path d="M27 49 L41 63 L70 33" fill="none" stroke="#FFFFFF" stroke-width="7.5" stroke-linecap="round" stroke-linejoin="round"/></g><path d="M70.7 31Q70.45 31 70.23 30.91Q70 30.82 69.84 30.65Q69.67 30.49 69.57 30.27Q69.48 30.05 69.48 29.81V19Q69.48 18.75 69.57 18.53Q69.67 18.31 69.84 18.15Q70 17.99 70.23 17.9Q70.45 17.8 70.7 17.8H73.97Q75.75 17.8 77.07 18.24Q78.39 18.69 79.27 19.54Q80.14 20.39 80.58 21.63Q81.01 22.87 81.01 24.45Q81.01 26.04 80.53 27.26Q80.06 28.48 79.17 29.32Q78.28 30.15 76.99 30.57Q75.69 31 74.06 31ZM71.92 29.32H73.99Q75.19 29.32 76.03 28.99Q76.87 28.65 77.4 28.02Q77.93 27.38 78.18 26.47Q78.42 25.57 78.42 24.41Q78.42 23.13 78.11 22.21Q77.79 21.28 77.19 20.67Q76.58 20.07 75.69 19.78Q74.8 19.49 73.65 19.49H71.92ZM88.75 24.89Q88.75 24.42 88.62 24.11Q88.48 23.79 88.24 23.6Q88 23.41 87.67 23.33Q87.33 23.24 86.93 23.24Q86.47 23.24 86.1 23.29Q85.72 23.34 85.39 23.44Q85.07 23.53 84.78 23.64Q84.5 23.76 84.22 23.89Q84.09 23.94 83.95 23.94Q83.82 23.94 83.7 23.89Q83.59 23.84 83.5 23.75Q83.41 23.67 83.36 23.55Q83.31 23.44 83.31 23.32Q83.31 23.22 83.35 23.14Q83.38 23.06 83.44 22.96Q83.88 22.3 84.81 22Q85.74 21.7 87.05 21.7Q87.85 21.7 88.53 21.88Q89.22 22.07 89.71 22.47Q90.21 22.87 90.49 23.5Q90.77 24.14 90.77 25.05V30.05Q90.76 30.29 90.67 30.47Q90.58 30.64 90.44 30.76Q90.3 30.88 90.12 30.94Q89.94 31 89.76 31Q89.58 31 89.41 30.94Q89.24 30.89 89.11 30.78Q88.98 30.67 88.9 30.5Q88.81 30.34 88.8 30.12V29.43Q88.61 29.76 88.29 30.1Q87.98 30.43 87.57 30.66Q87.16 30.88 86.7 31Q86.24 31.11 85.77 31.11Q85.11 31.11 84.54 30.93Q83.97 30.74 83.55 30.39Q83.13 30.05 82.89 29.53Q82.65 29.02 82.65 28.48Q82.65 27.63 83.02 27.04Q83.38 26.45 84.05 26.08Q84.73 25.7 85.68 25.54Q86.64 25.37 87.82 25.37Q88 25.37 88.28 25.38Q88.55 25.38 88.75 25.39ZM88.74 26.59Q88.67 26.59 88.56 26.6Q88.45 26.6 88.34 26.6Q88.23 26.6 88.11 26.6Q88 26.6 87.9 26.6Q87.33 26.6 86.75 26.67Q86.17 26.73 85.71 26.92Q85.24 27.11 84.95 27.45Q84.66 27.8 84.66 28.35Q84.66 28.62 84.8 28.92Q84.94 29.21 85.17 29.4Q85.41 29.6 85.73 29.69Q86.05 29.79 86.42 29.8Q86.9 29.79 87.32 29.62Q87.74 29.46 88.05 29.13Q88.36 28.81 88.54 28.38Q88.72 27.96 88.74 27.33ZM95.08 24.18Q95.08 24.46 95.24 24.66Q95.41 24.85 95.69 24.99Q95.97 25.13 96.36 25.24Q96.75 25.34 97.2 25.44Q97.65 25.54 98.14 25.68Q98.63 25.81 99.11 25.98Q99.99 26.24 100.49 26.79Q100.99 27.34 100.99 28.16Q100.99 28.84 100.67 29.41Q100.34 29.98 99.78 30.36Q99.22 30.73 98.48 30.92Q97.73 31.11 96.87 31.11Q96.1 31.11 95.41 30.98Q94.72 30.85 94.19 30.63Q93.67 30.41 93.36 30.12Q93.06 29.82 93.06 29.49Q93.06 29.24 93.26 29.06Q93.46 28.89 93.77 28.89Q93.96 28.89 94.27 29.01Q94.58 29.13 95 29.29Q95.42 29.46 95.94 29.58Q96.45 29.7 97.05 29.7Q97.42 29.7 97.76 29.62Q98.11 29.54 98.38 29.37Q98.66 29.2 98.82 28.94Q98.99 28.68 98.99 28.32Q98.99 27.99 98.7 27.7Q98.41 27.41 97.88 27.25Q97.27 27.08 96.68 26.95Q96.09 26.82 95.55 26.68Q95.01 26.54 94.56 26.36Q94.1 26.17 93.78 25.89Q93.45 25.61 93.26 25.21Q93.07 24.8 93.07 24.23Q93.07 23.67 93.37 23.17Q93.66 22.67 94.18 22.34Q94.7 22.01 95.41 21.86Q96.11 21.7 96.94 21.7Q97.8 21.7 98.44 21.83Q99.09 21.96 99.51 22.16Q99.94 22.37 100.15 22.63Q100.36 22.89 100.36 23.16Q100.36 23.42 100.16 23.56Q99.96 23.7 99.67 23.7Q99.56 23.7 99.46 23.68Q99.35 23.66 99.25 23.6Q98.88 23.39 98.35 23.26Q97.81 23.13 97.03 23.13Q96.59 23.13 96.23 23.19Q95.86 23.25 95.61 23.39Q95.36 23.53 95.22 23.77Q95.08 24.01 95.08 24.18ZM111.14 18.76Q111.14 19.21 110.79 19.5Q110.43 19.79 109.87 19.79Q109.59 19.79 109.36 19.71Q109.12 19.64 108.95 19.5Q108.78 19.36 108.69 19.17Q108.59 18.98 108.59 18.76Q108.59 18.54 108.69 18.35Q108.78 18.17 108.95 18.03Q109.12 17.89 109.36 17.81Q109.6 17.74 109.88 17.74Q110.15 17.74 110.39 17.81Q110.62 17.89 110.79 18.03Q110.95 18.17 111.05 18.35Q111.14 18.54 111.14 18.76ZM108.79 22.88Q108.79 22.61 108.89 22.41Q108.98 22.22 109.13 22.08Q109.28 21.95 109.48 21.88Q109.68 21.81 109.88 21.81Q110.08 21.81 110.27 21.88Q110.46 21.95 110.62 22.08Q110.77 22.22 110.86 22.41Q110.95 22.61 110.95 22.88V29.94Q110.95 30.2 110.86 30.4Q110.76 30.6 110.61 30.73Q110.46 30.86 110.26 30.93Q110.06 31 109.86 31Q109.66 31 109.46 30.94Q109.27 30.87 109.12 30.74Q108.98 30.61 108.89 30.4Q108.79 30.2 108.79 29.94ZM115.3 24.18Q115.3 24.46 115.46 24.66Q115.63 24.85 115.91 24.99Q116.2 25.13 116.58 25.24Q116.97 25.34 117.42 25.44Q117.87 25.54 118.36 25.68Q118.85 25.81 119.33 25.98Q120.21 26.24 120.71 26.79Q121.21 27.34 121.21 28.16Q121.21 28.84 120.89 29.41Q120.56 29.98 120 30.36Q119.44 30.73 118.7 30.92Q117.95 31.11 117.09 31.11Q116.32 31.11 115.63 30.98Q114.94 30.85 114.41 30.63Q113.89 30.41 113.58 30.12Q113.28 29.82 113.28 29.49Q113.28 29.24 113.48 29.06Q113.68 28.89 113.99 28.89Q114.18 28.89 114.49 29.01Q114.8 29.13 115.22 29.29Q115.64 29.46 116.16 29.58Q116.67 29.7 117.27 29.7Q117.64 2Line truncated
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 224 74" width="224" height="74" role="img" aria-labelledby="motif-title">
|
||||||
|
<title id="motif-title">Denkpause</title>
|
||||||
|
<rect x="10" y="11" width="207" height="51" rx="25.5" fill="#3B7B09" stroke="#FFFFFF" stroke-width="2.3"/><circle cx="33" cy="36.5" r="27.7" fill="#3B7B09" stroke="#FFFFFF" stroke-width="3.1"/><g transform="translate(9 10) scale(.55)"><path d="M30 51 V31 C30 25 37 24 38 31 V45 V19 C38 13 46 13 46 19 V43 V15 C46 9 54 9 54 15 V43 V21 C54 15 62 15 62 21 V46 V29 C62 23 70 23 70 29 V58 C70 73 62 83 49 83 H44 C36 82 30 77 25 69 L17 56 C13 49 21 45 26 50 L34 58 L30 51Z" fill="#FFFFFF"/><path d="M34 57 Q43 58 46 66" fill="none" stroke="#3B7B09" stroke-width="3.6" stroke-linecap="round" stroke-linejoin="round"/></g><path d="M74.33 45Q74 45 73.7 44.88Q73.4 44.76 73.18 44.54Q72.96 44.32 72.84 44.03Q72.71 43.74 72.71 43.41V29.05Q72.71 28.72 72.84 28.42Q72.96 28.13 73.18 27.92Q73.4 27.7 73.7 27.57Q74 27.45 74.33 27.45H78.68Q81.04 27.45 82.8 28.04Q84.56 28.63 85.73 29.76Q86.89 30.89 87.47 32.54Q88.04 34.18 88.04 36.3Q88.04 38.41 87.41 40.03Q86.78 41.66 85.6 42.76Q84.41 43.86 82.69 44.43Q80.97 45 78.8 45ZM75.95 42.77H78.71Q80.3 42.77 81.42 42.32Q82.53 41.88 83.24 41.03Q83.95 40.19 84.27 38.98Q84.6 37.77 84.6 36.24Q84.6 34.54 84.18 33.31Q83.77 32.07 82.96 31.27Q82.16 30.46 80.97 30.08Q79.79 29.69 78.26 29.69H75.95ZM102.57 38.49Q102.57 38.82 102.35 39.07Q102.14 39.32 101.7 39.32H93.39Q93.5 41.09 94.48 42.07Q95.46 43.05 97.08 43.05Q98.06 43.05 98.94 42.77Q99.82 42.49 100.74 42.02Q100.96 41.91 101.15 41.91Q101.48 41.91 101.68 42.16Q101.88 42.4 101.88 42.72Q101.88 42.85 101.84 43Q101.8 43.16 101.7 43.29Q101.31 43.79 100.74 44.15Q100.18 44.5 99.52 44.72Q98.86 44.94 98.16 45.04Q97.45 45.15 96.79 45.15Q95.46 45.15 94.32 44.71Q93.17 44.27 92.32 43.43Q91.47 42.6 90.99 41.37Q90.51 40.14 90.51 38.84Q90.51 37.72 90.96 36.58Q91.41 35.43 92.2 34.58Q92.99 33.72 94.09 33.18Q95.2 32.63 96.66 32.63Q98.16 32.63 99.25 33.11Q100.35 33.59 101.07 34.38Q101.8 35.17 102.17 36.28Q102.54 37.38 102.57 38.49ZM100.03 37.86Q99.98 37.27 99.75 36.61Q99.52 35.95 99.1 35.48Q98.67 35.01 98.07 34.78Q97.47 34.54 96.68 34.54Q95.98 34.54 95.4 34.79Q94.82 35.05 94.4 35.54Q93.97 36.03 93.72 36.67Q93.46 37.32 93.41 37.86ZM105.4 34.12Q105.4 33.79 105.53 33.54Q105.65 33.28 105.85 33.12Q106.05 32.95 106.31 32.87Q106.58 32.78 106.84 32.78Q107.11 32.78 107.36 32.86Q107.61 32.94 107.81 33.1Q108.02 33.27 108.14 33.51Q108.26 33.75 108.27 34.07V35.03Q108.49 34.58 108.91 34.1Q109.33 33.62 109.88 33.3Q110.43 32.98 111.07 32.81Q111.7 32.63 112.36 32.63Q113.22 32.63 113.99 32.9Q114.77 33.17 115.36 33.74Q115.95 34.31 116.3 35.19Q116.65 36.08 116.65 37.3V43.62Q116.65 43.96 116.52 44.22Q116.4 44.48 116.2 44.65Q116 44.83 115.74 44.91Q115.47 45 115.21 45Q114.94 45 114.69 44.91Q114.44 44.83 114.24 44.65Q114.03 44.48 113.91 44.22Q113.79 43.96 113.79 43.62V37.27Q113.79 36.58 113.59 36.06Q113.4 35.55 113.07 35.21Q112.74 34.87 112.3 34.7Q111.86 34.54 111.37 34.54Q110.73 34.54 110.16 34.75Q109.6 34.95 109.18 35.37Q108.76 35.8 108.52 36.35Q108.27 36.89 108.27 37.75V43.62Q108.27 43.96 108.15 44.22Q108.03 44.48 107.83 44.65Q107.62 44.83 107.36 44.91Q107.1 45 106.83 45Q106.56 45 106.31 44.91Q106.05 44.83 105.85 44.65Q105.65 44.48 105.53 44.22Q105.4 43.96 105.4 43.62ZM123.08 38.49V43.57Q123.08 43.93 122.95 44.19Q122.83 44.46 122.62 44.64Q122.42 44.82 122.16 44.91Q121.9 45 121.63 45Q121.36 45 121.11 44.91Q120.86 44.82 120.67 44.64Q120.47 44.46 120.35 44.19Q120.23 43.93 120.23 43.57V28.87Q120.23 28.53 120.35 28.26Q120.47 28 120.67 27.82Q120.87 27.64 121.13 27.55Q121.39 27.46 121.67 27.46Q121.93 27.46 122.18 27.55Q122.44 27.64 122.64 27.82Q122.84 28 122.96 28.26Q123.08 28.53 123.08 28.87V37.69L127.9 33.29Q128.17 33.05 128.41 32.92Q128.65 32.78 128.92 32.78Q129.17 32.78 129.41 32.87Q129.64 32.96 129.82 33.12Q130 33.28 130.11 33.49Q130.22 33.7 130.22 33.93Q130.22 34.12 130.16 34.3Q130.09 34.48 129.92 34.62L125.87 38.1L130.48 43.14Q130.63 43.3 130.66 43.47Q130.7 43.65 130.7 43.8Q130.7 44.05 130.58 44.27Q130.47 44.49 130.27 44.65Q130.08 44.82 129.83 44.91Q129.58 45 129.32 45Q129.03 45 128.77 44.84Q128.51 44.68 128.27 44.4ZM135.76 34.99Q136.09 34.49 136.55 34.03Q137.01 33.56 137.57 33.25Q138.12 32.94 138.75 32.79Q139.38 32.63 140.04 32.63Q141.3 32.63 142.24 33.16Q143.19 33.68 143.82 34.58Q144.45 35.47 144.76 36.63Q145.07 37.8 145.07 38.97Q145.07 40.14 144.73 41.3Q144.4 42.46 143.75 43.32Q143.1 44.17 142.16 44.66Q141.21 45.15 139.98 45.15Q139.36 45.15 138.75 44.99Q138.14 44.84 137.59 44.54Q137.04 44.23 136.57 43.77Q136.1 43.32 135.76 42.86V48.32Q135.76 48.65 135.63 48.91Q135.51 49.16 135.31 49.33Q135.11 49.49 134.85 49.58Q134.6 49.66 134.33 49.66Q134.06 49.66 133.8 49.58Q133.55 49.49 133.34 49.33Q133.14 49.16 133.02 48.91Q132.9 48.65 132.9 48.32V34.14Q132.9 33.79 133.02 33.54Q133.14 33.29 133.34 33.12Q133.53 32.95 133.78 32.87Q134.03 32.78 134.3 32.78Q134.56 32.78 134.8 32.86Q135.05 32.94 135.25 33.09Q135.45 33.24 135.58 33.48Q135.72 33.71 135.76 34.01ZM135.77 38.93Q135.77 39.79 135.95 40.52Q136.12 41.25 136.51 41.86Q136.9 42.47 137.53 42.83Q138.16 43.19 139.06 43.19Q139.97 43.19 140.56 42.8Q141.15 Line truncated
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 10 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" width="96" height="96" role="img" aria-labelledby="motif-title">
|
||||||
|
<title id="motif-title">Download</title>
|
||||||
|
<path d="M16 55 V71 Q16 77 22 77 H74 Q80 77 80 71 V55 M48 17 V59 M33 44 L48 59 L63 44" fill="none" stroke="#032551" stroke-width="5.1" stroke-linecap="round" stroke-linejoin="round"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 361 B |