2 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
3 # http://www.mediawiki.org/
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # http://www.gnu.org/copyleft/gpl.html
21 * Search engine hook for MySQL 3.23.x
27 require_once( 'SearchMySQL.php' );
33 class SearchMySQL3
extends SearchMySQL
{
34 function SearchMySQL3( &$db ) {
38 function parseQuery( $filteredText, $fulltext ) {
39 global $wgDBminWordLen, $wgContLang;
41 $field = $this->getIndexField( $fulltext );
43 # on non mysql4 database: get list of words we don't want to search for
44 require_once( 'FulltextStoplist.php' );
46 $lc = SearchEngine
::legalSearchChars() . '()';
47 $q = preg_replace( "/([()])/", " \\1 ", $filteredText );
48 $q = preg_replace( "/\\s+/", " ", $q );
49 $w = explode( ' ', trim( $q ) );
52 foreach ( $w as $word ) {
53 $word = $wgContLang->stripForSearch( $word );
54 if ( 'and' == $word ||
'or' == $word ||
'not' == $word
55 ||
'(' == $word ||
')' == $word ) {
56 $cond .= ' ' . strtoupper( $word );
58 } else if ( strlen( $word ) < $wgDBminWordLen ) {
60 } else if ( FulltextStoplist
::inList( $word ) ) {
63 if ( '' != $last ) { $cond .= ' AND'; }
64 $cond .= " (MATCH ($field) AGAINST ('" .
65 $this->db
->strencode( $word ). "'))";
67 $this->searchTerms
[] = "\\b" . preg_quote( $word, '/' ) . "\\b";
70 if ( 0 == count( $this->searchTerms
) ) {
71 # No searchable terms remaining.
72 # We have to return a term for the query or we get an SQL error.
76 return '(' . $cond . ' )';