v2.6.1d (Lyra): Plugin i18n, plugin editor vernieuwd, media invoegen
Plugin internationalisatie: plugins hebben eigen language/ mappen. Systeem plugins volgen admin taal (admin.php), content plugins volgen content taal (site.php). Fallback chain: geselecteerd -> plugin default_language -> CMS default. PluginManager/AdminPluginAPI/CMSAPI uitgebreid met getPluginTranslations()/t(). plugin.json settings ondersteunen label_key/help_key/option_label_key. Plugin uniformiteit: alle 6 plugins hebben uniforme structuur (README.md, assets/.gitkeep, language/nl|en/). plugins/README.md herschreven. guide plugin-development.md (NL+EN) volledig herschreven. Plugin editor vernieuwd: geneste bestandsbrowser zijbalk, nieuw bestand aanmaken, uploaden naar assets/, verwijderen en verplaatsen. Nieuwe routes: plugins-file-upload, plugins-file-delete, plugins-file-move. Path-traversal bescherming + protected plugins geblokkeerd. Media invoegen in editor: nieuw /admin/media-list JSON endpoint + herbruikbare _media-modal.twig include. Plugin-context scant assets/ map. editor-toolbar.js modeMap uitgebreid voor css/scss/js/json. Plugin overzicht knoppen: alleen iconen met title/aria-label. Tests: pentest 30/30, WCAG 2.1 AA 25/25.
This commit is contained in:
+76
-79
@@ -1,102 +1,99 @@
|
||||
# CodePress CMS Plugins
|
||||
|
||||
Deze map bevat plugins voor de CodePress CMS. Elke plugin heeft zijn eigen submap met de plugin code.
|
||||
Deze map bevat alle plugins voor de CodePress CMS. Elke plugin heeft zijn eigen submap.
|
||||
|
||||
## Plugin Structuur
|
||||
## Plugin overzicht
|
||||
|
||||
Elke plugin map moet het volgende bevatten:
|
||||
| Plugin | Type | Essentieel | Beschrijving |
|
||||
|--------|------|------------|--------------|
|
||||
| Dashboard | system | ja | Site informatie, content statistieken en plugin overzicht op het dashboard |
|
||||
| GeoIPInfo | system | nee | GeoIP-informatie (IP adres en land) in admin |
|
||||
| HTMLBlock | content | nee | Custom HTML-blok in de sidebar van content-pagina's |
|
||||
| Logs | system | nee | Admin activiteitlogs en front-end request logs met filter tabs |
|
||||
| Navigation | content | ja | Navigatie voor handleidingen en content (beschermd) |
|
||||
| Statistics | system | nee | Bezoekersstatistieken: views, unieke bezoekers, landen, top pagina's |
|
||||
|
||||
Elke plugin heeft een eigen `README.md` met specifieke documentatie.
|
||||
|
||||
## Plugin structuur (uniform)
|
||||
|
||||
Elke plugin-map heeft de volgende structuur:
|
||||
|
||||
```
|
||||
PluginName/
|
||||
├── PluginName.php # Hoofd plugin bestand
|
||||
├── README.md # Plugin documentatie (optioneel)
|
||||
├── config.json # Plugin configuratie (optioneel)
|
||||
└── assets/ # CSS, JS, images (optioneel)
|
||||
├── css/
|
||||
├── js/
|
||||
└── images/
|
||||
├── PluginName.php # Hoofd plugin class (naam = mapnaam)
|
||||
├── plugin.json # Plugin metadata + instellingen-schema
|
||||
├── README.md # Plugin documentatie
|
||||
├── config.json # Optionele runtime configuratie (overschrijft defaults)
|
||||
├── assets/ # Optionele CSS/JS/SCSS (.gitkeep als leeg)
|
||||
│ ├── css/
|
||||
│ └── scss/
|
||||
└── language/ # Vertalingen
|
||||
├── nl/
|
||||
│ ├── admin.php # Admin labels (systeem plugins)
|
||||
│ └── site.php # Front-end labels (content plugins)
|
||||
└── en/
|
||||
├── admin.php
|
||||
└── site.php
|
||||
```
|
||||
|
||||
## Beschikbare Plugins
|
||||
## plugin.json velden
|
||||
|
||||
### HTMLBlock
|
||||
Toont een custom HTML blok in de sidebar met pagina-informatie en navigatie.
|
||||
| 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 admin |
|
||||
| `default_language` | string | Fallback taal voor plugin-vertalingen (bijv. `nl`) |
|
||||
| `settings` | array | Instellingen-schema (zie hieronder) |
|
||||
|
||||
**Locatie:** `HTMLBlock/HTMLBlock.php`
|
||||
### Instellingen-schema
|
||||
|
||||
**Functies:**
|
||||
- Toont huidige pagina informatie
|
||||
- Dynamische navigatie
|
||||
- Bestandsinformatie
|
||||
- Interactive controls
|
||||
Elke instelling in `settings` ondersteunt:
|
||||
|
||||
## Plugin Development
|
||||
| Veld | Beschrijving |
|
||||
|------|--------------|
|
||||
| `key` | Instelling-sleutel (opgeslagen in `config.json`) |
|
||||
| `type` | `text`, `checkbox`, `number`, `select`, `multi-select` |
|
||||
| `default` | Standaardwaarde |
|
||||
| `label` | Hardcoded label (fallback als geen `label_key`) |
|
||||
| `help` | Hardcoded help-tekst (fallback als geen `help_key`) |
|
||||
| `label_key` | Sleutel in plugin `language/<lang>/admin.php` voor vertaald label |
|
||||
| `help_key` | Sleutel in plugin `language/<lang>/admin.php` voor vertaalde help-tekst |
|
||||
| `option_label_key` | Sleutel naar een array met optie-labels voor `select`/`multi-select` |
|
||||
| `options` | Opties voor `select`/`multi-select` (`{waarde: label}`) |
|
||||
|
||||
### Basis Plugin Class
|
||||
## Taal support
|
||||
|
||||
```php
|
||||
<?php
|
||||
- **Systeem plugins** volgen de geselecteerde **admin taal** (uit `config.admin_language`).
|
||||
- **Content plugins** volgen de geselecteerde **content taal** (uit de URL of `config.language.default`).
|
||||
|
||||
class MyPlugin
|
||||
{
|
||||
private ?CMSAPI $api = null;
|
||||
|
||||
public function setAPI(CMSAPI $api): void
|
||||
{
|
||||
$this->api = $api;
|
||||
}
|
||||
|
||||
public function getSidebarContent(): string
|
||||
{
|
||||
return '<div>Mijn plugin content</div>';
|
||||
}
|
||||
}
|
||||
```
|
||||
Fallback chain voor plugin-vertalingen:
|
||||
1. Geselecteerde taal (`language/<lang>/admin.php` of `site.php`)
|
||||
2. Plugin `default_language` (`plugin.json`)
|
||||
3. CMS `language.default`
|
||||
4. Lege array (sleutel wordt ongewijzigd getoond)
|
||||
|
||||
### Beschikbare API Methodes
|
||||
Plugins halen hun vertalingen op via de API:
|
||||
- Systeem plugins: `$this->api->getPluginTranslations('PluginName')` (AdminPluginAPI)
|
||||
- Content plugins: `$this->api->getPluginTranslations('PluginName')` (CMSAPI)
|
||||
|
||||
- `getCurrentPage()` - Huidige pagina data
|
||||
- `getCurrentPageTitle()` - Huidige pagina titel
|
||||
- `getMenu()` - Menu structuur
|
||||
- `getConfig($key)` - Configuratie waardes
|
||||
- `translate($key)` - Vertalingen
|
||||
- `getCurrentLanguage()` - Huidige taal
|
||||
- `isHomepage()` - Check of homepage
|
||||
- `getCurrentPageFileInfo()` - Bestandsinformatie
|
||||
- `createUrl($page, $lang)` - URL generatie
|
||||
## Uitgebreide documentatie
|
||||
|
||||
### Plugin Hooks
|
||||
Zie de handleiding voor uitgebreide plugin development documentatie:
|
||||
|
||||
Plugins kunnen de volgende methodes implementeren:
|
||||
|
||||
- `getSidebarContent()` - Content voor sidebar
|
||||
- `setAPI(CMSAPI $api)` - API injectie
|
||||
|
||||
## Configuratie
|
||||
|
||||
Plugins kunnen een `config.json` bestand hebben:
|
||||
|
||||
```json
|
||||
{
|
||||
"enabled": true,
|
||||
"settings": {
|
||||
"option1": "value1",
|
||||
"option2": "value2"
|
||||
}
|
||||
}
|
||||
```
|
||||
- `guide/nl/codepress-developer/plugin-development.md`
|
||||
- `guide/en/codepress-developer/plugin-development.md`
|
||||
|
||||
## Installatie
|
||||
|
||||
1. Maak een nieuwe map in `plugins/`
|
||||
2. Plaats de plugin class in `PluginName/PluginName.php`
|
||||
3. Optioneel: voeg README.md en config.json toe
|
||||
4. De plugin wordt automatisch geladen door de CMS
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Gebruik `htmlspecialchars()` voor output
|
||||
- Implementeer `setAPI()` voor CMS toegang
|
||||
- Volg PSR-12 coding standards
|
||||
- Gebruik namespace indien nodig
|
||||
- Documenteer je plugin met README.md
|
||||
1. Maak een nieuwe map in `plugins/` (mapnaam = plugin class naam)
|
||||
2. Voeg de hoofd plugin class toe als `<Naam>.php`
|
||||
3. Maak een `plugin.json` met metadata en (optioneel) instellingen-schema
|
||||
4. Voeg een `README.md` toe met plugin documentatie
|
||||
5. Voeg `language/<lang>/admin.php` of `site.php` toe voor vertalingen
|
||||
6. Schakel de plugin in via `enabled_plugins` in `config.json` (of via de admin Plugins-pagina)
|
||||
Reference in New Issue
Block a user