summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/libraries
diff options
context:
space:
mode:
authorTimothy Warren <tim@timshomepage.net>2011-10-07 15:55:27 +0200
committerTimothy Warren <tim@timshomepage.net>2011-10-07 15:55:27 +0200
commit486b17c1f39e04c952de995d68412db4d6477c3c (patch)
tree57a44b04a9cbe570de8f905bb0b2d70c30895cb5 /user_guide_src/source/libraries
parentec19332ba3791c933f2221d972ee073684b5ea3b (diff)
parent0252fc7ddf80262f915b20100107ec79ba3ccf01 (diff)
Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into develop
Diffstat (limited to 'user_guide_src/source/libraries')
-rw-r--r--user_guide_src/source/libraries/encryption.rst52
-rw-r--r--user_guide_src/source/libraries/form_validation.rst104
-rw-r--r--user_guide_src/source/libraries/sessions.rst67
3 files changed, 99 insertions, 124 deletions
diff --git a/user_guide_src/source/libraries/encryption.rst b/user_guide_src/source/libraries/encryption.rst
index 356465b21..80b45e4d7 100644
--- a/user_guide_src/source/libraries/encryption.rst
+++ b/user_guide_src/source/libraries/encryption.rst
@@ -31,11 +31,11 @@ string as you can concoct, with numbers and uppercase and lowercase
letters. Your key should **not** be a simple text string. In order to be
cryptographically secure it needs to be as random as possible.
-Your key can be either stored in your application/config/config.php, or
+Your key can be either stored in your **application/config/config.php**, or
you can design your own storage mechanism and pass the key dynamically
when encoding/decoding.
-To save your key to your application/config/config.php, open the file
+To save your key to your **application/config/config.php**, open the file
and set::
$config['encryption_key'] = "YOUR KEY";
@@ -57,7 +57,7 @@ Initializing the Class
======================
Like most other classes in CodeIgniter, the Encryption class is
-initialized in your controller using the $this->load->library function::
+initialized in your controller using the **$this->load->library** function::
$this->load->library('encrypt');
@@ -103,7 +103,7 @@ $this->encrypt->set_cipher();
==============================
Permits you to set an Mcrypt cipher. By default it uses
-MCRYPT_RIJNDAEL_256. Example::
+**MCRYPT_RIJNDAEL_256**. Example::
$this->encrypt->set_cipher(MCRYPT_BLOWFISH);
@@ -118,7 +118,7 @@ can use::
$this->encrypt->set_mode();
============================
-Permits you to set an Mcrypt mode. By default it uses MCRYPT_MODE_CBC.
+Permits you to set an Mcrypt mode. By default it uses **MCRYPT_MODE_CBC**.
Example::
$this->encrypt->set_mode(MCRYPT_MODE_CFB);
@@ -153,31 +153,27 @@ encrypted session data or transitory encrypted flashdata require no
intervention on your part. However, existing encrypted Sessions will be
destroyed since data encrypted prior to 2.x will not be decoded.
-..important:: **Why only a method to re-encode the data instead of maintaining legacy
-methods for both encoding and decoding?** The algorithms in the
-Encryption library have improved in CodeIgniter 2.x both for performance
-and security, and we do not wish to encourage continued use of the older
-methods. You can of course extend the Encryption library if you wish and
-replace the new methods with the old and retain seamless compatibility
-with CodeIgniter 1.x encrypted data, but this a decision that a
-developer should make cautiously and deliberately, if at all.
+.. important::
+ **Why only a method to re-encode the data instead of maintaining legacy
+ methods for both encoding and decoding?** The algorithms in the
+ Encryption library have improved in CodeIgniter 2.x both for performance
+ and security, and we do not wish to encourage continued use of the older
+ methods. You can of course extend the Encryption library if you wish and
+ replace the new methods with the old and retain seamless compatibility
+ with CodeIgniter 1.x encrypted data, but this a decision that a
+ developer should make cautiously and deliberately, if at all.
::
$new_data = $this->encrypt->encode_from_legacy($old_encrypted_string);
-Parameter
-Default
-Description
-**$orig_data**
-n/a
-The original encrypted data from CodeIgniter 1.x's Encryption library
-**$legacy_mode**
-MCRYPT_MODE_ECB
-The Mcrypt mode that was used to generate the original encrypted data.
-CodeIgniter 1.x's default was MCRYPT_MODE_ECB, and it will assume that
-to be the case unless overridden by this parameter.
-**$key**
-n/a
-The encryption key. This it typically specified in your config file as
-outlined above.
+====================== =============== =======================================================================
+Parameter Default Description
+====================== =============== =======================================================================
+**$orig_data** n/a The original encrypted data from CodeIgniter 1.x's Encryption library
+**$legacy_mode** MCRYPT_MODE_ECB The Mcrypt mode that was used to generate the original encrypted data.
+ CodeIgniter 1.x's default was MCRYPT_MODE_ECB, and it will assume that
+ to be the case unless overridden by this parameter.
+**$key** n/a The encryption key. This it typically specified in your config file as
+ outlined above.
+====================== =============== ======================================================================= \ No newline at end of file
diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst
index 7f5ba8653..53293ca5a 100644
--- a/user_guide_src/source/libraries/form_validation.rst
+++ b/user_guide_src/source/libraries/form_validation.rst
@@ -5,31 +5,7 @@ Form Validation
CodeIgniter provides a comprehensive form validation and data prepping
class that helps minimize the amount of code you'll write.
-- `Overview <#overview>`_
-- `Form Validation Tutorial <#tutorial>`_
-
- - `The Form <#theform>`_
- - `The Success Page <#thesuccesspage>`_
- - `The Controller <#thecontroller>`_
- - `Setting Validation Rules <#validationrules>`_
- - `Setting Validation Rules Using an
- Array <#validationrulesasarray>`_
- - `Cascading Rules <#cascadingrules>`_
- - `Prepping Data <#preppingdata>`_
- - `Re-populating the Form <#repopulatingform>`_
- - `Callbacks <#callbacks>`_
- - `Setting Error Messages <#settingerrors>`_
- - `Changing the Error Delimiters <#errordelimiters>`_
- - `Translating Field Names <#translatingfn>`_
- - `Showing Errors Individually <#individualerrors>`_
- - `Saving Sets of Validation Rules to a Config
- File <#savingtoconfig>`_
- - `Using Arrays as Field Names <#arraysasfields>`_
-
-- `Rule Reference <#rulereference>`_
-- `Prepping Reference <#preppingreference>`_
-- `Function Reference <#functionreference>`_
-- `Helper Reference <#helperreference>`_
+.. contents:: Page Contents
********
Overview
@@ -206,6 +182,8 @@ helper used by your view files. It also runs the validation routine.
Based on whether the validation was successful it either presents the
form or the success page.
+.. _setting-validation-rules:
+
Setting Validation Rules
========================
@@ -225,8 +203,7 @@ The above function takes **three** parameters as input:
#. The validation rules for this form field.
.. note:: If you would like the field
- name to be stored in a language file, please see `Translating Field
- Names <#translatingfn>`_.
+ name to be stored in a language file, please see :ref:`translating-field-names`.
Here is an example. In your controller (form.php), add this code just
below the validation initialization function::
@@ -400,7 +377,7 @@ functions!**
Now reload your page and submit the form so that it triggers an error.
Your form fields should now be re-populated
-.. note:: The `Function Reference <#functionreference>`_ section below
+.. note:: The :ref:`function-reference` section below
contains functions that permit you to re-populate <select> menus, radio
buttons, and checkboxes.
@@ -409,8 +386,7 @@ must supply it as an array to the function. Example::
<input type="text" name="colors[]" value="<?php echo set_value('colors[]'); ?>" size="50" />
-For more info please see the `Using Arrays as Field
-Names <#arraysasfields>`_ section below.
+For more info please see the :ref:`using-arrays-as-field-names` section below.
Callbacks: Your own Validation Functions
========================================
@@ -484,6 +460,8 @@ then it will be passed as the second argument of your callback function.
boolean TRUE/FALSE it is assumed that the data is your newly processed
form data.
+.. _setting-error-messages:
+
Setting Error Messages
======================
@@ -511,6 +489,8 @@ example, to change the message for the "required" rule you will do this::
$this->form_validation->set_message('required', 'Your custom message here');
+.. _translating-field-names:
+
Translating Field Names
=======================
@@ -536,6 +516,8 @@ prefix)::
See the :doc:`Language Class <language>` page for more info regarding
language files.
+.. _changing-delimiters:
+
Changing the Error Delimiters
=============================
@@ -595,8 +577,9 @@ must supply it as an array to the function. Example::
<?php echo form_error('options[size]'); ?>
<input type="text" name="options[size]" value="<?php echo set_value("options[size]"); ?>" size="50" />
-For more info please see the `Using Arrays as Field
-Names <#arraysasfields>`_ section below.
+For more info please see the :ref:`using-arrays-as-field-names` section below.
+
+.. _saving-groups:
************************************************
Saving Sets of Validation Rules to a Config File
@@ -774,6 +757,8 @@ When a rule group is named identically to a controller class/function it
will be used automatically when the run() function is invoked from that
class/function.
+.. _using-arrays-as-field-names:
+
***************************
Using Arrays as Field Names
***************************
@@ -784,7 +769,7 @@ Consider this example::
<input type="text" name="options[]" value="" size="50" />
If you do use an array as a field name, you must use the EXACT array
-name in the `Helper Functions <#helperreference>`_ that require the
+name in the :ref:`Helper Functions <helper-functions>` that require the
field name, and as your Validation Rule field name.
For example, to set a rule for the above field you would use::
@@ -888,7 +873,7 @@ Name Parameter Description
==================== ========= ===================================================================================================
**xss_clean** No Runs the data through the XSS filtering function, described in the :doc:`Input Class <input>` page.
**prep_for_form** No Converts special characters so that HTML data can be shown in a form field without breaking it.
-**prep_url** No Adds "http://" to URLs if missing.
+**prep_url** No Adds "\http://" to URLs if missing.
**strip_image_tags** No Strips the HTML from image tags leaving the raw URL.
**encode_php_tags** No Converts PHP tags to entities.
==================== ========= ===================================================================================================
@@ -896,36 +881,57 @@ Name Parameter Description
.. note:: You can also use any native PHP functions that permit one
parameter, like trim, htmlspecialchars, urldecode, etc.
+.. _function-reference:
+
******************
Function Reference
******************
+.. php:class:: Form_validation
+
The following functions are intended for use in your controller
functions.
$this->form_validation->set_rules();
======================================
-Permits you to set validation rules, as described in the tutorial
-sections above:
+ .. php:method:: set_rules ($field, $label = '', $rules = '')
-- `Setting Validation Rules <#validationrules>`_
-- `Saving Groups of Validation Rules to a Config
- File <#savingtoconfig>`_
+ :param string $field: The field name
+ :param string $label: The field label
+ :param string $rules: The rules, seperated by a pipe "|"
+ :rtype: Object
+
+ Permits you to set validation rules, as described in the tutorial
+ sections above:
+
+ - :ref:`setting-validation-rules`
+ - :ref:`saving-groups`
$this->form_validation->run();
===============================
+
+ .. php:method:: run ($group = '')
-Runs the validation routines. Returns boolean TRUE on success and FALSE
-on failure. You can optionally pass the name of the validation group via
-the function, as described in: `Saving Groups of Validation Rules to a
-Config File <#savingtoconfig>`_.
+ :param string $group: The name of the validation group to run
+ :rtype: Boolean
+
+ Runs the validation routines. Returns boolean TRUE on success and FALSE
+ on failure. You can optionally pass the name of the validation group via
+ the function, as described in: :ref:`saving-groups`
$this->form_validation->set_message();
========================================
+
+ .. php:method:: set_message ($lang, $val = '')
+
+ :param string $lang: The rule the message is for
+ :param string $val: The message
+ :rtype: Object
+
+ Permits you to set custom error messages. See :ref:`setting-error-messages`
-Permits you to set custom error messages. See `Setting Error
-Messages <#settingerrors>`_ above.
+.. _helper-functions:
****************
Helper Reference
@@ -943,8 +949,8 @@ supplied to the function. Example::
<?php echo form_error('username'); ?>
-The error delimiters can be optionally specified. See the `Changing the
-Error Delimiters <#errordelimiters>`_ section above.
+The error delimiters can be optionally specified. See the
+:ref:`changing-delimiters` section above.
validation_errors()
====================
@@ -953,8 +959,8 @@ Shows all error messages as a string: Example::
<?php echo validation_errors(); ?>
-The error delimiters can be optionally specified. See the `Changing the
-Error Delimiters <#errordelimiters>`_ section above.
+The error delimiters can be optionally specified. See the
+:ref:`changing-delimiters` section above.
set_value()
============
diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst
index af9dd49c9..ef32f5d71 100644
--- a/user_guide_src/source/libraries/sessions.rst
+++ b/user_guide_src/source/libraries/sessions.rst
@@ -284,50 +284,23 @@ Session Preferences
You'll find the following Session related preferences in your
application/config/config.php file:
-Preference
-Default
-Options
-Description
-**sess_cookie_name**
-ci_session
-None
-The name you want the session cookie saved as.
-**sess_expiration**
-7200
-None
-The number of seconds you would like the session to last. The default
-value is 2 hours (7200 seconds). If you would like a non-expiring
-session set the value to zero: 0
-**sess_expire_on_close**
-FALSE
-TRUE/FALSE (boolean)
-Whether to cause the session to expire automatically when the browser
-window is closed.
-**sess_encrypt_cookie**
-FALSE
-TRUE/FALSE (boolean)
-Whether to encrypt the session data.
-**sess_use_database**
-FALSE
-TRUE/FALSE (boolean)
-Whether to save the session data to a database. You must create the
-table before enabling this option.
-**sess_table_name**
-ci_sessions
-Any valid SQL table name
-The name of the session database table.
-**sess_time_to_update**
-300
-Time in seconds
-This options controls how often the session class will regenerate itself
-and create a new session id.
-**sess_match_ip**
-FALSE
-TRUE/FALSE (boolean)
-Whether to match the user's IP address when reading the session data.
-Note that some ISPs dynamically changes the IP, so if you want a
-non-expiring session you will likely set this to FALSE.
-**sess_match_useragent**
-TRUE
-TRUE/FALSE (boolean)
-Whether to match the User Agent when reading the session data.
+=========================== =============== =========================== ==========================================================================
+Preference Default Options Description
+=========================== =============== =========================== ==========================================================================
+**sess_cookie_name** ci_session None The name you want the session cookie saved as.
+**sess_expiration** 7200 None The number of seconds you would like the session to last. The default
+ value is 2 hours (7200 seconds). If you would like a non-expiring
+ session set the value to zero: 0
+**sess_expire_on_close** FALSE TRUE/FALSE (boolean) Whether to cause the session to expire automatically when the browser
+ window is closed.
+**sess_encrypt_cookie** FALSE TRUE/FALSE (boolean) Whether to encrypt the session data.
+**sess_use_database** FALSE TRUE/FALSE (boolean) Whether to save the session data to a database. You must create the
+ table before enabling this option.
+**sess_table_name** ci_sessions Any valid SQL table name The name of the session database table.
+**sess_time_to_update** 300 Time in seconds This options controls how often the session class will regenerate itself
+ and create a new session id.
+**sess_match_ip** FALSE TRUE/FALSE (boolean) Whether to match the user's IP address when reading the session data.
+ Note that some ISPs dynamically changes the IP, so if you want a
+ non-expiring session you will likely set this to FALSE.
+**sess_match_useragent** TRUE TRUE/FALSE (boolean) Whether to match the User Agent when reading the session data.
+=========================== =============== =========================== ========================================================================== \ No newline at end of file