PageRenderTime 57ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/src/application/libraries/Zend/Dojo/Form/Element/Button.php

https://bitbucket.org/masnug/grc276-blog-laravel
PHP | 121 lines | 46 code | 13 blank | 62 comment | 10 complexity | 70e6e87941c59b8c48930e529e4b11fb 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_Dojo
  17. * @subpackage Form_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_Dojo_Form_Element_Dijit */
  22. require_once 'Zend/Dojo/Form/Element/Dijit.php';
  23. /**
  24. * Button dijit
  25. *
  26. * @category Zend
  27. * @package Zend_Dojo
  28. * @subpackage Form_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: Button.php 23775 2011-03-01 17:25:24Z ralph $
  32. */
  33. class Zend_Dojo_Form_Element_Button extends Zend_Dojo_Form_Element_Dijit
  34. {
  35. /**
  36. * Use Button dijit view helper
  37. * @var string
  38. */
  39. public $helper = 'Button';
  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. parent::__construct($spec, $options);
  53. }
  54. /**
  55. * Return label
  56. *
  57. * If no label is present, returns the currently set name.
  58. *
  59. * If a translator is present, returns the translated label.
  60. *
  61. * @return string
  62. */
  63. public function getLabel()
  64. {
  65. $value = parent::getLabel();
  66. if (null === $value) {
  67. $value = $this->getName();
  68. }
  69. if (null !== ($translator = $this->getTranslator())) {
  70. return $translator->translate($value);
  71. }
  72. return $value;
  73. }
  74. /**
  75. * Has this submit button been selected?
  76. *
  77. * @return bool
  78. */
  79. public function isChecked()
  80. {
  81. $value = $this->getValue();
  82. if (empty($value)) {
  83. return false;
  84. }
  85. if ($value != $this->getLabel()) {
  86. return false;
  87. }
  88. return true;
  89. }
  90. /**
  91. * Default decorators
  92. *
  93. * Uses only 'DijitElement' and 'DtDdWrapper' decorators by default.
  94. *
  95. * @return void
  96. */
  97. public function loadDefaultDecorators()
  98. {
  99. if ($this->loadDefaultDecoratorsIsDisabled()) {
  100. return;
  101. }
  102. $decorators = $this->getDecorators();
  103. if (empty($decorators)) {
  104. $this->addDecorator('DijitElement')
  105. ->addDecorator('DtDdWrapper');
  106. }
  107. }
  108. }