You are here

class UcTreeNode in Ubercart 7.3

Same name and namespace in other branches
  1. 6.2 uc_catalog/uc_catalog.module \UcTreeNode

Data structure to mimic Drupal's menu system.

Hierarchy

Expanded class hierarchy of UcTreeNode

File

uc_catalog/classes/treenode.inc, line 11
Utility classes for catalog module.

View source
class UcTreeNode {
  public $tid = 0;
  public $name = 'Catalog';
  public $children = array();
  public $depth = -1;
  public $sequence = 0;

  /**
   * Constructor.
   */
  public function __construct($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 its
   * 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.
   */
  public 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
UcTreeNode::$children public property
UcTreeNode::$depth public property
UcTreeNode::$name public property
UcTreeNode::$sequence public property
UcTreeNode::$tid public property
UcTreeNode::add_child public function Determines if new child is an immediate descendant or not.
UcTreeNode::__construct public function Constructor.