summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwei <>2007-01-24 06:20:33 +0000
committerwei <>2007-01-24 06:20:33 +0000
commitd4d2da50c846c8b60f9b141d9f712d54f287e44b (patch)
treec21fafb34622db16f40904fd827ef03b1ecb1ab9
parent69e7bf1c66b645a99f1b4dd73863244d28b9c5b8 (diff)
Fixed #505, #508
-rw-r--r--HISTORY4
-rw-r--r--demos/quickstart/protected/pages/Advanced/Samples/I18N/Home.php3
-rw-r--r--framework/I18N/core/CultureInfo.php5
-rw-r--r--framework/I18N/core/HTTPNegotiator.php23
4 files changed, 21 insertions, 14 deletions
diff --git a/HISTORY b/HISTORY
index 75ddca7d..314c59d6 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,7 +1,9 @@
-Version 3.0.7
+Version 3.0.7 To be released
===================
BUG: Ticket#481 - Unable to cancel navigation when handling OnSideBarButtonClickEvent (Qiang)
BUG: typo in THttpResponse.writeFile() about sending headers (Qiang)
+BUG: Ticket#505 - cultureInfo::getEnglishName does not return an arrary (Wei)
+BUG: Ticket#508 - CultureInfo class: PHP Notice because of missing static declaration (Wei)
Version 3.0.6 December 4, 2006
==============================
diff --git a/demos/quickstart/protected/pages/Advanced/Samples/I18N/Home.php b/demos/quickstart/protected/pages/Advanced/Samples/I18N/Home.php
index d9a261d6..cce1ed4e 100644
--- a/demos/quickstart/protected/pages/Advanced/Samples/I18N/Home.php
+++ b/demos/quickstart/protected/pages/Advanced/Samples/I18N/Home.php
@@ -9,7 +9,8 @@ class Home extends TPage
{
parent::__construct();
$lang = $this->Request['lang'];
- if(CultureInfo::validCulture($lang)) //only valid lang is permitted
+ $info = new CultureInfo();
+ if($info->validCulture($lang)) //only valid lang is permitted
$this->getApplication()->getGlobalization()->setCulture($lang);
}
diff --git a/framework/I18N/core/CultureInfo.php b/framework/I18N/core/CultureInfo.php
index bcf2f245..404c81fe 100644
--- a/framework/I18N/core/CultureInfo.php
+++ b/framework/I18N/core/CultureInfo.php
@@ -414,7 +414,7 @@ class CultureInfo
* Gets the culture name in English.
* Returns <code>array('Language','Country');</code>
* 'Country' is omitted if the culture is neutral.
- * @return array array with language and country as elements.
+ * @return string language (country), it may locale code string if english name does not exist.
*/
function getEnglishName()
{
@@ -423,6 +423,9 @@ class CultureInfo
$culture = $this->getInvariantCulture();
$language = $culture->findInfo("Languages/{$lang}");
+ if(count($language) == 0)
+ return $this->culture;
+
$region = $culture->findInfo("Countries/{$reg}");
if($region)
return $language[0].' ('.$region[0].')';
diff --git a/framework/I18N/core/HTTPNegotiator.php b/framework/I18N/core/HTTPNegotiator.php
index f5eb876c..d4c80b50 100644
--- a/framework/I18N/core/HTTPNegotiator.php
+++ b/framework/I18N/core/HTTPNegotiator.php
@@ -24,7 +24,7 @@ require_once(dirname(__FILE__).'/CultureInfo.php');
/**
* HTTPNegotiator class.
- *
+ *
* Get the language and charset information from the client browser.
*
* @author Xiang Wei Zhuo <weizhuo[at]gmail[dot]com>
@@ -35,19 +35,19 @@ class HTTPNegotiator
{
/**
* A list of languages accepted by the browser.
- * @var array
+ * @var array
*/
protected $languages;
/**
* A list of charsets accepted by the browser
- * @var array
+ * @var array
*/
protected $charsets;
/**
* Get a list of languages acceptable by the client browser
- * @return array languages ordered in the user browser preferences.
+ * @return array languages ordered in the user browser preferences.
*/
function getLanguages()
{
@@ -61,14 +61,15 @@ class HTTPNegotiator
//$basedir = CultureInfo::dataDir();
//$ext = CultureInfo::fileExt();
+ $info = new CultureInfo();
- foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $lang)
+ foreach(explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $lang)
{
// Cut off any q-value that might come after a semi-colon
if ($pos = strpos($lang, ';'))
$lang = trim(substr($lang, 0, $pos));
- if (strstr($lang, '-'))
+ if (strstr($lang, '-'))
{
$codes = explode('-',$lang);
if($codes[0] == 'i')
@@ -91,16 +92,16 @@ class HTTPNegotiator
}
}
- if(CultureInfo::validCulture($lang))
+ if($info->validCulture($lang))
$this->languages[] = $lang;
}
-
+
return $this->languages;
}
/**
* Get a list of charsets acceptable by the client browser.
- * @return array list of charsets in preferable order.
+ * @return array list of charsets in preferable order.
*/
function getCharsets()
{
@@ -112,9 +113,9 @@ class HTTPNegotiator
if (!isset($_SERVER['HTTP_ACCEPT_CHARSET']))
return $this->charsets;
- foreach (explode(',', $_SERVER['HTTP_ACCEPT_CHARSET']) as $charset)
+ foreach (explode(',', $_SERVER['HTTP_ACCEPT_CHARSET']) as $charset)
{
- if (!empty($charset))
+ if (!empty($charset))
$this->charsets[] = preg_replace('/;.*/', '', $charset);
}