Public Member Functions | |
__construct ($currency=null, $locale=null) | |
getSymbolChoice ($currency=null, $locale=null) | |
setLocale ($locale=null) | |
getStore () | |
Public Attributes | |
const | XML_PATH_TRIM_CURRENCY_SIGN = 'currency/options/trim_sign' |
const | US_LOCALE = 'en_US' |
Protected Member Functions | |
_concatSign ($value, $sign, $options) | |
Protected Attributes | |
$_locale |
Definition at line 32 of file Currency.php.
__construct | ( | $ | currency = null , |
|
$ | locale = null | |||
) |
Creates a currency instance. Every supressed parameter is used from the actual or the given locale.
string | $currency OPTIONAL currency short name | |
string|Zend_Locale | $locale OPTIONAL locale name |
Zend_Currency_Exception | When currency is invalid |
Definition at line 45 of file Currency.php.
00046 { 00047 parent::__construct($currency, $locale); 00048 $this->_options['symbol_choice'] = self::getSymbolChoice($currency, $this->_locale); 00049 }
_concatSign | ( | $ | value, | |
$ | sign, | |||
$ | options | |||
) | [protected] |
Place the sign next to the number
string | $value | |
string | $sign | |
array | $options |
Definition at line 92 of file Currency.php.
00093 { 00094 $trimSign = $this->getStore()->getConfig(self::XML_PATH_TRIM_CURRENCY_SIGN); 00095 if (is_null($trimSign) && $this->_locale && $this->_locale == self::US_LOCALE) { 00096 $trimSign = true; 00097 } 00098 if ($trimSign) { 00099 $sign = trim($sign); 00100 } 00101 00102 // Place the sign next to the number 00103 if ($options['position'] === self::RIGHT) { 00104 $result = $value . $sign; 00105 } else if ($options['position'] === self::LEFT) { 00106 // Do not place sign before minus. And do not allow space between minus and sign 00107 if (0 === strpos($value, '-', 0)) { 00108 $result = '-' . ltrim($sign) . substr($value, 1); 00109 } else { 00110 $result = $sign . $value; 00111 } 00112 } 00113 return $result; 00114 }
getStore | ( | ) |
Get store instance
Definition at line 121 of file Currency.php.
00122 { 00123 return Mage::app()->getStore(); 00124 }
getSymbolChoice | ( | $ | currency = null , |
|
$ | locale = null | |||
) |
Returns the actual or details of available currency symbol choice,
string | $currency (Optional) Currency name | |
string|Zend_Locale | $locale (Optional) Locale to display informations |
Definition at line 58 of file Currency.php.
00059 { 00060 if (($currency === null) and ($locale === null)) { 00061 return $this->_options['symbol_choice']; 00062 } 00063 00064 $params = self::_checkParams($currency, $locale); 00065 00066 //Get the symbol choice 00067 $symbolChoice = Zend_Locale_Data::getContent($params['locale'], 'currencysymbolchoice', $params['currency']); 00068 if (empty($symbolChoice) === true) { 00069 $symbolChoice = Zend_Locale_Data::getContent($params['locale'], 'currencysymbolchoice', $params['name']); 00070 } 00071 if (empty($symbolChoice) === true) { 00072 return null; 00073 } 00074 return $symbolChoice; 00075 }
setLocale | ( | $ | locale = null |
) |
Definition at line 77 of file Currency.php.
00078 { 00079 $this->_locale = $locale; 00080 parent::setLocale($locale); 00081 return $this; 00082 }
$_locale [protected] |
Definition at line 36 of file Currency.php.
const US_LOCALE = 'en_US' |
Definition at line 35 of file Currency.php.
const XML_PATH_TRIM_CURRENCY_SIGN = 'currency/options/trim_sign' |
Definition at line 34 of file Currency.php.