HTML_QuickForm
[ class tree: HTML_QuickForm ] [ index: HTML_QuickForm ] [ all elements ]

Source for file textarea.php

Documentation is available at textarea.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4.0                                                      |
  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. // +----------------------------------------------------------------------+
  19. //
  20. // $Id: textarea.php,v 1.11 2004/02/28 22:10:16 avb Exp $
  21.  
  22. require_once("HTML/QuickForm/element.php");
  23.  
  24. /**
  25.  * HTML class for a textarea type field
  26.  * 
  27.  * @author       Adam Daniel <adaniel1@eesus.jnj.com>
  28.  * @author       Bertrand Mansion <bmansion@mamasam.com>
  29.  * @version      1.0
  30.  * @since        PHP4.04pl1
  31.  * @access       public
  32.  */
  33. {
  34.     // {{{ properties
  35.  
  36.     /**
  37.      * Field value
  38.      * @var       string 
  39.      * @since     1.0
  40.      * @access    private
  41.      */
  42.     var $_value = null;
  43.  
  44.     // }}}
  45.     // {{{ constructor
  46.         
  47.     /**
  48.      * Class constructor
  49.      * 
  50.      * @param     string    Input field name attribute
  51.      * @param     mixed     Label(s) for a field
  52.      * @param     mixed     Either a typical HTML attribute string or an associative array
  53.      * @since     1.0
  54.      * @access    public
  55.      * @return    void 
  56.      */
  57.     function HTML_QuickForm_textarea($elementName=null$elementLabel=null$attributes=null)
  58.     {
  59.         HTML_QuickForm_element::HTML_QuickForm_element($elementName$elementLabel$attributes);
  60.         $this->_persistantFreeze = true;
  61.         $this->_type 'textarea';
  62.     //end constructor
  63.     
  64.     // }}}
  65.     // {{{ setName()
  66.  
  67.     /**
  68.      * Sets the input field name
  69.      * 
  70.      * @param     string    $name   Input field name attribute
  71.      * @since     1.0
  72.      * @access    public
  73.      * @return    void 
  74.      */
  75.     function setName($name)
  76.     {
  77.         $this->updateAttributes(array('name'=>$name));
  78.     //end func setName
  79.     
  80.     // }}}
  81.     // {{{ getName()
  82.  
  83.     /**
  84.      * Returns the element name
  85.      * 
  86.      * @since     1.0
  87.      * @access    public
  88.      * @return    string 
  89.      */
  90.     function getName()
  91.     {
  92.         return $this->getAttribute('name');
  93.     //end func getName
  94.  
  95.     // }}}
  96.     // {{{ setValue()
  97.  
  98.     /**
  99.      * Sets value for textarea element
  100.      * 
  101.      * @param     string    $value  Value for textarea element
  102.      * @since     1.0
  103.      * @access    public
  104.      * @return    void 
  105.      */
  106.     function setValue($value)
  107.     {
  108.         $this->_value $value;
  109.     //end func setValue
  110.     
  111.     // }}}
  112.     // {{{ getValue()
  113.  
  114.     /**
  115.      * Returns the value of the form element
  116.      *
  117.      * @since     1.0
  118.      * @access    public
  119.      * @return    string 
  120.      */
  121.     function getValue()
  122.     {
  123.         return $this->_value;
  124.     // end func getValue
  125.  
  126.     // }}}
  127.     // {{{ setWrap()
  128.  
  129.     /**
  130.      * Sets wrap type for textarea element
  131.      * 
  132.      * @param     string    $wrap  Wrap type
  133.      * @since     1.0
  134.      * @access    public
  135.      * @return    void 
  136.      */
  137.     function setWrap($wrap)
  138.     {
  139.         $this->updateAttributes(array('wrap' => $wrap));
  140.     //end func setWrap
  141.     
  142.     // }}}
  143.     // {{{ setRows()
  144.  
  145.     /**
  146.      * Sets height in rows for textarea element
  147.      * 
  148.      * @param     string    $rows  Height expressed in rows
  149.      * @since     1.0
  150.      * @access    public
  151.      * @return    void 
  152.      */
  153.     function setRows($rows)
  154.     {
  155.         $this->updateAttributes(array('rows' => $rows));
  156.     //end func setRows
  157.  
  158.     // }}}
  159.     // {{{ setCols()
  160.  
  161.     /**
  162.      * Sets width in cols for textarea element
  163.      * 
  164.      * @param     string    $cols  Width expressed in cols
  165.      * @since     1.0
  166.      * @access    public
  167.      * @return    void 
  168.      */ 
  169.     function setCols($cols)
  170.     {
  171.         $this->updateAttributes(array('cols' => $cols));
  172.     //end func setCols
  173.  
  174.     // }}}
  175.     // {{{ toHtml()
  176.  
  177.     /**
  178.      * Returns the textarea element in HTML
  179.      * 
  180.      * @since     1.0
  181.      * @access    public
  182.      * @return    string 
  183.      */
  184.     function toHtml()
  185.     {
  186.         if ($this->_flagFrozen{
  187.             return $this->getFrozenHtml();
  188.         else {
  189.             return $this->_getTabs(.
  190.                    '<textarea' $this->_getAttrString($this->_attributes'>' .
  191.                    // because we wrap the form later we don't want the text indented
  192.                    preg_replace("/(\r\n|\n|\r)/"'&#010;'htmlspecialchars($this->_value)) .
  193.                    '</textarea>';
  194.         }
  195.     //end func toHtml
  196.     
  197.     // }}}
  198.     // {{{ getFrozenHtml()
  199.  
  200.     /**
  201.      * Returns the value of field without HTML tags (in this case, value is changed to a mask)
  202.      * 
  203.      * @since     1.0
  204.      * @access    public
  205.      * @return    string 
  206.      */
  207.     function getFrozenHtml()
  208.     {
  209.         $value htmlspecialchars($this->getValue());
  210.         if ($this->getAttribute('wrap'== 'off'{
  211.             $html $this->_getTabs('<pre>' $value."</pre>\n";
  212.         else {
  213.             $html nl2br($value)."\n";
  214.         }
  215.         return $html $this->_getPersistantData();
  216.     //end func getFrozenHtml
  217.  
  218.     // }}}
  219.  
  220. //end class HTML_QuickForm_textarea
  221. ?>

Documentation generated on Mon, 11 Mar 2019 14:16:37 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.