From acedd2b1a37b22cb04b01038f21876ddfe38b83a Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Sun, 29 Jul 2012 00:15:40 -0400 Subject: Adding a common stringify_attributes function for dealing with attributes through out various helpers. Signed-off-by: Eric Barnes --- system/helpers/html_helper.php | 41 +++-------------------------------------- 1 file changed, 3 insertions(+), 38 deletions(-) (limited to 'system/helpers/html_helper.php') diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 96234bb02..9843e804e 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -51,7 +51,7 @@ if ( ! function_exists('heading')) */ function heading($data = '', $h = '1', $attributes = '') { - return ''.$data.''; + return ''.$data.''; } } @@ -120,7 +120,7 @@ if ( ! function_exists('_list')) $out = str_repeat(' ', $depth); // Write the opening list tag - $out .= '<'.$type._html_attributes_to_string($attributes).">\n"; + $out .= '<'.$type._stringify_attributes($attributes).">\n"; // Cycle through the list elements. If an array is // encountered we will recursively call _list() @@ -215,7 +215,7 @@ if ( ! function_exists('img')) } } - return $img._html_attributes_to_string($attributes).'/>'; + return $img._stringify_attributes($attributes).'/>'; } } @@ -393,40 +393,5 @@ if ( ! function_exists('nbs')) } } -if ( ! function_exists('_html_attributes_to_string')) -{ - /** - * Attributes To String - * - * Helper function used to convert array or object of attributes to a string - * - * @param mixed - * @param bool - * @return string - */ - function _html_attributes_to_string($attributes) - { - if (is_object($attributes) && count($attributes) > 0) - { - $attributes = (array) $attributes; - } - - if (is_array($attributes) && count($attributes) > 0) - { - $atts = ''; - foreach ($attributes as $key => $val) - { - $atts .= ' '.$key.'="'.$val.'"'; - } - return $atts; - } - elseif (is_string($attributes) && strlen($attributes) > 0) - { - return ' '.$attributes; - } - - return $attributes; - } -} /* End of file html_helper.php */ /* Location: ./system/helpers/html_helper.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b