* Use local context instead of global variables
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Thu, 4 Aug 2011 15:48:36 +0000 (15:48 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Thu, 4 Aug 2011 15:48:36 +0000 (15:48 +0000)
* Call Linker methods statically

includes/specials/SpecialAllpages.php
includes/specials/SpecialPrefixindex.php

index a9cbf3a..5b848f0 100644 (file)
@@ -249,7 +249,7 @@ class SpecialAllpages extends IncludableSpecialPage {
                                                                $nsForm .
                                                        '</td>
                                                        <td class="mw-allpages-nav">' .
-                                                               $this->getSkin()->link( $this->getTitle(), wfMsgHtml ( 'allpages' ),
+                                                               Linker::link( $this->getTitle(), wfMsgHtml ( 'allpages' ),
                                                                        array(), array(), 'known' ) .
                                                        "</td>
                                                </tr>" .
@@ -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 ? '<div class="allpagesredirect">' : '' ) .
-                                                       $sk->link( $t ) .
+                                                       Linker::link( $t ) .
                                                        ($s->page_is_redirect ? '</div>' : '' );
                                        } else {
                                                $link = '[[' . htmlspecialchars( $s->page_title ) . ']]';
@@ -411,7 +410,7 @@ class SpecialAllpages extends IncludableSpecialPage {
                                                                $nsForm .
                                                        '</td>
                                                        <td class="mw-allpages-nav">' .
-                                                               $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 .= "</td></tr></table>";
                }
@@ -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 )
                                ) );
                }
 
index ad2bb74..3b64ee9 100644 (file)
@@ -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 ? '<div class="allpagesredirect">' : '' ) .
-                                                       $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 );
        }
 }