return self::openElement( $element, $attribs ) . $contents . "</$element>";
}
- /**
- * Build a drop-down box for selecting a namespace
- *
- * @param string $selected Namespace which should be pre-selected
- * @param string|null $all Value of an item denoting all namespaces, or null to omit
- * @param string $element_name Value of the "name" attribute of the select tag
- * @param string $label Optional label to add to the field
- * @return string
- * @deprecated since 1.19
- */
- public static function namespaceSelector( $selected = '', $all = null,
- $element_name = 'namespace', $label = null
- ) {
- wfDeprecated( __METHOD__, '1.19' );
- return Html::namespaceSelector( array(
- 'selected' => $selected,
- 'all' => $all,
- 'label' => $label,
- ), array(
- 'name' => $element_name,
- 'id' => 'namespace',
- 'class' => 'namespaceselector',
- ) );
- }
-
/**
* Create a date selector
*
* @param string $inLanguage The ISO code of the language to display the select list in (optional)
* @param array $overrideAttrs Override the attributes of the select tag (since 1.20)
* @param Message|null $msg Label message key (since 1.20)
- * @return array containing 2 items: label HTML and select list HTML
+ * @return array Array containing 2 items: label HTML and select list HTML
*/
public static function languageSelector( $selected, $customisedOnly = true,
$inLanguage = null, $overrideAttrs = array(), Message $msg = null
$attributes['value'] = $value;
}
- return self::element( 'input', $attributes + $attribs );
+ return self::element( 'input',
+ Html::getTextInputAttributes( $attributes + $attribs ) );
}
/**
* @return string HTML
*/
public static function checkLabel( $label, $name, $id, $checked = false, $attribs = array() ) {
- return self::check( $name, $checked, array( 'id' => $id ) + $attribs ) .
+ global $wgUseMediaWikiUIEverywhere;
+ $chkLabel = self::check( $name, $checked, array( 'id' => $id ) + $attribs ) .
' ' .
self::label( $label, $id, $attribs );
+
+ if ( $wgUseMediaWikiUIEverywhere ) {
+ $chkLabel = self::openElement( 'div', array( 'class' => 'mw-ui-checkbox' ) ) .
+ $chkLabel . self::closeElement( 'div' );
+ }
+ return $chkLabel;
}
/**
/**
* Convenience function to build an HTML submit button
+ * When $wgUseMediaWikiUIEverywhere is true it will default to a constructive button
* @param string $value Label text for the button
* @param array $attribs Optional custom attributes
* @return string HTML
*/
public static function submitButton( $value, $attribs = array() ) {
- return Html::element( 'input', array( 'type' => 'submit', 'value' => $value ) + $attribs );
+ global $wgUseMediaWikiUIEverywhere;
+ $baseAttrs = array(
+ 'type' => 'submit',
+ 'value' => $value,
+ );
+ // Done conditionally for time being as it is possible
+ // some submit forms
+ // might need to be mw-ui-destructive (e.g. delete a page)
+ if ( $wgUseMediaWikiUIEverywhere ) {
+ $baseAttrs['class'] = 'mw-ui-button mw-ui-constructive';
+ }
+ // Any custom attributes will take precendence of anything in baseAttrs e.g. override the class
+ $attribs = $attribs + $baseAttrs;
+ return Html::element( 'input', $attribs );
}
/**
*/
public static function textarea( $name, $content, $cols = 40, $rows = 5, $attribs = array() ) {
return self::element( 'textarea',
- array(
- 'name' => $name,
- 'id' => $name,
- 'cols' => $cols,
- 'rows' => $rows
- ) + $attribs,
+ Html::getTextInputAttributes(
+ array(
+ 'name' => $name,
+ 'id' => $name,
+ 'cols' => $cols,
+ 'rows' => $rows
+ ) + $attribs
+ ),
$content, false );
}