Merge "Revert "Use display name in category page subheadings if provided""
[lhc/web/wiklou.git] / includes / htmlform / fields / HTMLMultiSelectField.php
index 38d231f..58de763 100644 (file)
@@ -10,6 +10,9 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
         *   - dropdown: If given, the options will be displayed inside a dropdown with a text field that
         *     can be used to filter them. This is desirable mostly for very long lists of options.
         *     This only works for users with JavaScript support and falls back to the list of checkboxes.
+        *   - flatlist: If given, the options will be displayed on a single line (wrapping to following
+        *     lines if necessary), rather than each one on a line of its own. This is desirable mostly
+        *     for very short lists of concisely labelled options.
         */
        public function __construct( $params ) {
                parent::__construct( $params );
@@ -18,9 +21,13 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
                if ( isset( $params['dropdown'] ) || strpos( $this->mClass, 'mw-chosen' ) !== false ) {
                        $this->mClass .= ' mw-htmlform-dropdown';
                }
+
+               if ( isset( $params['flatlist'] ) ) {
+                       $this->mClass .= ' mw-htmlform-flatlist';
+               }
        }
 
-       function validate( $value, $alldata ) {
+       public function validate( $value, $alldata ) {
                $p = parent::validate( $value, $alldata );
 
                if ( $p !== true ) {
@@ -43,7 +50,7 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
                }
        }
 
-       function getInputHTML( $value ) {
+       public function getInputHTML( $value ) {
                if ( isset( $this->mParams['dropdown'] ) ) {
                        $this->mParent->getOutput()->addModules( 'jquery.chosen' );
                }
@@ -54,7 +61,7 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
                return $html;
        }
 
-       function formatOptions( $options, $value ) {
+       public function formatOptions( $options, $value ) {
                $html = '';
 
                $attribs = $this->getAttributes( [ 'disabled', 'tabindex' ] );
@@ -113,6 +120,8 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
         * @return OOUI\CheckboxMultiselectInputWidget
         */
        public function getInputOOUI( $value ) {
+               $this->mParent->getOutput()->addModules( 'oojs-ui-widgets' );
+
                $attr = $this->getTooltipAndAccessKey();
                $attr['id'] = $this->mID;
                $attr['name'] = "{$this->mName}[]";
@@ -142,7 +151,7 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
         *
         * @return string
         */
-       function loadDataFromRequest( $request ) {
+       public function loadDataFromRequest( $request ) {
                if ( $this->isSubmitAttempt( $request ) ) {
                        // Checkboxes are just not added to the request arrays if they're not checked,
                        // so it's perfectly possible for there not to be an entry at all
@@ -153,7 +162,7 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
                }
        }
 
-       function getDefault() {
+       public function getDefault() {
                if ( isset( $this->mDefault ) ) {
                        return $this->mDefault;
                } else {
@@ -161,7 +170,7 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
                }
        }
 
-       function filterDataForSubmit( $data ) {
+       public function filterDataForSubmit( $data ) {
                $data = HTMLFormField::forceToStringRecursive( $data );
                $options = HTMLFormField::flattenOptions( $this->getOptions() );