|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 if (!defined('MOODLE_INTERNAL')) { 00003 die('Direct access to this script is forbidden.'); 00004 } 00005 00006 global $CFG; 00007 require_once($CFG->libdir.'/form/password.php'); 00008 00015 class MoodleQuickForm_passwordunmask extends MoodleQuickForm_password { 00016 00017 function MoodleQuickForm_passwordunmask($elementName=null, $elementLabel=null, $attributes=null) { 00018 global $CFG; 00019 if (empty($CFG->xmlstrictheaders)) { 00020 // no standard mform in moodle should allow autocomplete of passwords 00021 // this is valid attribute in html5, sorry, we have to ignore validation errors in legacy xhtml 1.0 00022 if (empty($attributes)) { 00023 $attributes = array('autocomplete'=>'off'); 00024 } else if (is_array($attributes)) { 00025 $attributes['autocomplete'] = 'off'; 00026 } else { 00027 if (strpos($attributes, 'autocomplete') === false) { 00028 $attributes .= ' autocomplete="off" '; 00029 } 00030 } 00031 } 00032 parent::MoodleQuickForm_password($elementName, $elementLabel, $attributes); 00033 } 00034 00035 function toHtml() { 00036 global $PAGE; 00037 00038 if ($this->_flagFrozen) { 00039 return $this->getFrozenHtml(); 00040 } else { 00041 $unmask = get_string('unmaskpassword', 'form'); 00042 //Pass id of the element, so that unmask checkbox can be attached. 00043 $PAGE->requires->yui_module('moodle-form-passwordunmask', 'M.form.passwordunmask', 00044 array(array('formid' => $this->getAttribute('id'), 'checkboxname' => $unmask))); 00045 return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' />'; 00046 } 00047 } //end func toHtml 00048 00049 }