return Html::rawElement( isset($options["tag"]) ? $options["tag"] : "li", $attrs, $html );
}
+ function makeSearchInput($attrs = array()) {
+ $realAttrs = array(
+ "type" => "search",
+ "name" => "search",
+ "value" => isset($this->data['search']) ? $this->data['search'] : '',
+ );
+ $realAttrs = array_merge($realAttrs, $this->skin->tooltipAndAccesskeyAttribs('search'), $attrs);
+ return Html::element( "input", $realAttrs );
+ }
+
+ function makeSearchButton($mode, $attrs = array()) {
+ switch($mode) {
+ case "go":
+ case "fulltext":
+ $realAttrs = array(
+ "type" => "submit",
+ "name" => $mode,
+ "value" => $this->translator->translate( $mode == "go" ? "searcharticle" : "searchbutton" ),
+ );
+ $realAttrs = array_merge($realAttrs, $this->skin->tooltipAndAccesskeyAttribs("search-$mode"), $attrs);
+ return Html::element( "input", $realAttrs );
+ case "image":
+ $buttonAttrs = array(
+ "type" => "submit",
+ "name" => "button",
+ );
+ $buttonAttrs = array_merge($buttonAttrs, $this->skin->tooltipAndAccesskeyAttribs("search-fulltext"), $attrs);
+ unset($buttonAttrs["src"]);
+ unset($buttonAttrs["alt"]);
+ $imgAttrs = array(
+ "src" => $attrs["src"],
+ "alt" => isset($attrs["alt"]) ? $attrs["alt"] : $this->translator->translate( "searchbutton" ),
+ );
+ return Html::rawElement( "button", $buttonAttrs, Html::element( "img", $imgAttrs ) );
+ default:
+ throw new MWException("Unknown mode passed to BaseTemplate::makeSearchButton");
+ }
+ }
}
<div id="searchBody" class="pBody">
<form action="<?php $this->text('wgScript') ?>" id="searchform">
<input type='hidden' name="title" value="<?php $this->text('searchtitle') ?>"/>
- <?php
- echo Html::input( 'search',
- isset( $this->data['search'] ) ? $this->data['search'] : '', 'search',
- array(
- 'id' => 'searchInput',
- 'title' => $this->skin->titleAttrib( 'search' ),
- 'accesskey' => $this->skin->accesskey( 'search' )
- ) ); ?>
+ <?php echo $this->makeSearchInput(array( "id" => "searchInput" )); ?>
- <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg('searcharticle') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> /><?php if ($wgUseTwoButtonsSearchForm) { ?> 
- <input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg('searchbutton') ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> /><?php } else { ?>
+ <?php echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" ));
+ if ($wgUseTwoButtonsSearchForm): ?> 
+ <?php echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" ));
+ else: ?>
- <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php } ?>
+ <div><a href="<?php $this->text('searchaction') ?>" rel="search"><?php $this->msg('powersearch-legend') ?></a></div><?php
+ endif; ?>
</form>
</div>
<input type='hidden' name="title" value="<?php $this->text( 'searchtitle' ) ?>"/>
<?php if ( $wgVectorUseSimpleSearch && $wgUser->getOption( 'vector-simplesearch' ) ): ?>
<div id="simpleSearch">
- <input id="searchInput" name="search" type="text" <?php echo $this->skin->tooltipAndAccesskey( 'search' ); ?> <?php if( isset( $this->data['search'] ) ): ?> value="<?php $this->text( 'search' ) ?>"<?php endif; ?> />
- <button id="searchButton" type='submit' name='button' <?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?>><img src="<?php echo $this->skin->getSkinStylePath('images/search-' . ( $this->data['rtl'] ? 'rtl' : 'ltr' ) . '.png'); ?>" alt="<?php $this->msg( 'searchbutton' ) ?>" /></button>
+ <?php echo $this->makeSearchInput(array( "id" => "searchInput" )); ?>
+ <?php echo $this->makeSearchButton("image", array( "id" => "searchButton",
+ "src" => $this->skin->getSkinStylePath('images/search-' . ( $this->data['rtl'] ? 'rtl' : 'ltr' ) . '.png') )); ?>
</div>
<?php else: ?>
- <input id="searchInput" name="search" type="text" <?php echo $this->skin->tooltipAndAccesskey( 'search' ); ?> <?php if( isset( $this->data['search'] ) ): ?> value="<?php $this->text( 'search' ) ?>"<?php endif; ?> />
- <input type='submit' name="go" class="searchButton" id="searchGoButton" value="<?php $this->msg( 'searcharticle' ) ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-go' ); ?> />
- <input type="submit" name="fulltext" class="searchButton" id="mw-searchButton" value="<?php $this->msg( 'searchbutton' ) ?>"<?php echo $this->skin->tooltipAndAccesskey( 'search-fulltext' ); ?> />
+ <?php echo $this->makeSearchInput(array( "id" => "searchInput" )); ?>
+ <?php echo $this->makeSearchButton("go", array( "id" => "searchGoButton", "class" => "searchButton" )); ?>
+ <?php echo $this->makeSearchButton("fulltext", array( "id" => "mw-searchButton", "class" => "searchButton" )); ?>
<?php endif; ?>
</form>
</div>