2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2007-09-15 23:38:05 +02:00
|
|
|
* Password input field.
|
2008-01-09 05:18:36 +01:00
|
|
|
* @package forms
|
|
|
|
* @subpackage fields-formattedinput
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
|
|
|
class PasswordField extends FormField {
|
2007-09-15 23:38:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* maxlength of the password field
|
|
|
|
*
|
|
|
|
* @var int
|
|
|
|
*/
|
2007-07-19 12:40:28 +02:00
|
|
|
protected $maxLength;
|
2007-09-15 23:38:05 +02:00
|
|
|
|
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
/**
|
2007-09-15 23:38:05 +02:00
|
|
|
* Returns an input field, class="text" and type="text" with an optional
|
|
|
|
* maxlength
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
2007-09-15 23:38:05 +02:00
|
|
|
function __construct($name, $title = null, $value = "", $maxLength = null) {
|
2007-07-19 12:40:28 +02:00
|
|
|
$this->maxLength = $maxLength;
|
2007-09-15 23:38:05 +02:00
|
|
|
parent::__construct($name, $title, $value);
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
2007-09-15 23:38:05 +02:00
|
|
|
|
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
function Field() {
|
2009-04-29 01:55:53 +02:00
|
|
|
$disabled = $this->isDisabled()?"disabled=\"disabled\"":"";
|
|
|
|
$readonly = $this->isReadonly()?"readonly=\"readonly\"":"";
|
2007-09-15 23:38:05 +02:00
|
|
|
if($this->maxLength) {
|
|
|
|
return "<input class=\"text\" type=\"password\" id=\"" . $this->id() .
|
|
|
|
"\" name=\"{$this->name}\" value=\"" . $this->attrValue() .
|
2009-04-29 01:55:53 +02:00
|
|
|
"\" maxlength=\"$this->maxLength\" size=\"$this->maxLength\" $disabled $readonly />";
|
2007-09-15 23:38:05 +02:00
|
|
|
} else {
|
|
|
|
return "<input class=\"text\" type=\"password\" id=\"" . $this->id() .
|
2009-04-29 01:55:53 +02:00
|
|
|
"\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" $disabled $readonly />";
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
|
|
|
}
|
2007-09-15 23:38:05 +02:00
|
|
|
|
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
/**
|
2007-09-15 23:38:05 +02:00
|
|
|
* Makes a pretty readonly field with some stars in it
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
|
|
|
function performReadonlyTransformation() {
|
2007-09-15 23:38:05 +02:00
|
|
|
$stars = '*****';
|
|
|
|
|
|
|
|
$field = new ReadonlyField($this->name, $this->title ? $this->title : '', $stars);
|
2007-07-19 12:40:28 +02:00
|
|
|
$field->setForm($this->form);
|
2008-08-12 04:58:48 +02:00
|
|
|
$field->setReadonly(true);
|
2007-07-19 12:40:28 +02:00
|
|
|
return $field;
|
|
|
|
}
|
|
|
|
}
|
2007-09-15 23:38:05 +02:00
|
|
|
|
2009-02-02 00:49:53 +01:00
|
|
|
?>
|