function theme_ldap_query_results in Lightweight Directory Access Protocol (LDAP) 7
Same name and namespace in other branches
- 8.2 ldap_query/ldap_query.theme.inc \theme_ldap_query_results()
- 7.2 ldap_query/ldap_query.theme.inc \theme_ldap_query_results()
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 104 - theming functions for ldap_query module
Code
function theme_ldap_query_results($variables) {
extract($variables);
// $ldap_query, $results, $show_query
$query = theme('ldap_query', array(
'ldap_query' => $ldap_query,
));
$results_text = t('LDAP Query Results: count=%count', array(
'%count' => $results['count'],
));
if (!$results['count']) {
return $query . '<br/>' . $results_text;
}
$table = array(
'header' => array(
'DN',
),
'attributes' => array(
'id' => 'ldap_query_resultset',
'class' => 'data',
),
'colgroups' => array(),
'sticky' => FALSE,
'empty' => '',
'caption' => $results_text,
);
unset($results['count']);
$attributes_display = array();
if (isset($results[0]) && $results[0]) {
// searching on all attributes
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 = array(
$entry['dn'],
);
foreach ($attributes_display as $i => $attr_name) {
$attr_name = ldap_server_massage_text($attr_name, 'attr_name', LDAP_SERVER_MASSAGE_QUERY_ARRAY);
// drupal_strtolower($attr_name);
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($attr_data['count']);
}
unset($entry['count']);
$table['rows'][] = $row;
}
return $query . '<br/>' . theme_table($table);
}