1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27:
28: class Mage_Adminhtml_System_DesignController extends Mage_Adminhtml_Controller_Action
29: {
30: public function indexAction()
31: {
32: $this->_title($this->__('System'))->_title($this->__('Design'));
33:
34: $this->loadLayout();
35: $this->_setActiveMenu('system');
36: $this->_addContent($this->getLayout()->createBlock('adminhtml/system_design'));
37: $this->renderLayout();
38: }
39:
40: public function gridAction()
41: {
42: $this->getResponse()->setBody($this->getLayout()->createBlock('adminhtml/system_design_grid')->toHtml());
43: }
44:
45: public function newAction()
46: {
47: $this->_forward('edit');
48: }
49:
50: public function editAction()
51: {
52: $this->_title($this->__('System'))->_title($this->__('Design'));
53:
54: $this->loadLayout();
55: $this->_setActiveMenu('system');
56: $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
57:
58: $id = (int) $this->getRequest()->getParam('id');
59: $design = Mage::getModel('core/design');
60:
61: if ($id) {
62: $design->load($id);
63: }
64:
65: $this->_title($design->getId() ? $this->__('Edit Design Change') : $this->__('New Design Change'));
66:
67: Mage::register('design', $design);
68:
69: $this->_addContent($this->getLayout()->createBlock('adminhtml/system_design_edit'));
70: $this->_addLeft($this->getLayout()->createBlock('adminhtml/system_design_edit_tabs', 'design_tabs'));
71:
72: $this->renderLayout();
73: }
74:
75: public function saveAction()
76: {
77: if ($data = $this->getRequest()->getPost()) {
78: $id = (int) $this->getRequest()->getParam('id');
79:
80: $design = Mage::getModel('core/design');
81: if ($id) {
82: $design->load($id);
83: }
84:
85: $design->setData($data['design']);
86: if ($id) {
87: $design->setId($id);
88: }
89: try {
90: $design->save();
91:
92: Mage::getSingleton('adminhtml/session')->addSuccess($this->__('The design change has been saved.'));
93: } catch (Exception $e){
94: Mage::getSingleton('adminhtml/session')
95: ->addError($e->getMessage())
96: ->setDesignData($data);
97: $this->_redirect('*/*/edit', array('id'=>$design->getId()));
98: return;
99: }
100: }
101:
102: $this->_redirect('*/*/');
103: }
104:
105: public function deleteAction()
106: {
107: if ($id = $this->getRequest()->getParam('id')) {
108: $design = Mage::getModel('core/design')->load($id);
109:
110: try {
111: $design->delete();
112:
113: Mage::getSingleton('adminhtml/session')
114: ->addSuccess($this->__('The design change has been deleted.'));
115: } catch (Mage_Exception $e) {
116: Mage::getSingleton('adminhtml/session')
117: ->addError($e->getMessage());
118: } catch (Exception $e) {
119: Mage::getSingleton('adminhtml/session')
120: ->addException($e, $this->__("Cannot delete the design change."));
121: }
122: }
123: $this->getResponse()->setRedirect($this->getUrl('*/*/'));
124: }
125:
126: protected function _isAllowed()
127: {
128: return Mage::getSingleton('admin/session')->isAllowed('system/design');
129: }
130: }
131: