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
|
|
@ -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'];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue