00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Adminhtml 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 00028 class Mage_Adminhtml_System_DesignController extends Mage_Adminhtml_Controller_Action 00029 { 00030 public function indexAction() 00031 { 00032 $this->loadLayout(); 00033 $this->_setActiveMenu('system'); 00034 $this->_addContent($this->getLayout()->createBlock('adminhtml/system_design')); 00035 $this->renderLayout(); 00036 } 00037 00038 public function gridAction() 00039 { 00040 $this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/system_design_grid')->toHtml()); 00041 } 00042 00043 public function newAction() 00044 { 00045 $this->_forward('edit'); 00046 } 00047 00048 public function editAction() 00049 { 00050 $this->loadLayout(); 00051 $this->_setActiveMenu('system'); 00052 $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); 00053 00054 $id = (int) $this->getRequest()->getParam('id'); 00055 $design = Mage::getModel('core/design'); 00056 00057 if ($id) { 00058 $design->load($id); 00059 } 00060 00061 Mage::register('design', $design); 00062 00063 $this->_addContent($this->getLayout()->createBlock('adminhtml/system_design_edit')); 00064 $this->_addLeft($this->getLayout()->createBlock('adminhtml/system_design_edit_tabs', 'design_tabs')); 00065 00066 $this->renderLayout(); 00067 } 00068 00069 public function saveAction() 00070 { 00071 if ($data = $this->getRequest()->getPost()) { 00072 $id = (int) $this->getRequest()->getParam('id'); 00073 00074 $design = Mage::getModel('core/design'); 00075 if ($id) { 00076 $design->load($id); 00077 } 00078 00079 $design->setData($data['design']); 00080 if ($id) { 00081 $design->setId($id); 00082 } 00083 try { 00084 $design->save(); 00085 00086 Mage::getSingleton('adminhtml/session')->addSuccess($this->__('Design change saved')); 00087 } catch (Exception $e){ 00088 Mage::getSingleton('adminhtml/session') 00089 ->addError($e->getMessage()) 00090 ->setDesignData($data); 00091 $this->_redirect('*/*/edit', array('id'=>$design->getId())); 00092 return; 00093 } 00094 } 00095 00096 $this->_redirect('*/*/'); 00097 } 00098 00099 public function deleteAction() 00100 { 00101 if ($id = $this->getRequest()->getParam('id')) { 00102 $design = Mage::getModel('core/design') 00103 ->setId($id); 00104 00105 try { 00106 $design->delete(); 00107 00108 Mage::getSingleton('adminhtml/session') 00109 ->addSuccess($this->__('Design change deleted')); 00110 } catch (Mage_Exception $e) { 00111 Mage::getSingleton('adminhtml/session') 00112 ->addError($e->getMessage()); 00113 } catch (Exception $e) { 00114 Mage::getSingleton('adminhtml/session') 00115 ->addException($e, $this->__("Can't delete design change")); 00116 } 00117 } 00118 $this->getResponse()->setRedirect($this->getUrl('*/*/')); 00119 } 00120 00121 protected function _isAllowed() 00122 { 00123 return Mage::getSingleton('admin/session')->isAllowed('system/design'); 00124 } 00125 }