Upgrade to 3.3.0
This commit is contained in:
@@ -99,10 +99,13 @@ return [
|
||||
$field = $this->field();
|
||||
|
||||
return $field->filepicker([
|
||||
'query' => $field->query(),
|
||||
'image' => $field->image(),
|
||||
'info' => $field->info(),
|
||||
'text' => $field->text()
|
||||
'image' => $field->image(),
|
||||
'info' => $field->info(),
|
||||
'limit' => $field->limit(),
|
||||
'page' => $this->requestQuery('page'),
|
||||
'query' => $field->query(),
|
||||
'search' => $this->requestQuery('search'),
|
||||
'text' => $field->text()
|
||||
]);
|
||||
}
|
||||
],
|
||||
|
@@ -15,7 +15,8 @@ return [
|
||||
'text' => function () {
|
||||
if ($text = $this->text) {
|
||||
$text = $this->model()->toString($text);
|
||||
return kirbytext($text);
|
||||
$text = $this->kirby()->kirbytext($text);
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@@ -1,40 +1,14 @@
|
||||
<?php
|
||||
|
||||
use Kirby\Cms\FilePicker;
|
||||
|
||||
return [
|
||||
'methods' => [
|
||||
'filepicker' => function (array $params = []) {
|
||||
|
||||
// fetch the parent model
|
||||
$model = $this->model();
|
||||
$params['model'] = $this->model();
|
||||
|
||||
// find the right default query
|
||||
if (empty($params['query']) === false) {
|
||||
$query = $params['query'];
|
||||
} elseif (is_a($model, 'Kirby\Cms\File') === true) {
|
||||
$query = 'file.siblings';
|
||||
} else {
|
||||
$query = $model::CLASS_ALIAS . '.files';
|
||||
}
|
||||
|
||||
// fetch all files for the picker
|
||||
$files = $model->query($query, 'Kirby\Cms\Files');
|
||||
$data = [];
|
||||
|
||||
// prepare the response for each file
|
||||
foreach ($files as $index => $file) {
|
||||
if (empty($params['map']) === false) {
|
||||
$data[] = $params['map']($file);
|
||||
} else {
|
||||
$data[] = $file->panelPickerData([
|
||||
'image' => $params['image'] ?? [],
|
||||
'info' => $params['info'] ?? false,
|
||||
'model' => $model,
|
||||
'text' => $params['text'] ?? '{{ file.filename }}',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
return (new FilePicker($params))->toArray();
|
||||
}
|
||||
]
|
||||
];
|
||||
|
@@ -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();
|
||||
}
|
||||
]
|
||||
];
|
||||
|
@@ -53,6 +53,13 @@ return [
|
||||
return $query;
|
||||
},
|
||||
|
||||
/**
|
||||
* Enable/disable the search field in the picker
|
||||
*/
|
||||
'search' => function (bool $search = true) {
|
||||
return $search;
|
||||
},
|
||||
|
||||
/**
|
||||
* Main text for each item
|
||||
*/
|
||||
|
@@ -1,44 +1,13 @@
|
||||
<?php
|
||||
|
||||
use Kirby\Cms\UserPicker;
|
||||
|
||||
return [
|
||||
'methods' => [
|
||||
'userpicker' => function (array $params = []) {
|
||||
$params['model'] = $this->model();
|
||||
|
||||
// fetch the parent model
|
||||
$model = $this->model();
|
||||
|
||||
// find the right default query
|
||||
if (empty($params['query']) === false) {
|
||||
$query = $params['query'];
|
||||
} elseif (is_a($model, 'Kirby\Cms\User') === true) {
|
||||
$query = 'user.siblings';
|
||||
} else {
|
||||
$query = 'kirby.users';
|
||||
}
|
||||
|
||||
// fetch all users for the picker
|
||||
$users = $model->query($query, 'Kirby\Cms\Users');
|
||||
$data = [];
|
||||
|
||||
if (!$users) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// prepare the response for each user
|
||||
foreach ($users->sortBy('username', 'asc') as $index => $user) {
|
||||
if (empty($params['map']) === false) {
|
||||
$data[] = $params['map']($user);
|
||||
} else {
|
||||
$data[] = $user->panelPickerData([
|
||||
'image' => $params['image'] ?? [],
|
||||
'info' => $params['info'] ?? false,
|
||||
'model' => $model,
|
||||
'text' => $params['text'] ?? '{{ user.username }}',
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
return (new UserPicker($params))->toArray();
|
||||
}
|
||||
]
|
||||
];
|
||||
|
@@ -43,6 +43,13 @@ return [
|
||||
return $size;
|
||||
},
|
||||
|
||||
/**
|
||||
* Optionally include subpages of pages
|
||||
*/
|
||||
'subpages' => function (bool $subpages = true) {
|
||||
return $subpages;
|
||||
},
|
||||
|
||||
'value' => function ($value = null) {
|
||||
return $this->toPages($value);
|
||||
},
|
||||
@@ -86,11 +93,15 @@ return [
|
||||
$field = $this->field();
|
||||
|
||||
return $field->pagepicker([
|
||||
'image' => $field->image(),
|
||||
'info' => $field->info(),
|
||||
'parent' => $this->requestQuery('parent'),
|
||||
'query' => $field->query(),
|
||||
'text' => $field->text()
|
||||
'image' => $field->image(),
|
||||
'info' => $field->info(),
|
||||
'limit' => $field->limit(),
|
||||
'page' => $this->requestQuery('page'),
|
||||
'parent' => $this->requestQuery('parent'),
|
||||
'query' => $field->query(),
|
||||
'search' => $this->requestQuery('search'),
|
||||
'subpages' => $field->subpages(),
|
||||
'text' => $field->text()
|
||||
]);
|
||||
}
|
||||
]
|
||||
|
@@ -84,6 +84,10 @@ return [
|
||||
return $this->rows($this->value);
|
||||
},
|
||||
'fields' => function () {
|
||||
if (empty($this->fields) === true) {
|
||||
throw new Exception('Please provide some fields for the structure');
|
||||
}
|
||||
|
||||
return $this->form()->fields()->toArray();
|
||||
},
|
||||
'columns' => function () {
|
||||
|
@@ -75,17 +75,20 @@ return [
|
||||
$field = $this->field();
|
||||
|
||||
return $field->userpicker([
|
||||
'query' => $field->query(),
|
||||
'image' => $field->image(),
|
||||
'info' => $field->info(),
|
||||
'text' => $field->text()
|
||||
'image' => $field->image(),
|
||||
'info' => $field->info(),
|
||||
'limit' => $field->limit(),
|
||||
'page' => $this->requestQuery('page'),
|
||||
'query' => $field->query(),
|
||||
'search' => $this->requestQuery('search'),
|
||||
'text' => $field->text()
|
||||
]);
|
||||
}
|
||||
]
|
||||
];
|
||||
},
|
||||
'save' => function ($value = null) {
|
||||
return A::pluck($value, 'email');
|
||||
return A::pluck($value, 'id');
|
||||
},
|
||||
'validations' => [
|
||||
'max',
|
||||
|
Reference in New Issue
Block a user