r96774 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96773‎ | r96774 | r96775 >
Date:08:43, 11 September 2011
Author:ialex
Status:ok (Comments)
Tags:
Comment:
* Use local context instead of global variables
* Call Linker methods statically
* Added missing call to outputHeader()
Modified paths:
  • /trunk/phase3/includes/specials/SpecialLinkSearch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialLinkSearch.php
@@ -43,13 +43,18 @@
4444 }
4545
4646 function execute( $par ) {
47 - global $wgOut, $wgRequest, $wgUrlProtocols, $wgMiserMode, $wgLang;
 47+ global $wgUrlProtocols, $wgMiserMode;
 48+
4849 $this->setHeaders();
49 - $wgOut->allowClickjacking();
 50+ $this->outputHeader();
5051
51 - $target = $wgRequest->getVal( 'target', $par );
52 - $namespace = $wgRequest->getIntorNull( 'namespace', null );
 52+ $out = $this->getOutput();
 53+ $out->allowClickjacking();
5354
 55+ $request = $this->getRequest();
 56+ $target = $request->getVal( 'target', $par );
 57+ $namespace = $request->getIntorNull( 'namespace', null );
 58+
5459 $protocols_list[] = '';
5560 foreach( $wgUrlProtocols as $prot ) {
5661 $protocols_list[] = $prot;
@@ -77,11 +82,9 @@
7883 $protocol = '';
7984 }
8085
81 - $self = $this->getTitle();
82 -
83 - $wgOut->addWikiMsg( 'linksearch-text', '<nowiki>' . $wgLang->commaList( $wgUrlProtocols ) . '</nowiki>' );
 86+ $out->addWikiMsg( 'linksearch-text', '<nowiki>' . $this->getLang()->commaList( $wgUrlProtocols ) . '</nowiki>' );
8487 $s = Xml::openElement( 'form', array( 'id' => 'mw-linksearch-form', 'method' => 'get', 'action' => $GLOBALS['wgScript'] ) ) .
85 - Html::hidden( 'title', $self->getPrefixedDbKey() ) .
 88+ Html::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
8689 '<fieldset>' .
8790 Xml::element( 'legend', array(), wfMsg( 'linksearch' ) ) .
8891 Xml::inputLabel( wfMsg( 'linksearch-pat' ), 'target', 'target', 50, $target ) . ' ';
@@ -92,7 +95,7 @@
9396 $s .= Xml::submitButton( wfMsg( 'linksearch-ok' ) ) .
9497 '</fieldset>' .
9598 Xml::closeElement( 'form' );
96 - $wgOut->addHTML( $s );
 99+ $out->addHTML( $s );
97100
98101 if( $target != '' ) {
99102 $this->setParams( array(
@@ -101,7 +104,7 @@
102105 'protocol' => $protocol ) );
103106 parent::execute( $par );
104107 if( $this->mMungedQuery === false )
105 - $wgOut->addWikiMsg( 'linksearch-error' );
 108+ $out->addWikiMsg( 'linksearch-error' );
106109 }
107110 }
108111
@@ -172,8 +175,8 @@
173176 function formatResult( $skin, $result ) {
174177 $title = Title::makeTitle( $result->namespace, $result->title );
175178 $url = $result->url;
176 - $pageLink = $skin->linkKnown( $title );
177 - $urlLink = $skin->makeExternalLink( $url, $url );
 179+ $pageLink = Linker::linkKnown( $title );
 180+ $urlLink = Linker::makeExternalLink( $url, $url );
178181
179182 return wfMsgHtml( 'linksearch-line', $urlLink, $pageLink );
180183 }
@@ -182,14 +185,13 @@
183186 * Override to check query validity.
184187 */
185188 function doQuery( $offset = false, $limit = false ) {
186 - global $wgOut;
187189 list( $this->mMungedQuery, ) = LinkSearchPage::mungeQuery( $this->mQuery, $this->mProt );
188190 if( $this->mMungedQuery === false ) {
189 - $wgOut->addWikiMsg( 'linksearch-error' );
 191+ $this->getOutput()->addWikiMsg( 'linksearch-error' );
190192 } else {
191193 // For debugging
192194 // Generates invalid xhtml with patterns that contain --
193 - //$wgOut->addHTML( "\n<!-- " . htmlspecialchars( $this->mMungedQuery ) . " -->\n" );
 195+ //$this->getOutput()->addHTML( "\n<!-- " . htmlspecialchars( $this->mMungedQuery ) . " -->\n" );
194196 parent::doQuery( $offset, $limit );
195197 }
196198 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r107901MFT r96774reedy17:13, 3 January 2012
r107938MFT r96774, r98690, r99840reedy21:00, 3 January 2012

Comments

#Comment by MarkAHershberger (talk | contribs)   21:45, 4 December 2011

Without this rev $out is left undefined since r104033 was merged.

Status & tagging log