You are here

class uc_treeNode in Ubercart 5

Data structure to mimic Drupal's menu system.

Hierarchy

Expanded class hierarchy of uc_treeNode

File

uc_catalog/uc_catalog.module, line 18
Übercart Catalog module.

View source
class uc_treeNode {
  var $tid = 0;
  var $name = 'Catalog';
  var $children = array();
  var $depth = -1;
  var $sequence = 0;
  function uc_treeNode($term = null) {
    if ($term) {
      $this->tid = $term->tid;
      $this->name = $term->name;
      $this->depth = $term->depth;
      $this->sequence = $term->sequence;
    }
  }

  /**
   * Determines if new child is an immediate descendant or not.
   *
   * This function is completely dependent on the structure of the array returned
   * by taxonomy_get_tree(). Each element in the array knows it's depth in the tree
   * and the array is a preorder iteration of the logical tree structure. Therefore,
   * if the parameter is more than one level deeper than $this, it should be passed
   * to the last child of $this.
   */
  function add_child(&$child) {
    if ($child->depth - $this->depth == 1) {
      $this->children[] = $child;
    }
    else {
      $last_child =& $this->children[count($this->children) - 1];
      $last_child
        ->add_child($child);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
uc_treeNode::$children property
uc_treeNode::$depth property
uc_treeNode::$name property
uc_treeNode::$sequence property
uc_treeNode::$tid property
uc_treeNode::add_child function Determines if new child is an immediate descendant or not.
uc_treeNode::uc_treeNode function