当前位置: 首页>>代码示例>>PHP>>正文


PHP SimpleSAML_XHTML_Template::getTranslator方法代码示例

本文整理汇总了PHP中SimpleSAML_XHTML_Template::getTranslator方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleSAML_XHTML_Template::getTranslator方法的具体用法?PHP SimpleSAML_XHTML_Template::getTranslator怎么用?PHP SimpleSAML_XHTML_Template::getTranslator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleSAML_XHTML_Template的用法示例。


在下文中一共展示了SimpleSAML_XHTML_Template::getTranslator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: present_attributes

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;
}
开发者ID:mrvanes,项目名称:simplesamlphp,代码行数:49,代码来源:attributes.php

示例2: present_attributes

/**
 * 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;
}
开发者ID:mrvanes,项目名称:simplesamlphp,代码行数:80,代码来源:consentform.php

示例3: array

    $template = new SimpleSAML_XHTML_Template($config, 'consentAdmin:consentadminajax.php', 'consentAdmin:consentadmin');
    $template->data['res'] = $res;
    $template->show();
    exit;
}
// Get all consents for user
$user_consent_list = $consent_storage->getConsents($hashed_user_id);
// Parse list of consents
$user_consent = array();
foreach ($user_consent_list as $c) {
    $user_consent[$c[0]] = $c[1];
}
$template_sp_content = array();
// Init template
$template = new SimpleSAML_XHTML_Template($config, 'consentAdmin:consentadmin.php', 'consentAdmin:consentadmin');
$translator = $template->getTranslator();
$sp_empty_name = $translator->getTag('sp_empty_name');
$sp_empty_description = $translator->getTag('sp_empty_description');
// Process consents for all SP
foreach ($all_sp_metadata as $sp_entityid => $sp_values) {
    // Get metadata for SP
    $sp_metadata = $metadata->getMetaData($sp_entityid, 'saml20-sp-remote');
    // Run attribute filters
    list($targeted_id, $attribute_hash, $attributes_new) = driveProcessingChain($idp_metadata, $source, $sp_metadata, $sp_entityid, $attributes, $userid, $hashAttributes);
    // Check if consent exists
    if (array_key_exists($targeted_id, $user_consent)) {
        $sp_status = "changed";
        SimpleSAML\Logger::info('consentAdmin: changed');
        // Check if consent is valid. (Possible that attributes has changed)
        if ($user_consent[$targeted_id] == $attribute_hash) {
            SimpleSAML\Logger::info('consentAdmin: ok');
开发者ID:SysBind,项目名称:simplesamlphp,代码行数:31,代码来源:consentAdmin.php

示例4: present_attributes

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;
}
开发者ID:simplesamlphp,项目名称:simplesamlphp,代码行数:75,代码来源:attributes.php


注:本文中的SimpleSAML_XHTML_Template::getTranslator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。