diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 47cea45c5fe..89bb2bac258 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -2515,50 +2515,45 @@ class Form
print '';
}
- // Affiche lignes
- if (is_dir($filedir))
- {
- $handle=opendir($filedir);
- while (($file = readdir($handle))!==false)
- {
- // Si fichier non lisible ou mauvaise extension, on passe au suivant
- if (! is_readable($filedir."/".$file) ||
- eregi('\.meta$',$file) ||
- eregi('\.$',$file)
- ) continue;
-
- if (! $headershown)
- {
- // Affiche en-tete tableau
- $headershown=1;
-
- print_titre($langs->trans("Documents"));
- print '
';
- }
-
+ // Recupe liste des fichiers
+ $file_list=dolibarr_dir_list($filedir,'files',0,'','\.meta$','date',SORT_DESC);
+
+ // Affiche en-tete tableau si non deja affiché
+ if (sizeof($file_list) && ! $headershown)
+ {
+ $headershown=1;
+
+ print_titre($langs->trans("Documents"));
+ print '';
+ }
+
+ // Boucle sur chaque ligne trouvée
+ foreach($file_list as $i => $file)
+ {
+
// Défini chemin relatif par rapport au module pour lien download
- $relativepath=$filename."/".$file;
- if ($modulepart == 'don') { $relativepath = get_exdir($filename).$file; }
- if ($modulepart == 'export') { $relativepath = $file; }
+ $relativepath=$filename."/".$file["name"];
+ if ($modulepart == 'don') { $relativepath = get_exdir($filename).$file["name"]; }
+ if ($modulepart == 'export') { $relativepath = $file["name"]; }
// Défini le type MIME du document
- if (eregi('\.([^\.]+)$',$file,$reg)) $extension=$reg[1];
+ if (eregi('\.([^\.]+)$',$file["name"],$reg)) $extension=$reg[1];
$mimetype=strtoupper($extension);
if ($extension == 'pdf') $mimetype='PDF';
if ($extension == 'html') $mimetype='HTML';
- if (eregi('\-detail\.pdf',$file)) $mimetype='PDF Détaillé';
+ if (eregi('\-detail\.pdf',$file["name"])) $mimetype='PDF Détaillé';
print "";
// Affiche colonne type MIME
print '| '.$mimetype.' | ';
// Affiche nom fichier avec lien download
- print ''.$file.'';
+ print ' | '.$file["name"].'';
print ' | ';
// Affiche taille fichier
- print ''.filesize($filedir."/".$file). ' bytes | ';
+ print ''.filesize($filedir."/".$file["name"]). ' bytes | ';
// Affiche date fichier
- print ''.strftime("%d %b %Y %H:%M:%S",filemtime($filedir."/".$file)).' | ';
+ print ''.strftime("%d %b %Y %H:%M:%S",filemtime($filedir."/".$file["name"])).' | ';
if ($delallowed)
{
@@ -2568,21 +2563,21 @@ class Form
print '
';
$i++;
- }
- }
-
- if ($headershown)
- {
- // Affiche pied du tableau
- print "
\n";
- if ($genallowed)
- {
- print '';
- }
- }
-
- return $i;
-}
+ }
+
+
+ if ($headershown)
+ {
+ // Affiche pied du tableau
+ print "
\n";
+ if ($genallowed)
+ {
+ print '';
+ }
+ }
+
+ return $i;
+ }
}