Upgrade to 3.2.1

This commit is contained in:
Bastian Allgeier
2019-07-09 16:45:40 +02:00
parent 7b4170f17e
commit 2694b3d76f
38 changed files with 282 additions and 150 deletions

View File

@@ -1,5 +1,7 @@
<?php
use Kirby\Exception\Exception;
return [
'props' => [
/**
@@ -79,6 +81,49 @@ return [
return '';
},
'validations' => [
'date'
'date',
'minMax' => function ($value) {
$min = $this->min ? strtotime($this->min) : null;
$max = $this->max ? strtotime($this->max) : null;
$value = strtotime($this->value());
$format = 'd.m.Y';
$errors = [];
if ($value && $min && $value < $min) {
$errors['min'] = $min;
}
if ($value && $max && $value > $max) {
$errors['max'] = $max;
}
if (empty($errors) === false) {
if ($min && $max) {
throw new Exception([
'key' => 'validation.date.between',
'data' => [
'min' => date($format, $min),
'max' => date($format, $max)
]
]);
} elseif ($min) {
throw new Exception([
'key' => 'validation.date.after',
'data' => [
'date' => date($format, $min),
]
]);
} else {
throw new Exception([
'key' => 'validation.date.before',
'data' => [
'date' => date($format, $max),
]
]);
}
}
return true;
},
]
];

View File

@@ -13,8 +13,8 @@ return [
/**
* Image settings for each item
*/
'image' => function (array $image = null) {
return $image ?? [];
'image' => function ($image = null) {
return $image;
},
/**
@@ -55,7 +55,7 @@ return [
/**
* Main text for each item
*/
'text' => function (string $text = '{{ file.filename }}') {
'text' => function (string $text = null) {
return $text;
},

View File

@@ -1,6 +1,7 @@
<?php
use Kirby\Cms\Api;
use Kirby\Cms\File;
return [
'props' => [
@@ -13,13 +14,26 @@ return [
}
if (is_string($uploads) === true) {
return ['template' => $uploads];
$uploads = ['template' => $uploads];
}
if (is_array($uploads) === false) {
$uploads = [];
}
$template = $uploads['template'] ?? null;
if ($template) {
$file = new File([
'filename' => 'tmp',
'template' => $template
]);
$uploads['accept'] = $file->blueprint()->accept()['mime'] ?? '*';
} else {
$uploads['accept'] = '*';
}
return $uploads;
},
],

View File

@@ -22,20 +22,6 @@ return [
return $this->toPages($default);
},
/**
* Image settings for each item
*/
'image' => function (array $image = null) {
return $image ?? [];
},
/**
* Info text for each item
*/
'info' => function (string $info = null) {
return $info;
},
/**
* Changes the layout of the selected files. Available layouts: `list`, `cards`
*/
@@ -57,13 +43,6 @@ return [
return $size;
},
/**
* Main text for each item
*/
'text' => function (string $text = null) {
return $text;
},
'value' => function ($value = null) {
return $this->toPages($value);
},