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