From ce2b69675075444c9e40b72bcdd42ab7edbbe633 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Fri, 28 Jan 2011 22:51:06 +0100 Subject: update to CI 2.0 Signed-off-by: Florian Pritz --- system/helpers/inflector_helper.php | 43 +++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 16 deletions(-) mode change 100644 => 100755 system/helpers/inflector_helper.php (limited to 'system/helpers/inflector_helper.php') diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php old mode 100644 new mode 100755 index ffa99cc26..4cd7486b4 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -36,14 +36,14 @@ * @access public * @param string * @return str - */ + */ if ( ! function_exists('singular')) -{ +{ function singular($str) { $str = strtolower(trim($str)); $end = substr($str, -3); - + if ($end == 'ies') { $str = substr($str, 0, strlen($str)-3).'y'; @@ -55,13 +55,13 @@ if ( ! function_exists('singular')) else { $end = substr($str, -1); - + if ($end == 's') { $str = substr($str, 0, strlen($str)-1); } } - + return $str; } } @@ -77,9 +77,9 @@ if ( ! function_exists('singular')) * @param string * @param bool * @return str - */ + */ if ( ! function_exists('plural')) -{ +{ function plural($str, $force = FALSE) { $str = strtolower(trim($str)); @@ -91,6 +91,17 @@ if ( ! function_exists('plural')) $vowels = array('a', 'e', 'i', 'o', 'u'); $str = in_array(substr($str, -2, 1), $vowels) ? $str.'s' : substr($str, 0, -1).'ies'; } + elseif ($end == 'h') + { + if (substr($str, -2) == 'ch' OR substr($str, -2) == 'sh') + { + $str .= 'es'; + } + else + { + $str .= 's'; + } + } elseif ($end == 's') { if ($force == TRUE) @@ -117,11 +128,11 @@ if ( ! function_exists('plural')) * @access public * @param string * @return str - */ + */ if ( ! function_exists('camelize')) -{ +{ function camelize($str) - { + { $str = 'x'.strtolower(trim($str)); $str = ucwords(preg_replace('/[\s_]+/', ' ', $str)); return substr(str_replace(' ', '', $str), 1); @@ -138,7 +149,7 @@ if ( ! function_exists('camelize')) * @access public * @param string * @return str - */ + */ if ( ! function_exists('underscore')) { function underscore($str) @@ -157,15 +168,15 @@ if ( ! function_exists('underscore')) * @access public * @param string * @return str - */ + */ if ( ! function_exists('humanize')) -{ +{ function humanize($str) { return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str)))); } } - + /* End of file inflector_helper.php */ /* Location: ./system/helpers/inflector_helper.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b