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