Exemplo n.º 1
0
function present_attributes(SimpleSAML_XHTML_Template $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->getTranslator()->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;
}
Exemplo n.º 2
0
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">' : '<table id="table_with_attributes"  class="attributes">';
    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)) {
            $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">' . htmlspecialchars($name) . '</td><td class="attrvalue"><ul>';
                foreach ($value as $listitem) {
                    if ($nameraw === 'jpegPhoto') {
                        $str .= '<li><img src="data:image/jpeg;base64,' . $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">' . htmlspecialchars($name) . '</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;
}
Exemplo n.º 3
0
function present_attributes(SimpleSAML_XHTML_Template $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->getTranslator()->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>';
                } elseif (is_a($value[0], 'DOMNodeList')) {
                    // try to see if we have a NameID here
                    $n = $value[0]->length;
                    for ($idx = 0; $idx < $n; $idx++) {
                        $elem = $value[0]->item($idx);
                        /* @var DOMElement $elem */
                        if (!($elem->localName === 'NameID' && $elem->namespaceURI === \SAML2\Constants::NS_SAML)) {
                            continue;
                        }
                        $nameID = new \SAML2\XML\saml\NameID($elem);
                        $eptid = array('NameID' => array($nameID->value));
                        if (!empty($nameID->Format)) {
                            $eptid['Format'] = array($nameID->Format);
                        }
                        if (!empty($nameID->NameQualifier)) {
                            $eptid['NameQualifier'] = array($nameID->NameQualifier);
                        }
                        if (!empty($nameID->SPNameQualifier)) {
                            $eptid['SPNameQualifier'] = array($nameID->SPNameQualifier);
                        }
                        $str .= '<td class="attrvalue">';
                        $str .= present_assoc($eptid);
                        break;
                        // we only support one NameID here
                    }
                    $str .= '</td></tr>';
                } else {
                    $str .= '<td class="attrvalue">' . htmlspecialchars($value[0]) . '</td></tr>';
                }
            }
        }
        $str .= "\n";
    }
    $str .= '</table>';
    return $str;
}