From 30e2eafa86c4c7b6b39cea3e7089a90df9f603fb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2018 16:45:46 +0300 Subject: [ci skip] 3.1.9 release --- user_guide/helpers/array_helper.html | 660 ++++++++++++ user_guide/helpers/captcha_helper.html | 676 ++++++++++++ user_guide/helpers/cookie_helper.html | 608 +++++++++++ user_guide/helpers/date_helper.html | 1256 +++++++++++++++++++++++ user_guide/helpers/directory_helper.html | 587 +++++++++++ user_guide/helpers/download_helper.html | 556 ++++++++++ user_guide/helpers/email_helper.html | 598 +++++++++++ user_guide/helpers/file_helper.html | 829 +++++++++++++++ user_guide/helpers/form_helper.html | 1598 +++++++++++++++++++++++++++++ user_guide/helpers/html_helper.html | 1091 ++++++++++++++++++++ user_guide/helpers/index.html | 518 ++++++++++ user_guide/helpers/inflector_helper.html | 680 ++++++++++++ user_guide/helpers/language_helper.html | 550 ++++++++++ user_guide/helpers/number_helper.html | 559 ++++++++++ user_guide/helpers/path_helper.html | 557 ++++++++++ user_guide/helpers/security_helper.html | 669 ++++++++++++ user_guide/helpers/smiley_helper.html | 708 +++++++++++++ user_guide/helpers/string_helper.html | 873 ++++++++++++++++ user_guide/helpers/text_helper.html | 847 +++++++++++++++ user_guide/helpers/typography_helper.html | 607 +++++++++++ user_guide/helpers/url_helper.html | 1044 +++++++++++++++++++ user_guide/helpers/xml_helper.html | 559 ++++++++++ 22 files changed, 16630 insertions(+) create mode 100644 user_guide/helpers/array_helper.html create mode 100644 user_guide/helpers/captcha_helper.html create mode 100644 user_guide/helpers/cookie_helper.html create mode 100644 user_guide/helpers/date_helper.html create mode 100644 user_guide/helpers/directory_helper.html create mode 100644 user_guide/helpers/download_helper.html create mode 100644 user_guide/helpers/email_helper.html create mode 100644 user_guide/helpers/file_helper.html create mode 100644 user_guide/helpers/form_helper.html create mode 100644 user_guide/helpers/html_helper.html create mode 100644 user_guide/helpers/index.html create mode 100644 user_guide/helpers/inflector_helper.html create mode 100644 user_guide/helpers/language_helper.html create mode 100644 user_guide/helpers/number_helper.html create mode 100644 user_guide/helpers/path_helper.html create mode 100644 user_guide/helpers/security_helper.html create mode 100644 user_guide/helpers/smiley_helper.html create mode 100644 user_guide/helpers/string_helper.html create mode 100644 user_guide/helpers/text_helper.html create mode 100644 user_guide/helpers/typography_helper.html create mode 100644 user_guide/helpers/url_helper.html create mode 100644 user_guide/helpers/xml_helper.html (limited to 'user_guide/helpers') diff --git a/user_guide/helpers/array_helper.html b/user_guide/helpers/array_helper.html new file mode 100644 index 000000000..dd28bb5b5 --- /dev/null +++ b/user_guide/helpers/array_helper.html @@ -0,0 +1,660 @@ + + + + + + + + + + Array Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Array Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

Array Helper

+

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

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+element($item, $array[, $default = NULL])
+
+++ + + + + + + + +
Parameters:
    +
  • $item (string) – Item to fetch from the array
  • +
  • $array (array) – Input array
  • +
  • $default (bool) – What to return if the array isn’t valid
  • +
+
Returns:

NULL on failure or the array item.

+
Return type:

mixed

+
+

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:

+
$array = array(
+        'color' => 'red',
+        'shape' => 'round',
+        'size'  => ''
+);
+
+echo element('color', $array); // returns "red"
+echo element('size', $array, 'foobar'); // returns "foobar"
+
+
+
+ +
+
+elements($items, $array[, $default = NULL])
+
+++ + + + + + + + +
Parameters:
    +
  • $item (string) – Item to fetch from the array
  • +
  • $array (array) – Input array
  • +
  • $default (bool) – What to return if the array isn’t valid
  • +
+
Returns:

NULL on failure or the array item.

+
Return type:

mixed

+
+

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.

+

Example:

+
$array = array(
+        'color' => 'red',
+        'shape' => 'round',
+        'radius' => '10',
+        'diameter' => '20'
+);
+
+$my_shape = elements(array('color', 'shape', 'height'), $array);
+
+
+

The above will return the following array:

+
array(
+        'color' => 'red',
+        'shape' => 'round',
+        'height' => NULL
+);
+
+
+

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:

+
array(
+        'color'         => 'red',
+        'shape'         => 'round',
+        'height'        => 'foobar'
+);
+
+
+

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.

+
$this->load->model('post_model');
+$this->post_model->update(
+        elements(array('id', 'title', 'content'), $_POST)
+);
+
+
+

This ensures that only the id, title and content fields are sent to be +updated.

+
+ +
+
+random_element($array)
+
+++ + + + + + + + +
Parameters:
    +
  • $array (array) – Input array
  • +
+
Returns:

A random element from the array

+
Return type:

mixed

+
+

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

+

Usage example:

+
$quotes = array(
+        "I find that the harder I work, the more luck I seem to have. - Thomas Jefferson",
+        "Don't stay in bed, unless you can make money in bed. - George Burns",
+        "We didn't lose the game; we just ran out of time. - Vince Lombardi",
+        "If everything seems under control, you're not going fast enough. - Mario Andretti",
+        "Reality is merely an illusion, albeit a very persistent one. - Albert Einstein",
+        "Chance favors the prepared mind - Louis Pasteur"
+);
+
+echo random_element($quotes);
+
+
+
+ +
+
+ + +
+
+ + + + +
+ +
+

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/captcha_helper.html b/user_guide/helpers/captcha_helper.html new file mode 100644 index 000000000..2800c5924 --- /dev/null +++ b/user_guide/helpers/captcha_helper.html @@ -0,0 +1,676 @@ + + + + + + + + + + CAPTCHA Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • CAPTCHA Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

CAPTCHA Helper

+

The CAPTCHA Helper file contains functions that assist in creating +CAPTCHA images.

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Using the CAPTCHA helper

+

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,
+        'word_length'   => 8,
+        'font_size'     => 16,
+        'img_id'        => 'Imageid',
+        'pool'          => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
+
+        // White background and border, black text and red grid
+        'colors'        => array(
+                'background' => array(255, 255, 255),
+                'border' => array(255, 255, 255),
+                'text' => array(0, 0, 0),
+                'grid' => array(255, 40, 40)
+        )
+);
+
+$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 +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” directory must be writable
  • +
  • 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.
  • +
  • word_length defaults to 8, pool defaults to ‘0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’
  • +
  • font_size defaults to 16, the native GD font has a size limit. Specify a “true type” font for bigger sizes.
  • +
  • The img_id will be set as the “id” of the captcha image.
  • +
  • If any of the colors values is missing, it will be replaced by the default.
  • +
+
+

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() +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:

+
CREATE TABLE captcha (
+        captcha_id bigint(13) unsigned NOT NULL auto_increment,
+        captcha_time int(10) unsigned NOT NULL,
+        ip_address varchar(45) NOT NULL,
+        word varchar(20) NOT NULL,
+        PRIMARY KEY `captcha_id` (`captcha_id`),
+        KEY `word` (`word`)
+);
+
+
+

Here is an example of usage with a database. On the page where the +CAPTCHA will be shown you’ll have something like this:

+
$this->load->helper('captcha');
+$vals = array(
+        'img_path'      => './captcha/',
+        'img_url'       => 'http://example.com/captcha/'
+);
+
+$cap = create_captcha($vals);
+$data = array(
+        'captcha_time'  => $cap['time'],
+        'ip_address'    => $this->input->ip_address(),
+        'word'          => $cap['word']
+);
+
+$query = $this->db->insert_string('captcha', $data);
+$this->db->query($query);
+
+echo 'Submit the word you see below:';
+echo $cap['image'];
+echo '<input type="text" name="captcha" value="" />';
+
+
+

Then, on the page that accepts the submission you’ll have something like +this:

+
// First, delete old captchas
+$expiration = time() - 7200; // Two hour limit
+$this->db->where('captcha_time < ', $expiration)
+        ->delete('captcha');
+
+// Then see if a captcha exists:
+$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.';
+}
+
+
+
+
+
+

Available Functions

+

The following functions are available:

+
+
+create_captcha([$data = ''[, $img_path = ''[, $img_url = ''[, $font_path = '']]]])
+
+++ + + + + + + + +
Parameters:
    +
  • $data (array) – Array of data for the CAPTCHA
  • +
  • $img_path (string) – Path to create the image in (DEPRECATED)
  • +
  • $img_url (string) – URL to the CAPTCHA image folder (DEPRECATED)
  • +
  • $font_path (string) – Server path to font (DEPRECATED)
  • +
+
Returns:

array(‘word’ => $word, ‘time’ => $now, ‘image’ => $img)

+
Return type:

array

+
+

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.

+
array(
+        'image' => IMAGE TAG
+        'time'  => TIMESTAMP (in microtime)
+        'word'  => CAPTCHA WORD
+)
+
+
+

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 +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 +supplied to the function, will be a random string.

+
+

Note

+

Usage of the $img_path, $img_url and $font_path +parameters is DEPRECATED. Provide them in the $data array +instead.

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

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/cookie_helper.html b/user_guide/helpers/cookie_helper.html new file mode 100644 index 000000000..ba7eccdde --- /dev/null +++ b/user_guide/helpers/cookie_helper.html @@ -0,0 +1,608 @@ + + + + + + + + + + Cookie Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Cookie Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ + + + +
+
+ + + + +
+ +
+

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/date_helper.html b/user_guide/helpers/date_helper.html new file mode 100644 index 000000000..138fe5db4 --- /dev/null +++ b/user_guide/helpers/date_helper.html @@ -0,0 +1,1256 @@ + + + + + + + + + + Date Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Date Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

