*/
$wgFeaturePolicyReportOnly = [];
+/**
+ * Options for Special:Search completion widget form created by SearchFormWidget class.
+ * Settings that can be used:
+ * - showDescriptions: true/false - whether to show opensearch description results
+ * - performSearchOnClick: true/false - whether to perform search on click
+ * See also TitleWidget.js UI widget.
+ * @since 1.34
+ * @var array
+ */
+$wgSpecialSearchFormOptions = [];
+
/**
* For really cool vim folding this needs to be at the end:
* vim: foldmarker=@{,@} foldmethod=marker
}
$out = $this->getOutput();
+ $widgetOptions = $this->getConfig()->get( 'SpecialSearchFormOptions' );
$formWidget = new MediaWiki\Widget\Search\SearchFormWidget(
$this,
$this->searchConfig,
// only do the form render here for the empty $term case. Rendering
// the form when a search is provided is repeated below.
$out->addHTML( $formWidget->render(
- $this->profile, $term, 0, 0, $this->offset, $this->isPowerSearch()
+ $this->profile, $term, 0, 0, $this->offset, $this->isPowerSearch(), $widgetOptions
) );
return;
}
// start rendering the page
$out->enableOOUI();
$out->addHTML( $formWidget->render(
- $this->profile, $term, $num, $totalRes, $this->offset, $this->isPowerSearch()
+ $this->profile, $term, $num, $totalRes, $this->offset, $this->isPowerSearch(), $widgetOptions
) );
// did you mean... suggestions
protected $validateTitle = false;
protected $highlightFirst = false;
protected $dataLocation = 'header';
+ protected $showDescriptions = false;
/**
* @param array $config Configuration options
$this->dataLocation = $config['dataLocation'];
}
+ if ( !empty( $config['showDescriptions'] ) ) {
+ $this->showDescriptions = true;
+ }
+
// Initialization
$this->addClasses( [ 'mw-widget-searchInputWidget' ] );
}
if ( $this->dataLocation ) {
$config['dataLocation'] = $this->dataLocation;
}
+ if ( $this->showDescriptions ) {
+ $config['showDescriptions'] = true;
+ }
$config['$overlay'] = true;
return parent::getConfig( $config );
}
* @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(
$numResults,
$totalResults,
$offset,
- $isPowerSearch
+ $isPowerSearch,
+ array $options = []
) {
$user = $this->specialSearch->getUser();
]
) .
'<div id="mw-search-top-table">' .
- $this->shortDialogHtml( $profile, $term, $numResults, $totalResults, $offset ) .
+ $this->shortDialogHtml( $profile, $term, $numResults, $totalResults, $offset, $options ) .
'</div>' .
"<div class='mw-search-visualclear'></div>" .
"<div class='mw-search-profile-tabs'>" .
* @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 ) === '',