Mage_Core_Block_Store_Switcher Class Reference

Inheritance diagram for Mage_Core_Block_Store_Switcher:

Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 __construct ()
 getStoreCount ()
 getLanguageCount ()
 getCurrentStoreId ()
 getCurrentStoreCode ()

Protected Member Functions

 _loadData ()

Protected Attributes

 $_groups = array()
 $_stores = array()
 $_loaded = false


Detailed Description

Definition at line 34 of file Switcher.php.


Constructor & Destructor Documentation

__construct (  ) 

Constructor

By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes

Reimplemented from Varien_Object.

Definition at line 40 of file Switcher.php.

00041     {
00042         $this->_loadData();
00043         $this->setStores(array());
00044         $this->setLanguages(array());
00045         return parent::__construct();
00046     }


Member Function Documentation

_loadData (  )  [protected]

Definition at line 48 of file Switcher.php.

00049     {
00050         if ($this->_loaded) {
00051             return $this;
00052         }
00053 
00054         $websiteId = Mage::app()->getStore()->getWebsiteId();
00055         $storeCollection = Mage::getModel('core/store')
00056             ->getCollection()
00057             ->addWebsiteFilter($websiteId);
00058         $groupCollection = Mage::getModel('core/store_group')
00059             ->getCollection()
00060             ->addWebsiteFilter($websiteId);
00061         foreach ($groupCollection as $group) {
00062             $this->_groups[$group->getId()] = $group;
00063         }
00064         foreach ($storeCollection as $store) {
00065             if (!$store->getIsActive()) {
00066                 continue;
00067             }
00068             $store->setLocaleCode(Mage::getStoreConfig('general/locale/code', $store->getId()));
00069             $this->_stores[$store->getGroupId()][$store->getId()] = $store;
00070         }
00071 
00072         $this->_loaded = true;
00073 
00074         return $this;
00075     }

getCurrentStoreCode (  ) 

Definition at line 117 of file Switcher.php.

00118     {
00119         return Mage::app()->getStore()->getCode();
00120     }

getCurrentStoreId (  ) 

Definition at line 112 of file Switcher.php.

00113     {
00114         return Mage::app()->getStore()->getId();
00115     }

getLanguageCount (  ) 

Definition at line 101 of file Switcher.php.

00102     {
00103         $groupId = Mage::app()->getStore()->getGroupId();
00104         if (!isset($this->_stores[$groupId])) {
00105             $this->setLanguages(array());
00106             return 0;
00107         }
00108         $this->setLanguages($this->_stores[$groupId]);
00109         return count($this->getLanguages());
00110     }

getStoreCount (  ) 

Definition at line 77 of file Switcher.php.

00078     {
00079         $stores = array();
00080         $localeCode = Mage::getStoreConfig('general/locale/code');
00081         foreach ($this->_groups as $group) {
00082             if (!isset($this->_stores[$group->getId()])) {
00083                 continue;
00084             }
00085             $useStore = false;
00086             foreach ($this->_stores[$group->getId()] as $store) {
00087                 if ($store->getLocaleCode() == $localeCode) {
00088                     $useStore = true;
00089                     $stores[] = $store;
00090                 }
00091             }
00092             if (!$useStore && isset($this->_stores[$group->getId()][$group->getDefaultStoreId()])) {
00093                 $stores[] = $this->_stores[$group->getId()][$group->getDefaultStoreId()];
00094             }
00095         }
00096 
00097         $this->setStores($stores);
00098         return count($this->getStores());
00099     }


Member Data Documentation

$_groups = array() [protected]

Definition at line 36 of file Switcher.php.

$_loaded = false [protected]

Definition at line 38 of file Switcher.php.

$_stores = array() [protected]

Definition at line 37 of file Switcher.php.


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

Generated on Sat Jul 4 17:23:53 2009 for Magento by  doxygen 1.5.8