diff --git a/modules/consent/templates/consentform.php b/modules/consent/templates/consentform.php index 694c316bfd48faaa98a43d79e5427f77a2667598..3c19503ba1a890b7f01ada26ee65a293e5f03e55 100644 --- a/modules/consent/templates/consentform.php +++ b/modules/consent/templates/consentform.php @@ -59,100 +59,6 @@ if ($this->data['sppp'] !== false) { echo "</p>"; } -/** - * Recursive attribute array listing function - * - * @param \SimpleSAML\XHTML\Template $t Template object - * @param array $attributes Attributes to be presented - * @param string $nameParent Name of parent element - * - * @return string HTML representation of the attributes - */ -function present_attributes($t, $attributes, $nameParent) -{ - $translator = $t->getTranslator(); - - $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; - $name = $translator->getAttributeTranslation($parentStr.$nameraw); - - 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>'; - - $isHidden = in_array($nameraw, $t->data['hiddenAttributes'], true); - if ($isHidden) { - $hiddenId = SimpleSAML\Utils\Random::generateID(); - - $str .= '<div class="attrvalue" style="display: none;" id="hidden_'.$hiddenId.'">'; - } else { - $str .= '<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,'. - htmlspecialchars($listitem). - '" alt="User photo" /></li>'; - } else { - $str .= '<li>'.htmlspecialchars($listitem).'</li>'; - } - } - $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>'; - - if ($isHidden) { - $str .= '<div class="attrvalue consent_showattribute" id="visible_'.$hiddenId.'">'; - $str .= '... '; - $str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_'.$hiddenId; - $str .= '\'); SimpleSAML_hide(\'visible_'.$hiddenId.'\');">'; - $str .= $t->t('{consent:consent:show_attribute}'); - $str .= '</a>'; - $str .= '</div>'; - } - - $str .= '</td></tr>'; - } // end else: not child table - } // end foreach - $str .= isset($attributes) ? '</table>' : ''; - return $str; -} - echo '<h3 id="attributeheader">'. $this->t( '{consent:consent:consent_attributes_header}', diff --git a/modules/consent/www/getconsent.php b/modules/consent/www/getconsent.php index 8c722126f368ec1cb4cbb4b1b46e843e5c6ab109..92c9623b045de07f2727694422f53d5b4ef7755b 100644 --- a/modules/consent/www/getconsent.php +++ b/modules/consent/www/getconsent.php @@ -127,21 +127,21 @@ $t->data['attributes'] = $attributes; $t->data['checked'] = $state['consent:checked']; $t->data['stateId'] = $id; -$srcName = htmlspecialchars(is_array($srcName) ? $translator->t($srcName) : $srcName); -$dstName = htmlspecialchars(is_array($dstName) ? $translator->t($dstName) : $dstName); +$srcName = htmlspecialchars(is_array($srcName) ? $t->t($srcName) : $srcName); +$dstName = htmlspecialchars(is_array($dstName) ? $t->t($dstName) : $dstName); -$t->data['consent_attributes_header'] = $translator->t( +$t->data['consent_attributes_header'] = $t->t( '{consent:consent:consent_attributes_header}', array('SPNAME' => $dstName, 'IDPNAME' => $srcName) ); -$t->data['consent_accept'] = $translator->t( +$t->data['consent_accept'] = $t->t( '{consent:consent:consent_accept}', array('SPNAME' => $dstName, 'IDPNAME' => $srcName) ); if (array_key_exists('descr_purpose', $state['Destination'])) { - $t->data['consent_purpose'] = $translator->t( + $t->data['consent_purpose'] = $t->t( '{consent:consent:consent_purpose}', array( 'SPNAME' => $dstName, @@ -216,7 +216,7 @@ function present_attributes($t, $attributes, $nameParent) $alternate = array('odd', 'even'); $i = 0; - $summary = 'summary="'.$translator->t('{consent:consent:table_summary}').'"'; + $summary = 'summary="'.$t->t('{consent:consent:table_summary}').'"'; if (strlen($nameParent) > 0) { $parentStr = strtolower($nameParent).'_'; @@ -224,7 +224,7 @@ function present_attributes($t, $attributes, $nameParent) } else { $parentStr = ''; $str = '<table id="table_with_attributes" class="attributes" '.$summary.'>'; - $str .= "\n".'<caption>'.$translator->t('{consent:consent:table_caption}').'</caption>'; + $str .= "\n".'<caption>'.$t->t('{consent:consent:table_caption}').'</caption>'; } foreach ($attributes as $name => $value) { @@ -281,7 +281,7 @@ function present_attributes($t, $attributes, $nameParent) $str .= '... '; $str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_'.$hiddenId; $str .= '\'); SimpleSAML_hide(\'visible_'.$hiddenId.'\');">'; - $str .= $translator->t('{consent:consent:show_attribute}'); + $str .= $t->t('{consent:consent:show_attribute}'); $str .= '</a>'; $str .= '</div>'; }