1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Adminhtml_Block_Catalog_Product_Frontend_Product_Watermark extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
35: {
36: const XML_PATH_IMAGE_TYPES = 'global/catalog/product/media/image_types';
37:
38: public function render(Varien_Data_Form_Element_Abstract $element)
39: {
40: $html = $this->_getHeaderHtml($element);
41: $renderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
42:
43: $attributes = Mage::getConfig()->getNode(self::XML_PATH_IMAGE_TYPES)->asArray();
44:
45: foreach ($attributes as $key => $attribute) {
46: 47: 48:
49: $field = new Varien_Data_Form_Element_Text();
50: $field->setName("groups[watermark][fields][{$key}_size][value]")
51: ->setForm( $this->getForm() )
52: ->setLabel(Mage::helper('adminhtml')->__('Size for %s', $attribute['title']))
53: ->setRenderer($renderer);
54: $html.= $field->toHtml();
55:
56: 57: 58:
59: $field = new Varien_Data_Form_Element_Imagefile();
60: $field->setName("groups[watermark][fields][{$key}_image][value]")
61: ->setForm( $this->getForm() )
62: ->setLabel(Mage::helper('adminhtml')->__('Watermark File for %s', $attribute['title']))
63: ->setRenderer($renderer);
64: $html.= $field->toHtml();
65:
66: 67: 68:
69: $field = new Varien_Data_Form_Element_Select();
70: $field->setName("groups[watermark][fields][{$key}_position][value]")
71: ->setForm( $this->getForm() )
72: ->setLabel(Mage::helper('adminhtml')->__('Position of Watermark for %s', $attribute['title']))
73: ->setRenderer($renderer)
74: ->setValues(Mage::getSingleton('adminhtml/system_config_source_catalog_product_watermark_position')->toOptionArray());
75: $html.= $field->toHtml();
76: }
77:
78: $html .= $this->_getFooterHtml($element);
79:
80: return $html;
81: }
82:
83: protected function ($element)
84: {
85: $id = $element->getHtmlId();
86: $default = !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store');
87:
88: $html = '<h4 class="icon-head head-edit-form">'.$element->getLegend().'</h4>';
89: $html.= '<fieldset class="config" id="'.$element->getHtmlId().'">';
90: $html.= '<legend>'.$element->getLegend().'</legend>';
91:
92:
93: $html.= '<table cellspacing="0"><colgroup class="label" /><colgroup class="value" />';
94: if (!$default) {
95: $html.= '<colgroup class="use-default" />';
96: }
97: $html.= '<tbody>';
98:
99: return $html;
100: }
101:
102: protected function ($element)
103: {
104: $html = '</tbody></table></fieldset>';
105: return $html;
106: }
107: }
108: