Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 0 additions & 35 deletions .phpstan.dist.baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,6 @@ parameters:
count: 1
path: app/code/core/Mage/Adminhtml/Block/Report/Grid.php

-
message: "#^Parameter \\#1 \\$from of method Mage_Reports_Model_Resource_Report_Collection\\:\\:setInterval\\(\\) expects int, Zend_Date given\\.$#"
count: 1
path: app/code/core/Mage/Adminhtml/Block/Report/Grid.php

-
message: "#^Parameter \\#2 \\$to of method Mage_Reports_Model_Resource_Report_Collection\\:\\:setInterval\\(\\) expects int, Zend_Date given\\.$#"
count: 1
path: app/code/core/Mage/Adminhtml/Block/Report/Grid.php

-
message: "#^Method Mage_Adminhtml_Block_Report_Grid_Abstract\\:\\:getCollection\\(\\) should return Mage_Core_Model_Resource_Db_Collection_Abstract\\|Mage_Reports_Model_Grouped_Collection but returns Varien_Data_Collection_Db\\|null\\.$#"
count: 1
Expand Down Expand Up @@ -485,11 +475,6 @@ parameters:
count: 2
path: app/code/core/Mage/Adminhtml/Block/Tax/Rule/Grid.php

-
message: "#^Method Mage_Adminhtml_Block_Widget_Container\\:\\:_addButtonChildBlock\\(\\) should return Mage_Adminhtml_Block_Widget_Button but returns Mage_Core_Block_Abstract\\|false\\.$#"
count: 1
path: app/code/core/Mage/Adminhtml/Block/Widget/Container.php

-
message: "#^Method Mage_Eav_Model_Entity_Attribute_Source_Interface\\:\\:getAllOptions\\(\\) invoked with 2 parameters, 0 required\\.$#"
count: 2
Expand Down Expand Up @@ -4515,16 +4500,6 @@ parameters:
count: 4
path: app/code/core/Mage/Reports/Model/Resource/Report/Collection.php

-
message: "#^Property Mage_Reports_Model_Resource_Report_Collection\\:\\:\\$_from \\(string\\) does not accept int\\.$#"
count: 1
path: app/code/core/Mage/Reports/Model/Resource/Report/Collection.php

-
message: "#^Property Mage_Reports_Model_Resource_Report_Collection\\:\\:\\$_to \\(string\\) does not accept int\\.$#"
count: 1
path: app/code/core/Mage/Reports/Model/Resource/Report/Collection.php

-
message: "#^Comparison operation \"\\!\\=\" between array\\|int and 0 results in an error\\.$#"
count: 1
Expand Down Expand Up @@ -5785,11 +5760,6 @@ parameters:
count: 1
path: app/code/core/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Chooser/Layout.php

-
message: "#^Variable \\$productsOptions might not be defined\\.$#"
count: 1
path: app/code/core/Mage/Widget/Block/Adminhtml/Widget/Instance/Edit/Tab/Main/Layout.php

-
message: "#^Cannot call method toOptionArray\\(\\) on Mage_Core_Model_Abstract\\|false\\.$#"
count: 1
Expand Down Expand Up @@ -6660,11 +6630,6 @@ parameters:
count: 1
path: app/design/adminhtml/default/default/template/widget/form/element.phtml

-
message: "#^Variable \\$this might not be defined\\.$#"
count: 23
path: app/design/adminhtml/default/default/template/widget/form/element/gallery.phtml

-
message: "#^Method Mage_Adminhtml_Block_Widget_Grid\\:\\:getEmptyCellColspan\\(\\) invoked with 1 parameter, 0 required\\.$#"
count: 1
Expand Down
102 changes: 50 additions & 52 deletions app/code/core/Mage/Adminhtml/Block/Api/Buttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,80 +20,78 @@
*/
class Mage_Adminhtml_Block_Api_Buttons extends Mage_Adminhtml_Block_Template
{
public function __construct()
{
parent::__construct();
$this->setTemplate('api/userinfo.phtml');
}
public const BUTTON_BACK = 'backButton';
public const BUTTON_DELETE = 'deleteButton';
public const BUTTON_RESET = 'resetButton';
public const BUTTON_SAVE = 'saveButton';

protected $_template = 'api/userinfo.phtml';

/**
* @codeCoverageIgnore
* @inheritDoc
*/
protected function _prepareLayout()
{
$this->setChild(
'backButton',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('adminhtml')->__('Back'),
'onclick' => 'window.location.href=\'' . $this->getUrl('*/*/') . '\'',
'class' => 'back'
])
);

