Upgrade to 3.6.1
This commit is contained in:
@@ -200,16 +200,20 @@ return [
|
||||
},
|
||||
'submit' => function (string $id) {
|
||||
$page = Find::page($id);
|
||||
$title = trim(get('title'));
|
||||
$slug = trim(get('slug'));
|
||||
$title = trim(get('title', ''));
|
||||
$slug = trim(get('slug', ''));
|
||||
|
||||
// basic input validation before we move on
|
||||
if (Str::length($title) === 0) {
|
||||
throw new InvalidArgumentException(['key' => 'page.changeTitle.empty']);
|
||||
throw new InvalidArgumentException([
|
||||
'key' => 'page.changeTitle.empty'
|
||||
]);
|
||||
}
|
||||
|
||||
if (Str::length($slug) === 0) {
|
||||
throw new InvalidArgumentException(['key' => 'page.slug.invalid']);
|
||||
throw new InvalidArgumentException([
|
||||
'key' => 'page.slug.invalid'
|
||||
]);
|
||||
}
|
||||
|
||||
// nothing changed
|
||||
@@ -318,7 +322,7 @@ return [
|
||||
];
|
||||
},
|
||||
'submit' => function () {
|
||||
$title = trim(get('title'));
|
||||
$title = trim(get('title', ''));
|
||||
|
||||
if (Str::length($title) === 0) {
|
||||
throw new InvalidArgumentException([
|
||||
|
@@ -37,7 +37,7 @@ return [
|
||||
'plugins' => $plugins,
|
||||
'php' => phpversion(),
|
||||
'server' => $system->serverSoftware(),
|
||||
'ssl' => Server::https(),
|
||||
'https' => Server::https(),
|
||||
'version' => $kirby->version(),
|
||||
]
|
||||
];
|
||||
|
@@ -28,9 +28,7 @@ return [
|
||||
* @param string $url Relative or absolute URL
|
||||
* @param string|array $options An array of attributes for the link tag or a media attribute string
|
||||
*/
|
||||
'css' => function (App $kirby, string $url, $options = null): string {
|
||||
return $url;
|
||||
},
|
||||
'css' => fn (App $kirby, string $url, $options = null): string => $url,
|
||||
|
||||
|
||||
/**
|
||||
@@ -84,9 +82,10 @@ return [
|
||||
* @param \Kirby\Cms\App $kirby Kirby instance
|
||||
* @param \Kirby\Cms\File|\Kirby\Filesystem\Asset $file The file object
|
||||
* @param array $options All thumb options (width, height, crop, blur, grayscale)
|
||||
* @return \Kirby\Cms\File|\Kirby\Cms\FileVersion
|
||||
* @return \Kirby\Cms\File|\Kirby\Cms\FileVersion|\Kirby\Filesystem\Asset
|
||||
*/
|
||||
'file::version' => function (App $kirby, $file, array $options = []) {
|
||||
// if file is not resizable, return
|
||||
if ($file->isResizable() === false) {
|
||||
return $file;
|
||||
}
|
||||
@@ -96,14 +95,20 @@ return [
|
||||
$template = $mediaRoot . '/{{ name }}{{ attributes }}.{{ extension }}';
|
||||
$thumbRoot = (new Filename($file->root(), $template, $options))->toString();
|
||||
$thumbName = basename($thumbRoot);
|
||||
$job = $mediaRoot . '/.jobs/' . $thumbName . '.json';
|
||||
|
||||
// check if the thumb already exists
|
||||
if (file_exists($thumbRoot) === false) {
|
||||
|
||||
// if not, create job file
|
||||
$job = $mediaRoot . '/.jobs/' . $thumbName . '.json';
|
||||
|
||||
try {
|
||||
Data::write($job, array_merge($options, [
|
||||
'filename' => $file->filename()
|
||||
]));
|
||||
} catch (Throwable $e) {
|
||||
// if thumb doesn't exist yet and job file cannot
|
||||
// be created, return
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
@@ -123,9 +128,7 @@ return [
|
||||
* @param string $url Relative or absolute URL
|
||||
* @param string|array $options An array of attributes for the link tag or a media attribute string
|
||||
*/
|
||||
'js' => function (App $kirby, string $url, $options = null): string {
|
||||
return $url;
|
||||
},
|
||||
'js' => fn (App $kirby, string $url, $options = null): string => $url,
|
||||
|
||||
/**
|
||||
* Add your own Markdown parser
|
||||
|
@@ -11,7 +11,7 @@ return [
|
||||
],
|
||||
'computed' => [
|
||||
'value' => function () {
|
||||
return trim($this->value);
|
||||
return trim($this->value ?? '');
|
||||
}
|
||||
]
|
||||
];
|
||||
|
@@ -27,7 +27,7 @@ return [
|
||||
* Sets the default text when a new page/file/user is created
|
||||
*/
|
||||
'default' => function (string $default = null) {
|
||||
return trim($default);
|
||||
return trim($default ?? '');
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ return [
|
||||
},
|
||||
|
||||
'value' => function (string $value = null) {
|
||||
return trim($value);
|
||||
return trim($value ?? '');
|
||||
}
|
||||
],
|
||||
'api' => function () {
|
||||
|
@@ -29,7 +29,8 @@ return [
|
||||
],
|
||||
'computed' => [
|
||||
'value' => function () {
|
||||
return Sane::sanitize(trim($this->value), 'html');
|
||||
$value = trim($this->value ?? '');
|
||||
return Sane::sanitize($value, 'html');
|
||||
}
|
||||
],
|
||||
];
|
||||
|
@@ -98,10 +98,7 @@ function csrf(?string $check = null)
|
||||
function css($url, $options = null): ?string
|
||||
{
|
||||
if (is_array($url) === true) {
|
||||
$links = array_map(function ($url) use ($options) {
|
||||
return css($url, $options);
|
||||
}, $url);
|
||||
|
||||
$links = A::map($url, fn ($url) => css($url, $options));
|
||||
return implode(PHP_EOL, $links);
|
||||
}
|
||||
|
||||
@@ -373,10 +370,7 @@ function invalid(array $data = [], array $rules = [], array $messages = []): arr
|
||||
function js($url, $options = null): ?string
|
||||
{
|
||||
if (is_array($url) === true) {
|
||||
$scripts = array_map(function ($url) use ($options) {
|
||||
return js($url, $options);
|
||||
}, $url);
|
||||
|
||||
$scripts = A::map($url, fn ($url) => js($url, $options));
|
||||
return implode(PHP_EOL, $scripts);
|
||||
}
|
||||
|
||||
@@ -584,7 +578,7 @@ function page(...$id)
|
||||
*/
|
||||
function pages(...$id)
|
||||
{
|
||||
if (count($id) === 1) {
|
||||
if (count($id) === 1 && is_array($id[0]) === false) {
|
||||
// @codeCoverageIgnoreStart
|
||||
deprecated('Passing a single id to the `pages()` helper will return a Kirby\Cms\Pages collection with a single element instead of the single Kirby\Cms\Page object itself - starting in 3.7.0.');
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
@@ -121,13 +121,14 @@ return function (App $app) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$time = empty($field->value) === true ? strtotime($fallback) : $field->toTimestamp();
|
||||
|
||||
if ($format === null) {
|
||||
return $time;
|
||||
if (empty($field->value) === false) {
|
||||
$time = $field->toTimestamp();
|
||||
} else {
|
||||
$time = strtotime($fallback);
|
||||
}
|
||||
|
||||
return ($app->option('date.handler', 'date'))($format, $time);
|
||||
$handler = $app->option('date.handler', 'date');
|
||||
return Str::date($time, $format, $handler);
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -384,7 +385,7 @@ return function (App $app) {
|
||||
// Obsolete elements, script tags, image maps and form elements have
|
||||
// been excluded for safety reasons and as they are most likely not
|
||||
// needed in most cases.
|
||||
$field->value = strip_tags($field->value, '<b><i><small><abbr><cite><code><dfn><em><kbd><strong><samp><var><a><bdo><br><img><q><span><sub><sup>');
|
||||
$field->value = strip_tags($field->value, Html::$inlineList);
|
||||
return $field;
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user