summaryrefslogtreecommitdiff
path: root/framework/I18N/TI18NControl.php
diff options
context:
space:
mode:
authorxue <>2006-04-03 21:55:33 +0000
committerxue <>2006-04-03 21:55:33 +0000
commit63c79dd722d5a8dd09b8828a4711d496680c0062 (patch)
tree1c535a0aa373a60d049aa669ab3d2944efdce4fa /framework/I18N/TI18NControl.php
parentb3e1b298e6fa8e327516d54d62856599faf443d2 (diff)
Cleanup of I18N.
Diffstat (limited to 'framework/I18N/TI18NControl.php')
-rw-r--r--framework/I18N/TI18NControl.php89
1 files changed, 43 insertions, 46 deletions
diff --git a/framework/I18N/TI18NControl.php b/framework/I18N/TI18NControl.php
index 44e15f2f..e6aed0fa 100644
--- a/framework/I18N/TI18NControl.php
+++ b/framework/I18N/TI18NControl.php
@@ -1,43 +1,63 @@
<?php
-
/**
* Base I18N component.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the BSD License.
- *
- * Copyright(c) 2004 by Xiang Wei Zhuo.
- *
- * To contact the author write to {@link mailto:qiang.xue@gmail.com Qiang Xue}
- * The latest version of PRADO can be obtained from:
- * {@link http://prado.sourceforge.net/}
*
- * @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
- * @version $Revision: 1.1 $ $Date: 2005/08/27 03:21:12 $
+ * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
+ * @link http://www.pradosoft.com/
+ * @copyright Copyright &copy; 2005 PradoSoft
+ * @license http://www.pradosoft.com/license/
+ * @version $Revision: $ $Date: $
* @package System.I18N
*/
/**
+ * TI18NControl class.
+ *
* Base class for I18N components, providing Culture and Charset properties.
* Namespace: System.I18N
*
* Properties
- * - <b>Culture</b>, string,
+ * - <b>Culture</b>, string,
* <br>Gets or sets the culture for formatting. If the Culture property
* is not specified. The culture from the Application/Page is used.
- * - <b>Charset</b>, string,
- * <br>Gets or sets the charset for both input and output.
- * If the Charset property is not specified. The charset from the
+ * - <b>Charset</b>, string,
+ * <br>Gets or sets the charset for both input and output.
+ * If the Charset property is not specified. The charset from the
* Application/Page is used. The default is UTF-8.
- *
+ *
* @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version v1.0, last update on Sat Dec 11 15:25:11 EST 2004
* @package System.I18N
*/
class TI18NControl extends TControl
{
-
+ /**
+ * Gets the charset.
+ * It is evaluated in the following order:
+ * 1) application charset,
+ * 2) the default charset in globalization
+ * 3) UTF-8
+ * @return string charset
+ */
+ public function getCharset()
+ {
+ $app = $this->getApplication()->getGlobalization();
+
+ //instance charset
+ $charset = $this->getViewState('Charset','');
+
+ //fall back to globalization charset
+ if(empty($charset))
+ $charset = is_null($app) ? '' : $app->getCharset();
+
+ //fall back to default charset
+ if(empty($charset))
+ $charset = (is_null($app)) ? 'UTF-8' : $app->getDefaultCharset();
+
+ return $charset;
+ }
+
/**
* Sets the charset for message output
* @param string the charset, e.g. UTF-8
@@ -45,50 +65,27 @@ class TI18NControl extends TControl
public function setCharset($value)
{
$this->setViewState('Charset',$value,'');
- }
+ }
+
-
/**
* Get the specific culture for this control.
* @param parameter
- * @return string culture identifier.
+ * @return string culture identifier.
*/
public function getCulture()
{
return $this->getViewState('Culture','');
}
-
+
/**
* Get the custom culture identifier.
- * @param string culture identifier.
+ * @param string culture identifier.
*/
public function setCulture($culture)
{
$this->setViewState('Culture',$culture,'');
}
-
- /**
- * Gets the charset, with fall back to the application charset,
- * then the default charset in globalization, and finally UTF-8
- * @return string charset
- */
- public function getCharset()
- {
- $app = $this->Application->getGlobalization();
-
- //instance charset
- $charset = $this->getViewState('Charset','');
-
- //fall back to globalization charset
- if(empty($charset))
- $charset = is_null($app) ? '' : $app->getCharset();
-
- //fall back to default charset
- if(empty($charset))
- $charset = (is_null($app)) ? 'UTF-8' : $app->getDefaultCharset();
-
- return $charset;
- }
}
?> \ No newline at end of file