Skip to content

Commit b6e65db

Browse files
authored
Added helper for admin button onclick actions (#2784)
1 parent dab44bb commit b6e65db

File tree

79 files changed

+600
-291
lines changed

Some content is hidden

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

79 files changed

+600
-291
lines changed

app/code/core/Mage/Adminhtml/Block/Api/User/Edit/Tab/Main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected function _prepareForm()
4343
'name' => 'user_id',
4444
]);
4545
} else {
46-
if (! $model->hasData('is_active')) {
46+
if (!$model->hasData('is_active')) {
4747
$model->setIsActive(1);
4848
}
4949
}

app/code/core/Mage/Adminhtml/Block/Cache.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
2020
*/
2121

22+
2223
/**
2324
* @category Mage
2425
* @package Mage_Adminhtml
@@ -37,23 +38,24 @@ public function __construct()
3738
$this->_removeButton('add');
3839
$this->_addButton('flush_magento', [
3940
'label' => Mage::helper('core')->__('Flush OpenMage Cache'),
40-
'onclick' => 'setLocation(\'' . $this->getFlushSystemUrl() . '\')',
41+
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getFlushSystemUrl()),
4142
'class' => 'delete',
4243
]);
4344

44-
$confirmationMessage = Mage::helper('core')->jsQuoteEscape(
45-
Mage::helper('core')->__('Cache storage may contain additional data. Are you sure that you want flush it?')
46-
);
4745
$this->_addButton('flush_system', [
4846
'label' => Mage::helper('core')->__('Flush Cache Storage'),
49-
'onclick' => 'confirmSetLocation(\'' . $confirmationMessage . '\', \'' . $this->getFlushStorageUrl()
50-
. '\')',
47+
'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs(
48+
$this->getFlushStorageUrl(),
49+
Mage::helper('core')->__('Cache storage may contain additional data. Are you sure that you want flush it?')
50+
),
5151
'class' => 'delete',
5252
]);
5353
}
5454

5555
/**
5656
* Get url for clean cache storage
57+
*
58+
* @return string
5759
*/
5860
public function getFlushStorageUrl()
5961
{
@@ -62,6 +64,8 @@ public function getFlushStorageUrl()
6264

6365
/**
6466
* Get url for clean cache storage
67+
*
68+
* @return string
6569
*/
6670
public function getFlushSystemUrl()
6771
{

app/code/core/Mage/Adminhtml/Block/Catalog/Product.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
2020
*/
2121

22+
2223
/**
2324
* Catalog manage products block
2425
*
@@ -44,7 +45,7 @@ protected function _prepareLayout()
4445
{
4546
$this->_addButton('add_new', [
4647
'label' => Mage::helper('catalog')->__('Add Product'),
47-
'onclick' => "setLocation('{$this->getUrl('*/*/new')}')",
48+
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/new')),
4849
'class' => 'add'
4950
]);
5051

app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __construct()
6161
$this->_updateButton('save', 'label', Mage::helper('catalog')->__('Save Attribute'));
6262
$this->_updateButton('save', 'onclick', 'saveAttribute()');
6363

64-
if (! Mage::registry('entity_attribute')->getIsUserDefined()) {
64+
if (!Mage::registry('entity_attribute')->getIsUserDefined()) {
6565
$this->_removeButton('delete');
6666
} else {
6767
$this->_updateButton('delete', 'label', Mage::helper('catalog')->__('Delete Attribute'));

app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main extends Mage_Admin
3030
{
3131
/**
3232
* Initialize template
33-
*
3433
*/
3534
protected function _construct()
3635
{
@@ -78,7 +77,7 @@ protected function _prepareLayout()
7877
'back_button',
7978
$this->getLayout()->createBlock('adminhtml/widget_button')->setData([
8079
'label' => Mage::helper('catalog')->__('Back'),
81-
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/') . '\')',
80+
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/')),
8281
'class' => 'back'
8382
])
8483
);
@@ -100,14 +99,14 @@ protected function _prepareLayout()
10099
])
101100
);
102101

