Index: trunk/extensions/SphinxSearch/SphinxMWSearch.php |
— | — | @@ -163,13 +163,14 @@ |
164 | 164 | var $sphinx_client; |
165 | 165 | var $mSuggestion = ''; |
166 | 166 | var $db; |
| 167 | + var $total_hits = 0; |
167 | 168 | |
168 | 169 | function __construct( $resultSet, $terms, $sphinx_client, $dbr ) { |
169 | 170 | $this->sphinx_client = $sphinx_client; |
170 | 171 | $this->mResultSet = array(); |
171 | 172 | $this->db = $dbr ? $dbr : wfGetDB( DB_SLAVE ); |
172 | | - |
173 | 173 | if ( is_array( $resultSet ) && isset( $resultSet['matches'] ) ) { |
| 174 | + $this->total_hits = $resultSet[ 'total_found' ]; |
174 | 175 | foreach ( $resultSet['matches'] as $id => $docinfo ) { |
175 | 176 | $res = $this->db->select( |
176 | 177 | 'page', |
— | — | @@ -346,6 +347,29 @@ |
347 | 348 | } |
348 | 349 | |
349 | 350 | /** |
| 351 | + * Some search modes return a total hit count for the query |
| 352 | + * in the entire article database. This may include pages |
| 353 | + * in namespaces that would not be matched on the given |
| 354 | + * settings. |
| 355 | + * |
| 356 | + * Return null if no total hits number is supported. |
| 357 | + * |
| 358 | + * @return Integer |
| 359 | + */ |
| 360 | + function getTotalHits() { |
| 361 | + return $this->total_hits; |
| 362 | + } |
| 363 | + |
| 364 | + /** |
| 365 | + * Return information about how and from where the results were fetched. |
| 366 | + * |
| 367 | + * @return string |
| 368 | + */ |
| 369 | + function getInfo() { |
| 370 | + return wfMsg( 'sphinxPowered', "http://www.sphinxsearch.com" ); |
| 371 | + } |
| 372 | + |
| 373 | + /** |
350 | 374 | * @return SphinxMWSearchResult: next result, false if none |
351 | 375 | */ |
352 | 376 | function next() { |