From abae43f54b0d263e5596ed41fdfe39178a2e3f41 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 4 Dec 2024 05:50:36 +0100 Subject: [PATCH 01/10] add button methods, constants etc --- .../core/Mage/Adminhtml/Block/Template.php | 292 ++++++++++++++++++ 1 file changed, 292 insertions(+) diff --git a/app/code/core/Mage/Adminhtml/Block/Template.php b/app/code/core/Mage/Adminhtml/Block/Template.php index 63314a08acc..b4e7ff309d3 100644 --- a/app/code/core/Mage/Adminhtml/Block/Template.php +++ b/app/code/core/Mage/Adminhtml/Block/Template.php @@ -22,6 +22,29 @@ */ class Mage_Adminhtml_Block_Template extends Mage_Core_Block_Template { + public const BUTTON_ADD = 'add_button'; + public const BUTTON_BACK = 'back_button'; + public const BUTTON_CANCEL = 'cancel_button'; + public const BUTTON_CLOSE = 'close_button'; + public const BUTTON_DELETE = 'delete_button'; + public const BUTTON_DUPLICATE = 'duplicate_button'; + public const BUTTON_RESET = 'reset_button'; + public const BUTTON_REFRESH = 'refresh_button'; + public const BUTTON_SAVE = 'save_button'; + public const BUTTON_SAVE_AND_CONTINUE = 'save_and_edit_button'; + public const BUTTON_SUBMIT = 'submit_button'; + public const BUTTON_UPDATE = 'update_button'; + public const BUTTON_UPLOAD = 'upload_button'; + + public const BUTTON__CLASS_ADD = 'add'; + public const BUTTON__CLASS_BACK = 'back'; + public const BUTTON__CLASS_CANCEL = 'cancel'; + public const BUTTON__CLASS_DELETE = 'delete'; + public const BUTTON__CLASS_RESET = 'reeet'; + public const BUTTON__CLASS_SAVE = 'save'; + public const BUTTON__CLASS_TASK = 'task'; + public const BUTTON__CLASS_UPDATE = 'update-button'; + /** * @return string */ @@ -72,4 +95,273 @@ public function maliciousCodeFilter($html) { return Mage::getSingleton('core/input_filter_maliciousCode')->filter($html); } + + private function createWidgetButtonBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + /** @var Mage_Adminhtml_Block_Widget_Button $block */ + $block = $this->getLayout()->createBlock('adminhtml/widget_button', $name, $attributes); + return $block; + } + + public function getButtonBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetButtonBlock($name, $attributes); + } + + private function createWidgetAddButtonBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetButtonBlock($name, $attributes) + ->setLabel(Mage::helper('adminhtml')->__('Add')) + ->setClass(self::BUTTON__CLASS_ADD); + } + + public function getButtonAddBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetAddButtonBlock($name, $attributes); + } + + private function createWidgetBackButtonBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetButtonBlock($name, $attributes) + ->setLabel(Mage::helper('adminhtml')->__('Back')) + ->setOnClickSetLocationJsUrl() + ->setClass(self::BUTTON__CLASS_BACK); + } + + public function getButtonBackBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetBackButtonBlock($name, $attributes); + } + + private function createWidgetCancelButtonBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetButtonBlock($name, $attributes) + ->setLabel(Mage::helper('adminhtml')->__('Cancel')) + ->setOnClick('window.close()') + ->setClass(self::BUTTON__CLASS_CANCEL); + } + + public function getButtonCancelBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetCancelButtonBlock($name, $attributes); + } + + public function getButtonBackPopupBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetCancelButtonBlock($name, $attributes); + } + + private function createWidgetCloseButtonBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetButtonBlock($name, $attributes) + ->setLabel(Mage::helper('adminhtml')->__('Close Window')) + ->setOnClick('window.close()'); + } + + public function getButtonCloseBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetCloseButtonBlock($name, $attributes); + } + + private function createWidgetDeleteButtonBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetButtonBlock($name, $attributes) + ->setLabel(Mage::helper('adminhtml')->__('Delete')) + #->setOnClick(Mage::helper('core/js')->getConfirmSetLocationJs($this->getDeleteUrl())) + ->setClass(self::BUTTON__CLASS_DELETE); + } + + public function getButtonDeleteBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetDeleteButtonBlock($name, $attributes); + } + + private function createWidgetDuplicateleteButtonBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetAddButtonBlock($name, $attributes) + ->setLabel(Mage::helper('adminhtml')->__('Duplicate')) + ->setOnClickSetLocationJsFullUrl($this->getDuplicateUrl()); + } + + public function getButtonDuplicateBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetDuplicateleteButtonBlock($name, $attributes); + } + + private function createWidgetRefreshButtonBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetButtonBlock($name, $attributes) + ->setLabel(Mage::helper('adminhtml')->__('Refresh')) + ->setClass(self::BUTTON__CLASS_TASK); + } + + public function getButtonRefreshBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetRefreshButtonBlock($name, $attributes); + } + + private function createWidgetResetButtonBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetButtonBlock($name, $attributes) + ->setLabel(Mage::helper('adminhtml')->__('Reset')) + ->setOnClickSetLocationJsUrl('*/*/*', ['_current' => true]) + ->setClass(self::BUTTON__CLASS_RESET); + } + + public function getButtonResetBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetResetButtonBlock($name, $attributes); + } + + private function createWidgetSaveButtonBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetButtonBlock($name, $attributes) + ->setLabel(Mage::helper('adminhtml')->__('Save')) + ->setClass(self::BUTTON__CLASS_SAVE); + } + + public function getButtonSaveBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetSaveButtonBlock($name, $attributes); + } + + private function createWidgetSaveAndContinueButtonBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetButtonBlock($name, $attributes) + ->setLabel(Mage::helper('adminhtml')->__('Save and Continue Edit')) + ->setOnClick(Mage::helper('core/js')->getSaveAndContinueEditJs($this->getSaveAndContinueUrl())) + ->setClass(self::BUTTON__CLASS_SAVE); + } + + public function getButtonSaveAndContinueBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetSaveAndContinueButtonBlock($name, $attributes); + } + + private function createWidgetUpdateButtonBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetButtonBlock($name, $attributes) + ->setClass(self::BUTTON__CLASS_UPDATE); + } + + public function getButtonUpdateBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetUpdateButtonBlock($name, $attributes); + } + + private function createWidgetUploadButtonBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetButtonBlock($name, $attributes) + ->setLabel(Mage::helper('adminhtml')->__('Upload Files')); + } + + public function getButtonUploadBlock(string $name = '', array $attributes = []): Mage_Adminhtml_Block_Widget_Button + { + return $this->createWidgetUploadButtonBlock($name, $attributes); + } + + /** + * Retrieve Add Button HTML + * + * @return string + */ + public function getAddButtonHtml() + { + return $this->getChildHtml(static::BUTTON_ADD); + } + + /** + * Retrieve Back Button HTML + * + * @return string + */ + public function getBackButtonHtml() + { + return $this->getChildHtml(static::BUTTON_BACK); + } + + /** + * Retrieve Cancel Button HTML + * + * @return string + */ + public function getCancelButtonHtml() + { + return $this->getChildHtml(static::BUTTON_RESET); + } + + /** + * Retrieve Close Button HTML + * + * @return string + */ + public function getCloseButtonHtml() + { + return $this->getChildHtml(static::BUTTON_CLOSE); + } + + /** + * Retrieve Delete Button HTML + * + * @return string + */ + public function getDeleteButtonHtml() + { + return $this->getChildHtml(static::BUTTON_DELETE); + } + + /** + * Retrieve Delete Button HTML + * + * @return string + */ + public function getDuplicateButtonHtml() + { + return $this->getChildHtml(static::BUTTON_DUPLICATE); + } + + /** + * Retrieve Reset Button HTML + * + * @return string + */ + public function getResetButtonHtml() + { + return $this->getChildHtml(static::BUTTON_RESET); + } + + /** + * Retrieve Save Button HTML + * + * @return string + */ + public function getSaveButtonHtml() + { + return $this->getChildHtml(static::BUTTON_SAVE); + } + + public function getSaveAndEditButtonHtml(): string + { + return $this->getChildHtml(static::BUTTON_SAVE_AND_CONTINUE); + } + + /** + * Retrieve Update Button HTML + * + * @return string + */ + public function getUpdateButtonHtml() + { + return $this->getChildHtml(static::BUTTON_UPDATE); + } + + /** + * Retrieve Upload Button HTML + * + * @return string + */ + public function getUploadButtonHtml() + { + return $this->getChildHtml(static::BUTTON_UPLOAD); + } } From b9a78367e8741d6e056eb4381c81e81b761ac608 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Wed, 4 Dec 2024 05:54:45 +0100 Subject: [PATCH 02/10] cleanup - removed inherited methods - use constants for block - remove template from constructor --- .../Block/Catalog/Category/Edit/Form.php | 26 +- .../Adminhtml/Block/Catalog/Category/Tree.php | 23 +- .../Product/Attribute/New/Product/Created.php | 23 +- .../Catalog/Product/Attribute/Set/Main.php | 63 ++--- .../Attribute/Set/Main/Formattribute.php | 24 +- .../Product/Attribute/Set/Main/Formgroup.php | 36 +-- .../Product/Attribute/Set/Toolbar/Add.php | 29 +- .../Product/Attribute/Set/Toolbar/Main.php | 13 +- .../Block/Catalog/Product/Created.php | 10 +- .../Adminhtml/Block/Catalog/Product/Edit.php | 56 +--- .../Catalog/Product/Edit/Action/Attribute.php | 34 +-- .../Product/Edit/Tab/Attributes/Create.php | 2 +- .../Catalog/Product/Edit/Tab/Options.php | 17 +- .../Product/Edit/Tab/Options/Option.php | 13 +- .../Product/Edit/Tab/Options/Type/Select.php | 20 +- .../Catalog/Product/Edit/Tab/Price/Group.php | 15 +- .../Product/Edit/Tab/Price/Group/Abstract.php | 10 - .../Catalog/Product/Edit/Tab/Price/Tier.php | 6 +- .../Catalog/Product/Edit/Tab/Settings.php | 10 +- .../Catalog/Product/Edit/Tab/Super/Config.php | 12 +- .../Product/Edit/Tab/Super/Settings.php | 5 +- .../Block/Customer/Edit/Tab/Addresses.php | 30 +-- .../Sales/Order/Address/Form/Renderer/Vat.php | 8 +- .../Adminhtml/Block/Newsletter/Problem.php | 20 +- .../Adminhtml/Block/Newsletter/Queue/Edit.php | 37 +-- .../Block/Newsletter/Template/Edit.php | 57 +--- .../Adminhtml/Block/Permissions/Buttons.php | 35 +-- .../Permissions/OrphanedResource/Grid.php | 6 +- .../Promo/Quote/Edit/Tab/Coupons/Grid.php | 2 +- .../core/Mage/Adminhtml/Block/Report/Grid.php | 17 +- .../Block/Sales/Order/Comments/View.php | 1 + .../Block/Sales/Order/Create/Items/Grid.php | 9 +- .../Block/Sales/Order/View/History.php | 4 + .../Adminhtml/Block/System/Cache/Edit.php | 12 +- .../Adminhtml/Block/System/Config/Edit.php | 12 +- .../Adminhtml/Block/System/Config/Tabs.php | 17 +- .../System/Convert/Gui/Edit/Tab/Wizard.php | 11 +- .../System/Convert/Profile/Edit/Tab/Run.php | 6 +- .../Mage/Adminhtml/Block/System/Currency.php | 32 +-- .../Mage/Adminhtml/Block/System/Design.php | 8 +- .../Adminhtml/Block/System/Design/Edit.php | 9 +- .../Adminhtml/Block/System/Email/Template.php | 21 +- .../Block/System/Email/Template/Edit.php | 51 ++-- .../Adminhtml/Block/Tax/Rate/Toolbar/Add.php | 12 +- .../Adminhtml/Block/Tax/Rate/Toolbar/Save.php | 38 +-- .../Mage/Adminhtml/Block/Urlrewrite/Edit.php | 4 +- app/code/core/Mage/Adminhtml/Block/Widget.php | 2 +- .../Mage/Adminhtml/Block/Widget/Button.php | 252 +++++++++++++++++- .../Block/Widget/Form/Element/Gallery.php | 14 +- .../core/Mage/Adminhtml/Block/Widget/Grid.php | 14 +- .../Adminhtml/Block/Widget/Grid/Container.php | 2 +- .../OrphanedResourceController.php | 2 +- .../Block/Adminhtml/Attribute/Buttons.php | 44 +-- .../Api2/Block/Adminhtml/Roles/Buttons.php | 50 +--- .../Catalog/Product/Edit/Tab/Bundle.php | 22 +- .../Product/Edit/Tab/Bundle/Option.php | 21 +- .../Product/Edit/Tab/Bundle/Option/Search.php | 14 +- .../Edit/Tab/Bundle/Option/Selection.php | 10 +- app/code/core/Mage/Core/Block/Abstract.php | 8 +- .../Currency/Import/Currencyconverterapi.php | 2 +- .../Model/Currency/Import/Fixerio.php | 2 +- .../Product/Edit/Tab/Downloadable/Links.php | 14 +- .../Product/Edit/Tab/Downloadable/Samples.php | 20 +- .../Attribute/Edit/Options/Abstract.php | 21 +- .../Config/Source/Inputtype/Validator.php | 2 +- .../Block/Adminhtml/Settlement/Report.php | 2 +- .../Model/Resource/Report/Collection.php | 4 +- .../Mage/Sales/Model/Billing/Agreement.php | 2 +- .../core/Mage/Uploader/Block/Abstract.php | 14 +- .../core/Mage/Uploader/Block/Multiple.php | 10 - .../Mage/Usa/Model/Shipping/Carrier/Usps.php | 2 +- .../Mage/Weee/Block/Renderer/Weee/Tax.php | 20 +- .../Widget/Instance/Edit/Tab/Main/Layout.php | 17 +- .../widget/form/element/gallery.phtml | 6 +- 74 files changed, 641 insertions(+), 858 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php index f8f051df336..5a7a8c05476 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php @@ -22,6 +22,8 @@ */ class Mage_Adminhtml_Block_Catalog_Category_Edit_Form extends Mage_Adminhtml_Block_Catalog_Category_Abstract { + public const BLOCK_TABS = 'tabs'; + /** * Additional buttons on category page * @@ -29,19 +31,18 @@ class Mage_Adminhtml_Block_Catalog_Category_Edit_Form extends Mage_Adminhtml_Blo */ protected $_additionalButtons = []; - public function __construct() - { - parent::__construct(); - $this->setTemplate('catalog/category/edit/form.phtml'); - } + protected $_template = 'catalog/category/edit/form.phtml'; + /** + * @inheritDoc + */ protected function _prepareLayout() { - $category = $this->getCategory(); + $category = $this->getCategory(); $categoryId = (int) $category->getId(); // 0 when we create category, otherwise some value for editing category $this->setChild( - 'tabs', + self::BLOCK_TABS, $this->getLayout()->createBlock('adminhtml/catalog_category_tabs', 'tabs') ); @@ -100,15 +101,10 @@ public function getStoreConfigurationUrl() return $this->getUrl('*/system_store', $params); } - public function getDeleteButtonHtml() - { - return $this->getChildHtml('delete_button'); - } - public function getSaveButtonHtml() { if ($this->hasStoreRootCategory()) { - return $this->getChildHtml('save_button'); + return $this->getChildHtml(self::BUTTON_SAVE); } return ''; } @@ -116,7 +112,7 @@ public function getSaveButtonHtml() public function getResetButtonHtml() { if ($this->hasStoreRootCategory()) { - return $this->getChildHtml('reset_button'); + return $this->getChildHtml(self::BUTTON_RESET); } return ''; } @@ -173,7 +169,7 @@ public function removeAdditionalButton($alias) public function getTabsHtml() { - return $this->getChildHtml('tabs'); + return $this->getChildHtml(self::BLOCK_TABS); } public function getHeader() diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php index 5c3b4bda864..6f70c43dd35 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Category/Tree.php @@ -22,12 +22,18 @@ */ class Mage_Adminhtml_Block_Catalog_Category_Tree extends Mage_Adminhtml_Block_Catalog_Category_Abstract { + public const BLOCK_STORE_SWITCHER = 'store_switcher'; + + public const BUTTON_ADD_ROOT = 'add_root_button'; + public const BUTTON_ADD_SUB = 'add_sub_button'; + protected $_withProductCount; + protected $_template = 'catalog/category/tree.phtml'; + public function __construct() { parent::__construct(); - $this->setTemplate('catalog/category/tree.phtml'); $this->setUseAjax(true); $this->_withProductCount = true; } @@ -41,7 +47,7 @@ protected function _prepareLayout() ]); $this->setChild( - 'add_sub_button', + self::BUTTON_ADD_SUB, $this->getLayout()->createBlock('adminhtml/widget_button') ->setData([ 'label' => Mage::helper('catalog')->__('Add Subcategory'), @@ -54,7 +60,7 @@ protected function _prepareLayout() if ($this->canAddRootCategory()) { $this->setChild( - 'add_root_button', + self::BUTTON_ADD_ROOT, $this->getLayout()->createBlock('adminhtml/widget_button') ->setData([ 'label' => Mage::helper('catalog')->__('Add Root Category'), @@ -66,7 +72,7 @@ protected function _prepareLayout() } $this->setChild( - 'store_switcher', + self::BLOCK_STORE_SWITCHER, $this->getLayout()->createBlock('adminhtml/store_switcher') ->setSwitchUrl($this->getUrl('*/*/*', ['_current' => true, '_query' => false, 'store' => null])) ->setTemplate('store/switcher/enhanced.phtml') @@ -84,9 +90,8 @@ public function getCategoryCollection() $storeId = $this->getRequest()->getParam('store', $this->_getDefaultStoreId()); $collection = $this->getData('category_collection'); if (is_null($collection)) { + /** @var Mage_Catalog_Model_Resource_Category_Collection $collection */ $collection = Mage::getModel('catalog/category')->getCollection(); - - /** @var Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection $collection */ $collection->addAttributeToSelect('name') ->addAttributeToSelect('is_active') ->setProductStoreId($storeId) @@ -100,12 +105,12 @@ public function getCategoryCollection() public function getAddRootButtonHtml() { - return $this->getChildHtml('add_root_button'); + return $this->getChildHtml(self::BUTTON_ADD_ROOT); } public function getAddSubButtonHtml() { - return $this->getChildHtml('add_sub_button'); + return $this->getChildHtml(self::BUTTON_ADD_SUB); } public function getExpandButtonHtml() @@ -120,7 +125,7 @@ public function getCollapseButtonHtml() public function getStoreSwitcherHtml() { - return $this->getChildHtml('store_switcher'); + return $this->getChildHtml(self::BLOCK_STORE_SWITCHER); } public function getLoadTreeUrl($expanded = null) diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php index 4bf2877d5cc..9896c106e98 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/New/Product/Created.php @@ -22,14 +22,9 @@ */ class Mage_Adminhtml_Block_Catalog_Product_Attribute_New_Product_Created extends Mage_Adminhtml_Block_Widget { - /** - * Mage_Adminhtml_Block_Catalog_Product_Attribute_New_Product_Created constructor. - */ - public function __construct() - { - parent::__construct(); - $this->setTemplate('catalog/product/attribute/new/created.phtml'); - } + public const BLOCK_ATTRIBUTES = 'attributes'; + + protected $_template = 'catalog/product/attribute/new/created.phtml'; /** * @return $this @@ -38,7 +33,7 @@ public function __construct() protected function _prepareLayout() { $this->setChild( - 'attributes', + self::BLOCK_ATTRIBUTES, $this->getLayout()->createBlock('adminhtml/catalog_product_attribute_new_product_attributes') ->setGroupAttributes($this->_getGroupAttributes()) ); @@ -72,14 +67,6 @@ protected function _getGroupAttributes() return $attributes; } - /** - * @return string - */ - public function getCloseButtonHtml() - { - return $this->getChildHtml('close_button'); - } - /** * @return string * @throws Exception @@ -87,7 +74,7 @@ public function getCloseButtonHtml() public function getAttributesBlockJson() { $result = [ - $this->getRequest()->getParam('tab') => $this->getChildHtml('attributes') + $this->getRequest()->getParam('tab') => $this->getChildHtml(self::BLOCK_ATTRIBUTES) ]; return Mage::helper('core')->jsonEncode($result); diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php index 47e2f587dc0..de7852901bb 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main.php @@ -22,13 +22,14 @@ */ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main extends Mage_Adminhtml_Block_Template { - /** - * Initialize template - */ - protected function _construct() - { - $this->setTemplate('catalog/product/attribute/set/main.phtml'); - } + public const BLOCK_EDIT_SET_FORM = 'edit_set_form'; + public const BLOCK_GROUP_TREE = 'group_tree'; + + public const BUTTON_ADD_GROUP = 'add_group_button'; + public const BUTTON_DELETE_GROUP = 'delete_group_button'; + public const BUTTON_RENAME = 'rename_button'; + + protected $_template = 'catalog/product/attribute/set/main.phtml'; /** * Prepare Global Layout @@ -40,12 +41,12 @@ protected function _prepareLayout() $setId = $this->_getSetId(); $this->setChild( - 'group_tree', + self::BLOCK_GROUP_TREE, $this->getLayout()->createBlock('adminhtml/catalog_product_attribute_set_main_tree_group') ); $this->setChild( - 'edit_set_form', + self::BLOCK_EDIT_SET_FORM, $this->getLayout()->createBlock('adminhtml/catalog_product_attribute_set_main_formset') ); @@ -123,7 +124,7 @@ protected function _prepareLayout() */ public function getGroupTreeHtml() { - return $this->getChildHtml('group_tree'); + return $this->getChildHtml(self::BLOCK_GROUP_TREE); } /** @@ -133,7 +134,7 @@ public function getGroupTreeHtml() */ public function getSetFormHtml() { - return $this->getChildHtml('edit_set_form'); + return $this->getChildHtml(self::BLOCK_EDIT_SET_FORM); } /** @@ -283,39 +284,7 @@ public function getAttributeTreeJson() } /** - * Retrieve Back Button HTML - * - * @return string - */ - public function getBackButtonHtml() - { - return $this->getChildHtml('back_button'); - } - - /** - * Retrieve Reset Button HTML - * - * @return string - */ - public function getResetButtonHtml() - { - return $this->getChildHtml('reset_button'); - } - - /** - * Retrieve Save Button HTML - * - * @return string - */ - public function getSaveButtonHtml() - { - return $this->getChildHtml('save_button'); - } - - /** - * Retrieve Delete Button HTML - * - * @return string + * @inheritDoc */ public function getDeleteButtonHtml() { @@ -332,7 +301,7 @@ public function getDeleteButtonHtml() */ public function getDeleteGroupButton() { - return $this->getChildHtml('delete_group_button'); + return $this->getChildHtml(self::BUTTON_DELETE_GROUP); } /** @@ -342,7 +311,7 @@ public function getDeleteGroupButton() */ public function getAddGroupButton() { - return $this->getChildHtml('add_group_button'); + return $this->getChildHtml(self::BUTTON_ADD_GROUP); } /** @@ -352,7 +321,7 @@ public function getAddGroupButton() */ public function getRenameButton() { - return $this->getChildHtml('rename_button'); + return $this->getChildHtml(self::BUTTON_RENAME); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formattribute.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formattribute.php index daec4de0541..5c5e79ee53d 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formattribute.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formattribute.php @@ -30,24 +30,24 @@ protected function _prepareForm() 'new_attribute', 'text', [ - 'label' => Mage::helper('catalog')->__('Name'), - 'name' => 'new_attribute', - 'required' => true, - ] + 'label' => Mage::helper('catalog')->__('Name'), + 'name' => 'new_attribute', + 'required' => true, + ] ); $fieldset->addField( 'submit', 'note', [ - 'text' => $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData([ - 'label' => Mage::helper('catalog')->__('Add Attribute'), - 'onclick' => 'this.form.submit();', - 'class' => 'add' - ]) - ->toHtml(), - ] + 'text' => $this->getLayout()->createBlock('adminhtml/widget_button') + ->setData([ + 'label' => Mage::helper('catalog')->__('Add Attribute'), + 'onclick' => 'this.form.submit();', + 'class' => 'add' + ]) + ->toHtml(), + ] ); $form->setUseContainer(true); diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formgroup.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formgroup.php index 21f5291e207..013be190690 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formgroup.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Main/Formgroup.php @@ -30,33 +30,33 @@ protected function _prepareForm() 'attribute_group_name', 'text', [ - 'label' => Mage::helper('catalog')->__('Name'), - 'name' => 'attribute_group_name', - 'required' => true, - ] + 'label' => Mage::helper('catalog')->__('Name'), + 'name' => 'attribute_group_name', + 'required' => true, + ] ); $fieldset->addField( 'submit', 'note', [ - 'text' => $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData([ - 'label' => Mage::helper('catalog')->__('Add Group'), - 'onclick' => 'this.form.submit();', - 'class' => 'add' - ]) - ->toHtml(), - ] + 'text' => $this->getLayout()->createBlock('adminhtml/widget_button') + ->setData([ + 'label' => Mage::helper('catalog')->__('Add Group'), + 'onclick' => 'this.form.submit();', + 'class' => 'add' + ]) + ->toHtml(), + ] ); $fieldset->addField( 'attribute_set_id', 'hidden', [ - 'name' => 'attribute_set_id', - 'value' => $this->_getSetId(), - ] + 'name' => 'attribute_set_id', + 'value' => $this->_getSetId(), + ] ); $form->setUseContainer(true); @@ -69,8 +69,8 @@ protected function _prepareForm() protected function _getSetId() { return ((int) $this->getRequest()->getParam('id') > 0) - ? (int) $this->getRequest()->getParam('id') - : Mage::getSingleton('eav/config')->getEntityType(Mage::registry('entityType')) - ->getDefaultAttributeSetId(); + ? (int) $this->getRequest()->getParam('id') + : Mage::getSingleton('eav/config')->getEntityType(Mage::registry('entityType')) + ->getDefaultAttributeSetId(); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php index 2ea600035c4..1a48f380620 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Add.php @@ -20,10 +20,9 @@ */ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Toolbar_Add extends Mage_Adminhtml_Block_Template { - protected function _construct() - { - $this->setTemplate('catalog/product/attribute/set/toolbar/add.phtml'); - } + public const BLOCK_FORM = 'setForm'; + + protected $_template = 'catalog/product/attribute/set/toolbar/add.phtml'; /** * @inheritDoc @@ -50,7 +49,7 @@ protected function _prepareLayout() ); $this->setChild( - 'setForm', + self::BLOCK_FORM, $this->getLayout()->createBlock('adminhtml/catalog_product_attribute_set_main_formset') ); return parent::_prepareLayout(); @@ -64,32 +63,16 @@ protected function _getHeader() return Mage::helper('catalog')->__('Add New Attribute Set'); } - /** - * @return string - */ - protected function getSaveButtonHtml() - { - return $this->getChildHtml('save_button'); - } - - /** - * @return string - */ - protected function getBackButtonHtml() - { - return $this->getChildHtml('back_button'); - } - /** * @return string */ protected function getFormHtml() { - return $this->getChildHtml('setForm'); + return $this->getChildHtml(self::BLOCK_FORM); } protected function getFormId() { - return $this->getChild('setForm')->getForm()->getId(); + return $this->getChild(self::BLOCK_FORM)->getForm()->getId(); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php index a0f41b3393f..e400c5909d9 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Attribute/Set/Toolbar/Main.php @@ -22,13 +22,12 @@ */ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Toolbar_Main extends Mage_Adminhtml_Block_Template { - public function __construct() - { - parent::__construct(); - $this->setTemplate('catalog/product/attribute/set/toolbar/main.phtml'); - } + public const BUTTON_ADD = 'addButton'; + + protected $_template = 'catalog/product/attribute/set/toolbar/main.phtml'; /** + * @codeCoverageIgnore * @inheritDoc */ protected function _prepareLayout() @@ -47,10 +46,12 @@ protected function _prepareLayout() /** * @return string + * @deprecated + * @see getAddButtonHtml() */ protected function getNewButtonHtml() { - return $this->getChildHtml('addButton'); + return $this->getChildHtml(self::BUTTON_ADD); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Created.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Created.php index 90324463fe8..78bc6ebab00 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Created.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Created.php @@ -25,12 +25,12 @@ class Mage_Adminhtml_Block_Catalog_Product_Created extends Mage_Adminhtml_Block_ protected $_configurableProduct; protected $_product; - public function __construct() - { - parent::__construct(); - $this->setTemplate('catalog/product/created.phtml'); - } + protected $_template = 'catalog/product/created.phtml'; + /** + * @codeCoverageIgnore + * @inheritDoc + */ protected function _prepareLayout() { $this->setChild( 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 4c07a879fa4..bee32088e5c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit.php @@ -23,12 +23,8 @@ */ class Mage_Adminhtml_Block_Catalog_Product_Edit extends Mage_Adminhtml_Block_Widget { - public function __construct() - { - parent::__construct(); - $this->setTemplate('catalog/product/edit.phtml'); - $this->setId('product_edit'); - } + protected $_idFieldName = 'product_edit'; + protected $_template = 'catalog/product/edit.phtml'; /** * Retrieve currently edited product object @@ -128,54 +124,6 @@ protected function _prepareLayout() return parent::_prepareLayout(); } - /** - * @return string - */ - public function getBackButtonHtml() - { - return $this->getChildHtml('back_button'); - } - - /** - * @return string - */ - public function getCancelButtonHtml() - { - return $this->getChildHtml('reset_button'); - } - - /** - * @return string - */ - public function getSaveButtonHtml() - { - return $this->getChildHtml('save_button'); - } - - /** - * @return string - */ - public function getSaveAndEditButtonHtml() - { - return $this->getChildHtml('save_and_edit_button'); - } - - /** - * @return string - */ - public function getDeleteButtonHtml() - { - return $this->getChildHtml('delete_button'); - } - - /** - * @return string - */ - public function getDuplicateButtonHtml() - { - return $this->getChildHtml('duplicate_button'); - } - /** * @return string */ diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute.php index f73c584cb83..761488cf170 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Action/Attribute.php @@ -22,6 +22,10 @@ */ class Mage_Adminhtml_Block_Catalog_Product_Edit_Action_Attribute extends Mage_Adminhtml_Block_Widget { + /** + * @codeCoverageIgnore + * @inheritDoc + */ protected function _prepareLayout() { $this->setChild( @@ -80,36 +84,6 @@ protected function _getHelper() return $this->helper('adminhtml/catalog_product_edit_action_attribute'); } - /** - * Retrieve back button html code - * - * @return string - */ - public function getBackButtonHtml() - { - return $this->getChildHtml('back_button'); - } - - /** - * Retrieve cancel button html code - * - * @return string - */ - public function getCancelButtonHtml() - { - return $this->getChildHtml('reset_button'); - } - - /** - * Retrieve save button html code - * - * @return string - */ - public function getSaveButtonHtml() - { - return $this->getChildHtml('save_button'); - } - /** * Get save url * diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php index d7d1944e299..f2a9b6ebd0c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Attributes/Create.php @@ -50,7 +50,7 @@ protected function _beforeToHtml() { $this->setId('create_attribute_' . $this->getConfig()->getGroupId()) ->setOnClick($this->getJsObjectName() . '.create();') - ->setType('button') + ->setType(self::TYPE_BUTTON) ->setClass('add') ->setLabel(Mage::helper('adminhtml')->__('Create New Attribute')); diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options.php index be58d8e5e5f..d05820504c5 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options.php @@ -22,16 +22,14 @@ */ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options extends Mage_Adminhtml_Block_Widget { - public function __construct() - { - parent::__construct(); - $this->setTemplate('catalog/product/edit/options.phtml'); - } + public const BLOCK_OPTION_BOX = 'options_box'; + + protected $_template = 'catalog/product/edit/options.phtml'; protected function _prepareLayout() { $this->setChild( - 'add_button', + self::BLOCK_OPTION_BOX, $this->getLayout()->createBlock('adminhtml/widget_button') ->setData([ 'label' => Mage::helper('catalog')->__('Add New Option'), @@ -48,13 +46,8 @@ protected function _prepareLayout() return parent::_prepareLayout(); } - public function getAddButtonHtml() - { - return $this->getChildHtml('add_button'); - } - public function getOptionsBoxHtml() { - return $this->getChildHtml('options_box'); + return $this->getChildHtml(self::BLOCK_OPTION_BOX); } } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php index 0c3837e6200..2b1b9b31972 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Option.php @@ -30,13 +30,14 @@ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option extends Mage_ protected $_itemCount = 1; + protected $_template = 'catalog/product/edit/options/option.phtml'; + /** * Class constructor */ public function __construct() { parent::__construct(); - $this->setTemplate('catalog/product/edit/options/option.phtml'); $this->setCanReadPrice(true); $this->setCanEditPrice(true); } @@ -118,7 +119,6 @@ protected function _prepareLayout() ); $path = 'global/catalog/product/options/custom/groups'; - foreach (Mage::getConfig()->getNode($path)->children() as $group) { $this->setChild( $group->getName() . '_option_type', @@ -134,13 +134,8 @@ protected function _prepareLayout() public function getAddButtonId() { return $this->getLayout() - ->getBlock('admin.product.options') - ->getChild('add_button')->getId(); - } - - public function getDeleteButtonHtml() - { - return $this->getChildHtml('delete_button'); + ->getBlock('admin.product.options') + ->getChild(self::BUTTON_ADD)->getId(); } public function getTypeSelectHtml() diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Select.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Select.php index 42edef63968..0ed5e1129e8 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Select.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Options/Type/Select.php @@ -22,17 +22,25 @@ */ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Select extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Type_Abstract { + public const BUTTON_ADD = 'add_select_row_button'; + public const BUTTON_DELETE = 'delete_select_row_button'; + + protected $_template = 'catalog/product/edit/options/type/select.phtml'; + /** * Class constructor */ public function __construct() { parent::__construct(); - $this->setTemplate('catalog/product/edit/options/type/select.phtml'); $this->setCanEditPrice(true); $this->setCanReadPrice(true); } + /** + * @codeCoverageIgnore + * @inheritDoc + */ protected function _prepareLayout() { $this->setChild( @@ -58,16 +66,6 @@ protected function _prepareLayout() return parent::_prepareLayout(); } - public function getAddButtonHtml() - { - return $this->getChildHtml('add_select_row_button'); - } - - public function getDeleteButtonHtml() - { - return $this->getChildHtml('delete_select_row_button'); - } - public function getPriceTypeSelectHtml() { $this->getChild('option_price_type') diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group.php index 0bf686a3f88..4c3ff9f863a 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group.php @@ -22,13 +22,7 @@ */ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Group extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Group_Abstract { - /** - * Initialize block - */ - public function __construct() - { - $this->setTemplate('catalog/product/edit/price/group.phtml'); - } + protected $_template = 'catalog/product/edit/price/group.phtml'; /** * Sort values @@ -61,11 +55,8 @@ protected function _sortGroupPrices($a, $b) } /** - * Prepare global layout - * - * Add "Add Group Price" button to layout - * - * @return $this + * @codeCoverageIgnore + * @inheritDoc */ protected function _prepareLayout() { diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php index dd4503a64b2..68e48ababfa 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Group/Abstract.php @@ -243,16 +243,6 @@ public function getDefaultWebsite() return 0; } - /** - * Retrieve 'add group price item' button HTML - * - * @return string - */ - public function getAddButtonHtml() - { - return $this->getChildHtml('add_button'); - } - /** * Retrieve customized price column header * diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Tier.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Tier.php index a42efa66c4a..0e51b69a414 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Tier.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Price/Tier.php @@ -22,10 +22,7 @@ */ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Group_Abstract { - public function __construct() - { - $this->setTemplate('catalog/product/edit/price/tier.phtml'); - } + protected $_template = 'catalog/product/edit/price/tier.phtml'; /** * Retrieve list of initial customer groups @@ -75,6 +72,7 @@ protected function _sortTierPrices($a, $b) * Prepare global layout * Add "Add tier" button to layout * + * @codeCoverageIgnore * @return $this */ protected function _prepareLayout() diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Settings.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Settings.php index 4d674da0426..19efa6a465d 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Settings.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Settings.php @@ -22,6 +22,12 @@ */ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Settings extends Mage_Adminhtml_Block_Widget_Form { + public const BUTTON_CONTINUE = 'continue_button'; + + /** + * @codeCoverageIgnore + * @inheritDoc + */ protected function _prepareLayout() { $this->setChild( @@ -63,8 +69,8 @@ protected function _prepareForm() 'values' => Mage::getModel('catalog/product_type')->getOptionArray() ]); - $fieldset->addField('continue_button', 'note', [ - 'text' => $this->getChildHtml('continue_button'), + $fieldset->addField(self::BUTTON_CONTINUE, 'note', [ + 'text' => $this->getChildHtml(self::BUTTON_CONTINUE), ]); $this->setForm($form); diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php index 10b8d59ced2..3b23b2f3ecd 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Config.php @@ -22,16 +22,16 @@ */ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config extends Mage_Adminhtml_Block_Widget implements Mage_Adminhtml_Block_Widget_Tab_Interface { - /** - * Initialize block - * - */ + public const BUTTON_CREATE_EMPTY = 'create_empty'; + public const BUTTON_CREATE_CONFIGURABLE = 'create_from_configurable'; + + protected $_idFieldName = 'config_super_product'; + protected $_template = 'catalog/product/edit/super/config.phtml'; + public function __construct() { parent::__construct(); $this->setProductId($this->getRequest()->getParam('id')); - $this->setTemplate('catalog/product/edit/super/config.phtml'); - $this->setId('config_super_product'); $this->setCanEditPrice(true); $this->setCanReadPrice(true); } diff --git a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php index e3bee5f27fc..1d1aa214acd 100644 --- a/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php +++ b/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Super/Settings.php @@ -22,8 +22,11 @@ */ class Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Settings extends Mage_Adminhtml_Block_Widget_Form { + public const BUTTON_CONTINUE = 'continue_button'; + /** - * Prepare block children and data + * @codeCoverageIgnore + * @inheritDoc */ protected function _prepareLayout() { diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Addresses.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Addresses.php index 087797e31a7..6996c4b6d11 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Addresses.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Addresses.php @@ -22,14 +22,9 @@ */ class Mage_Adminhtml_Block_Customer_Edit_Tab_Addresses extends Mage_Adminhtml_Block_Widget_Form { - /** - * Mage_Adminhtml_Block_Customer_Edit_Tab_Addresses constructor. - */ - public function __construct() - { - parent::__construct(); - $this->setTemplate('customer/tab/addresses.phtml'); - } + public const BUTTON_ADD = 'add_address_button'; + + protected $_template = 'customer/tab/addresses.phtml'; /** * @return string @@ -40,6 +35,7 @@ public function getRegionsUrl() } /** + * @codeCoverageIgnore * @inheritDoc */ protected function _prepareLayout() @@ -95,14 +91,6 @@ public function isReadonly() return $customer->isReadonly(); } - /** - * @return string - */ - public function getDeleteButtonHtml() - { - return $this->getChildHtml('delete_button'); - } - /** * Initialize form object * @@ -211,20 +199,12 @@ public function initForm() return $this; } - /** - * @return string - */ - public function getCancelButtonHtml() - { - return $this->getChildHtml('cancel_button'); - } - /** * @return string */ public function getAddNewButtonHtml() { - return $this->getChildHtml('add_address_button'); + return $this->getChildHtml(self::BUTTON_ADD); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Sales/Order/Address/Form/Renderer/Vat.php b/app/code/core/Mage/Adminhtml/Block/Customer/Sales/Order/Address/Form/Renderer/Vat.php index abfb6ff0265..d19f20f5448 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Sales/Order/Address/Form/Renderer/Vat.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Sales/Order/Address/Form/Renderer/Vat.php @@ -29,13 +29,7 @@ class Mage_Adminhtml_Block_Customer_Sales_Order_Address_Form_Renderer_Vat extend */ protected $_validateButton = null; - /** - * Set custom template for 'VAT number' - */ - protected function _construct() - { - $this->setTemplate('customer/sales/order/create/address/form/renderer/vat.phtml'); - } + protected $_template = 'customer/sales/order/create/address/form/renderer/vat.phtml'; /** * Retrieve validate button block diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Problem.php b/app/code/core/Mage/Adminhtml/Block/Newsletter/Problem.php index 5ceda3ed212..8229bf331d8 100644 --- a/app/code/core/Mage/Adminhtml/Block/Newsletter/Problem.php +++ b/app/code/core/Mage/Adminhtml/Block/Newsletter/Problem.php @@ -22,11 +22,18 @@ */ class Mage_Adminhtml_Block_Newsletter_Problem extends Mage_Adminhtml_Block_Template { + public const BLOCK_GRID = 'grid'; + + public const BUTTON_DELETE = 'deleteButton'; + public const BUTTON_UNSUBSCRIBE = 'unsubscribeButton'; + + protected $_template = 'newsletter/problem/list.phtml'; + public function __construct() { parent::__construct(); - $this->setTemplate('newsletter/problem/list.phtml'); - $collection = Mage::getResourceSingleton('newsletter/problem_collection') + + Mage::getResourceSingleton('newsletter/problem_collection') ->addSubscriberInfo() ->addQueueInfo(); } @@ -34,7 +41,7 @@ public function __construct() protected function _prepareLayout() { $this->setChild( - 'grid', + self::BLOCK_GRID, $this->getLayout()->createBlock('adminhtml/newsletter_problem_grid', 'newsletter.problem.grid') ); @@ -64,12 +71,7 @@ protected function _prepareLayout() public function getUnsubscribeButtonHtml() { - return $this->getChildHtml('unsubscribeButton'); - } - - public function getDeleteButtonHtml() - { - return $this->getChildHtml('deleteButton'); + return $this->getChildHtml(self::BUTTON_UNSUBSCRIBE); } public function getShowButtons() diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php b/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php index f51d1cb9c91..c90ce04032c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Newsletter/Queue/Edit.php @@ -22,6 +22,9 @@ */ class Mage_Adminhtml_Block_Newsletter_Queue_Edit extends Mage_Adminhtml_Block_Template { + public const BUTTON_PREVIEW = 'preview_button'; + public const BUTTON_SAVE_AND_CONTINUE = 'save_and_resume'; + /** * Check for template Id in request */ @@ -156,37 +159,7 @@ public function getPreviewUrl() */ public function getPreviewButtonHtml() { - return $this->getChildHtml('preview_button'); - } - - /** - * Retrieve Save Button HTML - * - * @return string - */ - public function getSaveButtonHtml() - { - return $this->getChildHtml('save_button'); - } - - /** - * Retrieve Reset Button HTML - * - * @return string - */ - public function getResetButtonHtml() - { - return $this->getChildHtml('reset_button'); - } - - /** - * Retrieve Back Button HTML - * - * @return string - */ - public function getBackButtonHtml() - { - return $this->getChildHtml('back_button'); + return $this->getChildHtml(self::BUTTON_PREVIEW); } /** @@ -196,7 +169,7 @@ public function getBackButtonHtml() */ public function getResumeButtonHtml() { - return $this->getChildHtml('save_and_resume'); + return $this->getChildHtml(self::BUTTON_SAVE_AND_CONTINUE); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php b/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php index 7914d89018c..7fcd0285cb3 100644 --- a/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Newsletter/Template/Edit.php @@ -22,6 +22,11 @@ */ class Mage_Adminhtml_Block_Newsletter_Template_Edit extends Mage_Adminhtml_Block_Widget { + public const BUTTON_PREVIEW = 'preview_button'; + public const BUTTON_SAVE_AS = 'save_as_button'; + public const BUTTON_TO_HTML = 'to_html_button'; + public const BUTTON_TO_PLAIN = 'to_plain_button'; + /** * Edit Block model * @@ -45,7 +50,9 @@ public function getModel() protected function _prepareLayout() { // Load Wysiwyg on demand and Prepare layout - if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled() && ($block = $this->getLayout()->getBlock('head'))) { + if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled() + && ($block = $this->getLayout()->getBlock('head')) + ) { $block->setCanLoadTinyMce(true); } @@ -134,26 +141,6 @@ protected function _prepareLayout() return parent::_prepareLayout(); } - /** - * Retrieve Back Button HTML - * - * @return string - */ - public function getBackButtonHtml() - { - return $this->getChildHtml('back_button'); - } - - /** - * Retrieve Reset Button HTML - * - * @return string - */ - public function getResetButtonHtml() - { - return $this->getChildHtml('reset_button'); - } - /** * Retrieve Convert To Plain Button HTML * @@ -161,7 +148,7 @@ public function getResetButtonHtml() */ public function getToPlainButtonHtml() { - return $this->getChildHtml('to_plain_button'); + return $this->getChildHtml(self::BUTTON_TO_PLAIN); } /** @@ -171,17 +158,7 @@ public function getToPlainButtonHtml() */ public function getToHtmlButtonHtml() { - return $this->getChildHtml('to_html_button'); - } - - /** - * Retrieve Save Button HTML - * - * @return string - */ - public function getSaveButtonHtml() - { - return $this->getChildHtml('save_button'); + return $this->getChildHtml(self::BUTTON_TO_HTML); } /** @@ -191,17 +168,7 @@ public function getSaveButtonHtml() */ public function getPreviewButtonHtml() { - return $this->getChildHtml('preview_button'); - } - - /** - * Retrieve Delete Button HTML - * - * @return string - */ - public function getDeleteButtonHtml() - { - return $this->getChildHtml('delete_button'); + return $this->getChildHtml(self::BUTTON_PREVIEW); } /** @@ -211,7 +178,7 @@ public function getDeleteButtonHtml() */ public function getSaveAsButtonHtml() { - return $this->getChildHtml('save_as_button'); + return $this->getChildHtml(self::BUTTON_SAVE_AS); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Permissions/Buttons.php b/app/code/core/Mage/Adminhtml/Block/Permissions/Buttons.php index 04c3bd9668e..e3bf9746373 100644 --- a/app/code/core/Mage/Adminhtml/Block/Permissions/Buttons.php +++ b/app/code/core/Mage/Adminhtml/Block/Permissions/Buttons.php @@ -20,12 +20,17 @@ */ class Mage_Adminhtml_Block_Permissions_Buttons extends Mage_Adminhtml_Block_Template { - public function __construct() - { - parent::__construct(); - $this->setTemplate('permissions/userinfo.phtml'); - } + public const BUTTON_BACK = 'backButton'; + public const BUTTON_DELETE = 'deleteButton'; + public const BUTTON_RESET = 'resetButton'; + public const BUTTON_SAVE = 'saveButton'; + + protected $_template = 'permissions/userinfo.phtml'; + /** + * @codeCoverageIgnore + * @inheritDoc + */ protected function _prepareLayout() { $this->setChild( @@ -71,25 +76,13 @@ protected function _prepareLayout() return parent::_prepareLayout(); } - public function getBackButtonHtml() - { - return $this->getChildHtml('backButton'); - } - - public function getResetButtonHtml() - { - return $this->getChildHtml('resetButton'); - } - - public function getSaveButtonHtml() - { - return $this->getChildHtml('saveButton'); - } - + /** + * @inheritDoc + */ public function getDeleteButtonHtml() { if ((int) $this->getRequest()->getParam('rid') == 0) { - return; + return ''; } return $this->getChildHtml('deleteButton'); } diff --git a/app/code/core/Mage/Adminhtml/Block/Permissions/OrphanedResource/Grid.php b/app/code/core/Mage/Adminhtml/Block/Permissions/OrphanedResource/Grid.php index cb4bd5be707..2ce5af05eb6 100644 --- a/app/code/core/Mage/Adminhtml/Block/Permissions/OrphanedResource/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Permissions/OrphanedResource/Grid.php @@ -32,7 +32,7 @@ public function __construct() } /** - * @inheritdoc + * @inheritDoc */ protected function _prepareCollection() { @@ -55,7 +55,7 @@ protected function _prepareCollection() } /** - * @inheritdoc + * @inheritDoc */ protected function _prepareColumns() { @@ -68,7 +68,7 @@ protected function _prepareColumns() } /** - * @inheritdoc + * @inheritDoc */ protected function _prepareMassaction() { diff --git a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php b/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php index 0eca2099fec..5cd1282f72c 100644 --- a/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab/Coupons/Grid.php @@ -132,7 +132,7 @@ public function getGridUrl() } /** - * @inheritdoc + * @inheritDoc */ public function getRowUrl($row) { diff --git a/app/code/core/Mage/Adminhtml/Block/Report/Grid.php b/app/code/core/Mage/Adminhtml/Block/Report/Grid.php index 2ca12323b90..f5b84f39b90 100644 --- a/app/code/core/Mage/Adminhtml/Block/Report/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Report/Grid.php @@ -24,6 +24,8 @@ */ class Mage_Adminhtml_Block_Report_Grid extends Mage_Adminhtml_Block_Widget_Grid { + public const BLOCK_STORE_SWITCHER = 'store_switcher'; + protected $_storeSwitcherVisibility = true; protected $_dateFilterVisibility = true; @@ -35,8 +37,8 @@ class Mage_Adminhtml_Block_Report_Grid extends Mage_Adminhtml_Block_Widget_Grid protected $_filters = []; protected $_defaultFilters = [ - 'report_from' => '', - 'report_to' => '', + 'report_from' => '', + 'report_to' => '', 'report_period' => 'day' ]; @@ -59,6 +61,8 @@ class Mage_Adminhtml_Block_Report_Grid extends Mage_Adminhtml_Block_Widget_Grid /** @todo OM: check */ protected $_filterValues; + protected $_template = 'report/grid.phtml'; + /** * Mage_Adminhtml_Block_Report_Grid constructor. */ @@ -67,7 +71,6 @@ public function __construct() parent::__construct(); $this->setFilterVisibility(false); $this->setPagerVisibility(false); - $this->setTemplate('report/grid.phtml'); $this->setUseAjax(false); $this->setCountTotals(true); } @@ -78,7 +81,7 @@ public function __construct() protected function _prepareLayout() { $this->setChild( - 'store_switcher', + self::BLOCK_STORE_SWITCHER, $this->getLayout()->createBlock('adminhtml/store_switcher') ->setUseConfirm(false) ->setSwitchUrl($this->getUrl('*/*/*', ['store' => null])) @@ -115,7 +118,7 @@ protected function _prepareColumns() */ protected function _prepareCollection() { - $filter = $this->getParam($this->getVarNameFilter(), null); + $filter = $this->getParam($this->getVarNameFilter()); if (is_null($filter)) { $filter = $this->_defaultFilter; @@ -241,7 +244,7 @@ public function getStoreSwitcherVisibility() */ public function getStoreSwitcherHtml() { - return $this->getChildHtml('store_switcher'); + return $this->getChildHtml(self::BLOCK_STORE_SWITCHER); } /** @@ -319,7 +322,7 @@ public function getDateFormat() */ public function getRefreshButtonHtml() { - return $this->getChildHtml('refresh_button'); + return $this->getChildHtml(self::BUTTON_REFRESH); } public function setFilter($name, $value) diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Comments/View.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Comments/View.php index d0f486032d8..8896e9333cf 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Comments/View.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Comments/View.php @@ -35,6 +35,7 @@ protected function _beforeToHtml() } /** + * @codeCoverageIgnore * @inheritDoc */ protected function _prepareLayout() diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php index 322b3e5513e..15a4ee03a69 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items/Grid.php @@ -29,14 +29,7 @@ class Mage_Adminhtml_Block_Sales_Order_Create_Items_Grid extends Mage_Adminhtml_ */ protected $_moveToCustomerStorage = true; - /** - * Class constructor - */ - public function __construct() - { - parent::__construct(); - $this->setId('sales_order_create_search_grid'); - } + protected $_idFieldName = 'sales_order_create_search_grid'; /** * Returns the items diff --git a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/History.php b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/History.php index 5ad220a806f..4e04ac01d7f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/History.php +++ b/app/code/core/Mage/Adminhtml/Block/Sales/Order/View/History.php @@ -22,6 +22,10 @@ */ class Mage_Adminhtml_Block_Sales_Order_View_History extends Mage_Adminhtml_Block_Template { + /** + * @codeCoverageIgnore + * @inheritDoc + */ protected function _prepareLayout() { $onclick = "submitAndReloadArea($('order_history_block').parentNode, '" . $this->getSubmitUrl() . "')"; diff --git a/app/code/core/Mage/Adminhtml/Block/System/Cache/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Cache/Edit.php index efee49fb06a..0da30a8ca15 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Cache/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Cache/Edit.php @@ -22,17 +22,19 @@ */ class Mage_Adminhtml_Block_System_Cache_Edit extends Mage_Adminhtml_Block_Widget { + protected $_template = 'system/cache/edit.phtml'; + /** * Mage_Adminhtml_Block_System_Cache_Edit constructor. */ public function __construct() { parent::__construct(); - $this->setTemplate('system/cache/edit.phtml'); $this->setTitle('Cache Management'); } /** + * @codeCoverageIgnore * @inheritDoc */ protected function _prepareLayout() @@ -49,14 +51,6 @@ protected function _prepareLayout() return parent::_prepareLayout(); } - /** - * @return string - */ - public function getSaveButtonHtml() - { - return $this->getChildHtml('save_button'); - } - /** * @return string */ diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Edit.php index c4a71bd2f2e..6da40c56e4b 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Edit.php @@ -26,6 +26,8 @@ class Mage_Adminhtml_Block_System_Config_Edit extends Mage_Adminhtml_Block_Widge protected $_section; + protected $_template = 'system/config/edit.phtml'; + /** * Mage_Adminhtml_Block_System_Config_Edit constructor. * @throws Exception @@ -33,7 +35,6 @@ class Mage_Adminhtml_Block_System_Config_Edit extends Mage_Adminhtml_Block_Widge public function __construct() { parent::__construct(); - $this->setTemplate('system/config/edit.phtml'); $sectionCode = $this->getRequest()->getParam('section'); $sections = Mage::getSingleton('adminhtml/config')->getSections(); @@ -45,6 +46,7 @@ public function __construct() } /** + * @codeCoverageIgnore * @inheritDoc */ protected function _prepareLayout() @@ -61,14 +63,6 @@ protected function _prepareLayout() return parent::_prepareLayout(); } - /** - * @return string - */ - public function getSaveButtonHtml() - { - return $this->getChildHtml('save_button'); - } - /** * @return string */ diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php index c4c46b25e0c..85e0cc3fe5a 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Tabs.php @@ -27,11 +27,12 @@ class Mage_Adminhtml_Block_System_Config_Tabs extends Mage_Adminhtml_Block_Widge */ protected $_tabs; + protected $_idFieldName = 'system_config_tabs'; + protected $_template = 'system/config/tabs.phtml'; + protected function _construct() { - $this->setId('system_config_tabs'); $this->setTitle(Mage::helper('adminhtml')->__('Configuration')); - $this->setTemplate('system/config/tabs.phtml'); } /** @@ -54,16 +55,16 @@ public function initTabs() $configFields = Mage::getSingleton('adminhtml/config'); $sections = $configFields->getSections($current); - $tabs = (array)$configFields->getTabs()->children(); + $tabs = (array) $configFields->getTabs()->children(); - $sections = (array)$sections; + $sections = (array) $sections; usort($sections, [$this, '_sort']); usort($tabs, [$this, '_sort']); foreach ($tabs as $tab) { $helperName = $configFields->getAttributeModule($tab); - $label = Mage::helper($helperName)->__((string)$tab->label); + $label = Mage::helper($helperName)->__((string) $tab->label); $this->addTab($tab->getName(), [ 'label' => $label, @@ -86,7 +87,7 @@ public function initTabs() $helperName = $configFields->getAttributeModule($section); - $label = Mage::helper($helperName)->__((string)$section->label); + $label = Mage::helper($helperName)->__((string) $section->label); if ($code == $current) { if (!$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store')) { @@ -96,8 +97,8 @@ public function initTabs() } } if ($sectionAllowed && $hasChildren) { - $this->addSection($code, (string)$section->tab, [ - 'class' => (string)$section->class, + $this->addSection($code, (string) $section->tab, [ + 'class' => (string) $section->class, 'label' => $label, 'url' => $url->getUrl('*/*/*', ['_current' => true, 'section' => $code]), ]); diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php index 87d8435c228..b68ace08125 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/Wizard.php @@ -28,20 +28,13 @@ class Mage_Adminhtml_Block_System_Convert_Gui_Edit_Tab_Wizard extends Mage_Admin protected $_removeMapButtonHtml; protected $_shortDateFormat; + protected $_template = 'system/convert/profile/wizard.phtml'; + /** * @var array */ protected $_filterStores; - /** - * Mage_Adminhtml_Block_System_Convert_Gui_Edit_Tab_Wizard constructor. - */ - public function __construct() - { - parent::__construct(); - $this->setTemplate('system/convert/profile/wizard.phtml'); - } - /** * @return $this */ diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Run.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Run.php index fd74b554886..666dd076a48 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Run.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Run.php @@ -22,11 +22,7 @@ */ class Mage_Adminhtml_Block_System_Convert_Profile_Edit_Tab_Run extends Mage_Adminhtml_Block_Template { - public function __construct() - { - parent::__construct(); - $this->setTemplate('system/convert/profile/run.phtml'); - } + protected $_template = 'system/convert/profile/run.phtml'; public function getRunButtonHtml() { diff --git a/app/code/core/Mage/Adminhtml/Block/System/Currency.php b/app/code/core/Mage/Adminhtml/Block/System/Currency.php index 5a8d9524a22..48d4f1328e6 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Currency.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Currency.php @@ -22,11 +22,15 @@ */ class Mage_Adminhtml_Block_System_Currency extends Mage_Adminhtml_Block_Template { - protected function _construct() - { - $this->setTemplate('system/currency/rates.phtml'); - } + public const BUTTON_IMPORT = 'import_button'; + public const BLOCK_IMPORT_SERVICES = 'import_services'; + public const BLOCK_RATE_MATRIX = 'rates_matrix'; + + protected $_template = 'system/currency/rates.phtml'; + /** + * @inheritDoc + */ protected function _prepareLayout() { $this->setChild( @@ -60,12 +64,12 @@ protected function _prepareLayout() ); $this->setChild( - 'rates_matrix', + self::BLOCK_RATE_MATRIX, $this->getLayout()->createBlock('adminhtml/system_currency_rate_matrix') ); $this->setChild( - 'import_services', + self::BLOCK_IMPORT_SERVICES, $this->getLayout()->createBlock('adminhtml/system_currency_rate_services') ); @@ -77,29 +81,19 @@ protected function getHeader() return Mage::helper('adminhtml')->__('Manage Currency Rates'); } - protected function getSaveButtonHtml() - { - return $this->getChildHtml('save_button'); - } - - protected function getResetButtonHtml() - { - return $this->getChildHtml('reset_button'); - } - protected function getImportButtonHtml() { - return $this->getChildHtml('import_button'); + return $this->getChildHtml(self::BUTTON_IMPORT); } protected function getServicesHtml() { - return $this->getChildHtml('import_services'); + return $this->getChildHtml(self::BLOCK_IMPORT_SERVICES); } protected function getRatesMatrixHtml() { - return $this->getChildHtml('rates_matrix'); + return $this->getChildHtml(self::BLOCK_RATE_MATRIX); } protected function getImportFormAction() diff --git a/app/code/core/Mage/Adminhtml/Block/System/Design.php b/app/code/core/Mage/Adminhtml/Block/System/Design.php index c8e15009e25..4d77e2e8051 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Design.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Design.php @@ -21,13 +21,17 @@ */ class Mage_Adminhtml_Block_System_Design extends Mage_Adminhtml_Block_Template { + public const BLOCK_GRID = 'grid'; + + public const BUTTON_ADD = 'add_new_button'; + + protected $_template = 'system/design/index.phtml'; + /** * @inheritDoc */ protected function _prepareLayout() { - $this->setTemplate('system/design/index.phtml'); - $this->setChild( 'add_new_button', $this->getLayout()->createBlock('adminhtml/widget_button') diff --git a/app/code/core/Mage/Adminhtml/Block/System/Design/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Design/Edit.php index 884a9660cab..51c6503b6eb 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Design/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Design/Edit.php @@ -21,14 +21,11 @@ */ class Mage_Adminhtml_Block_System_Design_Edit extends Mage_Adminhtml_Block_Widget { - public function __construct() - { - parent::__construct(); - $this->setTemplate('system/design/edit.phtml'); - $this->setId('design_edit'); - } + protected $_idFieldName = 'design_edit'; + protected $_template = 'system/design/edit.phtml'; /** + * @codeCoverageIgnore * @inheritDoc */ protected function _prepareLayout() diff --git a/app/code/core/Mage/Adminhtml/Block/System/Email/Template.php b/app/code/core/Mage/Adminhtml/Block/System/Email/Template.php index 1551cd6f79b..ede894165f6 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Email/Template.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Email/Template.php @@ -22,14 +22,9 @@ */ class Mage_Adminhtml_Block_System_Email_Template extends Mage_Adminhtml_Block_Template { - /** - * Set transactional emails grid template - */ - protected function _construct() - { - parent::_construct(); - $this->setTemplate('system/email/template/list.phtml'); - } + public const BLOCK_GRID = 'grid'; + + protected $_template = 'system/email/template/list.phtml'; /** * @inheritDoc @@ -68,14 +63,4 @@ public function getHeaderText() { return Mage::helper('adminhtml')->__('Transactional Emails'); } - - /** - * Get Add New Template button html - * - * @return string - */ - protected function getAddButtonHtml() - { - return $this->getChildHtml('add_button'); - } } diff --git a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit.php index 436374814a8..fd54609d031 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Email/Template/Edit.php @@ -22,11 +22,14 @@ */ class Mage_Adminhtml_Block_System_Email_Template_Edit extends Mage_Adminhtml_Block_Widget { - public function __construct() - { - parent::__construct(); - $this->setTemplate('system/email/template/edit.phtml'); - } + public const BLOCK_FORM = 'form'; + public const BUTTON_LOAD = 'load_button'; + public const BUTTON_PREVIEW = 'preview_button'; + public const BUTTON_TO_HTML = 'to_html_button'; + public const BUTTON_TO_PLAIN = 'to_plain_button'; + public const BUTTON_TOGGLE = 'toggle_button'; + + protected $_template = 'system/email/template/edit.phtml'; /** * @inheritDoc @@ -142,7 +145,7 @@ protected function _prepareLayout() ); $this->setChild( - 'form', + self::BLOCK_FORM, $this->getLayout()->createBlock('adminhtml/system_email_template_edit_form') ); return parent::_prepareLayout(); @@ -161,15 +164,7 @@ public function getBackButtonHtml() */ public function getToggleButtonHtml() { - return $this->getChildHtml('toggle_button'); - } - - /** - * @return string - */ - public function getResetButtonHtml() - { - return $this->getChildHtml('reset_button'); + return $this->getChildHtml(self::BUTTON_TOGGLE); } /** @@ -177,7 +172,7 @@ public function getResetButtonHtml() */ public function getToPlainButtonHtml() { - return $this->getChildHtml('to_plain_button'); + return $this->getChildHtml(self::BUTTON_TO_PLAIN); } /** @@ -185,15 +180,7 @@ public function getToPlainButtonHtml() */ public function getToHtmlButtonHtml() { - return $this->getChildHtml('to_html_button'); - } - - /** - * @return string - */ - public function getSaveButtonHtml() - { - return $this->getChildHtml('save_button'); + return $this->getChildHtml(self::BUTTON_TO_HTML); } /** @@ -201,15 +188,7 @@ public function getSaveButtonHtml() */ public function getPreviewButtonHtml() { - return $this->getChildHtml('preview_button'); - } - - /** - * @return string - */ - public function getDeleteButtonHtml() - { - return $this->getChildHtml('delete_button'); + return $this->getChildHtml(self::BUTTON_PREVIEW); } /** @@ -217,7 +196,7 @@ public function getDeleteButtonHtml() */ public function getLoadButtonHtml() { - return $this->getChildHtml('load_button'); + return $this->getChildHtml(self::BUTTON_LOAD); } /** @@ -250,7 +229,7 @@ public function getHeaderText() */ public function getFormHtml() { - return $this->getChildHtml('form'); + return $this->getChildHtml(self::BLOCK_FORM); } /** diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Add.php b/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Add.php index 4a9f28df3ce..a12b3ce2e2f 100644 --- a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Add.php +++ b/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Add.php @@ -22,12 +22,14 @@ */ class Mage_Adminhtml_Block_Tax_Rate_Toolbar_Add extends Mage_Adminhtml_Block_Template { - public function __construct() - { - parent::__construct(); - $this->setTemplate('tax/toolbar/rate/add.phtml'); - } + public const BUTTON_ADD = 'addButton'; + + protected $_template = 'tax/toolbar/rate/add.phtml'; + /** + * @codeCoverageIgnore + * @inheritDoc + */ protected function _prepareLayout() { $this->setChild( diff --git a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Save.php b/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Save.php index 5359f65b7bc..c25e2fb9ca3 100644 --- a/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Save.php +++ b/app/code/core/Mage/Adminhtml/Block/Tax/Rate/Toolbar/Save.php @@ -23,6 +23,13 @@ */ class Mage_Adminhtml_Block_Tax_Rate_Toolbar_Save extends Mage_Adminhtml_Block_Template { + public const BUTTON_BACK = 'backButton'; + public const BUTTON_DELETE = 'deleteButton'; + public const BUTTON_RESET = 'resetButton'; + public const BUTTON_SAVE = 'saveButton'; + + protected $_template = 'tax/toolbar/rate/save.phtml'; + /** * Mage_Adminhtml_Block_Tax_Rate_Toolbar_Save constructor. */ @@ -30,12 +37,11 @@ public function __construct() { parent::__construct(); $this->assign('createUrl', $this->getUrl('*/tax_rate/save')); - $this->setTemplate('tax/toolbar/rate/save.phtml'); } /** + * @codeCoverageIgnore * @inheritDoc - * @throws Exception */ protected function _prepareLayout() { @@ -83,37 +89,13 @@ protected function _prepareLayout() } /** - * @return string - */ - public function getBackButtonHtml() - { - return $this->getChildHtml('backButton'); - } - - /** - * @return string - */ - public function getResetButtonHtml() - { - return $this->getChildHtml('resetButton'); - } - - /** - * @return string - */ - public function getSaveButtonHtml() - { - return $this->getChildHtml('saveButton'); - } - - /** - * @return string|void + * @inheritDoc * @throws Exception */ public function getDeleteButtonHtml() { if ((int) $this->getRequest()->getParam('rate') == 0) { - return; + return ''; } return $this->getChildHtml('deleteButton'); } diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php index 52d1aa7431c..b3e56c36a57 100644 --- a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php @@ -23,6 +23,8 @@ */ class Mage_Adminhtml_Block_Urlrewrite_Edit extends Mage_Adminhtml_Block_Widget_Container { + public const BUTTON_SKIP_CATEGORIES = 'skip_categories'; + /** * Part for building some blocks names * @@ -90,7 +92,7 @@ protected function _prepareLayout() $this->getLayout()->createBlock('adminhtml/urlrewrite_category_tree') ); $this->setChild( - 'skip_categories', + self::BUTTON_SKIP_CATEGORIES, $this->getLayout()->createBlock('adminhtml/widget_button')->setData([ 'label' => Mage::helper('adminhtml')->__('Skip Category Selection'), 'onclick' => 'window.location = \'' . Mage::helper('adminhtml')->getUrl('*/*/*', [ diff --git a/app/code/core/Mage/Adminhtml/Block/Widget.php b/app/code/core/Mage/Adminhtml/Block/Widget.php index 4bfebfae3ff..4603ac32cd8 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget.php @@ -21,7 +21,7 @@ * @package Mage_Adminhtml * * @method $this setHeaderCss(string $value) - * @method $this setTitle(string $value) + * @method $this setTitle(string $title) */ class Mage_Adminhtml_Block_Widget extends Mage_Adminhtml_Block_Template { diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Button.php b/app/code/core/Mage/Adminhtml/Block/Widget/Button.php index c953d82e637..4f867e7bc1b 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Button.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Button.php @@ -22,19 +22,28 @@ */ class Mage_Adminhtml_Block_Widget_Button extends Mage_Adminhtml_Block_Widget { - public function getType() - { - return ($type = $this->getData('type')) ? $type : 'button'; - } + public const DATA_AFTER_HTML = 'after_html'; + public const DATA_BEFORE_HTML = 'before_html'; + public const DATA_CLASS = 'class'; + public const DATA_DISABLED = 'disabled'; + public const DATA_ELEMENT_NAME = 'element_name'; + public const DATA_LABEL = 'label'; + public const DATA_LEVEL = 'level'; + public const DATA_NAME = 'name'; + public const DATA_ON_CLICK = 'on_click'; + public const DATA_STYLE = 'style'; + public const DATA_TITLE = 'title'; + public const DATA_TYPE = 'type'; + public const DATA_VALUE = 'value'; - public function getOnClick() - { - if (!$this->getData('on_click')) { - return $this->getData('onclick'); - } - return $this->getData('on_click'); - } + public const TYPE_BUTTON = 'button'; + public const TYPE_SUBMIT = 'submit'; + /** + * Prepare html output + * + * @return string + */ protected function _toHtml() { return $this->getBeforeHtml() . '' . $this->getAfterHtml(); } + + public function getAfterHtml(): ?string + { + return $this->getDataByKey(self::DATA_AFTER_HTML); + } + + /** + * @return $this + */ + public function setAfterHtml(string $html) + { + return $this->setData(self::DATA_AFTER_HTML, $html); + } + + public function getBeforeHtml(): ?string + { + return $this->getDataByKey(self::DATA_BEFORE_HTML); + } + + /** + * @return $this + */ + public function setBeforeHtml(string $html) + { + return $this->setData(self::DATA_BEFORE_HTML, $html); + } + + public function getClass(): ?string + { + return $this->getDataByKey(self::DATA_CLASS); + } + + /** + * @param Mage_Adminhtml_Block_Template::BUTTON__CLASS_* $class + * @return $this + */ + public function setClass(string $class) + { + return $this->setData(self::DATA_CLASS, $class); + } + + /** + * Add custmom html class + * + * @return $this + */ + public function addClass(string $class) + { + $curentClass = $this->getDataByKey(self::DATA_CLASS); + return $this->setData(self::DATA_CLASS, trim($curentClass) . ' ' . trim($class)); + } + + /** + * Reset html class to empty + * + * @return $this + */ + public function resetClass() + { + return $this->setData(self::DATA_CLASS, ''); + } + + public function getDisabled(): ?bool + { + return $this->getDataByKey(self::DATA_DISABLED); + } + + /** + * @return $this + */ + public function setDisabled(bool $value) + { + return $this->setData(self::DATA_DISABLED, $value); + } + + public function getElementName(): ?string + { + return $this->getDataByKey(self::DATA_ELEMENT_NAME); + } + + /** + * @return $this + */ + public function setElementName(string $name) + { + return $this->setData(self::DATA_ELEMENT_NAME, $name); + } + + public function getLabel(): ?string + { + return $this->getDataByKey(self::DATA_LABEL); + } + + /** + * @return $this + */ + public function setLabel(string $label) + { + return $this->setData(self::DATA_LABEL, $label); + } + + public function getLevel(): int + { + return $this->getDataByKey(self::DATA_LEVEL); + } + + /** + * @return $this + */ + public function setLevel(int $level) + { + return $this->setData(self::DATA_LEVEL, $level); + } + + public function getName(): ?string + { + return $this->getDataByKey(self::DATA_NAME); + } + + /** + * @return $this + */ + public function setName(string $name) + { + return $this->setData(self::DATA_NAME, $name); + } + + /** + * @return string + */ + public function getOnClick() + { + if (!$this->getDataByKey(self::DATA_ON_CLICK)) { + return $this->getDataByKey('onclick'); + } + return $this->getDataByKey(self::DATA_ON_CLICK); + } + + /** + * @return $this + */ + public function setOnClick(string $string) + { + return $this->setData(self::DATA_ON_CLICK, $string); + } + + /** + * @return $this + */ + public function setOnClickSetLocationJsUrl(string $route = '*/*/', array $params = []) + { + $url = Mage::helper('core/js')->getSetLocationJs($this->getUrl($route, $params)); + return $this->setOnClick($url); + } + + /** + * @return $this + */ + public function setOnClickSetLocationJsFullUrl(string $url) + { + $url = Mage::helper('core/js')->getSetLocationJs($url); + return $this->setOnClick($url); + } + + public function getStyle(): ?string + { + return $this->getDataByKey(self::DATA_STYLE); + } + + /** + * @return $this + */ + public function setStyle(string $style) + { + return $this->setData(self::DATA_STYLE, $style); + } + + public function getTitle(): ?string + { + return $this->getDataByKey(self::DATA_TITLE); + } + + /** + * @return $this + */ + public function setTitle(string $title) + { + return $this->setData(self::DATA_TITLE, $title); + } + + /** + * @return string + */ + public function getType() + { + return ($type = $this->getDataByKey(self::DATA_TYPE)) ? $type : self::TYPE_BUTTON; + } + + /** + * @return $this + */ + public function setType(string $type) + { + return $this->setData(self::DATA_TYPE, $type); + } + + /** + * @return string + */ + public function getValue() + { + return $this->getDataByKey(self::DATA_VALUE); + } + + /** + * @return $this + */ + public function setValue(string $value) + { + return $this->setData(self::DATA_VALUE, $value); + } } diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Form/Element/Gallery.php b/app/code/core/Mage/Adminhtml/Block/Widget/Form/Element/Gallery.php index 0c8cdda9ed4..217224ae8be 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Form/Element/Gallery.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Form/Element/Gallery.php @@ -24,10 +24,7 @@ class Mage_Adminhtml_Block_Widget_Form_Element_Gallery extends Mage_Adminhtml_Bl { protected $_element = null; - public function __construct() - { - $this->setTemplate('widget/form/element/gallery.phtml'); - } + protected $_template = 'widget/form/element/gallery.phtml'; public function render(Varien_Data_Form_Element_Abstract $element) { @@ -51,6 +48,10 @@ public function getValues() return $this->getElement()->getValue(); } + /** + * @codeCoverageIgnore + * @inheritDoc + */ protected function _prepareLayout() { $this->setChild( @@ -75,11 +76,6 @@ protected function _prepareLayout() return parent::_prepareLayout(); } - public function getAddButtonHtml() - { - return $this->getChildHtml('add_button'); - } - public function getDeleteButtonHtml($image) { return str_replace('#image#', $image, $this->getChildHtml('delete_button')); diff --git a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php index a8f3aa67c6d..b73edfef156 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid.php @@ -25,6 +25,10 @@ */ class Mage_Adminhtml_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget { + public const BUTTON_EXPORT = 'export_button'; + public const BUTTON_RESET_FILTER = 'reset_filter_button'; + public const BUTTON_SEARCH = 'search_button'; + /** * Columns array * @@ -214,6 +218,8 @@ class Mage_Adminhtml_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget */ protected ?array $defaultColumnSettings = null; + protected $_template = 'widget/grid.phtml'; + /** * Mage_Adminhtml_Block_Widget_Grid constructor. * @param array $attributes @@ -221,12 +227,12 @@ class Mage_Adminhtml_Block_Widget_Grid extends Mage_Adminhtml_Block_Widget public function __construct($attributes = []) { parent::__construct($attributes); - $this->setTemplate('widget/grid.phtml'); $this->setRowClickCallback('openGridRow'); $this->_emptyText = Mage::helper('adminhtml')->__('No records found.'); } /** + * @codeCoverageIgnore * @inheritDoc */ protected function _prepareLayout() @@ -265,7 +271,7 @@ protected function _prepareLayout() */ public function getExportButtonHtml() { - return $this->getChildHtml('export_button'); + return $this->getChildHtml(self::BUTTON_EXPORT); } /** @@ -273,7 +279,7 @@ public function getExportButtonHtml() */ public function getResetFilterButtonHtml() { - return $this->getChildHtml('reset_filter_button'); + return $this->getChildHtml(self::BUTTON_RESET_FILTER); } /** @@ -281,7 +287,7 @@ public function getResetFilterButtonHtml() */ public function getSearchButtonHtml() { - return $this->getChildHtml('search_button'); + return $this->getChildHtml(self::BUTTON_SEARCH); } /** 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 e3df83322eb..d46b0890230 100644 --- a/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php +++ b/app/code/core/Mage/Adminhtml/Block/Widget/Grid/Container.php @@ -56,7 +56,7 @@ public function __construct() } /** - * @inheritdoc + * @inheritDoc */ protected function _prepareLayout() { diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/OrphanedResourceController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/OrphanedResourceController.php index 7c3d53d8ef5..a1c4a57afce 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/OrphanedResourceController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/OrphanedResourceController.php @@ -74,7 +74,7 @@ public function massDeleteAction() } /** - * @inheritdoc + * @inheritDoc */ public function preDispatch() { diff --git a/app/code/core/Mage/Api2/Block/Adminhtml/Attribute/Buttons.php b/app/code/core/Mage/Api2/Block/Adminhtml/Attribute/Buttons.php index 82041b7b27e..432310e262a 100644 --- a/app/code/core/Mage/Api2/Block/Adminhtml/Attribute/Buttons.php +++ b/app/code/core/Mage/Api2/Block/Adminhtml/Attribute/Buttons.php @@ -22,16 +22,14 @@ */ class Mage_Api2_Block_Adminhtml_Attribute_Buttons extends Mage_Adminhtml_Block_Template { - public function __construct() - { - parent::__construct(); - $this->setTemplate('api2/attribute/buttons.phtml'); - } + public const BUTTON_BACK = 'backButton'; + public const BUTTON_SAVE = 'saveButton'; + + protected $_template = 'api2/attribute/buttons.phtml'; /** - * Prepare global layout - * - * @return Mage_Core_Block_Abstract + * @codeCoverageIgnore + * @inheritDoc */ protected function _prepareLayout() { @@ -56,36 +54,6 @@ protected function _prepareLayout() return parent::_prepareLayout(); } - /** - * Get back button HTML - * - * @return string - */ - public function getBackButtonHtml() - { - return $this->getChildHtml('backButton'); - } - - /** - * Get reset button HTML - * - * @return string - */ - public function getResetButtonHtml() - { - return $this->getChildHtml('resetButton'); - } - - /** - * Get save button HTML - * - * @return string - */ - public function getSaveButtonHtml() - { - return $this->getChildHtml('saveButton'); - } - /** * Get block caption * diff --git a/app/code/core/Mage/Api2/Block/Adminhtml/Roles/Buttons.php b/app/code/core/Mage/Api2/Block/Adminhtml/Roles/Buttons.php index 9f070afad49..037f87fdf9a 100644 --- a/app/code/core/Mage/Api2/Block/Adminhtml/Roles/Buttons.php +++ b/app/code/core/Mage/Api2/Block/Adminhtml/Roles/Buttons.php @@ -25,15 +25,15 @@ */ class Mage_Api2_Block_Adminhtml_Roles_Buttons extends Mage_Adminhtml_Block_Template { - public function __construct() - { - parent::__construct(); - $this->setTemplate('api2/role/buttons.phtml'); - } + public const BUTTON_BACK = 'backButton'; + public const BUTTON_DELETE = 'deleteButton'; + public const BUTTON_RESET = 'resetButton'; + public const BUTTON_SAVE = 'saveButton'; + + protected $_template = 'api2/role/buttons.phtml'; /** - * Preparing global layout - * + * @codeCoverageIgnore * @inheritDoc */ protected function _prepareLayout() @@ -69,39 +69,7 @@ protected function _prepareLayout() } /** - * Get back button HTML - * - * @return string - */ - public function getBackButtonHtml() - { - return $this->getChildHtml('backButton'); - } - - /** - * Get reset button HTML - * - * @return string - */ - public function getResetButtonHtml() - { - return $this->getChildHtml('resetButton'); - } - - /** - * Get save button HTML - * - * @return string - */ - public function getSaveButtonHtml() - { - return $this->getChildHtml('saveButton'); - } - - /** - * Get delete button HTML - * - * @return string + * @inheritDoc */ public function getDeleteButtonHtml() { @@ -111,7 +79,7 @@ public function getDeleteButtonHtml() return ''; } - $this->getChild('deleteButton')->setData('onclick', sprintf( + $this->getChild(self::BUTTON_DELETE)->setData('onclick', sprintf( "if(confirm('%s')) roleForm.submit('%s'); return false;", Mage::helper('core')->jsQuoteEscape(Mage::helper('adminhtml')->__('Are you sure you want to do this?')), $this->getUrl('*/*/delete') diff --git a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle.php b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle.php index 4ace45a9e3c..8c20bd121fb 100644 --- a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle.php +++ b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle.php @@ -22,12 +22,16 @@ */ class Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle extends Mage_Adminhtml_Block_Widget implements Mage_Adminhtml_Block_Widget_Tab_Interface { + public const BLOCK_OPTION_BOX = 'options_box'; + protected $_product = null; + + protected $_template = 'bundle/product/edit/bundle.phtml'; + public function __construct() { parent::__construct(); $this->setSkipGenerateContent(true); - $this->setTemplate('bundle/product/edit/bundle.phtml'); } /** @@ -47,14 +51,12 @@ public function getTabClass() } /** - * Prepare layout - * * @inheritDoc */ protected function _prepareLayout() { $this->setChild( - 'add_button', + self::BLOCK_OPTION_BOX, $this->getLayout()->createBlock('adminhtml/widget_button') ->setData([ 'label' => Mage::helper('bundle')->__('Add New Option'), @@ -65,7 +67,7 @@ protected function _prepareLayout() ); $this->setChild( - 'options_box', + self::BLOCK_OPTION_BOX, $this->getLayout()->createBlock( 'bundle/adminhtml_catalog_product_edit_tab_bundle_option', 'adminhtml.catalog.product.edit.tab.bundle.option' @@ -85,20 +87,12 @@ public function isReadonly() return $this->getProduct()->getCompositeReadonly(); } - /** - * @return string - */ - public function getAddButtonHtml() - { - return $this->getChildHtml('add_button'); - } - /** * @return string */ public function getOptionsBoxHtml() { - return $this->getChildHtml('options_box'); + return $this->getChildHtml(self::BLOCK_OPTION_BOX); } /** diff --git a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php index 15e527d5f07..3e7bf5110fd 100644 --- a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php +++ b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option.php @@ -27,6 +27,12 @@ */ class Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option extends Mage_Adminhtml_Block_Widget { + public const BLOCK_SELCTION_TEMPLATE = 'selection_template'; + + public const BUTTON_ADD_SELECTION = 'add_selection_button'; + public const BUTTON_CLOSE_SEARCH = 'close_search_button'; + public const BUTTON_OPTION_DELETE = 'option_delete_button'; + /** * Form element * @@ -57,6 +63,8 @@ class Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option extends */ protected $_options = null; + protected $_template = 'bundle/product/edit/bundle/option.phtml'; + /** * Bundle option renderer class constructor * @@ -64,7 +72,6 @@ class Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option extends */ public function __construct() { - $this->setTemplate('bundle/product/edit/bundle/option.phtml'); $this->setCanReadPrice(true); $this->setCanEditPrice(true); } @@ -138,7 +145,7 @@ public function isMultiWebsites() protected function _prepareLayout() { $this->setChild( - 'add_selection_button', + self::BLOCK_SELCTION_TEMPLATE, $this->getLayout()->createBlock('adminhtml/widget_button') ->setData([ 'id' => $this->getFieldId() . '_{{index}}_add_button', @@ -190,7 +197,7 @@ public function getAddButtonHtml() */ public function getCloseSearchButtonHtml() { - return $this->getChildHtml('close_search_button'); + return $this->getChildHtml(self::BUTTON_CLOSE_SEARCH); } /** @@ -198,7 +205,7 @@ public function getCloseSearchButtonHtml() */ public function getAddSelectionButtonHtml() { - return $this->getChildHtml('add_selection_button'); + return $this->getChildHtml(self::BUTTON_ADD_SELECTION); } /** @@ -249,7 +256,7 @@ public function getAddButtonId() { return $this->getLayout() ->getBlock('admin.product.bundle.items') - ->getChild('add_button')->getId(); + ->getChild(self::BUTTON_ADD)->getId(); } /** @@ -257,7 +264,7 @@ public function getAddButtonId() */ public function getOptionDeleteButtonHtml() { - return $this->getChildHtml('option_delete_button'); + return $this->getChildHtml(self::BUTTON_OPTION_DELETE); } /** @@ -265,7 +272,7 @@ public function getOptionDeleteButtonHtml() */ public function getSelectionHtml() { - return $this->getChildHtml('selection_template'); + return $this->getChildHtml(self::BLOCK_SELCTION_TEMPLATE); } /** diff --git a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search.php b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search.php index 4429cdad382..85dc7f915f7 100644 --- a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search.php +++ b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Search.php @@ -27,11 +27,10 @@ */ class Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option_Search extends Mage_Adminhtml_Block_Widget { - protected function _construct() - { - $this->setId('bundle_option_selection_search'); - $this->setTemplate('bundle/product/edit/bundle/option/search.phtml'); - } + public const BLOCK_GRID = 'grid'; + + protected $_idFieldName = 'bundle_option_selection_search'; + protected $_template = 'bundle/product/edit/bundle/option/search.phtml'; /** * @return string @@ -47,7 +46,7 @@ public function getHeaderText() protected function _prepareLayout() { $this->setChild( - 'grid', + self::BLOCK_GRID, $this->getLayout()->createBlock( 'bundle/adminhtml_catalog_product_edit_tab_bundle_option_search_grid', 'adminhtml.catalog.product.edit.tab.bundle.option.search.grid' @@ -61,7 +60,8 @@ protected function _prepareLayout() */ protected function _beforeToHtml() { - $this->getChild('grid')->setIndex($this->getIndex()) + $this->getChild(self::BLOCK_GRID) + ->setIndex($this->getIndex()) ->setFirstShow($this->getFirstShow()); return parent::_beforeToHtml(); diff --git a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Selection.php b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Selection.php index 616d608bb55..20cd78554a1 100644 --- a/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Selection.php +++ b/app/code/core/Mage/Bundle/Block/Adminhtml/Catalog/Product/Edit/Tab/Bundle/Option/Selection.php @@ -27,12 +27,15 @@ */ class Mage_Bundle_Block_Adminhtml_Catalog_Product_Edit_Tab_Bundle_Option_Selection extends Mage_Adminhtml_Block_Widget { + public const BUTTON_SELECTION_DELETE = 'selection_delete_button'; + + protected $_template = 'bundle/product/edit/bundle/option/selection.phtml'; + /** * Initialize bundle option selection block */ public function __construct() { - $this->setTemplate('bundle/product/edit/bundle/option/selection.phtml'); $this->setCanReadPrice(true); $this->setCanEditPrice(true); } @@ -58,8 +61,7 @@ public function getFieldName() } /** - * Prepare block layout - * + * @codeCoverageIgnore * @inheritDoc */ protected function _prepareLayout() @@ -83,7 +85,7 @@ protected function _prepareLayout() */ public function getSelectionDeleteButtonHtml() { - return $this->getChildHtml('selection_delete_button'); + return $this->getChildHtml(self::BUTTON_SELECTION_DELETE); } /** diff --git a/app/code/core/Mage/Core/Block/Abstract.php b/app/code/core/Mage/Core/Block/Abstract.php index 22dcf707e39..f20629bb795 100644 --- a/app/code/core/Mage/Core/Block/Abstract.php +++ b/app/code/core/Mage/Core/Block/Abstract.php @@ -28,13 +28,11 @@ * @method $this setCacheLifetime(int|false $value) * @method $this setCacheKey(string $value) * @method $this setCacheTags(array $value) - * @method $this setClass(string $value) + * @method $this setClass(string $class) * @method $this setDisabled(bool $value) - * @method $this setLabel(string $value) - * @method $this setOnclick(string $value) * @method string getPosition() * @method $this setTemplate(string $value) - * @method $this setType(string $value) + * @method $this setType(string $type) * @method bool hasWrapperMustBeVisible() */ abstract class Mage_Core_Block_Abstract extends Varien_Object @@ -300,7 +298,7 @@ public function setLayout(Mage_Core_Model_Layout $layout) } /** - * Preparing global layout + * Preparing global layout, adding buttons * * You can redefine this method in child classes for changing layout * diff --git a/app/code/core/Mage/Directory/Model/Currency/Import/Currencyconverterapi.php b/app/code/core/Mage/Directory/Model/Currency/Import/Currencyconverterapi.php index 8600c471c80..94ffa9b0dc2 100644 --- a/app/code/core/Mage/Directory/Model/Currency/Import/Currencyconverterapi.php +++ b/app/code/core/Mage/Directory/Model/Currency/Import/Currencyconverterapi.php @@ -62,7 +62,7 @@ public function __construct() } /** - * @inheritdoc + * @inheritDoc */ protected function _convert($currencyFrom, $currencyTo) { diff --git a/app/code/core/Mage/Directory/Model/Currency/Import/Fixerio.php b/app/code/core/Mage/Directory/Model/Currency/Import/Fixerio.php index 8a8b77ccd6c..fcd3fbade5f 100644 --- a/app/code/core/Mage/Directory/Model/Currency/Import/Fixerio.php +++ b/app/code/core/Mage/Directory/Model/Currency/Import/Fixerio.php @@ -62,7 +62,7 @@ public function __construct() } /** - * @inheritdoc + * @inheritDoc */ protected function _convert($currencyFrom, $currencyTo) { diff --git a/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php b/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php index 5b11a5e26e1..46575233f05 100644 --- a/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php +++ b/app/code/core/Mage/Downloadable/Block/Adminhtml/Catalog/Product/Edit/Tab/Downloadable/Links.php @@ -33,13 +33,14 @@ class Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Li */ protected $_purchasedSeparatelyAttribute = null; + protected $_template = 'downloadable/product/edit/downloadable/links.phtml'; + /** * Class constructor */ public function __construct() { parent::__construct(); - $this->setTemplate('downloadable/product/edit/downloadable/links.phtml'); $this->setCanEditPrice(true); $this->setCanReadPrice(true); } @@ -242,8 +243,7 @@ public function getConfigMaxDownloads() } /** - * Prepare block Layout - * + * @return $this */ protected function _prepareLayout() { @@ -271,7 +271,7 @@ protected function _prepareLayout() */ public function getUploadButtonHtml() { - return $this->getChild('upload_button')->toHtml(); + return $this->getChild(self::BUTTON_UPLOAD)->toHtml(); } /** @@ -300,7 +300,7 @@ public function getConfigJson($type = 'links') */ public function getBrowseButtonHtml($type = '') { - return $this->getChild('browse_button') + return $this->getChild(self::BUTTON_BROWSE) // Workaround for IE9 ->setBeforeHtml( '