summaryrefslogtreecommitdiff
path: root/demos/blog-tutorial/protected/common
diff options
context:
space:
mode:
Diffstat (limited to 'demos/blog-tutorial/protected/common')
-rwxr-xr-xdemos/blog-tutorial/protected/common/BlogTutorialGlobalization.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/demos/blog-tutorial/protected/common/BlogTutorialGlobalization.php b/demos/blog-tutorial/protected/common/BlogTutorialGlobalization.php
new file mode 100755
index 00000000..70435e34
--- /dev/null
+++ b/demos/blog-tutorial/protected/common/BlogTutorialGlobalization.php
@@ -0,0 +1,31 @@
+<?php
+
+class BlogTutorialGlobalization 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);
+ }
+ }
+ }
+}
+
+?> \ No newline at end of file