Date Helper

+

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

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+now([$timezone = NULL])
+
+++ + + + + + + + +
Parameters:
    +
  • $timezone (string) – Timezone
  • +
+
Returns:

UNIX timestamp

+
Return type:

int

+
+

Returns the current time as a UNIX timestamp, referenced either to your server’s +local time or any PHP supported 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 the +time_reference setting.

+
+ +
+
+mdate([$datestr = ''[, $time = '']])
+
+++ + + + + + + + +
Parameters:
    +
  • $datestr (string) – Date string
  • +
  • $time (int) – UNIX timestamp
  • +
+
Returns:

MySQL-formatted date

+
Return type:

string

+
+

This function is identical to PHP’s date() +function, except that it lets you use MySQL style date codes, where each +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:

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

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

+
+ +
+
+standard_date([$fmt = 'DATE_RFC822'[, $time = NULL]])
+
+++ + + + + + + + +
Parameters:
    +
  • $fmt (string) – Date format
  • +
  • $time (int) – UNIX timestamp
  • +
+
Returns:

Formatted date or FALSE on invalid format

+
Return type:

string

+
+

Lets you generate a date string in one of several standardized formats.

+

Example:

+
$format = 'DATE_RFC822';
+$time = time();
+echo standard_date($format, $time);
+
+
+
+

Note

+

This function is DEPRECATED. Use the native date() combined with +DateTime’s format constants +instead:

+
echo date(DATE_RFC822, time());
+
+
+
+

Supported formats:

+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ConstantDescriptionExample
DATE_ATOMAtom2005-08-15T16:13:03+0000
DATE_COOKIEHTTP CookiesSun, 14 Aug 2005 16:13:03 UTC
DATE_ISO8601ISO-86012005-08-14T16:13:03+00:00
DATE_RFC822RFC 822Sun, 14 Aug 05 16:13:03 UTC
DATE_RFC850RFC 850Sunday, 14-Aug-05 16:13:03 UTC
DATE_RFC1036RFC 1036Sunday, 14-Aug-05 16:13:03 UTC
DATE_RFC1123RFC 1123Sun, 14 Aug 2005 16:13:03 UTC
DATE_RFC2822RFC 2822Sun, 14 Aug 2005 16:13:03 +0000
DATE_RSSRSSSun, 14 Aug 2005 16:13:03 UTC
DATE_W3CW3C2005-08-14T16:13:03+0000
+
+ +
+
+local_to_gmt([$time = ''])
+
+++ + + + + + + + +
Parameters:
    +
  • $time (int) – UNIX timestamp
  • +
+
Returns:

UNIX timestamp

+
Return type:

int

+
+

Takes a UNIX timestamp as input and returns it as GMT.

+

Example:

+
$gmt = local_to_gmt(time());
+
+
+
+ +
+
+gmt_to_local([$time = ''[, $timezone = 'UTC'[, $dst = FALSE]]])
+
+++ + + + + + + + +
Parameters:
    +
  • $time (int) – UNIX timestamp
  • +
  • $timezone (string) – Timezone
  • +
  • $dst (bool) – Whether DST is active
  • +
+
Returns:

UNIX timestamp

+
Return type:

int

+
+

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

+

Example:

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

Note

+

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

+
+
+ +
+
+mysql_to_unix([$time = ''])
+
+++ + + + + + + + +
Parameters:
    +
  • $time (string) – MySQL timestamp
  • +
+
Returns:

UNIX timestamp

+
Return type:

int

+
+

Takes a MySQL Timestamp as input and returns it as a UNIX timestamp.

+

Example:

+
$unix = mysql_to_unix('20061124092345');
+
+
+
+ +
+
+unix_to_human([$time = ''[, $seconds = FALSE[, $fmt = 'us']]])
+
+++ + + + + + + + +
Parameters:
    +
  • $time (int) – UNIX timestamp
  • +
  • $seconds (bool) – Whether to show seconds
  • +
  • $fmt (string) – format (us or euro)
  • +
+
Returns:

Formatted date

+
Return type:

string

+
+

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

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

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

+

The time can be formatted with or without seconds, and it can be set to +European or US format. If only the timestamp is submitted it will return +the time without seconds formatted for the U.S.

+

Examples:

+
$now = time();
+echo unix_to_human($now); // U.S. time, no seconds
+echo unix_to_human($now, TRUE, 'us'); // U.S. time with seconds
+echo unix_to_human($now, TRUE, 'eu'); // Euro time with seconds
+
+
+
+ +
+
+human_to_unix([$datestr = ''])
+
+++ + + + + + + + +
Parameters:
    +
  • $datestr (int) – Date string
  • +
+
Returns:

UNIX timestamp or FALSE on failure

+
Return type:

int

+
+

The opposite of the 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);
+$unix = human_to_unix($human);
+
+
+
+ +
+
+nice_date([$bad_date = ''[, $format = FALSE]])
+
+++ + + + + + + + +
Parameters:
    +
  • $bad_date (int) – The terribly formatted date-like string
  • +
  • $format (string) – Date format to return (same as PHP’s date() function)
  • +
+
Returns:

Formatted date

+
Return type:

string

+
+

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.

+

Example:

+
$bad_date = '199605';
+// Should Produce: 1996-05-01
+$better_date = nice_date($bad_date, 'Y-m-d');
+
+$bad_date = '9-11-2001';
+// Should Produce: 2001-09-11
+$better_date = nice_date($bad_date, 'Y-m-d');
+
+
+
+

Note

+

This function is DEPRECATED. Use PHP’s native DateTime class instead.

+
+
+ +
+
+timespan([$seconds = 1[, $time = ''[, $units = '']]])
+
+++ + + + + + + + +
Parameters:
    +
  • $seconds (int) – Number of seconds
  • +
  • $time (string) – UNIX timestamp
  • +
  • $units (int) – Number of time units to display
  • +
+
Returns:

Formatted time difference

+
Return type:

string

+
+

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

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

The first parameter must contain a UNIX timestamp. +The second parameter must contain a timestamp that is greater that the +first timestamp. +The thirdparameter is optional and limits the number of time units to display.

+

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();
+$units = 2;
+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

+
+
+ +
+
+days_in_month([$month = 0[, $year = '']])
+
+++ + + + + + + + +
Parameters:
    +
  • $month (int) – a numeric month
  • +
  • $year (int) – a numeric year
  • +
+
Returns:

Count of days in the specified month

+
Return type:

int

+
+

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

+

Example:

+
echo days_in_month(06, 2005);
+
+
+

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

+
+

Note

+

This function will alias the native cal_days_in_month(), if +it is available.

+
+
+ +
+
+date_range([$unix_start = ''[, $mixed = ''[, $is_unix = TRUE[, $format = 'Y-m-d']]]])
+
+++ + + + + + + + +
Parameters:
    +
  • $unix_start (int) – UNIX timestamp of the range start date
  • +
  • $mixed (int) – UNIX timestamp of the range end date or interval in days
  • +
  • $is_unix (bool) – set to FALSE if $mixed is not a timestamp
  • +
  • $format (string) – Output date format, same as in date()
  • +
+
Returns:

An array of dates

+
Return type:

array

+
+

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:";
+foreach ($range as $date)
+{
+        echo $date."\n";
+}
+
+
+
+ +
+
+timezones([$tz = ''])
+
+++ + + + + + + + +
Parameters:
    +
  • $tz (string) – A numeric timezone
  • +
+
Returns:

Hour difference from UTC

+
Return type:

int

+
+

Takes a timezone reference (for a list of valid timezones, see the +“Timezone Reference” below) and returns the number of hours offset from +UTC.

+

Example:

+
echo timezones('UM5');
+
+
+

This function is useful when used with timezone_menu().

+
+ +
+
+timezone_menu([$default = 'UTC'[, $class = ''[, $name = 'timezones'[, $attributes = '']]]])
+
+++ + + + + + + + +
Parameters:
    +
  • $default (string) – Timezone
  • +
  • $class (string) – Class name
  • +
  • $name (string) – Menu name
  • +
  • $attributes (mixed) – HTML attributes
  • +
+
Returns:

HTML drop down menu with time zones

+
Return type:

string

+
+

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

+
+ +

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

+

The first parameter lets you set the “selected” state of the menu. For +example, to set Pacific time as the default you will do this:

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

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

+

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

+

The fourth parameter lets you set one or more attributes on the generated select tag.

+
+

Note

+

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

+
+
+ +
+
+

Timezone Reference

+

The following table indicates each timezone and its location.

+

Note some of the location lists have been abridged for clarity and formatting.

