summaryrefslogtreecommitdiff
path: root/includes/SpecialSearch.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/SpecialSearch.php')
-rw-r--r--includes/SpecialSearch.php41
1 files changed, 31 insertions, 10 deletions
diff --git a/includes/SpecialSearch.php b/includes/SpecialSearch.php
index 3fc8bab4..dcbbb903 100644
--- a/includes/SpecialSearch.php
+++ b/includes/SpecialSearch.php
@@ -103,7 +103,11 @@ class SpecialSearch {
return;
}
}
- $wgOut->addWikiText( wfMsg( 'noexactmatch', wfEscapeWikiText( $term ) ) );
+ if( $t->quickUserCan( 'create' ) && $t->quickUserCan( 'edit' ) ) {
+ $wgOut->addWikiMsg( 'noexactmatch', wfEscapeWikiText( $term ) );
+ } else {
+ $wgOut->addWikiMsg( 'noexactmatch-nocreate', wfEscapeWikiText( $term ) );
+ }
return $this->showResults( $term );
}
@@ -119,12 +123,13 @@ class SpecialSearch {
$this->setupPage( $term );
global $wgOut;
- $wgOut->addWikiText( wfMsg( 'searchresulttext' ) );
+ $wgOut->addWikiMsg( 'searchresulttext' );
- #if ( !$this->parseQuery() ) {
if( '' === trim( $term ) ) {
+ // Empty query -- straight view of search form
$wgOut->setSubtitle( '' );
$wgOut->addHTML( $this->powerSearchBox( $term ) );
+ $wgOut->addHTML( $this->powerSearchFocus() );
wfProfileOut( $fname );
return;
}
@@ -155,6 +160,15 @@ class SpecialSearch {
$search->setNamespaces( $this->namespaces );
$search->showRedirects = $this->searchRedirects;
$titleMatches = $search->searchTitle( $term );
+
+ // Sometimes the search engine knows there are too many hits
+ if ($titleMatches instanceof SearchResultTooMany) {
+ $wgOut->addWikiText( '==' . wfMsg( 'toomanymatches' ) . "==\n" );
+ $wgOut->addHTML( $this->powerSearchBox( $term ) );
+ $wgOut->addHTML( $this->powerSearchFocus() );
+ wfProfileOut( $fname );
+ return;
+ }
$textMatches = $search->searchText( $term );
$num = ( $titleMatches ? $titleMatches->numRows() : 0 )
@@ -180,27 +194,27 @@ class SpecialSearch {
if( $titleMatches ) {
if( $titleMatches->numRows() ) {
- $wgOut->addWikiText( '==' . wfMsg( 'titlematches' ) . "==\n" );
+ $wgOut->wrapWikiMsg( "==$1==\n", 'titlematches' );
$wgOut->addHTML( $this->showMatches( $titleMatches ) );
} else {
- $wgOut->addWikiText( '==' . wfMsg( 'notitlematches' ) . "==\n" );
+ $wgOut->wrapWikiMsg( "==$1==\n", 'notitlematches' );
}
$titleMatches->free();
}
if( $textMatches ) {
if( $textMatches->numRows() ) {
- $wgOut->addWikiText( '==' . wfMsg( 'textmatches' ) . "==\n" );
+ $wgOut->wrapWikiMsg( "==$1==\n", 'textmatches' );
$wgOut->addHTML( $this->showMatches( $textMatches ) );
} elseif( $num == 0 ) {
# Don't show the 'no text matches' if we received title matches
- $wgOut->addWikiText( '==' . wfMsg( 'notextmatches' ) . "==\n" );
+ $wgOut->wrapWikiMsg( "==$1==\n", 'notextmatches' );
}
$textMatches->free();
}
if ( $num == 0 ) {
- $wgOut->addWikiText( wfMsg( 'nonefound' ) );
+ $wgOut->addWikiMsg( 'nonefound' );
}
if( $num || $this->offset ) {
$wgOut->addHTML( "<p>{$prevnext}</p>\n" );
@@ -387,8 +401,9 @@ class SpecialSearch {
if( '' == $name ) {
$name = wfMsg( 'blanknamespace' );
}
+ $encName = htmlspecialchars( $name );
$namespaces .= " <label><input type='checkbox' value=\"1\" name=\"" .
- "ns{$ns}\"{$checked} />{$name}</label>\n";
+ "ns{$ns}\"{$checked} />{$encName}</label>\n";
}
$checked = $this->searchRedirects
@@ -396,7 +411,7 @@ class SpecialSearch {
: '';
$redirect = "<input type='checkbox' value='1' name=\"redirs\"{$checked} />\n";
- $searchField = '<input type="text" name="search" value="' .
+ $searchField = '<input type="text" id="powerSearchText" name="search" value="' .
htmlspecialchars( $term ) ."\" size=\"16\" />\n";
$searchButton = '<input type="submit" name="searchx" value="' .
@@ -412,6 +427,12 @@ class SpecialSearch {
return "<br /><br />\n<form id=\"powersearch\" method=\"get\" " .
"action=\"$action\">\n{$ret}\n</form>\n";
}
+
+ function powerSearchFocus() {
+ return "<script type='text/javascript'>" .
+ "document.getElementById('powerSearchText').focus();" .
+ "</script>";
+ }
}