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_Adminhtml_Model_Config extends Varien_Simplexml_Config
00036 {
00037
00038
00039
00040
00041
00042
00043 protected $_sections;
00044
00045
00046
00047
00048
00049
00050 protected $_tabs;
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 public function getSections($sectionCode=null, $websiteCode=null, $storeCode=null)
00061 {
00062 if (empty($this->_sections)) {
00063 $this->_initSectionsAndTabs();
00064 }
00065
00066 return $this->_sections;
00067 }
00068
00069
00070
00071
00072
00073
00074 public function getTabs()
00075 {
00076 if (empty($this->_tabs)) {
00077 $this->_initSectionsAndTabs();
00078 }
00079
00080 return $this->_tabs;
00081 }
00082
00083 protected function _initSectionsAndTabs()
00084 {
00085 $mergeConfig = Mage::getModel('core/config_base');
00086
00087 $config = Mage::getConfig()->loadModulesConfiguration('system.xml');
00088
00089 $this->_sections = $config->getNode('sections');
00090
00091 $this->_tabs = $config->getNode('tabs');
00092 }
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 public function getSection($sectionCode=null, $websiteCode=null, $storeCode=null)
00105 {
00106
00107 if ($sectionCode){
00108 return $this->getSections()->$sectionCode;
00109 } elseif ($websiteCode) {
00110 return $this->getSections()->$websiteCode;
00111 } elseif ($storeCode) {
00112 return $this->getSections()->$storeCode;
00113 }
00114 }
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 public function hasChildren ($node, $websiteCode=null, $storeCode=null, $isField=false)
00126 {
00127 $showTab = false;
00128 if ($storeCode) {
00129 if (isset($node->show_in_store)) {
00130 if ((int)$node->show_in_store) {
00131 $showTab=true;
00132 }
00133 }
00134 }elseif ($websiteCode) {
00135 if (isset($node->show_in_website)) {
00136 if ((int)$node->show_in_website) {
00137 $showTab=true;
00138 }
00139 }
00140 } elseif (isset($node->show_in_default)) {
00141 if ((int)$node->show_in_default) {
00142 $showTab=true;
00143 }
00144 }
00145 if ($showTab) {
00146 if (isset($node->groups)) {
00147 foreach ($node->groups->children() as $children){
00148 if ($this->hasChildren ($children, $websiteCode, $storeCode)) {
00149 return true;
00150 }
00151
00152 }
00153 }elseif (isset($node->fields)) {
00154
00155 foreach ($node->fields->children() as $children){
00156 if ($this->hasChildren ($children, $websiteCode, $storeCode, true)) {
00157 return true;
00158 }
00159 }
00160 } else {
00161 return true;
00162 }
00163 }
00164 return false;
00165
00166 }
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 function getAttributeModule($sectionNode = null, $groupNode = null, $fieldNode = null)
00177 {
00178 $moduleName = 'adminhtml';
00179 if (is_object($sectionNode) && method_exists($sectionNode, 'attributes')) {
00180 $sectionAttributes = $sectionNode->attributes();
00181 $moduleName = isset($sectionAttributes['module']) ? (string)$sectionAttributes['module'] : $moduleName;
00182 }
00183 if (is_object($groupNode) && method_exists($groupNode, 'attributes')) {
00184 $groupAttributes = $groupNode->attributes();
00185 $moduleName = isset($groupAttributes['module']) ? (string)$groupAttributes['module'] : $moduleName;
00186 }
00187 if (is_object($fieldNode) && method_exists($fieldNode, 'attributes')) {
00188 $fieldAttributes = $fieldNode->attributes();
00189 $moduleName = isset($fieldAttributes['module']) ? (string)$fieldAttributes['module'] : $moduleName;
00190 }
00191
00192 return $moduleName;
00193 }
00194
00195 }