Tpt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/97294
Change subject: Remove unneeded use of global variables
......................................................................
Remove unneeded use of global variables
Change-Id: If486cafcf7bba3ed43839d7e400f88d741aa945b
---
M ProofreadPage.body.php
M includes/ProofreadPageInit.php
M includes/ProofreadPageRenderer.php
M includes/index/EditProofreadIndexPage.php
M includes/index/ProofreadIndexPage.php
5 files changed, 29 insertions(+), 40 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage
refs/changes/94/97294/1
diff --git a/ProofreadPage.body.php b/ProofreadPage.body.php
index 9089369..1b72a4e 100644
--- a/ProofreadPage.body.php
+++ b/ProofreadPage.body.php
@@ -774,12 +774,10 @@
/**
* Add the links to previous, next, index page and scan image to Page:
pages.
* @param $skin SkinTemplate object
- * @param $links Structured navigation links
+ * @param $links array structured navigation links
*/
public static function onSkinTemplateNavigation( &$skin, &$links ) {
- global $wgOut;
-
- $title = $wgOut->getTitle();
+ $title = $skin->getTitle();
if( !$title->inNamespace( self::getPageNamespaceId() ) ) {
return true;
}
diff --git a/includes/ProofreadPageInit.php b/includes/ProofreadPageInit.php
index 380c2e8..3155162 100644
--- a/includes/ProofreadPageInit.php
+++ b/includes/ProofreadPageInit.php
@@ -116,10 +116,9 @@
* @return array
*/
protected static function getNamespaceName( $key, $lang = '' ) {
- global $proofreadPageNamespacesNames;
+ global $proofreadPageNamespacesNames, $wgLanguageCode;
if ( $lang === '' ) {
- global $wgLanguageCode;
$lang = $wgLanguageCode;
}
return isset( $proofreadPageNamespacesNames[$lang][$key] )
diff --git a/includes/ProofreadPageRenderer.php
b/includes/ProofreadPageRenderer.php
index a812a13..690c8bd 100644
--- a/includes/ProofreadPageRenderer.php
+++ b/includes/ProofreadPageRenderer.php
@@ -30,8 +30,6 @@
* @return string
*/
public static function renderPageList( $input, $args, $parser ) {
- global $wgContLang;
-
$title = $parser->getTitle();
if ( !$title->inNamespace( ProofreadPage::getIndexNamespaceId()
) ) {
return '';
@@ -69,9 +67,10 @@
}
$n = strlen( $count ) - mb_strlen( $view );
+ $language = $parser->getTargetLanguage();
if ( $n && ( $mode == 'normal' || $mode == 'empty' ) ) {
$txt = '<span style="visibility:hidden;">';
- $pad = $wgContLang->formatNum( 0, true );
+ $pad = $language->formatNum( 0, true );
for ( $j = 0; $j < $n; $j++ ) {
$txt = $txt . $pad;
}
@@ -98,8 +97,6 @@
* @return string
*/
public static function renderPages( $input, $args, $parser ) {
- global $wgContLang;
-
$pageNamespaceId = ProofreadPage::getPageNamespaceId();
// abort if this is nested <pages> call
@@ -144,6 +141,7 @@
$parser->getOutput()->addTemplate( $index_title,
$index_title->getArticleID(), $index_title->getLatestRevID() );
$out = '';
+ $language = $parser->getTargetLanguage();
list( $links, $params ) = $indexPage->getPages();
@@ -151,9 +149,9 @@
$pages = array();
if( empty( $links ) ) {
- $from = ( $from === null ) ? null :
$wgContLang->parseFormattedNumber( $from );
- $to = ( $to === null ) ? null :
$wgContLang->parseFormattedNumber( $to );
- $step = ( $step === null ) ? null :
$wgContLang->parseFormattedNumber( $step );
+ $from = ( $from === null ) ? null :
$language->parseFormattedNumber( $from );
+ $to = ( $to === null ) ? null :
$language->parseFormattedNumber( $to );
+ $step = ( $step === null ) ? null :
$language->parseFormattedNumber( $step );
$imageTitle = Title::makeTitleSafe( NS_IMAGE,
$index );
if ( !$imageTitle ) {
diff --git a/includes/index/EditProofreadIndexPage.php
b/includes/index/EditProofreadIndexPage.php
index 21a50d6..41785ba 100644
--- a/includes/index/EditProofreadIndexPage.php
+++ b/includes/index/EditProofreadIndexPage.php
@@ -29,9 +29,8 @@
* Add custom fields
*/
protected function showContentForm() {
- global $wgOut;
-
$pageLang = $this->mTitle->getPageLanguage();
+ $out = $this->mArticle->getContext()->getOutput();
$inputAttributes = array( 'lang' => $pageLang->getCode(), 'dir'
=> $pageLang->getDir() );
if ( wfReadOnly() ) {
$inputAttributes['readonly'] = '';
@@ -40,16 +39,16 @@
$index = new ProofreadIndexPage( $this->mTitle,
ProofreadIndexPage::getDataConfig(), $this->textbox1 );
$entries = $index->getIndexEntries();
- $wgOut->addHTML( Html::openElement( 'table', array( 'id' =>
'prp-formTable' ) ) );
+ $out->addHTML( Html::openElement( 'table', array( 'id' =>
'prp-formTable' ) ) );
$i = 10;
foreach( $entries as $entry ) {
$inputAttributes['tabindex'] = $i;
- $this->addEntry( $entry, $inputAttributes );
+ $this->addEntry( $entry, $inputAttributes, $out );
$i++;
}
- $wgOut->addHTML( Html::closeElement( 'table' ) );
+ $out->addHTML( Html::closeElement( 'table' ) );
- $wgOut->addModules( 'ext.proofreadpage.index' );
+ $out->addModules( 'ext.proofreadpage.index' );
}
/**
@@ -58,16 +57,14 @@
* @param $entry ProofreadIndexEntry
* @param $inputAttributes array
*/
- protected function addEntry( ProofreadIndexEntry $entry,
$inputAttributes = array() ) {
- global $wgOut;
-
+ protected function addEntry( ProofreadIndexEntry $entry,
$inputAttributes, OutputPage $out ) {
if ( $entry->isHidden() ) {
return;
}
$key = $this->getFieldNameForEntry( $entry->getKey() );
$val = $this->safeUnicodeOutput( $entry->getStringValue() );
- $wgOut->addHTML(
+ $out->addHTML(
Html::openElement( 'tr' ) .
Html::openElement( 'th', array( 'scope' =>
'row' ) ) .
Xml::label( $entry->getLabel(), $key )
@@ -76,10 +73,10 @@
$help = $entry->getHelp();
if ( $help !== '' ) {
- $wgOut->addHTML( Html::element( 'span', array( 'title'
=> $help, 'class' => 'prp-help-field' ) ) );
+ $out->addHTML( Html::element( 'span', array( 'title' =>
$help, 'class' => 'prp-help-field' ) ) );
}
- $wgOut->addHTML(
+ $out->addHTML(
Html::closeElement( 'th' ) .
Html::openElement( 'td' )
);
@@ -93,7 +90,7 @@
if ( !isset( $values[$val] ) && $val !== '' ) {
//compatiblity with already set data that aren't in the list
$select->addOption( $val, $val );
}
- $wgOut->addHTML( $select->getHtml() );
+ $out->addHTML( $select->getHtml() );
} else {
$type = $entry->getType();
$inputType = ( $type === 'number' ) ? 'number' : 'text';
@@ -104,16 +101,16 @@
$inputAttributes['type'] = $inputType;
$inputAttributes['id'] = $key;
$inputAttributes['size'] = 60;
- $wgOut->addHTML( Html::input( $key, $val,
$inputType, $inputAttributes ) );
+ $out->addHTML( Html::input( $key, $val,
$inputType, $inputAttributes ) );
}
else {
$inputAttributes['cols'] = 60;
$inputAttributes['rows'] = $size;
- $wgOut->addHTML( Html::textarea( $key, $val,
$inputAttributes ) );
+ $out->addHTML( Html::textarea( $key, $val,
$inputAttributes ) );
}
}
- $wgOut->addHTML(
+ $out->addHTML(
Html::closeElement( 'td' ) .
Html::closeElement( 'tr' )
);
@@ -189,8 +186,6 @@
* Check the validity of the page
*/
function internalAttemptSave( &$result, $bot = false ) {
- global $wgOut;
-
$index = new ProofreadIndexPage( $this->mTitle,
ProofreadIndexPage::getDataConfig(), $this->textbox1 );
list( $links, $params ) = $index->getPages();
@@ -202,7 +197,10 @@
}
if ( count( $linksTitle ) !== count( array_unique(
$linksTitle ) ) ) {
- $wgOut->showErrorPage(
'proofreadpage_indexdupe', 'proofreadpage_indexdupetext' );
+ $this->mArticle
+ ->getContext()
+ ->getOutput()
+ ->showErrorPage(
'proofreadpage_indexdupe', 'proofreadpage_indexdupetext' );
$status = Status::newGood();
$status->fatal( 'hookaborted' );
$status->value = self::AS_HOOK_ERROR;
diff --git a/includes/index/ProofreadIndexPage.php
b/includes/index/ProofreadIndexPage.php
index 49bbaa0..b438776 100644
--- a/includes/index/ProofreadIndexPage.php
+++ b/includes/index/ProofreadIndexPage.php
@@ -332,8 +332,6 @@
* @return array
*/
public function getPreviousAndNextPages( Title $page ) {
- global $wgContLang;
-
$image = $this->getImage();
// if multipage, we use the page order, but we should read
pagenum from the index
@@ -341,7 +339,7 @@
$pagenr = 1;
$parts = explode( '/', $page->getText() );
if ( count( $parts ) > 1 ) {
- $pagenr = intval(
$wgContLang->parseFormattedNumber( array_pop( $parts ) ) );
+ $pagenr = intval(
$this->title->getPageLanguage()->parseFormattedNumber( array_pop( $parts ) ) );
}
$count = $image->pageCount();
if ( $pagenr < 1 || $pagenr > $count || $count < 1 ) {
@@ -369,20 +367,18 @@
}
/**
- * Return the Title of the previous and the next page pages
+ * Return the page number to display
* @param $page Title the page
* @return string|null
* @todo Move to pager system
*/
public function getDisplayedPageNumber( Title $page ) {
- global $wgContLang;
-
list( $links, $params ) = $this->getPages();
if ( $links === null ) {
$pagenr = 1; //TODO move it to
ProofreadPagePage::getPosition()
$parts = explode( '/', $page->getText() );
if ( count( $parts ) > 1 ) {
- $pagenr = intval(
$wgContLang->parseFormattedNumber( array_pop( $parts ) ) );
+ $pagenr = intval(
$this->title->getPageLanguage()->parseFormattedNumber( array_pop( $parts ) ) );
list( $pagenum, $links, $mode ) =
ProofreadPage::pageNumber( $pagenr, $params );
return $pagenum;
}
--
To view, visit https://gerrit.wikimedia.org/r/97294
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If486cafcf7bba3ed43839d7e400f88d741aa945b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ProofreadPage
Gerrit-Branch: master
Gerrit-Owner: Tpt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits