diff --git a/app/code/core/Mage/Adminhtml/Block/Cache.php b/app/code/core/Mage/Adminhtml/Block/Cache.php
index 5d8b72bee7c..06ed78d20db 100644
--- a/app/code/core/Mage/Adminhtml/Block/Cache.php
+++ b/app/code/core/Mage/Adminhtml/Block/Cache.php
@@ -22,20 +22,25 @@ public function __construct()
$this->_headerText = Mage::helper('core')->__('Cache Storage Management');
parent::__construct();
$this->_removeButton(self::BUTTON_TYPE_ADD);
- $this->_addButton('flush_magento', [
- 'label' => Mage::helper('core')->__('Flush & Apply Updates'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getFlushSystemUrl()),
- 'class' => 'delete cache',
- ]);
-
- $this->_addButton('flush_system', [
- 'label' => Mage::helper('core')->__('Flush Cache Storage'),
- 'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs(
- $this->getFlushStorageUrl(),
- Mage::helper('core')->__('Cache storage may contain additional data. Are you sure that you want flush it?'),
- ),
- 'class' => 'delete flush',
- ]);
+
+ $this->_addPreparedButton(
+ id: 'flush_magento',
+ label: Mage::helper('core')->__('Flush & Apply Updates'),
+ class: 'delete cache',
+ onClickUrl: $this->getFlushSystemUrl(),
+ );
+
+ $onClick = Mage::helper('core/js')->getConfirmSetLocationJs(
+ $this->getFlushStorageUrl(),
+ Mage::helper('core')->__('Are you sure you want to flush cache storage?'),
+ );
+
+ $this->_addPreparedButton(
+ id: 'flush_system',
+ label: Mage::helper('core')->__('Flush Cache Storage'),
+ class: 'delete flush',
+ onClick: $onClick,
+ );
}
/**
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product.php
index 17cc472fd3f..628fbf33eb3 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product.php
@@ -30,11 +30,11 @@ public function __construct()
#[Override]
protected function _prepareLayout()
{
- $this->_addButton('add_new', [
- 'label' => Mage::helper('catalog')->__('Add Product'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/new')),
- 'class' => 'add',
- ]);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_ADD,
+ label: Mage::helper('catalog')->__('Add Product'),
+ onClickUrl: $this->getUrl('*/*/new'),
+ );
$this->setChild('grid', $this->getLayout()->createBlock('adminhtml/catalog_product_grid', 'product.grid'));
return parent::_prepareLayout();
diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php
index 981cb56f3a0..493c606edf5 100644
--- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Edit.php
@@ -23,24 +23,15 @@ public function __construct()
if ($this->getRequest()->getParam('popup')) {
$this->_removeButton(self::BUTTON_TYPE_BACK);
- $this->_addButton(
- self::BUTTON_TYPE_CLOSE,
- [
- 'label' => Mage::helper('catalog')->__('Close Window'),
- 'class' => 'cancel',
- 'onclick' => 'window.close()',
- 'level' => -1,
- ],
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_CLOSE,
+ module: 'catalog',
);
} else {
- $this->_addButton(
- 'save_and_edit_button',
- [
- 'label' => Mage::helper('catalog')->__('Save and Continue Edit'),
- 'onclick' => 'saveAndContinueEdit()',
- 'class' => 'save continue',
- ],
- 100,
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_SAVE_EDIT,
+ level: 100,
+ module: 'catalog',
);
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php b/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php
index b4f948adf0d..7dab8dc8503 100644
--- a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php
@@ -22,11 +22,10 @@ public function __construct()
parent::__construct();
if ($this->_isAllowedAction('save')) {
- $this->_addButton(self::BUTTON_TYPE_SAVE_EDIT, [
- 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
- 'onclick' => 'saveAndContinueEdit()',
- 'class' => 'save continue',
- ], -100);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_SAVE_EDIT,
+ level: -100,
+ );
} else {
$this->_removeButton(self::BUTTON_TYPE_SAVE);
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php
index 28745a7df40..0b7fcf86a02 100644
--- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php
@@ -26,11 +26,11 @@ public function __construct()
parent::__construct();
if ($this->_isAllowedAction('save')) {
- $this->_addButton(self::BUTTON_TYPE_SAVE_EDIT, [
- 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
- 'onclick' => Mage::helper('core/js')->getSaveAndContinueEditJs($this->_getSaveAndContinueUrl()),
- 'class' => 'save continue',
- ], -100);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_SAVE_EDIT,
+ level: -100,
+ onClick: Mage::helper('core/js')->getSaveAndContinueEditJs($this->_getSaveAndContinueUrl()),
+ );
} else {
$this->_removeButton(self::BUTTON_TYPE_SAVE);
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php
index de747bc902d..86c075aad30 100644
--- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php
@@ -23,11 +23,12 @@ public function __construct()
if ($this->getCustomerId()
&& Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/create')
) {
- $this->_addButton('order', [
- 'label' => Mage::helper('customer')->__('Create Order'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getCreateOrderUrl()),
- 'class' => 'add create-order',
- ], 0);
+ $this->_addPreparedButton(
+ id: 'order',
+ label: Mage::helper('customer')->__('Create Order'),
+ class: 'add create-order',
+ onClickUrl: $this->getCreateOrderUrl(),
+ );
}
parent::__construct();
@@ -95,11 +96,12 @@ public function getValidationUrl()
protected function _prepareLayout()
{
if (!Mage::registry('current_customer')->isReadonly()) {
- $this->_addButton(self::BUTTON_TYPE_SAVE_EDIT, [
- 'label' => Mage::helper('customer')->__('Save and Continue Edit'),
- 'onclick' => Mage::helper('core/js')->getSaveAndContinueEditJs($this->_getSaveAndContinueUrl()),
- 'class' => 'save continue',
- ], 10);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_SAVE_EDIT,
+ level: 10,
+ module: 'customer',
+ onClick: Mage::helper('core/js')->getSaveAndContinueEditJs($this->_getSaveAndContinueUrl()),
+ );
}
return parent::_prepareLayout();
diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog.php b/app/code/core/Mage/Adminhtml/Block/Promo/Catalog.php
index c5ac1845939..10d3aaec944 100644
--- a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog.php
+++ b/app/code/core/Mage/Adminhtml/Block/Promo/Catalog.php
@@ -16,11 +16,12 @@ class Mage_Adminhtml_Block_Promo_Catalog extends Mage_Adminhtml_Block_Widget_Gri
{
public function __construct()
{
- $this->_addButton('apply_rules', [
- 'label' => Mage::helper('catalogrule')->__('Apply Rules'),
- 'onclick' => "location.href='" . $this->getUrl('*/*/applyRules') . "'",
- 'class' => 'apply',
- ]);
+ $this->_addPreparedButton(
+ id: 'apply_rules',
+ label: Mage::helper('catalogrule')->__('Apply Rules'),
+ class: 'apply',
+ onClick: "location.href='" . $this->getUrl('*/*/applyRules') . "'",
+ );
$this->_controller = 'promo_catalog';
$this->_headerText = Mage::helper('catalogrule')->__('Catalog Price Rules');
diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit.php b/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit.php
index 0febd38ee5f..4562032fc8d 100644
--- a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit.php
@@ -27,17 +27,19 @@ public function __construct()
parent::__construct();
- $this->_addButton('save_apply', [
- 'class' => 'save apply',
- 'label' => Mage::helper('catalogrule')->__('Save and Apply'),
- 'onclick' => "$('rule_auto_apply').value=1; editForm.submit()",
- ]);
+ $this->_addPreparedButton(
+ id: 'save_apply',
+ label: Mage::helper('catalogrule')->__('Save and Apply'),
+ class: 'save apply',
+ onClick: "$('rule_auto_apply').value=1; editForm.submit()",
+ );
- $this->_addButton('save_and_continue_edit', [
- 'class' => 'save continue',
- 'label' => Mage::helper('catalogrule')->__('Save and Continue Edit'),
- 'onclick' => 'editForm.submit($(\'edit_form\').action + \'back/edit/\')',
- ], 10);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_SAVE_EDIT,
+ level: 10,
+ module: 'catalogrule',
+ onClick: 'editForm.submit($(\'edit_form\').action + \'back/edit/\')',
+ );
}
/**
diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit.php b/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit.php
index 64238b0c040..3bd8b5e1de7 100644
--- a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit.php
@@ -26,11 +26,12 @@ public function __construct()
parent::__construct();
- $this->_addButton('save_and_continue_edit', [
- 'class' => 'save continue',
- 'label' => Mage::helper('salesrule')->__('Save and Continue Edit'),
- 'onclick' => 'editForm.submit($(\'edit_form\').action + \'back/edit/\')',
- ], 10);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_SAVE_EDIT,
+ level: 10,
+ module: 'salesrule',
+ onClick: 'editForm.submit($(\'edit_form\').action + \'back/edit/\')',
+ );
}
/**
diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View.php
index 562d188c96f..e4534d1d226 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/View.php
@@ -31,47 +31,50 @@ public function __construct()
$this->_removeButton(self::BUTTON_TYPE_DELETE);
if ($this->getCreditmemo()->canCancel()) {
- $this->_addButton(self::BUTTON_TYPE_CANCEL, [
- 'label' => Mage::helper('sales')->__('Cancel'),
- 'class' => 'delete',
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getCancelUrl()),
- ]);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_CANCEL,
+ module: 'sales',
+ onClickUrl: $this->getCancelUrl(),
+ );
}
if ($this->_isAllowedAction('emails')) {
- $this->addButton('send_notification', [
- 'label' => Mage::helper('sales')->__('Send Email'),
- 'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs(
- $this->getEmailUrl(),
- Mage::helper('sales')->__('Are you sure you want to send Creditmemo email to customer?'),
- ),
- 'class' => 'send-email',
- ]);
+ $onClick = Mage::helper('core/js')->getConfirmSetLocationJs(
+ $this->getEmailUrl(),
+ Mage::helper('sales')->__('Are you sure you want to send Creditmemo email to customer?'),
+ );
+
+ $this->_addPreparedButton(
+ id: 'send_notification',
+ label: Mage::helper('sales')->__('Send Email'),
+ class: 'send-email',
+ onClick: $onClick,
+ );
}
if ($this->getCreditmemo()->canRefund()) {
- $this->_addButton('refund', [
- 'label' => Mage::helper('sales')->__('Refund'),
- 'class' => 'save refund',
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getRefundUrl()),
- ]);
+ $this->_addPreparedButton(
+ id: 'refund',
+ label: Mage::helper('sales')->__('Refund'),
+ class: 'save refund',
+ onClickUrl: $this->getRefundUrl(),
+ );
}
if ($this->getCreditmemo()->canVoid()) {
- $this->_addButton(self::BUTTON_TYPE_VOID, [
- 'label' => Mage::helper('sales')->__('Void'),
- 'class' => 'save void',
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getVoidUrl()),
-
- ]);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_VOID,
+ module: 'sales',
+ onClickUrl: $this->getVoidUrl(),
+ );
}
if ($this->getCreditmemo()->getId()) {
- $this->_addButton(self::BUTTON_TYPE_PRINT, [
- 'label' => Mage::helper('sales')->__('Print'),
- 'class' => 'save print',
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getPrintUrl()),
- ]);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_PRINT,
+ module: 'sales',
+ onClickUrl: $this->getPrintUrl(),
+ );
}
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View.php
index 0f3b02dbba5..60dbc6b236f 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/View.php
@@ -39,22 +39,25 @@ public function __construct()
$this->_removeButton(self::BUTTON_TYPE_DELETE);
if ($this->_isAllowedAction('cancel') && $this->getInvoice()->canCancel()) {
- $this->_addButton(self::BUTTON_TYPE_CANCEL, [
- 'label' => Mage::helper('sales')->__('Cancel'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getCancelUrl()),
- 'class' => 'delete',
- ]);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_CANCEL,
+ module: 'sales',
+ onClickUrl: $this->getCancelUrl(),
+ );
}
if ($this->_isAllowedAction('emails')) {
- $this->addButton('send_notification', [
- 'label' => Mage::helper('sales')->__('Send Email'),
- 'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs(
- $this->getEmailUrl(),
- Mage::helper('sales')->__('Are you sure you want to send Invoice email to customer?'),
- ),
- 'class' => 'send-email',
- ]);
+ $onClick = Mage::helper('core/js')->getConfirmSetLocationJs(
+ $this->getEmailUrl(),
+ Mage::helper('sales')->__('Are you sure you want to send Invoice email to customer?'),
+ );
+
+ $this->_addPreparedButton(
+ id: 'send_notification',
+ label: Mage::helper('sales')->__('Send Email'),
+ class: 'send-email',
+ onClick: $onClick,
+ );
}
$orderPayment = $this->getInvoice()->getOrder()->getPayment();
@@ -67,35 +70,37 @@ public function __construct()
|| $orderPayment->canRefund()
&& !$this->getInvoice()->getIsUsedForRefund())
) {
- $this->_addButton('capture', [ // capture?
- 'label' => Mage::helper('sales')->__('Credit Memo'),
- 'class' => 'go',
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getCreditMemoUrl()),
- ]);
+ $this->_addPreparedButton(
+ id: 'capture', // capture?
+ label: Mage::helper('sales')->__('Credit Memo'),
+ class: 'go',
+ onClickUrl: $this->getCreditMemoUrl(),
+ );
}
if ($this->_isAllowedAction('capture') && $this->getInvoice()->canCapture()) {
- $this->_addButton('capture', [
- 'label' => Mage::helper('sales')->__('Capture'),
- 'class' => 'save capture',
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getCaptureUrl()),
- ]);
+ $this->_addPreparedButton(
+ id: 'capture',
+ label: Mage::helper('sales')->__('Capture'),
+ class: 'save capture',
+ onClickUrl: $this->getCaptureUrl(),
+ );
}
if ($this->getInvoice()->canVoid()) {
- $this->_addButton(self::BUTTON_TYPE_VOID, [
- 'label' => Mage::helper('sales')->__('Void'),
- 'class' => 'save void',
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getVoidUrl()),
- ]);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_VOID,
+ module: 'sales',
+ onClickUrl: $this->getVoidUrl(),
+ );
}
if ($this->getInvoice()->getId()) {
- $this->_addButton(self::BUTTON_TYPE_PRINT, [
- 'label' => Mage::helper('sales')->__('Print'),
- 'class' => 'save print',
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getPrintUrl()),
- ]);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_PRINT,
+ module: 'sales',
+ onClickUrl: $this->getPrintUrl(),
+ );
}
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View.php
index 40f1449e3fa..fa59ae8a589 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/View.php
@@ -42,11 +42,11 @@ public function __construct()
}
if ($this->getShipment()->getId()) {
- $this->_addButton(self::BUTTON_TYPE_PRINT, [
- 'label' => Mage::helper('sales')->__('Print'),
- 'class' => 'save print',
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getPrintUrl()),
- ]);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_PRINT,
+ module: 'sales',
+ onClickUrl: $this->getPrintUrl(),
+ );
}
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status.php
index 19ea9a8ec9c..bc8f39a3cc8 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status.php
@@ -23,11 +23,12 @@ public function __construct()
$this->_controller = 'sales_order_status';
$this->_headerText = Mage::helper('sales')->__('Order Statuses');
$this->_addButtonLabel = Mage::helper('sales')->__('Create New Status');
- $this->_addButton('assign', [
- 'label' => Mage::helper('sales')->__('Assign Status to State'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getAssignUrl()),
- 'class' => 'add',
- ]);
+ $this->_addPreparedButton(
+ id: 'assign',
+ label: Mage::helper('sales')->__('Assign Status to State'),
+ class: 'add',
+ onClickUrl: $this->getAssignUrl(),
+ );
parent::__construct();
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php
index 8e1df1e9a34..d89692b701f 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php
@@ -38,10 +38,13 @@ public function __construct()
$this->getEditUrl(),
Mage::helper('sales')->__('Are you sure? This order will be canceled and a new one will be created instead'),
);
- $this->_addButton('order_edit', [
- 'label' => Mage::helper('sales')->__('Edit'),
- 'onclick' => $onclickJs,
- ]);
+
+ $this->_addPreparedButton(
+ id: 'order_edit',
+ label: Mage::helper('sales')->__('Edit'),
+ onClick: $onclickJs,
+ );
+
// see if order has non-editable products as items
$nonEditableTypes = array_keys($this->getOrder()->getResource()->aggregateProductsByTypes(
$order->getId(),
diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Detail.php b/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Detail.php
index 0fa349558ab..da82967d889 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Detail.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Detail.php
@@ -50,20 +50,20 @@ public function __construct()
$this->_txn = Mage::registry('current_transaction');
$backUrl = ($this->_txn->getOrderUrl()) ? $this->_txn->getOrderUrl() : $this->getUrl('*/*/');
- $this->_addButton(self::BUTTON_TYPE_BACK, [
- 'label' => Mage::helper('sales')->__('Back'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($backUrl),
- 'class' => 'back',
- ]);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_BACK,
+ onClickUrl: $backUrl,
+ );
if (Mage::getSingleton('admin/session')->isAllowed('sales/transactions/fetch')
&& $this->_txn->getOrderPaymentObject()->getMethodInstance()->canFetchTransactionInfo()
) {
- $this->_addButton('fetch', [
- 'label' => Mage::helper('sales')->__('Fetch'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/fetch', ['_current' => true])),
- 'class' => 'button',
- ]);
+ $this->_addPreparedButton(
+ id: 'fetch',
+ label: Mage::helper('sales')->__('Fetch'),
+ class: 'button',
+ onClickUrl: $this->getUrl('*/*/fetch', ['_current' => true]),
+ );
}
}
diff --git a/app/code/core/Mage/Adminhtml/Block/Sitemap/Edit.php b/app/code/core/Mage/Adminhtml/Block/Sitemap/Edit.php
index db3caecd605..adfb8042453 100644
--- a/app/code/core/Mage/Adminhtml/Block/Sitemap/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Sitemap/Edit.php
@@ -24,11 +24,12 @@ public function __construct()
parent::__construct();
- $this->_addButton('generate', [
- 'label' => Mage::helper('adminhtml')->__('Save & Generate'),
- 'onclick' => "$('generate').value=1; editForm.submit();",
- 'class' => 'add generate',
- ]);
+ $this->_addPreparedButton(
+ id: 'generate',
+ label: Mage::helper('adminhtml')->__('Save & Generate'),
+ class: 'add generate',
+ onClick: "$('generate').value=1; editForm.submit();",
+ );
}
/**
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit.php
index 16d9f1273e1..42af1ffdfed 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit.php
@@ -23,11 +23,12 @@ public function __construct()
$this->_updateButton(self::BUTTON_TYPE_SAVE, 'label', Mage::helper('adminhtml')->__('Save Profile'));
$this->_updateButton(self::BUTTON_TYPE_DELETE, 'label', Mage::helper('adminhtml')->__('Delete Profile'));
- $this->_addButton(self::BUTTON_TYPE_SAVE_EDIT, [
- 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
- 'onclick' => "$('edit_form').action += 'continue/true/'; editForm.submit();",
- 'class' => 'save continue',
- ], -100);
+
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_SAVE_EDIT,
+ level: -100,
+ onClick: "$('edit_form').action += 'continue/true/'; editForm.submit();",
+ );
}
public function getProfileId()
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit.php
index 4237edf710b..91c67729de1 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit.php
@@ -23,11 +23,12 @@ public function __construct()
$this->_updateButton(self::BUTTON_TYPE_SAVE, 'label', Mage::helper('adminhtml')->__('Save Profile'));
$this->_updateButton(self::BUTTON_TYPE_DELETE, 'label', Mage::helper('adminhtml')->__('Delete Profile'));
- $this->_addButton(self::BUTTON_TYPE_SAVE_EDIT, [
- 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
- 'onclick' => "$('edit_form').action += 'continue/true/'; editForm.submit();",
- 'class' => 'save continue',
- ], -100);
+
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_SAVE_EDIT,
+ level: -100,
+ onClick: "$('edit_form').action += 'continue/true/'; editForm.submit();",
+ );
}
public function getProfileId()
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Delete.php b/app/code/core/Mage/Adminhtml/Block/System/Store/Delete.php
index a55ae1b496f..3e507bfb2a5 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Store/Delete.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Store/Delete.php
@@ -34,10 +34,13 @@ public function __construct()
$this->_updateButton(self::BUTTON_TYPE_DELETE, 'area', 'footer');
$this->_updateButton(self::BUTTON_TYPE_DELETE, 'onclick', 'editForm.submit();');
- $this->_addButton(self::BUTTON_TYPE_CANCEL, [
- 'label' => Mage::helper('adminhtml')->__('Cancel'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getBackUrl()),
- ], 2, 100, 'footer');
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_CANCEL,
+ level: 2,
+ sortOrder: 100,
+ area: 'footer',
+ onClickUrl: $this->getBackUrl(),
+ );
}
/**
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php
index 1fc7bfac5c3..621524a5ea8 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php
@@ -60,7 +60,8 @@ public function __construct()
}
if (Mage::registry('store_data')->isReadOnly()) {
- $this->_removeButton(self::BUTTON_TYPE_SAVE)->_removeButton(self::BUTTON_TYPE_RESET);
+ $this->_removeButton(self::BUTTON_TYPE_SAVE)
+ ->_removeButton(self::BUTTON_TYPE_RESET);
}
}
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Store/Store.php b/app/code/core/Mage/Adminhtml/Block/System/Store/Store.php
index 0ae5c87b529..1ab6b9238c4 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Store/Store.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Store/Store.php
@@ -30,25 +30,28 @@ public function __construct()
protected function _prepareLayout()
{
/* Add website button */
- $this->_addButton(self::BUTTON_TYPE_ADD, [
- 'label' => Mage::helper('core')->__('Create Website'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/newWebsite')),
- 'class' => 'add website',
- ]);
+ $this->_addPreparedButton(
+ id: 'add_website',
+ label: Mage::helper('core')->__('Create Website'),
+ class: 'add website',
+ onClickUrl: $this->getUrl('*/*/newWebsite'),
+ );
/* Add Store Group button */
- $this->_addButton('add_group', [
- 'label' => Mage::helper('core')->__('Create Store'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/newGroup')),
- 'class' => 'add store',
- ]);
+ $this->_addPreparedButton(
+ id: 'add_group',
+ label: Mage::helper('core')->__('Create Store'),
+ class: 'add store',
+ onClickUrl: $this->getUrl('*/*/newGroup'),
+ );
/* Add Store button */
- $this->_addButton('add_store', [
- 'label' => Mage::helper('core')->__('Create Store View'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/newStore')),
- 'class' => 'add storeview',
- ]);
+ $this->_addPreparedButton(
+ id: 'add_store',
+ label: Mage::helper('core')->__('Create Store View'),
+ class: 'add storeview',
+ onClickUrl: $this->getUrl('*/*/newStore'),
+ );
return parent::_prepareLayout();
}
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php
index ec4d3c5bb87..6da70ac215a 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php
@@ -39,13 +39,14 @@ public function getVariable()
#[Override]
protected function _prepareLayout()
{
- $this->_addButton(self::BUTTON_TYPE_SAVE_EDIT, [
- 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'),
- 'class' => 'save continue',
- 'onclick' => "editForm.submit('" . $this->getSaveAndContinueUrl() . "');",
- ], 100);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_SAVE_EDIT,
+ level: 100,
+ onClick: "editForm.submit('" . $this->getSaveAndContinueUrl() . "');",
+ );
+
if (!$this->getVariable()->getId()) {
- $this->removeButton('delete');
+ $this->removeButton(self::BUTTON_TYPE_DELETE);
}
return parent::_prepareLayout();
diff --git a/app/code/core/Mage/Adminhtml/Block/Tag/Edit.php b/app/code/core/Mage/Adminhtml/Block/Tag/Edit.php
index 653db8265e1..b633245cebf 100644
--- a/app/code/core/Mage/Adminhtml/Block/Tag/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Tag/Edit.php
@@ -28,11 +28,11 @@ public function __construct()
$this->_updateButton(self::BUTTON_TYPE_SAVE, 'label', Mage::helper('tag')->__('Save Tag'));
$this->_updateButton(self::BUTTON_TYPE_DELETE, 'label', Mage::helper('tag')->__('Delete Tag'));
- $this->addButton('save_and_edit_button', [
- 'label' => Mage::helper('tag')->__('Save and Continue Edit'),
- 'onclick' => Mage::helper('core/js')->getSaveAndContinueEditJs($this->getSaveAndContinueUrl()),
- 'class' => 'save continue',
- ], 1);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_SAVE_EDIT,
+ module: 'tag',
+ onClick: Mage::helper('core/js')->getSaveAndContinueEditJs($this->getSaveAndContinueUrl()),
+ );
}
/**
diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rule/Edit.php b/app/code/core/Mage/Adminhtml/Block/Tax/Rule/Edit.php
index b964ea4397e..b0cf559c0a5 100644
--- a/app/code/core/Mage/Adminhtml/Block/Tax/Rule/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Tax/Rule/Edit.php
@@ -27,11 +27,11 @@ public function __construct()
#[Override]
protected function _prepareLayout()
{
- $this->_addButton(self::BUTTON_TYPE_SAVE_EDIT, [
- 'label' => Mage::helper('tax')->__('Save and Continue Edit'),
- 'onclick' => 'saveAndContinueEdit()',
- 'class' => 'save continue',
- ], 10);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_SAVE_EDIT,
+ level: 10,
+ module: 'tax',
+ );
$this->_formScripts[] = " function saveAndContinueEdit(){ editForm.submit($('edit_form').action + 'back/edit/') } ";
diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php
index 6bce4c2e492..471541fff0e 100644
--- a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php
+++ b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php
@@ -36,12 +36,8 @@ class Mage_Adminhtml_Block_Urlrewrite_Edit extends Mage_Adminhtml_Block_Widget_C
protected function _prepareLayout()
{
$this->setTemplate('urlrewrite/edit.phtml');
- $this->_addButton(self::BUTTON_TYPE_BACK, [
- 'label' => Mage::helper('adminhtml')->__('Back'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs(Mage::helper('adminhtml')::getUrl('*/*/')),
- 'class' => 'back',
- 'level' => -1,
- ]);
+
+ $this->_addPreparedButton(id: self::BUTTON_TYPE_BACK);
// links to products/categories (if any) selectors
if ($this->getProductId()) {
@@ -130,32 +126,28 @@ protected function _setFormChild()
{
$this->setChild('form', Mage::getBlockSingleton('adminhtml/urlrewrite_edit_form'));
if ($this->getUrlrewriteId()) {
- $this->_addButton(self::BUTTON_TYPE_RESET, [
- 'label' => Mage::helper('adminhtml')->__('Reset'),
- 'onclick' => '$(\'edit_form\').reset()',
- 'class' => 'scalable reset',
- 'level' => -1,
- ]);
- $this->_addButton(self::BUTTON_TYPE_DELETE, [
- 'label' => Mage::helper('adminhtml')->__('Delete'),
- 'onclick' => "deleteConfirm('"
- . Mage::helper('core')->jsQuoteEscape(
- Mage::helper('adminhtml')->__('Are you sure you want to do this?'),
- )
- . "', '"
- . Mage::helper('adminhtml')::getUrl('*/*/delete', ['id' => $this->getUrlrewriteId()])
- . "')",
- 'class' => 'scalable delete',
- 'level' => -1,
- ]);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_RESET,
+ class: 'scalable reset',
+ onClick: '$(\'edit_form\').reset()', #todo
+ );
+
+ $onClick = "deleteConfirm('"
+ . Mage::helper('core')->jsQuoteEscape(
+ Mage::helper('adminhtml')->__('Are you sure you want to do this?'),
+ )
+ . "', '"
+ . Mage::helper('adminhtml')::getUrl('*/*/delete', ['id' => $this->getUrlrewriteId()])
+ . "')";
+
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_DELETE,
+ class: 'scalable delete',
+ onClick: $onClick,
+ );
}
- $this->_addButton(self::BUTTON_TYPE_SAVE, [
- 'label' => Mage::helper('adminhtml')->__('Save'),
- 'onclick' => 'editForm.submit()',
- 'class' => 'save',
- 'level' => -1,
- ]);
+ $this->_addPreparedButton(id: self::BUTTON_TYPE_SAVE);
// update back button link
$params = [];
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Container.php b/app/code/core/Mage/Adminhtml/Block/Widget/Container.php
index 366e4f1f7a2..ef9dd4161ec 100644
--- a/app/code/core/Mage/Adminhtml/Block/Widget/Container.php
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Container.php
@@ -89,6 +89,118 @@ private function getTestIdentifier(string $id): string
return 'admin-button-' . str_replace([' ', '_'], '-', $id);
}
+ /**
+ * @param self::BUTTON_TYPE_*|string $id
+ * @param null|string $onClick Url or JS code to be executed on click
+ * @param null|string $onClickUrl Url to be executed on click, using getSetLocationJs()
+ * @param null|string $onClickConfirmUrl Url to be executed on click with confirmation, using getConfirmSetLocationJs()
+ * @return $this
+ *
+ * @SuppressWarnings("PHPMD.ExcessiveParameterList")
+ */
+ protected function _addPreparedButton(
+ string $id,
+ string $label = '',
+ string $class = '',
+ array $data = [],
+ ?int $level = null,
+ int $sortOrder = 0,
+ string $area = 'header',
+ string $module = 'adminhtml',
+ ?string $onClick = null,
+ ?string $onClickUrl = null,
+ ?string $onClickConfirmUrl = null,
+ ) {
+ $jsHelper = Mage::helper('core/js');
+
+ if (is_string($onClickUrl) && $onClickUrl !== '') {
+ $onClick = $jsHelper->getSetLocationJs($onClickUrl);
+ }
+
+ if (is_string($onClickConfirmUrl) && $onClickConfirmUrl !== '') {
+ $onClick = $jsHelper->getConfirmSetLocationJs($onClickConfirmUrl);
+ }
+
+ # ... todo
+ if (is_null($onClick)) {
+ $onClick = match ($id) {
+ self::BUTTON_TYPE_BACK => $jsHelper->getSetLocationJs(Mage::helper('adminhtml')::getUrl('*/*/')),
+ self::BUTTON_TYPE_CLOSE => 'window.close()',
+ self::BUTTON_TYPE_RESET => 'setLocation(window.location.href)',
+ self::BUTTON_TYPE_SAVE => 'editForm.submit();',
+ self::BUTTON_TYPE_SAVE_EDIT => 'saveAndContinueEdit()',
+ default => '',
+ };
+ }
+
+ if (is_null($level)) {
+ $level = match ($id) {
+ self::BUTTON_TYPE_BACK => -1,
+ self::BUTTON_TYPE_CANCEL => -1,
+ self::BUTTON_TYPE_CLOSE => -1,
+ self::BUTTON_TYPE_RESET => -1,
+ self::BUTTON_TYPE_SAVE => 1,
+ self::BUTTON_TYPE_SAVE_EDIT => 1,
+ default => 0,
+ };
+ }
+
+ $prefData = match ($id) {
+ self::BUTTON_TYPE_ADD => [
+ 'label' => Mage::helper($module)->__('Add'),
+ 'class' => 'add',
+ ],
+ self::BUTTON_TYPE_BACK => [
+ 'label' => Mage::helper($module)->__('Back'),
+ 'class' => 'back',
+ ],
+ self::BUTTON_TYPE_CANCEL => [
+ 'label' => Mage::helper($module)->__('Cancel'),
+ 'class' => 'cancel delete',
+ ],
+ self::BUTTON_TYPE_CLOSE => [
+ 'label' => Mage::helper($module)->__('Close Window'),
+ 'class' => 'cancel',
+ ],
+ self::BUTTON_TYPE_DELETE => [
+ 'label' => Mage::helper($module)->__('Delete'),
+ 'class' => 'delete',
+ ],
+ self::BUTTON_TYPE_PRINT => [
+ 'label' => Mage::helper($module)->__('Print'),
+ 'class' => 'save print',
+ ],
+ self::BUTTON_TYPE_RESET => [
+ 'label' => Mage::helper($module)->__('Reset'),
+ 'class' => 'reset',
+ ],
+ self::BUTTON_TYPE_SAVE => [
+ 'label' => Mage::helper($module)->__('Save'),
+ 'class' => 'save',
+ ],
+ self::BUTTON_TYPE_SAVE_EDIT => [
+ 'label' => Mage::helper($module)->__('Save and Continue Edit'),
+ 'class' => 'save continue',
+ ],
+ self::BUTTON_TYPE_VOID => [
+ 'label' => Mage::helper($module)->__('Void'),
+ 'class' => 'save void',
+ ],
+ default => [
+ 'label' => $label,
+ 'class' => $class,
+ ],
+ };
+
+ $data = array_merge($prefData, array_filter([
+ 'label' => $label,
+ 'class' => $class,
+ 'onclick' => $onClick,
+ ]), $data);
+
+ return $this->_addButton($id, $data, $level, $sortOrder, $area);
+ }
+
/**
* Public wrapper for protected _addButton method
*
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php b/app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php
index f70e1d3d764..0abcb348242 100644
--- a/app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php
@@ -33,32 +33,23 @@ public function __construct()
$this->setTemplate('widget/form/container.phtml');
}
- $this->_addButton(self::BUTTON_TYPE_BACK, [
- 'label' => Mage::helper('adminhtml')->__('Back'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getBackUrl()),
- 'class' => 'back',
- ], -1);
- $this->_addButton(self::BUTTON_TYPE_RESET, [
- 'label' => Mage::helper('adminhtml')->__('Reset'),
- 'onclick' => 'setLocation(window.location.href)',
- 'class' => 'reset',
- ], -1);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_BACK,
+ onClickUrl: $this->getBackUrl(),
+ );
+
+ $this->_addPreparedButton(id: self::BUTTON_TYPE_RESET);
$objId = $this->getRequest()->getParam($this->_objectId);
if (!empty($objId)) {
- $this->_addButton(self::BUTTON_TYPE_DELETE, [
- 'label' => Mage::helper('adminhtml')->__('Delete'),
- 'class' => 'delete',
- 'onclick' => Mage::helper('core/js')->getDeleteConfirmJs($this->getDeleteUrl()),
- ]);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_DELETE,
+ onClick: Mage::helper('core/js')->getDeleteConfirmJs($this->getDeleteUrl()),
+ );
}
- $this->_addButton(self::BUTTON_TYPE_SAVE, [
- 'label' => Mage::helper('adminhtml')->__('Save'),
- 'onclick' => 'editForm.submit();',
- 'class' => 'save',
- ], 1);
+ $this->_addPreparedButton(id: self::BUTTON_TYPE_SAVE);
}
/**
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php
index db6ae803300..2a5fe09afdf 100644
--- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php
@@ -46,11 +46,11 @@ public function __construct()
$this->setTemplate('widget/grid/container.phtml');
- $this->_addButton(self::BUTTON_TYPE_ADD, [
- 'label' => $this->getAddButtonLabel(),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getCreateUrl()),
- 'class' => 'add',
- ]);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_ADD,
+ label: $this->getAddButtonLabel(),
+ onClickUrl: $this->getCreateUrl(),
+ );
}
/**
@@ -103,11 +103,10 @@ protected function getBackButtonLabel()
protected function _addBackButton()
{
- $this->_addButton(self::BUTTON_TYPE_BACK, [
- 'label' => $this->getBackButtonLabel(),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getBackUrl()),
- 'class' => 'back',
- ]);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_BACK,
+ onClickUrl: $this->getBackUrl(),
+ );
}
/**
diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/View/Container.php b/app/code/core/Mage/Adminhtml/Block/Widget/View/Container.php
index 07ebc91c129..3ccf2f8d8a1 100644
--- a/app/code/core/Mage/Adminhtml/Block/Widget/View/Container.php
+++ b/app/code/core/Mage/Adminhtml/Block/Widget/View/Container.php
@@ -22,17 +22,17 @@ public function __construct()
$this->setTemplate('widget/view/container.phtml');
- $this->_addButton(self::BUTTON_TYPE_BACK, [
- 'label' => Mage::helper('adminhtml')->__('Back'),
- 'onclick' => "window.location.href='" . $this->getUrl('*/*/') . "'",
- 'class' => 'back',
- ]);
-
- $this->_addButton('edit', [
- 'label' => Mage::helper('adminhtml')->__('Edit'),
- 'class' => 'edit',
- 'onclick' => "window.location.href='" . $this->getEditUrl() . "'",
- ]);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_BACK,
+ onClick: "window.location.href='" . $this->getUrl('*/*/') . "'",
+ );
+
+ $this->_addPreparedButton(
+ id: 'edit',
+ label: Mage::helper('adminhtml')->__('Edit'),
+ class: 'edit',
+ onClick: "window.location.href='" . $this->getEditUrl() . "'",
+ );
}
#[Override]
diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Edit.php b/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Edit.php
index 416ff57c8d3..d134dbc2fb8 100644
--- a/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Edit.php
+++ b/app/code/core/Mage/ImportExport/Block/Adminhtml/Export/Edit.php
@@ -18,9 +18,9 @@ public function __construct()
{
parent::__construct();
- $this->removeButton('back')
- ->removeButton('reset')
- ->removeButton('save');
+ $this->removeButton(self::BUTTON_TYPE_BACK)
+ ->removeButton(self::BUTTON_TYPE_RESET)
+ ->removeButton(self::BUTTON_TYPE_SAVE);
}
/**
diff --git a/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit.php b/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit.php
index 106b599d327..446d20965bc 100644
--- a/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit.php
+++ b/app/code/core/Mage/ImportExport/Block/Adminhtml/Import/Edit.php
@@ -18,8 +18,8 @@ public function __construct()
{
parent::__construct();
- $this->removeButton('back')
- ->removeButton('reset')
+ $this->removeButton(self::BUTTON_TYPE_BACK)
+ ->removeButton(self::BUTTON_TYPE_RESET)
->_updateButton(self::BUTTON_TYPE_SAVE, 'label', $this->__('Check Data'))
->_updateButton(self::BUTTON_TYPE_SAVE, 'id', 'upload_button')
->_updateButton(self::BUTTON_TYPE_SAVE, 'onclick', 'editForm.postToFrame();');
diff --git a/app/code/core/Mage/Index/Block/Adminhtml/Process/Edit.php b/app/code/core/Mage/Index/Block/Adminhtml/Process/Edit.php
index 038da5c3b16..f9a2e64b2eb 100644
--- a/app/code/core/Mage/Index/Block/Adminhtml/Process/Edit.php
+++ b/app/code/core/Mage/Index/Block/Adminhtml/Process/Edit.php
@@ -25,10 +25,11 @@ public function __construct()
parent::__construct();
$this->_updateButton(self::BUTTON_TYPE_SAVE, 'label', Mage::helper('cms')->__('Save Process'));
- $this->_addButton('reindex', [
- 'label' => Mage::helper('index')->__('Reindex Data'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getRunUrl()),
- ]);
+ $this->_addPreparedButton(
+ id: 'reindex',
+ label: Mage::helper('index')->__('Reindex Data'),
+ onClickUrl: $this->getRunUrl(),
+ );
$this->_removeButton(self::BUTTON_TYPE_RESET);
$this->_removeButton(self::BUTTON_TYPE_DELETE);
}
diff --git a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit.php b/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit.php
index d032428add1..00350fb0218 100644
--- a/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit.php
+++ b/app/code/core/Mage/Oauth/Block/Adminhtml/Oauth/Consumer/Edit.php
@@ -45,11 +45,11 @@ public function __construct()
$this->_controller = 'adminhtml_oauth_consumer';
$this->_mode = 'edit';
- $this->_addButton(self::BUTTON_TYPE_SAVE_EDIT, [
- 'label' => Mage::helper('oauth')->__('Save and Continue Edit'),
- 'onclick' => 'saveAndContinueEdit()',
- 'class' => 'save continue',
- ], 100);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_SAVE_EDIT,
+ level: 100,
+ module: 'oauth',
+ );
$this->_formScripts[] = 'function saveAndContinueEdit()'
. "{editForm.submit($('edit_form').action + 'back/edit/')}";
diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report.php
index 28efc288f56..b298de1336c 100644
--- a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report.php
+++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report.php
@@ -22,14 +22,18 @@ public function __construct()
$this->_headerText = Mage::helper('paypal')->__('PayPal Settlement Reports');
parent::__construct();
$this->_removeButton(self::BUTTON_TYPE_ADD);
- $this->_addButton('fetch', [
- 'label' => Mage::helper('paypal')->__('Fetch Updates'),
- 'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs(
- $this->getUrl('*/*/fetch'),
- Mage::helper('paypal')->__('Connecting to PayPal SFTP server to fetch new reports. Are you sure you want to proceed?'),
- ),
- 'class' => 'task',
- ]);
+
+ $onClick = Mage::helper('core/js')->getConfirmSetLocationJs(
+ $this->getUrl('*/*/fetch'),
+ Mage::helper('paypal')->__('Connecting to PayPal SFTP server to fetch new reports. Are you sure you want to proceed?'),
+ );
+
+ $this->_addPreparedButton(
+ id: 'fetch',
+ label: Mage::helper('paypal')->__('Fetch Updates'),
+ class: 'task',
+ onClick: $onClick,
+ );
}
/**
diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View.php b/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View.php
index 318212752c1..244a06d84c6 100644
--- a/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View.php
+++ b/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View.php
@@ -35,18 +35,16 @@ public function __construct()
$this->_removeButton(self::BUTTON_TYPE_SAVE);
$this->setId('billing_agreement_view');
- $this->_addButton(self::BUTTON_TYPE_BACK, [
- 'label' => Mage::helper('adminhtml')->__('Back'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getBackUrl()),
- 'class' => 'back',
- ], -1);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_BACK,
+ onClickUrl: $this->getBackUrl(),
+ );
if ($this->_getBillingAgreement()->canCancel() && $this->_isAllowed('sales/billing_agreement/actions/manage')) {
- $this->_addButton(self::BUTTON_TYPE_CANCEL, [
- 'label' => Mage::helper('adminhtml')->__('Cancel'),
- 'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs($this->_getCancelUrl()),
- 'class' => 'cancel',
- ], -1);
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_CANCEL,
+ onClickConfirmUrl: $this->_getCancelUrl(),
+ );
}
}
diff --git a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View.php b/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View.php
index 7876d09ec08..43149b29dcc 100644
--- a/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View.php
+++ b/app/code/core/Mage/Sales/Block/Adminhtml/Recurring/Profile/View.php
@@ -26,56 +26,61 @@ class Mage_Sales_Block_Adminhtml_Recurring_Profile_View extends Mage_Adminhtml_B
#[Override]
protected function _prepareLayout()
{
- $this->_addButton(self::BUTTON_TYPE_BACK, [
- 'label' => Mage::helper('adminhtml')->__('Back'),
- 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/')),
- 'class' => 'back',
- ]);
+ $this->_addPreparedButton(id: self::BUTTON_TYPE_BACK);
$profile = Mage::registry('current_recurring_profile');
// cancel
if ($profile->canCancel()) {
- $this->_addButton(self::BUTTON_TYPE_CANCEL, [
- 'label' => Mage::helper('sales')->__('Cancel'),
- 'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs(
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_CANCEL,
+ module: 'sales',
+ onClick: Mage::helper('core/js')->getConfirmSetLocationJs(
$this->getUrl('*/*/updateState', ['profile' => $profile->getId(), 'action' => 'cancel']),
),
- 'class' => 'delete',
- ]);
+ );
}
// suspend
if ($profile->canSuspend()) {
- $this->_addButton('suspend', [
- 'label' => Mage::helper('sales')->__('Suspend'),
- 'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs(
- $this->getUrl('*/*/updateState', ['profile' => $profile->getId(), 'action' => 'suspend']),
- ),
- 'class' => 'delete',
- ]);
+ $onClick = Mage::helper('core/js')->getConfirmSetLocationJs(
+ $this->getUrl('*/*/updateState', ['profile' => $profile->getId(), 'action' => 'suspend']),
+ );
+
+ $this->_addPreparedButton(
+ id: 'suspend',
+ label: Mage::helper('sales')->__('Suspend'),
+ class: 'delete',
+ onClick: $onClick,
+ );
}
// activate
if ($profile->canActivate()) {
- $this->_addButton('activate', [
- 'label' => Mage::helper('sales')->__('Activate'),
- 'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs(
- $this->getUrl('*/*/updateState', ['profile' => $profile->getId(), 'action' => 'activate']),
- ),
- 'class' => 'add',
- ]);
+ $onClick = Mage::helper('core/js')->getConfirmSetLocationJs(
+ $this->getUrl('*/*/updateState', ['profile' => $profile->getId(), 'action' => 'activate']),
+ );
+
+ $this->_addPreparedButton(
+ id: 'activate',
+ label: Mage::helper('sales')->__('Activate'),
+ class: 'add',
+ onClick: $onClick,
+ );
}
// get update
if ($profile->canFetchUpdate()) {
- $this->_addButton('update', [
- 'label' => Mage::helper('sales')->__('Get Update'),
- 'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs(
- $this->getUrl('*/*/updateProfile', ['profile' => $profile->getId()]),
- ),
- 'class' => 'add',
- ]);
+ $onClick = Mage::helper('core/js')->getConfirmSetLocationJs(
+ $this->getUrl('*/*/updateProfile', ['profile' => $profile->getId()]),
+ );
+
+ $this->_addPreparedButton(
+ id: 'update',
+ label: Mage::helper('sales')->__('Get Update'),
+ class: 'add',
+ onClick: $onClick,
+ );
}
return parent::_prepareLayout();
diff --git a/app/code/core/Mage/Widget/Block/Adminhtml/Widget.php b/app/code/core/Mage/Widget/Block/Adminhtml/Widget.php
index 59d06090c2d..d4adda860a8 100644
--- a/app/code/core/Mage/Widget/Block/Adminhtml/Widget.php
+++ b/app/code/core/Mage/Widget/Block/Adminhtml/Widget.php
@@ -23,8 +23,8 @@ public function __construct()
$this->_mode = 'widget';
$this->_headerText = $this->helper('widget')->__('Widget Insertion');
- $this->removeButton('reset');
- $this->removeButton('back');
+ $this->removeButton(self::BUTTON_TYPE_RESET);
+ $this->removeButton(self::BUTTON_TYPE_BACK);
$this->_updateButton(self::BUTTON_TYPE_SAVE, 'label', $this->helper('widget')->__('Insert Widget'));
$this->_updateButton(self::BUTTON_TYPE_SAVE, 'class', 'add-widget');
$this->_updateButton(self::BUTTON_TYPE_SAVE, 'id', 'insert_button');
diff --git a/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit.php b/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit.php
index e71d6b7a440..babb7805a95 100644
--- a/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit.php
+++ b/app/code/core/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit.php
@@ -46,17 +46,13 @@ public function getWidgetInstance()
protected function _prepareLayout()
{
if ($this->getWidgetInstance()->isCompleteToCreate()) {
- $this->_addButton(
- 'save_and_edit_button',
- [
- 'label' => Mage::helper('widget')->__('Save and Continue Edit'),
- 'class' => 'save continue',
- 'onclick' => 'saveAndContinueEdit()',
- ],
- 100,
+ $this->_addPreparedButton(
+ id: self::BUTTON_TYPE_SAVE_EDIT,
+ level: 100,
+ module: 'widget',
);
} else {
- $this->removeButton('save');
+ $this->removeButton(self::BUTTON_TYPE_SAVE);
}
return parent::_prepareLayout();
diff --git a/dev/rector/Migration/Mage/Adminhtml.php b/dev/rector/Migration/Mage/Adminhtml.php
index dd22a2cc45f..9e2da16deb5 100644
--- a/dev/rector/Migration/Mage/Adminhtml.php
+++ b/dev/rector/Migration/Mage/Adminhtml.php
@@ -48,6 +48,19 @@ public static function renameMethod(): array
public static function replaceArgumentDefaultValue(): array
{
return [
+ new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, 'removeButton', 0, 'add', 'self::BUTTON_TYPE_ADD'),
+ new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, 'removeButton', 0, 'back', 'self::BUTTON_TYPE_BACK'),
+ new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, 'removeButton', 0, 'cancel', 'self::BUTTON_TYPE_CANCEL'),
+ new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, 'removeButton', 0, 'close', 'self::BUTTON_TYPE_CLOSE'),
+ new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, 'removeButton', 0, 'delete', 'self::BUTTON_TYPE_DELETE'),
+ new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, 'removeButton', 0, 'print', 'self::BUTTON_TYPE_PRINT'),
+ new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, 'removeButton', 0, 'reset', 'self::BUTTON_TYPE_RESET'),
+ new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, 'removeButton', 0, 'save', 'self::BUTTON_TYPE_SAVE'),
+ new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, 'removeButton', 0, 'savecontinue', 'self::BUTTON_TYPE_SAVE_EDIT'),
+ new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, 'removeButton', 0, 'saveandcontinue', 'self::BUTTON_TYPE_SAVE_EDIT'),
+ new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, 'removeButton', 0, 'save_and_continue', 'self::BUTTON_TYPE_SAVE_EDIT'),
+ new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, 'removeButton', 0, 'save_and_edit', 'self::BUTTON_TYPE_SAVE_EDIT'),
+ new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, 'removeButton', 0, 'void', 'self::BUTTON_TYPE_VOID'),
new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, '_addButton', 0, 'add', 'self::BUTTON_TYPE_ADD'),
new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, '_addButton', 0, 'back', 'self::BUTTON_TYPE_BACK'),
new ReplaceArgumentDefaultValue(Mage_Adminhtml_Block_Widget_Container::class, '_addButton', 0, 'cancel', 'self::BUTTON_TYPE_CANCEL'),