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: class Mage_Adminhtml_Block_System_Config_Dwstree extends Mage_Adminhtml_Block_Widget_Tabs
35: {
36: public function __construct()
37: {
38: parent::__construct();
39:
40: $this->setId('system_config_dwstree');
41: $this->setDestElementId('system_config_form');
42: }
43:
44: public function initTabs()
45: {
46: $section = $this->getRequest()->getParam('section');
47:
48: $curWebsite = $this->getRequest()->getParam('website');
49: $curStore = $this->getRequest()->getParam('store');
50:
51: $websitesConfig = Mage::getConfig()->getNode('websites');
52: $storesConfig = Mage::getConfig()->getNode('stores');
53:
54: $this->addTab('default', array(
55: 'label' => Mage::helper('adminhtml')->__('Default Config'),
56: 'url' => $this->getUrl('*/*/*', array('section'=>$section)),
57: 'class' => 'default',
58: ));
59:
60: foreach ($websitesConfig->children() as $wCode=>$wConfig) {
61: $wName = (string)$wConfig->descend('system/website/name');
62: $wUrl = $this->getUrl('*/*/*', array('section'=>$section, 'website'=>$wCode));
63: $this->addTab('website_'.$wCode, array(
64: 'label' => $wName,
65: 'url' => $wUrl,
66: 'class' => 'website',
67: ));
68: if ($curWebsite===$wCode) {
69: if ($curStore) {
70: $this->_addBreadcrumb($wName, '', $wUrl);
71: } else {
72: $this->_addBreadcrumb($wName);
73: }
74: }
75: foreach ($wConfig->descend('system/stores')->children() as $sCode=>$sId) {
76: $sName = (string)$storesConfig->descend($sCode.'/system/store/name');
77: $this->addTab('store_'.$sCode, array(
78: 'label' => $sName,
79: 'url' => $this->getUrl('*/*/*', array('section'=>$section, 'website'=>$wCode, 'store'=>$sCode)),
80: 'class' => 'store',
81: ));
82: if ($curStore===$sCode) {
83: $this->_addBreadcrumb($sName);
84: }
85: }
86: }
87: if ($curStore) {
88: $this->setActiveTab('store_'.$curStore);
89: } elseif ($curWebsite) {
90: $this->setActiveTab('website_'.$curWebsite);
91: } else {
92: $this->setActiveTab('default');
93: }
94:
95: return $this;
96: }
97: }
98: