75 $user = $this->specialSearch->getUser();
77 $form = Xml::openElement(
80 'id' => $isPowerSearch ?
'powersearch' :
'search',
82 'method' => ( $isPowerSearch && $user->isRegistered() ) ?
'post' :
'get',
88 [
'id' =>
'mw-search-top-table' ],
89 $this->
shortDialogHtml( $profile, $term, $numResults, $totalResults, $offset, $options )
91 Html::rawElement(
'div', [
'class' =>
'mw-search-visualclear' ] ) .
94 [
'class' =>
'mw-search-profile-tabs' ],
96 Html::rawElement(
'div', [
'style' =>
'clear:both' ] )
98 $this->
optionsHtml( $term, $isPowerSearch, $profile ) .
99 Xml::closeElement(
'form' );
101 return Html::rawElement(
'div', [
'class' =>
'mw-search-form-wrapper' ], $form );
124 'id' =>
'searchText',
126 'autofocus' => trim( $term ) ===
'',
127 'title' => $this->specialSearch->msg(
'searchsuggest-search' )->text(),
129 'dataLocation' =>
'content',
133 $layout = new \OOUI\ActionFieldLayout( $searchWidget,
new \OOUI\ButtonInputWidget( [
135 'label' => $this->specialSearch->msg(
'searchbutton' )->text(),
136 'flags' => [
'progressive',
'primary' ],
143 if ( $this->specialSearch->getPrefix() !==
'' ) {
144 $html .= Html::hidden(
'prefix', $this->specialSearch->getPrefix() );
147 if ( $totalResults > 0 && $offset < $totalResults ) {
151 'class' =>
'results-info',
152 'data-mw-num-results-offset' => $offset,
153 'data-mw-num-results-total' => $totalResults
155 $this->specialSearch->msg(
'search-showingresults' )
156 ->numParams( $offset + 1, $offset + $numResults, $totalResults )
157 ->numParams( $numResults )
163 Html::hidden(
'title', $this->specialSearch->getPageTitle()->getPrefixedText() ) .
164 Html::hidden(
'profile', $profile ) .
165 Html::hidden(
'fulltext',
'1' );
179 ? substr( $term, strpos( $term,
':' ) + 1 )
181 $lang = $this->specialSearch->getLanguage();
183 foreach ( $this->profiles as $id => $profileConfig ) {
184 $profileConfig[
'parameters'][
'profile'] = $id;
185 $tooltipParam = isset( $profileConfig[
'namespace-messages'] )
186 ?
$lang->commaList( $profileConfig[
'namespace-messages'] )
188 $items[] = Xml::tags(
190 [
'class' => $profile === $id ?
'current' :
'normal' ],
193 $this->specialSearch->msg( $profileConfig[
'message'] )->text(),
194 $this->specialSearch->msg( $profileConfig[
'tooltip'], $tooltipParam )->text(),
195 $profileConfig[
'parameters']
200 return Html::rawElement(
202 [
'class' =>
'search-types' ],
203 Html::rawElement(
'ul', [], implode(
'', $items ) )
255 protected function optionsHtml( $term, $isPowerSearch, $profile ) {
258 if ( $isPowerSearch ) {
263 $this->specialSearch, $form, $profile, $term, [] );
278 $activeNamespaces = $this->specialSearch->getNamespaces();
279 foreach ( $this->searchConfig->searchableNamespaces() as $namespace => $name ) {
280 $subject = $this->namespaceInfo->getSubject( $namespace );
281 if ( !isset( $rows[$subject] ) ) {
282 $rows[$subject] =
"";
285 $name = $this->languageConverter->convertNamespace( $namespace );
286 if ( $name ===
'' ) {
287 $name = $this->specialSearch->msg(
'blanknamespace' )->text();
290 $rows[$subject] .= Html::rawElement(
296 "mw-search-ns{$namespace}",
297 in_array( $namespace, $activeNamespaces )
305 foreach ( $rows as $row ) {
306 $tableRows[] = Html::rawElement(
'tr', [], $row );
308 $namespaceTables = [];
309 foreach ( array_chunk( $tableRows, 4 ) as $chunk ) {
310 $namespaceTables[] = implode(
'', $chunk );
314 'namespaceTables' =>
"<table>" . implode(
'</table><table>', $namespaceTables ) .
'</table>',
316 $this->
getHookRunner()->onSpecialSearchPowerBox( $showSections, $term, $opts );
319 foreach ( $opts as $key => $value ) {
320 $hidden .= Html::hidden( $key, $value );
323 $divider = Html::rawElement(
'div', [
'class' =>
'divider' ],
'' );
326 $user = $this->specialSearch->getUser();
328 if ( $user->isRegistered() ) {
329 $remember = $divider . Xml::checkLabel(
330 $this->specialSearch->msg(
'powersearch-remember' )->text(),
332 'mw-search-powersearch-remember',
336 [
'value' => $user->getEditToken(
338 $this->specialSearch->getRequest()
345 Html::rawElement(
'label', [], $this->specialSearch->msg(
'powersearch-togglelabel' )->escaped() ) .
350 'id' =>
'mw-search-toggleall',
351 'value' => $this->specialSearch->msg(
'powersearch-toggleall' )->text(),
358 'id' =>
'mw-search-togglenone',
359 'value' => $this->specialSearch->msg(
'powersearch-togglenone' )->text(),
363 Html::rawElement(
'legend', [], $this->specialSearch->msg(
'powersearch-legend' )->escaped() ) .
364 Html::rawElement(
'h4', [], $this->specialSearch->msg(
'powersearch-ns' )->parse() ) .
368 [
'id' =>
'mw-search-togglebox' ],
371 $divider . implode( $divider, $showSections ) . $hidden . $remember;
373 return Html::rawElement(
'fieldset', [
'id' =>
'mw-searchoptions' ], $fieldSetContents );