MediaWiki REL1_37
SearchApi.php File Reference

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. More...

Go to the source code of this file.

Functions

 buildCommonApiParams ( $isScrollable=true)
 The set of api parameters that are shared between api calls that call the SearchEngine.
 
 buildProfileApiParam ()
 Build the profile api param definitions.
 
 buildSearchEngine (array $params=null)
 Build the search engine to use.
 
 checkDependenciesSet ()
 
 getContext ()
 
 getSearchProfileParams ()
 

Variables

static $BACKEND_NULL_PARAM = 'database-backed'
 When $wgSearchType is null, $wgSearchAlternatives[0] is null.
 
SearchEngineFactory null $searchEngineFactory = null
 
trait SearchApi
 Traits for API components that use a SearchEngine.
 

Detailed Description

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html

Since
1.28

Definition in file SearchApi.php.

Function Documentation

◆ buildCommonApiParams()

buildCommonApiParams (   $isScrollable = true)

The set of api parameters that are shared between api calls that call the SearchEngine.

Primarily this defines parameters that are utilized by self::buildSearchEngine().

Parameters
bool$isScrollableTrue if the api offers scrolling
Returns
array

Definition at line 63 of file SearchApi.php.

References $BACKEND_NULL_PARAM, buildProfileApiParam(), checkDependenciesSet(), and NS_MAIN.

Referenced by ApiOpenSearch\getAllowedParams(), ApiQueryPrefixSearch\getAllowedParams(), and ApiQuerySearch\getAllowedParams().

◆ buildProfileApiParam()

buildProfileApiParam ( )
private

Build the profile api param definitions.

Makes bold assumption only one search engine is available, ensure that is true before calling.

Returns
array array containing available additional api param definitions. Empty if profiles are not supported by the searchEngine implementation.

Definition at line 121 of file SearchApi.php.

References checkDependenciesSet(), getContext(), and getSearchProfileParams().

Referenced by buildCommonApiParams().

◆ buildSearchEngine()

buildSearchEngine ( array  $params = null)

Build the search engine to use.

If $params is provided then the following searchEngine options will be set:

  • backend: which search backend to use
  • limit: mandatory
  • offset: optional
  • namespace: mandatory
  • search engine profiles defined by SearchApi::getSearchProfileParams()
    Parameters
    string[] | null$paramsAPI request params (must be sanitized by ApiBase::extractRequestParams() before)
    Returns
    SearchEngine

Definition at line 174 of file SearchApi.php.

References $type, checkDependenciesSet(), and getSearchProfileParams().

Referenced by ApiQueryPrefixSearch\run(), ApiQuerySearch\run(), and ApiOpenSearch\search().

◆ checkDependenciesSet()

checkDependenciesSet ( )
private

Definition at line 35 of file SearchApi.php.

Referenced by buildCommonApiParams(), buildProfileApiParam(), and buildSearchEngine().

◆ getContext()

getContext ( )
abstract
Returns
IContextSource

