Compare commits
71
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
759b3e1c02 | ||
|
|
061bc00564 | ||
|
|
57b2131632 | ||
|
|
8a97d9c334 | ||
|
|
e20f428a57 | ||
|
|
70695db290 | ||
|
|
f774d43647 | ||
|
|
c84ae10809 | ||
|
|
f3eda56021 | ||
|
|
4f3b7c351e | ||
|
|
75596bdaec | ||
|
|
5548106c31 | ||
|
|
dd3ee39f69 | ||
|
|
a7d369bab1 | ||
|
|
d4110b1d51 | ||
|
|
0c6519be28 | ||
|
|
30dd0f9eb8 | ||
|
|
07592f57bd | ||
|
|
bc6e4ec7ad | ||
|
|
77ebb0c1d5 | ||
|
|
4e00c4254b | ||
|
|
aaad2fa19b | ||
|
|
b23b30e897 | ||
|
|
afe35fc11f | ||
|
|
514eb46217 | ||
|
|
71e71b4ef2 | ||
|
|
0a0e4edbc2 | ||
|
|
b60029431f | ||
|
|
f4376ae819 | ||
|
|
51d58ac55c | ||
|
|
3aa1bad859 | ||
|
|
660b50f418 | ||
|
|
532979aa86 | ||
|
|
f846c0b2ee | ||
|
|
335b09f40e | ||
|
|
7b712e0c45 | ||
|
|
4847303a6f | ||
|
|
608550b620 | ||
|
|
0a8ff0761a | ||
|
|
a994c875ee | ||
|
|
d33ce86ae3 | ||
|
|
d1b10ef11d | ||
|
|
60f5b8e6c0 | ||
|
|
105d27f9c9 | ||
|
|
7eb3cd6230 | ||
|
|
156cdd6976 | ||
|
|
baa7691ab5 | ||
|
|
494e9fa0fb | ||
|
|
e7b0932e54 | ||
|
|
872f156d7d | ||
|
|
2d63109553 | ||
|
|
9dc4b4e64d | ||
|
|
1b271e0ce7 | ||
|
|
e1fd59491c | ||
|
|
41658d98dd | ||
|
|
b9fe0e3791 | ||
|
|
4c29ab2593 | ||
|
|
a359a5fb69 | ||
|
|
7b325f0d66 | ||
|
|
5590225f4f | ||
|
|
f29ea58fd5 | ||
|
|
c4be6ed8dc | ||
|
|
053a8d4648 | ||
|
|
7c63424ea6 | ||
|
|
13530b8171 | ||
|
|
72130d66c5 | ||
|
|
d37a7093dd | ||
|
|
3e56314cf9 | ||
|
|
8a6678aad7 | ||
|
|
b178939852 | ||
|
|
a08067c078 |
No files matched your search
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
description: Gemeinsame verbindliche UX-Vorgaben für Verwaltungsänderungen bei Lara & Felix. Ergänzt die Betriebsregeln, ersetzt sie nicht.
|
||||||
|
alwaysApply: true
|
||||||
|
---
|
||||||
|
|
||||||
|
# Verwaltung – gemeinsame Designgrundlage
|
||||||
|
|
||||||
|
Betriebsregeln in `CLAUDE.md` und `.cursor/rules/luf-betrieb.mdc` bleiben verbindlich. Diese Datei ergänzt sie für die Verwaltungsoberfläche.
|
||||||
|
|
||||||
|
1. `CLAUDE.md`, vorhandene aktive Repository-Regeln und `docs/ux/verwaltung/README.md` lesen.
|
||||||
|
2. `docs/ux/verwaltung/14-verwaltungsstandard.md` ist die maßgebliche UX-Grundlage. `15-umbauauftrag.md` beschreibt Umsetzung und Nachweise. Keine erneute allgemeine Designfreigabe oder neue Mockups je Screen verlangen.
|
||||||
|
3. Gemeinsame Komponenten statt kopierter Masken: Rahmen, Listen, Picker, Redaktion, geordnete Zuordnung, Status/Aktionen und Vorschau. Fachlich zulässige Typen und Referenzen sind Kontext derselben Komponente. Vorhanden in `resources/views/filament/verwaltung/`: `kopf` (Objektkopf, Status, Aktionen, Weitere Aktionen), `redaktion` (Manager), `texte`/`textfeld`, `praesentation`/`zuordnung-menue`, `einordnung`, `varianten`, `picker` (auch Aufbau, Vorschaubild und CMS-Bilder; Logik im Trait `ChoosesMedia`), `bestand` (gemeinsame Bestandsliste mit Suche, Filtern, aktiven Filterchips, Zeilen/Kacheln, „Weitere anzeigen“ und Dialogbereich; Trait `ShowsBestand`), Komponente `<x-vw.eintrag>` (Vorschau, Titel, Typzeile; Picker und Listen), `aufbau` (Struktur links, Detail rechts; auch Fassungen eines Mediums), `catalog/objekt` (Angebot, Paket, Rechteprofil), `cms/seite-kopf` (Seiteneditor mit Registern und Kontexten), Webpräsenz `cms/menues` mit `menue-zeile`, `menue-detail`, `ziel-auswahl` (Menüs als Arbeitsstand, breit Liste mit Detail, schmal ein aufgeklappter Eintrag), `bestaetigung` (statt `wire:confirm`), `abgang` (Warnung bei ungespeicherten Änderungen), `styles` (Tokens, einmal je Seite über den Panel-Hook). Logik im Trait `App\Filament\Support\ManagesEditorialSurface`; neue Objektarten liefern nur Feldliste, Einordnungsgruppen und Kopfangaben.
|
||||||
|
4. Eindeutigen Speicherumfang, Zustand und Vorschau-Datenstand anzeigen. Keine pauschale neue Genehmigungskette. Produktbeschreibung, Lehrinhalt, kommerzielle Daten und technische Verwaltung gezielt gliedern.
|
||||||
|
5. Redaktion für Medien einschließlich Filmen, Module, Programme und Lizenzartikel gemeinsam nutzen. Zentrale Medien referenzieren, mehrere Medien je Rolle und reine Präsentationsmedien ohne Lehrfassung erhalten.
|
||||||
|
6. Rückkehr mit offenen Eingaben sicherstellen; kein Pflichtspeichern vor dem Redaktionswechsel, kein heimliches Mitspeichern und kein veraltetes Zurückschreiben.
|
||||||
|
7. Bestehende Erwerbe, Rechte, Historie und fachliche Fassungsregeln erhalten. Offene Fragen in Dokument 04 nicht selbst durch neue Geschäftsregeln entscheiden; nur tatsächlich abhängige Teile gezielt klären.
|
||||||
|
8. Bestehende Tokens und freigegebene Assets nutzen. Verwaltungsmaße: `docs/ux/verwaltung/tokens.md`. Bilder sind räumliche Referenzen, keine autoritative Farbquelle oder auszuliefernde UI-Grafik.
|
||||||
|
9. Betroffene Abläufe funktional und visuell prüfen: Rückkehr, relevante Fehler-/Leer-/Ladezustände, Tastatur, breite/schmalere Fenster und fachliche Regressionen. Bestehende Betriebs- und Testregeln erfüllen.
|
||||||
|
10. Tatsächliche Komponentenwiederverwendung, Prüfergebnisse, gerenderte Screenshots und konkrete Abweichungen liefern; `docs/ux/verwaltung/regeln/ux-abnahme-vorlage.md` verwenden. Keine unbewiesene Abnahme behaupten.
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Einstieg für Coding-Agenten
|
||||||
|
|
||||||
|
Betriebs-, Test-, Deployment- und Medienschutzregeln stehen in `CLAUDE.md` und in `.cursor/rules/luf-betrieb.mdc`. Sie gelten unverändert.
|
||||||
|
|
||||||
|
Für die Verwaltung zusätzlich:
|
||||||
|
|
||||||
|
- `docs/ux/verwaltung/14-verwaltungsstandard.md` ist die maßgebliche Designgrundlage, `docs/ux/verwaltung/15-umbauauftrag.md` der konkrete Auftrag. Keine neue allgemeine Designfreigabe oder Screenserie verlangen.
|
||||||
|
- `docs/ux/verwaltung/README.md` und Dokument 04 für Herkunft und offene Geschäftsfragen. Historische Entwürfe nach der Rangfolge in Dokument 14 lesen.
|
||||||
|
- Gleichartige Aufgaben mit den gemeinsamen Komponenten unter `resources/views/filament/verwaltung/` und `resources/views/filament/editorial/` lösen. Fachfunktionen, Datenbeziehungen, Rechte und Fassungsbindungen erhalten.
|
||||||
|
- Offene Eingaben beim Wechsel zur Redaktion und zurück erhalten. Speicherwirkung benennen. Maße in `docs/ux/verwaltung/tokens.md`.
|
||||||
|
- Hauptabläufe prüfen, bestehende Testpflichten erfüllen, Abweichungen konkret benennen. Keine ungeprüfte Abnahme behaupten.
|
||||||
|
|
||||||
|
Diese Datei ergänzt die Betriebsregeln und löst kein Deployment aus.
|
||||||
@@ -59,3 +59,10 @@ ## Entwicklung
|
|||||||
- Commits: kurze, deutsche oder englische Betreffzeile im Imperativ, ein logischer Schritt pro Commit.
|
- Commits: kurze, deutsche oder englische Betreffzeile im Imperativ, ein logischer Schritt pro Commit.
|
||||||
- Änderungen an `.gitea/workflows/`, `Dockerfile`, `docker-compose.yml` und `scripts/deploy.sh` wirken direkt auf Test und Prod. Sie werden nur gezielt und mit Begründung geändert und in `docs/betrieb/DEPLOYMENT.md` nachgeführt.
|
- Änderungen an `.gitea/workflows/`, `Dockerfile`, `docker-compose.yml` und `scripts/deploy.sh` wirken direkt auf Test und Prod. Sie werden nur gezielt und mit Begründung geändert und in `docs/betrieb/DEPLOYMENT.md` nachgeführt.
|
||||||
- Nicht verifizierte Aussagen zu Servern oder Kapazitäten werden als solche gekennzeichnet. Nichts erfinden (Ports, Hostnamen, Pfade, Zugangsdaten).
|
- Nicht verifizierte Aussagen zu Servern oder Kapazitäten werden als solche gekennzeichnet. Nichts erfinden (Ports, Hostnamen, Pfade, Zugangsdaten).
|
||||||
|
|
||||||
|
## 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`.
|
||||||
|
- 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“. 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`).
|
||||||
|
- 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`.
|
||||||
@@ -67,7 +67,7 @@ private function createFixture(
|
|||||||
$kind = EditorialContentKind::query()->where('slug', 'programm')->first();
|
$kind = EditorialContentKind::query()->where('slug', 'programm')->first();
|
||||||
|
|
||||||
if ($kind === null) {
|
if ($kind === null) {
|
||||||
$this->error('Die Inhaltsart Programm fehlt.');
|
$this->error('Die fachliche Materialart Programm fehlt.');
|
||||||
|
|
||||||
return self::FAILURE;
|
return self::FAILURE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,10 @@ class Composition extends Model
|
|||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'designation',
|
'designation',
|
||||||
'display_title',
|
'display_title',
|
||||||
|
'teaser',
|
||||||
'summary',
|
'summary',
|
||||||
'description',
|
'description',
|
||||||
|
'search_terms',
|
||||||
'thumbnail_path',
|
'thumbnail_path',
|
||||||
'thumbnail_alt',
|
'thumbnail_alt',
|
||||||
'thumbnail_source',
|
'thumbnail_source',
|
||||||
|
|||||||
@@ -14,14 +14,21 @@ class ContentElement extends Model
|
|||||||
'output_class',
|
'output_class',
|
||||||
'working_title',
|
'working_title',
|
||||||
'display_title',
|
'display_title',
|
||||||
|
'teaser',
|
||||||
'description',
|
'description',
|
||||||
'usage_note',
|
'usage_note',
|
||||||
'license_note',
|
'license_note',
|
||||||
|
'website_credit',
|
||||||
|
'website_alt',
|
||||||
|
'website_released_at',
|
||||||
|
'website_public_path',
|
||||||
'summary',
|
'summary',
|
||||||
|
'search_terms',
|
||||||
'thumbnail_path',
|
'thumbnail_path',
|
||||||
'thumbnail_alt',
|
'thumbnail_alt',
|
||||||
'thumbnail_source',
|
'thumbnail_source',
|
||||||
'thumbnail_error',
|
'thumbnail_error',
|
||||||
|
'preview_path',
|
||||||
'editorial_content_kind_id',
|
'editorial_content_kind_id',
|
||||||
'archived_at',
|
'archived_at',
|
||||||
];
|
];
|
||||||
@@ -30,6 +37,7 @@ protected function casts(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'archived_at' => 'datetime',
|
'archived_at' => 'datetime',
|
||||||
|
'website_released_at' => 'datetime',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,17 +2,49 @@
|
|||||||
|
|
||||||
namespace App\Domain\Catalog;
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fachliche Materialart (FACH-56 bis FACH-58). Die Bezeichnung ist pflegbar, die Kennung (slug) bleibt nach dem Anlegen
|
||||||
|
* fest. Zulässige Objektkontexte bestimmen, wo eine Materialart neu gewählt werden kann; vorhandene Zuordnungen bleiben
|
||||||
|
* immer erhalten (siehe EditorialVocabulary).
|
||||||
|
*/
|
||||||
class EditorialContentKind extends Model
|
class EditorialContentKind extends Model
|
||||||
{
|
{
|
||||||
|
/** Objektkontexte aus dem Fachmodell: Medium (ContentElement), Modul und Programm (Composition), Lizenzartikel. */
|
||||||
|
public const CONTEXTS = [
|
||||||
|
'medium' => 'Medium',
|
||||||
|
'modul' => 'Modul',
|
||||||
|
'programm' => 'Programm',
|
||||||
|
'lizenzartikel' => 'Lizenzartikel',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kennungen, auf die der Code fachlich verweist: öffentliche Programmseiten und das Anlegen von Programmen und
|
||||||
|
* Modulen (programm, modul), Vertraulichkeit von Traineranleitungen (traineranleitung). Ihre Bezeichnung bleibt
|
||||||
|
* pflegbar; deaktivieren, Kontexte ändern und löschen sind gesperrt.
|
||||||
|
*/
|
||||||
|
public const SYSTEM_SLUGS = ['programm', 'modul', 'traineranleitung'];
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'slug',
|
'slug',
|
||||||
'label',
|
'label',
|
||||||
'sort_order',
|
'sort_order',
|
||||||
|
'is_active',
|
||||||
|
'contexts',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'is_active' => 'boolean',
|
||||||
|
'contexts' => 'array',
|
||||||
|
'sort_order' => 'integer',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function compositions(): HasMany
|
public function compositions(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(Composition::class);
|
return $this->hasMany(Composition::class);
|
||||||
@@ -23,11 +55,37 @@ public function contentElements(): HasMany
|
|||||||
return $this->hasMany(ContentElement::class);
|
return $this->hasMany(ContentElement::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function licenseArticles(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(LicenseArticle::class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param Builder<EditorialContentKind> $query
|
||||||
|
*/
|
||||||
|
public function scopeActive(Builder $query): void
|
||||||
|
{
|
||||||
|
$query->where('is_active', true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function allows(string $context): bool
|
||||||
|
{
|
||||||
|
return in_array($context, (array) ($this->contexts ?? []), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isSystem(): bool
|
||||||
|
{
|
||||||
|
return in_array($this->slug, self::SYSTEM_SLUGS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alle Materialarten in Pflegereihenfolge (ohne Kontext- oder Aktivfilter). Für Auswahlstellen gilt
|
||||||
|
* EditorialVocabulary.
|
||||||
|
*
|
||||||
* @return array<int, string>
|
* @return array<int, string>
|
||||||
*/
|
*/
|
||||||
public static function selectOptions(): array
|
public static function selectOptions(): array
|
||||||
{
|
{
|
||||||
return static::query()->orderBy('sort_order')->pluck('label', 'id')->all();
|
return static::query()->orderBy('sort_order')->orderBy('id')->pluck('label', 'id')->all();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,15 +2,48 @@
|
|||||||
|
|
||||||
namespace App\Domain\Catalog;
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
class EditorialDimension extends Model
|
class EditorialDimension extends Model
|
||||||
{
|
{
|
||||||
|
/** Gespiegelte Säulen; gepflegt werden Säulen über die Säulenverwaltung, nicht als Stammdaten. */
|
||||||
|
public const PILLAR_SLUG = 'saeule';
|
||||||
|
|
||||||
protected $fillable = ['slug', 'label'];
|
protected $fillable = ['slug', 'label'];
|
||||||
|
|
||||||
|
/** Werte in Pflegereihenfolge. */
|
||||||
public function values(): HasMany
|
public function values(): HasMany
|
||||||
{
|
{
|
||||||
return $this->hasMany(EditorialDimensionValue::class);
|
return $this->hasMany(EditorialDimensionValue::class)->orderBy('sort_order')->orderBy('id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inhaltselemente pflegen Themen über die Säulen, nicht noch einmal über die Dimension.
|
||||||
|
* Module, Programme und Lizenzartikel haben keine Säulenauswahl und behalten die Dimension.
|
||||||
|
*
|
||||||
|
* @return Collection<int, self>
|
||||||
|
*/
|
||||||
|
public static function forSubject(Model $subject): Collection
|
||||||
|
{
|
||||||
|
$query = static::query()->with('values')->orderBy('label');
|
||||||
|
|
||||||
|
if ($subject instanceof ContentElement) {
|
||||||
|
$query->where('slug', '!=', self::PILLAR_SLUG);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<int>
|
||||||
|
*/
|
||||||
|
public static function offeredValueIds(Model $subject): array
|
||||||
|
{
|
||||||
|
return static::forSubject($subject)
|
||||||
|
->flatMap(fn (self $dimension) => $dimension->values->pluck('id'))
|
||||||
|
->map(fn ($id): int => (int) $id)
|
||||||
|
->all();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,15 @@
|
|||||||
|
|
||||||
class EditorialDimensionValue extends Model
|
class EditorialDimensionValue extends Model
|
||||||
{
|
{
|
||||||
protected $fillable = ['editorial_dimension_id', 'slug', 'label'];
|
protected $fillable = ['editorial_dimension_id', 'slug', 'label', 'sort_order', 'is_active'];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'is_active' => 'boolean',
|
||||||
|
'sort_order' => 'integer',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function dimension(): BelongsTo
|
public function dimension(): BelongsTo
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aufgelöste Klasse-A-Angaben eines Fachobjekts.
|
||||||
|
* Fehlende Felder bleiben leer. Es wird nichts materialisiert.
|
||||||
|
*/
|
||||||
|
final readonly class EditorialProfile
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param array<string, ResolvedText> $texts
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
public ?string $workingTitle,
|
||||||
|
public array $texts,
|
||||||
|
public ?string $searchTerms,
|
||||||
|
public string $searchOrigin,
|
||||||
|
public ?string $kindLabel,
|
||||||
|
public ?Model $source,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function text(string $field): ResolvedText
|
||||||
|
{
|
||||||
|
return $this->texts[$field] ?? new ResolvedText(null, 'leer', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function value(string $field): ?string
|
||||||
|
{
|
||||||
|
return $this->text($field)->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function origin(string $field): string
|
||||||
|
{
|
||||||
|
return $this->text($field)->origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function originLabel(string $field): string
|
||||||
|
{
|
||||||
|
$text = $this->text($field);
|
||||||
|
|
||||||
|
return match ($text->origin) {
|
||||||
|
'eigen' => 'Eigene Angabe',
|
||||||
|
'variante' => 'Abweichung für '.($text->label ?? 'diesen Kontext'),
|
||||||
|
'quelle' => 'Übernommen von '.($text->label ?? 'der fachlichen Quelle'),
|
||||||
|
default => 'Keine Angabe',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,225 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Löst die Klasse-A-Texte eines Fachobjekts auf.
|
||||||
|
*
|
||||||
|
* Reihenfolge: abweichende Formulierung für den Kontext, eigene Angabe am Objekt,
|
||||||
|
* bei einem Lizenzartikel die Angabe der eindeutigen fachlichen Quelle.
|
||||||
|
* Eine Quelle gibt es nur, wenn der aktuelle Artikelstand genau eine Wurzel hat.
|
||||||
|
* Preise, Rechte und Fassungen werden nicht gelesen und nicht geschrieben.
|
||||||
|
*/
|
||||||
|
class EditorialProfileReader
|
||||||
|
{
|
||||||
|
public const AUDIENCES = [
|
||||||
|
'kachel' => 'Öffentliche Kachel',
|
||||||
|
'detail' => 'Öffentliche Detailvorstellung',
|
||||||
|
'bibliothek' => 'Mitgliederbibliothek',
|
||||||
|
'trainer' => 'Fachliche Traineransicht',
|
||||||
|
'artikel' => 'Lizenzartikelpräsentation',
|
||||||
|
'cms' => 'CMS-Teaser',
|
||||||
|
'suche' => 'Suchergebnis',
|
||||||
|
];
|
||||||
|
|
||||||
|
public const TEXT_FIELDS = ['display_title', 'teaser', 'summary', 'description'];
|
||||||
|
|
||||||
|
public function read(Model $subject, ?string $audience = null): EditorialProfile
|
||||||
|
{
|
||||||
|
if ($audience !== null && ! array_key_exists($audience, self::AUDIENCES)) {
|
||||||
|
throw new DomainRuleException('Diese Zielgruppe ist nicht vorgesehen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$source = $subject instanceof LicenseArticle ? $this->sourceOf($subject) : null;
|
||||||
|
$texts = [];
|
||||||
|
|
||||||
|
foreach (self::TEXT_FIELDS as $field) {
|
||||||
|
$texts[$field] = $this->resolve($subject, $field, $audience, $source);
|
||||||
|
}
|
||||||
|
|
||||||
|
$search = $this->own($subject, 'search_terms');
|
||||||
|
$searchOrigin = 'eigen';
|
||||||
|
|
||||||
|
if ($search === null && $source instanceof Model) {
|
||||||
|
$search = $this->own($source, 'search_terms');
|
||||||
|
$searchOrigin = $search === null ? 'leer' : 'quelle';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($search === null) {
|
||||||
|
$searchOrigin = 'leer';
|
||||||
|
}
|
||||||
|
|
||||||
|
return new EditorialProfile(
|
||||||
|
workingTitle: $this->workingTitle($subject),
|
||||||
|
texts: $texts,
|
||||||
|
searchTerms: $search,
|
||||||
|
searchOrigin: $searchOrigin,
|
||||||
|
kindLabel: $subject->editorialContentKind?->label
|
||||||
|
?? ($source?->editorialContentKind?->label),
|
||||||
|
source: $source,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sourceOf(LicenseArticle $article): ?Model
|
||||||
|
{
|
||||||
|
$release = $article->relationLoaded('currentRelease')
|
||||||
|
? $article->currentRelease
|
||||||
|
: $article->currentRelease()->first();
|
||||||
|
|
||||||
|
if (! $release instanceof ArticleRelease) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$elementId = $release->root_element_version_id;
|
||||||
|
$compositionId = $release->root_composition_version_id;
|
||||||
|
|
||||||
|
if (($elementId === null) === ($compositionId === null)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($elementId !== null) {
|
||||||
|
return ContentElementVersion::query()->with('element.editorialContentKind')->find($elementId)?->element;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CompositionVersion::query()->with('composition.editorialContentKind')->find($compositionId)?->composition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function putVariant(Model $subject, string $field, string $audience, ?string $body, ?User $actor = null): string
|
||||||
|
{
|
||||||
|
if (! in_array($field, self::TEXT_FIELDS, true) || ! array_key_exists($audience, self::AUDIENCES)) {
|
||||||
|
throw new DomainRuleException('Diese Abweichung ist nicht vorgesehen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$body = is_string($body) ? trim($body) : '';
|
||||||
|
$existing = $this->variant($subject, $field, $audience);
|
||||||
|
|
||||||
|
if ($body === '') {
|
||||||
|
if ($existing instanceof EditorialTextVariant) {
|
||||||
|
$this->record($subject, $audience, $field, $existing->body, null, $actor);
|
||||||
|
$existing->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'Die abweichende Formulierung ist entfernt. Es gilt wieder die zentrale Angabe.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($existing instanceof EditorialTextVariant && $existing->body === $body) {
|
||||||
|
return 'Die abweichende Formulierung ist unverändert.';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->record($subject, $audience, $field, $existing?->body, $body, $actor);
|
||||||
|
|
||||||
|
EditorialTextVariant::query()->updateOrCreate(
|
||||||
|
[
|
||||||
|
'subject_type' => $subject->getMorphClass(),
|
||||||
|
'subject_id' => $subject->getKey(),
|
||||||
|
'field' => $field,
|
||||||
|
'audience' => $audience,
|
||||||
|
],
|
||||||
|
['body' => $body],
|
||||||
|
);
|
||||||
|
|
||||||
|
return 'Die abweichende Formulierung gilt nur für '.self::AUDIENCES[$audience].'. Die zentrale Angabe bleibt.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function forgetVariant(Model $subject, EditorialTextVariant $variant, ?User $actor = null): void
|
||||||
|
{
|
||||||
|
if ($variant->subject_type !== $subject->getMorphClass() || (int) $variant->subject_id !== (int) $subject->getKey()) {
|
||||||
|
throw new DomainRuleException('Diese Abweichung gehört zu einem anderen Objekt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->record($subject, $variant->audience, $variant->field, $variant->body, null, $actor);
|
||||||
|
$variant->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function resolve(Model $subject, string $field, ?string $audience, ?Model $source): ResolvedText
|
||||||
|
{
|
||||||
|
if ($audience !== null) {
|
||||||
|
$variant = $this->variant($subject, $field, $audience);
|
||||||
|
|
||||||
|
if ($variant instanceof EditorialTextVariant && trim($variant->body) !== '') {
|
||||||
|
return new ResolvedText(trim($variant->body), 'variante', self::AUDIENCES[$audience]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$own = $this->own($subject, $field);
|
||||||
|
|
||||||
|
if ($own !== null) {
|
||||||
|
return new ResolvedText($own, 'eigen', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($source instanceof Model) {
|
||||||
|
$fromSource = $this->resolve($source, $field, $audience, null);
|
||||||
|
|
||||||
|
if ($fromSource->value !== null) {
|
||||||
|
return new ResolvedText($fromSource->value, 'quelle', $this->sourceLabel($source));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ResolvedText(null, 'leer', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function variant(Model $subject, string $field, string $audience): ?EditorialTextVariant
|
||||||
|
{
|
||||||
|
return EditorialTextVariant::query()
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->where('field', $field)
|
||||||
|
->where('audience', $audience)
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function own(Model $subject, string $field): ?string
|
||||||
|
{
|
||||||
|
$value = $subject->getAttribute($field);
|
||||||
|
|
||||||
|
if (! is_string($value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = trim($value);
|
||||||
|
|
||||||
|
return $value === '' ? null : $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function workingTitle(Model $subject): ?string
|
||||||
|
{
|
||||||
|
if ($subject instanceof Composition) {
|
||||||
|
return $this->own($subject, 'designation');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($subject instanceof LicenseArticle) {
|
||||||
|
return $this->own($subject, 'working_title') ?? $this->own($subject, 'code');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->own($subject, 'working_title');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sourceLabel(Model $source): string
|
||||||
|
{
|
||||||
|
if ($source instanceof Composition) {
|
||||||
|
return (string) ($source->display_title ?: $source->designation);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($source instanceof ContentElement) {
|
||||||
|
return (string) ($source->display_title ?: $source->working_title);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'der fachlichen Quelle';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function record(Model $subject, string $audience, string $field, ?string $before, ?string $after, ?User $actor): void
|
||||||
|
{
|
||||||
|
IdentityChange::query()->create([
|
||||||
|
'subject_type' => $subject->getMorphClass(),
|
||||||
|
'subject_id' => $subject->getKey(),
|
||||||
|
'field' => 'variante:'.$audience.':'.$field,
|
||||||
|
'before' => $before,
|
||||||
|
'after' => $after,
|
||||||
|
'actor_id' => $actor?->id,
|
||||||
|
'occurred_at' => now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class EditorialTextVariant extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'subject_type',
|
||||||
|
'subject_id',
|
||||||
|
'field',
|
||||||
|
'audience',
|
||||||
|
'body',
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -0,0 +1,252 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eine Regelquelle für redaktionelle Stammdaten (FACH-56 bis FACH-58): Welche fachlichen Materialarten und welche
|
||||||
|
* Einordnungswerte Editor, Filter und Picker anbieten.
|
||||||
|
*
|
||||||
|
* - Neu wählbar sind nur aktive Werte; Materialarten zusätzlich nur im zulässigen Objektkontext.
|
||||||
|
* - Vorhandene Zuordnungen bleiben sichtbar und erhalten, auch wenn der Wert inaktiv ist oder sein Kontext geändert
|
||||||
|
* wurde; sie sind gekennzeichnet.
|
||||||
|
* - Filter finden auch Objekte mit inaktiven Werten; ein gewählter Filter bleibt erhalten.
|
||||||
|
*/
|
||||||
|
final class EditorialVocabulary
|
||||||
|
{
|
||||||
|
public const INACTIVE_SUFFIX = ' (inaktiv)';
|
||||||
|
|
||||||
|
public const OUT_OF_CONTEXT_SUFFIX = ' (hier nicht vorgesehen)';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Objektkontext eines Fachobjekts nach dem Fachmodell, null wenn es keine Materialart trägt.
|
||||||
|
*/
|
||||||
|
public function contextOf(Model $subject): ?string
|
||||||
|
{
|
||||||
|
if ($subject instanceof ContentElement) {
|
||||||
|
return 'medium';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($subject instanceof LicenseArticle) {
|
||||||
|
return 'lizenzartikel';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($subject instanceof Composition) {
|
||||||
|
return self::compositionContext($subject->kind instanceof CompositionKind ? $subject->kind : CompositionKind::tryFrom((string) $subject->kind));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function compositionContext(?CompositionKind $kind): ?string
|
||||||
|
{
|
||||||
|
return match ($kind) {
|
||||||
|
CompositionKind::Kurs => 'programm',
|
||||||
|
CompositionKind::Uebung => 'modul',
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auswahl der Materialart in einem Editor: aktive, im Kontext zulässige Arten in Pflegereihenfolge, dazu die
|
||||||
|
* bereits zugeordnete Art mit Kennzeichnung, falls sie inaktiv oder hier nicht vorgesehen ist.
|
||||||
|
*
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public function kindOptions(string $context, ?int $currentId = null): array
|
||||||
|
{
|
||||||
|
$options = [];
|
||||||
|
|
||||||
|
foreach (EditorialContentKind::query()->orderBy('sort_order')->orderBy('id')->get() as $kind) {
|
||||||
|
$offered = $kind->is_active && $kind->allows($context);
|
||||||
|
|
||||||
|
if ($offered) {
|
||||||
|
$options[$kind->id] = (string) $kind->label;
|
||||||
|
} elseif ($currentId !== null && $kind->id === $currentId) {
|
||||||
|
$options[$kind->id] = $this->kindLabel($kind, $context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüft eine neue Materialart serverseitig. Die bereits gespeicherte Art bleibt immer zulässig.
|
||||||
|
*/
|
||||||
|
public function kindError(string $context, ?int $newId, ?int $storedId): ?string
|
||||||
|
{
|
||||||
|
if ($newId === null || $newId === $storedId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$kind = EditorialContentKind::query()->find($newId);
|
||||||
|
|
||||||
|
if (! $kind instanceof EditorialContentKind) {
|
||||||
|
return 'Diese fachliche Materialart gibt es nicht mehr.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $kind->is_active) {
|
||||||
|
return 'Die fachliche Materialart „'.$kind->label.'“ ist deaktiviert und kann nicht neu gewählt werden.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $kind->allows($context)) {
|
||||||
|
return 'Die fachliche Materialart „'.$kind->label.'“ ist für '.(EditorialContentKind::CONTEXTS[$context] ?? $context).' nicht vorgesehen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filteroptionen der Materialart für einen Bestand: im Kontext zulässige Arten und Arten, die dort tatsächlich
|
||||||
|
* vorkommen (gekennzeichnet), dazu ein bereits gewählter Filter.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function kindFilterOptions(string $context, string $selected = ''): array
|
||||||
|
{
|
||||||
|
$used = $this->usedKindIds($context);
|
||||||
|
$options = [];
|
||||||
|
|
||||||
|
foreach (EditorialContentKind::query()->orderBy('sort_order')->orderBy('id')->get() as $kind) {
|
||||||
|
$show = ($kind->allows($context) && $kind->is_active) || in_array($kind->id, $used, true) || (string) $kind->id === $selected;
|
||||||
|
|
||||||
|
if ($show) {
|
||||||
|
$options[(string) $kind->id] = $this->kindLabel($kind, $context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function kindLabel(EditorialContentKind $kind, string $context): string
|
||||||
|
{
|
||||||
|
return (string) $kind->label
|
||||||
|
.(! $kind->is_active ? self::INACTIVE_SUFFIX : (! $kind->allows($context) ? self::OUT_OF_CONTEXT_SUFFIX : ''));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<int>
|
||||||
|
*/
|
||||||
|
private function usedKindIds(string $context): array
|
||||||
|
{
|
||||||
|
$query = match ($context) {
|
||||||
|
'medium' => DB::table('content_elements'),
|
||||||
|
'lizenzartikel' => DB::table('license_articles'),
|
||||||
|
'programm' => DB::table('compositions')->where('kind', CompositionKind::Kurs->value),
|
||||||
|
'modul' => DB::table('compositions')->where('kind', CompositionKind::Uebung->value),
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
|
||||||
|
return $query === null ? [] : $query->whereNotNull('editorial_content_kind_id')->distinct()
|
||||||
|
->pluck('editorial_content_kind_id')->map(fn ($id): int => (int) $id)->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Einordnung im Editor: je angebotener Dimension aktive Werte und bereits zugeordnete inaktive Werte (gekennzeichnet).
|
||||||
|
*
|
||||||
|
* @param list<int> $assignedIds
|
||||||
|
* @return list<array{label: string, values: list<array{id: int, label: string, inactive: bool}>}>
|
||||||
|
*/
|
||||||
|
public function dimensionGroups(Model $subject, array $assignedIds): array
|
||||||
|
{
|
||||||
|
$groups = [];
|
||||||
|
|
||||||
|
foreach (EditorialDimension::forSubject($subject) as $dimension) {
|
||||||
|
$values = [];
|
||||||
|
|
||||||
|
foreach ($dimension->values as $value) {
|
||||||
|
if ($value->is_active || in_array((int) $value->id, $assignedIds, true)) {
|
||||||
|
$values[] = [
|
||||||
|
'id' => (int) $value->id,
|
||||||
|
'label' => (string) $value->label.($value->is_active ? '' : self::INACTIVE_SUFFIX),
|
||||||
|
'inactive' => ! $value->is_active,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($values !== []) {
|
||||||
|
$groups[] = ['label' => (string) $dimension->label, 'values' => $values];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filtergruppen der Einordnung: aktive Werte, verwendete inaktive Werte (gekennzeichnet) und gewählte Filter.
|
||||||
|
*
|
||||||
|
* @param list<int> $selectedIds
|
||||||
|
* @return list<array{label: string, values: list<array{id: int, label: string}>}>
|
||||||
|
*/
|
||||||
|
public function dimensionFilterGroups(array $selectedIds = [], bool $withPillars = true): array
|
||||||
|
{
|
||||||
|
$used = DB::table('identity_dimension_values')->distinct()->pluck('editorial_dimension_value_id')->map(fn ($id): int => (int) $id)->all();
|
||||||
|
$groups = [];
|
||||||
|
|
||||||
|
foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) {
|
||||||
|
if (! $withPillars && $dimension->slug === EditorialDimension::PILLAR_SLUG) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$values = [];
|
||||||
|
|
||||||
|
foreach ($dimension->values as $value) {
|
||||||
|
$id = (int) $value->id;
|
||||||
|
|
||||||
|
if ($value->is_active || in_array($id, $used, true) || in_array($id, $selectedIds, true)) {
|
||||||
|
$values[] = ['id' => $id, 'label' => (string) $value->label.($value->is_active ? '' : self::INACTIVE_SUFFIX)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($values !== []) {
|
||||||
|
$groups[] = ['label' => (string) $dimension->label, 'values' => $values];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Öffentliche Filter der Mitgliederbibliothek: nur aktive Werte, ein bereits gewählter Wert bleibt sichtbar.
|
||||||
|
*
|
||||||
|
* @param list<int> $selectedIds
|
||||||
|
* @return Collection<int, EditorialDimension>
|
||||||
|
*/
|
||||||
|
public function memberFilterDimensions(array $selectedIds = []): Collection
|
||||||
|
{
|
||||||
|
$dimensions = EditorialDimension::query()->with('values')->orderBy('label')->get();
|
||||||
|
|
||||||
|
foreach ($dimensions as $dimension) {
|
||||||
|
$dimension->setRelation('values', $dimension->values
|
||||||
|
->filter(fn (EditorialDimensionValue $value): bool => $value->is_active || in_array((int) $value->id, $selectedIds, true))
|
||||||
|
->values());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $dimensions->filter(fn (EditorialDimension $dimension): bool => $dimension->values->isNotEmpty())->values();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Für replaceOffered: Werte, die bei diesem Fachobjekt gesetzt oder entfernt werden dürfen. Aktive Werte der
|
||||||
|
* angebotenen Dimensionen und die bereits zugeordneten inaktiven (der Editor zeigt sie gekennzeichnet an).
|
||||||
|
*
|
||||||
|
* @param list<int> $assignedIds
|
||||||
|
* @return list<int>
|
||||||
|
*/
|
||||||
|
public function editableValueIds(Model $subject, array $assignedIds): array
|
||||||
|
{
|
||||||
|
$ids = [];
|
||||||
|
|
||||||
|
foreach (EditorialDimension::forSubject($subject) as $dimension) {
|
||||||
|
foreach ($dimension->values as $value) {
|
||||||
|
if ($value->is_active || in_array((int) $value->id, $assignedIds, true)) {
|
||||||
|
$ids[] = (int) $value->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ids;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,4 +52,44 @@ public function matches(Model $subject, array $valueIds): bool
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ersetzt nur die Werte der Dimensionen, die dieses Fachobjekt anbietet.
|
||||||
|
* Nicht angebotene Zuordnungen, etwa gespiegelte Säulen am Inhaltselement, bleiben.
|
||||||
|
*
|
||||||
|
* Inaktive Werte (Stammdatenpflege) sind nicht neu wählbar. Bereits zugeordnete inaktive Werte zeigt der Editor
|
||||||
|
* gekennzeichnet an; sie bleiben, solange sie mitgeschickt werden, und werden nur bei ausdrücklicher Abwahl entfernt.
|
||||||
|
*
|
||||||
|
* @param list<int> $valueIds
|
||||||
|
*/
|
||||||
|
public function replaceOffered(Model $subject, array $valueIds): void
|
||||||
|
{
|
||||||
|
$assigned = IdentityDimensionValue::query()
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->pluck('editorial_dimension_value_id')
|
||||||
|
->map(fn ($id): int => (int) $id)
|
||||||
|
->all();
|
||||||
|
$offeredIds = app(EditorialVocabulary::class)->editableValueIds($subject, $assigned);
|
||||||
|
$ids = array_values(array_intersect(
|
||||||
|
array_values(array_unique(array_map(intval(...), $valueIds))),
|
||||||
|
$offeredIds,
|
||||||
|
));
|
||||||
|
|
||||||
|
$query = IdentityDimensionValue::query()
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->where('origin', 'direkt')
|
||||||
|
->whereIn('editorial_dimension_value_id', $offeredIds === [] ? [0] : $offeredIds);
|
||||||
|
|
||||||
|
if ($ids !== []) {
|
||||||
|
$query->whereNotIn('editorial_dimension_value_id', $ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query->delete();
|
||||||
|
|
||||||
|
foreach (EditorialDimensionValue::query()->whereIn('id', $ids)->get() as $value) {
|
||||||
|
$this->assign($subject, $value, 'direkt');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,13 @@ class LicenseArticle extends Model
|
|||||||
{
|
{
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'code',
|
'code',
|
||||||
|
'working_title',
|
||||||
|
'display_title',
|
||||||
|
'teaser',
|
||||||
|
'summary',
|
||||||
|
'description',
|
||||||
|
'search_terms',
|
||||||
|
'editorial_content_kind_id',
|
||||||
'product_line',
|
'product_line',
|
||||||
'successor_of_id',
|
'successor_of_id',
|
||||||
'current_release_id',
|
'current_release_id',
|
||||||
@@ -37,4 +44,9 @@ public function successorOf(): BelongsTo
|
|||||||
{
|
{
|
||||||
return $this->belongsTo(self::class, 'successor_of_id');
|
return $this->belongsTo(self::class, 'successor_of_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function editorialContentKind(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(EditorialContentKind::class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class PresentationAssignment extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'subject_type',
|
||||||
|
'subject_id',
|
||||||
|
'content_element_id',
|
||||||
|
'presentation_role_id',
|
||||||
|
'position',
|
||||||
|
'source_version_id',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function role(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(PresentationRole::class, 'presentation_role_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function element(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(ContentElement::class, 'content_element_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function sourceVersion(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(ContentElementVersion::class, 'source_version_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,515 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use App\Domain\Media\ThumbnailRef;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Präsentationsmedien sind Referenzen auf Inhaltselemente.
|
||||||
|
* Die Rolle gehört zur Zuordnung. Eine Zuordnung gibt nichts frei und ändert keine Fassung.
|
||||||
|
*/
|
||||||
|
class PresentationMedia
|
||||||
|
{
|
||||||
|
public function __construct(private readonly WebsiteMedia $website) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function rows(Model $subject): array
|
||||||
|
{
|
||||||
|
$assignments = PresentationAssignment::query()
|
||||||
|
->with(['role', 'element.editorialContentKind', 'sourceVersion'])
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->orderBy('position')
|
||||||
|
->orderBy('id')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$rows = [];
|
||||||
|
|
||||||
|
foreach ($assignments as $assignment) {
|
||||||
|
$element = $assignment->element;
|
||||||
|
$released = $element instanceof ContentElement && $this->website->present($element) !== null;
|
||||||
|
$binding = $this->binding($assignment);
|
||||||
|
|
||||||
|
$rows[] = [
|
||||||
|
'id' => $assignment->id,
|
||||||
|
'role' => (string) $assignment->role?->slug,
|
||||||
|
'role_label' => (string) ($assignment->role?->label ?? ''),
|
||||||
|
'ordered' => (bool) $assignment->role?->ordered,
|
||||||
|
'position' => (int) $assignment->position,
|
||||||
|
'standard' => $assignment->role?->slug === 'titelbild',
|
||||||
|
'element_id' => (int) $assignment->content_element_id,
|
||||||
|
'title' => $element instanceof ContentElement
|
||||||
|
? (string) ($element->display_title ?: $element->working_title)
|
||||||
|
: 'Medium fehlt',
|
||||||
|
'image' => $element instanceof ContentElement
|
||||||
|
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path)
|
||||||
|
: null,
|
||||||
|
'kind' => $element?->editorialContentKind?->label,
|
||||||
|
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
|
||||||
|
'released' => $released,
|
||||||
|
'release_label' => $released ? 'Für die Website freigegeben' : 'Nicht für die Website freigegeben',
|
||||||
|
'binding' => $binding,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gespeicherte Zuordnungen als bearbeitbarer Arbeitsstand, nach Rolle und Position geordnet.
|
||||||
|
*
|
||||||
|
* @return list<array{key: string, id: int|null, role: string, element_id: int, source: int|null}>
|
||||||
|
*/
|
||||||
|
public function staged(Model $subject): array
|
||||||
|
{
|
||||||
|
$assignments = PresentationAssignment::query()
|
||||||
|
->with('role')
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->get()
|
||||||
|
->sortBy(fn (PresentationAssignment $row): string => sprintf('%05d-%05d-%08d', (int) $row->role?->sort_order, (int) $row->position, (int) $row->id))
|
||||||
|
->values();
|
||||||
|
|
||||||
|
$rows = [];
|
||||||
|
|
||||||
|
foreach ($assignments as $assignment) {
|
||||||
|
$rows[] = [
|
||||||
|
'key' => 'a'.$assignment->id,
|
||||||
|
'id' => (int) $assignment->id,
|
||||||
|
'role' => (string) $assignment->role?->slug,
|
||||||
|
'element_id' => (int) $assignment->content_element_id,
|
||||||
|
'source' => $assignment->source_version_id !== null ? (int) $assignment->source_version_id : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Anzeigezeilen für einen Arbeitsstand, gruppiert nach Rolle. Liest nur, schreibt nichts.
|
||||||
|
*
|
||||||
|
* @param list<array{key: string, id: int|null, role: string, element_id: int, source: int|null}> $staged
|
||||||
|
* @return list<array{role: string, label: string, multiple: bool, ordered: bool, rows: list<array<string, mixed>>}>
|
||||||
|
*/
|
||||||
|
public function describe(array $staged): array
|
||||||
|
{
|
||||||
|
$roles = PresentationRole::query()->orderBy('sort_order')->get()->keyBy('slug');
|
||||||
|
$elements = ContentElement::query()
|
||||||
|
->with('editorialContentKind')
|
||||||
|
->whereIn('id', array_values(array_unique(array_map(fn (array $row): int => (int) $row['element_id'], $staged))))
|
||||||
|
->get()
|
||||||
|
->keyBy('id');
|
||||||
|
$sources = ContentElementVersion::query()
|
||||||
|
->whereIn('id', array_values(array_filter(array_map(fn (array $row): ?int => $row['source'] ?? null, $staged))))
|
||||||
|
->get()
|
||||||
|
->keyBy('id');
|
||||||
|
$groups = [];
|
||||||
|
|
||||||
|
foreach ($roles as $slug => $role) {
|
||||||
|
$rows = array_values(array_filter($staged, fn (array $row): bool => $row['role'] === $slug));
|
||||||
|
|
||||||
|
if ($rows === []) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$described = [];
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$element = $elements->get((int) $row['element_id']);
|
||||||
|
$released = $element instanceof ContentElement && $this->website->present($element) !== null;
|
||||||
|
$source = $row['source'] !== null ? $sources->get((int) $row['source']) : null;
|
||||||
|
|
||||||
|
$described[] = [
|
||||||
|
'key' => $row['key'],
|
||||||
|
'id' => $row['id'],
|
||||||
|
'element_id' => (int) $row['element_id'],
|
||||||
|
'title' => $element instanceof ContentElement
|
||||||
|
? (string) ($element->display_title ?: $element->working_title)
|
||||||
|
: 'Medium fehlt',
|
||||||
|
'image' => $element instanceof ContentElement
|
||||||
|
? ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path)
|
||||||
|
: null,
|
||||||
|
'kind' => $element?->editorialContentKind?->label,
|
||||||
|
'output' => $element instanceof ContentElement ? (string) $element->output_class : '',
|
||||||
|
'released' => $released,
|
||||||
|
'release_label' => $released ? 'Für die Website freigegeben' : 'Nicht für die Website freigegeben',
|
||||||
|
'binding' => $source instanceof ContentElementVersion ? $this->bindingFor($source) : null,
|
||||||
|
'new' => $row['id'] === null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$groups[] = [
|
||||||
|
'role' => (string) $slug,
|
||||||
|
'label' => PresentationRole::displayLabel((string) $slug, (string) $role->label),
|
||||||
|
'multiple' => (bool) $role->multiple,
|
||||||
|
'ordered' => (bool) $role->ordered,
|
||||||
|
'rows' => $described,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $groups;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüft, ob ein Medium im Arbeitsstand einer Rolle zugeordnet werden darf. Liefert den Ablehnungsgrund oder null.
|
||||||
|
*/
|
||||||
|
public function refusal(Model $subject, string $roleSlug, int $elementId): ?string
|
||||||
|
{
|
||||||
|
$role = PresentationRole::query()->where('slug', $roleSlug)->first();
|
||||||
|
$element = ContentElement::query()->find($elementId);
|
||||||
|
|
||||||
|
if (! $role instanceof PresentationRole || ! $element instanceof ContentElement) {
|
||||||
|
return 'Rolle oder Medium fehlt.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($element->archived_at !== null) {
|
||||||
|
return 'Ein archiviertes Medium wird nicht zugeordnet.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($subject instanceof ContentElement && (int) $subject->getKey() === (int) $element->id) {
|
||||||
|
return 'Ein Medium kann nicht seine eigene Präsentation sein.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schreibt einen Arbeitsstand: entfernte Zuordnungen lösen, neue anlegen, Bindung und Reihenfolge je Rolle setzen.
|
||||||
|
* Medien, Fassungen und Website-Freigaben bleiben unberührt.
|
||||||
|
*
|
||||||
|
* Mit $baseline (dem beim Laden gelesenen Stand) werden nur Zuordnungen gelöst, die dort standen und im
|
||||||
|
* Arbeitsstand fehlen. Was inzwischen an anderer Stelle hinzugekommen ist, bleibt erhalten.
|
||||||
|
*
|
||||||
|
* @param list<array{key: string, id: int|null, role: string, element_id: int, source: int|null}> $staged
|
||||||
|
* @param list<array{key: string, id: int|null, role: string, element_id: int, source: int|null}>|null $baseline
|
||||||
|
*/
|
||||||
|
public function commit(Model $subject, array $staged, ?User $actor = null, ?array $baseline = null): void
|
||||||
|
{
|
||||||
|
$roles = PresentationRole::query()->get()->keyBy('slug');
|
||||||
|
$seen = [];
|
||||||
|
|
||||||
|
foreach ($staged as $row) {
|
||||||
|
$role = $roles->get($row['role']);
|
||||||
|
|
||||||
|
if (! $role instanceof PresentationRole) {
|
||||||
|
throw new DomainRuleException('Diese Rolle gibt es nicht.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$refusal = $this->refusal($subject, $row['role'], (int) $row['element_id']);
|
||||||
|
|
||||||
|
if ($refusal !== null) {
|
||||||
|
throw new DomainRuleException($refusal);
|
||||||
|
}
|
||||||
|
|
||||||
|
$pair = $row['role'].':'.$row['element_id'];
|
||||||
|
|
||||||
|
if (isset($seen[$pair])) {
|
||||||
|
throw new DomainRuleException('Ein Medium steht in derselben Rolle nur einmal.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$seen[$pair] = true;
|
||||||
|
$count = count(array_filter($staged, fn (array $other): bool => $other['role'] === $row['role']));
|
||||||
|
|
||||||
|
if (! $role->multiple && $count > 1) {
|
||||||
|
throw new DomainRuleException($role->label.' hat nur eine Zuordnung.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$element = ContentElement::query()->findOrFail((int) $row['element_id']);
|
||||||
|
$this->checkedSource($subject, $element, $row['source']);
|
||||||
|
}
|
||||||
|
|
||||||
|
DB::transaction(function () use ($subject, $staged, $roles, $actor, $baseline): void {
|
||||||
|
$existing = PresentationAssignment::query()
|
||||||
|
->with(['role', 'element'])
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->get()
|
||||||
|
->keyBy('id');
|
||||||
|
$kept = array_filter(array_map(fn (array $row): ?int => $row['id'], $staged));
|
||||||
|
$known = $baseline === null ? null : array_filter(array_map(fn (array $row): ?int => $row['id'], $baseline));
|
||||||
|
|
||||||
|
foreach ($existing as $id => $assignment) {
|
||||||
|
$wasLoaded = $known === null || in_array((int) $id, $known, true);
|
||||||
|
$replacedSingle = ! (bool) $assignment->role?->multiple
|
||||||
|
&& ! in_array((int) $id, $kept, true)
|
||||||
|
&& array_filter($staged, fn (array $row): bool => $row['role'] === $assignment->role?->slug) !== [];
|
||||||
|
|
||||||
|
if (! in_array((int) $id, $kept, true) && ($wasLoaded || $replacedSingle)) {
|
||||||
|
$this->record($subject, ($assignment->role?->label ?? 'Präsentation').': '.($assignment->element?->working_title ?? ''), null, $actor);
|
||||||
|
$assignment->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$positions = [];
|
||||||
|
|
||||||
|
foreach ($staged as $row) {
|
||||||
|
$role = $roles->get($row['role']);
|
||||||
|
$position = $positions[$row['role']] = ($positions[$row['role']] ?? 0) + 1;
|
||||||
|
$assignment = $row['id'] !== null ? $existing->get($row['id']) : null;
|
||||||
|
|
||||||
|
if ($assignment instanceof PresentationAssignment) {
|
||||||
|
$changed = (int) $assignment->position !== $position
|
||||||
|
|| (int) ($assignment->source_version_id ?? 0) !== (int) ($row['source'] ?? 0);
|
||||||
|
$assignment->position = $position;
|
||||||
|
$assignment->source_version_id = $row['source'];
|
||||||
|
|
||||||
|
if ($changed) {
|
||||||
|
$assignment->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$element = ContentElement::query()->findOrFail((int) $row['element_id']);
|
||||||
|
$same = PresentationAssignment::query()
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->where('presentation_role_id', $role->id)
|
||||||
|
->where('content_element_id', $element->id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($same instanceof PresentationAssignment) {
|
||||||
|
$same->position = $position;
|
||||||
|
$same->source_version_id = $row['source'];
|
||||||
|
$same->save();
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
PresentationAssignment::query()->create([
|
||||||
|
'subject_type' => $subject->getMorphClass(),
|
||||||
|
'subject_id' => $subject->getKey(),
|
||||||
|
'content_element_id' => $element->id,
|
||||||
|
'presentation_role_id' => $role->id,
|
||||||
|
'position' => $position,
|
||||||
|
'source_version_id' => $row['source'],
|
||||||
|
]);
|
||||||
|
$this->record($subject, null, $role->label.': '.$element->working_title, $actor);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assign(Model $subject, string $roleSlug, int $elementId, ?int $sourceVersionId, ?User $actor = null): string
|
||||||
|
{
|
||||||
|
$role = PresentationRole::query()->where('slug', $roleSlug)->first();
|
||||||
|
$element = ContentElement::query()->find($elementId);
|
||||||
|
|
||||||
|
if (! $role instanceof PresentationRole || ! $element instanceof ContentElement) {
|
||||||
|
throw new DomainRuleException('Rolle oder Medium fehlt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($element->archived_at !== null) {
|
||||||
|
throw new DomainRuleException('Ein archiviertes Medium wird nicht zugeordnet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($subject instanceof ContentElement && (int) $subject->getKey() === (int) $element->id) {
|
||||||
|
throw new DomainRuleException('Ein Medium kann nicht seine eigene Präsentation sein.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$source = $this->checkedSource($subject, $element, $sourceVersionId);
|
||||||
|
|
||||||
|
$existing = PresentationAssignment::query()
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->where('presentation_role_id', $role->id)
|
||||||
|
->where('content_element_id', $element->id)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($existing instanceof PresentationAssignment) {
|
||||||
|
if ((int) $existing->source_version_id !== (int) ($source?->id ?? 0) && ($source !== null || $existing->source_version_id !== null)) {
|
||||||
|
$existing->source_version_id = $source?->id;
|
||||||
|
$existing->save();
|
||||||
|
$this->record($subject, null, $role->label.': '.$element->working_title, $actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $element->working_title.' ist in dieser Rolle bereits zugeordnet.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $role->multiple) {
|
||||||
|
PresentationAssignment::query()
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->where('presentation_role_id', $role->id)
|
||||||
|
->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
$position = (int) PresentationAssignment::query()
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->where('presentation_role_id', $role->id)
|
||||||
|
->max('position') + 1;
|
||||||
|
|
||||||
|
PresentationAssignment::query()->create([
|
||||||
|
'subject_type' => $subject->getMorphClass(),
|
||||||
|
'subject_id' => $subject->getKey(),
|
||||||
|
'content_element_id' => $element->id,
|
||||||
|
'presentation_role_id' => $role->id,
|
||||||
|
'position' => max(1, $position),
|
||||||
|
'source_version_id' => $source?->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->record($subject, null, $role->label.': '.$element->working_title, $actor);
|
||||||
|
|
||||||
|
return $element->working_title.' ist als '.$role->label.' zugeordnet. Es entsteht keine Fassung und keine Freigabe.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function detach(Model $subject, int $assignmentId, ?User $actor = null): string
|
||||||
|
{
|
||||||
|
$assignment = $this->owned($subject, $assignmentId);
|
||||||
|
$label = ($assignment->role?->label ?? 'Präsentation').': '.($assignment->element?->working_title ?? '');
|
||||||
|
$assignment->delete();
|
||||||
|
$this->record($subject, $label, null, $actor);
|
||||||
|
|
||||||
|
return 'Die Zuordnung ist entfernt. Das Medium bleibt im Bestand.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function move(Model $subject, int $assignmentId, int $direction, ?User $actor = null): void
|
||||||
|
{
|
||||||
|
$assignment = $this->owned($subject, $assignmentId);
|
||||||
|
|
||||||
|
if (! $assignment->role?->ordered || $direction === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$neighbors = PresentationAssignment::query()
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->where('presentation_role_id', $assignment->presentation_role_id)
|
||||||
|
->orderBy('position')
|
||||||
|
->orderBy('id')
|
||||||
|
->get()
|
||||||
|
->values();
|
||||||
|
|
||||||
|
$index = $neighbors->search(fn (PresentationAssignment $row): bool => $row->id === $assignment->id);
|
||||||
|
|
||||||
|
if ($index === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$swap = $index + ($direction < 0 ? -1 : 1);
|
||||||
|
$other = $neighbors->get($swap);
|
||||||
|
|
||||||
|
if (! $other instanceof PresentationAssignment) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$position = $assignment->position;
|
||||||
|
$assignment->position = $other->position === $position ? $position + ($direction < 0 ? -1 : 1) : $other->position;
|
||||||
|
$other->position = $position;
|
||||||
|
$assignment->save();
|
||||||
|
$other->save();
|
||||||
|
$this->record($subject, null, 'Reihenfolge '.$assignment->role?->label, $actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kennung des ersten Titel- oder Galeriebildes. Ob es öffentlich erscheint, entscheidet WebsiteMedia.
|
||||||
|
*/
|
||||||
|
public function coverElementId(Model $subject): ?int
|
||||||
|
{
|
||||||
|
$assignments = PresentationAssignment::query()
|
||||||
|
->with('role')
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->orderBy('position')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach (PresentationRole::COVER_ROLES as $slug) {
|
||||||
|
$match = $assignments->first(fn (PresentationAssignment $row): bool => $row->role?->slug === $slug);
|
||||||
|
|
||||||
|
if ($match instanceof PresentationAssignment) {
|
||||||
|
return (int) $match->content_element_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function owned(Model $subject, int $assignmentId): PresentationAssignment
|
||||||
|
{
|
||||||
|
$assignment = PresentationAssignment::query()
|
||||||
|
->with(['role', 'element'])
|
||||||
|
->where('subject_type', $subject->getMorphClass())
|
||||||
|
->where('subject_id', $subject->getKey())
|
||||||
|
->whereKey($assignmentId)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! $assignment instanceof PresentationAssignment) {
|
||||||
|
throw new DomainRuleException('Diese Zuordnung gehört zu einem anderen Objekt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $assignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkedSource(Model $subject, ContentElement $element, ?int $sourceVersionId): ?ContentElementVersion
|
||||||
|
{
|
||||||
|
if ($sourceVersionId === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = ContentElementVersion::query()->find($sourceVersionId);
|
||||||
|
|
||||||
|
if (! $version instanceof ContentElementVersion) {
|
||||||
|
throw new DomainRuleException('Die gebundene Fassung fehlt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$ownsFilm = $subject instanceof ContentElement && (int) $version->content_element_id === (int) $subject->getKey();
|
||||||
|
$ownsClip = (int) $version->content_element_id === (int) $element->id;
|
||||||
|
|
||||||
|
if (! $ownsFilm && ! $ownsClip) {
|
||||||
|
throw new DomainRuleException('Die gebundene Fassung gehört weder zum Fachobjekt noch zum zugeordneten Medium.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $version;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{label: string, stale: bool}|null
|
||||||
|
*/
|
||||||
|
private function binding(PresentationAssignment $assignment): ?array
|
||||||
|
{
|
||||||
|
if ($assignment->source_version_id === null || ! $assignment->sourceVersion instanceof ContentElementVersion) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->bindingFor($assignment->sourceVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{label: string, stale: bool}
|
||||||
|
*/
|
||||||
|
private function bindingFor(ContentElementVersion $version): array
|
||||||
|
{
|
||||||
|
$latestId = ContentElementVersion::query()
|
||||||
|
->where('content_element_id', $version->content_element_id)
|
||||||
|
->where('status', ContentVersionStatus::Bereit)
|
||||||
|
->orderByDesc('number')
|
||||||
|
->value('id');
|
||||||
|
$stale = $latestId !== null && (int) $latestId !== (int) $version->id;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'label' => $stale
|
||||||
|
? 'Gebunden an Fassung '.$version->number.'. Die aktuelle Fassung ist eine andere. Der Clip wurde nicht neu erzeugt.'
|
||||||
|
: 'Gebunden an Fassung '.$version->number.'.',
|
||||||
|
'stale' => $stale,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function record(Model $subject, ?string $before, ?string $after, ?User $actor): void
|
||||||
|
{
|
||||||
|
IdentityChange::query()->create([
|
||||||
|
'subject_type' => $subject->getMorphClass(),
|
||||||
|
'subject_id' => $subject->getKey(),
|
||||||
|
'field' => 'praesentation',
|
||||||
|
'before' => $before,
|
||||||
|
'after' => $after,
|
||||||
|
'actor_id' => $actor?->id,
|
||||||
|
'occurred_at' => now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class PresentationRole extends Model
|
||||||
|
{
|
||||||
|
/** Rollen, deren Herkunft an einer Film- oder Audiofassung festgehalten werden kann. */
|
||||||
|
public const BOUND_ROLES = ['trailer', 'vorschauclip', 'audiovorschau'];
|
||||||
|
|
||||||
|
/** Reihenfolge, in der ein öffentliches Titelbild gesucht wird. */
|
||||||
|
public const COVER_ROLES = ['titelbild', 'hero', 'hover', 'titelbild_alternativ', 'galerie'];
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'slug',
|
||||||
|
'label',
|
||||||
|
'multiple',
|
||||||
|
'ordered',
|
||||||
|
'sort_order',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'multiple' => 'boolean',
|
||||||
|
'ordered' => 'boolean',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function assignments(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(PresentationAssignment::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public static function selectOptions(): array
|
||||||
|
{
|
||||||
|
return static::query()->orderBy('sort_order')->pluck('label', 'slug')->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kurze Bezeichnung für Überschriften und Auswahl in der Verwaltung.
|
||||||
|
*/
|
||||||
|
public static function displayLabel(string $slug, string $label): string
|
||||||
|
{
|
||||||
|
return match ($slug) {
|
||||||
|
'titelbild' => 'Titelbild',
|
||||||
|
'titelbild_alternativ' => 'Alternative Titelbilder',
|
||||||
|
'trailer' => 'Trailer',
|
||||||
|
'vorschauclip' => 'Vorschauclips',
|
||||||
|
'interview' => 'Interviews',
|
||||||
|
'galerie' => 'Galerie',
|
||||||
|
default => $label,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Catalog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ein aufgelöster redaktioneller Text. Der Wert wird nicht kopiert:
|
||||||
|
* eigen steht am Fachobjekt, variante ist eine Abweichung für einen Kontext,
|
||||||
|
* quelle verweist auf das eindeutig zugeordnete Fachobjekt eines Lizenzartikels.
|
||||||
|
*/
|
||||||
|
final readonly class ResolvedText
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public ?string $value,
|
||||||
|
public string $origin,
|
||||||
|
public ?string $label,
|
||||||
|
) {}
|
||||||
|
}
|
||||||
@@ -9,11 +9,18 @@
|
|||||||
* - url: nur ein öffentlich freigegebenes Ziel aus dem Fachobjekt (Themenseite, Programmseite), sonst null.
|
* - url: nur ein öffentlich freigegebenes Ziel aus dem Fachobjekt (Themenseite, Programmseite), sonst null.
|
||||||
* - public: false heißt „nur in der Redaktionsvorschau“; öffentlich entfällt die Karte dann.
|
* - public: false heißt „nur in der Redaktionsvorschau“; öffentlich entfällt die Karte dann.
|
||||||
* - notice: redaktioneller Hinweis für die Vorschau, warum die Karte öffentlich nicht erscheint.
|
* - notice: redaktioneller Hinweis für die Vorschau, warum die Karte öffentlich nicht erscheint.
|
||||||
|
* - visual: Darstellung ohne Kartenbild: 'film' (Medientafel Film), 'material' (Materialsymbol),
|
||||||
|
* 'catalog' (Navy-Tafel Programm/Modul) oder null (Karte ohne Bildbereich).
|
||||||
|
* - previewImage: geschütztes Vorschaubild der Bibliothek (Filmstandbild, Vorschau des Moduls). Nur für die
|
||||||
|
* Redaktionsvorschau (Route editorial.card, nur für angemeldete Redaktion); öffentlich nie ausgegeben, weil es
|
||||||
|
* keine Freigabe für die Website hat.
|
||||||
|
* - missing: was für eine vollständige Karte fehlt, als Hinweis nur in der Redaktionsvorschau.
|
||||||
*/
|
*/
|
||||||
final readonly class CardSubject
|
final readonly class CardSubject
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param list<string> $meta reine Anzeigetexte aus Fachdaten
|
* @param list<string> $meta reine Anzeigetexte aus Fachdaten
|
||||||
|
* @param list<string> $missing Hinweise für die Redaktion
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public string $title,
|
public string $title,
|
||||||
@@ -24,5 +31,29 @@ public function __construct(
|
|||||||
public ?string $url,
|
public ?string $url,
|
||||||
public bool $public,
|
public bool $public,
|
||||||
public ?string $notice = null,
|
public ?string $notice = null,
|
||||||
|
public ?string $visual = null,
|
||||||
|
public ?string $visualLabel = null,
|
||||||
|
public ?string $previewImage = null,
|
||||||
|
public array $missing = [],
|
||||||
|
public ?string $style = null,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
public function withText(?string $title, ?string $summary): self
|
||||||
|
{
|
||||||
|
return new self(
|
||||||
|
title: $title ?? $this->title,
|
||||||
|
summary: $summary ?? $this->summary,
|
||||||
|
kind: $this->kind,
|
||||||
|
badge: $this->badge,
|
||||||
|
meta: $this->meta,
|
||||||
|
url: $this->url,
|
||||||
|
public: $this->public,
|
||||||
|
notice: $this->notice,
|
||||||
|
visual: $this->visual,
|
||||||
|
visualLabel: $this->visualLabel,
|
||||||
|
previewImage: $this->previewImage,
|
||||||
|
missing: $this->missing,
|
||||||
|
style: $this->style,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,10 @@
|
|||||||
use App\Domain\Catalog\Composition;
|
use App\Domain\Catalog\Composition;
|
||||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||||
use App\Domain\Catalog\CompositionVersion;
|
use App\Domain\Catalog\CompositionVersion;
|
||||||
|
use App\Domain\Catalog\ContentVersionStatus;
|
||||||
use App\Domain\Catalog\EditorialContentKind;
|
use App\Domain\Catalog\EditorialContentKind;
|
||||||
|
use App\Domain\Catalog\EditorialProfileReader;
|
||||||
|
use App\Domain\Media\ThumbnailRef;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,7 +96,9 @@ public function search(?string $term, int $limit = 25): array
|
|||||||
$like = '%'.mb_strtolower($term).'%';
|
$like = '%'.mb_strtolower($term).'%';
|
||||||
$query->where(fn ($inner) => $inner
|
$query->where(fn ($inner) => $inner
|
||||||
->whereRaw('LOWER(designation) LIKE ?', [$like])
|
->whereRaw('LOWER(designation) LIKE ?', [$like])
|
||||||
->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like]));
|
->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like])
|
||||||
|
->orWhereRaw('LOWER(COALESCE(teaser, \'\')) LIKE ?', [$like])
|
||||||
|
->orWhereRaw('LOWER(COALESCE(search_terms, \'\')) LIKE ?', [$like]));
|
||||||
})
|
})
|
||||||
->orderBy('designation')
|
->orderBy('designation')
|
||||||
->limit($limit * 3)
|
->limit($limit * 3)
|
||||||
@@ -172,43 +177,164 @@ public function entries(array $refs, bool $includeNonPublic): array
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Anzeigedaten für eine Programm- oder Modulkarte (Premium-Karte). Dieselbe Regel wie entries():
|
* Für die Programm- oder Modulkarte wählbar: Programm oder Modul, nicht archiviert, mit mindestens einer
|
||||||
* Programme mit Anzeigefreigabe öffentlich mit Programmseite, Module nur in der Redaktionsvorschau.
|
* bereitgestellten Fassung. Anders als bei den Katalogkarten ist keine Anzeigefreigabe nötig, damit die Redaktion
|
||||||
* Die Art („Programm“ oder „Modul“) ist immer benannt. Kein Preis, kein Angebot, keine Kaufaktion.
|
* eine Karte vorbereiten kann; öffentlich gilt unverändert isPublic().
|
||||||
*/
|
*/
|
||||||
public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
public function isCardSelectable(Composition $composition): bool
|
||||||
{
|
{
|
||||||
$entry = $this->entries([['type' => 'composition', 'id' => $id]], $includeNonPublic)[0] ?? null;
|
return $composition->archived_at === null
|
||||||
|
&& in_array($composition->editorialContentKind?->slug, self::SELECTABLE_KINDS, true)
|
||||||
|
&& $this->latestReadyVersion($composition) !== null;
|
||||||
|
}
|
||||||
|
|
||||||
if ($entry === null) {
|
/**
|
||||||
return null;
|
* @return array<int, string>
|
||||||
}
|
*/
|
||||||
|
public function cardSearch(?string $term, int $limit = 25): array
|
||||||
|
{
|
||||||
|
$term = trim((string) $term);
|
||||||
|
|
||||||
$meta = [];
|
$candidates = Composition::query()
|
||||||
$composition = Composition::query()->find($entry->id);
|
->with('editorialContentKind')
|
||||||
$version = $composition !== null ? $this->shownVersion($composition) : null;
|
->whereNull('archived_at')
|
||||||
|
->whereHas('editorialContentKind', fn ($query) => $query->whereIn('slug', self::SELECTABLE_KINDS))
|
||||||
|
->when($term !== '', function ($query) use ($term): void {
|
||||||
|
$like = '%'.mb_strtolower($term).'%';
|
||||||
|
$query->where(fn ($inner) => $inner
|
||||||
|
->whereRaw('LOWER(designation) LIKE ?', [$like])
|
||||||
|
->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like])
|
||||||
|
->orWhereRaw('LOWER(COALESCE(teaser, \'\')) LIKE ?', [$like])
|
||||||
|
->orWhereRaw('LOWER(COALESCE(search_terms, \'\')) LIKE ?', [$like]));
|
||||||
|
})
|
||||||
|
->orderBy('designation')
|
||||||
|
->limit($limit * 3)
|
||||||
|
->get();
|
||||||
|
|
||||||
if ($version !== null) {
|
$options = [];
|
||||||
$nested = $version->members()->whereNotNull('nested_composition_version_id')->with('nestedCompositionVersion.composition.editorialContentKind')->get();
|
foreach ($candidates as $composition) {
|
||||||
$modules = $nested->filter(fn ($member): bool => $member->nestedCompositionVersion?->composition?->editorialContentKind?->slug === 'modul')->count();
|
if (! $this->isCardSelectable($composition)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($modules > 0) {
|
$options[$composition->id] = $this->cardOptionLabel($composition);
|
||||||
$meta[] = $modules === 1 ? '1 Modul' : $modules.' Module';
|
|
||||||
|
if (count($options) >= $limit) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function cardLabelFor(mixed $id): ?string
|
||||||
|
{
|
||||||
|
$composition = is_numeric($id) ? Composition::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||||
|
|
||||||
|
return $composition === null ? null : $this->cardOptionLabel($composition);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Anzeigedaten für eine Programm- oder Modulkarte (Premium-Karte).
|
||||||
|
*
|
||||||
|
* - Öffentlich nur Programme mit Anzeigefreigabe (dieselbe Regel wie /programme), mit Programmseite als Ziel.
|
||||||
|
* Module haben keine öffentliche Seitenart (ADR-29) und erscheinen nur in der Redaktionsvorschau, ohne Link.
|
||||||
|
* - Text: Kurzbeschreibung, sonst das Lernziel der gezeigten (öffentlich) bzw. neuesten bereitgestellten Fassung;
|
||||||
|
* das Lernziel steht auf der öffentlichen Programmseite bereits öffentlich.
|
||||||
|
* - Zusatzangaben: Zahl der Module, Dauer. Kein Preis, kein Angebot, keine Kaufaktion; eine Karte ist kein
|
||||||
|
* Lizenzartikel. Das Vorschaubild der Bibliothek erscheint nur in der Redaktionsvorschau.
|
||||||
|
*/
|
||||||
|
public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
||||||
|
{
|
||||||
|
$composition = is_numeric($id) ? Composition::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||||
|
|
||||||
|
if ($composition === null || ! $this->isCardSelectable($composition)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$shown = $this->shownVersion($composition);
|
||||||
|
$public = $shown !== null && $composition->archived_at === null;
|
||||||
|
|
||||||
|
if (! $public && ! $includeNonPublic) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = $shown ?? $this->latestReadyVersion($composition);
|
||||||
|
$program = $composition->editorialContentKind?->slug === 'programm';
|
||||||
|
$kind = (string) ($composition->editorialContentKind?->label ?? ($program ? 'Programm' : 'Modul'));
|
||||||
|
$profile = app(EditorialProfileReader::class)->read($composition, 'kachel');
|
||||||
|
$summary = $profile->value('teaser') ?: $profile->value('summary');
|
||||||
|
$goal = filled($version?->learning_goal) ? trim((string) $version->learning_goal) : null;
|
||||||
|
$missing = [];
|
||||||
|
|
||||||
|
if ($summary === null) {
|
||||||
|
$missing[] = $goal !== null
|
||||||
|
? 'Keine Kurzbeschreibung gepflegt; die Karte zeigt das Lernziel.'
|
||||||
|
: 'Weder Kurzbeschreibung noch Lernziel gepflegt.';
|
||||||
|
}
|
||||||
|
|
||||||
|
$meta = [];
|
||||||
|
if ($version !== null) {
|
||||||
|
$modules = $version->members()
|
||||||
|
->whereNotNull('nested_composition_version_id')
|
||||||
|
->with('nestedCompositionVersion.composition.editorialContentKind')
|
||||||
|
->get()
|
||||||
|
->filter(fn ($member): bool => $member->nestedCompositionVersion?->composition?->editorialContentKind?->slug === 'modul')
|
||||||
|
->count();
|
||||||
|
|
||||||
|
if ($program && $modules > 0) {
|
||||||
|
$meta[] = $modules === 1 ? '1 Modul' : $modules.' Module';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_numeric($version->duration_minutes) && (int) $version->duration_minutes > 0) {
|
||||||
|
$meta[] = 'Dauer '.(int) $version->duration_minutes.' Min.';
|
||||||
|
} else {
|
||||||
|
$missing[] = 'Keine Dauer gepflegt.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$notice = null;
|
||||||
|
if (! $public) {
|
||||||
|
$notice = 'Nur in der Redaktionsvorschau sichtbar: '.($program
|
||||||
|
? 'Das Programm hat keine Anzeigefreigabe.'
|
||||||
|
: 'Für Module gibt es noch keine öffentliche Seitenart (öffentliches Profil, ADR-29); die Karte erhält deshalb keinen Link.');
|
||||||
|
}
|
||||||
|
|
||||||
return new CardSubject(
|
return new CardSubject(
|
||||||
title: $entry->title,
|
title: $profile->value('display_title') ?: $this->title($composition),
|
||||||
summary: $entry->summary,
|
summary: $summary ?? $goal,
|
||||||
kind: $entry->kindLabel,
|
kind: $kind,
|
||||||
badge: null,
|
badge: null,
|
||||||
meta: $meta,
|
meta: $meta,
|
||||||
url: $entry->url,
|
url: $public ? route('public.program', $composition) : null,
|
||||||
public: $entry->public,
|
public: $public,
|
||||||
notice: $entry->public ? null : 'Nur in der Redaktionsvorschau sichtbar: Für Module gibt es noch keine öffentliche Seitenart (öffentliches Profil, ADR-29).',
|
notice: $notice,
|
||||||
|
visual: 'catalog',
|
||||||
|
visualLabel: $kind,
|
||||||
|
previewImage: $includeNonPublic ? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path) : null,
|
||||||
|
missing: $missing,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function latestReadyVersion(Composition $composition): ?CompositionVersion
|
||||||
|
{
|
||||||
|
return $composition->versions()
|
||||||
|
->where('status', ContentVersionStatus::Bereit->value)
|
||||||
|
->orderByDesc('number')
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function cardOptionLabel(Composition $composition): string
|
||||||
|
{
|
||||||
|
$visibility = match (true) {
|
||||||
|
$this->isPublic($composition) => 'öffentlich sichtbar',
|
||||||
|
$composition->editorialContentKind?->slug === 'modul' => 'Modul, nur Redaktionsvorschau',
|
||||||
|
default => 'ohne Anzeigefreigabe, nur Redaktionsvorschau',
|
||||||
|
};
|
||||||
|
|
||||||
|
return $this->title($composition).' · '.($composition->editorialContentKind?->label ?? '').' · '.$visibility;
|
||||||
|
}
|
||||||
|
|
||||||
private function title(Composition $composition): string
|
private function title(Composition $composition): string
|
||||||
{
|
{
|
||||||
return (string) ($composition->display_title ?: $composition->designation);
|
return (string) ($composition->display_title ?: $composition->designation);
|
||||||
|
|||||||
@@ -5,24 +5,31 @@
|
|||||||
use App\Domain\Catalog\CompositionStructureReader;
|
use App\Domain\Catalog\CompositionStructureReader;
|
||||||
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\StructureNode;
|
use App\Domain\Catalog\StructureNode;
|
||||||
|
use App\Domain\Media\ThumbnailRef;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lesesicht „Medien und Materialien“ für Premium-Karten (Website-CMS-Zielarchitektur 6.2).
|
* Lesesicht „Medien und Materialien“ für Premium-Karten (Website-CMS-Zielarchitektur 6.2).
|
||||||
*
|
*
|
||||||
* Übergangsregel, solange öffentliche Fachobjektprofile (ADR-29) fehlen:
|
* Auswahl in der Redaktion: jedes nicht archivierte Inhaltselement mit mindestens einer nicht gesperrten Fassung.
|
||||||
* Ein Medium oder Material hat keine eigene öffentliche Seite. Öffentlich genannt wird es heute nur als Bestandteil
|
|
||||||
* der gezeigten Fassung eines öffentlichen Programms (Programmseite /programme/{id}). Genau dann erscheint auch die
|
|
||||||
* Karte öffentlich, mit Verweis auf diese Programmseite. Sonst ist die Karte nur in der Redaktionsvorschau sichtbar.
|
|
||||||
*
|
*
|
||||||
* Gelesen werden nur Anzeigetitel, Inhaltsart und Ausgabeart, nie Kurzbeschreibung, Dateien, Lehrtexte,
|
* Öffentliche Sichtbarkeit (Übergangsregel, solange öffentliche Fachobjektprofile nach ADR-29 fehlen):
|
||||||
* Vorschaubilder der Bibliothek oder Ausgabeadressen. Eine Karte gibt kein Medium frei.
|
* Ein Medium hat keine eigene öffentliche Seite. Öffentlich genannt wird es heute nur als Bestandteil der gezeigten
|
||||||
|
* Fassung eines öffentlichen Programms (Programmseite /programme/{id}). Genau dann erscheint auch die Karte
|
||||||
|
* öffentlich, mit Verweis auf diese Programmseite, und nur mit bereitgestellter Fassung. Traineranleitungen erscheinen
|
||||||
|
* nie öffentlich (vertraulich für Trainerinnen und Trainer).
|
||||||
*
|
*
|
||||||
* Die Kurzbeschreibung eines Elements ist heute nirgends öffentlich (die Programmseite nennt nur den Titel). Sie bleibt
|
* Öffentlich gelesen werden Anzeigetitel (sonst Arbeitstitel), Kurzbeschreibung, Inhaltsart und Ausgabeart. Nie:
|
||||||
* deshalb auch auf der Karte aus, bis über öffentliche Profile (ADR-29) entschieden ist (offene Entscheidung, ADR-39).
|
* Beschreibung, Einsatzhinweis, Lizenzvermerk, Dateien, Lehrtexte, Ausgabeadressen. Das Vorschaubild (Filmstandbild)
|
||||||
|
* der Bibliothek ist nicht für die Website freigegeben; es erscheint nur in der Redaktionsvorschau.
|
||||||
|
* Eine Karte spielt nichts ab, bietet keinen Download und gibt kein Medium frei.
|
||||||
*/
|
*/
|
||||||
class PublicMaterialReader
|
class PublicMaterialReader
|
||||||
{
|
{
|
||||||
|
/** Inhaltsarten, die nie öffentlich auf einer Karte erscheinen. */
|
||||||
|
public const CONFIDENTIAL_KINDS = ['traineranleitung'];
|
||||||
|
|
||||||
/** @var array<int, array{id: int, title: string}>|null Element-ID => erstes öffentliches Programm */
|
/** @var array<int, array{id: int, title: string}>|null Element-ID => erstes öffentliches Programm */
|
||||||
private ?array $publicIndex = null;
|
private ?array $publicIndex = null;
|
||||||
|
|
||||||
@@ -31,13 +38,15 @@ public function __construct(
|
|||||||
private readonly CompositionStructureReader $structure,
|
private readonly CompositionStructureReader $structure,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
|
||||||
* Wählbar ist ein nicht archiviertes Element mit mindestens einer bereitgestellten (nicht gesperrten) Fassung.
|
|
||||||
*/
|
|
||||||
public function isSelectable(ContentElement $element): bool
|
public function isSelectable(ContentElement $element): bool
|
||||||
{
|
{
|
||||||
return $element->archived_at === null
|
return $element->archived_at === null
|
||||||
&& $element->versions()->where('status', ContentVersionStatus::Bereit->value)->exists();
|
&& $element->versions()->where('status', '!=', ContentVersionStatus::Gesperrt->value)->exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isReady(ContentElement $element): bool
|
||||||
|
{
|
||||||
|
return $element->versions()->where('status', ContentVersionStatus::Bereit->value)->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,6 +59,14 @@ public function publicProgramFor(ContentElement $element): ?array
|
|||||||
return $this->publicIndex()[$element->id] ?? null;
|
return $this->publicIndex()[$element->id] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isPublic(ContentElement $element): bool
|
||||||
|
{
|
||||||
|
return $this->isSelectable($element)
|
||||||
|
&& $this->isReady($element)
|
||||||
|
&& ! in_array($element->editorialContentKind?->slug, self::CONFIDENTIAL_KINDS, true)
|
||||||
|
&& $this->publicProgramFor($element) !== null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<int, string>
|
* @return array<int, string>
|
||||||
*/
|
*/
|
||||||
@@ -60,7 +77,7 @@ public function search(?string $term, int $limit = 25): array
|
|||||||
$candidates = ContentElement::query()
|
$candidates = ContentElement::query()
|
||||||
->with('editorialContentKind')
|
->with('editorialContentKind')
|
||||||
->whereNull('archived_at')
|
->whereNull('archived_at')
|
||||||
->whereHas('versions', fn ($query) => $query->where('status', ContentVersionStatus::Bereit->value))
|
->whereHas('versions', fn ($query) => $query->where('status', '!=', ContentVersionStatus::Gesperrt->value))
|
||||||
->when($term !== '', function ($query) use ($term): void {
|
->when($term !== '', function ($query) use ($term): void {
|
||||||
$like = '%'.mb_strtolower($term).'%';
|
$like = '%'.mb_strtolower($term).'%';
|
||||||
$query->where(fn ($inner) => $inner
|
$query->where(fn ($inner) => $inner
|
||||||
@@ -88,8 +105,10 @@ public function labelFor(mixed $id): ?string
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Anzeigedaten für eine Karte. Öffentlich null, wenn das Element nicht öffentlich genannt wird.
|
* Anzeigedaten für eine Karte. Öffentlich null, wenn das Element nicht öffentlich genannt wird.
|
||||||
|
*
|
||||||
|
* @param array<string, mixed> $draft ungespeicherte Anzeigedaten, nur für die Redaktionsvorschau
|
||||||
*/
|
*/
|
||||||
public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?CardSubject
|
||||||
{
|
{
|
||||||
$element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null;
|
$element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||||
|
|
||||||
@@ -97,29 +116,74 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$program = $this->publicProgramFor($element);
|
$public = $this->isPublic($element);
|
||||||
|
|
||||||
if ($program === null && ! $includeNonPublic) {
|
if (! $public && ! $includeNonPublic) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$output = self::outputLabel((string) $element->output_class);
|
$shown = clone $element;
|
||||||
|
|
||||||
|
foreach (['working_title', 'display_title', 'summary', 'thumbnail_path', 'thumbnail_alt'] as $field) {
|
||||||
|
if (! array_key_exists($field, $draft)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = $draft[$field];
|
||||||
|
$shown->setAttribute($field, is_string($value) && trim($value) === '' ? null : $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
$program = $this->publicProgramFor($element);
|
||||||
|
$output = self::outputLabel((string) $shown->output_class);
|
||||||
|
$film = $shown->output_class === 'film';
|
||||||
$editorialKind = $element->editorialContentKind?->label;
|
$editorialKind = $element->editorialContentKind?->label;
|
||||||
|
$summary = filled($shown->summary) ? trim((string) $shown->summary) : null;
|
||||||
|
$profile = app(EditorialProfileReader::class)->read($shown, 'bibliothek');
|
||||||
|
|
||||||
|
if (! array_key_exists('summary', $draft) && $profile->origin('summary') === 'variante') {
|
||||||
|
$summary = $profile->value('summary');
|
||||||
|
} elseif ($summary === null && filled($shown->teaser)) {
|
||||||
|
$summary = trim((string) $shown->teaser);
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = (string) ($shown->display_title ?: $shown->working_title);
|
||||||
|
|
||||||
|
if (! array_key_exists('display_title', $draft) && $profile->origin('display_title') === 'variante') {
|
||||||
|
$title = (string) $profile->value('display_title');
|
||||||
|
}
|
||||||
|
|
||||||
|
$meta = [$output];
|
||||||
|
if ($program !== null) {
|
||||||
|
$meta[] = 'Im Programm „'.$program['title'].'“';
|
||||||
|
}
|
||||||
|
if ($film) {
|
||||||
|
$meta[] = 'Vollständiger Film nur mit Lizenz im Mitgliederbereich';
|
||||||
|
}
|
||||||
|
|
||||||
|
$missing = [];
|
||||||
|
if ($summary === null) {
|
||||||
|
$missing[] = 'Keine Kurzbeschreibung gepflegt (Medium bearbeiten → Kurzbeschreibung).';
|
||||||
|
}
|
||||||
|
if (! filled($shown->display_title)) {
|
||||||
|
$missing[] = 'Kein Anzeigetitel gepflegt; die Karte zeigt den Arbeitstitel.';
|
||||||
|
}
|
||||||
|
|
||||||
|
$previewImage = $includeNonPublic ? ThumbnailRef::url('editorial.card', 'element', (int) $element->id, $shown->thumbnail_path) : null;
|
||||||
|
|
||||||
return new CardSubject(
|
return new CardSubject(
|
||||||
title: $this->title($element),
|
title: $title,
|
||||||
summary: null,
|
summary: $summary,
|
||||||
kind: filled($editorialKind) ? (string) $editorialKind : $output,
|
kind: filled($editorialKind) ? (string) $editorialKind : $output,
|
||||||
badge: $output,
|
badge: $output,
|
||||||
meta: array_values(array_filter([
|
meta: $meta,
|
||||||
$output,
|
url: $public && $program !== null ? route('public.program', $program['id']) : null,
|
||||||
$program !== null ? 'Im Programm „'.$program['title'].'“' : null,
|
public: $public,
|
||||||
])),
|
notice: $public ? null : $this->notice($element, $program),
|
||||||
url: $program !== null ? route('public.program', $program['id']) : null,
|
visual: $film ? 'film' : 'material',
|
||||||
public: $program !== null,
|
visualLabel: $output,
|
||||||
notice: $program === null
|
previewImage: $previewImage,
|
||||||
? 'Nur in der Redaktionsvorschau sichtbar: Dieses Medium gehört zu keinem öffentlich gezeigten Programm. Medien haben noch keine eigene öffentliche Freigabe (öffentliches Profil, ADR-29).'
|
missing: $missing,
|
||||||
: null,
|
style: $film ? 'media' : 'material',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,17 +199,40 @@ public static function outputLabel(string $outputClass): string
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private function title(ContentElement $element): string
|
public function visibilityNote(ContentElement $element): string
|
||||||
{
|
{
|
||||||
return (string) ($element->display_title ?: $element->working_title);
|
if ($this->isPublic($element)) {
|
||||||
|
$program = $this->publicProgramFor($element);
|
||||||
|
|
||||||
|
return 'Öffentlich nur als Teil der Programmseite „'.($program['title'] ?? '').'“. Die Mediendatei wird dabei nicht ausgeliefert.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->notice($element, $this->publicProgramFor($element));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array{id: int, title: string}|null $program
|
||||||
|
*/
|
||||||
|
private function notice(ContentElement $element, ?array $program): string
|
||||||
|
{
|
||||||
|
$reason = match (true) {
|
||||||
|
in_array($element->editorialContentKind?->slug, self::CONFIDENTIAL_KINDS, true) => 'Traineranleitungen erscheinen nie öffentlich.',
|
||||||
|
! $this->isReady($element) => 'Das Medium hat noch keine bereitgestellte Fassung.',
|
||||||
|
$program === null => 'Das Medium gehört zu keinem öffentlich gezeigten Programm. Medien haben noch keine eigene öffentliche Freigabe (öffentliches Profil, ADR-29).',
|
||||||
|
default => 'Das Medium ist nicht öffentlich.',
|
||||||
|
};
|
||||||
|
|
||||||
|
return 'Nur in der Redaktionsvorschau sichtbar: '.$reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function optionLabel(ContentElement $element): string
|
private function optionLabel(ContentElement $element): string
|
||||||
{
|
{
|
||||||
$visibility = $this->publicProgramFor($element) !== null ? 'öffentlich über Programmseite' : 'nur Redaktionsvorschau';
|
$visibility = $this->isPublic($element)
|
||||||
|
? 'öffentlich über Programmseite'
|
||||||
|
: ($this->isReady($element) ? 'nur Redaktionsvorschau' : 'Entwurf, nur Redaktionsvorschau');
|
||||||
$kind = $element->editorialContentKind?->label ?: self::outputLabel((string) $element->output_class);
|
$kind = $element->editorialContentKind?->label ?: self::outputLabel((string) $element->output_class);
|
||||||
|
|
||||||
return $this->title($element).' · '.$kind.' · '.$visibility;
|
return (string) ($element->display_title ?: $element->working_title).' · '.$kind.' · '.$visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Domain\Cms\Sections;
|
namespace App\Domain\Cms\Sections;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||||
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
@@ -145,7 +147,7 @@ public function mediaPaths(array $sections): array
|
|||||||
|
|
||||||
foreach ($sections as $section) {
|
foreach ($sections as $section) {
|
||||||
$style = SectionStyle::fromStored($section['style'] ?? []);
|
$style = SectionStyle::fromStored($section['style'] ?? []);
|
||||||
if ($style['image'] !== null && PublicMedia::isPublicPath($style['image'])) {
|
if (is_string($style['image']) && PublicMedia::isPublicPath($style['image'])) {
|
||||||
$paths[] = $style['image'];
|
$paths[] = $style['image'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -335,14 +337,17 @@ private function normalizeStyle(array $style, string $prefix, array &$errors): a
|
|||||||
$result[$key] = $value;
|
$result[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$upload = PublicMedia::fromUploadState($style['_upload'] ?? null);
|
|
||||||
$image = $upload ?? PublicMedia::fromUploadState($style['image'] ?? null);
|
|
||||||
|
|
||||||
if ($result['background'] === 'image') {
|
if ($result['background'] === 'image') {
|
||||||
if ($image === null) {
|
$widgetErrors = new WidgetErrors;
|
||||||
$errors["$prefix.style.image"] = ['Bitte ein Hintergrundbild wählen oder hochladen.'];
|
$refs = ImageRefFields::clean(['image' => $style['image'] ?? null, '_upload' => $style['_upload'] ?? null], $widgetErrors, errorKey: 'image');
|
||||||
} elseif (! PublicMedia::isPublicPath($image)) {
|
$image = $refs['image'];
|
||||||
$errors["$prefix.style.image"] = ['Das Hintergrundbild liegt nicht im öffentlichen Medienbereich.'];
|
|
||||||
|
foreach ($widgetErrors->all() as $messages) {
|
||||||
|
$errors["$prefix.style.image"] = $messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($image === null && ! isset($errors["$prefix.style.image"])) {
|
||||||
|
$errors["$prefix.style.image"] = ['Bitte ein Hintergrundbild aus dem Medienmanager wählen oder hochladen.'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$result['image'] = $image;
|
$result['image'] = $image;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
namespace App\Domain\Cms\Sections;
|
namespace App\Domain\Cms\Sections;
|
||||||
|
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
use App\Domain\Cms\Widgets\WidgetRenderer;
|
use App\Domain\Cms\Widgets\WidgetRenderer;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ public function renderAll(array $sections, RenderContext $context): HtmlString
|
|||||||
$last = count($rendered) - 1;
|
$last = count($rendered) - 1;
|
||||||
|
|
||||||
foreach ($rendered as $index => $item) {
|
foreach ($rendered as $index => $item) {
|
||||||
$html .= $this->renderSection($item['section'], $item['cells'], $index);
|
$html .= $this->renderSection($item['section'], $item['cells'], $index, $context);
|
||||||
|
|
||||||
$divider = $item['section']['style']['divider'] ?? 'none';
|
$divider = $item['section']['style']['divider'] ?? 'none';
|
||||||
if ($index < $last && in_array($divider, ['line', 'accent'], true)) {
|
if ($index < $last && in_array($divider, ['line', 'accent'], true)) {
|
||||||
@@ -71,11 +71,13 @@ public function renderAll(array $sections, RenderContext $context): HtmlString
|
|||||||
* @param array<string, mixed> $section
|
* @param array<string, mixed> $section
|
||||||
* @param list<array{units: int, html: string}> $cells
|
* @param list<array{units: int, html: string}> $cells
|
||||||
*/
|
*/
|
||||||
private function renderSection(array $section, array $cells, int $index): string
|
private function renderSection(array $section, array $cells, int $index, RenderContext $context): string
|
||||||
{
|
{
|
||||||
$style = SectionStyle::fromStored($section['style'] ?? []);
|
$style = SectionStyle::fromStored($section['style'] ?? []);
|
||||||
$columns = SectionLayouts::columns(array_column($cells, 'units'));
|
$columns = SectionLayouts::columns(array_column($cells, 'units'));
|
||||||
$hasImage = $style['background'] === 'image' && $style['image'] !== null && PublicMedia::isPublicPath($style['image']);
|
// Hintergrundbild aus dem Medienmanager: öffentlich nur mit Website-Freigabe (WebsiteImage → WebsiteMedia).
|
||||||
|
$imageUrl = $style['background'] === 'image' ? app(WebsiteImage::class)->url($style['image'], $context->preview) : null;
|
||||||
|
$hasImage = $imageUrl !== null;
|
||||||
|
|
||||||
$classes = [
|
$classes = [
|
||||||
'page-section',
|
'page-section',
|
||||||
@@ -109,7 +111,7 @@ private function renderSection(array $section, array $cells, int $index): string
|
|||||||
if ($hasImage) {
|
if ($hasImage) {
|
||||||
// Das Bild des ersten Abschnitts ist meist das größte sichtbare Element und wird nicht verzögert geladen.
|
// Das Bild des ersten Abschnitts ist meist das größte sichtbare Element und wird nicht verzögert geladen.
|
||||||
$loading = $index === 0 ? 'loading="eager" fetchpriority="high"' : 'loading="lazy"';
|
$loading = $index === 0 ? 'loading="eager" fetchpriority="high"' : 'loading="lazy"';
|
||||||
$html .= '<img class="page-section-image" src="'.e(PublicMedia::url($style['image'])).'" alt="" '.$loading.' decoding="async"'
|
$html .= '<img class="page-section-image" src="'.e($imageUrl).'" alt="" '.$loading.' decoding="async"'
|
||||||
.' style="object-position: '.e(SectionStyle::FOCUS_POSITIONS[$style['focus']]).'">';
|
.' style="object-position: '.e(SectionStyle::FOCUS_POSITIONS[$style['focus']]).'">';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Domain\Cms\Sections;
|
namespace App\Domain\Cms\Sections;
|
||||||
|
|
||||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Semantische Abschnittsgestaltung. Jeder Wert ist eine Aufzählung, die auf zentrale Design-Tokens
|
* Semantische Abschnittsgestaltung. Jeder Wert ist eine Aufzählung, die auf zentrale Design-Tokens
|
||||||
@@ -134,7 +134,7 @@ public static function fromStored(mixed $style): array
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result['image'] = $result['background'] === 'image' && is_string($style['image'] ?? null) ? $style['image'] : null;
|
$result['image'] = $result['background'] === 'image' ? WebsiteImage::normalize($style['image'] ?? null) : null;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@@ -204,7 +204,7 @@ public static function migrateSpacing(array $sections, bool $byVersion = false):
|
|||||||
$rendered = is_array($section['slots'] ?? null) && array_filter($section['slots'], 'is_array') !== [];
|
$rendered = is_array($section['slots'] ?? null) && array_filter($section['slots'], 'is_array') !== [];
|
||||||
|
|
||||||
$background = is_string($style['background'] ?? null) && isset(self::BACKGROUNDS[$style['background']]) ? $style['background'] : 'default';
|
$background = is_string($style['background'] ?? null) && isset(self::BACKGROUNDS[$style['background']]) ? $style['background'] : 'default';
|
||||||
if ($background === 'image' && ! PublicMedia::isPublicPath($style['image'] ?? null)) {
|
if ($background === 'image' && WebsiteImage::normalize($style['image'] ?? null) === null) {
|
||||||
$background = 'default';
|
$background = 'default';
|
||||||
}
|
}
|
||||||
$divider = in_array($style['divider'] ?? null, ['line', 'accent'], true) ? $style['divider'] : 'none';
|
$divider = in_array($style['divider'] ?? null, ['line', 'accent'], true) ? $style['divider'] : 'none';
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Cms;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Media\WebsiteMediaAlias;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wo ein Medium auf Website-Seiten als Bild verwendet wird (veröffentlichte Fassung und neuester Entwurf).
|
||||||
|
* Für den Medienmanager: Vor dem Zurücknehmen einer Website-Freigabe ist sichtbar, welche Seiten das Bild verlieren.
|
||||||
|
*/
|
||||||
|
class WebsiteImageUsage
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return list<array{path: string, published: bool, draft: bool}>
|
||||||
|
*/
|
||||||
|
public function pages(ContentElement $element): array
|
||||||
|
{
|
||||||
|
$legacy = WebsiteMediaAlias::query()->where('content_element_id', $element->id)->pluck('legacy_path')->all();
|
||||||
|
$usages = [];
|
||||||
|
|
||||||
|
foreach (Page::query()->with(['publishedRevision', 'latestRevision'])->orderBy('path')->get() as $page) {
|
||||||
|
$published = $page->publishedRevision !== null && $this->uses($page->publishedRevision->sections ?? [], $element->id, $legacy);
|
||||||
|
$draft = $page->latestRevision !== null && $page->latestRevision->id !== $page->published_revision_id
|
||||||
|
&& $this->uses($page->latestRevision->sections ?? [], $element->id, $legacy);
|
||||||
|
|
||||||
|
if ($published || $draft) {
|
||||||
|
$usages[] = ['path' => (string) $page->path, 'published' => $published, 'draft' => $draft];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $usages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $legacy
|
||||||
|
*/
|
||||||
|
private function uses(mixed $value, int $id, array $legacy): bool
|
||||||
|
{
|
||||||
|
if (! is_array($value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($value as $key => $item) {
|
||||||
|
if ($key === 'image' && (($item === $id || (is_string($item) && ($item === (string) $id || in_array($item, $legacy, true)))))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($item) && $this->uses($item, $id, $legacy)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,40 +5,76 @@
|
|||||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
use Filament\Forms\Components\Field;
|
use Filament\Forms\Components\Field;
|
||||||
use Filament\Forms\Components\FileUpload;
|
use Filament\Forms\Components\FileUpload;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Placeholder;
|
||||||
use Illuminate\Support\Str;
|
use Filament\Forms\Components\ViewField;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
|
use Filament\Schemas\Components\Utilities\Set;
|
||||||
|
use Illuminate\Support\HtmlString;
|
||||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gemeinsame Bildauswahl für Widgets: vorhandenes Bild aus dem öffentlichen Website-Bereich wählen
|
* Gemeinsame Bildauswahl aller Widgets und des Abschnittshintergrunds: Bilder aus dem zentralen Medienmanager
|
||||||
* oder ein neues hochladen. Keine eigene Medienverwaltung.
|
* (siehe WebsiteImage, docs/architektur/medienzugriff-fuer-komponenten.md). Keine eigene CMS-Medienverwaltung.
|
||||||
|
*
|
||||||
|
* - Auswahl: durchsuchbare Liste mit Vorschaubild, Titel und Website-Status.
|
||||||
|
* - Neu hochladen: Das Bild wird sofort als Medium im Medienmanager angelegt (WebsiteIntake) und ausgewählt.
|
||||||
|
* - Anzeige des gewählten Mediums mit Status und Verweis auf die Freigabe im Medienmanager.
|
||||||
|
*
|
||||||
|
* Das Bedienmuster folgt der Bildauswahl im Modul- und Programmeditor (Suche, Vorschaubild, Auswählen); jene ist an
|
||||||
|
* die Livewire-Seite des Editors gebunden und lässt sich nicht als Formularfeld im Widget-Dialog einhängen.
|
||||||
*/
|
*/
|
||||||
final class ImageRefFields
|
final class ImageRefFields
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param bool $live Änderungen sofort an die Vorschau im Bearbeitungsdialog geben.
|
* @param bool $live Änderungen sofort an die Vorschau im Bearbeitungsdialog geben.
|
||||||
* @return list<Field>
|
* @param string|null $altField Name des Alternativtext-Felds im selben Formular (für neue Medien), falls vorhanden.
|
||||||
|
* @return list<Field|Placeholder>
|
||||||
*/
|
*/
|
||||||
public static function fields(string $label = 'Bild', bool $live = false): array
|
public static function fields(string $label = 'Bild', bool $live = false, string $key = 'image', ?string $altField = null): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Select::make('image')
|
// Auswahl über den gemeinsamen visuellen Picker (Suche, Vorschau, Website-Freigabe im Detail).
|
||||||
->live($live)
|
ViewField::make($key)
|
||||||
->label($label.': vorhandenes Bild')
|
->live()
|
||||||
->options(fn (): array => PublicMedia::imageOptions())
|
->label($label.' aus dem Medienmanager')
|
||||||
->searchable()
|
->view('filament.cms.bild-feld')
|
||||||
->placeholder('Kein Bild')
|
->helperText('Öffentlich erscheint ein Bild nur mit Website-Freigabe; die Auswahl gibt es nicht frei.'),
|
||||||
->helperText('Auswahl aus den Bildern, die bereits für die Website hochgeladen wurden.'),
|
|
||||||
FileUpload::make('_upload')
|
FileUpload::make('_upload')
|
||||||
->live($live)
|
->live()
|
||||||
->label($label.': neu hochladen')
|
->label($label.': neues Bild hochladen')
|
||||||
->disk('cms_incoming')
|
|
||||||
->directory('cms')
|
|
||||||
->image()
|
->image()
|
||||||
->maxSize(8192)
|
->maxSize(8192)
|
||||||
->acceptedFileTypes(['image/jpeg', 'image/png', 'image/webp'])
|
->acceptedFileTypes(['image/jpeg', 'image/png', 'image/webp'])
|
||||||
->getUploadedFileNameForStorageUsing(fn (TemporaryUploadedFile $file): string => Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)).'-'.Str::lower(Str::random(6)).'.'.$file->guessExtension())
|
->storeFiles(false)
|
||||||
->helperText('Ein neues Bild ersetzt die Auswahl oben. Es wird beim Speichern im öffentlichen Bereich der Website abgelegt.'),
|
->afterStateUpdated(function (mixed $state, Set $set, Get $get) use ($key, $altField): void {
|
||||||
|
$file = is_array($state) ? (array_values($state)[0] ?? null) : $state;
|
||||||
|
|
||||||
|
if (! $file instanceof TemporaryUploadedFile) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$element = app(WebsiteImage::class)->accept($file, $altField !== null ? $get($altField) : null);
|
||||||
|
$set('_upload', null);
|
||||||
|
|
||||||
|
if ($element === null) {
|
||||||
|
Notification::make()->danger()->title('Das Bild konnte nicht übernommen werden.')->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$set($key, $element->id);
|
||||||
|
Notification::make()
|
||||||
|
->success()
|
||||||
|
->title('Im Medienmanager angelegt: „'.($element->display_title ?: $element->working_title).'“')
|
||||||
|
->body('Das Bild ist ausgewählt. Nach der Verarbeitung wird es automatisch für die Website freigegeben.')
|
||||||
|
->send();
|
||||||
|
})
|
||||||
|
->helperText('Das Bild wird im Medienmanager angelegt und hier ausgewählt. Nur Bilder mit geklärten Rechten hochladen.'),
|
||||||
|
Placeholder::make('_media_status')
|
||||||
|
->label('Gewähltes Bild')
|
||||||
|
->visible(fn (Get $get): bool => WebsiteImage::normalize($get($key)) !== null)
|
||||||
|
->content(fn (Get $get): HtmlString => self::statusHtml($get($key))),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,29 +84,49 @@ public static function fields(string $label = 'Bild', bool $live = false): array
|
|||||||
public static function rules(): array
|
public static function rules(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'image' => ['nullable', 'string', 'max:255'],
|
'image' => ['nullable'],
|
||||||
'_upload' => ['nullable'],
|
'_upload' => ['nullable'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Übernimmt einen neuen Upload als Bild und prüft, dass das Bild im öffentlichen Bereich liegt.
|
* Prüft das gewählte Bild. Ein früherer CMS-Pfad mit wirksamer Zuordnung wird zur Kennung des Mediums.
|
||||||
|
* Ein noch als Datei übergebener Upload (frühere Formulare) wird über den Medienmanager aufgenommen.
|
||||||
*
|
*
|
||||||
* @param array<string, mixed> $refs
|
* @param array<string, mixed> $refs
|
||||||
* @return array<string, mixed>
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public static function clean(array $refs, WidgetErrors $errors, string $key = 'image', ?string $errorKey = null): array
|
public static function clean(array $refs, WidgetErrors $errors, string $key = 'image', ?string $errorKey = null): array
|
||||||
{
|
{
|
||||||
$upload = PublicMedia::fromUploadState($refs['_upload'] ?? null);
|
$images = app(WebsiteImage::class);
|
||||||
$image = $upload ?? PublicMedia::fromUploadState($refs[$key] ?? null);
|
$upload = $refs['_upload'] ?? null;
|
||||||
|
$upload = is_array($upload) ? (array_values($upload)[0] ?? null) : $upload;
|
||||||
|
|
||||||
if ($image !== null && ! PublicMedia::isPublicPath($image)) {
|
if ($upload instanceof TemporaryUploadedFile) {
|
||||||
$errors->add($errorKey ?? "refs.$key", 'Das Bild liegt nicht im öffentlichen Medienbereich.');
|
$element = $images->accept($upload);
|
||||||
|
$refs[$key] = $element?->id ?? $refs[$key] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$refs[$key] = $image;
|
$refs[$key] = $images->clean($refs[$key] ?? null, $errors, $errorKey ?? "refs.$key");
|
||||||
unset($refs['_upload']);
|
unset($refs['_upload']);
|
||||||
|
|
||||||
return $refs;
|
return $refs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function statusHtml(mixed $value): HtmlString
|
||||||
|
{
|
||||||
|
$status = app(WebsiteImage::class)->status($value);
|
||||||
|
|
||||||
|
if ($status === null) {
|
||||||
|
return new HtmlString('');
|
||||||
|
}
|
||||||
|
|
||||||
|
$thumb = $status['thumb'] !== null ? '<img src="'.e($status['thumb']).'" alt="">' : '';
|
||||||
|
$link = $status['manageUrl'] !== null
|
||||||
|
? '<a href="'.e($status['manageUrl']).'" target="_blank" rel="noopener">Im Medienmanager öffnen</a>'
|
||||||
|
: '';
|
||||||
|
|
||||||
|
return new HtmlString('<div class="luf-media-status luf-media-status-'.e($status['state']).'">'.$thumb
|
||||||
|
.'<div><strong>'.e($status['title']).'</strong><p>'.e($status['note']).'</p>'.$link.'</div></div>');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -98,10 +98,10 @@ public static function focusFields(int $defaultX = 50, int $defaultY = 50): arra
|
|||||||
public static function altField(): TextInput
|
public static function altField(): TextInput
|
||||||
{
|
{
|
||||||
return TextInput::make('alt')
|
return TextInput::make('alt')
|
||||||
->label('Alternativtext des Bildes')
|
->label('Alternativtext (optional)')
|
||||||
->maxLength(300)
|
->maxLength(300)
|
||||||
->live(onBlur: true)
|
->live(onBlur: true)
|
||||||
->helperText('Beschreibt, was auf dem Bild zu sehen ist. Pflicht, sobald ein Bild gewählt ist.');
|
->helperText('Leer lassen, dann gilt der Alternativtext des Mediums aus dem Medienmanager. Nur ausfüllen, wenn das Bild hier etwas anderes aussagen soll.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,10 +127,6 @@ public static function clean(array $data, WidgetErrors $errors, bool $hasImage):
|
|||||||
$data[$key] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
$data[$key] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($hasImage && $data['alt'] === null) {
|
|
||||||
$errors->add('data.alt', 'Bitte einen Alternativtext für das Bild angeben.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,20 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Domain\Cms\Widgets\Support;
|
namespace App\Domain\Cms\Widgets\Support;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Öffentlicher Medienbereich der Website ("cms/"). Nur Dateien aus diesem Bereich dürfen in Widgets
|
* Frühere öffentliche CMS-Bilder („cms/“, Route media.public). Neue Bilder kommen aus dem Medienmanager (WebsiteImage);
|
||||||
* verwendet werden. Geschützte Bibliotheksmedien (Inhaltsdateien, Vorschaubilder) sind hier nie wählbar.
|
* dieser Bereich bleibt nur für gespeicherte Revisionen mit früheren Pfaden, die (noch) keinem Medium zugeordnet sind.
|
||||||
*/
|
*/
|
||||||
final class PublicMedia
|
final class PublicMedia
|
||||||
{
|
{
|
||||||
public const PREFIX = 'cms/';
|
public const PREFIX = 'cms/';
|
||||||
|
|
||||||
private const IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'webp', 'gif', 'avif'];
|
|
||||||
|
|
||||||
public static function isPublicPath(mixed $path): bool
|
public static function isPublicPath(mixed $path): bool
|
||||||
{
|
{
|
||||||
return is_string($path)
|
return is_string($path)
|
||||||
@@ -29,36 +23,6 @@ public static function url(string $path): string
|
|||||||
return route('media.public', ['path' => $path]);
|
return route('media.public', ['path' => $path]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Bereits vorhandene Bilder im öffentlichen Bereich (veröffentlicht oder zur Veröffentlichung vorgemerkt).
|
|
||||||
*
|
|
||||||
* @return array<string, string>
|
|
||||||
*/
|
|
||||||
public static function imageOptions(): array
|
|
||||||
{
|
|
||||||
$options = [];
|
|
||||||
|
|
||||||
foreach (['media_public', 'cms_incoming'] as $disk) {
|
|
||||||
try {
|
|
||||||
$files = Storage::disk($disk)->allFiles(rtrim(self::PREFIX, '/'));
|
|
||||||
} catch (Throwable) {
|
|
||||||
$files = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($files as $file) {
|
|
||||||
$extension = strtolower(pathinfo($file, PATHINFO_EXTENSION));
|
|
||||||
|
|
||||||
if (self::isPublicPath($file) && in_array($extension, self::IMAGE_EXTENSIONS, true)) {
|
|
||||||
$options[$file] = substr($file, strlen(self::PREFIX));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ksort($options);
|
|
||||||
|
|
||||||
return $options;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pfad aus dem Zustand eines Upload-Felds (Zeichenkette oder Liste).
|
* Pfad aus dem Zustand eines Upload-Felds (Zeichenkette oder Liste).
|
||||||
*/
|
*/
|
||||||
@@ -70,31 +34,4 @@ public static function fromUploadState(mixed $state): ?string
|
|||||||
|
|
||||||
return is_string($state) && $state !== '' ? $state : null;
|
return is_string($state) && $state !== '' ? $state : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Bildadresse für Darstellung und Blockvorschau. In der Vorschau kann ein noch nicht gespeicherter Upload vorliegen.
|
|
||||||
*
|
|
||||||
* @param array<string, mixed> $refs
|
|
||||||
*/
|
|
||||||
public static function imageUrl(array $refs, string $key = 'image'): ?string
|
|
||||||
{
|
|
||||||
$upload = $refs['_upload'] ?? null;
|
|
||||||
$upload = is_array($upload) ? (array_values($upload)[0] ?? null) : $upload;
|
|
||||||
|
|
||||||
if ($upload instanceof TemporaryUploadedFile) {
|
|
||||||
try {
|
|
||||||
return $upload->temporaryUrl();
|
|
||||||
} catch (Throwable) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self::isPublicPath($upload)) {
|
|
||||||
return self::url($upload);
|
|
||||||
}
|
|
||||||
|
|
||||||
$path = $refs[$key] ?? null;
|
|
||||||
|
|
||||||
return self::isPublicPath($path) ? self::url($path) : null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,349 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Cms\Widgets\Support;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\EditorialContentKind;
|
||||||
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
|
use App\Domain\Media\ThumbnailRef;
|
||||||
|
use App\Domain\Media\WebsiteIntake;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Domain\Media\WebsiteMediaAlias;
|
||||||
|
use App\Domain\Media\WebsitePresentation;
|
||||||
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bilder in CMS-Widgets und Abschnittshintergründen aus dem zentralen Medienbestand
|
||||||
|
* (docs/architektur/medienzugriff-fuer-komponenten.md).
|
||||||
|
*
|
||||||
|
* Gespeichert wird im jeweiligen Bildschlüssel (refs.image, style.image, data.items[].image) die Kennung des
|
||||||
|
* Inhaltselements (int). Frühere Werte sind Pfade unter cms/ (string):
|
||||||
|
* - mit wirksamer Zuordnung (WebsiteMediaAlias) gelten sie als das zugeordnete Medium,
|
||||||
|
* - ohne Zuordnung gelten sie weiter als öffentliches CMS-Bild (PublicMedia), bis das Widget umgestellt ist.
|
||||||
|
*
|
||||||
|
* Öffentlich erscheint ein Medium nur über WebsiteMedia (Website-Freigabe, Route website.media). In der
|
||||||
|
* Redaktionsvorschau erscheint ein nicht freigegebenes Bild als Vorschaubild der Bibliothek (Route editorial.card)
|
||||||
|
* mit Hinweis. Eine CMS-Verwendung gibt nichts frei.
|
||||||
|
*
|
||||||
|
* Je Anfrage gebunden (scoped): Ergebnisse werden innerhalb einer Anfrage zwischengespeichert.
|
||||||
|
*/
|
||||||
|
class WebsiteImage
|
||||||
|
{
|
||||||
|
/** @var array<string, int|string|null> */
|
||||||
|
private array $resolved = [];
|
||||||
|
|
||||||
|
/** @var array<int, WebsitePresentation|false> */
|
||||||
|
private array $presentations = [];
|
||||||
|
|
||||||
|
public function __construct(private readonly WebsiteMedia $media) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gespeicherter oder eingegebener Wert → Kennung (int), früherer Pfad (string) oder null.
|
||||||
|
*/
|
||||||
|
public static function normalize(mixed $value): int|string|null
|
||||||
|
{
|
||||||
|
if (is_array($value)) {
|
||||||
|
$value = array_values($value)[0] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_int($value) && $value > 0) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_string($value) && preg_match('/^[1-9][0-9]*$/', $value) === 1) {
|
||||||
|
return (int) $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return PublicMedia::isPublicPath($value) ? $value : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kennung des Mediums: gespeicherte Kennung oder wirksam zugeordneter früherer Pfad; sonst null.
|
||||||
|
*/
|
||||||
|
public function elementId(mixed $value): ?int
|
||||||
|
{
|
||||||
|
$value = self::normalize($value);
|
||||||
|
|
||||||
|
if (is_int($value)) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($value === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! array_key_exists($value, $this->resolved)) {
|
||||||
|
$this->resolved[$value] = WebsiteMediaAlias::effectiveFor($value)?->content_element_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = $this->resolved[$value];
|
||||||
|
|
||||||
|
return is_int($id) ? $id : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function presentation(mixed $value): ?WebsitePresentation
|
||||||
|
{
|
||||||
|
$id = $this->elementId($value);
|
||||||
|
|
||||||
|
if ($id === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! array_key_exists($id, $this->presentations)) {
|
||||||
|
$this->presentations[$id] = $this->media->present($id) ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->presentations[$id] ?: null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bildadresse für die Darstellung. Öffentlich nur freigegebene Medien (oder frühere CMS-Bilder ohne Zuordnung);
|
||||||
|
* in der Redaktionsvorschau zusätzlich das Vorschaubild eines nicht freigegebenen Mediums.
|
||||||
|
*/
|
||||||
|
public function url(mixed $value, bool $preview = false): ?string
|
||||||
|
{
|
||||||
|
$presentation = $this->presentation($value);
|
||||||
|
|
||||||
|
if ($presentation !== null) {
|
||||||
|
return $presentation->kind === 'bild' ? $presentation->url : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = $this->elementId($value);
|
||||||
|
|
||||||
|
if ($id !== null) {
|
||||||
|
if (! $preview) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$element = ContentElement::query()->find($id);
|
||||||
|
|
||||||
|
return $element === null ? null : ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
||||||
|
}
|
||||||
|
|
||||||
|
$legacy = self::normalize($value);
|
||||||
|
|
||||||
|
return is_string($legacy) ? PublicMedia::url($legacy) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Alternativtext: Angabe im Widget, sonst der Alternativtext des Mediums. */
|
||||||
|
public function alt(mixed $value, mixed $override = null): string
|
||||||
|
{
|
||||||
|
if (is_string($override) && trim($override) !== '') {
|
||||||
|
return trim($override);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->presentation($value)?->alt ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Öffentliche Quellenzeile des Mediums (nur solange es freigegeben ist). */
|
||||||
|
public function credit(mixed $value): ?string
|
||||||
|
{
|
||||||
|
return $this->presentation($value)?->credit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hinweis für die Redaktionsvorschau, wenn das gewählte Bild öffentlich nicht erscheint; sonst null.
|
||||||
|
*/
|
||||||
|
public function previewNotice(mixed $value, string $label = 'Das gewählte Bild'): ?string
|
||||||
|
{
|
||||||
|
$status = $this->status($value);
|
||||||
|
|
||||||
|
if ($status === null || $status['public']) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $label.' „'.$status['title'].'“ erscheint öffentlich nicht: '.$status['note'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zustand für Editor und Vorschau.
|
||||||
|
*
|
||||||
|
* @return array{public: bool, state: string, title: string, note: string, thumb: ?string, manageUrl: ?string}|null
|
||||||
|
*/
|
||||||
|
public function status(mixed $value): ?array
|
||||||
|
{
|
||||||
|
$value = self::normalize($value);
|
||||||
|
|
||||||
|
if ($value === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = $this->elementId($value);
|
||||||
|
|
||||||
|
if ($id === null) {
|
||||||
|
return [
|
||||||
|
'public' => true,
|
||||||
|
'state' => 'legacy',
|
||||||
|
'title' => basename((string) $value),
|
||||||
|
'note' => 'Früheres CMS-Bild, noch nicht in den Medienmanager übernommen.',
|
||||||
|
'thumb' => PublicMedia::url((string) $value),
|
||||||
|
'manageUrl' => null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$element = ContentElement::query()->with('editorialContentKind')->find($id);
|
||||||
|
|
||||||
|
if ($element === null) {
|
||||||
|
return ['public' => false, 'state' => 'missing', 'title' => 'Medium '.$id, 'note' => 'Das Medium gibt es nicht mehr.', 'thumb' => null, 'manageUrl' => null];
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = (string) ($element->display_title ?: $element->working_title);
|
||||||
|
$thumb = ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path);
|
||||||
|
$manageUrl = ContentElementResource::getUrl('view', ['record' => $element]);
|
||||||
|
$public = $this->presentation($id) !== null;
|
||||||
|
|
||||||
|
$note = match (true) {
|
||||||
|
$public => 'Für die Website freigegeben.',
|
||||||
|
$element->archived_at !== null => 'Das Medium ist archiviert.',
|
||||||
|
filled($element->thumbnail_error) => 'Die Datei ließ sich nicht verarbeiten: '.Str::limit((string) $element->thumbnail_error, 120),
|
||||||
|
$element->thumbnail_path === null => 'Wird gerade verarbeitet. Danach wird es automatisch für die Website freigegeben.',
|
||||||
|
default => 'Nicht für die Website freigegeben. Die Freigabe steht im Medienmanager beim Medium unter „Beschreibung“ (Website-Freigabe).',
|
||||||
|
};
|
||||||
|
|
||||||
|
return [
|
||||||
|
'public' => $public,
|
||||||
|
'state' => $public ? 'released' : ($element->thumbnail_path === null && ! filled($element->thumbnail_error) ? 'pending' : 'unreleased'),
|
||||||
|
'title' => $title,
|
||||||
|
'note' => $note,
|
||||||
|
'thumb' => $thumb,
|
||||||
|
'manageUrl' => $manageUrl,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prüft einen Wert beim Speichern. Ein früherer Pfad mit wirksamer Zuordnung wird zur Kennung des Mediums.
|
||||||
|
*/
|
||||||
|
public function clean(mixed $value, WidgetErrors $errors, string $errorKey): int|string|null
|
||||||
|
{
|
||||||
|
$raw = is_array($value) ? (array_values($value)[0] ?? null) : $value;
|
||||||
|
$value = self::normalize($raw);
|
||||||
|
|
||||||
|
if ($value === null) {
|
||||||
|
if ($raw !== null && $raw !== '') {
|
||||||
|
$errors->add($errorKey, 'Bitte ein Bild aus dem Medienmanager wählen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_string($value)) {
|
||||||
|
return $this->elementId($value) ?? $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$element = ContentElement::query()->find($value);
|
||||||
|
|
||||||
|
if ($element === null || ! self::isSelectable($element)) {
|
||||||
|
$errors->add($errorKey, 'Dieses Medium ist kein Bild für die Website (nur Bilder aus dem Medienmanager, keine Traineranleitungen).');
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $element->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isSelectable(ContentElement $element): bool
|
||||||
|
{
|
||||||
|
if ($element->output_class !== 'bild' || $element->archived_at !== null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$slug = $element->editorialContentKind?->slug
|
||||||
|
?? ($element->editorial_content_kind_id !== null ? EditorialContentKind::query()->whereKey($element->editorial_content_kind_id)->value('slug') : null);
|
||||||
|
|
||||||
|
return ! in_array($slug, PublicMaterialReader::CONFIDENTIAL_KINDS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auswahl für den Medienpicker: Bilder aus dem Medienmanager mit Vorschaubild, Titel und Freigabestatus (HTML).
|
||||||
|
*
|
||||||
|
* @return array<int, string>
|
||||||
|
*/
|
||||||
|
public function options(?string $search = null, int $limit = 60): array
|
||||||
|
{
|
||||||
|
$search = trim((string) $search);
|
||||||
|
|
||||||
|
$elements = ContentElement::query()
|
||||||
|
->with('editorialContentKind')
|
||||||
|
->where('output_class', 'bild')
|
||||||
|
->whereNull('archived_at')
|
||||||
|
->when($search !== '', function ($query) use ($search): void {
|
||||||
|
$like = '%'.mb_strtolower($search).'%';
|
||||||
|
$query->where(fn ($inner) => $inner
|
||||||
|
->whereRaw('LOWER(working_title) LIKE ?', [$like])
|
||||||
|
->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like]));
|
||||||
|
})
|
||||||
|
->orderByDesc('id')
|
||||||
|
->limit($limit)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$options = [];
|
||||||
|
foreach ($elements as $element) {
|
||||||
|
if (self::isSelectable($element)) {
|
||||||
|
$options[$element->id] = $this->optionHtml($element->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** HTML-Bezeichnung einer Option oder des gewählten Werts (auch für frühere Pfade). */
|
||||||
|
public function optionHtml(mixed $value): ?string
|
||||||
|
{
|
||||||
|
$status = $this->status($value);
|
||||||
|
|
||||||
|
if ($status === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$badge = match ($status['state']) {
|
||||||
|
'released' => ['ok', 'Website: freigegeben'],
|
||||||
|
'pending' => ['wait', 'Wird verarbeitet'],
|
||||||
|
'legacy' => ['quiet', 'Früheres CMS-Bild'],
|
||||||
|
default => ['warn', 'Website: nicht freigegeben'],
|
||||||
|
};
|
||||||
|
$thumb = $status['thumb'] !== null
|
||||||
|
? '<img src="'.e($status['thumb']).'" alt="" loading="lazy">'
|
||||||
|
: '<span class="luf-media-option-empty" aria-hidden="true"></span>';
|
||||||
|
|
||||||
|
return '<span class="luf-media-option">'.$thumb
|
||||||
|
.'<span class="luf-media-option-text"><strong>'.e($status['title']).'</strong>'
|
||||||
|
.'<span class="luf-media-badge luf-media-badge-'.$badge[0].'">'.e($badge[1]).'</span></span></span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Neues Bild direkt aus dem CMS: Datei in den Eingang legen und über WebsiteIntake als Medium anlegen.
|
||||||
|
* Die Warteschlange leitet das Bild ab und gibt die Ableitung für die Website frei.
|
||||||
|
*/
|
||||||
|
public function accept(TemporaryUploadedFile $file, ?string $alt = null): ?ContentElement
|
||||||
|
{
|
||||||
|
$base = Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)) ?: 'bild';
|
||||||
|
$name = $base.'-'.Str::lower(Str::random(6)).'.'.($file->guessExtension() ?: 'jpg');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$path = $file->storeAs('cms', $name, 'cms_incoming');
|
||||||
|
} catch (Throwable $exception) {
|
||||||
|
report($exception);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! is_string($path) || $path === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$actor = auth('staff')->user();
|
||||||
|
|
||||||
|
return app(WebsiteIntake::class)->acceptImage(
|
||||||
|
$path,
|
||||||
|
Str::title(str_replace(['-', '_'], ' ', $base)),
|
||||||
|
null,
|
||||||
|
filled($alt) ? trim((string) $alt) : null,
|
||||||
|
$actor instanceof User ? $actor : null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||||
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
use Filament\Forms\Components\Repeater;
|
use Filament\Forms\Components\Repeater;
|
||||||
@@ -84,14 +85,14 @@ public function dataRules(): array
|
|||||||
'items.*.title' => ['required', 'string', 'max:120'],
|
'items.*.title' => ['required', 'string', 'max:120'],
|
||||||
'items.*.text' => ['nullable', 'string', 'max:500'],
|
'items.*.text' => ['nullable', 'string', 'max:500'],
|
||||||
'items.*.url' => ['nullable', 'string', 'max:500'],
|
'items.*.url' => ['nullable', 'string', 'max:500'],
|
||||||
'items.*.image' => ['nullable', 'string', 'max:255'],
|
'items.*.image' => ['nullable'],
|
||||||
'items.*._upload' => ['nullable'],
|
'items.*._upload' => ['nullable'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataFields(): array
|
public function dataFields(): array
|
||||||
{
|
{
|
||||||
[$image, $upload] = ImageRefFields::fields('Bild (optional)');
|
[$image, $upload, $status] = ImageRefFields::fields('Bild (optional)');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
Repeater::make('items')
|
Repeater::make('items')
|
||||||
@@ -106,6 +107,7 @@ public function dataFields(): array
|
|||||||
->helperText('Seitenpfad wie /praevention oder eine http(s)-Adresse. Leer lassen für eine Karte ohne Link.'),
|
->helperText('Seitenpfad wie /praevention oder eine http(s)-Adresse. Leer lassen für eine Karte ohne Link.'),
|
||||||
$image,
|
$image,
|
||||||
$upload,
|
$upload,
|
||||||
|
$status,
|
||||||
])
|
])
|
||||||
->minItems(1)
|
->minItems(1)
|
||||||
->maxItems(12)
|
->maxItems(12)
|
||||||
@@ -139,7 +141,9 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
|||||||
|
|
||||||
public function resolve(array $widget, RenderContext $context): array
|
public function resolve(array $widget, RenderContext $context): array
|
||||||
{
|
{
|
||||||
|
$images = app(WebsiteImage::class);
|
||||||
$items = [];
|
$items = [];
|
||||||
|
$notices = [];
|
||||||
|
|
||||||
foreach ($widget['data']['items'] ?? [] as $item) {
|
foreach ($widget['data']['items'] ?? [] as $item) {
|
||||||
if (! is_array($item) || ! filled($item['title'] ?? null)) {
|
if (! is_array($item) || ! filled($item['title'] ?? null)) {
|
||||||
@@ -150,11 +154,15 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
'title' => $item['title'],
|
'title' => $item['title'],
|
||||||
'text' => $item['text'] ?? null,
|
'text' => $item['text'] ?? null,
|
||||||
'url' => SafeUrl::isSafe($item['url'] ?? null) ? $item['url'] : null,
|
'url' => SafeUrl::isSafe($item['url'] ?? null) ? $item['url'] : null,
|
||||||
'imageUrl' => PublicMedia::imageUrl($item),
|
'imageUrl' => $images->url($item['image'] ?? null, $context->preview),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($context->preview && ($notice = $images->previewNotice($item['image'] ?? null, 'Das Bild der Karte „'.$item['title'].'“')) !== null) {
|
||||||
|
$notices[] = $notice;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['items' => $items];
|
return ['items' => $items, 'imageNotice' => $notices === [] ? null : implode(' ', $notices)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mediaPaths(array $widget): array
|
public function mediaPaths(array $widget): array
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
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;
|
||||||
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
use Filament\Forms\Components\Textarea;
|
use Filament\Forms\Components\Textarea;
|
||||||
@@ -202,8 +203,13 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
{
|
{
|
||||||
$actions = PremiumFields::actions($widget['data']);
|
$actions = PremiumFields::actions($widget['data']);
|
||||||
|
|
||||||
|
$images = app(WebsiteImage::class);
|
||||||
|
$image = $widget['refs']['image'] ?? null;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'imageUrl' => PublicMedia::imageUrl($widget['refs']),
|
'imageUrl' => $images->url($image, $context->preview),
|
||||||
|
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
||||||
|
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||||
'actions' => $actions,
|
'actions' => $actions,
|
||||||
'action' => $actions[0] ?? null,
|
'action' => $actions[0] ?? null,
|
||||||
'focus' => PremiumFields::focus($widget['data'], 68, 50),
|
'focus' => PremiumFields::focus($widget['data'], 68, 50),
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
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;
|
||||||
use App\Domain\Cms\Widgets\Support\RichText;
|
use App\Domain\Cms\Widgets\Support\RichText;
|
||||||
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
use Filament\Forms\Components\RichEditor;
|
use Filament\Forms\Components\RichEditor;
|
||||||
@@ -229,8 +230,13 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
{
|
{
|
||||||
$surface = $widget['settings']['surface'] ?? 'cream';
|
$surface = $widget['settings']['surface'] ?? 'cream';
|
||||||
|
|
||||||
|
$images = app(WebsiteImage::class);
|
||||||
|
$image = $widget['refs']['image'] ?? null;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'imageUrl' => PublicMedia::imageUrl($widget['refs']),
|
'imageUrl' => $images->url($image, $context->preview),
|
||||||
|
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
||||||
|
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||||
'body' => RichText::sanitize(is_string($widget['data']['body'] ?? null) ? $widget['data']['body'] : ''),
|
'body' => RichText::sanitize(is_string($widget['data']['body'] ?? null) ? $widget['data']['body'] : ''),
|
||||||
'actions' => PremiumFields::actions($widget['data']),
|
'actions' => PremiumFields::actions($widget['data']),
|
||||||
'focus' => PremiumFields::focus($widget['data'], 64, 43),
|
'focus' => PremiumFields::focus($widget['data'], 64, 43),
|
||||||
|
|||||||
@@ -3,15 +3,16 @@
|
|||||||
namespace App\Domain\Cms\Widgets\Types;
|
namespace App\Domain\Cms\Widgets\Types;
|
||||||
|
|
||||||
use App\Domain\Catalog\ContentElement;
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\PresentationMedia;
|
||||||
use App\Domain\Cms\Catalog\CardSubject;
|
use App\Domain\Cms\Catalog\CardSubject;
|
||||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Medien- und Materialkarte (Kit v1.7 „media“): ein Inhaltselement (Film, Dokument, Hörstück …) mit Anzeigetitel,
|
* Medien- und Materialkarte (Kit v1.7 „media“): ein Inhaltselement mit Anzeigetitel, Kurzbeschreibung, Inhaltsart und
|
||||||
* Kurzbeschreibung, Inhaltsart und Ausgabeart. Öffentlich nur, wenn das Element zur gezeigten Fassung eines
|
* Ausgabeart. Filme erscheinen als Medienkarte (grüne Aktion, Filmtafel ohne freigegebenes Bild), Dokumente und andere
|
||||||
* öffentlichen Programms gehört (PublicMaterialReader); die Aktion führt dann auf diese Programmseite.
|
* Materialien als Materialkarte (Materialsymbol). Öffentlich nur nach den Regeln von PublicMaterialReader; die Aktion
|
||||||
* Die Karte spielt nichts ab, bietet keinen Download und gibt kein geschütztes Medium frei.
|
* führt auf die öffentliche Programmseite. Die Karte spielt nichts ab, bietet keinen Download und gibt kein Medium frei.
|
||||||
*/
|
*/
|
||||||
class MediaCardWidget extends PremiumCardWidget
|
class MediaCardWidget extends PremiumCardWidget
|
||||||
{
|
{
|
||||||
@@ -40,15 +41,6 @@ public function schematic(): array
|
|||||||
return [[2, 2, 56, 32, 'line'], [5, 5, 22, 26, 'image'], [7, 7, 8, 3, 'accent'], [31, 8, 22, 4, 'ink'], [31, 15, 22, 5, 'line'], [31, 25, 14, 5, 'accent']];
|
return [[2, 2, 56, 32, 'line'], [5, 5, 22, 26, 'image'], [7, 7, 8, 3, 'accent'], [31, 8, 22, 4, 'ink'], [31, 15, 22, 5, 'line'], [31, 25, 14, 5, 'accent']];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settings(): array
|
|
||||||
{
|
|
||||||
// Ohne Kurzbeschreibung (nicht öffentlich, siehe PublicMaterialReader) gibt es nichts ein- oder auszublenden.
|
|
||||||
$settings = parent::settings();
|
|
||||||
unset($settings['show_summary']);
|
|
||||||
|
|
||||||
return $settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function refKey(): string
|
protected function refKey(): string
|
||||||
{
|
{
|
||||||
return 'element';
|
return 'element';
|
||||||
@@ -61,7 +53,7 @@ protected function refLabel(): string
|
|||||||
|
|
||||||
protected function refHelp(): string
|
protected function refHelp(): string
|
||||||
{
|
{
|
||||||
return 'Wählbar sind bereitgestellte, nicht archivierte Inhalte. Öffentlich erscheint die Karte nur, wenn der Inhalt zu einem öffentlich gezeigten Programm gehört; sonst nur in der Redaktionsvorschau.';
|
return 'Wählbar sind alle nicht archivierten, nicht gesperrten Filme und Materialien. Öffentlich erscheint die Karte nur mit bereitgestellter Fassung und wenn der Inhalt zu einem öffentlich gezeigten Programm gehört; Traineranleitungen nie. Titel und Kurzbeschreibung pflegen Sie im Medium.';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function searchSubjects(?string $term): array
|
protected function searchSubjects(?string $term): array
|
||||||
@@ -80,7 +72,7 @@ protected function rejectSubject(int $id): ?string
|
|||||||
|
|
||||||
return $element !== null && app(PublicMaterialReader::class)->isSelectable($element)
|
return $element !== null && app(PublicMaterialReader::class)->isSelectable($element)
|
||||||
? null
|
? null
|
||||||
: 'Dieser Inhalt ist nicht bereitgestellt oder archiviert.';
|
: 'Dieser Inhalt ist archiviert oder gesperrt.';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||||
@@ -97,4 +89,13 @@ protected function cardStyle(): string
|
|||||||
{
|
{
|
||||||
return 'media';
|
return 'media';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function centralCoverId(mixed $id): ?int
|
||||||
|
{
|
||||||
|
$element = is_numeric($id) ? ContentElement::query()->find((int) $id) : null;
|
||||||
|
|
||||||
|
return $element instanceof ContentElement
|
||||||
|
? app(PresentationMedia::class)->coverElementId($element)
|
||||||
|
: null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,11 +7,14 @@
|
|||||||
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;
|
||||||
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Schemas\Components\Group;
|
use Filament\Schemas\Components\Group;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gemeinsame Basis der Premium-Karten (Brand-UI-Kit v1.7, Entwurf zur visuellen Freigabe):
|
* Gemeinsame Basis der Premium-Karten (Brand-UI-Kit v1.7, Entwurf zur visuellen Freigabe):
|
||||||
@@ -136,6 +139,8 @@ public function dataRules(): array
|
|||||||
return [
|
return [
|
||||||
'action_label' => ['nullable', 'string', 'max:60'],
|
'action_label' => ['nullable', 'string', 'max:60'],
|
||||||
'note' => ['nullable', 'string', 'max:200'],
|
'note' => ['nullable', 'string', 'max:200'],
|
||||||
|
'heading' => ['nullable', 'string', 'max:200'],
|
||||||
|
'summary' => ['nullable', 'string', 'max:500'],
|
||||||
'alt' => ['nullable', 'string', 'max:300'],
|
'alt' => ['nullable', 'string', 'max:300'],
|
||||||
'focus_x' => ['nullable', 'numeric', 'between:0,100'],
|
'focus_x' => ['nullable', 'numeric', 'between:0,100'],
|
||||||
'focus_y' => ['nullable', 'numeric', 'between:0,100'],
|
'focus_y' => ['nullable', 'numeric', 'between:0,100'],
|
||||||
@@ -177,7 +182,27 @@ public function editorSchema(): array
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
Group::make([$this->subjectField()])->statePath('refs'),
|
Group::make([$this->subjectField()])->statePath('refs'),
|
||||||
Group::make([$action, $note])->statePath('data'),
|
Group::make([
|
||||||
|
$action,
|
||||||
|
$note,
|
||||||
|
// Zentrale Angaben aus der Redaktion als Platzhalter; eine eigene Eintragung ist als solche markiert.
|
||||||
|
TextInput::make('heading')
|
||||||
|
->label('Anzeigename nur für diese Karte')
|
||||||
|
->maxLength(200)
|
||||||
|
->live(onBlur: true)
|
||||||
|
->placeholder(fn (Get $get): string => $this->centralText($get('../refs.'.$this->refKey()), 'title') ?? 'Zentraler Anzeigename')
|
||||||
|
->hint(fn (?string $state): string => filled($state) ? 'Eigene Angabe für diese Karte' : 'Aus der Redaktion')
|
||||||
|
->hintColor(fn (?string $state): string => filled($state) ? 'warning' : 'gray')
|
||||||
|
->helperText('Leer übernimmt den Anzeigenamen des Fachobjekts. Eine Eintragung gilt nur für diese Karte und ändert die Quelle nicht.'),
|
||||||
|
TextInput::make('summary')
|
||||||
|
->label('Teaser nur für diese Karte')
|
||||||
|
->maxLength(500)
|
||||||
|
->live(onBlur: true)
|
||||||
|
->placeholder(fn (Get $get): string => $this->centralText($get('../refs.'.$this->refKey()), 'summary') ?? 'Zentraler Teaser oder Kurzbeschreibung')
|
||||||
|
->hint(fn (?string $state): string => filled($state) ? 'Eigene Angabe für diese Karte' : 'Aus der Redaktion')
|
||||||
|
->hintColor(fn (?string $state): string => filled($state) ? 'warning' : 'gray')
|
||||||
|
->helperText('Leer übernimmt Teaser oder Kurzbeschreibung. Lehrinhalt, Rechte und Preise bleiben unberührt.'),
|
||||||
|
])->statePath('data'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +229,7 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
|||||||
$refs[$key] = $id;
|
$refs[$key] = $id;
|
||||||
$refs = ImageRefFields::clean($refs, $errors);
|
$refs = ImageRefFields::clean($refs, $errors);
|
||||||
|
|
||||||
foreach (['action_label', 'note', 'alt'] as $field) {
|
foreach (['action_label', 'note', 'alt', 'heading', 'summary'] as $field) {
|
||||||
$data[$field] = filled($data[$field] ?? null) ? trim((string) $data[$field]) : null;
|
$data[$field] = filled($data[$field] ?? null) ? trim((string) $data[$field]) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,10 +238,6 @@ public function clean(array $data, array $refs, WidgetErrors $errors): array
|
|||||||
$data[$field] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
$data[$field] = is_numeric($value) ? (int) round(max(0, min(100, (float) $value))) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($refs['image'] !== null && $data['alt'] === null) {
|
|
||||||
$errors->add('data.alt', 'Bitte einen Alternativtext für das Bild angeben.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return [$data, $refs];
|
return [$data, $refs];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,11 +247,23 @@ public function resolve(array $widget, RenderContext $context): array
|
|||||||
$option = fn (string $key, string $default): string => is_string($settings[$key] ?? null) && isset($this->settingOptions()[$key][$settings[$key]]) ? $settings[$key] : $default;
|
$option = fn (string $key, string $default): string => is_string($settings[$key] ?? null) && isset($this->settingOptions()[$key][$settings[$key]]) ? $settings[$key] : $default;
|
||||||
$data = $widget['data'];
|
$data = $widget['data'];
|
||||||
|
|
||||||
|
$subject = $this->subject($widget['refs'][$this->refKey()] ?? null, $context);
|
||||||
|
$heading = filled($data['heading'] ?? null) ? trim((string) $data['heading']) : null;
|
||||||
|
$lead = filled($data['summary'] ?? null) ? trim((string) $data['summary']) : null;
|
||||||
|
|
||||||
|
if ($subject instanceof CardSubject && ($heading !== null || $lead !== null)) {
|
||||||
|
$subject = $subject->withText($heading, $lead);
|
||||||
|
}
|
||||||
|
|
||||||
|
$storedImage = WebsiteImage::normalize($widget['refs']['image'] ?? null);
|
||||||
|
$imageRef = $storedImage ?? $this->centralCoverId($widget['refs'][$this->refKey()] ?? null);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'subject' => $this->subject($widget['refs'][$this->refKey()] ?? null, $context),
|
'subject' => $subject,
|
||||||
'cardStyle' => $this->cardStyle(),
|
'cardStyle' => $subject?->style ?? $this->cardStyle(),
|
||||||
'imageUrl' => PublicMedia::imageUrl($widget['refs']),
|
'imageUrl' => app(WebsiteImage::class)->url($imageRef, $context->preview),
|
||||||
'alt' => is_string($data['alt'] ?? null) ? $data['alt'] : '',
|
'alt' => app(WebsiteImage::class)->alt($imageRef, $data['alt'] ?? null),
|
||||||
|
'imageNotice' => $context->preview ? app(WebsiteImage::class)->previewNotice($imageRef, 'Das Kartenbild') : null,
|
||||||
'focus' => PremiumFields::focus($data, 66, 45),
|
'focus' => PremiumFields::focus($data, 66, 45),
|
||||||
'format' => $option('format', 'landscape'),
|
'format' => $option('format', 'landscape'),
|
||||||
'fit' => $option('fit', 'cover'),
|
'fit' => $option('fit', 'cover'),
|
||||||
@@ -261,6 +294,31 @@ public function summary(array $widget): string
|
|||||||
return $label ?? 'Kein Objekt gewählt';
|
return $label ?? 'Kein Objekt gewählt';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function centralCoverId(mixed $id): ?int
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zentraler Anzeigename oder Teaser des gewählten Objekts (Redaktionsstand) für Platzhalter im Editor.
|
||||||
|
*/
|
||||||
|
private function centralText(mixed $id, string $field): ?string
|
||||||
|
{
|
||||||
|
if (blank($id)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$subject = $this->subject($id, RenderContext::preview());
|
||||||
|
} catch (\Throwable) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$text = $subject?->{$field};
|
||||||
|
|
||||||
|
return is_string($text) && trim($text) !== '' ? Str::limit(trim($text), 120) : null;
|
||||||
|
}
|
||||||
|
|
||||||
private function subjectField(): Select
|
private function subjectField(): Select
|
||||||
{
|
{
|
||||||
return Select::make($this->refKey())
|
return Select::make($this->refKey())
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Domain\Cms\Widgets\Types;
|
namespace App\Domain\Cms\Widgets\Types;
|
||||||
|
|
||||||
use App\Domain\Catalog\Composition;
|
use App\Domain\Catalog\Composition;
|
||||||
|
use App\Domain\Catalog\PresentationMedia;
|
||||||
use App\Domain\Cms\Catalog\CardSubject;
|
use App\Domain\Cms\Catalog\CardSubject;
|
||||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
@@ -61,26 +62,26 @@ protected function refLabel(): string
|
|||||||
|
|
||||||
protected function refHelp(): string
|
protected function refHelp(): string
|
||||||
{
|
{
|
||||||
return 'Nur zur Anzeige freigegebene Programme und Module sind wählbar. Öffentlich erscheinen Programme mit Programmseite; Module nur in der Redaktionsvorschau.';
|
return 'Wählbar sind Programme und Module mit bereitgestellter Fassung. Öffentlich erscheinen nur Programme mit Anzeigefreigabe (mit Programmseite); Module haben keine öffentliche Seite und erscheinen nur in der Redaktionsvorschau.';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function searchSubjects(?string $term): array
|
protected function searchSubjects(?string $term): array
|
||||||
{
|
{
|
||||||
return app(PublicCatalogReader::class)->search($term);
|
return app(PublicCatalogReader::class)->cardSearch($term);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function subjectLabel(mixed $id): ?string
|
protected function subjectLabel(mixed $id): ?string
|
||||||
{
|
{
|
||||||
return app(PublicCatalogReader::class)->labelFor($id);
|
return app(PublicCatalogReader::class)->cardLabelFor($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function rejectSubject(int $id): ?string
|
protected function rejectSubject(int $id): ?string
|
||||||
{
|
{
|
||||||
$composition = Composition::query()->with('editorialContentKind')->find($id);
|
$composition = Composition::query()->with('editorialContentKind')->find($id);
|
||||||
|
|
||||||
return $composition !== null && app(PublicCatalogReader::class)->isSelectable($composition)
|
return $composition !== null && app(PublicCatalogReader::class)->isCardSelectable($composition)
|
||||||
? null
|
? null
|
||||||
: 'Dieses Objekt ist kein zur Anzeige freigegebenes Programm oder Modul.';
|
: 'Dieses Objekt ist kein Programm oder Modul mit bereitgestellter Fassung.';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||||
@@ -97,4 +98,13 @@ protected function cardStyle(): string
|
|||||||
{
|
{
|
||||||
return 'catalog';
|
return 'catalog';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function centralCoverId(mixed $id): ?int
|
||||||
|
{
|
||||||
|
$composition = is_numeric($id) ? Composition::query()->find((int) $id) : null;
|
||||||
|
|
||||||
|
return $composition instanceof Composition
|
||||||
|
? app(PresentationMedia::class)->coverElementId($composition)
|
||||||
|
: null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,9 +7,9 @@
|
|||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Redaktionelle Themenkarte (Kit v1.7 „editorial“): ein veröffentlichtes Thema (Säule) mit Name,
|
* Redaktionelle Themenkarte (Kit v1.7 „editorial“): ein Thema (fachliche Säule) mit Name, Text für die Website und
|
||||||
* öffentlicher Kurzbeschreibung und Verweis auf die Themenseite /themen/{slug}. Ruhige Textaktion mit gelber
|
* Verweis auf die Themenseite /themen/{slug}. Ruhige Textaktion mit gelber Unterstreichung. Wählbar sind alle Säulen;
|
||||||
* Unterstreichung. Ein nicht (mehr) veröffentlichtes Thema erscheint öffentlich nicht.
|
* ein nicht veröffentlichtes Thema erscheint nur in der Redaktionsvorschau, öffentlich nicht.
|
||||||
*/
|
*/
|
||||||
class TopicCardWidget extends PremiumCardWidget
|
class TopicCardWidget extends PremiumCardWidget
|
||||||
{
|
{
|
||||||
@@ -50,7 +50,7 @@ protected function refLabel(): string
|
|||||||
|
|
||||||
protected function refHelp(): string
|
protected function refHelp(): string
|
||||||
{
|
{
|
||||||
return 'Nur veröffentlichte Themen sind wählbar. Name und Kurzbeschreibung pflegen Sie im Thema, nicht hier.';
|
return 'Alle fachlichen Säulen sind wählbar. Öffentlich erscheint die Karte nur, wenn das Thema veröffentlicht ist; Name und Text pflegen Sie unter „Fachliche Säulen“, nicht hier.';
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function searchSubjects(?string $term): array
|
protected function searchSubjects(?string $term): array
|
||||||
@@ -58,11 +58,12 @@ protected function searchSubjects(?string $term): array
|
|||||||
$term = trim((string) $term);
|
$term = trim((string) $term);
|
||||||
|
|
||||||
return Pillar::query()
|
return Pillar::query()
|
||||||
->published()
|
->orderBy('sort_order')
|
||||||
|
->orderBy('name')
|
||||||
->when($term !== '', fn ($query) => $query->whereRaw('LOWER(name) LIKE ?', ['%'.mb_strtolower($term).'%']))
|
->when($term !== '', fn ($query) => $query->whereRaw('LOWER(name) LIKE ?', ['%'.mb_strtolower($term).'%']))
|
||||||
->limit(25)
|
->limit(50)
|
||||||
->get()
|
->get()
|
||||||
->mapWithKeys(fn (Pillar $pillar): array => [$pillar->id => $pillar->name.' · Thema'])
|
->mapWithKeys(fn (Pillar $pillar): array => [$pillar->id => $this->optionLabel($pillar)])
|
||||||
->all();
|
->all();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,39 +71,60 @@ protected function subjectLabel(mixed $id): ?string
|
|||||||
{
|
{
|
||||||
$pillar = is_numeric($id) ? Pillar::query()->find((int) $id) : null;
|
$pillar = is_numeric($id) ? Pillar::query()->find((int) $id) : null;
|
||||||
|
|
||||||
if ($pillar === null) {
|
return $pillar === null ? null : $this->optionLabel($pillar);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $pillar->name.' · Thema'.($pillar->published_at === null ? ' · nicht veröffentlicht' : '');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function rejectSubject(int $id): ?string
|
protected function rejectSubject(int $id): ?string
|
||||||
{
|
{
|
||||||
return Pillar::query()->whereKey($id)->whereNotNull('published_at')->exists()
|
return Pillar::query()->whereKey($id)->exists() ? null : 'Dieses Thema gibt es nicht.';
|
||||||
? null
|
|
||||||
: 'Dieses Thema ist nicht veröffentlicht.';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
protected function subject(mixed $id, RenderContext $context): ?CardSubject
|
||||||
{
|
{
|
||||||
$pillar = is_numeric($id) ? Pillar::query()->find((int) $id) : null;
|
$pillar = is_numeric($id) ? Pillar::query()->find((int) $id) : null;
|
||||||
|
|
||||||
if ($pillar === null || $pillar->published_at === null) {
|
if ($pillar === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$public = self::isPublic($pillar);
|
||||||
|
|
||||||
|
if (! $public && ! $context->preview) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$summary = filled($pillar->public_summary) ? trim((string) $pillar->public_summary) : null;
|
||||||
|
$pages = $pillar->pages()->whereNotNull('published_revision_id')->count();
|
||||||
|
$missing = [];
|
||||||
|
|
||||||
|
if ($summary === null) {
|
||||||
|
$missing[] = 'Kein Text für die Website gepflegt (Fachliche Säulen → Text für die Website).';
|
||||||
|
}
|
||||||
|
|
||||||
return new CardSubject(
|
return new CardSubject(
|
||||||
title: (string) $pillar->name,
|
title: (string) $pillar->name,
|
||||||
summary: filled($pillar->public_summary) ? (string) $pillar->public_summary : null,
|
summary: $summary,
|
||||||
kind: 'Thema',
|
kind: 'Thema',
|
||||||
badge: null,
|
badge: null,
|
||||||
meta: [],
|
meta: $pages > 0 ? [$pages === 1 ? '1 Seite zum Thema' : $pages.' Seiten zum Thema'] : [],
|
||||||
url: $pillar->publicUrl(),
|
url: $public ? $pillar->publicUrl() : null,
|
||||||
public: true,
|
public: $public,
|
||||||
|
notice: $public ? null : 'Nur in der Redaktionsvorschau sichtbar: Das Thema ist nicht veröffentlicht (Fachliche Säulen → Öffentliche Adresse und „Auf der Website veröffentlichen“).',
|
||||||
|
missing: $missing,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Öffentlich ist ein Thema mit Veröffentlichung und öffentlicher Adresse (dieselbe Regel wie /themen). */
|
||||||
|
public static function isPublic(Pillar $pillar): bool
|
||||||
|
{
|
||||||
|
return $pillar->published_at !== null && filled($pillar->slug);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function optionLabel(Pillar $pillar): string
|
||||||
|
{
|
||||||
|
return $pillar->name.' · Thema · '.(self::isPublic($pillar) ? 'veröffentlicht' : 'nicht veröffentlicht, nur Redaktionsvorschau');
|
||||||
|
}
|
||||||
|
|
||||||
protected function defaultActionLabel(): string
|
protected function defaultActionLabel(): string
|
||||||
{
|
{
|
||||||
return 'Thema entdecken';
|
return 'Thema entdecken';
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Legt die technische Ableitung eines Präsentationsmediums an der Medienidentität ab.
|
||||||
|
* Es entsteht keine Inhaltsfassung, keine Freigabe und keine Berechtigung.
|
||||||
|
*/
|
||||||
|
class PresentationFile
|
||||||
|
{
|
||||||
|
public function store(ContentElement $element, string $incoming): void
|
||||||
|
{
|
||||||
|
if (! in_array($element->output_class, ['bild', 'film', 'audio'], true)) {
|
||||||
|
throw new DomainRuleException('Eine Präsentationsdatei ist ein Bild, ein Film oder ein Hörstück.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($element->versions()->exists()) {
|
||||||
|
throw new DomainRuleException('Dieses Medium hat bereits eine Inhaltsfassung. Die Präsentationsdatei ersetzt sie nicht.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->readable($incoming)) {
|
||||||
|
throw new DomainRuleException('Die Datei liegt nicht im Eingang.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$extension = strtolower(pathinfo($incoming, PATHINFO_EXTENSION));
|
||||||
|
$allowed = match ($element->output_class) {
|
||||||
|
'bild' => ['jpg', 'jpeg', 'png', 'webp', 'gif'],
|
||||||
|
'audio' => ['mp3', 'm4a', 'ogg'],
|
||||||
|
default => ['mp4', 'webm'],
|
||||||
|
};
|
||||||
|
|
||||||
|
if (! in_array($extension, $allowed, true)) {
|
||||||
|
throw new DomainRuleException('Diese Datei ist keine freigebbare Ableitung. Es wird keine Inhaltsfassung angelegt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$prefix = $element->output_class === 'bild' ? 'vorschau' : 'teaser';
|
||||||
|
$target = $prefix.'/'.$element->id.'/datei.'.$extension;
|
||||||
|
$stream = Storage::disk('cms_incoming')->readStream($incoming);
|
||||||
|
|
||||||
|
if (! is_resource($stream)) {
|
||||||
|
throw new DomainRuleException('Die Datei ließ sich nicht lesen.');
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Storage::disk('media_derived')->writeStream($target, $stream);
|
||||||
|
} finally {
|
||||||
|
fclose($stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($element->output_class === 'bild') {
|
||||||
|
$element->thumbnail_path = $target;
|
||||||
|
$element->thumbnail_source = 'eigen';
|
||||||
|
} else {
|
||||||
|
$element->preview_path = $target;
|
||||||
|
}
|
||||||
|
|
||||||
|
$element->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function readable(string $path): bool
|
||||||
|
{
|
||||||
|
return (str_starts_with($path, 'inhalte/') || str_starts_with($path, 'cms/') || str_starts_with($path, 'vorschau/'))
|
||||||
|
&& ! str_contains($path, '..')
|
||||||
|
&& preg_match('#^(inhalte|cms|vorschau)/[A-Za-z0-9._\-/]+$#', $path) === 1
|
||||||
|
&& Storage::disk('cms_incoming')->exists($path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,6 +52,18 @@ public function forElementUpload(ContentElement $element, string $incoming): voi
|
|||||||
$this->rememberElement($element, 'eigen');
|
$this->rememberElement($element, 'eigen');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function forWebsiteImage(ContentElement $element, string $incoming): void
|
||||||
|
{
|
||||||
|
if ($element->output_class !== 'bild' || ! $this->incomingIsSafe($incoming)) {
|
||||||
|
$this->fail($element, 'Das Bild für die Website wurde nicht übernommen.');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->still($element, Storage::disk('cms_incoming'), $incoming, 'element-'.$element->id);
|
||||||
|
$this->rememberElement($element, 'eigen');
|
||||||
|
}
|
||||||
|
|
||||||
public function forElementFrame(ContentElement $element, ContentElementVersion $version, float $seconds): void
|
public function forElementFrame(ContentElement $element, ContentElementVersion $version, float $seconds): void
|
||||||
{
|
{
|
||||||
if ($version->content_element_id !== $element->id || $element->output_class !== 'film') {
|
if ($version->content_element_id !== $element->id || $element->output_class !== 'film') {
|
||||||
@@ -201,6 +213,14 @@ private function readableDerived(mixed $path, string $prefix): bool
|
|||||||
return Storage::disk('media_derived')->exists($path);
|
return Storage::disk('media_derived')->exists($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function incomingIsSafe(string $incoming): bool
|
||||||
|
{
|
||||||
|
return (str_starts_with($incoming, 'cms/') || str_starts_with($incoming, 'vorschau/'))
|
||||||
|
&& ! str_contains($incoming, '..')
|
||||||
|
&& preg_match('#^(cms|vorschau)/[A-Za-z0-9._\-/]+$#', $incoming) === 1
|
||||||
|
&& Storage::disk('cms_incoming')->exists($incoming);
|
||||||
|
}
|
||||||
|
|
||||||
private function secondText(float $seconds): string
|
private function secondText(float $seconds): string
|
||||||
{
|
{
|
||||||
$seconds = max(0, min(7200, $seconds));
|
$seconds = max(0, min(7200, $seconds));
|
||||||
@@ -271,9 +291,15 @@ private function still(ContentElement|Composition $subject, Filesystem $disk, st
|
|||||||
|
|
||||||
$width = imagesx($image);
|
$width = imagesx($image);
|
||||||
$height = imagesy($image);
|
$height = imagesy($image);
|
||||||
$targetWidth = 640;
|
// Bilder (Ausgabeart „bild“) dienen auch als Website-Ableitung für Einstieg und Hintergrund. 640 px wären dort
|
||||||
|
// sichtbar unscharf; deshalb bis 2400 px, nie vergrößert. Filmstandbilder und Modulvorschauen bleiben bei 640 px.
|
||||||
|
$targetWidth = $subject instanceof ContentElement && $subject->output_class === 'bild'
|
||||||
|
? max(1, min(2400, $width))
|
||||||
|
: 640;
|
||||||
$targetHeight = (int) max(1, round($height * ($targetWidth / max(1, $width))));
|
$targetHeight = (int) max(1, round($height * ($targetWidth / max(1, $width))));
|
||||||
$canvas = imagecreatetruecolor($targetWidth, $targetHeight);
|
$canvas = imagecreatetruecolor($targetWidth, $targetHeight);
|
||||||
|
// Transparente Flächen (PNG, GIF) werden im JPEG weiß statt schwarz.
|
||||||
|
imagefill($canvas, 0, 0, (int) imagecolorallocate($canvas, 255, 255, 255));
|
||||||
imagecopyresampled($canvas, $image, 0, 0, 0, 0, $targetWidth, $targetHeight, $width, $height);
|
imagecopyresampled($canvas, $image, 0, 0, 0, 0, $targetWidth, $targetHeight, $width, $height);
|
||||||
ob_start();
|
ob_start();
|
||||||
imagejpeg($canvas, null, 82);
|
imagejpeg($canvas, null, 82);
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentService;
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Catalog\IdentityProfile;
|
||||||
|
use App\Jobs\AcceptWebsiteImage;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nimmt ein neues Website-Bild in den Medienmanager auf.
|
||||||
|
* Die Warteschlange erzeugt danach die Ableitung und gibt sie frei.
|
||||||
|
*/
|
||||||
|
class WebsiteIntake
|
||||||
|
{
|
||||||
|
public function acceptImage(
|
||||||
|
string $incomingPath,
|
||||||
|
string $title,
|
||||||
|
?string $credit = null,
|
||||||
|
?string $alt = null,
|
||||||
|
?User $actor = null,
|
||||||
|
): ContentElement {
|
||||||
|
$title = trim($title);
|
||||||
|
|
||||||
|
if ($title === '') {
|
||||||
|
throw new DomainRuleException('Der Titel fehlt.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->incomingIsReadable($incomingPath)) {
|
||||||
|
throw new DomainRuleException('Die Bilddatei liegt nicht im Eingang.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$element = app(ContentService::class)->createElement('bild', 'bild', $title);
|
||||||
|
app(IdentityProfile::class)->fill($element, [
|
||||||
|
'display_title' => $title,
|
||||||
|
'website_credit' => $credit,
|
||||||
|
'website_alt' => $alt,
|
||||||
|
], $actor);
|
||||||
|
AcceptWebsiteImage::dispatch($element->id, $incomingPath, $actor?->id);
|
||||||
|
|
||||||
|
return $element->fresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function incomingIsReadable(string $path): bool
|
||||||
|
{
|
||||||
|
return (str_starts_with($path, 'cms/') || str_starts_with($path, 'vorschau/'))
|
||||||
|
&& ! str_contains($path, '..')
|
||||||
|
&& preg_match('#^(cms|vorschau)/[A-Za-z0-9._\-/]+$#', $path) === 1
|
||||||
|
&& Storage::disk('cms_incoming')->exists($path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lesesicht für Hero, Teaser und Slideshow.
|
||||||
|
* Liefert nur eine freigegebene öffentliche Ableitung, sonst nichts.
|
||||||
|
*/
|
||||||
|
class WebsiteMedia
|
||||||
|
{
|
||||||
|
public function present(ContentElement|int $element): ?WebsitePresentation
|
||||||
|
{
|
||||||
|
$element = $element instanceof ContentElement
|
||||||
|
? $element
|
||||||
|
: ContentElement::query()->find($element);
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement || $element->website_released_at === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = $element->website_public_path;
|
||||||
|
$expected = '#^website/'.$element->id.'/datei\.[a-z0-9]+$#';
|
||||||
|
|
||||||
|
if (! is_string($path) || preg_match($expected, $path) !== 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! Storage::disk('media_public')->exists($path)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = trim((string) ($element->display_title ?: $element->working_title));
|
||||||
|
$alt = trim((string) ($element->website_alt ?? ''));
|
||||||
|
|
||||||
|
return new WebsitePresentation(
|
||||||
|
elementId: $element->id,
|
||||||
|
title: $title,
|
||||||
|
alt: $alt !== '' ? $alt : $title,
|
||||||
|
credit: filled($element->website_credit) ? trim((string) $element->website_credit) : null,
|
||||||
|
kind: match ($element->output_class) {
|
||||||
|
'film' => 'film',
|
||||||
|
'audio' => 'audio',
|
||||||
|
default => 'bild',
|
||||||
|
},
|
||||||
|
url: route('website.media', $element),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Slideshow: freigegebene Medien in der angegebenen Reihenfolge. Nicht freigegebene Einträge entfallen.
|
||||||
|
*
|
||||||
|
* @param list<int|string> $ids
|
||||||
|
* @return list<WebsitePresentation>
|
||||||
|
*/
|
||||||
|
public function presentMany(array $ids): array
|
||||||
|
{
|
||||||
|
$presentations = [];
|
||||||
|
|
||||||
|
foreach ($ids as $id) {
|
||||||
|
if (! is_numeric($id)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$presentation = $this->present((int) $id);
|
||||||
|
|
||||||
|
if ($presentation !== null) {
|
||||||
|
$presentations[] = $presentation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $presentations;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\IdentityChange;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Früherer CMS-Bildpfad (cms/…), der in den Medienmanager übernommen wurde.
|
||||||
|
*
|
||||||
|
* Wirksam ist die Zuordnung erst, wenn das Medium mindestens einmal für die Website freigegeben war. Bis dahin
|
||||||
|
* (Ableitung läuft noch oder ist fehlgeschlagen) bleibt der frühere Pfad gültig, damit keine Seite ihr Bild verliert.
|
||||||
|
* Danach entscheidet allein die Website-Freigabe des Mediums, auch über die frühere Adresse /medien/cms/….
|
||||||
|
*/
|
||||||
|
class WebsiteMediaAlias extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['legacy_path', 'content_element_id', 'sha256'];
|
||||||
|
|
||||||
|
public function element(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(ContentElement::class, 'content_element_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wirksame Zuordnung für einen früheren Pfad, sonst null. Zwischengespeichert wird im Aufrufer (WebsiteImage, je Anfrage).
|
||||||
|
*/
|
||||||
|
public static function effectiveFor(mixed $path): ?self
|
||||||
|
{
|
||||||
|
if (! is_string($path) || $path === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$alias = self::query()->with('element')->where('legacy_path', $path)->first();
|
||||||
|
|
||||||
|
return $alias instanceof self && $alias->everReleased() ? $alias : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function everReleased(): bool
|
||||||
|
{
|
||||||
|
$element = $this->element;
|
||||||
|
|
||||||
|
if ($element === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($element->website_released_at !== null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return IdentityChange::query()
|
||||||
|
->where('subject_type', $element->getMorphClass())
|
||||||
|
->where('subject_id', $element->id)
|
||||||
|
->where('field', 'website_released_at')
|
||||||
|
->whereNotNull('after')
|
||||||
|
->exists();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Öffentliche Ableitung eines für die Website freigegebenen Mediums.
|
||||||
|
* Enthält keine internen Vermerke und keine Adresse einer Bestandsdatei.
|
||||||
|
*/
|
||||||
|
final class WebsitePresentation
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public readonly int $elementId,
|
||||||
|
public readonly string $title,
|
||||||
|
public readonly string $alt,
|
||||||
|
public readonly ?string $credit,
|
||||||
|
public readonly string $kind,
|
||||||
|
public readonly string $url,
|
||||||
|
) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Domain\Media;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentVersionStatus;
|
||||||
|
use App\Domain\Catalog\EditorialContentKind;
|
||||||
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
|
use App\Jobs\PublishWebsiteMedia;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt eine Ableitung für die Website frei oder nimmt sie zurück.
|
||||||
|
* Legt keinen Lizenzartikel an und ruft DecideAccess nicht auf.
|
||||||
|
* Der Web-Prozess schreibt die öffentliche Datei nicht selbst; das tut die Warteschlange.
|
||||||
|
*/
|
||||||
|
class WebsiteRelease
|
||||||
|
{
|
||||||
|
public function release(ContentElement $element, ?User $actor = null): string
|
||||||
|
{
|
||||||
|
$refusal = $this->refusal($element);
|
||||||
|
|
||||||
|
if ($refusal !== null) {
|
||||||
|
return $refusal;
|
||||||
|
}
|
||||||
|
|
||||||
|
PublishWebsiteMedia::dispatch($element->id, 'release', $actor?->id);
|
||||||
|
|
||||||
|
return 'Für die Website freigegeben. Öffentliche Seiten lesen nur diese Ableitung.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function withdraw(ContentElement $element, ?User $actor = null): string
|
||||||
|
{
|
||||||
|
PublishWebsiteMedia::dispatch($element->id, 'withdraw', $actor?->id);
|
||||||
|
|
||||||
|
return 'Die Website-Freigabe ist zurückgenommen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function refusal(ContentElement $element): ?string
|
||||||
|
{
|
||||||
|
if ($this->isConfidential($element)) {
|
||||||
|
return 'Traineranleitungen werden nicht für die Website freigegeben.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->derivedPath($element) === null) {
|
||||||
|
return 'Für die Website fehlt eine freigebbare Ableitung. Beim Bild ist das das Vorschaubild. Film und Hörstück ohne Inhaltsfassung nutzen die Datei am Medium unter teaser/. Ein Film mit Inhaltsfassung nutzt die Teaserfassung seiner bereitgestellten Fassung. Die Originaldatei bleibt geschützt.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function derivedPath(ContentElement $element): ?string
|
||||||
|
{
|
||||||
|
if ($this->isConfidential($element)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($element->output_class === 'bild') {
|
||||||
|
return $this->allowedDerivedPath($element->thumbnail_path, 'vorschau/', ['jpg', 'jpeg', 'png', 'webp', 'gif']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_array($element->output_class, ['film', 'audio'], true)) {
|
||||||
|
$extensions = $element->output_class === 'audio'
|
||||||
|
? ['mp3', 'm4a', 'ogg']
|
||||||
|
: ['mp4', 'webm'];
|
||||||
|
$own = $this->allowedDerivedPath($element->preview_path, 'teaser/', $extensions);
|
||||||
|
|
||||||
|
if ($own !== null) {
|
||||||
|
return $own;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($element->output_class !== 'film') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = $element->versions()
|
||||||
|
->where('status', ContentVersionStatus::Bereit->value)
|
||||||
|
->orderByDesc('number')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($version === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = MediaRendition::query()
|
||||||
|
->where('content_element_version_id', $version->id)
|
||||||
|
->where('role', 'preview')
|
||||||
|
->orderByDesc('id')
|
||||||
|
->value('path');
|
||||||
|
|
||||||
|
return $this->allowedDerivedPath($path, 'teaser/', ['mp4', 'webm']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publicPath(ContentElement $element, string $derivedPath): string
|
||||||
|
{
|
||||||
|
$extension = strtolower(pathinfo($derivedPath, PATHINFO_EXTENSION));
|
||||||
|
|
||||||
|
return 'website/'.$element->id.'/datei.'.$extension;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isConfidential(ContentElement $element): bool
|
||||||
|
{
|
||||||
|
$slug = $element->editorialContentKind?->slug;
|
||||||
|
|
||||||
|
if ($slug === null && $element->editorial_content_kind_id !== null) {
|
||||||
|
$slug = EditorialContentKind::query()->whereKey($element->editorial_content_kind_id)->value('slug');
|
||||||
|
}
|
||||||
|
|
||||||
|
return in_array($slug, PublicMaterialReader::CONFIDENTIAL_KINDS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $extensions
|
||||||
|
*/
|
||||||
|
private function allowedDerivedPath(mixed $path, string $prefix, array $extensions): ?string
|
||||||
|
{
|
||||||
|
if (! is_string($path) || ! str_starts_with($path, $prefix) || str_contains($path, '..')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$extension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
|
||||||
|
|
||||||
|
if (! in_array($extension, $extensions, true)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! Storage::disk('media_derived')->exists($path)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,20 +2,21 @@
|
|||||||
|
|
||||||
namespace App\Filament\Pages;
|
namespace App\Filament\Pages;
|
||||||
|
|
||||||
use App\Domain\Catalog\Composition;
|
|
||||||
use App\Domain\Catalog\CompositionKind;
|
use App\Domain\Catalog\CompositionKind;
|
||||||
use App\Domain\Catalog\ContentVersionStatus;
|
|
||||||
use App\Domain\Catalog\EditorialDimension;
|
|
||||||
use App\Domain\Catalog\IdentityDimensionValue;
|
|
||||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
use App\Filament\Support\EditorialCatalog;
|
use App\Filament\Support\ListsCompositions;
|
||||||
use Filament\Pages\Page;
|
use Filament\Pages\Page;
|
||||||
use Filament\Support\Enums\Width;
|
use Filament\Support\Enums\Width;
|
||||||
use Illuminate\Contracts\Support\Htmlable;
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
use Livewire\Attributes\Url;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Arbeitsplatz: Programme und Module in der gemeinsamen Bestandsliste. Die Listen „Module“ und „Programme“ zeigen
|
||||||
|
* dieselben Zeilen mit festem Typ (ListsCompositions).
|
||||||
|
*/
|
||||||
class EditorialDesk extends Page
|
class EditorialDesk extends Page
|
||||||
{
|
{
|
||||||
|
use ListsCompositions;
|
||||||
|
|
||||||
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte';
|
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte';
|
||||||
|
|
||||||
protected static ?string $navigationLabel = 'Arbeitsplatz';
|
protected static ?string $navigationLabel = 'Arbeitsplatz';
|
||||||
@@ -28,24 +29,6 @@ class EditorialDesk extends Page
|
|||||||
|
|
||||||
protected string $view = 'filament.editorial.desk-page';
|
protected string $view = 'filament.editorial.desk-page';
|
||||||
|
|
||||||
#[Url]
|
|
||||||
public string $query = '';
|
|
||||||
|
|
||||||
#[Url]
|
|
||||||
public string $kindFilter = 'alle';
|
|
||||||
|
|
||||||
#[Url]
|
|
||||||
public string $pillar = '';
|
|
||||||
|
|
||||||
#[Url]
|
|
||||||
public string $visibility = 'alle';
|
|
||||||
|
|
||||||
public string $programName = '';
|
|
||||||
|
|
||||||
public string $moduleName = '';
|
|
||||||
|
|
||||||
public string $feedback = '';
|
|
||||||
|
|
||||||
public function getHeading(): string|Htmlable|null
|
public function getHeading(): string|Htmlable|null
|
||||||
{
|
{
|
||||||
return 'Programme und Module';
|
return 'Programme und Module';
|
||||||
@@ -53,7 +36,7 @@ public function getHeading(): string|Htmlable|null
|
|||||||
|
|
||||||
public function getSubheading(): string|Htmlable|null
|
public function getSubheading(): string|Htmlable|null
|
||||||
{
|
{
|
||||||
return 'Vorhandene Einträge öffnen oder einen neuen anlegen. Technische Kennungen sind dafür nicht nötig.';
|
return 'Vorhandene Einträge öffnen oder einen neuen anlegen. Ein Programm ordnet Module; ein Modul ordnet Medien und Texte.';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMaxContentWidth(): Width|string|null
|
public function getMaxContentWidth(): Width|string|null
|
||||||
@@ -66,185 +49,11 @@ public static function canAccess(): bool
|
|||||||
return ContentElementResource::editor();
|
return ContentElementResource::editor();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function getHeaderActions(): array
|
||||||
* @return list<array{label: string, values: list<array{id: int, label: string}>}>
|
|
||||||
*/
|
|
||||||
public function dimensionFilters(): array
|
|
||||||
{
|
{
|
||||||
$groups = [];
|
return [
|
||||||
|
$this->createCompositionAction(CompositionKind::Uebung),
|
||||||
foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) {
|
$this->createCompositionAction(CompositionKind::Kurs),
|
||||||
$values = [];
|
];
|
||||||
|
|
||||||
foreach ($dimension->values as $value) {
|
|
||||||
$values[] = ['id' => $value->id, 'label' => $value->label];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($values !== []) {
|
|
||||||
$groups[] = ['label' => $dimension->label, 'values' => $values];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function resetFilters(): void
|
|
||||||
{
|
|
||||||
$this->query = '';
|
|
||||||
$this->kindFilter = 'alle';
|
|
||||||
$this->pillar = '';
|
|
||||||
$this->visibility = 'alle';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function hasActiveFilters(): bool
|
|
||||||
{
|
|
||||||
return trim($this->query) !== '' || $this->kindFilter !== 'alle' || $this->pillar !== '' || $this->visibility !== 'alle';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return list<array<string, mixed>>
|
|
||||||
*/
|
|
||||||
public function entries(): array
|
|
||||||
{
|
|
||||||
$query = trim($this->query);
|
|
||||||
$needle = mb_strtolower($query);
|
|
||||||
$catalog = app(EditorialCatalog::class);
|
|
||||||
$offered = $catalog->offeredCompositionIds();
|
|
||||||
$pillarIds = $this->pillar === '' ? null : $this->pillarSubjects((int) $this->pillar);
|
|
||||||
$rows = [];
|
|
||||||
|
|
||||||
$compositions = Composition::query()
|
|
||||||
->whereIn('kind', [CompositionKind::Kurs, CompositionKind::Uebung])
|
|
||||||
->with(['editorialContentKind', 'versions.members.contentElementVersion.element'])
|
|
||||||
->orderBy('designation')
|
|
||||||
->get();
|
|
||||||
|
|
||||||
foreach ($compositions as $composition) {
|
|
||||||
$kind = $composition->kind instanceof CompositionKind
|
|
||||||
? $composition->kind
|
|
||||||
: CompositionKind::from((string) $composition->kind);
|
|
||||||
|
|
||||||
if ($this->kindFilter === 'programm' && $kind !== CompositionKind::Kurs) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->kindFilter === 'modul' && $kind !== CompositionKind::Uebung) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($pillarIds !== null && ! in_array($composition->id, $pillarIds, true)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$stand = $catalog->stand($composition);
|
|
||||||
|
|
||||||
if (! $this->matchesVisibility($stand)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$title = $catalog->compositionTitle($composition);
|
|
||||||
$summary = (string) ($composition->summary ?? '');
|
|
||||||
$haystack = mb_strtolower($title.' '.$composition->designation.' '.$summary.' '.(string) $composition->description);
|
|
||||||
|
|
||||||
if ($needle !== '' && ! str_contains($haystack, $needle)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$cover = $catalog->cover($composition, $this->coverMembers($composition));
|
|
||||||
$rows[] = [
|
|
||||||
'title' => $title,
|
|
||||||
'kind' => $kind->deskLabel(),
|
|
||||||
'tone' => $kind === CompositionKind::Kurs ? 'programm' : 'modul',
|
|
||||||
'summary' => $summary,
|
|
||||||
'url' => EditorialCatalog::editUrl($composition),
|
|
||||||
'image' => $cover['url'],
|
|
||||||
'image_note' => $cover['note'],
|
|
||||||
'chips' => $catalog->statusChips($composition, in_array($composition->id, $offered, true)),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return list<array{target: string}>
|
|
||||||
*/
|
|
||||||
private function coverMembers(Composition $composition): array
|
|
||||||
{
|
|
||||||
$draft = $composition->working_draft;
|
|
||||||
|
|
||||||
if (is_array($draft) && is_array($draft['members'] ?? null) && $draft['members'] !== []) {
|
|
||||||
return $draft['members'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$version = $composition->versions
|
|
||||||
->filter(fn ($item): bool => $item->status === ContentVersionStatus::Bereit)
|
|
||||||
->sortByDesc('number')
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if ($version === null) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$members = [];
|
|
||||||
|
|
||||||
foreach ($version->members as $member) {
|
|
||||||
$target = $member->content_element_version_id
|
|
||||||
? 'element:'.$member->content_element_version_id
|
|
||||||
: 'composition:'.$member->nested_composition_version_id;
|
|
||||||
$members[] = ['target' => $target];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $members;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return list<int>
|
|
||||||
*/
|
|
||||||
private function pillarSubjects(int $valueId): array
|
|
||||||
{
|
|
||||||
return IdentityDimensionValue::query()
|
|
||||||
->where('subject_type', (new Composition)->getMorphClass())
|
|
||||||
->where('editorial_dimension_value_id', $valueId)
|
|
||||||
->pluck('subject_id')
|
|
||||||
->map(fn (mixed $id): int => (int) $id)
|
|
||||||
->all();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array{text: string, number: int|null, released_number: int|null} $stand
|
|
||||||
*/
|
|
||||||
private function matchesVisibility(array $stand): bool
|
|
||||||
{
|
|
||||||
return match ($this->visibility) {
|
|
||||||
'bibliothek' => $stand['released_number'] !== null,
|
|
||||||
'verborgen' => $stand['number'] !== null && $stand['released_number'] === null,
|
|
||||||
'entwurf' => $stand['number'] === null,
|
|
||||||
default => true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createProgram(): void
|
|
||||||
{
|
|
||||||
$this->create(CompositionKind::Kurs, $this->programName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createModule(): void
|
|
||||||
{
|
|
||||||
$this->create(CompositionKind::Uebung, $this->moduleName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function create(CompositionKind $kind, string $name): void
|
|
||||||
{
|
|
||||||
$name = trim($name);
|
|
||||||
|
|
||||||
if ($name === '') {
|
|
||||||
$this->feedback = 'Der Name fehlt.';
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$composition = app(EditorialCatalog::class)->create($name, $kind);
|
|
||||||
$this->redirect(EditorialCatalog::editUrl($composition), navigate: false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,693 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Pages;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Composition;
|
||||||
|
use App\Domain\Catalog\CompositionKind;
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\EditorialContentKind;
|
||||||
|
use App\Domain\Catalog\EditorialDimension;
|
||||||
|
use App\Domain\Catalog\EditorialDimensionValue;
|
||||||
|
use App\Domain\Catalog\EditorialVocabulary;
|
||||||
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
|
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||||
|
use App\Filament\Resources\Pillars\PillarResource;
|
||||||
|
use App\Filament\Support\EditorialCatalog;
|
||||||
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Actions\ActionGroup;
|
||||||
|
use Filament\Forms\Components\Checkbox;
|
||||||
|
use Filament\Forms\Components\CheckboxList;
|
||||||
|
use Filament\Forms\Components\Placeholder;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Pages\Page;
|
||||||
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
|
use Filament\Support\Exceptions\Halt;
|
||||||
|
use Filament\Tables\Columns\TextColumn;
|
||||||
|
use Filament\Tables\Concerns\InteractsWithTable;
|
||||||
|
use Filament\Tables\Contracts\HasTable;
|
||||||
|
use Filament\Tables\Filters\SelectFilter;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\HtmlString;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Livewire\Attributes\Url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redaktionelle Stammdaten (FACH-56 bis FACH-58): fachliche Materialarten und die Werte der Einordnung (Altersbereich
|
||||||
|
* und Zielgruppe, Einsatzbereiche, Verwendungszwecke) zentral pflegen. Bestehende Tabellen, keine Kopien.
|
||||||
|
*
|
||||||
|
* - Bezeichnung pflegbar, Kennung fest; Zuordnungen hängen an der Kennung des Datensatzes und bleiben beim Umbenennen.
|
||||||
|
* - Verwendete Werte werden deaktiviert statt gelöscht; Löschen nur ohne jede Zuordnung.
|
||||||
|
* - Materialarten haben zulässige Objektkontexte; vorhandene Zuordnungen bleiben bei einer Änderung erhalten.
|
||||||
|
* - Säulen werden in der vorhandenen Säulenverwaltung gepflegt (verlinkt), nicht hier.
|
||||||
|
*/
|
||||||
|
class RedaktionelleStammdaten extends Page implements HasTable
|
||||||
|
{
|
||||||
|
use InteractsWithTable;
|
||||||
|
|
||||||
|
protected static string|\UnitEnum|null $navigationGroup = 'Inhalte';
|
||||||
|
|
||||||
|
protected static ?string $navigationLabel = 'Redaktionelle Stammdaten';
|
||||||
|
|
||||||
|
protected static ?int $navigationSort = 6;
|
||||||
|
|
||||||
|
protected static ?string $slug = 'stammdaten';
|
||||||
|
|
||||||
|
protected static ?string $title = 'Redaktionelle Stammdaten';
|
||||||
|
|
||||||
|
protected string $view = 'filament.stammdaten';
|
||||||
|
|
||||||
|
/** Bevorzugte Reihenfolge der Einordnungsgruppen; weitere Dimensionen folgen nach Bezeichnung. */
|
||||||
|
private const DIMENSION_ORDER = ['zielgruppe', 'einsatzbereich', 'verwendungszweck'];
|
||||||
|
|
||||||
|
#[Url(as: 'gruppe', except: 'materialart')]
|
||||||
|
public string $gruppe = 'materialart';
|
||||||
|
|
||||||
|
/** @var array<int, array<string, int>>|null */
|
||||||
|
private ?array $verwendungCache = null;
|
||||||
|
|
||||||
|
public static function canAccess(): bool
|
||||||
|
{
|
||||||
|
return self::darfPflegen();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function darfPflegen(): bool
|
||||||
|
{
|
||||||
|
return ContentElementResource::editor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mount(): void
|
||||||
|
{
|
||||||
|
if (! array_key_exists($this->gruppe, $this->gruppen())) {
|
||||||
|
$this->gruppe = 'materialart';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSubheading(): string|Htmlable|null
|
||||||
|
{
|
||||||
|
return 'Auswahlwerte für Redaktion, Filter und Picker. Bezeichnungen sind änderbar, Zuordnungen bleiben erhalten; verwendete Werte werden deaktiviert statt gelöscht.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMaxContentWidth(): Width|string|null
|
||||||
|
{
|
||||||
|
return Width::Full;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string> Schlüssel => Bezeichnung
|
||||||
|
*/
|
||||||
|
public function gruppen(): array
|
||||||
|
{
|
||||||
|
$gruppen = ['materialart' => 'Fachliche Materialarten'];
|
||||||
|
$dimensionen = EditorialDimension::query()->where('slug', '!=', EditorialDimension::PILLAR_SLUG)->get()
|
||||||
|
->sortBy(fn (EditorialDimension $d): string => sprintf('%02d', array_search($d->slug, self::DIMENSION_ORDER, true) === false ? 99 : array_search($d->slug, self::DIMENSION_ORDER, true)).$d->label);
|
||||||
|
|
||||||
|
foreach ($dimensionen as $dimension) {
|
||||||
|
$gruppen[$dimension->slug] = (string) $dimension->label;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $gruppen;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function zeigeGruppe(string $gruppe): void
|
||||||
|
{
|
||||||
|
if (array_key_exists($gruppe, $this->gruppen())) {
|
||||||
|
$this->gruppe = $gruppe;
|
||||||
|
$this->verwendungCache = null;
|
||||||
|
$this->resetTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saeulenUrl(): string
|
||||||
|
{
|
||||||
|
return PillarResource::getUrl('index');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function istMaterialart(): bool
|
||||||
|
{
|
||||||
|
return $this->gruppe === 'materialart';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function dimension(): ?EditorialDimension
|
||||||
|
{
|
||||||
|
return $this->istMaterialart() ? null : EditorialDimension::query()->where('slug', $this->gruppe)->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
// Tabelle
|
||||||
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public function table(Table $table): Table
|
||||||
|
{
|
||||||
|
$materialart = $this->istMaterialart();
|
||||||
|
|
||||||
|
return $table
|
||||||
|
->query(function (): Builder {
|
||||||
|
if ($this->istMaterialart()) {
|
||||||
|
return EditorialContentKind::query();
|
||||||
|
}
|
||||||
|
|
||||||
|
return EditorialDimensionValue::query()->where('editorial_dimension_id', $this->dimension()?->id ?? 0);
|
||||||
|
})
|
||||||
|
->defaultSort('sort_order')
|
||||||
|
->reorderable('sort_order')
|
||||||
|
->reorderRecordsTriggerAction(fn (Action $action, bool $isReordering): Action => $action
|
||||||
|
->button()
|
||||||
|
->label($isReordering ? 'Sortieren beenden' : 'Per Ziehen sortieren'))
|
||||||
|
->paginated(false)
|
||||||
|
->searchPlaceholder('Bezeichnung oder Kennung')
|
||||||
|
->columns(array_values(array_filter([
|
||||||
|
TextColumn::make('label')
|
||||||
|
->label('Bezeichnung')
|
||||||
|
->searchable(['label', 'slug'])
|
||||||
|
->weight('semibold')
|
||||||
|
->wrap()
|
||||||
|
->description(fn (Model $record): string => 'Kennung: '.$record->slug
|
||||||
|
.($record instanceof EditorialContentKind && $record->isSystem() ? ' · vom System verwendet' : '')),
|
||||||
|
$materialart ? TextColumn::make('contexts')
|
||||||
|
->label('Zulässig für')
|
||||||
|
->state(fn (EditorialContentKind $record): array => array_values(array_map(
|
||||||
|
fn (string $context): string => EditorialContentKind::CONTEXTS[$context] ?? $context,
|
||||||
|
(array) ($record->contexts ?? []),
|
||||||
|
)))
|
||||||
|
->badge()
|
||||||
|
->color('gray')
|
||||||
|
->wrap() : null,
|
||||||
|
TextColumn::make('is_active')
|
||||||
|
->label('Status')
|
||||||
|
->formatStateUsing(fn (bool $state): string => $state ? 'Aktiv' : 'Inaktiv')
|
||||||
|
->badge()
|
||||||
|
->color(fn (bool $state): string => $state ? 'success' : 'gray'),
|
||||||
|
TextColumn::make('verwendung')
|
||||||
|
->label('Verwendung')
|
||||||
|
->state(fn (Model $record): string => $this->verwendungText($record))
|
||||||
|
->wrap()
|
||||||
|
->action($this->verwendungAction()->name('verwendungZeigen')),
|
||||||
|
])))
|
||||||
|
->filters([
|
||||||
|
SelectFilter::make('is_active')
|
||||||
|
->label('Status')
|
||||||
|
->options(['1' => 'Aktiv', '0' => 'Inaktiv']),
|
||||||
|
])
|
||||||
|
->recordActions([
|
||||||
|
Action::make('hoch')
|
||||||
|
->label('Nach oben')
|
||||||
|
->icon('heroicon-m-arrow-up')
|
||||||
|
->iconButton()
|
||||||
|
->color('gray')
|
||||||
|
->authorize(fn (): bool => self::darfPflegen())
|
||||||
|
->disabled(fn (Model $record): bool => $this->nachbar($record, -1) === null)
|
||||||
|
->action(fn (Model $record) => $this->verschiebe($record, -1)),
|
||||||
|
Action::make('runter')
|
||||||
|
->label('Nach unten')
|
||||||
|
->icon('heroicon-m-arrow-down')
|
||||||
|
->iconButton()
|
||||||
|
->color('gray')
|
||||||
|
->authorize(fn (): bool => self::darfPflegen())
|
||||||
|
->disabled(fn (Model $record): bool => $this->nachbar($record, 1) === null)
|
||||||
|
->action(fn (Model $record) => $this->verschiebe($record, 1)),
|
||||||
|
$this->bearbeitenAction(),
|
||||||
|
ActionGroup::make([
|
||||||
|
$this->verwendungAction(),
|
||||||
|
$this->umschaltenAction(),
|
||||||
|
$this->loeschenAction(),
|
||||||
|
])->label('Weitere')->icon('heroicon-m-chevron-down')->button()->size('sm')->color('gray'),
|
||||||
|
])
|
||||||
|
->emptyStateHeading('Noch keine Werte')
|
||||||
|
->emptyStateDescription('Mit „Wert anlegen“ entsteht der erste Wert dieser Gruppe.');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Action::make('anlegen')
|
||||||
|
->label('Wert anlegen')
|
||||||
|
->icon('heroicon-o-plus')
|
||||||
|
->authorize(fn (): bool => self::darfPflegen())
|
||||||
|
->modalHeading(fn (): string => 'Neuer Wert: '.($this->gruppen()[$this->gruppe] ?? ''))
|
||||||
|
->schema(fn (): array => $this->formular(null))
|
||||||
|
->fillForm(fn (): array => ['contexts' => ['medium']])
|
||||||
|
->modalSubmitActionLabel('Anlegen')
|
||||||
|
->action(function (array $data): void {
|
||||||
|
$this->anlegen($data);
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
// Formular, Anlegen, Bearbeiten
|
||||||
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<mixed>
|
||||||
|
*/
|
||||||
|
private function formular(?Model $record): array
|
||||||
|
{
|
||||||
|
$felder = [
|
||||||
|
TextInput::make('label')
|
||||||
|
->label('Bezeichnung')
|
||||||
|
->required()
|
||||||
|
->maxLength(120)
|
||||||
|
->helperText($record !== null
|
||||||
|
? 'Die Kennung „'.$record->slug.'“ bleibt; vorhandene Zuordnungen behalten den Wert und zeigen die neue Bezeichnung.'
|
||||||
|
: 'Die Kennung entsteht aus der Bezeichnung und bleibt danach fest.'),
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($this->istMaterialart()) {
|
||||||
|
$system = $record instanceof EditorialContentKind && $record->isSystem();
|
||||||
|
$felder[] = CheckboxList::make('contexts')
|
||||||
|
->label('Zulässig für')
|
||||||
|
->options(EditorialContentKind::CONTEXTS)
|
||||||
|
->required()
|
||||||
|
->live()
|
||||||
|
->columns(['default' => 2, 'md' => 4])
|
||||||
|
->disabled($system)
|
||||||
|
->dehydrated(! $system)
|
||||||
|
->helperText($system
|
||||||
|
? 'Diese Materialart verwendet das System; ihre Kontexte bleiben fest.'
|
||||||
|
: 'Nur hier wird die Materialart neu angeboten. Programm und Modul gehören zu den Objektarten Programm und Modul, nicht zu Medien.');
|
||||||
|
|
||||||
|
if ($record instanceof EditorialContentKind) {
|
||||||
|
$felder[] = Placeholder::make('konflikt')
|
||||||
|
->label('Bestehende Zuordnungen')
|
||||||
|
->visible(fn (Get $get): bool => $this->kontextKonflikte($record, (array) $get('contexts')) !== [])
|
||||||
|
->content(fn (Get $get): HtmlString => new HtmlString('<span style="color: #9a5b00">'
|
||||||
|
.e(implode(' ', $this->kontextKonflikte($record, (array) $get('contexts'))))
|
||||||
|
.' Diese Zuordnungen bleiben erhalten und werden dort als „hier nicht vorgesehen“ gekennzeichnet; neu wählbar ist die Materialart dort nicht mehr.</span>'));
|
||||||
|
$felder[] = Checkbox::make('konflikt_bestaetigt')
|
||||||
|
->label('Ich habe die bestehenden Zuordnungen geprüft.')
|
||||||
|
->accepted()
|
||||||
|
->visible(fn (Get $get): bool => $this->kontextKonflikte($record, (array) $get('contexts')) !== []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $felder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string> Meldungen je entferntem Kontext mit Verwendung
|
||||||
|
*/
|
||||||
|
private function kontextKonflikte(EditorialContentKind $kind, array $neu): array
|
||||||
|
{
|
||||||
|
$verwendung = $this->verwendung($kind);
|
||||||
|
$meldungen = [];
|
||||||
|
$zeilen = null;
|
||||||
|
|
||||||
|
foreach ((array) ($kind->contexts ?? []) as $context) {
|
||||||
|
if (! in_array($context, $neu, true) && ($verwendung[$context] ?? 0) > 0) {
|
||||||
|
$zeilen ??= $this->verwendungListe($kind)['zeilen'];
|
||||||
|
$titel = array_slice(array_column(array_filter($zeilen, fn (array $z): bool => $z['art'] === (EditorialContentKind::CONTEXTS[$context] ?? '')), 'titel'), 0, 5);
|
||||||
|
$meldungen[] = (EditorialContentKind::CONTEXTS[$context] ?? $context).': '.$verwendung[$context].' '.($verwendung[$context] === 1 ? 'Zuordnung' : 'Zuordnungen')
|
||||||
|
.($titel !== [] ? ' („'.implode('“, „', $titel).'“'.($verwendung[$context] > count($titel) ? ' und weitere' : '').')' : '').'.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $meldungen;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function bearbeitenAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('bearbeiten')
|
||||||
|
->label('Bearbeiten')
|
||||||
|
->icon('heroicon-o-pencil-square')
|
||||||
|
->button()
|
||||||
|
->size('sm')
|
||||||
|
->color('gray')
|
||||||
|
->authorize(fn (): bool => self::darfPflegen())
|
||||||
|
->modalHeading(fn (Model $record): string => '„'.$record->label.'“ bearbeiten')
|
||||||
|
->schema(fn (Model $record): array => $this->formular($record))
|
||||||
|
->fillForm(fn (Model $record): array => [
|
||||||
|
'label' => $record->label,
|
||||||
|
'contexts' => $record instanceof EditorialContentKind ? (array) ($record->contexts ?? []) : [],
|
||||||
|
])
|
||||||
|
->modalSubmitActionLabel('Speichern')
|
||||||
|
->action(function (Model $record, array $data): void {
|
||||||
|
$label = trim((string) $data['label']);
|
||||||
|
$this->pruefeBezeichnung($label, $record);
|
||||||
|
$record->label = $label;
|
||||||
|
|
||||||
|
if ($record instanceof EditorialContentKind && ! $record->isSystem() && isset($data['contexts'])) {
|
||||||
|
$record->contexts = $this->kontexte((array) $data['contexts']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$record->save();
|
||||||
|
Notification::make()->success()->title('Gespeichert')->body('Die neue Bezeichnung gilt sofort in Redaktion, Filtern und Picker.')->send();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function anlegen(array $data): void
|
||||||
|
{
|
||||||
|
$label = trim((string) $data['label']);
|
||||||
|
$this->pruefeBezeichnung($label, null);
|
||||||
|
|
||||||
|
if ($this->istMaterialart()) {
|
||||||
|
EditorialContentKind::query()->create([
|
||||||
|
'label' => $label,
|
||||||
|
'slug' => $this->freieKennung($label, EditorialContentKind::query()),
|
||||||
|
'sort_order' => (int) EditorialContentKind::query()->max('sort_order') + 10,
|
||||||
|
'is_active' => true,
|
||||||
|
'contexts' => $this->kontexte((array) ($data['contexts'] ?? [])),
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$dimension = $this->dimension();
|
||||||
|
abort_if($dimension === null, 404);
|
||||||
|
$werte = EditorialDimensionValue::query()->where('editorial_dimension_id', $dimension->id);
|
||||||
|
EditorialDimensionValue::query()->create([
|
||||||
|
'editorial_dimension_id' => $dimension->id,
|
||||||
|
'label' => $label,
|
||||||
|
'slug' => $this->freieKennung($label, clone $werte),
|
||||||
|
'sort_order' => (int) (clone $werte)->max('sort_order') + 10,
|
||||||
|
'is_active' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->verwendungCache = null;
|
||||||
|
Notification::make()->success()->title('Angelegt: „'.$label.'“')->body('Der Wert ist sofort in der passenden Redaktion wählbar.')->send();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function pruefeBezeichnung(string $label, ?Model $ausser): void
|
||||||
|
{
|
||||||
|
$query = $this->istMaterialart()
|
||||||
|
? EditorialContentKind::query()
|
||||||
|
: EditorialDimensionValue::query()->where('editorial_dimension_id', $this->dimension()?->id ?? 0);
|
||||||
|
|
||||||
|
$doppelt = $query->whereRaw('LOWER(label) = ?', [mb_strtolower($label)])
|
||||||
|
->when($ausser !== null, fn (Builder $q) => $q->whereKeyNot($ausser->getKey()))
|
||||||
|
->exists();
|
||||||
|
|
||||||
|
if ($label === '' || $doppelt) {
|
||||||
|
Notification::make()->danger()->title($label === '' ? 'Die Bezeichnung fehlt.' : 'Diese Bezeichnung gibt es in der Gruppe schon.')->send();
|
||||||
|
throw new Halt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function kontexte(array $kontexte): array
|
||||||
|
{
|
||||||
|
$erlaubt = array_keys(EditorialContentKind::CONTEXTS);
|
||||||
|
|
||||||
|
return array_values(array_filter($erlaubt, fn (string $context): bool => in_array($context, $kontexte, true)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function freieKennung(string $label, Builder $query): string
|
||||||
|
{
|
||||||
|
$basis = Str::slug($label) ?: 'wert';
|
||||||
|
$kennung = $basis;
|
||||||
|
$nummer = 2;
|
||||||
|
|
||||||
|
while ((clone $query)->where('slug', $kennung)->exists()) {
|
||||||
|
$kennung = $basis.'-'.$nummer++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $kennung;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
// Aktiv, Löschen, Reihenfolge
|
||||||
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
private function umschaltenAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('umschalten')
|
||||||
|
->label(fn (Model $record): string => $record->is_active ? 'Deaktivieren' : 'Reaktivieren')
|
||||||
|
->icon(fn (Model $record): string => $record->is_active ? 'heroicon-o-eye-slash' : 'heroicon-o-eye')
|
||||||
|
->authorize(fn (): bool => self::darfPflegen())
|
||||||
|
->hidden(fn (Model $record): bool => $record instanceof EditorialContentKind && $record->isSystem())
|
||||||
|
->requiresConfirmation()
|
||||||
|
->modalHeading(fn (Model $record): string => '„'.$record->label.'“ '.($record->is_active ? 'deaktivieren?' : 'reaktivieren?'))
|
||||||
|
->modalDescription(fn (Model $record): string => $record->is_active
|
||||||
|
? 'Der Wert wird für neue Zuordnungen nicht mehr angeboten. '.$this->verwendungSatz($record).' Filter finden diese Objekte weiterhin.'
|
||||||
|
: 'Der Wert wird wieder für neue Zuordnungen angeboten.')
|
||||||
|
->modalSubmitActionLabel(fn (Model $record): string => $record->is_active ? 'Deaktivieren' : 'Reaktivieren')
|
||||||
|
->action(function (Model $record): void {
|
||||||
|
abort_if($record instanceof EditorialContentKind && $record->isSystem(), 403);
|
||||||
|
$record->is_active = ! $record->is_active;
|
||||||
|
$record->save();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function loeschenAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('loeschen')
|
||||||
|
->label('Löschen')
|
||||||
|
->icon('heroicon-o-trash')
|
||||||
|
->color('danger')
|
||||||
|
->authorize(fn (): bool => self::darfPflegen())
|
||||||
|
->visible(fn (Model $record): bool => $this->loeschbar($record))
|
||||||
|
->requiresConfirmation()
|
||||||
|
->modalHeading(fn (Model $record): string => '„'.$record->label.'“ löschen?')
|
||||||
|
->modalDescription('Der Wert ist nirgends zugeordnet und wird endgültig entfernt.')
|
||||||
|
->modalSubmitActionLabel('Löschen')
|
||||||
|
->action(function (Model $record): void {
|
||||||
|
// Erneut prüfen: Zwischenzeitlich entstandene Zuordnungen würden die Datenbank sonst still lösen.
|
||||||
|
if (! $this->loeschbar($record)) {
|
||||||
|
Notification::make()->danger()->title('Nicht gelöscht: Der Wert ist inzwischen zugeordnet. Deaktivieren Sie ihn stattdessen.')->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$record->delete();
|
||||||
|
$this->verwendungCache = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function loeschbar(Model $record): bool
|
||||||
|
{
|
||||||
|
if ($record instanceof EditorialContentKind && $record->isSystem()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_sum($this->verwendung($record, frisch: true)) === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function nachbar(Model $record, int $richtung): ?Model
|
||||||
|
{
|
||||||
|
$liste = $this->geordnet();
|
||||||
|
$index = $liste->search(fn (Model $m): bool => $m->is($record));
|
||||||
|
|
||||||
|
return $index === false ? null : $liste->get($index + $richtung);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function verschiebe(Model $record, int $richtung): void
|
||||||
|
{
|
||||||
|
$liste = $this->geordnet()->values();
|
||||||
|
$index = $liste->search(fn (Model $m): bool => $m->is($record));
|
||||||
|
|
||||||
|
if ($index === false || $liste->get($index + $richtung) === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nachbar = $liste->get($index + $richtung);
|
||||||
|
|
||||||
|
// Nur die beiden Einträge tauschen; neu nummeriert wird nur bei gleicher Reihenfolgezahl.
|
||||||
|
if ((int) $record->sort_order !== (int) $nachbar->sort_order) {
|
||||||
|
DB::transaction(function () use ($record, $nachbar): void {
|
||||||
|
[$a, $b] = [(int) $record->sort_order, (int) $nachbar->sort_order];
|
||||||
|
$record->sort_order = $b;
|
||||||
|
$record->save();
|
||||||
|
$nachbar->sort_order = $a;
|
||||||
|
$nachbar->save();
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$neu = $liste->all();
|
||||||
|
[$neu[$index], $neu[$index + $richtung]] = [$neu[$index + $richtung], $neu[$index]];
|
||||||
|
|
||||||
|
DB::transaction(function () use ($neu): void {
|
||||||
|
foreach (array_values($neu) as $position => $eintrag) {
|
||||||
|
if ((int) $eintrag->sort_order !== ($position + 1) * 10) {
|
||||||
|
$eintrag->sort_order = ($position + 1) * 10;
|
||||||
|
$eintrag->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Collection<int, Model>
|
||||||
|
*/
|
||||||
|
private function geordnet(): Collection
|
||||||
|
{
|
||||||
|
$query = $this->istMaterialart()
|
||||||
|
? EditorialContentKind::query()
|
||||||
|
: EditorialDimensionValue::query()->where('editorial_dimension_id', $this->dimension()?->id ?? 0);
|
||||||
|
|
||||||
|
return $query->orderBy('sort_order')->orderBy('id')->get()->values();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
// Verwendung
|
||||||
|
// ---------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zuordnungen je Objektkontext.
|
||||||
|
*
|
||||||
|
* @return array<string, int>
|
||||||
|
*/
|
||||||
|
public function verwendung(Model $record, bool $frisch = false): array
|
||||||
|
{
|
||||||
|
if ($frisch || $this->verwendungCache === null) {
|
||||||
|
$this->verwendungCache = $this->istMaterialart() ? $this->materialartVerwendung() : $this->einordnungVerwendung();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->verwendungCache[(int) $record->getKey()] ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function verwendungText(Model $record): string
|
||||||
|
{
|
||||||
|
$teile = [];
|
||||||
|
|
||||||
|
foreach ($this->verwendung($record) as $context => $anzahl) {
|
||||||
|
if ($anzahl > 0) {
|
||||||
|
$teile[] = $anzahl.' '.$this->einheit($context, $anzahl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $teile === [] ? 'Nicht verwendet' : implode(' · ', $teile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function verwendungSatz(Model $record): string
|
||||||
|
{
|
||||||
|
$text = $this->verwendungText($record);
|
||||||
|
|
||||||
|
return $text === 'Nicht verwendet'
|
||||||
|
? 'Er ist derzeit nirgends zugeordnet.'
|
||||||
|
: 'Bestehende Zuordnungen ('.$text.') bleiben erhalten und sichtbar.';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function einheit(string $context, int $anzahl): string
|
||||||
|
{
|
||||||
|
return match ($context) {
|
||||||
|
'medium' => $anzahl === 1 ? 'Medium' : 'Medien',
|
||||||
|
'modul' => $anzahl === 1 ? 'Modul' : 'Module',
|
||||||
|
'programm' => $anzahl === 1 ? 'Programm' : 'Programme',
|
||||||
|
'lizenzartikel' => 'Lizenzartikel',
|
||||||
|
default => $anzahl === 1 ? 'Kombination' : 'Kombinationen',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array<string, int>>
|
||||||
|
*/
|
||||||
|
private function materialartVerwendung(): array
|
||||||
|
{
|
||||||
|
$ergebnis = [];
|
||||||
|
|
||||||
|
foreach (DB::table('content_elements')->whereNotNull('editorial_content_kind_id')->groupBy('editorial_content_kind_id')->selectRaw('editorial_content_kind_id as id, count(*) as anzahl')->get() as $zeile) {
|
||||||
|
$ergebnis[(int) $zeile->id]['medium'] = (int) $zeile->anzahl;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (DB::table('compositions')->whereNotNull('editorial_content_kind_id')->groupBy('editorial_content_kind_id', 'kind')->selectRaw('editorial_content_kind_id as id, kind, count(*) as anzahl')->get() as $zeile) {
|
||||||
|
$context = EditorialVocabulary::compositionContext(CompositionKind::tryFrom((string) $zeile->kind)) ?? 'kombination';
|
||||||
|
$ergebnis[(int) $zeile->id][$context] = ($ergebnis[(int) $zeile->id][$context] ?? 0) + (int) $zeile->anzahl;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (DB::table('license_articles')->whereNotNull('editorial_content_kind_id')->groupBy('editorial_content_kind_id')->selectRaw('editorial_content_kind_id as id, count(*) as anzahl')->get() as $zeile) {
|
||||||
|
$ergebnis[(int) $zeile->id]['lizenzartikel'] = (int) $zeile->anzahl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ergebnis;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, array<string, int>>
|
||||||
|
*/
|
||||||
|
private function einordnungVerwendung(): array
|
||||||
|
{
|
||||||
|
$ergebnis = [];
|
||||||
|
$zeilen = DB::table('identity_dimension_values')
|
||||||
|
->leftJoin('compositions', function ($join): void {
|
||||||
|
$join->on('compositions.id', '=', 'identity_dimension_values.subject_id')
|
||||||
|
->where('identity_dimension_values.subject_type', (new Composition)->getMorphClass());
|
||||||
|
})
|
||||||
|
->groupBy('identity_dimension_values.editorial_dimension_value_id', 'identity_dimension_values.subject_type', 'compositions.kind')
|
||||||
|
->selectRaw('identity_dimension_values.editorial_dimension_value_id as id, identity_dimension_values.subject_type as typ, compositions.kind as kind, count(*) as anzahl')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($zeilen as $zeile) {
|
||||||
|
$context = match ($zeile->typ) {
|
||||||
|
(new ContentElement)->getMorphClass() => 'medium',
|
||||||
|
(new LicenseArticle)->getMorphClass() => 'lizenzartikel',
|
||||||
|
default => EditorialVocabulary::compositionContext(CompositionKind::tryFrom((string) $zeile->kind)) ?? 'kombination',
|
||||||
|
};
|
||||||
|
$ergebnis[(int) $zeile->id][$context] = ($ergebnis[(int) $zeile->id][$context] ?? 0) + (int) $zeile->anzahl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ergebnis;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function verwendungAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('verwendung')
|
||||||
|
->label('Verwendung')
|
||||||
|
->icon('heroicon-m-list-bullet')
|
||||||
|
->authorize(fn (): bool => self::darfPflegen())
|
||||||
|
->modalHeading(fn (Model $record): string => 'Verwendung von „'.$record->label.'“')
|
||||||
|
->modalContent(fn (Model $record) => view('filament.stammdaten-verwendung', $this->verwendungListe($record)))
|
||||||
|
->modalSubmitAction(false)
|
||||||
|
->modalCancelActionLabel('Schließen');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zugeordnete Objekte mit Links in ihre Bearbeitung und gefilterte Bestandslisten.
|
||||||
|
*
|
||||||
|
* @return array{zeilen: list<array{art: string, titel: string, url: string}>, mehr: int, filter: list<array{label: string, url: string}>}
|
||||||
|
*/
|
||||||
|
public function verwendungListe(Model $record): array
|
||||||
|
{
|
||||||
|
$grenze = 40;
|
||||||
|
$zeilen = [];
|
||||||
|
$filter = [];
|
||||||
|
|
||||||
|
if ($record instanceof EditorialContentKind) {
|
||||||
|
$medien = ContentElement::query()->where('editorial_content_kind_id', $record->id);
|
||||||
|
$kompositionen = Composition::query()->where('editorial_content_kind_id', $record->id);
|
||||||
|
$artikel = LicenseArticle::query()->where('editorial_content_kind_id', $record->id);
|
||||||
|
if ((clone $medien)->exists()) {
|
||||||
|
$filter[] = ['label' => 'Im Medienmanager filtern', 'url' => ContentElementResource::getUrl('index', ['inhaltsart' => $record->id])];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$zuordnung = fn (string $klasse) => DB::table('identity_dimension_values')
|
||||||
|
->where('editorial_dimension_value_id', $record->getKey())
|
||||||
|
->where('subject_type', (new $klasse)->getMorphClass())
|
||||||
|
->pluck('subject_id');
|
||||||
|
$medien = ContentElement::query()->whereKey($zuordnung(ContentElement::class));
|
||||||
|
$kompositionen = Composition::query()->whereKey($zuordnung(Composition::class));
|
||||||
|
$artikel = LicenseArticle::query()->whereKey($zuordnung(LicenseArticle::class));
|
||||||
|
if ((clone $medien)->exists()) {
|
||||||
|
$filter[] = ['label' => 'Im Medienmanager filtern', 'url' => ContentElementResource::getUrl('index', ['einordnung' => $record->getKey()])];
|
||||||
|
}
|
||||||
|
if ((clone $kompositionen)->exists()) {
|
||||||
|
$filter[] = ['label' => 'Programme und Module filtern', 'url' => EditorialDesk::getUrl(['pillar' => $record->getKey()])];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$gesamt = (clone $medien)->count() + (clone $kompositionen)->count() + (clone $artikel)->count();
|
||||||
|
|
||||||
|
foreach ($medien->orderBy('working_title')->limit($grenze)->get() as $element) {
|
||||||
|
$zeilen[] = ['art' => 'Medium', 'titel' => (string) ($element->display_title ?: $element->working_title), 'url' => ContentElementResource::getUrl('view', ['record' => $element])];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($kompositionen->orderBy('designation')->limit($grenze)->get() as $composition) {
|
||||||
|
$context = EditorialVocabulary::compositionContext($composition->kind instanceof CompositionKind ? $composition->kind : CompositionKind::tryFrom((string) $composition->kind));
|
||||||
|
$zeilen[] = ['art' => EditorialContentKind::CONTEXTS[$context ?? ''] ?? 'Kombination', 'titel' => (string) ($composition->display_title ?: $composition->designation), 'url' => EditorialCatalog::editUrl($composition)];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($artikel->orderBy('code')->limit($grenze)->get() as $article) {
|
||||||
|
$zeilen[] = ['art' => 'Lizenzartikel', 'titel' => trim($article->code.' '.($article->display_title ?: $article->working_title)), 'url' => LicenseArticleResource::getUrl('view', ['record' => $article])];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['zeilen' => $zeilen, 'mehr' => max(0, $gesamt - count($zeilen)), 'filter' => $filter];
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -2,8 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Bundles\Pages;
|
namespace App\Filament\Resources\Bundles\Pages;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Bundle;
|
||||||
use App\Domain\Catalog\BundleService;
|
use App\Domain\Catalog\BundleService;
|
||||||
|
use App\Domain\Catalog\BundleStatus;
|
||||||
|
use App\Domain\Catalog\StatusValue;
|
||||||
use App\Filament\Resources\Bundles\BundleResource;
|
use App\Filament\Resources\Bundles\BundleResource;
|
||||||
|
use App\Filament\Support\ListsCatalog;
|
||||||
use App\Filament\Support\ReportsDomainRules;
|
use App\Filament\Support\ReportsDomainRules;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
@@ -12,6 +16,7 @@
|
|||||||
|
|
||||||
class ListBundles extends ListRecords
|
class ListBundles extends ListRecords
|
||||||
{
|
{
|
||||||
|
use ListsCatalog;
|
||||||
use ReportsDomainRules;
|
use ReportsDomainRules;
|
||||||
|
|
||||||
protected static string $resource = BundleResource::class;
|
protected static string $resource = BundleResource::class;
|
||||||
@@ -24,13 +29,83 @@ public function getSubheading(): string|Htmlable|null
|
|||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Action::make('create')->label('Paket anlegen')->schema([
|
Action::make('create')->label('Paket anlegen')
|
||||||
TextInput::make('name')->label('Name')->required(),
|
->modalHeading('Neues Paket')
|
||||||
])->action(function (array $data): void {
|
->modalDescription('Der Name genügt. Bestandteile stellst du danach am Paket zusammen.')
|
||||||
$this->report(function () use ($data): void {
|
->modalSubmitActionLabel('Paket anlegen')
|
||||||
app(BundleService::class)->create($data['name']);
|
->schema([
|
||||||
}, 'Das Paket ist angelegt.');
|
TextInput::make('name')->label('Name')->required(),
|
||||||
}),
|
])->action(function (array $data): void {
|
||||||
|
$bundle = null;
|
||||||
|
$this->report(function () use ($data, &$bundle): void {
|
||||||
|
$bundle = app(BundleService::class)->create($data['name']);
|
||||||
|
}, 'Das Paket ist angelegt.');
|
||||||
|
|
||||||
|
if ($bundle instanceof Bundle) {
|
||||||
|
$this->redirect(BundleResource::getUrl('view', ['record' => $bundle]));
|
||||||
|
}
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function catalogRows(): array
|
||||||
|
{
|
||||||
|
$rows = [];
|
||||||
|
|
||||||
|
foreach (Bundle::query()->with(['versions.items'])->orderBy('name')->get() as $bundle) {
|
||||||
|
$versions = $bundle->versions->sortByDesc('number');
|
||||||
|
$published = $versions->first(fn ($version): bool => StatusValue::of($version->status) === BundleStatus::Veroeffentlicht->value);
|
||||||
|
$draft = $versions->first(fn ($version): bool => StatusValue::of($version->status) === BundleStatus::Entwurf->value);
|
||||||
|
$chips = [];
|
||||||
|
$zustand = [];
|
||||||
|
|
||||||
|
if ($published !== null) {
|
||||||
|
$chips[] = ['label' => 'Fassung '.$published->number.' veröffentlicht', 'ton' => 'gut'];
|
||||||
|
$chips[] = ['label' => $published->items->count() === 1 ? '1 Bestandteil' : $published->items->count().' Bestandteile', 'ton' => 'leise'];
|
||||||
|
$zustand[] = 'veroeffentlicht';
|
||||||
|
} else {
|
||||||
|
$chips[] = ['label' => $versions->isEmpty() ? 'Noch keine Fassung' : 'Noch nicht veröffentlicht', 'ton' => 'offen'];
|
||||||
|
$zustand[] = 'ohne';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($draft !== null) {
|
||||||
|
$chips[] = ['label' => 'Fassung '.$draft->number.' in Arbeit', 'ton' => 'offen'];
|
||||||
|
$zustand[] = 'entwurf';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($bundle->archived_at !== null) {
|
||||||
|
$chips[] = ['label' => 'Archiviert', 'ton' => 'leise'];
|
||||||
|
$zustand[] = 'archiviert';
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = BundleResource::getUrl('view', ['record' => $bundle]);
|
||||||
|
$rows[] = [
|
||||||
|
'schluessel' => 'p'.$bundle->id,
|
||||||
|
'titel' => $bundle->name,
|
||||||
|
'meta' => 'Paket',
|
||||||
|
'symbol' => 'modul',
|
||||||
|
'url' => $url,
|
||||||
|
'chips' => $chips,
|
||||||
|
'zustand' => $zustand,
|
||||||
|
'aktionen' => [['label' => 'Öffnen', 'href' => $url]],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function zustandOptionen(): array
|
||||||
|
{
|
||||||
|
return ['alle' => 'Jeder Zustand', 'veroeffentlicht' => 'Veröffentlicht', 'ohne' => 'Noch nicht veröffentlicht', 'entwurf' => 'Fassung in Arbeit', 'archiviert' => 'Archiviert'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function einheit(): array
|
||||||
|
{
|
||||||
|
return ['Paket', 'Pakete'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function leer(): array
|
||||||
|
{
|
||||||
|
return ['titel' => 'Noch keine Pakete', 'text' => 'Mit „Paket anlegen“ oben entsteht das erste Paket.'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -4,54 +4,194 @@
|
|||||||
|
|
||||||
use App\Domain\Catalog\Bundle;
|
use App\Domain\Catalog\Bundle;
|
||||||
use App\Domain\Catalog\BundleService;
|
use App\Domain\Catalog\BundleService;
|
||||||
|
use App\Domain\Catalog\BundleStatus;
|
||||||
|
use App\Domain\Catalog\BundleVersion;
|
||||||
use App\Domain\Catalog\LicenseArticle;
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
|
use App\Domain\Catalog\StatusValue;
|
||||||
use App\Filament\Resources\Bundles\BundleResource;
|
use App\Filament\Resources\Bundles\BundleResource;
|
||||||
use App\Filament\Support\CatalogOptions;
|
use App\Filament\Support\CatalogOptions;
|
||||||
|
use App\Filament\Support\CatalogReading;
|
||||||
use App\Filament\Support\ReportsDomainRules;
|
use App\Filament\Support\ReportsDomainRules;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\CheckboxList;
|
use Filament\Forms\Components\CheckboxList;
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
use Filament\Schemas\Components\View;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paket in der gemeinsamen Katalog-Objektseite. Erste und geänderte Fassung nutzen dieselbe Maske; eine Änderung
|
||||||
|
* ist mit der neuesten veröffentlichten Fassung vorbelegt. Wirkung unverändert BundleService::publish.
|
||||||
|
*/
|
||||||
class ViewBundle extends ViewRecord
|
class ViewBundle extends ViewRecord
|
||||||
{
|
{
|
||||||
use ReportsDomainRules;
|
use ReportsDomainRules;
|
||||||
|
|
||||||
protected static string $resource = BundleResource::class;
|
protected static string $resource = BundleResource::class;
|
||||||
|
|
||||||
|
public function getTitle(): string|Htmlable
|
||||||
|
{
|
||||||
|
return (string) $this->getRecord()->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeading(): string|Htmlable
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function getBreadcrumbs(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMaxContentWidth(): Width|string|null
|
||||||
|
{
|
||||||
|
return Width::Full;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function infolist(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema->components([
|
||||||
|
View::make('filament.catalog.objekt')->viewData(fn (): array => $this->paketDaten())->columnSpanFull(),
|
||||||
|
])->columns(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publishedVersion(): ?BundleVersion
|
||||||
|
{
|
||||||
|
/** @var Bundle $bundle */
|
||||||
|
$bundle = $this->getRecord();
|
||||||
|
|
||||||
|
return $bundle->versions()
|
||||||
|
->where('status', BundleStatus::Veroeffentlicht)
|
||||||
|
->orderByDesc('number')
|
||||||
|
->with(['items.article', 'items.nestedBundle'])
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function publishAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('publish')
|
||||||
|
->label(fn (): string => $this->publishedVersion() !== null ? 'Geänderte Fassung veröffentlichen' : 'Fassung veröffentlichen')
|
||||||
|
->modalHeading(fn (): string => $this->publishedVersion() !== null
|
||||||
|
? 'Paket ändern: Fassung '.$this->nextNumber().' veröffentlichen'
|
||||||
|
: 'Erste Fassung veröffentlichen')
|
||||||
|
->modalDescription(fn (): string => ($published = $this->publishedVersion()) !== null
|
||||||
|
? 'Die Maske ist mit Fassung '.$published->number.' vorbelegt. Fassung '.$published->number.' bleibt veröffentlicht und unverändert; Angebote verweisen weiter auf die Paketfassung, die sie nennen.'
|
||||||
|
: 'Die gewählten Lizenzartikel und Pakete bilden die erste Fassung. Sie ist danach unveränderlich.')
|
||||||
|
->modalSubmitActionLabel(fn (): string => 'Fassung '.$this->nextNumber().' veröffentlichen')
|
||||||
|
->fillForm(fn (): array => $this->formFromPublished())
|
||||||
|
->schema([
|
||||||
|
CheckboxList::make('articles')->label('Lizenzartikel')->options(fn (): array => CatalogOptions::articles()),
|
||||||
|
CheckboxList::make('bundles')->label('Enthaltene Pakete')
|
||||||
|
->options(function (): array {
|
||||||
|
$options = CatalogOptions::bundles();
|
||||||
|
unset($options[$this->getRecord()->getKey()]);
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
->action(function (array $data): void {
|
||||||
|
$this->report(function () use ($data): string {
|
||||||
|
/** @var Bundle $bundle */
|
||||||
|
$bundle = $this->getRecord();
|
||||||
|
$items = [];
|
||||||
|
|
||||||
|
foreach ($data['articles'] ?? [] as $id) {
|
||||||
|
$items[] = LicenseArticle::query()->findOrFail($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($data['bundles'] ?? [] as $id) {
|
||||||
|
$items[] = Bundle::query()->findOrFail($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = app(BundleService::class)->publish($bundle, $items);
|
||||||
|
|
||||||
|
return 'Fassung '.$version->number.' ist veröffentlicht.';
|
||||||
|
}, 'Die Paketfassung ist veröffentlicht.');
|
||||||
|
$this->getRecord()->unsetRelations();
|
||||||
|
$this->getRecord()->refresh();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{articles: list<int>, bundles: list<int>}
|
||||||
|
*/
|
||||||
|
private function formFromPublished(): array
|
||||||
|
{
|
||||||
|
$published = $this->publishedVersion();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
Action::make('publish')
|
'articles' => $published?->items->pluck('license_article_id')->filter()->values()->all() ?? [],
|
||||||
->label('Fassung veröffentlichen')
|
'bundles' => $published?->items->pluck('nested_bundle_id')->filter()->values()->all() ?? [],
|
||||||
->schema([
|
];
|
||||||
CheckboxList::make('articles')->label('Lizenzartikel')->options(fn (): array => CatalogOptions::articles()),
|
}
|
||||||
CheckboxList::make('bundles')->label('Enthaltene Pakete')
|
|
||||||
->options(function (): array {
|
|
||||||
$options = CatalogOptions::bundles();
|
|
||||||
unset($options[$this->getRecord()->getKey()]);
|
|
||||||
|
|
||||||
return $options;
|
private function nextNumber(): int
|
||||||
}),
|
{
|
||||||
])
|
return ((int) $this->getRecord()->versions()->max('number')) + 1;
|
||||||
->action(function (array $data): void {
|
}
|
||||||
$this->report(function () use ($data): void {
|
|
||||||
/** @var Bundle $bundle */
|
|
||||||
$bundle = $this->getRecord();
|
|
||||||
$items = [];
|
|
||||||
|
|
||||||
foreach ($data['articles'] ?? [] as $id) {
|
/**
|
||||||
$items[] = LicenseArticle::query()->findOrFail($id);
|
* @return array<string, mixed>
|
||||||
}
|
*/
|
||||||
|
private function paketDaten(): array
|
||||||
|
{
|
||||||
|
/** @var Bundle $bundle */
|
||||||
|
$bundle = $this->getRecord();
|
||||||
|
$published = $this->publishedVersion();
|
||||||
|
$articles = $published !== null ? app(CatalogReading::class)->bundleArticles($bundle) : [];
|
||||||
|
|
||||||
foreach ($data['bundles'] ?? [] as $id) {
|
return [
|
||||||
$items[] = Bundle::query()->findOrFail($id);
|
'kopf' => [
|
||||||
}
|
'brot' => [['label' => 'Pakete', 'href' => BundleResource::getUrl('index')], $bundle->name],
|
||||||
|
'titel' => $bundle->name,
|
||||||
app(BundleService::class)->publish($bundle, $items);
|
'typ' => 'Paket',
|
||||||
}, 'Die Paketfassung ist veröffentlicht.');
|
'status' => $published !== null
|
||||||
$this->getRecord()->unsetRelations();
|
? ['text' => 'Fassung '.$published->number.' veröffentlicht', 'ton' => 'gut']
|
||||||
$this->getRecord()->refresh();
|
: ['text' => 'Noch keine veröffentlichte Fassung. Bestandteile werden mit der Fassung festgeschrieben.', 'ton' => 'offen'],
|
||||||
}),
|
'aktionen' => [[
|
||||||
|
'label' => $published !== null ? 'Geänderte Fassung veröffentlichen' : 'Fassung veröffentlichen',
|
||||||
|
'wire' => "mountAction('publish')",
|
||||||
|
'art' => 'primary',
|
||||||
|
]],
|
||||||
|
],
|
||||||
|
'haupt' => [
|
||||||
|
[
|
||||||
|
'titel' => 'Bestandteile',
|
||||||
|
'zusatz' => $published !== null ? 'Fassung '.$published->number : null,
|
||||||
|
'hilfe' => 'Was diese Fassung direkt enthält.',
|
||||||
|
'zeilen' => $published === null ? [] : $published->items->sortBy('position')->map(fn ($item): array => [
|
||||||
|
'text' => $item->article !== null ? 'Lizenzartikel '.$item->article->code : 'Paket '.($item->nestedBundle?->name ?? 'fehlt'),
|
||||||
|
])->values()->all(),
|
||||||
|
'leer' => ['titel' => 'Noch keine Bestandteile', 'text' => 'Mit „Fassung veröffentlichen“ wählst du Lizenzartikel und andere Pakete.'],
|
||||||
|
],
|
||||||
|
...($published !== null ? [[
|
||||||
|
'titel' => 'Aufgelöste Lizenzartikel',
|
||||||
|
'hilfe' => 'Darauf werden beim Erwerb die Berechtigungen vergeben.',
|
||||||
|
'zeilen' => array_map(fn (string $code): array => ['text' => $code], $articles),
|
||||||
|
]] : []),
|
||||||
|
],
|
||||||
|
'seite' => [[
|
||||||
|
'titel' => 'Fassungen',
|
||||||
|
'zeilen' => $bundle->versions()->withCount('items')->orderByDesc('number')->get()->map(fn (BundleVersion $version): array => [
|
||||||
|
'text' => 'Fassung '.$version->number,
|
||||||
|
'zustand' => StatusValue::of($version->status) === BundleStatus::Veroeffentlicht->value
|
||||||
|
? ['label' => 'Veröffentlicht', 'ton' => 'gut']
|
||||||
|
: ['label' => 'Entwurf', 'ton' => 'offen'],
|
||||||
|
'neben' => $version->items_count === 1 ? '1 Bestandteil' : $version->items_count.' Bestandteile',
|
||||||
|
])->all(),
|
||||||
|
'leer' => 'Noch keine Fassung.',
|
||||||
|
'hilfe' => 'Veröffentlichte Fassungen bleiben unverändert; ein Angebot nennt die Paketfassung, auf die es sich bezieht.',
|
||||||
|
]],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -4,38 +4,66 @@
|
|||||||
|
|
||||||
use App\Domain\Catalog\CompositionKind;
|
use App\Domain\Catalog\CompositionKind;
|
||||||
use App\Domain\Catalog\ContentService;
|
use App\Domain\Catalog\ContentService;
|
||||||
use App\Domain\Catalog\EditorialContentKind;
|
|
||||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
|
use App\Filament\Support\ListsCompositions;
|
||||||
use App\Filament\Support\ReportsDomainRules;
|
use App\Filament\Support\ReportsDomainRules;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
use Filament\Schemas\Components\View;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
use Illuminate\Contracts\Support\Htmlable;
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listen „Module“, „Programme“ und „Fachliche Kombinationen“: dieselbe Bestandsliste wie der Arbeitsplatz, mit festem
|
||||||
|
* Typ. Module und Programme teilen den Anlegedialog des Arbeitsplatzes; Kombinationen behalten ihren.
|
||||||
|
*/
|
||||||
abstract class ListCompositionKind extends ListRecords
|
abstract class ListCompositionKind extends ListRecords
|
||||||
{
|
{
|
||||||
|
use ListsCompositions;
|
||||||
use ReportsDomainRules;
|
use ReportsDomainRules;
|
||||||
|
|
||||||
abstract protected function kind(): CompositionKind;
|
abstract protected function kind(): CompositionKind;
|
||||||
|
|
||||||
|
protected function fixedKind(): ?CompositionKind
|
||||||
|
{
|
||||||
|
return $this->kind();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onDesk(): bool
|
||||||
|
{
|
||||||
|
return in_array($this->kind(), [CompositionKind::Kurs, CompositionKind::Uebung], true);
|
||||||
|
}
|
||||||
|
|
||||||
public function getSubheading(): string|Htmlable|null
|
public function getSubheading(): string|Htmlable|null
|
||||||
{
|
{
|
||||||
$desk = in_array($this->kind(), [CompositionKind::Kurs, CompositionKind::Uebung], true)
|
$desk = $this->onDesk() ? ' Programme und Module stehen gemeinsam auch auf dem Arbeitsplatz.' : '';
|
||||||
? ' Programme und Module liegen gemeinsam auf dem Arbeitsplatz.'
|
|
||||||
: '';
|
|
||||||
|
|
||||||
return $this->kind()->deskExplanation().$desk;
|
return $this->kind()->deskExplanation().$desk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMaxContentWidth(): Width|string|null
|
||||||
|
{
|
||||||
|
return Width::Full;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function content(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema->components([View::make('filament.verwaltung.bestand')]);
|
||||||
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
|
if ($this->onDesk()) {
|
||||||
|
return [$this->createCompositionAction($this->kind())];
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
Action::make('create')
|
Action::make('create')
|
||||||
->label(match ($this->kind()) {
|
->label($this->kind()->createLabel())
|
||||||
CompositionKind::Kurs => 'Programm anlegen',
|
->modalHeading('Neue '.lcfirst($this->kind()->label()))
|
||||||
CompositionKind::Uebung => 'Modul anlegen',
|
->modalSubmitActionLabel($this->kind()->createLabel())
|
||||||
default => $this->kind()->createLabel(),
|
|
||||||
})
|
|
||||||
->visible(fn (): bool => ContentElementResource::editor())
|
->visible(fn (): bool => ContentElementResource::editor())
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('designation')->label('Bezeichnung')->required(),
|
TextInput::make('designation')->label('Bezeichnung')->required(),
|
||||||
@@ -44,16 +72,6 @@ protected function getHeaderActions(): array
|
|||||||
$composition = null;
|
$composition = null;
|
||||||
$this->report(function () use ($data, &$composition): void {
|
$this->report(function () use ($data, &$composition): void {
|
||||||
$composition = app(ContentService::class)->createComposition($data['designation'], $this->kind());
|
$composition = app(ContentService::class)->createComposition($data['designation'], $this->kind());
|
||||||
$slug = match ($this->kind()) {
|
|
||||||
CompositionKind::Kurs => 'programm',
|
|
||||||
CompositionKind::Uebung => 'modul',
|
|
||||||
default => null,
|
|
||||||
};
|
|
||||||
$editorial = $slug === null ? null : EditorialContentKind::query()->where('slug', $slug)->first();
|
|
||||||
if ($editorial !== null) {
|
|
||||||
$composition->editorial_content_kind_id = $editorial->id;
|
|
||||||
$composition->save();
|
|
||||||
}
|
|
||||||
}, $this->kind()->label().' ist angelegt.');
|
}, $this->kind()->label().' ist angelegt.');
|
||||||
|
|
||||||
if ($composition !== null) {
|
if ($composition !== null) {
|
||||||
|
|||||||
@@ -7,9 +7,7 @@
|
|||||||
use App\Domain\Catalog\ContentElementVersion;
|
use App\Domain\Catalog\ContentElementVersion;
|
||||||
use App\Domain\Catalog\ContentService;
|
use App\Domain\Catalog\ContentService;
|
||||||
use App\Domain\Catalog\DomainRuleException;
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
use App\Domain\Catalog\EditorialContentKind;
|
use App\Domain\Catalog\EditorialVocabulary;
|
||||||
use App\Domain\Catalog\EditorialDimension;
|
|
||||||
use App\Domain\Catalog\EditorialDimensionValue;
|
|
||||||
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;
|
||||||
@@ -37,12 +35,23 @@
|
|||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Früheres Gesamtformular. Texte und Einordnung bearbeitet die gemeinsame Redaktion, Datei und Fassungen der
|
||||||
|
* Medieneditor; ein zweiter Editor für dieselben Felder ist nach Dokument 14 nicht zulässig. Die Adresse bleibt
|
||||||
|
* für alte Lesezeichen erhalten und führt nach der Rechteprüfung in die Redaktion des Mediums.
|
||||||
|
*/
|
||||||
class EditContentElement extends EditRecord
|
class EditContentElement extends EditRecord
|
||||||
{
|
{
|
||||||
use ReportsDomainRules;
|
use ReportsDomainRules;
|
||||||
|
|
||||||
protected static string $resource = ContentElementResource::class;
|
protected static string $resource = ContentElementResource::class;
|
||||||
|
|
||||||
|
public function mount(int|string $record): void
|
||||||
|
{
|
||||||
|
parent::mount($record);
|
||||||
|
$this->redirect(ContentElementResource::getUrl('view', ['record' => $this->getRecord(), 'redaktion' => 1]));
|
||||||
|
}
|
||||||
|
|
||||||
public function getSubheading(): string|Htmlable|null
|
public function getSubheading(): string|Htmlable|null
|
||||||
{
|
{
|
||||||
return 'Titel, Beschreibung, Hinweise und Vorschaubild gehören zum Medium. Ein Text bleibt dieselbe Fassung, solange er nicht freigegeben und verwendet wird.';
|
return 'Titel, Beschreibung, Hinweise und Vorschaubild gehören zum Medium. Ein Text bleibt dieselbe Fassung, solange er nicht freigegeben und verwendet wird.';
|
||||||
@@ -64,8 +73,8 @@ public function form(Schema $schema): Schema
|
|||||||
->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),
|
Textarea::make('summary')->label('Kurzbeschreibung')->rows(3),
|
||||||
Select::make('editorial_content_kind_id')
|
Select::make('editorial_content_kind_id')
|
||||||
->label('Inhaltsart')
|
->label('Fachliche Materialart')
|
||||||
->options(fn (): array => EditorialContentKind::selectOptions())
|
->options(fn (): array => app(EditorialVocabulary::class)->kindOptions('medium', $this->getRecord()->editorial_content_kind_id !== null ? (int) $this->getRecord()->editorial_content_kind_id : null))
|
||||||
->nullable()
|
->nullable()
|
||||||
->helperText('Optional für Bibliothek und Website. Ändert weder die Ausgabeart noch eine Fassung.'),
|
->helperText('Optional für Bibliothek und Website. Ändert weder die Ausgabeart noch eine Fassung.'),
|
||||||
Placeholder::make('usage')->label('Verwendung')->content(function (): HtmlString {
|
Placeholder::make('usage')->label('Verwendung')->content(function (): HtmlString {
|
||||||
@@ -93,9 +102,12 @@ public function form(Schema $schema): Schema
|
|||||||
CheckboxList::make('dimension_ids')->label('Fachliche Einordnung')
|
CheckboxList::make('dimension_ids')->label('Fachliche Einordnung')
|
||||||
->options(function (): array {
|
->options(function (): array {
|
||||||
$options = [];
|
$options = [];
|
||||||
foreach (EditorialDimension::query()->with('values')->orderBy('label')->get() as $dimension) {
|
foreach (app(EditorialVocabulary::class)->dimensionGroups($this->getRecord(), IdentityDimensionValue::query()
|
||||||
foreach ($dimension->values as $value) {
|
->where('subject_type', $this->getRecord()->getMorphClass())
|
||||||
$options[$value->id] = $dimension->label.': '.$value->label;
|
->where('subject_id', $this->getRecord()->getKey())
|
||||||
|
->pluck('editorial_dimension_value_id')->map(fn ($id): int => (int) $id)->all()) as $dimension) {
|
||||||
|
foreach ($dimension['values'] as $value) {
|
||||||
|
$options[$value['id']] = $dimension['label'].': '.$value['label'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,16 +245,7 @@ protected function handleRecordUpdate(Model $record, array $data): Model
|
|||||||
DeriveThumbnail::dispatch('element', $record->id, $data['thumbnail_upload']);
|
DeriveThumbnail::dispatch('element', $record->id, $data['thumbnail_upload']);
|
||||||
}
|
}
|
||||||
if (array_key_exists('dimension_ids', $data)) {
|
if (array_key_exists('dimension_ids', $data)) {
|
||||||
$ids = array_map(intval(...), $data['dimension_ids'] ?? []);
|
app(IdentityDimension::class)->replaceOffered($record, array_map(intval(...), $data['dimension_ids'] ?? []));
|
||||||
IdentityDimensionValue::query()
|
|
||||||
->where('subject_type', $record->getMorphClass())
|
|
||||||
->where('subject_id', $record->id)
|
|
||||||
->where('origin', 'direkt')
|
|
||||||
->whereNotIn('editorial_dimension_value_id', $ids === [] ? [0] : $ids)
|
|
||||||
->delete();
|
|
||||||
foreach (EditorialDimensionValue::query()->whereIn('id', $ids)->get() as $value) {
|
|
||||||
app(IdentityDimension::class)->assign($record, $value, 'direkt');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
app(PillarService::class)->assign($record, array_map(intval(...), $data['pillars'] ?? []));
|
app(PillarService::class)->assign($record, array_map(intval(...), $data['pillars'] ?? []));
|
||||||
} catch (DomainRuleException $exception) {
|
} catch (DomainRuleException $exception) {
|
||||||
|
|||||||
@@ -2,22 +2,279 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\ContentElements\Pages;
|
namespace App\Filament\Resources\ContentElements\Pages;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\EditorialVocabulary;
|
||||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
|
use App\Filament\Support\Bestand;
|
||||||
|
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 Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
use Filament\Schemas\Components\RenderHook;
|
||||||
|
use Filament\Schemas\Components\View;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
|
use Filament\View\PanelsRenderHook;
|
||||||
use Illuminate\Contracts\Support\Htmlable;
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
|
use Livewire\Attributes\Url;
|
||||||
|
|
||||||
class ListContentElements extends ListRecords
|
class ListContentElements extends ListRecords
|
||||||
{
|
{
|
||||||
use ReportsDomainRules;
|
use ReportsDomainRules;
|
||||||
|
use ShowsBestand;
|
||||||
|
|
||||||
protected static string $resource = ContentElementResource::class;
|
protected static string $resource = ContentElementResource::class;
|
||||||
|
|
||||||
|
#[Url(as: 'suche', except: '')]
|
||||||
|
public string $suche = '';
|
||||||
|
|
||||||
|
/** Dokument 14 §3: kompakte Liste als Grundansicht; Kacheln bleiben wählbar. */
|
||||||
|
#[Url(as: 'ansicht', except: 'liste')]
|
||||||
|
public string $ansicht = 'liste';
|
||||||
|
|
||||||
|
#[Url(as: 'art', except: '')]
|
||||||
|
public string $art = '';
|
||||||
|
|
||||||
|
#[Url(as: 'freigabe', except: '')]
|
||||||
|
public string $freigabe = '';
|
||||||
|
|
||||||
|
#[Url(as: 'entwurf', except: '')]
|
||||||
|
public string $entwurf = '';
|
||||||
|
|
||||||
|
#[Url(as: 'fassung', except: '')]
|
||||||
|
public string $fassung = '';
|
||||||
|
|
||||||
|
#[Url(as: 'nutzung', except: '')]
|
||||||
|
public string $nutzung = '';
|
||||||
|
|
||||||
|
#[Url(as: 'saeule', except: '')]
|
||||||
|
public string $saeule = '';
|
||||||
|
|
||||||
|
#[Url(as: 'inhaltsart', except: '')]
|
||||||
|
public string $inhaltsart = '';
|
||||||
|
|
||||||
|
#[Url(as: 'einordnung', except: '')]
|
||||||
|
public string $einordnung = '';
|
||||||
|
|
||||||
|
#[Url(as: 'verarbeitung', except: '')]
|
||||||
|
public string $verarbeitung = '';
|
||||||
|
|
||||||
|
#[Url(as: 'archiv', except: 'aktiv')]
|
||||||
|
public string $archiv = 'aktiv';
|
||||||
|
|
||||||
public function getSubheading(): string|Htmlable|null
|
public function getSubheading(): string|Htmlable|null
|
||||||
{
|
{
|
||||||
return 'Die Dateien und Texte. Eine Übung, ein Kurs oder eine fachliche Kombination verweist darauf; 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.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMaxContentWidth(): Width|string|null
|
||||||
|
{
|
||||||
|
return Width::Full;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function content(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema->components([
|
||||||
|
RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_BEFORE),
|
||||||
|
View::make('filament.verwaltung.bestand'),
|
||||||
|
RenderHook::make(PanelsRenderHook::RESOURCE_PAGES_LIST_RECORDS_TABLE_AFTER),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function bestandFilterEigenschaften(): array
|
||||||
|
{
|
||||||
|
return ['suche', 'art', 'freigabe', 'entwurf', 'fassung', 'nutzung', 'saeule', 'inhaltsart', 'einordnung', 'verarbeitung', 'archiv'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function showingList(): bool
|
||||||
|
{
|
||||||
|
return $this->ansicht === 'liste';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function cards(): array
|
||||||
|
{
|
||||||
|
return app(MediaLibrary::class)->cards($this->libraryFilters(), ContentElementResource::editor());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{value: string, label: string}>
|
||||||
|
*/
|
||||||
|
public function typeOptions(): array
|
||||||
|
{
|
||||||
|
return app(MediaLibrary::class)->types();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{id: int, name: string}>
|
||||||
|
*/
|
||||||
|
public function pillarOptions(): array
|
||||||
|
{
|
||||||
|
return app(MediaLibrary::class)->pillars();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{id: int, label: string}>
|
||||||
|
*/
|
||||||
|
public function classificationOptions(): array
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
return trim($this->suche) !== ''
|
||||||
|
|| $this->art !== ''
|
||||||
|
|| $this->freigabe !== ''
|
||||||
|
|| $this->entwurf !== ''
|
||||||
|
|| $this->fassung !== ''
|
||||||
|
|| $this->nutzung !== ''
|
||||||
|
|| $this->saeule !== ''
|
||||||
|
|| $this->einordnung !== ''
|
||||||
|
|| $this->inhaltsart !== ''
|
||||||
|
|| $this->verarbeitung !== ''
|
||||||
|
|| $this->archiv !== 'aktiv';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetFilters(): void
|
||||||
|
{
|
||||||
|
$this->suche = '';
|
||||||
|
$this->art = '';
|
||||||
|
$this->freigabe = '';
|
||||||
|
$this->entwurf = '';
|
||||||
|
$this->fassung = '';
|
||||||
|
$this->nutzung = '';
|
||||||
|
$this->saeule = '';
|
||||||
|
$this->einordnung = '';
|
||||||
|
$this->inhaltsart = '';
|
||||||
|
$this->verarbeitung = '';
|
||||||
|
$this->archiv = 'aktiv';
|
||||||
|
$this->bestandGrenze = Bestand::SCHRITT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gemeinsame Bestandsliste: Suche und häufige Filter sichtbar, die übrigen unter „Weitere Filter“.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function bestand(): array
|
||||||
|
{
|
||||||
|
$optionen = fn (array $liste, string $wert, string $label): array => collect($liste)
|
||||||
|
->mapWithKeys(fn (array $eintrag): array => [(string) $eintrag[$wert] => $eintrag[$label]])
|
||||||
|
->all();
|
||||||
|
$weitere = [
|
||||||
|
['eigenschaft' => 'inhaltsart', 'label' => 'Fachliche Materialart', 'vorgabe' => '', 'alle' => 'Alle Materialarten', 'optionen' => $this->contentKindOptions()],
|
||||||
|
['eigenschaft' => 'entwurf', 'label' => 'Entwurf', 'vorgabe' => '', 'alle' => 'Entwurf egal', 'optionen' => ['offen' => 'Offener Entwurf', 'keiner' => 'Kein offener Entwurf']],
|
||||||
|
['eigenschaft' => 'fassung', 'label' => 'Deaktivierte Fassungen', 'vorgabe' => '', 'alle' => 'Regulärer Bestand', 'optionen' => ['mit' => 'Mit deaktivierter Fassung', 'nur' => 'Nur deaktivierte Fassungen']],
|
||||||
|
];
|
||||||
|
|
||||||
|
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 [
|
||||||
|
'suche' => ['eigenschaft' => 'suche', 'label' => 'Suche', 'platzhalter' => 'Titel, Beschreibung oder Suchbegriff'],
|
||||||
|
'filter' => [
|
||||||
|
['eigenschaft' => 'art', 'label' => 'Technische Art', 'vorgabe' => '', 'alle' => 'Alle Arten', 'optionen' => $optionen($this->typeOptions(), 'value', 'label')],
|
||||||
|
['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. 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()),
|
||||||
|
'einheit' => ['Medium', 'Medien'],
|
||||||
|
'leer' => ['titel' => 'Noch keine Medien', 'text' => 'Mit „Medium anlegen“ oben lädst du eine Datei hoch oder schreibst einen Text.'],
|
||||||
|
'ansicht' => 'ansicht',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $card
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function zeile(array $card): array
|
||||||
|
{
|
||||||
|
$chips = [['label' => $card['stand'], 'ton' => match ($card['standTone']) {
|
||||||
|
'ready' => 'gut',
|
||||||
|
'draft' => 'offen',
|
||||||
|
'blocked' => 'achtung',
|
||||||
|
default => 'leise',
|
||||||
|
}]];
|
||||||
|
|
||||||
|
foreach ([['draftNote', 'offen'], ['blockedNote', 'achtung'], ['processing', 'offen'], ['versionLabel', 'leise']] as [$feld, $ton]) {
|
||||||
|
if (filled($card[$feld] ?? null)) {
|
||||||
|
$chips[] = ['label' => (string) $card[$feld], 'ton' => $ton];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($card['archived']) {
|
||||||
|
$chips[] = ['label' => 'Archiviert', 'ton' => 'leise'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'schluessel' => 'm'.$card['id'],
|
||||||
|
'titel' => $card['title'],
|
||||||
|
'meta' => $card['type'].(filled($card['editorialKind'] ?? null) ? ' · '.$card['editorialKind'] : ''),
|
||||||
|
'text' => $card['description'],
|
||||||
|
'bild' => $card['image'],
|
||||||
|
'bildAlt' => $card['imageAlt'],
|
||||||
|
'symbol' => match ($card['typeKey']) {
|
||||||
|
'film' => 'film',
|
||||||
|
'bild' => 'bild',
|
||||||
|
'audio' => 'audio',
|
||||||
|
default => 'dokument',
|
||||||
|
},
|
||||||
|
'url' => $card['url'],
|
||||||
|
'chips' => $chips,
|
||||||
|
'hinweise' => array_values(array_filter([
|
||||||
|
$card['imageNote'] ? 'Vorschaubild: '.$card['imageNote'] : null,
|
||||||
|
$card['usageNote'] ? 'Einsatz: '.$card['usageNote'] : null,
|
||||||
|
$card['licenseNote'] ? 'Interner Lizenzvermerk: '.$card['licenseNote'] : null,
|
||||||
|
])),
|
||||||
|
'zusatz' => ['view' => 'filament.media.usages', 'daten' => ['card' => $card]],
|
||||||
|
'aktionen' => array_values(array_filter([
|
||||||
|
['label' => 'Ansehen', 'href' => $card['url'], 'icon' => 'auge'],
|
||||||
|
$card['editUrl'] ? ['label' => 'Redaktion', 'href' => $card['editUrl'], 'icon' => 'stift'] : null,
|
||||||
|
])),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
private function libraryFilters(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'suche' => $this->suche,
|
||||||
|
'art' => $this->art,
|
||||||
|
'freigabe' => $this->freigabe,
|
||||||
|
'entwurf' => $this->entwurf,
|
||||||
|
'fassung' => $this->fassung,
|
||||||
|
'nutzung' => $this->nutzung,
|
||||||
|
'saeule' => $this->saeule,
|
||||||
|
'einordnung' => $this->einordnung,
|
||||||
|
'inhaltsart' => $this->inhaltsart,
|
||||||
|
'verarbeitung' => $this->verarbeitung,
|
||||||
|
'archiv' => $this->archiv,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
@@ -25,6 +282,7 @@ protected function getHeaderActions(): array
|
|||||||
return [
|
return [
|
||||||
Action::make('create')
|
Action::make('create')
|
||||||
->label('Medium anlegen')
|
->label('Medium anlegen')
|
||||||
|
->modalSubmitActionLabel('Medium anlegen')
|
||||||
->visible(fn (): bool => ContentElementResource::editor())
|
->visible(fn (): bool => ContentElementResource::editor())
|
||||||
->modalDescription('Dieselbe Maske gilt im Medienbestand, im Modul und im Programm. Der Upload zeigt seinen Fortschritt. Beschreibung, Hinweise und Vorschaubild gehören dazu.')
|
->modalDescription('Dieselbe Maske gilt im Medienbestand, im Modul und im Programm. Der Upload zeigt seinen Fortschritt. Beschreibung, Hinweise und Vorschaubild gehören dazu.')
|
||||||
->schema(fn (): array => MediumForm::fields(creating: true))
|
->schema(fn (): array => MediumForm::fields(creating: true))
|
||||||
|
|||||||
@@ -6,23 +6,35 @@
|
|||||||
use App\Domain\Catalog\ContentElementVersion;
|
use App\Domain\Catalog\ContentElementVersion;
|
||||||
use App\Domain\Catalog\ContentService;
|
use App\Domain\Catalog\ContentService;
|
||||||
use App\Domain\Catalog\ContentVersionStatus;
|
use App\Domain\Catalog\ContentVersionStatus;
|
||||||
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
|
use App\Domain\Catalog\EditorialVocabulary;
|
||||||
|
use App\Domain\Catalog\IdentityChange;
|
||||||
|
use App\Domain\Catalog\IdentityDimension;
|
||||||
|
use App\Domain\Catalog\IdentityDimensionValue;
|
||||||
use App\Domain\Catalog\IdentityProfile;
|
use App\Domain\Catalog\IdentityProfile;
|
||||||
use App\Domain\Catalog\Pillar;
|
use App\Domain\Catalog\Pillar;
|
||||||
use App\Domain\Catalog\PillarService;
|
use App\Domain\Catalog\PillarService;
|
||||||
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
|
use App\Domain\Cms\WebsiteImageUsage;
|
||||||
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
use App\Domain\Media\ThumbnailRef;
|
use App\Domain\Media\ThumbnailRef;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
use App\Filament\Support\CatalogReading;
|
use App\Filament\Support\CatalogReading;
|
||||||
|
use App\Filament\Support\EditorialCatalog;
|
||||||
use App\Filament\Support\ElementRevision;
|
use App\Filament\Support\ElementRevision;
|
||||||
|
use App\Filament\Support\ManagesEditorialSurface;
|
||||||
|
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;
|
||||||
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\Textarea;
|
use Filament\Forms\Components\Textarea;
|
||||||
use Filament\Forms\Components\TextInput;
|
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
use Filament\Schemas\Components\View;
|
use Filament\Schemas\Components\View;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
use Illuminate\Contracts\Support\Htmlable;
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||||
@@ -30,6 +42,7 @@
|
|||||||
|
|
||||||
class ViewContentElement extends ViewRecord
|
class ViewContentElement extends ViewRecord
|
||||||
{
|
{
|
||||||
|
use ManagesEditorialSurface;
|
||||||
use ReportsDomainRules;
|
use ReportsDomainRules;
|
||||||
use WithFileUploads;
|
use WithFileUploads;
|
||||||
|
|
||||||
@@ -45,8 +58,60 @@ class ViewContentElement extends ViewRecord
|
|||||||
|
|
||||||
public string $pictureFeedback = '';
|
public string $pictureFeedback = '';
|
||||||
|
|
||||||
|
/** Rückmeldung zur ausgewählten Fassung, direkt im Detailbereich. */
|
||||||
|
public string $fassungFeedback = '';
|
||||||
|
|
||||||
|
public bool $fassungFeedbackError = false;
|
||||||
|
|
||||||
|
/** Gewählte Quelle für ein neues Vorschaubild: film oder upload. */
|
||||||
|
public string $bildQuelle = '';
|
||||||
|
|
||||||
public mixed $previewUpload = null;
|
public mixed $previewUpload = null;
|
||||||
|
|
||||||
|
public string $bereich = 'inhalt';
|
||||||
|
|
||||||
|
public string $workingTitle = '';
|
||||||
|
|
||||||
|
public string $displayTitle = '';
|
||||||
|
|
||||||
|
public string $teaser = '';
|
||||||
|
|
||||||
|
public string $summary = '';
|
||||||
|
|
||||||
|
public string $searchTerms = '';
|
||||||
|
|
||||||
|
public string $descriptionText = '';
|
||||||
|
|
||||||
|
public string $usageNote = '';
|
||||||
|
|
||||||
|
public string $licenseNote = '';
|
||||||
|
|
||||||
|
public string $websiteCredit = '';
|
||||||
|
|
||||||
|
public string $websiteAlt = '';
|
||||||
|
|
||||||
|
public string $websiteFeedback = '';
|
||||||
|
|
||||||
|
public int|string|null $kindId = null;
|
||||||
|
|
||||||
|
/** @var list<int|string> */
|
||||||
|
public array $pillarIds = [];
|
||||||
|
|
||||||
|
/** @var list<int|string> */
|
||||||
|
public array $dimensionIds = [];
|
||||||
|
|
||||||
|
public string $editorialFeedback = '';
|
||||||
|
|
||||||
|
public int $versionsBeforeSave = 0;
|
||||||
|
|
||||||
|
public string $previewWidth = '640';
|
||||||
|
|
||||||
|
public string $previewSurface = 'website';
|
||||||
|
|
||||||
|
public string $pickerContext = 'modul';
|
||||||
|
|
||||||
|
public string $pickerLayout = 'kacheln';
|
||||||
|
|
||||||
public function mount(int|string $record): void
|
public function mount(int|string $record): void
|
||||||
{
|
{
|
||||||
parent::mount($record);
|
parent::mount($record);
|
||||||
@@ -57,26 +122,103 @@ public function mount(int|string $record): void
|
|||||||
$this->fassung = $requested;
|
$this->fassung = $requested;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$bereich = (string) request()->query('bereich', 'inhalt');
|
||||||
|
$this->bereich = $this->normalBereich($bereich);
|
||||||
$this->thumbnailAlt = (string) ($this->getRecord()->thumbnail_alt ?? '');
|
$this->thumbnailAlt = (string) ($this->getRecord()->thumbnail_alt ?? '');
|
||||||
|
$this->bildQuelle = $this->getRecord()->output_class === 'film' ? 'film' : 'upload';
|
||||||
|
$this->fillEditorial();
|
||||||
|
// Die gezeigte Fassung wird festgehalten. Sonst wechselte die Anzeige still auf eine andere Fassung, sobald
|
||||||
|
// eine Freigabe oder neue Fassung die Vorgabe „neueste freigegebene“ ändert, während das Textfeld noch den
|
||||||
|
// Wortlaut der bisherigen enthält. Eine fremde oder ungültige Angabe in der Adresse wird dabei ersetzt.
|
||||||
|
$this->fassung = $this->shownVersion()?->id;
|
||||||
$this->syncBodyDraft();
|
$this->syncBodyDraft();
|
||||||
|
|
||||||
|
if (in_array($bereich, ['praesentation', 'redaktion'], true) && $this->canEditEditorial()) {
|
||||||
|
$this->openRedaktion($bereich === 'praesentation' ? 'medien' : 'texte');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSubheading(): string|Htmlable|null
|
public function updatedBereich(string $value): void
|
||||||
{
|
{
|
||||||
return 'Jede Fassung hat eine eigene Nummer und bleibt einsehbar. Beschreibung, Arbeitstitel und Säulen gehören zum Medium und ändern keine Fassung. Eine deaktivierte Fassung wird nicht mehr ausgeliefert und lässt sich nicht neu einbauen.';
|
$this->bereich = $this->normalBereich($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bereiche des Medieneditors. Fassungen und Inhalt bilden einen Bereich (Fassungen links, ausgewählte Fassung rechts);
|
||||||
|
* „fassungen“ bleibt als Adresse gültig. Die früheren Werte „beschreibung“ und „praesentation“ führen zur
|
||||||
|
* Website-Ansicht, weil Texte und Präsentationsmedien in der gemeinsamen Redaktion bearbeitet werden.
|
||||||
|
*/
|
||||||
|
public function normalBereich(string $value): string
|
||||||
|
{
|
||||||
|
return match ($value) {
|
||||||
|
'inhalt', 'vorschaubild', 'verwendung', 'vorschau', 'website' => $value,
|
||||||
|
'fassungen' => 'inhalt',
|
||||||
|
'beschreibung', 'praesentation', 'redaktion' => 'website',
|
||||||
|
default => 'inhalt',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): string|Htmlable
|
||||||
|
{
|
||||||
|
return (string) $this->getRecord()->working_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMaxContentWidth(): Width|string|null
|
||||||
|
{
|
||||||
|
return Width::Full;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function infolist(Schema $schema): Schema
|
public function infolist(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return $schema->components([
|
return $schema->components([
|
||||||
View::make('filament.media.viewer')->viewData(fn (): array => $this->viewerData()),
|
View::make('filament.media.viewer')->viewData(fn (): array => $this->viewerData())->columnSpanFull(),
|
||||||
]);
|
])->columns(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wählt eine Fassung. Ein geänderter, noch nicht gespeicherter Text geht dabei nicht stillschweigend verloren.
|
||||||
|
*/
|
||||||
public function showVersion(int $version): void
|
public function showVersion(int $version): void
|
||||||
{
|
{
|
||||||
abort_unless($this->ownedVersion($version) instanceof ContentElementVersion, 404);
|
abort_unless($this->ownedVersion($version) instanceof ContentElementVersion, 404);
|
||||||
|
$this->bereich = 'inhalt';
|
||||||
|
|
||||||
|
if ($this->shownVersion()?->id === $version) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->textUnsaved()) {
|
||||||
|
$this->askConfirmation('showVersion', $version);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->selectVersion($version);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Der Text der gezeigten Fassung weicht vom gespeicherten Stand ab.
|
||||||
|
*/
|
||||||
|
public function textUnsaved(): bool
|
||||||
|
{
|
||||||
|
$shown = $this->shownVersion();
|
||||||
|
|
||||||
|
return $shown instanceof ContentElementVersion
|
||||||
|
&& $this->getRecord()->output_class === 'text'
|
||||||
|
&& $shown->status !== ContentVersionStatus::Gesperrt
|
||||||
|
&& trim($this->bodyDraft) !== trim((string) $shown->body);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function discardShownText(): void
|
||||||
|
{
|
||||||
|
$this->syncBodyDraft();
|
||||||
|
$this->fassungFeedback = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function selectVersion(int $version): void
|
||||||
|
{
|
||||||
$this->fassung = $version;
|
$this->fassung = $version;
|
||||||
|
$this->fassungFeedback = '';
|
||||||
$this->syncBodyDraft();
|
$this->syncBodyDraft();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,12 +230,28 @@ public function saveShownText(): void
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$created = app(ContentService::class)->isCommitted($shown);
|
if (! $this->textUnsaved()) {
|
||||||
$this->report(function () use ($shown): void {
|
$this->fassungFeedback = 'Der Text ist unverändert. Es gibt nichts zu speichern.';
|
||||||
app(ContentService::class)->reviseElementContent($shown, $this->bodyDraft);
|
$this->fassungFeedbackError = false;
|
||||||
}, $created
|
|
||||||
? 'Die neue Fassung ist angelegt. Die bisherige bleibt erhalten.'
|
return;
|
||||||
: 'Der Text ist in derselben Fassung gespeichert.');
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$saved = app(ContentService::class)->reviseElementContent($shown, $this->bodyDraft);
|
||||||
|
} catch (DomainRuleException $exception) {
|
||||||
|
$this->fassungFeedback = $exception->getMessage();
|
||||||
|
$this->fassungFeedbackError = true;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Eine freigegebene Fassung bleibt unverändert; die Auswahl folgt der neu angelegten Fassung.
|
||||||
|
$this->fassungFeedback = $saved->id !== $shown->id
|
||||||
|
? 'Fassung '.$saved->number.' ist angelegt. Fassung '.$shown->number.' bleibt erhalten.'
|
||||||
|
: 'Der Text ist in Fassung '.$saved->number.' gespeichert. Es entsteht keine neue Fassung.';
|
||||||
|
$this->fassungFeedbackError = false;
|
||||||
|
$this->fassung = $saved->id;
|
||||||
$this->getRecord()->unsetRelation('versions');
|
$this->getRecord()->unsetRelation('versions');
|
||||||
$this->syncBodyDraft();
|
$this->syncBodyDraft();
|
||||||
}
|
}
|
||||||
@@ -221,7 +379,7 @@ public function deactivateAction(): Action
|
|||||||
{
|
{
|
||||||
return Action::make('deactivate')
|
return Action::make('deactivate')
|
||||||
->label('Deaktivieren')
|
->label('Deaktivieren')
|
||||||
->modalHeading('Fassung deaktivieren')
|
->modalHeading(fn (array $arguments): string => 'Fassung '.($this->ownedVersion((int) ($arguments['version'] ?? 0))?->number ?? '').' deaktivieren')
|
||||||
->modalDescription('Die Fassung bleibt hier einsehbar. Sie wird nicht mehr ausgeliefert und kann nicht in eine neue Übung oder einen neuen Kurs übernommen werden.')
|
->modalDescription('Die Fassung bleibt hier einsehbar. Sie wird nicht mehr ausgeliefert und kann nicht in eine neue Übung oder einen neuen Kurs übernommen werden.')
|
||||||
->modalSubmitActionLabel('Deaktivieren')
|
->modalSubmitActionLabel('Deaktivieren')
|
||||||
->visible(fn (): bool => ContentElementResource::editor())
|
->visible(fn (): bool => ContentElementResource::editor())
|
||||||
@@ -241,83 +399,141 @@ public function deactivateAction(): Action
|
|||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [];
|
||||||
Action::make('describe')
|
}
|
||||||
->label('Beschreibung ändern')
|
|
||||||
->visible(fn (): bool => ContentElementResource::editor())
|
public function releaseVersionAction(): Action
|
||||||
->fillForm(fn (): array => [
|
{
|
||||||
'working_title' => $this->getRecord()->working_title,
|
return Action::make('releaseVersion')
|
||||||
'description' => $this->getRecord()->description,
|
->label('Fassung freigeben')
|
||||||
'usage_note' => $this->getRecord()->usage_note,
|
->modalHeading(function (array $arguments): string {
|
||||||
'license_note' => $this->getRecord()->license_note,
|
$versionId = (int) ($arguments['version'] ?? 0);
|
||||||
'pillars' => $this->getRecord()->pillars()->pluck('pillars.id')->all(),
|
$version = $versionId > 0
|
||||||
])
|
? $this->ownedVersion($versionId)
|
||||||
->schema([
|
: $this->getRecord()->versions()->where('status', ContentVersionStatus::Entwurf)->orderByDesc('number')->first();
|
||||||
TextInput::make('working_title')->label('Arbeitstitel')->required(),
|
|
||||||
Textarea::make('description')->label('Beschreibung')->rows(4)
|
return $version instanceof ContentElementVersion ? 'Fassung '.$version->number.' freigeben' : 'Fassung freigeben';
|
||||||
->helperText('Gilt für das Medium. Speichern legt keine neue Fassung an.'),
|
})
|
||||||
Textarea::make('usage_note')->label('Hinweise für den Einsatz')->rows(4),
|
->modalDescription('Diese Fassung wird freigegeben. Sie erscheint dadurch nicht in der Mitgliederbibliothek, nicht auf der Website und nicht in einem Angebot. Eine deaktivierte Fassung bleibt unverändert.')
|
||||||
Textarea::make('license_note')->label('Interner Lizenzvermerk')->rows(3)
|
->modalSubmitActionLabel('Freigeben')
|
||||||
->helperText('Nur in der Verwaltung. Nicht in der Bibliothek und nicht auf der Website.'),
|
->visible(function (): bool {
|
||||||
CheckboxList::make('pillars')
|
/** @var ContentElement $element */
|
||||||
->label('Fachliche Säulen')
|
$element = $this->getRecord();
|
||||||
->options(fn (): array => Pillar::query()->orderBy('name')->pluck('name', 'id')->all()),
|
|
||||||
])
|
return ContentElementResource::editor()
|
||||||
->action(function (array $data): void {
|
&& $element->versions()->where('status', ContentVersionStatus::Entwurf)->exists();
|
||||||
$this->report(function () use ($data): void {
|
})
|
||||||
/** @var ContentElement $element */
|
->action(function (array $arguments): void {
|
||||||
$element = $this->getRecord();
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
app(ContentService::class)->describe($element, (string) $data['working_title'], $data['description'] ?? null);
|
$this->report(function () use ($arguments): string {
|
||||||
app(IdentityProfile::class)->fill($element, [
|
/** @var ContentElement $element */
|
||||||
'usage_note' => $data['usage_note'] ?? null,
|
$element = $this->getRecord();
|
||||||
'license_note' => $data['license_note'] ?? null,
|
$versionId = (int) ($arguments['version'] ?? 0);
|
||||||
], auth()->user());
|
$version = $versionId > 0
|
||||||
app(PillarService::class)->assign($element, array_map(intval(...), $data['pillars'] ?? []));
|
? $this->ownedVersion($versionId)
|
||||||
}, 'Die Beschreibung ist gespeichert.');
|
: $element->versions()->where('status', ContentVersionStatus::Entwurf)->orderByDesc('number')->first();
|
||||||
$this->getRecord()->refresh();
|
abort_unless($version instanceof ContentElementVersion, 404);
|
||||||
}),
|
$released = app(ContentService::class)->releaseElementVersion($version);
|
||||||
Action::make('releaseVersion')
|
|
||||||
->label('Fassung freigeben')
|
return 'Fassung '.$released->number.' ist freigegeben.';
|
||||||
->modalHeading('Fassung freigeben')
|
}, 'Die Fassung ist freigegeben.');
|
||||||
->modalDescription('Diese Fassung wird freigegeben. Sie erscheint dadurch nicht in der Mitgliederbibliothek, nicht auf der Website und nicht in einem Angebot. Eine deaktivierte Fassung bleibt unverändert.')
|
$this->getRecord()->unsetRelation('versions');
|
||||||
->modalSubmitActionLabel('Freigeben')
|
});
|
||||||
->visible(function (): bool {
|
}
|
||||||
|
|
||||||
|
public function reviseAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('revise')
|
||||||
|
->label('Neue Fassung anlegen')
|
||||||
|
->modalHeading('Neue Fassung anlegen')
|
||||||
|
->modalDescription('Für eine neue Datei oder einen geänderten Lehrtext. Die bisherigen Fassungen bleiben unverändert. Redaktion, Vorschaubild und Website-Angaben gehören nicht zur Fassung.')
|
||||||
|
->modalSubmitActionLabel('Fassung anlegen')
|
||||||
|
->visible(fn (): bool => ContentElementResource::editor())
|
||||||
|
->schema(fn (): array => ElementRevision::fields($this->getRecord()))
|
||||||
|
->action(function (array $data): void {
|
||||||
|
// Vor dem Anlegen prüfen: danach gäbe es eine andere neueste Fassung.
|
||||||
|
$textOffen = $this->textUnsaved();
|
||||||
|
$this->report(function () use ($data): string {
|
||||||
/** @var ContentElement $element */
|
/** @var ContentElement $element */
|
||||||
$element = $this->getRecord();
|
$element = $this->getRecord();
|
||||||
|
|
||||||
return ContentElementResource::editor()
|
return ElementRevision::publish($element, $data);
|
||||||
&& $element->versions()->where('status', ContentVersionStatus::Entwurf)->exists();
|
}, 'Die neue Fassung ist angelegt.');
|
||||||
})
|
$this->getRecord()->unsetRelation('versions');
|
||||||
->action(function (array $arguments): void {
|
|
||||||
abort_unless(ContentElementResource::editor(), 403);
|
|
||||||
$this->report(function () use ($arguments): string {
|
|
||||||
/** @var ContentElement $element */
|
|
||||||
$element = $this->getRecord();
|
|
||||||
$versionId = (int) ($arguments['version'] ?? 0);
|
|
||||||
$version = $versionId > 0
|
|
||||||
? $this->ownedVersion($versionId)
|
|
||||||
: $element->versions()->where('status', ContentVersionStatus::Entwurf)->orderByDesc('number')->first();
|
|
||||||
abort_unless($version instanceof ContentElementVersion, 404);
|
|
||||||
$released = app(ContentService::class)->releaseElementVersion($version);
|
|
||||||
|
|
||||||
return 'Fassung '.$released->number.' ist freigegeben.';
|
// Die neue Fassung wird gezeigt, sofern dabei kein offener Text verloren geht.
|
||||||
}, 'Die Fassung ist freigegeben.');
|
if (! $textOffen) {
|
||||||
$this->getRecord()->unsetRelation('versions');
|
$neueste = $this->getRecord()->versions()->orderByDesc('number')->value('id');
|
||||||
}),
|
$this->fassung = $neueste !== null ? (int) $neueste : $this->fassung;
|
||||||
Action::make('revise')
|
$this->fassungFeedback = '';
|
||||||
->label('Neue Fassung anlegen')
|
$this->syncBodyDraft();
|
||||||
->visible(fn (): bool => ContentElementResource::editor())
|
}
|
||||||
->schema(fn (): array => ElementRevision::fields($this->getRecord()))
|
});
|
||||||
->action(function (array $data): void {
|
}
|
||||||
$this->report(function () use ($data): string {
|
|
||||||
/** @var ContentElement $element */
|
|
||||||
$element = $this->getRecord();
|
|
||||||
|
|
||||||
return ElementRevision::publish($element, $data);
|
/**
|
||||||
}, 'Die neue Fassung ist angelegt.');
|
* Löschen bleibt Medien ohne Fassung vorbehalten. Bisher nur im separaten Formular, jetzt unter „Weitere Aktionen“.
|
||||||
$this->getRecord()->unsetRelation('versions');
|
*/
|
||||||
}),
|
public function deleteAction(): Action
|
||||||
];
|
{
|
||||||
|
return Action::make('delete')
|
||||||
|
->label('Medium löschen')
|
||||||
|
->color('danger')
|
||||||
|
->requiresConfirmation()
|
||||||
|
->modalHeading('Medium löschen')
|
||||||
|
->modalDescription('Das Medium hat keine Fassung und wird endgültig gelöscht. Zuordnungen als Präsentationsmedium entfallen.')
|
||||||
|
->modalSubmitActionLabel('Löschen')
|
||||||
|
->visible(fn (): bool => ContentElementResource::editor() && $this->getRecord()->versions()->doesntExist())
|
||||||
|
->action(function (): void {
|
||||||
|
abort_unless(ContentElementResource::editor() && $this->getRecord()->versions()->doesntExist(), 403);
|
||||||
|
$this->getRecord()->delete();
|
||||||
|
$this->redirect(ContentElementResource::getUrl('index'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function openThumbnailPicker(): void
|
||||||
|
{
|
||||||
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
|
$this->resetPicker('vorschaubild');
|
||||||
|
$this->pickerKind = 'bild';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function adoptThumbnailFromPicker(string $target): void
|
||||||
|
{
|
||||||
|
$this->pickerSelected = $target;
|
||||||
|
$this->adoptLibraryImage();
|
||||||
|
$this->pickerSelected = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{aktion: string, argument: int|string|null, titel: string, text: string, label: string, gefahr: bool}|null
|
||||||
|
*/
|
||||||
|
protected function extraConfirmation(string $aktion, int|string|null $argument): ?array
|
||||||
|
{
|
||||||
|
$gezeigt = $this->shownVersion();
|
||||||
|
|
||||||
|
return match ($aktion) {
|
||||||
|
'withdrawWebsite' => ['aktion' => $aktion, 'argument' => null, 'titel' => 'Website-Freigabe zurücknehmen?', 'text' => 'Das Medium verschwindet sofort von allen öffentlichen Seiten. Zuordnungen und Fassungen bleiben erhalten.', 'label' => 'Freigabe zurücknehmen', 'gefahr' => true],
|
||||||
|
'showVersion' => ['aktion' => $aktion, 'argument' => $argument, 'titel' => 'Ungespeicherten Text verwerfen?', 'text' => 'Der geänderte Text von Fassung '.($gezeigt?->number ?? '').' ist noch nicht gespeichert und geht beim Wechsel verloren. Gespeicherte Fassungen bleiben unverändert.', 'label' => 'Verwerfen und wechseln', 'gefahr' => true],
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function runExtraConfirmation(string $aktion, int|string|null $argument): void
|
||||||
|
{
|
||||||
|
match ($aktion) {
|
||||||
|
'withdrawWebsite' => $this->withdrawWebsite(),
|
||||||
|
'showVersion' => $this->ownedVersion((int) $argument) instanceof ContentElementVersion ? $this->selectVersion((int) $argument) : null,
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasDraftVersion(): bool
|
||||||
|
{
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
|
||||||
|
return $element->versions()->where('status', ContentVersionStatus::Entwurf)->exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -395,6 +611,7 @@ private function pictureCaption(ContentElement $element): string
|
|||||||
return match ($source) {
|
return match ($source) {
|
||||||
'eigen' => 'Eigenes Vorschaubild.',
|
'eigen' => 'Eigenes Vorschaubild.',
|
||||||
'datei' => 'Vorschaubild aus der Datei des Mediums.',
|
'datei' => 'Vorschaubild aus der Datei des Mediums.',
|
||||||
|
'bestand' => 'Vorschaubild aus einem Bild im Bestand. Es ist damit nicht für die Website freigegeben.',
|
||||||
default => '',
|
default => '',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -406,4 +623,461 @@ private function ownedVersion(int $id): ?ContentElementVersion
|
|||||||
|
|
||||||
return $element->versions()->whereKey($id)->first();
|
return $element->versions()->whereKey($id)->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Speichert die Redaktion: Texte, Einordnung, Präsentationsmedien und Abweichungen. Datei und Fassungen bleiben.
|
||||||
|
*/
|
||||||
|
public function saveEditorial(): void
|
||||||
|
{
|
||||||
|
$this->saveRedaktion();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function saveRedaktionTexte(): bool
|
||||||
|
{
|
||||||
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
|
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
$title = trim($this->workingTitle);
|
||||||
|
|
||||||
|
if ($title === '') {
|
||||||
|
$this->deskFeedback = 'Der Arbeitstitel fehlt. Er bezeichnet das Medium in der Verwaltung.';
|
||||||
|
$this->redaktionFehlerFeld = 'workingTitle';
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$kindError = app(EditorialVocabulary::class)->kindError(
|
||||||
|
'medium',
|
||||||
|
filled($this->kindId) ? (int) $this->kindId : null,
|
||||||
|
$element->editorial_content_kind_id !== null ? (int) $element->editorial_content_kind_id : null,
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($kindError !== null) {
|
||||||
|
$this->deskFeedback = $kindError;
|
||||||
|
$this->redaktionFehlerFeld = 'kindId';
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->versionsBeforeSave = $element->versions()->count();
|
||||||
|
app(IdentityProfile::class)->fill($element, [
|
||||||
|
'working_title' => $title,
|
||||||
|
'display_title' => $this->displayTitle,
|
||||||
|
'teaser' => $this->teaser,
|
||||||
|
'summary' => $this->summary,
|
||||||
|
'search_terms' => $this->searchTerms,
|
||||||
|
'description' => $this->descriptionText,
|
||||||
|
'usage_note' => $this->usageNote,
|
||||||
|
'license_note' => $this->licenseNote,
|
||||||
|
'website_credit' => $this->websiteCredit,
|
||||||
|
'website_alt' => $this->websiteAlt,
|
||||||
|
'editorial_content_kind_id' => filled($this->kindId) ? (int) $this->kindId : null,
|
||||||
|
], auth()->user());
|
||||||
|
app(PillarService::class)->assign($element, array_map(intval(...), $this->pillarIds));
|
||||||
|
app(IdentityDimension::class)->replaceOffered($element, array_map(intval(...), $this->dimensionIds));
|
||||||
|
|
||||||
|
$element->refresh();
|
||||||
|
$this->fillEditorial();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function redaktionSavedMessage(): string
|
||||||
|
{
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
$this->editorialFeedback = $element->versions()->count() === $this->versionsBeforeSave
|
||||||
|
? 'Gespeichert. Es gibt keine neue Fassung.'
|
||||||
|
: 'Gespeichert. Prüfe die Fassungen, ihre Zahl hat sich geändert.';
|
||||||
|
|
||||||
|
return $this->editorialFeedback.' Datei, Inhaltsfassung und Website-Freigabe bleiben unverändert.';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function resetRedaktionTexte(): void
|
||||||
|
{
|
||||||
|
$this->fillEditorial();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function einordnungUnsaved(): bool
|
||||||
|
{
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord()->fresh() ?? $this->getRecord();
|
||||||
|
$kind = filled($this->kindId) ? (int) $this->kindId : null;
|
||||||
|
$storedKind = $element->editorial_content_kind_id !== null ? (int) $element->editorial_content_kind_id : null;
|
||||||
|
|
||||||
|
if ($kind !== $storedKind) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pillars = $element->pillars()->pluck('pillars.id')->map(fn ($id): int => (int) $id)->all();
|
||||||
|
$currentPillars = array_map(intval(...), $this->pillarIds);
|
||||||
|
sort($pillars);
|
||||||
|
sort($currentPillars);
|
||||||
|
|
||||||
|
if ($pillars !== $currentPillars) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stored = IdentityDimensionValue::query()
|
||||||
|
->where('subject_type', $element->getMorphClass())
|
||||||
|
->where('subject_id', $element->getKey())
|
||||||
|
->where('origin', 'direkt')
|
||||||
|
->pluck('editorial_dimension_value_id')
|
||||||
|
->map(fn ($id): int => (int) $id)
|
||||||
|
->all();
|
||||||
|
$current = array_map(intval(...), $this->dimensionIds);
|
||||||
|
sort($stored);
|
||||||
|
sort($current);
|
||||||
|
|
||||||
|
return $stored !== $current;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{art: string, fuer: string, liste: string, zurueck: string, typ: ?string, umfang: string}
|
||||||
|
*/
|
||||||
|
public function redaktionKopf(): array
|
||||||
|
{
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'art' => 'Medium',
|
||||||
|
'fuer' => 'das Medium',
|
||||||
|
'liste' => 'Medien',
|
||||||
|
'zurueck' => 'Zurück zur Medienbearbeitung',
|
||||||
|
'typ' => $element->editorialContentKind?->label ?? PublicMaterialReader::outputLabel((string) $element->output_class),
|
||||||
|
'umfang' => '„Redaktion speichern“ sichert Texte, Präsentationsmedien und Einordnung dieses Mediums. Verwendende Ansichten übernehmen die Angaben. Datei, Inhaltsfassung und Website-Freigabe bleiben unverändert.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function redaktionTitel(): string
|
||||||
|
{
|
||||||
|
$title = trim($this->displayTitle) !== '' ? trim($this->displayTitle) : trim($this->workingTitle);
|
||||||
|
|
||||||
|
return $title !== '' ? $title : (string) $this->getRecord()->working_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function redaktionFelder(): array
|
||||||
|
{
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
$stored = fn (string $column): string => (string) ($element->getAttribute($column) ?? '');
|
||||||
|
|
||||||
|
return [
|
||||||
|
['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' => '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' => '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' => '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' => 'lizenz', 'label' => 'Interner Lizenzvermerk', 'model' => 'licenseNote', 'kind' => 'textarea', 'rows' => 3, 'gruppe' => 'weitere', 'stored' => $stored('license_note'), 'hilfe' => 'Nur intern sichtbar.'],
|
||||||
|
['id' => 'quelle', 'label' => 'Quellenzeile für die Website', 'model' => 'websiteCredit', 'kind' => 'textarea', 'rows' => 2, 'gruppe' => 'weitere', 'stored' => $stored('website_credit')],
|
||||||
|
['id' => 'alt', 'label' => 'Alternativtext für die Website', 'model' => 'websiteAlt', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('website_alt'), 'hilfe' => 'Beschreibt das Bild für Menschen, die es nicht sehen.'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{model: string, options: array<int|string, string>, hilfe: string}
|
||||||
|
*/
|
||||||
|
public function einordnungArt(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'model' => 'kindId',
|
||||||
|
'options' => app(EditorialVocabulary::class)->kindOptions('medium', $this->getRecord()->editorial_content_kind_id !== null ? (int) $this->getRecord()->editorial_content_kind_id : null),
|
||||||
|
'hilfe' => 'Fachliche Materialart, unabhängig von der technischen Medienart.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{legend: string, model: string, values: list<array{id: int, label: string}>}>
|
||||||
|
*/
|
||||||
|
public function einordnungGruppen(): array
|
||||||
|
{
|
||||||
|
$groups = [[
|
||||||
|
'legend' => 'Fachliche Säulen',
|
||||||
|
'model' => 'pillarIds',
|
||||||
|
'values' => Pillar::query()->orderBy('name')->get(['id', 'name'])
|
||||||
|
->map(fn (Pillar $pillar): array => ['id' => (int) $pillar->id, 'label' => (string) $pillar->name])->all(),
|
||||||
|
]];
|
||||||
|
|
||||||
|
foreach (app(EditorialVocabulary::class)->dimensionGroups($this->getRecord(), IdentityDimensionValue::query()
|
||||||
|
->where('subject_type', $this->getRecord()->getMorphClass())
|
||||||
|
->where('subject_id', $this->getRecord()->getKey())
|
||||||
|
->pluck('editorial_dimension_value_id')->map(fn ($id): int => (int) $id)->all()) as $dimension) {
|
||||||
|
$groups[] = [
|
||||||
|
'legend' => $dimension['label'],
|
||||||
|
'model' => 'dimensionIds',
|
||||||
|
'values' => $dimension['values'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_values(array_filter($groups, fn (array $group): bool => $group['values'] !== []));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{view: string, stand: string}
|
||||||
|
*/
|
||||||
|
public function redaktionAusgabe(): ?array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'view' => 'filament.media.preview-frame',
|
||||||
|
'stand' => 'Arbeitstitel, Anzeigename und Kurzbeschreibung zeigen deine aktuellen Eingaben, auch ungespeicherte. Bild und übrige Angaben zeigen den gespeicherten Stand.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt das Medium für die Website frei. Quellenzeile und Alternativtext gelten im gespeicherten Stand der Redaktion;
|
||||||
|
* offene Eingaben in der Redaktion werden dabei weder gespeichert noch zurückgesetzt.
|
||||||
|
*/
|
||||||
|
public function releaseForWebsite(): void
|
||||||
|
{
|
||||||
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
|
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
$this->websiteFeedback = app(WebsiteRelease::class)->release($element, auth()->user());
|
||||||
|
$element->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function withdrawWebsite(): void
|
||||||
|
{
|
||||||
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
|
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
$this->websiteFeedback = app(WebsiteRelease::class)->withdraw($element, auth()->user());
|
||||||
|
$element->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveThumbnailAlt(): void
|
||||||
|
{
|
||||||
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
|
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
app(IdentityProfile::class)->fill($element, ['thumbnail_alt' => trim($this->thumbnailAlt)], auth()->user());
|
||||||
|
$element->refresh();
|
||||||
|
$this->thumbnailAlt = (string) ($element->thumbnail_alt ?? '');
|
||||||
|
$this->pictureFeedback = 'Der Alternativtext des Vorschaubilds ist gespeichert. Die Fassung bleibt unverändert.';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Website-Seiten, die dieses Medium als Bild verwenden (CMS-Widgets und Abschnittshintergründe).
|
||||||
|
*
|
||||||
|
* @return list<array{path: string, published: bool, draft: bool}>
|
||||||
|
*/
|
||||||
|
public function websitePages(): array
|
||||||
|
{
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
|
||||||
|
return app(WebsiteImageUsage::class)->pages($element);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function websiteIsPublic(): bool
|
||||||
|
{
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
|
||||||
|
return app(WebsiteMedia::class)->present($element->fresh()) !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function adoptLibraryImage(): void
|
||||||
|
{
|
||||||
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
|
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
$detail = $this->selectionDetail();
|
||||||
|
$sourceId = (int) ($detail['element_id'] ?? 0);
|
||||||
|
$source = $sourceId > 0 ? ContentElement::query()->find($sourceId) : null;
|
||||||
|
$path = $source?->thumbnail_path;
|
||||||
|
|
||||||
|
if (! $source instanceof ContentElement || $source->output_class !== 'bild' || ! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
||||||
|
$this->pictureFeedback = 'Dieses Bild hat noch kein übernehmbares Vorschaubild.';
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$versions = $element->versions()->count();
|
||||||
|
app(IdentityProfile::class)->fill($element, [
|
||||||
|
'thumbnail_path' => $path,
|
||||||
|
'thumbnail_alt' => filled($source->thumbnail_alt) ? $source->thumbnail_alt : $source->working_title,
|
||||||
|
'thumbnail_source' => 'bestand',
|
||||||
|
'thumbnail_error' => null,
|
||||||
|
], auth()->user());
|
||||||
|
$element->refresh();
|
||||||
|
$this->thumbnailAlt = (string) ($element->thumbnail_alt ?? '');
|
||||||
|
$this->pictureFeedback = $element->versions()->count() === $versions
|
||||||
|
? 'Vorschaubild übernommen. Es gibt keine neue Fassung. Für die Website ist es damit nicht freigegeben.'
|
||||||
|
: 'Vorschaubild übernommen. Prüfe die Fassungen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{items: list<array<string, mixed>>, more: bool}
|
||||||
|
*/
|
||||||
|
public function selection(): array
|
||||||
|
{
|
||||||
|
return app(EditorialCatalog::class)->browse(
|
||||||
|
$this->pickerQuery,
|
||||||
|
$this->pickerContext === 'bild' ? 'bild' : 'alle',
|
||||||
|
'',
|
||||||
|
0,
|
||||||
|
elementsOnly: $this->pickerContext !== 'modul',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>|null
|
||||||
|
*/
|
||||||
|
public function selectionDetail(): ?array
|
||||||
|
{
|
||||||
|
if ($this->pickerSelected === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = app(EditorialCatalog::class)->rowForTarget($this->pickerSelected, 0, allowDraft: true);
|
||||||
|
|
||||||
|
if ($row === null || ! isset($row['element_id'])) {
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
$element = ContentElement::query()->with('editorialContentKind')->find((int) $row['element_id']);
|
||||||
|
|
||||||
|
if ($element instanceof ContentElement) {
|
||||||
|
$row['visibility'] = app(PublicMaterialReader::class)->visibilityNote($element);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function previewHtml(): string
|
||||||
|
{
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
$draft = [
|
||||||
|
'working_title' => $this->workingTitle,
|
||||||
|
'display_title' => $this->displayTitle,
|
||||||
|
'summary' => $this->summary,
|
||||||
|
'thumbnail_alt' => $this->thumbnailAlt,
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($this->previewSurface === 'bibliothek') {
|
||||||
|
$title = trim($this->displayTitle) !== '' ? trim($this->displayTitle) : trim($this->workingTitle);
|
||||||
|
|
||||||
|
return view('member.partials.card', [
|
||||||
|
'href' => '#vorschau',
|
||||||
|
'card' => [
|
||||||
|
'title' => $title !== '' ? $title : $element->working_title,
|
||||||
|
'summary' => trim($this->summary) !== '' ? trim($this->summary) : null,
|
||||||
|
'kind' => PublicMaterialReader::outputLabel((string) $element->output_class),
|
||||||
|
'coverage' => 'offen',
|
||||||
|
'image' => trim($this->thumbnailAlt) !== '' ? trim($this->thumbnailAlt) : $title,
|
||||||
|
'image_url' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
||||||
|
'error' => 'Vorschau der Kartenform. Ob jemand sie öffnen darf, entscheidet die Lizenz.',
|
||||||
|
],
|
||||||
|
])->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
$subject = app(PublicMaterialReader::class)->subject($element->id, true, $draft);
|
||||||
|
|
||||||
|
if ($subject === null) {
|
||||||
|
return '<p class="preview-note">Für dieses Medium liegt noch keine anzeigbare Fassung vor. Die Karte erscheint deshalb auch in der Vorschau nicht.</p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('widgets.premium_card', [
|
||||||
|
'subject' => $subject,
|
||||||
|
'context' => RenderContext::preview(),
|
||||||
|
'cardStyle' => $subject->style ?? 'media',
|
||||||
|
'imageUrl' => null,
|
||||||
|
'alt' => '',
|
||||||
|
'focus' => ['x' => 50, 'y' => 45],
|
||||||
|
'format' => 'landscape',
|
||||||
|
'fit' => 'cover',
|
||||||
|
'headingTag' => 'h3',
|
||||||
|
'show' => ['summary' => true, 'kind' => true, 'meta' => true, 'action' => true],
|
||||||
|
'actionLabel' => 'Ansehen',
|
||||||
|
'note' => null,
|
||||||
|
'stacked' => $this->previewWidth === '390',
|
||||||
|
])->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{field: string, after: string, when: string}>
|
||||||
|
*/
|
||||||
|
public function editorialHistory(): array
|
||||||
|
{
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
$labels = [
|
||||||
|
'working_title' => 'Arbeitstitel',
|
||||||
|
'display_title' => 'Anzeigename',
|
||||||
|
'teaser' => 'Teaser',
|
||||||
|
'description' => 'Beschreibung',
|
||||||
|
'summary' => 'Kurzbeschreibung',
|
||||||
|
'search_terms' => 'Suchbegriffe',
|
||||||
|
'usage_note' => 'Einsatzhinweis',
|
||||||
|
'license_note' => 'Interner Lizenzvermerk',
|
||||||
|
'website_credit' => 'Quellenzeile',
|
||||||
|
'website_alt' => 'Alternativtext der Website',
|
||||||
|
'website_released_at' => 'Website-Freigabe',
|
||||||
|
'thumbnail_alt' => 'Alternativtext',
|
||||||
|
'thumbnail_path' => 'Vorschaubild',
|
||||||
|
'thumbnail_source' => 'Herkunft des Vorschaubilds',
|
||||||
|
'editorial_content_kind_id' => 'Fachliche Materialart',
|
||||||
|
];
|
||||||
|
|
||||||
|
return IdentityChange::query()
|
||||||
|
->where('subject_type', $element->getMorphClass())
|
||||||
|
->where('subject_id', $element->id)
|
||||||
|
->latest('occurred_at')
|
||||||
|
->limit(8)
|
||||||
|
->get()
|
||||||
|
->map(fn (IdentityChange $change): array => [
|
||||||
|
'field' => $labels[$change->field] ?? $change->field,
|
||||||
|
'after' => is_scalar($change->after) ? (string) $change->after : '',
|
||||||
|
'when' => $change->occurred_at?->timezone(config('app.timezone'))->format('d.m.Y H:i') ?? '',
|
||||||
|
])
|
||||||
|
->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function usageCard(): array
|
||||||
|
{
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
|
||||||
|
return app(MediaLibrary::class)->cardFor($element, ContentElementResource::editor());
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fillEditorial(): void
|
||||||
|
{
|
||||||
|
/** @var ContentElement $element */
|
||||||
|
$element = $this->getRecord();
|
||||||
|
$this->workingTitle = (string) $element->working_title;
|
||||||
|
$this->displayTitle = (string) ($element->display_title ?? '');
|
||||||
|
$this->teaser = (string) ($element->teaser ?? '');
|
||||||
|
$this->summary = (string) ($element->summary ?? '');
|
||||||
|
$this->searchTerms = (string) ($element->search_terms ?? '');
|
||||||
|
$this->descriptionText = (string) ($element->description ?? '');
|
||||||
|
$this->usageNote = (string) ($element->usage_note ?? '');
|
||||||
|
$this->licenseNote = (string) ($element->license_note ?? '');
|
||||||
|
$this->websiteCredit = (string) ($element->website_credit ?? '');
|
||||||
|
$this->websiteAlt = (string) ($element->website_alt ?? '');
|
||||||
|
$this->kindId = $element->editorial_content_kind_id;
|
||||||
|
$this->pillarIds = $element->pillars()->pluck('pillars.id')->all();
|
||||||
|
$this->dimensionIds = IdentityDimensionValue::query()
|
||||||
|
->where('subject_type', $element->getMorphClass())
|
||||||
|
->where('subject_id', $element->id)
|
||||||
|
->where('origin', 'direkt')
|
||||||
|
->pluck('editorial_dimension_value_id')
|
||||||
|
->all();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,9 +9,8 @@
|
|||||||
use App\Filament\Support\CatalogReading;
|
use App\Filament\Support\CatalogReading;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Infolists\Components\TextEntry;
|
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Schemas\Components\Section;
|
use Filament\Schemas\Components\View;
|
||||||
use Filament\Schemas\Schema;
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Tables\Columns\TextColumn;
|
use Filament\Tables\Columns\TextColumn;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
@@ -53,15 +52,13 @@ public static function getViewAuthorizationResponse(Model $record): Response
|
|||||||
|
|
||||||
public static function infolist(Schema $schema): Schema
|
public static function infolist(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return $schema->components([
|
return $schema->columns(1)->components([
|
||||||
Section::make('Aktueller Stand')->schema([
|
View::make('filament.editorial.license-desk')
|
||||||
TextEntry::make('stand')->hiddenLabel()->listWithLineBreaks()
|
->viewData(fn (LicenseArticle $record): array => [
|
||||||
->state(fn (LicenseArticle $record): array => app(CatalogReading::class)->articleStand($record)),
|
'stand' => app(CatalogReading::class)->articleStand($record),
|
||||||
]),
|
'kontext' => app(CatalogReading::class)->articleContext($record),
|
||||||
Section::make('Pakete und Angebote')->description('Wo dieser Artikel lizenziert wird.')->schema([
|
])
|
||||||
TextEntry::make('context')->hiddenLabel()->listWithLineBreaks()
|
->columnSpanFull(),
|
||||||
->state(fn (LicenseArticle $record): array => app(CatalogReading::class)->articleContext($record)),
|
|
||||||
]),
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,15 +3,24 @@
|
|||||||
namespace App\Filament\Resources\LicenseArticles\Pages;
|
namespace App\Filament\Resources\LicenseArticles\Pages;
|
||||||
|
|
||||||
use App\Domain\Catalog\ArticleService;
|
use App\Domain\Catalog\ArticleService;
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
|
use App\Domain\Catalog\PresentationMedia;
|
||||||
|
use App\Domain\Catalog\ReleaseStatus;
|
||||||
|
use App\Domain\Catalog\StatusValue;
|
||||||
|
use App\Domain\Media\ThumbnailRef;
|
||||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||||
|
use App\Filament\Support\ListsCatalog;
|
||||||
use App\Filament\Support\ReportsDomainRules;
|
use App\Filament\Support\ReportsDomainRules;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
use Illuminate\Contracts\Support\Htmlable;
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class ListLicenseArticles extends ListRecords
|
class ListLicenseArticles extends ListRecords
|
||||||
{
|
{
|
||||||
|
use ListsCatalog;
|
||||||
use ReportsDomainRules;
|
use ReportsDomainRules;
|
||||||
|
|
||||||
protected static string $resource = LicenseArticleResource::class;
|
protected static string $resource = LicenseArticleResource::class;
|
||||||
@@ -26,15 +35,118 @@ protected function getHeaderActions(): array
|
|||||||
return [
|
return [
|
||||||
Action::make('create')
|
Action::make('create')
|
||||||
->label('Artikel anlegen')
|
->label('Artikel anlegen')
|
||||||
|
->modalHeading('Neuer Lizenzartikel')
|
||||||
|
->modalDescription('Kennung und Produktlinie genügen. Titel, Texte und Stand pflegst du danach am Artikel.')
|
||||||
|
->modalSubmitActionLabel('Artikel anlegen')
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('code')->label('Kennung')->required(),
|
TextInput::make('code')->label('Kennung')->required(),
|
||||||
TextInput::make('product_line')->label('Produktlinie'),
|
TextInput::make('product_line')->label('Produktlinie'),
|
||||||
])
|
])
|
||||||
->action(function (array $data): void {
|
->action(function (array $data): void {
|
||||||
$this->report(function () use ($data): void {
|
$article = null;
|
||||||
app(ArticleService::class)->create($data['code'], $data['product_line'] ?? null);
|
$this->report(function () use ($data, &$article): void {
|
||||||
|
$article = app(ArticleService::class)->create($data['code'], $data['product_line'] ?? null);
|
||||||
}, 'Der Lizenzartikel ist angelegt.');
|
}, 'Der Lizenzartikel ist angelegt.');
|
||||||
|
|
||||||
|
if ($article instanceof LicenseArticle) {
|
||||||
|
$this->redirect(LicenseArticleResource::getUrl('view', ['record' => $article]));
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function catalogRows(): array
|
||||||
|
{
|
||||||
|
$offered = DB::table('resolved_scopes')
|
||||||
|
->join('offer_versions', 'offer_versions.id', '=', 'resolved_scopes.offer_version_id')
|
||||||
|
->where('offer_versions.status', 'aktiv')
|
||||||
|
->distinct()
|
||||||
|
->pluck('resolved_scopes.license_article_id')
|
||||||
|
->map(fn (mixed $id): int => (int) $id)
|
||||||
|
->all();
|
||||||
|
$presentation = app(PresentationMedia::class);
|
||||||
|
$rows = [];
|
||||||
|
|
||||||
|
foreach (LicenseArticle::query()->with(['currentRelease', 'releases'])->orderBy('code')->get() as $article) {
|
||||||
|
$current = $article->currentRelease;
|
||||||
|
$currentStatus = $current !== null ? StatusValue::of($current->status) : null;
|
||||||
|
$draft = $article->releases->first(fn ($release): bool => StatusValue::of($release->status) === ReleaseStatus::Entwurf->value);
|
||||||
|
$chips = [];
|
||||||
|
$zustand = [];
|
||||||
|
|
||||||
|
if ($current === null) {
|
||||||
|
$chips[] = ['label' => 'Noch kein Stand', 'ton' => 'offen'];
|
||||||
|
$zustand[] = 'ohne';
|
||||||
|
} elseif ($currentStatus === ReleaseStatus::Gesperrt->value) {
|
||||||
|
$chips[] = ['label' => 'Stand '.$current->number.' gesperrt', 'ton' => 'achtung'];
|
||||||
|
$zustand[] = 'gesperrt';
|
||||||
|
} else {
|
||||||
|
$chips[] = ['label' => 'Stand '.$current->number.' veröffentlicht', 'ton' => 'gut'];
|
||||||
|
$zustand[] = 'stand';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($draft !== null) {
|
||||||
|
$chips[] = ['label' => 'Stand '.$draft->number.' in Arbeit', 'ton' => 'offen'];
|
||||||
|
$zustand[] = 'entwurf';
|
||||||
|
}
|
||||||
|
|
||||||
|
$inOffer = in_array($article->id, $offered, true);
|
||||||
|
$chips[] = $inOffer ? ['label' => 'In einem aktiven Angebot', 'ton' => 'gut'] : ['label' => 'In keinem aktiven Angebot', 'ton' => 'leise'];
|
||||||
|
$zustand[] = $inOffer ? 'angebot' : 'ohne-angebot';
|
||||||
|
|
||||||
|
if ($article->archived_at !== null) {
|
||||||
|
$chips[] = ['label' => 'Archiviert', 'ton' => 'leise'];
|
||||||
|
$zustand[] = 'archiviert';
|
||||||
|
}
|
||||||
|
|
||||||
|
$coverId = $presentation->coverElementId($article);
|
||||||
|
$cover = $coverId !== null ? ContentElement::query()->find($coverId) : null;
|
||||||
|
$title = trim((string) ($article->display_title ?: $article->working_title)) ?: $article->code;
|
||||||
|
$url = LicenseArticleResource::getUrl('view', ['record' => $article]);
|
||||||
|
$rows[] = [
|
||||||
|
'schluessel' => 'a'.$article->id,
|
||||||
|
'titel' => $title,
|
||||||
|
'meta' => 'Lizenzartikel · '.$article->code.(filled($article->product_line) ? ' · '.$article->product_line : ''),
|
||||||
|
'text' => trim((string) ($article->teaser ?: $article->summary)),
|
||||||
|
'bild' => $cover !== null ? ThumbnailRef::url('editorial.card', 'element', $cover->id, $cover->thumbnail_path) : null,
|
||||||
|
'symbol' => 'dokument',
|
||||||
|
'url' => $url,
|
||||||
|
'chips' => $chips,
|
||||||
|
'zustand' => $zustand,
|
||||||
|
'suchtext' => implode(' ', array_filter([$article->code, $article->working_title, $article->display_title, $article->summary, $article->product_line, $article->search_terms])),
|
||||||
|
'aktionen' => [['label' => 'Öffnen', 'href' => $url]],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function zustandOptionen(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'alle' => 'Jeder Zustand',
|
||||||
|
'stand' => 'Mit veröffentlichtem Stand',
|
||||||
|
'ohne' => 'Noch ohne Stand',
|
||||||
|
'entwurf' => 'Stand in Arbeit',
|
||||||
|
'gesperrt' => 'Gesperrter Stand',
|
||||||
|
'angebot' => 'In einem aktiven Angebot',
|
||||||
|
'ohne-angebot' => 'In keinem aktiven Angebot',
|
||||||
|
'archiviert' => 'Archiviert',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function einheit(): array
|
||||||
|
{
|
||||||
|
return ['Lizenzartikel', 'Lizenzartikel'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function leer(): array
|
||||||
|
{
|
||||||
|
return ['titel' => 'Noch keine Lizenzartikel', 'text' => 'Mit „Artikel anlegen“ oben entsteht der erste Artikel.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function suchPlatzhalter(): string
|
||||||
|
{
|
||||||
|
return 'Kennung, Titel oder Produktlinie';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,78 +3,378 @@
|
|||||||
namespace App\Filament\Resources\LicenseArticles\Pages;
|
namespace App\Filament\Resources\LicenseArticles\Pages;
|
||||||
|
|
||||||
use App\Domain\Catalog\ArticleService;
|
use App\Domain\Catalog\ArticleService;
|
||||||
|
use App\Domain\Catalog\Composition;
|
||||||
|
use App\Domain\Catalog\CompositionKind;
|
||||||
use App\Domain\Catalog\CompositionVersion;
|
use App\Domain\Catalog\CompositionVersion;
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
use App\Domain\Catalog\ContentElementVersion;
|
use App\Domain\Catalog\ContentElementVersion;
|
||||||
|
use App\Domain\Catalog\EditorialProfileReader;
|
||||||
|
use App\Domain\Catalog\EditorialVocabulary;
|
||||||
|
use App\Domain\Catalog\IdentityDimension;
|
||||||
|
use App\Domain\Catalog\IdentityDimensionValue;
|
||||||
|
use App\Domain\Catalog\IdentityProfile;
|
||||||
use App\Domain\Catalog\LicenseArticle;
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||||
use App\Filament\Support\CatalogOptions;
|
use App\Filament\Support\CatalogOptions;
|
||||||
|
use App\Filament\Support\EditorialCatalog;
|
||||||
|
use App\Filament\Support\ManagesEditorialSurface;
|
||||||
use App\Filament\Support\ReportsDomainRules;
|
use App\Filament\Support\ReportsDomainRules;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\Textarea;
|
use Filament\Forms\Components\Textarea;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class ViewLicenseArticle extends ViewRecord
|
class ViewLicenseArticle extends ViewRecord
|
||||||
{
|
{
|
||||||
|
use ManagesEditorialSurface;
|
||||||
use ReportsDomainRules;
|
use ReportsDomainRules;
|
||||||
|
|
||||||
protected static string $resource = LicenseArticleResource::class;
|
protected static string $resource = LicenseArticleResource::class;
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
public string $workingTitle = '';
|
||||||
|
|
||||||
|
public string $displayTitle = '';
|
||||||
|
|
||||||
|
public string $teaser = '';
|
||||||
|
|
||||||
|
public string $summary = '';
|
||||||
|
|
||||||
|
public string $descriptionText = '';
|
||||||
|
|
||||||
|
public string $searchTerms = '';
|
||||||
|
|
||||||
|
public int|string|null $kindId = null;
|
||||||
|
|
||||||
|
public ?int $releaseBeforeSave = null;
|
||||||
|
|
||||||
|
public int $releaseCountBeforeSave = 0;
|
||||||
|
|
||||||
|
/** @var list<int|string> */
|
||||||
|
public array $dimensionIds = [];
|
||||||
|
|
||||||
|
public function mount(int|string $record): void
|
||||||
|
{
|
||||||
|
parent::mount($record);
|
||||||
|
$this->fillLicenseEditorial();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canEditEditorial(): bool
|
||||||
|
{
|
||||||
|
return LicenseArticleResource::keeper();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function canViewEditorial(): bool
|
||||||
|
{
|
||||||
|
return LicenseArticleResource::keeper();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle(): string|Htmlable
|
||||||
|
{
|
||||||
|
return $this->redaktionTitel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveLicenseEditorial(): void
|
||||||
|
{
|
||||||
|
$this->saveRedaktion();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function saveRedaktionTexte(): bool
|
||||||
|
{
|
||||||
|
$this->guardEditorial();
|
||||||
|
|
||||||
|
/** @var LicenseArticle $article */
|
||||||
|
$article = $this->getRecord();
|
||||||
|
$this->releaseBeforeSave = $article->current_release_id;
|
||||||
|
$this->releaseCountBeforeSave = $article->releases()->count();
|
||||||
|
|
||||||
|
$kindError = app(EditorialVocabulary::class)->kindError(
|
||||||
|
'lizenzartikel',
|
||||||
|
filled($this->kindId) ? (int) $this->kindId : null,
|
||||||
|
$article->editorial_content_kind_id !== null ? (int) $article->editorial_content_kind_id : null,
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($kindError !== null) {
|
||||||
|
$this->deskFeedback = $kindError;
|
||||||
|
$this->redaktionFehlerFeld = 'kindId';
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
app(IdentityProfile::class)->fill($article, [
|
||||||
|
'working_title' => $this->workingTitle,
|
||||||
|
'display_title' => $this->displayTitle,
|
||||||
|
'teaser' => $this->teaser,
|
||||||
|
'summary' => $this->summary,
|
||||||
|
'description' => $this->descriptionText,
|
||||||
|
'search_terms' => $this->searchTerms,
|
||||||
|
'editorial_content_kind_id' => filled($this->kindId) ? (int) $this->kindId : null,
|
||||||
|
], auth()->user());
|
||||||
|
|
||||||
|
app(IdentityDimension::class)->replaceOffered($article, array_map(intval(...), $this->dimensionIds));
|
||||||
|
|
||||||
|
$article->refresh();
|
||||||
|
$this->fillLicenseEditorial();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function redaktionSavedMessage(): string
|
||||||
|
{
|
||||||
|
/** @var LicenseArticle $article */
|
||||||
|
$article = $this->getRecord();
|
||||||
|
|
||||||
|
return $article->current_release_id === $this->releaseBeforeSave && $article->releases()->count() === $this->releaseCountBeforeSave
|
||||||
|
? 'Gespeichert. Stand, Preis und Rechte bleiben unverändert.'
|
||||||
|
: 'Gespeichert. Prüfe den Artikelstand, er hat sich geändert.';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function resetRedaktionTexte(): void
|
||||||
|
{
|
||||||
|
$this->fillLicenseEditorial();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function einordnungUnsaved(): bool
|
||||||
|
{
|
||||||
|
/** @var LicenseArticle $article */
|
||||||
|
$article = $this->getRecord()->fresh() ?? $this->getRecord();
|
||||||
|
$kind = filled($this->kindId) ? (int) $this->kindId : null;
|
||||||
|
$storedKind = $article->editorial_content_kind_id !== null ? (int) $article->editorial_content_kind_id : null;
|
||||||
|
|
||||||
|
if ($kind !== $storedKind) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stored = IdentityDimensionValue::query()
|
||||||
|
->where('subject_type', $article->getMorphClass())
|
||||||
|
->where('subject_id', $article->getKey())
|
||||||
|
->where('origin', 'direkt')
|
||||||
|
->pluck('editorial_dimension_value_id')
|
||||||
|
->map(fn ($id): int => (int) $id)
|
||||||
|
->all();
|
||||||
|
$current = array_map(intval(...), $this->dimensionIds);
|
||||||
|
sort($stored);
|
||||||
|
sort($current);
|
||||||
|
|
||||||
|
return $stored !== $current;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{art: string, fuer: string, liste: string, zurueck: string, typ: ?string, umfang: string}
|
||||||
|
*/
|
||||||
|
public function redaktionKopf(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Action::make('release')
|
'art' => 'Lizenzartikel',
|
||||||
->label('Stand veröffentlichen')
|
'fuer' => 'den Lizenzartikel',
|
||||||
->schema([
|
'liste' => 'Lizenzartikel',
|
||||||
Select::make('root')->label('Wurzel')->options(fn (): array => CatalogOptions::readyTargets())->required(),
|
'zurueck' => 'Zurück zum Lizenzartikel',
|
||||||
Textarea::make('classification')->label('Einordnung')->required()
|
'typ' => null,
|
||||||
->helperText('Warum dies derselbe Lizenzartikel bleibt und kein neues Produkt ist.'),
|
'umfang' => '„Redaktion speichern“ sichert die eigenen Texte, Präsentationsmedien und Einordnung dieses Lizenzartikels. Leere Angaben übernehmen weiter die fachliche Quelle. Stand, Preis und Rechte bleiben unverändert.',
|
||||||
TextInput::make('change_note')->label('Änderungshinweis'),
|
|
||||||
])
|
|
||||||
->action(function (array $data): void {
|
|
||||||
$this->report(function () use ($data): string {
|
|
||||||
/** @var LicenseArticle $article */
|
|
||||||
$article = $this->getRecord();
|
|
||||||
[$type, $id] = explode(':', $data['root'], 2);
|
|
||||||
$root = $type === 'composition'
|
|
||||||
? CompositionVersion::query()->findOrFail($id)
|
|
||||||
: ContentElementVersion::query()->findOrFail($id);
|
|
||||||
$release = app(ArticleService::class)->publishRelease(
|
|
||||||
$article,
|
|
||||||
$root,
|
|
||||||
$data['classification'],
|
|
||||||
$data['change_note'] ?? null,
|
|
||||||
);
|
|
||||||
$report = $release->impact_report ?? [];
|
|
||||||
$offers = $report['offers'] ?? [];
|
|
||||||
|
|
||||||
return 'Stand '.$release->number.' ist veröffentlicht. Inhalte: '.($report['contents'] ?? 0)
|
|
||||||
.', Inhaber: '.($report['holders'] ?? 0)
|
|
||||||
.', Angebote: '.(implode(', ', $offers) !== '' ? implode(', ', $offers) : 'keins').'.';
|
|
||||||
}, 'Der Artikel-Stand ist veröffentlicht.');
|
|
||||||
$this->refreshRecord();
|
|
||||||
}),
|
|
||||||
Action::make('withdraw')
|
|
||||||
->label('Stand zurückziehen')
|
|
||||||
->schema([
|
|
||||||
Textarea::make('reason')->label('Begründung')->required(),
|
|
||||||
])
|
|
||||||
->action(function (array $data): void {
|
|
||||||
$this->report(function () use ($data): string {
|
|
||||||
$result = app(ArticleService::class)->withdraw($this->getRecord(), $data['reason']);
|
|
||||||
$current = $result['fallback_number'] === null
|
|
||||||
? 'Es gibt keinen früheren Stand.'
|
|
||||||
: 'Aktuell ist wieder Stand '.$result['fallback_number'].'.';
|
|
||||||
$holders = $result['holders'] === [] ? 'niemand' : implode(', ', $result['holders']);
|
|
||||||
|
|
||||||
return 'Der Stand ist zurückgezogen. '.$current.' Betroffen: '.$holders.'.';
|
|
||||||
}, 'Der Stand ist zurückgezogen.');
|
|
||||||
$this->refreshRecord();
|
|
||||||
}),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function redaktionTitel(): string
|
||||||
|
{
|
||||||
|
foreach ([$this->displayTitle, $this->workingTitle] as $title) {
|
||||||
|
if (trim($title) !== '') {
|
||||||
|
return trim($title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$profile = $this->editorialProfile('artikel');
|
||||||
|
|
||||||
|
if ($profile->value('display_title') !== null) {
|
||||||
|
return (string) $profile->value('display_title');
|
||||||
|
}
|
||||||
|
|
||||||
|
$source = $profile->source;
|
||||||
|
|
||||||
|
return $source !== null ? $this->sourceTitle($source) : (string) $this->getRecord()->code;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function redaktionFelder(): array
|
||||||
|
{
|
||||||
|
/** @var LicenseArticle $article */
|
||||||
|
$article = $this->getRecord();
|
||||||
|
$source = app(EditorialProfileReader::class)->sourceOf($article);
|
||||||
|
$sourceTitle = $source !== null ? $this->sourceTitle($source) : null;
|
||||||
|
$stored = fn (string $column): string => (string) ($article->getAttribute($column) ?? '');
|
||||||
|
$quelle = fn (string $column): ?array => $sourceTitle === null ? null : [
|
||||||
|
'titel' => $sourceTitle,
|
||||||
|
'wert' => (string) ($source->getAttribute($column) ?? ''),
|
||||||
|
];
|
||||||
|
|
||||||
|
return [
|
||||||
|
['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' => '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' => 'beschreibung', 'label' => 'Beschreibung', 'model' => 'descriptionText', 'kind' => 'textarea', 'rows' => 6, 'stored' => $stored('description'), 'quelle' => $quelle('description')],
|
||||||
|
['id' => 'suche', 'label' => 'Suchbegriffe', 'model' => 'searchTerms', 'kind' => 'text', 'gruppe' => 'weitere', 'stored' => $stored('search_terms'), 'quelle' => $quelle('search_terms')],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{titel: string, art: string, fuer: string, url: ?string}|null
|
||||||
|
*/
|
||||||
|
public function redaktionQuelle(): ?array
|
||||||
|
{
|
||||||
|
/** @var LicenseArticle $article */
|
||||||
|
$article = $this->getRecord();
|
||||||
|
$source = app(EditorialProfileReader::class)->sourceOf($article);
|
||||||
|
|
||||||
|
if ($source === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = match (true) {
|
||||||
|
$source instanceof Composition => EditorialCatalog::editUrl($source),
|
||||||
|
$source instanceof ContentElement => ContentElementResource::getUrl('view', ['record' => $source]),
|
||||||
|
default => null,
|
||||||
|
};
|
||||||
|
|
||||||
|
return [
|
||||||
|
'titel' => $this->sourceTitle($source),
|
||||||
|
'art' => $source instanceof ContentElement ? 'Medium' : ($source instanceof Composition && $source->kind === CompositionKind::Kurs ? 'Programm' : 'Modul'),
|
||||||
|
'fuer' => 'diesen Lizenzartikel',
|
||||||
|
'url' => $url,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function redaktionOhneQuelle(): string
|
||||||
|
{
|
||||||
|
return 'Keine eindeutige fachliche Quelle. Es wird nichts aus einem Modul, Programm oder Medium übernommen.';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{model: string, options: array<int|string, string>, hilfe: string}
|
||||||
|
*/
|
||||||
|
public function einordnungArt(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'model' => 'kindId',
|
||||||
|
'options' => app(EditorialVocabulary::class)->kindOptions('lizenzartikel', $this->getRecord()->editorial_content_kind_id !== null ? (int) $this->getRecord()->editorial_content_kind_id : null),
|
||||||
|
'hilfe' => 'Die Einordnung des Artikels ändert weder die Quelle noch den Preis.',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{legend: string, model: string, values: list<array{id: int, label: string}>}>
|
||||||
|
*/
|
||||||
|
public function einordnungGruppen(): array
|
||||||
|
{
|
||||||
|
return array_map(fn (array $group): array => [
|
||||||
|
'legend' => $group['label'],
|
||||||
|
'model' => 'dimensionIds',
|
||||||
|
'values' => $group['values'],
|
||||||
|
], $this->licenseDimensionGroups());
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sourceTitle(Model $source): string
|
||||||
|
{
|
||||||
|
$title = $source->getAttribute('display_title') ?: ($source->getAttribute('working_title') ?? $source->getAttribute('designation'));
|
||||||
|
|
||||||
|
return (string) $title;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{label: string, values: list<array{id: int, label: string}>}>
|
||||||
|
*/
|
||||||
|
public function licenseDimensionGroups(): array
|
||||||
|
{
|
||||||
|
return app(EditorialVocabulary::class)->dimensionGroups($this->getRecord(), IdentityDimensionValue::query()
|
||||||
|
->where('subject_type', $this->getRecord()->getMorphClass())
|
||||||
|
->where('subject_id', $this->getRecord()->getKey())
|
||||||
|
->pluck('editorial_dimension_value_id')->map(fn ($id): int => (int) $id)->all());
|
||||||
|
}
|
||||||
|
|
||||||
|
private function fillLicenseEditorial(): void
|
||||||
|
{
|
||||||
|
/** @var LicenseArticle $article */
|
||||||
|
$article = $this->getRecord();
|
||||||
|
$this->workingTitle = (string) ($article->working_title ?? '');
|
||||||
|
$this->displayTitle = (string) ($article->display_title ?? '');
|
||||||
|
$this->teaser = (string) ($article->teaser ?? '');
|
||||||
|
$this->summary = (string) ($article->summary ?? '');
|
||||||
|
$this->descriptionText = (string) ($article->description ?? '');
|
||||||
|
$this->searchTerms = (string) ($article->search_terms ?? '');
|
||||||
|
$this->kindId = $article->editorial_content_kind_id;
|
||||||
|
$this->dimensionIds = IdentityDimensionValue::query()
|
||||||
|
->where('subject_type', $article->getMorphClass())
|
||||||
|
->where('subject_id', $article->id)
|
||||||
|
->where('origin', 'direkt')
|
||||||
|
->pluck('editorial_dimension_value_id')
|
||||||
|
->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function releaseAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('release')
|
||||||
|
->label('Stand veröffentlichen')
|
||||||
|
->schema([
|
||||||
|
Select::make('root')->label('Wurzel')->options(fn (): array => CatalogOptions::readyTargets())->required(),
|
||||||
|
Textarea::make('classification')->label('Einordnung')->required()
|
||||||
|
->helperText('Warum dies derselbe Lizenzartikel bleibt und kein neues Produkt ist.'),
|
||||||
|
TextInput::make('change_note')->label('Änderungshinweis'),
|
||||||
|
])
|
||||||
|
->action(function (array $data): void {
|
||||||
|
$this->report(function () use ($data): string {
|
||||||
|
/** @var LicenseArticle $article */
|
||||||
|
$article = $this->getRecord();
|
||||||
|
[$type, $id] = explode(':', $data['root'], 2);
|
||||||
|
$root = $type === 'composition'
|
||||||
|
? CompositionVersion::query()->findOrFail($id)
|
||||||
|
: ContentElementVersion::query()->findOrFail($id);
|
||||||
|
$release = app(ArticleService::class)->publishRelease(
|
||||||
|
$article,
|
||||||
|
$root,
|
||||||
|
$data['classification'],
|
||||||
|
$data['change_note'] ?? null,
|
||||||
|
);
|
||||||
|
$report = $release->impact_report ?? [];
|
||||||
|
$offers = $report['offers'] ?? [];
|
||||||
|
|
||||||
|
return 'Stand '.$release->number.' ist veröffentlicht. Inhalte: '.($report['contents'] ?? 0)
|
||||||
|
.', Inhaber: '.($report['holders'] ?? 0)
|
||||||
|
.', Angebote: '.(implode(', ', $offers) !== '' ? implode(', ', $offers) : 'keins').'.';
|
||||||
|
}, 'Der Artikel-Stand ist veröffentlicht.');
|
||||||
|
$this->refreshRecord();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function withdrawAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('withdraw')
|
||||||
|
->label('Stand zurückziehen')
|
||||||
|
->schema([
|
||||||
|
Textarea::make('reason')->label('Begründung')->required(),
|
||||||
|
])
|
||||||
|
->action(function (array $data): void {
|
||||||
|
$this->report(function () use ($data): string {
|
||||||
|
$result = app(ArticleService::class)->withdraw($this->getRecord(), $data['reason']);
|
||||||
|
$current = $result['fallback_number'] === null
|
||||||
|
? 'Es gibt keinen früheren Stand.'
|
||||||
|
: 'Aktuell ist wieder Stand '.$result['fallback_number'].'.';
|
||||||
|
$holders = $result['holders'] === [] ? 'niemand' : implode(', ', $result['holders']);
|
||||||
|
|
||||||
|
return 'Der Stand ist zurückgezogen. '.$current.' Betroffen: '.$holders.'.';
|
||||||
|
}, 'Der Stand ist zurückgezogen.');
|
||||||
|
$this->refreshRecord();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private function refreshRecord(): void
|
private function refreshRecord(): void
|
||||||
{
|
{
|
||||||
$this->getRecord()->unsetRelations();
|
$this->getRecord()->unsetRelations();
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ class NavigationItemResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $navigationLabel = 'Navigation';
|
protected static ?string $navigationLabel = 'Navigation';
|
||||||
|
|
||||||
|
/** Menüs werden in der Webpräsenz bearbeitet. */
|
||||||
|
protected static bool $shouldRegisterNavigation = false;
|
||||||
|
|
||||||
protected static ?string $modelLabel = 'Navigationspunkt';
|
protected static ?string $modelLabel = 'Navigationspunkt';
|
||||||
|
|
||||||
protected static ?string $pluralModelLabel = 'Navigation';
|
protected static ?string $pluralModelLabel = 'Navigation';
|
||||||
|
|||||||
@@ -2,18 +2,22 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\NavigationItems\Pages;
|
namespace App\Filament\Resources\NavigationItems\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Pages\Webpraesenz;
|
||||||
use App\Filament\Resources\NavigationItems\NavigationItemResource;
|
use App\Filament\Resources\NavigationItems\NavigationItemResource;
|
||||||
use Filament\Actions\CreateAction;
|
|
||||||
use Filament\Resources\Pages\ManageRecords;
|
use Filament\Resources\Pages\ManageRecords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Die Menüs werden in der Webpräsenz bearbeitet (Dokument 13). Die bisherige Adresse führt dorthin, nach derselben
|
||||||
|
* Rechteprüfung wie bisher.
|
||||||
|
*/
|
||||||
class ManageNavigationItems extends ManageRecords
|
class ManageNavigationItems extends ManageRecords
|
||||||
{
|
{
|
||||||
protected static string $resource = NavigationItemResource::class;
|
protected static string $resource = NavigationItemResource::class;
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
public function mount(): void
|
||||||
{
|
{
|
||||||
return [
|
parent::mount();
|
||||||
CreateAction::make(),
|
|
||||||
];
|
$this->redirect(Webpraesenz::getUrl(['bereich' => 'menues']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Offers\Pages;
|
namespace App\Filament\Resources\Offers\Pages;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Offer;
|
||||||
use App\Domain\Catalog\OfferService;
|
use App\Domain\Catalog\OfferService;
|
||||||
|
use App\Domain\Catalog\OfferStatus;
|
||||||
|
use App\Domain\Catalog\StatusValue;
|
||||||
use App\Filament\Resources\Offers\OfferResource;
|
use App\Filament\Resources\Offers\OfferResource;
|
||||||
|
use App\Filament\Support\CatalogLabels;
|
||||||
|
use App\Filament\Support\ListsCatalog;
|
||||||
use App\Filament\Support\ReportsDomainRules;
|
use App\Filament\Support\ReportsDomainRules;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
@@ -12,6 +17,7 @@
|
|||||||
|
|
||||||
class ListOffers extends ListRecords
|
class ListOffers extends ListRecords
|
||||||
{
|
{
|
||||||
|
use ListsCatalog;
|
||||||
use ReportsDomainRules;
|
use ReportsDomainRules;
|
||||||
|
|
||||||
protected static string $resource = OfferResource::class;
|
protected static string $resource = OfferResource::class;
|
||||||
@@ -24,13 +30,82 @@ public function getSubheading(): string|Htmlable|null
|
|||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Action::make('create')->label('Angebot anlegen')->schema([
|
Action::make('create')->label('Angebot anlegen')
|
||||||
TextInput::make('name')->label('Name')->required(),
|
->modalHeading('Neues Angebot')
|
||||||
])->action(function (array $data): void {
|
->modalDescription('Der Name genügt. Positionen, Vergabe und Preis legst du danach am Angebot fest.')
|
||||||
$this->report(function () use ($data): void {
|
->modalSubmitActionLabel('Angebot anlegen')
|
||||||
app(OfferService::class)->create($data['name']);
|
->schema([
|
||||||
}, 'Das Angebot ist angelegt.');
|
TextInput::make('name')->label('Name')->required(),
|
||||||
}),
|
])->action(function (array $data): void {
|
||||||
|
$offer = null;
|
||||||
|
$this->report(function () use ($data, &$offer): void {
|
||||||
|
$offer = app(OfferService::class)->create($data['name']);
|
||||||
|
}, 'Das Angebot ist angelegt.');
|
||||||
|
|
||||||
|
if ($offer instanceof Offer) {
|
||||||
|
$this->redirect(OfferResource::getUrl('view', ['record' => $offer]));
|
||||||
|
}
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function catalogRows(): array
|
||||||
|
{
|
||||||
|
$rows = [];
|
||||||
|
|
||||||
|
foreach (Offer::query()->with(['versions.lines.article', 'versions.lines.bundleVersion.bundle', 'versions.lines.rights.profile'])->orderBy('name')->get() as $offer) {
|
||||||
|
$versions = $offer->versions->sortByDesc('number');
|
||||||
|
$active = $versions->first(fn ($version): bool => StatusValue::of($version->status) === OfferStatus::Aktiv->value);
|
||||||
|
$ended = $versions->filter(fn ($version): bool => StatusValue::of($version->status) === OfferStatus::Beendet->value)->count();
|
||||||
|
$chips = [];
|
||||||
|
$zustand = [];
|
||||||
|
$text = '';
|
||||||
|
|
||||||
|
if ($active !== null) {
|
||||||
|
$chips[] = ['label' => 'Fassung '.$active->number.' aktiv', 'ton' => 'gut'];
|
||||||
|
$chips[] = ['label' => CatalogLabels::vergabe($active), 'ton' => 'neutral'];
|
||||||
|
$zustand[] = 'aktiv';
|
||||||
|
$text = $active->lines->map(fn ($line): string => ($line->article !== null
|
||||||
|
? 'Lizenzartikel '.$line->article->code
|
||||||
|
: 'Paket '.($line->bundleVersion?->bundle?->name ?? '–')).' · '.($line->rights?->profile?->name ?? ''))->implode('; ');
|
||||||
|
} else {
|
||||||
|
$chips[] = ['label' => 'Keine aktive Fassung', 'ton' => 'offen'];
|
||||||
|
$zustand[] = 'ohne';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ended > 0) {
|
||||||
|
$chips[] = ['label' => $ended === 1 ? '1 beendete Fassung' : $ended.' beendete Fassungen', 'ton' => 'leise'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = OfferResource::getUrl('view', ['record' => $offer]);
|
||||||
|
$rows[] = [
|
||||||
|
'schluessel' => 'o'.$offer->id,
|
||||||
|
'titel' => $offer->name,
|
||||||
|
'meta' => 'Angebot',
|
||||||
|
'text' => $text,
|
||||||
|
'symbol' => 'etikett',
|
||||||
|
'url' => $url,
|
||||||
|
'chips' => $chips,
|
||||||
|
'zustand' => $zustand,
|
||||||
|
'aktionen' => [['label' => 'Öffnen', 'href' => $url]],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function zustandOptionen(): array
|
||||||
|
{
|
||||||
|
return ['alle' => 'Jeder Zustand', 'aktiv' => 'Mit aktiver Fassung', 'ohne' => 'Ohne aktive Fassung'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function einheit(): array
|
||||||
|
{
|
||||||
|
return ['Angebot', 'Angebote'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function leer(): array
|
||||||
|
{
|
||||||
|
return ['titel' => 'Noch keine Angebote', 'text' => 'Mit „Angebot anlegen“ oben entsteht das erste Angebot.'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,8 +7,12 @@
|
|||||||
use App\Domain\Catalog\LicenseArticle;
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
use App\Domain\Catalog\Offer;
|
use App\Domain\Catalog\Offer;
|
||||||
use App\Domain\Catalog\OfferService;
|
use App\Domain\Catalog\OfferService;
|
||||||
|
use App\Domain\Catalog\OfferStatus;
|
||||||
|
use App\Domain\Catalog\OfferVersion;
|
||||||
use App\Domain\Catalog\RightsProfileVersion;
|
use App\Domain\Catalog\RightsProfileVersion;
|
||||||
|
use App\Domain\Catalog\StatusValue;
|
||||||
use App\Filament\Resources\Offers\OfferResource;
|
use App\Filament\Resources\Offers\OfferResource;
|
||||||
|
use App\Filament\Support\CatalogLabels;
|
||||||
use App\Filament\Support\CatalogOptions;
|
use App\Filament\Support\CatalogOptions;
|
||||||
use App\Filament\Support\ReportsDomainRules;
|
use App\Filament\Support\ReportsDomainRules;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
@@ -17,17 +21,85 @@
|
|||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
use Filament\Schemas\Components\Utilities\Get;
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
|
use Filament\Schemas\Components\View;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Angebot im gemeinsamen Rahmen. Anlegen und Ändern nutzen dieselbe Maske (FACH-20): „Fassung aktivieren“ legt die
|
||||||
|
* nächste, danach unveränderliche Angebotsfassung an; bei einer Änderung ist die Maske mit der aktiven Fassung
|
||||||
|
* vorbelegt (FACH-08). Die Wirkung bleibt die bestehende von OfferService::activate.
|
||||||
|
*/
|
||||||
class ViewOffer extends ViewRecord
|
class ViewOffer extends ViewRecord
|
||||||
{
|
{
|
||||||
use ReportsDomainRules;
|
use ReportsDomainRules;
|
||||||
|
|
||||||
protected static string $resource = OfferResource::class;
|
protected static string $resource = OfferResource::class;
|
||||||
|
|
||||||
|
public function getTitle(): string|Htmlable
|
||||||
|
{
|
||||||
|
return (string) $this->getRecord()->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeading(): string|Htmlable
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMaxContentWidth(): Width|string|null
|
||||||
|
{
|
||||||
|
return Width::Full;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [];
|
||||||
Action::make('activate')->label('Fassung aktivieren')->schema([
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Der gemeinsame Objektkopf zeigt den Pfad; Filaments eigener Pfad entfällt wie bei Medien und Aufbau.
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function getBreadcrumbs(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function infolist(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema->components([
|
||||||
|
View::make('filament.catalog.objekt')->viewData(fn (): array => $this->angebotDaten())->columnSpanFull(),
|
||||||
|
])->columns(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function activeVersion(): ?OfferVersion
|
||||||
|
{
|
||||||
|
/** @var Offer $offer */
|
||||||
|
$offer = $this->getRecord();
|
||||||
|
|
||||||
|
return $offer->versions()
|
||||||
|
->where('status', OfferStatus::Aktiv)
|
||||||
|
->orderByDesc('number')
|
||||||
|
->with(['lines.article', 'lines.bundleVersion.bundle', 'lines.rights.profile'])
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function activateAction(): Action
|
||||||
|
{
|
||||||
|
return Action::make('activate')
|
||||||
|
->label(fn (): string => $this->activeVersion() !== null ? 'Geänderte Fassung aktivieren' : 'Fassung aktivieren')
|
||||||
|
->modalHeading(fn (): string => $this->activeVersion() !== null
|
||||||
|
? 'Angebot ändern: Fassung '.$this->nextNumber().' aktivieren'
|
||||||
|
: 'Erste Fassung aktivieren')
|
||||||
|
->modalDescription(fn (): string => ($active = $this->activeVersion()) !== null
|
||||||
|
? 'Die Maske ist mit Fassung '.$active->number.' vorbelegt; Inhaberart, Laufzeitregel und Steuerklasse werden übernommen. Beim Aktivieren wird Fassung '.$active->number.' beendet und bleibt unverändert gespeichert; neue Erwerbe nutzen Fassung '.$this->nextNumber().'. Bereits begründete Berechtigungen ändern sich dadurch nicht.'
|
||||||
|
: 'Positionen, Vergabe und Preis bilden die erste Fassung. Nach dem Aktivieren ist sie unveränderlich; Änderungen ergeben eine weitere Fassung.')
|
||||||
|
->modalSubmitActionLabel(fn (): string => 'Fassung '.$this->nextNumber().' aktivieren')
|
||||||
|
->modalWidth('4xl')
|
||||||
|
->fillForm(fn (): array => $this->formFromActive())
|
||||||
|
->schema([
|
||||||
Select::make('grant_kind')->label('Vergabe')->options([
|
Select::make('grant_kind')->label('Vergabe')->options([
|
||||||
'kauf' => 'Kauf',
|
'kauf' => 'Kauf',
|
||||||
'auf_abruf' => 'Auf Abruf',
|
'auf_abruf' => 'Auf Abruf',
|
||||||
@@ -57,9 +129,10 @@ protected function getHeaderActions(): array
|
|||||||
Select::make('bundle_version_id')->label('Paketfassung')->options(fn (): array => CatalogOptions::bundleVersions())
|
Select::make('bundle_version_id')->label('Paketfassung')->options(fn (): array => CatalogOptions::bundleVersions())
|
||||||
->visible(fn (Get $get): bool => $get('kind') === 'bundle'),
|
->visible(fn (Get $get): bool => $get('kind') === 'bundle'),
|
||||||
Select::make('rights_id')->label('Rechte')->options(fn (): array => CatalogOptions::rights())->required(),
|
Select::make('rights_id')->label('Rechte')->options(fn (): array => CatalogOptions::rights())->required(),
|
||||||
])->minItems(1),
|
])->minItems(1)->addActionLabel('Position hinzufügen'),
|
||||||
])->action(function (array $data): void {
|
])
|
||||||
$this->report(function () use ($data): void {
|
->action(function (array $data): void {
|
||||||
|
$this->report(function () use ($data): string {
|
||||||
/** @var Offer $offer */
|
/** @var Offer $offer */
|
||||||
$offer = $this->getRecord();
|
$offer = $this->getRecord();
|
||||||
$lines = [];
|
$lines = [];
|
||||||
@@ -74,16 +147,137 @@ protected function getHeaderActions(): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
app(OfferService::class)->activate($offer, $lines, [
|
// Bedingungen, die die Maske nicht zeigt, bleiben bei einer Änderung die der aktiven Fassung; ohne
|
||||||
|
// aktive Fassung gilt wie bisher die Vorgabe (Personen, dauerhaft).
|
||||||
|
$active = $this->activeVersion();
|
||||||
|
$kept = $active === null ? ['holder_kind' => 'person'] : [
|
||||||
|
'holder_kind' => $active->holder_kind,
|
||||||
|
'term_rule' => $active->term_rule,
|
||||||
|
'tax_class' => $active->tax_class,
|
||||||
|
'dynamic' => (bool) $active->dynamic,
|
||||||
|
];
|
||||||
|
$version = app(OfferService::class)->activate($offer, $lines, [
|
||||||
|
...$kept,
|
||||||
'grant_kind' => $data['grant_kind'],
|
'grant_kind' => $data['grant_kind'],
|
||||||
'price_cents' => $data['price_cents'] === null || $data['price_cents'] === '' ? null : (int) $data['price_cents'],
|
'price_cents' => $data['price_cents'] === null || $data['price_cents'] === '' ? null : (int) $data['price_cents'],
|
||||||
'holder_kind' => 'person',
|
|
||||||
'composition_version_id' => filled($data['composition_version_id'] ?? null) ? (int) $data['composition_version_id'] : null,
|
'composition_version_id' => filled($data['composition_version_id'] ?? null) ? (int) $data['composition_version_id'] : null,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
return 'Fassung '.$version->number.' ist aktiv.';
|
||||||
}, 'Die Angebotsfassung ist aktiv.');
|
}, 'Die Angebotsfassung ist aktiv.');
|
||||||
$this->getRecord()->unsetRelations();
|
$this->getRecord()->unsetRelations();
|
||||||
$this->getRecord()->refresh();
|
$this->getRecord()->refresh();
|
||||||
}),
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vorbelegung aus der aktiven Fassung; ohne aktive Fassung eine leere Position.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function formFromActive(): array
|
||||||
|
{
|
||||||
|
$active = $this->activeVersion();
|
||||||
|
|
||||||
|
if ($active === null) {
|
||||||
|
return ['grant_kind' => 'kauf', 'lines' => [['kind' => 'article']]];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'grant_kind' => $active->grant_kind,
|
||||||
|
'price_cents' => $active->price_cents,
|
||||||
|
'lines' => $active->lines->sortBy('position')->map(fn ($line): array => [
|
||||||
|
'kind' => $line->license_article_id !== null ? 'article' : 'bundle',
|
||||||
|
'article_id' => $line->license_article_id,
|
||||||
|
'bundle_version_id' => $line->bundle_version_id,
|
||||||
|
'rights_id' => $line->rights_profile_version_id,
|
||||||
|
])->values()->all(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function nextNumber(): int
|
||||||
|
{
|
||||||
|
return ((int) $this->getRecord()->versions()->max('number')) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Daten der gemeinsamen Katalog-Objektseite.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function angebotDaten(): array
|
||||||
|
{
|
||||||
|
/** @var Offer $offer */
|
||||||
|
$offer = $this->getRecord();
|
||||||
|
$active = $this->activeVersion();
|
||||||
|
$vergabe = $active !== null ? CatalogLabels::vergabe($active) : null;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'kopf' => [
|
||||||
|
'brot' => [['label' => 'Angebote', 'href' => OfferResource::getUrl('index')], $offer->name],
|
||||||
|
'titel' => $offer->name,
|
||||||
|
'typ' => 'Angebot',
|
||||||
|
'status' => $active !== null
|
||||||
|
? ['text' => 'Fassung '.$active->number.' aktiv · '.$vergabe, 'ton' => 'gut']
|
||||||
|
: ['text' => 'Noch keine aktive Fassung. Ein Angebot ohne aktive Fassung kann niemand erwerben.', 'ton' => 'offen'],
|
||||||
|
'aktionen' => [[
|
||||||
|
'label' => $active !== null ? 'Geänderte Fassung aktivieren' : 'Fassung aktivieren',
|
||||||
|
'wire' => "mountAction('activate')",
|
||||||
|
'art' => 'primary',
|
||||||
|
]],
|
||||||
|
],
|
||||||
|
'haupt' => [
|
||||||
|
[
|
||||||
|
'titel' => 'Positionen',
|
||||||
|
'zusatz' => $active !== null ? 'Fassung '.$active->number : null,
|
||||||
|
'hilfe' => $active !== null ? 'Vergabe: '.$vergabe.'. Diese Fassung ist unveränderlich; eine Änderung aktiviert die nächste Fassung.' : null,
|
||||||
|
'zeilen' => $active === null ? [] : $active->lines->sortBy('position')->map(fn ($line): array => [
|
||||||
|
'text' => $line->article !== null ? 'Lizenzartikel '.$line->article->code : 'Paket '.($line->bundleVersion?->bundle?->name ?? '–').' · Fassung '.($line->bundleVersion?->number ?? '–'),
|
||||||
|
'neben' => 'Rechte: '.($line->rights?->profile?->name ?? '–'),
|
||||||
|
])->values()->all(),
|
||||||
|
'leer' => ['titel' => 'Noch keine Positionen', 'text' => 'Mit „Fassung aktivieren“ legst du fest, welche Lizenzartikel oder Paketfassungen mit welchem Rechteprofil angeboten werden, wie vergeben wird und zu welchem Preis.'],
|
||||||
|
],
|
||||||
|
...($active !== null ? [[
|
||||||
|
'titel' => 'Aufgelöster Leistungsumfang',
|
||||||
|
'hilfe' => 'Diese Artikel-Rechte entstehen beim Erwerb dieser Fassung.',
|
||||||
|
'zeilen' => $this->leistungsumfang($active),
|
||||||
|
'leer' => ['titel' => 'Kein Leistungsumfang', 'text' => 'Diese Fassung hat keinen aufgelösten Leistungsumfang.'],
|
||||||
|
]] : []),
|
||||||
|
],
|
||||||
|
'seite' => [[
|
||||||
|
'titel' => 'Fassungen',
|
||||||
|
'zeilen' => $offer->versions()->orderByDesc('number')->get()->map(fn (OfferVersion $version): array => [
|
||||||
|
'text' => 'Fassung '.$version->number,
|
||||||
|
'zustand' => match (StatusValue::of($version->status)) {
|
||||||
|
'aktiv' => ['label' => 'Aktiv', 'ton' => 'gut'],
|
||||||
|
'beendet' => ['label' => 'Beendet', 'ton' => 'leise'],
|
||||||
|
default => ['label' => 'Entwurf', 'ton' => 'offen'],
|
||||||
|
},
|
||||||
|
'neben' => CatalogLabels::vergabe($version).($version->activated_at ? ' · aktiviert am '.$version->activated_at->format('d.m.Y') : ''),
|
||||||
|
])->all(),
|
||||||
|
'leer' => 'Noch keine Fassung.',
|
||||||
|
'hilfe' => 'Beendete Fassungen bleiben gespeichert; Erwerbe verweisen auf ihre Fassung. Ob ein Angebot künftig auch als Vorlage für ein weiteres dienen soll, ist fachlich noch offen (OFF-04).',
|
||||||
|
]],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aufgelöster Leistungsumfang in lesbaren Fähigkeiten (dieselben Bezeichnungen wie beim Rechteprofil).
|
||||||
|
*
|
||||||
|
* @return list<array{text: string, neben: string}>
|
||||||
|
*/
|
||||||
|
private function leistungsumfang(OfferVersion $version): array
|
||||||
|
{
|
||||||
|
$zeilen = [];
|
||||||
|
|
||||||
|
foreach ($version->resolvedScopes()->with(['article', 'rights.profile'])->get() as $scope) {
|
||||||
|
$faehigkeiten = CatalogLabels::faehigkeiten($scope->rights?->capabilities);
|
||||||
|
$zeilen[] = [
|
||||||
|
'text' => 'Lizenzartikel '.$scope->article?->code,
|
||||||
|
'neben' => ($scope->rights?->profile?->name ?? '–').': '.($faehigkeiten === [] ? 'keine Fähigkeiten' : implode(', ', $faehigkeiten)),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $zeilen;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -27,6 +27,9 @@ class PageResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $navigationLabel = 'Seiten';
|
protected static ?string $navigationLabel = 'Seiten';
|
||||||
|
|
||||||
|
/** Der Seitenbestand steht in der Webpräsenz; Anlegen und Bearbeiten bleiben hier. */
|
||||||
|
protected static bool $shouldRegisterNavigation = false;
|
||||||
|
|
||||||
protected static ?string $modelLabel = 'Seite';
|
protected static ?string $modelLabel = 'Seite';
|
||||||
|
|
||||||
protected static ?string $pluralModelLabel = 'Seiten';
|
protected static ?string $pluralModelLabel = 'Seiten';
|
||||||
@@ -38,11 +41,9 @@ public static function form(Schema $schema): Schema
|
|||||||
return $schema->components([
|
return $schema->components([
|
||||||
Section::make('Seite und Suchmaschinen')
|
Section::make('Seite und Suchmaschinen')
|
||||||
->description('Adresse, Titel für Suchmaschinen und Zuordnung zu Themenbereichen.')
|
->description('Adresse, Titel für Suchmaschinen und Zuordnung zu Themenbereichen.')
|
||||||
->collapsible()
|
|
||||||
->collapsed(fn (string $operation): bool => $operation === 'edit')
|
|
||||||
->persistCollapsed()
|
|
||||||
->columns(2)
|
->columns(2)
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
|
->extraAttributes(fn ($livewire): array => ['class' => self::registerClass($livewire, 'einstellungen')])
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('path')
|
TextInput::make('path')
|
||||||
->label('Pfad')
|
->label('Pfad')
|
||||||
@@ -63,15 +64,26 @@ public static function form(Schema $schema): Schema
|
|||||||
->columns(['default' => 1, 'lg' => 2]),
|
->columns(['default' => 1, 'lg' => 2]),
|
||||||
]),
|
]),
|
||||||
Section::make('Inhalt der Seite')
|
Section::make('Inhalt der Seite')
|
||||||
->description('Abschnitt hinzufügen, Raster wählen, Widgets in die Plätze einsetzen. Ein Klick auf die Vorschau eines Widgets öffnet seinen Dialog; Hintergrund, Breite, Abstand und Trenner stehen unter „Gestaltung des Abschnitts“. Speichern legt einen Entwurf an; veröffentlicht wird erst über „Veröffentlichen“.')
|
->description(fn ($livewire): string => is_object($livewire) && method_exists($livewire, 'openAbschnitt')
|
||||||
|
? 'Seitenaufbau: Plätze und Bausteine im Rasterverhältnis der Website. „Abschnitt gestalten“ öffnet Raster, Breite, Hintergrund, Abstände und Trenner; ein Klick auf einen Baustein öffnet seine Konfiguration. Gesichert wird mit „Entwurf speichern“, veröffentlicht erst über „Veröffentlichen …“.'
|
||||||
|
: 'Abschnitt hinzufügen, Raster wählen, Widgets in die Plätze einsetzen. Ein Klick auf die Vorschau eines Widgets öffnet seinen Dialog; Hintergrund, Breite, Abstand und Trenner stehen unter „Gestaltung des Abschnitts“. Speichern legt einen Entwurf an; veröffentlicht wird erst über „Veröffentlichen“.')
|
||||||
->columnSpanFull()
|
->columnSpanFull()
|
||||||
->extraAttributes(['class' => 'luf-page-content'])
|
->extraAttributes(fn ($livewire): array => ['class' => 'luf-page-content '.self::registerClass($livewire, 'inhalt')])
|
||||||
->schema([
|
->schema([
|
||||||
SectionEditor::repeater('sections'),
|
SectionEditor::repeater('sections'),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Im Seiten-Arbeitsplatz (EditPage) zeigt jedes Register nur seinen Teil; ausgeblendete Felder bleiben im
|
||||||
|
* Formularzustand und werden mitgespeichert. Beim Anlegen ist alles sichtbar.
|
||||||
|
*/
|
||||||
|
public static function registerClass(mixed $livewire, string $register): string
|
||||||
|
{
|
||||||
|
return is_object($livewire) && property_exists($livewire, 'register') && $livewire->register !== $register ? 'vw-ausgeblendet' : '';
|
||||||
|
}
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
|
|||||||
@@ -6,16 +6,19 @@
|
|||||||
use App\Domain\Cms\Page;
|
use App\Domain\Cms\Page;
|
||||||
use App\Domain\Cms\PageService;
|
use App\Domain\Cms\PageService;
|
||||||
use App\Filament\Resources\Pages\PageResource;
|
use App\Filament\Resources\Pages\PageResource;
|
||||||
|
use App\Filament\Support\ChoosesWebsiteImages;
|
||||||
use App\Filament\Support\ReportsSectionErrors;
|
use App\Filament\Support\ReportsSectionErrors;
|
||||||
use App\Filament\Support\SectionEditor;
|
use App\Filament\Support\SectionEditor;
|
||||||
use Filament\Resources\Pages\CreateRecord;
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
use Filament\Support\Enums\Width;
|
use Filament\Support\Enums\Width;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
class CreatePage extends CreateRecord
|
class CreatePage extends CreateRecord
|
||||||
{
|
{
|
||||||
|
use ChoosesWebsiteImages;
|
||||||
use ReportsSectionErrors;
|
use ReportsSectionErrors;
|
||||||
|
|
||||||
protected static string $resource = PageResource::class;
|
protected static string $resource = PageResource::class;
|
||||||
@@ -28,6 +31,12 @@ class CreatePage extends CreateRecord
|
|||||||
|
|
||||||
protected static bool $canCreateAnother = false;
|
protected static bool $canCreateAnother = false;
|
||||||
|
|
||||||
|
/** Gemeinsamer Bild-Picker über dem Formular und dem Bausteindialog. */
|
||||||
|
public function getFooter(): ?View
|
||||||
|
{
|
||||||
|
return view('filament.cms.bild-picker');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $data
|
* @param array<string, mixed> $data
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,17 +6,23 @@
|
|||||||
use App\Domain\Cms\Page;
|
use App\Domain\Cms\Page;
|
||||||
use App\Domain\Cms\PageService;
|
use App\Domain\Cms\PageService;
|
||||||
use App\Filament\Resources\Pages\PageResource;
|
use App\Filament\Resources\Pages\PageResource;
|
||||||
|
use App\Filament\Support\ChoosesWebsiteImages;
|
||||||
use App\Filament\Support\ReportsSectionErrors;
|
use App\Filament\Support\ReportsSectionErrors;
|
||||||
use App\Filament\Support\SectionEditor;
|
use App\Filament\Support\SectionEditor;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Pages\EditRecord;
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
use Filament\Schemas\Components\Group;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Support\Enums\Width;
|
use Filament\Support\Enums\Width;
|
||||||
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Validation\ValidationException;
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Livewire\Attributes\Url;
|
||||||
|
|
||||||
class EditPage extends EditRecord
|
class EditPage extends EditRecord
|
||||||
{
|
{
|
||||||
|
use ChoosesWebsiteImages;
|
||||||
use ReportsSectionErrors;
|
use ReportsSectionErrors;
|
||||||
|
|
||||||
protected static string $resource = PageResource::class;
|
protected static string $resource = PageResource::class;
|
||||||
@@ -27,50 +33,234 @@ class EditPage extends EditRecord
|
|||||||
/** Warnt vor dem Verlassen oder Neuladen, wenn Änderungen noch nicht gespeichert sind. */
|
/** Warnt vor dem Verlassen oder Neuladen, wenn Änderungen noch nicht gespeichert sind. */
|
||||||
protected ?bool $hasUnsavedDataChangesAlert = true;
|
protected ?bool $hasUnsavedDataChangesAlert = true;
|
||||||
|
|
||||||
|
/** Register des Seiten-Arbeitsplatzes: inhalt, einstellungen, verlauf (Dokument 12, CMS-R01). */
|
||||||
|
#[Url(as: 'bereich', except: 'inhalt')]
|
||||||
|
public string $register = 'inhalt';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kontext „Abschnitt gestalten“: Position des Abschnitts (die Repeater-Schlüssel wechseln beim Speichern,
|
||||||
|
* die Reihenfolge nicht). null ist der Seitenaufbau.
|
||||||
|
*/
|
||||||
|
#[Url(as: 'abschnitt', except: null)]
|
||||||
|
public ?int $abschnitt = null;
|
||||||
|
|
||||||
|
/** Fingerabdruck des zuletzt geladenen oder gespeicherten Stands; Grundlage für „nicht gespeichert“. */
|
||||||
|
public string $gespeicherterStand = '';
|
||||||
|
|
||||||
|
public function showRegister(string $register): void
|
||||||
|
{
|
||||||
|
$this->register = in_array($register, ['inhalt', 'einstellungen', 'verlauf'], true) ? $register : 'inhalt';
|
||||||
|
$this->abschnitt = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function openAbschnitt(string $key): void
|
||||||
|
{
|
||||||
|
$index = array_search($key, array_map('strval', array_keys($this->data['sections'] ?? [])), true);
|
||||||
|
|
||||||
|
if ($index === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->register = 'inhalt';
|
||||||
|
$this->abschnitt = (int) $index;
|
||||||
|
$this->js('window.scrollTo({ top: 0 })');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zurück zum Seitenaufbau, an die Stelle des gestalteten Abschnitts (Fokus auf „Abschnitt gestalten“).
|
||||||
|
*/
|
||||||
|
public function closeAbschnitt(): void
|
||||||
|
{
|
||||||
|
$key = $this->abschnittSchluessel();
|
||||||
|
$this->abschnitt = null;
|
||||||
|
|
||||||
|
if ($key !== null) {
|
||||||
|
$selector = json_encode('.luf-sections [x-sortable-item="'.$key.'"]');
|
||||||
|
$this->js("requestAnimationFrame(() => requestAnimationFrame(() => { const el = document.querySelector($selector); if (! el) return; window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY - 96 }); [...el.querySelectorAll('button')].find((b) => b.textContent.includes('Abschnitt gestalten'))?.focus({ preventScroll: true }); }))");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repeater-Schlüssel des gestalteten Abschnitts, aufgelöst zur Laufzeit.
|
||||||
|
*/
|
||||||
|
public function abschnittSchluessel(): ?string
|
||||||
|
{
|
||||||
|
if ($this->abschnitt === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$keys = array_map('strval', array_keys($this->data['sections'] ?? []));
|
||||||
|
|
||||||
|
return $keys[$this->abschnitt] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gemeinsamer Objektkopf statt Filaments Titel, Pfad und Kopfaktionen.
|
||||||
|
*/
|
||||||
|
public function getHeader(): ?View
|
||||||
|
{
|
||||||
|
return view('filament.cms.seite-kopf', ['seite' => $this->record, 'ungespeichert' => $this->hasUnsavedEditorChanges()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Weicht der Editorstand vom geladenen oder gespeicherten Stand ab? Verglichen wird derselbe normalisierte
|
||||||
|
* Zustand, der auch gespeichert würde; Vorschaubreiten zählen nicht.
|
||||||
|
*/
|
||||||
|
public function hasUnsavedEditorChanges(): bool
|
||||||
|
{
|
||||||
|
return $this->gespeicherterStand !== '' && $this->editorFingerprint() !== $this->gespeicherterStand;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function afterFill(): void
|
||||||
|
{
|
||||||
|
$this->gespeicherterStand = $this->editorFingerprint();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function editorFingerprint(): string
|
||||||
|
{
|
||||||
|
$data = is_array($this->data ?? null) ? $this->data : [];
|
||||||
|
$pillars = array_map('intval', (array) ($data['pillars'] ?? []));
|
||||||
|
sort($pillars);
|
||||||
|
|
||||||
|
return md5(json_encode([
|
||||||
|
self::withoutPreviewKeys(SectionEditor::fromEditorState(is_array($data['sections'] ?? null) ? $data['sections'] : [])),
|
||||||
|
(string) ($data['path'] ?? ''),
|
||||||
|
(string) ($data['seo_title'] ?? ''),
|
||||||
|
(string) ($data['seo_description'] ?? ''),
|
||||||
|
$pillars,
|
||||||
|
], JSON_UNESCAPED_UNICODE) ?: '');
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function withoutPreviewKeys(mixed $value): mixed
|
||||||
|
{
|
||||||
|
if (! is_array($value)) {
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($value['_preview_width']);
|
||||||
|
|
||||||
|
return array_map(self::withoutPreviewKeys(...), $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formular und Verlauf (Revisionen) als Register; ausgeblendete Teile bleiben im Formularzustand.
|
||||||
|
*/
|
||||||
|
public function content(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema->components([
|
||||||
|
$this->getFormContentComponent(),
|
||||||
|
Group::make([$this->getRelationManagersContentComponent()])
|
||||||
|
->extraAttributes(fn (): array => ['class' => $this->register === 'verlauf' ? '' : 'vw-ausgeblendet']),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Speichern steht im Kopf; die Leiste unter dem Formular entfällt.
|
||||||
|
*/
|
||||||
|
protected function getFormActions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ein Fehler in einem gerade ausgeblendeten Register oder Abschnittsteil wird sichtbar gemacht (CMS-12).
|
||||||
|
*/
|
||||||
|
public function save(bool $shouldRedirect = true, bool $shouldSendSavedNotification = true): void
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
parent::save($shouldRedirect, $shouldSendSavedNotification);
|
||||||
|
} catch (ValidationException $exception) {
|
||||||
|
$keys = implode(' ', array_keys($exception->errors()));
|
||||||
|
$this->register = str_contains($keys, 'data.sections') ? 'inhalt' : (preg_match('/data\.(path|seo_|pillars)/', $keys) === 1 ? 'einstellungen' : $this->register);
|
||||||
|
$this->showFailingSection(array_keys($exception->errors()));
|
||||||
|
|
||||||
|
throw $exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raster und Gestaltung stehen nur im Kontext „Abschnitt gestalten“, andere Abschnitte sind dort ausgeblendet.
|
||||||
|
* Liegt der Fehler im gestalteten Abschnitt, bleibt der Kontext. Ein Raster- oder Gestaltungsfehler öffnet den
|
||||||
|
* betroffenen Abschnitt; jeder andere Abschnittsfehler (etwa die Platzübersicht) steht im Seitenaufbau.
|
||||||
|
*
|
||||||
|
* @param list<string> $errorKeys
|
||||||
|
*/
|
||||||
|
private function showFailingSection(array $errorKeys): void
|
||||||
|
{
|
||||||
|
$sectionKeys = array_map('strval', array_keys($this->data['sections'] ?? []));
|
||||||
|
$failing = [];
|
||||||
|
$design = null;
|
||||||
|
|
||||||
|
foreach ($errorKeys as $key) {
|
||||||
|
if (preg_match('/^data\.sections\.([^.]+)(?:\.(.*))?$/', $key, $match) !== 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$index = array_search($match[1], $sectionKeys, true);
|
||||||
|
if ($index === false) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$failing[] = $index;
|
||||||
|
if ($design === null && preg_match('/^(layout|style)(\.|$)/', $match[2] ?? '') === 1) {
|
||||||
|
$design = $index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($failing === [] || ($this->abschnitt !== null && in_array($this->abschnitt, $failing, true))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->abschnitt = $design;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* „Entwurf speichern“ aus dem Bausteindialog: Der Baustein ist bereits übernommen, der Dialog schließt. Ein Fehler
|
||||||
|
* wird wie beim Speichern im Kopf gezeigt (Register, Abschnitt, Meldung), ohne den Baustein erneut zu öffnen.
|
||||||
|
*/
|
||||||
|
public function saveFromBlock(): void
|
||||||
|
{
|
||||||
|
// Nach einer Dialogaktion rendert Filament sonst nur den Dialog neu; der Kopf zeigte den alten Speicherstand.
|
||||||
|
$this->forceRender();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->save(shouldRedirect: false);
|
||||||
|
} catch (ValidationException $exception) {
|
||||||
|
foreach ($exception->errors() as $key => $messages) {
|
||||||
|
foreach ((array) $messages as $message) {
|
||||||
|
$this->addError($key, $message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [];
|
||||||
Action::make('preview')
|
}
|
||||||
->label('Vorschau')
|
|
||||||
->icon('heroicon-o-device-phone-mobile')
|
|
||||||
->color('gray')
|
|
||||||
->tooltip('Zuletzt gespeicherten Entwurf in Smartphone-, Tablet- und Desktopbreite ansehen')
|
|
||||||
->url(function (): string {
|
|
||||||
$revision = $this->record->latestRevision;
|
|
||||||
|
|
||||||
return $revision === null
|
public function publishAction(): Action
|
||||||
? '#'
|
{
|
||||||
: route('pages.preview.devices', $revision);
|
return Action::make('publish')
|
||||||
})
|
->label('Veröffentlichen')
|
||||||
->openUrlInNewTab(),
|
->icon('heroicon-o-globe-alt')
|
||||||
Action::make('publish')
|
->requiresConfirmation()
|
||||||
->label('Veröffentlichen')
|
->modalHeading('Seite veröffentlichen?')
|
||||||
->icon('heroicon-o-globe-alt')
|
->modalDescription('Der aktuelle Stand im Editor wird als Entwurf gespeichert und genau dieser Stand wird veröffentlicht. Enthält er Fehler, wird nichts veröffentlicht.')
|
||||||
->requiresConfirmation()
|
->modalSubmitActionLabel('Speichern und veröffentlichen')
|
||||||
->modalHeading('Seite veröffentlichen?')
|
->visible(fn (): bool => auth()->user()?->can('publish', $this->record) ?? false)
|
||||||
->modalDescription('Der aktuelle Stand im Editor wird als Entwurf gespeichert und genau dieser Stand wird veröffentlicht. Enthält er Fehler, wird nichts veröffentlicht.')
|
->action(function (PageService $service): void {
|
||||||
->modalSubmitActionLabel('Speichern und veröffentlichen')
|
// Ungespeicherte Änderungen (zum Beispiel ein eben gewähltes Bild) gingen sonst beim Veröffentlichen verloren.
|
||||||
->visible(fn (): bool => auth()->user()?->can('publish', $this->record) ?? false)
|
$this->save(shouldRedirect: false, shouldSendSavedNotification: false);
|
||||||
->action(function (PageService $service): void {
|
|
||||||
// Ungespeicherte Änderungen (zum Beispiel ein eben gewähltes Bild) gingen sonst beim Veröffentlichen verloren.
|
|
||||||
$this->save(shouldRedirect: false, shouldSendSavedNotification: false);
|
|
||||||
|
|
||||||
$this->record->unsetRelation('latestRevision');
|
$this->record->unsetRelation('latestRevision');
|
||||||
$revision = $this->record->latestRevision;
|
$revision = $this->record->latestRevision;
|
||||||
abort_if($revision === null, 404);
|
abort_if($revision === null, 404);
|
||||||
$service->publish($this->record, $revision);
|
$service->publish($this->record, $revision);
|
||||||
$this->record->refresh();
|
$this->record->refresh();
|
||||||
|
|
||||||
Notification::make()->title('Seite veröffentlicht')->success()->send();
|
Notification::make()->title('Seite veröffentlicht')->success()->send();
|
||||||
}),
|
});
|
||||||
Action::make('open')
|
|
||||||
->label('Live-Seite')
|
|
||||||
->icon('heroicon-o-arrow-top-right-on-square')
|
|
||||||
->color('gray')
|
|
||||||
->visible(fn (): bool => $this->record->isPublished())
|
|
||||||
->url(fn (): string => $this->record->publicUrl())
|
|
||||||
->openUrlInNewTab(),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getSaveFormAction(): Action
|
protected function getSaveFormAction(): Action
|
||||||
|
|||||||
@@ -2,18 +2,22 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Pages\Pages;
|
namespace App\Filament\Resources\Pages\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Pages\Webpraesenz;
|
||||||
use App\Filament\Resources\Pages\PageResource;
|
use App\Filament\Resources\Pages\PageResource;
|
||||||
use Filament\Actions\CreateAction;
|
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Der Seitenbestand steht in der Webpräsenz (Dokument 13). Die bisherige Adresse führt dorthin, nach derselben
|
||||||
|
* Rechteprüfung wie bisher.
|
||||||
|
*/
|
||||||
class ListPages extends ListRecords
|
class ListPages extends ListRecords
|
||||||
{
|
{
|
||||||
protected static string $resource = PageResource::class;
|
protected static string $resource = PageResource::class;
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
public function mount(): void
|
||||||
{
|
{
|
||||||
return [
|
parent::mount();
|
||||||
CreateAction::make(),
|
|
||||||
];
|
$this->redirect(Webpraesenz::getUrl());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,9 @@ class RevisionsRelationManager extends RelationManager
|
|||||||
|
|
||||||
protected static ?string $title = 'Revisionen';
|
protected static ?string $title = 'Revisionen';
|
||||||
|
|
||||||
|
/** Steht im Register „Verlauf“ zunächst ausgeblendet; verzögertes Laden würde dort nie ausgelöst. */
|
||||||
|
protected static ?bool $isLazyLoaded = false;
|
||||||
|
|
||||||
public function table(Table $table): Table
|
public function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Pillars\Pages;
|
namespace App\Filament\Resources\Pillars\Pages;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Pillar;
|
||||||
use App\Domain\Catalog\PillarService;
|
use App\Domain\Catalog\PillarService;
|
||||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
use App\Filament\Resources\Pillars\PillarResource;
|
use App\Filament\Resources\Pillars\PillarResource;
|
||||||
|
use App\Filament\Support\ListsCatalog;
|
||||||
use App\Filament\Support\ReportsDomainRules;
|
use App\Filament\Support\ReportsDomainRules;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
@@ -13,6 +15,7 @@
|
|||||||
|
|
||||||
class ListPillars extends ListRecords
|
class ListPillars extends ListRecords
|
||||||
{
|
{
|
||||||
|
use ListsCatalog;
|
||||||
use ReportsDomainRules;
|
use ReportsDomainRules;
|
||||||
|
|
||||||
protected static string $resource = PillarResource::class;
|
protected static string $resource = PillarResource::class;
|
||||||
@@ -27,6 +30,9 @@ protected function getHeaderActions(): array
|
|||||||
return [
|
return [
|
||||||
Action::make('create')
|
Action::make('create')
|
||||||
->label('Säule anlegen')
|
->label('Säule anlegen')
|
||||||
|
->modalHeading('Neue fachliche Säule')
|
||||||
|
->modalDescription('Der Name genügt. Website-Text, Adresse und Veröffentlichung legst du danach fest.')
|
||||||
|
->modalSubmitActionLabel('Säule anlegen')
|
||||||
->visible(fn (): bool => ContentElementResource::editor())
|
->visible(fn (): bool => ContentElementResource::editor())
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('name')->label('Name')->required(),
|
TextInput::make('name')->label('Name')->required(),
|
||||||
@@ -43,4 +49,45 @@ protected function getHeaderActions(): array
|
|||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function catalogRows(): array
|
||||||
|
{
|
||||||
|
$rows = [];
|
||||||
|
|
||||||
|
foreach (Pillar::query()->withCount('elements')->orderBy('sort_order')->orderBy('name')->get() as $pillar) {
|
||||||
|
$public = $pillar->published_at !== null;
|
||||||
|
$url = PillarResource::getUrl('edit', ['record' => $pillar]);
|
||||||
|
$rows[] = [
|
||||||
|
'schluessel' => 's'.$pillar->id,
|
||||||
|
'titel' => $pillar->name,
|
||||||
|
'meta' => 'Fachliche Säule'.(filled($pillar->slug) ? ' · /themen/'.$pillar->slug : ''),
|
||||||
|
'text' => (string) ($pillar->public_summary ?? ''),
|
||||||
|
'symbol' => 'modul',
|
||||||
|
'url' => $url,
|
||||||
|
'chips' => [
|
||||||
|
$public ? ['label' => 'Auf der Website veröffentlicht', 'ton' => 'gut'] : ['label' => 'Intern', 'ton' => 'leise'],
|
||||||
|
['label' => $pillar->elements_count === 1 ? '1 Medium' : $pillar->elements_count.' Medien', 'ton' => 'neutral'],
|
||||||
|
],
|
||||||
|
'zustand' => [$public ? 'oeffentlich' : 'intern'],
|
||||||
|
'aktionen' => [['label' => 'Bearbeiten', 'href' => $url, 'icon' => 'stift']],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function zustandOptionen(): array
|
||||||
|
{
|
||||||
|
return ['alle' => 'Jeder Zustand', 'oeffentlich' => 'Auf der Website veröffentlicht', 'intern' => 'Intern'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function einheit(): array
|
||||||
|
{
|
||||||
|
return ['Fachliche Säule', 'Fachliche Säulen'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function leer(): array
|
||||||
|
{
|
||||||
|
return ['titel' => 'Noch keine Säulen', 'text' => 'Mit „Säule anlegen“ oben entsteht die erste Säule.'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,10 @@
|
|||||||
namespace App\Filament\Resources\RightsProfiles\Pages;
|
namespace App\Filament\Resources\RightsProfiles\Pages;
|
||||||
|
|
||||||
use App\Domain\Catalog\OfferService;
|
use App\Domain\Catalog\OfferService;
|
||||||
|
use App\Domain\Catalog\RightsProfile;
|
||||||
use App\Filament\Resources\RightsProfiles\RightsProfileResource;
|
use App\Filament\Resources\RightsProfiles\RightsProfileResource;
|
||||||
|
use App\Filament\Support\CatalogLabels;
|
||||||
|
use App\Filament\Support\ListsCatalog;
|
||||||
use App\Filament\Support\ReportsDomainRules;
|
use App\Filament\Support\ReportsDomainRules;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\CheckboxList;
|
use Filament\Forms\Components\CheckboxList;
|
||||||
@@ -14,6 +17,7 @@
|
|||||||
|
|
||||||
class ListRightsProfiles extends ListRecords
|
class ListRightsProfiles extends ListRecords
|
||||||
{
|
{
|
||||||
|
use ListsCatalog;
|
||||||
use ReportsDomainRules;
|
use ReportsDomainRules;
|
||||||
|
|
||||||
protected static string $resource = RightsProfileResource::class;
|
protected static string $resource = RightsProfileResource::class;
|
||||||
@@ -26,36 +30,78 @@ public function getSubheading(): string|Htmlable|null
|
|||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Action::make('create')->label('Rechteprofil anlegen')->schema([
|
Action::make('create')->label('Rechteprofil anlegen')
|
||||||
TextInput::make('name')->label('Name')->required(),
|
->modalHeading('Neues Rechteprofil')
|
||||||
Select::make('purpose')->label('Zweck')->options([
|
->modalDescription('Zweck und erlaubte Handlungen. Ein Angebot verbindet das Profil später mit Artikeln.')
|
||||||
'ehrenamtlich' => 'Ehrenamtlich',
|
->modalSubmitActionLabel('Rechteprofil anlegen')
|
||||||
'kommerziell' => 'Kommerziell',
|
->schema([
|
||||||
'institutionell' => 'Institutionell',
|
TextInput::make('name')->label('Name')->required(),
|
||||||
])->required(),
|
Select::make('purpose')->label('Zweck')->options([
|
||||||
CheckboxList::make('capabilities')->label('Fähigkeiten')->options([
|
'ehrenamtlich' => 'Ehrenamtlich',
|
||||||
'film:streamen' => 'Film ansehen',
|
'kommerziell' => 'Kommerziell',
|
||||||
'film:laden' => 'Film herunterladen',
|
'institutionell' => 'Institutionell',
|
||||||
'audio:streamen' => 'Hörstück ansehen',
|
])->required(),
|
||||||
'document:ansehen' => 'Dokument ansehen',
|
CheckboxList::make('capabilities')->label('Fähigkeiten')->options(CatalogLabels::FAEHIGKEITEN)->required(),
|
||||||
'document:laden' => 'Dokument herunterladen',
|
])->action(function (array $data): void {
|
||||||
'pdf:ansehen' => 'PDF ansehen',
|
$this->report(function () use ($data): void {
|
||||||
'pdf:laden' => 'PDF herunterladen',
|
$capabilities = [];
|
||||||
'text:ansehen' => 'Text ansehen',
|
|
||||||
'bild:ansehen' => 'Bild ansehen',
|
|
||||||
])->required(),
|
|
||||||
])->action(function (array $data): void {
|
|
||||||
$this->report(function () use ($data): void {
|
|
||||||
$capabilities = [];
|
|
||||||
|
|
||||||
foreach ($data['capabilities'] as $entry) {
|
foreach ($data['capabilities'] as $entry) {
|
||||||
[$class, $action] = explode(':', $entry, 2);
|
[$class, $action] = explode(':', $entry, 2);
|
||||||
$capabilities[$class][] = $action;
|
$capabilities[$class][] = $action;
|
||||||
}
|
}
|
||||||
|
|
||||||
app(OfferService::class)->createRightsProfile($data['name'], $data['purpose'], $capabilities);
|
app(OfferService::class)->createRightsProfile($data['name'], $data['purpose'], $capabilities);
|
||||||
}, 'Das Rechteprofil ist angelegt.');
|
}, 'Das Rechteprofil ist angelegt.');
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function catalogRows(): array
|
||||||
|
{
|
||||||
|
$rows = [];
|
||||||
|
|
||||||
|
foreach (RightsProfile::query()->with('versions')->orderBy('name')->get() as $profile) {
|
||||||
|
$version = $profile->versions->sortByDesc('number')->first();
|
||||||
|
$faehigkeiten = CatalogLabels::faehigkeiten($version?->capabilities);
|
||||||
|
$purpose = CatalogLabels::zweck($version?->purpose);
|
||||||
|
$chips = $version === null
|
||||||
|
? [['label' => 'Noch keine Fassung', 'ton' => 'offen']]
|
||||||
|
: [['label' => 'Fassung '.$version->number, 'ton' => 'neutral'], ['label' => $purpose, 'ton' => 'leise']];
|
||||||
|
|
||||||
|
if ($version?->locked_at !== null) {
|
||||||
|
$chips[] = ['label' => 'Festgeschrieben', 'ton' => 'leise'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = RightsProfileResource::getUrl('view', ['record' => $profile]);
|
||||||
|
$rows[] = [
|
||||||
|
'schluessel' => 'r'.$profile->id,
|
||||||
|
'titel' => $profile->name,
|
||||||
|
'meta' => 'Rechteprofil',
|
||||||
|
'text' => $faehigkeiten === [] ? 'Keine Fähigkeiten' : implode(', ', $faehigkeiten),
|
||||||
|
'symbol' => 'schluessel',
|
||||||
|
'url' => $url,
|
||||||
|
'chips' => $chips,
|
||||||
|
'zustand' => [(string) $version?->purpose],
|
||||||
|
'aktionen' => [['label' => 'Öffnen', 'href' => $url]],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function zustandOptionen(): array
|
||||||
|
{
|
||||||
|
return ['alle' => 'Jeder Zweck', 'ehrenamtlich' => 'Ehrenamtlich', 'kommerziell' => 'Kommerziell', 'institutionell' => 'Institutionell'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function einheit(): array
|
||||||
|
{
|
||||||
|
return ['Rechteprofil', 'Rechteprofile'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function leer(): array
|
||||||
|
{
|
||||||
|
return ['titel' => 'Noch keine Rechteprofile', 'text' => 'Mit „Rechteprofil anlegen“ oben entsteht das erste Profil.'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,119 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\RightsProfiles\Pages;
|
namespace App\Filament\Resources\RightsProfiles\Pages;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\OfferLine;
|
||||||
|
use App\Domain\Catalog\OfferStatus;
|
||||||
|
use App\Domain\Catalog\RightsProfile;
|
||||||
|
use App\Domain\Catalog\RightsProfileVersion;
|
||||||
|
use App\Domain\Catalog\StatusValue;
|
||||||
use App\Filament\Resources\RightsProfiles\RightsProfileResource;
|
use App\Filament\Resources\RightsProfiles\RightsProfileResource;
|
||||||
|
use App\Filament\Support\CatalogLabels;
|
||||||
use Filament\Resources\Pages\ViewRecord;
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
use Filament\Schemas\Components\View;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rechteprofil in der gemeinsamen Katalog-Objektseite: Zweck, erlaubte Handlungen und Verwendung in Angeboten.
|
||||||
|
* Ein Rechteprofil wird hier nur gelesen; es gibt keine Bearbeitung.
|
||||||
|
*/
|
||||||
class ViewRightsProfile extends ViewRecord
|
class ViewRightsProfile extends ViewRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = RightsProfileResource::class;
|
protected static string $resource = RightsProfileResource::class;
|
||||||
|
|
||||||
|
public function getTitle(): string|Htmlable
|
||||||
|
{
|
||||||
|
return (string) $this->getRecord()->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeading(): string|Htmlable
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function getBreadcrumbs(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMaxContentWidth(): Width|string|null
|
||||||
|
{
|
||||||
|
return Width::Full;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function infolist(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema->components([
|
||||||
|
View::make('filament.catalog.objekt')->viewData(fn (): array => $this->profilDaten())->columnSpanFull(),
|
||||||
|
])->columns(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function profilDaten(): array
|
||||||
|
{
|
||||||
|
/** @var RightsProfile $profile */
|
||||||
|
$profile = $this->getRecord();
|
||||||
|
$versions = $profile->versions()->orderByDesc('number')->get();
|
||||||
|
$current = $versions->first();
|
||||||
|
$faehigkeiten = CatalogLabels::faehigkeiten($current?->capabilities);
|
||||||
|
$optionen = collect($current?->options ?? [])->map(fn (mixed $wert, string $schluessel): array => [
|
||||||
|
'text' => $schluessel,
|
||||||
|
'neben' => is_scalar($wert) ? (string) $wert : json_encode($wert, JSON_UNESCAPED_UNICODE),
|
||||||
|
])->values()->all();
|
||||||
|
$verwendung = OfferLine::query()
|
||||||
|
->whereIn('rights_profile_version_id', $versions->pluck('id'))
|
||||||
|
->with(['offerVersion.offer', 'article', 'bundleVersion.bundle'])
|
||||||
|
->get()
|
||||||
|
->map(fn (OfferLine $line): array => [
|
||||||
|
'text' => ($line->offerVersion?->offer?->name ?? 'Angebot').' · Fassung '.($line->offerVersion?->number ?? '–'),
|
||||||
|
'zustand' => StatusValue::of($line->offerVersion?->status) === OfferStatus::Aktiv->value
|
||||||
|
? ['label' => 'Aktiv', 'ton' => 'gut']
|
||||||
|
: ['label' => StatusValue::of($line->offerVersion?->status) === OfferStatus::Beendet->value ? 'Beendet' : 'Entwurf', 'ton' => 'leise'],
|
||||||
|
'neben' => $line->article !== null ? 'Lizenzartikel '.$line->article->code : 'Paket '.($line->bundleVersion?->bundle?->name ?? '–'),
|
||||||
|
])->all();
|
||||||
|
|
||||||
|
return [
|
||||||
|
'kopf' => [
|
||||||
|
'brot' => [['label' => 'Rechteprofile', 'href' => RightsProfileResource::getUrl('index')], $profile->name],
|
||||||
|
'titel' => $profile->name,
|
||||||
|
'typ' => 'Rechteprofil',
|
||||||
|
'status' => $current === null
|
||||||
|
? ['text' => 'Noch keine Fassung', 'ton' => 'offen']
|
||||||
|
: ['text' => 'Fassung '.$current->number.' · '.CatalogLabels::zweck($current->purpose).($current->locked_at !== null ? ' · festgeschrieben seit '.$current->locked_at->format('d.m.Y') : ''), 'ton' => 'neutral'],
|
||||||
|
],
|
||||||
|
'haupt' => [
|
||||||
|
[
|
||||||
|
'titel' => 'Erlaubte Handlungen',
|
||||||
|
'zusatz' => $current !== null ? 'Fassung '.$current->number : null,
|
||||||
|
'hilfe' => $current?->locked_at !== null
|
||||||
|
? 'Diese Fassung wird in einem aktiven Angebot verwendet und ist deshalb unveränderlich.'
|
||||||
|
: 'Zweck und erlaubte Handlungen. Angebote verbinden das Profil mit Lizenzartikeln.',
|
||||||
|
'zeilen' => array_map(fn (string $label): array => ['text' => $label], $faehigkeiten),
|
||||||
|
'leer' => ['titel' => 'Keine Handlungen', 'text' => 'Diese Fassung erlaubt keine Handlung.'],
|
||||||
|
],
|
||||||
|
...($optionen !== [] ? [['titel' => 'Optionen', 'zeilen' => $optionen]] : []),
|
||||||
|
],
|
||||||
|
'seite' => [
|
||||||
|
[
|
||||||
|
'titel' => 'In Angeboten',
|
||||||
|
'zeilen' => $verwendung,
|
||||||
|
'leer' => 'In keinem Angebot verwendet.',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'titel' => 'Fassungen',
|
||||||
|
'zeilen' => $versions->map(fn (RightsProfileVersion $version): array => [
|
||||||
|
'text' => 'Fassung '.$version->number,
|
||||||
|
'zustand' => $version->locked_at !== null ? ['label' => 'Festgeschrieben', 'ton' => 'leise'] : null,
|
||||||
|
'neben' => CatalogLabels::zweck($version->purpose),
|
||||||
|
])->all(),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,18 +2,70 @@
|
|||||||
|
|
||||||
namespace App\Filament\Resources\Users\Pages;
|
namespace App\Filament\Resources\Users\Pages;
|
||||||
|
|
||||||
|
use App\Domain\Identity\AccountStatus;
|
||||||
|
use App\Domain\Identity\StaffRole;
|
||||||
use App\Filament\Resources\Users\UserResource;
|
use App\Filament\Resources\Users\UserResource;
|
||||||
|
use App\Filament\Support\ListsCatalog;
|
||||||
|
use App\Models\User;
|
||||||
use Filament\Actions\CreateAction;
|
use Filament\Actions\CreateAction;
|
||||||
use Filament\Resources\Pages\ListRecords;
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
class ListUsers extends ListRecords
|
class ListUsers extends ListRecords
|
||||||
{
|
{
|
||||||
|
use ListsCatalog;
|
||||||
|
|
||||||
protected static string $resource = UserResource::class;
|
protected static string $resource = UserResource::class;
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
CreateAction::make(),
|
CreateAction::make()->label('Benutzer anlegen'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function catalogRows(): array
|
||||||
|
{
|
||||||
|
$rows = [];
|
||||||
|
|
||||||
|
foreach (User::query()->with('staffRoles')->orderBy('name')->get() as $user) {
|
||||||
|
$status = $user->status instanceof AccountStatus ? $user->status->label() : (string) $user->status;
|
||||||
|
$rollen = $user->staffRoles->map(fn ($role): string => $role->role instanceof StaffRole ? $role->role->label() : StaffRole::from((string) $role->role)->label())->all();
|
||||||
|
$url = UserResource::getUrl('edit', ['record' => $user]);
|
||||||
|
$rows[] = [
|
||||||
|
'schluessel' => 'u'.$user->id,
|
||||||
|
'titel' => (string) $user->name,
|
||||||
|
'meta' => (string) $user->email,
|
||||||
|
'symbol' => 'schluessel',
|
||||||
|
'url' => $url,
|
||||||
|
'chips' => [
|
||||||
|
['label' => $status !== '' ? $status : 'Ohne Status', 'ton' => 'neutral'],
|
||||||
|
...array_map(fn (string $rolle): array => ['label' => $rolle, 'ton' => 'gut'], $rollen),
|
||||||
|
],
|
||||||
|
'zustand' => $rollen === [] ? ['ohne-rolle'] : ['mit-rolle'],
|
||||||
|
'aktionen' => [['label' => 'Bearbeiten', 'href' => $url, 'icon' => 'stift']],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function zustandOptionen(): array
|
||||||
|
{
|
||||||
|
return ['alle' => 'Alle Konten', 'mit-rolle' => 'Mit Verwaltungsrolle', 'ohne-rolle' => 'Ohne Verwaltungsrolle'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function einheit(): array
|
||||||
|
{
|
||||||
|
return ['Konto', 'Konten'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function leer(): array
|
||||||
|
{
|
||||||
|
return ['titel' => 'Noch keine Konten', 'text' => 'Mit „Benutzer anlegen“ oben entsteht das erste Konto.'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function suchPlatzhalter(): string
|
||||||
|
{
|
||||||
|
return 'Name oder E-Mail';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Werte der gemeinsamen Bestandsliste (ShowsBestand, Ansicht filament.verwaltung.bestand).
|
||||||
|
*/
|
||||||
|
final class Bestand
|
||||||
|
{
|
||||||
|
/** So viele Einträge zeigt eine Liste zunächst und je „Weitere anzeigen“. */
|
||||||
|
public const SCHRITT = 50;
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\OfferVersion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lesbare Bezeichnungen für Katalogangaben, gemeinsam für Listen und Objektseiten (Rechteprofil, Angebot).
|
||||||
|
*/
|
||||||
|
final class CatalogLabels
|
||||||
|
{
|
||||||
|
/** Fähigkeiten eines Rechteprofils; dieselben Werte wie im Anlegedialog. */
|
||||||
|
public const FAEHIGKEITEN = [
|
||||||
|
'film:streamen' => 'Film ansehen',
|
||||||
|
'film:laden' => 'Film herunterladen',
|
||||||
|
'audio:streamen' => 'Hörstück ansehen',
|
||||||
|
'document:ansehen' => 'Dokument ansehen',
|
||||||
|
'document:laden' => 'Dokument herunterladen',
|
||||||
|
'pdf:ansehen' => 'PDF ansehen',
|
||||||
|
'pdf:laden' => 'PDF herunterladen',
|
||||||
|
'text:ansehen' => 'Text ansehen',
|
||||||
|
'bild:ansehen' => 'Bild ansehen',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed>|null $capabilities ['film' => ['streamen'], …]
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
public static function faehigkeiten(?array $capabilities): array
|
||||||
|
{
|
||||||
|
$labels = [];
|
||||||
|
|
||||||
|
foreach ($capabilities ?? [] as $class => $actions) {
|
||||||
|
foreach ((array) $actions as $action) {
|
||||||
|
$labels[] = self::FAEHIGKEITEN[$class.':'.$action] ?? $class.': '.$action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $labels;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function zweck(?string $purpose): string
|
||||||
|
{
|
||||||
|
return match ((string) $purpose) {
|
||||||
|
'ehrenamtlich' => 'Ehrenamtlich',
|
||||||
|
'kommerziell' => 'Kommerziell',
|
||||||
|
'institutionell' => 'Institutionell',
|
||||||
|
default => (string) $purpose,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function vergabe(OfferVersion $version): string
|
||||||
|
{
|
||||||
|
$kind = match ($version->grant_kind) {
|
||||||
|
'kauf' => 'Kauf',
|
||||||
|
'auf_abruf' => 'Auf Abruf',
|
||||||
|
'bei_registrierung' => 'Bei Registrierung',
|
||||||
|
default => (string) $version->grant_kind,
|
||||||
|
};
|
||||||
|
|
||||||
|
return $version->price_cents === null ? $kind : $kind.' · '.number_format($version->price_cents / 100, 2, ',', '.').' €';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,252 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentElementVersion;
|
||||||
|
use App\Domain\Catalog\EditorialVocabulary;
|
||||||
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
|
use App\Http\Controllers\ContentPreviewController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gemeinsamer visueller Picker (Dokument 14 §9): Zustand, Suche, Treffer, Betrachten, Markieren und Detail. Die
|
||||||
|
* Ansicht ist filament.verwaltung.picker. Die Seite bestimmt Zweck, Titel, Typen, Mehrfachauswahl und was
|
||||||
|
* „Übernehmen“ bewirkt (pickerAllowsMany, pickerKinds, pickerTitle, pickerConfirmLabel, pickerKontext, confirmPicker,
|
||||||
|
* closePicker). Genutzt von der Redaktion (ManagesEditorialSurface) und vom CMS (ChoosesWebsiteImages).
|
||||||
|
*/
|
||||||
|
trait ChoosesMedia
|
||||||
|
{
|
||||||
|
public bool $pickerOpen = false;
|
||||||
|
|
||||||
|
public string $pickerPurpose = 'praesentation';
|
||||||
|
|
||||||
|
public string $pickerQuery = '';
|
||||||
|
|
||||||
|
public string $pickerKind = 'alle';
|
||||||
|
|
||||||
|
public string $pickerDimension = '';
|
||||||
|
|
||||||
|
/** Filter „Fachliche Materialart“ (Kennung), gleiche Regel wie Medieneditor und Medienfilter. */
|
||||||
|
public string $pickerMaterialart = '';
|
||||||
|
|
||||||
|
public string $pickerInspected = '';
|
||||||
|
|
||||||
|
public string $pickerSelected = '';
|
||||||
|
|
||||||
|
/** @var array<string, string> Ziel => Titel; bleibt bei Suche und Filter erhalten */
|
||||||
|
public array $pickerMarked = [];
|
||||||
|
|
||||||
|
public string $presentationRole = 'titelbild';
|
||||||
|
|
||||||
|
public bool $bindToVersion = false;
|
||||||
|
|
||||||
|
public ?string $replacingKey = null;
|
||||||
|
|
||||||
|
abstract public function pickerAllowsMany(): bool;
|
||||||
|
|
||||||
|
abstract public function closePicker(): void;
|
||||||
|
|
||||||
|
abstract public function confirmPicker(): void;
|
||||||
|
|
||||||
|
public function inspectPicker(string $target, bool $mark = false): void
|
||||||
|
{
|
||||||
|
$this->pickerInspected = $target;
|
||||||
|
|
||||||
|
if ($mark) {
|
||||||
|
$this->markPicker($target, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function togglePick(string $target): void
|
||||||
|
{
|
||||||
|
$this->markPicker($target, ! isset($this->pickerMarked[$target]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function markPicker(string $target, bool $on): void
|
||||||
|
{
|
||||||
|
if (! $on) {
|
||||||
|
unset($this->pickerMarked[$target]);
|
||||||
|
|
||||||
|
if ($this->pickerSelected === $target) {
|
||||||
|
$this->pickerSelected = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = app(EditorialCatalog::class)->rowForTarget($target, $this->pickerExceptId(), allowDraft: true);
|
||||||
|
|
||||||
|
if ($row === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->pickerAllowsMany()) {
|
||||||
|
$this->pickerMarked = [];
|
||||||
|
$this->pickerSelected = $target;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->pickerMarked[$target] = (string) $row['title'];
|
||||||
|
|
||||||
|
if ($this->pickerInspected === '') {
|
||||||
|
$this->pickerInspected = $target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{items: list<array<string, mixed>>, more: bool}
|
||||||
|
*/
|
||||||
|
public function pickerResult(): array
|
||||||
|
{
|
||||||
|
if (! $this->pickerOpen) {
|
||||||
|
return ['items' => [], 'more' => false];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->pickerPurpose === 'aufbau') {
|
||||||
|
return $this->filterByMaterialart(app(EditorialCatalog::class)->browse(
|
||||||
|
$this->pickerQuery,
|
||||||
|
$this->pickerKind,
|
||||||
|
$this->pickerDimension,
|
||||||
|
$this->pickerExceptId(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = app(EditorialCatalog::class)->presentationBrowse($this->pickerQuery, $this->pickerKind);
|
||||||
|
$result = $this->filterByMaterialart($result);
|
||||||
|
|
||||||
|
// CMS: nur Bilder, die als Website-Bild wählbar sind (keine vertraulichen Arten, nicht archiviert).
|
||||||
|
if ($this->pickerPurpose === 'website-bild') {
|
||||||
|
$ids = array_values(array_filter(array_map(fn (array $item): int => (int) ($item['element_id'] ?? 0), $result['items'])));
|
||||||
|
$elements = ContentElement::query()->with('editorialContentKind')->whereKey($ids)->get()->keyBy('id');
|
||||||
|
$result['items'] = array_values(array_filter($result['items'], function (array $item) use ($elements): bool {
|
||||||
|
$element = $elements->get((int) ($item['element_id'] ?? 0));
|
||||||
|
|
||||||
|
return $element !== null && WebsiteImage::isSelectable($element);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>|null
|
||||||
|
*/
|
||||||
|
public function pickerDetail(): ?array
|
||||||
|
{
|
||||||
|
$target = $this->pickerInspected !== '' ? $this->pickerInspected : $this->pickerSelected;
|
||||||
|
|
||||||
|
if ($target === '') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = app(EditorialCatalog::class)->rowForTarget($target, $this->pickerExceptId(), allowDraft: true);
|
||||||
|
|
||||||
|
if ($row === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row['playback'] = null;
|
||||||
|
$row['file_url'] = null;
|
||||||
|
$elementId = isset($row['element_id']) ? (int) $row['element_id'] : 0;
|
||||||
|
|
||||||
|
if (preg_match('/^element:(\d+)$/', (string) $row['target'], $match) === 1) {
|
||||||
|
$version = ContentElementVersion::query()->with('element.editorialContentKind')->find($match[1]);
|
||||||
|
|
||||||
|
if ($version instanceof ContentElementVersion) {
|
||||||
|
$row['playback'] = app(ContentPreviewController::class)->playback($version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$element = $elementId > 0 ? ContentElement::query()->with(['editorialContentKind', 'pillars'])->find($elementId) : null;
|
||||||
|
|
||||||
|
if ($element instanceof ContentElement) {
|
||||||
|
$row['visibility'] = app(PublicMaterialReader::class)->visibilityNote($element);
|
||||||
|
$row['released'] = $element->website_released_at !== null;
|
||||||
|
$row['output_label'] = PublicMaterialReader::outputLabel((string) $element->output_class);
|
||||||
|
$row['pillars'] = $element->pillars->pluck('name')->all();
|
||||||
|
$row['material'] = $element->editorialContentKind?->label;
|
||||||
|
$row['usage'] = app(CatalogReading::class)->elementUsage($element);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{target: string, label: string, current: bool}>
|
||||||
|
*/
|
||||||
|
public function pickerVersions(): array
|
||||||
|
{
|
||||||
|
$detail = $this->pickerDetail();
|
||||||
|
|
||||||
|
if ($detail === null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$options = app(EditorialCatalog::class)->alternatives((string) ($detail['identity'] ?? ''), $this->pickerExceptId());
|
||||||
|
|
||||||
|
if ($options === []) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$current = $options[array_key_last($options)]['target'];
|
||||||
|
|
||||||
|
return array_map(fn (array $option): array => $option + ['current' => $option['target'] === $current], $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function pickerExceptId(): int
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function resetPicker(string $purpose): void
|
||||||
|
{
|
||||||
|
$this->pickerPurpose = $purpose;
|
||||||
|
$this->pickerOpen = true;
|
||||||
|
$this->pickerQuery = '';
|
||||||
|
$this->pickerDimension = '';
|
||||||
|
$this->pickerMaterialart = '';
|
||||||
|
$this->pickerInspected = '';
|
||||||
|
$this->pickerSelected = '';
|
||||||
|
$this->pickerMarked = [];
|
||||||
|
$this->replacingKey = null;
|
||||||
|
$this->bindToVersion = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fachliche Materialarten, nach denen der Picker Medien eingrenzen kann (Kontext Medium).
|
||||||
|
*
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function pickerMaterialarten(): array
|
||||||
|
{
|
||||||
|
return app(EditorialVocabulary::class)->kindFilterOptions('medium', $this->pickerMaterialart);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array{items: list<array<string, mixed>>, more: bool} $result
|
||||||
|
* @return array{items: list<array<string, mixed>>, more: bool}
|
||||||
|
*/
|
||||||
|
private function filterByMaterialart(array $result): array
|
||||||
|
{
|
||||||
|
if (! ctype_digit($this->pickerMaterialart)) {
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ids = array_values(array_filter(array_map(fn (array $item): int => (int) ($item['element_id'] ?? 0), $result['items'])));
|
||||||
|
$passend = ContentElement::query()->whereKey($ids)->where('editorial_content_kind_id', (int) $this->pickerMaterialart)->pluck('id')->map(fn ($id): int => (int) $id)->all();
|
||||||
|
$result['items'] = array_values(array_filter($result['items'], fn (array $item): bool => in_array((int) ($item['element_id'] ?? 0), $passend, true)));
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Einordnungsfilter des Pickers: dieselbe Filterregel wie Medien- und Kompositionslisten (verwendete inaktive Werte
|
||||||
|
* bleiben auffindbar, ein gewählter Filter bleibt sichtbar).
|
||||||
|
*
|
||||||
|
* @return list<array{label: string, values: list<array{id: int, label: string}>}>
|
||||||
|
*/
|
||||||
|
public function pickerDimensionGroups(): array
|
||||||
|
{
|
||||||
|
return app(EditorialVocabulary::class)->dimensionFilterGroups(ctype_digit($this->pickerDimension) ? [(int) $this->pickerDimension] : []);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bildauswahl im CMS über den gemeinsamen visuellen Picker (Dokument 14 §9) statt einer eigenen Auswahlliste.
|
||||||
|
* Ein Bildfeld (filament.cms.bild-feld) öffnet den Picker mit seinem Formularpfad; „Bild übernehmen“ schreibt die
|
||||||
|
* Kennung des Mediums in genau dieses Feld, auch im geöffneten Bausteindialog. Gespeichert wird weiterhin nur mit dem
|
||||||
|
* Seitenentwurf. Die Auswahl gibt kein Bild für die Website frei.
|
||||||
|
*/
|
||||||
|
trait ChoosesWebsiteImages
|
||||||
|
{
|
||||||
|
use ChoosesMedia;
|
||||||
|
|
||||||
|
/** Formularpfad des Bildfelds, in das die Auswahl übernommen wird. */
|
||||||
|
public ?string $bildZiel = null;
|
||||||
|
|
||||||
|
public function openWebsiteImagePicker(string $pfad): void
|
||||||
|
{
|
||||||
|
if (preg_match('/^(data|mountedActions\.\d+\.data)(\.[A-Za-z0-9_-]+)+$/', $pfad) !== 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->resetPicker('website-bild');
|
||||||
|
$this->pickerKind = 'bild';
|
||||||
|
$this->bildZiel = $pfad;
|
||||||
|
$this->forceRenderForPicker();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filament rendert bei offenen Aktionsdialogen nur den Dialogteil neu; der Picker liegt darüber und braucht die
|
||||||
|
* ganze Seite.
|
||||||
|
*/
|
||||||
|
public function hydrateChoosesWebsiteImages(): void
|
||||||
|
{
|
||||||
|
if ($this->pickerOpen) {
|
||||||
|
$this->forceRenderForPicker();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function pickerAllowsMany(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function closePicker(): void
|
||||||
|
{
|
||||||
|
$this->pickerOpen = false;
|
||||||
|
$this->pickerSelected = '';
|
||||||
|
$this->pickerInspected = '';
|
||||||
|
$this->pickerMarked = [];
|
||||||
|
$this->bildZiel = null;
|
||||||
|
$this->forceRenderForPicker();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function confirmPicker(): void
|
||||||
|
{
|
||||||
|
$target = array_key_first($this->pickerMarked);
|
||||||
|
$ziel = $this->bildZiel;
|
||||||
|
|
||||||
|
if ($target === null || $ziel === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = app(EditorialCatalog::class)->rowForTarget((string) $target, 0, allowDraft: true);
|
||||||
|
$element = isset($row['element_id']) ? ContentElement::query()->find((int) $row['element_id']) : null;
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement || ! WebsiteImage::isSelectable($element)) {
|
||||||
|
Notification::make()->danger()->title('Dieses Medium kann nicht als Website-Bild gewählt werden.')->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data_set($this, $ziel, $element->id);
|
||||||
|
$this->closePicker();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function pickerKinds(): array
|
||||||
|
{
|
||||||
|
return ['bild' => 'Bilder'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function pickerTitle(): string
|
||||||
|
{
|
||||||
|
return 'Bild aus dem Medienmanager';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function pickerConfirmLabel(): string
|
||||||
|
{
|
||||||
|
return 'Bild übernehmen';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{art: string, titel: string}
|
||||||
|
*/
|
||||||
|
public function pickerKontext(): array
|
||||||
|
{
|
||||||
|
$pfad = property_exists($this, 'record') && is_object($this->record ?? null) ? (string) ($this->record->path ?? '') : '';
|
||||||
|
|
||||||
|
return ['art' => 'die Seite', 'titel' => $pfad !== '' ? $pfad : 'neue Seite'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
public function presentationRoleOptions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>|null
|
||||||
|
*/
|
||||||
|
public function pickerReplacing(): ?array
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function forceRenderForPicker(): void
|
||||||
|
{
|
||||||
|
if (method_exists($this, 'forceRender')) {
|
||||||
|
$this->forceRender();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,9 @@
|
|||||||
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;
|
||||||
|
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||||
use App\Filament\Resources\Combinations\CombinationResource;
|
use App\Filament\Resources\Combinations\CombinationResource;
|
||||||
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
use App\Filament\Resources\Courses\CourseResource;
|
use App\Filament\Resources\Courses\CourseResource;
|
||||||
use App\Filament\Resources\Exercises\ExerciseResource;
|
use App\Filament\Resources\Exercises\ExerciseResource;
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
@@ -63,6 +65,10 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
|
|||||||
return $this->draftCompositionRow((int) $draftMatch[1], $exceptCompositionId, $allowSelf);
|
return $this->draftCompositionRow((int) $draftMatch[1], $exceptCompositionId, $allowSelf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (preg_match('/^medium:(\d+)$/', $target, $mediumMatch) === 1) {
|
||||||
|
return $this->rowForPresentationMedium((int) $mediumMatch[1]);
|
||||||
|
}
|
||||||
|
|
||||||
if (preg_match('/^(element|composition):(\d+)$/', $target, $match) !== 1) {
|
if (preg_match('/^(element|composition):(\d+)$/', $target, $match) !== 1) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -111,7 +117,7 @@ public function rowForTarget(string $target, int $exceptCompositionId, bool $all
|
|||||||
'identity' => 'medium:'.$element->id,
|
'identity' => 'medium:'.$element->id,
|
||||||
'open_url' => route('content.preview', $version),
|
'open_url' => route('content.preview', $version),
|
||||||
'open_label' => 'Medium ansehen',
|
'open_label' => 'Medium ansehen',
|
||||||
'edit_url' => null,
|
'edit_url' => ContentElementResource::getUrl('view', ['record' => $element]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,6 +214,8 @@ public function search(string $query, string $scope, int $exceptCompositionId):
|
|||||||
|
|
||||||
$builder->where('working_title', 'like', $like)
|
$builder->where('working_title', 'like', $like)
|
||||||
->orWhere('display_title', 'like', $like)
|
->orWhere('display_title', 'like', $like)
|
||||||
|
->orWhere('teaser', 'like', $like)
|
||||||
|
->orWhere('search_terms', 'like', $like)
|
||||||
->orWhere('summary', 'like', $like);
|
->orWhere('summary', 'like', $like);
|
||||||
})
|
})
|
||||||
->orderByDesc('id')
|
->orderByDesc('id')
|
||||||
@@ -240,6 +248,8 @@ public function search(string $query, string $scope, int $exceptCompositionId):
|
|||||||
$builder->where(function ($inner) use ($like): void {
|
$builder->where(function ($inner) use ($like): void {
|
||||||
$inner->where('designation', 'like', $like)
|
$inner->where('designation', 'like', $like)
|
||||||
->orWhere('display_title', 'like', $like)
|
->orWhere('display_title', 'like', $like)
|
||||||
|
->orWhere('teaser', 'like', $like)
|
||||||
|
->orWhere('search_terms', 'like', $like)
|
||||||
->orWhere('summary', 'like', $like);
|
->orWhere('summary', 'like', $like);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@@ -262,7 +272,7 @@ public function search(string $query, string $scope, int $exceptCompositionId):
|
|||||||
/**
|
/**
|
||||||
* @return array{items: list<array<string, string|null>>, more: bool}
|
* @return array{items: list<array<string, string|null>>, more: bool}
|
||||||
*/
|
*/
|
||||||
public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId): array
|
public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId, bool $elementsOnly = false): array
|
||||||
{
|
{
|
||||||
$query = trim($query);
|
$query = trim($query);
|
||||||
$like = '%'.str_replace(['%', '_'], ['', ''], $query).'%';
|
$like = '%'.str_replace(['%', '_'], ['', ''], $query).'%';
|
||||||
@@ -294,7 +304,7 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($kind, ['alle', 'modul'], true)) {
|
if (! $elementsOnly && in_array($kind, ['alle', 'modul'], true)) {
|
||||||
$latestCompositions = CompositionVersion::query()
|
$latestCompositions = CompositionVersion::query()
|
||||||
->selectRaw('MAX(id)')
|
->selectRaw('MAX(id)')
|
||||||
->where('status', ContentVersionStatus::Bereit)
|
->where('status', ContentVersionStatus::Bereit)
|
||||||
@@ -315,6 +325,8 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
|||||||
$builder->where(function ($inner) use ($like): void {
|
$builder->where(function ($inner) use ($like): void {
|
||||||
$inner->where('designation', 'like', $like)
|
$inner->where('designation', 'like', $like)
|
||||||
->orWhere('display_title', 'like', $like)
|
->orWhere('display_title', 'like', $like)
|
||||||
|
->orWhere('teaser', 'like', $like)
|
||||||
|
->orWhere('search_terms', 'like', $like)
|
||||||
->orWhere('summary', 'like', $like);
|
->orWhere('summary', 'like', $like);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
@@ -372,12 +384,125 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$rows = $this->withVisibility($rows);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'items' => array_slice($rows, 0, $limit),
|
'items' => array_slice($rows, 0, $limit),
|
||||||
'more' => count($rows) > $limit,
|
'more' => count($rows) > $limit,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bestandssuche für Präsentationsmedien.
|
||||||
|
* Fassungen bleiben im didaktischen Aufbau. Bilder, Filme und Hörstücke ohne Inhaltsfassung kommen dazu.
|
||||||
|
*
|
||||||
|
* @return array{items: list<array<string, string|null>>, more: bool}
|
||||||
|
*/
|
||||||
|
public function presentationBrowse(string $query, string $kind = 'alle'): array
|
||||||
|
{
|
||||||
|
$catalog = $this->browse($query, $kind, '', 0, elementsOnly: true);
|
||||||
|
$outputs = match ($kind) {
|
||||||
|
'bild' => ['bild'],
|
||||||
|
'film' => ['film'],
|
||||||
|
'audio' => ['audio'],
|
||||||
|
'dokument' => [],
|
||||||
|
default => ['bild', 'film', 'audio'],
|
||||||
|
};
|
||||||
|
// Reine Texte sind Lehrinhalt oder Beschreibung, keine Präsentationsmedien.
|
||||||
|
$catalog['items'] = array_values(array_filter(
|
||||||
|
$catalog['items'],
|
||||||
|
fn (array $item): bool => ($item['output'] ?? '') !== 'text',
|
||||||
|
));
|
||||||
|
$seen = [];
|
||||||
|
|
||||||
|
foreach ($catalog['items'] as $item) {
|
||||||
|
if (isset($item['element_id'])) {
|
||||||
|
$seen[(int) $item['element_id']] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = trim($query);
|
||||||
|
$like = '%'.str_replace(['%', '_'], ['', ''], $query).'%';
|
||||||
|
$elements = ContentElement::query()
|
||||||
|
->with('editorialContentKind')
|
||||||
|
->whereIn('output_class', $outputs)
|
||||||
|
->whereNull('archived_at')
|
||||||
|
->whereDoesntHave('versions')
|
||||||
|
->where(function ($builder): void {
|
||||||
|
$builder->whereNull('editorial_content_kind_id')
|
||||||
|
->orWhereDoesntHave('editorialContentKind', function ($kind): void {
|
||||||
|
$kind->where('slug', 'traineranleitung');
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->when($query !== '', function ($builder) use ($like): void {
|
||||||
|
$builder->where(function ($inner) use ($like): void {
|
||||||
|
$inner->where('working_title', 'like', $like)
|
||||||
|
->orWhere('display_title', 'like', $like)
|
||||||
|
->orWhere('teaser', 'like', $like)
|
||||||
|
->orWhere('search_terms', 'like', $like)
|
||||||
|
->orWhere('summary', 'like', $like);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
->orderBy('working_title')
|
||||||
|
->limit(48)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($elements as $element) {
|
||||||
|
if (isset($seen[$element->id])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = $this->rowForPresentationMedium($element->id);
|
||||||
|
|
||||||
|
if ($row !== null) {
|
||||||
|
$catalog['items'][] = $row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $catalog;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string|null>|null
|
||||||
|
*/
|
||||||
|
private function rowForPresentationMedium(int $id): ?array
|
||||||
|
{
|
||||||
|
$element = ContentElement::query()->with('editorialContentKind')->find($id);
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement
|
||||||
|
|| $element->archived_at !== null
|
||||||
|
|| ! in_array($element->output_class, ['bild', 'film', 'audio'], true)
|
||||||
|
|| $element->editorialContentKind?->slug === 'traineranleitung') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$kind = $element->editorialContentKind?->label ?: $this->outputLabel((string) $element->output_class);
|
||||||
|
$title = filled($element->display_title) ? $element->display_title : $element->working_title;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'target' => 'medium:'.$element->id,
|
||||||
|
'element_id' => (string) $element->id,
|
||||||
|
'title' => $title,
|
||||||
|
'kind' => $kind,
|
||||||
|
'output' => (string) $element->output_class,
|
||||||
|
'body' => '',
|
||||||
|
'summary' => (string) ($element->summary ?: $element->description ?: ''),
|
||||||
|
'medium_description' => (string) ($element->description ?? ''),
|
||||||
|
'usage_note' => (string) ($element->usage_note ?? ''),
|
||||||
|
'license_note' => (string) ($element->license_note ?? ''),
|
||||||
|
'tone' => $this->tone((string) $element->output_class, $kind),
|
||||||
|
'image' => $element->output_class === 'bild'
|
||||||
|
? $this->cardUrl('element', $element->id, $element->thumbnail_path)
|
||||||
|
: null,
|
||||||
|
'version_label' => 'Ohne Inhaltsfassung',
|
||||||
|
'committed' => false,
|
||||||
|
'identity' => 'medium:'.$element->id,
|
||||||
|
'open_url' => ContentElementResource::getUrl('view', ['record' => $element]),
|
||||||
|
'open_label' => 'Medium ansehen',
|
||||||
|
'edit_url' => ContentElementResource::getUrl('view', ['record' => $element]),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
public function tone(string $outputClass, string $kindLabel): string
|
public function tone(string $outputClass, string $kindLabel): string
|
||||||
{
|
{
|
||||||
$value = mb_strtolower($outputClass.' '.$kindLabel);
|
$value = mb_strtolower($outputClass.' '.$kindLabel);
|
||||||
@@ -400,6 +525,42 @@ public function cardUrl(string $kind, int $id, ?string $path): ?string
|
|||||||
return route('editorial.card', ['kind' => $kind, 'subject' => $id]);
|
return route('editorial.card', ['kind' => $kind, 'subject' => $id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<array<string, mixed>> $rows
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
private function withVisibility(array $rows): array
|
||||||
|
{
|
||||||
|
$ids = [];
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
if (isset($row['element_id'])) {
|
||||||
|
$ids[] = (int) $row['element_id'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ids === []) {
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
$reader = app(PublicMaterialReader::class);
|
||||||
|
$elements = ContentElement::query()
|
||||||
|
->with('editorialContentKind')
|
||||||
|
->whereIn('id', array_values(array_unique($ids)))
|
||||||
|
->get()
|
||||||
|
->keyBy('id');
|
||||||
|
|
||||||
|
foreach ($rows as $index => $row) {
|
||||||
|
$element = $elements->get((int) ($row['element_id'] ?? 0));
|
||||||
|
|
||||||
|
if ($element instanceof ContentElement) {
|
||||||
|
$rows[$index]['visibility'] = $reader->visibilityNote($element);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Builder<ContentElement> $builder
|
* @param Builder<ContentElement> $builder
|
||||||
*/
|
*/
|
||||||
@@ -408,6 +569,8 @@ private function constrainElement($builder, string $query, string $like, string
|
|||||||
$outputs = match ($kind) {
|
$outputs = match ($kind) {
|
||||||
'film' => ['film'],
|
'film' => ['film'],
|
||||||
'text' => ['text'],
|
'text' => ['text'],
|
||||||
|
'bild' => ['bild'],
|
||||||
|
'audio' => ['audio'],
|
||||||
'dokument' => ['pdf', 'document'],
|
'dokument' => ['pdf', 'document'],
|
||||||
default => null,
|
default => null,
|
||||||
};
|
};
|
||||||
@@ -427,6 +590,8 @@ private function constrainElement($builder, string $query, string $like, string
|
|||||||
$builder->where(function ($inner) use ($like): void {
|
$builder->where(function ($inner) use ($like): void {
|
||||||
$inner->where('working_title', 'like', $like)
|
$inner->where('working_title', 'like', $like)
|
||||||
->orWhere('display_title', 'like', $like)
|
->orWhere('display_title', 'like', $like)
|
||||||
|
->orWhere('teaser', 'like', $like)
|
||||||
|
->orWhere('search_terms', 'like', $like)
|
||||||
->orWhere('summary', 'like', $like)
|
->orWhere('summary', 'like', $like)
|
||||||
->orWhere('description', 'like', $like);
|
->orWhere('description', 'like', $like);
|
||||||
});
|
});
|
||||||
@@ -596,13 +761,13 @@ public function statusChips(Composition $composition, bool $offered): array
|
|||||||
$chips[] = ['label' => 'Entwurf offen', 'tone' => 'yellow'];
|
$chips[] = ['label' => 'Entwurf offen', 'tone' => 'yellow'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$chips[] = $stand['released_number'] !== null
|
// Zeigt die Bibliothek eine ältere Fassung, nennt der Chip sie; „In der Mitgliederbibliothek“ neben
|
||||||
? ['label' => 'In der Mitgliederbibliothek', 'tone' => 'pine']
|
// „Fassung 2“ läse sich sonst, als wäre Fassung 2 sichtbar.
|
||||||
: ['label' => 'Nicht in der Mitgliederbibliothek', 'tone' => 'quiet'];
|
$chips[] = match (true) {
|
||||||
|
$stand['released_number'] === null => ['label' => 'Nicht in der Mitgliederbibliothek', 'tone' => 'quiet'],
|
||||||
if ($stand['released_number'] !== null && $stand['released_number'] !== $stand['number']) {
|
$stand['released_number'] === $stand['number'] => ['label' => 'In der Mitgliederbibliothek', 'tone' => 'pine'],
|
||||||
$chips[] = ['label' => 'Bibliothek zeigt Fassung '.$stand['released_number'], 'tone' => 'pine'];
|
default => ['label' => 'Bibliothek zeigt Fassung '.$stand['released_number'], 'tone' => 'pine'],
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
$chips[] = ['label' => 'Nicht auf der Website', 'tone' => 'quiet'];
|
$chips[] = ['label' => 'Nicht auf der Website', 'tone' => 'quiet'];
|
||||||
@@ -708,6 +873,8 @@ public function mediaPictures(string $query): array
|
|||||||
->where(function ($builder) use ($like): void {
|
->where(function ($builder) use ($like): void {
|
||||||
$builder->where('working_title', 'like', $like)
|
$builder->where('working_title', 'like', $like)
|
||||||
->orWhere('display_title', 'like', $like)
|
->orWhere('display_title', 'like', $like)
|
||||||
|
->orWhere('teaser', 'like', $like)
|
||||||
|
->orWhere('search_terms', 'like', $like)
|
||||||
->orWhere('summary', 'like', $like);
|
->orWhere('summary', 'like', $like);
|
||||||
})
|
})
|
||||||
->orderBy('working_title')
|
->orderBy('working_title')
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use Filament\Schemas\Components\View;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
|
use Livewire\Attributes\Url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kataloglisten (Lizenzartikel, Pakete, Rechteprofile, Angebote) in der gemeinsamen Bestandsliste. Die Seite liefert
|
||||||
|
* Zeilen mit 'suchtext' und 'zustand' (Liste von Zustandsschlüsseln) sowie die Zustandsoptionen.
|
||||||
|
*/
|
||||||
|
trait ListsCatalog
|
||||||
|
{
|
||||||
|
use ShowsBestand;
|
||||||
|
|
||||||
|
#[Url(as: 'suche', except: '')]
|
||||||
|
public string $suche = '';
|
||||||
|
|
||||||
|
#[Url(as: 'zustand', except: 'alle')]
|
||||||
|
public string $zustand = 'alle';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
abstract protected function catalogRows(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, string> Zustandsschlüssel => Bezeichnung, beginnend mit 'alle'
|
||||||
|
*/
|
||||||
|
abstract protected function zustandOptionen(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{0: string, 1: string}
|
||||||
|
*/
|
||||||
|
abstract protected function einheit(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{titel: string, text: string}
|
||||||
|
*/
|
||||||
|
abstract protected function leer(): array;
|
||||||
|
|
||||||
|
protected function bestandFilterEigenschaften(): array
|
||||||
|
{
|
||||||
|
return ['suche', 'zustand'];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function suchPlatzhalter(): string
|
||||||
|
{
|
||||||
|
return 'Name oder Beschreibung';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMaxContentWidth(): Width|string|null
|
||||||
|
{
|
||||||
|
return Width::Full;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function content(Schema $schema): Schema
|
||||||
|
{
|
||||||
|
return $schema->components([View::make('filament.verwaltung.bestand')]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetFilters(): void
|
||||||
|
{
|
||||||
|
$this->suche = '';
|
||||||
|
$this->zustand = 'alle';
|
||||||
|
$this->bestandGrenze = Bestand::SCHRITT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function bestand(): array
|
||||||
|
{
|
||||||
|
$needle = mb_strtolower(trim($this->suche));
|
||||||
|
$rows = array_values(array_filter($this->catalogRows(), function (array $row) use ($needle): bool {
|
||||||
|
if ($this->zustand !== 'alle' && ! in_array($this->zustand, $row['zustand'] ?? [], true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $needle === '' || str_contains(mb_strtolower(implode(' ', array_filter([
|
||||||
|
$row['titel'], $row['meta'] ?? '', $row['text'] ?? '', $row['suchtext'] ?? '',
|
||||||
|
]))), $needle);
|
||||||
|
}));
|
||||||
|
|
||||||
|
return [
|
||||||
|
'suche' => ['eigenschaft' => 'suche', 'label' => 'Suche', 'platzhalter' => $this->suchPlatzhalter()],
|
||||||
|
'filter' => [['eigenschaft' => 'zustand', 'label' => 'Zustand', 'vorgabe' => 'alle', 'optionen' => $this->zustandOptionen()]],
|
||||||
|
'zeilen' => $rows,
|
||||||
|
'einheit' => $this->einheit(),
|
||||||
|
'leer' => $this->leer(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,277 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Composition;
|
||||||
|
use App\Domain\Catalog\CompositionKind;
|
||||||
|
use App\Domain\Catalog\ContentVersionStatus;
|
||||||
|
use App\Domain\Catalog\EditorialVocabulary;
|
||||||
|
use App\Domain\Catalog\IdentityDimensionValue;
|
||||||
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
|
use Filament\Actions\Action;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Livewire\Attributes\Url;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eine Liste für Programme und Module (Arbeitsplatz, „Module“, „Programme“): dieselben Zeilen, Filter und derselbe
|
||||||
|
* Anlegedialog. Seiten mit festem Typ setzen fixedKind(); der Arbeitsplatz zeigt beide Arten mit Umschalter.
|
||||||
|
*/
|
||||||
|
trait ListsCompositions
|
||||||
|
{
|
||||||
|
use ShowsBestand;
|
||||||
|
|
||||||
|
#[Url]
|
||||||
|
public string $query = '';
|
||||||
|
|
||||||
|
#[Url]
|
||||||
|
public string $kindFilter = 'alle';
|
||||||
|
|
||||||
|
#[Url]
|
||||||
|
public string $pillar = '';
|
||||||
|
|
||||||
|
#[Url]
|
||||||
|
public string $visibility = 'alle';
|
||||||
|
|
||||||
|
protected function fixedKind(): ?CompositionKind
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function bestandFilterEigenschaften(): array
|
||||||
|
{
|
||||||
|
return ['query', 'kindFilter', 'pillar', 'visibility'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetFilters(): void
|
||||||
|
{
|
||||||
|
$this->query = '';
|
||||||
|
$this->kindFilter = 'alle';
|
||||||
|
$this->pillar = '';
|
||||||
|
$this->visibility = 'alle';
|
||||||
|
$this->bestandGrenze = Bestand::SCHRITT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasActiveFilters(): bool
|
||||||
|
{
|
||||||
|
return trim($this->query) !== '' || $this->kindFilter !== 'alle' || $this->pillar !== '' || $this->visibility !== 'alle';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function bestand(): array
|
||||||
|
{
|
||||||
|
$fixed = $this->fixedKind();
|
||||||
|
$einheit = match ($fixed) {
|
||||||
|
CompositionKind::Kurs => ['Programm', 'Programme'],
|
||||||
|
CompositionKind::Uebung => ['Modul', 'Module'],
|
||||||
|
CompositionKind::Kombination => ['Fachliche Kombination', 'Fachliche Kombinationen'],
|
||||||
|
default => ['Programm oder Modul', 'Programme und Module'],
|
||||||
|
};
|
||||||
|
$gruppen = [];
|
||||||
|
|
||||||
|
foreach ($this->dimensionFilters() as $gruppe) {
|
||||||
|
$optionen = [];
|
||||||
|
|
||||||
|
foreach ($gruppe['values'] as $value) {
|
||||||
|
$optionen[(string) $value['id']] = $value['label'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$gruppen[] = ['label' => $gruppe['label'], 'optionen' => $optionen];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'suche' => ['eigenschaft' => 'query', 'label' => 'Suche', 'platzhalter' => 'Titel oder Kurzbeschreibung'],
|
||||||
|
'segmente' => $fixed === null ? [[
|
||||||
|
'eigenschaft' => 'kindFilter', 'label' => 'Art', 'vorgabe' => 'alle',
|
||||||
|
'optionen' => ['alle' => 'Alle', 'programm' => 'Programme', 'modul' => 'Module'],
|
||||||
|
]] : [],
|
||||||
|
'filter' => [[
|
||||||
|
'eigenschaft' => 'visibility', 'label' => 'Stand', 'vorgabe' => 'alle',
|
||||||
|
'optionen' => ['alle' => 'Jeder Stand', 'bibliothek' => 'In der Mitgliederbibliothek', 'verborgen' => 'Nicht in der Mitgliederbibliothek', 'entwurf' => 'Noch ohne Fassung'],
|
||||||
|
]],
|
||||||
|
'weitere' => $gruppen === [] ? [] : [[
|
||||||
|
'eigenschaft' => 'pillar', 'label' => 'Fachliche Einordnung', 'vorgabe' => '', 'alle' => 'Alle Einordnungen', 'gruppen' => $gruppen,
|
||||||
|
]],
|
||||||
|
'zeilen' => $this->entries(),
|
||||||
|
'einheit' => $einheit,
|
||||||
|
'leer' => [
|
||||||
|
'titel' => $fixed === CompositionKind::Kombination ? 'Noch keine fachlichen Kombinationen' : 'Noch keine '.$einheit[1],
|
||||||
|
'text' => 'Mit „'.match ($fixed) {
|
||||||
|
CompositionKind::Kurs => 'Programm anlegen',
|
||||||
|
CompositionKind::Kombination => CompositionKind::Kombination->createLabel(),
|
||||||
|
default => 'Modul anlegen',
|
||||||
|
}.'“ oben entsteht der erste Eintrag. Der Name genügt.',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{label: string, values: list<array{id: int, label: string}>}>
|
||||||
|
*/
|
||||||
|
public function dimensionFilters(): array
|
||||||
|
{
|
||||||
|
return app(EditorialVocabulary::class)->dimensionFilterGroups(ctype_digit($this->pillar) ? [(int) $this->pillar] : []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zeilen der gemeinsamen Bestandsliste.
|
||||||
|
*
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function entries(): array
|
||||||
|
{
|
||||||
|
$needle = mb_strtolower(trim($this->query));
|
||||||
|
$catalog = app(EditorialCatalog::class);
|
||||||
|
$offered = $catalog->offeredCompositionIds();
|
||||||
|
$pillarIds = $this->pillar === '' ? null : $this->pillarSubjects((int) $this->pillar);
|
||||||
|
$fixed = $this->fixedKind();
|
||||||
|
$kinds = $fixed !== null ? [$fixed] : match ($this->kindFilter) {
|
||||||
|
'programm' => [CompositionKind::Kurs],
|
||||||
|
'modul' => [CompositionKind::Uebung],
|
||||||
|
default => [CompositionKind::Kurs, CompositionKind::Uebung],
|
||||||
|
};
|
||||||
|
$canEdit = ContentElementResource::editor();
|
||||||
|
$rows = [];
|
||||||
|
|
||||||
|
$compositions = Composition::query()
|
||||||
|
->whereIn('kind', $kinds)
|
||||||
|
->with(['editorialContentKind', 'versions.members.contentElementVersion.element'])
|
||||||
|
->orderBy('designation')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($compositions as $composition) {
|
||||||
|
$kind = $composition->kind instanceof CompositionKind
|
||||||
|
? $composition->kind
|
||||||
|
: CompositionKind::from((string) $composition->kind);
|
||||||
|
|
||||||
|
if ($pillarIds !== null && ! in_array($composition->id, $pillarIds, true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stand = $catalog->stand($composition);
|
||||||
|
|
||||||
|
if (! $this->matchesVisibility($stand)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$title = $catalog->compositionTitle($composition);
|
||||||
|
$summary = trim((string) ($composition->summary ?? ''));
|
||||||
|
$haystack = mb_strtolower($title.' '.$composition->designation.' '.$summary.' '.(string) $composition->description);
|
||||||
|
|
||||||
|
if ($needle !== '' && ! str_contains($haystack, $needle)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cover = $catalog->cover($composition, $this->coverMembers($composition));
|
||||||
|
$url = EditorialCatalog::editUrl($composition);
|
||||||
|
$rows[] = [
|
||||||
|
'schluessel' => 'c'.$composition->id,
|
||||||
|
'titel' => $title,
|
||||||
|
'meta' => $kind->deskLabel().($title !== $composition->designation ? ' · '.$composition->designation : ''),
|
||||||
|
'text' => $summary,
|
||||||
|
'bild' => $cover['url'],
|
||||||
|
'bildFehlt' => 'Kein Titelbild',
|
||||||
|
'hinweise' => filled($cover['note']) ? ['Bild: '.$cover['note']] : [],
|
||||||
|
'symbol' => 'modul',
|
||||||
|
'url' => $url,
|
||||||
|
'chips' => array_map(fn (array $chip): array => [
|
||||||
|
'label' => $chip['label'],
|
||||||
|
'ton' => match ($chip['tone']) {
|
||||||
|
'pine' => 'gut',
|
||||||
|
'yellow' => 'offen',
|
||||||
|
'quiet' => 'leise',
|
||||||
|
default => 'neutral',
|
||||||
|
},
|
||||||
|
], $catalog->statusChips($composition, in_array($composition->id, $offered, true))),
|
||||||
|
'aktionen' => array_values(array_filter([
|
||||||
|
['label' => 'Aufbau', 'href' => $url, 'icon' => 'modul'],
|
||||||
|
$canEdit ? ['label' => 'Redaktion', 'href' => $url.'?redaktion=1', 'icon' => 'stift'] : null,
|
||||||
|
])),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Anlegedialog für Module und Programme; derselbe auf dem Arbeitsplatz und in den Listen.
|
||||||
|
*/
|
||||||
|
protected function createCompositionAction(CompositionKind $kind): Action
|
||||||
|
{
|
||||||
|
$label = $kind === CompositionKind::Kurs ? 'Programm' : 'Modul';
|
||||||
|
|
||||||
|
return Action::make($kind === CompositionKind::Kurs ? 'createProgram' : 'createModule')
|
||||||
|
->label($label.' anlegen')
|
||||||
|
->modalHeading('Neues '.$label)
|
||||||
|
->modalDescription('Der Name genügt. Danach öffnet sich der Aufbau; Texte, Bilder und Einordnung folgen dort und in der Redaktion.')
|
||||||
|
->modalSubmitActionLabel($label.' anlegen')
|
||||||
|
->modalWidth('lg')
|
||||||
|
->visible(fn (): bool => ContentElementResource::editor())
|
||||||
|
->schema([
|
||||||
|
TextInput::make('designation')->label('Name')->required()->maxLength(255),
|
||||||
|
])
|
||||||
|
->action(function (array $data) use ($kind): void {
|
||||||
|
abort_unless(ContentElementResource::editor(), 403);
|
||||||
|
$composition = app(EditorialCatalog::class)->create(trim((string) $data['designation']), $kind);
|
||||||
|
$this->redirect(EditorialCatalog::editUrl($composition), navigate: false);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{target: string}>
|
||||||
|
*/
|
||||||
|
private function coverMembers(Composition $composition): array
|
||||||
|
{
|
||||||
|
$draft = $composition->working_draft;
|
||||||
|
|
||||||
|
if (is_array($draft) && is_array($draft['members'] ?? null) && $draft['members'] !== []) {
|
||||||
|
return $draft['members'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$version = $composition->versions
|
||||||
|
->filter(fn ($item): bool => $item->status === ContentVersionStatus::Bereit)
|
||||||
|
->sortByDesc('number')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($version === null) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$members = [];
|
||||||
|
|
||||||
|
foreach ($version->members as $member) {
|
||||||
|
$members[] = ['target' => $member->content_element_version_id
|
||||||
|
? 'element:'.$member->content_element_version_id
|
||||||
|
: 'composition:'.$member->nested_composition_version_id];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $members;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<int>
|
||||||
|
*/
|
||||||
|
private function pillarSubjects(int $valueId): array
|
||||||
|
{
|
||||||
|
return IdentityDimensionValue::query()
|
||||||
|
->where('subject_type', (new Composition)->getMorphClass())
|
||||||
|
->where('editorial_dimension_value_id', $valueId)
|
||||||
|
->pluck('subject_id')
|
||||||
|
->map(fn (mixed $id): int => (int) $id)
|
||||||
|
->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array{text: string, number: int|null, released_number: int|null} $stand
|
||||||
|
*/
|
||||||
|
private function matchesVisibility(array $stand): bool
|
||||||
|
{
|
||||||
|
return match ($this->visibility) {
|
||||||
|
'bibliothek' => $stand['released_number'] !== null,
|
||||||
|
'verborgen' => $stand['number'] !== null && $stand['released_number'] === null,
|
||||||
|
'entwurf' => $stand['number'] === null,
|
||||||
|
default => true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,580 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\Composition;
|
||||||
|
use App\Domain\Catalog\CompositionKind;
|
||||||
|
use App\Domain\Catalog\CompositionMember;
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\ContentElementVersion;
|
||||||
|
use App\Domain\Catalog\ContentVersionStatus;
|
||||||
|
use App\Domain\Catalog\EditorialVocabulary;
|
||||||
|
use App\Domain\Catalog\IdentityDimensionValue;
|
||||||
|
use App\Domain\Catalog\Pillar;
|
||||||
|
use App\Domain\Catalog\ReleaseContent;
|
||||||
|
use App\Domain\Media\ThumbnailRef;
|
||||||
|
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class MediaLibrary
|
||||||
|
{
|
||||||
|
public function __construct(private readonly EditorialCatalog $catalog) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{value: string, label: string}>
|
||||||
|
*/
|
||||||
|
public function types(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['value' => 'film', 'label' => 'Film'],
|
||||||
|
['value' => 'text', 'label' => 'Text'],
|
||||||
|
['value' => 'document', 'label' => 'Dokument'],
|
||||||
|
['value' => 'bild', 'label' => 'Bild'],
|
||||||
|
['value' => 'audio', 'label' => 'Hörstück'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{id: int, name: string}>
|
||||||
|
*/
|
||||||
|
public function pillars(): array
|
||||||
|
{
|
||||||
|
return Pillar::query()
|
||||||
|
->orderBy('name')
|
||||||
|
->get(['id', 'name'])
|
||||||
|
->map(fn (Pillar $pillar): array => ['id' => $pillar->id, 'name' => $pillar->name])
|
||||||
|
->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<array{id: int, label: string}>
|
||||||
|
*/
|
||||||
|
public function classifications(array $selectedIds = []): array
|
||||||
|
{
|
||||||
|
$options = [];
|
||||||
|
|
||||||
|
// Gleiche Regel wie Editor und Picker; verwendete inaktive Werte und gewählte Filter bleiben auffindbar.
|
||||||
|
foreach (app(EditorialVocabulary::class)->dimensionFilterGroups($selectedIds) as $dimension) {
|
||||||
|
foreach ($dimension['values'] as $value) {
|
||||||
|
$options[] = [
|
||||||
|
'id' => $value['id'],
|
||||||
|
'label' => $dimension['label'].': '.$value['label'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $filters
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function cardFor(ContentElement $element, bool $canEdit): array
|
||||||
|
{
|
||||||
|
$element->loadMissing(['versions', 'pillars', 'editorialContentKind']);
|
||||||
|
$versionIds = $element->versions->pluck('id')->all();
|
||||||
|
|
||||||
|
return $this->card(
|
||||||
|
$element,
|
||||||
|
$this->portrait($element),
|
||||||
|
$this->placements($versionIds)[$element->id] ?? [],
|
||||||
|
$this->licenses($versionIds)[$element->id] ?? [],
|
||||||
|
$canEdit,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $filters
|
||||||
|
* @return list<array<string, mixed>>
|
||||||
|
*/
|
||||||
|
public function cards(array $filters, bool $canEdit): array
|
||||||
|
{
|
||||||
|
$filters = $this->normalize($filters);
|
||||||
|
$elements = ContentElement::query()
|
||||||
|
->with(['versions', 'pillars', 'editorialContentKind'])
|
||||||
|
->orderBy('working_title')
|
||||||
|
->get();
|
||||||
|
$versionIds = $elements->flatMap(fn (ContentElement $element) => $element->versions->pluck('id'))->all();
|
||||||
|
$placements = $this->placements($versionIds);
|
||||||
|
$licenses = $this->licenses($versionIds);
|
||||||
|
$classified = $this->classifiedIds();
|
||||||
|
$needle = mb_strtolower($filters['suche']);
|
||||||
|
$cards = [];
|
||||||
|
|
||||||
|
foreach ($elements as $element) {
|
||||||
|
$portrait = $this->portrait($element);
|
||||||
|
$uses = $placements[$element->id] ?? [];
|
||||||
|
$codes = $licenses[$element->id] ?? [];
|
||||||
|
|
||||||
|
if (! $this->matches($element, $portrait, $uses, $filters, $needle, $classified)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cards[] = $this->card($element, $portrait, $uses, $codes, $canEdit);
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($cards, fn (array $left, array $right): int => strcasecmp(
|
||||||
|
mb_strtolower($left['title']),
|
||||||
|
mb_strtolower($right['title']),
|
||||||
|
));
|
||||||
|
|
||||||
|
return $cards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, string> $filters
|
||||||
|
* @return array<string, string>
|
||||||
|
*/
|
||||||
|
private function normalize(array $filters): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'suche' => trim($filters['suche'] ?? ''),
|
||||||
|
'art' => $this->choice($filters['art'] ?? '', ['film', 'text', 'document', 'bild', 'audio']),
|
||||||
|
'freigabe' => $this->choice($filters['freigabe'] ?? '', ['freigegeben', 'entwurf', 'ohne']),
|
||||||
|
'entwurf' => $this->choice($filters['entwurf'] ?? '', ['offen', 'keiner']),
|
||||||
|
'fassung' => $this->choice($filters['fassung'] ?? '', ['mit', 'nur']),
|
||||||
|
'nutzung' => $this->choice($filters['nutzung'] ?? '', ['verwendet', 'unbenutzt']),
|
||||||
|
'saeule' => ctype_digit($filters['saeule'] ?? '') ? $filters['saeule'] : '',
|
||||||
|
'einordnung' => ctype_digit($filters['einordnung'] ?? '') ? $filters['einordnung'] : '',
|
||||||
|
'inhaltsart' => ctype_digit($filters['inhaltsart'] ?? '') ? $filters['inhaltsart'] : '',
|
||||||
|
'verarbeitung' => $this->choice($filters['verarbeitung'] ?? '', ['fehler', 'uebernahme']),
|
||||||
|
'archiv' => $this->choice($filters['archiv'] ?? '', ['aktiv', 'archiviert', 'alle'], 'aktiv'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $allowed
|
||||||
|
*/
|
||||||
|
private function choice(string $value, array $allowed, string $fallback = ''): string
|
||||||
|
{
|
||||||
|
return in_array($value, $allowed, true) ? $value : $fallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<int> $versionIds
|
||||||
|
* @return array<int, list<array<string, mixed>>>
|
||||||
|
*/
|
||||||
|
private function placements(array $versionIds): array
|
||||||
|
{
|
||||||
|
if ($versionIds === []) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$grouped = [];
|
||||||
|
$members = CompositionMember::query()
|
||||||
|
->whereIn('content_element_version_id', $versionIds)
|
||||||
|
->with(['compositionVersion.composition', 'contentElementVersion'])
|
||||||
|
->orderBy('id')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($members as $member) {
|
||||||
|
$version = $member->contentElementVersion;
|
||||||
|
$compositionVersion = $member->compositionVersion;
|
||||||
|
$composition = $compositionVersion?->composition;
|
||||||
|
|
||||||
|
if (! $version instanceof ContentElementVersion || $compositionVersion === null || ! $composition instanceof Composition) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$elementId = $version->content_element_id;
|
||||||
|
$key = $composition->id.'-'.$compositionVersion->id.'-'.$version->id;
|
||||||
|
$role = trim((string) $member->role);
|
||||||
|
|
||||||
|
if (! isset($grouped[$elementId][$key])) {
|
||||||
|
$grouped[$elementId][$key] = [
|
||||||
|
'compositionId' => $composition->id,
|
||||||
|
'name' => $this->catalog->compositionTitle($composition),
|
||||||
|
'type' => $this->kindLabel($composition),
|
||||||
|
'mediumVersion' => $this->versionLabel($version),
|
||||||
|
'mediumVersionId' => $version->id,
|
||||||
|
'hostVersion' => 'Fassung '.$compositionVersion->number,
|
||||||
|
'url' => EditorialCatalog::editUrl($composition),
|
||||||
|
'roles' => [],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($role !== '' && ! in_array($role, $grouped[$elementId][$key]['roles'], true)) {
|
||||||
|
$grouped[$elementId][$key]['roles'][] = $role;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$placements = [];
|
||||||
|
|
||||||
|
foreach ($grouped as $elementId => $rows) {
|
||||||
|
$list = array_values($rows);
|
||||||
|
usort($list, fn (array $left, array $right): int => [$left['type'], $left['name'], $left['hostVersion']]
|
||||||
|
<=> [$right['type'], $right['name'], $right['hostVersion']]);
|
||||||
|
$placements[$elementId] = $list;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $placements;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<int> $versionIds
|
||||||
|
* @return array<int, list<string>>
|
||||||
|
*/
|
||||||
|
private function licenses(array $versionIds): array
|
||||||
|
{
|
||||||
|
if ($versionIds === []) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$codes = [];
|
||||||
|
$contents = ReleaseContent::query()
|
||||||
|
->whereIn('content_element_version_id', $versionIds)
|
||||||
|
->with(['release.article', 'elementVersion'])
|
||||||
|
->orderBy('id')
|
||||||
|
->get();
|
||||||
|
|
||||||
|
foreach ($contents as $content) {
|
||||||
|
$version = $content->elementVersion;
|
||||||
|
$code = $content->release?->article?->code;
|
||||||
|
|
||||||
|
if (! $version instanceof ContentElementVersion || ! is_string($code) || $code === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$codes[$version->content_element_id][$code] = $code;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_map(fn (array $row): array => array_values($row), $codes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<int, list<int>>
|
||||||
|
*/
|
||||||
|
private function classifiedIds(): array
|
||||||
|
{
|
||||||
|
$map = [];
|
||||||
|
$rows = IdentityDimensionValue::query()
|
||||||
|
->where('subject_type', (new ContentElement)->getMorphClass())
|
||||||
|
->where('origin', 'direkt')
|
||||||
|
->get(['subject_id', 'editorial_dimension_value_id']);
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$map[(int) $row->subject_id][] = (int) $row->editorial_dimension_value_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $map;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array{
|
||||||
|
* ready: ?ContentElementVersion,
|
||||||
|
* draft: ?ContentElementVersion,
|
||||||
|
* blocked: ?ContentElementVersion,
|
||||||
|
* versionCount: int,
|
||||||
|
* archived: bool,
|
||||||
|
* processing: ?string,
|
||||||
|
* stand: string,
|
||||||
|
* standTone: string,
|
||||||
|
* draftNote: ?string,
|
||||||
|
* blockedNote: ?string
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
private function portrait(ContentElement $element): array
|
||||||
|
{
|
||||||
|
/** @var Collection<int, ContentElementVersion> $versions */
|
||||||
|
$versions = $element->versions->sortByDesc('number')->values();
|
||||||
|
$ready = $versions->first(fn (ContentElementVersion $version): bool => $version->status === ContentVersionStatus::Bereit);
|
||||||
|
$draft = $versions->first(fn (ContentElementVersion $version): bool => $version->status === ContentVersionStatus::Entwurf);
|
||||||
|
$blocked = $versions->first(fn (ContentElementVersion $version): bool => $version->status === ContentVersionStatus::Gesperrt);
|
||||||
|
$processing = $this->processing($versions);
|
||||||
|
|
||||||
|
if ($ready instanceof ContentElementVersion) {
|
||||||
|
$stand = 'Fassung '.$ready->number.' freigegeben';
|
||||||
|
$tone = 'ready';
|
||||||
|
} elseif ($draft instanceof ContentElementVersion) {
|
||||||
|
$stand = 'Entwurf, noch nicht freigegeben';
|
||||||
|
$tone = 'draft';
|
||||||
|
} elseif ($blocked instanceof ContentElementVersion) {
|
||||||
|
$stand = 'Fassung '.$blocked->number.' deaktiviert';
|
||||||
|
$tone = 'blocked';
|
||||||
|
} else {
|
||||||
|
$stand = 'Noch keine Fassung';
|
||||||
|
$tone = 'quiet';
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'ready' => $ready instanceof ContentElementVersion ? $ready : null,
|
||||||
|
'draft' => $draft instanceof ContentElementVersion ? $draft : null,
|
||||||
|
'blocked' => $blocked instanceof ContentElementVersion ? $blocked : null,
|
||||||
|
'versionCount' => $versions->count(),
|
||||||
|
'archived' => $element->archived_at !== null,
|
||||||
|
'processing' => $processing,
|
||||||
|
'stand' => $stand,
|
||||||
|
'standTone' => $tone,
|
||||||
|
'draftNote' => $ready instanceof ContentElementVersion && $draft instanceof ContentElementVersion
|
||||||
|
? 'Entwurf offen'
|
||||||
|
: null,
|
||||||
|
'blockedNote' => $blocked instanceof ContentElementVersion && ($ready instanceof ContentElementVersion || $draft instanceof ContentElementVersion)
|
||||||
|
? 'Fassung '.$blocked->number.' deaktiviert'
|
||||||
|
: null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Collection<int, ContentElementVersion> $versions
|
||||||
|
*/
|
||||||
|
private function processing(Collection $versions): ?string
|
||||||
|
{
|
||||||
|
foreach ($versions as $version) {
|
||||||
|
$meta = is_array($version->metadata) ? $version->metadata : [];
|
||||||
|
|
||||||
|
if (is_string($meta['error'] ?? null) && trim($meta['error']) !== '') {
|
||||||
|
return 'Verarbeitungsfehler';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($versions as $version) {
|
||||||
|
$meta = is_array($version->metadata) ? $version->metadata : [];
|
||||||
|
$incoming = $meta['incoming'] ?? null;
|
||||||
|
$hasIncoming = (is_string($incoming) && $incoming !== '') || (is_array($incoming) && $incoming !== []);
|
||||||
|
|
||||||
|
if ($hasIncoming && ! is_string($meta['file'] ?? null)) {
|
||||||
|
return 'Datei wird übernommen';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $portrait
|
||||||
|
* @param list<array<string, mixed>> $uses
|
||||||
|
* @param array<string, string> $filters
|
||||||
|
* @param array<int, list<int>> $classified
|
||||||
|
*/
|
||||||
|
private function matches(ContentElement $element, array $portrait, array $uses, array $filters, string $needle, array $classified): bool
|
||||||
|
{
|
||||||
|
if ($needle !== '' && ! str_contains($this->haystack($element), $needle)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $this->matchesArt($element, $filters['art'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$onlyBlocked = $portrait['ready'] === null && $portrait['draft'] === null && $portrait['blocked'] !== null;
|
||||||
|
|
||||||
|
if ($onlyBlocked && $filters['fassung'] === '' && $filters['archiv'] === 'aktiv') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['archiv'] === 'aktiv' && $portrait['archived']) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['archiv'] === 'archiviert' && ! $portrait['archived']) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['freigabe'] === 'freigegeben' && $portrait['ready'] === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['freigabe'] === 'entwurf' && ($portrait['draft'] === null || $portrait['ready'] !== null)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['freigabe'] === 'ohne' && $portrait['ready'] !== null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['entwurf'] === 'offen' && $portrait['draft'] === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['entwurf'] === 'keiner' && $portrait['draft'] !== null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['fassung'] === 'mit' && $portrait['blocked'] === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['fassung'] === 'nur' && ($portrait['blocked'] === null || $portrait['ready'] !== null || $portrait['draft'] !== null)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$used = $this->usageCount($uses) > 0;
|
||||||
|
|
||||||
|
if ($filters['nutzung'] === 'verwendet' && ! $used) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['nutzung'] === 'unbenutzt' && $used) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['saeule'] !== '' && ! $element->pillars->contains('id', (int) $filters['saeule'])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['einordnung'] !== '' && ! in_array((int) $filters['einordnung'], $classified[$element->id] ?? [], true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['inhaltsart'] !== '' && (int) $element->editorial_content_kind_id !== (int) $filters['inhaltsart']) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['verarbeitung'] === 'fehler' && $portrait['processing'] !== 'Verarbeitungsfehler') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($filters['verarbeitung'] === 'uebernahme' && $portrait['processing'] !== 'Datei wird übernommen') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function matchesArt(ContentElement $element, string $art): bool
|
||||||
|
{
|
||||||
|
if ($art === '') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$class = (string) $element->output_class;
|
||||||
|
|
||||||
|
if ($art === 'document') {
|
||||||
|
return in_array($class, ['document', 'pdf'], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $class === $art;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function haystack(ContentElement $element): string
|
||||||
|
{
|
||||||
|
return mb_strtolower(implode("\n", array_filter([
|
||||||
|
$element->working_title,
|
||||||
|
$element->display_title,
|
||||||
|
$element->description,
|
||||||
|
$element->summary,
|
||||||
|
$element->teaser,
|
||||||
|
$element->search_terms,
|
||||||
|
$element->usage_note,
|
||||||
|
], fn (mixed $value): bool => is_string($value) && trim($value) !== '')));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $portrait
|
||||||
|
* @param list<array<string, mixed>> $uses
|
||||||
|
* @param list<string> $codes
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function card(ContentElement $element, array $portrait, array $uses, array $codes, bool $canEdit): array
|
||||||
|
{
|
||||||
|
$description = trim((string) ($element->description ?: $element->summary ?: ''));
|
||||||
|
$usageNote = trim((string) $element->usage_note);
|
||||||
|
$licenseNote = trim((string) $element->license_note);
|
||||||
|
$typeKey = $this->typeKey((string) $element->output_class);
|
||||||
|
$count = $this->usageCount($uses);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'id' => $element->id,
|
||||||
|
'title' => $element->working_title,
|
||||||
|
'type' => $this->catalog->outputLabel((string) $element->output_class),
|
||||||
|
'editorialKind' => $element->editorialContentKind?->label,
|
||||||
|
'typeKey' => $typeKey,
|
||||||
|
'description' => $description === '' ? null : $description,
|
||||||
|
'usageNote' => $usageNote === '' ? null : $usageNote,
|
||||||
|
'licenseNote' => $licenseNote === '' ? null : $licenseNote,
|
||||||
|
'image' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
||||||
|
'imageAlt' => trim((string) ($element->thumbnail_alt ?: $element->working_title)),
|
||||||
|
'imageNote' => $this->imageNote($element),
|
||||||
|
'stand' => $portrait['stand'],
|
||||||
|
'standTone' => $portrait['standTone'],
|
||||||
|
'draftNote' => $portrait['draftNote'],
|
||||||
|
'blockedNote' => $portrait['blockedNote'],
|
||||||
|
'processing' => $portrait['processing'],
|
||||||
|
'archived' => $portrait['archived'],
|
||||||
|
'versionCount' => $portrait['versionCount'],
|
||||||
|
'versionLabel' => $this->versionCountLabel($portrait['versionCount']),
|
||||||
|
'usageCount' => $count,
|
||||||
|
'usageLabel' => $count === 0
|
||||||
|
? 'In keinem Modul oder Programm verwendet'
|
||||||
|
: ($count === 1 ? '1 Verwendung' : $count.' Verwendungen'),
|
||||||
|
'usages' => $uses,
|
||||||
|
'licenseText' => $this->licenseText($codes),
|
||||||
|
'url' => ContentElementResource::getUrl('view', ['record' => $element]),
|
||||||
|
'editUrl' => $canEdit ? ContentElementResource::getUrl('view', ['record' => $element, 'redaktion' => 1]) : null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<array<string, mixed>> $uses
|
||||||
|
*/
|
||||||
|
private function usageCount(array $uses): int
|
||||||
|
{
|
||||||
|
return count(array_unique(array_column($uses, 'compositionId')));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function versionCountLabel(int $count): ?string
|
||||||
|
{
|
||||||
|
return match ($count) {
|
||||||
|
0 => null,
|
||||||
|
1 => '1 Fassung',
|
||||||
|
default => $count.' Fassungen',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param list<string> $codes
|
||||||
|
*/
|
||||||
|
private function licenseText(array $codes): ?string
|
||||||
|
{
|
||||||
|
if ($codes === []) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$named = count($codes) === 1
|
||||||
|
? 'Im Lizenzartikel '.$codes[0].' genannt.'
|
||||||
|
: 'In den Lizenzartikeln '.implode(', ', $codes).' genannt.';
|
||||||
|
|
||||||
|
return $named.' Das belegt keinen Zugriff in der Bibliothek.';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function imageNote(ContentElement $element): ?string
|
||||||
|
{
|
||||||
|
if (is_string($element->thumbnail_error) && trim($element->thumbnail_error) !== '') {
|
||||||
|
return Str::limit(trim($element->thumbnail_error), 180);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function typeKey(string $outputClass): string
|
||||||
|
{
|
||||||
|
return match ($outputClass) {
|
||||||
|
'film' => 'film',
|
||||||
|
'audio' => 'audio',
|
||||||
|
'bild' => 'bild',
|
||||||
|
'document', 'pdf' => 'document',
|
||||||
|
default => 'text',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private function kindLabel(Composition $composition): string
|
||||||
|
{
|
||||||
|
$kind = $composition->kind;
|
||||||
|
|
||||||
|
return ($kind instanceof CompositionKind ? $kind : CompositionKind::from((string) $kind))->deskLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function versionLabel(ContentElementVersion $version): string
|
||||||
|
{
|
||||||
|
return match ($version->status) {
|
||||||
|
ContentVersionStatus::Entwurf => 'Entwurf',
|
||||||
|
ContentVersionStatus::Gesperrt => 'Fassung '.$version->number.', deaktiviert',
|
||||||
|
default => 'Fassung '.$version->number,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,9 @@
|
|||||||
use App\Domain\Catalog\ContentService;
|
use App\Domain\Catalog\ContentService;
|
||||||
use App\Domain\Catalog\DomainRuleException;
|
use App\Domain\Catalog\DomainRuleException;
|
||||||
use App\Domain\Catalog\IdentityProfile;
|
use App\Domain\Catalog\IdentityProfile;
|
||||||
|
use App\Domain\Media\PresentationFile;
|
||||||
use App\Jobs\DeriveThumbnail;
|
use App\Jobs\DeriveThumbnail;
|
||||||
|
use Filament\Forms\Components\Checkbox;
|
||||||
use Filament\Forms\Components\FileUpload;
|
use Filament\Forms\Components\FileUpload;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\Textarea;
|
use Filament\Forms\Components\Textarea;
|
||||||
@@ -39,6 +41,10 @@ public static function fields(bool $creating, ?ContentElement $element = null):
|
|||||||
$fields[] = self::fileField()
|
$fields[] = self::fileField()
|
||||||
->visible(fn ($get): bool => filled($get('shape')) && $get('shape') !== 'text')
|
->visible(fn ($get): bool => filled($get('shape')) && $get('shape') !== 'text')
|
||||||
->required(fn ($get): bool => filled($get('shape')) && $get('shape') !== 'text');
|
->required(fn ($get): bool => filled($get('shape')) && $get('shape') !== 'text');
|
||||||
|
$fields[] = Checkbox::make('without_version')
|
||||||
|
->label('Eigenständiges Präsentationsmedium')
|
||||||
|
->helperText('Bild, Film oder Hörstück ohne fachliche Inhaltsfassung. Die Datei bleibt eine technische Ableitung am Medium. Sie wird nicht lizenziert und nicht automatisch für die Website freigegeben.')
|
||||||
|
->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[] = Textarea::make('body')->label('Text')->rows(8)->required();
|
||||||
}
|
}
|
||||||
@@ -120,13 +126,17 @@ public static function create(array $data, bool $hold): ContentElement
|
|||||||
throw new DomainRuleException('Diese Datei passt nicht zur gewählten Art.');
|
throw new DomainRuleException('Diese Datei passt nicht zur gewählten Art.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$metadata = ['incoming' => $incoming];
|
if (! empty($data['without_version']) && in_array($output, ['bild', 'film', 'audio'], true)) {
|
||||||
|
app(PresentationFile::class)->store($element, $incoming);
|
||||||
if ($hold) {
|
|
||||||
$metadata['hold'] = true;
|
|
||||||
$service->draftElementVersion($element, null, $metadata);
|
|
||||||
} else {
|
} else {
|
||||||
$service->publishElementVersion($element, null, $metadata);
|
$metadata = ['incoming' => $incoming];
|
||||||
|
|
||||||
|
if ($hold) {
|
||||||
|
$metadata['hold'] = true;
|
||||||
|
$service->draftElementVersion($element, null, $metadata);
|
||||||
|
} else {
|
||||||
|
$service->publishElementVersion($element, null, $metadata);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,9 @@
|
|||||||
use App\Domain\Cms\Sections\PageSections;
|
use App\Domain\Cms\Sections\PageSections;
|
||||||
use App\Domain\Cms\Sections\SectionLayouts;
|
use App\Domain\Cms\Sections\SectionLayouts;
|
||||||
use App\Domain\Cms\Sections\SectionStyle;
|
use App\Domain\Cms\Sections\SectionStyle;
|
||||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\FileUpload;
|
|
||||||
use Filament\Forms\Components\Hidden;
|
use Filament\Forms\Components\Hidden;
|
||||||
use Filament\Forms\Components\Repeater;
|
use Filament\Forms\Components\Repeater;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
@@ -20,7 +19,6 @@
|
|||||||
use Filament\Schemas\Components\Utilities\Set;
|
use Filament\Schemas\Components\Utilities\Set;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Seiteneditor für Abschnitte und Slots.
|
* Seiteneditor für Abschnitte und Slots.
|
||||||
@@ -39,7 +37,8 @@ public static function repeater(string $name = 'sections'): Repeater
|
|||||||
->label('Abschnitte')
|
->label('Abschnitte')
|
||||||
->hiddenLabel()
|
->hiddenLabel()
|
||||||
->schema(self::sectionSchema())
|
->schema(self::sectionSchema())
|
||||||
->itemLabel(fn (array $state, ?int $index): string => self::sectionLabel($state, $index))
|
->columns(['default' => 1, 'xl' => 2])
|
||||||
|
->itemLabel(fn (array $state, ?int $index): HtmlString => self::sectionLabel($state, $index))
|
||||||
->addActionLabel('Abschnitt hinzufügen')
|
->addActionLabel('Abschnitt hinzufügen')
|
||||||
->addBetweenActionLabel('Abschnitt hier einfügen')
|
->addBetweenActionLabel('Abschnitt hier einfügen')
|
||||||
->defaultItems(0)
|
->defaultItems(0)
|
||||||
@@ -50,6 +49,7 @@ public static function repeater(string $name = 'sections'): Repeater
|
|||||||
->deletable()
|
->deletable()
|
||||||
->maxItems(PageSections::MAX_SECTIONS)
|
->maxItems(PageSections::MAX_SECTIONS)
|
||||||
->cloneAction(fn (Action $action): Action => $action
|
->cloneAction(fn (Action $action): Action => $action
|
||||||
|
->label('Abschnitt duplizieren')
|
||||||
->tooltip('Abschnitt duplizieren')
|
->tooltip('Abschnitt duplizieren')
|
||||||
->action(function (array $arguments, Repeater $component): void {
|
->action(function (array $arguments, Repeater $component): void {
|
||||||
// Die Kopie steht direkt hinter dem Original (Filament hängt sie sonst ans Seitenende).
|
// Die Kopie steht direkt hinter dem Original (Filament hängt sie sonst ans Seitenende).
|
||||||
@@ -58,16 +58,28 @@ public static function repeater(string $name = 'sections'): Repeater
|
|||||||
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
$component->shouldPartiallyRenderAfterActionsCalled() ? $component->partiallyRender() : null;
|
||||||
}))
|
}))
|
||||||
->deleteAction(fn (Action $action): Action => $action
|
->deleteAction(fn (Action $action): Action => $action
|
||||||
|
->label('Abschnitt löschen')
|
||||||
->tooltip('Abschnitt löschen')
|
->tooltip('Abschnitt löschen')
|
||||||
->requiresConfirmation()
|
->requiresConfirmation()
|
||||||
->modalHeading('Abschnitt löschen?')
|
->modalHeading('Abschnitt löschen?')
|
||||||
->modalDescription('Der Abschnitt und die Widgets darin werden aus dem Entwurf entfernt. Bereits gespeicherte Revisionen bleiben erhalten.')
|
->modalDescription('Der Abschnitt und die Widgets darin werden aus dem Entwurf entfernt. Bereits gespeicherte Revisionen bleiben erhalten.')
|
||||||
->modalSubmitActionLabel('Löschen'))
|
->modalSubmitActionLabel('Löschen'))
|
||||||
->moveUpAction(fn (Action $action): Action => $action->tooltip('Abschnitt nach oben'))
|
->moveUpAction(fn (Action $action): Action => $action->label('Abschnitt nach oben')->tooltip('Abschnitt nach oben'))
|
||||||
->moveDownAction(fn (Action $action): Action => $action->tooltip('Abschnitt nach unten'))
|
->moveDownAction(fn (Action $action): Action => $action->label('Abschnitt nach unten')->tooltip('Abschnitt nach unten'))
|
||||||
->reorderAction(fn (Action $action): Action => $action->tooltip('Abschnitt ziehen'))
|
->reorderAction(fn (Action $action): Action => $action->label('Abschnitt ziehen')->tooltip('Abschnitt ziehen'))
|
||||||
->collapseAction(fn (Action $action): Action => $action->tooltip('Abschnitt einklappen'))
|
->extraItemActions([
|
||||||
->expandAction(fn (Action $action): Action => $action->tooltip('Abschnitt aufklappen'))
|
// Seiten-Arbeitsplatz (EditPage): Raster und Gestaltung im eigenen Kontext statt an jedem Abschnitt.
|
||||||
|
Action::make('gestalten')
|
||||||
|
->label('Abschnitt gestalten')
|
||||||
|
->icon('heroicon-o-swatch')
|
||||||
|
->button()
|
||||||
|
->size('sm')
|
||||||
|
->color('gray')
|
||||||
|
->visible(fn ($livewire): bool => is_object($livewire) && method_exists($livewire, 'openAbschnitt'))
|
||||||
|
->action(fn (array $arguments, Repeater $component) => $component->getLivewire()->openAbschnitt((string) $arguments['item'])),
|
||||||
|
])
|
||||||
|
->collapseAction(fn (Action $action): Action => $action->label('Abschnitt einklappen')->tooltip('Abschnitt einklappen'))
|
||||||
|
->expandAction(fn (Action $action): Action => $action->label('Abschnitt aufklappen')->tooltip('Abschnitt aufklappen'))
|
||||||
->extraAttributes(['class' => 'luf-sections'])
|
->extraAttributes(['class' => 'luf-sections'])
|
||||||
->columnSpanFull();
|
->columnSpanFull();
|
||||||
}
|
}
|
||||||
@@ -79,33 +91,50 @@ private static function sectionSchema(): array
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Hidden::make('id'),
|
Hidden::make('id'),
|
||||||
ToggleButtons::make('layout')
|
// Abschnittsgestaltung in drei Gruppen. Im Seiten-Arbeitsplatz nur im Kontext „Abschnitt gestalten“
|
||||||
->label('Raster')
|
// sichtbar und dort offen; beim Anlegen einer Seite an jedem Abschnitt, eingeklappt.
|
||||||
->options(self::layoutOptions())
|
Section::make('Raster und Breite')
|
||||||
->default(SectionLayouts::DEFAULT)
|
->columnSpanFull()
|
||||||
->required()
|
->extraAttributes(['class' => 'luf-nur-gestalten luf-gestaltung'])
|
||||||
->inline()
|
->collapsible(fn ($livewire): bool => ! self::onWorkplace($livewire))
|
||||||
->live()
|
->collapsed(fn ($livewire): bool => ! self::onWorkplace($livewire))
|
||||||
->disableOptionWhen(fn (string $value, Get $get): bool => self::filledCount($get('slots')) > SectionLayouts::slotCount($value))
|
|
||||||
->helperText(fn (Get $get): ?string => self::filledCount($get('slots')) > 1
|
|
||||||
? 'Raster mit weniger Plätzen als eingesetzten Widgets sind gesperrt. Entfernen oder verschieben Sie zuerst ein Widget; beim Wechsel geht kein Widget verloren.'
|
|
||||||
: null)
|
|
||||||
->afterStateUpdated(function (?string $state, Get $get, Set $set): void {
|
|
||||||
$set('slots', self::arrangeSlots($get('slots'), $state ?? SectionLayouts::DEFAULT));
|
|
||||||
})
|
|
||||||
->extraAttributes(['class' => 'luf-layout-picker']),
|
|
||||||
Section::make('Gestaltung des Abschnitts')
|
|
||||||
->description(fn (Get $get): string => SectionStyle::summary(is_array($get('style')) ? $get('style') : []))
|
|
||||||
->icon('heroicon-o-swatch')
|
|
||||||
->collapsible()
|
|
||||||
->collapsed()
|
|
||||||
->compact()
|
->compact()
|
||||||
->schema([
|
->schema([
|
||||||
Group::make(self::styleFields())
|
ToggleButtons::make('layout')
|
||||||
->statePath('style')
|
->label('Raster')
|
||||||
->columns(['default' => 1, 'md' => 2, 'xl' => 4]),
|
->options(self::layoutOptions())
|
||||||
|
->default(SectionLayouts::DEFAULT)
|
||||||
|
->required()
|
||||||
|
->inline()
|
||||||
|
->live()
|
||||||
|
->disableOptionWhen(fn (string $value, Get $get): bool => self::filledCount($get('slots')) > SectionLayouts::slotCount($value))
|
||||||
|
->helperText(fn (Get $get): ?string => self::filledCount($get('slots')) > 1
|
||||||
|
? 'Raster mit weniger Plätzen als eingesetzten Widgets sind gesperrt. Entfernen oder verschieben Sie zuerst ein Widget; beim Wechsel geht kein Widget verloren.'
|
||||||
|
: null)
|
||||||
|
->afterStateUpdated(function (?string $state, Get $get, Set $set): void {
|
||||||
|
$set('slots', self::arrangeSlots($get('slots'), $state ?? SectionLayouts::DEFAULT));
|
||||||
|
})
|
||||||
|
->extraAttributes(['class' => 'luf-layout-picker']),
|
||||||
|
Group::make([self::widthField()])->statePath('style')->columns(['default' => 1, 'md' => 2]),
|
||||||
|
]),
|
||||||
|
Section::make('Hintergrund')
|
||||||
|
->extraAttributes(['class' => 'luf-nur-gestalten luf-gestaltung'])
|
||||||
|
->collapsible(fn ($livewire): bool => ! self::onWorkplace($livewire))
|
||||||
|
->collapsed(fn ($livewire): bool => ! self::onWorkplace($livewire))
|
||||||
|
->compact()
|
||||||
|
->schema([
|
||||||
|
Group::make(self::backgroundFields())->statePath('style')->columns(['default' => 1, 'md' => 2]),
|
||||||
|
]),
|
||||||
|
Section::make('Abstände und Trenner')
|
||||||
|
->extraAttributes(['class' => 'luf-nur-gestalten luf-gestaltung'])
|
||||||
|
->collapsible(fn ($livewire): bool => ! self::onWorkplace($livewire))
|
||||||
|
->collapsed(fn ($livewire): bool => ! self::onWorkplace($livewire))
|
||||||
|
->compact()
|
||||||
|
->schema([
|
||||||
|
Group::make(self::spacingFields())->statePath('style')->columns(['default' => 1, 'md' => 2]),
|
||||||
]),
|
]),
|
||||||
Repeater::make('slots')
|
Repeater::make('slots')
|
||||||
|
->columnSpanFull()
|
||||||
->label('Plätze im Raster')
|
->label('Plätze im Raster')
|
||||||
->hiddenLabel()
|
->hiddenLabel()
|
||||||
->schema([
|
->schema([
|
||||||
@@ -115,8 +144,8 @@ private static function sectionSchema(): array
|
|||||||
->deletable(false)
|
->deletable(false)
|
||||||
->reorderableWithDragAndDrop()
|
->reorderableWithDragAndDrop()
|
||||||
->reorderableWithButtons(false)
|
->reorderableWithButtons(false)
|
||||||
->reorderAction(fn (Action $action): Action => $action->tooltip('Widget auf einen anderen Platz ziehen'))
|
->reorderAction(fn (Action $action): Action => $action->label('Baustein auf einen anderen Platz ziehen')->tooltip('Baustein auf einen anderen Platz ziehen'))
|
||||||
->itemLabel(fn (array $state, ?int $index, Get $get): string => self::slotLabel($state, $index, $get('layout')))
|
->itemLabel(fn (array $state, ?int $index, Get $get): HtmlString => self::slotLabel($state, $index, $get('layout')))
|
||||||
->default(fn (): array => self::arrangeSlots([], SectionLayouts::DEFAULT))
|
->default(fn (): array => self::arrangeSlots([], SectionLayouts::DEFAULT))
|
||||||
->extraAttributes(fn (Get $get): array => [
|
->extraAttributes(fn (Get $get): array => [
|
||||||
'class' => 'luf-slots',
|
'class' => 'luf-slots',
|
||||||
@@ -125,10 +154,27 @@ private static function sectionSchema(): array
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function onWorkplace(mixed $livewire): bool
|
||||||
|
{
|
||||||
|
return is_object($livewire) && method_exists($livewire, 'openAbschnitt');
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function widthField(): Select
|
||||||
|
{
|
||||||
|
return Select::make('width')
|
||||||
|
->label('Inhaltsbreite')
|
||||||
|
->options(SectionStyle::WIDTHS)
|
||||||
|
->default('standard')
|
||||||
|
->selectablePlaceholder(false)
|
||||||
|
->hintIcon('heroicon-o-question-mark-circle', 'Ein Hintergrund reicht immer über die ganze Bildschirmbreite.');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Hintergrund; Bild, Ausschnitt und Überlagerung nur beim Hintergrund „Bild“.
|
||||||
|
*
|
||||||
* @return list<mixed>
|
* @return list<mixed>
|
||||||
*/
|
*/
|
||||||
private static function styleFields(): array
|
private static function backgroundFields(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
Select::make('background')
|
Select::make('background')
|
||||||
@@ -137,71 +183,59 @@ private static function styleFields(): array
|
|||||||
->default('default')
|
->default('default')
|
||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
->live(),
|
->live(),
|
||||||
Select::make('width')
|
...array_map(
|
||||||
->label('Breite')
|
fn ($field) => $field->visible(fn (Get $get): bool => $get('background') === 'image')->columnSpan(['default' => 1, 'md' => 2]),
|
||||||
->options(SectionStyle::WIDTHS)
|
ImageRefFields::fields('Hintergrundbild'),
|
||||||
->default('standard')
|
),
|
||||||
->selectablePlaceholder(false)
|
|
||||||
->helperText('Ein Hintergrund reicht immer über die ganze Bildschirmbreite.'),
|
|
||||||
Select::make('spacing_top')
|
|
||||||
->label('Abstand oben')
|
|
||||||
->options(SectionStyle::SPACINGS)
|
|
||||||
->default(SectionStyle::DEFAULTS['spacing_top'])
|
|
||||||
->selectablePlaceholder(false)
|
|
||||||
->helperText('Vor dem Inhalt. Zwischen zwei Abschnitten addieren sich „unten“ und „oben“; „Kein Abstand“ lässt einen Einstieg direkt unter der Kopfzeile beginnen.'),
|
|
||||||
Select::make('spacing_bottom')
|
|
||||||
->label('Abstand unten')
|
|
||||||
->options(SectionStyle::SPACINGS)
|
|
||||||
->default(SectionStyle::DEFAULTS['spacing_bottom'])
|
|
||||||
->selectablePlaceholder(false)
|
|
||||||
->helperText('Nach dem Inhalt. Bei eigener Fläche liegen beide Abstände innerhalb der Fläche.'),
|
|
||||||
Select::make('gap')
|
|
||||||
->label('Widget-Abstand')
|
|
||||||
->options(SectionStyle::SPACINGS)
|
|
||||||
->default(SectionStyle::DEFAULTS['gap'])
|
|
||||||
->selectablePlaceholder(false)
|
|
||||||
->helperText('Zwischen den Plätzen dieses Abschnitts, nebeneinander und gestapelt. Abstände innerhalb eines Widgets bleiben Sache des Widgets.'),
|
|
||||||
Select::make('divider')
|
|
||||||
->label('Trenner zum nächsten Abschnitt')
|
|
||||||
->options(SectionStyle::DIVIDERS)
|
|
||||||
->default('none')
|
|
||||||
->selectablePlaceholder(false),
|
|
||||||
Select::make('image')
|
|
||||||
->label('Hintergrundbild: vorhandenes Bild')
|
|
||||||
->options(fn (): array => PublicMedia::imageOptions())
|
|
||||||
->searchable()
|
|
||||||
->placeholder('Bitte wählen')
|
|
||||||
->helperText('Nur Bilder aus dem öffentlichen Website-Bereich. Geschützte Filmbilder sind hier nicht wählbar.')
|
|
||||||
->visible(fn (Get $get): bool => $get('background') === 'image')
|
|
||||||
->columnSpan(['default' => 1, 'md' => 2]),
|
|
||||||
FileUpload::make('_upload')
|
|
||||||
->label('Hintergrundbild: neu hochladen')
|
|
||||||
->disk('cms_incoming')
|
|
||||||
->directory('cms')
|
|
||||||
->image()
|
|
||||||
->maxSize(8192)
|
|
||||||
->acceptedFileTypes(['image/jpeg', 'image/png', 'image/webp'])
|
|
||||||
->getUploadedFileNameForStorageUsing(fn (TemporaryUploadedFile $file): string => Str::slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)).'-'.Str::lower(Str::random(6)).'.'.$file->guessExtension())
|
|
||||||
->helperText('Ersetzt die Auswahl links. Nur Bilder mit geklärter Veröffentlichungsfreigabe hochladen.')
|
|
||||||
->visible(fn (Get $get): bool => $get('background') === 'image')
|
|
||||||
->columnSpan(['default' => 1, 'md' => 2]),
|
|
||||||
Select::make('focus')
|
Select::make('focus')
|
||||||
->label('Bildausschnitt (Fokuspunkt)')
|
->label('Bildausschnitt (Fokuspunkt)')
|
||||||
->options(SectionStyle::FOCUS)
|
->options(SectionStyle::FOCUS)
|
||||||
->default('center')
|
->default('center')
|
||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
->helperText('Dieser Bereich bleibt auf schmalen Bildschirmen sichtbar.')
|
->hintIcon('heroicon-o-question-mark-circle', 'Dieser Bereich bleibt auf schmalen Bildschirmen sichtbar.')
|
||||||
->visible(fn (Get $get): bool => $get('background') === 'image'),
|
->visible(fn (Get $get): bool => $get('background') === 'image'),
|
||||||
Select::make('overlay')
|
Select::make('overlay')
|
||||||
->label('Überlagerung')
|
->label('Überlagerung')
|
||||||
->options(SectionStyle::OVERLAYS)
|
->options(SectionStyle::OVERLAYS)
|
||||||
->default('light')
|
->default('light')
|
||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
->helperText('Sorgt für lesbaren Text auf dem Bild.')
|
->hintIcon('heroicon-o-question-mark-circle', 'Sorgt für lesbaren Text auf dem Bild.')
|
||||||
->visible(fn (Get $get): bool => $get('background') === 'image'),
|
->visible(fn (Get $get): bool => $get('background') === 'image'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return list<mixed>
|
||||||
|
*/
|
||||||
|
private static function spacingFields(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Select::make('spacing_top')
|
||||||
|
->label('Abstand oben')
|
||||||
|
->options(SectionStyle::SPACINGS)
|
||||||
|
->default(SectionStyle::DEFAULTS['spacing_top'])
|
||||||
|
->selectablePlaceholder(false)
|
||||||
|
->hintIcon('heroicon-o-question-mark-circle', 'Vor dem Inhalt. Zwischen zwei Abschnitten addieren sich „unten“ und „oben“; „Kein Abstand“ lässt einen Einstieg direkt unter der Kopfzeile beginnen.'),
|
||||||
|
Select::make('spacing_bottom')
|
||||||
|
->label('Abstand unten')
|
||||||
|
->options(SectionStyle::SPACINGS)
|
||||||
|
->default(SectionStyle::DEFAULTS['spacing_bottom'])
|
||||||
|
->selectablePlaceholder(false)
|
||||||
|
->hintIcon('heroicon-o-question-mark-circle', 'Nach dem Inhalt. Bei eigener Fläche liegen beide Abstände innerhalb der Fläche.'),
|
||||||
|
Select::make('gap')
|
||||||
|
->label('Widget-Abstand')
|
||||||
|
->options(SectionStyle::SPACINGS)
|
||||||
|
->default(SectionStyle::DEFAULTS['gap'])
|
||||||
|
->selectablePlaceholder(false)
|
||||||
|
->hintIcon('heroicon-o-question-mark-circle', 'Zwischen den Plätzen dieses Abschnitts, nebeneinander und gestapelt. Abstände innerhalb eines Widgets bleiben Sache des Widgets.'),
|
||||||
|
Select::make('divider')
|
||||||
|
->label('Trenner zum nächsten Abschnitt')
|
||||||
|
->options(SectionStyle::DIVIDERS)
|
||||||
|
->default('none')
|
||||||
|
->selectablePlaceholder(false),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gespeicherte Abschnitte (PageSections::read) als Formularzustand.
|
* Gespeicherte Abschnitte (PageSections::read) als Formularzustand.
|
||||||
*
|
*
|
||||||
@@ -498,7 +532,7 @@ private static function editorColumns(mixed $layout): string
|
|||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $state
|
* @param array<string, mixed> $state
|
||||||
*/
|
*/
|
||||||
private static function sectionLabel(array $state, ?int $index): string
|
private static function sectionLabel(array $state, ?int $index): HtmlString
|
||||||
{
|
{
|
||||||
$layout = SectionLayouts::has($state['layout'] ?? null) ? $state['layout'] : SectionLayouts::DEFAULT;
|
$layout = SectionLayouts::has($state['layout'] ?? null) ? $state['layout'] : SectionLayouts::DEFAULT;
|
||||||
$registry = app(WidgetRegistry::class);
|
$registry = app(WidgetRegistry::class);
|
||||||
@@ -512,16 +546,48 @@ private static function sectionLabel(array $state, ?int $index): string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$label = 'Abschnitt '.(($index ?? 0) + 1).' · Raster '.SectionLayouts::short($layout)
|
// Kurz sichtbar: Nummer, Raster und nur abweichende Gestaltung. Vollständig im Titel und für Screenreader.
|
||||||
.' · '.SectionStyle::summary(is_array($state['style'] ?? null) ? $state['style'] : []);
|
$style = SectionStyle::fromStored(is_array($state['style'] ?? null) ? $state['style'] : []);
|
||||||
|
$meta = ['Raster '.SectionLayouts::short($layout)];
|
||||||
|
if ($style['background'] !== 'default') {
|
||||||
|
$meta[] = SectionStyle::BACKGROUNDS[$style['background']] ?? $style['background'];
|
||||||
|
}
|
||||||
|
if ($style['width'] !== 'standard') {
|
||||||
|
$meta[] = SectionStyle::WIDTHS[$style['width']] ?? $style['width'];
|
||||||
|
}
|
||||||
|
if ($style['divider'] !== 'none') {
|
||||||
|
$meta[] = 'Trenner';
|
||||||
|
}
|
||||||
|
if ($names === []) {
|
||||||
|
$meta[] = 'noch leer';
|
||||||
|
}
|
||||||
|
|
||||||
return $names === [] ? $label.' · noch leer' : $label.' · '.implode(', ', $names);
|
$name = 'Abschnitt '.(($index ?? 0) + 1);
|
||||||
|
$full = 'Raster '.SectionLayouts::short($layout).' · '.SectionStyle::summary($style)
|
||||||
|
.($names === [] ? ' · noch leer' : ' · '.implode(', ', $names));
|
||||||
|
|
||||||
|
return new HtmlString('<span class="luf-abschnitt" title="'.e($full).'"><span class="luf-abschnitt-nr">'.e($name).'</span>'
|
||||||
|
.'<span class="luf-abschnitt-meta" aria-hidden="true">'.e(implode(' · ', $meta)).'</span>'
|
||||||
|
.'<span class="vw-sr">: '.e($full).'</span></span>');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $state
|
* @param array<string, mixed> $state
|
||||||
*/
|
*/
|
||||||
private static function slotLabel(array $state, ?int $index, mixed $layout): string
|
private static function slotLabel(array $state, ?int $index, mixed $layout): HtmlString
|
||||||
|
{
|
||||||
|
$text = self::slotText($state, $index, $layout);
|
||||||
|
|
||||||
|
// Plätze zeigen sich über Lage und Breite; benannt werden sie nur für Screenreader oder bei einem Problem.
|
||||||
|
return str_contains($text, 'passt nicht') || str_contains($text, 'außerhalb')
|
||||||
|
? new HtmlString('<span class="luf-platz-warnung">'.e($text).'</span>')
|
||||||
|
: new HtmlString('<span class="vw-sr">'.e($text).'</span>');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed> $state
|
||||||
|
*/
|
||||||
|
private static function slotText(array $state, ?int $index, mixed $layout): string
|
||||||
{
|
{
|
||||||
$layout = SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT;
|
$layout = SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT;
|
||||||
$units = SectionLayouts::units($layout);
|
$units = SectionLayouts::units($layout);
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gemeinsame Bestandsliste (Ansicht filament.verwaltung.bestand). Die Seite beschreibt Suche, Filter und Zeilen in
|
||||||
|
* bestand() und setzt alle Filter in resetFilters() zurück. Die Liste zeigt zunächst Bestand::SCHRITT Einträge; jede
|
||||||
|
* Filteränderung beginnt wieder oben.
|
||||||
|
*/
|
||||||
|
trait ShowsBestand
|
||||||
|
{
|
||||||
|
public int $bestandGrenze = Bestand::SCHRITT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
abstract public function bestand(): array;
|
||||||
|
|
||||||
|
abstract public function resetFilters(): void;
|
||||||
|
|
||||||
|
public function mehrAnzeigen(): void
|
||||||
|
{
|
||||||
|
$this->bestandGrenze += Bestand::SCHRITT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Eigenschaften, deren Änderung die Liste wieder oben beginnen lässt (Suche und Filter). Andere Änderungen,
|
||||||
|
* etwa Eingaben in einem geöffneten Anlegedialog, lassen die angezeigte Menge unverändert.
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
abstract protected function bestandFilterEigenschaften(): array;
|
||||||
|
|
||||||
|
public function updatedShowsBestand(string $name): void
|
||||||
|
{
|
||||||
|
if (in_array($name, $this->bestandFilterEigenschaften(), true)) {
|
||||||
|
$this->bestandGrenze = Bestand::SCHRITT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Filament\Support;
|
namespace App\Filament\Support;
|
||||||
|
|
||||||
|
use App\Domain\Cms\Sections\SectionLayouts;
|
||||||
use App\Domain\Cms\Widgets\RenderContext;
|
use App\Domain\Cms\Widgets\RenderContext;
|
||||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||||
use App\Domain\Cms\Widgets\WidgetRenderer;
|
use App\Domain\Cms\Widgets\WidgetRenderer;
|
||||||
use App\Domain\Cms\Widgets\WidgetType;
|
use App\Domain\Cms\Widgets\WidgetType;
|
||||||
|
use Filament\Actions\Action;
|
||||||
use Filament\Forms\Components\Builder;
|
use Filament\Forms\Components\Builder;
|
||||||
use Filament\Forms\Components\Builder\Block;
|
use Filament\Forms\Components\Builder\Block;
|
||||||
use Filament\Forms\Components\Hidden;
|
use Filament\Forms\Components\Hidden;
|
||||||
@@ -20,6 +22,7 @@
|
|||||||
use Filament\Schemas\Components\Text;
|
use Filament\Schemas\Components\Text;
|
||||||
use Filament\Schemas\Components\Utilities\Get;
|
use Filament\Schemas\Components\Utilities\Get;
|
||||||
use Filament\Schemas\Components\View;
|
use Filament\Schemas\Components\View;
|
||||||
|
use Filament\Support\Enums\Width;
|
||||||
use Illuminate\Foundation\Vite;
|
use Illuminate\Foundation\Vite;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
@@ -82,8 +85,38 @@ public static function slotBuilder(string $name = 'widget'): Builder
|
|||||||
->deletable()
|
->deletable()
|
||||||
->collapsible(false)
|
->collapsible(false)
|
||||||
->addAction(fn ($action) => $action->modalHeading('Widget einrichten')->modalWidth('4xl')->icon('heroicon-o-plus'))
|
->addAction(fn ($action) => $action->modalHeading('Widget einrichten')->modalWidth('4xl')->icon('heroicon-o-plus'))
|
||||||
->editAction(fn ($action) => $action->modalHeading('Widget bearbeiten')->modalWidth('4xl')->modalSubmitActionLabel('Übernehmen')->tooltip('Widget bearbeiten'))
|
// Baustein konfigurieren (Dokument 12, CMS-R03/R11): großer Kontext mit Vorschau. „Zur Seite“ übernimmt die
|
||||||
->deleteAction(fn ($action) => $action->tooltip('Widget aus diesem Platz entfernen')->requiresConfirmation()->modalHeading('Widget entfernen?')->modalDescription('Das Widget wird aus dem Entwurf entfernt. Gespeicherte Revisionen bleiben erhalten.')->modalSubmitActionLabel('Entfernen'))
|
// Eingaben in den Seitenentwurf; Verwerfen ist eine ausdrückliche Handlung, Esc und Klick daneben verwerfen
|
||||||
|
// nichts still. Eine Bearbeitung direkt in der Seite war gemessen deutlich langsamer (Abnahme Teil C).
|
||||||
|
->editAction(fn (Action $action) => $action
|
||||||
|
->label('Konfigurieren')
|
||||||
|
->icon('heroicon-o-adjustments-horizontal')
|
||||||
|
->button()
|
||||||
|
->size('sm')
|
||||||
|
->color('gray')
|
||||||
|
->modalHeading(fn (Builder $component, array $arguments): string => self::configureHeading($component, (string) ($arguments['item'] ?? '')))
|
||||||
|
->modalDescription(fn ($livewire): string => method_exists($livewire, 'openAbschnitt')
|
||||||
|
? 'Eingaben gelten im Seitenentwurf. „Zum Seitenaufbau“ kehrt an diese Stelle zurück, „Entwurf speichern“ sichert zusätzlich die Seite.'
|
||||||
|
: 'Eingaben gelten im Entwurf der neuen Seite.')
|
||||||
|
->modalWidth(Width::Screen)
|
||||||
|
->modalSubmitActionLabel('Zum Seitenaufbau')
|
||||||
|
// Kein Zwischenschritt: Speichern geht direkt aus dem Baustein (übernimmt und speichert den Entwurf).
|
||||||
|
->extraModalFooterActions(fn (Action $action, $livewire): array => method_exists($livewire, 'saveFromBlock')
|
||||||
|
? [$action->makeModalSubmitAction('entwurfSpeichern', arguments: ['speichern' => true])->label('Entwurf speichern')->color('gray')]
|
||||||
|
: [])
|
||||||
|
->after(function (array $arguments, $livewire): void {
|
||||||
|
if (($arguments['speichern'] ?? false) && method_exists($livewire, 'saveFromBlock')) {
|
||||||
|
$livewire->saveFromBlock();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->modalCancelActionLabel('Änderungen verwerfen')
|
||||||
|
->closeModalByClickingAway(false)
|
||||||
|
->closeModalByEscaping(false)
|
||||||
|
->modalCloseButton(false)
|
||||||
|
// Eigener Scrollbereich: Sonst wächst der Inhalt über das Fenster und der Dialogfuß ist bei schmalen
|
||||||
|
// Fenstern (Vorschau unter dem Formular) nicht erreichbar.
|
||||||
|
->extraModalWindowAttributes(['class' => 'luf-baustein-dialog']))
|
||||||
|
->deleteAction(fn ($action) => $action->label('Baustein entfernen')->tooltip('Baustein aus diesem Platz entfernen')->requiresConfirmation()->modalHeading('Widget entfernen?')->modalDescription('Das Widget wird aus dem Entwurf entfernt. Gespeicherte Revisionen bleiben erhalten.')->modalSubmitActionLabel('Entfernen'))
|
||||||
->columnSpanFull();
|
->columnSpanFull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,11 +179,14 @@ public static function block(WidgetType $type): Block
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auf breiten Schirmen stehen Inhalt/Medien/Darstellung und die Bausteinvorschau nebeneinander.
|
||||||
$schema = [
|
$schema = [
|
||||||
Hidden::make('id'),
|
Hidden::make('id'),
|
||||||
...$variantField,
|
...$variantField,
|
||||||
Tabs::make('Widget')->tabs($tabs)->contained(false),
|
Grid::make(['default' => 1, 'xl' => 5])->schema([
|
||||||
self::livePreview($type),
|
Tabs::make('Widget')->tabs($tabs)->contained(false)->columnSpan(['default' => 1, 'xl' => 3]),
|
||||||
|
self::livePreview($type)->columnSpan(['default' => 1, 'xl' => 2]),
|
||||||
|
]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +203,35 @@ public static function block(WidgetType $type): Block
|
|||||||
->preview('filament.cms.widget-preview');
|
->preview('filament.cms.widget-preview');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* „Programmkarte konfigurieren · Abschnitt 2 · Platz 2 · 1 Einheit“ aus dem Zustandspfad des Platzes.
|
||||||
|
*/
|
||||||
|
public static function configureHeading(Builder $component, string $itemKey): string
|
||||||
|
{
|
||||||
|
$registry = app(WidgetRegistry::class);
|
||||||
|
$type = $component->getRawState()[$itemKey]['type'] ?? null;
|
||||||
|
$heading = ($registry->has($type) ? $registry->get($type)->label() : 'Baustein').' konfigurieren';
|
||||||
|
|
||||||
|
if (preg_match('/sections\.([^.]+)\.slots\.([^.]+)\.widget$/', (string) $component->getStatePath(), $match) !== 1) {
|
||||||
|
return $heading;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sections = $component->getLivewire()->data['sections'] ?? [];
|
||||||
|
$sectionIndex = array_search($match[1], array_map('strval', array_keys(is_array($sections) ? $sections : [])), true);
|
||||||
|
$slots = is_array($sections[$match[1]]['slots'] ?? null) ? $sections[$match[1]]['slots'] : [];
|
||||||
|
$slotIndex = array_search($match[2], array_map('strval', array_keys($slots)), true);
|
||||||
|
|
||||||
|
if ($sectionIndex === false || $slotIndex === false) {
|
||||||
|
return $heading;
|
||||||
|
}
|
||||||
|
|
||||||
|
$layout = $sections[$match[1]]['layout'] ?? SectionLayouts::DEFAULT;
|
||||||
|
$units = SectionLayouts::units(SectionLayouts::has($layout) ? $layout : SectionLayouts::DEFAULT)[$slotIndex] ?? null;
|
||||||
|
|
||||||
|
return $heading.' · Abschnitt '.($sectionIndex + 1).' · Platz '.($slotIndex + 1)
|
||||||
|
.($units !== null ? ' · '.$units.' '.($units === 1 ? 'Einheit' : 'Einheiten') : '');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gespeicherte Bausteine (Altformat oder Hülle) als Builder-Zustand.
|
* Gespeicherte Bausteine (Altformat oder Hülle) als Builder-Zustand.
|
||||||
*
|
*
|
||||||
@@ -305,6 +370,9 @@ private static function livePreview(WidgetType $type): Section
|
|||||||
->hiddenLabel()
|
->hiddenLabel()
|
||||||
->options($widths)
|
->options($widths)
|
||||||
->default($default)
|
->default($default)
|
||||||
|
// Beim Bearbeiten fehlt der Wert (er wird nicht gespeichert); ohne ihn zeigte die Vorschau die
|
||||||
|
// Vorgabe, ohne dass ein Knopf als gewählt markiert war.
|
||||||
|
->afterStateHydrated(fn (ToggleButtons $component, mixed $state) => filled($state) ? null : $component->state($default))
|
||||||
->inline()
|
->inline()
|
||||||
->live()
|
->live()
|
||||||
->dehydrated(false)
|
->dehydrated(false)
|
||||||
@@ -385,7 +453,7 @@ private static function unitsHint(WidgetType $type): string
|
|||||||
/**
|
/**
|
||||||
* @param array<string, mixed> $state
|
* @param array<string, mixed> $state
|
||||||
*/
|
*/
|
||||||
private static function itemLabel(WidgetType $type, array $state): string
|
private static function itemLabel(WidgetType $type, array $state): HtmlString
|
||||||
{
|
{
|
||||||
$variant = $state['variant'] ?? $type->defaultVariant();
|
$variant = $state['variant'] ?? $type->defaultVariant();
|
||||||
$variantLabel = $type->variants()[$variant] ?? null;
|
$variantLabel = $type->variants()[$variant] ?? null;
|
||||||
@@ -409,7 +477,11 @@ private static function itemLabel(WidgetType $type, array $state): string
|
|||||||
|
|
||||||
$label = implode(' · ', $parts);
|
$label = implode(' · ', $parts);
|
||||||
|
|
||||||
return $summary !== '' ? $label.' – '.Str::limit($summary, 90) : $label;
|
// Kurzer Name des Bausteins und eine knappe Inhaltsangabe; vollständig im Titel.
|
||||||
|
return new HtmlString('<span class="luf-baustein" title="'.e($summary !== '' ? $label.' – '.$summary : $label).'">'
|
||||||
|
.'<span class="luf-baustein-name">'.e($type->label()).'</span>'
|
||||||
|
.($summary !== '' ? '<span class="luf-baustein-kurz">'.e(Str::limit($summary, 60)).'</span>' : '')
|
||||||
|
.'</span>');
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function schematicSvg(WidgetType $type): string
|
private static function schematicSvg(WidgetType $type): string
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
use App\Domain\Catalog\Composition;
|
use App\Domain\Catalog\Composition;
|
||||||
use App\Domain\Catalog\ContentElement;
|
use App\Domain\Catalog\ContentElement;
|
||||||
use App\Domain\Catalog\ContentElementVersion;
|
use App\Domain\Catalog\ContentElementVersion;
|
||||||
use App\Domain\Catalog\EditorialDimension;
|
use App\Domain\Catalog\EditorialVocabulary;
|
||||||
use App\Domain\Catalog\IdentityDimension;
|
use App\Domain\Catalog\IdentityDimension;
|
||||||
use App\Domain\Catalog\LicenseArticle;
|
use App\Domain\Catalog\LicenseArticle;
|
||||||
use App\Domain\Entitlement\DecideAccess;
|
use App\Domain\Entitlement\DecideAccess;
|
||||||
@@ -89,7 +89,7 @@ function (array $card) use ($dimensions, $dimensionIds): bool {
|
|||||||
'sicht' => $sicht,
|
'sicht' => $sicht,
|
||||||
'nutzung' => $nutzung,
|
'nutzung' => $nutzung,
|
||||||
'dimensionIds' => $dimensionIds,
|
'dimensionIds' => $dimensionIds,
|
||||||
'filterDimensions' => EditorialDimension::query()->with('values')->orderBy('label')->get(),
|
'filterDimensions' => app(EditorialVocabulary::class)->memberFilterDimensions(array_map(intval(...), $dimensionIds)),
|
||||||
'libraryEmpty' => $untouched,
|
'libraryEmpty' => $untouched,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,15 +2,21 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use App\Domain\Media\WebsiteMediaAlias;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
class PublicMediaController extends Controller
|
class PublicMediaController extends Controller
|
||||||
{
|
{
|
||||||
public function show(string $path): StreamedResponse
|
public function show(string $path, WebsiteMedia $media): StreamedResponse
|
||||||
{
|
{
|
||||||
abort_if(str_contains($path, '..') || ! str_starts_with($path, 'cms/'), 404);
|
abort_if(str_contains($path, '..') || ! str_starts_with($path, 'cms/'), 404);
|
||||||
|
|
||||||
|
// Ein in den Medienmanager übernommenes Bild folgt dessen Website-Freigabe, auch unter der früheren Adresse.
|
||||||
|
$alias = WebsiteMediaAlias::effectiveFor($path);
|
||||||
|
abort_if($alias !== null && $media->present($alias->content_element_id) === null, 404);
|
||||||
|
|
||||||
foreach (['media_public', 'cms_incoming'] as $disk) {
|
foreach (['media_public', 'cms_incoming'] as $disk) {
|
||||||
if (Storage::disk($disk)->exists($path)) {
|
if (Storage::disk($disk)->exists($path)) {
|
||||||
return Storage::disk($disk)->response($path);
|
return Storage::disk($disk)->response($path);
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Media\WebsiteMedia;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
|
|
||||||
|
class WebsiteMediaController extends Controller
|
||||||
|
{
|
||||||
|
public function show(ContentElement $element, WebsiteMedia $media): StreamedResponse
|
||||||
|
{
|
||||||
|
$presentation = $media->present($element);
|
||||||
|
abort_if($presentation === null, 404);
|
||||||
|
|
||||||
|
$path = $element->website_public_path;
|
||||||
|
abort_if(! is_string($path), 404);
|
||||||
|
|
||||||
|
return Storage::disk('media_public')->response($path, null, [
|
||||||
|
'Content-Disposition' => 'inline',
|
||||||
|
'X-Content-Type-Options' => 'nosniff',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Media\ThumbnailDeriver;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class AcceptWebsiteImage implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public int $elementId,
|
||||||
|
public string $incoming,
|
||||||
|
public ?int $actorId = null,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function handle(ThumbnailDeriver $deriver, WebsiteRelease $release): void
|
||||||
|
{
|
||||||
|
$element = ContentElement::query()->find($this->elementId);
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$deriver->forWebsiteImage($element, $this->incoming);
|
||||||
|
$element->refresh();
|
||||||
|
|
||||||
|
if ($release->derivedPath($element) === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->incomingIsDisposable()) {
|
||||||
|
Storage::disk('cms_incoming')->delete($this->incoming);
|
||||||
|
}
|
||||||
|
|
||||||
|
PublishWebsiteMedia::dispatch($element->id, 'release', $this->actorId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function incomingIsDisposable(): bool
|
||||||
|
{
|
||||||
|
return (str_starts_with($this->incoming, 'cms/') || str_starts_with($this->incoming, 'vorschau/'))
|
||||||
|
&& ! str_contains($this->incoming, '..');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Domain\Media\WebsiteIntake;
|
||||||
|
use App\Domain\Media\WebsiteMediaAlias;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Übernimmt die bisherigen CMS-Bilder (media_public, cms/…) in den Medienmanager.
|
||||||
|
*
|
||||||
|
* - Bytegleiche Dateien werden ein Medium (SHA-256); jeder frühere Pfad erhält eine Zuordnung (WebsiteMediaAlias).
|
||||||
|
* - Neue Medien entstehen über WebsiteIntake: Die Warteschlange leitet das Bild ab und gibt genau diese Ableitung
|
||||||
|
* für die Website frei. Erst danach wird die Zuordnung wirksam; bis dahin bleibt der frühere Pfad gültig.
|
||||||
|
* - Wiederholbar: Bereits zugeordnete Pfade werden übersprungen. Es wird nichts gelöscht; die Dateien unter cms/
|
||||||
|
* bleiben liegen (frühere Revisionen, Rückweg).
|
||||||
|
*/
|
||||||
|
class ImportCmsImages implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
private const EXTENSIONS = ['jpg', 'jpeg', 'png', 'webp', 'gif'];
|
||||||
|
|
||||||
|
public function handle(WebsiteIntake $intake): void
|
||||||
|
{
|
||||||
|
$public = Storage::disk('media_public');
|
||||||
|
|
||||||
|
try {
|
||||||
|
$files = $public->allFiles('cms');
|
||||||
|
} catch (Throwable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sort($files);
|
||||||
|
|
||||||
|
foreach ($files as $path) {
|
||||||
|
if (! $this->isImage($path) || WebsiteMediaAlias::query()->where('legacy_path', $path)->exists()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$bytes = $public->get($path);
|
||||||
|
|
||||||
|
if (! is_string($bytes) || $bytes === '') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$hash = hash('sha256', $bytes);
|
||||||
|
$twin = WebsiteMediaAlias::query()->where('sha256', $hash)->first();
|
||||||
|
|
||||||
|
if ($twin instanceof WebsiteMediaAlias) {
|
||||||
|
WebsiteMediaAlias::query()->create(['legacy_path' => $path, 'content_element_id' => $twin->content_element_id, 'sha256' => $hash]);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Storage::disk('cms_incoming')->put($path, $bytes);
|
||||||
|
$element = $intake->acceptImage($path, self::titleFor($path));
|
||||||
|
WebsiteMediaAlias::query()->create(['legacy_path' => $path, 'content_element_id' => $element->id, 'sha256' => $hash]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** „cms/platzhalter-karte-1-liyjqa.jpg“ → „Platzhalter Karte 1“ (ohne die angehängte Zufallskennung). */
|
||||||
|
public static function titleFor(string $path): string
|
||||||
|
{
|
||||||
|
$name = pathinfo($path, PATHINFO_FILENAME);
|
||||||
|
$name = preg_replace('/-[a-z0-9]{6}$/', '', $name) ?? $name;
|
||||||
|
$title = trim(str_replace(['-', '_'], ' ', $name));
|
||||||
|
|
||||||
|
return $title === '' ? 'Website-Bild' : Str::title($title);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isImage(string $path): bool
|
||||||
|
{
|
||||||
|
return str_starts_with($path, 'cms/')
|
||||||
|
&& ! str_contains($path, '..')
|
||||||
|
&& preg_match('#^cms/[A-Za-z0-9._\-/]+$#', $path) === 1
|
||||||
|
&& in_array(strtolower(pathinfo($path, PATHINFO_EXTENSION)), self::EXTENSIONS, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Jobs;
|
||||||
|
|
||||||
|
use App\Domain\Catalog\ContentElement;
|
||||||
|
use App\Domain\Catalog\IdentityChange;
|
||||||
|
use App\Domain\Media\WebsiteRelease;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Foundation\Queue\Queueable;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class PublishWebsiteMedia implements ShouldQueue
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public int $elementId,
|
||||||
|
public string $action,
|
||||||
|
public ?int $actorId = null,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function handle(WebsiteRelease $release): void
|
||||||
|
{
|
||||||
|
$element = ContentElement::query()->find($this->elementId);
|
||||||
|
|
||||||
|
if (! $element instanceof ContentElement || ! in_array($this->action, ['release', 'withdraw'], true)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->action === 'withdraw') {
|
||||||
|
$this->deletePublicFile($element);
|
||||||
|
$this->mark($element, $element->website_released_at?->toIso8601String(), null);
|
||||||
|
$element->forceFill([
|
||||||
|
'website_released_at' => null,
|
||||||
|
'website_public_path' => null,
|
||||||
|
])->save();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$derived = $release->derivedPath($element);
|
||||||
|
|
||||||
|
if ($derived === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$target = $release->publicPath($element, $derived);
|
||||||
|
$previous = $element->website_public_path;
|
||||||
|
|
||||||
|
Storage::disk('media_public')->put($target, Storage::disk('media_derived')->get($derived));
|
||||||
|
|
||||||
|
if (is_string($previous) && $previous !== $target && str_starts_with($previous, 'website/'.$element->id.'/')) {
|
||||||
|
Storage::disk('media_public')->delete($previous);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->mark($element, $element->website_released_at?->toIso8601String(), now()->toIso8601String());
|
||||||
|
$element->forceFill([
|
||||||
|
'website_released_at' => now(),
|
||||||
|
'website_public_path' => $target,
|
||||||
|
])->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function deletePublicFile(ContentElement $element): void
|
||||||
|
{
|
||||||
|
$path = $element->website_public_path;
|
||||||
|
|
||||||
|
if (! is_string($path) || ! str_starts_with($path, 'website/'.$element->id.'/') || str_contains($path, '..')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Storage::disk('media_public')->delete($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function mark(ContentElement $element, ?string $before, ?string $after): void
|
||||||
|
{
|
||||||
|
if ($before === $after) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IdentityChange::query()->create([
|
||||||
|
'subject_type' => $element->getMorphClass(),
|
||||||
|
'subject_id' => $element->id,
|
||||||
|
'field' => 'website_released_at',
|
||||||
|
'before' => $before,
|
||||||
|
'after' => $after,
|
||||||
|
'actor_id' => $this->actorId,
|
||||||
|
'occurred_at' => now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
use App\Domain\Cms\NavigationItemPolicy;
|
use App\Domain\Cms\NavigationItemPolicy;
|
||||||
use App\Domain\Cms\Page;
|
use App\Domain\Cms\Page;
|
||||||
use App\Domain\Cms\PagePolicy;
|
use App\Domain\Cms\PagePolicy;
|
||||||
|
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||||
use App\Domain\Cms\Widgets\WidgetRegistry;
|
use App\Domain\Cms\Widgets\WidgetRegistry;
|
||||||
use App\Domain\Media\FfmpegFilmTranscoder;
|
use App\Domain\Media\FfmpegFilmTranscoder;
|
||||||
use App\Domain\Media\FilmTranscoder;
|
use App\Domain\Media\FilmTranscoder;
|
||||||
@@ -26,6 +27,7 @@ public function register(): void
|
|||||||
$this->app->bind(FilmTranscoder::class, FfmpegFilmTranscoder::class);
|
$this->app->bind(FilmTranscoder::class, FfmpegFilmTranscoder::class);
|
||||||
// Je Anfrage einmal den Index der öffentlich genannten Medien bilden, nicht je Karte.
|
// Je Anfrage einmal den Index der öffentlich genannten Medien bilden, nicht je Karte.
|
||||||
$this->app->scoped(PublicMaterialReader::class);
|
$this->app->scoped(PublicMaterialReader::class);
|
||||||
|
$this->app->scoped(WebsiteImage::class);
|
||||||
$this->app->singleton(WidgetRegistry::class, fn ($app): WidgetRegistry => new WidgetRegistry(
|
$this->app->singleton(WidgetRegistry::class, fn ($app): WidgetRegistry => new WidgetRegistry(
|
||||||
array_map(fn (string $class) => $app->make($class), config('cms.widgets', [])),
|
array_map(fn (string $class) => $app->make($class), config('cms.widgets', [])),
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public function panel(Panel $panel): Panel
|
|||||||
->brandName('Verwaltung')
|
->brandName('Verwaltung')
|
||||||
->authGuard('staff')
|
->authGuard('staff')
|
||||||
->colors([
|
->colors([
|
||||||
'primary' => Color::hex('#0F6E56'),
|
'primary' => Color::hex('#3b7b09'),
|
||||||
])
|
])
|
||||||
->multiFactorAuthentication([
|
->multiFactorAuthentication([
|
||||||
AppAuthentication::make()
|
AppAuthentication::make()
|
||||||
@@ -69,7 +69,7 @@ public function panel(Panel $panel): Panel
|
|||||||
])
|
])
|
||||||
->renderHook(
|
->renderHook(
|
||||||
PanelsRenderHook::STYLES_AFTER,
|
PanelsRenderHook::STYLES_AFTER,
|
||||||
fn (): string => view('filament.cms.styles')->render(),
|
fn (): string => view('filament.cms.styles')->render().view('filament.verwaltung.styles')->render(),
|
||||||
)
|
)
|
||||||
->renderHook(
|
->renderHook(
|
||||||
PanelsRenderHook::BODY_END,
|
PanelsRenderHook::BODY_END,
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('content_elements', function (Blueprint $table) {
|
||||||
|
$table->text('website_credit')->nullable()->after('license_note');
|
||||||
|
$table->string('website_alt')->nullable()->after('website_credit');
|
||||||
|
$table->timestamp('website_released_at')->nullable()->after('website_alt');
|
||||||
|
$table->string('website_public_path')->nullable()->after('website_released_at');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('content_elements', function (Blueprint $table) {
|
||||||
|
$table->dropColumn([
|
||||||
|
'website_credit',
|
||||||
|
'website_alt',
|
||||||
|
'website_released_at',
|
||||||
|
'website_public_path',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zuordnung früherer CMS-Bildpfade (cms/…) zu Medien im Medienmanager. Additiv: Gespeicherte Revisionen und
|
||||||
|
* die Dateien unter cms/ bleiben unverändert; die Zuordnung wird beim Darstellen gelesen.
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('website_media_aliases', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('legacy_path')->unique();
|
||||||
|
$table->foreignId('content_element_id')->constrained()->restrictOnDelete();
|
||||||
|
$table->string('sha256', 64)->index();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('website_media_aliases');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Jobs\ImportCmsImages;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Übernimmt die bisherigen CMS-Bilder (media_public, cms/…) in den Medienmanager. Die Migration läuft im
|
||||||
|
* App-Container, der keine Medien schreibt; sie stößt deshalb nur den Job der Hintergrundverarbeitung an.
|
||||||
|
* Der Job ist wiederholbar und löscht nichts.
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
// In Tests liegen echte Medien nicht vor; die Übernahme prüfen eigene Tests mit Testplatten.
|
||||||
|
if (app()->runningUnitTests()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImportCmsImages::dispatch();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
// Nichts zurückzunehmen: Die übernommenen Medien und Zuordnungen bleiben; die Tabelle entfernt die vorige Migration.
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('content_elements', function (Blueprint $table) {
|
||||||
|
$table->text('teaser')->nullable()->after('display_title');
|
||||||
|
$table->text('search_terms')->nullable()->after('summary');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('compositions', function (Blueprint $table) {
|
||||||
|
$table->text('teaser')->nullable()->after('display_title');
|
||||||
|
$table->text('search_terms')->nullable()->after('description');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('license_articles', function (Blueprint $table) {
|
||||||
|
$table->string('working_title')->nullable()->after('code');
|
||||||
|
$table->string('display_title')->nullable()->after('working_title');
|
||||||
|
$table->text('teaser')->nullable()->after('display_title');
|
||||||
|
$table->text('summary')->nullable()->after('teaser');
|
||||||
|
$table->text('description')->nullable()->after('summary');
|
||||||
|
$table->text('search_terms')->nullable()->after('description');
|
||||||
|
$table->foreignId('editorial_content_kind_id')
|
||||||
|
->nullable()
|
||||||
|
->after('search_terms')
|
||||||
|
->constrained('editorial_content_kinds')
|
||||||
|
->nullOnDelete();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('editorial_text_variants', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('subject_type');
|
||||||
|
$table->unsignedBigInteger('subject_id');
|
||||||
|
$table->string('field');
|
||||||
|
$table->string('audience');
|
||||||
|
$table->text('body');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->unique(['subject_type', 'subject_id', 'field', 'audience'], 'editorial_text_variant_unique');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('presentation_roles', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('slug')->unique();
|
||||||
|
$table->string('label');
|
||||||
|
$table->boolean('multiple')->default(false);
|
||||||
|
$table->boolean('ordered')->default(false);
|
||||||
|
$table->unsignedInteger('sort_order')->default(0);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('presentation_assignments', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('subject_type');
|
||||||
|
$table->unsignedBigInteger('subject_id');
|
||||||
|
$table->foreignId('content_element_id')->constrained('content_elements')->cascadeOnDelete();
|
||||||
|
$table->foreignId('presentation_role_id')->constrained('presentation_roles')->cascadeOnDelete();
|
||||||
|
$table->unsignedInteger('position')->default(1);
|
||||||
|
$table->foreignId('source_version_id')->nullable()->constrained('content_element_versions')->nullOnDelete();
|
||||||
|
$table->timestamps();
|
||||||
|
$table->unique(
|
||||||
|
['subject_type', 'subject_id', 'presentation_role_id', 'content_element_id'],
|
||||||
|
'presentation_assignment_unique',
|
||||||
|
);
|
||||||
|
$table->index(['subject_type', 'subject_id'], 'presentation_assignment_subject');
|
||||||
|
});
|
||||||
|
|
||||||
|
$now = now();
|
||||||
|
|
||||||
|
foreach ([
|
||||||
|
['slug' => 'unterrichtsfilm', 'label' => 'Unterrichtsfilm', 'sort_order' => 50],
|
||||||
|
['slug' => 'kurzfilm', 'label' => 'Kurzfilm / Filmbeispiel', 'sort_order' => 60],
|
||||||
|
['slug' => 'trailer', 'label' => 'Trailer / Teaserfilm', 'sort_order' => 70],
|
||||||
|
['slug' => 'interview', 'label' => 'Interview', 'sort_order' => 80],
|
||||||
|
['slug' => 'arbeitsblatt', 'label' => 'Arbeitsblatt', 'sort_order' => 90],
|
||||||
|
['slug' => 'uebungsbeschreibung', 'label' => 'Übungsbeschreibung', 'sort_order' => 100],
|
||||||
|
['slug' => 'titelbild', 'label' => 'Titelbild / Keyvisual', 'sort_order' => 110],
|
||||||
|
['slug' => 'hintergrundbild', 'label' => 'Hintergrundbild', 'sort_order' => 120],
|
||||||
|
['slug' => 'praesentationsbild', 'label' => 'Sonstiges Präsentationsbild', 'sort_order' => 130],
|
||||||
|
['slug' => 'audioanleitung', 'label' => 'Audioanleitung', 'sort_order' => 140],
|
||||||
|
] as $row) {
|
||||||
|
DB::table('editorial_content_kinds')->insert($row + ['created_at' => $now, 'updated_at' => $now]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$dimensions = [
|
||||||
|
'verwendungszweck' => [
|
||||||
|
'label' => 'Redaktioneller Verwendungszweck',
|
||||||
|
'values' => [
|
||||||
|
'training' => 'Training / Lehrinhalt',
|
||||||
|
'begleitmaterial' => 'Trainer- und Begleitmaterial',
|
||||||
|
'website' => 'Website / Marketing',
|
||||||
|
'marke' => 'Markenpräsentation',
|
||||||
|
'intern' => 'Interne redaktionelle Ressource',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'zielgruppe' => [
|
||||||
|
'label' => 'Altersbereich und Zielgruppe',
|
||||||
|
'values' => [
|
||||||
|
'kinder' => 'Kinder',
|
||||||
|
'jugendliche' => 'Jugendliche',
|
||||||
|
'erwachsene' => 'Erwachsene',
|
||||||
|
'eltern' => 'Eltern',
|
||||||
|
'fachkraefte' => 'Fachkräfte',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'einsatzbereich' => [
|
||||||
|
'label' => 'Einsatzbereich',
|
||||||
|
'values' => [
|
||||||
|
'kita' => 'Kita',
|
||||||
|
'schule' => 'Schule',
|
||||||
|
'familie' => 'Familie',
|
||||||
|
'fortbildung' => 'Fortbildung',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($dimensions as $slug => $dimension) {
|
||||||
|
$dimensionId = DB::table('editorial_dimensions')->insertGetId([
|
||||||
|
'slug' => $slug,
|
||||||
|
'label' => $dimension['label'],
|
||||||
|
'created_at' => $now,
|
||||||
|
'updated_at' => $now,
|
||||||
|
]);
|
||||||
|
|
||||||
|
foreach ($dimension['values'] as $valueSlug => $label) {
|
||||||
|
DB::table('editorial_dimension_values')->insert([
|
||||||
|
'editorial_dimension_id' => $dimensionId,
|
||||||
|
'slug' => $valueSlug,
|
||||||
|
'label' => $label,
|
||||||
|
'created_at' => $now,
|
||||||
|
'updated_at' => $now,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ([
|
||||||
|
['slug' => 'titelbild', 'label' => 'Titelbild / Standard-Thumbnail', 'multiple' => false, 'ordered' => false, 'sort_order' => 10],
|
||||||
|
['slug' => 'titelbild_alternativ', 'label' => 'Alternatives Titelbild', 'multiple' => true, 'ordered' => true, 'sort_order' => 20],
|
||||||
|
['slug' => 'hero', 'label' => 'Hero-Bild', 'multiple' => false, 'ordered' => false, 'sort_order' => 30],
|
||||||
|
['slug' => 'hover', 'label' => 'Hoverbild', 'multiple' => false, 'ordered' => false, 'sort_order' => 40],
|
||||||
|
['slug' => 'trailer', 'label' => 'Trailer / Teaserfilm', 'multiple' => true, 'ordered' => true, 'sort_order' => 50],
|
||||||
|
['slug' => 'vorschauclip', 'label' => 'Vorschauclip', 'multiple' => true, 'ordered' => true, 'sort_order' => 60],
|
||||||
|
['slug' => 'audiovorschau', 'label' => 'Audiovorschau', 'multiple' => true, 'ordered' => true, 'sort_order' => 70],
|
||||||
|
['slug' => 'interview', 'label' => 'Interview', 'multiple' => true, 'ordered' => true, 'sort_order' => 80],
|
||||||
|
['slug' => 'galerie', 'label' => 'Galerieelement', 'multiple' => true, 'ordered' => true, 'sort_order' => 90],
|
||||||
|
] as $role) {
|
||||||
|
DB::table('presentation_roles')->insert($role + ['created_at' => $now, 'updated_at' => $now]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('presentation_assignments');
|
||||||
|
Schema::dropIfExists('presentation_roles');
|
||||||
|
Schema::dropIfExists('editorial_text_variants');
|
||||||
|
|
||||||
|
Schema::table('license_articles', function (Blueprint $table) {
|
||||||
|
$table->dropConstrainedForeignId('editorial_content_kind_id');
|
||||||
|
$table->dropColumn(['working_title', 'display_title', 'teaser', 'summary', 'description', 'search_terms']);
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('compositions', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['teaser', 'search_terms']);
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('content_elements', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['teaser', 'search_terms']);
|
||||||
|
});
|
||||||
|
|
||||||
|
$dimensionIds = DB::table('editorial_dimensions')
|
||||||
|
->whereIn('slug', ['verwendungszweck', 'zielgruppe', 'einsatzbereich'])
|
||||||
|
->pluck('id');
|
||||||
|
|
||||||
|
DB::table('identity_dimension_values')->whereIn(
|
||||||
|
'editorial_dimension_value_id',
|
||||||
|
DB::table('editorial_dimension_values')->whereIn('editorial_dimension_id', $dimensionIds)->pluck('id'),
|
||||||
|
)->delete();
|
||||||
|
DB::table('editorial_dimension_values')->whereIn('editorial_dimension_id', $dimensionIds)->delete();
|
||||||
|
DB::table('editorial_dimensions')->whereIn('id', $dimensionIds)->delete();
|
||||||
|
|
||||||
|
DB::table('editorial_content_kinds')->whereIn('slug', [
|
||||||
|
'unterrichtsfilm', 'kurzfilm', 'trailer', 'interview', 'arbeitsblatt', 'uebungsbeschreibung',
|
||||||
|
'titelbild', 'hintergrundbild', 'praesentationsbild', 'audioanleitung',
|
||||||
|
])->delete();
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('content_elements', function (Blueprint $table) {
|
||||||
|
$table->string('preview_path')->nullable()->after('thumbnail_error');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('content_elements', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('preview_path');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redaktionelle Stammdaten zentral pflegen (FACH-56 bis FACH-58). Nur Ergänzungen, nichts wird umbenannt oder gelöscht:
|
||||||
|
*
|
||||||
|
* - Fachliche Materialarten: aktiv/inaktiv und zulässige Objektkontexte (medium, modul, programm, lizenzartikel).
|
||||||
|
* - Werte der Einordnung (Zielgruppe, Einsatzbereich, Verwendungszweck): aktiv/inaktiv und Reihenfolge.
|
||||||
|
*
|
||||||
|
* Die Kontexte werden einmalig aus dem Bestand abgeleitet: Programm und Modul gelten für ihre Objektart, alle übrigen
|
||||||
|
* Materialarten für Medien; Lizenzartikel behalten wie bisher die ganze Auswahl. Danach wird jeder Kontext ergänzt, in
|
||||||
|
* dem eine Materialart tatsächlich verwendet wird, damit keine vorhandene Zuordnung unzulässig wird.
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('editorial_content_kinds', function (Blueprint $table) {
|
||||||
|
$table->boolean('is_active')->default(true)->after('sort_order');
|
||||||
|
$table->json('contexts')->nullable()->after('is_active');
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('editorial_dimension_values', function (Blueprint $table) {
|
||||||
|
$table->unsignedInteger('sort_order')->default(0)->after('label');
|
||||||
|
$table->boolean('is_active')->default(true)->after('sort_order');
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (DB::table('editorial_dimension_values')->orderBy('editorial_dimension_id')->orderBy('id')->get(['id', 'editorial_dimension_id']) as $index => $value) {
|
||||||
|
DB::table('editorial_dimension_values')->where('id', $value->id)->update(['sort_order' => ($index + 1) * 10]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$compositionContexts = ['kurs' => 'programm', 'uebung' => 'modul'];
|
||||||
|
|
||||||
|
foreach (DB::table('editorial_content_kinds')->get(['id', 'slug']) as $kind) {
|
||||||
|
$contexts = match ($kind->slug) {
|
||||||
|
'programm' => ['programm', 'lizenzartikel'],
|
||||||
|
'modul' => ['modul', 'lizenzartikel'],
|
||||||
|
default => ['medium', 'lizenzartikel'],
|
||||||
|
};
|
||||||
|
|
||||||
|
if (DB::table('content_elements')->where('editorial_content_kind_id', $kind->id)->exists()) {
|
||||||
|
$contexts[] = 'medium';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (DB::table('compositions')->where('editorial_content_kind_id', $kind->id)->distinct()->pluck('kind') as $compositionKind) {
|
||||||
|
if (isset($compositionContexts[$compositionKind])) {
|
||||||
|
$contexts[] = $compositionContexts[$compositionKind];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$order = ['medium', 'modul', 'programm', 'lizenzartikel'];
|
||||||
|
$contexts = array_values(array_filter($order, fn (string $context): bool => in_array($context, $contexts, true)));
|
||||||
|
|
||||||
|
DB::table('editorial_content_kinds')->where('id', $kind->id)->update(['contexts' => json_encode($contexts)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('editorial_dimension_values', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['sort_order', 'is_active']);
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('editorial_content_kinds', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['is_active', 'contexts']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -4,6 +4,11 @@ server {
|
|||||||
root /var/www/html/public;
|
root /var/www/html/public;
|
||||||
index index.php;
|
index index.php;
|
||||||
|
|
||||||
|
# Dockers interner DNS: Der Name „app“ wird zur Laufzeit aufgelöst (höchstens 10 s zwischengespeichert), nicht
|
||||||
|
# einmal beim Start von nginx. Sonst zeigt nginx nach jeder Neuerzeugung des App-Containers (neue Adresse) auf die
|
||||||
|
# alte Adresse und antwortet mit 502 – etwa bei einem erneuten Deploy-Lauf nach einer Änderung der Env-Datei.
|
||||||
|
resolver 127.0.0.11 valid=10s ipv6=off;
|
||||||
|
|
||||||
client_max_body_size 2048m;
|
client_max_body_size 2048m;
|
||||||
client_body_timeout 3600s;
|
client_body_timeout 3600s;
|
||||||
send_timeout 3600s;
|
send_timeout 3600s;
|
||||||
@@ -13,7 +18,8 @@ server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
location ~ \.php$ {
|
location ~ \.php$ {
|
||||||
fastcgi_pass app:9000;
|
set $php_upstream app:9000;
|
||||||
|
fastcgi_pass $php_upstream;
|
||||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
set $forwarded_proto $http_x_forwarded_proto;
|
set $forwarded_proto $http_x_forwarded_proto;
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
# Einheitliche Medienverwaltung im CMS – Bericht
|
||||||
|
|
||||||
|
Branch `feature/cms-medienverwaltung`, Commits `7c63424` (Website-Ableitung) und `053a8d4` (Umstellung). Gearbeitet wurde in einem separaten Worktree, der Deploy lief über `develop` (CI 4859, Deploy 4860). Kein Merge nach `main`.
|
||||||
|
|
||||||
|
- Entscheidung: ADR-40.
|
||||||
|
- Technik: `docs/architektur/medienzugriff-fuer-komponenten.md`, Abschnitt „Umsetzung im CMS“, und `cms-widget-registry.md` §§ 7 und 9.
|
||||||
|
|
||||||
|
## 1. Ergebnis
|
||||||
|
|
||||||
|
**Bildstellen:**
|
||||||
|
- Alle Bildstellen des CMS verwenden den zentralen Medienbestand: Einstieg (Hero), Bild und Text, redaktionelle Karten, Premium-Karten (Kartenbild) und Abschnittshintergrund.
|
||||||
|
- Gespeichert wird die Kennung des Mediums, nicht ein Pfad.
|
||||||
|
- Öffentlich erscheint ein Bild nur mit Website-Freigabe (`WebsiteMedia`, Route `website.media`).
|
||||||
|
- Die CMS-eigene Bildauswahl entfällt.
|
||||||
|
|
||||||
|
**Im Widget-Dialog** (Reiter „Medien“, beim Abschnitt „Gestaltung“):
|
||||||
|
|
||||||
|
| Funktion | Verhalten |
|
||||||
|
|---|---|
|
||||||
|
| Auswahl | Alle Bilder des Medienmanagers, durchsuchbar, mit Vorschaubild, Titel und Website-Status (freigegeben, nicht freigegeben, wird verarbeitet) |
|
||||||
|
| Neues Bild hochladen | Das Bild wird sofort im Medienmanager angelegt (`WebsiteIntake`) und ausgewählt. Nach der Verarbeitung gibt die Warteschlange es automatisch für die Website frei. |
|
||||||
|
| Gewähltes Bild | Vorschaubild, Status mit Begründung und „Im Medienmanager öffnen“ (dort steht die Website-Freigabe) |
|
||||||
|
| Austauschen | Ein anderes Bild in der Auswahl wählen; Bildausschnitt und Darstellung bleiben im Widget |
|
||||||
|
| Alternativtext | Kommt aus dem Medium. Das Feld im Widget ist eine optionale Abweichung. |
|
||||||
|
|
||||||
|
**Medienmanager:** Die Medienansicht nennt jetzt die Website-Seiten, die das Bild verwenden. Beim Zurücknehmen der Freigabe weist sie darauf hin, dass das Bild dort verschwindet.
|
||||||
|
|
||||||
|
**Nicht freigegeben:** Öffentlich entfällt nur das Bild; Überschrift, Text und Schaltflächen des Widgets bleiben. Die Redaktionsvorschau zeigt das Vorschaubild mit dem Hinweis, warum es öffentlich nicht erscheint und wo die Freigabe steht.
|
||||||
|
|
||||||
|
**Website-Ableitung:** Bilder werden bis 2400 px breit abgeleitet statt in 640 px Vorschaugröße und nie vergrößert. Transparente Flächen werden weiß. Filmstandbilder bleiben bei 640 px. Diese Änderung betrifft Lars' `ThumbnailDeriver` und liegt deshalb in einem eigenen Commit.
|
||||||
|
|
||||||
|
## 2. Übernahme der Bestandsmedien (Testinstanz)
|
||||||
|
|
||||||
|
Der Job `ImportCmsImages` wurde beim Deploy von einer Migration angestoßen und von der Warteschlange ausgeführt. Ergebnis, lesend geprüft:
|
||||||
|
|
||||||
|
- **21 frühere Bilddateien** unter `cms/`, bytegleich zusammengefasst zu **9 Medien**: Felix und die Einkäufe (Intro), Lara Felix Park (Original), Platzhalter Bild Text, Platzhalter Karte 1, 2 und 3, Platzhalter Markenbühne, Prüfbild, Testplatzhalter Hintergrund.
|
||||||
|
- Alle 9 Medien sind abgeleitet und freigegeben. Es gibt keine offenen und keine fehlgeschlagenen Jobs.
|
||||||
|
- Gelöscht wurde nichts. Die Dateien unter `cms/` und alle Revisionen bleiben unverändert.
|
||||||
|
- Frühere Pfade gelten über `website_media_aliases` als das jeweilige Medium. Beim nächsten Speichern wird die Kennung eingetragen.
|
||||||
|
|
||||||
|
## 3. Prüfung
|
||||||
|
|
||||||
|
| Prüfung | Ergebnis |
|
||||||
|
|---|---|
|
||||||
|
| Testsuite | 245 grün, davon neu: 8 Tests für die Medienanbindung und 2 für die Ableitungsgröße. Bewusst geändert: Die Alt-Text-Pflicht im Widget entfällt, weil der Alternativtext zum Medium gehört. |
|
||||||
|
| Bestehende Seiten vor und nach Deploy und Übernahme | Geometrie unverändert (16 Messungen: 8 Seiten bei 1440 und 390 px), Texte unverändert (12 Seiten). Alle 16 Bilder auf 5 Seiten kommen jetzt über `/website-medien/`, sind geladen und haben dieselben Maße und Alternativtexte (zuvor `/medien/cms/`). Frühere Revisionen werden damit korrekt dargestellt. |
|
||||||
|
| Browser auf der Testinstanz, Redaktionsablauf (13 von 13) | siehe Liste darunter |
|
||||||
|
| Browser auf der Testinstanz, Freigabe zurücknehmen (8 von 8) | siehe Liste darunter |
|
||||||
|
| Slideshow | Im CMS gibt es keine Slideshow. Neue Widget-Arten waren nicht Teil des Auftrags. `WebsiteMedia::presentMany` ist vorbereitet, aber noch unbenutzt. |
|
||||||
|
|
||||||
|
**Redaktionsablauf, Prüfkonto, regulärer Seitenkonfigurator, Entwurfsseite, nichts veröffentlicht:**
|
||||||
|
- Vorhandenes Bild aus dem Medienmanager im Einstieg gewählt; Picker und Statusanzeige mit Vorschaubild und Verweis.
|
||||||
|
- Übernommene Platzhaltergrafik („Platzhalter Markenbühne“) durch „Platzhalter Bild Text“ ersetzt.
|
||||||
|
- Neues Bild direkt im Dialog hochgeladen: Es war sofort ausgewählt, zuerst mit „Wird gerade verarbeitet“, danach freigegeben. Im Medienmanager per Suche auffindbar; dessen Ansicht nennt die verwendende Seite.
|
||||||
|
- Dasselbe Medium in Einstieg und Karte verwendet.
|
||||||
|
- Gespeichert, wieder geöffnet, Vorschau: alle Bilder über `/website-medien/`, geladen, 1200 bis 1600 px breit.
|
||||||
|
|
||||||
|
**Freigabe zurücknehmen, auf `/premium-referenz`, danach wiederhergestellt:**
|
||||||
|
- Die Medienansicht nennt die Seite.
|
||||||
|
- Nach dem Zurücknehmen fehlt das Bild öffentlich; die übrigen 6 Bilder bleiben.
|
||||||
|
- `/website-medien/15` und die frühere Adresse `/medien/cms/…` liefern 404.
|
||||||
|
- Nach der erneuten Freigabe ist der Ausgangszustand wieder da; Geometrie und Bilder entsprechen dem Stand vorher.
|
||||||
|
|
||||||
|
**Auf der Testinstanz neu angelegt:**
|
||||||
|
- das Medium „Platzhalter Upload Medienpruefung“ (gekennzeichneter Platzhalter),
|
||||||
|
- die Entwurfsseite `/medien-pruefung-entwurf`.
|
||||||
|
|
||||||
|
Beides lässt sich über den Medienmanager bzw. die Seitenverwaltung entfernen.
|
||||||
|
|
||||||
|
## 4. Offene Punkte für Lars
|
||||||
|
|
||||||
|
1. **Bild entfällt oder Widget entfällt?** Entschieden am 19.11.2026: Das Medium wird nicht öffentlich ausgeliefert. Texte und übrige Widget-Inhalte bleiben. Ein Widget ohne verbleibenden Inhalt entfällt. Siehe ADR-40.
|
||||||
|
2. **Bildschlüssel:** Gespeichert wird im bisherigen Schlüssel `image` (`refs.image`, `style.image`, `data.items[].image`), nicht in `refs.element`. Grund: Die Medienkarte nutzt `refs.element` für ihr Fachobjekt. Das Dokument ist entsprechend ergänzt.
|
||||||
|
3. **Originalmotiv freigegeben:** „Lara Felix Park Original“ (`cms/lara-felix-park-original-…png`) lag bereits öffentlich unter `cms/` und ist durch die Übernahme ein freigegebenes Medium. Ist die Veröffentlichung nicht geklärt, im Medienmanager zurücknehmen; `/premium-referenz` zeigt es dann nicht mehr.
|
||||||
|
4. **Titel und Quellenzeilen der übernommenen Medien** kommen aus den Dateinamen, ohne Quellenzeile, zum Beispiel „Platzhalter Markenbuehne“ ohne Umlaut. Beides lässt sich im Medienmanager pflegen.
|
||||||
|
5. **Rollback:** Eine Code-Fassung vor der Umstellung zeigt Bilder nicht, die danach gespeichert wurden (Kennung statt Pfad). Texte bleiben, die Dateien unter `cms/` bleiben (Registry §9).
|
||||||
|
6. **Bedienmuster:** Die Bildauswahl des Modul- und Programmeditors ist an dessen Seite gebunden und ließ sich nicht als Formularfeld wiederverwenden. Das Bedienmuster (Suche, Vorschaubild, Auswahl) ist übernommen, die Abfrage greift auf denselben Bestand zu.
|
||||||
@@ -83,3 +83,88 @@ ## 4. Abweichungen vom Kit
|
|||||||
- Schriftgewicht 600 statt 750, weil nur vorhandene Schnitte verwendet werden.
|
- Schriftgewicht 600 statt 750, weil nur vorhandene Schnitte verwendet werden.
|
||||||
- Bildhöhe höchstens min(70vh, 640 px).
|
- Bildhöhe höchstens min(70vh, 640 px).
|
||||||
- Karten, die nur in der Vorschau erscheinen, mit gestricheltem Rand.
|
- Karten, die nur in der Vorschau erscheinen, mit gestricheltem Rand.
|
||||||
|
|
||||||
|
## 5. Fachliche Nachbesserung nach der Betreiberprüfung (18.11.2026)
|
||||||
|
|
||||||
|
Branch `feature/premium-karten-nachbesserung`, separater Worktree, Deploy nur über `develop`. Keine neue Widget-Art, keine neuen Fachobjekte, keine Migration, keine Änderung an Lizenz- oder Kaufrechten.
|
||||||
|
|
||||||
|
**Ursache „keine Themen“.** Die Themenkarte bot nur veröffentlichte Säulen an. Auf der Testinstanz gibt es fünf Säulen (lesende Abfrage am 18.11.2026), keine ist veröffentlicht, keine hat eine öffentliche Adresse oder einen Text für die Website. Jetzt sind alle Säulen wählbar; öffentlich gilt unverändert die Regel der Themenseiten (veröffentlicht und mit Adresse).
|
||||||
|
|
||||||
|
**Datenstand der Testinstanz (lesend geprüft):**
|
||||||
|
- 5 Säulen, unveröffentlicht, ohne Website-Text; Säule 1 hat ein zugeordnetes Medium, Säule 2 eine veröffentlichte Seite.
|
||||||
|
- Film „Lara im Park“: bereitgestellte Fassung, Filmstandbild (aus dem Film bei 41,5 s), Beschreibung vorhanden, **keine Kurzbeschreibung und kein Anzeigetitel**; Bestandteil von „Programm Abstand“ (über Modul Abstand) und der UX-Prüfung, beide öffentlich.
|
||||||
|
- Zwei weitere Filme nur als Entwurf; Textmaterialien ohne Inhaltsart; eine gesperrte Traineranleitung.
|
||||||
|
- Module mit Lernziel, Dauer und Materialhinweis; zwei Module mit Vorschaubild; keine Kurzbeschreibungen außer einem Entwurfsmodul.
|
||||||
|
- Keine Laufzeiten in den Mediendaten (Metadaten nur `file`, `held`).
|
||||||
|
|
||||||
|
### Themenkarte
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| Verfügbare Fachdaten | Name, öffentliche Adresse, Text für die Website, Veröffentlichung, zugeordnete Seiten und Medien |
|
||||||
|
| Dargestellt | Name, Text für die Website, „N Seiten zum Thema“ (veröffentlichte Seiten), Aktion auf `/themen/{slug}` |
|
||||||
|
| Redaktion | alle Säulen wählbar, mit Status „veröffentlicht“ / „nicht veröffentlicht, nur Redaktionsvorschau“; Vorschau mit Hinweisen auf fehlenden Text und fehlendes Kartenbild |
|
||||||
|
| Fehlt | auf der Testinstanz: Veröffentlichung, Adresse und Text aller Säulen (Pflege unter „Fachliche Säulen“) |
|
||||||
|
| Bewusst | kein Themenbild aus Medien des Themas (geschützt); Bild nur als Kartenbild aus dem öffentlichen Website-Bereich |
|
||||||
|
|
||||||
|
### Medien- und Materialkarte
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| Verfügbare Fachdaten | Arbeits- und Anzeigetitel, Kurzbeschreibung, Beschreibung, Einsatzhinweis, Lizenzvermerk, Inhaltsart, Ausgabeart, Fassungsstatus, Vorschaubild (Filmstandbild, geschützt), Programmzugehörigkeit |
|
||||||
|
| Dargestellt | **Film:** Titel, Kurzbeschreibung, Inhalts- und Ausgabeart, „Im Programm …“, „Vollständiger Film nur mit Lizenz im Mitgliederbereich“, Filmtafel; Aktion auf die öffentliche Programmseite. **Material:** eigene Darstellung mit Materialsymbol, Titel, Kurzbeschreibung, Art. **Vorschau:** Filmstandbild der Bibliothek mit Marke „Bibliotheksbild · nur Vorschau“ |
|
||||||
|
| Unterschieden | öffentliche Filmvorschau: **gibt es fachlich noch nicht** (keine eigene Ausgabe, keine Freigabe); geschützter vollständiger Film: nie über die Karte, nur Hinweis; Film ohne freigegebenes Vorschaumaterial: öffentlich Filmtafel oder redaktionelles Kartenbild |
|
||||||
|
| Redaktion | Filme und Materialien mit Entwurfs- oder bereitgestellter Fassung wählbar (gesperrte nicht), Sichtbarkeit in der Auswahl; Hinweise auf fehlende Kurzbeschreibung, Anzeigetitel, freigegebenes Bild |
|
||||||
|
| Fehlt | Kurzbeschreibungen und Anzeigetitel in den Medien; Laufzeit in den Mediendaten; Freigabe von Vorschaubildern für die Website; öffentliche Filmvorschau (Erweiterungsbedarf: `cms-widget-registry.md` §13) |
|
||||||
|
| Bewusst | Traineranleitungen nie öffentlich; nie öffentlich: Beschreibung, Einsatzhinweis, Lizenzvermerk, Dateien; kein Abspielen, kein Download |
|
||||||
|
|
||||||
|
### Programm- und Modulkarte
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| Verfügbare Fachdaten | Bezeichnung, Anzeigetitel, Kurzbeschreibung, Inhaltsart, Fassungen mit Lernziel, Dauer, Materialhinweis, Anzeigefreigabe, Vorschaubild (geschützt), Bestandteile |
|
||||||
|
| Dargestellt | Titel, Kurzbeschreibung (sonst Lernziel; auf der Programmseite bereits öffentlich), Art „Programm“/„Modul“, Zahl der Module, Dauer, Navy-Tafel; Aktion nur für Programme mit Anzeigefreigabe; Vorschau: Vorschaubild der Bibliothek, markiert |
|
||||||
|
| Redaktion | Programme und Module mit bereitgestellter Fassung wählbar, auch ohne Anzeigefreigabe (nur Vorschau); Hinweise auf fehlende Kurzbeschreibung und Dauer |
|
||||||
|
| Fehlt | Kurzbeschreibungen; öffentliche Modulseite (ADR-29, nicht Teil dieses Auftrags); Freigabe von Vorschaubildern |
|
||||||
|
| Bewusst | kein künstlicher Link für Module; kein Materialhinweis öffentlich; kein Preis, keine Kaufaktion |
|
||||||
|
|
||||||
|
### Prüfungen der Nachbesserung
|
||||||
|
|
||||||
|
| Prüfung | Ergebnis |
|
||||||
|
|---|---|
|
||||||
|
| Testsuite | 214 grün (Kartentests 10, davon neu: Entwurf/ohne Freigabe nur in der Vorschau, unveröffentlichte Themen; erweitert: Film/Material, Traineranleitung, keine internen Felder, Bibliotheksbild nur in der Vorschau) |
|
||||||
|
| Lokaler Redaktionsablauf mit nachgebildetem Datenstand der Testinstanz | 32 von 32: vorhandene Säule, Film, Material, Modul, Programm in 1 + 1 + 2, 2 + 2, 4/4, 1 + 1 + 1 + 1; speichern, wieder öffnen, bearbeiten, speichern; Vorschau bei 1440/1024/768/390 px (alle Karten mindestens 240 px, kein Überlauf, gleiche Höhe je Zeile); Entwurfsseite öffentlich nicht erreichbar. **Gilt nicht als Abnahme auf der Testinstanz.** |
|
||||||
|
| Redaktionsablauf auf der Testinstanz (Prüfkonto, regulärer Seitenkonfigurator) | **32 von 32.** Die Auswahl bietet alle fünf Säulen und alle Filme und Materialien mit Sichtbarkeit an. Gewählt wurden „Meine Grenzen“, „Lara im Park“, ein Textmaterial, die Module „Freigabe mit Anleitung“ und „Modul Abstand“ sowie „Programm Abstand“, verteilt auf 1 + 1 + 2, 2 + 2, 4/4 und 1 + 1 + 1 + 1. Danach: Entwurf angelegt, wieder geöffnet, bearbeitet, gespeichert. Vorschau bei 1440/1024/768/390 px: alle 10 Karten, mindestens 240 px breit, kein Überlauf, gleiche Höhe je Zeile. Das Filmstandbild erscheint nur in der Vorschau, markiert. Die Entwurfsseite `/karten-nachbesserung-entwurf` (Seite 19) ist öffentlich nicht erreichbar (404). Es wurde nichts veröffentlicht. |
|
||||||
|
|
||||||
|
### Was die Karten mit den heutigen Daten der Testinstanz zeigen
|
||||||
|
|
||||||
|
- **Programmkarte „Programm Abstand“** (öffentlich): Titel, Lernziel als Text, „2 Module“, „Dauer 25 Min.“, Navy-Tafel, Aktion auf die Programmseite. Die vollständigste Karte.
|
||||||
|
- **Filmkarte „Lara im Park“** (öffentlich über „Programm Abstand“): Titel, Filmtafel, „Film“, „Im Programm …“, Hinweis auf den geschützten Film, Aktion auf die Programmseite. **Kein Text, weil das Medium keine Kurzbeschreibung hat**; in der Vorschau zusätzlich das Filmstandbild, als nicht öffentlich markiert.
|
||||||
|
- **Materialkarte „Trainerunterlage Abstand“** (öffentlich über „Programm Abstand“): Titel, Materialsymbol, „Text“, Programmbezug.
|
||||||
|
- **Modulkarten**: nur in der Vorschau, mit Lernziel und Dauer; „Mod - eigene Grenzen erkennen“ mit Vorschaubild der Bibliothek (markiert).
|
||||||
|
- **Themenkarten**: nur in der Vorschau, weil keine Säule veröffentlicht ist und keine einen Website-Text hat.
|
||||||
|
|
||||||
|
Die verbleibenden Lücken sind **fehlende Fachdaten, nicht fehlender Code**:
|
||||||
|
|
||||||
|
| Fehlt | Gepflegt unter |
|
||||||
|
|---|---|
|
||||||
|
| Kurzbeschreibung und Anzeigetitel der Medien | Medium bearbeiten → Anzeigetitel, Kurzbeschreibung |
|
||||||
|
| Veröffentlichung, Adresse und Text der Themen | Fachliche Säulen → Öffentliche Adresse, Text für die Website, „Auf der Website veröffentlichen“ |
|
||||||
|
| Kurzbeschreibung der Programme und Module | Programm/Modul → Kurzbeschreibung |
|
||||||
|
| öffentliches Bild | Kartenbild im Reiter „Medien“ (freigegebenes Motiv), später Freigabe von Vorschaubildern (§13 der Registry) |
|
||||||
|
|
||||||
|
### Neu öffentlich und bewusst entschieden
|
||||||
|
|
||||||
|
- **Kurzbeschreibung von Medien** (Betreibervorgabe) und **Dauer von Programmen** („Dauer N Min.“): beide stehen bisher auf keiner öffentlichen Seite. Die Programmseite zeigt das Lernziel, nicht die Dauer.
|
||||||
|
- **Vertraulichkeit hängt an der Inhaltsart.** Nie öffentlich sind Elemente mit der Inhaltsart „Traineranleitung“. „Trainerunterlage Abstand“ hat auf der Testinstanz keine Inhaltsart und gehört zu einem öffentlichen Programm. Die Karte ist deshalb öffentlich zulässig. Heute zeigt sie nur den Titel, der auf der Programmseite ohnehin steht. Eine später gepflegte Kurzbeschreibung würde öffentlich. **Vor dem Pflegen von Kurzbeschreibungen den Trainermaterialien die Inhaltsart „Traineranleitung“ zuordnen.**
|
||||||
|
|
||||||
|
### Offene Fragen an Lars
|
||||||
|
|
||||||
|
1. Soll die vorhandene „Beschreibung“ eines Mediums (zum Beispiel 215 Zeichen bei „Lara im Park“) öffentlich als Ersatz dienen, wenn keine Kurzbeschreibung gepflegt ist? Derzeit nein: Die Beschreibung ist Bibliothekstext.
|
||||||
|
2. Freigabe von Vorschaubildern für die Website und öffentliche Filmvorschauen: minimaler Erweiterungsbedarf in `cms-widget-registry.md` §13.
|
||||||
|
3. Öffentliche Sichtbarkeit auf der Testinstanz ist nicht live gezeigt, weil keine Hilfsseite veröffentlicht werden darf. Die Regeln belegen die Feature-Tests. Alternative: eine echte Seite mit Karten veröffentlichen.
|
||||||
|
4. Die Entwurfsseite `/karten-nachbesserung-entwurf` (Seite 19) bleibt zur Ansicht in der Redaktionsvorschau stehen; danach über die Seitenverwaltung löschen.
|
||||||
|
|
||||||
|
### Prüfskript für die Testinstanz
|
||||||
|
|
||||||
|
Das Prüfskript ist `e2e_karten2.py` (im Arbeitsordner der Sitzung, nicht im Repository). Es veröffentlicht nichts und legt die Entwurfsseite `/karten-nachbesserung-entwurf` an. Diese Seite nach der Prüfung über die Seitenverwaltung löschen.
|
||||||
Loaded 100 of 405 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user