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.
101 lines
4.8 KiB
PHP
101 lines
4.8 KiB
PHP
<?php
|
|
|
|
class HTMLBlock
|
|
{
|
|
private array $config;
|
|
private ?PluginAPIInterface $api = null;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->config = [
|
|
'title' => 'HTML Block Plugin',
|
|
'type' => 'content',
|
|
];
|
|
}
|
|
|
|
public function setAPI(PluginAPIInterface $api): void
|
|
{
|
|
$this->api = $api;
|
|
}
|
|
|
|
public function getSidebarContent(): string
|
|
{
|
|
// Content plugin: translations follow the current content language.
|
|
$t = $this->api ? $this->api->getPluginTranslations('HTMLBlock') : [];
|
|
$tr = function (string $key) use ($t): string {
|
|
return $t[$key] ?? $key;
|
|
};
|
|
|
|
$currentPage = $this->api ? $this->api->getCurrentPageTitle() : $tr('unknown');
|
|
$isHomepage = $this->api ? $this->api->isHomepage() : false;
|
|
$currentLang = $this->api ? $this->api->getCurrentLanguage() : 'nl';
|
|
$currentPath = $_GET['page'] ?? '';
|
|
$currentPath = preg_replace('/\.(md|php|html)$/', '', $currentPath);
|
|
|
|
$content = '
|
|
<p class="mb-2"><strong>' . htmlspecialchars($tr('current_page')) . ':</strong> ' . htmlspecialchars($currentPage) . '</p>
|
|
<p class="mb-2"><strong>' . htmlspecialchars($tr('language')) . ':</strong> ' . strtoupper($currentLang) . '</p>
|
|
<p class="mb-3"><strong>' . htmlspecialchars($tr('homepage')) . ':</strong> ' . htmlspecialchars($isHomepage ? $tr('yes') : $tr('no')) . '</p>';
|
|
|
|
// Add page-specific content
|
|
if ($this->api) {
|
|
$fileInfo = $this->api->getCurrentPageFileInfo();
|
|
if ($fileInfo) {
|
|
$content .= '
|
|
<div class="alert alert-info mb-3">
|
|
<small>
|
|
<strong>' . htmlspecialchars($tr('file_info')) . ':</strong><br>
|
|
' . htmlspecialchars($tr('created')) . ': ' . htmlspecialchars($fileInfo['created']) . '<br>
|
|
' . htmlspecialchars($tr('modified')) . ': ' . htmlspecialchars($fileInfo['modified']) . '
|
|
</small>
|
|
</div>';
|
|
}
|
|
|
|
// Add dynamic quick navigation
|
|
$menu = $this->api->getMenu();
|
|
if (!empty($menu)) {
|
|
$content .= '
|
|
<h6>' . htmlspecialchars($tr('quick_navigation')) . '</h6>
|
|
<ul class="list-unstyled mb-3">';
|
|
|
|
foreach ($menu as $item) {
|
|
if ($item['type'] === 'file') {
|
|
$url = '/' . $currentLang . '/' . $item['path'];
|
|
$isActive = ($item['path'] === $currentPath) ? ' fw-bold' : '';
|
|
$content .= '<li><a href="' . htmlspecialchars($url, ENT_QUOTES, 'UTF-8') . '" class="text-decoration-none' . $isActive . '"><i class="bi bi-file-earmark"></i> ' . htmlspecialchars($item['title'], ENT_QUOTES, 'UTF-8') . '</a></li>';
|
|
} elseif ($item['type'] === 'folder' && !empty($item['children'])) {
|
|
$url = '/' . $currentLang . '/' . $item['path'];
|
|
$isActive = strpos($currentPath, $item['path']) === 0 ? ' fw-bold' : '';
|
|
$content .= '<li><a href="' . htmlspecialchars($url, ENT_QUOTES, 'UTF-8') . '" class="text-decoration-none' . $isActive . '"><i class="bi bi-folder"></i> ' . htmlspecialchars($item['title'], ENT_QUOTES, 'UTF-8') . '</a></li>';
|
|
// Show children if current page is in this folder
|
|
if (strpos($currentPath, $item['path']) === 0) {
|
|
$content .= '<ul class="list-unstyled ms-3 mb-1">';
|
|
foreach ($item['children'] as $child) {
|
|
if ($child['type'] === 'file') {
|
|
$childUrl = '/' . $currentLang . '/' . $child['path'];
|
|
$childActive = ($child['path'] === $currentPath) ? ' fw-bold' : '';
|
|
$content .= '<li><a href="' . htmlspecialchars($childUrl, ENT_QUOTES, 'UTF-8') . '" class="text-decoration-none' . $childActive . '"><i class="bi bi-file-earmark"></i> ' . htmlspecialchars($child['title'], ENT_QUOTES, 'UTF-8') . '</a></li>';
|
|
}
|
|
}
|
|
$content .= '</ul>';
|
|
}
|
|
}
|
|
}
|
|
|
|
$content .= '</ul>';
|
|
}
|
|
}
|
|
|
|
return $content;
|
|
}
|
|
|
|
public function getConfig(): array
|
|
{
|
|
return $this->config;
|
|
}
|
|
|
|
public function setConfig(array $config): void
|
|
{
|
|
$this->config = array_merge($this->config, $config);
|
|
}
|
|
} |