From a28812aed2aa56d4e8e69ac3560ad33aa4b82f38 Mon Sep 17 00:00:00 2001 From: Chad Hedgcock Date: Wed, 25 Apr 2012 23:29:52 -0300 Subject: Corrected path to jquery --- user_guide_src/source/libraries/javascript.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/javascript.rst b/user_guide_src/source/libraries/javascript.rst index 5e80fb998..d5e09c314 100644 --- a/user_guide_src/source/libraries/javascript.rst +++ b/user_guide_src/source/libraries/javascript.rst @@ -86,14 +86,14 @@ The jQuery Class To initialize the jQuery class manually in your controller constructor, use the $this->load->library function:: - $this->load->library('jquery'); + $this->load->library('javascript/jquery'); You may send an optional parameter to determine whether or not a script tag for the main jQuery file will be automatically included when loading the library. It will be created by default. To prevent this, load the library as follows:: - $this->load->library('jquery', FALSE); + $this->load->library('javascript/jquery', FALSE); Once loaded, the jQuery library object will be available using: $this->jquery -- cgit v1.2.3-24-g4f1b From 55a6ddb0c7bab1149bb1ddfa3a1aff46612c91d4 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 23 May 2012 18:37:24 +0100 Subject: Input, Session and Cookie get's will return NULL. Read more about this change here: http://codeigniter.com/forums/viewthread/215833 --- user_guide_src/source/libraries/input.rst | 17 +++++------------ user_guide_src/source/libraries/uri.rst | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index 1f2ea650a..432bac3c7 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -18,7 +18,7 @@ The security filtering function is called automatically when a new :doc:`controller <../general/controllers>` is invoked. It does the following: -- If $config['allow_get_array'] is FALSE(default is TRUE), destroys +- If $config['allow_get_array'] is FALSE (default is TRUE), destroys the global GET array. - Destroys all global variables in the event register_globals is turned on. @@ -53,14 +53,7 @@ false (boolean) if not. This lets you conveniently use data without having to test whether an item exists first. In other words, normally you might do something like this:: - if ( ! isset($_POST['something'])) - { - $something = FALSE; - } - else - { - $something = $_POST['something']; - } + $something = isset($_POST['something']) ? $_POST['something'] : NULL; With CodeIgniter's built in functions you can simply do this:: @@ -95,7 +88,7 @@ To return an array of all POST items call without any parameters. To return all POST items and pass them through the XSS filter set the first parameter NULL while setting the second parameter to boolean; -The function returns FALSE (boolean) if there are no items in the POST. +The function returns NULL if there are no items in the POST. :: @@ -115,7 +108,7 @@ To return an array of all GET items call without any parameters. To return all GET items and pass them through the XSS filter set the first parameter NULL while setting the second parameter to boolean; -The function returns FALSE (boolean) if there are no items in the GET. +The function returns NULL if there are no items in the GET. :: @@ -210,7 +203,7 @@ the cookie you are looking for (including any prefixes):: cookie('some_cookie'); -The function returns FALSE (boolean) if the item you are attempting to +The function returns NULL if the item you are attempting to retrieve does not exist. The second optional parameter lets you run the data through the XSS diff --git a/user_guide_src/source/libraries/uri.rst b/user_guide_src/source/libraries/uri.rst index ee60b77d7..cdd76e322 100644 --- a/user_guide_src/source/libraries/uri.rst +++ b/user_guide_src/source/libraries/uri.rst @@ -25,7 +25,7 @@ The segment numbers would be this: #. metro #. crime_is_up -By default the function returns FALSE (boolean) if the segment does not +By default the function returns NULL if the segment does not exist. There is an optional second parameter that permits you to set your own default value if the segment is missing. For example, this would tell the function to return the number zero in the event of -- cgit v1.2.3-24-g4f1b From 991cfa2e5843df05c6295445133882b9f35e3f7b Mon Sep 17 00:00:00 2001 From: Thanasis Polychronakis Date: Thu, 31 May 2012 21:54:35 +0300 Subject: Changed documentation and added note to changelog as per @philsturgeon request --- user_guide_src/source/libraries/config.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/config.rst b/user_guide_src/source/libraries/config.rst index c81cad7b3..08d9c2905 100644 --- a/user_guide_src/source/libraries/config.rst +++ b/user_guide_src/source/libraries/config.rst @@ -149,11 +149,13 @@ folders: - Your own custom configuration files .. note:: - CodeIgniter always tries to load the configuration files for - the current environment first. If the file does not exist, the global - config file (i.e., the one in application/config/) is loaded. This means - you are not obligated to place **all** of your configuration files in an - environment folder − only the files that change per environment. + CodeIgniter always loads the global config file first (i.e., the one in application/config/), + then tries to load the configuration files for the current environment. + This means you are not obligated to place **all** of your configuration files in an + environment folder. Only the files that change per environment. Additionally you don't + have to copy **all** the config items in the environment config file. Only the config items + that you wish to change for your environment. The config items declared in your environment + folders always overwrite those in your global config files. Helper Functions ================ -- cgit v1.2.3-24-g4f1b From bfc1cad4fbf6d6640d782f39169af6c3799fa3e8 Mon Sep 17 00:00:00 2001 From: Mickey Wu Date: Thu, 31 May 2012 22:28:40 -0700 Subject: Made set_header() public in Email library and updated documentation. --- user_guide_src/source/libraries/email.rst | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst index daf000907..f99eb91df 100644 --- a/user_guide_src/source/libraries/email.rst +++ b/user_guide_src/source/libraries/email.rst @@ -182,6 +182,14 @@ formatting which is added to the header string for people who do not accept HTML email. If you do not set your own message CodeIgniter will extract the message from your HTML email and strip the tags. +$this->email->set_header() +----------------------- + +Appends additional headers to the e-mail:: + + $this->email->set_header('Header1', 'Value1'); + $this->email->set_header('Header2', 'Value2'); + $this->email->clear() --------------------- -- cgit v1.2.3-24-g4f1b From 149c07726bb60df65766a1046e695b1897652cc7 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:23:41 +0100 Subject: Changed load model examples to use lowercase model name. Fixes #1417 --- user_guide_src/source/libraries/loader.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst index 2090404bf..aadf9740a 100644 --- a/user_guide_src/source/libraries/loader.rst +++ b/user_guide_src/source/libraries/loader.rst @@ -116,12 +116,12 @@ assign it to a variable if you want the data returned:: $string = $this->load->view('myfile', '', true); -$this->load->model('Model_name'); +$this->load->model('model_name'); ================================== :: - $this->load->model('Model_name'); + $this->load->model('model_name'); If your model is located in a sub-folder, include the relative path from @@ -134,7 +134,7 @@ application/models/blog/queries.php you'll load it using:: If you would like your model assigned to a different object name you can specify it via the second parameter of the loading function:: - $this->load->model('Model_name', 'fubar'); + $this->load->model('model_name', 'fubar'); $this->fubar->function(); -- cgit v1.2.3-24-g4f1b From 47b673324f06236264ca64f8c3155aab51762609 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 6 Jun 2012 15:58:05 +0300 Subject: Add a second parameter (charset) to CI_Output::set_content_type() + fix for issue #666 --- user_guide_src/source/libraries/output.rst | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/output.rst b/user_guide_src/source/libraries/output.rst index baceaae7b..0472d14cf 100644 --- a/user_guide_src/source/libraries/output.rst +++ b/user_guide_src/source/libraries/output.rst @@ -49,6 +49,10 @@ data, JPEG's, XML, etc easily. .. important:: Make sure any non-mime string you pass to this method exists in config/mimes.php or it will have no effect. +You can also set the character set of the document, by passing a second argument:: + + $this->output->set_content_type('css', 'utf-8'); + $this->output->get_content_type(); ========================================== -- cgit v1.2.3-24-g4f1b From 5a257187c4ca09ea61c19999bf061cec3f224cc2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 10 Jun 2012 06:18:14 +0300 Subject: Merge branch 2.1-stable into develop --- user_guide_src/source/libraries/form_validation.rst | 1 + user_guide_src/source/libraries/input.rst | 3 +++ user_guide_src/source/libraries/sessions.rst | 2 +- user_guide_src/source/libraries/uri.rst | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 028b61c4c..3c0e6eda4 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -884,6 +884,7 @@ Rule Parameter Description **valid_email** No Returns FALSE if the form element does not contain a valid email address. **valid_emails** No Returns FALSE if any value provided in a comma separated list is not a valid email. **valid_ip** No Returns FALSE if the supplied IP is not valid. + Accepts an optional parameter of 'ipv4' or 'ipv6' to specify an IP format. **valid_base64** No Returns FALSE if the supplied string contains anything other than valid Base64 characters. ========================= ========== ============================================================================================= ======================= diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index 432bac3c7..7f995f050 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -242,6 +242,9 @@ validates the IP automatically. echo 'Valid'; } +Accepts an optional second string parameter of 'ipv4' or 'ipv6' to specify +an IP format. The default checks for both formats. + $this->input->user_agent() =========================== diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index e8332ee97..5400524a9 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -245,7 +245,7 @@ session class:: CREATE TABLE IF NOT EXISTS `ci_sessions` ( session_id varchar(40) DEFAULT '0' NOT NULL, - ip_address varchar(16) DEFAULT '0' NOT NULL, + ip_address varchar(45) DEFAULT '0' NOT NULL, user_agent varchar(120) NOT NULL, last_activity int(10) unsigned DEFAULT 0 NOT NULL, user_data text NOT NULL, diff --git a/user_guide_src/source/libraries/uri.rst b/user_guide_src/source/libraries/uri.rst index cdd76e322..bb959b002 100644 --- a/user_guide_src/source/libraries/uri.rst +++ b/user_guide_src/source/libraries/uri.rst @@ -146,7 +146,7 @@ full URL:: The function would return this:: - /news/local/345 + news/local/345 $this->uri->ruri_string() ========================== -- cgit v1.2.3-24-g4f1b From 37ec30c6d89448cd11c24788c01ff06326de128b Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Mon, 11 Jun 2012 09:26:33 +0200 Subject: changelog --- user_guide_src/source/libraries/file_uploading.rst | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/file_uploading.rst b/user_guide_src/source/libraries/file_uploading.rst index d573fc770..414d84f0b 100644 --- a/user_guide_src/source/libraries/file_uploading.rst +++ b/user_guide_src/source/libraries/file_uploading.rst @@ -287,6 +287,10 @@ data related to the file you uploaded. Here is the array prototype:: [image_size_str] => width="800" height="200" ) +To return one element from the array:: + + $this->upload->data('file_name'); // Returns: mypic.jpg + Explanation *********** -- cgit v1.2.3-24-g4f1b From 5a1e5e34207b9b30ff42200158074953ca1cabab Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 11:28:26 +0300 Subject: Add support for the anchor 'rel' attribute in the Pagination library --- user_guide_src/source/libraries/pagination.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst index f1653c913..560755fb6 100644 --- a/user_guide_src/source/libraries/pagination.rst +++ b/user_guide_src/source/libraries/pagination.rst @@ -254,3 +254,27 @@ Adding a class to every anchor If you want to add a class attribute to every link rendered by the pagination class, you can set the config "anchor_class" equal to the classname you want. + +:: + + $config['anchor_class'] = 'myclass'; // class="myclass" + +********************************** +Changing the "rel" attribute value +********************************** + +By default, the rel attribute will be automatically put under the +following conditions: + +- rel="start" for the "first" link +- rel="prev" for the "previous" link +- rel="next" for the "next" link + +If you want to disable the rel attribute, or change its value, you +can set the 'attr_rel' config option:: + + // Disable + $config['attr_rel'] = FALSE; + + // Use a custom value on all anchors + $config['attr_rel'] = 'custom_value'; // produces: rel="custom_value" \ No newline at end of file -- cgit v1.2.3-24-g4f1b From f9311136d9f821b7b0b1f2fa7c933f51803d4f96 Mon Sep 17 00:00:00 2001 From: Kevin Wood-Friend Date: Tue, 12 Jun 2012 10:57:57 -0400 Subject: Updated Form Validation's documentation for set_rules() now accepting an array of rules --- user_guide_src/source/libraries/form_validation.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 3c0e6eda4..3bcad7ba6 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -304,6 +304,10 @@ Give it a try! Submit your form without the proper data and you'll see new error messages that correspond to your new rules. There are numerous rules available which you can read about in the validation reference. +.. note:: You can also pass an array of rules to set_rules(), instead of a string. Example:: + + $this->form_validation->set_rules('username', 'Username', array('required', 'min_length[5]')); + Prepping Data ============= @@ -935,7 +939,7 @@ $this->form_validation->set_rules(); :param string $field: The field name :param string $label: The field label - :param string $rules: The rules, seperated by a pipe "|" + :param mixed $rules: The rules, as a string with rules separated by a pipe "|", or an array or rules. :rtype: Object Permits you to set validation rules, as described in the tutorial -- cgit v1.2.3-24-g4f1b From 9cf12d1de76c2696233a437e0cdc7266bb846ae6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 13 Jun 2012 10:19:59 +0300 Subject: Fix docs for Input library (issue #1465) --- user_guide_src/source/libraries/input.rst | 37 +++++++++---------------------- 1 file changed, 10 insertions(+), 27 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index 7f995f050..8c6f7c849 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -42,14 +42,14 @@ this:: Please refer to the :doc:`Security class ` documentation for information on using XSS Filtering in your application. -Using POST, COOKIE, or SERVER Data -================================== +Using POST, GET, COOKIE, or SERVER Data +======================================= -CodeIgniter comes with three helper functions that let you fetch POST, +CodeIgniter comes with four helper methods that let you fetch POST, GET, COOKIE or SERVER items. The main advantage of using the provided functions rather than fetching an item directly ($_POST['something']) -is that the functions will check to see if the item is set and return -false (boolean) if not. This lets you conveniently use data without +is that the methods will check to see if the item is set and return +NULL if not. This lets you conveniently use data without having to test whether an item exists first. In other words, normally you might do something like this:: @@ -73,8 +73,8 @@ looking for:: $this->input->post('some_data'); -The function returns FALSE (boolean) if the item you are attempting to -retrieve does not exist. +The function returns NULL if the item you are attempting to retrieve +does not exist. The second optional parameter lets you run the data through the XSS filter. It's enabled by setting the second parameter to boolean TRUE; @@ -130,7 +130,9 @@ $this->input->cookie() This function is identical to the post function, only it fetches cookie data:: - $this->input->cookie('some_data', TRUE); + $this->input->cookie('some_cookie'); + $this->input->cookie('some_cookie, TRUE); // with XSS filter + $this->input->server() ====================== @@ -195,25 +197,6 @@ parameters:: $this->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure); -$this->input->cookie() -====================== - -Lets you fetch a cookie. The first parameter will contain the name of -the cookie you are looking for (including any prefixes):: - - cookie('some_cookie'); - -The function returns NULL if the item you are attempting to -retrieve does not exist. - -The second optional parameter lets you run the data through the XSS -filter. It's enabled by setting the second parameter to boolean TRUE; - -:: - - cookie('some_cookie', TRUE); - - $this->input->ip_address() =========================== -- cgit v1.2.3-24-g4f1b From 22c3e73573d2828cec6183866b162359f873a949 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 13 Jun 2012 10:21:36 +0300 Subject: Another input library docs fix --- user_guide_src/source/libraries/input.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index 8c6f7c849..c0b9c6589 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -59,9 +59,10 @@ With CodeIgniter's built in functions you can simply do this:: $something = $this->input->post('something'); -The three functions are: +The four methods are: - $this->input->post() +- $this->input->get() - $this->input->cookie() - $this->input->server() -- cgit v1.2.3-24-g4f1b From ac35e5a3fc0987872933131988a99bd21f86a70c Mon Sep 17 00:00:00 2001 From: vlakoff Date: Fri, 15 Jun 2012 22:59:26 +0300 Subject: Fix error in Encryption Class documentation One ANSI character is 8 bits, so 32 characters are not 128 bits but 256 bits. --- user_guide_src/source/libraries/encryption.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/encryption.rst b/user_guide_src/source/libraries/encryption.rst index 28bdca203..a38122203 100644 --- a/user_guide_src/source/libraries/encryption.rst +++ b/user_guide_src/source/libraries/encryption.rst @@ -26,7 +26,7 @@ key security so you may want to think carefully before using it for anything that requires high security, like storing credit card numbers. To take maximum advantage of the encryption algorithm, your key should -be 32 characters in length (128 bits). The key should be as random a +be 32 characters in length (256 bits). The key should be as random a 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. -- cgit v1.2.3-24-g4f1b From 1764dd7d4ab6e6e5c799eaa9ce007fce48fa0b63 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 18:48:19 +0300 Subject: Fix issue #938 + some related improvements --- user_guide_src/source/libraries/config.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/config.rst b/user_guide_src/source/libraries/config.rst index 08d9c2905..694896353 100644 --- a/user_guide_src/source/libraries/config.rst +++ b/user_guide_src/source/libraries/config.rst @@ -175,7 +175,7 @@ This function retrieves the URL to your site, plus an optional path such as to a stylesheet or image. The two functions above are normally accessed via the corresponding -functions in the :doc:`URL Helper `. +functions in the :doc:`URL Helper `. $this->config->system_url(); ***************************** -- cgit v1.2.3-24-g4f1b From d60e700640c2a67f74acff090b94d06117bfc203 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 17 Jun 2012 00:03:03 +0300 Subject: Add an option to disable MIME detection in the Upload library (issue #1494) --- user_guide_src/source/libraries/file_uploading.rst | 3 +++ 1 file changed, 3 insertions(+) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/file_uploading.rst b/user_guide_src/source/libraries/file_uploading.rst index 414d84f0b..65cd5c722 100644 --- a/user_guide_src/source/libraries/file_uploading.rst +++ b/user_guide_src/source/libraries/file_uploading.rst @@ -215,6 +215,9 @@ Preference Default Value Options Descripti that can not be discerned by the person uploading it. **remove_spaces** TRUE TRUE/FALSE (boolean) If set to TRUE, any spaces in the file name will be converted to underscores. This is recommended. +**detect_mime** TRUE TRUE/FALSE (boolean) If set to TRUE, a server side detection of the file type will be + performed to avoid code injection attacks. DO NOT disable this option + unless you have no other option as that would cause a security risk. ============================ ================= ======================= ====================================================================== Setting preferences in a config file -- cgit v1.2.3-24-g4f1b From 88c47278f775413b5a408f48d30bd279e34e601a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 17 Jun 2012 02:32:31 +0300 Subject: Pagination: fixed 'rel' attribute handling, added custom attributes support, deprecated 'anchor_class' setting --- user_guide_src/source/libraries/pagination.rst | 40 ++++++++++++-------------- 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst index 560755fb6..c4398d739 100644 --- a/user_guide_src/source/libraries/pagination.rst +++ b/user_guide_src/source/libraries/pagination.rst @@ -247,34 +247,30 @@ adding:: $config['display_pages'] = FALSE; -****************************** -Adding a class to every anchor -****************************** +**************************** +Adding attributes to anchors +**************************** -If you want to add a class attribute to every link rendered by the -pagination class, you can set the config "anchor_class" equal to the -classname you want. +If you want to add an extra attribute to be added to every link rendered +by the pagination class, you can set them as key/value pairs in the +"attributes" config :: - $config['anchor_class'] = 'myclass'; // class="myclass" + // Produces: class="myclass" + $config['attributes'] = array('class' => 'myclass'); -********************************** -Changing the "rel" attribute value -********************************** +.. note:: Usage of the old method of setting classes via "anchor_class" + is deprecated. -By default, the rel attribute will be automatically put under the -following conditions: +***************************** +Disabling the "rel" attribute +***************************** -- rel="start" for the "first" link -- rel="prev" for the "previous" link -- rel="next" for the "next" link +By default the rel attribute is dynamically generated and appended to +the appropriate anchors. If for some reason you want to turn it off, +you can pass boolean FALSE as a regular attribute -If you want to disable the rel attribute, or change its value, you -can set the 'attr_rel' config option:: - - // Disable - $config['attr_rel'] = FALSE; +:: - // Use a custom value on all anchors - $config['attr_rel'] = 'custom_value'; // produces: rel="custom_value" \ No newline at end of file + $config['attributes']['rel'] = FALSE; \ No newline at end of file -- cgit v1.2.3-24-g4f1b From f82b92999e8309155df3e665e25a261c26b0e93d Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Sat, 23 Jun 2012 15:49:23 +0100 Subject: Added ['reuse_query_string'] to Pagination. This allows automatic repopulation of query string arguments, combined with normal URI segments. --- user_guide_src/source/libraries/pagination.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst index c4398d739..15b3675df 100644 --- a/user_guide_src/source/libraries/pagination.rst +++ b/user_guide_src/source/libraries/pagination.rst @@ -112,6 +112,21 @@ the pagination link will become. Note that "per_page" is the default query string passed, however can be configured using $config['query_string_segment'] = 'your_string' +$config['reuse_query_string'] = FALSE; +==================================== + +By default your Query String arguments (nothing to do with other +query string options) will be ignored. Setting this config to +TRUE will add existing query string arguments back into the +URL after the URI segment and before the suffix + +:: + + http://example.com/index.php/test/page/20?query=search%term + +This helps you mix together normal :doc:`URI Segments <../general/urls>` +as well as query string arguments, which until 3.0 was not possible. + *********************** Adding Enclosing Markup *********************** -- cgit v1.2.3-24-g4f1b From ce79be0b5ffc9d5754c93771a8c289a252ec437b Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Mon, 25 Jun 2012 23:23:46 -0700 Subject: Fixing various Sphinx bugs and syntax errors in docs --- user_guide_src/source/libraries/email.rst | 2 +- user_guide_src/source/libraries/pagination.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst index f99eb91df..c5fa68004 100644 --- a/user_guide_src/source/libraries/email.rst +++ b/user_guide_src/source/libraries/email.rst @@ -183,7 +183,7 @@ accept HTML email. If you do not set your own message CodeIgniter will extract the message from your HTML email and strip the tags. $this->email->set_header() ------------------------ +-------------------------- Appends additional headers to the e-mail:: diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst index 15b3675df..a7e4c84c9 100644 --- a/user_guide_src/source/libraries/pagination.rst +++ b/user_guide_src/source/libraries/pagination.rst @@ -113,7 +113,7 @@ Note that "per_page" is the default query string passed, however can be configured using $config['query_string_segment'] = 'your_string' $config['reuse_query_string'] = FALSE; -==================================== +====================================== By default your Query String arguments (nothing to do with other query string options) will be ignored. Setting this config to -- cgit v1.2.3-24-g4f1b From 4b84d62490e3c17c18f0d1681d713da57a2c82ba Mon Sep 17 00:00:00 2001 From: Marco Monteiro Date: Tue, 26 Jun 2012 11:53:20 +0100 Subject: Updated pagination library documentation with prefix and suffix --- user_guide_src/source/libraries/pagination.rst | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst index 15b3675df..6e1020be3 100644 --- a/user_guide_src/source/libraries/pagination.rst +++ b/user_guide_src/source/libraries/pagination.rst @@ -21,9 +21,9 @@ Here is a simple example showing how to create pagination in one of your $config['base_url'] = 'http://example.com/index.php/test/page/'; $config['total_rows'] = 200; - $config['per_page'] = 20; + $config['per_page'] = 20; - $this->pagination->initialize($config); + $this->pagination->initialize($config); echo $this->pagination->create_links(); @@ -115,9 +115,9 @@ configured using $config['query_string_segment'] = 'your_string' $config['reuse_query_string'] = FALSE; ==================================== -By default your Query String arguments (nothing to do with other -query string options) will be ignored. Setting this config to -TRUE will add existing query string arguments back into the +By default your Query String arguments (nothing to do with other +query string options) will be ignored. Setting this config to +TRUE will add existing query string arguments back into the URL after the URI segment and before the suffix :: @@ -127,6 +127,18 @@ URL after the URI segment and before the suffix This helps you mix together normal :doc:`URI Segments <../general/urls>` as well as query string arguments, which until 3.0 was not possible. +$config['prefix'] = ''; +================================== + +A custom prefix added to the path. The prefix value will be right before +the offset segment. + +$config['suffix'] = ''; +================================== + +A custom suffix added to the path. The sufix value will be right after +the offset segment. + *********************** Adding Enclosing Markup *********************** -- cgit v1.2.3-24-g4f1b From a36fd63379cba76128ed4a0d88e9466abb4419d8 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 27 Jun 2012 02:46:19 +0200 Subject: FTP Class documentation cleanup Since PHP 5 is required, setting permissions is always possible. --- user_guide_src/source/libraries/ftp.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/ftp.rst b/user_guide_src/source/libraries/ftp.rst index 20b11a5c8..05a3fdcc8 100644 --- a/user_guide_src/source/libraries/ftp.rst +++ b/user_guide_src/source/libraries/ftp.rst @@ -26,7 +26,7 @@ Usage Examples In this example a connection is opened to the FTP server, and a local file is read and uploaded in ASCII mode. The file permissions are set to -755. Note: Setting permissions requires PHP 5. +755. :: @@ -136,8 +136,7 @@ Example:: **Mode options are:** ascii, binary, and auto (the default). If auto is used it will base the mode on the file extension of the source file. -Permissions are available if you are running PHP 5 and can be passed as -an octal value in the fourth parameter. +If set, permissions have to be passed as an octal value. $this->ftp->download() ====================== -- cgit v1.2.3-24-g4f1b From 58dfc089bf5b0ca35c2ff244e5bfdff726f9adcd Mon Sep 17 00:00:00 2001 From: Melounek Date: Fri, 29 Jun 2012 08:43:47 +0200 Subject: added parameter for returned-path in Email::from() --- user_guide_src/source/libraries/email.rst | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst index f99eb91df..8d2549d11 100644 --- a/user_guide_src/source/libraries/email.rst +++ b/user_guide_src/source/libraries/email.rst @@ -117,6 +117,13 @@ Sets the email address and name of the person sending the email:: $this->email->from('you@example.com', 'Your Name'); +:: + + $this->email->from('you@example.com', 'Your Name', 'returned_emails@example.com'); + +Third parameter is redirect for undelivered emails (may not be configured with +protocol 'smtp'). + $this->email->reply_to() ------------------------- -- cgit v1.2.3-24-g4f1b From a78c6e0cf48b090f9e5ac5f303efe361c10a1881 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Wed, 4 Jul 2012 06:52:19 -0700 Subject: Fix URL helper link --- user_guide_src/source/libraries/config.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/config.rst b/user_guide_src/source/libraries/config.rst index 694896353..08d9c2905 100644 --- a/user_guide_src/source/libraries/config.rst +++ b/user_guide_src/source/libraries/config.rst @@ -175,7 +175,7 @@ This function retrieves the URL to your site, plus an optional path such as to a stylesheet or image. The two functions above are normally accessed via the corresponding -functions in the :doc:`URL Helper `. +functions in the :doc:`URL Helper `. $this->config->system_url(); ***************************** -- cgit v1.2.3-24-g4f1b From a473d8009e5ef2043f1570acf632f3b1a1253ed0 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Mon, 30 Jul 2012 09:51:04 +0100 Subject: Updated email library documentation --- user_guide_src/source/libraries/email.rst | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst index c5fa68004..f56bc2ff5 100644 --- a/user_guide_src/source/libraries/email.rst +++ b/user_guide_src/source/libraries/email.rst @@ -226,6 +226,14 @@ success or failure, enabling it to be used conditionally:: // Generate error } +This function will automatically clear all parameters if the request was + successful. To stop this behaviour pass FALSE:: + + if ($this->email->send(FALSE)) + { + // Parameters won't be cleared + } + $this->email->attach() ---------------------- -- cgit v1.2.3-24-g4f1b From bdb99999195711903af712fab58fdf4ef3da72ad Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 30 Jul 2012 17:38:05 +0300 Subject: Some clean-up and style changes --- user_guide_src/source/libraries/email.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst index f56bc2ff5..4403079b6 100644 --- a/user_guide_src/source/libraries/email.rst +++ b/user_guide_src/source/libraries/email.rst @@ -227,7 +227,7 @@ success or failure, enabling it to be used conditionally:: } This function will automatically clear all parameters if the request was - successful. To stop this behaviour pass FALSE:: +successful. To stop this behaviour pass FALSE:: if ($this->email->send(FALSE)) { -- cgit v1.2.3-24-g4f1b From 3169f26fe6b5e23d5ab5d791143d1dd51d78f80d Mon Sep 17 00:00:00 2001 From: dchill42 Date: Sat, 11 Aug 2012 20:12:05 -0400 Subject: Updated Loader and Session documentation --- user_guide_src/source/libraries/loader.rst | 71 +++++- user_guide_src/source/libraries/sessions.rst | 338 ++++++++++++++++++++------- 2 files changed, 326 insertions(+), 83 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst index aadf9740a..5a17629d2 100644 --- a/user_guide_src/source/libraries/loader.rst +++ b/user_guide_src/source/libraries/loader.rst @@ -4,6 +4,7 @@ Loader Class Loader, as the name suggests, is used to load elements. These elements can be libraries (classes) :doc:`View files <../general/views>`, +:doc:`Drivers <../general/drivers>`, :doc:`Helpers <../general/helpers>`, :doc:`Models <../general/models>`, or your own files. @@ -74,6 +75,70 @@ Assigning a Library to a different object name If the third (optional) parameter is blank, the library will usually be assigned to an object with the same name as the library. For example, if +the library is named Calendar, it will be assigned to a variable named +$this->calendar. + +If you prefer to set your own class names you can pass its value to the +third parameter:: + + $this->load->library('calendar', '', 'my_calendar'); + + // Session class is now accessed using: + + $this->my_calendar + +Please take note, when multiple libraries are supplied in an array for +the first parameter, this parameter is discarded. + +$this->load->driver('parent_name', $config, 'object name') +=========================================================== + +This function is used to load driver libraries. Where parent_name is the +name of the parent class you want to load. + +As an example, if you would like to use sessions with CodeIgniter, the first +step is to load the session driver within your controller:: + + $this->load->driver('session'); + +Once loaded, the library will be ready for use, using +$this->session->*some_function*(). + +Driver files must be stored in a subdirectory within the main +"libraries" folder, or within your personal application/libraries +folder. The subdirectory must match the parent class name. Read the +:doc:`Drivers <../general/drivers>` description for details. + +Additionally, multiple driver libraries can be loaded at the same time by +passing an array of drivers to the load function. + +:: + + $this->load->driver(array('session', 'cache')); + +Setting options +--------------- + +The second (optional) parameter allows you to optionally pass +configuration settings. You will typically pass these as an array:: + + $config = array ( + 'sess_driver' => 'cookie', + 'sess_encrypt_cookie' => true, + 'encryption_key' => 'mysecretkey' + ); + + $this->load->driver('session', $config); + +Config options can usually also be set via a config file. Each library +is explained in detail in its own page, so please read the information +regarding each one you would like to use. + +Assigning a Driver to a different object name +---------------------------------------------- + +If the third (optional) parameter is blank, the library will be assigned +to an object with the same name as the parent class. For example, if the library is named Session, it will be assigned to a variable named $this->session. @@ -86,8 +151,8 @@ third parameter:: $this->my_session -Please take note, when multiple libraries are supplied in an array for -the first parameter, this parameter is discarded. +.. note:: Driver libraries may also be loaded with the library() method, + but it is faster to use driver() $this->load->view('file_name', $data, true/false) ================================================== @@ -281,4 +346,4 @@ calling add_package_path(). // Again without the second parameter: $this->load->add_package_path(APPPATH.'my_app', TRUE); $this->load->view('my_app_index'); // Loads - $this->load->view('welcome_message'); // Loads \ No newline at end of file + $this->load->view('welcome_message'); // Loads diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index 5400524a9..7a27a8f34 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -1,29 +1,19 @@ -############# -Session Class -############# +############## +Session Driver +############## The Session class permits you maintain a user's "state" and track their -activity while they browse your site. The Session class stores session -information for each user as serialized (and optionally encrypted) data -in a cookie. It can also store the session data in a database table for -added security, as this permits the session ID in the user's cookie to -be matched against the stored session ID. By default only the cookie is -saved. If you choose to use the database option you'll need to create -the session table as indicated below. - -.. note:: The Session class does **not** utilize native PHP sessions. It - generates its own session data, offering more flexibility for - developers. - -.. note:: Even if you are not using encrypted sessions, you must set - an :doc:`encryption key <./encryption>` in your config file which is used - to aid in preventing session data manipulation. +activity while they browse your site. CodeIgniter offers two default +session drivers: the classic `Cookie Driver`_, and the `Native Driver`_, +which supports usage of the native PHP Session mechanism. In addition, +you may create your own `Custom Drivers`_ to store session data however +you wish, while still taking advantage of the features of the Session class. Initializing a Session ====================== Sessions will typically run globally with each page load, so the session -class must either be :doc:`initialized <../general/libraries>` in your +class must either be :doc:`initialized <../general/drivers>` in your :doc:`controller <../general/controllers>` constructors, or it can be :doc:`auto-loaded <../general/autoloader>` by the system. For the most part the session class will run unattended in the background, so simply @@ -31,22 +21,25 @@ initializing the class will cause it to read, create, and update sessions. To initialize the Session class manually in your controller constructor, -use the $this->load->library function:: +use the $this->load->driver function:: - $this->load->library('session'); + $this->load->driver('session'); Once loaded, the Sessions library object will be available using: $this->session +.. note:: For backward compatibility, the Session class may stil be loaded + using the $this->load->library function, but converting your applications + to use $this->load->driver is strongly recommended. + How do Sessions work? ===================== When a page is loaded, the session class will check to see if valid -session data exists in the user's session cookie. If sessions data does -**not** exist (or if it has expired) a new session will be created and -saved in the cookie. If a session does exist, its information will be -updated and the cookie will be updated. With each update, the -session_id will be regenerated. +session data exists in the user's session. If sessions data does **not** +exist (or if it has expired) a new session will be created and saved. +If a session does exist, its information will be updated. With each update, +the session_id will be regenerated. It's important for you to understand that once initialized, the Session class runs automatically. There is nothing you need to do to cause the @@ -79,19 +72,12 @@ prototype:: 'last_activity' => timestamp ) -If you have the encryption option enabled, the serialized array will be -encrypted before being stored in the cookie, making the data highly -secure and impervious to being read or altered by someone. More info -regarding encryption can be :doc:`found here `, although -the Session class will take care of initializing and encrypting the data -automatically. - -Note: Session cookies are only updated every five minutes by default to -reduce processor load. If you repeatedly reload a page you'll notice -that the "last activity" time only updates if five minutes or more has -passed since the last time the cookie was written. This time is -configurable by changing the $config['sess_time_to_update'] line in -your system/config/config.php file. +.. note:: Sessions are only updated every five minutes by default to + reduce processor load. If you repeatedly reload a page you'll notice + that the "last activity" time only updates if five minutes or more has + passed since the last time the cookie was written. This time is + configurable by changing the $config['sess_time_to_update'] line in + your system/config/config.php file. Retrieving Session Data ======================= @@ -106,7 +92,7 @@ fetch. For example, to fetch the session ID you will do this:: $session_id = $this->session->userdata('session_id'); -.. note:: The function returns FALSE (boolean) if the item you are +.. note:: The function returns NULL if the item you are trying to access does not exist. Adding Custom Session Data @@ -117,7 +103,7 @@ to it and it will be stored in the user's cookie. Why would you want to do this? Here's one example: Let's say a particular user logs into your site. Once authenticated, you -could add their username and email address to the session cookie, making +could add their username and email address to the session, making that data globally available to you without having to run a database query when you need it. @@ -144,11 +130,11 @@ supports this syntax. $this->session->set_userdata('some_name', 'some_value'); +If you want to verify that a userdata value exists, call has_userdata(). -.. note:: Cookies can only hold 4KB of data, so be careful not to exceed - the capacity. The encryption process in particular produces a longer - data string than the original so keep careful track of how much data you - are storing. +:: + + $this->session->has_userdata('some_name'); Retrieving All Session Data =========================== @@ -195,8 +181,8 @@ available for the next server request, and are then automatically cleared. These can be very useful, and are typically used for informational or status messages (for example: "record 2 deleted"). -Note: Flash variables are prefaced with "flash\_" so avoid this prefix -in your own session names. +.. note:: Flash variables are prefaced with "flash\_" so avoid this prefix + in your own session names. To add flashdata:: @@ -222,9 +208,162 @@ additional request, you can do so using the keep_flashdata() function. $this->session->keep_flashdata('item'); +Tempdata +======== + +CodeIgniter also supports "tempdata", or session data with a specific +expiration time. After the value expires, or the session expires or is +deleted, the value is automatically removed. + +To add tempdata:: + + $expire = 300; // Expire in 5 minutes + + $this->session->set_tempdata('item', 'value', $expire); + +You can also pass an array to set_tempdata():: + + $tempdata = array('newuser' => TRUE, 'message' => 'Thanks for joining!'); + + $this->session->set_tempdata($tempdata, '', $expire); + +.. note:: If the expiration is omitted or set to 0, the default expiration of + 5 minutes will be used. + +To read a tempdata variable:: + + $this->session->tempdata('item'); + +If you need to remove a tempdata value before it expires, +use unset_tempdata():: + + $this->session->unset_tempdata('item'); + +Destroying a Session +==================== + +To clear the current session:: + + $this->session->sess_destroy(); + +.. note:: This function should be the last one called, and even flash + variables will no longer be available. If you only want some items + destroyed and not all, use unset_userdata(). + +Session Preferences +=================== + +You'll find the following Session related preferences in your +application/config/config.php file: + +=========================== =============== =========================== ========================================================================== +Preference Default Options Description +=========================== =============== =========================== ========================================================================== +**sess_driver** cookie cookie/native/*custom* The initial session driver to load. +**sess_valid_drivers** cookie, native None Additional valid drivers which may be loaded. +**sess_cookie_name** ci_session None The name you want the session cookie saved as (data for Cookie driver or + session ID for Native driver). +**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 (Cookie driver only). +**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 (Cookie driver only). +**sess_table_name** ci_sessions Any valid SQL table name The name of the session database table (Cookie driver only). +**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. +=========================== =============== =========================== ========================================================================== + +In addition to the values above, the cookie and native drivers apply the +following configuration values shared by the :doc:`Input ` and +:doc:`Security ` classes: + +=========================== =============== ========================================================================== +Preference Default Description +=========================== =============== ========================================================================== +**cookie_prefix** '' Set a cookie name prefix in order to avoid name collisions +**cookie_domain** '' The domain for which the session is applicable +**cookie_path** / The path to which the session is applicable +=========================== =============== ========================================================================== + +Session Drivers +=============== + +By default, the `Cookie Driver`_ is loaded when a session is initialized. +However, any valid driver may be selected with the $config['sess_driver'] +line in your config.php file. + +The session driver library comes with the cookie and native drivers +installed, and `Custom Drivers`_ may also be installed by the user. + +Typically, only one driver will be used at a time, but CodeIgniter does +support loading multiple drivers. If a specific valid driver is called, it +will be automatically loaded. Or, an additional driver may be explicitly +loaded by calling load_driver():: + + $this->session->load_driver('native'); + +The Session library keeps track of the most recently selected driver to call +for driver methods. Normally, session class methods are called directly on +the parent class, as illustrated above. However, any methods called through +a specific driver will select that driver before invoking the parent method. + +So, alternation between multiple drivers can be achieved by specifying which +driver to use for each call:: + + $this->session->native->set_userdata('foo', 'bar'); + + $this->session->cookie->userdata('foo'); + + $this->session->native->unset_userdata('foo'); + +Notice in the previous example that the *native* userdata value 'foo' +would be set to 'bar', which would NOT be returned by the call for +the *cookie* userdata 'foo', nor would the *cookie* value be unset by +the call to unset the *native* 'foo' value. The drivers maintain independent +sets of values, regardless of key names. + +A specific driver may also be explicitly selected for use by pursuant +methods with the select_driver() call:: + + $this->session->select_driver('native'); + + $this->session->userdata('item'); // Uses the native driver + +Cookie Driver +------------- + +The Cookie driver stores session information for each user as serialized +(and optionally encrypted) data in a cookie. It can also store the session +data in a database table for added security, as this permits the session ID +in the user's cookie to be matched against the stored session ID. By default +only the cookie is saved. If you choose to use the database option you'll +need to create the session table as indicated below. + +If you have the encryption option enabled, the serialized array will be +encrypted before being stored in the cookie, making the data highly +secure and impervious to being read or altered by someone. More info +regarding encryption can be :doc:`found here `, although +the Session class will take care of initializing and encrypting the data +automatically. + +.. note:: Even if you are not using encrypted sessions, you must set + an :doc:`encryption key <./encryption>` in your config file which is used + to aid in preventing session data manipulation. + +.. note:: Cookies can only hold 4KB of data, so be careful not to exceed + the capacity. The encryption process in particular produces a longer + data string than the original so keep careful track of how much data you + are storing. Saving Session Data to a Database -================================= +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ While the session data array stored in the user's cookie contains a Session ID, unless you store session data in a database there is no way @@ -267,44 +406,83 @@ session class:: $config['sess_table_name'] = 'ci_sessions'; -.. note:: The Session class has built-in garbage collection which clears +.. note:: The Cookie driver has built-in garbage collection which clears out expired sessions so you do not need to write your own routine to do it. -Destroying a Session -==================== +Native Driver +------------- -To clear the current session:: +The Native driver relies on native PHP sessions to store data in the +$_SESSION superglobal array. All stored values continue to be available +through $_SESSION, but flash- and temp- data items carry special prefixes. - $this->session->sess_destroy(); +Custom Drivers +-------------- -.. note:: This function should be the last one called, and even flash - variables will no longer be available. If you only want some items - destroyed and not all, use unset_userdata(). +You may also :doc:`create your own <../general/creating_drivers>` custom +session drivers. A session driver basically manages an array of name/value +pairs with some sort of storage mechanism. -Session Preferences -=================== +To make a new driver, extend CI_Session_driver. Overload the initialize +method and read or create session data. Then implement a save handler to +write changed data to storage (sess_save), a destroy handler to remove +deleted data (sess_destroy), a regenerate handler to make a new session ID, +and an access handler to expose the data (get_userdata). Your initial class +might look like:: -You'll find the following Session related preferences in your -application/config/config.php file: + class CI_Session_custom extends CI_Session_driver { + protected function initialize() + { + // Read existing session data or create a new one + } + + public function sess_save() + { + // Save current data to storage + } + + public function sess_destroy() + { + // Destroy the current session and clean up storage + } + + public function sess_regenerate() + { + // Create new session ID + } + + public function &get_userdata() + { + // Return a reference to your userdata array + } + } + +Notice that get_userdata() returns a reference so the parent library is +accessing the same array the driver object is using. This saves memory +and avoids synchronization issues during usage. + +Put your driver in the libraries/Session/drivers folder anywhere in your +package paths. This includes the application directory, the system directory, +or any path you add with $CI->load->add_package_path(). Your driver must be +named CI_Session_, and your filename must be Session_.php, +preferably also capitalized, such as:: + + CI_Session_foo in libraries/Session/drivers/Session_foo.php + +Then specify the driver by setting 'sess_driver' in your config.php file or as a +parameter when loading the CI_Session object:: + + $config['sess_driver'] = 'foo'; + +OR:: + + $CI->load->driver('session', array('sess_driver' => 'foo')); + +The driver specified by 'sess_driver' is automatically included as a valid +driver. However, if you want to make a custom driver available as an option +without making it the initially loaded driver, set 'sess_valid_drivers' in +your config.php file to an array including your driver name:: + + $config['sess_valid_drivers'] = array('sess_driver'); -=========================== =============== =========================== ========================================================================== -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 -- cgit v1.2.3-24-g4f1b From b3816b794592873a4e98187e66745544b463e933 Mon Sep 17 00:00:00 2001 From: dchill42 Date: Mon, 13 Aug 2012 09:47:58 -0400 Subject: Minor doc fixes --- user_guide_src/source/libraries/loader.rst | 2 +- user_guide_src/source/libraries/sessions.rst | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst index 5a17629d2..33c1bafec 100644 --- a/user_guide_src/source/libraries/loader.rst +++ b/user_guide_src/source/libraries/loader.rst @@ -83,7 +83,7 @@ third parameter:: $this->load->library('calendar', '', 'my_calendar'); - // Session class is now accessed using: + // Calendar class is now accessed using: $this->my_calendar diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index 7a27a8f34..dd9e8cbb4 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -424,12 +424,12 @@ You may also :doc:`create your own <../general/creating_drivers>` custom session drivers. A session driver basically manages an array of name/value pairs with some sort of storage mechanism. -To make a new driver, extend CI_Session_driver. Overload the initialize +To make a new driver, extend CI_Session_driver. Overload the initialize() method and read or create session data. Then implement a save handler to write changed data to storage (sess_save), a destroy handler to remove -deleted data (sess_destroy), a regenerate handler to make a new session ID, -and an access handler to expose the data (get_userdata). Your initial class -might look like:: +deleted data (sess_destroy), a regenerate handler to make a new session ID +(sess_regenerate), and an access handler to expose the data (get_userdata). +Your initial class might look like:: class CI_Session_custom extends CI_Session_driver { protected function initialize() -- cgit v1.2.3-24-g4f1b From 19ac8bc3fc55460660cca618b6cce0ef212e7bdc Mon Sep 17 00:00:00 2001 From: RecoilUK Date: Thu, 23 Aug 2012 20:43:48 +0200 Subject: Update user_guide_src/source/libraries/form_validation.rst --- user_guide_src/source/libraries/form_validation.rst | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 3bcad7ba6..bc25d8292 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -488,6 +488,15 @@ the name of the function:: $this->form_validation->set_message('username_check') +If you are using an error message that can accept two $s in your error string, +such as .. + + $this->form_validation->set_message('min_length', 'The $s field must contain at least $s characters.'); + +Then you can also use %1$s and %2$s: + + $this->form_validation->set_message('min_length', 'This field must contain at least %2$s characters.'); + You can also override any error message found in the language file. For example, to change the message for the "required" rule you will do this:: -- cgit v1.2.3-24-g4f1b From f3fddf6e0f4b0b0976c433c139326bdcd45d2da0 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 31 Aug 2012 10:10:16 +0800 Subject: fix issue #1719 and update ip address length on captcha helper Signed-off-by: Bo-Yi Wu --- user_guide_src/source/libraries/trackback.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/trackback.rst b/user_guide_src/source/libraries/trackback.rst index 07b2b2177..f9e0df882 100644 --- a/user_guide_src/source/libraries/trackback.rst +++ b/user_guide_src/source/libraries/trackback.rst @@ -114,7 +114,7 @@ store them. Here is a basic prototype for such a table:: excerpt text NOT NULL, blog_name varchar(100) NOT NULL, tb_date int(10) NOT NULL, - ip_address varchar(16) NOT NULL, + ip_address varchar(45) NOT NULL, PRIMARY KEY `tb_id` (`tb_id`), KEY `entry_id` (`entry_id`) ); -- cgit v1.2.3-24-g4f1b From 7c70d10d699d7f7ecd446bf81c9e05de0811f282 Mon Sep 17 00:00:00 2001 From: pickupman Date: Sun, 2 Sep 2012 23:40:49 -0400 Subject: Fix #1741 is_unique duplicated in documentation for Form_validation --- user_guide_src/source/libraries/form_validation.rst | 1 - 1 file changed, 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 3bcad7ba6..39f787402 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -884,7 +884,6 @@ Rule Parameter Description 0, 1, 2, 3, etc. **is_natural_no_zero** No Returns FALSE if the form element contains anything other than a natural number, but not zero: 1, 2, 3, etc. -**is_unique** Yes Returns FALSE if the form element is not unique in a database table. is_unique[table.field] **valid_email** No Returns FALSE if the form element does not contain a valid email address. **valid_emails** No Returns FALSE if any value provided in a comma separated list is not a valid email. **valid_ip** No Returns FALSE if the supplied IP is not valid. -- cgit v1.2.3-24-g4f1b From 596e48d30d91c69a3a4a0bfbd059e8fa21d88ad1 Mon Sep 17 00:00:00 2001 From: Joe McFrederick Date: Tue, 4 Sep 2012 14:25:47 -0400 Subject: Add documation to user guide for Migrations class --- user_guide_src/source/libraries/migration.rst | 134 +++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst index 5192f1f29..cb7d96a6d 100644 --- a/user_guide_src/source/libraries/migration.rst +++ b/user_guide_src/source/libraries/migration.rst @@ -2,4 +2,136 @@ Migrations Class ################ -Coming soon. \ No newline at end of file +Migrations are a convenient way for you to alter your database in a +structured and organized manner. You could edit fragments of SQL by hand +but you would then be responsible for telling other developers that they +need to go and run them. You would also have to keep track of which changes +need to be run against the production machines next time you deploy. + +The database table **migration** tracks which migrations have already been +run so all you have to do is update your application files and +call **$this->migrate->current()** to work out which migrations should be run. +The current version is found in **config/migration.php**. + +****************** +Create a Migration +****************** + +.. note:: Each Migration is run in numerical order forward or backwards + depending on the method taken. Use a prefix of 3 numbers followed by an + underscore for the filename of your migration. + +This will be the first migration for a new site which has a blog. All +migrations go in the folder **application/migrations/** and have names such +as: **001_add_blog.php**.:: + + defined('BASEPATH') OR exit('No direct script access allowed'); + + class Migration_Add_blog extends CI_Migration { + + public function up() + { + $this->dbforge->add_field(array( + 'blog_id' => array( + 'type' => 'INT', + 'constraint' => 5, + 'unsigned' => TRUE, + 'auto_increment' => TRUE + ), + 'blog_title' => array( + 'type' => 'VARCHAR', + 'constraint' => '100', + ), + 'blog_description' => array( + 'type' => 'TEXT', + 'null' => TRUE, + ), + )); + + $this->dbforge->create_table('blog'); + } + + public function down() + { + $this->dbforge->drop_table('blog'); + } + +Then in **application/config/migration.php** set **$config['migration_version'] = 1;**. + +************* +Usage Example +************* + +In this example some simple code is placed in **application/controllers/migrate.php** +to update the schema.:: + + $this->load->library('migration'); + + if ( ! $this->migration->current()) + { + show_error($this->migration->error_string()); + } + +****************** +Function Reference +****************** + +There are five available methods for the Migration class: + +- $this->migration->current(); +- $this->migration->error_string(); +- $this->migration->find_migrations(); +- $this->migration->latest(); +- $this->migration->version(); + +$this->migration->current() +============================ + +The current migration is whatever is set for **$config['migration_version']** in +**application/config/migration.php**. + +$this->migration->error_string() +================================= + +This returns a string of errors while performing a migration. + +$this->migration->find_migrations() +==================================== + +An array of migration filenames are returned that are found in the **migration_path** +property. + +$this->migration->latest() +=========================== + +This works much the same way as current() but instead of looking for +the **$config['migration_version']** the Migration class will use the very +newest migration found in the filesystem. + +$this->migration->version() +============================ + +Version can be used to roll back changes or step forwards programmatically to +specific versions. It works just like current but ignores **$config['migration_version']**.:: + + $this->load->library('migration'); + + $this->migration->version(5); + +********************* +Migration Preferences +********************* + +The following is a table of all the config options for migrations. + +========================== ====================== ============= ============================================= +Preference Default Options Description +========================== ====================== ============= ============================================= +**migration_enabled** FALSE TRUE / FALSE Enable or disable migrations. +**migration_path** APPPATH.'migrations/' None The path to your migrations folder. +**migration_version** 0 None The current version your database should use. +**migration_table** migrations None The table name for storing the shema + version number. +**migration_auto_latest** FALSE TRUE / FALSE Enable or disable automatically + running migrations. +========================== ====================== ============= ============================================= -- cgit v1.2.3-24-g4f1b From 65bdaf5e2636cb7aa8780826529020ab0bfe9252 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 21 Sep 2012 13:49:09 +0800 Subject: Fixed pagination document error. Signed-off-by: Bo-Yi Wu --- user_guide_src/source/libraries/pagination.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst index 7d750bd23..00554c1c7 100644 --- a/user_guide_src/source/libraries/pagination.rst +++ b/user_guide_src/source/libraries/pagination.rst @@ -80,7 +80,7 @@ The number of "digit" links you would like before and after the selected page number. For example, the number 2 will place two digits on either side, as in the example links at the very top of this page. -$config['use_page_number'] = TRUE; +$config['use_page_numbers'] = TRUE; ================================== By default, the URI segment will use the starting index for the items -- cgit v1.2.3-24-g4f1b From a5e329ff95e0308c07b8db04117f056081997796 Mon Sep 17 00:00:00 2001 From: "W. Kristianto" Date: Sun, 23 Sep 2012 22:34:18 +0700 Subject: Update user_guide_src/source/libraries/loader.rst Remove the second parameter --- user_guide_src/source/libraries/loader.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst index 33c1bafec..615aba1c2 100644 --- a/user_guide_src/source/libraries/loader.rst +++ b/user_guide_src/source/libraries/loader.rst @@ -344,6 +344,6 @@ calling add_package_path(). $this->load->remove_package_path(APPPATH.'my_app'); // Again without the second parameter: - $this->load->add_package_path(APPPATH.'my_app', TRUE); + $this->load->add_package_path(APPPATH.'my_app'); $this->load->view('my_app_index'); // Loads $this->load->view('welcome_message'); // Loads -- cgit v1.2.3-24-g4f1b From 9438e26671ee1f0b49c8da7a56a0a195788fd5da Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 5 Oct 2012 13:16:27 +0300 Subject: Fix issue #116 + other space/style fixes [ci skip --- user_guide_src/source/libraries/image_lib.rst | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/image_lib.rst b/user_guide_src/source/libraries/image_lib.rst index ed6575c62..dcdccbd92 100644 --- a/user_guide_src/source/libraries/image_lib.rst +++ b/user_guide_src/source/libraries/image_lib.rst @@ -91,9 +91,9 @@ error upon failure, like this:: echo $this->image_lib->display_errors(); } -Note: You can optionally specify the HTML formatting to be applied to -the errors, by submitting the opening/closing tags in the function, like -this:: +.. note:: You can optionally specify the HTML formatting to be applied to + the errors, by submitting the opening/closing tags in the function, + like this:: $this->image_lib->display_errors('

', '

'); @@ -225,8 +225,7 @@ pixels) specifying where to crop, like this:: $config['y_axis'] = '40'; All preferences listed in the table above are available for this -function except these: rotation_angle, width, height, create_thumb, -new_image. +function except these: rotation_angle, create_thumb, new_image. Here's an example showing how you might crop an image:: @@ -243,11 +242,11 @@ Here's an example showing how you might crop an image:: echo $this->image_lib->display_errors(); } -Note: Without a visual interface it is difficult to crop images, so this -function is not very useful unless you intend to build such an -interface. That's exactly what we did using for the photo gallery module -in ExpressionEngine, the CMS we develop. We added a JavaScript UI that -lets the cropping area be selected. +.. note:: Without a visual interface it is difficult to crop images, so this + function is not very useful unless you intend to build such an + interface. That's exactly what we did using for the photo gallery module + in ExpressionEngine, the CMS we develop. We added a JavaScript UI that + lets the cropping area be selected. $this->image_lib->rotate() =========================== @@ -338,8 +337,8 @@ The above example will use a 16 pixel True Type font to create the text bottom/center of the image, 20 pixels from the bottom of the image. .. note:: In order for the image class to be allowed to do any - processing, the image file must have "write" file permissions. For - example, 777. + processing, the image file must have "write" file permissions + For example, 777. Watermarking Preferences ======================== -- cgit v1.2.3-24-g4f1b From 241a69be96de350b18d875304eb1e361b710e148 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 5 Oct 2012 14:58:36 +0300 Subject: [ci skip] Add a note to the user guide regarding issue #1010 --- user_guide_src/source/libraries/form_validation.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 39f787402..faf221981 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -861,8 +861,9 @@ Rule Parameter Description ========================= ========== ============================================================================================= ======================= **required** No Returns FALSE if the form element is empty. **matches** Yes Returns FALSE if the form element does not match the one in the parameter. matches[form_item] -**is_unique** Yes Returns FALSE if the form element is not unique to the is_unique[table.field] - table and field name in the parameter. is_unique[table.field] +**is_unique** Yes Returns FALSE if the form element is not unique to the table and field name in the is_unique[table.field] + parameter. Note: This rule requires :doc:`Query Builder ` to be + enabled in order to work. **max_length** Yes Returns FALSE if the form element is longer then the parameter value. max_length[12] **exact_length** Yes Returns FALSE if the form element is not exactly the parameter value. exact_length[8] **greater_than** Yes Returns FALSE if the form element is less than or equal to the parameter value or not greater_than[8] -- cgit v1.2.3-24-g4f1b From 6123b61e8ec95ac91f67bfbf442e34021c922319 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 5 Oct 2012 15:54:43 +0300 Subject: Fix issue #1340 [ci skip] --- user_guide_src/source/libraries/file_uploading.rst | 1 + 1 file changed, 1 insertion(+) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/file_uploading.rst b/user_guide_src/source/libraries/file_uploading.rst index 65cd5c722..1698dcbb9 100644 --- a/user_guide_src/source/libraries/file_uploading.rst +++ b/user_guide_src/source/libraries/file_uploading.rst @@ -197,6 +197,7 @@ Preference Default Value Options Descripti Separate multiple types with a pipe. **file_name** None Desired file name If set CodeIgniter will rename the uploaded file to this name. The extension provided in the file name must also be an allowed file type. + If no extension is provided in the original file_name will be used. **overwrite** FALSE TRUE/FALSE (boolean) If set to true, if a file with the same name as the one you are uploading exists, it will be overwritten. If set to false, a number will be appended to the filename if another with the same name exists. -- cgit v1.2.3-24-g4f1b From ccd01c75f5802e4e4b74bb53414a58d2aa0fd0d8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 5 Oct 2012 17:12:55 +0300 Subject: Polish changes from #1586 --- user_guide_src/source/libraries/email.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst index fc324ffc9..e7ed9f74c 100644 --- a/user_guide_src/source/libraries/email.rst +++ b/user_guide_src/source/libraries/email.rst @@ -117,12 +117,12 @@ Sets the email address and name of the person sending the email:: $this->email->from('you@example.com', 'Your Name'); -:: +You can also set a Return-Path, to help redirect undelivered mail:: $this->email->from('you@example.com', 'Your Name', 'returned_emails@example.com'); -Third parameter is redirect for undelivered emails (may not be configured with -protocol 'smtp'). +.. note:: Return-Path can't be used if you've configured + 'smtp' as your protocol. $this->email->reply_to() ------------------------- -- cgit v1.2.3-24-g4f1b From 9e31f8f1600c6577f46a855eee6a3c7d527aebea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 5 Oct 2012 17:31:46 +0300 Subject: Fix #1745 --- user_guide_src/source/libraries/form_validation.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 29e1be032..bc922e69b 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -489,11 +489,13 @@ the name of the function:: $this->form_validation->set_message('username_check') If you are using an error message that can accept two $s in your error string, -such as .. +such as: +:: $this->form_validation->set_message('min_length', 'The $s field must contain at least $s characters.'); Then you can also use %1$s and %2$s: +:: $this->form_validation->set_message('min_length', 'This field must contain at least %2$s characters.'); -- cgit v1.2.3-24-g4f1b From 73766c239318974b7e8ed02ab441794cab7f523f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 5 Oct 2012 20:32:14 +0300 Subject: [ci skip] Small doc fixes, thanks dchill42 --- user_guide_src/source/libraries/pagination.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst index 00554c1c7..d9d3f5092 100644 --- a/user_guide_src/source/libraries/pagination.rst +++ b/user_guide_src/source/libraries/pagination.rst @@ -81,7 +81,7 @@ page number. For example, the number 2 will place two digits on either side, as in the example links at the very top of this page. $config['use_page_numbers'] = TRUE; -================================== +=================================== By default, the URI segment will use the starting index for the items you are paginating. If you prefer to show the the actual page number, -- cgit v1.2.3-24-g4f1b From 92f00046751d44b3e938d6be1fc49017dd0e0040 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 5 Oct 2012 20:43:36 +0300 Subject: [ci skip] More doc fixes --- user_guide_src/source/libraries/form_validation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index bc922e69b..14305b664 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -873,7 +873,7 @@ Rule Parameter Description **required** No Returns FALSE if the form element is empty. **matches** Yes Returns FALSE if the form element does not match the one in the parameter. matches[form_item] **is_unique** Yes Returns FALSE if the form element is not unique to the table and field name in the is_unique[table.field] - parameter. Note: This rule requires :doc:`Query Builder ` to be + parameter. Note: This rule requires :doc:`Query Builder <../database/query_builder>` to be enabled in order to work. **max_length** Yes Returns FALSE if the form element is longer then the parameter value. max_length[12] **exact_length** Yes Returns FALSE if the form element is not exactly the parameter value. exact_length[8] -- cgit v1.2.3-24-g4f1b From 956631d2b8f0f1173f55134b8465b41d2018edfa Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 6 Oct 2012 20:43:47 +0300 Subject: [ci skip] Alter some changelog entries --- user_guide_src/source/libraries/output.rst | 3 +++ 1 file changed, 3 insertions(+) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/output.rst b/user_guide_src/source/libraries/output.rst index 0472d14cf..3289a241f 100644 --- a/user_guide_src/source/libraries/output.rst +++ b/user_guide_src/source/libraries/output.rst @@ -105,6 +105,9 @@ Permits you to manually set a server status header. Example:: `See here `_ for a full list of headers. +.. note:: This method is an alias for :doc:`Common function <../general/common_funtions.rst>` + ``set_status_header()``. + $this->output->enable_profiler(); ================================== -- cgit v1.2.3-24-g4f1b From 960e616d18c77f463e7c53f666d98b09f5ca9057 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 7 Oct 2012 15:48:55 +0300 Subject: Fix a typo [ci skip] --- user_guide_src/source/libraries/form_validation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 14305b664..22272dc9b 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -399,7 +399,7 @@ The validation system supports callbacks to your own validation functions. This permits you to extend the validation class to meet your needs. For example, if you need to run a database query to see if the user is choosing a unique username, you can create a callback function -that does that. Let's create a example of this. +that does that. Let's create an example of this. In your controller, change the "username" rule to this:: -- cgit v1.2.3-24-g4f1b From 6d9915a7a82ff3f7e9dc0f4969764788cf005f36 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 10 Oct 2012 16:18:33 +0300 Subject: Update Email library docs --- user_guide_src/source/libraries/email.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst index e7ed9f74c..da3bf2616 100644 --- a/user_guide_src/source/libraries/email.rst +++ b/user_guide_src/source/libraries/email.rst @@ -97,7 +97,7 @@ Preference Default Value Options Descript **mailtype** text text or html Type of mail. If you send HTML email you must send it as a complete web page. Make sure you don't have any relative links or relative image paths otherwise they will not work. -**charset** utf-8 Character set (utf-8, iso-8859-1, etc.). +**charset** ``$config['charset']`` Character set (utf-8, iso-8859-1, etc.). **validate** FALSE TRUE or FALSE (boolean) Whether to validate the email address. **priority** 3 1, 2, 3, 4, 5 Email Priority. 1 = highest. 5 = lowest. 3 = normal. **crlf** \\n "\\r\\n" or "\\n" or "\\r" Newline character. (Use "\\r\\n" to comply with RFC 822). -- cgit v1.2.3-24-g4f1b From f38564d739455f46eb38bcbfaa8e255d0a50defe Mon Sep 17 00:00:00 2001 From: Raul Baldner Junior Date: Thu, 11 Oct 2012 11:32:23 -0300 Subject: New form_validation rule: 'differs' Added new validation rule 'differs'. It checks if the value of a field differs from the value of another field. --- user_guide_src/source/libraries/form_validation.rst | 1 + 1 file changed, 1 insertion(+) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 22272dc9b..6c6743d06 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -872,6 +872,7 @@ Rule Parameter Description ========================= ========== ============================================================================================= ======================= **required** No Returns FALSE if the form element is empty. **matches** Yes Returns FALSE if the form element does not match the one in the parameter. matches[form_item] +**differs** Yes Returns FALSE if the form element does not differ from the one in the parameter. differs[form_item] **is_unique** Yes Returns FALSE if the form element is not unique to the table and field name in the is_unique[table.field] parameter. Note: This rule requires :doc:`Query Builder <../database/query_builder>` to be enabled in order to work. -- cgit v1.2.3-24-g4f1b From 126c09bdf89b904615017127de8192f18d54b61b Mon Sep 17 00:00:00 2001 From: János Rusiczki Date: Tue, 16 Oct 2012 01:50:31 +0300 Subject: Update user_guide_src/source/libraries/javascript.rst --- user_guide_src/source/libraries/javascript.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/javascript.rst b/user_guide_src/source/libraries/javascript.rst index d5e09c314..393d4e321 100644 --- a/user_guide_src/source/libraries/javascript.rst +++ b/user_guide_src/source/libraries/javascript.rst @@ -192,7 +192,7 @@ and triggered by a click using the jQuery library's click() event. 'width' => '50%', 'marginLeft' => 125 ); - $this->jquery->click('#trigger', $this->jquery->animate('#note', $params, normal)); + $this->jquery->click('#trigger', $this->jquery->animate('#note', $params, 'normal')); fadeIn() / fadeOut() -------------------- -- cgit v1.2.3-24-g4f1b From 2220fbe70503dd6d7ff9b2a57b84685955e815ab Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 16 Oct 2012 05:43:26 +0300 Subject: Fix user guide typos [ci skip] --- user_guide_src/source/libraries/output.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/output.rst b/user_guide_src/source/libraries/output.rst index 3289a241f..2b72ba777 100644 --- a/user_guide_src/source/libraries/output.rst +++ b/user_guide_src/source/libraries/output.rst @@ -105,7 +105,7 @@ Permits you to manually set a server status header. Example:: `See here `_ for a full list of headers. -.. note:: This method is an alias for :doc:`Common function <../general/common_funtions.rst>` +.. note:: This method is an alias for :doc:`Common function <../general/common_functions.rst>` ``set_status_header()``. $this->output->enable_profiler(); -- cgit v1.2.3-24-g4f1b From 3639d4798cd1ac26b715d8d74ff7855474fb01d7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 24 Oct 2012 11:43:21 +0300 Subject: [ci skip] Fix an erroneous link in the docs --- user_guide_src/source/libraries/output.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/output.rst b/user_guide_src/source/libraries/output.rst index 2b72ba777..82b1a56a5 100644 --- a/user_guide_src/source/libraries/output.rst +++ b/user_guide_src/source/libraries/output.rst @@ -105,7 +105,7 @@ Permits you to manually set a server status header. Example:: `See here `_ for a full list of headers. -.. note:: This method is an alias for :doc:`Common function <../general/common_functions.rst>` +.. note:: This method is an alias for :doc:`Common function <../general/common_functions>` ``set_status_header()``. $this->output->enable_profiler(); -- cgit v1.2.3-24-g4f1b From 5fd3ae8d33a4f5d3159b86683b9a670e973a63f5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 24 Oct 2012 14:55:35 +0300 Subject: [ci skip] style and phpdoc-related changes (rel #1295) --- user_guide_src/source/libraries/user_agent.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/user_agent.rst b/user_guide_src/source/libraries/user_agent.rst index 855ece29d..97abd2244 100644 --- a/user_guide_src/source/libraries/user_agent.rst +++ b/user_guide_src/source/libraries/user_agent.rst @@ -72,7 +72,7 @@ Returns TRUE/FALSE (boolean) if the user agent is a known web browser. { echo 'You are using Safari.'; } - else if ($this->agent->is_browser()) + elseif ($this->agent->is_browser()) { echo 'You are using a browser.'; } @@ -94,7 +94,7 @@ Returns TRUE/FALSE (boolean) if the user agent is a known mobile device. { $this->load->view('iphone/home'); } - else if ($this->agent->is_mobile()) + elseif ($this->agent->is_mobile()) { $this->load->view('mobile/home'); } -- cgit v1.2.3-24-g4f1b From 2dce1ffda218456e19f28edce8b0d74122f4d55c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 24 Oct 2012 20:49:04 +0300 Subject: Fix #1268 (or rather enforce some security measures, there's nothing really broken) --- user_guide_src/source/libraries/language.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/language.rst b/user_guide_src/source/libraries/language.rst index ec678cd21..b231f14a3 100644 --- a/user_guide_src/source/libraries/language.rst +++ b/user_guide_src/source/libraries/language.rst @@ -54,7 +54,9 @@ first. Loading a language file is done with the following code:: Where filename is the name of the file you wish to load (without the file extension), and language is the language set containing it (ie, english). If the second parameter is missing, the default language set -in your application/config/config.php file will be used. +in your *application/config/config.php* file will be used. + +.. note:: The *language* parameter can only consist of letters. Fetching a Line of Text ======================= @@ -67,8 +69,7 @@ text using this function:: Where language_key is the array key corresponding to the line you wish to show. -Note: This function simply returns the line. It does not echo it for -you. +.. note:: This method simply returns the line. It does not echo it. Using language lines as form labels ----------------------------------- -- cgit v1.2.3-24-g4f1b From f795ab52dadaef20afd3a97ad4c8ed408e211dc2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 24 Oct 2012 21:28:25 +0300 Subject: [ci skip] Document get_csrf_token_name(), get_csrf_hash() (issue #715) --- user_guide_src/source/libraries/security.rst | 45 +++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 7 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/security.rst b/user_guide_src/source/libraries/security.rst index e7d25555f..05553142f 100644 --- a/user_guide_src/source/libraries/security.rst +++ b/user_guide_src/source/libraries/security.rst @@ -26,7 +26,7 @@ processing since it requires a fair amount of processing overhead. To filter data through the XSS filter use this function: $this->security->xss_clean() -============================= +============================ Here is an usage example:: @@ -56,7 +56,7 @@ browser may attempt to execute. } $this->security->sanitize_filename() -===================================== +==================================== When accepting filenames from user input, it is best to sanitize them to prevent directory traversal and other security related issues. To do so, @@ -76,16 +76,35 @@ parameter, $relative_path to TRUE. Cross-site request forgery (CSRF) ================================= -You can enable csrf protection by opening your +You can enable CSRF protection by opening your application/config/config.php file and setting this:: $config['csrf_protection'] = TRUE; -If you use the :doc:`form helper <../helpers/form_helper>` the -form_open() function will automatically insert a hidden csrf field in -your forms. +If you use the :doc:`form helper <../helpers/form_helper>`, then +``form_open()`` will automatically insert a hidden csrf field in +your forms. If not, then you can use ``csrf_get_token_name()`` +and ``csrf_get_hash()`` -Tokens may be either regenerated on every submission (default) or kept the same throughout the life of the CSRF cookie. The default regeneration of tokens provides stricter security but may result in usability concerns as other tokens become invalid (back/forward navigation, multiple tabs/windows, asynchronous actions, etc). You may alter this behavior by editing the following config parameter:: +:: + + $csrf = array( + 'name' => $this->security->csrf_get_token_name(), + 'hash' => $this->security->csrf_get_hash() + ); + + ... + + + +Tokens may be either regenerated on every submission (default) or +kept the same throughout the life of the CSRF cookie. The default +regeneration of tokens provides stricter security, but may result +in usability concerns as other tokens become invalid (back/forward +navigation, multiple tabs/windows, asynchronous actions, etc). You +may alter this behavior by editing the following config parameter + +:: $config['csrf_regeneration'] = TRUE; @@ -95,3 +114,15 @@ by editing the 'csrf_exclude_uris' config parameter:: $config['csrf_exclude_uris'] = array('api/person/add'); +$this->security->get_csrf_token_name() +====================================== + +Returns the CSRF token name, which is set by +``$config['csrf_token_name']``. + +$this->security->get_csrf_hash() +================================ + +Returns the CSRF hash value. Useful in combination with +``get_csrf_token_name()`` for manually building forms or +sending valid AJAX POST requests. \ No newline at end of file -- cgit v1.2.3-24-g4f1b From cdeee661db2438cc65304f704ab4bcebeccb9b7d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 25 Oct 2012 17:29:52 +0300 Subject: Add CI_Cart::get_item() (rel #400) --- user_guide_src/source/libraries/cart.rst | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/cart.rst b/user_guide_src/source/libraries/cart.rst index 6594b3b9a..716e94bcb 100644 --- a/user_guide_src/source/libraries/cart.rst +++ b/user_guide_src/source/libraries/cart.rst @@ -279,16 +279,22 @@ by which this is returned by passing it "true" where the contents will be sorted from newest to oldest, by leaving this function blank, you'll automatically just get first added to the basket to last added to the basket. -$this->cart->has_options(rowid); -******************************** +$this->cart->get_item($row_id); +******************************* + +Returns an array containing data for the item matching the specified row ID, +or FALSE if no such item exists. + +$this->cart->has_options($row_id); +********************************** Returns TRUE (boolean) if a particular row in the cart contains options. This function is designed to be used in a loop with $this->cart->contents(), since you must pass the rowid to this function, as shown in the Displaying the Cart example above. -$this->cart->product_options(rowid); -************************************ +$this->cart->product_options($row_id); +************************************** Returns an array of options for a particular product. This function is designed to be used in a loop with $this->cart->contents(), since you -- cgit v1.2.3-24-g4f1b From 58c2b10eff196d6e7e4c678a3d7ef13bbc030124 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 26 Oct 2012 14:42:29 +0300 Subject: Implement cache key prefixing (as suggested in #1197) and update the Cache docs --- user_guide_src/source/libraries/caching.rst | 57 ++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 9 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/caching.rst b/user_guide_src/source/libraries/caching.rst index 2f06d29f9..8d7b4c440 100644 --- a/user_guide_src/source/libraries/caching.rst +++ b/user_guide_src/source/libraries/caching.rst @@ -32,6 +32,17 @@ available in the hosting environment. echo $foo; +You can also prefix cache item names via the **key_prefix** setting, which is useful +to avoid collisions when you're running multiple applications on the same environment. + +:: + + $this->load->driver('cache', + array('adapter' => 'apc', 'backup' => 'file', 'key_prefix' => 'my_') + ); + + $this->cache->get('foo'); // Will get the cache entry named 'my_foo' + ****************** Function Reference ****************** @@ -39,7 +50,7 @@ Function Reference .. php:class:: CI_Cache is_supported() -=============== +============== .. php:method:: is_supported ( $driver ) @@ -130,7 +141,7 @@ clean() $this->cache->clean(); cache_info() -============= +============ .. php:method:: cache_info ( ) @@ -148,7 +159,7 @@ cache_info() get_metadata() -=============== +============== .. php:method:: get_metadata ( $id ) @@ -166,7 +177,6 @@ get_metadata() .. note:: The information returned and the structure of the data is dependent on which adapter is being used. - ******* Drivers ******* @@ -181,7 +191,7 @@ specific adapter to the driver loader as follows:: $this->cache->apc->save('foo', 'bar', 10); For more information on APC, please see -`http://php.net/apc `_ +`http://php.net/apc `_. File-based Caching ================== @@ -201,20 +211,49 @@ Memcached Caching ================= Multiple Memcached servers can be specified in the memcached.php -configuration file, located in the application/config/ directory. +configuration file, located in the _application/config/* directory. -All of the functions listed above can be accessed without passing a +All of the methods listed above can be accessed without passing a specific adapter to the driver loader as follows:: $this->load->driver('cache'); $this->cache->memcached->save('foo', 'bar', 10); For more information on Memcached, please see -`http://php.net/memcached `_ +`http://php.net/memcached `_. + +WinCache Caching +================ + +Under Windows, you can also utilize the WinCache driver. + +All of the functions listed above can be accessed without passing a +specific adapter to the driver loader as follows:: + + $this->load->driver('cache'); + $this->cache->wincache->save('foo', 'bar', 10); + +For more information on WinCache, please see +`http://php.net/wincache `_. + +Redis Caching +============= + +All of the methods listed above can be accessed without passing a +specific adapter to the driver loader as follows:: + + $this->load->driver('cache'); + $this->cache->redis->save('foo', 'bar', 10); + +.. important:: Redis may require one or more of the following options: + **host**, **post**, **timeout**, **password**. + +The Redis PHP extension repository is located at +`https://github.com/nicolasff/phpredis `_. Dummy Cache =========== This is a caching backend that will always 'miss.' It stores no data, but lets you keep your caching code in place in environments that don't -support your chosen cache. +support your chosen cache. \ No newline at end of file -- cgit v1.2.3-24-g4f1b From a779b2cf8ceaea5ecfd8d26f5e2c379b8fca48d8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 26 Oct 2012 16:25:47 +0300 Subject: Fix #1624 and clear-up the form validation docs (manually applying #1603) --- .../source/libraries/form_validation.rst | 190 ++++++++++----------- 1 file changed, 95 insertions(+), 95 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 6c6743d06..4d1940212 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -254,30 +254,30 @@ Setting Rules Using an Array Before moving on it should be noted that the rule setting function can be passed an array if you prefer to set all your rules in one action. If -you use this approach you must name your array keys as indicated:: +you use this approach, you must name your array keys as indicated:: $config = array( - array( - 'field' => 'username', - 'label' => 'Username', - 'rules' => 'required' - ), - array( - 'field' => 'password', - 'label' => 'Password', - 'rules' => 'required' - ), - array( - 'field' => 'passconf', - 'label' => 'Password Confirmation', - 'rules' => 'required' - ), - array( - 'field' => 'email', - 'label' => 'Email', - 'rules' => 'required' - ) - ); + array( + 'field' => 'username', + 'label' => 'Username', + 'rules' => 'required' + ), + array( + 'field' => 'password', + 'label' => 'Password', + 'rules' => 'required' + ), + array( + 'field' => 'passconf', + 'label' => 'Password Confirmation', + 'rules' => 'required' + ), + array( + 'field' => 'email', + 'label' => 'Email', + 'rules' => 'required' + ) + ); $this->form_validation->set_rules($config); @@ -291,7 +291,6 @@ your rules in the third parameter of rule setting function, like this:: $this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]'); $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required'); $this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]'); - The above code sets the following rules: @@ -560,11 +559,10 @@ globally, individually, or change the defaults in a config file. #. **Set delimiters in a config file** You can add your error delimiters in application/config/form_validation.php as follows:: - + $config['error_prefix'] = '
'; $config['error_suffix'] = '
'; - Showing Errors Individually =========================== @@ -592,8 +590,8 @@ Try it! Change your form so that it looks like this:: If there are no errors, nothing will be shown. If there is an error, the message will appear. -**Important Note:** If you use an array as the name of a form field, you -must supply it as an array to the function. Example:: +.. important:: If you use an array as the name of a form field, you + must supply it as an array to the function. Example:: " size="50" /> @@ -603,20 +601,20 @@ For more info please see the :ref:`using-arrays-as-field-names` section below. Validating an Array (other than $_POST) ======================================= -Sometimes you may want to validate an array that does not originate from $_POST data. +Sometimes you may want to validate an array that does not originate from ``$_POST`` data. In this case, you can specify the array to be validated:: - + $data = array( - 'username' => 'johndoe', - 'password' => 'mypassword', - 'passconf' => 'mypassword' - ); + 'username' => 'johndoe', + 'password' => 'mypassword', + 'passconf' => 'mypassword' + ); $this->form_validation->set_data($data); -Creating validation rules, running the validation and retrieving error messages works the same whether you are -validating $_POST data or an array. +Creating validation rules, running the validation and retrieving error messages works the +same whether you are validating ``$_POST`` data or an array. **Important Note:** If you want to validate more than one array during a single execution, then you should call the reset_validation() function before setting up rules and validating the new array. @@ -644,32 +642,32 @@ you will place an array named $config with your rules. As shown earlier, the validation array will have this prototype:: $config = array( - array( - 'field' => 'username', - 'label' => 'Username', - 'rules' => 'required' - ), - array( - 'field' => 'password', - 'label' => 'Password', - 'rules' => 'required' - ), - array( - 'field' => 'passconf', - 'label' => 'Password Confirmation', - 'rules' => 'required' - ), - array( - 'field' => 'email', - 'label' => 'Email', - 'rules' => 'required' - ) - ); + array( + 'field' => 'username', + 'label' => 'Username', + 'rules' => 'required' + ), + array( + 'field' => 'password', + 'label' => 'Password', + 'rules' => 'required' + ), + array( + 'field' => 'passconf', + 'label' => 'Password Confirmation', + 'rules' => 'required' + ), + array( + 'field' => 'email', + 'label' => 'Email', + 'rules' => 'required' + ) + ); Your validation rule file will be loaded automatically and used when you -call the run() function. +call the ``run()`` method. -Please note that you MUST name your array $config. +Please note that you MUST name your ``$config`` array. Creating Sets of Rules ====================== @@ -729,45 +727,44 @@ You can name your rules anything you want:: Calling a Specific Rule Group ============================= -In order to call a specific group you will pass its name to the run() -function. For example, to call the signup rule you will do this:: +In order to call a specific group you will pass its name to the ``run()`` +method. For example, to call the signup rule you will do this:: if ($this->form_validation->run('signup') == FALSE) { - $this->load->view('myform'); + $this->load->view('myform'); } else { - $this->load->view('formsuccess'); + $this->load->view('formsuccess'); } Associating a Controller Function with a Rule Group =================================================== An alternate (and more automatic) method of calling a rule group is to -name it according to the controller class/function you intend to use it +name it according to the controller class/method you intend to use it with. For example, let's say you have a controller named Member and a -function named signup. Here's what your class might look like:: +method named signup. Here's what your class might look like:: load->library('form_validation'); - - if ($this->form_validation->run() == FALSE) - { - $this->load->view('myform'); - } - else - { - $this->load->view('formsuccess'); - } - } + function signup() + { + $this->load->library('form_validation'); + + if ($this->form_validation->run() == FALSE) + { + $this->load->view('myform'); + } + else + { + $this->load->view('formsuccess'); + } + } } - ?> In your validation config file, you will name your rule group member/signup:: @@ -913,6 +910,9 @@ Rule Parameter Description to two parameters, where at least one is required (to pass the field data). +.. note:: When using the **matches** rule, the form item specified + to compare against must already be defined. + ****************** Prepping Reference ****************** @@ -945,7 +945,7 @@ The following functions are intended for use in your controller functions. $this->form_validation->set_rules(); -====================================== +==================================== .. php:method:: set_rules ($field, $label = '', $rules = '') @@ -953,7 +953,7 @@ $this->form_validation->set_rules(); :param string $label: The field label :param mixed $rules: The rules, as a string with rules separated by a pipe "|", or an array or rules. :rtype: Object - + Permits you to set validation rules, as described in the tutorial sections above: @@ -961,19 +961,19 @@ $this->form_validation->set_rules(); - :ref:`saving-groups` $this->form_validation->run(); -=============================== +============================== .. php:method:: run ($group = '') :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 = '') @@ -984,7 +984,7 @@ $this->form_validation->set_message(); Permits you to set custom error messages. See :ref:`setting-error-messages` $this->form_validation->set_data(); -======================================== +=================================== .. php:method:: set_data ($data = '') @@ -996,13 +996,13 @@ $this->form_validation->set_data(); $this->form_validation->reset_validation(); =========================================== - .. php:method:: reset_validation () + .. php:method:: reset_validation () - Permits you to reset the validation when you validate more than one array. - This function should be called before validating each new array. + Permits you to reset the validation when you validate more than one array. + This method should be called before validating each new array. $this->form_validation->error_array(); -======================================== +====================================== .. php:method:: error_array () @@ -1021,7 +1021,7 @@ containing your forms. Note that these are procedural functions, so they **do not** require you to prepend them with $this->form_validation. form_error() -============= +============ Shows an individual error message associated with the field name supplied to the function. Example:: @@ -1032,7 +1032,7 @@ The error delimiters can be optionally specified. See the :ref:`changing-delimiters` section above. validation_errors() -==================== +=================== Shows all error messages as a string: Example:: @@ -1042,7 +1042,7 @@ The error delimiters can be optionally specified. See the :ref:`changing-delimiters` section above. set_value() -============ +=========== 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 @@ -1054,7 +1054,7 @@ form. Example:: The above form will show "0" when loaded for the first time. set_select() -============= +============ If you use a set_checkbox() -=============== +============== Permits you to display a checkbox in the state it was submitted. The first parameter must contain the name of the checkbox, the second @@ -1082,7 +1082,7 @@ lets you set an item as the default (use boolean TRUE/FALSE). Example:: /> set_radio() -============ +=========== Permits you to display radio buttons in the state they were submitted. This function is identical to the **set_checkbox()** function above. @@ -1090,4 +1090,4 @@ This function is identical to the **set_checkbox()** function above. :: /> - /> + /> \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 34c8b9c45fdcd2eb0eee5e2275a52e4c2faed5dc Mon Sep 17 00:00:00 2001 From: Jonathon Hill Date: Wed, 31 Oct 2012 14:02:35 -0400 Subject: Added support for timestamp-based migrations Signed-off-by: Jonathon Hill --- user_guide_src/source/libraries/migration.rst | 84 ++++++++++++++++++--------- 1 file changed, 55 insertions(+), 29 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst index cb7d96a6d..246396171 100644 --- a/user_guide_src/source/libraries/migration.rst +++ b/user_guide_src/source/libraries/migration.rst @@ -13,17 +13,40 @@ run so all you have to do is update your application files and call **$this->migrate->current()** to work out which migrations should be run. The current version is found in **config/migration.php**. +******************** +Migration file names +******************** + +Each Migration is run in numeric order forward or backwards depending on the +method taken. Two numbering styles are available: + +* **Sequential:** each migration is numbered in sequence, starting with **001**. + Each number must be three digits, and there must not be any gaps in the + sequence. (This was the numbering scheme prior to CodeIgniter 3.0.) +* **Timestamp:** each migration is numbered using the timestamp when the migration + was created, in **YYYYMMDDHHIISS** format (e.g. **20121031100537**). This + helps prevent numbering conflicts when working in a team environment, and is + the preferred scheme in CodeIgniter 3.0 and later. + +The desired style may be selected using the **$config['migration_style']** +setting in your **migration.php** config file. + +Regardless of which numbering style you choose to use, prefix your migration +files with the migration number followed by an underscore and a descriptive +name for the migration. For example: + +* **001_add_blog.php** (sequential numbering) +* **20121031100537_add_blog.php** (timestamp numbering) + ****************** Create a Migration ****************** - -.. note:: Each Migration is run in numerical order forward or backwards - depending on the method taken. Use a prefix of 3 numbers followed by an - underscore for the filename of your migration. This will be the first migration for a new site which has a blog. All migrations go in the folder **application/migrations/** and have names such -as: **001_add_blog.php**.:: +as **20121031100537_add_blog.php**.:: + + TRUE, ), )); - + $this->dbforge->add_key('blog_id', TRUE); $this->dbforge->create_table('blog'); } @@ -55,6 +78,7 @@ as: **001_add_blog.php**.:: { $this->dbforge->drop_table('blog'); } + } Then in **application/config/migration.php** set **$config['migration_version'] = 1;**. @@ -65,25 +89,25 @@ Usage Example In this example some simple code is placed in **application/controllers/migrate.php** to update the schema.:: - $this->load->library('migration'); - - if ( ! $this->migration->current()) + migration->error_string()); + public function index() + { + $this->load->library('migration'); + + if ($this->migration->current() === FALSE) + { + show_error($this->migration->error_string()); + } + } } ****************** Function Reference ****************** -There are five available methods for the Migration class: - -- $this->migration->current(); -- $this->migration->error_string(); -- $this->migration->find_migrations(); -- $this->migration->latest(); -- $this->migration->version(); - $this->migration->current() ============================ @@ -124,14 +148,16 @@ Migration Preferences The following is a table of all the config options for migrations. -========================== ====================== ============= ============================================= -Preference Default Options Description -========================== ====================== ============= ============================================= -**migration_enabled** FALSE TRUE / FALSE Enable or disable migrations. -**migration_path** APPPATH.'migrations/' None The path to your migrations folder. -**migration_version** 0 None The current version your database should use. -**migration_table** migrations None The table name for storing the shema - version number. -**migration_auto_latest** FALSE TRUE / FALSE Enable or disable automatically - running migrations. -========================== ====================== ============= ============================================= +========================== ====================== ========================== ============================================= +Preference Default Options Description +========================== ====================== ========================== ============================================= +**migration_enabled** FALSE TRUE / FALSE Enable or disable migrations. +**migration_path** APPPATH.'migrations/' None The path to your migrations folder. +**migration_version** 0 None The current version your database should use. +**migration_table** migrations None The table name for storing the schema + version number. +**migration_auto_latest** FALSE TRUE / FALSE Enable or disable automatically + running migrations. +**migration_style** 'timestamp' 'timestamp' / 'sequential' The type of numeric identifier used to name + migration files. +========================== ====================== ========================== ============================================= -- cgit v1.2.3-24-g4f1b From e2afc886d5e7fe1d55a467c9bc46fe40c1a2bbf6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 01:35:34 +0200 Subject: Session cookie driver changes - Changed docs CREATE TABLE ci_sessions example to have the PRIMARY KEY of session_id, ip_address and user_agent combined. - Changed DB updates to add WHERE clauses for the ip_address and/or user_agent strings if sess_match_ip and/or sess_match_useragent are set to TRUE. --- user_guide_src/source/libraries/sessions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index dd9e8cbb4..ee7fb0b1c 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -388,7 +388,7 @@ session class:: user_agent varchar(120) NOT NULL, last_activity int(10) unsigned DEFAULT 0 NOT NULL, user_data text NOT NULL, - PRIMARY KEY (session_id), + PRIMARY KEY (session_id, ip_address, user_agent), KEY `last_activity_idx` (`last_activity`) ); -- cgit v1.2.3-24-g4f1b From 8161e57a1c038566ff28a6ba08c9b165079c9b75 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 18:50:43 +0200 Subject: [ci skip] Alter form validation examples including the *matches* rule --- user_guide_src/source/libraries/form_validation.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 4d1940212..c010eb578 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -288,8 +288,8 @@ CodeIgniter lets you pipe multiple rules together. Let's try it. Change your rules in the third parameter of rule setting function, like this:: $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]|is_unique[users.username]'); - $this->form_validation->set_rules('password', 'Password', 'required|matches[passconf]'); - $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required'); + $this->form_validation->set_rules('password', 'Password', 'required'); + $this->form_validation->set_rules('passconf', 'Password Confirmation', 'required|matches[password]'); $this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[users.email]'); The above code sets the following rules: @@ -315,8 +315,8 @@ can also prep your data in various ways. For example, you can set up rules like this:: $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]|max_length[12]|xss_clean'); - $this->form_validation->set_rules('password', 'Password', 'trim|required|matches[passconf]|md5'); - $this->form_validation->set_rules('passconf', 'Password Confirmation', 'trim|required'); + $this->form_validation->set_rules('password', 'Password', 'trim|required|md5'); + $this->form_validation->set_rules('passconf', 'Password Confirmation', 'trim|required|matches[password]'); $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email'); In the above example, we are "trimming" the fields, converting the -- cgit v1.2.3-24-g4f1b From 751f2479460c6f5cfc5333f6561d9827a92089bd Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 3 Nov 2012 18:26:27 +0200 Subject: Fix #1957 --- user_guide_src/source/libraries/form_validation.rst | 3 --- 1 file changed, 3 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index c010eb578..a3a35b499 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -910,9 +910,6 @@ Rule Parameter Description to two parameters, where at least one is required (to pass the field data). -.. note:: When using the **matches** rule, the form item specified - to compare against must already be defined. - ****************** Prepping Reference ****************** -- cgit v1.2.3-24-g4f1b From 7ffaea45cb0e2fa5ba82314755894bd5136a8575 Mon Sep 17 00:00:00 2001 From: Daniel Paul Searles Date: Mon, 5 Nov 2012 14:54:00 -0800 Subject: Fixed typo in unit testing documentation. There was a reference to a non-existent Unit_test::set_items method when it should be Unit_test::set_test_items. --- user_guide_src/source/libraries/unit_testing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/unit_testing.rst b/user_guide_src/source/libraries/unit_testing.rst index 03819b27c..6bd91bf88 100644 --- a/user_guide_src/source/libraries/unit_testing.rst +++ b/user_guide_src/source/libraries/unit_testing.rst @@ -131,7 +131,7 @@ default: - Any notes you entered for the test (notes) You can customize which of these items get displayed by using -$this->unit->set_items(). For example, if you only wanted the test name +$this->unit->set_test_items(). For example, if you only wanted the test name and the result displayed: Customizing displayed tests -- cgit v1.2.3-24-g4f1b From 303eef056b7317a1e4f06feb26fdb452a59c3a51 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Nov 2012 14:55:48 +0200 Subject: Added CI_Input::input_stream() Helps in reading php://input stream data by caching it when accessed for the first time. (supersedes PR #1684) --- user_guide_src/source/libraries/input.rst | 93 ++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 32 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index c0b9c6589..177f5cb64 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -5,8 +5,7 @@ Input Class The Input Class serves two purposes: #. It pre-processes global input data for security. -#. It provides some helper functions for fetching input data and - pre-processing it. +#. It provides some helper methods for fetching input data and pre-processing it. .. note:: This class is initialized automatically by the system so there is no need to do it manually. @@ -14,7 +13,7 @@ The Input Class serves two purposes: Security Filtering ================== -The security filtering function is called automatically when a new +The security filtering method is called automatically when a new :doc:`controller <../general/controllers>` is invoked. It does the following: @@ -47,7 +46,7 @@ Using POST, GET, COOKIE, or SERVER Data CodeIgniter comes with four helper methods that let you fetch POST, GET, COOKIE or SERVER items. The main advantage of using the provided -functions rather than fetching an item directly ($_POST['something']) +methods rather than fetching an item directly (``$_POST['something']``) is that the methods will check to see if the item is set and return NULL if not. This lets you conveniently use data without having to test whether an item exists first. In other words, normally @@ -55,7 +54,7 @@ you might do something like this:: $something = isset($_POST['something']) ? $_POST['something'] : NULL; -With CodeIgniter's built in functions you can simply do this:: +With CodeIgniter's built in methods you can simply do this:: $something = $this->input->post('something'); @@ -74,7 +73,7 @@ looking for:: $this->input->post('some_data'); -The function returns NULL if the item you are attempting to retrieve +The method returns NULL if the item you are attempting to retrieve does not exist. The second optional parameter lets you run the data through the XSS @@ -89,7 +88,7 @@ To return an array of all POST items call without any parameters. To return all POST items and pass them through the XSS filter set the first parameter NULL while setting the second parameter to boolean; -The function returns NULL if there are no items in the POST. +The method returns NULL if there are no items in the POST. :: @@ -99,8 +98,8 @@ The function returns NULL if there are no items in the POST. $this->input->get() =================== -This function is identical to the post function, only it fetches get -data:: +This method is identical to the post method, only it fetches get data +:: $this->input->get('some_data', TRUE); @@ -109,7 +108,7 @@ To return an array of all GET items call without any parameters. To return all GET items and pass them through the XSS filter set the first parameter NULL while setting the second parameter to boolean; -The function returns NULL if there are no items in the GET. +The method returns NULL if there are no items in the GET. :: @@ -118,9 +117,9 @@ The function returns NULL if there are no items in the GET. $this->input->get_post() -========================= +======================== -This function will search through both the post and get streams for +This method will search through both the post and get streams for data, looking first in post, and then in get:: $this->input->get_post('some_data', TRUE); @@ -128,8 +127,8 @@ data, looking first in post, and then in get:: $this->input->cookie() ====================== -This function is identical to the post function, only it fetches cookie -data:: +This method is identical to the post method, only it fetches cookie data +:: $this->input->cookie('some_cookie'); $this->input->cookie('some_cookie, TRUE); // with XSS filter @@ -138,16 +137,43 @@ data:: $this->input->server() ====================== -This function is identical to the above functions, only it fetches +This method is identical to the above methods, only it fetches server server data:: $this->input->server('some_data'); +Using the php://input stream +============================ + +If you want to utilize the PUT, DELETE, PATCH or other exotic request +methods, they can only be accessed via a special input stream, that +can only be read once. This isn't as easy as just reading from e.g. +the ``$_POST`` array, because it will always exist and you can try +and access multiple variables without caring that you might only have +one shot at all of the POST data. + +CodeIgniter will take care of that for you, and you can access data +from the **php://input** stream at any time, just by calling the +``input_stream()`` method:: + + $this->input->input_stream('key'); + +Similar to the methods above, if the requested data is not found, it +will return NULL and you can also decide whether to run the data +through ``xss_clean()`` by passing a boolean value as the second +parameter:: + + $this->input->input_stream('key', TRUE); // XSS Clean + $this->input->input_stream('key', FALSE); // No XSS filter + +.. note:: You can utilize method() in order to know if you're reading + PUT, DELETE or PATCH data. + $this->input->set_cookie() -=========================== +========================== Sets a cookie containing the values you specify. There are two ways to -pass information to this function so that a cookie can be set: Array +pass information to this method so that a cookie can be set: Array Method, and Discrete Parameters: Array Method @@ -182,7 +208,7 @@ For site-wide cookies regardless of how your site is requested, add your URL to the **domain** starting with a period, like this: .your-domain.com -The path is usually not needed since the function sets a root path. +The path is usually not needed since the method sets a root path. The prefix is only needed if you need to avoid name collisions with other identically named cookies for your server. @@ -198,22 +224,25 @@ parameters:: $this->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure); + $this->input->ip_address() -=========================== +========================== Returns the IP address for the current user. If the IP address is not -valid, the function will return an IP of: 0.0.0.0 +valid, the method will return an IP of: 0.0.0.0 :: echo $this->input->ip_address(); $this->input->valid_ip($ip) -============================ +=========================== Takes an IP address as input and returns TRUE or FALSE (boolean) if it -is valid or not. Note: The $this->input->ip_address() function above -validates the IP automatically. +is valid or not. + +.. note:: The $this->input->ip_address() method above automatically + validates the IP address. :: @@ -230,7 +259,7 @@ Accepts an optional second string parameter of 'ipv4' or 'ipv6' to specify an IP format. The default checks for both formats. $this->input->user_agent() -=========================== +========================== Returns the user agent (web browser) being used by the current user. Returns FALSE if it's not available. @@ -243,7 +272,7 @@ See the :doc:`User Agent Class ` for methods which extract information from the user agent string. $this->input->request_headers() -================================ +=============================== Useful if running in a non-Apache environment where `apache_request_headers() `_ @@ -253,8 +282,8 @@ will not be supported. Returns an array of headers. $headers = $this->input->request_headers(); -$this->input->get_request_header(); -===================================== +$this->input->get_request_header() +================================== Returns a single member of the request headers array. @@ -263,13 +292,13 @@ Returns a single member of the request headers array. $this->input->get_request_header('some-header', TRUE); $this->input->is_ajax_request() -================================= +=============================== Checks to see if the HTTP_X_REQUESTED_WITH server header has been set, and returns a boolean response. $this->input->is_cli_request() -================================ +============================== Checks to see if the STDIN constant is set, which is a failsafe way to see if PHP is being run on the command line. @@ -278,8 +307,8 @@ see if PHP is being run on the command line. $this->input->is_cli_request() -$this->input->method(); -===================================== +$this->input->method() +====================== Returns the $_SERVER['REQUEST_METHOD'], optional set uppercase or lowercase (default lowercase). @@ -287,4 +316,4 @@ Returns the $_SERVER['REQUEST_METHOD'], optional set uppercase or lowercase (def echo $this->input->method(TRUE); // Outputs: POST echo $this->input->method(FALSE); // Outputs: post - echo $this->input->method(); // Outputs: post + echo $this->input->method(); // Outputs: post \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b719bfdb268926e764a787ffcab1a3ea9c9759d7 Mon Sep 17 00:00:00 2001 From: Jonathon Hill Date: Mon, 12 Nov 2012 09:03:36 -0500 Subject: Changed the `migration_style` config setting to `migration_type` Signed-off-by: Jonathon Hill --- user_guide_src/source/libraries/migration.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst index 246396171..1a73fb78d 100644 --- a/user_guide_src/source/libraries/migration.rst +++ b/user_guide_src/source/libraries/migration.rst @@ -28,7 +28,7 @@ method taken. Two numbering styles are available: helps prevent numbering conflicts when working in a team environment, and is the preferred scheme in CodeIgniter 3.0 and later. -The desired style may be selected using the **$config['migration_style']** +The desired style may be selected using the **$config['migration_type']** setting in your **migration.php** config file. Regardless of which numbering style you choose to use, prefix your migration @@ -158,6 +158,6 @@ Preference Default Options Des version number. **migration_auto_latest** FALSE TRUE / FALSE Enable or disable automatically running migrations. -**migration_style** 'timestamp' 'timestamp' / 'sequential' The type of numeric identifier used to name +**migration_type** 'timestamp' 'timestamp' / 'sequential' The type of numeric identifier used to name migration files. ========================== ====================== ========================== ============================================= -- cgit v1.2.3-24-g4f1b From a51f8ec0b98df8b7adc97cdca555cf50064eb94a Mon Sep 17 00:00:00 2001 From: Alan Jenkins Date: Mon, 19 Nov 2012 10:29:52 +0000 Subject: Documentation: fix typos in name of application folder The name is "application/", not "applications/". (This commit does not change managing_apps.rst, where "applications/" is used intentionally). --- user_guide_src/source/libraries/file_uploading.rst | 6 +++--- user_guide_src/source/libraries/form_validation.rst | 6 +++--- user_guide_src/source/libraries/xmlrpc.rst | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/file_uploading.rst b/user_guide_src/source/libraries/file_uploading.rst index 1698dcbb9..cceadfcae 100644 --- a/user_guide_src/source/libraries/file_uploading.rst +++ b/user_guide_src/source/libraries/file_uploading.rst @@ -26,7 +26,7 @@ Creating the Upload Form ======================== Using a text editor, create a form called upload_form.php. In it, place -this code and save it to your applications/views/ folder:: +this code and save it to your application/views/ folder:: @@ -59,7 +59,7 @@ The Success Page ================ Using a text editor, create a form called upload_success.php. In it, -place this code and save it to your applications/views/ folder:: +place this code and save it to your application/views/ folder:: @@ -84,7 +84,7 @@ The Controller ============== Using a text editor, create a controller called upload.php. In it, place -this code and save it to your applications/controllers/ folder:: +this code and save it to your application/controllers/ folder:: @@ -98,7 +98,7 @@ The Success Page ================ Using a text editor, create a form called formsuccess.php. In it, place -this code and save it to your applications/views/ folder:: +this code and save it to your application/views/ folder:: @@ -117,7 +117,7 @@ The Controller ============== Using a text editor, create a controller called form.php. In it, place -this code and save it to your applications/controllers/ folder:: +this code and save it to your application/controllers/ folder:: Date: Thu, 22 Nov 2012 17:26:29 +0200 Subject: Fix issue #118 (manually implementing PR #1832) --- user_guide_src/source/libraries/language.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/language.rst b/user_guide_src/source/libraries/language.rst index b231f14a3..772f70d0b 100644 --- a/user_guide_src/source/libraries/language.rst +++ b/user_guide_src/source/libraries/language.rst @@ -66,9 +66,14 @@ text using this function:: $this->lang->line('language_key'); -Where language_key is the array key corresponding to the line you wish +Where *language_key* is the array key corresponding to the line you wish to show. +You can optionally pass FALSE as the second argument of that method to +disable error logging, in case you're not sure if the line exists:: + + $this->lang->line('misc_key', FALSE); + .. note:: This method simply returns the line. It does not echo it. Using language lines as form labels -- cgit v1.2.3-24-g4f1b From 4beca5c9b64ba7bd1622e5c01666491f02cfa6db Mon Sep 17 00:00:00 2001 From: Johnathan Croom Date: Fri, 23 Nov 2012 18:32:46 -0700 Subject: keep_flashdata accepts array --- user_guide_src/source/libraries/sessions.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index ee7fb0b1c..aecad3164 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -195,7 +195,7 @@ set_userdata(). To read a flashdata variable:: $this->session->flashdata('item'); - + An array of all flashdata can be retrieved as follows:: $this->session->all_flashdata(); @@ -203,10 +203,12 @@ An array of all flashdata can be retrieved as follows:: If you find that you need to preserve a flashdata variable through an additional request, you can do so using the keep_flashdata() function. +You can either pass a single item or an array of flashdata items to keep. :: $this->session->keep_flashdata('item'); + $this->session->keep_flashdata(array('item1', 'item2', 'item3')); Tempdata ======== -- cgit v1.2.3-24-g4f1b From 6262d053db57957c4445ef7fce76070854c3e30d Mon Sep 17 00:00:00 2001 From: dchill42 Date: Sat, 24 Nov 2012 18:41:13 -0500 Subject: Added support for extending individual driver classes and driver unit tests Signed-off-by: dchill42 --- user_guide_src/source/libraries/sessions.rst | 5 ----- 1 file changed, 5 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/sessions.rst b/user_guide_src/source/libraries/sessions.rst index ee7fb0b1c..df1049f82 100644 --- a/user_guide_src/source/libraries/sessions.rst +++ b/user_guide_src/source/libraries/sessions.rst @@ -28,10 +28,6 @@ use the $this->load->driver function:: Once loaded, the Sessions library object will be available using: $this->session -.. note:: For backward compatibility, the Session class may stil be loaded - using the $this->load->library function, but converting your applications - to use $this->load->driver is strongly recommended. - How do Sessions work? ===================== @@ -485,4 +481,3 @@ without making it the initially loaded driver, set 'sess_valid_drivers' in your config.php file to an array including your driver name:: $config['sess_valid_drivers'] = array('sess_driver'); - -- cgit v1.2.3-24-g4f1b From 61797f67a9bcb357ae7e1be9dadffd58eaa3e540 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Nov 2012 16:15:12 +0200 Subject: CI_Email::print_debugger() option to limit the type of data to be printed (an alternative to PR #1759; partially solves issue #1742) --- user_guide_src/source/libraries/email.rst | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst index da3bf2616..8643444f8 100644 --- a/user_guide_src/source/libraries/email.rst +++ b/user_guide_src/source/libraries/email.rst @@ -268,11 +268,21 @@ parameter as mime-type:: $this->email->attach($buffer, 'attachment', 'report.pdf', 'application/pdf'); $this->email->print_debugger() -------------------------------- +------------------------------ Returns a string containing any server messages, the email headers, and the email messsage. Useful for debugging. +You can optionally specify which parts of the message should be printed. +Valid options are: **headers**, **subject**, **body**. + +Example:: + + // Will only print the email headers, excluding the message subject and body + $this->email->print_debugger(array('headers')); + +.. note:: By default, all of the raw data will be printed. + Overriding Word Wrapping ======================== -- cgit v1.2.3-24-g4f1b From daaca882e48e26e60bf2eea9f4fad108a845fb38 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Nov 2012 22:16:12 +0200 Subject: Add 'valid_url' rule to Form Validation (issue #1966) --- user_guide_src/source/libraries/form_validation.rst | 1 + 1 file changed, 1 insertion(+) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index b1f466f4c..7478ca0ef 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -894,6 +894,7 @@ Rule Parameter Description 0, 1, 2, 3, etc. **is_natural_no_zero** No Returns FALSE if the form element contains anything other than a natural number, but not zero: 1, 2, 3, etc. +**valid_url** No Returns FALSE if the form element does not contain a valid URL. **valid_email** No Returns FALSE if the form element does not contain a valid email address. **valid_emails** No Returns FALSE if any value provided in a comma separated list is not a valid email. **valid_ip** No Returns FALSE if the supplied IP is not valid. -- cgit v1.2.3-24-g4f1b From b11b9f38f3ae0f9699612ac61000ee789665f2d6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Nov 2012 23:01:24 +0200 Subject: Implement cascade-style loading of language files (as requested in issue #452) --- user_guide_src/source/libraries/language.rst | 40 +++++++++++++--------------- 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/language.rst b/user_guide_src/source/libraries/language.rst index 772f70d0b..d288cd65e 100644 --- a/user_guide_src/source/libraries/language.rst +++ b/user_guide_src/source/libraries/language.rst @@ -10,12 +10,11 @@ containing sets of language files. You can create your own language files as needed in order to display error and other messages in other languages. -Language files are typically stored in your system/language directory. -Alternately you can create a folder called language inside your -application folder and store them there. CodeIgniter will look first in -your application/language directory. If the directory does not exist or -the specified language is not located there CI will instead look in your -global system/language folder. +Language files are typically stored in your **system/language/** directory. +Alternately you can create a directory called language inside your +application folder and store them there. CodeIgniter will always load the +one in **system/language/** first and will then look for an override in +your **application/language/** directory. .. note:: Each language should be stored in its own folder. For example, the English files are located at: system/language/english @@ -23,14 +22,14 @@ global system/language folder. Creating Language Files ======================= -Language files must be named with _lang.php as the file extension. For +Language files must be named with **_lang.php** as the file extension. For example, let's say you want to create a file containing error messages. You might name it: error_lang.php Within the file you will assign each line of text to an array called -$lang with this prototype:: +``$lang`` with this prototype:: - $lang['language_key'] = "The actual message to be shown"; + $lang['language_key'] = 'The actual message to be shown'; .. note:: It's a good practice to use a common prefix for all messages in a given file to avoid collisions with similarly named items in other @@ -39,9 +38,9 @@ $lang with this prototype:: :: - $lang['error_email_missing'] = "You must submit an email address"; - $lang['error_url_missing'] = "You must submit a URL"; - $lang['error_username_missing'] = "You must submit a username"; + $lang['error_email_missing'] = 'You must submit an email address'; + $lang['error_url_missing'] = 'You must submit a URL'; + $lang['error_username_missing'] = 'You must submit a username'; Loading A Language File ======================= @@ -54,7 +53,7 @@ first. Loading a language file is done with the following code:: Where filename is the name of the file you wish to load (without the file extension), and language is the language set containing it (ie, english). If the second parameter is missing, the default language set -in your *application/config/config.php* file will be used. +in your **application/config/config.php** file will be used. .. note:: The *language* parameter can only consist of letters. @@ -80,17 +79,14 @@ Using language lines as form labels ----------------------------------- This feature has been deprecated from the language library and moved to -the lang() function of the :doc:`Language -helper <../helpers/language_helper>`. +the :php:func:`lang()` function of the :doc:`Language Helper +<../helpers/language_helper>`. Auto-loading Languages ====================== If you find that you need a particular language globally throughout your -application, you can tell CodeIgniter to -:doc:`auto-load <../general/autoloader>` it during system -initialization. This is done by opening the -application/config/autoload.php file and adding the language(s) to the -autoload array. - - +application, you can tell CodeIgniter to :doc:`auto-load +<../general/autoloader>` it during system initialization. This is done +by opening the **application/config/autoload.php** file and adding the +language(s) to the autoload array. \ No newline at end of file -- cgit v1.2.3-24-g4f1b From cc4b00347c9ff061488bc88194002be701f4190f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 29 Nov 2012 17:21:43 +0200 Subject: Added CI_Output::get_header() (an improved version of PR #645) Also fixed get_content_type() to only return the MIME value and created Output library unit tests for both of these methods. --- user_guide_src/source/libraries/output.rst | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/output.rst b/user_guide_src/source/libraries/output.rst index 82b1a56a5..a3d67b847 100644 --- a/user_guide_src/source/libraries/output.rst +++ b/user_guide_src/source/libraries/output.rst @@ -53,17 +53,37 @@ You can also set the character set of the document, by passing a second argument $this->output->set_content_type('css', 'utf-8'); -$this->output->get_content_type(); -========================================== +$this->output->get_content_type() +================================= -Returns the Content-Type HTTP header that's currently in use. +Returns the Content-Type HTTP header that's currently in use, +excluding the character set value. $mime = $this->output->get_content_type(); .. note:: If not set, the default return value is 'text/html'. -$this->output->get_output(); -============================= +$this->output->get_header() +=========================== + +Gets the requested HTTP header value, if set. + +If the header is not set, NULL will be returned. +If an empty value is passed to the method, it will return FALSE. + +Example:: + + $this->output->set_content_type('text/plain', 'UTF-8'); + echo $this->output->get_header('content-type'); + // Outputs: text/plain; charset=utf-8 + +.. note:: The header name is compared in a case-insensitive manner. + +.. note:: Raw headers sent via PHP's native ``header()`` function are + also detected. + +$this->output->get_output() +=========================== Permits you to manually retrieve any output that has been sent for storage in the output class. Usage example:: -- cgit v1.2.3-24-g4f1b From 05aa2d653a76b086a909739b2c9386289aa2e0fb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 3 Dec 2012 16:06:55 +0200 Subject: Add min_width and min_height options to the Upload class (manually implementing outdated PR #636) --- user_guide_src/source/libraries/file_uploading.rst | 98 ++++++++++++---------- 1 file changed, 53 insertions(+), 45 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/file_uploading.rst b/user_guide_src/source/libraries/file_uploading.rst index cceadfcae..c7965ae11 100644 --- a/user_guide_src/source/libraries/file_uploading.rst +++ b/user_guide_src/source/libraries/file_uploading.rst @@ -26,7 +26,7 @@ Creating the Upload Form ======================== Using a text editor, create a form called upload_form.php. In it, place -this code and save it to your application/views/ folder:: +this code and save it to your **application/views/** directory:: @@ -59,7 +59,7 @@ The Success Page ================ Using a text editor, create a form called upload_success.php. In it, -place this code and save it to your application/views/ folder:: +place this code and save it to your **application/views/** directory:: @@ -84,7 +84,7 @@ The Controller ============== Using a text editor, create a controller called upload.php. In it, place -this code and save it to your application/controllers/ folder:: +this code and save it to your **application/controllers/** directory:: -The Upload Folder -================= +The Upload Directory +==================== -You'll need a destination folder for your uploaded images. Create a -folder at the root of your CodeIgniter installation called uploads and -set its file permissions to 777. +You'll need a destination directory for your uploaded images. Create a +directory at the root of your CodeIgniter installation called uploads +and set its file permissions to 777. Try it! ======= @@ -153,7 +153,7 @@ Initializing the Upload Class ============================= Like most other classes in CodeIgniter, the Upload class is initialized -in your controller using the $this->load->library function:: +in your controller using the ``$this->load->library()`` method:: $this->load->library('upload'); @@ -175,7 +175,7 @@ following preferences:: $this->load->library('upload', $config); - // Alternately you can set preferences by calling the initialize function. Useful if you auto-load the class: + // Alternately you can set preferences by calling the ``initialize()`` method. Useful if you auto-load the class: $this->upload->initialize($config); The above preferences should be fairly self-explanatory. Below is a @@ -190,8 +190,8 @@ what will be used if you do not specify that preference. ============================ ================= ======================= ====================================================================== Preference Default Value Options Description ============================ ================= ======================= ====================================================================== -**upload_path** None None The path to the folder where the upload should be placed. The folder - must be writable and the path can be absolute or relative. +**upload_path** None None The path to the directory where the upload should be placed. The + directory must be writable and the path can be absolute or relative. **allowed_types** None None The mime types corresponding to the types of files you allow to be uploaded. Usually the file extension can be used as the mime type. Separate multiple types with a pipe. @@ -204,9 +204,13 @@ Preference Default Value Options Descripti **max_size** 0 None The maximum size (in kilobytes) that the file can be. Set to zero for no limit. Note: Most PHP installations have their own limit, as specified in the php.ini file. Usually 2 MB (or 2048 KB) by default. -**max_width** 0 None The maximum width (in pixels) that the file can be. Set to zero for no +**max_width** 0 None The maximum width (in pixels) that the image can be. Set to zero for no limit. -**max_height** 0 None The maximum height (in pixels) that the file can be. Set to zero for no +**max_height** 0 None The maximum height (in pixels) that the image can be. Set to zero for no + limit. +**min_width** 0 None The minimum width (in pixels) that the image can be. Set to zero for no + limit. +**min_height** 0 None The minimum height (in pixels) that the image can be. Set to zero for no limit. **max_filename** 0 None The maximum length that a file name can be. Set to zero for no limit. **max_filename_increment** 100 None When overwrite is set to FALSE, use this to set the maximum filename @@ -227,42 +231,46 @@ Setting preferences in a config file If you prefer not to set preferences using the above method, you can instead put them into a config file. Simply create a new file called the upload.php, add the $config array in that file. Then save the file in: -config/upload.php and it will be used automatically. You will NOT need -to use the $this->upload->initialize function if you save your +**config/upload.php** and it will be used automatically. You will NOT +need to use the ``$this->upload->initialize()`` method if you save your preferences in a config file. -****************** -Function Reference -****************** +*************** +Class Reference +*************** -The following functions are available +The following methods are available: $this->upload->do_upload() -=========================== +========================== + +Performs the upload based on the preferences you've set. + +.. note:: By default the upload routine expects the file to come from + a form field called userfile, and the form must be of type + "multipart". -Performs the upload based on the preferences you've set. Note: By -default the upload routine expects the file to come from a form field -called userfile, and the form must be a "multipart type:: +::
If you would like to set your own field name simply pass its value to -the do_upload function:: +the ``do_upload()`` method:: $field_name = "some_field_name"; $this->upload->do_upload($field_name); $this->upload->display_errors() -================================ +=============================== -Retrieves any error messages if the do_upload() function returned -false. The function does not echo automatically, it returns the data so +Retrieves any error messages if the ``do_upload()`` method returned +false. The method does not echo automatically, it returns the data so you can assign it however you need. Formatting Errors ***************** -By default the above function wraps any errors within

tags. You can +By default the above method wraps any errors within

tags. You can set your own delimiters like this:: $this->upload->display_errors('

', '

'); @@ -270,25 +278,25 @@ set your own delimiters like this:: $this->upload->data() ===================== -This is a helper function that returns an array containing all of the +This is a helper method that returns an array containing all of the data related to the file you uploaded. Here is the array prototype:: Array ( - [file_name] => mypic.jpg - [file_type] => image/jpeg - [file_path] => /path/to/your/upload/ - [full_path] => /path/to/your/upload/jpg.jpg - [raw_name] => mypic - [orig_name] => mypic.jpg - [client_name] => mypic.jpg - [file_ext] => .jpg - [file_size] => 22.2 - [is_image] => 1 - [image_width] => 800 - [image_height] => 600 - [image_type] => jpeg - [image_size_str] => width="800" height="200" + [file_name] => mypic.jpg + [file_type] => image/jpeg + [file_path] => /path/to/your/upload/ + [full_path] => /path/to/your/upload/jpg.jpg + [raw_name] => mypic + [orig_name] => mypic.jpg + [client_name] => mypic.jpg + [file_ext] => .jpg + [file_size] => 22.2 + [is_image] => 1 + [image_width] => 800 + [image_height] => 600 + [image_type] => jpeg + [image_size_str] => width="800" height="200" ) To return one element from the array:: @@ -332,4 +340,4 @@ Image height Image type. Typically the file extension without the period. **image_size_str** A string containing the width and height. Useful to put into an image -tag. +tag. \ No newline at end of file -- cgit v1.2.3-24-g4f1b