summaryrefslogtreecommitdiff
path: root/system/helpers/url.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-12-21 20:05:27 -0800
committerBharat Mediratta <bharat@menalto.com>2009-12-21 20:05:27 -0800
commit9285c8c66c530196399eb05bb5561c3fa5538335 (patch)
tree7cec68583c01b5b365e7669fefc1adc6360e89a5 /system/helpers/url.php
parent9c5df1d31bd214fab051b71d092c751a1da20ecc (diff)
Updated Kohana to r4724
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);