mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-12 00:45:34 +00:00
add support for fine uploader
This commit is contained in:
parent
05e163a39d
commit
8516d23684
|
@ -56,14 +56,30 @@ if ($document->isLocked()) {
|
||||||
else $document->setLocked(false);
|
else $document->setLocked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($_POST['fineuploaderuuids']) && $_POST['fineuploaderuuids']) {
|
||||||
|
$uuids = explode(';', $_POST['fineuploaderuuids']);
|
||||||
|
$names = explode(';', $_POST['fineuploadernames']);
|
||||||
|
$uuid = $uuids[0];
|
||||||
|
$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[0]) ? $names[0] : $uuid;
|
||||||
|
$_FILES["userfile"]['size'] = filesize($fullfile);
|
||||||
|
$_FILES["userfile"]['error'] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(isset($_POST["comment"]))
|
if(isset($_POST["comment"]))
|
||||||
$comment = $_POST["comment"];
|
$comment = $_POST["comment"];
|
||||||
else
|
else
|
||||||
$comment = "";
|
$comment = "";
|
||||||
|
|
||||||
if ($_FILES['userfile']['error'] == 0) {
|
if ($_FILES['userfile']['error'] == 0) {
|
||||||
if(!is_uploaded_file($_FILES["userfile"]["tmp_name"]))
|
// if(!is_uploaded_file($_FILES["userfile"]["tmp_name"]))
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
|
// UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured")."lsajdflk");
|
||||||
|
|
||||||
if($_FILES["userfile"]["size"] == 0)
|
if($_FILES["userfile"]["size"] == 0)
|
||||||
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_zerosize"));
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("uploading_zerosize"));
|
||||||
|
|
|
@ -34,55 +34,38 @@ class SeedDMS_View_UpdateDocument extends SeedDMS_Bootstrap_Style {
|
||||||
function js() { /* {{{ */
|
function js() { /* {{{ */
|
||||||
$strictformcheck = $this->params['strictformcheck'];
|
$strictformcheck = $this->params['strictformcheck'];
|
||||||
$dropfolderdir = $this->params['dropfolderdir'];
|
$dropfolderdir = $this->params['dropfolderdir'];
|
||||||
|
$enablelargefileupload = $this->params['enablelargefileupload'];
|
||||||
|
$partitionsize = $this->params['partitionsize'];
|
||||||
header('Content-Type: application/javascript');
|
header('Content-Type: application/javascript');
|
||||||
$this->printDropFolderChooserJs("form1");
|
$this->printDropFolderChooserJs("form1");
|
||||||
$this->printSelectPresetButtonJs();
|
$this->printSelectPresetButtonJs();
|
||||||
$this->printInputPresetButtonJs();
|
$this->printInputPresetButtonJs();
|
||||||
$this->printCheckboxPresetButtonJs();
|
$this->printCheckboxPresetButtonJs();
|
||||||
|
if($enablelargefileupload)
|
||||||
|
$this->printFineUploaderJs('../op/op.UploadChunks.php', $partitionsize, false);
|
||||||
?>
|
?>
|
||||||
function checkForm()
|
|
||||||
{
|
|
||||||
msg = new Array();
|
|
||||||
<?php if($dropfolderdir) { ?>
|
|
||||||
if ($("#userfile").val() == "" && $("#dropfolderfileform1").val() == "") msg.push("<?php printMLText("js_no_file");?>");
|
|
||||||
<?php } else { ?>
|
|
||||||
if ($("#userfile").val() == "") msg.push("<?php printMLText("js_no_file");?>");
|
|
||||||
<?php } ?>
|
|
||||||
<?php
|
|
||||||
if ($strictformcheck) {
|
|
||||||
?>
|
|
||||||
if ($("#comment").val() == "") msg.push("<?php printMLText("js_no_comment");?>");
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
if (msg != "")
|
|
||||||
{
|
|
||||||
noty({
|
|
||||||
text: msg.join('<br />'),
|
|
||||||
type: 'error',
|
|
||||||
dismissQueue: true,
|
|
||||||
layout: 'topRight',
|
|
||||||
theme: 'defaultTheme',
|
|
||||||
_timeout: 1500,
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready( function() {
|
$(document).ready( function() {
|
||||||
/*
|
|
||||||
$('body').on('submit', '#form1', function(ev){
|
|
||||||
if(checkForm()) return;
|
|
||||||
ev.preventDefault();
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
jQuery.validator.addMethod("alternatives", function(value, element, params) {
|
jQuery.validator.addMethod("alternatives", function(value, element, params) {
|
||||||
if(value == '' && params.val() == '')
|
if(value == '' && params.val() == '')
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}, "<?php printMLText("js_no_file");?>");
|
}, "<?php printMLText("js_no_file");?>");
|
||||||
|
/* 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) {
|
||||||
|
if(params[1].val() != '')
|
||||||
|
return true;
|
||||||
|
uploader = params[0];
|
||||||
|
arr = uploader.getUploads();
|
||||||
|
for(var i in arr) {
|
||||||
|
if(arr[i].status == 'submitted')
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}, "<?php printMLText("js_no_file");?>");
|
||||||
$("#form1").validate({
|
$("#form1").validate({
|
||||||
invalidHandler: function(e, validator) {
|
invalidHandler: function(e, validator) {
|
||||||
noty({
|
noty({
|
||||||
|
@ -94,13 +77,34 @@ $(document).ready( function() {
|
||||||
timeout: 1500,
|
timeout: 1500,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
<?php
|
||||||
|
if($enablelargefileupload) {
|
||||||
|
?>
|
||||||
|
submitHandler: function(form) {
|
||||||
|
manualuploader.uploadStoredFiles();
|
||||||
|
},
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
rules: {
|
rules: {
|
||||||
|
<?php
|
||||||
|
if($enablelargefileupload) {
|
||||||
|
?>
|
||||||
|
fineuploaderuuids: {
|
||||||
|
fineuploader: [ manualuploader, $('#dropfolderfileform1') ]
|
||||||
|
}
|
||||||
|
<?php
|
||||||
|
} else {
|
||||||
|
?>
|
||||||
userfile: {
|
userfile: {
|
||||||
alternatives: $('#dropfolderfileform1')
|
alternatives: $('#dropfolderfileform1')
|
||||||
},
|
},
|
||||||
dropfolderfileform1: {
|
dropfolderfileform1: {
|
||||||
alternatives: $('#userfile')
|
alternatives: $('#userfile')
|
||||||
}
|
}
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
},
|
},
|
||||||
messages: {
|
messages: {
|
||||||
comment: "<?php printMLText("js_no_comment");?>",
|
comment: "<?php printMLText("js_no_comment");?>",
|
||||||
|
@ -134,6 +138,8 @@ console.log(element);
|
||||||
$documentid = $document->getId();
|
$documentid = $document->getId();
|
||||||
|
|
||||||
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/validate/jquery.validate.js"></script>'."\n", 'js');
|
$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->htmlStartPage(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))));
|
||||||
$this->globalNavigation($folder);
|
$this->globalNavigation($folder);
|
||||||
|
@ -190,9 +196,12 @@ console.log(element);
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php printMLText("local_file");?>:</td>
|
<td><?php printMLText("local_file");?>:</td>
|
||||||
<td><!-- input type="File" name="userfile" size="60" -->
|
<td>
|
||||||
<?php
|
<?php
|
||||||
$this->printFileChooser('userfile', false);
|
if($enablelargefileupload)
|
||||||
|
$this->printFineUploaderHtml();
|
||||||
|
else
|
||||||
|
$this->printFileChooser('userfile', false);
|
||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user