Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
c37caf00
Commit
c37caf00
authored
8 years ago
by
Jaime Pérez
Browse files
Options
Downloads
Patches
Plain Diff
Reformat code of the table-printing template.
parent
6cbc9945
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
templates/includes/attributes.php
+104
-97
104 additions, 97 deletions
templates/includes/attributes.php
with
104 additions
and
97 deletions
templates/includes/attributes.php
+
104
−
97
View file @
c37caf00
...
...
@@ -3,108 +3,115 @@
* Functions used to present a table of attributes and their values.
*/
function
present_list
(
$attr
)
{
if
(
is_array
(
$attr
)
&&
count
(
$attr
)
>
1
)
{
$str
=
'<ul>'
;
foreach
(
$attr
as
$value
)
{
$str
.
=
'<li>'
.
htmlspecialchars
(
$attr
)
.
'</li>'
;
}
$str
.
=
'</ul>'
;
return
$str
;
}
else
{
return
htmlspecialchars
(
$attr
[
0
]);
}
function
present_list
(
$attr
)
{
if
(
is_array
(
$attr
)
&&
count
(
$attr
)
>
1
)
{
$str
=
'<ul>'
;
foreach
(
$attr
as
$value
)
{
$str
.
=
'<li>'
.
htmlspecialchars
(
$attr
)
.
'</li>'
;
}
$str
.
=
'</ul>'
;
return
$str
;
}
else
{
return
htmlspecialchars
(
$attr
[
0
]);
}
}
function
present_assoc
(
$attr
)
{
if
(
is_array
(
$attr
))
{
$str
=
'<dl>'
;
foreach
(
$attr
AS
$key
=>
$value
)
{
$str
.
=
"
\n
"
.
'<dt>'
.
htmlspecialchars
(
$key
)
.
'</dt><dd>'
.
present_list
(
$value
)
.
'</dd>'
;
}
$str
.
=
'</dl>'
;
return
$str
;
}
else
{
return
htmlspecialchars
(
$attr
);
}
function
present_assoc
(
$attr
)
{
if
(
is_array
(
$attr
))
{
$str
=
'<dl>'
;
foreach
(
$attr
as
$key
=>
$value
)
{
$str
.
=
"
\n
"
.
'<dt>'
.
htmlspecialchars
(
$key
)
.
'</dt><dd>'
.
present_list
(
$value
)
.
'</dd>'
;
}
$str
.
=
'</dl>'
;
return
$str
;
}
else
{
return
htmlspecialchars
(
$attr
);
}
}
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">'
;
function
present_attributes
(
SimpleSAML_XHTML_Template
$t
,
$attributes
,
$nameParent
)
{
$alternate
=
array
(
'odd'
,
'even'
);
$i
=
0
;
foreach
(
$attributes
as
$name
=>
$value
)
{
$nameraw
=
$name
;
$name
=
$t
->
getTranslator
()
->
getAttributeTranslation
(
$parentStr
.
$nameraw
);
$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">'
;
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">'
;
foreach
(
$attributes
as
$name
=>
$value
)
{
$nameraw
=
$name
;
$name
=
$t
->
getTranslator
()
->
getAttributeTranslation
(
$parentStr
.
$nameraw
);
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
;
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
/** @var DOMNodeList $value[0] */
$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
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment