/**
* @var string
*/
- protected $didYouMeanHtml, $fulltext;
+ protected $fulltext;
const NAMESPACES_CURRENT = 'sense';
}
}
- $this->didYouMeanHtml = ''; # html of did you mean... link
$this->fulltext = $request->getVal( 'fulltext' );
$this->profile = $profile;
}
# No match, generate an edit URL
$title = Title::newFromText( $term );
if ( !is_null( $title ) ) {
- wfRunHooks( 'SpecialSearchNogomatch', array( &$title ) );
+ Hooks::run( 'SpecialSearchNogomatch', array( &$title ) );
}
$this->showResults( $term );
}
public function showResults( $term ) {
global $wgContLang;
- $profile = new ProfileSection( __METHOD__ );
$search = $this->getSearchEngine();
$search->setLimitOffset( $this->limit, $this->offset );
$search->setNamespaces( $this->namespaces );
$search->prefix = $this->mPrefix;
$term = $search->transformSearchTerm( $term );
+ $didYouMeanHtml = '';
- wfRunHooks( 'SpecialSearchSetupEngine', array( $this, $this->profile, $search ) );
+ Hooks::run( 'SpecialSearchSetupEngine', array( $this, $this->profile, $search ) );
$this->setupPage( $term );
$stParams
);
- $this->didYouMeanHtml = '<div class="searchdidyoumean">'
- . $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() . '</div>';
+ # html of did you mean... search suggestion link
+ $didYouMeanHtml =
+ Xml::openElement( 'div', array( 'class' => 'searchdidyoumean' ) ) .
+ $this->msg( 'search-suggest' )->rawParams( $suggestLink )->text() .
+ Xml::closeElement( 'div' );
}
- if ( !wfRunHooks( 'SpecialSearchResultsPrepend', array( $this, $out, $term ) ) ) {
+ if ( !Hooks::run( 'SpecialSearchResultsPrepend', array( $this, $out, $term ) ) ) {
# Hook requested termination
return;
}
Xml::openElement(
'form',
array(
- 'id' => ( $this->profile === 'advanced' ? 'powersearch' : 'search' ),
+ 'id' => ( $this->isPowerSearch() ? 'powersearch' : 'search' ),
'method' => 'get',
'action' => wfScript(),
)
Xml::openElement( 'div', array( 'id' => 'mw-search-top-table' ) ) .
$this->shortDialog( $term, $num, $totalRes ) .
Xml::closeElement( 'div' ) .
- $this->formHeader( $term ) .
- Xml::closeElement( 'form' )
+ $this->searchProfileTabs( $term ) .
+ $this->searchOptions( $term ) .
+ Xml::closeElement( 'form' ) .
+ $didYouMeanHtml
);
$filePrefix = $wgContLang->getFormattedNsText( NS_FILE ) . ':';
);
}
}
- wfRunHooks( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) );
+ Hooks::run( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) );
$out->parserOptions()->setEditSection( false );
if ( $titleMatches ) {
wfEscapeWikiText( $title->getPrefixedText() ),
Message::numParam( $num )
);
- wfRunHooks( 'SpecialSearchCreateLink', array( $title, &$params ) );
+ Hooks::run( 'SpecialSearchCreateLink', array( $title, &$params ) );
// Extensions using the hook might still return an empty $messageName
if ( $messageName ) {
* @param string $term
*/
protected function setupPage( $term ) {
- # Should advanced UI be used?
- $this->searchAdvanced = ( $this->profile === 'advanced' );
$out = $this->getOutput();
if ( strval( $term ) !== '' ) {
$out->setPageTitle( $this->msg( 'searchresults' ) );
$out->addModules( 'mediawiki.special.search' );
}
+ /**
+ * Return true if current search is a power (advanced) search
+ *
+ * @return bool
+ */
+ protected function isPowerSearch() {
+ return $this->profile === 'advanced';
+ }
+
/**
* Extract "power search" namespace settings from the request object,
* returning a list of index numbers to search.
*/
protected function powerSearchOptions() {
$opt = array();
- if ( $this->profile !== 'advanced' ) {
+ if ( !$this->isPowerSearch() ) {
$opt['profile'] = $this->profile;
} else {
foreach ( $this->namespaces as $n ) {
protected function showMatches( &$matches ) {
global $wgContLang;
- $profile = new ProfileSection( __METHOD__ );
$terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
$out = "<ul class='mw-search-results'>\n";
* @return string
*/
protected function showHit( $result, $terms ) {
- $profile = new ProfileSection( __METHOD__ );
if ( $result->isBrokenTitle() ) {
return '';
$link_t = clone $title;
- wfRunHooks( 'ShowSearchHitTitle',
+ Hooks::run( 'ShowSearchHitTitle',
array( &$link_t, &$titleSnippet, $result, $terms, $this ) );
$link = Linker::linkKnown(
$html = null;
$score = '';
- if ( wfRunHooks( 'ShowSearchHit', array(
+ if ( Hooks::run( 'ShowSearchHit', array(
$this, $result, $terms,
&$link, &$redirect, &$section, &$extract,
&$score, &$size, &$date, &$related,
*/
protected function showInterwiki( $matches, $query ) {
global $wgContLang;
- $profile = new ProfileSection( __METHOD__ );
$out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>" .
$this->msg( 'search-interwiki-caption' )->text() . "</div>\n";
* @return string
*/
protected function showInterwikiHit( $result, $lastInterwiki, $query, $customCaptions ) {
- $profile = new ProfileSection( __METHOD__ );
if ( $result->isBrokenTitle() ) {
return '';
$showSections = array( 'namespaceTables' => $namespaceTables );
- wfRunHooks( 'SpecialSearchPowerBox', array( &$showSections, $term, $opts ) );
+ Hooks::run( 'SpecialSearchPowerBox', array( &$showSections, $term, $opts ) );
$hidden = '';
foreach ( $opts as $key => $value ) {
$user = $this->getUser();
if ( $user->isLoggedIn() ) {
$remember .= Xml::checkLabel(
- wfMessage( 'powersearch-remember' )->text(),
+ $this->msg( 'powersearch-remember' )->text(),
'nsRemember',
'mw-search-powersearch-remember',
false,
)
);
- wfRunHooks( 'SpecialSearchProfiles', array( &$profiles ) );
+ Hooks::run( 'SpecialSearchProfiles', array( &$profiles ) );
foreach ( $profiles as &$data ) {
if ( !is_array( $data['namespaces'] ) ) {
* @param string $term
* @return string
*/
- protected function formHeader( $term ) {
- $out = Xml::openElement( 'div', array( 'class' => 'mw-search-formheader' ) );
+ protected function searchProfileTabs( $term ) {
+ $out = Xml::openElement( 'div', array( 'class' => 'mw-search-profile-tabs' ) );
$bareterm = $term;
if ( $this->startsWithImage( $term ) ) {
$out .= Xml::element( 'div', array( 'style' => 'clear:both' ), '', false );
$out .= Xml::closeElement( 'div' );
- // Hidden stuff
+ return $out;
+ }
+
+ /**
+ * @param string $term Search term
+ * @return string
+ */
+ protected function searchOptions( $term ) {
+ $out = '';
$opts = array();
$opts['profile'] = $this->profile;
- if ( $this->profile === 'advanced' ) {
+ if ( $this->isPowerSearch() ) {
$out .= $this->powerSearchBox( $term, $opts );
} else {
$form = '';
- wfRunHooks( 'SpecialSearchProfileForm', array( $this, &$form, $this->profile, $term, $opts ) );
+ Hooks::run( 'SpecialSearchProfileForm', array( $this, &$form, $this->profile, $term, $opts ) );
$out .= $form;
}
$out .= Html::hidden( 'profile', $this->profile ) . "\n";
// Term box
$out .= Html::input( 'search', $term, 'search', array(
- 'id' => $this->profile === 'advanced' ? 'powerSearchText' : 'searchText',
+ 'id' => $this->isPowerSearch() ? 'powerSearchText' : 'searchText',
'size' => '50',
- 'autofocus',
+ 'autofocus' => trim( $term ) === '',
'class' => 'mw-ui-input mw-ui-input-inline',
) ) . "\n";
$out .= Html::hidden( 'fulltext', 'Search' ) . "\n";
Xml::element( 'div', array( 'style' => 'clear:both' ), '', false );
}
- return $out . $this->didYouMeanHtml;
+ return $out;
}
/**