From a248a1dba7b34541b7e6d756327906adc4cebaf1 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 7 Jul 2009 20:17:54 +0000 Subject: [PATCH] API: Add snippet field to list=search output --- RELEASE-NOTES | 1 + includes/api/ApiQuerySearch.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 619738dfe2..731ba0b59e 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -268,6 +268,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 18720) Add anchor field to action=parse&prop=sections output * (bug 19423) The initial file description page used caption in user lang rather than UI lang +* Added snippet field to list=search output === Languages updated in 1.16 === diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php index 80ae14d9d1..4a3b892506 100644 --- a/includes/api/ApiQuerySearch.php +++ b/includes/api/ApiQuerySearch.php @@ -48,7 +48,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { } private function run($resultPageSet = null) { - + global $wgContLang; $params = $this->extractRequestParams(); $limit = $params['limit']; @@ -87,6 +87,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { $this->dieUsage("{$what} search is disabled", "search-{$what}-disabled"); + $terms = $wgContLang->convertForSearchResult($matches->termMatches()); $titles = array (); $count = 0; while( $result = $matches->next() ) { @@ -104,6 +105,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase { if (is_null($resultPageSet)) { $vals = array(); ApiQueryBase::addTitleInfo($vals, $title); + $vals['snippet'] = $result->getTextSnippet($terms); $fit = $this->getResult()->addValue(array('query', $this->getModuleName()), null, $vals); if(!$fit) { -- 2.20.1