From a1e1ea2367819b150a15a59e2bc46db842836a24 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 14 Jul 2007 15:48:42 +0000 Subject: [PATCH] Fix: ajout du filtre png lors de l'affichage de l'icone pdf --- htdocs/html.form.class.php | 10 ++++-- htdocs/lib/functions.inc.php | 66 ++++++++++++++++++------------------ 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 24315809a90..9d3262b0553 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -3053,8 +3053,14 @@ class Form } // Recupe liste des fichiers - if ($iconPDF==1) $png = '|\.png$'; - $file_list=dolibarr_dir_list($filedir,'files',0,'','\.meta$'.$png,'date',SORT_DESC); + $png = ''; + $filter = ''; + if ($iconPDF==1) + { + $png = '|\.png$'; + $filter = $filename; + } + $file_list=dolibarr_dir_list($filedir,'files',0,$filter,'\.meta$'.$png,'date',SORT_DESC); // Affiche en-tete tableau si non deja affiché if (sizeof($file_list) && ! $headershown && !$iconPDF) diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index f603a4af133..892c9c06464 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -2241,56 +2241,56 @@ function dolibarr_dir_list($path, $types="all", $recursive=0, $filter="", $exclu if (! is_dir($path)) return array(); if ($dir = opendir($path)) + { + $file_list = array(); + while (false !== ($file = readdir($dir))) { - $file_list = array(); - while (false !== ($file = readdir($dir))) - { - $qualified=1; - - // Check if file is qualified - if (eregi('^\.',$file)) $qualified=0; - if ($excludefilter && eregi($excludefilter,$file)) $qualified=0; - - if ($qualified) + $qualified=1; + + // Check if file is qualified + if (eregi('^\.',$file)) $qualified=0; + if ($excludefilter && eregi($excludefilter,$file)) $qualified=0; + + if ($qualified) { // Check whether this is a file or directory and whether we're interested in that type if ((is_dir($path."/".$file)) && (($types=="directories") || ($types=="all"))) - { - // Add entry into file_list array - if ($sortcriteria == 'date') $filedate=filemtime($path."/".$file); - if ($sortcriteria == 'size') $filesize=filesize($path."/".$file); - - if (! $filter || eregi($filter,$path.'/'.$file)) - { - $file_list[] = array( + { + // Add entry into file_list array + if ($sortcriteria == 'date') $filedate=filemtime($path."/".$file); + if ($sortcriteria == 'size') $filesize=filesize($path."/".$file); + + if (! $filter || eregi($filter,$path.'/'.$file)) + { + $file_list[] = array( "name" => $file, "fullname" => $path.'/'.$file, "date" => $filedate, "size" => $filesize ); + } + + // if we're in a directory and we want recursive behavior, call this function again + if ($recursive) + { + $file_list = array_merge($file_list, dolibarr_dir_list($path."/".$file."/", $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder)); + } } - - // if we're in a directory and we want recursive behavior, call this function again - if ($recursive) - { - $file_list = array_merge($file_list, dolibarr_dir_list($path."/".$file."/", $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder)); - } - } else if (($types == "files") || ($types == "all")) - { - // Add file into file_list array - if ($sortcriteria == 'date') $filedate=filemtime($path."/".$file); - if ($sortcriteria == 'size') $filesize=filesize($path."/".$file); - if (! $filter || eregi($filter,$path.'/'.$file)) - { - $file_list[] = array( + { + // Add file into file_list array + if ($sortcriteria == 'date') $filedate=filemtime($path."/".$file); + if ($sortcriteria == 'size') $filesize=filesize($path."/".$file); + if (! $filter || eregi($filter,$path.'/'.$file)) + { + $file_list[] = array( "name" => $file, "fullname" => $path.'/'.$file, "date" => $filedate, "size" => $filesize ); + } } - } } } closedir($dir);