You are here

function theme_ldap_server_ldap_entry_table in Lightweight Directory Access Protocol (LDAP) 7

Same name and namespace in other branches
  1. 8.2 ldap_servers/ldap_servers.theme.inc \theme_ldap_server_ldap_entry_table()
  2. 7.2 ldap_servers/ldap_servers.theme.inc \theme_ldap_server_ldap_entry_table()
2 theme calls to theme_ldap_server_ldap_entry_table()
ldap_servers_show_sample_user_tokens in ldap_servers/ldap_servers.functions.inc
ldap_servers_test_form in ldap_servers/ldap_servers.test_form.inc
Implements the LDAP server test page.

File

ldap_servers/ldap_servers.theme.inc, line 126
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 = array(
    'Attribute Name',
    'Instance',
    'Value',
    'token',
  );
  $rows = array();
  foreach ($variables['entry'] as $key => $value) {
    if (is_numeric($key) || $key == 'count') {
    }
    elseif (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[] = array(
          'data' => array(
            $key,
            $i,
            $value2,
            $token,
          ),
        );
      }
    }
  }
  $entry_table = '<div class="content"><h2>' . t('LDAP Entry for %username', array(
    '%username' => $variables['username'],
  )) . '</h2>' . theme('table', array(
    'colgroups' => NULL,
    'caption' => 'ldap entry array',
    'header' => $header,
    'rows' => $rows,
    'sticky' => TRUE,
    'attributes' => array(),
    'empty' => 'No data',
  )) . '</div>';
  return $entry_table;
}