Reconcept cl_raw_sortkey as cl_sortkey_prefix
[lhc/web/wiklou.git] / includes / HTMLForm.php
index 78c3794..cbd73a4 100644 (file)
@@ -23,7 +23,7 @@
  *                                through HTMLForm::$typeMappings to get the class name.
  *      'default'  -- default value when the form is displayed
  *      'id'       -- HTML id attribute
- *   'cssclass' -- CSS class
+ *      'cssclass' -- CSS class
  *      'options'  -- varies according to the specific object.
  *      'label-message' -- message key for a message to use as the label.
  *                                can be an array of msg key and then parameters to
@@ -587,7 +587,7 @@ class HTMLForm {
                                        : $value->getDefault();
                                $tableHtml .= $value->getTableRow( $v );
 
-                               if ( $value->getLabel() != ' ' )
+                               if ( $value->getLabel() != ' ' )
                                        $hasLeftColumn = true;
                        } elseif ( is_array( $value ) ) {
                                $section = $this->displaySection( $value, $key );
@@ -812,6 +812,14 @@ abstract class HTMLFormField {
                global $wgRequest;
 
                $errors = $this->validate( $value, $this->mParent->mFieldData );
+               
+               $cellAttributes = array();
+               $verticalLabel = false;
+               
+               if ( !empty($this->mParams['vertical-label']) ) {
+                       $cellAttributes['colspan'] = 2;
+                       $verticalLabel = true;
+               }
 
                if ( $errors === true || !$wgRequest->wasPosted() ) {
                        $errors = '';
@@ -819,20 +827,26 @@ abstract class HTMLFormField {
                        $errors = Html::rawElement( 'span', array( 'class' => 'error' ), $errors );
                }
 
-               $html = $this->getLabelHtml();
-               $html .= Html::rawElement(
+               $label = $this->getLabelHtml( $cellAttributes );
+               $field = Html::rawElement(
                        'td',
-                       array( 'class' => 'mw-input' ),
+                       array( 'class' => 'mw-input' ) + $cellAttributes,
                        $this->getInputHTML( $value ) . "\n$errors"
                );
-
+               
                $fieldType = get_class( $this );
-
-               $html = Html::rawElement(
-                       'tr',
-                       array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass}" ),
-                       $html
-               ) . "\n";
+               
+               if ($verticalLabel) {
+                       $html = Html::rawElement( 'tr',
+                               array( 'class' => 'mw-htmlform-vertical-label' ), $label );
+                       $html .= Html::rawElement( 'tr',
+                               array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass}" ),
+                               $field );
+               } else {
+                       $html = Html::rawElement( 'tr',
+                               array( 'class' => "mw-htmlform-field-$fieldType {$this->mClass}" ),
+                               $label . $field );
+               }
 
                $helptext = null;
 
@@ -860,7 +874,7 @@ abstract class HTMLFormField {
        function getLabel() {
                return $this->mLabel;
        }
-       function getLabelHtml() {
+       function getLabelHtml( $cellAttributes = array() ) {
                # Don't output a for= attribute for labels with no associated input.
                # Kind of hacky here, possibly we don't want these to be <label>s at all.
                $for = array();
@@ -869,7 +883,7 @@ abstract class HTMLFormField {
                        $for['for'] = $this->mID;
                }
 
-               return Html::rawElement( 'td', array( 'class' => 'mw-label' ),
+               return Html::rawElement( 'td', array( 'class' => 'mw-label' ) + $cellAttributes,
                        Html::rawElement( 'label', $for, $this->getLabel() )
                );
        }
@@ -1133,7 +1147,7 @@ class HTMLCheckField extends HTMLFormField {
                        $attr['disabled'] = 'disabled';
                }
 
-               return Xml::check( $this->mName, $value, $attr ) . '&nbsp;' .
+               return Xml::check( $this->mName, $value, $attr ) . '&#160;' .
                        Html::rawElement( 'label', array( 'for' => $this->mID ), $this->mLabel );
        }
 
@@ -1142,7 +1156,7 @@ class HTMLCheckField extends HTMLFormField {
         * added in getInputHTML(), rather than HTMLFormField::getRow()
         */
        function getLabel() {
-               return '&nbsp;';
+               return '&#160;';
        }
 
        function loadDataFromRequest( $request ) {
@@ -1333,7 +1347,7 @@ class HTMLMultiSelectField extends HTMLFormField {
 
                                $checkbox = Xml::check( $this->mName . '[]', in_array( $info, $value, true ),
                                                                $attribs + $thisAttribs );
-                               $checkbox .= '&nbsp;' . Html::rawElement( 'label', array( 'for' => $this->mID . "-$info" ), $label );
+                               $checkbox .= '&#160;' . Html::rawElement( 'label', array( 'for' => $this->mID . "-$info" ), $label );
 
                                $html .= $checkbox . '<br />';
                        }
@@ -1425,7 +1439,7 @@ class HTMLRadioField extends HTMLFormField {
                                        $info == $value,
                                        $attribs + array( 'id' => $id )
                                );
-                               $html .= '&nbsp;' .
+                               $html .= '&#160;' .
                                                Html::rawElement( 'label', array( 'for' => $id ), $label );
 
                                $html .= "<br />\n";