summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Barnes <eric@ericlbarnes.com>2012-07-29 07:14:05 +0200
committerEric Barnes <eric@ericlbarnes.com>2012-07-29 07:14:05 +0200
commit6d953a8ff137d1d8b9bfe1f50328e5b64542c7b8 (patch)
treecf5fbe8ea5f8f7b1dd3bd7e3195a1664b7414918
parent19204f96b8abc1322feb0f660240ed7abb69026b (diff)
parent3211ede5156a9fe4a3ea6d203dca190422b4187b (diff)
Merge pull request #1668 from ShadesOfLight/feature/stringify_attributes
Feature/stringify attributes
-rw-r--r--system/core/Common.php34
1 files changed, 13 insertions, 21 deletions
diff --git a/system/core/Common.php b/system/core/Common.php
index 7c46c590a..5cd3961d1 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -608,42 +608,34 @@ if ( ! function_exists('_stringify_attributes'))
* Helper function used to convert a string, array, or object of
* attributes to a string
*
- * @param mixed string, array, object
- * @param bool
- * @return string
+ * @param mixed string, array, object
+ * @param bool
+ * @return string
*/
function _stringify_attributes($attributes, $js = FALSE)
{
- if (is_string($attributes))
- {
- return strlen($attributes) > 0 ? ' '.$attributes : $attributes;
- }
+ $atts = null;
- if (is_object($attributes))
+ if (empty($attributes))
{
- $attributes = (array) $attributes;
+ return $atts;
}
- if (count($attributes) === 0)
+ if (is_string($attributes))
{
- return;
+ return ' '.$attributes;
}
- $atts = '';
+ $attributes = (array) $attributes;
+
foreach ($attributes as $key => $val)
{
- if ($js)
- {
- $atts .= $key.'='.$val.',';
- }
- else
- {
- $atts .= ' '.$key.'="'.$val.'"';
- }
+ $atts .= ($js) ? $key.'='.$val.',' : ' '.$key.'="'.$val.'"';
}
+
return rtrim($atts, ',');
}
}
/* End of file Common.php */
-/* Location: ./system/core/Common.php */ \ No newline at end of file
+/* Location: ./system/core/Common.php */