Add numerous missing @throws to method documentation
[lhc/web/wiklou.git] / includes / specials / SpecialFileDuplicateSearch.php
index 0a7a6ef..96739ea 100644 (file)
@@ -40,9 +40,17 @@ class FileDuplicateSearchPage extends QueryPage {
                parent::__construct( $name );
        }
 
-       function isSyndicated() { return false; }
-       function isCacheable() { return false; }
-       function isCached() { return false; }
+       function isSyndicated() {
+               return false;
+       }
+
+       function isCacheable() {
+               return false;
+       }
+
+       function isCached() {
+               return false;
+       }
 
        function linkParameters() {
                return array( 'filename' => $this->filename );
@@ -78,8 +86,8 @@ class FileDuplicateSearchPage extends QueryPage {
                return array(
                        'tables' => array( 'image' ),
                        'fields' => array(
-                               'img_name AS title',
-                               'img_sha1 AS value',
+                               'title' => 'img_name',
+                               'value' => 'img_sha1',
                                'img_user_text',
                                'img_timestamp'
                        ),
@@ -108,9 +116,9 @@ class FileDuplicateSearchPage extends QueryPage {
                        Xml::openElement( 'form', array( 'id' => 'fileduplicatesearch', 'method' => 'get', 'action' => $wgScript ) ) .
                        Html::hidden( 'title', $this->getTitle()->getPrefixedDbKey() ) .
                        Xml::openElement( 'fieldset' ) .
-                       Xml::element( 'legend', null, wfMsg( 'fileduplicatesearch-legend' ) ) .
-                       Xml::inputLabel( wfMsg( 'fileduplicatesearch-filename' ), 'filename', 'filename', 50, $this->filename ) . ' ' .
-                       Xml::submitButton( wfMsg( 'fileduplicatesearch-submit' ) ) .
+                       Xml::element( 'legend', null, $this->msg( 'fileduplicatesearch-legend' )->text() ) .
+                       Xml::inputLabel( $this->msg( 'fileduplicatesearch-filename' )->text(), 'filename', 'filename', 50, $this->filename ) . ' ' .
+                       Xml::submitButton( $this->msg( 'fileduplicatesearch-submit' )->text() ) .
                        Xml::closeElement( 'fieldset' ) .
                        Xml::closeElement( 'form' )
                );
@@ -132,12 +140,10 @@ class FileDuplicateSearchPage extends QueryPage {
                                if( $thumb ) {
                                        $out->addHTML( '<div id="mw-fileduplicatesearch-icon">' .
                                                $thumb->toHtml( array( 'desc-link' => false ) ) . '<br />' .
-                                               wfMsgExt( 'fileduplicatesearch-info', array( 'parse' ),
-                                                       $this->getLang()->formatNum( $img->getWidth() ),
-                                                       $this->getLang()->formatNum( $img->getHeight() ),
-                                                       $this->getLang()->formatSize( $img->getSize() ),
-                                                       $img->getMimeType()
-                                               ) .
+                                               $this->msg( 'fileduplicatesearch-info' )->numParams(
+                                                       $img->getWidth(), $img->getHeight() )->params(
+                                                       $this->getLanguage()->formatSize( $img->getSize() ),
+                                                       $img->getMimeType() )->parseAsBlock() .
                                                '</div>' );
                                }
                        }
@@ -155,14 +161,28 @@ class FileDuplicateSearchPage extends QueryPage {
                                $out->wrapWikiMsg(
                                        "<p class='mw-fileduplicatesearch-result-n'>\n$1\n</p>",
                                        array( 'fileduplicatesearch-result-n', wfEscapeWikiText( $this->filename ),
-                                               $this->getLang()->formatNum( $numRows - 1 ) )
+                                               $this->getLanguage()->formatNum( $numRows - 1 ) )
                                );
                        }
 
+                       $this->doBatchLookups( $dupes );
                        $this->showList( $dupes );
                }
        }
 
+       function doBatchLookups( $list ) {
+               $batch = new LinkBatch();
+               foreach( $list as $file ) {
+                       $batch->addObj( $file->getTitle() );
+                       if( $file->isLocal() ) {
+                               $userName = $file->getUser( 'text' );
+                               $batch->add( NS_USER, $userName );
+                               $batch->add( NS_USER_TALK, $userName );
+                       }
+               }
+               $batch->execute();
+       }
+
        /**
         *
         * @param Skin $skin
@@ -180,8 +200,18 @@ class FileDuplicateSearchPage extends QueryPage {
                );
 
                $userText = $result->getUser( 'text' );
-               $user = Linker::link( Title::makeTitle( NS_USER, $userText ), $userText );
-               $time = $this->getLang()->timeanddate( $result->getTimestamp() );
+               if ( $result->isLocal() ) {
+                       $userId = $result->getUser( 'id' );
+                       $user = Linker::userLink( $userId, $userText );
+                       $user .= $this->getContext()->msg( 'word-separator' )->plain();
+                       $user .= '<span style="white-space: nowrap;">';
+                       $user .= Linker::userToolLinks( $userId, $userText );
+                       $user .= '</span>';
+               } else {
+                       $user = htmlspecialchars( $userText );
+               }
+
+               $time = $this->getLanguage()->userTimeAndDate( $result->getTimestamp(), $this->getUser() );
 
                return "$plink . . $user . . $time";
        }