global $wgContLang;
$search = $this->getSearchEngine();
+ $search->setFeatureData( 'rewrite', $this->runSuggestion );
$search->setLimitOffset( $this->limit, $this->offset );
$search->setNamespaces( $this->namespaces );
$search->prefix = $this->mPrefix;
// did you mean... suggestions
$didYouMeanHtml = '';
if ( $showSuggestion && $textMatches && !$textStatus ) {
- if ( $this->shouldRunSuggestedQuery( $textMatches ) ) {
- $newMatches = $search->searchText( $textMatches->getSuggestionQuery() );
- if ( $newMatches instanceof SearchResultSet && $newMatches->numRows() > 0 ) {
- $didYouMeanHtml = $this->getDidYouMeanRewrittenHtml( $term, $textMatches );
- $textMatches = $newMatches;
- }
+ if ( $textMatches->hasRewrittenQuery() ) {
+ $didYouMeanHtml = $this->getDidYouMeanRewrittenHtml( $term, $textMatches );
} elseif ( $textMatches->hasSuggestion() ) {
$didYouMeanHtml = $this->getDidYouMeanHtml( $textMatches );
}
$out->wrapWikiMsg( "==$1==\n", 'textmatches' );
}
- // show interwiki results if any
- if ( $textMatches->hasInterwikiResults() ) {
- $out->addHTML( $this->showInterwiki( $textMatches->getInterwikiResults(), $term ) );
- }
// show results
if ( $numTextMatches > 0 ) {
$out->addHTML( $this->showMatches( $textMatches ) );
}
+ // show interwiki results if any
+ if ( $textMatches->hasInterwikiResults() ) {
+ $out->addHTML( $this->showInterwiki( $textMatches->getInterwikiResults(), $term ) );
+ }
$textMatches->free();
}
}
}
+ $out->addHTML( '<div class="visualClear"></div>' );
if ( $prevnext ) {
$out->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
}
return false;
}
- // Generate a random number between 0 and 1. If the
- // number is less than the desired percentages run it.
- $rand = rand( 0, getrandmax() ) / getrandmax();
- return $this->getConfig()->get( 'SearchRunSuggestedQueryPercent' ) > $rand;
+ return $this->getConfig()->get( 'SearchRunSuggestedQuery' );
}
/**
$suggest = Linker::linkKnown(
$this->getPageTitle(),
$textMatches->getSuggestionSnippet() ?: null,
- array(),
+ array( 'id' => 'mw-search-DYM-suggestion' ),
$stParams
);
// Showing results for '$rewritten'
// Search instead for '$orig'
- $params = array( 'search' => $textMatches->getSuggestionQuery() );
+ $params = array( 'search' => $textMatches->getQueryAfterRewrite() );
if ( $this->fulltext != null ) {
$params['fulltext'] = $this->fulltext;
}
$rewritten = Linker::linkKnown(
$this->getPageTitle(),
- $textMatches->getSuggestionSnippet() ?: null,
- array(),
+ $textMatches->getQueryAfterRewriteSnippet() ?: null,
+ array( 'id' => 'mw-search-DYM-rewritten' ),
$stParams
);
$original = Linker::linkKnown(
$this->getPageTitle(),
htmlspecialchars( $term ),
- array(),
+ array( 'id' => 'mw-search-DYM-original' ),
$stParams
);