MediaWiki REL1_30
SearchResultSet.php
Go to the documentation of this file.
1<?php
28
36 const SECONDARY_RESULTS = 0;
41 const INLINE_RESULTS = 1;
42
43 protected $containedSyntax = false;
44
50 private $titles;
51
57 private $results;
58
66 protected $extraData = [];
67
68 public function __construct( $containedSyntax = false ) {
69 $this->containedSyntax = $containedSyntax;
70 }
71
79 function termMatches() {
80 return [];
81 }
82
83 function numRows() {
84 return 0;
85 }
86
97 function getTotalHits() {
98 return null;
99 }
100
108 function hasRewrittenQuery() {
109 return false;
110 }
111
117 return null;
118 }
119
125 return null;
126 }
127
134 function hasSuggestion() {
135 return false;
136 }
137
142 return null;
143 }
144
149 return '';
150 }
151
158 function getInterwikiResults( $type = self::SECONDARY_RESULTS ) {
159 return null;
160 }
161
168 function hasInterwikiResults( $type = self::SECONDARY_RESULTS ) {
169 return false;
170 }
171
178 function next() {
179 return false;
180 }
181
185 function rewind() {
186 }
187
191 function free() {
192 // ...
193 }
194
201 public function searchContainedSyntax() {
202 return $this->containedSyntax;
203 }
204
209 public function extractResults() {
210 if ( is_null( $this->results ) ) {
211 $this->results = [];
212 if ( $this->numRows() == 0 ) {
213 // Don't bother if we've got empty result
214 return $this->results;
215 }
216 $this->rewind();
217 while ( ( $result = $this->next() ) != false ) {
218 $this->results[] = $result;
219 }
220 $this->rewind();
221 }
222 return $this->results;
223 }
224
229 public function extractTitles() {
230 if ( is_null( $this->titles ) ) {
231 if ( $this->numRows() == 0 ) {
232 // Don't bother if we've got empty result
233 $this->titles = [];
234 } else {
235 $this->titles = array_map(
236 function ( SearchResult $result ) {
237 return $result->getTitle();
238 },
239 $this->extractResults() );
240 }
241 }
242 return $this->titles;
243 }
244
250 public function setAugmentedData( $name, $data ) {
251 foreach ( $data as $id => $resultData ) {
252 $this->extraData[$id][$name] = $resultData;
253 }
254 }
255
261 public function augmentResult( SearchResult $result ) {
262 $id = $result->getTitle()->getArticleID();
263 if ( !$id || !isset( $this->extraData[$id] ) ) {
264 return null;
265 }
266 $result->setExtensionData( $this->extraData[$id] );
267 return $this->extraData[$id];
268 }
269
276 public function getOffset() {
277 return null;
278 }
279}
hasInterwikiResults( $type=self::SECONDARY_RESULTS)
Check if there are results on other wikis.
setAugmentedData( $name, $data)
Sets augmented data for result set.
getTotalHits()
Some search modes return a total hit count for the query in the entire article database.
augmentResult(SearchResult $result)
Returns extra data for specific result and store it in SearchResult object.
array[] $extraData
Set of result's extra data, indexed per result id and then per data item name.
getInterwikiResults( $type=self::SECONDARY_RESULTS)
Return a result set of hits on other (multiple) wikis associated with this one.
rewind()
Rewind result set back to beginning.
searchContainedSyntax()
Did the search contain search syntax? If so, Special:Search won't offer the user a link to a create a...
free()
Frees the result set, if applicable.
__construct( $containedSyntax=false)
hasRewrittenQuery()
Some search modes will run an alternative query that it thinks gives a better result than the provide...
Title[] $titles
Cache of titles.
extractResults()
Extract all the results in the result set as array.
hasSuggestion()
Some search modes return a suggested alternate term if there are no exact hits.
$containedSyntax
Types of interwiki results.
next()
Fetches next search result, or false.
extractTitles()
Extract all the titles in the result set.
termMatches()
Fetch an array of regular expression fragments for matching the search terms as parsed by this engine...
SearchResult[] $results
Cache of results - serialization of the result iterator as an array.
Represents a title within MediaWiki.
Definition Title.php:39
namespace being checked & $result
Definition hooks.txt:2293
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:302
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
Definition linkcache.txt:17