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_Compiler 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 * Compiler process controller 00029 * 00030 * @category Mage 00031 * @package Mage_Compiler 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 class Mage_Compiler_ProcessController extends Mage_Adminhtml_Controller_Action 00035 { 00036 protected $_compiler = null; 00037 00038 public function preDispatch() 00039 { 00040 parent::preDispatch(); 00041 } 00042 00043 /** 00044 * Get compiler process object 00045 * 00046 * @return Mage_Compiler_Model_Process 00047 */ 00048 protected function _getCompiler() 00049 { 00050 if ($this->_compiler === null) { 00051 $this->_compiler = Mage::getModel('compiler/process'); 00052 } 00053 return $this->_compiler; 00054 } 00055 public function indexAction() 00056 { 00057 Mage::getSingleton('adminhtml/session')->addError( 00058 Mage::helper('compiler')->__('Compiler module is now in Beta (not to be used in production environment)') 00059 ); 00060 $this->loadLayout(); 00061 $this->_setActiveMenu('system/tools'); 00062 $this->renderLayout(); 00063 } 00064 00065 public function runAction() 00066 { 00067 try { 00068 $this->_getCompiler()->run(); 00069 Mage::getSingleton('adminhtml/session')->addSuccess( 00070 Mage::helper('compiler')->__('Compilation successfully finished') 00071 ); 00072 } catch (Mage_Core_Exception $e) { 00073 Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); 00074 } catch (Exception $e) { 00075 Mage::getSingleton('adminhtml/session')->addError( 00076 Mage::helper('compiler')->__('Compilation error') 00077 ); 00078 } 00079 $this->_redirect('*/*/'); 00080 } 00081 00082 public function recompileAction() 00083 { 00084 $this->_getCompiler()->clear(); 00085 $this->_redirect('*/*/run'); 00086 } 00087 00088 public function disableAction() 00089 { 00090 $this->_getCompiler()->registerIncludePath(false); 00091 Mage::getSingleton('adminhtml/session')->addSuccess( 00092 Mage::helper('compiler')->__('Compiler include path disabled') 00093 ); 00094 $this->_redirect('*/*/'); 00095 } 00096 00097 public function enableAction() 00098 { 00099 $this->_getCompiler()->registerIncludePath(); 00100 Mage::getSingleton('adminhtml/session')->addSuccess( 00101 Mage::helper('compiler')->__('Compiler include path enabled') 00102 ); 00103 $this->_redirect('*/*/'); 00104 } 00105 00106 protected function _isAllowed() 00107 { 00108 return Mage::getSingleton('admin/session')->isAllowed('compiler'); 00109 } 00110 }