Orphan creating feature -- go redirects to edit if the page doesn't exist, off by...
authorTim Starling <tstarling@users.mediawiki.org>
Tue, 4 May 2004 14:36:42 +0000 (14:36 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Tue, 4 May 2004 14:36:42 +0000 (14:36 +0000)
includes/DefaultSettings.php
includes/SearchEngine.php

index cf47423..d3dde9c 100644 (file)
@@ -354,5 +354,8 @@ $wgImportSources = array();
 $wgMaxCredits = 0;
 
 # Text matching this regex will be recognised as spam
-$wgSpamRegex   = false; 
+$wgSpamRegex = false; 
+
+# Go button goes straight to the edit screen if the article doesn't exist
+$wgGoToEdit = false;
 ?>
index da22677..19a081b 100644 (file)
@@ -424,19 +424,12 @@ class SearchEngine {
 
        function goResult()
        {
-               global $wgOut, $wgRequest;
+               global $wgOut, $wgRequest, $wgGoToEdit;
                global $wgDisableTextSearch;
                $fname = "SearchEngine::goResult";
                
                $search = trim( $wgRequest->getText( "search" ) );
 
-               # Entering an IP address goes to the contributions page
-               if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $search ) ) {
-                       $title = Title::makeTitle( NS_SPECIAL, "Contributions" );
-                       $wgOut->redirect( $title->getFullUrl( "target=$search" ) );
-                       return;
-               }
-
                # Try to go to page as entered.
                #
                $t = Title::newFromText( $search );
@@ -477,8 +470,22 @@ class SearchEngine {
                        return;
                }
 
+               # Entering an IP address goes to the contributions page
+               if ( preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $search ) ) {
+                       $title = Title::makeTitle( NS_SPECIAL, "Contributions" );
+                       $wgOut->redirect( $title->getFullUrl( "target=$search" ) );
+                       return;
+               }
+
                # No match, generate an edit URL
                $t = Title::newFromText( $this->mUsertext );
+               
+               # If the feature is enabled, go straight to the edit page
+               if ( $wgGoToEdit ) {
+                       $wgOut->redirect( $t->getFullURL( "action=edit" ) );
+                       return;
+               }
+
                $wgOut->addHTML( "<p>" . wfMsg("nogomatch", $t->escapeLocalURL( "action=edit" ) ) . "</p>\n" );
 
                # Try a fuzzy title search