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


PHP Zend_Locale_Format::toNumber方法代码示例

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


在下文中一共展示了Zend_Locale_Format::toNumber方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDisplayValue

 /**
  *
  */
 public function getDisplayValue($pa_options = null)
 {
     if (caGetOption('returnAsDecimalWithCurrencySpecifier', $pa_options, false)) {
         return $this->ops_currency_specifier . ' ' . $this->opn_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($this->opn_value, array('locale' => $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
     $vs_val = str_replace('¤', $this->ops_currency_specifier, $vs_decimal_with_placeholder);
     if (($vs_to_currency = caGetOption('displayCurrencyConversion', $pa_options, false)) && $this->ops_currency_specifier != $vs_to_currency) {
         $vs_val .= " (" . _t("~%1", caConvertCurrencyValue($this->ops_currency_specifier . ' ' . $this->opn_value, $vs_to_currency)) . ")";
     }
     return $vs_val;
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:29,代码来源:CurrencyAttributeValue.php

示例2: format

 /**
  * Formats a given value
  * @see library/Bvb/Grid/Formatter/Bvb_Grid_Formatter_FormatterInterface::format()
  */
 public function format($value)
 {
     if (!is_numeric($value)) {
         return $value;
     }
     return Zend_Locale_Format::toNumber($value, $this->_options);
 }
开发者ID:Aeryris,项目名称:grid,代码行数:11,代码来源:Number.php

示例3: getDisplayValue

 /**
  *
  */
 public function getDisplayValue($pa_options = null)
 {
     if (caGetOption('returnAsDecimalWithCurrencySpecifier', $pa_options, false)) {
         return $this->ops_currency_specifier . ' ' . $this->opn_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($this->opn_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.
     // we do this because we don't print "$10" (which is expected in the Zend locale rules) but "USD 10" ... and that looks nicer with an additional space.
     // we also replace the weird multibyte nonsense Zend uses as placeholder with something more reasonable so that
     // whatever we output here isn't rejected if thrown into parseValue() again
     if (substr($vs_decimal_with_placeholder, 0, 2) == "¤") {
         // '¤' has length 2
         $vs_decimal_with_placeholder = str_replace("¤", '% ', $vs_decimal_with_placeholder);
     } elseif (substr($vs_decimal_with_placeholder, -2) == "¤") {
         // placeholder at the end
         $vs_decimal_with_placeholder = preg_replace("![^\\d\\,\\.]!", "", $vs_decimal_with_placeholder) . " %";
     }
     // insert currency which is not locale-dependent in our case
     $vs_val = str_replace('%', $this->ops_currency_specifier, $vs_decimal_with_placeholder);
     if (($vs_to_currency = caGetOption('displayCurrencyConversion', $pa_options, false)) && $this->ops_currency_specifier != $vs_to_currency) {
         $vs_val .= " (" . _t("~%1", caConvertCurrencyValue($this->ops_currency_specifier . ' ' . $this->opn_value, $vs_to_currency)) . ")";
     }
     return $vs_val;
 }
开发者ID:ffarago,项目名称:pawtucket2,代码行数:34,代码来源:CurrencyAttributeValue.php

示例4: smarty_modifier_number

/**
 * Returns a number in local specific format.
 *
 * @link http://framework.zend.com/manual/de/zend.locale.parsing.html
 * @param int|float $value
 * @param array     $format
 * @return mixed
 */
function smarty_modifier_number($value, $format = array())
{
    if (empty($format['locale'])) {
        $format['locale'] = Enlight_Application::Instance()->Locale();
    }
    return Zend_Locale_Format::toNumber($value, $format);
}
开发者ID:nvdnkpr,项目名称:Enlight,代码行数:15,代码来源:modifier.number.php

示例5: _createRowObject

 /**
  * Converts map array to microdata Object
  *
  * @param array $map map array returned by the generator
  * @return null|Varien_Object
  */
 protected function _createRowObject($map)
 {
     if (empty($map['price']) || empty($map['availability']) || empty($map['title'])) {
         return null;
     }
     $microdata = new Varien_Object();
     $microdata->setName($map['title']);
     $microdata->setId($map['id']);
     if (!empty($map['sale_price'])) {
         $price = $map['sale_price'];
     } else {
         $price = $map['price'];
     }
     $microdata->setPrice(Zend_Locale_Format::toNumber($price, array('precision' => 2, 'number_format' => '#0.00')));
     $microdata->setCurrency(Mage::app()->getStore()->getCurrentCurrencyCode());
     if ($map['availability'] == 'in stock') {
         $microdata->setAvailability('http://schema.org/InStock');
     } else {
         $microdata->setAvailability('http://schema.org/OutOfStock');
     }
     if (array_key_exists('condition', $map)) {
         if (strcasecmp('new', $map['condition']) == 0) {
             $microdata->setCondition('http://schema.org/NewCondition');
         } else {
             if (strcasecmp('used', $map['condition']) == 0) {
                 $microdata->setCondition('http://schema.org/UsedCondition');
             } else {
                 if (strcasecmp('refurbished', $map['condition']) == 0) {
                     $microdata->setCondition('http://schema.org/RefurbishedCondition');
                 }
             }
         }
     }
     return $microdata;
 }
开发者ID:brandontamm,项目名称:api-merchant-center,代码行数:41,代码来源:Microdata.php

示例6: getAnualPercentageRate

 public function getAnualPercentageRate($format = true)
 {
     $s = Zend_Locale_Format::toNumber($this->_anualPercentageRate, array('precision' => 2));
     if ($format) {
         return $s . '%';
     } else {
         return $s;
     }
 }
开发者ID:xiaoguizhidao,项目名称:bilderrahmen,代码行数:9,代码来源:Calculation.php

示例7: format

 /** Format a number with grouped thousands and localized decimal point/thousands separator.
  * @param number $number The number being formatted.
  * @param int|null $precision [default: null] The wanted precision; if null or not specified the complete localized number will be returned.
  * @return string
  * @example http://www.concrete5.org/documentation/how-tos/developers/formatting-numbers/ See the Formatting numbers how-to for more details
  */
 public function format($number, $precision = null)
 {
     if (!is_numeric($number)) {
         return $number;
     }
     $options = array('locale' => $this->getZendLocale());
     if (is_numeric($precision)) {
         $options['precision'] = $precision;
     }
     return Zend_Locale_Format::toNumber($number, $options);
 }
开发者ID:ojalehto,项目名称:concrete5-legacy,代码行数:17,代码来源:number.php

示例8: number

 public static function number($number, $precision = "", $locale = "")
 {
     global $config;
     $locale == "" ? $locale = new Zend_Locale($config->local->locale) : ($locale = $locale);
     $load_precision = $config->local->precision;
     $precision == "" ? $precision = $load_precision : ($precision = $precision);
     $formatted_number = Zend_Locale_Format::toNumber($number, array('precision' => $precision, 'locale' => $locale));
     //trim zeros from decimal point if enabled
     //if ($config->local->trim_zeros == "y") { $formatted_number = rtrim(trim($formatted_number, '0'), '.'); }
     return $formatted_number;
 }
开发者ID:alachaum,项目名称:simpleinvoices,代码行数:11,代码来源:siLocal.php

示例9: setValue

 /**
  * @param mixed $value
  * @param array $data
  *
  * @return $this
  *
  * @throws Zend_Locale_Exception
  */
 public function setValue($value, $data = array())
 {
     require_once "Zend/Locale/Format.php";
     // If passing in a non-string number, or a value
     // directly from a DataObject then localise this number
     if (is_int($value) || is_float($value) || $data instanceof DataObject) {
         $locale = new Zend_Locale($this->getLocale());
         $this->value = Zend_Locale_Format::toNumber($value, array('locale' => $locale));
     } else {
         $this->value = $this->clean($value);
     }
     return $this;
 }
开发者ID:maent45,项目名称:redefine_renos,代码行数:21,代码来源:NumericField.php

示例10: __toString

 public function __toString()
 {
     $value = $this->getValue();
     if (is_numeric($value)) {
         try {
             $locale = Zend_Registry::get("Zend_Locale");
         } catch (Exception $e) {
         }
         if ($locale) {
             $value = Zend_Locale_Format::toNumber($value, array('locale' => $locale));
         }
     }
     return $value . " " . $this->getUnit()->getAbbreviation();
 }
开发者ID:sfie,项目名称:pimcore,代码行数:14,代码来源:QuantityValue.php

示例11: Value

 /**
  * @return string
  * @throws Zend_Locale_Exception
  */
 public function Value()
 {
     if (!$this->isNumeric()) {
         return '0%';
     }
     require_once "Zend/Locale/Format.php";
     $locale = new Zend_Locale($this->getLocale());
     // convert from the stored format to a real number so we can multiply
     $number = Zend_Locale_Format::getNumber($this->clean($this->value), array('locale' => $locale));
     $number *= 100.0;
     // convert back to string
     $val = Zend_Locale_Format::toNumber($number, array('locale' => $locale));
     return $val . '%';
 }
开发者ID:markguinn,项目名称:silverstripe-shop-extendedpricing,代码行数:18,代码来源:PercentageField.php

示例12: 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

示例13: setValue

 public function setValue($value, $data = array())
 {
     require_once "Zend/Locale/Format.php";
     // If passing in a non-string number, or a value
     // directly from a dataobject then localise this number
     if (is_numeric($value) && !is_string($value) || $value && $data instanceof DataObject) {
         $locale = new Zend_Locale($this->getLocale());
         $this->value = Zend_Locale_Format::toNumber($value, array('locale' => $locale));
     } else {
         // If an invalid number, store it anyway, but validate() will fail
         $this->value = $this->clean($value);
     }
     return $this;
 }
开发者ID:nicocin,项目名称:silverstripe-framework,代码行数:14,代码来源:NumericField.php

示例14: getTaxRateIDs

 public function getTaxRateIDs($locale = null)
 {
     $taxrateDb = new Application_Model_DbTable_Taxrate();
     $taxratesObject = $taxrateDb->fetchAll();
     $taxrates = array();
     if ($locale) {
         foreach ($taxratesObject as $taxrate) {
             $taxrates[$taxrate->id] = Zend_Locale_Format::toNumber($taxrate->rate, array('precision' => 1, 'locale' => $locale)) . ' %';
         }
     } else {
         foreach ($taxratesObject as $taxrate) {
             $taxrates[$taxrate->id] = $taxrate->rate;
         }
     }
     return $taxrates;
 }
开发者ID:dewawi,项目名称:dewawi,代码行数:16,代码来源:TaxRate.php

示例15: testToNumber

 /**
  * test to number
  * expected string
  */
 public function testToNumber()
 {
     $this->assertEquals(Zend_Locale_Format::toNumber(0), '0', "string 0 expected");
     $this->assertEquals(Zend_Locale_Format::toNumber(0, 'de'), '0', "string 0 expected");
     $this->assertEquals(Zend_Locale_Format::toNumber(0, 'de_AT'), '0', "string 0 expected");
     $this->assertEquals(Zend_Locale_Format::toNumber(-1234567, 'de_AT'), '-1.234.567', "string -1.234.567 expected");
     $this->assertEquals(Zend_Locale_Format::toNumber(1234567, 'de_AT'), '1.234.567', "string 1.234.567 expected");
     $this->assertEquals(Zend_Locale_Format::toNumber(0.1234567, 'de_AT'), '0,1234567', "string 0,1234567 expected");
     $this->assertEquals(Zend_Locale_Format::toNumber(-1234567.12345, 'de_AT'), '-1.234.567,12345', "string -1.234.567,12345 expected");
     $this->assertEquals(Zend_Locale_Format::toNumber(1234567.12345, 'de_AT'), '1.234.567,12345', "value 1.234.567,12345 expected");
     $this->assertEquals(Zend_Locale_Format::toNumber(1234567.12345, 'ar_QA'), '1234567٫12345', "value 1234567٫12345 expected");
     $this->assertEquals(Zend_Locale_Format::toNumber(-1234567.12345, 'ar_QA'), '1234567٫12345-', "value 1234567٫12345- expected");
     $this->assertEquals(Zend_Locale_Format::toNumber(1234567.12345, 'dz_BT'), '12,34,567.12345', "value 12,34,567.12345 expected");
     $this->assertEquals(Zend_Locale_Format::toNumber(-1234567.12345, 'mk_MK'), '-(1.234.567,12345)', "value -(1.234.567,12345) expected");
     $this->assertEquals(Zend_Locale_Format::toNumber(452.25, 'en_US'), '452.25', "value 452.25 expected");
     $this->assertEquals(Zend_Locale_Format::toNumber(54321.1234, 'en_US'), '54,321.1234', "value 54,321.1234 expected");
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:21,代码来源:FormatTest.php


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