web/lib/Zend/View/Helper/FormTextarea.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_View
       
    17  * @subpackage Helper
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: FormTextarea.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 
       
    24 /**
       
    25  * Abstract class for extension
       
    26  */
       
    27 require_once 'Zend/View/Helper/FormElement.php';
       
    28 
       
    29 
       
    30 /**
       
    31  * Helper to generate a "textarea" element
       
    32  *
       
    33  * @category   Zend
       
    34  * @package    Zend_View
       
    35  * @subpackage Helper
       
    36  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    38  */
       
    39 class Zend_View_Helper_FormTextarea extends Zend_View_Helper_FormElement
       
    40 {
       
    41     /**
       
    42      * The default number of rows for a textarea.
       
    43      *
       
    44      * @access public
       
    45      *
       
    46      * @var int
       
    47      */
       
    48     public $rows = 24;
       
    49 
       
    50     /**
       
    51      * The default number of columns for a textarea.
       
    52      *
       
    53      * @access public
       
    54      *
       
    55      * @var int
       
    56      */
       
    57     public $cols = 80;
       
    58 
       
    59     /**
       
    60      * Generates a 'textarea' element.
       
    61      *
       
    62      * @access public
       
    63      *
       
    64      * @param string|array $name If a string, the element name.  If an
       
    65      * array, all other parameters are ignored, and the array elements
       
    66      * are extracted in place of added parameters.
       
    67      *
       
    68      * @param mixed $value The element value.
       
    69      *
       
    70      * @param array $attribs Attributes for the element tag.
       
    71      *
       
    72      * @return string The element XHTML.
       
    73      */
       
    74     public function formTextarea($name, $value = null, $attribs = null)
       
    75     {
       
    76         $info = $this->_getInfo($name, $value, $attribs);
       
    77         extract($info); // name, value, attribs, options, listsep, disable
       
    78 
       
    79         // is it disabled?
       
    80         $disabled = '';
       
    81         if ($disable) {
       
    82             // disabled.
       
    83             $disabled = ' disabled="disabled"';
       
    84         }
       
    85 
       
    86         // Make sure that there are 'rows' and 'cols' values
       
    87         // as required by the spec.  noted by Orjan Persson.
       
    88         if (empty($attribs['rows'])) {
       
    89             $attribs['rows'] = (int) $this->rows;
       
    90         }
       
    91         if (empty($attribs['cols'])) {
       
    92             $attribs['cols'] = (int) $this->cols;
       
    93         }
       
    94 
       
    95         // build the element
       
    96         $xhtml = '<textarea name="' . $this->view->escape($name) . '"'
       
    97                 . ' id="' . $this->view->escape($id) . '"'
       
    98                 . $disabled
       
    99                 . $this->_htmlAttribs($attribs) . '>'
       
   100                 . $this->view->escape($value) . '</textarea>';
       
   101 
       
   102         return $xhtml;
       
   103     }
       
   104 }