Security: verwijder hardcoded wachtwoord, voeg random-wachtwoord-generator toe bij eerste installatie
This commit is contained in:
@@ -1,14 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Dashboard plugin: toont CMS-, content- en plugin-overzicht in het beheer.
|
||||
*
|
||||
* Systeem-plugin die een overzichtspagina biedt met site-informatie,
|
||||
* content-statistieken en een lijst van geïnstalleerde plugins.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*/
|
||||
class Dashboard
|
||||
{
|
||||
/**
|
||||
* Plugin-API instantie voor communicatie met de CMS-core.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @var PluginAPIInterface|null
|
||||
*/
|
||||
private ?PluginAPIInterface $api = null;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Geeft de plugin-configuratie terug.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<string, mixed> Plugin-configuratie met title, viewable en type.
|
||||
*/
|
||||
public function getConfig(): array
|
||||
{
|
||||
return [
|
||||
@@ -18,6 +45,12 @@ class Dashboard
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Geeft de admin-menu-items voor deze plugin.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<int, array<string, mixed>> Lijst met admin-menu-item configuraties.
|
||||
*/
|
||||
public function getAdminMenu(): array
|
||||
{
|
||||
return [
|
||||
@@ -33,6 +66,16 @@ class Dashboard
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Verwerkt een admin-route en toont het dashboard.
|
||||
*
|
||||
* Geeft een HTML-weergave van site-informatie, content-statistieken
|
||||
* en een plugin-overzicht.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $action De uit te voeren actie.
|
||||
* @return string|null De HTML-uitvoer van het dashboard, of null.
|
||||
*/
|
||||
public function handleAdminRoute(string $action): ?string
|
||||
{
|
||||
$siteConfig = $this->getSiteConfig();
|
||||
@@ -147,6 +190,12 @@ class Dashboard
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Haalt de site-configuratie op via de AdminPluginAPI.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<string, mixed> De site-configuratie, of een lege array.
|
||||
*/
|
||||
private function getSiteConfig(): array
|
||||
{
|
||||
if ($this->api === null) {
|
||||
@@ -159,6 +208,14 @@ class Dashboard
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Bepaalt het type (system of content) van een plugin door het hoofdbestand te lezen.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $pluginDir Pad naar de plugin-map.
|
||||
* @param string $pluginName Naam van de plugin.
|
||||
* @return string Het plugin-type ('system' of 'content').
|
||||
*/
|
||||
private function getPluginType(string $pluginDir, string $pluginName): string
|
||||
{
|
||||
$pluginFile = $pluginDir . '/' . $pluginName . '.php';
|
||||
@@ -173,6 +230,16 @@ class Dashboard
|
||||
return 'content';
|
||||
}
|
||||
|
||||
/**
|
||||
* Telt het aantal bestanden in een map, eventueel gefilterd op extensie.
|
||||
*
|
||||
* Slaat verborgen en met '-' voorafgegane bestanden en mappen over.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $dir Pad naar de map die doorzocht moet worden.
|
||||
* @param string[] $extensions Optionele lijst van toegestane extensies.
|
||||
* @return int Het aantal gevonden bestanden.
|
||||
*/
|
||||
private function countFiles(string $dir, array $extensions = []): int
|
||||
{
|
||||
if (!is_dir($dir)) return 0;
|
||||
@@ -197,6 +264,15 @@ class Dashboard
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Telt het aantal submappen in een map, recursief.
|
||||
*
|
||||
* Slaat verborgen en met '-' voorafgegane mappen over.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $dir Pad naar de map die doorzocht moet worden.
|
||||
* @return int Het aantal gevonden submappen.
|
||||
*/
|
||||
private function countDirs(string $dir): int
|
||||
{
|
||||
if (!is_dir($dir)) return 0;
|
||||
@@ -215,6 +291,13 @@ class Dashboard
|
||||
return $count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Berekent de totale bestandsgrootte in bytes van alle bestanden in een map.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $dir Pad naar de map die doorzocht moet worden.
|
||||
* @return int De totale grootte in bytes.
|
||||
*/
|
||||
private function dirSize(string $dir): int
|
||||
{
|
||||
if (!is_dir($dir)) return 0;
|
||||
@@ -230,6 +313,13 @@ class Dashboard
|
||||
return $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formateert een byte-grootte naar een leesbare string met eenheid.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param int $bytes Het aantal bytes.
|
||||
* @return string De geformatteerde grootte met eenheid (bijv. '1.5 MB').
|
||||
*/
|
||||
private function formatSize(int $bytes): string
|
||||
{
|
||||
if ($bytes <= 0) return '0 B';
|
||||
|
||||
@@ -1,14 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* GeoIPInfo plugin: toont geografische informatie op basis van IP-adres.
|
||||
*
|
||||
* Systeem-plugin die een admin-pagina biedt met het IP-adres van de bezoeker
|
||||
* en het bijbehorende land via de GeoIP-dienst.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*/
|
||||
class GeoIPInfo
|
||||
{
|
||||
/**
|
||||
* Plugin-API instantie voor communicatie met de CMS-core.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @var PluginAPIInterface|null
|
||||
*/
|
||||
private ?PluginAPIInterface $api = null;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Geeft de plugin-configuratie terug.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<string, mixed> Plugin-configuratie met title en type.
|
||||
*/
|
||||
public function getConfig(): array
|
||||
{
|
||||
return [
|
||||
@@ -18,7 +45,10 @@ class GeoIPInfo
|
||||
}
|
||||
|
||||
/**
|
||||
* Register admin menu items.
|
||||
* Geeft de admin-menu-items voor deze plugin terug.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<int, array<string, mixed>> Lijst met admin-menu-item configuraties.
|
||||
*/
|
||||
public function getAdminMenu(): array
|
||||
{
|
||||
@@ -34,7 +64,10 @@ class GeoIPInfo
|
||||
}
|
||||
|
||||
/**
|
||||
* Register admin routes this plugin handles.
|
||||
* Geeft de admin-routes terug die deze plugin afhandelt.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<int, string> Lijst met admin-route namen.
|
||||
*/
|
||||
public function getAdminRoutes(): array
|
||||
{
|
||||
@@ -42,7 +75,13 @@ class GeoIPInfo
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle admin route — render the admin page.
|
||||
* Verwerkt een admin-route en toont de GeoIP-info-pagina.
|
||||
*
|
||||
* Bepaalt het IP-adres van de bezoeker en toont het land en de vlag.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $route De af te handelen admin-route.
|
||||
* @return void
|
||||
*/
|
||||
public function handleAdminRoute(string $route): void
|
||||
{
|
||||
|
||||
@@ -1,10 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* HTMLBlock plugin: toont context-afhankelijke HTML-blokken in de zijbalk.
|
||||
*
|
||||
* Content-plugin die informatie over de huidige pagina toont,
|
||||
* inclusief taal, homepage-status, bestandsinformatie en snelle navigatie.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*/
|
||||
class HTMLBlock
|
||||
{
|
||||
/**
|
||||
* Plugin-configuratie.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
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 = [
|
||||
@@ -13,11 +39,27 @@ class HTMLBlock
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -89,11 +131,24 @@ class HTMLBlock
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Geeft de plugin-configuratie terug.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<string, mixed> 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<string, mixed> $config De configuratie die samengevoegd moet worden.
|
||||
* @return void
|
||||
*/
|
||||
public function setConfig(array $config): void
|
||||
{
|
||||
$this->config = array_merge($this->config, $config);
|
||||
|
||||
+50
-2
@@ -1,14 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Logs plugin: toont admin- en request-logs in het beheer.
|
||||
*
|
||||
* Systeem-plugin die logbestanden uitleest en in een tabel toont,
|
||||
* met tabbladen voor admin-logs en request-logs.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*/
|
||||
class Logs
|
||||
{
|
||||
/**
|
||||
* Plugin-API instantie voor communicatie met de CMS-core.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @var PluginAPIInterface|null
|
||||
*/
|
||||
private ?PluginAPIInterface $api = null;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Geeft de plugin-configuratie terug.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<string, mixed> Plugin-configuratie met title, viewable en type.
|
||||
*/
|
||||
public function getConfig(): array
|
||||
{
|
||||
return [
|
||||
@@ -18,6 +45,12 @@ class Logs
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Geeft de admin-menu-items voor deze plugin terug.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<int, array<string, mixed>> Lijst met admin-menu-item configuraties.
|
||||
*/
|
||||
public function getAdminMenu(): array
|
||||
{
|
||||
$config = $this->getPluginConfig();
|
||||
@@ -38,7 +71,12 @@ class Logs
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this plugin's runtime config (defaults + overrides).
|
||||
* Haalt de runtime-configuratie van deze plugin op (standaardwaarden plus overrides).
|
||||
*
|
||||
* Leest standaardwaarden uit plugin.json en overschrijft deze met config.json.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<string, mixed> De samengevoegde plugin-configuratie.
|
||||
*/
|
||||
private function getPluginConfig(): array
|
||||
{
|
||||
@@ -64,6 +102,16 @@ class Logs
|
||||
return array_merge($defaults, $overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verwerkt een admin-route en toont de logs-pagina.
|
||||
*
|
||||
* Leest de geselecteerde log, parset de regels en toont deze in een tabel
|
||||
* met tabbladen voor admin- en request-logs.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $action De uit te voeren actie.
|
||||
* @return string|null De HTML-uitvoer van de logs-pagina, of null.
|
||||
*/
|
||||
public function handleAdminRoute(string $action): ?string
|
||||
{
|
||||
$config = $this->getPluginConfig();
|
||||
@@ -78,7 +126,7 @@ class Logs
|
||||
};
|
||||
|
||||
$tab = $_GET['tab'] ?? 'admin';
|
||||
$logDir = dirname(__DIR__, 2) . '/admin/storage/logs';
|
||||
$logDir = ($this->api ? $this->api->getProjectRoot() : dirname(__DIR__, 2)) . '/admin/storage/logs';
|
||||
$logFile = $tab === 'requests' ? $logDir . '/requests.log' : $logDir . '/admin.log';
|
||||
|
||||
$logs = [];
|
||||
|
||||
@@ -1,10 +1,36 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Navigation plugin: bouwt zijbalk-navigatie voor content en guide.
|
||||
*
|
||||
* Content-plugin die de navigatie opbouwt op basis van de mappenstructuur,
|
||||
* met ondersteuning voor guide-pagina's en reguliere content-pagina's.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*/
|
||||
class Navigation
|
||||
{
|
||||
/**
|
||||
* Plugin-configuratie.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
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 = [
|
||||
@@ -14,23 +40,46 @@ class Navigation
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Geeft de plugin-configuratie terug.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<string, mixed> 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<string, mixed> $config De configuratie die samengevoegd moet worden.
|
||||
* @return void
|
||||
*/
|
||||
public function setConfig(array $config): void
|
||||
{
|
||||
$this->config = array_merge($this->config, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path to this plugin's CSS file (relative to web root).
|
||||
* Geeft het pad naar het CSS-bestand van deze plugin (relatief ten opzichte van de webroot).
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return string Het CSS-URL-pad.
|
||||
*/
|
||||
public function getCssUrl(): string
|
||||
{
|
||||
@@ -38,8 +87,13 @@ class Navigation
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate sidebar navigation.
|
||||
* Detects whether we're on a guide page or content page and builds nav accordingly.
|
||||
* Genereert de zijbalk-navigatie.
|
||||
*
|
||||
* Detecteert of het om een guide-pagina of een content-pagina gaat en
|
||||
* bouwt de navigatie dienovereenkomstig op.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return string De HTML-navigatie, of een lege string in admin-context.
|
||||
*/
|
||||
public function getSidebarContent(): string
|
||||
{
|
||||
@@ -61,11 +115,17 @@ class Navigation
|
||||
}
|
||||
|
||||
/**
|
||||
* Build navigation for the guide section.
|
||||
* Bouwt de navigatie voor de guide-sectie.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $lang De huidige taalcode.
|
||||
* @param string $currentPage De huidige pagina-pad.
|
||||
* @param bool $isAdmin Of dit in admin-context is.
|
||||
* @return string De opgebouwde HTML-navigatie, of een lege string.
|
||||
*/
|
||||
private function buildGuideNav(string $lang, string $currentPage, bool $isAdmin): string
|
||||
{
|
||||
$guideRoot = dirname(__DIR__, 2) . '/guide/' . $lang;
|
||||
$guideRoot = ($this->api ? $this->api->getProjectRoot() : dirname(__DIR__, 2)) . '/guide/' . $lang;
|
||||
if (!is_dir($guideRoot)) {
|
||||
return '';
|
||||
}
|
||||
@@ -79,11 +139,16 @@ class Navigation
|
||||
}
|
||||
|
||||
/**
|
||||
* Build navigation for the content section.
|
||||
* Bouwt de navigatie voor de content-sectie.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $lang De huidige taalcode.
|
||||
* @param string $currentPage De huidige pagina-pad.
|
||||
* @return string De opgebouwde HTML-navigatie, of een lege string.
|
||||
*/
|
||||
private function buildContentNav(string $lang, string $currentPage): string
|
||||
{
|
||||
$contentRoot = dirname(__DIR__, 2) . '/content';
|
||||
$contentRoot = $this->api ? $this->api->getContentDir() : dirname(__DIR__, 2) . '/content';
|
||||
if (!is_dir($contentRoot)) {
|
||||
return '';
|
||||
}
|
||||
@@ -95,15 +160,17 @@ class Navigation
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively build navigation from a directory structure.
|
||||
* Bouwt recursief navigatie op vanuit een mapstructuur.
|
||||
*
|
||||
* @param string $dir Current directory
|
||||
* @param string $relPath Relative path from root
|
||||
* @param string $currentPage Current page path
|
||||
* @param bool $isAdmin Whether this is admin context
|
||||
* @param string $mode 'guide' or 'content'
|
||||
* @param string $lang Current language
|
||||
* @param int $depth Nesting depth (0 = top level)
|
||||
* @since 2.6.4
|
||||
* @param string $dir Huidige map.
|
||||
* @param string $relPath Relatief pad vanaf de root.
|
||||
* @param string $currentPage Huidige pagina-pad.
|
||||
* @param bool $isAdmin Of dit in admin-context is.
|
||||
* @param string $mode Modus: 'guide' of 'content'.
|
||||
* @param string $lang Huidige taalcode.
|
||||
* @param int $depth Nesting-diepte (0 = topniveau). Standaard 0.
|
||||
* @return string De opgebouwde HTML-navigatie.
|
||||
*/
|
||||
private function buildNav(string $dir, string $relPath, string $currentPage, bool $isAdmin, string $mode, string $lang, int $depth = 0): string
|
||||
{
|
||||
@@ -188,7 +255,14 @@ class Navigation
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the URL for a page.
|
||||
* Bouwt de URL voor een pagina-referentie.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $pageRef De pagina-referentie.
|
||||
* @param string $lang De huidige taalcode.
|
||||
* @param bool $isAdmin Of dit in admin-context is.
|
||||
* @param string $mode Modus: 'guide' of 'content'.
|
||||
* @return string De opgebouwde URL.
|
||||
*/
|
||||
private function buildUrl(string $pageRef, string $lang, bool $isAdmin, string $mode): string
|
||||
{
|
||||
@@ -203,7 +277,13 @@ class Navigation
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a nav item is the current page.
|
||||
* Controleert of een navigatie-item de huidige pagina is.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $pageRef De pagina-referentie van het item.
|
||||
* @param string $currentPage Het huidige pagina-pad.
|
||||
* @param string $mode Modus: 'guide' of 'content'.
|
||||
* @return bool True als het item actief is, anders false.
|
||||
*/
|
||||
private function isActive(string $pageRef, string $currentPage, string $mode): bool
|
||||
{
|
||||
@@ -215,7 +295,10 @@ class Navigation
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available language codes.
|
||||
* Geeft de beschikbare taalcodes terug.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<int, string> Lijst met taalcodes.
|
||||
*/
|
||||
private function getLanguageCodes(): array
|
||||
{
|
||||
@@ -223,7 +306,11 @@ class Navigation
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a slug into a readable title.
|
||||
* Formateert een slug naar een leesbare titel.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $slug De te formatteren slug.
|
||||
* @return string De geformatteerde titel.
|
||||
*/
|
||||
private function formatTitle(string $slug): string
|
||||
{
|
||||
@@ -233,8 +320,13 @@ class Navigation
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the H1 title from a markdown/PHP/HTML file.
|
||||
* Falls back to formatTitle() if no H1 is found.
|
||||
* Haalt de H1-titel uit een markdown-, PHP- of HTML-bestand.
|
||||
*
|
||||
* Valt terug op formatTitle() wanneer geen H1 gevonden is.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $filePath Pad naar het bestand.
|
||||
* @return string De gevonden titel, of een lege string.
|
||||
*/
|
||||
private function getTitleFromFile(string $filePath): string
|
||||
{
|
||||
@@ -253,10 +345,12 @@ class Navigation
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the navigation items as HTML.
|
||||
* Rendert de navigatie-items als HTML.
|
||||
*
|
||||
* @param array $items Navigation items
|
||||
* @param int $depth Nesting depth (0 = top level)
|
||||
* @since 2.6.4
|
||||
* @param array $items Navigatie-items.
|
||||
* @param int $depth Nesting-diepte (0 = topniveau). Standaard 0.
|
||||
* @return string De gegenereerde HTML.
|
||||
*/
|
||||
private function renderNav(array $items, int $depth = 0): string
|
||||
{
|
||||
|
||||
@@ -1,14 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Statistics plugin: toont analytics-statistieken in het beheer.
|
||||
*
|
||||
* Systeem-plugin die analytics-gegevens toont, zoals totaal aantal views,
|
||||
* unieke bezoekers, landen en top-pagina's.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*/
|
||||
class Statistics
|
||||
{
|
||||
/**
|
||||
* Plugin-API instantie voor communicatie met de CMS-core.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @var PluginAPIInterface|null
|
||||
*/
|
||||
private ?PluginAPIInterface $api = null;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Geeft de plugin-configuratie terug.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<string, mixed> Plugin-configuratie met title, viewable en type.
|
||||
*/
|
||||
public function getConfig(): array
|
||||
{
|
||||
return [
|
||||
@@ -18,6 +45,12 @@ class Statistics
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Geeft de admin-menu-items voor deze plugin terug.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<int, array<string, mixed>> Lijst met admin-menu-item configuraties.
|
||||
*/
|
||||
public function getAdminMenu(): array
|
||||
{
|
||||
$config = $this->getPluginConfig();
|
||||
@@ -38,7 +71,12 @@ class Statistics
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this plugin's runtime config (defaults + overrides).
|
||||
* Haalt de runtime-configuratie van deze plugin op (standaardwaarden plus overrides).
|
||||
*
|
||||
* Leest standaardwaarden uit plugin.json en overschrijft deze met config.json.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return array<string, mixed> De samengevoegde plugin-configuratie.
|
||||
*/
|
||||
private function getPluginConfig(): array
|
||||
{
|
||||
@@ -64,6 +102,16 @@ class Statistics
|
||||
return array_merge($defaults, $overrides);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verwerkt een admin-route en toont de statistieken-pagina.
|
||||
*
|
||||
* Toont analytics-gegevens zoals views, unieke bezoekers, landen en
|
||||
* top-pagina's, mits analytics ingeschakeld is.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @param string $action De uit te voeren actie.
|
||||
* @return string|null De HTML-uitvoer van de statistieken-pagina, of null.
|
||||
*/
|
||||
public function handleAdminRoute(string $action): ?string
|
||||
{
|
||||
// System plugin: translations resolve against the admin language.
|
||||
@@ -182,6 +230,12 @@ class Statistics
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Haalt de Analytics-instantie op basis van de analytics-configuratie.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @return Analytics|null De Analytics-instantie, of null als analytics uitgeschakeld is.
|
||||
*/
|
||||
private function getAnalytics(): ?Analytics
|
||||
{
|
||||
if ($this->api === null) {
|
||||
|
||||
Reference in New Issue
Block a user