static public printCleanArray ( $tab, $pad, $jsexpand = false ) : nothing | ||
$tab | the array to display | |
$pad | Pad used (default 0) | |
$jsexpand | Expand using JS ? (default false) | |
return | nothing |
static function printCleanArray($tab, $pad = 0, $jsexpand = false)
{
if (count($tab)) {
echo "<table class='tab_cadre'>";
// For debug / no gettext
echo "<tr><th>KEY</th><th>=></th><th>VALUE</th></tr>";
foreach ($tab as $key => $val) {
echo "<tr class='tab_bg_1'><td class='top right'>";
echo $key;
$is_array = is_array($val);
$rand = mt_rand();
echo "</td><td class='top'>";
if ($jsexpand && $is_array) {
echo "<a class='pointer' href=\"javascript:showHideDiv('content{$key}{$rand}','','','')\">";
echo "=></a>";
} else {
echo "=>";
}
echo "</td><td class='top tab_bg_1'>";
if ($is_array) {
echo "<div id='content{$key}{$rand}' " . ($jsexpand ? "style=\"display:none;\"" : '') . ">";
self::printCleanArray($val, $pad + 1);
echo "</div>";
} else {
if (is_bool($val)) {
if ($val) {
echo 'true';
} else {
echo 'false';
}
} else {
if (is_object($val)) {
print_r($val);
} else {
echo htmlentities($val);
}
}
}
echo "</td></tr>";
}
echo "</table>";
} else {
_e('Empty array');
}
}
/** * Display information from LDAP server for user **/ private function showLdapDebug() { if ($this->fields['authtype'] != Auth::LDAP) { return false; } echo "<div class='spaced'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . __('LDAP directory') . "</th></tr>"; echo "<tr class='tab_bg_2'><td>" . __('User DN') . "</td>"; echo "<td>" . $this->fields['user_dn'] . "</td></tr>\n"; if ($this->fields['user_dn']) { echo "<tr class='tab_bg_2'><td>" . __('User information') . "</td><td>"; $config_ldap = new AuthLDAP(); $ds = false; if ($config_ldap->getFromDB($this->fields['auths_id'])) { $ds = $config_ldap->connect(); } if ($ds) { $info = AuthLdap::getUserByDn($ds, $this->fields['user_dn'], array('*', 'createTimeStamp', 'modifyTimestamp')); if (is_array($info)) { Html::printCleanArray($info); } else { _e('No item to display'); } } else { _e('Connection failed'); } echo "</td></tr>\n"; } echo "</table></div>"; }