Merge "Search data should support multiple searches"

This commit is contained in:
jenkins-bot 2021-09-20 22:47:47 +00:00 committed by Gerrit Code Review
commit 02b29b5f73
2 changed files with 45 additions and 7 deletions

View file

@ -2456,12 +2456,12 @@ abstract class Skin extends ContextSource {
}
/**
* @since 1.35
* @since 1.38
* @param array $attrs (optional) will be passed to tooltipAndAccesskeyAttribs
* and decorate the resulting input
* @return string of HTML input
* @return array attributes of HTML input
*/
final public function makeSearchInput( $attrs = [] ) {
protected function getSearchInputAttributes( $attrs = [] ) {
$autoCapHint = $this->getConfig()->get( 'CapitalLinks' );
$realAttrs = [
'type' => 'search',
@ -2472,8 +2472,17 @@ abstract class Skin extends ContextSource {
'autocapitalize' => $autoCapHint ? 'sentences' : 'none',
];
$realAttrs = array_merge( $realAttrs, Linker::tooltipAndAccesskeyAttribs( 'search' ), $attrs );
return Html::element( 'input', $realAttrs );
return array_merge( $realAttrs, Linker::tooltipAndAccesskeyAttribs( 'search' ), $attrs );
}
/**
* @since 1.35
* @param array $attrs (optional) will be passed to tooltipAndAccesskeyAttribs
* and decorate the resulting input
* @return string of HTML input
*/
final public function makeSearchInput( $attrs = [] ) {
return Html::element( 'input', $this->getSearchInputAttributes( $attrs ) );
}
/**

View file

@ -972,20 +972,49 @@ class SkinTemplate extends Skin {
*/
private function buildSearchProps(): array {
$config = $this->getConfig();
$searchButtonAttributes = [
'class' => 'searchButton'
];
$fallbackButtonAttributes = [
'class' => 'searchButton mw-fallbackSearchButton'
];
$buttonAttributes = [
'type' => 'submit',
];
$props = [
'form-action' => $config->get( 'Script' ),
'html-button-search-fallback' => $this->makeSearchButton(
'fulltext',
[ 'id' => 'mw-searchButton', 'class' => 'searchButton mw-fallbackSearchButton' ]
$fallbackButtonAttributes + [
'id' => 'mw-searchButton',
]
),
'html-button-search' => $this->makeSearchButton(
'go',
[ 'id' => 'searchButton', 'class' => 'searchButton' ]
$searchButtonAttributes + [
'id' => 'searchButton',
]
),
'html-input' => $this->makeSearchInput( [ 'id' => 'searchInput' ] ),
'msg-search' => $this->msg( 'search' )->text(),
'page-title' => $this->getSearchPageTitle()->getPrefixedDBkey(),
// @since 1.38
'html-button-go-attributes' => Html::expandAttributes(
$searchButtonAttributes + $buttonAttributes + [
'name' => 'go',
] + Linker::tooltipAndAccesskeyAttribs( 'search-go' )
),
// @since 1.38
'html-button-fulltext-attributes' => Html::expandAttributes(
$fallbackButtonAttributes + $buttonAttributes + [
'name' => 'fulltext'
] + Linker::tooltipAndAccesskeyAttribs( 'search-fulltext' )
),
// @since 1.38
'html-input-attributes' => Html::expandAttributes(
$this->getSearchInputAttributes( [] )
),
];
return $props;