Merge development v2.6.0 into main
Resolved conflicts by taking development (v2.6.0) version for all files. Removed statistics.twig (replaced by Statistics plugin).
This commit is contained in:
@@ -11,5 +11,7 @@ De admin beheerder handleiding bevat de volgende onderwerpen:
|
||||
- **Gebruikers** - Gebruikersbeheer met rollen (Admin, Content Beheerder, BI Beheerder, Site Admin)
|
||||
- **Statistieken** - Bezoekersstatistieken bekijken en exporteren
|
||||
- **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
|
||||
@@ -2,48 +2,29 @@
|
||||
|
||||
## Plugin types
|
||||
|
||||
CodePress kent twee soorten plugins, bepaald door het `type` veld in `plugin.json`:
|
||||
Er zijn twee soorten plugins:
|
||||
|
||||
- **Content plugins** (`type: "content"`) — Verschijnen in de sidebar en in de plugin selectie op content-edit pagina's. Bieden sidebar content via `getSidebarContent()`.
|
||||
- **Systeem plugins** (`type: "system"`) — Worden geladen door PluginManager maar verschijnen NIET in de sidebar. Bieden functionaliteit via admin menu, routes en de CMSAPI. Geregistreerd via `getAdminMenu()` en `getAdminRoutes()`.
|
||||
|
||||
Bij afwezigheid van een `type` veld wordt `content` aangenomen.
|
||||
- **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 zijn gedefinieerd in `getProtectedPlugins()` in `public/admin.php`. Huidige essentiële plugin: **Navigation**.
|
||||
|
||||
Deze plugins:
|
||||
- Kunnen NIET worden gedeactiveerd
|
||||
- Kunnen NIET worden bewerkt
|
||||
- Kunnen NIET worden verwijderd
|
||||
|
||||
Op de plugins pagina krijgen ze een **Essentieel** badge i.p.v. de actieknoppen.
|
||||
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** — Plugin aan/uit zetten (niet voor essentiële plugins)
|
||||
- **Bewerken** — Plugin code aanpassen in CodeMirror (niet voor essentiële plugins)
|
||||
- **Configuratie** — Plugin instellingen bewerken
|
||||
- **Verwijderen** — Plugin map verwijderen (niet voor essentiële plugins)
|
||||
- **Activeren/Deactiveren** - Plugins aan/uit
|
||||
- **Bewerken** - Plugin code aanpassen
|
||||
- **Configuratie** - Plugin instellingen (alleen bij plugins met een Config-knop)
|
||||
- **Verwijderen** - Plugin verwijderen
|
||||
|
||||
De admin plugins pagina toont een **Content** of **Systeem** badge per plugin.
|
||||
Alleen actieve plugins worden getoond in de admin sidebar.
|
||||
|
||||
## Nieuwe plugin aanmaken
|
||||
## Nieuwe plugin
|
||||
|
||||
1. Ga naar **Plugins** → **Nieuwe plugin**
|
||||
2. Geef naam op (bijv. `MijnPlugin`) — dit wordt de mapnaam
|
||||
3. Kies het type: **Content** of **Systeem**
|
||||
4. Het bestand `MijnPlugin.php` wordt aangemaakt (NIET `plugin.php`)
|
||||
5. Bewerk de plugin code in CodeMirror
|
||||
6. Activeer de plugin
|
||||
2. Geef naam op (bijv. `MijnPlugin`)
|
||||
3. Bewerk het PHP-bestand
|
||||
4. Activeer de plugin
|
||||
|
||||
## Plugin bestandsnaam
|
||||
|
||||
Plugin PHP bestanden heten `<PluginName>.php` (bijv. `Navigation.php`, `HTMLBlock.php`). `PluginManager` laadt `$pluginDir . '/' . $pluginName . '.php'`.
|
||||
|
||||
## Plugin CSS
|
||||
|
||||
- Content en systeem plugins kunnen eigen CSS hebben in `assets/scss/` en `assets/css/`
|
||||
- Plugin CSS wordt automatisch geladen ná theme CSS (in `base.twig`), zodat thema's plugin styling kunnen overschrijven
|
||||
- Plugin assets worden geserveerd via `cms/router.php` op URL `/plugins/<Name>/assets/...`
|
||||
Nieuwe plugins zijn standaard content-plugins. Wil je een systeem-plugin maken, voeg dan `"type": "system"` toe aan `plugin.json`.
|
||||
@@ -1,84 +1,24 @@
|
||||
# CMS Architectuur
|
||||
|
||||
CodePress is een file-based CMS zonder database. Content, configuratie en gebruikers worden opgeslagen in bestanden.
|
||||
|
||||
## Mappenstructuur
|
||||
|
||||
```
|
||||
codepress/
|
||||
├── cms/ # Core CMS engine
|
||||
│ ├── core/
|
||||
│ │ ├── class/
|
||||
│ │ │ ├── CodePressCMS.php # Hoofd CMS class (routing, rendering, breadcrumb)
|
||||
│ │ │ ├── ThemeManager.php # Thema-resolver + Twig render + SCSS compile
|
||||
│ │ │ ├── ContentAPI.php # Read-only API voor PHP content
|
||||
│ │ │ ├── ContentSecurityPolicy.php # CSP header management
|
||||
│ │ │ ├── Analytics.php # Bezoekersstatistieken
|
||||
│ │ │ ├── BotGuard.php # Bot/AI detectie
|
||||
│ │ │ ├── Cache.php # Cache systeem
|
||||
│ │ │ ├── GeoIP.php # GeoIP lookup (land, vlag)
|
||||
│ │ │ ├── Logger.php # Basis logging
|
||||
│ │ │ ├── LogManager.php # Dynamisch logging (SQLite/syslog)
|
||||
│ │ │ ├── RateLimiter.php # Rate limiting per IP
|
||||
│ │ │ ├── RequestLogger.php # Request logging + visitor info
|
||||
│ │ │ ├── SearchEngine.php # Volledige tekst zoekfunctie
|
||||
│ │ │ └── AccessibilityManager.php # Accessibility features
|
||||
│ │ ├── plugin/
|
||||
│ │ │ ├── PluginManager.php # Plugin loader (hooks, filters, sidebar, admin routes)
|
||||
│ │ │ └── CMSAPI.php # API voor plugins (getPage, getConfig, etc.)
|
||||
│ │ ├── config.php # Config loader (leest config.json)
|
||||
│ │ └── index.php # Bootstrap (autoloader, requires)
|
||||
│ ├── lang/ # Taalbestanden (nl.php, en.php)
|
||||
│ └── router.php # PHP dev server router
|
||||
├── themes/ # Dynamische thema's
|
||||
│ └── default/ # Standaard thema (views + assets)
|
||||
│ ├── theme.json # { title, config.default_template, template: layout→.twig }
|
||||
│ ├── base.twig # Hoofd layout
|
||||
│ ├── *.twig # Layout templates
|
||||
│ ├── partials/ # header.twig, navigation.twig, footer.twig
|
||||
│ └── assets/
|
||||
│ ├── scss/theme.scss # SCSS bron (enige CSS bron)
|
||||
│ ├── css_compiled/ # Gegenereerd door scssphp (read-only)
|
||||
│ ├── css/ # Externe CSS (bootstrap.min.css, etc.)
|
||||
│ ├── js/ # JavaScript
|
||||
│ └── img/ # Afbeeldingen
|
||||
├── admin/ # Admin paneel
|
||||
│ ├── config/
|
||||
│ │ ├── app.php # Admin app configuratie
|
||||
│ │ └── admin.json # Gebruikers & security (file-based, .gitignore'd)
|
||||
│ ├── src/
|
||||
│ │ └── AdminAuth.php # Authenticatie + RBAC
|
||||
│ ├── theme/default/ # Admin thema (views + assets)
|
||||
│ │ ├── theme.json
|
||||
│ │ ├── assets/ # CSS, JS, CodeMirror, fonts
|
||||
│ │ └── views/ # login.twig, layouts/, pages/
|
||||
│ └── storage/ # Logs, cache, geoip
|
||||
├── plugins/ # CMS plugins
|
||||
│ ├── Navigation/ # Essentiële navigatie plugin (beschermd)
|
||||
│ │ ├── Navigation.php # Plugin code (NIET plugin.php)
|
||||
│ │ ├── plugin.json # Metadata met type veld
|
||||
│ │ └── assets/ # SCSS + CSS
|
||||
│ └── HTMLBlock/ # Voorbeeld sidebar plugin
|
||||
├── content/ # Website content (.md, .php, .html) — .gitignore'd
|
||||
├── guide/ # Handleidingen (nl/en)
|
||||
├── public/ # Web root
|
||||
│ ├── index.php # Website entry point
|
||||
│ ├── admin.php # Admin entry point + routing
|
||||
│ ├── asset.php # Asset server voor Apache (themes/, admin/assets/, plugins/)
|
||||
│ ├── .htaccess # Stuurt asset URLs door naar asset.php
|
||||
│ ├── favicon.ico
|
||||
│ └── robots.txt
|
||||
├── var/ # Cache (twig) — .gitignore'd
|
||||
├── config.json # Site configuratie — .gitignore'd
|
||||
├── composer.json # PHP dependencies (CommonMark, Twig, scssphp)
|
||||
└── version.php # Versie informatie (2.5.2)
|
||||
```
|
||||
|
||||
## Principes
|
||||
|
||||
- **Geen database** — Alles in bestanden (content in `content/`, gebruikers in `admin/config/admin.json`, config in `config.json`)
|
||||
- **File-based auth** — `AdminAuth` gebruikt bcrypt hashes in `admin.json`, sessies voor login
|
||||
- **Twig templating** — Themes gebruiken Twig; `ThemeManager` rendert via Twig
|
||||
- **SCSS compilatie** — `assets/scss/theme.scss` → `assets/css_compiled/theme.css` via scssphp (read-only output)
|
||||
- **Plugin systeem** — `PluginManager` laadt content en systeem plugins met hooks/filters
|
||||
- **Asset serving** — PHP dev router (`cms/router.php`) of Apache (`.htaccess` → `public/asset.php`)
|
||||
├── 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,17 +5,11 @@
|
||||
Hoofd CMS class in `cms/core/class/CodePressCMS.php`:
|
||||
|
||||
```php
|
||||
$cms = new CodePressCMS();
|
||||
$cms->init();
|
||||
$cms = new CodePressCMS($config);
|
||||
$cms->renderPage($pagePath);
|
||||
```
|
||||
|
||||
Verantwoordelijkheden:
|
||||
- Routing en pagina rendering
|
||||
- Breadcrumb generatie (dynamisch: Home > [submappen] > [pagina])
|
||||
- Guide pagina's laden (`getGuidePage()`)
|
||||
- Titel extractie uit H1 (`getTitleFromFile()`)
|
||||
- Weergavenaam verwerking (`formatDisplayName()`)
|
||||
Belangrijke methodes: `renderPage()`, `getMenu()`, `getPage()`, `parseMarkdown()`, `generateBreadcrumb()`, `getAvailableLanguages()`.
|
||||
|
||||
## ThemeManager.php
|
||||
|
||||
@@ -23,20 +17,10 @@ Themabeheer in `cms/core/class/ThemeManager.php`:
|
||||
|
||||
```php
|
||||
$themeManager = new ThemeManager($config);
|
||||
$themeManager->getActiveTheme();
|
||||
$themeManager->renderTwig($template, $data);
|
||||
$themeManager->compileCss($force);
|
||||
$themeManager->getCssUrl();
|
||||
```
|
||||
|
||||
Verantwoordelijkheden:
|
||||
- Actief thema resolveren vanuit `config.json`
|
||||
- `theme.json` laden (title, config.default_template, template mapping)
|
||||
- Twig environment bouwen (geroot in thema map)
|
||||
- **SCSS compilatie** — compileert `assets/scss/theme.scss` naar `assets/css_compiled/theme.css` via scssphp
|
||||
- Layout resolveren naar `.twig` template (fallback op `config.default_template`)
|
||||
|
||||
`getCssUrl()` prioriteit: 1) `assets/css/theme.css` (handmatig), 2) `assets/css_compiled/theme.css` (gecompileerd).
|
||||
Compileert `assets/scss/theme.scss` runtime naar CSS en rendert Twig templates.
|
||||
|
||||
## PluginManager.php
|
||||
|
||||
@@ -44,66 +28,39 @@ Plugin systeem in `cms/core/plugin/PluginManager.php`:
|
||||
|
||||
```php
|
||||
$pluginManager = new PluginManager($pluginsPath, $enabledPlugins);
|
||||
$pluginManager->getSidebarContent($allowedPlugins);
|
||||
$pluginManager->getPluginCssUrls();
|
||||
$pluginManager->executeHook($name, $params);
|
||||
$pluginManager->setAPI($api);
|
||||
$pluginManager->doAction('onPageLoad', $args);
|
||||
$result = $pluginManager->applyFilters('onContentFilter', $content);
|
||||
$pluginManager->getAdminMenuItems();
|
||||
$pluginManager->handleAdminRoute($route);
|
||||
$pluginManager->getPluginType($pluginName);
|
||||
```
|
||||
|
||||
Verantwoordelijkheden:
|
||||
- Plugins laden vanuit `plugins/` mappen (alleen ingeschakelde plugins)
|
||||
- Plugin bestand: `<PluginName>.php` (NIET `plugin.php`)
|
||||
- Hooks en filters systeem (`doAction`, `applyFilters`)
|
||||
- Sidebar content verzamelen van content plugins (`getSidebarContent`)
|
||||
- Plugin CSS URLs verzamelen (`getPluginCssUrls`)
|
||||
- **Admin menu items** van systeem plugins (`getAdminMenuItems`)
|
||||
- **Admin routes** afhandelen via systeem plugins (`handleAdminRoute`)
|
||||
- **Plugin type** bepalen (`getPluginType` — `content` of `system`)
|
||||
- `isPluginViewable` — systeem plugins verschijnen niet in sidebar
|
||||
|
||||
## AdminAuth.php
|
||||
|
||||
Authenticatie en RBAC in `admin/src/AdminAuth.php`:
|
||||
|
||||
```php
|
||||
$auth = new AdminAuth($appConfig);
|
||||
$auth->login($username, $password);
|
||||
$auth->logout();
|
||||
$auth->hasPermission($route);
|
||||
$auth->verifyCsrf($token);
|
||||
```
|
||||
|
||||
Constanten:
|
||||
- `ROLE_PERMISSIONS` — Mapping van rol → toegestane route prefixes. `admin` heeft wildcard `*`.
|
||||
- `ROLE_LABELS` — Human-readable labels per rol.
|
||||
|
||||
Rollen:
|
||||
|
||||
| Rol | Label | Permissies |
|
||||
|-----|-------|-----------|
|
||||
| `admin` | Admin | Alles (`*`) |
|
||||
| `content-manager` | Content Beheerder | Content beheer, handleiding |
|
||||
| `bi-manager` | BI Beheerder | Statistieken, logs, handleiding |
|
||||
| `site-admin` | Site Admin | Thema, plugins, statistieken, logs, update, handleiding |
|
||||
|
||||
Verantwoordelijkheden:
|
||||
- Session-based authenticatie
|
||||
- bcrypt password hashing
|
||||
- CSRF tokens (`verifyCsrf`)
|
||||
- Brute-force lockout (login attempts tracking)
|
||||
- RBAC via `hasPermission($route)` — checkt route tegen `ROLE_PERMISSIONS`
|
||||
Belangrijke methodes: `setAPI()`, `doAction()`, `applyFilters()`, `getPlugin()`, `getAllPlugins()`, `getEnabledPlugins()`, `isEnabled()`, `getSidebarContent()`, `getPluginCssUrls()`, `getAdminMenuItems()`, `dispatchAdminRoute()`, `resolveAdminRoute()`.
|
||||
|
||||
## CMSAPI.php
|
||||
|
||||
Plugin API in `cms/core/plugin/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 = PluginManager::getAPI();
|
||||
$config = $api->getConfig();
|
||||
$page = $api->getPage($path);
|
||||
$content = $api->getContent();
|
||||
$api->getCurrentPageTitle();
|
||||
$api->getMenu();
|
||||
$api->getConfig('site_title');
|
||||
$api->createUrl('over-ons');
|
||||
```
|
||||
|
||||
Biedt read-only toegang aan plugins tot CMS data (config, pagina's, content).
|
||||
## 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.
|
||||
@@ -1,144 +1,146 @@
|
||||
# Plugin Development
|
||||
|
||||
## Plugin types
|
||||
|
||||
CodePress kent twee soorten plugins, bepaald door het `type` veld in `plugin.json`:
|
||||
|
||||
- **Content plugins** (`type: "content"`) — Verschijnen in de sidebar en in de plugin selectie op content-edit pagina's. Bieden sidebar content via `getSidebarContent()`.
|
||||
- **Systeem plugins** (`type: "system"`) — Worden geladen door PluginManager maar verschijnen NIET in de sidebar. Bieden functionaliteit via admin menu, routes en de CMSAPI.
|
||||
|
||||
Bij afwezigheid van een `type` veld wordt `content` aangenomen.
|
||||
|
||||
## Plugin structuur
|
||||
|
||||
```
|
||||
plugins/MijnPlugin/
|
||||
├── MijnPlugin.php # Plugin code (NIET plugin.php)
|
||||
├── plugin.json # Metadata met type veld
|
||||
├── config.json # Optionele configuratie
|
||||
└── assets/
|
||||
├── scss/mijnplugin.scss # SCSS bron (optioneel)
|
||||
└── css/mijnplugin.css # CSS (handmatig onderhouden)
|
||||
├── MijnPlugin.php # Hoofd plugin class (naam = mapnaam)
|
||||
├── plugin.json # Plugin metadata
|
||||
├── config.json # Optionele configuratie
|
||||
└── assets/ # Optionele CSS/JS
|
||||
├── css/
|
||||
└── scss/
|
||||
```
|
||||
|
||||
Plugin bestanden heten `<PluginName>.php` (bijv. `Navigation.php`, `HTMLBlock.php`). `PluginManager` laadt `$pluginDir . '/' . $pluginName . '.php'`.
|
||||
|
||||
## plugin.json
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Mijn Plugin",
|
||||
"version": "1.0.0",
|
||||
"author": "Jouw Naam",
|
||||
"description": "Beschrijving",
|
||||
"type": "content"
|
||||
"name": "Mijn Plugin",
|
||||
"version": "1.0.0",
|
||||
"author": "Jouw Naam",
|
||||
"description": "Beschrijving",
|
||||
"type": "content",
|
||||
"essential": false,
|
||||
"hasConfig": false
|
||||
}
|
||||
```
|
||||
|
||||
- `name` — Weergavenaam
|
||||
- `type` — `"content"` of `"system"` (default: `content`)
|
||||
### Velden
|
||||
|
||||
## Content plugin voorbeeld
|
||||
| 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 (content)
|
||||
*/
|
||||
|
||||
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
|
||||
{
|
||||
return '<p>Hello World</p>';
|
||||
$title = $this->api ? $this->api->getCurrentPageTitle() : '';
|
||||
return '<p>Huidige pagina: ' . htmlspecialchars($title) . '</p>';
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Systeem plugin voorbeeld
|
||||
|
||||
```php
|
||||
<?php
|
||||
/**
|
||||
* Plugin: MijnSysteem (system)
|
||||
*/
|
||||
class MijnSysteem
|
||||
{
|
||||
public function getConfig(): array
|
||||
{
|
||||
return [
|
||||
'title' => 'Mijn Systeem',
|
||||
'type' => 'system',
|
||||
];
|
||||
}
|
||||
|
||||
public function getAdminMenu(): array
|
||||
{
|
||||
return [
|
||||
['label' => 'Mijn Systeem', 'route' => 'mijn-systeem', 'icon' => 'bi-gear'],
|
||||
];
|
||||
}
|
||||
|
||||
public function getAdminRoutes(): array
|
||||
{
|
||||
return ['mijn-systeem'];
|
||||
}
|
||||
|
||||
public function handleAdminRoute(string $route): void
|
||||
{
|
||||
echo '<h1>Mijn Systeem pagina</h1>';
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Systeem plugins worden via `PluginManager::getAdminMenuItems()` in de admin sidebar getoond en via `PluginManager::handleAdminRoute()` afgehandeld.
|
||||
De plugin class wordt automatisch geladen door `PluginManager` als de plugin in `enabled_plugins` staat in `config.json`.
|
||||
|
||||
## CMSAPI gebruiken
|
||||
|
||||
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`.
|
||||
|
||||
```php
|
||||
<?php
|
||||
$api = PluginManager::getAPI();
|
||||
$config = $api->getConfig();
|
||||
$page = $api->getPage($path);
|
||||
// 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();
|
||||
```
|
||||
|
||||
`setAPI()` wordt automatisch aangeroepen door `PluginManager` als de plugin de methode heeft.
|
||||
## Hooks
|
||||
|
||||
## Plugin CSS
|
||||
Plugins kunnen de volgende methodes implementeren voor automatiche hook-registratie:
|
||||
|
||||
- Plugin CSS in `assets/css/` is handmatig te onderhouden (SCSS compilatie voor plugins is nog niet automatisch)
|
||||
- Plugin CSS wordt automatisch geladen ná theme CSS (in `base.twig`), zodat thema's plugin styling kunnen overschrijven
|
||||
- Plugin assets worden geserveerd via `cms/router.php` op URL `/plugins/<Name>/assets/...`
|
||||
- Implementeer `getCssUrl()` in de plugin klasse om de CSS URL terug te geven
|
||||
**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/mijnplugin.css';
|
||||
return '/plugins/MijnPlugin/assets/css/style.css';
|
||||
}
|
||||
```
|
||||
|
||||
## Hooks en filters
|
||||
|
||||
PluginManager auto-registert deze methoden als hooks/filters:
|
||||
|
||||
- **Hooks**: `onPageLoad`, `onBeforeRender`, `onAfterRender`, `onSearch`, `onMenuBuild`
|
||||
- **Filters**: `onContentFilter`, `onTitleFilter`, `onMenuFilter`
|
||||
|
||||
```php
|
||||
public function onPageLoad($page) { /* ... */ }
|
||||
public function onContentFilter($content) { return $content; }
|
||||
```
|
||||
|
||||
## Essentiële plugins
|
||||
|
||||
Essentiële plugins zijn gedefinieerd in `getProtectedPlugins()` in `public/admin.php`. Huidige essentiële plugin: **Navigation**.
|
||||
|
||||
Deze plugins kunnen niet worden gedeactiveerd, bewerkt of verwijderd. Voeg altijd de `isProtectedPlugin()` check toe aan nieuwe plugin handlers.
|
||||
```
|
||||
@@ -1,7 +1,5 @@
|
||||
# Layouts
|
||||
|
||||
Layouts definiëren de pagina structuur (sidebar links, volledige breedte, etc.). Layouts worden gedefinieerd in `theme.json` en gekozen via frontmatter in content bestanden.
|
||||
|
||||
## Layout kiezen in content
|
||||
|
||||
```markdown
|
||||
@@ -16,58 +14,19 @@ Content...
|
||||
|
||||
## Layouts in theme.json
|
||||
|
||||
Layouts worden gedefinieerd in de `template` mapping. De `config.default_template` is de fallback voor pagina's zonder `layout:` frontmatter of met een onbekende layout:
|
||||
|
||||
```json
|
||||
{
|
||||
"config": {
|
||||
"default_template": "full_content"
|
||||
},
|
||||
"template": {
|
||||
"full_content": "full_content.twig",
|
||||
"left_sidebar": "left_sidebar.twig",
|
||||
"right_sidebar": "right_sidebar.twig",
|
||||
"custom1": "custom1.twig",
|
||||
"guide": "guide.twig"
|
||||
}
|
||||
"config": {
|
||||
"default_template": "full_content"
|
||||
},
|
||||
"template": {
|
||||
"full_content": "full_content.twig",
|
||||
"left_sidebar": "left_sidebar.twig",
|
||||
"right_sidebar": "right_sidebar.twig",
|
||||
"custom1": "custom1.twig",
|
||||
"guide": "guide.twig"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Layout template
|
||||
|
||||
Een layout template extends `base.twig` en vult het `content` block:
|
||||
|
||||
```twig
|
||||
{% extends 'base.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
{{ content|raw }}
|
||||
</div>
|
||||
{% endblock %}
|
||||
```
|
||||
|
||||
## Layouts met sidebar
|
||||
|
||||
Layouts met sidebar kunnen plugin content tonen:
|
||||
|
||||
```twig
|
||||
{% extends 'base.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<main class="col-md-8">
|
||||
{{ content|raw }}
|
||||
</main>
|
||||
<aside class="col-md-4">
|
||||
{{ sidebar_content|raw }}
|
||||
</aside>
|
||||
</div>
|
||||
{% endblock %}
|
||||
```
|
||||
|
||||
Als een pagina geen plugins heeft of de layout geen sidebar bevat, is `sidebar_content` leeg.
|
||||
|
||||
## Guide layout
|
||||
|
||||
De `guide` layout (`guide.twig`) is speciaal voor handleidingen. Het injecteert de Navigation plugin in de sidebar voor zijbalk navigatie. Wordt automatisch gebruikt voor pagina's in de `guide/` map.
|
||||
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
|
||||
|
||||
|
||||
@@ -2,45 +2,24 @@
|
||||
|
||||
```json
|
||||
{
|
||||
"title": "Mijn Thema",
|
||||
"config": {
|
||||
"default_template": "full_content"
|
||||
},
|
||||
"template": {
|
||||
"full_content": "full_content.twig",
|
||||
"left_sidebar": "left_sidebar.twig",
|
||||
"right_sidebar": "right_sidebar.twig",
|
||||
"custom1": "custom1.twig",
|
||||
"guide": "guide.twig"
|
||||
}
|
||||
"title": "Mijn Thema",
|
||||
"config": {
|
||||
"default_template": "full_content"
|
||||
},
|
||||
"template": {
|
||||
"full_content": "full_content.twig",
|
||||
"left_sidebar": "left_sidebar.twig",
|
||||
"right_sidebar": "right_sidebar.twig",
|
||||
"custom1": "custom1.twig",
|
||||
"guide": "guide.twig"
|
||||
},
|
||||
"header_color": "#0a369d"
|
||||
}
|
||||
```
|
||||
|
||||
## Velden
|
||||
|
||||
- `title` — Weergavenaam in admin
|
||||
- `config.default_template` — Standaard layout voor pagina's zonder `layout:` frontmatter (fallback bij onbekende layouts)
|
||||
- `template` — Mapping van layout naam naar `.twig` bestand
|
||||
|
||||
## Template mapping
|
||||
|
||||
De `template` mapping definieert welke layouts beschikbaar zijn. Elke key is een layout naam, elke value is het `.twig` bestand:
|
||||
|
||||
| Layout naam | Twig bestand | Beschrijving |
|
||||
|-------------|--------------|--------------|
|
||||
| `full_content` | `full_content.twig` | Volledige breedte, geen sidebar |
|
||||
| `left_sidebar` | `left_sidebar.twig` | Sidebar links |
|
||||
| `right_sidebar` | `right_sidebar.twig` | Sidebar rechts |
|
||||
| `custom1` | `custom1.twig` | Custom layout |
|
||||
| `guide` | `guide.twig` | Handleiding met sidebar (Navigation plugin) |
|
||||
|
||||
## Layout keuze
|
||||
|
||||
- Layouts worden gekozen via frontmatter `layout:` key in content bestanden
|
||||
- Onbekende layouts vallen terug op `config.default_template`
|
||||
- `ThemeManager::getTemplates()` geeft de template mapping terug
|
||||
- `ThemeManager::getConfig()` geeft de config sectie terug (inclusief `default_template`)
|
||||
|
||||
## Guide layout
|
||||
|
||||
De `guide` layout is speciaal voor handleidingen. `getGuidePage()` in `CodePressCMS.php` injecteert automatisch de Navigation plugin in de metadata voor zijbalk navigatie.
|
||||
- `title` - Weergavenaam in admin
|
||||
- `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