10 defined(
'JPATH_PLATFORM') or die;
30 protected $type =
'Password';
38 protected $threshold = 66;
54 protected $meter =
false;
65 public function __get($name)
75 return parent::__get($name);
88 public function __set($name, $value)
90 $value = (string) $value;
96 $this->$name = $value;
100 $this->$meter = ($value ===
'true' || $value === $name || $value ===
'1');
104 parent::__set($name, $value);
122 public function setup(SimpleXMLElement $element, $value, $group = null)
124 $return = parent::setup($element, $value, $group);
128 $this->maxLength = $this->element[
'maxlength'] ? (int) $this->element[
'maxlength'] : 99;
129 $this->threshold = $this->element[
'threshold'] ? (int) $this->element[
'threshold'] : 66;
131 $meter = (string) $this->element[
'strengthmeter'];
132 $this->meter = ($meter ==
'true' || $meter ==
'on' || $meter ==
'1');
145 protected function getInput()
148 $hint = $this->translateHint ?
JText::_($this->hint) : $this->hint;
151 $size = !empty($this->size) ?
' size="' . $this->size .
'"' :
'';
152 $maxLength = !empty($this->maxLength) ?
' maxlength="' . $this->maxLength .
'"' :
'';
153 $class = !empty($this->
class) ?
' class="' . $this->
class . '"' : '';
154 $readonly = $this->readonly ? ' readonly' : '';
155 $disabled = $this->disabled ? ' disabled' : '';
156 $required = $this->required ? ' required aria-required="true"' : '';
157 $hint = $hint ? ' placeholder="' . $hint . '"' : '';
158 $autocomplete = !$this->autocomplete ? ' autocomplete="off"' : '';
159 $autofocus = $this->autofocus ? ' autofocus' : '';
163 JHtml::_(
'script',
'system/passwordstrength.js',
true,
true);
164 $script =
'new Form.PasswordStrength("' . $this->
id .
'",
166 threshold: ' . $this->threshold .
',
167 onUpdate: function(element, strength, threshold) {
168 element.set("data-passwordstrength", strength);
175 "jQuery(document).ready(function(){" . $script .
"});"
180 JHtml::_(
'jquery.framework');
181 JHtml::_(
'script',
'system/html5fallback.js',
false,
true);
183 return '<input type="password" name="' . $this->name .
'" id="' . $this->
id .
'"' .
184 ' value="' . htmlspecialchars($this->value, ENT_COMPAT,
'UTF-8') .
'"' . $hint . $autocomplete .
185 $class . $readonly . $disabled . $size . $maxLength . $required . $autofocus .
' />';