本文整理汇总了PHP中Zend_Currency::getSymbol方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Currency::getSymbol方法的具体用法?PHP Zend_Currency::getSymbol怎么用?PHP Zend_Currency::getSymbol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Currency
的用法示例。
在下文中一共展示了Zend_Currency::getSymbol方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CurrencySymbol
public function CurrencySymbol()
{
require_once THIRDPARTY_PATH . "/Zend/Currency.php";
$locale = new Zend_Locale(i18n::get_locale());
$symbol = new Zend_Currency($locale);
return $symbol->getSymbol();
}
示例2: getSymbol
/**
* @return string
*/
function getSymbol($currency = null, $locale = null) {
if($locale === null) $locale = $this->getLocale();
if($currency === null) $currency = $this->getCurrency();
return $this->currencyLib->getSymbol($currency, $locale);
}
示例3: getDefaultCurrencySymbol
public function getDefaultCurrencySymbol()
{
$current_locale = I18n::getCurrentLangCode();
require_once 'Zend/Currency.php';
$current_currency = DEFAULT_CURRENCY;
if (!$current_currency) {
$current_currency = "USD";
}
$currency = new Zend_Currency($current_currency, $current_locale);
$currency->getSymbol($current_currency, $current_locale);
return $display_name;
}
示例4: Currency
/**
* returns the value formatet in the current locales currency format
*
* @return string
*/
public function Currency($symbol = false)
{
require_once THIRDPARTY_PATH . "/Zend/Locale/Format.php";
require_once THIRDPARTY_PATH . "/Zend/Currency.php";
if ($this->owner->value) {
$locale = new Zend_Locale(i18n::get_locale());
$number = Zend_Locale_Format::toNumber($this->owner->value, array('locale' => $locale));
if ($symbol) {
$symbol = new Zend_Currency($locale);
$number = $symbol->getSymbol() . " " . $number;
}
return $number;
}
}
示例5: parseZendCurrencyFormat
/**
* Parses a Zend_Currency & Zend_Locale into a NostoCurrency object.
*
* REQUIRES Zend Framework (version 1) to be available.
*
* @param string $currencyCode the 3-letter ISO 4217 currency code.
* @param Zend_Currency $zendCurrency the zend currency object.
* @return NostoCurrency the parsed nosto currency object.
*
* @throws NostoInvalidArgumentException
*/
public function parseZendCurrencyFormat($currencyCode, Zend_Currency $zendCurrency)
{
try {
$format = Zend_Locale_Data::getContent($zendCurrency->getLocale(), 'currencynumber');
$symbols = Zend_Locale_Data::getList($zendCurrency->getLocale(), 'symbols');
// Remove extra part, e.g. "¤ #,##0.00; (¤ #,##0.00)" => "¤ #,##0.00".
if (($pos = strpos($format, ';')) !== false) {
$format = substr($format, 0, $pos);
}
// Check if the currency symbol is before or after the amount.
$symbolPosition = strpos(trim($format), '¤') === 0 ? NostoCurrencySymbol::SYMBOL_POS_LEFT : NostoCurrencySymbol::SYMBOL_POS_RIGHT;
// Remove all other characters than "0", "#", "." and ",",
$format = preg_replace('/[^0\\#\\.,]/', '', $format);
// Calculate the decimal precision.
$precision = 0;
if (($decimalPos = strpos($format, '.')) !== false) {
$precision = strlen($format) - (strrpos($format, '.') + 1);
} else {
$decimalPos = strlen($format);
}
$decimalFormat = substr($format, $decimalPos);
if (($pos = strpos($decimalFormat, '#')) !== false) {
$precision = strlen($decimalFormat) - $pos - $precision;
}
// Calculate the group length.
if (strrpos($format, ',') !== false) {
$groupLength = $decimalPos - strrpos($format, ',') - 1;
} else {
$groupLength = strrpos($format, '.');
}
// If the symbol is missing for the current locale, use the ISO code.
$currencySymbol = $zendCurrency->getSymbol();
if (is_null($currencySymbol)) {
$currencySymbol = $currencyCode;
}
return new NostoCurrency(new NostoCurrencyCode($currencyCode), new NostoCurrencySymbol($currencySymbol, $symbolPosition), new NostoCurrencyFormat($symbols['group'], $groupLength, $symbols['decimal'], $precision));
} catch (Zend_Exception $e) {
throw new NostoInvalidArgumentException($e);
}
}
示例6: testGetSign
/**
* test getSign
*/
public function testGetSign()
{
$locale = new Zend_Locale('ar_EG');
$currency = new Zend_Currency('ar_EG');
$this->assertSame('ج.م.', $currency->getSymbol('EGP', 'ar_EG'));
$this->assertSame('€', $currency->getSymbol('EUR', 'de_AT'));
$this->assertSame('ج.م.', $currency->getSymbol('ar_EG'));
$this->assertSame('€', $currency->getSymbol('de_AT'));
$this->assertSame('ج.م.', $currency->getSymbol());
try {
$currency->getSymbol('EGP', 'de_XX');
$this->fail("exception expected");
} catch (Zend_Currency_Exception $e) {
// success
}
}
示例7: testGetSign
/**
* test getSign
*/
public function testGetSign()
{
$this->assertSame(Zend_Currency::getSymbol('EGP', 'ar_EG'), 'ج.م.');
$this->assertSame(Zend_Currency::getSymbol('ar_EG'), 'ج.م.');
}
示例8: getCountriesList
public static function getCountriesList()
{
if (is_null(self::$_countries_list)) {
self::$_countries_list = array();
$locale = Zend_Registry::get('Zend_Locale');
$currency = new Zend_Currency();
foreach (Zend_Locale::getTranslationList('Territory', null, 2) as $ter => $name) {
$country_code = Zend_Locale::getLocaleToTerritory($ter);
if (!is_null($country_code)) {
try {
$symbol = $currency->getSymbol($country_code);
if (!empty($symbol)) {
$countries[$country_code] = array('code' => $country_code, 'name' => $name, 'symbol' => $symbol);
}
} catch (Exception $e) {
}
}
}
uasort($countries, 'cmp');
foreach ($countries as $currency) {
self::$_countries_list[] = new Core_Model_Default($currency);
}
}
return self::$_countries_list;
}
示例9: testGetSign
/**
* test getSign
*/
public function testGetSign()
{
$locale = new Zend_Locale('ar_EG');
$this->assertSame(Zend_Currency::getSymbol('EGP','ar_EG'), 'ج.م.');
$this->assertSame(Zend_Currency::getSymbol('ar_EG'), 'ج.م.');
$this->assertSame(Zend_Currency::getSymbol('ar_EG'), 'ج.م.');
try {
$this->assertSame(is_string(Zend_Currency::getSymbol('EGP')), true);
} catch (Zend_Currency_Exception $e) {
// Systems without locale are expected to be ok from the testbed
$this->assertSame($e->getMessage(), "Locale 'root' is no valid locale");
}
try {
Zend_Currency::getSymbol('EGP', 'de_XX');
$this->fail();
} catch (Zend_Currency_Exception $e) {
// success
}
}
示例10: DefaultCurrencySymbol
/**
* Returns the configured default currency symbol.
*
* @return string
*
* @author Sebastian Diel <sdiel@pixeltricks.de>
* @since 25.10.2013
*/
public static function DefaultCurrencySymbol()
{
if (is_null(self::$defaultCurrencySymbol)) {
$zend_currency = new Zend_Currency(null, i18n::default_locale());
self::$defaultCurrencySymbol = $zend_currency->getSymbol(self::DefaultCurrency(), i18n::get_locale());
}
return self::$defaultCurrencySymbol;
}