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 class Mage_Adminhtml_Block_System_Config_Switcher extends Mage_Adminhtml_Block_Template
00029 {
00030 protected function _prepareLayout()
00031 {
00032 $this->setTemplate('system/config/switcher.phtml');
00033 return parent::_prepareLayout();
00034 }
00035
00036
00037
00038
00039
00040
00041 public function getStoreSelectOptions()
00042 {
00043 $section = $this->getRequest()->getParam('section');
00044
00045 $curWebsite = $this->getRequest()->getParam('website');
00046 $curStore = $this->getRequest()->getParam('store');
00047
00048 $storeModel = Mage::getSingleton('adminhtml/system_store');
00049
00050
00051 $url = Mage::getModel('adminhtml/url');
00052
00053 $options = array();
00054 $options['default'] = array(
00055 'label' => Mage::helper('adminhtml')->__('Default Config'),
00056 'url' => $url->getUrl('*/*/*', array('section'=>$section)),
00057 'selected' => !$curWebsite && !$curStore,
00058 'style' => 'background:#ccc; font-weight:bold;',
00059 );
00060
00061 foreach ($storeModel->getWebsiteCollection() as $website) {
00062 $websiteShow = false;
00063 foreach ($storeModel->getGroupCollection() as $group) {
00064 if ($group->getWebsiteId() != $website->getId()) {
00065 continue;
00066 }
00067 $groupShow = false;
00068 foreach ($storeModel->getStoreCollection() as $store) {
00069 if ($store->getGroupId() != $group->getId()) {
00070 continue;
00071 }
00072 if (!$websiteShow) {
00073 $websiteShow = true;
00074 $options['website_' . $website->getCode()] = array(
00075 'label' => $website->getName(),
00076 'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode())),
00077 'selected' => !$curStore && $curWebsite == $website->getCode(),
00078 'style' => 'padding-left:16px; background:#DDD; font-weight:bold;',
00079 );
00080 }
00081 if (!$groupShow) {
00082 $groupShow = true;
00083 $options['group_' . $group->getId() . '_open'] = array(
00084 'is_group' => true,
00085 'is_close' => false,
00086 'label' => $group->getName(),
00087 'style' => 'padding-left:32px;'
00088 );
00089 }
00090 $options['store_' . $store->getCode()] = array(
00091 'label' => $store->getName(),
00092 'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getCode(), 'store'=>$store->getCode())),
00093 'selected' => $curStore == $store->getCode(),
00094 'style' => '',
00095 );
00096 }
00097 if ($groupShow) {
00098 $options['group_' . $group->getId() . '_close'] = array(
00099 'is_group' => true,
00100 'is_close' => true,
00101 );
00102 }
00103 }
00104 }
00105
00106 return $options;
00107 }
00108
00109 }