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_Switcher extends Mage_Adminhtml_Block_Template
29: {
30: protected function _prepareLayout()
31: {
32: $this->setTemplate('system/config/switcher.phtml');
33: return parent::_prepareLayout();
34: }
35:
36: 37: 38: 39: 40:
41: public function getStoreSelectOptions()
42: {
43: $section = $this->getRequest()->getParam('section');
44:
45: $curWebsite = $this->getRequest()->getParam('website');
46: $curStore = $this->getRequest()->getParam('store');
47:
48: $storeModel = Mage::getSingleton('adminhtml/system_store');
49:
50:
51: $url = Mage::getModel('adminhtml/url');
52:
53: $options = array();
54: $options['default'] = array(
55: 'label' => Mage::helper('adminhtml')->__('Default Config'),
56: 'url' => $url->getUrl('*/*/*', array('section'=>$section)),
57: 'selected' => !$curWebsite && !$curStore,
58: 'style' => 'background:#ccc; font-weight:bold;',
59: );
60:
61: foreach ($storeModel->getWebsiteCollection() as $website) {
62: $websiteShow = false;
63: foreach ($storeModel->getGroupCollection() as $group) {
64: if ($group->getWebsiteId() != $website->getId()) {
65: continue;
66: }
67: $groupShow = false;
68: foreach ($storeModel->getStoreCollection() as $store) {
69: if ($store->getGroupId() != $group->getId()) {
70: continue;
71: }
72: if (!$websiteShow) {
73: $websiteShow = true;
74: $options['website_' . $website->getCode()] = array(
75: 'label' => $website->getName(),
76: 'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode())),
77: 'selected' => !$curStore && $curWebsite == $website->getCode(),
78: 'style' => 'padding-left:16px; background:#DDD; font-weight:bold;',
79: );
80: }
81: if (!$groupShow) {
82: $groupShow = true;
83: $options['group_' . $group->getId() . '_open'] = array(
84: 'is_group' => true,
85: 'is_close' => false,
86: 'label' => $group->getName(),
87: 'style' => 'padding-left:32px;'
88: );
89: }
90: $options['store_' . $store->getCode()] = array(
91: 'label' => $store->getName(),
92: 'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode(), 'store'=>$store->getCode())),
93: 'selected' => $curStore == $store->getCode(),
94: 'style' => '',
95: );
96: }
97: if ($groupShow) {
98: $options['group_' . $group->getId() . '_close'] = array(
99: 'is_group' => true,
100: 'is_close' => true,
101: );
102: }
103: }
104: }
105:
106: return $options;
107: }
108:
109: 110: 111: 112: 113:
114: public function getHintHtml()
115: {
116: return Mage::getBlockSingleton('adminhtml/store_switcher')->getHintHtml();
117: }
118: }
119: