From 6861f1cda7eac8e15b7cea8d4b99fcae20f07ddb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Jul 2011 09:25:05 +0000 Subject: [PATCH] Enhancements in file upload --- htdocs/core/ajaxfileupload.php | 4 +- htdocs/core/class/html.formfile.class.php | 44 ++++++++++++------- htdocs/lib/files.lib.php | 16 +++---- htdocs/lib/functions.lib.php | 22 +++++----- htdocs/societe/document.php | 51 +---------------------- htdocs/theme/eldy/style.css.php | 32 +++++++++++++- 6 files changed, 84 insertions(+), 85 deletions(-) diff --git a/htdocs/core/ajaxfileupload.php b/htdocs/core/ajaxfileupload.php index 68199e8588d..2c964aa5a17 100644 --- a/htdocs/core/ajaxfileupload.php +++ b/htdocs/core/ajaxfileupload.php @@ -20,7 +20,7 @@ /** * \file htdocs/core/ajaxfileupload.php * \brief File to return Ajax response on file upload - * \version $Id: ajaxfileupload.php,v 1.8 2011/07/06 06:21:51 hregis Exp $ + * \version $Id: ajaxfileupload.php,v 1.9 2011/07/06 09:25:06 eldy Exp $ */ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); @@ -209,7 +209,7 @@ class UploadHandler FILE_APPEND ); } else { - move_uploaded_file($uploaded_file, $file_path); + dol_move_uploaded_file($uploaded_file, $file_path, 1); } } else { // Non-multipart uploads (PUT method support) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 4aa64bed577..b3792c9b612 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.40 2011/07/06 06:21:52 hregis Exp $ + * \version $Id: html.formfile.class.php,v 1.41 2011/07/06 09:25:06 eldy Exp $ */ @@ -548,9 +548,9 @@ class FormFile /** * Show list of documents in a directory - * @param filearray Array of files loaded by dol_dir_list function before calling this function + * @param filearray Array of files loaded by dol_dir_list('files') function before calling this * @param object Object on which document is linked to - * @param modulepart Value for modulepart used by download wrapper + * @param modulepart Value for modulepart used by download or viewimage wrapper * @param param Parameters on sort links * @param forcedownload Force to open dialog box "Save As" when clicking on file * @param relativepath Relative path of docs (autodefined if not provided) @@ -566,7 +566,7 @@ class FormFile global $bc; global $sortfield, $sortorder; - // Affiche liste des documents existant + // Show list of existing files if (empty($useinecm)) print_titre($langs->trans("AttachedFiles")); //else { $bc[true]=''; $bc[false]=''; }; $url=$_SERVER["PHP_SELF"]; @@ -575,14 +575,18 @@ class FormFile print_liste_field_titre($langs->trans("Documents2"),$_SERVER["PHP_SELF"],"name","",$param,'align="left"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Size"),$_SERVER["PHP_SELF"],"size","",$param,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("Date"),$_SERVER["PHP_SELF"],"date","",$param,'align="center"',$sortfield,$sortorder); + if (empty($useinecm)) print_liste_field_titre('',$_SERVER["PHP_SELF"],"","",$param,'align="center"'); print_liste_field_titre('','',''); print ''; + $nboffiles=sizeof($filearray); + + if ($nboffiles > 0) include_once(DOL_DOCUMENT_ROOT.'/lib/images.lib.php'); + $var=true; - foreach($filearray as $key => $file) + foreach($filearray as $key => $file) // filearray must be only files here { - if (!is_dir($dir.$file['name']) - && $file['name'] != '.' + if ($file['name'] != '.' && $file['name'] != '..' && $file['name'] != 'CVS' && ! preg_match('/\.meta$/i',$file['name'])) @@ -603,14 +607,25 @@ class FormFile print "\n"; print ''.dol_print_size($file['size'],1,1).''; print ''.dol_print_date($file['date'],"dayhour").''; + // Preview + if (empty($useinecm)) + { + print ''; + $pdirthumb='thumbs/'; + if (image_format_supported($file['name']) > 0) print ''; + else print ' '; + print ''; + } + // Delete or view link print ''; - if (! empty($useinecm)) print ''.img_view().'   '; + if (! empty($useinecm)) print ''.img_view().'   '; if ($permtodelete) print ''.img_delete().''; else print ' '; - print "\n"; + print ""; + print "\n"; } } - if (sizeof($filearray) == 0) + if ($nboffiles == 0) { print ''; if (empty($textifempty)) print $langs->trans("NoFileFound"); @@ -669,7 +684,7 @@ class FormFile $var=true; foreach($filearray as $key => $file) { - if (!is_dir($dir.$file['name']) + if (!is_dir($file['name']) && $file['name'] != '.' && $file['name'] != '..' && $file['name'] != 'CVS' @@ -828,15 +843,16 @@ class FormFile print '
'; print ''; - print ''; + /*print ''; print ''; print ''; print ''; print ''; - print ''; + print '';*/ print '
'.$langs->trans("Documents2").''.$langs->trans("Preview").''.$langs->trans("Size").'
'; - print '
'; + // We remove this because there is already individual bars. + //print '
'; print '
'; print ''; diff --git a/htdocs/lib/files.lib.php b/htdocs/lib/files.lib.php index 35ce31d0bc8..4e63a2221a5 100644 --- a/htdocs/lib/files.lib.php +++ b/htdocs/lib/files.lib.php @@ -20,7 +20,7 @@ /** * \file htdocs/lib/files.lib.php * \brief Library for file managing functions - * \version $Id: files.lib.php,v 1.64 2011/07/05 16:10:57 hregis Exp $ + * \version $Id: files.lib.php,v 1.65 2011/07/06 09:25:06 eldy Exp $ */ /** @@ -192,6 +192,7 @@ function dol_compare_file($a, $b) * @param mode 0=Return full mime, 1=otherwise short mime string, 2=image for mime type, 3=source language * @return string Return a mime type family * (text/xxx, application/xxx, image/xxx, audio, video, archive) + * @see image_format_supported (images.lib.php) */ function dol_mimetype($file,$default='application/octet-stream',$mode=0) { @@ -459,7 +460,7 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1) */ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disablevirusscan=0, $uploaderrorcode=0, $notrigger=0) { - global $conf, $user, $langs; + global $conf, $user, $langs, $db; global $object; $file_name = $dest_file; @@ -492,7 +493,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable } // If we need to make a virus scan - if (empty($disablevirusscan) && file_exists($src_file) && $conf->global->MAIN_ANTIVIRUS_COMMAND) + if (empty($disablevirusscan) && file_exists($src_file) && ! empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) { require_once(DOL_DOCUMENT_ROOT.'/lib/security.lib.php'); require_once(DOL_DOCUMENT_ROOT.'/lib/antivir.class.php'); @@ -554,9 +555,10 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable { if (! empty($conf->global->MAIN_UMASK)) @chmod($file_name_osencoded, octdec($conf->global->MAIN_UMASK)); dol_syslog("Functions.lib::dol_move_uploaded_file Success to move ".$src_file." to ".$file_name." - Umask=".$conf->global->MAIN_UMASK, LOG_DEBUG); - + if (! $notrigger) { + if (! is_object($object)) $object=(object) 'dummy'; $object->src_file=$dest_file; // Appel des triggers @@ -566,7 +568,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable if ($result < 0) { $error++; $errors=$interface->errors; } // Fin appel triggers } - + return 1; // Success } else @@ -590,7 +592,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0) { global $conf, $user, $langs; global $object; - + //print "x".$file." ".$disableglob; $ok=true; $file_osencoded=dol_osencode($file); // New filename encoded in OS filesystem encoding charset @@ -606,7 +608,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0) if (! $notrigger) { $object->src_file=$file; - + // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($db); diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 5cda1373034..deee3fc1ed5 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.538 2011/07/04 10:33:56 eldy Exp $ + * \version $Id: functions.lib.php,v 1.539 2011/07/06 09:25:05 eldy Exp $ */ // For compatibility during upgrade @@ -807,7 +807,7 @@ function dolibarr_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$chec * @param year Year * @param gm 1=Input informations are GMT values, otherwise local to server TZ * @param check 0=No check on parameters (Can use day 32, etc...) - * @param isdst Dayling saving time + * @param isdst Dayling saving time * @return timestamp Date as a timestamp, '' if error * @see dol_print_date, dol_stringtotime */ @@ -2538,16 +2538,16 @@ function dol_print_error_email() /** * Show title line of an array - * @param name libelle champ - * @param file url pour clic sur tri - * @param field champ de tri - * @param begin ("" par defaut) - * @param options ("" par defaut) - * @param td options de l'attribut td ("" par defaut) - * @param sortfield field currently used to sort - * @param sortorder ordre du tri + * @param name Label of field + * @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 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="", $options="", $td="", $sortfield="", $sortorder="") { global $conf; //print "$name, $file, $field, $begin, $options, $td, $sortfield, $sortorder
\n"; diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 9a6495b4c6e..5aab83e3302 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -23,7 +23,7 @@ * \file htdocs/societe/document.php * \brief Tab for documents linked to third party * \ingroup societe - * \version $Id: document.php,v 1.34 2011/07/05 22:40:35 eldy Exp $ + * \version $Id: document.php,v 1.35 2011/07/06 09:25:06 eldy Exp $ */ require("../main.inc.php"); @@ -227,53 +227,6 @@ if ($socid > 0) $formfile->list_of_documents($filearray,$object,'societe',$param); print "

"; - - // Courriers - // Les courriers sont des documents speciaux generes par des scripts - // situes dans scripts/courrier. - // Voir Rodo - if (! empty($conf->global->MAIN_MODULE_EDITEUR)) - { - $filearray=array(); - $errorlevel=error_reporting(); - error_reporting(0); - $handle=opendir($courrier_dir); - error_reporting($errorlevel); - if (is_resource($handle)) - { - $i=0; - while (($file = readdir($handle))!==false) - { - if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') - { - $filearray[$i]=$file; - $i++; - } - } - closedir($handle); - } - - print ''; - print ''; - - $var=true; - foreach($filearray as $key => $file) - { - if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') - { - $var=!$var; - print "\n"; - - print ''; - print ''; - print "\n"; - } - } - print "
'.$langs->trans("Courriers").''.$langs->trans("Size").''.$langs->trans("Date").'
"; - $loc = "courrier/".get_exdir($socid); - echo ''.$file.''; - print "'.dol_print_size(dol_filesize($courrier_dir."/".$file)).''.dol_print_date(dol_filemtime($courrier_dir."/".$file),'dayhour').'
"; - } } else { @@ -288,6 +241,6 @@ else $db->close(); -llxFooter('$Date: 2011/07/05 22:40:35 $ - $Revision: 1.34 $'); +llxFooter('$Date: 2011/07/06 09:25:06 $ - $Revision: 1.35 $'); ?> diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index ba9e6e5e520..bc390481a9c 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -21,7 +21,7 @@ /** * \file htdocs/theme/eldy/style.css.php * \brief Fichier de style CSS du theme Eldy - * \version $Id: style.css.php,v 1.80 2011/07/01 23:08:25 eldy Exp $ + * \version $Id: style.css.php,v 1.81 2011/07/06 09:25:06 eldy Exp $ */ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language @@ -1114,7 +1114,7 @@ padding-right: 2px; } tr.liste_titre { -height: 16px; +height: 18px; background: #7699A9; background-image: url(); background-repeat: repeat-x; @@ -1883,3 +1883,31 @@ A.none, A.none:active, A.none:visited, A.none:hover { } span.cke_skin_kama { padding: 0 !important; } .cke_wrapper { padding: 4px !important; } + + +/* ============================================================================== */ +/* CKEditor */ +/* ============================================================================== */ + +.fileupload-content +{ + padding: 0 !important; +} +.ui-corner-br +{ + border-bottom-right-radius: 0 !important; +} +.ui-corner-bl +{ + border-bottom-left-radius: 0 !important; +} +.files td { + height: 18px !important; + padding: 0; +} +.files { + margin: 0px; +} +.template-upload { + height: 72px !important; +} \ No newline at end of file