You are here

function theme_ldap_query in Lightweight Directory Access Protocol (LDAP) 7.2

Same name and namespace in other branches
  1. 8.2 ldap_query/ldap_query.theme.inc \theme_ldap_query()
  2. 7 ldap_query/ldap_query.theme.inc \theme_ldap_query()

Returns HTML for ldap server.

Parameters

$variables: An associative array containing:

  • ldap_query_config: an array of one or more ldap server configurations.
  • actions: true or false indicating include update, delete, etc. links
  • type: 'table', 'list', etc for style to render

Return value

string

3 theme calls to theme_ldap_query()
ldap_query_admin_delete in ldap_query/ldap_query.admin.inc
Implements the LDAP query delete page.
ldap_query_admin_enable_disable in ldap_query/ldap_query.admin.inc
Implements the LDAP query disable.
theme_ldap_query_results in ldap_query/ldap_query.theme.inc

File

ldap_query/ldap_query.theme.inc, line 75
Theming functions for ldap_query module.

Code

function theme_ldap_query($variables) {

  /** @var array $ldap_query */

  /** @var bool $actions */

  /** @var string $type */
  extract($variables);
  ldap_servers_module_load_include('php', 'ldap_query', 'LdapQuery.class');
  $properties = [];
  foreach (LdapQuery::fields() as $field_id => $field) {
    $value = $ldap_query->{$field['property_name']};
    if (is_scalar($value)) {
      $properties[] = $field_id . " = " . $value;
    }
  }
  if ($actions) {
    $admin = new LdapQueryAdmin($ldap_query->sid);
    $properties = join(' | ', $admin
      ->getActions());
  }
  $output = theme_item_list([
    'items' => $properties,
    'type' => 'ul',
    'title' => 'Query Properties',
    'attributes' => [],
  ]);
  return $output;
}