- Timestamp:
- 07/06/2008 07:14:18 PM (5 months ago)
- Files:
-
- 1 modified
-
tags/2.1.3/system/helpers/inflector.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tags/2.1.3/system/helpers/inflector.php
r2972 r2974 49 49 { 50 50 // Remove garbage 51 $str = trim($str);51 $str = strtolower(trim($str)); 52 52 53 53 if (is_string($count)) … … 80 80 $str = $irregular; 81 81 } 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)) 83 83 { 84 84 // Remove "es" 85 85 $str = substr($str, 0, -2); 86 86 } 87 elseif (preg_match('/[^aeiou]ies$/ i', $str))87 elseif (preg_match('/[^aeiou]ies$/', $str)) 88 88 { 89 // Remove "ies"90 89 $str = substr($str, 0, -3).'y'; 91 90 } 92 91 elseif (substr($str, -1) === 's') 93 92 { 94 // Remove "s" 95 $str = substr($str, 0, strlen($str) - 1); 93 $str = substr($str, 0, -1); 96 94 } 97 95 … … 108 106 { 109 107 // Remove garbage 110 $str = trim($str);108 $str = strtolower(trim($str)); 111 109 112 110 if (is_string($count)) … … 129 127 return self::$cache[$key] = $str; 130 128 131 $end = substr($str, -1);132 $low = (strcmp($end, strtolower($end)) === 0) ? TRUE : FALSE;133 134 129 if (empty(self::$irregular)) 135 130 { … … 138 133 } 139 134 140 if (isset(self::$irregular[ strtolower($str)]))135 if (isset(self::$irregular[$str])) 141 136 { 142 $str = self::$irregular[ strtolower($str)];137 $str = self::$irregular[$str]; 143 138 } 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)) 145 140 { 146 $end = 'es'; 147 $str .= ($low == FALSE) ? strtoupper($end) : $end; 141 $str .= 'es'; 148 142 } 149 elseif (preg_match('/[^aeiou]y$/ i', $str))143 elseif (preg_match('/[^aeiou]y$/', $str)) 150 144 { 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); 154 147 } 155 148 else 156 149 { 157 $end = 's'; 158 $str .= ($low == FALSE) ? strtoupper($end) : $end; 150 $str .= 's'; 159 151 } 160 152
