Skip to content

Commit

Permalink
* Fix bug where two sub nodes that both have children were not being …
Browse files Browse the repository at this point in the history
…processed correctly

* Took off example usage since there is now an example page in docs/


git-svn-id: http://svn.php.net/repository/pear/packages/DB_NestedSet/trunk@126034 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Jason Rust committed May 6, 2003
1 parent 520c533 commit 3eb462f
Showing 1 changed file with 4 additions and 28 deletions.
32 changes: 4 additions & 28 deletions NestedSet/TreeMenu.php
Expand Up @@ -26,33 +26,8 @@
/**
* A helper class to translate the data from a nested set table into a HTML_TreeMenu object
* so that it can be used to create a dynamic tree menu using the PEAR HTML_TreeMenu class.
* An example usage:
* require_once('DB/NestedSet.php');
* require_once('DB/NestedSet/TreeMenu.php');
* $nestedSet =& DB_NestedSet::factory('DB', $dsn, $params);
* $icon = 'folder.gif';
* $expandedIcon = 'folder-expanded.gif';
* // get data (important to fetch it as an array, using the true flag)
* $data = $nestedSet->getAllNodes(true);
* // change the events for one of the elements
* $data[35]['events'] = array('onexpand' => 'alert("we expanded!");');
* // add links to each item
* foreach ($data as $a_data) {
* $a_data['link'] = 'http://foo.com/foo.php?' . $a_data['id'];
* }
* $params = array(
* 'structure' => $data,
* 'options' => array(
* 'icon' => $icon,
* 'expandedIcon' => $expandedIcon,
* ),
* 'textField' => 'name',
* 'linkField' => 'link',
* );
* $menu =& DB_NestedSet_TreeMenu::createFromStructure($params);
* $list =& HTML_TreeMenu_Listbox($menu);
* $list->toHtml();
*
* @see docs/TreeMenu_example.php
* @author Jason Rust <jrust@rustyparts.com>
* @package DB_NestedSet
* @version $Revision$
Expand Down Expand Up @@ -130,8 +105,9 @@ function &_createFromStructure($params)
// harvest all the children
foreach ($params['structure'] as $childKey => $childNode) {
if (!isset($childNode['hit']) &&
$node['rootid'] == $childNode['rootid'] &&
$childNode['level'] > $params['currentLevel']) {
$childNode['l'] > $node['l'] &&
$childNode['r'] < $node['r'] &&
$childNode['rootid'] == $node['rootid']) {
// important that we assign it by reference here, so that when the child
// marks itself 'hit' the parent loops will know
$children[] =& $params['structure'][$childKey];
Expand Down

0 comments on commit 3eb462f

Please sign in to comment.