File indexing completed on 2024-06-23 05:55:56

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 /** Zend_View_Helper_FormElement **/
0024 // require_once 'Zend/View/Helper/FormElement.php';
0025 
0026 /**
0027  * Form label helper
0028  *
0029  * @category   Zend
0030  * @package    Zend_View
0031  * @subpackage Helper
0032  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0033  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0034  */
0035 class Zend_View_Helper_FormLabel extends Zend_View_Helper_FormElement
0036 {
0037     /**
0038      * Generates a 'label' element.
0039      *
0040      * @param  string $name The form element name for which the label is being generated
0041      * @param  string $value The label text
0042      * @param  array $attribs Form element attributes (used to determine if disabled)
0043      * @return string The element XHTML.
0044      */
0045     public function formLabel($name, $value = null, array $attribs = null)
0046     {
0047         $info = $this->_getInfo($name, $value, $attribs);
0048         extract($info); // name, value, attribs, options, listsep, disable, escape
0049 
0050         // build the element
0051         if ($disable) {
0052             // disabled; display nothing
0053             return  '';
0054         }
0055 
0056         $value = ($escape) ? $this->view->escape($value) : $value;
0057         $for   = (empty($attribs['disableFor']) || !$attribs['disableFor'])
0058                ? ' for="' . $this->view->escape($id) . '"'
0059                : '';
0060         if (array_key_exists('disableFor', $attribs)) {
0061             unset($attribs['disableFor']);
0062         }
0063 
0064         // enabled; display label
0065         $xhtml = '<label'
0066                 . $for
0067                 . $this->_htmlAttribs($attribs)
0068                 . '>' . $value . '</label>';
0069 
0070         return $xhtml;
0071     }
0072 }