<?
/*
Display a grid of entries from an array
this code is a module, it will probably not work when not included by a page.
parameters required are:
@in $items array items list, a simple array ( integer indices from 0 to array size )
@in $offset integer index of the first item to display
@in $listsize integer number of items to display on the grid
@TODO : finish the modularization
*/
$minbound = $offset + 1;
$maxbound = $offset + $listsize;
echo '<div align=center>';
echo '<TABLE cellspacing=0 style="padding: 4px; width:96%">',
"<tr>",
"<td align=left width=100>$urlPrevPage</td>",
"<th align=center>", "$entries_count results - Displaying $minbound - $maxbound ", "</th>",
"<td align=right width=100>$urlFullResults</td>",
"<td align=right width=100>$urlNextPage</td>",
"</tr>",
"</table>";
echo '<TABLE cellspacing=0 style="border: 1px solid gray; width:96%">',
"<tr>",
"<th width=20 class=grid>", " ", "</th>\n", // icon column
"<th class=grid>", "Name", "</th>\n",
"<th class=grid>", "Description", "</th>\n",
"<th class=grid>", "Service", "</th>\n",
"<th class=grid>", "Email", "</th>\n",
"</tr>\n";
while( $cnt++ < $listsize ) {
$item = get_ldap_object( $items[$offset] );
if( $offset % 2 )
$bgcolor = "bgcolor=#CCCCF0";
else
$bgcolor = "";
$icon = smartIcon( $item['objectclass'] );
// choix du champ a afficher comme "Nom"
if( $item['cn'] )
$commonname = $item['cn'][0];
elseif( $item['ou'] )
$commonname = $item['ou'][0];
else {
list( $commonname, $dummy ) = ldap_explode_dn( $item['dn'], 0 );
}
$encdn = urlencode($item['dn']);
$tooltip = utf8_decode($item['dn']); // @TODO : escape " char
$mail = attributeFormat( 'mail', $item['mail'][0] );
echo "<TR $bgcolor>";
echo "<TD class=\"grid\">", "<img src=\"img/$icon\" border=0>", "</TD>\n";
echo "<TD class=\"grid\"><a title=\"$tooltip\" href=\"submit.php?A=entry.properties&dn=$encdn&prevURL=$prevURL\">" .
$commonname . "</a></TD>\n";
echo "<TD class=\"grid\">", $item['description'][0], " </TD>\n";
echo "<TD class=\"grid\">", $item['ou'][0], " </TD>\n";
echo "<TD class=\"grid\">", $mail, " </TD>\n";
echo "</TR>\n";
$offset ++;
}
echo "</table></div>\n";
?>