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:
@@ -2,10 +2,23 @@
|
||||
|
||||
```
|
||||
codepress/
|
||||
├── cms/core/ # Core engine
|
||||
├── admin/ # Admin console
|
||||
├── themes/ # Thema's
|
||||
├── plugins/ # Plugins
|
||||
├── content/ # Content
|
||||
└── public/ # Web root
|
||||
├── cms/core/ # Core engine
|
||||
│ ├── class/ # CodePressCMS, ThemeManager, Logger, Analytics
|
||||
│ ├── plugin/ # PluginManager, CMSAPI, AdminPluginAPI
|
||||
│ ├── config.php # Config loader
|
||||
│ └── index.php # Bootstrap
|
||||
├── admin/ # Admin console
|
||||
│ ├── config/ # app.php, admin.json
|
||||
│ ├── src/ # AdminAuth
|
||||
│ └── theme/default/views/ # Twig templates
|
||||
├── themes/ # Thema's (default, demo, ...)
|
||||
├── plugins/ # Plugins (Dashboard, HTMLBlock, Navigation, ...)
|
||||
├── content/ # Content bestanden (.md, .php, .html)
|
||||
├── language/ # Taalbestanden (nl/, en/, de/)
|
||||
├── guide/ # Handleidingen (nl/, en/)
|
||||
├── public/ # Web root
|
||||
│ ├── index.php # Website entry point
|
||||
│ └── admin.php # Admin entry point + router
|
||||
├── config.json # Site configuratie
|
||||
└── version.php # Versie info
|
||||
```
|
||||
@@ -5,28 +5,62 @@
|
||||
Hoofd CMS class in `cms/core/class/CodePressCMS.php`:
|
||||
|
||||
```php
|
||||
$cms = new CodePressCMS();
|
||||
$cms->init();
|
||||
$cms = new CodePressCMS($config);
|
||||
$cms->renderPage($pagePath);
|
||||
```
|
||||
|
||||
Belangrijke methodes: `renderPage()`, `getMenu()`, `getPage()`, `parseMarkdown()`, `generateBreadcrumb()`, `getAvailableLanguages()`.
|
||||
|
||||
## ThemeManager.php
|
||||
|
||||
Themabeheer in `cms/core/class/ThemeManager.php`:
|
||||
|
||||
```php
|
||||
$themeManager = new ThemeManager($config);
|
||||
$themeManager->getActiveTheme();
|
||||
$themeManager->renderTwig($template, $data);
|
||||
$themeManager->compileCss($force);
|
||||
```
|
||||
|
||||
Compileert `assets/scss/theme.scss` runtime naar CSS en rendert Twig templates.
|
||||
|
||||
## PluginManager.php
|
||||
|
||||
Plugin systeem in `cms/core/class/PluginManager.php`:
|
||||
Plugin systeem in `cms/core/plugin/PluginManager.php`:
|
||||
|
||||
```php
|
||||
$pluginManager = new PluginManager();
|
||||
$pluginManager->loadPlugins($enabledPlugins);
|
||||
$pluginManager->executeHook($name, $params);
|
||||
```
|
||||
$pluginManager = new PluginManager($pluginsPath, $enabledPlugins);
|
||||
$pluginManager->setAPI($api);
|
||||
$pluginManager->doAction('onPageLoad', $args);
|
||||
$result = $pluginManager->applyFilters('onContentFilter', $content);
|
||||
$pluginManager->getAdminMenuItems();
|
||||
```
|
||||
|
||||
Belangrijke methodes: `setAPI()`, `doAction()`, `applyFilters()`, `getPlugin()`, `getAllPlugins()`, `getEnabledPlugins()`, `isEnabled()`, `getSidebarContent()`, `getPluginCssUrls()`, `getAdminMenuItems()`, `dispatchAdminRoute()`, `resolveAdminRoute()`.
|
||||
|
||||
## CMSAPI.php
|
||||
|
||||
Front-end API voor plugins in `cms/core/plugin/CMSAPI.php`. Implementeert `PluginAPIInterface`. Biedt toegang tot de CMS instance voor plugins in de front-end context.
|
||||
|
||||
```php
|
||||
$api->getCurrentPageTitle();
|
||||
$api->getMenu();
|
||||
$api->getConfig('site_title');
|
||||
$api->createUrl('over-ons');
|
||||
```
|
||||
|
||||
## AdminPluginAPI.php
|
||||
|
||||
Admin API voor plugins in `cms/core/plugin/AdminPluginAPI.php`. Implementeert `PluginAPIInterface`. Light-weight wrapper met alleen config-toegang (geen CMS instance nodig).
|
||||
|
||||
```php
|
||||
$api->getConfig('analytics.enabled');
|
||||
$api->getContentDir();
|
||||
$api->getEnabledPlugins();
|
||||
```
|
||||
|
||||
## AdminAuth.php
|
||||
|
||||
Authenticatie in `admin/src/AdminAuth.php`. Beheert sessies, bcrypt wachtwoorden, CSRF tokens, brute-force lockout en role-based permissions.
|
||||
|
||||
## LogManager.php
|
||||
|
||||
Logging systeem in `cms/core/class/LogManager.php`. Ondersteunt SQLite, syslog en file-based logging. Events: admin, requests, errors, security, content, system.
|
||||
@@ -4,9 +4,12 @@
|
||||
|
||||
```
|
||||
plugins/MijnPlugin/
|
||||
├── plugin.json # Plugin metadata
|
||||
├── plugin.php # Plugin code
|
||||
└── config.json # Optionele configuratie
|
||||
├── MijnPlugin.php # Hoofd plugin class (naam = mapnaam)
|
||||
├── plugin.json # Plugin metadata
|
||||
├── config.json # Optionele configuratie
|
||||
└── assets/ # Optionele CSS/JS
|
||||
├── css/
|
||||
└── scss/
|
||||
```
|
||||
|
||||
## plugin.json
|
||||
@@ -16,28 +19,128 @@ plugins/MijnPlugin/
|
||||
"name": "Mijn Plugin",
|
||||
"version": "1.0.0",
|
||||
"author": "Jouw Naam",
|
||||
"description": "Beschrijving"
|
||||
"description": "Beschrijving",
|
||||
"type": "content",
|
||||
"essential": false,
|
||||
"hasConfig": false
|
||||
}
|
||||
```
|
||||
|
||||
## plugin.php voorbeeld
|
||||
### Velden
|
||||
|
||||
| Veld | Waarde | Beschrijving |
|
||||
|------|--------|--------------|
|
||||
| `name` | string | Weergavenaam in admin |
|
||||
| `version` | string | Versienummer |
|
||||
| `author` | string | Auteur |
|
||||
| `description` | string | Korte beschrijving |
|
||||
| `type` | `"system"` of `"content"` | Systeem (blauwe badge) of content (groene badge) |
|
||||
| `essential` | boolean | Essentiële plugins kunnen niet worden bewerkt/verwijderd |
|
||||
| `hasConfig` | boolean | Toont een Config-knop in de admin |
|
||||
|
||||
## Plugin class voorbeeld
|
||||
|
||||
```php
|
||||
<?php
|
||||
/**
|
||||
* Plugin: MijnPlugin
|
||||
*/
|
||||
|
||||
echo '<div class="mijn-plugin">Hello World</div>';
|
||||
class MijnPlugin
|
||||
{
|
||||
private ?PluginAPIInterface $api = null;
|
||||
|
||||
public function setAPI(PluginAPIInterface $api): void
|
||||
{
|
||||
$this->api = $api;
|
||||
}
|
||||
|
||||
public function getConfig(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Mijn Plugin',
|
||||
'type' => 'content',
|
||||
'viewable' => true,
|
||||
];
|
||||
}
|
||||
|
||||
public function getSidebarContent(): string
|
||||
{
|
||||
$title = $this->api ? $this->api->getCurrentPageTitle() : '';
|
||||
return '<p>Huidige pagina: ' . htmlspecialchars($title) . '</p>';
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
De plugin class wordt automatisch geladen door `PluginManager` als de plugin in `enabled_plugins` staat in `config.json`.
|
||||
|
||||
## CMSAPI gebruiken
|
||||
|
||||
```php
|
||||
<?php
|
||||
require_once '../../cms/core/class/PluginManager.php';
|
||||
De API wordt geïnjecteerd via `setAPI()`, niet via een statische methode. In de front-end context is dit een `CMSAPI` instance, in de admin context een `AdminPluginAPI` instance. Beide implementeren `PluginAPIInterface`.
|
||||
|
||||
$api = PluginManager::getAPI();
|
||||
$config = $api->getConfig();
|
||||
$content = $api->getContent();
|
||||
```php
|
||||
// Front-end API (CMSAPI)
|
||||
$this->api->getCurrentPageTitle();
|
||||
$this->api->getMenu();
|
||||
$this->api->getConfig('site_title');
|
||||
$this->api->getCurrentLanguage();
|
||||
$this->api->isHomepage();
|
||||
$this->api->createUrl('over-ons');
|
||||
|
||||
// Admin API (AdminPluginAPI)
|
||||
$this->api->getConfig('analytics.enabled');
|
||||
$this->api->getContentDir();
|
||||
$this->api->getEnabledPlugins();
|
||||
```
|
||||
|
||||
## Hooks
|
||||
|
||||
Plugins kunnen de volgende methodes implementeren voor automatiche hook-registratie:
|
||||
|
||||
**Actions** (geen return waarde):
|
||||
|
||||
- `onPageLoad` - Bij laden van een pagina
|
||||
- `onBeforeRender` - Voor het renderen
|
||||
- `onAfterRender` - Na het renderen
|
||||
- `onSearch` - Bij zoeken
|
||||
- `onMenuBuild` - Bij opbouwen menu
|
||||
|
||||
**Filters** (return aangepaste waarde):
|
||||
|
||||
- `onContentFilter` - Content filteren
|
||||
- `onTitleFilter` - Titel filteren
|
||||
- `onMenuFilter` - Menu filteren
|
||||
|
||||
## Admin integratie
|
||||
|
||||
Plugins kunnen eigen admin-pagina's toevoegen via `getAdminMenu()` en `handleAdminRoute()`:
|
||||
|
||||
```php
|
||||
public function getAdminMenu(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
'plugin' => 'MijnPlugin',
|
||||
'route' => 'mijn-plugin',
|
||||
'label' => 'Mijn Plugin',
|
||||
'icon' => 'bi-puzzle',
|
||||
'section' => 'general', // of 'system'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function handleAdminRoute(string $action): ?string
|
||||
{
|
||||
return '<h2>Mijn Plugin admin pagina</h2>';
|
||||
}
|
||||
```
|
||||
|
||||
Alleen plugins die in `enabled_plugins` staan worden in de admin sidebar getoond.
|
||||
|
||||
## CSS toevoegen
|
||||
|
||||
Plugins kunnen een CSS-URL leveren via `getCssUrl()`:
|
||||
|
||||
```php
|
||||
public function getCssUrl(): string
|
||||
{
|
||||
return '/plugins/MijnPlugin/assets/css/style.css';
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user