本文整理汇总了PHP中Zend_Currency类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Currency类的具体用法?PHP Zend_Currency怎么用?PHP Zend_Currency使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Currency类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:spekulatius,项目名称:silverstripe-bootstrap_extra_fields,代码行数:7,代码来源:BootstrapCurrencyField.php
示例2: format
/**
* Formats a given value
* @see library/Bvb/Grid/Formatter/Bvb_Grid_Formatter_FormatterInterface::format()
*/
public function format($value)
{
if ($this->_locale === null || !is_numeric($value)) {
return $value;
}
$currency = new Zend_Currency($this->_locale);
return $currency->toCurrency($value);
}
开发者ID:ocpyosep78,项目名称:Booking,代码行数:12,代码来源:Currency.php
示例3: getFormat
/**
* Retrives pattern with local date format
* @return string
*/
public function getFormat()
{
$currency = new Zend_Currency(Mage::app()->getStore()->getBaseCurrency()->getCode(), Mage::app()->getLocale()->getLocaleCode());
$format = $currency->toCurrency('0');
$format = preg_replace('/\\d+.\\d+/', '%f', $format);
$format = str_replace(' ', '', $format);
return $format;
}
开发者ID:bevello,项目名称:bevello,代码行数:12,代码来源:Explain.php
示例4: currency
/**
* Format a numeric currency value and return it as a string
*
* @param int|float $value any value that return true with is_numeric
* @param array $options additional options to pass to the currency
* constructor
* @param string $locale locale value
*
* @throws InvalidParameterException if the $value parameter is not numeric
* @return string the formatted value
*/
public function currency($value, $options = array(), $locale = null)
{
if (!is_numeric($value)) {
throw new InvalidArgumentException('Numeric argument expected ' . gettype($value) . ' given');
}
$options = array_merge($options, array('value' => $value));
$currency = new Zend_Currency($options, $locale);
return $currency->toString();
}
开发者ID:JellyBellyDev,项目名称:zle,代码行数:20,代码来源:Currency.php
示例5: _getShippingMultiOptions
private function _getShippingMultiOptions()
{
$currency = new Zend_Currency();
$shipping = new Storefront_Model_Shipping();
$options = array(0 => 'Please Select');
foreach ($shipping->getShippingOptions() as $key => $value) {
$options["{$value}"] = $key . ' - ' . $currency->toCurrency($value);
}
return $options;
}
开发者ID:AkimBolushbek,项目名称:zendframeworkstorefront,代码行数:10,代码来源:Cart.php
示例6: convert
/**
* Convert currency value to another currency. Will throw an exception if value cannot be converted.
*
* @param $ps_value string Currency value with specifier (Ex. $500, USD 500, ��1200, CAD 750)
* @param $ps_to string Specifier of currency to convert value to (Ex. USD, CAD, EUR)
* @param $pa_options array Options are:
* numericValue = return floating point numeric value only, without currency specifier. Default is false.
*
* @return string Converted value with currency specifier, unless numericValue option is set.
*/
public static function convert($ps_value, $ps_to, $pa_options = null)
{
$va_currency_data = WLPlugCurrencyConversionEuroBank::_loadData();
$ps_to = parent::normalizeCurrencySpecifier($ps_to);
if (preg_match("!^([^\\d]+)([\\d\\.\\,]+)\$!", trim($ps_value), $va_matches)) {
$vs_decimal_value = (double) $va_matches[2];
$vs_currency_specifier = trim($va_matches[1]);
// or 1
} else {
if (preg_match("!^([\\d\\.\\,]+)([^\\d]+)\$!", trim($ps_value), $va_matches)) {
$vs_decimal_value = (double) $va_matches[1];
$vs_currency_specifier = trim($va_matches[2]);
// or 2
} else {
if (preg_match("!(^[\\d\\,\\.]+\$)!", trim($ps_value), $va_matches)) {
$vs_decimal_value = (double) $va_matches[1];
$vs_currency_specifier = null;
// derp
} else {
throw new Exception(_t('%1 is not a valid currency value; be sure to include a currency symbol', $ps_value));
return false;
}
}
}
if (!$vs_currency_specifier) {
$o_currency = new Zend_Currency();
$vs_currency_specifier = $o_currency->getShortName();
}
$vs_currency_specifier = parent::normalizeCurrencySpecifier($vs_currency_specifier);
if (!self::canConvert($vs_currency_specifier, $ps_to)) {
throw new Exception(_t('Cannot convert %1 to %2', $vs_currency_specifier, $ps_to));
return false;
}
$vn_value_in_euros = $vs_decimal_value / $va_currency_data[$vs_currency_specifier];
$vn_converted_value = $vn_value_in_euros * $va_currency_data[$ps_to];
if (caGetOption('numericValue', $pa_options, false)) {
return (double) sprintf("%01.2f", $vn_converted_value);
}
if (Zend_Registry::isRegistered("Zend_Locale")) {
$o_locale = Zend_Registry::get('Zend_Locale');
} else {
$o_locale = new Zend_Locale('en_US');
}
$vs_format = Zend_Locale_Data::getContent($o_locale, 'currencynumber');
// this returns a string like '50,00 ��' for locale de_DE
$vs_decimal_with_placeholder = Zend_Locale_Format::toNumber($vn_converted_value, array('locale' => $o_locale, 'number_format' => $vs_format, 'precision' => 2));
// if the currency placeholder is the first character, for instance in en_US locale ($10), insert a space.
// this has to be done because we don't print "$10" (which is expected in the locale rules) but "USD 10" ... and that looks nicer with an additional space.
if (substr($vs_decimal_with_placeholder, 0, 2) == '��') {
// for whatever reason '��' has length 2
$vs_decimal_with_placeholder = str_replace('��', '�� ', $vs_decimal_with_placeholder);
}
// insert currency which is not locale-dependent in our case
return str_replace('��', $ps_to, $vs_decimal_with_placeholder);
}
开发者ID:idiscussforum,项目名称:providence,代码行数:65,代码来源:EuroBank.php
示例7: formatPrice
/**
* Format Price to locale
*
* @param $price
* @return string
*/
public static function formatPrice($price)
{
try {
$zCurrency = new \Zend_Currency("de_DE");
//TODO: fix to use Zend_Locale
return $zCurrency->toCurrency($price, array('symbol' => Tool::getCurrency()->getSymbol()));
} catch (\Exception $ex) {
echo $ex;
}
return $price;
}
开发者ID:Cube-Solutions,项目名称:pimcore-coreshop,代码行数:17,代码来源:Tool.php
示例8: 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;
}
开发者ID:Why-Not-Sky,项目名称:cubi-ng,代码行数:12,代码来源:currencyService.php
示例9: index
/**
* Specific controller action for displaying a particular list of links
* for a class
*
* @return mixed
*/
public function index()
{
if (GoogleShoppingFeed::enabled()) {
Config::inst()->update('SSViewer', 'set_source_file_comments', false);
$this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"');
$this->getResponse()->addHeader('X-Robots-Tag', 'noindex');
$items = GoogleShoppingFeed::get_items();
$currency = new Zend_Currency(i18n::get_locale());
$this->extend('updateGoogleShoppingFeedItems', $items);
return array("SiteConfig" => SiteConfig::current_site_config(), 'Items' => $items, "Currency" => $currency->getShortName());
} else {
return new SS_HTTPResponse(_t("GoogleShoppingFeed.PageNotFound", 'Page not found'), 404);
}
}
开发者ID:spekulatius,项目名称:silverstripe-googleshoppingfeed,代码行数:20,代码来源:GoogleShoppingFeedController.php
示例10: 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;
}
}
开发者ID:spekulatius,项目名称:silverstripe-bootstrap_extra_fields,代码行数:19,代码来源:ExtendedDecimal.php
示例11: preco
public function preco($especialidade_id, $simbol = true)
{
$salao_id = Zend_Auth::getInstance()->getIdentity()->salao_id;
$modelEspecialidadePreco = new Model_DbTable_EspecialidadePreco();
$preco = $modelEspecialidadePreco->getPrecoEspecialidadeSalao($especialidade_id, $salao_id);
if (!$preco) {
return "";
}
$zendCurrency = new Zend_Currency();
$options = array();
if (!$simbol) {
$options = array('precision' => 2, 'symbol' => '');
}
return $zendCurrency->toCurrency($preco->especialidade_preco_preco, $options);
}
开发者ID:nandorodpires2,项目名称:homemakes,代码行数:15,代码来源:Preco.php
示例12: __construct
/**
* Creates a currency instance.
*
* @param CacheInterface $appCache
* @param string|array $options Options array or currency short name when string is given
* @param string $locale Locale name
*/
public function __construct(CacheInterface $appCache, $options = null, $locale = null)
{
// set Zend cache to low level frontend app cache
$lowLevelFrontendCache = $appCache->getFrontend()->getLowLevelFrontend();
\Zend_Currency::setCache($lowLevelFrontendCache);
parent::__construct($options, $locale);
}
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:14,代码来源:Currency.php
示例13: setUp
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* @return void
*/
public function setUp()
{
$this->clearRegistry();
$this->_cache = Zend_Cache::factory('Core', 'File', array('lifetime' => 120, 'automatic_serialization' => true), array('cache_dir' => dirname(__FILE__) . '/../../_files/'));
Zend_Currency::setCache($this->_cache);
$this->helper = new Zend_View_Helper_Currency('de_AT');
}
开发者ID:bradley-holt,项目名称:zf2,代码行数:13,代码来源:CurrencyTest.php
示例14: setFormat
/**
* Sets the formating options of the localized currency string
* If no parameter is passed, the standard setting of the
* actual set locale will be used
*
* @param array $options (Optional) Options to set
* @return Zend_Currency
*/
public function setFormat(array $options = array())
{
if (isset($options['id'])) {
$this->id = (int) $options['id'];
}
return parent::setFormat($options);
}
开发者ID:nvdnkpr,项目名称:Enlight,代码行数:15,代码来源:Currency.php
示例15: setCurrency
/**
* @param mixed $currency
*/
public function setCurrency($price, $userCurrencyId = null)
{
$cy = new Application_Model_CurrencyMapper();
$currency_id = $cy->getDefaultCurrency()->id;
$code = $cy->find($currency_id)->code;
$currency = null;
if ($userCurrencyId) {
$userCode = $cy->find($userCurrencyId)->code;
$currency = new Zend_Currency(array('value' => 1, 'currency' => $userCode, 'display' => Zend_Currency::USE_SHORTNAME, 'position' => Zend_Currency::RIGHT, 'format' => '#0.# '));
$exService = new My_Class_ExchangeService();
$currency->setService($exService);
$currency->setValue($price, $code);
} else {
$currency = new Zend_Currency(array('value' => $price, 'currency' => $code, 'display' => Zend_Currency::USE_SHORTNAME, 'position' => Zend_Currency::RIGHT, 'format' => '#0.# '));
}
$this->currency = $currency;
}
开发者ID:cioionut,项目名称:products-webEcommerce,代码行数:20,代码来源:Product.php
示例16: currency
/**
* Output a formatted currency
*
* @param integer|float $value Currency value to output
* @param string|Zend_Locale|Zend_Currency $currency OPTIONAL Currency to use for this call
* @return string Formatted currency
*/
public function currency($value = null, $currency = null)
{
if ($value === null) {
return $this;
}
if (is_string($currency) || $currency instanceof Zend_Locale) {
if (Zend_Locale::isLocale($currency)) {
$currency = array('locale' => $currency);
}
}
if (is_string($currency)) {
$currency = array('currency' => $currency);
}
if (is_array($currency)) {
return $this->_currency->toCurrency($value, $currency);
}
return $this->_currency->toCurrency($value);
}
开发者ID:bradley-holt,项目名称:zf2,代码行数:25,代码来源:Currency.php
示例17: formatAmount
/**
* Convenience method
* call $this->formatDate() in the view to access
* the helper
*
* @access public
* @return string
*/
public function formatAmount($amount, $currencyIso = NULL)
{
$formattedAmount = new Zend_Currency();
$formattedAmount->setValue($amount);
if (!is_null($currencyIso)) {
switch ($currencyIso) {
case 'EUR':
$locale = 'es_ES';
break;
case 'GBP':
$locale = 'en_GB';
break;
default:
$locale = 'en_US';
break;
}
$formattedAmount->setLocale($locale);
}
return $formattedAmount;
}
开发者ID:omusico,项目名称:logica,代码行数:28,代码来源:FormatAmount.php
示例18: getFromList
function getFromList(&$list)
{
$current_locale = I18n::getCurrentLangCode();
//require_once('Zend/Locale.php');
$locale = new \Zend_Locale($current_locale);
$current_currency = CUBI_DEFAULT_CURRENCY;
if (!$current_currency) {
$current_currency = "USD";
}
//require_once('Zend/Currency.php');
$currency = new \Zend_Currency($current_currency, $current_locale);
$currencyList = $currency->getCurrencyList();
foreach ($currencyList as $currency_code => $country) {
$display_name = $currency->getName($currency_code, $current_locale);
if ($display_name) {
array_push($list, array("val" => $currency_code, "txt" => "{$currency_code} - {$display_name}"));
}
}
return $list;
}
开发者ID:openbizx,项目名称:openbizx-cubix,代码行数:20,代码来源:CurrencySelector.php
示例19: 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);
}
}
开发者ID:ysilvela,项目名称:php-sdk,代码行数:51,代码来源:Currency.php
示例20: getNoOfSharersAllowed
/**
* Gets the number of sharers allowed.
*
* Method which returns the number of sharers that are permitted
* given a specified cover amount.
*
* @param Zend_Currency $coverAmount
* The main cover amount on the TCI+ policy.
*
* @return integer
* Returns the number of sharers allowed on the $coverAmount given.
*/
public function getNoOfSharersAllowed($coverAmount)
{
$params = Zend_Registry::get('params');
//Read in the lower contents bands.
$bandLower = array();
$bandLower[] = new Zend_Currency(array('value' => $params->sharers->band0->lower, 'precision' => 0));
$bandLower[] = new Zend_Currency(array('value' => $params->sharers->band1->lower, 'precision' => 0));
$bandLower[] = new Zend_Currency(array('value' => $params->sharers->band2->lower, 'precision' => 0));
$bandLower[] = new Zend_Currency(array('value' => $params->sharers->band3->lower, 'precision' => 0));
//Read in the upper contents bands.
$bandUpper = array();
$bandUpper[] = new Zend_Currency(array('value' => $params->sharers->band0->upper, 'precision' => 0));
$bandUpper[] = new Zend_Currency(array('value' => $params->sharers->band1->upper, 'precision' => 0));
$bandUpper[] = new Zend_Currency(array('value' => $params->sharers->band2->upper, 'precision' => 0));
$bandUpper[] = new Zend_Currency(array('value' => $params->sharers->band3->upper, 'precision' => 0));
$numberPermitted = array();
$numberPermitted[] = $params->sharers->numberPermitted->band0;
$numberPermitted[] = $params->sharers->numberPermitted->band1;
$numberPermitted[] = $params->sharers->numberPermitted->band2;
$numberPermitted[] = $params->sharers->numberPermitted->band3;
//Zero sharers by default until the cover amount is understood.
$returnVal = 0;
for ($i = 0; $i < count($bandLower); $i++) {
$bandFound = false;
if ($coverAmount->isMore($bandLower[$i]) && $coverAmount->isLess($bandUpper[$i])) {
$bandFound = true;
} else {
if ($coverAmount->equals($bandLower[$i]) || $coverAmount->equals($bandUpper[$i])) {
$bandFound = true;
}
}
if ($bandFound) {
$returnVal = $numberPermitted[$i];
break;
}
}
return $returnVal;
}
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:50,代码来源:Sharers.php
注:本文中的Zend_Currency类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论