// Blocklayered: Fix bug with urlrewrite

This commit is contained in:
mDeflotte
2012-03-29 15:25:02 +00:00
parent c4bb0c2a14
commit ff0a447a44
4 changed files with 81 additions and 35 deletions
+14 -2
View File
@@ -64,6 +64,18 @@ class DispatcherCore
'tags' => array('regexp' => '[a-zA-Z0-9-\pL]*'),
),
),
'layered_rule' => array(
'controller' => 'category',
'rule' => '{id}-{rewrite}{/:selected_filters}',
'keywords' => array(
'id' => array('regexp' => '[0-9]+', 'param' => 'id_category'),
/* Selected filters is used by the module blocklayered */
'selected_filters' => array('regexp' => '.*', 'param' => 'selected_filters'),
'rewrite' => array('regexp' => '[a-zA-Z0-9-\pL]*'),
'meta_keywords' => array('regexp' => '[a-zA-Z0-9-\pL]*'),
'meta_title' => array('regexp' => '[a-zA-Z0-9-\pL]*'),
),
),
'category_rule' => array(
'controller' => 'category',
'rule' => '{id}-{rewrite}',
@@ -249,8 +261,8 @@ class DispatcherCore
$controllers['authentication'] = $controllers['auth'];
if (isset($controllers['compare']))
$controllers['productscomparison'] = $controllers['compare'];
if (isset($controllers['contact']))
$controllers['contactform'] = $controllers['contact'];
if (isset($controllers['contact']))
$controllers['contactform'] = $controllers['contact'];
if (!isset($controllers[$this->controller]))
$this->controller = $this->controller_not_found;
+14 -2
View File
@@ -133,9 +133,10 @@ class LinkCore
* @param mixed $category Category object (can be an ID category, but deprecated)
* @param string $alias
* @param int $id_lang
* @param string $selected_filters Url parameter to autocheck filters of the module blocklayered
* @return string
*/
public function getCategoryLink($category, $alias = null, $id_lang = null)
public function getCategoryLink($category, $alias = null, $id_lang = null, $selected_filters = null)
{
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
@@ -150,8 +151,19 @@ class LinkCore
$params['rewrite'] = (!$alias) ? $category->link_rewrite : $alias;
$params['meta_keywords'] = Tools::str2url($category->meta_keywords);
$params['meta_title'] = Tools::str2url($category->meta_title);
// Selected filters is used by the module blocklayered
$selected_filters = is_null($selected_filters) ? Tools::getValue('selected_filters') : $selected_filters;
if (empty($selected_filters))
$rule = 'category_rule';
else
{
$rule = 'layered_rule';
$params['selected_filters'] = $selected_filters;
}
return $url.Dispatcher::getInstance()->createUrl('category_rule', $params, $this->allow);
return $url.Dispatcher::getInstance()->createUrl($rule, $params, $this->allow);
}
/**
+1 -1
View File
@@ -591,7 +591,7 @@ class FrontControllerCore extends Controller
$matchUrl = (($this->ssl && Configuration::get('PS_SSL_ENABLED')) ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$matchUrl = rawurldecode($matchUrl);
if (!preg_match('/^'.Tools::pRegexp($canonicalURL, '/').'([&?].*)?$/', $matchUrl))
if (!preg_match('/^'.Tools::pRegexp(rawurldecode($canonicalURL), '/').'([&?].*)?$/', $matchUrl))
{
$params = array();
$excludedKey = array('isolang', 'id_lang', 'controller', 'fc');