summaryrefslogtreecommitdiffstats
path: root/system/helpers/html_helper.php
diff options
context:
space:
mode:
authorEric Barnes <eric@ericlbarnes.com>2012-07-29 06:15:40 +0200
committerEric Barnes <eric@ericlbarnes.com>2012-07-29 06:15:40 +0200
commitacedd2b1a37b22cb04b01038f21876ddfe38b83a (patch)
treeb3b0a1a347abcbe9c2484072f8d859575654a9aa /system/helpers/html_helper.php
parent62ab8b24fc37a25eab9205c46321fa41729e5faf (diff)
Adding a common stringify_attributes function for dealing with attributes through out various helpers.
Signed-off-by: Eric Barnes <eric@ericlbarnes.com>
Diffstat (limited to 'system/helpers/html_helper.php')
-rw-r--r--system/helpers/html_helper.php41
1 files changed, 3 insertions, 38 deletions
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 '<h'.$h._html_attributes_to_string($attributes).'>'.$data.'</h'.$h.'>';
+ return '<h'.$h._stringify_attributes($attributes).'>'.$data.'</h'.$h.'>';
}
}
@@ -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