From b0dd10f8171945e0c1f3527dd1e9d18b043e01a7 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 25 Aug 2006 17:25:49 +0000 Subject: Initial Import --- user_guide/helpers/array_helper.html | 111 ++++++++++ user_guide/helpers/cookie_helper.html | 133 ++++++++++++ user_guide/helpers/date_helper.html | 340 +++++++++++++++++++++++++++++ user_guide/helpers/directory_helper.html | 145 +++++++++++++ user_guide/helpers/file_helper.html | 144 +++++++++++++ user_guide/helpers/form_helper.html | 343 ++++++++++++++++++++++++++++++ user_guide/helpers/html_helper.html | 117 ++++++++++ user_guide/helpers/index.html | 131 ++++++++++++ user_guide/helpers/security_helper.html | 131 ++++++++++++ user_guide/helpers/string_helper.html | 144 +++++++++++++ user_guide/helpers/text_helper.html | 197 +++++++++++++++++ user_guide/helpers/typography_helper.html | 129 +++++++++++ user_guide/helpers/url_helper.html | 269 +++++++++++++++++++++++ user_guide/helpers/xml_helper.html | 110 ++++++++++ 14 files changed, 2444 insertions(+) create mode 100644 user_guide/helpers/array_helper.html create mode 100644 user_guide/helpers/cookie_helper.html create mode 100644 user_guide/helpers/date_helper.html create mode 100644 user_guide/helpers/directory_helper.html create mode 100644 user_guide/helpers/file_helper.html create mode 100644 user_guide/helpers/form_helper.html create mode 100644 user_guide/helpers/html_helper.html create mode 100644 user_guide/helpers/index.html create mode 100644 user_guide/helpers/security_helper.html create mode 100644 user_guide/helpers/string_helper.html create mode 100644 user_guide/helpers/text_helper.html create mode 100644 user_guide/helpers/typography_helper.html create mode 100644 user_guide/helpers/url_helper.html create mode 100644 user_guide/helpers/xml_helper.html (limited to 'user_guide/helpers') diff --git a/user_guide/helpers/array_helper.html b/user_guide/helpers/array_helper.html new file mode 100644 index 000000000..d719be9c7 --- /dev/null +++ b/user_guide/helpers/array_helper.html @@ -0,0 +1,111 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.0

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

Array Helper

+ +

The Array Helper file contains functions that assist in working with arrays.

+ + +

Loading this Helper

+ +

This helper is loaded using the following code:

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

The following functions are available:

+ + +

random_element()

+ +

Takes an array as input and returns a random element from it. Usage example:

+ +$quotes = array(
+            "I find that the harder I work, the more luck I seem to have. - Thomas Jefferson",
+            "Don't stay in bed, unless you can make money in bed. - George Burns",
+            "We didn't lose the game; we just ran out of time. - Vince Lombardi",
+            "If everything seems under control, you're not going fast enough. - Mario Andretti",
+            "Reality is merely an illusion, albeit a very persistent one. - Albert Einstein",
+            "Chance favors the prepared mind - Louis Pasteur"
+            );
+
+echo random_element($quotes);
+ + + + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/cookie_helper.html b/user_guide/helpers/cookie_helper.html new file mode 100644 index 000000000..3152fc309 --- /dev/null +++ b/user_guide/helpers/cookie_helper.html @@ -0,0 +1,133 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.0

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

Cookie Helper

+ +

The Cookie Helper file contains functions that assist in working with cookies.

+ + +

Loading this Helper

+ +

This helper is loaded using the following code:

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

The following functions are available:

+ +

set_cookie()

+ +

Sets a cookie containing the values you specify. There are two ways to pass information this function so that a cookie can be set: +Arrray Method, and Discreet Parameters:

+ +

Array Method

+ +

Using this method, an associative array is passed to the first parameter:

+ +$cookie = array(
+                   'name'   => 'The Cookie Name',
+                   'value'  => 'The Value',
+                   'expire' => '86500',
+                   'domain' => '.some-domain.com',
+                   'path'   => '/',
+                   'prefix' => 'myprefix_',
+               );
+
+set_cookie($cookie); +
+ +

Notes:

+ +

Only the name and value are required.

+ +

The expiration is set in seconds, which will be added to the current time. Do not include the time, but rather only the +number of seconds from now that you wish the cookie to be valid. If the expiration is set to +zero the cookie will only last as long as the browser is open.

+

To delete a cookie set it with the expiration blank.

+

For site-wide cookies regardless of how your site is requested, add your URL to the domain starting with a period, like this: .your-domain.com

+

The path is usually not needed since the function sets a root path.

+

The prefix is only needed if you need to avoid name collisions with other identically named cookies for your server.

+ +

Discreet Parameters

+ +

If you prefer, you can set the cookie by passing data using individual parameters:

+ +set_cookie($name, $value, $expire, $domain, $path, $prefix); + + + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/date_helper.html b/user_guide/helpers/date_helper.html new file mode 100644 index 000000000..b25f249df --- /dev/null +++ b/user_guide/helpers/date_helper.html @@ -0,0 +1,340 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.0

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

Date Helper

+ +

The Date Helper file contains functions that help you work with dates.

+ + +

Loading this Helper

+ +

This helper is loaded using the following code:

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

The following functions are available:

+ +

now()

+ +

Returns the current time as a Unix timestamp, referenced either to your server's local time or GMT, based on the "time reference" +setting in your config file. If you do not intend to set your master time reference to GMT (which you'll typically do if you +run a site that lets each user set their own timezone settings) there is no benefit to using this function over PHP's time() function. +

+ + + + +

mdate()

+ +

This function is identical to PHPs date() function, except that it lets you +use MySQL style date codes, where each code letter is preceded with a percent sign: %Y %m %d etc.

+ +

The benefit of doing dates this way is that you don't have to worry about escaping any characters that +are not date codes, as you would normally have to do with the date() function. Example:

+ +$datestring = "Year: %Y Month: %m Day: %d - %h:%i %a";
+$time = time();
+
+echo mdate($datestring, $time);
+ +

If a timestamp is not included in the second parameter the current time will be used.

+ + +

local_to_gmt()

+ +

Takes a Unix timestamp as input and returns it as GMT. Example:

+ +$now = time();
+
+$gmt = local_to_gmt($now);
+ + +

gmt_to_local()

+ +

Takes a Unix timestamp (referenced to GMT) as input, and converts it to a localized timestamp based on the +timezone and Daylight Saving time submitted. Example:

+ + +$timestamp = '1140153693';
+$timezone = 'UM8';
+$daylight_saving = TRUE;
+
+echo gmt_to_local($timestamp, $timezone, daylight_saving);
+ +

Note: For a list of timezones see the reference at the bottom of this page.

+ +

mysql_to_unix()

+ +

Takes a MySQL Timestamp as input and returns it as Unix. Example:

+ +$mysql = '20061124092345';
+
+$unix = mysql_to_unix($mysql);
+ + +

unix_to_human()

+ +

Takes a Unix timestamp as input and returns it in a human readable format with this prototype:

+ +YYYY-MM-DD HH:MM:SS AM/PM + +

This can be useful if you need to display a date in a form field for submission.

+ +

The time can be formatted with or without seconds, and it can be set to European or US format. If only +the timestamp is submitted it will return the time without seconds formatted for the U.S. Examples: + +$now = time();
+
+echo unix_to_human($now); // U.S. time, no seconds
+
+echo unix_to_human($now, TRUE, 'us'); // U.S. time with seconds
+
+echo unix_to_human($now, TRUE, 'eu'); // Euro time with seconds
+ + +

human_to_unix()

+ +

The opposite of the above function. Takes a "human" time as input and returns it as Unix. This function is +useful if you accept "human" formatted dates submitted via a form. Returns FALSE (boolean) if +the date string passed to it is not formatted as indicated above. Example:

+ +$now = time();
+
+$human = unix_to_human($now);
+
+$unix = human_to_unix($human);
+ + + + + +

timespan()

+ +

Formats a unix timestamp so that is appears similar to this:

+ +1 Year, 10 Months, 2 Weeks, 5 Days, 10 Hours, 16 Minutes + +

The first parameter must contain a Unix timestamp. The second parameter must contain a +timestamp that is greater that the first timesamp. If the second parameter empty, the current time will be used. The most common purpose +for this function is to show how much time has elapsed from some point in time in the past to now. Example:

+ +$post_date = '1079621429';
+$now = time();
+
+echo timespan($post_date, $now);
+ +

Note: The text generated by this function is found in the following language file: language/<your_lang>/date_lang.php

+ + +

days_in_month()

+ +

Returns the number of days in a given month/year. Takes leap years into account. Example:

+echo days_in_month(06, 2005); + +

If the second parameter is empty, the current year will be used.

+ + + +

timezone_menu()

+ +

Generates a pull-down menu of timezones, like this one:

+ +
+ +
+ +

This menu is useful if you run a membership site in which your users are allowed to set their local timezone value.

+ +

The first paramater lets you set the "selected" state of the menu. For example, to set Pacific time as the default you will do this:

+ +echo timezone_menu('UM8'); + +

Please see the timezone reference below to see the values of this menu.

+ +

The second parameter lets you set a CSS class name for the menu.

+ +

Note: The text contained in the menu is found in the following language file: language/<your_lang>/date_lang.php

+ + + +

Timezone Reference

+ +

