2 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
3 # http://www.mediawiki.org/
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # http://www.gnu.org/copyleft/gpl.html
21 * Run text & title search and display the output
23 * @ingroup SpecialPage
29 * @param $par String: (default '')
31 function wfSpecialSearch( $par = '' ) {
32 global $wgRequest, $wgUser;
34 // Strip underscores from title parameter; most of the time we'll want
35 // text form here. But don't strip underscores from actual text params!
36 $titleParam = str_replace( '_', ' ', $par );
38 $search = str_replace( "\n", " ", $wgRequest->getText( 'search', $titleParam ) );
39 $searchPage = new SpecialSearch( $wgRequest, $wgUser );
40 if( $wgRequest->getVal( 'fulltext' )
41 ||
!is_null( $wgRequest->getVal( 'offset' ))
42 ||
!is_null( $wgRequest->getVal( 'searchx' )) )
44 $searchPage->showResults( $search, 'search' );
46 $searchPage->goResult( $search );
51 * implements Special:Search - Run text & title search and display the output
52 * @ingroup SpecialPage
57 * Set up basic search parameters from the request and user settings.
58 * Typically you'll pass $wgRequest and $wgUser.
60 * @param WebRequest $request
64 function SpecialSearch( &$request, &$user ) {
65 list( $this->limit
, $this->offset
) = $request->getLimitOffset( 20, 'searchlimit' );
67 $this->namespaces
= $this->powerSearch( $request );
68 if( empty( $this->namespaces
) ) {
69 $this->namespaces
= SearchEngine
::userNamespaces( $user );
72 $this->searchRedirects
= $request->getcheck( 'redirs' ) ?
true : false;
73 $this->searchAdvanced
= $request->getVal('advanced');
77 * If an exact title match can be found, jump straight ahead to it.
81 function goResult( $term ) {
82 global $wgOut, $wgGoToEdit;
84 $this->setupPage( $term );
86 # Try to go to page as entered.
87 $t = Title
::newFromText( $term );
89 # If the string cannot be used to create a title
91 return $this->showResults( $term );
94 # If there's an exact or very near match, jump right there.
95 $t = SearchEngine
::getNearMatch( $term );
96 if( !is_null( $t ) ) {
97 $wgOut->redirect( $t->getFullURL() );
101 # No match, generate an edit URL
102 $t = Title
::newFromText( $term );
103 if( ! is_null( $t ) ) {
104 wfRunHooks( 'SpecialSearchNogomatch', array( &$t ) );
105 # If the feature is enabled, go straight to the edit page
107 $wgOut->redirect( $t->getFullURL( 'action=edit' ) );
112 return $this->showResults( $term );
116 * @param string $term
119 function showResults( $term ) {
120 $fname = 'SpecialSearch::showResults';
121 wfProfileIn( $fname );
122 global $wgOut, $wgUser;
123 $sk = $wgUser->getSkin();
125 $this->setupPage( $term );
126 $this->searchEngine
= SearchEngine
::create();
128 $t = Title
::newFromText( $term );
131 Xml
::openElement( 'table', array( 'border'=>0, 'cellpadding'=>0, 'cellspacing'=>0 ) ) .
132 Xml
::openElement( 'tr' ) .
133 Xml
::openElement( 'td' ) . "\n"
135 if( $this->searchAdvanced
) {
136 $wgOut->addHTML( $this->powerSearchBox( $term ) );
139 $wgOut->addHTML( $this->shortDialog( $term ) );
143 Xml
::closeElement('td') .
144 Xml
::closeElement('tr') .
145 Xml
::closeElement('table')
148 if( '' === trim( $term ) ) {
149 // Empty query -- straight view of search form
150 wfProfileOut( $fname );
154 global $wgDisableTextSearch;
155 if( $wgDisableTextSearch ) {
156 global $wgSearchForwardUrl;
157 if( $wgSearchForwardUrl ) {
158 $url = str_replace( '$1', urlencode( $term ), $wgSearchForwardUrl );
159 $wgOut->redirect( $url );
162 global $wgInputEncoding;
164 Xml
::openElement( 'fieldset' ) .
165 Xml
::element( 'legend', null, wfMsg( 'search-external' ) ) .
166 Xml
::element( 'p', array( 'class' => 'mw-searchdisabled' ), wfMsg( 'searchdisabled' ) ) .
167 wfMsg( 'googlesearch',
168 htmlspecialchars( $term ),
169 htmlspecialchars( $wgInputEncoding ),
170 htmlspecialchars( wfMsg( 'searchbutton' ) )
172 Xml
::closeElement( 'fieldset' )
174 wfProfileOut( $fname );
178 $search =& $this->searchEngine
;
179 $search->setLimitOffset( $this->limit
, $this->offset
);
180 $search->setNamespaces( $this->namespaces
);
181 $search->showRedirects
= $this->searchRedirects
;
182 $rewritten = $search->replacePrefixes($term);
184 $titleMatches = $search->searchTitle( $rewritten );
186 // Sometimes the search engine knows there are too many hits
187 if( $titleMatches instanceof SearchResultTooMany
) {
188 $wgOut->addWikiText( '==' . wfMsg( 'toomanymatches' ) . "==\n" );
189 wfProfileOut( $fname );
193 $textMatches = $search->searchText( $rewritten );
195 // did you mean... suggestions
196 if( $textMatches && $textMatches->hasSuggestion() ) {
197 $st = SpecialPage
::getTitleFor( 'Search' );
198 $stParams = wfArrayToCGI(
199 array( 'search' => $textMatches->getSuggestionQuery(), 'fulltext' => wfMsg('search') ),
200 $this->powerSearchOptions()
202 $suggestLink = '<a href="'.$st->escapeLocalURL($stParams).'">'.
203 $textMatches->getSuggestionSnippet().'</a>';
205 $wgOut->addHTML('<div class="searchdidyoumean">'.wfMsg('search-suggest',$suggestLink).'</div>');
208 // show direct page/create link
210 if( !$t->exists() ) {
211 $wgOut->addWikiMsg( 'searchmenu-new', wfEscapeWikiText( $t->getPrefixedText() ) );
213 $wgOut->addWikiMsg( 'searchmenu-exists', wfEscapeWikiText( $t->getPrefixedText() ) );
217 // show number of results
218 $numTitleMatches = $titleMatches ?
$titleMatches->numRows() : 0;
219 $numTextMatches = $textMatches ?
$textMatches->numRows() : 0;
220 $highestNum = max( $numTitleMatches, $numTextMatches );
221 // Total query matches (possible false positives)
222 $num = $numTitleMatches +
$numTextMatches;
223 // Get total actual results
225 if( $titleMatches && !is_null($titleMatches->getTotalHits()) )
226 $totalNum +
= $titleMatches->getTotalHits();
227 if( $textMatches && !is_null($textMatches->getTotalHits()) )
228 $totalNum +
= $textMatches->getTotalHits();
230 if( $totalNum > 0 ) {
231 $top = wfMsgExt('showingresultstotal', array( 'parseinline' ),
232 $this->offset+
1, $this->offset+
$num, $totalNum, $num );
233 } elseif( $num >= $this->limit
) {
234 $top = wfShowingResults( $this->offset
, $this->limit
);
236 $top = wfShowingResultsNum( $this->offset
, $this->limit
, $num );
238 $wgOut->addHTML( "<p class='mw-search-numberresults'>{$top}</p>\n" );
242 if( $num ||
$this->offset
) {
243 $prevnext = wfViewPrevNext( $this->offset
, $this->limit
,
244 SpecialPage
::getTitleFor( 'Search' ),
245 wfArrayToCGI( $this->powerSearchOptions(), array( 'search' => $term ) ),
246 ($highestNum < $this->limit
)
248 $wgOut->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" );
249 wfRunHooks( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) );
251 wfRunHooks( 'SpecialSearchNoResults', array( $term ) );
254 $wgOut->addHtml( "<div class='searchresults'>" );
256 if( $titleMatches ) {
257 if( $titleMatches->numRows() ) {
258 $wgOut->wrapWikiMsg( "==$1==\n", 'titlematches' );
259 $wgOut->addHTML( $this->showMatches( $titleMatches ) );
261 $titleMatches->free();
265 // output appropriate heading
266 if( $textMatches->numRows() ) {
268 $wgOut->wrapWikiMsg( "==$1==\n", 'textmatches' );
269 else // if no title matches the heading is redundant
270 $wgOut->addHTML("<hr/>");
271 } elseif( $num == 0 ) {
272 # Don't show the 'no text matches' if we received title matches
273 $wgOut->wrapWikiMsg( "==$1==\n", 'notextmatches' );
275 // show interwiki results if any
276 if( $textMatches->hasInterwikiResults() )
277 $wgOut->addHTML( $this->showInterwiki( $textMatches->getInterwikiResults(), $term ));
279 if( $textMatches->numRows() )
280 $wgOut->addHTML( $this->showMatches( $textMatches ) );
282 $textMatches->free();
286 $wgOut->addWikiMsg( 'search-nonefound' );
289 $wgOut->addHtml( "</div>" );
291 if( $num ||
$this->offset
) {
292 $wgOut->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
294 wfProfileOut( $fname );
300 protected function setupPage( $term ) {
302 if( !empty( $term ) ) {
303 $wgOut->setPageTitle( wfMsg( 'searchresults') );
304 $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'searchresults-title', $term) ) );
306 $wgOut->setArticleRelated( false );
307 $wgOut->setRobotPolicy( 'noindex,nofollow' );
311 * Extract "power search" namespace settings from the request object,
312 * returning a list of index numbers to search.
314 * @param WebRequest $request
317 protected function powerSearch( &$request ) {
319 foreach( SearchEngine
::searchableNamespaces() as $ns => $name ) {
320 if( $request->getCheck( 'ns' . $ns ) ) {
328 * Reconstruct the 'power search' options for links
331 protected function powerSearchOptions() {
333 foreach( $this->namespaces
as $n ) {
336 $opt['redirs'] = $this->searchRedirects ?
1 : 0;
337 if( $this->searchAdvanced
)
338 $opt['advanced'] = $this->searchAdvanced
;
343 * Show whole set of results
345 * @param SearchResultSet $matches
347 protected function showMatches( &$matches ) {
349 $fname = 'SpecialSearch::showMatches';
350 wfProfileIn( $fname );
352 $terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
356 $infoLine = $matches->getInfo();
357 if( !is_null($infoLine) )
358 $out .= "\n<!-- {$infoLine} -->\n";
361 $off = $this->offset +
1;
362 $out .= "<ul class='mw-search-results'>\n";
363 while( $result = $matches->next() ) {
364 $out .= $this->showHit( $result, $terms );
368 // convert the whole thing to desired language variant
369 $out = $wgContLang->convert( $out );
370 wfProfileOut( $fname );
375 * Format a single hit result
376 * @param SearchResult $result
377 * @param array $terms terms to highlight
379 protected function showHit( $result, $terms ) {
380 $fname = 'SpecialSearch::showHit';
381 wfProfileIn( $fname );
382 global $wgUser, $wgContLang, $wgLang;
384 if( $result->isBrokenTitle() ) {
385 wfProfileOut( $fname );
386 return "<!-- Broken link in search result -->\n";
389 $t = $result->getTitle();
390 $sk = $wgUser->getSkin();
392 $link = $sk->makeKnownLinkObj( $t, $result->getTitleSnippet($terms));
394 //If page content is not readable, just return the title.
395 //This is not quite safe, but better than showing excerpts from non-readable pages
396 //Note that hiding the entry entirely would screw up paging.
397 if(!$t->userCanRead()) {
398 wfProfileOut( $fname );
399 return "<li>{$link}</li>\n";
402 // If the page doesn't *exist*... our search index is out of date.
403 // The least confusing at this point is to drop the result.
404 // You may get less results, but... oh well. :P
405 if( $result->isMissingRevision() ) {
406 wfProfileOut( $fname );
407 return "<!-- missing page " .
408 htmlspecialchars( $t->getPrefixedText() ) . "-->\n";
411 // format redirects / relevant sections
412 $redirectTitle = $result->getRedirectTitle();
413 $redirectText = $result->getRedirectSnippet($terms);
414 $sectionTitle = $result->getSectionTitle();
415 $sectionText = $result->getSectionSnippet($terms);
417 if( !is_null($redirectTitle) )
418 $redirect = "<span class='searchalttitle'>"
419 .wfMsg('search-redirect',$sk->makeKnownLinkObj( $redirectTitle, $redirectText))
422 if( !is_null($sectionTitle) )
423 $section = "<span class='searchalttitle'>"
424 .wfMsg('search-section', $sk->makeKnownLinkObj( $sectionTitle, $sectionText))
427 // format text extract
428 $extract = "<div class='searchresult'>".$result->getTextSnippet($terms)."</div>";
431 if( is_null( $result->getScore() ) ) {
432 // Search engine doesn't report scoring info
435 $percent = sprintf( '%2.1f', $result->getScore() * 100 );
436 $score = wfMsg( 'search-result-score', $wgLang->formatNum( $percent ) )
440 // format description
441 $byteSize = $result->getByteSize();
442 $wordCount = $result->getWordCount();
443 $timestamp = $result->getTimestamp();
444 $size = wfMsgExt( 'search-result-size', array( 'parsemag', 'escape' ),
445 $sk->formatSize( $byteSize ),
447 $date = $wgLang->timeanddate( $timestamp );
449 // link to related articles if supported
451 if( $result->hasRelated() ) {
452 $st = SpecialPage
::getTitleFor( 'Search' );
453 $stParams = wfArrayToCGI( $this->powerSearchOptions(),
454 array('search' => wfMsgForContent('searchrelated').':'.$t->getPrefixedText(),
455 'fulltext' => wfMsg('search') ));
457 $related = ' -- <a href="'.$st->escapeLocalURL($stParams).'">'.
458 wfMsg('search-relatedarticle').'</a>';
461 // Include a thumbnail for media files...
462 if( $t->getNamespace() == NS_IMAGE
) {
463 $img = wfFindFile( $t );
465 $thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) );
467 $desc = $img->getShortDesc();
468 wfProfileOut( $fname );
469 // Float doesn't seem to interact well with the bullets.
470 // Table messes up vertical alignment of the bullets.
471 // Bullets are therefore disabled (didn't look great anyway).
473 '<table class="searchResultImage">' .
475 '<td width="120" align="center">' .
476 $thumb->toHtml( array( 'desc-link' => true ) ) .
478 '<td valign="top">' .
481 "<div class='mw-search-result-data'>{$score}{$desc} - {$date}{$related}</div>" .
490 wfProfileOut( $fname );
491 return "<li>{$link} {$redirect} {$section} {$extract}\n" .
492 "<div class='mw-search-result-data'>{$score}{$size} - {$date}{$related}</div>" .
498 * Show results from other wikis
500 * @param SearchResultSet $matches
502 protected function showInterwiki( &$matches, $query ) {
503 $fname = 'SpecialSearch::showInterwiki';
504 wfProfileIn( $fname );
507 $terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
509 $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>".
510 wfMsg('search-interwiki-caption')."</div>\n";
511 $off = $this->offset +
1;
512 $out .= "<ul start='{$off}' class='mw-search-iwresults'>\n";
514 // work out custom project captions
515 $customCaptions = array();
516 $customLines = explode("\n",wfMsg('search-interwiki-custom')); // format per line <iwprefix>:<caption>
517 foreach($customLines as $line) {
518 $parts = explode(":",$line,2);
519 if(count($parts) == 2) // validate line
520 $customCaptions[$parts[0]] = $parts[1];
525 while( $result = $matches->next() ) {
526 $out .= $this->showInterwikiHit( $result, $prev, $terms, $query, $customCaptions );
527 $prev = $result->getInterwikiPrefix();
529 // FIXME: should support paging in a non-confusing way (not sure how though, maybe via ajax)..
530 $out .= "</ul></div>\n";
532 // convert the whole thing to desired language variant
534 $out = $wgContLang->convert( $out );
535 wfProfileOut( $fname );
540 * Show single interwiki link
542 * @param SearchResult $result
543 * @param string $lastInterwiki
544 * @param array $terms
545 * @param string $query
546 * @param array $customCaptions iw prefix -> caption
548 protected function showInterwikiHit( $result, $lastInterwiki, $terms, $query, $customCaptions) {
549 $fname = 'SpecialSearch::showInterwikiHit';
550 wfProfileIn( $fname );
551 global $wgUser, $wgContLang, $wgLang;
553 if( $result->isBrokenTitle() ) {
554 wfProfileOut( $fname );
555 return "<!-- Broken link in search result -->\n";
558 $t = $result->getTitle();
559 $sk = $wgUser->getSkin();
561 $link = $sk->makeKnownLinkObj( $t, $result->getTitleSnippet($terms));
563 // format redirect if any
564 $redirectTitle = $result->getRedirectTitle();
565 $redirectText = $result->getRedirectSnippet($terms);
567 if( !is_null($redirectTitle) )
568 $redirect = "<span class='searchalttitle'>"
569 .wfMsg('search-redirect',$sk->makeKnownLinkObj( $redirectTitle, $redirectText))
573 // display project name
574 if(is_null($lastInterwiki) ||
$lastInterwiki != $t->getInterwiki()) {
575 if( key_exists($t->getInterwiki(),$customCaptions) )
576 // captions from 'search-interwiki-custom'
577 $caption = $customCaptions[$t->getInterwiki()];
579 // default is to show the hostname of the other wiki which might suck
580 // if there are many wikis on one hostname
581 $parsed = parse_url($t->getFullURL());
582 $caption = wfMsg('search-interwiki-default', $parsed['host']);
584 // "more results" link (special page stuff could be localized, but we might not know target lang)
585 $searchTitle = Title
::newFromText($t->getInterwiki().":Special:Search");
586 $searchLink = $sk->makeKnownLinkObj( $searchTitle, wfMsg('search-interwiki-more'),
587 wfArrayToCGI(array('search' => $query, 'fulltext' => 'Search')));
588 $out .= "</ul><div class='mw-search-interwiki-project'><span class='mw-search-interwiki-more'>
589 {$searchLink}</span>{$caption}</div>\n<ul>";
592 $out .= "<li>{$link} {$redirect}</li>\n";
593 wfProfileOut( $fname );
599 * Generates the power search box at bottom of [[Special:Search]]
600 * @param $term string: search term
601 * @return $out string: HTML form
603 protected function powerSearchBox( $term ) {
607 foreach( SearchEngine
::searchableNamespaces() as $ns => $name ) {
608 $name = str_replace( '_', ' ', $name );
610 $name = wfMsg( 'blanknamespace' );
612 $namespaces .= Xml
::openElement( 'span', array( 'style' => 'white-space: nowrap' ) ) .
613 Xml
::checkLabel( $name, "ns{$ns}", "mw-search-ns{$ns}", in_array( $ns, $this->namespaces
) ) .
614 Xml
::closeElement( 'span' ) . "\n";
617 if( $this->searchEngine
->acceptListRedirects() ) {
618 $redirect = Xml
::check( 'redirs', $this->searchRedirects
, array( 'value' => '1', 'id' => 'redirs' ) );
619 $redirectLabel = Xml
::label( wfMsg( 'powersearch-redir' ), 'redirs' );
624 $searchField = Xml
::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'powerSearchText' ) );
625 $searchButton = Xml
::submitButton( wfMsg( 'powersearch' ), array( 'name' => 'fulltext' ) ) . "\n";
626 $searchTitle = SpecialPage
::getTitleFor( 'Search' );
628 $out = Xml
::openElement( 'form', array( 'id' => 'powersearch', 'method' => 'get', 'action' => $wgScript ) ) .
629 Xml
::hidden( 'title', $searchTitle->getPrefixedText() ) .
630 Xml
::hidden( 'advanced', 1 ) .
632 wfMsgExt( 'powersearch-ns', array( 'parseinline' ) ) .
637 $redirect . " " . $redirectLabel .
639 wfMsgExt( 'powersearch-field', array( 'parseinline' ) ) .
644 ' (' . wfMsgExt('searchmenu-help',array('parseinline') ) . ')' .
646 $out .= wfMsgExt( 'searchmenu-prefix', array('parseinline'), $term );
648 return Xml
::openElement( 'fieldset', array('id' => 'mw-searchoptions','style' => 'margin:0em;') ) .
649 Xml
::element( 'legend', null, wfMsg('searchmenu-legend') ) .
650 $this->formHeader($term) . $out .
651 Xml
::closeElement( 'fieldset' );
654 protected function powerSearchFocus() {
655 global $wgJsMimeType;
656 return "<script type=\"$wgJsMimeType\">" .
657 "hookEvent(\"load\", function() {" .
658 "document.getElementById('powerSearchText').focus();" .
663 /** Make a search link with some target namespaces */
664 protected function makeSearchLink( $term, $namespaces, $label, $tooltip, $params=array() ) {
666 foreach( $namespaces as $n ) {
669 $opt['redirs'] = $this->searchRedirects ?
1 : 0;
671 $st = SpecialPage
::getTitleFor( 'Search' );
672 $stParams = wfArrayToCGI( array( 'search' => $term, 'fulltext' => wfMsg( 'search' ) ), $opt );
674 return Xml
::element( 'a',
675 array( 'href'=> $st->getLocalURL( $stParams ), 'title' => $tooltip ),
679 /** Check if query starts with image: prefix */
680 protected function startsWithImage( $term ) {
683 $p = explode( ':', $term );
684 if( count( $p ) > 1 ) {
685 return $wgContLang->getNsIndex( $p[0] ) == NS_IMAGE
;
690 protected function formHeader( $term ) {
691 global $wgContLang, $wgCanonicalNamespaceNames;
693 $sep = ' ';
694 $out = Xml
::openElement('div', array( 'style' => 'padding-bottom:0.5em;' ) );
697 if( $this->startsWithImage( $term ) )
698 $bareterm = substr( $term, strpos( $term, ':' ) +
1 ); // delete all/image prefix
700 $nsAllSet = array_keys( SearchEngine
::searchableNamespaces() );
701 // figure out the active search profile header
702 if( $this->searchAdvanced
)
703 $active = 'advanced';
704 else if( $this->namespaces
=== NS_IMAGE ||
$this->startsWithImage( $term ) )
706 elseif( $this->namespaces
=== $nsAllSet )
708 elseif( $this->namespaces
=== SearchEngine
::defaultNamespaces() )
710 elseif( $this->namespaces
=== SearchEngine
::defaultAndProjectNamespaces() )
711 $active = 'withproject';
712 elseif( $this->namespaces
=== SearchEngine
::projectNamespaces() )
715 $active = 'advanced';
718 // search profiles headers
719 $m = wfMsg( 'searchprofile-articles' );
720 $tt = wfMsg( 'searchprofile-articles-tooltip',
721 implode( ', ', SearchEngine
::namespacesAsText( SearchEngine
::defaultNamespaces() ) ) );
722 if( $active == 'default' ) {
723 $out .= Xml
::element( 'strong', array( 'title'=>$tt ), $m );
725 $out .= $this->makeSearchLink( $bareterm, SearchEngine
::defaultNamespaces(), $m, $tt );
729 $m = wfMsg( 'searchprofile-images' );
730 $tt = wfMsg( 'searchprofile-images-tooltip' );
731 if( $active == 'images' ) {
732 $out .= Xml
::element( 'strong', array( 'title'=>$tt ), $m );
734 $out .= $this->makeSearchLink( $wgContLang->getFormattedNsText(NS_IMAGE
).':'.$bareterm, array() , $m, $tt );
738 $m = wfMsg( 'searchprofile-articles-and-proj' );
739 $tt = wfMsg( 'searchprofile-project-tooltip',
740 implode( ', ', SearchEngine
::namespacesAsText( SearchEngine
::defaultAndProjectNamespaces() ) ) );
741 if( $active == 'withproject' ) {
742 $out .= Xml
::element( 'strong', array( 'title'=>$tt ), $m );
744 $out .= $this->makeSearchLink( $bareterm, SearchEngine
::defaultAndProjectNamespaces(), $m, $tt );
748 $m = wfMsg( 'searchprofile-project' );
749 $tt = wfMsg( 'searchprofile-project-tooltip',
750 implode( ', ', SearchEngine
::namespacesAsText( SearchEngine
::projectNamespaces() ) ) );
751 if( $active == 'project' ) {
752 $out .= Xml
::element( 'strong', array( 'title'=>$tt ), $m );
754 $out .= $this->makeSearchLink( $bareterm, SearchEngine
::projectNamespaces(), $m, $tt );
758 $m = wfMsg( 'searchprofile-everything' );
759 $tt = wfMsg( 'searchprofile-everything-tooltip' );
760 if( $active == 'all' ) {
761 $out .= Xml
::element( 'strong', array( 'title'=>$tt ), $m );
763 $out .= $this->makeSearchLink( $bareterm, $nsAllSet, $m, $tt );
767 $m = wfMsg( 'searchprofile-advanced' );
768 $tt = wfMsg( 'searchprofile-advanced-tooltip' );
769 if( $active == 'advanced' ) {
770 $out .= Xml
::element( 'strong', array( 'title'=>$tt ), $m );
772 $out .= $this->makeSearchLink( $bareterm, $this->namespaces
, $m, $tt, array( 'advanced' => '1' ) );
774 $out .= Xml
::closeElement('div') ;
779 protected function shortDialog( $term ) {
781 $out = Xml
::openElement( 'form', array( 'id' => 'search', 'method' => 'get', 'action' => $wgScript ) );
782 $searchTitle = SpecialPage
::getTitleFor( 'Search' );
783 $out .= Xml
::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n";
784 $out .= Xml
::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'searchText' ) ) . "\n";
785 foreach( SearchEngine
::searchableNamespaces() as $ns => $name ) {
786 if( in_array( $ns, $this->namespaces
) ) {
787 $out .= Xml
::hidden( "ns{$ns}", '1' );
790 $out .= Xml
::submitButton( wfMsg( 'searchbutton' ), array( 'name' => 'fulltext' ) );
791 $out .= ' (' . wfMsgExt('searchmenu-help',array('parseinline') ) . ')';
792 $out .= Xml
::closeElement( 'form' );
793 $out .= wfMsgExt( 'searchmenu-prefix', array('parseinline'), $term );
794 return Xml
::openElement( 'fieldset', array('id' => 'mw-searchoptions','style' => 'margin:0em;') ) .
795 Xml
::element( 'legend', null, wfMsg('searchmenu-legend') ) .
796 $this->formHeader($term) . $out .
797 Xml
::closeElement( 'fieldset' );