From e6663c8f6e19e0886bb4bffe293a0dad03928d50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Wed, 6 Jul 2011 21:12:33 +0000 Subject: [PATCH] Fix: Bad order on documents pages --- htdocs/core/class/html.formfile.class.php | 6 ++--- htdocs/ecm/index.php | 12 +++++----- htdocs/lib/functions.lib.php | 27 ++++++++++++++--------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index ccd1f8bee5e..e6ac2d294b9 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -22,7 +22,7 @@ * \file htdocs/core/class/html.formfile.class.php * \ingroup core * \brief File of class to offer components to list and upload files - * \version $Id: html.formfile.class.php,v 1.45 2011/07/06 17:44:56 eldy Exp $ + * \version $Id: html.formfile.class.php,v 1.46 2011/07/06 21:12:34 eldy Exp $ */ @@ -623,8 +623,8 @@ class FormFile } // Delete or view link print '<td align="right">'; - if (! empty($useinecm)) print '<a href="'.DOL_URL_ROOT.'/ecm/docfile.php?section='.$_REQUEST["section"].'&urlfile='.urlencode($file['name']).'">'.img_view().'</a> '; - if ($permtodelete) print '<a href="'.$url.'?id='.$object->id.'§ion='.$_REQUEST["section"].'&action=delete&urlfile='.urlencode($file['name']).'">'.img_delete().'</a>'; + if (! empty($useinecm)) print '<a href="'.DOL_URL_ROOT.'/ecm/docfile.php?urlfile='.urlencode($file['name']).$param.'">'.img_view().'</a> '; + if ($permtodelete) print '<a href="'.$url.'?id='.$object->id.'&action=delete&urlfile='.urlencode($file['name']).$param.'">'.img_delete().'</a>'; else print ' '; print "</td>"; print "</tr>\n"; diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 35cdb9fb64e..523dcb1ea90 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -21,7 +21,7 @@ * \file htdocs/ecm/index.php * \ingroup ecm * \brief Main page for ECM section area - * \version $Id: index.php,v 1.100 2011/07/06 20:56:49 eldy Exp $ + * \version $Id: index.php,v 1.101 2011/07/06 21:12:34 eldy Exp $ * \author Laurent Destailleur */ @@ -800,6 +800,8 @@ else $formfile=new FormFile($db); +$param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:''); + // Right area if ($module == 'invoice_supplier') // Auto area for suppliers invoices { @@ -807,7 +809,7 @@ if ($module == 'invoice_supplier') // Auto area for suppliers invoices $upload_dir = $conf->fournisseur->dir_output.'/'.$relativepath; $filearray=dol_dir_list($upload_dir,"files",1,'',array('^SPECIMEN\.pdf$','^\.','\.meta$','^temp$','^CVS$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); - $param='&module='.$module; + $param.='&module='.$module; $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection"))); $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,40); @@ -817,7 +819,7 @@ else if ($module == 'invoice') // Auto area for suppliers invoices $upload_dir = $conf->facture->dir_output; $filearray=dol_dir_list($upload_dir,"files",1,'',array('^SPECIMEN\.pdf$','^\.','\.meta$','^temp$','^payments$','^CVS$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); - $param='&module='.$module; + $param.='&module='.$module; $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection"))); $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,40); @@ -828,7 +830,7 @@ else // Manual area $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; $filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','\.meta$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); - $param='&section='.$section; + $param.='§ion='.$section; $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("ECMSelectASection"))); $formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty,40); @@ -887,5 +889,5 @@ else // End of page $db->close(); -llxFooter('$Date: 2011/07/06 20:56:49 $ - $Revision: 1.100 $'); +llxFooter('$Date: 2011/07/06 21:12:34 $ - $Revision: 1.101 $'); ?> diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 0ffdc176611..1ee21155c31 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -29,7 +29,7 @@ * \file htdocs/lib/functions.lib.php * \brief A set of functions for Dolibarr * This file contains all frequently used functions. - * \version $Id: functions.lib.php,v 1.540 2011/07/06 17:43:33 eldy Exp $ + * \version $Id: functions.lib.php,v 1.541 2011/07/06 21:12:33 eldy Exp $ */ // For compatibility during upgrade @@ -2542,12 +2542,12 @@ function dol_print_error_email() * @param file Url used when we click on sort picto * @param field Field to use for new sorting * @param begin ("" by defaut) - * @param options ("" by defaut) + * @param moreparam Add more parameters on sort url links ("" by default) * @param td Options of attribute td ("" by defaut) * @param sortfield Current field used to sort * @param sortorder Current sort order */ -function print_liste_field_titre($name, $file="", $field="", $begin="", $options="", $td="", $sortfield="", $sortorder="") +function print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $td="", $sortfield="", $sortorder="") { global $conf; //print "$name, $file, $field, $begin, $options, $td, $sortfield, $sortorder<br>\n"; @@ -2567,29 +2567,34 @@ function print_liste_field_titre($name, $file="", $field="", $begin="", $options // If this is a sort field if ($field) { + $options=preg_replace('/sortfield=([a-zA-Z0-9,\s\.]+)/i','',$moreparam); + $options=preg_replace('/sortorder=([a-zA-Z0-9,\s\.]+)/i','',$options); + $options=preg_replace('/&+/i','&',$options); + if (! preg_match('/^&/',$options)) $options='&'.$options; + //print " "; print '<img width="2" src="'.DOL_URL_ROOT.'/theme/common/transparent.png" alt="">'; if (! $sortorder) { - print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>'; - print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>'; + print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>'; + print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>'; } else { if ($field != $sortfield) { - print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>'; - print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>'; + print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>'; + print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>'; } else { $sortorder=strtoupper($sortorder); if ($sortorder == 'DESC' ) { - print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>'; - print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",1).'</a>'; + print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",0).'</a>'; + print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",1).'</a>'; } if ($sortorder == 'ASC' ) { - print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",1).'</a>'; - print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>'; + print '<a href="'.$file.'?sortfield='.$field.'&sortorder=asc&begin='.$begin.$options.'">'.img_down("A-Z",1).'</a>'; + print '<a href="'.$file.'?sortfield='.$field.'&sortorder=desc&begin='.$begin.$options.'">'.img_up("Z-A",0).'</a>'; } } } -- GitLab