From 39b622db9bda38282a32bb45623da63efe685729 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Wed, 16 Jan 2008 21:10:09 +0000 Subject: Many new Active Record functions, and another whack of stuff --- user_guide/helpers/array_helper.html | 2 +- user_guide/helpers/cookie_helper.html | 2 +- user_guide/helpers/date_helper.html | 2 +- user_guide/helpers/directory_helper.html | 2 +- user_guide/helpers/download_helper.html | 2 +- user_guide/helpers/file_helper.html | 2 +- user_guide/helpers/form_helper.html | 2 +- user_guide/helpers/html_helper.html | 2 +- user_guide/helpers/index.html | 2 +- user_guide/helpers/inflector_helper.html | 2 +- user_guide/helpers/security_helper.html | 2 +- user_guide/helpers/smiley_helper.html | 205 +++++++++++++++++++++++++++++- user_guide/helpers/string_helper.html | 177 +++++++++++++++++++++++++- user_guide/helpers/text_helper.html | 2 +- user_guide/helpers/typography_helper.html | 2 +- user_guide/helpers/url_helper.html | 2 +- user_guide/helpers/xml_helper.html | 2 +- 17 files changed, 395 insertions(+), 17 deletions(-) (limited to 'user_guide/helpers') diff --git a/user_guide/helpers/array_helper.html b/user_guide/helpers/array_helper.html index 136d475af..8dd8cc794 100644 --- a/user_guide/helpers/array_helper.html +++ b/user_guide/helpers/array_helper.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

diff --git a/user_guide/helpers/cookie_helper.html b/user_guide/helpers/cookie_helper.html index 46307d18d..f902592c4 100644 --- a/user_guide/helpers/cookie_helper.html +++ b/user_guide/helpers/cookie_helper.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

diff --git a/user_guide/helpers/date_helper.html b/user_guide/helpers/date_helper.html index 7b91d8806..ea2612e29 100644 --- a/user_guide/helpers/date_helper.html +++ b/user_guide/helpers/date_helper.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

diff --git a/user_guide/helpers/directory_helper.html b/user_guide/helpers/directory_helper.html index d739778b1..c3b35c56b 100644 --- a/user_guide/helpers/directory_helper.html +++ b/user_guide/helpers/directory_helper.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

diff --git a/user_guide/helpers/download_helper.html b/user_guide/helpers/download_helper.html index dd644e540..55f13db02 100644 --- a/user_guide/helpers/download_helper.html +++ b/user_guide/helpers/download_helper.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

diff --git a/user_guide/helpers/file_helper.html b/user_guide/helpers/file_helper.html index da8337cb1..646956cd5 100644 --- a/user_guide/helpers/file_helper.html +++ b/user_guide/helpers/file_helper.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

diff --git a/user_guide/helpers/form_helper.html b/user_guide/helpers/form_helper.html index 62c1f68f3..bc9c8902d 100644 --- a/user_guide/helpers/form_helper.html +++ b/user_guide/helpers/form_helper.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

diff --git a/user_guide/helpers/html_helper.html b/user_guide/helpers/html_helper.html index 8dc3f0060..564f4e6f2 100644 --- a/user_guide/helpers/html_helper.html +++ b/user_guide/helpers/html_helper.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

diff --git a/user_guide/helpers/index.html b/user_guide/helpers/index.html index 41526906d..2946641ce 100644 --- a/user_guide/helpers/index.html +++ b/user_guide/helpers/index.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

diff --git a/user_guide/helpers/inflector_helper.html b/user_guide/helpers/inflector_helper.html index e19eaec5e..917e0cc77 100644 --- a/user_guide/helpers/inflector_helper.html +++ b/user_guide/helpers/inflector_helper.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

diff --git a/user_guide/helpers/security_helper.html b/user_guide/helpers/security_helper.html index 0c9f7b92c..6032d68cb 100644 --- a/user_guide/helpers/security_helper.html +++ b/user_guide/helpers/security_helper.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

diff --git a/user_guide/helpers/smiley_helper.html b/user_guide/helpers/smiley_helper.html index 715c3df4f..c9b86c825 100644 --- a/user_guide/helpers/smiley_helper.html +++ b/user_guide/helpers/smiley_helper.html @@ -1 +1,204 @@ - CodeIgniter User Guide : Smiley Helper

CodeIgniter User Guide Version 1.5.4


Smiley Helper

The Smiley Helper file contains functions that let you manage smileys (emoticons).

Loading this Helper

This helper is loaded using the following code:

$this->load->helper('smiley');

Overview

The Smiley helper has a renderer that takes plain text simileys, like :-) and turns them into a image representation, like smile!

It also lets you display a set of smiley images that when clicked will be inserted into a form field. For example, if you have a blog that allows user commenting you can show the smileys next to the comment form. Your users can click a desired smiley and with the help of some JavaScript it will be placed into the form field.

Clickable Smileys Tutorial

Here is an example demonstrating how you might create a set of clickable smileys next to a form field. This example requires that you first download and install the smiley images, then create a controller and the View as described.

Important: Before you begin, please download the smiley images and put them in a publicly accessible place on your server. This helper also assumes you have the smiley replacement array located at application/config/smileys.php

The Controller

In your application/controllers/ folder, create a file called smileys.php and place the code below in it.

Important: Change the URL in the get_clickable_smileys() function below so that it points to your smiley folder.

You'll notice that in addition to the smiley helper we are using the Table Class.

In your application/views/ folder, create a file called smiley_view.php and place this code in it:

When you have created the above controller and view, load it by visiting http://www.your=site.com/index.php/smileys/

Function Reference

get_clickable_smileys()

Returns an array containing your smiley images wrapped in a cliackable link. You must supply the URL to your smiley folder via the first parameter:

$image_array = get_clickable_smileys("http://www.your-site.com/images/smileys/");

js_insert_smiley()

Generates the JavaScript that allows the images to be clicked and inserted into a form field. The first parameter must contain the name of your form, the second parameter must contain the name of the form field. This function is designed to be placed into the <head> area of your web page.

<?php echo js_insert_smiley('blog', 'comments'); ?>

parse_smileys()

Takes a string of text as input and replaces any contained plain text smileys into the image equivalent. The first parameter must contain your string, the second must contain the the URL to your smiley folder:

$str = 'Here are some simileys: :-) ;-)'; $str = parse_smileys($str, "http://www.your-site.com/images/smileys/"); echo $str;
\ No newline at end of file + + + + +CodeIgniter User Guide : Smiley Helper + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

CodeIgniter User Guide Version 1.6.0

+
+ + + + + + + + + +
+ + +
+ + + +
+ + +

Smiley Helper

+ +

The Smiley Helper file contains functions that let you manage smileys (emoticons).

+ + +

Loading this Helper

+ +

This helper is loaded using the following code:

+$this->load->helper('smiley'); + +

Overview

+ +

The Smiley helper has a renderer that takes plain text simileys, like :-) and turns +them into a image representation, like smile!

+ +

It also lets you display a set of smiley images that when clicked will be inserted into a form field. +For example, if you have a blog that allows user commenting you can show the smileys next to the comment form. +Your users can click a desired smiley and with the help of some JavaScript it will be placed into the form field.

+ + + +

Clickable Smileys Tutorial

+ +

Here is an example demonstrating how you might create a set of clickable smileys next to a form field. This example +requires that you first download and install the smiley images, then create a controller and the View as described.

+ +

Important: Before you begin, please download the smiley images and put them in +a publicly accessible place on your server. This helper also assumes you have the smiley replacement array located at +application/config/smileys.php

+ + +

The Controller

+ +

In your application/controllers/ folder, create a file called smileys.php and place the code below in it.

+ +

Important: Change the URL in the get_clickable_smileys() function below so that it points to +your smiley folder.

+ +

You'll notice that in addition to the smiley helper we are using the Table Class.

+ + + +

In your application/views/ folder, create a file called smiley_view.php and place this code in it:

+ + + + + +

When you have created the above controller and view, load it by visiting http://www.your=site.com/index.php/smileys/

+ +

Function Reference

+ + +

get_clickable_smileys()

+ +

Returns an array containing your smiley images wrapped in a cliackable link. You must supply the URL to your smiley folder +via the first parameter:

+ +$image_array = get_clickable_smileys("http://www.your-site.com/images/smileys/"); + + +

js_insert_smiley()

+ +

Generates the JavaScript that allows the images to be clicked and inserted into a form field. +The first parameter must contain the name of your form, the second parameter must contain the name of the +form field. This function is designed to be placed into the <head> area of your web page.

+ +<?php echo js_insert_smiley('blog', 'comments'); ?> + + +

parse_smileys()

+ +

Takes a string of text as input and replaces any contained plain text smileys into the image +equivalent. The first parameter must contain your string, the second must contain the the URL to your smiley folder:

+ + + +$str = 'Here are some simileys: :-) ;-)'; + +$str = parse_smileys($str, "http://www.your-site.com/images/smileys/"); + +echo $str; + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/string_helper.html b/user_guide/helpers/string_helper.html index 554afc824..74be2306d 100644 --- a/user_guide/helpers/string_helper.html +++ b/user_guide/helpers/string_helper.html @@ -1 +1,176 @@ - CodeIgniter User Guide : String Helper

CodeIgniter User Guide Version 1.5.4


String Helper

The String Helper file contains functions that assist in working with strings.

Loading this Helper

This helper is loaded using the following code:

$this->load->helper('string');

The following functions are available:

random_string()

Generates a random string based on the type and length you specify. Useful for creating passwords or generating random hashes.

The first parameter specifies the type of string, the second parameter specifies the length. The following choices are available:

  • alnum:  Alpha-numeric string with lower and uppercase characters.
  • numeric:  Numeric string.
  • nozero:  Numeric string with no zeros.
  • unique:  Encrypted with MD5 and uniqid(). Note: The length parameter is not available for this type. Returns a fixed length 33 character string.

Usage example:

echo random_string('alnum', 16);

alternator()

Allows two or more items to be alternated between, when cycling through a loop. Example:

for ($i = 0; $i < 10; $i++)
{
    echo alternator('string one', 'string two');
}

You can add as many parameters as you want, and with each iteration of your loop the next item will be returned.

for ($i = 0; $i < 10; $i++)
{
    echo alternator('one', 'two', 'three', 'four', 'five');
}

Note: To use multiple separate calls to this function simply call the function with no arguments to re-initialize.

repeater()

Generates repeating copies of the data you submit. Example:

$string = "\n";
echo repeater($string, 30);

The above would generate 30 newlines.

reduce_double_slashes()

Converts double slashes in a string to a single slash, except those found in http://. Example:

$string = "http://www.example.com//index.php";
echo reduce_double_slashes($string); // results in "http://www.example.com/index.php"

trim_slashes()

Removes any leading/trailing slashes from a string. Example:

$string = "/this/that/theother/";
echo trim_slashes($string); // results in this/that/theother

reduce_multiples()

Reduces multiple instances of a particular character occuring directly after each other. Example:

$string="Fred, Bill,, Joe, Jimmy";
$string=reduce_multiples($string,","); //results in "Fred, Bill, Joe, Jimmy"

The function accepts the following parameters: reduce_multiples(string: text to search in, string: character to reduce, boolean: whether to remove the character from the front and end of the string) The first parameter contrains the string in which you want to reduce the multiplies. The second parameter contains the character you want to have reduced. The third parameter is False by default. If it it's to true it will remove occurences of the character at the beginning and the end of the string. Example: $string=",Fred, Bill,, Joe, Jimmy,";
$string=reduce_multiples($string,",",true); //results in "Fred, Bill, Joe, Jimmy"

quotes_to_entities()

Converts single and double quotes in a string to the corresponding HTML entities. Example:

$string="Joe's \"dinner\"";
$string=quotes_to_entities($string); //results in "Joe&#39;s &quot;dinner&quot;"

strip_quotes()

Removes single and double quotes from a string. Example:

$string="Joe's \"dinner\"";
$string=strip_quotes($string); //results in "Joes dinner"
\ No newline at end of file + + + + +CodeIgniter User Guide : String Helper + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

CodeIgniter User Guide Version 1.6.0

+
+ + + + + + + + + +
+ + +
+ + + +
+ + +

String Helper

+ +

The String Helper file contains functions that assist in working with strings.

+ + +

Loading this Helper

+ +

