Implement #1398 : Using go button to go to empty userpage for existing user goes...
authorAntoine Musso <hashar@users.mediawiki.org>
Tue, 1 Feb 2005 02:31:08 +0000 (02:31 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Tue, 1 Feb 2005 02:31:08 +0000 (02:31 +0000)
patch by Thue Janus Kristensen <thuejk (at) gmail (dot) com>

includes/SearchEngine.php

index 2e83974..f802aeb 100644 (file)
@@ -47,6 +47,9 @@ 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() ) {
@@ -75,10 +78,18 @@ class SearchEngine {
                }
 
                # Entering an IP address goes to the contributions page
-               if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $term ) ) {
+               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;
                }
+
+               # 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;
+                        }
+               }
                
                return NULL;
        }