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:
35: class Mage_Adminhtml_Block_Media_Editor extends Mage_Adminhtml_Block_Widget
36: {
37:
38: protected $_config;
39:
40: public function __construct()
41: {
42: parent::__construct();
43: $this->setTemplate('media/editor.phtml');
44: $this->getConfig()->setImage($this->getSkinUrl('images/image.jpg'));
45: $this->getConfig()->setParams();
46: }
47:
48: protected function _prepareLayout()
49: {
50: $this->setChild(
51: 'rotatecw_button',
52: $this->getLayout()->createBlock('adminhtml/widget_button')
53: ->addData(array(
54: 'id' => $this->_getButtonId('rotatecw'),
55: 'label' => Mage::helper('adminhtml')->__('Rotate CW'),
56: 'onclick' => $this->getJsObjectName() . '.rotateCw()'
57: ))
58: );
59:
60: $this->setChild(
61: 'rotateccw_button',
62: $this->getLayout()->createBlock('adminhtml/widget_button')
63: ->addData(array(
64: 'id' => $this->_getButtonId('rotateccw'),
65: 'label' => Mage::helper('adminhtml')->__('Rotate CCW'),
66: 'onclick' => $this->getJsObjectName() . '.rotateCCw()'
67: ))
68: );
69:
70: $this->setChild(
71: 'resize_button',
72: $this->getLayout()->createBlock('adminhtml/widget_button')
73: ->addData(array(
74: 'id' => $this->_getButtonId('upload'),
75: 'label' => Mage::helper('adminhtml')->__('Resize'),
76: 'onclick' => $this->getJsObjectName() . '.resize()'
77: ))
78: );
79:
80: $this->setChild(
81: 'image_button',
82: $this->getLayout()->createBlock('adminhtml/widget_button')
83: ->addData(array(
84: 'id' => $this->_getButtonId('image'),
85: 'label' => Mage::helper('adminhtml')->__('Get Image Base64'),
86: 'onclick' => $this->getJsObjectName() . '.getImage()'
87: ))
88: );
89:
90: return parent::_prepareLayout();
91: }
92:
93: protected function _getButtonId($buttonName)
94: {
95: return $this->getHtmlId() . '-' . $buttonName;
96: }
97:
98: public function getRotatecwButtonHtml()
99: {
100: return $this->getChildHtml('rotatecw_button');
101: }
102:
103: public function getImageButtonHtml()
104: {
105: return $this->getChildHtml('image_button');
106: }
107:
108: public function getRotateccwButtonHtml()
109: {
110: return $this->getChildHtml('rotateccw_button');
111: }
112:
113: public function getResizeButtonHtml()
114: {
115: return $this->getChildHtml('resize_button');
116: }
117:
118: 119: 120: 121: 122:
123: public function getJsObjectName()
124: {
125: return $this->getHtmlId() . 'JsObject';
126: }
127:
128: 129: 130: 131: 132:
133: public function getConfigJson()
134: {
135: return Mage::helper('core')->jsonEncode($this->getConfig()->getData());
136: }
137:
138: 139: 140: 141: 142:
143: public function getConfig()
144: {
145: if(is_null($this->_config)) {
146: $this->_config = new Varien_Object();
147: }
148:
149: return $this->_config;
150: }
151:
152: }
153: