New: add hook 'getDirList' in dol_dir_list() method
This commit is contained in:
parent
f056ca3a41
commit
6bd571b31a
@ -321,6 +321,8 @@ print '</form>';
|
|||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
|
|
||||||
// Form to test upload
|
// Form to test upload
|
||||||
print '<br>';
|
print '<br>';
|
||||||
$formfile=new FormFile($db);
|
$formfile=new FormFile($db);
|
||||||
|
|||||||
@ -51,8 +51,20 @@ function dol_basename($pathfile)
|
|||||||
*/
|
*/
|
||||||
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
|
function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter="", $sortcriteria="name", $sortorder=SORT_ASC, $mode=0)
|
||||||
{
|
{
|
||||||
|
global $db, $hookmanager;
|
||||||
|
|
||||||
dol_syslog("files.lib.php::dol_dir_list path=".$path." types=".$types." recursive=".$recursive." filter=".$filter." excludefilter=".json_encode($excludefilter));
|
dol_syslog("files.lib.php::dol_dir_list path=".$path." types=".$types." recursive=".$recursive." filter=".$filter." excludefilter=".json_encode($excludefilter));
|
||||||
|
|
||||||
|
if (! is_object($hookmanager))
|
||||||
|
{
|
||||||
|
if (! class_exists('HookManager')) {
|
||||||
|
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||||
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
|
$hookmanager=new HookManager($db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$hookmanager->initHooks(array('fileslib'));
|
||||||
|
|
||||||
$loaddate=($mode==1||$mode==2)?true:false;
|
$loaddate=($mode==1||$mode==2)?true:false;
|
||||||
$loadsize=($mode==1||$mode==3)?true:false;
|
$loadsize=($mode==1||$mode==3)?true:false;
|
||||||
|
|
||||||
@ -60,6 +72,25 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
|
|||||||
$path=preg_replace('/([\\/]+)$/i','',$path);
|
$path=preg_replace('/([\\/]+)$/i','',$path);
|
||||||
$newpath=dol_osencode($path);
|
$newpath=dol_osencode($path);
|
||||||
|
|
||||||
|
$parameters=array(
|
||||||
|
'path' => $newpath,
|
||||||
|
'types'=> $types,
|
||||||
|
'recursive' =>$recursive,
|
||||||
|
'filter' => $filter,
|
||||||
|
'excludefilter' => $excludefilter,
|
||||||
|
'sortcriteria' => $sortcriteria,
|
||||||
|
'sortorder' => $sortorder,
|
||||||
|
'loaddate' => $loaddate,
|
||||||
|
'loadsize' => $loadsize
|
||||||
|
);
|
||||||
|
$file_list=$hookmanager->executeHooks('getDirList', $parameters);
|
||||||
|
|
||||||
|
if (is_array($file_list))
|
||||||
|
{
|
||||||
|
return $file_list;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (! is_dir($newpath)) return array();
|
if (! is_dir($newpath)) return array();
|
||||||
|
|
||||||
if ($dir = opendir($newpath))
|
if ($dir = opendir($newpath))
|
||||||
@ -84,7 +115,9 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
|
|||||||
// Check if file is qualified
|
// Check if file is qualified
|
||||||
foreach($excludefilterarray as $filt)
|
foreach($excludefilterarray as $filt)
|
||||||
{
|
{
|
||||||
if (preg_match('/'.$filt.'/i',$file)) { $qualified=0; break; }
|
if (preg_match('/'.$filt.'/i',$file)) {
|
||||||
|
$qualified=0; break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($qualified)
|
if ($qualified)
|
||||||
@ -157,6 +190,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
|
|||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fast compare of 2 files identified by their properties ->name, ->date and ->size
|
* Fast compare of 2 files identified by their properties ->name, ->date and ->size
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user