r93978 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93977‎ | r93978 | r93979 >
Date:14:58, 5 August 2011
Author:ialex
Status:ok
Tags:
Comment:
* Use local context instead of global variables
* Call Linker methods statically
Modified paths:
  • /trunk/phase3/includes/specials/SpecialFileDuplicateSearch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialFileDuplicateSearch.php
@@ -62,19 +62,16 @@
6363 * @param $dupes Array of File objects
6464 */
6565 function showList( $dupes ) {
66 - global $wgOut;
67 - $skin = $this->getSkin();
68 -
6966 $html = array();
7067 $html[] = $this->openList( 0 );
7168
7269 foreach ( $dupes as $dupe ) {
73 - $line = $this->formatResult( $skin, $dupe );
 70+ $line = $this->formatResult( null, $dupe );
7471 $html[] = "<li>" . $line . "</li>";
7572 }
7673 $html[] = $this->closeList();
7774
78 - $wgOut->addHtml( implode( "\n", $html ) );
 75+ $this->getOutput()->addHtml( implode( "\n", $html ) );
7976 }
8077
8178 function getQueryInfo() {
@@ -91,12 +88,12 @@
9289 }
9390
9491 function execute( $par ) {
95 - global $wgRequest, $wgOut, $wgLang, $wgScript;
 92+ global $wgScript;
9693
9794 $this->setHeaders();
9895 $this->outputHeader();
9996
100 - $this->filename = isset( $par ) ? $par : $wgRequest->getText( 'filename' );
 97+ $this->filename = isset( $par ) ? $par : $this->getRequest()->getText( 'filename' );
10198 $this->file = null;
10299 $this->hash = '';
103100 $title = Title::newFromText( $this->filename, NS_FILE );
@@ -104,8 +101,10 @@
105102 $this->file = wfFindFile( $title );
106103 }
107104
 105+ $out = $this->getOutput();
 106+
108107 # Create the input form
109 - $wgOut->addHTML(
 108+ $out->addHTML(
110109 Xml::openElement( 'form', array( 'id' => 'fileduplicatesearch', 'method' => 'get', 'action' => $wgScript ) ) .
111110 Html::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
112111 Xml::openElement( 'fieldset' ) .
@@ -119,7 +118,7 @@
120119 if( $this->file ) {
121120 $this->hash = $this->file->getSha1();
122121 } elseif( $this->filename !== '' ) {
123 - $wgOut->wrapWikiMsg(
 122+ $out->wrapWikiMsg(
124123 "<p class='mw-fileduplicatesearch-noresults'>\n$1\n</p>",
125124 array( 'fileduplicatesearch-noresults', wfEscapeWikiText( $this->filename ) )
126125 );
@@ -131,12 +130,12 @@
132131 if ( $img ) {
133132 $thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) );
134133 if( $thumb ) {
135 - $wgOut->addHTML( '<div class="mw-float-end" id="mw-fileduplicatesearch-icon">' .
 134+ $out->addHTML( '<div class="mw-float-end" id="mw-fileduplicatesearch-icon">' .
136135 $thumb->toHtml( array( 'desc-link' => false ) ) . '<br />' .
137136 wfMsgExt( 'fileduplicatesearch-info', array( 'parse' ),
138 - $wgLang->formatNum( $img->getWidth() ),
139 - $wgLang->formatNum( $img->getHeight() ),
140 - $wgLang->formatSize( $img->getSize() ),
 137+ $this->getLang()->formatNum( $img->getWidth() ),
 138+ $this->getLang()->formatNum( $img->getHeight() ),
 139+ $this->getLang()->formatSize( $img->getSize() ),
141140 $img->getMimeType()
142141 ) .
143142 '</div>' );
@@ -148,15 +147,15 @@
149148
150149 # Show a short summary
151150 if( $numRows == 1 ) {
152 - $wgOut->wrapWikiMsg(
 151+ $out->wrapWikiMsg(
153152 "<p class='mw-fileduplicatesearch-result-1'>\n$1\n</p>",
154153 array( 'fileduplicatesearch-result-1', wfEscapeWikiText( $this->filename ) )
155154 );
156155 } elseif ( $numRows ) {
157 - $wgOut->wrapWikiMsg(
 156+ $out->wrapWikiMsg(
158157 "<p class='mw-fileduplicatesearch-result-n'>\n$1\n</p>",
159158 array( 'fileduplicatesearch-result-n', wfEscapeWikiText( $this->filename ),
160 - $wgLang->formatNum( $numRows - 1 ) )
 159+ $this->getLang()->formatNum( $numRows - 1 ) )
161160 );
162161 }
163162
@@ -171,18 +170,18 @@
172171 * @return string
173172 */
174173 function formatResult( $skin, $result ) {
175 - global $wgContLang, $wgLang;
 174+ global $wgContLang;
176175
177176 $nt = $result->getTitle();
178177 $text = $wgContLang->convert( $nt->getText() );
179 - $plink = $skin->link(
 178+ $plink = Linker::link(
180179 Title::newFromText( $nt->getPrefixedText() ),
181180 $text
182181 );
183182
184183 $userText = $result->getUser( 'text' );
185 - $user = $skin->link( Title::makeTitle( NS_USER, $userText ), $userText );
186 - $time = $wgLang->timeanddate( $result->getTimestamp() );
 184+ $user = Linker::link( Title::makeTitle( NS_USER, $userText ), $userText );
 185+ $time = $this->getLang()->timeanddate( $result->getTimestamp() );
187186
188187 return "$plink . . $user . . $time";
189188 }

Status & tagging log