|
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_View |
|
17 * @subpackage Helper |
|
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
20 * @version $Id: FormImage.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
21 */ |
|
22 |
|
23 |
|
24 /** |
|
25 * Abstract class for extension |
|
26 */ |
|
27 require_once 'Zend/View/Helper/FormElement.php'; |
|
28 |
|
29 |
|
30 /** |
|
31 * Helper to generate an "image" element |
|
32 * |
|
33 * @category Zend |
|
34 * @package Zend_View |
|
35 * @subpackage Helper |
|
36 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
37 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
38 */ |
|
39 class Zend_View_Helper_FormImage extends Zend_View_Helper_FormElement |
|
40 { |
|
41 /** |
|
42 * Generates an 'image' element. |
|
43 * |
|
44 * @access public |
|
45 * |
|
46 * @param string|array $name If a string, the element name. If an |
|
47 * array, all other parameters are ignored, and the array elements |
|
48 * are extracted in place of added parameters. |
|
49 * |
|
50 * @param mixed $value The source ('src="..."') for the image. |
|
51 * |
|
52 * @param array $attribs Attributes for the element tag. |
|
53 * |
|
54 * @return string The element XHTML. |
|
55 */ |
|
56 public function formImage($name, $value = null, $attribs = null) |
|
57 { |
|
58 $info = $this->_getInfo($name, $value, $attribs); |
|
59 extract($info); // name, value, attribs, options, listsep, disable |
|
60 |
|
61 // Determine if we should use the value or the src attribute |
|
62 if (isset($attribs['src'])) { |
|
63 $src = ' src="' . $this->view->escape($attribs['src']) . '"'; |
|
64 unset($attribs['src']); |
|
65 } else { |
|
66 $src = ' src="' . $this->view->escape($value) . '"'; |
|
67 unset($value); |
|
68 } |
|
69 |
|
70 // Do we have a value? |
|
71 if (isset($value) && !empty($value)) { |
|
72 $value = ' value="' . $this->view->escape($value) . '"'; |
|
73 } else { |
|
74 $value = ''; |
|
75 } |
|
76 |
|
77 // Disabled? |
|
78 $disabled = ''; |
|
79 if ($disable) { |
|
80 $disabled = ' disabled="disabled"'; |
|
81 } |
|
82 |
|
83 // XHTML or HTML end tag? |
|
84 $endTag = ' />'; |
|
85 if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) { |
|
86 $endTag= '>'; |
|
87 } |
|
88 |
|
89 // build the element |
|
90 $xhtml = '<input type="image"' |
|
91 . ' name="' . $this->view->escape($name) . '"' |
|
92 . ' id="' . $this->view->escape($id) . '"' |
|
93 . $src |
|
94 . $value |
|
95 . $disabled |
|
96 . $this->_htmlAttribs($attribs) |
|
97 . $endTag; |
|
98 |
|
99 return $xhtml; |
|
100 } |
|
101 } |