Upgrade to 4.6.0
This commit is contained in:
@@ -8,7 +8,7 @@ return [
|
||||
'pages' => [
|
||||
'label' => I18n::translate('pages'),
|
||||
'icon' => 'page',
|
||||
'query' => function (string $query = null, int $limit, int $page) {
|
||||
'query' => function (string|null $query, int $limit, int $page) {
|
||||
$kirby = App::instance();
|
||||
$pages = $kirby->site()
|
||||
->index(true)
|
||||
@@ -31,7 +31,7 @@ return [
|
||||
'files' => [
|
||||
'label' => I18n::translate('files'),
|
||||
'icon' => 'image',
|
||||
'query' => function (string $query = null, int $limit, int $page) {
|
||||
'query' => function (string|null $query, int $limit, int $page) {
|
||||
$kirby = App::instance();
|
||||
$files = $kirby->site()
|
||||
->index(true)
|
||||
|
@@ -35,7 +35,7 @@ return [
|
||||
],
|
||||
[
|
||||
'label' => I18n::translate('server'),
|
||||
'value' => $system->serverSoftware() ?? '?',
|
||||
'value' => $system->serverSoftwareShort() ?? '?',
|
||||
'icon' => 'server'
|
||||
]
|
||||
];
|
||||
|
@@ -8,7 +8,7 @@ return [
|
||||
'users' => [
|
||||
'label' => I18n::translate('users'),
|
||||
'icon' => 'users',
|
||||
'query' => function (string $query = null, int $limit, int $page) {
|
||||
'query' => function (string|null $query, int $limit, int $page) {
|
||||
$kirby = App::instance();
|
||||
$users = $kirby->users()
|
||||
->search($query)
|
||||
|
@@ -7,6 +7,7 @@ fields:
|
||||
type: radio
|
||||
columns: 2
|
||||
default: "kirby"
|
||||
required: true
|
||||
options:
|
||||
kirby: "{{ t('field.blocks.image.location.internal') }}"
|
||||
web: "{{ t('field.blocks.image.location.external') }}"
|
||||
|
@@ -118,7 +118,7 @@ return [
|
||||
*/
|
||||
'markdown' => function (
|
||||
App $kirby,
|
||||
string $text = null,
|
||||
string|null $text = null,
|
||||
array $options = []
|
||||
): string {
|
||||
static $markdown;
|
||||
@@ -230,7 +230,7 @@ return [
|
||||
$scoring['score'] += 16 * $score;
|
||||
$scoring['hits'] += 1;
|
||||
|
||||
// check for exact beginning matches
|
||||
// check for exact beginning matches
|
||||
} elseif (
|
||||
$options['words'] === false &&
|
||||
Str::startsWith($lowerValue, $query) === true
|
||||
@@ -238,7 +238,7 @@ return [
|
||||
$scoring['score'] += 8 * $score;
|
||||
$scoring['hits'] += 1;
|
||||
|
||||
// check for exact query matches
|
||||
// check for exact query matches
|
||||
} elseif ($matches = preg_match_all('!' . $exact . '!ui', $value, $r)) {
|
||||
$scoring['score'] += 2 * $score;
|
||||
$scoring['hits'] += $matches;
|
||||
@@ -270,7 +270,7 @@ return [
|
||||
*/
|
||||
'smartypants' => function (
|
||||
App $kirby,
|
||||
string $text = null,
|
||||
string|null $text = null,
|
||||
array $options = []
|
||||
): string {
|
||||
static $smartypants;
|
||||
@@ -354,7 +354,7 @@ return [
|
||||
*/
|
||||
'url' => function (
|
||||
App $kirby,
|
||||
string $path = null,
|
||||
string|null $path = null,
|
||||
$options = null
|
||||
): string {
|
||||
$language = null;
|
||||
|
@@ -29,13 +29,13 @@ return [
|
||||
/**
|
||||
* Maximum number of checked boxes
|
||||
*/
|
||||
'max' => function (int $max = null) {
|
||||
'max' => function (int|null $max = null) {
|
||||
return $max;
|
||||
},
|
||||
/**
|
||||
* Minimum number of checked boxes
|
||||
*/
|
||||
'min' => function (int $min = null) {
|
||||
'min' => function (int|null $min = null) {
|
||||
return $min;
|
||||
},
|
||||
'value' => function ($value = null) {
|
||||
|
@@ -24,7 +24,7 @@ return [
|
||||
/**
|
||||
* Default date when a new page/file/user gets created
|
||||
*/
|
||||
'default' => function (string $default = null): string {
|
||||
'default' => function (string|null $default = null): string {
|
||||
return $this->toDatetime($default) ?? '';
|
||||
},
|
||||
|
||||
@@ -46,13 +46,13 @@ return [
|
||||
/**
|
||||
* Latest date, which can be selected/saved (Y-m-d)
|
||||
*/
|
||||
'max' => function (string $max = null): string|null {
|
||||
'max' => function (string|null $max = null): string|null {
|
||||
return Date::optional($max);
|
||||
},
|
||||
/**
|
||||
* Earliest date, which can be selected/saved (Y-m-d)
|
||||
*/
|
||||
'min' => function (string $min = null): string|null {
|
||||
'min' => function (string|null $min = null): string|null {
|
||||
return Date::optional($min);
|
||||
},
|
||||
|
||||
|
@@ -26,7 +26,7 @@ return [
|
||||
/**
|
||||
* Change the design of the info box
|
||||
*/
|
||||
'theme' => function (string $theme = null) {
|
||||
'theme' => function (string|null $theme = null) {
|
||||
return $theme;
|
||||
}
|
||||
],
|
||||
|
@@ -16,14 +16,29 @@ return [
|
||||
* @values 'anchor', 'url, 'page, 'file', 'email', 'tel', 'custom'
|
||||
*/
|
||||
'options' => function (array|null $options = null): array {
|
||||
return $options ?? [
|
||||
'url',
|
||||
'page',
|
||||
'file',
|
||||
'email',
|
||||
'tel',
|
||||
'anchor'
|
||||
];
|
||||
// default options
|
||||
if ($options === null) {
|
||||
return [
|
||||
'url',
|
||||
'page',
|
||||
'file',
|
||||
'email',
|
||||
'tel',
|
||||
'anchor'
|
||||
];
|
||||
}
|
||||
|
||||
// validate options
|
||||
$available = array_keys($this->availableTypes());
|
||||
|
||||
if ($unavailable = array_diff($options, $available)) {
|
||||
throw new InvalidArgumentException([
|
||||
'key' => 'field.link.options',
|
||||
'data' => ['options' => implode(', ', $unavailable)]
|
||||
]);
|
||||
}
|
||||
|
||||
return $options;
|
||||
},
|
||||
'value' => function (string|null $value = null) {
|
||||
return $value ?? '';
|
||||
@@ -31,9 +46,11 @@ return [
|
||||
],
|
||||
'methods' => [
|
||||
'activeTypes' => function () {
|
||||
return array_filter($this->availableTypes(), function (string $type) {
|
||||
return in_array($type, $this->props['options']) === true;
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
return array_filter(
|
||||
$this->availableTypes(),
|
||||
fn (string $type) => in_array($type, $this->props['options']),
|
||||
ARRAY_FILTER_USE_KEY
|
||||
);
|
||||
},
|
||||
'availableTypes' => function () {
|
||||
return [
|
||||
|
@@ -7,7 +7,7 @@ return [
|
||||
/**
|
||||
* Defines a custom format that is used when the field is saved
|
||||
*/
|
||||
'format' => function (string $format = null) {
|
||||
'format' => function (string|null $format = null) {
|
||||
return $format;
|
||||
}
|
||||
],
|
||||
|
@@ -23,7 +23,7 @@ return [
|
||||
/**
|
||||
* Info text for each item
|
||||
*/
|
||||
'info' => function (string $info = null) {
|
||||
'info' => function (string|null $info = null) {
|
||||
return $info;
|
||||
},
|
||||
|
||||
@@ -37,14 +37,14 @@ return [
|
||||
/**
|
||||
* The minimum number of required selected
|
||||
*/
|
||||
'min' => function (int $min = null) {
|
||||
'min' => function (int|null $min = null) {
|
||||
return $min;
|
||||
},
|
||||
|
||||
/**
|
||||
* The maximum number of allowed selected
|
||||
*/
|
||||
'max' => function (int $max = null) {
|
||||
'max' => function (int|null $max = null) {
|
||||
return $max;
|
||||
},
|
||||
|
||||
@@ -58,7 +58,7 @@ return [
|
||||
/**
|
||||
* Query for the items to be included in the picker
|
||||
*/
|
||||
'query' => function (string $query = null) {
|
||||
'query' => function (string|null $query = null) {
|
||||
return $query;
|
||||
},
|
||||
|
||||
@@ -86,7 +86,7 @@ return [
|
||||
/**
|
||||
* Main text for each item
|
||||
*/
|
||||
'text' => function (string $text = null) {
|
||||
'text' => function (string|null $text = null) {
|
||||
return $text;
|
||||
},
|
||||
],
|
||||
|
@@ -74,7 +74,7 @@ return [
|
||||
return $map($file, $parent);
|
||||
});
|
||||
},
|
||||
'uploadParent' => function (string $parentQuery = null) {
|
||||
'uploadParent' => function (string|null $parentQuery = null) {
|
||||
$parent = $this->model();
|
||||
|
||||
if ($parentQuery) {
|
||||
|
@@ -13,13 +13,13 @@ return [
|
||||
/**
|
||||
* The lowest allowed number
|
||||
*/
|
||||
'min' => function (float $min = null) {
|
||||
'min' => function (float|null $min = null) {
|
||||
return $min;
|
||||
},
|
||||
/**
|
||||
* The highest allowed number
|
||||
*/
|
||||
'max' => function (float $max = null) {
|
||||
'max' => function (float|null $max = null) {
|
||||
return $max;
|
||||
},
|
||||
/**
|
||||
|
@@ -31,7 +31,7 @@ return [
|
||||
/**
|
||||
* Optional query to select a specific set of pages
|
||||
*/
|
||||
'query' => function (string $query = null) {
|
||||
'query' => function (string|null $query = null) {
|
||||
return $query;
|
||||
},
|
||||
|
||||
|
@@ -13,7 +13,7 @@ return [
|
||||
/**
|
||||
* Custom icon to replace the arrow down.
|
||||
*/
|
||||
'icon' => function (string $icon = null) {
|
||||
'icon' => function (string|null $icon = null) {
|
||||
return $icon;
|
||||
},
|
||||
/**
|
||||
|
@@ -28,7 +28,7 @@ return [
|
||||
/**
|
||||
* Set prefix for the help text
|
||||
*/
|
||||
'path' => function (string $path = null) {
|
||||
'path' => function (string|null $path = null) {
|
||||
return $path;
|
||||
},
|
||||
|
||||
@@ -36,7 +36,7 @@ return [
|
||||
* Name of another field that should be used to
|
||||
* automatically update this field's value
|
||||
*/
|
||||
'sync' => function (string $sync = null) {
|
||||
'sync' => function (string|null $sync = null) {
|
||||
return $sync;
|
||||
},
|
||||
|
||||
|
@@ -45,7 +45,7 @@ return [
|
||||
/**
|
||||
* Set the default rows for the structure
|
||||
*/
|
||||
'default' => function (array $default = null) {
|
||||
'default' => function (array|null $default = null) {
|
||||
return $default;
|
||||
},
|
||||
|
||||
@@ -58,38 +58,38 @@ return [
|
||||
/**
|
||||
* The number of entries that will be displayed on a single page. Afterwards pagination kicks in.
|
||||
*/
|
||||
'limit' => function (int $limit = null) {
|
||||
'limit' => function (int|null $limit = null) {
|
||||
return $limit;
|
||||
},
|
||||
/**
|
||||
* Maximum allowed entries in the structure. Afterwards the "Add" button will be switched off.
|
||||
*/
|
||||
'max' => function (int $max = null) {
|
||||
'max' => function (int|null $max = null) {
|
||||
return $max;
|
||||
},
|
||||
/**
|
||||
* Minimum required entries in the structure
|
||||
*/
|
||||
'min' => function (int $min = null) {
|
||||
'min' => function (int|null $min = null) {
|
||||
return $min;
|
||||
},
|
||||
/**
|
||||
* Toggles adding to the top or bottom of the list
|
||||
*/
|
||||
'prepend' => function (bool $prepend = null) {
|
||||
'prepend' => function (bool|null $prepend = null) {
|
||||
return $prepend;
|
||||
},
|
||||
/**
|
||||
* Toggles drag & drop sorting
|
||||
*/
|
||||
'sortable' => function (bool $sortable = null) {
|
||||
'sortable' => function (bool|null $sortable = null) {
|
||||
return $sortable;
|
||||
},
|
||||
/**
|
||||
* Sorts the entries by the given field and order (i.e. `title desc`)
|
||||
* Drag & drop is disabled in this case
|
||||
*/
|
||||
'sortBy' => function (string $sort = null) {
|
||||
'sortBy' => function (string|null $sort = null) {
|
||||
return $sort;
|
||||
}
|
||||
],
|
||||
|
@@ -37,13 +37,13 @@ return [
|
||||
/**
|
||||
* Minimum number of required entries/tags
|
||||
*/
|
||||
'min' => function (int $min = null) {
|
||||
'min' => function (int|null $min = null) {
|
||||
return $min;
|
||||
},
|
||||
/**
|
||||
* Maximum number of allowed entries/tags
|
||||
*/
|
||||
'max' => function (int $max = null) {
|
||||
'max' => function (int|null $max = null) {
|
||||
return $max;
|
||||
},
|
||||
/**
|
||||
@@ -93,7 +93,7 @@ return [
|
||||
return $value;
|
||||
}
|
||||
],
|
||||
'save' => function (array $value = null): string {
|
||||
'save' => function (array|null $value = null): string {
|
||||
return A::join(
|
||||
$value,
|
||||
$this->separator() . ' '
|
||||
|
@@ -30,28 +30,28 @@ return [
|
||||
/**
|
||||
* Sets the font family (sans or monospace)
|
||||
*/
|
||||
'font' => function (string $font = null) {
|
||||
'font' => function (string|null $font = null) {
|
||||
return $font === 'monospace' ? 'monospace' : 'sans-serif';
|
||||
},
|
||||
|
||||
/**
|
||||
* Maximum number of allowed characters
|
||||
*/
|
||||
'maxlength' => function (int $maxlength = null) {
|
||||
'maxlength' => function (int|null $maxlength = null) {
|
||||
return $maxlength;
|
||||
},
|
||||
|
||||
/**
|
||||
* Minimum number of required characters
|
||||
*/
|
||||
'minlength' => function (int $minlength = null) {
|
||||
'minlength' => function (int|null $minlength = null) {
|
||||
return $minlength;
|
||||
},
|
||||
|
||||
/**
|
||||
* A regular expression, which will be used to validate the input
|
||||
*/
|
||||
'pattern' => function (string $pattern = null) {
|
||||
'pattern' => function (string|null $pattern = null) {
|
||||
return $pattern;
|
||||
},
|
||||
|
||||
|
@@ -26,7 +26,7 @@ return [
|
||||
/**
|
||||
* Sets the default text when a new page/file/user is created
|
||||
*/
|
||||
'default' => function (string $default = null) {
|
||||
'default' => function (string|null $default = null) {
|
||||
return trim($default ?? '');
|
||||
},
|
||||
|
||||
@@ -48,28 +48,28 @@ return [
|
||||
/**
|
||||
* Sets the font family (sans or monospace)
|
||||
*/
|
||||
'font' => function (string $font = null) {
|
||||
'font' => function (string|null $font = null) {
|
||||
return $font === 'monospace' ? 'monospace' : 'sans-serif';
|
||||
},
|
||||
|
||||
/**
|
||||
* Maximum number of allowed characters
|
||||
*/
|
||||
'maxlength' => function (int $maxlength = null) {
|
||||
'maxlength' => function (int|null $maxlength = null) {
|
||||
return $maxlength;
|
||||
},
|
||||
|
||||
/**
|
||||
* Minimum number of required characters
|
||||
*/
|
||||
'minlength' => function (int $minlength = null) {
|
||||
'minlength' => function (int|null $minlength = null) {
|
||||
return $minlength;
|
||||
},
|
||||
|
||||
/**
|
||||
* Changes the size of the textarea. Available sizes: `small`, `medium`, `large`, `huge`
|
||||
*/
|
||||
'size' => function (string $size = null) {
|
||||
'size' => function (string|null $size = null) {
|
||||
return $size;
|
||||
},
|
||||
|
||||
@@ -80,7 +80,7 @@ return [
|
||||
return $spellcheck;
|
||||
},
|
||||
|
||||
'value' => function (string $value = null) {
|
||||
'value' => function (string|null $value = null) {
|
||||
return trim($value ?? '');
|
||||
}
|
||||
],
|
||||
|
@@ -36,13 +36,13 @@ return [
|
||||
/**
|
||||
* Latest time, which can be selected/saved (H:i or H:i:s)
|
||||
*/
|
||||
'max' => function (string $max = null): string|null {
|
||||
'max' => function (string|null $max = null): string|null {
|
||||
return Date::optional($max);
|
||||
},
|
||||
/**
|
||||
* Earliest time, which can be selected/saved (H:i or H:i:s)
|
||||
*/
|
||||
'min' => function (string $min = null): string|null {
|
||||
'min' => function (string|null $min = null): string|null {
|
||||
return Date::optional($min);
|
||||
},
|
||||
|
||||
|
@@ -36,14 +36,14 @@ return [
|
||||
/**
|
||||
* Maximum number of allowed characters
|
||||
*/
|
||||
'maxlength' => function (int $maxlength = null) {
|
||||
'maxlength' => function (int|null $maxlength = null) {
|
||||
return $maxlength;
|
||||
},
|
||||
|
||||
/**
|
||||
* Minimum number of required characters
|
||||
*/
|
||||
'minlength' => function (int $minlength = null) {
|
||||
'minlength' => function (int|null $minlength = null) {
|
||||
return $minlength;
|
||||
},
|
||||
/**
|
||||
|
@@ -7,6 +7,8 @@ use Kirby\Cms\Html;
|
||||
use Kirby\Cms\ModelWithContent;
|
||||
use Kirby\Cms\Page;
|
||||
use Kirby\Cms\Pages;
|
||||
use Kirby\Cms\Plugin;
|
||||
use Kirby\Cms\PluginAssets;
|
||||
use Kirby\Cms\Response;
|
||||
use Kirby\Cms\Site;
|
||||
use Kirby\Cms\Url;
|
||||
@@ -89,7 +91,7 @@ if (Helpers::hasOverride('css') === false) { // @codeCoverageIgnore
|
||||
* @param string|array|null $options Pass an array of attributes for the link tag or a media attribute string
|
||||
*/
|
||||
function css(
|
||||
string|array $url,
|
||||
string|array|Plugin|PluginAssets $url,
|
||||
string|array|null $options = null
|
||||
): string|null {
|
||||
return Html::css($url, $options);
|
||||
@@ -260,7 +262,7 @@ if (Helpers::hasOverride('js') === false) { // @codeCoverageIgnore
|
||||
* Creates a script tag to load a javascript file
|
||||
*/
|
||||
function js(
|
||||
string|array $url,
|
||||
string|array|Plugin|PluginAssets $url,
|
||||
string|array|bool|null $options = null
|
||||
): string|null {
|
||||
return Html::js($url, $options);
|
||||
|
@@ -115,7 +115,7 @@ return function (App $app) {
|
||||
'toDate' => function (
|
||||
Field $field,
|
||||
string|IntlDateFormatter|null $format = null,
|
||||
string $fallback = null
|
||||
string|null $fallback = null
|
||||
) use ($app): string|int|null {
|
||||
if (empty($field->value) === true && $fallback === null) {
|
||||
return null;
|
||||
@@ -504,7 +504,7 @@ return function (App $app) {
|
||||
*/
|
||||
'query' => function (
|
||||
Field $field,
|
||||
string $expect = null
|
||||
string|null $expect = null
|
||||
) use ($app): mixed {
|
||||
if ($parent = $field->parent()) {
|
||||
return $parent->query($field->value, $expect);
|
||||
|
@@ -33,7 +33,7 @@ return function (App $kirby) {
|
||||
'pattern' => $api . '/(:all)',
|
||||
'method' => 'ALL',
|
||||
'env' => 'api',
|
||||
'action' => function (string $path = null) use ($kirby) {
|
||||
'action' => function (string|null $path = null) use ($kirby) {
|
||||
if ($kirby->option('api') === false) {
|
||||
return null;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ return function (App $kirby) {
|
||||
'pattern' => $panel . '/(:all?)',
|
||||
'method' => 'ALL',
|
||||
'env' => 'panel',
|
||||
'action' => function (string $path = null) {
|
||||
'action' => function (string|null $path = null) {
|
||||
return Panel::router($path);
|
||||
}
|
||||
],
|
||||
|
@@ -28,7 +28,7 @@ return [
|
||||
/**
|
||||
* Filters all files by template and also sets the template, which will be used for all uploads
|
||||
*/
|
||||
'template' => function (string $template = null) {
|
||||
'template' => function (string|null $template = null) {
|
||||
return $template;
|
||||
},
|
||||
/**
|
||||
|
@@ -7,13 +7,13 @@ return [
|
||||
'headline',
|
||||
],
|
||||
'props' => [
|
||||
'icon' => function (string $icon = null) {
|
||||
'icon' => function (string|null $icon = null) {
|
||||
return $icon;
|
||||
},
|
||||
'text' => function ($text = null) {
|
||||
return I18n::translate($text, $text);
|
||||
},
|
||||
'theme' => function (string $theme = null) {
|
||||
'theme' => function (string|null $theme = null) {
|
||||
return $theme;
|
||||
}
|
||||
],
|
||||
|
@@ -10,7 +10,7 @@ return [
|
||||
/**
|
||||
* Columns config for `layout: table`
|
||||
*/
|
||||
'columns' => function (array $columns = null) {
|
||||
'columns' => function (array|null $columns = null) {
|
||||
return $columns ?? [];
|
||||
},
|
||||
/**
|
||||
|
@@ -5,7 +5,7 @@ return [
|
||||
/**
|
||||
* Sets the maximum number of allowed entries in the section
|
||||
*/
|
||||
'max' => function (int $max = null) {
|
||||
'max' => function (int|null $max = null) {
|
||||
return $max;
|
||||
}
|
||||
],
|
||||
|
@@ -5,7 +5,7 @@ return [
|
||||
/**
|
||||
* Sets the minimum number of required entries in the section
|
||||
*/
|
||||
'min' => function (int $min = null) {
|
||||
'min' => function (int|null $min = null) {
|
||||
return $min;
|
||||
}
|
||||
],
|
||||
|
@@ -12,9 +12,9 @@ return [
|
||||
return $limit;
|
||||
},
|
||||
/**
|
||||
* Sets the default page for the pagination. This will overwrite default pagination.
|
||||
* Sets the default page for the pagination.
|
||||
*/
|
||||
'page' => function (int $page = null) {
|
||||
'page' => function (int|null $page = null) {
|
||||
return App::instance()->request()->get('page', $page);
|
||||
},
|
||||
],
|
||||
|
@@ -11,7 +11,7 @@ return [
|
||||
/**
|
||||
* Sets the query to a parent to find items for the list
|
||||
*/
|
||||
'parent' => function (string $parent = null) {
|
||||
'parent' => function (string|null $parent = null) {
|
||||
return $parent;
|
||||
}
|
||||
],
|
||||
|
@@ -17,7 +17,7 @@ return [
|
||||
/**
|
||||
* Overwrites manual sorting and sorts by the given field and sorting direction (i.e. `date desc`)
|
||||
*/
|
||||
'sortBy' => function (string $sortBy = null) {
|
||||
'sortBy' => function (string|null $sortBy = null) {
|
||||
return $sortBy;
|
||||
},
|
||||
],
|
||||
|
@@ -53,7 +53,7 @@ return [
|
||||
/**
|
||||
* Filters the list by single template.
|
||||
*/
|
||||
'template' => function (string|array $template = null) {
|
||||
'template' => function (string|array|null $template = null) {
|
||||
return $template;
|
||||
},
|
||||
/**
|
||||
|
Reference in New Issue
Block a user