From 37207927bd069b50be9491e02479ff41189304f8 Mon Sep 17 00:00:00 2001 From: Esenjin Date: Tue, 7 Jan 2025 15:30:48 +0100 Subject: [PATCH] =?UTF-8?q?les=20albums=20sont=20tri=C3=A9s=20par=20ordre?= =?UTF-8?q?=20alphab=C3=A9tique?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- albums.php | 10 ++++- arbre-prive.php | 103 ++++++++++++++++++++++++++---------------------- arbre.php | 93 +++++++++++++++++++++++-------------------- 3 files changed, 115 insertions(+), 91 deletions(-) diff --git a/albums.php b/albums.php index ff65a9e..2f8e287 100644 --- a/albums.php +++ b/albums.php @@ -17,6 +17,7 @@ $currentAlbumInfo = getAlbumInfo($currentPath); // Récupérer tous les sous-dossiers $albums = []; +$tempAlbums = []; foreach (new DirectoryIterator($currentPath) as $item) { if ($item->isDot()) continue; if ($item->isDir()) { @@ -27,7 +28,7 @@ foreach (new DirectoryIterator($currentPath) as $item) { getImagesRecursively($albumPath) : getLatestImages($albumPath); - $albums[] = [ + $tempAlbums[] = [ 'path' => str_replace('\\', '/', $albumPath), 'title' => $info['title'], 'description' => $info['description'], @@ -39,6 +40,13 @@ foreach (new DirectoryIterator($currentPath) as $item) { } } +// Tri alphabétique des albums par titre +usort($tempAlbums, function($a, $b) { + return strcasecmp($a['title'], $b['title']); +}); + +$albums = $tempAlbums; + // Déterminer le chemin parent pour le bouton retour $parentPath = dirname($currentPath); if (!isSecurePath($parentPath)) { diff --git a/arbre-prive.php b/arbre-prive.php index b0f2f1a..8f4032c 100644 --- a/arbre-prive.php +++ b/arbre-prive.php @@ -141,60 +141,69 @@ function generatePrivateTree($path, $currentPath) { $output .= ''; } - // Parcourir tous les sous-dossiers + // Récupérer et trier les sous-dossiers + $dirs = array(); foreach (new DirectoryIterator($path) as $item) { if ($item->isDot()) continue; if ($item->isDir()) { $fullPath = $item->getPathname(); $info = getAlbumInfo($fullPath); - $isCurrentPath = realpath($fullPath) === $currentPath; - $hasSubfolders = hasSubfolders($fullPath); - $hasImages = hasImages($fullPath); - - $output .= '
  • '; - $output .= '
    '; - $output .= ''; - $output .= '🔒 ' . htmlspecialchars($info['title']); - if ($info['mature_content']) { - $output .= ' 🔞'; - } - $output .= ''; - $output .= '
    '; - if (!$hasSubfolders) { - $output .= '🖼️'; - // Ajout du bouton de génération de lien si le dossier contient des images - if ($hasImages) { - $output .= ''; - } - } - if (!$hasSubfolders) { - $output .= ''; - } else { - $output .= ''; - } - if (!$hasImages) { - $output .= ''; - } - if ($fullPath !== './liste_albums_prives') { - $output .= ''; - } - $output .= '
    '; - - $output .= generatePrivateTree($fullPath, $currentPath); - $output .= '
  • '; + $dirs[$info['title']] = $fullPath; } } + + // Tri alphabétique par titre + ksort($dirs, SORT_STRING | SORT_FLAG_CASE); + + // Parcourir les dossiers triés + foreach ($dirs as $title => $fullPath) { + $info = getAlbumInfo($fullPath); + $isCurrentPath = realpath($fullPath) === $currentPath; + $hasSubfolders = hasSubfolders($fullPath); + $hasImages = hasImages($fullPath); + + $output .= '
  • '; + $output .= '
    '; + $output .= ''; + $output .= '🔒 ' . htmlspecialchars($info['title']); + if ($info['mature_content']) { + $output .= ' 🔞'; + } + $output .= ''; + $output .= '
    '; + if (!$hasSubfolders) { + $output .= '🖼️'; + if ($hasImages) { + $output .= ''; + } + } + if (!$hasSubfolders) { + $output .= ''; + } else { + $output .= ''; + } + if (!$hasImages) { + $output .= ''; + } + if ($fullPath !== './liste_albums_prives') { + $output .= ''; + } + $output .= '
    '; + + $output .= generatePrivateTree($fullPath, $currentPath); + $output .= '
  • '; + } $output .= ''; return $output; diff --git a/arbre.php b/arbre.php index f6dd2ad..0ad4407 100644 --- a/arbre.php +++ b/arbre.php @@ -112,55 +112,63 @@ function generateTree($path, $currentPath) { $output .= ''; } - // Parcourir tous les sous-dossiers + // Récupérer et trier les sous-dossiers + $dirs = array(); foreach (new DirectoryIterator($path) as $item) { if ($item->isDot()) continue; if ($item->isDir()) { $fullPath = $item->getPathname(); $info = getAlbumInfo($fullPath); - $isCurrentPath = realpath($fullPath) === $currentPath; - $hasSubfolders = hasSubfolders($fullPath); - - $output .= '
  • '; - $output .= '
    '; - $output .= ''; - $output .= '📁 ' . htmlspecialchars($info['title']); - if ($info['mature_content']) { - $output .= ' 🔞'; - } - $output .= ''; - $output .= '
    '; - if (!$hasSubfolders) { - $output .= '🖼️'; - } - // Pour les dossiers avec des images - if (!$hasSubfolders) { - $output .= ''; - } else { - // Pour les dossiers sans images - $output .= ''; - } - if (!hasImages($fullPath)) { - $output .= ''; - } - if ($fullPath !== './liste_albums') { - $output .= ''; - } - $output .= '
    '; - - $output .= generateTree($fullPath, $currentPath); - $output .= '
  • '; + $dirs[$info['title']] = $fullPath; } } + + // Tri alphabétique par titre + ksort($dirs, SORT_STRING | SORT_FLAG_CASE); + + // Parcourir les dossiers triés + foreach ($dirs as $title => $fullPath) { + $info = getAlbumInfo($fullPath); + $isCurrentPath = realpath($fullPath) === $currentPath; + $hasSubfolders = hasSubfolders($fullPath); + + $output .= '
  • '; + $output .= '
    '; + $output .= ''; + $output .= '📁 ' . htmlspecialchars($info['title']); + if ($info['mature_content']) { + $output .= ' 🔞'; + } + $output .= ''; + $output .= '
    '; + if (!$hasSubfolders) { + $output .= '🖼️'; + } + if (!$hasSubfolders) { + $output .= ''; + } else { + $output .= ''; + } + if (!hasImages($fullPath)) { + $output .= ''; + } + if ($fullPath !== './liste_albums') { + $output .= ''; + } + $output .= '
    '; + + $output .= generateTree($fullPath, $currentPath); + $output .= '
  • '; + } $output .= ''; return $output; @@ -168,7 +176,6 @@ function generateTree($path, $currentPath) { $config = getSiteConfig(); ?> -