v2.6.3 (Lyra): Content multi-type handling, getAllPages() structuur, . verberg-prefix

- Content bestanden met dezelfde naam maar ander type (md/php/html) worden
  correct geserveerd: URL met extensie opent dat bestand, URL zonder extensie
  valt terug op md > php > html (resolveContentByType helper)
- Admin content editor accepteert bestanden met dezelfde naam (ander type);
  preview-knop linkt per extensie
- Frontend navigatie/directory listing/search tonen elk bestandstype apart
- getAllPages() array structuur gewijzigd naar list van
  ['path','title','type'] met type 'md'/'php'/'html'/'folder'
- Verberg-prefix logica: _ is geen verberg-prefix meer, alleen . (en -);
  admin toont wél alle . bestanden/mappen
- ContentAPI getPage()/pageExists() respecteren expliciete extensie
- Handleiding content-api.md (NL+EN) herschreven
- File-tree unificatie: _file-tree.twig + _editor-styles.twig includes
- Versie verhoogd naar 2.6.3
This commit is contained in:
2026-08-20 16:45:53 +00:00
parent 97c4d52c78
commit 6485f693dc
28 changed files with 1481 additions and 950 deletions
+23 -9
View File
@@ -17,9 +17,10 @@ class ContentAPI
}
/**
* Get all pages as a flat array of path => title pairs
* Get all content entries (mappen + bestanden) as a list of entry arrays.
*
* @return array Associative array like ['index' => 'Home', 'over-ons' => 'Over ons']
* @return array List of ['path' => ..., 'title' => ..., 'type' => ...]
* type is 'md'/'php'/'html' voor bestanden, 'folder' voor mappen.
*/
public function getAllPages(): array
{
@@ -29,18 +30,32 @@ class ContentAPI
/**
* Get a single page by path, including title, content, layout, and metadata
*
* @param string $path Page path without extension (e.g. 'over-ons' or 'blog/post-1')
* De $path mag een extensie bevten (bijv. 'over-ons.php') of niet ('over-ons').
* Zonder extensie wordt het eerste bestaande bestand gekozen (md > php > html);
* met extensie wordt dat specifieke bestand gekozen.
*
* @param string $path Page path, al dan niet met extensie
* @return array|null Page data or null if not found
*/
public function getPage(string $path): ?array
{
$contentDir = $this->cms->config['content_dir'];
$path = preg_replace('/\.(md|php|html)$/', '', $path);
// Detecteer expliciete extensie en strip hem voor de basis
$preferredExt = null;
if (preg_match('/\.(md|php|html)$/i', $path, $m)) {
$preferredExt = strtolower($m[1]);
}
$path = preg_replace('/\.(md|php|html)$/i', '', $path);
$filePath = $contentDir . '/' . $path;
$extensions = ['md', 'php', 'html'];
// Probeer de gevraagde extensie eerst, dan de standaard volgorde
$order = ['md', 'php', 'html'];
if ($preferredExt !== null) {
$order = array_unique(array_merge([$preferredExt], $order));
}
$actualPath = null;
foreach ($extensions as $ext) {
foreach ($order as $ext) {
if (file_exists($filePath . '.' . $ext)) {
$actualPath = $filePath . '.' . $ext;
break;
@@ -141,14 +156,13 @@ class ContentAPI
/**
* Check if a page exists at the given path
*
* @param string $path Page path without extension
* @param string $path Page path, al dan niet met extensie
* @return bool
*/
public function pageExists(string $path): bool
{
$contentDir = $this->cms->config['content_dir'];
$path = preg_replace('/\.(md|php|html)$/', '', $path);
$basePath = $contentDir . '/' . $path;
$basePath = $contentDir . '/' . preg_replace('/\.(md|php|html)$/i', '', $path);
return file_exists($basePath . '.md')
|| file_exists($basePath . '.php')