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:  * Currency dropdown block
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_Directory
 32:  * @author      Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Directory_Block_Currency extends Mage_Core_Block_Template
 35: {
 36:     /**
 37:      * Retrieve count of currencies
 38:      * Return 0 if only one currency
 39:      *
 40:      * @return int
 41:      */
 42:     public function getCurrencyCount()
 43:     {
 44:         return count($this->getCurrencies());
 45:     }
 46: 
 47:     /**
 48:      * Retrieve currencies array
 49:      * Return array: code => currency name
 50:      * Return empty array if only one currency
 51:      *
 52:      * @return array
 53:      */
 54:     public function getCurrencies()
 55:     {
 56:         $currencies = $this->getData('currencies');
 57:         if (is_null($currencies)) {
 58:             $currencies = array();
 59:             $codes = Mage::app()->getStore()->getAvailableCurrencyCodes(true);
 60:             if (is_array($codes) && count($codes) > 1) {
 61:                 $rates = Mage::getModel('directory/currency')->getCurrencyRates(
 62:                     Mage::app()->getStore()->getBaseCurrency(),
 63:                     $codes
 64:                 );
 65: 
 66:                 foreach ($codes as $code) {
 67:                     if (isset($rates[$code])) {
 68:                         $currencies[$code] = Mage::app()->getLocale()
 69:                             ->getTranslation($code, 'nametocurrency');
 70:                     }
 71:                 }
 72:             }
 73: 
 74:             $this->setData('currencies', $currencies);
 75:         }
 76:         return $currencies;
 77:     }
 78: 
 79:     /**
 80:      * Retrieve Currency Swith URL
 81:      *
 82:      * @return string
 83:      */
 84:     public function getSwitchUrl()
 85:     {
 86:         return $this->getUrl('directory/currency/switch');
 87:     }
 88: 
 89:     /**
 90:      * Return URL for specified currency to switch
 91:      *
 92:      * @param string $code Currency code
 93:      * @return string
 94:      */
 95:     public function getSwitchCurrencyUrl($code)
 96:     {
 97:         return Mage::helper('directory/url')->getSwitchCurrencyUrl(array('currency' => $code));
 98:     }
 99: 
100:     /**
101:      * Retrieve Current Currency code
102:      *
103:      * @return string
104:      */
105:     public function getCurrentCurrencyCode()
106:     {
107:         if (is_null($this->_getData('current_currency_code'))) {
108:             // do not use Mage::app()->getStore()->getCurrentCurrencyCode() because of probability
109:             // to get an invalid (without base rate) currency from code saved in session
110:             $this->setData('current_currency_code', Mage::app()->getStore()->getCurrentCurrency()->getCode());
111:         }
112: 
113:         return $this->_getData('current_currency_code');
114:     }
115: }
116: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0