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  * @version    $Id$
0020  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0021  */
0022 
0023 /** Zend_View_Helper_FormElement */
0024 // require_once 'Zend/View/Helper/FormElement.php';
0025 
0026 /**
0027  * Helper for rendering fieldsets
0028  *
0029  * @package    Zend_View
0030  * @subpackage Helper
0031  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0032  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0033  */
0034 class Zend_View_Helper_Fieldset extends Zend_View_Helper_FormElement
0035 {
0036     /**
0037      * Render HTML form
0038      *
0039      * @param  string $name Form name
0040      * @param  string $content Form content
0041      * @param  array $attribs HTML form attributes
0042      * @return string
0043      */
0044     public function fieldset($name, $content, $attribs = null)
0045     {
0046         $info = $this->_getInfo($name, $content, $attribs);
0047         extract($info);
0048 
0049         // get legend
0050         $legend = '';
0051         if (isset($attribs['legend'])) {
0052             $legendString = trim($attribs['legend']);
0053             if (!empty($legendString)) {
0054                 $legend = '<legend>'
0055                         . (($escape) ? $this->view->escape($legendString) : $legendString)
0056                         . '</legend>' . PHP_EOL;
0057             }
0058             unset($attribs['legend']);
0059         }
0060 
0061         // get id
0062         if (!empty($id)) {
0063             $id = ' id="' . $this->view->escape($id) . '"';
0064         } else {
0065             $id = '';
0066         }
0067 
0068         // render fieldset
0069         $xhtml = '<fieldset'
0070                . $id
0071                . $this->_htmlAttribs($attribs)
0072                . '>'
0073                . $legend
0074                . $content
0075                . '</fieldset>';
0076 
0077         return $xhtml;
0078     }
0079 }