v2.6.1d (Lyra): Plugin i18n, plugin editor vernieuwd, media invoegen

Plugin internationalisatie: plugins hebben eigen language/ mappen. Systeem
plugins volgen admin taal (admin.php), content plugins volgen content taal
(site.php). Fallback chain: geselecteerd -> plugin default_language -> CMS
default. PluginManager/AdminPluginAPI/CMSAPI uitgebreid met
getPluginTranslations()/t(). plugin.json settings ondersteunen
label_key/help_key/option_label_key.

Plugin uniformiteit: alle 6 plugins hebben uniforme structuur (README.md,
assets/.gitkeep, language/nl|en/). plugins/README.md herschreven.
guide plugin-development.md (NL+EN) volledig herschreven.

Plugin editor vernieuwd: geneste bestandsbrowser zijbalk, nieuw bestand
aanmaken, uploaden naar assets/, verwijderen en verplaatsen. Nieuwe routes:
plugins-file-upload, plugins-file-delete, plugins-file-move. Path-traversal
bescherming + protected plugins geblokkeerd.

Media invoegen in editor: nieuw /admin/media-list JSON endpoint + herbruikbare
_media-modal.twig include. Plugin-context scant assets/ map. editor-toolbar.js
modeMap uitgebreid voor css/scss/js/json.

Plugin overzicht knoppen: alleen iconen met title/aria-label.

