summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/date_helper.php17
-rw-r--r--system/helpers/html_helper.php41
-rw-r--r--system/helpers/url_helper.php50
3 files changed, 8 insertions, 100 deletions
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index a45b3d7ac..a792f09a2 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -575,22 +575,7 @@ if ( ! function_exists('timezone_menu'))
$menu .= ' class="'.$class.'"';
}
- // Generate a string from the attributes submitted, if any
- if (is_array($attributes))
- {
- $atts = '';
- foreach ($attributes as $key => $val)
- {
- $atts .= ' '.$key.'="'.$val.'"';
- }
- $attributes = $atts;
- }
- elseif (is_string($attributes) && strlen($attributes) > 0)
- {
- $attributes = ' '.$attributes;
- }
-
- $menu .= $attributes.">\n";
+ $menu .= _stringify_attributes($attributes).">\n";
foreach (timezones() as $key => $val)
{
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
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 '<a href="'.$site_url.'"'.$attributes.'>'.$title.'</a>';
@@ -221,10 +221,10 @@ if ( ! function_exists('anchor_popup'))
unset($attributes[$key]);
}
- $attributes = empty($attributes) ? '' : _parse_attributes($attributes);
+ $attributes = _stringify_attributes($attributes);
return '<a href="'.$site_url
- .'" onclick="window.open(\''.$site_url."', '".$window_name."', '"._parse_attributes($atts, TRUE)."'); return false;\""
+ .'" onclick="window.open(\''.$site_url."', '".$window_name."', '"._stringify_attributes($atts, TRUE)."'); return false;\""
.$attributes.'>'.$title.'</a>';
}
}
@@ -250,7 +250,7 @@ if ( ! function_exists('mailto'))
$title = $email;
}
- return '<a href="mailto:'.$email.'"'._parse_attributes($attributes).'>'.$title.'</a>';
+ return '<a href="mailto:'.$email.'"'._stringify_attributes($attributes).'>'.$title.'</a>';
}
}
@@ -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