From 903b3a5293084afbd4fa07c7c83da1aa55f9f07b Mon Sep 17 00:00:00 2001 From: dignajar Date: Fri, 7 Aug 2015 14:59:21 -0300 Subject: [PATCH] Clean URL improves --- kernel/helpers/text.class.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/kernel/helpers/text.class.php b/kernel/helpers/text.class.php index 33a441ea..3b4967ef 100644 --- a/kernel/helpers/text.class.php +++ b/kernel/helpers/text.class.php @@ -52,6 +52,7 @@ class Text { return $text; } +/* public static function cleanUrl($string, $separator='-') { // Delete characters @@ -72,6 +73,21 @@ class Text { return $string; } +*/ + + public static function cleanUrl($string, $separator='-') + { + if(function_exists('iconv')) { + $string = iconv('UTF-8', 'ASCII//TRANSLIT', $string); + } + + $string = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $string); + $string = trim($string, '-'); + $string = self::lowercase($string); + $string = preg_replace("/[\/_|+ -]+/", $separator, $string); + + return $string; + } // Replace all occurrences of the search string with the replacement string. public static function replace($search, $replace, $string)