+ ++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Time ZoneLocation
UM12(UTC - 12:00) Baker/Howland Island
UM11(UTC - 11:00) Samoa Time Zone, Niue
UM10(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 - 07: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
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
UM1(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
UP45(UTC +4:30) Afghanistan
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
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
UP875(UTC +8:45) Australian Central Western Standard Time
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
UP11(UTC +11:00) Srednekolymsk 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
UP13(UTC +13:00) Phoenix Islands Time, Tonga
UP14(UTC +14:00) Line Islands
+
+
+ + +
+
+ + + + +
+ +
+

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/directory_helper.html b/user_guide/helpers/directory_helper.html new file mode 100644 index 000000000..eed0d9f63 --- /dev/null +++ b/user_guide/helpers/directory_helper.html @@ -0,0 +1,587 @@ + + + + + + + + + + Directory Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Directory Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

Directory Helper

+

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

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+directory_map($source_dir[, $directory_depth = 0[, $hidden = FALSE]])
+
+++ + + + + + + + +
Parameters:
    +
  • $source_dir (string) – Path to the source directory
  • +
  • $directory_depth (int) – Depth of directories to traverse (0 = fully recursive, 1 = current dir, etc)
  • +
  • $hidden (bool) – Whether to include hidden directories
  • +
+
Returns:

An array of files

+
Return type:

array

+
+

Examples:

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

Note

+

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

+
+

Sub-folders contained within the directory will be mapped as well. If +you wish to control the recursion depth, you can do so using the second +parameter (integer). A depth of 1 will only map the top level directory:

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

By default, hidden files will not be included in the returned array. To +override this behavior, you may set a third parameter to true (boolean):

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

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

+
Array (
+        [libraries] => Array
+                (
+                        [0] => benchmark.html
+                        [1] => config.html
+                        ["database/"] => Array
+                                (
+                                        [0] => query_builder.html
+                                        [1] => binds.html
+                                        [2] => configuration.html
+                                        [3] => connecting.html
+                                        [4] => examples.html
+                                        [5] => fields.html
+                                        [6] => index.html
+                                        [7] => queries.html
+                                )
+                        [2] => email.html
+                        [3] => file_uploading.html
+                        [4] => image_lib.html
+                        [5] => input.html
+                        [6] => language.html
+                        [7] => loader.html
+                        [8] => pagination.html
+                        [9] => uri.html
+                )
+
+
+
+ +
+
+ + +
+
+ + + + +
+ +
+

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/download_helper.html b/user_guide/helpers/download_helper.html new file mode 100644 index 000000000..daa30b857 --- /dev/null +++ b/user_guide/helpers/download_helper.html @@ -0,0 +1,556 @@ + + + + + + + + + + Download Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Download Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

Download Helper

+

The Download Helper lets you download data to your desktop.

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+force_download([$filename = ''[, $data = ''[, $set_mime = FALSE]]])
+
+++ + + + + + +
Parameters:
    +
  • $filename (string) – Filename
  • +
  • $data (mixed) – File contents
  • +
  • $set_mime (bool) – Whether to try to send the actual MIME type
  • +
+
Return type:

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.

+

If you set the second parameter to NULL and $filename is an existing, readable +file path, then its content will be read instead.

+

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 +do the following:

+
// Contents of photo.jpg will be automatically read
+force_download('/path/to/photo.jpg', NULL);
+
+
+
+ +
+
+ + +
+
+ + + + +
+ +
+

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/email_helper.html b/user_guide/helpers/email_helper.html new file mode 100644 index 000000000..a534782d5 --- /dev/null +++ b/user_guide/helpers/email_helper.html @@ -0,0 +1,598 @@ + + + + + + + + + + Email Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Email Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

Email Helper

+

The Email Helper provides some assistive functions for working with +Email. For a more robust email solution, see CodeIgniter’s Email +Class.

+
+

Important

+

The Email helper is DEPRECATED and is currently +only kept for backwards compatibility.

+
+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+valid_email($email)
+
+++ + + + + + + + +
Parameters:
    +
  • $email (string) – E-mail address
  • +
+
Returns:

TRUE if a valid email is supplied, FALSE otherwise

+
Return type:

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.

+

Example:

+
if (valid_email('email@somesite.com'))
+{
+        echo 'email is valid';
+}
+else
+{
+        echo 'email is not valid';
+}
+
+
+
+

Note

+

All that this function does is to use PHP’s native filter_var():

+
(bool) filter_var($email, FILTER_VALIDATE_EMAIL);
+
+
+
+
+ +
+
+send_email($recipient, $subject, $message)
+
+++ + + + + + + + +
Parameters:
    +
  • $recipient (string) – E-mail address
  • +
  • $subject (string) – Mail subject
  • +
  • $message (string) – Message body
  • +
+
Returns:

TRUE if the mail was successfully sent, FALSE in case of an error

+
Return type:

bool

+
+

Sends an email using PHP’s native 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 Email Library.

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

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/file_helper.html b/user_guide/helpers/file_helper.html new file mode 100644 index 000000000..f48770ebf --- /dev/null +++ b/user_guide/helpers/file_helper.html @@ -0,0 +1,829 @@ + + + + + + + + + + File Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • File Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

File Helper

+

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

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+read_file($file)
+
+++ + + + + + + + +
Parameters:
    +
  • $file (string) – File path
  • +
+
Returns:

File contents or FALSE on failure

+
Return type:

string

+
+

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

+

Example:

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

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

+
+

Note

+

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

+
+
+

Note

+

This function is DEPRECATED. Use the native file_get_contents() +instead.

+
+
+

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[, $mode = 'wb'])
+
+++ + + + + + + + +
Parameters:
    +
  • $path (string) – File path
  • +
  • $data (string) – Data to write to file
  • +
  • $mode (string) – fopen() mode
  • +
+
Returns:

TRUE if the write was successful, FALSE in case of an error

+
Return type:

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))
+{
+        echo 'Unable to write the file';
+}
+else
+{
+        echo 'File written!';
+}
+
+
+

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 +for mode options.

+
+

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.

+
+
+

Note

+

This function acquires an exclusive lock on the file while writing to it.

+
+
+ +
+
+delete_files($path[, $del_dir = FALSE[, $htdocs = FALSE]])
+
+++ + + + + + + + +
Parameters:
    +
  • $path (string) – Directory path
  • +
  • $del_dir (bool) – Whether to also delete directories
  • +
  • $htdocs (bool) – Whether to skip deleting .htaccess and index page files
  • +
+
Returns:

TRUE on success, FALSE in case of an error

+
Return type:

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:

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

Note

+

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

+
+
+ +
+
+get_filenames($source_dir[, $include_path = FALSE])
+
+++ + + + + + + + +
Parameters:
    +
  • $source_dir (string) – Directory path
  • +
  • $include_path (bool) – Whether to include the path as part of the filenames
  • +
+
Returns:

An array of file names

+
Return type:

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.

+

Example:

+
$controllers = get_filenames(APPPATH.'controllers/');
+
+
+
+ +
+
+get_dir_file_info($source_dir, $top_level_only)
+
+++ + + + + + + + +
Parameters:
    +
  • $source_dir (string) – Directory path
  • +
  • $top_level_only (bool) – Whether to look only at the specified directory (excluding sub-directories)
  • +
+
Returns:

An array containing info on the supplied directory’s contents

+
Return type:

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($file[, $returned_values = array('name', 'server_path', 'size', 'date')])
+
+++ + + + + + + + +
Parameters:
    +
  • $file (string) – File path
  • +
  • $returned_values (array) – What type of info to return
  • +
+
Returns:

An array containing info on the specified file or FALSE on failure

+
Return type:

array

+
+

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.

+

Valid $returned_values options are: name, size, date, readable, writeable, +executable and fileperms.

+
+ +
+
+get_mime_by_extension($filename)
+
+++ + + + + + + + +
Parameters:
    +
  • $filename (string) – File name
  • +
+
Returns:

MIME type string or FALSE on failure

+
Return type:

string

+
+

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);
+
+
+
+

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($perms)
+
+++ + + + + + + + +
Parameters:
    +
  • $perms (int) – Permissions
  • +
+
Returns:

Symbolic permissions string

+
Return type:

string

+
+

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)
+
+++ + + + + + + + +
Parameters:
    +
  • $perms (int) – Permissions
  • +
+
Returns:

Octal permissions string

+
Return type:

string

+
+

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

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/form_helper.html b/user_guide/helpers/form_helper.html new file mode 100644 index 000000000..e7bf03210 --- /dev/null +++ b/user_guide/helpers/form_helper.html @@ -0,0 +1,1598 @@ + + + + + + + + + + Form Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Form Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

Form Helper

+

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

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Escaping field values

+

You may need to use HTML and characters such as quotes within your form +elements. In order to do that safely, you’ll need to use +common function +html_escape().

+

Consider the following example:

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

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

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

Note

+

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

+
+
+
+

Available Functions

+

The following functions are available:

+
+
+form_open([$action = ''[, $attributes = ''[, $hidden = array()]]])
+
+++ + + + + + + + +
Parameters:
    +
  • $action (string) – Form action/target URI string
  • +
  • $attributes (array) – HTML attributes
  • +
  • $hidden (array) – An array of hidden fields’ definitions
  • +
+
Returns:

An HTML form opening tag

+
Return type:

string

+
+

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.

+

Here’s a simple example:

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

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

+
<form method="post" accept-charset="utf-8" action="http://example.com/index.php/email/send">
+
+
+

Adding Attributes

+
+

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

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

Alternatively, you can specify the second parameter as a string:

+
echo form_open('email/send', 'class="email" id="myform"');
+
+
+

The above examples 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 = array('username' => 'Joe', 'member_id' => '234');
+echo form_open('email/send', '', $hidden);
+
+
+

You can skip the second parameter by passing any falsy value to it.

+

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" />
+        <input type="hidden" name="member_id" value="234" />
+
+
+
+
+ +
+
+form_open_multipart([$action = ''[, $attributes = array()[, $hidden = array()]]])
+
+++ + + + + + + + +
Parameters:
    +
  • $action (string) – Form action/target URI string
  • +
  • $attributes (array) – HTML attributes
  • +
  • $hidden (array) – An array of hidden fields’ definitions
  • +
+
Returns:

An HTML multipart form opening tag

+
Return type:

string

+
+

This function is absolutely identical to 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($name[, $value = ''])
+
+++ + + + + + + + +
Parameters:
    +
  • $name (string) – Field name
  • +
  • $value (string) – Field value
  • +
+
Returns:

An HTML hidden input field tag

+
Return type:

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:

+
$data = array(
+        'name'  => 'John Doe',
+        'email' => 'john@example.com',
+        'url'   => 'http://example.com'
+);
+
+echo form_hidden($data);
+
+/*
+        Would produce:
+        <input type="hidden" name="name" value="John Doe" />
+        <input type="hidden" name="email" value="john@example.com" />
+        <input type="hidden" name="url" value="http://example.com" />
+*/
+
+
+

You can also pass an associative array to the value field:

