diff options
author | christophe.boulain <> | 2008-12-03 14:22:03 +0000 |
---|---|---|
committer | christophe.boulain <> | 2008-12-03 14:22:03 +0000 |
commit | 6228873cf9d6471463d2413e7dfd7447f759baf2 (patch) | |
tree | 496a0e658330c39d4caa35602ba9f783b6f24f9c /framework/I18N/TNumberFormat.php | |
parent | e8f239fea7351b248302a593a8e5eaa2a88c3e80 (diff) |
Merge from trunk
Diffstat (limited to 'framework/I18N/TNumberFormat.php')
-rw-r--r-- | framework/I18N/TNumberFormat.php | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/framework/I18N/TNumberFormat.php b/framework/I18N/TNumberFormat.php index 12422521..62b43243 100644 --- a/framework/I18N/TNumberFormat.php +++ b/framework/I18N/TNumberFormat.php @@ -4,7 +4,7 @@ *
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
- * @copyright Copyright © 2005-2008 PradoSoft + * @copyright Copyright © 2005-2008 PradoSoft
* @license http://www.pradosoft.com/license/
* @version $Id$
* @package System.I18N
@@ -56,6 +56,9 @@ Prado::using('System.I18N.TI18NControl'); * The default is 'USD' if the Currency property is not specified.
* - <b>Pattern</b>, string,
* <br>Gets or sets the custom number formatting pattern.
+ * - <b>DefaultText</b>, string,
+ * <br>Gets or sets the default text. If Value is not set, DefaultText will be
+ * shown instead of the default currency Value/Pattern.
*
* @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version v1.0, last update on Sat Dec 11 17:49:56 EST 2004
@@ -105,6 +108,23 @@ class TNumberFormat extends TI18NControl implements IDataRenderer $this->setViewState('Value',$value,'');
}
+ /**
+ * Get the default text value for this control.
+ * @return string default text value
+ */
+ public function getDefaultText()
+ {
+ return $this->getViewState('DefaultText','');
+ }
+
+ /**
+ * Set the default text value for this control.
+ * @param string default text value
+ */
+ public function setDefaultText($value)
+ {
+ $this->setViewState('DefaultText',$value,'');
+ }
/**
* Get the numberic value for this control.
@@ -193,6 +213,11 @@ class TNumberFormat extends TI18NControl implements IDataRenderer */
protected function getFormattedValue()
{
+ $value = $this->getValue();
+ $defaultText = $this->getDefaultText();
+ if(empty($value) && !empty($defaultText))
+ return $this->getDefaultText();
+
$app = $this->getApplication()->getGlobalization();
//initialized the default class wide formatter
if(is_null(self::$formatter))
@@ -223,4 +248,4 @@ class TNumberFormat extends TI18NControl implements IDataRenderer }
}
-?> +?>
|