aboutsummaryrefslogtreecommitdiff
path: root/views/default/html/tag.php
blob: c8a49dd61905c3d36259f241d4f337d6c93aef12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php

// remove all the junk that elgg_view throws into $vars

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']);
}

$js = '';
if (isset($vars['js'])) {
	$js = $vars['js'];
	unset($vars['js']);
}

$tag = $vars['tag'];
unset($vars['tag']);

$body = $vars['body'];
unset($vars['body']);

//Build the input
$element = array();

$element[] = "<$tag";
foreach ($vars as $attr => $val) {
	if ($val === TRUE) {
		$element[] = $attr;
	} elseif ($val !== FALSE) {
		$val = htmlspecialchars($val);
		$element[] = "$attr=\"$val\"";
	}
}

if (!empty($js)) {
	$element[] = $js;
}

if (!isset($body)) {
	$element[] = '/';
}

echo implode(" ", $element).">";

if (isset($body)) {
	echo "$body</$tag>";
}