X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fwidget%2Fsearch%2FSearchFormWidget.php;h=66b65667c258999c1186db91888c087315ee154e;hb=7049236d2804c52639abae01d266d3ecaaff480f;hp=7eb92fdfd6a1d1a8571c6b7c9ca9a55e5bdd2282;hpb=a5dd9a99469b0adea8ffd7ac21df28843e8af52e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/widget/search/SearchFormWidget.php b/includes/widget/search/SearchFormWidget.php index 7eb92fdfd6..62ee9cb6f1 100644 --- a/includes/widget/search/SearchFormWidget.php +++ b/includes/widget/search/SearchFormWidget.php @@ -6,7 +6,6 @@ use Hooks; use Html; use MediaWiki\MediaWikiServices; use MediaWiki\Widget\SearchInputWidget; -use MWNamespace; use SearchEngineConfig; use SpecialSearch; use Xml; @@ -41,6 +40,7 @@ class SearchFormWidget { * @param int $totalResults The total estimated results found * @param int $offset Current offset in search results * @param bool $isPowerSearch Is the 'advanced' section open? + * @param array $options Widget options * @return string HTML */ public function render( @@ -49,19 +49,23 @@ class SearchFormWidget { $numResults, $totalResults, $offset, - $isPowerSearch + $isPowerSearch, + array $options = [] ) { + $user = $this->specialSearch->getUser(); + return '
' . Xml::openElement( 'form', [ 'id' => $isPowerSearch ? 'powersearch' : 'search', - 'method' => 'get', + // T151903: default to POST in case JS is disabled + 'method' => ( $isPowerSearch && $user->isLoggedIn() ) ? 'post' : 'get', 'action' => wfScript(), ] ) . '
' . - $this->shortDialogHtml( $profile, $term, $numResults, $totalResults, $offset ) . + $this->shortDialogHtml( $profile, $term, $numResults, $totalResults, $offset, $options ) . '
' . "
" . "
" . @@ -79,12 +83,20 @@ class SearchFormWidget { * @param int $numResults The number of results shown * @param int $totalResults The total estimated results found * @param int $offset Current offset in search results + * @param array $options Widget options * @return string HTML */ - protected function shortDialogHtml( $profile, $term, $numResults, $totalResults, $offset ) { + protected function shortDialogHtml( + $profile, + $term, + $numResults, + $totalResults, + $offset, + array $options = [] + ) { $html = ''; - $searchWidget = new SearchInputWidget( [ + $searchWidget = new SearchInputWidget( $options + [ 'id' => 'searchText', 'name' => 'search', 'autofocus' => trim( $term ) === '', @@ -238,9 +250,10 @@ class SearchFormWidget { protected function powerSearchBox( $term, array $opts ) { $rows = []; $activeNamespaces = $this->specialSearch->getNamespaces(); - $langConverter = MediaWikiServices::getInstance()->getContentLanguage()->getConverter(); + $langConverter = $this->specialSearch->getLanguage(); foreach ( $this->searchConfig->searchableNamespaces() as $namespace => $name ) { - $subject = MWNamespace::getSubject( $namespace ); + $subject = MediaWikiServices::getInstance()->getNamespaceInfo()-> + getSubject( $namespace ); if ( !isset( $rows[$subject] ) ) { $rows[$subject] = ""; } @@ -305,8 +318,14 @@ class SearchFormWidget { return "
" . "" . $this->specialSearch->msg( 'powersearch-legend' )->escaped() . '' . "

" . $this->specialSearch->msg( 'powersearch-ns' )->parse() . '

' . - // populated by js if available - "
" . + // Handled by JavaScript if available + '
' . + '' . + '' . + '' . + '
' . $divider . implode( $divider,