The following table indicates each timezone and its location.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Time ZoneLocation
UM12(UTC - 12:00) Enitwetok, Kwajalien
UM11(UTC - 11:00) Nome, Midway Island, Samoa
UM10(UTC - 10:00) Hawaii
UM9(UTC - 9:00) Alaska
UM8(UTC - 8:00) Pacific Time
UM7(UTC - 7:00) Mountain Time
UM6(UTC - 6:00) Central Time, Mexico City
UM5(UTC - 5:00) Eastern Time, Bogota, Lima, Quito
UM4(UTC - 4:00) Atlantic Time, Caracas, La Paz
UM25(UTC - 3:30) Newfoundland
UM3(UTC - 3:00) Brazil, Buenos Aires, Georgetown, Falkland Is.
UM2(UTC - 2:00) Mid-Atlantic, Ascention Is., St Helena
UM1(UTC - 1:00) Azores, Cape Verde Islands
(UTC(UTC) Casablanca, Dublin, Edinburgh, London, Lisbon, Monrovia
UP1(UTC + 1:00) Berlin, Brussels, Copenhagen, Madrid, Paris, Rome
UP2(UTC + 2:00) Kaliningrad, South Africa, Warsaw
UP3(UTC + 3:00) Baghdad, Riyadh, Moscow, Nairobi
UP25(UTC + 3:30) Tehran
UP4(UTC + 4:00) Adu Dhabi, Baku, Muscat, Tbilisi
UP35(UTC + 4:30) Kabul
UP5(UTC + 5:00) Islamabad, Karachi, Tashkent
UP45(UTC + 5:30) Bombay, Calcutta, Madras, New Delhi
UP6(UTC + 6:00) Almaty, Colomba, Dhakra
UP7(UTC + 7:00) Bangkok, Hanoi, Jakarta
UP8(UTC + 8:00) Beijing, Hong Kong, Perth, Singapore, Taipei
UP9(UTC + 9:00) Osaka, Sapporo, Seoul, Tokyo, Yakutsk
UP85(UTC + 9:30) Adelaide, Darwin
UP10(UTC + 10:00) Melbourne, Papua New Guinea, Sydney, Vladivostok
UP11(UTC + 11:00) Magadan, New Caledonia, Solomon Islands
UP12(UTC + 12:00) Auckland, Wellington, Fiji, Marshall Island
+ + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/directory_helper.html b/user_guide/helpers/directory_helper.html new file mode 100644 index 000000000..803bb4ce0 --- /dev/null +++ b/user_guide/helpers/directory_helper.html @@ -0,0 +1,145 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.0

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

Directory Helper

+ +

The Directory Helper file contains functions that assist in working with directories.

+ + +

Loading this Helper

+ +

This helper is loaded using the following code:

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

The following functions are available:

+ +

directory_map('source directory')

+ +

This function reads the directory path specified in the first parameter +and builds an array representation of it and all its contained files. Example:

+ +$map = directory_map('./mydirectory/'); + +

Note: Paths are almost always relative to your main index.php file.

+ + + +

Sub-folders contained within the directory will be mapped as well. If you wish to map +only the top level directory set the second parameter to true (boolean):

+ +$map = directory_map('./mydirectory/', TRUE); + +

Each folder name will be an array index, while its contained files will be numerically indexed. +Here is an example of a typical array:

+ +Array
+(
+   [libraries] => Array
+   (
+       [0] => benchmark.html
+       [1] => config.html
+       [database] => Array
+       (
+             [0] => active_record.html
+             [1] => binds.html
+             [2] => configuration.html
+             [3] => connecting.html
+             [4] => examples.html
+             [5] => fields.html
+             [6] => index.html
+             [7] => queries.html
+        )
+       [2] => email.html
+       [3] => file_uploading.html
+       [4] => image_lib.html
+       [5] => input.html
+       [6] => language.html
+       [7] => loader.html
+       [8] => pagination.html
+       [9] => uri.html
+)
+ + + + + + + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/file_helper.html b/user_guide/helpers/file_helper.html new file mode 100644 index 000000000..c6b049b27 --- /dev/null +++ b/user_guide/helpers/file_helper.html @@ -0,0 +1,144 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.0

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

File Helper

+ +

The File Helper file contains functions that assist in working with files.

+ + +

Loading this Helper

+ +

This helper is loaded using the following code:

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

The following functions are available:

+ +

read_file('path')

+ +

Returns the data contained in the file specified in the path. Example:

+ +$string = read_file('./path/to/file.php'); + +

The path can be a relative or full server path. Returns FALSE (boolean) on failure.

+ +

Note: The path is relative to your main site index.php file, NOT your controller or view files. +Code Igniter uses a front controller so paths are always relative to the main site index.

+ +

If you server is running an open_basedir restriction this function +might not work if you are trying to access a file above the calling script.

+ +

write_file('path', $data)

+ +

Writes data to the file specified in the path. If the file does not exist the function will create it. Example:

+ + +$data = 'Some file data';
+
+if ( ! write_file('./path/to/file.php', $data))
+{
+     echo 'Unable to write the file';
+}
+else
+{
+     echo 'File written!';
+}
+ +

Note: In order for this function to write data to a file its file permissions must be set such that it is writable (666, 777, etc.). +If the file does not already exist, the directory containing it must be writable.

+ +

Note: The path is relative to your main site index.php file, NOT your controller or view files. +Code Igniter uses a front controller so paths are always relative to the main site index.

+ + + +

delete_files('path')

+ +

Deletes ALL files contained in the supplied path. Example:

+delete_files('/path/to/directory/'); + +

If the second parameter is set to true, any directories contained within the supplied root path will be deleted as well. Example:

+ +delete_files('/path/to/directory/', TRUE); + +

Note: The files must be writable or owned by the system in order to be deleted.

+ + + + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/form_helper.html b/user_guide/helpers/form_helper.html new file mode 100644 index 000000000..8593f81d9 --- /dev/null +++ b/user_guide/helpers/form_helper.html @@ -0,0 +1,343 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.0

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

Form Helper

+ +

The Form Helper file contains functions that assist in working with forms.

+ + +

Loading this Helper

+ +

This helper is loaded using the following code:

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

The following functions are available:

+ + + +

form_open()

+ +

Creates an opening form tag with a base URL built from your config preferences. It will optionally let you +add form attributes and hidden input fields.

+ +

The main benefit of using this tag rather than hard coding your own HTML is that it permits your site to be more portable +in the event your URLs ever change.

+ +

Here's a simple example:

+ +echo form_open('email/send'); + +

The above example would create a form that points to your base URL plus the "email/send" URI segments, like this:

+ +<form method="post" action="http:/www.your-site.com/index.php/email/send" /> + +

Adding Attributes

+ +

Attributes can be added by passing an associative array to the second parameter, like this:

+ + +$attributes = array('class' => 'email', 'id' => 'myform');
+
+echo form_open('email/send', $attributes);
+ +

The above example would create a form similar to this:

+ +<form method="post" action="http:/www.your-site.com/index.php/email/send"  class="email"  id="myform" /> + +

Adding Hidden Input Fields

+ +

Hidden fields can be added by passing an associative array to the third parameter, like this:

+ + +$hidden = array('username' => 'Joe', 'member_id' => '234');
+
+echo form_open('email/send', '', $hidden);
+ +

The above example would create a form similar to this:

+ +<form method="post" action="http:/www.your-site.com/index.php/email/send"  class="email"  id="myform" />
+<input type="hidden" name="username" value="Joe" />
+<input type="hidden" name="member_id" value="234" />
+ + +

form_open_multipart()

+ +

This function is absolutely identical to the form_open() tag above except that it adds a multipart attribute, +which is necessary if you would like to use the form to upload files with.

+ +

form_hidden()

+ +

Lets you generate hidden input fields. You can either submit a name/value string to create one field:

+ +form_hidden('username', 'johndoe');
+
+// Would produce:

+<input type="hidden" name="username" value="johnodoe" />
+ +

Or you can submit an associative array to create multiple fields:

+ +$data = array(
+              'name'  => 'John Doe',
+              'email' => 'john@some-site.com',
+              'url'   => 'http://www.some-site.com'
+            );
+
+echo form_hidden($data);
+
+// Would produce:

+<input type="hidden" name="name" value="John Doe" />
+<input type="hidden" name="email" value="john@some-site.com" />
+<input type="hidden" name="url" value="http://www.some-site.com" />
+ + + + +

form_input()

+ +

Lets you generate a standard text input field. You can minimally pass the field name and value in the first +and second parameter: + +echo form_input('username', 'johndoe'); + +

Or you can pass an associative array containing any data you wish your form to contain:

+ +$data = array(
+              'name'        => 'username',
+              'id'          => 'username',
+              'value'       => 'johndoe',
+              'maxlength'   => '100',
+              'size'        => '50',
+              'style'       => 'width:50%',
+            );
+
+echo form_input($data);
+
+// Would produce:

+<input type="text" name="username" id="username" value="johndoe" maxlength="100" size="50" style="width:50%" />
+ +

If you would like your form to contain some additional data, like JavaScript, you can pass it as a string in the +third parameter: + +$js = 'onClick="some_function()"';
+
+echo form_input('username', 'johndoe', $js);
+ +

form_password()

+ +

This function is identical in all respects to the form_input() function above +except that is sets it as a "password" type.

+ +

form_upload()

+ +

This function is identical in all respects to the form_input() function above +except that is sets it as a "file" type, allowing it to be used to upload files.

+ +

form_textarea()

+ +

This function is identical in all respects to the form_input() function above +except that it generates a "textarea" type. Note: Instead of the "maxlength" and "size" attributes in the above +example, you will instead specify "rows" and "cols".

+ + +

form_dropdown()

+ +

Lets you create a standard drop-down field. The first parameter will contain the name of the field, +the second parameter will contain an associative array of options, and the third parameter will contain the +value you wish to be selected. Example: + +$options = array(
+                  'small'  => 'Small Shirt',
+                  'med'    => 'Medium Shirt',
+                  large'   => 'Large Shirt',
+                  'xlarge' => 'Extra Large Shirt',
+                );
+
+echo form_dropdown('shirts', $options, 'large');
+
+// Would produce:

+ +<select name="shirts">
+<option value="small">Small Shirt
+<option value="med">Medium Shirt
+<option value="large" selected>Large Shirt
+<option value="xlarge">Extra Large Shirt
+</select>
+ + +

If you would like the opening <select> to contain additional data, like JavaScript, you can pass it as a string in the +fourth parameter: + +$js = 'onChange="some_function()"';
+
+echo form_dropdown('shirts', $options, 'large', $js);
+ + +

form_checkbox()

+ +

Lets you generate a checkbox field. Simple example: + + +echo form_checkbox('newsletter', 'accept', TRUE);
+
+// Would produce:
+
+<input type="checkbox" name="newsletter" value="accept" checked="checked" />
+ +

The third parameter contains a boolean TRUE/FALSE to determine whether the box should be checked or not.

+ +

Similar to the other form functions in this helper, you can also pass an array of attributes to the function:

+ +$data = array(
+              'name'        => 'newsletter',
+              'id'          => 'newsletter',
+              'value'       => 'accept',
+              'checked'     => TRUE,
+              'style'       => 'margin:10px',
+            );
+
+echo form_checkbox($data);
+
+// Would produce:

+<input type="checkbox" name="newsletter" id="newsletter" value="accept" checked="checked" style="margin:10px" />
+ +

As with other functions, if you would like the tag to contain additional data, like JavaScript, you can pass it as a string in the +fourth parameter: + +$js = 'onClick="some_function()"';
+
+echo echo form_checkbox('newsletter', 'accept', TRUE, $js)
+ + +

form_radio()

+

This function is identical in all respects to the form_checkbox() function above except that is sets it as a "radio" type.

+ + +

form_submit()

+ +

Lets you generate a standard submit button. Simple example:

+ +echo form_submit('mysubmit', 'Submit Post!');
+
+// Would produce:
+
+<input type="submit" name="mysubmit" value="Submit Post!" />
+ +

Similar to other functions, you can submit an associative array in the first parameter if you prefer to set your own attributes. +The third parameter lets you add extra data to your form, like JavaScript.

+ + +

form_close()

+ +

Produces a closing </form> tag. The only advantage to using this function is it permits you to pass data to it +which will be added below the tag. For example:

+ +$string = "</div></div>";
+
+echo form_close($string);
+
+// Would produce:
+
+</form>
+</div></div>
+ + + + + +

form_prep()

+ +

Allows you to safely use HTML and characters such as quotes within form elements without breaking out of the form. Consider this example:

+ +$string = 'Here is a string containing "quoted" text.';
+
+<input type="text" name="myform" value="$string" />
+ +

Since the above string contains a set of quotes it will cause the form to break. +The form_prep function converts HTML so that it can be used safely:

+ +<input type="text" name="myform" value="<?php echo form_prep($string); ?>" /> + +

Note: If you use any of the form helper functions listed in this page the form +values will be prepped automatically, so there is no need to call this function. Use it only if you are +creating your own form elements.

+ + + + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/html_helper.html b/user_guide/helpers/html_helper.html new file mode 100644 index 000000000..603b83aa8 --- /dev/null +++ b/user_guide/helpers/html_helper.html @@ -0,0 +1,117 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.0

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

HTML Helper

+ +

The HTML Helper file contains functions that assist in working with HTML.

+ + +

Loading this Helper

+ +

This helper is loaded using the following code:

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

The following functions are available:

+ + +

heading()

+ +

Lets you create HTML <h1> tags. The first parameter will contain the data, the +second the size of the heading. Example:

+ +echo heading('Welcome!', 3); + +

The above would produce: <h3>Welcome!</h3>

+ + +

nbs()

+

Generates non-breaking spaces (&nbsp;) based on the number you submit. Example:

+echo nbs(3); +

The above would produce: &nbsp;&nbsp;&nbsp;

+ + +

br()

+

Generates line break tags (<br />) based on the number you submit. Example:

+echo br(3); +

The above would produce: <br /><br /><br />

+ + + + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/index.html b/user_guide/helpers/index.html new file mode 100644 index 000000000..342549d33 --- /dev/null +++ b/user_guide/helpers/index.html @@ -0,0 +1,131 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.0

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

Helper Functions

+ +

Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular +category. There are URL Helpers, that assist in creating links, there are Form Helpers +that help you create form elements, Text Helpers perform various text formatting routines, +Cookie Helpers set and read cookies, File Helpers help you deal with files, etc. +

+ +

Unlike most other systems in Code Igniter, Helpers are not written in an Object Oriented format. They are simple, procedural functions. +Each helper function performs one specific task, with no dependence on other functions.

+ +

Helpers are intentionally kept very simple so that they can be used within your View Files with a minimal amount of code. +This is important if you intend to have designers or non-programmer will be working with your view files, since it keeps the code to a minimum. +

+ +

Code Igniter does not load Helper Files by default, so the first step in using +a Helper is to load it. Once loaded, it becomes globally available in your controller and views.

+ +

Loading a Helper

+ +

Loading a helper file is quite simple using the following function:

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

Where name is the file name of the helper, without the .php file extension or the "helper" part.

+ +

For example, to load the URL Helper file, which is named url_helper.php, you would do this:

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

A helper can be loaded anywhere within your controller functions (or even within your View files, although that's not a good practice), +as long as you load it before you use it. You can load your helpers in your controller constructor so that they become available +automatically in any function, or you can load a helper in a specific function that needs it.

+ +

Note: The Helper loading function above does not return a value, so don't try to assign it to a variable. Just use it as shown.

+ +

Auto-loading Helpers

+ +

If you find that you need a particular helper globally throughout your application, you can tell Code Igniter to auto-load it during system initialization. +This is done by opening the application/config/autoload.php file and adding the helper to the autoload array.

+ + +

Using a Helper

+ +

Once you've loaded the Helper File containing the function you intend to use, you'll call it the way you would a standard PHP function.

+ +

For example, to create a link using the anchor() function in one of your view files you would do this:

+ +<?=anchor('blog/comments', 'Click Here');?> + +

Where "Click Here" is the name of the link, and "blog/comments" is the URI to the controller/function you wish to link to.

+ + +

Now What?

+ +

In the Table of Contents you'll find a list of all the available Helper Files. Browse each one to see what they do.

+ + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/security_helper.html b/user_guide/helpers/security_helper.html new file mode 100644 index 000000000..7649fe779 --- /dev/null +++ b/user_guide/helpers/security_helper.html @@ -0,0 +1,131 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.0

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

Security Helper

+ +

The Security Helper file contains security related functions.

+ + +

Loading this Helper

+ +

This helper is loaded using the following code:

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

The following functions are available:

+ + +

xss_clean()

+ +

Provides Cross Site Script Hack filtering. This function is an alias to the the one in the +Input class. More info can be found there.

+ + +

hash()

+ +

Permits you to create SHA1 or MD5 one way hashes suitable for encrypting passwords. Will create SHA1 by default. Examples:

+ + +$str = hash($str); // SHA1
+
+$str = hash($str, 'md5'); // MD5 +
+ + + + +

strip_image_tags()

+ +

This is a security function that will strip image tags from a string. It leaves the image URL as plain text.

+ +$string = strip_image_tags($string); + + +

encode_php_tags()

+ +

This is a security function that converts PHP tags to entities. Note: If you use the XSS filtering function it does this automatically.

+ +$string = encode_php_tags($string); + + + + + + + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/string_helper.html b/user_guide/helpers/string_helper.html new file mode 100644 index 000000000..dfe8ae7d6 --- /dev/null +++ b/user_guide/helpers/string_helper.html @@ -0,0 +1,144 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.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:

+ + + + +

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 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.

+ + + + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/text_helper.html b/user_guide/helpers/text_helper.html new file mode 100644 index 000000000..61de8ea43 --- /dev/null +++ b/user_guide/helpers/text_helper.html @@ -0,0 +1,197 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.0

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

Text Helper

+ +

The Text Helper file contains functions that assist in working with text.

+ + +

Loading this Helper

+ +

This helper is loaded using the following code:

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

The following functions are available:

+ + +

word_limiter()

+ +

Truncates a string to the number of words specified. Example:

+ + +$str = "Here is a nice text string consisting of eleven words.";
+
+$string = word_limiter($string, 4);

+ +// Returns: Here is a nice… +
+ +

The third parameter is an optional suffix added to the string. By default it add an ellipsis.

+ + +

character_limiter()

+ +

Truncates a string to the number of characters specified. It maintains the integrity +of words so the character count may be slightly more or less then what you specify. Example:

+ + +$str = "Here is a nice text string consisting of eleven words.";
+
+$string = char_limiter($string, 20);

+ +// Returns: Here is a nice text string… +
+ +

The third parameter is an optional suffix added to the string. By default it add an ellipsis.

+ + + +

ascii_to_entities()

+ +

Converts ASCII values to character entities, including high ASCII and MS Word characters that can cause problems when used in a web page, +so that they can be shown consistently regardless of browser settings or stored reliably in a database. +There is some dependance on your server's supported character sets, so it may not be 100% reliable in all cases, but for the most +part it should correctly identify characters outside the normal range (like accented characters). Example:

+ +$string = ascii_to_entities($string); + + +

entities_to_ascii()

+ +

This function does the opposite of the previous one; it turns character entities back into ASCII.

+ + +

word_censor()

+ +

Enables you to censor words within a text string. The first parameter will contain the original string. The +second will contain an array of words which you disallow. The third (optional) parameter can contain a replacement value +for the words. If not specified they are replaced with pound signs: ####. Example:

+ + +$disallowed = array('darn', 'shucks', 'golly', 'phooey');
+
+$string = word_censor($string, $disallowed, 'Beep!');
+ + +

highlight_code()

+ +

Colorizes a string of code (PHP, HTML, etc.). Example:

+ +$string = highlight_code($string); + +

The function uses PHP's highlight_string() function, so the colors used are the ones specified in your php.ini file.

+ + +

highlight_phrase()

+ +

Will highlight a phrase within a text string. The first parameter will contain the original string, the second will +contain the phrase you wish to highlight. The third and fourth parameters will contain the opening/closing HTML tags +you would like the phrase wrapped in. Example:

+ + +$str = "Here is a nice text string about nothing in particular.";
+
+$string = highlight_phrase($string, "nice text", '<span style="color:#990000">', '</span>'); +
+ +

The above text returns:

+ +

Here is a nice text string about nothing in particular.

+ + + +

word_wrap()

+ +

Wraps text at the specified character count while maintaining complete words. Example:

+ +$string = "Here is a simple string of text that will help us demonstrate this function.";
+
+echo word_wrap($string, 25);
+
+// Would produce:
+
+Here is a simple string
+of text that will help
+us demonstrate this
+function
+ + + + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/typography_helper.html b/user_guide/helpers/typography_helper.html new file mode 100644 index 000000000..5e8da4bab --- /dev/null +++ b/user_guide/helpers/typography_helper.html @@ -0,0 +1,129 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.0

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

Typography Helper

+ +

The Typography Helper file contains functions that help your format text in semantically relevant ways.

+ + +

Loading this Helper

+ +

This helper is loaded using the following code:

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

The following functions are available:

+ + +

auto_typography()

+ +

Formats text so that it is semantically and typographically correct HTML. Takes a string as input and returns it with +the following formatting:

+ + + +

Usage example:

+ +$string = auto_typography($string); + +

Note: Typographic formatting can be processor intensive, particularly if you have a lot of content being formatted. +If you choose to use this function you may want to consider +caching your pages.

+ + +

nl2br_except_pre()

+ +

Converts newlines to <br /> tags unless they appear within <pre> tags. +This function is identical to the native PHP nl2br() function, except that it ignores <pre> tags.

+ +

Usage example:

+ +$string = nl2br_except_pre($string); + + + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/url_helper.html b/user_guide/helpers/url_helper.html new file mode 100644 index 000000000..a8f5c14d6 --- /dev/null +++ b/user_guide/helpers/url_helper.html @@ -0,0 +1,269 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.0

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

URL Helper

+ +

The URL Helper file contains functions that assist in working with URLs.

+ + +

Loading this Helper

+ +

This helper is loaded using the following code:

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

The following functions are available:

+ +

site_url()

+ +

Returns your site URL, as specified in your config file. The index.php file (or whatever you have set as your +site index_page in your config file) will be added to the URL, as will any URI segments you pass to the function.

+ +

You are encouraged to use this function any time you need to generate a local URL so that your pages become more portable +in the event your URL changes.

+ +

Segments can be optionally passed to the function as a string or an array. Here is a string example:

+ +echo site_url("news/local/123"); + +

The above example would return something like: http://www.your-site.com/index.php/news/local/123

+ +

Here is an example of segments passed as an array:

+ + +$segments = array('news', 'local', '123');
+
+echo site_url($segments);
+ + +

base_url()

+

Returns your site base URL, as specified in your config file. Example:

+echo base_url(); + + +

index_page()

+

Returns your site "index" page, as specified in your config file. Example:

+echo index_page(); + + + +

anchor()

+ +

Creates a standard HTML anchor link based on your local site URL:

+ +<a href="http://www.your-site.com">Click Here</a> + +

The tag has three optional parameters:

+ +anchor(uri segments, text, attributes) + +

The first parameter can contain any segments you wish appended to the URL. As with the site_url() function above, +segments can be a string or an array. Note: Do not include the base URL. It will be built as specified in your config file. Include +only the URI segments you wish appended to the URL.

+ +

The second segment is the text you would like the link to say. If you leave it blank, the URL will be used.

+ +

The third parameter can contain a list of attributes you would like added to the link. The attributes can be a simple string or an associative array.

+ +

Here are some examples:

+ +echo anchor(news/local/123, My News); + +

Would produce: <a href="http://www.your-site.com/index.php/news/local/123" title="My News">My News</a>

+ +echo anchor(news/local/123, My News, array('title' => 'The best news!')); + +

Would produce: <a href="http://www.your-site.com/index.php/news/local/123" title="The best news!">My News</a>

+ + +

anchor_popup()

+ +

Nearly identical to the anchor() function except that it opens the URL in a new window. + +You can specify JavaScript window attributes in the third parameter to control how the window is opened. If +the third parameter is not set it will simply open a new window with your own browser settings. Here is an example +with attributes:

+ + + +$atts = array(
+              'width'      => '800',
+              'height'     => '600',
+              'scrollbars' => 'yes',
+              'status'     => 'yes',
+              'resizable'  => 'yes',
+              'screenx'    => '0',
+              'screeny'    => '0'
+            );
+
+echo anchor_popup(news/local/123, 'Click Me!', $atts);
+ +

Note: The above attributes are the function defaults so you only need to set the ones that are different from what you need. +If you want the function to use all of its defaults simply pass an empty array in the third parameter:

+ +echo anchor_popup(news/local/123, 'Click Me!', array()); + + +

mailto()

+ +

Creates a standard HTML email link. Usage example:

+ +echo mailto('me@my-site.com', 'Click Here to Contact Me'); + +

As with the anchor() tab above, you can set attributes using the third parameter.

+ + +

safe_mailto()

+ +

Identical to the above function except it writes an obfuscated version of the mailto tag using ordinal numbers +written with JavaScript to help prevent the email address from being harvested by spam bots.

+ + +

auto_link()

+ +

Automatically turns URLs and email addresses contained in a string into links. Example:

+ +$string = auto_link($string); + +

The second parameter determines whether URLs and emails are converted or just one or the other. Default behavior is both +if the parameter is not specified

+ +

Converts only URLs:

+$string = auto_link($string, 'url'); + +

Converts only Email addresses:

+$string = auto_link($string, 'email'); + +

The third parameter determines whether links are shown in a new window. The value can be TRUE or FALSE (boolean):

+$string = auto_link($string, 'both', TRUE); + + +

url_title()

+

Takes a string as input and creates a human-friendly URL string. This is useful if, for example, you have a blog +in which you'd like to use the title of your entries in the URL. Example:

+ +$title = "What's wrong with CSS?";
+
+$url_title = url_title($title);
+
+// Produces: whats-wrong-with-css +
+ + +

The second parameter determines the word delimiter. By default dashes are used. Options are: dash, or underscore:

+ +$title = "What's wrong with CSS?";
+
+$url_title = url_title($title, 'underscore');
+
+// Produces: whats_wrong_with_css +
+ + +

prep_url()

+

This function will add http:// in the event it is missing from a URL. Pass the URL string to the function like this:

+ +$url = "www.some-site.com";

+$url = prep_url($url);
+ + + + +

redirect()

+ +

Does a "header redirect" to the local URI specified. Just like other functions in this helper, this one is designed +to redirect to a local URL within your site. You will not specify the full site URL, but rather simply the URI segments +to the controller you want to direct to. The function will build the URL based on your config file values.

+ +

The second parameter allows you to choose between the "location" +method or the "refresh" method. Location is faster, but on Windows servers it can sometimes be a problem. Example:

+ +if ($logged_in == FALSE)
+{
+     redirect('/login/form/', 'refresh');
+}
+ +

Note: In order for this function to work it must be used before anything is outputted +to the browser since it utilizes server headers.

+ + + + + + +
+ + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/xml_helper.html b/user_guide/helpers/xml_helper.html new file mode 100644 index 000000000..63e2b73cd --- /dev/null +++ b/user_guide/helpers/xml_helper.html @@ -0,0 +1,110 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.0

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

XML Helper

+ +

The XML Helper file contains functions that assist in working with XML data.

+ + +

Loading this Helper

+ +

This helper is loaded using the following code:

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

The following functions are available:

+ +

xml_convert('string')

+ +

Takes a string as input and converts the following reserved XML characters to entities:

+ +

+Ampersands: &
+Less then and greater than characters: < >
+Single and double quotes: '  "
+Dashes: -

+ +

This function ignores ampersands if they are part of existing character entities. Example:

+ +$string = xml_convert($string); + + + + + + +
+ + + + + + + \ No newline at end of file -- cgit v1.2.3-24-g4f1b