00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Adminhtml_Block_Catalog_Product_Frontend_Product_Watermark extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
00035 {
00036 const XML_PATH_IMAGE_TYPES = 'global/catalog/product/media/image_types';
00037
00038 public function render(Varien_Data_Form_Element_Abstract $element)
00039 {
00040 $html = $this->_getHeaderHtml($element);
00041 $renderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
00042
00043 $attributes = Mage::getConfig()->getNode(self::XML_PATH_IMAGE_TYPES)->asArray();
00044
00045 foreach ($attributes as $key => $attribute) {
00046
00047
00048
00049 $field = new Varien_Data_Form_Element_Text();
00050 $field->setName("groups[watermark][fields][{$key}_size][value]")
00051 ->setForm( $this->getForm() )
00052 ->setLabel(Mage::helper('adminhtml')->__('Size for %s', $attribute['title']))
00053 ->setRenderer($renderer);
00054 $html.= $field->toHtml();
00055
00056
00057
00058
00059 $field = new Varien_Data_Form_Element_Imagefile();
00060 $field->setName("groups[watermark][fields][{$key}_image][value]")
00061 ->setForm( $this->getForm() )
00062 ->setLabel(Mage::helper('adminhtml')->__('Watermark File for %s', $attribute['title']))
00063 ->setRenderer($renderer);
00064 $html.= $field->toHtml();
00065
00066
00067
00068
00069 $field = new Varien_Data_Form_Element_Select();
00070 $field->setName("groups[watermark][fields][{$key}_position][value]")
00071 ->setForm( $this->getForm() )
00072 ->setLabel(Mage::helper('adminhtml')->__('Position of Watermark for %s', $attribute['title']))
00073 ->setRenderer($renderer)
00074 ->setValues(Mage::getSingleton('adminhtml/system_config_source_catalog_product_watermark_position')->toOptionArray());
00075 $html.= $field->toHtml();
00076 }
00077
00078 $html .= $this->_getFooterHtml($element);
00079
00080 return $html;
00081 }
00082
00083 protected function _getHeaderHtml($element)
00084 {
00085 $id = $element->getHtmlId();
00086 $default = !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store');
00087
00088 $html = '<h4 class="icon-head head-edit-form">'.$element->getLegend().'</h4>';
00089 $html.= '<fieldset class="config" id="'.$element->getHtmlId().'">';
00090 $html.= '<legend>'.$element->getLegend().'</legend>';
00091
00092
00093 $html.= '<table cellspacing="0"><colgroup class="label" /><colgroup class="value" />';
00094 if (!$default) {
00095 $html.= '<colgroup class="use-default" />';
00096 }
00097 $html.= '<tbody>';
00098
00099 return $html;
00100 }
00101
00102 protected function _getFooterHtml($element)
00103 {
00104 $html = '</tbody></table></fieldset>';
00105 return $html;
00106 }
00107 }