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_Review_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
36: {
37: public function __construct()
38: {
39: parent::__construct();
40:
41: $this->_objectId = 'id';
42: $this->_controller = 'review';
43:
44: $this->_updateButton('save', 'label', Mage::helper('review')->__('Save Review'));
45: $this->_updateButton('save', 'id', 'save_button');
46: $this->_updateButton('delete', 'label', Mage::helper('review')->__('Delete Review'));
47:
48: if( $this->getRequest()->getParam('productId', false) ) {
49: $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/catalog_product/edit', array('id' => $this->getRequest()->getParam('productId', false))) .'\')' );
50: }
51:
52: if( $this->getRequest()->getParam('customerId', false) ) {
53: $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/customer/edit', array('id' => $this->getRequest()->getParam('customerId', false))) .'\')' );
54: }
55:
56: if( $this->getRequest()->getParam('ret', false) == 'pending' ) {
57: $this->_updateButton('back', 'onclick', 'setLocation(\'' . $this->getUrl('*/*/pending') .'\')' );
58: $this->_updateButton('delete', 'onclick', 'deleteConfirm(\'' . Mage::helper('review')->__('Are you sure you want to do this?') . '\', \'' . $this->getUrl('*/*/delete', array(
59: $this->_objectId => $this->getRequest()->getParam($this->_objectId),
60: 'ret' => 'pending',
61: )) .'\')' );
62: Mage::register('ret', 'pending');
63: }
64:
65: if( $this->getRequest()->getParam($this->_objectId) ) {
66: $reviewData = Mage::getModel('review/review')
67: ->load($this->getRequest()->getParam($this->_objectId));
68: Mage::register('review_data', $reviewData);
69: }
70:
71: $this->_formInitScripts[] = '
72: var review = {
73: updateRating: function() {
74: elements = [$("select_stores"), $("rating_detail").getElementsBySelector("input[type=\'radio\']")].flatten();
75: $(\'save_button\').disabled = true;
76: new Ajax.Updater("rating_detail", "'.$this->getUrl('*/*/ratingItems', array('_current'=>true)).'", {parameters:Form.serializeElements(elements), evalScripts:true, onComplete:function(){ $(\'save_button\').disabled = false; } });
77: }
78: }
79: Event.observe(window, \'load\', function(){
80: Event.observe($("select_stores"), \'change\', review.updateRating);
81: });
82: ';
83: }
84:
85: public function ()
86: {
87: if( Mage::registry('review_data') && Mage::registry('review_data')->getId() ) {
88: return Mage::helper('review')->__("Edit Review '%s'", $this->htmlEscape(Mage::registry('review_data')->getTitle()));
89: } else {
90: return Mage::helper('review')->__('New Review');
91: }
92: }
93: }
94: