v2.6.0: Content backup/git versioning, plugin type system, docs update
New features: - ContentBackup class with ZIP backup/restore and git versioning - Admin backup & restore page (content-backup.twig) with git init/commit/log/restore - Plugin type system: system (blue) vs content (green) with visual badges - PluginAPIInterface + AdminPluginAPI for plugin architecture - Essential plugin flag (cannot edit/deactivate/delete) Improvements: - Consolidated enabled_plugins config (removed plugins.enabled) - Removed Analytics/Logging toggles from admin config page - Fixed Dashboard plugin Twig comments rendered as text - Updated 20 guide files (NL+EN): configuratie, plugins, plugin-development, core-classes, theme-json, layouts, scss-styling, admin-beheerder, nieuw-thema, architectuur - Improved accessibility test script (grep -E, min/max checks) Cleanup: - Removed unused classes: ARIAComponents, AccessibilityManager, ContentSecurityPolicy, etc. - Removed vendor packages: mustache/mustache, php-mqtt/client - Removed old templates: logs.twig, statistics.twig (now plugins) - Moved language files to language/ directory Tests: - Pentest: 30/30 passed, 0 vulnerabilities - WCAG 2.1 AA: 25/25 passed, 100% compliance
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
class Statistics
|
||||
{
|
||||
private ?PluginAPIInterface $api = null;
|
||||
|
||||
public function setAPI(PluginAPIInterface $api): void
|
||||
{
|
||||
$this->api = $api;
|
||||
}
|
||||
|
||||
public function getConfig(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Statistics',
|
||||
'viewable' => false,
|
||||
'type' => 'system',
|
||||
];
|
||||
}
|
||||
|
||||
public function getAdminMenu(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'plugin' => 'Statistics',
|
||||
'route' => 'statistics',
|
||||
'label' => 'Statistieken',
|
||||
'icon' => 'bi-bar-chart',
|
||||
'section' => 'general',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function handleAdminRoute(string $action): ?string
|
||||
{
|
||||
$analytics = $this->getAnalytics();
|
||||
if ($analytics === null) {
|
||||
return '<div class="alert alert-warning">Analytics is uitgeschakeld.</div>';
|
||||
}
|
||||
|
||||
$stats = $analytics->getStats();
|
||||
$totals = $stats['totals'] ?? ['views' => 0, 'uniques' => 0, 'pages' => []];
|
||||
$countries = $stats['countries'] ?? [];
|
||||
$topPages = $stats['top_pages'] ?? $totals['pages'] ?? [];
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<h2 class="mb-4"><i class="bi bi-bar-chart"></i> Statistieken</h2>
|
||||
|
||||
<div class="row g-4 mb-4">
|
||||
<div class="col-md-4">
|
||||
<div class="card stat-card shadow-sm">
|
||||
<div class="card-body d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<h6 class="text-muted mb-1">Totaal aantal views</h6>
|
||||
<h3 class="mb-0"><?= number_format($totals['views'] ?? 0, 0, ',', '.') ?></h3>
|
||||
</div>
|
||||
<i class="bi bi-eye stat-icon text-primary"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card stat-card shadow-sm">
|
||||
<div class="card-body d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<h6 class="text-muted mb-1">Unieke bezoekers</h6>
|
||||
<h3 class="mb-0"><?= number_format($totals['uniques'] ?? 0, 0, ',', '.') ?></h3>
|
||||
</div>
|
||||
<i class="bi bi-people stat-icon text-success"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="card stat-card shadow-sm">
|
||||
<div class="card-body d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<h6 class="text-muted mb-1">Pagina views</h6>
|
||||
<h3 class="mb-0"><?= number_format($totals['page_views'] ?? ($totals['views'] ?? 0), 0, ',', '.') ?></h3>
|
||||
</div>
|
||||
<i class="bi bi-file-earmark-text stat-icon text-info"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-4">
|
||||
<div class="col-md-6">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header"><i class="bi bi-globe"></i> Landen</div>
|
||||
<div class="card-body">
|
||||
<?php if (empty($countries)): ?>
|
||||
<p class="text-muted mb-0">Geen data</p>
|
||||
<?php else: ?>
|
||||
<table class="table table-sm mb-0">
|
||||
<thead><tr><th>Land</th><th>Views</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($countries as $country => $count): ?>
|
||||
<tr>
|
||||
<td><?= GeoIP::getCountryFlagEmoji($country) ?> <?= htmlspecialchars(GeoIP::getCountryName($country)) ?></td>
|
||||
<td><?= number_format($count, 0, ',', '.') ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header"><i class="bi bi-file-earmark-bar"></i> Top pagina's</div>
|
||||
<div class="card-body">
|
||||
<?php if (empty($topPages)): ?>
|
||||
<p class="text-muted mb-0">Geen data</p>
|
||||
<?php else: ?>
|
||||
<table class="table table-sm mb-0">
|
||||
<thead><tr><th>Pagina</th><th>Views</th></tr></thead>
|
||||
<tbody>
|
||||
<?php foreach ($topPages as $page => $count): ?>
|
||||
<tr>
|
||||
<td><?= htmlspecialchars($page) ?></td>
|
||||
<td><?= number_format($count, 0, ',', '.') ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
private function getAnalytics(): ?Analytics
|
||||
{
|
||||
if ($this->api === null) {
|
||||
return null;
|
||||
}
|
||||
$analyticsConfig = $this->api->getConfig('analytics', []);
|
||||
if (!is_array($analyticsConfig) || empty($analyticsConfig['enabled'])) {
|
||||
return null;
|
||||
}
|
||||
return new Analytics($analyticsConfig);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "Statistics",
|
||||
"version": "1.0.0",
|
||||
"author": "CodePress",
|
||||
"description": "Bezoekersstatistieken: totaal aantal views, unieke bezoekers, landen en top pagina's.",
|
||||
"type": "system",
|
||||
"essential": false,
|
||||
"hasConfig": true
|
||||
}
|
||||
Reference in New Issue
Block a user