From 9ff9d71952db26c06fe2eb1bf98b53340242e524 Mon Sep 17 00:00:00 2001 From: Evan Winslow Date: Thu, 21 Oct 2010 17:46:39 +0000 Subject: Removed html/tag view -- all we really needed was a function to form an attribute string from an array. This is now being used in each input view and there is not so much view nesting going on... --- start.php | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'start.php') diff --git a/start.php b/start.php index 9b442a243..d83e75bcd 100644 --- a/start.php +++ b/start.php @@ -6,4 +6,66 @@ function html5_init() { elgg_extend_view('js/initialise_elgg', 'js/html5'); } +function html5_get_html_attributes(array $attrs = array(), $quote_style = ENT_COMPAT, $charset = 'UTF-8', $double_encode = TRUE) { + $attrs = html5_clean_vars($attrs); + $attributes = array(); + + if (isset($attrs['js'])) { + elgg_deprecated_notice("Use of the 'js' attribute was deprecated in 1.8. You can now use the js attributes directly.", '1.8'); + + if (!empty($attrs['js'])) { + $attributes[] = $attrs['js']; + } + + unset($attrs['js']); + } + + foreach ($attrs as $attr => $val) { + $attr = strtolower($attr); + + if ($val === TRUE) { + $attributes[] = $attr; + } elseif (!empty($val)) { + //allow multi-value attributes to be passed as array + if (is_array($val)) { + sort($val); //gzip? + + $val = implode(' ', $val); + } + + $val = htmlspecialchars($val, $quote_style, $charset, $double_encode); + $attributes[] = "$attr=\"$val\""; + } + } + + sort($attributes); //gzip? + + return implode(' ', $attributes); +} + +// remove all the junk that elgg_view throws into $vars +function html5_clean_vars(array $vars = array()) { + unset($vars['config']); + unset($vars['url']); + unset($vars['page_owner']); + unset($vars['page_owner_user']); + + foreach ($_SESSION as $key => $value) { + unset($vars[$key]); + } + + // backwards compatibility code + if (isset($vars['internalname'])) { + $vars['name'] = $vars['internalname']; + unset($vars['internalname']); + } + + if (isset($vars['internalid'])) { + $vars['id'] = $vars['internalid']; + unset($vars['internalid']); + } + + return $vars; +} + register_elgg_event_handler('init', 'system', 'html5_init'); -- cgit v1.2.3