r68909 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68908‎ | r68909 | r68910 >
Date:21:20, 2 July 2010
Author:werdna
Status:resolved (Comments)
Tags:
Comment:
Add vertical-label option to HTMLForm, for CommunityHiring
Modified paths:
  • /trunk/phase3/includes/HTMLForm.php (modified) (history)
  • /trunk/phase3/skins/common/shared.css (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/shared.css
@@ -116,6 +116,10 @@
117117 width: 0 !important;
118118 }
119119
 120+tr.mw-htmlform-vertical-label td.mw-label {
 121+ text-align: left !important;
 122+}
 123+
120124 input#wpSummary {
121125 width: 80%;
122126 }
Index: trunk/phase3/includes/HTMLForm.php
@@ -23,7 +23,7 @@
2424 * through HTMLForm::$typeMappings to get the class name.
2525 * 'default' -- default value when the form is displayed
2626 * 'id' -- HTML id attribute
27 - * 'cssclass' -- CSS class
 27+ * 'cssclass' -- CSS class
2828 * 'options' -- varies according to the specific object.
2929 * 'label-message' -- message key for a message to use as the label.
3030 * can be an array of msg key and then parameters to
@@ -812,6 +812,14 @@
813813 global $wgRequest;
814814
815815 $errors = $this->validate( $value, $this->mParent->mFieldData );
 816+
 817+ $cellAttributes = array();
 818+ $verticalLabel = false;
 819+
 820+ if ( !empty($this->mParams['vertical-label']) ) {
 821+ $cellAttributes['colspan'] = 2;
 822+ $verticalLabel = true;
 823+ }
816824
817825 if ( $errors === true || !$wgRequest->wasPosted() ) {
818826 $errors = '';
@@ -819,18 +827,30 @@
820828 $errors = Html::rawElement( 'span', array( 'class' => 'error' ), $errors );
821829 }
822830
823 - $html = $this->getLabelHtml();
824 - $html .= Html::rawElement(
 831+ $label = $this->getLabelHtml( $cellAttributes );
 832+ $field = Html::rawElement(
825833 'td',
826 - array( 'class' => 'mw-input' ),
 834+ array( 'class' => 'mw-input' ) + $cellAttributes,
827835 $this->getInputHTML( $value ) . "\n$errors"
828836 );
829 -
 837+
830838 $fieldType = get_class( $this );
 839+
 840+ if ($verticalLabel) {
 841+ $html = Html::rawElement( 'tr',
 842+ array( 'class' => 'mw-htmlform-vertical-label' ), $label );
 843+ $html .= Html::rawElement( 'tr',
 844+ array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass}" ),
 845+ $field );
 846+ } else {
 847+ $html = Html::rawElement( 'tr',
 848+ array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass}" ),
 849+ $label . $field );
 850+ }
831851
832852 $html = Html::rawElement(
833853 'tr',
834 - array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass}" ),
 854+ array( ),
835855 $html
836856 ) . "\n";
837857
@@ -860,7 +880,7 @@
861881 function getLabel() {
862882 return $this->mLabel;
863883 }
864 - function getLabelHtml() {
 884+ function getLabelHtml( $cellAttributes = array() ) {
865885 # Don't output a for= attribute for labels with no associated input.
866886 # Kind of hacky here, possibly we don't want these to be <label>s at all.
867887 $for = array();
@@ -869,7 +889,7 @@
870890 $for['for'] = $this->mID;
871891 }
872892
873 - return Html::rawElement( 'td', array( 'class' => 'mw-label' ),
 893+ return Html::rawElement( 'td', array( 'class' => 'mw-label' ) + $cellAttributes,
874894 Html::rawElement( 'label', $for, $this->getLabel() )
875895 );
876896 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r68915Merge r68909, r68914werdna21:41, 2 July 2010

Comments

#Comment by Raymond (talk | contribs)   11:44, 3 July 2010

Seen on translatewiki:

PHP Strict Standards: Declaration of UploadSourceField::getLabelHtml() should be compatible with that of HTMLFormField::getLabelHtml() in /www/w/includes/specials/SpecialUpload.php on line 1085

#Comment by IAlex (talk | contribs)   13:59, 4 July 2010

This was fixed in r68944.

Status & tagging log