X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fsearch%2FSearchSqlite.php;h=6b1a6b24bcded0f880ec60456d68d790dc9e3b79;hb=ed945112a8640fcaefa0128456602893294aee31;hp=ebff68ef1fb43c038b2e1d5bacd17d273f8d7afa;hpb=11cb289cfc45fd40056bccae208934b11c98c10e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/search/SearchSqlite.php b/includes/search/SearchSqlite.php index ebff68ef1f..6b1a6b24bc 100644 --- a/includes/search/SearchSqlite.php +++ b/includes/search/SearchSqlite.php @@ -28,7 +28,7 @@ class SearchSqlite extends SearchDatabase { /** * Whether fulltext search is supported by current schema - * @return Boolean + * @return bool */ function fulltextSearchSupported() { return $this->db->checkForEnabledSearch(); @@ -42,7 +42,7 @@ class SearchSqlite extends SearchDatabase { */ function parseQuery( $filteredText, $fulltext ) { global $wgContLang; - $lc = SearchEngine::legalSearchChars(); // Minus format chars + $lc = $this->legalSearchChars(); // Minus format chars $searchon = ''; $this->searchTerms = array(); @@ -144,8 +144,8 @@ class SearchSqlite extends SearchDatabase { /** * Perform a full text search query and return a result set. * - * @param string $term raw search term - * @return SqliteSearchResultSet + * @param string $term Raw search term + * @return SqlSearchResultSet */ function searchText( $term ) { return $this->searchInternal( $term, true ); @@ -154,8 +154,8 @@ class SearchSqlite extends SearchDatabase { /** * Perform a title-only search query and return a result set. * - * @param string $term raw search term - * @return SqliteSearchResultSet + * @param string $term Raw search term + * @return SqlSearchResultSet */ function searchTitle( $term ) { return $this->searchInternal( $term, false ); @@ -181,24 +181,12 @@ class SearchSqlite extends SearchDatabase { $totalResult->free(); } - return new SqliteSearchResultSet( $resultSet, $this->searchTerms, $total ); - } - - /** - * Return a partial WHERE clause to exclude redirects, if so set - * @return String - */ - function queryRedirect() { - if ( $this->showRedirects ) { - return ''; - } else { - return 'AND page_is_redirect=0'; - } + return new SqlSearchResultSet( $resultSet, $this->searchTerms, $total ); } /** * Return a partial WHERE clause to limit the search to the given namespaces - * @return String + * @return string */ function queryNamespaces() { if ( is_null( $this->namespaces ) ) { @@ -214,8 +202,8 @@ class SearchSqlite extends SearchDatabase { /** * Returns a query with limit for number of results set. - * @param $sql String: - * @return String + * @param string $sql + * @return string */ function limitResult( $sql ) { return $this->db->limitResult( $sql, $this->limit, $this->offset ); @@ -224,22 +212,21 @@ class SearchSqlite extends SearchDatabase { /** * Construct the full SQL query to do the search. * The guts shoulds be constructed in queryMain() - * @param $filteredTerm String - * @param $fulltext Boolean - * @return String + * @param string $filteredTerm + * @param bool $fulltext + * @return string */ function getQuery( $filteredTerm, $fulltext ) { return $this->limitResult( $this->queryMain( $filteredTerm, $fulltext ) . ' ' . - $this->queryRedirect() . ' ' . $this->queryNamespaces() ); } /** * Picks which field to index on, depending on what type of query. - * @param $fulltext Boolean - * @return String + * @param bool $fulltext + * @return string */ function getIndexField( $fulltext ) { return $fulltext ? 'si_text' : 'si_title'; @@ -248,9 +235,9 @@ class SearchSqlite extends SearchDatabase { /** * Get the base part of the search query. * - * @param $filteredTerm String - * @param $fulltext Boolean - * @return String + * @param string $filteredTerm + * @param bool $fulltext + * @return string */ function queryMain( $filteredTerm, $fulltext ) { $match = $this->parseQuery( $filteredTerm, $fulltext ); @@ -267,8 +254,7 @@ class SearchSqlite extends SearchDatabase { $searchindex = $this->db->tableName( 'searchindex' ); return "SELECT COUNT(*) AS c " . "FROM $page,$searchindex " . - "WHERE page_id=$searchindex.rowid AND $match" . - $this->queryRedirect() . ' ' . + "WHERE page_id=$searchindex.rowid AND $match " . $this->queryNamespaces(); } @@ -276,9 +262,9 @@ class SearchSqlite extends SearchDatabase { * Create or update the search index record for the given page. * Title and text should be pre-processed. * - * @param $id Integer - * @param $title String - * @param $text String + * @param int $id + * @param string $title + * @param string $text */ function update( $id, $title, $text ) { if ( !$this->fulltextSearchSupported() ) { @@ -302,8 +288,8 @@ class SearchSqlite extends SearchDatabase { * Update a search index record's title only. * Title should be pre-processed. * - * @param $id Integer - * @param $title String + * @param int $id + * @param string $title */ function updateTitle( $id, $title ) { if ( !$this->fulltextSearchSupported() ) { @@ -317,17 +303,3 @@ class SearchSqlite extends SearchDatabase { __METHOD__ ); } } - -/** - * @ingroup Search - */ -class SqliteSearchResultSet extends SqlSearchResultSet { - function __construct( $resultSet, $terms, $totalHits = null ) { - parent::__construct( $resultSet, $terms ); - $this->mTotalHits = $totalHits; - } - - function getTotalHits() { - return $this->mTotalHits; - } -}