|
94 | 94 | echo "</p>"; |
95 | 95 | } |
96 | 96 |
|
97 | | -/** |
98 | | - * Recursive attribute array listing function |
99 | | - * |
100 | | - * @param SimpleSAML_XHTML_Template $t Template object |
101 | | - * @param array $attributes Attributes to be presented |
102 | | - * @param string $nameParent Name of parent element |
103 | | - * |
104 | | - * @return string HTML representation of the attributes |
105 | | - */ |
106 | | -function present_attributes($t, $attributes, $nameParent) |
107 | | -{ |
108 | | - $i = 0; |
109 | | - $summary = 'summary="' . $t->t('{consent:consent:table_summary}') . '"'; |
110 | | - |
111 | | - if (strlen($nameParent) > 0) { |
112 | | - $parentStr = strtolower($nameParent) . '_'; |
113 | | - $str = '<table class="table attributes" ' . $summary . '>'; |
114 | | - } else { |
115 | | - $parentStr = ''; |
116 | | - $str = '<table id="table_with_attributes" class="table attributes" '. $summary .'>'; |
117 | | - $str .= "\n" . '<caption>' . $t->t('{consent:consent:table_caption}') . |
118 | | - '</caption>'; |
119 | | - } |
120 | | - |
121 | | - foreach ($attributes as $name => $value) { |
122 | | - $nameraw = $name; |
123 | | - $name = $t->getAttributeTranslation($parentStr . $nameraw); |
124 | | - |
125 | | - if (preg_match('/^child_/', $nameraw)) { |
126 | | - // insert child table |
127 | | - $parentName = preg_replace('/^child_/', '', $nameraw); |
128 | | - foreach ($value as $child) { |
129 | | - $str .= "\n" . '<tr class="odd"><td style="padding: 2em">' . |
130 | | - present_attributes($t, $child, $parentName) . '</td></tr>'; |
131 | | - } |
132 | | - } else { |
133 | | - // insert values directly |
134 | | - |
135 | | - $str .= "\n" . '<tr><td><span class="attrname">' . htmlspecialchars($name) . '</span>'; |
136 | | - |
137 | | - $isHidden = in_array($nameraw, $t->data['hiddenAttributes'], true); |
138 | | - if ($isHidden) { |
139 | | - $hiddenId = SimpleSAML\Utils\Random::generateID(); |
140 | | - |
141 | | - $str .= '<div class="attrvalue" style="display: none;" id="hidden_' . $hiddenId . '">'; |
142 | | - } else { |
143 | | - $str .= '<div class="attrvalue">'; |
144 | | - } |
145 | | - |
146 | | - if (sizeof($value) > 1) { |
147 | | - // we hawe several values |
148 | | - $str .= '<ul>'; |
149 | | - foreach ($value as $listitem) { |
150 | | - if ($nameraw === 'jpegPhoto') { |
151 | | - $str .= '<li><img src="data:image/jpeg;base64,' . |
152 | | - htmlspecialchars($listitem) . |
153 | | - '" alt="User photo" /></li>'; |
154 | | - } else { |
155 | | - $str .= '<li>' . htmlspecialchars($listitem) . '</li>'; |
156 | | - } |
157 | | - } |
158 | | - $str .= '</ul>'; |
159 | | - } elseif (isset($value[0])) { |
160 | | - // we hawe only one value |
161 | | - if ($nameraw === 'jpegPhoto') { |
162 | | - $str .= '<img src="data:image/jpeg;base64,' . |
163 | | - htmlspecialchars($value[0]) . |
164 | | - '" alt="User photo" />'; |
165 | | - } else { |
166 | | - $str .= htmlspecialchars($value[0]); |
167 | | - } |
168 | | - } // end of if multivalue |
169 | | - $str .= '</div>'; |
170 | | - |
171 | | - if ($isHidden) { |
172 | | - $str .= '<div class="attrvalue consent_showattribute" id="visible_' . $hiddenId . '">'; |
173 | | - $str .= '... '; |
174 | | - $str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_' . $hiddenId; |
175 | | - $str .= '\'); SimpleSAML_hide(\'visible_' . $hiddenId . '\');">'; |
176 | | - $str .= $t->t('{consent:consent:show_attribute}'); |
177 | | - $str .= '</a>'; |
178 | | - $str .= '</div>'; |
179 | | - } |
180 | | - |
181 | | - $str .= '</td></tr>'; |
182 | | - } // end else: not child table |
183 | | - } // end foreach |
184 | | - $str .= isset($attributes)? '</table>':''; |
185 | | - return $str; |
186 | | -} |
187 | | - |
188 | 97 | echo '<h3 id="attributeheader">' . |
189 | 98 | $this->t( |
190 | 99 | '{consent:consent:consent_attributes_header}', |
|
0 commit comments