diff options
Diffstat (limited to 'system/helpers')
-rw-r--r-- | system/helpers/form_helper.php | 35 | ||||
-rw-r--r-- | system/helpers/text_helper.php | 13 |
2 files changed, 14 insertions, 34 deletions
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 200da8ac5..692909c79 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -228,7 +228,7 @@ if ( ! function_exists('form_upload')) */ function form_upload($data = '', $value = '', $extra = '') { - $default = array('type' => 'file', 'name' => ''); + $defaults = array('type' => 'file', 'name' => ''); is_array($data) OR $data = array('name' => $data); $data['type'] = 'file'; return '<input '._parse_form_attributes($data, $defaults).$extra." />\n"; @@ -642,37 +642,14 @@ if ( ! function_exists('set_value')) */ function set_value($field = '', $default = '', $is_textarea = FALSE) { - if (FALSE !== ($OBJ =& _get_validation_object()) && $OBJ->has_rule($field)) - { - return form_prep($OBJ->set_value($field, $default), $is_textarea); - } - - // We couldn't find the $field in validator, so try in $_POST array - $index = $field; - $container = $_POST; - - // Test if the $field is an array name, and try to obtain the final index - if (preg_match_all('/\[(.*?)\]/', $field, $matches)) + if (FALSE === ($OBJ =& _get_validation_object())) { - sscanf($field, '%[^[][', $index); - for ($i = 0, $c = count($matches[0]); $i < $c; $i++) - { - if (isset($container[$index]) && $matches[1][$i] !== '') - { - $container = $container[$index]; - $index = $matches[1][$i]; - } - else - { - $container = array(); - break; - } - } + return isset($_POST[$field]) + ? form_prep($_POST[$field], $is_textarea) + : form_prep($default, $is_textarea); } - return isset($container[$index]) - ? form_prep($container[$index], $is_textarea) - : form_prep($default, $is_textarea); + return form_prep($OBJ->set_value($field, $default), $is_textarea); } } diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 54db14f94..b2351db95 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -363,9 +363,9 @@ if ( ! function_exists('convert_accented_characters')) */ function convert_accented_characters($str) { - static $_foreign_characters; + static $array_from, $array_to; - if ( ! is_array($_foreign_characters)) + if ( ! is_array($array_from)) { if (file_exists(APPPATH.'config/foreign_chars.php')) { @@ -379,14 +379,17 @@ if ( ! function_exists('convert_accented_characters')) if (empty($foreign_characters) OR ! is_array($foreign_characters)) { - $_foreign_characters = array(); + $array_from = array(); + $array_to = array(); + return $str; } - $_foreign_characters = $foreign_characters; + $array_from = array_keys($foreign_characters); + $array_to = array_values($foreign_characters); } - return preg_replace(array_keys($_foreign_characters), array_values($_foreign_characters), $str); + return preg_replace($array_from, $array_to, $str); } } |