From ce499a93bfba20a40370297b1cadcf32f554b56c Mon Sep 17 00:00:00 2001 From: Justin Beaty Date: Wed, 3 Aug 2022 07:37:59 -0700 Subject: [PATCH 01/22] Mage_Eav: Add generic grid code --- EVENTS.md | 4 + .../Catalog/Model/Resource/Eav/Attribute.php | 4 - .../Mage/Eav/Block/Adminhtml/Attribute.php | 49 ++ .../Eav/Block/Adminhtml/Attribute/Edit.php | 81 ++++ .../Block/Adminhtml/Attribute/Edit/Form.php | 30 ++ .../Attribute/Edit/Main/Abstract.php | 8 +- .../Adminhtml/Attribute/Edit/Tab/Main.php | 112 +++++ .../Adminhtml/Attribute/Edit/Tab/Options.php | 23 + .../Block/Adminhtml/Attribute/Edit/Tabs.php | 51 ++ .../Eav/Block/Adminhtml/Attribute/Grid.php | 63 +++ .../Adminhtml/Attribute/Grid/Abstract.php | 6 +- .../Eav/Block/Adminhtml/Attribute/Set.php | 54 +++ .../Block/Adminhtml/Attribute/Set/Grid.php | 72 +++ .../Block/Adminhtml/Attribute/Set/Main.php | 415 ++++++++++++++++ .../Attribute/Set/Main/Formattribute.php | 65 +++ .../Attribute/Set/Main/Formgroup.php | 81 ++++ .../Adminhtml/Attribute/Set/Main/Formset.php | 86 ++++ .../Attribute/Set/Main/Tree/Attribute.php | 33 ++ .../Attribute/Set/Main/Tree/Group.php | 33 ++ .../Adminhtml/Attribute/Set/Toolbar/Add.php | 82 ++++ .../Adminhtml/Attribute/Abstract.php | 337 +++++++++++++ .../Eav/Controller/Adminhtml/Set/Abstract.php | 195 ++++++++ app/code/core/Mage/Eav/Helper/Data.php | 77 +++ .../core/Mage/Eav/Model/Entity/Attribute.php | 4 + .../Eav/Model/Resource/Entity/Attribute.php | 4 +- app/code/core/Mage/Eav/etc/config.xml | 5 + .../default/template/eav/attribute/js.phtml | 174 +++++++ .../template/eav/attribute/set/main.phtml | 450 ++++++++++++++++++ .../attribute/set/main/tree/attribute.phtml | 20 + .../eav/attribute/set/main/tree/group.phtml | 21 + .../eav/attribute/set/toolbar/add.phtml | 35 ++ app/locale/en_US/Mage_Eav.csv | 12 + skin/adminhtml/default/default/boxes.css | 2 + 33 files changed, 2675 insertions(+), 13 deletions(-) create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Form.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Options.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tabs.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Attribute.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Group.php create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php create mode 100644 app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php create mode 100644 app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php create mode 100644 app/design/adminhtml/default/default/template/eav/attribute/js.phtml create mode 100644 app/design/adminhtml/default/default/template/eav/attribute/set/main.phtml create mode 100644 app/design/adminhtml/default/default/template/eav/attribute/set/main/tree/attribute.phtml create mode 100644 app/design/adminhtml/default/default/template/eav/attribute/set/main/tree/group.phtml create mode 100644 app/design/adminhtml/default/default/template/eav/attribute/set/toolbar/add.phtml diff --git a/EVENTS.md b/EVENTS.md index 0c9cb7488db..6d7bbef3926 100644 --- a/EVENTS.md +++ b/EVENTS.md @@ -36,6 +36,10 @@ | admin_user_authenticate_after | 1.9.4.5 | | admin_user_authenticate_before | 1.9.4.5 | | admin_user_validate | 1.9.4.5 | +| adminhtml_[entityCode]_attribute_types | 20.0.15 | +| adminhtml_[entityCode]_attribute_scopes | 20.0.15 | +| adminhtml_[entityCode]_attribute_edit_prepare_form | 20.0.15 | +| adminhtml_[entityCode]_attribute_edit_prepare_save | 20.0.15 | | adminhtml_block_eav_attribute_edit_form_init | 1.9.4.5 | | adminhtml_block_promo_widget_chooser_prepare_collection | 1.9.4.5 | | adminhtml_block_salesrule_actions_prepareform | 1.9.4.5 | diff --git a/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php b/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php index 9a928418705..f7e8aaf8921 100644 --- a/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php +++ b/app/code/core/Mage/Catalog/Model/Resource/Eav/Attribute.php @@ -70,10 +70,6 @@ */ class Mage_Catalog_Model_Resource_Eav_Attribute extends Mage_Eav_Model_Entity_Attribute { - const SCOPE_STORE = 0; - const SCOPE_GLOBAL = 1; - const SCOPE_WEBSITE = 2; - const MODULE_NAME = 'Mage_Catalog'; const ENTITY = 'catalog_eav_attribute'; diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute.php new file mode 100644 index 00000000000..ef4ad4eb69c --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute.php @@ -0,0 +1,49 @@ + + */ + +class Mage_Eav_Block_Adminhtml_Attribute extends Mage_Adminhtml_Block_Widget_Grid_Container +{ + public function __construct() + { + $this->_blockGroup = 'eav'; + $this->_controller = 'adminhtml_attribute'; + if ($entity_type = Mage::registry('entity_type')) { + $this->_headerText = Mage::helper('eav')->__('Manage %s Attributes', Mage::helper('eav')->formatTypeCode($entity_type)); + } else { + $this->_headerText = Mage::helper('eav')->__('Manage Attributes'); + } + $this->_addButtonLabel = Mage::helper('eav')->__('Add New Attribute'); + parent::__construct(); + } + + public function getHeaderCssClass() + { + return 'icon-head head-eav-attribute'; + } + +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php new file mode 100644 index 00000000000..e56fe46744f --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php @@ -0,0 +1,81 @@ +_objectId = 'attribute_id'; + $this->_blockGroup = 'eav'; + $this->_controller = 'adminhtml_attribute'; + + parent::__construct(); + + $this->_addButton( + 'save_and_edit_button', + array( + 'label' => Mage::helper('eav')->__('Save and Continue Edit'), + 'onclick' => 'saveAndContinueEdit()', + 'class' => 'save' + ), + 100 + ); + + $this->_updateButton('save', 'label', Mage::helper('eav')->__('Save Attribute')); + $this->_updateButton('save', 'onclick', 'saveAttribute()'); + + if (!Mage::registry('entity_attribute')->getIsUserDefined()) { + $this->_removeButton('delete'); + } else { + $this->_updateButton('delete', 'label', Mage::helper('eav')->__('Delete Attribute')); + } + } + + public function getHeaderText() + { + if (Mage::registry('entity_attribute')->getId()) { + $frontendLabel = Mage::registry('entity_attribute')->getFrontendLabel(); + if (is_array($frontendLabel)) { + $frontendLabel = $frontendLabel[0]; + } + return Mage::helper('eav')->__('Edit %s Attribute "%s"', Mage::helper('eav')->formatTypeCode(Mage::registry('entity_type')), $this->escapeHtml($frontendLabel)); + } + else { + return Mage::helper('eav')->__('New %s Attribute', Mage::helper('eav')->formatTypeCode(Mage::registry('entity_type'))); + } + } + + public function getValidationUrl() + { + return $this->getUrl('*/*/validate', array('_current'=>true)); + } + + public function getSaveUrl() + { + return $this->getUrl('*/*/save', array('_current'=>true, 'back'=>null)); + } + + public function getHeaderCssClass() + { + return 'icon-head head-eav-attribute'; + } + +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Form.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Form.php new file mode 100644 index 00000000000..7a37b2b7af1 --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Form.php @@ -0,0 +1,30 @@ + 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')); + $form->setUseContainer(true); + $this->setForm($form); + return parent::_prepareForm(); + } +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php index 30146a4105b..65da4424ccd 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Main/Abstract.php @@ -31,7 +31,7 @@ abstract class Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract extends Mag protected $_attribute = null; /** - * @param Mage_Catalog_Model_Resource_Eav_Attribute $attribute + * @param Mage_Eav_Model_Entity_Attribute $attribute * @return $this */ public function setAttributeObject($attribute) @@ -41,7 +41,7 @@ public function setAttributeObject($attribute) } /** - * @return Mage_Catalog_Model_Resource_Eav_Attribute + * @return Mage_Eav_Model_Entity_Attribute */ public function getAttributeObject() { @@ -97,8 +97,8 @@ protected function _prepareForm() $fieldset->addField('frontend_input', 'select', array( 'name' => 'frontend_input', - 'label' => Mage::helper('eav')->__('Catalog Input Type for Store Owner'), - 'title' => Mage::helper('eav')->__('Catalog Input Type for Store Owner'), + 'label' => Mage::helper('eav')->__('Input Type for Store Owner'), + 'title' => Mage::helper('eav')->__('Input Type for Store Owner'), 'value' => 'text', 'values'=> $inputTypes )); diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php new file mode 100644 index 00000000000..430ae987cf4 --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php @@ -0,0 +1,112 @@ +getAttributeObject(); + $attributeTypeCode = $attributeObject->getEntityType()->getEntityTypeCode(); + /* @var $form Varien_Data_Form */ + $form = $this->getForm(); + /* @var $fieldset Varien_Data_Form_Element_Fieldset */ + $fieldset = $form->getElement('base_fieldset'); + + $fieldset->getElements() + ->searchById('attribute_code') + ->setData( + 'class', + 'validate-code-event ' . $fieldset->getElements()->searchById('attribute_code')->getData('class') + )->setData( + 'note', + $fieldset->getElements()->searchById('attribute_code')->getData('note') + . Mage::helper('eav')->__('. Do not use "event" for an attribute code, it is a reserved keyword.') + ); + + $fieldset->getElements() + ->searchById('is_unique') + ->setData( + 'title', + Mage::helper('eav')->__('Unique Value (not shared with other %s)', strtolower(Mage::helper('eav')->formatTypeCode($attributeTypeCode))) + )->setData( + 'note', + Mage::helper('eav')->__('Not shared with other %s', strtolower(Mage::helper('eav')->formatTypeCode($attributeTypeCode))) + ); + + $frontendInputElm = $form->getElement('frontend_input'); + $additionalTypes = array(); + + $response = new Varien_Object(); + $response->setTypes(array()); + Mage::dispatchEvent("adminhtml_{$attributeTypeCode}_attribute_types", array('response'=>$response)); + $_disabledTypes = array(); + $_hiddenFields = array(); + foreach ($response->getTypes() as $type) { + $additionalTypes[] = $type; + if (isset($type['hide_fields'])) { + $_hiddenFields[$type['value']] = $type['hide_fields']; + } + if (isset($type['disabled_types'])) { + $_disabledTypes[$type['value']] = $type['disabled_types']; + } + } + Mage::register('attribute_type_hidden_fields', $_hiddenFields); + Mage::register('attribute_type_disabled_types', $_disabledTypes); + + $frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes); + $frontendInputElm->setValues($frontendInputValues); + + $scopes = array( + Mage_Eav_Model_Entity_Attribute::SCOPE_STORE =>Mage::helper('eav')->__('Store View'), + Mage_Eav_Model_Entity_Attribute::SCOPE_WEBSITE =>Mage::helper('eav')->__('Website'), + Mage_Eav_Model_Entity_Attribute::SCOPE_GLOBAL =>Mage::helper('eav')->__('Global'), + ); + + if ($attributeObject->getAttributeCode() == 'status') { + unset($scopes[Mage_Eav_Model_Entity_Attribute::SCOPE_STORE]); + } + + $response = new Varien_Object(); + $response->setScopes($scopes); + $response->setAttribute($attributeObject); + Mage::dispatchEvent("adminhtml_{$attributeTypeCode}_attribute_scopes", array('response'=>$response)); + + $fieldset->addField('is_global', 'select', array( + 'name' => 'is_global', + 'label' => Mage::helper('eav')->__('Scope'), + 'title' => Mage::helper('eav')->__('Scope'), + 'note' => Mage::helper('eav')->__('Declare attribute value saving scope'), + 'values'=> $response->getScopes(), + ), 'attribute_code'); + + Mage::dispatchEvent("adminhtml_{$attributeTypeCode}_attribute_edit_prepare_form", array( + 'form' => $form, + 'attribute' => $attributeObject + )); + + return $this; + } +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Options.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Options.php new file mode 100644 index 00000000000..2c3d11f4177 --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Options.php @@ -0,0 +1,23 @@ +setId('eav_attribute_tabs'); + $this->setDestElementId('edit_form'); + $this->setTitle(Mage::helper('eav')->__('Attribute Information')); + } + + protected function _beforeToHtml() + { + $this->addTab('main', array( + 'label' => Mage::helper('eav')->__('Properties'), + 'title' => Mage::helper('eav')->__('Properties'), + 'content' => $this->getLayout()->createBlock('eav/adminhtml_attribute_edit_tab_main')->toHtml(), + 'active' => true + )); + + $model = Mage::registry('entity_attribute'); + + $this->addTab('labels', array( + 'label' => Mage::helper('eav')->__('Manage Label / Options'), + 'title' => Mage::helper('eav')->__('Manage Label / Options'), + 'content' => $this->getLayout()->createBlock('eav/adminhtml_attribute_edit_tab_options')->toHtml(), + )); + + return parent::_beforeToHtml(); + } + +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php new file mode 100644 index 00000000000..dc25681375e --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php @@ -0,0 +1,63 @@ +getEntityAttributeCollection()); + $collection->setEntityTypeFilter($entity_type->getEntityTypeId()); + $this->setCollection($collection); + } + return parent::_prepareCollection(); + } + + /** + * Prepare attributes grid columns + * + * @return $this + */ + protected function _prepareColumns() + { + parent::_prepareColumns(); + + $this->addColumn('is_global', array( + 'header'=>Mage::helper('eav')->__('Scope'), + 'sortable'=>true, + 'index'=>'is_global', + 'type' => 'options', + 'options' => array( + Mage_Eav_Model_Entity_Attribute::SCOPE_STORE =>Mage::helper('eav')->__('Store View'), + Mage_Eav_Model_Entity_Attribute::SCOPE_WEBSITE =>Mage::helper('eav')->__('Website'), + Mage_Eav_Model_Entity_Attribute::SCOPE_GLOBAL =>Mage::helper('eav')->__('Global'), + ), + 'align' => 'center', + )); + + return $this; + } +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid/Abstract.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid/Abstract.php index 526a4689ad3..1b7e04ccddc 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid/Abstract.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid/Abstract.php @@ -19,10 +19,10 @@ */ /** - * Product attributes grid + * Eav attributes grid * * @category Mage - * @package Mage_Adminhtml + * @package Mage_Eav * @author Magento Core Team */ abstract class Mage_Eav_Block_Adminhtml_Attribute_Grid_Abstract extends Mage_Adminhtml_Block_Widget_Grid @@ -87,7 +87,7 @@ protected function _prepareColumns() /** * Return url of given row * - * @param Mage_Catalog_Model_Resource_Eav_Attribute $row + * @param Mage_Eav_Model_Entity_Attribute $row * @return string */ public function getRowUrl($row) diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set.php new file mode 100644 index 00000000000..b22883bb32b --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set.php @@ -0,0 +1,54 @@ + + */ + +class Mage_Eav_Block_Adminhtml_Attribute_Set extends Mage_Adminhtml_Block_Widget_Grid_Container +{ + public function __construct() + { + $this->_blockGroup = 'eav'; + $this->_controller = 'adminhtml_attribute_set'; + if ($entity_type = Mage::registry('entity_type')) { + $this->_headerText = Mage::helper('eav')->__('Manage %s Attribute Sets', Mage::helper('eav')->formatTypeCode($entity_type)); + } else { + $this->_headerText = Mage::helper('eav')->__('Manage Attribute Sets'); + } + $this->_addButtonLabel = Mage::helper('eav')->__('Add New Set'); + parent::__construct(); + } + + public function getCreateUrl() + { + return $this->getUrl('*/*/add'); + } + + public function getHeaderCssClass() + { + return 'icon-head head-eav-attribute-sets'; + } + +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php new file mode 100644 index 00000000000..4251d08ac89 --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php @@ -0,0 +1,72 @@ + + */ +class Mage_Eav_Block_Adminhtml_Attribute_Set_Grid extends Mage_Adminhtml_Block_Widget_Grid +{ + + public function __construct() + { + parent::__construct(); + $this->setId('setGrid'); + $this->setDefaultSort('set_name'); + $this->setDefaultDir('ASC'); + $this->setSaveParametersInSession(true); + } + + protected function _prepareCollection() + { + $collection = Mage::getResourceModel('eav/entity_attribute_set_collection') + ->setEntityTypeFilter(Mage::registry('entity_type')->getEntityTypeId()); + + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + protected function _prepareColumns() + { + /*$this->addColumn('set_id', array( + 'header' => Mage::helper('eav')->__('ID'), + 'align' => 'right', + 'sortable' => true, + 'width' => '50px', + 'index' => 'attribute_set_id', + ));*/ + + $this->addColumn('set_name', array( + 'header' => Mage::helper('eav')->__('Set Name'), + 'align' => 'left', + 'sortable' => true, + 'index' => 'attribute_set_name', + )); + } + + public function getRowUrl($row) + { + return $this->getUrl('*/*/edit', array('id'=>$row->getAttributeSetId())); + } + +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php new file mode 100644 index 00000000000..23ccec4bc62 --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php @@ -0,0 +1,415 @@ + + */ +class Mage_Eav_Block_Adminhtml_Attribute_Set_Main extends Mage_Adminhtml_Block_Template +{ + /** + * Initialize template + * + */ + protected function _construct() + { + $this->setTemplate('eav/attribute/set/main.phtml'); + } + + /** + * Prepare Global Layout + * + * @return $this + */ + protected function _prepareLayout() + { + $setId = $this->_getSetId(); + + $this->setChild('group_tree', + $this->getLayout()->createBlock('eav/adminhtml_attribute_set_main_tree_group') + ); + + $this->setChild('edit_set_form', + $this->getLayout()->createBlock('eav/adminhtml_attribute_set_main_formset') + ); + + $this->setChild('delete_group_button', + $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( + 'label' => Mage::helper('eav')->__('Delete Selected Group'), + 'onclick' => 'editSet.submit();', + 'class' => 'delete' + ))); + + $this->setChild('add_group_button', + $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( + 'label' => Mage::helper('eav')->__('Add New'), + 'onclick' => 'editSet.addGroup();', + 'class' => 'add' + ))); + + $this->setChild('back_button', + $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( + 'label' => Mage::helper('eav')->__('Back'), + 'onclick' => 'setLocation(\''.$this->getUrl('*/*/').'\')', + 'class' => 'back' + ))); + + $this->setChild('reset_button', + $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( + 'label' => Mage::helper('eav')->__('Reset'), + 'onclick' => 'window.location.reload()' + ))); + + $this->setChild('save_button', + $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( + 'label' => Mage::helper('eav')->__('Save Attribute Set'), + 'onclick' => 'editSet.save();', + 'class' => 'save' + ))); + + if ($entity_type = Mage::registry('entity_type')) { + $deleteConfirmMessage = $this->jsQuoteEscape(Mage::helper('eav') + ->__('All %s of this set will be deleted! Are you sure you want to delete this attribute set?')); + } else { + $deleteConfirmMessage = $this->jsQuoteEscape(Mage::helper('eav') + ->__('All items of this set will be deleted! Are you sure you want to delete this attribute set?')); + } + $deleteUrl = $this->getUrlSecure('*/*/delete', array('id' => $setId)); + $this->setChild('delete_button', + $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( + 'label' => Mage::helper('eav')->__('Delete Attribute Set'), + 'onclick' => 'deleteConfirm(\'' . $deleteConfirmMessage . '\', \'' . $deleteUrl . '\')', + 'class' => 'delete' + ))); + + $this->setChild('rename_button', + $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( + 'label' => Mage::helper('eav')->__('New Set Name'), + 'onclick' => 'editSet.rename()' + ))); + + return parent::_prepareLayout(); + } + + /** + * Retrieve Attribute Set Group Tree HTML + * + * @return string + */ + public function getGroupTreeHtml() + { + return $this->getChildHtml('group_tree'); + } + + /** + * Retrieve Attribute Set Edit Form HTML + * + * @return string + */ + public function getSetFormHtml() + { + return $this->getChildHtml('edit_set_form'); + } + + /** + * Retrieve Block Header Text + * + * @return string + */ + protected function _getHeader() + { + return Mage::helper('eav')->__("Edit Attribute Set '%s'", $this->_getAttributeSet()->getAttributeSetName()); + } + + /** + * Retrieve Attribute Set Save URL + * + * @return string + */ + public function getMoveUrl() + { + return $this->getUrl('*/*/save', array('id' => $this->_getSetId())); + } + + /** + * Retrieve Attribute Set Group Save URL + * + * @return string + */ + public function getGroupUrl() + { + return $this->getUrl('*/*/save', array('id' => $this->_getSetId())); + } + + /** + * Retrieve Attribute Set Group Tree as JSON format + * + * @return string + */ + public function getGroupTreeJson() + { + $items = array(); + $setId = $this->_getSetId(); + + /* @var $groups Mage_Eav_Model_Mysql4_Entity_Attribute_Group_Collection */ + $groups = Mage::getModel('eav/entity_attribute_group') + ->getResourceCollection() + ->setAttributeSetFilter($setId) + ->setSortOrder() + ->load(); + + /* @var $entity_type Mage_Eav_Model_Entity_Type */ + $entity_type = Mage::registry('entity_type'); + + /* @var $node Mage_Eav_Model_Entity_Attribute_Group */ + foreach ($groups as $node) { + $item = array(); + $item['text'] = $node->getAttributeGroupName(); + $item['id'] = $node->getAttributeGroupId(); + $item['cls'] = 'folder'; + $item['allowDrop'] = true; + $item['allowDrag'] = true; + + /** @var Mage_Eav_Model_Entity_Attribute $nodeChildren */ + $nodeChildren = Mage::getResourceModel($entity_type->getEntityAttributeCollection()); + $nodeChildren->setEntityTypeFilter($entity_type->getEntityTypeId()) + ->setAttributeGroupFilter($node->getId()) + ->load(); + + if ($nodeChildren->getSize() > 0) { + $item['children'] = array(); + foreach ($nodeChildren->getItems() as $child) { + /* @var $child Mage_Eav_Model_Entity_Attribute */ + $attr = array( + 'text' => $child->getAttributeCode(), + 'id' => $child->getAttributeId(), + 'cls' => (!$child->getIsUserDefined()) ? 'system-leaf' : 'leaf', + 'allowDrop' => false, + 'allowDrag' => true, + 'leaf' => true, + 'is_user_defined' => $child->getIsUserDefined(), + 'entity_id' => $child->getEntityAttributeId() + ); + + $item['children'][] = $attr; + } + } + + $items[] = $item; + } + + return Mage::helper('core')->jsonEncode($items); + } + + /** + * Retrieve Unused in Attribute Set Attribute Tree as JSON + * + * @return string + */ + public function getAttributeTreeJson() + { + $items = array(); + $setId = $this->_getSetId(); + + /* @var $entity_type Mage_Eav_Model_Entity_Type */ + $entity_type = Mage::registry('entity_type'); + + /** @var Mage_Eav_Model_Resource_Entity_Attribute_Collection $collection */ + $collection = Mage::getResourceModel($entity_type->getEntityAttributeCollection()); + $collection->setEntityTypeFilter($entity_type->getEntityTypeId()) + ->setAttributeSetFilter($setId) + ->load(); + + $attributesIds = array('0'); + /* @var $item Mage_Eav_Model_Entity_Attribute */ + foreach ($collection->getItems() as $item) { + $attributesIds[] = $item->getAttributeId(); + } + + /** @var Mage_Eav_Model_Resource_Entity_Attribute_Collection $attributes */ + $attributes = Mage::getResourceModel($entity_type->getEntityAttributeCollection()); + $attributes->setEntityTypeFilter($entity_type->getEntityTypeId()) + ->setAttributesExcludeFilter($attributesIds) + ->setOrder('attribute_code', 'asc') + ->load(); + + foreach ($attributes as $child) { + $attr = array( + 'text' => $child->getAttributeCode(), + 'id' => $child->getAttributeId(), + 'cls' => 'leaf', + 'allowDrop' => false, + 'allowDrag' => true, + 'leaf' => true, + 'is_user_defined' => $child->getIsUserDefined(), + 'entity_id' => $child->getEntityId() + ); + + $items[] = $attr; + } + + if (count($items) == 0) { + $items[] = array( + 'text' => Mage::helper('eav')->__('Empty'), + 'id' => 'empty', + 'cls' => 'folder', + 'allowDrop' => false, + 'allowDrag' => false, + ); + } + + return Mage::helper('core')->jsonEncode($items); + } + + /** + * 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 + */ + public function getDeleteButtonHtml() + { + if ($this->getIsCurrentSetDefault()) { + return ''; + } + return $this->getChildHtml('delete_button'); + } + + /** + * Retrieve Delete Group Button HTML + * + * @return string + */ + public function getDeleteGroupButton() + { + return $this->getChildHtml('delete_group_button'); + } + + /** + * Retrieve Add New Group Button HTML + * + * @return string + */ + public function getAddGroupButton() + { + return $this->getChildHtml('add_group_button'); + } + + /** + * Retrieve Rename Button HTML + * + * @return string + */ + public function getRenameButton() + { + return $this->getChildHtml('rename_button'); + } + + /** + * Retrieve current Attribute Set object + * + * @return Mage_Eav_Model_Entity_Attribute_Set + */ + protected function _getAttributeSet() + { + return Mage::registry('current_attribute_set'); + } + + /** + * Retrieve current attribute set Id + * + * @return int + */ + protected function _getSetId() + { + return $this->_getAttributeSet()->getId(); + } + + /** + * Check Current Attribute Set is a default + * + * @return bool + */ + public function getIsCurrentSetDefault() + { + $isDefault = $this->getData('is_current_set_default'); + if (is_null($isDefault)) { + $defaultSetId = Mage::registry('entity_type')->getDefaultAttributeSetId(); + $isDefault = $this->_getSetId() == $defaultSetId; + $this->setData('is_current_set_default', $isDefault); + } + return $isDefault; + } + + /** + * Retrieve current Attribute Set object + * + * @deprecated use _getAttributeSet + * @return Mage_Eav_Model_Entity_Attribute_Set + */ + protected function _getSetData() + { + return $this->_getAttributeSet(); + } + + /** + * Prepare HTML + * + * @return string + */ + protected function _toHtml() + { + $type = Mage::registry('entity_type')->getEntityTypeCode(); + Mage::dispatchEvent("adminhtml_{$type}_attribute_set_main_html_before", array('block' => $this)); + return parent::_toHtml(); + } +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php new file mode 100644 index 00000000000..99ab6c967be --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php @@ -0,0 +1,65 @@ + + */ + +class Mage_Eav_Block_Adminhtml_Attribute_Set_Main_Formattribute extends Mage_Adminhtml_Block_Widget_Form +{ + public function __construct() + { + parent::__construct(); + } + + protected function _prepareForm() + { + $form = new Varien_Data_Form(); + + $fieldset = $form->addFieldset('set_fieldset', array('legend'=>Mage::helper('eav')->__('Add New Attribute'))); + + $fieldset->addField('new_attribute', 'text', + array( + 'label' => Mage::helper('eav')->__('Name'), + 'name' => 'new_attribute', + 'required' => true, + ) + ); + + $fieldset->addField('submit', 'note', + array( + 'text' => $this->getLayout()->createBlock('adminhtml/widget_button') + ->setData(array( + 'label' => Mage::helper('eav')->__('Add Attribute'), + 'onclick' => 'this.form.submit();', + 'class' => 'add' + )) + ->toHtml(), + ) + ); + + $form->setUseContainer(true); + $form->setMethod('post'); + $this->setForm($form); + return $this; + } +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php new file mode 100644 index 00000000000..dcdf466430f --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php @@ -0,0 +1,81 @@ + + */ + +class Mage_Eav_Block_Adminhtml_Attribute_Set_Main_Formgroup extends Mage_Adminhtml_Block_Widget_Form +{ + public function __construct() + { + parent::__construct(); + } + + protected function _prepareForm() + { + $form = new Varien_Data_Form(); + + $fieldset = $form->addFieldset('set_fieldset', array('legend'=>Mage::helper('eav')->__('Add New Group'))); + + $fieldset->addField('attribute_group_name', 'text', + array( + 'label' => Mage::helper('eav')->__('Name'), + 'name' => 'attribute_group_name', + 'required' => true, + ) + ); + + $fieldset->addField('submit', 'note', + array( + 'text' => $this->getLayout()->createBlock('adminhtml/widget_button') + ->setData(array( + 'label' => Mage::helper('eav')->__('Add Group'), + 'onclick' => 'this.form.submit();', + 'class' => 'add' + )) + ->toHtml(), + ) + ); + + $fieldset->addField('attribute_set_id', 'hidden', + array( + 'name' => 'attribute_set_id', + 'value' => $this->_getSetId(), + ) + + ); + + $form->setUseContainer(true); + $form->setMethod('post'); + $form->setAction($this->getUrl('*/*/save')); + $this->setForm($form); + return $this; + } + + protected function _getSetId() + { + return ( intval($this->getRequest()->getParam('id')) > 0 ) + ? intval($this->getRequest()->getParam('id')) + : Mage::registry('entity_type')->getDefaultAttributeSetId(); + } +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php new file mode 100644 index 00000000000..301d9ad994e --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php @@ -0,0 +1,86 @@ + + */ + +class Mage_Eav_Block_Adminhtml_Attribute_Set_Main_Formset extends Mage_Adminhtml_Block_Widget_Form +{ + public function __construct() + { + parent::__construct(); + } + + /** + * Prepares attribute set form + * + */ + protected function _prepareForm() + { + $data = Mage::getModel('eav/entity_attribute_set') + ->load($this->getRequest()->getParam('id')); + + $form = new Varien_Data_Form(); + $fieldset = $form->addFieldset('set_name', array('legend'=> Mage::helper('eav')->__('Edit Set Name'))); + $fieldset->addField('attribute_set_name', 'text', array( + 'label' => Mage::helper('eav')->__('Name'), + 'note' => Mage::helper('eav')->__('For internal use.'), + 'name' => 'attribute_set_name', + 'required' => true, + 'class' => 'required-entry validate-no-html-tags', + 'value' => $data->getAttributeSetName() + )); + + if( !$this->getRequest()->getParam('id', false) ) { + $fieldset->addField('gotoEdit', 'hidden', array( + 'name' => 'gotoEdit', + 'value' => '1' + )); + + /** @var Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection @collection */ + $collection = Mage::getModel('eav/entity_attribute_set') + ->getResourceCollection(); + + $sets = $collection->setEntityTypeFilter(Mage::registry('entity_type')->getEntityTypeId()) + ->setOrder('attribute_set_name', 'asc') + ->load() + ->toOptionArray(); + + $fieldset->addField('skeleton_set', 'select', array( + 'label' => Mage::helper('eav')->__('Based On'), + 'name' => 'skeleton_set', + 'required' => true, + 'class' => 'required-entry', + 'values' => $sets, + )); + } + + $form->setMethod('post'); + $form->setUseContainer(true); + $form->setId('set_prop_form'); + $form->setAction($this->getUrl('*/*/save')); + $form->setOnsubmit('return false;'); + $this->setForm($form); + return $this; + } +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Attribute.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Attribute.php new file mode 100644 index 00000000000..8bd7ad8d0b1 --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Attribute.php @@ -0,0 +1,33 @@ + + */ + +class Mage_Eav_Block_Adminhtml_Attribute_Set_Main_Tree_Attribute extends Mage_Adminhtml_Block_Template +{ + protected function _construct() + { + $this->setTemplate('eav/attribute/set/main/tree/attribute.phtml'); + } +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Group.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Group.php new file mode 100644 index 00000000000..e4eba07c4f4 --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Group.php @@ -0,0 +1,33 @@ + + */ + +class Mage_Eav_Block_Adminhtml_Attribute_Set_Main_Tree_Group extends Mage_Adminhtml_Block_Template +{ + protected function _construct() + { + $this->setTemplate('eav/attribute/set/main/tree/group.phtml'); + } +} diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php new file mode 100644 index 00000000000..b87f5c3a92c --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php @@ -0,0 +1,82 @@ + + */ +class Mage_Eav_Block_Adminhtml_Attribute_Set_Toolbar_Add extends Mage_Adminhtml_Block_Template +{ + protected function _construct() + { + $this->setTemplate('eav/attribute/set/toolbar/add.phtml'); + } + + protected function _prepareLayout() + { + $this->setChild('save_button', + $this->getLayout()->createBlock('adminhtml/widget_button') + ->setData(array( + 'label' => Mage::helper('eav')->__('Save Attribute Set'), + 'onclick' => 'if (addSet.submit()) disableElements(\'save\');', + 'class' => 'save' + ))); + $this->setChild('back_button', + $this->getLayout()->createBlock('adminhtml/widget_button') + ->setData(array( + 'label' => Mage::helper('eav')->__('Back'), + 'onclick' => 'setLocation(\''.$this->getUrl('*/*/').'\')', + 'class' => 'back' + ))); + + $this->setChild('setForm', + $this->getLayout()->createBlock('eav/adminhtml_attribute_set_main_formset') + ); + return parent::_prepareLayout(); + } + + protected function _getHeader() + { + return Mage::helper('eav')->__('Add New Attribute Set'); + } + + protected function getSaveButtonHtml() + { + return $this->getChildHtml('save_button'); + } + + protected function getBackButtonHtml() + { + return $this->getChildHtml('back_button'); + } + + protected function getFormHtml() + { + return $this->getChildHtml('setForm'); + } + + protected function getFormId() + { + return $this->getChild('setForm')->getForm()->getId(); + } +} diff --git a/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php b/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php new file mode 100644 index 00000000000..a2818da6254 --- /dev/null +++ b/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php @@ -0,0 +1,337 @@ + + */ + +abstract class Mage_Eav_Controller_Adminhtml_Attribute_Abstract extends Mage_Adminhtml_Controller_Action +{ + + /** @var string $_entityCode */ + protected $_entityCode; + + /** @var Mage_Eav_Model_Entity_Type $_entityType */ + protected $_entityType; + + /** + * Controller predispatch method + * + * @return Mage_Adminhtml_Controller_Action + */ + public function preDispatch() + { + $this->_setForcedFormKeyActions('delete'); + $this->_entityType = Mage::getModel('eav/entity')->setType($this->_entityCode)->getEntityType(); + if (!Mage::registry('entity_type')) { + Mage::register('entity_type', $this->_entityType); + } + return parent::preDispatch(); + } + + protected function _initAction() + { + return $this->loadLayout(); + } + + public function indexAction() + { + $this->_initAction() + ->_addContent($this->getLayout()->createBlock('eav/adminhtml_attribute')) + ->renderLayout(); + } + + public function newAction() + { + $this->_forward('edit'); + } + + public function editAction() + { + $id = $this->getRequest()->getParam('attribute_id'); + $model = Mage::getModel($this->_entityType->getAttributeModel()) + ->setEntityTypeId($this->_entityType->getEntityTypeId()); + if ($id) { + $model->load($id); + + if (! $model->getId()) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('eav')->__('This attribute no longer exists')); + $this->_redirect('*/*/'); + return; + } + + // entity type check + if ($model->getEntityTypeId() != $this->_entityType->getEntityTypeId()) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('eav')->__('This attribute cannot be edited.')); + $this->_redirect('*/*/'); + return; + } + } + + // set entered data if was error when we do save + $data = Mage::getSingleton('adminhtml/session')->getAttributeData(true); + if (! empty($data)) { + $model->addData($data); + } + + Mage::register('entity_attribute', $model); + + $this->_initAction(); + + $this->_title($id ? $model->getName() : $this->__('New Attribute')); + + $item = $id ? Mage::helper('eav')->__('Edit Attribute') + : Mage::helper('eav')->__('New Attribute'); + + $this->_addBreadcrumb($item, $item); + + $this->_addLeft($this->getLayout()->createBlock('eav/adminhtml_attribute_edit_tabs')) + ->_addContent($this->getLayout()->createBlock('eav/adminhtml_attribute_edit')); + + $this->_addJs( + $this->getLayout()->createBlock('adminhtml/template') + ->setTemplate('eav/attribute/js.phtml') + ); + + $this->renderLayout(); + + } + + public function validateAction() + { + $response = new Varien_Object(); + $response->setError(false); + + $attributeCode = $this->getRequest()->getParam('attribute_code'); + $attributeId = $this->getRequest()->getParam('attribute_id'); + + /** @var Mage_Eav_Model_Entity_Attribute $attribute */ + $attribute = Mage::getModel($this->_entityType->getAttributeModel()); + $attribute->loadByCode($this->_entityType->getEntityTypeId(), $attributeCode); + + if ($attribute->getId() && !$attributeId) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('eav')->__('Attribute with the same code already exists')); + $this->_initLayoutMessages('adminhtml/session'); + $response->setError(true); + $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml()); + } + + $this->getResponse()->setBody($response->toJson()); + } + + /** + * Filter post data + * + * @param array $data + * @return array + */ + protected function _filterPostData($data) + { + if ($data) { + //labels + $data['frontend_label'] = (array) $data['frontend_label']; + foreach ($data['frontend_label'] as & $value) { + if ($value) { + $value = Mage::helper('eav')->stripTags($value); + } + } + + if (!empty($data['option']) && !empty($data['option']['value']) && is_array($data['option']['value'])) { + foreach ($data['option']['value'] as $key => $values) { + foreach ($values as $storeId => $storeLabel) { + $data['option']['value'][$key][$storeId] = Mage::helper('eav')->stripTags($storeLabel); + } + } + } + } + return $data; + } + + public function saveAction() + { + $data = $this->getRequest()->getPost(); + if ($data) { + /** @var Mage_Admin_Model_Session $session */ + $session = Mage::getSingleton('adminhtml/session'); + + $redirectBack = $this->getRequest()->getParam('back', false); + /** @var Mage_Eav_Model_Entity_Attribute $model */ + $model = Mage::getModel($this->_entityType->getAttributeModel()); + /** @var Mage_Eav_Helper_Data $helper */ + $helper = Mage::helper('eav'); + + $id = $this->getRequest()->getParam('attribute_id'); + + //validate attribute_code + if (isset($data['attribute_code'])) { + $validatorAttrCode = new Zend_Validate_Regex(array('pattern' => '/^(?!event$)[a-z][a-z_0-9]{1,254}$/')); + if (!$validatorAttrCode->isValid($data['attribute_code'])) { + $session->addError( + Mage::helper('eav')->__('Attribute code is invalid. Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter. Do not use "event" for an attribute code.') + ); + $this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true)); + return; + } + } + + + //validate frontend_input + if (isset($data['frontend_input'])) { + /** @var Mage_Eav_Model_Adminhtml_System_Config_Source_Inputtype_Validator $validatorInputType */ + $validatorInputType = Mage::getModel('eav/adminhtml_system_config_source_inputtype_validator'); + if (!$validatorInputType->isValid($data['frontend_input'])) { + foreach ($validatorInputType->getMessages() as $message) { + $session->addError($message); + } + $this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true)); + return; + } + } + + if ($id) { + $model->load($id); + + if (!$model->getId()) { + $session->addError( + Mage::helper('eav')->__('This Attribute no longer exists')); + $this->_redirect('*/*/'); + return; + } + + // entity type check + if ($model->getEntityTypeId() != $this->_entityType->getEntityTypeId()) { + $session->addError( + Mage::helper('eav')->__('This attribute cannot be updated.')); + $session->setAttributeData($data); + $this->_redirect('*/*/'); + return; + } + + $data['backend_model'] = $model->getBackendModel(); + $data['attribute_code'] = $model->getAttributeCode(); + $data['is_user_defined'] = $model->getIsUserDefined(); + $data['frontend_input'] = $model->getFrontendInput(); + } else { + /** + * @todo add to helper and specify all relations for properties + */ + $data['source_model'] = $helper->getAttributeSourceModelByInputType($data['frontend_input']); + $data['backend_model'] = $helper->getAttributeBackendModelByInputType($data['frontend_input']); + } + + if (is_null($model->getIsUserDefined()) || $model->getIsUserDefined() != 0) { + $data['backend_type'] = $model->getBackendTypeByInput($data['frontend_input']); + } + + $defaultValueField = $model->getDefaultValueByInput($data['frontend_input']); + if ($defaultValueField) { + $data['default_value'] = $this->getRequest()->getParam($defaultValueField); + } + + if ($model) { + $data['entity_type_id'] = $model->getEntityTypeId(); + } + + //filter + $data = $this->_filterPostData($data); + $model->addData($data); + + if (!$id) { + $model->setEntityTypeId($this->_entityType->getEntityTypeId()); + $model->setIsUserDefined(1); + } + + + if ($this->getRequest()->getParam('set') && $this->getRequest()->getParam('group')) { + // For creating attribute on page we need specify attribute set and group + $model->setAttributeSetId($this->getRequest()->getParam('set')); + $model->setAttributeGroupId($this->getRequest()->getParam('group')); + } + + Mage::dispatchEvent( + "adminhtml_{$this->_entityCode}_attribute_edit_prepare_save", + array('object' => $model, 'request' => $this->getRequest()) + ); + + try { + $model->save(); + $session->addSuccess( + Mage::helper('eav')->__('The attribute has been saved.')); + + /** + * Clear translation cache because attribute labels are stored in translation + */ + Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG)); + $session->setAttributeData(false); + if ($redirectBack) { + $this->_redirect('*/*/edit', array('attribute_id' => $model->getId(),'_current'=>true)); + } else { + $this->_redirect('*/*/', array()); + } + return; + } catch (Exception $e) { + $session->addError($e->getMessage()); + $session->setAttributeData($data); + $this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true)); + return; + } + } + $this->_redirect('*/*/'); + } + + public function deleteAction() + { + if ($id = $this->getRequest()->getParam('attribute_id')) { + $model = Mage::getModel($this->_entityType->getAttributeModel()); + + // entity type check + $model->load($id); + if ($model->getEntityTypeId() != $this->_entityType->getEntityTypeId() || !$model->getIsUserDefined()) { + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('eav')->__('This attribute cannot be deleted.')); + $this->_redirect('*/*/'); + return; + } + + try { + $model->delete(); + Mage::getSingleton('adminhtml/session')->addSuccess( + Mage::helper('eav')->__('The attribute has been deleted.')); + $this->_redirect('*/*/'); + return; + } catch (Exception $e) { + Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); + $this->_redirect('*/*/edit', array('attribute_id' => $this->getRequest()->getParam('attribute_id'))); + return; + } + } + Mage::getSingleton('adminhtml/session')->addError( + Mage::helper('eav')->__('Unable to find an attribute to delete.')); + $this->_redirect('*/*/'); + } + +} diff --git a/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php b/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php new file mode 100644 index 00000000000..d9aaebd0fe5 --- /dev/null +++ b/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php @@ -0,0 +1,195 @@ + + */ + +abstract class Mage_Eav_Controller_Adminhtml_Set_Abstract extends Mage_Adminhtml_Controller_Action +{ + + /** @var string $_entityCode */ + protected $_entityCode; + + /** @var Mage_Eav_Model_Entity_Type $_entityType */ + protected $_entityType; + + /** + * Controller predispatch method + * + * @return Mage_Adminhtml_Controller_Action + */ + public function preDispatch() + { + $this->_setForcedFormKeyActions('delete'); + $this->_entityType = Mage::getModel('eav/entity')->setType($this->_entityCode)->getEntityType(); + if (!Mage::registry('entity_type')) { + Mage::register('entity_type', $this->_entityType); + } + return parent::preDispatch(); + } + + protected function _initAction() + { + return $this->loadLayout(); + } + + public function indexAction() + { + $this->_initAction() + ->_addContent($this->getLayout()->createBlock('eav/adminhtml_attribute_set')) + ->renderLayout(); + } + + public function editAction() + { + $attributeSet = Mage::getModel('eav/entity_attribute_set') + ->load($this->getRequest()->getParam('id')); + + if (!$attributeSet->getId()) { + $this->_redirect('*/*/index'); + return; + } + + Mage::register('current_attribute_set', $attributeSet); + + $this->_initAction() + ->_title($attributeSet->getId() ? $attributeSet->getAttributeSetName() : $this->__('New Set')) + ->_addContent($this->getLayout()->createBlock('eav/adminhtml_attribute_set_main')); + + $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); + + $this->renderLayout(); + } + + public function setGridAction() + { + $this->getResponse()->setBody( + $this->getLayout() + ->createBlock('eav/adminhtml_attribute_set_grid') + ->toHtml()); + } + + /** + * Save attribute set action + * + * [POST] Create attribute set from another set and redirect to edit page + * [AJAX] Save attribute set data + * + */ + public function saveAction() + { + $entityTypeId = $this->_entityType->getEntityTypeId(); + $hasError = false; + $attributeSetId = $this->getRequest()->getParam('id', false); + $isNewSet = $this->getRequest()->getParam('gotoEdit', false) == '1'; + + /** @var Mage_Eav_Model_Entity_Attribute_Set $model */ + $model = Mage::getModel('eav/entity_attribute_set') + ->setEntityTypeId($entityTypeId); + + /** @var Mage_Eav_Helper_Data $helper */ + $helper = Mage::helper('eav'); + + try { + if ($isNewSet) { + //filter html tags + $name = $helper->stripTags($this->getRequest()->getParam('attribute_set_name')); + $model->setAttributeSetName(trim($name)); + } else { + if ($attributeSetId) { + $model->load($attributeSetId); + } + if (!$model->getId()) { + Mage::throwException(Mage::helper('eav')->__('This attribute set no longer exists.')); + } + $data = Mage::helper('core')->jsonDecode($this->getRequest()->getPost('data')); + + //filter html tags + $data['attribute_set_name'] = $helper->stripTags($data['attribute_set_name']); + + $model->organizeData($data); + } + + $model->validate(); + if ($isNewSet) { + $model->save(); + $model->initFromSkeleton($this->getRequest()->getParam('skeleton_set')); + } + $model->save(); + $this->_getSession()->addSuccess(Mage::helper('eav')->__('The attribute set has been saved.')); + } catch (Mage_Core_Exception $e) { + $this->_getSession()->addError($e->getMessage()); + $hasError = true; + } catch (Exception $e) { + $this->_getSession()->addException($e, + Mage::helper('eav')->__('An error occurred while saving the attribute set.')); + $hasError = true; + } + + if ($isNewSet) { + if ($hasError) { + $this->_redirect('*/*/add'); + } else { + $this->_redirect('*/*/edit', array('id' => $model->getId())); + } + } else { + $response = array(); + if ($hasError) { + $this->_initLayoutMessages('adminhtml/session'); + $response['error'] = 1; + $response['message'] = $this->getLayout()->getMessagesBlock()->getGroupedHtml(); + } else { + $response['error'] = 0; + $response['url'] = $this->getUrl('*/*/'); + } + $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response)); + } + } + + public function addAction() + { + $this->_initAction() + ->_title($this->__('New Set')) + ->_addContent($this->getLayout()->createBlock('eav/adminhtml_attribute_set_toolbar_add')) + ->renderLayout(); + } + + public function deleteAction() + { + $setId = $this->getRequest()->getParam('id'); + try { + Mage::getModel('eav/entity_attribute_set') + ->setId($setId) + ->delete(); + + $this->_getSession()->addSuccess($this->__('The attribute set has been removed.')); + $this->getResponse()->setRedirect($this->getUrl('*/*/')); + } catch (Exception $e) { + $this->_getSession()->addError($this->__('An error occurred while deleting this set.')); + $this->_redirectReferer(); + } + } + +} diff --git a/app/code/core/Mage/Eav/Helper/Data.php b/app/code/core/Mage/Eav/Helper/Data.php index 60b473996a1..0bc2394ae7d 100644 --- a/app/code/core/Mage/Eav/Helper/Data.php +++ b/app/code/core/Mage/Eav/Helper/Data.php @@ -137,4 +137,81 @@ public function getInputTypesValidatorData() { return Mage::getStoreConfig(self::XML_PATH_VALIDATOR_DATA_INPUT_TYPES); } + + /** + * Return information array of attribute input types + * Only a small number of settings returned, so we won't break anything in current dataflow + * As soon as development process goes on we need to add there all possible settings + * + * @param string $inputType + * @return array + */ + public function getAttributeInputTypes($inputType = null) + { + /** + * @todo specify there all relations for properties depending on input type + */ + $inputTypes = array( + 'multiselect' => array( + 'backend_model' => 'eav/entity_attribute_backend_array' + ), + 'boolean' => array( + 'source_model' => 'eav/entity_attribute_source_boolean' + ) + ); + + if (is_null($inputType)) { + return $inputTypes; + } elseif (isset($inputTypes[$inputType])) { + return $inputTypes[$inputType]; + } + return array(); + } + + /** + * Return default attribute backend model by input type + * + * @param string $inputType + * @return string|null + */ + public function getAttributeBackendModelByInputType($inputType) + { + $inputTypes = $this->getAttributeInputTypes(); + if (!empty($inputTypes[$inputType]['backend_model'])) { + return $inputTypes[$inputType]['backend_model']; + } + return null; + } + + /** + * Return default attribute source model by input type + * + * @param string $inputType + * @return string|null + */ + public function getAttributeSourceModelByInputType($inputType) + { + $inputTypes = $this->getAttributeInputTypes(); + if (!empty($inputTypes[$inputType]['source_model'])) { + return $inputTypes[$inputType]['source_model']; + } + return null; + } + + /** + * Return entity code formatted for humans + * + * @param Mage_Eav_Model_Entity_Type|string $entityTypeCode + * @return string + */ + public function formatTypeCode($entityTypeCode) + { + if ($entityTypeCode instanceof Mage_Eav_Model_Entity_Type) { + $entityTypeCode = $entityTypeCode->getEntityTypeCode(); + } + if (!is_string($entityTypeCode)) { + $entityTypeCode = ''; + } + return ucwords(str_replace('_', ' ', $entityTypeCode)); + } } diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute.php b/app/code/core/Mage/Eav/Model/Entity/Attribute.php index 37d95ec4ac9..6577a2f7b8c 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute.php +++ b/app/code/core/Mage/Eav/Model/Entity/Attribute.php @@ -40,6 +40,10 @@ */ class Mage_Eav_Model_Entity_Attribute extends Mage_Eav_Model_Entity_Attribute_Abstract { + const SCOPE_STORE = 0; + const SCOPE_GLOBAL = 1; + const SCOPE_WEBSITE = 2; + /** * Prefix of model events names * diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute.php b/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute.php index 4e317775535..ba52fe5091a 100644 --- a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute.php +++ b/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute.php @@ -152,7 +152,7 @@ public function deleteEntity(Mage_Core_Model_Abstract $object) /** * Validate attribute data before save * - * @param Mage_Catalog_Model_Resource_Eav_Attribute $object + * @param Mage_Eav_Model_Entity_Attribute $object * @inheritDoc */ protected function _beforeSave(Mage_Core_Model_Abstract $object) @@ -170,7 +170,7 @@ protected function _beforeSave(Mage_Core_Model_Abstract $object) * @todo need use default source model of entity type !!! */ if (!$object->getId()) { - if ($object->getFrontendInput() == 'select') { + if ($object->getFrontendInput() == 'select' || $object->getFrontendInput() == 'multiselect') { $object->setSourceModel('eav/entity_attribute_source_table'); } } diff --git a/app/code/core/Mage/Eav/etc/config.xml b/app/code/core/Mage/Eav/etc/config.xml index 8ca3c5686c1..2431941df60 100644 --- a/app/code/core/Mage/Eav/etc/config.xml +++ b/app/code/core/Mage/Eav/etc/config.xml @@ -94,6 +94,11 @@ + + + Mage_Eav_Block + + diff --git a/app/design/adminhtml/default/default/template/eav/attribute/js.phtml b/app/design/adminhtml/default/default/template/eav/attribute/js.phtml new file mode 100644 index 00000000000..4f32178b018 --- /dev/null +++ b/app/design/adminhtml/default/default/template/eav/attribute/js.phtml @@ -0,0 +1,174 @@ + + diff --git a/app/design/adminhtml/default/default/template/eav/attribute/set/main.phtml b/app/design/adminhtml/default/default/template/eav/attribute/set/main.phtml new file mode 100644 index 00000000000..9fee7cf5590 --- /dev/null +++ b/app/design/adminhtml/default/default/template/eav/attribute/set/main.phtml @@ -0,0 +1,450 @@ + +
+ + + + + +

escapeHtml($this->_getHeader()) ?>

+ getBackButtonHtml() ?> + getResetButtonHtml() ?> + getDeleteButtonHtml() ?> + getSaveButtonHtml() ?> +
+
+ + + + + + +
+ getSetFormHtml() ?> + +
+ + + + + + +

__('Groups') ?>

+
+ + getIsReadOnly()): ?> +

getAddGroupButton() ?> getDeleteGroupButton() ?>

+

__('Double click on a group to rename it') ?>

+ + + getSetsFilterHtml() ?> + getGroupTreeHtml() ?> +
+
+ + + + + + +

__('Unassigned Attributes') ?>

+
+
+ +
diff --git a/app/design/adminhtml/default/default/template/eav/attribute/set/main/tree/attribute.phtml b/app/design/adminhtml/default/default/template/eav/attribute/set/main/tree/attribute.phtml new file mode 100644 index 00000000000..807cf7a9254 --- /dev/null +++ b/app/design/adminhtml/default/default/template/eav/attribute/set/main/tree/attribute.phtml @@ -0,0 +1,20 @@ + diff --git a/app/design/adminhtml/default/default/template/eav/attribute/set/main/tree/group.phtml b/app/design/adminhtml/default/default/template/eav/attribute/set/main/tree/group.phtml new file mode 100644 index 00000000000..b2c24824665 --- /dev/null +++ b/app/design/adminhtml/default/default/template/eav/attribute/set/main/tree/group.phtml @@ -0,0 +1,21 @@ + +
diff --git a/app/design/adminhtml/default/default/template/eav/attribute/set/toolbar/add.phtml b/app/design/adminhtml/default/default/template/eav/attribute/set/toolbar/add.phtml new file mode 100644 index 00000000000..2b7a3b33d82 --- /dev/null +++ b/app/design/adminhtml/default/default/template/eav/attribute/set/toolbar/add.phtml @@ -0,0 +1,35 @@ + +
+ + + + + +

_getHeader() ?>

+ getBackButtonHtml() ?> + getSaveButtonHtml() ?> +
+
+getFormHtml() ?> + diff --git a/app/locale/en_US/Mage_Eav.csv b/app/locale/en_US/Mage_Eav.csv index 71006030106..ade599ebc9c 100644 --- a/app/locale/en_US/Mage_Eav.csv +++ b/app/locale/en_US/Mage_Eav.csv @@ -46,6 +46,7 @@ "Attribute with the same code","Attribute with the same code" "Can't create table: %s","Can't create table: %s" "Catalog Input Type for Store Owner","Catalog Input Type for Store Owner" +"Input Type for Store Owner","Input Type for Store Owner" "Current module EAV entity is undefined","Current module EAV entity is undefined" "Current module pathname is undefined","Current module pathname is undefined" "Data integrity: No header row found for attribute","Data integrity: No header row found for attribute" @@ -102,6 +103,7 @@ "No options found in config node %s","No options found in config node %s" "None","None" "Not shared with other products","Not shared with other products" +"Not shared with other %s","Not shared with other %s" "Problem loading the collection, aborting. Error: %s","Problem loading the collection, aborting. Error: %s" "Problem saving the collection, aborting. Error: %s","Problem saving the collection, aborting. Error: %s" "Required","Required" @@ -117,6 +119,7 @@ "URL","URL" "Unique Value","Unique Value" "Unique Value (not shared with other products)","Unique Value (not shared with other products)" +"Unique Value (not shared with other %s)","Unique Value (not shared with other products)" "Unknown parameter","Unknown parameter" "Values Required","Values Required" "Wrong attribute group ID","Wrong attribute group ID" @@ -125,3 +128,12 @@ "Wrong type definition for %s","Wrong type definition for %s" "Yes","Yes" "Yes/No","Yes/No" +"Edit Attribute","Edit Attribute" +"The attribute has been deleted.","The attribute has been deleted." +"The attribute has been saved.","The attribute has been saved." +"Manage %s Attributes","Manage %s Attributes" +"Manage %s Attribute Sets","Manage %s Attribute Sets" +"Edit %s Attribute ""%s""","Edit %s Attribute ""%s""" +"New %s Attribute","New %s Attribute" +"All %s of this set will be deleted! Are you sure you want to delete this attribute set?","All %s of this set will be deleted! Are you sure you want to delete this attribute set?" +"All items of this set will be deleted! Are you sure you want to delete this attribute set?","All items of this set will be deleted! Are you sure you want to delete this attribute set?" diff --git a/skin/adminhtml/default/default/boxes.css b/skin/adminhtml/default/default/boxes.css index aec05a60002..6ffedde5354 100644 --- a/skin/adminhtml/default/default/boxes.css +++ b/skin/adminhtml/default/default/boxes.css @@ -709,7 +709,9 @@ div.autocomplete ul li { padding:.5em .7em; min-height:32px; cursor:pointer; tex .head-promo-quote, .head-promo-catalog { background-image:url(images/fam_money.gif); padding-left:22px; } .head-categories { background-image:url(images/fam_folder_database.gif); padding-left:20px; color:#253033 !important; } +.head-eav-attribute, .head-catalog-product-attribute { background-image:url(images/fam_rainbow.gif); padding-left:24px; } +.head-eav-attribute-sets, .head-product-attribute-sets { background-image:url(images/fam_folder_palette.gif); padding-left:23px; } .head-cms-page, .head-cms-block, .head-adminhtml-widget-instance { background-image:url(images/application_view_tile.gif); padding-left:22px; } From d34bde948386234c776537f76a21edb0ad1dd364 Mon Sep 17 00:00:00 2001 From: Justin Beaty Date: Wed, 3 Aug 2022 07:38:55 -0700 Subject: [PATCH 02/22] Mage_Eav: Add generic form element renderers --- .../Block/Adminhtml/Helper/Form/Boolean.php | 44 +++++++ .../core/Mage/Eav/Block/Widget/Abstract.php | 90 +++++++++++++ .../core/Mage/Eav/Block/Widget/Boolean.php | 54 ++++++++ app/code/core/Mage/Eav/Block/Widget/Date.php | 124 ++++++++++++++++++ .../Mage/Eav/Block/Widget/Multiselect.php | 58 ++++++++ .../core/Mage/Eav/Block/Widget/Select.php | 48 +++++++ app/code/core/Mage/Eav/Block/Widget/Text.php | 38 ++++++ .../core/Mage/Eav/Block/Widget/Textarea.php | 38 ++++++ .../default/template/eav/widget/boolean.phtml | 32 +++++ .../default/template/eav/widget/date.phtml | 58 ++++++++ .../template/eav/widget/multiselect.phtml | 32 +++++ .../default/template/eav/widget/select.phtml | 32 +++++ .../default/template/eav/widget/text.phtml | 26 ++++ .../template/eav/widget/textarea.phtml | 26 ++++ js/varien/js.js | 15 +++ skin/frontend/rwd/default/scss/_core.scss | 1 + .../rwd/default/scss/module/_eav.scss | 38 ++++++ 17 files changed, 754 insertions(+) create mode 100644 app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php create mode 100644 app/code/core/Mage/Eav/Block/Widget/Abstract.php create mode 100644 app/code/core/Mage/Eav/Block/Widget/Boolean.php create mode 100644 app/code/core/Mage/Eav/Block/Widget/Date.php create mode 100644 app/code/core/Mage/Eav/Block/Widget/Multiselect.php create mode 100644 app/code/core/Mage/Eav/Block/Widget/Select.php create mode 100644 app/code/core/Mage/Eav/Block/Widget/Text.php create mode 100644 app/code/core/Mage/Eav/Block/Widget/Textarea.php create mode 100644 app/design/frontend/base/default/template/eav/widget/boolean.phtml create mode 100644 app/design/frontend/base/default/template/eav/widget/date.phtml create mode 100644 app/design/frontend/base/default/template/eav/widget/multiselect.phtml create mode 100644 app/design/frontend/base/default/template/eav/widget/select.phtml create mode 100644 app/design/frontend/base/default/template/eav/widget/text.phtml create mode 100644 app/design/frontend/base/default/template/eav/widget/textarea.phtml create mode 100644 skin/frontend/rwd/default/scss/module/_eav.scss diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php b/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php new file mode 100644 index 00000000000..508eb2fba1b --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php @@ -0,0 +1,44 @@ + + */ +class Mage_Eav_Block_Adminhtml_Helper_Form_Boolean extends Varien_Data_Form_Element_Select +{ + public function __construct($attributes=array()) + { + parent::__construct($attributes); + $this->setValues(array( + array( + 'label' => Mage::helper('eav')->__('No'), + 'value' => 0, + ), + array( + 'label' => Mage::helper('eav')->__('Yes'), + 'value' => 1, + ), + )); + } +} diff --git a/app/code/core/Mage/Eav/Block/Widget/Abstract.php b/app/code/core/Mage/Eav/Block/Widget/Abstract.php new file mode 100644 index 00000000000..54c824a876b --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Widget/Abstract.php @@ -0,0 +1,90 @@ +getAttribute()->getIsVisible(); + } + + /** + * Check if attribute marked as required + * + * @return bool + */ + public function isRequired() + { + return (bool)$this->getAttribute()->getIsRequired(); + } + + /** + * @return string + */ + public function getFieldIdFormat() + { + if (!$this->hasData('field_id_format')) { + $this->setData('field_id_format', '%s'); + } + return $this->getData('field_id_format'); + } + + /** + * @return string + */ + public function getFieldNameFormat() + { + if (!$this->hasData('field_name_format')) { + $this->setData('field_name_format', '%s'); + } + return $this->getData('field_name_format'); + } + + /** + * @param string $field + * @return string + */ + public function getFieldId($field) + { + return sprintf($this->getFieldIdFormat(), $field); + } + + /** + * @param string $field + * @return string + */ + public function getFieldName($field) + { + return sprintf($this->getFieldNameFormat(), $field); + } +} diff --git a/app/code/core/Mage/Eav/Block/Widget/Boolean.php b/app/code/core/Mage/Eav/Block/Widget/Boolean.php new file mode 100644 index 00000000000..cb0973cd886 --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Widget/Boolean.php @@ -0,0 +1,54 @@ + + */ +class Mage_Eav_Block_Widget_Boolean extends Mage_Eav_Block_Widget_Abstract +{ + /** + * Initialize block + */ + public function _construct() + { + parent::_construct(); + $this->setTemplate('eav/widget/boolean.phtml'); + } + + /** + * Get select options + * + * @return array + */ + public function getOptions() + { + $options = array( + array('value' => '', 'label' => Mage::helper('eav')->__('')), + array('value' => '1', 'label' => Mage::helper('eav')->__('Yes')), + array('value' => '0', 'label' => Mage::helper('eav')->__('No')) + ); + + return $options; + } +} diff --git a/app/code/core/Mage/Eav/Block/Widget/Date.php b/app/code/core/Mage/Eav/Block/Widget/Date.php new file mode 100644 index 00000000000..11a49172c1c --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Widget/Date.php @@ -0,0 +1,124 @@ +setTemplate('eav/widget/date.phtml'); + } + + /** + * @param string $date + * @return $this + */ + public function setDate($date) + { + $this->setTime($date ? strtotime($date) : false); + $this->setData('date', $date); + return $this; + } + + /** + * @return false|string + */ + public function getDay() + { + return $this->getTime() ? date('d', $this->getTime()) : ''; + } + + /** + * @return false|string + */ + public function getMonth() + { + return $this->getTime() ? date('m', $this->getTime()) : ''; + } + + /** + * @return false|string + */ + public function getYear() + { + return $this->getTime() ? date('Y', $this->getTime()) : ''; + } + + /** + * Returns format which will be applied for date in javascript + * + * @return string + */ + public function getDateFormat() + { + return Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); + } + + /** + * Add date input html + * + * @param string $code + * @param string $html + */ + public function setDateInput($code, $html) + { + $this->_dateInputs[$code] = $html; + } + + /** + * Sort date inputs by dateformat order of current locale + * + * @return string + */ + public function getSortedDateInputs() + { + $strtr = array( + '%b' => '%1$s', + '%B' => '%1$s', + '%m' => '%1$s', + '%d' => '%2$s', + '%e' => '%2$s', + '%Y' => '%3$s', + '%y' => '%3$s' + ); + + $dateFormat = preg_replace('/[^\%\w]/', '\\1', $this->getDateFormat()); + + return sprintf( + strtr($dateFormat, $strtr), + $this->_dateInputs['m'], + $this->_dateInputs['d'], + $this->_dateInputs['y'] + ); + } +} diff --git a/app/code/core/Mage/Eav/Block/Widget/Multiselect.php b/app/code/core/Mage/Eav/Block/Widget/Multiselect.php new file mode 100644 index 00000000000..329216986fe --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Widget/Multiselect.php @@ -0,0 +1,58 @@ + + */ +class Mage_Eav_Block_Widget_Multiselect extends Mage_Eav_Block_Widget_Abstract +{ + /** + * Initialize block + */ + public function _construct() + { + parent::_construct(); + $this->setTemplate('eav/widget/multiselect.phtml'); + } + + /** + * Get select element extra attributes + * + * @return string + */ + public function getFieldParams() + { + return 'multiple'; + } + + /** + * Get select options + * + * @return array + */ + public function getOptions() + { + return $this->getAttribute()->getSource()->getAllOptions(false); + } +} diff --git a/app/code/core/Mage/Eav/Block/Widget/Select.php b/app/code/core/Mage/Eav/Block/Widget/Select.php new file mode 100644 index 00000000000..b97509537e9 --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Widget/Select.php @@ -0,0 +1,48 @@ + + */ +class Mage_Eav_Block_Widget_Select extends Mage_Eav_Block_Widget_Abstract +{ + /** + * Initialize block + */ + public function _construct() + { + parent::_construct(); + $this->setTemplate('eav/widget/select.phtml'); + } + + /** + * Get select options + * + * @return array + */ + public function getOptions() + { + return $this->getAttribute()->getSource()->getAllOptions(); + } +} diff --git a/app/code/core/Mage/Eav/Block/Widget/Text.php b/app/code/core/Mage/Eav/Block/Widget/Text.php new file mode 100644 index 00000000000..4402d6645c3 --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Widget/Text.php @@ -0,0 +1,38 @@ + + */ +class Mage_Eav_Block_Widget_Text extends Mage_Eav_Block_Widget_Abstract +{ + /** + * Initialize block + */ + public function _construct() + { + parent::_construct(); + $this->setTemplate('eav/widget/text.phtml'); + } +} diff --git a/app/code/core/Mage/Eav/Block/Widget/Textarea.php b/app/code/core/Mage/Eav/Block/Widget/Textarea.php new file mode 100644 index 00000000000..5989f5e8409 --- /dev/null +++ b/app/code/core/Mage/Eav/Block/Widget/Textarea.php @@ -0,0 +1,38 @@ + + */ +class Mage_Eav_Block_Widget_Textarea extends Mage_Eav_Block_Widget_Abstract +{ + /** + * Initialize block + */ + public function _construct() + { + parent::_construct(); + $this->setTemplate('eav/widget/textarea.phtml'); + } +} diff --git a/app/design/frontend/base/default/template/eav/widget/boolean.phtml b/app/design/frontend/base/default/template/eav/widget/boolean.phtml new file mode 100644 index 00000000000..9fdff14968f --- /dev/null +++ b/app/design/frontend/base/default/template/eav/widget/boolean.phtml @@ -0,0 +1,32 @@ + +getAttribute() ?> +getAttributeCode() ?> + +
+ +
diff --git a/app/design/frontend/base/default/template/eav/widget/date.phtml b/app/design/frontend/base/default/template/eav/widget/date.phtml new file mode 100644 index 00000000000..1716f9315a5 --- /dev/null +++ b/app/design/frontend/base/default/template/eav/widget/date.phtml @@ -0,0 +1,58 @@ + +getAttribute() ?> +getAttributeCode() ?> + +
+setDateInput('d', + '
+ getFieldParams() . ' /> + +
' + ); + + $this->setDateInput('m', + '
+ getFieldParams() . ' /> + +
' + ); + + $this->setDateInput('y', + '
+ getFieldParams() . ' /> + +
' + ); +?> + getSortedDateInputs() ?> + + + +
+ diff --git a/app/design/frontend/base/default/template/eav/widget/multiselect.phtml b/app/design/frontend/base/default/template/eav/widget/multiselect.phtml new file mode 100644 index 00000000000..16bb71bda04 --- /dev/null +++ b/app/design/frontend/base/default/template/eav/widget/multiselect.phtml @@ -0,0 +1,32 @@ + +getAttribute() ?> +getAttributeCode() ?> + +
+ +
diff --git a/app/design/frontend/base/default/template/eav/widget/select.phtml b/app/design/frontend/base/default/template/eav/widget/select.phtml new file mode 100644 index 00000000000..9fdff14968f --- /dev/null +++ b/app/design/frontend/base/default/template/eav/widget/select.phtml @@ -0,0 +1,32 @@ + +getAttribute() ?> +getAttributeCode() ?> + +
+ +
diff --git a/app/design/frontend/base/default/template/eav/widget/text.phtml b/app/design/frontend/base/default/template/eav/widget/text.phtml new file mode 100644 index 00000000000..1e85785844c --- /dev/null +++ b/app/design/frontend/base/default/template/eav/widget/text.phtml @@ -0,0 +1,26 @@ + +getAttribute() ?> +getAttributeCode() ?> + +
+ getFieldParams() ?> /> +
diff --git a/app/design/frontend/base/default/template/eav/widget/textarea.phtml b/app/design/frontend/base/default/template/eav/widget/textarea.phtml new file mode 100644 index 00000000000..803cb98d0d9 --- /dev/null +++ b/app/design/frontend/base/default/template/eav/widget/textarea.phtml @@ -0,0 +1,26 @@ + +getAttribute() ?> +getAttributeCode() ?> + +
+ +
diff --git a/js/varien/js.js b/js/varien/js.js index 3edf05b6113..31f41000f52 100644 --- a/js/varien/js.js +++ b/js/varien/js.js @@ -531,6 +531,21 @@ Varien.DateElement.prototype = { } }; +Varien.DateElementHelper = Class.create(); +Varien.DateElementHelper.prototype = { + initialize: function(selector, required, format, classPrefix="date") { + var el = $$(selector)[0]; + var container = {}; + container.day = Element.select(el, '.' + classPrefix + '-day input')[0]; + container.month = Element.select(el, '.' + classPrefix + '-month input')[0]; + container.year = Element.select(el, '.' + classPrefix + '-year input')[0]; + container.full = Element.select(el, '.' + classPrefix + '-full input')[0]; + container.advice = Element.select(el, '.validation-advice')[0]; + + new Varien.DateElement('container', container, required, format); + } +}; + Varien.DOB = Class.create(); Varien.DOB.prototype = { initialize: function(selector, required, format) { diff --git a/skin/frontend/rwd/default/scss/_core.scss b/skin/frontend/rwd/default/scss/_core.scss index 78f4976a16e..a505fd41528 100644 --- a/skin/frontend/rwd/default/scss/_core.scss +++ b/skin/frontend/rwd/default/scss/_core.scss @@ -68,6 +68,7 @@ @import "module/configurableswatches"; @import "module/customer"; @import "module/contacts"; +@import "module/eav"; @import "module/paypal"; @import "module/review"; @import "module/slideshow"; diff --git a/skin/frontend/rwd/default/scss/module/_eav.scss b/skin/frontend/rwd/default/scss/module/_eav.scss new file mode 100644 index 00000000000..88fcc45c4f6 --- /dev/null +++ b/skin/frontend/rwd/default/scss/module/_eav.scss @@ -0,0 +1,38 @@ +// +// OpenMage +// +// NOTICE OF LICENSE +// +// This source file is subject to the Academic Free License (AFL 3.0) +// that is bundled with this package in the file LICENSE_AFL.txt. +// It is also available through the world-wide-web at this URL: +// http://opensource.org/licenses/afl-3.0.php +// If you did not receive a copy of the license and are unable to +// obtain it through the world-wide-web, please send an email +// to license@magento.com so we can send you a copy immediately. +// +// @category design +// @package rwd_default +// @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) +// @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) +// + +/* ============================================ * + * Eav Forms + * ============================================ */ + +.form-list { + .date-dob { + .date-month, + .date-day { + width: 40px; + float: left; + margin-right: $box-spacing; + } + + .date-year { + width: 80px; + float: left; + } + } +} From 80d7f81fdd62a6ea6e283060f7b5735dab43e0b8 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Sat, 29 Jul 2023 23:55:50 +0100 Subject: [PATCH 03/22] phpcs --- .../Mage/Eav/Block/Adminhtml/Attribute.php | 1 - .../Eav/Block/Adminhtml/Attribute/Edit.php | 5 +- .../Block/Adminhtml/Attribute/Edit/Tabs.php | 1 - .../Eav/Block/Adminhtml/Attribute/Set.php | 1 - .../Block/Adminhtml/Attribute/Set/Grid.php | 2 - .../Block/Adminhtml/Attribute/Set/Main.php | 48 +++++++++++------ .../Attribute/Set/Main/Formattribute.php | 36 +++++++------ .../Attribute/Set/Main/Formgroup.php | 51 ++++++++++--------- .../Adminhtml/Attribute/Set/Main/Formset.php | 2 +- .../Adminhtml/Attribute/Set/Toolbar/Add.php | 15 ++++-- .../Adminhtml/Attribute/Abstract.php | 30 ++++++----- .../Eav/Controller/Adminhtml/Set/Abstract.php | 11 ++-- .../core/Mage/Eav/Model/Entity/Attribute.php | 6 +-- 13 files changed, 119 insertions(+), 90 deletions(-) diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute.php index ef4ad4eb69c..64d80115516 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute.php @@ -45,5 +45,4 @@ public function getHeaderCssClass() { return 'icon-head head-eav-attribute'; } - } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php index e56fe46744f..02732989faf 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php @@ -20,7 +20,6 @@ class Mage_Eav_Block_Adminhtml_Attribute_Edit extends Mage_Adminhtml_Block_Widget_Form_Container { - public function __construct() { $this->_objectId = 'attribute_id'; @@ -57,8 +56,7 @@ public function getHeaderText() $frontendLabel = $frontendLabel[0]; } return Mage::helper('eav')->__('Edit %s Attribute "%s"', Mage::helper('eav')->formatTypeCode(Mage::registry('entity_type')), $this->escapeHtml($frontendLabel)); - } - else { + } else { return Mage::helper('eav')->__('New %s Attribute', Mage::helper('eav')->formatTypeCode(Mage::registry('entity_type'))); } } @@ -77,5 +75,4 @@ public function getHeaderCssClass() { return 'icon-head head-eav-attribute'; } - } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tabs.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tabs.php index 76199547619..227fc104b30 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tabs.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tabs.php @@ -47,5 +47,4 @@ protected function _beforeToHtml() return parent::_beforeToHtml(); } - } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set.php index b22883bb32b..c33be700692 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set.php @@ -50,5 +50,4 @@ public function getHeaderCssClass() { return 'icon-head head-eav-attribute-sets'; } - } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php index 4251d08ac89..35176f6db12 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php @@ -27,7 +27,6 @@ */ class Mage_Eav_Block_Adminhtml_Attribute_Set_Grid extends Mage_Adminhtml_Block_Widget_Grid { - public function __construct() { parent::__construct(); @@ -68,5 +67,4 @@ public function getRowUrl($row) { return $this->getUrl('*/*/edit', array('id'=>$row->getAttributeSetId())); } - } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php index 23ccec4bc62..e952b245482 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php @@ -45,47 +45,59 @@ protected function _prepareLayout() { $setId = $this->_getSetId(); - $this->setChild('group_tree', + $this->setChild( + 'group_tree', $this->getLayout()->createBlock('eav/adminhtml_attribute_set_main_tree_group') ); - $this->setChild('edit_set_form', + $this->setChild( + 'edit_set_form', $this->getLayout()->createBlock('eav/adminhtml_attribute_set_main_formset') ); - $this->setChild('delete_group_button', + $this->setChild( + 'delete_group_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( 'label' => Mage::helper('eav')->__('Delete Selected Group'), 'onclick' => 'editSet.submit();', 'class' => 'delete' - ))); + )) + ); - $this->setChild('add_group_button', + $this->setChild( + 'add_group_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( 'label' => Mage::helper('eav')->__('Add New'), 'onclick' => 'editSet.addGroup();', 'class' => 'add' - ))); + )) + ); - $this->setChild('back_button', + $this->setChild( + 'back_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( 'label' => Mage::helper('eav')->__('Back'), 'onclick' => 'setLocation(\''.$this->getUrl('*/*/').'\')', 'class' => 'back' - ))); + )) + ); - $this->setChild('reset_button', + $this->setChild( + 'reset_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( 'label' => Mage::helper('eav')->__('Reset'), 'onclick' => 'window.location.reload()' - ))); + )) + ); - $this->setChild('save_button', + $this->setChild( + 'save_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( 'label' => Mage::helper('eav')->__('Save Attribute Set'), 'onclick' => 'editSet.save();', 'class' => 'save' - ))); + )) + ); if ($entity_type = Mage::registry('entity_type')) { $deleteConfirmMessage = $this->jsQuoteEscape(Mage::helper('eav') @@ -95,18 +107,22 @@ protected function _prepareLayout() ->__('All items of this set will be deleted! Are you sure you want to delete this attribute set?')); } $deleteUrl = $this->getUrlSecure('*/*/delete', array('id' => $setId)); - $this->setChild('delete_button', + $this->setChild( + 'delete_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( 'label' => Mage::helper('eav')->__('Delete Attribute Set'), 'onclick' => 'deleteConfirm(\'' . $deleteConfirmMessage . '\', \'' . $deleteUrl . '\')', 'class' => 'delete' - ))); + )) + ); - $this->setChild('rename_button', + $this->setChild( + 'rename_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( 'label' => Mage::helper('eav')->__('New Set Name'), 'onclick' => 'editSet.rename()' - ))); + )) + ); return parent::_prepareLayout(); } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php index 99ab6c967be..827cd53f042 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php @@ -37,24 +37,28 @@ protected function _prepareForm() $fieldset = $form->addFieldset('set_fieldset', array('legend'=>Mage::helper('eav')->__('Add New Attribute'))); - $fieldset->addField('new_attribute', 'text', - array( - 'label' => Mage::helper('eav')->__('Name'), - 'name' => 'new_attribute', - 'required' => true, - ) + $fieldset->addField( + 'new_attribute', + 'text', + array( + 'label' => Mage::helper('eav')->__('Name'), + 'name' => 'new_attribute', + 'required' => true, + ) ); - $fieldset->addField('submit', 'note', - array( - 'text' => $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData(array( - 'label' => Mage::helper('eav')->__('Add Attribute'), - 'onclick' => 'this.form.submit();', - 'class' => 'add' - )) - ->toHtml(), - ) + $fieldset->addField( + 'submit', + 'note', + array( + 'text' => $this->getLayout()->createBlock('adminhtml/widget_button') + ->setData(array( + 'label' => Mage::helper('eav')->__('Add Attribute'), + 'onclick' => 'this.form.submit();', + 'class' => 'add' + )) + ->toHtml(), + ) ); $form->setUseContainer(true); diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php index dcdf466430f..bb7e230d249 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php @@ -37,32 +37,37 @@ protected function _prepareForm() $fieldset = $form->addFieldset('set_fieldset', array('legend'=>Mage::helper('eav')->__('Add New Group'))); - $fieldset->addField('attribute_group_name', 'text', - array( - 'label' => Mage::helper('eav')->__('Name'), - 'name' => 'attribute_group_name', - 'required' => true, - ) + $fieldset->addField( + 'attribute_group_name', + 'text', + array( + 'label' => Mage::helper('eav')->__('Name'), + 'name' => 'attribute_group_name', + 'required' => true, + ) ); - $fieldset->addField('submit', 'note', - array( - 'text' => $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData(array( - 'label' => Mage::helper('eav')->__('Add Group'), - 'onclick' => 'this.form.submit();', - 'class' => 'add' - )) - ->toHtml(), - ) + $fieldset->addField( + 'submit', + 'note', + array( + 'text' => $this->getLayout()->createBlock('adminhtml/widget_button') + ->setData(array( + 'label' => Mage::helper('eav')->__('Add Group'), + 'onclick' => 'this.form.submit();', + 'class' => 'add' + )) + ->toHtml(), + ) ); - $fieldset->addField('attribute_set_id', 'hidden', - array( - 'name' => 'attribute_set_id', - 'value' => $this->_getSetId(), - ) - + $fieldset->addField( + 'attribute_set_id', + 'hidden', + array( + 'name' => 'attribute_set_id', + 'value' => $this->_getSetId(), + ) ); $form->setUseContainer(true); @@ -74,7 +79,7 @@ protected function _prepareForm() protected function _getSetId() { - return ( intval($this->getRequest()->getParam('id')) > 0 ) + return (intval($this->getRequest()->getParam('id')) > 0) ? intval($this->getRequest()->getParam('id')) : Mage::registry('entity_type')->getDefaultAttributeSetId(); } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php index 301d9ad994e..bbcc709b712 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php @@ -51,7 +51,7 @@ protected function _prepareForm() 'value' => $data->getAttributeSetName() )); - if( !$this->getRequest()->getParam('id', false) ) { + if (!$this->getRequest()->getParam('id', false)) { $fieldset->addField('gotoEdit', 'hidden', array( 'name' => 'gotoEdit', 'value' => '1' diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php index b87f5c3a92c..08756b9f82d 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php @@ -34,22 +34,27 @@ protected function _construct() protected function _prepareLayout() { - $this->setChild('save_button', + $this->setChild( + 'save_button', $this->getLayout()->createBlock('adminhtml/widget_button') ->setData(array( 'label' => Mage::helper('eav')->__('Save Attribute Set'), 'onclick' => 'if (addSet.submit()) disableElements(\'save\');', 'class' => 'save' - ))); - $this->setChild('back_button', + )) + ); + $this->setChild( + 'back_button', $this->getLayout()->createBlock('adminhtml/widget_button') ->setData(array( 'label' => Mage::helper('eav')->__('Back'), 'onclick' => 'setLocation(\''.$this->getUrl('*/*/').'\')', 'class' => 'back' - ))); + )) + ); - $this->setChild('setForm', + $this->setChild( + 'setForm', $this->getLayout()->createBlock('eav/adminhtml_attribute_set_main_formset') ); return parent::_prepareLayout(); diff --git a/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php b/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php index a2818da6254..654e139aa44 100644 --- a/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php +++ b/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php @@ -28,7 +28,6 @@ abstract class Mage_Eav_Controller_Adminhtml_Attribute_Abstract extends Mage_Adminhtml_Controller_Action { - /** @var string $_entityCode */ protected $_entityCode; @@ -77,7 +76,8 @@ public function editAction() if (! $model->getId()) { Mage::getSingleton('adminhtml/session')->addError( - Mage::helper('eav')->__('This attribute no longer exists')); + Mage::helper('eav')->__('This attribute no longer exists') + ); $this->_redirect('*/*/'); return; } @@ -85,7 +85,8 @@ public function editAction() // entity type check if ($model->getEntityTypeId() != $this->_entityType->getEntityTypeId()) { Mage::getSingleton('adminhtml/session')->addError( - Mage::helper('eav')->__('This attribute cannot be edited.')); + Mage::helper('eav')->__('This attribute cannot be edited.') + ); $this->_redirect('*/*/'); return; } @@ -117,7 +118,6 @@ public function editAction() ); $this->renderLayout(); - } public function validateAction() @@ -134,7 +134,8 @@ public function validateAction() if ($attribute->getId() && !$attributeId) { Mage::getSingleton('adminhtml/session')->addError( - Mage::helper('eav')->__('Attribute with the same code already exists')); + Mage::helper('eav')->__('Attribute with the same code already exists') + ); $this->_initLayoutMessages('adminhtml/session'); $response->setError(true); $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml()); @@ -217,7 +218,8 @@ public function saveAction() if (!$model->getId()) { $session->addError( - Mage::helper('eav')->__('This Attribute no longer exists')); + Mage::helper('eav')->__('This Attribute no longer exists') + ); $this->_redirect('*/*/'); return; } @@ -225,7 +227,8 @@ public function saveAction() // entity type check if ($model->getEntityTypeId() != $this->_entityType->getEntityTypeId()) { $session->addError( - Mage::helper('eav')->__('This attribute cannot be updated.')); + Mage::helper('eav')->__('This attribute cannot be updated.') + ); $session->setAttributeData($data); $this->_redirect('*/*/'); return; @@ -280,7 +283,8 @@ public function saveAction() try { $model->save(); $session->addSuccess( - Mage::helper('eav')->__('The attribute has been saved.')); + Mage::helper('eav')->__('The attribute has been saved.') + ); /** * Clear translation cache because attribute labels are stored in translation @@ -312,7 +316,8 @@ public function deleteAction() $model->load($id); if ($model->getEntityTypeId() != $this->_entityType->getEntityTypeId() || !$model->getIsUserDefined()) { Mage::getSingleton('adminhtml/session')->addError( - Mage::helper('eav')->__('This attribute cannot be deleted.')); + Mage::helper('eav')->__('This attribute cannot be deleted.') + ); $this->_redirect('*/*/'); return; } @@ -320,7 +325,8 @@ public function deleteAction() try { $model->delete(); Mage::getSingleton('adminhtml/session')->addSuccess( - Mage::helper('eav')->__('The attribute has been deleted.')); + Mage::helper('eav')->__('The attribute has been deleted.') + ); $this->_redirect('*/*/'); return; } catch (Exception $e) { @@ -330,8 +336,8 @@ public function deleteAction() } } Mage::getSingleton('adminhtml/session')->addError( - Mage::helper('eav')->__('Unable to find an attribute to delete.')); + Mage::helper('eav')->__('Unable to find an attribute to delete.') + ); $this->_redirect('*/*/'); } - } diff --git a/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php b/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php index d9aaebd0fe5..62c4e51b349 100644 --- a/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php +++ b/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php @@ -28,7 +28,6 @@ abstract class Mage_Eav_Controller_Adminhtml_Set_Abstract extends Mage_Adminhtml_Controller_Action { - /** @var string $_entityCode */ protected $_entityCode; @@ -88,7 +87,8 @@ public function setGridAction() $this->getResponse()->setBody( $this->getLayout() ->createBlock('eav/adminhtml_attribute_set_grid') - ->toHtml()); + ->toHtml() + ); } /** @@ -143,8 +143,10 @@ public function saveAction() $this->_getSession()->addError($e->getMessage()); $hasError = true; } catch (Exception $e) { - $this->_getSession()->addException($e, - Mage::helper('eav')->__('An error occurred while saving the attribute set.')); + $this->_getSession()->addException( + $e, + Mage::helper('eav')->__('An error occurred while saving the attribute set.') + ); $hasError = true; } @@ -191,5 +193,4 @@ public function deleteAction() $this->_redirectReferer(); } } - } diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute.php b/app/code/core/Mage/Eav/Model/Entity/Attribute.php index 83fd211319c..6f8773c6bea 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute.php +++ b/app/code/core/Mage/Eav/Model/Entity/Attribute.php @@ -34,9 +34,9 @@ */ class Mage_Eav_Model_Entity_Attribute extends Mage_Eav_Model_Entity_Attribute_Abstract { - const SCOPE_STORE = 0; - const SCOPE_GLOBAL = 1; - const SCOPE_WEBSITE = 2; + public const SCOPE_STORE = 0; + public const SCOPE_GLOBAL = 1; + public const SCOPE_WEBSITE = 2; /** * Prefix of model events names From 02937624a3aa608a3963b9ae5efa2dd482093595 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Fri, 26 Jan 2024 14:46:38 +0000 Subject: [PATCH 04/22] PHPStan --- .../Mage/Eav/Block/Adminhtml/Attribute/Edit.php | 4 ++-- .../Eav/Block/Adminhtml/Attribute/Set/Grid.php | 14 ++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php index 02732989faf..60e56f05bf1 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php @@ -30,11 +30,11 @@ public function __construct() $this->_addButton( 'save_and_edit_button', - array( + [ 'label' => Mage::helper('eav')->__('Save and Continue Edit'), 'onclick' => 'saveAndContinueEdit()', 'class' => 'save' - ), + ], 100 ); diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php index 35176f6db12..60e41b3911f 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php @@ -47,20 +47,14 @@ protected function _prepareCollection() protected function _prepareColumns() { - /*$this->addColumn('set_id', array( - 'header' => Mage::helper('eav')->__('ID'), - 'align' => 'right', - 'sortable' => true, - 'width' => '50px', - 'index' => 'attribute_set_id', - ));*/ - - $this->addColumn('set_name', array( + $this->addColumn('set_name', [ 'header' => Mage::helper('eav')->__('Set Name'), 'align' => 'left', 'sortable' => true, 'index' => 'attribute_set_name', - )); + ]); + + return $this; } public function getRowUrl($row) From 9dd0a4eead35534f7906a4c3895a64a4e6620fbb Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Fri, 26 Jan 2024 14:48:50 +0000 Subject: [PATCH 05/22] slightly better whitespace --- app/code/core/Mage/Eav/Model/Entity/Attribute.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute.php b/app/code/core/Mage/Eav/Model/Entity/Attribute.php index 6f8773c6bea..d2088472c58 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute.php +++ b/app/code/core/Mage/Eav/Model/Entity/Attribute.php @@ -34,18 +34,18 @@ */ class Mage_Eav_Model_Entity_Attribute extends Mage_Eav_Model_Entity_Attribute_Abstract { - public const SCOPE_STORE = 0; - public const SCOPE_GLOBAL = 1; - public const SCOPE_WEBSITE = 2; + public const SCOPE_STORE = 0; + public const SCOPE_GLOBAL = 1; + public const SCOPE_WEBSITE = 2; /** * Prefix of model events names * * @var string */ - protected $_eventPrefix = 'eav_entity_attribute'; + protected $_eventPrefix = 'eav_entity_attribute'; - public const ATTRIBUTE_CODE_MAX_LENGTH = 30; + public const ATTRIBUTE_CODE_MAX_LENGTH = 30; /** * Parameter name in event @@ -56,7 +56,7 @@ class Mage_Eav_Model_Entity_Attribute extends Mage_Eav_Model_Entity_Attribute_Ab */ protected $_eventObject = 'attribute'; - public const CACHE_TAG = 'EAV_ATTRIBUTE'; + public const CACHE_TAG = 'EAV_ATTRIBUTE'; protected $_cacheTag = 'EAV_ATTRIBUTE'; /** From 510961503b18da30e7ef561ef587d45d1e80598e Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Fri, 26 Jan 2024 14:51:18 +0000 Subject: [PATCH 06/22] short array format + whitespace --- .../Adminhtml/Attribute/Edit/Tab/Main.php | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php index 430ae987cf4..77a1d5f248d 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php @@ -36,34 +36,34 @@ protected function _prepareForm() $fieldset = $form->getElement('base_fieldset'); $fieldset->getElements() - ->searchById('attribute_code') - ->setData( - 'class', - 'validate-code-event ' . $fieldset->getElements()->searchById('attribute_code')->getData('class') - )->setData( - 'note', - $fieldset->getElements()->searchById('attribute_code')->getData('note') - . Mage::helper('eav')->__('. Do not use "event" for an attribute code, it is a reserved keyword.') - ); + ->searchById('attribute_code') + ->setData( + 'class', + 'validate-code-event ' . $fieldset->getElements()->searchById('attribute_code')->getData('class') + )->setData( + 'note', + $fieldset->getElements()->searchById('attribute_code')->getData('note') + . Mage::helper('eav')->__('. Do not use "event" for an attribute code, it is a reserved keyword.') + ); $fieldset->getElements() - ->searchById('is_unique') - ->setData( - 'title', - Mage::helper('eav')->__('Unique Value (not shared with other %s)', strtolower(Mage::helper('eav')->formatTypeCode($attributeTypeCode))) - )->setData( - 'note', - Mage::helper('eav')->__('Not shared with other %s', strtolower(Mage::helper('eav')->formatTypeCode($attributeTypeCode))) - ); + ->searchById('is_unique') + ->setData( + 'title', + Mage::helper('eav')->__('Unique Value (not shared with other %s)', strtolower(Mage::helper('eav')->formatTypeCode($attributeTypeCode))) + )->setData( + 'note', + Mage::helper('eav')->__('Not shared with other %s', strtolower(Mage::helper('eav')->formatTypeCode($attributeTypeCode))) + ); $frontendInputElm = $form->getElement('frontend_input'); - $additionalTypes = array(); + $additionalTypes = []; $response = new Varien_Object(); - $response->setTypes(array()); - Mage::dispatchEvent("adminhtml_{$attributeTypeCode}_attribute_types", array('response'=>$response)); - $_disabledTypes = array(); - $_hiddenFields = array(); + $response->setTypes([]); + Mage::dispatchEvent("adminhtml_{$attributeTypeCode}_attribute_types", ['response'=>$response]); + $_disabledTypes = []; + $_hiddenFields = []; foreach ($response->getTypes() as $type) { $additionalTypes[] = $type; if (isset($type['hide_fields'])) { @@ -79,11 +79,11 @@ protected function _prepareForm() $frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes); $frontendInputElm->setValues($frontendInputValues); - $scopes = array( + $scopes = [ Mage_Eav_Model_Entity_Attribute::SCOPE_STORE =>Mage::helper('eav')->__('Store View'), Mage_Eav_Model_Entity_Attribute::SCOPE_WEBSITE =>Mage::helper('eav')->__('Website'), Mage_Eav_Model_Entity_Attribute::SCOPE_GLOBAL =>Mage::helper('eav')->__('Global'), - ); + ]; if ($attributeObject->getAttributeCode() == 'status') { unset($scopes[Mage_Eav_Model_Entity_Attribute::SCOPE_STORE]); @@ -92,20 +92,20 @@ protected function _prepareForm() $response = new Varien_Object(); $response->setScopes($scopes); $response->setAttribute($attributeObject); - Mage::dispatchEvent("adminhtml_{$attributeTypeCode}_attribute_scopes", array('response'=>$response)); + Mage::dispatchEvent("adminhtml_{$attributeTypeCode}_attribute_scopes", ['response'=>$response]); - $fieldset->addField('is_global', 'select', array( + $fieldset->addField('is_global', 'select', [ 'name' => 'is_global', 'label' => Mage::helper('eav')->__('Scope'), 'title' => Mage::helper('eav')->__('Scope'), 'note' => Mage::helper('eav')->__('Declare attribute value saving scope'), 'values'=> $response->getScopes(), - ), 'attribute_code'); + ], 'attribute_code'); - Mage::dispatchEvent("adminhtml_{$attributeTypeCode}_attribute_edit_prepare_form", array( + Mage::dispatchEvent("adminhtml_{$attributeTypeCode}_attribute_edit_prepare_form", [ 'form' => $form, 'attribute' => $attributeObject - )); + ]); return $this; } From b666ce6e2fb6cfb007a0f5df0fc8b2debd40443f Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 22 Apr 2024 14:48:52 +0100 Subject: [PATCH 07/22] phpcs --- .../Mage/Eav/Block/Adminhtml/Attribute/Edit.php | 4 ++-- .../Block/Adminhtml/Attribute/Edit/Tab/Main.php | 12 ++++++------ .../Mage/Eav/Block/Adminhtml/Attribute/Grid.php | 12 ++++++------ .../Eav/Block/Adminhtml/Attribute/Set/Grid.php | 2 +- .../Eav/Block/Adminhtml/Attribute/Set/Main.php | 16 ++++++++-------- .../Attribute/Set/Main/Formattribute.php | 2 +- .../Adminhtml/Attribute/Set/Main/Formgroup.php | 2 +- .../Adminhtml/Attribute/Set/Main/Formset.php | 2 +- .../Adminhtml/Attribute/Set/Toolbar/Add.php | 6 +++--- .../Eav/Block/Adminhtml/Helper/Form/Boolean.php | 2 +- .../Controller/Adminhtml/Attribute/Abstract.php | 2 +- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php index 60e56f05bf1..5ea014c2d2e 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php @@ -63,12 +63,12 @@ public function getHeaderText() public function getValidationUrl() { - return $this->getUrl('*/*/validate', array('_current'=>true)); + return $this->getUrl('*/*/validate', array('_current' => true)); } public function getSaveUrl() { - return $this->getUrl('*/*/save', array('_current'=>true, 'back'=>null)); + return $this->getUrl('*/*/save', array('_current' => true, 'back' => null)); } public function getHeaderCssClass() diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php index 77a1d5f248d..5dc714635c2 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php @@ -61,7 +61,7 @@ protected function _prepareForm() $response = new Varien_Object(); $response->setTypes([]); - Mage::dispatchEvent("adminhtml_{$attributeTypeCode}_attribute_types", ['response'=>$response]); + Mage::dispatchEvent("adminhtml_{$attributeTypeCode}_attribute_types", ['response' => $response]); $_disabledTypes = []; $_hiddenFields = []; foreach ($response->getTypes() as $type) { @@ -80,9 +80,9 @@ protected function _prepareForm() $frontendInputElm->setValues($frontendInputValues); $scopes = [ - Mage_Eav_Model_Entity_Attribute::SCOPE_STORE =>Mage::helper('eav')->__('Store View'), - Mage_Eav_Model_Entity_Attribute::SCOPE_WEBSITE =>Mage::helper('eav')->__('Website'), - Mage_Eav_Model_Entity_Attribute::SCOPE_GLOBAL =>Mage::helper('eav')->__('Global'), + Mage_Eav_Model_Entity_Attribute::SCOPE_STORE => Mage::helper('eav')->__('Store View'), + Mage_Eav_Model_Entity_Attribute::SCOPE_WEBSITE => Mage::helper('eav')->__('Website'), + Mage_Eav_Model_Entity_Attribute::SCOPE_GLOBAL => Mage::helper('eav')->__('Global'), ]; if ($attributeObject->getAttributeCode() == 'status') { @@ -92,14 +92,14 @@ protected function _prepareForm() $response = new Varien_Object(); $response->setScopes($scopes); $response->setAttribute($attributeObject); - Mage::dispatchEvent("adminhtml_{$attributeTypeCode}_attribute_scopes", ['response'=>$response]); + Mage::dispatchEvent("adminhtml_{$attributeTypeCode}_attribute_scopes", ['response' => $response]); $fieldset->addField('is_global', 'select', [ 'name' => 'is_global', 'label' => Mage::helper('eav')->__('Scope'), 'title' => Mage::helper('eav')->__('Scope'), 'note' => Mage::helper('eav')->__('Declare attribute value saving scope'), - 'values'=> $response->getScopes(), + 'values' => $response->getScopes(), ], 'attribute_code'); Mage::dispatchEvent("adminhtml_{$attributeTypeCode}_attribute_edit_prepare_form", [ diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php index dc25681375e..62365202eb1 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php @@ -46,14 +46,14 @@ protected function _prepareColumns() parent::_prepareColumns(); $this->addColumn('is_global', array( - 'header'=>Mage::helper('eav')->__('Scope'), - 'sortable'=>true, - 'index'=>'is_global', + 'header' => Mage::helper('eav')->__('Scope'), + 'sortable' => true, + 'index' => 'is_global', 'type' => 'options', 'options' => array( - Mage_Eav_Model_Entity_Attribute::SCOPE_STORE =>Mage::helper('eav')->__('Store View'), - Mage_Eav_Model_Entity_Attribute::SCOPE_WEBSITE =>Mage::helper('eav')->__('Website'), - Mage_Eav_Model_Entity_Attribute::SCOPE_GLOBAL =>Mage::helper('eav')->__('Global'), + Mage_Eav_Model_Entity_Attribute::SCOPE_STORE => Mage::helper('eav')->__('Store View'), + Mage_Eav_Model_Entity_Attribute::SCOPE_WEBSITE => Mage::helper('eav')->__('Website'), + Mage_Eav_Model_Entity_Attribute::SCOPE_GLOBAL => Mage::helper('eav')->__('Global'), ), 'align' => 'center', )); diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php index 60e41b3911f..b5bb9e688ca 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php @@ -59,6 +59,6 @@ protected function _prepareColumns() public function getRowUrl($row) { - return $this->getUrl('*/*/edit', array('id'=>$row->getAttributeSetId())); + return $this->getUrl('*/*/edit', array('id' => $row->getAttributeSetId())); } } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php index e952b245482..457ace5df50 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php @@ -61,7 +61,7 @@ protected function _prepareLayout() 'label' => Mage::helper('eav')->__('Delete Selected Group'), 'onclick' => 'editSet.submit();', 'class' => 'delete' - )) + )) ); $this->setChild( @@ -70,16 +70,16 @@ protected function _prepareLayout() 'label' => Mage::helper('eav')->__('Add New'), 'onclick' => 'editSet.addGroup();', 'class' => 'add' - )) + )) ); $this->setChild( 'back_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( 'label' => Mage::helper('eav')->__('Back'), - 'onclick' => 'setLocation(\''.$this->getUrl('*/*/').'\')', + 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/') . '\')', 'class' => 'back' - )) + )) ); $this->setChild( @@ -87,7 +87,7 @@ protected function _prepareLayout() $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( 'label' => Mage::helper('eav')->__('Reset'), 'onclick' => 'window.location.reload()' - )) + )) ); $this->setChild( @@ -96,7 +96,7 @@ protected function _prepareLayout() 'label' => Mage::helper('eav')->__('Save Attribute Set'), 'onclick' => 'editSet.save();', 'class' => 'save' - )) + )) ); if ($entity_type = Mage::registry('entity_type')) { @@ -113,7 +113,7 @@ protected function _prepareLayout() 'label' => Mage::helper('eav')->__('Delete Attribute Set'), 'onclick' => 'deleteConfirm(\'' . $deleteConfirmMessage . '\', \'' . $deleteUrl . '\')', 'class' => 'delete' - )) + )) ); $this->setChild( @@ -121,7 +121,7 @@ protected function _prepareLayout() $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( 'label' => Mage::helper('eav')->__('New Set Name'), 'onclick' => 'editSet.rename()' - )) + )) ); return parent::_prepareLayout(); diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php index 827cd53f042..5d0c15cdf9e 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php @@ -35,7 +35,7 @@ protected function _prepareForm() { $form = new Varien_Data_Form(); - $fieldset = $form->addFieldset('set_fieldset', array('legend'=>Mage::helper('eav')->__('Add New Attribute'))); + $fieldset = $form->addFieldset('set_fieldset', array('legend' => Mage::helper('eav')->__('Add New Attribute'))); $fieldset->addField( 'new_attribute', diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php index bb7e230d249..a4f3240cf5b 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php @@ -35,7 +35,7 @@ protected function _prepareForm() { $form = new Varien_Data_Form(); - $fieldset = $form->addFieldset('set_fieldset', array('legend'=>Mage::helper('eav')->__('Add New Group'))); + $fieldset = $form->addFieldset('set_fieldset', array('legend' => Mage::helper('eav')->__('Add New Group'))); $fieldset->addField( 'attribute_group_name', diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php index bbcc709b712..63b7938c18b 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php @@ -41,7 +41,7 @@ protected function _prepareForm() ->load($this->getRequest()->getParam('id')); $form = new Varien_Data_Form(); - $fieldset = $form->addFieldset('set_name', array('legend'=> Mage::helper('eav')->__('Edit Set Name'))); + $fieldset = $form->addFieldset('set_name', array('legend' => Mage::helper('eav')->__('Edit Set Name'))); $fieldset->addField('attribute_set_name', 'text', array( 'label' => Mage::helper('eav')->__('Name'), 'note' => Mage::helper('eav')->__('For internal use.'), diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php index 08756b9f82d..070c666f01a 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php @@ -41,16 +41,16 @@ protected function _prepareLayout() 'label' => Mage::helper('eav')->__('Save Attribute Set'), 'onclick' => 'if (addSet.submit()) disableElements(\'save\');', 'class' => 'save' - )) + )) ); $this->setChild( 'back_button', $this->getLayout()->createBlock('adminhtml/widget_button') ->setData(array( 'label' => Mage::helper('eav')->__('Back'), - 'onclick' => 'setLocation(\''.$this->getUrl('*/*/').'\')', + 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/') . '\')', 'class' => 'back' - )) + )) ); $this->setChild( diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php b/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php index 508eb2fba1b..9ae248dca60 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php @@ -27,7 +27,7 @@ */ class Mage_Eav_Block_Adminhtml_Helper_Form_Boolean extends Varien_Data_Form_Element_Select { - public function __construct($attributes=array()) + public function __construct($attributes = array()) { parent::__construct($attributes); $this->setValues(array( diff --git a/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php b/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php index 654e139aa44..fd2bfbd19fa 100644 --- a/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php +++ b/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php @@ -292,7 +292,7 @@ public function saveAction() Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG)); $session->setAttributeData(false); if ($redirectBack) { - $this->_redirect('*/*/edit', array('attribute_id' => $model->getId(),'_current'=>true)); + $this->_redirect('*/*/edit', array('attribute_id' => $model->getId(),'_current' => true)); } else { $this->_redirect('*/*/', array()); } From c6f1ff564f19d06739876f143a085345ecfa0248 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 22 Apr 2024 14:50:32 +0100 Subject: [PATCH 08/22] array --- app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php index 5ea014c2d2e..92d392313c8 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php @@ -63,12 +63,12 @@ public function getHeaderText() public function getValidationUrl() { - return $this->getUrl('*/*/validate', array('_current' => true)); + return $this->getUrl('*/*/validate', ['_current' => true]); } public function getSaveUrl() { - return $this->getUrl('*/*/save', array('_current' => true, 'back' => null)); + return $this->getUrl('*/*/save', ['_current' => true, 'back' => null]); } public function getHeaderCssClass() From b0be74d71fff3a52e7d14fde106d66fd5b2affe8 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 22 Apr 2024 14:51:25 +0100 Subject: [PATCH 09/22] array --- app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php index 62365202eb1..36137a46f84 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php @@ -45,7 +45,7 @@ protected function _prepareColumns() { parent::_prepareColumns(); - $this->addColumn('is_global', array( + $this->addColumn('is_global', [ 'header' => Mage::helper('eav')->__('Scope'), 'sortable' => true, 'index' => 'is_global', @@ -56,7 +56,7 @@ protected function _prepareColumns() Mage_Eav_Model_Entity_Attribute::SCOPE_GLOBAL => Mage::helper('eav')->__('Global'), ), 'align' => 'center', - )); + ]); return $this; } From cdb6f8a4256a44419c9b2ce68e21b229b7bee55e Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 22 Apr 2024 14:51:51 +0100 Subject: [PATCH 10/22] array --- app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php index b5bb9e688ca..d7ee00d23fd 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php @@ -59,6 +59,6 @@ protected function _prepareColumns() public function getRowUrl($row) { - return $this->getUrl('*/*/edit', array('id' => $row->getAttributeSetId())); + return $this->getUrl('*/*/edit', ['id' => $row->getAttributeSetId()]); } } From 1bbec409fbb1f181dbbed2aff7b1158eded5863d Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 22 Apr 2024 14:54:10 +0100 Subject: [PATCH 11/22] array --- .../Block/Adminhtml/Attribute/Set/Main.php | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php index 457ace5df50..179262e8341 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php @@ -57,46 +57,46 @@ protected function _prepareLayout() $this->setChild( 'delete_group_button', - $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( + $this->getLayout()->createBlock('adminhtml/widget_button')->setData([ 'label' => Mage::helper('eav')->__('Delete Selected Group'), 'onclick' => 'editSet.submit();', 'class' => 'delete' - )) + ]) ); $this->setChild( 'add_group_button', - $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( + $this->getLayout()->createBlock('adminhtml/widget_button')->setData([ 'label' => Mage::helper('eav')->__('Add New'), 'onclick' => 'editSet.addGroup();', 'class' => 'add' - )) + ]) ); $this->setChild( 'back_button', - $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( + $this->getLayout()->createBlock('adminhtml/widget_button')->setData([ 'label' => Mage::helper('eav')->__('Back'), 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/') . '\')', 'class' => 'back' - )) + ]) ); $this->setChild( 'reset_button', - $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( + $this->getLayout()->createBlock('adminhtml/widget_button')->setData([ 'label' => Mage::helper('eav')->__('Reset'), 'onclick' => 'window.location.reload()' - )) + ]) ); $this->setChild( 'save_button', - $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( + $this->getLayout()->createBlock('adminhtml/widget_button')->setData([ 'label' => Mage::helper('eav')->__('Save Attribute Set'), 'onclick' => 'editSet.save();', 'class' => 'save' - )) + ]) ); if ($entity_type = Mage::registry('entity_type')) { @@ -106,22 +106,22 @@ protected function _prepareLayout() $deleteConfirmMessage = $this->jsQuoteEscape(Mage::helper('eav') ->__('All items of this set will be deleted! Are you sure you want to delete this attribute set?')); } - $deleteUrl = $this->getUrlSecure('*/*/delete', array('id' => $setId)); + $deleteUrl = $this->getUrlSecure('*/*/delete', ['id' => $setId]); $this->setChild( 'delete_button', - $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( + $this->getLayout()->createBlock('adminhtml/widget_button')->setData([ 'label' => Mage::helper('eav')->__('Delete Attribute Set'), 'onclick' => 'deleteConfirm(\'' . $deleteConfirmMessage . '\', \'' . $deleteUrl . '\')', 'class' => 'delete' - )) + ]) ); $this->setChild( 'rename_button', - $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array( + $this->getLayout()->createBlock('adminhtml/widget_button')->setData([ 'label' => Mage::helper('eav')->__('New Set Name'), 'onclick' => 'editSet.rename()' - )) + ]) ); return parent::_prepareLayout(); @@ -164,7 +164,7 @@ protected function _getHeader() */ public function getMoveUrl() { - return $this->getUrl('*/*/save', array('id' => $this->_getSetId())); + return $this->getUrl('*/*/save', ['id' => $this->_getSetId()]); } /** @@ -174,7 +174,7 @@ public function getMoveUrl() */ public function getGroupUrl() { - return $this->getUrl('*/*/save', array('id' => $this->_getSetId())); + return $this->getUrl('*/*/save', ['id' => $this->_getSetId()]); } /** @@ -184,7 +184,7 @@ public function getGroupUrl() */ public function getGroupTreeJson() { - $items = array(); + $items = []; $setId = $this->_getSetId(); /* @var $groups Mage_Eav_Model_Mysql4_Entity_Attribute_Group_Collection */ @@ -199,7 +199,7 @@ public function getGroupTreeJson() /* @var $node Mage_Eav_Model_Entity_Attribute_Group */ foreach ($groups as $node) { - $item = array(); + $item = []; $item['text'] = $node->getAttributeGroupName(); $item['id'] = $node->getAttributeGroupId(); $item['cls'] = 'folder'; @@ -213,10 +213,10 @@ public function getGroupTreeJson() ->load(); if ($nodeChildren->getSize() > 0) { - $item['children'] = array(); + $item['children'] = []; foreach ($nodeChildren->getItems() as $child) { /* @var $child Mage_Eav_Model_Entity_Attribute */ - $attr = array( + $attr = [ 'text' => $child->getAttributeCode(), 'id' => $child->getAttributeId(), 'cls' => (!$child->getIsUserDefined()) ? 'system-leaf' : 'leaf', @@ -225,7 +225,7 @@ public function getGroupTreeJson() 'leaf' => true, 'is_user_defined' => $child->getIsUserDefined(), 'entity_id' => $child->getEntityAttributeId() - ); + ]; $item['children'][] = $attr; } @@ -244,7 +244,7 @@ public function getGroupTreeJson() */ public function getAttributeTreeJson() { - $items = array(); + $items = []; $setId = $this->_getSetId(); /* @var $entity_type Mage_Eav_Model_Entity_Type */ @@ -256,7 +256,7 @@ public function getAttributeTreeJson() ->setAttributeSetFilter($setId) ->load(); - $attributesIds = array('0'); + $attributesIds = ['0']; /* @var $item Mage_Eav_Model_Entity_Attribute */ foreach ($collection->getItems() as $item) { $attributesIds[] = $item->getAttributeId(); @@ -270,7 +270,7 @@ public function getAttributeTreeJson() ->load(); foreach ($attributes as $child) { - $attr = array( + $attr = [ 'text' => $child->getAttributeCode(), 'id' => $child->getAttributeId(), 'cls' => 'leaf', @@ -279,19 +279,19 @@ public function getAttributeTreeJson() 'leaf' => true, 'is_user_defined' => $child->getIsUserDefined(), 'entity_id' => $child->getEntityId() - ); + ]; $items[] = $attr; } if (count($items) == 0) { - $items[] = array( + $items[] = [ 'text' => Mage::helper('eav')->__('Empty'), 'id' => 'empty', 'cls' => 'folder', 'allowDrop' => false, 'allowDrag' => false, - ); + ]; } return Mage::helper('core')->jsonEncode($items); @@ -425,7 +425,7 @@ protected function _getSetData() protected function _toHtml() { $type = Mage::registry('entity_type')->getEntityTypeCode(); - Mage::dispatchEvent("adminhtml_{$type}_attribute_set_main_html_before", array('block' => $this)); + Mage::dispatchEvent("adminhtml_{$type}_attribute_set_main_html_before", ['block' => $this]); return parent::_toHtml(); } } From 0440e6cc89f3859558cac9df06288b1cef22c849 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 22 Apr 2024 14:55:30 +0100 Subject: [PATCH 12/22] array --- .../core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Form.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Form.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Form.php index 7a37b2b7af1..07108944686 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Form.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Form.php @@ -22,7 +22,11 @@ class Mage_Eav_Block_Adminhtml_Attribute_Edit_Form extends Mage_Adminhtml_Block_ { protected function _prepareForm() { - $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post')); + $form = new Varien_Data_Form([ + 'id' => 'edit_form', + 'action' => $this->getData('action'), + 'method' => 'post' + ]); $form->setUseContainer(true); $this->setForm($form); return parent::_prepareForm(); From cb87b611d310598ef3b14601f607ea09a95c0861 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 22 Apr 2024 22:15:20 +0100 Subject: [PATCH 13/22] phpcs --- .../core/Mage/Adminhtml/Block/Urlrewrite/Grid.php | 2 +- app/code/core/Mage/Eav/Helper/Data.php | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Grid.php b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Grid.php index de0ba83c878..469707f38b3 100644 --- a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Grid.php @@ -105,6 +105,6 @@ protected function _prepareColumns() public function getRowUrl($row) { return $this->getUrl('*/*/edit', ['id' => $row->getId()]); - //return $this->getUrl('*/*/view', array('id' => $row->getId())); + //return $this->getUrl('*/*/view', ['id' => $row->getId()]); } } diff --git a/app/code/core/Mage/Eav/Helper/Data.php b/app/code/core/Mage/Eav/Helper/Data.php index b055271949e..7f53014945a 100644 --- a/app/code/core/Mage/Eav/Helper/Data.php +++ b/app/code/core/Mage/Eav/Helper/Data.php @@ -151,21 +151,21 @@ public function getAttributeInputTypes($inputType = null) /** * @todo specify there all relations for properties depending on input type */ - $inputTypes = array( - 'multiselect' => array( + $inputTypes = [ + 'multiselect' => [ 'backend_model' => 'eav/entity_attribute_backend_array' - ), - 'boolean' => array( + ], + 'boolean' => [ 'source_model' => 'eav/entity_attribute_source_boolean' - ) - ); + ] + ]; if (is_null($inputType)) { return $inputTypes; } elseif (isset($inputTypes[$inputType])) { return $inputTypes[$inputType]; } - return array(); + return []; } /** From 558ee5d3f70fdd7335981b02bdbf5561ced824b5 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 22 Apr 2024 22:23:18 +0100 Subject: [PATCH 14/22] phpcs --- .../Block/Adminhtml/Attribute/Edit/Tabs.php | 8 +++--- .../Eav/Block/Adminhtml/Attribute/Grid.php | 4 +-- .../Attribute/Set/Main/Formattribute.php | 22 ++++++++-------- .../Attribute/Set/Main/Formgroup.php | 26 +++++++++---------- .../Adminhtml/Attribute/Set/Main/Formset.php | 14 +++++----- .../Adminhtml/Attribute/Set/Toolbar/Add.php | 8 +++--- .../Block/Adminhtml/Helper/Form/Boolean.php | 14 +++++----- .../core/Mage/Eav/Block/Widget/Boolean.php | 20 +++++--------- app/code/core/Mage/Eav/Block/Widget/Date.php | 8 +++--- .../Adminhtml/Attribute/Abstract.php | 18 ++++++------- 10 files changed, 66 insertions(+), 76 deletions(-) diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tabs.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tabs.php index 227fc104b30..9806ea0e14e 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tabs.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tabs.php @@ -30,20 +30,20 @@ public function __construct() protected function _beforeToHtml() { - $this->addTab('main', array( + $this->addTab('main', [ 'label' => Mage::helper('eav')->__('Properties'), 'title' => Mage::helper('eav')->__('Properties'), 'content' => $this->getLayout()->createBlock('eav/adminhtml_attribute_edit_tab_main')->toHtml(), 'active' => true - )); + ]); $model = Mage::registry('entity_attribute'); - $this->addTab('labels', array( + $this->addTab('labels', [ 'label' => Mage::helper('eav')->__('Manage Label / Options'), 'title' => Mage::helper('eav')->__('Manage Label / Options'), 'content' => $this->getLayout()->createBlock('eav/adminhtml_attribute_edit_tab_options')->toHtml(), - )); + ]); return parent::_beforeToHtml(); } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php index 36137a46f84..e5f8e80bf4f 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php @@ -50,11 +50,11 @@ protected function _prepareColumns() 'sortable' => true, 'index' => 'is_global', 'type' => 'options', - 'options' => array( + 'options' => [ Mage_Eav_Model_Entity_Attribute::SCOPE_STORE => Mage::helper('eav')->__('Store View'), Mage_Eav_Model_Entity_Attribute::SCOPE_WEBSITE => Mage::helper('eav')->__('Website'), Mage_Eav_Model_Entity_Attribute::SCOPE_GLOBAL => Mage::helper('eav')->__('Global'), - ), + ], 'align' => 'center', ]); diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php index 5d0c15cdf9e..5bf02be3b4a 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php @@ -35,30 +35,30 @@ protected function _prepareForm() { $form = new Varien_Data_Form(); - $fieldset = $form->addFieldset('set_fieldset', array('legend' => Mage::helper('eav')->__('Add New Attribute'))); + $fieldset = $form->addFieldset('set_fieldset', ['legend' => Mage::helper('eav')->__('Add New Attribute')]); $fieldset->addField( 'new_attribute', 'text', - array( + [ 'label' => Mage::helper('eav')->__('Name'), 'name' => 'new_attribute', 'required' => true, - ) + ] ); $fieldset->addField( 'submit', 'note', - array( + [ 'text' => $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData(array( - 'label' => Mage::helper('eav')->__('Add Attribute'), - 'onclick' => 'this.form.submit();', - 'class' => 'add' - )) - ->toHtml(), - ) + ->setData([ + 'label' => Mage::helper('eav')->__('Add Attribute'), + 'onclick' => 'this.form.submit();', + 'class' => 'add' + ]) + ->toHtml(), + ] ); $form->setUseContainer(true); diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php index a4f3240cf5b..abe6ec71c69 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php @@ -35,16 +35,16 @@ protected function _prepareForm() { $form = new Varien_Data_Form(); - $fieldset = $form->addFieldset('set_fieldset', array('legend' => Mage::helper('eav')->__('Add New Group'))); + $fieldset = $form->addFieldset('set_fieldset', ['legend' => Mage::helper('eav')->__('Add New Group')]); $fieldset->addField( 'attribute_group_name', 'text', - array( + [ 'label' => Mage::helper('eav')->__('Name'), 'name' => 'attribute_group_name', 'required' => true, - ) + ] ); $fieldset->addField( @@ -52,22 +52,22 @@ protected function _prepareForm() 'note', array( 'text' => $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData(array( - 'label' => Mage::helper('eav')->__('Add Group'), - 'onclick' => 'this.form.submit();', - 'class' => 'add' - )) - ->toHtml(), + ->setData([ + 'label' => Mage::helper('eav')->__('Add Group'), + 'onclick' => 'this.form.submit();', + 'class' => 'add' + ]) + ->toHtml(), ) ); $fieldset->addField( 'attribute_set_id', 'hidden', - array( + [ 'name' => 'attribute_set_id', 'value' => $this->_getSetId(), - ) + ] ); $form->setUseContainer(true); @@ -80,7 +80,7 @@ protected function _prepareForm() protected function _getSetId() { return (intval($this->getRequest()->getParam('id')) > 0) - ? intval($this->getRequest()->getParam('id')) - : Mage::registry('entity_type')->getDefaultAttributeSetId(); + ? intval($this->getRequest()->getParam('id')) + : Mage::registry('entity_type')->getDefaultAttributeSetId(); } } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php index 63b7938c18b..d84774ba7bf 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php @@ -41,21 +41,21 @@ protected function _prepareForm() ->load($this->getRequest()->getParam('id')); $form = new Varien_Data_Form(); - $fieldset = $form->addFieldset('set_name', array('legend' => Mage::helper('eav')->__('Edit Set Name'))); - $fieldset->addField('attribute_set_name', 'text', array( + $fieldset = $form->addFieldset('set_name', ['legend' => Mage::helper('eav')->__('Edit Set Name')]); + $fieldset->addField('attribute_set_name', 'text', [ 'label' => Mage::helper('eav')->__('Name'), 'note' => Mage::helper('eav')->__('For internal use.'), 'name' => 'attribute_set_name', 'required' => true, 'class' => 'required-entry validate-no-html-tags', 'value' => $data->getAttributeSetName() - )); + ]); if (!$this->getRequest()->getParam('id', false)) { - $fieldset->addField('gotoEdit', 'hidden', array( + $fieldset->addField('gotoEdit', 'hidden', [ 'name' => 'gotoEdit', 'value' => '1' - )); + ]); /** @var Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection @collection */ $collection = Mage::getModel('eav/entity_attribute_set') @@ -66,13 +66,13 @@ protected function _prepareForm() ->load() ->toOptionArray(); - $fieldset->addField('skeleton_set', 'select', array( + $fieldset->addField('skeleton_set', 'select', [ 'label' => Mage::helper('eav')->__('Based On'), 'name' => 'skeleton_set', 'required' => true, 'class' => 'required-entry', 'values' => $sets, - )); + ]); } $form->setMethod('post'); diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php index 070c666f01a..b3bf37deaea 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php @@ -37,20 +37,20 @@ protected function _prepareLayout() $this->setChild( 'save_button', $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData(array( + ->setData([ 'label' => Mage::helper('eav')->__('Save Attribute Set'), 'onclick' => 'if (addSet.submit()) disableElements(\'save\');', 'class' => 'save' - )) + ]) ); $this->setChild( 'back_button', $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData(array( + ->setData([ 'label' => Mage::helper('eav')->__('Back'), 'onclick' => 'setLocation(\'' . $this->getUrl('*/*/') . '\')', 'class' => 'back' - )) + ]) ); $this->setChild( diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php b/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php index 9ae248dca60..db77c1c17fa 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php @@ -27,18 +27,18 @@ */ class Mage_Eav_Block_Adminhtml_Helper_Form_Boolean extends Varien_Data_Form_Element_Select { - public function __construct($attributes = array()) + public function __construct($attributes = []) { parent::__construct($attributes); - $this->setValues(array( - array( + $this->setValues([ + [ 'label' => Mage::helper('eav')->__('No'), 'value' => 0, - ), - array( + ], + [ 'label' => Mage::helper('eav')->__('Yes'), 'value' => 1, - ), - )); + ], + ]); } } diff --git a/app/code/core/Mage/Eav/Block/Widget/Boolean.php b/app/code/core/Mage/Eav/Block/Widget/Boolean.php index cb0973cd886..5ea9bd04585 100644 --- a/app/code/core/Mage/Eav/Block/Widget/Boolean.php +++ b/app/code/core/Mage/Eav/Block/Widget/Boolean.php @@ -27,27 +27,19 @@ */ class Mage_Eav_Block_Widget_Boolean extends Mage_Eav_Block_Widget_Abstract { - /** - * Initialize block - */ public function _construct() { parent::_construct(); $this->setTemplate('eav/widget/boolean.phtml'); } - /** - * Get select options - * - * @return array - */ - public function getOptions() + public function getOptions(): array { - $options = array( - array('value' => '', 'label' => Mage::helper('eav')->__('')), - array('value' => '1', 'label' => Mage::helper('eav')->__('Yes')), - array('value' => '0', 'label' => Mage::helper('eav')->__('No')) - ); + $options = [ + ['value' => '', 'label' => Mage::helper('eav')->__('')], + ['value' => '1', 'label' => Mage::helper('eav')->__('Yes')], + ['value' => '0', 'label' => Mage::helper('eav')->__('No')] + ]; return $options; } diff --git a/app/code/core/Mage/Eav/Block/Widget/Date.php b/app/code/core/Mage/Eav/Block/Widget/Date.php index 11a49172c1c..9369e123555 100644 --- a/app/code/core/Mage/Eav/Block/Widget/Date.php +++ b/app/code/core/Mage/Eav/Block/Widget/Date.php @@ -25,11 +25,9 @@ class Mage_Eav_Block_Widget_Date extends Mage_Eav_Block_Widget_Abstract { /** - * Date inputs - * * @var array */ - protected $_dateInputs = array(); + protected $_dateInputs = []; public function _construct() { @@ -102,7 +100,7 @@ public function setDateInput($code, $html) */ public function getSortedDateInputs() { - $strtr = array( + $strtr = [ '%b' => '%1$s', '%B' => '%1$s', '%m' => '%1$s', @@ -110,7 +108,7 @@ public function getSortedDateInputs() '%e' => '%2$s', '%Y' => '%3$s', '%y' => '%3$s' - ); + ]; $dateFormat = preg_replace('/[^\%\w]/', '\\1', $this->getDateFormat()); diff --git a/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php b/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php index fd2bfbd19fa..0bbc5768012 100644 --- a/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php +++ b/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php @@ -189,12 +189,12 @@ public function saveAction() //validate attribute_code if (isset($data['attribute_code'])) { - $validatorAttrCode = new Zend_Validate_Regex(array('pattern' => '/^(?!event$)[a-z][a-z_0-9]{1,254}$/')); + $validatorAttrCode = new Zend_Validate_Regex(['pattern' => '/^(?!event$)[a-z][a-z_0-9]{1,254}$/']); if (!$validatorAttrCode->isValid($data['attribute_code'])) { $session->addError( Mage::helper('eav')->__('Attribute code is invalid. Please use only letters (a-z), numbers (0-9) or underscore(_) in this field, first character should be a letter. Do not use "event" for an attribute code.') ); - $this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true)); + $this->_redirect('*/*/edit', ['attribute_id' => $id, '_current' => true]); return; } } @@ -208,7 +208,7 @@ public function saveAction() foreach ($validatorInputType->getMessages() as $message) { $session->addError($message); } - $this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true)); + $this->_redirect('*/*/edit', ['attribute_id' => $id, '_current' => true]); return; } } @@ -277,7 +277,7 @@ public function saveAction() Mage::dispatchEvent( "adminhtml_{$this->_entityCode}_attribute_edit_prepare_save", - array('object' => $model, 'request' => $this->getRequest()) + ['object' => $model, 'request' => $this->getRequest()] ); try { @@ -289,18 +289,18 @@ public function saveAction() /** * Clear translation cache because attribute labels are stored in translation */ - Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG)); + Mage::app()->cleanCache([Mage_Core_Model_Translate::CACHE_TAG]); $session->setAttributeData(false); if ($redirectBack) { - $this->_redirect('*/*/edit', array('attribute_id' => $model->getId(),'_current' => true)); + $this->_redirect('*/*/edit', ['attribute_id' => $model->getId(),'_current' => true]); } else { - $this->_redirect('*/*/', array()); + $this->_redirect('*/*/'); } return; } catch (Exception $e) { $session->addError($e->getMessage()); $session->setAttributeData($data); - $this->_redirect('*/*/edit', array('attribute_id' => $id, '_current' => true)); + $this->_redirect('*/*/edit', ['attribute_id' => $id, '_current' => true]); return; } } @@ -331,7 +331,7 @@ public function deleteAction() return; } catch (Exception $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); - $this->_redirect('*/*/edit', array('attribute_id' => $this->getRequest()->getParam('attribute_id'))); + $this->_redirect('*/*/edit', ['attribute_id' => $this->getRequest()->getParam('attribute_id')]); return; } } From 7de5ccd6a2cfb757f6beffa308a161b6eb6e7a16 Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 22 Apr 2024 22:34:05 +0100 Subject: [PATCH 15/22] phpstan --- app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php b/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php index 62c4e51b349..c3ffed5fc9d 100644 --- a/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php +++ b/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php @@ -74,7 +74,7 @@ public function editAction() Mage::register('current_attribute_set', $attributeSet); $this->_initAction() - ->_title($attributeSet->getId() ? $attributeSet->getAttributeSetName() : $this->__('New Set')) + ->_title($attributeSet->getAttributeSetName()) ->_addContent($this->getLayout()->createBlock('eav/adminhtml_attribute_set_main')); $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); From da9559a081bb86e1841beb1d7fe4d999801b67fe Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Mon, 22 Apr 2024 22:42:31 +0100 Subject: [PATCH 16/22] type hint --- app/code/core/Mage/Eav/Block/Widget/Multiselect.php | 10 +--------- app/code/core/Mage/Eav/Block/Widget/Select.php | 10 +--------- app/code/core/Mage/Eav/Block/Widget/Text.php | 3 --- app/code/core/Mage/Eav/Block/Widget/Textarea.php | 3 --- 4 files changed, 2 insertions(+), 24 deletions(-) diff --git a/app/code/core/Mage/Eav/Block/Widget/Multiselect.php b/app/code/core/Mage/Eav/Block/Widget/Multiselect.php index 329216986fe..3c3266f5c6a 100644 --- a/app/code/core/Mage/Eav/Block/Widget/Multiselect.php +++ b/app/code/core/Mage/Eav/Block/Widget/Multiselect.php @@ -27,9 +27,6 @@ */ class Mage_Eav_Block_Widget_Multiselect extends Mage_Eav_Block_Widget_Abstract { - /** - * Initialize block - */ public function _construct() { parent::_construct(); @@ -46,12 +43,7 @@ public function getFieldParams() return 'multiple'; } - /** - * Get select options - * - * @return array - */ - public function getOptions() + public function getOptions(): array { return $this->getAttribute()->getSource()->getAllOptions(false); } diff --git a/app/code/core/Mage/Eav/Block/Widget/Select.php b/app/code/core/Mage/Eav/Block/Widget/Select.php index b97509537e9..c2aa3ff21be 100644 --- a/app/code/core/Mage/Eav/Block/Widget/Select.php +++ b/app/code/core/Mage/Eav/Block/Widget/Select.php @@ -27,21 +27,13 @@ */ class Mage_Eav_Block_Widget_Select extends Mage_Eav_Block_Widget_Abstract { - /** - * Initialize block - */ public function _construct() { parent::_construct(); $this->setTemplate('eav/widget/select.phtml'); } - /** - * Get select options - * - * @return array - */ - public function getOptions() + public function getOptions(): array { return $this->getAttribute()->getSource()->getAllOptions(); } diff --git a/app/code/core/Mage/Eav/Block/Widget/Text.php b/app/code/core/Mage/Eav/Block/Widget/Text.php index 4402d6645c3..543682001d9 100644 --- a/app/code/core/Mage/Eav/Block/Widget/Text.php +++ b/app/code/core/Mage/Eav/Block/Widget/Text.php @@ -27,9 +27,6 @@ */ class Mage_Eav_Block_Widget_Text extends Mage_Eav_Block_Widget_Abstract { - /** - * Initialize block - */ public function _construct() { parent::_construct(); diff --git a/app/code/core/Mage/Eav/Block/Widget/Textarea.php b/app/code/core/Mage/Eav/Block/Widget/Textarea.php index 5989f5e8409..77888d350e2 100644 --- a/app/code/core/Mage/Eav/Block/Widget/Textarea.php +++ b/app/code/core/Mage/Eav/Block/Widget/Textarea.php @@ -27,9 +27,6 @@ */ class Mage_Eav_Block_Widget_Textarea extends Mage_Eav_Block_Widget_Abstract { - /** - * Initialize block - */ public function _construct() { parent::_construct(); From ddf34c02db86565a13ddc3696fcfb5e12827f82d Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 19 Sep 2024 18:07:07 +0200 Subject: [PATCH 17/22] phpcs --- .../core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php | 2 +- .../Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php | 8 ++++---- .../core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php index d7ee00d23fd..752315a0f6e 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php @@ -54,7 +54,7 @@ protected function _prepareColumns() 'index' => 'attribute_set_name', ]); - return $this; + return parent::_prepareColumns(); } public function getRowUrl($row) diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php index abe6ec71c69..8d351b11feb 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php @@ -50,7 +50,7 @@ protected function _prepareForm() $fieldset->addField( 'submit', 'note', - array( + [ 'text' => $this->getLayout()->createBlock('adminhtml/widget_button') ->setData([ 'label' => Mage::helper('eav')->__('Add Group'), @@ -58,7 +58,7 @@ protected function _prepareForm() 'class' => 'add' ]) ->toHtml(), - ) + ] ); $fieldset->addField( @@ -79,8 +79,8 @@ protected function _prepareForm() protected function _getSetId() { - return (intval($this->getRequest()->getParam('id')) > 0) - ? intval($this->getRequest()->getParam('id')) + return ((int) ($this->getRequest()->getParam('id')) > 0) + ? (int) ($this->getRequest()->getParam('id')) : Mage::registry('entity_type')->getDefaultAttributeSetId(); } } diff --git a/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php b/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php index c3ffed5fc9d..bf7f2994fee 100644 --- a/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php +++ b/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php @@ -154,10 +154,10 @@ public function saveAction() if ($hasError) { $this->_redirect('*/*/add'); } else { - $this->_redirect('*/*/edit', array('id' => $model->getId())); + $this->_redirect('*/*/edit', ['id' => $model->getId()]); } } else { - $response = array(); + $response = []; if ($hasError) { $this->_initLayoutMessages('adminhtml/session'); $response['error'] = 1; From 7dd9002e17b1fc54cb0f8ecc391c34d69bdd6305 Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Thu, 19 Sep 2024 20:48:46 +0200 Subject: [PATCH 18/22] Cleanup [skip ci] - added strict types for new classes - added parameter & return types - updated copyright --- .../Block/Customer/Edit/Tab/Newsletter.php | 2 +- .../System/Convert/Gui/Edit/Tab/View.php | 2 +- .../System/Convert/Profile/Edit/Tab/Edit.php | 2 +- .../Mage/Adminhtml/Block/Urlrewrite/Grid.php | 2 +- .../controllers/Api/UserController.php | 2 +- .../controllers/NotificationController.php | 2 +- .../Permissions/BlockController.php | 2 +- .../Permissions/RoleController.php | 2 +- .../Permissions/UserController.php | 2 +- .../Permissions/VariableController.php | 2 +- .../controllers/Report/CustomerController.php | 2 +- .../controllers/Report/ProductController.php | 2 +- .../controllers/Report/SalesController.php | 2 +- .../Sales/Order/StatusController.php | 2 +- .../controllers/System/CurrencyController.php | 2 +- .../Adminhtml/Api2/AttributeController.php | 2 +- app/code/core/Mage/Cms/Model/Block.php | 2 +- app/code/core/Mage/Cms/Model/Mysql4/Block.php | 2 +- .../Cms/Model/Mysql4/Block/Collection.php | 2 +- app/code/core/Mage/Cms/Model/Mysql4/Page.php | 2 +- .../Mage/Cms/Model/Mysql4/Page/Collection.php | 2 +- .../Mage/Cms/Model/Mysql4/Page/Service.php | 2 +- app/code/core/Mage/Cms/Model/Page.php | 2 +- .../Cms/Model/Resource/Block/Collection.php | 2 +- .../Cms/Model/Resource/Page/Collection.php | 2 +- .../System/CurrencysymbolController.php | 2 +- .../Mage/Eav/Block/Adminhtml/Attribute.php | 22 ++-- .../Eav/Block/Adminhtml/Attribute/Edit.php | 30 +++--- .../Block/Adminhtml/Attribute/Edit/Form.php | 23 ++-- .../Adminhtml/Attribute/Edit/Tab/Main.php | 25 ++--- .../Adminhtml/Attribute/Edit/Tab/Options.php | 22 ++-- .../Block/Adminhtml/Attribute/Edit/Tabs.php | 22 ++-- .../Eav/Block/Adminhtml/Attribute/Grid.php | 24 +++-- .../Eav/Block/Adminhtml/Attribute/Set.php | 24 ++--- .../Block/Adminhtml/Attribute/Set/Grid.php | 23 ++-- .../Block/Adminhtml/Attribute/Set/Main.php | 102 ++++++------------ .../Attribute/Set/Main/Formattribute.php | 23 ++-- .../Attribute/Set/Main/Formgroup.php | 23 ++-- .../Adminhtml/Attribute/Set/Main/Formset.php | 25 ++--- .../Attribute/Set/Main/Tree/Attribute.php | 20 ++-- .../Attribute/Set/Main/Tree/Group.php | 20 ++-- .../Adminhtml/Attribute/Set/Toolbar/Add.php | 30 +++--- .../Block/Adminhtml/Helper/Form/Boolean.php | 19 ++-- .../core/Mage/Eav/Block/Widget/Abstract.php | 41 +++---- .../core/Mage/Eav/Block/Widget/Boolean.php | 23 ++-- app/code/core/Mage/Eav/Block/Widget/Date.php | 44 +++----- .../Mage/Eav/Block/Widget/Multiselect.php | 25 ++--- .../core/Mage/Eav/Block/Widget/Select.php | 19 ++-- app/code/core/Mage/Eav/Block/Widget/Text.php | 21 ++-- .../core/Mage/Eav/Block/Widget/Textarea.php | 21 ++-- .../Adminhtml/Attribute/Abstract.php | 36 +++---- .../Eav/Controller/Adminhtml/Set/Abstract.php | 31 +++--- app/code/core/Mage/Eav/Helper/Data.php | 20 +--- .../core/Mage/Eav/Model/Entity/Attribute.php | 2 +- .../Mage/Eav/Model/Entity/Attribute/Set.php | 4 +- .../Eav/Model/Resource/Entity/Attribute.php | 2 +- .../Adminhtml/ExportController.php | 2 +- .../Adminhtml/ImportController.php | 2 +- .../Adminhtml/ProcessController.php | 2 +- .../Adminhtml/Oauth/Admin/TokenController.php | 2 +- .../Oauth/AuthorizedTokensController.php | 2 +- .../Adminhtml/Paypal/ReportsController.php | 2 +- .../Adminhtml/Widget/InstanceController.php | 2 +- .../default/template/eav/attribute/js.phtml | 21 ++-- .../template/eav/attribute/options.phtml | 23 ++-- .../template/eav/attribute/set/main.phtml | 21 ++-- .../attribute/set/main/tree/attribute.phtml | 23 ++-- .../eav/attribute/set/main/tree/group.phtml | 21 ++-- .../eav/attribute/set/toolbar/add.phtml | 21 ++-- .../default/template/eav/widget/boolean.phtml | 21 ++-- .../default/template/eav/widget/date.phtml | 21 ++-- .../template/eav/widget/multiselect.phtml | 21 ++-- .../default/template/eav/widget/select.phtml | 21 ++-- .../default/template/eav/widget/text.phtml | 21 ++-- .../template/eav/widget/textarea.phtml | 21 ++-- skin/frontend/rwd/default/scss/_core.scss | 2 +- .../rwd/default/scss/module/_eav.scss | 1 + 77 files changed, 455 insertions(+), 636 deletions(-) diff --git a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter.php b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter.php index 94c815fdf58..f8a4122f6b2 100644 --- a/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter.php +++ b/app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/Newsletter.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/View.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/View.php index 0fc992d2738..eddf0d3e284 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/View.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/View.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Edit.php b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Edit.php index e8b952b1e1d..632ba283a15 100644 --- a/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Edit.php +++ b/app/code/core/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/Edit.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Grid.php b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Grid.php index 469707f38b3..60321567ddf 100644 --- a/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Grid.php +++ b/app/code/core/Mage/Adminhtml/Block/Urlrewrite/Grid.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php b/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php index a822c710b23..bf787d8fd6a 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Api/UserController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Adminhtml/controllers/NotificationController.php b/app/code/core/Mage/Adminhtml/controllers/NotificationController.php index 2a71cc58cea..27031b4f6e7 100644 --- a/app/code/core/Mage/Adminhtml/controllers/NotificationController.php +++ b/app/code/core/Mage/Adminhtml/controllers/NotificationController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php index 8ffb7d3c546..c9e72766061 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/BlockController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php index e8c42b4576e..e138b788f93 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/RoleController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php index ada91c84683..d20c96b8a21 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2018-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2018-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php b/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php index f9d8800642a..6daa10ec0d0 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Permissions/VariableController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php b/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php index 79a3d675f4f..4e0396706b6 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/CustomerController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php b/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php index daa7cb8dd75..afc1dc579fa 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/ProductController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php b/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php index a73ef0963d7..19290ef4231 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Report/SalesController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2017-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2017-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php index 71c02bd943c..0e48b09e97b 100644 --- a/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php +++ b/app/code/core/Mage/Adminhtml/controllers/Sales/Order/StatusController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php b/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php index 9b1e7beca0e..b8e08da93b4 100644 --- a/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php +++ b/app/code/core/Mage/Adminhtml/controllers/System/CurrencyController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Adminhtml * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/AttributeController.php b/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/AttributeController.php index 11f8b6ace35..9d1656cf1a2 100644 --- a/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/AttributeController.php +++ b/app/code/core/Mage/Api2/controllers/Adminhtml/Api2/AttributeController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Api2 * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Cms/Model/Block.php b/app/code/core/Mage/Cms/Model/Block.php index 0b9c8275dc7..fe4e32ebeb3 100644 --- a/app/code/core/Mage/Cms/Model/Block.php +++ b/app/code/core/Mage/Cms/Model/Block.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Cms * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Cms/Model/Mysql4/Block.php b/app/code/core/Mage/Cms/Model/Mysql4/Block.php index e4fcf4094e6..8bea21200da 100644 --- a/app/code/core/Mage/Cms/Model/Mysql4/Block.php +++ b/app/code/core/Mage/Cms/Model/Mysql4/Block.php @@ -10,7 +10,7 @@ * @category Mage * @package Mage_Cms * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Cms/Model/Mysql4/Block/Collection.php b/app/code/core/Mage/Cms/Model/Mysql4/Block/Collection.php index 132fa989e3a..e3fa3f17e9e 100644 --- a/app/code/core/Mage/Cms/Model/Mysql4/Block/Collection.php +++ b/app/code/core/Mage/Cms/Model/Mysql4/Block/Collection.php @@ -10,7 +10,7 @@ * @category Mage * @package Mage_Cms * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Cms/Model/Mysql4/Page.php b/app/code/core/Mage/Cms/Model/Mysql4/Page.php index 208fa046d25..8bcce0bc132 100644 --- a/app/code/core/Mage/Cms/Model/Mysql4/Page.php +++ b/app/code/core/Mage/Cms/Model/Mysql4/Page.php @@ -10,7 +10,7 @@ * @category Mage * @package Mage_Cms * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Cms/Model/Mysql4/Page/Collection.php b/app/code/core/Mage/Cms/Model/Mysql4/Page/Collection.php index d44f61ddd14..6404c3aee3b 100644 --- a/app/code/core/Mage/Cms/Model/Mysql4/Page/Collection.php +++ b/app/code/core/Mage/Cms/Model/Mysql4/Page/Collection.php @@ -10,7 +10,7 @@ * @category Mage * @package Mage_Cms * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Cms/Model/Mysql4/Page/Service.php b/app/code/core/Mage/Cms/Model/Mysql4/Page/Service.php index 2dd48084def..2e9863a9030 100644 --- a/app/code/core/Mage/Cms/Model/Mysql4/Page/Service.php +++ b/app/code/core/Mage/Cms/Model/Mysql4/Page/Service.php @@ -10,7 +10,7 @@ * @category Mage * @package Mage_Cms * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Cms/Model/Page.php b/app/code/core/Mage/Cms/Model/Page.php index beb9d8b5eb3..9e199523054 100644 --- a/app/code/core/Mage/Cms/Model/Page.php +++ b/app/code/core/Mage/Cms/Model/Page.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Cms * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Cms/Model/Resource/Block/Collection.php b/app/code/core/Mage/Cms/Model/Resource/Block/Collection.php index 2e0852a8385..cdb8d2bc9d6 100644 --- a/app/code/core/Mage/Cms/Model/Resource/Block/Collection.php +++ b/app/code/core/Mage/Cms/Model/Resource/Block/Collection.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Cms * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Cms/Model/Resource/Page/Collection.php b/app/code/core/Mage/Cms/Model/Resource/Page/Collection.php index aa54f1ef80a..0b26cc8e353 100644 --- a/app/code/core/Mage/Cms/Model/Resource/Page/Collection.php +++ b/app/code/core/Mage/Cms/Model/Resource/Page/Collection.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Cms * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2018-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2018-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php b/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php index f397dc5ceed..fd65fb08bc1 100644 --- a/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php +++ b/app/code/core/Mage/CurrencySymbol/controllers/Adminhtml/System/CurrencysymbolController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_CurrencySymbol * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute.php index 64d80115516..487cf1beb29 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute.php @@ -2,30 +2,24 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** * Adminhtml attributes block * * @category Mage * @package Mage_Eav - * @author Magento Core Team */ - class Mage_Eav_Block_Adminhtml_Attribute extends Mage_Adminhtml_Block_Widget_Grid_Container { public function __construct() @@ -41,7 +35,7 @@ public function __construct() parent::__construct(); } - public function getHeaderCssClass() + public function getHeaderCssClass(): string { return 'icon-head head-eav-attribute'; } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php index 92d392313c8..2579643664b 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit.php @@ -2,22 +2,22 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + +/** + * @category Mage + * @package Mage_Eav + */ class Mage_Eav_Block_Adminhtml_Attribute_Edit extends Mage_Adminhtml_Block_Widget_Form_Container { public function __construct() @@ -48,7 +48,7 @@ public function __construct() } } - public function getHeaderText() + public function getHeaderText(): string { if (Mage::registry('entity_attribute')->getId()) { $frontendLabel = Mage::registry('entity_attribute')->getFrontendLabel(); @@ -61,17 +61,17 @@ public function getHeaderText() } } - public function getValidationUrl() + public function getValidationUrl(): string { return $this->getUrl('*/*/validate', ['_current' => true]); } - public function getSaveUrl() + public function getSaveUrl(): string { return $this->getUrl('*/*/save', ['_current' => true, 'back' => null]); } - public function getHeaderCssClass() + public function getHeaderCssClass(): string { return 'icon-head head-eav-attribute'; } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Form.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Form.php index 07108944686..d7d8b23d4e9 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Form.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Form.php @@ -2,22 +2,22 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + +/** + * @category Mage + * @package Mage_Eav + */ class Mage_Eav_Block_Adminhtml_Attribute_Edit_Form extends Mage_Adminhtml_Block_Widget_Form { protected function _prepareForm() @@ -29,6 +29,7 @@ protected function _prepareForm() ]); $form->setUseContainer(true); $this->setForm($form); + return parent::_prepareForm(); } } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php index 5dc714635c2..067abd79685 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Main.php @@ -2,35 +2,36 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + +/** + * @category Mage + * @package Mage_Eav + */ class Mage_Eav_Block_Adminhtml_Attribute_Edit_Tab_Main extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Main_Abstract { /** * Adding form elements for editing attribute * * @return $this + * @throws Mage_Core_Exception */ protected function _prepareForm() { parent::_prepareForm(); $attributeObject = $this->getAttributeObject(); $attributeTypeCode = $attributeObject->getEntityType()->getEntityTypeCode(); - /* @var $form Varien_Data_Form */ + $form = $this->getForm(); /* @var $fieldset Varien_Data_Form_Element_Fieldset */ $fieldset = $form->getElement('base_fieldset'); diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Options.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Options.php index 2c3d11f4177..eacaa31c202 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Options.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tab/Options.php @@ -2,22 +2,22 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + +/** + * @category Mage + * @package Mage_Eav + */ class Mage_Eav_Block_Adminhtml_Attribute_Edit_Tab_Options extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract { } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tabs.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tabs.php index 9806ea0e14e..e1095b2b0da 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tabs.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Edit/Tabs.php @@ -2,22 +2,22 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + +/** + * @category Mage + * @package Mage_Eav + */ class Mage_Eav_Block_Adminhtml_Attribute_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs { public function __construct() diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php index e5f8e80bf4f..af684315d44 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Grid.php @@ -2,28 +2,29 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + +/** + * @category Mage + * @package Mage_Eav + */ class Mage_Eav_Block_Adminhtml_Attribute_Grid extends Mage_Eav_Block_Adminhtml_Attribute_Grid_Abstract { /** * Prepare grid collection object * * @return $this + * @throws Exception */ protected function _prepareCollection() { @@ -40,6 +41,7 @@ protected function _prepareCollection() * Prepare attributes grid columns * * @return $this + * @throws Exception */ protected function _prepareColumns() { diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set.php index c33be700692..3a0b63c6390 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set.php @@ -2,30 +2,24 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** * Adminhtml attribute sets block * * @category Mage * @package Mage_Eav - * @author Magento Core Team */ - class Mage_Eav_Block_Adminhtml_Attribute_Set extends Mage_Adminhtml_Block_Widget_Grid_Container { public function __construct() @@ -41,12 +35,12 @@ public function __construct() parent::__construct(); } - public function getCreateUrl() + public function getCreateUrl(): string { return $this->getUrl('*/*/add'); } - public function getHeaderCssClass() + public function getHeaderCssClass(): string { return 'icon-head head-eav-attribute-sets'; } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php index 752315a0f6e..7eed92d2c96 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Grid.php @@ -2,28 +2,21 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** - * description - * * @category Mage * @package Mage_Eav - * @author Magento Core Team */ class Mage_Eav_Block_Adminhtml_Attribute_Set_Grid extends Mage_Adminhtml_Block_Widget_Grid { @@ -57,7 +50,7 @@ protected function _prepareColumns() return parent::_prepareColumns(); } - public function getRowUrl($row) + public function getRowUrl($row): string { return $this->getUrl('*/*/edit', ['id' => $row->getAttributeSetId()]); } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php index 179262e8341..5cfb23fd081 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main.php @@ -2,34 +2,28 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** * Adminhtml Attribute Set Main Block * - * @category Mage - * @package Mage_Eav - * @author Magento Core Team + * @category Mage + * @package Mage_Eav */ class Mage_Eav_Block_Adminhtml_Attribute_Set_Main extends Mage_Adminhtml_Block_Template { /** * Initialize template - * */ protected function _construct() { @@ -99,7 +93,7 @@ protected function _prepareLayout() ]) ); - if ($entity_type = Mage::registry('entity_type')) { + if (Mage::registry('entity_type')) { $deleteConfirmMessage = $this->jsQuoteEscape(Mage::helper('eav') ->__('All %s of this set will be deleted! Are you sure you want to delete this attribute set?')); } else { @@ -129,50 +123,40 @@ protected function _prepareLayout() /** * Retrieve Attribute Set Group Tree HTML - * - * @return string */ - public function getGroupTreeHtml() + public function getGroupTreeHtml(): string { return $this->getChildHtml('group_tree'); } /** * Retrieve Attribute Set Edit Form HTML - * - * @return string */ - public function getSetFormHtml() + public function getSetFormHtml(): string { return $this->getChildHtml('edit_set_form'); } /** * Retrieve Block Header Text - * - * @return string */ - protected function _getHeader() + protected function _getHeader(): string { return Mage::helper('eav')->__("Edit Attribute Set '%s'", $this->_getAttributeSet()->getAttributeSetName()); } /** * Retrieve Attribute Set Save URL - * - * @return string */ - public function getMoveUrl() + public function getMoveUrl(): string { return $this->getUrl('*/*/save', ['id' => $this->_getSetId()]); } /** * Retrieve Attribute Set Group Save URL - * - * @return string */ - public function getGroupUrl() + public function getGroupUrl(): string { return $this->getUrl('*/*/save', ['id' => $this->_getSetId()]); } @@ -180,9 +164,9 @@ public function getGroupUrl() /** * Retrieve Attribute Set Group Tree as JSON format * - * @return string + * @throws Mage_Core_Exception */ - public function getGroupTreeJson() + public function getGroupTreeJson(): string { $items = []; $setId = $this->_getSetId(); @@ -239,10 +223,8 @@ public function getGroupTreeJson() /** * Retrieve Unused in Attribute Set Attribute Tree as JSON - * - * @return string */ - public function getAttributeTreeJson() + public function getAttributeTreeJson(): string { $items = []; $setId = $this->_getSetId(); @@ -257,7 +239,6 @@ public function getAttributeTreeJson() ->load(); $attributesIds = ['0']; - /* @var $item Mage_Eav_Model_Entity_Attribute */ foreach ($collection->getItems() as $item) { $attributesIds[] = $item->getAttributeId(); } @@ -299,40 +280,32 @@ public function getAttributeTreeJson() /** * Retrieve Back Button HTML - * - * @return string */ - public function getBackButtonHtml() + public function getBackButtonHtml(): string { return $this->getChildHtml('back_button'); } /** * Retrieve Reset Button HTML - * - * @return string */ - public function getResetButtonHtml() + public function getResetButtonHtml(): string { return $this->getChildHtml('reset_button'); } /** * Retrieve Save Button HTML - * - * @return string */ - public function getSaveButtonHtml() + public function getSaveButtonHtml(): string { return $this->getChildHtml('save_button'); } /** * Retrieve Delete Button HTML - * - * @return string */ - public function getDeleteButtonHtml() + public function getDeleteButtonHtml(): string { if ($this->getIsCurrentSetDefault()) { return ''; @@ -342,60 +315,48 @@ public function getDeleteButtonHtml() /** * Retrieve Delete Group Button HTML - * - * @return string */ - public function getDeleteGroupButton() + public function getDeleteGroupButton(): string { return $this->getChildHtml('delete_group_button'); } /** * Retrieve Add New Group Button HTML - * - * @return string */ - public function getAddGroupButton() + public function getAddGroupButton(): string { return $this->getChildHtml('add_group_button'); } /** * Retrieve Rename Button HTML - * - * @return string */ - public function getRenameButton() + public function getRenameButton(): string { return $this->getChildHtml('rename_button'); } /** * Retrieve current Attribute Set object - * - * @return Mage_Eav_Model_Entity_Attribute_Set */ - protected function _getAttributeSet() + protected function _getAttributeSet(): ?Mage_Eav_Model_Entity_Attribute_Set { return Mage::registry('current_attribute_set'); } /** * Retrieve current attribute set Id - * - * @return int */ - protected function _getSetId() + protected function _getSetId(): int { return $this->_getAttributeSet()->getId(); } /** * Check Current Attribute Set is a default - * - * @return bool */ - public function getIsCurrentSetDefault() + public function getIsCurrentSetDefault(): bool { $isDefault = $this->getData('is_current_set_default'); if (is_null($isDefault)) { @@ -410,19 +371,16 @@ public function getIsCurrentSetDefault() * Retrieve current Attribute Set object * * @deprecated use _getAttributeSet - * @return Mage_Eav_Model_Entity_Attribute_Set */ - protected function _getSetData() + protected function _getSetData(): ?Mage_Eav_Model_Entity_Attribute_Set { return $this->_getAttributeSet(); } /** * Prepare HTML - * - * @return string */ - protected function _toHtml() + protected function _toHtml(): string { $type = Mage::registry('entity_type')->getEntityTypeCode(); Mage::dispatchEvent("adminhtml_{$type}_attribute_set_main_html_before", ['block' => $this]); diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php index 5bf02be3b4a..5652e4b432d 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formattribute.php @@ -2,28 +2,22 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** * @category Mage * @package Mage_Eav - * @author Magento Core Team */ - class Mage_Eav_Block_Adminhtml_Attribute_Set_Main_Formattribute extends Mage_Adminhtml_Block_Widget_Form { public function __construct() @@ -64,6 +58,7 @@ protected function _prepareForm() $form->setUseContainer(true); $form->setMethod('post'); $this->setForm($form); - return $this; + + return parent::_prepareForm(); } } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php index 8d351b11feb..19056502c43 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formgroup.php @@ -2,28 +2,22 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** * @category Mage * @package Mage_Eav - * @author Magento Core Team */ - class Mage_Eav_Block_Adminhtml_Attribute_Set_Main_Formgroup extends Mage_Adminhtml_Block_Widget_Form { public function __construct() @@ -74,7 +68,8 @@ protected function _prepareForm() $form->setMethod('post'); $form->setAction($this->getUrl('*/*/save')); $this->setForm($form); - return $this; + + return parent::_prepareForm(); } protected function _getSetId() diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php index d84774ba7bf..3a14dd588f6 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Formset.php @@ -2,28 +2,22 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** * @category Mage * @package Mage_Eav - * @author Magento Core Team */ - class Mage_Eav_Block_Adminhtml_Attribute_Set_Main_Formset extends Mage_Adminhtml_Block_Widget_Form { public function __construct() @@ -57,7 +51,7 @@ protected function _prepareForm() 'value' => '1' ]); - /** @var Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection @collection */ + /** @var Mage_Eav_Model_Resource_Entity_Attribute_Set_Collection $collection */ $collection = Mage::getModel('eav/entity_attribute_set') ->getResourceCollection(); @@ -81,6 +75,7 @@ protected function _prepareForm() $form->setAction($this->getUrl('*/*/save')); $form->setOnsubmit('return false;'); $this->setForm($form); - return $this; + + return parent::_prepareForm(); } } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Attribute.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Attribute.php index 8bd7ad8d0b1..43e87ef2be5 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Attribute.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Attribute.php @@ -2,28 +2,22 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** * @category Mage * @package Mage_Eav - * @author Magento Core Team */ - class Mage_Eav_Block_Adminhtml_Attribute_Set_Main_Tree_Attribute extends Mage_Adminhtml_Block_Template { protected function _construct() diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Group.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Group.php index e4eba07c4f4..e1754f67b39 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Group.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Main/Tree/Group.php @@ -2,28 +2,22 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** * @category Mage * @package Mage_Eav - * @author Magento Core Team */ - class Mage_Eav_Block_Adminhtml_Attribute_Set_Main_Tree_Group extends Mage_Adminhtml_Block_Template { protected function _construct() diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php index b3bf37deaea..21e2e890ad5 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Attribute/Set/Toolbar/Add.php @@ -2,28 +2,21 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** - * description - * * @category Mage * @package Mage_Eav - * @author Magento Core Team */ class Mage_Eav_Block_Adminhtml_Attribute_Set_Toolbar_Add extends Mage_Adminhtml_Block_Template { @@ -57,25 +50,26 @@ protected function _prepareLayout() 'setForm', $this->getLayout()->createBlock('eav/adminhtml_attribute_set_main_formset') ); + return parent::_prepareLayout(); } - protected function _getHeader() + protected function _getHeader(): string { return Mage::helper('eav')->__('Add New Attribute Set'); } - protected function getSaveButtonHtml() + protected function getSaveButtonHtml(): string { return $this->getChildHtml('save_button'); } - protected function getBackButtonHtml() + protected function getBackButtonHtml(): string { return $this->getChildHtml('back_button'); } - protected function getFormHtml() + protected function getFormHtml(): string { return $this->getChildHtml('setForm'); } diff --git a/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php b/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php index db77c1c17fa..1b3c857ddc6 100644 --- a/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php +++ b/app/code/core/Mage/Eav/Block/Adminhtml/Helper/Form/Boolean.php @@ -2,28 +2,23 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** * Eav form boolean field helper * * @category Mage * @package Mage_Eav - * @author Magento Core Team */ class Mage_Eav_Block_Adminhtml_Helper_Form_Boolean extends Varien_Data_Form_Element_Select { diff --git a/app/code/core/Mage/Eav/Block/Widget/Abstract.php b/app/code/core/Mage/Eav/Block/Widget/Abstract.php index 54c824a876b..21480b6c33f 100644 --- a/app/code/core/Mage/Eav/Block/Widget/Abstract.php +++ b/app/code/core/Mage/Eav/Block/Widget/Abstract.php @@ -2,25 +2,24 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** * Class Mage_Eav_Block_Widget_Abstract * + * @category Mage + * @package Mage_Eav + * * @method Mage_Core_Model_Abstract getAttribute() * @method $this setAttribute(Mage_Eav_Model_Entity_Attribute $value) * @method Mage_Core_Model_Abstract getObject() @@ -33,7 +32,7 @@ class Mage_Eav_Block_Widget_Abstract extends Mage_Core_Block_Template * * @return bool */ - public function isEnabled() + public function isEnabled(): bool { return (bool)$this->getAttribute()->getIsVisible(); } @@ -43,7 +42,7 @@ public function isEnabled() * * @return bool */ - public function isRequired() + public function isRequired(): bool { return (bool)$this->getAttribute()->getIsRequired(); } @@ -51,7 +50,7 @@ public function isRequired() /** * @return string */ - public function getFieldIdFormat() + public function getFieldIdFormat(): string { if (!$this->hasData('field_id_format')) { $this->setData('field_id_format', '%s'); @@ -62,7 +61,7 @@ public function getFieldIdFormat() /** * @return string */ - public function getFieldNameFormat() + public function getFieldNameFormat(): string { if (!$this->hasData('field_name_format')) { $this->setData('field_name_format', '%s'); @@ -70,20 +69,12 @@ public function getFieldNameFormat() return $this->getData('field_name_format'); } - /** - * @param string $field - * @return string - */ - public function getFieldId($field) + public function getFieldId(string $field): string { return sprintf($this->getFieldIdFormat(), $field); } - /** - * @param string $field - * @return string - */ - public function getFieldName($field) + public function getFieldName(string $field): string { return sprintf($this->getFieldNameFormat(), $field); } diff --git a/app/code/core/Mage/Eav/Block/Widget/Boolean.php b/app/code/core/Mage/Eav/Block/Widget/Boolean.php index 5ea9bd04585..e3e1aaf6b82 100644 --- a/app/code/core/Mage/Eav/Block/Widget/Boolean.php +++ b/app/code/core/Mage/Eav/Block/Widget/Boolean.php @@ -2,28 +2,23 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** * Block to render boolean attribute * * @category Mage * @package Mage_Eav - * @author Magento Core Team */ class Mage_Eav_Block_Widget_Boolean extends Mage_Eav_Block_Widget_Abstract { @@ -35,12 +30,10 @@ public function _construct() public function getOptions(): array { - $options = [ + return [ ['value' => '', 'label' => Mage::helper('eav')->__('')], ['value' => '1', 'label' => Mage::helper('eav')->__('Yes')], ['value' => '0', 'label' => Mage::helper('eav')->__('No')] ]; - - return $options; } } diff --git a/app/code/core/Mage/Eav/Block/Widget/Date.php b/app/code/core/Mage/Eav/Block/Widget/Date.php index 9369e123555..c774784cef5 100644 --- a/app/code/core/Mage/Eav/Block/Widget/Date.php +++ b/app/code/core/Mage/Eav/Block/Widget/Date.php @@ -2,32 +2,28 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** - * @method string getTime() - * @method $this setTime(string $value) + * @category Mage + * @package Mage_Eav + * + * @method false|int getTime() + * @method $this setTime(false|int $value) */ class Mage_Eav_Block_Widget_Date extends Mage_Eav_Block_Widget_Abstract { - /** - * @var array - */ - protected $_dateInputs = []; + protected array $_dateInputs = []; public function _construct() { @@ -38,10 +34,9 @@ public function _construct() } /** - * @param string $date * @return $this */ - public function setDate($date) + public function setDate(string $date) { $this->setTime($date ? strtotime($date) : false); $this->setData('date', $date); @@ -74,21 +69,16 @@ public function getYear() /** * Returns format which will be applied for date in javascript - * - * @return string */ - public function getDateFormat() + public function getDateFormat(): string { return Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT); } /** * Add date input html - * - * @param string $code - * @param string $html */ - public function setDateInput($code, $html) + public function setDateInput(string $code, string $html): void { $this->_dateInputs[$code] = $html; } @@ -98,7 +88,7 @@ public function setDateInput($code, $html) * * @return string */ - public function getSortedDateInputs() + public function getSortedDateInputs(): string { $strtr = [ '%b' => '%1$s', diff --git a/app/code/core/Mage/Eav/Block/Widget/Multiselect.php b/app/code/core/Mage/Eav/Block/Widget/Multiselect.php index 3c3266f5c6a..2f17798b565 100644 --- a/app/code/core/Mage/Eav/Block/Widget/Multiselect.php +++ b/app/code/core/Mage/Eav/Block/Widget/Multiselect.php @@ -2,28 +2,23 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** - * Block to render select attribute + * Block to render multi-select attribute * * @category Mage * @package Mage_Eav - * @author Magento Core Team */ class Mage_Eav_Block_Widget_Multiselect extends Mage_Eav_Block_Widget_Abstract { @@ -35,10 +30,8 @@ public function _construct() /** * Get select element extra attributes - * - * @return string */ - public function getFieldParams() + public function getFieldParams(): string { return 'multiple'; } diff --git a/app/code/core/Mage/Eav/Block/Widget/Select.php b/app/code/core/Mage/Eav/Block/Widget/Select.php index c2aa3ff21be..4edc6847acf 100644 --- a/app/code/core/Mage/Eav/Block/Widget/Select.php +++ b/app/code/core/Mage/Eav/Block/Widget/Select.php @@ -2,28 +2,23 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** * Block to render select attribute * * @category Mage * @package Mage_Eav - * @author Magento Core Team */ class Mage_Eav_Block_Widget_Select extends Mage_Eav_Block_Widget_Abstract { diff --git a/app/code/core/Mage/Eav/Block/Widget/Text.php b/app/code/core/Mage/Eav/Block/Widget/Text.php index 543682001d9..dff7c56b977 100644 --- a/app/code/core/Mage/Eav/Block/Widget/Text.php +++ b/app/code/core/Mage/Eav/Block/Widget/Text.php @@ -2,28 +2,23 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** - * Block to render textfield attribute + * Block to render text-field attribute * * @category Mage * @package Mage_Eav - * @author Magento Core Team */ class Mage_Eav_Block_Widget_Text extends Mage_Eav_Block_Widget_Abstract { diff --git a/app/code/core/Mage/Eav/Block/Widget/Textarea.php b/app/code/core/Mage/Eav/Block/Widget/Textarea.php index 77888d350e2..fca813f666f 100644 --- a/app/code/core/Mage/Eav/Block/Widget/Textarea.php +++ b/app/code/core/Mage/Eav/Block/Widget/Textarea.php @@ -2,28 +2,23 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** - * Block to render textarea attribute + * Block to render text-area attribute * * @category Mage * @package Mage_Eav - * @author Magento Core Team */ class Mage_Eav_Block_Widget_Textarea extends Mage_Eav_Block_Widget_Abstract { diff --git a/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php b/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php index 0bbc5768012..7975c9489f2 100644 --- a/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php +++ b/app/code/core/Mage/Eav/Controller/Adminhtml/Attribute/Abstract.php @@ -2,42 +2,35 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** * Attribute controller * * @category Mage * @package Mage_Eav - * @author Magento Core Team */ - abstract class Mage_Eav_Controller_Adminhtml_Attribute_Abstract extends Mage_Adminhtml_Controller_Action { - /** @var string $_entityCode */ - protected $_entityCode; + protected string $_entityCode; - /** @var Mage_Eav_Model_Entity_Type $_entityType */ - protected $_entityType; + protected Mage_Eav_Model_Entity_Type $_entityType; /** - * Controller predispatch method + * Controller pre-dispatch method * * @return Mage_Adminhtml_Controller_Action + * @throws Mage_Core_Exception */ public function preDispatch() { @@ -146,11 +139,8 @@ public function validateAction() /** * Filter post data - * - * @param array $data - * @return array */ - protected function _filterPostData($data) + protected function _filterPostData(array $data): array { if ($data) { //labels @@ -329,7 +319,7 @@ public function deleteAction() ); $this->_redirect('*/*/'); return; - } catch (Exception $e) { + } catch (Throwable $e) { Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); $this->_redirect('*/*/edit', ['attribute_id' => $this->getRequest()->getParam('attribute_id')]); return; diff --git a/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php b/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php index bf7f2994fee..160475f2f15 100644 --- a/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php +++ b/app/code/core/Mage/Eav/Controller/Adminhtml/Set/Abstract.php @@ -2,42 +2,35 @@ /** * OpenMage * - * NOTICE OF LICENSE - * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/osl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * It is also available at https://opensource.org/license/osl-3-0-php * - * @category Mage - * @package Mage_Eav - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ +declare(strict_types=1); + /** * Attribute set controller * * @category Mage * @package Mage_Eav - * @author Magento Core Team */ - abstract class Mage_Eav_Controller_Adminhtml_Set_Abstract extends Mage_Adminhtml_Controller_Action { - /** @var string $_entityCode */ - protected $_entityCode; + protected string $_entityCode; - /** @var Mage_Eav_Model_Entity_Type $_entityType */ - protected $_entityType; + protected Mage_Eav_Model_Entity_Type $_entityType; /** - * Controller predispatch method + * Controller pre-dispatch method * * @return Mage_Adminhtml_Controller_Action + * @throws Mage_Core_Exception */ public function preDispatch() { @@ -142,7 +135,7 @@ public function saveAction() } catch (Mage_Core_Exception $e) { $this->_getSession()->addError($e->getMessage()); $hasError = true; - } catch (Exception $e) { + } catch (Throwable $e) { $this->_getSession()->addException( $e, Mage::helper('eav')->__('An error occurred while saving the attribute set.') diff --git a/app/code/core/Mage/Eav/Helper/Data.php b/app/code/core/Mage/Eav/Helper/Data.php index 7f53014945a..febacd9dda4 100644 --- a/app/code/core/Mage/Eav/Helper/Data.php +++ b/app/code/core/Mage/Eav/Helper/Data.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Eav * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2022-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ @@ -142,11 +142,8 @@ public function getInputTypesValidatorData() * Return information array of attribute input types * Only a small number of settings returned, so we won't break anything in current dataflow * As soon as development process goes on we need to add there all possible settings - * - * @param string $inputType - * @return array */ - public function getAttributeInputTypes($inputType = null) + public function getAttributeInputTypes(?string $inputType = null): array { /** * @todo specify there all relations for properties depending on input type @@ -170,11 +167,8 @@ public function getAttributeInputTypes($inputType = null) /** * Return default attribute backend model by input type - * - * @param string $inputType - * @return string|null */ - public function getAttributeBackendModelByInputType($inputType) + public function getAttributeBackendModelByInputType(string $inputType): ?string { $inputTypes = $this->getAttributeInputTypes(); if (!empty($inputTypes[$inputType]['backend_model'])) { @@ -185,11 +179,8 @@ public function getAttributeBackendModelByInputType($inputType) /** * Return default attribute source model by input type - * - * @param string $inputType - * @return string|null */ - public function getAttributeSourceModelByInputType($inputType) + public function getAttributeSourceModelByInputType(string $inputType): ?string { $inputTypes = $this->getAttributeInputTypes(); if (!empty($inputTypes[$inputType]['source_model'])) { @@ -202,9 +193,8 @@ public function getAttributeSourceModelByInputType($inputType) * Return entity code formatted for humans * * @param Mage_Eav_Model_Entity_Type|string $entityTypeCode - * @return string */ - public function formatTypeCode($entityTypeCode) + public function formatTypeCode($entityTypeCode): string { if ($entityTypeCode instanceof Mage_Eav_Model_Entity_Type) { $entityTypeCode = $entityTypeCode->getEntityTypeCode(); diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute.php b/app/code/core/Mage/Eav/Model/Entity/Attribute.php index d2088472c58..c64206b66bc 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute.php +++ b/app/code/core/Mage/Eav/Model/Entity/Attribute.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Eav * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Eav/Model/Entity/Attribute/Set.php b/app/code/core/Mage/Eav/Model/Entity/Attribute/Set.php index f4284b0ef1d..194b4bf0a67 100644 --- a/app/code/core/Mage/Eav/Model/Entity/Attribute/Set.php +++ b/app/code/core/Mage/Eav/Model/Entity/Attribute/Set.php @@ -27,8 +27,8 @@ * @method int getAttributeSetId(string $value) * @method string getAttributeSetName() * @method $this setAttributeSetName(string $value) - * @method int getEntityTypeId() - * @method $this setEntityTypeId(int $value) + * @method string getEntityTypeId() + * @method $this setEntityTypeId(string $value) * @method Mage_Eav_Model_Entity_Attribute_Group[] getGroups() * @method $this setGroups(Mage_Eav_Model_Entity_Attribute_Group[] $value) * @method int getSortOrder() diff --git a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute.php b/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute.php index 705abca4125..cedf256523a 100644 --- a/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute.php +++ b/app/code/core/Mage/Eav/Model/Resource/Entity/Attribute.php @@ -136,7 +136,7 @@ public function deleteEntity(Mage_Core_Model_Abstract $object) /** * Validate attribute data before save * - * @param Mage_Eav_Model_Entity_Attribute $object + * @param Mage_Catalog_Model_Resource_Eav_Attribute $object * @inheritDoc */ protected function _beforeSave(Mage_Core_Model_Abstract $object) diff --git a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php index 438497e8440..a3e4fe2fb70 100644 --- a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php +++ b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ExportController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_ImportExport * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php index 3575a00b47b..aa88d5e5df2 100644 --- a/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php +++ b/app/code/core/Mage/ImportExport/controllers/Adminhtml/ImportController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_ImportExport * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php b/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php index bc96028993a..9460b9770dd 100644 --- a/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php +++ b/app/code/core/Mage/Index/controllers/Adminhtml/ProcessController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Index * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2020-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2020-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php index fb37e09189e..a51024ded1c 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php +++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/Admin/TokenController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Oauth * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php index bc9ddd14893..53c8e126a1b 100644 --- a/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php +++ b/app/code/core/Mage/Oauth/controllers/Adminhtml/Oauth/AuthorizedTokensController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Oauth * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php index 0bcb2c4d134..37a34ecf974 100644 --- a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php +++ b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Paypal * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php b/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php index 09e5defd4d1..bf59653d732 100644 --- a/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php +++ b/app/code/core/Mage/Widget/controllers/Adminhtml/Widget/InstanceController.php @@ -9,7 +9,7 @@ * @category Mage * @package Mage_Widget * @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) - * @copyright Copyright (c) 2019-2023 The OpenMage Contributors (https://www.openmage.org) + * @copyright Copyright (c) 2019-2024 The OpenMage Contributors (https://www.openmage.org) * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ diff --git a/app/design/adminhtml/default/default/template/eav/attribute/js.phtml b/app/design/adminhtml/default/default/template/eav/attribute/js.phtml index 4f32178b018..1dfdf282655 100644 --- a/app/design/adminhtml/default/default/template/eav/attribute/js.phtml +++ b/app/design/adminhtml/default/default/template/eav/attribute/js.phtml @@ -2,20 +2,19 @@ /** * OpenMage * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License (AFL 3.0) - * that is bundled with this package in the file LICENSE_AFL.txt. - * It is also available through the world-wide-web at this URL: - * http://opensource.org/licenses/afl-3.0.php - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@magento.com so we can send you a copy immediately. + * This source file is subject to the Open Software License (OSL 3.0) + * that is bundled with this package in the file LICENSE.txt. + * It is also available at https://opensource.org/license/osl-3-0-php * + * @category Mage + * @package Mage_Eav + * @copyright Copyright (c) 2024 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +/** * @category design * @package default_default - * @copyright Copyright (c) 2006-2020 Magento, Inc. (http://www.magento.com) - * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ ?>