password.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3. /**
  4. * HTML class for a password type field
  5. *
  6. * PHP versions 4 and 5
  7. *
  8. * LICENSE: This source file is subject to version 3.01 of the PHP license
  9. * that is available through the world-wide-web at the following URI:
  10. * http://www.php.net/license/3_01.txt If you did not receive a copy of
  11. * the PHP License and are unable to obtain it through the web, please
  12. * send a note to license@php.net so we can mail you a copy immediately.
  13. *
  14. * @category HTML
  15. * @package HTML_QuickForm
  16. * @author Adam Daniel <adaniel1@eesus.jnj.com>
  17. * @author Bertrand Mansion <bmansion@mamasam.com>
  18. * @copyright 2001-2009 The PHP Group
  19. * @license http://www.php.net/license/3_01.txt PHP License 3.01
  20. * @version CVS: $Id: password.php,v 1.8 2009/04/04 21:34:04 avb Exp $
  21. * @link http://pear.php.net/package/HTML_QuickForm
  22. */
  23. /**
  24. * Base class for <input /> form elements
  25. */
  26. require_once 'HTML/QuickForm/input.php';
  27. /**
  28. * HTML class for a password type field
  29. *
  30. * @category HTML
  31. * @package HTML_QuickForm
  32. * @author Adam Daniel <adaniel1@eesus.jnj.com>
  33. * @author Bertrand Mansion <bmansion@mamasam.com>
  34. * @version Release: 3.2.11
  35. * @since 1.0
  36. */
  37. class HTML_QuickForm_password extends HTML_QuickForm_input
  38. {
  39. // {{{ constructor
  40. /**
  41. * Class constructor
  42. *
  43. * @param string $elementName (optional)Input field name attribute
  44. * @param string $elementLabel (optional)Input field label
  45. * @param mixed $attributes (optional)Either a typical HTML attribute string
  46. * or an associative array
  47. * @since 1.0
  48. * @access public
  49. * @return void
  50. * @throws
  51. */
  52. function HTML_QuickForm_password($elementName=null, $elementLabel=null, $attributes=null)
  53. {
  54. HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes);
  55. $this->setType('password');
  56. } //end constructor
  57. // }}}
  58. // {{{ setSize()
  59. /**
  60. * Sets size of password element
  61. *
  62. * @param string $size Size of password field
  63. * @since 1.0
  64. * @access public
  65. * @return void
  66. */
  67. function setSize($size)
  68. {
  69. $this->updateAttributes(array('size'=>$size));
  70. } //end func setSize
  71. // }}}
  72. // {{{ setMaxlength()
  73. /**
  74. * Sets maxlength of password element
  75. *
  76. * @param string $maxlength Maximum length of password field
  77. * @since 1.0
  78. * @access public
  79. * @return void
  80. */
  81. function setMaxlength($maxlength)
  82. {
  83. $this->updateAttributes(array('maxlength'=>$maxlength));
  84. } //end func setMaxlength
  85. // }}}
  86. // {{{ getFrozenHtml()
  87. /**
  88. * Returns the value of field without HTML tags (in this case, value is changed to a mask)
  89. *
  90. * @since 1.0
  91. * @access public
  92. * @return string
  93. * @throws
  94. */
  95. function getFrozenHtml()
  96. {
  97. $value = $this->getValue();
  98. return ('' != $value? '**********': '&nbsp;') .
  99. $this->_getPersistantData();
  100. } //end func getFrozenHtml
  101. // }}}
  102. } //end class HTML_QuickForm_password
  103. ?>