+
$data = array(
+        '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:

+
$data = array(
+        'type'  => 'hidden',
+        'name'  => 'email',
+        'id'    => 'hiddenemail',
+        'value' => 'john@example.com',
+        'class' => 'hiddenemail'
+);
+
+echo form_input($data);
+
+/*
+        Would produce:
+
+        <input type="hidden" name="email" value="john@example.com" id="hiddenemail" class="hiddenemail" />
+*/
+
+
+
+ +
+
+form_input([$data = ''[, $value = ''[, $extra = '']]])
+
+++ + + + + + + + +
Parameters:
    +
  • $data (array) – Field attributes data
  • +
  • $value (string) – Field value
  • +
  • $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string
  • +
+
Returns:

An HTML text input field tag

+
Return type:

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:

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

If you would like your form to contain some additional data, like +JavaScript, you can pass it as a string in the third parameter:

+
$js = 'onClick="some_function()"';
+echo form_input('username', 'johndoe', $js);
+
+
+

Or you can pass it as an array:

+
$js = array('onClick' => 'some_function();');
+echo form_input('username', 'johndoe', $js);
+
+
+
+ +
+
+form_password([$data = ''[, $value = ''[, $extra = '']]])
+
+++ + + + + + + + +
Parameters:
    +
  • $data (array) – Field attributes data
  • +
  • $value (string) – Field value
  • +
  • $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string
  • +
+
Returns:

An HTML password input field tag

+
Return type:

string

+
+

This function is identical in all respects to the form_input() +function above except that it uses the “password” input type.

+
+ +
+
+form_upload([$data = ''[, $value = ''[, $extra = '']]])
+
+++ + + + + + + + +
Parameters:
    +
  • $data (array) – Field attributes data
  • +
  • $value (string) – Field value
  • +
  • $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string
  • +
+
Returns:

An HTML file upload input field tag

+
Return type:

string

+
+

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.

+
+ +
+
+form_textarea([$data = ''[, $value = ''[, $extra = '']]])
+
+++ + + + + + + + +
Parameters:
    +
  • $data (array) – Field attributes data
  • +
  • $value (string) – Field value
  • +
  • $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string
  • +
+
Returns:

An HTML textarea tag

+
Return type:

string

+
+

This function is identical in all respects to the form_input() +function above except that it generates a “textarea” type.

+
+

Note

+

Instead of the maxlength and size attributes in the above example, +you will instead specify rows and cols.

+
+
+ +
+
+form_dropdown([$name = ''[, $options = array()[, $selected = array()[, $extra = '']]]])
+
+++ + + + + + + + +
Parameters:
    +
  • $name (string) – Field name
  • +
  • $options (array) – An associative array of options to be listed
  • +
  • $selected (array) – List of fields to mark with the selected attribute
  • +
  • $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string
  • +
+
Returns:

An HTML dropdown select field tag

+
Return type:

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:

+
$options = array(
+        'small'         => 'Small Shirt',
+        'med'           => 'Medium Shirt',
+        'large'         => 'Large Shirt',
+        'xlarge'        => 'Extra Large Shirt',
+);
+
+$shirts_on_sale = array('small', 'large');
+echo form_dropdown('shirts', $options, 'large');
+
+/*
+        Would produce:
+
+        <select name="shirts">
+                <option value="small">Small Shirt</option>
+                <option value="med">Medium  Shirt</option>
+                <option value="large" selected="selected">Large Shirt</option>
+                <option value="xlarge">Extra Large Shirt</option>
+        </select>
+*/
+
+echo form_dropdown('shirts', $options, $shirts_on_sale);
+
+/*
+        Would produce:
+
+        <select name="shirts" multiple="multiple">
+                <option value="small" selected="selected">Small Shirt</option>
+                <option value="med">Medium  Shirt</option>
+                <option value="large" selected="selected">Large Shirt</option>
+                <option value="xlarge">Extra Large Shirt</option>
+        </select>
+*/
+
+
+

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:

+
$js = 'id="shirts" onChange="some_function();"';
+echo form_dropdown('shirts', $options, 'large', $js);
+
+
+

Or you can pass it as an array:

+
$js = array(
+        'id'       => 'shirts',
+        'onChange' => 'some_function();'
+);
+echo form_dropdown('shirts', $options, 'large', $js);
+
+
+

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([$name = ''[, $options = array()[, $selected = array()[, $extra = '']]]])
+
+++ + + + + + + + +
Parameters:
    +
  • $name (string) – Field name
  • +
  • $options (array) – An associative array of options to be listed
  • +
  • $selected (array) – List of fields to mark with the selected attribute
  • +
  • $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string
  • +
+
Returns:

An HTML dropdown multiselect field tag

+
Return type:

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

+
+ +
+
+form_fieldset([$legend_text = ''[, $attributes = array()]])
+
+++ + + + + + + + +
Parameters:
    +
  • $legend_text (string) – Text to put in the <legend> tag
  • +
  • $attributes (array) – Attributes to be set on the <fieldset> tag
  • +
+
Returns:

An HTML fieldset opening tag

+
Return type:

string

+
+

Lets you generate fieldset/legend fields.

+

Example:

+
echo form_fieldset('Address Information');
+echo "<p>fieldset content here</p>\n";
+echo form_fieldset_close();
+
+/*
+        Produces:
+
+                <fieldset>
+                        <legend>Address Information</legend>
+                                <p>form content here</p>
+                </fieldset>
+*/
+
+
+

Similar to other functions, you can submit an associative array in the +second parameter if you prefer to set additional attributes:

+
$attributes = array(
+        'id'    => 'address_info',
+        'class' => 'address_info'
+);
+
+echo form_fieldset('Address Information', $attributes);
+echo "<p>fieldset content here</p>\n";
+echo form_fieldset_close();
+
+/*
+        Produces:
+
+        <fieldset id="address_info" class="address_info">
+                <legend>Address Information</legend>
+                <p>form content here</p>
+        </fieldset>
+*/
+
+
+
+ +
+
+form_fieldset_close([$extra = ''])
+
+++ + + + + + + + +
Parameters:
    +
  • $extra (string) – Anything to append after the closing tag, as is
  • +
+
Returns:

An HTML fieldset closing tag

+
Return type:

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>';
+echo form_fieldset_close($string);
+// Would produce: </fieldset></div></div>
+
+
+
+ +
+
+form_checkbox([$data = ''[, $value = ''[, $checked = FALSE[, $extra = '']]]])
+
+++ + + + + + + + +
Parameters:
    +
  • $data (array) – Field attributes data
  • +
  • $value (string) – Field value
  • +
  • $checked (bool) – Whether to mark the checkbox as being checked
  • +
  • $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string
  • +
+
Returns:

An HTML checkbox input tag

+
Return type:

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" />
+
+
+

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

+

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

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

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);
+
+
+

Or you can pass it as an array:

+
$js = array('onClick' => 'some_function();');
+echo form_checkbox('newsletter', 'accept', TRUE, $js);
+
+
+
+ +
+
+form_radio([$data = ''[, $value = ''[, $checked = FALSE[, $extra = '']]]])
+
+++ + + + + + + + +
Parameters:
    +
  • $data (array) – Field attributes data
  • +
  • $value (string) – Field value
  • +
  • $checked (bool) – Whether to mark the radio button as being checked
  • +
  • $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string
  • +
+
Returns:

An HTML radio input tag

+
Return type:

string

+
+

This function is identical in all respects to the form_checkbox() +function above except that it uses the “radio” input type.

+
+ +
+
+form_label([$label_text = ''[, $id = ''[, $attributes = array()]]])
+
+++ + + + + + + + +
Parameters:
    +
  • $label_text (string) – Text to put in the <label> tag
  • +
  • $id (string) – ID of the form element that we’re making a label for
  • +
  • $attributes (mixed) – HTML attributes
  • +
+
Returns:

An HTML field label tag

+
Return type:

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

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',
+        'style' => 'color: #000;'
+);
+
+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([$data = ''[, $value = ''[, $extra = '']]])
+
+++ + + + + + + + +
Parameters:
    +
  • $data (string) – Button name
  • +
  • $value (string) – Button value
  • +
  • $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string
  • +
+
Returns:

An HTML input submit tag

+
Return type:

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([$data = ''[, $value = ''[, $extra = '']]])
+
+++ + + + + + + + +
Parameters:
    +
  • $data (string) – Button name
  • +
  • $value (string) – Button value
  • +
  • $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string
  • +
+
Returns:

An HTML input reset button tag

+
Return type:

string

+
+

Lets you generate a standard reset button. Use is identical to +form_submit().

+
+ +
+
+form_button([$data = ''[, $content = ''[, $extra = '']]])
+
+++ + + + + + + + +
Parameters:
    +
  • $data (string) – Button name
  • +
  • $content (string) – Button label
  • +
  • $extra (mixed) – Extra attributes to be added to the tag either as an array or a literal string
  • +
+
Returns:

An HTML button tag

+
Return type:

string

+
+

Lets you generate a standard button element. You can minimally pass the +button name and content in the first and second parameter:

+
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'
+);
+
+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:

+
$js = 'onClick="some_function()"';
+echo form_button('mybutton', 'Click Me', $js);
+
+
+
+ +
+
+form_close([$extra = ''])
+
+++ + + + + + + + +
Parameters:
    +
  • $extra (string) – Anything to append after the closing tag, as is
  • +
+
Returns:

An HTML form closing tag

+
Return type:

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:

+
$string = '</div></div>';
+echo form_close($string);
+// Would produce:  </form> </div></div>
+
+
+
+ +
+
+set_value($field[, $default = ''[, $html_escape = TRUE]])
+
+++ + + + + + + + +
Parameters:
    +
  • $field (string) – Field name
  • +
  • $default (string) – Default value
  • +
  • $html_escape (bool) – Whether to turn off HTML escaping of the value
  • +
+
Returns:

Field value

+
Return type:

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. The third (optional) parameter allows you to turn off HTML escaping +of the value, in case you need to use this function in combination with +i.e. form_input() and avoid double-escaping.

+

Example:

+
<input type="text" name="quantity" value="<?php echo set_value('quantity', '0'); ?>" size="50" />
+
+
+

The above form will show “0” when loaded for the first time.

