Fix formatDisplayName special cases for directory names

- Restrict special case handling (phpinfo, ICT) to exact filenames only
- Prevent special cases from overriding directory names like 'nl.test'
- Directory names now use formatDisplayName() without special case overrides
- This ensures 'nl.test' directory displays as 'Test' not 'Untitled'
This commit is contained in:
Edwin Noorlander 2025-11-22 17:07:31 +01:00
parent dec50951d0
commit b92d192399

View File

@ -559,11 +559,12 @@ class CodePressCMS {
// Remove file extensions (.md, .php, .html) from display names // Remove file extensions (.md, .php, .html) from display names
$filename = preg_replace('/\.(md|php|html)$/', '', $filename); $filename = preg_replace('/\.(md|php|html)$/', '', $filename);
// Handle special cases first // Handle special cases first (only for exact filenames, not directories)
if (strtolower($filename) === 'phpinfo') { // These should only apply to actual files, not directory names
if (strtolower($filename) === 'phpinfo' && !preg_match('/\//', $filename)) {
return 'phpinfo'; return 'phpinfo';
} }
if (strtolower($filename) === 'ict') { if (strtolower($filename) === 'ict' && !preg_match('/\//', $filename)) {
return 'ICT'; return 'ICT';
} }
@ -718,6 +719,9 @@ class CodePressCMS {
// Get the directory name from the path, not from a potential file // Get the directory name from the path, not from a potential file
$pathParts = explode('/', $pagePath); $pathParts = explode('/', $pagePath);
$dirName = end($pathParts); $dirName = end($pathParts);
// Get the directory name from path, not from a potential file
$title = $this->formatDisplayName($dirName) ?: 'Home'; $title = $this->formatDisplayName($dirName) ?: 'Home';
$content = '<h1>' . htmlspecialchars($title) . '</h1>'; $content = '<h1>' . htmlspecialchars($title) . '</h1>';