Upgrade to 3.5.5
This commit is contained in:
@@ -36,7 +36,10 @@ return [
|
||||
[
|
||||
'pattern' => [
|
||||
'pages/(:any)/blueprints',
|
||||
// Deprecated: remove in 3.6.0
|
||||
/**
|
||||
* @deprecated
|
||||
* @todo remove in 3.6.0
|
||||
*/
|
||||
'pages/(:any)/children/blueprints',
|
||||
],
|
||||
'method' => 'GET',
|
||||
|
@@ -49,7 +49,10 @@ return [
|
||||
[
|
||||
'pattern' => [
|
||||
'site/blueprints',
|
||||
// Deprecated: remove in 3.6.0
|
||||
/**
|
||||
* @deprecated
|
||||
* @todo remove in 3.6.0
|
||||
*/
|
||||
'site/children/blueprints',
|
||||
],
|
||||
'method' => 'GET',
|
||||
|
@@ -330,6 +330,8 @@ return [
|
||||
* @param Closure $originalHandler Deprecated: Callback function to the original URL handler with `$path` and `$options` as parameters
|
||||
* Use `$kirby->nativeComponent('url')` inside your URL component instead.
|
||||
* @return string
|
||||
*
|
||||
* @todo Remove $originalHandler parameter in 3.6.0
|
||||
*/
|
||||
'url' => function (App $kirby, string $path = null, $options = null, Closure $originalHandler = null): string {
|
||||
$language = null;
|
||||
|
@@ -8,5 +8,10 @@ return [
|
||||
'marks' => function ($marks = true) {
|
||||
return $marks;
|
||||
}
|
||||
],
|
||||
'computed' => [
|
||||
'value' => function () {
|
||||
return trim($this->value);
|
||||
}
|
||||
]
|
||||
];
|
||||
|
@@ -12,9 +12,22 @@ return [
|
||||
},
|
||||
/**
|
||||
* Sets the allowed HTML formats. Available formats: `bold`, `italic`, `underline`, `strike`, `code`, `link`. Activate them all by passing `true`. Deactivate them all by passing `false`
|
||||
* @param array|bool $marks
|
||||
*/
|
||||
'marks' => function ($marks = true) {
|
||||
return $marks;
|
||||
},
|
||||
/**
|
||||
* Sets the allowed nodes. Available nodes: `bulletList`, `orderedList`, `heading`, `horizontalRule`, `listItem`. Activate/deactivate them all by passing `true`/`false`. Default nodes are `heading`, `bulletList`, `orderedList`.
|
||||
* @param array|bool|null $nodes
|
||||
*/
|
||||
'nodes' => function ($nodes = null) {
|
||||
return $nodes;
|
||||
}
|
||||
]
|
||||
],
|
||||
'computed' => [
|
||||
'value' => function () {
|
||||
return trim($this->value);
|
||||
}
|
||||
],
|
||||
];
|
||||
|
@@ -171,14 +171,13 @@ if (function_exists('e') === false) {
|
||||
* Escape context specific output
|
||||
*
|
||||
* @param string $string Untrusted data
|
||||
* @param string $context Location of output
|
||||
* @param bool $strict Whether to escape an extended set of characters (HTML attributes only)
|
||||
* @param string $context Location of output (`html`, `attr`, `js`, `css`, `url` or `xml`)
|
||||
* @return string Escaped data
|
||||
*/
|
||||
function esc($string, $context = 'html', $strict = false)
|
||||
function esc($string, $context = 'html')
|
||||
{
|
||||
if (method_exists('Kirby\Toolkit\Escape', $context) === true) {
|
||||
return Escape::$context($string, $strict);
|
||||
return Escape::$context($string);
|
||||
}
|
||||
|
||||
return $string;
|
||||
@@ -308,15 +307,25 @@ function invalid(array $data = [], array $rules = [], array $messages = [])
|
||||
|
||||
// See: http://php.net/manual/en/types.comparisons.php
|
||||
// only false for: null, undefined variable, '', []
|
||||
$filled = isset($data[$field]) && $data[$field] !== '' && $data[$field] !== [];
|
||||
$value = $data[$field] ?? null;
|
||||
$filled = $value !== null && $value !== '' && $value !== [];
|
||||
$message = $messages[$field] ?? $field;
|
||||
|
||||
// True if there is an error message for each validation method.
|
||||
$messageArray = is_array($message);
|
||||
|
||||
foreach ($validations as $method => $options) {
|
||||
// If the index is numeric, there is no option
|
||||
// and `$value` is sent directly as a `$options` parameter
|
||||
if (is_numeric($method) === true) {
|
||||
$method = $options;
|
||||
$method = $options;
|
||||
$options = [$value];
|
||||
} else {
|
||||
if (is_array($options) === false) {
|
||||
$options = [$options];
|
||||
}
|
||||
|
||||
array_unshift($options, $value);
|
||||
}
|
||||
|
||||
$validationIndex++;
|
||||
@@ -327,12 +336,6 @@ function invalid(array $data = [], array $rules = [], array $messages = [])
|
||||
continue;
|
||||
}
|
||||
} elseif ($filled) {
|
||||
if (is_array($options) === false) {
|
||||
$options = [$options];
|
||||
}
|
||||
|
||||
array_unshift($options, $data[$field] ?? null);
|
||||
|
||||
if (V::$method(...$options) === true) {
|
||||
// Field is filled and passes validation method.
|
||||
continue;
|
||||
|
@@ -337,7 +337,7 @@ return function (App $app) {
|
||||
* templates without the risk of XSS attacks
|
||||
*
|
||||
* @param \Kirby\Cms\Field $field
|
||||
* @param string $context html, attr, js or css
|
||||
* @param string $context Location of output (`html`, `attr`, `js`, `css`, `url` or `xml`)
|
||||
*/
|
||||
'escape' => function (Field $field, string $context = 'html') {
|
||||
$field->value = esc($field->value, $context);
|
||||
@@ -528,7 +528,7 @@ return function (App $app) {
|
||||
* Converts the field content to a slug
|
||||
*
|
||||
* @param \Kirby\Cms\Field $field
|
||||
* @return \Kirby\cms\Field
|
||||
* @return \Kirby\Cms\Field
|
||||
*/
|
||||
'slug' => function (Field $field) {
|
||||
$field->value = Str::slug($field->value);
|
||||
@@ -539,7 +539,7 @@ return function (App $app) {
|
||||
* Applies SmartyPants to the field
|
||||
*
|
||||
* @param \Kirby\Cms\Field $field
|
||||
* @return \Kirby\cms\Field
|
||||
* @return \Kirby\Cms\Field
|
||||
*/
|
||||
'smartypants' => function (Field $field) use ($app) {
|
||||
$field->value = $app->smartypants($field->value);
|
||||
@@ -560,7 +560,7 @@ return function (App $app) {
|
||||
* Converts the field content to uppercase
|
||||
*
|
||||
* @param \Kirby\Cms\Field $field
|
||||
* @return \Kirby\cms\Field
|
||||
* @return \Kirby\Cms\Field
|
||||
*/
|
||||
'upper' => function (Field $field) {
|
||||
$field->value = Str::upper($field->value);
|
||||
@@ -572,7 +572,7 @@ return function (App $app) {
|
||||
* the last space with ` `
|
||||
*
|
||||
* @param \Kirby\Cms\Field $field
|
||||
* @return \Kirby\cms\Field
|
||||
* @return \Kirby\Cms\Field
|
||||
*/
|
||||
'widont' => function (Field $field) {
|
||||
$field->value = Str::widont($field->value);
|
||||
|
@@ -2,6 +2,9 @@
|
||||
|
||||
use Kirby\Cms\Html;
|
||||
use Kirby\Cms\Url;
|
||||
use Kirby\Text\KirbyTag;
|
||||
use Kirby\Toolkit\F;
|
||||
use Kirby\Toolkit\Str;
|
||||
|
||||
/**
|
||||
* Default KirbyTags definition
|
||||
@@ -236,23 +239,113 @@ return [
|
||||
*/
|
||||
'video' => [
|
||||
'attr' => [
|
||||
'class',
|
||||
'autoplay',
|
||||
'caption',
|
||||
'controls',
|
||||
'class',
|
||||
'height',
|
||||
'width'
|
||||
'loop',
|
||||
'muted',
|
||||
'poster',
|
||||
'preload',
|
||||
'style',
|
||||
'width',
|
||||
],
|
||||
'html' => function ($tag) {
|
||||
$video = Html::video(
|
||||
$tag->value,
|
||||
$tag->kirby()->option('kirbytext.video.options', []),
|
||||
[
|
||||
'height' => $tag->height ?? $tag->kirby()->option('kirbytext.video.height'),
|
||||
'width' => $tag->width ?? $tag->kirby()->option('kirbytext.video.width'),
|
||||
]
|
||||
);
|
||||
// all available video tag attributes
|
||||
$availableAttrs = KirbyTag::$types[$tag->type]['attr'];
|
||||
|
||||
return Html::figure([$video], $tag->caption, [
|
||||
'class' => $tag->class ?? $tag->kirby()->option('kirbytext.video.class', 'video'),
|
||||
// global video tag options
|
||||
$attrs = $tag->kirby()->option('kirbytext.video', []);
|
||||
$options = $attrs['options'] ?? [];
|
||||
|
||||
// removes options from attributes
|
||||
if (isset($attrs['options']) === true) {
|
||||
unset($attrs['options']);
|
||||
}
|
||||
|
||||
// injects default values from global options
|
||||
// applies only defined attributes to safely update tag props
|
||||
foreach ($attrs as $key => $value) {
|
||||
if (
|
||||
in_array($key, $availableAttrs) === true &&
|
||||
(isset($tag->{$key}) === false || $tag->{$key} === null)
|
||||
) {
|
||||
$tag->{$key} = $value;
|
||||
}
|
||||
}
|
||||
|
||||
// checks and gets if poster is local file
|
||||
if (
|
||||
empty($tag->poster) === false &&
|
||||
Str::startsWith($tag->poster, 'http://') !== true &&
|
||||
Str::startsWith($tag->poster, 'https://') !== true
|
||||
) {
|
||||
if ($poster = $tag->file($tag->poster)) {
|
||||
$tag->poster = $poster->url();
|
||||
}
|
||||
}
|
||||
|
||||
// converts tag attributes to supported formats (listed below) to output correct html
|
||||
// booleans: autoplay, controls, loop, muted
|
||||
// strings : height, poster, preload, width
|
||||
// for ex : `autoplay` will not work if `false` is a `string` instead of a `boolean`
|
||||
$attrs = [
|
||||
'autoplay' => $autoplay = Str::toType($tag->autoplay, 'bool'),
|
||||
'controls' => Str::toType($tag->controls ?? true, 'bool'),
|
||||
'height' => $tag->height,
|
||||
'loop' => Str::toType($tag->loop, 'bool'),
|
||||
'muted' => Str::toType($tag->muted ?? $autoplay, 'bool'),
|
||||
'poster' => $tag->poster,
|
||||
'preload' => $tag->preload,
|
||||
'width' => $tag->width
|
||||
];
|
||||
|
||||
// handles local and remote video file
|
||||
if (
|
||||
Str::startsWith($tag->value, 'http://') !== true &&
|
||||
Str::startsWith($tag->value, 'https://') !== true
|
||||
) {
|
||||
// handles local video file
|
||||
if ($tag->file = $tag->file($tag->value)) {
|
||||
$source = Html::tag('source', null, [
|
||||
'src' => $tag->file->url(),
|
||||
'type' => $tag->file->mime()
|
||||
]);
|
||||
$video = Html::tag('video', [$source], $attrs);
|
||||
}
|
||||
} else {
|
||||
// firstly handles supported video providers as youtube, vimeo, etc
|
||||
try {
|
||||
$video = Html::video(
|
||||
$tag->value,
|
||||
$options,
|
||||
// providers only support width and height attributes
|
||||
[
|
||||
'height' => $tag->height,
|
||||
'width' => $tag->width
|
||||
]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
// if not one of the supported video providers
|
||||
// it checks if there is a valid remote video file
|
||||
$extension = F::extension($tag->value);
|
||||
$type = F::extensionToType($extension);
|
||||
$mime = F::extensionToMime($extension);
|
||||
|
||||
if ($type === 'video') {
|
||||
$source = Html::tag('source', null, [
|
||||
'src' => $tag->value,
|
||||
'type' => $mime
|
||||
]);
|
||||
$video = Html::tag('video', [$source], $attrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Html::figure([$video ?? ''], $tag->caption, [
|
||||
'class' => $tag->class ?? 'video',
|
||||
'style' => $tag->style
|
||||
]);
|
||||
}
|
||||
],
|
||||
|
@@ -5,4 +5,4 @@
|
||||
* @var string $code
|
||||
* @var int $timeout
|
||||
*/
|
||||
echo I18n::template('login.email.login.body', null, compact('user', 'code', 'timeout'));
|
||||
echo I18n::template('login.email.login.body', null, compact('user', 'code', 'timeout'), $user->language());
|
||||
|
@@ -5,4 +5,4 @@
|
||||
* @var string $code
|
||||
* @var int $timeout
|
||||
*/
|
||||
echo I18n::template('login.email.password-reset.body', null, compact('user', 'code', 'timeout'));
|
||||
echo I18n::template('login.email.password-reset.body', null, compact('user', 'code', 'timeout'), $user->language());
|
||||
|
Reference in New Issue
Block a user