|
28 | 28 | assert('is_array($this->data["hiddenAttributes"])'); |
29 | 29 | assert('$this->data["sppp"] === false || is_string($this->data["sppp"])'); |
30 | 30 |
|
| 31 | +if (!isset($this->data['label-col'])) { |
| 32 | + $this->data['label-col'] = 5; |
| 33 | +} |
| 34 | + |
| 35 | +function present_attributes_photo_or_value($nameraw, $listitem) |
| 36 | +{ |
| 37 | + if ($nameraw === 'jpegPhoto') { |
| 38 | + return '<img src="data:image/jpeg;base64,' . htmlspecialchars($listitem) . '" alt="User photo" />'; |
| 39 | + } else { |
| 40 | + return htmlspecialchars($listitem); |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +function perun_present_attributes($t, $attributes, $nameParent, $labelCol = 5) |
| 45 | +{ |
| 46 | + $translator = $t->getTranslator(); |
| 47 | + |
| 48 | + if (strlen($nameParent) > 0) { |
| 49 | + $parentStr = strtolower($nameParent).'_'; |
| 50 | + $str = '<ul class="perun-attributes">'; |
| 51 | + } else { |
| 52 | + $parentStr = ''; |
| 53 | + $str = '<ul id="perun-table_with_attributes" class="perun-attributes">'; |
| 54 | + } |
| 55 | + |
| 56 | + foreach ($attributes as $name => $value) { |
| 57 | + $nameraw = $name; |
| 58 | + $name = $translator->getAttributeTranslation($parentStr.$nameraw); |
| 59 | + |
| 60 | + if (preg_match('/^child_/', $nameraw)) { |
| 61 | + // insert child table |
| 62 | + throw new Exception('Unsupported'); |
| 63 | + } else { |
| 64 | + // insert values directly |
| 65 | + $str .= "\n".'<li>' |
| 66 | + . '<div class="row"><div class="col-sm-' . $labelCol |
| 67 | + . '"><h2 class="perun-attrname h4">' |
| 68 | + . htmlspecialchars(str_replace("domovksé", "domovské", $name)).'</h2></div>'; |
| 69 | + |
| 70 | + $str .= '<div class="perun-attrcontainer col-sm-' . (12-$labelCol) . '">'; |
| 71 | + $isHidden = in_array($nameraw, $t->data['hiddenAttributes'], true); |
| 72 | + if ($isHidden) { |
| 73 | + $hiddenId = \SimpleSAML\Utils\Random::generateID(); |
| 74 | + $str .= '<span class="perun-attrvalue hidden" id="hidden_'.$hiddenId.'">'; |
| 75 | + } else { |
| 76 | + $str .= '<span class="perun-attrvalue">'; |
| 77 | + } |
| 78 | + |
| 79 | + if (count($value) > 0) { |
| 80 | + $str .= '<ul class="perun-attrlist">'; |
| 81 | + foreach ($value as $listitem) { |
| 82 | + $str .= '<li>' . present_attributes_photo_or_value($nameraw, $listitem) . '</li>'; |
| 83 | + } |
| 84 | + $str .= '</ul>'; |
| 85 | + } |
| 86 | + $str .= '</span>'; |
| 87 | + |
| 88 | + if ($isHidden) { |
| 89 | + $str .= '<div class="perun-attrvalue consent_showattribute" id="visible_'.$hiddenId.'">'; |
| 90 | + $str .= '… '; |
| 91 | + $str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_'.$hiddenId; |
| 92 | + $str .= '\'); SimpleSAML_hide(\'visible_'.$hiddenId.'\');">'; |
| 93 | + $str .= $t->t('{consent:consent:show_attribute}'); |
| 94 | + $str .= '</a>'; |
| 95 | + $str .= '</div>'; |
| 96 | + } |
| 97 | + |
| 98 | + $str .= '</div><!-- .perun-attrcontainer --></div><!-- .row --></li>'; |
| 99 | + } // end else: not child table |
| 100 | + } // end foreach |
| 101 | + $str .= isset($attributes) ? '</ul>' : ''; |
| 102 | + return $str; |
| 103 | +} |
| 104 | + |
| 105 | + |
31 | 106 | // Parse parameters |
32 | 107 | if (array_key_exists('name', $this->data['srcMetadata'])) { |
33 | 108 | $srcName = $this->data['srcMetadata']['name']; |
|
60 | 135 |
|
61 | 136 | $this->data['header'] = $this->t('{consent:consent:consent_header}'); |
62 | 137 |
|
63 | | -$this->data['head'] = '<link rel="stylesheet" media="screen" type="text/css" href="' . |
| 138 | +if (!isset($this->data['head'])) { |
| 139 | + $this->data['head'] = ''; |
| 140 | +} |
| 141 | +$this->data['head'] .= '<link rel="stylesheet" media="screen" type="text/css" href="' . |
64 | 142 | Module::getModuleUrl('consent/assets/css/consent.css') . '" />'; |
65 | 143 | $this->data['head'] .= '<link rel="stylesheet" media="screen" type="text/css" href="' . |
66 | 144 | Module::getModuleUrl('perun/res/css/consent.css') . '" />'; |
|
88 | 166 | echo "</p>"; |
89 | 167 | } |
90 | 168 |
|
91 | | -echo '<h3 id="attributeheader">' . |
| 169 | +echo '<h1 id="attributeheader">' . |
92 | 170 | $this->t( |
93 | 171 | '{perun:consent:consent_attributes_header}', |
94 | 172 | ['SPNAME' => $dstName, 'IDPNAME' => $srcName] |
95 | 173 | ) . |
96 | | - '</h3>'; |
| 174 | + '</h1>'; |
97 | 175 |
|
98 | | -echo present_attributes($this, $attributes, ''); |
| 176 | +echo perun_present_attributes($this, $attributes, '', $this->data['label-col']); |
99 | 177 |
|
100 | 178 | ?> |
| 179 | + <div class="row" id="saveconsentcontainer"> |
| 180 | + <div class="col-xs-12"> |
| 181 | + <?php |
| 182 | + if ($this->data['usestorage']) { |
| 183 | + $checked = ($this->data['checked'] ? 'checked="checked"' : ''); |
| 184 | + echo '<div class="checkbox"> |
| 185 | + <input type="checkbox" form="yesform" name="saveconsent" id="saveconsent" value="1" /> ' |
| 186 | + . '<label for="saveconsent">' . $this->t('{perun:consent:remember}') . '</label> |
| 187 | + </div>'; |
| 188 | + } |
| 189 | + ?> |
| 190 | + </div> |
| 191 | + </div> |
101 | 192 |
|
102 | 193 | <div class="row"> |
103 | | - <div class="col-xs-6"> |
| 194 | + <div class="col-sm-6"> |
104 | 195 |
|
105 | | - <form action="<?php echo htmlspecialchars($this->data['yesTarget']); ?>"> |
| 196 | + <form action="<?php echo htmlspecialchars($this->data['yesTarget']); ?>" id="yesform"> |
106 | 197 | <?php |
107 | | - if ($this->data['usestorage']) { |
108 | | - $checked = ($this->data['checked'] ? 'checked="checked"' : ''); |
109 | | - echo '<div class="checkbox"> |
110 | | - <label> |
111 | | - <input type="checkbox" name="saveconsent" value="1" /> ' . $this->t('{perun:consent:remember}') . ' |
112 | | - </label> |
113 | | - </div>'; |
114 | | - } |
115 | | - |
116 | 198 | // Embed hidden fields... |
117 | 199 | foreach ($this->data['yesData'] as $name => $value) { |
118 | 200 | echo '<input type="hidden" name="' . htmlspecialchars($name) . |
119 | 201 | '" value="' . htmlspecialchars($value) . '" />'; |
120 | 202 | } |
121 | 203 | ?> |
122 | 204 |
|
123 | | - <button type="submit" name="yes" class="btn btn-lg btn-success btn-block" id="yesbutton"> |
124 | | - <?php echo htmlspecialchars($this->t('{consent:consent:yes}')) ?> |
| 205 | + <button type="submit" name="yes" class="btn btn-lg btn-primary btn-success btn-block" id="yesbutton"> |
| 206 | + <span><?php echo htmlspecialchars($this->t('{consent:consent:yes}')) ?></span> |
125 | 207 | </button> |
126 | 208 |
|
127 | 209 | </form> |
128 | 210 |
|
129 | 211 | </div> |
130 | | - <div class="col-xs-6"> |
| 212 | + <div class="col-sm-6"> |
131 | 213 |
|
132 | 214 | <form action="<?php echo htmlspecialchars($this->data['noTarget']); ?>"> |
133 | 215 |
|
|
138 | 220 | } |
139 | 221 | ?> |
140 | 222 | <button type="submit" class="btn btn-lg btn-default btn-block btn-no" name="no" id="nobutton"> |
141 | | - <?php echo htmlspecialchars($this->t('{consent:consent:no}')) ?> |
| 223 | + <span><?php echo htmlspecialchars($this->t('{consent:consent:no}')) ?></span> |
142 | 224 | </button> |
143 | 225 |
|
144 | 226 | </form> |
|
0 commit comments