Merge "Remove unused $entryPoint from Preferences::tryFormSubmit"
[lhc/web/wiklou.git] / includes / htmlform / HTMLFormField.php
index eeed907..dcdba1e 100644 (file)
@@ -484,6 +484,30 @@ abstract class HTMLFormField {
                return Linker::tooltipAndAccesskeyAttribs( $this->mParams['tooltip'] );
        }
 
+       /**
+        * Returns the given attributes from the parameters
+        *
+        * @param array $list List of attributes to get
+        * @return array Attributes
+        */
+       public function getAttributes( array $list ) {
+               static $boolAttribs = array( 'disabled', 'required', 'autofocus', 'multiple', 'readonly' );
+
+               $ret = array();
+
+               foreach ( $list as $key ) {
+                       if ( in_array( $key, $boolAttribs ) ) {
+                               if ( !empty( $this->mParams[$key] ) ) {
+                                       $ret[$key] = '';
+                               }
+                       } elseif ( isset( $this->mParams[$key] ) ) {
+                               $ret[$key] = $this->mParams[$key];
+                       }
+               }
+
+               return $ret;
+       }
+
        /**
         * flatten an array of options to a single array, for instance,
         * a set of "<options>" inside "<optgroups>".