Merge "ApiQueryAllUsers: Set 'array' type on result arrays"
[lhc/web/wiklou.git] / includes / htmlform / HTMLFormField.php
index a91f331..0c3fe44 100644 (file)
@@ -10,9 +10,11 @@ abstract class HTMLFormField {
        protected $mValidationCallback;
        protected $mFilterCallback;
        protected $mName;
+       protected $mDir;
        protected $mLabel; # String label.  Set on construction
        protected $mID;
        protected $mClass = '';
+       protected $mVFormClass = '';
        protected $mHelpClass = false;
        protected $mDefault;
        protected $mOptions = false;
@@ -376,6 +378,10 @@ abstract class HTMLFormField {
                        $this->mName = $params['name'];
                }
 
+               if ( isset( $params['dir'] ) ) {
+                       $this->mDir = $params['dir'];
+               }
+
                $validName = Sanitizer::escapeId( $this->mName );
                $validName = str_replace( array( '.5B', '.5D' ), array( '[', ']' ), $validName );
                if ( $this->mName != $validName && !isset( $params['nodata'] ) ) {
@@ -512,10 +518,7 @@ abstract class HTMLFormField {
                        array( 'class' => $outerDivClass ) + $cellAttributes,
                        $inputHtml . "\n$errors"
                );
-               $divCssClasses = array( "mw-htmlform-field-$fieldType", $this->mClass, $errorClass );
-               if ( $this->mParent->isVForm() ) {
-                       $divCssClasses[] = 'mw-ui-vform-field';
-               }
+               $divCssClasses = array( "mw-htmlform-field-$fieldType", $this->mClass, $this->mVFormClass, $errorClass );
 
                $wrapperAttributes = array(
                        'class' => $divCssClasses,
@@ -554,6 +557,41 @@ abstract class HTMLFormField {
                return $html;
        }
 
+       /**
+        * Get the complete field for the input, including help text,
+        * labels, and whatever. Fall back from 'vform' to 'div' when not overridden.
+        *
+        * @since 1.25
+        * @param string $value The value to set the input to.
+        * @return string Complete HTML field.
+        */
+       public function getVForm( $value ) {
+               // Ewwww
+               $this->mVFormClass = ' mw-ui-vform-field';
+               return $this->getDiv( $value );
+       }
+
+       /**
+        * Get the complete field as an inline element.
+        * @since 1.25
+        * @param string $value The value to set the input to.
+        * @return string Complete HTML inline element
+        */
+       public function getInline( $value ) {
+               list( $errors, $errorClass ) = $this->getErrorsAndErrorClass( $value );
+               $inputHtml = $this->getInputHTML( $value );
+               $helptext = $this->getHelpTextHtmlDiv( $this->getHelpText() );
+               $cellAttributes = array();
+               $label = $this->getLabelHtml( $cellAttributes );
+
+               $html = "\n" . $errors .
+                       $label . ' ' .
+                       $inputHtml .
+                       $helptext;
+
+               return $html;
+       }
+
        /**
         * Generate help text HTML in table format
         * @since 1.20