Upgrade to 3.2.0
This commit is contained in:
@@ -3,7 +3,12 @@
|
||||
use Kirby\Toolkit\A;
|
||||
|
||||
return [
|
||||
'mixins' => ['min'],
|
||||
'mixins' => [
|
||||
'picker',
|
||||
'filepicker',
|
||||
'min',
|
||||
'upload'
|
||||
],
|
||||
'props' => [
|
||||
/**
|
||||
* Unset inherited props
|
||||
@@ -21,27 +26,6 @@ return [
|
||||
return $default;
|
||||
},
|
||||
|
||||
/**
|
||||
* The placeholder text if no pages have been selected yet
|
||||
*/
|
||||
'empty' => function ($empty = null) {
|
||||
return I18n::translate($empty, $empty);
|
||||
},
|
||||
|
||||
/**
|
||||
* Image settings for each item
|
||||
*/
|
||||
'image' => function (array $image = null) {
|
||||
return $image ?? [];
|
||||
},
|
||||
|
||||
/**
|
||||
* Info text
|
||||
*/
|
||||
'info' => function (string $info = null) {
|
||||
return $info;
|
||||
},
|
||||
|
||||
/**
|
||||
* Changes the layout of the selected files. Available layouts: `list`, `cards`
|
||||
*/
|
||||
@@ -49,48 +33,13 @@ return [
|
||||
return $layout;
|
||||
},
|
||||
|
||||
/**
|
||||
* Minimum number of required files
|
||||
*/
|
||||
'min' => function (int $min = null) {
|
||||
return $min;
|
||||
},
|
||||
|
||||
/**
|
||||
* Maximum number of allowed files
|
||||
*/
|
||||
'max' => function (int $max = null) {
|
||||
return $max;
|
||||
},
|
||||
|
||||
/**
|
||||
* If false, only a single file can be selected
|
||||
*/
|
||||
'multiple' => function (bool $multiple = true) {
|
||||
return $multiple;
|
||||
},
|
||||
|
||||
/**
|
||||
* Query for the files to be included
|
||||
*/
|
||||
'query' => function (string $query = null) {
|
||||
return $query;
|
||||
},
|
||||
|
||||
/**
|
||||
* Layout size for cards: `tiny`, `small`, `medium`, `large` or `huge`
|
||||
*/
|
||||
'size' => function (string $size = null) {
|
||||
'size' => function (string $size = 'auto') {
|
||||
return $size;
|
||||
},
|
||||
|
||||
/**
|
||||
* Main text
|
||||
*/
|
||||
'text' => function (string $text = '{{ file.filename }}') {
|
||||
return $text;
|
||||
},
|
||||
|
||||
'value' => function ($value = null) {
|
||||
return $value;
|
||||
}
|
||||
@@ -118,38 +67,15 @@ return [
|
||||
],
|
||||
'methods' => [
|
||||
'fileResponse' => function ($file) {
|
||||
if ($this->layout === 'list') {
|
||||
$thumb = [
|
||||
'width' => 100,
|
||||
'height' => 100
|
||||
];
|
||||
} else {
|
||||
$thumb = [
|
||||
'width' => 400,
|
||||
'height' => 400
|
||||
];
|
||||
}
|
||||
|
||||
$image = $file->panelImage($this->image, $thumb);
|
||||
$model = $this->model();
|
||||
$uuid = $file->parent() === $model ? $file->filename() : $file->id();
|
||||
|
||||
return [
|
||||
'filename' => $file->filename(),
|
||||
'text' => $file->toString($this->text),
|
||||
'link' => $file->panelUrl(true),
|
||||
'id' => $file->id(),
|
||||
'uuid' => $uuid,
|
||||
'url' => $file->url(),
|
||||
'info' => $file->toString($this->info ?? false),
|
||||
'image' => $image,
|
||||
'icon' => $file->panelIcon($image),
|
||||
'type' => $file->type(),
|
||||
];
|
||||
return $file->panelPickerData([
|
||||
'image' => $this->image,
|
||||
'info' => $this->info ?? false,
|
||||
'model' => $this->model(),
|
||||
'text' => $this->text,
|
||||
]);
|
||||
},
|
||||
'toFiles' => function ($value = null) {
|
||||
$files = [];
|
||||
$kirby = kirby();
|
||||
|
||||
foreach (Yaml::decode($value) as $id) {
|
||||
if (is_array($id) === true) {
|
||||
@@ -168,16 +94,32 @@ return [
|
||||
return [
|
||||
[
|
||||
'pattern' => '/',
|
||||
'action' => function () {
|
||||
'action' => function () {
|
||||
$field = $this->field();
|
||||
$files = $field->model()->query($field->query(), 'Kirby\Cms\Files');
|
||||
$data = [];
|
||||
|
||||
foreach ($files as $index => $file) {
|
||||
$data[] = $field->fileResponse($file);
|
||||
}
|
||||
return $field->filepicker([
|
||||
'query' => $field->query(),
|
||||
'image' => $field->image(),
|
||||
'info' => $field->info(),
|
||||
'text' => $field->text()
|
||||
]);
|
||||
}
|
||||
],
|
||||
[
|
||||
'pattern' => 'upload',
|
||||
'method' => 'POST',
|
||||
'action' => function () {
|
||||
$field = $this->field();
|
||||
$uploads = $field->uploads();
|
||||
|
||||
return $data;
|
||||
return $field->upload($this, $uploads, function ($file) use ($field) {
|
||||
return $file->panelPickerData([
|
||||
'image' => $field->image(),
|
||||
'info' => $field->info(),
|
||||
'model' => $field->model(),
|
||||
'text' => $field->text(),
|
||||
]);
|
||||
});
|
||||
}
|
||||
]
|
||||
];
|
||||
|
Reference in New Issue
Block a user