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
31 changes: 17 additions & 14 deletions app/code/core/Mage/Adminhtml/Block/Cms/Page/Edit/Tab/Design.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Adminhtml
*/

use Mage_Cms_Api_Data_PageInterface as PageInterface;

/**
* @package Mage_Adminhtml
*/
Expand All @@ -23,6 +25,7 @@ public function __construct()

/**
* @inheritDoc
* @throws Exception
*/
protected function _prepareForm()
{
Expand All @@ -47,8 +50,8 @@ protected function _prepareForm()
'disabled' => $isElementDisabled,
]);

$layoutFieldset->addField('root_template', 'select', [
'name' => 'root_template',
$layoutFieldset->addField(PageInterface::DATA_ROOT_TEMPLATE, 'select', [
'name' => PageInterface::DATA_ROOT_TEMPLATE,
'label' => Mage::helper('cms')->__('Layout'),
'required' => true,
'values' => Mage::getSingleton('page/source_layout')->toOptionArray(),
Expand All @@ -58,8 +61,8 @@ protected function _prepareForm()
$model->setRootTemplate(Mage::getSingleton('page/source_layout')->getDefaultValue());
}

$layoutFieldset->addField('layout_update_xml', 'textarea', [
'name' => 'layout_update_xml',
$layoutFieldset->addField(PageInterface::DATA_LAYOUT_UPDATE_XML, 'textarea', [
'name' => PageInterface::DATA_LAYOUT_UPDATE_XML,
'label' => Mage::helper('cms')->__('Layout Update XML'),
'style' => 'height:24em;',
'disabled' => $isElementDisabled,
Expand All @@ -75,40 +78,40 @@ protected function _prepareForm()
Mage_Core_Model_Locale::FORMAT_TYPE_SHORT,
);

$designFieldset->addField('custom_theme_from', 'date', [
'name' => 'custom_theme_from',
$designFieldset->addField(PageInterface::DATA_CUSTOM_THEME_FROM, 'date', [
'name' => PageInterface::DATA_CUSTOM_THEME_FROM,
'label' => Mage::helper('cms')->__('Custom Design From'),
'image' => $this->getSkinUrl('images/grid-cal.gif'),
'format' => $dateFormatIso,
'disabled' => $isElementDisabled,
'class' => 'validate-date validate-date-range date-range-custom_theme-from',
]);

$designFieldset->addField('custom_theme_to', 'date', [
'name' => 'custom_theme_to',
$designFieldset->addField(PageInterface::DATA_CUSTOM_THEME_TO, 'date', [
'name' => PageInterface::DATA_CUSTOM_THEME_TO,
'label' => Mage::helper('cms')->__('Custom Design To'),
'image' => $this->getSkinUrl('images/grid-cal.gif'),
'format' => $dateFormatIso,
'disabled' => $isElementDisabled,
'class' => 'validate-date validate-date-range date-range-custom_theme-to',
]);

$designFieldset->addField('custom_theme', 'select', [
'name' => 'custom_theme',
$designFieldset->addField(PageInterface::DATA_CUSTOM_THEME, 'select', [
'name' => PageInterface::DATA_CUSTOM_THEME,
'label' => Mage::helper('cms')->__('Custom Theme'),
'values' => Mage::getModel('core/design_source_design')->getAllOptions(),
'disabled' => $isElementDisabled,
]);

$designFieldset->addField('custom_root_template', 'select', [
'name' => 'custom_root_template',
$designFieldset->addField(PageInterface::DATA_CUSTOM_ROOT_TEMPLATE, 'select', [
'name' => PageInterface::DATA_CUSTOM_ROOT_TEMPLATE,
'label' => Mage::helper('cms')->__('Custom Layout'),
'values' => Mage::getSingleton('page/source_layout')->toOptionArray(true),
'disabled' => $isElementDisabled,
]);

$designFieldset->addField('custom_layout_update_xml', 'textarea', [
'name' => 'custom_layout_update_xml',
$designFieldset->addField(PageInterface::DATA_CUSTOM_LAYOUT_UPDATE_XML, 'textarea', [
'name' => PageInterface::DATA_CUSTOM_LAYOUT_UPDATE_XML,
'label' => Mage::helper('cms')->__('Custom Layout Update XML'),
'style' => 'height:24em;',
'disabled' => $isElementDisabled,
Expand Down
42 changes: 24 additions & 18 deletions app/code/core/Mage/Adminhtml/controllers/Cms/BlockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @package Mage_Adminhtml
*/

use Mage_Cms_Api_Data_BlockInterface as BlockInterface;

/**
* Cms manage blocks controller
*
Expand Down Expand Up @@ -49,6 +51,8 @@ protected function _initAction()

/**
* Index action
*
* @throws Mage_Core_Exception
*/
public function indexAction()
{
Expand All @@ -69,18 +73,20 @@ public function newAction()

/**
* Edit CMS block
*
* @throws Mage_Core_Exception
*/
public function editAction()
{
$this->_title($this->__('CMS'))->_title($this->__('Static Blocks'));

// 1. Get ID and create model
$id = $this->getRequest()->getParam('block_id');
$blockId = $this->getRequest()->getParam(BlockInterface::DATA_ID);
$model = Mage::getModel('cms/block');

// 2. Initial checking
if ($id) {
$model->load($id);
if ($blockId) {
$model->load($blockId);
if (!$model->getId()) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('cms')->__('This block no longer exists.'));
$this->_redirect('*/*/');
Expand All @@ -101,20 +107,22 @@ public function editAction()

// 5. Build edit form
$this->_initAction()
->_addBreadcrumb($id ? Mage::helper('cms')->__('Edit Block') : Mage::helper('cms')->__('New Block'), $id ? Mage::helper('cms')->__('Edit Block') : Mage::helper('cms')->__('New Block'))
->_addBreadcrumb($blockId ? Mage::helper('cms')->__('Edit Block') : Mage::helper('cms')->__('New Block'), $blockId ? Mage::helper('cms')->__('Edit Block') : Mage::helper('cms')->__('New Block'))
->renderLayout();
}

/**
* Save action
*
* @throws Mage_Core_Exception
*/
public function saveAction()
{
// check if data sent
if ($data = $this->getRequest()->getPost()) {
$id = $this->getRequest()->getParam('block_id');
$model = Mage::getModel('cms/block')->load($id);
if (!$model->getId() && $id) {
$blockId = $this->getRequest()->getParam(BlockInterface::DATA_ID);
$model = Mage::getModel('cms/block')->load($blockId);
if (!$model->getId() && $blockId) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('cms')->__('This block no longer exists.'));
$this->_redirect('*/*/');
return;
Expand All @@ -135,20 +143,20 @@ public function saveAction()

// check if 'Save and Continue'
if ($this->getRequest()->getParam('back')) {
$this->_redirect('*/*/edit', ['block_id' => $model->getId()]);
$this->_redirect('*/*/edit', [BlockInterface::DATA_ID => $model->getId()]);
return;
}

// go to grid
$this->_redirect('*/*/');
return;
} catch (Exception $e) {
} catch (Exception $exception) {
// display error message
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->addError($exception->getMessage());
// save data in session
Mage::getSingleton('adminhtml/session')->setFormData($data);
// redirect to edit form
$this->_redirect('*/*/edit', ['block_id' => $this->getRequest()->getParam('block_id')]);
$this->_redirect('*/*/edit', [BlockInterface::DATA_ID => $this->getRequest()->getParam(BlockInterface::DATA_ID)]);
return;
}
}
Expand All @@ -162,24 +170,22 @@ public function saveAction()
public function deleteAction()
{
// check if we know what should be deleted
if ($id = $this->getRequest()->getParam('block_id')) {
$title = '';
if ($blockId = $this->getRequest()->getParam(BlockInterface::DATA_ID)) {
try {
// init model and delete
$model = Mage::getModel('cms/block');
$model->load($id);
$title = $model->getTitle();
$model->load($blockId);
$model->delete();
// display success message
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('cms')->__('The block has been deleted.'));
// go to grid
$this->_redirect('*/*/');
return;
} catch (Exception $e) {
} catch (Exception $exception) {
// display error message
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->addError($exception->getMessage());
// go back to edit form
$this->_redirect('*/*/edit', ['block_id' => $id]);
$this->_redirect('*/*/edit', [BlockInterface::DATA_ID => $blockId]);
return;
}
}
Expand Down
Loading
Loading