if ( isset( $searchInfo['totalhits'] ) ) {
$totalhits = $matches->getTotalHits();
if ( $totalhits !== null ) {
- $apiResult->addValue( array( 'query', 'searchinfo' ),
+ $apiResult->addValue( [ 'query', 'searchinfo' ],
'totalhits', $totalhits );
}
}
if ( isset( $searchInfo['suggestion'] ) && $matches->hasSuggestion() ) {
- $apiResult->addValue( array( 'query', 'searchinfo' ),
+ $apiResult->addValue( [ 'query', 'searchinfo' ],
'suggestion', $matches->getSuggestionQuery() );
- $apiResult->addValue( array( 'query', 'searchinfo' ),
+ $apiResult->addValue( [ 'query', 'searchinfo' ],
'suggestionsnippet', $matches->getSuggestionSnippet() );
}
if ( isset( $searchInfo['rewrittenquery'] ) && $matches->hasRewrittenQuery() ) {
- $apiResult->addValue( array( 'query', 'searchinfo' ),
+ $apiResult->addValue( [ 'query', 'searchinfo' ],
'rewrittenquery', $matches->getQueryAfterRewrite() );
- $apiResult->addValue( array( 'query', 'searchinfo' ),
+ $apiResult->addValue( [ 'query', 'searchinfo' ],
'rewrittenquerysnippet', $matches->getQueryAfterRewriteSnippet() );
}
}
// Add the search results to the result
$terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
- $titles = array();
+ $titles = [];
$count = 0;
$result = $matches->next();
$title = $result->getTitle();
if ( $resultPageSet === null ) {
- $vals = array();
+ $vals = [];
ApiQueryBase::addTitleInfo( $vals, $title );
if ( isset( $prop['snippet'] ) ) {
}
// Add item to results and see whether it fits
- $fit = $apiResult->addValue( array( 'query', $this->getModuleName() ),
+ $fit = $apiResult->addValue( [ 'query', $this->getModuleName() ],
null, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'offset', $params['offset'] + $count - 1 );
$title = $result->getTitle();
if ( $resultPageSet === null ) {
- $vals = array(
+ $vals = [
'namespace' => $result->getInterwikiNamespaceText(),
'title' => $title->getText(),
'url' => $title->getFullUrl(),
- );
+ ];
// Add item to results and see whether it fits
$fit = $apiResult->addValue(
- array( 'query', 'interwiki' . $this->getModuleName(), $result->getInterwikiPrefix() ),
+ [ 'query', 'interwiki' . $this->getModuleName(), $result->getInterwikiPrefix() ],
null,
$vals
);
}
}
if ( $totalhits !== null ) {
- $apiResult->addValue( array( 'query', 'interwikisearchinfo' ),
+ $apiResult->addValue( [ 'query', 'interwikisearchinfo' ],
'totalhits', $totalhits );
}
}
if ( $resultPageSet === null ) {
- $apiResult->addIndexedTagName( array(
+ $apiResult->addIndexedTagName( [
'query', $this->getModuleName()
- ), 'p' );
+ ], 'p' );
if ( $hasInterwikiResults ) {
- $apiResult->addIndexedTagName( array(
+ $apiResult->addIndexedTagName( [
'query', 'interwiki' . $this->getModuleName()
- ), 'p' );
+ ], 'p' );
}
} else {
$resultPageSet->setRedirectMergePolicy( function ( $current, $new ) {
$resultPageSet->populateFromTitles( $titles );
$offset = $params['offset'] + 1;
foreach ( $titles as $index => $title ) {
- $resultPageSet->setGeneratorData( $title, array( 'index' => $index + $offset ) );
+ $resultPageSet->setGeneratorData( $title, [ 'index' => $index + $offset ] );
}
}
}
}
public function getAllowedParams() {
- $params = array(
- 'search' => array(
+ $params = [
+ 'search' => [
ApiBase::PARAM_TYPE => 'string',
ApiBase::PARAM_REQUIRED => true
- ),
- 'namespace' => array(
+ ],
+ 'namespace' => [
ApiBase::PARAM_DFLT => NS_MAIN,
ApiBase::PARAM_TYPE => 'namespace',
ApiBase::PARAM_ISMULTI => true,
- ),
- 'what' => array(
- ApiBase::PARAM_DFLT => null,
- ApiBase::PARAM_TYPE => array(
+ ],
+ 'what' => [
+ ApiBase::PARAM_TYPE => [
'title',
'text',
'nearmatch',
- )
- ),
- 'info' => array(
+ ]
+ ],
+ 'info' => [
ApiBase::PARAM_DFLT => 'totalhits|suggestion|rewrittenquery',
- ApiBase::PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => [
'totalhits',
'suggestion',
'rewrittenquery',
- ),
+ ],
ApiBase::PARAM_ISMULTI => true,
- ),
- 'prop' => array(
+ ],
+ 'prop' => [
ApiBase::PARAM_DFLT => 'size|wordcount|timestamp|snippet',
- ApiBase::PARAM_TYPE => array(
+ ApiBase::PARAM_TYPE => [
'size',
'wordcount',
'timestamp',
'categorysnippet',
'score', // deprecated
'hasrelated', // deprecated
- ),
+ ],
ApiBase::PARAM_ISMULTI => true,
- ApiBase::PARAM_HELP_MSG_PER_VALUE => array(),
- ),
- 'offset' => array(
+ ApiBase::PARAM_HELP_MSG_PER_VALUE => [],
+ ],
+ 'offset' => [
ApiBase::PARAM_DFLT => 0,
ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
- ),
- 'limit' => array(
+ ],
+ 'limit' => [
ApiBase::PARAM_DFLT => 10,
ApiBase::PARAM_TYPE => 'limit',
ApiBase::PARAM_MIN => 1,
- ApiBase::PARAM_MAX => ApiBase::LIMIT_SML1,
- ApiBase::PARAM_MAX2 => ApiBase::LIMIT_SML2
- ),
+ ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+ ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
+ ],
'interwiki' => false,
'enablerewrites' => false,
- );
+ ];
$alternatives = SearchEngine::getSearchTypes();
if ( count( $alternatives ) > 1 ) {
if ( $alternatives[0] === null ) {
$alternatives[0] = self::BACKEND_NULL_PARAM;
}
- $params['backend'] = array(
+ $params['backend'] = [
ApiBase::PARAM_DFLT => $this->getConfig()->get( 'SearchType' ),
ApiBase::PARAM_TYPE => $alternatives,
- );
+ ];
}
return $params;
}
protected function getExamplesMessages() {
- return array(
+ return [
'action=query&list=search&srsearch=meaning'
=> 'apihelp-query+search-example-simple',
'action=query&list=search&srwhat=text&srsearch=meaning'
=> 'apihelp-query+search-example-text',
'action=query&generator=search&gsrsearch=meaning&prop=info'
=> 'apihelp-query+search-example-generator',
- );
+ ];
}
public function getHelpUrls() {