Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added helper for admin button onclick actions #2784

Merged
merged 8 commits into from
Dec 25, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function _prepareForm()
'name' => 'user_id',
]);
} else {
if (! $model->hasData('is_active')) {
if (!$model->hasData('is_active')) {
$model->setIsActive(1);
}
}
Expand Down
16 changes: 10 additions & 6 deletions app/code/core/Mage/Adminhtml/Block/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


/**
* @category Mage
* @package Mage_Adminhtml
Expand All @@ -37,23 +38,24 @@ public function __construct()
$this->_removeButton('add');
$this->_addButton('flush_magento', [
'label' => Mage::helper('core')->__('Flush OpenMage Cache'),
'onclick' => 'setLocation(\'' . $this->getFlushSystemUrl() . '\')',
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getFlushSystemUrl()),
'class' => 'delete',
]);

$confirmationMessage = Mage::helper('core')->jsQuoteEscape(
Mage::helper('core')->__('Cache storage may contain additional data. Are you sure that you want flush it?')
);
$this->_addButton('flush_system', [
'label' => Mage::helper('core')->__('Flush Cache Storage'),
'onclick' => 'confirmSetLocation(\'' . $confirmationMessage . '\', \'' . $this->getFlushStorageUrl()
. '\')',
'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs(
$this->getFlushStorageUrl(),
Mage::helper('core')->__('Cache storage may contain additional data. Are you sure that you want flush it?')
),
'class' => 'delete',
]);
}

/**
* Get url for clean cache storage
*
* @return string
*/
public function getFlushStorageUrl()
{
Expand All @@ -62,6 +64,8 @@ public function getFlushStorageUrl()

/**
* Get url for clean cache storage
*
* @return string
*/
public function getFlushSystemUrl()
{
Expand Down
3 changes: 2 additions & 1 deletion app/code/core/Mage/Adminhtml/Block/Catalog/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/


/**
* Catalog manage products block
*
Expand All @@ -44,7 +45,7 @@ protected function _prepareLayout()
{
$this->_addButton('add_new', [
'label' => Mage::helper('catalog')->__('Add Product'),
'onclick' => "setLocation('{$this->getUrl('*/*/new')}')",
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/new')),
'class' => 'add'
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct()
$this->_updateButton('save', 'label', Mage::helper('catalog')->__('Save Attribute'));
$this->_updateButton('save', 'onclick', 'saveAttribute()');

if (! Mage::registry('entity_attribute')->getIsUserDefined()) {
if (!Mage::registry('entity_attribute')->getIsUserDefined()) {
$this->_removeButton('delete');
} else {
$this->_updateButton('delete', 'label', Mage::helper('catalog')->__('Delete Attribute'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Mage_Adminhtml_Block_Catalog_Product_Attribute_Set_Main extends Mage_Admin
{
/**
* Initialize template
*
*/
protected function _construct()
{
Expand Down Expand Up @@ -78,7 +77,7 @@ protected function _prepareLayout()
'back_button',
$this->getLayout()->createBlock('adminhtml/widget_button')->setData([
'label' => Mage::helper('catalog')->__('Back'),
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/') . '\')',
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/')),
'class' => 'back'
])
);
Expand All @@ -100,14 +99,14 @@ protected function _prepareLayout()
])
);

$deleteConfirmMessage = $this->jsQuoteEscape(Mage::helper('catalog')
->__('All products of this set will be deleted! Are you sure you want to delete this attribute set?'));
$deleteUrl = $this->getUrlSecure('*/*/delete', ['id' => $setId]);
$this->setChild(
'delete_button',
$this->getLayout()->createBlock('adminhtml/widget_button')->setData([
'label' => Mage::helper('catalog')->__('Delete Attribute Set'),
'onclick' => 'deleteConfirm(\'' . $deleteConfirmMessage . '\', \'' . $deleteUrl . '\')',
'onclick' => Mage::helper('core/js')->getDeleteConfirmJs(
$this->getUrlSecure('*/*/delete', ['id' => $setId]),
Mage::helper('catalog')->__('All products of this set will be deleted! Are you sure you want to delete this attribute set?')
),
'class' => 'delete'
])
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ protected function _construct()
$this->setTemplate('catalog/product/attribute/set/toolbar/add.phtml');
}

/**
* @inheritDoc
*/
protected function _prepareLayout()
{
$this->setChild(
Expand All @@ -47,7 +50,7 @@ protected function _prepareLayout()
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('catalog')->__('Back'),
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/') . '\')',
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/')),
'class' => 'back'
])
);
Expand All @@ -59,21 +62,33 @@ protected function _prepareLayout()
return parent::_prepareLayout();
}

/**
* @return string
*/
protected function _getHeader()
{
return Mage::helper('catalog')->__('Add New Attribute Set');
}

/**
* @return string
*/
protected function getSaveButtonHtml()
{
return $this->getChildHtml('save_button');
}

/**
* @return string
*/
protected function getBackButtonHtml()
{
return $this->getChildHtml('back_button');
}

/**
* @return string
*/
protected function getFormHtml()
{
return $this->getChildHtml('setForm');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,42 @@ public function __construct()
$this->setTemplate('catalog/product/attribute/set/toolbar/main.phtml');
}

/**
* @inheritDoc
*/
protected function _prepareLayout()
{
$this->setChild(
'addButton',
$this->getLayout()->createBlock('adminhtml/widget_button')
->setData([
'label' => Mage::helper('catalog')->__('Add New Set'),
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/add') . '\')',
'class' => 'add',
'onclick' => Mage::helper('core/js')->getSetLocationJs($this->getUrl('*/*/add')),
'class' => 'add',
])
);
return parent::_prepareLayout();
}

/**
* @return string
*/
protected function getNewButtonHtml()
{
return $this->getChildHtml('addButton');
}

/**
* @return string
*/
protected function _getHeader()
{
return Mage::helper('catalog')->__('Manage Attribute Sets');
}

/**
* @return string
*/
protected function _toHtml()
{
Mage::dispatchEvent('adminhtml_catalog_product_attribute_set_toolbar_main_html_before', ['block' => $this]);
Expand Down
Loading