summaryrefslogtreecommitdiff
path: root/system/helpers/url.php
diff options
context:
space:
mode:
authorTim Almdal <tnalmdal@shaw.ca>2009-12-26 11:24:50 -0800
committerTim Almdal <tnalmdal@shaw.ca>2009-12-26 11:24:50 -0800
commit3060a6f662da66008d57a461bf1c9b5b4aa2b002 (patch)
tree442fd290505817efc0324f2af6e01805cb7396aa /system/helpers/url.php
parent1cd6a615bb47a33794e4a4f690c87a348ab752d7 (diff)
parent32d25dafd5b033338b6a9bb8c7c53edab462543a (diff)
Merge branch 'master' into talmdal_dev
Conflicts: modules/gallery/controllers/albums.php modules/gallery/controllers/movies.php modules/gallery/controllers/photos.php
Diffstat (limited to 'system/helpers/url.php')
-rw-r--r--system/helpers/url.php27
1 files changed, 18 insertions, 9 deletions
diff --git a/system/helpers/url.php b/system/helpers/url.php
index 56f6db4b..4a94e894 100644
--- a/system/helpers/url.php
+++ b/system/helpers/url.php
@@ -2,12 +2,12 @@
/**
* URL helper class.
*
- * $Id: url.php 4479 2009-07-23 04:51:22Z ixmatus $
+ * $Id: url.php 4685 2009-11-30 21:24:06Z isaiah $
*
* @package Core
* @author Kohana Team
- * @copyright (c) 2007-2008 Kohana Team
- * @license http://kohanaphp.com/license.html
+ * @copyright (c) 2007-2009 Kohana Team
+ * @license http://kohanaphp.com/license
*/
class url_Core {
@@ -15,7 +15,7 @@ class url_Core {
* Fetches the current URI.
*
* @param boolean include the query string
- * @param boolean include the suffix
+ * @param boolean include the suffix
* @return string
*/
public static function current($qs = FALSE, $suffix = FALSE)
@@ -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 = utf8::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);