Performance improvements for the tree.

This commit is contained in:
Deon George 2009-08-19 21:19:35 +10:00
parent 5669c92371
commit ebe2cb6eda
4 changed files with 16 additions and 8 deletions

View File

@ -149,7 +149,10 @@ class AJAXTree extends HTMLTree {
debug_log('Entered (%%)',33,0,__FILE__,__LINE__,__METHOD__,$fargs);
$children = array();
foreach ($parent_entry->getChildren() as $child) {
$pchildren = $parent_entry->getChildren();
usort($pchildren,'pla_compare_dns');
foreach ($pchildren as $child) {
if (! $this->getEntry($child))
$this->addEntry($child);

View File

@ -261,11 +261,13 @@ function hideall(key,except) {
echo "\n\n";
$this->drawBaseTabs();
$ado = $this->template->getAttrDisplayOrder();
switch(get_request('format','REQUEST',false,'table')) {
case 'list':
$counter = 0;
foreach ($this->template->results as $base => $results) {
if (! $show = get_request('show','REQUEST'))
$show = ($counter++ === 0 ? $this->getAjaxRef($base) : null);
@ -303,7 +305,7 @@ function hideall(key,except) {
htmlspecialchars(dn_unescape($dn)));
# Iterate over each attribute for this entry
foreach (explode(',',$this->template->getAttrDisplayOrder()) as $attr) {
foreach (explode(',',$ado) as $attr) {
# Ignore DN, we've already displayed it.
if ($attr == 'dn')
continue;
@ -387,7 +389,7 @@ function hideall(key,except) {
echo '<td>&nbsp;</td>';
echo '<td>&nbsp;</td>';
foreach (explode(',',$this->template->getAttrDisplayOrder()) as $attr) {
foreach (explode(',',$ado) as $attr) {
echo '<td>';
$this->draw('Name',$afattrs[$attr]);
echo '</td>';
@ -418,7 +420,7 @@ function hideall(key,except) {
IMGDIR,get_icon($server->getIndex(),$dn));
# We'll clone our attribute factory attributes, since we need to add the values to them for rendering.
foreach (explode(',',$this->template->getAttrDisplayOrder()) as $attr) {
foreach (explode(',',$ado) as $attr) {
# If the entry is blank, we'll draw an empty box and continue.
if (! isset($dndetails[$attr])) {
echo '<td>&nbsp;</td>';
@ -454,7 +456,7 @@ function hideall(key,except) {
if ($_SESSION[APPCONFIG]->getValue('mass','enabled')) {
printf('<tr class="%s">',++$counter%2 ? 'odd' : 'even',$counter);
echo '<td><input type="checkbox" name="allbox" value="1" onclick="CheckAll(1);" /></td>';
printf('<td colspan=%s>',2+count(explode(',',$this->template->getAttrDisplayOrder())));
printf('<td colspan=%s>',2+count(explode(',',$ado)));
echo '<select name="cmd" onChange="if (this.value) submit();" style="font-size: 12px">';
foreach ($mass_actions as $action => $display)
printf('<option value="%s">%s</option>',$display,$action);

View File

@ -167,8 +167,9 @@ abstract class Tree {
$server = $this->getServer();
$dnlower = $this->indexDN($dn);
if (! ($server->dnExists($dn)))
return;
# @todo Temporarily removed, some non-ascii char DNs that do exist, fail here for some reason?
#if (! ($server->dnExists($dn)))
# return;
if (isset($this->entries[$dnlower]))
debug_dump_backtrace('Calling add entry to an entry that ALREADY exists?',1);
@ -179,6 +180,9 @@ abstract class Tree {
$tree_factory = new TreeItem($server->getIndex(),$dn);
$tree_factory->setObjectClasses($server->getDNAttrValue($dn,'objectClass'));
if ((($isleaf = $server->getDNAttrValue($dn,'hassubordinates')) && ! strcasecmp($isleaf[0],'false')) || ! $isleaf)
$tree_factory->setLeaf();
$this->entries[$dnlower] = $tree_factory;
# Is this entry in a base entry?

View File

@ -133,7 +133,6 @@ class TreeItem {
return;
array_push($this->children,$dn);
usort($this->children,'pla_compare_dns');
}
/**