* Yummie ? : syntax.
[lhc/web/wiklou.git] / includes / SearchEngine.php
index f802aeb..a49f8e5 100644 (file)
@@ -47,9 +47,6 @@ class SearchEngine {
         * @access private
         */
        function getNearMatch( $term ) {
-               # Eliminate Blanks at start
-               $term = ereg_replace('[[:blank:]]*', '', $term);
-
                # Exact match? No need to look further.
                $title = Title::newFromText( $term );
                if ( $title->getNamespace() == NS_SPECIAL || 0 != $title->getArticleID() ) {
@@ -77,18 +74,18 @@ class SearchEngine {
                        return $title;
                }
 
+               $title = Title::newFromText( $term );
+
                # Entering an IP address goes to the contributions page
-               if ( preg_match( '/^(user:)?\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', strtolower($term) ) ) {
-                       $title = Title::makeTitle( NS_SPECIAL, "Contributions/" . $term );
-                       return $title;
+               if ( ( $title->getNamespace() == NS_USER && User::isIP($title->getText() ) )
+                       || User::isIP( trim( $term ) ) ) {
+                       return Title::makeTitle( NS_SPECIAL, "Contributions/" . $title->getDbkey() );
                }
 
+
                # Entering a user goes to the user page whether it's there or not
-               if ( preg_match( '/^user:/', strtolower($term) ) ) {
-                        if (User::idFromName($term)) {
-                         $title = Title::newFromURL( $term );
-                         return $title;
-                        }
+               if ( $title->getNamespace() == NS_USER ) {
+                       return $title;
                }
                
                return NULL;