}
# 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 ) ) {
$wgOut->redirect( $t->getFullURL() );
return;
$wgOut->addHTML( $this->formHeader($term, 0, 0));
if( $this->searchAdvanced ) {
$wgOut->addHTML( $this->powerSearchBox( $term ) );
- }
+ }
$wgOut->addHTML( '</form>' );
// Empty query -- straight view of search form
wfProfileOut( __METHOD__ );
$textMatchesNum = $textMatches ? $textMatches->numRows() : 0;
// Total initial query matches (possible false positives)
$num = $titleMatchesNum + $textMatchesNum;
-
+
// Get total actual results (after second filtering, if any)
$numTitleMatches = $titleMatches && !is_null( $titleMatches->getTotalHits() ) ?
$titleMatches->getTotalHits() : $titleMatchesNum;
$totalRes += $titleMatches->getTotalHits();
if($textMatches && !is_null( $textMatches->getTotalHits() ))
$totalRes += $textMatches->getTotalHits();
-
+
// show number of results and current offset
$wgOut->addHTML( $this->formHeader($term, $num, $totalRes));
if( $this->searchAdvanced ) {
$wgOut->addHTML( $this->powerSearchBox( $term ) );
}
-
+
$wgOut->addHtml( Xml::closeElement( 'form' ) );
$wgOut->addHtml( "<div class='searchresults'>" );
wfRunHooks( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) );
} else {
wfRunHooks( 'SpecialSearchNoResults', array( $term ) );
- }
+ }
$wgOut->parserOptions()->setEditSection( false );
if( $titleMatches ) {
}
wfProfileOut( __METHOD__ );
}
-
+
protected function showCreateLink( $t ) {
global $wgOut;
-
+
// show direct page/create link if applicable
$messageName = null;
if( !is_null($t) ) {
} else {
$messageName = 'searchmenu-new-nocreate';
}
- }
+ }
if( $messageName ) {
$wgOut->wrapWikiMsg( "<p class=\"mw-search-createlink\">\n$1</p>", array( $messageName, wfEscapeWikiText( $t->getPrefixedText() ) ) );
} else {
$this->active = 'advanced';
} else {
$profiles = $this->getSearchProfiles();
-
+
foreach( $profiles as $key => $data ) {
if ( $this->namespaces == $data['namespaces'] && $key != 'advanced')
$this->active = $key;
}
-
+
}
# Should advanced UI be used?
$this->searchAdvanced = ($this->active === 'advanced');
if( $titleSnippet == '' )
$titleSnippet = null;
-
+
$link_t = clone $t;
-
+
wfRunHooks( 'ShowSearchHitTitle',
array( &$link_t, &$titleSnippet, $result, $terms, $this ) );
}
$rows = array_values( $rows );
$numRows = count( $rows );
-
+
// Lays out namespaces in multiple floating two-column tables so they'll
// be arranged nicely while still accommodating different screen widths
$namespaceTables = '';
Html::hidden( 'fulltext', 'Advanced search' ) .
Xml::closeElement( 'fieldset' );
}
-
+
protected function getSearchProfiles() {
// Builds list of Search Types (profiles)
$nsAllSet = array_keys( SearchEngine::searchableNamespaces() );
-
+
$profiles = array(
'default' => array(
'message' => 'searchprofile-articles',
'parameters' => array( 'advanced' => 1 ),
)
);
-
+
wfRunHooks( 'SpecialSearchProfiles', array( &$profiles ) );
foreach( $profiles as &$data ) {
sort($data['namespaces']);
}
-
+
return $profiles;
}
protected function formHeader( $term, $resultsShown, $totalNum ) {
global $wgLang;
-
+
$out = Xml::openElement('div', array( 'class' => 'mw-search-formheader' ) );
-
+
$bareterm = $term;
if( $this->startsWithImage( $term ) ) {
// Deletes prefixes
}
$profiles = $this->getSearchProfiles();
-
+
// Outputs XML for Search Types
$out .= Xml::openElement( 'div', array( 'class' => 'search-types' ) );
$out .= Xml::openElement( 'ul' );
$profile['namespaces'],
wfMsg( $profile['message'] ),
wfMsg( $profile['tooltip'], $tooltipParam ),
- isset( $profile['parameters'] ) ? $profile['parameters'] : array()
+ isset( $profile['parameters'] ) ? $profile['parameters'] : array()
)
);
}
Xml::tags( 'ul', null, Xml::tags( 'li', null, $top ) )
);
}
-
+
$out .= Xml::element( 'div', array( 'style' => 'clear:both' ), '', false );
$out .= Xml::closeElement('div');
-
+
// Adds hidden namespace fields
if ( !$this->searchAdvanced ) {
foreach( $this->namespaces as $ns ) {
$out .= Html::hidden( "ns{$ns}", '1' );
}
}
-
+
return $out;
}
) ) . "\n";
$out .= Html::hidden( 'fulltext', 'Search' ) . "\n";
$out .= Xml::submitButton( wfMsg( 'searchbutton' ) ) . "\n";
- return $out . $this->didYouMeanHtml;
+ return $out . $this->didYouMeanHtml;
}
/**
'a',
array(
'href' => $st->getLocalURL( $stParams ),
- 'title' => $tooltip,
+ 'title' => $tooltip,
'onmousedown' => 'mwSearchHeaderClick(this);',
'onkeydown' => 'mwSearchHeaderClick(this);'),
$label
}
return false;
}
-
+
/**
* Check if query starts with all: prefix
*
protected function startsWithAll( $term ) {
$allkeyword = wfMsgForContent('searchall');
-
+
$p = explode( ':', $term );
if( count( $p ) > 1 ) {
return $p[0] == $allkeyword;
return false;
}
}
-