Set values from query params (bug 12750)
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
1 <?php
2 # Copyright (C) 2004 Brion Vibber <brion@pobox.com>
3 # http://www.mediawiki.org/
4 #
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.
9 #
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.
14 #
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
19
20 /**
21 * Run text & title search and display the output
22 * @file
23 * @ingroup SpecialPage
24 */
25
26 /**
27 * Entry point
28 *
29 * @param $par String: (default '')
30 */
31 function wfSpecialSearch( $par = '' ) {
32 global $wgRequest, $wgUser;
33
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 );
37
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' ))) {
43 $searchPage->showResults( $search, 'search' );
44 } else {
45 $searchPage->goResult( $search );
46 }
47 }
48
49 /**
50 * implements Special:Search - Run text & title search and display the output
51 * @ingroup SpecialPage
52 */
53 class SpecialSearch {
54
55 /**
56 * Set up basic search parameters from the request and user settings.
57 * Typically you'll pass $wgRequest and $wgUser.
58 *
59 * @param WebRequest $request
60 * @param User $user
61 * @public
62 */
63 function SpecialSearch( &$request, &$user ) {
64 list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, 'searchlimit' );
65
66 $this->namespaces = $this->powerSearch( $request );
67 if( empty( $this->namespaces ) ) {
68 $this->namespaces = SearchEngine::userNamespaces( $user );
69 }
70
71 $this->searchRedirects = $request->getcheck( 'redirs' ) ? true : false;
72 }
73
74 /**
75 * If an exact title match can be found, jump straight ahead to it.
76 * @param string $term
77 * @public
78 */
79 function goResult( $term ) {
80 global $wgOut;
81 global $wgGoToEdit;
82
83 $this->setupPage( $term );
84
85 # Try to go to page as entered.
86 $t = Title::newFromText( $term );
87
88 # If the string cannot be used to create a title
89 if( is_null( $t ) ){
90 return $this->showResults( $term );
91 }
92
93 # If there's an exact or very near match, jump right there.
94 $t = SearchEngine::getNearMatch( $term );
95 if( !is_null( $t ) ) {
96 $wgOut->redirect( $t->getFullURL() );
97 return;
98 }
99
100 # No match, generate an edit URL
101 $t = Title::newFromText( $term );
102 if( ! is_null( $t ) ) {
103 wfRunHooks( 'SpecialSearchNogomatch', array( &$t ) );
104 # If the feature is enabled, go straight to the edit page
105 if ( $wgGoToEdit ) {
106 $wgOut->redirect( $t->getFullURL( 'action=edit' ) );
107 return;
108 }
109 }
110
111 $wgOut->wrapWikiMsg( "==$1==\n", 'notitlematches' );
112 if( $t->quickUserCan( 'create' ) && $t->quickUserCan( 'edit' ) ) {
113 $wgOut->addWikiMsg( 'noexactmatch', wfEscapeWikiText( $term ) );
114 } else {
115 $wgOut->addWikiMsg( 'noexactmatch-nocreate', wfEscapeWikiText( $term ) );
116 }
117
118 return $this->showResults( $term );
119 }
120
121 /**
122 * @param string $term
123 * @public
124 */
125 function showResults( $term ) {
126 $fname = 'SpecialSearch::showResults';
127 wfProfileIn( $fname );
128 global $wgOut, $wgUser;
129 $sk = $wgUser->getSkin();
130
131 $this->setupPage( $term );
132
133 $wgOut->addWikiMsg( 'searchresulttext' );
134
135 if( '' === trim( $term ) ) {
136 // Empty query -- straight view of search form
137 $wgOut->setSubtitle( '' );
138 $wgOut->addHTML( $this->powerSearchBox( $term ) );
139 $wgOut->addHTML( $this->powerSearchFocus() );
140 wfProfileOut( $fname );
141 return;
142 }
143
144 global $wgDisableTextSearch;
145 if ( $wgDisableTextSearch ) {
146 global $wgSearchForwardUrl;
147 if( $wgSearchForwardUrl ) {
148 $url = str_replace( '$1', urlencode( $term ), $wgSearchForwardUrl );
149 $wgOut->redirect( $url );
150 return;
151 }
152 global $wgInputEncoding;
153 $wgOut->addHTML(
154 Xml::openElement( 'fieldset' ) .
155 Xml::element( 'legend', null, wfMsg( 'search-external' ) ) .
156 Xml::element( 'p', array( 'class' => 'mw-searchdisabled' ), wfMsg( 'searchdisabled' ) ) .
157 wfMsg( 'googlesearch',
158 htmlspecialchars( $term ),
159 htmlspecialchars( $wgInputEncoding ),
160 htmlspecialchars( wfMsg( 'searchbutton' ) )
161 ) .
162 Xml::closeElement( 'fieldset' )
163 );
164 wfProfileOut( $fname );
165 return;
166 }
167
168 $wgOut->addHTML( $this->shortDialog( $term ) );
169
170 $search = SearchEngine::create();
171 $search->setLimitOffset( $this->limit, $this->offset );
172 $search->setNamespaces( $this->namespaces );
173 $search->showRedirects = $this->searchRedirects;
174 $rewritten = $search->replacePrefixes($term);
175
176 $titleMatches = $search->searchTitle( $rewritten );
177
178 // Sometimes the search engine knows there are too many hits
179 if ($titleMatches instanceof SearchResultTooMany) {
180 $wgOut->addWikiText( '==' . wfMsg( 'toomanymatches' ) . "==\n" );
181 $wgOut->addHTML( $this->powerSearchBox( $term ) );
182 $wgOut->addHTML( $this->powerSearchFocus() );
183 wfProfileOut( $fname );
184 return;
185 }
186
187 $textMatches = $search->searchText( $rewritten );
188
189 // did you mean... suggestions
190 if($textMatches && $textMatches->hasSuggestion()){
191 $st = SpecialPage::getTitleFor( 'Search' );
192 $stParams = wfArrayToCGI( array(
193 'search' => $textMatches->getSuggestionQuery(),
194 'fulltext' => wfMsg('search')),
195 $this->powerSearchOptions());
196
197 $suggestLink = '<a href="'.$st->escapeLocalURL($stParams).'">'.
198 $textMatches->getSuggestionSnippet().'</a>';
199
200 $wgOut->addHTML('<div class="searchdidyoumean">'.wfMsg('search-suggest',$suggestLink).'</div>');
201 }
202
203 // show number of results
204 $num = ( $titleMatches ? $titleMatches->numRows() : 0 )
205 + ( $textMatches ? $textMatches->numRows() : 0);
206 $totalNum = 0;
207 if($titleMatches && !is_null($titleMatches->getTotalHits()))
208 $totalNum += $titleMatches->getTotalHits();
209 if($textMatches && !is_null($textMatches->getTotalHits()))
210 $totalNum += $textMatches->getTotalHits();
211 if ( $num > 0 ) {
212 if ( $totalNum > 0 ){
213 $top = wfMsgExt('showingresultstotal', array( 'parseinline' ),
214 $this->offset+1, $this->offset+$num, $totalNum, $num );
215 } elseif ( $num >= $this->limit ) {
216 $top = wfShowingResults( $this->offset, $this->limit );
217 } else {
218 $top = wfShowingResultsNum( $this->offset, $this->limit, $num );
219 }
220 $wgOut->addHTML( "<p class='mw-search-numberresults'>{$top}</p>\n" );
221 }
222
223 // prev/next links
224 if( $num || $this->offset ) {
225 $prevnext = wfViewPrevNext( $this->offset, $this->limit,
226 SpecialPage::getTitleFor( 'Search' ),
227 wfArrayToCGI(
228 $this->powerSearchOptions(),
229 array( 'search' => $term ) ),
230 ($num < $this->limit) );
231 $wgOut->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" );
232 wfRunHooks( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) );
233 } else {
234 wfRunHooks( 'SpecialSearchNoResults', array( $term ) );
235 }
236
237 if( $titleMatches ) {
238 if( $titleMatches->numRows() ) {
239 $wgOut->wrapWikiMsg( "==$1==\n", 'titlematches' );
240 $wgOut->addHTML( $this->showMatches( $titleMatches ) );
241 }
242 $titleMatches->free();
243 }
244
245 if( $textMatches ) {
246 // output appropriate heading
247 if( $textMatches->numRows() ) {
248 if($titleMatches)
249 $wgOut->wrapWikiMsg( "==$1==\n", 'textmatches' );
250 else // if no title matches the heading is redundant
251 $wgOut->addHTML("<hr/>");
252 } elseif( $num == 0 ) {
253 # Don't show the 'no text matches' if we received title matches
254 $wgOut->wrapWikiMsg( "==$1==\n", 'notextmatches' );
255 }
256 // show interwiki results if any
257 if( $textMatches->hasInterwikiResults() )
258 $wgOut->addHtml( $this->showInterwiki( $textMatches->getInterwikiResults(), $term ));
259 // show results
260 if( $textMatches->numRows() )
261 $wgOut->addHTML( $this->showMatches( $textMatches ) );
262
263 $textMatches->free();
264 }
265
266 if ( $num == 0 ) {
267 $wgOut->addWikiMsg( 'nonefound' );
268 }
269 if( $num || $this->offset ) {
270 $wgOut->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
271 }
272 $wgOut->addHTML( $this->powerSearchBox( $term ) );
273 wfProfileOut( $fname );
274 }
275
276 #------------------------------------------------------------------
277 # Private methods below this line
278
279 /**
280 *
281 */
282 function setupPage( $term ) {
283 global $wgOut;
284 if( !empty( $term ) ){
285 $wgOut->setPageTitle( wfMsg( 'searchresults') );
286 $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'searchresults-title', $term) ) );
287 }
288 $subtitlemsg = ( Title::newFromText( $term ) ? 'searchsubtitle' : 'searchsubtitleinvalid' );
289 $wgOut->setSubtitle( $wgOut->parse( wfMsg( $subtitlemsg, wfEscapeWikiText($term) ) ) );
290 $wgOut->setArticleRelated( false );
291 $wgOut->setRobotPolicy( 'noindex,nofollow' );
292 }
293
294 /**
295 * Extract "power search" namespace settings from the request object,
296 * returning a list of index numbers to search.
297 *
298 * @param WebRequest $request
299 * @return array
300 * @private
301 */
302 function powerSearch( &$request ) {
303 $arr = array();
304 foreach( SearchEngine::searchableNamespaces() as $ns => $name ) {
305 if( $request->getCheck( 'ns' . $ns ) ) {
306 $arr[] = $ns;
307 }
308 }
309 return $arr;
310 }
311
312 /**
313 * Reconstruct the 'power search' options for links
314 * @return array
315 * @private
316 */
317 function powerSearchOptions() {
318 $opt = array();
319 foreach( $this->namespaces as $n ) {
320 $opt['ns' . $n] = 1;
321 }
322 $opt['redirs'] = $this->searchRedirects ? 1 : 0;
323 return $opt;
324 }
325
326 /**
327 * Show whole set of results
328 *
329 * @param SearchResultSet $matches
330 */
331 function showMatches( &$matches ) {
332 $fname = 'SpecialSearch::showMatches';
333 wfProfileIn( $fname );
334
335 global $wgContLang;
336 $terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
337
338 $out = "";
339
340 $infoLine = $matches->getInfo();
341 if( !is_null($infoLine) )
342 $out .= "\n<!-- {$infoLine} -->\n";
343
344
345 $off = $this->offset + 1;
346 $out .= "<ul class='mw-search-results'>\n";
347
348 while( $result = $matches->next() ) {
349 $out .= $this->showHit( $result, $terms );
350 }
351 $out .= "</ul>\n";
352
353 // convert the whole thing to desired language variant
354 global $wgContLang;
355 $out = $wgContLang->convert( $out );
356 wfProfileOut( $fname );
357 return $out;
358 }
359
360 /**
361 * Format a single hit result
362 * @param SearchResult $result
363 * @param array $terms terms to highlight
364 */
365 function showHit( $result, $terms ) {
366 $fname = 'SpecialSearch::showHit';
367 wfProfileIn( $fname );
368 global $wgUser, $wgContLang, $wgLang;
369
370 if( $result->isBrokenTitle() ) {
371 wfProfileOut( $fname );
372 return "<!-- Broken link in search result -->\n";
373 }
374
375 $t = $result->getTitle();
376 $sk = $wgUser->getSkin();
377
378 $link = $sk->makeKnownLinkObj( $t, $result->getTitleSnippet($terms));
379
380 //If page content is not readable, just return the title.
381 //This is not quite safe, but better than showing excerpts from non-readable pages
382 //Note that hiding the entry entirely would screw up paging.
383 if (!$t->userCanRead()) {
384 wfProfileOut( $fname );
385 return "<li>{$link}</li>\n";
386 }
387
388 // If the page doesn't *exist*... our search index is out of date.
389 // The least confusing at this point is to drop the result.
390 // You may get less results, but... oh well. :P
391 if( $result->isMissingRevision() ) {
392 wfProfileOut( $fname );
393 return "<!-- missing page " .
394 htmlspecialchars( $t->getPrefixedText() ) . "-->\n";
395 }
396
397 // format redirects / relevant sections
398 $redirectTitle = $result->getRedirectTitle();
399 $redirectText = $result->getRedirectSnippet($terms);
400 $sectionTitle = $result->getSectionTitle();
401 $sectionText = $result->getSectionSnippet($terms);
402 $redirect = '';
403 if( !is_null($redirectTitle) )
404 $redirect = "<span class='searchalttitle'>"
405 .wfMsg('search-redirect',$sk->makeKnownLinkObj( $redirectTitle, $redirectText))
406 ."</span>";
407 $section = '';
408 if( !is_null($sectionTitle) )
409 $section = "<span class='searchalttitle'>"
410 .wfMsg('search-section', $sk->makeKnownLinkObj( $sectionTitle, $sectionText))
411 ."</span>";
412
413 // format text extract
414 $extract = "<div class='searchresult'>".$result->getTextSnippet($terms)."</div>";
415
416 // format score
417 if( is_null( $result->getScore() ) ) {
418 // Search engine doesn't report scoring info
419 $score = '';
420 } else {
421 $percent = sprintf( '%2.1f', $result->getScore() * 100 );
422 $score = wfMsg( 'search-result-score', $wgLang->formatNum( $percent ) )
423 . ' - ';
424 }
425
426 // format description
427 $byteSize = $result->getByteSize();
428 $wordCount = $result->getWordCount();
429 $timestamp = $result->getTimestamp();
430 $size = wfMsgExt( 'search-result-size', array( 'parsemag', 'escape' ),
431 $sk->formatSize( $byteSize ),
432 $wordCount );
433 $date = $wgLang->timeanddate( $timestamp );
434
435 // link to related articles if supported
436 $related = '';
437 if( $result->hasRelated() ){
438 $st = SpecialPage::getTitleFor( 'Search' );
439 $stParams = wfArrayToCGI( $this->powerSearchOptions(),
440 array('search' => wfMsgForContent('searchrelated').':'.$t->getPrefixedText(),
441 'fulltext' => wfMsg('search') ));
442
443 $related = ' -- <a href="'.$st->escapeLocalURL($stParams).'">'.
444 wfMsg('search-relatedarticle').'</a>';
445 }
446
447 // Include a thumbnail for media files...
448 if( $t->getNamespace() == NS_IMAGE ) {
449 $img = wfFindFile( $t );
450 if( $img ) {
451 $thumb = $img->transform( array( 'width' => 120, 'height' => 120 ) );
452 if( $thumb ) {
453 $desc = $img->getShortDesc();
454 wfProfileOut( $fname );
455 // Ugly table. :D
456 // Float doesn't seem to interact well with the bullets.
457 // Table messes up vertical alignment of the bullet, but I'm
458 // not sure what more I can do about that. :(
459 return "<li>" .
460 '<table class="searchResultImage">' .
461 '<tr>' .
462 '<td width="120" align="center">' .
463 $thumb->toHtml( array( 'desc-link' => true ) ) .
464 '</td>' .
465 '<td valign="top">' .
466 $link .
467 $extract .
468 "<div class='mw-search-result-data'>{$score}{$desc} - {$date}{$related}</div>" .
469 '</td>' .
470 '</tr>' .
471 '</table>' .
472 "</li>\n";
473 }
474 }
475 }
476
477 wfProfileOut( $fname );
478 return "<li>{$link} {$redirect} {$section} {$extract}\n" .
479 "<div class='mw-search-result-data'>{$score}{$size} - {$date}{$related}</div>" .
480 "</li>\n";
481
482 }
483
484 /**
485 * Show results from other wikis
486 *
487 * @param SearchResultSet $matches
488 */
489 function showInterwiki( &$matches, $query ) {
490 $fname = 'SpecialSearch::showInterwiki';
491 wfProfileIn( $fname );
492
493 global $wgContLang;
494 $terms = $wgContLang->convertForSearchResult( $matches->termMatches() );
495
496 $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>".wfMsg('search-interwiki-caption')."</div>\n";
497 $off = $this->offset + 1;
498 $out .= "<ul start='{$off}' class='mw-search-iwresults'>\n";
499
500 // work out custom project captions
501 $customCaptions = array();
502 $customLines = explode("\n",wfMsg('search-interwiki-custom')); // format per line <iwprefix>:<caption>
503 foreach($customLines as $line){
504 $parts = explode(":",$line,2);
505 if(count($parts) == 2) // validate line
506 $customCaptions[$parts[0]] = $parts[1];
507 }
508
509
510 $prev = null;
511 while( $result = $matches->next() ) {
512 $out .= $this->showInterwikiHit( $result, $prev, $terms, $query, $customCaptions );
513 $prev = $result->getInterwikiPrefix();
514 }
515 // FIXME: should support paging in a non-confusing way (not sure how though, maybe via ajax)..
516 $out .= "</ul></div>\n";
517
518 // convert the whole thing to desired language variant
519 global $wgContLang;
520 $out = $wgContLang->convert( $out );
521 wfProfileOut( $fname );
522 return $out;
523 }
524
525 /**
526 * Show single interwiki link
527 *
528 * @param SearchResult $result
529 * @param string $lastInterwiki
530 * @param array $terms
531 * @param string $query
532 * @param array $customCaptions iw prefix -> caption
533 */
534 function showInterwikiHit( $result, $lastInterwiki, $terms, $query, $customCaptions){
535 $fname = 'SpecialSearch::showInterwikiHit';
536 wfProfileIn( $fname );
537 global $wgUser, $wgContLang, $wgLang;
538
539 if( $result->isBrokenTitle() ) {
540 wfProfileOut( $fname );
541 return "<!-- Broken link in search result -->\n";
542 }
543
544 $t = $result->getTitle();
545 $sk = $wgUser->getSkin();
546
547 $link = $sk->makeKnownLinkObj( $t, $result->getTitleSnippet($terms));
548
549 // format redirect if any
550 $redirectTitle = $result->getRedirectTitle();
551 $redirectText = $result->getRedirectSnippet($terms);
552 $redirect = '';
553 if( !is_null($redirectTitle) )
554 $redirect = "<span class='searchalttitle'>"
555 .wfMsg('search-redirect',$sk->makeKnownLinkObj( $redirectTitle, $redirectText))
556 ."</span>";
557
558 $out = "";
559 // display project name
560 if(is_null($lastInterwiki) || $lastInterwiki != $t->getInterwiki()){
561 if( key_exists($t->getInterwiki(),$customCaptions) )
562 // captions from 'search-interwiki-custom'
563 $caption = $customCaptions[$t->getInterwiki()];
564 else{
565 // default is to show the hostname of the other wiki which might suck
566 // if there are many wikis on one hostname
567 $parsed = parse_url($t->getFullURL());
568 $caption = wfMsg('search-interwiki-default', $parsed['host']);
569 }
570 // "more results" link (special page stuff could be localized, but we might not know target lang)
571 $searchTitle = Title::newFromText($t->getInterwiki().":Special:Search");
572 $searchLink = $sk->makeKnownLinkObj( $searchTitle, wfMsg('search-interwiki-more'),
573 wfArrayToCGI(array('search' => $query, 'fulltext' => 'Search')));
574 $out .= "</ul><div class='mw-search-interwiki-project'><span class='mw-search-interwiki-more'>{$searchLink}</span>{$caption}</div>\n<ul>";
575 }
576
577 $out .= "<li>{$link} {$redirect}</li>\n";
578 wfProfileOut( $fname );
579 return $out;
580 }
581
582
583 /**
584 * Generates the power search box at bottom of [[Special:Search]]
585 * @param $term string: search term
586 * @return $out string: HTML form
587 */
588 function powerSearchBox( $term ) {
589 global $wgScript;
590
591 $namespaces = '';
592 foreach( SearchEngine::searchableNamespaces() as $ns => $name ) {
593 $name = str_replace( '_', ' ', $name );
594 if( '' == $name ) {
595 $name = wfMsg( 'blanknamespace' );
596 }
597 $namespaces .= Xml::openElement( 'span', array( 'style' => 'white-space: nowrap' ) ) .
598 Xml::checkLabel( $name, "ns{$ns}", "mw-search-ns{$ns}", in_array( $ns, $this->namespaces ) ) .
599 Xml::closeElement( 'span' ) . "\n";
600 }
601
602 $redirect = Xml::check( 'redirs', $this->searchRedirects, array( 'value' => '1', 'id' => 'redirs' ) );
603 $redirectLabel = Xml::label( wfMsg( 'powersearch-redir' ), 'redirs' );
604 $searchField = Xml::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'powerSearchText' ) );
605 $searchButton = Xml::submitButton( wfMsg( 'powersearch' ), array( 'name' => 'fulltext' ) ) . "\n";
606 $searchTitle = SpecialPage::getTitleFor( 'Search' );
607
608 $out = Xml::openElement( 'form', array( 'id' => 'powersearch', 'method' => 'get', 'action' => $wgScript ) ) .
609 Xml::fieldset( wfMsg( 'powersearch-legend' ),
610 Xml::hidden( 'title', $searchTitle->getPrefixedText() ) .
611 "<p>" .
612 wfMsgExt( 'powersearch-ns', array( 'parseinline' ) ) .
613 "<br />" .
614 $namespaces .
615 "</p>" .
616 "<p>" .
617 $redirect . " " . $redirectLabel .
618 "</p>" .
619 wfMsgExt( 'powersearch-field', array( 'parseinline' ) ) .
620 "&nbsp;" .
621 $searchField .
622 "&nbsp;" .
623 $searchButton ) .
624 "</form>";
625
626 return $out;
627 }
628
629 function powerSearchFocus() {
630 global $wgJsMimeType;
631 return "<script type=\"$wgJsMimeType\">" .
632 "hookEvent(\"load\", function(){" .
633 "document.getElementById('powerSearchText').focus();" .
634 "});" .
635 "</script>";
636 }
637
638 function shortDialog($term) {
639 global $wgScript;
640
641 $out = Xml::openElement( 'form', array(
642 'id' => 'search',
643 'method' => 'get',
644 'action' => $wgScript
645 ));
646 $searchTitle = SpecialPage::getTitleFor( 'Search' );
647 $out .= Xml::hidden( 'title', $searchTitle->getPrefixedText() );
648 $out .= Xml::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'searchText' ) ) . ' ';
649 foreach( SearchEngine::searchableNamespaces() as $ns => $name ) {
650 if( in_array( $ns, $this->namespaces ) ) {
651 $out .= Xml::hidden( "ns{$ns}", '1' );
652 }
653 }
654 $out .= Xml::submitButton( wfMsg( 'searchbutton' ), array( 'name' => 'fulltext' ) );
655 $out .= Xml::closeElement( 'form' );
656
657 return $out;
658 }
659 }