1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
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@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Adminhtml
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Customer Widget Form Image File Element Block
30: *
31: * @category Mage
32: * @package Mage_Adminhtml
33: * @author Magento Core Team <core@magentocommerce.com>
34: */
35: class Mage_Adminhtml_Block_Customer_Form_Element_Image extends Mage_Adminhtml_Block_Customer_Form_Element_File
36: {
37: /**
38: * Return Delete CheckBox Label
39: *
40: * @return string
41: */
42: protected function _getDeleteCheckboxLabel()
43: {
44: return Mage::helper('adminhtml')->__('Delete Image');
45: }
46:
47: /**
48: * Return Delete CheckBox SPAN Class name
49: *
50: * @return string
51: */
52: protected function _getDeleteCheckboxSpanClass()
53: {
54: return 'delete-image';
55: }
56:
57: /**
58: * Return File preview link HTML
59: *
60: * @return string
61: */
62: protected function _getPreviewHtml()
63: {
64: $html = '';
65: if ($this->getValue() && !is_array($this->getValue())) {
66: $url = $this->_getPreviewUrl();
67: $imageId = sprintf('%s_image', $this->getHtmlId());
68: $image = array(
69: 'alt' => Mage::helper('adminhtml')->__('View Full Size'),
70: 'title' => Mage::helper('adminhtml')->__('View Full Size'),
71: 'src' => $url,
72: 'class' => 'small-image-preview v-middle',
73: 'height' => 22,
74: 'width' => 22,
75: 'id' => $imageId
76: );
77: $link = array(
78: 'href' => $url,
79: 'onclick' => "imagePreview('{$imageId}'); return false;",
80: );
81:
82: $html = sprintf('%s%s</a> ',
83: $this->_drawElementHtml('a', $link, false),
84: $this->_drawElementHtml('img', $image)
85: );
86: }
87: return $html;
88: }
89:
90: /**
91: * Return Image URL
92: *
93: * @return string
94: */
95: protected function _getPreviewUrl()
96: {
97: if (is_array($this->getValue())) {
98: return false;
99: }
100: return Mage::helper('adminhtml')->getUrl('adminhtml/customer/viewfile', array(
101: 'image' => Mage::helper('core')->urlEncode($this->getValue()),
102: ));
103: }
104: }
105: