diff --git a/.phpstan.dist.baselines/booleanAnd.rightNotBoolean.php b/.phpstan.dist.baselines/booleanAnd.rightNotBoolean.php index 5e9c331deee..88bec28fbeb 100644 --- a/.phpstan.dist.baselines/booleanAnd.rightNotBoolean.php +++ b/.phpstan.dist.baselines/booleanAnd.rightNotBoolean.php @@ -61,11 +61,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in &&, int|string|null given on the right side.', - 'count' => 1, - 'path' => __DIR__ . '/../app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in &&, int|string|null given on the right side.', 'count' => 1, diff --git a/.phpstan.dist.baselines/booleanNot.exprNotBoolean.php b/.phpstan.dist.baselines/booleanNot.exprNotBoolean.php index 0977686bf4f..1dbb5abdf12 100644 --- a/.phpstan.dist.baselines/booleanNot.exprNotBoolean.php +++ b/.phpstan.dist.baselines/booleanNot.exprNotBoolean.php @@ -121,11 +121,6 @@ 'count' => 1, 'path' => __DIR__ . '/../app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php', ]; -$ignoreErrors[] = [ - 'rawMessage' => 'Only booleans are allowed in a negated boolean, mixed given.', - 'count' => 2, - 'path' => __DIR__ . '/../app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php', -]; $ignoreErrors[] = [ 'rawMessage' => 'Only booleans are allowed in a negated boolean, Varien_Data_Form_Element_Abstract|null given.', 'count' => 1, diff --git a/app/OpenMageVersionInterface.php b/app/OpenMageVersionInterface.php index 1f164f67e44..7c3a8eeff30 100644 --- a/app/OpenMageVersionInterface.php +++ b/app/OpenMageVersionInterface.php @@ -94,4 +94,6 @@ interface OpenMageVersionInterface public const VERSION_20_17_0 = '20.17.0'; public const VERSION_20_18_0 = '20.18.0'; + + public const VERSION_20_19_0 = '20.19.0'; } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php index 41ae27391dc..3be55dd93eb 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php @@ -12,130 +12,102 @@ * * @package Mage_Adminhtml */ -class Mage_Adminhtml_Block_Catalog_Product_Edit extends Mage_Adminhtml_Block_Widget +class Mage_Adminhtml_Block_Catalog_Product_Edit extends Mage_Adminhtml_Block_Widget_Container { public function __construct() { parent::__construct(); $this->setTemplate('catalog/product/edit.phtml'); $this->setId('product_edit'); - } - - /** - * Retrieve currently edited product object - * - * @return Mage_Catalog_Model_Product - */ - public function getProduct() - { - return Mage::registry('current_product'); - } - /** - * @inheritDoc - */ - #[Override] - protected function _prepareLayout() - { - if (!$this->getRequest()->getParam('popup')) { - $this->setChild( - 'back_button', - $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData([ - 'label' => Mage::helper('catalog')->__('Back'), - 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/', ['store' => $this->getRequest()->getParam('store', 0)])), - 'class' => 'back', - ]), - ); - } else { - $this->setChild( - 'back_button', - $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData([ - 'label' => Mage::helper('catalog')->__('Close Window'), - 'onclick' => 'window.close()', - 'class' => 'cancel', - ]), - ); + $isConfigured = $this->getIsConfigured(); + $isReadOnly = $this->getProduct()->isReadonly(); + $isPopup = (bool) $this->getRequest()->getParam('popup'); + $isProductId = (bool) $this->getProductId(); + $isProductSetId = (bool) $this->getProductSetId(); + + if ($isPopup) { + $this->_addButton(self::BUTTON_TYPE_CLOSE, [ + 'label' => Mage::helper('catalog')->__('Close Window'), + 'onclick' => 'window.close()', + 'class' => 'cancel', + ], -1); } - if (!$this->getProduct()->isReadonly()) { - $this->setChild( - 'reset_button', - $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData([ - 'label' => Mage::helper('catalog')->__('Reset'), - 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/*', ['_current' => true])), - 'class' => 'reset', - ]), - ); - - $this->setChild( - 'save_button', - $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData([ - 'label' => Mage::helper('catalog')->__('Save'), - 'onclick' => 'productForm.submit()', - 'class' => 'save', - ]), - ); + if (!$isPopup) { + $this->_addButton(self::BUTTON_TYPE_BACK, [ + 'label' => Mage::helper('catalog')->__('Back'), + 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/', ['store' => $this->getRequest()->getParam('store', 0)])), + 'class' => 'back', + ], -1); } - if (!$this->getRequest()->getParam('popup')) { - if (!$this->getProduct()->isReadonly()) { - $this->setChild( - 'save_and_edit_button', - $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData([ - 'label' => Mage::helper('catalog')->__('Save and Continue Edit'), - 'onclick' => Mage::helper('core/js')->getSaveAndContinueEditJs($this->getSaveAndContinueUrl()), - 'class' => 'save continue', - ]), - ); - } + if (!$isReadOnly) { + $this->_addButton(self::BUTTON_TYPE_RESET, [ + 'label' => Mage::helper('catalog')->__('Reset'), + 'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/*', ['_current' => true])), + 'class' => 'reset', + ], -1); + } - if ($this->getProduct()->isDeleteable()) { - $this->setChild( - 'delete_button', - $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData([ - 'label' => Mage::helper('catalog')->__('Delete'), - 'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs($this->getDeleteUrl()), - 'class' => 'delete', - ]), - ); - } + if (!$isPopup && $isProductId && $this->getProduct()->isDeleteable()) { + $this->_addButton(self::BUTTON_TYPE_DELETE, [ + 'label' => Mage::helper('catalog')->__('Delete'), + 'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs($this->getDeleteUrl()), + 'class' => 'delete', + ]); + } - if ($this->getProduct()->isDuplicable() && $this->getProduct()->getId()) { - if ($this->getProduct()->getMediaGalleryImages()->count() === 0) { - $onClickAction = Mage::helper('core/js')->getSetLocationJs($this->getDuplicateUrl(true)); - } else { - $skipImgOnDuplicate = $this->helper('catalog/image')->skipProductImageOnDuplicate(); - $onClickAction = "openDuplicateDialog('" . $this->getDuplicateUrl(false) . "','" . $this->getDuplicateUrl(true) . "'); return false;"; + if (!$isPopup && $isProductId && $isConfigured && $this->getProduct()->isDuplicable()) { + if ($this->getProduct()->getMediaGalleryImages()->count() === 0) { + $onClickAction = Mage::helper('core/js')->getSetLocationJs($this->getDuplicateUrl(true)); + } else { + $skipImgOnDuplicate = $this->helper('catalog/image')->skipProductImageOnDuplicate(); + $onClickAction = "openDuplicateDialog('" . $this->getDuplicateUrl(false) . "','" . $this->getDuplicateUrl(true) . "'); return false;"; - if ($skipImgOnDuplicate !== Mage_Catalog_Model_Product_Image::ON_DUPLICATE_ASK) { - $onClickAction = Mage::helper('core/js')->getSetLocationJs($this->getDuplicateUrl((bool) $skipImgOnDuplicate)); - } + if ($skipImgOnDuplicate !== Mage_Catalog_Model_Product_Image::ON_DUPLICATE_ASK) { + $onClickAction = Mage::helper('core/js')->getSetLocationJs($this->getDuplicateUrl((bool) $skipImgOnDuplicate)); } + } - $this->setChild( - 'duplicate_button', - $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData([ - 'label' => Mage::helper('catalog')->__('Duplicate'), - 'onclick' => $onClickAction, - 'class' => 'add duplicate', - ]), - ); + $this->_addButton(self::BUTTON_TYPE_DUPLICATE, [ + 'label' => Mage::helper('catalog')->__('Duplicate'), + 'onclick' => $onClickAction, + 'class' => 'add duplicate', + ], 1); + } + + if ($isProductSetId && $isConfigured && !$isReadOnly) { + $this->_addButton(self::BUTTON_TYPE_SAVE, [ + 'label' => Mage::helper('catalog')->__('Save'), + 'onclick' => 'productForm.submit()', + 'class' => 'save', + ], 1); + + if (!$isPopup) { + $this->_addButton(self::BUTTON_TYPE_SAVE_EDIT, [ + 'label' => Mage::helper('catalog')->__('Save and Continue Edit'), + 'onclick' => Mage::helper('core/js')->getSaveAndContinueEditJs($this->getSaveAndContinueUrl()), + 'class' => 'save continue', + ], 1); } } + } - return parent::_prepareLayout(); + /** + * Retrieve currently edited product object + * + * @return Mage_Catalog_Model_Product + */ + public function getProduct() + { + return Mage::registry('current_product'); } /** * @return string */ + #[Deprecated(message: 'Use $this->getButtonsHtml(\'header\')', since: OpenMageVersionInterface::VERSION_20_19_0)] public function getBackButtonHtml() { return $this->getChildHtml('back_button'); @@ -144,6 +116,7 @@ public function getBackButtonHtml() /** * @return string */ + #[Deprecated(message: 'Use $this->getButtonsHtml(\'header\')', since: OpenMageVersionInterface::VERSION_20_19_0)] public function getCancelButtonHtml() { return $this->getChildHtml('reset_button'); @@ -152,6 +125,7 @@ public function getCancelButtonHtml() /** * @return string */ + #[Deprecated(message: 'Use $this->getButtonsHtml(\'header\')', since: OpenMageVersionInterface::VERSION_20_19_0)] public function getSaveButtonHtml() { return $this->getChildHtml('save_button'); @@ -160,6 +134,7 @@ public function getSaveButtonHtml() /** * @return string */ + #[Deprecated(message: 'Use $this->getButtonsHtml(\'header\')', since: OpenMageVersionInterface::VERSION_20_19_0)] public function getSaveAndEditButtonHtml() { return $this->getChildHtml('save_and_edit_button'); @@ -168,6 +143,7 @@ public function getSaveAndEditButtonHtml() /** * @return string */ + #[Deprecated(message: 'Use $this->getButtonsHtml(\'header\')', since: OpenMageVersionInterface::VERSION_20_19_0)] public function getDeleteButtonHtml() { return $this->getChildHtml('delete_button'); @@ -176,6 +152,7 @@ public function getDeleteButtonHtml() /** * @return string */ + #[Deprecated(message: 'Use $this->getButtonsHtml(\'header\')', since: OpenMageVersionInterface::VERSION_20_19_0)] public function getDuplicateButtonHtml() { return $this->getChildHtml('duplicate_button'); diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Container.php b/app/code/core/Mage/Adminhtml/Block/Widget/Container.php index 366e4f1f7a2..4829e583f29 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Container.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Container.php @@ -34,6 +34,8 @@ class Mage_Adminhtml_Block_Widget_Container extends Mage_Adminhtml_Block_Templat public const BUTTON_TYPE_VOID = 'void'; + public const BUTTON_TYPE_DUPLICATE = 'duplicate'; + /** * So-called "container controller" to specify group of blocks participating in some action * diff --git a/app/design/adminhtml/base/default/template/catalog/product/edit.phtml b/app/design/adminhtml/base/default/template/catalog/product/edit.phtml index 897c516b53e..858c8b34aee 100644 --- a/app/design/adminhtml/base/default/template/catalog/product/edit.phtml +++ b/app/design/adminhtml/base/default/template/catalog/product/edit.phtml @@ -14,19 +14,7 @@ ?>

getHeader() ?>

-

getBackButtonHtml() ?> - getCancelButtonHtml() ?> - getProductId()): ?> - getDeleteButtonHtml() ?> - getProductSetId() && $this->getIsConfigured()): ?> - getDuplicateButtonHtml() ?> - - - getProductSetId() && $this->getIsConfigured()): ?> - getSaveButtonHtml() ?> - getSaveAndEditButtonHtml() ?> - -

+

getButtonsHtml('header') ?>

getBlockHtml('formkey')?>