Skip to content

Commit

Permalink
Dropzone fixes
Browse files Browse the repository at this point in the history
- full localization
- fix spelling
- use existing config property 'allowed_files' in 'acceptedFiles'
- remove multiple inputs as they're no longer necessary
- change default max upload files number to 10

Fixes #21221, #21222
  • Loading branch information
badfiles authored and vboctor committed Jul 10, 2016
1 parent ab0c7c0 commit c73ff8d
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 43 deletions.
14 changes: 1 addition & 13 deletions bug_file_upload_inc.php
Expand Up @@ -79,9 +79,7 @@
<table class="table table-bordered table-condensed table-striped">
<tr>
<td class="category" width="15%">
<?php echo lang_get( $t_file_upload_max_num == 1 ? 'select_file' : 'select_files' ) ?>
<br />
<?php print_max_filesize( $t_max_file_size ); ?>
<?php print_max_filesize( $t_max_file_size ) ?>
</td>
<td width="85%">
<input type="hidden" name="bug_id" value="<?php echo $f_bug_id ?>" />
Expand All @@ -94,17 +92,7 @@
<div id="auto-dropzone-previews-box" class="dropzone-previews dz-max-files-reached"></div>
</div>
<div class="fallback">
<?php
# Display multiple file upload fields
for( $i = 0; $i < $t_file_upload_max_num; $i++ ) {
?>
<input id="ufile[]" name="ufile[]" type="file" size="50" />
<?php
if( $t_file_upload_max_num > 1 ) {
echo '<br />';
}
}
?>
<br />
<input type="submit" class="btn btn-primary btn-sm btn-white btn-round"
value="<?php echo lang_get( $t_file_upload_max_num == 1 ? 'upload_file_button' : 'upload_files_button' ) ?>"
Expand Down
12 changes: 1 addition & 11 deletions bug_report_page.php
Expand Up @@ -624,7 +624,7 @@
?>
<tr>
<th class="category">
<label for="file"><?php echo lang_get( $t_file_upload_max_num == 1 ? 'upload_file' : 'upload_files' ) ?></label>
<label for="ufile[]"><?php echo lang_get( $t_file_upload_max_num == 1 ? 'upload_file' : 'upload_files' ) ?></label>
<br />
<?php print_max_filesize( $t_max_file_size ); ?>
</th>
Expand All @@ -637,17 +637,7 @@
</div>
<div class="fallback">
<div class="dz-message" data-dz-message></div>
<?php
# Display multiple file upload fields
for( $i = 0; $i < $t_file_upload_max_num; $i++ ) {
?>
<input <?php echo helper_get_tab_index() ?> id="ufile[]" name="ufile[]" type="file" size="60" />
<?php
if( $t_file_upload_max_num > 1 ) {
echo '<br />';
}
}
?>
</div>
</td>
</tr>
Expand Down
10 changes: 0 additions & 10 deletions bugnote_add_inc.php
Expand Up @@ -159,17 +159,7 @@
<div id="dropzone-previews-box" class="dz dropzone-previews dz-max-files-reached"></div>
</div>
<div class="fallback">
<?php
# Display multiple file upload fields
for( $i = 0; $i < $t_file_upload_max_num; $i++ ) {
?>
<input id="ufile[]" name="ufile[]" type="file" size="50" />
<?php
if( $t_file_upload_max_num > 1 ) {
echo '<br />';
}
}
?>
</div>
</td>
</tr>
Expand Down
2 changes: 1 addition & 1 deletion config_defaults_inc.php
Expand Up @@ -1714,7 +1714,7 @@
* Maximum number of files that can be uploaded simultaneously
* @global integer $g_file_upload_max_num
*/
$g_file_upload_max_num = 1;
$g_file_upload_max_num = 10;

/**
* Files that are allowed or not allowed. Separate items by commas.
Expand Down
1 change: 1 addition & 0 deletions docbook/Admin_Guide/en-US/config/uploads.xml
Expand Up @@ -54,6 +54,7 @@
<term>$g_file_upload_max_num</term>
<listitem>
<para>Maximum number of files that can be uploaded simultaneously.
Default value is 10.
</para>
</listitem>
</varlistentry>
Expand Down
9 changes: 3 additions & 6 deletions fileupload_inc.php
Expand Up @@ -31,7 +31,6 @@

<!-- The template to display files available for download -->
<script type="text/javascript">

Dropzone.autoDiscover = false;
function enableDropzone( classPrefix, autoUpload ) {
try {
Expand All @@ -43,8 +42,9 @@ function enableDropzone( classPrefix, autoUpload ) {
previewsContainer: '#' + classPrefix + '-previews-box',
uploadMultiple: true,
parallelUploads: 100,
maxFilesize: <?php echo ceil( ( config_get( 'max_file_size' ) / (1000 * 1024) ) ) ?>,
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' ) ?>",
Expand Down Expand Up @@ -80,19 +80,16 @@ function enableDropzone( classPrefix, autoUpload ) {
}
});
} catch (e) {
alert( 'Dropzone.js does not support older browsers!' );
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>
5 changes: 3 additions & 2 deletions lang/strings_english.txt
Expand Up @@ -1767,10 +1767,11 @@ $s_dropzone_default_message = 'Drop files here to upload (or click)';
$s_dropzone_fallback_message = "Your browser does not support drag'n'drop file uploads.";
$s_dropzone_fallback_text = '';
$s_dropzone_file_too_big = "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.";
$s_dropzone_invalid_file_type = "You can't upload files of this type.";
$s_dropzone_invalid_file_type = "You cannot upload files of this type.";
$s_dropzone_response_error = "Server responded with {{statusCode}} code.";
$s_dropzone_cancel_upload = 'Cancel upload';
$s_dropzone_cancel_upload_confirmation = 'Are you sure you want to cancel this upload?';
$s_dropzone_remove_file = 'Remove file';
$s_dropzone_remove_file_confirmation = '';
$s_dropzone_max_files_exceeded = 'You can not upload any more files.';
$s_dropzone_max_files_exceeded = 'You cannot upload any more files.';
$s_dropzone_not_supported = 'Dropzone.js does not support older browsers!';

0 comments on commit c73ff8d

Please sign in to comment.