mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
add support for fine uploader
This commit is contained in:
parent
ea85b65818
commit
05e163a39d
|
@ -42,20 +42,43 @@ if ($document->getAccessMode($user) < M_READWRITE) {
|
|||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
||||
}
|
||||
|
||||
if (is_uploaded_file($_FILES["userfile"]["tmp_name"]) && $_FILES["userfile"]["size"] > 0 && $_FILES['userfile']['error']!=0){
|
||||
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("uploading_failed"));
|
||||
if(isset($_POST['fineuploaderuuids']) && $_POST['fineuploaderuuids']) {
|
||||
$uuids = explode(';', $_POST['fineuploaderuuids']);
|
||||
$names = explode(';', $_POST['fineuploadernames']);
|
||||
foreach($uuids as $i=>$uuid) {
|
||||
$fullfile = $settings->_stagingDir.'/'.basename($uuid);
|
||||
if(file_exists($fullfile)) {
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$mimetype = finfo_file($finfo, $fullfile);
|
||||
$_FILES["userfile"]['tmp_name'][] = $fullfile;
|
||||
$_FILES["userfile"]['type'][] = $mimetype;
|
||||
$_FILES["userfile"]['name'][] = isset($names[$i]) ? $names[$i] : $uuid;
|
||||
$_FILES["userfile"]['size'][] = filesize($fullfile);
|
||||
$_FILES["userfile"]['error'][] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ($file_num=0;$file_num<count($_FILES["userfile"]["tmp_name"]);$file_num++){
|
||||
if ($_FILES["userfile"]["size"][$file_num]==0) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_zerosize"));
|
||||
}
|
||||
if (is_uploaded_file($_FILES["userfile"]["tmp_name"][$file_num]) && $_FILES['userfile']['error'][$file_num] != 0){
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_failed"));
|
||||
}
|
||||
if($_FILES["userfile"]["error"][$file_num]) {
|
||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
|
||||
}
|
||||
|
||||
if(count($_FILES["userfile"]["tmp_name"]) == 1 && !empty($_POST['name']))
|
||||
$name = $_POST["name"];
|
||||
else
|
||||
$name = $_FILES["userfile"]['name'][$file_num];
|
||||
$comment = $_POST["comment"];
|
||||
|
||||
if($_FILES["userfile"]["error"]) {
|
||||
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("error_occured"));
|
||||
}
|
||||
|
||||
$userfiletmp = $_FILES["userfile"]["tmp_name"];
|
||||
$userfiletype = $_FILES["userfile"]["type"];
|
||||
$userfilename = $_FILES["userfile"]["name"];
|
||||
$userfiletmp = $_FILES["userfile"]["tmp_name"][$file_num];
|
||||
$userfiletype = $_FILES["userfile"]["type"][$file_num];
|
||||
$userfilename = $_FILES["userfile"]["name"][$file_num];
|
||||
|
||||
$fileType = ".".pathinfo($userfilename, PATHINFO_EXTENSION);
|
||||
|
||||
|
@ -74,24 +97,6 @@ if (is_bool($res) && !$res) {
|
|||
if($notifier) {
|
||||
$notifyList = $document->getNotifyList();
|
||||
|
||||
/*
|
||||
$subject = "###SITENAME###: ".$document->getName()." - ".getMLText("new_file_email");
|
||||
$message = getMLText("new_file_email")."\r\n";
|
||||
$message .=
|
||||
getMLText("name").": ".$name."\r\n".
|
||||
getMLText("comment").": ".$comment."\r\n".
|
||||
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() .">\r\n".
|
||||
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."\r\n";
|
||||
|
||||
$subject=$subject;
|
||||
$message=$message;
|
||||
|
||||
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
|
||||
foreach ($document->_notifyList["groups"] as $grp) {
|
||||
$notifier->toGroup($user, $grp, $subject, $message);
|
||||
}
|
||||
*/
|
||||
|
||||
$subject = "new_file_email_subject";
|
||||
$message = "new_file_email_body";
|
||||
$params = array();
|
||||
|
@ -108,6 +113,7 @@ if (is_bool($res) && !$res) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_log_line("?name=".$name."&documentid=".$documentid);
|
||||
|
||||
|
|
|
@ -32,40 +32,79 @@ require_once("class.Bootstrap.php");
|
|||
class SeedDMS_View_AddFile extends SeedDMS_Bootstrap_Style {
|
||||
|
||||
function js() { /* {{{ */
|
||||
$enablelargefileupload = $this->params['enablelargefileupload'];
|
||||
$partitionsize = $this->params['partitionsize'];
|
||||
header('Content-Type: application/javascript');
|
||||
if($enablelargefileupload)
|
||||
$this->printFineUploaderJs('../op/op.UploadChunks.php', $partitionsize);
|
||||
?>
|
||||
function checkForm()
|
||||
{
|
||||
msg = new Array();
|
||||
if ($("#userfile").val() == "") msg.push("<?php printMLText("js_no_file");?>");
|
||||
if ($("#name").val() == "") msg.push("<?php printMLText("js_no_name");?>");
|
||||
<?php
|
||||
if (isset($settings->_strictFormCheck) && $settings->_strictFormCheck) {
|
||||
?>
|
||||
if ($("#comment").val() == "") msg.push("<?php printMLText("js_no_comment");?>");
|
||||
<?php
|
||||
|
||||
$(document).ready( function() {
|
||||
/* The fineuploader validation is actually checking all fields that can contain
|
||||
* a file to be uploaded. First checks if an alternative input field is set,
|
||||
* second loops through the list of scheduled uploads, checking if at least one
|
||||
* file will be submitted.
|
||||
*/
|
||||
jQuery.validator.addMethod("fineuploader", function(value, element, params) {
|
||||
uploader = params[0];
|
||||
arr = uploader.getUploads();
|
||||
for(var i in arr) {
|
||||
if(arr[i].status == 'submitted')
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
if (msg != "")
|
||||
{
|
||||
return false;
|
||||
}, "<?php printMLText("js_no_file");?>");
|
||||
$("#form1").validate({
|
||||
debug: false,
|
||||
ignore: ":hidden:not(.do_validate)",
|
||||
invalidHandler: function(e, validator) {
|
||||
noty({
|
||||
text: msg.join('<br />'),
|
||||
text: (validator.numberOfInvalids() == 1) ? "<?php printMLText("js_form_error");?>".replace('#', validator.numberOfInvalids()) : "<?php printMLText("js_form_errors");?>".replace('#', validator.numberOfInvalids()),
|
||||
type: 'error',
|
||||
dismissQueue: true,
|
||||
layout: 'topRight',
|
||||
theme: 'defaultTheme',
|
||||
_timeout: 1500,
|
||||
timeout: 1500,
|
||||
});
|
||||
return false;
|
||||
},
|
||||
<?php
|
||||
if($enablelargefileupload) {
|
||||
?>
|
||||
submitHandler: function(form) {
|
||||
manualuploader.uploadStoredFiles();
|
||||
},
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
rules: {
|
||||
<?php
|
||||
if($enablelargefileupload) {
|
||||
?>
|
||||
fineuploaderuuids: {
|
||||
fineuploader: [ manualuploader ]
|
||||
}
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
'userfile[]': {
|
||||
required: true
|
||||
}
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
},
|
||||
messages: {
|
||||
name: "<?php printMLText("js_no_name");?>",
|
||||
comment: "<?php printMLText("js_no_comment");?>",
|
||||
'userfile[]': "<?php printMLText("js_no_file");?>"
|
||||
},
|
||||
errorPlacement: function( error, element ) {
|
||||
if ( element.is( ":file" ) ) {
|
||||
error.appendTo( element.parent().parent().parent());
|
||||
} else {
|
||||
error.appendTo( element.parent());
|
||||
}
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
$(document).ready( function() {
|
||||
$('body').on('submit', '#fileupload', function(ev){
|
||||
if(checkForm()) return;
|
||||
ev.preventDefault();
|
||||
});
|
||||
});
|
||||
<?php
|
||||
|
@ -79,6 +118,10 @@ $(document).ready( function() {
|
|||
$strictformcheck = $this->params['strictformcheck'];
|
||||
$enablelargefileupload = $this->params['enablelargefileupload'];
|
||||
|
||||
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/validate/jquery.validate.js"></script>'."\n", 'js');
|
||||
if($enablelargefileupload)
|
||||
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/fine-uploader/jquery.fine-uploader.min.js"></script>'."\n", 'js');
|
||||
|
||||
$this->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))));
|
||||
$this->globalNavigation($folder);
|
||||
$this->contentStart();
|
||||
|
@ -89,7 +132,7 @@ $(document).ready( function() {
|
|||
<div class="alert alert-warning">
|
||||
<?php echo getMLText("max_upload_size").": ".ini_get( "upload_max_filesize"); ?>
|
||||
<?php
|
||||
if($enablelargefileupload) {
|
||||
if(0 && $enablelargefileupload) {
|
||||
printf('<p>'.getMLText('link_alt_updatedocument').'</p>', "out.AddFile2.php?documentid=".$document->getId());
|
||||
}
|
||||
?>
|
||||
|
@ -98,13 +141,18 @@ $(document).ready( function() {
|
|||
$this->contentContainerStart();
|
||||
?>
|
||||
|
||||
<form class="form-horizontal" action="../op/op.AddFile.php" enctype="multipart/form-data" method="post" name="form1" id="fileupload">
|
||||
<form class="form-horizontal" action="../op/op.AddFile.php" enctype="multipart/form-data" method="post" name="form1" id="form1">
|
||||
<input type="hidden" name="documentid" value="<?php print $document->getId(); ?>">
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label"><?php printMLText("local_file");?>:</label>
|
||||
<div class="controls">
|
||||
<?php $this->printFileChooser('userfile', false); ?>
|
||||
<?php
|
||||
if($enablelargefileupload)
|
||||
$this->printFineUploaderHtml();
|
||||
else
|
||||
$this->printFileChooser('userfile[]', false);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -120,7 +168,7 @@ $(document).ready( function() {
|
|||
<div class="control-group">
|
||||
<label class="control-label"><?php printMLText("comment");?>:</label>
|
||||
<div class="controls">
|
||||
<textarea name="comment" id="comment" rows="4" cols="80"></textarea>
|
||||
<textarea name="comment" id="comment" rows="4" cols="80"<?php echo $strictformcheck ? ' required' : ''; ?>></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user