* the search terms as parsed by this engine in a text extract.
* STUB
*
- * @return Array
+ * @return array
*/
function termMatches() {
return array();
return 0;
}
- /**
- * Return true if results are included in this result set.
- * STUB
- *
- * @return Boolean
- */
- function hasResults() {
- return false;
- }
-
/**
* Some search modes return a total hit count for the query
* in the entire article database. This may include pages
*
* Return null if no total hits number is supported.
*
- * @return Integer
+ * @return int
*/
function getTotalHits() {
return null;
* Some search modes return a suggested alternate term if there are
* no exact hits. Returns true if there is one on this set.
*
- * @return Boolean
+ * @return bool
*/
function hasSuggestion() {
return false;
}
/**
- * @return String: suggested query, null if none
+ * @return string Suggested query, null if none
*/
function getSuggestionQuery() {
return null;
}
/**
- * @return String: HTML highlighted suggested query, '' if none
+ * @return string HTML highlighted suggested query, '' if none
*/
function getSuggestionSnippet() {
return '';
}
- /**
- * Return information about how and from where the results were fetched,
- * should be useful for diagnostics and debugging
- *
- * @return String
- */
- function getInfo() {
- return null;
- }
-
/**
* Return a result set of hits on other (multiple) wikis associated with this one
*
/**
* Check if there are results on other wikis
*
- * @return Boolean
+ * @return bool
*/
function hasInterwikiResults() {
return $this->getInterwikiResults() != null;
* Did the search contain search syntax? If so, Special:Search won't offer
* the user a link to a create a page named by the search string because the
* name would contain the search syntax.
+ * @return bool
*/
public function searchContainedSyntax() {
return false;
* @ingroup Search
*/
class SqlSearchResultSet extends SearchResultSet {
+ protected $resultSet;
+ protected $terms;
+ protected $totalHits;
- protected $mResultSet;
-
- function __construct( $resultSet, $terms ) {
- $this->mResultSet = $resultSet;
- $this->mTerms = $terms;
+ function __construct( $resultSet, $terms, $total = null ) {
+ $this->resultSet = $resultSet;
+ $this->terms = $terms;
+ $this->totalHits = $total;
}
function termMatches() {
- return $this->mTerms;
+ return $this->terms;
}
function numRows() {
- if ( $this->mResultSet === false ) {
+ if ( $this->resultSet === false ) {
return false;
}
- return $this->mResultSet->numRows();
+ return $this->resultSet->numRows();
}
function next() {
- if ( $this->mResultSet === false ) {
+ if ( $this->resultSet === false ) {
return false;
}
- $row = $this->mResultSet->fetchObject();
+ $row = $this->resultSet->fetchObject();
if ( $row === false ) {
return false;
}
}
function free() {
- if ( $this->mResultSet === false ) {
+ if ( $this->resultSet === false ) {
return false;
}
- $this->mResultSet->free();
+ $this->resultSet->free();
+ }
+
+ function getTotalHits() {
+ if ( !is_null( $this->totalHits ) ) {
+ return $this->totalHits;
+ } else {
+ // Special:Search expects a number here.
+ return $this->numRows();
+ }
}
}
private $fetched = false;
/**
- * @param $match mixed Title if matched, else null
+ * @param Title|null $match Title if matched, else null
*/
public function __construct( $match ) {
$this->result = $match;
}
- public function hasResult() {
- return (bool)$this->result;
- }
-
public function numRows() {
- return $this->hasResults() ? 1 : 0;
+ return $this->result ? 1 : 0;
}
public function next() {