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.
18
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
19
* @license http://framework.zend.com/license/new-bsd New BSD License
24
* Abstract class for extension
26
require_once 'Zend/View/Helper/FormElement.php';
30
* Helper to generate an "image" element
35
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
36
* @license http://framework.zend.com/license/new-bsd New BSD License
38
class Zend_View_Helper_FormImage extends Zend_View_Helper_FormElement
41
* Generates an 'image' element.
45
* @param string|array $name If a string, the element name. If an
46
* array, all other parameters are ignored, and the array elements
47
* are extracted in place of added parameters.
49
* @param mixed $value The source ('src="..."') for the image.
51
* @param array $attribs Attributes for the element tag.
53
* @return string The element XHTML.
55
public function formImage($name, $value = null, $attribs = null)
57
$info = $this->_getInfo($name, $value, $attribs);
58
extract($info); // name, value, attribs, options, listsep, disable
60
// Determine if we should use the value or the src attribute
61
if (isset($attribs['src'])) {
62
$src = ' src="' . $this->view->escape($attribs['src']) . '"';
63
unset($attribs['src']);
65
$src = ' src="' . $this->view->escape($value) . '"';
69
// Do we have a value?
70
if (isset($value) && !empty($value)) {
71
$value = ' value="' . $this->view->escape($value) . '"';
79
$disabled = ' disabled="disabled"';
82
// XHTML or HTML end tag?
84
if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
89
$xhtml = '<input type="image"'
90
. ' name="' . $this->view->escape($name) . '"'
91
. ' id="' . $this->view->escape($id) . '"'
95
. $this->_htmlAttribs($attribs)