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:
@@ -11,5 +11,7 @@ De admin beheerder handleiding bevat de volgende onderwerpen:
|
||||
- **Gebruikers** - Gebruikers toevoegen en verwijderen
|
||||
- **Statistieken** - Bezoekersstatistieken bekijken
|
||||
- **Logs** - Logbestanden bekijken en filteren
|
||||
- **Media** - Media bestanden beheren
|
||||
- **Update** - Controleren op updates
|
||||
|
||||
Selecteer een onderwerp uit de navigatie aan de linkerkant.
|
||||
@@ -3,7 +3,13 @@
|
||||
## Algemene instellingen
|
||||
|
||||
- **Site titel** - Naam van de website
|
||||
- **Standaard taal** - nl/en/de/fr
|
||||
- **Auteur** - Naam en e-mail
|
||||
- **Analytics** - Bezoekers tracking aan/uit
|
||||
- **Logging** - Logbestanden aan/uit
|
||||
- **Admin taal** - Taal van het admin-paneel (nl/en/de)
|
||||
- **Content taal** - Standaardtaal van de website-content (nl/en/de/fr)
|
||||
|
||||
## Homepage
|
||||
|
||||
Kies welke pagina getoond wordt op de homepage:
|
||||
|
||||
- **Automatisch** - Eerste beschikbare pagina
|
||||
- **Meest recent** - Laatst aangepaste pagina
|
||||
- **Specifieke pagina** - Kies een specifieke pagina uit de content-map
|
||||
@@ -1,15 +1,30 @@
|
||||
# Plugins
|
||||
|
||||
## Plugin types
|
||||
|
||||
Er zijn twee soorten plugins:
|
||||
|
||||
- **Systeem plugins** (blauwe badge) - Beheren CMS-functionaliteit zoals Dashboard, Logs en Statistieken
|
||||
- **Content plugins** (groene badge) - Tonen content in de front-end zoals HTMLBlock en Navigation
|
||||
|
||||
## Essentiële plugins
|
||||
|
||||
Essentiële plugins (met een schild-icoon) kunnen niet worden bewerkt, gedeactiveerd of verwijderd. Dit geldt bijvoorbeeld voor de Navigation plugin.
|
||||
|
||||
## Plugins beheren
|
||||
|
||||
- **Activeren/Deactiveren** - Plugins aan/uit
|
||||
- **Bewerken** - Plugin code aanpassen
|
||||
- **Configuratie** - Plugin instellingen
|
||||
- **Configuratie** - Plugin instellingen (alleen bij plugins met een Config-knop)
|
||||
- **Verwijderen** - Plugin verwijderen
|
||||
|
||||
Alleen actieve plugins worden getoond in de admin sidebar.
|
||||
|
||||
## Nieuwe plugin
|
||||
|
||||
1. Ga naar **Plugins** → **Nieuwe plugin**
|
||||
2. Geef naam op (bijv. `MijnPlugin`)
|
||||
3. Bewerk `plugin.php`
|
||||
4. Activeer de plugin
|
||||
3. Bewerk het PHP-bestand
|
||||
4. Activeer de plugin
|
||||
|
||||
Nieuwe plugins zijn standaard content-plugins. Wil je een systeem-plugin maken, voeg dan `"type": "system"` toe aan `plugin.json`.
|
||||
@@ -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';
|
||||
}
|
||||
```
|
||||
@@ -16,12 +16,17 @@ Content...
|
||||
|
||||
```json
|
||||
{
|
||||
"default_layout": "full_content",
|
||||
"layouts": {
|
||||
"config": {
|
||||
"default_template": "full_content"
|
||||
},
|
||||
"template": {
|
||||
"full_content": "full_content.twig",
|
||||
"left_sidebar": "left_sidebar.twig",
|
||||
"right_sidebar": "right_sidebar.twig",
|
||||
"custom1": "custom1.twig"
|
||||
"custom1": "custom1.twig",
|
||||
"guide": "guide.twig"
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
Onbekende layouts in frontmatter vallen terug op `config.default_template`.
|
||||
@@ -22,4 +22,5 @@ Maak basis bestanden:
|
||||
- `full_content.twig`
|
||||
- `partials/header.twig`
|
||||
- `partials/footer.twig`
|
||||
- `scss/theme.scss`
|
||||
- `scss/theme.scss`
|
||||
- `guide.twig` (indien handleidingen ondersteund moeten worden)
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
1. Ga naar **Admin** → **Thema**
|
||||
2. Klik **SCSS compileren** bij jouw thema
|
||||
3. CSS wordt gegenereerd in `assets/css/theme.css`
|
||||
3. CSS wordt gegenereerd in `assets/css_compiled/theme.css`
|
||||
|
||||
## SCSS voorbeeld
|
||||
|
||||
|
||||
@@ -3,19 +3,23 @@
|
||||
```json
|
||||
{
|
||||
"title": "Mijn Thema",
|
||||
"default_layout": "full_content",
|
||||
"header_color": "#0a369d",
|
||||
"layouts": {
|
||||
"config": {
|
||||
"default_template": "full_content"
|
||||
},
|
||||
"template": {
|
||||
"full_content": "full_content.twig",
|
||||
"left_sidebar": "left_sidebar.twig",
|
||||
"right_sidebar": "right_sidebar.twig"
|
||||
}
|
||||
"right_sidebar": "right_sidebar.twig",
|
||||
"custom1": "custom1.twig",
|
||||
"guide": "guide.twig"
|
||||
},
|
||||
"header_color": "#0a369d"
|
||||
}
|
||||
```
|
||||
|
||||
## Velden
|
||||
|
||||
- `title` - Weergavenaam in admin
|
||||
- `default_layout` - Standaard layout voor nieuwe pagina's
|
||||
- `header_color` - Kleur admin sidebar
|
||||
- `layouts` - Mapping van layout namen naar .twig bestanden
|
||||
- `config.default_template` - Standaard layout voor nieuwe pagina's
|
||||
- `template` - Mapping van layout namen naar .twig bestanden
|
||||
- `header_color` - (optioneel) Kleur admin sidebar, standaard `#0a369d`
|
||||
Reference in New Issue
Block a user