chapter hgroup + calming decor

This commit is contained in:
Julie Blanc 2026-04-07 18:09:15 +02:00
parent 0545b131de
commit 94d14d70c1
370 changed files with 9583 additions and 1566 deletions

View file

@ -65,16 +65,19 @@ class Option
/**
* Renders all data for the option
*/
public function render(ModelWithContent $model): array
{
public function render(
ModelWithContent $model,
bool $safeMode = true
): array {
$info = I18n::translate($this->info, $this->info);
$text = I18n::translate($this->text, $this->text);
$method = $safeMode === true ? 'toSafeString' : 'toString';
return [
'disabled' => $this->disabled,
'icon' => $this->icon,
'info' => $info ? $model->toSafeString($info) : $info,
'text' => $text ? $model->toSafeString($text) : $text,
'info' => $info ? $model->$method($info) : $info,
'text' => $text ? $model->$method($text) : $text,
'value' => $this->value
];
}

View file

@ -63,12 +63,12 @@ class Options extends Collection
return $collection;
}
public function render(ModelWithContent $model): array
public function render(ModelWithContent $model, bool $safeMode = true): array
{
$options = [];
foreach ($this->data as $key => $option) {
$options[$key] = $option->render($model);
$options[$key] = $option->render($model, $safeMode);
}
return array_values($options);

View file

@ -10,11 +10,12 @@ use Kirby\Cms\StructureObject;
use Kirby\Cms\User;
use Kirby\Content\Field;
use Kirby\Exception\InvalidArgumentException;
use Kirby\Toolkit\A;
use Kirby\Toolkit\Collection;
use Kirby\Toolkit\Obj;
/**
* Options derrived from running a query against
* Options derived from running a query against
* pages, files, users or structures to create
* options out of them.
*
@ -38,11 +39,14 @@ class OptionsQuery extends OptionsProvider
protected function collection(array $array): Collection
{
$isAssociative = A::isAssociative($array);
foreach ($array as $key => $value) {
if (is_scalar($value) === true) {
$array[$key] = new Obj([
'key' => new Field(null, 'key', $key),
'value' => new Field(null, 'value', $value),
'key' => new Field(null, 'key', $key),
'value' => new Field(null, 'value', $value),
'hasStringKey' => $isAssociative,
]);
}
}
@ -72,6 +76,12 @@ class OptionsQuery extends OptionsProvider
protected function itemToDefaults(array|object $item): array
{
return match (true) {
$item instanceof Obj && $item->hasStringKey === true => [
'arrayItem',
'{{ item.value }}',
'{{ item.key }}'
],
is_array($item),
$item instanceof Obj => [
'arrayItem',