Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.
   1  <?php
   2  /* vim: set expandtab tabstop=4 shiftwidth=4: */
   3  // +----------------------------------------------------------------------+
   4  // | PHP version 4.0                                                      |
   5  // +----------------------------------------------------------------------+
   6  // | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group             |
   7  // +----------------------------------------------------------------------+
   8  // | This source file is subject to version 2.0 of the PHP license,       |
   9  // | that is bundled with this package in the file LICENSE, and is        |
  10  // | available at through the world-wide-web at                           |
  11  // | http://www.php.net/license/2_02.txt.                                 |
  12  // | If you did not receive a copy of the PHP license and are unable to   |
  13  // | obtain it through the world-wide-web, please send a note to          |
  14  // | license@php.net so we can mail you a copy immediately.               |
  15  // +----------------------------------------------------------------------+
  16  // | Authors: Adam Daniel <adaniel1@eesus.jnj.com>                        |
  17  // |          Bertrand Mansion <bmansion@mamasam.com>                     |
  18  // +----------------------------------------------------------------------+
  19  //
  20  // $Id$
  21  
  22  require_once("HTML/QuickForm/input.php");
  23  
  24  /**
  25   * HTML class for a password type field
  26   * 
  27   * @author       Adam Daniel <adaniel1@eesus.jnj.com>
  28   * @author       Bertrand Mansion <bmansion@mamasam.com>
  29   * @version      1.1
  30   * @since        PHP4.04pl1
  31   * @access       public
  32   */
  33  class HTML_QuickForm_password extends HTML_QuickForm_input
  34  {
  35      // {{{ constructor
  36  
  37      /**
  38       * Class constructor
  39       * 
  40       * @param     string    $elementName    (optional)Input field name attribute
  41       * @param     string    $elementLabel   (optional)Input field label
  42       * @param     mixed     $attributes     (optional)Either a typical HTML attribute string 
  43       *                                      or an associative array
  44       * @since     1.0
  45       * @access    public
  46       * @return    void
  47       * @throws    
  48       */
  49      public function __construct($elementName=null, $elementLabel=null, $attributes=null) {
  50          parent::__construct($elementName, $elementLabel, $attributes);
  51          $this->setType('password');
  52      } //end constructor
  53  
  54      /**
  55       * Old syntax of class constructor. Deprecated in PHP7.
  56       *
  57       * @deprecated since Moodle 3.1
  58       */
  59      public function HTML_QuickForm_password($elementName=null, $elementLabel=null, $attributes=null) {
  60          debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER);
  61          self::__construct($elementName, $elementLabel, $attributes);
  62      }
  63      
  64      // }}}
  65      // {{{ setSize()
  66  
  67      /**
  68       * Sets size of password element
  69       * 
  70       * @param     string    $size  Size of password field
  71       * @since     1.0
  72       * @access    public
  73       * @return    void
  74       */
  75      function setSize($size)
  76      {
  77          $this->updateAttributes(array('size'=>$size));
  78      } //end func setSize
  79  
  80      // }}}
  81      // {{{ setMaxlength()
  82  
  83      /**
  84       * Sets maxlength of password element
  85       * 
  86       * @param     string    $maxlength  Maximum length of password field
  87       * @since     1.0
  88       * @access    public
  89       * @return    void
  90       */
  91      function setMaxlength($maxlength)
  92      {
  93          $this->updateAttributes(array('maxlength'=>$maxlength));
  94      } //end func setMaxlength
  95          
  96      // }}}
  97      // {{{ getFrozenHtml()
  98  
  99      /**
 100       * Returns the value of field without HTML tags (in this case, value is changed to a mask)
 101       * 
 102       * @since     1.0
 103       * @access    public
 104       * @return    string
 105       * @throws    
 106       */
 107      function getFrozenHtml()
 108      {
 109          $value = $this->getValue();
 110          return ('' != $value? '**********': '&nbsp;') .
 111                 $this->_getPersistantData();
 112      } //end func getFrozenHtml
 113  
 114      // }}}
 115  
 116  } //end class HTML_QuickForm_password
 117  ?>