summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes3
-rw-r--r--demos/quickstart/protected/QuickStartGlobalization.php31
-rw-r--r--demos/quickstart/protected/application.xml17
-rw-r--r--demos/quickstart/protected/controls/Layout.php18
-rw-r--r--demos/quickstart/protected/controls/Layout.tpl12
-rw-r--r--demos/quickstart/protected/controls/fr/TopicList.tpl10
-rw-r--r--demos/quickstart/protected/pages/GettingStarted/fr/Introduction.page4
-rw-r--r--demos/quickstart/themes/PradoSoft/style.css18
8 files changed, 110 insertions, 3 deletions
diff --git a/.gitattributes b/.gitattributes
index d43a248b..b7df44ef 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -810,6 +810,7 @@ demos/quickstart/images/star5.gif -text
demos/quickstart/index.php -text
demos/quickstart/index2.php -text
demos/quickstart/protected/.htaccess -text
+demos/quickstart/protected/QuickStartGlobalization.php -text
demos/quickstart/protected/application.xml -text
demos/quickstart/protected/controls/DocLink.php -text
demos/quickstart/protected/controls/Layout.php -text
@@ -822,6 +823,7 @@ demos/quickstart/protected/controls/SearchBox.php -text
demos/quickstart/protected/controls/SearchBox.tpl -text
demos/quickstart/protected/controls/TopicList.php -text
demos/quickstart/protected/controls/TopicList.tpl -text
+demos/quickstart/protected/controls/fr/TopicList.tpl -text
demos/quickstart/protected/index/Zend/Exception.php -text
demos/quickstart/protected/index/Zend/LICENSE.txt -text
demos/quickstart/protected/index/Zend/Search/Exception.php -text
@@ -1128,6 +1130,7 @@ demos/quickstart/protected/pages/GettingStarted/Installation.page -text
demos/quickstart/protected/pages/GettingStarted/Introduction.page -text
demos/quickstart/protected/pages/GettingStarted/Upgrading.page -text
demos/quickstart/protected/pages/GettingStarted/directory.gif -text
+demos/quickstart/protected/pages/GettingStarted/fr/Introduction.page -text
demos/quickstart/protected/pages/GettingStarted/sequence.gif -text
demos/quickstart/protected/pages/GettingStarted/sequence.vsd -text
demos/quickstart/protected/pages/Search.page -text
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 @@
+<?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);
+ }
+ }
+ }
+}
+
+?> \ 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 @@
<?xml version="1.0" encoding="utf-8"?>
<application id="QuickStart" Mode="Debug">
+ <paths>
+ <using namespace="Application.controls.*" />
+ <using namespace="System.I18N.*" />
+ </paths>
+
<modules>
<!-- uncomment the following to enable caching
<module id="cache" class="System.Caching.TSqliteCache" />
@@ -13,11 +18,17 @@
<module id="quickstart_search"
class="Application.index.ZendSearch"
IndexDataDirectory="Application.index.quickstart" />
+
+ <module id="globalization" class="Application.QuickStartGlobalization" Charset="UTF-8"/>
</modules>
- <paths>
- <using namespace="Application.controls.*" />
- </paths>
<services>
<service id="page" class="TPageService" DefaultPage="GettingStarted.Introduction" />
</services>
+
+<!--
+ <parameters>
+ <parameter id="languages" value="('en'=>'English', 'fr'=>'Français', 'zh' => '中文(简体)')" />
+ </parameters>
+-->
+
</application> \ 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 @@
<com:TopicList ID="TopicPanel" />
</td>
<td valign="top">
+
+<com:TRepeater ID="languages" OnItemCreated="language_links">
+ <prop:HeaderTemplate>
+ <div class="languages">Available Languages: <ul>
+ </prop:HeaderTemplate>
+ <prop:ItemTemplate>
+ <li><com:THyperLink ID="link" Text=<%# $this->DataItem %> /></li>
+ </prop:ItemTemplate>
+ <prop:FooterTemplate>
+ </ul></div>
+ </prop:FooterTemplate>
+</com:TRepeater>
<div id="content">
<com:TContentPlaceHolder ID="body" />
</div>
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 @@
+<div id="toc">
+
+<div class="topic">
+<div>Getting Started</div>
+<ul>
+ <li><a href="?page=GettingStarted.Introduction">Introduction</a></li>
+</ul>
+</div>
+
+</div> \ 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 @@
+<com:TContent ID="body" >
+<h1 id="101">French Intro</h1>
+
+</com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/themes/PradoSoft/style.css b/demos/quickstart/themes/PradoSoft/style.css
index d7e94032..82aa3dd5 100644
--- a/demos/quickstart/themes/PradoSoft/style.css
+++ b/demos/quickstart/themes/PradoSoft/style.css
@@ -67,6 +67,24 @@ a
}
+.languages
+{
+ text-align: right;
+ margin: 0.5em 1em;
+}
+
+.languages ul, .languages li
+{
+ margin: 0; padding: 0;
+ list-style: none;
+ display: inline;
+}
+
+.languages a.active
+{
+ color: black;
+ text-decoration: none;
+}
.mainmenu {
padding:10px;