summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/helpers/inflector_helper.php78
-rw-r--r--user_guide/changelog.html3
-rw-r--r--user_guide/helpers/inflector_helper.html5
3 files changed, 52 insertions, 34 deletions
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index fbe851f3b..28ecf5201 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -39,26 +39,31 @@
*/
function singular($str)
{
- $str = strtolower(trim($str));
- $end = substr($str, -3);
-
- if ($end == 'ies')
- {
- $str = substr($str, 0, strlen($str)-3).'y';
- }
- else
- {
- $end = substr($str, -1);
-
- if ($end == 's')
- {
- $str = substr($str, 0, strlen($str)-1);
- }
- }
-
- return $str;
+ $str = strtolower(trim($str));
+ $end = substr($str, -3);
+
+ if ($end == 'ies')
+ {
+ $str = substr($str, 0, strlen($str)-3).'y';
+ }
+ elseif ($end == 'ses')
+ {
+ $str = substr($str, 0, strlen($str)-2);
+ }
+ else
+ {
+ $end = substr($str, -1);
+
+ if ($end == 's')
+ {
+ $str = substr($str, 0, strlen($str)-1);
+ }
+ }
+
+ return $str;
}
+
// --------------------------------------------------------------------
/**
@@ -68,25 +73,34 @@ function singular($str)
*
* @access public
* @param string
+ * @param bool
* @return str
*/
-function plural($str)
+function plural($str, $force = FALSE)
{
- $str = strtolower(trim($str));
- $end = substr($str, -1);
-
- if ($end == 'y')
- {
- $str = substr($str, 0, strlen($str)-1).'ies';
- }
- elseif ($end != 's')
- {
- $str .= 's';
- }
-
- return $str;
+ $str = strtolower(trim($str));
+ $end = substr($str, -1);
+
+ if ($end == 'y')
+ {
+ $str = substr($str, 0, strlen($str)-1).'ies';
+ }
+ elseif ($end == 's')
+ {
+ if ($force == TRUE)
+ {
+ $str .= 'es';
+ }
+ }
+ else
+ {
+ $str .= 's';
+ }
+
+ return $str;
}
+
// --------------------------------------------------------------------
/**
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index c8ad1a9b0..5435864d4 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -69,6 +69,7 @@ Change Log
<li>Added array to string into the profiler </li>
<li>Added some additional mime types in application/config/mimes.php</li>
<li>Added filename_security() method to Input library</li>
+ <li>Added some additional arguements to the <a href="./helpers/inflector_helper.html">Inflection helper</a> singular() to compensate for words ending in "s". Also added a force parameter to pluralize()</li>
<li>Fixed MSSQL insert_id().</li>
<li>Fixed a logic error in the DB trans_status() function. It was incorrectly returning TRUE on failure and FALSE on success.</li>
<li>Fixed a bug that was allowing multiple load attempts on extended classes.</li>
@@ -80,7 +81,7 @@ Change Log
<li>Fixed a bug in router that was ignoring the scaffolding route for optimization </li>
<li>Fixed an IP validation bug.</li>
<li>Fixed various doc typos. </li>
- <li>Docs now validate to XHTML 1 transitional </li>
+ <li>Docs now validate to XHTML 1 transitional</li>
<li>Fixed a bug where one could unset certain PHP superglobals by setting them via GET or POST data</li>
<li>Updated the XSS Filtering to take into account the IE expression() ability and improved certain deletions to prevent possible exploits</li>
<li>Modified the Router so that when Query Strings are Enabled, the controller trigger and function trigger values are sanitized for filename include security.</li>
diff --git a/user_guide/helpers/inflector_helper.html b/user_guide/helpers/inflector_helper.html
index 2a4ee559f..91de2e20f 100644
--- a/user_guide/helpers/inflector_helper.html
+++ b/user_guide/helpers/inflector_helper.html
@@ -94,8 +94,11 @@ echo plural($word); // Returns "dogs"
</code>
-<h2>camelize()</h2>
+<p>To force a word to end with &quot;es&quot; use a second &quot;true&quot; argument. </p>
+<code> $word = &quot;pass&quot;;<br />
+echo plural($word); // Returns &quot;passes&quot; </code>
+<h2>camelize()</h2>
<p>Changes a string of words separated by spaces or underscores to camel case. Example:</p>
<code>