summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected/QuickStartGlobalization.php
blob: 6a0b0fb2bbce713da546ea6fc3492c64bfe5c07c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php

class QuickStartGlobalization extends TGlobalizationAutoDetect
{
	public function init($xml)
	{
		parent::init($xml);
		$this->Application->OnBeginRequest[] = array($this, 'beginRequest');
	}

	public function beginRequest($sender, $param)
	{
		if(null == ($culture=$this->Request['lang']))
		{
			if(null !== ($cookie=$this->Request->Cookies['lang']))
				$culture = $cookie->getValue();
		}

		if(is_string($culture))
		{
			$info = new CultureInfo();
			if($info->validCulture($culture))
			{
				$this->setCulture($culture);
				$this->Response->Cookies[] = new THttpCookie('lang',$culture);
			}
		}
	}
}

?>