From 01b129a42b62fd08cd873f44ded026041b560420 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 27 Apr 2012 11:36:50 -0400 Subject: Fix docblocks A-H --- system/helpers/form_helper.php | 514 +++++++++++++++++++++-------------------- 1 file changed, 260 insertions(+), 254 deletions(-) (limited to 'system/helpers/form_helper.php') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index e5b487608..b246d72f3 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -36,18 +36,18 @@ // ------------------------------------------------------------------------ -/** - * Form Declaration - * - * Creates the opening portion of the form. - * - * @param string the URI segments of the form destination - * @param array a key/value pair of attributes - * @param array a key/value pair hidden data - * @return string - */ if ( ! function_exists('form_open')) { + /** + * Form Declaration + * + * Creates the opening portion of the form. + * + * @param string the URI segments of the form destination + * @param array a key/value pair of attributes + * @param array a key/value pair hidden data + * @return string + */ function form_open($action = '', $attributes = '', $hidden = array()) { $CI =& get_instance(); @@ -85,18 +85,18 @@ if ( ! function_exists('form_open')) // ------------------------------------------------------------------------ -/** - * Form Declaration - Multipart type - * - * Creates the opening portion of the form, but with "multipart/form-data". - * - * @param string the URI segments of the form destination - * @param array a key/value pair of attributes - * @param array a key/value pair hidden data - * @return string - */ if ( ! function_exists('form_open_multipart')) { + /** + * Form Declaration - Multipart type + * + * Creates the opening portion of the form, but with "multipart/form-data". + * + * @param string the URI segments of the form destination + * @param array a key/value pair of attributes + * @param array a key/value pair hidden data + * @return string + */ function form_open_multipart($action = '', $attributes = array(), $hidden = array()) { if (is_string($attributes)) @@ -114,18 +114,19 @@ if ( ! function_exists('form_open_multipart')) // ------------------------------------------------------------------------ -/** - * Hidden Input Field - * - * Generates hidden fields. You can pass a simple key/value string or - * an associative array with multiple values. - * - * @param mixed - * @param string - * @return string - */ if ( ! function_exists('form_hidden')) { + /** + * Hidden Input Field + * + * Generates hidden fields. You can pass a simple key/value string or + * an associative array with multiple values. + * + * @param mixed + * @param string + * @param bool + * @return string + */ function form_hidden($name, $value = '', $recursing = FALSE) { static $form; @@ -163,16 +164,16 @@ if ( ! function_exists('form_hidden')) // ------------------------------------------------------------------------ -/** - * Text Input Field - * - * @param mixed - * @param string - * @param string - * @return string - */ if ( ! function_exists('form_input')) { + /** + * Text Input Field + * + * @param mixed + * @param string + * @param string + * @return string + */ function form_input($data = '', $value = '', $extra = '') { $defaults = array('type' => 'text', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value); @@ -183,18 +184,19 @@ if ( ! function_exists('form_input')) // ------------------------------------------------------------------------ -/** - * Password Field - * - * Identical to the input function but adds the "password" type - * - * @param mixed - * @param string - * @param string - * @return string - */ + if ( ! function_exists('form_password')) { + /** + * Password Field + * + * Identical to the input function but adds the "password" type + * + * @param mixed + * @param string + * @param string + * @return string + */ function form_password($data = '', $value = '', $extra = '') { if ( ! is_array($data)) @@ -209,18 +211,18 @@ if ( ! function_exists('form_password')) // ------------------------------------------------------------------------ -/** - * Upload Field - * - * Identical to the input function but adds the "file" type - * - * @param mixed - * @param string - * @param string - * @return string - */ if ( ! function_exists('form_upload')) { + /** + * Upload Field + * + * Identical to the input function but adds the "file" type + * + * @param mixed + * @param string + * @param string + * @return string + */ function form_upload($data = '', $value = '', $extra = '') { if ( ! is_array($data)) @@ -235,16 +237,16 @@ if ( ! function_exists('form_upload')) // ------------------------------------------------------------------------ -/** - * Textarea field - * - * @param mixed - * @param string - * @param string - * @return string - */ if ( ! function_exists('form_textarea')) { + /** + * Textarea field + * + * @param mixed + * @param string + * @param string + * @return string + */ function form_textarea($data = '', $value = '', $extra = '') { $defaults = array('name' => ( ! is_array($data) ? $data : ''), 'cols' => '40', 'rows' => '10'); @@ -266,17 +268,17 @@ if ( ! function_exists('form_textarea')) // ------------------------------------------------------------------------ -/** - * Multi-select menu - * - * @param string - * @param array - * @param mixed - * @param string - * @return string - */ if ( ! function_exists('form_multiselect')) { + /** + * Multi-select menu + * + * @param string + * @param array + * @param mixed + * @param string + * @return string + */ function form_multiselect($name = '', $options = array(), $selected = array(), $extra = '') { if ( ! strpos($extra, 'multiple')) @@ -290,17 +292,17 @@ if ( ! function_exists('form_multiselect')) // -------------------------------------------------------------------- -/** - * Drop-down Menu - * - * @param string - * @param array - * @param string - * @param string - * @return string - */ if ( ! function_exists('form_dropdown')) { + /** + * Drop-down Menu + * + * @param string + * @param array + * @param string + * @param string + * @return string + */ function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '') { // If name is really an array then we'll call the function again using the array @@ -358,17 +360,17 @@ if ( ! function_exists('form_dropdown')) // ------------------------------------------------------------------------ -/** - * Checkbox Field - * - * @param mixed - * @param string - * @param bool - * @param string - * @return string - */ if ( ! function_exists('form_checkbox')) { + /** + * Checkbox Field + * + * @param mixed + * @param string + * @param bool + * @param string + * @return string + */ function form_checkbox($data = '', $value = '', $checked = FALSE, $extra = '') { $defaults = array('type' => 'checkbox', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value); @@ -402,17 +404,17 @@ if ( ! function_exists('form_checkbox')) // ------------------------------------------------------------------------ -/** - * Radio Button - * - * @param mixed - * @param string - * @param bool - * @param string - * @return string - */ if ( ! function_exists('form_radio')) { + /** + * Radio Button + * + * @param mixed + * @param string + * @param bool + * @param string + * @return string + */ function form_radio($data = '', $value = '', $checked = FALSE, $extra = '') { if ( ! is_array($data)) @@ -427,16 +429,16 @@ if ( ! function_exists('form_radio')) // ------------------------------------------------------------------------ -/** - * Submit Button - * - * @param mixed - * @param string - * @param string - * @return string - */ if ( ! function_exists('form_submit')) { + /** + * Submit Button + * + * @param mixed + * @param string + * @param string + * @return string + */ function form_submit($data = '', $value = '', $extra = '') { $defaults = array('type' => 'submit', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value); @@ -446,16 +448,16 @@ if ( ! function_exists('form_submit')) // ------------------------------------------------------------------------ -/** - * Reset Button - * - * @param mixed - * @param string - * @param string - * @return string - */ if ( ! function_exists('form_reset')) { + /** + * Reset Button + * + * @param mixed + * @param string + * @param string + * @return string + */ function form_reset($data = '', $value = '', $extra = '') { $defaults = array('type' => 'reset', 'name' => ( ! is_array($data) ? $data : ''), 'value' => $value); @@ -465,16 +467,16 @@ if ( ! function_exists('form_reset')) // ------------------------------------------------------------------------ -/** - * Form Button - * - * @param mixed - * @param string - * @param string - * @return string - */ if ( ! function_exists('form_button')) { + /** + * Form Button + * + * @param mixed + * @param string + * @param string + * @return string + */ function form_button($data = '', $content = '', $extra = '') { $defaults = array('name' => ( ! is_array($data) ? $data : ''), 'type' => 'button'); @@ -490,16 +492,16 @@ if ( ! function_exists('form_button')) // ------------------------------------------------------------------------ -/** - * Form Label Tag - * - * @param string The text to appear onscreen - * @param string The id the label applies to - * @param string Additional attributes - * @return string - */ if ( ! function_exists('form_label')) { + /** + * Form Label Tag + * + * @param string The text to appear onscreen + * @param string The id the label applies to + * @param string Additional attributes + * @return string + */ function form_label($label_text = '', $id = '', $attributes = array()) { @@ -523,18 +525,19 @@ if ( ! function_exists('form_label')) } // ------------------------------------------------------------------------ -/** - * Fieldset Tag - * - * Used to produce
text. To close fieldset - * use form_fieldset_close() - * - * @param string The legend text - * @param string Additional attributes - * @return string - */ + if ( ! function_exists('form_fieldset')) { + /** + * Fieldset Tag + * + * Used to produce
text. To close fieldset + * use form_fieldset_close() + * + * @param string The legend text + * @param string Additional attributes + * @return string + */ function form_fieldset($legend_text = '', $attributes = array()) { $fieldset = '\n"; @@ -549,14 +552,14 @@ if ( ! function_exists('form_fieldset')) // ------------------------------------------------------------------------ -/** - * Fieldset Close Tag - * - * @param string - * @return string - */ if ( ! function_exists('form_fieldset_close')) { + /** + * Fieldset Close Tag + * + * @param string + * @return string + */ function form_fieldset_close($extra = '') { return '
'.$extra; @@ -565,14 +568,14 @@ if ( ! function_exists('form_fieldset_close')) // ------------------------------------------------------------------------ -/** - * Form Close Tag - * - * @param string - * @return string - */ if ( ! function_exists('form_close')) { + /** + * Form Close Tag + * + * @param string + * @return string + */ function form_close($extra = '') { return ''.$extra; @@ -581,16 +584,17 @@ if ( ! function_exists('form_close')) // ------------------------------------------------------------------------ -/** - * Form Prep - * - * Formats text so that it can be safely placed in a form field in the event it has HTML tags. - * - * @param string - * @return string - */ if ( ! function_exists('form_prep')) { + /** + * Form Prep + * + * Formats text so that it can be safely placed in a form field in the event it has HTML tags. + * + * @param string + * @param string + * @return string + */ function form_prep($str = '', $field_name = '') { static $prepped_fields = array(); @@ -631,18 +635,19 @@ 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 - * is active it retrieves the info from the validation class - * - * @param string - * @return mixed - */ if ( ! function_exists('set_value')) { + /** + * 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 + * is active it retrieves the info from the validation class + * + * @param string + * @param string + * @return mixed + */ function set_value($field = '', $default = '') { if (FALSE === ($OBJ =& _get_validation_object())) @@ -661,19 +666,19 @@ if ( ! function_exists('set_value')) // ------------------------------------------------------------------------ -/** - * Set Select - * - * Let's you set the selected value of a menu via data in the POST array. + * If Form Validation is active it retrieves the info from the validation class + * + * @param string + * @param string + * @param bool + * @return string + */ function set_select($field = '', $value = '', $default = FALSE) { $OBJ =& _get_validation_object(); @@ -712,19 +717,19 @@ if ( ! function_exists('set_select')) // ------------------------------------------------------------------------ -/** - * Set Checkbox - * - * Let's you set the selected value of a checkbox via the value in the POST array. - * If Form Validation is active it retrieves the info from the validation class - * - * @param string - * @param string - * @param bool - * @return string - */ if ( ! function_exists('set_checkbox')) { + /** + * Set Checkbox + * + * Let's you set the selected value of a checkbox via the value in the POST array. + * If Form Validation is active it retrieves the info from the validation class + * + * @param string + * @param string + * @param bool + * @return string + */ function set_checkbox($field = '', $value = '', $default = FALSE) { $OBJ =& _get_validation_object(); @@ -763,19 +768,19 @@ if ( ! function_exists('set_checkbox')) // ------------------------------------------------------------------------ -/** - * Set Radio - * - * Let's you set the selected value of a radio field via info in the POST array. - * If Form Validation is active it retrieves the info from the validation class - * - * @param string - * @param string - * @param bool - * @return string - */ if ( ! function_exists('set_radio')) { + /** + * Set Radio + * + * Let's you set the selected value of a radio field via info in the POST array. + * If Form Validation is active it retrieves the info from the validation class + * + * @param string + * @param string + * @param bool + * @return string + */ function set_radio($field = '', $value = '', $default = FALSE) { $OBJ =& _get_validation_object(); @@ -817,19 +822,20 @@ if ( ! function_exists('set_radio')) // ------------------------------------------------------------------------ -/** - * Form Error - * - * Returns the error for a specific form field. This is a helper for the - * form validation class. - * - * @param string - * @param string - * @param string - * @return string - */ + if ( ! function_exists('form_error')) { + /** + * Form Error + * + * Returns the error for a specific form field. This is a helper for the + * form validation class. + * + * @param string + * @param string + * @param string + * @return string + */ function form_error($field = '', $prefix = '', $suffix = '') { if (FALSE === ($OBJ =& _get_validation_object())) @@ -843,18 +849,18 @@ if ( ! function_exists('form_error')) // ------------------------------------------------------------------------ -/** - * Validation Error String - * - * Returns all the errors associated with a form submission. This is a helper - * function for the form validation class. - * - * @param string - * @param string - * @return string - */ if ( ! function_exists('validation_errors')) { + /** + * Validation Error String + * + * Returns all the errors associated with a form submission. This is a helper + * function for the form validation class. + * + * @param string + * @param string + * @return string + */ function validation_errors($prefix = '', $suffix = '') { if (FALSE === ($OBJ =& _get_validation_object())) @@ -868,17 +874,17 @@ if ( ! function_exists('validation_errors')) // ------------------------------------------------------------------------ -/** - * Parse the form attributes - * - * Helper function used by some of the form helpers - * - * @param array - * @param array - * @return string - */ if ( ! function_exists('_parse_form_attributes')) { + /** + * Parse the form attributes + * + * Helper function used by some of the form helpers + * + * @param array + * @param array + * @return string + */ function _parse_form_attributes($attributes, $default) { if (is_array($attributes)) @@ -916,17 +922,17 @@ if ( ! function_exists('_parse_form_attributes')) // ------------------------------------------------------------------------ -/** - * Attributes To String - * - * Helper function used by some of the form helpers - * - * @param mixed - * @param bool - * @return string - */ if ( ! function_exists('_attributes_to_string')) { + /** + * Attributes To String + * + * Helper function used by some of the form helpers + * + * @param mixed + * @param bool + * @return string + */ function _attributes_to_string($attributes, $formtag = FALSE) { if (is_string($attributes) && strlen($attributes) > 0) @@ -975,16 +981,16 @@ if ( ! function_exists('_attributes_to_string')) // ------------------------------------------------------------------------ -/** - * Validation Object - * - * Determines what the form validation class was instantiated as, fetches - * the object and returns it. - * - * @return mixed - */ if ( ! function_exists('_get_validation_object')) { + /** + * Validation Object + * + * Determines what the form validation class was instantiated as, fetches + * the object and returns it. + * + * @return mixed + */ function &_get_validation_object() { $CI =& get_instance(); -- cgit v1.2.3-24-g4f1b From ae31eb5e75d914fc3ab622a7ac5c23eb1e6d9f9a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 17 May 2012 14:54:15 +0300 Subject: Clean up the helpers --- system/helpers/form_helper.php | 1 - 1 file changed, 1 deletion(-) (limited to 'system/helpers/form_helper.php') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index b246d72f3..eca6c5f1e 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -184,7 +184,6 @@ if ( ! function_exists('form_input')) // ------------------------------------------------------------------------ - if ( ! function_exists('form_password')) { /** -- cgit v1.2.3-24-g4f1b From 773ccc318f2769c9b7579630569b5d8ba47b114b Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:11:08 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/helpers --- system/helpers/form_helper.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'system/helpers/form_helper.php') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index eca6c5f1e..410972187 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -52,7 +52,7 @@ if ( ! function_exists('form_open')) { $CI =& get_instance(); - if ($attributes == '') + if ($attributes === '') { $attributes = 'method="post"'; } @@ -325,7 +325,7 @@ if ( ! function_exists('form_dropdown')) $selected = array($_POST[$name]); } - if ($extra != '') $extra = ' '.$extra; + if ($extra !== '') $extra = ' '.$extra; $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; @@ -378,7 +378,7 @@ if ( ! function_exists('form_checkbox')) { $checked = $data['checked']; - if ($checked == FALSE) + if ($checked === FALSE) { unset($data['checked']); } @@ -388,7 +388,7 @@ if ( ! function_exists('form_checkbox')) } } - if ($checked == TRUE) + if ($checked === TRUE) { $defaults['checked'] = 'checked'; } @@ -506,7 +506,7 @@ if ( ! function_exists('form_label')) $label = '\n"; - if ($legend_text != '') + if ($legend_text !== '') { return $fieldset.''.$legend_text."\n"; } @@ -623,7 +623,7 @@ if ( ! function_exists('form_prep')) return $str; } - if ($field_name != '') + if ($field_name !== '') { $prepped_fields[$field_name] = $field_name; } @@ -686,7 +686,7 @@ if ( ! function_exists('set_select')) { if ( ! isset($_POST[$field])) { - if (count($_POST) === 0 && $default == TRUE) + if (count($_POST) === 0 && $default === TRUE) { return ' selected="selected"'; } @@ -702,7 +702,7 @@ if ( ! function_exists('set_select')) return ''; } } - elseif (($field == '' OR $value == '') OR ($field != $value)) + elseif (($field === '' OR $value === '') OR ($field !== $value)) { return ''; } @@ -737,7 +737,7 @@ if ( ! function_exists('set_checkbox')) { if ( ! isset($_POST[$field])) { - if (count($_POST) === 0 && $default == TRUE) + if (count($_POST) === 0 && $default === TRUE) { return ' checked="checked"'; } @@ -753,7 +753,7 @@ if ( ! function_exists('set_checkbox')) return ''; } } - elseif (($field == '' OR $value == '') OR ($field != $value)) + elseif (($field === '' OR $value === '') OR ($field !== $value)) { return ''; } @@ -788,7 +788,7 @@ if ( ! function_exists('set_radio')) { if ( ! isset($_POST[$field])) { - if (count($_POST) === 0 && $default == TRUE) + if (count($_POST) === 0 && $default === TRUE) { return ' checked="checked"'; } @@ -806,7 +806,7 @@ if ( ! function_exists('set_radio')) } else { - if (($field == '' OR $value == '') OR ($field != $value)) + if (($field === '' OR $value === '') OR ($field !== $value)) { return ''; } @@ -907,7 +907,7 @@ if ( ! function_exists('_parse_form_attributes')) foreach ($default as $key => $val) { - if ($key == 'value') + if ($key === 'value') { $val = form_prep($val, $default['name']); } @@ -936,12 +936,12 @@ if ( ! function_exists('_attributes_to_string')) { if (is_string($attributes) && strlen($attributes) > 0) { - if ($formtag == TRUE && strpos($attributes, 'method=') === FALSE) + if ($formtag === TRUE && strpos($attributes, 'method=') === FALSE) { $attributes .= ' method="post"'; } - if ($formtag == TRUE && strpos($attributes, 'accept-charset=') === FALSE) + if ($formtag === TRUE && strpos($attributes, 'accept-charset=') === FALSE) { $attributes .= ' accept-charset="'.strtolower(config_item('charset')).'"'; } -- cgit v1.2.3-24-g4f1b From 910ff7ad430f47ebcf3d801314fcee9a3c10f011 Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Wed, 6 Jun 2012 20:03:14 +0200 Subject: form_checkbox set_value fix --- system/helpers/form_helper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/helpers/form_helper.php') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 410972187..04d11837e 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -378,7 +378,7 @@ if ( ! function_exists('form_checkbox')) { $checked = $data['checked']; - if ($checked === FALSE) + if ($checked == FALSE) { unset($data['checked']); } @@ -388,7 +388,7 @@ if ( ! function_exists('form_checkbox')) } } - if ($checked === TRUE) + if ($checked == TRUE) { $defaults['checked'] = 'checked'; } -- cgit v1.2.3-24-g4f1b From 9640a037c51c1efea2e64caa974c577dc1594f5d Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Wed, 6 Jun 2012 20:20:27 +0200 Subject: fixes --- system/helpers/form_helper.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'system/helpers/form_helper.php') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 04d11837e..40c7d8823 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -325,7 +325,10 @@ if ( ! function_exists('form_dropdown')) $selected = array($_POST[$name]); } - if ($extra !== '') $extra = ' '.$extra; + if ($extra != '') + { + $extra = ' '.$extra; + } $multiple = (count($selected) > 1 && strpos($extra, 'multiple') === FALSE) ? ' multiple="multiple"' : ''; @@ -702,7 +705,7 @@ if ( ! function_exists('set_select')) return ''; } } - elseif (($field === '' OR $value === '') OR ($field !== $value)) + elseif (($field == '' OR $value == '') OR ($field != $value)) { return ''; } @@ -753,7 +756,7 @@ if ( ! function_exists('set_checkbox')) return ''; } } - elseif (($field === '' OR $value === '') OR ($field !== $value)) + elseif (($field == '' OR $value == '') OR ($field != $value)) { return ''; } @@ -806,7 +809,7 @@ if ( ! function_exists('set_radio')) } else { - if (($field === '' OR $value === '') OR ($field !== $value)) + if (($field == '' OR $value == '') OR ($field != $value)) { return ''; } -- cgit v1.2.3-24-g4f1b From a6f3423388c2c51119e71d7aac2917b34911bf5c Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Thu, 7 Jun 2012 10:14:29 +0200 Subject: fixes --- system/helpers/form_helper.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/helpers/form_helper.php') diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index 40c7d8823..984634315 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -705,7 +705,7 @@ if ( ! function_exists('set_select')) return ''; } } - elseif (($field == '' OR $value == '') OR ($field != $value)) + elseif (($field == '' OR $value == '') OR $field !== $value) { return ''; } @@ -756,7 +756,7 @@ if ( ! function_exists('set_checkbox')) return ''; } } - elseif (($field == '' OR $value == '') OR ($field != $value)) + elseif (($field == '' OR $value == '') OR $field !== $value) { return ''; } @@ -809,7 +809,7 @@ if ( ! function_exists('set_radio')) } else { - if (($field == '' OR $value == '') OR ($field != $value)) + if (($field == '' OR $value == '') OR $field !== $value) { return ''; } -- cgit v1.2.3-24-g4f1b