summaryrefslogtreecommitdiff
path: root/includes/api/ApiQuerySearch.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
committerPierre Schmitz <pierre@archlinux.de>2011-12-03 13:29:22 +0100
commitca32f08966f1b51fcb19460f0996bb0c4048e6fe (patch)
treeec04cc15b867bc21eedca904cea9af0254531a11 /includes/api/ApiQuerySearch.php
parenta22fbfc60f36f5f7ee10d5ae6fe347340c2ee67c (diff)
Update to MediaWiki 1.18.0
* also update ArchLinux skin to chagnes in MonoBook * Use only css to hide our menu bar when printing
Diffstat (limited to 'includes/api/ApiQuerySearch.php')
-rw-r--r--includes/api/ApiQuerySearch.php38
1 files changed, 26 insertions, 12 deletions
diff --git a/includes/api/ApiQuerySearch.php b/includes/api/ApiQuerySearch.php
index 3cf693af..42bed93a 100644
--- a/includes/api/ApiQuerySearch.php
+++ b/includes/api/ApiQuerySearch.php
@@ -1,6 +1,6 @@
<?php
/**
- * API for MediaWiki 1.8+
+ *
*
* Created on July 30, 2007
*
@@ -48,6 +48,10 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
$this->run( $resultPageSet );
}
+ /**
+ * @param $resultPageSet ApiPageSet
+ * @return void
+ */
private function run( $resultPageSet = null ) {
global $wgContLang;
$params = $this->extractRequestParams();
@@ -93,16 +97,17 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
$this->dieUsage( "{$what} search is disabled", "search-{$what}-disabled" );
}
+ $apiResult = $this->getResult();
// Add search meta data to result
if ( isset( $searchInfo['totalhits'] ) ) {
$totalhits = $matches->getTotalHits();
if ( $totalhits !== null ) {
- $this->getResult()->addValue( array( 'query', 'searchinfo' ),
+ $apiResult->addValue( array( 'query', 'searchinfo' ),
'totalhits', $totalhits );
}
}
if ( isset( $searchInfo['suggestion'] ) && $matches->hasSuggestion() ) {
- $this->getResult()->addValue( array( 'query', 'searchinfo' ),
+ $apiResult->addValue( array( 'query', 'searchinfo' ),
'suggestion', $matches->getSuggestionQuery() );
}
@@ -110,7 +115,9 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
$terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
$titles = array();
$count = 0;
- while ( $result = $matches->next() ) {
+ $result = $matches->next();
+
+ while ( $result ) {
if ( ++ $count > $limit ) {
// We've reached the one extra which shows that there are additional items to be had. Stop here...
$this->setContinueEnumParameter( 'offset', $params['offset'] + $params['limit'] );
@@ -119,6 +126,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
// Silently skip broken and missing titles
if ( $result->isBrokenTitle() || $result->isMissingRevision() ) {
+ $result = $matches->next();
continue;
}
@@ -155,7 +163,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
}
if ( !is_null( $result->getSectionTitle() ) ) {
if ( isset( $prop['sectiontitle'] ) ) {
- $vals['sectiontitle'] = $result->getSectionTitle();
+ $vals['sectiontitle'] = $result->getSectionTitle()->getFragment();
}
if ( isset( $prop['sectionsnippet'] ) ) {
$vals['sectionsnippet'] = $result->getSectionSnippet();
@@ -166,7 +174,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
}
// Add item to results and see whether it fits
- $fit = $this->getResult()->addValue( array( 'query', $this->getModuleName() ),
+ $fit = $apiResult->addValue( array( 'query', $this->getModuleName() ),
null, $vals );
if ( !$fit ) {
$this->setContinueEnumParameter( 'offset', $params['offset'] + $count - 1 );
@@ -175,10 +183,12 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
} else {
$titles[] = $title;
}
+
+ $result = $matches->next();
}
if ( is_null( $resultPageSet ) ) {
- $this->getResult()->setIndexedTagName_internal( array(
+ $apiResult->setIndexedTagName_internal( array(
'query', $this->getModuleName()
), 'p' );
} else {
@@ -260,10 +270,10 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
' score - Adds the score (if any) from the search engine',
' snippet - Adds a parsed snippet of the page',
' titlesnippet - Adds a parsed snippet of the page title',
- ' redirectsnippet - Adds a parsed snippet of the redirect',
- ' redirecttitle - Adds a parsed snippet of the redirect title',
- ' sectionsnippet - Adds a parsed snippet of the matching section',
- ' sectiontitle - Adds a parsed snippet of the matching section title',
+ ' redirectsnippet - Adds a parsed snippet of the redirect title',
+ ' redirecttitle - Adds the title of the matching redirect',
+ ' sectionsnippet - Adds a parsed snippet of the matching section title',
+ ' sectiontitle - Adds the title of the matching section',
' hasrelated - Indicates whether a related search is available',
),
'redirects' => 'Include redirect pages in the search',
@@ -291,7 +301,11 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
);
}
+ public function getHelpUrls() {
+ return 'https://www.mediawiki.org/wiki/API:Search';
+ }
+
public function getVersion() {
- return __CLASS__ . ': $Id: ApiQuerySearch.php 76300 2010-11-08 12:23:24Z reedy $';
+ return __CLASS__ . ': $Id: ApiQuerySearch.php 104449 2011-11-28 15:52:04Z reedy $';
}
}