summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/helpers
diff options
context:
space:
mode:
authorJonathon Hill <jhill@brandmovers.com>2012-11-12 14:51:41 +0100
committerJonathon Hill <jhill@brandmovers.com>2012-11-12 14:51:41 +0100
commit3978fc33d82dd7f778d1adbf30744f4dfac41c25 (patch)
treef32be1ae610f0cfeff65c35abecd14e8ea5cadc6 /user_guide_src/source/helpers
parent275cf274860c6ed181d50b398efd3a21d7ba9135 (diff)
parenta9ab46d7a031bda304eb9b6658ffaf693b8d9bcb (diff)
Merge remote-tracking branch 'upstream/develop' into develop
Conflicts: user_guide_src/source/changelog.rst Signed-off-by: Jonathon Hill <jhill@brandmovers.com>
Diffstat (limited to 'user_guide_src/source/helpers')
-rw-r--r--user_guide_src/source/helpers/array_helper.rst66
-rw-r--r--user_guide_src/source/helpers/captcha_helper.rst99
-rw-r--r--user_guide_src/source/helpers/cookie_helper.rst65
-rw-r--r--user_guide_src/source/helpers/date_helper.rst339
-rw-r--r--user_guide_src/source/helpers/directory_helper.rst5
-rw-r--r--user_guide_src/source/helpers/download_helper.rst32
-rw-r--r--user_guide_src/source/helpers/email_helper.rst48
-rw-r--r--user_guide_src/source/helpers/file_helper.rst178
-rw-r--r--user_guide_src/source/helpers/form_helper.rst518
-rw-r--r--user_guide_src/source/helpers/html_helper.rst296
-rw-r--r--user_guide_src/source/helpers/inflector_helper.rst82
-rw-r--r--user_guide_src/source/helpers/language_helper.rst25
-rw-r--r--user_guide_src/source/helpers/number_helper.rst32
-rw-r--r--user_guide_src/source/helpers/path_helper.rst31
-rw-r--r--user_guide_src/source/helpers/security_helper.rst70
-rw-r--r--user_guide_src/source/helpers/smiley_helper.rst70
-rw-r--r--user_guide_src/source/helpers/string_helper.rst136
-rw-r--r--user_guide_src/source/helpers/text_helper.rst138
-rw-r--r--user_guide_src/source/helpers/typography_helper.rst45
-rw-r--r--user_guide_src/source/helpers/url_helper.rst300
20 files changed, 1527 insertions, 1048 deletions
diff --git a/user_guide_src/source/helpers/array_helper.rst b/user_guide_src/source/helpers/array_helper.rst
index 15b5e17c4..9435b3ac7 100644
--- a/user_guide_src/source/helpers/array_helper.rst
+++ b/user_guide_src/source/helpers/array_helper.rst
@@ -10,9 +10,7 @@ arrays.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('array');
@@ -21,20 +19,19 @@ The following functions are available:
element()
=========
-.. php:method:: element($item, $array, $default = NULL)
-
- :param string $item: Item to fetch from the array
- :param array $array: Input array
- :param boolean $default: What to return if the array isn't valid
- :returns: NULL on failure or the array item.
+.. php:function:: element($item, $array, $default = NULL)
+ :param string $item: Item to fetch from the array
+ :param array $array: Input array
+ :param bool $default: What to return if the array isn't valid
+ :returns: NULL on failure or the array item.
Lets you fetch an item from an array. The function tests whether the
array index is set and whether it has a value. If a value exists it is
returned. If a value does not exist it returns NULL, or whatever you've
-specified as the default value via the third parameter. Example
+specified as the default value via the third parameter.
-::
+Example::
$array = array(
'color' => 'red',
@@ -48,21 +45,19 @@ specified as the default value via the third parameter. Example
elements()
==========
+.. php:function:: elements($items, $array, $default = NULL)
+
+ :param string $item: Item to fetch from the array
+ :param array $array: Input array
+ :param bool $default: What to return if the array isn't valid
+ :returns: NULL on failure or the array item.
+
Lets you fetch a number of items from an array. The function tests
whether each of the array indices is set. If an index does not exist it
is set to NULL, or whatever you've specified as the default value via
the third parameter.
-.. php:method:: elements($items, $array, $default = NULL)
-
- :param string $item: Item to fetch from the array
- :param array $array: Input array
- :param boolean $default: What to return if the array isn't valid
- :returns: NULL on failure or the array item.
-
-Example
-
-::
+Example::
$array = array(
'color' => 'red',
@@ -73,9 +68,7 @@ Example
$my_shape = elements(array('color', 'shape', 'height'), $array);
-The above will return the following array
-
-::
+The above will return the following array::
array(
'color' => 'red',
@@ -83,15 +76,12 @@ The above will return the following array
'height' => NULL
);
-You can set the third parameter to any default value you like
-
+You can set the third parameter to any default value you like.
::
$my_shape = elements(array('color', 'shape', 'height'), $array, 'foobar');
-The above will return the following array
-
-::
+The above will return the following array::
array(     
'color' => 'red',
@@ -99,9 +89,9 @@ The above will return the following array
'height' => 'foobar'
);
-This is useful when sending the $_POST array to one of your Models.
+This is useful when sending the ``$_POST`` array to one of your Models.
This prevents users from sending additional POST data to be entered into
-your tables
+your tables.
::
@@ -116,15 +106,14 @@ updated.
random_element()
================
-Takes an array as input and returns a random element from it. Usage
-example
+.. php:function:: random_element($array)
-.. php:method:: random_element($array)
+ :param array $array: Input array
+ :returns: string (a random element from the array)
- :param array $array: Input array
- :returns: String - Random element from the array.
+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",
@@ -135,5 +124,4 @@ example
"Chance favors the prepared mind - Louis Pasteur"
);
- echo random_element($quotes);
-
+ echo random_element($quotes); \ No newline at end of file
diff --git a/user_guide_src/source/helpers/captcha_helper.rst b/user_guide_src/source/helpers/captcha_helper.rst
index 90244739b..17462a8de 100644
--- a/user_guide_src/source/helpers/captcha_helper.rst
+++ b/user_guide_src/source/helpers/captcha_helper.rst
@@ -11,78 +11,72 @@ Loading this Helper
===================
This helper is loaded using the following code
-
::
$this->load->helper('captcha');
The following functions are available:
-create_captcha($data)
-=====================
+create_captcha()
+================
+
+.. php:function:: function create_captcha($data = '', $img_path = '', $img_url = '', $font_path = '')
+
+ :param array $data: Array of data for the CAPTCHA
+ :param string $img_path: Path to create the image in
+ :param string $img_url: URL to the CAPTCHA image folder
+ :param string $font_path: Server path to font
+ :returns: array('word' => $word, 'time' => $now, 'image' => $img)
Takes an array of information to generate the CAPTCHA as input and
creates the image to your specifications, returning an array of
associative data about the image.
-.. php:method:: function create_captcha($data = '', $img_path = '', $img_url = '', $font_path = '')
-
- :param array $data: array of data for the CAPTCHA
- :param string $img_path: path to create the image in
- :param string $img_url: URL to the CAPTCHA image folder
- :param string $font_path: server path to font
- :returns: array('word' => $word, 'time' => $now, 'image' => $img)
-
-
::
- [array] (
- 'image' => IMAGE TAG   
- 'time' => TIMESTAMP (in microtime)   
- 'word' => CAPTCHA WORD )
+ array(
+ 'image' => IMAGE TAG
+ 'time' => TIMESTAMP (in microtime)
+ 'word' => CAPTCHA WORD
+ )
-The "image" is the actual image tag:
-
-::
+The **image** is the actual image tag::
<img src="http://example.com/captcha/12345.jpg" width="140" height="50" />
-
-The "time" is the micro timestamp used as the image name without the
+The **time** is the micro timestamp used as the image name without the
file extension. It will be a number like this: 1139612155.3422
-The "word" is the word that appears in the captcha image, which if not
+The **word** is the word that appears in the captcha image, which if not
supplied to the function, will be a random string.
Using the CAPTCHA helper
------------------------
-Once loaded you can generate a captcha like this
-
-::
+Once loaded you can generate a captcha like this::
- $vals = array(     
- 'word' => 'Random word',     
- 'img_path' => './captcha/',     
- 'img_url' => 'http://example.com/captcha/',     
- 'font_path' => './path/to/fonts/texb.ttf',     
- 'img_width' => '150',     
- 'img_height' => 30,     
- 'expiration' => 7200     
+ $vals = array(
+ 'word' => 'Random word',
+ 'img_path' => './captcha/',
+ 'img_url' => 'http://example.com/captcha/',
+ 'font_path' => './path/to/fonts/texb.ttf',
+ 'img_width' => '150',
+ 'img_height' => 30,
+ 'expiration' => 7200
);
- $cap = create_captcha($vals); echo $cap['image'];
-
+ $cap = create_captcha($vals);
+ echo $cap['image'];
- The captcha function requires the GD image library.
-- Only the img_path and img_url are required.
-- If a "word" is not supplied, the function will generate a random
+- Only the **img_path** and **img_url** are required.
+- If a **word** is not supplied, the function will generate a random
ASCII string. You might put together your own word library that you
can draw randomly from.
- If you do not specify a path to a TRUE TYPE font, the native ugly GD
font will be used.
- The "captcha" folder must be writable (666, or 777)
-- The "expiration" (in seconds) signifies how long an image will remain
+- The **expiration** (in seconds) signifies how long an image will remain
in the captcha folder before it will be deleted. The default is two
hours.
@@ -90,14 +84,12 @@ Adding a Database
-----------------
In order for the captcha function to prevent someone from submitting,
-you will need to add the information returned from create_captcha()
-function to your database. Then, when the data from the form is
-submitted by the user you will need to verify that the data exists in
-the database and has not expired.
+you will need to add the information returned from ``create_captcha()``
+to your database. Then, when the data from the form is submitted by
+the user you will need to verify that the data exists in the database
+and has not expired.
-Here is a table prototype
-
-::
+Here is a table prototype::
CREATE TABLE captcha (  
captcha_id bigint(13) unsigned NOT NULL auto_increment,  
@@ -109,9 +101,7 @@ Here is a table prototype
);
Here is an example of usage with a database. On the page where the
-CAPTCHA will be shown you'll have something like this
-
-::
+CAPTCHA will be shown you'll have something like this::
$this->load->helper('captcha');
$vals = array(     
@@ -134,23 +124,20 @@ CAPTCHA will be shown you'll have something like this
echo '<input type="text" name="captcha" value="" />';
Then, on the page that accepts the submission you'll have something like
-this
-
-::
+this::
// First, delete old captchas
$expiration = time() - 7200; // Two hour limit
$this->db->where('captcha_time < ', $expiration)
- ->delete('captcha');
+ ->delete('captcha');
// Then see if a captcha exists:
- $sql = "SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND captcha_time > ?";
+ $sql = 'SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND captcha_time > ?';
$binds = array($_POST['captcha'], $this->input->ip_address(), $expiration);
$query = $this->db->query($sql, $binds);
$row = $query->row();
if ($row->count == 0)
{     
- echo "You must submit the word that appears in the image";
- }
-
+ echo 'You must submit the word that appears in the image.';
+ } \ No newline at end of file
diff --git a/user_guide_src/source/helpers/cookie_helper.rst b/user_guide_src/source/helpers/cookie_helper.rst
index 30e601c32..c41193c3c 100644
--- a/user_guide_src/source/helpers/cookie_helper.rst
+++ b/user_guide_src/source/helpers/cookie_helper.rst
@@ -10,9 +10,7 @@ cookies.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('cookie');
@@ -21,52 +19,53 @@ The following functions are available:
set_cookie()
============
+.. php:function:: set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE)
+
+ :param string $name: Cookie name
+ :param string $value: Cookie value
+ :param int $expire: Number of seconds until expiration
+ :param string $domain: Cookie domain (usually: .yourdomain.com)
+ :param string $path: Cookie path
+ :param string $prefix: Cookie name prefix
+ :param bool $secure: Whether to only send the cookie through HTTPS
+ :param bool $httponly: Whether to hide the cookie from JavaScript
+ :returns: void
+
This helper function gives you view file friendly syntax to set browser
-cookies. Refer to the :doc:`Input class <../libraries/input>` for a
-description of use, as this function is an alias to
-`$this->input->set_cookie()`.
-
-.. php:method:: set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
-
- :param string $name: the name of the cookie
- :param string $value: the value of the cookie
- :param string $expire: the number of seconds until expiration
- :param string $domain: the cookie domain. Usually: .yourdomain.com
- :param string $path: the cookie path
- :param string $prefix: the cookie prefix
- :param boolean $secure: secure cookie or not.
- :returns: void
+cookies. Refer to the :doc:`Input Library <../libraries/input>` for a
+description of its use, as this function is an alias for
+``CI_Input::set_cookie()``.
get_cookie()
============
-This helper function gives you view file friendly syntax to get browser
-cookies. Refer to the :doc:`Input class <../libraries/input>` for a
-description of use, as this function is an alias to `$this->input->cookie()`.
+.. php:function:: get_cookie($index = '', $xss_clean = FALSE)
-.. php:method:: get_cookie($index = '', $xss_clean = FALSE)
+ :param string $index: Cookie name
+ :param bool $xss_clean: Whether to apply XSS filtering to the returned value
+ :returns: mixed
- :param string $index: the name of the cookie
- :param boolean $xss_clean: If the resulting value should be xss_cleaned or not
- :returns: mixed
+This helper function gives you view file friendly syntax to get browser
+cookies. Refer to the :doc:`Input Library <../libraries/input>` for a
+description of itsuse, as this function is an alias for ``CI_Input::cookie()``.
delete_cookie()
===============
-Lets you delete a cookie. Unless you've set a custom path or other
-values, only the name of the cookie is needed
-
-.. php:method:: delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
+.. php:function:: delete_cookie($name = '', $domain = '', $path = '/', $prefix = '')
- :param string $name: the name of the cookie
- :param string $domain: cookie domain (ususally .example.com)
- :param string $path: cookie path
- :param string $prefix: cookie prefix
+ :param string $name: Cookie name
+ :param string $domain: Cookie domain (usually: .yourdomain.com)
+ :param string $path: Cookie path
+ :param string $prefix: Cookie name prefix
:returns: void
+Lets you delete a cookie. Unless you've set a custom path or other
+values, only the name of the cookie is needed.
+
::
- delete_cookie("name");
+ delete_cookie('name');
This function is otherwise identical to ``set_cookie()``, except that it
does not have the value and expiration parameters. You can submit an
diff --git a/user_guide_src/source/helpers/date_helper.rst b/user_guide_src/source/helpers/date_helper.rst
index 9de925ba7..3a3454edc 100644
--- a/user_guide_src/source/helpers/date_helper.rst
+++ b/user_guide_src/source/helpers/date_helper.rst
@@ -9,9 +9,7 @@ The Date Helper file contains functions that help you work with dates.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('date');
@@ -20,44 +18,45 @@ The following functions are available:
now()
=====
-Returns the current time as a Unix timestamp, referenced either to your
-server's local time or any PHP suported timezone, based on the "time reference"
-setting in your config file. If you do not intend to set your master time reference
-to any other PHP suported timezone (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.
+.. php:function:: now($timezone = NULL)
-.. php:method:: now($timezone = NULL)
+ :param string $timezone: Timezone
+ :returns: int
- :param string $timezone: The timezone you want to be returned
- :returns: integer
+Returns the current time as a UNIX timestamp, referenced either to your server's
+local time or any PHP suported timezone, based on the "time reference" setting
+in your config file. If you do not intend to set your master time reference to
+any other PHP supported timezone (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.
::
- echo now("Australia/Victoria");
-If a timezone is not provided, it will return time() based on "time_reference" setting.
+ echo now('Australia/Victoria');
+
+If a timezone is not provided, it will return ``time()`` based on the
+**time_reference** setting.
mdate()
=======
+.. php:function:: mdate($datestr = '', $time = '')
+
+ :param string $datestr: Date string
+ :param int $time: UNIX timestamp
+ :returns: int
+
This function is identical to PHP's `date() <http://www.php.net/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.
+code letter is preceded with a percent sign, e.g. `%Y %m %d`
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
-
-.. php:method:: mdate($datestr = '', $time = '')
+normally have to do with the ``date()`` function.
- :param string $datestr: Date String
- :param integer $time: time
- :returns: integer
+Example::
-
-::
-
- $datestring = "Year: %Y Month: %m Day: %d - %h:%i %a";
+ $datestring = 'Year: %Y Month: %m Day: %d - %h:%i %a';
$time = time();
echo mdate($datestring, $time);
@@ -67,32 +66,30 @@ will be used.
standard_date()
===============
-Lets you generate a date string in one of several standardized formats.
-Example
+.. php:function:: standard_date($fmt = 'DATE_RFC822', $time = NULL)
-.. php:method:: standard_date($fmt = 'DATE_RFC822', $time = '')
+ :param string $fmt: Date format
+ :param int $time: UNIX timestamp
+ :returns: string
- :param string $fmt: the chosen format
- :param string $time: Unix timestamp
- :returns: string
+Lets you generate a date string in one of several standardized formats.
-::
+Example::
$format = 'DATE_RFC822';
$time = time();
echo standard_date($format, $time);
-The first parameter must contain the format, the second parameter must
-contain the date as a Unix timestamp.
-
-.. note:: This function is DEPRECATED. Use the native ``date()`` combined
- with `DateTime's format constants <http://www.php.net/manual/en/class.datetime.php#datetime.constants.types>`_
+.. note:: This function is DEPRECATED.Use the native ``date()`` combined with
+ `DateTime's format constants
+ <http://www.php.net/manual/en/class.datetime.php#datetime.constants.types>`_
instead:
|
| echo date(DATE_RFC822, time());
-Supported formats:
+Supported formats
+-----------------
=============== ======================= ======================================
Constant Description Example
@@ -112,39 +109,34 @@ DATE_W3C W3C 2005-08-14T16:13:03+0000
local_to_gmt()
==============
-Takes a Unix timestamp as input and returns it as GMT.
+.. php:function:: local_to_gmt($time = '')
-.. php:method:: local_to_gmt($time = '')
+ :param int $time: UNIX timestamp
+ :returns: string
- :param integer $time: Unix timestamp
- :returns: string
+Takes a UNIX timestamp as input and returns it as GMT.
-Example:
+Example::
-::
-
- $now = time();
- $gmt = local_to_gmt($now);
+ $gmt = local_to_gmt(time());
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.
-
-.. php:method:: gmt_to_local($time = '', $timezone = 'UTC', $dst = FALSE)
+.. php:function:: gmt_to_local($time = '', $timezone = 'UTC', $dst = FALSE)
- :param integer $time: Unix timestamp
- :param string $timezone: timezone
- :param boolean $dst: whether DST is active
- :returns: integer
+ :param int $time: UNIX timestamp
+ :param string $timezone: Timezone
+ :param bool $dst: Whether DST is active
+ :returns: int
-Example
+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';
+ $timestamp = 1140153693;
$timezone = 'UM8';
$daylight_saving = TRUE;
echo gmt_to_local($timestamp, $timezone, $daylight_saving);
@@ -152,40 +144,32 @@ Example
.. 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.
+.. php:function:: mysql_to_unix($time = '')
-.. php:method:: mysql_to_unix($time = '')
+ :param int $time: UNIX timestamp
+ :returns: int
- :param integer $time: Unix timestamp
- :returns: integer
-
-Example
+Takes a MySQL Timestamp as input and returns it as a UNIX timestamp.
-::
+Example::
- $mysql = '20061124092345';
- $unix = mysql_to_unix($mysql);
+ $unix = mysql_to_unix('20061124092345');
unix_to_human()
===============
-Takes a Unix timestamp as input and returns it in a human readable
-format with this prototype
+.. php:function:: unix_to_human($time = '', $seconds = FALSE, $fmt = 'us')
-.. php:method:: unix_to_human($time = '', $seconds = FALSE, $fmt = 'us')
-
- :param integer $time: Unix timestamp
- :param boolean $seconds: whether to show seconds
- :param string $fmt: format: us or euro
+ :param int $time: UNIX timestamp
+ :param bool $seconds: Whether to show seconds
+ :param string $fmt: format (us or euro)
:returns: integer
-Example
-
-::
+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
@@ -194,9 +178,9 @@ 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
+the time without seconds formatted for the U.S.
-::
+Examples::
$now = time();
echo unix_to_human($now); // U.S. time, no seconds
@@ -206,19 +190,17 @@ the time without seconds formatted for the U.S. Examples
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.
+.. php:function:: human_to_unix($datestr = '')
-.. php:method:: human_to_unix($datestr = '')
-
- :param integer $datestr: Date String
- :returns: integer
+ :param int $datestr: Date string
+ :returns: int UNIX timestamp or FALSE on failure
-Example:
+The opposite of the :php:func:`unix_to_time()` function. Takes a "human"
+time as input and returns it as a UNIX timestamp. This is useful if you
+accept "human" formatted dates submitted via a form. Returns boolean FALSE
+date string passed to it is not formatted as indicated above.
-::
+Example::
$now = time();
$human = unix_to_human($now);
@@ -227,22 +209,20 @@ Example:
nice_date()
===========
-This function can take a number poorly-formed date formats and convert
-them into something useful. It also accepts well-formed dates.
-
-The function will return a Unix timestamp by default. You can,
-optionally, pass a format string (the same type as the PHP date function
-accepts) as the second parameter.
+.. php:function:: nice_date($bad_date = '', $format = FALSE)
-.. php:method:: nice_date($bad_date = '', $format = FALSE)
+ :param int $bad_date: The terribly formatted date-like string
+ :param string $format: Date format to return (same as PHP's ``date()`` function)
+ :returns: string
- :param integer $bad_date: The terribly formatted date-like string
- :param string $format: Date format to return (same as php date function)
- :returns: string
+This function can take a number poorly-formed date formats and convert
+them into something useful. It also accepts well-formed dates.
-Example
+The function will return a UNIX timestamp by default. You can, optionally,
+pass a format string (the same type as the PHP ``date()`` function accepts)
+as the second parameter.
-::
+Example::
$bad_date = '199605';
// Should Produce: 1996-05-01
@@ -255,28 +235,28 @@ Example
timespan()
==========
-Formats a unix timestamp so that is appears similar to this
-::
+.. php:function:: timespan($seconds = 1, $time = '', $units = '')
- 1 Year, 10 Months, 2 Weeks, 5 Days, 10 Hours, 16 Minutes
+ :param int $seconds: Number of seconds
+ :param string $time: UNIX timestamp
+ :param int $units: Number of time units to display
+ :returns: string
-The first parameter must contain a Unix timestamp. The second parameter
-must contain a timestamp that is greater that the first timestamp. If
-the second parameter empty, the current time will be used. The third
-parameter is optional and limits the number of time units to display.
-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.
+Formats a UNIX timestamp so that is appears similar to this::
-.. php:method:: timespan($seconds = 1, $time = '', $units = '')
+ 1 Year, 10 Months, 2 Weeks, 5 Days, 10 Hours, 16 Minutes
- :param integer $seconds: a number of seconds
- :param string $time: Unix timestamp
- :param integer $units: a number of time units to display
- :returns: string
+The first parameter must contain a UNIX timestamp.
+The second parameter must contain a timestamp that is greater that the
+first timestamp.
+The thirdparameter is optional and limits the number of time units to display.
-Example
+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();
@@ -284,23 +264,21 @@ Example
echo timespan($post_date, $now, $units);
.. note:: The text generated by this function is found in the following language
- file: language/<your_lang>/date_lang.php
+ 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.
+.. php:function:: days_in_month($month = 0, $year = '')
-.. php:method:: days_in_month($month = 0, $year = '')
+ :param int $month: a numeric month
+ :param int $year: a numeric year
+ :returns: int
- :param integer $month: a numeric month
- :param integer $year: a numeric year
- :returns: integer
-
-Example
+Returns the number of days in a given month/year. Takes leap years into
+account.
-::
+Example::
echo days_in_month(06, 2005);
@@ -309,19 +287,17 @@ If the second parameter is empty, the current year will be used.
date_range()
============
-Returns a list of dates within a specified period.
-
-.. php:method:: date_range($unix_start = '', $mixed = '', $is_unix = TRUE, $format = 'Y-m-d')
+.. php:function:: date_range($unix_start = '', $mixed = '', $is_unix = TRUE, $format = 'Y-m-d')
- :param integer $unix_start: UNIX timestamp of the range start date
- :param integer $mixed: UNIX timestamp of the range end date or interval in days
- :param boolean $is_unix: set to FALSE if $mixed is not a timestamp
- :param string $format: output date format, same as in date()
- :returns: array
+ :param int $unix_start: UNIX timestamp of the range start date
+ :param int $mixed: UNIX timestamp of the range end date or interval in days
+ :param bool $is_unix: set to FALSE if $mixed is not a timestamp
+ :param string $format: Output date format, same as in ``date()``
+ :returns: array
-Example
+Returns a list of dates within a specified period.
-::
+Example::
$range = date_range('2012-01-01', '2012-01-15');
echo "First 15 days of 2012:";
@@ -333,29 +309,34 @@ Example
timezones()
===========
+.. php:function:: timezones($tz = '')
+
+ :param string $tz: a numeric timezone
+ :returns: string
+
Takes a timezone reference (for a list of valid timezones, see the
"Timezone Reference" below) and returns the number of hours offset from
UTC.
-.. php:method:: timezones($tz = '')
-
- :param string $tz: a numeric timezone
- :returns: string
-
-Example
-
-::
+Example::
echo timezones('UM5');
-This function is useful when used with `timezone_menu()`.
+This function is useful when used with :php:func:`timezone_menu()`.
timezone_menu()
===============
-Generates a pull-down menu of timezones, like this one:
+.. php:function:: timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '')
+ :param string $default: Timezone
+ :param string $class: Class name
+ :param string $name: Menu name
+ :param mixed $attributes: HTML attributes
+ :returns: string
+
+Generates a pull-down menu of timezones, like this one:
.. raw:: html
@@ -409,19 +390,7 @@ This menu is useful if you run a membership site in which your users are
allowed to set their local timezone value.
The first parameter lets you set the "selected" state of the menu. For
-example, to set Pacific time as the default you will do this
-
-.. php:method:: timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '')
-
- :param string $default: timezone
- :param string $class: classname
- :param string $name: menu name
- :param mixed $attributes: attributes
- :returns: string
-
-Example:
-
-::
+example, to set Pacific time as the default you will do this::
echo timezone_menu('UM8');
@@ -445,37 +414,37 @@ Note some of the location lists have been abridged for clarity and formatting.
=========== =====================================================================
Time Zone Location
=========== =====================================================================
-UM2 (UTC - 12:00) Baker/Howland Island
-UM1 (UTC - 11:00) Samoa Time Zone, Niue
-UM0 (UTC - 10:00) Hawaii-Aleutian Standard Time, Cook Islands
+UM2 (UTC - 12:00) Baker/Howland Island
+UM1 (UTC - 11:00) Samoa Time Zone, Niue
+UM0 (UTC - 10:00) Hawaii-Aleutian Standard Time, Cook Islands
UM95 (UTC - 09:30) Marquesas Islands
-UM9 (UTC - 09:00) Alaska Standard Time, Gambier Islands
-UM8 (UTC - 08:00) Pacific Standard Time, Clipperton Island
-UM7 (UTC - 11:00) Mountain Standard Time
-UM6 (UTC - 06:00) Central Standard Time
-UM5 (UTC - 05:00) Eastern Standard Time, Western Caribbean
+UM9 (UTC - 09:00) Alaska Standard Time, Gambier Islands
+UM8 (UTC - 08:00) Pacific Standard Time, Clipperton Island
+UM7 (UTC - 11:00) Mountain Standard Time
+UM6 (UTC - 06:00) Central Standard Time
+UM5 (UTC - 05:00) Eastern Standard Time, Western Caribbean
UM45 (UTC - 04:30) Venezuelan Standard Time
-UM4 (UTC - 04:00) Atlantic Standard Time, Eastern Caribbean
+UM4 (UTC - 04:00) Atlantic Standard Time, Eastern Caribbean
UM35 (UTC - 03:30) Newfoundland Standard Time
-UM3 (UTC - 03:00) Argentina, Brazil, French Guiana, Uruguay
-UM2 (UTC - 02:00) South Georgia/South Sandwich Islands
-UM (UTC -1:00) Azores, Cape Verde Islands
-UTC (UTC) Greenwich Mean Time, Western European Time
-UP1 (UTC +1:00) Central European Time, West Africa Time
-UP2 (UTC +2:00) Central Africa Time, Eastern European Time
-UP3 (UTC +3:00) Moscow Time, East Africa Time
+UM3 (UTC - 03:00) Argentina, Brazil, French Guiana, Uruguay
+UM2 (UTC - 02:00) South Georgia/South Sandwich Islands
+UM (UTC -1:00) Azores, Cape Verde Islands
+UTC (UTC) Greenwich Mean Time, Western European Time
+UP1 (UTC +1:00) Central European Time, West Africa Time
+UP2 (UTC +2:00) Central Africa Time, Eastern European Time
+UP3 (UTC +3:00) Moscow Time, East Africa Time
UP35 (UTC +3:30) Iran Standard Time
-UP4 (UTC +4:00) Azerbaijan Standard Time, Samara Time
+UP4 (UTC +4:00) Azerbaijan Standard Time, Samara Time
UP45 (UTC +4:30) Afghanistan
-UP5 (UTC +5:00) Pakistan Standard Time, Yekaterinburg Time
+UP5 (UTC +5:00) Pakistan Standard Time, Yekaterinburg Time
UP55 (UTC +5:30) Indian Standard Time, Sri Lanka Time
UP575 (UTC +5:45) Nepal Time
-UP6 (UTC +6:00) Bangladesh Standard Time, Bhutan Time, Omsk Time
+UP6 (UTC +6:00) Bangladesh Standard Time, Bhutan Time, Omsk Time
UP65 (UTC +6:30) Cocos Islands, Myanmar
-UP7 (UTC +7:00) Krasnoyarsk Time, Cambodia, Laos, Thailand, Vietnam
-UP8 (UTC +8:00) Australian Western Standard Time, Beijing Time
+UP7 (UTC +7:00) Krasnoyarsk Time, Cambodia, Laos, Thailand, Vietnam
+UP8 (UTC +8:00) Australian Western Standard Time, Beijing Time
UP875 (UTC +8:45) Australian Central Western Standard Time
-UP9 (UTC +9:00) Japan Standard Time, Korea Standard Time, Yakutsk
+UP9 (UTC +9:00) Japan Standard Time, Korea Standard Time, Yakutsk
UP95 (UTC +9:30) Australian Central Standard Time
UP10 (UTC +10:00) Australian Eastern Standard Time, Vladivostok Time
UP105 (UTC +10:30) Lord Howe Island
@@ -483,6 +452,6 @@ UP11 (UTC +11:00) Magadan Time, Solomon Islands, Vanuatu
UP115 (UTC +11:30) Norfolk Island
UP12 (UTC +12:00) Fiji, Gilbert Islands, Kamchatka, New Zealand
UP1275 (UTC +12:45) Chatham Islands Standard Time
-UP1 (UTC +13:00) Phoenix Islands Time, Tonga
+UP1 (UTC +13:00) Phoenix Islands Time, Tonga
UP14 (UTC +14:00) Line Islands
=========== ===================================================================== \ No newline at end of file
diff --git a/user_guide_src/source/helpers/directory_helper.rst b/user_guide_src/source/helpers/directory_helper.rst
index cf88732d3..a785ebc8c 100644
--- a/user_guide_src/source/helpers/directory_helper.rst
+++ b/user_guide_src/source/helpers/directory_helper.rst
@@ -57,7 +57,7 @@ be numerically indexed. Here is an example of a typical array::
(        
[0] => benchmark.html        
[1] => config.html        
- [database] => Array
+ ["database/"] => Array
(              
[0] => query_builder.html              
[1] => binds.html              
@@ -76,5 +76,4 @@ be numerically indexed. Here is an example of a typical array::
[7] => loader.html        
[8] => pagination.html        
[9] => uri.html
- )
-
+ ) \ No newline at end of file
diff --git a/user_guide_src/source/helpers/download_helper.rst b/user_guide_src/source/helpers/download_helper.rst
index e6094dc6b..1e9ec21ea 100644
--- a/user_guide_src/source/helpers/download_helper.rst
+++ b/user_guide_src/source/helpers/download_helper.rst
@@ -9,34 +9,40 @@ The Download Helper lets you download data to your desktop.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('download');
The following functions are available:
-force_download('filename', 'data')
-==================================
+force_download()
+================
+
+.. php:function:: force_download($filename = '', $data = '', $set_mime = FALSE)
+
+ :param string $filename: Filename
+ :param string $data: File contents
+ :param bool $set_mime: Whether to try to send the actual MIME type
+ :returns: void
Generates server headers which force data to be downloaded to your
desktop. Useful with file downloads. The first parameter is the **name
you want the downloaded file to be named**, the second parameter is the
-file data. Example
+file data.
+
+If you set the third parameter to boolean TRUE, then the actual file MIME type
+(based on the filename extension) will be sent, so that if your browser has a
+handler for that type - it can use it.
-::
+Example::
$data = 'Here is some text!';
$name = 'mytext.txt';
force_download($name, $data);
If you want to download an existing file from your server you'll need to
-read the file into a string
+read the file into a string::
-::
-
- $data = file_get_contents("/path/to/photo.jpg"); // Read the file's contents
+ $data = file_get_contents('/path/to/photo.jpg'); // Read the file's contents
$name = 'myphoto.jpg';
- force_download($name, $data);
-
+ force_download($name, $data); \ No newline at end of file
diff --git a/user_guide_src/source/helpers/email_helper.rst b/user_guide_src/source/helpers/email_helper.rst
index d4e94b1ed..10adf1d0e 100644
--- a/user_guide_src/source/helpers/email_helper.rst
+++ b/user_guide_src/source/helpers/email_helper.rst
@@ -8,6 +8,8 @@ Class <../libraries/email>`.
.. contents:: Page Contents
+.. important:: The Email helper is DEPRECATED.
+
Loading this Helper
===================
@@ -15,21 +17,21 @@ This helper is loaded using the following code::
$this->load->helper('email');
-
The following functions are available:
-valid_email('email')
-====================
+valid_email()
+=============
-Checks if an email is a correctly formatted email. Note that is doesn't
-actually prove the email will recieve mail, simply that it is a validly
-formed address.
+.. php:function:: valid_email($email)
-It returns TRUE/FALSE
+ :param string $email: Email address
+ :returns: bool
-::
+Checks if the input is a correctly formatted e-mail address. Note that is
+doesn't actually prove that the address will be able recieve mail, but
+simply that it is a validly formed address.
- $this->load->helper('email');
+Example::
if (valid_email('email@somesite.com'))
{
@@ -40,10 +42,26 @@ It returns TRUE/FALSE
echo 'email is not valid';
}
-send_email('recipient', 'subject', 'message')
-=============================================
+.. note:: All that this function does is to use PHP's native ``filter_var()``:
+ |
+ | (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
-Sends an email using PHP's native
-`mail() <http://www.php.net/function.mail>`_ function. For a more robust
-email solution, see CodeIgniter's :doc:`Email
-Class <../libraries/email>`.
+send_email()
+============
+
+.. php:function:: send_email($recipient, $subject, $message)
+
+ :param string $recipient: E-mail address
+ :param string $subject: Mail subject
+ :param string $message: Message body
+ :returns: bool
+
+Sends an email using PHP's native `mail() <http://www.php.net/function.mail>`_
+function.
+
+.. note:: All that this function does is to use PHP's native ``mail``:
+ |
+ | mail($recipient, $subject, $message);
+
+For a more robust email solution, see CodeIgniter's :doc:`Email Library
+<../libraries/email>`.
diff --git a/user_guide_src/source/helpers/file_helper.rst b/user_guide_src/source/helpers/file_helper.rst
index 60c5aa98c..194d4348f 100644
--- a/user_guide_src/source/helpers/file_helper.rst
+++ b/user_guide_src/source/helpers/file_helper.rst
@@ -9,20 +9,23 @@ The File Helper file contains functions that assist in working with files.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('file');
The following functions are available:
-read_file('path')
-=================
+read_file()
+===========
-Returns the data contained in the file specified in the path. Example
+.. php:function:: read_file($file)
-::
+ :param string $file: File path
+ :returns: string or FALSE on failure
+
+Returns the data contained in the file specified in the path.
+
+Example::
$string = read_file('./path/to/file.php');
@@ -35,14 +38,24 @@ The path can be a relative or full server path. Returns FALSE (boolean) on failu
.. note:: This function is DEPRECATED. Use the native ``file_get_contents()``
instead.
-If your server is running an `open_basedir` restriction this function might not work if you are trying to access a file above the calling script.
+.. important:: If your 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)
-=========================
+write_file()
+============
-Writes data to the file specified in the path. If the file does not exist the function will create it. Example
+.. php:function:: write_file($path, $data, $mode = 'wb')
-::
+ :param string $path: File path
+ :param string $data: Data to write to file
+ :param string $mode: ``fopen()`` mode
+ :returns: bool
+
+Writes data to the file specified in the path. If the file does not exist then the
+function will create it.
+
+Example::
$data = 'Some file data';
if ( ! write_file('./path/to/file.php', $data))
@@ -54,85 +67,150 @@ Writes data to the file specified in the path. If the file does not exist the fu
echo 'File written!';
}
-You can optionally set the write mode via the third parameter
-
-::
+You can optionally set the write mode via the third parameter::
write_file('./path/to/file.php', $data, 'r+');
-The default mode is wb. Please see the `PHP user guide <http://php.net/fopen>`_ for mode options.
+The default mode is 'wb'. Please see the `PHP user guide <http://php.net/fopen>`_
+for mode options.
-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: In order for this function to write data to a file, its 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. CodeIgniter uses a front controller so paths
are always relative to the main site index.
-delete_files('path')
-====================
+.. note:: This function acquires an exclusive lock on the file while writing to it.
-Deletes ALL files contained in the supplied path. Example
+delete_files()
+==============
-::
+.. php:function:: delete_files($path, $del_dir = FALSE, $htdocs = FALSE)
+
+ :param string $path: Directory path
+ :param bool $del_dir: Whether to also delete directories
+ :param bool $htdocs: Whether to skip deleting .htaccess and index page files
+ :returns: bool
+
+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
+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.
-get_filenames('path/to/directory/')
-===================================
+get_filenames()
+===============
+
+.. php:function:: get_filenames($source_dir, $include_path = FALSE)
+
+ :param string $source_dir: Directory path
+ :param bool $include_path: Whether to include the path as part of the filenames
+ :returns: array
-Takes a server path as input and returns an array containing the names of all files contained within it. The file path can optionally be added to the file names by setting the second parameter to TRUE.
+Takes a server path as input and returns an array containing the names of all files
+contained within it. The file path can optionally be added to the file names by setting
+the second parameter to TRUE.
-get_dir_file_info('path/to/directory/', $top_level_only = TRUE)
-===============================================================
+Example::
-Reads the specified directory and builds an array containing the filenames, filesize, dates, and permissions. Sub-folders contained within the specified path are only read if forced by sending the second parameter, $top_level_only to FALSE, as this can be an intensive operation.
+ $controllers = get_filenames(APPPATH.'controllers/');
-get_file_info('path/to/file', $file_information)
-================================================
+get_dir_file_info()
+===================
+
+.. php:function:: get_dir_file_info($source_dir, $top_level_only)
+
+ :param string $source_dir: Directory path
+ :param bool $top_level_only: Whether to look only at the specified directory
+ (excluding sub-directories)
+ :returns: array
+
+Reads the specified directory and builds an array containing the filenames, filesize,
+dates, and permissions. Sub-folders contained within the specified path are only read
+if forced by sending the second parameter to FALSE, as this can be an intensive
+operation.
+
+Example::
+
+ $models_info = get_dir_file_info(APPPATH.'models/');
+
+get_file_info()
+===============
+
+.. php:function: get_file_info($file, $returned_values = array('name', 'server_path', 'size', 'date'))
+
+ :param string $file: File path
+ :param array $returned_values: What type of info to return
+ :returns: array or FALSE on failure
-Given a file and path, returns the name, path, size, date modified. Second parameter allows you to explicitly declare what information you want returned; options are: `name`, `server_path`, `size`, `date`, `readable`, `writable`, `executable`, `fileperms`. Returns FALSE if the file cannot be found.
+Given a file and path, returns (optionally) the *name*, *path*, *size* and *date modified*
+information attributes for a file. Second parameter allows you to explicitly declare what
+information you want returned.
-.. note:: The "writable" uses the PHP function is_writable() which is known
- to have issues on the IIS webserver. Consider using fileperms instead,
- which returns information from PHP's fileperms() function.
+Valid ``$returned_values`` options are: `name`, `size`, `date`, `readable`, `writeable`,
+`executable` and `fileperms`.
-get_mime_by_extension('file')
-=============================
+.. note:: The *writable* attribute is checked via PHP's ``is_writeable()`` function, which
+ known to have issues on the IIS webserver. Consider using *fileperms* instead,
+ which returns information from PHP's ``fileperms()`` function.
-Translates a file extension into a mime type based on config/mimes.php. Returns FALSE if it can't determine the type, or open the mime config file.
+get_mime_by_extension()
+=======================
+
+.. php:function:: get_mime_by_extension($filename)
+
+ :param string $filename: File name
+ :returns: string or FALSE on failure
+
+Translates a filename extension into a MIME type based on *config/mimes.php*.
+Returns FALSE if it can't determine the type, or read the MIME config file.
::
- $file = "somefile.png";
- echo $file . ' is has a mime type of ' . get_mime_by_extension($file);
+ $file = 'somefile.png';
+ echo $file.' is has a mime type of '.get_mime_by_extension($file);
+
+.. note:: This is not an accurate way of determining file MIME types, and
+ is here strictly for convenience. It should not be used for security
+ purposes.
+symbolic_permissions()
+======================
-.. note:: This is not an accurate way of determining file mime types, and
- is here strictly as a convenience. It should not be used for security.
+.. php:function:: symbolic_permissions($perms)
-symbolic_permissions($perms)
-============================
+ :param int $perms: Permissions
+ :returns: string
-Takes numeric permissions (such as is returned by `fileperms()` and returns standard symbolic notation of file permissions.
+Takes numeric permissions (such as is returned by ``fileperms()``) and returns
+standard symbolic notation of file permissions.
::
echo symbolic_permissions(fileperms('./index.php')); // -rw-r--r--
-octal_permissions($perms)
-=========================
+octal_permissions()
+===================
-Takes numeric permissions (such as is returned by fileperms() and returns a three character octal notation of file permissions.
+.. php:function:: octal_permissions($perms)
-::
+ :param int $perms: Permissions
+ :returns: string
- echo octal_permissions(fileperms('./index.php')); // 644
+Takes numeric permissions (such as is returned by ``fileperms()``) and returns
+a three character octal notation of file permissions.
+
+::
+ echo octal_permissions(fileperms('./index.php')); // 644 \ No newline at end of file
diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst
index 015bf1162..b2a9b6f0f 100644
--- a/user_guide_src/source/helpers/form_helper.rst
+++ b/user_guide_src/source/helpers/form_helper.rst
@@ -10,9 +10,7 @@ forms.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('form');
@@ -21,19 +19,27 @@ 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, and will always add the attribute accept-charset based on the charset value in your config file.
+.. php:function:: form_open($action = '', $attributes = '', $hidden = array())
-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.
+ :param string $action: Form action/target URI string
+ :param string $attributes: HTML attributes
+ :param array $hidden: An array of hidden fields' definitions
+ :returns: string
-Here's a simple example
+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, and
+will always add the `accept-charset` attribute based on the charset value in your
+config file.
-::
+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.
- echo form_open('email/send');
+Here's a simple example::
-The above example would create a form that points to your base URL plus the "email/send" URI segments, like this
+ 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" accept-charset="utf-8" action="http://example.com/index.php/email/send" />
@@ -41,32 +47,25 @@ Adding Attributes
^^^^^^^^^^^^^^^^^
Attributes can be added by passing an associative array to the second
-parameter, like this
-
-::
+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
-
-::
+The above example would create a form similar to this::
<form method="post" accept-charset="utf-8" action="http://example.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 fields can be added by passing an associative array to the
+third parameter, like this::
-::
-
- $hidden = array('username' => 'Joe', 'member_id' => '234');
+ $hidden = array('username' => 'Joe', 'member_id' => '234');
echo form_open('email/send', '', $hidden);
-The above example would create a form similar to this
-
-::
+The above example would create a form similar to this::
<form method="post" accept-charset="utf-8" action="http://example.com/index.php/email/send">
<input type="hidden" name="username" value="Joe" />
@@ -75,29 +74,38 @@ The above example would create a form similar to this
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
+.. php:function:: form_open_multipart($action = '', $attributes = array(), $hidden = array())
+
+ :param string $action: Form action/target URI string
+ :param string $attributes: HTML attributes
+ :param array $hidden: An array of hidden fields' definitions
+ :returns: string
+
+This function is absolutely identical to :php:func:`form_open()` 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
+.. php:function:: form_hidden($name, $value = '')
-::
+ :param string $name: Field name
+ :param string $value: Field value
+ :returns: string
+
+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="johndoe" />
-Or you can submit an associative array to create multiple fields
-
-::
+... or you can submit an associative array to create multiple fields::
$data = array(
- 'name'  => 'John Doe',
- 'email' => 'john@example.com',
- 'url'   => 'http://example.com'
+ 'name' => 'John Doe',
+ 'email' => 'john@example.com',
+ 'url' => 'http://example.com'
);
echo form_hidden($data);
@@ -109,35 +117,32 @@ Or you can submit an associative array to create multiple fields
<input type="hidden" name="url" value="http://example.com" />
*/
-Or pass an associative array to the value field.
-
-::
+You can also pass an associative array to the value field::
$data = array(
- 'name'  => 'John Doe',
- 'email' => 'john@example.com',
- 'url'   => 'http://example.com'
+ 'name' => 'John Doe',
+ 'email' => 'john@example.com',
+ 'url' => 'http://example.com'
);
echo form_hidden('my_array', $data);
/*
Would produce:
+
<input type="hidden" name="my_array[name]" value="John Doe" />
<input type="hidden" name="my_array[email]" value="john@example.com" />
<input type="hidden" name="my_array[url]" value="http://example.com" />
*/
-If you want to create hidden input fields with extra attributes
-
-::
+If you want to create hidden input fields with extra attributes::
$data = array(
- 'type'        => 'hidden',
- 'name'        => 'email',
- 'id'          => 'hiddenemail',
- 'value'       => 'john@example.com',
- 'class'       => 'hiddenemail'
+ 'type' => 'hidden',
+ 'name' => 'email',
+ 'id' => 'hiddenemail',
+ 'value' => 'john@example.com',
+ 'class' => 'hiddenemail'
);
echo form_input($data);
@@ -151,25 +156,28 @@ If you want to create hidden input fields with extra attributes
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
+.. php:function:: form_input($data = '', $value = '', $extra = '')
-::
+ :param array $data: Field attributes data
+ :param string $value: Field value
+ :param string $extra: Extra attributes to be added to the tag *as is*
+ :returns: string
+
+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
-
-::
+form to contain::
$data = array(
- 'name'        => 'username',
- 'id'          => 'username',
- 'value'       => 'johndoe',
- 'maxlength'   => '100',
- 'size'        => '50',
- 'style'       => 'width:50%'
+ 'name' => 'username',
+ 'id' => 'username',
+ 'value' => 'johndoe',
+ 'maxlength' => '100',
+ 'size' => '50',
+ 'style' => 'width:50%'
);
echo form_input($data);
@@ -181,9 +189,7 @@ form to contain
*/
If you would like your form to contain some additional data, like
-Javascript, you can pass it as a string in the third parameter
-
-::
+JavaScript, you can pass it as a string in the third parameter::
$js = 'onClick="some_function()"';
echo form_input('username', 'johndoe', $js);
@@ -191,34 +197,70 @@ Javascript, you can pass it as a string in the third parameter
form_password()
===============
-This function is identical in all respects to the `form_input()` function above except that it uses the "password" input type.
+.. php:function:: form_password($data = '', $value = '', $extra = '')
+
+ :param array $data: Field attributes data
+ :param string $value: Field value
+ :param string $extra: Extra attributes to be added to the tag *as is*
+ :returns: string
+
+This function is identical in all respects to the :php:func:`form_input()`
+function above except that it uses the "password" input type.
form_upload()
=============
-This function is identical in all respects to the `form_input()` function above except that it uses the "file" input type, allowing it to be used to upload files.
+.. php:function:: form_upload($data = '', $value = '', $extra = '')
+
+ :param array $data: Field attributes data
+ :param string $value: Field value
+ :param string $extra: Extra attributes to be added to the tag *as is*
+ :returns: string
+
+This function is identical in all respects to the :php:func:`form_input()`
+function above except that it uses the "file" input 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".
+.. php:function:: form_textarea($data = '', $value = '', $extra = '')
+
+ :param array $data: Field attributes data
+ :param string $value: Field value
+ :param string $extra: Extra attributes to be added to the tag *as is*
+ :returns: string
+
+This function is identical in all respects to the :php:func:`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()
===============
+.. php:function:: form_dropdown($name = '', $options = array(), $selected = array(), $extra = '')
+
+ :param string $name: Field name
+ :param array $options: An associative array of options to be listed
+ :param array $selected: List of fields to mark with the *selected* attribute
+ :param string $extra: Extra attributes to be added to the tag *as is*
+ :returns: string
+
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. You can also pass an array of multiple
items through the third parameter, and CodeIgniter will create a
-multiple select for you. Example
+multiple select for you.
-::
+Example::
$options = array(
- 'small'  => 'Small Shirt',
- 'med'    => 'Medium Shirt',
- 'large'   => 'Large Shirt',
+ 'small' => 'Small Shirt',
+ 'med' => 'Medium Shirt',
+ 'large' => 'Large Shirt',
'xlarge' => 'Extra Large Shirt',
);
@@ -251,33 +293,47 @@ multiple select for you. Example
If you would like the opening <select> to contain additional data, like
an id attribute or JavaScript, you can pass it as a string in the fourth
-parameter
-
-::
+parameter::
$js = 'id="shirts" onChange="some_function();"';
echo form_dropdown('shirts', $options, 'large', $js);
-If the array passed as $options is a multidimensional array,
-`form_dropdown()` will produce an <optgroup> with the array key as the
+If the array passed as ``$options`` is a multidimensional array, then
+``form_dropdown()`` will produce an <optgroup> with the array key as the
label.
form_multiselect()
==================
+.. php:function:: form_multiselect($name = '', $options = array(), $selected = array(), $extra = '')
+
+ :param string $name: Field name
+ :param array $options: An associative array of options to be listed
+ :param array $selected: List of fields to mark with the *selected* attribute
+ :param string $extra: Extra attributes to be added to the tag *as is*
+ :returns: string
+
Lets you create a standard multiselect 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 or values you wish to be selected. The parameter usage is
-identical to using form_dropdown() above, except of course that the
-name of the field will need to use POST array syntax, e.g. foo[].
+value or values you wish to be selected.
+
+The parameter usage is identical to using :php:func:`form_dropdown()` above,
+except of course that the name of the field will need to use POST array
+syntax, e.g. foo[].
form_fieldset()
-================
+===============
+
+.. php:function:: form_fieldset($legend_text = '', $attributes = array())
+
+ :param string $legend_text: Text to put in the <legend> tag
+ :param array $attributes: Attributes to be set on the <fieldset> tag
+ :returns: string
Lets you generate fieldset/legend fields.
-::
+Example::
echo form_fieldset('Address Information');
echo "<p>fieldset content here</p>\n";
@@ -285,6 +341,7 @@ Lets you generate fieldset/legend fields.
/*
Produces:
+
<fieldset>
<legend>Address Information</legend>
<p>form content here</p>
@@ -292,13 +349,11 @@ Lets you generate fieldset/legend fields.
*/
Similar to other functions, you can submit an associative array in the
-second parameter if you prefer to set additional attributes.
-
-::
+second parameter if you prefer to set additional attributes::
$attributes = array(
- 'id' => 'address_info',
- 'class' => 'address_info'
+ 'id' => 'address_info',
+ 'class' => 'address_info'
);
echo form_fieldset('Address Information', $attributes);
@@ -317,22 +372,33 @@ second parameter if you prefer to set additional attributes.
form_fieldset_close()
=====================
+.. php:function:: form_fieldset_close($extra = '')
+
+ :param string $extra: Anything to append after the closing tag, *as is*
+ :returns: string
+
Produces a closing </fieldset> 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>";
+ $string = '</div></div>';
echo form_fieldset_close($string);
// Would produce: </fieldset></div></div>
form_checkbox()
===============
-Lets you generate a checkbox field. Simple example
+.. php:function:: form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '')
-::
+ :param array $data: Field attributes data
+ :param string $value: Field value
+ :param bool $checked: Whether to mark the checkbox as being *checked*
+ :param string $extra: Extra attributes to be added to the tag *as is*
+ :returns: string
+
+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" />
@@ -346,21 +412,19 @@ array of attributes to the function
::
$data = array(
- 'name'        => 'newsletter',
- 'id'          => 'newsletter',
- 'value'       => 'accept',
- 'checked'     => TRUE,
- 'style'       => 'margin:10px',
+ '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
-
-::
+Also 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 form_checkbox('newsletter', 'accept', TRUE, $js)
@@ -368,29 +432,28 @@ parameter
form_radio()
============
-This function is identical in all respects to the `form_checkbox()`
-function above except that it uses the "radio" input type.
-
-form_submit()
-=============
+.. php:function:: form_radio($data = '', $value = '', $checked = FALSE, $extra = '')
-Lets you generate a standard submit button. Simple example
+ :param array $data: Field attributes data
+ :param string $value: Field value
+ :param bool $checked: Whether to mark the radio button as being *checked*
+ :param string $extra: Extra attributes to be added to the tag *as is*
+ :returns: string
-::
-
- 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.
+This function is identical in all respects to the :php:func:`form_checkbox()`
+function above except that it uses the "radio" input type.
form_label()
============
-Lets you generate a <label>. Simple example
+.. php:function:: form_label($label_text = '', $id = '', $attributes = array())
-::
+ :param string $label_text: Text to put in the <label> tag
+ :param string $id: ID of the form element that we're making a label for
+ :param string $attributes: HTML attributes
+ :returns: string
+
+Lets you generate a <label>. Simple example::
echo form_label('What is your Name', 'username');
// Would produce: <label for="username">What is your Name</label>
@@ -398,7 +461,7 @@ Lets you generate a <label>. Simple example
Similar to other functions, you can submit an associative array in the
third parameter if you prefer to set additional attributes.
-::
+Example::
$attributes = array(
'class' => 'mycustomclass',
@@ -408,87 +471,156 @@ third parameter if you prefer to set additional attributes.
echo form_label('What is your Name', 'username', $attributes);
// Would produce: <label for="username" class="mycustomclass" style="color: #000;">What is your Name</label>
+form_submit()
+=============
+
+.. php:function:: form_submit($data = '', $value = '', $extra = '')
+
+ :param string $data: Button name
+ :param string $value: Button value
+ :param string $extra: Extra attributes to be added to the tag *as is*
+ :returns: string
+
+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_reset()
============
+.. php:function:: form_reset($data = '', $value = '', $extra = '')
+
+ :param string $data: Button name
+ :param string $value: Button value
+ :param string $extra: Extra attributes to be added to the tag *as is*
+ :returns: string
+
Lets you generate a standard reset button. Use is identical to
-`form_submit()`.
+:php:func:`form_submit()`.
form_button()
=============
-Lets you generate a standard button element. You can minimally pass the
-button name and content in the first and second parameter
+.. php:function:: form_button($data = '', $content = '', $extra = '')
-::
+ :param string $data: Button name
+ :param string $content: Button label
+ :param string $extra: Extra attributes to be added to the tag *as is*
+ :returns: string
- echo form_button('name','content');
- // Would produce <button name="name" type="button">Content</button>
+Lets you generate a standard button element. You can minimally pass the
+button name and content in the first and second parameter::
-Or you can pass an associative array containing any data you wish your
-form to contain:
+ echo form_button('name','content');
+ // Would produce: <button name="name" type="button">Content</button>
-::
+Or you can pass an associative array containing any data you wish your
+form to contain::
$data = array(
- 'name' => 'button',
- 'id' => 'button',
- 'value' => 'true',
- 'type' => 'reset',
- 'content' => 'Reset'
+ 'name' => 'button',
+ 'id' => 'button',
+ 'value' => 'true',
+ 'type' => 'reset',
+ 'content' => 'Reset'
);
echo form_button($data);
// Would produce: <button name="button" id="button" value="true" type="reset">Reset</button>
If you would like your form to contain some additional data, like
-JavaScript, you can pass it as a string in the third parameter:
-
-::
+JavaScript, you can pass it as a string in the third parameter::
- $js = 'onClick="some_function()"';
+ $js = 'onClick="some_function()"';
echo form_button('mybutton', 'Click Me', $js);
form_close()
============
+.. php:function:: form_close($extra = '')
+
+ :param string $extra: Anything to append after the closing tag, *as is*
+ :returns: string
+
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
+the tag. For example::
-::
-
- $string = "</div></div>";
+ $string = '</div></div>';
echo form_close($string);
// Would produce: </form> </div></div>
+form_prep()
+===========
+
+.. php:function:: form_prep($str = '', $is_textarea = FALSE)
+
+ :param string $str: Value to escape
+ :param bool $is_textarea: Whether we're preparing for <textarea> or a regular input tag
+ :returns: string
+
+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.
+
set_value()
===========
+.. php:function:: set_value($field = '', $default = '', $is_textarea = FALSE)
+
+ :param string $field: Field name
+ :param string $default: Default value
+ :param bool $is_textarea: Whether we're setting <textarea> content
+ :returns: string
+
Permits you to set the value of an input form or textarea. You must
supply the field name via the first parameter of the function. The
second (optional) parameter allows you to set a default value for the
-form. Example
+form.
-::
+Example::
- <input type="text" name="quantity" value="<?php echo set_value('quantity', '0'); ?>" size="50" />
+ <input type="text" name="quantity" value="<?=set_value('quantity', '0');?>" size="50" />
The above form will show "0" when loaded for the first time.
set_select()
============
+.. php:function:: set_select($field = '', $value = '', $default = FALSE)
+
+ :param string $field: Field name
+ :param string $value: Value to check for
+ :param string $default: Whether the value is also a default one
+ :returns: string
+
If you use a <select> menu, this function permits you to display the
-menu item that was selected. The first parameter must contain the name
-of the select menu, the second parameter must contain the value of each
-item, and the third (optional) parameter lets you set an item as the
-default (use boolean TRUE/FALSE).
+menu item that was selected.
-Example
+The first parameter must contain the name of the select menu, the second
+parameter must contain the value of each item, and the third (optional)
+parameter lets you set an item as the default (use boolean TRUE/FALSE).
-::
+Example::
<select name="myselect">
<option value="one" <?php echo set_select('myselect', 'one', TRUE); ?> >One</option>
@@ -499,12 +631,20 @@ Example
set_checkbox()
==============
-Permits you to display a checkbox in the state it was submitted. The
-first parameter must contain the name of the checkbox, the second
+.. php:function:: set_checkbox($field = '', $value = '', $default = FALSE)
+
+ :param string $field: Field name
+ :param string $value: Value to check for
+ :param string $default: Whether the value is also a default one
+ :returns: string
+
+Permits you to display a checkbox in the state it was submitted.
+
+The first parameter must contain the name of the checkbox, the second
parameter must contain its value, and the third (optional) parameter
-lets you set an item as the default (use boolean TRUE/FALSE). Example
+lets you set an item as the default (use boolean TRUE/FALSE).
-::
+Example::
<input type="checkbox" name="mycheck" value="1" <?php echo set_checkbox('mycheck', '1'); ?> />
<input type="checkbox" name="mycheck" value="2" <?php echo set_checkbox('mycheck', '2'); ?> />
@@ -512,37 +652,71 @@ lets you set an item as the default (use boolean TRUE/FALSE). Example
set_radio()
===========
+.. php:function:: set_radio($field = '', $value = '', $default = FALSE)
+
+ :param string $field: Field name
+ :param string $value: Value to check for
+ :param string $default: Whether the value is also a default one
+ :returns: string
+
Permits you to display radio buttons in the state they were submitted.
-This function is identical to the **set_checkbox()** function above.
+This function is identical to the :php:func:`set_checkbox()` function above.
-::
+Example::
<input type="radio" name="myradio" value="1" <?php echo set_radio('myradio', '1', TRUE); ?> />
<input type="radio" name="myradio" value="2" <?php echo set_radio('myradio', '2'); ?> />
-.. note:: If you are using the Form Validation class, you must always specify a rule for your field,
- even if empty, in order for the set_*() functions to work. This is because if a Form Validation object
- is defined, the control for set_*() is handed over to a method of the class instead of the generic helper
- function.
+.. note:: If you are using the Form Validation class, you must always specify
+ a rule for your field, even if empty, in order for the ``set_*()``
+ functions to work. This is because if a Form Validation object is
+ defined, the control for ``set_*()`` is handed over to a method of the
+ class instead of the generic helper function.
-Escaping field values
-=====================
+form_error()
+============
-You may need to use HTML and characters such as quotes within form
-elements. In order to do that safely, you'll need to use
-:doc:`common function <../general/common_functions>` ``html_escape()``.
+.. php:function:: form_error($field = '', $prefix = '', $suffix = '')
-Consider the following example::
+ :param string $field: Field name
+ :param string $prefix: Error opening tag
+ :param string $suffix: Error closing tag
+ :returns: string
- $string = 'Here is a string containing "quoted" text.';
- <input type="text" name="myform" value="$string" />
+Returns a validation error message from the :doc:`Form Validation Library
+<../libraries/form_validation>`, associated with the specified field name.
+You can optionally specify opening and closing tag(s) to put around the error
+message.
-Since the above string contains a set of quotes it will cause the form
-to break. The ``html_escape()`` function converts HTML so that it can be
-used safely::
+Example::
- <input type="text" name="myform" value="<?php echo html_escape($string); ?>" />
+ // Assuming that the 'username' field value was incorrect:
+ echo form_error('myfield', '<div class="error">', '</div>');
-.. 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
+ // Would produce: <div class="error">Error message associated with the "username" field.</div>
+
+validation_errors()
+===================
+
+.. php:function:: validation_errors($prefix = '', $suffix = '')
+
+ :param string $prefix: Error opening tag
+ :param string $suffix: Error closing tag
+ :returns: string
+
+Similarly to the :php:func:`form_error()` function, returns all validation
+error messages produced by the :doc:`Form Validation Library
+<../libraries/form_validation>`, with optional opening and closing tags
+around each of the messages.
+
+Example::
+
+ echo validation_errors('<span class="error">', '</span>');
+
+ /*
+ Would produce, e.g.:
+
+ <span class="error">The "email" field doesn't contain a valid e-mail address!</span>
+ <span class="error">The "password" field doesn't match the "repeat_password" field!</span>
+
+ */ \ No newline at end of file
diff --git a/user_guide_src/source/helpers/html_helper.rst b/user_guide_src/source/helpers/html_helper.rst
index 17c28cd2a..df53ebd2f 100644
--- a/user_guide_src/source/helpers/html_helper.rst
+++ b/user_guide_src/source/helpers/html_helper.rst
@@ -19,6 +19,11 @@ The following functions are available:
br()
====
+.. php:function:: br($count = 1)
+
+ :param int $count: Number of times to repeat the tag
+ :returns: string
+
Generates line break tags (<br />) based on the number you submit.
Example::
@@ -29,7 +34,14 @@ The above would produce: <br /><br /><br />
heading()
=========
-Lets you create HTML <h1> tags. The first parameter will contain the
+.. php:function:: heading($data = '', $h = '1', $attributes = '')
+
+ :param string $data: Content
+ :param string $h: Heading level
+ :param array $attributes: HTML attributes
+ :returns: string
+
+Lets you create HTML heading tags. The first parameter will contain the
data, the second the size of the heading. Example::
echo heading('Welcome!', 3);
@@ -37,9 +49,7 @@ data, the second the size of the heading. Example::
The above would produce: <h3>Welcome!</h3>
Additionally, in order to add attributes to the heading tag such as HTML
-classes, ids or inline styles, a third parameter is available.
-
-::
+classes, ids or inline styles, a third parameter is available::
echo heading('Welcome!', 3, 'class="pink"')
@@ -48,28 +58,31 @@ The above code produces: <h3 class="pink">Welcome!<<h3>
img()
=====
-Lets you create HTML <img /> tags. The first parameter contains the
-image source. Example
+.. php:function:: img($src = '', $index_page = FALSE, $attributes = '')
-::
+ :param string $src: Image source data
+ :param bool $index_page: Whether to treat $src as a routed URI string
+ :param array $attributes: HTML attributes
+ :returns: string
+
+Lets you create HTML <img /> tags. The first parameter contains the
+image source. Example::
echo img('images/picture.jpg'); // gives <img src="http://site.com/images/picture.jpg" />
There is an optional second parameter that is a TRUE/FALSE value that
-specifics if the src should have the page specified by
-$config['index_page'] added to the address it creates. Presumably, this
-would be if you were using a media controller.
-
-::
+specifics if the *src* should have the page specified by
+``$config['index_page']`` added to the address it creates.
+Presumably, this would be if you were using a media controller::
echo img('images/picture.jpg', TRUE); // gives <img src="http://site.com/index.php/images/picture.jpg" alt="" />
-Additionally, an associative array can be passed to the img() function
-for complete control over all attributes and values. If an alt attribute
+Additionally, an associative array can be passed to the ``img()`` function
+for complete control over all attributes and values. If an *alt* attribute
is not provided, CodeIgniter will generate an empty string.
-::
+Example::
$image_properties = array(           
'src' => 'images/picture.jpg',           
@@ -81,128 +94,136 @@ is not provided, CodeIgniter will generate an empty string.
'rel' => 'lightbox'
);
- img($image_properties); // <img src="http://site.com/index.php/images/picture.jpg" alt="Me, demonstrating how to eat 4 slices of pizza at one time" class="post_images" width="200" height="200" title="That was quite a night" rel="lightbox" />
+ img($image_properties);
+ // <img src="http://site.com/index.php/images/picture.jpg" alt="Me, demonstrating how to eat 4 slices of pizza at one time" class="post_images" width="200" height="200" title="That was quite a night" rel="lightbox" />
link_tag()
-===========
+==========
-Lets you create HTML <link /> tags. This is useful for stylesheet links,
-as well as other links. The parameters are href, with optional rel,
-type, title, media and index_page. index_page is a TRUE/FALSE value
-that specifics if the href should have the page specified by
-$config['index_page'] added to the address it creates.
+.. php:function:: ling_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE)
-::
+ :param string $href: What are we linking to
+ :param string $rel: Relation type
+ :param string $type: Type of the related document
+ :param string $title: Link title
+ :param string $media: Media type
+ :param bool $index_page: Whether to treat $src as a routed URI string
+ :returns: string
- echo link_tag('css/mystyles.css'); // gives <link href="http://site.com/css/mystyles.css" rel="stylesheet" type="text/css" />
+Lets you create HTML <link /> tags. This is useful for stylesheet links,
+as well as other links. The parameters are *href*, with optional *rel*,
+*type*, *title*, *media* and *index_page*.
+
+*index_page* is a boolean value that specifies if the *href* should have
+the page specified by ``$config['index_page']`` added to the address it creates.
+Example::
-Further examples
+ echo link_tag('css/mystyles.css');
+ // gives <link href="http://site.com/css/mystyles.css" rel="stylesheet" type="text/css" />
-::
- echo link_tag('favicon.ico', 'shortcut icon', 'image/ico'); // <link href="http://site.com/favicon.ico" rel="shortcut icon" type="image/ico" />
+Further examples::
- echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed'); // <link href="http://site.com/feed" rel="alternate" type="application/rss+xml" title="My RSS Feed" />
+ echo link_tag('favicon.ico', 'shortcut icon', 'image/ico');
+ // <link href="http://site.com/favicon.ico" rel="shortcut icon" type="image/ico" />
-Additionally, an associative array can be passed to the link() function
-for complete control over all attributes and values.
+ echo link_tag('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');
+ // <link href="http://site.com/feed" rel="alternate" type="application/rss+xml" title="My RSS Feed" />
-::
+Additionally, an associative array can be passed to the ``link()`` function
+for complete control over all attributes and values::
$link = array(           
- 'href' => 'css/printer.css',           
- 'rel' => 'stylesheet',           
- 'type' => 'text/css',           
- 'media' => 'print'
+ 'href' => 'css/printer.css',
+ 'rel' => 'stylesheet',
+ 'type' => 'text/css',
+ 'media' => 'print'
);
- echo link_tag($link); // <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" />
-
+ echo link_tag($link);
+ // <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" />
nbs()
=====
-Generates non-breaking spaces (&nbsp;) based on the number you submit.
-Example
+.. php:function:: nbs($num = 1)
-::
+ :param int $num: Number of space entities to produce
+ :returns: string
- echo nbs(3);
+Generates non-breaking spaces (&nbsp;) based on the number you submit.
+Example::
-The above would produce
+ echo nbs(3);
-::
+The above would produce::
&nbsp;&nbsp;&nbsp;
-ol() and ul()
+ul() and ol()
=============
-Permits you to generate ordered or unordered HTML lists from simple or
-multi-dimensional arrays. Example
+.. php:function:: ul($list, $attributes = '')
-::
+ :param array $list: List entries
+ :param array $attributes: HTML attributes
+ :returns: string
- $this->load->helper('html');
+Permits you to generate ordered or unordered HTML lists from simple or
+multi-dimensional arrays. Example::
- $list = array(             
- 'red',             
- 'blue',             
- 'green',             
- 'yellow'             
+ $list = array(
+ 'red',
+ 'blue',
+ 'green',
+ 'yellow'
);
- $attributes = array(                     
- 'class' => 'boldlist',                     
- 'id'    => 'mylist'                    
+ $attributes = array(
+ 'class' => 'boldlist',
+ 'id' => 'mylist'
);
echo ul($list, $attributes);
-The above code will produce this
-
-::
+The above code will produce this::
- <ul class="boldlist" id="mylist">   
- <li>red</li>   
- <li>blue</li>   
- <li>green</li>   
+ <ul class="boldlist" id="mylist">
+ <li>red</li>
+ <li>blue</li>
+ <li>green</li>
<li>yellow</li>
</ul>
-Here is a more complex example, using a multi-dimensional array
-
-::
-
- $this->load->helper('html');
+Here is a more complex example, using a multi-dimensional array::
- $attributes = array(                     
- 'class' => 'boldlist',                     
- 'id'    => 'mylist'                     
+ $attributes = array(
+ 'class' => 'boldlist',
+ 'id' => 'mylist'
);
- $list = array(             
- 'colors' => array(                                 
- 'red',                                 
- 'blue',                                 
- 'green'                             
+ $list = array(
+ 'colors' => array(
+ 'red',
+ 'blue',
+ 'green'
),
- 'shapes' => array(                                 
- 'round',                                 
- 'square',                                 
- 'circles' => array(                                             
+ 'shapes' => array(
+ 'round',
+ 'square',
+ 'circles' => array(
'ellipse',
'oval',
'sphere'
- )                             
- ),             
- 'moods' => array(                                 
- 'happy',                                 
- 'upset' => array(                                         
+ )
+ ),
+ 'moods' => array(
+ 'happy',
+ 'upset' => array(
'defeated' => array(
- 'dejected',                
+ 'dejected',
'disheartened',
'depressed'
),
@@ -215,59 +236,74 @@ Here is a more complex example, using a multi-dimensional array
echo ul($list, $attributes);
-The above code will produce this
-
-::
-
- <ul class="boldlist" id="mylist">   
- <li>colors     
- <ul>       
- <li>red</li>       
- <li>blue</li>       
- <li>green</li>     
- </ul>   
- </li>   
- <li>shapes     
- <ul>       
- <li>round</li>       
- <li>suare</li>       
- <li>circles         
- <ul>           
- <li>elipse</li>           
- <li>oval</li>           
- <li>sphere</li>         
- </ul>       
- </li>     
- </ul>   
- </li>   
- <li>moods     
- <ul>       
- <li>happy</li>       
- <li>upset         
- <ul>           
- <li>defeated             
- <ul>               
+The above code will produce this::
+
+ <ul class="boldlist" id="mylist">
+ <li>colors
+ <ul>
+ <li>red</li>
+ <li>blue</li>
+ <li>green</li>
+ </ul>
+ </li>
+ <li>shapes
+ <ul>
+ <li>round</li>
+ <li>suare</li>
+ <li>circles
+ <ul>
+ <li>elipse</li>
+ <li>oval</li>
+ <li>sphere</li>
+ </ul>
+ </li>
+ </ul>
+ </li>
+ <li>moods
+ <ul>
+ <li>happy</li>
+ <li>upset
+ <ul>
+ <li>defeated
+ <ul>
<li>dejected</li>
<li>disheartened</li>
<li>depressed</li>
</ul>
</li>
<li>annoyed</li>
- <li>cross</li>           
- <li>angry</li>         
- </ul>       
- </li>     
- </ul>   
+ <li>cross</li>
+ <li>angry</li>
+ </ul>
+ </li>
+ </ul>
</li>
</ul>
+.. php:function:: ol($list, $attributes = '')
+
+ :param array $list: List entries
+ :param array $attributes: HTML attributes
+ :returns: string
+
+Identical to :php:func:`ul()`, only it produces the <ol> tag for
+ordered lists instead of <ul>.
+
meta()
======
+.. php:function:: meta($name = '', $content = '', $type = 'name', $newline = "\n")
+
+ :param string $name: Meta name
+ :param string $content: Meta content
+ :param string $type: Meta type
+ :param string $newline: Newline character
+ :returns: string
+
Helps you generate meta tags. You can pass strings to the function, or
-simple arrays, or multidimensional ones. Examples
+simple arrays, or multidimensional ones.
-::
+Examples::
echo meta('description', 'My Great site');
// Generates: <meta name="description" content="My Great Site" />
@@ -279,7 +315,7 @@ simple arrays, or multidimensional ones. Examples
echo meta(array('name' => 'robots', 'content' => 'no-cache'));
// Generates: <meta name="robots" content="no-cache" />
- $meta = array(         
+ $meta = array(
array(
'name' => 'robots',
'content' => 'no-cache'
@@ -291,7 +327,7 @@ simple arrays, or multidimensional ones. Examples
array(
'name' => 'keywords',
'content' => 'love, passion, intrigue, deception'
- ),         
+ ),
array(
'name' => 'robots',
'content' => 'no-cache'
@@ -313,10 +349,14 @@ simple arrays, or multidimensional ones. Examples
doctype()
=========
+.. php:function:: doctype($type = 'xhtml1-strict')
+
+ :param string $type: Doctype name
+
Helps you generate document type declarations, or DTD's. XHTML 1.0
Strict is used by default, but many doctypes are available.
-::
+Example::
echo doctype(); // <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
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
diff --git a/user_guide_src/source/helpers/language_helper.rst b/user_guide_src/source/helpers/language_helper.rst
index b7b23d149..8b039374d 100644
--- a/user_guide_src/source/helpers/language_helper.rst
+++ b/user_guide_src/source/helpers/language_helper.rst
@@ -10,24 +10,27 @@ language files.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('language');
The following functions are available:
-lang('language line', 'element id')
-===================================
+lang()
+======
+
+.. php:function:: lang($line, $id = '')
+
+ :param string $line: Language line key
+ :param string $id: ID of the element we're creating a label for
+ :returns: string
This function returns a line of text from a loaded language file with
-simplified syntax that may be more desirable for view files than calling
-`$this->lang->line()`. The optional second parameter will also output a
-form label for you. Example
+simplified syntax that may be more desirable for view files than
+``CI_Lang::line()``.
+The optional second parameter will also output a form label for you.
-::
+Example::
echo lang('language_key', 'form_item_id');
- // becomes <label for="form_item_id">language_key</label>
-
+ // becomes <label for="form_item_id">language_key</label> \ No newline at end of file
diff --git a/user_guide_src/source/helpers/number_helper.rst b/user_guide_src/source/helpers/number_helper.rst
index af6cdad57..8e0ebda5e 100644
--- a/user_guide_src/source/helpers/number_helper.rst
+++ b/user_guide_src/source/helpers/number_helper.rst
@@ -10,9 +10,7 @@ numeric data.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('number');
@@ -21,25 +19,27 @@ The following functions are available:
byte_format()
=============
-Formats a numbers as bytes, based on size, and adds the appropriate
-suffix. Examples
+.. php:function:: byte_format($num, $precision = 1)
+
+ :param mixed $num: Number of bytes
+ :param int $precision: Floating point precision
+ :returns: string
-::
+Formats numbers as bytes, based on size, and adds the appropriate
+suffix. Examples::
- echo byte_format(456); // Returns 456 Bytes
- echo byte_format(4567); // Returns 4.5 KB
- echo byte_format(45678); // Returns 44.6 KB
- echo byte_format(456789); // Returns 447.8 KB
- echo byte_format(3456789); // Returns 3.3 MB
- echo byte_format(12345678912345); // Returns 1.8 GB
+ echo byte_format(456); // Returns 456 Bytes
+ echo byte_format(4567); // Returns 4.5 KB
+ echo byte_format(45678); // Returns 44.6 KB
+ echo byte_format(456789); // Returns 447.8 KB
+ echo byte_format(3456789); // Returns 3.3 MB
+ echo byte_format(12345678912345); // Returns 1.8 GB
echo byte_format(123456789123456789); // Returns 11,228.3 TB
An optional second parameter allows you to set the precision of the
-result.
-
-::
+result::
echo byte_format(45678, 2); // Returns 44.61 KB
.. note:: The text generated by this function is found in the following
- language file: language/<your_lang>/number_lang.php
+ language file: `language/<your_lang>/number_lang.php` \ No newline at end of file
diff --git a/user_guide_src/source/helpers/path_helper.rst b/user_guide_src/source/helpers/path_helper.rst
index 847f5a08b..3a271b28f 100644
--- a/user_guide_src/source/helpers/path_helper.rst
+++ b/user_guide_src/source/helpers/path_helper.rst
@@ -10,9 +10,7 @@ file paths on the server.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('path');
@@ -21,23 +19,28 @@ The following functions are available:
set_realpath()
==============
-Checks to see if the path exists. This function will return a server
-path without symbolic links or relative directory structures. An
-optional second argument will cause an error to be triggered if the path
-cannot be resolved.
+.. php:function:: set_realpath($path, $check_existance = FALSE)
+
+ :param string $path: Path
+ :param bool $check_existance: Whether to check if the path actually exists
+ :returns: string
+
+This function will return a server path without symbolic links or
+relative directory structures. An optional second argument will
+cause an error to be triggered if the path cannot be resolved.
-::
+Examples::
$file = '/etc/php5/apache2/php.ini';
- echo set_realpath($file); // returns "/etc/php5/apache2/php.ini"
+ echo set_realpath($file); // Prints '/etc/php5/apache2/php.ini'
$non_existent_file = '/path/to/non-exist-file.txt';
- echo set_realpath($non_existent_file, TRUE); // shows an error, as the path cannot be resolved
- echo set_realpath($non_existent_file, FALSE); // returns "/path/to/non-exist-file.txt"
+ echo set_realpath($non_existent_file, TRUE); // Shows an error, as the path cannot be resolved
+ echo set_realpath($non_existent_file, FALSE); // Prints '/path/to/non-exist-file.txt'
$directory = '/etc/php5';
- echo set_realpath($directory); // returns "/etc/php5/"
+ echo set_realpath($directory); // Prints '/etc/php5/'
$non_existent_directory = '/path/to/nowhere';
- echo set_realpath($non_existent_directory, TRUE); // shows an error, as the path cannot be resolved
- echo set_realpath($non_existent_directory, FALSE); // returns "/path/to/nowhere"
+ echo set_realpath($non_existent_directory, TRUE); // Shows an error, as the path cannot be resolved
+ echo set_realpath($non_existent_directory, FALSE); // Prints '/path/to/nowhere' \ No newline at end of file
diff --git a/user_guide_src/source/helpers/security_helper.rst b/user_guide_src/source/helpers/security_helper.rst
index ec0be28b3..21bf53490 100644
--- a/user_guide_src/source/helpers/security_helper.rst
+++ b/user_guide_src/source/helpers/security_helper.rst
@@ -9,9 +9,7 @@ The Security Helper file contains security related functions.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('security');
@@ -20,25 +18,47 @@ The following functions are available:
xss_clean()
===========
-Provides Cross Site Script Hack filtering. This function is an alias to
-the one in the :doc:`Input class <../libraries/input>`. More info can
-be found there.
+.. php:function:: xss_clean($str, $is_image = FALSE)
+
+ :param string $str: Input data
+ :param bool $is_image: Whether we're dealing with an image
+ :returns: string
+
+Provides Cross Site Script Hack filtering.
+
+This function is an alias for ``CI_Input::xss_clean()``. For more info,
+please see the :doc:`Input Library <../libraries/input>` documentation.
sanitize_filename()
===================
-Provides protection against directory traversal. This function is an
-alias to the one in the :doc:`Security class <../libraries/security>`.
-More info can be found there.
+.. php:function:: sanitize_filename($filename)
+
+ :param string $filename: Filename
+ :returns: string
+
+Provides protection against directory traversal.
+
+This function is an alias for ``CI_Security::sanitize_filename()``.
+For more info, please see the :doc:`Security Library <../libraries/security>`
+documentation.
do_hash()
=========
+.. php:function:: do_hash($str, $type = 'sha1')
+
+ :param string $str: Input
+ :param string $type: Algorithm
+ :returns: string
+
Permits you to create one way hashes suitable for encrypting
-passwords. Will create SHA1 by default. See `hash_algos() <http://php.net/function.hash_algos>`_
+passwords. Will use SHA1 by default.
+
+See `hash_algos() <http://php.net/function.hash_algos>`_
for a full list of supported algorithms.
-::
+Examples::
$str = do_hash($str); // SHA1
$str = do_hash($str, 'md5'); // MD5
@@ -51,20 +71,34 @@ for a full list of supported algorithms.
strip_image_tags()
==================
-This is a security function that will strip image tags from a string. It
-leaves the image URL as plain text.
+.. php:function:: strip_image_tags($str)
+
+ :param string $str: Input
+ :returns: string
+
+This is a security function that will strip image tags from a string.
+It leaves the image URL as plain text.
-::
+Example::
$string = strip_image_tags($string);
+This function is an alias for ``CI_Security::strip_image_tags()``. For
+more info, please see the :doc:`Security Library <../libraries/security>`
+documentation.
+
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.
+.. php:function:: encode_php_tags($str)
+
+ :param string $str: Input
+ :returns: string
+
+This is a security function that converts PHP tags to entities.
-::
+.. note: :php:func:`xss_clean()` does this automatically, if you use it.
- $string = encode_php_tags($string);
+Example::
+ $string = encode_php_tags($string); \ No newline at end of file
diff --git a/user_guide_src/source/helpers/smiley_helper.rst b/user_guide_src/source/helpers/smiley_helper.rst
index 941ba11e3..13841e8bd 100644
--- a/user_guide_src/source/helpers/smiley_helper.rst
+++ b/user_guide_src/source/helpers/smiley_helper.rst
@@ -10,9 +10,7 @@ The Smiley Helper file contains functions that let you manage smileys
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('smiley');
@@ -36,10 +34,11 @@ 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 <http://codeigniter.com/download_files/smileys.zip>`_
- 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`
+.. important:: Before you begin, please `download the smiley images
+ <http://codeigniter.com/download_files/smileys.zip>`_
+ 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
--------------
@@ -47,18 +46,17 @@ 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()`
+.. important:: Change the URL in the :php:func:`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 :doc:`Table Class <../libraries/table>`.
-
-::
+You'll notice that in addition to the smiley helper, we are also using
+the :doc:`Table Class <../libraries/table>`::
<?php
class Smileys extends CI_Controller {
- function index()
+ public function index()
{
$this->load->helper('smiley');
$this->load->library('table');
@@ -69,12 +67,11 @@ You'll notice that in addition to the smiley helper we are using the :doc:`Table
$data['smiley_table'] = $this->table->generate($col_array);
$this->load->view('smiley_view', $data);
}
+
}
In your `application/views/` folder, create a file called `smiley_view.php`
-and place this code in it:
-
-::
+and place this code in it::
<html>
<head>
@@ -102,59 +99,66 @@ links a generic name that will be tied to a specific id in your view.
$image_array = get_smiley_links("http://example.com/images/smileys/", "comment_textarea_alias");
-To map the alias to the field id, pass them both into the `smiley_js`
-function
-
-::
+To map the alias to the field id, pass them both into the
+:php:func:`smiley_js()` function::
$image_array = smiley_js("comment_textarea_alias", "comments");
-******************
-Function Reference
-******************
-
get_clickable_smileys()
=======================
+.. php:function:: get_clickable_smileys($image_url, $alias = '', $smileys = NULL)
+
+ :param string $image_url: URL path to the smileys directory
+ :param string $alias: Field alias
+ :returns: array
+
Returns an array containing your smiley images wrapped in a clickable
link. You must supply the URL to your smiley folder and a field id or
field alias.
-::
+Example::
$image_array = get_smiley_links("http://example.com/images/smileys/", "comment");
-Note: Usage of this function without the second parameter, in
-combination with `js_insert_smiley` has been deprecated.
-
smiley_js()
===========
+.. php:function:: smiley_js($alias = '', $field_id = '', $inline = TRUE)
+
+ :param string $alias: Field alias
+ :param string $field_id: Field ID
+ :param bool $inline: Whether we're inserting an inline smiley
+
Generates the JavaScript that allows the images to be clicked and
inserted into a form field. If you supplied an alias instead of an id
when generating your smiley links, you need to pass the alias and
corresponding form id into the function. This function is designed to be
placed into the <head> area of your web page.
-::
+Example::
<?php echo smiley_js(); ?>
-Note: This function replaces `js_insert_smiley`, which has been
-deprecated.
-
parse_smileys()
===============
+.. php:function:: parse_smileys($str = '', $image_url = '', $smileys = NULL)
+
+ :param string $str: Text containing smiley codes
+ :param string $image_url: URL path to the smileys directory
+ :param array $smileys: An array of smileys
+ :returns: string
+
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 URL to your smiley folder
-::
+Example::
$str = 'Here are some simileys: :-) ;-)';
$str = parse_smileys($str, "http://example.com/images/smileys/");
echo $str;
-.. |smile!| image:: ../images/smile.gif
+.. |smile!| image:: ../images/smile.gif \ No newline at end of file
diff --git a/user_guide_src/source/helpers/string_helper.rst b/user_guide_src/source/helpers/string_helper.rst
index 530af2f89..d0d302476 100644
--- a/user_guide_src/source/helpers/string_helper.rst
+++ b/user_guide_src/source/helpers/string_helper.rst
@@ -10,9 +10,7 @@ strings.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('string');
@@ -21,39 +19,48 @@ The following functions are available:
random_string()
===============
+.. php:function:: random_string($type = 'alnum', $len = 8)
+
+ :param string $type: Randomization type
+ :param int $len: Output string length
+ :returns: 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:
-alpha, alunum, numeric, nozero, unique, md5, encrypt and sha1
-
- **alpha**: A string with lower and uppercase letters only.
- **alnum**: Alpha-numeric string with lower and uppercase characters.
+- **basic**: A random number based on ``mt_rand()``.
- **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 32
- character string.
-- **sha1**: An encrypted random number based on ``sha1()``.
-
-Usage example
+- **md5**: An encrypted random number based on ``md5()`` (fixed length of 32).
+- **sha1**: An encrypted random number based on ``sha1()`` (fixed length of 40).
-::
+Usage example::
echo random_string('alnum', 16);
+.. note:: Usage of the *unique* and *encrypt* types is DEPRECATED. They
+ are just aliases for *md5* and *sha1* respectively.
+
increment_string()
==================
+.. php:function:: increment_string($str, $separator = '_', $first = 1)
+
+ :param string $str: Input string
+ :param string $separator: Separator to append a duplicate number with
+ :param int $first: Starting number
+ :returns: string
+
Increments a string by appending a number to it or increasing the
number. Useful for creating "copies" or a file or duplicating database
content which has unique titles or slugs.
-Usage example
-
-::
+Usage example::
echo increment_string('file', '_'); // "file_1"
echo increment_string('file', '-', 2); // "file-2"
@@ -62,10 +69,13 @@ Usage example
alternator()
============
-Allows two or more items to be alternated between, when cycling through
-a loop. Example
+.. php:function:: alternator($args)
-::
+ :param mixed $args: A variable number of arguments
+ :returns: mixed
+
+Allows two or more items to be alternated between, when cycling through
+a loop. Example::
for ($i = 0; $i < 10; $i++)
{     
@@ -88,11 +98,16 @@ your loop the next item will be returned.
repeater()
==========
-Generates repeating copies of the data you submit. Example
+.. php:function:: repeater($data, $num = 1)
-::
+ :param string $data: Input
+ :param int $num: Number of times to repeat
+ :returns: string
+
+Generates repeating copies of the data you submit. Example::
- $string = "\n"; echo repeater($string, 30);
+ $string = "\n";
+ echo repeater($string, 30);
The above would generate 30 newlines.
@@ -102,10 +117,15 @@ The above would generate 30 newlines.
reduce_double_slashes()
=======================
+.. php:function:: reduce_double_slashes($str)
+
+ :param string $str: Input string
+ :returns: string
+
Converts double slashes in a string to a single slash, except those
-found in http://. Example
+found in URL protocol prefixes (e.g. http://).
-::
+Example::
$string = "http://example.com//index.php";
echo reduce_double_slashes($string); // results in "http://example.com/index.php"
@@ -113,16 +133,14 @@ found in http://. Example
strip_slashes()
===============
-Removes any slashes from a string. Example
-
-::
+.. php:function:: strip_slashes($data)
- $str = "Is your name O\'reilly?";
- echo strip_slashes($str); // results in Is your name O'reilly?
+ :param array $data: Input
+ :returns: array
-You can also use an array. Example
+Removes any slashes from an array of strings.
-::
+Example::
$str = array(
'question'  => 'Is your name O\'reilly?',
@@ -131,60 +149,66 @@ You can also use an array. Example
$str = strip_slashes($str);
-The above will return the following array:
-
-::
+The above will return the following array::
array(
'question'  => "Is your name O'reilly?",
'answer' => "No, my name is O'connor."
);
+.. note:: For historical reasons, this function will also accept
+ and handle string inputs. This however makes it just an
+ alias for ``stripslashes()``.
+
trim_slashes()
==============
-Removes any leading/trailing slashes from a string. Example
+.. php:function:: trim_slashes($str)
-::
+ :param string $str: Input string
+ :returns: string
+
+Removes any leading/trailing slashes from a string. Example::
$string = "/this/that/theother/";
echo trim_slashes($string); // results in this/that/theother
+.. note:: This function is DEPRECATED. Use the native ``trim()`` instead:
+ |
+ | trim($str, '/');
reduce_multiples()
==================
+.. php:function:: reduce_multiples($str, $character = '', $trim = FALSE)
+
+ :param string $str: Text to search in
+ :param string $character: Character to reduce
+ :param bool $trim: Whether to also trim the specified character
+ :returns: string
+
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 contains 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 set to TRUE it will
-remove occurences of the character at the beginning and the end of the
-string. Example:
-
-::
+If the third parameter is set 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
+.. php:function:: quotes_to_entities($str)
-::
+ :param string $str: Input string
+ :returns: string
+
+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;"
@@ -192,8 +216,12 @@ entities. Example
strip_quotes()
==============
+.. php:function:: strip_quotes($str)
+
+ :param string $str: Input string
+ :returns: string
+
Removes single and double quotes from a string. Example::
$string = "Joe's \"dinner\"";
- $string = strip_quotes($string); //results in "Joes dinner"
-
+ $string = strip_quotes($string); //results in "Joes dinner" \ No newline at end of file
diff --git a/user_guide_src/source/helpers/text_helper.rst b/user_guide_src/source/helpers/text_helper.rst
index 8cb2d6f96..aec36c9a7 100644
--- a/user_guide_src/source/helpers/text_helper.rst
+++ b/user_guide_src/source/helpers/text_helper.rst
@@ -10,9 +10,7 @@ text.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('text');
@@ -21,7 +19,14 @@ The following functions are available:
word_limiter()
==============
-Truncates a string to the number of **words** specified. Example::
+.. php:function:: word_limiter($str, $limit = 100, $end_char = '&#8230;')
+
+ :param string $str: Input string
+ :param int $limit: Limit
+ :param string $end_char: End character (usually an ellipsis)
+ :returns: string
+
+Truncates a string to the number of *words* specified. Example::
$string = "Here is a nice text string consisting of eleven words.";
$string = word_limiter($string, 4);
@@ -33,11 +38,18 @@ default it adds an ellipsis.
character_limiter()
===================
-Truncates a string to the number of **characters** specified. It
+.. php:function:: character_limiter($str, $n = 500, $end_char = '&#8230;')
+
+ :param string $str: Input string
+ :param int $n: Number of characters
+ :param string $end_char: End character (usually an ellipsis)
+ :returns: string
+
+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
+more or less then what you specify.
-::
+Example::
$string = "Here is a nice text string consisting of eleven words.";
$string = character_limiter($string, 20);
@@ -46,55 +58,78 @@ more or less then what you specify. Example
The third parameter is an optional suffix added to the string, if
undeclared this helper uses an ellipsis.
-**Note:** If you need to truncate to an exact number of characters please see
-the :ref:`ellipsize` function below.
+.. note:: If you need to truncate to an exact number of characters please
+ see the :ref:`ellipsize()` function below.
ascii_to_entities()
===================
+.. php:function:: ascii_to_entities($str)
+
+ :param string $str: Input string
+ :returns: string
+
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 dependence 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
+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.
+.. php:function::entities_to_ascii($str, $all = TRUE)
+
+ :param string $str: Input string
+ :param bool $all: Whether to convert unsafe entities as well
+ :returns: string
+
+This function does the opposite of :php:func:`ascii_to_entities()`.
+It turns character entities back into ASCII.
convert_accented_characters()
=============================
-Transliterates high ASCII characters to low ASCII equivalents, useful
+.. php:function:: convert_accented_characters($str)
+
+ :param string $str: Input string
+ :returns: string
+
+Transliterates high ASCII characters to low ASCII equivalents. Useful
when non-English characters need to be used where only standard ASCII
characters are safely used, for instance, in URLs.
-::
+Example::
$string = convert_accented_characters($string);
-This function uses a companion config file
-`application/config/foreign_chars.php` to define the to and from array
-for transliteration.
+.. note:: This function uses a companion config file
+ `application/config/foreign_chars.php` to define the to and
+ from array for transliteration.
word_censor()
=============
+.. php:function:: word_censor($str, $censored, $replacement = '')
+
+ :param string $str: Input string
+ :param array $censored: List of bad words to censor
+ :param string $replacement: What to replace bad words with
+ :returns: string
+
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
+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!');
@@ -102,48 +137,76 @@ pound signs: ####. Example
highlight_code()
================
+.. php:function:: highlight_code($str)
+
+ :param string $str: Input string
+ :returns: string
+
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.
+The function uses PHP's ``highlight_string()`` function, so the
+colors used are the ones specified in your php.ini file.
highlight_phrase()
==================
+.. php:function:: highlight_phrase($str, $phrase, $tag_open = '<strong>', $tag_close = '</strong>')
+
+ :param string $str: Input string
+ :param string $phrase: Phrase to highlight
+ :param string $tag_open: Opening tag used for the highlight
+ :param string $tag_close: Closing tag for the highlight
+ :returns: string
+
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
+opening/closing HTML tags you would like the phrase wrapped in.
-::
+Example::
$string = "Here is a nice text string about nothing in particular.";
- $string = highlight_phrase($string, "nice text", '<span style="color:#990000">', '</span>');
+ echo highlight_phrase($string, "nice text", '<span style="color:#990000;">', '</span>');
-The above text returns:
+The above code prints::
-Here is a nice text string about nothing in particular.
+ Here is a <span style="color:#990000;">nice text</span> string about nothing in particular.
word_wrap()
===========
-Wraps text at the specified **character** count while maintaining
-complete words. Example
+.. php:function:: word_wrap($str, $charlim = 76)
+
+ :param string $str: Input string
+ :param int $charlim: Character limit
+ :returns: string
-::
+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
-.. _ellipsize:
+.. _ellipsize():
ellipsize()
===========
+.. php:function:: ellipsize($str, $max_length, $position = 1, $ellipsis = '&hellip;')
+
+ :param string $str: Input string
+ :param int $max_length: String length limit
+ :param mixed $position: Position to split at
+ (int or float)
+ :param string $ellipsis: What to use as the ellipsis character
+ :returns: string
+
This function will strip tags from a string, split it at a defined
maximum length, and insert an ellipsis.
@@ -156,14 +219,11 @@ string, .5 in the middle, and 0 at the left.
An optional forth parameter is the kind of ellipsis. By default,
&hellip; will be inserted.
-::
+Example::
$str = 'this_string_is_entirely_too_long_and_might_break_my_design.jpg';
echo ellipsize($str, 32, .5);
-Produces:
-
-::
-
- this_string_is_e&hellip;ak_my_design.jpg
+Produces::
+ this_string_is_e&hellip;ak_my_design.jpg \ No newline at end of file
diff --git a/user_guide_src/source/helpers/typography_helper.rst b/user_guide_src/source/helpers/typography_helper.rst
index f3202603a..3c81687ac 100644
--- a/user_guide_src/source/helpers/typography_helper.rst
+++ b/user_guide_src/source/helpers/typography_helper.rst
@@ -10,9 +10,7 @@ in semantically relevant ways.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('typography');
@@ -21,9 +19,18 @@ The following functions are available:
auto_typography()
=================
+.. php:function:: auto_typography($str, $reduce_linebreaks = FALSE)
+
+ :param string $str: Input string
+ :param bool $reduce_linebreaks: Whether to reduce multiple instances of double newlines to two
+ :returns: string
+
Formats text so that it is semantically and typographically correct
-HTML. Please see the :doc:`Typography Class <../libraries/typography>`
-for more info.
+HTML.
+
+This function is an alias for ``CI_Typography::auto_typography``.
+For more info, please see the :doc:`Typography Library
+<../libraries/typography>` documentation.
Usage example::
@@ -31,18 +38,34 @@ Usage example::
.. 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 </general/caching>` your pages.
+ function you may want to consider `caching <../general/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.
+.. php:function:: nl2br_except_pre($str)
-Usage example
+ :param string $str: Input string
+ :returns: string
-::
+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);
+entity_decode()
+===============
+
+.. php:function:: entity_decode($str, $charset = NULL)
+
+ :param string $str: Input string
+ :param string $charset: Character set
+ :returns: string
+
+This function is an alias for ``CI_Security::entity_decode()``.
+Fore more info, please see the :doc:`Security Library
+<../libraries/security>` documentation. \ No newline at end of file
diff --git a/user_guide_src/source/helpers/url_helper.rst b/user_guide_src/source/helpers/url_helper.rst
index 1987dfb72..5b8fa5f44 100644
--- a/user_guide_src/source/helpers/url_helper.rst
+++ b/user_guide_src/source/helpers/url_helper.rst
@@ -9,9 +9,7 @@ The URL Helper file contains functions that assist in working with URLs.
Loading this Helper
===================
-This helper is loaded using the following code
-
-::
+This helper is loaded using the following code::
$this->load->helper('url');
@@ -20,119 +18,135 @@ The following functions are available:
site_url()
==========
+.. php:function:: site_url($uri = '')
+
+ :param string $uri: URI string
+ :returns: string
+
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 (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, and the url_suffix as set in your config file.
+function, plus the **url_suffix** as set in your config file.
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
+array. Here is a string example::
-::
-
- echo site_url("news/local/123");
+ echo site_url('news/local/123');
The above example would return something like:
-http://example.com/index.php/news/local/123
-
-Here is an example of segments passed as an array
+*http://example.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);
+This function is an alias for ``CI_Config::site_url()``. For more info,
+please see the :doc:`Config Library <../libraries/config>` documentation.
+
base_url()
===========
-Returns your site base URL, as specified in your config file. Example
+.. php:function:: base_url($uri = '')
-::
+ :param string $uri: URI string
+ :returns: string
- echo base_url();
+Returns your site base URL, as specified in your config file. Example::
-This function returns the same thing as `site_url`, without the
-index_page or url_suffix being appended.
+ echo base_url();
-Also like site_url, you can supply segments as a string or an array.
-Here is a string example
+This function returns the same thing as :php:func:`site_url()`, without
+the *index_page* or *url_suffix* being appended.
-::
+Also like :php:func:`site_url()`, you can supply segments as a string or
+an array. Here is a string example::
echo base_url("blog/post/123");
The above example would return something like:
-http://example.com/blog/post/123
-
-This is useful because unlike `site_url()`, you can supply a string to a
-file, such as an image or stylesheet. For example
+*http://example.com/blog/post/123*
-::
+This is useful because unlike :php:func:`site_url()`, you can supply a
+string to a file, such as an image or stylesheet. For example::
echo base_url("images/icons/edit.png");
This would give you something like:
-http://example.com/images/icons/edit.png
+*http://example.com/images/icons/edit.png*
+
+This function is an alias for ``CI_Config::base_url()``. For more info,
+please see the :doc:`Config Library <../libraries/config>` documentation.
current_url()
=============
+.. php:function:: current_url()
+
+ :returns: string
+
Returns the full URL (including segments) of the page being currently
viewed.
+.. note:: Calling this function is the same as doing this:
+ |
+ | site_url(uri_string());
+
uri_string()
============
-Returns the URI segments of any page that contains this function. For
-example, if your URL was this
+.. php:function:: uri_string()
-::
+ :returns: string
- http://some-site.com/blog/comments/123
+Returns the URI segments of any page that contains this function.
+For example, if your URL was this::
-The function would return
+ http://some-site.com/blog/comments/123
-::
+The function would return::
/blog/comments/123
+This function is an alias for ``CI_Config::uri_string()``. For more info,
+please see the :doc:`Config Library <../libraries/config>` documentation.
+
index_page()
============
-Returns your site "index" page, as specified in your config file.
-Example
+.. php:function:: index_page()
+
+ :returns: string
-::
+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
-
-::
+.. php:function:: anchor($uri = '', $title = '', $attributes = '')
- <a href="http://example.com">Click Here</a>
+ :param string $uri: URI string
+ :param string $title: Anchor title
+ :param mixed $attributes: HTML attributes
+ :returns: string
-The tag has three optional parameters
-
-::
-
- anchor(uri segments, text, attributes)
+Creates a standard HTML anchor link based on your local site URL.
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.
+URL. As with the :php:func:`site_url()` function above, segments can
+be a string or an array.
.. note:: If you are building links that are internal to your application
- do not include the base URL (http://...). This will be added automatically
- from the information specified in your config file. Include only the
- URI segments you wish appended to the URL.
+ do not include the base URL (http://...). This will be added
+ automatically from the information 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.
@@ -141,41 +155,43 @@ 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
-
-::
+Here are some examples::
echo anchor('news/local/123', 'My News', 'title="News title"');
-
-Would produce: <a href="http://example.com/index.php/news/local/123"
-title="News title">My News</a>
-
-::
+ // Prints: <a href="http://example.com/index.php/news/local/123" title="News title">My News</a>
echo anchor('news/local/123', 'My News', array('title' => 'The best news!'));
+ // Prints: <a href="http://example.com/index.php/news/local/123" title="The best news!">My News</a>
-Would produce: <a href="http://example.com/index.php/news/local/123"
-title="The best news!">My News</a>
+ echo anchor('', 'Click here');
+ // Prints: <a href="http://example.com">Click Here</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
+.. php:function:: anchor_popup($uri = '', $title = '', $attributes = FALSE)
-::
+ :param string $uri: URI string
+ :param string $title: Anchor title
+ :param mixed $attributes: HTML attributes
+ :returns: string
+
+Nearly identical to the :php:func:``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',
+ 'width' => 800,
+ 'height' => 600,
'scrollbars' => 'yes',
'status'      => 'yes',
'resizable'   => 'yes',
- 'screenx'     => '0',
- 'screeny'     => '0',
+ 'screenx' => 0,
+ 'screeny' => 0,
'window_name' => '_blank'
);
@@ -184,13 +200,11 @@ browser settings. Here is an example with attributes
.. 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
-
-::
+ third parameter:
+ |
+ | echo anchor_popup('news/local/123', 'Click Me!', array());
- echo anchor_popup('news/local/123', 'Click Me!', array());
-
-.. note:: The 'window_name' is not really an attribute, but an argument to
+.. note:: The **window_name** is not really an attribute, but an argument to
the JavaScript `window.open() <http://www.w3schools.com/jsref/met_win_open.asp>`
method, which accepts either a window name or a window target.
@@ -200,117 +214,149 @@ browser settings. Here is an example with attributes
mailto()
========
-Creates a standard HTML email link. Usage example
+.. php:function:: mailto($email, $title = '', $attributes = '')
-::
+ :param string $email: E-mail address
+ :param string $title: Anchor title
+ :param mixed $attributes: HTML attributes
+ :returns: string
- echo mailto('me@my-site.com', 'Click Here to Contact Me');
+Creates a standard HTML e-mail link. Usage example::
-As with the anchor() tab above, you can set attributes using the third
-parameter:
+ echo mailto('me@my-site.com', 'Click Here to Contact Me');
-::
+As with the :php:func:`anchor()` tab above, you can set attributes using the
+third parameter::
- $attributes = array('title' => 'Mail me');
- echo mailto('me@my-site.com', 'Contact Me', $attributes);
+ $attributes = array('title' => 'Mail me');
+ echo mailto('me@my-site.com', 'Contact Me', $attributes);
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.
+.. php:function:: safe_mailto($email, $title = '', $attributes = '')
+
+ :param string $email: E-mail address
+ :param string $title: Anchor title
+ :param mixed $attributes: HTML attributes
+ :returns: string
+
+Identical to the :php:func:`mailto()` function except it writes an obfuscated
+version of the *mailto* tag using ordinal numbers written with JavaScript to
+help prevent the e-mail address from being harvested by spam bots.
auto_link()
===========
-Automatically turns URLs and email addresses contained in a string into
-links. Example
+.. php:function:: auto_link($str, $type = 'both', $popup = FALSE)
+
+ :param string $str: Input string
+ :param string $type: Link type ('email', 'url' or 'both')
+ :param bool $popup: Whether to create popup links
+ :returns: string
-::
+Automatically turns URLs and e-mail addresses contained in a string into
+links. Example::
$string = auto_link($string);
-The second parameter determines whether URLs and emails are converted or
+The second parameter determines whether URLs and e-mails are converted or
just one or the other. Default behavior is both if the parameter is not
-specified. Email links are encoded as safe_mailto() as shown above.
+specified. E-mail links are encoded as :php:func:`safe_mailto()` as shown
+above.
-Converts only URLs
-
-::
+Converts only URLs::
$string = auto_link($string, 'url');
-Converts only Email addresses
-
-::
+Converts only e-mail 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)
-
-::
+The value can be TRUE or FALSE (boolean)::
$string = auto_link($string, 'both', TRUE);
url_title()
===========
+.. php:function:: url_title($str, $separator = '-', $lowercase = FALSE)
+
+ :param string $str: Input string
+ :param string $separator: Word separator
+ :param string $lowercase: Whether to transform the output string to lower-case
+ :returns: string
+
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 of your entries in the URL. Example::
$title = "What's wrong with CSS?";
- $url_title = url_title($title); // Produces: Whats-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
+are used. Preferred options are: **-** (dash) or **_** (underscore)
-::
+Example::
$title = "What's wrong with CSS?";
- $url_title = url_title($title, 'underscore'); // Produces: Whats_wrong_with_CSS
+ $url_title = url_title($title, 'underscore');
+ // Produces: Whats_wrong_with_CSS
+
+.. note:: Old usage of 'dash' and 'underscore' as the second parameter
+ is DEPRECATED.
The third parameter determines whether or not lowercase characters are
-forced. By default they are not. Options are boolean TRUE/FALSE
+forced. By default they are not. Options are boolean TRUE/FALSE.
-::
+Example::
$title = "What's wrong with CSS?";
- $url_title = url_title($title, 'underscore', TRUE); // Produces: whats_wrong_with_css
+ $url_title = url_title($title, 'underscore', TRUE);
+ // Produces: whats_wrong_with_css
prep_url()
----------
-This function will add http:// in the event that a scheme is missing
-from a URL. Pass the URL string to the function like this
+.. php:function:: prep_url($str = '')
+
+ :param string $str: URL string
+ :returns: string
-::
+This function will add http:// in the event that a protocol prefix
+is missing from a URL.
- $url = "example.com";
- $url = prep_url($url);
+Pass the URL string to the function like this::
+
+ $url = prep_url('example.com');
redirect()
==========
+.. php:function:: redirect($uri = '', $method = 'auto', $code = NULL)
+
+ :param string $uri: URI string
+ :param string $method: Redirect method ('auto', 'location' or 'refresh')
+ :param string $code: HTTP Response code (usually 302 or 303)
+ :returns: void
+
Does a "header redirect" to the URI specified. If you specify the full
site URL that link will be built, but for local links simply providing
the URI segments to the controller you want to direct to will create the
link. The function will build the URL based on your config file values.
The optional second parameter allows you to force a particular redirection
-method. The available methods are "location" or "refresh", with location
-being faster but less reliable on IIS servers. The default is "auto",
-which will attempt to intelligently choose the method based on the server
-environment.
+method. The available methods are **auto**, **location** and **refresh**,
+with location being faster but less reliable on IIS servers.
+The default is **auto**, which will attempt to intelligently choose the
+method based on the server environment.
The optional third parameter allows you to send a specific HTTP Response
Code - this could be used for example to create 301 redirects for search
engine purposes. The default Response Code is 302. The third parameter is
-*only* available with 'location' redirects, and not 'refresh'. Examples::
+*only* available with **location** redirects, and not *refresh*. Examples::
if ($logged_in == FALSE)
{      
@@ -324,8 +370,14 @@ engine purposes. The default Response Code is 302. The third parameter is
is outputted to the browser since it utilizes server headers.
.. note:: For very fine grained control over headers, you should use the
- `Output Library </libraries/output>` set_header() function.
+ `Output Library </libraries/output>` ``set_header()`` method.
-.. note:: To IIS users: if you hide the `Server` HTTP header, the "auto"
+.. note:: To IIS users: if you hide the `Server` HTTP header, the *auto*
method won't detect IIS, in that case it is advised you explicitly
- use the "refresh" method.
+ use the **refresh** method.
+
+.. note:: When the **location** method is used, an HTTP status code of 303
+ will *automatically* be selected when the page is currently accessed
+ via POST and HTTP/1.1 is used.
+
+.. important:: This function will terminate script execution. \ No newline at end of file