From b670cdaea92afed5a7e80dc36ee19e4ca036e48d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 17 Apr 2011 18:52:14 +0000 Subject: [PATCH] New: Work on automatic ecm. --- htdocs/lib/files.lib.php | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/htdocs/lib/files.lib.php b/htdocs/lib/files.lib.php index d66404fd420..80ec73f80cd 100644 --- a/htdocs/lib/files.lib.php +++ b/htdocs/lib/files.lib.php @@ -64,39 +64,43 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil if ($qualified) { - // Check whether this is a file or directory and whether we're interested in that type - if (is_dir(dol_osencode($path."/".$file)) && (($types=="directories") || ($types=="all"))) + $isdir=is_dir(dol_osencode($path."/".$file)); + // Check whether this is a file or directory and whether we're interested in that type + if ($isdir && (($types=="directories") || ($types=="all") || $recursive)) { // Add entry into file_list array - if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file); - if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file); + if (($types=="directories") || ($types=="all")) + { + if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file); + if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file); - if (! $filter || preg_match('/'.$filter.'/i',$path.'/'.$file)) - { - $file_list[] = array( - "name" => $file, - "fullname" => $path.'/'.$file, - "date" => $filedate, - "size" => $filesize, - "type" => 'dir' - ); - } + if (! $filter || preg_match('/'.$filter.'/i',$path.'/'.$file)) + { + $file_list[] = array( + "name" => $file, + "fullname" => $path.'/'.$file, + "date" => $filedate, + "size" => $filesize, + "type" => 'dir' + ); + } + } // if we're in a directory and we want recursive behavior, call this function again if ($recursive) { - $file_list = array_merge($file_list,dol_dir_list($path."/".$file."/", $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder)); + $file_list = array_merge($file_list,dol_dir_list($path."/".$file, $types, $recursive, $filter, $excludefilter, $sortcriteria, $sortorder, $mode)); } } - else if (! is_dir(dol_osencode($path."/".$file)) && (($types == "files") || ($types == "all"))) + else if (! $isdir && (($types == "files") || ($types == "all"))) { - // Add file into file_list array + // Add file into file_list array if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file); if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file); if (! $filter || preg_match('/'.$filter.'/i',$path.'/'.$file)) { - $file_list[] = array( + $file_list[] = array( "name" => $file, "fullname" => $path.'/'.$file, "date" => $filedate,