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_Block_System_Config_Form_Fieldset_Modules_DisableOutput
29: extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
30: {
31: protected $_dummyElement;
32: protected $_fieldRenderer;
33: protected $_values;
34:
35: public function render(Varien_Data_Form_Element_Abstract $element)
36: {
37: $html = $this->_getHeaderHtml($element);
38:
39: $modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());
40:
41: $dispatchResult = new Varien_Object($modules);
42: Mage::dispatchEvent(
43: 'adminhtml_system_config_advanced_disableoutput_render_before',
44: array('modules' => $dispatchResult)
45: );
46: $modules = $dispatchResult->toArray();
47:
48: sort($modules);
49:
50: foreach ($modules as $moduleName) {
51: if ($moduleName==='Mage_Adminhtml') {
52: continue;
53: }
54: $html.= $this->_getFieldHtml($element, $moduleName);
55: }
56: $html .= $this->_getFooterHtml($element);
57:
58: return $html;
59: }
60:
61: protected function _getDummyElement()
62: {
63: if (empty($this->_dummyElement)) {
64: $this->_dummyElement = new Varien_Object(array('show_in_default'=>1, 'show_in_website'=>1));
65: }
66: return $this->_dummyElement;
67: }
68:
69: protected function _getFieldRenderer()
70: {
71: if (empty($this->_fieldRenderer)) {
72: $this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
73: }
74: return $this->_fieldRenderer;
75: }
76:
77: protected function _getValues()
78: {
79: if (empty($this->_values)) {
80: $this->_values = array(
81: array('label'=>Mage::helper('adminhtml')->__('Enable'), 'value'=>0),
82: array('label'=>Mage::helper('adminhtml')->__('Disable'), 'value'=>1),
83: );
84: }
85: return $this->_values;
86: }
87:
88: protected function _getFieldHtml($fieldset, $moduleName)
89: {
90: $configData = $this->getConfigData();
91: $path = 'advanced/modules_disable_output/'.$moduleName;
92: if (isset($configData[$path])) {
93: $data = $configData[$path];
94: $inherit = false;
95: } else {
96: $data = (int)(string)$this->getForm()->getConfigRoot()->descend($path);
97: $inherit = true;
98: }
99:
100: $e = $this->_getDummyElement();
101:
102: $field = $fieldset->addField($moduleName, 'select',
103: array(
104: 'name' => 'groups[modules_disable_output][fields]['.$moduleName.'][value]',
105: 'label' => $moduleName,
106: 'value' => $data,
107: 'values' => $this->_getValues(),
108: 'inherit' => $inherit,
109: 'can_use_default_value' => $this->getForm()->canUseDefaultValue($e),
110: 'can_use_website_value' => $this->getForm()->canUseWebsiteValue($e),
111: ))->setRenderer($this->_getFieldRenderer());
112:
113: return $field->toHtml();
114: }
115: }
116: