1: <?php
2:
3: /**
4: * This file contains the cHTMLPasswordbox class.
5: *
6: * @package Core
7: * @subpackage GUI_HTML
8: * @version SVN Revision $Rev:$
9: *
10: * @author Simon Sprankel
11: * @copyright four for business AG <www.4fb.de>
12: * @license http://www.contenido.org/license/LIZENZ.txt
13: * @link http://www.4fb.de
14: * @link http://www.contenido.org
15: */
16:
17: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
18:
19: /**
20: * cHTMLPasswordbox class represents a password form field.
21: *
22: * @package Core
23: * @subpackage GUI_HTML
24: */
25: class cHTMLPasswordbox extends cHTMLFormElement {
26:
27: /**
28: * Constructor.
29: * Creates an HTML password box.
30: *
31: * If no additional parameters are specified, the
32: * default width is 20 units.
33: *
34: * @param string $name
35: * Name of the element
36: * @param string $initvalue [optional]
37: * Initial value of the box
38: * @param int $width [optional]
39: * width of the text box
40: * @param int $maxlength [optional]
41: * maximum input length of the box
42: * @param string $id [optional]
43: * ID of the element
44: * @param string $disabled [optional]
45: * Item disabled flag (non-empty to set disabled)
46: * @param string $tabindex [optional]
47: * Tab index for form elements
48: * @param string $accesskey [optional]
49: * Key to access the field
50: * @param string $class [optional]
51: * the class of this element
52: */
53: public function __construct($name, $initvalue = '', $width = '', $maxlength = '', $id = '', $disabled = false, $tabindex = NULL, $accesskey = '', $class = '') {
54: parent::__construct($name, $id, $disabled, $tabindex, $accesskey);
55: $this->_tag = 'input';
56: $this->setValue($initvalue);
57:
58: $this->setWidth($width);
59: $this->setMaxLength($maxlength);
60:
61: $this->updateAttribute('type', 'password');
62: $this->setClass($class);
63: }
64:
65: /**
66: * Sets the width of the text box.
67: *
68: * @param int $width
69: * width of the text box
70: * @return cHTMLPasswordbox
71: * $this for chaining
72: */
73: public function setWidth($width) {
74: $width = intval($width);
75:
76: if ($width <= 0) {
77: $width = 20;
78: }
79:
80: return $this->updateAttribute('size', $width);
81: }
82:
83: /**
84: * Sets the maximum input length of the text box.
85: *
86: * @param int $maxlen
87: * maximum input length
88: * @return cHTMLPasswordbox
89: * $this for chaining
90: */
91: public function setMaxLength($maxlen) {
92: $maxlen = intval($maxlen);
93:
94: if ($maxlen <= 0) {
95: return $this->removeAttribute('maxlength');
96: } else {
97: return $this->updateAttribute('maxlength', $maxlen);
98: }
99: }
100:
101: /**
102: * Sets the initial value of the text box.
103: *
104: * @param string $value
105: * Initial value
106: * @return cHTMLPasswordbox
107: * $this for chaining
108: */
109: public function setValue($value) {
110: return $this->updateAttribute('value', $value);
111: }
112:
113: }
114: