Hygiene: move VectorTemplate inlined PHP to variables

Move template logic outside of the template and into variables. This
will allow a future refactor to move the template to a separate
template-only file.

Change-Id: I91c2df11106cf09428a890a2d96ecbddb18ef0fe
This commit is contained in:
Stephen Niedzielski 2019-11-18 16:06:10 -05:00
parent 501b94f1b4
commit c9f15a4206

View file

@ -449,16 +449,29 @@ class VectorTemplate extends BaseTemplate {
}
private function renderSearchComponent() {
$searchHeaderAttrs = $this->data[ 'userlangattributes' ] ?? '';
$searchAction = htmlspecialchars( $this->data[ 'wgScript' ] ?? '' );
$searchDivID = $this->config->get( 'VectorUseSimpleSearch' ) ? 'simpleSearch' : '';
$searchInputHTML = $this->makeSearchInput( [ 'id' => 'searchInput' ] );
$titleHTML = Html::hidden( 'title', $this->get( 'searchtitle' ) );
$fallbackSearchButtonHTML = $this->makeSearchButton(
'fulltext',
[ 'id' => 'mw-searchButton', 'class' => 'searchButton mw-fallbackSearchButton' ]
);
$searchButtonHTML = $this->makeSearchButton(
'go',
[ 'id' => 'searchButton', 'class' => 'searchButton' ]
);
?>
<div id="p-search" role="search">
<h3<?php $this->html( 'userlangattributes' ) ?>>
<h3<?php echo $searchHeaderAttrs ?>>
<label for="searchInput"><?php $this->msg( 'search' ) ?></label>
</h3>
<form action="<?php $this->text( 'wgScript' ) ?>" id="searchform">
<div<?php echo $this->config->get( 'VectorUseSimpleSearch' ) ? ' id="simpleSearch"' : '' ?>>
<form action="<?php echo $searchAction ?>" id="searchform">
<div id="<?php echo $searchDivID ?>">
<?php
echo $this->makeSearchInput( [ 'id' => 'searchInput' ] );
echo Html::hidden( 'title', $this->get( 'searchtitle' ) );
echo $searchInputHTML;
echo $titleHTML;
/* We construct two buttons (for 'go' and 'fulltext' search modes),
* but only one will be visible and actionable at a time (they are
* overlaid on top of each other in CSS).
@ -471,14 +484,8 @@ class VectorTemplate extends BaseTemplate {
* 'fulltext' search itself; this will reveal the 'go' button and
* cause it to be used.
*/
echo $this->makeSearchButton(
'fulltext',
[ 'id' => 'mw-searchButton', 'class' => 'searchButton mw-fallbackSearchButton' ]
);
echo $this->makeSearchButton(
'go',
[ 'id' => 'searchButton', 'class' => 'searchButton' ]
);
echo $fallbackSearchButtonHTML;
echo $searchButtonHTML;
?>
</div>
</form>