Changeset 2020
- Timestamp:
- 02/10/2008 04:41:19 AM (11 months ago)
- Files:
-
- 1 modified
-
releases/2.1.1/system/helpers/url.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
releases/2.1.1/system/helpers/url.php
r1970 r2020 85 85 public static function title($title, $separator = '-') 86 86 { 87 $separator = ($separator == '-') ? '-' : '_'; 88 89 // Replace all dashes, underscores and whitespace by the separator 90 $title = preg_replace('/[-_\s]+/', $separator, $title); 87 $separator = ($separator === '-') ? '-' : '_'; 91 88 92 89 // Replace accented characters by their unaccented equivalents 93 90 $title = utf8::transliterate_to_ascii($title); 94 91 95 // Remove all characters that are not a-z, 0-9, or the separator 96 $title = preg_replace('/[^a-z0-9'.$separator.']+/', '', strtolower($title)); 92 // Remove all characters that are not the separator, a-z, 0-9, or whitespace 93 $title = preg_replace('/[^'.$separator.'a-z0-9\s]+/', '', strtolower($title)); 94 95 // Replace all separator characters and whitespace by a single separator 96 $title = preg_replace('/['.$separator.'\s]+/', $separator, $title); 97 97 98 98 // Trim separators from the beginning and end 99 $title = trim($title, $separator); 100 101 return $title; 99 return trim($title, $separator); 102 100 } 103 101
