72 lines
3.0 KiB
PHP
72 lines
3.0 KiB
PHP
<?php include 'header-sneat.php'; ?>
|
|
|
|
<div class="container-xxl flex-grow-1 container-p-y">
|
|
<h4 class="fw-bold py-3 mb-4"><span class="text-muted fw-light">Magico /</span> Prototypy</h4>
|
|
|
|
<div class="row">
|
|
<?php
|
|
$rootDir = __DIR__ . '/prototype';
|
|
$structure = [];
|
|
|
|
if (is_dir($rootDir)) {
|
|
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($rootDir));
|
|
|
|
foreach ($iterator as $file) {
|
|
if ($file->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): ?>
|
|
<div class="col-md-6 col-lg-4 mb-4">
|
|
<div class="card h-100">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h5 class="mb-0 card-title"><i class="bi bi-folder2-open me-2"></i><?= htmlspecialchars($folder) ?></h5>
|
|
<span class="badge bg-label-primary rounded-pill"><?= count($files) ?></span>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="list-group list-group-flush">
|
|
<?php foreach ($files as $file): ?>
|
|
<a href="<?= htmlspecialchars($file['url']) ?>"
|
|
class="list-group-item list-group-item-action d-flex align-items-center">
|
|
<i class="bi bi-file-earmark-code me-2 text-secondary"></i>
|
|
<?= htmlspecialchars($file['name']) ?>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
<?php if (empty($structure)): ?>
|
|
<div class="col-12">
|
|
<div class="alert alert-warning" role="alert">
|
|
Nie znaleziono żadnych plików w folderze <code>prototype</code>.
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php include 'footer-sneat.php'; ?>
|