Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / lib / form / passwordunmask.php
blobeb8cee941ffb1f485af5ef97579290f45046aa35
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 toHtml() {
18 if ($this->_flagFrozen) {
19 return $this->getFrozenHtml();
20 } else {
21 $id = $this->getAttribute('id');
22 $unmask = get_string('unmaskpassword', 'form');
23 $unmaskjs = '<script type="text/javascript">
24 //<![CDATA[
25 document.write(\'<div class="unmask"><input id="'.$id.'unmask" value="1" type="checkbox" onclick="unmaskPassword(\\\''.$id.'\\\')"/><label for="'.$id.'unmask">'.addslashes_js($unmask).'<\/label><\/div>\');
26 //]]>
27 </script>';
28 return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' />'.$unmaskjs;
30 } //end func toHtml