Media browser: recursive scan entire content/ tree, /-media/ URL prefix, editor change detection fix

- handleMediaList() now scans content/ recursively for all media files
- URLs use /-media/ prefix mapping directly to content/ (no special cases)
- index.php: added /-media/ route, kept /-assets/ for backward compat
- editor-toolbar.js: fixed editor.on('change') placement (was inside switchMode)
- content-edit.php and content-new.php: back-btn unsaved-changes detection
- Removed unused __editorCleanup global
This commit is contained in:
2026-06-24 17:00:59 +02:00
parent d97c67c6a9
commit dc0d370e65
50 changed files with 2796 additions and 140 deletions

View File

@@ -0,0 +1,74 @@
<h2 class="mb-4"><i class="bi bi-plug"></i> Plugin Configuratie: <?= htmlspecialchars($pluginName) ?></h2>
<form method="post" class="card shadow-sm">
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($csrf) ?>">
<div class="card-body">
<?php if (empty($pluginConfig)): ?>
<div class="alert alert-info">Deze plugin heeft geen configureerbare instellingen.</div>
<?php else: ?>
<?php foreach ($pluginConfig as $key => $value): ?>
<?= renderConfigField($key, $value) ?>
<?php endforeach; ?>
<?php endif; ?>
</div>
<?php if (!empty($pluginConfig)): ?>
<div class="card-footer text-end">
<a href="admin.php?route=plugins" class="btn btn-secondary">Annuleren</a>
<button type="submit" class="btn btn-primary"><i class="bi bi-check-lg"></i> Opslaan</button>
</div>
<?php endif; ?>
</form>
<div class="mt-3">
<a href="admin.php?route=plugins" class="btn btn-outline-secondary btn-sm">
<i class="bi bi-arrow-left"></i> Terug naar plugins
</a>
</div>
<?php
function renderConfigField(string $key, $value, string $prefix = ''): string
{
$name = $prefix ? $prefix . '[' . $key . ']' : 'config[' . $key . ']';
$id = 'cfg_' . str_replace(['.', '['], '_', rtrim($name, ']'));
$label = ucwords(str_replace('_', ' ', $key));
$html = '';
if (is_bool($value)) {
$checked = $value ? 'checked' : '';
$html .= '<div class="mb-3 form-check form-switch">';
$html .= '<input type="hidden" name="' . htmlspecialchars($name) . '" value="0">';
$html .= '<input class="form-check-input" type="checkbox" id="' . htmlspecialchars($id) . '" name="' . htmlspecialchars($name) . '" value="1" ' . $checked . '>';
$html .= '<label class="form-check-label" for="' . htmlspecialchars($id) . '">' . htmlspecialchars($label) . '</label>';
$html .= '</div>';
} elseif (is_numeric($value)) {
$step = is_float($value) ? 'step="0.01"' : 'step="1"';
$html .= '<div class="mb-3">';
$html .= '<label for="' . htmlspecialchars($id) . '" class="form-label">' . htmlspecialchars($label) . '</label>';
$html .= '<input type="number" class="form-control" id="' . htmlspecialchars($id) . '" name="' . htmlspecialchars($name) . '" value="' . htmlspecialchars($value) . '" ' . $step . '>';
$html .= '</div>';
} elseif (is_array($value)) {
$html .= '<div class="mb-3">';
$html .= '<label class="form-label fw-bold">' . htmlspecialchars($label) . '</label>';
$html .= '<div class="card bg-light">';
$html .= '<div class="card-body">';
foreach ($value as $subKey => $subValue) {
$html .= renderConfigField($subKey, $subValue, $name);
}
$html .= '</div></div></div>';
} else {
$html .= '<div class="mb-3">';
$html .= '<label for="' . htmlspecialchars($id) . '" class="form-label">' . htmlspecialchars($label) . '</label>';
if (strlen($value) > 80 || str_contains($value, "\n")) {
$html .= '<textarea class="form-control font-monospace" id="' . htmlspecialchars($id) . '" name="' . htmlspecialchars($name) . '" rows="4">' . htmlspecialchars($value) . '</textarea>';
} else {
$html .= '<input type="text" class="form-control" id="' . htmlspecialchars($id) . '" name="' . htmlspecialchars($name) . '" value="' . htmlspecialchars($value) . '">';
}
$html .= '</div>';
}
return $html;
}