From 4ec816b3ff425e0d2fab8be96c5f1c3ca1a8a2e0 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 21 Apr 2026 10:01:19 +0200 Subject: [PATCH 01/26] update buttons --- .../Block/Catalog/Product/Attribute/Edit.php | 12 ++-- .../Mage/Adminhtml/Block/Cms/Block/Edit.php | 10 +-- .../Mage/Adminhtml/Block/Cms/Page/Edit.php | 10 +-- .../Mage/Adminhtml/Block/Customer/Edit.php | 11 ++-- .../Adminhtml/Block/Promo/Catalog/Edit.php | 11 ++-- .../Mage/Adminhtml/Block/Promo/Quote/Edit.php | 11 ++-- .../Block/Sales/Transactions/Detail.php | 9 ++- .../Block/System/Convert/Gui/Edit.php | 11 ++-- .../Block/System/Convert/Profile/Edit.php | 11 ++-- .../Adminhtml/Block/System/Variable/Edit.php | 11 ++-- .../core/Mage/Adminhtml/Block/Tag/Edit.php | 11 ++-- .../Mage/Adminhtml/Block/Tax/Rule/Edit.php | 10 +-- .../Mage/Adminhtml/Block/Urlrewrite/Edit.php | 10 +-- .../Mage/Adminhtml/Block/Widget/Container.php | 66 +++++++++++++++++++ .../Adminhtml/Block/Widget/Form/Container.php | 31 ++++----- .../Adminhtml/Block/Widget/Grid/Container.php | 9 ++- .../Adminhtml/Block/Widget/View/Container.php | 9 ++- .../Block/Adminhtml/Oauth/Consumer/Edit.php | 10 +-- .../Adminhtml/Billing/Agreement/View.php | 9 ++- .../Adminhtml/Recurring/Profile/View.php | 6 +- .../Block/Adminhtml/Widget/Instance/Edit.php | 12 ++-- 21 files changed, 167 insertions(+), 123 deletions(-) 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 a68510d0aca..0a8d40d7e29 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 @@ -33,14 +33,10 @@ public function __construct() ], ); } 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 17caa2c615e..8da4b665567 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,11 @@ public function __construct() parent::__construct(); if ($this->_isAllowedAction('save')) { - $this->_addButton('saveandcontinue', [ - 'label' => Mage::helper('adminhtml')->__('Save and Continue Edit'), - 'onclick' => 'saveAndContinueEdit()', - 'class' => 'save continue', - ], -100); + $this->_addPreparedButton( + id: self::BUTTON_TYPE_SAVE_EDIT, + level: -100, + module: 'catalog', + ); } else { $this->_removeButton('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 22706d008a9..3f0681727a6 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('saveandcontinue', [ - '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('save'); } diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php index e4af46c1b1a..24e1489a9da 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php @@ -95,11 +95,12 @@ public function getValidationUrl() protected function _prepareLayout() { if (!Mage::registry('current_customer')->isReadonly()) { - $this->_addButton('save_and_continue', [ - '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/Edit.php b/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit.php index 0febd38ee5f..8cd9bcde163 100644 --- a/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Promo/Catalog/Edit.php @@ -33,11 +33,12 @@ public function __construct() '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/Transactions/Detail.php b/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Detail.php index 3af47b3c771..fe0cbfbebbc 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Detail.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Transactions/Detail.php @@ -50,11 +50,10 @@ public function __construct() $this->_txn = Mage::registry('current_transaction'); $backUrl = ($this->_txn->getOrderUrl()) ? $this->_txn->getOrderUrl() : $this->getUrl('*/*/'); - $this->_addButton('back', [ - 'label' => Mage::helper('sales')->__('Back'), - 'onclick' => Mage::helper('core/js')->getSetLocationJs($backUrl), - 'class' => 'back', - ]); + $this->_addPreparedButton( + id: self::BUTTON_TYPE_BACK, + onClick: Mage::helper('core/js')->getSetLocationJs($backUrl), + ); if (Mage::getSingleton('admin/session')->isAllowed('sales/transactions/fetch') && $this->_txn->getOrderPaymentObject()->getMethodInstance()->canFetchTransactionInfo() 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 9ae5785d1c1..dedeacd1b2e 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('save', 'label', Mage::helper('adminhtml')->__('Save Profile')); $this->_updateButton('delete', 'label', Mage::helper('adminhtml')->__('Delete Profile')); - $this->_addButton('savecontinue', [ - '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 1d3608e93c7..8fd152c370d 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('save', 'label', Mage::helper('adminhtml')->__('Save Profile')); $this->_updateButton('delete', 'label', Mage::helper('adminhtml')->__('Delete Profile')); - $this->_addButton('savecontinue', [ - '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/Variable/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php index 1ba30b5b516..634a44b7ab7 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php @@ -39,11 +39,12 @@ public function getVariable() #[Override] protected function _prepareLayout() { - $this->_addButton('save_and_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'); } diff --git a/app/code/core/Mage/Adminhtml/Block/Tag/Edit.php b/app/code/core/Mage/Adminhtml/Block/Tag/Edit.php index 78bfafa9e6d..e41865558f5 100644 --- a/app/code/core/Mage/Adminhtml/Block/Tag/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Tag/Edit.php @@ -28,11 +28,12 @@ public function __construct() $this->_updateButton('save', 'label', Mage::helper('tag')->__('Save Tag')); $this->_updateButton('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, + level: 1, + 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 499d207823d..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('save_and_continue', [ - '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 698704df42a..1563925bed8 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('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()) { @@ -96,7 +92,7 @@ protected function _prepareLayout() ]), ); $this->_updateButton( - 'back', + self::BUTTON_TYPE_BACK, 'onclick', Mage::helper('core/js')->getSetLocationJs(Mage::helper('adminhtml')::getUrl('*/*/edit') . 'product'), ); diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Container.php b/app/code/core/Mage/Adminhtml/Block/Widget/Container.php index e997e8cf61e..7768932855b 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Container.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Container.php @@ -14,6 +14,16 @@ */ class Mage_Adminhtml_Block_Widget_Container extends Mage_Adminhtml_Block_Template { + public const BUTTON_TYPE_BACK = 'back'; + + public const BUTTON_TYPE_DELETE = 'delete'; + + public const BUTTON_TYPE_RESET = 'reset'; + + public const BUTTON_TYPE_SAVE = 'save'; + + public const BUTTON_TYPE_SAVE_EDIT = 'save-edit'; + /** * So-called "container controller" to specify group of blocks participating in some action * @@ -62,6 +72,62 @@ protected function _addButton($id, $data, $level = 0, $sortOrder = 0, $area = 'h return $this; } + /** + * @param self::BUTTON_TYPE_* $id + * @return $this + */ + protected function _addPreparedButton( + string $id, + array $data, + int $level = 0, + int $sortOrder = 0, + string $area = 'header', + string $module = 'adminhtml', + ?string $onClick = null + ) { + if (is_null($onClick)) { + $onClick = match ($id) { + self::BUTTON_TYPE_BACK => Mage::helper('core/js')->getSetLocationJs(Mage::helper('adminhtml')::getUrl('*/*/')), + self::BUTTON_TYPE_RESET => 'setLocation(window.location.href)', + self::BUTTON_TYPE_SAVE => 'editForm.submit();', + self::BUTTON_TYPE_SAVE_EDIT => 'saveAndContinueEdit()', + default => '', + }; + } + + match ($id) { + self::BUTTON_TYPE_BACK => $data = array_merge([ + 'label' => Mage::helper($module)->__('Back'), + 'class' => 'back', + 'onclick' => $onClick, + 'level' => -1, + ], $data), + self::BUTTON_TYPE_DELETE => $data = array_merge([ + 'label' => Mage::helper($module)->__('Delete'), + 'class' => 'delete', + ], $data), + self::BUTTON_TYPE_RESET => $data = array_merge([ + 'label' => Mage::helper($module)->__('Reset'), + 'class' => 'reset', + 'onclick' => $onClick, + 'level' => -1, + ], $data), + self::BUTTON_TYPE_SAVE => $data = array_merge([ + 'label' => Mage::helper($module)->__('Save'), + 'class' => 'save', + 'onclick' => $onClick, + 'level' => 1, + ], $data), + self::BUTTON_TYPE_SAVE_EDIT => $data = array_merge([ + 'label' => Mage::helper($module)->__('Save and Continue Edit'), + 'class' => 'save continue', + 'onclick' => $onClick, + ], $data), + }; + + return $this->_addButton($id, $data); + } + /** * 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 dab09877809..da43a8d41e3 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('back', [ - 'label' => Mage::helper('adminhtml')->__('Back'), - 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getBackUrl()), - 'class' => 'back', - ], -1); - $this->_addButton('reset', [ - 'label' => Mage::helper('adminhtml')->__('Reset'), - 'onclick' => 'setLocation(window.location.href)', - 'class' => 'reset', - ], -1); + $this->_addPreparedButton( + id: self::BUTTON_TYPE_BACK, + onClick: Mage::helper('core/js')->getSetLocationJs($this->getBackUrl()), + ); + + $this->_addPreparedButton(id: self::BUTTON_TYPE_RESET); $objId = $this->getRequest()->getParam($this->_objectId); if (!empty($objId)) { - $this->_addButton('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('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 766d9afdb38..24a7ff8be9e 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php @@ -103,11 +103,10 @@ protected function getBackButtonLabel() protected function _addBackButton() { - $this->_addButton('back', [ - 'label' => $this->getBackButtonLabel(), - 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getBackUrl()), - 'class' => 'back', - ]); + $this->_addPreparedButton( + id: self::BUTTON_TYPE_BACK, + onClick: Mage::helper('core/js')->getSetLocationJs($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 c86b28ef8af..8d0326e65f0 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/View/Container.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/View/Container.php @@ -22,11 +22,10 @@ public function __construct() $this->setTemplate('widget/view/container.phtml'); - $this->_addButton('back', [ - 'label' => Mage::helper('adminhtml')->__('Back'), - 'onclick' => "window.location.href='" . $this->getUrl('*/*/') . "'", - 'class' => 'back', - ]); + $this->_addPreparedButton( + id: self::BUTTON_TYPE_BACK, + onClick: "window.location.href='" . $this->getUrl('*/*/') . "'", + ); $this->_addButton('edit', [ 'label' => Mage::helper('adminhtml')->__('Edit'), 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 98d5c7762c7..83eb6af84e4 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('save_and_continue', [ - '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/Sales/Block/Adminhtml/Billing/Agreement/View.php b/app/code/core/Mage/Sales/Block/Adminhtml/Billing/Agreement/View.php index f19d07d0c49..6c187408ec1 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,11 +35,10 @@ public function __construct() $this->_removeButton('save'); $this->setId('billing_agreement_view'); - $this->_addButton('back', [ - 'label' => Mage::helper('adminhtml')->__('Back'), - 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getBackUrl()), - 'class' => 'back', - ], -1); + $this->_addPreparedButton( + id: self::BUTTON_TYPE_BACK, + onClick: Mage::helper('core/js')->getSetLocationJs($this->getBackUrl()) + ); if ($this->_getBillingAgreement()->canCancel() && $this->_isAllowed('sales/billing_agreement/actions/manage')) { $this->_addButton('cancel', [ 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 240c26ca11a..ac28b893876 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,11 +26,7 @@ class Mage_Sales_Block_Adminhtml_Recurring_Profile_View extends Mage_Adminhtml_B #[Override] protected function _prepareLayout() { - $this->_addButton('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'); 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..6848ab5b968 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,14 +46,10 @@ 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'); From d1f8b99ef4fcfdf2b79355ff45c243a7fe7dd52d Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 21 Apr 2026 11:08:45 +0200 Subject: [PATCH 02/26] added data-test id to login. --- app/design/adminhtml/base/default/template/login.phtml | 4 ++-- app/design/adminhtml/openmage/default/template/login.phtml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/design/adminhtml/base/default/template/login.phtml b/app/design/adminhtml/base/default/template/login.phtml index d50f9dd5e2c..70a63064aca 100644 --- a/app/design/adminhtml/base/default/template/login.phtml +++ b/app/design/adminhtml/base/default/template/login.phtml @@ -35,11 +35,11 @@

- +

- +
getChildHtml('form.additional.info') ?>
diff --git a/app/design/adminhtml/openmage/default/template/login.phtml b/app/design/adminhtml/openmage/default/template/login.phtml index 10d25b8cc4f..fbd02c92237 100644 --- a/app/design/adminhtml/openmage/default/template/login.phtml +++ b/app/design/adminhtml/openmage/default/template/login.phtml @@ -34,11 +34,11 @@

- +

- +
getChildHtml('form.additional.info') ?>
From b5003899d6a8be76ea3a8f5c6d8aac48dea13195 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 21 Apr 2026 11:25:11 +0200 Subject: [PATCH 03/26] update --- .../Block/Catalog/Product/Attribute/Edit.php | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) 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 0a8d40d7e29..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 @@ -22,15 +22,10 @@ public function __construct() parent::__construct(); if ($this->getRequest()->getParam('popup')) { - $this->_removeButton('back'); - $this->_addButton( - 'close', - [ - 'label' => Mage::helper('catalog')->__('Close Window'), - 'class' => 'cancel', - 'onclick' => 'window.close()', - 'level' => -1, - ], + $this->_removeButton(self::BUTTON_TYPE_BACK); + $this->_addPreparedButton( + id: self::BUTTON_TYPE_CLOSE, + module: 'catalog', ); } else { $this->_addPreparedButton( @@ -40,13 +35,13 @@ public function __construct() ); } - $this->_updateButton('save', 'label', Mage::helper('catalog')->__('Save Attribute')); - $this->_updateButton('save', 'onclick', 'saveAttribute()'); + $this->_updateButton(self::BUTTON_TYPE_SAVE, 'label', Mage::helper('catalog')->__('Save Attribute')); + $this->_updateButton(self::BUTTON_TYPE_SAVE, 'onclick', 'saveAttribute()'); if (!Mage::registry('entity_attribute')->getIsUserDefined()) { - $this->_removeButton('delete'); + $this->_removeButton(self::BUTTON_TYPE_DELETE); } else { - $this->_updateButton('delete', 'label', Mage::helper('catalog')->__('Delete Attribute')); + $this->_updateButton(self::BUTTON_TYPE_DELETE, 'label', Mage::helper('catalog')->__('Delete Attribute')); } } From 7e3263732ed9cfc4c23150f007b88519fcb68294 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 21 Apr 2026 11:43:21 +0200 Subject: [PATCH 04/26] update --- .../Mage/Adminhtml/Block/Cms/Block/Edit.php | 4 ++-- .../core/Mage/Adminhtml/Block/Cms/Page/Edit.php | 4 ++-- .../Adminhtml/Block/System/Convert/Gui/Edit.php | 4 ++-- .../Block/System/Convert/Profile/Edit.php | 4 ++-- .../Adminhtml/Block/System/Variable/Edit.php | 2 +- app/code/core/Mage/Adminhtml/Block/Tag/Edit.php | 4 ++-- .../Mage/Adminhtml/Block/Widget/Container.php | 17 +++++++++++++++++ .../Block/Adminhtml/Oauth/Consumer/Edit.php | 8 ++++---- .../Block/Adminhtml/Billing/Agreement/View.php | 17 ++++++++--------- .../Block/Adminhtml/Recurring/Profile/View.php | 10 +++++----- .../Block/Adminhtml/Widget/Instance/Edit.php | 2 +- 11 files changed, 46 insertions(+), 30 deletions(-) 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 8da4b665567..4df8244ebeb 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Block/Edit.php @@ -28,11 +28,11 @@ public function __construct() module: 'catalog', ); } else { - $this->_removeButton('save'); + $this->_removeButton(self::BUTTON_TYPE_SAVE); } if (!$this->_isAllowedAction('delete')) { - $this->_removeButton('delete'); + $this->_removeButton(self::BUTTON_TYPE_DELETE); } } 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 3f0681727a6..0b7fcf86a02 100644 --- a/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit.php @@ -32,11 +32,11 @@ public function __construct() onClick: Mage::helper('core/js')->getSaveAndContinueEditJs($this->_getSaveAndContinueUrl()), ); } else { - $this->_removeButton('save'); + $this->_removeButton(self::BUTTON_TYPE_SAVE); } if (!$this->_isAllowedAction('delete')) { - $this->_removeButton('delete'); + $this->_removeButton(self::BUTTON_TYPE_DELETE); } } 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 dedeacd1b2e..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 @@ -21,8 +21,8 @@ public function __construct() parent::__construct(); - $this->_updateButton('save', 'label', Mage::helper('adminhtml')->__('Save Profile')); - $this->_updateButton('delete', 'label', Mage::helper('adminhtml')->__('Delete Profile')); + $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->_addPreparedButton( id: self::BUTTON_TYPE_SAVE_EDIT, 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 8fd152c370d..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 @@ -21,8 +21,8 @@ public function __construct() parent::__construct(); - $this->_updateButton('save', 'label', Mage::helper('adminhtml')->__('Save Profile')); - $this->_updateButton('delete', 'label', Mage::helper('adminhtml')->__('Delete Profile')); + $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->_addPreparedButton( id: self::BUTTON_TYPE_SAVE_EDIT, 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 634a44b7ab7..6da70ac215a 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Variable/Edit.php @@ -46,7 +46,7 @@ protected function _prepareLayout() ); 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 e41865558f5..1307fa99543 100644 --- a/app/code/core/Mage/Adminhtml/Block/Tag/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Tag/Edit.php @@ -25,8 +25,8 @@ public function __construct() parent::__construct(); - $this->_updateButton('save', 'label', Mage::helper('tag')->__('Save Tag')); - $this->_updateButton('delete', 'label', Mage::helper('tag')->__('Delete Tag')); + $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->_addPreparedButton( id: self::BUTTON_TYPE_SAVE_EDIT, diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Container.php b/app/code/core/Mage/Adminhtml/Block/Widget/Container.php index 7768932855b..c2afd46dfd2 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Container.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Container.php @@ -16,6 +16,10 @@ class Mage_Adminhtml_Block_Widget_Container extends Mage_Adminhtml_Block_Templat { public const BUTTON_TYPE_BACK = 'back'; + public const BUTTON_TYPE_CANCEL = 'cancel'; + + public const BUTTON_TYPE_CLOSE = 'close'; + public const BUTTON_TYPE_DELETE = 'delete'; public const BUTTON_TYPE_RESET = 'reset'; @@ -88,6 +92,7 @@ protected function _addPreparedButton( if (is_null($onClick)) { $onClick = match ($id) { self::BUTTON_TYPE_BACK => Mage::helper('core/js')->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()', @@ -102,6 +107,18 @@ protected function _addPreparedButton( 'onclick' => $onClick, 'level' => -1, ], $data), + self::BUTTON_TYPE_CANCEL => $data = array_merge([ + 'label' => Mage::helper($module)->__('Cancel'), + 'class' => 'cancel', + 'onclick' => $onClick, + 'level' => -1, + ], $data), + self::BUTTON_TYPE_CLOSE => $data = array_merge([ + 'label' => Mage::helper($module)->__('Close Window'), + 'class' => 'cancel', + 'onclick' => $onClick, + 'level' => -1, + ], $data), self::BUTTON_TYPE_DELETE => $data = array_merge([ 'label' => Mage::helper($module)->__('Delete'), 'class' => '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 83eb6af84e4..0c19c213517 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 @@ -54,10 +54,10 @@ public function __construct() $this->_formScripts[] = 'function saveAndContinueEdit()' . "{editForm.submit($('edit_form').action + 'back/edit/')}"; - $this->_updateButton('save', 'label', $this->__('Save')); - $this->_updateButton('save', 'id', 'save_button'); - $this->_updateButton('delete', 'label', $this->__('Delete')); - $this->_updateButton('delete', 'onclick', "if(confirm('" . Mage::helper('core')->jsQuoteEscape( + $this->_updateButton(self::BUTTON_TYPE_SAVE, 'label', $this->__('Save')); + $this->_updateButton(self::BUTTON_TYPE_SAVE, 'id', 'save_button'); + $this->_updateButton(self::BUTTON_TYPE_DELETE, 'label', $this->__('Delete')); + $this->_updateButton(self::BUTTON_TYPE_DELETE, 'onclick', "if(confirm('" . Mage::helper('core')->jsQuoteEscape( Mage::helper('adminhtml')->__('Are you sure you want to do this?'), ) . "')) editForm.submit('" . $this->getUrl('*/*/delete') . "'); return false;"); 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 6c187408ec1..be14cfc89a9 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 @@ -28,24 +28,23 @@ public function __construct() parent::__construct(); if (!$this->_isAllowed('sales/billing_agreement/actions/manage')) { - $this->_removeButton('delete'); + $this->_removeButton(self::BUTTON_TYPE_DELETE); } - $this->_removeButton('reset'); - $this->_removeButton('save'); + $this->_removeButton(self::BUTTON_TYPE_RESET); + $this->_removeButton(self::BUTTON_TYPE_SAVE); $this->setId('billing_agreement_view'); $this->_addPreparedButton( id: self::BUTTON_TYPE_BACK, - onClick: Mage::helper('core/js')->getSetLocationJs($this->getBackUrl()) + onClick: Mage::helper('core/js')->getSetLocationJs($this->getBackUrl()), ); if ($this->_getBillingAgreement()->canCancel() && $this->_isAllowed('sales/billing_agreement/actions/manage')) { - $this->_addButton('cancel', [ - 'label' => Mage::helper('adminhtml')->__('Cancel'), - 'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs($this->_getCancelUrl()), - 'class' => 'cancel', - ], -1); + $this->_addPreparedButton( + id: self::BUTTON_TYPE_CANCEL, + onClick: Mage::helper('core/js')->getConfirmSetLocationJs($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 ac28b893876..12a0c6dc34d 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 @@ -32,13 +32,13 @@ protected function _prepareLayout() // cancel if ($profile->canCancel()) { - $this->_addButton('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 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 6848ab5b968..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 @@ -52,7 +52,7 @@ protected function _prepareLayout() module: 'widget', ); } else { - $this->removeButton('save'); + $this->removeButton(self::BUTTON_TYPE_SAVE); } return parent::_prepareLayout(); From 15b428904e664d5aa3bcf141315bad198eaa2a88 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 21 Apr 2026 12:09:00 +0200 Subject: [PATCH 05/26] update --- .../Block/Sales/Order/Creditmemo/View.php | 37 +++++++++---------- .../Block/Sales/Order/Invoice/View.php | 36 +++++++++--------- .../Adminhtml/Block/System/Store/Delete.php | 19 ++++++---- .../Mage/Adminhtml/Block/Widget/Container.php | 17 ++++++++- 4 files changed, 62 insertions(+), 47 deletions(-) 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 2c190b954cf..873505ffd44 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 @@ -26,16 +26,16 @@ public function __construct() parent::__construct(); - $this->_removeButton('save'); - $this->_removeButton('reset'); - $this->_removeButton('delete'); + $this->_removeButton(self::BUTTON_TYPE_SAVE); + $this->_removeButton(self::BUTTON_TYPE_RESET); + $this->_removeButton(self::BUTTON_TYPE_DELETE); if ($this->getCreditmemo()->canCancel()) { - $this->_addButton('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', + onClick: Mage::helper('core/js')->getSetLocationJs($this->getCancelUrl()), + ); } if ($this->_isAllowedAction('emails')) { @@ -58,20 +58,19 @@ public function __construct() } if ($this->getCreditmemo()->canVoid()) { - $this->_addButton('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', + onClick: Mage::helper('core/js')->getSetLocationJs($this->getVoidUrl()), + ); } if ($this->getCreditmemo()->getId()) { - $this->_addButton('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', + onClick: Mage::helper('core/js')->getSetLocationJs($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 722b9a3f764..5103305d25a 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 @@ -34,16 +34,16 @@ public function __construct() parent::__construct(); - $this->_removeButton('save'); - $this->_removeButton('reset'); - $this->_removeButton('delete'); + $this->_removeButton(self::BUTTON_TYPE_SAVE); + $this->_removeButton(self::BUTTON_TYPE_RESET); + $this->_removeButton(self::BUTTON_TYPE_DELETE); if ($this->_isAllowedAction('cancel') && $this->getInvoice()->canCancel()) { - $this->_addButton('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', + onClick: Mage::helper('core/js')->getSetLocationJs($this->getCancelUrl()), + ); } if ($this->_isAllowedAction('emails')) { @@ -83,19 +83,19 @@ public function __construct() } if ($this->getInvoice()->canVoid()) { - $this->_addButton('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', + onClick: Mage::helper('core/js')->getSetLocationJs($this->getVoidUrl()), + ); } if ($this->getInvoice()->getId()) { - $this->_addButton('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', + onClick: Mage::helper('core/js')->getSetLocationJs($this->getPrintUrl()), + ); } } 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 673de4ca1ce..d3b7314aca3 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Store/Delete.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Store/Delete.php @@ -28,16 +28,19 @@ public function __construct() parent::__construct(); - $this->_removeButton('save'); - $this->_removeButton('reset'); + $this->_removeButton(self::BUTTON_TYPE_SAVE); + $this->_removeButton(self::BUTTON_TYPE_RESET); - $this->_updateButton('delete', 'area', 'footer'); - $this->_updateButton('delete', 'onclick', 'editForm.submit();'); + $this->_updateButton(self::BUTTON_TYPE_DELETE, 'area', 'footer'); + $this->_updateButton(self::BUTTON_TYPE_DELETE, 'onclick', 'editForm.submit();'); - $this->_addButton('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', + onClick: Mage::helper('core/js')->getSetLocationJs($this->getBackUrl()), + ); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Container.php b/app/code/core/Mage/Adminhtml/Block/Widget/Container.php index c2afd46dfd2..c8f78d4e32c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Container.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Container.php @@ -22,12 +22,16 @@ class Mage_Adminhtml_Block_Widget_Container extends Mage_Adminhtml_Block_Templat public const BUTTON_TYPE_DELETE = 'delete'; + public const BUTTON_TYPE_PRINT = 'print'; + public const BUTTON_TYPE_RESET = 'reset'; public const BUTTON_TYPE_SAVE = 'save'; public const BUTTON_TYPE_SAVE_EDIT = 'save-edit'; + public const BUTTON_TYPE_VOID = 'void'; + /** * So-called "container controller" to specify group of blocks participating in some action * @@ -109,7 +113,7 @@ protected function _addPreparedButton( ], $data), self::BUTTON_TYPE_CANCEL => $data = array_merge([ 'label' => Mage::helper($module)->__('Cancel'), - 'class' => 'cancel', + 'class' => 'cancel delete', 'onclick' => $onClick, 'level' => -1, ], $data), @@ -123,6 +127,10 @@ protected function _addPreparedButton( 'label' => Mage::helper($module)->__('Delete'), 'class' => 'delete', ], $data), + self::BUTTON_TYPE_PRINT => $data = array_merge([ + 'label' => Mage::helper($module)->__('Print'), + 'class' => 'save print', + ], $data), self::BUTTON_TYPE_RESET => $data = array_merge([ 'label' => Mage::helper($module)->__('Reset'), 'class' => 'reset', @@ -140,9 +148,14 @@ protected function _addPreparedButton( 'class' => 'save continue', 'onclick' => $onClick, ], $data), + self::BUTTON_TYPE_VOID => $data = array_merge([ + 'label' => Mage::helper($module)->__('Void'), + 'class' => 'save void', + 'onclick' => $onClick, + ], $data), }; - return $this->_addButton($id, $data); + return $this->_addButton($id, $data, $level, $sortOrder, $area); } /** From 21798c7a588fb8e385deea4087c30545624533be Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 21 Apr 2026 12:25:02 +0200 Subject: [PATCH 06/26] update --- .../core/Mage/Adminhtml/Block/Customer/Edit.php | 6 +++--- .../Mage/Adminhtml/Block/Customer/Group/Edit.php | 2 +- .../Mage/Adminhtml/Block/Sales/Order/Address.php | 4 ++-- .../Block/Sales/Order/Creditmemo/Create.php | 4 ++-- .../Block/Sales/Order/Invoice/Create.php | 4 ++-- .../Block/Sales/Order/Shipment/Create.php | 4 ++-- .../Block/Sales/Order/Shipment/View.php | 16 ++++++++-------- .../Block/Sales/Order/Status/Assign.php | 4 ++-- .../Adminhtml/Block/Sales/Order/Status/New.php | 4 ++-- .../Mage/Adminhtml/Block/Sales/Order/View.php | 6 +++--- .../Mage/Adminhtml/Block/System/Account/Edit.php | 2 +- .../Mage/Adminhtml/Block/System/Store/Edit.php | 11 ++++++----- .../Mage/Index/Block/Adminhtml/Process/Edit.php | 6 +++--- .../Block/Adminhtml/Oauth/Consumer/Edit.php | 2 +- 14 files changed, 38 insertions(+), 37 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php index 24e1489a9da..68d57a39425 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit.php @@ -33,12 +33,12 @@ public function __construct() parent::__construct(); if (Mage::registry('current_customer')->isReadonly()) { - $this->_removeButton('save'); - $this->_removeButton('reset'); + $this->_removeButton(self::BUTTON_TYPE_SAVE); + $this->_removeButton(self::BUTTON_TYPE_RESET); } if (!Mage::registry('current_customer')->isDeleteable()) { - $this->_removeButton('delete'); + $this->_removeButton(self::BUTTON_TYPE_DELETE); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit.php b/app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit.php index a9041ed4f74..c099e331dfd 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Group/Edit.php @@ -22,7 +22,7 @@ public function __construct() $this->_controller = 'customer_group'; if (!Mage::registry('current_group')->getId() || Mage::registry('current_group')->usesAsDefault()) { - $this->_removeButton('delete'); + $this->_removeButton(self::BUTTON_TYPE_DELETE); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Address.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Address.php index 69f8ca8aee2..a7e37dfc8e3 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Address.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Address.php @@ -19,8 +19,8 @@ public function __construct() $this->_controller = 'sales_order'; $this->_mode = 'address'; parent::__construct(); - $this->_updateButton('save', 'label', Mage::helper('sales')->__('Save Order Address')); - $this->_removeButton('delete'); + $this->_updateButton(self::BUTTON_TYPE_SAVE, 'label', Mage::helper('sales')->__('Save Order Address')); + $this->_removeButton(self::BUTTON_TYPE_DELETE); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create.php index 61a045bd61f..f510a4df31a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Creditmemo/Create.php @@ -22,8 +22,8 @@ public function __construct() parent::__construct(); - $this->_removeButton('delete'); - $this->_removeButton('save'); + $this->_removeButton(self::BUTTON_TYPE_DELETE); + $this->_removeButton(self::BUTTON_TYPE_SAVE); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create.php index 4b281bd7dc5..016185bf87a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Invoice/Create.php @@ -22,8 +22,8 @@ public function __construct() parent::__construct(); - $this->_removeButton('save'); - $this->_removeButton('delete'); + $this->_removeButton(self::BUTTON_TYPE_SAVE); + $this->_removeButton(self::BUTTON_TYPE_DELETE); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create.php index 44d8381d328..fe7072a7c76 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Shipment/Create.php @@ -22,8 +22,8 @@ public function __construct() parent::__construct(); - $this->_removeButton('save'); - $this->_removeButton('delete'); + $this->_removeButton(self::BUTTON_TYPE_SAVE); + $this->_removeButton(self::BUTTON_TYPE_DELETE); } /** 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 964b21c1fbe..404be0180ac 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 @@ -26,13 +26,13 @@ public function __construct() parent::__construct(); - $this->_removeButton('reset'); - $this->_removeButton('delete'); + $this->_removeButton(self::BUTTON_TYPE_RESET); + $this->_removeButton(self::BUTTON_TYPE_DELETE); if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/emails')) { $this->_updateButton('save', 'label', Mage::helper('sales')->__('Send Tracking Information')); $this->_updateButton('save', 'class', 'save send-email'); $this->_updateButton( - 'save', + self::BUTTON_TYPE_SAVE, 'onclick', Mage::helper('core/js')->getDeleteConfirmJs( $this->getEmailUrl(), @@ -42,11 +42,11 @@ public function __construct() } if ($this->getShipment()->getId()) { - $this->_addButton('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', + onClick: Mage::helper('core/js')->getSetLocationJs($this->getPrintUrl()), + ); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Assign.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Assign.php index e16409a8a20..a2c01c5f9fc 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Assign.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/Assign.php @@ -17,8 +17,8 @@ public function __construct() $this->_controller = 'sales_order_status'; $this->_mode = 'assign'; parent::__construct(); - $this->_updateButton('save', 'label', Mage::helper('sales')->__('Save Status Assignment')); - $this->_removeButton('delete'); + $this->_updateButton(self::BUTTON_TYPE_SAVE, 'label', Mage::helper('sales')->__('Save Status Assignment')); + $this->_removeButton(self::BUTTON_TYPE_DELETE); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/New.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/New.php index 2f63598349f..cfed3af9cd9 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/New.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Status/New.php @@ -19,8 +19,8 @@ public function __construct() $this->_mode = 'new'; parent::__construct(); - $this->_updateButton('save', 'label', Mage::helper('sales')->__('Save Status')); - $this->_removeButton('delete'); + $this->_updateButton(self::BUTTON_TYPE_SAVE, 'label', Mage::helper('sales')->__('Save Status')); + $this->_removeButton(self::BUTTON_TYPE_DELETE); } /** 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 ed86dba60a6..8e1df1e9a34 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View.php @@ -26,9 +26,9 @@ public function __construct() parent::__construct(); - $this->_removeButton('delete'); - $this->_removeButton('reset'); - $this->_removeButton('save'); + $this->_removeButton(self::BUTTON_TYPE_DELETE); + $this->_removeButton(self::BUTTON_TYPE_RESET); + $this->_removeButton(self::BUTTON_TYPE_SAVE); $this->setId('sales_order_view'); $order = $this->getOrder(); $coreHelper = Mage::helper('core'); diff --git a/app/code/core/Mage/Adminhtml/Block/System/Account/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Account/Edit.php index 37534d8749b..b7a702d25aa 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Account/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Account/Edit.php @@ -19,7 +19,7 @@ public function __construct() parent::__construct(); $this->_controller = 'system_account'; - $this->_removeButton('delete'); + $this->_removeButton(self::BUTTON_TYPE_DELETE); } /** 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 43c3eff927b..621524a5ea8 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Store/Edit.php @@ -51,16 +51,17 @@ public function __construct() parent::__construct(); - $this->_updateButton('save', 'label', $saveLabel); - $this->_updateButton('delete', 'label', $deleteLabel); - $this->_updateButton('delete', 'onclick', Mage::helper('core/js')->getConfirmSetLocationJs($deleteUrl)); + $this->_updateButton(self::BUTTON_TYPE_SAVE, 'label', $saveLabel); + $this->_updateButton(self::BUTTON_TYPE_DELETE, 'label', $deleteLabel); + $this->_updateButton(self::BUTTON_TYPE_DELETE, 'onclick', Mage::helper('core/js')->getConfirmSetLocationJs($deleteUrl)); if (!Mage::registry('store_data')->isCanDelete()) { - $this->_removeButton('delete'); + $this->_removeButton(self::BUTTON_TYPE_DELETE); } if (Mage::registry('store_data')->isReadOnly()) { - $this->_removeButton('save')->_removeButton('reset'); + $this->_removeButton(self::BUTTON_TYPE_SAVE) + ->_removeButton(self::BUTTON_TYPE_RESET); } } 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 24d3f80db2c..038da5c3b16 100644 --- a/app/code/core/Mage/Index/Block/Adminhtml/Process/Edit.php +++ b/app/code/core/Mage/Index/Block/Adminhtml/Process/Edit.php @@ -24,13 +24,13 @@ public function __construct() parent::__construct(); - $this->_updateButton('save', 'label', Mage::helper('cms')->__('Save Process')); + $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->_removeButton('reset'); - $this->_removeButton('delete'); + $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 0c19c213517..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 @@ -64,7 +64,7 @@ public function __construct() /** @var Mage_Admin_Model_Session $session */ $session = Mage::getSingleton('admin/session'); if (!$this->getModel() || !$this->getModel()->getId() || !$session->isAllowed('system/oauth/consumer/delete')) { - $this->_removeButton('delete'); + $this->_removeButton(self::BUTTON_TYPE_DELETE); } } From df96102cf0d5b9bce23c2f9343dbe4bb14b5c163 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 21 Apr 2026 12:35:14 +0200 Subject: [PATCH 07/26] update --- app/code/core/Mage/Adminhtml/Block/Widget/Container.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Container.php b/app/code/core/Mage/Adminhtml/Block/Widget/Container.php index c8f78d4e32c..2af41f337ee 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Container.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Container.php @@ -86,7 +86,7 @@ protected function _addButton($id, $data, $level = 0, $sortOrder = 0, $area = 'h */ protected function _addPreparedButton( string $id, - array $data, + array $data = [], int $level = 0, int $sortOrder = 0, string $area = 'header', From 0b450d87b043510d9ef2bec8b346ef006cb621f8 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Tue, 21 Apr 2026 12:48:03 +0200 Subject: [PATCH 08/26] varien elements --- lib/Varien/Data/Form/Element/Abstract.php | 13 +++++++++++-- lib/Varien/Data/Form/Element/Date.php | 3 ++- lib/Varien/Data/Form/Element/Editor.php | 1 + lib/Varien/Data/Form/Element/Multiselect.php | 8 ++++++-- lib/Varien/Data/Form/Element/Select.php | 6 +++++- lib/Varien/Data/Form/Element/Textarea.php | 6 +++++- 6 files changed, 30 insertions(+), 7 deletions(-) diff --git a/lib/Varien/Data/Form/Element/Abstract.php b/lib/Varien/Data/Form/Element/Abstract.php index b3765005ee1..20da3762c2c 100644 --- a/lib/Varien/Data/Form/Element/Abstract.php +++ b/lib/Varien/Data/Form/Element/Abstract.php @@ -239,13 +239,22 @@ public function getRenderer() return $this->_renderer; } + public function getTestId(): string + { + return 'input-' . str_replace('_', '-', $this->getHtmlId()); + } + /** * @return string */ public function getElementHtml() { - $html = 'serialize($this->getHtmlAttributes()) . '/>' . "\n"; + $html = 'serialize($this->getHtmlAttributes()) + . ' data-test="' . $this->getTestId() + . '"/>' . "\n"; return $html . $this->getAfterElementHtml(); } diff --git a/lib/Varien/Data/Form/Element/Date.php b/lib/Varien/Data/Form/Element/Date.php index 15e676dc593..db265a7dd9b 100644 --- a/lib/Varien/Data/Form/Element/Date.php +++ b/lib/Varien/Data/Form/Element/Date.php @@ -155,12 +155,13 @@ public function getElementHtml() $this->addClass('input-text'); $html = sprintf( - '' + '' . ' ', $this->getName(), $this->getHtmlId(), $this->_escape($this->getValue()), $this->serialize($this->getHtmlAttributes()), + $this->getTestId(), $this->getImage(), $this->getHtmlId(), 'Select Date', diff --git a/lib/Varien/Data/Form/Element/Editor.php b/lib/Varien/Data/Form/Element/Editor.php index 9601939223b..a5cf4ddbbc9 100644 --- a/lib/Varien/Data/Form/Element/Editor.php +++ b/lib/Varien/Data/Form/Element/Editor.php @@ -89,6 +89,7 @@ public function getElementHtml() . '' . $str . '