Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Directory_Block_Adminhtml_Frontend_Currency_Base
  • Mage_Directory_Block_Adminhtml_Frontend_Region_Updater
  • Mage_Directory_Block_Currency
  • Mage_Directory_Block_Data
  • Mage_Directory_CurrencyController
  • Mage_Directory_Helper_Data
  • Mage_Directory_Helper_Url
  • Mage_Directory_Model_Country
  • Mage_Directory_Model_Country_Api
  • Mage_Directory_Model_Country_Api_V2
  • Mage_Directory_Model_Country_Format
  • Mage_Directory_Model_Currency
  • Mage_Directory_Model_Currency_Filter
  • Mage_Directory_Model_Currency_Import_Abstract
  • Mage_Directory_Model_Currency_Import_Webservicex
  • Mage_Directory_Model_Mysql4_Country
  • Mage_Directory_Model_Mysql4_Country_Collection
  • Mage_Directory_Model_Mysql4_Country_Format
  • Mage_Directory_Model_Mysql4_Country_Format_Collection
  • Mage_Directory_Model_Mysql4_Currency
  • Mage_Directory_Model_Mysql4_Currency_Collection
  • Mage_Directory_Model_Mysql4_Region
  • Mage_Directory_Model_Mysql4_Region_Collection
  • Mage_Directory_Model_Observer
  • Mage_Directory_Model_Region
  • Mage_Directory_Model_Region_Api
  • Mage_Directory_Model_Region_Api_V2
  • Mage_Directory_Model_Resource_Country
  • Mage_Directory_Model_Resource_Country_Collection
  • Mage_Directory_Model_Resource_Country_Format
  • Mage_Directory_Model_Resource_Country_Format_Collection
  • Mage_Directory_Model_Resource_Currency
  • Mage_Directory_Model_Resource_Region
  • Mage_Directory_Model_Resource_Region_Collection

Exceptions

  • Mage_Directory_Exception
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Directory
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Directory data block
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_Directory
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Directory_Block_Data extends Mage_Core_Block_Template
 35: {
 36:     public function getLoadrRegionUrl()
 37:     {
 38:         return $this->getUrl('directory/json/childRegion');
 39:     }
 40: 
 41:     public function getCountryCollection()
 42:     {
 43:         $collection = $this->getData('country_collection');
 44:         if (is_null($collection)) {
 45:             $collection = Mage::getModel('directory/country')->getResourceCollection()
 46:                 ->loadByStore();
 47:             $this->setData('country_collection', $collection);
 48:         }
 49: 
 50:         return $collection;
 51:     }
 52: 
 53:     public function getCountryHtmlSelect($defValue=null, $name='country_id', $id='country', $title='Country')
 54:     {
 55:         Varien_Profiler::start('TEST: '.__METHOD__);
 56:         if (is_null($defValue)) {
 57:             $defValue = $this->getCountryId();
 58:         }
 59:         $cacheKey = 'DIRECTORY_COUNTRY_SELECT_STORE_'.Mage::app()->getStore()->getCode();
 60:         if (Mage::app()->useCache('config') && $cache = Mage::app()->loadCache($cacheKey)) {
 61:             $options = unserialize($cache);
 62:         } else {
 63:             $options = $this->getCountryCollection()->toOptionArray();
 64:             if (Mage::app()->useCache('config')) {
 65:                 Mage::app()->saveCache(serialize($options), $cacheKey, array('config'));
 66:             }
 67:         }
 68:         $html = $this->getLayout()->createBlock('core/html_select')
 69:             ->setName($name)
 70:             ->setId($id)
 71:             ->setTitle(Mage::helper('directory')->__($title))
 72:             ->setClass('validate-select')
 73:             ->setValue($defValue)
 74:             ->setOptions($options)
 75:             ->getHtml();
 76: 
 77:         Varien_Profiler::stop('TEST: '.__METHOD__);
 78:         return $html;
 79:     }
 80: 
 81:     public function getRegionCollection()
 82:     {
 83:         $collection = $this->getData('region_collection');
 84:         if (is_null($collection)) {
 85:             $collection = Mage::getModel('directory/region')->getResourceCollection()
 86:                 ->addCountryFilter($this->getCountryId())
 87:                 ->load();
 88: 
 89:             $this->setData('region_collection', $collection);
 90:         }
 91:         return $collection;
 92:     }
 93: 
 94: 
 95:     public function getRegionHtmlSelect()
 96:     {
 97:         Varien_Profiler::start('TEST: '.__METHOD__);
 98:         $cacheKey = 'DIRECTORY_REGION_SELECT_STORE'.Mage::app()->getStore()->getId();
 99:         if (Mage::app()->useCache('config') && $cache = Mage::app()->loadCache($cacheKey)) {
100:             $options = unserialize($cache);
101:         } else {
102:             $options = $this->getRegionCollection()->toOptionArray();
103:             if (Mage::app()->useCache('config')) {
104:                 Mage::app()->saveCache(serialize($options), $cacheKey, array('config'));
105:             }
106:         }
107:         $html = $this->getLayout()->createBlock('core/html_select')
108:             ->setName('region')
109:             ->setTitle(Mage::helper('directory')->__('State/Province'))
110:             ->setId('state')
111:             ->setClass('required-entry validate-state')
112:             ->setValue(intval($this->getRegionId()))
113:             ->setOptions($options)
114:             ->getHtml();
115:         Varien_Profiler::start('TEST: '.__METHOD__);
116:         return $html;
117:     }
118: 
119:     public function getCountryId()
120:     {
121:         $countryId = $this->getData('country_id');
122:         if (is_null($countryId)) {
123:             $countryId = Mage::helper('core')->getDefaultCountry();
124:         }
125:         return $countryId;
126:     }
127: 
128:     public function getRegionsJs()
129:     {
130:         Varien_Profiler::start('TEST: '.__METHOD__);
131:         $regionsJs = $this->getData('regions_js');
132:         if (!$regionsJs) {
133:             $countryIds = array();
134:             foreach ($this->getCountryCollection() as $country) {
135:                 $countryIds[] = $country->getCountryId();
136:             }
137:             $collection = Mage::getModel('directory/region')->getResourceCollection()
138:                 ->addCountryFilter($countryIds)
139:                 ->load();
140:             $regions = array();
141:             foreach ($collection as $region) {
142:                 if (!$region->getRegionId()) {
143:                     continue;
144:                 }
145:                 $regions[$region->getCountryId()][$region->getRegionId()] = array(
146:                     'code'=>$region->getCode(),
147:                     'name'=>$region->getName()
148:                 );
149:             }
150:             $regionsJs = Mage::helper('core')->jsonEncode($regions);
151:         }
152:         Varien_Profiler::stop('TEST: '.__METHOD__);
153:         return $regionsJs;
154:     }
155: }
156: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0