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: 29: 30: 31: 32: 33: 34:
35: class Mage_Compiler_Block_Process extends Mage_Adminhtml_Block_Template
36: {
37: 38: 39: 40: 41:
42: protected $_process;
43: protected $_validationResult;
44:
45:
46: protected function _construct()
47: {
48: $this->_process = Mage::getModel('compiler/process');
49: $this->_validationResult = $this->_process->validate();
50: return parent::_construct();
51: }
52:
53: 54: 55: 56: 57:
58: public function getProcess()
59: {
60: return $this->_process;
61: }
62:
63: protected function _prepareLayout()
64: {
65: $this->setChild('run_button',
66: $this->getLayout()->createBlock('adminhtml/widget_button')
67: ->setData(array(
68: 'label' => Mage::helper('compiler')->__('Run Compilation Process'),
69: 'onclick' => 'compilationForm.submit();',
70: 'class' => 'save'
71: )));
72:
73: if (defined('COMPILER_INCLUDE_PATH')) {
74: $this->setChild('change_status_button',
75: $this->getLayout()->createBlock('adminhtml/widget_button')
76: ->setData(array(
77: 'label' => Mage::helper('compiler')->__('Disable'),
78: 'onclick' => 'setLocation(\'' . $this->getUrl('*/compiler_process/disable') . '\')',
79: 'class' => 'save'
80: )));
81: } else {
82: $this->setChild('change_status_button',
83: $this->getLayout()->createBlock('adminhtml/widget_button')
84: ->setData(array(
85: 'label' => Mage::helper('compiler')->__('Enable'),
86: 'onclick' => 'setLocation(\'' . $this->getUrl('*/compiler_process/enable') . '\')',
87: 'class' => 'save'
88: )));
89: }
90:
91: return parent::_prepareLayout();
92: }
93:
94: 95: 96: 97: 98:
99: protected function ()
100: {
101: return Mage::helper('compiler')->__('Compilation');
102: }
103:
104: public function getChangeStatusButtonHtml()
105: {
106: if ($this->getCollectedFilesCount()) {
107: return $this->getChildHtml('change_status_button');
108: }
109: return '';
110: }
111:
112: 113: 114: 115: 116:
117: protected function getRunButtonHtml()
118: {
119: return $this->getChildHtml('run_button');
120: }
121:
122: 123: 124: 125: 126:
127: public function getRunFormAction()
128: {
129: return $this->getUrl('*/compiler_process/recompile');
130: }
131:
132: 133: 134: 135: 136:
137: public function canRunCompilation()
138: {
139: return empty($this->_validationResult);
140: }
141:
142: 143: 144: 145: 146:
147: public function getMessagesBlock()
148: {
149: $block = $this->getLayout()->createBlock('core/messages');
150: foreach ($this->_validationResult as $message) {
151: $block->addError($message);
152: }
153: return $block;
154: }
155:
156: public function getCompilationList()
157: {
158: return $this->getProcess()->getCompileClassList();
159: }
160:
161: public function arrToSting($arr)
162: {
163: return implode("\n", $arr);
164: }
165:
166: public function getCompilerState()
167: {
168: if ($this->getCollectedFilesCount() > 0) {
169: return $this->__('Compiled');
170: } else {
171: return $this->__('Not Compiled');
172: }
173: }
174:
175: public function getCompilerStatus()
176: {
177: if (defined('COMPILER_INCLUDE_PATH')) {
178: return $this->__('Enabled');
179: } else {
180: return $this->__('Disabled');
181: }
182: }
183:
184: public function getCollectedFilesCount()
185: {
186: if (!$this->hasData('collected_files_count')) {
187: $this->setData('collected_files_count', $this->getProcess()->getCollectedFilesCount());
188: }
189: return $this->_getData('collected_files_count');
190: }
191:
192: public function getCompiledFilesCount()
193: {
194: if (!$this->hasData('compiled_files_count')) {
195: $this->setData('compiled_files_count', $this->getProcess()->getCompiledFilesCount());
196: }
197: return $this->_getData('compiled_files_count');
198: }
199: }
200: