Update Kirby and Composer dependencies

This commit is contained in:
Paul Nicoué 2022-03-22 15:39:39 +01:00
parent f5d3ea5e84
commit ec74d78ba9
382 changed files with 25077 additions and 4955 deletions

View file

@ -61,12 +61,10 @@ return [
* Users
*/
'users' => [
'default' => function () {
return $this->users();
},
'model' => 'user',
'type' => 'Kirby\Cms\Users',
'view' => 'compact'
'default' => fn () => $this->users(),
'model' => 'user',
'type' => 'Kirby\Cms\Users',
'view' => 'compact'
]
];

View file

@ -8,92 +8,48 @@ use Kirby\Form\Form;
*/
return [
'fields' => [
'blueprint' => function (File $file) {
return $file->blueprint();
},
'content' => function (File $file) {
return Form::for($file)->values();
},
'dimensions' => function (File $file) {
return $file->dimensions()->toArray();
},
'dragText' => function (File $file) {
return $file->panel()->dragText();
},
'exists' => function (File $file) {
return $file->exists();
},
'extension' => function (File $file) {
return $file->extension();
},
'filename' => function (File $file) {
return $file->filename();
},
'id' => function (File $file) {
return $file->id();
},
'link' => function (File $file) {
return $file->panel()->url(true);
},
'mime' => function (File $file) {
return $file->mime();
},
'modified' => function (File $file) {
return $file->modified('c');
},
'name' => function (File $file) {
return $file->name();
},
'next' => function (File $file) {
return $file->next();
},
'blueprint' => fn (File $file) => $file->blueprint(),
'content' => fn (File $file) => Form::for($file)->values(),
'dimensions' => fn (File $file) => $file->dimensions()->toArray(),
'dragText' => fn (File $file) => $file->panel()->dragText(),
'exists' => fn (File $file) => $file->exists(),
'extension' => fn (File $file) => $file->extension(),
'filename' => fn (File $file) => $file->filename(),
'id' => fn (File $file) => $file->id(),
'link' => fn (File $file) => $file->panel()->url(true),
'mime' => fn (File $file) => $file->mime(),
'modified' => fn (File $file) => $file->modified('c'),
'name' => fn (File $file) => $file->name(),
'next' => fn (File $file) => $file->next(),
'nextWithTemplate' => function (File $file) {
$files = $file->templateSiblings()->sorted();
$index = $files->indexOf($file);
return $files->nth($index + 1);
},
'niceSize' => function (File $file) {
return $file->niceSize();
},
'options' => function (File $file) {
return $file->panel()->options();
},
'panelIcon' => function (File $file) {
'niceSize' => fn (File $file) => $file->niceSize(),
'options' => fn (File $file) => $file->panel()->options(),
'panelIcon' => function (File $file) {
// TODO: remove in 3.7.0
// @codeCoverageIgnoreStart
deprecated('The API field file.panelIcon has been deprecated and will be removed in 3.7.0. Use file.panelImage instead');
return $file->panel()->image();
// @codeCoverageIgnoreEnd
},
'panelImage' => function (File $file) {
return $file->panel()->image();
},
'panelUrl' => function (File $file) {
return $file->panel()->url(true);
},
'prev' => function (File $file) {
return $file->prev();
},
'panelImage' => fn (File $file) => $file->panel()->image(),
'panelUrl' => fn (File $file) => $file->panel()->url(true),
'prev' => fn (File $file) => $file->prev(),
'prevWithTemplate' => function (File $file) {
$files = $file->templateSiblings()->sorted();
$index = $files->indexOf($file);
return $files->nth($index - 1);
},
'parent' => function (File $file) {
return $file->parent();
},
'parents' => function (File $file) {
return $file->parents()->flip();
},
'size' => function (File $file) {
return $file->size();
},
'template' => function (File $file) {
return $file->template();
},
'thumbs' => function ($file) {
'parent' => fn (File $file) => $file->parent(),
'parents' => fn (File $file) => $file->parents()->flip(),
'size' => fn (File $file) => $file->size(),
'template' => fn (File $file) => $file->template(),
'thumbs' => function ($file) {
if ($file->isResizable() === false) {
return null;
}
@ -106,12 +62,8 @@ return [
'huge' => $file->resize(1024)->url(),
];
},
'type' => function (File $file) {
return $file->type();
},
'url' => function (File $file) {
return $file->url();
},
'type' => fn (File $file) => $file->type(),
'url' => fn (File $file) => $file->url(),
],
'type' => 'Kirby\Cms\File',
'views' => [

View file

@ -7,18 +7,10 @@ use Kirby\Cms\FileBlueprint;
*/
return [
'fields' => [
'name' => function (FileBlueprint $blueprint) {
return $blueprint->name();
},
'options' => function (FileBlueprint $blueprint) {
return $blueprint->options();
},
'tabs' => function (FileBlueprint $blueprint) {
return $blueprint->tabs();
},
'title' => function (FileBlueprint $blueprint) {
return $blueprint->title();
},
'name' => fn (FileBlueprint $blueprint) => $blueprint->name(),
'options' => fn (FileBlueprint $blueprint) => $blueprint->options(),
'tabs' => fn (FileBlueprint $blueprint) => $blueprint->tabs(),
'title' => fn (FileBlueprint $blueprint) => $blueprint->title(),
],
'type' => 'Kirby\Cms\FileBlueprint',
'views' => [

View file

@ -7,42 +7,18 @@ use Kirby\Cms\FileVersion;
*/
return [
'fields' => [
'dimensions' => function (FileVersion $file) {
return $file->dimensions()->toArray();
},
'exists' => function (FileVersion $file) {
return $file->exists();
},
'extension' => function (FileVersion $file) {
return $file->extension();
},
'filename' => function (FileVersion $file) {
return $file->filename();
},
'id' => function (FileVersion $file) {
return $file->id();
},
'mime' => function (FileVersion $file) {
return $file->mime();
},
'modified' => function (FileVersion $file) {
return $file->modified('c');
},
'name' => function (FileVersion $file) {
return $file->name();
},
'niceSize' => function (FileVersion $file) {
return $file->niceSize();
},
'size' => function (FileVersion $file) {
return $file->size();
},
'type' => function (FileVersion $file) {
return $file->type();
},
'url' => function (FileVersion $file) {
return $file->url();
},
'dimensions' => fn (FileVersion $file) => $file->dimensions()->toArray(),
'exists' => fn (FileVersion $file) => $file->exists(),
'extension' => fn (FileVersion $file) => $file->extension(),
'filename' => fn (FileVersion $file) => $file->filename(),
'id' => fn (FileVersion $file) => $file->id(),
'mime' => fn (FileVersion $file) => $file->mime(),
'modified' => fn (FileVersion $file) => $file->modified('c'),
'name' => fn (FileVersion $file) => $file->name(),
'niceSize' => fn (FileVersion $file) => $file->niceSize(),
'size' => fn (FileVersion $file) => $file->size(),
'type' => fn (FileVersion $file) => $file->type(),
'url' => fn (FileVersion $file) => $file->url(),
],
'type' => 'Kirby\Cms\FileVersion',
'views' => [

View file

@ -7,27 +7,13 @@ use Kirby\Cms\Language;
*/
return [
'fields' => [
'code' => function (Language $language) {
return $language->code();
},
'default' => function (Language $language) {
return $language->isDefault();
},
'direction' => function (Language $language) {
return $language->direction();
},
'locale' => function (Language $language) {
return $language->locale();
},
'name' => function (Language $language) {
return $language->name();
},
'rules' => function (Language $language) {
return $language->rules();
},
'url' => function (Language $language) {
return $language->url();
},
'code' => fn (Language $language) => $language->code(),
'default' => fn (Language $language) => $language->isDefault(),
'direction' => fn (Language $language) => $language->direction(),
'locale' => fn (Language $language) => $language->locale(),
'name' => fn (Language $language) => $language->name(),
'rules' => fn (Language $language) => $language->rules(),
'url' => fn (Language $language) => $language->url(),
],
'type' => 'Kirby\Cms\Language',
'views' => [

View file

@ -8,42 +8,18 @@ use Kirby\Form\Form;
*/
return [
'fields' => [
'blueprint' => function (Page $page) {
return $page->blueprint();
},
'blueprints' => function (Page $page) {
return $page->blueprints();
},
'children' => function (Page $page) {
return $page->children();
},
'content' => function (Page $page) {
return Form::for($page)->values();
},
'drafts' => function (Page $page) {
return $page->drafts();
},
'errors' => function (Page $page) {
return $page->errors();
},
'files' => function (Page $page) {
return $page->files()->sorted();
},
'hasChildren' => function (Page $page) {
return $page->hasChildren();
},
'hasDrafts' => function (Page $page) {
return $page->hasDrafts();
},
'hasFiles' => function (Page $page) {
return $page->hasFiles();
},
'id' => function (Page $page) {
return $page->id();
},
'isSortable' => function (Page $page) {
return $page->isSortable();
},
'blueprint' => fn (Page $page) => $page->blueprint(),
'blueprints' => fn (Page $page) => $page->blueprints(),
'children' => fn (Page $page) => $page->children(),
'content' => fn (Page $page) => Form::for($page)->values(),
'drafts' => fn (Page $page) => $page->drafts(),
'errors' => fn (Page $page) => $page->errors(),
'files' => fn (Page $page) => $page->files()->sorted(),
'hasChildren' => fn (Page $page) => $page->hasChildren(),
'hasDrafts' => fn (Page $page) => $page->hasDrafts(),
'hasFiles' => fn (Page $page) => $page->hasFiles(),
'id' => fn (Page $page) => $page->id(),
'isSortable' => fn (Page $page) => $page->isSortable(),
/**
* @deprecated 3.6.0
* @todo Throw deprecated warning in 3.7.0
@ -58,12 +34,8 @@ return [
->filter('isReadable', true)
->first();
},
'num' => function (Page $page) {
return $page->num();
},
'options' => function (Page $page) {
return $page->panel()->options(['preview']);
},
'num' => fn (Page $page) => $page->num(),
'options' => fn (Page $page) => $page->panel()->options(['preview']),
/**
* @todo Remove in 3.7.0
* @codeCoverageIgnore
@ -72,15 +44,9 @@ return [
deprecated('The API field page.panelIcon has been deprecated and will be removed in 3.7.0. Use page.panelImage instead');
return $page->panel()->image();
},
'panelImage' => function (Page $page) {
return $page->panel()->image();
},
'parent' => function (Page $page) {
return $page->parent();
},
'parents' => function (Page $page) {
return $page->parents()->flip();
},
'panelImage' => fn (Page $page) => $page->panel()->image(),
'parent' => fn (Page $page) => $page->parent(),
'parents' => fn (Page $page) => $page->parents()->flip(),
/**
* @deprecated 3.6.0
* @todo Throw deprecated warning in 3.7.0
@ -95,31 +61,19 @@ return [
->filter('isReadable', true)
->last();
},
'previewUrl' => function (Page $page) {
return $page->previewUrl();
},
'siblings' => function (Page $page) {
'previewUrl' => fn (Page $page) => $page->previewUrl(),
'siblings' => function (Page $page) {
if ($page->isDraft() === true) {
return $page->parentModel()->children()->not($page);
} else {
return $page->siblings();
}
},
'slug' => function (Page $page) {
return $page->slug();
},
'status' => function (Page $page) {
return $page->status();
},
'template' => function (Page $page) {
return $page->intendedTemplate()->name();
},
'title' => function (Page $page) {
return $page->title()->value();
},
'url' => function (Page $page) {
return $page->url();
},
'slug' => fn (Page $page) => $page->slug(),
'status' => fn (Page $page) => $page->status(),
'template' => fn (Page $page) => $page->intendedTemplate()->name(),
'title' => fn (Page $page) => $page->title()->value(),
'url' => fn (Page $page) => $page->url(),
],
'type' => 'Kirby\Cms\Page',
'views' => [

View file

@ -7,27 +7,13 @@ use Kirby\Cms\PageBlueprint;
*/
return [
'fields' => [
'name' => function (PageBlueprint $blueprint) {
return $blueprint->name();
},
'num' => function (PageBlueprint $blueprint) {
return $blueprint->num();
},
'options' => function (PageBlueprint $blueprint) {
return $blueprint->options();
},
'preview' => function (PageBlueprint $blueprint) {
return $blueprint->preview();
},
'status' => function (PageBlueprint $blueprint) {
return $blueprint->status();
},
'tabs' => function (PageBlueprint $blueprint) {
return $blueprint->tabs();
},
'title' => function (PageBlueprint $blueprint) {
return $blueprint->title();
},
'name' => fn (PageBlueprint $blueprint) => $blueprint->name(),
'num' => fn (PageBlueprint $blueprint) => $blueprint->num(),
'options' => fn (PageBlueprint $blueprint) => $blueprint->options(),
'preview' => fn (PageBlueprint $blueprint) => $blueprint->preview(),
'status' => fn (PageBlueprint $blueprint) => $blueprint->status(),
'tabs' => fn (PageBlueprint $blueprint) => $blueprint->tabs(),
'title' => fn (PageBlueprint $blueprint) => $blueprint->title(),
],
'type' => 'Kirby\Cms\PageBlueprint',
'views' => [

View file

@ -7,18 +7,10 @@ use Kirby\Cms\Role;
*/
return [
'fields' => [
'description' => function (Role $role) {
return $role->description();
},
'name' => function (Role $role) {
return $role->name();
},
'permissions' => function (Role $role) {
return $role->permissions()->toArray();
},
'title' => function (Role $role) {
return $role->title();
},
'description' => fn (Role $role) => $role->description(),
'name' => fn (Role $role) => $role->name(),
'permissions' => fn (Role $role) => $role->permissions()->toArray(),
'title' => fn (Role $role) => $role->title(),
],
'type' => 'Kirby\Cms\Role',
'views' => [

View file

@ -7,37 +7,17 @@ use Kirby\Form\Form;
* Site
*/
return [
'default' => function () {
return $this->site();
},
'default' => fn () => $this->site(),
'fields' => [
'blueprint' => function (Site $site) {
return $site->blueprint();
},
'children' => function (Site $site) {
return $site->children();
},
'content' => function (Site $site) {
return Form::for($site)->values();
},
'drafts' => function (Site $site) {
return $site->drafts();
},
'files' => function (Site $site) {
return $site->files()->sorted();
},
'options' => function (Site $site) {
return $site->permissions()->toArray();
},
'previewUrl' => function (Site $site) {
return $site->previewUrl();
},
'title' => function (Site $site) {
return $site->title()->value();
},
'url' => function (Site $site) {
return $site->url();
},
'blueprint' => fn (Site $site) => $site->blueprint(),
'children' => fn (Site $site) => $site->children(),
'content' => fn (Site $site) => Form::for($site)->values(),
'drafts' => fn (Site $site) => $site->drafts(),
'files' => fn (Site $site) => $site->files()->sorted(),
'options' => fn (Site $site) => $site->permissions()->toArray(),
'previewUrl' => fn (Site $site) => $site->previewUrl(),
'title' => fn (Site $site) => $site->title()->value(),
'url' => fn (Site $site) => $site->url(),
],
'type' => 'Kirby\Cms\Site',
'views' => [

View file

@ -7,20 +7,11 @@ use Kirby\Cms\SiteBlueprint;
*/
return [
'fields' => [
'name' => function (SiteBlueprint $blueprint) {
return $blueprint->name();
},
'options' => function (SiteBlueprint $blueprint) {
return $blueprint->options();
},
'tabs' => function (SiteBlueprint $blueprint) {
return $blueprint->tabs();
},
'title' => function (SiteBlueprint $blueprint) {
return $blueprint->title();
},
],
'type' => 'Kirby\Cms\SiteBlueprint',
'views' => [
'name' => fn (SiteBlueprint $blueprint) => $blueprint->name(),
'options' => fn (SiteBlueprint $blueprint) => $blueprint->options(),
'tabs' => fn (SiteBlueprint $blueprint) => $blueprint->tabs(),
'title' => fn (SiteBlueprint $blueprint) => $blueprint->title(),
],
'type' => 'Kirby\Cms\SiteBlueprint',
'views' => [],
];

View file

@ -8,37 +8,17 @@ use Kirby\Toolkit\Str;
*/
return [
'fields' => [
'ascii' => function () {
return Str::$ascii;
},
'authStatus' => function () {
return $this->kirby()->auth()->status()->toArray();
},
'defaultLanguage' => function () {
return $this->kirby()->panelLanguage();
},
'isOk' => function (System $system) {
return $system->isOk();
},
'isInstallable' => function (System $system) {
return $system->isInstallable();
},
'isInstalled' => function (System $system) {
return $system->isInstalled();
},
'isLocal' => function (System $system) {
return $system->isLocal();
},
'multilang' => function () {
return $this->kirby()->option('languages', false) !== false;
},
'languages' => function () {
return $this->kirby()->languages();
},
'license' => function (System $system) {
return $system->license();
},
'locales' => function () {
'ascii' => fn () => Str::$ascii,
'authStatus' => fn () => $this->kirby()->auth()->status()->toArray(),
'defaultLanguage' => fn () => $this->kirby()->panelLanguage(),
'isOk' => fn (System $system) => $system->isOk(),
'isInstallable' => fn (System $system) => $system->isInstallable(),
'isInstalled' => fn (System $system) => $system->isInstalled(),
'isLocal' => fn (System $system) => $system->isLocal(),
'multilang' => fn () => $this->kirby()->option('languages', false) !== false,
'languages' => fn () => $this->kirby()->languages(),
'license' => fn (System $system) => $system->license(),
'locales' => function () {
$locales = [];
$translations = $this->kirby()->translations();
foreach ($translations as $translation) {
@ -46,21 +26,11 @@ return [
}
return $locales;
},
'loginMethods' => function (System $system) {
return array_keys($system->loginMethods());
},
'requirements' => function (System $system) {
return $system->toArray();
},
'site' => function (System $system) {
return $system->title();
},
'slugs' => function () {
return Str::$language;
},
'title' => function () {
return $this->site()->title()->value();
},
'loginMethods' => fn (System $system) => array_keys($system->loginMethods()),
'requirements' => fn (System $system) => $system->toArray(),
'site' => fn (System $system) => $system->title(),
'slugs' => fn () => Str::$language,
'title' => fn () => $this->site()->title()->value(),
'translation' => function () {
if ($user = $this->user()) {
$translationCode = $user->language();
@ -74,12 +44,8 @@ return [
return $this->kirby()->translation('en');
}
},
'kirbytext' => function () {
return $this->kirby()->option('panel.kirbytext') ?? true;
},
'user' => function () {
return $this->user();
},
'kirbytext' => fn () => $this->kirby()->option('panel.kirbytext') ?? true,
'user' => fn () => $this->user(),
'version' => function () {
$user = $this->user();

View file

@ -7,21 +7,11 @@ use Kirby\Cms\Translation;
*/
return [
'fields' => [
'author' => function (Translation $translation) {
return $translation->author();
},
'data' => function (Translation $translation) {
return $translation->dataWithFallback();
},
'direction' => function (Translation $translation) {
return $translation->direction();
},
'id' => function (Translation $translation) {
return $translation->id();
},
'name' => function (Translation $translation) {
return $translation->name();
},
'author' => fn (Translation $translation) => $translation->author(),
'data' => fn (Translation $translation) => $translation->dataWithFallback(),
'direction' => fn (Translation $translation) => $translation->direction(),
'id' => fn (Translation $translation) => $translation->id(),
'name' => fn (Translation $translation) => $translation->name(),
],
'type' => 'Kirby\Cms\Translation',
'views' => [

View file

@ -7,58 +7,24 @@ use Kirby\Form\Form;
* User
*/
return [
'default' => function () {
return $this->user();
},
'default' => fn () => $this->user(),
'fields' => [
'avatar' => function (User $user) {
return $user->avatar() ? $user->avatar()->crop(512) : null;
},
'blueprint' => function (User $user) {
return $user->blueprint();
},
'content' => function (User $user) {
return Form::for($user)->values();
},
'email' => function (User $user) {
return $user->email();
},
'files' => function (User $user) {
return $user->files()->sorted();
},
'id' => function (User $user) {
return $user->id();
},
'language' => function (User $user) {
return $user->language();
},
'name' => function (User $user) {
return $user->name()->value();
},
'next' => function (User $user) {
return $user->next();
},
'options' => function (User $user) {
return $user->panel()->options();
},
'panelImage' => function (User $user) {
return $user->panel()->image();
},
'permissions' => function (User $user) {
return $user->role()->permissions()->toArray();
},
'prev' => function (User $user) {
return $user->prev();
},
'role' => function (User $user) {
return $user->role();
},
'roles' => function (User $user) {
return $user->roles();
},
'username' => function (User $user) {
return $user->username();
}
'avatar' => fn (User $user) => $user->avatar() ? $user->avatar()->crop(512) : null,
'blueprint' => fn (User $user) => $user->blueprint(),
'content' => fn (User $user) => Form::for($user)->values(),
'email' => fn (User $user) => $user->email(),
'files' => fn (User $user) => $user->files()->sorted(),
'id' => fn (User $user) => $user->id(),
'language' => fn (User $user) => $user->language(),
'name' => fn (User $user) => $user->name()->value(),
'next' => fn (User $user) => $user->next(),
'options' => fn (User $user) => $user->panel()->options(),
'panelImage' => fn (User $user) => $user->panel()->image(),
'permissions' => fn (User $user) => $user->role()->permissions()->toArray(),
'prev' => fn (User $user) => $user->prev(),
'role' => fn (User $user) => $user->role(),
'roles' => fn (User $user) => $user->roles(),
'username' => fn (User $user) => $user->username()
],
'type' => 'Kirby\Cms\User',
'views' => [

View file

@ -7,18 +7,10 @@ use Kirby\Cms\UserBlueprint;
*/
return [
'fields' => [
'name' => function (UserBlueprint $blueprint) {
return $blueprint->name();
},
'options' => function (UserBlueprint $blueprint) {
return $blueprint->options();
},
'tabs' => function (UserBlueprint $blueprint) {
return $blueprint->tabs();
},
'title' => function (UserBlueprint $blueprint) {
return $blueprint->title();
},
'name' => fn (UserBlueprint $blueprint) => $blueprint->name(),
'options' => fn (UserBlueprint $blueprint) => $blueprint->options(),
'tabs' => fn (UserBlueprint $blueprint) => $blueprint->tabs(),
'title' => fn (UserBlueprint $blueprint) => $blueprint->title(),
],
'type' => 'Kirby\Cms\UserBlueprint',
'views' => [

View file

@ -6,12 +6,10 @@ use Kirby\Panel\Panel;
return [
'account' => [
'pattern' => 'account',
'action' => function () {
return [
'component' => 'k-account-view',
'props' => kirby()->user()->panel()->props(),
];
},
'action' => fn () => [
'component' => 'k-account-view',
'props' => kirby()->user()->panel()->props(),
],
],
'account.file' => [
'pattern' => 'account/files/(:any)',
@ -31,10 +29,6 @@ return [
],
'account.password' => [
'pattern' => 'reset-password',
'action' => function () {
return [
'component' => 'k-reset-password-view',
];
}
'action' => fn () => ['component' => 'k-reset-password-view']
]
];

View file

@ -32,9 +32,7 @@ return function ($kirby) {
'installation.fallback' => [
'pattern' => '(:all)',
'auth' => false,
'action' => function () {
Panel::go('installation');
}
'action' => fn () => Panel::go('installation')
]
]
];

View file

@ -11,14 +11,12 @@ return [
return [
'component' => 'k-languages-view',
'props' => [
'languages' => $kirby->languages()->values(function ($language) {
return [
'default' => $language->isDefault(),
'id' => $language->code(),
'info' => Escape::html($language->code()),
'text' => Escape::html($language->name()),
];
})
'languages' => $kirby->languages()->values(fn ($language) => [
'default' => $language->isDefault(),
'id' => $language->code(),
'info' => Escape::html($language->code()),
'text' => Escape::html($language->name()),
])
]
];
}

View file

@ -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([

View file

@ -7,9 +7,7 @@ $files = require __DIR__ . '/../files/dropdowns.php';
return [
'changes' => [
'pattern' => 'changes',
'options' => function () {
return Dropdown::changes();
}
'options' => fn () => Dropdown::changes()
],
'page' => [
'pattern' => 'pages/(:any)',

View file

@ -5,9 +5,7 @@ use Kirby\Cms\Find;
return [
'page' => [
'pattern' => 'pages/(:any)',
'action' => function (string $path) {
return Find::page($path)->panel()->view();
}
'action' => fn (string $path) => Find::page($path)->panel()->view()
],
'page.file' => [
'pattern' => 'pages/(:any)/files/(:any)',
@ -17,9 +15,7 @@ return [
],
'site' => [
'pattern' => 'site',
'action' => function () {
return site()->panel()->view();
}
'action' => fn () => site()->panel()->view()
],
'site.file' => [
'pattern' => 'site/files/(:any)',

View file

@ -1,5 +1,6 @@
<?php
use Kirby\Http\Server;
return [
'system' => [
@ -37,7 +38,7 @@ return [
'plugins' => $plugins,
'php' => phpversion(),
'server' => $system->serverSoftware(),
'ssl' => Server::https(),
'https' => Server::https(),
'version' => $kirby->version(),
]
];

View file

@ -25,8 +25,8 @@ return [
'link' => false,
'required' => true
]),
'password' => Field::password(),
'language' => Field::translation([
'password' => Field::password(),
'translation' => Field::translation([
'required' => true
]),
'role' => Field::role([
@ -35,11 +35,11 @@ return [
],
'submitButton' => t('create'),
'value' => [
'name' => '',
'email' => '',
'password' => '',
'language' => $kirby->panelLanguage(),
'role' => $kirby->user()->role()->name()
'name' => '',
'email' => '',
'password' => '',
'translation' => $kirby->panelLanguage(),
'role' => $kirby->user()->role()->name()
]
]
];
@ -49,7 +49,7 @@ return [
'name' => get('name'),
'email' => get('email'),
'password' => get('password'),
'language' => get('language'),
'language' => get('translation'),
'role' => get('role')
]);
return [

View file

@ -9,12 +9,10 @@ return [
'action' => function () {
$kirby = kirby();
$role = get('role');
$roles = $kirby->roles()->toArray(function ($role) {
return [
'id' => $role->id(),
'title' => $role->title(),
];
});
$roles = $kirby->roles()->toArray(fn ($role) => [
'id' => $role->id(),
'title' => $role->title(),
]);
return [
'component' => 'k-users-view',
@ -38,15 +36,13 @@ return [
]);
return [
'data' => $users->values(function ($user) {
return [
'id' => $user->id(),
'image' => $user->panel()->image(),
'info' => Escape::html($user->role()->title()),
'link' => $user->panel()->url(true),
'text' => Escape::html($user->username())
];
}),
'data' => $users->values(fn ($user) => [
'id' => $user->id(),
'image' => $user->panel()->image(),
'info' => Escape::html($user->role()->title()),
'link' => $user->panel()->url(true),
'text' => Escape::html($user->username())
]),
'pagination' => $users->pagination()->toArray()
];
},

View file

@ -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
@ -133,13 +136,18 @@ return [
* @param \Kirby\Cms\App $kirby Kirby instance
* @param string $text Text to parse
* @param array $options Markdown options
* @param bool $inline Whether to wrap the text in `<p>` tags
* @param bool $inline Whether to wrap the text in `<p>` tags (deprecated: set via $options['inline'] instead)
* @return string
* @todo add deprecation warning for $inline parameter in 3.7.0
* @todo remove $inline parameter in in 3.8.0
*/
'markdown' => function (App $kirby, string $text = null, array $options = [], bool $inline = false): string {
static $markdown;
static $config;
// support for the deprecated fourth argument
$options['inline'] ??= $inline;
// if the config options have changed or the component is called for the first time,
// (re-)initialize the parser object
if ($config !== $options) {
@ -147,7 +155,7 @@ return [
$config = $options;
}
return $markdown->parse($text, $inline);
return $markdown->parse($text, $options['inline']);
},
/**
@ -340,7 +348,7 @@ return [
* Modify all URLs
*
* @param \Kirby\Cms\App $kirby Kirby instance
* @param string $path URL path
* @param string|null $path URL path
* @param array|string|null $options Array of options for the Uri class
* @return string
*/
@ -373,7 +381,10 @@ return [
}
// keep relative urls
if (substr($path, 0, 2) === './' || substr($path, 0, 3) === '../') {
if (
$path !== null &&
(substr($path, 0, 2) === './' || substr($path, 0, 3) === '../')
) {
return $path;
}

View file

@ -2,6 +2,7 @@
use Kirby\Exception\Exception;
use Kirby\Form\Field;
use Kirby\Toolkit\Date;
use Kirby\Toolkit\I18n;
use Kirby\Toolkit\Str;
@ -20,12 +21,11 @@ return [
return $calendar;
},
/**
* Default date when a new page/file/user gets created
*/
'default' => function (string $default = null) {
return $default;
'default' => function (string $default = null): string {
return $this->toDatetime($default) ?? '';
},
/**
@ -46,42 +46,21 @@ return [
/**
* Latest date, which can be selected/saved (Y-m-d)
*/
'max' => function (string $max = null) {
return $this->toDatetime($max);
'max' => function (string $max = null): ?string {
return Date::optional($max);
},
/**
* Earliest date, which can be selected/saved (Y-m-d)
*/
'min' => function (string $min = null) {
return $this->toDatetime($min);
'min' => function (string $min = null): ?string {
return Date::optional($min);
},
/**
* Round to the nearest: sub-options for `unit` (day) and `size` (1)
*/
'step' => function ($step = null) {
$default = [
'size' => 1,
'unit' => 'day'
];
if ($step === null) {
return $default;
}
if (is_array($step) === true) {
$step = array_merge($default, $step);
$step['unit'] = strtolower($step['unit']);
return $step;
}
if (is_int($step) === true) {
return array_merge($default, ['size' => $step]);
}
if (is_string($step) === true) {
return array_merge($default, ['unit' => strtolower($step)]);
}
return $step;
},
/**
@ -95,12 +74,9 @@ return [
*/
'value' => function ($value = null) {
return $value;
},
}
],
'computed' => [
'default' => function () {
return $this->toDatetime($this->default);
},
'display' => function () {
if ($this->display) {
return Str::upper($this->display);
@ -120,57 +96,56 @@ return [
return $field->toArray();
},
'step' => function () {
if ($this->time === false) {
return $this->step;
if ($this->time === false || empty($this->time['step']) === true) {
return Date::stepConfig($this->step, [
'size' => 1,
'unit' => 'day'
]);
}
return $this->time['step'];
return Date::stepConfig($this->time['step'], [
'size' => 5,
'unit' => 'minute'
]);
},
'value' => function () {
return $this->toDatetime($this->value);
'value' => function (): string {
return $this->toDatetime($this->value) ?? '';
},
],
'validations' => [
'date',
'minMax' => function ($value) {
$min = $this->min ? strtotime($this->min) : null;
$max = $this->max ? strtotime($this->max) : null;
$value = strtotime($this->value());
if (!$value = Date::optional($value)) {
return true;
}
$min = Date::optional($this->min);
$max = Date::optional($this->max);
$format = $this->time === false ? 'd.m.Y' : 'd.m.Y H:i';
$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),
]
]);
}
if ($min && $max && $value->isBetween($min, $max) === false) {
throw new Exception([
'key' => 'validation.date.between',
'data' => [
'min' => $min->format($format),
'max' => $min->format($format)
]
]);
} elseif ($min && $value->isMin($min) === false) {
throw new Exception([
'key' => 'validation.date.after',
'data' => [
'date' => $min->format($format),
]
]);
} elseif ($max && $value->isMax($max) === false) {
throw new Exception([
'key' => 'validation.date.before',
'data' => [
'date' => $max->format($format),
]
]);
}
return true;

View file

@ -11,7 +11,7 @@ return [
],
'computed' => [
'value' => function () {
return trim($this->value);
return trim($this->value ?? '');
}
]
];

View file

@ -1,5 +1,7 @@
<?php
use Kirby\Toolkit\Date;
return [
'props' => [
/**
@ -11,16 +13,21 @@ return [
],
'methods' => [
'toDatetime' => function ($value, string $format = 'Y-m-d H:i:s') {
if ($timestamp = timestamp($value, $this->step)) {
return date($format, $timestamp);
if ($date = Date::optional($value)) {
if ($this->step) {
$step = Date::stepConfig($this->step);
$date->round($step['unit'], $step['size']);
}
return $date->format($format);
}
return null;
}
],
'save' => function ($value) {
if ($value !== null && $timestamp = strtotime($value)) {
return date($this->format, $timestamp);
if ($date = Date::optional($value)) {
return $date->format($this->format);
}
return '';

View file

@ -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 () {

View file

@ -1,6 +1,7 @@
<?php
use Kirby\Exception\Exception;
use Kirby\Toolkit\Date;
use Kirby\Toolkit\I18n;
return [
@ -11,11 +12,10 @@ return [
*/
'placeholder' => null,
/**
* Sets the default time when a new page/file/user is created
*/
'default' => function ($default = null) {
'default' => function ($default = null): ?string {
return $default;
},
@ -36,14 +36,14 @@ return [
/**
* Latest time, which can be selected/saved (H:i or H:i:s)
*/
'max' => function (string $max = null) {
return $max ? $this->toDatetime(date('Y-m-d ') . $max) : null;
'max' => function (string $max = null): ?string {
return Date::optional($max);
},
/**
* Earliest time, which can be selected/saved (H:i or H:i:s)
*/
'min' => function (string $min = null) {
return $min ? $this->toDatetime(date('Y-m-d ') . $min) : null;
'min' => function (string $min = null): ?string {
return Date::optional($min);
},
/**
@ -57,92 +57,67 @@ return [
* Round to the nearest: sub-options for `unit` (minute) and `size` (5)
*/
'step' => function ($step = null) {
$default = [
return Date::stepConfig($step, [
'size' => 5,
'unit' => 'minute'
];
if ($step === null) {
return $default;
}
if (is_array($step) === true) {
$step = array_merge($default, $step);
$step['unit'] = strtolower($step['unit']);
return $step;
}
if (is_int($step) === true) {
return array_merge($default, ['size' => $step]);
}
if (is_string($step) === true) {
return array_merge($default, ['unit' => strtolower($step)]);
}
'unit' => 'minute',
]);
},
'value' => function ($value = null) {
'value' => function ($value = null): ?string {
return $value;
}
],
'computed' => [
'default' => function () {
return $this->toDatetime($this->default, 'H:i:s');
},
'display' => function () {
if ($this->display) {
return $this->display;
}
return $this->notation === 24 ? 'HH:mm' : 'h:mm a';
return $this->notation === 24 ? 'HH:mm' : 'hh:mm a';
},
'default' => function (): string {
return $this->toDatetime($this->default, 'H:i:s') ?? '';
},
'format' => function () {
return $this->props['format'] ?? 'H:i:s';
},
'value' => function () {
return $this->toDatetime($this->value, 'H:i:s');
'value' => function (): ?string {
return $this->toDatetime($this->value, 'H:i:s') ?? '';
}
],
'validations' => [
'time',
'minMax' => function ($value) {
$min = $this->min ? strtotime($this->min) : null;
$max = $this->max ? strtotime($this->max) : null;
$value = strtotime($this->value());
if (!$value = Date::optional($value)) {
return true;
}
$min = Date::optional($this->min);
$max = Date::optional($this->max);
$format = 'H:i:s';
$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.time.between',
'data' => [
'min' => date($format, $min),
'max' => date($format, $max)
]
]);
} elseif ($min) {
throw new Exception([
'key' => 'validation.time.after',
'data' => [
'time' => date($format, $min),
]
]);
} else {
throw new Exception([
'key' => 'validation.time.before',
'data' => [
'time' => date($format, $max),
]
]);
}
if ($min && $max && $value->isBetween($min, $max) === false) {
throw new Exception([
'key' => 'validation.time.between',
'data' => [
'min' => $min->format($format),
'max' => $min->format($format)
]
]);
} elseif ($min && $value->isMin($min) === false) {
throw new Exception([
'key' => 'validation.time.after',
'data' => [
'time' => $min->format($format),
]
]);
} elseif ($max && $value->isMax($max) === false) {
throw new Exception([
'key' => 'validation.time.before',
'data' => [
'time' => $max->format($format),
]
]);
}
return true;

View file

@ -29,7 +29,8 @@ return [
],
'computed' => [
'value' => function () {
return Sane::sanitize(trim($this->value), 'html');
$value = trim($this->value ?? '');
return Sane::sanitize($value, 'html');
}
],
];

View file

@ -8,6 +8,7 @@ use Kirby\Exception\InvalidArgumentException;
use Kirby\Filesystem\Asset;
use Kirby\Filesystem\F;
use Kirby\Http\Router;
use Kirby\Toolkit\Date;
use Kirby\Toolkit\Escape;
use Kirby\Toolkit\I18n;
use Kirby\Toolkit\Str;
@ -98,10 +99,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);
}
@ -117,11 +115,18 @@ function css($url, $options = null): ?string
}
}
// only valid value for 'rel' is 'alternate stylesheet', if 'title' is given as well
if (
($options['rel'] ?? '') !== 'alternate stylesheet' ||
($options['title'] ?? '') === ''
) {
$options['rel'] = 'stylesheet';
}
$url = ($kirby->component('css'))($kirby, $url, $options);
$url = Url::to($url);
$attr = array_merge((array)$options, [
'href' => $url,
'rel' => 'stylesheet'
'href' => $url
]);
return '<link ' . attr($attr) . '>';
@ -373,10 +378,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);
}
@ -533,11 +535,12 @@ function load(array $classmap, ?string $base = null)
* `$kirby->markdown($text)`
*
* @param string|null $text
* @param array $options
* @return string
*/
function markdown(?string $text = null): string
function markdown(?string $text = null, array $options = []): string
{
return App::instance()->markdown($text);
return App::instance()->markdown($text, $options);
}
/**
@ -584,7 +587,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
@ -762,11 +765,12 @@ function svg($file)
*
* @param string|array $key
* @param string|null $fallback
* @param string|null $locale
* @return array|string|null
*/
function t($key, string $fallback = null)
function t($key, string $fallback = null, string $locale = null)
{
return I18n::translate($key, $fallback);
return I18n::translate($key, $fallback, $locale);
}
/**
@ -774,11 +778,13 @@ function t($key, string $fallback = null)
*
* @param string $key
* @param int $count
* @param string|null $locale
* @param bool $formatNumber If set to `false`, the count is not formatted
* @return mixed
*/
function tc(string $key, int $count)
function tc(string $key, int $count, string $locale = null, bool $formatNumber = true)
{
return I18n::translateCount($key, $count);
return I18n::translateCount($key, $count, $locale, $formatNumber);
}
/**
@ -791,60 +797,19 @@ function tc(string $key, int $count)
*/
function timestamp(?string $date = null, $step = null): ?int
{
if (V::date($date) === false) {
return null;
}
$date = strtotime($date);
if ($step === null) {
return $date;
}
// fallback for pre-3.5.0 usage
if (is_int($step) === true) {
$step = [
'unit' => 'minute',
'size' => $step
];
}
if (is_array($step) === false) {
return $date;
}
$parts = [
'second' => date('s', $date),
'minute' => date('i', $date),
'hour' => date('H', $date),
'day' => date('d', $date),
'month' => date('m', $date),
'year' => date('Y', $date),
];
$current = $parts[$step['unit']];
$nearest = round($current / $step['size']) * $step['size'];
$parts[$step['unit']] = $nearest;
foreach ($parts as $part => $value) {
if ($part === $step['unit']) {
break;
if ($date = Date::optional($date)) {
if ($step !== null) {
$step = Date::stepConfig($step, [
'unit' => 'minute',
'size' => 1
]);
$date->round($step['unit'], $step['size']);
}
$parts[$part] = 0;
return $date->timestamp();
}
$timestamp = strtotime(
$parts['year'] . '-' .
str_pad($parts['month'], 2, 0, STR_PAD_LEFT) . '-' .
str_pad($parts['day'], 2, 0, STR_PAD_LEFT) . ' ' .
str_pad($parts['hour'], 2, 0, STR_PAD_LEFT) . ':' .
str_pad($parts['minute'], 2, 0, STR_PAD_LEFT) . ':' .
str_pad($parts['second'], 2, 0, STR_PAD_LEFT)
);
// on error, convert `false` into `null`
return $timestamp ?? null;
return null;
}
/**

View file

@ -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;
},
@ -392,13 +393,14 @@ return function (App $app) {
* Converts the field content from Markdown/Kirbytext to valid HTML
*
* @param \Kirby\Cms\Field $field
* @param array $options
* @return \Kirby\Cms\Field
*/
'kirbytext' => function (Field $field) use ($app) {
$field->value = $app->kirbytext($field->value, [
'kirbytext' => function (Field $field, array $options = []) use ($app) {
$field->value = $app->kirbytext($field->value, A::merge($options, [
'parent' => $field->parent(),
'field' => $field
]);
]));
return $field;
},
@ -409,13 +411,17 @@ return function (App $app) {
* @since 3.1.0
*
* @param \Kirby\Cms\Field $field
* @param array $options
* @return \Kirby\Cms\Field
*/
'kirbytextinline' => function (Field $field) use ($app) {
$field->value = $app->kirbytext($field->value, [
'parent' => $field->parent(),
'field' => $field
], true);
'kirbytextinline' => function (Field $field, array $options = []) use ($app) {
$field->value = $app->kirbytext($field->value, A::merge($options, [
'parent' => $field->parent(),
'field' => $field,
'markdown' => [
'inline' => true
]
]));
return $field;
},
@ -450,10 +456,11 @@ return function (App $app) {
* Converts markdown to valid HTML
*
* @param \Kirby\Cms\Field $field
* @param array $options
* @return \Kirby\Cms\Field
*/
'markdown' => function (Field $field) use ($app) {
$field->value = $app->markdown($field->value);
'markdown' => function (Field $field, array $options = []) use ($app) {
$field->value = $app->markdown($field->value, $options);
return $field;
},

View file

@ -298,7 +298,7 @@ return [
if ($isLocalVideo === true) {
// handles local video file
if ($tag->file = $tag->file($tag->value)) {
$source = Html::tag('source', null, [
$source = Html::tag('source', '', [
'src' => $tag->file->url(),
'type' => $tag->file->mime()
]);