Author: david
Date: Mon Oct 19 13:25:14 2009
New Revision: 3768
Log:
Optimize treeview for large datasets (see issue #1068).
Modified:
trunk/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
Modified:
trunk/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
==============================================================================
---
trunk/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
Mon Oct 19 00:02:50 2009 (r3767)
+++
trunk/apps/qubit/modules/informationobject/actions/contextMenuComponent.class.php
Mon Oct 19 13:25:14 2009 (r3768)
@@ -37,15 +37,14 @@
// Get info object tree
$this->informationObjects = null;
- if ($this->informationObject->getId())
+ if (isset($this->informationObject->id))
{
- $ancestors = $this->informationObject->getAncestors()->orderBy('lft');
+ $ancestors =
$this->informationObject->getAncestors()->andSelf()->orderBy('lft');
foreach ($ancestors as $ancestor)
{
$path[] = $ancestor->getId();
}
- $informationObjects =
$this->buildInformationObjectTree($ancestors->offsetGet(0), $path);
-
+ $informationObjects = $this->buildInformationObjectTree($path);
if (0 < count($informationObjects))
{
$this->informationObjects = $informationObjects;
@@ -148,32 +147,30 @@
}
}
- protected function buildInformationObjectTree($ancestor, $path)
+ protected function buildInformationObjectTree($path)
{
$tmp = array();
+ $parent = QubitInformationObject::getById(array_shift($path));
- foreach ($ancestor->getChildren(array('sortBy' =>
sfConfig::get('app_sort_treeview_informationobject'))) as $child)
+ // skip the root node
+ if (QubitInformationObject::ROOT_ID == $parent->id)
+ {
+ $tmp = array_merge($tmp, $this->buildInformationObjectTree($path));
+ }
+ else
{
- // If ancestor is not the empty root node
- // Or it children is in $path
- // Or it children is the selected information object
- if (QubitInformationObject::ROOT_ID != $ancestor->getId() ||
in_array($child->getId(), $path) || $child->getId() ==
$this->informationObject->getId())
+ $tmp[] = $parent;
+ foreach ($parent->getChildren(array('sortBy' =>
sfConfig::get('app_sort_treeview_informationobject'))) as $child)
{
- // Add the children
- $tmp[] = $child;
-
// If it in path, we go on building the tree in that way
if (in_array($child->getId(), $path))
{
- $tmp = array_merge($tmp, $this->buildInformationObjectTree($child,
$path));
+ $tmp = array_merge($tmp, $this->buildInformationObjectTree($path));
}
- // If it is the selected information object, add it children
- else if ($child->getId() == $this->informationObject->getId())
+ else
{
- foreach ($child->getChildren(array('sortBy' =>
sfConfig::get('app_sort_treeview_informationobject'))) as $ch)
- {
- $tmp[] = $ch;
- }
+ // Add the child
+ $tmp[] = $child;
}
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---