Merge pull request 'MVP 1.2 (inkl. Shop)' (#3) from develop into main
Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
commit
4248ecffb8
391 files changed
+17338
-390
No files matched your search
@@ -63,6 +63,6 @@ ## Entwicklung
|
||||
## 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`).
|
||||
- Gemeinsame Bausteine wiederverwenden statt neue Masken bauen: `resources/views/filament/verwaltung/` (`kopf`, `redaktion`, `texte`, `praesentation`, `einordnung`, `picker`, `bestaetigung`, `abgang`, `aufbau`, `bestand`) mit dem Trait `App\Filament\Support\ManagesEditorialSurface`. Listen nutzen `verwaltung/bestand` mit `ShowsBestand` (bzw. `ListsCompositions`, `ListsCatalog`) und den Eintrag `<x-vw.eintrag>`, den auch der Picker verwendet; Katalogobjekte die Seite `catalog/objekt`. CMS: Seitenkopf `cms/seite-kopf` (Register, Kontexte „Abschnitt gestalten“ und „Konfigurieren“); Seiten und Menüs in der Webpräsenz (`App\Filament\Pages\Webpraesenz`, Menüs als Arbeitsstand mit einer Speicherhandlung). Der Picker liegt im Trait `ChoosesMedia` (Redaktion über `ManagesEditorialSurface`, CMS-Bilder über `ChoosesWebsiteImages`); keine eigenen Auswahllisten für Medien bauen. Redaktionelle Auswahlwerte (Materialart, Einordnung) nur über `App\Domain\Catalog\EditorialVocabulary` anbieten und prüfen (aktiv, zulässiger Kontext, vorhandene Zuordnungen erhalten); gepflegt werden sie unter „Redaktionelle Stammdaten“. Fachliche Säulen gibt es nur in der Säulenverwaltung (`pillars`); Zuordnung über `PillarService::assign`, nie über eine Dimension. Ersetzt eine Seite die Filament-Tabelle, muss sie den Dialogbereich ausgeben (in `bestand` enthalten), sonst öffnen „… anlegen“-Dialoge nicht. Gestaltungswerte nur in `verwaltung/styles.blade.php` (Tokens `--vw-…`, dokumentiert in `docs/ux/verwaltung/tokens.md`).
|
||||
- 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`.
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Domain\Catalog\LegacyPillarAdoption;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class AdoptLegacyPillars extends Command
|
||||
{
|
||||
protected $signature = 'luf:saeulen-uebernehmen {--dry-run : Nur berichten, nichts schreiben}';
|
||||
|
||||
protected $description = 'Übernimmt die alte Dimension „Fachliche Säule“ in die zentrale Säulenverwaltung und berichtet ungeklärte Fälle';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$dryRun = (bool) $this->option('dry-run');
|
||||
$report = (new LegacyPillarAdoption)->run($dryRun);
|
||||
|
||||
foreach (LegacyPillarAdoption::lines($report, $dryRun) as $line) {
|
||||
$this->line($line);
|
||||
}
|
||||
|
||||
return $report['unresolved'] === [] ? self::SUCCESS : self::FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Composition extends Model
|
||||
@@ -44,4 +45,13 @@ public function versions(): HasMany
|
||||
{
|
||||
return $this->hasMany(CompositionVersion::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Direkt zugeordnete fachliche Säulen (zentrale Säulenverwaltung). Die Säulen der enthaltenen Medien sind davon
|
||||
* getrennt und werden zur Laufzeit abgeleitet (CatalogReading::memberPillars).
|
||||
*/
|
||||
public function pillars(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Pillar::class)->orderBy('pillars.sort_order')->orderBy('pillars.name');
|
||||
}
|
||||
}
|
||||
@@ -20,20 +20,15 @@ public function values(): HasMany
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Fachliche Säulen werden für alle Objektarten über die zentrale Säulenverwaltung gewählt (`pillars`), nie über
|
||||
* eine Dimension. Die alte Dimension „Fachliche Säule“ bleibt nur als Verlauf in der Datenbank und wird nirgends
|
||||
* mehr angeboten, geändert oder gefiltert.
|
||||
*
|
||||
* @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 static::query()->with('values')->where('slug', '!=', self::PILLAR_SLUG)->orderBy('label')->get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
class EditorialDimensionValue extends Model
|
||||
{
|
||||
protected $fillable = ['editorial_dimension_id', 'slug', 'label', 'sort_order', 'is_active'];
|
||||
protected $fillable = ['editorial_dimension_id', 'pillar_id', 'slug', 'label', 'sort_order', 'is_active'];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
|
||||
@@ -181,13 +181,13 @@ public function dimensionGroups(Model $subject, array $assignedIds): array
|
||||
* @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
|
||||
public function dimensionFilterGroups(array $selectedIds = []): 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) {
|
||||
if ($dimension->slug === EditorialDimension::PILLAR_SLUG) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -217,7 +217,7 @@ public function dimensionFilterGroups(array $selectedIds = [], bool $withPillars
|
||||
*/
|
||||
public function memberFilterDimensions(array $selectedIds = []): Collection
|
||||
{
|
||||
$dimensions = EditorialDimension::query()->with('values')->orderBy('label')->get();
|
||||
$dimensions = EditorialDimension::query()->with('values')->where('slug', '!=', EditorialDimension::PILLAR_SLUG)->orderBy('label')->get();
|
||||
|
||||
foreach ($dimensions as $dimension) {
|
||||
$dimension->setRelation('values', $dimension->values
|
||||
|
||||
@@ -0,0 +1,270 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Übernimmt die frühere Kopie „Fachliche Säule“ (Dimension `saeule`) in die zentrale Säulenverwaltung (Tabelle
|
||||
* `pillars`). Verlustfrei, wiederholbar und ohne Raten:
|
||||
*
|
||||
* - **Zuordnung Wert → Säule** nur über die gespeicherte Kennung `pfeiler-{Säulenkennung}`, die die Migration
|
||||
* vom 16.11.2026 beim Spiegeln geschrieben hat, und nur, wenn die Säule existiert und nicht jünger als der Wert ist
|
||||
* (sonst kann die Kennung nicht aus ihr entstanden sein). Eine abweichende Bezeichnung ist nach einem Umbenennen
|
||||
* erwartet und wird nur berichtet. Die Verknüpfung steht in `editorial_dimension_values.pillar_id`.
|
||||
* - **Übernommen** werden nur direkte Zuordnungen von Modulen, Programmen und Lizenzartikeln in `composition_pillar`
|
||||
* und `license_article_pillar` (insert-or-ignore, daher beliebig oft ausführbar).
|
||||
* - **Nicht übernommen, sondern gemeldet:** Werte ohne belastbare Kennung, Zuordnungen zu fehlenden Objekten,
|
||||
* abgeleitete Zuordnungen und unbekannte Objektarten. Abgeleitete Säulen eines Programms oder Moduls entstehen zur
|
||||
* Laufzeit aus den enthaltenen Medien und werden nie als direkte Zuordnung gespeichert.
|
||||
* - **Medien:** Die gespiegelten Zeilen sind eine veraltete Kopie; maßgeblich ist `content_element_pillar`. Sie werden
|
||||
* nicht zurückgemischt, nur gezählt.
|
||||
* - Alte Zeilen werden weder geändert noch gelöscht.
|
||||
*
|
||||
* Nur die Datenbankfassade, damit spätere Änderungen an Modellen die Migration nicht berühren.
|
||||
*/
|
||||
final class LegacyPillarAdoption
|
||||
{
|
||||
/** @var array<string, array{table: string, column: string, subjects: string}> */
|
||||
private const TARGETS = [
|
||||
'composition' => ['table' => 'composition_pillar', 'column' => 'composition_id', 'subjects' => 'compositions'],
|
||||
'license_article' => ['table' => 'license_article_pillar', 'column' => 'license_article_id', 'subjects' => 'license_articles'],
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* mapping: list<array<string, mixed>>,
|
||||
* unresolved: list<array<string, mixed>>,
|
||||
* copied: array<string, int>,
|
||||
* already: array<string, int>,
|
||||
* before: array<string, int>,
|
||||
* after: array<string, int>,
|
||||
* mirror: array<string, int>
|
||||
* }
|
||||
*/
|
||||
public function run(bool $dryRun = false): array
|
||||
{
|
||||
$report = [
|
||||
'mapping' => [],
|
||||
'unresolved' => [],
|
||||
'copied' => ['composition' => 0, 'license_article' => 0],
|
||||
'already' => ['composition' => 0, 'license_article' => 0],
|
||||
'before' => $this->counts(),
|
||||
'after' => [],
|
||||
'mirror' => ['element_rows' => 0, 'missing_in_pivot' => 0, 'only_in_pivot' => 0],
|
||||
];
|
||||
|
||||
$dimension = DB::table('editorial_dimensions')->where('slug', 'saeule')->first();
|
||||
|
||||
if ($dimension === null) {
|
||||
$report['after'] = $report['before'];
|
||||
|
||||
return $report;
|
||||
}
|
||||
|
||||
$resolved = [];
|
||||
|
||||
foreach (DB::table('editorial_dimension_values')->where('editorial_dimension_id', $dimension->id)->orderBy('id')->get() as $value) {
|
||||
$pillar = $this->pillarFor($value);
|
||||
|
||||
if (is_string($pillar)) {
|
||||
$report['unresolved'][] = ['art' => 'Wert', 'wert_id' => (int) $value->id, 'wert' => $value->label, 'kennung' => $value->slug, 'grund' => $pillar];
|
||||
$report['mapping'][] = ['wert_id' => (int) $value->id, 'wert' => $value->label, 'saeule_id' => null, 'status' => 'offen'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$resolved[(int) $value->id] = (int) $pillar->id;
|
||||
$status = $value->pillar_id === null ? 'zugeordnet' : 'bereits zugeordnet';
|
||||
$hint = $value->label !== $pillar->name ? 'über Kennung zugeordnet, Bezeichnung weicht ab („'.$pillar->name.'“)' : null;
|
||||
$report['mapping'][] = ['wert_id' => (int) $value->id, 'wert' => $value->label, 'saeule_id' => (int) $pillar->id, 'saeule' => $pillar->name, 'status' => $status, 'hinweis' => $hint];
|
||||
|
||||
if ($value->pillar_id === null && ! $dryRun) {
|
||||
DB::table('editorial_dimension_values')->where('id', $value->id)->update(['pillar_id' => $pillar->id]);
|
||||
}
|
||||
}
|
||||
|
||||
$subjectTypes = $this->subjectTypes();
|
||||
|
||||
foreach (DB::table('identity_dimension_values')
|
||||
->whereIn('editorial_dimension_value_id', DB::table('editorial_dimension_values')->where('editorial_dimension_id', $dimension->id)->select('id'))
|
||||
->orderBy('id')->get() as $row) {
|
||||
$valueId = (int) $row->editorial_dimension_value_id;
|
||||
$label = DB::table('editorial_dimension_values')->where('id', $valueId)->value('label');
|
||||
$target = $subjectTypes[$row->subject_type] ?? null;
|
||||
|
||||
if ($target === 'content_element') {
|
||||
$report['mirror']['element_rows']++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$where = ['art' => 'Zuordnung', 'zuordnung_id' => (int) $row->id, 'wert_id' => $valueId, 'wert' => $label, 'objektart' => $row->subject_type, 'objekt_id' => (int) $row->subject_id, 'herkunft' => $row->origin];
|
||||
|
||||
if ($target === null) {
|
||||
$report['unresolved'][] = $where + ['grund' => 'unbekannte Objektart'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($row->origin !== 'direkt') {
|
||||
$report['unresolved'][] = $where + ['grund' => 'abgeleitete Zuordnung (wird nicht als direkte übernommen)'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! isset($resolved[$valueId])) {
|
||||
$report['unresolved'][] = $where + ['grund' => 'Wert ohne belastbare Säule'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$config = self::TARGETS[$target];
|
||||
|
||||
if (! DB::table($config['subjects'])->where('id', $row->subject_id)->exists()) {
|
||||
$report['unresolved'][] = $where + ['grund' => 'Objekt nicht mehr vorhanden'];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$present = DB::table($config['table'])->where($config['column'], $row->subject_id)->where('pillar_id', $resolved[$valueId])->exists();
|
||||
|
||||
if ($present) {
|
||||
$report['already'][$target]++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! $dryRun) {
|
||||
DB::table($config['table'])->insertOrIgnore([$config['column'] => $row->subject_id, 'pillar_id' => $resolved[$valueId]]);
|
||||
}
|
||||
|
||||
$report['copied'][$target]++;
|
||||
}
|
||||
|
||||
$report['mirror'] = array_merge($report['mirror'], $this->mirrorDivergence($dimension->id, $resolved));
|
||||
$report['after'] = $dryRun ? $report['before'] : $this->counts();
|
||||
|
||||
return $report;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $report
|
||||
* @return list<string>
|
||||
*/
|
||||
public static function lines(array $report, bool $dryRun = false): array
|
||||
{
|
||||
$names = ['composition' => 'Module und Programme', 'license_article' => 'Lizenzartikel'];
|
||||
$lines = [$dryRun ? 'Probelauf, es wird nichts geschrieben.' : 'Übernahme abgeschlossen.', ''];
|
||||
|
||||
foreach ($report['mapping'] as $row) {
|
||||
$lines[] = sprintf('Wert %d „%s“ → %s%s', $row['wert_id'], $row['wert'], $row['saeule_id'] === null ? 'keine Säule (offen)' : 'Säule '.$row['saeule_id'].' „'.($row['saeule'] ?? '').'“ ('.$row['status'].')', ! empty($row['hinweis']) ? ' – '.$row['hinweis'] : '');
|
||||
}
|
||||
|
||||
$lines[] = '';
|
||||
|
||||
foreach ($names as $key => $label) {
|
||||
$lines[] = sprintf('%s: %d übernommen, %d bereits vorhanden, Zuordnungen vorher %d, nachher %d', $label, $report['copied'][$key], $report['already'][$key], $report['before'][$key], $report['after'][$key]);
|
||||
}
|
||||
|
||||
$lines[] = sprintf('Medien (nur Information): %d gespiegelte Zeilen, %d nicht mehr in der Medienzuordnung, %d nur dort. Maßgeblich bleibt die Medienzuordnung.', $report['mirror']['element_rows'], $report['mirror']['missing_in_pivot'], $report['mirror']['only_in_pivot']);
|
||||
|
||||
if ($report['unresolved'] === []) {
|
||||
$lines[] = 'Keine ungeklärten Fälle.';
|
||||
} else {
|
||||
$lines[] = '';
|
||||
$lines[] = 'Ungeklärt, bitte entscheiden (nichts wurde geändert):';
|
||||
|
||||
foreach ($report['unresolved'] as $row) {
|
||||
$lines[] = '- '.json_encode($row, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
return $lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Säule zu einem alten Wert, oder der Grund, warum es keine belastbare gibt.
|
||||
*/
|
||||
private function pillarFor(object $value): object|string
|
||||
{
|
||||
if (preg_match('/^pfeiler-(\d+)$/', (string) $value->slug, $match) !== 1) {
|
||||
return 'Kennung ist nicht „pfeiler-<Nummer>“, keine belastbare Verknüpfung';
|
||||
}
|
||||
|
||||
$pillar = DB::table('pillars')->where('id', (int) $match[1])->first();
|
||||
|
||||
if ($pillar === null) {
|
||||
return 'Die Säule zur Kennung existiert nicht mehr';
|
||||
}
|
||||
|
||||
if ($value->pillar_id !== null && (int) $value->pillar_id !== (int) $pillar->id) {
|
||||
return 'Gespeicherte Verknüpfung (Säule '.$value->pillar_id.') und Kennung (Säule '.$pillar->id.') widersprechen sich';
|
||||
}
|
||||
|
||||
if ($pillar->created_at !== null && $value->created_at !== null && $pillar->created_at > $value->created_at) {
|
||||
return 'Die Säule ist jünger als der Wert; die Kennung kann nicht aus ihr entstanden sein';
|
||||
}
|
||||
|
||||
return $pillar;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string> Objektart wie gespeichert => Ziel
|
||||
*/
|
||||
private function subjectTypes(): array
|
||||
{
|
||||
$types = [];
|
||||
|
||||
foreach ([
|
||||
'composition' => [Composition::class],
|
||||
'license_article' => [LicenseArticle::class],
|
||||
'content_element' => [ContentElement::class],
|
||||
] as $target => $classes) {
|
||||
foreach ($classes as $class) {
|
||||
$types[$class] = $target;
|
||||
$types[(new $class)->getMorphClass()] = $target;
|
||||
}
|
||||
}
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, int>
|
||||
*/
|
||||
private function counts(): array
|
||||
{
|
||||
return [
|
||||
'composition' => DB::table('composition_pillar')->count(),
|
||||
'license_article' => DB::table('license_article_pillar')->count(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, int> $resolved
|
||||
* @return array{missing_in_pivot: int, only_in_pivot: int}
|
||||
*/
|
||||
private function mirrorDivergence(int $dimensionId, array $resolved): array
|
||||
{
|
||||
$mirrored = [];
|
||||
|
||||
foreach (DB::table('identity_dimension_values')
|
||||
->whereIn('subject_type', array_unique([ContentElement::class, (new ContentElement)->getMorphClass()]))
|
||||
->whereIn('editorial_dimension_value_id', array_keys($resolved) ?: [0])
|
||||
->get() as $row) {
|
||||
$mirrored[$row->subject_id.':'.$resolved[(int) $row->editorial_dimension_value_id]] = true;
|
||||
}
|
||||
|
||||
$pivot = [];
|
||||
|
||||
foreach (DB::table('content_element_pillar')->get() as $row) {
|
||||
$pivot[$row->content_element_id.':'.$row->pillar_id] = true;
|
||||
}
|
||||
|
||||
return [
|
||||
'missing_in_pivot' => count(array_diff_key($mirrored, $pivot)),
|
||||
'only_in_pivot' => count(array_diff_key($pivot, $mirrored)),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class LicenseArticle extends Model
|
||||
@@ -49,4 +50,10 @@ public function editorialContentKind(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(EditorialContentKind::class);
|
||||
}
|
||||
|
||||
/** Direkt zugeordnete fachliche Säulen (zentrale Säulenverwaltung). */
|
||||
public function pillars(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Pillar::class)->orderBy('pillars.sort_order')->orderBy('pillars.name');
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,29 @@
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Offer extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'composition_id',
|
||||
'option_label',
|
||||
];
|
||||
|
||||
/** Komposition, deren öffentliche Seite die Produktseite dieser Lizenzoption ist. */
|
||||
public function composition(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Composition::class);
|
||||
}
|
||||
|
||||
/** Bezeichnung der Option auf der Produktseite. */
|
||||
public function optionName(): string
|
||||
{
|
||||
return filled($this->option_label) ? (string) $this->option_label : (string) $this->name;
|
||||
}
|
||||
|
||||
public function versions(): HasMany
|
||||
{
|
||||
return $this->hasMany(OfferVersion::class);
|
||||
|
||||
@@ -22,6 +22,23 @@ public function currentActiveVersion(Offer $offer): OfferVersion
|
||||
return $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Die aktive, als Kauf angebotene Fassung mit Preis; sonst null (nicht kaufbar, zurückgezogen oder kostenlos).
|
||||
*/
|
||||
public function purchasableVersion(Offer $offer): ?OfferVersion
|
||||
{
|
||||
$version = $offer->versions()
|
||||
->where('status', OfferStatus::Aktiv)
|
||||
->orderByDesc('number')
|
||||
->first();
|
||||
|
||||
if ($version === null || $version->grant_kind !== 'kauf' || $version->price_cents === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $capabilities
|
||||
* @param array<string, mixed> $options
|
||||
@@ -138,6 +155,40 @@ public function activate(Offer $offer, array $lines, array $attributes = []): Of
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Zieht die Option aus dem Verkauf zurück: Die aktive Fassung wird beendet und bleibt gespeichert. Bereits
|
||||
* begründete Berechtigungen und Bestellungen ändern sich nicht; offene Warenkörbe zeigen die Position als
|
||||
* zurückgezogen und blockieren den Abschluss, bis der Käufer sie entfernt.
|
||||
*/
|
||||
public function end(Offer $offer): OfferVersion
|
||||
{
|
||||
return DB::transaction(function () use ($offer): OfferVersion {
|
||||
$offer = Offer::query()->lockForUpdate()->findOrFail($offer->id);
|
||||
$version = $this->currentActiveVersion($offer);
|
||||
$version->status = OfferStatus::Beendet;
|
||||
$version->save();
|
||||
|
||||
return $version;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Produktzuordnung der Option: Die Komposition bestimmt die öffentliche Produktseite und die Alternativgruppe,
|
||||
* die Bezeichnung benennt die Option auf dieser Seite. Beides sind keine bindenden Konditionen.
|
||||
*/
|
||||
public function assignProduct(Offer $offer, ?int $compositionId, ?string $optionLabel): Offer
|
||||
{
|
||||
if ($compositionId !== null) {
|
||||
Composition::query()->findOrFail($compositionId);
|
||||
}
|
||||
|
||||
$offer->composition_id = $compositionId;
|
||||
$offer->option_label = filled($optionLabel) ? trim((string) $optionLabel) : null;
|
||||
$offer->save();
|
||||
|
||||
return $offer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
|
||||
@@ -34,6 +34,16 @@ public function pages(): BelongsToMany
|
||||
return $this->belongsToMany(Page::class);
|
||||
}
|
||||
|
||||
public function compositions(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Composition::class);
|
||||
}
|
||||
|
||||
public function licenseArticles(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(LicenseArticle::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder<Pillar> $query
|
||||
* @return Builder<Pillar>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Catalog;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Alte Filteradressen: Vor der Vereinheitlichung war „Fachliche Säule“ ein Wert der redaktionellen Einordnung
|
||||
* (`?einordnung=…`, `?pillar=…`, `dimension[]=…`). Verweist ein solcher Wert über `pillar_id` auf eine zentrale Säule,
|
||||
* gilt der Filter jetzt für diese Säule, statt stillschweigend zu entfallen.
|
||||
*/
|
||||
final class PillarFilterCompat
|
||||
{
|
||||
/**
|
||||
* @return int|null|false Kennung der Säule; null: alter Säulenwert ohne belastbare Verknüpfung; false: kein Säulenwert
|
||||
*/
|
||||
public static function pillarOfLegacyValue(int $valueId): int|false|null
|
||||
{
|
||||
$row = DB::table('editorial_dimension_values')
|
||||
->join('editorial_dimensions', 'editorial_dimensions.id', '=', 'editorial_dimension_values.editorial_dimension_id')
|
||||
->where('editorial_dimension_values.id', $valueId)
|
||||
->where('editorial_dimensions.slug', EditorialDimension::PILLAR_SLUG)
|
||||
->first(['editorial_dimension_values.pillar_id']);
|
||||
|
||||
if ($row === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $row->pillar_id === null ? null : (int) $row->pillar_id;
|
||||
}
|
||||
}
|
||||
@@ -40,19 +40,55 @@ public function present(Pillar $pillar, string $name, string $slug, ?string $sum
|
||||
|
||||
public function delete(Pillar $pillar): void
|
||||
{
|
||||
if ($pillar->elements()->exists() || $pillar->pages()->exists()) {
|
||||
throw new DomainRuleException('Eine Säule mit zugeordneten Medien oder Seiten wird nicht gelöscht.');
|
||||
$usage = $this->usage($pillar);
|
||||
|
||||
if (array_sum($usage) > 0) {
|
||||
throw new DomainRuleException('Eine Säule mit zugeordneten Objekten wird nicht gelöscht ('.$this->usageText($usage).'). Ordnen Sie sie zuerst anders zu.');
|
||||
}
|
||||
|
||||
$pillar->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $pillarIds
|
||||
* Zuordnungen je Objektart: Medien, Module und Programme, Lizenzartikel, Seiten.
|
||||
*
|
||||
* @return array{medien: int, zusammenstellungen: int, lizenzartikel: int, seiten: int}
|
||||
*/
|
||||
public function assign(ContentElement $element, array $pillarIds): void
|
||||
public function usage(Pillar $pillar): array
|
||||
{
|
||||
$element->pillars()->sync($this->ids($pillarIds));
|
||||
return [
|
||||
'medien' => $pillar->elements()->count(),
|
||||
'zusammenstellungen' => $pillar->compositions()->count(),
|
||||
'lizenzartikel' => $pillar->licenseArticles()->count(),
|
||||
'seiten' => $pillar->pages()->count(),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{medien: int, zusammenstellungen: int, lizenzartikel: int, seiten: int} $usage
|
||||
*/
|
||||
public function usageText(array $usage): string
|
||||
{
|
||||
$parts = [];
|
||||
|
||||
foreach (['medien' => ['Medium', 'Medien'], 'zusammenstellungen' => ['Modul oder Programm', 'Module und Programme'], 'lizenzartikel' => ['Lizenzartikel', 'Lizenzartikel'], 'seiten' => ['Seite', 'Seiten']] as $key => [$one, $many]) {
|
||||
if ($usage[$key] > 0) {
|
||||
$parts[] = $usage[$key].' '.($usage[$key] === 1 ? $one : $many);
|
||||
}
|
||||
}
|
||||
|
||||
return $parts === [] ? 'nirgends zugeordnet' : implode(', ', $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ordnet einem Medium, Modul, Programm, Lizenzartikel oder einer Seite Säulen zu. Alle Objektarten verwenden
|
||||
* dieselbe zentrale Säule und dieselbe Speicherregel; die Zuordnung ersetzt die bisherige vollständig.
|
||||
*
|
||||
* @param list<int|string> $pillarIds
|
||||
*/
|
||||
public function assign(ContentElement|Composition|LicenseArticle|Page $subject, array $pillarIds): void
|
||||
{
|
||||
$subject->pillars()->sync($this->ids($pillarIds));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +96,7 @@ public function assign(ContentElement $element, array $pillarIds): void
|
||||
*/
|
||||
public function assignPages(Page $page, array $pillarIds): void
|
||||
{
|
||||
$page->pillars()->sync($this->ids($pillarIds));
|
||||
$this->assign($page, $pillarIds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
* 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.
|
||||
* - texts: die zentralen Texte des Fachobjekts, aus denen die Karte einen wählen kann (teaser, summary, description).
|
||||
* summary bleibt der Text der Vorgabe („Automatisch“); texts wird nur gelesen, wenn die Redaktion einen wählt.
|
||||
*/
|
||||
final readonly class CardSubject
|
||||
{
|
||||
@@ -36,24 +38,39 @@ public function __construct(
|
||||
public ?string $previewImage = null,
|
||||
public array $missing = [],
|
||||
public ?string $style = null,
|
||||
public array $texts = [],
|
||||
) {}
|
||||
|
||||
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,
|
||||
);
|
||||
return $this->copy(['title' => $title ?? $this->title, 'summary' => $summary ?? $this->summary]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Text der Karte aus einem zentralen Text des Fachobjekts. Ist er nicht gepflegt, bleibt die Karte ohne Text
|
||||
* (kein stiller Ersatz aus einem anderen Feld); in der Redaktionsvorschau steht dann ein Hinweis.
|
||||
*/
|
||||
public function withTextChoice(string $field, string $missingHint): self
|
||||
{
|
||||
if (! array_key_exists($field, $this->texts)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$text = $this->texts[$field];
|
||||
$missing = array_values(array_filter($this->missing, fn (string $hint): bool => ! str_contains($hint, 'Kurzbeschreibung')));
|
||||
|
||||
if ($text === null) {
|
||||
$missing[] = $missingHint;
|
||||
}
|
||||
|
||||
return $this->copy(['summary' => $text, 'missing' => $missing]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $changes
|
||||
*/
|
||||
private function copy(array $changes): self
|
||||
{
|
||||
return new self(...array_merge(get_object_vars($this), $changes));
|
||||
}
|
||||
}
|
||||
@@ -265,6 +265,13 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
||||
$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;
|
||||
// Zentrale Texte, aus denen die Redaktion den Kartentext wählen kann (Zielgruppe „Öffentliche Kachel“).
|
||||
$texts = [
|
||||
'teaser' => $profile->value('teaser'),
|
||||
'summary' => $profile->value('summary'),
|
||||
'description' => $profile->value('description'),
|
||||
'goal' => $goal,
|
||||
];
|
||||
$missing = [];
|
||||
|
||||
if ($summary === null) {
|
||||
@@ -313,6 +320,7 @@ public function subject(mixed $id, bool $includeNonPublic): ?CardSubject
|
||||
visualLabel: $kind,
|
||||
previewImage: $includeNonPublic ? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path) : null,
|
||||
missing: $missing,
|
||||
texts: $texts,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,13 @@
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\StructureNode;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
|
||||
/**
|
||||
* Lesesicht „Medien und Materialien“ für Premium-Karten (Website-CMS-Zielarchitektur 6.2).
|
||||
*
|
||||
* Auswahl in der Redaktion: jedes nicht archivierte Inhaltselement mit mindestens einer nicht gesperrten Fassung.
|
||||
* Auswahl in der Redaktion: jedes nicht archivierte Inhaltselement mit mindestens einer nicht gesperrten Fassung, dazu
|
||||
* jeder Film, der nur aus einer Website-Datei besteht (Medium ohne Inhaltsfassung, z. B. ein Teaser).
|
||||
*
|
||||
* Öffentliche Sichtbarkeit (Übergangsregel, solange öffentliche Fachobjektprofile nach ADR-29 fehlen):
|
||||
* Ein Medium hat keine eigene öffentliche Seite. Öffentlich genannt wird es heute nur als Bestandteil der gezeigten
|
||||
@@ -20,10 +22,17 @@
|
||||
* öffentlich, mit Verweis auf diese Programmseite, und nur mit bereitgestellter Fassung. Traineranleitungen erscheinen
|
||||
* nie öffentlich (vertraulich für Trainerinnen und Trainer).
|
||||
*
|
||||
* Öffentlich gelesen werden Anzeigetitel (sonst Arbeitstitel), Kurzbeschreibung, Inhaltsart und Ausgabeart. Nie:
|
||||
* Beschreibung, Einsatzhinweis, Lizenzvermerk, Dateien, Lehrtexte, Ausgabeadressen. Das Vorschaubild (Filmstandbild)
|
||||
* der Bibliothek ist nicht für die Website freigegeben; es erscheint nur in der Redaktionsvorschau.
|
||||
* Eine Karte spielt nichts ab, bietet keinen Download und gibt kein Medium frei.
|
||||
* Ein Film nur mit Website-Datei hat weder Fassung noch Programm. Er erscheint öffentlich, sobald seine Website-Datei
|
||||
* für die Website freigegeben ist (die Freigabe ist die ausdrückliche Entscheidung der Redaktion), ohne Verweis auf
|
||||
* eine Programmseite und damit ohne Aktion. Ohne Freigabe bleibt er auf die Redaktionsvorschau beschränkt.
|
||||
*
|
||||
* Öffentlich gelesen werden Anzeigetitel (sonst Arbeitstitel), Inhaltsart und Ausgabeart sowie einer der Texte
|
||||
* Teaser, Kurzbeschreibung oder ausführliche Beschreibung. Welcher Text erscheint, entscheidet die Redaktion je Karte
|
||||
* (Einstellung „Text der Karte“); ohne Wahl gilt die Kurzbeschreibung, sonst der Teaser. Die ausführliche Beschreibung
|
||||
* erscheint nur, wenn die Redaktion sie ausdrücklich wählt. Nie: Einsatzhinweis, Lizenzvermerk, Dateien, Lehrtexte,
|
||||
* Ausgabeadressen. Das Vorschaubild der Bibliothek ist nicht für die Website freigegeben; es erscheint nur in der
|
||||
* Redaktionsvorschau und kann in der Karte ausdrücklich als Website-Bild übernommen werden (FilmStill).
|
||||
* Eine Karte spielt höchstens den für die Website freigegebenen Trailer ab (CardClip), bietet keinen Download und gibt kein Medium frei.
|
||||
*/
|
||||
class PublicMaterialReader
|
||||
{
|
||||
@@ -41,14 +50,36 @@ public function __construct(
|
||||
public function isSelectable(ContentElement $element): bool
|
||||
{
|
||||
return $element->archived_at === null
|
||||
&& $element->versions()->where('status', '!=', ContentVersionStatus::Gesperrt->value)->exists();
|
||||
&& ($element->versions()->where('status', '!=', ContentVersionStatus::Gesperrt->value)->exists()
|
||||
|| $this->isWebsiteOnlyFilm($element));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ein Film ohne jede Inhaltsfassung, der nur die Website-Datei (`teaser/…`) hat, zum Beispiel ein Teaser. Er kann
|
||||
* auf der Medienkarte gewählt werden; was daraus öffentlich wird, bestimmt allein die Freigabe der Datei.
|
||||
*/
|
||||
public function isWebsiteOnlyFilm(ContentElement $element): bool
|
||||
{
|
||||
return $element->output_class === 'film'
|
||||
&& filled($element->preview_path)
|
||||
&& ! $element->versions()->exists();
|
||||
}
|
||||
|
||||
public function isReady(ContentElement $element): bool
|
||||
{
|
||||
if ($this->isWebsiteOnlyFilm($element)) {
|
||||
return $this->isWebsiteReleased($element);
|
||||
}
|
||||
|
||||
return $element->versions()->where('status', ContentVersionStatus::Bereit->value)->exists();
|
||||
}
|
||||
|
||||
/** Die Website-Datei des Films ist freigegeben und wird tatsächlich ausgeliefert (WebsiteMedia). */
|
||||
private function isWebsiteReleased(ContentElement $element): bool
|
||||
{
|
||||
return app(WebsiteMedia::class)->present($element)?->kind === 'film';
|
||||
}
|
||||
|
||||
/**
|
||||
* Öffentliches Programm, in dessen gezeigter Fassung das Element vorkommt, sonst null.
|
||||
*
|
||||
@@ -64,7 +95,7 @@ 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;
|
||||
&& ($this->publicProgramFor($element) !== null || $this->isWebsiteOnlyFilm($element));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +108,13 @@ public function search(?string $term, int $limit = 25): array
|
||||
$candidates = ContentElement::query()
|
||||
->with('editorialContentKind')
|
||||
->whereNull('archived_at')
|
||||
->whereHas('versions', fn ($query) => $query->where('status', '!=', ContentVersionStatus::Gesperrt->value))
|
||||
->where(fn ($selectable) => $selectable
|
||||
->whereHas('versions', fn ($query) => $query->where('status', '!=', ContentVersionStatus::Gesperrt->value))
|
||||
->orWhere(fn ($websiteOnly) => $websiteOnly
|
||||
->where('output_class', 'film')
|
||||
->whereNotNull('preview_path')
|
||||
->where('preview_path', '!=', '')
|
||||
->whereDoesntHave('versions')))
|
||||
->when($term !== '', function ($query) use ($term): void {
|
||||
$like = '%'.mb_strtolower($term).'%';
|
||||
$query->where(fn ($inner) => $inner
|
||||
@@ -124,7 +161,7 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
|
||||
|
||||
$shown = clone $element;
|
||||
|
||||
foreach (['working_title', 'display_title', 'summary', 'thumbnail_path', 'thumbnail_alt'] as $field) {
|
||||
foreach (['working_title', 'display_title', 'teaser', 'summary', 'description', 'thumbnail_path', 'thumbnail_alt'] as $field) {
|
||||
if (! array_key_exists($field, $draft)) {
|
||||
continue;
|
||||
}
|
||||
@@ -146,17 +183,30 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
|
||||
$summary = trim((string) $shown->teaser);
|
||||
}
|
||||
|
||||
$texts = [];
|
||||
|
||||
foreach (['teaser', 'summary', 'description'] as $field) {
|
||||
$own = filled($shown->getAttribute($field)) ? trim((string) $shown->getAttribute($field)) : null;
|
||||
|
||||
if (! array_key_exists($field, $draft) && $profile->origin($field) === 'variante') {
|
||||
$own = $profile->value($field);
|
||||
}
|
||||
|
||||
$texts[$field] = $own;
|
||||
}
|
||||
|
||||
$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');
|
||||
}
|
||||
|
||||
$websiteOnly = $this->isWebsiteOnlyFilm($element);
|
||||
$meta = [$output];
|
||||
if ($program !== null) {
|
||||
$meta[] = 'Im Programm „'.$program['title'].'“';
|
||||
}
|
||||
if ($film) {
|
||||
if ($film && ! $websiteOnly) {
|
||||
$meta[] = 'Vollständiger Film nur mit Lizenz im Mitgliederbereich';
|
||||
}
|
||||
|
||||
@@ -184,6 +234,7 @@ public function subject(mixed $id, bool $includeNonPublic, array $draft = []): ?
|
||||
previewImage: $previewImage,
|
||||
missing: $missing,
|
||||
style: $film ? 'media' : 'material',
|
||||
texts: $texts,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -204,7 +255,11 @@ public function visibilityNote(ContentElement $element): string
|
||||
if ($this->isPublic($element)) {
|
||||
$program = $this->publicProgramFor($element);
|
||||
|
||||
return 'Öffentlich nur als Teil der Programmseite „'.($program['title'] ?? '').'“. Die Mediendatei wird dabei nicht ausgeliefert.';
|
||||
if ($program === null) {
|
||||
return 'Öffentlich mit der für die Website freigegebenen Datei, ohne Verweis auf eine Programmseite. Die Originaldatei wird nie ausgeliefert.';
|
||||
}
|
||||
|
||||
return 'Öffentlich nur als Teil der Programmseite „'.$program['title'].'“. Die Mediendatei wird dabei nicht ausgeliefert.';
|
||||
}
|
||||
|
||||
return $this->notice($element, $this->publicProgramFor($element));
|
||||
@@ -217,6 +272,7 @@ 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->isWebsiteOnlyFilm($element) => 'Die Website-Datei ist nicht für die Website freigegeben (Medium öffnen → Reiter „Website“ → freigeben).',
|
||||
! $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.',
|
||||
@@ -227,9 +283,14 @@ private function notice(ContentElement $element, ?array $program): string
|
||||
|
||||
private function optionLabel(ContentElement $element): string
|
||||
{
|
||||
$visibility = $this->isPublic($element)
|
||||
? 'öffentlich über Programmseite'
|
||||
: ($this->isReady($element) ? 'nur Redaktionsvorschau' : 'Entwurf, nur Redaktionsvorschau');
|
||||
$visibility = match (true) {
|
||||
$this->isWebsiteOnlyFilm($element) => $this->isPublic($element)
|
||||
? 'öffentlich mit Website-Datei'
|
||||
: 'Website-Datei nicht freigegeben, nur Redaktionsvorschau',
|
||||
$this->isPublic($element) => 'öffentlich über Programmseite',
|
||||
$this->isReady($element) => 'nur Redaktionsvorschau',
|
||||
default => 'Entwurf, nur Redaktionsvorschau',
|
||||
};
|
||||
$kind = $element->editorialContentKind?->label ?: self::outputLabel((string) $element->output_class);
|
||||
|
||||
return (string) ($element->display_title ?: $element->working_title).' · '.$kind.' · '.$visibility;
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Support;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\PresentationAssignment;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Der kurze Clip, den eine Premium-Karte beim Überfahren oder Antippen abspielt.
|
||||
*
|
||||
* Gelesen wird nur, was die Redaktion ohnehin für die Website freigegeben hat (WebsiteMedia, Route website.media):
|
||||
* 1. der Trailer des Fachobjekts (Präsentationsrolle „Trailer“), sonst der Vorschauclip,
|
||||
* 2. bei einem Film ersatzweise dessen eigener freigegebener Teaser.
|
||||
* Der vollständige Film, die Originaldatei und nicht freigegebene Clips kommen nie über die Karte. Die Karte gibt
|
||||
* nichts frei; ohne freigegebenen Clip bleibt es beim Kartenbild.
|
||||
*
|
||||
* In der Redaktionsvorschau erklärt `notice`, warum kein Clip läuft (zugeordnet, aber nicht freigegeben).
|
||||
*/
|
||||
class CardClip
|
||||
{
|
||||
/** Rollen in der Reihenfolge, in der ein Clip gesucht wird. */
|
||||
public const ROLES = ['trailer', 'vorschauclip'];
|
||||
|
||||
public function __construct(private readonly WebsiteMedia $media) {}
|
||||
|
||||
/**
|
||||
* @return array{url: string|null, title: string, source: string, notice: string|null, hint: string|null}
|
||||
*/
|
||||
public function for(Model $subject, bool $preview): array
|
||||
{
|
||||
$assigned = PresentationAssignment::query()
|
||||
->with(['role', 'element'])
|
||||
->where('subject_type', $subject->getMorphClass())
|
||||
->where('subject_id', $subject->getKey())
|
||||
->whereHas('role', fn ($query) => $query->whereIn('slug', self::ROLES))
|
||||
->orderBy('position')
|
||||
->orderBy('id')
|
||||
->get()
|
||||
->sortBy(fn (PresentationAssignment $row): int => (int) array_search($row->role?->slug, self::ROLES, true))
|
||||
->values();
|
||||
|
||||
$unreleased = null;
|
||||
|
||||
foreach ($assigned as $assignment) {
|
||||
$element = $assignment->element;
|
||||
|
||||
if (! $element instanceof ContentElement || $element->archived_at !== null || $element->output_class !== 'film') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$present = $this->media->present($element);
|
||||
|
||||
if ($present !== null && $present->kind === 'film') {
|
||||
return $this->found($present->url, $present->title, $assignment->role?->slug === 'trailer' ? 'trailer' : 'vorschauclip');
|
||||
}
|
||||
|
||||
$unreleased ??= $element;
|
||||
}
|
||||
|
||||
if ($subject instanceof ContentElement && $subject->output_class === 'film') {
|
||||
$own = $this->media->present($subject);
|
||||
|
||||
if ($own !== null && $own->kind === 'film') {
|
||||
return $this->found($own->url, $own->title, 'teaser');
|
||||
}
|
||||
}
|
||||
|
||||
if (! $preview) {
|
||||
return $this->none();
|
||||
}
|
||||
|
||||
if ($unreleased instanceof ContentElement) {
|
||||
$title = (string) ($unreleased->display_title ?: $unreleased->working_title);
|
||||
|
||||
return $this->none('Der Trailer „'.$title.'“ ist nicht für die Website freigegeben; öffentlich bleibt es beim Kartenbild (Medium öffnen → Reiter „Website“ → freigeben).');
|
||||
}
|
||||
|
||||
return $this->none(null, 'Kein Trailer zugeordnet; die Karte zeigt nur das Bild (Rolle „Trailer“ in der Präsentation des Mediums).');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{url: string|null, title: string, source: string, notice: string|null, hint: string|null}
|
||||
*/
|
||||
private function found(string $url, string $title, string $source): array
|
||||
{
|
||||
return ['url' => $url, 'title' => $title, 'source' => $source, 'notice' => null, 'hint' => null];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{url: string|null, title: string, source: string, notice: string|null, hint: string|null}
|
||||
*/
|
||||
private function none(?string $notice = null, ?string $hint = null): array
|
||||
{
|
||||
return ['url' => null, 'title' => '', 'source' => 'none', 'notice' => $notice, 'hint' => $hint];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Cms\Widgets\Support;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
|
||||
/**
|
||||
* Das Video des Einstiegs (Hero): ein stummer Clip auf der Fläche des Fotos.
|
||||
*
|
||||
* Gewählt wird ein Film aus dem Medienmanager. Abgespielt wird nur, was die Redaktion für die Website freigegeben hat,
|
||||
* und zwar nach derselben Regel wie auf der Karte (CardClip): Trailer des Films, sonst sein Vorschauclip, sonst seine
|
||||
* eigene freigegebene Website-Datei. Der vollständige Film, die Originaldatei und nicht freigegebene Clips kommen nie
|
||||
* über den Einstieg. Ohne freigegebenen Clip bleibt es beim Foto; die Auswahl gibt nichts frei.
|
||||
*/
|
||||
final class HeroVideo
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CardClip $clips,
|
||||
private readonly PublicMaterialReader $materials,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Auswahlliste: Filme, die auf der Website gezeigt werden dürfen, mit dem Stand ihrer Freigabe.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function options(?string $term, int $limit = 25): array
|
||||
{
|
||||
$term = trim((string) $term);
|
||||
|
||||
$candidates = ContentElement::query()
|
||||
->with('editorialContentKind')
|
||||
->where('output_class', 'film')
|
||||
->whereNull('archived_at')
|
||||
->when($term !== '', function ($query) use ($term): void {
|
||||
$like = '%'.mb_strtolower($term).'%';
|
||||
$query->where(fn ($inner) => $inner
|
||||
->whereRaw('LOWER(working_title) LIKE ?', [$like])
|
||||
->orWhereRaw('LOWER(COALESCE(display_title, \'\')) LIKE ?', [$like]));
|
||||
})
|
||||
->orderBy('working_title')
|
||||
->limit($limit * 2)
|
||||
->get();
|
||||
|
||||
$options = [];
|
||||
|
||||
foreach ($candidates as $element) {
|
||||
if (! $this->allowed($element)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$options[$element->id] = $this->label($element);
|
||||
|
||||
if (count($options) >= $limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function labelFor(mixed $id): ?string
|
||||
{
|
||||
$element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
return $element instanceof ContentElement ? $this->label($element) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft die gewählte Kennung. Gibt die Kennung zurück oder null, wenn keine gewählt ist oder die Wahl ungültig ist.
|
||||
*/
|
||||
public function clean(mixed $value, WidgetErrors $errors, string $key = 'refs.video'): ?int
|
||||
{
|
||||
if ($value === null || $value === '' || $value === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$element = is_numeric($value) ? ContentElement::query()->with('editorialContentKind')->find((int) $value) : null;
|
||||
|
||||
if (! $element instanceof ContentElement || ! $this->allowed($element)) {
|
||||
$errors->add($key, 'Bitte einen Film aus dem Medienmanager wählen (nicht archiviert, nicht gesperrt, keine Traineranleitung).');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $element->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{url: string|null, title: string, notice: string|null}
|
||||
*/
|
||||
public function resolve(mixed $id, bool $preview): array
|
||||
{
|
||||
$element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
if (! $element instanceof ContentElement) {
|
||||
return ['url' => null, 'title' => '', 'notice' => null];
|
||||
}
|
||||
|
||||
$title = (string) ($element->display_title ?: $element->working_title);
|
||||
|
||||
if (! $this->allowed($element)) {
|
||||
return ['url' => null, 'title' => $title, 'notice' => $preview ? 'Das gewählte Medium „'.$title.'“ ist archiviert oder gesperrt; es erscheint kein Video.' : null];
|
||||
}
|
||||
|
||||
$clip = $this->clips->for($element, $preview);
|
||||
|
||||
if ($clip['url'] !== null) {
|
||||
return ['url' => $clip['url'], 'title' => $clip['title'] !== '' ? $clip['title'] : $title, 'notice' => null];
|
||||
}
|
||||
|
||||
return [
|
||||
'url' => null,
|
||||
'title' => $title,
|
||||
'notice' => $preview
|
||||
? 'Für „'.$title.'“ gibt es kein für die Website freigegebenes Video (Trailer, Vorschauclip oder freigegebene Website-Datei des Mediums); öffentlich bleibt es beim Foto. Freigabe: Medium öffnen → Reiter „Website“.'
|
||||
: null,
|
||||
];
|
||||
}
|
||||
|
||||
/** Ein Film, der nicht archiviert, nicht gesperrt und keine Traineranleitung ist. */
|
||||
private function allowed(ContentElement $element): bool
|
||||
{
|
||||
return $element->output_class === 'film'
|
||||
&& $this->materials->isSelectable($element)
|
||||
&& ! in_array($element->editorialContentKind?->slug, PublicMaterialReader::CONFIDENTIAL_KINDS, true);
|
||||
}
|
||||
|
||||
private function label(ContentElement $element): string
|
||||
{
|
||||
$state = $this->clips->for($element, false)['url'] !== null ? 'Video freigegeben' : 'noch kein freigegebenes Video';
|
||||
|
||||
return (string) ($element->display_title ?: $element->working_title).' · '.$state;
|
||||
}
|
||||
}
|
||||
@@ -127,6 +127,10 @@ public function url(mixed $value, bool $preview = false): ?string
|
||||
|
||||
$legacy = self::normalize($value);
|
||||
|
||||
if (is_string($legacy) && WebsiteMediaAlias::isRetired($legacy)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return is_string($legacy) ? PublicMedia::url($legacy) : null;
|
||||
}
|
||||
|
||||
@@ -175,6 +179,10 @@ public function status(mixed $value): ?array
|
||||
|
||||
$id = $this->elementId($value);
|
||||
|
||||
if ($id === null && WebsiteMediaAlias::isRetired($value)) {
|
||||
return ['public' => false, 'state' => 'missing', 'title' => basename((string) $value), 'note' => 'Das Medium wurde gelöscht.', 'thumb' => null, 'manageUrl' => null];
|
||||
}
|
||||
|
||||
if ($id === null) {
|
||||
return [
|
||||
'public' => true,
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
namespace App\Domain\Cms\Widgets\Types;
|
||||
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\HeroVideo;
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Group;
|
||||
@@ -20,6 +22,10 @@
|
||||
* Containerbreite), Label, Überschriftenebene, Bildfokus in Prozent, Akzent, zwei Schaltflächen.
|
||||
* Die data-Schlüssel der Version 1 (heading, text, cta_*, alt) bleiben unverändert, damit ältere Revisionen und ein
|
||||
* Code-Rollback darstellbar bleiben.
|
||||
*
|
||||
* Optional ein Video (refs.video, ein Film aus dem Medienmanager): In der Variante „Foto mit Textfläche“ läuft ein
|
||||
* stummer, für die Website freigegebener Clip auf der Fläche des Fotos (HeroVideo, resources/js/hero-video.js). Neuer
|
||||
* Schlüssel ohne Versionssprung; ältere Revisionen ohne `video` bleiben unverändert darstellbar.
|
||||
*/
|
||||
class HeroWidget extends WidgetType
|
||||
{
|
||||
@@ -109,10 +115,18 @@ public function settings(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function settingGroups(): array
|
||||
{
|
||||
return [
|
||||
'Aussehen' => ['accent'],
|
||||
'Seitenstruktur' => ['heading_level'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'heading_level' => ['Überschriftenebene', 'Der erste Einstieg einer Seite ist immer die Hauptüberschrift (H1).'],
|
||||
'heading_level' => ['Überschriftenebene', 'Betrifft nur die Gliederung für Suchmaschinen und Hilfstechnik, nicht das Aussehen. Der erste Einstieg einer Seite ist immer die Hauptüberschrift (H1).'],
|
||||
'accent' => ['Markenakzent', 'Freigegebene Akzente aus dem Brand-UI-Kit. Vorgabe: gelbe Unterstreichung.'],
|
||||
];
|
||||
}
|
||||
@@ -152,7 +166,7 @@ public function dataRules(): array
|
||||
|
||||
public function refRules(): array
|
||||
{
|
||||
return ImageRefFields::rules();
|
||||
return ImageRefFields::rules() + ['video' => ['nullable']];
|
||||
}
|
||||
|
||||
public function dataFields(): array
|
||||
@@ -169,7 +183,19 @@ public function dataFields(): array
|
||||
|
||||
public function refFields(): array
|
||||
{
|
||||
return ImageRefFields::fields(live: true);
|
||||
return [...ImageRefFields::fields(live: true), $this->videoField()];
|
||||
}
|
||||
|
||||
private function videoField(): Select
|
||||
{
|
||||
return Select::make('video')
|
||||
->label('Video (optional)')
|
||||
->helperText('Ein Film aus dem Medienmanager. Läuft stumm auf der Fläche des Fotos, nur in der Variante „Foto mit Textfläche“ und nur, wenn ein Trailer, Vorschauclip oder die Website-Datei des Films für die Website freigegeben ist. Das Foto bleibt als Rückfall, bei „reduzierte Bewegung“ und im Datensparmodus startet das Video nur auf Wunsch. Die Auswahl gibt nichts frei.')
|
||||
->live()
|
||||
->searchable()
|
||||
->getSearchResultsUsing(fn (?string $search): array => app(HeroVideo::class)->options($search))
|
||||
->getOptionLabelUsing(fn (mixed $value): ?string => app(HeroVideo::class)->labelFor($value))
|
||||
->options(fn (): array => app(HeroVideo::class)->options(null));
|
||||
}
|
||||
|
||||
public function editorSchema(): array
|
||||
@@ -192,6 +218,8 @@ public function mediaSchema(): array
|
||||
public function clean(array $data, array $refs, WidgetErrors $errors): array
|
||||
{
|
||||
$refs = ImageRefFields::clean($refs, $errors);
|
||||
$video = app(HeroVideo::class)->clean($refs['video'] ?? null, $errors);
|
||||
$video === null ? $refs = array_diff_key($refs, ['video' => true]) : $refs['video'] = $video;
|
||||
$data['heading'] = trim((string) ($data['heading'] ?? ''));
|
||||
$data['text'] = filled($data['text'] ?? null) ? trim((string) $data['text']) : null;
|
||||
$data = PremiumFields::clean($data, $errors, $refs['image'] !== null);
|
||||
@@ -205,8 +233,15 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
|
||||
$images = app(WebsiteImage::class);
|
||||
$image = $widget['refs']['image'] ?? null;
|
||||
$video = app(HeroVideo::class)->resolve($widget['refs']['video'] ?? null, $context->preview);
|
||||
$photoSplit = ($widget['variant'] ?? 'photo_split') !== 'editorial_solid';
|
||||
|
||||
if (! $photoSplit && $video['title'] !== '') {
|
||||
$video = ['url' => null, 'title' => $video['title'], 'notice' => $context->preview ? 'Das Video erscheint nur in der Variante „Foto mit Textfläche“; die Markenfläche zeigt kein Video.' : null];
|
||||
}
|
||||
|
||||
return [
|
||||
'video' => $video,
|
||||
'imageUrl' => $images->url($image, $context->preview),
|
||||
'imageAlt' => $images->alt($image, $widget['data']['alt'] ?? null),
|
||||
'imageNotice' => $context->preview ? $images->previewNotice($image) : null,
|
||||
|
||||
@@ -117,11 +117,19 @@ public function settings(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function settingGroups(): array
|
||||
{
|
||||
return [
|
||||
'Aussehen' => ['surface'],
|
||||
'Seitenstruktur' => ['heading_level'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'surface' => ['Hintergrund des Widgets', 'Unabhängig vom Abschnittshintergrund. „Ohne eigene Fläche“ übernimmt den Abschnitt.'],
|
||||
'heading_level' => ['Überschriftenebene', 'Steht das Widget als erstes auf der Seite, ist die Überschrift immer H1.'],
|
||||
'heading_level' => ['Überschriftenebene', 'Betrifft nur die Gliederung für Suchmaschinen und Hilfstechnik, nicht das Aussehen. Steht das Widget als erstes auf der Seite, ist die Überschrift immer H1.'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,17 @@
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Media\FilmStill;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use Filament\Forms\Components\ViewField;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Medien- und Materialkarte (Kit v1.7 „media“): ein Inhaltselement mit Anzeigetitel, Kurzbeschreibung, Inhaltsart und
|
||||
* Ausgabeart. Filme erscheinen als Medienkarte (grüne Aktion, Filmtafel ohne freigegebenes Bild), Dokumente und andere
|
||||
* Materialien als Materialkarte (Materialsymbol). Öffentlich nur nach den Regeln von PublicMaterialReader; die Aktion
|
||||
* führt auf die öffentliche Programmseite. Die Karte spielt nichts ab, bietet keinen Download und gibt kein Medium frei.
|
||||
* führt auf die öffentliche Programmseite. Die Karte spielt höchstens den für die Website freigegebenen Trailer ab (CardClip), bietet keinen Download und gibt kein Medium frei.
|
||||
*/
|
||||
class MediaCardWidget extends PremiumCardWidget
|
||||
{
|
||||
@@ -28,7 +33,7 @@ public function label(): string
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Karte zu einem Film oder Material aus der Bibliothek; Titel und Art kommen aus den Fachdaten, kein Abspielen, kein Download.';
|
||||
return 'Karte zu einem Film oder Material aus der Bibliothek; Titel und Art kommen aus den Fachdaten, Trailer nur wenn freigegeben, kein Download.';
|
||||
}
|
||||
|
||||
public function icon(): string
|
||||
@@ -53,7 +58,7 @@ protected function refLabel(): string
|
||||
|
||||
protected function refHelp(): string
|
||||
{
|
||||
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.';
|
||||
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; ein Film nur mit Website-Datei (zum Beispiel ein Teaser) erscheint, sobald diese Datei für die Website freigegeben ist. Traineranleitungen nie. Titel, Teaser, Kurzbeschreibung und Beschreibung pflegen Sie im Medium; welcher Text auf der Karte erscheint, wählen Sie unter „Darstellung“.';
|
||||
}
|
||||
|
||||
protected function searchSubjects(?string $term): array
|
||||
@@ -90,6 +95,80 @@ protected function cardStyle(): string
|
||||
return 'media';
|
||||
}
|
||||
|
||||
/**
|
||||
* Bei einem Film: das Vorschaubild des Films oder eine Stelle des Films als Kartenbild übernehmen. Das Bild wird
|
||||
* einmal als Bild-Medium abgelegt (FilmStill) und wie jedes andere Bild ausgewählt; die Karte liest nur diese Datei.
|
||||
*/
|
||||
protected function imageSourceFields(): array
|
||||
{
|
||||
return [
|
||||
ViewField::make('_filmbild')
|
||||
->label('Bild aus dem Film')
|
||||
->view('filament.cms.filmbild-feld')
|
||||
->dehydrated(false)
|
||||
->visible(fn (Get $get): bool => $this->filmFor($get('element')) !== null)
|
||||
->viewData(fn (Get $get): array => $this->filmFieldData($this->filmFor($get('element')))),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Anzeigedaten des Felds „Bild aus dem Film“. Die Stelle kommt aus der bereitgestellten Fassung, bei einem Film
|
||||
* nur mit Website-Datei aus dieser (Route content.website-frame).
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
protected function filmFieldData(?ContentElement $film): array
|
||||
{
|
||||
$stills = app(FilmStill::class);
|
||||
$version = $film instanceof ContentElement ? $stills->version($film) : null;
|
||||
|
||||
return [
|
||||
'film' => $film,
|
||||
'filmTitle' => $film instanceof ContentElement ? (string) ($film->display_title ?: $film->working_title) : '',
|
||||
'filmVersionId' => $version?->id,
|
||||
'filmWebsiteFrameUrl' => $film instanceof ContentElement && $version === null && $stills->websiteFile($film) !== null
|
||||
? route('content.website-frame', ['element' => $film])
|
||||
: null,
|
||||
'filmHasThumbnail' => $film instanceof ContentElement && is_string($film->thumbnail_path) && $film->thumbnail_path !== '',
|
||||
'filmThumbnailUrl' => $film instanceof ContentElement ? ThumbnailRef::url('editorial.card', 'element', (int) $film->id, $film->thumbnail_path) : null,
|
||||
'filmStartSecond' => $film instanceof ContentElement ? ($stills->thumbnailSecond($film) ?? '0') : '0',
|
||||
];
|
||||
}
|
||||
|
||||
private function filmFor(mixed $id): ?ContentElement
|
||||
{
|
||||
$element = is_numeric($id) ? ContentElement::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
return $element instanceof ContentElement && app(FilmStill::class)->refusal($element) === null ? $element : null;
|
||||
}
|
||||
|
||||
protected function subjectNoun(): string
|
||||
{
|
||||
return 'Medium';
|
||||
}
|
||||
|
||||
protected function textChoices(): array
|
||||
{
|
||||
return [
|
||||
'auto' => 'Automatisch (Kurzbeschreibung, sonst Teaser)',
|
||||
'teaser' => 'Teaser',
|
||||
'summary' => 'Kurzbeschreibung',
|
||||
'description' => 'Ausführliche Beschreibung (erscheint öffentlich)',
|
||||
];
|
||||
}
|
||||
|
||||
protected function supportsClip(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function clipSubject(mixed $id): ?Model
|
||||
{
|
||||
$element = is_numeric($id) ? ContentElement::query()->find((int) $id) : null;
|
||||
|
||||
return $element instanceof ContentElement ? $element : null;
|
||||
}
|
||||
|
||||
protected function centralCoverId(mixed $id): ?int
|
||||
{
|
||||
$element = is_numeric($id) ? ContentElement::query()->find((int) $id) : null;
|
||||
|
||||
@@ -4,16 +4,19 @@
|
||||
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Cms\Widgets\Support\CardClip;
|
||||
use App\Domain\Cms\Widgets\Support\ImageRefFields;
|
||||
use App\Domain\Cms\Widgets\Support\PremiumFields;
|
||||
use App\Domain\Cms\Widgets\Support\PublicMedia;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Cms\Widgets\WidgetErrors;
|
||||
use App\Domain\Cms\Widgets\WidgetType;
|
||||
use Filament\Forms\Components\Field;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Group;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
@@ -56,6 +59,56 @@ abstract protected function defaultActionLabel(): string;
|
||||
/** Gestaltungsvariante des Kits: editorial, media oder catalog. */
|
||||
abstract protected function cardStyle(): string;
|
||||
|
||||
/**
|
||||
* Weitere Wege zum Kartenbild im Reiter „Medien“, zum Beispiel ein Bild aus dem Film. Standard: keine.
|
||||
*
|
||||
* @return list<Field>
|
||||
*/
|
||||
protected function imageSourceFields(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Fachobjekt, dessen Trailer die Karte beim Überfahren oder Antippen abspielt (Medium, Programm, Modul).
|
||||
* Null: diese Karte hat keinen Clip (Thema). Der Clip kommt aus der Präsentation des Objekts (CardClip).
|
||||
*/
|
||||
protected function clipSubject(mixed $id): ?Model
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zentrale Texte des Fachobjekts, aus denen die Redaktion den Kartentext wählen kann: Wert => Bezeichnung.
|
||||
* Leer: keine Wahl (die Karte nimmt den Text ihrer Vorgabe). Mit Wahl gilt „auto“ als Vorgabe.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function textChoices(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/** Was die Redaktion bearbeitet, um einen Text zu pflegen („Medium“, „Programm oder Modul“); für Hinweise. */
|
||||
protected function subjectNoun(): string
|
||||
{
|
||||
return 'Objekt';
|
||||
}
|
||||
|
||||
/** Hinweis der Redaktionsvorschau, wenn der gewählte zentrale Text nicht gepflegt ist. */
|
||||
private function missingTextHint(string $field): string
|
||||
{
|
||||
$noun = $this->subjectNoun();
|
||||
|
||||
return match ($field) {
|
||||
'teaser' => 'Kein Teaser gepflegt ('.$noun.' bearbeiten → Teaser).',
|
||||
'summary' => 'Keine Kurzbeschreibung gepflegt ('.$noun.' bearbeiten → Kurzbeschreibung).',
|
||||
'description' => 'Keine ausführliche Beschreibung gepflegt ('.$noun.' bearbeiten → Beschreibung).',
|
||||
'goal' => 'Kein Lernziel gepflegt ('.$noun.' bearbeiten → Lernziel der Fassung).',
|
||||
default => '',
|
||||
};
|
||||
}
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'widgets.premium_card';
|
||||
@@ -110,7 +163,9 @@ public function optionIcons(): array
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
return [
|
||||
$choices = $this->textChoices();
|
||||
|
||||
return ($choices === [] ? [] : ['text_source' => $choices]) + ($this->supportsClip() ? ['clip' => ['yes' => 'Abspielen', 'no' => 'Nicht abspielen'], 'show_body' => self::SHOW] : []) + [
|
||||
'format' => ['landscape' => 'Querformat 16:9', 'square' => 'Quadrat 1:1', 'portrait' => 'Hochformat 3:4'],
|
||||
'fit' => ['cover' => 'Ausschnitt füllt die Fläche', 'contain' => 'Ganzes Bild zeigen (Dokument, Poster)'],
|
||||
'heading_level' => ['h3' => 'H3', 'h2' => 'H2', 'h4' => 'H4'],
|
||||
@@ -121,16 +176,34 @@ public function settings(): array
|
||||
];
|
||||
}
|
||||
|
||||
public function settingGroups(): array
|
||||
{
|
||||
return [
|
||||
'Bild und Video' => ['format', 'fit', 'clip'],
|
||||
'Texte auf der Karte' => ['show_body', 'text_source', 'show_summary', 'show_kind', 'show_meta', 'show_action'],
|
||||
'Seitenstruktur' => ['heading_level'],
|
||||
];
|
||||
}
|
||||
|
||||
public function settingHiddenWhen(): array
|
||||
{
|
||||
// „Texte auf der Karte: Ausblenden“ macht die Einzelschalter wirkungslos; sie bleiben gespeichert, aber unsichtbar.
|
||||
return array_fill_keys(['text_source', 'show_summary', 'show_kind', 'show_meta', 'show_action'], ['show_body', 'no']);
|
||||
}
|
||||
|
||||
public function settingLabels(): array
|
||||
{
|
||||
return [
|
||||
'format' => ['Bildformat', 'Vorgabe: Querformat 16:9. Gilt auch neben dem Text; das Motiv wird nicht nachträglich hochkant beschnitten.'],
|
||||
'fit' => ['Bilddarstellung', 'Vorgabe: Ausschnitt. „Ganzes Bild“ zeigt Dokumente und Poster vollständig auf ruhiger Fläche.'],
|
||||
'heading_level' => ['Überschriftenebene', 'Vorgabe: H3, passend unter einer Abschnittsüberschrift (H2).'],
|
||||
'show_summary' => ['Kurzbeschreibung', 'Aus den Fachdaten. Vorgabe: anzeigen.'],
|
||||
'show_kind' => ['Art oder Label', 'Zum Beispiel „Thema“ oder „Merkblatt“. Vorgabe: anzeigen.'],
|
||||
'show_meta' => ['Zusatzangaben', 'Aus den Fachdaten, zum Beispiel Ausgabeart oder Programmzugehörigkeit. Vorgabe: anzeigen.'],
|
||||
'show_action' => ['Aktion', 'Verweis auf die öffentliche Seite des Fachobjekts, falls es eine gibt. Vorgabe: anzeigen.'],
|
||||
'format' => ['Bildformat', 'Seitenverhältnis des Bildes oder Videos. Vorgabe: Querformat 16:9. Gilt auch neben dem Text; das Motiv wird nicht nachträglich hochkant beschnitten.'],
|
||||
'fit' => ['Bildausschnitt', 'Ausschnitt füllt die ganze Fläche; „Ganzes Bild“ zeigt Dokumente und Poster vollständig auf ruhiger Fläche. Vorgabe: Ausschnitt.'],
|
||||
'clip' => ['Trailer auf der Karte', 'Spielt den freigegebenen Trailer als stumme Vorschau, solange die Maus auf der Karte steht; ein Klick oder Tipp auf das Bild oder die kleine Schaltfläche (auch per Tastatur) spielt ihn mit Ton. Gewählt wird der Trailer (sonst der Vorschauclip) in der Präsentation des Objekts, bei einem Film ersatzweise sein freigegebener Teaser. Ohne freigegebenen Clip bleibt das Kartenbild. Vorgabe: Abspielen.'],
|
||||
'show_body' => ['Texte auf der Karte', 'Hauptschalter für alle Texte neben dem Bild. „Ausblenden“ zeigt nur Bild und Video, ohne Titel, Beschreibung, Art, Zusatzangaben und Schaltfläche; die Einzelschalter darunter verschwinden dann. Für Hilfstechnik bleibt der Titel unsichtbar erhalten. Sinnvoll, wenn das Video allein erklärt. Vorgabe: Anzeigen.'],
|
||||
'text_source' => ['Quelle der Beschreibung', 'Welche Angabe aus der Redaktion als Beschreibung erscheint. Vorgabe: Automatisch. Der Text erscheint öffentlich, wenn die Karte öffentlich ist; ist er nicht gepflegt, bleibt die Karte ohne Beschreibung.'],
|
||||
'show_summary' => ['Beschreibung', 'Der Beschreibungstext unter dem Titel, aus den Fachdaten. Vorgabe: Anzeigen.'],
|
||||
'show_kind' => ['Art-Label', 'Kleines Label über dem Titel, zum Beispiel „Thema“ oder „Merkblatt“. Vorgabe: Anzeigen.'],
|
||||
'show_meta' => ['Zusatzangaben', 'Angaben aus den Fachdaten, zum Beispiel Ausgabeart oder Programmzugehörigkeit. Vorgabe: Anzeigen.'],
|
||||
'show_action' => ['Schaltfläche', 'Verweis auf die öffentliche Seite des Fachobjekts, falls es eine gibt. Vorgabe: Anzeigen.'],
|
||||
'heading_level' => ['Überschriftenebene', 'Betrifft nur die Gliederung für Suchmaschinen und Hilfstechnik, nicht das Aussehen. Vorgabe: H3, passend unter einer Abschnittsüberschrift (H2).'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -195,13 +268,13 @@ public function editorSchema(): array
|
||||
->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')
|
||||
->label('Text 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')
|
||||
->placeholder(fn (Get $get): string => $this->centralText($get('../refs.'.$this->refKey()), 'summary', $get('../settings.text_source')) ?? 'Zentraler Text aus der Redaktion')
|
||||
->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.'),
|
||||
->helperText('Leer übernimmt den Text, den „Text der Karte“ (Darstellung) wählt. Lehrinhalt, Rechte und Preise bleiben unberührt.'),
|
||||
])->statePath('data'),
|
||||
];
|
||||
}
|
||||
@@ -211,7 +284,7 @@ public function mediaSchema(): array
|
||||
[, , $alt, $focusX, $focusY] = $this->dataFields();
|
||||
|
||||
return [
|
||||
Group::make(ImageRefFields::fields('Kartenbild', live: true))->statePath('refs'),
|
||||
Group::make([...ImageRefFields::fields('Kartenbild', live: true), ...$this->imageSourceFields()])->statePath('refs'),
|
||||
Group::make([$alt, $focusX, $focusY])->statePath('data'),
|
||||
];
|
||||
}
|
||||
@@ -248,6 +321,12 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
$data = $widget['data'];
|
||||
|
||||
$subject = $this->subject($widget['refs'][$this->refKey()] ?? null, $context);
|
||||
$textSource = $option('text_source', 'auto');
|
||||
|
||||
if ($subject instanceof CardSubject && $textSource !== 'auto' && isset($this->textChoices()[$textSource])) {
|
||||
$subject = $subject->withTextChoice($textSource, $this->missingTextHint($textSource));
|
||||
}
|
||||
|
||||
$heading = filled($data['heading'] ?? null) ? trim((string) $data['heading']) : null;
|
||||
$lead = filled($data['summary'] ?? null) ? trim((string) $data['summary']) : null;
|
||||
|
||||
@@ -258,8 +337,16 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
$storedImage = WebsiteImage::normalize($widget['refs']['image'] ?? null);
|
||||
$imageRef = $storedImage ?? $this->centralCoverId($widget['refs'][$this->refKey()] ?? null);
|
||||
|
||||
$clip = null;
|
||||
|
||||
if ($this->supportsClip() && $option('clip', 'yes') === 'yes' && $subject instanceof CardSubject) {
|
||||
$owner = $this->clipSubject($widget['refs'][$this->refKey()] ?? null);
|
||||
$clip = $owner instanceof Model ? app(CardClip::class)->for($owner, $context->preview) : null;
|
||||
}
|
||||
|
||||
return [
|
||||
'subject' => $subject,
|
||||
'clip' => $clip,
|
||||
'cardStyle' => $subject?->style ?? $this->cardStyle(),
|
||||
'imageUrl' => app(WebsiteImage::class)->url($imageRef, $context->preview),
|
||||
'alt' => app(WebsiteImage::class)->alt($imageRef, $data['alt'] ?? null),
|
||||
@@ -277,6 +364,7 @@ public function resolve(array $widget, RenderContext $context): array
|
||||
'actionLabel' => filled($data['action_label'] ?? null) ? (string) $data['action_label'] : $this->defaultActionLabel(),
|
||||
'note' => filled($data['note'] ?? null) ? (string) $data['note'] : null,
|
||||
'stacked' => $widget['variant'] === 'stacked',
|
||||
'bare' => $this->supportsClip() && $option('show_body', 'yes') === 'no',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -299,10 +387,15 @@ protected function centralCoverId(mixed $id): ?int
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function supportsClip(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zentraler Anzeigename oder Teaser des gewählten Objekts (Redaktionsstand) für Platzhalter im Editor.
|
||||
*/
|
||||
private function centralText(mixed $id, string $field): ?string
|
||||
private function centralText(mixed $id, string $field, mixed $textSource = null): ?string
|
||||
{
|
||||
if (blank($id)) {
|
||||
return null;
|
||||
@@ -314,6 +407,10 @@ private function centralText(mixed $id, string $field): ?string
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($subject instanceof CardSubject && is_string($textSource) && isset($this->textChoices()[$textSource]) && $textSource !== 'auto') {
|
||||
$subject = $subject->withTextChoice($textSource, $this->missingTextHint($textSource));
|
||||
}
|
||||
|
||||
$text = $subject?->{$field};
|
||||
|
||||
return is_string($text) && trim($text) !== '' ? Str::limit(trim($text), 120) : null;
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
use App\Domain\Cms\Catalog\CardSubject;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Media\CompositionStill;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use Filament\Forms\Components\ViewField;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* Modul- und Programmkarte (Kit v1.7 „catalog“): ein Programm oder Modul über PublicCatalogReader, dieselbe
|
||||
@@ -41,6 +46,59 @@ public function schematic(): array
|
||||
return [[2, 2, 56, 32, 'line'], [5, 5, 22, 26, 'ink'], [8, 24, 10, 2, 'accent'], [31, 8, 10, 2, 'line'], [31, 13, 22, 4, 'ink'], [31, 25, 14, 5, 'ink']];
|
||||
}
|
||||
|
||||
/**
|
||||
* Das Vorschaubild des Programms oder Moduls als Kartenbild übernehmen. Es wird einmal als Bild-Medium abgelegt
|
||||
* (CompositionStill) und wie jedes andere Bild ausgewählt; die Karte liest nur diese Datei.
|
||||
*/
|
||||
protected function imageSourceFields(): array
|
||||
{
|
||||
return [
|
||||
ViewField::make('_programmbild')
|
||||
->label('Bild aus dem Programm oder Modul')
|
||||
->view('filament.cms.kompositionsbild-feld')
|
||||
->dehydrated(false)
|
||||
->visible(fn (Get $get): bool => $this->compositionFor($get('composition')) !== null)
|
||||
->viewData(function (Get $get): array {
|
||||
$composition = $this->compositionFor($get('composition'));
|
||||
|
||||
return [
|
||||
'composition' => $composition,
|
||||
'compositionTitle' => $composition instanceof Composition ? (string) ($composition->display_title ?: $composition->designation) : '',
|
||||
'compositionThumbnailUrl' => $composition instanceof Composition && app(CompositionStill::class)->hasThumbnail($composition)
|
||||
? ThumbnailRef::url('editorial.card', 'komposition', (int) $composition->id, $composition->thumbnail_path)
|
||||
: null,
|
||||
];
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
private function compositionFor(mixed $id): ?Composition
|
||||
{
|
||||
$composition = is_numeric($id) ? Composition::query()->with('editorialContentKind')->find((int) $id) : null;
|
||||
|
||||
return $composition instanceof Composition && app(PublicCatalogReader::class)->isCardSelectable($composition) ? $composition : null;
|
||||
}
|
||||
|
||||
protected function subjectNoun(): string
|
||||
{
|
||||
return 'Programm oder Modul';
|
||||
}
|
||||
|
||||
/**
|
||||
* Wählbare Texte: die zentralen Texte des Programms oder Moduls und das Lernziel der Fassung. „Automatisch“ bleibt
|
||||
* wie bisher: Teaser, sonst Kurzbeschreibung, sonst Lernziel. Die ausführliche Beschreibung erscheint nur auf Wahl.
|
||||
*/
|
||||
protected function textChoices(): array
|
||||
{
|
||||
return [
|
||||
'auto' => 'Automatisch (Teaser, sonst Kurzbeschreibung, sonst Lernziel)',
|
||||
'teaser' => 'Teaser',
|
||||
'summary' => 'Kurzbeschreibung',
|
||||
'description' => 'Ausführliche Beschreibung (erscheint öffentlich)',
|
||||
'goal' => 'Lernziel der Fassung',
|
||||
];
|
||||
}
|
||||
|
||||
public function settings(): array
|
||||
{
|
||||
// Die Art (Programm oder Modul) bleibt immer sichtbar; sie lässt sich nicht ausblenden.
|
||||
@@ -99,6 +157,18 @@ protected function cardStyle(): string
|
||||
return 'catalog';
|
||||
}
|
||||
|
||||
protected function supportsClip(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function clipSubject(mixed $id): ?Model
|
||||
{
|
||||
$composition = is_numeric($id) ? Composition::query()->find((int) $id) : null;
|
||||
|
||||
return $composition instanceof Composition ? $composition : null;
|
||||
}
|
||||
|
||||
protected function centralCoverId(mixed $id): ?int
|
||||
{
|
||||
$composition = is_numeric($id) ? Composition::query()->find((int) $id) : null;
|
||||
|
||||
@@ -194,6 +194,29 @@ public function settingLabels(): array
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gliederung der Einstellungen im Reiter „Darstellung“: Gruppentitel => Schlüssel der Einstellungen in der
|
||||
* Reihenfolge der Anzeige. Variante und Höhe stehen immer in der ersten Gruppe „Aufbau“. Einstellungen ohne
|
||||
* Gruppe erscheinen unter „Weitere Einstellungen“, so geht keine verloren.
|
||||
*
|
||||
* @return array<string, list<string>>
|
||||
*/
|
||||
public function settingGroups(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Einstellungen, die im Editor ausgeblendet werden, solange eine andere Einstellung einen bestimmten Wert hat:
|
||||
* Schlüssel => [steuernde Einstellung, Wert, bei dem ausgeblendet wird]. Die Werte bleiben dabei erhalten.
|
||||
*
|
||||
* @return array<string, array{0: string, 1: string}>
|
||||
*/
|
||||
public function settingHiddenWhen(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Alle zulässigen Einstellungen einschließlich der gemeinsamen Höhe. Registry-Prüfung, Editor und Darstellung
|
||||
* verwenden ausschließlich diese Zusammenführung.
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Identity\Party;
|
||||
use App\Domain\Identity\PartyType;
|
||||
use App\Models\User;
|
||||
|
||||
/**
|
||||
* Sitzungsgebundener Mehrangebotswarenkorb (Etappe 1). Er bleibt in derselben Browsersitzung über Anmeldung,
|
||||
* Registrierung und E-Mail-Bestätigung erhalten. Je Option gibt es genau eine Position. Optionen derselben Produktseite
|
||||
* (gleiche Komposition) sind Alternativen und werden nur nach ausdrücklichem Wechsel ersetzt.
|
||||
* Der Warenkorb reserviert weder Preis noch Konditionen; er merkt sich, was der Käufer gesehen hat.
|
||||
*/
|
||||
class Cart
|
||||
{
|
||||
public const KEY = 'shop.cart';
|
||||
|
||||
public const ADDED = 'added';
|
||||
|
||||
public const PRESENT = 'present';
|
||||
|
||||
public const ALTERNATIVE = 'alternative';
|
||||
|
||||
public const UNAVAILABLE = 'unavailable';
|
||||
|
||||
public function __construct(
|
||||
private readonly OwnershipCheck $ownership,
|
||||
private readonly OrderHolders $holders,
|
||||
private readonly OfferService $offers,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return array<int, array{version_id: int, price_cents: int}>
|
||||
*/
|
||||
public function items(): array
|
||||
{
|
||||
return (array) session()->get(self::KEY, []);
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->items());
|
||||
}
|
||||
|
||||
public function has(Offer $offer): bool
|
||||
{
|
||||
return isset($this->items()[$offer->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Die bereits enthaltene Alternative derselben Produktseite, falls vorhanden.
|
||||
*/
|
||||
public function alternativeTo(Offer $offer): ?Offer
|
||||
{
|
||||
if ($offer->composition_id === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$ids = array_diff(array_keys($this->items()), [$offer->id]);
|
||||
|
||||
return $ids === [] ? null : Offer::query()
|
||||
->whereIn('id', $ids)
|
||||
->where('composition_id', $offer->composition_id)
|
||||
->first();
|
||||
}
|
||||
|
||||
public function add(Offer $offer): string
|
||||
{
|
||||
$version = $this->purchasable($offer);
|
||||
|
||||
if ($version === null) {
|
||||
return self::UNAVAILABLE;
|
||||
}
|
||||
|
||||
if ($this->has($offer)) {
|
||||
return self::PRESENT;
|
||||
}
|
||||
|
||||
if ($this->alternativeTo($offer) !== null) {
|
||||
return self::ALTERNATIVE;
|
||||
}
|
||||
|
||||
$this->put($offer, $version);
|
||||
|
||||
return self::ADDED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ausdrücklicher Wechsel: die Alternative wird durch die gewählte Option ersetzt.
|
||||
*/
|
||||
public function switchTo(Offer $offer): bool
|
||||
{
|
||||
$version = $this->purchasable($offer);
|
||||
|
||||
if ($version === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$alternative = $this->alternativeTo($offer);
|
||||
|
||||
if ($alternative !== null) {
|
||||
$this->remove($alternative);
|
||||
}
|
||||
|
||||
$this->put($offer, $version);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function remove(Offer $offer): void
|
||||
{
|
||||
$items = $this->items();
|
||||
unset($items[$offer->id]);
|
||||
session()->put(self::KEY, $items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Käufer übernimmt Preis und Fassung, die der Shop jetzt zeigt.
|
||||
*/
|
||||
public function acceptCurrent(Offer $offer): void
|
||||
{
|
||||
$version = $this->purchasable($offer);
|
||||
|
||||
if ($version !== null && $this->has($offer)) {
|
||||
$this->put($offer, $version);
|
||||
}
|
||||
}
|
||||
|
||||
public function clear(): void
|
||||
{
|
||||
session()->forget(self::KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serverseitige Prüfung: aktuelle Fassung, Preis, Kaufbarkeit, passende Inhaberart, vorhandene Rechte.
|
||||
*/
|
||||
public function review(?User $user = null, ?int $holderPartyId = null): CartReview
|
||||
{
|
||||
$offers = Offer::query()
|
||||
->whereIn('id', array_keys($this->items()))
|
||||
->with('composition')
|
||||
->get()
|
||||
->keyBy('id');
|
||||
$versions = [];
|
||||
|
||||
foreach ($this->items() as $offerId => $item) {
|
||||
$offer = $offers->get($offerId);
|
||||
|
||||
if ($offer !== null) {
|
||||
$versions[$offerId] = $this->purchasable($offer);
|
||||
}
|
||||
}
|
||||
|
||||
$holder = $user === null ? null : $this->holderFor($user, $holderPartyId, $versions);
|
||||
$lines = [];
|
||||
|
||||
foreach ($this->items() as $offerId => $item) {
|
||||
$offer = $offers->get($offerId);
|
||||
|
||||
if ($offer === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$version = $versions[$offerId] ?? null;
|
||||
$seen = (int) $item['price_cents'];
|
||||
|
||||
if ($version === null) {
|
||||
$lines[] = new CartLine($offer, null, CartLine::WITHDRAWN, $seen, null,
|
||||
'Diese Option ist nicht mehr erhältlich. Entferne sie, um mit den übrigen Positionen fortzufahren.');
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$current = (int) $version->price_cents;
|
||||
|
||||
if ($holder !== null && ! $this->suitsHolder($version, $holder)) {
|
||||
$lines[] = new CartLine($offer, $version, CartLine::WRONG_HOLDER, $seen, $current,
|
||||
$version->holder_kind === 'organisation'
|
||||
? 'Diese Option ist für Organisationen. Bestelle als Verein oder entferne sie.'
|
||||
: 'Diese Option ist für Privatpersonen. Bestelle als Privatperson oder entferne sie.');
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($holder !== null && $this->ownership->covers($holder, $version)) {
|
||||
$lines[] = new CartLine($offer, $version, CartLine::OWNED, $seen, $current);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($current !== $seen) {
|
||||
$lines[] = new CartLine($offer, $version, CartLine::PRICE_CHANGED, $seen, $current);
|
||||
} elseif ((int) $item['version_id'] !== $version->id) {
|
||||
$lines[] = new CartLine($offer, $version, CartLine::TERMS_CHANGED, $seen, $current,
|
||||
'Die Bedingungen dieser Option wurden aktualisiert. Bitte prüfe die Übersicht.');
|
||||
} else {
|
||||
$lines[] = new CartLine($offer, $version, CartLine::OK, $seen, $current);
|
||||
}
|
||||
}
|
||||
|
||||
return new CartReview($lines, $holder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Die aktive, als Kauf angebotene Fassung der Option; sonst null (nicht kaufbar oder zurückgezogen).
|
||||
*/
|
||||
public function purchasable(Offer $offer): ?OfferVersion
|
||||
{
|
||||
return $this->offers->purchasableVersion($offer);
|
||||
}
|
||||
|
||||
private function put(Offer $offer, OfferVersion $version): void
|
||||
{
|
||||
$items = $this->items();
|
||||
$items[$offer->id] = ['version_id' => $version->id, 'price_cents' => (int) $version->price_cents];
|
||||
session()->put(self::KEY, $items);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, OfferVersion|null> $versions
|
||||
*/
|
||||
private function holderFor(User $user, ?int $partyId, array $versions): ?Party
|
||||
{
|
||||
$onlyOrganisations = $versions !== [] && collect($versions)
|
||||
->filter()
|
||||
->every(fn (OfferVersion $version): bool => $version->holder_kind === 'organisation');
|
||||
|
||||
try {
|
||||
return $this->holders->resolve($user, $partyId, $onlyOrganisations);
|
||||
} catch (DomainRuleException) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function suitsHolder(OfferVersion $version, Party $holder): bool
|
||||
{
|
||||
return ($version->holder_kind === 'organisation') === ($holder->type === PartyType::Organisation);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
|
||||
/**
|
||||
* Eine Position des Warenkorbs mit dem Ergebnis der serverseitigen Prüfung.
|
||||
*/
|
||||
final class CartLine
|
||||
{
|
||||
public const OK = 'ok';
|
||||
|
||||
public const PRICE_CHANGED = 'preis_geaendert';
|
||||
|
||||
public const TERMS_CHANGED = 'bedingungen_geaendert';
|
||||
|
||||
public const WITHDRAWN = 'zurueckgezogen';
|
||||
|
||||
public const OWNED = 'bereits_erworben';
|
||||
|
||||
public const WRONG_HOLDER = 'falscher_inhaber';
|
||||
|
||||
public function __construct(
|
||||
public readonly Offer $offer,
|
||||
public readonly ?OfferVersion $version,
|
||||
public readonly string $state,
|
||||
public readonly int $seenPriceCents,
|
||||
public readonly ?int $currentPriceCents,
|
||||
public readonly ?string $note = null,
|
||||
) {}
|
||||
|
||||
/** Geht in Summe und Bestellung ein. */
|
||||
public function orderable(): bool
|
||||
{
|
||||
return in_array($this->state, [self::OK, self::PRICE_CHANGED, self::TERMS_CHANGED], true);
|
||||
}
|
||||
|
||||
/** Verhindert den Abschluss, bis der Käufer die Position selbst entfernt oder den Inhaber wechselt. */
|
||||
public function blocks(): bool
|
||||
{
|
||||
return in_array($this->state, [self::WITHDRAWN, self::WRONG_HOLDER], true);
|
||||
}
|
||||
|
||||
public function title(): string
|
||||
{
|
||||
$composition = $this->offer->composition;
|
||||
|
||||
return $composition !== null
|
||||
? (string) ($composition->display_title ?: $composition->designation)
|
||||
: (string) $this->offer->name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Identity\Party;
|
||||
|
||||
/**
|
||||
* Prüfergebnis des Warenkorbs für einen vorgesehenen Lizenzinhaber. Die Prüfsumme bindet die Bestellung an genau
|
||||
* diese Übersicht: Inhaber, Fassung und Preis jeder Position samt Zustand, auch der ausgeschlossenen.
|
||||
*/
|
||||
final class CartReview
|
||||
{
|
||||
/**
|
||||
* @param list<CartLine> $lines
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly array $lines,
|
||||
public readonly ?Party $holder,
|
||||
) {}
|
||||
|
||||
/** @return list<CartLine> */
|
||||
public function orderable(): array
|
||||
{
|
||||
return array_values(array_filter($this->lines, fn (CartLine $line): bool => $line->orderable()));
|
||||
}
|
||||
|
||||
public function totalCents(): int
|
||||
{
|
||||
return array_sum(array_map(fn (CartLine $line): int => (int) $line->currentPriceCents, $this->orderable()));
|
||||
}
|
||||
|
||||
public function blocked(): bool
|
||||
{
|
||||
foreach ($this->lines as $line) {
|
||||
if ($line->blocks()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function empty(): bool
|
||||
{
|
||||
return $this->orderable() === [];
|
||||
}
|
||||
|
||||
public function canOrder(): bool
|
||||
{
|
||||
return $this->holder !== null && ! $this->blocked() && ! $this->empty();
|
||||
}
|
||||
|
||||
public function digest(): string
|
||||
{
|
||||
$parts = [];
|
||||
|
||||
foreach ($this->lines as $line) {
|
||||
$parts[] = $line->offer->id.':'.($line->version?->id ?? 0).':'.$line->currentPriceCents.':'.$line->state;
|
||||
}
|
||||
|
||||
sort($parts);
|
||||
|
||||
return hash('sha256', ($this->holder?->id ?? 0).'|'.implode(',', $parts));
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,13 @@
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Entitlement\Acquisition;
|
||||
use App\Domain\Entitlement\AcquisitionType;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
use App\Domain\Identity\AccountStatus;
|
||||
use App\Domain\Identity\Party;
|
||||
use App\Mail\OrderConfirmed;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -20,13 +22,15 @@ class Checkout
|
||||
public function __construct(
|
||||
private readonly GrantIssuer $grants,
|
||||
private readonly OfferService $offers,
|
||||
private readonly OrderHolders $holders,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Einzelkauf einer Option als Person (bestehender Weg, ohne Warenkorb).
|
||||
*/
|
||||
public function place(User $user, Offer $offer): Order
|
||||
{
|
||||
if ($user->status !== AccountStatus::Aktiv || $user->party_id === null) {
|
||||
throw new DomainRuleException('Nur ein aktives Mitglied kann kaufen.');
|
||||
}
|
||||
$this->assertActive($user);
|
||||
|
||||
$version = $this->offers->currentActiveVersion($offer);
|
||||
|
||||
@@ -38,20 +42,78 @@ public function place(User $user, Offer $offer): Order
|
||||
throw new DomainRuleException('Der Kauf braucht einen Preis an der Angebotsfassung.');
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($user, $offer, $version): Order {
|
||||
$order = Order::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'party_id' => $user->party_id,
|
||||
'status' => 'offen',
|
||||
'holder_kind' => 'person',
|
||||
]);
|
||||
$holder = $this->holders->resolve($user, null);
|
||||
|
||||
return DB::transaction(fn (): Order => $this->createOrder($user, $holder, [[$offer, $version]]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Bestellung aus dem Warenkorb, erst nach serverseitiger Prüfung. Die Prüfsumme bindet die Bestellung an die
|
||||
* Übersicht, die der Käufer gesehen hat: Hat sich Preis, Fassung oder Bedingung seither geändert, entsteht keine
|
||||
* Bestellung und der Käufer sieht zuerst die aktualisierte Übersicht. Positionen, deren Umfang der Inhaber bereits
|
||||
* mit denselben Rechten besitzt, erzeugen keine Bestellposition.
|
||||
*/
|
||||
public function placeFromCart(User $user, Cart $cart, ?int $holderPartyId, string $digest): Order
|
||||
{
|
||||
$this->assertActive($user);
|
||||
|
||||
$order = DB::transaction(function () use ($user, $cart, $holderPartyId, $digest): Order {
|
||||
// Optionen sperren, damit eine gleichzeitige Aktivierung die Prüfung nicht unterläuft.
|
||||
Offer::query()->whereIn('id', array_keys($cart->items()))->orderBy('id')->lockForUpdate()->get();
|
||||
$review = $cart->review($user, $holderPartyId);
|
||||
|
||||
if ($review->holder === null) {
|
||||
throw new DomainRuleException('Für diesen Lizenzinhaber ist das Konto nicht bestellberechtigt.');
|
||||
}
|
||||
|
||||
if (! hash_equals($review->digest(), $digest)) {
|
||||
throw new StaleOverview('Die Übersicht hat sich geändert. Bitte prüfe die aktualisierte Bestellübersicht.');
|
||||
}
|
||||
|
||||
if ($review->blocked()) {
|
||||
throw new DomainRuleException('Entferne zuerst die Positionen, die nicht bestellt werden können.');
|
||||
}
|
||||
|
||||
if ($review->empty()) {
|
||||
throw new DomainRuleException('Es gibt nichts zu bestellen. Alle Positionen sind bereits erworben.');
|
||||
}
|
||||
|
||||
$pairs = array_map(fn (CartLine $line): array => [$line->offer, $line->version], $review->orderable());
|
||||
|
||||
return $this->createOrder($user, $review->holder, $pairs);
|
||||
});
|
||||
|
||||
$cart->clear();
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array{0: Offer, 1: OfferVersion}> $pairs
|
||||
*/
|
||||
private function createOrder(User $user, Party $holder, array $pairs): Order
|
||||
{
|
||||
$order = Order::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'party_id' => $holder->id,
|
||||
'status' => 'offen',
|
||||
'holder_kind' => $holder->type->value,
|
||||
'total_cents' => array_sum(array_map(fn (array $pair): int => (int) $pair[1]->price_cents, $pairs)),
|
||||
'currency' => 'EUR',
|
||||
]);
|
||||
|
||||
foreach ($pairs as [$offer, $version]) {
|
||||
$line = $order->lines()->create([
|
||||
'offer_version_id' => $version->id,
|
||||
'offer_name' => $offer->name,
|
||||
'price_cents' => $version->price_cents,
|
||||
'currency' => 'EUR',
|
||||
'term_rule' => $version->term_rule,
|
||||
'update_promise' => $version->update_promise,
|
||||
'holder_kind' => $version->holder_kind,
|
||||
'tax_class' => $version->tax_class,
|
||||
'grant_kind' => $version->grant_kind,
|
||||
'holder_party_id' => $holder->id,
|
||||
]);
|
||||
$version->load('resolvedScopes.rights');
|
||||
|
||||
@@ -66,14 +128,39 @@ public function place(User $user, Offer $offer): Order
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $order->load('lines.scopeItems');
|
||||
});
|
||||
return $order->load('lines.scopeItems');
|
||||
}
|
||||
|
||||
/**
|
||||
* Freischaltung nach bestätigter Testzahlung: alle Bestellpositionen aus ihrem festgehaltenen Umfang, in einer
|
||||
* Transaktion. Wiederholte Bestätigung ist wirkungslos; ein Fehler hinterlässt weder Zahlung noch Rechte.
|
||||
*/
|
||||
public function confirmTestPayment(Order $order, string $reference): Order
|
||||
{
|
||||
$this->assertTestDriver();
|
||||
|
||||
return $this->settle($order, 'test', $reference);
|
||||
}
|
||||
|
||||
/**
|
||||
* Zahlung eines Anbieters (Stripe): wie die Testzahlung, aber erst nach Prüfung von Betrag und Währung gegen die
|
||||
* Bestellung. Wiederholte Meldungen sind wirkungslos.
|
||||
*/
|
||||
public function confirmProviderPayment(Order $order, string $provider, string $reference, int $amountCents, string $currency): Order
|
||||
{
|
||||
$expected = (int) ($order->total_cents ?? $order->lines()->sum('price_cents'));
|
||||
|
||||
if ($amountCents !== $expected || strtoupper($currency) !== strtoupper((string) ($order->currency ?? 'EUR'))) {
|
||||
throw new DomainRuleException('Der gezahlte Betrag weicht von der Bestellung ab.');
|
||||
}
|
||||
|
||||
return $this->settle($order, $provider, $reference);
|
||||
}
|
||||
|
||||
private function settle(Order $order, string $provider, string $reference): Order
|
||||
{
|
||||
$reference = trim($reference);
|
||||
|
||||
if ($reference === '') {
|
||||
@@ -81,7 +168,7 @@ public function confirmTestPayment(Order $order, string $reference): Order
|
||||
}
|
||||
|
||||
$paidNow = false;
|
||||
$order = DB::transaction(function () use ($order, $reference, &$paidNow): Order {
|
||||
$order = DB::transaction(function () use ($order, $provider, $reference, &$paidNow): Order {
|
||||
$order = Order::query()->lockForUpdate()->findOrFail($order->id);
|
||||
|
||||
if ($order->status === 'bezahlt') {
|
||||
@@ -92,22 +179,20 @@ public function confirmTestPayment(Order $order, string $reference): Order
|
||||
throw new DomainRuleException('Diese Bestellung nimmt keine Zahlung mehr an.');
|
||||
}
|
||||
|
||||
$order->payments()->create([
|
||||
'provider' => 'test',
|
||||
'status' => 'bestaetigt',
|
||||
'provider_reference' => $reference,
|
||||
]);
|
||||
// Eine bei Stripe angelegte offene Zahlung mit derselben Referenz wird bestätigt statt doppelt geführt.
|
||||
$order->payments()->updateOrCreate(
|
||||
['provider_reference' => $reference],
|
||||
['provider' => $provider, 'status' => 'bestaetigt'],
|
||||
);
|
||||
$order->status = 'bezahlt';
|
||||
$order->save();
|
||||
$paidNow = true;
|
||||
$line = $order->lines()->firstOrFail();
|
||||
$this->grants->issue(
|
||||
$order->user,
|
||||
$line->offerVersion,
|
||||
AcquisitionType::Bestellposition,
|
||||
'order_line',
|
||||
$line->id,
|
||||
);
|
||||
$actor = User::query()->findOrFail($order->user_id);
|
||||
|
||||
foreach ($order->lines()->orderBy('id')->get() as $line) {
|
||||
$holder = Party::query()->findOrFail($line->holder_party_id ?? $order->party_id);
|
||||
$this->grants->issueFromOrderLine($line, $holder, $actor);
|
||||
}
|
||||
|
||||
return $order->load('lines', 'payments');
|
||||
});
|
||||
@@ -142,6 +227,10 @@ public function failTestPayment(Order $order, string $reference): Order
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Vollerstattung: widerruft die Berechtigungen aller Positionen dieser Bestellung. Andere Erwerbsquellen
|
||||
* (kostenlose Vergabe, frühere Käufe) bleiben unberührt.
|
||||
*/
|
||||
public function refund(Order $order, string $reason): Order
|
||||
{
|
||||
$reason = trim($reason);
|
||||
@@ -157,15 +246,14 @@ public function refund(Order $order, string $reason): Order
|
||||
throw new DomainRuleException('Nur eine bezahlte Bestellung kann erstattet werden.');
|
||||
}
|
||||
|
||||
$line = $order->lines()->firstOrFail();
|
||||
$acquisition = Acquisition::query()->where([
|
||||
'type' => AcquisitionType::Bestellposition,
|
||||
'reference_type' => 'order_line',
|
||||
'reference_id' => $line->id,
|
||||
])->first();
|
||||
foreach ($order->lines()->orderBy('id')->get() as $line) {
|
||||
$acquisition = Acquisition::query()->where([
|
||||
'type' => AcquisitionType::Bestellposition,
|
||||
'reference_type' => 'order_line',
|
||||
'reference_id' => $line->id,
|
||||
])->first();
|
||||
|
||||
if ($acquisition !== null) {
|
||||
foreach ($acquisition->grants as $grant) {
|
||||
foreach ($acquisition?->grants ?? [] as $grant) {
|
||||
if ($grant->status === GrantStatus::Aktiv) {
|
||||
$grant->status = GrantStatus::Widerrufen;
|
||||
$grant->status_reason = $reason;
|
||||
@@ -182,6 +270,13 @@ public function refund(Order $order, string $reason): Order
|
||||
});
|
||||
}
|
||||
|
||||
private function assertActive(User $user): void
|
||||
{
|
||||
if ($user->status !== AccountStatus::Aktiv || $user->party_id === null) {
|
||||
throw new DomainRuleException('Nur ein aktives Mitglied kann kaufen.');
|
||||
}
|
||||
}
|
||||
|
||||
private function assertTestDriver(): void
|
||||
{
|
||||
if (app()->isProduction() || config('services.payment.driver') !== 'test') {
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
|
||||
/**
|
||||
* Beträge werden als ganze Cent gespeichert und in Euro angezeigt und eingegeben (deutsches Format).
|
||||
*/
|
||||
final class Money
|
||||
{
|
||||
/** Obergrenze eines Preises (1.000.000 €), weit unter dem Wertebereich der Datenbank. */
|
||||
public const MAX_CENTS = 100_000_000;
|
||||
|
||||
public static function format(?int $cents): string
|
||||
{
|
||||
return $cents === null ? '–' : number_format($cents / 100, 2, ',', '.').' €';
|
||||
}
|
||||
|
||||
/**
|
||||
* Euro-Eingabe („12,50“, „1.299“, „5“) als Cent. Leere Eingabe ergibt null.
|
||||
*/
|
||||
public static function parse(string|int|float|null $input): ?int
|
||||
{
|
||||
if ($input === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$text = trim((string) $input);
|
||||
|
||||
if ($text === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
$text = str_replace([' ', '€'], '', $text);
|
||||
|
||||
if (str_contains($text, ',')) {
|
||||
$text = str_replace('.', '', $text);
|
||||
$text = str_replace(',', '.', $text);
|
||||
} elseif (preg_match('/^\d{1,3}(\.\d{3})+$/', $text) === 1) {
|
||||
$text = str_replace('.', '', $text);
|
||||
}
|
||||
|
||||
if (preg_match('/^\d+(\.\d{1,2})?$/', $text) !== 1) {
|
||||
throw new DomainRuleException('Der Preis ist kein gültiger Eurobetrag, zum Beispiel 12,50.');
|
||||
}
|
||||
|
||||
$cents = (int) round(((float) $text) * 100);
|
||||
|
||||
if ($cents > self::MAX_CENTS) {
|
||||
throw new DomainRuleException('Der Preis ist zu hoch. Zulässig sind höchstens '.self::format(self::MAX_CENTS).'.');
|
||||
}
|
||||
|
||||
return $cents;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ class Order extends Model
|
||||
'party_id',
|
||||
'status',
|
||||
'holder_kind',
|
||||
'total_cents',
|
||||
'currency',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Identity\Membership;
|
||||
use App\Domain\Identity\Party;
|
||||
use App\Domain\Identity\PartyType;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Für wen ein Konto bestellen darf: für sich selbst (Person) und für Organisationen, bei denen es eine aktive
|
||||
* Mitgliedschaft mit Bestellberechtigung hat. Eine Bestellung hat genau einen Lizenzinhaber.
|
||||
*/
|
||||
class OrderHolders
|
||||
{
|
||||
/**
|
||||
* @return Collection<int, Party>
|
||||
*/
|
||||
public function for(User $user): Collection
|
||||
{
|
||||
$holders = collect();
|
||||
|
||||
if ($user->party_id !== null) {
|
||||
$person = Party::query()->find($user->party_id);
|
||||
|
||||
if ($person !== null) {
|
||||
$holders->push($person);
|
||||
}
|
||||
}
|
||||
|
||||
$organisations = Membership::query()
|
||||
->active()
|
||||
->where('user_id', $user->id)
|
||||
->where('may_order', true)
|
||||
->with('organisation')
|
||||
->orderBy('id')
|
||||
->get()
|
||||
->map(fn (Membership $membership): ?Party => $membership->organisation)
|
||||
->filter(fn (?Party $party): bool => $party !== null && $party->type === PartyType::Organisation);
|
||||
|
||||
return $holders->concat($organisations)->values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Der gewählte Inhaber; ohne Wahl die Person, bei Angeboten nur für Organisationen die erste Organisation.
|
||||
*/
|
||||
public function resolve(User $user, ?int $partyId, bool $preferOrganisation = false): Party
|
||||
{
|
||||
$holders = $this->for($user);
|
||||
|
||||
if ($partyId !== null) {
|
||||
$chosen = $holders->first(fn (Party $party): bool => $party->id === $partyId);
|
||||
|
||||
if ($chosen === null) {
|
||||
throw new DomainRuleException('Für diesen Lizenzinhaber ist das Konto nicht bestellberechtigt.');
|
||||
}
|
||||
|
||||
return $chosen;
|
||||
}
|
||||
|
||||
if ($preferOrganisation) {
|
||||
$organisation = $holders->first(fn (Party $party): bool => $party->type === PartyType::Organisation);
|
||||
|
||||
if ($organisation !== null) {
|
||||
return $organisation;
|
||||
}
|
||||
}
|
||||
|
||||
$person = $holders->first(fn (Party $party): bool => $party->type === PartyType::Person);
|
||||
|
||||
return $person ?? throw new DomainRuleException('Nur ein aktives Mitglied kann kaufen.');
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Identity\Party;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
@@ -17,6 +18,10 @@ class OrderLine extends Model
|
||||
'term_rule',
|
||||
'update_promise',
|
||||
'holder_kind',
|
||||
'currency',
|
||||
'tax_class',
|
||||
'grant_kind',
|
||||
'holder_party_id',
|
||||
];
|
||||
|
||||
public function order(): BelongsTo
|
||||
@@ -24,6 +29,11 @@ public function order(): BelongsTo
|
||||
return $this->belongsTo(Order::class);
|
||||
}
|
||||
|
||||
public function holder(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Party::class, 'holder_party_id');
|
||||
}
|
||||
|
||||
public function offerVersion(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(OfferVersion::class);
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
use App\Domain\Identity\Party;
|
||||
|
||||
/**
|
||||
* „Bereits erworben“ (FACH-59): Der vorgesehene Lizenzinhaber hat bereits eine gültige Lizenz mit demselben Umfang
|
||||
* und denselben Nutzungsrechten. Maßgeblich ist genau ein Erwerb, der jeden Umfangsposten der Angebotsfassung mit
|
||||
* gleichem Zweck, gleichen Fähigkeiten und gleichen Optionen trägt. Rechte mehrerer Erwerbe werden nicht zu einer
|
||||
* neuen Lizenz kombiniert. Alle Erwerbsarten zählen (Kauf, freier Abruf, manuelle Vergabe), sofern aktiv und gültig.
|
||||
*/
|
||||
class OwnershipCheck
|
||||
{
|
||||
public function covers(Party $holder, OfferVersion $version): bool
|
||||
{
|
||||
$needed = $this->needed($version);
|
||||
|
||||
if ($needed === []) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$now = now();
|
||||
$byAcquisition = Grant::query()
|
||||
->where('status', GrantStatus::Aktiv)
|
||||
->whereHas('acquisition', fn ($query) => $query->where('party_id', $holder->id))
|
||||
->get()
|
||||
->filter(fn (Grant $grant): bool => ($grant->valid_from === null || ! $grant->valid_from->greaterThan($now))
|
||||
&& ($grant->valid_until === null || $grant->valid_until->greaterThan($now)))
|
||||
->groupBy('acquisition_id');
|
||||
|
||||
foreach ($byAcquisition as $grants) {
|
||||
$have = [];
|
||||
|
||||
foreach ($grants as $grant) {
|
||||
$have[$grant->license_article_id.'|'.$this->fingerprint($grant->rights_snapshot ?? [])] = true;
|
||||
}
|
||||
|
||||
if (array_diff_key($needed, $have) === []) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, true>
|
||||
*/
|
||||
private function needed(OfferVersion $version): array
|
||||
{
|
||||
$needed = [];
|
||||
$version->loadMissing('resolvedScopes.rights');
|
||||
|
||||
foreach ($version->resolvedScopes as $scope) {
|
||||
$needed[$scope->license_article_id.'|'.$this->fingerprint([
|
||||
'purpose' => $scope->rights->purpose,
|
||||
'capabilities' => $scope->rights->capabilities,
|
||||
'options' => $scope->rights->options ?? [],
|
||||
])] = true;
|
||||
}
|
||||
|
||||
return $needed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reihenfolge von Schlüsseln und Aktionen spielt keine Rolle.
|
||||
*
|
||||
* @param array<string, mixed> $rights
|
||||
*/
|
||||
private function fingerprint(array $rights): string
|
||||
{
|
||||
$capabilities = [];
|
||||
|
||||
foreach ((array) ($rights['capabilities'] ?? []) as $class => $actions) {
|
||||
$actions = array_values(array_unique((array) $actions));
|
||||
sort($actions);
|
||||
$capabilities[(string) $class] = $actions;
|
||||
}
|
||||
|
||||
ksort($capabilities);
|
||||
$options = (array) ($rights['options'] ?? []);
|
||||
ksort($options);
|
||||
|
||||
return md5(json_encode([
|
||||
'purpose' => (string) ($rights['purpose'] ?? ''),
|
||||
'capabilities' => $capabilities,
|
||||
'options' => $options,
|
||||
], JSON_THROW_ON_ERROR));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\EditorialProfileReader;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Filament\Support\CatalogLabels;
|
||||
|
||||
/**
|
||||
* Kaufbare Lizenzoptionen einer Produktseite aus dem veröffentlichten Katalog: aktive Angebotsfassungen mit Preis,
|
||||
* Eignung, Laufzeit, Umfang und Nutzungsrechten. Die Seite selbst (Titel, Beschreibung, Struktur) kommt aus der
|
||||
* zur Anzeige freigegebenen Komposition; hier entsteht kein zweiter Text.
|
||||
*/
|
||||
class ProductOptions
|
||||
{
|
||||
public function __construct(private readonly OfferService $offers) {}
|
||||
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function forComposition(Composition $composition): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (Offer::query()->where('composition_id', $composition->id)->orderBy('id')->get() as $offer) {
|
||||
$version = $this->offers->purchasableVersion($offer);
|
||||
|
||||
if ($version !== null) {
|
||||
$options[] = $this->describe($offer, $version);
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zeilen für Shop-Suche und Kacheln: je Komposition die günstigste Option.
|
||||
*
|
||||
* @return array<int, array{from_cents: int, count: int}>
|
||||
*/
|
||||
public function summaries(): array
|
||||
{
|
||||
$summary = [];
|
||||
|
||||
foreach (Offer::query()->whereNotNull('composition_id')->orderBy('id')->get() as $offer) {
|
||||
$version = $this->offers->purchasableVersion($offer);
|
||||
|
||||
if ($version === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$current = $summary[$offer->composition_id] ?? ['from_cents' => PHP_INT_MAX, 'count' => 0];
|
||||
$summary[$offer->composition_id] = [
|
||||
'from_cents' => min($current['from_cents'], (int) $version->price_cents),
|
||||
'count' => $current['count'] + 1,
|
||||
];
|
||||
}
|
||||
|
||||
return $summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function describe(Offer $offer, OfferVersion $version): array
|
||||
{
|
||||
$version->loadMissing('resolvedScopes.article', 'resolvedScopes.rights');
|
||||
$scope = [];
|
||||
|
||||
foreach ($version->resolvedScopes as $item) {
|
||||
$faehigkeiten = CatalogLabels::faehigkeiten($item->rights?->capabilities);
|
||||
$scope[] = [
|
||||
'article' => $this->articleTitle($item->article),
|
||||
'purpose' => CatalogLabels::zweck($item->rights?->purpose),
|
||||
'rights' => $faehigkeiten,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'offer' => $offer,
|
||||
'version' => $version,
|
||||
'name' => $offer->optionName(),
|
||||
'price_cents' => (int) $version->price_cents,
|
||||
'price' => Money::format((int) $version->price_cents),
|
||||
'for' => $version->holder_kind === 'organisation' ? 'Organisationen und Vereine' : 'Privatpersonen',
|
||||
'holder_kind' => $version->holder_kind,
|
||||
'term' => self::termLabel($version),
|
||||
'scope' => $scope,
|
||||
];
|
||||
}
|
||||
|
||||
public static function termLabel(OfferVersion $version): string
|
||||
{
|
||||
return match ($version->term_rule) {
|
||||
'dauerhaft' => 'Dauerhaft nutzbar',
|
||||
'befristet' => 'Befristet',
|
||||
'solange_angebot_aktiv' => 'Solange das Angebot aktiv ist',
|
||||
'periodisch' => 'Laufend, periodisch',
|
||||
default => (string) $version->term_rule,
|
||||
};
|
||||
}
|
||||
|
||||
public function articleTitle(?LicenseArticle $article): string
|
||||
{
|
||||
if ($article === null) {
|
||||
return '–';
|
||||
}
|
||||
|
||||
return $this->articleName($article) ?: (string) $article->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Name wie in der Redaktion: eigener Name, sonst der Name des Inhalts (Anzeigename, Arbeitstitel oder
|
||||
* Bezeichnung), sonst der eigene Arbeitstitel; leer, wenn nichts davon vorhanden ist.
|
||||
*/
|
||||
public function articleName(LicenseArticle $article): string
|
||||
{
|
||||
$profile = app(EditorialProfileReader::class)->read($article, 'detail');
|
||||
$source = $profile->source;
|
||||
$candidates = [
|
||||
$profile->value('display_title'),
|
||||
$article->working_title,
|
||||
$source?->getAttribute('working_title'),
|
||||
$source?->getAttribute('designation'),
|
||||
];
|
||||
|
||||
foreach ($candidates as $candidate) {
|
||||
if (filled($candidate)) {
|
||||
return trim((string) $candidate);
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
/**
|
||||
* Etappe 1 verwendet ausschließlich Testzahlung und erteilt keine Produktivfreigabe. Der Shop (Warenkorb, Kasse,
|
||||
* Kopflink) ist deshalb nur aktiv, wenn die Umgebung nicht Produktion ist und der Zahlungstreiber „test“ gilt.
|
||||
* Dieselbe Bedingung gilt für die Testzahlung der Bestellseite.
|
||||
*/
|
||||
final class Shop
|
||||
{
|
||||
public static function driver(): string
|
||||
{
|
||||
return (string) config('services.payment.driver');
|
||||
}
|
||||
|
||||
public static function enabled(): bool
|
||||
{
|
||||
return ! app()->isProduction() && in_array(self::driver(), ['test', 'stripe'], true);
|
||||
}
|
||||
|
||||
/** Stripe-Kasse (Etappe 1: nur Testmodus, nie in Produktion). */
|
||||
public static function stripe(): bool
|
||||
{
|
||||
return ! app()->isProduction() && self::driver() === 'stripe';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce;
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
|
||||
/**
|
||||
* Preis oder bindende Bedingungen haben sich nach Anzeige der Bestellübersicht geändert. Es entsteht keine
|
||||
* Bestellung; der Käufer sieht zuerst die aktualisierte Übersicht (FACH-59).
|
||||
*/
|
||||
class StaleOverview extends DomainRuleException {}
|
||||
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce\Stripe;
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Commerce\Order;
|
||||
use Illuminate\Http\Client\ConnectionException;
|
||||
use Illuminate\Http\Client\PendingRequest;
|
||||
use Illuminate\Http\Client\Response;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Stripe-Kasse (Checkout Session) für die Testzahlung in Etappe 1. Ausschließlich Testschlüssel: Ein Live-Schlüssel
|
||||
* oder die Produktionsumgebung werden abgewiesen, bevor ein Aufruf an Stripe geht. Bezahlt wird bei Stripe; Kartendaten
|
||||
* berühren diese Anwendung nie. Die Freischaltung erfolgt allein über die signierte Meldung (StripeWebhook).
|
||||
*/
|
||||
class StripeGateway
|
||||
{
|
||||
/**
|
||||
* Legt für die Bestellung eine Checkout Session an oder liefert die noch offene wieder.
|
||||
*
|
||||
* @return array{id: string, url: string}
|
||||
*/
|
||||
public function checkoutFor(Order $order): array
|
||||
{
|
||||
$this->assertSandbox();
|
||||
$order->loadMissing('lines', 'user');
|
||||
$taxRate = $this->taxRate();
|
||||
|
||||
if ($order->status !== 'offen') {
|
||||
throw new DomainRuleException('Diese Bestellung nimmt keine Zahlung mehr an.');
|
||||
}
|
||||
|
||||
$open = $this->reusableSession($order);
|
||||
|
||||
if ($open !== null) {
|
||||
return $open;
|
||||
}
|
||||
|
||||
$attempt = $order->payments()->where('provider', 'stripe')->count() + 1;
|
||||
$params = [
|
||||
'mode' => 'payment',
|
||||
'client_reference_id' => (string) $order->id,
|
||||
'customer_email' => $order->user->email,
|
||||
'locale' => 'de',
|
||||
'success_url' => route('member.order', $order).'?zahlung=zurueck',
|
||||
'cancel_url' => route('member.order', $order).'?zahlung=abbruch',
|
||||
'metadata' => ['order_id' => (string) $order->id],
|
||||
'payment_intent_data' => ['metadata' => ['order_id' => (string) $order->id]],
|
||||
];
|
||||
|
||||
foreach ($order->lines->values() as $index => $line) {
|
||||
$params['line_items'][$index] = [
|
||||
'quantity' => 1,
|
||||
'price_data' => [
|
||||
'currency' => strtolower((string) ($line->currency ?? $order->currency ?? 'EUR')),
|
||||
'unit_amount' => (int) $line->price_cents,
|
||||
'product_data' => ['name' => filled($line->offer_name) ? (string) $line->offer_name : 'Lizenz'],
|
||||
],
|
||||
];
|
||||
|
||||
if ($taxRate !== null) {
|
||||
$params['line_items'][$index]['tax_rates'] = [$taxRate];
|
||||
}
|
||||
}
|
||||
|
||||
$response = $this->request()
|
||||
->withHeaders(['Idempotency-Key' => $this->idempotencyKey($order, $attempt, $params)])
|
||||
->post('/v1/checkout/sessions', $params);
|
||||
|
||||
$this->assertOk($response, 'angelegt');
|
||||
$id = (string) $response->json('id');
|
||||
$url = (string) $response->json('url');
|
||||
|
||||
if ($id === '' || $url === '') {
|
||||
throw new DomainRuleException('Stripe hat keine Kasse geliefert. Bitte versuche es später noch einmal.');
|
||||
}
|
||||
|
||||
$order->payments()->create(['provider' => 'stripe', 'status' => 'offen', 'provider_reference' => $id]);
|
||||
|
||||
return ['id' => $id, 'url' => $url];
|
||||
}
|
||||
|
||||
public function assertSandbox(): void
|
||||
{
|
||||
$secret = (string) config('services.stripe.secret');
|
||||
|
||||
if (app()->isProduction()) {
|
||||
throw new DomainRuleException('Stripe ist in Produktion nicht freigegeben.');
|
||||
}
|
||||
|
||||
if ($secret === '') {
|
||||
throw new DomainRuleException('Stripe ist nicht eingerichtet: Der Schlüssel fehlt.');
|
||||
}
|
||||
|
||||
if (! str_starts_with($secret, 'sk_test_') && ! str_starts_with($secret, 'rk_test_')) {
|
||||
throw new DomainRuleException('Etappe 1 erlaubt nur den Stripe-Testmodus (Schlüssel sk_test_).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stripe bindet einen Schlüssel an die Parameter der ersten Anfrage und lehnt dieselbe Kennung mit anderen
|
||||
* Parametern ab. Der Schlüssel enthält deshalb einen Fingerabdruck der Parameter und die Minute: Ein
|
||||
* doppelter Klick bleibt wirkungslos, eine geänderte Anfrage oder ein Neuversuch nach einer Korrektur nicht.
|
||||
*
|
||||
* @param array<string, mixed> $params
|
||||
*/
|
||||
private function idempotencyKey(Order $order, int $attempt, array $params): string
|
||||
{
|
||||
$fingerprint = substr(sha1(json_encode([$params, now()->format('YmdHi')], JSON_THROW_ON_ERROR)), 0, 12);
|
||||
|
||||
return 'luf-order-'.$order->id.'-'.$attempt.'-'.$fingerprint;
|
||||
}
|
||||
|
||||
/** Konfigurierter Steuersatz oder null; eine ungültige ID wird abgewiesen, statt geraten zu werden. */
|
||||
private function taxRate(): ?string
|
||||
{
|
||||
$id = trim((string) config('services.stripe.tax_rate'));
|
||||
|
||||
if ($id === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! preg_match('/^txr_[A-Za-z0-9]+$/', $id)) {
|
||||
throw new DomainRuleException('Die Steuersatz-ID für Stripe ist ungültig (erwartet txr_...).');
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{id: string, url: string}|null
|
||||
*/
|
||||
private function reusableSession(Order $order): ?array
|
||||
{
|
||||
$payment = $order->payments()->where('provider', 'stripe')->where('status', 'offen')->latest('id')->first();
|
||||
|
||||
if ($payment === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$response = $this->request()->get('/v1/checkout/sessions/'.$payment->provider_reference);
|
||||
} catch (ConnectionException) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($response->successful() && $response->json('status') === 'open' && filled($response->json('url'))) {
|
||||
return ['id' => (string) $payment->provider_reference, 'url' => (string) $response->json('url')];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function request(): PendingRequest
|
||||
{
|
||||
return Http::baseUrl(rtrim((string) config('services.stripe.api_base'), '/'))
|
||||
->withToken((string) config('services.stripe.secret'))
|
||||
->asForm()
|
||||
->acceptJson()
|
||||
->timeout(15);
|
||||
}
|
||||
|
||||
private function assertOk(Response $response, string $what): void
|
||||
{
|
||||
if ($response->successful()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Statuscode, Fehlertyp, Code, betroffener Parameter und Begründung von Stripe, damit die Ursache lesbar ist.
|
||||
// Nie Schlüssel oder Kundendaten; die Begründung wird gekürzt.
|
||||
Log::warning('Stripe-Anfrage fehlgeschlagen', [
|
||||
'status' => $response->status(),
|
||||
'type' => $response->json('error.type'),
|
||||
'code' => $response->json('error.code'),
|
||||
'param' => $response->json('error.param'),
|
||||
'message' => mb_substr((string) $response->json('error.message'), 0, 300),
|
||||
]);
|
||||
|
||||
throw new DomainRuleException('Die Zahlung konnte bei Stripe nicht '.$what.' werden. Bitte versuche es später noch einmal.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Commerce\Stripe;
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
|
||||
/**
|
||||
* Prüft die Signatur einer Stripe-Meldung (Header „Stripe-Signature“: t=Zeit, v1=HMAC-SHA256 über „t.Nutzlast“).
|
||||
* Eine Meldung ohne gültige Signatur oder außerhalb der Zeittoleranz wird abgewiesen.
|
||||
*/
|
||||
class StripeSignature
|
||||
{
|
||||
public const TOLERANCE_SECONDS = 300;
|
||||
|
||||
public function verify(string $payload, ?string $header, ?int $now = null): void
|
||||
{
|
||||
$secret = (string) config('services.stripe.webhook_secret');
|
||||
|
||||
if ($secret === '') {
|
||||
throw new DomainRuleException('Das Webhook-Geheimnis ist nicht eingerichtet.');
|
||||
}
|
||||
|
||||
if ($header === null || trim($header) === '') {
|
||||
throw new DomainRuleException('Die Signatur fehlt.');
|
||||
}
|
||||
|
||||
$timestamp = null;
|
||||
$signatures = [];
|
||||
|
||||
foreach (explode(',', $header) as $part) {
|
||||
[$key, $value] = array_pad(explode('=', trim($part), 2), 2, '');
|
||||
|
||||
if ($key === 't') {
|
||||
$timestamp = ctype_digit($value) ? (int) $value : null;
|
||||
} elseif ($key === 'v1' && $value !== '') {
|
||||
$signatures[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
if ($timestamp === null || $signatures === []) {
|
||||
throw new DomainRuleException('Die Signatur ist unvollständig.');
|
||||
}
|
||||
|
||||
$expected = hash_hmac('sha256', $timestamp.'.'.$payload, $secret);
|
||||
$valid = false;
|
||||
|
||||
foreach ($signatures as $signature) {
|
||||
$valid = hash_equals($expected, $signature) || $valid;
|
||||
}
|
||||
|
||||
if (! $valid) {
|
||||
throw new DomainRuleException('Die Signatur stimmt nicht.');
|
||||
}
|
||||
|
||||
if (abs(($now ?? now()->getTimestamp()) - $timestamp) > self::TOLERANCE_SECONDS) {
|
||||
throw new DomainRuleException('Die Meldung ist zu alt.');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ class Acquisition extends Model
|
||||
'reference_type',
|
||||
'reference_id',
|
||||
'conditions',
|
||||
'acting_user_id',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
|
||||
@@ -47,7 +47,7 @@ public function __invoke(
|
||||
$candidates = Grant::query()
|
||||
->where('license_article_id', $article->id)
|
||||
->where('status', GrantStatus::Aktiv)
|
||||
->whereHas('acquisition', fn ($query) => $query->where('party_id', $user->party_id))
|
||||
->usableBy($user)
|
||||
->get()
|
||||
->filter(function (Grant $grant) use ($now): bool {
|
||||
if ($grant->valid_from !== null && $grant->valid_from->greaterThan($now)) {
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Identity\Membership;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
@@ -32,6 +35,32 @@ protected function casts(): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Berechtigungen, die ein Konto nutzen darf (zentrale Regel für Entscheidung, Bibliothek und Vorschaubilder):
|
||||
* - persönliche Erwerbe: Inhaber ist die Person des Kontos;
|
||||
* - Erwerbe einer Organisation: nur das auslösende Konto und nur, solange seine Mitgliedschaft mit
|
||||
* Bestellberechtigung besteht (Etappe 1, Domänenmodell 04; Sitzpools folgen mit A4).
|
||||
*
|
||||
* @param Builder<Grant> $query
|
||||
* @return Builder<Grant>
|
||||
*/
|
||||
public function scopeUsableBy(Builder $query, User $user): Builder
|
||||
{
|
||||
return $query->whereHas('acquisition', function (Builder $acquisition) use ($user): void {
|
||||
$acquisition->where(function (Builder $either) use ($user): void {
|
||||
$either->where('party_id', $user->party_id)
|
||||
->orWhere(function (Builder $organisation) use ($user): void {
|
||||
$organisation->where('acting_user_id', $user->id)
|
||||
->whereIn('party_id', Membership::query()
|
||||
->active()
|
||||
->where('user_id', $user->id)
|
||||
->where('may_order', true)
|
||||
->select('party_id'));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public function acquisition(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Acquisition::class);
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Commerce\OrderLine;
|
||||
use App\Domain\Identity\Party;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
@@ -69,6 +71,56 @@ public function grantManually(User $user, Offer $offer, User $actor, string $rea
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Freischaltung einer bezahlten Bestellposition aus deren festgehaltenem Umfang (Umfangskopie und Bedingungen der
|
||||
* Position, nicht aus der Angebotsfassung). Inhaber ist der Lizenzinhaber der Position, das auslösende Konto wird
|
||||
* am Erwerb festgehalten. Wiederholsicher: je Bestellposition genau ein Erwerb.
|
||||
*/
|
||||
public function issueFromOrderLine(OrderLine $line, Party $holder, User $actor): Acquisition
|
||||
{
|
||||
return DB::transaction(function () use ($line, $holder, $actor): Acquisition {
|
||||
$existing = Acquisition::query()->where([
|
||||
'party_id' => $holder->id,
|
||||
'type' => AcquisitionType::Bestellposition,
|
||||
'reference_type' => 'order_line',
|
||||
'reference_id' => $line->id,
|
||||
])->first();
|
||||
|
||||
if ($existing !== null) {
|
||||
return $existing->load('grants');
|
||||
}
|
||||
|
||||
$acquisition = Acquisition::query()->create([
|
||||
'party_id' => $holder->id,
|
||||
'type' => AcquisitionType::Bestellposition,
|
||||
'reference_type' => 'order_line',
|
||||
'reference_id' => $line->id,
|
||||
'acting_user_id' => $actor->id,
|
||||
'conditions' => [
|
||||
'term_rule' => $line->term_rule,
|
||||
'update_promise' => $line->update_promise,
|
||||
'holder_kind' => $line->holder_kind,
|
||||
'offer_version_id' => $line->offer_version_id,
|
||||
],
|
||||
]);
|
||||
|
||||
$line->loadMissing('scopeItems.article');
|
||||
|
||||
foreach ($line->scopeItems as $item) {
|
||||
$acquisition->grants()->create([
|
||||
'license_article_id' => $item->license_article_id,
|
||||
'rights_profile_version_id' => $item->rights_profile_version_id,
|
||||
'rights_snapshot' => $item->rights_snapshot,
|
||||
'release_at_grant_id' => $item->article?->current_release_id,
|
||||
'status' => GrantStatus::Aktiv,
|
||||
'valid_from' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
return $acquisition->load('grants');
|
||||
});
|
||||
}
|
||||
|
||||
public function issue(
|
||||
User $user,
|
||||
OfferVersion $version,
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Identity;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Mitgliedschaft eines Kontos in einer Organisation (Domänenmodell 04, MEMBERSHIP). Etappe 1 nutzt sie für die
|
||||
* Bestellberechtigung: Ein Konto bestellt nur für eine Organisation, bei der eine aktive Mitgliedschaft mit
|
||||
* `may_order` besteht. Sitzpools und Selbstverwaltung folgen mit A4.
|
||||
*/
|
||||
class Membership extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'party_id',
|
||||
'role',
|
||||
'may_order',
|
||||
'valid_from',
|
||||
'valid_until',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'may_order' => 'boolean',
|
||||
'valid_from' => 'date',
|
||||
'valid_until' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function organisation(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Party::class, 'party_id');
|
||||
}
|
||||
|
||||
/** Mitgliedschaften, die heute gelten. */
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query
|
||||
->where(fn (Builder $inner) => $inner->whereNull('valid_from')->orWhereDate('valid_from', '<=', now()))
|
||||
->where(fn (Builder $inner) => $inner->whereNull('valid_until')->orWhereDate('valid_until', '>=', now()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Übernimmt das Vorschaubild eines Programms oder Moduls als gewöhnliches Bild-Medium im Medienmanager
|
||||
* (Programm- und Modulkarte), nach demselben Prinzip wie FilmStill.
|
||||
*
|
||||
* - Ausdrückliche Handlung der Redaktion. Das Vorschaubild ist ein geschütztes Bibliotheksbild; erst die Übernahme
|
||||
* legt ein Medium an, das für die Website freigegeben werden kann (WebsiteIntake, Warteschlange).
|
||||
* - Die Datei wird einmal kopiert. Dieselbe Vorschaudatei ergibt dasselbe Medium (composition_still_sources).
|
||||
* - Es entsteht keine Fassung, keine Berechtigung, kein Lizenzartikel.
|
||||
*/
|
||||
class CompositionStill
|
||||
{
|
||||
/** Wahr, wenn der letzte Aufruf ein schon vorhandenes Bild geliefert hat. */
|
||||
public bool $reused = false;
|
||||
|
||||
public function __construct(private readonly WebsiteIntake $intake) {}
|
||||
|
||||
public function refusal(Composition $composition): ?string
|
||||
{
|
||||
if ($composition->archived_at !== null) {
|
||||
return 'Das Programm oder Modul ist archiviert.';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function hasThumbnail(Composition $composition): bool
|
||||
{
|
||||
$path = $composition->thumbnail_path;
|
||||
|
||||
return is_string($path) && str_starts_with($path, 'vorschau/') && ! str_contains($path, '..')
|
||||
&& Storage::disk('media_derived')->exists($path);
|
||||
}
|
||||
|
||||
public function fromThumbnail(Composition $composition, ?User $actor = null): ContentElement
|
||||
{
|
||||
$this->reused = false;
|
||||
$refusal = $this->refusal($composition);
|
||||
|
||||
if ($refusal !== null) {
|
||||
throw new DomainRuleException($refusal);
|
||||
}
|
||||
|
||||
if (! $this->hasThumbnail($composition)) {
|
||||
throw new DomainRuleException('Dieses Programm oder Modul hat noch kein Vorschaubild. Setzen Sie es im Redaktionsmanager.');
|
||||
}
|
||||
|
||||
$bytes = Storage::disk('media_derived')->get((string) $composition->thumbnail_path);
|
||||
|
||||
if (! is_string($bytes) || $bytes === '') {
|
||||
throw new DomainRuleException('Das Vorschaubild ließ sich nicht lesen.');
|
||||
}
|
||||
|
||||
$key = 'file:'.hash('sha256', $bytes);
|
||||
$existing = $this->existing($composition, $key);
|
||||
|
||||
if ($existing instanceof ContentElement) {
|
||||
$this->reused = true;
|
||||
|
||||
return $existing;
|
||||
}
|
||||
|
||||
$title = (string) ($composition->display_title ?: $composition->designation);
|
||||
$path = 'cms/titelbild-'.$composition->id.'-'.Str::lower(Str::random(8)).'.jpg';
|
||||
Storage::disk('cms_incoming')->put($path, $bytes);
|
||||
|
||||
$still = $this->intake->acceptImage($path, 'Titelbild: '.$title, null, 'Titelbild zu „'.$title.'“', $actor);
|
||||
|
||||
try {
|
||||
CompositionStillSource::query()->updateOrCreate(
|
||||
['composition_id' => $composition->id, 'source_key' => $key],
|
||||
['still_element_id' => $still->id, 'actor_id' => $actor?->id],
|
||||
);
|
||||
} catch (QueryException) {
|
||||
return $this->existing($composition, $key) ?? $still;
|
||||
}
|
||||
|
||||
return $still;
|
||||
}
|
||||
|
||||
private function existing(Composition $composition, string $key): ?ContentElement
|
||||
{
|
||||
$source = CompositionStillSource::query()->with('still')->where('composition_id', $composition->id)->where('source_key', $key)->first();
|
||||
$still = $source?->still;
|
||||
|
||||
// Ein archiviertes oder bei der Verarbeitung gescheitertes Bild wird nicht wiederverwendet.
|
||||
return $still instanceof ContentElement && $still->archived_at === null && ! filled($still->thumbnail_error) ? $still : null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Herkunft eines Bild-Mediums aus dem Vorschaubild eines Programms oder Moduls (source_key file:{SHA-256}).
|
||||
*/
|
||||
class CompositionStillSource extends Model
|
||||
{
|
||||
protected $fillable = ['composition_id', 'still_element_id', 'source_key', 'actor_id'];
|
||||
|
||||
public function composition(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Composition::class);
|
||||
}
|
||||
|
||||
public function still(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ContentElement::class, 'still_element_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Legt ein Bild aus einem Film als gewöhnliches Bild-Medium im Medienmanager ab (Medien- und Materialkarte).
|
||||
*
|
||||
* - Die Stelle kommt aus der bereitgestellten Fassung, bei einem Film ohne solche Fassung (zum Beispiel ein Teaser nur
|
||||
* mit Website-Datei) aus der Website-Datei (`teaser/`, Herkunft `frame:0@Sekunde`).
|
||||
* - Zwei Wege: das Vorschaubild des Films übernehmen oder eine Stelle (Sekunde) wählen. Beides ist eine
|
||||
* ausdrückliche Handlung der Redaktion; erst dadurch entsteht ein Bild, das für die Website freigegeben werden kann.
|
||||
* - Das Bild wird einmal gezogen und gespeichert (WebsiteIntake legt es an, die Warteschlange leitet es ab und gibt
|
||||
* es frei). Seitenaufrufe lesen nur die gespeicherte Datei und starten nie ffmpeg.
|
||||
* - Dieselbe Stelle (oder dieselbe Vorschaudatei) ergibt dasselbe Medium (film_still_sources).
|
||||
* - Es wird nie der Film selbst, nur ein Einzelbild bis 1600 px Breite abgelegt. Traineranleitungen und
|
||||
* archivierte oder gesperrte Filme sind ausgeschlossen. Eine Rechte- oder Lizenzentscheidung entsteht nicht.
|
||||
*/
|
||||
class FilmStill
|
||||
{
|
||||
/** Breite eines übernommenen Standbilds; die kleine Filmstufe (640 px) wäre auf der Website sichtbar unscharf. */
|
||||
public const WIDTH = 1600;
|
||||
|
||||
/** Wahr, wenn der letzte Aufruf ein schon vorhandenes Bild geliefert hat (keine neue Extraktion). */
|
||||
public bool $reused = false;
|
||||
|
||||
public function __construct(
|
||||
private readonly ThumbnailDeriver $deriver,
|
||||
private readonly WebsiteIntake $intake,
|
||||
) {}
|
||||
|
||||
/** Grund, warum aus diesem Medium kein Standbild übernommen wird, sonst null. */
|
||||
public function refusal(ContentElement $film): ?string
|
||||
{
|
||||
if ($film->output_class !== 'film') {
|
||||
return 'Nur aus einem Film lässt sich ein Bild übernehmen.';
|
||||
}
|
||||
|
||||
if ($film->archived_at !== null) {
|
||||
return 'Der Film ist archiviert.';
|
||||
}
|
||||
|
||||
$slug = $film->editorialContentKind?->slug;
|
||||
|
||||
if (in_array($slug, PublicMaterialReader::CONFIDENTIAL_KINDS, true)) {
|
||||
return 'Aus Traineranleitungen werden keine Bilder für die Website übernommen.';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Die bereitgestellte Fassung, aus der Stellen gezogen werden (die höchste). */
|
||||
public function version(ContentElement $film): ?ContentElementVersion
|
||||
{
|
||||
return $film->versions()
|
||||
->where('status', ContentVersionStatus::Bereit->value)
|
||||
->orderByDesc('number')
|
||||
->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Website-Datei, aus der Stellen gezogen werden, wenn es keine bereitgestellte Fassung gibt (Film nur mit
|
||||
* Website-Datei). Sonst null.
|
||||
*/
|
||||
public function websiteFile(ContentElement $film): ?string
|
||||
{
|
||||
$path = $film->preview_path;
|
||||
|
||||
if ($this->version($film) instanceof ContentElementVersion
|
||||
|| ! is_string($path) || $path === '' || str_contains($path, '..') || ! str_starts_with($path, 'teaser/')
|
||||
|| ! Storage::disk('media_derived')->exists($path)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
/** Sekunde der Stelle, aus der das aktuelle Vorschaubild des Films stammt, sonst null. */
|
||||
public function thumbnailSecond(ContentElement $film): ?string
|
||||
{
|
||||
$source = $film->thumbnail_source;
|
||||
|
||||
return is_string($source) && preg_match('/^frame:\d+@([\d.]+)$/', $source, $match) === 1 ? $match[1] : null;
|
||||
}
|
||||
|
||||
public function fromSecond(ContentElement $film, float $seconds, ?User $actor = null): ContentElement
|
||||
{
|
||||
$this->reused = false;
|
||||
$this->guard($film);
|
||||
|
||||
if ($seconds < 0 || $seconds > 7200) {
|
||||
throw new DomainRuleException('Die Zeitposition liegt außerhalb des Films.');
|
||||
}
|
||||
|
||||
$version = $this->version($film);
|
||||
|
||||
if (! $version instanceof ContentElementVersion) {
|
||||
if ($this->websiteFile($film) !== null) {
|
||||
return $this->fromWebsiteFrame($film, $seconds, $actor);
|
||||
}
|
||||
|
||||
throw new DomainRuleException('Der Film hat weder eine bereitgestellte Fassung noch eine Website-Datei.');
|
||||
}
|
||||
|
||||
return $this->fromFrame($film, $version, $seconds, $actor);
|
||||
}
|
||||
|
||||
public function fromThumbnail(ContentElement $film, ?User $actor = null): ContentElement
|
||||
{
|
||||
$this->reused = false;
|
||||
$this->guard($film);
|
||||
|
||||
// Stammt das Vorschaubild aus einer Filmstelle, wird dieselbe Stelle in voller Auflösung gezogen.
|
||||
$second = $this->thumbnailSecond($film);
|
||||
|
||||
if ($second !== null && preg_match('/^frame:(\d+)@/', (string) $film->thumbnail_source, $match) === 1) {
|
||||
$version = ContentElementVersion::query()->find((int) $match[1]);
|
||||
|
||||
if ($version instanceof ContentElementVersion
|
||||
&& (int) $version->content_element_id === (int) $film->id
|
||||
&& $version->status !== ContentVersionStatus::Gesperrt) {
|
||||
try {
|
||||
return $this->fromFrame($film, $version, (float) $second, $actor);
|
||||
} catch (DomainRuleException) {
|
||||
// Die Stelle lässt sich nicht mehr ziehen: das gespeicherte Vorschaubild selbst übernehmen.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$path = $film->thumbnail_path;
|
||||
|
||||
if (! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..') || ! Storage::disk('media_derived')->exists($path)) {
|
||||
throw new DomainRuleException('Dieser Film hat noch kein Vorschaubild. Setzen Sie es im Medienmanager oder wählen Sie eine Stelle.');
|
||||
}
|
||||
|
||||
$bytes = Storage::disk('media_derived')->get($path);
|
||||
|
||||
if (! is_string($bytes) || $bytes === '') {
|
||||
throw new DomainRuleException('Das Vorschaubild ließ sich nicht lesen.');
|
||||
}
|
||||
|
||||
$key = 'file:'.hash('sha256', $bytes);
|
||||
$existing = $this->existing($film, $key);
|
||||
|
||||
if ($existing instanceof ContentElement) {
|
||||
$this->reused = true;
|
||||
|
||||
return $existing;
|
||||
}
|
||||
|
||||
return $this->store($film, $key, $bytes, 'Vorschaubild', $actor);
|
||||
}
|
||||
|
||||
private function fromFrame(ContentElement $film, ContentElementVersion $version, float $seconds, ?User $actor): ContentElement
|
||||
{
|
||||
$second = $this->secondText($seconds);
|
||||
$key = 'frame:'.$version->id.'@'.$second;
|
||||
$existing = $this->existing($film, $key);
|
||||
|
||||
if ($existing instanceof ContentElement) {
|
||||
$this->reused = true;
|
||||
|
||||
return $existing;
|
||||
}
|
||||
|
||||
$bytes = $this->deriver->frameJpeg($version, (float) $second, self::WIDTH, original: true);
|
||||
|
||||
if (! is_string($bytes)) {
|
||||
throw new DomainRuleException('Aus dieser Filmstelle ließ sich kein Bild erzeugen.');
|
||||
}
|
||||
|
||||
return $this->store($film, $key, $bytes, 'Fassung '.$version->number.', '.str_replace('.', ',', $second).' s', $actor);
|
||||
}
|
||||
|
||||
private function fromWebsiteFrame(ContentElement $film, float $seconds, ?User $actor): ContentElement
|
||||
{
|
||||
$second = $this->secondText($seconds);
|
||||
$key = 'frame:0@'.$second;
|
||||
$existing = $this->existing($film, $key);
|
||||
|
||||
if ($existing instanceof ContentElement) {
|
||||
$this->reused = true;
|
||||
|
||||
return $existing;
|
||||
}
|
||||
|
||||
$bytes = $this->deriver->websiteFileJpeg($film, (float) $second, self::WIDTH);
|
||||
|
||||
if (! is_string($bytes)) {
|
||||
throw new DomainRuleException('Aus dieser Stelle der Website-Datei ließ sich kein Bild erzeugen.');
|
||||
}
|
||||
|
||||
return $this->store($film, $key, $bytes, 'Website-Datei, '.str_replace('.', ',', $second).' s', $actor);
|
||||
}
|
||||
|
||||
private function guard(ContentElement $film): void
|
||||
{
|
||||
$refusal = $this->refusal($film);
|
||||
|
||||
if ($refusal !== null) {
|
||||
throw new DomainRuleException($refusal);
|
||||
}
|
||||
}
|
||||
|
||||
private function existing(ContentElement $film, string $key): ?ContentElement
|
||||
{
|
||||
$source = FilmStillSource::query()->with('still')->where('film_element_id', $film->id)->where('source_key', $key)->first();
|
||||
$still = $source?->still;
|
||||
|
||||
// Ein archiviertes oder an der Verarbeitung gescheitertes Bild wird nicht wiederverwendet; die Stelle kann neu
|
||||
// übernommen werden (store() ordnet dann das neue Bild zu).
|
||||
return $still instanceof ContentElement && $still->archived_at === null && ! filled($still->thumbnail_error) ? $still : null;
|
||||
}
|
||||
|
||||
private function store(ContentElement $film, string $key, string $bytes, string $label, ?User $actor): ContentElement
|
||||
{
|
||||
$title = (string) ($film->display_title ?: $film->working_title);
|
||||
$path = 'cms/standbild-'.$film->id.'-'.Str::lower(Str::random(8)).'.jpg';
|
||||
Storage::disk('cms_incoming')->put($path, $bytes);
|
||||
|
||||
$still = $this->intake->acceptImage(
|
||||
$path,
|
||||
'Standbild: '.$title.' ('.$label.')',
|
||||
filled($film->website_credit) ? (string) $film->website_credit : null,
|
||||
'Szene aus dem Film „'.$title.'“',
|
||||
$actor,
|
||||
);
|
||||
|
||||
try {
|
||||
FilmStillSource::query()->updateOrCreate(
|
||||
['film_element_id' => $film->id, 'source_key' => $key],
|
||||
['still_element_id' => $still->id, 'actor_id' => $actor?->id],
|
||||
);
|
||||
} catch (QueryException) {
|
||||
// Gleichzeitige Übernahme derselben Stelle: das zuerst angelegte Bild gilt.
|
||||
return $this->existing($film, $key) ?? $still;
|
||||
}
|
||||
|
||||
return $still;
|
||||
}
|
||||
|
||||
private function secondText(float $seconds): string
|
||||
{
|
||||
$text = number_format(max(0, min(7200, $seconds)), 3, '.', '');
|
||||
|
||||
return rtrim(rtrim($text, '0'), '.') ?: '0';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\Media;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Herkunft eines Standbilds: aus welchem Film und welcher Stelle (frame:{Fassung}@{Sekunde}) oder aus welcher Datei
|
||||
* (file:{SHA-256}) das Bild-Medium stammt.
|
||||
*/
|
||||
class FilmStillSource extends Model
|
||||
{
|
||||
protected $fillable = ['film_element_id', 'still_element_id', 'source_key', 'actor_id'];
|
||||
|
||||
public function film(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ContentElement::class, 'film_element_id');
|
||||
}
|
||||
|
||||
public function still(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ContentElement::class, 'still_element_id');
|
||||
}
|
||||
}
|
||||
@@ -4,39 +4,72 @@
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Jobs\StorePresentationFile;
|
||||
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.
|
||||
* Legt die technische Ableitung eines Präsentationsmediums (Website-Datei) an der Medienidentität ab.
|
||||
* Es entsteht keine Inhaltsfassung, keine Freigabe und keine Berechtigung. Eine vorhandene Inhaltsfassung bleibt
|
||||
* unverändert und geschützt; die Website-Datei ist eine eigene, bewusst gewählte Datei daneben.
|
||||
*
|
||||
* Der Web-Prozess hat `derived/` nur lesend. Er prüft deshalb nur und gibt das Kopieren an die Warteschlange
|
||||
* (`StorePresentationFile`, ruft `place()` auf).
|
||||
*/
|
||||
class PresentationFile
|
||||
{
|
||||
public function store(ContentElement $element, string $incoming): void
|
||||
/**
|
||||
* Dateiendungen, die ein Browser auf der Website abspielen kann.
|
||||
*
|
||||
* @var array<string, list<string>>
|
||||
*/
|
||||
public const EXTENSIONS = [
|
||||
'bild' => ['jpg', 'jpeg', 'png', 'webp', 'gif'],
|
||||
'audio' => ['mp3', 'm4a', 'ogg'],
|
||||
'film' => ['mp4', 'webm'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Prüft die Datei im Eingang, ohne etwas zu verändern. Wirft eine verständliche Regelverletzung.
|
||||
*/
|
||||
public function validate(string $outputClass, string $incoming): void
|
||||
{
|
||||
if (! in_array($element->output_class, ['bild', 'film', 'audio'], true)) {
|
||||
if (! isset(self::EXTENSIONS[$outputClass])) {
|
||||
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.');
|
||||
$extension = strtolower(pathinfo($incoming, PATHINFO_EXTENSION));
|
||||
|
||||
if (! in_array($extension, self::EXTENSIONS[$outputClass], true)) {
|
||||
throw new DomainRuleException(sprintf(
|
||||
'Für die Website geht nur %s. Eine %s-Datei kann der Browser nicht direkt abspielen; wandle sie vorher um oder lade sie ohne „Eigenständiges Präsentationsmedium“ hoch.',
|
||||
$this->formats($outputClass),
|
||||
$extension === '' ? 'Datei ohne Endung' : '.'.$extension,
|
||||
));
|
||||
}
|
||||
|
||||
if (! $this->readable($incoming)) {
|
||||
throw new DomainRuleException('Die Datei liegt nicht im Eingang.');
|
||||
}
|
||||
}
|
||||
|
||||
public function store(ContentElement $element, string $incoming): void
|
||||
{
|
||||
$this->validate((string) $element->output_class, $incoming);
|
||||
|
||||
$element->thumbnail_error = null;
|
||||
$element->save();
|
||||
|
||||
StorePresentationFile::dispatch($element->id, $incoming);
|
||||
}
|
||||
|
||||
/**
|
||||
* Kopiert die Datei nach `derived/`. Läuft nur in der Warteschlange, die dort schreiben darf.
|
||||
*/
|
||||
public function place(ContentElement $element, string $incoming): void
|
||||
{
|
||||
$this->validate((string) $element->output_class, $incoming);
|
||||
|
||||
$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);
|
||||
@@ -46,11 +79,15 @@ public function store(ContentElement $element, string $incoming): void
|
||||
}
|
||||
|
||||
try {
|
||||
Storage::disk('media_derived')->writeStream($target, $stream);
|
||||
$written = Storage::disk('media_derived')->writeStream($target, $stream);
|
||||
} finally {
|
||||
fclose($stream);
|
||||
}
|
||||
|
||||
if ($written === false) {
|
||||
throw new DomainRuleException('Die Datei ließ sich nicht ablegen.');
|
||||
}
|
||||
|
||||
if ($element->output_class === 'bild') {
|
||||
$element->thumbnail_path = $target;
|
||||
$element->thumbnail_source = 'eigen';
|
||||
@@ -58,7 +95,18 @@ public function store(ContentElement $element, string $incoming): void
|
||||
$element->preview_path = $target;
|
||||
}
|
||||
|
||||
$element->thumbnail_error = null;
|
||||
$element->save();
|
||||
Storage::disk('cms_incoming')->delete($incoming);
|
||||
}
|
||||
|
||||
public function formats(string $outputClass): string
|
||||
{
|
||||
return match ($outputClass) {
|
||||
'bild' => 'JPG, PNG, WebP oder GIF',
|
||||
'audio' => 'MP3, M4A oder OGG',
|
||||
default => 'MP4 (H.264) oder WebM',
|
||||
};
|
||||
}
|
||||
|
||||
private function readable(string $path): bool
|
||||
|
||||
@@ -87,6 +87,27 @@ public function forElementFrame(ContentElement $element, ContentElementVersion $
|
||||
$this->rememberElement($element, 'frame:'.$version->id.'@'.$this->secondText($seconds));
|
||||
}
|
||||
|
||||
/**
|
||||
* Vorschaubild aus einer Stelle der Website-Datei. Die Herkunft steht als `frame:0@{Sekunde}`; die 0 steht für die
|
||||
* Website-Datei (es gibt keine Fassung), alle Leser der Herkunft kommen damit zurecht.
|
||||
*/
|
||||
public function forElementWebsiteFrame(ContentElement $element, float $seconds): void
|
||||
{
|
||||
$bytes = $this->jpegAtWebsiteFile($element, $seconds);
|
||||
|
||||
if (! is_string($bytes)) {
|
||||
$this->fail($element, 'Aus dieser Filmstelle ließ sich kein Vorschaubild erzeugen.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$name = 'element-'.$element->id;
|
||||
$path = 'vorschau/'.$name.'.jpg';
|
||||
Storage::disk('media_derived')->put($path, $bytes);
|
||||
$this->still($element, Storage::disk('media_derived'), $path, $name);
|
||||
$this->rememberElement($element, 'frame:0@'.$this->secondText($seconds));
|
||||
}
|
||||
|
||||
public function forCompositionUpload(Composition $composition, string $incoming): void
|
||||
{
|
||||
if (! str_starts_with($incoming, 'vorschau/') || str_contains($incoming, '..')) {
|
||||
@@ -138,8 +159,20 @@ public function forCompositionFrame(Composition $composition, ContentElementVers
|
||||
$this->rememberChoice($composition, 'frame:'.$version->id.'@'.$this->secondText($seconds));
|
||||
}
|
||||
|
||||
public function frameInput(ContentElementVersion $version): ?string
|
||||
/**
|
||||
* Datei, aus der ein Bild gezogen wird. Vorgabe: die kleine Filmstufe (schnell, für die Vorschau). Mit $original
|
||||
* zuerst die Mediendatei selbst, damit ein übernommenes Standbild nicht aus der kleinen Stufe hochgerechnet wird.
|
||||
*/
|
||||
public function frameInput(ContentElementVersion $version, bool $original = false): ?string
|
||||
{
|
||||
if ($original) {
|
||||
$master = is_array($version->metadata) ? ($version->metadata['file'] ?? null) : null;
|
||||
|
||||
if ($this->readableDerived($master, 'inhalte/')) {
|
||||
return $master;
|
||||
}
|
||||
}
|
||||
|
||||
$proxy = MediaRendition::query()
|
||||
->where('content_element_version_id', $version->id)
|
||||
->where('role', 'variant')
|
||||
@@ -155,15 +188,55 @@ public function frameInput(ContentElementVersion $version): ?string
|
||||
return $this->readableDerived($file, 'inhalte/') ? $file : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Einzelbild einer Filmstelle als JPEG, 640 px breit aus der kleinen Stufe (Vorschau im Editor und Vorschaubild).
|
||||
*/
|
||||
public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?string
|
||||
{
|
||||
return $this->frameJpeg($version, $seconds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Einzelbild einer Filmstelle als JPEG. Ein übernommenes Standbild (FilmStill) wird mit $width und $original aus der
|
||||
* Mediendatei gezogen statt aus der kleinen Stufe und dabei nie über die Breite der Quelle hinaus vergrößert.
|
||||
*/
|
||||
public function frameJpeg(ContentElementVersion $version, float $seconds, int $width = 640, bool $original = false): ?string
|
||||
{
|
||||
if ($seconds < 0 || $seconds > 7200) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$file = $this->frameInput($version);
|
||||
$file = $this->frameInput($version, $original);
|
||||
|
||||
if ($file === null) {
|
||||
return $file === null ? null : $this->jpegFromFile($file, $seconds, $width);
|
||||
}
|
||||
|
||||
/**
|
||||
* Einzelbild aus der Website-Datei eines Films (`teaser/`), für Medien ohne Inhaltsfassung.
|
||||
*/
|
||||
public function jpegAtWebsiteFile(ContentElement $element, float $seconds): ?string
|
||||
{
|
||||
return $this->websiteFileJpeg($element, $seconds, 640);
|
||||
}
|
||||
|
||||
/**
|
||||
* Einzelbild aus der Website-Datei in der gewünschten Breite, nie über die Breite der Datei hinaus (Standbild für
|
||||
* die Medienkarte, FilmStill).
|
||||
*/
|
||||
public function websiteFileJpeg(ContentElement $element, float $seconds, int $width): ?string
|
||||
{
|
||||
$file = $element->preview_path;
|
||||
|
||||
if ($element->output_class !== 'film' || ! $this->readableDerived($file, 'teaser/')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->jpegFromFile($file, $seconds, $width);
|
||||
}
|
||||
|
||||
private function jpegFromFile(string $file, float $seconds, int $width): ?string
|
||||
{
|
||||
if ($seconds < 0 || $seconds > 7200) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -186,7 +259,7 @@ public function jpegAtVersion(ContentElementVersion $version, float $seconds): ?
|
||||
'-frames:v',
|
||||
'1',
|
||||
'-vf',
|
||||
'scale=640:-2',
|
||||
$width === 640 ? 'scale=640:-2' : 'scale=min('.max(160, min(2400, $width)).'\,iw):-2',
|
||||
'-f',
|
||||
'image2pipe',
|
||||
'-vcodec',
|
||||
|
||||
@@ -37,6 +37,16 @@ public static function effectiveFor(mixed $path): ?self
|
||||
return $alias instanceof self && $alias->everReleased() ? $alias : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Früherer Pfad, dessen übernommenes Medium inzwischen gelöscht wurde. Die Datei unter cms/ bleibt liegen, wird aber
|
||||
* weder ausgeliefert noch als Bild gezeigt: Das Löschen des Mediums gilt auch für die frühere Adresse.
|
||||
*/
|
||||
public static function isRetired(mixed $path): bool
|
||||
{
|
||||
return is_string($path) && $path !== ''
|
||||
&& self::query()->where('legacy_path', $path)->whereNull('content_element_id')->exists();
|
||||
}
|
||||
|
||||
public function everReleased(): bool
|
||||
{
|
||||
$element = $this->element;
|
||||
|
||||
@@ -44,7 +44,7 @@ public function refusal(ContentElement $element): ?string
|
||||
}
|
||||
|
||||
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 'Für die Website fehlt eine freigebbare Datei. Beim Bild ist das das Vorschaubild. Bei Film und Hörstück lädst du unter „Website-Freigabe“ eine Website-Datei hoch (Film als MP4 oder WebM); die geschützte Originaldatei bleibt unberührt.';
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
use App\Filament\Resources\Bundles\BundleResource;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
@@ -90,7 +91,8 @@ public function publishAction(): Action
|
||||
->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('articles')->label('Lizenzartikel')->options(fn (): array => app(PublicationReadiness::class)->articleOptions())
|
||||
->helperText('Artikel ohne Stand lassen sich aufnehmen, aber erst verkaufen, wenn sie einen Inhalt haben.'),
|
||||
CheckboxList::make('bundles')->label('Enthaltene Pakete')
|
||||
->options(function (): array {
|
||||
$options = CatalogOptions::bundles();
|
||||
@@ -115,7 +117,12 @@ public function publishAction(): Action
|
||||
|
||||
$version = app(BundleService::class)->publish($bundle, $items);
|
||||
|
||||
return 'Fassung '.$version->number.' ist veröffentlicht.';
|
||||
$bundle->unsetRelations();
|
||||
$readiness = app(PublicationReadiness::class)->forBundle($bundle->refresh());
|
||||
|
||||
return 'Fassung '.$version->number.' ist veröffentlicht.'.($readiness['naechster'] !== null
|
||||
? ' Nächster Schritt: '.$readiness['naechster']['titel'].'.'
|
||||
: '');
|
||||
}, 'Die Paketfassung ist veröffentlicht.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
@@ -164,6 +171,7 @@ private function paketDaten(): array
|
||||
'art' => 'primary',
|
||||
]],
|
||||
],
|
||||
'voraussetzungen' => app(PublicationReadiness::class)->forBundle($bundle),
|
||||
'haupt' => [
|
||||
[
|
||||
'titel' => 'Bestandteile',
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\AssignsPillars;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Filament\Support\ManagesEditorialSurface;
|
||||
use App\Filament\Support\MediumForm;
|
||||
@@ -43,6 +44,7 @@
|
||||
|
||||
abstract class EditComposition extends EditRecord
|
||||
{
|
||||
use AssignsPillars;
|
||||
use ManagesEditorialSurface;
|
||||
use WithFileUploads;
|
||||
|
||||
@@ -398,11 +400,15 @@ public function redaktionTexteHinweis(): string
|
||||
*/
|
||||
public function einordnungGruppen(): array
|
||||
{
|
||||
return array_map(fn (array $group): array => [
|
||||
$groups = array_map(fn (array $group): array => [
|
||||
'legend' => $group['label'],
|
||||
'model' => 'dimensionIds',
|
||||
'values' => $group['values'],
|
||||
], $this->dimensionGroups());
|
||||
|
||||
$pillars = $this->pillarGroup();
|
||||
|
||||
return $pillars === null ? $groups : [$pillars, ...$groups];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -466,7 +472,7 @@ public function einordnungUnsaved(): bool
|
||||
sort($stored);
|
||||
sort($current);
|
||||
|
||||
return $stored !== $current;
|
||||
return $stored !== $current || $this->pillarsUnsaved($record);
|
||||
}
|
||||
|
||||
public function openText(): void
|
||||
@@ -1654,6 +1660,7 @@ protected function fillRedaktion(): void
|
||||
->pluck('editorial_dimension_value_id')
|
||||
->map(fn (mixed $id): string => (string) (int) $id)
|
||||
->all();
|
||||
$this->loadPillarIds($composition);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1913,6 +1920,7 @@ protected function persistRedaktion(): bool
|
||||
'description' => $this->description,
|
||||
], $this->actor());
|
||||
$this->syncDimensions($record, array_map(intval(...), $this->dimensionIds));
|
||||
$this->persistPillarIds($record);
|
||||
$record->refresh();
|
||||
$this->getRecord()->setRawAttributes($record->getAttributes());
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\ContentElements\Pages;
|
||||
|
||||
use App\Domain\Catalog\EditorialVocabulary;
|
||||
use App\Domain\Catalog\PillarFilterCompat;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\Bestand;
|
||||
use App\Filament\Support\MediaLibrary;
|
||||
@@ -39,6 +40,9 @@ class ListContentElements extends ListRecords
|
||||
#[Url(as: 'freigabe', except: '')]
|
||||
public string $freigabe = '';
|
||||
|
||||
#[Url(as: 'schutz', except: '')]
|
||||
public string $schutz = '';
|
||||
|
||||
#[Url(as: 'entwurf', except: '')]
|
||||
public string $entwurf = '';
|
||||
|
||||
@@ -84,7 +88,7 @@ public function content(Schema $schema): Schema
|
||||
|
||||
protected function bestandFilterEigenschaften(): array
|
||||
{
|
||||
return ['suche', 'art', 'freigabe', 'entwurf', 'fassung', 'nutzung', 'saeule', 'inhaltsart', 'einordnung', 'verarbeitung', 'archiv'];
|
||||
return ['suche', 'art', 'schutz', 'freigabe', 'entwurf', 'fassung', 'nutzung', 'saeule', 'inhaltsart', 'einordnung', 'verarbeitung', 'archiv'];
|
||||
}
|
||||
|
||||
public function showingList(): bool
|
||||
@@ -137,6 +141,7 @@ public function filtersActive(): bool
|
||||
return trim($this->suche) !== ''
|
||||
|| $this->art !== ''
|
||||
|| $this->freigabe !== ''
|
||||
|| $this->schutz !== ''
|
||||
|| $this->entwurf !== ''
|
||||
|| $this->fassung !== ''
|
||||
|| $this->nutzung !== ''
|
||||
@@ -152,6 +157,7 @@ public function resetFilters(): void
|
||||
$this->suche = '';
|
||||
$this->art = '';
|
||||
$this->freigabe = '';
|
||||
$this->schutz = '';
|
||||
$this->entwurf = '';
|
||||
$this->fassung = '';
|
||||
$this->nutzung = '';
|
||||
@@ -170,6 +176,11 @@ public function resetFilters(): void
|
||||
*/
|
||||
public function bestand(): array
|
||||
{
|
||||
// Alte Adressen mit einem Säulenwert der Einordnung gelten für die zentrale Säule.
|
||||
if (ctype_digit($this->einordnung) && $this->saeule === '' && is_int($pillar = PillarFilterCompat::pillarOfLegacyValue((int) $this->einordnung))) {
|
||||
[$this->saeule, $this->einordnung] = [(string) $pillar, ''];
|
||||
}
|
||||
|
||||
$optionen = fn (array $liste, string $wert, string $label): array => collect($liste)
|
||||
->mapWithKeys(fn (array $eintrag): array => [(string) $eintrag[$wert] => $eintrag[$label]])
|
||||
->all();
|
||||
@@ -194,11 +205,12 @@ public function bestand(): array
|
||||
'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' => 'schutz', 'label' => 'Schutz', 'vorgabe' => '', 'alle' => 'Alle Medien', 'optionen' => ['geschuetzt' => 'Geschützte Medien', 'oeffentlich' => 'Öffentliche Medien', 'website' => 'Auf der Website frei']],
|
||||
['eigenschaft' => 'freigabe', 'label' => 'Freigabe', 'vorgabe' => '', 'alle' => 'Alle Freigaben', 'optionen' => ['freigegeben' => 'Freigegebene Fassung', 'entwurf' => 'Nur offener Entwurf', 'ohne' => 'Keine freigegebene Fassung']],
|
||||
['eigenschaft' => 'nutzung', 'label' => 'Verwendung', 'vorgabe' => '', 'alle' => 'Verwendung egal', 'optionen' => ['verwendet' => 'Verwendet', 'unbenutzt' => 'Nicht verwendet']],
|
||||
],
|
||||
'weitere' => $weitere,
|
||||
'hinweis' => 'Freigabe meint die Fassung des Mediums, nicht die Website und keinen Zugriff. 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.',
|
||||
'hinweis' => 'Freigabe meint die Fassung des Mediums, nicht die Website und keinen Zugriff. Geschützte Medien haben eine Inhaltsfassung und laufen über Lizenzen. Öffentliche Medien sind eigenständige Präsentationsmedien ohne Fassung für die Website; ob sie freigegeben sind, zeigt die Kennzeichnung an der Zeile. Materialart und Einordnung sind die redaktionelle Klassifikation; Verwendung zeigt, wo das Medium tatsächlich eingebunden ist. Deaktivierte und archivierte Medien bleiben über „Weitere Filter“ auffindbar.',
|
||||
'zeilen' => array_map($this->zeile(...), $this->cards()),
|
||||
'einheit' => ['Medium', 'Medien'],
|
||||
'leer' => ['titel' => 'Noch keine Medien', 'text' => 'Mit „Medium anlegen“ oben lädst du eine Datei hoch oder schreibst einen Text.'],
|
||||
@@ -212,13 +224,19 @@ public function bestand(): array
|
||||
*/
|
||||
private function zeile(array $card): array
|
||||
{
|
||||
$chips = [['label' => $card['stand'], 'ton' => match ($card['standTone']) {
|
||||
$chips = [['label' => $card['presentation'] ? 'Präsentationsmedium, ohne Inhaltsfassung' : $card['stand'], 'ton' => match ($card['standTone']) {
|
||||
'ready' => 'gut',
|
||||
'draft' => 'offen',
|
||||
'blocked' => 'achtung',
|
||||
default => 'leise',
|
||||
}]];
|
||||
|
||||
if ($card['websiteReleased']) {
|
||||
$chips[] = ['label' => 'Für die Website freigegeben', 'ton' => 'gut'];
|
||||
} elseif ($card['presentation']) {
|
||||
$chips[] = ['label' => 'Nicht für die Website freigegeben', 'ton' => 'offen'];
|
||||
}
|
||||
|
||||
foreach ([['draftNote', 'offen'], ['blockedNote', 'achtung'], ['processing', 'offen'], ['versionLabel', 'leise']] as [$feld, $ton]) {
|
||||
if (filled($card[$feld] ?? null)) {
|
||||
$chips[] = ['label' => (string) $card[$feld], 'ton' => $ton];
|
||||
@@ -266,6 +284,7 @@ private function libraryFilters(): array
|
||||
'suche' => $this->suche,
|
||||
'art' => $this->art,
|
||||
'freigabe' => $this->freigabe,
|
||||
'schutz' => $this->schutz,
|
||||
'entwurf' => $this->entwurf,
|
||||
'fassung' => $this->fassung,
|
||||
'nutzung' => $this->nutzung,
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\WebsiteImageUsage;
|
||||
use App\Domain\Cms\Widgets\RenderContext;
|
||||
use App\Domain\Media\PresentationFile;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Domain\Media\WebsiteRelease;
|
||||
@@ -92,6 +93,9 @@ class ViewContentElement extends ViewRecord
|
||||
|
||||
public string $websiteFeedback = '';
|
||||
|
||||
/** Gewählte Website-Datei für Film oder Hörstück (ungeschützt, getrennt von der Inhaltsfassung). */
|
||||
public mixed $websiteUpload = null;
|
||||
|
||||
public int|string|null $kindId = null;
|
||||
|
||||
/** @var list<int|string> */
|
||||
@@ -262,8 +266,9 @@ public function adoptFrame(): void
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$shown = $this->shownVersion();
|
||||
$fromWebsiteFile = ! $shown instanceof ContentElementVersion && $this->hasWebsiteFilm($element);
|
||||
|
||||
if (! $shown instanceof ContentElementVersion || $element->output_class !== 'film') {
|
||||
if ((! $shown instanceof ContentElementVersion && ! $fromWebsiteFile) || $element->output_class !== 'film') {
|
||||
$this->pictureFeedback = 'Für dieses Medium gibt es keine Filmstelle.';
|
||||
|
||||
return;
|
||||
@@ -286,7 +291,9 @@ public function adoptFrame(): void
|
||||
$this->keepAlt($element);
|
||||
$element->thumbnail_error = null;
|
||||
$element->save();
|
||||
DeriveThumbnail::dispatch('element', $element->id, null, null, $shown->id, $seconds);
|
||||
$fromWebsiteFile
|
||||
? DeriveThumbnail::dispatch('element', $element->id, null, null, null, $seconds, true)
|
||||
: DeriveThumbnail::dispatch('element', $element->id, null, null, $shown->id, $seconds);
|
||||
$element->refresh();
|
||||
$this->pictureFeedback = $element->thumbnail_error
|
||||
?: 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.';
|
||||
@@ -361,10 +368,24 @@ public function useOwnImage(): void
|
||||
?: 'Das Vorschaubild ist gespeichert. Die Fassung bleibt unverändert.';
|
||||
}
|
||||
|
||||
/** Ein Film ohne Inhaltsfassung, aber mit Website-Datei: die Filmstelle kommt aus dieser Datei. */
|
||||
public function hasWebsiteFilm(?ContentElement $element = null): bool
|
||||
{
|
||||
$element ??= $this->getRecord();
|
||||
|
||||
return $element->output_class === 'film'
|
||||
&& filled($element->preview_path)
|
||||
&& ! $element->versions()->exists();
|
||||
}
|
||||
|
||||
public function framePreviewUrl(): ?string
|
||||
{
|
||||
$shown = $this->shownVersion();
|
||||
|
||||
if (! $shown instanceof ContentElementVersion && $this->hasWebsiteFilm() && is_numeric($this->frameSecond) && trim($this->frameSecond) !== '') {
|
||||
return route('content.website-frame', ['element' => $this->getRecord(), 'sekunde' => $this->frameSecond]);
|
||||
}
|
||||
|
||||
if (! $shown instanceof ContentElementVersion || ! is_numeric($this->frameSecond) || trim($this->frameSecond) === '') {
|
||||
return null;
|
||||
}
|
||||
@@ -844,6 +865,61 @@ public function releaseForWebsite(): void
|
||||
$element->refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Legt die Datei ab, die auf der Website laufen soll (zum Beispiel ein Trailer). Die geschützte Inhaltsfassung
|
||||
* bleibt unberührt; öffentlich wird die Datei erst mit der Website-Freigabe.
|
||||
*/
|
||||
public function storeWebsiteFile(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
if (! in_array($element->output_class, ['film', 'audio'], true)) {
|
||||
$this->websiteFeedback = 'Eine Website-Datei gibt es nur für Filme und Hörstücke.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $this->websiteUpload instanceof TemporaryUploadedFile) {
|
||||
$this->websiteFeedback = 'Wähle zuerst eine Datei.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$files = app(PresentationFile::class);
|
||||
$extension = strtolower($this->websiteUpload->getClientOriginalExtension());
|
||||
|
||||
if (! in_array($extension, PresentationFile::EXTENSIONS[$element->output_class], true)) {
|
||||
$this->websiteFeedback = 'Für die Website geht nur '.$files->formats($element->output_class).'. Eine .'.$extension.'-Datei kann der Browser nicht direkt abspielen.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$path = $this->websiteUpload->storeAs('inhalte', 'web-'.bin2hex(random_bytes(6)).'.'.$extension, 'cms_incoming');
|
||||
$this->websiteUpload = null;
|
||||
|
||||
if (! is_string($path)) {
|
||||
$this->websiteFeedback = 'Die Datei wurde nicht übernommen.';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$files->store($element, $path);
|
||||
} catch (DomainRuleException $e) {
|
||||
$this->websiteFeedback = $e->getMessage();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$element->refresh();
|
||||
$this->websiteFeedback = filled($element->thumbnail_error)
|
||||
? (string) $element->thumbnail_error
|
||||
: 'Die Website-Datei ist übernommen. Sie ist erst nach „Für die Website freigeben“ öffentlich. Ein bereits freigegebenes Medium zeigt danach die neue Datei.';
|
||||
}
|
||||
|
||||
public function withdrawWebsite(): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
use App\Filament\Resources\LicenseArticles\Pages\ListLicenseArticles;
|
||||
use App\Filament\Resources\LicenseArticles\Pages\ViewLicenseArticle;
|
||||
use App\Filament\Support\CatalogReading;
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Resources\Resource;
|
||||
@@ -57,6 +58,7 @@ public static function infolist(Schema $schema): Schema
|
||||
->viewData(fn (LicenseArticle $record): array => [
|
||||
'stand' => app(CatalogReading::class)->articleStand($record),
|
||||
'kontext' => app(CatalogReading::class)->articleContext($record),
|
||||
'voraussetzungen' => app(PublicationReadiness::class)->forArticle($record),
|
||||
])
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Support\AssignsPillars;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\EditorialCatalog;
|
||||
use App\Filament\Support\ManagesEditorialSurface;
|
||||
@@ -30,6 +31,7 @@
|
||||
|
||||
class ViewLicenseArticle extends ViewRecord
|
||||
{
|
||||
use AssignsPillars;
|
||||
use ManagesEditorialSurface;
|
||||
use ReportsDomainRules;
|
||||
|
||||
@@ -115,6 +117,7 @@ protected function saveRedaktionTexte(): bool
|
||||
], auth()->user());
|
||||
|
||||
app(IdentityDimension::class)->replaceOffered($article, array_map(intval(...), $this->dimensionIds));
|
||||
$this->persistPillarIds($article);
|
||||
|
||||
$article->refresh();
|
||||
$this->fillLicenseEditorial();
|
||||
@@ -159,7 +162,7 @@ public function einordnungUnsaved(): bool
|
||||
sort($stored);
|
||||
sort($current);
|
||||
|
||||
return $stored !== $current;
|
||||
return $stored !== $current || $this->pillarsUnsaved($article);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,11 +273,15 @@ public function einordnungArt(): array
|
||||
*/
|
||||
public function einordnungGruppen(): array
|
||||
{
|
||||
return array_map(fn (array $group): array => [
|
||||
$groups = array_map(fn (array $group): array => [
|
||||
'legend' => $group['label'],
|
||||
'model' => 'dimensionIds',
|
||||
'values' => $group['values'],
|
||||
], $this->licenseDimensionGroups());
|
||||
|
||||
$pillars = $this->pillarGroup();
|
||||
|
||||
return $pillars === null ? $groups : [$pillars, ...$groups];
|
||||
}
|
||||
|
||||
private function sourceTitle(Model $source): string
|
||||
@@ -312,6 +319,7 @@ private function fillLicenseEditorial(): void
|
||||
->where('origin', 'direkt')
|
||||
->pluck('editorial_dimension_value_id')
|
||||
->all();
|
||||
$this->loadPillarIds($article);
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
@@ -322,12 +330,28 @@ protected function getHeaderActions(): array
|
||||
public function releaseAction(): Action
|
||||
{
|
||||
return Action::make('release')
|
||||
->label('Stand veröffentlichen')
|
||||
->label(fn (): string => $this->isFirstStand() ? 'Inhalt festlegen' : 'Neuen Stand veröffentlichen')
|
||||
->modalHeading(fn (): string => $this->isFirstStand() ? 'Inhalt festlegen: ersten Stand veröffentlichen' : 'Neuen Stand veröffentlichen')
|
||||
->modalDescription(fn (): string => $this->isFirstStand()
|
||||
? 'Der Stand legt fest, welche Inhalte dieser Lizenzartikel lizenziert: der gewählte Inhalt samt allem, was er enthält. Er ist danach unveränderlich. Pakete und Angebote können den Artikel danach verwenden; verkauft wird er erst über ein Angebot.'
|
||||
: 'Ein neuer Stand ersetzt den aktuellen für künftige Ausgaben. Bestehende Käufer erhalten ihn im Rahmen ihrer Lizenz; frühere Stände bleiben gespeichert.')
|
||||
->modalSubmitActionLabel('Stand veröffentlichen')
|
||||
->fillForm(fn (): array => $this->isFirstStand() ? ['classification' => 'Erster Stand dieses Lizenzartikels.'] : [])
|
||||
->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'),
|
||||
Select::make('root')->label('Freigegebener Inhalt')
|
||||
->options(fn (): array => CatalogOptions::assignmentTargets())
|
||||
->searchable()
|
||||
->required()
|
||||
->helperText(fn (): string => CatalogOptions::assignmentTargets() === []
|
||||
? 'Es gibt noch keinen freigegebenen Inhalt. Gib zuerst ein Medium, Modul oder Programm frei.'
|
||||
: 'Medien, Module und Programme mit freigegebener Fassung. Bei Modulen und Programmen gehört alles Enthaltene zum Stand.'),
|
||||
Textarea::make('classification')->label('Einordnung')
|
||||
->required(fn (): bool => ! $this->isFirstStand())
|
||||
->helperText(fn (): string => $this->isFirstStand()
|
||||
? 'Beim ersten Stand genügt der vorgegebene Text.'
|
||||
: 'Warum dies derselbe Lizenzartikel bleibt und kein neues Produkt ist.'),
|
||||
TextInput::make('change_note')->label('Änderungshinweis')
|
||||
->visible(fn (): bool => ! $this->isFirstStand()),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): string {
|
||||
@@ -340,7 +364,7 @@ public function releaseAction(): Action
|
||||
$release = app(ArticleService::class)->publishRelease(
|
||||
$article,
|
||||
$root,
|
||||
$data['classification'],
|
||||
(string) ($data['classification'] ?? 'Erster Stand dieses Lizenzartikels.'),
|
||||
$data['change_note'] ?? null,
|
||||
);
|
||||
$report = $release->impact_report ?? [];
|
||||
@@ -375,6 +399,11 @@ public function withdrawAction(): Action
|
||||
});
|
||||
}
|
||||
|
||||
private function isFirstStand(): bool
|
||||
{
|
||||
return ! $this->getRecord()->releases()->exists();
|
||||
}
|
||||
|
||||
private function refreshRecord(): void
|
||||
{
|
||||
$this->getRecord()->unsetRelations();
|
||||
|
||||
@@ -64,6 +64,7 @@ protected function catalogRows(): array
|
||||
if ($active !== null) {
|
||||
$chips[] = ['label' => 'Fassung '.$active->number.' aktiv', 'ton' => 'gut'];
|
||||
$chips[] = ['label' => CatalogLabels::vergabe($active), 'ton' => 'neutral'];
|
||||
$chips[] = ['label' => $active->holder_kind === 'organisation' ? 'Für Organisationen' : 'Für Privatpersonen', 'ton' => 'neutral'];
|
||||
$zustand[] = 'aktiv';
|
||||
$text = $active->lines->map(fn ($line): string => ($line->article !== null
|
||||
? 'Lizenzartikel '.$line->article->code
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
namespace App\Filament\Resources\Offers\Pages;
|
||||
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\BundleVersion;
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
@@ -11,9 +14,13 @@
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Catalog\StatusValue;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Filament\Resources\Offers\OfferResource;
|
||||
use App\Filament\Support\CatalogLabels;
|
||||
use App\Filament\Support\CatalogOptions;
|
||||
use App\Filament\Support\PublicationReadiness;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
@@ -25,6 +32,7 @@
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Angebot im gemeinsamen Rahmen. Anlegen und Ändern nutzen dieselbe Maske (FACH-20): „Fassung aktivieren“ legt die
|
||||
@@ -91,22 +99,34 @@ 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')
|
||||
? 'Option „'.$this->getRecord()->optionName().'“ ändern: Fassung '.$this->nextNumber().' aktivieren'
|
||||
: 'Option „'.$this->getRecord()->optionName().'“: 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.')
|
||||
? 'Betroffen ist nur die Option „'.$this->getRecord()->optionName().'“'.$this->productPageSuffix().'. Die Maske ist mit Fassung '.$active->number.' vorbelegt. Erst „Fassung '.$this->nextNumber().' aktivieren“ schaltet die Änderung öffentlich (auch Bezeichnung und Produktseite, sie erzeugen ebenfalls eine neue Fassung und zeigen offenen Warenkörben „Bedingungen aktualisiert“): Fassung '.$active->number.' wird beendet und bleibt gespeichert, neue Käufe nutzen Fassung '.$this->nextNumber().'. Bereits begründete Berechtigungen und Bestellungen ändern sich nicht. Andere Optionen derselben Produktseite bleiben unverändert kaufbar. „Abbrechen“ verwirft die Eingaben.'
|
||||
: 'Positionen, Vergabe, Eignung und Preis bilden die erste Fassung dieser Option. Erst das Aktivieren macht sie öffentlich; danach ist sie unveränderlich, Änderungen ergeben eine weitere Fassung.')
|
||||
->modalSubmitActionLabel(fn (): string => 'Fassung '.$this->nextNumber().' aktivieren')
|
||||
->modalWidth('4xl')
|
||||
->fillForm(fn (): array => $this->formFromActive())
|
||||
->schema([
|
||||
TextInput::make('option_label')->label('Bezeichnung der Option')
|
||||
->helperText('So heißt die Option auf der Produktseite, zum Beispiel „Einzellizenz für Privatpersonen“. Sie ist keine bindende Bedingung, wird aber wie die übrigen Angaben erst mit „Fassung aktivieren“ übernommen.')
|
||||
->maxLength(120),
|
||||
Select::make('composition_id')->label('Produktseite')
|
||||
->options(fn (): array => $this->productPages())
|
||||
->searchable()
|
||||
->helperText('Optionen derselben Produktseite sind Alternativen; im Warenkorb liegt nur eine davon. Die Beschreibung der Seite wird zentral an der Komposition gepflegt. Die Zuordnung wird mit „Fassung aktivieren“ übernommen.'),
|
||||
Select::make('holder_kind')->label('Geeignet für')->options([
|
||||
'person' => 'Privatpersonen',
|
||||
'organisation' => 'Organisationen und Vereine',
|
||||
])->required()
|
||||
->helperText('Wähle die Eignung passend zu den Rechten: Organisationslizenzen brauchen institutionelle Rechte. Das System erzwingt diese Kopplung nicht.'),
|
||||
Select::make('grant_kind')->label('Vergabe')->options([
|
||||
'kauf' => 'Kauf',
|
||||
'auf_abruf' => 'Auf Abruf',
|
||||
'bei_registrierung' => 'Bei Registrierung',
|
||||
])->required(),
|
||||
TextInput::make('price_cents')->label('Preis in Cent')->numeric()
|
||||
->helperText('Nur bei einem Kauf. 500 bedeutet 5,00 €.'),
|
||||
TextInput::make('price_euro')->label('Preis in Euro')->suffix('€')
|
||||
->helperText('Nur bei einem Kauf, zum Beispiel 49,00.'),
|
||||
Select::make('composition_version_id')->label('Programmfassung, die abgedeckt sein muss')
|
||||
->options(function (): array {
|
||||
return CompositionVersion::query()
|
||||
@@ -124,9 +144,12 @@ public function activateAction(): Action
|
||||
'article' => 'Lizenzartikel',
|
||||
'bundle' => 'Paketfassung',
|
||||
])->required()->live(),
|
||||
Select::make('article_id')->label('Artikel')->options(fn (): array => CatalogOptions::articles())
|
||||
Select::make('article_id')->label('Artikel')->options(fn (): array => app(PublicationReadiness::class)->articleOptions())
|
||||
->searchable()
|
||||
->helperText('Nur Artikel mit veröffentlichtem Stand lassen sich verkaufen. Artikel ohne Stand sind gekennzeichnet.')
|
||||
->visible(fn (Get $get): bool => $get('kind') === 'article'),
|
||||
Select::make('bundle_version_id')->label('Paketfassung')->options(fn (): array => CatalogOptions::bundleVersions())
|
||||
Select::make('bundle_version_id')->label('Paketfassung')->options(fn (): array => app(PublicationReadiness::class)->bundleVersionOptions())
|
||||
->searchable()
|
||||
->visible(fn (Get $get): bool => $get('kind') === 'bundle'),
|
||||
Select::make('rights_id')->label('Rechte')->options(fn (): array => CatalogOptions::rights())->required(),
|
||||
])->minItems(1)->addActionLabel('Position hinzufügen'),
|
||||
@@ -147,29 +170,117 @@ public function activateAction(): Action
|
||||
];
|
||||
}
|
||||
|
||||
// Bedingungen, die die Maske nicht zeigt, bleiben bei einer Änderung die der aktiven Fassung; ohne
|
||||
// aktive Fassung gilt wie bisher die Vorgabe (Personen, dauerhaft).
|
||||
// Voraussetzung: Jeder Artikel der Positionen hat einen veröffentlichten Stand, sonst erhielten Käufer nichts.
|
||||
$articleIds = [];
|
||||
|
||||
foreach ($lines as $line) {
|
||||
$target = $line['target'];
|
||||
array_push($articleIds, ...($target instanceof BundleVersion ? app(BundleService::class)->articleIds($target) : [$target->id]));
|
||||
}
|
||||
|
||||
$unusable = app(PublicationReadiness::class)->unusableArticles($articleIds);
|
||||
|
||||
if ($unusable !== []) {
|
||||
throw new DomainRuleException(app(PublicationReadiness::class)->unusableMessage($unusable, 'das Angebot aktivierst'));
|
||||
}
|
||||
|
||||
// Bedingungen, die die Maske nicht zeigt, bleiben bei einer Änderung die der aktiven Fassung.
|
||||
$active = $this->activeVersion();
|
||||
$kept = $active === null ? ['holder_kind' => 'person'] : [
|
||||
'holder_kind' => $active->holder_kind,
|
||||
$kept = $active === null ? [] : [
|
||||
'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'],
|
||||
'price_cents' => $data['price_cents'] === null || $data['price_cents'] === '' ? null : (int) $data['price_cents'],
|
||||
'composition_version_id' => filled($data['composition_version_id'] ?? null) ? (int) $data['composition_version_id'] : null,
|
||||
]);
|
||||
$price = Money::parse($data['price_euro'] ?? null);
|
||||
|
||||
return 'Fassung '.$version->number.' ist aktiv.';
|
||||
if ($data['grant_kind'] === 'kauf' && ($price === null || $price <= 0)) {
|
||||
throw new DomainRuleException('Ein Kauf braucht einen Preis über 0,00 €.');
|
||||
}
|
||||
|
||||
$service = app(OfferService::class);
|
||||
$version = DB::transaction(function () use ($service, $offer, $data, $lines, $kept, $price) {
|
||||
$service->assignProduct(
|
||||
$offer,
|
||||
filled($data['composition_id'] ?? null) ? (int) $data['composition_id'] : null,
|
||||
$data['option_label'] ?? null,
|
||||
);
|
||||
|
||||
return $service->activate($offer, $lines, [
|
||||
...$kept,
|
||||
'holder_kind' => $data['holder_kind'],
|
||||
'grant_kind' => $data['grant_kind'],
|
||||
'price_cents' => $price,
|
||||
'composition_version_id' => filled($data['composition_version_id'] ?? null) ? (int) $data['composition_version_id'] : null,
|
||||
]);
|
||||
});
|
||||
|
||||
$offer->unsetRelations();
|
||||
$readiness = app(PublicationReadiness::class)->forOffer($offer->refresh());
|
||||
|
||||
return 'Fassung '.$version->number.' ist aktiv.'.($readiness['bereit']
|
||||
? ' Die Option ist öffentlich kaufbar und im Shop auffindbar.'
|
||||
: ' Noch nicht im Shop kaufbar. Nächster Schritt: '.$readiness['naechster']['titel'].'.');
|
||||
}, 'Die Angebotsfassung ist aktiv.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Option aus dem Verkauf nehmen: nur die aktive Fassung dieser Option wird beendet.
|
||||
*/
|
||||
public function endAction(): Action
|
||||
{
|
||||
return Action::make('end')
|
||||
->label('Aus dem Verkauf nehmen')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->modalHeading(fn (): string => 'Option „'.$this->getRecord()->optionName().'“ aus dem Verkauf nehmen?')
|
||||
->modalDescription(fn (): string => 'Betroffen ist nur die Option „'.$this->getRecord()->optionName().'“'.$this->productPageSuffix().'. Die aktive Fassung wird beendet und bleibt gespeichert. Die Option ist danach nicht mehr kaufbar; in vorhandenen Warenkörben bleibt sie mit Hinweis sichtbar und blockiert den Abschluss, bis der Käufer sie entfernt. Bestehende Berechtigungen und Bestellungen ändern sich nicht. Andere Optionen derselben Produktseite bleiben kaufbar.')
|
||||
->modalSubmitActionLabel('Aus dem Verkauf nehmen')
|
||||
->visible(fn (): bool => $this->activeVersion() !== null)
|
||||
->action(function (): void {
|
||||
$this->report(function (): string {
|
||||
$version = app(OfferService::class)->end($this->getRecord());
|
||||
|
||||
return 'Fassung '.$version->number.' ist beendet. Die Option ist nicht mehr kaufbar.';
|
||||
}, 'Die Option ist aus dem Verkauf genommen.');
|
||||
$this->getRecord()->unsetRelations();
|
||||
$this->getRecord()->refresh();
|
||||
});
|
||||
}
|
||||
|
||||
/** „ der Produktseite „Titel““ oder leer, wenn die Option noch keiner Produktseite zugeordnet ist. */
|
||||
private function productPageSuffix(): string
|
||||
{
|
||||
$page = $this->getRecord()->composition;
|
||||
|
||||
return $page === null ? '' : ' der Produktseite „'.($page->display_title ?: $page->designation).'“';
|
||||
}
|
||||
|
||||
/**
|
||||
* Produktseiten, die als Ziel wählbar sind: Kompositionen mit Bezeichnung und Art.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private function productPages(): array
|
||||
{
|
||||
$catalog = app(PublicCatalogReader::class);
|
||||
|
||||
return Composition::query()
|
||||
->with('editorialContentKind')
|
||||
->whereNull('archived_at')
|
||||
->orderBy('designation')
|
||||
->get()
|
||||
->sortBy(fn (Composition $composition): int => $catalog->shownVersion($composition) !== null ? 0 : 1)
|
||||
->mapWithKeys(fn (Composition $composition): array => [
|
||||
$composition->id => ($composition->display_title ?: $composition->designation)
|
||||
.' ('.($composition->editorialContentKind?->label ?? 'Zusammenstellung').')'
|
||||
.($catalog->shownVersion($composition) !== null ? ' · im Shop auffindbar' : ' · nicht öffentlich, im Shop nicht auffindbar'),
|
||||
])
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Vorbelegung aus der aktiven Fassung; ohne aktive Fassung eine leere Position.
|
||||
*
|
||||
@@ -178,14 +289,19 @@ public function activateAction(): Action
|
||||
private function formFromActive(): array
|
||||
{
|
||||
$active = $this->activeVersion();
|
||||
/** @var Offer $offer */
|
||||
$offer = $this->getRecord();
|
||||
$option = ['option_label' => $offer->option_label, 'composition_id' => $offer->composition_id];
|
||||
|
||||
if ($active === null) {
|
||||
return ['grant_kind' => 'kauf', 'lines' => [['kind' => 'article']]];
|
||||
return [...$option, 'holder_kind' => 'person', 'grant_kind' => 'kauf', 'lines' => [['kind' => 'article']]];
|
||||
}
|
||||
|
||||
return [
|
||||
...$option,
|
||||
'holder_kind' => $active->holder_kind,
|
||||
'grant_kind' => $active->grant_kind,
|
||||
'price_cents' => $active->price_cents,
|
||||
'price_euro' => $active->price_cents === null ? null : number_format($active->price_cents / 100, 2, ',', ''),
|
||||
'lines' => $active->lines->sortBy('position')->map(fn ($line): array => [
|
||||
'kind' => $line->license_article_id !== null ? 'article' : 'bundle',
|
||||
'article_id' => $line->license_article_id,
|
||||
@@ -220,13 +336,22 @@ private function angebotDaten(): array
|
||||
'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',
|
||||
]],
|
||||
'aktionen' => [
|
||||
[
|
||||
'label' => $active !== null ? 'Geänderte Fassung aktivieren' : 'Fassung aktivieren',
|
||||
'wire' => "mountAction('activate')",
|
||||
'art' => 'primary',
|
||||
],
|
||||
...($active !== null ? [[
|
||||
'label' => 'Aus dem Verkauf nehmen',
|
||||
'wire' => "mountAction('end')",
|
||||
'art' => 'line',
|
||||
]] : []),
|
||||
],
|
||||
],
|
||||
'voraussetzungen' => app(PublicationReadiness::class)->forOffer($offer),
|
||||
'haupt' => [
|
||||
...($active !== null ? [$this->optionAbschnitt($offer, $active)] : []),
|
||||
[
|
||||
'titel' => 'Positionen',
|
||||
'zusatz' => $active !== null ? 'Fassung '.$active->number : null,
|
||||
@@ -261,6 +386,37 @@ private function angebotDaten(): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Die Option auf einen Blick: Preis in Euro, Eignung, Rechte, zugrunde liegender Inhalt, Status und Produktseite.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function optionAbschnitt(Offer $offer, OfferVersion $active): array
|
||||
{
|
||||
$option = app(ProductOptions::class)->describe($offer, $active);
|
||||
$inhalt = collect($option['scope'])->pluck('article')->unique()->implode(', ');
|
||||
$rechte = collect($option['scope'])
|
||||
->map(fn (array $item): string => $item['purpose'].($item['rights'] === [] ? '' : ': '.implode(', ', $item['rights'])))
|
||||
->unique()
|
||||
->implode('; ');
|
||||
$seite = $offer->composition;
|
||||
$kaufbar = app(OfferService::class)->purchasableVersion($offer) !== null;
|
||||
|
||||
return [
|
||||
'titel' => 'Die Option auf einen Blick',
|
||||
'zusatz' => 'Fassung '.$active->number,
|
||||
'hilfe' => 'So erscheint die Option auf der öffentlichen Produktseite und im Warenkorb. Die Angaben dieser Fassung sind unveränderlich.',
|
||||
'zeilen' => [
|
||||
['text' => 'Preis: '.$option['price'], 'neben' => $active->grant_kind === 'kauf' ? 'Kauf mit Testzahlung' : CatalogLabels::vergabe($active)],
|
||||
['text' => 'Geeignet für: '.$option['for'], 'neben' => $option['term']],
|
||||
['text' => 'Rechte: '.($rechte !== '' ? $rechte : 'keine'), 'neben' => null],
|
||||
['text' => 'Zugrunde liegender Inhalt: '.($inhalt !== '' ? $inhalt : '–'), 'neben' => null],
|
||||
['text' => 'Status: '.($kaufbar ? 'Öffentlich kaufbar' : 'Nicht als Kauf angeboten'), 'neben' => $kaufbar ? 'Aktive Fassung '.$active->number : null],
|
||||
['text' => 'Produktseite: '.($seite !== null ? ($seite->display_title ?: $seite->designation) : 'noch nicht zugeordnet'), 'neben' => $seite !== null ? 'Option „'.$offer->optionName().'“' : 'Mit „Geänderte Fassung aktivieren“ zuordnen.'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Aufgelöster Leistungsumfang in lesbaren Fähigkeiten (dieselben Bezeichnungen wie beim Rechteprofil).
|
||||
*
|
||||
|
||||
@@ -22,7 +22,7 @@ class ListPillars extends ListRecords
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Die fachlichen Säulen des Materials. Eine veröffentlichte Säule ist ein Themenbereich der Website. Ein Medium und eine Seite können mehreren Säulen zugeordnet sein.';
|
||||
return 'Die fachlichen Säulen des Materials. Eine veröffentlichte Säule ist ein Themenbereich der Website. Medien, Module, Programme, Lizenzartikel und Seiten können mehreren Säulen zugeordnet sein. Hier ist die einzige Pflegestelle der Säulen.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
@@ -50,11 +50,28 @@ protected function getHeaderActions(): array
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Zuordnungen aller Objektarten; ohne Zuordnung wie bisher „0 Medien“.
|
||||
*/
|
||||
private function usageLabel(PillarService $service, Pillar $pillar): string
|
||||
{
|
||||
$usage = [
|
||||
'medien' => (int) $pillar->elements_count,
|
||||
'zusammenstellungen' => (int) $pillar->compositions_count,
|
||||
'lizenzartikel' => (int) $pillar->license_articles_count,
|
||||
'seiten' => (int) $pillar->pages_count,
|
||||
];
|
||||
|
||||
return array_sum($usage) === 0 ? '0 Medien' : $service->usageText($usage);
|
||||
}
|
||||
|
||||
protected function catalogRows(): array
|
||||
{
|
||||
$rows = [];
|
||||
|
||||
foreach (Pillar::query()->withCount('elements')->orderBy('sort_order')->orderBy('name')->get() as $pillar) {
|
||||
$service = app(PillarService::class);
|
||||
|
||||
foreach (Pillar::query()->withCount(['elements', 'compositions', 'licenseArticles', 'pages'])->orderBy('sort_order')->orderBy('name')->get() as $pillar) {
|
||||
$public = $pillar->published_at !== null;
|
||||
$url = PillarResource::getUrl('edit', ['record' => $pillar]);
|
||||
$rows[] = [
|
||||
@@ -66,7 +83,7 @@ protected function catalogRows(): array
|
||||
'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'],
|
||||
['label' => $this->usageLabel($service, $pillar), 'ton' => 'neutral'],
|
||||
],
|
||||
'zustand' => [$public ? 'oeffentlich' : 'intern'],
|
||||
'aktionen' => [['label' => 'Bearbeiten', 'href' => $url, 'icon' => 'stift']],
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarService;
|
||||
|
||||
/**
|
||||
* Fachliche Säulen im Redaktionsmanager von Modul, Programm und Lizenzartikel (wie bei Medien): Die Auswahl kommt aus
|
||||
* der zentralen Säulenverwaltung, die Zuordnung ersetzt die bisherige vollständig und bleibt beim Speichern anderer
|
||||
* Angaben erhalten, weil der gespeicherte Stand geladen und mitgeschrieben wird.
|
||||
*
|
||||
* Eine Zuordnung veröffentlicht nichts: Ob eine Säule eine Themenseite hat, entscheidet allein die Säulenverwaltung.
|
||||
*/
|
||||
trait AssignsPillars
|
||||
{
|
||||
/** @var list<int|string> */
|
||||
public array $pillarIds = [];
|
||||
|
||||
/**
|
||||
* @return array{legend: string, model: string, values: list<array{id: int, label: string}>}|null
|
||||
*/
|
||||
public function pillarGroup(): ?array
|
||||
{
|
||||
$values = Pillar::query()->orderBy('sort_order')->orderBy('name')->get(['id', 'name'])
|
||||
->map(fn (Pillar $pillar): array => ['id' => (int) $pillar->id, 'label' => (string) $pillar->name])
|
||||
->all();
|
||||
|
||||
return $values === [] ? null : ['legend' => 'Fachliche Säulen', 'model' => 'pillarIds', 'values' => $values];
|
||||
}
|
||||
|
||||
protected function loadPillarIds(Composition|LicenseArticle $subject): void
|
||||
{
|
||||
$this->pillarIds = $subject->pillars()->pluck('pillars.id')->map(fn (mixed $id): string => (string) (int) $id)->all();
|
||||
}
|
||||
|
||||
protected function persistPillarIds(Composition|LicenseArticle $subject): void
|
||||
{
|
||||
app(PillarService::class)->assign($subject, array_map(intval(...), $this->pillarIds));
|
||||
}
|
||||
|
||||
protected function pillarsUnsaved(Composition|LicenseArticle $subject): bool
|
||||
{
|
||||
$stored = $subject->pillars()->pluck('pillars.id')->map(fn (mixed $id): int => (int) $id)->all();
|
||||
$current = array_map(intval(...), $this->pillarIds);
|
||||
sort($stored);
|
||||
sort($current);
|
||||
|
||||
return $stored !== $current;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\EditorialVocabulary;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Cms\Catalog\PublicMaterialReader;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Http\Controllers\ContentPreviewController;
|
||||
@@ -27,6 +28,9 @@ trait ChoosesMedia
|
||||
|
||||
public string $pickerDimension = '';
|
||||
|
||||
/** Filter „Fachliche Säule“ (Kennung der Säule aus der zentralen Säulenverwaltung). */
|
||||
public string $pickerSaeule = '';
|
||||
|
||||
/** Filter „Fachliche Materialart“ (Kennung), gleiche Regel wie Medieneditor und Medienfilter. */
|
||||
public string $pickerMaterialart = '';
|
||||
|
||||
@@ -108,6 +112,8 @@ public function pickerResult(): array
|
||||
$this->pickerKind,
|
||||
$this->pickerDimension,
|
||||
$this->pickerExceptId(),
|
||||
false,
|
||||
ctype_digit($this->pickerSaeule) ? (int) $this->pickerSaeule : 0,
|
||||
));
|
||||
}
|
||||
|
||||
@@ -204,6 +210,7 @@ protected function resetPicker(string $purpose): void
|
||||
$this->pickerOpen = true;
|
||||
$this->pickerQuery = '';
|
||||
$this->pickerDimension = '';
|
||||
$this->pickerSaeule = '';
|
||||
$this->pickerMaterialart = '';
|
||||
$this->pickerInspected = '';
|
||||
$this->pickerSelected = '';
|
||||
@@ -239,6 +246,17 @@ private function filterByMaterialart(array $result): array
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Säulen für den Picker-Filter, in der Reihenfolge der Säulenverwaltung.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function pickerSaeulen(): array
|
||||
{
|
||||
return Pillar::query()->orderBy('sort_order')->orderBy('name')->pluck('name', 'id')
|
||||
->mapWithKeys(fn (string $name, int|string $id): array => [(string) $id => $name])->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Einordnungsfilter des Pickers: dieselbe Filterregel wie Medien- und Kompositionslisten (verwendete inaktive Werte
|
||||
* bleiben auffindbar, ein gewählter Filter bleibt sichtbar).
|
||||
|
||||
@@ -2,8 +2,14 @@
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Cms\Widgets\Support\WebsiteImage;
|
||||
use App\Domain\Media\CompositionStill;
|
||||
use App\Domain\Media\FilmStill;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
/**
|
||||
@@ -31,6 +37,128 @@ public function openWebsiteImagePicker(string $pfad): void
|
||||
$this->forceRenderForPicker();
|
||||
}
|
||||
|
||||
/**
|
||||
* Medien- und Materialkarte: das Vorschaubild des Films als Bild für die Website übernehmen. Es entsteht ein Bild
|
||||
* im Medienmanager (einmal gespeichert), das im Bildfeld ausgewählt wird. Die Datei des Films bleibt geschützt.
|
||||
*/
|
||||
public function adoptFilmThumbnail(string $pfad, int $elementId): void
|
||||
{
|
||||
$this->adoptFilmStill($pfad, $elementId, fn (FilmStill $stills, ContentElement $film): ContentElement => $stills->fromThumbnail($film, auth('staff')->user()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Medien- und Materialkarte: eine Stelle des Films wählen und als Bild für die Website übernehmen.
|
||||
*/
|
||||
public function adoptFilmFrame(string $pfad, int $elementId, string $sekunde): void
|
||||
{
|
||||
if (! is_numeric($sekunde)) {
|
||||
Notification::make()->danger()->title('Bitte eine Zeitposition in Sekunden angeben.')->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->adoptFilmStill($pfad, $elementId, fn (FilmStill $stills, ContentElement $film): ContentElement => $stills->fromSecond($film, (float) $sekunde, auth('staff')->user()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Programm- und Modulkarte: das Vorschaubild des Programms oder Moduls als Bild für die Website übernehmen
|
||||
* (Bild-Medium im Medienmanager, einmal kopiert).
|
||||
*/
|
||||
public function adoptCompositionThumbnail(string $pfad, int $compositionId): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
if ($this->imageTargetIsInvalid($pfad)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$composition = Composition::query()->find($compositionId);
|
||||
|
||||
if (! $composition instanceof Composition) {
|
||||
return;
|
||||
}
|
||||
|
||||
$stills = app(CompositionStill::class);
|
||||
|
||||
try {
|
||||
$still = $stills->fromThumbnail($composition, auth('staff')->user());
|
||||
} catch (DomainRuleException $exception) {
|
||||
Notification::make()->danger()->title($exception->getMessage())->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
data_set($this, $pfad, $still->id);
|
||||
$this->announceAdoptedStill($still, $stills->reused, 'Dieses Vorschaubild war schon übernommen.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable(FilmStill, ContentElement): ContentElement $make
|
||||
*/
|
||||
private function adoptFilmStill(string $pfad, int $elementId, callable $make): void
|
||||
{
|
||||
abort_unless(ContentElementResource::editor(), 403);
|
||||
|
||||
if ($this->imageTargetIsInvalid($pfad)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$film = ContentElement::query()->with('editorialContentKind')->find($elementId);
|
||||
|
||||
if (! $film instanceof ContentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
$stills = app(FilmStill::class);
|
||||
|
||||
try {
|
||||
$still = $make($stills, $film);
|
||||
} catch (DomainRuleException $exception) {
|
||||
Notification::make()->danger()->title($exception->getMessage())->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
data_set($this, $pfad, $still->id);
|
||||
$this->announceAdoptedStill($still, $stills->reused, 'Diese Stelle war schon übernommen.');
|
||||
}
|
||||
|
||||
/** Nur das Bildfeld eines Widgets oder Abschnitts ist ein zulässiges Ziel (…image). */
|
||||
private function imageTargetIsInvalid(string $pfad): bool
|
||||
{
|
||||
return preg_match('/^(data|mountedActions\.\d+\.data)(\.[A-Za-z0-9_-]+)+\.image$/', $pfad) !== 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Meldung nach dem tatsächlichen Stand des Bildes: neu angelegt, schon vorhanden und freigegeben, wird verarbeitet
|
||||
* oder Website-Freigabe zurückgenommen (bleibt zurückgenommen).
|
||||
*/
|
||||
private function announceAdoptedStill(ContentElement $still, bool $reused, string $reusedText): void
|
||||
{
|
||||
$title = ($still->display_title ?: $still->working_title);
|
||||
|
||||
if (! $reused) {
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Im Medienmanager angelegt: „'.$title.'“')
|
||||
->body('Das Bild ist als Kartenbild ausgewählt. Nach der Verarbeitung wird es für die Website freigegeben; dort lässt sich die Freigabe auch zurücknehmen.')
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (app(WebsiteMedia::class)->present($still) !== null) {
|
||||
Notification::make()->success()->title('Bereits im Medienmanager: „'.$title.'“')->body($reusedText.' Das Bild ist als Kartenbild ausgewählt.')->send();
|
||||
} elseif (blank($still->thumbnail_path) && blank($still->thumbnail_error)) {
|
||||
Notification::make()->success()->title('Bereits im Medienmanager: „'.$title.'“')->body('Das Bild wird noch verarbeitet und danach für die Website freigegeben.')->send();
|
||||
} else {
|
||||
Notification::make()->warning()->title('Bild ausgewählt, aber nicht für die Website freigegeben: „'.$title.'“')
|
||||
->body($reusedText.' Die Website-Freigabe wurde zurückgenommen. Das Bild erscheint öffentlich erst wieder, wenn sie im Medienmanager (Reiter „Website“) erneut gegeben wird.')
|
||||
->persistent()
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filament rendert bei offenen Aktionsdialogen nur den Dialogteil neu; der Picker liegt darüber und braucht die
|
||||
* ganze Seite.
|
||||
|
||||
@@ -272,7 +272,7 @@ public function search(string $query, string $scope, int $exceptCompositionId):
|
||||
/**
|
||||
* @return array{items: list<array<string, string|null>>, more: bool}
|
||||
*/
|
||||
public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId, bool $elementsOnly = false): array
|
||||
public function browse(string $query, string $kind, string $dimension, int $exceptCompositionId, bool $elementsOnly = false, int $pillarId = 0): array
|
||||
{
|
||||
$query = trim($query);
|
||||
$like = '%'.str_replace(['%', '_'], ['', ''], $query).'%';
|
||||
@@ -284,8 +284,8 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
$latestElements = ContentElementVersion::query()
|
||||
->selectRaw('MAX(id)')
|
||||
->whereIn('status', [ContentVersionStatus::Bereit, ContentVersionStatus::Entwurf])
|
||||
->whereHas('element', function ($builder) use ($query, $like, $kind, $dimensionId): void {
|
||||
$this->constrainElement($builder, $query, $like, $kind, $dimensionId);
|
||||
->whereHas('element', function ($builder) use ($query, $like, $kind, $dimensionId, $pillarId): void {
|
||||
$this->constrainElement($builder, $query, $like, $kind, $dimensionId, $pillarId);
|
||||
})
|
||||
->groupBy('content_element_id');
|
||||
$elements = ContentElementVersion::query()
|
||||
@@ -309,7 +309,7 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
->selectRaw('MAX(id)')
|
||||
->where('status', ContentVersionStatus::Bereit)
|
||||
->where('composition_id', '!=', $exceptCompositionId)
|
||||
->whereHas('composition', function ($builder) use ($query, $like, $kind, $dimensionId): void {
|
||||
->whereHas('composition', function ($builder) use ($query, $like, $kind, $dimensionId, $pillarId): void {
|
||||
if ($kind === 'modul') {
|
||||
$builder->where('kind', CompositionKind::Uebung);
|
||||
}
|
||||
@@ -318,6 +318,10 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
$builder->whereIn('id', $this->dimensionSubjectIds(Composition::class, $dimensionId));
|
||||
}
|
||||
|
||||
if ($pillarId > 0) {
|
||||
$builder->whereIn('id', $this->pillarSubjectIds(Composition::class, $pillarId));
|
||||
}
|
||||
|
||||
if ($query === '') {
|
||||
return;
|
||||
}
|
||||
@@ -370,6 +374,10 @@ public function browse(string $query, string $kind, string $dimension, int $exce
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($pillarId > 0 && ! in_array($composition->id, $this->pillarSubjectIds(Composition::class, $pillarId), true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = $this->compositionTitle($composition);
|
||||
|
||||
if ($query !== '' && ! str_contains(mb_strtolower($title.' '.(string) ($composition->summary ?? '')), mb_strtolower($query))) {
|
||||
@@ -564,7 +572,7 @@ private function withVisibility(array $rows): array
|
||||
/**
|
||||
* @param Builder<ContentElement> $builder
|
||||
*/
|
||||
private function constrainElement($builder, string $query, string $like, string $kind, int $dimensionId): void
|
||||
private function constrainElement($builder, string $query, string $like, string $kind, int $dimensionId, int $pillarId = 0): void
|
||||
{
|
||||
$outputs = match ($kind) {
|
||||
'film' => ['film'],
|
||||
@@ -583,6 +591,10 @@ private function constrainElement($builder, string $query, string $like, string
|
||||
$builder->whereIn('id', $this->dimensionSubjectIds(ContentElement::class, $dimensionId));
|
||||
}
|
||||
|
||||
if ($pillarId > 0) {
|
||||
$builder->whereIn('id', $this->pillarSubjectIds(ContentElement::class, $pillarId));
|
||||
}
|
||||
|
||||
if ($query === '') {
|
||||
return;
|
||||
}
|
||||
@@ -597,6 +609,22 @@ private function constrainElement($builder, string $query, string $like, string
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Direkt einer Säule zugeordnete Medien oder Module und Programme (zentrale Säulenverwaltung).
|
||||
*
|
||||
* @param class-string<Model> $class
|
||||
* @return list<int>
|
||||
*/
|
||||
private function pillarSubjectIds(string $class, int $pillarId): array
|
||||
{
|
||||
[$table, $column] = $class === Composition::class
|
||||
? ['composition_pillar', 'composition_id']
|
||||
: ['content_element_pillar', 'content_element_id'];
|
||||
|
||||
return DB::table($table)->where('pillar_id', $pillarId)->pluck($column)
|
||||
->map(fn (mixed $id): int => (int) $id)->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param class-string<Model> $class
|
||||
* @return list<int>
|
||||
|
||||
@@ -7,9 +7,12 @@
|
||||
use App\Domain\Catalog\ContentVersionStatus;
|
||||
use App\Domain\Catalog\EditorialVocabulary;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarFilterCompat;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Livewire\Attributes\Url;
|
||||
|
||||
/**
|
||||
@@ -29,6 +32,10 @@ trait ListsCompositions
|
||||
#[Url]
|
||||
public string $pillar = '';
|
||||
|
||||
/** Fachliche Säule (zentrale Säulenverwaltung), direkt zugeordnet. */
|
||||
#[Url(as: 'saeule', except: '')]
|
||||
public string $saeule = '';
|
||||
|
||||
#[Url]
|
||||
public string $visibility = 'alle';
|
||||
|
||||
@@ -39,7 +46,7 @@ protected function fixedKind(): ?CompositionKind
|
||||
|
||||
protected function bestandFilterEigenschaften(): array
|
||||
{
|
||||
return ['query', 'kindFilter', 'pillar', 'visibility'];
|
||||
return ['query', 'kindFilter', 'pillar', 'saeule', 'visibility'];
|
||||
}
|
||||
|
||||
public function resetFilters(): void
|
||||
@@ -47,13 +54,14 @@ public function resetFilters(): void
|
||||
$this->query = '';
|
||||
$this->kindFilter = 'alle';
|
||||
$this->pillar = '';
|
||||
$this->saeule = '';
|
||||
$this->visibility = 'alle';
|
||||
$this->bestandGrenze = Bestand::SCHRITT;
|
||||
}
|
||||
|
||||
public function hasActiveFilters(): bool
|
||||
{
|
||||
return trim($this->query) !== '' || $this->kindFilter !== 'alle' || $this->pillar !== '' || $this->visibility !== 'alle';
|
||||
return trim($this->query) !== '' || $this->kindFilter !== 'alle' || $this->pillar !== '' || $this->saeule !== '' || $this->visibility !== 'alle';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,6 +69,7 @@ public function hasActiveFilters(): bool
|
||||
*/
|
||||
public function bestand(): array
|
||||
{
|
||||
$this->normalizeLegacyPillarFilter();
|
||||
$fixed = $this->fixedKind();
|
||||
$einheit = match ($fixed) {
|
||||
CompositionKind::Kurs => ['Programm', 'Programme'],
|
||||
@@ -90,9 +99,14 @@ public function bestand(): array
|
||||
'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,
|
||||
]],
|
||||
'weitere' => [
|
||||
...($this->pillarOptions() === [] ? [] : [[
|
||||
'eigenschaft' => 'saeule', 'label' => 'Fachliche Säule', 'vorgabe' => '', 'alle' => 'Alle Säulen', 'optionen' => $this->pillarOptions(),
|
||||
]]),
|
||||
...($gruppen === [] ? [] : [[
|
||||
'eigenschaft' => 'pillar', 'label' => 'Fachliche Einordnung', 'vorgabe' => '', 'alle' => 'Alle Einordnungen', 'gruppen' => $gruppen,
|
||||
]]),
|
||||
],
|
||||
'zeilen' => $this->entries(),
|
||||
'einheit' => $einheit,
|
||||
'leer' => [
|
||||
@@ -124,7 +138,9 @@ public function entries(): array
|
||||
$needle = mb_strtolower(trim($this->query));
|
||||
$catalog = app(EditorialCatalog::class);
|
||||
$offered = $catalog->offeredCompositionIds();
|
||||
$this->normalizeLegacyPillarFilter();
|
||||
$pillarIds = $this->pillar === '' ? null : $this->pillarSubjects((int) $this->pillar);
|
||||
$saeuleIds = ctype_digit($this->saeule) && $this->saeule !== '' ? $this->saeuleSubjects((int) $this->saeule) : null;
|
||||
$fixed = $this->fixedKind();
|
||||
$kinds = $fixed !== null ? [$fixed] : match ($this->kindFilter) {
|
||||
'programm' => [CompositionKind::Kurs],
|
||||
@@ -149,6 +165,10 @@ public function entries(): array
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($saeuleIds !== null && ! in_array($composition->id, $saeuleIds, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$stand = $catalog->stand($composition);
|
||||
|
||||
if (! $this->matchesVisibility($stand)) {
|
||||
@@ -249,6 +269,36 @@ private function coverMembers(Composition $composition): array
|
||||
return $members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alte Adressen mit einem Säulenwert der Einordnung (`?pillar=…`) gelten für die zentrale Säule.
|
||||
*/
|
||||
private function normalizeLegacyPillarFilter(): void
|
||||
{
|
||||
if (ctype_digit($this->pillar) && $this->pillar !== '' && $this->saeule === '' && is_int($pillar = PillarFilterCompat::pillarOfLegacyValue((int) $this->pillar))) {
|
||||
[$this->saeule, $this->pillar] = [(string) $pillar, ''];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function pillarOptions(): array
|
||||
{
|
||||
return Pillar::query()->orderBy('sort_order')->orderBy('name')->pluck('name', 'id')
|
||||
->mapWithKeys(fn (string $name, int|string $id): array => [(string) $id => $name])->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Direkt zugeordnete Module und Programme einer Säule. Die Säulen der enthaltenen Medien zählen hier nicht.
|
||||
*
|
||||
* @return list<int>
|
||||
*/
|
||||
private function saeuleSubjects(int $pillarId): array
|
||||
{
|
||||
return DB::table('composition_pillar')->where('pillar_id', $pillarId)->pluck('composition_id')
|
||||
->map(fn (mixed $id): int => (int) $id)->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<int>
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
use App\Domain\Catalog\EditorialVocabulary;
|
||||
use App\Domain\Catalog\IdentityDimensionValue;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarFilterCompat;
|
||||
use App\Domain\Catalog\ReleaseContent;
|
||||
use App\Domain\Media\ThumbnailRef;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
@@ -132,15 +133,23 @@ public function cards(array $filters, bool $canEdit): array
|
||||
*/
|
||||
private function normalize(array $filters): array
|
||||
{
|
||||
$saeule = ctype_digit($filters['saeule'] ?? '') ? $filters['saeule'] : '';
|
||||
$einordnung = ctype_digit($filters['einordnung'] ?? '') ? $filters['einordnung'] : '';
|
||||
|
||||
if ($einordnung !== '' && $saeule === '' && is_int($pillar = PillarFilterCompat::pillarOfLegacyValue((int) $einordnung))) {
|
||||
[$saeule, $einordnung] = [(string) $pillar, ''];
|
||||
}
|
||||
|
||||
return [
|
||||
'suche' => trim($filters['suche'] ?? ''),
|
||||
'art' => $this->choice($filters['art'] ?? '', ['film', 'text', 'document', 'bild', 'audio']),
|
||||
'freigabe' => $this->choice($filters['freigabe'] ?? '', ['freigegeben', 'entwurf', 'ohne']),
|
||||
'schutz' => $this->choice($filters['schutz'] ?? '', ['geschuetzt', 'oeffentlich', 'website']),
|
||||
'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'] : '',
|
||||
'saeule' => $saeule,
|
||||
'einordnung' => $einordnung,
|
||||
'inhaltsart' => ctype_digit($filters['inhaltsart'] ?? '') ? $filters['inhaltsart'] : '',
|
||||
'verarbeitung' => $this->choice($filters['verarbeitung'] ?? '', ['fehler', 'uebernahme']),
|
||||
'archiv' => $this->choice($filters['archiv'] ?? '', ['aktiv', 'archiviert', 'alle'], 'aktiv'),
|
||||
@@ -375,6 +384,20 @@ private function matches(ContentElement $element, array $portrait, array $uses,
|
||||
return false;
|
||||
}
|
||||
|
||||
$presentation = $this->isPresentationMedium($element, $portrait['versionCount']);
|
||||
|
||||
if ($filters['schutz'] === 'geschuetzt' && $presentation) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['schutz'] === 'oeffentlich' && ! $presentation) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['schutz'] === 'website' && $element->website_released_at === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($filters['freigabe'] === 'freigegeben' && $portrait['ready'] === null) {
|
||||
return false;
|
||||
}
|
||||
@@ -436,6 +459,15 @@ private function matches(ContentElement $element, array $portrait, array $uses,
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Eigenständiges Präsentationsmedium: Bild, Film oder Hörstück ohne Inhaltsfassung. Es ist für die Website
|
||||
* bestimmt und nicht lizenziert; alles mit einer Inhaltsfassung gilt als geschützt.
|
||||
*/
|
||||
private function isPresentationMedium(ContentElement $element, int $versionCount): bool
|
||||
{
|
||||
return $versionCount === 0 && in_array($element->output_class, ['bild', 'film', 'audio'], true);
|
||||
}
|
||||
|
||||
private function matchesArt(ContentElement $element, string $art): bool
|
||||
{
|
||||
if ($art === '') {
|
||||
@@ -490,6 +522,8 @@ private function card(ContentElement $element, array $portrait, array $uses, arr
|
||||
'image' => ThumbnailRef::url('editorial.card', 'element', $element->id, $element->thumbnail_path),
|
||||
'imageAlt' => trim((string) ($element->thumbnail_alt ?: $element->working_title)),
|
||||
'imageNote' => $this->imageNote($element),
|
||||
'presentation' => $this->isPresentationMedium($element, $portrait['versionCount']),
|
||||
'websiteReleased' => $element->website_released_at !== null,
|
||||
'stand' => $portrait['stand'],
|
||||
'standTone' => $portrait['standTone'],
|
||||
'draftNote' => $portrait['draftNote'],
|
||||
|
||||
@@ -43,7 +43,7 @@ public static function fields(bool $creating, ?ContentElement $element = null):
|
||||
->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.')
|
||||
->helperText('Bild, Film oder Hörstück ohne fachliche Inhaltsfassung, zum Beispiel ein Trailer, der ungeschützt auf der Website laufen soll. Der Film muss dafür MP4 (H.264) oder WebM sein. Er wird nicht lizenziert und erst nach „Für die Website freigeben“ öffentlich.')
|
||||
->visible(fn ($get): bool => in_array($get('shape'), ['film', 'audio', 'bild'], true));
|
||||
} elseif ($element?->output_class === 'text') {
|
||||
$fields[] = Textarea::make('body')->label('Text')->rows(8)->required();
|
||||
@@ -94,20 +94,10 @@ public static function create(array $data, bool $hold): ContentElement
|
||||
{
|
||||
$service = app(ContentService::class);
|
||||
[$kind, $output] = self::shape($data['shape'] ?? null);
|
||||
$element = $service->createElement($kind, $output, (string) $data['working_title']);
|
||||
self::remember($element, $data);
|
||||
$incoming = null;
|
||||
|
||||
if ($output === 'text') {
|
||||
$body = trim((string) ($data['body'] ?? ''));
|
||||
|
||||
if ($body === '') {
|
||||
throw new DomainRuleException('Der Text braucht einen Inhalt.');
|
||||
}
|
||||
|
||||
$hold
|
||||
? $service->draftElementVersion($element, $body)
|
||||
: $service->publishElementVersion($element, $body);
|
||||
} else {
|
||||
if ($output !== 'text') {
|
||||
// Alles prüfen, bevor etwas angelegt wird: Eine abgelehnte Datei darf kein leeres Medium hinterlassen.
|
||||
$incoming = IncomingFile::store($data['incoming'] ?? null);
|
||||
|
||||
if ($incoming === null) {
|
||||
@@ -126,6 +116,25 @@ public static function create(array $data, bool $hold): ContentElement
|
||||
throw new DomainRuleException('Diese Datei passt nicht zur gewählten Art.');
|
||||
}
|
||||
|
||||
if (! empty($data['without_version']) && in_array($output, ['bild', 'film', 'audio'], true)) {
|
||||
app(PresentationFile::class)->validate($output, $incoming);
|
||||
}
|
||||
}
|
||||
|
||||
$element = $service->createElement($kind, $output, (string) $data['working_title']);
|
||||
self::remember($element, $data);
|
||||
|
||||
if ($output === 'text') {
|
||||
$body = trim((string) ($data['body'] ?? ''));
|
||||
|
||||
if ($body === '') {
|
||||
throw new DomainRuleException('Der Text braucht einen Inhalt.');
|
||||
}
|
||||
|
||||
$hold
|
||||
? $service->draftElementVersion($element, $body)
|
||||
: $service->publishElementVersion($element, $body);
|
||||
} else {
|
||||
if (! empty($data['without_version']) && in_array($output, ['bild', 'film', 'audio'], true)) {
|
||||
app(PresentationFile::class)->store($element, $incoming);
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,320 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Support;
|
||||
|
||||
use App\Domain\Catalog\ArticleRelease;
|
||||
use App\Domain\Catalog\Bundle;
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\BundleStatus;
|
||||
use App\Domain\Catalog\BundleVersion;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\OfferVersion;
|
||||
use App\Domain\Catalog\ReleaseStatus;
|
||||
use App\Domain\Catalog\StatusValue;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Filament\Resources\LicenseArticles\LicenseArticleResource;
|
||||
use App\Filament\Resources\Offers\OfferResource;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/**
|
||||
* Voraussetzungen bis zur Veröffentlichung für Lizenzartikel, Paket und Angebot in einer gemeinsamen Form
|
||||
* (Verwaltungsstandard 14, Abschnitt 9: eine Komponente für gleiche Aufgaben). Die Klasse liest nur; sie ändert keine
|
||||
* fachliche Regel. Jeder Schritt nennt, was fehlt, und bietet den Weg dorthin an.
|
||||
*
|
||||
* Schritt: ['titel', 'text', 'stand' => erledigt|offen|optional, 'aktion' => ['label', 'wire'|'href']|null]
|
||||
* Ergebnis: ['schritte', 'bereit' (alle Pflichtschritte erledigt), 'naechster' (Text des ersten offenen Pflichtschritts)].
|
||||
*/
|
||||
class PublicationReadiness
|
||||
{
|
||||
public function __construct(
|
||||
private readonly BundleService $bundles,
|
||||
private readonly OfferService $offers,
|
||||
private readonly PublicCatalogReader $catalog,
|
||||
) {}
|
||||
|
||||
/** Ein Artikel ist verwendbar, wenn sein aktueller Stand veröffentlicht ist. */
|
||||
public function articleUsable(LicenseArticle $article): bool
|
||||
{
|
||||
$release = $article->currentRelease;
|
||||
|
||||
return $release instanceof ArticleRelease && StatusValue::of($release->status) === ReleaseStatus::Veroeffentlicht->value;
|
||||
}
|
||||
|
||||
/** Anzeige in Auswahllisten: Name, Kennung und Stand statt der bloßen Kennung. */
|
||||
public function articleLabel(LicenseArticle $article): string
|
||||
{
|
||||
$title = $this->articleName($article);
|
||||
$name = $title !== '' ? $title.' ('.$article->code.')' : (string) $article->code;
|
||||
$release = $article->currentRelease;
|
||||
|
||||
if ($this->articleUsable($article)) {
|
||||
return $name.' · Stand '.$release->number;
|
||||
}
|
||||
|
||||
return $name.' · '.($release === null ? 'noch ohne Stand, nicht verwendbar' : 'Stand gesperrt, nicht verwendbar');
|
||||
}
|
||||
|
||||
/** Name wie in der Redaktion: eigener Name oder Name des Inhalts, sonst der Arbeitstitel; leer ohne beides. */
|
||||
public function articleName(LicenseArticle $article): string
|
||||
{
|
||||
return app(ProductOptions::class)->articleName($article);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function articleOptions(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (LicenseArticle::query()->with('currentRelease')->orderBy('code')->get() as $article) {
|
||||
$options[$article->id] = $this->articleLabel($article);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Veröffentlichte Paketfassungen mit ihren Artikeln, damit die Auswahl zeigt, was verkauft wird.
|
||||
*
|
||||
* @return array<int, string>
|
||||
*/
|
||||
public function bundleVersionOptions(): array
|
||||
{
|
||||
$options = [];
|
||||
|
||||
foreach (BundleVersion::query()->where('status', BundleStatus::Veroeffentlicht)->with('bundle')->orderBy('id')->get() as $version) {
|
||||
try {
|
||||
$codes = LicenseArticle::query()->whereIn('id', $this->bundles->articleIds($version))->orderBy('code')->pluck('code')->all();
|
||||
} catch (DomainRuleException) {
|
||||
$codes = [];
|
||||
}
|
||||
|
||||
$options[$version->id] = $version->bundle->name.' · Fassung '.$version->number.' ('.($codes === [] ? 'ohne Artikel' : implode(', ', $codes)).')';
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Artikel einer Auswahl, die keinen verwendbaren Stand haben.
|
||||
*
|
||||
* @param list<int> $articleIds
|
||||
* @return list<LicenseArticle>
|
||||
*/
|
||||
public function unusableArticles(array $articleIds): array
|
||||
{
|
||||
return LicenseArticle::query()->with('currentRelease')->whereIn('id', array_unique($articleIds))->orderBy('code')->get()
|
||||
->reject(fn (LicenseArticle $article): bool => $this->articleUsable($article))
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<LicenseArticle> $articles
|
||||
*/
|
||||
public function unusableMessage(array $articles, string $zweck): string
|
||||
{
|
||||
$namen = implode(', ', array_map(fn (LicenseArticle $article): string => '„'.($this->articleName($article) ?: $article->code).'“ ('.$article->code.')', $articles));
|
||||
|
||||
return (count($articles) === 1 ? 'Der Lizenzartikel ' : 'Die Lizenzartikel ').$namen
|
||||
.(count($articles) === 1 ? ' hat' : ' haben')
|
||||
.' noch keinen veröffentlichten Stand und vergibt'.(count($articles) === 1 ? '' : ' keine').' keine Inhalte. '
|
||||
.'Lege zuerst am Artikel mit „Inhalt festlegen“ den Inhalt fest, bevor du '.$zweck.'.';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function forArticle(LicenseArticle $article): array
|
||||
{
|
||||
$article->loadMissing('currentRelease');
|
||||
$usable = $this->articleUsable($article);
|
||||
$release = $article->currentRelease;
|
||||
$inUse = $this->articleInUse($article);
|
||||
|
||||
return $this->result([
|
||||
[
|
||||
'titel' => 'Inhalt festlegen',
|
||||
'text' => $usable
|
||||
? 'Stand '.$release->number.' ist veröffentlicht und bestimmt, welche Inhalte der Artikel lizenziert.'
|
||||
: 'Der Artikel lizenziert noch nichts. Wähle den freigegebenen Inhalt (Medium, Modul oder Programm), den er umfassen soll.',
|
||||
'stand' => $usable ? 'erledigt' : 'offen',
|
||||
'aktion' => $usable ? null : ['label' => 'Inhalt festlegen', 'wire' => "mountAction('release')"],
|
||||
],
|
||||
[
|
||||
'titel' => 'Name und Beschreibung',
|
||||
'text' => $this->articleName($article) !== ''
|
||||
? 'Der Name „'.$this->articleName($article).'“ erscheint in Paketen, Angeboten, im Shop und in der Bibliothek.'
|
||||
: 'Ohne Name erscheint die Kennung „'.$article->code.'“. Name, Teaser und Beschreibung pflegst du in der Redaktion.',
|
||||
'stand' => $this->articleName($article) !== '' ? 'erledigt' : 'optional',
|
||||
'aktion' => $this->articleName($article) !== '' ? null : ['label' => 'Redaktion bearbeiten', 'wire' => "openRedaktion('texte')"],
|
||||
],
|
||||
[
|
||||
'titel' => 'In einem Paket oder Angebot verwenden',
|
||||
'text' => $inUse
|
||||
? 'Der Artikel ist in einem Paket oder Angebot enthalten.'
|
||||
: 'Verkauft wird der Artikel erst über ein Angebot, allein oder in einem Paket.',
|
||||
'stand' => $inUse ? 'erledigt' : 'offen',
|
||||
'aktion' => $inUse ? null : ['label' => 'Angebote öffnen', 'href' => OfferResource::getUrl('index')],
|
||||
'pflicht' => false,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function forBundle(Bundle $bundle): array
|
||||
{
|
||||
$published = $bundle->versions()->where('status', BundleStatus::Veroeffentlicht)->orderByDesc('number')->first();
|
||||
$missing = [];
|
||||
|
||||
if ($published instanceof BundleVersion) {
|
||||
try {
|
||||
$missing = $this->unusableArticles($this->bundles->articleIds($published));
|
||||
} catch (DomainRuleException) {
|
||||
$missing = [];
|
||||
}
|
||||
}
|
||||
|
||||
$offered = $published instanceof BundleVersion && $this->bundleOffered($bundle);
|
||||
|
||||
return $this->result([
|
||||
[
|
||||
'titel' => 'Bestandteile festlegen',
|
||||
'text' => $published instanceof BundleVersion
|
||||
? 'Fassung '.$published->number.' ist veröffentlicht und unveränderlich.'
|
||||
: 'Wähle die Lizenzartikel und Pakete, die zusammen verkauft werden, und veröffentliche die Fassung.',
|
||||
'stand' => $published instanceof BundleVersion ? 'erledigt' : 'offen',
|
||||
'aktion' => $published instanceof BundleVersion ? null : ['label' => 'Bestandteile festlegen', 'wire' => "mountAction('publish')"],
|
||||
],
|
||||
[
|
||||
'titel' => 'Jeder enthaltene Artikel hat einen Inhalt',
|
||||
'text' => ! $published instanceof BundleVersion
|
||||
? 'Wird geprüft, sobald die Bestandteile feststehen.'
|
||||
: ($missing === []
|
||||
? 'Alle enthaltenen Artikel haben einen veröffentlichten Stand.'
|
||||
: 'Ohne Stand und damit ohne Inhalt: '.implode(', ', array_map(fn (LicenseArticle $article): string => (string) $article->code, $missing)).'. Ein Angebot lässt sich erst aktivieren, wenn jeder Artikel einen Stand hat.'),
|
||||
'stand' => $published instanceof BundleVersion && $missing === [] ? 'erledigt' : 'offen',
|
||||
'aktion' => $missing === [] ? null : ['label' => 'Artikel „'.$missing[0]->code.'“ öffnen', 'href' => LicenseArticleResource::getUrl('view', ['record' => $missing[0]])],
|
||||
],
|
||||
[
|
||||
'titel' => 'Angebot mit Preis und Rechten',
|
||||
'text' => $offered
|
||||
? 'Ein aktives Angebot verkauft dieses Paket.'
|
||||
: 'Verkauft wird das Paket erst über ein Angebot. Dort wählst du die Paketfassung, die Rechte und den Preis.',
|
||||
'stand' => $offered ? 'erledigt' : 'offen',
|
||||
'aktion' => $offered ? null : ['label' => 'Angebote öffnen', 'href' => OfferResource::getUrl('index')],
|
||||
'pflicht' => false,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function forOffer(Offer $offer): array
|
||||
{
|
||||
$active = $offer->versions()->where('status', 'aktiv')->orderByDesc('number')->first();
|
||||
$hasActive = $active instanceof OfferVersion;
|
||||
$articleIds = $hasActive ? $active->resolvedScopes()->pluck('license_article_id')->map(fn ($id): int => (int) $id)->all() : [];
|
||||
$missing = $this->unusableArticles($articleIds);
|
||||
$buyable = $hasActive && $this->offers->purchasableVersion($offer) !== null;
|
||||
$page = $offer->composition;
|
||||
$shown = $page !== null && $this->catalog->shownVersion($page) !== null;
|
||||
$pageName = $page !== null ? (string) ($page->display_title ?: $page->designation) : '';
|
||||
$activate = ['label' => $hasActive ? 'Geänderte Fassung aktivieren' : 'Angebot konfigurieren', 'wire' => "mountAction('activate')"];
|
||||
|
||||
return $this->result([
|
||||
[
|
||||
'titel' => 'Artikel oder Paket, Rechte, Preis und Vergabe festlegen',
|
||||
'text' => $hasActive
|
||||
? 'Fassung '.$active->number.' ist aktiv.'
|
||||
: 'Wähle, was verkauft wird (Lizenzartikel oder Paketfassung), welche Nutzungsrechte dazugehören, für wen es gilt und was es kostet. Erst „Fassung aktivieren“ macht das Angebot gültig.',
|
||||
'stand' => $hasActive ? 'erledigt' : 'offen',
|
||||
'aktion' => $hasActive ? null : $activate,
|
||||
],
|
||||
[
|
||||
'titel' => 'Inhalt vorhanden',
|
||||
'text' => ! $hasActive
|
||||
? 'Wird geprüft, sobald die Fassung aktiv ist.'
|
||||
: ($missing === []
|
||||
? 'Jeder enthaltene Lizenzartikel hat einen veröffentlichten Stand.'
|
||||
: 'Ohne Stand und damit ohne Inhalt: '.implode(', ', array_map(fn (LicenseArticle $article): string => (string) $article->code, $missing)).'. Käufer würden nichts erhalten.'),
|
||||
'stand' => $hasActive && $missing === [] ? 'erledigt' : 'offen',
|
||||
'aktion' => $missing === [] ? null : ['label' => 'Artikel „'.$missing[0]->code.'“ öffnen', 'href' => LicenseArticleResource::getUrl('view', ['record' => $missing[0]])],
|
||||
],
|
||||
[
|
||||
'titel' => 'Als Kauf mit Preis angeboten',
|
||||
'text' => $buyable
|
||||
? 'Die aktive Fassung ist ein Kauf zu '.Money::format((int) $active->price_cents).'.'
|
||||
: ($hasActive ? 'Die aktive Fassung ist kein Kauf mit Preis (Vergabe: '.CatalogLabels::vergabe($active).'). Im Shop erscheinen nur Käufe.' : 'Wird mit der Fassung festgelegt.'),
|
||||
'stand' => $buyable ? 'erledigt' : 'offen',
|
||||
'aktion' => $buyable ? null : ($hasActive ? $activate : null),
|
||||
],
|
||||
[
|
||||
'titel' => 'Produktseite zuordnen',
|
||||
'text' => $page !== null
|
||||
? 'Zugeordnet: „'.$pageName.'“. Optionen derselben Produktseite sind Alternativen im Warenkorb.'
|
||||
: 'Der Shop zeigt ein Angebot auf der Seite eines Programms. Wähle in der Maske die Produktseite. Ein Paket braucht eine eigene Produktseite, sonst ist es Alternative zu den Einzelangeboten dieser Seite.',
|
||||
'stand' => $page !== null ? 'erledigt' : 'offen',
|
||||
'aktion' => $page !== null ? null : $activate,
|
||||
],
|
||||
[
|
||||
'titel' => 'Produktseite öffentlich',
|
||||
'text' => $page === null
|
||||
? 'Wird geprüft, sobald eine Produktseite zugeordnet ist.'
|
||||
: ($shown
|
||||
? 'Das Programm ist zur Anzeige freigegeben. Das Angebot erscheint in der Shop-Suche und auf der Produktseite.'
|
||||
: 'Das Programm „'.$pageName.'“ ist nicht zur Anzeige freigegeben oder kein Programm. Das Angebot ist dort nicht auffindbar.'),
|
||||
'stand' => $shown ? 'erledigt' : 'offen',
|
||||
'aktion' => $page === null || $shown ? null : ['label' => 'Programm öffnen', 'href' => EditorialCatalog::editUrl($page)],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $schritte
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function result(array $schritte): array
|
||||
{
|
||||
$schritte = array_map(fn (array $schritt): array => ['pflicht' => true, 'aktion' => null, ...$schritt], $schritte);
|
||||
$naechster = null;
|
||||
|
||||
foreach ($schritte as $schritt) {
|
||||
if ($schritt['pflicht'] && $schritt['stand'] === 'offen') {
|
||||
$naechster = $schritt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'schritte' => $schritte,
|
||||
'bereit' => $naechster === null,
|
||||
'naechster' => $naechster,
|
||||
];
|
||||
}
|
||||
|
||||
private function articleInUse(LicenseArticle $article): bool
|
||||
{
|
||||
return DB::table('offer_lines')->where('license_article_id', $article->id)->exists()
|
||||
|| DB::table('bundle_items')->where('license_article_id', $article->id)->exists();
|
||||
}
|
||||
|
||||
private function bundleOffered(Bundle $bundle): bool
|
||||
{
|
||||
return DB::table('offer_lines')
|
||||
->join('offer_versions', 'offer_versions.id', '=', 'offer_lines.offer_version_id')
|
||||
->join('bundle_versions', 'bundle_versions.id', '=', 'offer_lines.bundle_version_id')
|
||||
->where('bundle_versions.bundle_id', $bundle->id)
|
||||
->where('offer_versions.status', 'aktiv')
|
||||
->exists();
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Group;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
@@ -120,45 +121,92 @@ public static function slotBuilder(string $name = 'widget'): Builder
|
||||
->columnSpanFull();
|
||||
}
|
||||
|
||||
/**
|
||||
* Erklärung als kleines (i) neben der Bezeichnung: erscheint beim Überfahren und beim Fokussieren.
|
||||
*/
|
||||
private static function withInfo(ToggleButtons|Select $component, ?string $help): ToggleButtons|Select
|
||||
{
|
||||
return filled($help)
|
||||
? $component->hintIcon('heroicon-m-information-circle', tooltip: $help)->hintColor('gray')
|
||||
: $component;
|
||||
}
|
||||
|
||||
public static function block(WidgetType $type): Block
|
||||
{
|
||||
$icons = $type->optionIcons();
|
||||
$display = [];
|
||||
|
||||
// Aufbau: Anordnung (Variante) und gemeinsame Höhe. Erklärungen stehen im (i) neben der Bezeichnung.
|
||||
$layout = [];
|
||||
if (count($type->variants()) > 1) {
|
||||
$display[] = ToggleButtons::make('variant')
|
||||
->label('Darstellung')
|
||||
$layout[] = self::withInfo(ToggleButtons::make('variant')
|
||||
->label('Anordnung')
|
||||
->options($type->variants())
|
||||
->icons($icons['variant'] ?? [])
|
||||
->default($type->defaultVariant())
|
||||
->inline()
|
||||
->required()
|
||||
->live();
|
||||
->live(), 'Wie Bild und Text zueinander stehen. Bei wenig Platz stellt sich jede Anordnung selbständig um; die gespeicherte Seite bleibt erhalten.');
|
||||
}
|
||||
|
||||
$settings = [];
|
||||
$options = $type->settingOptions();
|
||||
$labels = $type->settingLabels();
|
||||
foreach ($type->settingOptions() as $key => $options) {
|
||||
$hiddenWhen = $type->settingHiddenWhen();
|
||||
|
||||
$field = function (string $key) use ($options, $labels, $type, $icons, $hiddenWhen): Select|ToggleButtons {
|
||||
$help = $labels[$key][1] ?? null;
|
||||
// Gemeinsame Höhe (ADR-38): immer als sichtbare Auswahl mit Vorgabe, nie als freie Eingabe.
|
||||
$settings[] = $key === 'height'
|
||||
$component = $key === 'height'
|
||||
? ToggleButtons::make('height')
|
||||
->label('Höhe')
|
||||
->helperText('Gestaltungsparameter, keine Begrenzung: Längere Inhalte erhalten immer den nötigen Platz.')
|
||||
->options($options)
|
||||
->options($options['height'])
|
||||
->icons($icons['height'] ?? [])
|
||||
->default($type->defaultHeight())
|
||||
->inline()
|
||||
->live()
|
||||
: Select::make($key)
|
||||
->label($labels[$key][0] ?? Str::headline($key))
|
||||
->helperText($labels[$key][1] ?? null)
|
||||
->placeholder('Vorgabe der Darstellung')
|
||||
->options($options)
|
||||
->options($options[$key])
|
||||
->live();
|
||||
|
||||
if ($key === 'height') {
|
||||
$help = 'Gestaltungsparameter, keine Begrenzung: Längere Inhalte erhalten immer den nötigen Platz.';
|
||||
}
|
||||
|
||||
if (isset($hiddenWhen[$key])) {
|
||||
[$controller, $value] = $hiddenWhen[$key];
|
||||
// Ausgeblendete Werte bleiben gespeichert, damit ein späteres Einblenden nichts zurücksetzt.
|
||||
$component->hidden(fn (Get $get): bool => ($get($controller) ?? null) === $value)->dehydratedWhenHidden();
|
||||
}
|
||||
|
||||
return self::withInfo($component, $help);
|
||||
};
|
||||
|
||||
if (isset($options['height'])) {
|
||||
$layout[] = Group::make([$field('height')])->statePath('settings');
|
||||
}
|
||||
|
||||
if ($settings !== []) {
|
||||
$display[] = Grid::make(['default' => 1, 'md' => 2])->schema($settings)->statePath('settings');
|
||||
if ($layout !== []) {
|
||||
$display[] = Section::make('Aufbau')->compact()->schema($layout);
|
||||
}
|
||||
|
||||
$grouped = [];
|
||||
foreach ($type->settingGroups() as $title => $keys) {
|
||||
$keys = array_values(array_filter($keys, fn (string $key): bool => isset($options[$key]) && $key !== 'height'));
|
||||
$grouped = [...$grouped, ...$keys];
|
||||
if ($keys !== []) {
|
||||
$display[] = Section::make($title)->compact()->schema([
|
||||
Grid::make(['default' => 1, 'md' => 2])->schema(array_map($field, $keys))->statePath('settings'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
$rest = array_values(array_filter(array_keys($options), fn (string $key): bool => $key !== 'height' && ! in_array($key, $grouped, true)));
|
||||
if ($rest !== []) {
|
||||
$display[] = Section::make($grouped === [] && $layout === [] ? 'Einstellungen' : 'Weitere Einstellungen')->compact()->schema([
|
||||
Grid::make(['default' => 1, 'md' => 2])->schema(array_map($field, $rest))->statePath('settings'),
|
||||
]);
|
||||
}
|
||||
|
||||
$variantField = count($type->variants()) > 1 ? [] : [Hidden::make('variant')->default($type->defaultVariant())];
|
||||
|
||||
@@ -25,7 +25,8 @@ public function verify(EmailVerificationRequest $request): RedirectResponse
|
||||
$request->fulfill();
|
||||
app(GrantIssuer::class)->grantRegistrationOffers($request->user());
|
||||
|
||||
return redirect()->route('member.dashboard');
|
||||
// Wer aus dem Warenkorb kam, kehrt nach der Bestätigung zur Kasse zurück (gespeichertes Ziel der Sitzung).
|
||||
return redirect()->intended(route('member.dashboard'));
|
||||
}
|
||||
|
||||
public function send(Request $request): RedirectResponse
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\OrderHolders;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
* Öffentlicher Warenkorb (Etappe 1, nur Testzahlung). Er ist vor der Anmeldung nutzbar; die Prüfung der
|
||||
* vorhandenen Rechte erfolgt, sobald ein Konto angemeldet ist.
|
||||
*/
|
||||
class CartController extends Controller
|
||||
{
|
||||
public function show(Request $request, Cart $cart, OrderHolders $holders): View
|
||||
{
|
||||
$user = $request->user();
|
||||
$review = $cart->review($user, $request->integer('bestellen_als') ?: null);
|
||||
|
||||
return view('shop.cart', [
|
||||
'review' => $review,
|
||||
'holders' => $user === null ? collect() : $holders->for($user),
|
||||
]);
|
||||
}
|
||||
|
||||
public function add(Offer $offer, Cart $cart, PublicCatalogReader $catalog): RedirectResponse
|
||||
{
|
||||
$page = $offer->composition;
|
||||
$result = $page !== null && $catalog->shownVersion($page) !== null
|
||||
? $cart->add($offer)
|
||||
: Cart::UNAVAILABLE;
|
||||
$back = $this->productPage($offer);
|
||||
|
||||
return match ($result) {
|
||||
Cart::ADDED => $back->with('status', 'Die Option liegt im Warenkorb.'),
|
||||
Cart::PRESENT => $back->with('status', 'Diese Option liegt bereits im Warenkorb. Sie erscheint nur einmal.'),
|
||||
Cart::ALTERNATIVE => $back->with('shop.switch', $offer->id),
|
||||
default => $back->withErrors(['shop' => 'Diese Option ist gerade nicht erhältlich.']),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Ausdrücklicher Wechsel zwischen Alternativoptionen derselben Produktseite.
|
||||
*/
|
||||
public function switch(Offer $offer, Cart $cart): RedirectResponse
|
||||
{
|
||||
if (! $cart->switchTo($offer)) {
|
||||
return $this->productPage($offer)->withErrors(['shop' => 'Diese Option ist gerade nicht erhältlich.']);
|
||||
}
|
||||
|
||||
return redirect()->route('cart')->with('status', 'Die Option wurde gewechselt.');
|
||||
}
|
||||
|
||||
public function remove(Offer $offer, Cart $cart): RedirectResponse
|
||||
{
|
||||
$cart->remove($offer);
|
||||
|
||||
return redirect()->route('cart')->with('status', 'Die Position ist entfernt.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Der Käufer übernimmt den aktuell gezeigten Preis und die aktuellen Bedingungen einer Position.
|
||||
*/
|
||||
public function accept(Offer $offer, Cart $cart): RedirectResponse
|
||||
{
|
||||
$seen = $cart->items()[$offer->id]['price_cents'] ?? null;
|
||||
$cart->acceptCurrent($offer);
|
||||
$price = $cart->purchasable($offer)?->price_cents;
|
||||
|
||||
return redirect()->route('cart')->with('status', match (true) {
|
||||
$price === null => 'Die Option ist nicht mehr erhältlich.',
|
||||
$seen !== null && (int) $seen !== (int) $price => 'Der aktuelle Preis von '.Money::format($price).' ist übernommen.',
|
||||
default => 'Die aktuellen Bedingungen sind übernommen.',
|
||||
});
|
||||
}
|
||||
|
||||
private function productPage(Offer $offer): RedirectResponse
|
||||
{
|
||||
return $offer->composition_id !== null
|
||||
? redirect()->route('public.program', $offer->composition_id)
|
||||
: redirect()->route('cart');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Concerns;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
/**
|
||||
* Liefert eine Datei einer Disk aus, bei Filmen und Hörstücken mit Bereichsabrufen (206/416). Safari und iOS spielen
|
||||
* sonst nicht ab, und ohne Bereiche ist kein Springen möglich.
|
||||
*/
|
||||
trait ServesByteRanges
|
||||
{
|
||||
private const CHUNK = 262144;
|
||||
|
||||
protected function respondWithRanges(Request $request, string $diskName, string $path, bool $ranged): StreamedResponse
|
||||
{
|
||||
$headers = [
|
||||
'Content-Disposition' => 'inline',
|
||||
'X-Content-Type-Options' => 'nosniff',
|
||||
'Accept-Ranges' => 'bytes',
|
||||
];
|
||||
$range = $request->header('Range');
|
||||
|
||||
if (! is_string($range) || ! $ranged) {
|
||||
return Storage::disk($diskName)->response($path, null, $headers);
|
||||
}
|
||||
|
||||
$disk = Storage::disk($diskName);
|
||||
$size = (int) $disk->size($path);
|
||||
$bounds = $this->bounds($range, $size);
|
||||
|
||||
if ($bounds === null) {
|
||||
return response()->stream(fn () => null, 416, $headers + ['Content-Range' => 'bytes */'.$size]);
|
||||
}
|
||||
|
||||
[$start, $end] = $bounds;
|
||||
$length = $end - $start + 1;
|
||||
$stream = $disk->readStream($path);
|
||||
abort_if(! is_resource($stream), 404);
|
||||
|
||||
return response()->stream(function () use ($stream, $start, $length): void {
|
||||
fseek($stream, $start);
|
||||
$left = $length;
|
||||
|
||||
while ($left > 0 && ! feof($stream)) {
|
||||
$chunk = fread($stream, min(self::CHUNK, $left));
|
||||
|
||||
if ($chunk === false || $chunk === '') {
|
||||
break;
|
||||
}
|
||||
|
||||
echo $chunk;
|
||||
$left -= strlen($chunk);
|
||||
}
|
||||
|
||||
fclose($stream);
|
||||
}, 206, $headers + [
|
||||
'Content-Type' => (string) ($disk->mimeType($path) ?: 'application/octet-stream'),
|
||||
'Content-Length' => (string) $length,
|
||||
'Content-Range' => 'bytes '.$start.'-'.$end.'/'.$size,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Erster Bereich aus „bytes=a-b“, „bytes=a-“ oder „bytes=-n“; null, wenn er nicht erfüllbar ist.
|
||||
*
|
||||
* @return array{0: int, 1: int}|null
|
||||
*/
|
||||
private function bounds(string $header, int $size): ?array
|
||||
{
|
||||
if ($size < 1 || preg_match('/^bytes=(\d*)-(\d*)(?:,.*)?$/', trim($header), $match) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
[, $from, $to] = $match;
|
||||
|
||||
if ($from === '' && $to === '') {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($from === '') {
|
||||
$suffix = min((int) $to, $size);
|
||||
|
||||
return $suffix < 1 ? null : [$size - $suffix, $size - 1];
|
||||
}
|
||||
|
||||
$start = (int) $from;
|
||||
$end = $to === '' ? $size - 1 : min((int) $to, $size - 1);
|
||||
|
||||
return $start > $end || $start >= $size ? null : [$start, $end];
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,16 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Identity\StaffRole;
|
||||
use App\Domain\Media\FilmPlayback;
|
||||
use App\Domain\Media\HlsPlaylist;
|
||||
use App\Domain\Media\MediaRendition;
|
||||
use App\Domain\Media\ThumbnailDeriver;
|
||||
use App\Http\Controllers\Concerns\ServesByteRanges;
|
||||
use App\Models\User;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\View\View;
|
||||
@@ -15,6 +19,27 @@
|
||||
|
||||
class ContentPreviewController extends Controller
|
||||
{
|
||||
use ServesByteRanges;
|
||||
|
||||
/**
|
||||
* Die Website-Datei eines Films oder Hörstücks, damit die Redaktion sie vor der Freigabe ansehen kann. Nur für
|
||||
* angemeldete Redakteure; öffentlich ist erst die freigegebene Kopie (`website.media`).
|
||||
*/
|
||||
public function websiteFile(Request $request, ContentElement $element): StreamedResponse
|
||||
{
|
||||
$this->authorizeStaff();
|
||||
$path = $element->preview_path;
|
||||
|
||||
abort_unless(
|
||||
is_string($path) && str_starts_with($path, 'teaser/') && ! str_contains($path, '..')
|
||||
&& in_array($element->output_class, ['film', 'audio'], true)
|
||||
&& Storage::disk('media_derived')->exists($path),
|
||||
404,
|
||||
);
|
||||
|
||||
return $this->respondWithRanges($request, 'media_derived', $path, true);
|
||||
}
|
||||
|
||||
public function show(ContentElementVersion $version): View
|
||||
{
|
||||
$this->authorizeStaff();
|
||||
@@ -38,6 +63,24 @@ public function file(ContentElementVersion $version): StreamedResponse
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Einzelbild einer Stelle der Website-Datei, zur Auswahl des Vorschaubilds.
|
||||
*/
|
||||
public function websiteFrame(Request $request, ContentElement $element, ThumbnailDeriver $deriver): Response
|
||||
{
|
||||
$this->authorizeStaff();
|
||||
$seconds = $request->query('sekunde');
|
||||
abort_unless(is_numeric($seconds), 404);
|
||||
|
||||
$bytes = $deriver->jpegAtWebsiteFile($element, (float) $seconds);
|
||||
abort_unless(is_string($bytes), 404);
|
||||
|
||||
return response($bytes, 200, [
|
||||
'Content-Type' => 'image/jpeg',
|
||||
'Cache-Control' => 'private, no-store',
|
||||
]);
|
||||
}
|
||||
|
||||
public function fileUrl(ContentElementVersion $version): ?string
|
||||
{
|
||||
return $this->storedPath($version) === null ? null : route('content.file', $version);
|
||||
|
||||
@@ -5,8 +5,13 @@
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferStatus;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\Checkout;
|
||||
use App\Domain\Commerce\Order;
|
||||
use App\Domain\Commerce\OrderHolders;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use App\Domain\Commerce\StaleOverview;
|
||||
use App\Domain\Commerce\Stripe\StripeGateway;
|
||||
use App\Domain\Entitlement\GrantIssuer;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -48,17 +53,74 @@ public function place(Request $request, Offer $offer, Checkout $checkout): Redir
|
||||
return redirect()->route('member.order', $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bestellübersicht: zeigt die geprüften Positionen mit dem Inhaber, für den bestellt wird.
|
||||
*/
|
||||
public function checkout(Request $request, Cart $cart, OrderHolders $holders): View|RedirectResponse
|
||||
{
|
||||
if ($cart->count() === 0) {
|
||||
return redirect()->route('cart');
|
||||
}
|
||||
|
||||
$review = $cart->review($request->user(), $request->integer('bestellen_als') ?: null);
|
||||
|
||||
return view('shop.checkout', [
|
||||
'review' => $review,
|
||||
'holders' => $holders->for($request->user()),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Legt die Bestellung an, aber nur, wenn die serverseitige Prüfung zur gezeigten Übersicht passt.
|
||||
*/
|
||||
public function placeOrder(Request $request, Cart $cart, Checkout $checkout): RedirectResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'digest' => ['required', 'string'],
|
||||
'bestellen_als' => ['nullable', 'integer'],
|
||||
]);
|
||||
$holderId = isset($data['bestellen_als']) ? (int) $data['bestellen_als'] : null;
|
||||
$back = redirect()->route('checkout', array_filter(['bestellen_als' => $holderId]));
|
||||
|
||||
try {
|
||||
$order = $checkout->placeFromCart($request->user(), $cart, $holderId, $data['digest']);
|
||||
} catch (StaleOverview $exception) {
|
||||
return $back->withErrors(['checkout' => $exception->getMessage()]);
|
||||
} catch (DomainRuleException $exception) {
|
||||
return $back->withErrors(['checkout' => $exception->getMessage()]);
|
||||
}
|
||||
|
||||
return redirect()->route('member.order', $order)->with('status', 'Die Bestellung ist angelegt. Bestätige jetzt die Testzahlung.');
|
||||
}
|
||||
|
||||
public function show(Request $request, Order $order): View
|
||||
{
|
||||
abort_unless($order->user_id === $request->user()->id, 403);
|
||||
$order->load('lines.offerVersion.offer', 'payments');
|
||||
$order->load('lines.offerVersion.offer', 'lines.holder', 'payments', 'party', 'user');
|
||||
|
||||
return view('member.order', [
|
||||
'order' => $order,
|
||||
'testPayment' => ! app()->isProduction() && config('services.payment.driver') === 'test',
|
||||
'stripePayment' => Shop::stripe(),
|
||||
'zahlung' => $request->query('zahlung'),
|
||||
]);
|
||||
}
|
||||
|
||||
/** Leitet zur Stripe-Kasse (Testmodus). Freigeschaltet wird erst durch die signierte Meldung von Stripe. */
|
||||
public function pay(Request $request, Order $order, StripeGateway $stripe): RedirectResponse
|
||||
{
|
||||
abort_unless($order->user_id === $request->user()->id, 403);
|
||||
abort_unless(Shop::stripe(), 404);
|
||||
|
||||
try {
|
||||
$session = $stripe->checkoutFor($order);
|
||||
} catch (DomainRuleException $exception) {
|
||||
return back()->withErrors(['payment' => $exception->getMessage()]);
|
||||
}
|
||||
|
||||
return redirect()->away($session['url']);
|
||||
}
|
||||
|
||||
public function confirm(Request $request, Order $order, Checkout $checkout): RedirectResponse
|
||||
{
|
||||
abort_unless($order->user_id === $request->user()->id, 403);
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
use App\Domain\Catalog\EditorialVocabulary;
|
||||
use App\Domain\Catalog\IdentityDimension;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Catalog\PillarFilterCompat;
|
||||
use App\Domain\Entitlement\DecideAccess;
|
||||
use App\Domain\Entitlement\Grant;
|
||||
use App\Domain\Entitlement\GrantStatus;
|
||||
@@ -20,8 +22,10 @@
|
||||
use App\Http\CourseOutline;
|
||||
use App\Http\LibraryCatalog;
|
||||
use App\Http\SignedLink;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\View\View;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
@@ -35,8 +39,21 @@ public function index(Request $request, ?string $sicht = null): View
|
||||
$query = trim((string) $request->query('q', ''));
|
||||
$nutzung = (string) $request->query('nutzung', '');
|
||||
$dimensionIds = array_values(array_filter(array_map(intval(...), (array) $request->query('dimension', []))));
|
||||
$saeuleIds = array_values(array_filter(array_map(intval(...), (array) $request->query('saeule', []))));
|
||||
$dimensions = app(IdentityDimension::class);
|
||||
|
||||
// Alte Adressen: Säulen waren ein Wert der Einordnung. Mit belastbarer Verknüpfung gilt der Filter der Säule.
|
||||
foreach ($dimensionIds as $index => $valueId) {
|
||||
if (is_int($pillarId = PillarFilterCompat::pillarOfLegacyValue($valueId))) {
|
||||
$saeuleIds[] = $pillarId;
|
||||
unset($dimensionIds[$index]);
|
||||
}
|
||||
}
|
||||
|
||||
$dimensionIds = array_values($dimensionIds);
|
||||
$saeuleIds = array_values(array_unique($saeuleIds));
|
||||
$pillarOptions = $this->visiblePillars($catalog, $saeuleIds);
|
||||
|
||||
foreach (['programs', 'modules'] as $shelf) {
|
||||
if ($query !== '') {
|
||||
$catalog[$shelf] = array_values(array_filter(
|
||||
@@ -50,6 +67,12 @@ public function index(Request $request, ?string $sicht = null): View
|
||||
fn (array $card): bool => $dimensions->matches($card['composition'], $dimensionIds),
|
||||
));
|
||||
}
|
||||
if ($saeuleIds !== []) {
|
||||
$catalog[$shelf] = array_values(array_filter(
|
||||
$catalog[$shelf],
|
||||
fn (array $card): bool => $this->hasPillar($card['composition'], $saeuleIds),
|
||||
));
|
||||
}
|
||||
if (in_array($nutzung, ['nutzbar', 'teilweise', 'nicht enthalten'], true)) {
|
||||
$catalog[$shelf] = array_values(array_filter(
|
||||
$catalog[$shelf],
|
||||
@@ -79,6 +102,13 @@ function (array $card) use ($dimensions, $dimensionIds): bool {
|
||||
));
|
||||
}
|
||||
|
||||
if ($saeuleIds !== []) {
|
||||
$catalog['materials'] = array_values(array_filter(
|
||||
$catalog['materials'],
|
||||
fn (array $card): bool => $this->hasPillar($this->materialSubject($card), $saeuleIds),
|
||||
));
|
||||
}
|
||||
|
||||
if ($nutzung === 'teilweise' || $nutzung === 'nicht enthalten') {
|
||||
$catalog['materials'] = [];
|
||||
}
|
||||
@@ -89,11 +119,65 @@ function (array $card) use ($dimensions, $dimensionIds): bool {
|
||||
'sicht' => $sicht,
|
||||
'nutzung' => $nutzung,
|
||||
'dimensionIds' => $dimensionIds,
|
||||
'saeuleIds' => $saeuleIds,
|
||||
'filterPillars' => $pillarOptions,
|
||||
'filterDimensions' => app(EditorialVocabulary::class)->memberFilterDimensions(array_map(intval(...), $dimensionIds)),
|
||||
'libraryEmpty' => $untouched,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subjekt eines Materialkarte: Programm oder Modul, Medium oder der Artikel selbst.
|
||||
*
|
||||
* @param array<string, mixed> $card
|
||||
*/
|
||||
private function materialSubject(array $card): Model
|
||||
{
|
||||
$release = $card['article']->currentRelease;
|
||||
|
||||
return $release?->rootCompositionVersion?->composition
|
||||
?? $release?->rootElementVersion?->element
|
||||
?? $card['article'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Direkte Säulenzuordnung des Objekts selbst; die Säulen enthaltener Medien zählen hier nicht.
|
||||
*
|
||||
* @param list<int> $pillarIds
|
||||
*/
|
||||
private function hasPillar(Model $subject, array $pillarIds): bool
|
||||
{
|
||||
return $subject->pillars()->whereIn('pillars.id', $pillarIds)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Säulen für den Filter: nur solche, die ein sichtbares Objekt der Bibliothek tatsächlich trägt, und eine bereits
|
||||
* gewählte. So erscheinen neue oder interne Säulen ohne Zuordnung nicht in der Bibliothek.
|
||||
*
|
||||
* @param array<string, mixed> $catalog
|
||||
* @param list<int> $selected
|
||||
* @return Collection<int, Pillar>
|
||||
*/
|
||||
private function visiblePillars(array $catalog, array $selected)
|
||||
{
|
||||
$used = [];
|
||||
|
||||
foreach (array_merge($catalog['programs'], $catalog['modules']) as $card) {
|
||||
foreach ($card['composition']->pillars()->pluck('pillars.id') as $id) {
|
||||
$used[(int) $id] = true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($catalog['materials'] as $card) {
|
||||
foreach ($this->materialSubject($card)->pillars()->pluck('pillars.id') as $id) {
|
||||
$used[(int) $id] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return Pillar::query()->whereIn('id', array_values(array_unique([...array_keys($used), ...$selected])))
|
||||
->orderBy('sort_order')->orderBy('name')->get();
|
||||
}
|
||||
|
||||
public function programs(Request $request): View
|
||||
{
|
||||
return $this->index($request, 'programme');
|
||||
@@ -382,7 +466,7 @@ private function grantQuery(Request $request)
|
||||
{
|
||||
return Grant::query()
|
||||
->where('status', GrantStatus::Aktiv)
|
||||
->whereHas('acquisition', fn ($query) => $query->where('party_id', $request->user()->party_id))
|
||||
->usableBy($request->user())
|
||||
->with('article.currentRelease')
|
||||
->orderBy('id');
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\CompositionStructureReader;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Cart;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class PublicCatalogController extends Controller
|
||||
@@ -14,7 +17,7 @@ public function index(PublicCatalogReader $catalog): View
|
||||
return view('public.programs', ['programs' => $catalog->publicPrograms()]);
|
||||
}
|
||||
|
||||
public function program(Composition $composition, PublicCatalogReader $catalog): View
|
||||
public function program(Composition $composition, PublicCatalogReader $catalog, ProductOptions $products, Cart $cart): View
|
||||
{
|
||||
$version = $catalog->shownVersion($composition);
|
||||
abort_if($version === null, 404);
|
||||
@@ -23,6 +26,9 @@ public function program(Composition $composition, PublicCatalogReader $catalog):
|
||||
'composition' => $composition,
|
||||
'version' => $version,
|
||||
'nodes' => app(CompositionStructureReader::class)->tree($version),
|
||||
'options' => Shop::enabled() ? $products->forComposition($composition) : [],
|
||||
'cart' => $cart,
|
||||
'switchTo' => session('shop.switch'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,8 @@ public function show(string $path, WebsiteMedia $media): StreamedResponse
|
||||
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.
|
||||
abort_if(WebsiteMediaAlias::isRetired($path), 404);
|
||||
|
||||
$alias = WebsiteMediaAlias::effectiveFor($path);
|
||||
abort_if($alias !== null && $media->present($alias->content_element_id) === null, 404);
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Cms\Catalog\PublicCatalogReader;
|
||||
use App\Domain\Commerce\Money;
|
||||
use App\Domain\Commerce\ProductOptions;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
/**
|
||||
* Durchsuchbarer Shop (Etappe 1): macht kaufbare Produkte auffindbar. Treffer öffnen dieselbe öffentliche Produktseite
|
||||
* wie die Programmkacheln. Gelistet wird nur, was zur Anzeige freigegeben ist und mindestens eine kaufbare Option hat.
|
||||
*/
|
||||
class ShopController extends Controller
|
||||
{
|
||||
public function index(Request $request, ProductOptions $products, PublicCatalogReader $catalog): View
|
||||
{
|
||||
$term = trim((string) $request->query('suche', ''));
|
||||
$summaries = $products->summaries();
|
||||
$cards = [];
|
||||
|
||||
foreach (Composition::query()->whereIn('id', array_keys($summaries))->orderBy('designation')->get() as $composition) {
|
||||
$version = $catalog->shownVersion($composition);
|
||||
|
||||
if ($version === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = (string) ($composition->display_title ?: $composition->designation);
|
||||
$haystack = mb_strtolower($title.' '.$composition->teaser.' '.$composition->summary.' '.$composition->search_terms);
|
||||
|
||||
if ($term !== '' && ! str_contains($haystack, mb_strtolower($term))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$summary = $summaries[$composition->id];
|
||||
$cards[] = [
|
||||
'composition' => $composition,
|
||||
'title' => $title,
|
||||
'teaser' => (string) ($composition->teaser ?: $composition->summary),
|
||||
'from' => Money::format($summary['from_cents']),
|
||||
'count' => $summary['count'],
|
||||
];
|
||||
}
|
||||
|
||||
return view('shop.index', ['cards' => $cards, 'term' => $term]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Commerce\Checkout;
|
||||
use App\Domain\Commerce\Order;
|
||||
use App\Domain\Commerce\Payment;
|
||||
use App\Domain\Commerce\Shop;
|
||||
use App\Domain\Commerce\Stripe\StripeSignature;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Empfängt die signierten Meldungen von Stripe (Etappe 1: Testmodus). Ohne gültige Signatur geschieht nichts. Die
|
||||
* Freischaltung nutzt denselben geprüften Weg wie die Testzahlung und ist bei Wiederholung wirkungslos.
|
||||
* Antworten: 404 wenn Stripe nicht aktiv ist, 400 bei ungültiger Signatur, sonst 200 (Stripe wiederholt sonst).
|
||||
*/
|
||||
class StripeWebhookController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, StripeSignature $signature, Checkout $checkout): JsonResponse
|
||||
{
|
||||
abort_unless(Shop::stripe(), 404);
|
||||
|
||||
$payload = $request->getContent();
|
||||
|
||||
try {
|
||||
$signature->verify($payload, $request->header('Stripe-Signature'));
|
||||
} catch (DomainRuleException $exception) {
|
||||
Log::warning('Stripe-Meldung abgewiesen', ['grund' => $exception->getMessage()]);
|
||||
|
||||
return response()->json(['error' => 'Ungültige Signatur.'], 400);
|
||||
}
|
||||
|
||||
$event = json_decode($payload, true);
|
||||
|
||||
if (! is_array($event) || ! isset($event['type'])) {
|
||||
return response()->json(['error' => 'Ungültige Nutzlast.'], 400);
|
||||
}
|
||||
|
||||
$session = (array) ($event['data']['object'] ?? []);
|
||||
|
||||
return match ($event['type']) {
|
||||
'checkout.session.completed', 'checkout.session.async_payment_succeeded' => $this->paid($session, $checkout),
|
||||
'checkout.session.expired', 'checkout.session.async_payment_failed' => $this->notPaid($session, (string) $event['type']),
|
||||
default => response()->json(['received' => true, 'handled' => false]),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $session
|
||||
*/
|
||||
private function paid(array $session, Checkout $checkout): JsonResponse
|
||||
{
|
||||
if (($session['payment_status'] ?? null) !== 'paid') {
|
||||
return response()->json(['received' => true, 'handled' => false]);
|
||||
}
|
||||
|
||||
$order = $this->orderOf($session);
|
||||
$reference = (string) ($session['id'] ?? '');
|
||||
|
||||
if ($order === null || $reference === '') {
|
||||
Log::warning('Stripe-Zahlung ohne zugehörige Bestellung', ['session' => $reference]);
|
||||
|
||||
return response()->json(['received' => true, 'handled' => false]);
|
||||
}
|
||||
|
||||
try {
|
||||
$checkout->confirmProviderPayment(
|
||||
$order,
|
||||
'stripe',
|
||||
$reference,
|
||||
(int) ($session['amount_total'] ?? -1),
|
||||
(string) ($session['currency'] ?? ''),
|
||||
);
|
||||
} catch (DomainRuleException $exception) {
|
||||
// Dauerhafter Fehler (Betragsabweichung, Bestellung nicht mehr offen): nichts freischalten, Zahlung zur
|
||||
// Prüfung festhalten und 200 antworten, damit Stripe nicht endlos wiederholt.
|
||||
Log::warning('Stripe-Zahlung nicht übernommen', ['order' => $order->id, 'session' => $reference, 'grund' => $exception->getMessage()]);
|
||||
$order->payments()->updateOrCreate(['provider_reference' => $reference], ['provider' => 'stripe', 'status' => 'zu_pruefen']);
|
||||
|
||||
return response()->json(['received' => true, 'handled' => false]);
|
||||
}
|
||||
|
||||
return response()->json(['received' => true, 'handled' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $session
|
||||
*/
|
||||
private function notPaid(array $session, string $type): JsonResponse
|
||||
{
|
||||
$payment = Payment::query()->where('provider', 'stripe')->where('provider_reference', (string) ($session['id'] ?? ''))->first();
|
||||
|
||||
// Die Bestellung bleibt offen und lässt sich erneut bezahlen; nur diese Kasse gilt nicht mehr.
|
||||
if ($payment !== null && $payment->status === 'offen') {
|
||||
$payment->status = $type === 'checkout.session.expired' ? 'abgelaufen' : 'fehlgeschlagen';
|
||||
$payment->save();
|
||||
}
|
||||
|
||||
return response()->json(['received' => true, 'handled' => $payment !== null]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $session
|
||||
*/
|
||||
private function orderOf(array $session): ?Order
|
||||
{
|
||||
$id = $session['client_reference_id'] ?? ($session['metadata']['order_id'] ?? null);
|
||||
|
||||
return is_numeric($id) ? Order::query()->find((int) $id) : null;
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,15 @@
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Media\WebsiteMedia;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Http\Controllers\Concerns\ServesByteRanges;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class WebsiteMediaController extends Controller
|
||||
{
|
||||
public function show(ContentElement $element, WebsiteMedia $media): StreamedResponse
|
||||
use ServesByteRanges;
|
||||
|
||||
public function show(Request $request, ContentElement $element, WebsiteMedia $media): StreamedResponse
|
||||
{
|
||||
$presentation = $media->present($element);
|
||||
abort_if($presentation === null, 404);
|
||||
@@ -17,9 +20,6 @@ public function show(ContentElement $element, WebsiteMedia $media): StreamedResp
|
||||
$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',
|
||||
]);
|
||||
return $this->respondWithRanges($request, 'media_public', $path, $presentation->kind !== 'bild');
|
||||
}
|
||||
}
|
||||
@@ -266,7 +266,7 @@ private function grants(User $user): Collection
|
||||
{
|
||||
return Grant::query()
|
||||
->where('status', GrantStatus::Aktiv)
|
||||
->whereHas('acquisition', fn ($query) => $query->where('party_id', $user->party_id))
|
||||
->usableBy($user)
|
||||
->with([
|
||||
'article.currentRelease.rootCompositionVersion.composition.editorialContentKind',
|
||||
'article.currentRelease.rootElementVersion.element.editorialContentKind',
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Domain\Commerce\Shop;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Warenkorb und Kasse gibt es nur mit Testzahlung und nie in Produktion (Etappe 1 erteilt keine Produktivfreigabe).
|
||||
*/
|
||||
class EnsureShopEnabled
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
abort_unless(Shop::enabled(), 404);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ public function __construct(
|
||||
public readonly ?int $fromElement = null,
|
||||
public readonly ?int $versionId = null,
|
||||
public readonly ?float $atSecond = null,
|
||||
public readonly bool $websiteFile = false,
|
||||
) {}
|
||||
|
||||
public function handle(ThumbnailDeriver $deriver): void
|
||||
@@ -54,6 +55,12 @@ public function handle(ThumbnailDeriver $deriver): void
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->websiteFile && $this->atSecond !== null) {
|
||||
$deriver->forElementWebsiteFrame($element, $this->atSecond);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->versionId !== null && $this->atSecond !== null) {
|
||||
$version = ContentElementVersion::query()->find($this->versionId);
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\DomainRuleException;
|
||||
use App\Domain\Media\PresentationFile;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Kopiert die Website-Datei eines Mediums nach `derived/`. Nur die Warteschlange darf dort schreiben.
|
||||
* Ein Fehler wird am Medium vermerkt (`thumbnail_error`), damit die Verwaltung ihn zeigen kann.
|
||||
*/
|
||||
class StorePresentationFile implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public int $timeout = 3600;
|
||||
|
||||
public function __construct(
|
||||
public int $elementId,
|
||||
public string $incoming,
|
||||
) {}
|
||||
|
||||
public function handle(PresentationFile $file): void
|
||||
{
|
||||
$element = ContentElement::query()->find($this->elementId);
|
||||
|
||||
if (! $element instanceof ContentElement) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$file->place($element, $this->incoming);
|
||||
|
||||
// Ein schon freigegebenes Medium zeigt sonst weiter die alte öffentliche Kopie.
|
||||
if ($element->website_released_at !== null) {
|
||||
PublishWebsiteMedia::dispatch($element->id, 'release');
|
||||
}
|
||||
} catch (DomainRuleException $e) {
|
||||
$this->remember($element, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function failed(\Throwable $e): void
|
||||
{
|
||||
$element = ContentElement::query()->find($this->elementId);
|
||||
|
||||
if ($element instanceof ContentElement) {
|
||||
$this->remember($element, 'Die Datei ließ sich nicht übernehmen: '.Str::limit($e->getMessage(), 120));
|
||||
}
|
||||
}
|
||||
|
||||
private function remember(ContentElement $element, string $message): void
|
||||
{
|
||||
$element->thumbnail_error = $message;
|
||||
$element->save();
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,8 @@
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
$middleware->trustProxies(at: '*');
|
||||
// Stripe sendet ohne Sitzung und CSRF-Token; die Signatur der Meldung ersetzt beides.
|
||||
$middleware->validateCsrfTokens(except: ['stripe/webhook']);
|
||||
$middleware->prepend(UseStaffSessionCookie::class);
|
||||
$middleware->prepend(UseRequestRootUrl::class);
|
||||
$middleware->prepend(IgnoreEmptyForwardedHeaders::class);
|
||||
|
||||
+2
-2
@@ -42,8 +42,8 @@
|
||||
],
|
||||
|
||||
/*
|
||||
| Vorbereiteter Warenkorbzugang in der Kopfzeile. Der Warenkorb ist Teil des kommerziellen Anwendungssystems
|
||||
| und noch nicht umgesetzt; solange enabled false ist, erscheint kein Warenkorbsymbol.
|
||||
| Früher vorbereiteter Warenkorbzugang. Seit Etappe 1 folgt der Eintrag in der Kopfzeile dem Shop
|
||||
| (App\Domain\Commerce\Shop::enabled: Testzahlung, nie in Produktion). Diese Werte werden nicht mehr gelesen.
|
||||
*/
|
||||
'cart' => [
|
||||
'enabled' => (bool) env('LUF_CART_ENABLED', false),
|
||||
|
||||
@@ -29,9 +29,19 @@
|
||||
],
|
||||
|
||||
'payment' => [
|
||||
// test: Testweg ohne Anbieter. stripe: Stripe-Kasse, in Etappe 1 nur mit Testschlüsseln (sk_test_).
|
||||
'driver' => env('PAYMENT_DRIVER', 'test'),
|
||||
],
|
||||
|
||||
'stripe' => [
|
||||
'secret' => env('STRIPE_SECRET'),
|
||||
'webhook_secret' => env('STRIPE_WEBHOOK_SECRET'),
|
||||
// Optional: ID eines in Stripe angelegten Steuersatzes (txr_...), der jeder Position mitgegeben wird.
|
||||
// Er muss im Preis enthalten (inklusiv) sein, sonst weicht der gezahlte Betrag von der Bestellung ab.
|
||||
'tax_rate' => env('STRIPE_TAX_RATE_ID'),
|
||||
'api_base' => env('STRIPE_API_BASE', 'https://api.stripe.com'),
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'notifications' => [
|
||||
'bot_user_oauth_token' => env('SLACK_BOT_USER_OAUTH_TOKEN'),
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
use App\Domain\Catalog\LegacyPillarAdoption;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Fachliche Säulen vereinheitlichen: Module, Programme und Lizenzartikel verwenden wie Medien und Seiten die zentrale
|
||||
* Säulenverwaltung (`pillars`) statt der Kopie „Fachliche Säule“ in den redaktionellen Dimensionen.
|
||||
*
|
||||
* Nur Ergänzungen: zwei Zuordnungstabellen (die Säule wird beim Löschen nie still entfernt, wie bei Medien und Seiten),
|
||||
* die Verknüpfung `pillar_id` an den alten Dimensionswerten und die einmalige, wiederholbare Übernahme durch
|
||||
* LegacyPillarAdoption. Alte Tabellen und Zeilen bleiben unverändert erhalten.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('composition_pillar', function (Blueprint $table) {
|
||||
$table->foreignId('composition_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('pillar_id')->constrained()->restrictOnDelete();
|
||||
$table->primary(['composition_id', 'pillar_id']);
|
||||
});
|
||||
|
||||
Schema::create('license_article_pillar', function (Blueprint $table) {
|
||||
$table->foreignId('license_article_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('pillar_id')->constrained()->restrictOnDelete();
|
||||
$table->primary(['license_article_id', 'pillar_id']);
|
||||
});
|
||||
|
||||
Schema::table('editorial_dimension_values', function (Blueprint $table) {
|
||||
$table->foreignId('pillar_id')->nullable()->after('editorial_dimension_id')->constrained('pillars')->nullOnDelete();
|
||||
});
|
||||
|
||||
$report = (new LegacyPillarAdoption)->run();
|
||||
|
||||
foreach (LegacyPillarAdoption::lines($report) as $line) {
|
||||
if ($line !== '') {
|
||||
Log::info('Säulenübernahme: '.$line);
|
||||
}
|
||||
}
|
||||
|
||||
if ($report['unresolved'] !== []) {
|
||||
Log::warning('Säulenübernahme: '.count($report['unresolved']).' Fälle ungeklärt; „php artisan luf:saeulen-uebernehmen --dry-run“ listet sie.');
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('editorial_dimension_values', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('pillar_id');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('license_article_pillar');
|
||||
Schema::dropIfExists('composition_pillar');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Herkunft der Standbilder, die aus einem Film als Bild-Medium übernommen wurden (Medien- und Materialkarte).
|
||||
* Additiv. Sie verhindert, dass dieselbe Filmstelle mehrfach als neues Medium entsteht, und hält fest, woher das
|
||||
* Bild kommt. Das Standbild selbst ist ein gewöhnliches Medium (output_class bild) mit eigener Website-Freigabe.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('film_still_sources', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('film_element_id')->constrained('content_elements')->restrictOnDelete();
|
||||
$table->foreignId('still_element_id')->constrained('content_elements')->restrictOnDelete();
|
||||
$table->string('source_key', 120);
|
||||
$table->unsignedBigInteger('actor_id')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['film_element_id', 'source_key']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('film_still_sources');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Etappe 1 (Testkauf): nur ergänzend, keine Daten werden gelöscht oder umbenannt.
|
||||
*
|
||||
* - Ein Angebot (Lizenzoption) kann auf die Komposition zeigen, deren öffentliche Seite die Produktseite ist
|
||||
* (`offers.composition_id`). Angebote derselben Komposition bilden die Angebotsgruppe (Alternativen).
|
||||
* - Mitgliedschaft eines Kontos in einer Organisation mit Bestellberechtigung (Domänenmodell 04, MEMBERSHIP).
|
||||
* - Der Erwerb hält das auslösende Konto, die Bestellung Gesamtsumme und Währung, die Position Inhaber, Währung,
|
||||
* Steuerklasse und Vergabeart als Kopie. `orders.party_id` ist der Lizenzinhaber, `orders.user_id` das handelnde Konto.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('offers', function (Blueprint $table) {
|
||||
$table->foreignId('composition_id')->nullable()->constrained('compositions')->nullOnDelete();
|
||||
$table->string('option_label')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('memberships', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('party_id')->constrained()->restrictOnDelete();
|
||||
$table->string('role')->default('mitglied');
|
||||
$table->boolean('may_order')->default(false);
|
||||
$table->date('valid_from')->nullable();
|
||||
$table->date('valid_until')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['user_id', 'party_id']);
|
||||
});
|
||||
|
||||
Schema::table('acquisitions', function (Blueprint $table) {
|
||||
$table->foreignId('acting_user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('orders', function (Blueprint $table) {
|
||||
$table->unsignedInteger('total_cents')->nullable();
|
||||
$table->string('currency', 3)->default('EUR');
|
||||
});
|
||||
|
||||
Schema::table('order_lines', function (Blueprint $table) {
|
||||
$table->string('currency', 3)->default('EUR');
|
||||
$table->string('tax_class')->nullable();
|
||||
$table->string('grant_kind')->nullable();
|
||||
$table->foreignId('holder_party_id')->nullable()->constrained('parties')->restrictOnDelete();
|
||||
});
|
||||
|
||||
// Bestehende Bestellungen: Summe und Inhaber der Position aus den vorhandenen Angaben.
|
||||
foreach (DB::table('orders')->get() as $order) {
|
||||
DB::table('orders')->where('id', $order->id)->update([
|
||||
'total_cents' => (int) DB::table('order_lines')->where('order_id', $order->id)->sum('price_cents'),
|
||||
]);
|
||||
DB::table('order_lines')->where('order_id', $order->id)->update(['holder_party_id' => $order->party_id]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('order_lines', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('holder_party_id');
|
||||
$table->dropColumn(['currency', 'tax_class', 'grant_kind']);
|
||||
});
|
||||
Schema::table('orders', function (Blueprint $table) {
|
||||
$table->dropColumn(['total_cents', 'currency']);
|
||||
});
|
||||
Schema::table('acquisitions', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('acting_user_id');
|
||||
});
|
||||
Schema::dropIfExists('memberships');
|
||||
Schema::table('offers', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('composition_id');
|
||||
$table->dropColumn('option_label');
|
||||
});
|
||||
}
|
||||
};
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* „Medium löschen“ (Medien ohne Fassung) muss auch Standbilder aus Filmen und übernommene CMS-Bilder erreichen.
|
||||
*
|
||||
* - film_still_sources: Die Herkunftszeile eines gelöschten Standbilds entfällt (cascade); dieselbe Stelle kann neu
|
||||
* übernommen werden.
|
||||
* - website_media_aliases: Die Zuordnung bleibt als Sperre bestehen (content_element_id wird leer). Ein früherer Pfad
|
||||
* mit gelöschtem Medium wird nicht wieder über /medien/cms/… ausgeliefert und nicht mehr als Bild gezeigt.
|
||||
*
|
||||
* Lockert nur Fremdschlüssel; bestehende Daten bleiben unverändert (rückwärtskompatibel).
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('film_still_sources', function (Blueprint $table) {
|
||||
$table->dropForeign(['still_element_id']);
|
||||
});
|
||||
Schema::table('film_still_sources', function (Blueprint $table) {
|
||||
$table->foreign('still_element_id')->references('id')->on('content_elements')->cascadeOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('website_media_aliases', function (Blueprint $table) {
|
||||
$table->dropForeign(['content_element_id']);
|
||||
});
|
||||
Schema::table('website_media_aliases', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('content_element_id')->nullable()->change();
|
||||
});
|
||||
Schema::table('website_media_aliases', function (Blueprint $table) {
|
||||
$table->foreign('content_element_id')->references('id')->on('content_elements')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// Bewusst leer: Die gelockerten Fremdschlüssel schaden älterem Code nicht, und leere Zuordnungen
|
||||
// (gelöschte Medien) ließen sich nicht in den strengeren Zustand zurückführen.
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Herkunft der Bild-Medien, die aus dem Vorschaubild eines Programms oder Moduls übernommen wurden
|
||||
* (Programm- und Modulkarte). Additiv. Verhindert, dass dasselbe Vorschaubild mehrfach als neues Medium entsteht.
|
||||
* Das übernommene Bild ist ein gewöhnliches Medium (output_class bild) mit eigener Website-Freigabe.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('composition_still_sources', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('composition_id')->constrained('compositions')->cascadeOnDelete();
|
||||
$table->foreignId('still_element_id')->constrained('content_elements')->cascadeOnDelete();
|
||||
$table->string('source_key', 120);
|
||||
$table->unsignedBigInteger('actor_id')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['composition_id', 'source_key']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('composition_still_sources');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Domain\Catalog\ArticleService;
|
||||
use App\Domain\Catalog\BundleService;
|
||||
use App\Domain\Catalog\CompositionDisplayRelease;
|
||||
use App\Domain\Catalog\CompositionVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Domain\Catalog\EditorialContentKind;
|
||||
use App\Domain\Catalog\LicenseArticle;
|
||||
use App\Domain\Catalog\Offer;
|
||||
use App\Domain\Catalog\OfferService;
|
||||
use App\Domain\Catalog\RightsProfileVersion;
|
||||
use App\Domain\Identity\AccountStatus;
|
||||
use App\Domain\Identity\Membership;
|
||||
use App\Domain\Identity\Party;
|
||||
use App\Domain\Identity\PartyType;
|
||||
use App\Domain\Identity\RegisterAccount;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Testdaten für den Testkauf (Etappe 1): zwei Programme mit Film und Begleitmaterial, ein Starterpaket, die
|
||||
* Lizenzoptionen für Privatpersonen und für einen Verein, ein Testverein mit bestellberechtigtem Konto und drei
|
||||
* Testkonten. Nur für Entwicklung und die Testinstanz; in Produktion läuft der Seeder nicht.
|
||||
* Mehrfach ausführbar: Vorhandenes bleibt unverändert.
|
||||
*/
|
||||
class ShopDemoSeeder extends Seeder
|
||||
{
|
||||
/** Nur für automatisierte Tests. Außerhalb von Tests gilt LUF_DEMO_PASSWORD oder ein zufälliges Passwort. */
|
||||
public const PASSWORD = 'testkauf-passwort-1';
|
||||
|
||||
private ?string $password = null;
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
if (app()->isProduction() || LicenseArticle::query()->where('code', 'shop-konflikte')->exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$content = app(ContentService::class);
|
||||
$articles = app(ArticleService::class);
|
||||
$bundles = app(BundleService::class);
|
||||
$offers = app(OfferService::class);
|
||||
$this->password = app()->runningUnitTests()
|
||||
? self::PASSWORD
|
||||
: (getenv('LUF_DEMO_PASSWORD') ?: Str::random(24));
|
||||
$editor = $this->account('Demo Redaktion', 'shop-demo-redaktion@example.test');
|
||||
|
||||
[$konflikteVersion, $konflikteArticle] = $this->program(
|
||||
$content, $articles, $editor, 'shop-konflikte', 'Konflikte im Training',
|
||||
'Wie Trainerinnen und Trainer Konflikte in der Gruppe ruhig und klar begleiten.',
|
||||
'Ein Film, ein Arbeitsblatt und eine Anleitung für sechs Trainingseinheiten.',
|
||||
'Konflikte erkennen, benennen und gemeinsam lösen.',
|
||||
);
|
||||
[$grenzenVersion, $grenzenArticle] = $this->program(
|
||||
$content, $articles, $editor, 'shop-grenzen', 'Grenzen setzen im Verein',
|
||||
'Sicher auftreten, Grenzen vermitteln und Kinder stärken.',
|
||||
'Film und Begleitmaterial für einen Übungsabend zu Grenzen und Respekt.',
|
||||
'Grenzen verständlich vermitteln.',
|
||||
);
|
||||
[$starterVersion, $starterArticle] = $this->program(
|
||||
$content, $articles, $editor, 'shop-starter', 'Starterpaket für neue Trainer',
|
||||
'Das Einstiegspaket mit beiden Programmen und einer Einführung für neue Trainerinnen und Trainer.',
|
||||
'Zusätzlich zu beiden Programmen enthält das Paket eine Einführung ins Konzept.',
|
||||
'Das Konzept kennenlernen.',
|
||||
);
|
||||
|
||||
$privat = $offers->createRightsProfile('Privatlizenz ehrenamtlich', 'ehrenamtlich', [
|
||||
'film' => ['streamen', 'laden'],
|
||||
'pdf' => ['ansehen', 'laden'],
|
||||
]);
|
||||
$verein = $offers->createRightsProfile('Vereinslizenz institutionell', 'institutionell', [
|
||||
'film' => ['streamen', 'laden'],
|
||||
'pdf' => ['ansehen', 'laden'],
|
||||
]);
|
||||
|
||||
$this->offer($offers, 'Konflikte im Training: Privatlizenz', 'Privatlizenz', $konflikteVersion, [$konflikteArticle, $privat], 4900, 'person');
|
||||
$this->offer($offers, 'Konflikte im Training: Vereinslizenz', 'Mehrfachlizenz für Vereine', $konflikteVersion, [$konflikteArticle, $verein], 14900, 'organisation');
|
||||
$this->offer($offers, 'Grenzen setzen: Privatlizenz', 'Privatlizenz', $grenzenVersion, [$grenzenArticle, $privat], 2900, 'person');
|
||||
|
||||
$bundle = $bundles->create('Starterpaket');
|
||||
$starter = $bundles->publish($bundle, [$konflikteArticle->fresh(), $grenzenArticle->fresh(), $starterArticle->fresh()]);
|
||||
$paket = $offers->create('Starterpaket: Privatlizenz');
|
||||
$offers->activate($paket, [['target' => $starter, 'rights' => $privat]], ['grant_kind' => 'kauf', 'price_cents' => 5900, 'holder_kind' => 'person']);
|
||||
$offers->assignProduct($paket, $starterVersion->composition_id, 'Starterpaket (zwei Programme und Einführung)');
|
||||
|
||||
$tina = $this->account('Tina Trainerin', 'tina.trainerin@example.test');
|
||||
$vera = $this->account('Vera Vorstand', 'vera.vorstand@example.test');
|
||||
$max = $this->account('Max Mitglied', 'max.mitglied@example.test');
|
||||
$club = Party::query()->firstOrCreate(
|
||||
['type' => PartyType::Organisation, 'display_name' => 'Testverein Musterstadt e. V.'],
|
||||
);
|
||||
Membership::query()->firstOrCreate(['user_id' => $vera->id, 'party_id' => $club->id], ['role' => 'org_admin', 'may_order' => true]);
|
||||
Membership::query()->firstOrCreate(['user_id' => $max->id, 'party_id' => $club->id], ['role' => 'mitglied', 'may_order' => false]);
|
||||
unset($tina);
|
||||
|
||||
if (! app()->runningUnitTests()) {
|
||||
$this->command?->info('Testkonten angelegt (tina.trainerin, vera.vorstand, max.mitglied und shop-demo-redaktion bei example.test). Passwort: '.($this->password));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Zwei Dateien (Film, Begleitmaterial) als Platzhalter im Speicher, ein Programm als Komposition mit
|
||||
* Anzeigefreigabe und ein Lizenzartikel dazu.
|
||||
*
|
||||
* @return array{0: CompositionVersion, 1: LicenseArticle}
|
||||
*/
|
||||
private function program(
|
||||
ContentService $content,
|
||||
ArticleService $articles,
|
||||
User $editor,
|
||||
string $code,
|
||||
string $title,
|
||||
string $teaser,
|
||||
string $summary,
|
||||
string $goal,
|
||||
): array {
|
||||
$disk = Storage::disk('media_derived');
|
||||
$disk->put('inhalte/'.$code.'/film.mp4', 'Platzhalter für den Film '.$title);
|
||||
$disk->put('inhalte/'.$code.'/begleitmaterial.pdf', "%PDF-1.4\n% Platzhalter für das Begleitmaterial ".$title."\n%%EOF\n");
|
||||
|
||||
$film = $content->publishElementVersion(
|
||||
$content->createElement('film', 'film', 'Film '.$title),
|
||||
null,
|
||||
['file' => 'inhalte/'.$code.'/film.mp4'],
|
||||
);
|
||||
$sheet = $content->publishElementVersion(
|
||||
$content->createElement('pdf', 'pdf', 'Begleitmaterial '.$title),
|
||||
null,
|
||||
['file' => 'inhalte/'.$code.'/begleitmaterial.pdf'],
|
||||
);
|
||||
$composition = $content->createComposition($title);
|
||||
$composition->editorial_content_kind_id = EditorialContentKind::query()->where('slug', 'programm')->value('id');
|
||||
$composition->display_title = $title;
|
||||
$composition->teaser = $teaser;
|
||||
$composition->summary = $summary;
|
||||
$composition->save();
|
||||
$version = $content->publishComposition(
|
||||
$composition,
|
||||
[['role' => 'Film', 'target' => $film], ['role' => 'Begleitmaterial', 'target' => $sheet]],
|
||||
null,
|
||||
null,
|
||||
['learning_goal' => $goal],
|
||||
);
|
||||
app(CompositionDisplayRelease::class)->release($version, $editor);
|
||||
|
||||
$article = $articles->create($code, 'Testkauf');
|
||||
$article->working_title = $title;
|
||||
$article->display_title = $title;
|
||||
$article->save();
|
||||
$articles->publishRelease($article, $version, 'Programm für den Testkauf.');
|
||||
|
||||
return [$version, $article->fresh()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{0: LicenseArticle, 1: RightsProfileVersion} $line
|
||||
*/
|
||||
private function offer(OfferService $offers, string $name, string $label, CompositionVersion $version, array $line, int $cents, string $holder): Offer
|
||||
{
|
||||
$offer = $offers->create($name);
|
||||
$offers->activate($offer, [['target' => $line[0], 'rights' => $line[1]]], [
|
||||
'grant_kind' => 'kauf',
|
||||
'price_cents' => $cents,
|
||||
'holder_kind' => $holder,
|
||||
]);
|
||||
$offers->assignProduct($offer, $version->composition_id, $label);
|
||||
|
||||
return $offer;
|
||||
}
|
||||
|
||||
private function account(string $name, string $email): User
|
||||
{
|
||||
$existing = User::query()->where('email', $email)->first();
|
||||
|
||||
if ($existing !== null) {
|
||||
return $existing;
|
||||
}
|
||||
|
||||
$user = app(RegisterAccount::class)->register($name, $email, (string) $this->password, true);
|
||||
$user->forceFill(['email_verified_at' => now(), 'status' => AccountStatus::Aktiv])->save();
|
||||
|
||||
return $user;
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,11 @@ MAIL_MAILER=log
|
||||
MAIL_FROM_ADDRESS="noreply@example.invalid"
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
# test bleibt der lokale Testweg. Ein echter Zahlungsdienst ist noch nicht festgelegt.
|
||||
# test: lokaler Testweg ohne Anbieter. stripe: Stripe-Kasse, in Etappe 1 nur mit Testschlüsseln und nie in Produktion.
|
||||
# Die Schlüssel stehen nur in /etc/luf/<umgebung>.env auf dem Server, nie im Repo.
|
||||
PAYMENT_DRIVER=test
|
||||
# STRIPE_SECRET=sk_test_... (Entwickler > API-Schlüssel, Testmodus)
|
||||
# STRIPE_WEBHOOK_SECRET=whsec_... (Entwickler > Webhooks > Endpunkt > Signiergeheimnis)
|
||||
# STRIPE_TAX_RATE_ID=txr_... (optional: in Stripe angelegter, im Preis enthaltener Steuersatz)
|
||||
|
||||
# Medienpfade setzt Compose auf den Host-Mount (/srv/luf/<env>/media/...). Hier nichts eintragen.
|
||||
@@ -0,0 +1,25 @@
|
||||
/* Lara & Felix – draft brand tokens; source imagery sampled 2026-11-15.
|
||||
Do not treat these color values or fonts as final without approval. */
|
||||
:root {
|
||||
--lf-navy: #032551;
|
||||
--lf-navy-deep: #01244C;
|
||||
--lf-green: #5B8625;
|
||||
--lf-green-deep: #3B7B09;
|
||||
--lf-yellow: #FCD10A;
|
||||
--lf-cream: #F7F6F2;
|
||||
--lf-white: #FFFFFF;
|
||||
--lf-surface: #F9FAF7;
|
||||
--lf-ink: #15243A;
|
||||
--lf-muted: #5D6A78;
|
||||
--lf-border: #DDE5E3;
|
||||
--lf-focus: #1769AA;
|
||||
--lf-error: #B92F38;
|
||||
--lf-radius-sm: 8px;
|
||||
--lf-radius-md: 14px;
|
||||
--lf-radius-lg: 22px;
|
||||
--lf-radius-pill: 999px;
|
||||
--lf-shadow-card: 0 12px 30px rgb(3 37 81 / .07);
|
||||
--lf-max-container: 1180px;
|
||||
--lf-font-ui: "Nunito Sans", "Segoe UI", system-ui, sans-serif;
|
||||
--lf-font-display: "Nunito", "Trebuchet MS", system-ui, sans-serif;
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
{
|
||||
"$schema": "https://design-tokens.github.io/community-group/format/",
|
||||
"status": "working draft, needs formal brand approval",
|
||||
"source": "sampled colors from uploaded title/denkpause, with supporting UI tokens chosen for accessibility",
|
||||
"color": {
|
||||
"navy": {
|
||||
"$type": "color",
|
||||
"$value": "#032551"
|
||||
},
|
||||
"navy_deep": {
|
||||
"$type": "color",
|
||||
"$value": "#01244C"
|
||||
},
|
||||
"green": {
|
||||
"$type": "color",
|
||||
"$value": "#5B8625"
|
||||
},
|
||||
"green_deep": {
|
||||
"$type": "color",
|
||||
"$value": "#3B7B09"
|
||||
},
|
||||
"yellow": {
|
||||
"$type": "color",
|
||||
"$value": "#FCD10A"
|
||||
},
|
||||
"cream": {
|
||||
"$type": "color",
|
||||
"$value": "#F7F6F2"
|
||||
},
|
||||
"white": {
|
||||
"$type": "color",
|
||||
"$value": "#FFFFFF"
|
||||
},
|
||||
"surface": {
|
||||
"$type": "color",
|
||||
"$value": "#F9FAF7"
|
||||
},
|
||||
"ink": {
|
||||
"$type": "color",
|
||||
"$value": "#15243A"
|
||||
},
|
||||
"muted": {
|
||||
"$type": "color",
|
||||
"$value": "#5D6A78"
|
||||
},
|
||||
"border": {
|
||||
"$type": "color",
|
||||
"$value": "#DDE5E3"
|
||||
},
|
||||
"focus": {
|
||||
"$type": "color",
|
||||
"$value": "#1769AA"
|
||||
},
|
||||
"error": {
|
||||
"$type": "color",
|
||||
"$value": "#B92F38"
|
||||
}
|
||||
},
|
||||
"radius": {
|
||||
"sm": {
|
||||
"$type": "dimension",
|
||||
"$value": "8px"
|
||||
},
|
||||
"md": {
|
||||
"$type": "dimension",
|
||||
"$value": "14px"
|
||||
},
|
||||
"lg": {
|
||||
"$type": "dimension",
|
||||
"$value": "22px"
|
||||
},
|
||||
"pill": {
|
||||
"$type": "dimension",
|
||||
"$value": "999px"
|
||||
}
|
||||
},
|
||||
"space": {
|
||||
"1": {
|
||||
"$type": "dimension",
|
||||
"$value": "4px"
|
||||
},
|
||||
"2": {
|
||||
"$type": "dimension",
|
||||
"$value": "8px"
|
||||
},
|
||||
"3": {
|
||||
"$type": "dimension",
|
||||
"$value": "12px"
|
||||
},
|
||||
"4": {
|
||||
"$type": "dimension",
|
||||
"$value": "16px"
|
||||
},
|
||||
"5": {
|
||||
"$type": "dimension",
|
||||
"$value": "20px"
|
||||
},
|
||||
"6": {
|
||||
"$type": "dimension",
|
||||
"$value": "24px"
|
||||
},
|
||||
"7": {
|
||||
"$type": "dimension",
|
||||
"$value": "28px"
|
||||
},
|
||||
"8": {
|
||||
"$type": "dimension",
|
||||
"$value": "32px"
|
||||
},
|
||||
"9": {
|
||||
"$type": "dimension",
|
||||
"$value": "36px"
|
||||
},
|
||||
"10": {
|
||||
"$type": "dimension",
|
||||
"$value": "40px"
|
||||
},
|
||||
"11": {
|
||||
"$type": "dimension",
|
||||
"$value": "44px"
|
||||
},
|
||||
"12": {
|
||||
"$type": "dimension",
|
||||
"$value": "48px"
|
||||
},
|
||||
"13": {
|
||||
"$type": "dimension",
|
||||
"$value": "52px"
|
||||
},
|
||||
"14": {
|
||||
"$type": "dimension",
|
||||
"$value": "56px"
|
||||
},
|
||||
"15": {
|
||||
"$type": "dimension",
|
||||
"$value": "60px"
|
||||
},
|
||||
"16": {
|
||||
"$type": "dimension",
|
||||
"$value": "64px"
|
||||
}
|
||||
},
|
||||
"typography": {
|
||||
"display": "Rounded friendly display – select licensed font",
|
||||
"body": "Highly readable sans – select licensed font"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="17" fill="#032551"/><path d="M10 45V17h8v20h12v8z" fill="#fff"/><text x="31" y="42" font-family="system-ui,sans-serif" font-size="19" font-weight="900" fill="white">F</text><path d="M9 53Q28 43 55 49" stroke="#FCD10A" stroke-width="5" fill="none" stroke-linecap="round"/></svg>
|
||||
|
After Width: | Height: | Size: 370 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><g fill="none" stroke="#032551" stroke-width="5" stroke-linejoin="round" stroke-linecap="round"><path d="M20 53V30c0-9 13-9 13 0V16c0-9 13-9 13 0v11-17c0-9 13-9 13 0v18-14c0-9 13-9 13 0v36l7-10c7-9 20-3 15 7L76 82C67 93 43 94 30 86L9 64C2 56 13 47 20 53z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 329 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 258"><path d="M59 68C72 19 132 6 165 35c39-37 103-10 113 30 56-3 78 45 56 86 10 45-42 89-95 75-39 30-94 12-109-11-38 21-100-11-99-56-27-29-20-78 28-91z" fill="#FFFFFF" stroke="#032551" stroke-width="7" stroke-linejoin="round"/><circle cx="48" cy="233" r="14" fill="white" stroke="#032551" stroke-width="6"/><circle cx="17" cy="253" r="6" fill="white" stroke="#032551" stroke-width="4"/></svg>
|
||||
|
After Width: | Height: | Size: 449 B |
Loaded 100 of 391 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user