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  * Image 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_Image extends Zend_Form_Element_Xhtml
0036 {
0037     /**
0038      * What view helper to use when using view helper decorator
0039      * @var string
0040      */
0041     public $helper = 'formImage';
0042 
0043     /**
0044      * Image source
0045      * @var string
0046      */
0047     public $src;
0048 
0049     /**
0050      * Image value
0051      * @var mixed
0052      */
0053     protected $_imageValue;
0054 
0055     /**
0056      * Load default decorators
0057      *
0058      * @return Zend_Form_Element_Image
0059      */
0060     public function loadDefaultDecorators()
0061     {
0062         if ($this->loadDefaultDecoratorsIsDisabled()) {
0063             return $this;
0064         }
0065 
0066         $decorators = $this->getDecorators();
0067         if (empty($decorators)) {
0068             $this->addDecorator('Tooltip')
0069                  ->addDecorator('Image')
0070                  ->addDecorator('Errors')
0071                  ->addDecorator('HtmlTag', array('tag' => 'dd'))
0072                  ->addDecorator('Label', array('tag' => 'dt'));
0073         }
0074         return $this;
0075     }
0076 
0077     /**
0078      * Set image path
0079      *
0080      * @param  string $path
0081      * @return Zend_Form_Element_Image
0082      */
0083     public function setImage($path)
0084     {
0085         $this->src = (string) $path;
0086         return $this;
0087     }
0088 
0089     /**
0090      * Get image path
0091      *
0092      * @return string
0093      */
0094     public function getImage()
0095     {
0096         return $this->src;
0097     }
0098 
0099     /**
0100      * Set image value to use when submitted
0101      *
0102      * @param  mixed $value
0103      * @return Zend_Form_Element_Image
0104      */
0105     public function setImageValue($value)
0106     {
0107         $this->_imageValue = $value;
0108         return $this;
0109     }
0110 
0111     /**
0112      * Get image value to use when submitted
0113      *
0114      * @return mixed
0115      */
0116     public function getImageValue()
0117     {
0118         return $this->_imageValue;
0119     }
0120 
0121     /**
0122      * Was this element used to submit the form?
0123      *
0124      * @return bool
0125      */
0126     public function isChecked()
0127     {
0128         $imageValue = $this->getImageValue();
0129         return ((null !== $imageValue) && ($this->getValue() == $imageValue));
0130     }
0131 
0132 }