function theme_ldap_server_ldap_entry_table in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_servers/ldap_servers.theme.inc \theme_ldap_server_ldap_entry_table()
- 7 ldap_servers/ldap_servers.theme.inc \theme_ldap_server_ldap_entry_table()
2 theme calls to theme_ldap_server_ldap_entry_table()
- ldap_servers_test_form in ldap_servers/
ldap_servers.test_form.inc - Implements the LDAP server test page.
- ldap_servers_token_show_sample_user_tokens in ldap_servers/
ldap_servers.tokens.inc
File
- ldap_servers/
ldap_servers.theme.inc, line 125 - Theming functions for ldap_servers module.
Code
function theme_ldap_server_ldap_entry_table($variables) {
if (!isset($variables['entry']) || !is_array($variables['entry'])) {
return '<p>' . t('No Entry Returned.') . t('</p>');
}
$header = [
'Attribute Name',
'Instance',
'Value',
'token',
];
$rows = [];
foreach ($variables['entry'] as $key => $value) {
if (is_numeric($key) || $key == 'count') {
}
elseif (is_array($value) && count($value) > 1) {
$count = (int) $value['count'];
foreach ($value as $i => $value2) {
if ((string) $i == 'count') {
continue;
}
elseif ($i == 0 && $count == 1) {
$token = LDAP_SERVERS_TOKEN_PRE . $key . LDAP_SERVERS_TOKEN_POST;
}
elseif ($i == 0 && $count > 1) {
$token = LDAP_SERVERS_TOKEN_PRE . $key . LDAP_SERVERS_TOKEN_DEL . '0' . LDAP_SERVERS_TOKEN_POST;
}
elseif ($i == $count - 1 && $count > 1) {
$token = LDAP_SERVERS_TOKEN_PRE . $key . LDAP_SERVERS_TOKEN_DEL . 'last' . LDAP_SERVERS_TOKEN_POST;
}
elseif ($count > 1) {
$token = LDAP_SERVERS_TOKEN_PRE . $key . LDAP_SERVERS_TOKEN_DEL . $i . LDAP_SERVERS_TOKEN_POST;
}
else {
$token = "";
}
$rows[] = [
'data' => [
$key,
$i,
ldap_servers_string_binary_check($value2),
$token,
],
];
}
}
}
$heading = sprintf('<h2>%s</h2>', t('LDAP Entry for %username (dn: %dn)', [
'%dn' => $variables['dn'],
'%username' => $variables['username'],
]));
$table = theme('table', [
'colgroups' => NULL,
'caption' => 'ldap entry array',
'header' => $header,
'rows' => $rows,
'sticky' => TRUE,
'attributes' => [],
'empty' => 'No data',
]);
$entry_table = '<div class="content">' . $heading . $table . '</div>';
return $entry_table;
}