From af4085a1753513ee16133ac6fcbd2988133019ff Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 18 Mar 2014 11:51:02 -0700 Subject: [PATCH] Allow interwiki searches to return arrays of interwiki results 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 | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index aa38e6cd63..ed3857bd2c 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -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 = "
" . $this->msg( 'search-interwiki-caption' )->text() . "
\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 .= "
\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() ) { -- 2.20.1