Automatic installer lang files (20110214)
[moodle.git] / lib / form / passwordunmask.php
blobb70f0d51f39f70dd71efd11e9220c78c086b2a30
1 <?php
2 if (!defined('MOODLE_INTERNAL')) {
3 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
6 global $CFG;
7 require_once($CFG->libdir.'/form/password.php');
9 /**
10 * HTML class for a password type element with unmask option
12 * @author Petr Skoda
13 * @access public
15 class MoodleQuickForm_passwordunmask extends MoodleQuickForm_password {
17 function MoodleQuickForm_passwordunmask($elementName=null, $elementLabel=null, $attributes=null) {
18 parent::MoodleQuickForm_password($elementName, $elementLabel, $attributes);
21 function toHtml() {
22 global $CFG;
23 if ($this->_flagFrozen) {
24 return $this->getFrozenHtml();
25 } else {
26 $id = $this->getAttribute('id');
27 $unmask = get_string('unmaskpassword', 'form');
28 $unmaskjs = html_writer::script(js_writer::set_variable('punmask', array('id'=>$id, 'unmaskstr'=>$unmask)));
29 $unmaskjs .= html_writer::script('', $CFG->httpswwwroot.'/lib/form/passwordunmask.js');
30 return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' /><div class="unmask" id="'.$id.'unmaskdiv"></div>'.$unmaskjs;
32 } //end func toHtml