Skip to content

Commit a27835b

Browse files
committed
Update as of 7/26/2012
* Implemented Magento Validator library in order to have clear solid mechanism and formal rules of input data validation * Moved translations to module directories, so that it is much more convenient to manage module resources * Updated inline translation mechanism to support locales inheritance * Implemented ability to navigate through pending reviews with Prev/Next buttons, no need to switch to grid and back * Fixed issues: * Unable to use shell-installer after changes in Backend area routing process * Incorrect redirect after entering wrong captcha on the "Forgot your user name or password?" backend page * Translation is absent for several strings in Sales module `guest/form.phtml` template * Exception during installation process, when `var` directory is not empty * Node `modules` is merged to all modules' config XML-files, although it must be merged to `config.xml` only * GitHub requests: * [#39](#39) -- added `composer.json`, which was announced at previous update, but mistakenly omitted from publishing
1 parent 1617a6e commit a27835b

File tree

507 files changed

+1809
-1368
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

507 files changed

+1809
-1368
lines changed

CHANGELOG.markdown

Lines changed: 16 additions & 1 deletion

app/code/core/Mage/Adminhtml/Block/Review/Edit.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,37 @@ public function __construct()
4141
$this->_objectId = 'id';
4242
$this->_controller = 'review';
4343

44+
/** @var $actionPager Mage_Review_Helper_Action_Pager */
45+
$actionPager = Mage::helper('Mage_Review_Helper_Action_Pager');
46+
$actionPager->setStorageId('reviews');
47+
48+
$reviewId = $this->getRequest()->getParam('id');
49+
$prevId = $actionPager->getPreviousItemId($reviewId);
50+
$nextId = $actionPager->getNextItemId($reviewId);
51+
if ($prevId !== false) {
52+
$this->addButton('previous', array(
53+
'label' => Mage::helper('Mage_Review_Helper_Data')->__('Previous'),
54+
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/*', array('id' => $prevId)) . '\')'
55+
), 3, 10);
56+
57+
$this->addButton('save_and_previous', array(
58+
'label' => Mage::helper('Mage_Review_Helper_Data')->__('Save and Previous'),
59+
'onclick' => 'submitAndGo(\'' . $prevId . '\')',
60+
'class' => 'save'
61+
), 3, 11);
62+
}
63+
if ($nextId !== false) {
64+
$this->addButton('save_and_next', array(
65+
'label' => Mage::helper('Mage_Review_Helper_Data')->__('Save and Next'),
66+
'onclick' => 'submitAndGo(\'' . $nextId . '\')',
67+
'class' => 'save'
68+
), 3, 100);
69+
70+
$this->addButton('next', array(
71+
'label' => Mage::helper('Mage_Review_Helper_Data')->__('Next'),
72+
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/*', array('id' => $nextId)) . '\')'
73+
), 3, 105);
74+
}
4475
$this->_updateButton('save', 'label', Mage::helper('Mage_Review_Helper_Data')->__('Save Review'));
4576
$this->_updateButton('save', 'id', 'save_button');
4677
$this->_updateButton('delete', 'label', Mage::helper('Mage_Review_Helper_Data')->__('Delete Review'));
@@ -97,6 +128,16 @@ public function __construct()
97128
}
98129

99130
$this->_formInitScripts[] = '
131+
function submitAndGo(id)
132+
{
133+
var nextIdElement = document.createElement("input");
134+
nextIdElement.name = "next_item";
135+
nextIdElement.type = "text";
136+
nextIdElement.value = id;
137+
document.getElementById("edit_form").appendChild(nextIdElement);
138+
editForm.submit();
139+
}
140+
100141
var review = {
101142
updateRating: function() {
102143
elements = [

app/code/core/Mage/Adminhtml/Block/Review/Grid.php

Lines changed: 72 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,53 @@
2727
/**
2828
* Adminhtml reviews grid
2929
*
30+
* @method int getProductId() getProductId()
31+
* @method Mage_Adminhtml_Block_Review_Grid setProductId() setProductId(int $productId)
32+
* @method int getCustomerId() getCustomerId()
33+
* @method Mage_Adminhtml_Block_Review_Grid setCustomerId() setCustomerId(int $customerId)
34+
* @method Mage_Adminhtml_Block_Review_Grid setMassactionIdFieldOnlyIndexValue() setMassactionIdFieldOnlyIndexValue(bool $onlyIndex)
35+
*
3036
* @category Mage
3137
* @package Mage_Adminhtml
3238
* @author Magento Core Team <[email protected]>
3339
*/
34-
class Mage_Adminhtml_Block_Review_Grid extends Mage_Adminhtml_Block_Widget_Grid
40+
class Mage_Adminhtml_Block_Review_Grid extends Mage_Backend_Block_Widget_Grid
3541
{
36-
42+
/**
43+
* Initialize grid
44+
*/
3745
public function __construct()
3846
{
3947
parent::__construct();
4048
$this->setId('reviwGrid');
4149
$this->setDefaultSort('created_at');
4250
}
4351

52+
/**
53+
* Save search results
54+
*
55+
* @return Mage_Backend_Block_Widget_Grid
56+
*/
57+
protected function _afterLoadCollection()
58+
{
59+
/** @var $actionPager Mage_Review_Helper_Action_Pager */
60+
$actionPager = Mage::helper('Mage_Review_Helper_Action_Pager');
61+
$actionPager->setStorageId('reviews');
62+
$actionPager->setItems($this->getCollection()->getResultingIds());
63+
64+
return parent::_afterLoadCollection();
65+
}
66+
67+
/**
68+
* Prepare collection
69+
*
70+
* @return Mage_Adminhtml_Block_Review_Grid
71+
*/
4472
protected function _prepareCollection()
4573
{
74+
/** @var $model Mage_Review_Model_Review */
4675
$model = Mage::getModel('Mage_Review_Model_Review');
76+
/** @var $collection Mage_Review_Model_Resource_Review_Product_Collection */
4777
$collection = $model->getProductCollection();
4878

4979
if ($this->getProductId() || $this->getRequest()->getParam('productId', false)) {
@@ -74,18 +104,25 @@ protected function _prepareCollection()
74104
return parent::_prepareCollection();
75105
}
76106

107+
/**
108+
* Prepare grid columns
109+
*
110+
* @return Mage_Backend_Block_Widget_Grid
111+
*/
77112
protected function _prepareColumns()
78113
{
114+
/** @var $helper Mage_Review_Helper_Data */
115+
$helper = Mage::helper('Mage_Review_Helper_Data');
79116
$this->addColumn('review_id', array(
80-
'header' => Mage::helper('Mage_Review_Helper_Data')->__('ID'),
117+
'header' => $helper->__('ID'),
81118
'align' => 'right',
82119
'width' => '50px',
83120
'filter_index' => 'rt.review_id',
84121
'index' => 'review_id',
85122
));
86123

87124
$this->addColumn('created_at', array(
88-
'header' => Mage::helper('Mage_Review_Helper_Data')->__('Created On'),
125+
'header' => $helper->__('Created On'),
89126
'align' => 'left',
90127
'type' => 'datetime',
91128
'width' => '100px',
@@ -95,18 +132,18 @@ protected function _prepareColumns()
95132

96133
if( !Mage::registry('usePendingFilter') ) {
97134
$this->addColumn('status', array(
98-
'header' => Mage::helper('Mage_Review_Helper_Data')->__('Status'),
135+
'header' => $helper->__('Status'),
99136
'align' => 'left',
100137
'type' => 'options',
101-
'options' => Mage::helper('Mage_Review_Helper_Data')->getReviewStatuses(),
138+
'options' => $helper->getReviewStatuses(),
102139
'width' => '100px',
103140
'filter_index' => 'rt.status_id',
104141
'index' => 'status_id',
105142
));
106143
}
107144

108145
$this->addColumn('title', array(
109-
'header' => Mage::helper('Mage_Review_Helper_Data')->__('Title'),
146+
'header' => $helper->__('Title'),
110147
'align' => 'left',
111148
'width' => '100px',
112149
'filter_index' => 'rdt.title',
@@ -117,7 +154,7 @@ protected function _prepareColumns()
117154
));
118155

119156
$this->addColumn('nickname', array(
120-
'header' => Mage::helper('Mage_Review_Helper_Data')->__('Nickname'),
157+
'header' => $helper->__('Nickname'),
121158
'align' => 'left',
122159
'width' => '100px',
123160
'filter_index' => 'rdt.nickname',
@@ -128,7 +165,7 @@ protected function _prepareColumns()
128165
));
129166

130167
$this->addColumn('detail', array(
131-
'header' => Mage::helper('Mage_Review_Helper_Data')->__('Review'),
168+
'header' => $helper->__('Review'),
132169
'align' => 'left',
133170
'index' => 'detail',
134171
'filter_index' => 'rdt.detail',
@@ -143,31 +180,31 @@ protected function _prepareColumns()
143180
*/
144181
if (!Mage::app()->isSingleStoreMode()) {
145182
$this->addColumn('visible_in', array(
146-
'header' => Mage::helper('Mage_Review_Helper_Data')->__('Visible In'),
183+
'header' => $helper->__('Visible In'),
147184
'index' => 'stores',
148185
'type' => 'store',
149186
'store_view' => true,
150187
));
151188
}
152189

153190
$this->addColumn('type', array(
154-
'header' => Mage::helper('Mage_Review_Helper_Data')->__('Type'),
191+
'header' => $helper->__('Type'),
155192
'type' => 'select',
156193
'index' => 'type',
157194
'filter' => 'Mage_Adminhtml_Block_Review_Grid_Filter_Type',
158195
'renderer' => 'Mage_Adminhtml_Block_Review_Grid_Renderer_Type'
159196
));
160197

161198
$this->addColumn('name', array(
162-
'header' => Mage::helper('Mage_Review_Helper_Data')->__('Product Name'),
199+
'header' => $helper->__('Product Name'),
163200
'align' =>'left',
164201
'type' => 'text',
165202
'index' => 'name',
166203
'escape' => true
167204
));
168205

169206
$this->addColumn('sku', array(
170-
'header' => Mage::helper('Mage_Review_Helper_Data')->__('Product SKU'),
207+
'header' => $helper->__('Product SKU'),
171208
'align' => 'right',
172209
'type' => 'text',
173210
'width' => '50px',
@@ -204,8 +241,16 @@ protected function _prepareColumns()
204241
return parent::_prepareColumns();
205242
}
206243

244+
/**
245+
* Prepare grid mass actions
246+
*
247+
* @return Mage_Backend_Block_Widget_Grid|void
248+
*/
207249
protected function _prepareMassaction()
208250
{
251+
/** @var $helper Mage_Review_Helper_Data */
252+
$helper = Mage::helper('Mage_Review_Helper_Data');
253+
209254
$this->setMassactionIdField('review_id');
210255
$this->setMassactionIdFilter('rt.review_id');
211256
$this->setMassactionIdFieldOnlyIndexValue(true);
@@ -220,10 +265,10 @@ protected function _prepareMassaction()
220265
'confirm' => Mage::helper('Mage_Review_Helper_Data')->__('Are you sure?')
221266
));
222267

223-
$statuses = Mage::helper('Mage_Review_Helper_Data')->getReviewStatusesOptionArray();
268+
$statuses = $helper->getReviewStatusesOptionArray();
224269
array_unshift($statuses, array('label'=>'', 'value'=>''));
225270
$this->getMassactionBlock()->addItem('update_status', array(
226-
'label' => Mage::helper('Mage_Review_Helper_Data')->__('Update Status'),
271+
'label' => $helper->__('Update Status'),
227272
'url' => $this->getUrl(
228273
'*/*/massUpdateStatus',
229274
array('ret' => Mage::registry('usePendingFilter') ? 'pending' : 'index')
@@ -233,13 +278,19 @@ protected function _prepareMassaction()
233278
'name' => 'status',
234279
'type' => 'select',
235280
'class' => 'required-entry',
236-
'label' => Mage::helper('Mage_Review_Helper_Data')->__('Status'),
281+
'label' => $helper->__('Status'),
237282
'values' => $statuses
238283
)
239284
)
240285
));
241286
}
242287

288+
/**
289+
* Get row url
290+
*
291+
* @param Mage_Review_Model_Review|Varien_Object $row
292+
* @return string
293+
*/
243294
public function getRowUrl($row)
244295
{
245296
return $this->getUrl('*/catalog_product_review/edit', array(
@@ -250,6 +301,11 @@ public function getRowUrl($row)
250301
));
251302
}
252303

304+
/**
305+
* Get grid url
306+
*
307+
* @return string
308+
*/
253309
public function getGridUrl()
254310
{
255311
if( $this->getProductId() || $this->getCustomerId() ) {

app/code/core/Mage/Adminhtml/controllers/Catalog/Product/ReviewController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,12 @@ public function saveAction()
160160
}
161161
}
162162

163-
return $this->getResponse()->setRedirect($this->getUrl($this->getRequest()->getParam('ret') == 'pending' ? '*/*/pending' : '*/*/'));
163+
$nextId = (int) $this->getRequest()->getParam('next_item');
164+
$url = $this->getUrl($this->getRequest()->getParam('ret') == 'pending' ? '*/*/pending' : '*/*/');
165+
if ($nextId) {
166+
$url = $this->getUrl('*/*/edit', array('id' => $nextId));
167+
}
168+
return $this->getResponse()->setRedirect($url);
164169
}
165170
$this->_redirect('*/*/');
166171
}

app/code/core/Mage/Captcha/Model/Observer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function checkUserForgotPasswordBackend($observer)
205205
$this->_getBackendSession()->setEmail((string) $controller->getRequest()->getPost('email'));
206206
$controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
207207
$this->_getBackendSession()->addError(Mage::helper('Mage_Captcha_Helper_Data')->__('Incorrect CAPTCHA.'));
208-
$controller->getResponse()->setRedirect(Mage::getUrl('*/*/forgotpassword'));
208+
$controller->getResponse()->setRedirect($controller->getUrl('*/*/forgotpassword', array('_nosecret' => true)));
209209
}
210210
}
211211
}

app/code/core/Mage/Captcha/etc/config.xml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@
7171
</captcha>
7272
</observers>
7373
</controller_action_predispatch_customer_account_createpost>
74-
<controller_action_predispatch_adminhtml_auth_forgotpassword>
75-
<observers>
76-
<captcha>
77-
<class>Mage_Captcha_Model_Observer</class>
78-
<method>checkUserForgotPasswordBackend</method>
79-
</captcha>
80-
</observers>
81-
</controller_action_predispatch_adminhtml_auth_forgotpassword>
8274
<admin_user_authenticate_before>
8375
<observers>
8476
<captcha>
@@ -154,6 +146,16 @@
154146
</captcha>
155147
</updates>
156148
</layout>
149+
<events>
150+
<controller_action_predispatch_adminhtml_auth_forgotpassword>
151+
<observers>
152+
<captcha>
153+
<class>Mage_Captcha_Model_Observer</class>
154+
<method>checkUserForgotPasswordBackend</method>
155+
</captcha>
156+
</observers>
157+
</controller_action_predispatch_adminhtml_auth_forgotpassword>
158+
</events>
157159
</adminhtml>
158160
<default>
159161
<system>

app/code/core/Mage/Core/Controller/Varien/Router/Standard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Mage_Core_Controller_Varien_Router_Standard extends Mage_Core_Controller_V
3333
/**
3434
* @param array $options
3535
*
36-
* @@SuppressWarnings(PHPMD.UnusedFormalParameter)
36+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3737
*/
3838
public function __construct(array $options = array())
3939
{

0 commit comments

Comments
 (0)