Source for file DBMS_SIMPLETREE.phpclass
Documentation is available at DBMS_SIMPLETREE.phpclass
* openCSP class file DBMS_SIMPLETREE.phpclass
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: DBMS_SIMPLETREE.phpclass,v 1.1 2008/12/04 16:45:40 peterkrebs Exp $
// ---------------------------------------------------------
// ---------------------------------------------------------
* openCSP class DBMS_SIMPLETREE
* a single table with an integer parent field
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: DBMS_SIMPLETREE.phpclass,v 1.1 2008/12/04 16:45:40 peterkrebs Exp $
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* @constant string CLASS_SRC_FILE
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** class vars ------------------------------------------------------ */
/*abstract*/ protected static $myTreeClass =
"";
/*abstract*/ protected static $myTreeTable =
"";
/*abstract*/ protected static $myTreeIndexCol =
"";
/*abstract*/ protected static $myTreeParentCol =
"";
/*abstract*/ protected static $myTreeSort =
"";
protected static $myTreeRootId =
0;
protected static $myTreeCache =
array();
protected static $myTreePopulateTS =
array();
/*** class methods ------------------------------------------------------ */
* returns if the tree is already populated
return (isset
($myTreePopulateTS[self::$myTreeTable]));
* @param array $arr_filter ('KEY' => value pairs)
* @return int (number of loaded nodes)
public static function populateTree($filter=
Null,$debug=
False)
if ($debug) echoDebugMethod(__FILE__
,"static","DBMS_SIMPLETREE::populateTree()",self::$myTreeTable);
$str_sort =
self::$myTreeParentCol .
(!empty(self::$myTreeSort) ?
"," .
self::$myTreeSort :
"");
self::$myTreeCache[self::$myTreeTable] =
array();
self::getInstance(self::$myTreeRootId);
if ($arr_children =
OCSP_OBJ::defaultReadDBObj()->getArray(self::$myTreeTable,$filter,0,0,$str_sort))
foreach($arr_children as $arr_row)
$obj_node =
self::factoryFromDBRow($arr_row);
self::$myTreeCache[self::$myTreeTable][$obj_node->getId()]['NODE'] =
$obj_node;
self::$myTreeCache[self::$myTreeTable][$obj_node->getParentId()]['CHILDREN'][] =
$obj_node->getId();
$myTreePopulateTS[self::$myTreeTable] =
$filter;
return self::getRootNode();
* returns the instance with id $aId
* if the instance has not been loaded factoryFromId is called
* @return DBMS_SIMPLETREE
if (!isset
(self::$myTreeCache[self::$myTreeTable][intval($aId)]))
if ($obj_node =
self::factoryFromId(intval($aId)))
self::$myTreeCache[self::$myTreeTable][intval($aId)]['NODE'] =
$obj_node;
if (!$obj_node->isRoot())
self::$myTreeCache[self::$myTreeTable][$obj_node->getParentId()]['CHILDREN'][] =
$obj_node;
return self::$myTreeCache[self::$myTreeTable][intval($aId)];
* @return DMBS_SIMPLETREE
return self::getInstance(self::$myTreeRootId);
* returns an array with all populated instances
if (is_array(self::$myTreeCache[self::$myTreeTable]))
foreach(self::$myTreeCache[self::$myTreeTable] as $int_id =>
$arr_nodes)
$arr_ret[$int_id] =
&$arr_nodes['NODE'];
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** compostion --------------------------------------------------- */
/*** attributes -------------------------------------------------- */
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* @return DBMS_SIMPLETREE
* @return DBMS_SIMPLETREE
* sets the table name for DBMS_TABLEOBJ
* @param boolean $noCache
function init($debug=
False,$noCache=
False)
if ($debug) echoDebugMethod(__FILE__
,get_class($this),"DBMS_SIMPLETREE::init()",self::$myTreeTable);
$this->myTable =
self::$myTreeTable;
parent::init($debug,$noCache);
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
return intval($this->getDBField(self::$myTreeParentCol));
* returns if the node is the root node
return ($this->getId() ==
self::$myTreeRootId);
Documentation generated on Thu, 08 Jan 2009 17:43:42 +0100 by phpDocumentor 1.4.0a2