48 $info[
'nodata'] =
true;
52 parent::__construct( $info );
54 if ( isset( $info[
'flags'] ) ) {
55 $this->mFlags = $info[
'flags'];
58 if ( isset( $info[
'formnovalidate'] ) ) {
59 $this->mFormnovalidate = $info[
'formnovalidate'];
62 # Generate the label from a message, if possible
63 if ( isset( $info[
'buttonlabel-message'] ) ) {
64 $this->buttonLabel = $this->
getMessage( $info[
'buttonlabel-message'] )->parse();
65 } elseif ( isset( $info[
'buttonlabel'] ) ) {
66 if ( $info[
'buttonlabel'] ===
' ' || $info[
'buttonlabel'] ===
"\u{00A0}" ) {
68 $this->buttonLabel =
"\u{00A0}";
70 $this->buttonLabel = htmlspecialchars( $info[
'buttonlabel'] );
72 } elseif ( isset( $info[
'buttonlabel-raw'] ) ) {
73 $this->buttonLabel = $info[
'buttonlabel-raw'];
80 $prefix =
'mw-htmlform-';
81 foreach ( $this->mFlags as $flag ) {
82 $flags .=
' ' . $prefix . $flag;
85 'class' =>
'mw-htmlform-submit ' . $this->mClass . $flags,
93 return Html::rawElement(
'button', $attr,
94 $this->buttonLabel ?: htmlspecialchars( $this->
getDefault() ) );
104 return new \OOUI\ButtonInputWidget( [
105 'name' => $this->mName,
107 'label' => $this->buttonLabel
108 ?
new \OOUI\HtmlSnippet( $this->buttonLabel )
115 ] + \OOUI\Element::configFromHtmlAttributes(
122 $buttonClasses = [
'mw-htmlform-submit',
'cdx-button' ];
123 if ( isset( $this->mParams[
'size'] ) ) {
124 $codexSizeKeywords = [
'small',
'medium',
'large' ];
125 if ( !in_array( $this->mParams[
'size'], $codexSizeKeywords,
true ) ) {
126 throw new \InvalidArgumentException(
127 'Invalid size for button: "' . $this->mParams[
'size'] .
'". Please use one of the Codex keywords.'
131 $sizeClass =
'cdx-button--size-' . $this->mParams[
'size'];
132 $buttonClasses[] = $sizeClass;
137 'class' => $buttonClasses,
145 return static::buildCodexComponent(
168 'progressive' =>
'cdx-button--action-progressive',
169 'destructive' =>
'cdx-button--action-destructive',
170 'primary' =>
'cdx-button--weight-primary',
171 'quiet' =>
'cdx-button--weight-quiet',
174 foreach ( $flags as $flag ) {
175 if ( isset( $flagClassMap[$flag] ) ) {
176 $flagClasses[] = $flagClassMap[$flag];
180 $buttonClassesAndFlags = array_merge( $attribs[
'class' ], $flagClasses );
181 $attribs[
'class'] = $buttonClassesAndFlags;
183 $buttonHtml = Html::rawElement(
213class_alias( HTMLButtonField::class,
'HTMLButtonField' );