summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChad Furman <cybarc@gmail.com>2012-07-29 07:11:27 +0200
committerChad Furman <cybarc@gmail.com>2012-07-29 07:11:27 +0200
commit3211ede5156a9fe4a3ea6d203dca190422b4187b (patch)
treecf5fbe8ea5f8f7b1dd3bd7e3195a1664b7414918
parent19204f96b8abc1322feb0f660240ed7abb69026b (diff)
parenta1abadaab34d8d08c54557c7e60d12eb624b72fe (diff)
Refactored _stringify_attributes in system/core/Common.php
-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 */