// Fix language switch (equal is not equal to equal equal)

This commit is contained in:
rMalie
2012-06-12 09:31:01 +00:00
parent 02d2438ddd
commit 4683f9a737
+7 -3
View File
@@ -334,9 +334,11 @@ class ToolsCore
/* If language does not exist or is disabled, erase it */
if ($cookie->id_lang)
{
//echo $cookie->id_lang;exit;
$lang = new Language((int)$cookie->id_lang);
if (!Validate::isLoadedObject($lang) || !$lang->active || !$lang->isAssociatedToShop())
$cookie->id_lang = null;
}
/* Automatically detect language if not already defined */
@@ -379,16 +381,18 @@ class ToolsCore
// update language only if new id is different from old id
// or if default language changed
$cookie_id_lang = $context->cookie->id_lang;
$configuration_id_lang = Configuration::get('PS_LANG_DEFAULT', null, null, $context->shop->id);
$configuration_id_lang = Configuration::get('PS_LANG_DEFAULT');
if ((($id_lang = (int)Tools::getValue('id_lang')) && Validate::isUnsignedId($id_lang) && $cookie_id_lang != (int)$id_lang)
|| (($id_lang = $configuration_id_lang) && Validate::isUnsignedId($id_lang) && $id_lang != $cookie_id_lang))
|| (($id_lang == $configuration_id_lang) && Validate::isUnsignedId($id_lang) && $id_lang != $cookie_id_lang))
{
$context->cookie->id_lang = $id_lang;
$language = new Language($id_lang);
if (Validate::isLoadedObject($language))
$context->language = $language;
Tools::redirect($_SERVER['REQUEST_URI']);
$params = $_GET;
unset($params['id_lang']);
Tools::redirect('index.php?'.http_build_query($params));
}
}