* Use local context instead of global variables
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 11 Sep 2011 08:43:30 +0000 (08:43 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sun, 11 Sep 2011 08:43:30 +0000 (08:43 +0000)
* Call Linker methods statically
* Added missing call to outputHeader()

includes/specials/SpecialLinkSearch.php

index 7ecad85..a37bdec 100644 (file)
@@ -43,12 +43,17 @@ class LinkSearchPage extends QueryPage {
        }
 
        function execute( $par ) {
-               global $wgOut, $wgRequest, $wgUrlProtocols, $wgMiserMode, $wgLang;
+               global $wgUrlProtocols, $wgMiserMode;
+
                $this->setHeaders();
-               $wgOut->allowClickjacking();
+               $this->outputHeader();
+
+               $out = $this->getOutput();
+               $out->allowClickjacking();
 
-               $target = $wgRequest->getVal( 'target', $par );
-               $namespace = $wgRequest->getIntorNull( 'namespace', null );
+               $request = $this->getRequest();
+               $target = $request->getVal( 'target', $par );
+               $namespace = $request->getIntorNull( 'namespace', null );
 
                $protocols_list[] = '';
                foreach( $wgUrlProtocols as $prot ) {
@@ -77,11 +82,9 @@ class LinkSearchPage extends QueryPage {
                        $protocol = '';
                }
 
-               $self = $this->getTitle();
-
-               $wgOut->addWikiMsg( 'linksearch-text', '<nowiki>' . $wgLang->commaList( $wgUrlProtocols ) . '</nowiki>' );
+               $out->addWikiMsg( 'linksearch-text', '<nowiki>' . $this->getLang()->commaList( $wgUrlProtocols ) . '</nowiki>' );
                $s = Xml::openElement( 'form', array( 'id' => 'mw-linksearch-form', 'method' => 'get', 'action' => $GLOBALS['wgScript'] ) ) .
-                       Html::hidden( 'title', $self->getPrefixedDbKey() ) .
+                       Html::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
                        '<fieldset>' .
                        Xml::element( 'legend', array(), wfMsg( 'linksearch' ) ) .
                        Xml::inputLabel( wfMsg( 'linksearch-pat' ), 'target', 'target', 50, $target ) . ' ';
@@ -92,7 +95,7 @@ class LinkSearchPage extends QueryPage {
                $s .=   Xml::submitButton( wfMsg( 'linksearch-ok' ) ) .
                        '</fieldset>' .
                        Xml::closeElement( 'form' );
-               $wgOut->addHTML( $s );
+               $out->addHTML( $s );
 
                if( $target != '' ) {
                        $this->setParams( array(
@@ -101,7 +104,7 @@ class LinkSearchPage extends QueryPage {
                                'protocol' => $protocol ) );
                        parent::execute( $par );
                        if( $this->mMungedQuery === false )
-                               $wgOut->addWikiMsg( 'linksearch-error' );
+                               $out->addWikiMsg( 'linksearch-error' );
                }
        }
 
@@ -172,8 +175,8 @@ class LinkSearchPage extends QueryPage {
        function formatResult( $skin, $result ) {
                $title = Title::makeTitle( $result->namespace, $result->title );
                $url = $result->url;
-               $pageLink = $skin->linkKnown( $title );
-               $urlLink = $skin->makeExternalLink( $url, $url );
+               $pageLink = Linker::linkKnown( $title );
+               $urlLink = Linker::makeExternalLink( $url, $url );
 
                return wfMsgHtml( 'linksearch-line', $urlLink, $pageLink );
        }
@@ -182,14 +185,13 @@ class LinkSearchPage extends QueryPage {
         * Override to check query validity.
         */
        function doQuery( $offset = false, $limit = false ) {
-               global $wgOut;
                list( $this->mMungedQuery,  ) = LinkSearchPage::mungeQuery( $this->mQuery, $this->mProt );
                if( $this->mMungedQuery === false ) {
-                       $wgOut->addWikiMsg( 'linksearch-error' );
+                       $this->getOutput()->addWikiMsg( 'linksearch-error' );
                } else {
                        // For debugging
                        // Generates invalid xhtml with patterns that contain --
-                       //$wgOut->addHTML( "\n<!-- " . htmlspecialchars( $this->mMungedQuery ) . " -->\n" );
+                       //$this->getOutput()->addHTML( "\n<!-- " . htmlspecialchars( $this->mMungedQuery ) . " -->\n" );
                        parent::doQuery( $offset, $limit );
                }
        }