function theme_ldap_query_results in Lightweight Directory Access Protocol (LDAP) 7.2
Same name and namespace in other branches
- 8.2 ldap_query/ldap_query.theme.inc \theme_ldap_query_results()
- 7 ldap_query/ldap_query.theme.inc \theme_ldap_query_results()
Parameters
$variables:
Return value
string
1 theme call to theme_ldap_query_results()
- ldap_query_test in ldap_query/
ldap_query.admin.inc
File
- ldap_query/
ldap_query.theme.inc, line 112 - Theming functions for ldap_query module.
Code
function theme_ldap_query_results($variables) {
// $ldap_query, $results, $show_query.
/** @var array $ldap_query */
/** @var array $results */
/** @var mixed $show_query */
extract($variables);
$query = theme('ldap_query', [
'ldap_query' => $ldap_query,
]);
$results_text = t('LDAP Query Results: count=%count', [
'%count' => $results['count'],
]);
if (!$results['count']) {
return $query . '<br/>' . $results_text;
}
$table = [
'header' => [
'DN',
],
'attributes' => [
'id' => 'ldap_query_resultset',
'class' => 'data',
],
'colgroups' => [],
'sticky' => FALSE,
'empty' => '',
'caption' => $results_text,
];
unset($results['count']);
$attributes_display = [];
// Searching on all attributes.
if (isset($results[0]) && $results[0]) {
foreach ($results[0] as $k => $v) {
if (is_numeric($k)) {
$attributes_display[] = $v;
}
}
}
foreach ($attributes_display as $attr) {
$table['header'][] = $attr;
}
foreach ($results as $i => $entry) {
$row = [
$entry['dn'],
];
foreach ($attributes_display as $i => $attr_name) {
// drupal_strtolower($attr_name);
$attr_name = ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_QUERY_ARRAY);
if (!isset($entry[$attr_name])) {
$row[] = 'no data';
}
elseif (is_array($entry[$attr_name])) {
unset($entry[$attr_name]['count']);
$row[] = join("<br/>", $entry[$attr_name]);
}
else {
$row[] = $entry[$attr_name];
}
}
unset($entry['count']);
$table['rows'][] = $row;
}
return $query . '<br/>' . theme_table($table);
}