Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@
"batchupload": "Upload multiple files",
"simplebatchupload-buttonlabel": "Select files (or drop them here)...",
"simplebatchupload-comment": "Uploaded with [[mw:Special:MyLanguage/Extension:SimpleBatchUpload|SimpleBatchUpload]]",
"simplebatchupload-max-files-alert": "You cannot upload more than $1 {{PLURAL:$1|file|files}} at a time."
"simplebatchupload-filesummary": "<!-- Default file summary for uploaded new files via SimpleBatchUpload -->",
"simplebatchupload-max-files-alert": "You cannot upload more than $1 {{PLURAL:$1|file|files}} at a time.",
"simplebatchupload-parameters": "<!-- Customization settings for SimpleBatchUpload subpages, see mw:Special:MyLanguage/Extension:SimpleBatchUpload#Customization for details -->"
}
4 changes: 3 additions & 1 deletion i18n/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@
"batchupload": "{{doc-special|BatchUpload}}",
"simplebatchupload-buttonlabel": "The label for the upload button",
"simplebatchupload-comment": "Comment saved with the upload. Do not translate '[[mw:Special:MyLanguage/Extension:SimpleBatchUpload|SimpleBatchUpload]]'",
"simplebatchupload-max-files-alert": "Alert saying there are too many files in a batch"
"simplebatchupload-filesummary": "Default file summary. Do not add anything outside the first comment. Do not translate 'SimpleBatchUpload'",
"simplebatchupload-max-files-alert": "Alert saying there are too many files in a batch",
"simplebatchupload-parameters": "Customization settings. Do not add anything outside the first comment. Do not translate 'SimpleBatchUpload' and 'mw:Special:MyLanguage/Extension:SimpleBatchUpload#Customization'"
}
20 changes: 16 additions & 4 deletions src/ParameterProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,23 @@ public function __construct( $templateName ) {

public function getUploadPageText(): string {

if ( $this->templateName === '' ) {
return '';
$msgKey = 'simplebatchupload-filesummary';
$templateName = $this->getParameter( self::IDX_TEMPLATENAME );
$templateParams = preg_replace( '/^\|+/', '|', $this->getParameter( self::IDX_TEMPLATEPARAMETERS ) );

if ( $this->templateName !== '' ) {
$msgKey = $msgKey . '-' . $templateName;
}

$fileSummaryMsg = Message::newFromKey( $msgKey, $templateParams );

if ( $fileSummaryMsg->exists() ) {
return preg_replace( '/^[\s\n]*<!--[\s\S]*?-->[\s\n]*/', '', $fileSummaryMsg->plain() );
}
else {
return '{{' . $templateName . $templateParams . '}}';
}

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

private function getEscapedParameter( int $key ): string {
Expand Down Expand Up @@ -83,7 +95,7 @@ private function populateParametersFromKey() {

if ( $paramMsg->exists() ) {

$paramLines = explode( "\n", $paramMsg->plain() );
$paramLines = preg_replace( '/^\*\s*/', '', explode( "\n", preg_replace( '/^[\s\n]*<!--[\s\S]*?-->[\s\n]*/', '', $paramMsg->plain() ) ) );
$paramSet = array_map( [ $this, 'parseParamLine' ], $paramLines );
$paramMap = array_combine( array_column( $paramSet, 0 ), $paramSet );

Expand Down
18 changes: 18 additions & 0 deletions src/SimpleBatchUpload.alias.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,21 @@
$specialPageAliases['en'] = [
'BatchUpload' => [ 'BatchUpload' ],
];

/** Simplified Chinese
*/
$specialPageAliases['zh-hans'] = [
'BatchUpload' => [ '批量上传' ],
];

/** Traditional Chinese
*/
$specialPageAliases['zh-hant'] = [
'BatchUpload' => [ '批次上傳' ],
];

/** Traditional Chinese, Hong Kong
*/
$specialPageAliases['zh-hk'] = [
'BatchUpload' => [ '批次上載' ],
];
7 changes: 4 additions & 3 deletions src/UploadButtonRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ protected function prepareParameterProvider( $args ): ParameterProvider {

if ( $templateName !== '' ) {
array_shift( $args );
foreach ( $args as $node ) {
$paramProvider->addTemplateParameter( $node );
}
}
foreach ( $args as $node ) {
$paramProvider->addTemplateParameter( $node );
}

return $paramProvider;
}

Expand Down