Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * Base I18N component.
4
 *
5
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
6
 * @link http://www.pradosoft.com/
7
 * @copyright Copyright &copy; 2005-2008 PradoSoft
8
 * @license http://www.pradosoft.com/license/
9
 * @version $Id: TI18NControl.php 2541 2008-10-21 15:05:13Z qiang.xue $
10
 * @package System.I18N
11
 */
12
 
13
 
14
/**
15
 * TI18NControl class.
16
 *
17
 * Base class for I18N components, providing Culture and Charset properties.
18
 * Namespace: System.I18N
19
 *
20
 * Properties
21
 * - <b>Culture</b>, string,
22
 *   <br>Gets or sets the culture for formatting. If the Culture property
23
 *   is not specified. The culture from the Application/Page is used.
24
 * - <b>Charset</b>, string,
25
 *   <br>Gets or sets the charset for both input and output.
26
 *   If the Charset property is not specified. The charset from the
27
 *   Application/Page is used. The default is UTF-8.
28
 *
29
 * @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
30
 * @version v1.0, last update on Sat Dec 11 15:25:11 EST 2004
31
 * @package System.I18N
32
 */
33
class TI18NControl extends TControl
34
{
35
	/**
36
	 * Gets the charset.
37
	 * It is evaluated in the following order:
38
	 * 1) application charset,
39
	 * 2) the default charset in globalization
40
	 * 3) UTF-8
41
	 * @return string charset
42
	 */
43
	public function getCharset()
44
	{
45
		$app = $this->getApplication()->getGlobalization(false);
46
 
47
		//instance charset
48
		$charset = $this->getViewState('Charset','');
49
 
50
		//fall back to globalization charset
51
		if(empty($charset))
52
			$charset = is_null($app) ? '' : $app->getCharset();
53
 
54
		//fall back to default charset
55
		if(empty($charset))
56
			$charset = (is_null($app)) ? 'UTF-8' : $app->getDefaultCharset();
57
 
58
		return $charset;
59
	}
60
 
61
	/**
62
	 * Sets the charset for message output
63
	 * @param string the charset, e.g. UTF-8
64
	 */
65
	public function setCharset($value)
66
	{
67
		$this->setViewState('Charset',$value,'');
68
	}
69
 
70
 
71
	/**
72
	 * Get the specific culture for this control.
73
	 * @param parameter
74
	 * @return string culture identifier.
75
	 */
76
	public function getCulture()
77
	{
78
		return $this->getViewState('Culture','');
79
	}
80
 
81
	/**
82
	 * Get the custom culture identifier.
83
	 * @param string culture identifier.
84
	 */
85
	public function setCulture($culture)
86
	{
87
		$this->setViewState('Culture',$culture,'');
88
	}
89
}
90