Mage_Core_Model_Locale_Currency Class Reference

List of all members.

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


Detailed Description

Locale model

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 32 of file Currency.php.


Constructor & Destructor Documentation

__construct ( currency = null,
locale = null 
)

Creates a currency instance. Every supressed parameter is used from the actual or the given locale.

Parameters:
string $currency OPTIONAL currency short name
string|Zend_Locale $locale OPTIONAL locale name
Exceptions:
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     }


Member Function Documentation

_concatSign ( value,
sign,
options 
) [protected]

Place the sign next to the number

Parameters:
string $value
string $sign
array $options
Returns:
string

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

Returns:
Mage_Core_Model_Store

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,

Parameters:
string $currency (Optional) Currency name
string|Zend_Locale $locale (Optional) Locale to display informations
Returns:
string

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     }


Member Data Documentation

$_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.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:57 2009 for Magento by  doxygen 1.5.8