From d187847cd09eaacb881ddebe74416fdfa7a6ead9 Mon Sep 17 00:00:00 2001 From: garrettair Date: Wed, 3 Dec 2014 15:28:07 -0600 Subject: Updated Zip Library documentation to mention compression features. Signed-off-by: garrettair --- user_guide_src/source/libraries/zip.rst | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/zip.rst b/user_guide_src/source/libraries/zip.rst index 4ca14086a..a6b98c2ac 100644 --- a/user_guide_src/source/libraries/zip.rst +++ b/user_guide_src/source/libraries/zip.rst @@ -88,6 +88,11 @@ Class Reference The above example will place my_bio.txt inside a folder called personal. + You can change the level of compression and encoding that is used by the gzcompress function during compression:: + + $this->zip->compression_level = 0; // Disable compression + $this->zip->compression_encoding = ZLIB_ENCODING_GZIP; + .. method:: add_dir($directory) :param mixed $directory: Directory name string or an array of multiple directories -- cgit v1.2.3-24-g4f1b From 694d400efb077666955672c2e8c22e4d1b3a3a06 Mon Sep 17 00:00:00 2001 From: James L Parry Date: Wed, 3 Dec 2014 20:53:40 -0800 Subject: Flag the smiley helper and shopping cart as deprecated. They should be removed the next minor release. Lowered the "javascript" deprecation message to "important" instead of "warning", for consistency with the rest of CI. Signed-off-by:James L Parry --- user_guide_src/source/libraries/cart.rst | 4 ++++ user_guide_src/source/libraries/javascript.rst | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (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 bedea4dbf..e06a4d127 100644 --- a/user_guide_src/source/libraries/cart.rst +++ b/user_guide_src/source/libraries/cart.rst @@ -2,6 +2,10 @@ Shopping Cart Class ################### +.. important:: This library is DEPRECATED and should not be used. + It is now no longer supported. + Currently only kept for backwards compatibility. + The Cart Class permits items to be added to a session that stays active while a user is browsing your site. These items can be retrieved and displayed in a standard "shopping cart" format, allowing the user to diff --git a/user_guide_src/source/libraries/javascript.rst b/user_guide_src/source/libraries/javascript.rst index 9d0237e57..5ca12515c 100644 --- a/user_guide_src/source/libraries/javascript.rst +++ b/user_guide_src/source/libraries/javascript.rst @@ -2,7 +2,7 @@ Javascript Class ################ -.. note:: This library is DEPRECATED and should not be used. It has always +.. important:: This library is DEPRECATED and should not be used. It has always been with an 'experimental' status and is now no longer supported. Currently only kept for backwards compatibility. -- cgit v1.2.3-24-g4f1b From 309d7012a737f140076cabbe8873dc39f25331b2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 4 Dec 2014 11:47:26 +0200 Subject: Zip library changes related to PR #3341 - Drop compression_encoding option, it requires PHP 5.4. - Change default compression_level to 2 as this was previously the hard-coded default. - Improve on the doc changes made in the PR. --- user_guide_src/source/libraries/zip.rst | 56 ++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 21 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/zip.rst b/user_guide_src/source/libraries/zip.rst index a6b98c2ac..0f255755e 100644 --- a/user_guide_src/source/libraries/zip.rst +++ b/user_guide_src/source/libraries/zip.rst @@ -25,7 +25,9 @@ your controller using the $this->load->library function:: $this->load->library('zip'); -Once loaded, the Zip library object will be available using: $this->zip +Once loaded, the Zip library object will be available using: + + $this->zip Usage Example ============= @@ -52,6 +54,14 @@ Class Reference .. class:: CI_Zip + .. attribute:: $compression_level = 2 + + The compression level to use. + + It can range from 0 to 9, with 9 being the highest and 0 effectively disabling compression:: + + $this->zip->compression_level = 0; + .. method:: add_data($filepath[, $data = NULL]) :param mixed $filepath: A single file path or an array of file => data pairs @@ -60,7 +70,8 @@ Class Reference Adds data to the Zip archive. Can work both in single and multiple files mode. - When adding a single file, the first parameter must contain the name you would like given to the file and the second must contain the file contents:: + When adding a single file, the first parameter must contain the name you would + like given to the file and the second must contain the file contents:: $name = 'mydata1.txt'; $data = 'A Data String!'; @@ -70,7 +81,8 @@ Class Reference $data = 'Another Data String!'; $this->zip->add_data($name, $data); - When adding multiple files, the first parameter must contain *file => contents* pairs and the second parameter is ignored:: + When adding multiple files, the first parameter must contain *file => contents* pairs + and the second parameter is ignored:: $data = array( 'mydata1.txt' => 'A Data String!', @@ -79,7 +91,8 @@ Class Reference $this->zip->add_data($data); - If you would like your compressed data organized into sub-directories, simply include the path as part of the filename(s):: + If you would like your compressed data organized into sub-directories, simply include + the path as part of the filename(s):: $name = 'personal/my_bio.txt'; $data = 'I was born in an elevator...'; @@ -88,18 +101,14 @@ Class Reference The above example will place my_bio.txt inside a folder called personal. - You can change the level of compression and encoding that is used by the gzcompress function during compression:: - - $this->zip->compression_level = 0; // Disable compression - $this->zip->compression_encoding = ZLIB_ENCODING_GZIP; - .. method:: add_dir($directory) :param mixed $directory: Directory name string or an array of multiple directories :rtype: void - Permits you to add a directory. Usually this method is unnecessary since you can place your data into directories when using - ``$this->zip->add_data()``, but if you would like to create an empty directory you can do so:: + Permits you to add a directory. Usually this method is unnecessary since you can place + your data into directories when using ``$this->zip->add_data()``, but if you would like + to create an empty directory you can do so:: $this->zip->add_dir('myfolder'); // Creates a directory called "myfolder" @@ -161,15 +170,16 @@ Class Reference // Download the file to your desktop. Name it "my_backup.zip" $this->zip->download('my_backup.zip'); - By default the Zip archive will place all directories listed in the first parameter inside the zip. - If you want the tree preceding the target directory to be ignored you can pass FALSE (boolean) in the second parameter. Example:: + By default the Zip archive will place all directories listed in the first parameter + inside the zip. If you want the tree preceding the target directory to be ignored, + you can pass FALSE (boolean) in the second parameter. Example:: $path = '/path/to/your/directory/'; $this->zip->read_dir($path, FALSE); - This will create a ZIP with a directory named "directory" inside, then all sub-directories stored correctly inside that, but will not include the - */path/to/your* part of the path. + This will create a ZIP with a directory named "directory" inside, then all sub-directories + stored correctly inside that, but will not include the */path/to/your* part of the path. .. method:: archive($filepath) @@ -177,8 +187,9 @@ Class Reference :returns: TRUE on success, FALSE on failure :rtype: bool - Writes the Zip-encoded file to a directory on your server. Submit a valid server path ending in the file name. - Make sure the directory is writable (755 is usually OK). Example:: + Writes the Zip-encoded file to a directory on your server. Submit a valid server path + ending in the file name. Make sure the directory is writable (755 is usually OK). + Example:: $this->zip->archive('/path/to/folder/myarchive.zip'); // Creates a file named myarchive.zip @@ -187,7 +198,8 @@ Class Reference :param string $filename: Archive file name :rtype: void - Causes the Zip file to be downloaded from your server. You must pass the name you would like the zip file called. Example:: + Causes the Zip file to be downloaded from your server. + You must pass the name you would like the zip file called. Example:: $this->zip->download('latest_stuff.zip'); // File will be named "latest_stuff.zip" @@ -200,7 +212,8 @@ Class Reference :returns: Zip file content :rtype: string - Returns the Zip-compressed file data. Generally you will not need this method unless you want to do something unique with the data. Example:: + Returns the Zip-compressed file data. Generally you will not need this method unless you + want to do something unique with the data. Example:: $name = 'my_bio.txt'; $data = 'I was born in an elevator...'; @@ -213,8 +226,9 @@ Class Reference :rtype: void - The Zip class caches your zip data so that it doesn't need to recompile the Zip archive for each method you use above. - If, however, you need to create multiple Zip archives, each with different data, you can clear the cache between calls. Example:: + The Zip class caches your zip data so that it doesn't need to recompile the Zip archive + for each method you use above. If, however, you need to create multiple Zip archives, + each with different data, you can clear the cache between calls. Example:: $name = 'my_bio.txt'; $data = 'I was born in an elevator...'; -- cgit v1.2.3-24-g4f1b From 21c3c22320a10d32054b251b24e5b1e569ddeabf Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 4 Dec 2014 12:10:00 +0200 Subject: [ci skip] Update on the changes from PR #3388 - Fixed a broken link - Added missing notes about deprecations in the upgrade instructions - Improved consistency with other deprecation notices in the docs --- user_guide_src/source/libraries/cart.rst | 7 +++---- user_guide_src/source/libraries/javascript.rst | 8 ++++---- 2 files changed, 7 insertions(+), 8 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 e06a4d127..a023ccb36 100644 --- a/user_guide_src/source/libraries/cart.rst +++ b/user_guide_src/source/libraries/cart.rst @@ -2,15 +2,14 @@ Shopping Cart Class ################### -.. important:: This library is DEPRECATED and should not be used. - It is now no longer supported. - Currently only kept for backwards compatibility. - The Cart Class permits items to be added to a session that stays active while a user is browsing your site. These items can be retrieved and displayed in a standard "shopping cart" format, allowing the user to update the quantity or remove items from the cart. +.. important:: The Card library is DEPRECATED and should not be used. + It is currently only kept for backwards compatibility. + Please note that the Cart Class ONLY provides the core "cart" functionality. It does not provide shipping, credit card authorization, or other processing components. diff --git a/user_guide_src/source/libraries/javascript.rst b/user_guide_src/source/libraries/javascript.rst index 5ca12515c..7f83b2f70 100644 --- a/user_guide_src/source/libraries/javascript.rst +++ b/user_guide_src/source/libraries/javascript.rst @@ -2,16 +2,16 @@ Javascript Class ################ -.. important:: This library is DEPRECATED and should not be used. It has always - been with an 'experimental' status and is now no longer supported. - Currently only kept for backwards compatibility. - CodeIgniter provides a library to help you with certain common functions that you may want to use with Javascript. Please note that CodeIgniter does not require the jQuery library to run, and that any scripting library will work equally well. The jQuery library is simply presented as a convenience if you choose to use it. +.. important:: This library is DEPRECATED and should not be used. It has always + been with an 'experimental' status and is now no longer supported. + Currently only kept for backwards compatibility. + .. contents:: :local: -- cgit v1.2.3-24-g4f1b From b906149a2e6b4d607294b12d4a690ed3af84eed0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 4 Dec 2014 16:33:24 +0200 Subject: DB forge/utilities polishing (docs) following #3375, #3378 --- user_guide_src/source/libraries/encryption.rst | 1 + 1 file changed, 1 insertion(+) (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 f29ebf4ed..2d0ee23a3 100644 --- a/user_guide_src/source/libraries/encryption.rst +++ b/user_guide_src/source/libraries/encryption.rst @@ -533,6 +533,7 @@ Class Reference :param int $length: Optional output length :param string $info: Optional context/application-specific info :returns: A pseudo-random key or FALSE on failure + :rtype: string Derives a key from another, presumably weaker key. -- cgit v1.2.3-24-g4f1b From f3f06f258041a2962ef1a7c0b3f5079ca84fe564 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 4 Dec 2014 16:54:07 +0200 Subject: [ci skip] Polish changes from PR #3365 --- user_guide_src/source/libraries/parser.rst | 202 +++++++++++++++-------------- 1 file changed, 104 insertions(+), 98 deletions(-) (limited to 'user_guide_src/source/libraries') diff --git a/user_guide_src/source/libraries/parser.rst b/user_guide_src/source/libraries/parser.rst index e7c7e3abd..d66684d9b 100644 --- a/user_guide_src/source/libraries/parser.rst +++ b/user_guide_src/source/libraries/parser.rst @@ -10,18 +10,18 @@ If you've never used a template engine, pseudo-variable names are enclosed in braces, like this:: - - {blog_title} - - - -

