From 23f8123718edd7e07b53808d055dc9f3352656f0 Mon Sep 17 00:00:00 2001 From: leosw Date: Sat, 2 Aug 2025 13:16:50 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20d'un=20syst=C3=A8me=20de=20listing=20de?= =?UTF-8?q?s=20fichiers=20de=20dossier=20/medias/wiki?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/d.admin.php | 73 +++++++++++++++++++++++++++++++++++ views/d.admin.git-pull.html | 2 +- views/d.admin.html | 1 + views/d.admin.logs.html | 2 +- views/d.admin.wiki-files.html | 62 +++++++++++++++++++++++++++++ 5 files changed, 138 insertions(+), 2 deletions(-) create mode 100755 views/d.admin.wiki-files.html diff --git a/controllers/d.admin.php b/controllers/d.admin.php index eb5df90..298eef8 100755 --- a/controllers/d.admin.php +++ b/controllers/d.admin.php @@ -42,6 +42,63 @@ if(isset($controller->splitted_url[1]) && $user->rankIsHigher("moderator")) { $notfound = 1; } break; + case 'wiki-files': + if ($user->rankIsHigher("moderator")) { + $head['title'] = "Fichiers attachés au wiki"; + $rows_per_pages = 50; + $files_folder = $config['medias_folder']."wiki/"; + + // Get the file list + $files_list = scandir($files_folder); + // Populate table + foreach ($files_list as $file) { + $file_path = $files_folder.$file; + + if (is_file($file_path)) { + $file_info = [ + 'name' => $file, + 'type' => mime_content_type($file_path), + 'creation_date' => date("Y-m-d H:i:s", filectime($file_path)), + 'size' => filesize($file_path), + ]; + + $files[] = $file_info; + } + } + $filenb = count($files); + + // Manage sorting + if(isset($_GET['orderby'])) + $orderby = $_GET['orderby']; + else + $orderby = 'name'; + if(isset($_GET['order']) && $_GET['order']=='ASC') { + $order = 'ASC'; + usort($files, function ($a, $b) use ($orderby) { return $a[$orderby] <=> $b[$orderby]; }); + } + else { + $order = 'DESC'; + usort($files, function ($a, $b) use ($orderby) { return $b[$orderby] <=> $a[$orderby]; }); + } + + // Get the correct page number + if (!isset($controller->splitted_url[2]) OR $controller->splitted_url[2]=="" OR $controller->splitted_url[2]=="0" OR !is_numeric($controller->splitted_url[2])) { + $page = 0; + } else { + $page = $controller->splitted_url[2] - 1; + } + // In case the wanted page is too big + if($rows_per_pages * $page >= $filenb) + $page = 0; + + $first = $page*$rows_per_pages+1; + $last = (($page+1)*$rows_per_pages > $filenb ? $filenb : ($page+1)*$rows_per_pages); + include ($config['views_folder']."d.admin.wiki-files.html"); + } + else { + $notfound = 1; + } + break; default: $notfound = 1; break; @@ -55,4 +112,20 @@ else { $notfound = 1; } +function getFontAwesomeIcon($mimeType) { + $icons = [ + 'application/pdf' => 'fa-file-pdf', + 'image/jpeg' => 'fa-file-image', + 'image/png' => 'fa-file-image', + 'application/zip' => 'fa-file-archive', + 'text/plain' => 'fa-file-alt', + 'application/vnd.ms-excel' => 'fa-file-excel', + 'application/msword' => 'fa-file-word', + 'video/mp4' => 'fa-file-video', + 'audio/mpeg' => 'fa-file-audio', + ]; + + return $icons[$mimeType] ?? 'fa-file'; // Default +} + ?> \ No newline at end of file diff --git a/views/d.admin.git-pull.html b/views/d.admin.git-pull.html index f004010..479aa23 100755 --- a/views/d.admin.git-pull.html +++ b/views/d.admin.git-pull.html @@ -8,7 +8,7 @@
-

Mise à jour

+



 			rankIsHigher("moderator")) { ?>
 				 Voir les logs Permet d'accéder aux 200 dernières lignes des logs bruts des actions sur la base de données.

+ Fichiers attachésGérer les fichiers attachés pour le wiki : liste, ajout suppression...

diff --git a/views/d.admin.logs.html b/views/d.admin.logs.html index 431b705..195727b 100755 --- a/views/d.admin.logs.html +++ b/views/d.admin.logs.html @@ -8,7 +8,7 @@
-

Logs

+