[MediaWiki-commits] [Gerrit] Improve tags parser code - change (mediawiki...ProofreadPage)
jenkins-bot has submitted this change and it was merged. Change subject: Improve tags parser code .. Improve tags parser code Removes a duplicate file Change-Id: Ib44682281a7fb2d473c07e7cec7852b4755b15d8 --- M includes/Parser/PagelistTagParser.php M includes/Parser/PagesTagParser.php M includes/Parser/ParserEntryPoint.php M includes/Parser/TagParser.php D includes/parser/ParserEntryPoint.php 5 files changed, 38 insertions(+), 61 deletions(-) Approvals: Tpt: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/Parser/PagelistTagParser.php b/includes/Parser/PagelistTagParser.php index 304e4f9..357af9a 100644 --- a/includes/Parser/PagelistTagParser.php +++ b/includes/Parser/PagelistTagParser.php @@ -17,17 +17,17 @@ */ public function render( $input, array $args ) { $title = $this-parser-getTitle(); - if ( !$title-inNamespace( ProofreadPage::getIndexNamespaceId() ) ) { + if ( !$title-inNamespace( $this-context-getIndexNamespaceId() ) ) { return ''; } $imageTitle = Title::makeTitleSafe( NS_IMAGE, $title-getText() ); if ( !$imageTitle ) { - return 'strong class=error' . wfMessage( 'proofreadpage_nosuch_file' )-inContentLanguage()-escaped() . '/strong'; + return $this-formatError( 'proofreadpage_nosuch_file' ); } $image = wfFindFile( $imageTitle ); if ( !( $image $image-isMultipage() $image-pageCount() ) ) { - return 'strong class=error' . wfMessage( 'proofreadpage_nosuch_file' )-inContentLanguage()-escaped() . '/strong'; + return $this-formatError( 'proofreadpage_nosuch_file' ); } $return = ''; @@ -39,10 +39,10 @@ $to = array_key_exists( 'to', $args ) ? $args['to'] : $count; if( !is_numeric( $from ) || !is_numeric( $to ) ) { - return 'strong class=error' . wfMessage( 'proofreadpage_number_expected' )-inContentLanguage()-escaped() . '/strong'; + return $this-formatError( 'proofreadpage_number_expected' ); } if( ( $from $to ) || ( $from 1 ) || ( $to 1 ) || ( $to $count ) ) { - return 'strong class=error' . wfMessage( 'proofreadpage_invalid_interval' )-inContentLanguage()-escaped() . '/strong'; + return $this-formatError( 'proofreadpage_invalid_interval' ); } for ( $i = $from; $i $to + 1; $i++ ) { diff --git a/includes/Parser/PagesTagParser.php b/includes/Parser/PagesTagParser.php index cd6efff..a527f9b 100644 --- a/includes/Parser/PagesTagParser.php +++ b/includes/Parser/PagesTagParser.php @@ -18,7 +18,7 @@ * @see TagParser::render */ public function render( $input, array $args ) { - $pageNamespaceId = ProofreadPage::getPageNamespaceId(); + $pageNamespaceId = $this-context-getPageNamespaceId(); // abort if this is nested pages call if ( isset( $this-parser-proofreadRenderingPages ) $this-parser-proofreadRenderingPages ) { @@ -37,7 +37,7 @@ $onlysection = array_key_exists( 'onlysection', $args ) ? $args['onlysection'] : null; // abort if the tag is on an index page - if ( $this-parser-getTitle()-inNamespace( ProofreadPage::getIndexNamespaceId() ) ) { + if ( $this-parser-getTitle()-inNamespace( $this-context-getIndexNamespaceId() ) ) { return ''; } // abort too if the tag is in the page namespace @@ -51,11 +51,11 @@ } if( !$index ) { - return 'strong class=error' . wfMessage( 'proofreadpage_index_expected' )-inContentLanguage()-escaped() . '/strong'; + return $this-formatError( 'proofreadpage_index_expected' ); } - $index_title = Title::makeTitleSafe( ProofreadPage::getIndexNamespaceId(), $index ); + $index_title = Title::makeTitleSafe( $this-context-getIndexNamespaceId(), $index ); if( !$index_title || !$index_title-exists() ) { - return 'strong class=error' . wfMessage( 'proofreadpage_nosuch_index' )-inContentLanguage()-escaped() . '/strong'; + return $this-formatError( 'proofreadpage_nosuch_index' ); } $indexPage = ProofreadIndexPage::newFromTitle( $index_title ); @@ -76,11 +76,11 @@ $imageTitle = Title::makeTitleSafe( NS_IMAGE, $index ); if ( !$imageTitle ) { - return 'strong
[MediaWiki-commits] [Gerrit] Improve tags parser code - change (mediawiki...ProofreadPage)
Tpt has uploaded a new change for review. https://gerrit.wikimedia.org/r/113165 Change subject: Improve tags parser code .. Improve tags parser code Removes a duplicate file Change-Id: Ib44682281a7fb2d473c07e7cec7852b4755b15d8 --- M includes/Parser/PagelistTagParser.php M includes/Parser/PagesTagParser.php M includes/Parser/ParserEntryPoint.php M includes/Parser/TagParser.php D includes/parser/ParserEntryPoint.php 5 files changed, 38 insertions(+), 61 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage refs/changes/65/113165/1 diff --git a/includes/Parser/PagelistTagParser.php b/includes/Parser/PagelistTagParser.php index a3939e3..1c9de85 100644 --- a/includes/Parser/PagelistTagParser.php +++ b/includes/Parser/PagelistTagParser.php @@ -17,17 +17,17 @@ */ public function render( $input, array $args ) { $title = $this-parser-getTitle(); - if ( !$title-inNamespace( ProofreadPage::getIndexNamespaceId() ) ) { + if ( !$title-inNamespace( $this-context-getIndexNamespaceId() ) ) { return ''; } $imageTitle = Title::makeTitleSafe( NS_IMAGE, $title-getText() ); if ( !$imageTitle ) { - return 'strong class=error' . wfMessage( 'proofreadpage_nosuch_file' )-inContentLanguage()-escaped() . '/strong'; + return $this-formatError( 'proofreadpage_nosuch_file' ); } $image = wfFindFile( $imageTitle ); if ( !( $image $image-isMultipage() $image-pageCount() ) ) { - return 'strong class=error' . wfMessage( 'proofreadpage_nosuch_file' )-inContentLanguage()-escaped() . '/strong'; + return $this-formatError( 'proofreadpage_nosuch_file' ); } $return = ''; @@ -39,10 +39,10 @@ $to = array_key_exists( 'to', $args ) ? $args['to'] : $count; if( !is_numeric( $from ) || !is_numeric( $to ) ) { - return 'strong class=error' . wfMessage( 'proofreadpage_number_expected' )-inContentLanguage()-escaped() . '/strong'; + return $this-formatError( 'proofreadpage_number_expected' ); } if( ( $from $to ) || ( $from 1 ) || ( $to 1 ) || ( $to $count ) ) { - return 'strong class=error' . wfMessage( 'proofreadpage_invalid_interval' )-inContentLanguage()-escaped() . '/strong'; + return $this-formatError( 'proofreadpage_invalid_interval' ); } for ( $i = $from; $i $to + 1; $i++ ) { diff --git a/includes/Parser/PagesTagParser.php b/includes/Parser/PagesTagParser.php index cd6efff..a527f9b 100644 --- a/includes/Parser/PagesTagParser.php +++ b/includes/Parser/PagesTagParser.php @@ -18,7 +18,7 @@ * @see TagParser::render */ public function render( $input, array $args ) { - $pageNamespaceId = ProofreadPage::getPageNamespaceId(); + $pageNamespaceId = $this-context-getPageNamespaceId(); // abort if this is nested pages call if ( isset( $this-parser-proofreadRenderingPages ) $this-parser-proofreadRenderingPages ) { @@ -37,7 +37,7 @@ $onlysection = array_key_exists( 'onlysection', $args ) ? $args['onlysection'] : null; // abort if the tag is on an index page - if ( $this-parser-getTitle()-inNamespace( ProofreadPage::getIndexNamespaceId() ) ) { + if ( $this-parser-getTitle()-inNamespace( $this-context-getIndexNamespaceId() ) ) { return ''; } // abort too if the tag is in the page namespace @@ -51,11 +51,11 @@ } if( !$index ) { - return 'strong class=error' . wfMessage( 'proofreadpage_index_expected' )-inContentLanguage()-escaped() . '/strong'; + return $this-formatError( 'proofreadpage_index_expected' ); } - $index_title = Title::makeTitleSafe( ProofreadPage::getIndexNamespaceId(), $index ); + $index_title = Title::makeTitleSafe( $this-context-getIndexNamespaceId(), $index ); if( !$index_title || !$index_title-exists() ) { - return 'strong class=error' . wfMessage( 'proofreadpage_nosuch_index' )-inContentLanguage()-escaped() . '/strong'; + return $this-formatError( 'proofreadpage_nosuch_index' ); } $indexPage = ProofreadIndexPage::newFromTitle( $index_title ); @@ -76,11 +76,11 @@ $imageTitle = Title::makeTitleSafe( NS_IMAGE, $index ); if ( !$imageTitle ) {