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

140 lines
3.7 KiB
PHP
Raw Normal View History

2022-06-17 17:51:59 +02:00
<?php
2022-08-31 15:02:43 +02:00
use Kirby\Cms\App;
2025-07-11 14:41:34 +02:00
use Kirby\Panel\Ui\Buttons\ViewButtons;
2022-12-19 14:56:05 +01:00
use Kirby\Toolkit\I18n;
2022-06-17 17:51:59 +02:00
return [
2022-08-31 15:02:43 +02:00
'system' => [
'pattern' => 'system',
'action' => function () {
2022-12-19 14:56:05 +01:00
$kirby = App::instance();
$system = $kirby->system();
$updateStatus = $system->updateStatus();
$license = $system->license();
2025-04-21 18:57:21 +02:00
$debugMode = $kirby->option('debug', false) === true;
$isLocal = $system->isLocal();
2022-12-19 14:56:05 +01:00
$environment = [
[
2025-04-21 18:57:21 +02:00
'label' => $license->status()->label(),
'value' => $license->label(),
'theme' => $license->status()->theme(),
'icon' => $license->status()->icon(),
'dialog' => $license->status()->dialog()
2022-12-19 14:56:05 +01:00
],
[
'label' => $updateStatus?->label() ?? I18n::translate('version'),
'value' => $kirby->version(),
2025-04-21 18:57:21 +02:00
'link' => $updateStatus?->url() ??
'https://github.com/getkirby/kirby/releases/tag/' . $kirby->version(),
'theme' => $updateStatus?->theme(),
'icon' => $updateStatus?->icon() ?? 'info'
2022-12-19 14:56:05 +01:00
],
[
'label' => 'PHP',
2025-04-21 18:57:21 +02:00
'value' => phpversion(),
'icon' => 'code'
2022-12-19 14:56:05 +01:00
],
[
'label' => I18n::translate('server'),
2025-04-21 18:57:21 +02:00
'value' => $system->serverSoftwareShort() ?? '?',
'icon' => 'server'
2022-12-19 14:56:05 +01:00
]
];
$exceptions = $updateStatus?->exceptionMessages() ?? [];
$plugins = $system->plugins()->values(function ($plugin) use (&$exceptions) {
$authors = $plugin->authorsNames();
$updateStatus = $plugin->updateStatus();
2025-04-21 18:57:21 +02:00
$version = $updateStatus?->toArray();
$version ??= $plugin->version() ?? '';
2022-12-19 14:56:05 +01:00
if ($updateStatus !== null) {
2025-04-21 18:57:21 +02:00
$exceptions = [
...$exceptions,
...$updateStatus->exceptionMessages()
];
2022-12-19 14:56:05 +01:00
}
2022-06-17 17:51:59 +02:00
2022-08-31 15:02:43 +02:00
return [
2022-12-19 14:56:05 +01:00
'author' => empty($authors) ? '' : $authors,
2025-07-11 14:41:34 +02:00
'license' => $plugin->license()->toArray(),
2022-08-31 15:02:43 +02:00
'name' => [
2022-12-19 14:56:05 +01:00
'text' => $plugin->name() ?? '',
2022-08-31 15:02:43 +02:00
'href' => $plugin->link(),
],
2025-07-11 14:41:34 +02:00
'status' => $plugin->license()->status()->toArray(),
2022-12-19 14:56:05 +01:00
'version' => $version,
2022-08-31 15:02:43 +02:00
];
});
2022-06-17 17:51:59 +02:00
2022-12-19 14:56:05 +01:00
$security = $updateStatus?->messages() ?? [];
2025-04-21 18:57:21 +02:00
if ($isLocal === true) {
2022-12-19 14:56:05 +01:00
$security[] = [
2025-04-21 18:57:21 +02:00
'id' => 'local',
'icon' => 'info',
'theme' => 'info',
'text' => I18n::translate('system.issues.local')
2022-12-19 14:56:05 +01:00
];
}
2025-04-21 18:57:21 +02:00
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
) {
2022-12-19 14:56:05 +01:00
$security[] = [
'id' => 'https',
'text' => I18n::translate('system.issues.https'),
'link' => 'https://getkirby.com/security/https'
];
}
2025-04-21 18:57:21 +02:00
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')
];
}
2022-08-31 15:02:43 +02:00
return [
'component' => 'k-system-view',
'props' => [
2025-07-11 14:41:34 +02:00
'buttons' => fn () =>
ViewButtons::view('system')->render(),
2022-12-19 14:56:05 +01:00
'environment' => $environment,
2025-04-21 18:57:21 +02:00
'exceptions' => $debugMode ? $exceptions : [],
'info' => $system->info(),
2022-12-19 14:56:05 +01:00
'plugins' => $plugins,
'security' => $security,
2025-07-11 14:41:34 +02:00
'urls' => $sensitive ?? []
2022-08-31 15:02:43 +02:00
]
];
}
],
2022-06-17 17:51:59 +02:00
];