From 133beafd1746b0f5fa06794fd183289d43defdbe Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 10 Mar 2011 16:38:32 +0000 Subject: Changed the logic for form_open() in Form helper. If no value is passed it will submit to the current URL. --- system/helpers/form_helper.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'system/helpers') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 758056b50..8ed520f5d 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -49,7 +49,10 @@ if ( ! function_exists('form_open')) $attributes = 'method="post"'; } - $action = ( strpos($action, '://') === FALSE) ? $CI->config->site_url($action) : $action; + if ($action && strpos($action, '://') === FALSE) + { + $CI->config->site_url($action); + } $form = '
Date: Fri, 11 Mar 2011 10:17:01 +0000 Subject: Fixed last commit, form helper will work fine for self-submissions and normal URLs. --- system/helpers/form_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 8ed520f5d..532309794 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -51,7 +51,7 @@ if ( ! function_exists('form_open')) if ($action && strpos($action, '://') === FALSE) { - $CI->config->site_url($action); + $action = $CI->config->site_url($action); } $form = ' Date: Fri, 11 Mar 2011 17:33:05 -0500 Subject: Changed the 'plural' function so that it doesn't ruin the captalization of your string. It also take into consideration acronyms which are all caps. --- system/helpers/inflector_helper.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index 4cd7486b4..3042202cb 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -82,18 +82,17 @@ if ( ! function_exists('plural')) { function plural($str, $force = FALSE) { - $str = strtolower(trim($str)); $end = substr($str, -1); - if ($end == 'y') + if (preg_match('/y/i',$end)) { // Y preceded by vowel => regular plural - $vowels = array('a', 'e', 'i', 'o', 'u'); + $vowels = array('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'); $str = in_array(substr($str, -2, 1), $vowels) ? $str.'s' : substr($str, 0, -1).'ies'; } - elseif ($end == 'h') + elseif (preg_match('/h/i',$end)) { - if (substr($str, -2) == 'ch' OR substr($str, -2) == 'sh') + if(preg_match('/^[c|s]h$/i',substr($str, -2))) { $str .= 'es'; } @@ -102,7 +101,7 @@ if ( ! function_exists('plural')) $str .= 's'; } } - elseif ($end == 's') + elseif (preg_match('/s/i',$end)) { if ($force == TRUE) { -- cgit v1.2.3-24-g4f1b From af376a2df84123549293af846f827ff4da30bf5e Mon Sep 17 00:00:00 2001 From: Kyle Farris Date: Fri, 11 Mar 2011 17:46:53 -0500 Subject: Forgot to trim the string first. --- system/helpers/inflector_helper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/helpers') diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index 3042202cb..e1cd66be0 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -81,7 +81,8 @@ if ( ! function_exists('singular')) if ( ! function_exists('plural')) { function plural($str, $force = FALSE) - { + { + $str = trim($str); $end = substr($str, -1); if (preg_match('/y/i',$end)) -- cgit v1.2.3-24-g4f1b From 2f620fe804ae5b7f4f20adc70ceaee1cf616a655 Mon Sep 17 00:00:00 2001 From: Kyle Farris Date: Fri, 11 Mar 2011 18:34:07 -0500 Subject: Fixed the capitalization "bug" in the singular function as well. --- system/helpers/inflector_helper.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index e1cd66be0..c7c113b8a 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -41,20 +41,22 @@ if ( ! function_exists('singular')) { function singular($str) { - $str = strtolower(trim($str)); + $str = trim($str); $end = substr($str, -3); - - if ($end == 'ies') + + $str = preg_replace('/(.*)?([s|c]h)es/i','$1$2',$str); + + if (strtolower($end) == 'ies') { - $str = substr($str, 0, strlen($str)-3).'y'; + $str = substr($str, 0, strlen($str)-3).(preg_match('/[a-z]/',$end) ? 'y' : 'Y'); } - elseif ($end == 'ses') + elseif (strtolower($end) == 'ses') { $str = substr($str, 0, strlen($str)-2); } else { - $end = substr($str, -1); + $end = strtolower(substr($str, -1)); if ($end == 's') { -- cgit v1.2.3-24-g4f1b From 0ea04149bbae0fdcde92b7362e7cbd76f0df3865 Mon Sep 17 00:00:00 2001 From: bubbafoley Date: Thu, 17 Mar 2011 14:55:41 -0500 Subject: load config files from environment specific locations in core classes, helpers and libraries --- system/helpers/download_helper.php | 9 ++++++++- system/helpers/file_helper.php | 11 ++++++++++- system/helpers/html_helper.php | 11 ++++++++++- system/helpers/smiley_helper.php | 13 ++++++++++--- system/helpers/text_helper.php | 11 +++++++++-- 5 files changed, 47 insertions(+), 8 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 6cecd0d11..a851e3c42 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -58,7 +58,14 @@ if ( ! function_exists('force_download')) $extension = end($x); // Load the mime types - @include(APPPATH.'config/mimes'.EXT); + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) + { + @include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT); + } + else + { + @include(APPPATH.'config/mimes'.EXT); + } // Set a default mime if we can't find it if ( ! isset($mimes[$extension])) diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index 9518e4843..fb074e027 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -352,7 +352,16 @@ if ( ! function_exists('get_mime_by_extension')) if ( ! is_array($mimes)) { - if ( ! require_once(APPPATH.'config/mimes.php')) + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) + { + @include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT); + } + else + { + @include(APPPATH.'config/mimes'.EXT); + } + + if ( ! is_array($mimes)) { return FALSE; } diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 68c6f5908..c94c88004 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -258,7 +258,16 @@ if ( ! function_exists('doctype')) if ( ! is_array($_doctypes)) { - if ( ! require_once(APPPATH.'config/doctypes.php')) + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT)) + { + @include(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT); + } + else + { + @include(APPPATH.'config/doctypes'.EXT); + } + + if ( ! is_array($_doctypes)) { return FALSE; } diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index 463881f58..6c901515d 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -229,13 +229,20 @@ if ( ! function_exists('_get_smiley_array')) { function _get_smiley_array() { - if ( ! file_exists(APPPATH.'config/smileys'.EXT)) + if ( ! file_exists(APPPATH.'config/smileys'.EXT) AND ! file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT)) { return FALSE; } - include(APPPATH.'config/smileys'.EXT); - + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT)) + { + include(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT); + } + else + { + include(APPPATH.'config/smileys'.EXT); + } + if ( ! isset($smileys) OR ! is_array($smileys)) { return FALSE; diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 96afd4cee..197bcb14e 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -366,12 +366,19 @@ if ( ! function_exists('convert_accented_characters')) { function convert_accented_characters($str) { - if ( ! file_exists(APPPATH.'config/foreign_chars'.EXT)) + if ( ! file_exists(APPPATH.'config/foreign_chars'.EXT) AND ! file_exists(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT)) { return $str; } - include APPPATH.'config/foreign_chars'.EXT; + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT)) + { + include APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT; + } + else + { + include APPPATH.'config/foreign_chars'.EXT; + } if ( ! isset($foreign_characters)) { -- cgit v1.2.3-24-g4f1b From 928083406322821a35a7d8a4205620c3854772a6 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Fri, 18 Mar 2011 09:02:37 -0400 Subject: Fixed coding to match standards from previous releases --- system/helpers/download_helper.php | 2 +- system/helpers/file_helper.php | 4 ++-- system/helpers/html_helper.php | 4 ++-- system/helpers/text_helper.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index a851e3c42..56e4c2a2f 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -60,7 +60,7 @@ if ( ! function_exists('force_download')) // Load the mime types if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) { - @include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT); + include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT); } else { diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index fb074e027..f4b48b484 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -354,13 +354,13 @@ if ( ! function_exists('get_mime_by_extension')) { if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) { - @include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT); + include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT); } else { @include(APPPATH.'config/mimes'.EXT); } - + if ( ! is_array($mimes)) { return FALSE; diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index c94c88004..15c15a919 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -260,13 +260,13 @@ if ( ! function_exists('doctype')) { if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT)) { - @include(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT); + include(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT); } else { @include(APPPATH.'config/doctypes'.EXT); } - + if ( ! is_array($_doctypes)) { return FALSE; diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 197bcb14e..99f521fb5 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -373,7 +373,7 @@ if ( ! function_exists('convert_accented_characters')) if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT)) { - include APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT; + include APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT; } else { -- cgit v1.2.3-24-g4f1b From fdd5b11b62f127901ddff2e5dc7923b063371070 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Mon, 21 Mar 2011 21:28:58 -0400 Subject: Fixed logic and removed the error supressing --- system/helpers/download_helper.php | 6 +++--- system/helpers/file_helper.php | 6 +++--- system/helpers/html_helper.php | 6 +++--- system/helpers/text_helper.php | 13 ++++--------- 4 files changed, 13 insertions(+), 18 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 56e4c2a2f..e537cdeca 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -58,13 +58,13 @@ if ( ! function_exists('force_download')) $extension = end($x); // Load the mime types - if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) + if (is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) { include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT); } - else + elseif (is_file(APPPATH.'config/mimes'.EXT)) { - @include(APPPATH.'config/mimes'.EXT); + include(APPPATH.'config/mimes'.EXT); } // Set a default mime if we can't find it diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index f4b48b484..7a35c3fa1 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -352,13 +352,13 @@ if ( ! function_exists('get_mime_by_extension')) if ( ! is_array($mimes)) { - if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) + if (is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) { include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT); } - else + elseif (is_file(APPPATH.'config/mimes'.EXT)) { - @include(APPPATH.'config/mimes'.EXT); + include(APPPATH.'config/mimes'.EXT); } if ( ! is_array($mimes)) diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 15c15a919..53fc899a3 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -258,13 +258,13 @@ if ( ! function_exists('doctype')) if ( ! is_array($_doctypes)) { - if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT)) + if (is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT)) { include(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT); } - else + elseif (is_file(APPPATH.'config/doctypes'.EXT)) { - @include(APPPATH.'config/doctypes'.EXT); + include(APPPATH.'config/doctypes'.EXT); } if ( ! is_array($_doctypes)) diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 99f521fb5..664408912 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -366,18 +366,13 @@ if ( ! function_exists('convert_accented_characters')) { function convert_accented_characters($str) { - if ( ! file_exists(APPPATH.'config/foreign_chars'.EXT) AND ! file_exists(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT)) + if (is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT)) { - return $str; + include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT); } - - if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT)) - { - include APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT; - } - else + elseif (is_file(APPPATH.'config/foreign_chars'.EXT)) { - include APPPATH.'config/foreign_chars'.EXT; + include(APPPATH.'config/foreign_chars'.EXT); } if ( ! isset($foreign_characters)) -- cgit v1.2.3-24-g4f1b From 9d0e61768acc8eb6adfd032cdc6fbeac4c024598 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Sat, 2 Apr 2011 12:43:55 +0100 Subject: Added is_cli_request() method to documentation for Input class. --- system/helpers/form_helper.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'system/helpers') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 532309794..8aa788c6c 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -49,11 +49,15 @@ if ( ! function_exists('form_open')) $attributes = 'method="post"'; } + // If an action is not a full URL then turn it into one if ($action && strpos($action, '://') === FALSE) { $action = $CI->config->site_url($action); } + // If no action is provided then set to the current url + $action OR $action = $CI->config->site_url($CI->uri->uri_string()); + $form = ' Date: Tue, 5 Apr 2011 14:58:04 -0400 Subject: Removing security loading calls. --- system/helpers/typography_helper.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php index 302bf45c5..19b4eec03 100644 --- a/system/helpers/typography_helper.php +++ b/system/helpers/typography_helper.php @@ -84,9 +84,8 @@ if ( ! function_exists('entity_decode')) { function entity_decode($str, $charset='UTF-8') { - $CI =& get_instance(); - $CI->load->library('security'); - return $CI->security->entity_decode($str, $charset); + global $SEC; + return $SEC->entity_decode($str, $charset); } } -- cgit v1.2.3-24-g4f1b From 6b488674368cf695a228e87e7d8e0f4f40fe4181 Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Tue, 5 Apr 2011 15:02:15 -0400 Subject: Removing dohash and deprecating CI_SHA --- system/helpers/security_helper.php | 34 +--------------------------------- 1 file changed, 1 insertion(+), 33 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index 61ebf46f9..678dac821 100644 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.php @@ -64,22 +64,6 @@ if ( ! function_exists('sanitize_filename')) // -------------------------------------------------------------------- -/** - * Hash encode a string - * - * This is simply an alias for do_hash() - * dohash() is now deprecated - */ -if ( ! function_exists('dohash')) -{ - function dohash($str, $type = 'sha1') - { - return do_hash($str, $type); - } -} - -// -------------------------------------------------------------------- - /** * Hash encode a string * @@ -93,23 +77,7 @@ if ( ! function_exists('do_hash')) { if ($type == 'sha1') { - if ( ! function_exists('sha1')) - { - if ( ! function_exists('mhash')) - { - require_once(BASEPATH.'libraries/Sha1'.EXT); - $SH = new CI_SHA; - return $SH->generate($str); - } - else - { - return bin2hex(mhash(MHASH_SHA1, $str)); - } - } - else - { - return sha1($str); - } + return sha1($str); } else { -- cgit v1.2.3-24-g4f1b From 05fa61144667c85b0463f7e8baa6af00aa195dc6 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 6 Apr 2011 22:57:43 +0100 Subject: Made Environment Support optional. Comment out or delete the constant to stop environment checks. --- system/helpers/download_helper.php | 2 +- system/helpers/file_helper.php | 2 +- system/helpers/html_helper.php | 2 +- system/helpers/smiley_helper.php | 15 +++++---------- system/helpers/text_helper.php | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index e537cdeca..f8073d238 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -58,7 +58,7 @@ if ( ! function_exists('force_download')) $extension = end($x); // Load the mime types - if (is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) { include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT); } diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index 7a35c3fa1..44344947e 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -352,7 +352,7 @@ if ( ! function_exists('get_mime_by_extension')) if ( ! is_array($mimes)) { - if (is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) { include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT); } diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 53fc899a3..c6103ab6f 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -258,7 +258,7 @@ if ( ! function_exists('doctype')) if ( ! is_array($_doctypes)) { - if (is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT)) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT)) { include(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT); } diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index 6c901515d..a2d1031b3 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -229,26 +229,21 @@ if ( ! function_exists('_get_smiley_array')) { function _get_smiley_array() { - if ( ! file_exists(APPPATH.'config/smileys'.EXT) AND ! file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT)) - { - return FALSE; - } - - if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT)) + if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT)) { include(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT); } - else + elseif (file_exists(APPPATH.'config/smileys'.EXT)) { include(APPPATH.'config/smileys'.EXT); } - if ( ! isset($smileys) OR ! is_array($smileys)) + if (isset($smileys) AND is_array($smileys)) { - return FALSE; + return $smileys; } - return $smileys; + return FALSE; } } diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 664408912..cca093976 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -366,7 +366,7 @@ if ( ! function_exists('convert_accented_characters')) { function convert_accented_characters($str) { - if (is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT)) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT)) { include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT); } -- cgit v1.2.3-24-g4f1b From 1f6f0abf0d17046a99fd9c9b3c60fb459b4531b1 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Thu, 7 Apr 2011 18:24:53 -0500 Subject: Fixing a bug in the form_helper where csrf_token_name and csrf_hash were referencing class properties in the Security class that were moved. --- system/helpers/form_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 8aa788c6c..acd75c239 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -67,7 +67,7 @@ if ( ! function_exists('form_open')) // CSRF if ($CI->config->item('csrf_protection') === TRUE) { - $hidden[$CI->security->csrf_token_name] = $CI->security->csrf_hash; + $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash(); } if (is_array($hidden) AND count($hidden) > 0) -- cgit v1.2.3-24-g4f1b From 64e35cdcb9fd24787798c0f6ca3c0af45b0b904d Mon Sep 17 00:00:00 2001 From: patwork Date: Fri, 8 Apr 2011 15:25:31 +0200 Subject: There is absolutely no need to specify class name (it will validate anyway). --- system/helpers/form_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index acd75c239..bca0ff0c9 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -72,7 +72,7 @@ if ( ! function_exists('form_open')) if (is_array($hidden) AND count($hidden) > 0) { - $form .= sprintf("\n
%s
", form_hidden($hidden)); + $form .= sprintf("\n
%s
", form_hidden($hidden)); } return $form; @@ -1053,4 +1053,4 @@ if ( ! function_exists('_get_validation_object')) /* End of file form_helper.php */ -/* Location: ./system/helpers/form_helper.php */ \ No newline at end of file +/* Location: ./system/helpers/form_helper.php */ -- cgit v1.2.3-24-g4f1b From 826429cf40a9624788b92d2e6e4b7659e1b0d8a1 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Mon, 18 Apr 2011 09:40:19 -0500 Subject: Added an optional third parameter to heading() which allows adding html attributes to the rendered heading tag. --- system/helpers/html_helper.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index c6103ab6f..a29204391 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -40,9 +40,10 @@ */ if ( ! function_exists('heading')) { - function heading($data = '', $h = '1') + function heading($data = '', $h = '1', $attributes = '') { - return "".$data.""; + $attributes = ($attributes != '') ? ' '.$attributes : $attributes; + return "".$data.""; } } -- cgit v1.2.3-24-g4f1b From 3a746655e92ec59ee7e731c3535673a9aedc5d3e Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Tue, 19 Apr 2011 10:59:47 -0500 Subject: Removing internal references to the EXT constant. Additionally, marked the constant as deprecated. Use ".php" instead. Also adding upgrade notes from 2.0.2 to 2.0.3. --- system/helpers/download_helper.php | 8 ++++---- system/helpers/file_helper.php | 8 ++++---- system/helpers/html_helper.php | 8 ++++---- system/helpers/smiley_helper.php | 8 ++++---- system/helpers/text_helper.php | 8 ++++---- 5 files changed, 20 insertions(+), 20 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index f8073d238..1145688ae 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -58,13 +58,13 @@ if ( ! function_exists('force_download')) $extension = end($x); // Load the mime types - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) { - include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT); + include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); } - elseif (is_file(APPPATH.'config/mimes'.EXT)) + elseif (is_file(APPPATH.'config/mimes.php')) { - include(APPPATH.'config/mimes'.EXT); + include(APPPATH.'config/mimes.php'); } // Set a default mime if we can't find it diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index 44344947e..3931667fd 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -352,13 +352,13 @@ if ( ! function_exists('get_mime_by_extension')) if ( ! is_array($mimes)) { - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) { - include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT); + include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); } - elseif (is_file(APPPATH.'config/mimes'.EXT)) + elseif (is_file(APPPATH.'config/mimes.php')) { - include(APPPATH.'config/mimes'.EXT); + include(APPPATH.'config/mimes.php'); } if ( ! is_array($mimes)) diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index a29204391..080f622dd 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -259,13 +259,13 @@ if ( ! function_exists('doctype')) if ( ! is_array($_doctypes)) { - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT)) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php')) { - include(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT); + include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'); } - elseif (is_file(APPPATH.'config/doctypes'.EXT)) + elseif (is_file(APPPATH.'config/doctypes.php')) { - include(APPPATH.'config/doctypes'.EXT); + include(APPPATH.'config/doctypes.php'); } if ( ! is_array($_doctypes)) diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index a2d1031b3..6d8889354 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -229,13 +229,13 @@ if ( ! function_exists('_get_smiley_array')) { function _get_smiley_array() { - if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT)) + if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php')) { - include(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT); + include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'); } - elseif (file_exists(APPPATH.'config/smileys'.EXT)) + elseif (file_exists(APPPATH.'config/smileys.php')) { - include(APPPATH.'config/smileys'.EXT); + include(APPPATH.'config/smileys.php'); } if (isset($smileys) AND is_array($smileys)) diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index cca093976..33d7fa2fd 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -366,13 +366,13 @@ if ( ! function_exists('convert_accented_characters')) { function convert_accented_characters($str) { - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT)) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php')) { - include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT); + include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'); } - elseif (is_file(APPPATH.'config/foreign_chars'.EXT)) + elseif (is_file(APPPATH.'config/foreign_chars.php')) { - include(APPPATH.'config/foreign_chars'.EXT); + include(APPPATH.'config/foreign_chars.php'); } if ( ! isset($foreign_characters)) -- cgit v1.2.3-24-g4f1b From 9ce4385cfc976e309ee12c53726abfd4f066ac3f Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Tue, 19 Apr 2011 12:58:52 -0500 Subject: 1/2 reverting a previous change to the form_helper. Wrapping hidden form elements in
instead of an empty div. If a user is styling form div {} they can run into display issues, so something is needed. --- system/helpers/form_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index bca0ff0c9..a5cd97b82 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -72,7 +72,7 @@ if ( ! function_exists('form_open')) if (is_array($hidden) AND count($hidden) > 0) { - $form .= sprintf("\n
%s
", form_hidden($hidden)); + $form .= sprintf("
%s
", form_hidden($hidden)); } return $form; -- cgit v1.2.3-24-g4f1b From 0c9ee4a348a9e0c9ee6d6c0085e463e098e453f4 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Wed, 20 Apr 2011 09:40:17 -0500 Subject: Refactoring the loader to set protected class variables. Moved _ci_autoload(), which is used in CI_Controller to be a public method. Also added CI_Loader::set_base_classes() to be called in the controller so we're not setting protected vars in another class. Also refactored in the form_helper so it's not trying to access protected vars in CI_Loader. Added the is_loaded() method to the loader to take care of the checks that were being done there. --- system/helpers/form_helper.php | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index a5cd97b82..51a9c6ca3 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -1032,22 +1032,20 @@ if ( ! function_exists('_get_validation_object')) { $CI =& get_instance(); - // We set this as a variable since we're returning by reference + // We set this as a variable since we're returning by reference. $return = FALSE; - - if ( ! isset($CI->load->_ci_classes) OR ! isset($CI->load->_ci_classes['form_validation'])) - { - return $return; - } - - $object = $CI->load->_ci_classes['form_validation']; - - if ( ! isset($CI->$object) OR ! is_object($CI->$object)) + + if ( ! ($object = $CI->load->is_loaded('form_validation'))) { - return $return; + if ( ! isset($CI->$object) OR ! is_object($CI->$object)) + { + return $return; + } + + return $CI->$object; } - - return $CI->$object; + + return $return; } } -- cgit v1.2.3-24-g4f1b From c6d918ad24a8844e9de1e145f545bc9f2c7ca9a6 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Fri, 22 Apr 2011 10:17:32 -0500 Subject: Fix #233 Fixing a regression in _get_validation_object() in the form helper after some refactoring the other day. --- system/helpers/form_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 51a9c6ca3..16eb4b2c9 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -898,7 +898,7 @@ if ( ! function_exists('validation_errors')) function validation_errors($prefix = '', $suffix = '') { if (FALSE === ($OBJ =& _get_validation_object())) - { + {var_dump(_get_validation_object()); exit; return ''; } @@ -1035,7 +1035,7 @@ if ( ! function_exists('_get_validation_object')) // We set this as a variable since we're returning by reference. $return = FALSE; - if ( ! ($object = $CI->load->is_loaded('form_validation'))) + if (FALSE !== ($object = $CI->load->is_loaded('form_validation'))) { if ( ! isset($CI->$object) OR ! is_object($CI->$object)) { -- cgit v1.2.3-24-g4f1b From c83bea665eb3a441b6e52528f75fa4c71ca1f8c2 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sat, 23 Apr 2011 12:12:57 -0500 Subject: Removing debug code accidentally committed. --- system/helpers/form_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/helpers') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 16eb4b2c9..2925d3c7c 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -898,7 +898,7 @@ if ( ! function_exists('validation_errors')) function validation_errors($prefix = '', $suffix = '') { if (FALSE === ($OBJ =& _get_validation_object())) - {var_dump(_get_validation_object()); exit; + { return ''; } -- cgit v1.2.3-24-g4f1b From 114ab0988e20ac6be39ad363ff897a1a3b85e565 Mon Sep 17 00:00:00 2001 From: Razican Date: Mon, 25 Apr 2011 17:26:45 +0200 Subject: Fixed double-space typo. --- system/helpers/array_helper.php | 8 ++++---- system/helpers/captcha_helper.php | 20 ++++++++++---------- system/helpers/cookie_helper.php | 6 +++--- system/helpers/date_helper.php | 22 +++++++++++----------- system/helpers/directory_helper.php | 4 ++-- system/helpers/download_helper.php | 2 +- system/helpers/email_helper.php | 2 +- system/helpers/file_helper.php | 4 ++-- system/helpers/form_helper.php | 18 +++++++++--------- system/helpers/html_helper.php | 10 +++++----- system/helpers/inflector_helper.php | 14 +++++++------- system/helpers/language_helper.php | 2 +- system/helpers/number_helper.php | 2 +- system/helpers/path_helper.php | 4 ++-- system/helpers/security_helper.php | 4 ++-- system/helpers/smiley_helper.php | 12 ++++++------ system/helpers/string_helper.php | 8 ++++---- system/helpers/text_helper.php | 10 +++++----- system/helpers/typography_helper.php | 2 +- system/helpers/url_helper.php | 6 +++--- system/helpers/xml_helper.php | 4 ++-- 21 files changed, 82 insertions(+), 82 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php index 075a31fdf..daa21a3ef 100644 --- a/system/helpers/array_helper.php +++ b/system/helpers/array_helper.php @@ -1,4 +1,4 @@ -text. To close fieldset + * Used to produce
text. To close fieldset * use form_fieldset_close() * * @access public @@ -663,7 +663,7 @@ if ( ! function_exists('form_prep')) * Form Value * * Grabs a value from the POST array for the specified field so you can - * re-populate an input field or textarea. If Form Validation + * re-populate an input field or textarea. If Form Validation * is active it retrieves the info from the validation class * * @access public @@ -858,7 +858,7 @@ if ( ! function_exists('set_radio')) /** * Form Error * - * Returns the error for a specific form field. This is a helper for the + * Returns the error for a specific form field. This is a helper for the * form validation class. * * @access public @@ -885,7 +885,7 @@ if ( ! function_exists('form_error')) /** * Validation Error String * - * Returns all the errors associated with a form submission. This is a helper + * Returns all the errors associated with a form submission. This is a helper * function for the form validation class. * * @access public @@ -1034,17 +1034,17 @@ if ( ! function_exists('_get_validation_object')) // We set this as a variable since we're returning by reference. $return = FALSE; - + if (FALSE !== ($object = $CI->load->is_loaded('form_validation'))) { if ( ! isset($CI->$object) OR ! is_object($CI->$object)) { return $return; } - + return $CI->$object; } - + return $return; } } diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 080f622dd..bd66bc2d0 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -1,4 +1,4 @@ -\n"; - // Cycle through the list elements. If an array is + // Cycle through the list elements. If an array is // encountered we will recursively call _list() static $_last_list_item = ''; @@ -244,7 +244,7 @@ if ( ! function_exists('img')) * Generates a page document type declaration * * Valid options are xhtml-11, xhtml-strict, xhtml-trans, xhtml-frame, - * html4-strict, html4-trans, and html4-frame. Values are saved in the + * html4-strict, html4-trans, and html4-frame. Values are saved in the * doctypes config file. * * @access public diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php index c7c113b8a..2352b642e 100644 --- a/system/helpers/inflector_helper.php +++ b/system/helpers/inflector_helper.php @@ -1,4 +1,4 @@ -'), array('<?php', '<?PHP', '<?', '?>'), $str); + return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str); } } diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index 6d8889354..22ca4df77 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -1,4 +1,4 @@ - $val) { // Keep duplicates from being used, which can happen if the - // mapping array contains multiple identical replacements. For example: + // mapping array contains multiple identical replacements. For example: // :-) and :) might be replaced with the same image so both smileys // will be in the array. if (isset($used[$smileys[$key][0]])) @@ -204,7 +204,7 @@ if ( ! function_exists('parse_smileys')) } // Add a trailing slash to the file path if needed - $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url); + $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url); foreach ($smileys as $key => $val) { @@ -231,13 +231,13 @@ if ( ! function_exists('_get_smiley_array')) { if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php')) { - include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'); + include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'); } elseif (file_exists(APPPATH.'config/smileys.php')) { include(APPPATH.'config/smileys.php'); } - + if (isset($smileys) AND is_array($smileys)) { return $smileys; diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php index 7765bba31..9f730bd10 100644 --- a/system/helpers/string_helper.php +++ b/system/helpers/string_helper.php @@ -1,4 +1,4 @@ - $val) { - $x[] = ' '.$key.'="'; + $x[] = ' '.$key.'="'; for ($i = 0; $i < strlen($val); $i++) { $x[] = "|".ord(substr($val, $i, 1)); @@ -363,7 +363,7 @@ if ( ! function_exists('safe_mailto')) * * Automatically links URL and Email addresses. * Note: There's a bit of extra code here to deal with - * URLs or emails that end in a period. We'll strip these + * URLs or emails that end in a period. We'll strip these * off and add them after the link. * * @access public diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php index cdd81ad70..2219d662a 100644 --- a/system/helpers/xml_helper.php +++ b/system/helpers/xml_helper.php @@ -1,4 +1,4 @@ -","\"", "'", "-"), -- cgit v1.2.3-24-g4f1b