Add comprehensive development documentation with execution flow
- Add DEVELOPMENT.md with complete architecture overview - Document exact loading order and function call sequence - Include security checkpoints and data flow analysis - Provide practical development workflow and coding standards
This commit is contained in:
parent
25769cef24
commit
4b9551d7e4
188
DEVELOPMENT.md
Normal file
188
DEVELOPMENT.md
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
# CodePress CMS - Executie Flow
|
||||||
|
|
||||||
|
## Volledige Laadvolgorde en Functie Aanroepen
|
||||||
|
|
||||||
|
### 1. Web Request Start
|
||||||
|
**Bestand:** `public/index.php` (Eerste geladen bestand)
|
||||||
|
|
||||||
|
**Stappen:**
|
||||||
|
1. **Line 3:** `require_once __DIR__ . '/../engine/core/index.php'`
|
||||||
|
- Laadt de core loader
|
||||||
|
|
||||||
|
2. **Line 5:** `$config = include __DIR__ . '/../engine/core/config.php'`
|
||||||
|
- Laadt configuratie
|
||||||
|
|
||||||
|
3. **Line 8-13:** Security check
|
||||||
|
- Blokkeert directe toegang tot `/content/` directory
|
||||||
|
|
||||||
|
4. **Line 15:** `$cms = new CodePressCMS($config)`
|
||||||
|
- Creëert CMS instance
|
||||||
|
|
||||||
|
5. **Line 16:** `$cms->render()`
|
||||||
|
- Start de rendering
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 2. Core Loader
|
||||||
|
**Bestand:** `engine/core/index.php`
|
||||||
|
|
||||||
|
**Stappen (in volgorde):**
|
||||||
|
1. **Line 27:** `require_once 'config.php'`
|
||||||
|
- Laadt configuratie systeem
|
||||||
|
|
||||||
|
2. **Line 30:** `require_once 'class/SimpleTemplate.php'`
|
||||||
|
- Laadt template engine
|
||||||
|
|
||||||
|
3. **Line 33:** `require_once 'class/CodePressCMS.php'`
|
||||||
|
- Laadt main CMS class
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 3. Configuratie Laden
|
||||||
|
**Bestand:** `engine/core/config.php`
|
||||||
|
|
||||||
|
**Stappen:**
|
||||||
|
1. **Line 9-25:** `$defaultConfig` array wordt gedefinieerd
|
||||||
|
2. **Line 27-41:** Configuratie wordt samengevoegd met `config.json` indien aanwezig
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 4. CodePressCMS Constructor
|
||||||
|
**Bestand:** `engine/core/class/CodePressCMS.php`
|
||||||
|
**Methode:** `__construct($config)` (Line 35-44)
|
||||||
|
|
||||||
|
**Stappen in exacte volgorde:**
|
||||||
|
1. **Line 36:** `$this->config = $config`
|
||||||
|
- Slaat configuratie op
|
||||||
|
|
||||||
|
2. **Line 37:** `$this->currentLanguage = $this->getCurrentLanguage()`
|
||||||
|
- Roept `getCurrentLanguage()` aan
|
||||||
|
|
||||||
|
3. **Line 38:** `$this->translations = $this->loadTranslations($this->currentLanguage)`
|
||||||
|
- Roept `loadTranslations()` aan
|
||||||
|
|
||||||
|
4. **Line 39:** `$this->buildMenu()`
|
||||||
|
- Roept `buildMenu()` aan
|
||||||
|
|
||||||
|
5. **Line 41-43:** Search handling indien nodig
|
||||||
|
- Roept `performSearch()` aan als `$_GET['search']` bestaat
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 5. Taal Detectie
|
||||||
|
**Methode:** `getCurrentLanguage()` (Line 51-53)
|
||||||
|
|
||||||
|
**Stappen:**
|
||||||
|
1. **Line 52:** `return $_GET['lang'] ?? $this->config['language']['default'] ?? 'nl'`
|
||||||
|
- Check URL parameter, dan config default, dan 'nl'
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 6. Translaties Laden
|
||||||
|
**Methode:** `loadTranslations($lang)` (Line 61-74)
|
||||||
|
|
||||||
|
**Stappen:**
|
||||||
|
1. **Line 62:** `$langFile = __DIR__ . '/../../lang/' . $lang . '.php'`
|
||||||
|
- Bouwt pad naar taalbestand
|
||||||
|
|
||||||
|
2. **Line 64-68:** Check of bestand exists en laad het
|
||||||
|
3. **Line 70-73:** Fallback naar default taal indien nodig
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 7. Menu Bouwen
|
||||||
|
**Methode:** `buildMenu()` (ongeveer Line 200+)
|
||||||
|
|
||||||
|
**Stappen:**
|
||||||
|
1. **Scan content directory** voor bestanden en mappen
|
||||||
|
2. **Roep `scanDirectory()` aan** recursief
|
||||||
|
3. **Genereer menu structuur** met hiërarchie
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 8. Main Render Methode
|
||||||
|
**Methode:** `render()` (ongeveer Line 300+)
|
||||||
|
|
||||||
|
**Stappen in volgorde:**
|
||||||
|
1. **Bepaal page type** (content, search, guide, directory)
|
||||||
|
2. **Roep `getPage()` aan** voor content
|
||||||
|
3. **Genereer breadcrumb** met `generateBreadcrumb()`
|
||||||
|
4. **Bepaal content type** met `getContentType()`
|
||||||
|
5. **Laad template** (layout, header, content, footer)
|
||||||
|
6. **Render template** met `SimpleTemplate::render()`
|
||||||
|
7. **Output HTML**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 9. Content Verwerking
|
||||||
|
**Methode:** `getPage()` (ongeveer Line 150+)
|
||||||
|
|
||||||
|
**Flow afhankelijk van page type:**
|
||||||
|
|
||||||
|
**Voor Markdown (.md):**
|
||||||
|
1. `parseMarkdown($content, $filePath)`
|
||||||
|
2. CommonMark conversie
|
||||||
|
3. Auto-linking met `autoLinkPageTitles()`
|
||||||
|
|
||||||
|
**Voor PHP (.php):**
|
||||||
|
1. `parsePHP($filePath)`
|
||||||
|
2. Execute PHP en capture output
|
||||||
|
3. Buffer handling
|
||||||
|
|
||||||
|
**Voor HTML (.html):**
|
||||||
|
1. `parseHTML($content)`
|
||||||
|
2. Directe verwerking
|
||||||
|
|
||||||
|
**Voor Directory:**
|
||||||
|
1. `getDirectoryListing($pagePath, $dirPath)`
|
||||||
|
2. Scan directory voor bestanden
|
||||||
|
3. Genereer lijst met metadata
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 10. Template Rendering
|
||||||
|
**Klasse:** `SimpleTemplate`
|
||||||
|
**Methode:** `render($template, $data)`
|
||||||
|
|
||||||
|
**Stappen:**
|
||||||
|
1. **Load template file**
|
||||||
|
2. **Process partials** met `{{>partial}}`
|
||||||
|
3. **Process conditionals** met `{{#var}}...{{/var}}`
|
||||||
|
4. **Replace variables** met `{{variable}}` (escaped) of `{{{variable}}}` (unescaped)
|
||||||
|
5. **Return rendered HTML**
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Complete Flow Samenvatting
|
||||||
|
|
||||||
|
```
|
||||||
|
1. public/index.php
|
||||||
|
↓ require_once
|
||||||
|
2. engine/core/index.php
|
||||||
|
↓ require_once (3x)
|
||||||
|
3. config.php → SimpleTemplate.php → CodePressCMS.php
|
||||||
|
↓ new CodePressCMS()
|
||||||
|
4. CodePressCMS::__construct()
|
||||||
|
↓ getCurrentLanguage()
|
||||||
|
5. loadTranslations()
|
||||||
|
↓ buildMenu()
|
||||||
|
↓ (optioneel) performSearch()
|
||||||
|
↓ render()
|
||||||
|
6. getPage() → parseMarkdown/parsePHP/parseHTML/getDirectoryListing()
|
||||||
|
↓ generateBreadcrumb()
|
||||||
|
↓ getContentType()
|
||||||
|
↓ SimpleTemplate::render()
|
||||||
|
7. SimpleTemplate::renderTemplate()
|
||||||
|
↓ Output HTML
|
||||||
|
```
|
||||||
|
|
||||||
|
## Security Checkpoints
|
||||||
|
1. **public/index.php Line 8-13:** Blokkeert `/content/` toegang
|
||||||
|
2. **Template engine:** Escaped variabelen met `htmlspecialchars()`
|
||||||
|
3. **File access:** Gecontroleerde paden en validatie
|
||||||
|
|
||||||
|
## Data Flow
|
||||||
|
- **Request URI** → Page detection → Content parsing → Template rendering → HTML output
|
||||||
|
- **Configuratie** → Doorgegeven aan alle componenten
|
||||||
|
- **Taal** → Gedetecteerd → Translations geladen → Template data
|
||||||
|
- **Menu** → Gebouwd uit file structure → Doorgegeven aan template
|
||||||
Loading…
x
Reference in New Issue
Block a user