From 46ad8917ad8486f3a789ee07c92e98d3a1b60f73 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Oct 2010 15:50:34 +0000 Subject: [PATCH] Perf: A little speed enhancement on document tabs. --- htdocs/adherents/document.php | 2 +- htdocs/comm/action/document.php | 2 +- htdocs/comm/mailing/fiche.php | 10 +++++----- htdocs/comm/propal/document.php | 2 +- htdocs/commande/document.php | 2 +- htdocs/compta/facture/document.php | 2 +- htdocs/contrat/document.php | 2 +- htdocs/fichinter/document.php | 2 +- htdocs/fourn/commande/document.php | 2 +- htdocs/fourn/facture/document.php | 2 +- htdocs/lib/files.lib.php | 1 + htdocs/product/document.php | 2 +- htdocs/projet/document.php | 2 +- htdocs/projet/tasks/document.php | 2 +- htdocs/societe/document.php | 2 +- 15 files changed, 19 insertions(+), 18 deletions(-) diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index 8da7a68ad09..688bcac2d33 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -139,7 +139,7 @@ if ($id > 0) // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),3); $totalsize=0; foreach($filearray as $key => $file) { diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index bca18b5712e..f12dd40f616 100755 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -202,7 +202,7 @@ if ($objectid > 0) print '
'; // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),3); $totalsize=0; foreach($filearray as $key => $file) { diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php index 4aaadcfb9ba..b9a9dd9e363 100644 --- a/htdocs/comm/mailing/fiche.php +++ b/htdocs/comm/mailing/fiche.php @@ -194,7 +194,7 @@ if ($_REQUEST["action"] == 'sendallconfirmed' && $_REQUEST['confirm'] == 'yes') $arr_name = array(); $arr_css = array(); - $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,1); + $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0); if (sizeof($listofpaths)) { foreach($listofpaths as $key => $val) @@ -324,7 +324,7 @@ if ($_POST["action"] == 'send' && empty($_POST["cancel"])) $arr_css = array(); // Attached files - $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,1); + $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0); if (sizeof($listofpaths)) { foreach($listofpaths as $key => $val) @@ -426,7 +426,7 @@ if (! empty($_POST["removedfile"])) $upload_dir = $conf->mailing->dir_output . "/" . get_exdir($mil->id,2,0,1); - $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,1); + $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0); // Remove file $filenb=($_POST["removedfile"]-1); @@ -879,7 +879,7 @@ else //$property='joined_file'.$i; print ''; print '
'.$langs->trans("MailFile").' '.$i.''; // List of files - $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,1); + $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0); if (sizeof($listofpaths)) { foreach($listofpaths as $key => $val) @@ -966,7 +966,7 @@ else print '
'.$langs->trans("MailFile").' '.$i.''; // List of files - $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,1); + $listofpaths=dol_dir_list($upload_dir,'all',0,'','','name',SORT_ASC,0); if (sizeof($listofpaths)) { foreach($listofpaths as $key => $val) diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 337acb8bdf1..66c715e9f7f 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -144,7 +144,7 @@ if ($id > 0 || ! empty($ref)) // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),3); $totalsize=0; foreach($filearray as $key => $file) { diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 26ee9202c61..abe08c4701a 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -136,7 +136,7 @@ if ($id > 0 || ! empty($ref)) // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),3); $totalsize=0; foreach($filearray as $key => $file) { diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 85473925b98..06887448d30 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -146,7 +146,7 @@ if ($id > 0 || ! empty($ref)) // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),3); $totalsize=0; foreach($filearray as $key => $file) { diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 9187a4f34b4..369f9272b35 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -133,7 +133,7 @@ if ($contrat->id) // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),3); $totalsize=0; foreach($filearray as $key => $file) { diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index a142ac023e2..d3a3b0bba3c 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -132,7 +132,7 @@ if ($object->id) // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),3); $totalsize=0; foreach($filearray as $key => $file) { diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index 3b034ab03d6..777e9aa2822 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -143,7 +143,7 @@ if ($id > 0 || ! empty($ref)) // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),3); $totalsize=0; foreach($filearray as $key => $file) { diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index b28df21a4b7..d142fc7ac37 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -138,7 +138,7 @@ if ($facid > 0) // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),3); $totalsize=0; foreach($filearray as $key => $file) { diff --git a/htdocs/lib/files.lib.php b/htdocs/lib/files.lib.php index c1dbb6442a3..0c8ab3a2083 100644 --- a/htdocs/lib/files.lib.php +++ b/htdocs/lib/files.lib.php @@ -93,6 +93,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil // 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( diff --git a/htdocs/product/document.php b/htdocs/product/document.php index b0f71d5aa6f..5b5c19e683d 100755 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -136,7 +136,7 @@ if ($product->id) // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),3); $totalsize=0; foreach($filearray as $key => $file) { diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index db64340449b..763c204acb5 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -136,7 +136,7 @@ if ($id > 0 || ! empty($ref)) dol_fiche_head($head, 'document', $langs->trans("Project"), 0, ($project->public?'projectpub':'project')); // Files list constructor - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),3); $totalsize=0; foreach($filearray as $key => $file) { diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index c9ff1e76cae..a9869e30e5a 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -146,7 +146,7 @@ if ($id > 0 || ! empty($ref)) dol_fiche_head($head, 'document', $langs->trans("Task"), 0, 'projecttask'); // Files list constructor - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),3); $totalsize=0; foreach($filearray as $key => $file) { diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index ae8f8e340b4..e7f5becfad0 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -136,7 +136,7 @@ if ($socid > 0) // Construit liste des fichiers - $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),3); $totalsize=0; foreach($filearray as $key => $file) {