diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php
index a7ae78882d0..d2130845bf7 100644
--- a/htdocs/core/ajax/ajaxdirpreview.php
+++ b/htdocs/core/ajax/ajaxdirpreview.php
@@ -22,10 +22,10 @@
*/
/**
- * \file htdocs/filemanager/ajaxshowpreview.php
- * \brief Service to return a HTML preview of a file
+ * \file htdocs/core/ajax/ajaxdirpreview.php
+ * \brief Service to return a HTML preview of a directory
* Call of this service is made with URL:
- * ajaxpreview.php?action=preview&modulepart=repfichierconcerne&file=pathrelatifdufichier
+ * ajaxdirpreview.php?mode=nojs&action=preview&module=ecm§ion=0&file=xxx
*/
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
@@ -33,11 +33,45 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
-// C'est un wrapper, donc header vierge
-function llxHeader() { }
+if (! isset($mode) || $mode != 'noajax')
+{
+ require_once("../../main.inc.php");
+ require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
+ require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php');
+ require_once(DOL_DOCUMENT_ROOT."/ecm/class/ecmdirectory.class.php");
-require("../../main.inc.php");
-require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
+ $action=GETPOST("action");
+ $file=urldecode(GETPOST('file'));
+ $section=GETPOST("section");
+ $module=GETPOST("module");
+ $urlsource=GETPOST("urlsource");
+
+ $upload_dir = dirname(str_replace("../","/", $conf->ecm->dir_output.'/'.$file));
+
+ $ecmdir = new EcmDirectory($db);
+ $result=$ecmdir->fetch($section);
+ if (! $result > 0)
+ {
+ dol_print_error($db,$ecmdir->error);
+ exit;
+ }
+}
+else
+{
+ $ecmdir = new EcmDirectory($db);
+ $relativepath='';
+ if ($section > 0)
+ {
+ $result=$ecmdir->fetch($section);
+ if (! $result > 0)
+ {
+ dol_print_error($db,$ecmdir->error);
+ exit;
+ }
+ }
+ $relativepath=$ecmdir->getRelativePath();
+ $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
+}
// Load traductions files
$langs->load("ecm");
@@ -47,371 +81,189 @@ $langs->load("other");
// Security check
if ($user->societe_id > 0) $socid = $user->societe_id;
-// Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
-$action=GETPOST("action");
-$file=urldecode(GETPOST('file'));
-$section=GETPOST("section");
-$module=GETPOST("module");
-$urlsource=GETPOST("urlsource");
-if (! $section)
-{
- dol_print_error('',"ErrorSectionParamNotDefined");
- exit;
-}
-
-// Suppression de la chaine de caractere ../ dans $original_file
-$original_file = str_replace("../","/", $file);
-$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset
+//print 'xxx'.$upload_dir;
// Security:
// On interdit les remontees de repertoire ainsi que les pipe dans
// les noms de fichiers.
-if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file))
+if (preg_match('/\.\./',$upload_dir) || preg_match('/[<>|]/',$upload_dir))
{
- dol_syslog("Refused to deliver file ".$original_file);
+ dol_syslog("Refused to deliver file ".$upload_dir);
// Do no show plain path in shown error message
- dol_print_error(0,$langs->trans("ErrorFileNameInvalid",$_GET["file"]));
+ dol_print_error(0,$langs->trans("ErrorFileNameInvalid",$upload_dir));
exit;
}
-// Load ecm object
-/*$ecmdir = new EcmDirectory($db);
- $result=$ecmdir->fetch(GETPOST("section"));
-if (! $result > 0)
-{
-dol_print_error($db,$ecmdir->error);
-exit;
-}
-$relativepath=$ecmdir->getRelativePath();
-$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
-*/
-
/*
* Action
*/
-if ($action == 'remove_file') // Remove a file
+/*
+ if ($action == 'remove_file') // Remove a file
{
- clearstatcache();
+clearstatcache();
- dol_syslog(__FILE__." remove $original_file $urlsource", LOG_DEBUG);
+dol_syslog(__FILE__." remove $original_file $urlsource", LOG_DEBUG);
- // This test should be useless. We keep it to find bug more easily
- if (! file_exists($original_file_osencoded))
- {
- dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$_GET["file"]));
- exit;
- }
-
- dol_delete_file($original_file);
-
- dol_syslog(__FILE__." back to ".urldecode($urlsource), LOG_DEBUG);
-
- header("Location: ".urldecode($urlsource));
-
- return;
+// This test should be useless. We keep it to find bug more easily
+if (! file_exists($original_file_osencoded))
+{
+dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$_GET["file"]));
+exit;
}
+dol_delete_file($original_file);
+
+dol_syslog(__FILE__." back to ".urldecode($urlsource), LOG_DEBUG);
+
+header("Location: ".urldecode($urlsource));
+
+return;
+}
+*/
/*
* View
*/
-// Ajout directives pour resoudre bug IE
-header('Cache-Control: Public, must-revalidate');
-header('Pragma: public');
-
-$filename = basename($original_file_osencoded);
-$sizeoffile = filesize($original_file_osencoded);
-
-if (dol_is_dir($original_file))
+if (! isset($mode) || $mode != 'noajax')
{
- $type='directory';
-}
-else
-{
- // Define mime type
- $type = 'application/octet-stream';
- if (GETPOST("type") != 'auto') $type=$_GET["type"];
- else $type=dol_mimetype($original_file,'text/plain');
- //print 'X'.$type.'-'.$original_file;exit;
+ // Ajout directives pour resoudre bug IE
+ header('Cache-Control: Public, must-revalidate');
+ header('Pragma: public');
}
-clearstatcache();
-
-// Output file on browser
-dol_syslog("document.php download $original_file $filename content-type=$type");
+$type='directory';
// This test if file exists should be useless. We keep it to find bug more easily
-if (! file_exists($original_file_osencoded))
+if (! dol_is_dir($upload_dir))
{
- dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file));
+ $langs->load("install");
+ dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir));
exit;
}
print ''."\n";
-print ''."\n";
print ''."\n";
-// Les drois sont ok et fichier trouve, et fichier texte, on l'envoie
-print ''.$langs->trans("Information").' ';
-print '
';
// Dir
if ($type == 'directory')
{
- print '';
- print ''.$langs->trans("Directory").': '.$original_file.' ';
+ $formfile=new FormFile($db);
- //print $langs->trans("FullPath").': '.$original_file_osencoded.' ';
- //print $langs->trans("Mime-type").': '.$type.' ';
+ $param=($sortfield?'&sortfield='.$sortfield:'').($sortorder?'&sortorder='.$sortorder:'');
+ $maxlengthname=40;
- $info=stat($original_file_osencoded);
- //print ' '."\n";
- //print $langs->trans("Owner").": ".$info['udi']." \n";
- //print $langs->trans("Group").": ".$info['gdi']." \n";
- //print $langs->trans("Size").": ".dol_print_size($info['size'])." \n";
- print ''.$langs->trans("DateLastAccess").': '.dol_print_date($info['atime'],'%Y-%m-%d %H:%M:%S')." \n";
- print ''.$langs->trans("DateLastChange").': '.dol_print_date($info['mtime'],'%Y-%m-%d %H:%M:%S')." \n";
- //print $langs->trans("Ctime").": ".$info['ctime']." \n";
- print '
'."\n";
-
- print ' ';
- print ''.$langs->trans("Content")." \n";
- print ' ';
-
- print ''."\n";
-
- // Return content of dir
- $dircontent=dol_dir_list($original_file,'all',0,'','','name',SORT_ASC,0);
- foreach($dircontent as $key => $val)
+ // Right area
+ if ($module == 'company') // Auto area for suppliers invoices
{
- if (dol_is_dir($val['name'])) $mimeimg='other.png';
- else $mimeimg=dol_mimetype($val['name'],'application/octet-stream',2);
+ $upload_dir = $conf->societe->dir_output;
+ $filearray=dol_dir_list($upload_dir,"files",1,'',array('^SPECIMEN\.pdf$','^\.','\.meta$','^temp$','^payments$','^CVS$','^thumbs$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
- print '';
- print ' ';
- print ' ';
- print dol_nl2br(dol_trunc($val['name'],24,'wrap'),1);
- print ' '."\n";
+ $param.='&module='.$module;
+ $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound")));
+
+ $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,$maxlengthname);
+ }
+ 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$','^thumbs$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
+
+ $param.='&module='.$module;
+ $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound")));
+
+ $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,$maxlengthname);
+ }
+ else if ($module == 'invoice_supplier') // Auto area for suppliers invoices
+ {
+ $relativepath='facture';
+ $upload_dir = $conf->fournisseur->dir_output.'/'.$relativepath;
+ $filearray=dol_dir_list($upload_dir,"files",1,'',array('^SPECIMEN\.pdf$','^\.','\.meta$','^temp$','^CVS$','^thumbs$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
+
+ $param.='&module='.$module;
+ $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound")));
+
+ $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,$maxlengthname);
+ }
+ else if ($module == 'propal') // Auto area for customers orders
+ {
+ $upload_dir = $conf->propal->dir_output;
+ $filearray=dol_dir_list($upload_dir,"files",1,'',array('^SPECIMEN\.pdf$','^\.','\.meta$','^temp$','^payments$','^CVS$','^thumbs$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
+
+ $param.='&module='.$module;
+ $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound")));
+
+ $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,$maxlengthname);
+ }
+ else if ($module == 'order') // Auto area for customers orders
+ {
+ $upload_dir = $conf->commande->dir_output;
+ $filearray=dol_dir_list($upload_dir,"files",1,'',array('^SPECIMEN\.pdf$','^\.','\.meta$','^temp$','^payments$','^CVS$','^thumbs$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
+
+ $param.='&module='.$module;
+ $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound")));
+
+ $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,$maxlengthname);
+ }
+ else if ($module == 'order_supplier') // Auto area for suppliers orders
+ {
+ $relativepath='commande';
+ $upload_dir = $conf->fournisseur->dir_output.'/'.$relativepath;
+ $filearray=dol_dir_list($upload_dir,"files",1,'',array('^SPECIMEN\.pdf$','^\.','\.meta$','^temp$','^payments$','^CVS$','^thumbs$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
+
+ $param.='&module='.$module;
+ $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound")));
+
+ $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,$maxlengthname);
+ }
+ else if ($module == 'contract') // Auto area for suppliers invoices
+ {
+ $upload_dir = $conf->contrat->dir_output;
+ $filearray=dol_dir_list($upload_dir,"files",1,'',array('^SPECIMEN\.pdf$','^\.','\.meta$','^temp$','^CVS$','^thumbs$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
+
+ $param.='&module='.$module;
+ $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound")));
+
+ $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,$maxlengthname);
+ }
+ else if ($module == 'tax') // Auto area for suppliers invoices
+ {
+ $upload_dir = $conf->tax->dir_output;
+ $filearray=dol_dir_list($upload_dir,"files",1,'',array('^SPECIMEN\.pdf$','^\.','\.meta$','^temp$','^CVS$','^thumbs$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
+
+ $param.='&module='.$module;
+ $textifempty=($section?$langs->trans("NoFileFound"):($showonrightsize=='featurenotyetavailable'?$langs->trans("FeatureNotYetAvailable"):$langs->trans("NoFileFound")));
+
+ $formfile->list_of_autoecmfiles($upload_dir,$filearray,$module,$param,1,'',$user->rights->ecm->upload,1,$textifempty,$maxlengthname);
+ }
+ else // Manual area
+ {
+
+ $relativepath=$ecmdir->getRelativePath();
+ $upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
+ $filearray=dol_dir_list($upload_dir,"files",0,'',array('^\.','\.meta$','^temp$','^CVS$'),$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
+
+ $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,$maxlengthname);
}
- print ' '."\n";
-}
-else {
- print '';
- print ''.$langs->trans("File").': '.$original_file.' ';
- print ''.$langs->trans("Mime-type").': '.$type.' ';
- print ''.$langs->trans("Download").' ';
- print ' ';
-
- $info=stat($original_file_osencoded);
- //print ' '."\n";
- //print $langs->trans("Owner").": ".$info['udi']." \n";
- //print $langs->trans("Group").": ".$info['gdi']." \n";
- print ''.$langs->trans("Size").': '.dol_print_size($info['size'])." \n";
- print ''.$langs->trans("DateLastAccess").': '.dol_print_date($info['atime'],'%Y-%m-%d %H:%M:%S')." \n";
- print ''.$langs->trans("DateLastChange").': '.dol_print_date($info['mtime'],'%Y-%m-%d %H:%M:%S')." \n";
- //print $langs->trans("Ctime").": ".$info['ctime']." \n";
- $sizearray=array();
- if (preg_match('/image/i',$type))
- {
- require_once(DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php');
- $sizearray=dol_getImageSize($original_file_osencoded);
- print ''.$langs->trans("Width").': '.$sizearray['width'].'px ';
- print ''.$langs->trans("Height").': '.$sizearray['height'].'px ';
- }
- print '
'."\n";
-
- // Flush content before preview generation
- flush(); // This send all data to browser. Browser however may wait to have message complete or aborted before showing it.
-
-
- // Preview
- $preview=0;
- if (preg_match('/text/i',$type))
- {
- $minmem=64; // Minimum of memory required to use Geshi (color syntax on text files)
- $maxsize=65536; // Max size of data to read for text preview
-
- // Define memmax (memory_limit in bytes)
- $memmaxorig=@ini_get("memory_limit");
- $memmax=@ini_get("memory_limit");
- if ($memmaxorig != '')
- {
- preg_match('/([0-9]+)([a-zA-Z]*)/i',$memmax,$reg);
- if ($reg[2])
- {
- if (strtoupper($reg[2]) == 'M') $memmax=$reg[1]*1024*1024;
- if (strtoupper($reg[2]) == 'K') $memmax=$reg[1]*1024;
- }
- }
- //print "memmax php=".$memmax;
-
- $out='';
- $srclang=dol_mimetype($original_file,'text/plain',3);
-
- if (preg_match('/html/i',$type)) // If HTML file
- {
- print ' ';
- print ''.$langs->trans("Preview")." \n";
- print ' ';
-
- readfile($original_file_osencoded);
- //$out=file_get_contents($original_file_osencoded);
- //print $out;
- }
- else // If not a HTML file
- {
- $warn='';
-
- // Check if we have enough memory for Geshi
- if ($memmax < $minmem*1024*1024)
- {
- $warn=img_warning().' '.$langs->trans("NotEnoughMemoryForSyntaxColor");
- $warn.=' (Have '.$memmax.' - Need '.$minmem.')';
- $srclang=''; // We disable geshi
- }
-
- if (empty($conf->global->FILEMANAGER_DISABLE_COLORSYNTAXING))
- {
- $warn=' ('.$langs->trans("ColoringDisabled").')';
- $srclang=''; // We disable geshi
- }
-
- // Try to detect srclang using first line
- if ($type=='text/plain' && empty($srclang)) // Try to enhance MIME detection with first line content
- {
- $firstline=file_get_contents($original_file_osencoded,false,null,0,32);
- $texts = preg_split("/((\r(?!\n))|((?'bash', 'sh'=>'bash', 'bash'=>'bash');
- $srclang=$converttogeshicode[$reg[1]]?$converttogeshicode[$reg[1]]:$reg[1];
- //print "ee".$srclang;
- }
- }
- if ($srclang=='php') $srclang='php-brief';
- //if ($srclang=='perl') $srclang=''; // Perl seems to be bugged
-
- if (! empty($srclang))
- {
- print ' ';
- print ''.$langs->trans("Preview")." (".$srclang.") \n";
- print ' ';
-
- // Translate with Geshi
- include_once('includes/geshi/geshi.php');
-
- $out=file_get_contents($original_file_osencoded,false,null,0,$maxsize);
- if (! utf8_check($out)) { $isoutf='iso'; $out=utf8_encode($out); }
-
- $geshi = new GeSHi($out, $srclang);
- $geshi->enable_strict_mode(true);
- $res='';
- $res=$geshi->parse_code();
-
- //print "zzzzzzzz";
- print $res;
- }
- else
- {
- print ' ';
- print ''.$langs->trans("Preview")." ";
- if ($warn) print ' '.$warn;
- print " \n";
- print ' ';
-
- $maxlines=25;
- $i=0;$more=0;
- $handle = @fopen($original_file_osencoded, "r");
- if ($handle)
- {
- while (!feof($handle) && $i < $maxlines)
- {
- $buffer = fgets($handle, $maxsize);
- if (utf8_check($buffer)) $out.=$buffer." \n";
- else $out.=utf8_encode($buffer)." \n";
- $i++;
- }
- if (!feof($handle)) $more=1;
- fclose($handle);
- }
- else
- {
- print ''.$langs->trans("ErrorFailedToOpenFile",$original_file).'
';
- }
-
- print $out;
-
- print ' ';
-
- if ($more)
- {
- print '...'.$langs->trans("More").'... '."\n";
- }
- }
- }
- $preview=1;
- }
- // Preview if image
- if (preg_match('/image/i',$type))
- {
- print ' ';
- print ''.$langs->trans("Preview")." \n";
- print ' ';
-
-
- print ' 500) print ' width="500"';
- print ' src="'.dol_buildpath('/filemanager/viewimage.php',1).'?modulepart=filemanager&file='.urlencode($original_file).'"> ';
- $preview=1;
- }
- // Preview if video
- if (preg_match('/video/i',$type))
- {
- $typecodec='';
- if (preg_match('/ogg/i',$type)) $typecodec=' type=\'video/ogg; codecs="theora, vorbis"\''; // This works with HTML5 video
- //if (preg_match('/msvideo/i',$type)) $typecodec=' type=\'video/x-msvideo;\''; // AVI
- //if (preg_match('/webm/i',$type)) $typecodec=' type=\'video/webm; codecs="vp8, vorbis"\'';
- //if (preg_match('/mp4/i',$type)) $typecodec=' type=\'video/mp4; codecs="avc1.42E01E, mp4a.40.2"\'';
-
- if ($typecodec)
- {
- print ' ';
- print ''.$langs->trans("Preview")." \n";
- print ' ';
-
- print '';
- print '';
- print ' ';
- print ' ';
- print ' ';
- /*';*/
- $preview=1;
- }
- }
- // No preview
- if (empty($preview))
- {
- print ' ';
- print ''.$langs->trans("Preview")." \n";
- print ' ';
-
- print $langs->trans("PreviewNotAvailableForThisType");
- }
}
-if (is_object($db)) $db->close();
+if ((! isset($mode) || $mode != 'noajax') && ! empty($conf->global->MAIN_ECM_TRY_JS))
+{
+ // Enable jquery handlers on new generated HTML objects
+ print "\n".''."\n";
+
+ if (is_object($db)) $db->close();
+}
+
?>
diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php
index f3b07de5a3c..e3f0f17850c 100644
--- a/htdocs/core/ajax/ajaxdirtree.php
+++ b/htdocs/core/ajax/ajaxdirtree.php
@@ -33,9 +33,6 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
-// C'est un wrapper, donc header vierge
-function llxHeader() { }
-
$res=@include("../../main.inc.php");
include_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php');
include_once(DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php');
@@ -107,7 +104,7 @@ if( file_exists($fullpathselecteddir) )
echo "\n";
// All dirs
- foreach( $files as $file ) // $file can be '.', '..', or 'My dir'
+ foreach( $files as $file ) // $file can be '.', '..', or 'My dir' or 'My file'
{
$nbofsubdir=0;
$nboffilesinsubdir=0;
@@ -129,16 +126,16 @@ if( file_exists($fullpathselecteddir) )
}
//if (file_exists($fullpathselecteddir . $file) && $file != '.' && $file != '..' && is_dir($fullpathselecteddir . $file))
- if ($file != '.' && $file != '..' && ($val['id'] >= 0 || dol_is_dir($fullpathselecteddir . $file)))
+ if ($file != '.' && $file != '..' && ((! empty($val['fullrelativename']) && $val['id'] >= 0) || dol_is_dir($fullpathselecteddir . $file)))
{
print '';
- print "";
print dol_escape_htmltag($file);
print " ";
- print '';
+ print '
';
print '
';
@@ -148,7 +145,7 @@ if( file_exists($fullpathselecteddir) )
// Nb of docs
print '';
- print $val['cachenbofdoc'];
+ print isset($val['cachenbofdoc'])?$val['cachenbofdoc']:' ';
print ' ';
print '';
if ($nbofsubdir && $nboffilesinsubdir) print '+'.$nboffilesinsubdir.' ';
@@ -173,7 +170,7 @@ if( file_exists($fullpathselecteddir) )
$htmltooltip.=''.$langs->trans("ECMNbOfFilesInDir").' : '.$val['cachenbofdoc'].' ';
if ($nbofsubdir) $htmltooltip.=''.$langs->trans("ECMNbOfFilesInSubDir").' : '.$nboffilesinsubdir;
else $htmltooltip.=''.$langs->trans("ECMNbOfSubDir").' : '.$nbofsubdir.' ';
- print $form->textwithpicto('',$htmltooltip,1,0);
+ print $form->textwithpicto('',$htmltooltip,1,"info");
print " ";
print "
\n";
@@ -184,25 +181,14 @@ if( file_exists($fullpathselecteddir) )
}
}
- // All files
- /*
- foreach( $files as $file )
- {
- if( file_exists($fullpathselecteddir . $file) && $file != '.' && $file != '..' && !is_dir($fullpathselecteddir . $file) )
- {
- $ext = preg_replace('/^.*\./', '', $file);
- print "
";
- print "" . dol_escape_htmltag($file) . " ";
- print " \n";
- }
- }
- */
-
- // Enable tooltips
+ // Enable jquery handlers on new generated HTML objects
print '';
echo "\n";
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index bbd1cc108b1..1eee2e85b70 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -78,8 +78,9 @@ class FormFile
if (empty($title)) $title=$langs->trans("AttachANewFile");
if ($title != 'none') print_titre($title);
- print '