Changeset 2017

Show
Ignore:
Timestamp:
02/10/2008 03:32:16 AM (10 months ago)
Author:
Geert
Message:

Fixed #391

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/helpers/url.php

    r1967 r2017  
    8585        public static function title($title, $separator = '-') 
    8686        { 
    87                 $separator = ($separator == '-') ? '-' : '_'; 
    88  
    89                 // Replace all dashes, underscores and whitespace by the separator 
    90                 $title = preg_replace('/[-_\s]+/', $separator, $title); 
     87                $separator = ($separator === '-') ? '-' : '_'; 
    9188 
    9289                // Replace accented characters by their unaccented equivalents 
    9390                $title = utf8::transliterate_to_ascii($title); 
    9491 
    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); 
    9797 
    9898                // Trim separators from the beginning and end 
    99                 $title = trim($title, $separator); 
    100  
    101                 return $title; 
     99                return trim($title, $separator); 
    102100        } 
    103101