From 50fa326116582087c6ea31430d9ace9ff4f91cbc Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Thu, 4 Aug 2011 15:48:36 +0000 Subject: [PATCH] * Use local context instead of global variables * Call Linker methods statically --- includes/specials/SpecialAllpages.php | 19 ++++++------- includes/specials/SpecialPrefixindex.php | 36 +++++++++++++----------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/includes/specials/SpecialAllpages.php b/includes/specials/SpecialAllpages.php index a9cbf3ab77..5b848f0e08 100644 --- a/includes/specials/SpecialAllpages.php +++ b/includes/specials/SpecialAllpages.php @@ -249,7 +249,7 @@ class SpecialAllpages extends IncludableSpecialPage { $nsForm . ' ' . - $this->getSkin()->link( $this->getTitle(), wfMsgHtml ( 'allpages' ), + Linker::link( $this->getTitle(), wfMsgHtml ( 'allpages' ), array(), array(), 'known' ) . " " . @@ -293,9 +293,8 @@ class SpecialAllpages extends IncludableSpecialPage { * @param $to String: list all pages to this name (default FALSE) */ function showChunk( $namespace = NS_MAIN, $from = false, $to = false ) { - global $wgContLang, $wgLang; + global $wgContLang; $output = $this->getOutput(); - $sk = $this->getSkin(); $fromList = $this->getNamespaceKeyAndText($namespace, $from); $toList = $this->getNamespaceKeyAndText( $namespace, $to ); @@ -338,7 +337,7 @@ class SpecialAllpages extends IncludableSpecialPage { $t = Title::newFromRow( $s ); if( $t ) { $link = ( $s->page_is_redirect ? '
' : '' ) . - $sk->link( $t ) . + Linker::link( $t ) . ($s->page_is_redirect ? '
' : '' ); } else { $link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; @@ -411,7 +410,7 @@ class SpecialAllpages extends IncludableSpecialPage { $nsForm . ' ' . - $sk->link( $self, wfMsgHtml ( 'allpages' ) ); + Linker::link( $self, wfMsgHtml ( 'allpages' ) ); # Do we put a previous link ? if( isset( $prevTitle ) && $pt = $prevTitle->getText() ) { @@ -420,13 +419,13 @@ class SpecialAllpages extends IncludableSpecialPage { if( $namespace ) $query['namespace'] = $namespace; - $prevLink = $sk->linkKnown( + $prevLink = Linker::linkKnown( $self, wfMessage( 'prevpage', $pt )->escaped(), array(), $query ); - $out2 = $wgLang->pipeList( array( $out2, $prevLink ) ); + $out2 = $this->getLang()->pipeList( array( $out2, $prevLink ) ); } if( $n == $this->maxPerPage && $s = $res->fetchObject() ) { @@ -437,13 +436,13 @@ class SpecialAllpages extends IncludableSpecialPage { if( $namespace ) $query['namespace'] = $namespace; - $nextLink = $sk->linkKnown( + $nextLink = Linker::linkKnown( $self, wfMessage( 'nextpage', $t->getText() )->escaped(), array(), $query ); - $out2 = $wgLang->pipeList( array( $out2, $nextLink ) ); + $out2 = $this->getLang()->pipeList( array( $out2, $nextLink ) ); } $out2 .= ""; } @@ -458,7 +457,7 @@ class SpecialAllpages extends IncludableSpecialPage { $output->addHTML( Html::element( 'hr' ) . Html::rawElement( 'div', array( 'class' => 'mw-allpages-nav' ), - $wgLang->pipeList( $links ) + $this->getLang()->pipeList( $links ) ) ); } diff --git a/includes/specials/SpecialPrefixindex.php b/includes/specials/SpecialPrefixindex.php index ad2bb746f7..3b64ee9a8f 100644 --- a/includes/specials/SpecialPrefixindex.php +++ b/includes/specials/SpecialPrefixindex.php @@ -38,20 +38,23 @@ class SpecialPrefixindex extends SpecialAllpages { * @param $par String: becomes "FOO" when called like Special:Prefixindex/FOO (default null) */ function execute( $par ) { - global $wgRequest, $wgOut, $wgContLang; + global $wgContLang; $this->setHeaders(); $this->outputHeader(); - $wgOut->addModuleStyles( 'mediawiki.special' ); + + $out = $this->getOutput(); + $out->addModuleStyles( 'mediawiki.special' ); # GET values - $from = $wgRequest->getVal( 'from', '' ); - $prefix = $wgRequest->getVal( 'prefix', '' ); - $ns = $wgRequest->getIntOrNull( 'namespace' ); + $request = $this->getRequest(); + $from = $request->getVal( 'from', '' ); + $prefix = $request->getVal( 'prefix', '' ); + $ns = $request->getIntOrNull( 'namespace' ); $namespace = (int)$ns; // if no namespace given, use 0 (NS_MAIN). $namespaces = $wgContLang->getNamespaces(); - $wgOut->setPagetitle( + $out->setPagetitle( ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces ) ) ) ? wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) : wfMsg( 'prefixindex' ) @@ -71,7 +74,7 @@ class SpecialPrefixindex extends SpecialAllpages { if ( $this->including() || $showme != '' || $ns !== null ) { $this->showPrefixChunk( $namespace, $showme, $from ); } else { - $wgOut->addHTML( $this->namespacePrefixForm( $namespace, null ) ); + $out->addHTML( $this->namespacePrefixForm( $namespace, null ) ); } } @@ -82,11 +85,10 @@ class SpecialPrefixindex extends SpecialAllpages { */ function namespacePrefixForm( $namespace = NS_MAIN, $from = '' ) { global $wgScript; - $t = $this->getTitle(); $out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) ); $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); - $out .= Html::hidden( 'title', $t->getPrefixedText() ); + $out .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ); $out .= Xml::openElement( 'fieldset' ); $out .= Xml::element( 'legend', null, wfMsg( 'allpages' ) ); $out .= Xml::openElement( 'table', array( 'id' => 'nsselect', 'class' => 'allpages' ) ); @@ -120,11 +122,11 @@ class SpecialPrefixindex extends SpecialAllpages { * @param $from String: list all pages from this name (default FALSE) */ function showPrefixChunk( $namespace = NS_MAIN, $prefix, $from = null ) { - global $wgOut, $wgContLang, $wgLang; - - $sk = $this->getSkin(); + global $wgContLang; - if (!isset($from)) $from = $prefix; + if ( $from === null ) { + $from = $prefix; + } $fromList = $this->getNamespaceKeyAndText($namespace, $from); $prefixList = $this->getNamespaceKeyAndText($namespace, $prefix); @@ -169,7 +171,7 @@ class SpecialPrefixindex extends SpecialAllpages { $t = Title::makeTitle( $s->page_namespace, $s->page_title ); if( $t ) { $link = ($s->page_is_redirect ? '
' : '' ) . - $sk->linkKnown( + Linker::linkKnown( $t, htmlspecialchars( $t->getText() ) ) . @@ -217,9 +219,9 @@ class SpecialPrefixindex extends SpecialAllpages { $query['namespace'] = $namespace; } - $out2 = $wgLang->pipeList( array( + $out2 = $this->getLang()->pipeList( array( $out2, - $sk->linkKnown( + Linker::linkKnown( $self, wfMsgHtml( 'nextpage', str_replace( '_',' ', htmlspecialchars( $s->page_title ) ) ), array(), @@ -231,6 +233,6 @@ class SpecialPrefixindex extends SpecialAllpages { Xml::closeElement( 'table' ); } - $wgOut->addHTML( $out2 . $out ); + $this->getOutput()->addHTML( $out2 . $out ); } } -- 2.20.1