Allow interwiki searches to return arrays of interwiki results
authorChad Horohoe <chadh@wikimedia.org>
Tue, 18 Mar 2014 18:51:02 +0000 (11:51 -0700)
committerChad Horohoe <chadh@wikimedia.org>
Mon, 24 Mar 2014 18:33:52 +0000 (11:33 -0700)
This allows them to group by interwiki in more sane ways.
Also remove no longer used $terms paramter

Change-Id: I5d420595edfd35a1ce85662d2722ebbe2d357ce3

includes/specials/SpecialSearch.php

index aa38e6c..ed3857b 100644 (file)
@@ -730,16 +730,14 @@ class SpecialSearch extends SpecialPage {
        /**
         * Show results from other wikis
         *
-        * @param $matches SearchResultSet
+        * @param $matches SearchResultSet|array
         * @param $query String
         *
         * @return string
         */
        protected function showInterwiki( $matches, $query ) {
                global $wgContLang;
-
                $profile = new ProfileSection( __METHOD__ );
-               $terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
 
                $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>" .
                        $this->msg( 'search-interwiki-caption' )->text() . "</div>\n";
@@ -756,12 +754,20 @@ class SpecialSearch extends SpecialPage {
                }
 
                $prev = null;
-               $result = $matches->next();
-               while ( $result ) {
-                       $out .= $this->showInterwikiHit( $result, $prev, $terms, $query, $customCaptions );
-                       $prev = $result->getInterwikiPrefix();
-                       $result = $matches->next();
+               if ( !is_array( $matches ) ) {
+                       $matches = array( $matches );
                }
+
+               foreach ( $matches as $set ) {
+                       $result = $set->next();
+                       while ( $result ) {
+                               $out .= $this->showInterwikiHit( $result, $prev, $query, $customCaptions );
+                               $prev = $result->getInterwikiPrefix();
+                               $result = $set->next();
+                       }
+               }
+
+
                // TODO: should support paging in a non-confusing way (not sure how though, maybe via ajax)..
                $out .= "</ul></div>\n";
 
@@ -776,13 +782,12 @@ class SpecialSearch extends SpecialPage {
         *
         * @param $result SearchResult
         * @param $lastInterwiki String
-        * @param $terms Array
         * @param $query String
         * @param array $customCaptions iw prefix -> caption
         *
         * @return string
         */
-       protected function showInterwikiHit( $result, $lastInterwiki, $terms, $query, $customCaptions ) {
+       protected function showInterwikiHit( $result, $lastInterwiki, $query, $customCaptions ) {
                $profile = new ProfileSection( __METHOD__ );
 
                if ( $result->isBrokenTitle() ) {