File "test05.php"
Full Path: /home/analogde/www/Python/Monsta-FTP-master/affichahe _expand_collpase_tableau/test05.php
File size: 3.09 KB
MIME-type: text/x-php
Charset: utf-8
<?php
$data = [
"0filtre_P1000118.jpg" => [
[
"file_name" => "/home/analogde//www/Document_workarea/patrice/plouf/0filtre_P1000118.jpg",
"size" => 119005,
"creation_date" => "2025-01-06 22:40:26",
],
],
"1105655.jpg" => [
[
"file_name" => "/home/analogde//www/Document_workarea/patrice/plouf/1105655_v1.jpg",
"size" => 262301,
"creation_date" => "2025-01-06 22:50:11",
],
[
"file_name" => "/home/analogde//www/Document_workarea/patrice/plouf/1105655_v2.jpg",
"size" => 262301,
"creation_date" => "2025-01-07 22:34:30",
],
],
];
echo '<!DOCTYPE html>';
echo '<html lang="en">';
echo '<head>';
echo '<meta charset="UTF-8">';
echo '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
echo '<title>Gestion des Fichiers</title>';
echo '<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet">';
echo '</head>';
echo '<body class="p-3">';
echo '<div class="container">';
echo '<h1 class="mb-4">Liste des Fichiers</h1>';
echo '<table class="table table-striped table-bordered">';
echo '<thead class="thead-dark">';
echo '<tr>';
echo '<th>Nom du fichier</th>';
echo '<th>Nombre de versions</th>';
echo '<th>Taille</th>';
echo '<th>Date de création</th>';
echo '<th>Actions</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
foreach ($data as $key => $versions) {
$rowId = md5($key);
$original = $versions[0];
$isMultiple = count($versions) > 1;
echo '<tr>';
echo '<td>' . htmlspecialchars($key) . '</td>';
echo '<td>' . count($versions) . '</td>';
echo '<td>' . number_format($original["size"], 0, ",", " ") . ' bytes</td>';
echo '<td>' . $original["creation_date"] . '</td>';
if ($isMultiple) {
echo '<td><button class="btn btn-primary btn-sm" type="button" data-bs-toggle="collapse" data-bs-target="#' . $rowId . '" aria-expanded="false" aria-controls="' . $rowId . '">Afficher/Masquer</button></td>';
} else {
echo '<td>-</td>';
}
echo '</tr>';
if ($isMultiple) {
echo '<tr class="collapse" id="' . $rowId . '">';
echo '<td colspan="5">';
echo '<table class="table">';
//echo '<thead>';
//echo '<tr><th>Nom</th><th>Taille</th><th>Date de création</th></tr>';
//echo '</thead>';
echo '<tbody>';
foreach ($versions as $index => $version) {
$fileNameOnly = basename($version["file_name"]);
echo '<tr>';
echo '<td>' . htmlspecialchars($fileNameOnly) . '</td>';
echo '<td>' . number_format($version["size"], 0, ",", " ") . ' bytes</td>';
echo '<td>' . $version["creation_date"] . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
echo '</td>';
echo '</tr>';
}
}
echo '</tbody>';
echo '</table>';
echo '</div>';
echo '<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script>';
echo '</body>';
echo '</html>';
?>