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_Review_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
00036 {
00037 public function __construct()
00038 {
00039 parent::__construct();
00040
00041 $this->_objectId = 'id';
00042 $this->_controller = 'review';
00043
00044 $this->_updateButton('save', 'label', Mage::helper('review')->__('Save Review'));
00045 $this->_updateButton('save', 'id', 'save_button');
00046 $this->_updateButton('delete', 'label', Mage::helper('review')->__('Delete Review'));
00047
00048 if( $this->getRequest()->getParam('productId', false) ) {
00049 $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/catalog_product/edit', array('id' => $this->getRequest()->getParam('productId', false))) .'\')' );
00050 }
00051
00052 if( $this->getRequest()->getParam('customerId', false) ) {
00053 $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/customer/edit', array('id' => $this->getRequest()->getParam('customerId', false))) .'\')' );
00054 }
00055
00056 if( $this->getRequest()->getParam('ret', false) == 'pending' ) {
00057 $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/*/pending') .'\')' );
00058 $this->_updateButton('delete', 'onclick', 'deleteConfirm(\'' . Mage::helper('review')->__('Are you sure you want to do this?') . '\', \'' . $this->getUrl('*/*/delete', array(
00059 $this->_objectId => $this->getRequest()->getParam($this->_objectId),
00060 'ret' => 'pending',
00061 )) .'\')' );
00062 Mage::register('ret', 'pending');
00063 }
00064
00065 if( $this->getRequest()->getParam($this->_objectId) ) {
00066 $reviewData = Mage::getModel('review/review')
00067 ->load($this->getRequest()->getParam($this->_objectId));
00068 Mage::register('review_data', $reviewData);
00069 }
00070
00071 $this->_formInitScripts[] = '
00072 var review = {
00073 updateRating: function() {
00074 elements = [$("select_stores"), $("rating_detail").getElementsBySelector("input[type=\'radio\']")].flatten();
00075 $(\'save_button\').disabled = true;
00076 new Ajax.Updater("rating_detail", "'.$this->getUrl('*/*/ratingItems', array('_current'=>true)).'", {parameters:Form.serializeElements(elements), evalScripts:true, onComplete:function(){ $(\'save_button\').disabled = false; } });
00077 }
00078 }
00079 Event.observe(window, \'load\', function(){
00080 Event.observe($("select_stores"), \'change\', review.updateRating);
00081 });
00082 ';
00083 }
00084
00085 public function getHeaderText()
00086 {
00087 if( Mage::registry('review_data') && Mage::registry('review_data')->getId() ) {
00088 return Mage::helper('review')->__("Edit Review '%s'", $this->htmlEscape(Mage::registry('review_data')->getTitle()));
00089 } else {
00090 return Mage::helper('review')->__('New Review');
00091 }
00092 }
00093 }