* @ingroup SpecialPage
*/
-/**
- * Entry point
- *
- * @param $par String: (default '')
- */
-function wfSpecialSearch( $par = '' ) {
- global $wgRequest, $wgUser;
- // Strip underscores from title parameter; most of the time we'll want
- // text form here. But don't strip underscores from actual text params!
- $titleParam = str_replace( '_', ' ', $par );
- // Fetch the search term
- $search = str_replace( "\n", " ", $wgRequest->getText( 'search', $titleParam ) );
- $searchPage = new SpecialSearch( $wgRequest, $wgUser );
- if( $wgRequest->getVal( 'fulltext' )
- || !is_null( $wgRequest->getVal( 'offset' ))
- || !is_null( $wgRequest->getVal( 'searchx' )) )
- {
- $searchPage->showResults( $search );
- } else {
- $searchPage->goResult( $search );
- }
-}
-
/**
* implements Special:Search - Run text & title search and display the output
* @ingroup SpecialPage
*/
-class SpecialSearch {
+class SpecialSearch extends SpecialPage {
+
+ public function __construct() {
+ parent::__construct( 'Search' );
+ }
+
+ /**
+ * Entry point
+ *
+ * @param $par String or null
+ */
+ public function execute( $par ) {
+ global $wgRequest, $wgUser, $wgOut;
+
+ $this->setHeaders();
+ $this->outputHeader();
+ $wgOut->allowClickjacking();
+
+ // Strip underscores from title parameter; most of the time we'll want
+ // text form here. But don't strip underscores from actual text params!
+ $titleParam = str_replace( '_', ' ', $par );
+
+ // Fetch the search term
+ $search = str_replace( "\n", " ", $wgRequest->getText( 'search', $titleParam ) );
+
+ $this->load( $wgRequest, $wgUser );
+
+ if ( $wgRequest->getVal( 'fulltext' )
+ || !is_null( $wgRequest->getVal( 'offset' ) )
+ || !is_null( $wgRequest->getVal( 'searchx' ) ) )
+ {
+ $this->showResults( $search );
+ } else {
+ $this->goResult( $search );
+ }
+ }
/**
* Set up basic search parameters from the request and user settings.
* @param $request WebRequest
* @param $user User
*/
- public function __construct( &$request, &$user ) {
+ public function load( &$request, &$user ) {
list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, 'searchlimit' );
$this->mPrefix = $request->getVal('prefix', '');
# Extract requested namespaces
}
# If there's an exact or very near match, jump right there.
$t = SearchEngine::getNearMatch( $term );
+
+ if ( !wfRunHooks( 'SpecialSearchGo', array( &$t, &$term ) ) ) {
+ # Hook requested termination
+ return;
+ }
+
if( !is_null( $t ) ) {
- wfRunHooks( 'SpecialSearchGomatch', array( &$t ) );
$wgOut->redirect( $t->getFullURL() );
return;
}
wfRunHooks( 'SpecialSearchNoResults', array( $term ) );
}
+ $wgOut->parserOptions()->setEditSection( false );
if( $titleMatches ) {
if( $numTitleMatches > 0 ) {
$wgOut->wrapWikiMsg( "==$1==\n", 'titlematches' );
$textMatches->free();
}
if( $num === 0 ) {
- $wgOut->addWikiMsg( 'search-nonefound', wfEscapeWikiText( $term ) );
+ $wgOut->wrapWikiMsg( "<p class=\"mw-search-nonefound\">\n$1</p>", array( 'search-nonefound', wfEscapeWikiText( $term ) ) );
$this->showCreateLink( $t );
}
$wgOut->addHtml( "</div>" );
}
}
if( $messageName ) {
- $wgOut->addWikiMsg( $messageName, wfEscapeWikiText( $t->getPrefixedText() ) );
+ $wgOut->wrapWikiMsg( "<p class=\"mw-search-createlink\">\n$1</p>", array( $messageName, wfEscapeWikiText( $t->getPrefixedText() ) ) );
} else {
// preserve the paragraph for margins etc...
$wgOut->addHtml( '<p></p>' );
protected function setupPage( $term ) {
global $wgOut;
// Figure out the active search profile header
- $nsAllSet = array_keys( SearchEngine::searchableNamespaces() );
- if( $this->searchAdvanced )
+ if( $this->searchAdvanced ) {
$this->active = 'advanced';
- else {
+ } else {
$profiles = $this->getSearchProfiles();
foreach( $profiles as $key => $data ) {
$wgOut->setPageTitle( wfMsg( 'searchresults') );
$wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'searchresults-title', $term ) ) );
}
- $wgOut->setArticleRelated( false );
- $wgOut->setRobotPolicy( 'noindex,nofollow' );
// add javascript specific to special:search
$wgOut->addModules( 'mediawiki.legacy.search' );
- $wgOut->addModules( 'mediawiki.specials.search' );
+ $wgOut->addModules( 'mediawiki.special.search' );
}
/**
if( !is_null($infoLine) ) {
$out .= "\n<!-- {$infoLine} -->\n";
}
- $off = $this->offset + 1;
$out .= "<ul class='mw-search-results'>\n";
while( $result = $matches->next() ) {
$out .= $this->showHit( $result, $terms );
if( $img ) {
$thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) );
if( $thumb ) {
- $desc = $img->getShortDesc();
+ $desc = wfMsgExt( 'parentheses', 'parseinline', $img->getShortDesc() );
wfProfileOut( __METHOD__ );
// Float doesn't seem to interact well with the bullets.
// Table messes up vertical alignment of the bullets.
$out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>".
wfMsg('search-interwiki-caption')."</div>\n";
- $off = $this->offset + 1;
$out .= "<ul class='mw-search-iwresults'>\n";
// work out custom project captions
$namespaceTables .
Xml::element( 'div', array( 'class' => 'divider' ), '', false ) .
$redirects .
- Xml::hidden( 'title', SpecialPage::getTitleFor( 'Search' )->getPrefixedText() ) .
- Xml::hidden( 'advanced', $this->searchAdvanced ) .
- Xml::hidden( 'fulltext', 'Advanced search' ) .
+ Html::hidden( 'title', SpecialPage::getTitleFor( 'Search' )->getPrefixedText() ) .
+ Html::hidden( 'advanced', $this->searchAdvanced ) .
+ Html::hidden( 'fulltext', 'Advanced search' ) .
Xml::closeElement( 'fieldset' );
}
// Adds hidden namespace fields
if ( !$this->searchAdvanced ) {
foreach( $this->namespaces as $ns ) {
- $out .= Xml::hidden( "ns{$ns}", '1' );
+ $out .= Html::hidden( "ns{$ns}", '1' );
}
}