+
+

Note

+

If you’ve loaded the Form Validation Library and +have set a validation rule for the field name in use with this helper, then it will +forward the call to the Form Validation Library’s +own set_value() method. Otherwise, this function looks in $_POST for the +field value.

+
+
+ +
+
+set_select($field[, $value = ''[, $default = FALSE]])
+
+++ + + + + + + + +
Parameters:
    +
  • $field (string) – Field name
  • +
  • $value (string) – Value to check for
  • +
  • $default (string) – Whether the value is also a default one
  • +
+
Returns:

‘selected’ attribute or an empty string

+
Return type:

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

+

Example:

+
<select name="myselect">
+        <option value="one" <?php echo  set_select('myselect', 'one', TRUE); ?> >One</option>
+        <option value="two" <?php echo  set_select('myselect', 'two'); ?> >Two</option>
+        <option value="three" <?php echo  set_select('myselect', 'three'); ?> >Three</option>
+</select>
+
+
+
+ +
+
+set_checkbox($field[, $value = ''[, $default = FALSE]])
+
+++ + + + + + + + +
Parameters:
    +
  • $field (string) – Field name
  • +
  • $value (string) – Value to check for
  • +
  • $default (string) – Whether the value is also a default one
  • +
+
Returns:

‘checked’ attribute or an empty string

+
Return type:

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:

+
<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'); ?> />
+
+
+
+ +
+
+set_radio($field[, $value = ''[, $default = FALSE]])
+
+++ + + + + + + + +
Parameters:
    +
  • $field (string) – Field name
  • +
  • $value (string) – Value to check for
  • +
  • $default (string) – Whether the value is also a default one
  • +
+
Returns:

‘checked’ attribute or an empty string

+
Return type:

string

+
+

Permits you to display radio buttons in the state they were submitted. +This function is identical to the 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.

+
+
+ +
+
+form_error([$field = ''[, $prefix = ''[, $suffix = '']]])
+
+++ + + + + + + + +
Parameters:
    +
  • $field (string) – Field name
  • +
  • $prefix (string) – Error opening tag
  • +
  • $suffix (string) – Error closing tag
  • +
+
Returns:

HTML-formatted form validation error message(s)

+
Return type:

string

+
+

Returns a validation error message from the Form Validation Library, associated with the specified field name. +You can optionally specify opening and closing tag(s) to put around the error +message.

+

Example:

+
// Assuming that the 'username' field value was incorrect:
+echo form_error('myfield', '<div class="error">', '</div>');
+
+// Would produce: <div class="error">Error message associated with the "username" field.</div>
+
+
+
+ +
+
+validation_errors([$prefix = ''[, $suffix = '']])
+
+++ + + + + + + + +
Parameters:
    +
  • $prefix (string) – Error opening tag
  • +
  • $suffix (string) – Error closing tag
  • +
+
Returns:

HTML-formatted form validation error message(s)

+
Return type:

string

+
+

Similarly to the form_error() function, returns all validation +error messages produced by the Form Validation Library, 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>
+
+ */
+
+
+
+ +
+
+form_prep($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Value to escape
  • +
+
Returns:

Escaped value

+
Return type:

string

+
+

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

+
+

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.

+
+
+

Note

+

This function is DEPRECATED and is just an alias for +common function +html_escape() - please use that instead.

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

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/html_helper.html b/user_guide/helpers/html_helper.html new file mode 100644 index 000000000..c40615033 --- /dev/null +++ b/user_guide/helpers/html_helper.html @@ -0,0 +1,1091 @@ + + + + + + + + + + HTML Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • HTML Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

HTML Helper

+

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

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+heading([$data = ''[, $h = '1'[, $attributes = '']]])
+
+++ + + + + + + + +
Parameters:
    +
  • $data (string) – Content
  • +
  • $h (string) – Heading level
  • +
  • $attributes (mixed) – HTML attributes
  • +
+
Returns:

HTML heading tag

+
Return type:

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);
+
+
+

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 accepts either a string +or an array:

+
echo heading('Welcome!', 3, 'class="pink"');
+echo heading('How are you?', 4, array('id' => 'question', 'class' => 'green'));
+
+
+

The above code produces:

+
<h3 class="pink">Welcome!<h3>
+<h4 id="question" class="green">How are you?</h4>
+
+
+
+ +
+
+img([$src = ''[, $index_page = FALSE[, $attributes = '']]])
+
+++ + + + + + + + +
Parameters:
    +
  • $src (string) – Image source data
  • +
  • $index_page (bool) – Whether to treat $src as a routed URI string
  • +
  • $attributes (array) – HTML attributes
  • +
+
Returns:

HTML image tag

+
Return type:

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:

+
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 +is not provided, CodeIgniter will generate an empty string.

+

Example:

+
$image_properties = array(
+        'src'   => '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" />
+
+
+
+ +
+ +
+++ + + + + + + + +
Parameters:
    +
  • $href (string) – What are we linking to
  • +
  • $rel (string) – Relation type
  • +
  • $type (string) – Type of the related document
  • +
  • $title (string) – Link title
  • +
  • $media (string) – Media type
  • +
  • $index_page (bool) – Whether to treat $src as a routed URI string
  • +
+
Returns:

HTML link tag

+
Return type:

string

+
+

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:

+
echo link_tag('css/mystyles.css');
+// gives <link href="http://site.com/css/mystyles.css" rel="stylesheet" type="text/css" />
+
+
+

Further examples:

+
echo link_tag('favicon.ico', 'shortcut icon', 'image/ico');
+// <link href="http://site.com/favicon.ico" rel="shortcut icon" type="image/ico" />
+
+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'
+);
+
+echo link_tag($link);
+// <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" />
+
+
+
+ +
+
+ul($list[, $attributes = ''])
+
+++ + + + + + + + +
Parameters:
    +
  • $list (array) – List entries
  • +
  • $attributes (array) – HTML attributes
  • +
+
Returns:

HTML-formatted unordered list

+
Return type:

string

+
+

Permits you to generate unordered HTML lists from simple or +multi-dimensional arrays. Example:

+
$list = array(
+        'red',
+        'blue',
+        'green',
+        'yellow'
+);
+
+$attributes = array(
+        'class' => 'boldlist',
+        'id'    => 'mylist'
+);
+
+echo ul($list, $attributes);
+
+
+

The above code will produce this:

+
<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:

+
$attributes = array(
+        'class' => 'boldlist',
+        'id'    => 'mylist'
+);
+
+$list = array(
+        'colors'  => array(
+                'red',
+                'blue',
+                'green'
+        ),
+        'shapes'  => array(
+                'round',
+                'square',
+                'circles' => array(
+                        'ellipse',
+                        'oval',
+                        'sphere'
+                )
+        ),
+        'moods'  => array(
+                'happy',
+                'upset' => array(
+                        'defeated' => array(
+                                'dejected',
+                                'disheartened',
+                                'depressed'
+                        ),
+                        'annoyed',
+                        'cross',
+                        'angry'
+                )
+        )
+);
+
+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>
+                                                        <li>dejected</li>
+                                                        <li>disheartened</li>
+                                                        <li>depressed</li>
+                                                </ul>
+                                        </li>
+                                        <li>annoyed</li>
+                                        <li>cross</li>
+                                        <li>angry</li>
+                                </ul>
+                        </li>
+                </ul>
+        </li>
+</ul>
+
+
+
+ +
+
+ol($list, $attributes = '')
+
+++ + + + + + + + +
Parameters:
    +
  • $list (array) – List entries
  • +
  • $attributes (array) – HTML attributes
  • +
+
Returns:

HTML-formatted ordered list

+
Return type:

string

+
+

Identical to ul(), only it produces the <ol> tag for +ordered lists instead of <ul>.

+
+ +
+
+meta([$name = ''[, $content = ''[, $type = 'name'[, $newline = "n"]]]])
+
+++ + + + + + + + +
Parameters:
    +
  • $name (string) – Meta name
  • +
  • $content (string) – Meta content
  • +
  • $type (string) – Meta type
  • +
  • $newline (string) – Newline character
  • +
+
Returns:

HTML meta tag

+
Return type:

string

+
+

Helps you generate meta tags. You can pass strings to the function, or +simple arrays, or multidimensional ones.

+

Examples:

+
echo meta('description', 'My Great site');
+// Generates:  <meta name="description" content="My Great Site" />
+
+echo meta('Content-type', 'text/html; charset=utf-8', 'equiv');
+// Note the third parameter.  Can be "equiv" or "name"
+// Generates:  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+
+echo meta(array('name' => 'robots', 'content' => 'no-cache'));
+// Generates:  <meta name="robots" content="no-cache" />
+
+$meta = array(
+        array(
+                'name' => 'robots',
+                'content' => 'no-cache'
+        ),
+        array(
+                'name' => 'description',
+                'content' => 'My Great Site'
+        ),
+        array(
+                'name' => 'keywords',
+                'content' => 'love, passion, intrigue, deception'
+        ),
+        array(
+                'name' => 'robots',
+                'content' => 'no-cache'
+        ),
+        array(
+                'name' => 'Content-type',
+                'content' => 'text/html; charset=utf-8', 'type' => 'equiv'
+        )
+);
+
+echo meta($meta);
+// Generates:
+// <meta name="robots" content="no-cache" />
+// <meta name="description" content="My Great Site" />
+// <meta name="keywords" content="love, passion, intrigue, deception" />
+// <meta name="robots" content="no-cache" />
+// <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+
+
+
+ +
+
+doctype([$type = 'xhtml1-strict'])
+
+++ + + + + + + + +
Parameters:
    +
  • $type (string) – Doctype name
  • +
+
Returns:

HTML DocType tag

+
Return type:

string

+
+

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">
+
+echo doctype('html4-trans'); // <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+
+
+

The following is a list of doctype choices. These are configurable, and +pulled from application/config/doctypes.php

