Source for file CMS_MENU.phpclass
Documentation is available at CMS_MENU.phpclass
* openCSP class file CMS_MENU.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: CMS_MENU.phpclass,v 1.10 2008/11/24 23:30:33 pitlinz Exp $
// ---------------------------------------------------------
// ---------------------------------------------------------
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: CMS_MENU.phpclass,v 1.10 2008/11/24 23:30:33 pitlinz Exp $
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* @constant string CLASS_SRC_FILE
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** class vars ------------------------------------------------------ */
* @staticvar CMS_MENU $myInstance
protected static $loadedMenus =
array();
/*** class methods ---------------------------------------------- */
* returns the singleton instance
self::$loadedMenus[$projId] =
new CMS_MENU();
return self::$loadedMenus[$projId];
* returns an array with all available node classes
//"SELECT MEN_OBJCLASS,MET_TITLE FROM T_CMS_MENUTYPE ORDER BY MET_ISDEFAULT DESC"
if ($arr_row =
OCSP_OBJ::defaultReadDBObj()->getArray('T_CMS_MENUTYPE',Null,0,0,"MET_ISDEFAULT DESC,MET_TITLE"))
$arr_ret[$arr_row['MEN_OBJCLASS']] =
$arr_row;
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** compostion --------------------------------------------------- */
* array(key = array($key => node))
* @var array $nodeChildKeys
* array of the first level children
* @var array $myFirstLevelChildren
* @var CMS_PROJECT $myProject
/*** attributes -------------------------------------------------- */
* the root Id in T_CMS_MENU
/*** factory / construct ----------------------------------------- */
/*** getter / setter ---------------------------------------------- */
* returns the project object
* @param CMS_PROJECT $aProject
/*** node get/factory methods ------------------------------------- */
* returns the menu node with key $aKey
* a key can be seperated with '-'
* @param boolean $forceObj
public function &getNode($aKey,$forceObj=
False,$debug=
False)
if (empty($aKey) &&
(!$forceObj))
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"returning already loaded node");
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"returning node from cache row");
$arr_childKeys =
explode("-",$aKey);
$int_menId =
$arr_childKeys[0];
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"key array: <pre>" .
print_r($arr_childKeys,True) .
"</pre>");
$bol_storeToCache =
False;
$bol_storeToCache =
True;
break; // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$this->myNodes[$int_menId]->setTreeObj($this);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"returning CMS Menu " .
$int_menId .
" Node for key: " .
$aKey);
$this->myNodes[$aKey] =
$this->myNodes[$int_menId]->factoryChildNode($aKey,$debug);
$this->myNodes[$aKey]->setTreeObj($this);
$str_cmd =
"\$obj_node = new " .
$arr_menRow['MEN_OBJCLASS'] .
"();";
$obj_node->setTreeObj($this);
$obj_node->setParentObj($this->myNodes[$int_menId]);
$this->myNodes[$aKey]->setTreeObj($this);
if ($mix_key =
$aNode->getKey())
* returns the menu node from $_GET
* faktories a node form a dbRow
* @param boolean $forceOverload
public function &getNodeFromRow($nodeRow,$forceOverload=
False,$debug=
False)
$str_cmd =
"\$obj_node = new " .
$nodeRow['MEN_OBJCLASS'] .
"();";
if ($debug) echoDebugLine(__FILE__
,__LINE__
, $str_cmd .
"<p style=\"font-size:75%\">" .
print_r($nodeRow,True) .
"</p>");
$obj_node->setTreeObj($this);
$obj_node->setDBRow($nodeRow,True);
if (!isset
($this->myNodes[$obj_node->getKey()]) ||
$forceOverload)
$this->myNodes[$obj_node->getKey()] =
$obj_node;
if (get_class($this->myNodes[$obj_node->getKey()]) !=
$nodeRow['MEN_OBJCLASS'] )
$this->myNodes[$obj_node->getKey()] =
$obj_node;
$this->myNodes[$obj_node->getKey()]->setDBRow($nodeRow,True,$debug);
return $this->myNodes[$obj_node->getKey()];
/*** node children get/factory methods ----------------------------- */
* returns previously set children array
* sets the child array of $aKey
* @param array $arr_nodes
* returns a array of pointers to the child objects
foreach($arr_childRows as $arr_row)
$int_sort =
((isset
($arr_row['MEN_SORTORDER']) &&
intval($arr_row['MEN_SORTORDER'])) ?
intval($arr_row['MEN_SORTORDER']) :
1);
while(isset
($this->childNodes['ROOT'][$int_sort])) $int_sort++
; // fix order
$arr_row['MEN_SORTORDER'] =
$int_sort;
'PROJ_ID' =>
$int_projectId,
foreach($arr_childRows as $arr_row)
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"adding node: <pre>" .
print_r($arr_row,True)) .
"</pre>";
$int_sort =
((isset
($arr_row['MEN_SORTORDER']) &&
intval($arr_row['MEN_SORTORDER'])) ?
intval($arr_row['MEN_SORTORDER']) :
1);
while(isset
($this->childNodes['ROOT'][$int_sort])) $int_sort++
; // fix order
$arr_row['MEN_SORTORDER'] =
$int_sort;
/*** tree methods -------------------------------------------------- */
* returns an array of pointers to the elements till root with all
* in case of an error false is return (use '===' type equal )
* @param mixed $aNode (DMBS_TREE_NODE) a node object or (int) a node id
* @returns array array of pointers to nodes key=DBMS_TREE_NODE::getId()
function getRootPath($aNode,$useCache=
TRUE,$debug=
FALSE) {
if ($debug) echo
"<blockquote style=\"backgroud-color: #febf00;font-size:80%\">";
if ($debug) echo
"</blockquote>";
return $aNode->getRootPath($useCache,$debug);
if (empty($aNode)) return array();
if ($o_node=
$this->getNode($aNode,$debug))
if ($debug) echo
"</blockquote>";
return $o_node->getRootPath($useCache,$debug);
ocsp_logError(__FILE__
,__LINE__
,"$aNode is not in the tree",E_WARNING);
if ($debug) echo
"</blockquote>";
Documentation generated on Thu, 08 Jan 2009 17:39:08 +0100 by phpDocumentor 1.4.0a2