summaryrefslogtreecommitdiff
path: root/system/helpers/url.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/helpers/url.php')
-rw-r--r--system/helpers/url.php21
1 files changed, 15 insertions, 6 deletions
diff --git a/system/helpers/url.php b/system/helpers/url.php
index 6c2a6c66..4a94e894 100644
--- a/system/helpers/url.php
+++ b/system/helpers/url.php
@@ -2,7 +2,7 @@
/**
* URL helper class.
*
- * $Id: url.php 4679 2009-11-10 01:45:52Z isaiah $
+ * $Id: url.php 4685 2009-11-30 21:24:06Z isaiah $
*
* @package Core
* @author Kohana Team
@@ -160,17 +160,26 @@ class url_Core {
*
* @param string phrase to convert
* @param string word separator (- or _)
+ * @param boolean transliterate to ASCII
* @return string
*/
- public static function title($title, $separator = '-')
+ public static function title($title, $separator = '-', $ascii_only = FALSE)
{
$separator = ($separator === '-') ? '-' : '_';
- // Replace accented characters by their unaccented equivalents
- $title = text::transliterate_to_ascii($title);
+ if ($ascii_only === TRUE)
+ {
+ // Replace accented characters by their unaccented equivalents
+ $title = text::transliterate_to_ascii($title);
- // Remove all characters that are not the separator, a-z, 0-9, or whitespace
- $title = preg_replace('/[^'.$separator.'a-z0-9\s]+/', '', strtolower($title));
+ // Remove all characters that are not the separator, a-z, 0-9, or whitespace
+ $title = preg_replace('/[^'.$separator.'a-z0-9\s]+/', '', strtolower($title));
+ }
+ else
+ {
+ // Remove all characters that are not the separator, letters, numbers, or whitespace
+ $title = preg_replace('/[^'.$separator.'\pL\pN\s]+/u', '', mb_strtolower($title));
+ }
// Replace all separator characters and whitespace by a single separator
$title = preg_replace('/['.$separator.'\s]+/', $separator, $title);