From dd1ac34e8fba8260780b8c16bbf03d42cd6ebb9a Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Tue, 24 Mar 2020 12:26:23 +0100 Subject: [PATCH 1/3] Misc code cleanup --- src/ParameterProvider.php | 45 +++++++----------------------------- src/SimpleBatchUpload.php | 29 +++-------------------- src/UploadButtonRenderer.php | 12 +++------- 3 files changed, 14 insertions(+), 72 deletions(-) diff --git a/src/ParameterProvider.php b/src/ParameterProvider.php index ef433f7..298f7f4 100644 --- a/src/ParameterProvider.php +++ b/src/ParameterProvider.php @@ -42,17 +42,13 @@ class ParameterProvider { private $parameters = null; /** - * ParameterProvider constructor. * @param string|null $templateName */ public function __construct( $templateName ) { $this->templateName = $templateName ? $templateName : ''; } - /** - * @return string - */ - public function getEscapedUploadPageText() { + public function getEscapedUploadPageText(): string { if ( $this->templateName === '' ) { return ''; @@ -61,27 +57,15 @@ public function getEscapedUploadPageText() { return '{{' . $this->getEscapedParameter( self::IDX_TEMPLATENAME ) . $this->getEscapedParameter( self::IDX_TEMPLATEPARAMETERS ) . '}}'; } - /** - * @param int $key - * @return string - */ - private function getEscapedParameter( $key ) { + private function getEscapedParameter( int $key ): string { return $this->escape( $this->getParameter( $key ) ); } - /** - * @param string $text - * @return string - */ - private function escape( $text ) { + private function escape( string $text ): string { return htmlspecialchars( $text, ENT_QUOTES, 'UTF-8', false ); } - /** - * @param int $key - * @return string - */ - private function getParameter( $key ) { + private function getParameter( int $key ): string { if ( $this->parameters === null ) { $this->populateParameters(); } @@ -89,15 +73,11 @@ private function getParameter( $key ) { } private function populateParameters() { - if ( $this->templateName === '' || $this->populateParametersFromKey() === false ) { $this->populateParametersFromDefaults(); } - } - /** - */ private function populateParametersFromKey() { $paramMsg = Message::newFromKey( 'simplebatchupload-parameters' ); @@ -134,24 +114,15 @@ private function setParameters( $templateName, $templateParameters, $uploadComme ]; } - /** - * @return string - */ - public function getEscapedUploadComment() { + public function getEscapedUploadComment(): string { return $this->getEscapedParameter( self::IDX_COMMENT ); } - /** - * @return string - */ - public function getSpecialPageTitle() { + public function getSpecialPageTitle(): string { return $this->getParameter( self::IDX_SPECIALPAGETITLE ); } - /** - * @param string $parameter - */ - public function addTemplateParameter( $parameter ) { + public function addTemplateParameter( string $parameter ) { if ( $this->parameters === null ) { $this->populateParameters(); @@ -164,7 +135,7 @@ public function addTemplateParameter( $parameter ) { * @param string $paramLine * @return string[] */ - private function parseParamLine( $paramLine ) { + private function parseParamLine( string $paramLine ): array { return array_replace( [ '', '', '' ], array_map( 'trim', explode( '|', $paramLine, 3 ) ) ); } diff --git a/src/SimpleBatchUpload.php b/src/SimpleBatchUpload.php index 7b4a525..cbb59d8 100644 --- a/src/SimpleBatchUpload.php +++ b/src/SimpleBatchUpload.php @@ -42,18 +42,11 @@ public static function initCallback() { $simpleBatchUpload->registerEarlyConfiguration( $GLOBALS ); } - - /** - * @param $targetConfiguration - */ public function registerEarlyConfiguration( &$targetConfiguration ){ $sourceConfiguration = $this->getEarlyConfiguration(); $this->mergeConfiguration( $sourceConfiguration, $targetConfiguration ); } - /** - * @param $targetConfiguration - */ public function registerLateConfiguration( &$targetConfiguration ){ $sourceConfiguration = $this->getLateConfiguration(); $this->mergeConfiguration( $sourceConfiguration, $targetConfiguration ); @@ -68,9 +61,6 @@ protected function mergeConfiguration( $sourceConfiguration, &$targetConfigurati } } - /** - * @return array - */ protected function getEarlyConfiguration(): array { $configuration = []; @@ -87,10 +77,6 @@ protected function getEarlyConfiguration(): array { return $configuration; } - - /** - * @return array - */ protected function getLateConfiguration(): array { $configuration = []; @@ -110,12 +96,7 @@ public function registerParserFunction( &$parser ) { return true; } - - /** - * @return array - */ - protected function getUploadSupportModuleDefinition() { - + protected function getUploadSupportModuleDefinition(): array { return [ 'ext.SimpleBatchUpload.jquery-file-upload' => $this->getBasePathsForNonComposerModules() + @@ -127,13 +108,9 @@ protected function getUploadSupportModuleDefinition() { 'dependencies' => [ 'jquery.ui.widget' ], ], ]; - } - /** - * @return array - */ - protected function getUploadModuleDefinition() { + protected function getUploadModuleDefinition(): array { $dependencies = [ 'ext.SimpleBatchUpload.jquery-file-upload', 'mediawiki.Title', 'mediawiki.jqueryMsg' ]; @@ -160,7 +137,7 @@ protected function getUploadModuleDefinition() { /** * @return string[] */ - protected function getBasePathsForNonComposerModules() { + protected function getBasePathsForNonComposerModules(): array { return [ 'localBasePath' => dirname( __DIR__ ), 'remoteBasePath' => $GLOBALS[ 'wgExtensionAssetsPath' ] . '/SimpleBatchUpload', diff --git a/src/UploadButtonRenderer.php b/src/UploadButtonRenderer.php index a0a890e..f451d13 100644 --- a/src/UploadButtonRenderer.php +++ b/src/UploadButtonRenderer.php @@ -39,31 +39,26 @@ class UploadButtonRenderer { * @param $args * @return array */ - public function renderParserFunction( Parser $parser, PPFrame $frame, $args ) { - + public function renderParserFunction( Parser $parser, PPFrame $frame, $args ): array { $args = array_map( [ $frame, 'expand' ], $args ); $output = $parser->getOutput(); $html = $this->renderUploadButton( $args, $output ); return [ $html, 'isHTML' => true, 'noparse' => true, 'nowiki' => false ]; - } - /** * @param SpecialBatchUpload $specialPage * @param string $templateName */ public function renderSpecialPage( SpecialBatchUpload $specialPage, $templateName ) { - $args = [ $templateName ]; $output = $specialPage->getOutput(); $html = $this->renderUploadButton( $args, $output ); $output->addHTML( $html ); - } /** @@ -72,7 +67,6 @@ public function renderSpecialPage( SpecialBatchUpload $specialPage, $templateNam * @return string */ protected function renderUploadButton( $args, $output ) { - $paramProvider = $this->prepareParameterProvider( $args ); $this->addModulesToOutput( $output ); @@ -121,7 +115,7 @@ protected function addModulesToOutput( $output ) { * @param string[] $args * @return ParameterProvider */ - protected function prepareParameterProvider( $args ) { + protected function prepareParameterProvider( $args ): ParameterProvider { $templateName = $args[ 0 ]; @@ -136,4 +130,4 @@ protected function prepareParameterProvider( $args ) { return $paramProvider; } -} \ No newline at end of file +} From 121b7eec468a4d2ddb89b7c277c735f48c644719 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Tue, 24 Mar 2020 12:35:07 +0100 Subject: [PATCH 2/3] Bump version to 1.6 --- extension.json | 3 ++- release-notes.md | 8 +++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/extension.json b/extension.json index 5e1ef64..4c043c5 100644 --- a/extension.json +++ b/extension.json @@ -1,8 +1,9 @@ { "name": "SimpleBatchUpload", - "version": "1.5.1-alpha", + "version": "1.6.0-alpha", "author": [ "[https://www.mediawiki.org/wiki/User:F.trott Stephan Gambke]", + "[https://professional.wiki/ Professional.Wiki]", "..." ], "url": "https://www.mediawiki.org/wiki/Extension:SimpleBatchUpload", diff --git a/release-notes.md b/release-notes.md index dcc82a3..934f802 100644 --- a/release-notes.md +++ b/release-notes.md @@ -1,12 +1,10 @@ ## Release Notes -### SimpleBatchUpload 1.5.1 +### SimpleBatchUpload 1.6.0 -Released on tbd +Released on tbd.githgu -Changes: -- Support for system message translations via [translatewiki.net](https://translatewiki.net). -- System message translations by translatewiki.net translators +* Added translations (via [translatewiki.net](https://translatewiki.net)). ### SimpleBatchUpload 1.5.0 From 0267dcf10dcc16dcdb938af8e530a369b8d29f83 Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Tue, 24 Mar 2020 12:36:28 +0100 Subject: [PATCH 3/3] Undo intellij --- release-notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release-notes.md b/release-notes.md index 934f802..ca57324 100644 --- a/release-notes.md +++ b/release-notes.md @@ -2,7 +2,7 @@ ### SimpleBatchUpload 1.6.0 -Released on tbd.githgu +Released on tbd * Added translations (via [translatewiki.net](https://translatewiki.net)).