aboutsummaryrefslogtreecommitdiff
path: root/start.php
diff options
context:
space:
mode:
authorEvan Winslow <evan.b.winslow@gmail.com>2010-10-21 17:46:39 +0000
committerEvan Winslow <evan.b.winslow@gmail.com>2010-10-21 17:46:39 +0000
commit9ff9d71952db26c06fe2eb1bf98b53340242e524 (patch)
treefa0a068d6a024d029246691c0c67f1b5e83d2ede /start.php
parent1bb750cdf821416584dc42206a29dae7c41144a5 (diff)
downloadelgg-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.php62
1 files changed, 62 insertions, 0 deletions
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');