PageRenderTime 39ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/src/application/libraries/Zend/View/Helper/FormLabel.php

https://bitbucket.org/masnug/grc276-blog-laravel
PHP | 72 lines | 25 code | 6 blank | 41 comment | 3 complexity | 6deca16bec1943c90252976b6171c262 MD5 | raw file
  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-2011 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id: FormLabel.php 23775 2011-03-01 17:25:24Z ralph $
  21. */
  22. /** Zend_View_Helper_FormElement **/
  23. require_once 'Zend/View/Helper/FormElement.php';
  24. /**
  25. * Form label helper
  26. *
  27. * @category Zend
  28. * @package Zend_View
  29. * @subpackage Helper
  30. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. class Zend_View_Helper_FormLabel extends Zend_View_Helper_FormElement
  34. {
  35. /**
  36. * Generates a 'label' element.
  37. *
  38. * @param string $name The form element name for which the label is being generated
  39. * @param string $value The label text
  40. * @param array $attribs Form element attributes (used to determine if disabled)
  41. * @return string The element XHTML.
  42. */
  43. public function formLabel($name, $value = null, array $attribs = null)
  44. {
  45. $info = $this->_getInfo($name, $value, $attribs);
  46. extract($info); // name, value, attribs, options, listsep, disable, escape
  47. // build the element
  48. if ($disable) {
  49. // disabled; display nothing
  50. return '';
  51. }
  52. $value = ($escape) ? $this->view->escape($value) : $value;
  53. $for = (empty($attribs['disableFor']) || !$attribs['disableFor'])
  54. ? ' for="' . $this->view->escape($id) . '"'
  55. : '';
  56. if (array_key_exists('disableFor', $attribs)) {
  57. unset($attribs['disableFor']);
  58. }
  59. // enabled; display label
  60. $xhtml = '<label'
  61. . $for
  62. . $this->_htmlAttribs($attribs)
  63. . '>' . $value . '</label>';
  64. return $xhtml;
  65. }
  66. }