Mage_Page_Block_Switch Class Reference

Inheritance diagram for Mage_Page_Block_Switch:

Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 getCurrentWebsiteId ()
 getCurrentGroupId ()
 getCurrentStoreId ()
 getRawGroups ()
 getRawStores ()
 getGroups ()
 getStores ()
 getCurrentStoreCode ()
 isStoreInUrl ()

Protected Attributes

 $_storeInUrl


Detailed Description

Definition at line 34 of file Switch.php.


Member Function Documentation

getCurrentGroupId (  ) 

Definition at line 43 of file Switch.php.

00044     {
00045         return Mage::app()->getStore()->getGroupId();
00046     }

getCurrentStoreCode (  ) 

Definition at line 147 of file Switch.php.

00148     {
00149         return Mage::app()->getStore()->getCode();
00150     }

getCurrentStoreId (  ) 

Definition at line 48 of file Switch.php.

00049     {
00050         return Mage::app()->getStore()->getId();
00051     }

getCurrentWebsiteId (  ) 

Definition at line 38 of file Switch.php.

00039     {
00040         return Mage::app()->getStore()->getWebsiteId();
00041     }

getGroups (  ) 

Definition at line 95 of file Switch.php.

00096     {
00097         if (!$this->hasData('groups')) {
00098             $rawGroups = $this->getRawGroups();
00099             $rawStores = $this->getRawStores();
00100 
00101             $groups = array();
00102             $localeCode = Mage::getStoreConfig('general/locale/code');
00103             foreach ($rawGroups as $group) {
00104                 if (!isset($rawStores[$group->getId()])) {
00105                     continue;
00106                 }
00107                 if ($group->getId() == $this->getCurrentGroupId()) {
00108                     $groups[] = $group;
00109                     continue;
00110                 }
00111                 $store = false;
00112                 foreach ($rawStores[$group->getId()] as $s) {
00113                     if ($s->getLocaleCode() == $localeCode) {
00114                         $store = $s;
00115                         break;
00116                     }
00117                 }
00118                 if (!$store && isset($rawStores[$group->getId()][$group->getDefaultStoreId()])) {
00119                     $store = $rawStores[$group->getId()][$group->getDefaultStoreId()];
00120                 }
00121                 if ($store) {
00122                     $group->setHomeUrl($store->getHomeUrl());
00123                     $groups[] = $group;
00124                 }
00125             }
00126             $this->setData('groups', $groups);
00127         }
00128         return $this->getData('groups');
00129     }

getRawGroups (  ) 

Definition at line 53 of file Switch.php.

00054     {
00055         if (!$this->hasData('raw_groups')) {
00056             $websiteGroups = Mage::app()->getWebsite()->getGroups();
00057 
00058             $groups = array();
00059             foreach ($websiteGroups as $group) {
00060                 $groups[$group->getId()] = $group;
00061             }
00062             $this->setData('raw_groups', $groups);
00063         }
00064         return $this->getData('raw_groups');
00065     }

getRawStores (  ) 

Definition at line 67 of file Switch.php.

00068     {
00069         if (!$this->hasData('raw_stores')) {
00070             $websiteStores = Mage::app()->getWebsite()->getStores();
00071             $stores = array();
00072             foreach ($websiteStores as $store) {
00073                 /* @var $store Mage_Core_Model_Store */
00074                 if (!$store->getIsActive()) {
00075                     continue;
00076                 }
00077                 $store->setLocaleCode(Mage::getStoreConfig('general/locale/code', $store->getId()));
00078 
00079                 $params = array(
00080                     '_query' => array()
00081                 );
00082                 if (!$this->isStoreInUrl()) {
00083                     $params['_query']['___store'] = $store->getCode();
00084                 }
00085                 $baseUrl = $store->getUrl('', $params);
00086 
00087                 $store->setHomeUrl($baseUrl);
00088                 $stores[$store->getGroupId()][$store->getId()] = $store;
00089             }
00090             $this->setData('raw_stores', $stores);
00091         }
00092         return $this->getData('raw_stores');
00093     }

getStores (  ) 

Definition at line 131 of file Switch.php.

00132     {
00133         if (!$this->getData('stores')) {
00134             $rawStores = $this->getRawStores();
00135 
00136             $groupId = $this->getCurrentGroupId();
00137             if (!isset($rawStores[$groupId])) {
00138                 $stores = array();
00139             } else {
00140                 $stores = $rawStores[$groupId];
00141             }
00142             $this->setData('stores', $stores);
00143         }
00144         return $this->getData('stores');
00145     }

isStoreInUrl (  ) 

Definition at line 152 of file Switch.php.

00153     {
00154         if (is_null($this->_storeInUrl)) {
00155             $this->_storeInUrl = Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_STORE_IN_URL);
00156         }
00157         return $this->_storeInUrl;
00158     }


Member Data Documentation

$_storeInUrl [protected]

Definition at line 36 of file Switch.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:30 2009 for Magento by  doxygen 1.5.8