From 53b8ef524529e6ca9f32ad49d36c5140df84feb0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 8 Nov 2012 21:38:53 +0200 Subject: Polish docs for HTML, Inflector, Language, Number, Path, Security and Smiley helpers Also fixed a DB_cache bug introduced in previous commit and removed an unused parameter in a smiley helper --- user_guide_src/source/helpers/inflector_helper.rst | 82 +++++++++++++--------- 1 file changed, 48 insertions(+), 34 deletions(-) (limited to 'user_guide_src/source/helpers/inflector_helper.rst') diff --git a/user_guide_src/source/helpers/inflector_helper.rst b/user_guide_src/source/helpers/inflector_helper.rst index cc46a1851..1f54b76c0 100644 --- a/user_guide_src/source/helpers/inflector_helper.rst +++ b/user_guide_src/source/helpers/inflector_helper.rst @@ -10,9 +10,7 @@ words to plural, singular, camel case, etc. Loading this Helper =================== -This helper is loaded using the following code - -:: +This helper is loaded using the following code:: $this->load->helper('inflector'); @@ -21,65 +19,81 @@ The following functions are available: singular() ========== -Changes a plural word to singular. Example +.. php:function:: singular($str) + + :param string $str: Input string + :returns: string -:: +Changes a plural word to singular. Example:: - $word = "dogs"; - echo singular($word); // Returns "dog" + echo singular('dogs'); // Prints 'dog' plural() ======== -Changes a singular word to plural. Example - -:: - - $word = "dog"; - echo plural($word); // Returns "dogs" +.. php:function:: plural($str) -To force a word to end with "es" use a second "true" argument. + :param string $str: Input string + :returns: string -:: +Changes a singular word to plural. Example:: - $word = "pass"; - echo plural($word, TRUE); // Returns "passes" + echo plural('dog'); // Prints 'dogs' camelize() ========== -Changes a string of words separated by spaces or underscores to camel -case. Example +.. php:function:: camelize($str) + + :param string $str: Input string + :returns: string -:: +Changes a string of words separated by spaces or underscores to camel +case. Example:: - $word = "my_dog_spot"; - echo camelize($word); // Returns "myDogSpot" + echo camelize('my_dog_spot'); // Prints 'myDogSpot' underscore() ============ -Takes multiple words separated by spaces and underscores them. Example +.. php:function:: camelize($str) -:: + :param string $str: Input string + :returns: string - $word = "my dog spot"; - echo underscore($word); // Returns "my_dog_spot" +Takes multiple words separated by spaces and underscores them. +Example:: + + echo underscore('my dog spot'); // Prints 'my_dog_spot' humanize() ========== +.. php:function:: camelize($str) + + :param string $str: Input string + :param string $separator: Input separator + :returns: string + Takes multiple words separated by underscores and adds spaces between -them. Each word is capitalized. Example +them. Each word is capitalized. + +Example:: + + echo humanize('my_dog_spot'); // Prints 'My Dog Spot' + +To use dashes instead of underscores:: + + echo humanize('my-dog-spot', '-'); // Prints 'My Dog Spot' -:: +is_countable() +============== - $word = "my_dog_spot"; - echo humanize($word); // Returns "My Dog Spot" +.. php:function:: is_countable($word) -To use dashes instead of underscores + :param string $word: Input string + :returns: bool -:: +Checks if the given word has a plural version. Example:: - $word = "my-dog-spot"; - echo humanize($word, '-'); // Returns "My Dog Spot" \ No newline at end of file + is_countable('equipment'); // Returns FALSE \ No newline at end of file -- cgit v1.2.3-24-g4f1b