X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiQuerySearch.php;h=349e7fa651e4cd2e3d624b8ff5bcc09c50ac679b;hb=6cde392c84e7dca6ef1baa9f90695d6ef2653cd0;hp=e489b2fef8a1b98c71f5023497fb3a3e512751cc;hpb=c67cf1a47f7c9863712cf529d2994b4beb132c43;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php index e489b2fef8..349e7fa651 100644 --- a/includes/api/ApiQuerySearch.php +++ b/includes/api/ApiQuerySearch.php @@ -92,7 +92,9 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { } elseif ( $what == 'title' ) { $matches = $search->searchTitle( $query ); } elseif ( $what == 'nearmatch' ) { - $matches = SearchEngine::getNearMatchResultSet( $query ); + // near matches must receive the user input as provided, otherwise + // the near matches within namespaces are lost. + $matches = SearchEngine::getNearMatchResultSet( $params['search'] ); } else { // We default to title searches; this is a terrible legacy // of the way we initially set up the MySQL fulltext-based @@ -129,6 +131,8 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { if ( isset( $searchInfo['suggestion'] ) && $matches->hasSuggestion() ) { $apiResult->addValue( array( 'query', 'searchinfo' ), 'suggestion', $matches->getSuggestionQuery() ); + $apiResult->addValue( array( 'query', 'searchinfo' ), + 'suggestionsnippet', $matches->getSuggestionSnippet() ); } } @@ -172,6 +176,9 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { if ( isset( $prop['titlesnippet'] ) ) { $vals['titlesnippet'] = $result->getTitleSnippet(); } + if ( isset( $prop['categorysnippet'] ) ) { + $vals['categorysnippet'] = $result->getCategorySnippet(); + } if ( !is_null( $result->getRedirectTitle() ) ) { if ( isset( $prop['redirecttitle'] ) ) { $vals['redirecttitle'] = $result->getRedirectTitle()->getPrefixedText(); @@ -188,6 +195,9 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { $vals['sectionsnippet'] = $result->getSectionSnippet(); } } + if ( isset( $prop['isfilematch'] ) ) { + $vals['isfilematch'] = $result->isFileMatch(); + } // Add item to results and see whether it fits $fit = $apiResult->addValue( array( 'query', $this->getModuleName() ), @@ -228,7 +238,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { // Add item to results and see whether it fits $fit = $apiResult->addValue( - array( 'query', 'interwiki' . $this->getModuleName(), $result->getInterwikiPrefix() ), + array( 'query', 'interwiki' . $this->getModuleName(), $result->getInterwikiPrefix() ), null, $vals ); @@ -252,11 +262,11 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { } if ( $resultPageSet === null ) { - $apiResult->setIndexedTagName_internal( array( + $apiResult->addIndexedTagName( array( 'query', $this->getModuleName() ), 'p' ); if ( $hasInterwikiResults ) { - $apiResult->setIndexedTagName_internal( array( + $apiResult->addIndexedTagName( array( 'query', 'interwiki' . $this->getModuleName() ), 'p' ); } @@ -314,6 +324,8 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { 'sectiontitle', 'sectionsnippet', 'hasrelated', + 'isfilematch', + 'categorysnippet', ), ApiBase::PARAM_ISMULTI => true, ),