diff options
Diffstat (limited to 'user_guide_src/source')
-rw-r--r-- | user_guide_src/source/_themes/eldocs/static/asset/css/common.css | 2 | ||||
-rw-r--r-- | user_guide_src/source/changelog.rst | 26 | ||||
-rw-r--r-- | user_guide_src/source/database/active_record.rst | 10 | ||||
-rw-r--r-- | user_guide_src/source/database/results.rst | 9 | ||||
-rw-r--r-- | user_guide_src/source/general/creating_libraries.rst | 16 | ||||
-rw-r--r-- | user_guide_src/source/general/requirements.rst | 6 | ||||
-rw-r--r-- | user_guide_src/source/helpers/form_helper.rst | 265 | ||||
-rw-r--r-- | user_guide_src/source/helpers/path_helper.rst | 20 | ||||
-rw-r--r-- | user_guide_src/source/installation/upgrade_200.rst | 2 | ||||
-rw-r--r-- | user_guide_src/source/libraries/form_validation.rst | 99 | ||||
-rw-r--r-- | user_guide_src/source/libraries/input.rst | 16 | ||||
-rw-r--r-- | user_guide_src/source/libraries/table.rst | 2 |
12 files changed, 293 insertions, 180 deletions
diff --git a/user_guide_src/source/_themes/eldocs/static/asset/css/common.css b/user_guide_src/source/_themes/eldocs/static/asset/css/common.css index b9e28aec0..66768bac6 100644 --- a/user_guide_src/source/_themes/eldocs/static/asset/css/common.css +++ b/user_guide_src/source/_themes/eldocs/static/asset/css/common.css @@ -2,7 +2,7 @@ CodeIgniter http://codeigniter.com -An open source application development framework for PHP 5.1.6 or newer +An open source application development framework for PHP 5.2.4 or newer NOTICE OF LICENSE diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index e96076164..e679d4a40 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -19,6 +19,7 @@ Release Date: Not Released - General Changes + - PHP 5.1.6 is no longer supported. CodeIgniter now requires PHP 5.2.4. - Added an optional backtrace to php-error template. - Added Android to the list of user agents. - Added Windows 7 to the list of user platforms. @@ -42,6 +43,9 @@ Release Date: Not Released - Changed humanize to include a second param for the separator. - Refactored ``plural()`` and ``singular()`` to avoid double pluralization and support more words. - Added an optional third parameter to ``force_download()`` that enables/disables sending the actual file MIME type in the Content-Type header (disabled by default). + - Added a work-around in force_download() for a bug Android <= 2.1, where the filename extension needs to be in uppercase. + - form_dropdown() will now also take an array for unity with other form helpers. + - set_realpath() can now also handle file paths as opposed to just directories. - Database @@ -62,12 +66,16 @@ Release Date: Not Released - pg_version() is now used to get the database version number, when possible. - Added db_set_charset() support. - Added _optimize_table() support for the :doc:`Database Utility Class <database/utilities>` (rebuilds table indexes). + - Added a constructor to the DB_result class and moved all driver-specific properties and logic out of the base DB_driver class to allow better abstraction. + - Removed limit() and order_by() support for UPDATE and DELETE queries in PostgreSQL driver. Postgres does not support those features. + - Removed protect_identifiers() and renamed _protect_identifiers() to it instead - it was just an alias. + - MySQL and MySQLi drivers now require at least MySQL version 5.1. + - db_set_charset() now only requires one parameter (collation was only needed due to legacy support for MySQL versions prior to 5.1). - Libraries - Added max_filename_increment config setting for Upload library. - CI_Loader::_ci_autoloader() is now a protected method. - - Modified valid_ip() to use PHP's filter_var() when possible (>= PHP 5.2) in the :doc:`Form Validation library <libraries/form_validation>`. - Added custom filename to Email::attach() as $this->email->attach($filename, $disposition, $newname) - Cart library changes include: - It now auto-increments quantity's instead of just resetting it, this is the default behaviour of large e-commerce sites. @@ -82,9 +90,13 @@ Release Date: Not Released - Minor speed optimizations and method & property visibility declarations in the Calendar Library. - Removed SHA1 function in the :doc:`Encryption Library <libraries/encryption>`. - Added $config['csrf_regeneration'] to the CSRF protection in the :doc:`Security library <libraries/security>`, which makes token regeneration optional. + - Allowed for setting table class defaults in a config file. + - Form Validation library now allows setting of error delimiters in the config file via $config['error_prefix'] and $config['error_suffix']. - Added function error_array() to return all error messages as an array in the Form_validation class. - Added function set_data() to Form_validation library, which can be used in place of the default $_POST array. + - Added function reset_validation() to form validation library, which resets internal validation variables in case of multiple validation routines. - Changed the Session library to select only one row when using database sessions. + - Added a Wincache driver to the `Caching Library <libraries/caching>`. - Core @@ -92,6 +104,9 @@ Release Date: Not Released - Removed CI_CORE boolean constant from CodeIgniter.php (no longer Reactor and Core versions). - Added method get_vars() to CI_Loader to retrieve all variables loaded with $this->load->vars(). - is_loaded() function from system/core/Commons.php now returns a reference. + - $config['rewrite_short_tags'] now has no effect when using PHP 5.4 as *<?=* will always be available. + - Added method() to CI_Input to retrieve $_SERVER['REQUEST_METHOD']. + - Modified valid_ip() to use PHP's filter_var() in the :doc:`Input Library <libraries/input>`. Bug fixes for 3.0 ------------------ @@ -130,12 +145,19 @@ Bug fixes for 3.0 - Fixed a bug in PDO's _version() method where it used to return the client version as opposed to the server one. - Fixed a bug in PDO's insert_id() method where it could've failed if it's used with Postgre versions prior to 8.1. - Fixed a bug in CUBRID's affected_rows() method where a connection resource was passed to cubrid_affected_rows() instead of a result. -- Fixed a bug (#638) - db_set_charset() ignored its arguments and always used the configured charset and collation instead. +- Fixed a bug (#638) - db_set_charset() ignored its arguments and always used the configured charset instead. - Fixed a bug (#413) - Oracle's error handling methods used to only return connection-related errors. - Fixed a bug (#804) - Profiler library was trying to handle objects as strings in some cases, resulting in warnings being issued by htmlspecialchars(). - Fixed a bug (#1101) - MySQL/MySQLi result method field_data() was implemented as if it was handling a DESCRIBE result instead of the actual result set. - Fixed a bug in Oracle's :doc:`Database Forge Class <database/forge>` method _create_table() where it failed with AUTO_INCREMENT as it's not supported. - Fixed a bug (#1080) - When using the SMTP protocol, the :doc:`Email Library <libraries/email>` send() method was returning TRUE even if the connection/authentication against the server failed. +- Fixed a bug (#499) - a CSRF cookie was created even with CSRF protection being disabled. +- Fixed a bug (#306) - ODBC's insert_id() method was calling non-existent function odbc_insert_id(), which resulted in a fatal error. +- Fixed a bug in Oracle's DB_result class where the cursor id passed to it was always NULL. +- Fixed a bug (#64) - Regular expression in DB_active_rec.php failed to handle queries containing SQL bracket delimiters in the join condition. +- Fixed a bug in the :doc:`Session Library <libraries/sessions>` where a PHP E_NOTICE error was triggered by _unserialize() due to results from databases such as MSSQL and Oracle being space-padded on the right. +- Fixed a bug (#501) - set_rules() to check if the request method is not 'POST' before aborting, instead of depending on count($_POST) in the :doc:`Form Validation Library <libraries/form_validation>`. +- Fixed a bug (#940) - csrf_verify() used to set the CSRF cookie while processing a POST request with no actual POST data, which resulted in validating a request that should be considered invalid. Version 2.1.1 ============= diff --git a/user_guide_src/source/database/active_record.rst b/user_guide_src/source/database/active_record.rst index c04e67d2a..e328c11e2 100644 --- a/user_guide_src/source/database/active_record.rst +++ b/user_guide_src/source/database/active_record.rst @@ -68,7 +68,7 @@ Example:: // Produces string: SELECT * FROM mytable The second parameter enables you to set whether or not the active record query -will be reset (by default it will be—just like `$this->db->get()`):: +will be reset (by default it will be just like `$this->db->get()`):: echo $this->db->limit(10,20)->get_compiled_select('mytable', FALSE); // Produces string: SELECT * FROM mytable LIMIT 20, 10 @@ -533,7 +533,7 @@ Query grouping ************** Query grouping allows you to create groups of WHERE clauses by enclosing them in parentheses. This will allow -you to create queries with complex WHERE clauses. Nested groups are supported. Example: +you to create queries with complex WHERE clauses. Nested groups are supported. Example:: $this->db->select('*')->from('my_table') ->group_start() @@ -921,9 +921,9 @@ Method chaining allows you to simplify your syntax by connecting multiple functions. Consider this example:: $query = $this->db->select('title') - ->where('id', $id) - ->limit(10, 20) - ->get('mytable'); + ->where('id', $id) + ->limit(10, 20) + ->get('mytable'); .. _ar-caching: diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst index 4f93c794d..865345762 100644 --- a/user_guide_src/source/database/results.rst +++ b/user_guide_src/source/database/results.rst @@ -150,6 +150,12 @@ is the variable that the query result object is assigned to:: echo $query->num_rows(); +.. note:: + Not all database drivers have a native way of getting the total + number of rows for a result set. When this is the case, all of + the data is prefetched and count() is manually called on the + resulting array in order to achieve the same functionality. + $query->num_fields() ===================== @@ -182,5 +188,4 @@ Example:: $row = $query2->row(); echo $row->name; - $query2->free_result();// The $query2 result object will no longer be available - + $query2->free_result(); // The $query2 result object will no longer be available diff --git a/user_guide_src/source/general/creating_libraries.rst b/user_guide_src/source/general/creating_libraries.rst index bc545b483..673fbd4bb 100644 --- a/user_guide_src/source/general/creating_libraries.rst +++ b/user_guide_src/source/general/creating_libraries.rst @@ -188,17 +188,23 @@ application/libraries/MY_Email.php, and declare your class with:: } -Note: If you need to use a constructor in your class make sure you +If you need to use a constructor in your class make sure you extend the parent constructor:: class MY_Email extends CI_Email { - public function __construct() - { - parent::__construct(); - } + public function __construct($config = array()) + { + parent::__construct($config); + } + } +.. note:: + Not all of the libraries have the same (or any) parameters + in their constructor. Take a look at the library that you're + extending first to see how it should be implemented. + Loading Your Sub-class ---------------------- diff --git a/user_guide_src/source/general/requirements.rst b/user_guide_src/source/general/requirements.rst index 38623557d..05e87961a 100644 --- a/user_guide_src/source/general/requirements.rst +++ b/user_guide_src/source/general/requirements.rst @@ -2,7 +2,7 @@ Server Requirements ################### -- `PHP <http://www.php.net/>`_ version 5.1.6 or newer. +- `PHP <http://www.php.net/>`_ version 5.2.4 or newer. - A Database is required for most web application programming. Current - supported databases are MySQL (4.1+), MySQLi, MS SQL, Postgres, Oracle, - SQLite, ODBC and CUBRID.
\ No newline at end of file + supported databases are MySQL (5.1+), MySQLi, MS SQL, SQLSRV, Oracle, + PostgreSQL, SQLite, CUBRID, Interbase, ODBC and PDO. diff --git a/user_guide_src/source/helpers/form_helper.rst b/user_guide_src/source/helpers/form_helper.rst index 3794e0835..4cb0cfd38 100644 --- a/user_guide_src/source/helpers/form_helper.rst +++ b/user_guide_src/source/helpers/form_helper.rst @@ -45,7 +45,7 @@ parameter, like this :: - $attributes = array('class' => 'email', 'id' => 'myform'); + $attributes = array('class' => 'email', 'id' => 'myform'); echo form_open('email/send', $attributes); The above example would create a form similar to this @@ -61,15 +61,15 @@ Hidden fields can be added by passing an associative array to the third paramete :: - $hidden = array('username' => 'Joe', 'member_id' => '234'); + $hidden = array('username' => 'Joe', 'member_id' => '234'); echo form_open('email/send', '', $hidden); The above example would create a form similar to this :: - <form method="post" accept-charset="utf-8" action="http://example.com/index.php/email/send"> - <input type="hidden" name="username" value="Joe" /> + <form method="post" accept-charset="utf-8" action="http://example.com/index.php/email/send"> + <input type="hidden" name="username" value="Joe" /> <input type="hidden" name="member_id" value="234" /> form_open_multipart() @@ -87,28 +87,67 @@ name/value string to create one field :: - form_hidden('username', 'johndoe'); + form_hidden('username', 'johndoe'); // Would produce: <input type="hidden" name="username" value="johndoe" /> Or you can submit an associative array to create multiple fields :: - $data = array( - 'name' => 'John Doe', - 'email' => 'john@example.com', - 'url' => 'http://example.com' - ); - - echo form_hidden($data); - + $data = array( + 'name' => 'John Doe', + 'email' => 'john@example.com', + 'url' => 'http://example.com' + ); + + echo form_hidden($data); + /* - Would produce: - <input type="hidden" name="name" value="John Doe" /> - <input type="hidden" name="email" value="john@example.com" /> + Would produce: + <input type="hidden" name="name" value="John Doe" /> + <input type="hidden" name="email" value="john@example.com" /> <input type="hidden" name="url" value="http://example.com" /> */ +Or pass an associative array to the value field. + +:: + + $data = array( + 'name' => 'John Doe', + 'email' => 'john@example.com', + 'url' => 'http://example.com' + ); + + echo form_hidden('my_array', $data); + + /* + Would produce: + <input type="hidden" name="my_array[name]" value="John Doe" /> + <input type="hidden" name="my_array[email]" value="john@example.com" /> + <input type="hidden" name="my_array[url]" value="http://example.com" /> + */ + +If you want to create hidden input fields with extra attributes + +:: + + $data = array( + 'type' => 'hidden', + 'name' => 'email', + 'id' => 'hiddenemail', + 'value' => 'john@example.com', + 'class' => 'hiddenemail' + ); + + echo form_input($data); + + /* + Would produce: + + <input type="hidden" name="email" value="john@example.com" id="hiddenemail" class="hiddenemail" /> + */ + form_input() ============ @@ -124,20 +163,20 @@ form to contain :: - $data = array( - 'name' => 'username', - 'id' => 'username', - 'value' => 'johndoe', - 'maxlength' => '100', - 'size' => '50', - 'style' => 'width:50%', - ); - + $data = array( + 'name' => 'username', + 'id' => 'username', + 'value' => 'johndoe', + 'maxlength' => '100', + 'size' => '50', + 'style' => 'width:50%' + ); + echo form_input($data); - + /* Would produce: - + <input type="text" name="username" id="username" value="johndoe" maxlength="100" size="50" style="width:50%" /> */ @@ -146,7 +185,7 @@ Javascript, you can pass it as a string in the third parameter :: - $js = 'onClick="some_function()"'; + $js = 'onClick="some_function()"'; echo form_input('username', 'johndoe', $js); form_password() @@ -176,37 +215,37 @@ multiple select for you. Example :: - $options = array( - 'small' => 'Small Shirt', - 'med' => 'Medium Shirt', - 'large' => 'Large Shirt', - 'xlarge' => 'Extra Large Shirt', - ); - - $shirts_on_sale = array('small', 'large'); - echo form_dropdown('shirts', $options, 'large'); - + $options = array( + 'small' => 'Small Shirt', + 'med' => 'Medium Shirt', + 'large' => 'Large Shirt', + 'xlarge' => 'Extra Large Shirt', + ); + + $shirts_on_sale = array('small', 'large'); + echo form_dropdown('shirts', $options, 'large'); + /* - Would produce: - - <select name="shirts"> - <option value="small">Small Shirt</option> - <option value="med">Medium Shirt</option> - <option value="large" selected="selected">Large Shirt</option> - <option value="xlarge">Extra Large Shirt</option> + Would produce: + + <select name="shirts"> + <option value="small">Small Shirt</option> + <option value="med">Medium Shirt</option> + <option value="large" selected="selected">Large Shirt</option> + <option value="xlarge">Extra Large Shirt</option> </select> */ - + echo form_dropdown('shirts', $options, $shirts_on_sale); - + /* - Would produce: - - <select name="shirts" multiple="multiple"> - <option value="small" selected="selected">Small Shirt</option> - <option value="med">Medium Shirt</option> - <option value="large" selected="selected">Large Shirt</option> - <option value="xlarge">Extra Large Shirt</option> + Would produce: + + <select name="shirts" multiple="multiple"> + <option value="small" selected="selected">Small Shirt</option> + <option value="med">Medium Shirt</option> + <option value="large" selected="selected">Large Shirt</option> + <option value="xlarge">Extra Large Shirt</option> </select> */ @@ -216,7 +255,7 @@ parameter :: - $js = 'id="shirts" onChange="some_function();"'; + $js = 'id="shirts" onChange="some_function();"'; echo form_dropdown('shirts', $options, 'large', $js); If the array passed as $options is a multidimensional array, @@ -240,38 +279,38 @@ Lets you generate fieldset/legend fields. :: - echo form_fieldset('Address Information'); - echo "<p>fieldset content here</p>\n"; + echo form_fieldset('Address Information'); + echo "<p>fieldset content here</p>\n"; echo form_fieldset_close(); - + /* Produces: - <fieldset> - <legend>Address Information</legend> - <p>form content here</p> + <fieldset> + <legend>Address Information</legend> + <p>form content here</p> </fieldset> */ - + Similar to other functions, you can submit an associative array in the second parameter if you prefer to set additional attributes. :: $attributes = array( - 'id' => 'address_info', + 'id' => 'address_info', 'class' => 'address_info' - ); - - echo form_fieldset('Address Information', $attributes); - echo "<p>fieldset content here</p>\n"; - echo form_fieldset_close(); - + ); + + echo form_fieldset('Address Information', $attributes); + echo "<p>fieldset content here</p>\n"; + echo form_fieldset_close(); + /* - Produces: - - <fieldset id="address_info" class="address_info"> - <legend>Address Information</legend> - <p>form content here</p> + Produces: + + <fieldset id="address_info" class="address_info"> + <legend>Address Information</legend> + <p>form content here</p> </fieldset> */ @@ -284,8 +323,8 @@ the tag. For example :: - $string = "</div></div>"; - echo form_fieldset_close($string); + $string = "</div></div>"; + echo form_fieldset_close($string); // Would produce: </fieldset> </div></div> form_checkbox() @@ -295,7 +334,7 @@ Lets you generate a checkbox field. Simple example :: - echo form_checkbox('newsletter', 'accept', TRUE); + echo form_checkbox('newsletter', 'accept', TRUE); // Would produce: <input type="checkbox" name="newsletter" value="accept" checked="checked" /> The third parameter contains a boolean TRUE/FALSE to determine whether @@ -306,15 +345,15 @@ array of attributes to the function :: - $data = array( - 'name' => 'newsletter', - 'id' => 'newsletter', - 'value' => 'accept', - 'checked' => TRUE, - 'style' => 'margin:10px', - ); - - echo form_checkbox($data); + $data = array( + 'name' => 'newsletter', + 'id' => 'newsletter', + 'value' => 'accept', + 'checked' => TRUE, + 'style' => 'margin:10px', + ); + + echo form_checkbox($data); // Would produce: <input type="checkbox" name="newsletter" id="newsletter" value="accept" checked="checked" style="margin:10px" /> As with other functions, if you would like the tag to contain additional @@ -323,7 +362,7 @@ parameter :: - $js = 'onClick="some_function()"'; + $js = 'onClick="some_function()"'; echo form_checkbox('newsletter', 'accept', TRUE, $js) form_radio() @@ -339,7 +378,7 @@ Lets you generate a standard submit button. Simple example :: - echo form_submit('mysubmit', 'Submit Post!'); + echo form_submit('mysubmit', 'Submit Post!'); // Would produce: <input type="submit" name="mysubmit" value="Submit Post!" /> Similar to other functions, you can submit an associative array in the @@ -353,7 +392,7 @@ Lets you generate a <label>. Simple example :: - echo form_label('What is your Name', 'username'); + echo form_label('What is your Name', 'username'); // Would produce: <label for="username">What is your Name</label> Similar to other functions, you can submit an associative array in the @@ -361,12 +400,12 @@ third parameter if you prefer to set additional attributes. :: - $attributes = array( - 'class' => 'mycustomclass', + $attributes = array( + 'class' => 'mycustomclass', 'style' => 'color: #000;' - ); - - echo form_label('What is your Name', 'username', $attributes); + ); + + echo form_label('What is your Name', 'username', $attributes); // Would produce: <label for="username" class="mycustomclass" style="color: #000;">What is your Name</label> @@ -384,7 +423,7 @@ button name and content in the first and second parameter :: - echo form_button('name','content'); + echo form_button('name','content'); // Would produce <button name="name" type="button">Content</button> Or you can pass an associative array containing any data you wish your @@ -392,15 +431,15 @@ form to contain: :: - $data = array( - 'name' => 'button', - 'id' => 'button', - 'value' => 'true', - 'type' => 'reset', - 'content' => 'Reset' - ); - - echo form_button($data); + $data = array( + 'name' => 'button', + 'id' => 'button', + 'value' => 'true', + 'type' => 'reset', + 'content' => 'Reset' + ); + + echo form_button($data); // Would produce: <button name="button" id="button" value="true" type="reset">Reset</button> If you would like your form to contain some additional data, like @@ -408,7 +447,7 @@ JavaScript, you can pass it as a string in the third parameter: :: - $js = 'onClick="some_function()"'; + $js = 'onClick="some_function()"'; echo form_button('mybutton', 'Click Me', $js); form_close() @@ -420,8 +459,8 @@ the tag. For example :: - $string = "</div></div>"; - echo form_close($string); + $string = "</div></div>"; + echo form_close($string); // Would produce: </form> </div></div> form_prep() @@ -432,7 +471,7 @@ elements without breaking out of the form. Consider this example :: - $string = 'Here is a string containing "quoted" text.'; + $string = 'Here is a string containing "quoted" text.'; <input type="text" name="myform" value="$string" /> Since the above string contains a set of quotes it will cause the form @@ -475,9 +514,9 @@ Example :: <select name="myselect"> - <option value="one" <?php echo set_select('myselect', 'one', TRUE); ?> >One</option> - <option value="two" <?php echo set_select('myselect', 'two'); ?> >Two</option> - <option value="three" <?php echo set_select('myselect', 'three'); ?> >Three</option> + <option value="one" <?php echo set_select('myselect', 'one', TRUE); ?> >One</option> + <option value="two" <?php echo set_select('myselect', 'two'); ?> >Two</option> + <option value="three" <?php echo set_select('myselect', 'three'); ?> >Three</option> </select> set_checkbox() @@ -490,7 +529,7 @@ lets you set an item as the default (use boolean TRUE/FALSE). Example :: - <input type="checkbox" name="mycheck" value="1" <?php echo set_checkbox('mycheck', '1'); ?> /> + <input type="checkbox" name="mycheck" value="1" <?php echo set_checkbox('mycheck', '1'); ?> /> <input type="checkbox" name="mycheck" value="2" <?php echo set_checkbox('mycheck', '2'); ?> /> set_radio() @@ -501,6 +540,6 @@ This function is identical to the **set_checkbox()** function above. :: - <input type="radio" name="myradio" value="1" <?php echo set_radio('myradio', '1', TRUE); ?> /> + <input type="radio" name="myradio" value="1" <?php echo set_radio('myradio', '1', TRUE); ?> /> <input type="radio" name="myradio" value="2" <?php echo set_radio('myradio', '2'); ?> /> diff --git a/user_guide_src/source/helpers/path_helper.rst b/user_guide_src/source/helpers/path_helper.rst index 1a70af458..847f5a08b 100644 --- a/user_guide_src/source/helpers/path_helper.rst +++ b/user_guide_src/source/helpers/path_helper.rst @@ -28,10 +28,16 @@ cannot be resolved. :: - $directory = '/etc/passwd'; - echo set_realpath($directory); // returns "/etc/passwd" - $non_existent_directory = '/path/to/nowhere'; - echo set_realpath($non_existent_directory, TRUE); // returns an error, as the path could not be resolved - echo set_realpath($non_existent_directory, FALSE); // returns "/path/to/nowhere" - - + $file = '/etc/php5/apache2/php.ini'; + echo set_realpath($file); // returns "/etc/php5/apache2/php.ini" + + $non_existent_file = '/path/to/non-exist-file.txt'; + echo set_realpath($non_existent_file, TRUE); // shows an error, as the path cannot be resolved + echo set_realpath($non_existent_file, FALSE); // returns "/path/to/non-exist-file.txt" + + $directory = '/etc/php5'; + echo set_realpath($directory); // returns "/etc/php5/" + + $non_existent_directory = '/path/to/nowhere'; + echo set_realpath($non_existent_directory, TRUE); // shows an error, as the path cannot be resolved + echo set_realpath($non_existent_directory, FALSE); // returns "/path/to/nowhere" diff --git a/user_guide_src/source/installation/upgrade_200.rst b/user_guide_src/source/installation/upgrade_200.rst index 0bcbd5c99..b39f4fd23 100644 --- a/user_guide_src/source/installation/upgrade_200.rst +++ b/user_guide_src/source/installation/upgrade_200.rst @@ -102,7 +102,7 @@ Please refer to the :ref:`2.0.0 Change Log <2.0.0-changelog>` for full details, but here are some of the larger changes that are more likely to impact your code: -- CodeIgniter now requires PHP 5.1.6. +- CodeIgniter now requires PHP 5.2.4. - Scaffolding has been removed. - The CAPTCHA plugin in now a :doc:`helper </helpers/captcha_helper>`. - The JavaScript calendar plugin was removed. diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 2fe315dba..5d7368ccb 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -523,7 +523,7 @@ Changing the Error Delimiters By default, the Form Validation class adds a paragraph tag (<p>) around each error message shown. You can either change these delimiters -globally or individually. +globally, individually, or change the defaults in a config file. #. **Changing delimiters Globally** To globally change the error delimiters, in your controller function, @@ -543,6 +543,12 @@ globally or individually. <?php echo validation_errors('<div class="error">', '</div>'); ?> +#. **Set delimiters in a config file** + You can add your error delimiters in application/config/form_validation.php as follows:: + + $config['error_prefix'] = '<div class="error_prefix">'; + $config['error_suffix'] = '</div>'; + Showing Errors Individually =========================== @@ -579,24 +585,27 @@ must supply it as an array to the function. Example:: For more info please see the :ref:`using-arrays-as-field-names` section below. -Validating An Array (Other Than The $_POST Array) -================================================= +Validating an Array (other than $_POST) +======================================= 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' - )); + $data = array( + 'username' => 'johndoe', + 'password' => 'mypassword', + 'passconf' => 'mypassword' + ); - $this->form_validation->set_data($data); + $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. +**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. + For more info please see the :ref:`function-reference` section below. -.. _saving-groups: @@ -843,34 +852,40 @@ Rule Reference The following is a list of all the native rules that are available to use: -======================= ========== ============================================================================================= ======================= -Rule Parameter Description Example -======================= ========== ============================================================================================= ======================= -**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] -**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 the parameter value or not numeric. greater_than[8] -**less_than** Yes Returns FALSE if the form element is greater than the parameter value or not numeric. less_than[8] -**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_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. -**integer** No Returns FALSE if the form element contains anything other than an integer. -**decimal** Yes Returns FALSE if the form element is not exactly the parameter value. -**is_natural** No Returns FALSE if the form element contains anything other than a natural number: - 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. -**valid_base64** No Returns FALSE if the supplied string contains anything other than valid Base64 characters. -======================= ========== ============================================================================================= ======================= +========================= ========== ============================================================================================= ======================= +Rule Parameter Description Example +========================= ========== ============================================================================================= ======================= +**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] +**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] + numeric. +**greater_than_equal_to** Yes Returns FALSE if the form element is less than the parameter value, greater_than_equal_to[8] + or not numeric. +**less_than** Yes Returns FALSE if the form element is greater than or equal to the parameter value or less_than[8] + not numeric. +**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_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. +**integer** No Returns FALSE if the form element contains anything other than an integer. +**decimal** No Returns FALSE if the form element contains anything other than a decimal number. +**is_natural** No Returns FALSE if the form element contains anything other than a natural number: + 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. +**valid_base64** No Returns FALSE if the supplied string contains anything other than valid Base64 characters. +========================= ========== ============================================================================================= ======================= .. note:: These rules can also be called as discrete functions. For example:: @@ -960,6 +975,14 @@ $this->form_validation->set_data(); Permits you to set an array for validation, instead of using the default $_POST array. +$this->form_validation->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. + $this->form_validation->error_array(); ======================================== @@ -1049,4 +1072,4 @@ This function is identical to the **set_checkbox()** function above. :: <input type="radio" name="myradio" value="1" <?php echo set_radio('myradio', '1', TRUE); ?> /> - <input type="radio" name="myradio" value="2" <?php echo set_radio('myradio', '2'); ?> />
\ No newline at end of file + <input type="radio" name="myradio" value="2" <?php echo set_radio('myradio', '2'); ?> /> diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst index bcf117358..1f2ea650a 100644 --- a/user_guide_src/source/libraries/input.rst +++ b/user_guide_src/source/libraries/input.rst @@ -99,7 +99,7 @@ The function returns FALSE (boolean) if there are no items in the POST. :: - $this->input->post(NULL, TRUE); // returns all POST items with XSS filter + $this->input->post(NULL, TRUE); // returns all POST items with XSS filter $this->input->post(); // returns all POST items without XSS filter $this->input->get() @@ -119,9 +119,9 @@ The function returns FALSE (boolean) if there are no items in the GET. :: - $this->input->get(NULL, TRUE); // returns all GET items with XSS filter + $this->input->get(NULL, TRUE); // returns all GET items with XSS filter $this->input->get(); // returns all GET items without XSS filtering - + $this->input->get_post() ========================= @@ -298,3 +298,13 @@ see if PHP is being run on the command line. $this->input->is_cli_request() +$this->input->method(); +===================================== + +Returns the $_SERVER['REQUEST_METHOD'], optional set uppercase or lowercase (default lowercase). + +:: + + echo $this->input->method(TRUE); // Outputs: POST + echo $this->input->method(FALSE); // Outputs: post + echo $this->input->method(); // Outputs: post diff --git a/user_guide_src/source/libraries/table.rst b/user_guide_src/source/libraries/table.rst index 9bc3f3423..6a808abc2 100644 --- a/user_guide_src/source/libraries/table.rst +++ b/user_guide_src/source/libraries/table.rst @@ -116,6 +116,8 @@ example, only the table opening tag is being changed:: $tmpl = array ( 'table_open' => '<table border="1" cellpadding="2" cellspacing="1" class="mytable">' ); $this->table->set_template($tmpl); + +You can also set defaults for these in a config file. ****************** Function Reference |