Upgrade to 3.3.0

This commit is contained in:
Bastian Allgeier
2019-11-05 09:35:58 +01:00
parent 447a9dd266
commit a431716732
186 changed files with 3068 additions and 1458 deletions

View File

@@ -1,49 +1,14 @@
<?php
use Kirby\Cms\PagePicker;
return [
'methods' => [
'pagepicker' => function (array $params = []) {
$query = $params['query'] ?? null;
$model = $this->model();
$site = $this->kirby()->site();
// inject the current model
$params['model'] = $this->model();
if ($query) {
$pages = $model->query($query, 'Kirby\Cms\Pages');
$self = null;
} else {
if (!$parent = $site->find($params['parent'] ?? null)) {
$parent = $site;
}
$pages = $parent->children();
$self = [
'id' => $parent->id() == '' ? null : $parent->id(),
'title' => $parent->title()->value(),
'parent' => is_a($parent->parent(), 'Kirby\Cms\Page') === true ? $parent->parent()->id() : null,
];
}
$children = [];
foreach ($pages as $index => $page) {
if ($page->isReadable() === true) {
if (empty($params['map']) === false) {
$children[] = $params['map']($page);
} else {
$children[] = $page->panelPickerData([
'image' => $params['image'] ?? [],
'info' => $params['info'] ?? false,
'model' => $model,
'text' => $params['text'] ?? null,
]);
}
}
}
return [
'model' => $self,
'pages' => $children
];
return (new PagePicker($params))->toArray();
}
]
];