From f08548b2b88324c36729a7dd4d179a9e1076dc14 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 6 Sep 2011 17:40:17 -0400 Subject: Fixed int typecasting of limit parameter in DB_active_rec.php If an empty string was passed, the typecast was changing it to 0. This produced "LIMIT 0" which returned no results. This must be a bug and not a feature because there are other params after limit in both $this->db->limit and $this->db->get. --- system/database/DB_active_rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 841ede28e..a16363c68 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -874,7 +874,7 @@ class CI_DB_active_record extends CI_DB_driver { */ public function limit($value, $offset = '') { - $this->ar_limit = (int) $value; + $this->ar_limit = $value; if ($offset != '') { -- cgit v1.2.3-24-g4f1b From ceec45609be0ebc2319e9e21a25eb1642f4eef06 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Fri, 24 Feb 2012 09:25:49 -0500 Subject: fixed active record inconsistency. --- system/database/DB_active_rec.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 429f65186..424735157 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -988,7 +988,7 @@ class CI_DB_active_record extends CI_DB_driver { */ public function limit($value, $offset = NULL) { - $this->ar_limit = $value; + $this->ar_limit = (int) $value; if ( ! is_null($offset)) { -- cgit v1.2.3-24-g4f1b From 326a5e75db1e03e453f488f2d612b0f421806129 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Fri, 24 Feb 2012 10:06:28 -0500 Subject: added config process method checking for delimiter values, updated changelog and user guide. --- system/libraries/Form_validation.php | 24 ++++++++++++++++++++++ user_guide_src/source/changelog.rst | 1 + .../source/libraries/form_validation.rst | 8 +++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 0a6a2af0d..93ec8b34a 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -55,6 +55,9 @@ class CI_Form_validation { { $this->CI =& get_instance(); + // applies delimiters set in config file. + $this->_config_delimiters(); + // Validation rules can be stored in a config file. $this->_config_rules = $rules; @@ -69,6 +72,27 @@ class CI_Form_validation { log_message('debug', "Form Validation Class Initialized"); } + + // -------------------------------------------------------------------- + + /** + * if prefixes/suffixes set in config, assign and unset. + * + * @return void + */ + private function _config_delimiters() + { + if (isset($rules['error_prefix'])) + { + $this->_error_prefix = $rules['error_prefix']); + unset $rules['error_prefix']); + } + if (isset($rules['error_suffix'])) + { + $this->_error_suffix = $rules['error_suffix']); + unset $rules['error_suffix']); + } + } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index dc6b29516..3aa9d6573 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -72,6 +72,7 @@ Release Date: Not Released - Minor speed optimizations and method & property visibility declarations in the Calendar Library. - Removed SHA1 function in the :doc:`Encryption Library `. - Added $config['csrf_regeneration'] to the CSRF protection in the :doc:`Security library `, which makes token regeneration optional. + - Form Validation library now allows setting of error delimiters in the config file via $config['error_prefix'] and $config['error_suffix']. - Core diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index e7875bc22..1b3fa61d1 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 (

) 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. ', ''); ?> +#. **Set delimiters in a config file** + You can add your error delimiters in application/config/form_validation.php as follows:: + + $config['error_prefix'] = '

'; + $config['error_suffix'] = '

'; + Showing Errors Individually =========================== -- cgit v1.2.3-24-g4f1b From 571e41eee86494c45f09fc723849011ca5a4f45b Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Fri, 24 Feb 2012 10:10:07 -0500 Subject: fixed suffix documentation. --- user_guide_src/source/libraries/form_validation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 1b3fa61d1..36ad85dd2 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -547,7 +547,7 @@ globally, individually, or change the defaults in a config file. You can add your error delimiters in application/config/form_validation.php as follows:: $config['error_prefix'] = '

'; - $config['error_suffix'] = '

'; + $config['error_suffix'] = '

'; Showing Errors Individually -- cgit v1.2.3-24-g4f1b From 840a89396dbd67b7be5539bf2e9ce94274795ad8 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Fri, 24 Feb 2012 10:11:37 -0500 Subject: updated documentation to differentiate prefix and suffix more. --- user_guide_src/source/libraries/form_validation.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 36ad85dd2..b70fc44d0 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -546,8 +546,8 @@ globally, individually, or change the defaults in a config file. #. **Set delimiters in a config file** You can add your error delimiters in application/config/form_validation.php as follows:: - $config['error_prefix'] = '

'; - $config['error_suffix'] = '

'; + $config['error_prefix'] = '
'; + $config['error_suffix'] = '
'; Showing Errors Individually -- cgit v1.2.3-24-g4f1b From 1ccdb9a8e3a34153d3c9a1075b44e84dd39aa25c Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 28 Feb 2012 13:32:19 -0500 Subject: changed _config_delimiters() to protected. --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 93ec8b34a..25ccb4c69 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -80,7 +80,7 @@ class CI_Form_validation { * * @return void */ - private function _config_delimiters() + protected function _config_delimiters() { if (isset($rules['error_prefix'])) { -- cgit v1.2.3-24-g4f1b From 9af3337175b82c66e7f43d2ad782e2e1d79dac5e Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 28 Feb 2012 13:37:56 -0500 Subject: fixed some mismatched brackets. --- system/libraries/Form_validation.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 25ccb4c69..bfe64fac9 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -84,13 +84,13 @@ class CI_Form_validation { { if (isset($rules['error_prefix'])) { - $this->_error_prefix = $rules['error_prefix']); - unset $rules['error_prefix']); + $this->_error_prefix = $rules['error_prefix']; + unset($rules['error_prefix']); } if (isset($rules['error_suffix'])) { - $this->_error_suffix = $rules['error_suffix']); - unset $rules['error_suffix']); + $this->_error_suffix = $rules['error_suffix']; + unset($rules['error_suffix']); } } -- cgit v1.2.3-24-g4f1b From a90b1f2f89a41b2fe061f5fdd3f84f08b961a887 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Tue, 28 Feb 2012 13:44:19 -0500 Subject: tab separator in _config_delimiters dockblock. --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index bfe64fac9..79414656f 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -78,7 +78,7 @@ class CI_Form_validation { /** * if prefixes/suffixes set in config, assign and unset. * - * @return void + * @return void */ protected function _config_delimiters() { -- cgit v1.2.3-24-g4f1b From fd15423734b23ce1f10a24b6fc57f6b16a3b361b Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Wed, 7 Mar 2012 19:58:58 -0500 Subject: Fixed bug with rules not being passed to _config_delimiters or back into $this->_config_rules. --- system/libraries/Form_validation.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index f2f3712d9..f3535b225 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -54,7 +54,7 @@ class CI_Form_validation { $this->CI =& get_instance(); // applies delimiters set in config file. - $this->_config_delimiters(); + $rules = $this->_config_delimiters($rules); // Validation rules can be stored in a config file. $this->_config_rules = $rules; @@ -76,9 +76,10 @@ class CI_Form_validation { /** * if prefixes/suffixes set in config, assign and unset. * - * @return void + * @param array + * @return array */ - protected function _config_delimiters() + protected function _config_delimiters($rules) { if (isset($rules['error_prefix'])) { @@ -90,6 +91,7 @@ class CI_Form_validation { $this->_error_suffix = $rules['error_suffix']; unset($rules['error_suffix']); } + return $rules; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 7f42d060fb828bfb0bd857ad1a17b91070e52628 Mon Sep 17 00:00:00 2001 From: Mike Funk Date: Thu, 8 Mar 2012 09:00:57 -0500 Subject: moved delimiter assigning to constructor, removed extra function. --- system/libraries/Form_validation.php | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index f3535b225..3e16d69ed 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -54,7 +54,16 @@ class CI_Form_validation { $this->CI =& get_instance(); // applies delimiters set in config file. - $rules = $this->_config_delimiters($rules); + if (isset($rules['error_prefix'])) + { + $this->_error_prefix = $rules['error_prefix']; + unset($rules['error_prefix']); + } + if (isset($rules['error_suffix'])) + { + $this->_error_suffix = $rules['error_suffix']; + unset($rules['error_suffix']); + } // Validation rules can be stored in a config file. $this->_config_rules = $rules; @@ -70,29 +79,6 @@ class CI_Form_validation { log_message('debug', "Form Validation Class Initialized"); } - - // -------------------------------------------------------------------- - - /** - * if prefixes/suffixes set in config, assign and unset. - * - * @param array - * @return array - */ - protected function _config_delimiters($rules) - { - if (isset($rules['error_prefix'])) - { - $this->_error_prefix = $rules['error_prefix']; - unset($rules['error_prefix']); - } - if (isset($rules['error_suffix'])) - { - $this->_error_suffix = $rules['error_suffix']; - unset($rules['error_suffix']); - } - return $rules; - } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b