00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 class Mage_Directory_Block_Currency extends Mage_Core_Block_Template
00035 {
00036
00037
00038
00039
00040
00041
00042 public function getCurrencyCount()
00043 {
00044 return count($this->getCurrencies());
00045 }
00046
00047
00048
00049
00050
00051
00052
00053
00054 public function getCurrencies()
00055 {
00056 $currencies = $this->getData('currencies');
00057 if (is_null($currencies)) {
00058 $currencies = array();
00059 $codes = Mage::app()->getStore()->getAvailableCurrencyCodes(true);
00060 if (is_array($codes) && count($codes) > 1) {
00061 $rates = Mage::getModel('directory/currency')->getCurrencyRates(
00062 Mage::app()->getStore()->getBaseCurrency(),
00063 $codes
00064 );
00065
00066 foreach ($codes as $code) {
00067 if (isset($rates[$code])) {
00068 $currencies[$code] = Mage::app()->getLocale()
00069 ->getTranslation($code, 'nametocurrency');
00070 }
00071 }
00072 }
00073
00074 $this->setData('currencies', $currencies);
00075 }
00076 return $currencies;
00077 }
00078
00079
00080
00081
00082
00083
00084 public function getSwitchUrl()
00085 {
00086 return $this->getUrl('directory/currency/switch');
00087 }
00088
00089
00090
00091
00092
00093
00094 public function getCurrentCurrencyCode()
00095 {
00096 $code = $this->getData('current_currency_code');
00097 if (is_null($code)) {
00098 $code = Mage::app()->getStore()->getCurrentCurrencyCode();
00099 $this->setData('current_currency_code', $code);
00100 }
00101 return $code;
00102 }
00103 }