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() {
|
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() .
|
|
|
|
"\" maxlength=\"$this->maxLength\" size=\"$this->maxLength\"/>";
|
|
|
|
} else {
|
|
|
|
return "<input class=\"text\" type=\"password\" id=\"" . $this->id() .
|
|
|
|
"\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" />";
|
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);
|
|
|
|
return $field;
|
|
|
|
}
|
|
|
|
}
|
2007-09-15 23:38:05 +02:00
|
|
|
|
2007-11-12 03:58:27 +01:00
|
|
|
?>
|