From 65731b050199ab7ecdd4027fa2d65f2175fe561e Mon Sep 17 00:00:00 2001 From: wei <> Date: Thu, 11 Jan 2007 05:06:31 +0000 Subject: Add structure for localized quickstart. --- .../protected/QuickStartGlobalization.php | 31 ++++++++++++++++++++++ demos/quickstart/protected/application.xml | 17 +++++++++--- demos/quickstart/protected/controls/Layout.php | 18 +++++++++++++ demos/quickstart/protected/controls/Layout.tpl | 12 +++++++++ .../quickstart/protected/controls/fr/TopicList.tpl | 10 +++++++ .../pages/GettingStarted/fr/Introduction.page | 4 +++ 6 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 demos/quickstart/protected/QuickStartGlobalization.php create mode 100644 demos/quickstart/protected/controls/fr/TopicList.tpl create mode 100644 demos/quickstart/protected/pages/GettingStarted/fr/Introduction.page (limited to 'demos/quickstart/protected') diff --git a/demos/quickstart/protected/QuickStartGlobalization.php b/demos/quickstart/protected/QuickStartGlobalization.php new file mode 100644 index 00000000..6a0b0fb2 --- /dev/null +++ b/demos/quickstart/protected/QuickStartGlobalization.php @@ -0,0 +1,31 @@ +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 diff --git a/demos/quickstart/protected/application.xml b/demos/quickstart/protected/application.xml index 3e2374d8..777dd86b 100644 --- a/demos/quickstart/protected/application.xml +++ b/demos/quickstart/protected/application.xml @@ -1,6 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/demos/quickstart/protected/controls/Layout.php b/demos/quickstart/protected/controls/Layout.php index 7c2cbd85..e4f2fc1a 100644 --- a/demos/quickstart/protected/controls/Layout.php +++ b/demos/quickstart/protected/controls/Layout.php @@ -24,6 +24,24 @@ class Layout extends TTemplateControl $this->MainMenu->Visible=false; $this->TopicPanel->Visible=false; } + + $this->languages->DataSource = TPropertyValue::ensureArray($this->Application->Parameters['languages']); + $this->languages->dataBind(); + } + + public function language_links($sender, $param) + { + $item = $param->Item; + if($item->ItemType == TListItemType::Item || $item->ItemType == TListItemType::AlternatingItem) + { + $params = $this->Request->toArray(); + $params['lang'] = $sender->DataKeys[$item->ItemIndex]; + unset($params[$this->Request->ServiceID]); + $url = $this->Service->ConstructUrl($this->Service->RequestedPagePath, $params); + $item->link->NavigateUrl = $url; + if($this->Application->Globalization->Culture == $params['lang']) + $item->link->CssClass="active"; + } } } diff --git a/demos/quickstart/protected/controls/Layout.tpl b/demos/quickstart/protected/controls/Layout.tpl index 52ab5bc4..87013156 100644 --- a/demos/quickstart/protected/controls/Layout.tpl +++ b/demos/quickstart/protected/controls/Layout.tpl @@ -29,6 +29,18 @@ + + + +
Available Languages:
    + + +
  • DataItem %> />
  • +
    + +
+ +
diff --git a/demos/quickstart/protected/controls/fr/TopicList.tpl b/demos/quickstart/protected/controls/fr/TopicList.tpl new file mode 100644 index 00000000..048f00fd --- /dev/null +++ b/demos/quickstart/protected/controls/fr/TopicList.tpl @@ -0,0 +1,10 @@ +
+ +
+
Getting Started
+ +
+ +
\ No newline at end of file diff --git a/demos/quickstart/protected/pages/GettingStarted/fr/Introduction.page b/demos/quickstart/protected/pages/GettingStarted/fr/Introduction.page new file mode 100644 index 00000000..a44319fa --- /dev/null +++ b/demos/quickstart/protected/pages/GettingStarted/fr/Introduction.page @@ -0,0 +1,4 @@ + +

French Intro

+ +
\ No newline at end of file -- cgit v1.2.3