Skip to content

Commit

Permalink
Move dropzone form view helper to print_api
Browse files Browse the repository at this point in the history
Fixes #21715
  • Loading branch information
syncguru authored and vboctor committed Oct 25, 2016
1 parent 48a71a7 commit add29e7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 46 deletions.
2 changes: 1 addition & 1 deletion bug_file_upload_inc.php
Expand Up @@ -61,7 +61,7 @@
enctype="multipart/form-data"
action="bug_file_add.php"
class="form-inline auto-dropzone-form"
<?php include_once( dirname( __FILE__ ) . '/dropzone_inc.php' ) ?>>
<?php print_dropzone_form_data() ?>>
<?php echo form_security_field( 'bug_file_add' ) ?>

<div id="upload_form" class="widget-box widget-color-blue2 <?php echo $t_block_css ?>">
Expand Down
2 changes: 1 addition & 1 deletion bug_report_page.php
Expand Up @@ -240,7 +240,7 @@
method="post" <?php echo $t_form_encoding; ?>
action="bug_report.php?posted=1"
class="dropzone-form"
<?php include_once( dirname( __FILE__ ) . '/dropzone_inc.php' ) ?>>
<?php print_dropzone_form_data() ?>>
<?php echo form_security_field( 'bug_report' ) ?>
<input type="hidden" name="m_id" value="<?php echo $f_master_bug_id ?>" />
<input type="hidden" name="project_id" value="<?php echo $t_project_id ?>" />
Expand Down
2 changes: 1 addition & 1 deletion bugnote_add_inc.php
Expand Up @@ -68,7 +68,7 @@
action="bugnote_add.php"
enctype="multipart/form-data"
class="dz dropzone-form"
<?php include_once( dirname( __FILE__ ) . '/dropzone_inc.php' ) ?>>
<?php print_dropzone_form_data() ?>>
<?php echo form_security_field( 'bugnote_add' ) ?>
<input type="hidden" name="bug_id" value="<?php echo $f_bug_id ?>" />
<div id="bugnote_add" class="widget-box widget-color-blue2 <?php echo $t_block_css ?>">
Expand Down
23 changes: 23 additions & 0 deletions core/print_api.php
Expand Up @@ -2097,3 +2097,26 @@ function print_max_filesize( $p_size, $p_divider = 1000, $p_unit = 'kb' ) {
. get_filesize_info( $p_size / $p_divider, lang_get( $p_unit ) );
echo '</span>';
}

/**
* Populate form element with dropzone data attributes
* @return void
*/
function print_dropzone_form_data() {
echo 'data-force-fallback="' . ( config_get( 'dropzone_enabled' ) ? 'false' : 'true' ) . '"' . "\n";
echo "\t" . 'data-max-filesize="'. ceil( config_get( 'max_file_size' ) / (1000 * 1024) ) . '"' . "\n";
echo "\t" . 'data-accepted-files="' . config_get( 'allowed_files' ) . '"' . "\n";
echo "\t" . 'data-default-message="' . htmlspecialchars( lang_get( 'dropzone_default_message' ) ) . '"' . "\n";
echo "\t" . 'data-fallback-message="' . htmlspecialchars( lang_get( 'dropzone_fallback_message' ) ) . '"' . "\n";
echo "\t" . 'data-fallback-text="' . htmlspecialchars( lang_get( 'dropzone_fallback_text' ) ) . '"' . "\n";
echo "\t" . 'data-file-too-big="' . htmlspecialchars( lang_get( 'dropzone_file_too_big' ) ) . '"' . "\n";
echo "\t" . 'data-invalid-file-type="' . htmlspecialchars( lang_get( 'dropzone_invalid_file_type' ) ) . '"' . "\n";
echo "\t" . 'data-response-error="' . htmlspecialchars( lang_get( 'dropzone_response_error' ) ) . '"' . "\n";
echo "\t" . 'data-cancel-upload="' . htmlspecialchars( lang_get( 'dropzone_cancel_upload' ) ) . '"' . "\n";
echo "\t" . 'data-cancel-upload-confirmation="' . htmlspecialchars( lang_get( 'dropzone_cancel_upload_confirmation' ) ) . '"' . "\n";
echo "\t" . 'data-remove-file="'. htmlspecialchars( lang_get( 'dropzone_remove_file' ) ) . '"' . "\n";
echo "\t" . 'data-remove-file-confirmation="' . htmlspecialchars( lang_get( 'dropzone_remove_file_confirmation' ) ) . '"' . "\n";
echo "\t" . 'data-max-files-exceeded="' . htmlspecialchars( lang_get( 'dropzone_max_files_exceeded' ) ) . '"' . "\n";
echo "\t" . 'data-dropzone-not-supported="' . htmlspecialchars( lang_get( 'dropzone_not_supported' ) ) . '"';

}
43 changes: 0 additions & 43 deletions dropzone_inc.php

This file was deleted.

0 comments on commit add29e7

Please sign in to comment.