return $ret;
}
+ function setupPage() {
+ global $wgOut;
+ $wgOut->setPageTitle( wfMsg( "searchresults" ) );
+ $q = wfMsg( "searchquery", htmlspecialchars( $this->mUsertext ) );
+ $wgOut->setSubtitle( $q );
+ $wgOut->setArticleRelated( false );
+ $wgOut->setRobotpolicy( "noindex,nofollow" );
+ }
+
# Perform the search and construct the results page
function showResults()
{
$powersearch = $this->powersearch(); /* Need side-effects here? */
- $wgOut->setPageTitle( wfMsg( "searchresults" ) );
- $q = wfMsg( "searchquery", htmlspecialchars( $this->mUsertext ) );
- $wgOut->setSubtitle( $q );
- $wgOut->setArticleRelated( false );
- $wgOut->setRobotpolicy( "noindex,nofollow" );
-
+ $this->setupPage();
+
$sk = $wgUser->getSkin();
$header = wfMsg( "searchresulttext", $sk->makeKnownLink(
wfMsg( "searchhelppage" ), wfMsg( "searchingwikipedia" ) ) );
# Use cleaner boolean search if available
return $this->parseQuery4();
}
+ # on non mysql4 database: get list of words we don't want to search for
+ require_once( "FulltextStoplist.php" );
$lc = SearchEngine::legalSearchChars() . "()";
$q = preg_replace( "/([()])/", " \\1 ", $this->mUsertext );
function goResult()
{
- global $wgOut, $wgRequest;
+ global $wgOut, $wgRequest, $wgGoToEdit;
global $wgDisableTextSearch;
$fname = "SearchEngine::goResult";
- $search = $wgRequest->getText( "search" );
+ $search = trim( $wgRequest->getText( "search" ) );
- # First try to go to page as entered.
+ # Try to go to page as entered.
#
$t = Title::newFromText( $search );
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 );
- $wgOut->addHTML( "<p>" . wfMsg("nogomatch", $t->escapeLocalURL( "action=edit" ) ) . "</p>\n" );
+
+ # If the feature is enabled, go straight to the edit page
+ if ( $wgGoToEdit ) {
+ $wgOut->redirect( $t->getFullURL( "action=edit" ) );
+ return;
+ }
+
+ if( $t ) {
+ $editurl = $t->escapeLocalURL( "action=edit" );
+ } else {
+ $editurl = ""; # ??
+ }
+ $wgOut->addHTML( "<p>" . wfMsg("nogomatch", $editurl ) . "</p>\n" );
# Try a fuzzy title search
$anyhit = false;
/* static */ function doFuzzyTitleSearch( $search, $namespace ){
global $wgLang, $wgOut;
+
+ $this->setupPage();
+
$sstr = ucfirst($search);
$sstr = str_replace(" ", "_", $sstr);
$fuzzymatches = SearchEngine::fuzzyTitles( $sstr, $namespace );