This helper is loaded using the following code:

+$this->load->helper('string'); + +

The following functions are available:

+ +

random_string()

+ +

Generates a random string based on the type and length you specify. Useful for creating passwords or generating random hashes.

+ +

The first parameter specifies the type of string, the second parameter specifies the length. The following choices are available:

+ + +
    +
  • alnum:  Alpha-numeric string with lower and uppercase characters.
  • +
  • numeric:  Numeric string.
  • +
  • nozero:  Numeric string with no zeros.
  • +
  • unique:  Encrypted with MD5 and uniqid(). Note: The length parameter is not available for this type. +Returns a fixed length 33 character string.
  • +
+ +

Usage example:

+ +echo random_string('alnum', 16); + + +

alternator()

+ +

Allows two or more items to be alternated between, when cycling through a loop. Example:

+ +for ($i = 0; $i < 10; $i++)
+{
+    echo alternator('string one', 'string two');
+}
+
+ +

You can add as many parameters as you want, and with each iteration of your loop the next item will be returned.

+ +for ($i = 0; $i < 10; $i++)
+{
+    echo alternator('one', 'two', 'three', 'four', 'five');
+}
+
+ +

Note: To use multiple separate calls to this function simply call the function with no arguments to re-initialize.

+ + + +

repeater()

+

Generates repeating copies of the data you submit. Example:

+$string = "\n";
+echo repeater($string, 30);
+ +

The above would generate 30 newlines.

+

reduce_double_slashes()

+

Converts double slashes in a string to a single slash, except those found in http://. Example:

+$string = "http://www.example.com//index.php";
+echo reduce_double_slashes($string); // results in "http://www.example.com/index.php"
+

trim_slashes()

+

Removes any leading/trailing slashes from a string. Example:
+
+ $string = "/this/that/theother/";
+echo trim_slashes($string); // results in this/that/theother

+ + +

reduce_multiples()

+

Reduces multiple instances of a particular character occuring directly after each other. Example:

+ +$string="Fred, Bill,, Joe, Jimmy";
+$string=reduce_multiples($string,","); //results in "Fred, Bill, Joe, Jimmy" +
+

The function accepts the following parameters: +reduce_multiples(string: text to search in, string: character to reduce, boolean: whether to remove the character from the front and end of the string) + +The first parameter contrains the string in which you want to reduce the multiplies. The second parameter contains the character you want to have reduced. +The third parameter is False by default. If it it's to true it will remove occurences of the character at the beginning and the end of the string. Example: + + +$string=",Fred, Bill,, Joe, Jimmy,";
+$string=reduce_multiples($string,",",true); //results in "Fred, Bill, Joe, Jimmy" +
+

+ +

quotes_to_entities()

+

Converts single and double quotes in a string to the corresponding HTML entities. Example:

+$string="Joe's \"dinner\"";
+$string=quotes_to_entities($string); //results in "Joe&#39;s &quot;dinner&quot;" +
+ +

strip_quotes()

+

Removes single and double quotes from a string. Example:

+$string="Joe's \"dinner\"";
+$string=strip_quotes($string); //results in "Joes dinner" +
+ +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/text_helper.html b/user_guide/helpers/text_helper.html index 7a83d8f9a..217689c48 100644 --- a/user_guide/helpers/text_helper.html +++ b/user_guide/helpers/text_helper.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

diff --git a/user_guide/helpers/typography_helper.html b/user_guide/helpers/typography_helper.html index 686f5c23e..e3d18f8fb 100644 --- a/user_guide/helpers/typography_helper.html +++ b/user_guide/helpers/typography_helper.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

diff --git a/user_guide/helpers/url_helper.html b/user_guide/helpers/url_helper.html index f2c45c343..854d06a23 100644 --- a/user_guide/helpers/url_helper.html +++ b/user_guide/helpers/url_helper.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

diff --git a/user_guide/helpers/xml_helper.html b/user_guide/helpers/xml_helper.html index 6336eec53..47082a59f 100644 --- a/user_guide/helpers/xml_helper.html +++ b/user_guide/helpers/xml_helper.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 1.5.4

CodeIgniter User Guide Version 1.6.0

-- cgit v1.2.3-24-g4f1b