isFile() && in_array($file->getExtension(), ['php', 'html'])) {
$path = $file->getPathname();
$relativePath = str_replace($rootDir . DIRECTORY_SEPARATOR, '', $path);
$relativePath = str_replace('\\', '/', $relativePath); // Normalize for URL
// Extract folder and filename
$parts = explode('/', $relativePath);
$filename = array_pop($parts);
$folder = empty($parts) ? 'Główny' : implode('/', $parts);
$structure[$folder][] = [
'name' => $filename,
'url' => 'prototype/' . $relativePath
];
}
}
// Sort folders and files
ksort($structure);
foreach ($structure as &$files) {
sort($files);
}
unset($files); // Break the reference with the last element
}
foreach ($structure as $folder => $files): ?>
Nie znaleziono żadnych plików w folderze prototype.