From 849c2da9eb22fbff8ed101909919433b1ed9b1db Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Thu, 14 Feb 2013 09:14:48 +0100 Subject: [PATCH] [*] BO : the option for accented URLs is now available in the backend --- classes/Tools.php | 8 ++++---- controllers/admin/AdminMetaController.php | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/classes/Tools.php b/classes/Tools.php index 845ee3682..ba0ce7031 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -978,11 +978,11 @@ class ToolsCore if ($allow_accented_chars === null) $allow_accented_chars = Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'); + $str = trim($str); + if (function_exists('mb_strtolower')) $str = mb_strtolower($str, 'utf-8'); - - $str = trim($str); - if (!function_exists('mb_strtolower') || !$allow_accented_chars) + elseif (!$allow_accented_chars) $str = Tools::replaceAccentedChars($str); // Remove all non-whitelist chars. @@ -990,7 +990,7 @@ class ToolsCore $str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-\pL]/u', '', $str); else $str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-]/','', $str); - + $str = preg_replace('/[\s\'\:\/\[\]-]+/', ' ', $str); $str = str_replace(array(' ', '/'), '-', $str); diff --git a/controllers/admin/AdminMetaController.php b/controllers/admin/AdminMetaController.php index dfc09fa84..85cef7942 100644 --- a/controllers/admin/AdminMetaController.php +++ b/controllers/admin/AdminMetaController.php @@ -64,6 +64,13 @@ class AdminMetaControllerCore extends AdminController 'type' => 'rewriting_settings', 'mod_rewrite' => $mod_rewrite ), + 'PS_ALLOW_ACCENTED_CHARS_URL' => array( + 'title' => $this->l('Accented URL'), + 'desc' => $this->l('Enable if you want to allow accented characters in your friendly URLs.'), + 'validation' => 'isBool', + 'cast' => 'intval', + 'type' => 'bool' + ), 'PS_CANONICAL_REDIRECT' => array( 'title' => $this->l('Automatically redirect to the canonical URL.'), 'desc' => $this->l('Recommended, but your theme must be compliant.'),