Ein Foto gehoert zu keinem (ganzjaehrig) oder mehreren Erscheinungsbildern und erscheint nur dort, vor den ganzjaehrigen Fotos. Bausteine waehlen "automatisch" oder eine eigene Auswahl; Titelbereich und Abschluss zeigen das erste passende Foto ihrer Liste. Titelbild und "Bilder je Baustein" des Erscheinungsbilds werden in die Bausteine uebernommen und entfallen dort. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
1.9 KiB
PHP
60 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Themes\Sections;
|
|
|
|
use App\Enums\PhotoCategory;
|
|
use App\Themes\Theme;
|
|
use Filament\Forms\Components\RichEditor;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Toggle;
|
|
use Filament\Schemas\Components\Group;
|
|
use Filament\Schemas\Components\Utilities\Get;
|
|
|
|
/**
|
|
* Location: text, photos of the area and a map link (no embedded third-party map, so no consent needed).
|
|
*/
|
|
class LocationSection extends Section
|
|
{
|
|
public static function key(): string
|
|
{
|
|
return 'location';
|
|
}
|
|
|
|
public static function label(): string
|
|
{
|
|
return 'Lage & Umgebung';
|
|
}
|
|
|
|
public static function icon(): string
|
|
{
|
|
return 'heroicon-o-map-pin';
|
|
}
|
|
|
|
public static function schema(): array
|
|
{
|
|
return [
|
|
TextInput::make('eyebrow')->label('Kleine Überschrift')->maxLength(100),
|
|
TextInput::make('heading')->label('Überschrift')->required()->maxLength(160),
|
|
RichEditor::make('text')->label('Text')->toolbarButtons([['bold', 'italic', 'link'], ['bulletList']]),
|
|
Toggle::make('show_photos')->label('Bilder zeigen')->default(true)->live(),
|
|
Group::make(static::photoSourceFields('Automatisch: Fotos der Umgebung'))->visible(fn (Get $get): bool => (bool) $get('show_photos')),
|
|
];
|
|
}
|
|
|
|
public function data(Theme $theme, array $data): array
|
|
{
|
|
$address = $theme->property()?->address;
|
|
|
|
return [
|
|
'eyebrow' => $data['eyebrow'] ?? null,
|
|
'heading' => $data['heading'] ?? '',
|
|
'text' => $this->html($data['text'] ?? null),
|
|
'address' => $address,
|
|
'mapUrl' => $address ? 'https://www.openstreetmap.org/search?query='.rawurlencode($address) : null,
|
|
'photos' => ($data['show_photos'] ?? true)
|
|
? $this->sourcedPhotos($theme, $data, PhotoCategory::Area, 6)
|
|
: collect(),
|
|
];
|
|
}
|
|
}
|