Referenced by WatchAction\__construct(), Article\addHelpLink(), OutputPage\addSubtitle(), Article\adjustDisplayTitle(), SkinTemplate\buildContentNavigationUrls(), UsersPager\buildGroupLink(), Skin\buildNavUrls(), buildProfileApiParam(), CategoryPage\closeShowCategory(), ImagePage\createXmlOptionStringForLanguage(), Article\doDelete(), Article\doOutputFromRenderStatus(), ImagePage\doRenderLangOpt(), ApiOptions\execute(), ApiParse\execute(), ApiMain\executeAction(), ApiMain\executeActionWithErrorHandling(), ContextSource\exportSession(), ApiQueryRevisionsBase\extractDeprecatedContent(), SpecialNewpages\form(), ChangesList\formatCharacterDifference(), PageQueryPage\formatResult(), ContribsPager\formatRow(), DifferenceEngine\generateContentDiffBody(), DifferenceEngine\generateTextDiffBody(), EditPage\getCheckboxesDefinitionForWatchlist(), SpecialEditWatchlist\getClearForm(), SpecialPage\getConfig(), SpecialUpload\getDupeWarning(), SpecialRecentChanges\getExtraOptions(), ApiBase\getFinalDescription(), ApiBase\getFinalParamDescription(), ApiBase\getFinalSummary(), ImageListPager\getForm(), SpecialContributions\getForm(), WatchAction\getFormFields(), SpecialPage\getFullTitle(), OutputPage\getHeadLinksArray(), OutputPage\getJSVars(), Action\getLanguage(), ContextSource\getLanguage(), DerivativeContext\getLanguage(), SpecialPage\getLanguage(), SpecialEditWatchlist\getNormalForm(), Article\getOldIDFromRequest(), Action\getOutput(), SpecialPage\getOutput(), UsersPager\getPageHeader(), SpecialContributions\getPager(), Article\getParserOptions(), DifferenceEngine\getParserOutput(), ApiOptions\getPreferences(), SpecialEditWatchlist\getRawForm(), RawAction\getRawText(), Action\getRequest(), SpecialPage\getRequest(), Article\getRobotPolicy(), Action\getSkin(), ContextSource\getSkin(), DerivativeContext\getSkin(), SpecialPage\getSkin(), DifferenceEngine\getSlotDiffRenderers(), NewFilesPager\getStartBody(), ImagePage\getThumbPrevText(), ImagePage\getThumbSizes(), ContextSource\getTiming(), HTMLForm\getTitle(), BaseTemplate\getTrail(), Skin\getUndeleteLink(), SpecialUpload\getUploadForm(), Action\getUser(), SpecialPage\getUser(), SpecialEditWatchlist\getWatchlistInfo(), RollbackAction\handleRollbackRequest(), OutputPage\headElement(), HistoryPager\historyLine(), ImagePage\imageDupes(), ImagePage\imageHistory(), ImagePage\imageLinks(), ChangesList\insertLog(), ChangesList\insertLogEntry(), ChangesList\insertRollback(), Article\isFileCacheable(), Profiler\logData(), LogEventsList\logLine(), ChangesListSpecialPage\makeLegend(), ImagePage\makeMetadataTable(), ApiParse\makeParserOptions(), Action\msg(), ContextSource\msg(), SpecialPage\msg(), EditPage\newTextConflictHelper(), McrUndoAction\onSubmit(), UnwatchAction\onSubmit(), WatchAction\onSubmit(), WatchAction\onSuccess(), InfoAction\onView(), RawAction\onView(), ImagePage\openShowImage(), SpecialRecentChanges\outputChangesList(), InfoAction\pageInfo(), OutputPage\parserOptions(), ImagePage\printSharedImageText(), ChangesList\recentChangesFlags(), Article\render(), ApiOptions\resetPreferences(), OutputPage\setHTMLTitle(), Article\setOldSubtitle(), OutputPage\setPageTitle(), OutputPage\setTitle(), McrUndoAction\show(), SpecialPageAction\show(), Article\showDeletedRevisionHeader(), DifferenceEngine\showDiffPage(), Article\showDiffPage(), ImagePage\showError(), Article\showMissingArticle(), Article\showNamespaceHeader(), LogEventsList\showOptions(), Article\showPatrolFooter(), Article\showRedirectedFromHeader(), ImagePage\showTOC(), Article\showViewError(), Article\showViewFooter(), SkinTemplate\tabAction(), DifferenceEngine\textDiff(), Article\tryFileCache(), ImagePage\uploadLinksBox(), Article\view(), CategoryPage\view(), ImagePage\view(), and Article\viewRedirect().

◆ getSearchProfileParams()

getSearchProfileParams ( )
abstract
Returns
array[] array of arrays mapping from parameter name to a two value map containing 'help-message' and 'profile-type' keys.

Referenced by buildProfileApiParam(), and buildSearchEngine().

Variable Documentation

◆ $BACKEND_NULL_PARAM

$BACKEND_NULL_PARAM = 'database-backed'
staticprivate

When $wgSearchType is null, $wgSearchAlternatives[0] is null.

Null isn't a valid option for an array for PARAM_TYPE, so we'll use a fake name that can't possibly be a class name and describes what the null behavior does

Definition at line 53 of file SearchApi.php.

Referenced by buildCommonApiParams().

◆ $searchEngineFactory