Upgrade to 3.7.0

This commit is contained in:
Bastian Allgeier
2022-06-27 10:02:22 +02:00
parent 0751a6510d
commit 1c22148d7b
674 changed files with 5052 additions and 3082 deletions

1
kirby/config/aliases.php Normal file → Executable file
View File

@@ -7,6 +7,7 @@ return [
'file' => 'Kirby\Cms\File',
'files' => 'Kirby\Cms\Files',
'find' => 'Kirby\Cms\Find',
'helpers' => 'Kirby\Cms\Helpers',
'html' => 'Kirby\Cms\Html',
'kirby' => 'Kirby\Cms\App',
'page' => 'Kirby\Cms\Page',

0
kirby/config/api/authentication.php Normal file → Executable file
View File

0
kirby/config/api/collections.php Normal file → Executable file
View File

0
kirby/config/api/models.php Normal file → Executable file
View File

7
kirby/config/api/models/File.php Normal file → Executable file
View File

@@ -29,13 +29,6 @@ return [
},
'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' => fn (File $file) => $file->panel()->image(),
'panelUrl' => fn (File $file) => $file->panel()->url(true),
'prev' => fn (File $file) => $file->prev(),

0
kirby/config/api/models/FileBlueprint.php Normal file → Executable file
View File

0
kirby/config/api/models/FileVersion.php Normal file → Executable file
View File

0
kirby/config/api/models/Language.php Normal file → Executable file
View File

15
kirby/config/api/models/Page.php Normal file → Executable file
View File

@@ -1,5 +1,6 @@
<?php
use Kirby\Cms\Helpers;
use Kirby\Cms\Page;
use Kirby\Form\Form;
@@ -22,11 +23,12 @@ return [
'isSortable' => fn (Page $page) => $page->isSortable(),
/**
* @deprecated 3.6.0
* @todo Throw deprecated warning in 3.7.0
* @todo Remove in 3.8.0
* @codeCoverageIgnore
*/
'next' => function (Page $page) {
Helpers::deprecated('The API field page.next has been deprecated and will be removed in 3.8.0.');
return $page
->nextAll()
->filter('intendedTemplate', $page->intendedTemplate())
@@ -36,24 +38,17 @@ return [
},
'num' => fn (Page $page) => $page->num(),
'options' => fn (Page $page) => $page->panel()->options(['preview']),
/**
* @todo Remove in 3.7.0
* @codeCoverageIgnore
*/
'panelIcon' => function (Page $page) {
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' => 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
* @todo Remove in 3.8.0
* @codeCoverageIgnore
*/
'prev' => function (Page $page) {
Helpers::deprecated('The API field page.prev has been deprecated and will be removed in 3.8.0.');
return $page
->prevAll()
->filter('intendedTemplate', $page->intendedTemplate())

0
kirby/config/api/models/PageBlueprint.php Normal file → Executable file
View File

0
kirby/config/api/models/Role.php Normal file → Executable file
View File

0
kirby/config/api/models/Site.php Normal file → Executable file
View File

0
kirby/config/api/models/SiteBlueprint.php Normal file → Executable file
View File

0
kirby/config/api/models/System.php Normal file → Executable file
View File

0
kirby/config/api/models/Translation.php Normal file → Executable file
View File

0
kirby/config/api/models/User.php Normal file → Executable file
View File

0
kirby/config/api/models/UserBlueprint.php Normal file → Executable file
View File

0
kirby/config/api/routes.php Normal file → Executable file
View File

0
kirby/config/api/routes/auth.php Normal file → Executable file
View File

0
kirby/config/api/routes/files.php Normal file → Executable file
View File

0
kirby/config/api/routes/languages.php Normal file → Executable file
View File

47
kirby/config/api/routes/lock.php Normal file → Executable file
View File

@@ -5,29 +5,6 @@
* Content Lock Routes
*/
return [
[
'pattern' => '(:all)/lock',
'method' => 'GET',
/**
* @deprecated 3.6.0
* @todo Remove in 3.7.0
*/
'action' => function (string $path) {
deprecated('The `GET (:all)/lock` API endpoint has been deprecated and will be removed in 3.7.0');
if ($lock = $this->parent($path)->lock()) {
return [
'supported' => true,
'locked' => $lock->get()
];
}
return [
'supported' => false,
'locked' => null
];
}
],
[
'pattern' => '(:all)/lock',
'method' => 'PATCH',
@@ -46,30 +23,6 @@ return [
}
}
],
[
'pattern' => '(:all)/unlock',
'method' => 'GET',
/**
* @deprecated 3.6.0
* @todo Remove in 3.7.0
*/
'action' => function (string $path) {
deprecated('The `GET (:all)/unlock` API endpoint has been deprecated and will be removed in 3.7.0');
if ($lock = $this->parent($path)->lock()) {
return [
'supported' => true,
'unlocked' => $lock->isUnlocked()
];
}
return [
'supported' => false,
'unlocked' => null
];
}
],
[
'pattern' => '(:all)/unlock',
'method' => 'PATCH',

15
kirby/config/api/routes/pages.php Normal file → Executable file
View File

@@ -1,5 +1,6 @@
<?php
/**
* Page Routes
*/
@@ -34,21 +35,9 @@ return [
}
],
[
'pattern' => [
'pages/(:any)/blueprints',
/**
* @deprecated
* @todo remove in 3.7.0
*/
'pages/(:any)/children/blueprints',
],
'pattern' => 'pages/(:any)/blueprints',
'method' => 'GET',
'action' => function (string $id) {
// @codeCoverageIgnoreStart
if ($this->route->pattern() === 'pages/([a-zA-Z0-9\.\-_%= \+\@\(\)]+)/children/blueprints') {
deprecated('`GET pages/(:any)/children/blueprints` API endpoint has been deprecated and will be removed in 3.7.0. Use `GET pages/(:any)/blueprints` instead');
}
// @codeCoverageIgnoreEnd
return $this->page($id)->blueprints($this->requestQuery('section'));
}
],

10
kirby/config/api/routes/roles.php Normal file → Executable file
View File

@@ -8,13 +8,15 @@ return [
'pattern' => 'roles',
'method' => 'GET',
'action' => function () {
switch (get('canBe')) {
$kirby = $this->kirby();
switch ($kirby->request()->get('canBe')) {
case 'changed':
return $this->kirby()->roles()->canBeChanged();
return $kirby->roles()->canBeChanged();
case 'created':
return $this->kirby()->roles()->canBeCreated();
return $kirby->roles()->canBeCreated();
default:
return $this->kirby()->roles();
return $kirby->roles();
}
}
],

15
kirby/config/api/routes/site.php Normal file → Executable file
View File

@@ -1,5 +1,6 @@
<?php
/**
* Site Routes
*/
@@ -47,21 +48,9 @@ return [
}
],
[
'pattern' => [
'site/blueprints',
/**
* @deprecated
* @todo remove in 3.7.0
*/
'site/children/blueprints',
],
'pattern' => 'site/blueprints',
'method' => 'GET',
'action' => function () {
// @codeCoverageIgnoreStart
if ($this->route->pattern() === 'site/children/blueprints') {
deprecated('`GET site/children/blueprints` API endpoint has been deprecated and will be removed in 3.7.0. Use `GET site/blueprints` instead.');
}
// @codeCoverageIgnoreEnd
return $this->site()->blueprints($this->requestQuery('section'));
}
],

0
kirby/config/api/routes/system.php Normal file → Executable file
View File

0
kirby/config/api/routes/translations.php Normal file → Executable file
View File

0
kirby/config/api/routes/users.php Normal file → Executable file
View File

4
kirby/config/areas/account.php Normal file → Executable file
View File

@@ -1,9 +1,11 @@
<?php
use Kirby\Toolkit\I18n;
return function () {
return [
'icon' => 'account',
'label' => t('view.account'),
'label' => I18n::translate('view.account'),
'search' => 'users',
'dialogs' => require __DIR__ . '/account/dialogs.php',
'dropdowns' => require __DIR__ . '/account/dropdowns.php',

0
kirby/config/areas/account/dialogs.php Normal file → Executable file
View File

0
kirby/config/areas/account/dropdowns.php Normal file → Executable file
View File

5
kirby/config/areas/account/views.php Normal file → Executable file
View File

@@ -1,5 +1,6 @@
<?php
use Kirby\Cms\App;
use Kirby\Cms\Find;
use Kirby\Panel\Panel;
@@ -8,7 +9,7 @@ return [
'pattern' => 'account',
'action' => fn () => [
'component' => 'k-account-view',
'props' => kirby()->user()->panel()->props(),
'props' => App::instance()->user()->panel()->props(),
],
],
'account.file' => [
@@ -21,7 +22,7 @@ return [
'pattern' => 'logout',
'auth' => false,
'action' => function () {
if ($user = kirby()->user()) {
if ($user = App::instance()->user()) {
$user->logout();
}
Panel::go('login');

13
kirby/config/areas/files/dialogs.php Normal file → Executable file
View File

@@ -4,6 +4,7 @@ use Kirby\Cms\Find;
use Kirby\Panel\Field;
use Kirby\Panel\Panel;
use Kirby\Toolkit\Escape;
use Kirby\Toolkit\I18n;
/**
* Shared file dialogs
@@ -21,7 +22,7 @@ return [
'props' => [
'fields' => [
'name' => [
'label' => t('name'),
'label' => I18n::translate('name'),
'type' => 'slug',
'required' => true,
'icon' => 'title',
@@ -30,7 +31,7 @@ return [
'preselect' => true
]
],
'submitButton' => t('rename'),
'submitButton' => I18n::translate('rename'),
'value' => [
'name' => $file->name(),
]
@@ -39,7 +40,7 @@ return [
},
'submit' => function (string $path, string $filename) {
$file = Find::file($path, $filename);
$renamed = $file->changeName(get('name'));
$renamed = $file->changeName($file->kirby()->request()->get('name'));
$oldUrl = $file->panel()->url(true);
$newUrl = $renamed->panel()->url(true);
$response = [
@@ -70,7 +71,7 @@ return [
'fields' => [
'position' => Field::filePosition($file)
],
'submitButton' => t('change'),
'submitButton' => I18n::translate('change'),
'value' => [
'position' => $file->sort()->isEmpty() ? $file->siblings(false)->count() + 1 : $file->sort()->toInt(),
]
@@ -81,7 +82,7 @@ return [
$file = Find::file($path, $filename);
$files = $file->siblings()->sorted();
$ids = $files->keys();
$newIndex = (int)(get('position')) - 1;
$newIndex = (int)($file->kirby()->request()->get('position')) - 1;
$oldIndex = $files->indexOf($file);
array_splice($ids, $oldIndex, 1);
@@ -101,7 +102,7 @@ return [
return [
'component' => 'k-remove-dialog',
'props' => [
'text' => tt('file.delete.confirm', [
'text' => I18n::template('file.delete.confirm', [
'filename' => Escape::html($file->filename())
]),
]

0
kirby/config/areas/files/dropdowns.php Normal file → Executable file
View File

3
kirby/config/areas/installation.php Normal file → Executable file
View File

@@ -1,11 +1,12 @@
<?php
use Kirby\Panel\Panel;
use Kirby\Toolkit\I18n;
return function ($kirby) {
return [
'icon' => 'settings',
'label' => t('view.installation'),
'label' => I18n::translate('view.installation'),
'views' => [
'installation' => [
'pattern' => 'installation',

4
kirby/config/areas/languages.php Normal file → Executable file
View File

@@ -1,9 +1,11 @@
<?php
use Kirby\Toolkit\I18n;
return function ($kirby) {
return [
'icon' => 'globe',
'label' => t('view.languages'),
'label' => I18n::translate('view.languages'),
'menu' => true,
'dialogs' => require __DIR__ . '/languages/dialogs.php',
'views' => require __DIR__ . '/languages/views.php'

46
kirby/config/areas/languages/dialogs.php Normal file → Executable file
View File

@@ -1,19 +1,21 @@
<?php
use Kirby\Cms\App;
use Kirby\Cms\Find;
use Kirby\Panel\Field;
use Kirby\Toolkit\A;
use Kirby\Toolkit\Escape;
use Kirby\Toolkit\I18n;
$languageDialogFields = [
'name' => [
'label' => t('language.name'),
'label' => I18n::translate('language.name'),
'type' => 'text',
'required' => true,
'icon' => 'title'
],
'code' => [
'label' => t('language.code'),
'label' => I18n::translate('language.code'),
'type' => 'text',
'required' => true,
'counter' => false,
@@ -21,18 +23,18 @@ $languageDialogFields = [
'width' => '1/2'
],
'direction' => [
'label' => t('language.direction'),
'label' => I18n::translate('language.direction'),
'type' => 'select',
'required' => true,
'empty' => false,
'options' => [
['value' => 'ltr', 'text' => t('language.direction.ltr')],
['value' => 'rtl', 'text' => t('language.direction.rtl')]
['value' => 'ltr', 'text' => I18n::translate('language.direction.ltr')],
['value' => 'rtl', 'text' => I18n::translate('language.direction.rtl')]
],
'width' => '1/2'
],
'locale' => [
'label' => t('language.locale'),
'label' => I18n::translate('language.locale'),
'type' => 'text',
],
];
@@ -47,7 +49,7 @@ return [
'component' => 'k-language-dialog',
'props' => [
'fields' => $languageDialogFields,
'submitButton' => t('language.create'),
'submitButton' => I18n::translate('language.create'),
'value' => [
'code' => '',
'direction' => 'ltr',
@@ -58,12 +60,16 @@ return [
];
},
'submit' => function () {
kirby()->languages()->create([
'code' => get('code'),
'direction' => get('direction'),
'locale' => get('locale'),
'name' => get('name'),
$kirby = App::instance();
$data = $kirby->request()->get([
'code',
'direction',
'locale',
'name'
]);
$kirby->languages()->create($data);
return [
'event' => 'language.create'
];
@@ -78,7 +84,7 @@ return [
return [
'component' => 'k-remove-dialog',
'props' => [
'text' => tt('language.delete.confirm', [
'text' => I18n::template('language.delete.confirm', [
'name' => Escape::html($language->name())
])
]
@@ -116,7 +122,7 @@ return [
$fields['locale'] = [
'label' => $fields['locale']['label'],
'type' => 'info',
'text' => t('language.locale.warning')
'text' => I18n::translate('language.locale.warning')
];
}
@@ -124,7 +130,7 @@ return [
'component' => 'k-language-dialog',
'props' => [
'fields' => $fields,
'submitButton' => t('save'),
'submitButton' => I18n::translate('save'),
'value' => [
'code' => $language->code(),
'direction' => $language->direction(),
@@ -136,11 +142,11 @@ return [
];
},
'submit' => function (string $id) {
$language = Find::language($id)->update([
'direction' => get('direction'),
'locale' => get('locale'),
'name' => get('name'),
]);
$kirby = App::instance();
$data = $kirby->request()->get(['direction', 'locale', 'name']);
$language = Find::language($id)->update($data);
return [
'event' => 'language.update'
];

3
kirby/config/areas/languages/views.php Normal file → Executable file
View File

@@ -1,12 +1,13 @@
<?php
use Kirby\Cms\App;
use Kirby\Toolkit\Escape;
return [
'languages' => [
'pattern' => 'languages',
'action' => function () {
$kirby = kirby();
$kirby = App::instance();
return [
'component' => 'k-languages-view',

3
kirby/config/areas/login.php Normal file → Executable file
View File

@@ -1,11 +1,12 @@
<?php
use Kirby\Panel\Panel;
use Kirby\Toolkit\I18n;
return function ($kirby) {
return [
'icon' => 'user',
'label' => t('login'),
'label' => I18n::translate('login'),
'views' => [
'login' => [
'pattern' => 'login',

5
kirby/config/areas/site.php Normal file → Executable file
View File

@@ -1,13 +1,14 @@
<?php
use Kirby\Toolkit\I18n;
return function ($kirby) {
return [
'breadcrumbLabel' => function () use ($kirby) {
return $kirby->site()->title()->or(t('view.site'))->toString();
return $kirby->site()->title()->or(I18n::translate('view.site'))->toString();
},
'icon' => 'home',
'label' => $kirby->site()->blueprint()->title() ?? t('view.site'),
'label' => $kirby->site()->blueprint()->title() ?? I18n::translate('view.site'),
'menu' => true,
'dialogs' => require __DIR__ . '/site/dialogs.php',
'dropdowns' => require __DIR__ . '/site/dropdowns.php',

114
kirby/config/areas/site/dialogs.php Normal file → Executable file
View File

@@ -1,11 +1,13 @@
<?php
use Kirby\Cms\App;
use Kirby\Cms\Find;
use Kirby\Exception\Exception;
use Kirby\Exception\InvalidArgumentException;
use Kirby\Exception\PermissionException;
use Kirby\Panel\Field;
use Kirby\Panel\Panel;
use Kirby\Toolkit\I18n;
use Kirby\Toolkit\Str;
$files = require __DIR__ . '/../files/dialogs.php';
@@ -33,7 +35,7 @@ return [
'fields' => [
'position' => Field::pagePosition($page),
],
'submitButton' => t('change'),
'submitButton' => I18n::translate('change'),
'value' => [
'position' => $page->panel()->position()
]
@@ -41,7 +43,13 @@ return [
];
},
'submit' => function (string $id) {
Find::page($id)->changeStatus('listed', get('position'));
$request = App::instance()->request();
Find::page($id)->changeStatus(
'listed',
$request->get('position')
);
return [
'event' => 'page.sort',
];
@@ -75,7 +83,7 @@ return [
return [
'component' => 'k-error-dialog',
'props' => [
'message' => t('error.page.changeStatus.incomplete'),
'message' => I18n::translate('error.page.changeStatus.incomplete'),
'details' => $errors,
]
];
@@ -84,7 +92,7 @@ return [
$fields = [
'status' => [
'label' => t('page.changeStatus.select'),
'label' => I18n::translate('page.changeStatus.select'),
'type' => 'radio',
'required' => true,
'options' => $states
@@ -105,7 +113,7 @@ return [
'component' => 'k-form-dialog',
'props' => [
'fields' => $fields,
'submitButton' => t('change'),
'submitButton' => I18n::translate('change'),
'value' => [
'status' => $status,
'position' => $position
@@ -114,7 +122,13 @@ return [
];
},
'submit' => function (string $id) {
Find::page($id)->changeStatus(get('status'), get('position'));
$request = App::instance()->request();
Find::page($id)->changeStatus(
$request->get('status'),
$request->get('position')
);
return [
'event' => 'page.changeStatus',
];
@@ -145,7 +159,7 @@ return [
'required' => true
])
],
'submitButton' => t('change'),
'submitButton' => I18n::translate('change'),
'value' => [
'template' => $page->intendedTemplate()->name()
]
@@ -153,7 +167,10 @@ return [
];
},
'submit' => function (string $id) {
Find::page($id)->changeTemplate(get('template'));
$request = App::instance()->request();
Find::page($id)->changeTemplate($request->get('template'));
return [
'event' => 'page.changeTemplate',
];
@@ -164,9 +181,11 @@ return [
'page.changeTitle' => [
'pattern' => 'pages/(:any)/changeTitle',
'load' => function (string $id) {
$request = App::instance()->request();
$page = Find::page($id);
$permissions = $page->permissions();
$select = get('select', 'title');
$select = $request->get('select', 'title');
return [
'component' => 'k-form-dialog',
@@ -183,13 +202,13 @@ return [
'path' => $page->parent() ? '/' . $page->parent()->id() . '/' : '/',
'disabled' => $permissions->can('changeSlug') === false,
'wizard' => [
'text' => t('page.changeSlug.fromTitle'),
'text' => I18n::translate('page.changeSlug.fromTitle'),
'field' => 'title'
]
])
],
'autofocus' => false,
'submitButton' => t('change'),
'submitButton' => I18n::translate('change'),
'value' => [
'title' => $page->title()->value(),
'slug' => $page->slug(),
@@ -198,9 +217,11 @@ return [
];
},
'submit' => function (string $id) {
$request = App::instance()->request();
$page = Find::page($id);
$title = trim(get('title', ''));
$slug = trim(get('slug', ''));
$title = trim($request->get('title', ''));
$slug = trim($request->get('slug', ''));
// basic input validation before we move on
if (Str::length($title) === 0) {
@@ -256,17 +277,20 @@ return [
'page.create' => [
'pattern' => 'pages/create',
'load' => function () {
$kirby = App::instance();
$request = $kirby->request();
// the parent model for the new page
$parent = get('parent', 'site');
$parent = $request->get('parent', 'site');
// the view on which the add button is located
// this is important to find the right section
// and provide the correct templates for the new page
$view = get('view', $parent);
$view = $request->get('view', $parent);
// templates will be fetched depending on the
// section settings in the blueprint
$section = get('section');
$section = $request->get('section');
// this is the parent model
$model = Find::parent($parent);
@@ -300,7 +324,7 @@ return [
// only show template field if > 1 templates available
// or when in debug mode
if (count($blueprints) > 1 || option('debug') === true) {
if (count($blueprints) > 1 || $kirby->option('debug') === true) {
$fields['template'] = Field::template($blueprints, [
'required' => true
]);
@@ -310,7 +334,7 @@ return [
'component' => 'k-form-dialog',
'props' => [
'fields' => $fields,
'submitButton' => t('page.draft.create'),
'submitButton' => I18n::translate('page.draft.create'),
'value' => [
'parent' => $parent,
'slug' => '',
@@ -321,7 +345,8 @@ return [
];
},
'submit' => function () {
$title = trim(get('title', ''));
$request = App::instance()->request();
$title = trim($request->get('title', ''));
if (Str::length($title) === 0) {
throw new InvalidArgumentException([
@@ -329,10 +354,10 @@ return [
]);
}
$page = Find::parent(get('parent', 'site'))->createChild([
$page = Find::parent($request->get('parent', 'site'))->createChild([
'content' => ['title' => $title],
'slug' => get('slug'),
'template' => get('template'),
'slug' => $request->get('slug'),
'template' => $request->get('template'),
]);
return [
@@ -347,7 +372,7 @@ return [
'pattern' => 'pages/(:any)/delete',
'load' => function (string $id) {
$page = Find::page($id);
$text = tt('page.delete.confirm', [
$text = I18n::template('page.delete.confirm', [
'title' => Escape::html($page->title()->value())
]);
@@ -359,16 +384,16 @@ return [
'info' => [
'type' => 'info',
'theme' => 'negative',
'text' => t('page.delete.confirm.subpages')
'text' => I18n::translate('page.delete.confirm.subpages')
],
'check' => [
'label' => t('page.delete.confirm.title'),
'label' => I18n::translate('page.delete.confirm.title'),
'type' => 'text',
'counter' => false
]
],
'size' => 'medium',
'submitButton' => t('delete'),
'submitButton' => I18n::translate('delete'),
'text' => $text,
'theme' => 'negative',
]
@@ -383,12 +408,17 @@ return [
];
},
'submit' => function (string $id) {
$request = App::instance()->request();
$page = Find::page($id);
$redirect = false;
$referrer = Panel::referrer();
$url = $page->panel()->url(true);
if ($page->childrenAndDrafts()->count() > 0 && get('check') !== $page->title()->value()) {
if (
$page->childrenAndDrafts()->count() > 0 &&
$request->get('check') !== $page->title()->value()
) {
throw new InvalidArgumentException(['key' => 'page.delete.confirm']);
}
@@ -425,7 +455,7 @@ return [
'required' => true,
'path' => $page->parent() ? '/' . $page->parent()->id() . '/' : '/',
'wizard' => [
'text' => t('page.changeSlug.fromTitle'),
'text' => I18n::translate('page.changeSlug.fromTitle'),
'field' => 'title'
]
])
@@ -433,7 +463,7 @@ return [
if ($hasFiles === true) {
$fields['files'] = [
'label' => t('page.duplicate.files'),
'label' => I18n::translate('page.duplicate.files'),
'type' => 'toggle',
'required' => true,
'width' => $toggleWidth
@@ -442,7 +472,7 @@ return [
if ($hasChildren === true) {
$fields['children'] = [
'label' => t('page.duplicate.pages'),
'label' => I18n::translate('page.duplicate.pages'),
'type' => 'toggle',
'required' => true,
'width' => $toggleWidth
@@ -453,21 +483,23 @@ return [
'component' => 'k-form-dialog',
'props' => [
'fields' => $fields,
'submitButton' => t('duplicate'),
'submitButton' => I18n::translate('duplicate'),
'value' => [
'children' => false,
'files' => false,
'slug' => $page->slug() . '-' . Str::slug(t('page.duplicate.appendix')),
'title' => $page->title() . ' ' . t('page.duplicate.appendix')
'slug' => $page->slug() . '-' . Str::slug(I18n::translate('page.duplicate.appendix')),
'title' => $page->title() . ' ' . I18n::translate('page.duplicate.appendix')
]
]
];
},
'submit' => function (string $id) {
$newPage = Find::page($id)->duplicate(get('slug'), [
'children' => (bool)get('children'),
'files' => (bool)get('files'),
'title' => (string)get('title'),
$request = App::instance()->request();
$newPage = Find::page($id)->duplicate($request->get('slug'), [
'children' => (bool)$request->get('children'),
'files' => (bool)$request->get('files'),
'title' => (string)$request->get('title'),
]);
return [
@@ -511,15 +543,17 @@ return [
'preselect' => true
])
],
'submitButton' => t('rename'),
'submitButton' => I18n::translate('rename'),
'value' => [
'title' => site()->title()->value()
'title' => App::instance()->site()->title()->value()
]
]
];
},
'submit' => function () {
site()->changeTitle(get('title'));
$kirby = App::instance();
$kirby->site()->changeTitle($kirby->request()->get('title'));
return [
'event' => 'site.changeTitle',
];

0
kirby/config/areas/site/dropdowns.php Normal file → Executable file
View File

10
kirby/config/areas/site/searches.php Normal file → Executable file
View File

@@ -1,13 +1,15 @@
<?php
use Kirby\Cms\App;
use Kirby\Toolkit\Escape;
use Kirby\Toolkit\I18n;
return [
'pages' => [
'label' => t('pages'),
'label' => I18n::translate('pages'),
'icon' => 'page',
'query' => function (string $query = null) {
$pages = site()
$pages = App::instance()->site()
->index(true)
->search($query)
->filter('isReadable', true)
@@ -28,10 +30,10 @@ return [
}
],
'files' => [
'label' => t('files'),
'label' => I18n::translate('files'),
'icon' => 'image',
'query' => function (string $query = null) {
$files = site()
$files = App::instance()->site()
->index(true)
->filter('isReadable', true)
->files()

3
kirby/config/areas/site/views.php Normal file → Executable file
View File

@@ -1,5 +1,6 @@
<?php
use Kirby\Cms\App;
use Kirby\Cms\Find;
return [
@@ -15,7 +16,7 @@ return [
],
'site' => [
'pattern' => 'site',
'action' => fn () => site()->panel()->view()
'action' => fn () => App::instance()->site()->panel()->view()
],
'site.file' => [
'pattern' => 'site/files/(:any)',

4
kirby/config/areas/system.php Normal file → Executable file
View File

@@ -1,9 +1,11 @@
<?php
use Kirby\Toolkit\I18n;
return function ($kirby) {
return [
'icon' => 'settings',
'label' => t('view.system'),
'label' => I18n::translate('view.system'),
'menu' => true,
'dialogs' => require __DIR__ . '/system/dialogs.php',
'views' => require __DIR__ . '/system/views.php'

53
kirby/config/areas/system/dialogs.php Normal file → Executable file
View File

@@ -1,8 +1,46 @@
<?php
use Kirby\Cms\App;
use Kirby\Panel\Field;
use Kirby\Toolkit\I18n;
return [
// license key
'license' => [
'load' => function () {
$license = App::instance()->system()->license();
// @codeCoverageIgnoreStart
// the system is registered but the license
// key is only visible for admins
if ($license === true) {
$license = 'Kirby 3';
}
// @codeCoverageIgnoreEnd
return [
'component' => 'k-form-dialog',
'props' => [
'size' => 'medium',
'fields' => [
'license' => [
'type' => 'info',
'label' => I18n::translate('license'),
'text' => $license ? $license : I18n::translate('license.unregistered.label'),
'theme' => $license ? 'code' : 'negative',
'help' => $license ?
// @codeCoverageIgnoreStart
'<a href="https://hub.getkirby.com">' . I18n::translate('license.manage') . ' &rarr;</a>' :
// @codeCoverageIgnoreEnd
'<a href="https://getkirby.com/buy">' . I18n::translate('license.buy') . ' &rarr;</a>'
]
],
'submitButton' => false,
'cancelButton' => false,
]
];
}
],
// license registration
'registration' => [
'load' => function () {
@@ -11,18 +49,18 @@ return [
'props' => [
'fields' => [
'license' => [
'label' => t('license.register.label'),
'label' => I18n::translate('license.register.label'),
'type' => 'text',
'required' => true,
'counter' => false,
'placeholder' => 'K3-',
'help' => t('license.register.help')
'help' => I18n::translate('license.register.help')
],
'email' => Field::email([
'required' => true
])
],
'submitButton' => t('license.register'),
'submitButton' => I18n::translate('license.register'),
'value' => [
'license' => null,
'email' => null
@@ -32,10 +70,15 @@ return [
},
'submit' => function () {
// @codeCoverageIgnoreStart
kirby()->system()->register(get('license'), get('email'));
$kirby = App::instance();
$kirby->system()->register(
$kirby->request()->get('license'),
$kirby->request()->get('email')
);
return [
'event' => 'system.register',
'message' => t('license.register.success')
'message' => I18n::translate('license.register.success')
];
// @codeCoverageIgnoreEnd
}

18
kirby/config/areas/system/views.php Normal file → Executable file
View File

@@ -1,12 +1,12 @@
<?php
use Kirby\Http\Server;
use Kirby\Cms\App;
return [
'system' => [
'pattern' => 'system',
'action' => function () {
$kirby = kirby();
$kirby = App::instance();
$system = $kirby->system();
$license = $system->license();
@@ -24,8 +24,10 @@ return [
return [
'author' => $plugin->authorsNames(),
'license' => $plugin->license(),
'link' => $plugin->link(),
'name' => $plugin->name(),
'name' => [
'text' => $plugin->name(),
'href' => $plugin->link(),
],
'version' => $plugin->version(),
];
});
@@ -38,8 +40,14 @@ return [
'plugins' => $plugins,
'php' => phpversion(),
'server' => $system->serverSoftware(),
'https' => Server::https(),
'https' => $kirby->environment()->https(),
'version' => $kirby->version(),
'urls' => [
'content' => $system->exposedFileUrl('content'),
'git' => $system->exposedFileUrl('git'),
'kirby' => $system->exposedFileUrl('kirby'),
'site' => $system->exposedFileUrl('site')
]
]
];
}

4
kirby/config/areas/users.php Normal file → Executable file
View File

@@ -1,9 +1,11 @@
<?php
use Kirby\Toolkit\I18n;
return function ($kirby) {
return [
'icon' => 'users',
'label' => t('view.users'),
'label' => I18n::translate('view.users'),
'search' => 'users',
'menu' => true,
'dialogs' => require __DIR__ . '/users/dialogs.php',

64
kirby/config/areas/users/dialogs.php Normal file → Executable file
View File

@@ -1,11 +1,13 @@
<?php
use Kirby\Cms\App;
use Kirby\Cms\Find;
use Kirby\Cms\UserRules;
use Kirby\Exception\InvalidArgumentException;
use Kirby\Panel\Field;
use Kirby\Panel\Panel;
use Kirby\Toolkit\Escape;
use Kirby\Toolkit\I18n;
$files = require __DIR__ . '/../files/dialogs.php';
@@ -15,7 +17,7 @@ return [
'user.create' => [
'pattern' => 'users/create',
'load' => function () {
$kirby = kirby();
$kirby = App::instance();
return [
'component' => 'k-form-dialog',
'props' => [
@@ -33,7 +35,7 @@ return [
'required' => true
])
],
'submitButton' => t('create'),
'submitButton' => I18n::translate('create'),
'value' => [
'name' => '',
'email' => '',
@@ -45,13 +47,16 @@ return [
];
},
'submit' => function () {
kirby()->users()->create([
'name' => get('name'),
'email' => get('email'),
'password' => get('password'),
'language' => get('translation'),
'role' => get('role')
$kirby = App::instance();
$kirby->users()->create([
'name' => $kirby->request()->get('name'),
'email' => $kirby->request()->get('email'),
'password' => $kirby->request()->get('password'),
'language' => $kirby->request()->get('translation'),
'role' => $kirby->request()->get('role')
]);
return [
'event' => 'user.create'
];
@@ -69,13 +74,13 @@ return [
'props' => [
'fields' => [
'email' => [
'label' => t('email'),
'label' => I18n::translate('email'),
'required' => true,
'type' => 'email',
'preselect' => true
]
],
'submitButton' => t('change'),
'submitButton' => I18n::translate('change'),
'value' => [
'email' => $user->email()
]
@@ -83,7 +88,10 @@ return [
];
},
'submit' => function (string $id) {
Find::user($id)->changeEmail(get('email'));
$request = App::instance()->request();
Find::user($id)->changeEmail($request->get('email'));
return [
'event' => 'user.changeEmail'
];
@@ -102,7 +110,7 @@ return [
'fields' => [
'translation' => Field::translation(['required' => true])
],
'submitButton' => t('change'),
'submitButton' => I18n::translate('change'),
'value' => [
'translation' => $user->language()
]
@@ -110,7 +118,9 @@ return [
];
},
'submit' => function (string $id) {
Find::user($id)->changeLanguage(get('translation'));
$request = App::instance()->request();
Find::user($id)->changeLanguage($request->get('translation'));
return [
'event' => 'user.changeLanguage',
@@ -135,7 +145,7 @@ return [
'preselect' => true
])
],
'submitButton' => t('rename'),
'submitButton' => I18n::translate('rename'),
'value' => [
'name' => $user->name()->value()
]
@@ -143,7 +153,9 @@ return [
];
},
'submit' => function (string $id) {
Find::user($id)->changeName(get('name'));
$request = App::instance()->request();
Find::user($id)->changeName($request->get('name'));
return [
'event' => 'user.changeName'
@@ -162,20 +174,22 @@ return [
'props' => [
'fields' => [
'password' => Field::password([
'label' => t('user.changePassword.new'),
'label' => I18n::translate('user.changePassword.new'),
]),
'passwordConfirmation' => Field::password([
'label' => t('user.changePassword.new.confirm'),
'label' => I18n::translate('user.changePassword.new.confirm'),
])
],
'submitButton' => t('change'),
'submitButton' => I18n::translate('change'),
]
];
},
'submit' => function (string $id) {
$request = App::instance()->request();
$user = Find::user($id);
$password = get('password');
$passwordConfirmation = get('passwordConfirmation');
$password = $request->get('password');
$passwordConfirmation = $request->get('passwordConfirmation');
// validate the password
UserRules::validPassword($user, $password ?? '');
@@ -207,11 +221,11 @@ return [
'props' => [
'fields' => [
'role' => Field::role([
'label' => t('user.changeRole.select'),
'label' => I18n::translate('user.changeRole.select'),
'required' => true,
])
],
'submitButton' => t('user.changeRole'),
'submitButton' => I18n::translate('user.changeRole'),
'value' => [
'role' => $user->role()->name()
]
@@ -219,7 +233,9 @@ return [
];
},
'submit' => function (string $id) {
$user = Find::user($id)->changeRole(get('role'));
$request = App::instance()->request();
$user = Find::user($id)->changeRole($request->get('role'));
return [
'event' => 'user.changeRole',
@@ -238,7 +254,7 @@ return [
return [
'component' => 'k-remove-dialog',
'props' => [
'text' => tt($i18nPrefix . '.delete.confirm', [
'text' => I18n::template($i18nPrefix . '.delete.confirm', [
'email' => Escape::html($user->email())
])
]

0
kirby/config/areas/users/dropdowns.php Normal file → Executable file
View File

6
kirby/config/areas/users/searches.php Normal file → Executable file
View File

@@ -1,13 +1,15 @@
<?php
use Kirby\Cms\App;
use Kirby\Toolkit\Escape;
use Kirby\Toolkit\I18n;
return [
'users' => [
'label' => t('users'),
'label' => I18n::translate('users'),
'icon' => 'users',
'query' => function (string $query = null) {
$users = kirby()->users()->search($query)->limit(10);
$users = App::instance()->users()->search($query)->limit(10);
$results = [];
foreach ($users as $user) {

7
kirby/config/areas/users/views.php Normal file → Executable file
View File

@@ -1,5 +1,6 @@
<?php
use Kirby\Cms\App;
use Kirby\Cms\Find;
use Kirby\Toolkit\Escape;
@@ -7,8 +8,8 @@ return [
'users' => [
'pattern' => 'users',
'action' => function () {
$kirby = kirby();
$role = get('role');
$kirby = App::instance();
$role = $kirby->request()->get('role');
$roles = $kirby->roles()->toArray(fn ($role) => [
'id' => $role->id(),
'title' => $role->title(),
@@ -32,7 +33,7 @@ return [
$users = $users->paginate([
'limit' => 20,
'page' => get('page')
'page' => $kirby->request()->get('page')
]);
return [

0
kirby/config/blocks/code/code.php Normal file → Executable file
View File

0
kirby/config/blocks/code/code.yml Normal file → Executable file
View File

0
kirby/config/blocks/gallery/gallery.php Normal file → Executable file
View File

0
kirby/config/blocks/gallery/gallery.yml Normal file → Executable file
View File

0
kirby/config/blocks/heading/heading.php Normal file → Executable file
View File

0
kirby/config/blocks/heading/heading.yml Normal file → Executable file
View File

4
kirby/config/blocks/image/image.php Normal file → Executable file
View File

@@ -17,9 +17,9 @@ if ($block->location() == 'web') {
?>
<?php if ($src): ?>
<figure<?= attr(['data-ratio' => $ratio, 'data-crop' => $crop], ' ') ?>>
<figure<?= Html::attr(['data-ratio' => $ratio, 'data-crop' => $crop], null, ' ') ?>>
<?php if ($link->isNotEmpty()): ?>
<a href="<?= esc($link->toUrl()) ?>">
<a href="<?= Str::esc($link->toUrl()) ?>">
<img src="<?= $src ?>" alt="<?= $alt->esc() ?>">
</a>
<?php else: ?>

0
kirby/config/blocks/image/image.yml Normal file → Executable file
View File

0
kirby/config/blocks/line/line.php Normal file → Executable file
View File

0
kirby/config/blocks/line/line.yml Normal file → Executable file
View File

0
kirby/config/blocks/list/list.php Normal file → Executable file
View File

0
kirby/config/blocks/list/list.yml Normal file → Executable file
View File

0
kirby/config/blocks/markdown/markdown.php Normal file → Executable file
View File

0
kirby/config/blocks/markdown/markdown.yml Normal file → Executable file
View File

0
kirby/config/blocks/quote/quote.php Normal file → Executable file
View File

0
kirby/config/blocks/quote/quote.yml Normal file → Executable file
View File

0
kirby/config/blocks/table/table.yml Normal file → Executable file
View File

0
kirby/config/blocks/text/text.php Normal file → Executable file
View File

0
kirby/config/blocks/text/text.yml Normal file → Executable file
View File

8
kirby/config/blocks/video/video.php Normal file → Executable file
View File

@@ -1,5 +1,9 @@
<?php /** @var \Kirby\Cms\Block $block */ ?>
<?php if ($video = video($block->url())): ?>
<?php
use Kirby\Cms\Html;
/** @var \Kirby\Cms\Block $block */
?>
<?php if ($video = Html::video($block->url())): ?>
<figure>
<?= $video ?>
<?php if ($block->caption()->isNotEmpty()): ?>

0
kirby/config/blocks/video/video.yml Normal file → Executable file
View File

0
kirby/config/blueprints/blocks/code.yml Normal file → Executable file
View File

0
kirby/config/blueprints/blocks/heading.yml Normal file → Executable file
View File

0
kirby/config/blueprints/blocks/image.yml Normal file → Executable file
View File

0
kirby/config/blueprints/blocks/quote.yml Normal file → Executable file
View File

0
kirby/config/blueprints/blocks/table.yml Normal file → Executable file
View File

0
kirby/config/blueprints/blocks/text.yml Normal file → Executable file
View File

0
kirby/config/blueprints/blocks/video.yml Normal file → Executable file
View File

0
kirby/config/blueprints/files/default.yml Normal file → Executable file
View File

0
kirby/config/blueprints/pages/default.yml Normal file → Executable file
View File

0
kirby/config/blueprints/site.yml Normal file → Executable file
View File

29
kirby/config/components.php Normal file → Executable file
View File

@@ -4,12 +4,12 @@ use Kirby\Cms\App;
use Kirby\Cms\Collection;
use Kirby\Cms\File;
use Kirby\Cms\FileVersion;
use Kirby\Cms\Helpers;
use Kirby\Cms\Template;
use Kirby\Data\Data;
use Kirby\Email\PHPMailer as Emailer;
use Kirby\Filesystem\F;
use Kirby\Filesystem\Filename;
use Kirby\Http\Server;
use Kirby\Http\Uri;
use Kirby\Http\Url;
use Kirby\Image\Darkroom;
@@ -39,9 +39,12 @@ return [
* @param mixed $variable
* @param bool $echo
* @return string
*
* @deprecated 3.7.0 Disable `dump()` via `KIRBY_HELPER_DUMP` instead and create your own function
* @todo move to `Helpers::dump()`, remove component in 3.8.0
*/
'dump' => function (App $kirby, $variable, bool $echo = true) {
if (Server::cli() === true) {
if ($kirby->environment()->cli() === true) {
$output = print_r($variable, true) . PHP_EOL;
} else {
$output = '<pre>' . print_r($variable, true) . '</pre>';
@@ -138,13 +141,19 @@ return [
* @param array $options Markdown options
* @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;
// warning for deprecated fourth parameter
if (func_num_args() === 4 && isset($options['inline']) === false) {
// @codeCoverageIgnoreStart
Helpers::deprecated('markdown component: the $inline parameter is deprecated and will be removed in Kirby 3.8.0. Use $options[\'inline\'] instead.');
// @codeCoverageIgnoreEnd
}
// support for the deprecated fourth argument
$options['inline'] ??= $inline;
@@ -155,7 +164,7 @@ return [
$config = $options;
}
return $markdown->parse($text, $options['inline']);
return $markdown->parse($text, $options['inline'] ?? false);
},
/**
@@ -332,8 +341,8 @@ return [
*/
'thumb' => function (App $kirby, string $src, string $dst, array $options): string {
$darkroom = Darkroom::factory(
option('thumbs.driver', 'gd'),
option('thumbs', [])
$kirby->option('thumbs.driver', 'gd'),
$kirby->option('thumbs', [])
);
$options = $darkroom->preprocess($src, $options);
$root = (new Filename($src, $dst, $options))->toString();
@@ -371,7 +380,13 @@ return [
if ($kirby->multilang() === true) {
$parts = Str::split($path, '#');
if ($page = page($parts[0] ?? null)) {
if ($parts[0] ?? null) {
$page = $kirby->site()->find($parts[0]);
} else {
$page = $kirby->site()->page();
}
if ($page) {
$path = $page->url($language);
if (isset($parts[1]) === true) {

0
kirby/config/fields/checkboxes.php Normal file → Executable file
View File

0
kirby/config/fields/date.php Normal file → Executable file
View File

0
kirby/config/fields/email.php Normal file → Executable file
View File

0
kirby/config/fields/files.php Normal file → Executable file
View File

0
kirby/config/fields/gap.php Normal file → Executable file
View File

0
kirby/config/fields/headline.php Normal file → Executable file
View File

0
kirby/config/fields/hidden.php Normal file → Executable file
View File

0
kirby/config/fields/info.php Normal file → Executable file
View File

0
kirby/config/fields/line.php Normal file → Executable file
View File

0
kirby/config/fields/list.php Normal file → Executable file
View File

0
kirby/config/fields/mixins/datetime.php Normal file → Executable file
View File

0
kirby/config/fields/mixins/filepicker.php Normal file → Executable file
View File

0
kirby/config/fields/mixins/layout.php Normal file → Executable file
View File

0
kirby/config/fields/mixins/min.php Normal file → Executable file
View File

0
kirby/config/fields/mixins/options.php Normal file → Executable file
View File

0
kirby/config/fields/mixins/pagepicker.php Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More