Merge "Support custom offsets from SearchResultSet"
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
index 3a93107..eeb8823 100644 (file)
@@ -352,12 +352,16 @@ class SpecialSearch extends SpecialPage {
                        $out->addHTML( $dymWidget->render( $term, $textMatches ) );
                }
 
-               $out->addHTML( "<div class='searchresults'>" );
-
                $hasErrors = $textStatus && $textStatus->getErrors();
                $hasOtherResults = $textMatches &&
                        $textMatches->hasInterwikiResults( SearchResultSet::INLINE_RESULTS );
 
+               if ( $textMatches && $textMatches->hasInterwikiResults( SearchResultSet::SECONDARY_RESULTS ) ) {
+                       $out->addHTML( '<div class="searchresults mw-searchresults-has-iw">' );
+               } else {
+                       $out->addHTML( '<div class="searchresults">' );
+               }
+
                if ( $hasErrors ) {
                        list( $error, $warning ) = $textStatus->splitByErrorType();
                        if ( $error->getErrors() ) {
@@ -395,13 +399,13 @@ class SpecialSearch extends SpecialPage {
                $mainResultWidget = new FullSearchResultWidget( $this, $linkRenderer );
 
                if ( $search->getFeatureData( 'enable-new-crossproject-page' ) ) {
-
                        $sidebarResultWidget = new InterwikiSearchResultWidget( $this, $linkRenderer );
                        $sidebarResultsWidget = new InterwikiSearchResultSetWidget(
                                $this,
                                $sidebarResultWidget,
                                $linkRenderer,
-                               MediaWikiServices::getInstance()->getInterwikiLookup()
+                               MediaWikiServices::getInstance()->getInterwikiLookup(),
+                               $search->getFeatureData( 'show-multimedia-search-results' )
                        );
                } else {
                        $sidebarResultWidget = new SimpleSearchResultWidget( $this, $linkRenderer );
@@ -431,9 +435,17 @@ class SpecialSearch extends SpecialPage {
 
                // prev/next links
                if ( $totalRes > $this->limit || $this->offset ) {
+                       // Allow matches to define the correct offset, as interleaved
+                       // AB testing may require a different next page offset.
+                       if ( $textMatches && $textMatches->getOffset() !== null ) {
+                               $offset = $textMatches->getOffset();
+                       } else {
+                               $offset = $this->offset;
+                       }
+
                        $prevnext = $this->getLanguage()->viewPrevNext(
                                $this->getPageTitle(),
-                               $this->offset,
+                               $offset,
                                $this->limit,
                                $this->powerSearchOptions() + [ 'search' => $term ],
                                $this->limit + $this->offset >= $totalRes