~chroot64bit/zivios/gentoo-experimental

« back to all changes in this revision

Viewing changes to application/library/Zend/View/Helper/FormImage.php

  • Committer: Mustafa A. Hashmi
  • Date: 2008-12-04 13:32:21 UTC
  • Revision ID: mhashmi@zivios.org-20081204133221-0nd1trunwevijj38
Inclusion of new installation framework with ties to zend layout and dojo layout

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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-2008 Zend Technologies USA Inc. (http://www.zend.com)
 
19
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 
20
 */
 
21
 
 
22
 
 
23
/**
 
24
 * Abstract class for extension
 
25
 */
 
26
require_once 'Zend/View/Helper/FormElement.php';
 
27
 
 
28
 
 
29
/**
 
30
 * Helper to generate an "image" element
 
31
 *
 
32
 * @category   Zend
 
33
 * @package    Zend_View
 
34
 * @subpackage Helper
 
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
 
37
 */
 
38
class Zend_View_Helper_FormImage extends Zend_View_Helper_FormElement
 
39
{
 
40
    /**
 
41
     * Generates an 'image' element.
 
42
     *
 
43
     * @access public
 
44
     *
 
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.
 
48
     *
 
49
     * @param mixed $value The source ('src="..."') for the image.
 
50
     *
 
51
     * @param array $attribs Attributes for the element tag.
 
52
     *
 
53
     * @return string The element XHTML.
 
54
     */
 
55
    public function formImage($name, $value = null, $attribs = null)
 
56
    {
 
57
        $info = $this->_getInfo($name, $value, $attribs);
 
58
        extract($info); // name, value, attribs, options, listsep, disable
 
59
 
 
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']);
 
64
        } else {
 
65
            $src = ' src="' . $this->view->escape($value) . '"';
 
66
            unset($value);
 
67
        }
 
68
 
 
69
        // Do we have a value?
 
70
        if (isset($value) && !empty($value)) {
 
71
            $value = ' value="' . $this->view->escape($value) . '"';
 
72
        } else {
 
73
            $value = '';
 
74
        }
 
75
 
 
76
        // Disabled?
 
77
        $disabled = '';
 
78
        if ($disable) {
 
79
            $disabled = ' disabled="disabled"';
 
80
        }
 
81
        
 
82
        // XHTML or HTML end tag?
 
83
        $endTag = ' />';
 
84
        if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
 
85
            $endTag= '>';
 
86
        }
 
87
 
 
88
        // build the element
 
89
        $xhtml = '<input type="image"'
 
90
                . ' name="' . $this->view->escape($name) . '"'
 
91
                . ' id="' . $this->view->escape($id) . '"'
 
92
                . $src
 
93
                . $value
 
94
                . $disabled
 
95
                . $this->_htmlAttribs($attribs) 
 
96
                . $endTag;
 
97
 
 
98
        return $xhtml;
 
99
    }
 
100
}