//// Merge -> revision 8290

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8295 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
tDidierjean
2011-09-01 09:53:43 +00:00
parent d27c0b3b7d
commit c2258ae8e9
50 changed files with 431 additions and 256 deletions
+12 -8
View File
@@ -25,8 +25,6 @@
* International Registered Trademark & Property of PrestaShop SA
*/
include_once("../classes/Validate.php");
class LanguageManager
{
private $url_xml;
@@ -72,8 +70,12 @@ class LanguageManager
return $this->lang;
}
/** get the http_accept_language isocode (if exists),
* and use it to find the corresponding prestashop id_lang
* otherwise, return 0.
* @return int id_lang to use
*/
private function getIdByHAL(){
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
{
$FirstHAL = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
@@ -86,14 +88,16 @@ class LanguageManager
}
else
return 0;
}
/** set lang property with param $_GET['language'] if present,
* or by $_SERVER['HTTP_ACCEPT_LANGUAGE'] otherwise
*/
private function setLanguage()
{
if( isset($_GET['language']) AND Validate::isInt($_GET['language']))
$id_lang = (int)($_GET['language']);
if (!isset($id_lang))
if ( !empty($_GET['language']))
$id_lang = (int)($_GET['language'])>0 ? $_GET['language'] : 0;
if (empty($id_lang))
$id_lang = ($this->getIdByHAL());
$this->lang = $this->xml_file->lang[(int)($id_lang)];
}
@@ -102,4 +106,4 @@ class LanguageManager
{
return ($this->lang == NULL) ? false : dirname(__FILE__).$this->lang['trad_file'];
}
}
}