103-
$deleteConfirmMessage = $this->jsQuoteEscape(Mage::helper('catalog')
104-
->__('All products of this set will be deleted! Are you sure you want to delete this attribute set?'));
105-
$deleteUrl = $this->getUrlSecure('*/*/delete', ['id' => $setId]);
106102
$this->setChild(
107103
'delete_button',
108104
$this->getLayout()->createBlock('adminhtml/widget_button')->setData([
109105
'label' => Mage::helper('catalog')->__('Delete Attribute Set'),
110-
'onclick' => 'deleteConfirm(\'' . $deleteConfirmMessage . '\', \'' . $deleteUrl . '\')',
106+
'onclick' => Mage::helper('core/js')->getDeleteConfirmJs(
107+
$this->getUrlSecure('*/*/delete', ['id' => $setId]),
108+
Mage::helper('catalog')->__('All products of this set will be deleted! Are you sure you want to delete this attribute set?')
109+
),
111110
'class' => 'delete'
112111
])
113112
);

app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ protected function _construct()
3131
$this->setTemplate('catalog/product/attribute/set/toolbar/add.phtml');
3232
}
3333

34+
/**
35+
* @inheritDoc
36+
*/
3437
protected function _prepareLayout()
3538
{
3639
$this->setChild(
@@ -47,7 +50,7 @@ protected function _prepareLayout()
4750
$this->getLayout()->createBlock('adminhtml/widget_button')
4851
->setData([
4952
'label' => Mage::helper('catalog')->__('Back'),
50-
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/') . '\')',
53+
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/')),
5154
'class' => 'back'
5255
])
5356
);
@@ -59,21 +62,33 @@ protected function _prepareLayout()
5962
return parent::_prepareLayout();
6063
}
6164

65+
/**
66+
* @return string
67+
*/
6268
protected function _getHeader()
6369
{
6470
return Mage::helper('catalog')->__('Add New Attribute Set');
6571
}
6672

73+
/**
74+
* @return string
75+
*/
6776
protected function getSaveButtonHtml()
6877
{
6978
return $this->getChildHtml('save_button');
7079
}
7180

81+
/**
82+
* @return string
83+
*/
7284
protected function getBackButtonHtml()
7385
{
7486
return $this->getChildHtml('back_button');
7587
}
7688

89+
/**
90+
* @return string
91+
*/
7792
protected function getFormHtml()
7893
{
7994
return $this->getChildHtml('setForm');

app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,42 @@ public function __construct()
3434
$this->setTemplate('catalog/product/attribute/set/toolbar/main.phtml');
3535
}
3636

37+
/**
38+
* @inheritDoc
39+
*/
3740
protected function _prepareLayout()
3841
{
3942
$this->setChild(
4043
'addButton',
4144
$this->getLayout()->createBlock('adminhtml/widget_button')
4245
->setData([
4346
'label' => Mage::helper('catalog')->__('Add New Set'),
44-
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/add') . '\')',
45-
'class' => 'add',
47+
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/add')),
48+
'class' => 'add',
4649
])
4750
);
4851
return parent::_prepareLayout();
4952
}
5053

54+
/**
55+
* @return string
56+
*/
5157
protected function getNewButtonHtml()
5258
{
5359
return $this->getChildHtml('addButton');
5460
}
5561

62+
/**
63+
* @return string
64+
*/
5665
protected function _getHeader()
5766
{
5867
return Mage::helper('catalog')->__('Manage Attribute Sets');
5968
}
6069

70+
/**
71+
* @return string
72+
*/
6173
protected function _toHtml()
6274
{
6375
Mage::dispatchEvent('adminhtml_catalog_product_attribute_set_toolbar_main_html_before', ['block' => $this]);

0 commit comments

Comments
 (0)