Startseite frei gestalten, Neuigkeiten-Block mit Kategorien-Filter (0.26.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 5m21s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m55s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m40s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m42s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m25s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m57s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m16s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m34s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m14s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 5m21s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m55s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m40s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m42s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m25s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m57s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m16s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m34s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m14s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6290e09074
commit
2c96fcce1c
151 changed files with 1515 additions and 317 deletions
162
app/Dashboard/Homepage.php
Normal file
162
app/Dashboard/Homepage.php
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
<?php
|
||||
|
||||
namespace App\Dashboard;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Pagebuilder\Content;
|
||||
use App\Support\Audit;
|
||||
use App\Support\Settings;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Frei gestaltete Startseite: Inhalt aus Pagebuilder-Blöcken (inkl. aller Kacheln
|
||||
* als Block „Kachel“). Alternativ bleibt die Startseite aus Kacheln (Widgets).
|
||||
*
|
||||
* Gespeichert in den Einstellungen: veröffentlichter Stand, Entwurf und die letzten Versionen.
|
||||
*/
|
||||
class Homepage
|
||||
{
|
||||
public const MODE = 'homepage.mode'; // widgets | builder
|
||||
|
||||
public const PUBLISHED = 'homepage.content';
|
||||
|
||||
public const DRAFT = 'homepage.draft';
|
||||
|
||||
public const REVISIONS = 'homepage.revisions';
|
||||
|
||||
public const MAX_REVISIONS = 20;
|
||||
|
||||
public const WIDGET_BLOCK = 'dashboard.widget';
|
||||
|
||||
public function __construct(private readonly Settings $settings, private readonly Content $content) {}
|
||||
|
||||
public function isBuilder(): bool
|
||||
{
|
||||
return $this->settings->get(self::MODE) === 'builder' && $this->published() !== null;
|
||||
}
|
||||
|
||||
public function setMode(string $mode): void
|
||||
{
|
||||
$this->settings->set(self::MODE, $mode === 'builder' ? 'builder' : 'widgets');
|
||||
}
|
||||
|
||||
public function mode(): string
|
||||
{
|
||||
return $this->settings->get(self::MODE) === 'builder' ? 'builder' : 'widgets';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{blocks: list<array<string, mixed>>}|null
|
||||
*/
|
||||
public function published(): ?array
|
||||
{
|
||||
$content = $this->settings->get(self::PUBLISHED);
|
||||
|
||||
return is_array($content) ? $content : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{content: array<string, mixed>, updated_at: string, user: ?string}|null
|
||||
*/
|
||||
public function draft(): ?array
|
||||
{
|
||||
$draft = $this->settings->get(self::DRAFT);
|
||||
|
||||
return is_array($draft) && is_array($draft['content'] ?? null) ? $draft : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arbeitsstand für den Editor: Entwurf, sonst veröffentlichter Stand, sonst die heutige Kachel-Anordnung.
|
||||
*
|
||||
* @return array{blocks: list<array<string, mixed>>}
|
||||
*/
|
||||
public function working(): array
|
||||
{
|
||||
return $this->draft()['content'] ?? $this->published() ?? $this->fromWidgets();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<mixed> $content
|
||||
*/
|
||||
public function saveDraft(array $content, User $user): void
|
||||
{
|
||||
$this->settings->set(self::DRAFT, ['content' => $this->content->sanitize($content), 'updated_at' => now()->toIso8601String(), 'user' => $user->name]);
|
||||
}
|
||||
|
||||
public function discardDraft(): void
|
||||
{
|
||||
$this->settings->set(self::DRAFT, null);
|
||||
}
|
||||
|
||||
public function publish(User $user): void
|
||||
{
|
||||
$content = $this->working();
|
||||
$revisions = (array) $this->settings->get(self::REVISIONS, []);
|
||||
array_unshift($revisions, ['id' => Str::random(8), 'content' => $content, 'at' => now()->toIso8601String(), 'user' => $user->name]);
|
||||
|
||||
$this->settings->setMany([
|
||||
self::PUBLISHED => $content,
|
||||
self::DRAFT => null,
|
||||
self::REVISIONS => array_slice($revisions, 0, self::MAX_REVISIONS),
|
||||
]);
|
||||
|
||||
Audit::log('homepage.published', ['blocks' => count($content['blocks'] ?? [])]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array{id: string, at: string, user: ?string, blocks: int}>
|
||||
*/
|
||||
public function revisions(): array
|
||||
{
|
||||
return array_map(fn (array $r) => ['id' => $r['id'], 'at' => $r['at'], 'user' => $r['user'] ?? null, 'blocks' => count($r['content']['blocks'] ?? [])], (array) $this->settings->get(self::REVISIONS, []));
|
||||
}
|
||||
|
||||
/**
|
||||
* Frühere Fassung als Entwurf zurückholen.
|
||||
*/
|
||||
public function restore(string $id, User $user): bool
|
||||
{
|
||||
foreach ((array) $this->settings->get(self::REVISIONS, []) as $revision) {
|
||||
if (($revision['id'] ?? null) === $id) {
|
||||
$this->saveDraft($revision['content'], $user);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Anzeige für eine Person (veröffentlicht oder – in der Vorschau – der Entwurf).
|
||||
*
|
||||
* @return array{blocks: list<array<string, mixed>>}
|
||||
*/
|
||||
public function render(User $user, bool $draft = false): array
|
||||
{
|
||||
return $this->content->render($draft ? $this->working() : ($this->published() ?? ['blocks' => []]), $user, ['homepage' => true]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Die heutige Kachel-Startseite als Blöcke: oben die Banner, darunter zwei Spalten
|
||||
* (Hauptbereich und Seitenleiste).
|
||||
*
|
||||
* @return array{blocks: list<array<string, mixed>>}
|
||||
*/
|
||||
public function fromWidgets(): array
|
||||
{
|
||||
$areas = app(Widgets::class)->arrangement();
|
||||
$block = fn (string $key) => ['id' => Str::random(12), 'type' => self::WIDGET_BLOCK, 'data' => ['widget' => $key]];
|
||||
|
||||
$main = array_map($block, [...array_slice($areas['hero'] ?? [], 0, 1), ...($areas['feed'] ?? []), ...($areas['main'] ?? [])]);
|
||||
$aside = array_map($block, $areas['aside'] ?? []);
|
||||
|
||||
return $this->content->sanitize(['blocks' => [
|
||||
...array_map($block, $areas['top'] ?? []),
|
||||
['id' => Str::random(12), 'type' => 'columns', 'data' => ['layout' => '2-1', 'stack' => 'md', 'gap' => 'normal', 'align' => 'start'], 'items' => [
|
||||
['id' => Str::random(12), 'blocks' => $main],
|
||||
['id' => Str::random(12), 'blocks' => $aside],
|
||||
]],
|
||||
]]);
|
||||
}
|
||||
}
|
||||
|
|
@ -84,6 +84,56 @@ class Widgets
|
|||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Alle Kacheln zur Auswahl (Startseiten-Baukasten): Schlüssel => Name.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function options(): array
|
||||
{
|
||||
return $this->candidates()->map(fn (array $w) => $w['label'])->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sichtbare Kacheln je Bereich in gespeicherter Reihenfolge (Ausgangspunkt für den Baukasten).
|
||||
*
|
||||
* @return array<string, list<string>> Bereich => Schlüssel
|
||||
*/
|
||||
public function arrangement(): array
|
||||
{
|
||||
$layout = $this->layout();
|
||||
|
||||
return $this->candidates()
|
||||
->filter(fn (array $w, string $key) => $layout[$key]['visible'] ?? true)
|
||||
->groupBy(fn (array $w) => $w['area'], preserveKeys: true)
|
||||
->map(fn ($widgets) => $widgets->keys()->all())
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Eine Kachel für eine Person berechnen (Baustein „Kachel“ der frei gestalteten Startseite).
|
||||
*
|
||||
* @return array{component: string, props: array<string, mixed>}|null
|
||||
*/
|
||||
public function resolveOne(string $key, User $user, Request $request): ?array
|
||||
{
|
||||
$widget = $this->candidates($user)->get($key);
|
||||
|
||||
if (! $widget || ! app(PluginAccess::class)->allows($key, $user)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
$props = ($widget['props'])($user, $request);
|
||||
} catch (Throwable $e) {
|
||||
Log::error("Startseiten-Kachel {$key} fehlgeschlagen: ".$e->getMessage(), ['exception' => $e]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $props === null ? null : ['component' => $widget['component'], 'props' => $props];
|
||||
}
|
||||
|
||||
/**
|
||||
* Mitgelieferte Kacheln plus eigene Kacheln, sortiert nach gespeicherter Anordnung.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Dashboard\Homepage;
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Filament\Clusters\HomepageCluster;
|
||||
use App\Filament\Resources\DashboardTiles\DashboardTileResource;
|
||||
|
|
@ -10,6 +11,7 @@ use App\Support\Settings;
|
|||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Repeater\TableColumn;
|
||||
use Filament\Forms\Components\Select;
|
||||
|
|
@ -61,6 +63,7 @@ class DashboardSettings extends Page
|
|||
public function mount(Widgets $widgets): void
|
||||
{
|
||||
$this->form->fill([
|
||||
'mode' => app(Homepage::class)->mode(),
|
||||
...collect(self::AREAS)->mapWithKeys(fn ($info, $area) => [$area => $widgets->forAdmin($area)])->all(),
|
||||
'people_fields' => (array) app(Settings::class)->get(ContactCards::PEOPLE_SEARCH_FIELDS, ContactCards::DEFAULT_PEOPLE_SEARCH_FIELDS),
|
||||
]);
|
||||
|
|
@ -87,9 +90,22 @@ class DashboardSettings extends Page
|
|||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->statePath('data')->components([
|
||||
Section::make('Art der Startseite')
|
||||
->schema([
|
||||
Radio::make('mode')
|
||||
->hiddenLabel()
|
||||
->live()
|
||||
->options([
|
||||
'widgets' => 'Kacheln – feste Bereiche, Anordnung unten festlegen',
|
||||
'builder' => 'Frei gestaltet – mit dem Baukasten („Startseite gestalten“)',
|
||||
])
|
||||
->helperText(fn () => app(Homepage::class)->published() === null
|
||||
? 'Die freie Gestaltung ist noch nicht veröffentlicht – bis dahin bleiben die Kacheln sichtbar. Beim ersten Öffnen übernimmt der Baukasten die heutige Anordnung.'
|
||||
: 'Alle Kacheln stehen im Baukasten als Block „Kachel“ zur Verfügung.'),
|
||||
]),
|
||||
...collect(self::AREAS)->map(fn ($info, $area) => Section::make($info[0])
|
||||
->description($info[1] ?: null)
|
||||
->visible(fn () => app(Widgets::class)->forAdmin($area) !== [])
|
||||
->visible(fn (Get $get) => $get('mode') !== 'builder' && app(Widgets::class)->forAdmin($area) !== [])
|
||||
->schema([
|
||||
Repeater::make($area)
|
||||
->hiddenLabel()
|
||||
|
|
@ -139,7 +155,12 @@ class DashboardSettings extends Page
|
|||
}
|
||||
}
|
||||
|
||||
$settings->set('dashboard.layout', $layout);
|
||||
// Bei „Frei gestaltet“ sind die Kachel-Bereiche ausgeblendet – ihre Anordnung bleibt dann unverändert
|
||||
if (($this->data['mode'] ?? 'widgets') !== 'builder') {
|
||||
$settings->set('dashboard.layout', $layout);
|
||||
}
|
||||
|
||||
app(Homepage::class)->setMode((string) ($this->data['mode'] ?? 'widgets'));
|
||||
$settings->set(ContactCards::PEOPLE_SEARCH_FIELDS, array_values(array_intersect((array) ($this->data['people_fields'] ?? []), array_keys(app(ContactCards::class)->options()))));
|
||||
|
||||
// Verschobene Kacheln im Formular in ihren neuen Bereich umsortieren
|
||||
|
|
@ -151,6 +172,8 @@ class DashboardSettings extends Page
|
|||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('design')->label('Startseite gestalten')->icon(Heroicon::OutlinedPaintBrush)
|
||||
->url('/startseite/gestalten'),
|
||||
Action::make('tiles')->label('Eigene Kacheln')->icon(Heroicon::OutlinedRectangleGroup)->color('gray')
|
||||
->url(fn () => DashboardTileResource::getUrl()),
|
||||
Action::make('preview')->label('Startseite ansehen')->icon(Heroicon::OutlinedEye)->color('gray')
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Dashboard\Homepage;
|
||||
use App\Dashboard\Widgets;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
|
|
@ -9,8 +10,18 @@ use Inertia\Response;
|
|||
|
||||
class DashboardController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, Widgets $widgets): Response
|
||||
public function __invoke(Request $request, Widgets $widgets, Homepage $homepage): Response
|
||||
{
|
||||
// Vorschau des Entwurfs für alle, die die Startseite gestalten
|
||||
$preview = $request->boolean('entwurf') && $request->user()->can('appearance.manage');
|
||||
|
||||
if ($preview || $homepage->isBuilder()) {
|
||||
return Inertia::render('Dashboard', [
|
||||
'content' => $homepage->render($request->user(), draft: $preview),
|
||||
'preview' => $preview,
|
||||
]);
|
||||
}
|
||||
|
||||
return Inertia::render('Dashboard', [
|
||||
'widgets' => $widgets->resolve($request->user(), $request),
|
||||
]);
|
||||
|
|
|
|||
127
app/Http/Controllers/HomepageEditorController.php
Normal file
127
app/Http/Controllers/HomepageEditorController.php
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Dashboard\Homepage;
|
||||
use App\Media\MediaLibrary;
|
||||
use App\Pagebuilder\Blocks;
|
||||
use App\Pagebuilder\Content;
|
||||
use App\Support\Permissions\Audiences;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Validation\Rules\File;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
/**
|
||||
* Frei gestaltete Startseite bearbeiten (erreichbar aus dem Backend unter „Startseite“).
|
||||
*/
|
||||
class HomepageEditorController extends Controller
|
||||
{
|
||||
public function __construct(private readonly Homepage $homepage) {}
|
||||
|
||||
public function edit(Request $request, Blocks $blocks): Response
|
||||
{
|
||||
$this->authorize($request);
|
||||
$draft = $this->homepage->draft();
|
||||
|
||||
return Inertia::render('HomepageEditor', [
|
||||
'content' => $this->homepage->working(),
|
||||
'state' => $this->state(),
|
||||
'revisions' => $this->homepage->revisions(),
|
||||
'blockTypes' => $blocks->forEditor(homepage: true),
|
||||
'blockGroups' => Blocks::GROUPS,
|
||||
'audienceOptions' => Audiences::options(),
|
||||
'uploadsUrl' => rtrim(Storage::disk('uploads')->url(''), '/'),
|
||||
'draftBy' => $draft['user'] ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
public function saveDraft(Request $request): JsonResponse
|
||||
{
|
||||
$this->authorize($request);
|
||||
$request->validate(['content' => ['present', 'array']]);
|
||||
$this->homepage->saveDraft($request->input('content'), $request->user());
|
||||
|
||||
return response()->json(['state' => $this->state()]);
|
||||
}
|
||||
|
||||
public function discardDraft(Request $request): JsonResponse
|
||||
{
|
||||
$this->authorize($request);
|
||||
$this->homepage->discardDraft();
|
||||
|
||||
return response()->json(['state' => $this->state(), 'content' => $this->homepage->working()]);
|
||||
}
|
||||
|
||||
public function publish(Request $request): JsonResponse
|
||||
{
|
||||
$this->authorize($request);
|
||||
$request->validate(['content' => ['nullable', 'array'], 'activate' => ['boolean']]);
|
||||
|
||||
if ($request->has('content')) {
|
||||
$this->homepage->saveDraft($request->input('content'), $request->user());
|
||||
}
|
||||
|
||||
$this->homepage->publish($request->user());
|
||||
|
||||
if ($request->boolean('activate')) {
|
||||
$this->homepage->setMode('builder');
|
||||
}
|
||||
|
||||
return response()->json(['state' => $this->state(), 'revisions' => $this->homepage->revisions()]);
|
||||
}
|
||||
|
||||
public function restore(Request $request, string $revision): JsonResponse
|
||||
{
|
||||
$this->authorize($request);
|
||||
abort_unless($this->homepage->restore($revision, $request->user()), 404);
|
||||
|
||||
return response()->json(['state' => $this->state(), 'content' => $this->homepage->working()]);
|
||||
}
|
||||
|
||||
public function preview(Request $request, Content $content): JsonResponse
|
||||
{
|
||||
$this->authorize($request);
|
||||
$request->validate(['blocks' => ['required', 'array', 'max:100'], 'blocks.*' => ['array']]);
|
||||
|
||||
$props = [];
|
||||
|
||||
foreach ($request->input('blocks') as $block) {
|
||||
if (is_string($block['id'] ?? null)) {
|
||||
$props[$block['id']] = $content->preview($block, $request->user(), ['homepage' => true, 'editing' => true]);
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json(['props' => (object) $props]);
|
||||
}
|
||||
|
||||
public function uploadImage(Request $request, MediaLibrary $library): JsonResponse
|
||||
{
|
||||
$this->authorize($request);
|
||||
$request->validate(['image' => ['required', File::image()->types(['jpg', 'jpeg', 'png', 'webp', 'gif'])->max(15 * 1024)]]);
|
||||
|
||||
$media = $library->store($request->file('image'), 'pagebuilder/startseite', $request->user());
|
||||
|
||||
return response()->json(['path' => $media->path, 'url' => Blocks::imageUrl($media->path), 'media' => $media->toLibraryArray()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{mode: string, has_draft: bool, published: bool, draft_updated_at: ?string}
|
||||
*/
|
||||
private function state(): array
|
||||
{
|
||||
return [
|
||||
'mode' => $this->homepage->mode(),
|
||||
'has_draft' => $this->homepage->draft() !== null,
|
||||
'published' => $this->homepage->published() !== null,
|
||||
'draft_updated_at' => $this->homepage->draft()['updated_at'] ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
private function authorize(Request $request): void
|
||||
{
|
||||
abort_unless($request->user()->can('appearance.manage'), 403);
|
||||
}
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ class Blocks
|
|||
'content' => 'Inhalt',
|
||||
'media' => 'Medien',
|
||||
'dynamic' => 'Dynamisch',
|
||||
'homepage' => 'Startseite',
|
||||
];
|
||||
|
||||
/** @var array<string, BlockType> */
|
||||
|
|
@ -61,9 +62,13 @@ class Blocks
|
|||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function forEditor(): array
|
||||
/**
|
||||
* @param bool $homepage Startseiten-Editor: auch die Blöcke der Gruppe „Startseite“ (Kacheln)
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
public function forEditor(bool $homepage = false): array
|
||||
{
|
||||
return array_values(array_map(fn (BlockType $type) => $type->toArray(), $this->all()));
|
||||
return array_values(array_map(fn (BlockType $type) => $type->toArray(), array_filter($this->all(), fn (BlockType $type) => $homepage || $type->group !== 'homepage')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -48,6 +48,16 @@ final class Field
|
|||
return new self($name, 'select', $label, ['choices' => $choices, 'default' => $default]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mehrfachauswahl (Häkchen), z. B. mehrere Kategorien.
|
||||
*
|
||||
* @param array<string, string>|Closure(): array<string, string> $choices
|
||||
*/
|
||||
public static function multiselect(string $name, string $label, array|Closure $choices): self
|
||||
{
|
||||
return new self($name, 'multiselect', $label, ['choices' => $choices, 'default' => []]);
|
||||
}
|
||||
|
||||
public static function toggle(string $name, string $label, bool $default = false): self
|
||||
{
|
||||
return new self($name, 'toggle', $label, ['default' => $default]);
|
||||
|
|
@ -138,6 +148,7 @@ final class Field
|
|||
'text', 'textarea' => mb_substr(trim(is_scalar($value) ? (string) $value : ''), 0, $this->options['max']),
|
||||
'html' => app(RichText::class)->sanitize(is_string($value) ? mb_substr($value, 0, 200_000) : ''),
|
||||
'select' => $this->sanitizeChoice($value),
|
||||
'multiselect' => $this->sanitizeChoices($value),
|
||||
'toggle' => (bool) $value,
|
||||
'number' => max($this->options['min'], min($this->options['max'], is_numeric($value) ? (int) $value : $this->options['default'])),
|
||||
'url' => self::safeUrl($value),
|
||||
|
|
@ -166,6 +177,19 @@ final class Field
|
|||
return preg_match('#^[a-z0-9.-]+\.[a-z]{2,}(/|$)#i', $url) ? 'https://'.$url : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
private function sanitizeChoices(mixed $value): array
|
||||
{
|
||||
$choices = $this->options['choices'] instanceof Closure ? ($this->options['choices'])() : $this->options['choices'];
|
||||
|
||||
return array_values(array_unique(array_filter(
|
||||
array_map(fn ($v) => is_scalar($v) ? (string) $v : '', is_array($value) ? $value : []),
|
||||
fn (string $v) => $v !== '' && array_key_exists($v, $choices),
|
||||
)));
|
||||
}
|
||||
|
||||
private function sanitizeChoice(mixed $value): ?string
|
||||
{
|
||||
$choices = $this->options['choices'] instanceof Closure ? ($this->options['choices'])() : $this->options['choices'];
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace App\Providers;
|
||||
|
||||
use App\Dashboard\CoreWidgets;
|
||||
use App\Dashboard\Homepage;
|
||||
use App\Dashboard\Widgets;
|
||||
use App\Editorial\Editorial;
|
||||
use App\Identity\Entra\EntraDriver;
|
||||
|
|
@ -15,6 +16,8 @@ use App\Models\DashboardTile;
|
|||
use App\Models\IdentityProvider;
|
||||
use App\Models\User;
|
||||
use App\Pagebuilder\Blocks;
|
||||
use App\Pagebuilder\BlockType;
|
||||
use App\Pagebuilder\Field;
|
||||
use App\Plugins\PluginAccess;
|
||||
use App\Search\GlobalSearch;
|
||||
use App\Support\Abilities;
|
||||
|
|
@ -90,6 +93,14 @@ class AppServiceProvider extends ServiceProvider
|
|||
|
||||
CoreWidgets::register($this->app->make(Widgets::class));
|
||||
|
||||
// Frei gestaltete Startseite: jede Kachel als Block
|
||||
$this->app->make(Blocks::class)->add(BlockType::make(Homepage::WIDGET_BLOCK, 'Kachel', 'layout-dashboard', 'homepage', 'WidgetBlock')
|
||||
->description('Eine Kachel der Startseite – Begrüßung, Termine, Geburtstage, eigene Kacheln …')
|
||||
->fields([Field::select('widget', 'Kachel', fn () => $this->app->make(Widgets::class)->options())])
|
||||
->resolveUsing(fn (array $data, ?User $user) => $user && $data['widget']
|
||||
? $this->app->make(Widgets::class)->resolveOne($data['widget'], $user, request())
|
||||
: null));
|
||||
|
||||
$this->app->make(Navigation::class)->add('editorial', 'Redaktion', '/redaktion', active: ['editorial', 'pages.editor', 'news.editor.*', 'forms.builder', 'media.*'], sort: 85,
|
||||
visible: fn (User $user) => $this->app->make(Editorial::class)->visibleFor($user));
|
||||
|
||||
|
|
|
|||
|
|
@ -9,5 +9,5 @@ namespace App;
|
|||
*/
|
||||
final class Version
|
||||
{
|
||||
public const VERSION = '0.25.2';
|
||||
public const VERSION = '0.26.0';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue