Using a better method to get the English language file.
[lhc/web/wiklou.git] / includes / SearchEngine.php
index ee90ab7..c3b3851 100644 (file)
@@ -12,7 +12,7 @@ class SearchEngine {
        var $limit = 10;
        var $offset = 0;
        var $searchTerms = array();
-       var $namespaces = array( 0 );
+       var $namespaces = array( NS_MAIN );
        var $showRedirects = false;
 
        /**
@@ -48,7 +48,7 @@ class SearchEngine {
         * @static
         * @param string $term
         * @return Title
-        * @access private
+        * @private
         */
        function getNearMatch( $term ) {
                # Exact match? No need to look further.
@@ -80,7 +80,19 @@ class SearchEngine {
                if ( $title->exists() ) {
                        return $title;
                }
-               
+
+               # Now try Word-Caps-Breaking-At-Word-Breaks, for hyphenated names etc
+               $title = Title::newFromText( preg_replace_callback(
+                       '/\b([\w\x80-\xff]+)\b/',
+                       create_function( '$matches', '
+                               global $wgContLang;
+                               return $wgContLang->ucfirst($matches[1]);
+                               ' ),
+                       $term ) );
+               if ( $title->exists() ) {
+                       return $title;
+               }
+
                global $wgCapitalLinks, $wgContLang;
                if( !$wgCapitalLinks ) {
                        // Catch differs-by-first-letter-case-only
@@ -175,7 +187,7 @@ class SearchEngine {
         * active database backend, and return a configured instance.
         *
         * @return SearchEngine
-        * @access private
+        * @private
         */
        function create() {
                global $wgDBtype, $wgSearchType;
@@ -183,10 +195,8 @@ class SearchEngine {
                        $class = $wgSearchType;
                } elseif( $wgDBtype == 'mysql' ) {
                        $class = 'SearchMySQL4';
-                       require_once( 'SearchMySQL4.php' );
-               } else if ( $wgDBtype == 'PostgreSQL' ) {
-                       $class = 'SearchTsearch2';
-                       require_once( 'SearchTsearch2.php' );
+               } else if ( $wgDBtype == 'postgres' ) {
+                       $class = 'SearchPostgres';
                } else {
                        $class = 'SearchEngineDummy';
                }
@@ -332,4 +342,4 @@ class SearchEngineDummy {
        function searchtitle() {}
        function searchtext() {}
 }
-
+?>