summaryrefslogtreecommitdiffstats
path: root/inc/simplesamlphp/templates/status.php
blob: b3bd0e367d65583c81798a5031b12bdc170e91fb (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
if(array_key_exists('header', $this->data)) {
	if($this->getTag($this->data['header']) !== NULL) {
		$this->data['header'] = $this->t($this->data['header']);
	}
}

$this->includeAtTemplateBase('includes/header.php');
?>

<h2><?php if (isset($this->data['header'])) { echo($this->data['header']); } else { echo($this->t('{status:some_error_occurred}')); } ?></h2>

<p><?php echo($this->t('{status:intro}')); ?></p>

<?php
if (isset($this->data['remaining'])) {
	echo('<p>' . $this->t('{status:validfor}', array('%SECONDS%' => $this->data['remaining'])) . '</p>');
}

if(isset($this->data['sessionsize'])) {
	echo('<p>' . $this->t('{status:sessionsize}', array('%SIZE%' => $this->data['sessionsize'])) . '</p>');
}
?>

<h2><?php echo($this->t('{status:attributes_header}')); ?></h2>

<?php
// consent style listing start
$attributes = $this->data['attributes'];

function present_list($attr) {
	if (is_array($attr) && count($attr) > 1) {
		$str = '<ul>';
		foreach ($attr as $value) {
			$str .= '<li>' . htmlspecialchars($attr) . '</li>';
		}
		$str .= '</ul>';
		return $str;
	} else {
		return htmlspecialchars($attr[0]);
	}
}

function present_assoc($attr) {
	if (is_array($attr)) {
		
		$str = '<dl>';
		foreach ($attr AS $key => $value) {
			$str .= "\n" . '<dt>' . htmlspecialchars($key) . '</dt><dd>' . present_list($value) . '</dd>';
		}
		$str .= '</dl>';
		return $str;
	} else {
		return htmlspecialchars($attr);
	}
}

function present_attributes($t, $attributes, $nameParent) {
	$alternate = array('odd', 'even'); $i = 0;
	
	$parentStr = (strlen($nameParent) > 0)? strtolower($nameParent) . '_': '';
	$str = (strlen($nameParent) > 0)? '<table class="attributes" summary="attribute overview">':
		'<table id="table_with_attributes"  class="attributes" summary="attribute overview">';

	foreach ($attributes as $name => $value) {
	
		$nameraw = $name;
		$name = $t->getAttributeTranslation($parentStr . $nameraw);

		if (preg_match('/^child_/', $nameraw)) {
			$parentName = preg_replace('/^child_/', '', $nameraw);
			foreach($value AS $child) {
				$str .= '<tr class="odd"><td colspan="2" style="padding: 2em">' . present_attributes($t, $child, $parentName) . '</td></tr>';
			}
		} else {	
			if (sizeof($value) > 1) {
				$str .= '<tr class="' . $alternate[($i++ % 2)] . '"><td class="attrname">';

				if ($nameraw !== $name)
					$str .= htmlspecialchars($name).'<br/>';
				$str .= '<tt>'.htmlspecialchars($nameraw).'</tt>';
				$str .= '</td><td class="attrvalue"><ul>';
				foreach ($value AS $listitem) {
					if ($nameraw === 'jpegPhoto') {
						$str .= '<li><img src="data:image/jpeg;base64,' . htmlspecialchars($listitem) . '" /></li>';
					} else {
						$str .= '<li>' . present_assoc($listitem) . '</li>';
					}
				}
				$str .= '</ul></td></tr>';
			} elseif(isset($value[0])) {
				$str .= '<tr class="' . $alternate[($i++ % 2)] . '"><td class="attrname">';
				if ($nameraw !== $name)
					$str .= htmlspecialchars($name).'<br/>';
				$str .= '<tt>'.htmlspecialchars($nameraw).'</tt>';
				$str .= '</td>';
				if ($nameraw === 'jpegPhoto') {
					$str .= '<td class="attrvalue"><img src="data:image/jpeg;base64,' . htmlspecialchars($value[0]) . '" /></td></tr>';
				} else {
					$str .= '<td class="attrvalue">' . htmlspecialchars($value[0]) . '</td></tr>';
				}
			}
		}
		$str .= "\n";
	}
	$str .= '</table>';
	return $str;
}
	
echo(present_attributes($this, $attributes, ''));
// consent style listing end

if (isset($this->data['logout'])) {
	echo('<h2>' . $this->t('{status:logout}') . '</h2>');
	echo('<p>' . $this->data['logout'] . '</p>');
}

if (isset($this->data['logouturl'])) {
	echo('<h2>' . $this->t('{status:logout}') . '</h2>');
	echo('<p>[ <a href="' . htmlspecialchars($this->data['logouturl']) . '">' . $this->t('{status:logout}') . '</a> ]</p>');
}
?>

	<h2><?php echo $this->t('{core:frontpage:about_header}'); ?></h2>
	<p><?php echo $this->t('{core:frontpage:about_text}'); ?></p>
	
<?php $this->includeAtTemplateBase('includes/footer.php'); ?>