diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-12-08 09:55:49 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-12-08 09:55:49 +0100 |
commit | 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e (patch) | |
tree | af68743f2f4a47d13f2b0eb05f5c4aaf86d8ea37 /includes/search/SearchOracle.php | |
parent | af4da56f1ad4d3ef7b06557bae365da2ea27a897 (diff) |
Update to MediaWiki 1.22.0
Diffstat (limited to 'includes/search/SearchOracle.php')
-rw-r--r-- | includes/search/SearchOracle.php | 86 |
1 files changed, 46 insertions, 40 deletions
diff --git a/includes/search/SearchOracle.php b/includes/search/SearchOracle.php index b0ea97fe..a8479654 100644 --- a/includes/search/SearchOracle.php +++ b/includes/search/SearchOracle.php @@ -30,32 +30,34 @@ */ class SearchOracle extends SearchEngine { - private $reservedWords = array ('ABOUT' => 1, - 'ACCUM' => 1, - 'AND' => 1, - 'BT' => 1, - 'BTG' => 1, - 'BTI' => 1, - 'BTP' => 1, - 'FUZZY' => 1, - 'HASPATH' => 1, - 'INPATH' => 1, - 'MINUS' => 1, - 'NEAR' => 1, - 'NOT' => 1, - 'NT' => 1, - 'NTG' => 1, - 'NTI' => 1, - 'NTP' => 1, - 'OR' => 1, - 'PT' => 1, - 'RT' => 1, - 'SQE' => 1, - 'SYN' => 1, - 'TR' => 1, - 'TRSYN' => 1, - 'TT' => 1, - 'WITHIN' => 1); + private $reservedWords = array( + 'ABOUT' => 1, + 'ACCUM' => 1, + 'AND' => 1, + 'BT' => 1, + 'BTG' => 1, + 'BTI' => 1, + 'BTP' => 1, + 'FUZZY' => 1, + 'HASPATH' => 1, + 'INPATH' => 1, + 'MINUS' => 1, + 'NEAR' => 1, + 'NOT' => 1, + 'NT' => 1, + 'NTG' => 1, + 'NTI' => 1, + 'NTP' => 1, + 'OR' => 1, + 'PT' => 1, + 'RT' => 1, + 'SQE' => 1, + 'SYN' => 1, + 'TR' => 1, + 'TRSYN' => 1, + 'TT' => 1, + 'WITHIN' => 1, + ); /** * Creates an instance of this class @@ -72,8 +74,9 @@ class SearchOracle extends SearchEngine { * @return SqlSearchResultSet */ function searchText( $term ) { - if ( $term == '' ) + if ( $term == '' ) { return new SqlSearchResultSet( false, '' ); + } $resultSet = $this->db->resultObject( $this->db->query( $this->getQuery( $this->filter( $term ), true ) ) ); return new SqlSearchResultSet( $resultSet, $this->searchTerms ); @@ -86,8 +89,9 @@ class SearchOracle extends SearchEngine { * @return SqlSearchResultSet */ function searchTitle( $term ) { - if ( $term == '' ) + if ( $term == '' ) { return new SqlSearchResultSet( false, '' ); + } $resultSet = $this->db->resultObject( $this->db->query( $this->getQuery( $this->filter( $term ), false ) ) ); return new MySQLSearchResultSet( $resultSet, $this->searchTerms ); @@ -110,8 +114,9 @@ class SearchOracle extends SearchEngine { * @return String */ function queryNamespaces() { - if( is_null( $this->namespaces ) ) + if ( is_null( $this->namespaces ) ) { return ''; + } if ( !count( $this->namespaces ) ) { $namespaces = '0'; } else { @@ -195,23 +200,24 @@ class SearchOracle extends SearchEngine { $searchon = ''; if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { - foreach( $m as $terms ) { + foreach ( $m as $terms ) { // Search terms in all variant forms, only // apply on wiki with LanguageConverter $temp_terms = $wgContLang->autoConvertToAllVariants( $terms[2] ); - if( is_array( $temp_terms )) { - $temp_terms = array_unique( array_values( $temp_terms )); - foreach( $temp_terms as $t ) { - $searchon .= ($terms[1] == '-' ? ' ~' : ' & ') . $this->escapeTerm( $t ); + if ( is_array( $temp_terms ) ) { + $temp_terms = array_unique( array_values( $temp_terms ) ); + foreach ( $temp_terms as $t ) { + $searchon .= ( $terms[1] == '-' ? ' ~' : ' & ' ) . $this->escapeTerm( $t ); } } else { - $searchon .= ($terms[1] == '-' ? ' ~' : ' & ') . $this->escapeTerm( $terms[2] ); + $searchon .= ( $terms[1] == '-' ? ' ~' : ' & ' ) . $this->escapeTerm( $terms[2] ); } if ( !empty( $terms[3] ) ) { $regexp = preg_quote( $terms[3], '/' ); - if ( $terms[4] ) + if ( $terms[4] ) { $regexp .= "[0-9A-Za-z_]+"; + } } else { $regexp = preg_quote( str_replace( '"', '', $terms[2] ), '/' ); } @@ -227,9 +233,9 @@ class SearchOracle extends SearchEngine { private function escapeTerm( $t ) { global $wgContLang; $t = $wgContLang->normalizeForSearch( $t ); - $t = isset( $this->reservedWords[strtoupper( $t )] ) ? '{'.$t.'}' : $t; - $t = preg_replace('/^"(.*)"$/', '($1)', $t); - $t = preg_replace('/([-&|])/', '\\\\$1', $t); + $t = isset( $this->reservedWords[strtoupper( $t )] ) ? '{' . $t . '}' : $t; + $t = preg_replace( '/^"(.*)"$/', '($1)', $t ); + $t = preg_replace( '/([-&|])/', '\\\\$1', $t ); return $t; } /** @@ -273,7 +279,7 @@ class SearchOracle extends SearchEngine { $dbw->update( 'searchindex', array( 'si_title' => $title ), - array( 'si_page' => $id ), + array( 'si_page' => $id ), 'SearchOracle::updateTitle', array() ); } |