00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Compiler_Block_Process extends Mage_Adminhtml_Block_Template
00036 {
00037
00038
00039
00040
00041
00042 protected $_process;
00043 protected $_validationResult;
00044
00045
00046 protected function _construct()
00047 {
00048 $this->_process = Mage::getModel('compiler/process');
00049 $this->_validationResult = $this->_process->validate();
00050 return parent::_construct();
00051 }
00052
00053
00054
00055
00056
00057
00058 public function getProcess()
00059 {
00060 return $this->_process;
00061 }
00062
00063 protected function _prepareLayout()
00064 {
00065 $this->setChild('run_button',
00066 $this->getLayout()->createBlock('adminhtml/widget_button')
00067 ->setData(array(
00068 'label' => Mage::helper('compiler')->__('Run Compilation Process'),
00069 'onclick' => 'compilationForm.submit();',
00070 'class' => 'save'
00071 )));
00072
00073 if (defined('COMPILER_INCLUDE_PATH')) {
00074 $this->setChild('change_status_button',
00075 $this->getLayout()->createBlock('adminhtml/widget_button')
00076 ->setData(array(
00077 'label' => Mage::helper('compiler')->__('Disable'),
00078 'onclick' => 'setLocation(\'' . $this->getUrl('compiler/process/disable') . '\')',
00079 'class' => 'save'
00080 )));
00081 } else {
00082 $this->setChild('change_status_button',
00083 $this->getLayout()->createBlock('adminhtml/widget_button')
00084 ->setData(array(
00085 'label' => Mage::helper('compiler')->__('Enable'),
00086 'onclick' => 'setLocation(\'' . $this->getUrl('compiler/process/enable') . '\')',
00087 'class' => 'save'
00088 )));
00089 }
00090
00091 return parent::_prepareLayout();
00092 }
00093
00094
00095
00096
00097
00098
00099 protected function getHeader()
00100 {
00101 return Mage::helper('compiler')->__('Compilation (Beta)');
00102 }
00103
00104 public function getChangeStatusButtonHtml()
00105 {
00106 if ($this->getCollectedFilesCount()) {
00107 return $this->getChildHtml('change_status_button');
00108 }
00109 return '';
00110 }
00111
00112
00113
00114
00115
00116
00117 protected function getRunButtonHtml()
00118 {
00119 return $this->getChildHtml('run_button');
00120 }
00121
00122
00123
00124
00125
00126
00127 public function getRunFormAction()
00128 {
00129 return $this->getUrl('compiler/process/recompile');
00130 }
00131
00132
00133
00134
00135
00136
00137 public function canRunCompilation()
00138 {
00139 return empty($this->_validationResult);
00140 }
00141
00142
00143
00144
00145
00146
00147 public function getMessagesBlock()
00148 {
00149 $block = $this->getLayout()->createBlock('core/messages');
00150 foreach ($this->_validationResult as $message) {
00151 $block->addError($message);
00152 }
00153 return $block;
00154 }
00155
00156 public function getCompilationList()
00157 {
00158 return $this->getProcess()->getCompileClassList();
00159 }
00160
00161 public function arrToSting($arr)
00162 {
00163 return implode("\n", $arr);
00164 }
00165
00166 public function getCompilerState()
00167 {
00168 if ($this->getCollectedFilesCount() > 0) {
00169 return $this->__('Compiled');
00170 } else {
00171 return $this->__('Not Compiled');
00172 }
00173 }
00174
00175 public function getCompilerStatus()
00176 {
00177 if (defined('COMPILER_INCLUDE_PATH')) {
00178 return $this->__('Enabled');
00179 } else {
00180 return $this->__('Disabled');
00181 }
00182 }
00183
00184 public function getCollectedFilesCount()
00185 {
00186 if (!$this->hasData('collected_files_count')) {
00187 $this->setData('collected_files_count', $this->getProcess()->getCollectedFilesCount());
00188 }
00189 return $this->_getData('collected_files_count');
00190 }
00191
00192 public function getCompiledFilesCount()
00193 {
00194 if (!$this->hasData('compiled_files_count')) {
00195 $this->setData('compiled_files_count', $this->getProcess()->getCompiledFilesCount());
00196 }
00197 return $this->_getData('compiled_files_count');
00198 }
00199 }