Merge "Set Language in SpecialSearchTest.php"
[lhc/web/wiklou.git] / includes / specials / SpecialFileDuplicateSearch.php
index da79bb8..bb57ee0 100644 (file)
@@ -48,7 +48,7 @@ class FileDuplicateSearchPage extends QueryPage {
                return false;
        }
 
-       function isCached() {
+       public function isCached() {
                return false;
        }
 
@@ -82,7 +82,7 @@ class FileDuplicateSearchPage extends QueryPage {
                $this->getOutput()->addHtml( implode( "\n", $html ) );
        }
 
-       function getQueryInfo() {
+       public function getQueryInfo() {
                return array(
                        'tables' => array( 'image' ),
                        'fields' => array(
@@ -95,7 +95,7 @@ class FileDuplicateSearchPage extends QueryPage {
                );
        }
 
-       function execute( $par ) {
+       public function execute( $par ) {
                $this->setHeaders();
                $this->outputHeader();
 
@@ -151,6 +151,7 @@ class FileDuplicateSearchPage extends QueryPage {
                        if ( $img ) {
                                $thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) );
                                if ( $thumb ) {
+                                       $out->addModuleStyles( 'mediawiki.special' );
                                        $out->addHTML( '<div id="mw-fileduplicatesearch-icon">' .
                                                $thumb->toHtml( array( 'desc-link' => false ) ) . '<br />' .
                                                $this->msg( 'fileduplicatesearch-info' )->numParams(
@@ -231,6 +232,30 @@ class FileDuplicateSearchPage extends QueryPage {
                return "$plink . . $user . . $time";
        }
 
+       /**
+        * Return an array of subpages beginning with $search that this special page will accept.
+        *
+        * @param string $search Prefix to search for
+        * @param int $limit Maximum number of results to return (usually 10)
+        * @param int $offset Number of results to skip (usually 0)
+        * @return string[] Matching subpages
+        */
+       public function prefixSearchSubpages( $search, $limit, $offset ) {
+               $title = Title::newFromText( $search );
+               if ( !$title || $title->getNamespace() !== NS_FILE ) {
+                       // No prefix suggestion outside of file namespace
+                       return array();
+               }
+               // Autocomplete subpage the same as a normal search, but just for files
+               $prefixSearcher = new TitlePrefixSearch;
+               $result = $prefixSearcher->search( $search, $limit, array( NS_FILE ), $offset );
+
+               return array_map( function ( Title $t ) {
+                       // Remove namespace in search suggestion
+                       return $t->getText();
+               }, $result );
+       }
+
        protected function getGroupName() {
                return 'media';
        }