{blog_heading}

- - {blog_entries} -
{title}
-

{body}

- {/blog_entries} - + + {blog_title} + + +

{blog_heading}

+ + {blog_entries} +
{title}
+

{body}

+ {/blog_entries} + + These variables are not actual PHP variables, but rather plain text @@ -30,8 +30,8 @@ representations that allow you to eliminate PHP from your templates .. note:: CodeIgniter does **not** require you to use this class since using pure PHP in your view pages lets them run a little faster. - However, some developers prefer to use a template engine if - they work with designers who they feel would find some + However, some developers prefer to use a template engine if + they work with designers who they feel would find some confusion working with PHP. .. important:: The Template Parser Class is **not** a full-blown @@ -53,7 +53,7 @@ Initializing the Class ====================== Like most other classes in CodeIgniter, the Parser class is initialized -in your controller using the $this->load->library function:: +in your controller using the ``$this->load->library()`` method:: $this->load->library('parser'); @@ -63,12 +63,12 @@ $this->parser Parsing templates ================= -You can use the ``parse()`` method to parse (or render) simple templates, +You can use the ``parse()`` method to parse (or render) simple templates, like this:: $data = array( - 'blog_title' => 'My Blog Title', - 'blog_heading' => 'My Blog Heading' + 'blog_title' => 'My Blog Title', + 'blog_heading' => 'My Blog Heading' ); $this->parser->parse('blog_template', $data); @@ -96,18 +96,18 @@ iteration containing new values? Consider the template example we showed at the top of the page:: - - {blog_title} - - - -

