X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fsearch%2FSearchOracle.php;h=9cd245a8603cc2318510eadddd840c7d3ceaeb79;hb=7b05197301ee330865d2d377cc1005b6c61cb251;hp=c5a5ef11a792695217b03538b991dfa14f661a90;hpb=f43fa6f4f0e2cb60b8543daad661b48a3e0653a9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/search/SearchOracle.php b/includes/search/SearchOracle.php index c5a5ef11a7..9cd245a860 100644 --- a/includes/search/SearchOracle.php +++ b/includes/search/SearchOracle.php @@ -24,6 +24,8 @@ * @ingroup Search */ +use MediaWiki\MediaWikiServices; + /** * Search engine hook base class for Oracle (ConText). * @ingroup Search @@ -64,7 +66,7 @@ class SearchOracle extends SearchDatabase { * @param string $term Raw search term * @return SqlSearchResultSet */ - function searchText( $term ) { + protected function doSearchTextInDB( $term ) { if ( $term == '' ) { return new SqlSearchResultSet( false, '' ); } @@ -79,7 +81,7 @@ class SearchOracle extends SearchDatabase { * @param string $term Raw search term * @return SqlSearchResultSet */ - function searchTitle( $term ) { + protected function doSearchTitleInDB( $term ) { if ( $term == '' ) { return new SqlSearchResultSet( false, '' ); } @@ -92,7 +94,7 @@ class SearchOracle extends SearchDatabase { * Return a partial WHERE clause to limit the search to the given namespaces * @return string */ - function queryNamespaces() { + private function queryNamespaces() { if ( is_null( $this->namespaces ) ) { return ''; } @@ -111,7 +113,7 @@ class SearchOracle extends SearchDatabase { * * @return string */ - function queryLimit( $sql ) { + private function queryLimit( $sql ) { return $this->db->limitResult( $sql, $this->limit, $this->offset ); } @@ -134,7 +136,7 @@ class SearchOracle extends SearchDatabase { * @param bool $fulltext * @return string */ - function getQuery( $filteredTerm, $fulltext ) { + private function getQuery( $filteredTerm, $fulltext ) { return $this->queryLimit( $this->queryMain( $filteredTerm, $fulltext ) . ' ' . $this->queryNamespaces() . ' ' . $this->queryRanking( $filteredTerm, $fulltext ) . ' ' ); @@ -145,7 +147,7 @@ class SearchOracle extends SearchDatabase { * @param bool $fulltext * @return string */ - function getIndexField( $fulltext ) { + private function getIndexField( $fulltext ) { return $fulltext ? 'si_text' : 'si_title'; } @@ -172,9 +174,8 @@ class SearchOracle extends SearchDatabase { * @param bool $fulltext * @return string */ - function parseQuery( $filteredText, $fulltext ) { - global $wgContLang; - $lc = $this->legalSearchChars(); + private function parseQuery( $filteredText, $fulltext ) { + $lc = $this->legalSearchChars( self::CHARS_NO_SYNTAX ); $this->searchTerms = []; # @todo FIXME: This doesn't handle parenthetical expressions. @@ -185,7 +186,8 @@ class SearchOracle extends SearchDatabase { foreach ( $m as $terms ) { // Search terms in all variant forms, only // apply on wiki with LanguageConverter - $temp_terms = $wgContLang->autoConvertToAllVariants( $terms[2] ); + $temp_terms = MediaWikiServices::getInstance()->getContentLanguage()-> + autoConvertToAllVariants( $terms[2] ); if ( is_array( $temp_terms ) ) { $temp_terms = array_unique( array_values( $temp_terms ) ); foreach ( $temp_terms as $t ) { @@ -212,8 +214,7 @@ class SearchOracle extends SearchDatabase { } private function escapeTerm( $t ) { - global $wgContLang; - $t = $wgContLang->normalizeForSearch( $t ); + $t = MediaWikiServices::getInstance()->getContentLanguage()->normalizeForSearch( $t ); $t = isset( $this->reservedWords[strtoupper( $t )] ) ? '{' . $t . '}' : $t; $t = preg_replace( '/^"(.*)"$/', '($1)', $t ); $t = preg_replace( '/([-&|])/', '\\\\$1', $t ); @@ -266,7 +267,11 @@ class SearchOracle extends SearchDatabase { [] ); } - public static function legalSearchChars() { - return "\"" . parent::legalSearchChars(); + public static function legalSearchChars( $type = self::CHARS_ALL ) { + $searchChars = parent::legalSearchChars( $type ); + if ( $type === self::CHARS_ALL ) { + $searchChars = "\"" . $searchChars; + } + return $searchChars; } }