Completed
Branch master (86dc85)
by
unknown
23:45
created

SearchResultSet::rewind()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 2
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Search result sets
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation; either version 2 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License along
16
 * with this program; if not, write to the Free Software Foundation, Inc.,
17
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
 * http://www.gnu.org/copyleft/gpl.html
19
 *
20
 * @file
21
 * @ingroup Search
22
 */
23
24
/**
25
 * @ingroup Search
26
 */
27
class SearchResultSet {
28
29
	/**
30
	 * Types of interwiki results
31
	 */
32
	/**
33
	 * Results that are displayed only together with existing main wiki results
34
	 * @var int
35
	 */
36
	const SECONDARY_RESULTS = 0;
37
	/**
38
	 * Results that can displayed even if no existing main wiki results exist
39
	 * @var int
40
	 */
41
	const INLINE_RESULTS = 1;
42
43
	protected $containedSyntax = false;
44
45
	public function __construct( $containedSyntax = false ) {
46
		$this->containedSyntax = $containedSyntax;
47
	}
48
49
	/**
50
	 * Fetch an array of regular expression fragments for matching
51
	 * the search terms as parsed by this engine in a text extract.
52
	 * STUB
53
	 *
54
	 * @return array
55
	 */
56
	function termMatches() {
57
		return [];
58
	}
59
60
	function numRows() {
61
		return 0;
62
	}
63
64
	/**
65
	 * Some search modes return a total hit count for the query
66
	 * in the entire article database. This may include pages
67
	 * in namespaces that would not be matched on the given
68
	 * settings.
69
	 *
70
	 * Return null if no total hits number is supported.
71
	 *
72
	 * @return int
73
	 */
74
	function getTotalHits() {
75
		return null;
76
	}
77
78
	/**
79
	 * Some search modes will run an alternative query that it thinks gives
80
	 * a better result than the provided search. Returns true if this has
81
	 * occured.
82
	 *
83
	 * @return bool
84
	 */
85
	function hasRewrittenQuery() {
86
		return false;
87
	}
88
89
	/**
90
	 * @return string|null The search the query was internally rewritten to,
91
	 *  or null when the result of the original query was returned.
92
	 */
93
	function getQueryAfterRewrite() {
94
		return null;
95
	}
96
97
	/**
98
	 * @return string|null Same as self::getQueryAfterRewrite(), but in HTML
99
	 *  and with changes highlighted. Null when the query was not rewritten.
100
	 */
101
	function getQueryAfterRewriteSnippet() {
102
		return null;
103
	}
104
105
	/**
106
	 * Some search modes return a suggested alternate term if there are
107
	 * no exact hits. Returns true if there is one on this set.
108
	 *
109
	 * @return bool
110
	 */
111
	function hasSuggestion() {
112
		return false;
113
	}
114
115
	/**
116
	 * @return string|null Suggested query, null if none
117
	 */
118
	function getSuggestionQuery() {
119
		return null;
120
	}
121
122
	/**
123
	 * @return string HTML highlighted suggested query, '' if none
124
	 */
125
	function getSuggestionSnippet() {
126
		return '';
127
	}
128
129
	/**
130
	 * Return a result set of hits on other (multiple) wikis associated with this one
131
	 *
132
	 * @return SearchResultSet[]
133
	 */
134
	function getInterwikiResults( $type = self::SECONDARY_RESULTS ) {
135
		return null;
136
	}
137
138
	/**
139
	 * Check if there are results on other wikis
140
	 *
141
	 * @return bool
142
	 */
143
	function hasInterwikiResults( $type = self::SECONDARY_RESULTS ) {
144
		return false;
145
	}
146
147
	/**
148
	 * Fetches next search result, or false.
149
	 * STUB
150
	 *
151
	 * @return SearchResult
152
	 */
153
	function next() {
154
		return false;
155
	}
156
157
	/**
158
	 * Rewind result set back to begining
159
	 */
160
	function rewind() {
161
	}
162
163
	/**
164
	 * Frees the result set, if applicable.
165
	 */
166
	function free() {
167
		// ...
168
	}
169
170
	/**
171
	 * Did the search contain search syntax?  If so, Special:Search won't offer
172
	 * the user a link to a create a page named by the search string because the
173
	 * name would contain the search syntax.
174
	 * @return bool
175
	 */
176
	public function searchContainedSyntax() {
177
		return $this->containedSyntax;
178
	}
179
}
180