-
Notifications
You must be signed in to change notification settings - Fork 3
/
fileupload_inc.php
95 lines (88 loc) · 4.01 KB
/
fileupload_inc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
# MantisBT - A PHP based bugtracking system
# MantisBT is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# MantisBT is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MantisBT. If not, see <http://www.gnu.org/licenses/>.
/**
* This include file prints out the fileupload widget
*
* @package MantisBT
* @copyright Copyright 2000 - 2002 Kenzaburo Ito - [email protected]
* @copyright Copyright 2002 MantisBT Team - [email protected]
* @link http://www.mantisbt.org
*
*/
html_css_link( 'dropzone.css' );
html_javascript_link( 'dropzone.min.js');
?>
<!-- The template to display files available for download -->
<script type="text/javascript">
Dropzone.autoDiscover = false;
function enableDropzone( classPrefix, autoUpload ) {
try {
var zone = new Dropzone( "." + classPrefix + "-form", {
forceFallback: <?php echo config_get( 'dropzone_enabled' ) ? 'false' : 'true' ?>,
paramName: "ufile",
autoProcessQueue: autoUpload,
clickable: '.' + classPrefix,
previewsContainer: '#' + classPrefix + '-previews-box',
uploadMultiple: true,
parallelUploads: 100,
maxFilesize: <?php echo ceil( config_get( 'max_file_size' ) / (1000 * 1024) ) ?>,
addRemoveLinks: !autoUpload,
acceptedFiles: '<?php echo config_get( 'allowed_files' ) ?>',
previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n <div class=\"dz-details\">\n <div class=\"dz-filename\"><span data-dz-name></span></div>\n <div class=\"dz-size\" data-dz-size></div>\n <img data-dz-thumbnail />\n </div>\n <div class=\"progress progress-small progress-striped active\"><div class=\"progress-bar progress-bar-success\" data-dz-uploadprogress></div></div>\n <div class=\"dz-success-mark\"><span></span></div>\n <div class=\"dz-error-mark\"><span></span></div>\n <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>",
dictDefaultMessage: "<?php echo lang_get( 'dropzone_default_message' ) ?>",
dictFallbackMessage: "<?php echo lang_get( 'dropzone_fallback_message' ) ?>",
dictFallbackText: "<?php echo lang_get( 'dropzone_fallback_text' ) ?>",
dictFileTooBig: "<?php echo lang_get( 'dropzone_file_too_big' ) ?>",
dictInvalidFileType: "<?php echo lang_get( 'dropzone_invalid_file_type' ) ?>",
dictResponseError: "<?php echo lang_get( 'dropzone_response_error' ) ?>",
dictCancelUpload: "<?php echo lang_get( 'dropzone_cancel_upload' ) ?>",
dictCancelUploadConfirmation: "<?php echo lang_get( 'dropzone_cancel_upload_confirmation' ) ?>",
dictRemoveFile: "<?php echo lang_get( 'dropzone_remove_file' ) ?>",
dictRemoveFileConfirmation: "<?php echo lang_get( 'dropzone_remove_file_confirmation' ) ?>",
dictMaxFilesExceeded: "<?php echo lang_get( 'dropzone_max_files_exceeded' ) ?>",
init: function () {
var dropzone = this;
$( "input[type=submit]" ).on( "click", function (e) {
if( dropzone.getQueuedFiles().length ) {
e.preventDefault();
e.stopPropagation();
dropzone.processQueue();
}
});
this.on( "successmultiple", function( files, response ) {
document.open();
document.write( response );
document.close();
});
},
fallback: function() {
if( $( "." + classPrefix ).length ) {
$( "." + classPrefix ).hide();
}
}
});
} catch (e) {
alert( '<?php echo lang_get( 'dropzone_not_supported' ) ?>' );
}
}
$(document).ready( function() {
if( $( ".dropzone-form" ).length ) {
enableDropzone( "dropzone", false );
}
if( $( ".auto-dropzone-form" ).length ) {
enableDropzone( "auto-dropzone", true );
}
});
</script>