r106911 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106910‎ | r106911 | r106912 >
Date:01:10, 21 December 2011
Author:jeroendedauw
Status:ok (Comments)
Tags:
Comment:
actually use the flipping cssclass arg, so its possible to set a css class without creating your own input field type class
Modified paths:
  • /trunk/phase3/includes/HTMLForm.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HTMLForm.php
@@ -1174,6 +1174,10 @@
11751175 'value' => $value,
11761176 ) + $this->getTooltipAndAccessKey();
11771177
 1178+ if ( $this->mClass !== '' ) {
 1179+ $attribs['class'] = $this->mClass;
 1180+ }
 1181+
11781182 if ( isset( $this->mParams['maxlength'] ) ) {
11791183 $attribs['maxlength'] = $this->mParams['maxlength'];
11801184 }
@@ -1244,7 +1248,10 @@
12451249 'rows' => $this->getRows(),
12461250 ) + $this->getTooltipAndAccessKey();
12471251
1248 -
 1252+ if ( $this->mClass !== '' ) {
 1253+ $attribs['class'] = $this->mClass;
 1254+ }
 1255+
12491256 if ( !empty( $this->mParams['disabled'] ) ) {
12501257 $attribs['disabled'] = 'disabled';
12511258 }
@@ -1351,6 +1358,10 @@
13521359 if ( !empty( $this->mParams['disabled'] ) ) {
13531360 $attr['disabled'] = 'disabled';
13541361 }
 1362+
 1363+ if ( $this->mClass !== '' ) {
 1364+ $attr['class'] = $this->mClass;
 1365+ }
13551366
13561367 return Xml::check( $this->mName, $value, $attr ) . ' ' .
13571368 Html::rawElement( 'label', array( 'for' => $this->mID ), $this->mLabel );
@@ -1428,6 +1439,10 @@
14291440 if ( !empty( $this->mParams['disabled'] ) ) {
14301441 $select->setAttribute( 'disabled', 'disabled' );
14311442 }
 1443+
 1444+ if ( $this->mClass !== '' ) {
 1445+ $select->setAttribute( 'class', $this->mClass );
 1446+ }
14321447
14331448 $select->addOptions( $this->mParams['options'] );
14341449
@@ -1489,6 +1504,10 @@
14901505 if ( isset( $this->mParams['maxlength'] ) ) {
14911506 $tbAttribs['maxlength'] = $this->mParams['maxlength'];
14921507 }
 1508+
 1509+ if ( $this->mClass !== '' ) {
 1510+ $tbAttribs['class'] = $this->mClass;
 1511+ }
14931512
14941513 $textbox = Html::input(
14951514 $this->mName . '-other',
@@ -1712,6 +1731,10 @@
17131732 'id' => $this->mID . '-other',
17141733 'size' => $this->getSize(),
17151734 );
 1735+
 1736+ if ( $this->mClass !== '' ) {
 1737+ $textAttribs['class'] = $this->mClass;
 1738+ }
17161739
17171740 foreach ( array( 'required', 'autofocus', 'multiple', 'disabled' ) as $param ) {
17181741 if ( isset( $this->mParams[$param] ) ) {
@@ -1941,7 +1964,7 @@
19421965 return Xml::submitButton(
19431966 $value,
19441967 array(
1945 - 'class' => 'mw-htmlform-submit',
 1968+ 'class' => 'mw-htmlform-submit ' . $this->mClass,
19461969 'name' => $this->mName,
19471970 'id' => $this->mID,
19481971 )

Comments

#Comment by Duplicatebug (talk | contribs)   20:37, 21 December 2011
 			array(
-				'class' => 'mw-htmlform-submit',
+				'class' => 'mw-htmlform-submit ' . $this->mClass,
 				'name' => $this->mName,

In my opinion it s not good style, to have the space always there.

#Comment by Krinkle (talk | contribs)   11:31, 2 January 2012

if you use a function from the Html class instead of the Xml class, then the "class" attribute takes an array, which makes this problem go away.

#Comment by Hashar (talk | contribs)   11:24, 3 January 2012

I wish we could avoid code duplication :-)

Status & tagging log