Update Kirby and dependencies
This commit is contained in:
parent
503b339974
commit
399fa20902
439 changed files with 66915 additions and 64442 deletions
|
@ -19,85 +19,85 @@ use Kirby\Toolkit\Str;
|
|||
*/
|
||||
class Fieldsets extends Items
|
||||
{
|
||||
public const ITEM_CLASS = '\Kirby\Cms\Fieldset';
|
||||
public const ITEM_CLASS = '\Kirby\Cms\Fieldset';
|
||||
|
||||
protected static function createFieldsets($params)
|
||||
{
|
||||
$fieldsets = [];
|
||||
$groups = [];
|
||||
protected static function createFieldsets($params)
|
||||
{
|
||||
$fieldsets = [];
|
||||
$groups = [];
|
||||
|
||||
foreach ($params as $type => $fieldset) {
|
||||
if (is_int($type) === true && is_string($fieldset)) {
|
||||
$type = $fieldset;
|
||||
$fieldset = 'blocks/' . $type;
|
||||
}
|
||||
foreach ($params as $type => $fieldset) {
|
||||
if (is_int($type) === true && is_string($fieldset)) {
|
||||
$type = $fieldset;
|
||||
$fieldset = 'blocks/' . $type;
|
||||
}
|
||||
|
||||
if ($fieldset === false) {
|
||||
continue;
|
||||
}
|
||||
if ($fieldset === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($fieldset === true) {
|
||||
$fieldset = 'blocks/' . $type;
|
||||
}
|
||||
if ($fieldset === true) {
|
||||
$fieldset = 'blocks/' . $type;
|
||||
}
|
||||
|
||||
$fieldset = Blueprint::extend($fieldset);
|
||||
$fieldset = Blueprint::extend($fieldset);
|
||||
|
||||
// make sure the type is always set
|
||||
$fieldset['type'] ??= $type;
|
||||
// make sure the type is always set
|
||||
$fieldset['type'] ??= $type;
|
||||
|
||||
// extract groups
|
||||
if ($fieldset['type'] === 'group') {
|
||||
$result = static::createFieldsets($fieldset['fieldsets'] ?? []);
|
||||
$fieldsets = array_merge($fieldsets, $result['fieldsets']);
|
||||
$label = $fieldset['label'] ?? Str::ucfirst($type);
|
||||
// extract groups
|
||||
if ($fieldset['type'] === 'group') {
|
||||
$result = static::createFieldsets($fieldset['fieldsets'] ?? []);
|
||||
$fieldsets = array_merge($fieldsets, $result['fieldsets']);
|
||||
$label = $fieldset['label'] ?? Str::ucfirst($type);
|
||||
|
||||
$groups[$type] = [
|
||||
'label' => I18n::translate($label, $label),
|
||||
'name' => $type,
|
||||
'open' => $fieldset['open'] ?? true,
|
||||
'sets' => array_column($result['fieldsets'], 'type'),
|
||||
];
|
||||
} else {
|
||||
$fieldsets[$fieldset['type']] = $fieldset;
|
||||
}
|
||||
}
|
||||
$groups[$type] = [
|
||||
'label' => I18n::translate($label, $label),
|
||||
'name' => $type,
|
||||
'open' => $fieldset['open'] ?? true,
|
||||
'sets' => array_column($result['fieldsets'], 'type'),
|
||||
];
|
||||
} else {
|
||||
$fieldsets[$fieldset['type']] = $fieldset;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'fieldsets' => $fieldsets,
|
||||
'groups' => $groups
|
||||
];
|
||||
}
|
||||
return [
|
||||
'fieldsets' => $fieldsets,
|
||||
'groups' => $groups
|
||||
];
|
||||
}
|
||||
|
||||
public static function factory(array $items = null, array $params = [])
|
||||
{
|
||||
$items ??= option('blocks.fieldsets', [
|
||||
'code' => 'blocks/code',
|
||||
'gallery' => 'blocks/gallery',
|
||||
'heading' => 'blocks/heading',
|
||||
'image' => 'blocks/image',
|
||||
'line' => 'blocks/line',
|
||||
'list' => 'blocks/list',
|
||||
'markdown' => 'blocks/markdown',
|
||||
'quote' => 'blocks/quote',
|
||||
'text' => 'blocks/text',
|
||||
'video' => 'blocks/video',
|
||||
]);
|
||||
public static function factory(array $items = null, array $params = [])
|
||||
{
|
||||
$items ??= App::instance()->option('blocks.fieldsets', [
|
||||
'code' => 'blocks/code',
|
||||
'gallery' => 'blocks/gallery',
|
||||
'heading' => 'blocks/heading',
|
||||
'image' => 'blocks/image',
|
||||
'line' => 'blocks/line',
|
||||
'list' => 'blocks/list',
|
||||
'markdown' => 'blocks/markdown',
|
||||
'quote' => 'blocks/quote',
|
||||
'text' => 'blocks/text',
|
||||
'video' => 'blocks/video',
|
||||
]);
|
||||
|
||||
$result = static::createFieldsets($items);
|
||||
$result = static::createFieldsets($items);
|
||||
|
||||
return parent::factory($result['fieldsets'], ['groups' => $result['groups']] + $params);
|
||||
}
|
||||
return parent::factory($result['fieldsets'], ['groups' => $result['groups']] + $params);
|
||||
}
|
||||
|
||||
public function groups(): array
|
||||
{
|
||||
return $this->options['groups'] ?? [];
|
||||
}
|
||||
public function groups(): array
|
||||
{
|
||||
return $this->options['groups'] ?? [];
|
||||
}
|
||||
|
||||
public function toArray(?Closure $map = null): array
|
||||
{
|
||||
return A::map(
|
||||
$this->data,
|
||||
$map ?? fn ($fieldset) => $fieldset->toArray()
|
||||
);
|
||||
}
|
||||
public function toArray(?Closure $map = null): array
|
||||
{
|
||||
return A::map(
|
||||
$this->data,
|
||||
$map ?? fn ($fieldset) => $fieldset->toArray()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue