web/lib/Zend/View/Helper/Fieldset.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  * @version    $Id: Fieldset.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    21  */
       
    22 
       
    23 /** Zend_View_Helper_FormElement */
       
    24 require_once 'Zend/View/Helper/FormElement.php';
       
    25 
       
    26 /**
       
    27  * Helper for rendering fieldsets
       
    28  *
       
    29  * @package    Zend_View
       
    30  * @subpackage Helper
       
    31  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    32  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    33  */
       
    34 class Zend_View_Helper_Fieldset extends Zend_View_Helper_FormElement
       
    35 {
       
    36     /**
       
    37      * Render HTML form
       
    38      *
       
    39      * @param  string $name Form name
       
    40      * @param  string $content Form content
       
    41      * @param  array $attribs HTML form attributes
       
    42      * @return string
       
    43      */
       
    44     public function fieldset($name, $content, $attribs = null)
       
    45     {
       
    46         $info = $this->_getInfo($name, $content, $attribs);
       
    47         extract($info);
       
    48 
       
    49         // get legend
       
    50         $legend = '';
       
    51         if (isset($attribs['legend'])) {
       
    52             $legendString = trim($attribs['legend']);
       
    53             if (!empty($legendString)) {
       
    54                 $legend = '<legend>'
       
    55                         . (($escape) ? $this->view->escape($legendString) : $legendString)
       
    56                         . '</legend>' . PHP_EOL;
       
    57             }
       
    58             unset($attribs['legend']);
       
    59         }
       
    60 
       
    61         // get id
       
    62         if (!empty($id)) {
       
    63             $id = ' id="' . $this->view->escape($id) . '"';
       
    64         } else {
       
    65             $id = '';
       
    66         }
       
    67 
       
    68         // render fieldset
       
    69         $xhtml = '<fieldset'
       
    70                . $id
       
    71                . $this->_htmlAttribs($attribs)
       
    72                . '>'
       
    73                . $legend
       
    74                . $content
       
    75                . '</fieldset>';
       
    76 
       
    77         return $xhtml;
       
    78     }
       
    79 }