Enhancements in file upload
This commit is contained in:
parent
d0e98414bb
commit
6861f1cda7
@ -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)
|
||||
|
||||
@ -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 '</tr>';
|
||||
|
||||
$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 "</td>\n";
|
||||
print '<td align="right">'.dol_print_size($file['size'],1,1).'</td>';
|
||||
print '<td align="center">'.dol_print_date($file['date'],"dayhour").'</td>';
|
||||
// Preview
|
||||
if (empty($useinecm))
|
||||
{
|
||||
print '<td align="center">';
|
||||
$pdirthumb='thumbs/';
|
||||
if (image_format_supported($file['name']) > 0) print '<img border="0" height="'.$maxheightmini.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&file='.urlencode($pdirthumb.$file['name']).'" title="">';
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
}
|
||||
// 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 (! 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>';
|
||||
else print ' ';
|
||||
print "</td></tr>\n";
|
||||
print "</td>";
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
if (sizeof($filearray) == 0)
|
||||
if ($nboffiles == 0)
|
||||
{
|
||||
print '<tr '.$bc[$var].'><td colspan="4">';
|
||||
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 '<div class="fileupload-content">';
|
||||
|
||||
print '<table width="100%" class="files">';
|
||||
print '<tr class="liste_titre">';
|
||||
/*print '<tr>';
|
||||
print '<td>'.$langs->trans("Documents2").'</td>';
|
||||
print '<td>'.$langs->trans("Preview").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Size").'</td>';
|
||||
print '<td colspan="3"></td>';
|
||||
print '</tr>';
|
||||
print '</tr>';*/
|
||||
print '</table>';
|
||||
|
||||
print '<div class="fileupload-progressbar"></div>';
|
||||
// We remove this because there is already individual bars.
|
||||
//print '<div class="fileupload-progressbar"></div>';
|
||||
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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<br>\n";
|
||||
|
||||
@ -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 "<br><br>";
|
||||
|
||||
// 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 '<table width="100%" class="noborder">';
|
||||
print '<tr class="liste_titre"><td>'.$langs->trans("Courriers").'</td><td align="right">'.$langs->trans("Size").'</td><td align="center">'.$langs->trans("Date").'</td></tr>';
|
||||
|
||||
$var=true;
|
||||
foreach($filearray as $key => $file)
|
||||
{
|
||||
if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
|
||||
{
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]><td>";
|
||||
$loc = "courrier/".get_exdir($socid);
|
||||
echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart=societe&attachment=1&file='.urlencode($loc.'/'.$file).'">'.$file.'</a>';
|
||||
print "</td>\n";
|
||||
|
||||
print '<td align="right">'.dol_print_size(dol_filesize($courrier_dir."/".$file)).'</td>';
|
||||
print '<td align="center">'.dol_print_date(dol_filemtime($courrier_dir."/".$file),'dayhour').'</td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
}
|
||||
print "</table>";
|
||||
}
|
||||
}
|
||||
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 $');
|
||||
|
||||
?>
|
||||
|
||||
@ -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(<?php echo DOL_URL_ROOT.'/theme/eldy/img/liste_titre2.png' ?>);
|
||||
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;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user