summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-04-16 14:43:51 +0000
committerxue <>2006-04-16 14:43:51 +0000
commit2983057ad91ccdef1fef86a85fe8e888350c3384 (patch)
tree6eb89e44b6d141d69779f8b2a26d18aeec641ee0
parenteeb97a9e51e87a359c2c069fc64b04b80d9ebe95 (diff)
Fixed a few issues with using Globalization.
-rw-r--r--.gitattributes5
-rw-r--r--framework/I18N/TI18NControl.php2
-rw-r--r--framework/I18N/TNumberFormat.php2
-rw-r--r--framework/I18N/TTranslate.php2
-rw-r--r--framework/PradoBase.php4
-rw-r--r--framework/TApplication.php5
-rw-r--r--framework/Web/THttpResponse.php10
-rw-r--r--framework/Web/UI/TTemplateManager.php2
-rw-r--r--framework/Web/UI/WebControls/TDatePicker.php2
-rw-r--r--tests/FunctionalTests/features/protected/pages/ImageMap/Home.page43
-rw-r--r--tests/FunctionalTests/features/protected/pages/ImageMap/Home.php12
-rw-r--r--tests/FunctionalTests/features/protected/pages/ImageMap/hotspot.jpgbin12206 -> 0 bytes
-rw-r--r--tests/FunctionalTests/features/protected/pages/MultiView/Home.page24
-rw-r--r--tests/FunctionalTests/features/protected/pages/Wizard/Home.page35
14 files changed, 16 insertions, 132 deletions
diff --git a/.gitattributes b/.gitattributes
index 44fd8a48..e7229317 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -859,12 +859,7 @@ tests/FunctionalTests/features/protected/pages/I18N/BasicI18N.php -text
tests/FunctionalTests/features/protected/pages/I18N/Home.page -text
tests/FunctionalTests/features/protected/pages/I18N/Home.zh_CN.page -text
tests/FunctionalTests/features/protected/pages/I18N/config.xml -text
-tests/FunctionalTests/features/protected/pages/ImageMap/Home.page -text
-tests/FunctionalTests/features/protected/pages/ImageMap/Home.php -text
-tests/FunctionalTests/features/protected/pages/ImageMap/hotspot.jpg -text
-tests/FunctionalTests/features/protected/pages/MultiView/Home.page -text
tests/FunctionalTests/features/protected/pages/RatingList.page -text
-tests/FunctionalTests/features/protected/pages/Wizard/Home.page -text
tests/FunctionalTests/index.php -text
tests/FunctionalTests/quickstart.php -text
tests/FunctionalTests/quickstart/Advanced/I18N.php -text
diff --git a/framework/I18N/TI18NControl.php b/framework/I18N/TI18NControl.php
index e6aed0fa..efe3ac84 100644
--- a/framework/I18N/TI18NControl.php
+++ b/framework/I18N/TI18NControl.php
@@ -42,7 +42,7 @@ class TI18NControl extends TControl
*/
public function getCharset()
{
- $app = $this->getApplication()->getGlobalization();
+ $app = $this->getApplication()->getGlobalization(false);
//instance charset
$charset = $this->getViewState('Charset','');
diff --git a/framework/I18N/TNumberFormat.php b/framework/I18N/TNumberFormat.php
index 4dc1e3ee..76373a8e 100644
--- a/framework/I18N/TNumberFormat.php
+++ b/framework/I18N/TNumberFormat.php
@@ -166,7 +166,7 @@ class TNumberFormat extends TI18NControl
*/
protected function getFormattedValue()
{
- $app = $this->Application->getGlobalization();
+ $app = $this->getApplication()->getGlobalization();
//initialized the default class wide formatter
if(is_null(self::$formatter))
self::$formatter = new NumberFormat($app->getCulture());
diff --git a/framework/I18N/TTranslate.php b/framework/I18N/TTranslate.php
index 0a03b506..6a30f3a6 100644
--- a/framework/I18N/TTranslate.php
+++ b/framework/I18N/TTranslate.php
@@ -168,7 +168,7 @@ class TTranslate extends TI18NControl
*/
protected function translateText($text, $subs)
{
- $app = $this->Application->getGlobalization();
+ $app = $this->getApplication()->getGlobalization();
//no translation handler provided
if(is_null($config = $app->getTranslationConfiguration()))
diff --git a/framework/PradoBase.php b/framework/PradoBase.php
index 329bb5da..e0c8cc52 100644
--- a/framework/PradoBase.php
+++ b/framework/PradoBase.php
@@ -533,14 +533,14 @@ class PradoBase
public static function localize($text, $parameters=array(), $catalogue=null, $charset=null)
{
Prado::using('System.I18N.Translation');
- $app = Prado::getApplication()->getGlobalization();
+ $app = Prado::getApplication()->getGlobalization(false);
$params = array();
foreach($parameters as $key => $value)
$params['{'.$key.'}'] = $value;
//no translation handler provided
- if(($config = $app->getTranslationConfiguration())===null)
+ if($app===null || ($config = $app->getTranslationConfiguration())===null)
return strtr($text, $params);
Translation::init();
diff --git a/framework/TApplication.php b/framework/TApplication.php
index fcc77b16..aa46f39d 100644
--- a/framework/TApplication.php
+++ b/framework/TApplication.php
@@ -754,10 +754,13 @@ class TApplication extends TComponent
}
/**
+ * @param boolean whether to create globalization if it does not exist
* @return TGlobalization globalization module
*/
- public function getGlobalization()
+ public function getGlobalization($createIfNotExists=true)
{
+ if($this->_globalization===null && $createIfNotExists)
+ $this->_globalization=new TGlobalization;
return $this->_globalization;
}
diff --git a/framework/Web/THttpResponse.php b/framework/Web/THttpResponse.php
index d4a62cc6..f76218ca 100644
--- a/framework/Web/THttpResponse.php
+++ b/framework/Web/THttpResponse.php
@@ -69,7 +69,7 @@ class THttpResponse extends TModule implements ITextWriter
/**
* @var string character set, e.g. UTF-8
*/
- private $_charset;
+ private $_charset='';
/**
* Destructor.
@@ -285,10 +285,10 @@ class THttpResponse extends TModule implements ITextWriter
*/
protected function sendContentTypeHeader()
{
- $charset = $this->getCharset();
- if(empty($charset) && ($globalization=$this->getApplication()->getGlobalization())!==null)
- $charset = $globalization->getCharset();
- if(!empty($charset))
+ $charset=$this->getCharset();
+ if($charset==='' && ($globalization=$this->getApplication()->getGlobalization(false))!==null)
+ $charset=$globalization->getCharset();
+ if($charset==='')
{
$header='Content-Type: '.$this->getContentType().';charset='.$charset;
$this->appendHeader($header);
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php
index dd3f7af8..71b53e19 100644
--- a/framework/Web/UI/TTemplateManager.php
+++ b/framework/Web/UI/TTemplateManager.php
@@ -100,7 +100,7 @@ class TTemplateManager extends TModule
*/
protected function getLocalizedTemplate($filename)
{
- if(($app=$this->getApplication()->getGlobalization())===null)
+ if(($app=$this->getApplication()->getGlobalization(false))===null)
return $filename;
foreach($app->getLocalizedResource($filename) as $file)
{
diff --git a/framework/Web/UI/WebControls/TDatePicker.php b/framework/Web/UI/WebControls/TDatePicker.php
index 9bb352d6..c6a2345b 100644
--- a/framework/Web/UI/WebControls/TDatePicker.php
+++ b/framework/Web/UI/WebControls/TDatePicker.php
@@ -406,7 +406,7 @@ class TDatePicker extends TTextBox
*/
protected function getCurrentCulture()
{
- $app = $this->getApplication()->getGlobalization();
+ $app = $this->getApplication()->getGlobalization(false);
return $this->getCulture() == '' ?
($app ? $app->getCulture() : 'en') : $this->getCulture();
}
diff --git a/tests/FunctionalTests/features/protected/pages/ImageMap/Home.page b/tests/FunctionalTests/features/protected/pages/ImageMap/Home.page
deleted file mode 100644
index 34631125..00000000
--- a/tests/FunctionalTests/features/protected/pages/ImageMap/Home.page
+++ /dev/null
@@ -1,43 +0,0 @@
-<com:TContent ID="Content">
-
-<com:TImageMap ImageUrl=<%~hotspot.jpg%> AlternateText="Navigate buttons" OnClick="buttonClicked" >
-
-<com:TRectangleHotSpot
- hotspotmode="Navigate"
- NavigateUrl="navigate1.htm"
- alternatetext="Button 1"
- top="30"
- left="175"
- bottom="110"
- right="355" />
-
-<com:TRectangleHotSpot
- hotspotmode="PostBack"
- PostBackValue="test"
- CausesValidation="true"
- ValidationGroup="Group1"
- alternatetext="Button 2"
- top="155"
- left="175"
- bottom="240"
- right="355" />
-
-<com:TRectangleHotSpot
- hotspotmode="Inactive"
- NavigateUrl="navigate3.htm"
- alternatetext="Button 3"
- top="285"
- left="175"
- bottom="365"
- right="355" />
-
-</com:TImageMap>
-
-<com:TTextBox ID="TextBox" />
-<com:TRequiredFieldValidator
- ValidationGroup="Group1"
- EnableClientScript="true"
- ControlToValidate="TextBox"
- Text="required" />
-
-</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/features/protected/pages/ImageMap/Home.php b/tests/FunctionalTests/features/protected/pages/ImageMap/Home.php
deleted file mode 100644
index 36ec7e9c..00000000
--- a/tests/FunctionalTests/features/protected/pages/ImageMap/Home.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-
-class Home extends TPage
-{
- public function buttonClicked($sender,$param)
- {
- //echo $param->getPostBackValue();
- print_r($param);
- }
-}
-
-?> \ No newline at end of file
diff --git a/tests/FunctionalTests/features/protected/pages/ImageMap/hotspot.jpg b/tests/FunctionalTests/features/protected/pages/ImageMap/hotspot.jpg
deleted file mode 100644
index 3491813f..00000000
--- a/tests/FunctionalTests/features/protected/pages/ImageMap/hotspot.jpg
+++ /dev/null
Binary files differ
diff --git a/tests/FunctionalTests/features/protected/pages/MultiView/Home.page b/tests/FunctionalTests/features/protected/pages/MultiView/Home.page
deleted file mode 100644
index 30ee1bbe..00000000
--- a/tests/FunctionalTests/features/protected/pages/MultiView/Home.page
+++ /dev/null
@@ -1,24 +0,0 @@
-<com:TContent ID="Content">
-
-<com:TMultiView ActiveViewIndex="2">
- <com:TView ID="View1">
- view 1
- <com:TTextBox Text="view 1" />
- <com:TButton Text="see view 2" CommandName="SwitchViewIndex" CommandParameter="1" />
- <com:TButton Text="see view 3" CommandName="SwitchViewIndex" CommandParameter="2" />
- </com:TView>
- <com:TView ID="View2">
- view 2
- <com:TTextBox Text="view 2" />
- <com:TButton Text="see view 1" CommandName="SwitchViewID" CommandParameter="View1" />
- <com:TButton Text="see view 3" CommandName="NextView" />
- </com:TView>
- <com:TView ID="View3">
- view 3
- <com:TTextBox Text="view 3" />
- <com:TButton Text="see view 1" CommandName="SwitchViewIndex" CommandParameter="0" />
- <com:TButton Text="see view 2" CommandName="PreviousView" />
- </com:TView>
-</com:TMultiView>
-
-</com:TContent> \ No newline at end of file
diff --git a/tests/FunctionalTests/features/protected/pages/Wizard/Home.page b/tests/FunctionalTests/features/protected/pages/Wizard/Home.page
deleted file mode 100644
index bcd93fef..00000000
--- a/tests/FunctionalTests/features/protected/pages/Wizard/Home.page
+++ /dev/null
@@ -1,35 +0,0 @@
-<com:TContent ID="Content">
-
-<com:TWizard
- HeaderText="Wizard Test"
- Width="300px"
- NavigationStyle.BackColor="silver"
- NavigationButtonStyle.BackColor="green"
- FinishCompleteButtonStyle.BackColor="red"
- >
- <com:TWizardStep Title="Step 1">
- step 1
- <com:TTextBox Text="step 1" ID="TextBox1" />
- <com:TRequiredFieldValidator ControlToValidate="TextBox1" Text="required 1" />
- </com:TWizardStep>
- <com:TWizardStep Title="Step 2" AllowReturn="false">
- step 2
- <com:TTextBox Text="step 2" ID="TextBox2" />
- <com:TRequiredFieldValidator ControlToValidate="TextBox2" Text="required 2" />
- </com:TWizardStep>
- <com:TTemplatedWizardStep Title="Step 22">
- <prop:ContentTemplate>
- <com:TTextBox Text="step 22" ID="TextBox22" />
- </prop:ContentTemplate>
- <prop:NavigationTemplate>
- <com:TButton Text="N...ext" CommandName="Complete" />
- </prop:NavigationTemplate>
- </com:TTemplatedWizardStep>
- <com:TWizardStep Title="Step 3" StepType="Complete">
- step 3
- <com:TTextBox Text="step 3" ID="TextBox3" />
- <com:TRequiredFieldValidator ControlToValidate="TextBox3" Text="required 3" />
- </com:TWizardStep>
-</com:TWizard>
-
-</com:TContent> \ No newline at end of file