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_Form extends Mage_Adminhtml_Block_Widget_Form
36: {
37: protected function _prepareForm()
38: {
39: $review = Mage::registry('review_data');
40: $product = Mage::getModel('catalog/product')->load($review->getEntityPkValue());
41: $customer = Mage::getModel('customer/customer')->load($review->getCustomerId());
42: $statuses = Mage::getModel('review/review')
43: ->getStatusCollection()
44: ->load()
45: ->toOptionArray();
46:
47: $form = new Varien_Data_Form(array(
48: 'id' => 'edit_form',
49: 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'), 'ret' => Mage::registry('ret'))),
50: 'method' => 'post'
51: ));
52:
53: $fieldset = $form->addFieldset('review_details', array('legend' => Mage::helper('review')->__('Review Details'), 'class' => 'fieldset-wide'));
54:
55: $fieldset->addField('product_name', 'note', array(
56: 'label' => Mage::helper('review')->__('Product'),
57: 'text' => '<a href="' . $this->getUrl('*/catalog_product/edit', array('id' => $product->getId())) . '" onclick="this.target=\'blank\'">' . $product->getName() . '</a>'
58: ));
59:
60: if ($customer->getId()) {
61: $customerText = Mage::helper('review')->__('<a href="%1$s" onclick="this.target=\'blank\'">%2$s %3$s</a> <a href="mailto:%4$s">(%4$s)</a>', $this->getUrl('*/customer/edit', array('id' => $customer->getId(), 'active_tab'=>'review')), $this->escapeHtml($customer->getFirstname()), $this->escapeHtml($customer->getLastname()), $this->escapeHtml($customer->getEmail()));
62: } else {
63: if (is_null($review->getCustomerId())) {
64: $customerText = Mage::helper('review')->__('Guest');
65: } elseif ($review->getCustomerId() == 0) {
66: $customerText = Mage::helper('review')->__('Administrator');
67: }
68: }
69:
70: $fieldset->addField('customer', 'note', array(
71: 'label' => Mage::helper('review')->__('Posted By'),
72: 'text' => $customerText,
73: ));
74:
75: $fieldset->addField('summary_rating', 'note', array(
76: 'label' => Mage::helper('review')->__('Summary Rating'),
77: 'text' => $this->getLayout()->createBlock('adminhtml/review_rating_summary')->toHtml(),
78: ));
79:
80: $fieldset->addField('detailed_rating', 'note', array(
81: 'label' => Mage::helper('review')->__('Detailed Rating'),
82: 'required' => true,
83: 'text' => '<div id="rating_detail">'
84: . $this->getLayout()->createBlock('adminhtml/review_rating_detailed')->toHtml()
85: . '</div>',
86: ));
87:
88: $fieldset->addField('status_id', 'select', array(
89: 'label' => Mage::helper('review')->__('Status'),
90: 'required' => true,
91: 'name' => 'status_id',
92: 'values' => Mage::helper('review')->translateArray($statuses),
93: ));
94:
95: 96: 97:
98: if (!Mage::app()->isSingleStoreMode()) {
99: $field = $fieldset->addField('select_stores', 'multiselect', array(
100: 'label' => Mage::helper('review')->__('Visible In'),
101: 'required' => true,
102: 'name' => 'stores[]',
103: 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(),
104: ));
105: $renderer = $this->getLayout()->createBlock('adminhtml/store_switcher_form_renderer_fieldset_element');
106: $field->setRenderer($renderer);
107: $review->setSelectStores($review->getStores());
108: }
109: else {
110: $fieldset->addField('select_stores', 'hidden', array(
111: 'name' => 'stores[]',
112: 'value' => Mage::app()->getStore(true)->getId()
113: ));
114: $review->setSelectStores(Mage::app()->getStore(true)->getId());
115: }
116:
117: $fieldset->addField('nickname', 'text', array(
118: 'label' => Mage::helper('review')->__('Nickname'),
119: 'required' => true,
120: 'name' => 'nickname'
121: ));
122:
123: $fieldset->addField('title', 'text', array(
124: 'label' => Mage::helper('review')->__('Summary of Review'),
125: 'required' => true,
126: 'name' => 'title',
127: ));
128:
129: $fieldset->addField('detail', 'textarea', array(
130: 'label' => Mage::helper('review')->__('Review'),
131: 'required' => true,
132: 'name' => 'detail',
133: 'style' => 'height:24em;',
134: ));
135:
136: $form->setUseContainer(true);
137: $form->setValues($review->getData());
138: $this->setForm($form);
139: return parent::_prepareForm();
140: }
141: }
142: