diff options
Diffstat (limited to 'user_guide_src/source')
-rw-r--r-- | user_guide_src/source/changelog.rst | 16 | ||||
-rw-r--r-- | user_guide_src/source/general/routing.rst | 4 | ||||
-rw-r--r-- | user_guide_src/source/installation/upgrade_300.rst | 34 | ||||
-rw-r--r-- | user_guide_src/source/libraries/form_validation.rst | 4 | ||||
-rw-r--r-- | user_guide_src/source/libraries/loader.rst | 146 | ||||
-rw-r--r-- | user_guide_src/source/tutorial/news_section.rst | 4 |
6 files changed, 121 insertions, 87 deletions
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8b9ec2539..893c3db61 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -38,7 +38,6 @@ Release Date: Not Released - Updated support for php files in mimes.php. - Updated support for zip files in mimes.php. - Updated support for csv files in mimes.php. - - Added some more doctypes. - Added Romanian, Greek, Vietnamese and Cyrilic characters in *application/config/foreign_characters.php*. - Changed logger to only chmod when file is first created. - Removed previously deprecated SHA1 Library. @@ -74,7 +73,10 @@ Release Date: Not Released - Added support (auto-detection) for HTTP/1.1 response code 303 in :php:func:`redirect()`. - Changed :php:func:`redirect()` to only choose the **refresh** method only on IIS servers, instead of all servers on Windows (when **auto** is used). - Changed :php:func:`anchor()`, :php:func:`anchor_popup()`, and :php:func:`redirect()` to support protocol-relative URLs (e.g. *//ellislab.com/codeigniter*). - - Added XHTML Basic 1.1 doctype to :doc:`HTML Helper <helpers/html_helper>`. + - :doc:`HTML Helper <helpers/html_helper>` changes include: + - Added more doctypes. + - Changed application and environment config files to be loaded in a cascade-like manner. + - The doctypes array is now cached and loaded only once. - :doc:`Inflector Helper <helpers/inflector_helper>` changes include: - Changed :php:func:`humanize()` to allow passing an input separator as its second parameter. - Refactored :php:func:`plural()` and :php:func:`singular()` to avoid double pluralization and support more words. @@ -88,7 +90,10 @@ Release Date: Not Released - :doc:`Security Helper <helpers/security_helper>` changes include: - :php:func:`do_hash()` now uses PHP's native ``hash()`` function (supporting more algorithms) and is deprecated. - :php:func:`strip_image_tags()` is now an alias for the same method in the :doc:`Security Library <libraries/security>`. - - Removed previously deprecated helper function ``js_insert_smiley()`` from :doc:`Smiley Helper <helpers/smiley_helper>`. + - :doc:`Smiley Helper <helpers/smiley_helper>` changes include: + - Removed previously deprecated function ``js_insert_smiley()``. + - Changed application and environment config files to be loaded in a cascade-like manner. + - The smileys array is now cached and loaded only once. - :doc:`File Helper <helpers/file_helper>` changes include: - :php:func:`set_realpath()` can now also handle file paths as opposed to just directories. - Added an optional paramater to :php:func:`delete_files()` to enable it to skip deleting files such as *.htaccess* and *index.html*. @@ -210,6 +215,7 @@ Release Date: Not Released - Added **max_filename_increment** config setting. - Added an **index** parameter to the ``data()`` method. - Added the **min_width** and **min_height** options for images. + - Removed method ``clean_file_name()`` and its usage in favor of :doc:`Security Library <libraries/security>`'s ``sanitize_filename()``. - :doc:`Cart library <libraries/cart>` changes include: - ``insert()`` now auto-increments quantity for an item when inserted twice instead of resetting it, this is the default behaviour of large e-commerce sites. - *Product Name* strictness can be disabled by switching the ``$product_name_safe`` property to FALSE. @@ -236,6 +242,7 @@ Release Date: Not Released - Added rule **valid_url**. - Added support for named parameters in error messages. - :doc:`Language <libraries/language>` line keys must now be prefixed with **form_validation_**. + - Added rule **alpha_numeric_spaces**. - Added support for setting :doc:`Table <libraries/table>` class defaults in a config file. - :doc:`Caching Library <libraries/caching>` changes include: - Added Wincache driver. @@ -472,6 +479,9 @@ Bug fixes for 3.0 - Fixed a bug (#113) - :doc:`Form Validation Library <libraries/form_validation>` didn't properly handle empty fields that were specified as an array. - Fixed a bug (#2061) - :doc:`Routing Class <general/routing>` didn't properly sanitize directory, controller and function triggers with **enable_query_strings** set to TRUE. - Fixed a bug - SQLSRV didn't support ``escape_like_str()`` or escaping an array of values. +- Fixed a bug - :doc:`DB result <database/results>` method ``list_fields()`` didn't reset its field pointer for the *mysql*, *mysqli* and *mssql* drivers. +- Fixed a bug (#73) - :doc:`Security Library <libraries/security>` method ``sanitize_filename()`` could be tricked by an XSS attack. +- Fixed a bug (#2211) - :doc:`Migration Library <libraries/migration>` extensions couldn't execute ``CI_Migration::__construct()``. Version 2.1.3 ============= diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst index 2a0332088..ed21a6109 100644 --- a/user_guide_src/source/general/routing.rst +++ b/user_guide_src/source/general/routing.rst @@ -129,7 +129,7 @@ For those of you who don't know regular expressions and want to learn more about them, `regular-expressions.info <http://www.regular-expressions.info/>` might be a good starting point. -..note:: You can also mix and match wildcards with regular expressions. +.. note:: You can also mix and match wildcards with regular expressions. Callbacks ========= @@ -137,7 +137,7 @@ Callbacks If you are using PHP >= 5.3 you can use callbacks in place of the normal routing rules to process the back-references. Example:: - $route['products/([a-z]+)/edit/(\d+)'] = function ($product_type, $id) + $route['products/([a-zA-Z]+)/edit/(\d+)'] = function ($product_type, $id) { return 'catalog/product_edit/' . strtolower($product_type) . '/' . $id; }; diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index 94f6321be..2d125a71a 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -104,16 +104,40 @@ regular expression:: (.+) // matches ANYTHING (:any) // matches any character, except for '/' +******************************************* +Step 9: Update your librararies' file names +******************************************* + +CodeIgniter 3.0 only allows library file names to be named in a *ucfirst* manner +(meaning that the first letter of the class name must be a capital). For example, +if you have the following library file: + + application/libraries/mylibrary.php + +... then you'll have to rename it to: + + application/libraries/Mylibrary.php + +The same goes for driver libraries and extensions and/or overrides of CodeIgniter's +own libraries and core classes. + + application/libraries/MY_email.php + application/core/MY_log.php + +The above files should respectively be renamed to the following: + + application/libraries/MY_Email.php + application/core/MY_Log.php **************************************************************************** -Step 9: Check the calls to Array Helper's element() and elements() functions +Step 10: Check the calls to Array Helper's element() and elements() functions **************************************************************************** The default return value of these functions, when the required elements don't exist, has been changed from FALSE to NULL. ************************************************************* -Step 10: Update usage of Database Forge's drop_table() method +Step 11: Update usage of Database Forge's drop_table() method ************************************************************* Up until now, ``drop_table()`` added an IF EXISTS clause by default or it didn't work @@ -135,7 +159,7 @@ If your application relies on IF EXISTS, you'll have to change its usage. all drivers with the exception of ODBC. *********************************************************** -Step 11: Change usage of Email library with multiple emails +Step 12: Change usage of Email library with multiple emails *********************************************************** The :doc:`Email Library <../libraries/email>` will automatically clear the @@ -150,7 +174,7 @@ pass FALSE as the first parameter in the ``send()`` method: } *************************************************** -Step 12: Update your Form_validation language lines +Step 13: Update your Form_validation language lines *************************************************** Two improvements have been made to the :doc:`Form Validation Library @@ -181,7 +205,7 @@ files and error messages format: later. **************************************************************** -Step 13: Remove usage of (previously) deprecated functionalities +Step 14: Remove usage of (previously) deprecated functionalities **************************************************************** In addition to the ``$autoload['core']`` configuration setting, there's a diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index ae7859aa3..8b35fdc75 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -877,7 +877,9 @@ Rule Parameter Description **less_than_equal_to** Yes Returns FALSE if the form element is greater than the parameter value, less_than_equal_to[8] or not numeric. **alpha** No Returns FALSE if the form element contains anything other than alphabetical characters. -**alpha_numeric** No Returns FALSE if the form element contains anything other than alpha-numeric characters. +**alpha_numeric** No Returns FALSE if the form element contains anything other than alpha-numeric characters. +**alpha_numeric_spaces** No Returns FALSE if the form element contains anything other than alpha-numeric characters + or spaces. Should be used after trim to avoid spaces at the beginning or end. **alpha_dash** No Returns FALSE if the form element contains anything other than alpha-numeric characters, underscores or dashes. **numeric** No Returns FALSE if the form element contains anything other than numeric characters. diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst index 615aba1c2..b048f4881 100644 --- a/user_guide_src/source/libraries/loader.rst +++ b/user_guide_src/source/libraries/loader.rst @@ -11,14 +11,15 @@ can be libraries (classes) :doc:`View files <../general/views>`, .. note:: This class is initialized automatically by the system so there is no need to do it manually. -The following functions are available in this class: +The following methods are available in this class: $this->load->library('class_name', $config, 'object name') -=========================================================== +========================================================== -This function is used to load core classes. Where class_name is the -name of the class you want to load. Note: We use the terms "class" and -"library" interchangeably. +This method is used to load core classes. Where class_name is the +name of the class you want to load. + +.. note:: We use the terms "class" and "library" interchangeably. For example, if you would like to send email with CodeIgniter, the first step is to load the email class within your controller:: @@ -26,15 +27,15 @@ step is to load the email class within your controller:: $this->load->library('email'); Once loaded, the library will be ready for use, using -$this->email->*some_function*(). +$this->email->*some_method*(). Library files can be stored in subdirectories within the main -"libraries" folder, or within your personal application/libraries -folder. To load a file located in a subdirectory, simply include the -path, relative to the "libraries" folder. For example, if you have file -located at:: +"libraries" directory, or within your personal application/libraries +directory. To load a file located in a subdirectory, simply include the +path, relative to the "libraries" directory. For example, if you have +file located at:: - libraries/flavors/chocolate.php + libraries/flavors/Chocolate.php You will load it using:: @@ -43,7 +44,7 @@ You will load it using:: You may nest the file in as many subdirectories as you want. Additionally, multiple libraries can be loaded at the same time by -passing an array of libraries to the load function. +passing an array of libraries to the load method. :: @@ -56,10 +57,10 @@ The second (optional) parameter allows you to optionally pass configuration setting. You will typically pass these as an array:: $config = array ( - 'mailtype' => 'html', - 'charset' => 'utf-8, - 'priority' => '1' - ); + 'mailtype' => 'html', + 'charset' => 'utf-8, + 'priority' => '1' + ); $this->load->library('email', $config); @@ -84,16 +85,15 @@ third parameter:: $this->load->library('calendar', '', 'my_calendar'); // Calendar 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 +This method 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 @@ -102,15 +102,15 @@ 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*(). +$this->session->*some_method*(). 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 +"libraries" directory, or within your personal application/libraries +directory. 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. +passing an array of drivers to the load method. :: @@ -122,11 +122,11 @@ 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' - ); + $config = array( + 'sess_driver' => 'cookie', + 'sess_encrypt_cookie' => true, + 'encryption_key' => 'mysecretkey' + ); $this->load->driver('session', $config); @@ -135,12 +135,12 @@ 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. +``$this->session``. If you prefer to set your own class names you can pass its value to the third parameter:: @@ -148,32 +148,33 @@ third parameter:: $this->load->library('session', '', 'my_session'); // Session class is now accessed using: - $this->my_session -.. note:: Driver libraries may also be loaded with the library() method, - but it is faster to use driver() +.. 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) -================================================== +$this->load->view('file_name', $data, TRUE/FALSE) +================================================= -This function is used to load your View files. If you haven't read the +This method is used to load your View files. If you haven't read the :doc:`Views <../general/views>` section of the user guide it is -recommended that you do since it shows you how this function is +recommended that you do since it shows you how this method is typically used. The first parameter is required. It is the name of the view file you -would like to load. Note: The .php file extension does not need to be -specified unless you use something other than .php. +would like to load. + +.. note:: The .php file extension does not need to be specified unless + you use something other than .php. The second **optional** parameter can take an associative array or an object as input, which it runs through the PHP -`extract <http://www.php.net/extract>`_ function to convert to variables +`extract() <http://www.php.net/extract>`_ function to convert to variables that can be used in your view files. Again, read the :doc:`Views <../general/views>` page to learn how this might be useful. The third **optional** parameter lets you change the behavior of the -function so that it returns data as a string rather than sending it to +method so that it returns data as a string rather than sending it to your browser. This can be useful if you want to process the data in some way. If you set the parameter to true (boolean) it will return data. The default behavior is false, which sends it to your browser. Remember to @@ -189,79 +190,76 @@ $this->load->model('model_name'); $this->load->model('model_name'); -If your model is located in a sub-folder, include the relative path from -your models folder. For example, if you have a model located at +If your model is located in a subdirectory, include the relative path +from your models directory. For example, if you have a model located at application/models/blog/queries.php you'll load it using:: $this->load->model('blog/queries'); - If you would like your model assigned to a different object name you can -specify it via the second parameter of the loading function:: +specify it via the second parameter of the loading method:: $this->load->model('model_name', 'fubar'); + $this->fubar->method(); - $this->fubar->function(); - -$this->load->database('options', true/false) +$this->load->database('options', TRUE/FALSE) ============================================ -This function lets you load the database class. The two parameters are +This method lets you load the database class. The two parameters are **optional**. Please see the :doc:`database <../database/index>` section for more info. $this->load->vars($array) ========================= -This function takes an associative array as input and generates +This method takes an associative array as input and generates variables using the PHP `extract <http://www.php.net/extract>`_ -function. This function produces the same result as using the second -parameter of the $this->load->view() function above. The reason you -might want to use this function independently is if you would like to +method. This method produces the same result as using the second +parameter of the ``$this->load->view()`` method above. The reason you +might want to use this method independently is if you would like to set some global variables in the constructor of your controller and have -them become available in any view file loaded from any function. You can -have multiple calls to this function. The data get cached and merged +them become available in any view file loaded from any method. You can +have multiple calls to this method. The data get cached and merged into one array for conversion to variables. $this->load->get_var($key) -=========================== +========================== -This function checks the associative array of variables available to +This method checks the associative array of variables available to your views. This is useful if for any reason a var is set in a library -or another controller method using $this->load->vars(). +or another controller method using ``$this->load->vars()``. $this->load->get_vars() -=========================== +======================= -This function retrieves all variables available to -your views. +This method retrieves all variables available to your views. $this->load->helper('file_name') -================================= +================================ -This function loads helper files, where file_name is the name of the +This method loads helper files, where file_name is the name of the file, without the _helper.php extension. -$this->load->file('filepath/filename', true/false) +$this->load->file('filepath/filename', TRUE/FALSE) ================================================== -This is a generic file loading function. Supply the filepath and name in +This is a generic file loading method. Supply the filepath and name in the first parameter and it will open and read the file. By default the data is sent to your browser, just like a View file, but if you set the second parameter to true (boolean) it will instead return the data as a string. $this->load->language('file_name') -=================================== +================================== -This function is an alias of the :doc:`language loading -function <language>`: $this->lang->load() +This method is an alias of the :doc:`language loading +method <language>`: ``$this->lang->load()`` $this->load->config('file_name') -================================= +================================ -This function is an alias of the :doc:`config file loading -function <config>`: $this->config->load() +This method is an alias of the :doc:`config file loading +method <config>`: ``$this->config->load()`` Application "Packages" ====================== @@ -269,7 +267,7 @@ Application "Packages" An application package allows for the easy distribution of complete sets of resources in a single directory, complete with its own libraries, models, helpers, config, and language files. It is recommended that -these packages be placed in the application/third_party folder. Below +these packages be placed in the application/third_party directory. Below is a sample map of an package directory Sample Package "Foo Bar" Directory Map @@ -311,7 +309,7 @@ $this->load->remove_package_path() When your controller is finished using resources from an application package, and particularly if you have other application packages you want to work with, you may wish to remove the package path so the Loader -no longer looks in that folder for resources. To remove the last path +no longer looks in that directory for resources. To remove the last path added, simply call the method with no parameters. $this->load->remove_package_path() @@ -346,4 +344,4 @@ calling add_package_path(). // Again without the second parameter: $this->load->add_package_path(APPPATH.'my_app'); $this->load->view('my_app_index'); // Loads - $this->load->view('welcome_message'); // Loads + $this->load->view('welcome_message'); // Loads
\ No newline at end of file diff --git a/user_guide_src/source/tutorial/news_section.rst b/user_guide_src/source/tutorial/news_section.rst index b64ea2aae..833e34ead 100644 --- a/user_guide_src/source/tutorial/news_section.rst +++ b/user_guide_src/source/tutorial/news_section.rst @@ -68,7 +68,7 @@ following code to your model. $query = $this->db->get('news'); return $query->result_array(); } - + $query = $this->db->get_where('news', array('slug' => $slug)); return $query->row_array(); } @@ -146,7 +146,7 @@ and add the next piece of code. <?php foreach ($news as $news_item): ?> <h2><?php echo $news_item['title'] ?></h2> - <div id="main"> + <div class="main"> <?php echo $news_item['text'] ?> </div> <p><a href="<?php echo $news_item['slug'] ?>">View article</a></p> |