$this->setChild(
'resetButton',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('adminhtml')->__('Reset'),
'onclick' => 'window.location.reload()'
])
);
$this->addButtons();
return parent::_prepareLayout();
}

$this->setChild(
'saveButton',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('adminhtml')->__('Save Role'),
'onclick' => 'roleForm.submit();return false;',
'class' => 'save'
])
);
/**
* @codeCoverageIgnore
*/
protected function addButtons(): void
{
$this->setChild(self::BUTTON_SAVE, $this->getButtonSaveBlock());
$this->setChild(self::BUTTON_BACK, $this->getButtonBackBlock());
$this->setChild(self::BUTTON_RESET, $this->getButtonResetBlock());
$this->setChild(self::BUTTON_DELETE, $this->getButtonDeleteBlock());
}

$this->setChild(
'deleteButton',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('adminhtml')->__('Delete Role'),
'onclick' => 'if(confirm(\'' . Mage::helper('core')->jsQuoteEscape(
Mage::helper('adminhtml')->__('Are you sure you want to do this?')
) . '\')) roleForm.submit(\'' . $this->getUrl('*/*/delete') . '\'); return false;',
'class' => 'delete'
])
);
return parent::_prepareLayout();
public function getButtonBackBlock(): Mage_Adminhtml_Block_Widget_Button
{
return parent::getButtonBlockByType(self::BUTTON_BACK);
}

public function getBackButtonHtml()
public function getButtonDeleteBlock(): Mage_Adminhtml_Block_Widget_Button
{
return $this->getChildHtml('backButton');
return parent::getButtonBlockByType(self::BUTTON_DELETE)
->setLabel(Mage::helper('adminhtml')->__('Delete Role'))
->setOnClick(
'if(confirm(\'' . Mage::helper('core')->jsQuoteEscape(
Mage::helper('adminhtml')->__('Are you sure you want to do this?')
) . '\')) roleForm.submit(\'' . $this->getUrl('*/*/delete') . '\'); return false;'
);
}

public function getResetButtonHtml()
public function getButtonResetBlock(): Mage_Adminhtml_Block_Widget_Button
{
return $this->getChildHtml('resetButton');
return parent::getButtonBlockByType(self::BUTTON_RESET)
->setOnClick('window.location.reload()')
->resetClass();
}

public function getSaveButtonHtml()
public function getButtonSaveBlock(): Mage_Adminhtml_Block_Widget_Button
{
return $this->getChildHtml('saveButton');
return parent::getButtonBlockByType(self::BUTTON_SAVE)
->setLabel(Mage::helper('adminhtml')->__('Save Role'))
->setOnClick('roleForm.submit();return false;');
}

/**
* @inheritDoc
*/
public function getDeleteButtonHtml()
{
if ((int) $this->getRequest()->getParam('rid') == 0) {
return;
return '';
}
return $this->getChildHtml('deleteButton');
return parent::getDeleteButtonHtml();
}

/**
* @codeCoverageIgnore
*/
public function getUser()
{
return Mage::registry('user_data');
Expand Down
84 changes: 41 additions & 43 deletions app/code/core/Mage/Adminhtml/Block/Catalog/Category/Edit/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,71 +22,74 @@
*/
class Mage_Adminhtml_Block_Catalog_Category_Edit_Form extends Mage_Adminhtml_Block_Catalog_Category_Abstract
{
public const BLOCK_TABS = 'tabs';

/**
* Additional buttons on category page
*
* @var array
*/
protected $_additionalButtons = [];

public function __construct()
{
parent::__construct();
$this->setTemplate('catalog/category/edit/form.phtml');
}
protected $_template = 'catalog/category/edit/form.phtml';

/**
* @inheritDoc
*/
protected function _prepareLayout()
{
$category = $this->getCategory();
$category = $this->getCategory();
$categoryId = (int) $category->getId(); // 0 when we create category, otherwise some value for editing category

$this->setChild(
'tabs',
self::BLOCK_TABS,
$this->getLayout()->createBlock('adminhtml/catalog_category_tabs', 'tabs')
);

// Save button
if (!$category->isReadonly()) {
$this->setChild(
'save_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('catalog')->__('Save Category'),
'onclick' => "categorySubmit('" . $this->getSaveUrl() . "', true)",
'class' => 'save'
])
);
$this->setChild(self::BUTTON_SAVE, $this->getButtonSaveBlock());
}

// Delete button
if (!in_array($categoryId, $this->getRootIds()) && $category->isDeleteable()) {
$this->setChild(
'delete_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('catalog')->__('Delete Category'),
'onclick' => "categoryDelete('" . $this->getUrl('*/*/delete', ['_current' => true]) . "', true, {$categoryId})",
'class' => 'delete'
])
);
$this->setChild(self::BUTTON_DELETE, $this->getButtonDeleteBlock());
}

