Skip to content
Snippets Groups Projects
Commit d19907bb authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Patch from Thomas Graff, consent presentation UI.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1483 44740490-163a-0410-bde0-09ae8108e29a
parent 04b30db7
No related branches found
No related tags found
No related merge requests found
......@@ -111,86 +111,63 @@ if ($this->data['sppp'] !== FALSE) {
?>
<?php
function present_list($attr) {
if (is_array($attr) && count($attr) > 1) {
$str = '<ul><li>' . join('</li><li>', $attr) . '</li></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);
}
// Recursiv attribute array listing function
function present_attributes($t, $attributes, $nameParent) {
$alternate = array('odd', 'even'); $i = 0;
$summary = 'summary="' . $t->t('{consent:consent:table_summary}') . '"';
if(strlen($nameParent) > 0){
$parentStr = strtolower($nameParent) . '_';
$str = '<table class="attributes"' . $summary . ' >';
}else{
$parentStr = '';
$str = '<table id="table_with_attributes" class="attributes" '. $summary .'>';
$str .= "\n" . '<caption>' . $t->t('{consent:consent:table_caption}') . '</caption>';
}
function present_attributes($t, $attributes, $nameParent) {
$alternate = array('odd', 'even'); $i = 0;
$summary = 'summary="' . $t->t('{consent:consent:table_summary}') . '"';
if(strlen($nameParent) > 0){
$parentStr = strtolower($nameParent) . '_';
$str = '<table class="attributes"' . $summary . ' >';
}else{
$parentStr = '';
$str = '<table id="table_with_attributes" class="attributes" '. $summary .'>';
$str .= "\n" . '<caption>' . $t->t('{consent:consent:table_caption}') . '</caption>';
foreach ($attributes as $name => $value) {
$nameraw = $name;
$nameTag = '{attributes:attribute_' . $parentStr . str_replace(":", "_", strtolower($name) ) . '}';
if ($t->getTag($nameTag) !== NULL) {
$name = $t->t($nameTag);
}
foreach ($attributes as $name => $value) {
$nameraw = $name;
$nameTag = '{attributes:attribute_' . $parentStr . str_replace(":", "_", strtolower($name) ) . '}';
if ($t->getTag($nameTag) !== NULL) {
$name = $t->t($nameTag);
if (preg_match('/^child_/', $nameraw)) {
// Insert child table
$parentName = preg_replace('/^child_/', '', $nameraw);
foreach($value AS $child) {
$str .= "\n" . '<tr class="odd"><td style="padding: 2em">' . present_attributes($t, $child, $parentName) . '</td></tr>';
}
if (preg_match('/^child_/', $nameraw)) {
// Insert child table
$parentName = preg_replace('/^child_/', '', $nameraw);
foreach($value AS $child) {
$str .= "\n" . '<tr class="odd"><td style="padding: 2em">' . present_attributes($t, $child, $parentName) . '</td></tr>';
}
} else {
// Insert values directly
$str .= "\n" . '<tr class="' . $alternate[($i++ % 2)] . '"><td><span class="attrname">' . htmlspecialchars($name) . '</span><div class="attrvalue">';
if (sizeof($value) > 1) {
// We hawe several values
$str .= '<ul>';
foreach ($value AS $listitem) {
if ($nameraw === 'jpegPhoto') {
$str .= '<li><img src="data:image/jpeg;base64,' . $listitem . '" alt="User photo" /></li>';
} else {
$str .= '<li>' . present_assoc($listitem) . '</li>';
}
}
$str .= '</ul>';
} elseif(isset($value[0])) {
// We hawe only one value
} else {
// Insert values directly
$str .= "\n" . '<tr class="' . $alternate[($i++ % 2)] . '"><td><span class="attrname">' . htmlspecialchars($name) . '</span><div class="attrvalue">';
if (sizeof($value) > 1) {
// We hawe several values
$str .= '<ul>';
foreach ($value AS $listitem) {
if ($nameraw === 'jpegPhoto') {
$str .= '<img src="data:image/jpeg;base64,' . htmlspecialchars($value[0]) . '" alt="User photo" />';
$str .= '<li><img src="data:image/jpeg;base64,' . $listitem . '" alt="User photo" /></li>';
} else {
$str .= htmlspecialchars($value[0]);
$str .= '<li>' . htmlspecialchars($listitem) . '</li>';
}
} // end of if multivalue
$str .= '</div></td></tr>';
} // end else: not child table
} // end foreach
$str .= count($attributes)>1? '</table>':'';
return $str;
}
}
$str .= '</ul>';
} elseif(isset($value[0])) {
// We hawe only one value
if ($nameraw === 'jpegPhoto') {
$str .= '<img src="data:image/jpeg;base64,' . htmlspecialchars($value[0]) . '" alt="User photo" />';
} else {
$str .= htmlspecialchars($value[0]);
}
} // end of if multivalue
$str .= '</div></td></tr>';
} // end else: not child table
} // end foreach
$str .= isset($attributes)? '</table>':'';
return $str;
}
?>
<h3 id="attributeheader"><?php echo $this->t('{consent:consent:consent_attributes_header}',array( 'SPNAME' => $dstName, 'IDPNAME' => $srcName )); ?></h3>
<?php echo(present_attributes($this, $attributes, '')); ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment