Allow password fields to be served by HTMLForm.
authorHappy-melon <happy-melon@users.mediawiki.org>
Sun, 6 Sep 2009 14:32:03 +0000 (14:32 +0000)
committerHappy-melon <happy-melon@users.mediawiki.org>
Sun, 6 Sep 2009 14:32:03 +0000 (14:32 +0000)
includes/HTMLForm.php

index 35fb020..1db26fe 100644 (file)
@@ -21,6 +21,7 @@ class HTMLForm {
                'int' => 'HTMLIntField',
                'float' => 'HTMLFloatField',
                'info' => 'HTMLInfoField',
+               'password' => 'HTMLPasswordField',
                'selectorother' => 'HTMLSelectOrOtherField',
                # HTMLTextField will output the correct type="" attribute automagically.
                # There are about four zillion other HTML 5 input types, like url, but
@@ -515,6 +516,9 @@ abstract class HTMLFormField {
 }
 
 class HTMLTextField extends HTMLFormField {
+       # Override in derived classes to use other Xml::... functions
+       protected $mFunction = 'input';
+       
        function getSize() {
                return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 45;
        }
@@ -562,7 +566,8 @@ class HTMLTextField extends HTMLFormField {
                        }
                }
 
-               return Xml::input(
+               $func = $this->mFunction;
+               return Xml::$func(
                        $this->mName,
                        $this->getSize(),
                        $value,
@@ -571,6 +576,10 @@ class HTMLTextField extends HTMLFormField {
        }
 }
 
+class HTMLPasswordField extends HTMLTextField {
+       protected $mFunction = 'password';
+}
+
 class HTMLFloatField extends HTMLTextField {
        function getSize() {
                return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 20;