{blog_heading}

- - {blog_entries} -
{title}
-

{body}

- {/blog_entries} - + + {blog_title} + + +

{blog_heading}

+ + {blog_entries} +
{title}
+

{body}

+ {/blog_entries} + + In the above code you'll notice a pair of variables: {blog_entries} @@ -122,31 +122,31 @@ corresponding to your variable pair data. Consider this example:: $this->load->library('parser'); $data = array( - 'blog_title' => 'My Blog Title', - 'blog_heading' => 'My Blog Heading', - 'blog_entries' => array( - array('title' => 'Title 1', 'body' => 'Body 1'), - array('title' => 'Title 2', 'body' => 'Body 2'), - array('title' => 'Title 3', 'body' => 'Body 3'), - array('title' => 'Title 4', 'body' => 'Body 4'), - array('title' => 'Title 5', 'body' => 'Body 5') - ) + 'blog_title' => 'My Blog Title', + 'blog_heading' => 'My Blog Heading', + 'blog_entries' => array( + array('title' => 'Title 1', 'body' => 'Body 1'), + array('title' => 'Title 2', 'body' => 'Body 2'), + array('title' => 'Title 3', 'body' => 'Body 3'), + array('title' => 'Title 4', 'body' => 'Body 4'), + array('title' => 'Title 5', 'body' => 'Body 5') + ) ); $this->parser->parse('blog_template', $data); If your "pair" data is coming from a database result, which is already a -multi-dimensional array, you can simply use the database result_array() -function:: +multi-dimensional array, you can simply use the database ``result_array()`` +method:: $query = $this->db->query("SELECT * FROM blog"); $this->load->library('parser'); $data = array( - 'blog_title' => 'My Blog Title', - 'blog_heading' => 'My Blog Heading', - 'blog_entries' => $query->result_array() + 'blog_title' => 'My Blog Title', + 'blog_heading' => 'My Blog Heading', + 'blog_entries' => $query->result_array() ); $this->parser->parse('blog_template', $data); @@ -154,94 +154,95 @@ function:: Usage Notes =========== -If you include substitution parameters that are not referenced in your +If you include substitution parameters that are not referenced in your template, they are ignored:: $template = 'Hello, {firstname} {lastname}'; $data = array( - 'title' => 'Mr', - 'firstname' => 'John', - 'lastname' => 'Doe' + 'title' => 'Mr', + 'firstname' => 'John', + 'lastname' => 'Doe' ); $this->parser->parse_string($template, $data); - Result: Hello, John Doe + // Result: Hello, John Doe -If you do not include a substitution parameter that is referenced in your +If you do not include a substitution parameter that is referenced in your template, the original pseudo-variable is shown in the result:: $template = 'Hello, {firstname} {initials} {lastname}'; $data = array( - 'title' => 'Mr', - 'firstname' => 'John', - 'lastname' => 'Doe' + 'title' => 'Mr', + 'firstname' => 'John', + 'lastname' => 'Doe' ); $this->parser->parse_string($template, $data); - Result: Hello, John {initials} Doe + // Result: Hello, John {initials} Doe -If you provide a string substitution parameter when an array is expected, +If you provide a string substitution parameter when an array is expected, i.e. for a variable pair, the substitution is done for the opening variable pair tag, but the closing variable pair tag is not rendered properly:: $template = 'Hello, {firstname} {lastname} ({degrees}{degree} {/degrees})'; $data = array( - 'degrees' => 'Mr', - 'firstname' => 'John', - 'lastname' => 'Doe', - 'titles' => array( - array('degree' => 'BSc'), - array('degree' => 'PhD') - - ) + 'degrees' => 'Mr', + 'firstname' => 'John', + 'lastname' => 'Doe', + 'titles' => array( + array('degree' => 'BSc'), + array('degree' => 'PhD') + ) ); $this->parser->parse_string($template, $data); - Result: Hello, John Doe (Mr{degree} {/degrees}) + // Result: Hello, John Doe (Mr{degree} {/degrees}) -If you name one of your individual substitution parameters the same as one -used inside a variable pair, the results -may not be as expected:: +If you name one of your individual substitution parameters the same as one +used inside a variable pair, the results may not be as expected:: $template = 'Hello, {firstname} {lastname} ({degrees}{degree} {/degrees})'; $data = array( - 'degree' => 'Mr', - 'firstname' => 'John', - 'lastname' => 'Doe', - 'degrees' => array( - array('degree' => 'BSc'), - array('degree' => 'PhD') - - ) + 'degree' => 'Mr', + 'firstname' => 'John', + 'lastname' => 'Doe', + 'degrees' => array( + array('degree' => 'BSc'), + array('degree' => 'PhD') + ) ); $this->parser->parse_string($template, $data); - Result: Hello, John Doe (Mr Mr ) + // Result: Hello, John Doe (Mr Mr ) View Fragments ============== -You do not have to use variable pairs to get the effect of iteration in -your views. It is possible to use a view fragment for what would be inside -a variable pair, and to control the iteration in your controller instead +You do not have to use variable pairs to get the effect of iteration in +your views. It is possible to use a view fragment for what would be inside +a variable pair, and to control the iteration in your controller instead of in the view. An example with the iteration controlled in the view:: $template = '
    {menuitems} -
  • {title}
  • - {/menuitems}
'; +
  • {title}
  • + {/menuitems}'; + $data = array( - 'menuitems' => array( - array('title' => 'First Link', 'link' => '/first'), - array('title' => 'Second Link', 'link' => '/second'), - ) + 'menuitems' => array( + array('title' => 'First Link', 'link' => '/first'), + array('title' => 'Second Link', 'link' => '/second'), + ) ); $this->parser->parse_string($template, $data); - Result: - - First Link - - Second Link +Result:: + + An example with the iteration controlled in the controller, using a view fragment:: @@ -252,19 +253,24 @@ using a view fragment:: array('title' => 'First Link', 'link' => '/first'), array('title' => 'Second Link', 'link' => '/second'), ); - foreach ($data1 as $menuitem) { - $temp .= $this->parser->parse_string($template1, $menuitem, TRUE); + + foreach ($data1 as $menuitem) + { + $temp .= $this->parser->parse_string($template1, $menuitem, TRUE); } $template = '
      {menuitems}
    '; $data = array( - 'menuitems' => $temp + 'menuitems' => $temp ); $this->parser->parse_string($template, $data); - Result: - - First Link - - Second Link +Result:: + + *************** Class Reference @@ -290,8 +296,8 @@ Class Reference :returns: Parsed template string :rtype: string - This method works exactly like ``parse()``, only it accepts - the template as a string instead of loading a view file. + This method works exactly like ``parse()``, only it accepts + the template as a string instead of loading a view file. .. method:: set_delimiters([$l = '{'[, $r = '}']]) @@ -299,5 +305,5 @@ Class Reference :param string $r: Right delimiter :rtype: void - Sets the delimiters (opening and closing) for a - pseudo-variable "tag" in a template. \ No newline at end of file + Sets the delimiters (opening and closing) for a + pseudo-variable "tag" in a template. \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 0972c2194e1bd66e6a399c61c31da68333db426e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 4 Dec 2014 17:00:33 +0200 Subject: [ci skip] Polish changes from PR #3361 --- user_guide_src/source/libraries/language.rst | 82 ++++++++++++++-------------- 1 file changed, 41 insertions(+), 41 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 c3f9b6d5a..e833d9757 100644 --- a/user_guide_src/source/libraries/language.rst +++ b/user_guide_src/source/libraries/language.rst @@ -5,26 +5,25 @@ Language Class The Language Class provides functions to retrieve language files and lines of text for purposes of internationalization. -In your CodeIgniter **system** folder, you will find a **language** -subfolder containing a set of language files for the **english** idiom. -The files in this folder (**system/language/english/**) define the regular messages, +In your CodeIgniter **system** folder, you will find a **language** sub-directory +containing a set of language files for the **english** idiom. +The files in this directory (**system/language/english/**) define the regular messages, error messages, and other generally output terms or expressions, for the different parts -of the CodeIgniter core framework. +of the CodeIgniter framework. -You can create or incorporate your own language -files, as needed, in order to provide application-specific error and other messages, -or to provide translations of the core messages into other languages. -These translations or additional messages would go inside your application/language folder, -with separate subfolders for each idiom (for instance french or german). +You can create or incorporate your own language files, as needed, in order to provide +application-specific error and other messages, or to provide translations of the core +messages into other languages. These translations or additional messages would go inside +your **application/language/** directory, with separate sub-directories for each idiom +(for instance, 'french' or 'german'). The CodeIgniter framework comes with a set of language files for the "english" idiom. -Additional approved translations for different idioms may be found in the +Additional approved translations for different idioms may be found in the `CodeIgniter 3 Translations repositories `_. Each repository deals with a single idiom. -When CodeIgniter loads language files, it will load the -one in **system/language/** first and will then look for an override in -your **application/language/** directory. +When CodeIgniter loads language files, it will 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 @@ -41,7 +40,7 @@ Handling Multiple Languages *************************** If you want to support multiple languages in your application, you would provide folders inside -your **application/language/** directory for each of them, and you would specify the default +your **application/language/** directory for each of them, and you would specify the default language in your **application/config/config.php**. The **application/language/english/** directory would contain any additional language files @@ -58,45 +57,46 @@ Sample Language Files :: - system/ - language/ - english/ - ... - email_lang.php - form_validation_lang.php - ... - - application/ - language/ - english/ - error_messages_lang.php - french/ - ... - email_lang.php - error_messages_lang.php - form_validation_lang.php - ... + system/ + language/ + english/ + ... + email_lang.php + form_validation_lang.php + ... + + application/ + language/ + english/ + error_messages_lang.php + french/ + ... + email_lang.php + error_messages_lang.php + form_validation_lang.php + ... Example of switching languages ============================== :: - $idiom = $this->session->get_userdata('language'); - $this->lang->load('error_messages',$idiom); - $oops = $this->lang->line('nessage_key'); + $idiom = $this->session->get_userdata('language'); + $this->lang->load('error_messages', $idiom); + $oops = $this->lang->line('message_key'); ******************** Internationalization ******************** -The Language class in CodeIgniter is meant to provide an easy and lightweight way to support multiple -languages in your application. It is not meant to be a full implementation of what is commonly called -`internationalization and localization `_. +The Language class in CodeIgniter is meant to provide an easy and lightweight +way to support multiplelanguages in your application. It is not meant to be a +full implementation of what is commonly called `internationalization and localization +`_. -We use the term "idiom" to refer to a language using its common name, -rather than using any of the international standards, such as "en", "en-US", or "en-CA-x-ca" for English -and some of its variants. +We use the term "idiom" to refer to a language using its common name, +rather than using any of the international standards, such as "en", "en-US", +or "en-CA-x-ca" for English and some of its variants. .. note:: There is nothing to prevent you from using those abbreviations in your application! -- cgit v1.2.3-24-g4f1b From d31a4e64aea57b24306484737a374a7f31b8b983 Mon Sep 17 00:00:00 2001 From: David Wosnitza Date: Fri, 12 Dec 2014 16:35:35 +0100 Subject: fixed indentation/linkref errors Signed-off-by: David Wosnitza --- user_guide_src/source/libraries/input.rst | 20 +++++++++++++------- user_guide_src/source/libraries/zip.rst | 16 ++++++++-------- 2 files changed, 21 insertions(+), 15 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 112347129..695a650e0 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -136,15 +136,17 @@ Class Reference $this->input->post(NULL, TRUE); // returns all POST items with XSS filter $this->input->post(NULL, FALSE); // returns all POST items without XSS filter - + To return an array of multiple POST parameters, pass all the required keys as an array. :: + $this->input->post(array('field1', 'field2')); - + Same rule applied here, to retrive the parameters with XSS filtering enabled, set the second parameter to boolean TRUE. :: + $this->input->post(array('field1', 'field2'), TRUE); .. method:: get([$index = NULL[, $xss_clean = NULL]]) @@ -167,15 +169,17 @@ Class Reference $this->input->get(NULL, TRUE); // returns all GET items with XSS filter $this->input->get(NULL, FALSE); // returns all GET items without XSS filtering - + To return an array of multiple GET parameters, pass all the required keys as an array. :: + $this->input->get(array('field1', 'field2')); - + Same rule applied here, to retrive the parameters with XSS filtering enabled, set the second parameter to boolean TRUE. :: + $this->input->get(array('field1', 'field2'), TRUE); .. method:: post_get($index[, $xss_clean = NULL]) @@ -218,10 +222,11 @@ Class Reference $this->input->cookie('some_cookie'); $this->input->cookie('some_cookie, TRUE); // with XSS filter - + To return an array of multiple cookie values, pass all the required keys as an array. :: + $this->input->cookie(array('some_cookie', 'some_cookie2')); .. method:: server($index[, $xss_clean = NULL]) @@ -239,7 +244,8 @@ Class Reference To return an array of multiple ``$_SERVER`` values, pass all the required keys as an array. :: - $this->input->server(array('SERVER_PROTOCOL', 'REQUEST_URI')); + + $this->input->server(array('SERVER_PROTOCOL', 'REQUEST_URI')); .. method:: input_stream([$index = NULL[, $xss_clean = NULL]]) @@ -437,4 +443,4 @@ Class Reference echo $this->input->method(TRUE); // Outputs: POST echo $this->input->method(FALSE); // Outputs: post - echo $this->input->method(); // Outputs: post \ No newline at end of file + echo $this->input->method(); // Outputs: post diff --git a/user_guide_src/source/libraries/zip.rst b/user_guide_src/source/libraries/zip.rst index 0f255755e..b509236de 100644 --- a/user_guide_src/source/libraries/zip.rst +++ b/user_guide_src/source/libraries/zip.rst @@ -43,7 +43,7 @@ your server, and download it to your desktop. $this->zip->add_data($name, $data); // Write the zip file to a folder on your server. Name it "my_backup.zip" - $this->zip->archive('/path/to/directory/my_backup.zip'); + $this->zip->archive('/path/to/directory/my_backup.zip'); // Download the file to your desktop. Name it "my_backup.zip" $this->zip->download('my_backup.zip'); @@ -80,7 +80,7 @@ Class Reference $name = 'mydata2.txt'; $data = 'Another Data String!'; $this->zip->add_data($name, $data); - + When adding multiple files, the first parameter must contain *file => contents* pairs and the second parameter is ignored:: @@ -124,7 +124,7 @@ Class Reference $path = '/path/to/photo.jpg'; - $this->zip->read_file($path); + $this->zip->read_file($path); // Download the file to your desktop. Name it "my_backup.zip" $this->zip->download('my_backup.zip'); @@ -134,7 +134,7 @@ Class Reference $path = '/path/to/photo.jpg'; - $this->zip->read_file($path, TRUE); + $this->zip->read_file($path, TRUE); // Download the file to your desktop. Name it "my_backup.zip" $this->zip->download('my_backup.zip'); @@ -165,14 +165,14 @@ Class Reference $path = '/path/to/your/directory/'; - $this->zip->read_dir($path); + $this->zip->read_dir($path); // Download the file to your desktop. Name it "my_backup.zip" $this->zip->download('my_backup.zip'); By default the Zip archive will place all directories listed in the first parameter inside the zip. If you want the tree preceding the target directory to be ignored, - you can pass FALSE (boolean) in the second parameter. Example:: + you can pass FALSE (boolean) in the second parameter. Example:: $path = '/path/to/your/directory/'; @@ -236,9 +236,9 @@ Class Reference $this->zip->add_data($name, $data); $zip_file = $this->zip->get_zip(); - $this->zip->clear_data(); + $this->zip->clear_data(); $name = 'photo.jpg'; $this->zip->read_file("/path/to/photo.jpg"); // Read the file's contents - $this->zip->download('myphotos.zip'); \ No newline at end of file + $this->zip->download('myphotos.zip'); -- cgit v1.2.3-24-g4f1b From 08191be30a81ca5843c8f41a189c9d26d40d5f68 Mon Sep 17 00:00:00 2001 From: James L Parry Date: Sat, 20 Dec 2014 02:37:13 -0800 Subject: User Guide Tuning Adjust the heading levels in the writeups for the input, loader, security and unit testing libraries, to match the other library writeups. Specifically, the class reference section in each of these was appearing as a sub-level in the toctree, when it should be at the same level. Signed-off-by:James L Parry --- user_guide_src/source/libraries/input.rst | 8 ++++++++ user_guide_src/source/libraries/loader.rst | 3 ++- user_guide_src/source/libraries/security.rst | 6 ++++-- user_guide_src/source/libraries/unit_testing.rst | 4 ++++ 4 files changed, 18 insertions(+), 3 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 695a650e0..4464e0fdc 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -17,6 +17,10 @@ The Input Class serves two purposes:
    +*************** +Input Filtering +*************** + Security Filtering ================== @@ -49,6 +53,10 @@ this:: Please refer to the :doc:`Security class ` documentation for information on using XSS Filtering in your application. +******************* +Accessing form data +******************* + Using POST, GET, COOKIE, or SERVER Data ======================================= diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst index 107b3ece3..48ac6e174 100644 --- a/user_guide_src/source/libraries/loader.rst +++ b/user_guide_src/source/libraries/loader.rst @@ -18,8 +18,9 @@ can be libraries (classes) :doc:`View files <../general/views>`,
    +********************** Application "Packages" -====================== +********************** An application package allows for the easy distribution of complete sets of resources in a single directory, complete with its own libraries, diff --git a/user_guide_src/source/libraries/security.rst b/user_guide_src/source/libraries/security.rst index 0c51e342b..a39ef5976 100644 --- a/user_guide_src/source/libraries/security.rst +++ b/user_guide_src/source/libraries/security.rst @@ -12,8 +12,9 @@ application, processing input data for security.
    +************* XSS Filtering -============= +************* CodeIgniter comes with a Cross Site Scripting Hack prevention filter which can either run automatically to filter all POST and COOKIE data @@ -57,8 +58,9 @@ browser may attempt to execute. // file failed the XSS test } +********************************* Cross-site request forgery (CSRF) -================================= +********************************* You can enable CSRF protection by altering your **application/config/config.php** file in the following way:: diff --git a/user_guide_src/source/libraries/unit_testing.rst b/user_guide_src/source/libraries/unit_testing.rst index 0bc860f61..7e91a7b95 100644 --- a/user_guide_src/source/libraries/unit_testing.rst +++ b/user_guide_src/source/libraries/unit_testing.rst @@ -18,6 +18,10 @@ code to determine if it is producing the correct data type and result.
    +****************************** +Using the Unit Testing Library +****************************** + Initializing the Class ====================== -- cgit v1.2.3-24-g4f1b From 40651ebf5e29fd4a17be2cd338e8d501d41b66b1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 5 Jan 2015 17:23:13 +0200 Subject: Remove CI_Form_validation::xss_clean() More details in the commit diff itself, and here: https://github.com/benedmunds/CodeIgniter-Ion-Auth/issues/683#issuecomment-66598821 --- user_guide_src/source/libraries/form_validation.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 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 aae9e3b89..f964965ec 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -326,14 +326,13 @@ In addition to the validation method like the ones we used above, you 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('username', 'Username', 'trim|required|min_length[5]|max_length[12]'); $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 -password to MD5, and running the username through the `xss_clean()` -method, which removes malicious data. +In the above example, we are "trimming" the fields, checking for length +where necessary and converting the password to MD5. **Any native PHP function that accepts one parameter can be used as a rule, like htmlspecialchars, trim, md5, etc.** @@ -1002,7 +1001,6 @@ to use: ==================== ========= ======================================================================================================= Name Parameter Description ==================== ========= ======================================================================================================= -**xss_clean** No Runs the data through the XSS filtering method, described in the :doc:`Security Class ` page. **prep_for_form** No Converts special characters so that HTML data can be shown in a form field without breaking it. **prep_url** No Adds "\http://" to URLs if missing. **strip_image_tags** No Strips the HTML from image tags leaving the raw URL. -- cgit v1.2.3-24-g4f1b