}
protected function showStandardInputs( &$tabindex = 2 ) {
- global $wgOut, $wgUseMediaWikiUIEverywhere;
+ global $wgOut;
$wgOut->addHTML( "<div class='editOptions'>\n" );
if ( $this->section != 'new' ) {
'target' => 'helpwindow',
'href' => $edithelpurl,
);
- if ( $wgUseMediaWikiUIEverywhere ) {
- $attrs['class'] = 'mw-ui-button mw-ui-quiet';
- }
- $edithelp = Html::element( 'a', $attrs, wfMessage( 'edithelp' )->text() ) .
+ $edithelp = Html::linkButton( wfMessage( 'edithelp' )->text(),
+ $attrs, array( 'mw-ui-quiet' ) ) .
wfMessage( 'word-separator' )->escaped() .
wfMessage( 'newwindow' )->parse();
* @return string
*/
public function getCancelLink() {
- global $wgUseMediaWikiUIEverywhere;
$cancelParams = array();
if ( !$this->isConflict && $this->oldid > 0 ) {
$cancelParams['oldid'] = $this->oldid;
}
$attrs = array( 'id' => 'mw-editform-cancel' );
- if ( $wgUseMediaWikiUIEverywhere ) {
- $attrs['class'] = 'mw-ui-button mw-ui-quiet';
- }
return Linker::linkKnown(
$this->getContextTitle(),
wfMessage( 'cancel' )->parse(),
- $attrs,
+ Html::buttonAttributes( $attrs, array( 'mw-ui-quiet' ) ),
$cancelParams
);
}
* @return array
*/
public function getEditButtons( &$tabindex ) {
- global $wgUseMediaWikiUIEverywhere;
-
$buttons = array();
$attribs = array(
'id' => 'wpSave',
'name' => 'wpSave',
- 'type' => 'submit',
'tabindex' => ++$tabindex,
- 'value' => wfMessage( 'savearticle' )->text(),
) + Linker::tooltipAndAccesskeyAttribs( 'save' );
- if ( $wgUseMediaWikiUIEverywhere ) {
- $attribs['class'] = 'mw-ui-button mw-ui-constructive';
- }
- $buttons['save'] = Xml::element( 'input', $attribs, '' );
+ $buttons['save'] = Html::submitButton( wfMessage( 'savearticle' )->text(),
+ $attribs, array( 'mw-ui-constructive' ) );
++$tabindex; // use the same for preview and live preview
$attribs = array(
'id' => 'wpPreview',
'name' => 'wpPreview',
- 'type' => 'submit',
'tabindex' => $tabindex,
- 'value' => wfMessage( 'showpreview' )->text(),
) + Linker::tooltipAndAccesskeyAttribs( 'preview' );
- if ( $wgUseMediaWikiUIEverywhere ) {
- $attribs['class'] = 'mw-ui-button mw-ui-progressive';
- }
- $buttons['preview'] = Xml::element( 'input', $attribs, '' );
+ $buttons['preview'] = Html::submitButton( wfMessage( 'showpreview' )->text(),
+ $attribs, array( 'mw-ui-progressive' ) );
$buttons['live'] = '';
$attribs = array(
'id' => 'wpDiff',
'name' => 'wpDiff',
- 'type' => 'submit',
'tabindex' => ++$tabindex,
- 'value' => wfMessage( 'showdiff' )->text(),
) + Linker::tooltipAndAccesskeyAttribs( 'diff' );
- if ( $wgUseMediaWikiUIEverywhere ) {
- $attribs['class'] = 'mw-ui-button mw-ui-progressive';
- }
- $buttons['diff'] = Xml::element( 'input', $attribs, '' );
+ $buttons['diff'] = Html::submitButton( wfMessage( 'showdiff' )->text(),
+ $attribs, array( 'mw-ui-progressive' ) );
wfRunHooks( 'EditPageBeforeEditButtons', array( &$this, &$buttons, &$tabindex ) );
return $buttons;
'itemscope',
);
+ /**
+ * Modifies a set of attributes meant for button elements
+ * and apply a set of default attributes when $wgUseMediaWikiUIEverywhere enabled.
+ * @param array $modifiers to add to the button
+ * @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers
+ * @return array $attrs A modified attribute array
+ */
+ public static function buttonAttributes( $attrs, $modifiers = array() ) {
+ global $wgUseMediaWikiUIEverywhere;
+ if ( $wgUseMediaWikiUIEverywhere ) {
+ if ( isset( $attrs['class'] ) ) {
+ if ( is_array( $attrs['class'] ) ) {
+ $attrs['class'][] = 'mw-ui-button';
+ $attrs = array_merge( $attrs, $modifiers );
+ // ensure compatibility with Xml
+ $attrs['class'] = implode( ' ', $attrs['class'] );
+ } else {
+ $attrs['class'] .= ' mw-ui-button ' . implode( ' ', $modifiers );
+ }
+ } else {
+ $attrs['class'] = array( 'mw-ui-button' );
+ // ensure compatibility with Xml
+ $attrs['class'] = implode( ' ', array_merge( $attrs['class'], $modifiers ) );
+ }
+ }
+ return $attrs;
+ }
+
/**
* Modifies a set of attributes meant for text input elements
* and apply a set of default attributes.
return $attrs;
}
+ /**
+ * Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enabled).
+ *
+ * @param string $contents The raw HTML contents of the element: *not*
+ * escaped!
+ * @param array $attrs Associative array of attributes, e.g., array(
+ * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for
+ * further documentation.
+ * @param array $modifiers to add to the button
+ * @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers
+ * @return string Raw HTML
+ */
+ public static function linkButton( $contents, $attrs, $modifiers = array() ) {
+ return Html::element( 'a',
+ self::buttonAttributes( $attrs, $modifiers ),
+ $contents
+ );
+ }
+
+ /**
+ * Returns an HTML link element in a string styled as a button (when $wgUseMediaWikiUIEverywhere is enabled).
+ *
+ * @param string $contents The raw HTML contents of the element: *not*
+ * escaped!
+ * @param array $attrs Associative array of attributes, e.g., array(
+ * 'href' => 'http://www.mediawiki.org/' ). See expandAttributes() for
+ * further documentation.
+ * @param array $modifiers to add to the button
+ * @see http://tools.wmflabs.org/styleguide/desktop/index.html for guidance on available modifiers
+ * @return string Raw HTML
+ */
+ public static function submitButton( $contents, $attrs, $modifiers = array() ) {
+ $attrs['type'] = 'submit';
+ $attrs['value'] = $contents;
+ return Html::element( 'input', self::buttonAttributes( $attrs, $modifiers ) );
+ }
+
/**
* Returns an HTML element in a string. The major advantage here over
* manually typing out the HTML is that it will escape all attribute
* @return string
*/
function getButtons() {
- global $wgUseMediaWikiUIEverywhere;
$attrs = array( 'id' => 'mw-prefs-restoreprefs' );
- if ( $wgUseMediaWikiUIEverywhere ) {
- $attrs['class'] = 'mw-ui-button mw-ui-quiet';
- }
if ( !$this->getModifiedUser()->isAllowedAny( 'editmyprivateinfo', 'editmyoptions' ) ) {
return '';
$t = SpecialPage::getTitleFor( 'Preferences', 'reset' );
$html .= "\n" . Linker::link( $t, $this->msg( 'restoreprefs' )->escaped(),
- $attrs );
+ Html::buttonAttributes( $attrs, array( 'mw-ui-quiet' ) ) );
$html = Xml::tags( 'div', array( 'class' => 'mw-prefs-buttons' ), $html );
}
// Add the general form
$action = htmlspecialchars( wfScript() );
$className = 'historysubmit mw-history-compareselectedversions-button';
- if ( $config->get( 'UseMediaWikiUIEverywhere' ) ) {
- $className .= ' mw-ui-button mw-ui-progressive';
- }
$out->addHTML(
"<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
Xml::fieldset(
) . ' ' .
( $tagSelector ? ( implode( ' ', $tagSelector ) . ' ' ) : '' ) .
$checkDeleted .
- Xml::submitButton(
+ Html::submitButton(
$this->msg( 'allpagessubmit' )->text(),
- array( 'class' => $className )
+ $attrs,
+ array( 'mw-ui-progressive' )
) . "\n" .
'</fieldset></form>'
);
// Button container stored in $this->buttons for re-use in getEndBody()
$this->buttons = '<div>';
$className = 'historysubmit mw-history-compareselectedversions-button';
- if ( $this->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) {
- $className .= ' mw-ui-button';
- }
+ $attrs = array( 'class' => $className )
+ + Linker::tooltipAndAccesskeyAttribs( 'compareselectedversions' );
$this->buttons .= $this->submitButton( $this->msg( 'compareselectedversions' )->text(),
- array( 'class' => $className )
- + Linker::tooltipAndAccesskeyAttribs( 'compareselectedversions' )
+ $attrs
) . "\n";
if ( $this->getUser()->isAllowed( 'deleterevision' ) ) {
function submitButton( $message, $attributes = array() ) {
# Disable submit button if history has 1 revision only
if ( $this->getNumRows() > 1 ) {
- return Xml::submitButton( $message, $attributes );
+ return Html::submitButton( $message, $attributes );
} else {
return '';
}
array( 'autofocus' => true, 'class' => 'mw-ui-input-inline' )
);
- if ( $this->getConfig()->get( 'UseMediaWikiUIEverywhere' ) ) {
- $form .= ' ' . Xml::submitButton(
- $this->msg( 'booksources-search' )->text(),
- array( 'class' => 'mw-ui-button mw-ui-progressive' )
- ) . "</p>\n";
- } else {
- $form .= ' ' . Xml::submitButton(
- $this->msg( 'booksources-search' )->text()
- ) . "</p>\n";
- }
+ $form .= ' ' . Html::submitButton(
+ $this->msg( 'booksources-search' )->text(),
+ array(), array( 'mw-ui-progressive' )
+ ) . "</p>\n";
$form .= Html::closeElement( 'form' ) . "\n";
$form .= Html::closeElement( 'fieldset' ) . "\n";
}
public function getStartForm( $from ) {
- $submitClassName = '';
- if ( $this->getConfig( 'UseMediaWikiUIEverywhere' ) ) {
- $submitClassName = 'mw-ui-button mw-ui-progressive';
- }
return Xml::tags(
'form',
array( 'method' => 'get', 'action' => wfScript() ),
$this->msg( 'categoriesfrom' )->text(),
'from', 'from', 20, $from, array( 'class' => 'mw-ui-input-inline' ) ) .
' ' .
- Xml::submitButton(
+ Html::submitButton(
$this->msg( 'allpagessubmit' )->text(),
- array( 'class' => $submitClassName )
+ array(), array( 'mw-ui-progressive' )
)
)
);
$deletedOnlyCheck . $checkLabelTopOnly . $checkLabelNewOnly
);
- $className = 'mw-submit';
- if ( $this->getConfig( 'UseMediaWikiUIEverywhere') ) {
- $className .= ' mw-ui-button mw-ui-progressive';
- }
-
$dateSelectionAndSubmit = Xml::tags( 'td', array( 'colspan' => 2 ),
Xml::dateMenu(
$this->opts['year'] === '' ? MWTimestamp::getInstance()->format( 'Y' ) : $this->opts['year'],
$this->opts['month']
) . ' ' .
- Xml::submitButton(
+ Html::submitButton(
$this->msg( 'sp-contributions-submit' )->text(),
- array( 'class' => $className )
+ array( 'class' => 'mw-submit' ), array( 'mw-ui-progressive' )
)
);
'class' => 'mw-ui-input mw-ui-input-inline',
) ) . "\n";
$out .= Html::hidden( 'fulltext', 'Search' ) . "\n";
- $out .= Xml::submitButton(
+ $out .= Html::submitButton(
$this->msg( 'searchbutton' )->text(),
- array( 'class' => array( 'mw-ui-button', 'mw-ui-progressive' ) )
+ array(), array( 'mw-ui-progressive' )
) . "\n";
// Results-info
?>
<div class="mw-ui-vform-field mw-submit">
<?php
- echo Html::input(
- 'wpCreateaccount',
+ echo Html::submitButton(
$this->getMsg( $this->data['loggedin'] ? 'createacct-another-submit' : 'createacct-submit' ),
- 'submit',
- array(
- 'class' => "mw-ui-button mw-ui-big mw-ui-block mw-ui-constructive",
+ $attrs = array(
'id' => 'wpCreateaccount',
'tabindex' => $tabIndex++
+ ),
+ array(
+ 'mw-ui-big',
+ 'mw-ui-block',
+ 'mw-ui-constructive',
)
);
?>
<div class="mw-ui-vform-field">
<?php
- echo Html::input( 'wpLoginAttempt', $this->getMsg( 'pt-login-button' )->text(), 'submit', array(
+ $attrs = array(
'id' => 'wpLoginAttempt',
'tabindex' => '6',
- 'class' => 'mw-ui-button mw-ui-big mw-ui-block mw-ui-constructive'
- ) );
+ );
+ $modifiers = array(
+ 'mw-ui-big', 'mw-ui-block', 'mw-ui-constructive',
+ );
+ echo Html::submitButton( $this->getMsg( 'pt-login-button' )->text(), $attrs, $modifiers );
?>
</div>