Location: PHPKode > projects > Content*Builder > contentbuilder/lib/CB_NestedSet_Common.class.php
<?php

/**
 * 
 *
 * @version $Id: CB_NestedSet_Common.class.php,v 1.1 2004/03/29 22:45:31 cb_fog Exp $
 * @copyright 2003 
 **/

class CB_NestedSet_Common {
	/*
	* @var array $data Daten von getAllNodes()
	* @access private
	*/
	var $data = array();
	
	/*
	* @var array $structure Geordnete Struktur 
	* @access private
	*/
	var $structure = array();
	
	/* 
	* Konstruktor
	* Nimmt Daten von DB_NestedSet::getAllNodes() entgegen
	* 
	* @param $data Struktur von getAllNodes()
	*/
	function & CB_NestedSet_Common($data) {
		if(is_array($data)) {
			$this->data = $data;
			return true;
		} else {
			return false;
		}
	}
	
	function getTree() {
		foreach($this->data as $key => $value) {
			$this->tempData[$value['rootid']][$key] = $value;
		}
		$this->_createFromStructure();
		return $this->structure;
	}
	
	function _createFromStructure() {
		if(is_array($this->tempData)) {
			foreach($this->tempData as $key => $value) {
				foreach($value as $v) {
					$this->structure[] = $v;
				}
			}
		}
	}
}

?>
Return current item: Content*Builder