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