+ +++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Document typeOptionResult
XHTML 1.1xhtml11<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN” “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
XHTML 1.0 Strictxhtml1-strict<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
XHTML 1.0 Transitionalxhtml1-trans<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
XHTML 1.0 Framesetxhtml1-frame<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Frameset//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd”>
XHTML Basic 1.1xhtml-basic11<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML Basic 1.1//EN” “http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd”>
HTML 5html5<!DOCTYPE html>
HTML 4 Stricthtml4-strict<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
HTML 4 Transitionalhtml4-trans<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
HTML 4 Framesethtml4-frame<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN” “http://www.w3.org/TR/html4/frameset.dtd”>
MathML 1.01mathml1<!DOCTYPE math SYSTEM “http://www.w3.org/Math/DTD/mathml1/mathml.dtd”>
MathML 2.0mathml2<!DOCTYPE math PUBLIC “-//W3C//DTD MathML 2.0//EN” “http://www.w3.org/Math/DTD/mathml2/mathml2.dtd”>
SVG 1.0svg10<!DOCTYPE svg PUBLIC “-//W3C//DTD SVG 1.0//EN” “http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd”>
SVG 1.1 Fullsvg11<!DOCTYPE svg PUBLIC “-//W3C//DTD SVG 1.1//EN” “http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd”>
SVG 1.1 Basicsvg11-basic<!DOCTYPE svg PUBLIC “-//W3C//DTD SVG 1.1 Basic//EN” “http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd”>
SVG 1.1 Tinysvg11-tiny<!DOCTYPE svg PUBLIC “-//W3C//DTD SVG 1.1 Tiny//EN” “http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd”>
XHTML+MathML+SVG (XHTML host)xhtml-math-svg-xh<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN” “http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd”>
XHTML+MathML+SVG (SVG host)xhtml-math-svg-sh<!DOCTYPE svg:svg PUBLIC “-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN” “http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd”>
XHTML+RDFa 1.0xhtml-rdfa-1<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML+RDFa 1.0//EN” “http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd”>
XHTML+RDFa 1.1xhtml-rdfa-2<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML+RDFa 1.1//EN” “http://www.w3.org/MarkUp/DTD/xhtml-rdfa-2.dtd”>
+
+ +
+
+br([$count = 1])
+
+++ + + + + + + + +
Parameters:
    +
  • $count (int) – Number of times to repeat the tag
  • +
+
Returns:

HTML line break tag

+
Return type:

string

+
+

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

+
echo br(3);
+
+
+

The above would produce:

+
<br /><br /><br />
+
+
+
+

Note

+

This function is DEPRECATED. Use the native str_repeat() +in combination with <br /> instead.

+
+
+ +
+
+nbs([$num = 1])
+
+++ + + + + + + + +
Parameters:
    +
  • $num (int) – Number of space entities to produce
  • +
+
Returns:

A sequence of non-breaking space HTML entities

+
Return type:

string

+
+

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

+
echo nbs(3);
+
+
+

The above would produce:

+
&nbsp;&nbsp;&nbsp;
+
+
+
+

Note

+

This function is DEPRECATED. Use the native str_repeat() +in combination with &nbsp; instead.

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

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/index.html b/user_guide/helpers/index.html new file mode 100644 index 000000000..bc73f8eb4 --- /dev/null +++ b/user_guide/helpers/index.html @@ -0,0 +1,518 @@ + + + + + + + + + + Helpers — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+ +
+ + + + +
+ +
+

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/inflector_helper.html b/user_guide/helpers/inflector_helper.html new file mode 100644 index 000000000..3d1acb4d8 --- /dev/null +++ b/user_guide/helpers/inflector_helper.html @@ -0,0 +1,680 @@ + + + + + + + + + + Inflector Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Inflector Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

Inflector Helper

+

