update Kirby

This commit is contained in:
isUnknown 2025-04-22 16:01:57 +02:00
parent ecd997c895
commit 1b05e91943
47 changed files with 963 additions and 307 deletions

View file

@ -1,5 +1,6 @@
<?php
use Kirby\Cms\App;
use Kirby\Panel\Lab\Category;
use Kirby\Panel\Lab\Docs;
@ -108,6 +109,7 @@ return [
$example = $category->example($id, $tab);
$props = $example->props();
$vue = $example->vue();
$compiler = App::instance()->option('panel.vue.compiler', true);
if (Docs::installed() === true && $docs = $props['docs'] ?? null) {
$docs = new Docs($docs);
@ -131,6 +133,7 @@ return [
]
],
'props' => [
'compiler' => $compiler,
'docs' => $docs?->name(),
'examples' => $vue['examples'],
'file' => $example->module(),

View file

@ -242,12 +242,26 @@ return [
$fields['key']['disabled'] = true;
$fields['value']['autofocus'] = true;
// shows info text when variable is an array
// TODO: 5.0: use entries field instead showing info text
$isVariableArray = is_array($variable->value()) === true;
if ($isVariableArray === true) {
$fields['value'] = [
'label' => I18n::translate('info'),
'type' => 'info',
'text' => 'You are using an array variable for this key. Please modify it in the language file in /site/languages',
];
}
return [
'component' => 'k-form-dialog',
'props' => [
'fields' => $fields,
'size' => 'large',
'value' => [
'props' => [
'cancelButton' => $isVariableArray === false,
'fields' => $fields,
'size' => 'large',
'submitButton' => $isVariableArray === false,
'value' => [
'key' => $variable->key(),
'value' => $variable->value()
]

View file

@ -11,6 +11,8 @@ return [
$system = $kirby->system();
$updateStatus = $system->updateStatus();
$license = $system->license();
$debugMode = $kirby->option('debug', false) === true;
$isLocal = $system->isLocal();
$environment = [
[
@ -45,10 +47,14 @@ return [
$plugins = $system->plugins()->values(function ($plugin) use (&$exceptions) {
$authors = $plugin->authorsNames();
$updateStatus = $plugin->updateStatus();
$version = $updateStatus?->toArray() ?? $plugin->version() ?? '';
$version = $updateStatus?->toArray();
$version ??= $plugin->version() ?? '';
if ($updateStatus !== null) {
$exceptions = array_merge($exceptions, $updateStatus->exceptionMessages());
$exceptions = [
...$exceptions,
...$updateStatus->exceptionMessages()
];
}
return [
@ -64,15 +70,29 @@ return [
$security = $updateStatus?->messages() ?? [];
if ($kirby->option('debug', false) === true) {
if ($isLocal === true) {
$security[] = [
'id' => 'debug',
'text' => I18n::translate('system.issues.debug'),
'link' => 'https://getkirby.com/security/debug'
'id' => 'local',
'icon' => 'info',
'theme' => 'info',
'text' => I18n::translate('system.issues.local')
];
}
if ($kirby->environment()->https() !== true) {
if ($debugMode === true) {
$security[] = [
'id' => 'debug',
'icon' => $isLocal ? 'info' : 'alert',
'theme' => $isLocal ? 'info' : 'negative',
'text' => I18n::translate('system.issues.debug'),
'link' => 'https://getkirby.com/security/debug'
];
}
if (
$isLocal === false &&
$kirby->environment()->https() !== true
) {
$security[] = [
'id' => 'https',
'text' => I18n::translate('system.issues.https'),
@ -80,20 +100,34 @@ return [
];
}
if ($kirby->option('panel.vue.compiler', null) === null) {
$security[] = [
'id' => 'vue-compiler',
'link' => 'https://getkirby.com/security/vue-compiler',
'text' => I18n::translate('system.issues.vue.compiler'),
'theme' => 'notice'
];
}
// sensitive URLs
if ($isLocal === false) {
$sensitive = [
'content' => $system->exposedFileUrl('content'),
'git' => $system->exposedFileUrl('git'),
'kirby' => $system->exposedFileUrl('kirby'),
'site' => $system->exposedFileUrl('site')
];
}
return [
'component' => 'k-system-view',
'props' => [
'environment' => $environment,
'exceptions' => $kirby->option('debug') === true ? $exceptions : [],
'exceptions' => $debugMode ? $exceptions : [],
'info' => $system->info(),
'plugins' => $plugins,
'security' => $security,
'urls' => [
'content' => $system->exposedFileUrl('content'),
'git' => $system->exposedFileUrl('git'),
'kirby' => $system->exposedFileUrl('kirby'),
'site' => $system->exposedFileUrl('site')
]
'urls' => $sensitive ?? null
]
];
}

View file

@ -3,6 +3,7 @@
use Kirby\Cms\App;
use Kirby\Cms\Find;
use Kirby\Cms\UserRules;
use Kirby\Exception\Exception;
use Kirby\Exception\InvalidArgumentException;
use Kirby\Panel\Field;
use Kirby\Panel\Panel;
@ -42,7 +43,9 @@ return [
'link' => false,
'required' => true
]),
'password' => Field::password(),
'password' => Field::password([
'autocomplete' => 'new-password'
]),
'translation' => Field::translation([
'required' => true
]),
@ -180,17 +183,23 @@ return [
'user.changePassword' => [
'pattern' => 'users/(:any)/changePassword',
'load' => function (string $id) {
$user = Find::user($id);
Find::user($id);
return [
'component' => 'k-form-dialog',
'props' => [
'fields' => [
'fields' => [
'currentPassword' => Field::password([
'label' => I18n::translate('user.changePassword.current'),
'autocomplete' => 'current-password'
]),
'password' => Field::password([
'label' => I18n::translate('user.changePassword.new'),
'label' => I18n::translate('user.changePassword.new'),
'autocomplete' => 'new-password'
]),
'passwordConfirmation' => Field::password([
'label' => I18n::translate('user.changePassword.new.confirm'),
'label' => I18n::translate('user.changePassword.new.confirm'),
'autocomplete' => 'new-password'
])
],
'submitButton' => I18n::translate('change'),
@ -198,13 +207,26 @@ return [
];
},
'submit' => function (string $id) {
$request = App::instance()->request();
$kirby = App::instance();
$request = $kirby->request();
$user = Find::user($id);
$currentPassword = $request->get('currentPassword');
$password = $request->get('password');
$passwordConfirmation = $request->get('passwordConfirmation');
// validate the password
// validate the current password of the acting user
try {
$kirby->user()->validatePassword($currentPassword);
} catch (Exception) {
// catching and re-throwing exception to avoid automatic
// sign-out of current user from the Panel
throw new InvalidArgumentException([
'key' => 'user.password.wrong'
]);
}
// validate the new password
UserRules::validPassword($user, $password ?? '');
// compare passwords

View file

@ -14,6 +14,7 @@ use Kirby\Filesystem\Filename;
use Kirby\Http\Uri;
use Kirby\Http\Url;
use Kirby\Image\Darkroom;
use Kirby\Session\SessionStore;
use Kirby\Template\Snippet;
use Kirby\Template\Template;
use Kirby\Text\Markdown;
@ -262,6 +263,13 @@ return [
);
},
/**
* Add your own session store
*/
'session::store' => function (App $kirby): string|SessionStore {
return $kirby->root('sessions');
},
/**
* Add your own SmartyPants parser
*