*/ private array $config; /** * Plugin-API instantie voor communicatie met de CMS-core. * * @since 2.6.4 * @var PluginAPIInterface|null */ private ?PluginAPIInterface $api = null; /** * Initialiseert de plugin met standaardconfiguratie. * * @since 2.6.4 */ public function __construct() { $this->config = [ 'title' => 'HTML Block Plugin', 'type' => 'content', ]; } /** * Stelt de Plugin-API instantie in. * * @since 2.6.4 * @param PluginAPIInterface $api De Plugin-API instantie. * @return void */ public function setAPI(PluginAPIInterface $api): void { $this->api = $api; } /** * Genereert de HTML-inhoud voor de zijbalk. * * Toont informatie over de huidige pagina, taal, homepage-status, * bestandsinformatie en een snelle navigatielijst. * * @since 2.6.4 * @return string De opgebouwde HTML voor de zijbalk. */ 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 = '

' . htmlspecialchars($tr('current_page')) . ': ' . htmlspecialchars($currentPage) . '

' . htmlspecialchars($tr('language')) . ': ' . strtoupper($currentLang) . '

' . htmlspecialchars($tr('homepage')) . ': ' . htmlspecialchars($isHomepage ? $tr('yes') : $tr('no')) . '

'; // Add page-specific content if ($this->api) { $fileInfo = $this->api->getCurrentPageFileInfo(); if ($fileInfo) { $content .= '
' . htmlspecialchars($tr('file_info')) . ':
' . htmlspecialchars($tr('created')) . ': ' . htmlspecialchars($fileInfo['created']) . '
' . htmlspecialchars($tr('modified')) . ': ' . htmlspecialchars($fileInfo['modified']) . '
'; } // Add dynamic quick navigation $menu = $this->api->getMenu(); if (!empty($menu)) { $content .= '
' . htmlspecialchars($tr('quick_navigation')) . '
'; } } return $content; } /** * Geeft de plugin-configuratie terug. * * @since 2.6.4 * @return array Plugin-configuratie. */ public function getConfig(): array { return $this->config; } /** * Stelt de plugin-configuratie in door deze te mergen met standaardwaarden. * * @since 2.6.4 * @param array $config De configuratie die samengevoegd moet worden. * @return void */ public function setConfig(array $config): void { $this->config = array_merge($this->config, $config); } }