2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
3 // +----------------------------------------------------------------------+
5 // +----------------------------------------------------------------------+
6 // | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group |
7 // +----------------------------------------------------------------------+
8 // | This source file is subject to version 2.0 of the PHP license, |
9 // | that is bundled with this package in the file LICENSE, and is |
10 // | available at through the world-wide-web at |
11 // | http://www.php.net/license/2_02.txt. |
12 // | If you did not receive a copy of the PHP license and are unable to |
13 // | obtain it through the world-wide-web, please send a note to |
14 // | license@php.net so we can mail you a copy immediately. |
15 // +----------------------------------------------------------------------+
16 // | Authors: Adam Daniel <adaniel1@eesus.jnj.com> |
17 // | Bertrand Mansion <bmansion@mamasam.com> |
18 // +----------------------------------------------------------------------+
22 require_once("HTML/QuickForm/element.php");
25 * HTML class for a textarea type field
27 * @author Adam Daniel <adaniel1@eesus.jnj.com>
28 * @author Bertrand Mansion <bmansion@mamasam.com>
33 class HTML_QuickForm_textarea
extends HTML_QuickForm_element
51 * @param string Input field name attribute
52 * @param mixed Label(s) for a field
53 * @param mixed Either a typical HTML attribute string or an associative array
58 function HTML_QuickForm_textarea($elementName=null, $elementLabel=null, $attributes=null)
60 HTML_QuickForm_element
::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
61 $this->_persistantFreeze
= true;
62 $this->_type
= 'textarea';
69 * Sets the input field name
71 * @param string $name Input field name attribute
76 function setName($name)
78 $this->updateAttributes(array('name'=>$name));
85 * Returns the element name
93 return $this->getAttribute('name');
100 * Sets value for textarea element
102 * @param string $value Value for textarea element
107 function setValue($value)
109 $this->_value
= $value;
110 } //end func setValue
116 * Returns the value of the form element
124 return $this->_value
;
125 } // end func getValue
131 * Sets wrap type for textarea element
133 * @param string $wrap Wrap type
138 function setWrap($wrap)
140 $this->updateAttributes(array('wrap' => $wrap));
147 * Sets height in rows for textarea element
149 * @param string $rows Height expressed in rows
154 function setRows($rows)
156 $this->updateAttributes(array('rows' => $rows));
163 * Sets width in cols for textarea element
165 * @param string $cols Width expressed in cols
170 function setCols($cols)
172 $this->updateAttributes(array('cols' => $cols));
179 * Returns the textarea element in HTML
187 if ($this->_flagFrozen
) {
188 return $this->getFrozenHtml();
190 return $this->_getTabs() .
191 '<textarea' . $this->_getAttrString($this->_attributes
) . '>' .
192 // because we wrap the form later we don't want the text indented
193 preg_replace("/(\r\n|\n|\r)/", '
', htmlspecialchars($this->_value
)) .
199 // {{{ getFrozenHtml()
202 * Returns the value of field without HTML tags (in this case, value is changed to a mask)
208 function getFrozenHtml()
210 $value = htmlspecialchars($this->getValue());
211 if ($this->getAttribute('wrap') == 'off') {
212 $html = $this->_getTabs() . '<pre>' . $value."</pre>\n";
214 $html = nl2br($value)."\n";
216 return $html . $this->_getPersistantData();
217 } //end func getFrozenHtml
221 } //end class HTML_QuickForm_textarea