1: <?php
2:
3: /**
4: * This file contains the cHTMLTextarea 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: * cHTMLTextarea class represents a textarea.
21: *
22: * @package Core
23: * @subpackage GUI_HTML
24: */
25: class cHTMLTextarea extends cHTMLFormElement {
26:
27: protected $_value;
28:
29: /**
30: * Constructor.
31: * Creates an HTML text area.
32: *
33: * If no additional parameters are specified, the
34: * default width is 60 chars, and the height is 5 chars.
35: *
36: * @param string $name
37: * Name of the element
38: * @param string $initvalue [optional]
39: * Initial value of the textarea
40: * @param int $width [optional]
41: * width of the textarea
42: * @param int $height [optional]
43: * height of the textarea
44: * @param string $id [optional]
45: * ID of the element
46: * @param string $disabled [optional]
47: * Item disabled flag (non-empty to set disabled)
48: * @param string $tabindex [optional]
49: * Tab index for form elements
50: * @param string $accesskey [optional]
51: * Key to access the field
52: * @param string $class [optional]
53: * the class of this element
54: */
55: public function __construct($name, $initvalue = '', $width = '', $height = '', $id = '', $disabled = false, $tabindex = NULL, $accesskey = '', $class = '') {
56: parent::__construct($name, $id, $disabled, $tabindex, $accesskey);
57: $this->_tag = 'textarea';
58: $this->setValue($initvalue);
59: $this->_contentlessTag = false;
60: $this->setWidth($width);
61: $this->setHeight($height);
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 cHTMLTextarea
71: * $this for chaining
72: */
73: public function setWidth($width) {
74: $width = intval($width);
75:
76: if ($width <= 0) {
77: $width = 50;
78: }
79:
80: return $this->updateAttribute('cols', $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 cHTMLTextarea
89: * $this for chaining
90: */
91: public function setHeight($height) {
92: $height = intval($height);
93:
94: if ($height <= 0) {
95: $height = 5;
96: }
97:
98: return $this->updateAttribute('rows', $height);
99: }
100:
101: /**
102: * Sets the initial value of the text box.
103: *
104: * @param string $value
105: * Initial value
106: * @return cHTMLTextarea
107: * $this for chaining
108: */
109: public function setValue($value) {
110: $this->_value = $value;
111:
112: return $this;
113: }
114:
115: /**
116: * Renders the textarea
117: *
118: * @return string
119: * Rendered HTML
120: */
121: public function toHtml() {
122: $this->_setContent($this->_value);
123:
124: return parent::toHTML();
125: }
126:
127: }
128: