diff options
author | Evan Winslow <evan.b.winslow@gmail.com> | 2010-10-21 17:46:39 +0000 |
---|---|---|
committer | Evan Winslow <evan.b.winslow@gmail.com> | 2010-10-21 17:46:39 +0000 |
commit | 9ff9d71952db26c06fe2eb1bf98b53340242e524 (patch) | |
tree | fa0a068d6a024d029246691c0c67f1b5e83d2ede /start.php | |
parent | 1bb750cdf821416584dc42206a29dae7c41144a5 (diff) | |
download | elgg-9ff9d71952db26c06fe2eb1bf98b53340242e524.tar.gz elgg-9ff9d71952db26c06fe2eb1bf98b53340242e524.tar.bz2 |
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...
Diffstat (limited to 'start.php')
-rw-r--r-- | start.php | 62 |
1 files changed, 62 insertions, 0 deletions
@@ -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');
|