File indexing completed on 2024-12-22 05:37:13

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_View
0017  * @subpackage Helper
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 
0024 /**
0025  * Abstract class for extension
0026  */
0027 // require_once 'Zend/View/Helper/FormElement.php';
0028 
0029 
0030 /**
0031  * Helper to generate a "textarea" element
0032  *
0033  * @category   Zend
0034  * @package    Zend_View
0035  * @subpackage Helper
0036  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0037  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0038  */
0039 class Zend_View_Helper_FormTextarea extends Zend_View_Helper_FormElement
0040 {
0041     /**
0042      * The default number of rows for a textarea.
0043      *
0044      * @access public
0045      *
0046      * @var int
0047      */
0048     public $rows = 24;
0049 
0050     /**
0051      * The default number of columns for a textarea.
0052      *
0053      * @access public
0054      *
0055      * @var int
0056      */
0057     public $cols = 80;
0058 
0059     /**
0060      * Generates a 'textarea' element.
0061      *
0062      * @access public
0063      *
0064      * @param string|array $name If a string, the element name.  If an
0065      * array, all other parameters are ignored, and the array elements
0066      * are extracted in place of added parameters.
0067      *
0068      * @param mixed $value The element value.
0069      *
0070      * @param array $attribs Attributes for the element tag.
0071      *
0072      * @return string The element XHTML.
0073      */
0074     public function formTextarea($name, $value = null, $attribs = null)
0075     {
0076         $info = $this->_getInfo($name, $value, $attribs);
0077         extract($info); // name, value, attribs, options, listsep, disable
0078 
0079         // is it disabled?
0080         $disabled = '';
0081         if ($disable) {
0082             // disabled.
0083             $disabled = ' disabled="disabled"';
0084         }
0085 
0086         // Make sure that there are 'rows' and 'cols' values
0087         // as required by the spec.  noted by Orjan Persson.
0088         if (empty($attribs['rows'])) {
0089             $attribs['rows'] = (int) $this->rows;
0090         }
0091         if (empty($attribs['cols'])) {
0092             $attribs['cols'] = (int) $this->cols;
0093         }
0094 
0095         // build the element
0096         $xhtml = '<textarea name="' . $this->view->escape($name) . '"'
0097                 . ' id="' . $this->view->escape($id) . '"'
0098                 . $disabled
0099                 . $this->_htmlAttribs($attribs) . '>'
0100                 . $this->view->escape($value) . '</textarea>';
0101 
0102         return $xhtml;
0103     }
0104 }