2 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
 
   5  * HTML class for a textarea type field
 
   9  * LICENSE: This source file is subject to version 3.01 of the PHP license
 
  10  * that is available through the world-wide-web at the following URI:
 
  11  * http://www.php.net/license/3_01.txt If you did not receive a copy of
 
  12  * the PHP License and are unable to obtain it through the web, please
 
  13  * send a note to license@php.net so we can mail you a copy immediately.
 
  16  * @package     HTML_QuickForm
 
  17  * @author      Adam Daniel <adaniel1@eesus.jnj.com>
 
  18  * @author      Bertrand Mansion <bmansion@mamasam.com>
 
  19  * @copyright   2001-2011 The PHP Group
 
  20  * @license     http://www.php.net/license/3_01.txt PHP License 3.01
 
  22  * @link        http://pear.php.net/package/HTML_QuickForm
 
  26  * Base class for form elements
 
  28 require_once 'HTML/QuickForm/element.php';
 
  31  * HTML class for a textarea type field
 
  34  * @package     HTML_QuickForm
 
  35  * @author      Adam Daniel <adaniel1@eesus.jnj.com>
 
  36  * @author      Bertrand Mansion <bmansion@mamasam.com>
 
  37  * @version     Release: 3.2.16
 
  40 class HTML_QuickForm_textarea extends HTML_QuickForm_element
 
  58      * @param     string    Input field name attribute
 
  59      * @param     mixed     Label(s) for a field
 
  60      * @param     mixed     Either a typical HTML attribute string or an associative array
 
  65     function HTML_QuickForm_textarea($elementName=null, $elementLabel=null, $attributes=null)
 
  67         HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
 
  68         $this->_persistantFreeze = true;
 
  69         $this->_type = 'textarea';
 
  76      * Sets the input field name
 
  78      * @param     string    $name   Input field name attribute
 
  83     function setName($name)
 
  85         $this->updateAttributes(array('name'=>$name));
 
  92      * Returns the element name
 
 100         return $this->getAttribute('name');
 
 107      * Sets value for textarea element
 
 109      * @param     string    $value  Value for textarea element
 
 114     function setValue($value)
 
 116         $this->_value = $value;
 
 117     } //end func setValue
 
 123      * Returns the value of the form element
 
 131         return $this->_value;
 
 132     } // end func getValue
 
 138      * Sets wrap type for textarea element
 
 140      * @param     string    $wrap  Wrap type
 
 145     function setWrap($wrap)
 
 147         $this->updateAttributes(array('wrap' => $wrap));
 
 154      * Sets height in rows for textarea element
 
 156      * @param     string    $rows  Height expressed in rows
 
 161     function setRows($rows)
 
 163         $this->updateAttributes(array('rows' => $rows));
 
 170      * Sets width in cols for textarea element
 
 172      * @param     string    $cols  Width expressed in cols
 
 177     function setCols($cols)
 
 179         $this->updateAttributes(array('cols' => $cols));
 
 186      * Returns the textarea element in HTML
 
 194         if ($this->_flagFrozen) {
 
 195             return $this->getFrozenHtml();
 
 197             return $this->_getTabs() .
 
 198                    '<textarea' . $this->_getAttrString($this->_attributes) . '>' .
 
 199                    // because we wrap the form later we don't want the text indented
 
 200                    preg_replace("/(\r\n|\n|\r)/", '
', htmlspecialchars($this->_value)) .
 
 206     // {{{ getFrozenHtml()
 
 209      * Returns the value of field without HTML tags (in this case, value is changed to a mask)
 
 215     function getFrozenHtml()
 
 217         $value = htmlspecialchars($this->getValue());
 
 218         if ($this->getAttribute('wrap') == 'off') {
 
 219             $html = $this->_getTabs() . '<pre>' . $value."</pre>\n";
 
 221             $html = nl2br($value)."\n";
 
 223         return $html . $this->_getPersistantData();
 
 224     } //end func getFrozenHtml
 
 228 } //end class HTML_QuickForm_textarea