1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Compiler
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * Compiler process controller
29: *
30: * @category Mage
31: * @package Mage_Compiler
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Compiler_Adminhtml_Compiler_ProcessController extends Mage_Adminhtml_Controller_Action
35: {
36: protected $_compiler = null;
37:
38: public function preDispatch()
39: {
40: parent::preDispatch();
41: }
42:
43: /**
44: * Get compiler process object
45: *
46: * @return Mage_Compiler_Model_Process
47: */
48: protected function _getCompiler()
49: {
50: if ($this->_compiler === null) {
51: $this->_compiler = Mage::getModel('compiler/process');
52: }
53: return $this->_compiler;
54: }
55: public function indexAction()
56: {
57: $this->_title($this->__('System'))->_title($this->__('Tools'))->_title($this->__('Compilation'));
58:
59: $this->loadLayout();
60: $this->_setActiveMenu('system/tools');
61: $this->renderLayout();
62: }
63:
64: public function runAction()
65: {
66: try {
67: $this->_getCompiler()->run();
68: Mage::getSingleton('adminhtml/session')->addSuccess(
69: Mage::helper('compiler')->__('The compilation has completed.')
70: );
71: } catch (Mage_Core_Exception $e) {
72: Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
73: } catch (Exception $e) {
74: Mage::getSingleton('adminhtml/session')->addError(
75: Mage::helper('compiler')->__('Compilation error')
76: );
77: }
78: $this->_redirect('*/*/');
79: }
80:
81: public function recompileAction()
82: {
83: /**
84: * Add redirect heades before clear compiled sources
85: */
86: $this->_redirect('*/*/run');
87: $this->_getCompiler()->clear();
88: $this->getResponse()->sendHeaders();
89: exit;
90: }
91:
92: public function disableAction()
93: {
94: $this->_getCompiler()->registerIncludePath(false);
95: Mage::getSingleton('adminhtml/session')->addSuccess(
96: Mage::helper('compiler')->__('Compiler include path is disabled.')
97: );
98: $this->_redirect('*/*/');
99: }
100:
101: public function enableAction()
102: {
103: $this->_getCompiler()->registerIncludePath();
104: Mage::getSingleton('adminhtml/session')->addSuccess(
105: Mage::helper('compiler')->__('Compiler include path is enabled.')
106: );
107: $this->_redirect('*/*/');
108: }
109:
110: protected function _isAllowed()
111: {
112: return Mage::getSingleton('admin/session')->isAllowed('system/tools/compiler');
113: }
114: }
115: