Changeset 2974 for tags

Show
Ignore:
Timestamp:
07/06/2008 07:14:18 PM (5 months ago)
Author:
Shadowhand
Message:

Follow up to r2972 and r2973.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • tags/2.1.3/system/helpers/inflector.php

    r2972 r2974  
    4949        { 
    5050                // Remove garbage 
    51                 $str = trim($str); 
     51                $str = strtolower(trim($str)); 
    5252 
    5353                if (is_string($count)) 
     
    8080                        $str = $irregular; 
    8181                } 
    82                 elseif (preg_match('/[sxz]es$/i', $str) OR preg_match('/[^aeioudgkprt]hes$/i', $str)) 
     82                elseif (preg_match('/[sxz]es$/', $str) OR preg_match('/[^aeioudgkprt]hes$/', $str)) 
    8383                { 
    8484                        // Remove "es" 
    8585                        $str = substr($str, 0, -2); 
    8686                } 
    87                 elseif (preg_match('/[^aeiou]ies$/i', $str)) 
     87                elseif (preg_match('/[^aeiou]ies$/', $str)) 
    8888                { 
    89                         // Remove "ies" 
    9089                        $str = substr($str, 0, -3).'y'; 
    9190                } 
    9291                elseif (substr($str, -1) === 's') 
    9392                { 
    94                         // Remove "s" 
    95                         $str = substr($str, 0, strlen($str) - 1); 
     93                        $str = substr($str, 0, -1); 
    9694                } 
    9795 
     
    108106        { 
    109107                // Remove garbage 
    110                 $str = trim($str); 
     108                $str = strtolower(trim($str)); 
    111109 
    112110                if (is_string($count)) 
     
    129127                        return self::$cache[$key] = $str; 
    130128 
    131                 $end = substr($str, -1); 
    132                 $low = (strcmp($end, strtolower($end)) === 0) ? TRUE : FALSE; 
    133  
    134129                if (empty(self::$irregular)) 
    135130                { 
     
    138133                } 
    139134 
    140                 if (isset(self::$irregular[strtolower($str)])) 
     135                if (isset(self::$irregular[$str])) 
    141136                { 
    142                         $str = self::$irregular[strtolower($str)]; 
     137                        $str = self::$irregular[$str]; 
    143138                } 
    144                 elseif (preg_match('/[sxz]$/i', $str) OR preg_match('/[^aeioudgkprt]h$/i', $str)) 
     139                elseif (preg_match('/[sxz]$/', $str) OR preg_match('/[^aeioudgkprt]h$/', $str)) 
    145140                { 
    146                         $end = 'es'; 
    147                         $str .= ($low == FALSE) ? strtoupper($end) : $end; 
     141                        $str .= 'es'; 
    148142                } 
    149                 elseif (preg_match('/[^aeiou]y$/i', $str)) 
     143                elseif (preg_match('/[^aeiou]y$/', $str)) 
    150144                { 
    151                         $end = 'ies'; 
    152                         $end = ($low == FALSE) ? strtoupper($end) : $end; 
    153                         $str = substr_replace($str, $end, -1); 
     145                        // Change "y" to "ies" 
     146                        $str = substr_replace($str, 'ies', -1); 
    154147                } 
    155148                else 
    156149                { 
    157                         $end = 's'; 
    158                         $str .= ($low == FALSE) ? strtoupper($end) : $end; 
     150                        $str .= 's'; 
    159151                } 
    160152