The Inflector Helper file contains functions that permits you to change +English words to plural, singular, camel case, etc.

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+singular($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
+
Returns:

A singular word

+
Return type:

string

+
+

Changes a plural word to singular. Example:

+
echo singular('dogs'); // Prints 'dog'
+
+
+
+ +
+
+plural($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
+
Returns:

A plural word

+
Return type:

string

+
+

Changes a singular word to plural. Example:

+
echo plural('dog'); // Prints 'dogs'
+
+
+
+ +
+
+camelize($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
+
Returns:

Camelized string

+
Return type:

string

+
+

Changes a string of words separated by spaces or underscores to camel +case. Example:

+
echo camelize('my_dog_spot'); // Prints 'myDogSpot'
+
+
+
+ +
+
+underscore($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
+
Returns:

String containing underscores instead of spaces

+
Return type:

string

+
+

Takes multiple words separated by spaces and underscores them. +Example:

+
echo underscore('my dog spot'); // Prints 'my_dog_spot'
+
+
+
+ +
+
+humanize($str[, $separator = '_'])
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
  • $separator (string) – Input separator
  • +
+
Returns:

Humanized string

+
Return type:

string

+
+

Takes multiple words separated by underscores and adds spaces between +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)
+
+++ + + + + + + + +
Parameters:
    +
  • $word (string) – Input string
  • +
+
Returns:

TRUE if the word is countable or FALSE if not

+
Return type:

bool

+
+

Checks if the given word has a plural version. Example:

+
is_countable('equipment'); // Returns FALSE
+
+
+
+ +
+
+ + +
+
+ + + + +
+ +
+

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/language_helper.html b/user_guide/helpers/language_helper.html new file mode 100644 index 000000000..4ca5548ca --- /dev/null +++ b/user_guide/helpers/language_helper.html @@ -0,0 +1,550 @@ + + + + + + + + + + Language Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Language Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

Language Helper

+

The Language Helper file contains functions that assist in working with +language files.

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+lang($line[, $for = ''[, $attributes = array()]])
+
+++ + + + + + + + +
Parameters:
    +
  • $line (string) – Language line key
  • +
  • $for (string) – HTML “for” attribute (ID of the element we’re creating a label for)
  • +
  • $attributes (array) – Any additional HTML attributes
  • +
+
Returns:

The language line; in an HTML label tag, if the $for parameter is not empty

+
Return type:

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 +CI_Lang::line().

+

Examples:

+
echo lang('language_key');
+// Outputs: Language line
+
+echo lang('language_key', 'form_item_id', array('class' => 'myClass'));
+// Outputs: <label for="form_item_id" class="myClass">Language line</label>
+
+
+
+ +
+
+ + +
+
+ + + + +
+ +
+

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/number_helper.html b/user_guide/helpers/number_helper.html new file mode 100644 index 000000000..5d6720522 --- /dev/null +++ b/user_guide/helpers/number_helper.html @@ -0,0 +1,559 @@ + + + + + + + + + + Number Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Number Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

Number Helper

+

The Number Helper file contains functions that help you work with +numeric data.

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+byte_format($num[, $precision = 1])
+
+++ + + + + + + + +
Parameters:
    +
  • $num (mixed) – Number of bytes
  • +
  • $precision (int) – Floating point precision
  • +
+
Returns:

Formatted data size string

+
Return type:

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(123456789123456789); // Returns 11,228.3 TB
+
+
+

An optional second parameter allows you to set the precision of the +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

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

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/path_helper.html b/user_guide/helpers/path_helper.html new file mode 100644 index 000000000..3d0fce9d5 --- /dev/null +++ b/user_guide/helpers/path_helper.html @@ -0,0 +1,557 @@ + + + + + + + + + + Path Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Path Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

Path Helper

+

The Path Helper file contains functions that permits you to work with +file paths on the server.

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+set_realpath($path[, $check_existance = FALSE])
+
+++ + + + + + + + +
Parameters:
    +
  • $path (string) – Path
  • +
  • $check_existance (bool) – Whether to check if the path actually exists
  • +
+
Returns:

An absolute path

+
Return type:

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); // 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);   // Prints '/path/to/non-exist-file.txt'
+
+$directory = '/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);      // Prints '/path/to/nowhere'
+
+
+
+ +
+
+ + +
+
+ + + + +
+ +
+

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/security_helper.html b/user_guide/helpers/security_helper.html new file mode 100644 index 000000000..736f44f57 --- /dev/null +++ b/user_guide/helpers/security_helper.html @@ -0,0 +1,669 @@ + + + + + + + + + + Security Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Security Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

Security Helper

+

The Security Helper file contains security related functions.

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+xss_clean($str[, $is_image = FALSE])
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input data
  • +
  • $is_image (bool) – Whether we’re dealing with an image
  • +
+
Returns:

XSS-clean string

+
Return type:

string

+
+

Provides Cross Site Script Hack filtering.

+

This function is an alias for CI_Input::xss_clean(). For more info, +please see the Input Library documentation.

+
+ +
+
+sanitize_filename($filename)
+
+++ + + + + + + + +
Parameters:
    +
  • $filename (string) – Filename
  • +
+
Returns:

Sanitized file name

+
Return type:

string

+
+

Provides protection against directory traversal.

+

This function is an alias for CI_Security::sanitize_filename(). +For more info, please see the Security Library +documentation.

+
+ +
+
+do_hash($str[, $type = 'sha1'])
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input
  • +
  • $type (string) – Algorithm
  • +
+
Returns:

Hex-formatted hash

+
Return type:

string

+
+

Permits you to create one way hashes suitable for encrypting +passwords. Will use SHA1 by default.

+

See hash_algos() +for a full list of supported algorithms.

+

Examples:

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

Note

+

This function was formerly named dohash(), which has been +removed in favor of do_hash().

+
+
+

Note

+

This function is DEPRECATED. Use the native hash() instead.

+
+
+ +
+
+strip_image_tags($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
+
Returns:

The input string with no image tags

+
Return type:

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 Security Library +documentation.

+
+ +
+
+encode_php_tags($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
+
Returns:

Safely formatted string

+
Return type:

string

+
+

This is a security function that converts PHP tags to entities.

+
+

Note

+

xss_clean() does this automatically, if you use it.

+
+

Example:

+
$string = encode_php_tags($string);
+
+
+
+ +
+
+ + +
+
+ + + + +
+ +
+

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/smiley_helper.html b/user_guide/helpers/smiley_helper.html new file mode 100644 index 000000000..0a0a7e106 --- /dev/null +++ b/user_guide/helpers/smiley_helper.html @@ -0,0 +1,708 @@ + + + + + + + + + + Smiley Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Smiley Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

Smiley Helper

+

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

+
+

Important

+

The Smiley helper is DEPRECATED and should not be used. +It is currently only kept for backwards compatibility.

+
+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Overview

+

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

+

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

+
+
+

Clickable Smileys Tutorial

+

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

+
+

Important

+

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

+
+
+

The Controller

+

In your application/controllers/ directory, create a file called +Smileys.php and place the code below in it.

+
+

Important

+

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

+
+

You’ll notice that in addition to the smiley helper, we are also using +the Table Class:

+
<?php
+
+class Smileys extends CI_Controller {
+
+        public function index()
+        {
+                $this->load->helper('smiley');
+                $this->load->library('table');
+
+                $image_array = get_clickable_smileys('http://example.com/images/smileys/', 'comments');
+                $col_array = $this->table->make_columns($image_array, 8);
+
+                $data['smiley_table'] = $this->table->generate($col_array);
+                $this->load->view('smiley_view', $data);
+        }
+
+}
+
+
+

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

+
<html>
+        <head>
+                <title>Smileys</title>
+                <?php echo smiley_js(); ?>
+        </head>
+        <body>
+                <form name="blog">
+                        <textarea name="comments" id="comments" cols="40" rows="4"></textarea>
+                </form>
+                <p>Click to insert a smiley!</p>
+                <?php echo $smiley_table; ?> </body> </html>
+                When you have created the above controller and view, load it by visiting http://www.example.com/index.php/smileys/
+        </body>
+</html>
+
+
+
+
+

Field Aliases

+

When making changes to a view it can be inconvenient to have the field +id in the controller. To work around this, you can give your smiley +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:

+
$image_array = smiley_js("comment_textarea_alias", "comments");
+
+
+
+
+
+

Available Functions

+
+
+get_clickable_smileys($image_url[, $alias = ''[, $smileys = NULL]])
+
+++ + + + + + + + +
Parameters:
    +
  • $image_url (string) – URL path to the smileys directory
  • +
  • $alias (string) – Field alias
  • +
+
Returns:

An array of ready to use smileys

+
Return type:

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_clickable_smileys('http://example.com/images/smileys/', 'comment');
+
+
+
+ +
+
+smiley_js([$alias = ''[, $field_id = ''[, $inline = TRUE]]])
+
+++ + + + + + + + +
Parameters:
    +
  • $alias (string) – Field alias
  • +
  • $field_id (string) – Field ID
  • +
  • $inline (bool) – Whether we’re inserting an inline smiley
  • +
+
Returns:

Smiley-enabling JavaScript code

+
Return type:

string

+
+

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(); ?>
+
+
+
+ +
+
+parse_smileys([$str = ''[, $image_url = ''[, $smileys = NULL]]])
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Text containing smiley codes
  • +
  • $image_url (string) – URL path to the smileys directory
  • +
  • $smileys (array) – An array of smileys
  • +
+
Returns:

Parsed smileys

+
Return type:

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 smileys: :-)  ;-)';
+$str = parse_smileys($str, 'http://example.com/images/smileys/');
+echo $str;
+
+
+
+ +
+
+ + +
+
+ + + + +
+ +
+

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/string_helper.html b/user_guide/helpers/string_helper.html new file mode 100644 index 000000000..094dee295 --- /dev/null +++ b/user_guide/helpers/string_helper.html @@ -0,0 +1,873 @@ + + + + + + + + + + String Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • String Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

String Helper

+

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

+
+

Important

+

Please note that these functions are NOT intended, nor +suitable to be used for any kind of security-related logic.

+
+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+random_string([$type = 'alnum'[, $len = 8]])
+
+++ + + + + + + + +
Parameters:
    +
  • $type (string) – Randomization type
  • +
  • $len (int) – Output string length
  • +
+
Returns:

A random string

+
Return type:

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: 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.
  • +
  • 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($str[, $separator = '_'[, $first = 1]])
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
  • $separator (string) – Separator to append a duplicate number with
  • +
  • $first (int) – Starting number
  • +
+
Returns:

An incremented string

+
Return type:

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:

+
echo increment_string('file', '_'); // "file_1"
+echo increment_string('file', '-', 2); // "file-2"
+echo increment_string('file_4'); // "file_5"
+
+
+
+ +
+
+alternator($args)
+
+++ + + + + + + + +
Parameters:
    +
  • $args (mixed) – A variable number of arguments
  • +
+
Returns:

Alternated string(s)

+
Return type:

mixed

+
+

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

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

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

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

Note

+

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

+
+
+ +
+
+repeater($data[, $num = 1])
+
+++ + + + + + + + +
Parameters:
    +
  • $data (string) – Input
  • +
  • $num (int) – Number of times to repeat
  • +
+
Returns:

Repeated string

+
Return type:

string

+
+

Generates repeating copies of the data you submit. Example:

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

The above would generate 30 newlines.

+
+

Note

+

This function is DEPRECATED. Use the native str_repeat() +instead.

+
+
+ +
+
+reduce_double_slashes($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
+
Returns:

A string with normalized slashes

+
Return type:

string

+
+

Converts double slashes in a string to a single slash, except those +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"
+
+
+
+ +
+
+strip_slashes($data)
+
+++ + + + + + + + +
Parameters:
    +
  • $data (mixed) – Input string or an array of strings
  • +
+
Returns:

String(s) with stripped slashes

+
Return type:

mixed

+
+

Removes any slashes from an array of strings.

+

Example:

+
$str = array(
+        'question'  => 'Is your name O\'reilly?',
+        'answer' => 'No, my name is O\'connor.'
+);
+
+$str = strip_slashes($str);
+
+
+

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($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
+
Returns:

Slash-trimmed string

+
Return type:

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($str[, $character = ''[, $trim = FALSE]])
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Text to search in
  • +
  • $character (string) – Character to reduce
  • +
  • $trim (bool) – Whether to also trim the specified character
  • +
+
Returns:

Reduced string

+
Return type:

string

+
+

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

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

If the third parameter is set to TRUE it will remove occurrences 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($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
+
Returns:

String with quotes converted to HTML entities

+
Return type:

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;"
+
+
+
+ +
+
+strip_quotes($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
+
Returns:

String with quotes stripped

+
Return type:

string

+
+

Removes single and double quotes from a string. Example:

+
$string = "Joe's \"dinner\"";
+$string = strip_quotes($string); //results in "Joes dinner"
+
+
+
+ +
+
+ + +
+
+ + + + +
+ +
+

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/text_helper.html b/user_guide/helpers/text_helper.html new file mode 100644 index 000000000..48cf30762 --- /dev/null +++ b/user_guide/helpers/text_helper.html @@ -0,0 +1,847 @@ + + + + + + + + + + Text Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Text Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

Text Helper

+

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

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+word_limiter($str[, $limit = 100[, $end_char = '&#8230;']])
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
  • $limit (int) – Limit
  • +
  • $end_char (string) – End character (usually an ellipsis)
  • +
+
Returns:

Word-limited string

+
Return type:

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);
+// Returns:  Here is a nice
+
+
+

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

+
+ +
+
+character_limiter($str[, $n = 500[, $end_char = '&#8230;']])
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
  • $n (int) – Number of characters
  • +
  • $end_char (string) – End character (usually an ellipsis)
  • +
+
Returns:

Character-limited string

+
Return type:

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 than what you specify.

+

Example:

+
$string = "Here is a nice text string consisting of eleven words.";
+$string = character_limiter($string, 20);
+// Returns:  Here is a nice text string
+
+
+

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 ellipsize() function below.

+
+
+ +
+
+ascii_to_entities($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
+
Returns:

A string with ASCII values converted to entities

+
Return type:

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:

+
$string = ascii_to_entities($string);
+
+
+
+ +
+
+convert_accented_characters($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
+
Returns:

A string with accented characters converted

+
Return type:

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);
+
+
+
+

Note

+

This function uses a companion config file +application/config/foreign_chars.php to define the to and +from array for transliteration.

+
+
+ +
+
+word_censor($str, $censored[, $replacement = ''])
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
  • $censored (array) – List of bad words to censor
  • +
  • $replacement (string) – What to replace bad words with
  • +
+
Returns:

Censored string

+
Return type:

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:

+
$disallowed = array('darn', 'shucks', 'golly', 'phooey');
+$string = word_censor($string, $disallowed, 'Beep!');
+
+
+
+ +
+
+highlight_code($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
+
Returns:

String with code highlighted via HTML

+
Return type:

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.

+
+ +
+
+highlight_phrase($str, $phrase[, $tag_open = '<mark>'[, $tag_close = '</mark>']])
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
  • $phrase (string) – Phrase to highlight
  • +
  • $tag_open (string) – Opening tag used for the highlight
  • +
  • $tag_close (string) – Closing tag for the highlight
  • +
+
Returns:

String with a phrase highlighted via HTML

+
Return type:

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:

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

The above code prints:

+
Here is a <span style="color:#990000;">nice text</span> string about nothing in particular.
+
+
+
+

Note

+

This function used to use the <strong> tag by default. Older browsers +might not support the new HTML5 mark tag, so it is recommended that you +insert the following CSS code into your stylesheet if you need to support +such browsers:

+
mark {
+        background: #ff0;
+        color: #000;
+};
+
+
+
+
+ +
+
+word_wrap($str[, $charlim = 76])
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
  • $charlim (int) – Character limit
  • +
+
Returns:

Word-wrapped string

+
Return type:

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($str, $max_length[, $position = 1[, $ellipsis = '&hellip;']])
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
  • $max_length (int) – String length limit
  • +
  • $position (mixed) – Position to split at (int or float)
  • +
  • $ellipsis (string) – What to use as the ellipsis character
  • +
+
Returns:

Ellipsized string

+
Return type:

string

+
+

This function will strip tags from a string, split it at a defined +maximum length, and insert an ellipsis.

+

The first parameter is the string to ellipsize, the second is the number +of characters in the final string. The third parameter is where in the +string the ellipsis should appear from 0 - 1, left to right. For +example. a value of 1 will place the ellipsis at the right of the +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
+
+
+
+ +
+
+ + +
+
+ + + + +
+ +
+

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/typography_helper.html b/user_guide/helpers/typography_helper.html new file mode 100644 index 000000000..9343573df --- /dev/null +++ b/user_guide/helpers/typography_helper.html @@ -0,0 +1,607 @@ + + + + + + + + + + Typography Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • Typography Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

Typography Helper

+

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

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+auto_typography($str[, $reduce_linebreaks = FALSE])
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
  • $reduce_linebreaks (bool) – Whether to reduce multiple instances of double newlines to two
  • +
+
Returns:

HTML-formatted typography-safe string

+
Return type:

string

+
+

Formats text so that it is semantically and typographically correct +HTML.

+

This function is an alias for CI_Typography::auto_typography(). +For more info, please see the Typography Library documentation.

+

Usage example:

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

Note

+

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

+
+
+ +
+
+nl2br_except_pre($str)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
+
Returns:

String with HTML-formatted line breaks

+
Return type:

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($str, $charset = NULL)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
  • $charset (string) – Character set
  • +
+
Returns:

String with decoded HTML entities

+
Return type:

string

+
+

This function is an alias for CI_Security::entity_decode(). +Fore more info, please see the Security Library documentation.

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

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/url_helper.html b/user_guide/helpers/url_helper.html new file mode 100644 index 000000000..04c9be47c --- /dev/null +++ b/user_guide/helpers/url_helper.html @@ -0,0 +1,1044 @@ + + + + + + + + + + URL Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • URL Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

URL Helper

+

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

+ +
+

Loading this Helper

+

This helper is loaded using the following code:

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

Available Functions

+

The following functions are available:

+
+
+site_url([$uri = ''[, $protocol = NULL]])
+
+++ + + + + + + + +
Parameters:
    +
  • $uri (string) – URI string
  • +
  • $protocol (string) – Protocol, e.g. ‘http’ or ‘https’
  • +
+
Returns:

Site URL

+
Return type:

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) will be added to the URL, as will any URI segments you pass to the +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:

+
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:

+
$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 Config Library documentation.

+
+ +
+
+base_url($uri = '', $protocol = NULL)
+
+++ + + + + + + + +
Parameters:
    +
  • $uri (string) – URI string
  • +
  • $protocol (string) – Protocol, e.g. ‘http’ or ‘https’
  • +
+
Returns:

Base URL

+
Return type:

string

+
+

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

+
echo base_url();
+
+
+

This function returns the same thing as site_url(), without +the index_page or url_suffix being appended.

+

Also like 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:

+
echo base_url("images/icons/edit.png");
+
+
+

This would give you something like: +http://example.com/images/icons/edit.png

+

This function is an alias for CI_Config::base_url(). For more info, +please see the Config Library documentation.

+
+ +
+
+current_url()
+
+++ + + + + + +
Returns:The current URL
Return type: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:An URI string
Return type:string
+

Returns the URI segments of any page that contains this function. +For example, if your URL was this:

+
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 Config Library documentation.

+
+ +
+
+index_page()
+
+++ + + + + + +
Returns:‘index_page’ value
Return type:mixed
+

Returns your site index_page, as specified in your config file. +Example:

+
echo index_page();
+
+
+
+ +
+
+anchor($uri = '', $title = '', $attributes = '')
+
+++ + + + + + + + +
Parameters:
    +
  • $uri (string) – URI string
  • +
  • $title (string) – Anchor title
  • +
  • $attributes (mixed) – HTML attributes
  • +
+
Returns:

HTML hyperlink (anchor tag)

+
Return type:

string

+
+

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.

+
+

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.

+
+

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

+

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

+

Here are some examples:

+
echo anchor('news/local/123', 'My News', 'title="News title"');
+// 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>
+
+echo anchor('', 'Click here');
+// Prints: <a href="http://example.com">Click Here</a>
+
+
+
+ +
+
+anchor_popup($uri = '', $title = '', $attributes = FALSE)
+
+++ + + + + + + + +
Parameters:
    +
  • $uri (string) – URI string
  • +
  • $title (string) – Anchor title
  • +
  • $attributes (mixed) – HTML attributes
  • +
+
Returns:

Pop-up hyperlink

+
Return type:

string

+
+

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

+

Here is an example with attributes:

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

Note

+

The above attributes are the function defaults so you only need to +set the ones that are different from what you need. If you want the +function to use all of its defaults simply pass an empty array in the +third parameter: +| +| echo anchor_popup(‘news/local/123’, ‘Click Me!’, array());

+
+
+

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.

+
+
+

Note

+

Any other attribute than the listed above will be parsed as an +HTML attribute to the anchor tag.

+
+
+ +
+
+mailto($email, $title = '', $attributes = '')
+
+++ + + + + + + + +
Parameters:
    +
  • $email (string) – E-mail address
  • +
  • $title (string) – Anchor title
  • +
  • $attributes (mixed) – HTML attributes
  • +
+
Returns:

A “mail to” hyperlink

+
Return type:

string

+
+

Creates a standard HTML e-mail link. Usage example:

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

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

+
$attributes = array('title' => 'Mail me');
+echo mailto('me@my-site.com', 'Contact Me', $attributes);
+
+
+
+ +
+
+safe_mailto($email, $title = '', $attributes = '')
+
+++ + + + + + + + +
Parameters:
    +
  • $email (string) – E-mail address
  • +
  • $title (string) – Anchor title
  • +
  • $attributes (mixed) – HTML attributes
  • +
+
Returns:

A spam-safe “mail to” hyperlink

+
Return type:

string

+
+

Identical to the 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.

+
+ +
+ +
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
  • $type (string) – Link type (‘email’, ‘url’ or ‘both’)
  • +
  • $popup (bool) – Whether to create popup links
  • +
+
Returns:

Linkified string

+
Return type:

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 e-mails are converted or +just one or the other. Default behavior is both if the parameter is not +specified. E-mail links are encoded as safe_mailto() as shown +above.

+

Converts only URLs:

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

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):

+
$string = auto_link($string, 'both', TRUE);
+
+
+
+ +
+
+url_title($str, $separator = '-', $lowercase = FALSE)
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – Input string
  • +
  • $separator (string) – Word separator
  • +
  • $lowercase (bool) – Whether to transform the output string to lower-case
  • +
+
Returns:

URL-formatted string

+
Return type:

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 = "What's wrong with CSS?";
+$url_title = url_title($title);
+// Produces: Whats-wrong-with-CSS
+
+
+

The second parameter determines the word delimiter. By default dashes +are used. Preferred options are: - (dash) or _ (underscore)

+

Example:

+
$title = "What's 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.

+

Example:

+
$title = "What's wrong with CSS?";
+$url_title = url_title($title, 'underscore', TRUE);
+// Produces: whats_wrong_with_css
+
+
+
+ +
+
+prep_url($str = '')
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – URL string
  • +
+
Returns:

Protocol-prefixed URL string

+
Return type:

string

+
+

This function will add http:// in the event that a protocol prefix +is missing from a URL.

+

Pass the URL string to the function like this:

+
$url = prep_url('example.com');
+
+
+
+ +
+
+redirect($uri = '', $method = 'auto', $code = NULL)
+
+++ + + + + + +
Parameters:
    +
  • $uri (string) – URI string
  • +
  • $method (string) – Redirect method (‘auto’, ‘location’ or ‘refresh’)
  • +
  • $code (string) – HTTP Response code (usually 302 or 303)
  • +
+
Return type:

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

+
if ($logged_in == FALSE)
+{
+        redirect('/login/form/');
+}
+
+// with 301 redirect
+redirect('/article/13', 'location', 301);
+
+
+
+

Note

+

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

+
+
+

Note

+

For very fine grained control over headers, you should use the +Output Library set_header() method.

+
+
+

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.

+
+
+

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.

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

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/user_guide/helpers/xml_helper.html b/user_guide/helpers/xml_helper.html new file mode 100644 index 000000000..3d50ffcd7 --- /dev/null +++ b/user_guide/helpers/xml_helper.html @@ -0,0 +1,559 @@ + + + + + + + + + + XML Helper — CodeIgniter 3.1.9 documentation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+
+
+
    +
  • Docs »
  • + +
  • Helpers »
  • + +
  • XML Helper
  • +
  • + +
  • +
    + classic layout +
    +
+
+
+
+ +
+

XML Helper

+

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

+ +
+

Loading this Helper

+

This helper is loaded using the following code

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

Available Functions

+

The following functions are available:

+
+
+xml_convert($str[, $protect_all = FALSE])
+
+++ + + + + + + + +
Parameters:
    +
  • $str (string) – the text string to convert
  • +
  • $protect_all (bool) – Whether to protect all content that looks like a potential entity instead of just numbered entities, e.g. &foo;
  • +
+
Returns:

XML-converted string

+
Return type:

string

+
+

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

+
+
    +
  • Ampersands: &
  • +
  • Less than and greater than characters: < >
  • +
  • Single and double quotes: ‘ “
  • +
  • Dashes: -
  • +
+
+

This function ignores ampersands if they are part of existing numbered +character entities, e.g. &#123;. Example:

+
$string = '<p>Here is a paragraph & an entity (&#123;).</p>';
+$string = xml_convert($string);
+echo $string;
+
+
+

outputs:

+
&lt;p&gt;Here is a paragraph &amp; an entity (&#123;).&lt;/p&gt;
+
+
+
+ +
+
+ + +
+
+ + + + +
+ +
+

+ © Copyright 2014 - 2018, British Columbia Institute of Technology. + Last updated on Jun 12, 2018. +

+
+ + Built with Sphinx using a theme provided by Read the Docs. + +
+
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3-24-g4f1b