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: */
45: public function __construct($name, $initvalue = '', $width = '', $height = '', $id = '', $disabled = false, $tabindex = NULL, $accesskey = '', $class = '') {
46: parent::__construct($name, $id, $disabled, $tabindex, $accesskey);
47: $this->_tag = 'textarea';
48: $this->setValue($initvalue);
49: $this->_contentlessTag = false;
50: $this->setWidth($width);
51: $this->setHeight($height);
52: $this->setClass($class);
53: }
54:
55: /**
56: * Sets the width of the text box.
57: *
58: * @param int $width width of the text box
59: * @return cHTMLTextarea $this
60: */
61: public function setWidth($width) {
62: $width = intval($width);
63:
64: if ($width <= 0) {
65: $width = 50;
66: }
67:
68: return $this->updateAttribute('cols', $width);
69: }
70:
71: /**
72: * Sets the maximum input length of the text box.
73: *
74: * @param int $maxlen maximum input length
75: * @return cHTMLTextarea $this
76: */
77: public function setHeight($height) {
78: $height = intval($height);
79:
80: if ($height <= 0) {
81: $height = 5;
82: }
83:
84: return $this->updateAttribute('rows', $height);
85: }
86:
87: /**
88: * Sets the initial value of the text box.
89: *
90: * @param string $value Initial value
91: * @return cHTMLTextarea $this
92: */
93: public function setValue($value) {
94: $this->_value = $value;
95:
96: return $this;
97: }
98:
99: /**
100: * Renders the textarea
101: *
102: * @return string Rendered HTML
103: */
104: public function toHtml() {
105: $this->_setContent($this->_value);
106:
107: return parent::toHTML();
108: }
109:
110: }
111: