From: Alexandre Emsenhuber Date: Mon, 8 Aug 2011 21:07:17 +0000 (+0000) Subject: Use local context instead of global variables X-Git-Tag: 1.31.0-rc.0~28386 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=090f743683f29a97f4204c489f59cbd01a53fb72;p=lhc%2Fweb%2Fwiklou.git Use local context instead of global variables --- diff --git a/includes/QueryPage.php b/includes/QueryPage.php index da8faf5b14..c5a093df83 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -437,24 +437,23 @@ abstract class QueryPage extends SpecialPage { * real, honest-to-gosh query page. */ function execute( $par ) { - global $wgUser, $wgOut, $wgLang, $wgRequest; - - if ( !$this->userCanExecute( $wgUser ) ) { + if ( !$this->userCanExecute( $this->getUser() ) ) { $this->displayRestrictionError(); return; } if ( $this->limit == 0 && $this->offset == 0 ) { - list( $this->limit, $this->offset ) = $wgRequest->getLimitOffset(); + list( $this->limit, $this->offset ) = $this->getRequest()->getLimitOffset(); } $dbr = wfGetDB( DB_SLAVE ); $this->setHeaders(); - $wgOut->setSyndicated( $this->isSyndicated() ); + $out = $this->getOutput(); + $out->setSyndicated( $this->isSyndicated() ); if ( $this->isCached() && !$this->isCacheable() ) { - $wgOut->setSyndicated( false ); - $wgOut->addWikiMsg( 'querypage-disabled' ); + $out->setSyndicated( false ); + $out->addWikiMsg( 'querypage-disabled' ); return 0; } @@ -471,21 +470,22 @@ abstract class QueryPage extends SpecialPage { $ts = $this->getCachedTimestamp(); if ( $ts ) { - $updated = $wgLang->timeanddate( $ts, true, true ); - $updateddate = $wgLang->date( $ts, true, true ); - $updatedtime = $wgLang->time( $ts, true, true ); - $wgOut->addMeta( 'Data-Cache-Time', $ts ); - $wgOut->addInlineScript( "var dataCacheTime = '$ts';" ); - $wgOut->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime ); + $lang = $this->getLang(); + $updated = $lang->timeanddate( $ts, true, true ); + $updateddate = $lang->date( $ts, true, true ); + $updatedtime = $lang->time( $ts, true, true ); + $out->addMeta( 'Data-Cache-Time', $ts ); + $out->addInlineScript( "var dataCacheTime = '$ts';" ); + $out->addWikiMsg( 'perfcachedts', $updated, $updateddate, $updatedtime ); } else { - $wgOut->addWikiMsg( 'perfcached' ); + $out->addWikiMsg( 'perfcached' ); } # If updates on this page have been disabled, let the user know # that the data set won't be refreshed for now global $wgDisableQueryPageUpdate; if ( is_array( $wgDisableQueryPageUpdate ) && in_array( $this->getName(), $wgDisableQueryPageUpdate ) ) { - $wgOut->addWikiMsg( 'querypage-no-updates' ); + $out->addWikiMsg( 'querypage-no-updates' ); } } @@ -496,23 +496,23 @@ abstract class QueryPage extends SpecialPage { $this->preprocessResults( $dbr, $res ); - $wgOut->addHTML( Xml::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) ); + $out->addHTML( Xml::openElement( 'div', array( 'class' => 'mw-spcontent' ) ) ); # Top header and navigation if ( $this->shownavigation ) { - $wgOut->addHTML( $this->getPageHeader() ); + $out->addHTML( $this->getPageHeader() ); if ( $this->numRows > 0 ) { - $wgOut->addHTML( '

' . wfShowingResults( $this->offset, $this->numRows ) . '

' ); + $out->addHTML( '

' . wfShowingResults( $this->offset, $this->numRows ) . '

' ); # Disable the "next" link when we reach the end $paging = wfViewPrevNext( $this->offset, $this->limit, $this->getTitle( $par ), wfArrayToCGI( $this->linkParameters() ), ( $this->numRows < $this->limit ) ); - $wgOut->addHTML( '

' . $paging . '

' ); + $out->addHTML( '

' . $paging . '

' ); } else { # No results to show, so don't bother with "showing X of Y" etc. # -- just let the user know and give up now - $wgOut->addHTML( '

' . wfMsgHtml( 'specialpage-empty' ) . '

' ); - $wgOut->addHTML( Xml::closeElement( 'div' ) ); + $out->addHTML( '

' . wfMsgHtml( 'specialpage-empty' ) . '

' ); + $out->addHTML( Xml::closeElement( 'div' ) ); return; } } @@ -520,7 +520,7 @@ abstract class QueryPage extends SpecialPage { # The actual results; specialist subclasses will want to handle this # with more than a straight list, so we hand them the info, plus # an OutputPage, and let them get on with it - $this->outputResults( $wgOut, + $this->outputResults( $out, $this->getSkin(), $dbr, # Should use a ResultWrapper for this $res, @@ -529,10 +529,10 @@ abstract class QueryPage extends SpecialPage { # Repeat the paging links at the bottom if ( $this->shownavigation ) { - $wgOut->addHTML( '

' . $paging . '

' ); + $out->addHTML( '

' . $paging . '

' ); } - $wgOut->addHTML( Xml::closeElement( 'div' ) ); + $out->addHTML( Xml::closeElement( 'div' ) ); return $this->numRows; } @@ -617,8 +617,7 @@ abstract class QueryPage extends SpecialPage { global $wgFeed, $wgFeedClasses; if ( !$wgFeed ) { - global $wgOut; - $wgOut->addWikiMsg( 'feed-unavailable' ); + $this->getOutput()->addWikiMsg( 'feed-unavailable' ); return; } @@ -787,10 +786,9 @@ abstract class WantedQueryPage extends QueryPage { * @return string */ private function makeWlhLink( $title, $skin, $result ) { - global $wgLang; $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' ); $label = wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ), - $wgLang->formatNum( $result->value ) ); + $this->getLang()->formatNum( $result->value ) ); return $skin->link( $wlh, $label, array(), array( 'target' => $title->getPrefixedText() ) ); } }