PageRenderTime 54ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/src/application/libraries/Zend/Form/Element/Submit.php

https://bitbucket.org/masnug/grc276-blog-laravel
PHP | 127 lines | 51 code | 14 blank | 62 comment | 11 complexity | 1bd6e9a76f2203031fa2b3bb3f7c2092 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_Form
  17. * @subpackage Element
  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. */
  21. /** Zend_Form_Element_Xhtml */
  22. require_once 'Zend/Form/Element/Xhtml.php';
  23. /**
  24. * Submit form element
  25. *
  26. * @category Zend
  27. * @package Zend_Form
  28. * @subpackage Element
  29. * @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. * @version $Id: Submit.php 24280 2011-07-28 18:39:33Z matthew $
  32. */
  33. class Zend_Form_Element_Submit extends Zend_Form_Element_Xhtml
  34. {
  35. /**
  36. * Default view helper to use
  37. * @var string
  38. */
  39. public $helper = 'formSubmit';
  40. /**
  41. * Constructor
  42. *
  43. * @param string|array|Zend_Config $spec Element name or configuration
  44. * @param string|array|Zend_Config $options Element value or configuration
  45. * @return void
  46. */
  47. public function __construct($spec, $options = null)
  48. {
  49. if (is_string($spec) && ((null !== $options) && is_string($options))) {
  50. $options = array('label' => $options);
  51. }
  52. if (!isset($options['ignore'])) {
  53. $options['ignore'] = true;
  54. }
  55. parent::__construct($spec, $options);
  56. }
  57. /**
  58. * Return label
  59. *
  60. * If no label is present, returns the currently set name.
  61. *
  62. * If a translator is present, returns the translated label.
  63. *
  64. * @return string
  65. */
  66. public function getLabel()
  67. {
  68. $value = parent::getLabel();
  69. if (null === $value) {
  70. $value = $this->getName();
  71. if (null !== ($translator = $this->getTranslator())) {
  72. return $translator->translate($value);
  73. }
  74. }
  75. return $value;
  76. }
  77. /**
  78. * Has this submit button been selected?
  79. *
  80. * @return bool
  81. */
  82. public function isChecked()
  83. {
  84. $value = $this->getValue();
  85. if (empty($value)) {
  86. return false;
  87. }
  88. if ($value != $this->getLabel()) {
  89. return false;
  90. }
  91. return true;
  92. }
  93. /**
  94. * Default decorators
  95. *
  96. * Uses only 'Submit' and 'DtDdWrapper' decorators by default.
  97. *
  98. * @return Zend_Form_Element_Submit
  99. */
  100. public function loadDefaultDecorators()
  101. {
  102. if ($this->loadDefaultDecoratorsIsDisabled()) {
  103. return $this;
  104. }
  105. $decorators = $this->getDecorators();
  106. if (empty($decorators)) {
  107. $this->addDecorator('Tooltip')
  108. ->addDecorator('ViewHelper')
  109. ->addDecorator('DtDdWrapper');
  110. }
  111. return $this;
  112. }
  113. }