responsive account table

This commit is contained in:
Roland Gruber 2018-10-28 13:55:30 +01:00
parent 985828da3a
commit 1935d3def8
2 changed files with 57 additions and 36 deletions

View File

@ -178,12 +178,10 @@ class lamDHCPList extends lamList {
} }
/** /**
* Prints the content of a cell in the account list for a given LDAP entry and attribute. * {@inheritDoc}
* * @see lamList::getTableCellContent()
* @param array $entry LDAP attributes
* @param string $attribute attribute name
*/ */
public function listPrintTableCellContent(&$entry, &$attribute) { public function getTableCellContent(&$entry, &$attribute) {
// Fixed IPs // Fixed IPs
if ($attribute=="fixed_ips") { if ($attribute=="fixed_ips") {
// find all fixed addresses: // find all fixed addresses:
@ -197,48 +195,59 @@ class lamDHCPList extends lamList {
$order[$i] = fixed_ip::extractIP($entries[$i]['dhcpstatements']); $order[$i] = fixed_ip::extractIP($entries[$i]['dhcpstatements']);
} }
} }
$group = new htmlGroup();
natcasesort($order); natcasesort($order);
echo "<table border=\"0\" width=\"100%\">"; for ($i = 0; $i < sizeof($order); $i++) {
foreach ($order as $i => $sortval) {
$dhcpstatements = array(); $dhcpstatements = array();
if (isset($entries[$i]['dhcpstatements'][0])) { if (isset($entries[$i]['dhcpstatements'][0])) {
$dhcpstatements = $entries[$i]['dhcpstatements']; $dhcpstatements = $entries[$i]['dhcpstatements'];
} }
$style = ''; $cssClasses = array('nowrap');
if (!fixed_ip::isActive($dhcpstatements)) { if (!fixed_ip::isActive($dhcpstatements)) {
$style = 'style="text-decoration: line-through;"'; $cssClasses[] = 'strike-through';
} }
echo "<tr " . $style . ">";
echo "<td width=\"25%\">" . fixed_ip::extractIP($dhcpstatements) . "</td>";
$dhcphwaddress = explode(" ",$entries[$i]['dhcphwaddress'][0]); $dhcphwaddress = explode(" ",$entries[$i]['dhcphwaddress'][0]);
echo "<td width=\"35%\">".array_pop($dhcphwaddress)."</td>"; $ipAddress = fixed_ip::extractIP($dhcpstatements);
echo "<td width=\"40%\">".$entries[$i]['cn'][0]."</td>"; $ip = new htmlOutputText($ipAddress);
echo "</tr>"; $ip->setCSSClasses($cssClasses);
$group->addElement($ip);
if (!empty($ipAddress)) {
$group->addElement(new htmlOutputText('<br>', false));
} }
echo "</table>"; $macAddress = array_pop($dhcphwaddress);
} $mac = new htmlOutputText($macAddress);
} $mac->setCSSClasses($cssClasses);
// fixed ip address $group->addElement($mac);
elseif ($attribute=="dhcpstatements") { if (!empty($macAddress)) {
// Search after the fixed ip entry $group->addElement(new htmlOutputText('<br>', false));
if (is_array($entry['dhcpstatements'])) { }
foreach($entry['dhcpstatements'] AS $id => $value) { $name = new htmlOutputText($entries[$i]['cn'][0]);
$name->setCSSClasses($cssClasses);
if (!is_array($value) && array_shift( explode(" ", $value) ) == "fixed-address") { $group->addElement($name);
$ip = explode(" ", $value); $group->addElement(new htmlOutputText('<br>', false));
echo $ip['1']; if ($i < (sizeof($order) - 1)) {
$group->addElement(new htmlOutputText('<br>', false));
} }
} }
return $group;
} }
} }
elseif ($attribute=="dhcprange") { // DHCP Range elseif ($attribute=="dhcprange") { // DHCP Range
if (isset($entry['dhcprange'])) { if (isset($entry['dhcprange'])) {
echo"<table cellspacing=\"0\">"; $table = new htmlTable();
$table->setCSSClasses(array('nowrap'));
$ranges = array(); $ranges = array();
foreach($entry['dhcprange'] AS $id => $value) { foreach($entry['dhcprange'] AS $id => $value) {
if (!empty($value) && !is_numeric($value)) { if (!empty($value) && !is_numeric($value)) {
$ex = explode(" ", $value); $ex = explode(" ", $value);
$ranges[] = "<tr><td>".$ex[0]."</td><td width=\"20\"><center>-</center></td><td>".$ex[1]."</td></tr>"; $row = new htmlTableRow(
array(
new htmlOutputText($ex[0]),
new htmlOutputText(' - '),
new htmlOutputText($ex[1])
)
);
$ranges[$ex[0] . ' - ' . $ex[1]] = $row;
} }
} }
$pooledRanges = searchLDAP($entry['dn'], '(objectclass=dhcpPool)', array('dhcprange')); $pooledRanges = searchLDAP($entry['dn'], '(objectclass=dhcpPool)', array('dhcprange'));
@ -249,18 +258,26 @@ class lamDHCPList extends lamList {
foreach($pool['dhcprange'] AS $id => $value) { foreach($pool['dhcprange'] AS $id => $value) {
if (!empty($value) && !is_numeric($value)) { if (!empty($value) && !is_numeric($value)) {
$ex = explode(" ", $value); $ex = explode(" ", $value);
$ranges[] = "<tr><td>".$ex[0]."</td><td width=\"20\"><center>-</center></td><td>".$ex[1]."</td></tr>"; $row = new htmlTableRow(
array(
new htmlOutputText($ex[0]),
new htmlOutputText(' - '),
new htmlOutputText($ex[1])
)
);
$ranges[$ex[0] . ' - ' . $ex[1]] = $row;
} }
} }
} }
natcasesort($ranges); uksort($ranges, 'strnatcasecmp');
echo implode('', $ranges); foreach ($ranges as $text => $row) {
echo"</table>"; $table->addElement($row);
}
return $table;
} }
} }
else else {
{ return parent::getTableCellContent($entry, $attribute);
parent::listPrintTableCellContent($entry, $attribute);
} }
} }

View File

@ -507,6 +507,10 @@ input.markOk {
.sortableList li { margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; } .sortableList li { margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; }
.sortableList li span { position: absolute; margin-left: -1.3em; } .sortableList li span { position: absolute; margin-left: -1.3em; }
.strike-through {
text-decoration: line-through;
}
/** /**
* table style for delete.php * table style for delete.php