// Fix bug with dispatcher on going from a page in a language to an other one with an other language
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16170 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
1 parent
6a01c12854
commit
3d6119fc64
1 file changed
+32
-17
+32
-17
@@ -219,14 +219,9 @@ class DispatcherCore
|
|||||||
$this->default_controller = 'index';
|
$this->default_controller = 'index';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->loadRoutes();
|
$this->setRequestUri();
|
||||||
|
|
||||||
// Get request uri (HTTP_X_REWRITE_URL is used by IIS)
|
$this->loadRoutes();
|
||||||
if (isset($_SERVER['REQUEST_URI']))
|
|
||||||
$this->request_uri = $_SERVER['REQUEST_URI'];
|
|
||||||
else if (isset($_SERVER['HTTP_X_REWRITE_URL']))
|
|
||||||
$this->request_uri = $_SERVER['HTTP_X_REWRITE_URL'];
|
|
||||||
$this->request_uri = rawurldecode($this->request_uri);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -235,15 +230,6 @@ class DispatcherCore
|
|||||||
public function dispatch()
|
public function dispatch()
|
||||||
{
|
{
|
||||||
$controller_class = '';
|
$controller_class = '';
|
||||||
$this->request_uri = preg_replace('#^'.preg_quote(Context::getContext()->shop->getBaseURI(), '#').'#i', '/', $this->request_uri);
|
|
||||||
|
|
||||||
// If there are several languages, get language from uri
|
|
||||||
if ($this->use_routes && Language::isMultiLanguageActivated())
|
|
||||||
if (preg_match('#^/([a-z]{2})/#', $this->request_uri, $m))
|
|
||||||
{
|
|
||||||
$_GET['isolang'] = $m[1];
|
|
||||||
$this->request_uri = substr($this->request_uri, 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get current controller
|
// Get current controller
|
||||||
$this->getController();
|
$this->getController();
|
||||||
@@ -358,6 +344,29 @@ class DispatcherCore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set request uri and iso lang
|
||||||
|
*/
|
||||||
|
protected function setRequestUri()
|
||||||
|
{
|
||||||
|
// Get request uri (HTTP_X_REWRITE_URL is used by IIS)
|
||||||
|
if (isset($_SERVER['REQUEST_URI']))
|
||||||
|
$this->request_uri = $_SERVER['REQUEST_URI'];
|
||||||
|
else if (isset($_SERVER['HTTP_X_REWRITE_URL']))
|
||||||
|
$this->request_uri = $_SERVER['HTTP_X_REWRITE_URL'];
|
||||||
|
$this->request_uri = rawurldecode($this->request_uri);
|
||||||
|
|
||||||
|
$this->request_uri = preg_replace('#^'.preg_quote(Context::getContext()->shop->getBaseURI(), '#').'#i', '/', $this->request_uri);
|
||||||
|
|
||||||
|
// If there are several languages, get language from uri
|
||||||
|
if ($this->use_routes && Language::isMultiLanguageActivated())
|
||||||
|
if (preg_match('#^/([a-z]{2})/#', $this->request_uri, $m))
|
||||||
|
{
|
||||||
|
$_GET['isolang'] = $m[1];
|
||||||
|
$this->request_uri = substr($this->request_uri, 3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load default routes
|
* Load default routes
|
||||||
*/
|
*/
|
||||||
@@ -375,11 +384,17 @@ class DispatcherCore
|
|||||||
|
|
||||||
if ($this->use_routes)
|
if ($this->use_routes)
|
||||||
{
|
{
|
||||||
|
// Get iso lang
|
||||||
|
$iso_lang = Tools::getValue('isolang');
|
||||||
|
$id_lang = $context->language->id;
|
||||||
|
if (!empty($iso_lang))
|
||||||
|
$id_lang = Language::getIdByIso($iso_lang);
|
||||||
|
|
||||||
// Load routes from meta table
|
// Load routes from meta table
|
||||||
$sql = 'SELECT m.page, ml.url_rewrite
|
$sql = 'SELECT m.page, ml.url_rewrite
|
||||||
FROM `'._DB_PREFIX_.'meta` m
|
FROM `'._DB_PREFIX_.'meta` m
|
||||||
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.id_meta = ml.id_meta'.Shop::addSqlRestrictionOnLang('ml').')
|
LEFT JOIN `'._DB_PREFIX_.'meta_lang` ml ON (m.id_meta = ml.id_meta'.Shop::addSqlRestrictionOnLang('ml').')
|
||||||
WHERE id_lang = '.(int)$context->language->id.'
|
WHERE id_lang = '.(int)$id_lang.'
|
||||||
ORDER BY LENGTH(ml.url_rewrite) DESC';
|
ORDER BY LENGTH(ml.url_rewrite) DESC';
|
||||||
if ($results = Db::getInstance()->executeS($sql))
|
if ($results = Db::getInstance()->executeS($sql))
|
||||||
foreach ($results as $row)
|
foreach ($results as $row)
|
||||||
|
|||||||
Reference in new issue
Block a user