xiaowang/kirby/config/areas/system/views.php

100 lines
2.7 KiB
PHP
Raw Normal View History

2021-11-18 17:44:47 +01:00
<?php
2022-08-31 16:08:03 +02:00
use Kirby\Cms\App;
2022-12-19 16:26:24 +01:00
use Kirby\Toolkit\I18n;
2021-11-18 17:44:47 +01:00
return [
2022-08-31 16:08:03 +02:00
'system' => [
'pattern' => 'system',
'action' => function () {
2022-12-19 16:26:24 +01:00
$kirby = App::instance();
$system = $kirby->system();
$updateStatus = $system->updateStatus();
$license = $system->license();
$environment = [
[
'label' => $license ? I18n::translate('license') : I18n::translate('license.register.label'),
'value' => $license ? 'Kirby 3' : I18n::translate('license.unregistered.label'),
'theme' => $license ? null : 'negative',
'dialog' => $license ? 'license' : 'registration'
],
[
'label' => $updateStatus?->label() ?? I18n::translate('version'),
'value' => $kirby->version(),
'link' => (
$updateStatus ?
$updateStatus->url() :
'https://github.com/getkirby/kirby/releases/tag/' . $kirby->version()
),
'theme' => $updateStatus?->theme()
],
[
'label' => 'PHP',
'value' => phpversion()
],
[
'label' => I18n::translate('server'),
'value' => $system->serverSoftware() ?? '?'
]
];
$exceptions = $updateStatus?->exceptionMessages() ?? [];
$plugins = $system->plugins()->values(function ($plugin) use (&$exceptions) {
$authors = $plugin->authorsNames();
$updateStatus = $plugin->updateStatus();
$version = $updateStatus?->toArray() ?? $plugin->version() ?? '';
if ($updateStatus !== null) {
$exceptions = array_merge($exceptions, $updateStatus->exceptionMessages());
}
2021-11-18 17:44:47 +01:00
2022-08-31 16:08:03 +02:00
return [
2022-12-19 16:26:24 +01:00
'author' => empty($authors) ? '' : $authors,
'license' => $plugin->license() ?? '',
2022-08-31 16:08:03 +02:00
'name' => [
2022-12-19 16:26:24 +01:00
'text' => $plugin->name() ?? '',
2022-08-31 16:08:03 +02:00
'href' => $plugin->link(),
],
2022-12-19 16:26:24 +01:00
'version' => $version,
2022-08-31 16:08:03 +02:00
];
});
2021-11-18 17:44:47 +01:00
2022-12-19 16:26:24 +01:00
$security = $updateStatus?->messages() ?? [];
if ($kirby->option('debug', false) === true) {
$security[] = [
'id' => 'debug',
'text' => I18n::translate('system.issues.debug'),
'link' => 'https://getkirby.com/security/debug'
];
}
if ($kirby->environment()->https() !== true) {
$security[] = [
'id' => 'https',
'text' => I18n::translate('system.issues.https'),
'link' => 'https://getkirby.com/security/https'
];
}
2022-08-31 16:08:03 +02:00
return [
'component' => 'k-system-view',
'props' => [
2022-12-19 16:26:24 +01:00
'environment' => $environment,
'exceptions' => $kirby->option('debug') === true ? $exceptions : [],
'plugins' => $plugins,
'security' => $security,
'urls' => [
2022-08-31 16:08:03 +02:00
'content' => $system->exposedFileUrl('content'),
'git' => $system->exposedFileUrl('git'),
'kirby' => $system->exposedFileUrl('kirby'),
'site' => $system->exposedFileUrl('site')
]
]
];
}
],
2021-11-18 17:44:47 +01:00
];