File indexing completed on 2024-12-22 05:36:42

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_Form
0017  * @subpackage Element
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  */
0021 
0022 /** Zend_Form_Element_Xhtml */
0023 // require_once 'Zend/Form/Element/Xhtml.php';
0024 
0025 /**
0026  * Submit form element
0027  *
0028  * @category   Zend
0029  * @package    Zend_Form
0030  * @subpackage Element
0031  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0032  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0033  * @version    $Id$
0034  */
0035 class Zend_Form_Element_Submit extends Zend_Form_Element_Xhtml
0036 {
0037     /**
0038      * Default view helper to use
0039      * @var string
0040      */
0041     public $helper = 'formSubmit';
0042 
0043     /**
0044      * Constructor
0045      *
0046      * @param  string|array|Zend_Config $spec Element name or configuration
0047      * @param  string|array|Zend_Config $options Element value or configuration
0048      * @return void
0049      */
0050     public function __construct($spec, $options = null)
0051     {
0052         if (is_string($spec) && ((null !== $options) && is_string($options))) {
0053             $options = array('label' => $options);
0054         }
0055 
0056         if (!isset($options['ignore'])) {
0057             $options['ignore'] = true;
0058         }
0059 
0060         parent::__construct($spec, $options);
0061     }
0062 
0063     /**
0064      * Return label
0065      *
0066      * If no label is present, returns the currently set name.
0067      *
0068      * If a translator is present, returns the translated label.
0069      *
0070      * @return string
0071      */
0072     public function getLabel()
0073     {
0074         $value = parent::getLabel();
0075 
0076         if (null === $value) {
0077             $value = $this->getName();
0078 
0079             if (null !== ($translator = $this->getTranslator())) {
0080                 return $translator->translate($value);
0081             }
0082         }
0083 
0084         return $value;
0085     }
0086 
0087     /**
0088      * Has this submit button been selected?
0089      *
0090      * @return bool
0091      */
0092     public function isChecked()
0093     {
0094         $value = $this->getValue();
0095 
0096         if (empty($value)) {
0097             return false;
0098         }
0099         if ($value != $this->getLabel()) {
0100             return false;
0101         }
0102 
0103         return true;
0104     }
0105 
0106     /**
0107      * Default decorators
0108      *
0109      * Uses only 'Submit' and 'DtDdWrapper' decorators by default.
0110      *
0111      * @return Zend_Form_Element_Submit
0112      */
0113     public function loadDefaultDecorators()
0114     {
0115         if ($this->loadDefaultDecoratorsIsDisabled()) {
0116             return $this;
0117         }
0118 
0119         $decorators = $this->getDecorators();
0120         if (empty($decorators)) {
0121             $this->addDecorator('Tooltip')
0122                  ->addDecorator('ViewHelper')
0123                  ->addDecorator('DtDdWrapper');
0124         }
0125         return $this;
0126     }
0127 }