This method was introduced in
4115586000a575eb814a80868c817d18ee169d3b
to support the prefix URI param introduced by the InputBox extension.
There are no reasons that this logic is exposed to SearchEngine users
and should be handled internally by SearchEngine implementations
that supports it.
Previously the search query was updated, now the prefix param will passed
along using SpecialSearch::$extraParams.
Bug: T198318
Change-Id: I33518d3f3ddee741ff4f3b47eb4928009bea66d1
Depends-On: I67c7f1886dd6a2d07c12015e2711c138e9f140e9
the Parsoid v3 API in May 2015.
* $input is deprecated in hook 'LogEventsListGetExtraInputs'. Use
$formDescriptor instead.
+* SearchEngine::transformSearchTerm( $term ) should no longer be called prior
+ to running searchText. This method was mainly implemented to support the
+ 'prefix' URI param in SpecialSearch, but there are no reasons to expose this
+ logic as it should be handled internally by SearchEngine implementations
+ supporting this feature. SearchEngine implementations should no longer
+ override this methods.
=== Other changes in 1.32 ===
* (T198811) The following tables have had their UNIQUE indexes turned into
$search->setFeatureData( 'rewrite', (bool)$params['enablerewrites'] );
$search->setFeatureData( 'interwiki', (bool)$interwiki );
- $query = $search->transformSearchTerm( $query );
+ $nquery = $search->transformSearchTerm( $query );
+ if ( $nquery !== $query ) {
+ $query = $nquery;
+ wfDeprecated( 'SearchEngine::transformSearchTerm() (overridden by ' .
+ get_class( $search ) . ')', '1.32' );
+ }
$query = $search->replacePrefixes( $query );
// Perform the actual search
* search=test&prefix=Main_Page/Archive -> test prefix:Main Page/Archive
* @param string $term
* @return string
+ * @deprecated since 1.32 this should now be handled internally by the
+ * search engine
*/
public function transformSearchTerm( $term ) {
return $term;
$request = $this->getRequest();
list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, '' );
$this->mPrefix = $request->getVal( 'prefix', '' );
+ if ( $this->mPrefix !== '' ) {
+ $this->setExtraParam( 'prefix', $this->mPrefix );
+ }
$user = $this->getUser();
$search->setLimitOffset( $this->limit, $this->offset );
$search->setNamespaces( $this->namespaces );
$search->prefix = $this->mPrefix;
- $term = $search->transformSearchTerm( $term );
Hooks::run( 'SpecialSearchSetupEngine', [ $this, $this->profile, $search ] );
if ( !Hooks::run( 'SpecialSearchResultsPrepend', [ $this, $out, $term ] ) ) {
$showSuggestion = $title === null || !$title->isKnown();
$search->setShowSuggestion( $showSuggestion );
+ $nterm = $search->transformSearchTerm( $term );
+ if ( $nterm !== $term ) {
+ $term = $nterm;
+ wfDeprecated( 'SearchEngine::transformSearchTerm() (overridden by ' .
+ get_class( $search ) . ')', '1.32' );
+ }
+
// fetch search results
$rewritten = $search->replacePrefixes( $term );
);
}
+ if ( $this->mPrefix !== '' ) {
+ $subtitle = $this->msg( 'search-filter-title-prefix' )->plaintextParams( $this->mPrefix );
+ $params = $this->powerSearchOptions();
+ unset( $params['prefix'] );
+ $params += [
+ 'search' => $term,
+ 'fulltext' => 1,
+ ];
+
+ $subtitle .= ' (';
+ $subtitle .= Xml::element(
+ 'a',
+ [
+ 'href' => $this->getPageTitle()->getLocalURL( $params ),
+ 'title' => $this->msg( 'search-filter-title-prefix-reset' ),
+ ],
+ $this->msg( 'search-filter-title-prefix-reset' )
+ );
+ $subtitle .= ')';
+ $out->setSubtitle( $subtitle );
+ }
+
$out->addJsConfigVars( [ 'searchTerm' => $term ] );
$out->addModules( 'mediawiki.special.search' );
$out->addModuleStyles( [
$this->extraParams[$key] = $value;
}
+ /**
+ * The prefix value send to Special:Search using the 'prefix' URI param
+ * It means that the user is willing to search for pages whose titles start with
+ * this prefix value.
+ * (Used by the InputBox extension)
+ *
+ * @return string
+ */
+ public function getPrefix() {
+ return $this->mPrefix;
+ }
+
protected function getGroupName() {
return 'pages';
}
$html .= $layout;
+ if ( $this->specialSearch->getPrefix() !== '' ) {
+ $html .= Html::hidden( 'prefix', $this->specialSearch->getPrefix() );
+ }
+
if ( $totalResults > 0 && $offset < $totalResults ) {
$html .= Xml::tags(
'div',
"difference-missing-revision": "{{PLURAL:$2|One revision|$2 revisions}} of this difference ($1) {{PLURAL:$2|was|were}} not found.\n\nThis is usually caused by following an outdated diff link to a page that has been deleted.\nDetails can be found in the [{{fullurl:{{#Special:Log}}/delete|page={{FULLPAGENAMEE}}}} deletion log].",
"search-summary": "",
"searchresults": "Search results",
+ "search-filter-title-prefix": "Only searching in pages whose title starts with \"$1\"",
+ "search-filter-title-prefix-reset": "Search all pages",
"searchresults-title": "Search results for \"$1\"",
"titlematches": "Page title matches",
"textmatches": "Page text matches",
"difference-missing-revision": "Text displayed when the requested revision does not exist using a diff link.\n\nExample: [{{canonicalurl:Project:News|diff=426850&oldid=99999999}} Diff with invalid revision#]\n\nParameters:\n* $1 - the list of missing revisions IDs\n* $2 - the number of items in $1 (one or two)",
"search-summary": "{{doc-specialpagesummary|search}}",
"searchresults": "This is the title of the page that contains the results of a search.\n\n{{Identical|Search results}}",
+ "search-filter-title-prefix": "Subtitle added to indicate that the user is filtering for pages whose title starts with $1, \n* $1 - the title prefix",
+ "search-filter-title-prefix-reset": "Appears next to {{msg-mw|search-filter-title-prefix}} as a link to let users reset the prefix filter",
"searchresults-title": "Appears as page title in the html header of the search result special page.\n\nParameters:\n* $1 - the search term",
"titlematches": "Used as section header in [[Special:Search]].\n\nThis message is followed by search results.",
"textmatches": "When displaying search results",