Merge "Skin: Make skins aware of their registered skin name"
[lhc/web/wiklou.git] / includes / htmlform / HTMLFormField.php
index 3f1c590..9c301e6 100644 (file)
@@ -631,7 +631,7 @@ abstract class HTMLFormField {
 
                // the element could specify, that the label doesn't need to be added
                $label = $this->getLabel();
-               if ( $label ) {
+               if ( $label && $label !== ' ' ) {
                        $config['label'] = new OOUI\HtmlSnippet( $label );
                }
 
@@ -660,6 +660,8 @@ abstract class HTMLFormField {
 
        /**
         * Get a FieldLayout (or subclass thereof) to wrap this field in when using OOUI output.
+        * @param string $inputField
+        * @param array $config
         * @return OOUI\FieldLayout|OOUI\ActionFieldLayout
         */
        protected function getFieldLayoutOOUI( $inputField, $config ) {
@@ -1074,33 +1076,8 @@ abstract class HTMLFormField {
                                $this->mOptionsLabelsNotFromMessage = true;
                                $this->mOptions = self::forceToStringRecursive( $this->mParams['options'] );
                        } elseif ( array_key_exists( 'options-message', $this->mParams ) ) {
-                               /** @todo This is copied from Xml::listDropDown(), deprecate/avoid duplication? */
                                $message = $this->getMessage( $this->mParams['options-message'] )->inContentLanguage()->plain();
-
-                               $optgroup = false;
-                               $this->mOptions = [];
-                               foreach ( explode( "\n", $message ) as $option ) {
-                                       $value = trim( $option );
-                                       if ( $value == '' ) {
-                                               continue;
-                                       } elseif ( substr( $value, 0, 1 ) == '*' && substr( $value, 1, 1 ) != '*' ) {
-                                               # A new group is starting...
-                                               $value = trim( substr( $value, 1 ) );
-                                               $optgroup = $value;
-                                       } elseif ( substr( $value, 0, 2 ) == '**' ) {
-                                               # groupmember
-                                               $opt = trim( substr( $value, 2 ) );
-                                               if ( $optgroup === false ) {
-                                                       $this->mOptions[$opt] = $opt;
-                                               } else {
-                                                       $this->mOptions[$optgroup][$opt] = $opt;
-                                               }
-                                       } else {
-                                               # groupless reason list
-                                               $optgroup = false;
-                                               $this->mOptions[$option] = $option;
-                                       }
-                               }
+                               $this->mOptions = Xml::listDropDownOptions( $message );
                        } else {
                                $this->mOptions = null;
                        }
@@ -1120,16 +1097,7 @@ abstract class HTMLFormField {
                        return null;
                }
 
-               $options = [];
-
-               foreach ( $oldoptions as $text => $data ) {
-                       $options[] = [
-                               'data' => (string)$data,
-                               'label' => (string)$text,
-                       ];
-               }
-
-               return $options;
+               return Xml::listDropDownOptionsOoui( $oldoptions );
        }
 
        /**