Tests: pentest 30/30, WCAG 2.1 AA 25/25.
This commit is contained in:
2026-08-18 13:49:52 +00:00
parent 88fbaa5702
commit 6d5ca7cab4
64 changed files with 3503 additions and 366 deletions
+59 -9
View File
@@ -20,19 +20,63 @@ class Logs
public function getAdminMenu(): array
{
$config = $this->getPluginConfig();
$requiredRoles = $config['required_roles'] ?? ['bi-manager', 'site-admin', 'admin'];
return [
[
'plugin' => 'Logs',
'route' => 'logs',
'label' => 'Logs',
'label_key' => 'menu_label',
'icon' => 'bi-journal-text',
'section' => 'general',
'permission' => 'logs',
'required_roles' => $requiredRoles,
],
];
}
/**
* Get this plugin's runtime config (defaults + overrides).
*/
private function getPluginConfig(): array
{
$pluginDir = dirname(__DIR__);
$pluginJsonFile = $pluginDir . '/plugin.json';
$configJsonFile = $pluginDir . '/config.json';
$defaults = [];
if (file_exists($pluginJsonFile)) {
$pluginJson = json_decode(file_get_contents($pluginJsonFile), true) ?? [];
foreach ($pluginJson['settings'] ?? [] as $setting) {
if (isset($setting['key'])) {
$defaults[$setting['key']] = $setting['default'] ?? null;
}
}
}
$overrides = [];
if (file_exists($configJsonFile)) {
$overrides = json_decode(file_get_contents($configJsonFile), true) ?? [];
}
return array_merge($defaults, $overrides);
}
public function handleAdminRoute(string $action): ?string
{
$config = $this->getPluginConfig();
$maxLines = (int)($config['max_lines'] ?? 100);
$showAdminTab = $config['show_admin_tab'] ?? true;
$showRequestsTab = $config['show_requests_tab'] ?? true;
// System plugin: translations resolve against the admin language.
$t = $this->api ? $this->api->getPluginTranslations('Logs') : [];
$tr = function (string $key) use ($t): string {
return $t[$key] ?? $key;
};
$tab = $_GET['tab'] ?? 'admin';
$logDir = dirname(__DIR__, 2) . '/admin/storage/logs';
$logFile = $tab === 'requests' ? $logDir . '/requests.log' : $logDir . '/admin.log';
@@ -40,7 +84,7 @@ class Logs
$logs = [];
if (file_exists($logFile)) {
$lines = file($logFile) ?: [];
$lines = array_slice($lines, -100);
$lines = array_slice($lines, -$maxLines);
foreach ($lines as $line) {
if (preg_match('/^\[([^\]]+)\] \[([^\]]+)\] \[([^\]]+)\] (.+)$/', trim($line), $m)) {
$logs[] = [
@@ -56,31 +100,37 @@ class Logs
ob_start();
?>
<h2 class="mb-4"><i class="bi bi-journal-text"></i> Logs</h2>
<h2 class="mb-4"><i class="bi bi-journal-text"></i> <?= htmlspecialchars($tr('page_title')) ?></h2>
<?php if ($showAdminTab || $showRequestsTab): ?>
<ul class="nav nav-tabs mb-3">
<?php if ($showAdminTab): ?>
<li class="nav-item">
<a class="nav-link <?= $tab === 'admin' ? 'active' : '' ?>" href="/admin/logs?tab=admin">Admin</a>
<a class="nav-link <?= $tab === 'admin' ? 'active' : '' ?>" href="/admin/logs?tab=admin"><?= htmlspecialchars($tr('tab_admin')) ?></a>
</li>
<?php endif; ?>
<?php if ($showRequestsTab): ?>
<li class="nav-item">
<a class="nav-link <?= $tab === 'requests' ? 'active' : '' ?>" href="/admin/logs?tab=requests">Requests</a>
<a class="nav-link <?= $tab === 'requests' ? 'active' : '' ?>" href="/admin/logs?tab=requests"><?= htmlspecialchars($tr('tab_requests')) ?></a>
</li>
<?php endif; ?>
</ul>
<?php endif; ?>
<div class="card shadow-sm">
<div class="card-body p-0">
<table class="table table-hover mb-0">
<thead>
<tr>
<th>Tijd</th>
<th>Level</th>
<th>IP</th>
<th>Bericht</th>
<th><?= htmlspecialchars($tr('col_time')) ?></th>
<th><?= htmlspecialchars($tr('col_level')) ?></th>
<th><?= htmlspecialchars($tr('col_ip')) ?></th>
<th><?= htmlspecialchars($tr('col_message')) ?></th>
</tr>
</thead>
<tbody>
<?php if (empty($logs)): ?>
<tr><td colspan="4" class="text-muted text-center py-4">Geen logs gevonden.</td></tr>
<tr><td colspan="4" class="text-muted text-center py-4"><?= htmlspecialchars($tr('no_logs')) ?></td></tr>
<?php else: ?>
<?php foreach ($logs as $log): ?>
<tr>
+49
View File
@@ -0,0 +1,49 @@
# Logs Plugin
Toont admin activiteitlogs en front-end request logs met filter tabs op een admin-pagina.
## Plugin type
**Systeem** plugin. De plugin-output volgt de geselecteerde **admin taal** (via `AdminPluginAPI::getPluginTranslations()` met `admin.php`).
## Bestandsstructuur
```
Logs/
├── Logs.php # Hoofd plugin class
├── plugin.json # Plugin metadata + instellingen
├── README.md # Dit bestand
├── assets/ # Optionele CSS/JS (leeg)
└── language/ # Vertalingen
├── nl/admin.php # Nederlandse admin labels
└── en/admin.php # Engelse admin labels
```
## Functies
- **Admin tab**: Toont admin activiteitlogs (uit `admin/storage/logs/admin.log`)
- **Requests tab**: Toont front-end request logs (uit `admin/storage/logs/requests.log`)
- Tabbladen kunnen via de instellingen in/uitgeschakeld worden
- Aantal getoonde regels is instelbaar (meest recente eerst)
## Instellingen
Deze plugin heeft instelbare configuratie (`hasConfig: true`). Instellingen worden gedefinieerd in `plugin.json` onder `settings` en overschreven via `config.json`.
| Sleutel | Type | Standaard | Beschrijving |
|---------|------|-----------|--------------|
| `required_roles` | multi-select | `bi-manager, site-admin, admin` | Rollen die deze plugin mogen zien |
| `max_lines` | number | `100` | Aantal logregels dat getoond wordt (meest recente eerst) |
| `show_admin_tab` | checkbox | `true` | Schakel de admin activiteit-log tab in of uit |
| `show_requests_tab` | checkbox | `true` | Schakel de front-end request-log tab in of uit |
De label- en help-teksten voor instellingen worden vertaald via `label_key`/`help_key` (verwijst naar sleutels in `language/<lang>/admin.php`).
## Taal support
De plugin gebruikt `AdminPluginAPI::getPluginTranslations('Logs')` om labels op te halen. Fallback chain:
1. Geselecteerde admin taal
2. Plugin `default_language` (`nl`)
3. Lege array (sleutel wordt ongewijzigd getoond)
Beschikbare sleutels staan in `language/<lang>/admin.php`. Het admin-menu label wordt vertaald via `label_key: 'menu_label'` in `getAdminMenu()`.
View File
+32
View File
@@ -0,0 +1,32 @@
<?php
return [
// Menu
'menu_label' => 'Logs',
// Page
'page_title' => 'Logs',
'tab_admin' => 'Admin',
'tab_requests' => 'Requests',
'col_time' => 'Time',
'col_level' => 'Level',
'col_ip' => 'IP',
'col_message' => 'Message',
'no_logs' => 'No logs found.',
'analytics_disabled' => 'Analytics is disabled.',
// Settings (plugin.json label_key/help_key)
'setting_required_roles' => 'Roles allowed to view this plugin',
'setting_required_roles_help' => 'Determines which roles can access the logs page in the admin panel. Admin always has access.',
'role_options' => [
'admin' => 'Admin',
'content-manager' => 'Content Manager',
'bi-manager' => 'BI Manager',
'site-admin' => 'Site Admin',
],
'setting_max_lines' => 'Maximum number of lines',
'setting_max_lines_help' => 'Number of log lines shown (most recent first).',
'setting_show_admin_tab' => 'Show admin log tab',
'setting_show_admin_tab_help' => 'Enable or disable the admin activity log tab.',
'setting_show_requests_tab' => 'Show request log tab',
'setting_show_requests_tab_help' => 'Enable or disable the front-end request log tab.',
];
+32
View File
@@ -0,0 +1,32 @@
<?php
return [
// Menu
'menu_label' => 'Logs',
// Page
'page_title' => 'Logs',
'tab_admin' => 'Admin',
'tab_requests' => 'Requests',
'col_time' => 'Tijd',
'col_level' => 'Level',
'col_ip' => 'IP',
'col_message' => 'Bericht',
'no_logs' => 'Geen logs gevonden.',
'analytics_disabled' => 'Analytics is uitgeschakeld.',
// Settings (plugin.json label_key/help_key)
'setting_required_roles' => 'Rollen die deze plugin mogen zien',
'setting_required_roles_help' => 'Bepaalt welke rollen toegang hebben tot de logs-pagina in het admin-paneel. Admin heeft altijd toegang.',
'role_options' => [
'admin' => 'Admin',
'content-manager' => 'Content Beheerder',
'bi-manager' => 'BI Beheerder',
'site-admin' => 'Site Admin',
],
'setting_max_lines' => 'Maximaal aantal regels',
'setting_max_lines_help' => 'Aantal logregels dat getoond wordt (meest recente eerst).',
'setting_show_admin_tab' => 'Toon admin-log tab',
'setting_show_admin_tab_help' => 'Schakel de admin activiteit-log tab in of uit.',
'setting_show_requests_tab' => 'Toon request-log tab',
'setting_show_requests_tab_help' => 'Schakel de front-end request-log tab in of uit.',
];
+39 -1
View File
@@ -5,5 +5,43 @@
"description": "Toont admin activiteitlogs en front-end request logs met filter tabs.",
"type": "system",
"essential": false,
"hasConfig": true
"hasConfig": true,
"default_language": "nl",
"settings": [
{
"key": "required_roles",
"label_key": "setting_required_roles",
"help_key": "setting_required_roles_help",
"option_label_key": "role_options",
"type": "multi-select",
"default": ["bi-manager", "site-admin", "admin"],
"options": {
"admin": "Admin",
"content-manager": "Content Beheerder",
"bi-manager": "BI Beheerder",
"site-admin": "Site Admin"
}
},
{
"key": "max_lines",
"label_key": "setting_max_lines",
"help_key": "setting_max_lines_help",
"type": "number",
"default": 100
},
{
"key": "show_admin_tab",
"label_key": "setting_show_admin_tab",
"help_key": "setting_show_admin_tab_help",
"type": "checkbox",
"default": true
},
{
"key": "show_requests_tab",
"label_key": "setting_show_requests_tab",
"help_key": "setting_show_requests_tab_help",
"type": "checkbox",
"default": true
}
]
}