Skip to content

Commit

Permalink
Merge pull request #39 from thijskh/feature/add-description-textarea
Browse files Browse the repository at this point in the history
Allow to specify the description of all uploaded files.
  • Loading branch information
JeroenDeDauw committed Apr 11, 2021
2 parents 72eb608 + e6c6131 commit 05d5b08
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion res/ext.SimpleBatchUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
var src_filename = data.files[ 0 ].name;
var filenode_text = src_filename;
var dst_filename = src_filename
var textdata = $( that ).fileupload( 'option', 'text' );
var textdata = $("#wfUploadDescription").val();
// It matches:
// other| +rename = !(\w+)[ -_/]*! =$1-}}
// where:
Expand Down
4 changes: 2 additions & 2 deletions src/ParameterProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ public function __construct( $templateName ) {
$this->templateName = $templateName ? $templateName : '';
}

public function getEscapedUploadPageText(): string {
public function getUploadPageText(): string {

if ( $this->templateName === '' ) {
return '';
}

return '{{' . $this->getEscapedParameter( self::IDX_TEMPLATENAME ) . $this->getEscapedParameter( self::IDX_TEMPLATEPARAMETERS ) . '}}';
return '{{' . $this->getParameter( self::IDX_TEMPLATENAME ) . $this->getParameter( self::IDX_TEMPLATEPARAMETERS ) . '}}';
}

private function getEscapedParameter( int $key ): string {
Expand Down
9 changes: 6 additions & 3 deletions src/UploadButtonRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace SimpleBatchUpload;
use Parser;
use PPFrame;

use Html;

/**
* Class UploadButtonRenderer
Expand Down Expand Up @@ -85,10 +85,14 @@ protected function renderUploadButton( $args, $output ) {
protected function getHtml( ParameterProvider $paramProvider ) {

$escapedUploadComment = $paramProvider->getEscapedUploadComment();
$escapedUploadPageText = $paramProvider->getEscapedUploadPageText();
$uploadPageText = $paramProvider->getUploadPageText();

return

'<label for="wfUploadDescription">' . \Message::newFromKey( 'upload-form-label-infoform-description' )->escaped() . ':</label><br>'.
'<span class="mw-input">' .
Html::element('textarea', ['name' => 'wfUploadDescription', 'id' => 'wfUploadDescription', 'cols' => '80', 'rows' => '8'], $uploadPageText) .
'</span><br> ' .
'<span class="fileupload-container"> ' .
'<span class="fileupload-dropzone fileinput-button"> ' .
'<i class="glyphicon glyphicon-plus"></i> ' .
Expand All @@ -97,7 +101,6 @@ protected function getHtml( ParameterProvider $paramProvider ) {
'<input class="fileupload" type="file" name="file" multiple ' .
' data-url="' . wfScript( 'api' ) . '" ' .
' data-comment="' . $escapedUploadComment . '" ' .
' data-text="' . $escapedUploadPageText . '" ' .
'> ' .
'</span><ul class="fileupload-results"></ul> ' .
'</span>';
Expand Down

0 comments on commit 05d5b08

Please sign in to comment.