当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Currency类代码示例

本文整理汇总了PHP中Zend_Currency的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Currency类的具体用法?PHP Zend_Currency怎么用?PHP Zend_Currency使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Zend_Currency类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的Zend_Currency类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。