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
00035 class Mage_Adminhtml_Block_Media_Editor extends Mage_Adminhtml_Block_Widget
00036 {
00037
00038 protected $_config;
00039
00040 public function __construct()
00041 {
00042 parent::__construct();
00043 $this->setTemplate('media/editor.phtml');
00044 $this->getConfig()->setImage($this->getSkinUrl('images/image.jpg'));
00045 $this->getConfig()->setParams();
00046 }
00047
00048 protected function _prepareLayout()
00049 {
00050 $this->setChild(
00051 'rotatecw_button',
00052 $this->getLayout()->createBlock('adminhtml/widget_button')
00053 ->addData(array(
00054 'id' => $this->_getButtonId('rotatecw'),
00055 'label' => Mage::helper('adminhtml')->__('Rotate CW'),
00056 'onclick' => $this->getJsObjectName() . '.rotateCw()'
00057 ))
00058 );
00059
00060 $this->setChild(
00061 'rotateccw_button',
00062 $this->getLayout()->createBlock('adminhtml/widget_button')
00063 ->addData(array(
00064 'id' => $this->_getButtonId('rotateccw'),
00065 'label' => Mage::helper('adminhtml')->__('Rotate CCW'),
00066 'onclick' => $this->getJsObjectName() . '.rotateCCw()'
00067 ))
00068 );
00069
00070 $this->setChild(
00071 'resize_button',
00072 $this->getLayout()->createBlock('adminhtml/widget_button')
00073 ->addData(array(
00074 'id' => $this->_getButtonId('upload'),
00075 'label' => Mage::helper('adminhtml')->__('Resize'),
00076 'onclick' => $this->getJsObjectName() . '.resize()'
00077 ))
00078 );
00079
00080 $this->setChild(
00081 'image_button',
00082 $this->getLayout()->createBlock('adminhtml/widget_button')
00083 ->addData(array(
00084 'id' => $this->_getButtonId('image'),
00085 'label' => Mage::helper('adminhtml')->__('Get Image Base64'),
00086 'onclick' => $this->getJsObjectName() . '.getImage()'
00087 ))
00088 );
00089
00090 return parent::_prepareLayout();
00091 }
00092
00093 protected function _getButtonId($buttonName)
00094 {
00095 return $this->getHtmlId() . '-' . $buttonName;
00096 }
00097
00098 public function getRotatecwButtonHtml()
00099 {
00100 return $this->getChildHtml('rotatecw_button');
00101 }
00102
00103 public function getImageButtonHtml()
00104 {
00105 return $this->getChildHtml('image_button');
00106 }
00107
00108 public function getRotateccwButtonHtml()
00109 {
00110 return $this->getChildHtml('rotateccw_button');
00111 }
00112
00113 public function getResizeButtonHtml()
00114 {
00115 return $this->getChildHtml('resize_button');
00116 }
00117
00118
00119
00120
00121
00122
00123 public function getJsObjectName()
00124 {
00125 return $this->getHtmlId() . 'JsObject';
00126 }
00127
00128
00129
00130
00131
00132
00133 public function getConfigJson()
00134 {
00135 return Zend_Json::encode($this->getConfig()->getData());
00136 }
00137
00138
00139
00140
00141
00142
00143 public function getConfig()
00144 {
00145 if(is_null($this->_config)) {
00146 $this->_config = new Varien_Object();
00147 }
00148
00149 return $this->_config;
00150 }
00151
00152 }