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/url_helper.php | 50 ++++--------------------------------------- 1 file changed, 4 insertions(+), 46 deletions(-) (limited to 'system/helpers/url_helper.php') diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 39e6343a6..57208c948 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -165,7 +165,7 @@ if ( ! function_exists('anchor')) if ($attributes !== '') { - $attributes = _parse_attributes($attributes); + $attributes = _stringify_attributes($attributes); } return ''.$title.''; @@ -221,10 +221,10 @@ if ( ! function_exists('anchor_popup')) unset($attributes[$key]); } - $attributes = empty($attributes) ? '' : _parse_attributes($attributes); + $attributes = _stringify_attributes($attributes); return ''.$title.''; } } @@ -250,7 +250,7 @@ if ( ! function_exists('mailto')) $title = $email; } - return ''.$title.''; + return ''.$title.''; } } @@ -560,47 +560,5 @@ if ( ! function_exists('redirect')) } } -// ------------------------------------------------------------------------ - -if ( ! function_exists('_parse_attributes')) -{ - /** - * Parse out the attributes - * - * Some of the functions use this - * - * @param array - * @param bool - * @return string - */ - function _parse_attributes($attributes, $javascript = FALSE) - { - if (is_string($attributes)) - { - return ($attributes !== '') ? ' '.$attributes : ''; - } - - $att = ''; - foreach ($attributes as $key => $val) - { - if ($javascript === TRUE) - { - $att .= $key.'='.$val.','; - } - else - { - $att .= ' '.$key.'="'.$val.'"'; - } - } - - if ($javascript === TRUE && $att !== '') - { - return substr($att, 0, -1); - } - - return $att; - } -} - /* End of file url_helper.php */ /* Location: ./system/helpers/url_helper.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b