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:  * Country model
 29:  *
 30:  * @method Mage_Directory_Model_Resource_Country _getResource()
 31:  * @method Mage_Directory_Model_Resource_Country getResource()
 32:  * @method string getCountryId()
 33:  * @method Mage_Directory_Model_Country setCountryId(string $value)
 34:  * @method string getIso2Code()
 35:  * @method Mage_Directory_Model_Country setIso2Code(string $value)
 36:  * @method string getIso3Code()
 37:  * @method Mage_Directory_Model_Country setIso3Code(string $value)
 38:  *
 39:  * @category    Mage
 40:  * @package     Mage_Directory
 41:  * @author      Magento Core Team <core@magentocommerce.com>
 42:  */
 43: class Mage_Directory_Model_Country extends Mage_Core_Model_Abstract
 44: {
 45:     static public $_format = array();
 46: 
 47:     protected function _construct()
 48:     {
 49:         $this->_init('directory/country');
 50:     }
 51: 
 52:     public function loadByCode($code)
 53:     {
 54:         $this->_getResource()->loadByCode($this, $code);
 55:         return $this;
 56:     }
 57: 
 58:     public function getRegions()
 59:     {
 60:         return $this->getLoadedRegionCollection();
 61:     }
 62: 
 63:     public function getLoadedRegionCollection()
 64:     {
 65:         $collection = $this->getRegionCollection();
 66:         $collection->load();
 67:         return $collection;
 68:     }
 69: 
 70:     public function getRegionCollection()
 71:     {
 72:         $collection = Mage::getResourceModel('directory/region_collection');
 73:         $collection->addCountryFilter($this->getId());
 74:         return $collection;
 75:     }
 76: 
 77:     public function formatAddress(Varien_Object $address, $html=false)
 78:     {
 79:         //TODO: is it still used?
 80:         $address->getRegion();
 81:         $address->getCountry();
 82: 
 83: 
 84: 
 85:         $template = $this->getData('address_template_'.($html ? 'html' : 'plain'));
 86:         if (empty($template)) {
 87:             if (!$this->getId()) {
 88:                 $template = '{{firstname}} {{lastname}}';
 89:             } elseif (!$html) {
 90:                 $template = "{{firstname}} {{lastname}}
 91: {{company}}
 92: {{street1}}
 93: {{street2}}
 94: {{city}}, {{region}} {{postcode}}";
 95:             } else {
 96:                 $template = "{{firstname}} {{lastname}}<br/>
 97: {{street}}<br/>
 98: {{city}}, {{region}} {{postcode}}<br/>
 99: T: {{telephone}}";
100:             }
101:         }
102: 
103:         $filter = new Varien_Filter_Template_Simple();
104:         $addressText = $filter->setData($address->getData())->filter($template);
105: 
106:         if ($html) {
107:             $addressText = preg_replace('#(<br\s*/?>\s*){2,}#im', '<br/>', $addressText);
108:         } else {
109:             $addressText = preg_replace('#(\n\s*){2,}#m', "\n", $addressText);
110:         }
111: 
112:         return $addressText;
113:     }
114: 
115:     /**
116:      * Retrive formats for
117:      *
118:      * @return Mage_Directory_Model_Resource_Country_Format_Collection
119:      */
120:     public function getFormats()
121:     {
122:         if (!isset(self::$_format[$this->getId()]) && $this->getId()) {
123:             self::$_format[$this->getId()] = Mage::getModel('directory/country_format')
124:                                                 ->getCollection()
125:                                                 ->setCountryFilter($this)
126:                                                 ->load();
127:         }
128: 
129:         if (isset(self::$_format[$this->getId()])) {
130:             return self::$_format[$this->getId()];
131:         }
132: 
133:         return null;
134:     }
135: 
136:     /**
137:      * Retrive format
138:      *
139:      * @param string $type
140:      * @return Mage_Directory_Model_Country_Format
141:      */
142:     public function getFormat($type)
143:     {
144:         if ($this->getFormats()) {
145:             foreach ($this->getFormats() as $format) {
146:                 if ($format->getType()==$type) {
147:                     return $format;
148:                 }
149:             }
150:         }
151:         return null;
152:     }
153: 
154:     public function getName()
155:     {
156:         if(!$this->getData('name')) {
157:             $this->setData(
158:                 'name',
159:                 Mage::app()->getLocale()->getCountryTranslation($this->getId())
160:             );
161:         }
162:         return $this->getData('name');
163:     }
164: 
165: }
166: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0