Mage_Adminhtml_Model_System_Config_Source_Allregion Class Reference

List of all members.

Public Member Functions

 toOptionArray ($isMultiselect=false)
 sortRegionCountries ($a, $b)

Protected Attributes

 $_countries
 $_options


Detailed Description

Definition at line 28 of file Allregion.php.


Member Function Documentation

sortRegionCountries ( a,
b 
)

Definition at line 67 of file Allregion.php.

00068     {
00069         return strcmp($this->_countries[$a], $this->_countries[$b]);
00070     }

toOptionArray ( isMultiselect = false  ) 

Definition at line 33 of file Allregion.php.

00034     {
00035         if (!$this->_options) {
00036             $countriesArray = Mage::getResourceModel('directory/country_collection')->load()
00037                 ->toOptionArray(false);
00038             $this->_countries = array();
00039             foreach ($countriesArray as $a) {
00040                 $this->_countries[$a['value']] = $a['label'];
00041             }
00042 
00043             $countryRegions = array();
00044             $regionsCollection = Mage::getResourceModel('directory/region_collection')->load();
00045             foreach ($regionsCollection as $region) {
00046                 $countryRegions[$region->getCountryId()][$region->getId()] = $region->getDefaultName();
00047             }
00048             uksort($countryRegions, array($this, 'sortRegionCountries'));
00049 
00050             $this->_options = array();
00051             foreach ($countryRegions as $countryId=>$regions) {
00052                 $regionOptions = array();
00053                 foreach ($regions as $regionId=>$regionName) {
00054                     $regionOptions[] = array('label'=>$regionName, 'value'=>$regionId);
00055                 }
00056                 $this->_options[] = array('label'=>$this->_countries[$countryId], 'value'=>$regionOptions);
00057             }
00058         }
00059         $options = $this->_options;
00060         if(!$isMultiselect){
00061             array_unshift($options, array('value'=>'', 'label'=>''));
00062         }
00063 
00064         return $options;
00065     }


Member Data Documentation

$_countries [protected]

Definition at line 30 of file Allregion.php.

$_options [protected]

Definition at line 31 of file Allregion.php.


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

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