From aa46c9ab78abdd23c273c5e49b402a87a2aefcdb Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 8 Feb 2006 23:18:20 +0000 Subject: Changed accessibility of a few render-related methods (needed by adapters). --- framework/I18N/TNumberFormat.php | 80 ++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'framework/I18N/TNumberFormat.php') diff --git a/framework/I18N/TNumberFormat.php b/framework/I18N/TNumberFormat.php index 9f2de233..e50a0de3 100644 --- a/framework/I18N/TNumberFormat.php +++ b/framework/I18N/TNumberFormat.php @@ -1,11 +1,11 @@ * * - * + * * Numbers can be formatted as currency, percentage, decimal or scientific - * numbers by specifying the Type attribute. The known types are + * numbers by specifying the Type attribute. The known types are * "currency", "percentage", "decimal" and "scientific". * - * If someone from US want to see sales figures from a store in - * Germany (say using the EURO currency), formatted using the german - * currency, you would need to use the attribute Culture="de_DE" to get - * the currency right, e.g. 100,00 â‚?. The decimal and grouping separator is - * then also from the de_DE locale. This may lead to some confusion because + * If someone from US want to see sales figures from a store in + * Germany (say using the EURO currency), formatted using the german + * currency, you would need to use the attribute Culture="de_DE" to get + * the currency right, e.g. 100,00 â‚?. The decimal and grouping separator is + * then also from the de_DE locale. This may lead to some confusion because * people from US know the "," as thousand separator. Therefore a "Currency" * attribute is available, so that the output from the following example * results in â‚?100.00 * * * - * + * * Namespace: System.I18N * * Properties - * - Value, number, + * - Value, number, *
Gets or sets the number to format. The tag content is used as Value * if the Value property is not specified. * - Type, string, - *
Gets or sets the formatting type. The valid types are + *
Gets or sets the formatting type. The valid types are * 'decimal', 'currency', 'percentage' and 'scientific'. - * - Currency, string, + * - Currency, string, *
Gets or sets the currency symbol for the currency format. * The default is 'USD' if the Currency property is not specified. * - Pattern, string, @@ -62,15 +62,15 @@ Prado::using('System.I18N.core.NumberFormat'); * @author Xiang Wei Zhuo * @version v1.0, last update on Sat Dec 11 17:49:56 EST 2004 * @package System.I18N - */ -class TNumberFormat extends TI18NControl + */ +class TNumberFormat extends TI18NControl { /** * Default NumberFormat, set to the application culture. - * @var NumberFormat + * @var NumberFormat */ protected static $formatter; - + /** * Get the number formatting pattern. * @return string format pattern. @@ -79,7 +79,7 @@ class TNumberFormat extends TI18NControl { return $this->getViewState('Pattern',''); } - + /** * Set the number format pattern. * @param string format pattern. @@ -88,16 +88,16 @@ class TNumberFormat extends TI18NControl { $this->setViewState('Pattern',$pattern,''); } - + /** * Get the numberic value for this control. * @return string number */ function getValue() - { + { return $this->getViewState('Value',''); } - + /** * Set the numberic value for this control. * @param string the number value @@ -106,7 +106,7 @@ class TNumberFormat extends TI18NControl { $this->setViewState('Value',$value,''); } - + /** * Get the formatting type for this control. * @return string formatting type. @@ -118,17 +118,17 @@ class TNumberFormat extends TI18NControl return 'd'; return $type; } - + /** * Set the formatting type for this control. - * @param string formatting type, either "decimal", "currency","percentage" + * @param string formatting type, either "decimal", "currency","percentage" * or "scientific" * @throws TPropertyTypeInvalidException */ function setType($type) { $type = strtolower($type); - + switch($type) { case 'decimal': @@ -142,13 +142,13 @@ class TNumberFormat extends TI18NControl default: throw new TPropertyTypeInvalidException($this,'Type',$type); } - + } - + /** * Get the currency for this control. * @param parameter - * @return string 3 letter currency code. + * @return string 3 letter currency code. */ function getCurrency() { @@ -157,33 +157,33 @@ class TNumberFormat extends TI18NControl return 'USD'; return $currency; } - + /** - * Set the 3-letter ISO 4217 code. For example, the code + * Set the 3-letter ISO 4217 code. For example, the code * "USD" represents the US Dollar and "EUR" represents the Euro currency. * @param string currency code. */ function setCurrency($currency) { $this->setViewState('Currency', $currency,''); - } - + } + /** * Formats the localized number, be it currency or decimal, or percentage. * If the culture is not specified, the default application * culture will be used. * @return string formatted number - */ + */ protected function getFormattedValue() { $app = $this->Application->getGlobalization(); //initialized the default class wide formatter if(is_null(self::$formatter)) self::$formatter = new NumberFormat($app->getCulture()); - - $pattern = strlen($this->getPattern()) > 0 + + $pattern = strlen($this->getPattern()) > 0 ? $this->getPattern() : $this->getType(); - + $culture = $this->getCulture(); //return the specific cultural formatted number if(!empty($culture) && $app->getCulture() != $culture) @@ -193,14 +193,14 @@ class TNumberFormat extends TI18NControl $this->getCurrency(), $this->getCharset()); } - + //return the application wide culture formatted number. return self::$formatter->format($this->getValue(),$pattern, - $this->getCurrency(), + $this->getCurrency(), $this->getCharset()); } - protected function render($writer) + public function render($writer) { $writer->write($this->getFormattedValue()); } -- cgit v1.2.3