// Reset button
if (!$category->isReadonly()) {
$resetPath = $categoryId ? '*/*/edit' : '*/*/add';
$this->setChild(
'reset_button',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('catalog')->__('Reset'),
'onclick' => "categoryReset('" . $this->getUrl($resetPath, ['_current' => true]) . "',true)"
])
);
$this->setChild(self::BUTTON_RESET, $this->getButtonResetBlock());
}

return parent::_prepareLayout();
}

public function getButtonDeleteBlock(): Mage_Adminhtml_Block_Widget_Button
{
return parent::getButtonBlockByType(self::BUTTON_DELETE)
->setLabel(Mage::helper('catalog')->__('Delete Category'))
->setOnClick("categorySubmit('" . $this->getSaveUrl() . "', true)");
}

public function getButtonResetBlock(): Mage_Adminhtml_Block_Widget_Button
{
$category = $this->getCategory();
$categoryId = (int) $category->getId(); // 0 when we create category, otherwise some value for editing category
$resetPath = $categoryId ? '*/*/edit' : '*/*/add';
return parent::getButtonBlockByType(self::BUTTON_RESET)
->setOnClick("categoryReset('" . $this->getUrl($resetPath, ['_current' => true]) . "',true)")
->resetClass();
}

public function getButtonSaveBlock(): Mage_Adminhtml_Block_Widget_Button
{
$category = $this->getCategory();
$categoryId = (int) $category->getId(); // 0 when we create category, otherwise some value for editing category
return parent::getButtonBlockByType(self::BUTTON_SAVE)
->setLabel(Mage::helper('catalog')->__('Save Category'))
->setOnClick("categoryDelete('" . $this->getUrl('*/*/delete', ['_current' => true]) . "', true, {$categoryId})");
}

public function getStoreConfigurationUrl()
{
$storeId = (int) $this->getRequest()->getParam('store');
Expand All @@ -100,23 +103,18 @@ public function getStoreConfigurationUrl()
return $this->getUrl('*/system_store', $params);
}

public function getDeleteButtonHtml()
{
return $this->getChildHtml('delete_button');
}

public function getSaveButtonHtml()
{
if ($this->hasStoreRootCategory()) {
return $this->getChildHtml('save_button');
return $this->getChildHtml(self::BUTTON_SAVE);
}
return '';
}

public function getResetButtonHtml()
{
if ($this->hasStoreRootCategory()) {
return $this->getChildHtml('reset_button');
return $this->getChildHtml(self::BUTTON_RESET);
}
return '';
}
Expand Down Expand Up @@ -149,7 +147,7 @@ public function addAdditionalButton($alias, $config)
}
$this->setChild(
$alias . '_button',
$this->getLayout()->createBlock('adminhtml/widget_button')->addData($config)
parent::getButtonBlock()->addData($config)
);
$this->_additionalButtons[$alias] = $alias . '_button';
return $this;
Expand All @@ -173,7 +171,7 @@ public function removeAdditionalButton($alias)

public function getTabsHtml()
{
return $this->getChildHtml('tabs');
return $this->getChildHtml(self::BLOCK_TABS);
}

public function getHeader()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ protected function _prepareLayout()
{
parent::_prepareLayout();
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
/** @var Mage_Page_Block_Html_Head $head */
$head = $this->getLayout()->getBlock('head');
if ($head) {
$head->setCanLoadTinyMce(true);
}
}
return $this;
}
Expand Down
Loading
Loading