2
0
forked from Wavyzz/dolibarr

New: A lot of enhancements into ECM module. Dir can contains special characters. Speed enhancements. Dir can be created outside of dolibarr, the refresh button will update database.

This commit is contained in:
Laurent Destailleur
2010-10-03 15:42:01 +00:00
parent 640e03422f
commit a6c0e62107
9 changed files with 278 additions and 115 deletions

View File

@@ -24,23 +24,24 @@
*/
/**
* Scan a directory and return a list of files/directories. Content for string is UTF8.
* Scan a directory and return a list of files/directories.
* Content for string is UTF8 and dir separator is "/".
* @param $path Starting path from which to search
* @param $types Can be "directories", "files", or "all"
* @param $recursive Determines whether subdirectories are searched
* @param $filter Regex for include filter
* @param $exludefilter Regex for exclude filter (example: '\.meta$')
* @param $sortcriteria Sort criteria ("name","date","size")
* @param $excludefilter Regex for exclude filter (example: '\.meta$')
* @param $sortcriteria Sort criteria ("","name","date","size")
* @param $sortorder Sort order (SORT_ASC, SORT_DESC)
* @param $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower)
* @param $mode 0=Return array minimum keys loaded (faster), 1=Force all keys like date and size to be loaded (slower), 2=Force load of date only, 3=Force load of size only
* @return array Array of array('name'=>'xxx','fullname'=>'/abc/xxx','date'=>'yyy','size'=>99,'type'=>'dir|file')
*/
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
{
dol_syslog("files.lib.php::dol_dir_list path=".$path." types=".$types." recursive=".$recursive." filter=".$filter." excludefilter=".$excludefilter);
$loaddate=$mode?true:false;
$loadsize=$mode?true:false;
$loaddate=($mode==1||$mode==2)?true:false;
$loadsize=($mode==1||$mode==3)?true:false;
// Clean parameters
$path=preg_replace('/([\\/]+)$/i','',$path);
@@ -114,7 +115,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
$myarray[$key] = $row[$sortcriteria];
}
// Sort the data
array_multisort($myarray, $sortorder, $file_list);
if ($sortorder) array_multisort($myarray, $sortorder, $file_list);
return $file_list;
}