Source for file CMS_MENU_NODE.phpclass

Documentation is available at CMS_MENU_NODE.phpclass

  1. <?php
  2. /**
  3.   * Class file CMS_MENU_NODE.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    cms
  7.   *
  8.   * @author     Peter Krebs (pk) <pitlinz@users.sourceforge.net>
  9.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  10.   *
  11.   * @version $Id: CMS_MENU_NODE.phpclass,v 1.43 2008/12/03 09:47:56 pitlinz Exp $
  12.   * 
  13.   */
  14.  
  15. // ---------------------------------------------------------
  16. // requirements
  17. // ---------------------------------------------------------
  18.  
  19.     pcf_require_interface('INFA_CMS_MENU_NODE',dirname(__FILE__"/INFA_CMS_MENU_NODE.phpclass");
  20.     pcf_require_class('DBMS_TREE_NODE',"db/");
  21.     //pcf_require_class('CMS_MENU_V2',dirname(__FILE__)."/CMS_MENU_V2.phpclass");
  22.     pcf_require_class('CMS_MENU',dirname(__FILE__)."/");
  23.     pcf_require_class('CMS_TABLEOBJ',"cms/");
  24.     pcf_require_class('OCSP_TEMPLATE',"common/");
  25.     
  26.  
  27.  
  28. /**
  29.   * Class CMS_MENU_NODE
  30.   *
  31.   * @project    Open CSP-Management
  32.   * @package    cms
  33.   *
  34.   * @author     Peter Krebs (pk) <pitlinz@users.sourceforge.net>
  35.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  36.   *
  37.   * @version $Id: CMS_MENU_NODE.phpclass,v 1.43 2008/12/03 09:47:56 pitlinz Exp $
  38.   */
  39. class CMS_MENU_NODE extends DBMS_TREE_NODE implements INFA_CMS_MENU_NODE
  40. {
  41.     
  42.     // ---------------------------------------------------------------------------
  43.     // constants
  44.     // ---------------------------------------------------------------------------
  45.     
  46.  
  47.     /**
  48.       * @constant string CLASS_SRC_FILE
  49.       */
  50.     const CLASS_SRC_FILE = __FILE__;    
  51.  
  52.     // ---------------------------------------------------------------------------
  53.     // class (static)
  54.     // ---------------------------------------------------------------------------
  55.     
  56.     /*** class vars ------------------------------------------------------ */
  57.     
  58.     /**
  59.      * array with key -> project association
  60.      *
  61.      * @staticvar array $menuProjectLst 
  62.      */
  63.     protected static $menuProjectLst array();
  64.     
  65.     /*** class methods   ---------------------------------------------- */
  66.     
  67.     public static function &getInstance($aKey,$projId=0)
  68.     {
  69.         if (isset(self::$menuProjectLst[$aKey]&& intval(self::$menuProjectLst[$aKey])) 
  70.         {
  71.             return CMS_MENU::getInstance(self::$menuProjectLst[$aKey])->getNode($aKey,False,$debug);
  72.         }
  73.         
  74.         if ($arr_menRow OCSP_CMS_CACHE::getInstance('MENU')->getMenuRow($aKey))
  75.         {
  76.             return CMS_MENU::getInstance($arr_menRow['PROJ_ID'])->getNode($aKey,False,$debug);
  77.         }
  78.         
  79.         if (intval($projId))
  80.         {
  81.             return CMS_MENU::getInstance($projId)->getNode($aKey,False,$debug);
  82.         }
  83.         
  84.         if (strstr($aKey,"-"))
  85.         {
  86.             list($int_menId,$str_subKey$explode("-",$aKey,2);            
  87.         else {
  88.             $int_menId intval($aKey);
  89.         }
  90.                     
  91.         if ($arr_menRow OCSP_OBJ::defaultReadDBObj()->getRow('T_CMS_MENU',array('MEN_ID' => $int_menId))) 
  92.         {
  93.             return CMS_MENU::getInstance($arr_menRow['PROJ_ID'])->getNode($aKey,False,$debug);
  94.         else {
  95.             $obj_ret Null;
  96.             return $obj_ret;
  97.         }
  98.         
  99.     }
  100.     
  101.     
  102.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~ static ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  103.  
  104.     
  105.     /**
  106.       * @staticvar string $myClassSrcFile if is set the DBMS_FORM get the class object
  107.       * @since pk-07-10-14
  108.       ***/
  109.     protected $myClassSrcFile=__FILE__;
  110.  
  111.     /** -----------------------------------------------------
  112.       * Aggregations:
  113.       */
  114.  
  115.  
  116.     /** -----------------------------------------------------
  117.       * Compositions:
  118.       */
  119.  
  120.     /**
  121.       * @var CMS_PROJECT $myProjObj 
  122.       * @since pk-05-07-11
  123.       ***/
  124.     protected $myProjObj=NULL;
  125.  
  126.     /**
  127.      * the current page
  128.      *
  129.      * @var CMS_PAGE $myCurrentPage 
  130.      */
  131.     protected $myCurrentPage = Null;
  132.  
  133.     /**
  134.      * array of the menu pages
  135.      * 
  136.      * @var array $myPages 
  137.      */
  138.     protected $myPages = array();
  139.     
  140.     /** -----------------------------------------------------
  141.       * Attributes:
  142.       */
  143.  
  144.     /**
  145.       * @var string $myTable 
  146.       ***/
  147.     protected $myTable="T_CMS_MENU";
  148.  
  149.     /**
  150.       * @staticvar string $myTreeClass 
  151.       ***/
  152.     protected $myTreeClass="CMS_MENU";
  153.  
  154.     /**
  155.       * @staticvar  string  $myIdFld        id column = root
  156.       ***/
  157.     protected $myIdFld        ="MEN_ID";
  158.  
  159.     /**
  160.       * @staticvar  string  $myParentFld    name of the parent column
  161.       ***/
  162.        protected $myParentFld    ="MEN_PARENT";
  163.  
  164.     /**
  165.       * @staticvar  string  $mySortFld      name of the sort field
  166.       ***/
  167.     protected $mySortFld      ="MEN_SORTORDER";
  168.  
  169.     /**
  170.       * @staticvar  strint  $myChildKeys    comma sperated list of keys the children have to fit to
  171.       ***/
  172.     protected $myChildKeys    ="PROJ_ID";
  173.  
  174.     /**
  175.       * @var string $myChildClass 
  176.       ***/
  177.     protected $myChildClass = "CMS_MENU_NODE";
  178.  
  179.     /**
  180.       * @var string $myChildTbl table where childrens are stored
  181.       * @since pk-05-12-12
  182.       ***/
  183.     protected $myChildTbl = "T_CMS_MENU";
  184.  
  185.     /**
  186.       * @staticvar string $myPageTable 
  187.       * @since pk-05-07-12
  188.       ***/
  189.     protected $myPageTable="T_CMS_PAGE";
  190.  
  191.     /**
  192.       * @var double $hasChildrenToShowTS 
  193.       * @since pk-05-07-27
  194.       ***/
  195.     protected $hasChildrenToShowTS=0// time when we found children to show
  196.  
  197.     /**
  198.       * @var string $HTML_TitlePrepend 
  199.       * @since pk-05-08-08
  200.       ***/
  201.     protected $HTML_TitlePrepend="";
  202.  
  203.     /**
  204.       * @var string $HTML_TitleAppend 
  205.       * @since pk-05-08-08
  206.       ***/
  207.     protected $HTML_TitleAppend="";
  208.  
  209.     /**
  210.       * @staticvar string $CLASSVARIABLES 
  211.       * @since pk-05-11-22
  212.       ***/
  213.     protected $CLASSVARIABLES="MEN_OBJCLASS,myTreeClass,myIdFld,myParentFld,mySortFld,myTable,myChildKeys,myChildClass,myPageTable,myPageTable";
  214.  
  215.     /**
  216.      * Id of the template to use if PTMP_ID is not used
  217.      * @var int $myTemplateId 
  218.      * @since pk-08-06-16
  219.      */
  220.     protected $myTemplateId = 0;    
  221.  
  222.     /**
  223.       * @var array $myOnlinePageList 
  224.       * @access protected
  225.       * @since pk-07-08-16
  226.       */
  227.     protected $myOnlinePageList=array('NOTLOADED'=>TRUE);
  228.  
  229.     /**
  230.      * timestamp the page list has been populated
  231.      *
  232.      * @var double $pageListPopulateTS 
  233.      */
  234.     protected $pageListPopulateTS = 0;
  235.     
  236.     /**
  237.       *
  238.       * METHODS _____________________________________________
  239.       *
  240.       */
  241.  
  242.     /** -----------------------------------------------------
  243.       * Constructors and factory methods
  244.       */
  245.  
  246.     /**
  247.       * cunstructor checks if we have a key of $this->mytable or a composed one
  248.       * and populates the menu node from T_CMS_MENU if $auto_populate is true
  249.       *
  250.       * composed keys consists of at least 2 parts seperated by "-"
  251.       *
  252.       * 1st Part: MEN_ID
  253.       * 2nd Part: modulekey
  254.       * ....
  255.       *
  256.       * example 1_PGP_1_1
  257.       *
  258.       * @param int $aId 
  259.       * @param mixed $myTree @see DBMS_TREE_NODE::DBMS_TREE_NODE()
  260.       * @param boolean $auto_populate 
  261.       * @param boolean $debug 
  262.       *
  263.       * @since pk-05-12-14
  264.       * @version pk-07-06-15
  265.       * @version pk-08-06-19
  266.       * 
  267.       * @deprecated since pk-08-06-19
  268.       */
  269.     function CMS_MENU_NODE($aId=Null,$myTree="",$auto_populate=True,$debug=False{
  270.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::CMS_MENU_NODE(" $aId ")");
  271.  
  272.         $this->init();
  273.                 
  274.         if (!empty($aid))
  275.         {
  276.             if (intval($aId!= $aId)  {
  277.                 // we have a composed key -> extract MEN_ID
  278.                 $a_keys=explode("_",$aId);
  279.                 parent::DBMS_TREE_NODE(intval($a_keys[1]),$myTree,$auto_populate,$debug);
  280.             else {
  281.                 parent::DBMS_TREE_NODE(intval($aId),$myTree,$auto_populate,$debug);
  282.             }
  283.         }
  284.     }
  285.  
  286.     /**
  287.      * fakotry the propper menu node from the key
  288.      * 
  289.      * the key can be seperated with a _ in this case
  290.      * the first element is the MEN_ID and the second one
  291.      * is passed to the new node
  292.      *
  293.      * @param int $projId 
  294.      * @param string $key 
  295.      * @param boolean $debug 
  296.      * 
  297.      * @return CMS_MENU_NODE 
  298.      */
  299.     static public function &factoryFromKey($projId,$key,$debug=False)
  300.     {                   
  301.         if ($debugechoDebugMethod(__FILE__,"static call","CMS_MENU_NODE::factoryFromKey({$projId},{$key})");
  302.  
  303.         $obj_ret CMS_MENU::getInstance($projId)->getNode($key,False,$debug);
  304.         if ($debugechoDebugLine(__FILE__,__LINE__,"Returning " get_class($obj_ret" Object");
  305.         return $obj_ret;
  306.     }
  307.     
  308.  
  309.     // --------------------------------------------------------------------------
  310.     // class validateion methods
  311.     // --------------------------------------------------------------------------
  312.  
  313.     /**
  314.       * checks if the object has the rigth class (type of $this->MEN_OBJCLASS)
  315.       * and returns the proper object
  316.       *
  317.       * @param boolean $debug; 
  318.       *
  319.       * @return CMS_MENU_NODE or child instance
  320.       *
  321.       * @since pk-05-12-12
  322.       * @version pk-06-06-12
  323.       * @version pk-08-06-15
  324.       */
  325.     function validateClass($debug=False
  326.     {       
  327.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::validateClass()",$this->getDBField('MEN_OBJCLASS'));
  328.         if (($str_className $this->getDBField('MEN_OBJCLASS')) && ($str_className != get_class($this)))
  329.            {            
  330.             if (CMS_TABLEOBJ::menuType_requireClass($str_className,$debug))
  331.             {
  332.                 if ($o_ret=pcf_castObject($this,$str_className,$debug)) {
  333.                     $o_ret->setTreeObj($this->getTree(True),$debug);
  334.  
  335.                     $GLOBALS['OCSP_VAL']['DBMS_TREE'][$this->getGlobalTreeKey()][$this->getId()]=$o_ret;
  336.                     // replace the object in the global tree
  337.                     return $o_ret;
  338.                 }
  339.             }
  340.         }
  341.         if ($debugechoDebugLine(__FILE__,__LINE__,"node is already of of the right class");
  342.         return $this;
  343.  
  344.     }
  345.  
  346.     /**
  347.       * checks if the object is the current menu
  348.       * and returns the proper object
  349.       *
  350.       * @param boolean $debug; 
  351.       *
  352.       * @return CMS_MENU_NODE or child instance
  353.       *
  354.       * @since pk-05-12-12
  355.       *
  356.       ***/
  357.     function validateCurrentMenu($debug=FALSE
  358.     {
  359.         if ($debugecho "<p><b>CMS_MENU_NODE::validateCurrentMenu(".$this->MEN_OBJCLASS.")</b> (".get_class($this).")</p>";
  360.         return $this;
  361.     }
  362.  
  363.     /**
  364.       * abstract class to get the cms menu node for special menu objects
  365.       * overwrite in this classes
  366.       *
  367.       * @param boolean $debug 
  368.       *
  369.       * @return CMS_MENU_NODE 
  370.       *
  371.       * @since pk-07-10-15
  372.       */
  373.     function &getMyCMSMenuNode($debug=FALSE)
  374.     {
  375.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getMyCMSMenuNode()");
  376.         return $this;
  377.     }
  378.  
  379.     // --------------------------------------------------------------------------
  380.     // getter / setter
  381.     // --------------------------------------------------------------------------
  382.  
  383.     /**
  384.       * returns a array of variables used by the menu object
  385.       *
  386.       * array[varName]=array(
  387.       *     [TYPE]          datatype
  388.       *     [FLDCLASS]      name of DBMS_FIELD* class
  389.       *     [CLASSVALS]     array of values of [FLDCLASS]
  390.       *
  391.       * @returns array
  392.       * 
  393.       * @abstract
  394.       */
  395.     protected function getObjVarDef($debug=False
  396.     {
  397.           if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE::getObjVarDef");
  398.         $arr_ret array();
  399.         return $arr_ret;
  400.     }    
  401.     
  402.     /**
  403.       * returns the id
  404.       *
  405.       * @return int 
  406.       *
  407.       ***/
  408.     function getId(
  409.     {
  410.         return intval($this->getDBField($this->myIdFld));
  411.     }
  412.     
  413.     /**
  414.      * returns the cms menu node id
  415.      * 
  416.      * @return int 
  417.      * 
  418.      * @version pk-08-06-17
  419.      */
  420.     public function getMenId()
  421.     {
  422.         return $this->getId();
  423.     }
  424.  
  425.     /**
  426.      * returns the menu key
  427.      *
  428.      * the menu key is a '-' separeted string where the first part is the
  429.      * ocsp CMS MEN_ID
  430.      * 
  431.      * @return string 
  432.      */
  433.     public function getKey()
  434.     {
  435.         return $this->getId();
  436.     }
  437.     
  438.     /**
  439.       * @return string 
  440.       */
  441.     function getChildTblName()
  442.     {
  443.         if (!empty($this->myChildTbl))          return $this->myChildTbl;
  444.         if (!empty($this->myTable))             return $this->myTable;
  445.         if (pcf_is_instance_of($this->myTree))  return $this->myTree->getMyTable();
  446.     }
  447.  
  448.     /**
  449.      * @param int $langId 
  450.      * @param boolean $debug 
  451.      *
  452.      * @return string 
  453.      *
  454.      * @version pk-07-01-18 parse template
  455.      * @version pk-08-06-18 langId added
  456.      */
  457.     function getTitle($langId=0,$debug=False
  458.     {
  459.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getTitle()");
  460.         
  461.         if ($this->getId(== 0)
  462.         {
  463.             if (!empty($this->HTML_TitlePrepend|| !empty($this->HTML_TitleAppend))
  464.             {
  465.                 $str_tmpl $this->HTML_TitlePrepend . $this->HTML_TitleAppend;
  466.             else if (intval($this->getProjId())) {
  467.                 $str_tmpl $this->getMyProject()->getTitle()
  468.             else {
  469.                 return "";
  470.             }
  471.         else {
  472.             $str_tmpl $this->HTML_TitlePrepend.$this->getDBField('MEN_TITLE').$this->HTML_TitleAppend;
  473.         }
  474.         
  475.         return OCSP_TEMPLATE::parse($str_tmpl,$this->getDBVal());        
  476.     }
  477.  
  478.     /**
  479.       * @param string $aTitle 
  480.       * @since pk-05-09-06
  481.       ***/
  482.     function setTitle($aTitle
  483.     {
  484.         $this->setDBField('MEN_TITLE',$aTitle);
  485.     }
  486.  
  487.     /**
  488.       * returns the language id
  489.       * @return int 
  490.       ***/
  491.     function getLangId()
  492.     {
  493.         return intval($this->getDBField('LANG_ID'));
  494.     }
  495.  
  496.     /**
  497.       * call parent::setParentObj and sets the project from the parent
  498.       * @param CMS_MENU_NODE $aParent 
  499.       *
  500.       */
  501.     function setParentObj(&$aParent)
  502.     {
  503.         parent::setParentObj($aParent);
  504.  
  505.         if (method_exists($aParent,'getMyProject'))
  506.         {
  507.             $this->setMyProject($aParent->getMyProject());
  508.         }
  509.         $this->setDBField('MEN_PARENT',$aParent->getId());
  510.         
  511.     }
  512.  
  513.     /**
  514.      * returns the include file (if set)
  515.      * 
  516.      * @global array $OCSP_CONF 
  517.      * 
  518.      * @return string 
  519.      * 
  520.      * @since pk-07-10-31
  521.      */
  522.     function getMenuInclude()
  523.     {
  524.         global $OCSP_CONF;
  525.         $str_ret=$this->getDBField('MEN_INCLUDE');
  526.         if (!empty($str_ret))
  527.         {
  528.             $str_ret=$OCSP_CONF['PROJECTPATH'].$str_ret;
  529.             if (file_exists($str_ret)) 
  530.             {
  531.                 return $str_ret;
  532.             }
  533.         }
  534.         return NULL;
  535.     }
  536.  
  537.  
  538.     /**
  539.      * returns the template id set in menu or project
  540.      *
  541.      * @param boolean $debug 
  542.      * 
  543.      * @return int 
  544.      * 
  545.      * @since pk-08-06-16
  546.      */
  547.     public function getTemplateId($debug=False)
  548.     {
  549.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getTemplateId()");    
  550.         
  551.         if (intval($this->myTemplateId))
  552.         {
  553.             return $this->myTemplateId;
  554.         else if ($this->myTemplateId = $this->getDBField('PTMP_ID')) {
  555.             return $this->myTemplateId;
  556.         else {
  557.             $this->myTemplateId = $this->getMyProject($debug,True)->getTemplateId();
  558.         }   
  559.         return $this->myTemplateId;     
  560.     }
  561.     
  562.     // ---------------------------------------------------------------------------
  563.     // tree methods
  564.     // ---------------------------------------------------------------------------
  565.  
  566.     /**
  567.       * returns myTree object
  568.       *
  569.       * @param boolean $useCache 
  570.       * @param boolean $debug 
  571.       * @param boolean $checkParent (if false $this->getParentObj is not called)
  572.       *
  573.       * @return CMS_MENU 
  574.       *
  575.       * @since pk-08-06-17
  576.       */
  577.     function &getTree($useCache=True,$debug=False,$checkParent=True)
  578.     {
  579.         if (!pcf_is_instance_of($this->myTree,'CMS_MENU'))
  580.         {
  581.             $this->myTree = CMS_MENU::getInstance($this->getProjId());
  582.             $this->myTree->setMyProject($this->getMyProject($debug));
  583.         }
  584.         return $this->myTree;
  585.     }
  586.  
  587.     /*** parent ------------------------------------ */
  588.     
  589.     /**
  590.       * returns the parent object or null if parent is root
  591.       *
  592.       * @param boolean $useCache 
  593.       * @param boolean $debug 
  594.       *
  595.       * @return CMS_MENU_NODE 
  596.       *
  597.       * @since pk-08-06-17
  598.       */
  599.     function &getParentObj($useCache=True,$debug=False)
  600.     {
  601.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getParentObj()");   
  602.  
  603.         if (pcf_is_instance_of($this->myParent,'CMS_MENU_NODE'))
  604.         {
  605.             return $this->myParent;        
  606.         }
  607.         
  608.         if (pcf_class_implements($this->myParent,'INFA_CMS_MENU_NODE'))
  609.         {
  610.             return $this->myParent
  611.         }
  612.         
  613.         if ($int_parent $this->getParentId($debug))
  614.         {
  615.             $this->getTree($useCache,$debug);
  616.             $this->myParent=$this->myTree->getNode($int_parent);
  617.         //} else if ($this->getId()) {
  618.         //    $this->myParent=new CMS_MENU_NODE();
  619.         //    $this->myParent->setMyProject($this->getMyProject($debug,True));                    
  620.         else {
  621.             if ($debugechoDebugLine(__FILE__,__LINE__,"no parent Id");
  622.             $this->myParent = Null;
  623.         }
  624.         return $this->myParent;
  625.     }
  626.     
  627.     /*** children ------------------------------------ */
  628.     
  629.     /**
  630.       * returns a array of pointers to the child objects
  631.       *
  632.       * if filtered $this->myFilterArr is used to check the child
  633.       *
  634.       * @param boolean $useCache 
  635.       * @param boolean $debug 
  636.       * @param boolean $filtered 
  637.       *
  638.       * @global array $OCSP_VAL 
  639.       *
  640.       * @return array 
  641.       *
  642.       */
  643.     function getChildrenList($useCache=True,$debug=False,$filtered=False)
  644.     {        
  645.         if (!$useCache || !$this->myChildrenPopulateTS >= (time(ini_get('max_execution_time')))
  646.         {
  647.             $this->populateChildren($useCache,$debug);
  648.         }
  649.         
  650.         return $this->myChildren;
  651.     }
  652.     
  653.     /**
  654.       * populates the children
  655.       *
  656.       * @param boolean $useCache 
  657.       * @param boolean $debug 
  658.       *
  659.       * @return double 
  660.       *
  661.       */
  662.     protected function populateChildren($useCache=True,$debug=False
  663.     {
  664.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::populateChildren()","MEN_ID: ".$this->getId().($useCache "USECACHE" ""));
  665.     
  666.         $this->getTree();
  667.         
  668.            if ($this->myChildren = $this->myTree->getChildNodes($this->getKey(),$debug))
  669.            {
  670.                return $this->myChildren;
  671.            }
  672.            $this->myChildren = array();
  673.            
  674.            if ($useCache && ($arr_childRows OCSP_CMS_CACHE::getInstance('MENU')->getMenuChildrenRowArray($this->getKey()))) 
  675.            {               
  676.                foreach($arr_childRows as $arr_row)
  677.                {
  678.                    $int_sort ((isset($arr_row['MEN_SORTORDER']&& intval($arr_row['MEN_SORTORDER'])) intval($arr_row['MEN_SORTORDER']1);
  679.                 while(isset($this->myChildren[$int_sort])) $int_sort++// fix order
  680.                 $arr_row['MEN_SORTORDER'$int_sort;
  681.                 $this->myChildren[$int_sort&$this->myTree->getNodeFromRow($arr_row,$debug);
  682.                 $this->myChildren[$int_sort]->setParentObj($this);                            
  683.                }               
  684.                $this->myChildrenPopulateTS = time();
  685.                return $this->myChildrenPopulateTS;
  686.            }
  687.            
  688.            $arr_filter array(
  689.                    'PROJ_ID'      => $this->getProjId(),
  690.                    'MEN_PARENT' => $this->getId()
  691.                );
  692.            
  693.         if ($arr_childRows OCSP_OBJ::defaultReadDBObj()->getArray('T_CMS_MENU',$arr_filter,0,0,'MEN_SORTORDER'))
  694.         {
  695.                foreach($arr_childRows as $arr_row)
  696.                {
  697.                    $int_sort ((isset($arr_row['MEN_SORTORDER']&& intval($arr_row['MEN_SORTORDER'])) intval($arr_row['MEN_SORTORDER']1);
  698.                 while(isset($this->myChildren[$int_sort])) $int_sort++// fix order
  699.                 $arr_row['MEN_SORTORDER'$int_sort;
  700.                 $this->myChildren[$int_sort&$this->myTree->getNodeFromRow($arr_row,$debug);
  701.                 $this->myChildren[$int_sort]->setParentObj($this);                            
  702.                }               
  703.                $this->myChildrenPopulateTS = time();
  704.                OCSP_CMS_CACHE::getInstance('MENU')->storeMenuObj($this);
  705.                return $this->myChildrenPopulateTS;                       
  706.         else {
  707.             return parent::populateChildren($useCache,$debug);
  708.         }
  709.            
  710.     }
  711.     
  712.     
  713.     // --------------------------------------------------------------------------
  714.     // project methods
  715.     // --------------------------------------------------------------------------
  716.  
  717.     /**
  718.       * sets the project object of the page
  719.       * NOTE: does not set the current project ID
  720.       * the values of $this->PROJ_ID and $this->myProjObj->getId() can differ
  721.       *
  722.       * @param CMS_PROJECT $aProjObj 
  723.       * @param boolean $debug 
  724.       *
  725.       * @since pk-05-07-11
  726.       * @version pk-05-08-11
  727.       *
  728.       ***/
  729.     function setMyProject(&$aProjObj,$debug=FALSE{
  730.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::setMyProject()");
  731.         $this->myProjObj=$aProjObj;
  732.         if (method_exists($this->myProjObj,'getId'))
  733.         {
  734.             $this->setProjId($this->myProjObj->getId());
  735.         else if ($debug{
  736.             ocsp_logError(__FILE__,__LINE__,"project does not support getId()",E_WARNING);
  737.         }
  738.         //if ($debug) {echo "<pre style=\"font-size: 80%;\">";debug_zval_dump($this->myProjObj);echo "</pre>";}
  739.     }
  740.  
  741.     /**
  742.       * returns the Project Object
  743.       *
  744.       * @param boolean $debug 
  745.       * @param boolean $forceObj (if false no new object will be instanciated)
  746.       * @param boolean $setAsCurrent (if true call $this->setAsCurrent())
  747.       *
  748.       * @return CMS_PROJECT 
  749.       *
  750.       * @version pk-05-11-22
  751.       * @version pk-06-05-16 bugfix for default project (PROJ_ID=0) wihich is not in the database
  752.       * @version pk-07-08-23
  753.       * @version pk-08-06-06
  754.       *
  755.       * @global array $OCSP_OBJ 
  756.       ***/
  757.     function &getMyProject($debug=False,$forceObj=True,$setAsCurrent=False
  758.     {
  759.         global $OCSP_OBJ;
  760.  
  761.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getMyProject()","",0);
  762.  
  763.         if (pcf_is_instance_of($this->myProjObj,'CMS_PROJECT'))
  764.         {
  765.             if(intval($this->getDBField('PROJ_ID')) == $this->myProjObj->getId())
  766.             {
  767.                 if ($debugechoDebugLine(__FILE__,__LINE__,"returning \$this->myProjObj");
  768.                 if ($setAsCurrent$this->setAsCurrent($debug);
  769.                 return $this->myProjObj;
  770.             }
  771.             if (intval($this->myProjObj->getId()) || !intval($this->getDBField('PROJ_ID')))
  772.             {
  773.                 $this->setDBFieldIfDiff('PROJ_ID',$this->myProjObj->getId());
  774.                 if ($debugechoDebugLine(__FILE__,__LINE__,"returning \$this->myProjObj");
  775.                 if ($setAsCurrent$this->setAsCurrent($debug);
  776.                 return $this->myProjObj;
  777.             }
  778.         }
  779.  
  780.         $this->myProjObj = CMS_TABLEOBJ::get_currentProj();
  781.         if (pcf_is_instance_of($this->myProjObj,'CMS_PROJECT'))
  782.         {
  783.             if (intval($this->myProjObj->getId())==intval($this->getDBField('PROJ_ID')))
  784.             {
  785.                 if ($debugechoDebugLine(__FILE__,__LINE__,"returning \$OCSP_OBJ['CUR_CMSPROJ']");
  786.                 if ($setAsCurrent$this->setAsCurrent($debug);
  787.                 return $this->myProjObj;
  788.             else {
  789.                 $this->myProjObj = Null;
  790.             }
  791.         }
  792.  
  793.         if (!$forceObjreturn $this->myProjObj;
  794.  
  795.         pcf_require_class('CMS_PROJECT',"cms/");
  796.         $this->myProjObj = CMS_PROJECT::getInstance(intval($this->getDBField('PROJ_ID')));
  797.         
  798.         if ($setAsCurrent$this->setAsCurrent($debug);
  799.         return $this->myProjObj;
  800.     }
  801.  
  802.  
  803.     /**
  804.       * returns the project id
  805.       * @return int 
  806.       * @version pk-05-08-11
  807.       ***/
  808.     function getProjId({
  809.         if (!intval($this->getDBField('PROJ_ID')) && (is_object($this->myProjObj))) {
  810.             return $this->myProjObj->getId();
  811.         else {
  812.             return intval($this->getDBField('PROJ_ID'));
  813.         }
  814.     }
  815.  
  816.     /**
  817.       * sets the project id
  818.       * @param int $aId 
  819.       * @since pk-05-07-12
  820.       ***/
  821.     function setProjId($aId{
  822.         $this->setDBFieldIfDiff('PROJ_ID',intval($aId));
  823.     }
  824.  
  825.  
  826.     /**
  827.       * sets the node as current menu node
  828.       * @param boolean $debug 
  829.       */
  830.     function setAsCurrent($debug=FALSE)
  831.     {
  832.         CMS_TABLEOBJ::set_currentMenu($this);
  833.     }
  834.  
  835.     /**
  836.       * checks if the menu is the current menu
  837.       *
  838.       * @param boolean $debug 
  839.       *
  840.       * @return boolean 
  841.       *
  842.       * @since pk-06-02-23
  843.       * 
  844.       * @version pk-08-06-19
  845.       */
  846.     function isCurrent($debug=False{
  847.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::isCurrent()");
  848.  
  849.         if (CMS_TABLEOBJ::get_currentMenu())
  850.         {
  851.             return (CMS_TABLEOBJ::get_currentMenu()->getKey(== $this->getKey());
  852.         else {
  853.             return False;
  854.         }
  855.      
  856.     }
  857.  
  858.  
  859.     // --------------------------------------------------------------------------
  860.     // form methods
  861.     // --------------------------------------------------------------------------
  862.  
  863.     /**
  864.       * returns a database form
  865.       *
  866.       * @param int    $mode       dbms form show mode
  867.       * @param string $frmName    dbms form name
  868.       *
  869.       * @return DBMS_FORM 
  870.       *
  871.       * @version pk-05-01-12 store the page object to the database
  872.       * @version pk-05-02-17 add objects if TYPE == "__FRMFIELD__"
  873.       *
  874.       * @deprecated since pk-07-08-21
  875.       *
  876.       */
  877.     function &dbGetForm($mode=FRM_MODE_READONLY,$frmName="",$debug=FALSE)  
  878.     {
  879.         throw new Exception('deprecated call');
  880.         /*    
  881.         if ($debug) echo "<p><b>CMS_MENU_NODE::dbGetForm($mode,$frmName,...)</b> (".get_class($this).")</p>";
  882.  
  883.         if (empty($frmName)) $frmName="MENUFORM_".strtoupper(get_class($this));
  884.         if (($frmObj=&parent::dbGetForm($mode,$frmName,$debug)) && (pcf_is_instance_of($frmObj,"DBMS_FORM"))) {
  885.             $saveForm=FALSE;
  886.         } else {
  887.             if ($debug) echo "<blockquote><p>generating new form</p></blockquote>";
  888.             if (($frmObj=&parent::dbGetForm($mode,"",$debug)) && (pcf_is_instance_of($frmObj,"DBMS_FORM"))) {
  889.                 $frmObj->frmId=0;
  890.                 $frmObj->isTblDefault=0;
  891.                 $frmObj->frmName=$frmName;
  892.                 $saveForm=TRUE;
  893.             } else {
  894.                 if ($debug) echo "<p style=\"color:red\">ERROR NO FORM FOR MENU OBJECT FOUND</p>";
  895.                 return $frmObj;
  896.             }
  897.         }
  898.  
  899.         if (pcf_is_instance_of($frmObj,"DBMS_FORM")) {
  900.             
  901.             if (is_array($objVars)) {
  902.                 if ($debug) echo "<p><b>Adding MENU Fields</b></p>"; //<blockquote><pre>".htmlspecialchars(print_r($objVars,TRUE))."</pre></blockquote>";
  903.                 if ($debug) echo "<p>FORMOBJECT:</p><pre style=\"font-size:8px;padding-left:50px;backgorund-color:#C0C0C0;\">".pcf_object_info($frmObj,1)."</pre><blockquote>";
  904.  
  905.                 if ($objVars['TYPE']=="__FRMFIELD__") {
  906.                     require_once $GLOBALS['OCSP']['PHPINCPATH']."common/pcf.phpinc";
  907.                     if (pcf_is_instance_of($objVars['OBJ'],"DBMS_FIELD")) {
  908.                         $frmObj->addFieldObj($objVars['OBJ'],TRUE,$debug);
  909.                     }
  910.                 } else {
  911.                     foreach($objVars as $key => $descArr) {
  912.                         if (!($frmObj->getField($key,$descArr['TABLE'],$debug))) { // </pk-06-02-01> $descArr['TABLE']
  913.                             $fld=&$frmObj->addNoDbClassField($descArr['FLDCLASS'],$key,$key,$descArr['TABLE'],$debug);
  914.                             $fld->dbDesc['TYPE']=$descArr['TYPE'];
  915.                             $fld->dbDesc['NULL']=TRUE;
  916.                             $fld->allowNull=TRUE;
  917.                             $fild->setObjectVars($descArr['CLASSVALS']);
  918.  
  919.                             $saveForm=TRUE;
  920.                         } else {
  921.                             if ($debug) echo "<p>Field: $key exists</p>";
  922.                         }
  923.                         // if ($debug) echo "<blockquote><pre>";pcf_object_info($fld,2);echo "</pre></blockquote>";
  924.                     }
  925.                 }
  926.                 if ($debug) echo "</blockquote>";
  927.             }
  928.  
  929.             if ($debug) echo "<blockquote><pre>";pcf_object_info($frmObj,2);echo "</pre></blockquote>";
  930.  
  931.             if ($saveForm && $frmObj->frmName=="MENUFORM_".strtoupper(get_class($this))) {
  932.                 if ($debug) echo "<p>saveing form: ".$frmObj->frmName."</p><blockquote>";
  933.                 if (empty($frmObj->frmDesc)) $frmObj->frmDesc="Created by CMS_MENU_NODE";
  934.                 $frmObj->storeToDb($debug);
  935.                 if ($debug) echo "</blockquote>";
  936.             }
  937.  
  938.             return $frmObj;
  939.         }
  940.         return NULL;
  941.         */
  942.     }
  943.  
  944.     /**
  945.      * returns the required form name
  946.      * 
  947.      * normaly this function return Null to let $this->getForm decide
  948.      * which form ($this->getMyTable()) to use. In some subclasses it can
  949.      * be useful to overwrite this methode to get a special form
  950.      * 
  951.      * This is also a way to tell ajax reloads to change form. in jOCSP/formRPC.php
  952.      * is checked wether the currently loaded form (from the environment) fits to
  953.      * the forms tableobject if this function returns a value.
  954.      *
  955.      * @return string 
  956.      * 
  957.      * @since pk-08-11-01
  958.      */
  959.     public function getFormName()
  960.     {
  961.         return "MENUFORM_".strtoupper(get_class($this));
  962.     }
  963.     
  964.     /**
  965.      * returns the form class name to use
  966.      *
  967.      * if you overwrite this method make sure the returned form
  968.      * class source has been included
  969.      * 
  970.      * @return string 
  971.      * 
  972.      * @since pk-08-11-01
  973.      */
  974.     public function getFormClassName()
  975.     {
  976.         pcf_require_class('CMS_MENU_FORM',"cms/menu/");
  977.         return 'CMS_MENU_FORM';
  978.     }    
  979.     
  980.     /**
  981.       * returns the form used for manipulating the node
  982.       *
  983.       * replaces dbGetForm and returns a OCSP_FORM
  984.       * 
  985.       * @param int $mode 
  986.       * @param mixed $form (string) form name (int) form id
  987.       * @param string $frmClass 
  988.       * @param boolean $debug 
  989.       *
  990.       * @return OCSP_FORM 
  991.       *
  992.       * @since pk-07-08-21
  993.       * @requires __OCSP_PHPINCPATH__/db/forms/OCSP_FORM.phpclass
  994.       */
  995.     public function &getForm($mode=FRM_MODE_READONLY,$form=Null,$frmClass='CMS_MENU_FORM',$debug=False)    
  996.     {        
  997.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getForm()");
  998.  
  999.         if (empty($frmClass|| ($frmClass "OCSP_FORM"))
  1000.         {
  1001.             $frmClass$this->getFormClassName();            
  1002.         }
  1003.  
  1004.         $form=(empty($form$this->getFormName($form);
  1005.  
  1006.         if (intval($form))
  1007.         {
  1008.             $obj_form=OCSP_FORM::factory_from_id(intval($form),$frmClass,$debug);
  1009.             $frmName="";
  1010.         else {
  1011.             $obj_form=OCSP_FORM::factory_from_Name($form,$frmClass,$debug);
  1012.             $frmName=$form;
  1013.         }
  1014.  
  1015.         if (!pcf_is_instance_of($obj_form,"OCSP_FORM"))
  1016.         {
  1017.             if ($debugechoDebugLine(__FILE__,__LINE__,"Form : " $form " not found");
  1018.             $obj_srcForm=parent::getForm($mode,'MENUFORM_CMS_MENU_NODE',$frmClass,$debug);
  1019.             if (pcf_is_instance_of($obj_srcForm,'OCSP_FORM'))
  1020.             {
  1021.                 if (!empty($frmName&& ($frmName != 'MENUFORM_CMS_MENU_NODE'))
  1022.                 {
  1023.                     $frmClass=get_class($obj_srcForm);
  1024.                     $obj_form=new $frmClass(0,$frmName,$debug);
  1025.                     $arr_values=$obj_srcForm->getMyDBRow();
  1026.                     unset($arr_values['FRM_ID']);
  1027.                     $arr_values['FRM_NAME']=$frmName// <pk-08-06-15 />
  1028.                     $obj_form->setMyDBRow($arr_values);
  1029.                     $obj_form->setId(0);
  1030.                     if (!$obj_form->storeToDb($debug))
  1031.                     {
  1032.                         ocsp_logError(__FILE__,__LINE__,"could not generate form $form",E_ERROR);
  1033.                         exit();
  1034.                     }
  1035.                     $arr_blocks=$obj_srcForm->getBlocks($debug);
  1036.                     foreach($arr_blocks as &$obj_block)
  1037.                     {
  1038.                         $obj_form->copyBlock($obj_block->getId(),$debug);
  1039.                     }
  1040.                 }
  1041.             else {
  1042.                 ocsp_logError(__FILE__,__LINE__,"no suitable form found for menu class: ".get_class($this),E_ERROR);
  1043.                 exit();
  1044.             }
  1045.         }
  1046.  
  1047.         if (method_exists($this,"getObjVarDef"))
  1048.         {
  1049.             $b_toSave=False;
  1050.             $arr_objVars=$this->getObjVarDef();
  1051.             foreach($arr_objVars as $str_key => $arr_descArr)
  1052.             {
  1053.                 if (!isset($arr_descArr['TABLE']))
  1054.                 {
  1055.                     switch($arr_descArr['TYPE'])
  1056.                     {
  1057.                         case 'layout':
  1058.                             $arr_descArr['TABLE'DBMS_NO_DBFIELD;
  1059.                             break;                        
  1060.                         default:
  1061.                             $arr_descArr['TABLE'"OBJVALS_" $this->myTable;
  1062.                     }
  1063.                 }
  1064.                 
  1065.                    if (!($obj_form->getField($arr_descArr['TABLE'"." $str_key,$debug)))
  1066.                    {
  1067.                        $arr_fldValues=$arr_descArr['CLASSVALS'];
  1068.                                                   
  1069.                     if (!isset($arr_fldValues['myTable'])) $arr_fldValues['myTable']=$arr_descArr['TABLE'];
  1070.                     if (!isset($arr_fldValues['myTableAlias'])) $arr_fldValues['myTableAlias']=$arr_descArr['TABLE'];
  1071.                     
  1072.                     $arr_dbDesc=array(
  1073.                         'TYPE'  => $arr_descArr['TYPE'],
  1074.                         'NULL'  => True,
  1075.                         'TABLE' => $arr_fldValues['myTable'// <pk-08-06-17 />
  1076.                     );
  1077.                     
  1078.                     
  1079.                     if ($obj_field=$obj_form->factory_field($str_key,$arr_descArr['FLDCLASS'],$arr_dbDesc,$arr_fldValues,$debug))
  1080.                     {
  1081.                         $obj_block=$obj_form->getBlock(0);
  1082.                         $obj_block->addFieldObj($obj_field,$debug);
  1083.                         if ($debugechoDebugLine(__FILE__,__LINE__,"Field ".$obj_field->getKey()." generated");
  1084.                         $b_toSave=True;
  1085.                     else {
  1086.                         ocsp_logError(__FILE__,__LINE__,"opjVar Field$str_key not in form: <strong>".$obj_form->getName()."</strong><pre>".print_r($arr_descArr,True)."</pre>");
  1087.                     }
  1088.                 }                
  1089.             }
  1090.             if ($b_toSave)
  1091.             {
  1092.                 $obj_form->storeToDb();
  1093.             }
  1094.         }
  1095.         
  1096.         //$debug=True;echoDebugLine(__FILE__,__LINE__,"debug On");        
  1097.         $obj_form->setMyTblObj($this,$debug);
  1098.         if (!empty($this->myClassSrcFile&& stristr($this->myClassSrcFile,get_class($this)))
  1099.         {
  1100.             if ($debugechoDebugLine(__FILE__,__LINE__,"\$this->myClassSrcFile is set to " $this->myClassSrcFile . " for class: " get_class($this));
  1101.             $obj_form->setTblObjInc($this->myClassSrcFile);
  1102.             $obj_form->setTblObjClass(get_class($this));
  1103.         
  1104.         $obj_form->setFrmMode($mode);
  1105.         return $obj_form;
  1106.     }
  1107.  
  1108.     // --------------------------------------------------------------------------
  1109.     // database methods
  1110.     // --------------------------------------------------------------------------
  1111.  
  1112.      /**
  1113.       *    returns an array of db default values
  1114.       *
  1115.       * @param boolean     $debug 
  1116.       *
  1117.       * @return array 
  1118.       *
  1119.       * @since pk-08-02-13
  1120.       */
  1121.     public function getDefaults($debug=FALSE)
  1122.     {
  1123.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getDefaults()");
  1124.  
  1125.         $arr_ret parent::getDefaults($debug);
  1126.         if ($int_id intval($this->getProjId()))
  1127.         {
  1128.             $arr_ret['PROJ_ID']=$int_id;    
  1129.         }
  1130.         
  1131.         if ($int_id intval($this->getParentId()))
  1132.         {
  1133.             $arr_ret['MEN_PARENT'$int_id;
  1134.         }
  1135.         return $arr_ret;
  1136.     }
  1137.     
  1138.     
  1139.     /**
  1140.       * sets all fields of an array to the objcet
  1141.       * if $valArr['PEARCACHE_TS'] isset this will become the populateTS
  1142.       *
  1143.       * @param array $valArr 
  1144.       * @param boolean $debug 
  1145.       *
  1146.       * @rerturn boolean
  1147.       *
  1148.       * @since pk-05-08-30
  1149.       * @version pk-07-06-16
  1150.       ***/
  1151.     function setDBVal($valArr,$debug=FALSE{
  1152.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::setDBVal()");
  1153.  
  1154.         if (!is_array($valArr)) {
  1155.             if ($debugechoDebugLine(__FILE__,__LINE__,"\$valArr is not an array");
  1156.             return FALSE;
  1157.         }
  1158.         if (isset($valArr['PEARCACHE_TS']))
  1159.         {
  1160.             $this->populateTS           =$valArr['PEARCACHE_TS'];
  1161.             $this->myObjValsPopulateTS  =$valArr['PEARCACHE_TS'];
  1162.             unset($valArr['PEARCACHE_TS']);
  1163.         }
  1164.         parent::setDBVal($valArr,$debug);
  1165.     }
  1166.  
  1167.     /**
  1168.       * ensures that LANG_ID is set and
  1169.       * sets $this->mySortFld to IFNULL(MAX(".$this->mySortFld."),1)
  1170.       *
  1171.       * @param boolean   $debug  show debug info
  1172.       *
  1173.       * @return int   returns the autoIncFld ID if exists or 1 on success
  1174.       *
  1175.       * @since pk-04-08-25
  1176.       * @version pk-05-07-08
  1177.       *
  1178.       */
  1179.     function dbInsert($debug=False{
  1180.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::dbInsert()");
  1181.  
  1182.         if (!intval($this->getDBField('LANG_ID')))      $this->setDBField('LANG_ID',0);
  1183.         if (!intval($this->getDBField('MEN_LINKFK')))   $this->setDBField('MEN_LINKFK',0);
  1184.  
  1185.         if (!intval($this->{$this->mySortFld})) // <pk-05-07-08 />
  1186.             $query ="SELECT IFNULL(MAX(".$this->mySortFld."),1) FROM ".$this->myTable;
  1187.             $query.=" WHERE ".$this->myParentFld."=".intval($this->{$this->myParentFld});
  1188.             $query.=" AND PROJ_ID=".$this->getProjId();
  1189.  
  1190.             $this->{$this->mySortFldOCSP_OBJ::defaultReadDBObj()->quickQuery($query,0,0);
  1191.         }
  1192.  
  1193.         return parent::dbInsert($debug);
  1194.     }
  1195.  
  1196.     /**
  1197.       * ensures that LANG_ID is set
  1198.       *
  1199.       * @param boolean   $debug  show debug info
  1200.       * @param boolean $ignorPopulated (if false the table MUST have been populated)
  1201.       *
  1202.       * @return int   returns the autoIncFld ID if exists or 1 on success
  1203.       *
  1204.       * @since pk-06-08-18
  1205.       *
  1206.       ***/
  1207.     function dbReplace($debug=False,$ignorPopulated=False{
  1208.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::dbReplace()");
  1209.  
  1210.         if (!intval($this->getDBField('LANG_ID')))      $this->setDBField('LANG_ID',0);
  1211.         if (!intval($this->getDBField('MEN_LINKFK')))   $this->setDBField('MEN_LINKFK',0);
  1212.         
  1213.         $str_tmp $this->getDBField('MEN_SHORTLINK')
  1214.         if (empty($str_tmp))        
  1215.         {
  1216.             $this->setDBField('MEN_SHORTLINK','#');
  1217.         }
  1218.                 
  1219.         return parent::dbReplace($debug,$ignorPopulated);
  1220.     }
  1221.  
  1222.     /**
  1223.       * deletes a node from the database
  1224.       *
  1225.       * @param string $gDBIDX 
  1226.       * @param boolean $backupData 
  1227.       * @param boolean $debug 
  1228.       *
  1229.       * @return boolean 
  1230.       *
  1231.       * @since pk-05-11-29
  1232.       *
  1233.       * @todo CMS_MENU_NODE::dbDelete() inline SQL
  1234.       ***/
  1235.     function dbDelete($backupData=FALSE,$debug=FALSE{
  1236.         if ($debugecho "<p><b>CMS_MENU_NODE::dbDelete($gDBIDX,$backupData)</b> (".get_class($this).")</p>";
  1237.         $s_query="SELECT * FROM T_CMS_PAGE WHERE MEN_ID=".$this->getId();
  1238.         if (!$this->isConnected(TRUE,$debug)) // ensure $this->myDBObj is set
  1239.         {
  1240.             ocsp_logError(__FILE__,__LINE__,"no database connection",E_ERROR);
  1241.             return FALSE;
  1242.         }
  1243.         if ($o_cursor=$this->myDBObj->query($s_query)) {
  1244.             //require_once $GLOBALS['CMS']['PHPINCPATH']."page/function.phpinc";
  1245.             require_once __OCSP_CMS_PHPINCPATH__."page"._OCSP_DIRSEP_."CMS_PAGE_V2.phpclass";
  1246.             if ($debugecho "<blockquote><h2>Deleting Pages</h2>";
  1247.             while($a_row=$o_cursor->fetchArrayFld()) {
  1248.                 $obj_page=new CMS_PAGE_V2();
  1249.                 $obj_page->setDBRow($a_row);
  1250.                 $obj_page->dbDelete($backupData,$debug);
  1251.             }
  1252.             if ($debugecho "</blockquote>";
  1253.         }
  1254.  
  1255.         return parent::dbDelete($backupData,$debug);
  1256.     }
  1257.  
  1258.  
  1259.     /**
  1260.       * adds a node to childArray($key)
  1261.       *
  1262.       * @param DBMS_TREE_NODE $aNode 
  1263.       * @param boolean $debug 
  1264.       *
  1265.       * @return int 
  1266.       *
  1267.       ***/
  1268.     function addChildNode(&$aNode,$debug=FALSE{
  1269.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::addChildNode(".$aNode->getId().")");
  1270.  
  1271.         $aNode->setMyProject($this->getMyProject());
  1272.         if (!is_object($this->myProjObj))
  1273.         {
  1274.             $aNode->setProjId($this->getProjId());
  1275.         }
  1276.  
  1277.         return parent::addChildNode($aNode,$debug);
  1278.     }
  1279.  
  1280.  
  1281.     /**
  1282.       * copies the childs from the menu with id $sourceId
  1283.       * into this menu
  1284.       *
  1285.       * @param mixed &$source MEN_ID or menu object of sourcemenu
  1286.       * @param boll $copypage if true pages will be copied, else only menu sructure
  1287.       * @param bool $outdated if true copy only pages with show till > now
  1288.       * @param bool $debug 
  1289.       *
  1290.       * @since sw-05-12-30
  1291.       * @version pk-07-10-01
  1292.       *
  1293.       ***/
  1294.     function copyChildsFrom(&$source,$copypage=TRUE,$outdated=FALSE,$debug=FALSE{
  1295.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::copyChildsFrom()");
  1296.  
  1297.         if (!pcf_is_instance_of($source,'CMS_MENU_NODE'))
  1298.         {
  1299.             if (is_object($source)) return FALSE// schould be a special menu child node licke a product group
  1300.  
  1301.             if (!intval($source))
  1302.             {
  1303.                 ocsp_logError(__FILE__,__LINE__,"don't know what to do with <pre>".print_r($source,TRUE)."</pre>",E_WARNING);
  1304.                 return FALSE;
  1305.             }
  1306.             $obj_src=CMS_MENU_NODE::CMS_MENU_NODE_FROM_KEY($source);
  1307.             if (!pcf_is_instance_of($obj_src,'CMS_MENU_NODE')) return FALSE// schould be a special menu child node licke a product group
  1308.         else {
  1309.             $obj_src=&$source;
  1310.         }
  1311.  
  1312.         if (!intval($obj_src->getId()))
  1313.         {
  1314.             ocsp_logError(__FILE__,__LINE__,"source node is not populated",E_WARNING);
  1315.             return FALSE;
  1316.         }
  1317.  
  1318.         if ($arr_srcChildren=$obj_src->getChildrenList(TRUE,$debug,FALSE))
  1319.         {
  1320.             foreach($arr_srcChildren as &$obj_srcChild)
  1321.             {
  1322.                 if (intval($obj_srcChild->checkShowDate($debug)) || $outdated)
  1323.                 {
  1324.                     $arr_childVals=$obj_srcChild->getDBVal();
  1325.                     unset($arr_childVals[$this->myIdFld]);
  1326.  
  1327.                     $str_cmd="\$obj_newChild = new ".get_class($obj_srcChild)."();";
  1328.                     if ($debugechoDebugLine(__FILE__,__LINE__,$str_cmd);
  1329.                     eval($str_cmd);
  1330.                     $obj_newChild->setDBObj($this->getDBObj());
  1331.                     $obj_newChild->setDBVal($arr_childVals);
  1332.                     $obj_newChild->setParentObj($this);
  1333.                     $obj_newChild->dbSave();
  1334.                     $obj_newChild->copyChildsFrom($obj_srcChild,$copypage,$outdated,$debug);
  1335.                     if ($copypage)
  1336.                     {
  1337.                         $obj_newChild->copyPagesFrom($obj_srcChild->getId());
  1338.                     }
  1339.                 }
  1340.             }
  1341.         }
  1342.  
  1343.     }
  1344.  
  1345.     /**
  1346.       * copies the pages from the menu with id $sourceId
  1347.       * into this menu
  1348.       *
  1349.       * @param mixed $source    MEN_ID of sourcemenu or menu object
  1350.       * @param boll $copypage   if true pages will be copied, else only menu sructure
  1351.       * @param bool $outdated   if true copy only pages with show till > now
  1352.       * @param bool $debug 
  1353.       *
  1354.       * @since sw-05-12-30
  1355.       * @version pk-07-10-01
  1356.       *
  1357.       ***/
  1358.     function copyPagesFrom(&$source,$outdated=FALSE,$debug=FALSE{
  1359.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::copyPagesFrom()");
  1360.  
  1361.         if (!pcf_is_instance_of($source,'CMS_MENU_NODE'))
  1362.         {
  1363.             if (is_object($source)) return FALSE// schould be a special menu child node licke a product group
  1364.  
  1365.             if (!intval($source))
  1366.             {
  1367.                 ocsp_logError(__FILE__,__LINE__,"don't know what to do with <pre>".print_r($source,TRUE)."</pre>",E_WARNING);
  1368.                 return FALSE;
  1369.             }
  1370.             $obj_src=CMS_MENU_NODE::CMS_MENU_NODE_FROM_KEY($source);
  1371.             if (!pcf_is_instance_of($obj_src,'CMS_MENU_NODE')) return FALSE// schould be a special menu child node licke a product group
  1372.         else {
  1373.             $obj_src=&$source;
  1374.         }
  1375.  
  1376.         if (!intval($obj_src->getId()))
  1377.         {
  1378.             ocsp_logError(__FILE__,__LINE__,"source node is not populated",E_WARNING);
  1379.             return FALSE;
  1380.         }
  1381.  
  1382.         if ($arr_pageList=$obj_src->getPageList(TRUE,FALSE,$debug))
  1383.         {
  1384.             foreach($arr_pageList as &$obj_srcPage)
  1385.             {
  1386.                 $str_cmd="\$obj_newPage=new ".get_class($obj_srcPage)."();";
  1387.                 if ($debugechoDebugLine(__FILE__,__LINE__,$str_cmd);
  1388.                 eval ($str_cmd);
  1389.  
  1390.                 $obj_newPage->setDBObj($this->getDBObj());
  1391.                 $obj_newPage->setMyMenuNode($this,$debug);
  1392.  
  1393.                 $arr_pagVal=$obj_srcPage->getDBVal();
  1394.                 unset($arr_pagVal['PAG_ID']);
  1395.                 $arr_pagVal['MEN_ID']   =$this->getId();
  1396.                 $arr_pagVal['PROJ_ID']  =$this->getProjId();
  1397.                 $obj_newPage->setDBVal($arr_pagVal,$debug);
  1398.                 $obj_newPage->dbSave($debug);
  1399.  
  1400.                 if ($debugechoDebugLine(__FILE__,__LINE__,"<pre>".print_r($obj_newPage->getDBRow(),TRUE)."</pre>");
  1401.  
  1402.                 $obj_newPage->copyChaptersFrom($obj_srcPage->getId(),FALSE,$debug);
  1403.  
  1404.             }
  1405.         }
  1406.     }
  1407.  
  1408.     /**
  1409.       * returns if MEN_SHOW is on
  1410.       *
  1411.       * @return boolean 
  1412.       *
  1413.       * @since pk-07-08-23
  1414.       */
  1415.     function isEnabled()
  1416.     {
  1417.         return (intval($this->getDBField('MEN_SHOW')) True False);
  1418.     }
  1419.  
  1420.     /**
  1421.       * @since pk-07-08-23
  1422.       */
  1423.     function setEnabled()
  1424.     {
  1425.         $this->setDBFieldIfDiff('MEN_SHOW',1);
  1426.     }
  1427.  
  1428.     /**
  1429.       * @since pk-07-08-23
  1430.       */
  1431.     function setDisabled()
  1432.     {
  1433.         $this->setDBFieldIfDiff('MEN_SHOW',0);
  1434.     }
  1435.  
  1436.     /**
  1437.      * returns the group id allowed for the page
  1438.      *
  1439.      * @return int 
  1440.      */
  1441.     public function getShowGroup()
  1442.     {
  1443.         return intval($this->getDBField('MEN_SHOWGROUP'));
  1444.     }
  1445.     
  1446.     
  1447.     /**
  1448.       * checks if the node is on
  1449.       *
  1450.       * @param boolean $checkDate 
  1451.       * @param boolean $checkGroup 
  1452.       * @param boolean $debug 
  1453.       *
  1454.       * @return bool 
  1455.       *
  1456.       * @version pk-05-01-11
  1457.       * @version pk-06-01-30 checkShow added
  1458.       * @version pk-08-06-06
  1459.       */
  1460.     function isToShow($checkDate=True,$checkGroup=True,$debug=False,$checkShow=True{
  1461.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::isToShow(...) [" .$this->getId(": " .$this->getTitle()."]");
  1462.         if ((!$this->isEnabled()) && ($checkShow)) {
  1463.             if ($debugechoDebugLine(__FILE__,__LINE__,"<p>turned off</p>");
  1464.             return False;
  1465.         }
  1466.         if (($checkDate&& ($this->checkShowDate($debug!= 1)) {
  1467.             if ($debugechoDebugLine(__FILE__,__LINE__,"<p>outdated</p>");
  1468.             return False;
  1469.         }
  1470.  
  1471.         // <pk-08-06-06>
  1472.         if ($checkGroup && ($int_grpId $this->getShowGroup())) 
  1473.         {
  1474.             if (!OCSP_OBJ::currentUser()->isGroupMember($int_grpId,$debug))
  1475.             {
  1476.                 if ($debugechoDebugLine(__FILE__,__LINE__,"<p>not in group</p>");
  1477.                 return False;
  1478.             }            
  1479.         }
  1480.         // </pk-08-06-06>
  1481.         
  1482.         
  1483.         if (!empty($this->MEN_SHOWQUERY)) {
  1484.             require_once __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";
  1485.             $s_query "SELECT ".pcf_tmpl_parse($this->MEN_SHOWQUERY,$this->getDBVal(),$debug);
  1486.  
  1487.             if ($debugechoDebug(__FILE__,"<p>checkShowNode(".$this->getId()."SHOWQUERY: \n$s_query</p>");
  1488.             if (!$this->isConnected(TRUE))
  1489.             {
  1490.                 ocsp_logError(__FILE__,__LINE__,"no database connection to check: ".$this->MEN_SHOWQUERY,E_WARNING);
  1491.                 return FALSE;
  1492.             }
  1493.             if (!(intval($this->myDBObj->quickQuery($s_query,0)))) return FALSE;
  1494.         }
  1495.  
  1496.         return TRUE;
  1497.  
  1498.     }
  1499.  
  1500.     /**
  1501.       * PROTOTYPE:
  1502.       *
  1503.       * returns if the object is to echo in the tree when creating the html-code
  1504.       * or only children are to show
  1505.       *
  1506.       * @param boolean $debug 
  1507.       *
  1508.       * @return boolean (TRUE)
  1509.       *
  1510.       * @since pk-06-05-30
  1511.       *
  1512.       ***/
  1513.     function isToEcho($debug=False{
  1514.         return True;
  1515.     }
  1516.  
  1517.     /**
  1518.       * PROTOTYPE:
  1519.       *
  1520.       * returns if html-code should add an intend statement
  1521.       * before children(list) is outputed
  1522.       *
  1523.       * @param boolean $debug 
  1524.       *
  1525.       * @return boolean (TRUE)
  1526.       *
  1527.       * @since pk-06-05-30
  1528.       *
  1529.       ***/
  1530.     function areChildrenToIntend($debug=False{
  1531.         return True;
  1532.     }
  1533.  
  1534.  
  1535.     /**
  1536.       * checks if the node has children which are on
  1537.       *
  1538.       * @param boolean $filtered use filter
  1539.       * @param boolean $checkDate 
  1540.       * @param boolean $checkGroup 
  1541.       * @param boolean $debug 
  1542.       *
  1543.       * @return bool 
  1544.       *
  1545.       * @version pk-05-06-14
  1546.       * @version pk-06-01-30 checkShow added
  1547.       *
  1548.       ***/
  1549.     function hasChildrenToShow($filtered=FALSE,$checkDate=TRUE,$checkGroup=TRUE,$debug=FALSE,$checkShow=TRUE{
  1550.         if ($debugecho "<p><b>CMS_MENU_NODE::hasChildrenToShow(\$filtered=$filetered,\$checkDate=$checkDate,\$checkGroup=$checkGroup,...)</b> (".get_class($this).")</p>";
  1551.  
  1552.         if ((time()-$this->myChildCacheTTL$this->hasChildrenToShowTS{
  1553.             if ($debugecho "<blockquote>Cached</blockquote>\n";
  1554.             return TRUE;
  1555.         }
  1556.  
  1557.         if ($childArr=$this->getChildrenList(TRUE,$debug,$filtered)) {
  1558.             foreach($childArr as $child{
  1559.                 if ($child->isToShow($checkDate,$checkGroup,$debug,$checkShow)) {
  1560.                     $this->hasChildrenToShowTS=time();
  1561.                     if ($debugecho "<blockquote style=\"background-color: green;\">CMS_MENU_NODE::hasChildrenToShow returns TRUE</blockquote>";
  1562.                     return TRUE;
  1563.                 }
  1564.             }
  1565.         }
  1566.         return FALSE;
  1567.     }
  1568.  
  1569.     /**
  1570.       * checks if the menu is to show from date
  1571.       *
  1572.       * return values are:
  1573.       *
  1574.       * - 1: yes
  1575.       * - 0: showtill is outdate
  1576.       * - -2: showfrom is not reached
  1577.       *
  1578.       * @return int 
  1579.       *
  1580.       * @since pk-04-07-23
  1581.       * @version pk-08-08-01
  1582.       */
  1583.     function checkShowDate($debug=False{
  1584.         pcf_require_class('OCSP_DATE',"common/");
  1585.  
  1586.         $obj_Date new OCSP_DATE();
  1587.         $obj_Date->setDbString($this->getDBField('MEN_SHOWFROM'));
  1588.         if ($obj_Date->isInFutur()) 
  1589.         {
  1590.             return -2;
  1591.         }
  1592.  
  1593.         $obj_Date->setDbString($this->getDBField('MEN_SHOWTILL'));
  1594.         if ($obj_Date->isInPast())
  1595.         {
  1596.             return 0;
  1597.         }
  1598.  
  1599.         return 1;
  1600.     }
  1601.  
  1602.     /**
  1603.       * returns a array back to the root
  1604.       * if we have MEN_LINKTYPE 10 ($page->subMenu()) the page menu
  1605.       * is included in the rootPath if $GLOBALS['CURRENT_PROJ']->curMen
  1606.       *
  1607.       * @param boolean $useCache 
  1608.       * @param boolean $debug 
  1609.       *
  1610.       * @return array 
  1611.       *
  1612.       * @since pk-05-07-25
  1613.       * @version pk-08-06-19
  1614.       */
  1615.     function getRootPath($useCache=True,$debug=False{
  1616.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getRootPath(".($useCache "USECACHE" "NOCHACHE").")",$this->getId()."/".substr($this->getTitle(),0,8)."...");
  1617.  
  1618.         if (!$this->getParentObj($useCache,$debug))
  1619.         {
  1620.             if ($debugechoDebugLine(__FILE__,__LINE__,"Root Node");
  1621.             $arr_ret array();
  1622.         else {
  1623.             $arr_ret $this->myParent->getRootPath($useCache,$debug);
  1624.         }
  1625.  
  1626.         $arr_ret[&$this;
  1627.         return $arr_ret;
  1628.     }
  1629.  
  1630.  
  1631.     /**
  1632.       * creates a child object out of database row
  1633.       * checks $dbRow['MEN_OBJCLASS'] to determine the class of the new object
  1634.       *
  1635.       * NOTE does not add the object to the tree only sets objects parent
  1636.       *
  1637.       * @param array $dbRow 
  1638.       * @param boolean $debug 
  1639.       *
  1640.       * @return object 
  1641.       *
  1642.       * @since pk-05-11-22
  1643.       * @version pk-05-12-13
  1644.       * @version pk-07-08-10
  1645.       * @version pk-08-06-13
  1646.       */
  1647.     function newChildObj($dbRow,$debug=False{
  1648.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::newChildObj()");
  1649.         
  1650.         // <pk-05-12-13>
  1651.         if (empty($dbRow['MEN_OBJCLASS'])) {
  1652.             // unknown object class asume default
  1653.             if ($debugechoDebugLine(__FILE__,get_class($this),"MEN_OBJCLASS not set calling parent::newChildObj()");
  1654.             return parent::newChildObj($dbRow,$debug);
  1655.         }
  1656.  
  1657.         $s_menuClass=$dbRow['MEN_OBJCLASS'];
  1658.         // <pk-08-06-11><pk-08-06-13 />
  1659.         if (!(CMS_TABLEOBJ::menuType_requireClass($s_menuClass,$debug))) 
  1660.         {
  1661.             throw new Exception(_OCSP_EXCEP_CLASSNOTFOUND_ ":" $s_menuClass);
  1662.         }
  1663.         // </pk-08-06-11 />
  1664.         
  1665.         // <pk-05-12-13>
  1666.         $o_tmpObj=NULL;
  1667.         $s_cmd="\$o_tmpObj=new ".$s_menuClass."();";
  1668.         eval($s_cmd);
  1669.         if (pcf_is_instance_of($o_tmpObj,$s_menuClass)) {
  1670.             $o_tmpObj->setDBObj($this->getDBObj());
  1671.             $o_tmpObj->setDBRow($dbRow,TRUE);
  1672.             if (intval($o_tmpObj->getId()))
  1673.             {
  1674.                 $o_tmpObj->setTreeObj($this->getTree());
  1675.                 $o_tmpObj->setParentObj($this);
  1676.             }
  1677.         else {
  1678.             if ($debugechoDebugLine(__FILE__,__LINE__,"\$o_tmpObj is not an instance of $s_menuClass ".get_type($o_tmpObj));
  1679.         }
  1680.         return $o_tmpObj;
  1681.     }
  1682.  
  1683.  
  1684.  
  1685.     /**
  1686.       * returns the previos menu (sibling)
  1687.       *
  1688.       * first check if we have a menu node with the same parent and MEN_SORTORDER < $this->MEN_SORTORDER
  1689.       * then go up in the tree if $goUp
  1690.       *
  1691.       * @param boolean $goUp 
  1692.       * @param boolean $isOnline return only a menu node which is currently online
  1693.       * @param boolean $useCache 
  1694.       * @param boolean $debug 
  1695.       *
  1696.       * @return CMS_MENU_NODE 
  1697.       *
  1698.       * @since pk-07-01-10
  1699.       *
  1700.       ***/
  1701.     function &getPrevSibling($goUp=TRUE,$isOnline=TRUE,$useCache=TRUE,$debug=FALSE{
  1702.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getPrevSibling()","MEN_ID: ".$this->getId());
  1703.  
  1704.         $o_ret=NULL;
  1705.         if ($o_parent=$this->getParentObj(TRUE,$debug)) {
  1706.             $a_nodeLst=$o_parent->getChildrenList(TRUE,$debug);
  1707.             if (is_array($a_nodeLst)) {
  1708.                 reset ($a_nodeLst);$b_reached=FALSE;$o_prevNode=NULL;
  1709.                 while (!$b_reached && (list(,$o_nodeeach ($a_nodeLst))) {
  1710.                     if ($o_node->getId()==$this->getId()) {
  1711.                         $b_reached=TRUE;
  1712.                     else {
  1713.                         if ($isOnline && $o_node->isToShow()) {
  1714.                             $o_prevNode=$o_node;
  1715.                         else if (!$isOnline{
  1716.                             $o_prevNode=$o_node;
  1717.                         }
  1718.                     }
  1719.                 }
  1720.                 if ($o_prevNode{
  1721.                     return $o_prevNode;
  1722.                 else if ($goUp{
  1723.                     if ($o_parent->isToShow()) {
  1724.                         return $o_parent;
  1725.                     else {
  1726.                         return $o_parent->getPrevSibling($goUp,$isOnline,$debug);
  1727.                     }
  1728.                 else {
  1729.                     return $o_ret;
  1730.                 }
  1731.             }
  1732.         else {
  1733.             return $o_ret;
  1734.         }
  1735.     }
  1736.  
  1737.     /**
  1738.       * returns the next menu (sibling)
  1739.       *
  1740.       * first check if we have a menu node with the same parent and MEN_SORTORDER > $this->MEN_SORTORDER
  1741.       * if not then go down in the tree if $goDown
  1742.       *
  1743.       * @param boolean $goUp 
  1744.       * @param boolean $isOnline return only a menu node which is currently online
  1745.       * @param boolean $useCache 
  1746.       * @param boolean $debug 
  1747.       *
  1748.       * @return CMS_MENU_NODE 
  1749.       *
  1750.       * @since pk-07-01-10
  1751.       *
  1752.       ***/
  1753.     function &getNextSibling($goDown=TRUE,$isOnline=TRUE,$useCache=TRUE,$debug=FALSE{
  1754.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getNextSibling()","MEN_ID: ".$this->getId());
  1755.  
  1756.         $o_ret=NULL;
  1757.         if ($o_parent=$this->getParentObj(TRUE,$debug)) {
  1758.             $a_nodeLst=$o_parent->getChildrenList(TRUE,$debug);
  1759.             if (is_array($a_nodeLst)) {
  1760.                 reset ($a_nodeLst);$o_nextNode=NULL;
  1761.                 $b_reached=FALSE;
  1762.                 while (list(,$o_nodeeach ($a_nodeLst)) {
  1763.                     if ($o_node->getId()==$this->getId()) {
  1764.                         $b_reached=TRUE;
  1765.                     else if ($b_reached{
  1766.                         if ($isOnline && $o_node->isToShow()) {
  1767.                             return $o_node;
  1768.                         else if (!$isOnline{
  1769.                             return $o_node;
  1770.                         else if ($goDown && ($o_node=$this->getFirstChild($isOnline,$useCache,$debug))) {
  1771.                             return $o_node;
  1772.                         }
  1773.                     }
  1774.                 }
  1775.  
  1776.             }
  1777.         else {
  1778.             return $o_ret;
  1779.         }
  1780.     }
  1781.  
  1782.     /**
  1783.       * returns the first child
  1784.       *
  1785.       * @param boolean $isOnline 
  1786.       * @param boolean $useCache 
  1787.       * @param boolean $debug 
  1788.       *
  1789.       * @return CMS_MENU_NODE 
  1790.       *
  1791.       * @since pk-07-01-10
  1792.       *
  1793.       ***/
  1794.     function &getFirstChild($isOnline=TRUE,$useCache=TRUE,$debug=FALSE{
  1795.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getNextSibling()","MEN_ID: ".$this->getId());
  1796.         $a_nodeLst=$this->getChildrenList(TRUE,$debug);
  1797.  
  1798.         if (is_array($a_nodeLst)) {
  1799.             reset($a_nodeLst);
  1800.             while (list(,$o_nodeeach ($a_nodeLst)) {
  1801.                 if ($isOnline && $o_node->isToShow()) {
  1802.                     return $o_node;
  1803.                 else if (!$isOnline{
  1804.                     return $o_node;
  1805.                 }
  1806.             }
  1807.         }
  1808.  
  1809.         $o_ret=NULL;
  1810.         return $o_ret;
  1811.  
  1812.     }
  1813.  
  1814.     // ----------------------------------------------------------
  1815.     // cms methods
  1816.     // ----------------------------------------------------------
  1817.     
  1818.     /**
  1819.       * returns if the node is deletable or not
  1820.       *
  1821.       * @param boolean $debug 
  1822.       *
  1823.       * @return boolean 
  1824.       *
  1825.       * @since pk-05-11-29
  1826.       *
  1827.       ***/
  1828.     function isDeleteable($debug=False
  1829.     {
  1830.         if ($debugecho "<p><b>CMS_MENU_NODE::isDeleteable()</b> (".get_class($this).")</p>\n";
  1831.         if ($this->numberOfChildren(TRUE,$debug)) {
  1832.             return FALSE;
  1833.         }
  1834.  
  1835.         return TRUE;
  1836.     }
  1837.  
  1838.     /**
  1839.      * returns if the node is editable
  1840.      *
  1841.      * @param boolean $debug 
  1842.      * @return boolean 
  1843.      */
  1844.     public function isEditable($debug=False)
  1845.     {
  1846.         return True;
  1847.     }
  1848.     
  1849.     /**
  1850.      * return if the menu type can have editable pages
  1851.      * 
  1852.      * if not the menu generates it's page object himself
  1853.      * users are not able to add pages to the menu
  1854.      *
  1855.      * @param boolean $debug 
  1856.      * 
  1857.      * @return boolean 
  1858.      * 
  1859.      * @since pk-08-12-03
  1860.      */
  1861.     public function hasEditablePages($debug=False)
  1862.     {
  1863.         return True;
  1864.     }
  1865.     
  1866.     
  1867.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1868.     // user methods
  1869.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1870.  
  1871.     /**
  1872.       * returns if the current user can open the menu
  1873.       *
  1874.       * @param boolean $debug 
  1875.       *
  1876.       * @return boolean 
  1877.       *
  1878.       * @since pk-06-11-11
  1879.       * @version pk-06-11-15 return $this->curUserCanEdit($debug) instead of FALSE
  1880.       *
  1881.       ***/
  1882.     public function curUserCanOpen($debug=FALSE{
  1883.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::curUserCanOpen()");
  1884.  
  1885.         $this->getMyProject()// to ensure we have the right project object
  1886.         if (!$this->myProjObj->curUserCanOpen($debug)) {
  1887.             if ($debugechoDebug(__FILE__,"<p>Project check failed</p>");
  1888.             return FALSE;
  1889.         }
  1890.         if ($debug{
  1891.             echoDebug(__FILE__,"<p>Checking Group: ".$this->getDBField('MEN_SHOWGROUP')."</p>");
  1892.         }
  1893.         if ($GLOBALS['USER']->isGroupMember(intval($this->getDBField('MEN_SHOWGROUP')))) {
  1894.             if ($debugechoDebug(__FILE__,"<p>check passed</p>");
  1895.             return TRUE;
  1896.         else {
  1897.             return $this->curUserCanEdit($debug);
  1898.         }
  1899.     }
  1900.  
  1901.     /**
  1902.       * returns if the current user can add a childmenu
  1903.       *
  1904.       * @param boolean $debug 
  1905.       *
  1906.       * @return boolean 
  1907.       *
  1908.       * @since pk-05-12-14
  1909.       *
  1910.       ***/
  1911.     public function curUserCanAddChild($debug=False{
  1912.         if ($debugechoDebug(__FILE__,"<p><b>CMS_MENU_NODE::userCanAddChild($userId)</b> (".get_class($this).")</p>");
  1913.  
  1914.         $this->getMyProject()// to ensure we have the right project object
  1915.         return $this->myProjObj->curUserIsAuthor();
  1916.     }
  1917.  
  1918.     /**
  1919.       * returns if the current user can add a page
  1920.       *
  1921.       * @param boolean $debug 
  1922.       *
  1923.       * @return boolean 
  1924.       *
  1925.       * @since pk-05-12-14
  1926.       *
  1927.       ***/
  1928.     public function curUserCanAddPage($debug=false{
  1929.         if ($debugechoDebug(__FILE__,"<p><b>CMS_MENU_NODE::curUserCanAddPage($userId)</b> (".get_class($this).")</p>");
  1930.  
  1931.         $this->getMyProject()// to ensure we have the right project object
  1932.         return $this->myProjObj->curUserIsAuthor();
  1933.     }
  1934.  
  1935.     /**
  1936.       * returns if the current user can delete the menu
  1937.       *
  1938.       * @param boolean $debug 
  1939.       *
  1940.       * @return boolean 
  1941.       *
  1942.       * @since pk-05-12-14
  1943.       *
  1944.       ***/
  1945.     public function curUserCanDelete($debug=False{
  1946.         if ($debugechoDebug(__FILE__,"<p><b>CMS_MENU_NODE::curUserCanDelete($userId)</b> (".get_class($this).")</p>");
  1947.  
  1948.         if ($this->isDeleteable($debug)) {
  1949.             $this->getMyProject()// to ensure we have the right project object
  1950.  
  1951.             if ((!$this->isEnabled()) && ($this->checkShowDate(== -2)) {
  1952.                 // menu is hidden and show from is in future
  1953.                 return $this->myProjObj->curUserIsAuthor();
  1954.             else {
  1955.                // the page is online or in the archive
  1956.                 return $this->myProjObj->curUserIsEditor();
  1957.             }
  1958.         else if ($debugechoDebug(__FILE__,"<blockquote>MENU IS NOT DELETEABLE</blockquote>");
  1959.         return FALSE;
  1960.     }
  1961.  
  1962.     /**
  1963.       * returns if the current user can edit the menu
  1964.       *
  1965.       * @param boolean $debug 
  1966.       *
  1967.       * @return boolean 
  1968.       *
  1969.       * @since pk-06-11-06
  1970.       *
  1971.       ***/
  1972.     public function curUserCanEdit($debug=False{
  1973.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::curUserCanEdit()");
  1974.  
  1975.         $this->getMyProject()// to ensure we have the right project object
  1976.         return $this->myProjObj->curUserCanEdit();
  1977.     }
  1978.     
  1979.     public function curUserCanFormMode($aMode,$debug=False)
  1980.     {
  1981.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::curUserCanFormMode({$aMode});");
  1982.         
  1983.         switch(intval($aMode))
  1984.         {
  1985.             case FRM_MODE_NEW:
  1986.             case FRM_MODE_COPY:
  1987.                 return ($this->isEditable(&& $this->curUserCanAddChild());
  1988.             case FRM_MODE_EDIT:
  1989.                 return ($this->isEditable(&& $this->curUserCanEdit());
  1990.             case FRM_MODE_DELETE:
  1991.                 return $this->curUserCanDelete();
  1992.             default:
  1993.                 return $this->curUserCanOpen();
  1994.         }
  1995.         
  1996.         return False;
  1997.         
  1998.         
  1999.     }
  2000.  
  2001.     // -----------------------------------------------------------------
  2002.     //  sidemenu methods
  2003.     // -----------------------------------------------------------------
  2004.     
  2005.     /**
  2006.       * checks if the object is in the rootPath $rPath
  2007.       * if $rPath is not an array $GLOBALS['CURRENT_ROOTPATH'] is checked
  2008.       *
  2009.       * @param array $rPath 
  2010.       * @param boolean $debug 
  2011.       *
  2012.       * @return boolean 
  2013.       *
  2014.       * @since pk-06-02-23
  2015.       *
  2016.       ***/
  2017.     function isInPath($rPath=NULL,$debug=FALSE{
  2018.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::isInPath()","",0);
  2019.  
  2020.         if (!is_array($rPath)) {
  2021.             if (!is_array($GLOBALS['CURRENT_ROOTPATH'])) {
  2022.                 return FALSE;
  2023.             else {
  2024.                 $rPath=$GLOBALS['CURRENT_ROOTPATH'];
  2025.             }
  2026.         }
  2027.  
  2028.         foreach($rPath as $o_node{
  2029.             if ($o_node->getId()==$this->getId()) return TRUE;
  2030.         }
  2031.         return FALSE;
  2032.     }
  2033.  
  2034.  
  2035.     /**
  2036.       * returns the html-code for the sidemenu link
  2037.       * @param string $class 
  2038.       * @param boolean $debug 
  2039.       *
  2040.       * @return string 
  2041.       *
  2042.       ***/
  2043.     function getSideMenuLink($class="",$debug=FALSE{
  2044.         if (empty($this->pageUrl)) {
  2045.             $this->pageUrl=$_SERVER['SCRIPT_NAME'];
  2046.         }
  2047.  
  2048.         $getVar=$_GET;
  2049.         unset($getVar['MEN_ID']);
  2050.         unset($getVar['MEN_PARENT']);
  2051.         unset($getVar['PROJ_ID']);
  2052.         unset($getVar['LANG_ID']);
  2053.         unset($getVar['PGP_ID']);
  2054.         unset($getVar['NORELOAD']);
  2055.         unset($getVar['cmd']);
  2056.  
  2057.         $target="";
  2058.         $ret="<a class='".$class."' href=";
  2059.  
  2060.         $menParam="PROJ_ID=".$this->PROJ_ID."&MEN_ID=".$this->MEN_ID."&LANG_ID=".$this->LANG_ID;
  2061.  
  2062.         switch($this->MEN_LINKTYPE{
  2063.             case 1:
  2064.                 // HTML-URL
  2065.                 require_once __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";
  2066.                 $url=pcf_tmpl_parse($this->MEN_LINK,$this->getDBVal(),$debug);
  2067.                 if (!strstr($this->MEN_LINK,"PROJ_ID")) $url.= (strstr($url,"?""&" "?")."PROJ_ID=".$this->PROJ_ID;
  2068.                 if (!strstr($this->MEN_LINK,"MEN_ID")) $url.= (strstr($url,"?""&" "?")."MEN_ID=".$this->MEN_ID;
  2069.                 if (!strstr($this->MEN_LINK,"LANG_ID")) $url.= (strstr($url,"?""&" "?")."LANG_ID=".$this->LANG_ID;
  2070.                 $ret.= "\"".$url."\"";
  2071.                 $target=$this->MEN_TARGET;
  2072.                 break;
  2073.             // case 2: PAGE is default
  2074.  
  2075.             case 3:
  2076.                 // PRODUCT PAGE
  2077.                 if (empty($GLOBALS['PROJECT']['PRODGRPURL'])) {
  2078.                     $ret.= "\"/cms/prodgrp.php";
  2079.                 else {
  2080.                     $ret.="\"".$GLOBALS['PROJECT']['PRODGRPURL'];
  2081.                 }
  2082.  
  2083.                 $ret.= "?".$menParam."&PGP_ID=".$this->MEN_LINKFK;
  2084.                 unset($getVar['PGP_ID']);
  2085.                 foreach($getVar as $key => $val$ret.= "&$key=$val";
  2086.                 $ret.="\""// " for editor layout :-)
  2087.                 $target=$this->MEN_TARGET;
  2088.                 break;
  2089.             case 4:
  2090.                 $ret.="\"mailto:".$this->MEN_LINK."\"";
  2091.                 break;
  2092.             case 5:
  2093.                 // home
  2094.                 $ret.="\"http://".$_SERVER['SERVER_NAME']."\"";
  2095.                 $target="_top";
  2096.                 break;
  2097.             case 6:
  2098.                 // HTML-Code
  2099.                 require_once __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";
  2100.                 return pcf_tmpl_parse($this->MEN_LINK,$this->getDBVal(),$debug);
  2101.             case 7:
  2102.                 // PopUp Window
  2103.                 require_once __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";
  2104.                 $url=pcf_tmpl_parse($this->MEN_LINK,$this->getDBVal(),$debug);
  2105.                 $ret.="\"#\" onClick=\"popup_window('".$url."',200,400);\"";
  2106.                 break;
  2107.             case 8:
  2108.                 // JavaScript
  2109.                 require_once __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";
  2110.                 $url=pcf_tmpl_parse($this->MEN_LINK,$this->getDBVal(),$debug);
  2111.                 $ret.="\"#\" onClick=\"".$url."\"";
  2112.                 break;
  2113.  
  2114.             case 9:
  2115.                 // Warenkorb
  2116.                 $ret.="\"".$GLOBALS['PROJECT']['BASKETURL'].$menParam;
  2117.                 foreach($getVar as $key => $val$ret.= "&$key=$val";
  2118.                 $ret.= "\"";
  2119.                 break;
  2120.             case 10:
  2121.                 // $page->subMenu();
  2122.                 global $page;
  2123.                 if (pcf_object_has_method($page,"getSubMenu",$debug)) {
  2124.                     return $page->getSubMenu($debug);
  2125.                 }
  2126.                 break;
  2127.             default:
  2128.                 $ret.="\"".$this->pageUrl."?".$menParam;
  2129.                 foreach($getVar as $key => $val$ret.= "&$key=$val";
  2130.                 $ret.="\"";
  2131.                 $target=$node['MEN_TARGET'];
  2132.         }
  2133.  
  2134.         if (!empty($target)) $ret.=" target=\"".$target."\"";
  2135.         $ret.=">".$this->getTitle()."</a>";
  2136.         return $ret;
  2137.  
  2138.     }
  2139.  
  2140.     /**
  2141.       * writes a sidemneu row
  2142.       *
  2143.       * @param string $class css-style class to use for <a>
  2144.       * @param boolean $debug 
  2145.       ***/
  2146.     function writeSideMenuRow($class="",$debug{
  2147.         if ($debugecho "<p><b>CMS_MENU_NODE::writeSideMenuRow($class,$debug)</b> (".get_class($this).")</p>";
  2148.         echo $this->trTag;
  2149.         echo $this->tdTag;
  2150.         echo $this->getSideMenuLink($class,$debug);
  2151.         echo "</td></tr>\n";
  2152.     }
  2153.  
  2154.     /**
  2155.       * writes a sidemneu row on Path to the selected node
  2156.       *
  2157.       * @param string $class css-style class to use for <a>
  2158.       * @param boolean $debug 
  2159.       ***/
  2160.     function writeSideMenuRowOnPath($treePath,$class="",$debug=FALSE{
  2161.         if ($debugecho "<tr><td><b>CMS_MENU_NODE::writeSideMenuRowOnPath($path,$class,$debug)</b> (".get_class($this).")</td></tr>";
  2162.         echo $this->writeSideMenuRow($class,$debug);
  2163.  
  2164.         if (sizeof($this->myChildren)) {
  2165.             echo "<tr><td align=\"right\">";
  2166.  
  2167.             echo $this->subtblTag."\n";
  2168.             array_shift($treePath)// remove the first id (points to $this)
  2169.             foreach($this->myChildren as $orderNr => $id{
  2170.                 $node=$GLOBALS['OCSP_VAL']['DBMS_TREE'][$this->getGlobalTreeKey()][$id];
  2171.                 $node->subtblTag=$this->subtblTag;
  2172.                 $node->trTag    ="\t".$this->trTag;
  2173.                 $node->tdTag    =$this->tdTag;
  2174.                 $node->pageUrl  =$this->pageUrl;
  2175.                 if ((!is_object($treePath[0])) || ($id != $treePath[0]->getId())) {
  2176.                     if ($node->isToShow(TRUE,TRUE,$debug)) {
  2177.                         $node->writeSideMenuRow("",$debug);
  2178.                     }
  2179.                 else {
  2180.                     $node->writeSideMenuRowOnPath($treePath,"",$debug);
  2181.                 }
  2182.             }
  2183.             echo "</table></td></tr>\n";
  2184.         }
  2185.     }
  2186.  
  2187.     // -----------------------------------------------------------------
  2188.     //  public methods
  2189.     // -----------------------------------------------------------------
  2190.     
  2191.     /**
  2192.       * converts the title to a dirname this can be used with url-rewriting
  2193.       *
  2194.       * @return string 
  2195.       *
  2196.       * @since pk-06-07-27
  2197.       *
  2198.       ***/
  2199.     function getTitleAsDirName({
  2200.         $s_dirName $this->getTitle();
  2201.         $s_dirName preg_replace('/<.*>/i',"",$s_dirName)// replace html tags
  2202.  
  2203.         $s_dirName str_replace("Ä","Ae",$s_dirName);
  2204.         $s_dirName str_replace("ä","ae",$s_dirName);
  2205.         $s_dirName str_replace("Ö","Oe",$s_dirName);
  2206.         $s_dirName str_replace("ö","oe",$s_dirName);
  2207.         $s_dirName str_replace("Ü","Ue",$s_dirName);
  2208.         $s_dirName str_replace("ü","ue",$s_dirName);
  2209.         $s_dirName str_replace("ß","ss",$s_dirName);
  2210.  
  2211.         $s_dirName str_replace("-","",$s_dirName);
  2212.         return preg_replace('/[^a-z0-9_\-\.]/i',""$s_dirName);
  2213.     }
  2214.  
  2215.     /**
  2216.       * returns the link url
  2217.       *
  2218.       * @param array $valArr 
  2219.       * @param boolean $debug 
  2220.       *
  2221.       * @return string 
  2222.       *
  2223.       * @since pk-05-01-20
  2224.       * @version pk-06-08-07 bugfix
  2225.       * @version pk-06-09-28 $GLOBALS['OCSP_CMS']['MENLINKTMPL'] added
  2226.       * @version pk-08-06-20
  2227.       */
  2228.     function getLinkUrl($valArr=array(),$debug=False
  2229.     {             
  2230.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getLinkUrl()","<pre style=\"font-size:75%\">" print_r($valArr,True"</pre>");
  2231.  
  2232.         if (!function_exists('pcf_tmpl_parse')) require_once __OCSP_PHPINCPATH__ ."common" _OCSP_DIRSEP_ "pcf_templates.phpinc";
  2233.         $obj_conf OCSP_CONF::getInstance('OCSP_CMS');
  2234.         
  2235.         $str_menParams ="PROJ_ID=".$this->getProjId();
  2236.         $str_menParams.="&MEN_ID=".$this->getKey();        
  2237.         if (isset($valArr['PAG_ID']))     $str_menParams.="&PAG_ID=".$valArr['PAG_ID'];
  2238.         
  2239.         if (!isset($valArr['PROJ_ID'])) $valArr['PROJ_ID']$this->getProjId();       
  2240.         if (!isset($valArr['MEN_ID']))     $valArr['MEN_ID'$this->getKey();
  2241.         
  2242.         $str_ret="";
  2243.         switch($this->MEN_LINKTYPE{
  2244.             
  2245.             case 1:     // HTML-URL  
  2246.                 
  2247.                 $str_ret=pcf_tmpl_parse($this->MEN_LINK,array_merge($this->getDBVal(),$valArr),$debug);
  2248.                                 
  2249.                 break;             
  2250.                     
  2251.             case 2:     // MENU
  2252.             case 10:     // $page->getSubMenu();
  2253.                 $str_linkUrl     $obj_conf->getValue('MENLINKURL');
  2254.                 $str_linkTmpl   $obj_conf->getValue('MENLINKTMPL');
  2255.                 $bol_rewrite     $obj_conf->getValue('REWRITE');
  2256.                 
  2257.                 if (empty($str_linkUrl&& empty($str_linkTmpl))
  2258.                 {
  2259.                     $str_ret "/index.php?".$str_menParams;
  2260.                     break;
  2261.                 }
  2262.                 
  2263.                 if (!empty($str_linkTmpl&& !$bol_rewrite)
  2264.                 {                    
  2265.                     $str_ret pcf_tmpl_parse($str_linkTmpl,array_merge($this->getDBVal(),$valArr));
  2266.                     break;
  2267.                 }
  2268.                 
  2269.                 if ($bol_rewrite)
  2270.                 {
  2271.                     $str_linkUrl (empty($str_linkUrl"/" $str_linkUrl);
  2272.                     $str_ret str_replace("#MEN_TITLE#",$this->getTitleAsDirName(),$str_linkUrl);
  2273.                     
  2274.                     $cha_sep ($obj_conf->getValue('MENLINKSEP'$obj_conf->getValue('MENLINKSEP'"/" );
  2275.                     
  2276.                     $str_ret.= (isset($valArr['PROJ_ID']$valArr['PROJ_ID'$this->getProjId()) $cha_sep;
  2277.                     $str_ret.= $valArr['MEN_ID'$cha_sep;
  2278.                     $str_ret.= ((isset($valArr['PAG_ID']&& !empty($valArr['PAG_ID'])) $valArr['PAG_ID'0)
  2279.                     
  2280.                     if (intval($obj_conf->getValue('APPENDHTML')))
  2281.                     {
  2282.                         $str_ret.=".html";
  2283.                     }                                    
  2284.                     $str_ret pcf_tmpl_parse($str_ret,array_merge($this->getDBVal(),$valArr));
  2285.                     if ($debugechoDebugLine(__FILE__,__LINE__,"rewrite url: " $str_ret "<pre>" print_r($valArr,True"</pre>");
  2286.                     break;
  2287.                 else {
  2288.                     $str_ret "/index.php?" $str_menParams;
  2289.                 }
  2290.                 
  2291.                 break;
  2292.             case 3// PRODUCT PAGE
  2293.                 if (empty($GLOBALS['PROJECT']['PRODGRPURL'])) {
  2294.                     $str_ret"/cms/prodgrp.php";
  2295.                 else {
  2296.                     $str_ret=$GLOBALS['PROJECT']['PRODGRPURL'];
  2297.                 }
  2298.                 $str_ret.= "?".$str_menParams."&PGP_ID=".$this->MEN_LINKFK;
  2299.                 foreach($_GET as $key => $valif (!strstr($str_ret,$key)) $str_ret.= "&$key=$val";
  2300.                 return $str_ret;
  2301.             case 4// mailto
  2302.                 return "mailto:".$this->MEN_LINK;
  2303.             case 5// home
  2304.                 if ($pjUrl=OCSP_OBJ::defaultReadDBObj()->quickQuery("SELECT PROJ_URL FROM T_CMS_PROJECT WHERE PROJ_ID=".$this->PROJ_ID,0)) {
  2305.                     return $pjUrl;
  2306.                 else {
  2307.                     return "/";
  2308.                 }
  2309.             case 6// HTML-Code                            
  2310.                 return pcf_tmpl_parse($this->MEN_LINK,array_merge($this->getDBVal(),$valArr),$debug);
  2311.                 
  2312.             case 7// PopUp Window
  2313.                 $url=pcf_tmpl_parse($this->MEN_LINK,array_merge($this->getDBVal(),$valArr),$debug);
  2314.                 return "javscript:{popup_window('".$url."',200,400);}";
  2315.             case 8// JavaScript
  2316.                 if (!stristr($this->getDBField('MEN_LINK'),'javascript'))
  2317.                 {
  2318.                     return "javascript: ".str_replace('"','\"',pcf_tmpl_parse($this->MEN_LINK,array_merge($this->getDBVal(),$valArr),$debug));
  2319.                 else {
  2320.                     return pcf_tmpl_parse($this->MEN_LINK,array_merge($this->getDBVal(),$valArr),$debug);
  2321.                 }
  2322.  
  2323.             case 9// Warenkorb
  2324.                 $str_ret=$GLOBALS['PROJECT']['BASKETURL']."?".$str_menParams;
  2325.                 foreach($_GET as $key => $valif (!strstr($str_ret,$key)) $str_ret.= "&$key=$val";
  2326.                 break;
  2327.             default:
  2328.                 $str_ret="/index.php";
  2329.                 $sep="?";
  2330.                 foreach($this->myKeys as $key => $val{
  2331.                     $str_ret.=$sep.$key."=".str_replace("\"","",$this->{$key});
  2332.                     $sep="&";
  2333.                 }
  2334.                 break;
  2335.         }
  2336.  
  2337.         if (isset($GLOBALS['MENU_ADD_GET']&& is_array($GLOBALS['MENU_ADD_GET'])) {
  2338.             foreach($GLOBALS['MENU_ADD_GET'as $s_key => $m_val{
  2339.                 $str_ret=pcf_HTML_changeURI_GetValue($str_ret,$s_key,$m_val);
  2340.             }
  2341.         }
  2342.         return $str_ret;
  2343.  
  2344.     }
  2345.  
  2346.     /**
  2347.       * returns the <a ... </a> tag for the menu link
  2348.       *
  2349.       * @param array $valArr 
  2350.       * @param string $aAddTag 
  2351.       * @param boolean $debug 
  2352.       * @param boolean $addGetArr array with get values to add to the link KEY=NAME
  2353.       *
  2354.       * @return string 
  2355.       *
  2356.       * @version pk-05-01-21
  2357.       * @version pk-05-07-13
  2358.       * @version pk-05-11-02
  2359.       * @version pk-07-10-08
  2360.       *
  2361.       ***/
  2362.     function getHTMLLink($valArr=NULL,$aAddTag="",$debug=FALSE,$add_GETarr=NULL{
  2363.         if ($debugecho "<p><b>CMS_MENU_NODE::getHTMLLink($valArr,...)</b> (".get_class($this).")</p>";
  2364.  
  2365.         if (!is_array($valArr)) $valArr=array();
  2366.  
  2367.         // <pk-07-10-08>
  2368.         foreach($this->getDBVal(as $str_name => $mix_val)
  2369.         {
  2370.             if (!isset($valArr[$str_name])) $valArr[$str_name]=$mix_val;
  2371.         }
  2372.         // </pk-07-10-08>
  2373.  
  2374.         if (!isset($valArr['PAG_ID'])) {
  2375.             $valArr['PAG_ID']=intval($this->getPageId());
  2376.         }
  2377.  
  2378.         if (!empty($this->MEN_TARGET&& ($this->MEN_TARGET != "_SELF"&& (!strstr(strtoupper($aAddTag),"TARGET"))) // pk-05-07-13
  2379.             // there is an error in the older database version default for MEN_TARGET was _SELF instead of _self
  2380.             $target " target=\"".$this->MEN_TARGET."\" ";
  2381.         else {
  2382.             $target "";
  2383.         }
  2384.  
  2385.         $ret ="<a href=\"".$this->getLinkUrl($valArr,$debug)."\""// <pk-06-09-06 />
  2386.         $ret.=" ".$target." $aAddTag>".$this->getTitle()."</a>";   // <pk-06-10-20 />
  2387.         return $ret;
  2388.     }
  2389.  
  2390.     /**
  2391.       * returns the link url to other projekts coresponding page
  2392.       *
  2393.       * @param int $projId 
  2394.       *
  2395.       * @return string 
  2396.       *
  2397.       ***/
  2398.     function getCrossProjLinkUrl($aProjId,$debug{
  2399.         if ($debugecho "<p><b>CMS_MENU_NODE::getCrossProjLink($aProjId,...)</b> (".get_class($this).")</p>";
  2400.  
  2401.         if (!($project=$GLOBALS[$this->get_gDBIDX()]->quickQuery("SELECT * FROM T_CMS_PROJECT WHERE PROJ_ID=".intval($aProjId)))) {
  2402.             return "#";
  2403.         }
  2404.  
  2405.         if (empty($this->MEN_PROJCROSSLNK)) {
  2406.             if ($parent=&$this->getParentObj(TRUE,$debug)) {
  2407.                 return $parent->getCrossProjLinkUrl($aProjId,$debug);
  2408.             else {
  2409.                 return "/index.php?PROJ_ID=".intval($aProjId);
  2410.             }
  2411.         else {
  2412.             $xLinks=unserialize($this->MEN_PROJCROSSLNK);
  2413.             if (is_array($xLinks[$aProjId])) {
  2414.                 if ($debugecho "<pre>".print_r($xLinks[$aProjId],TRUE)."</pre>";
  2415.                 $query ="SELECT * FROM T_CMS_MENU ";
  2416.                 $query.=" WHERE PROJ_ID=".intval($aProjId);
  2417.                 $query.="   AND MEN_ID=".intval($xLinks[$aProjId]['LINK']);
  2418.                 if ($menArr=$GLOBALS[$this->get_gDBIDX()]->quickQuery($query)) {
  2419.                     $menObj=new CMS_MENU_NODE();
  2420.                     $menObj->setDbRow($menArr);
  2421.                     return $menObj->getLinkUrl(array(),$debug);
  2422.                 }
  2423.             }
  2424.         }
  2425.     }
  2426.  
  2427.  
  2428.     // -------------------------------------------------------------------------
  2429.     //  page methods
  2430.     // -------------------------------------------------------------------------#
  2431.     
  2432.     /**
  2433.      * populates the pages from the database
  2434.      *
  2435.      * @param boolean $debug 
  2436.      * 
  2437.      * @return array 
  2438.      * 
  2439.      * @since pk-08-08-12
  2440.      */
  2441.     protected function populatePages($debug=False)
  2442.     {
  2443.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::populatePages()");
  2444.         
  2445.         pcf_require_class('CMS_PAGE',"cms/page/");
  2446.         
  2447.         $arr_filter array(
  2448.                 'PROJ_ID'     => $this->getProjId(),
  2449.                 'MEN_ID'    =>$this->getId()
  2450.             );
  2451.         
  2452.         if ($arr_pageRows OCSP_OBJ::defaultReadDBObj()->getArray($this->myPageTable,$arr_filter,0,0,"PAG_SORTORDER"))
  2453.         {
  2454.             $this->myPages array();
  2455.             foreach($arr_pageRows as $arr_row)
  2456.             {
  2457.                 $int_sortorder $arr_row['PAG_SORTORDER'];
  2458.                 while(isset($this->myPages[$int_sortorder])) $int_sortorder++;
  2459.                 if (CMS_PAGE::isInstanced($arr_row['PAG_ID']))
  2460.                 {
  2461.                     $this->myPages[$int_sortorderCMS_PAGE::getInstance($arr_row['PAG_ID']);
  2462.                 else {
  2463.                     $this->myPages[$int_sortorderCMS_PAGE::factoryFromDBRow($arr_row,$debug);
  2464.                     CMS_PAGE::setInstance($this->myPages[$int_sortorder]);
  2465.                 }
  2466.             }
  2467.             
  2468.             $this->pageListPopulateTS time();
  2469.         }
  2470.     }
  2471.     
  2472.     /**
  2473.       * returns an array with some page vales of the node
  2474.       *
  2475.       * NOTE if $xtraConditions is set caching is disabled
  2476.       *
  2477.       * @param boolean $online (check if the page is online if false all pages are returned)
  2478.       * @param array $xtraConditions (array of columns to check to)
  2479.       * @param boolean $debug 
  2480.       *
  2481.       * @return array (or null if the menu has no page)
  2482.       *
  2483.       * @since pk-07-08-15
  2484.       * @version pk-08-06-19
  2485.       * 
  2486.       * @todo caching
  2487.       */
  2488.     function getPageKeyArr($online=TRUE,$xtraConditions=NULL,$debug=FALSE)
  2489.     {
  2490.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getPageKeyArr()");
  2491.  
  2492.         $arr_pages=array();
  2493.  
  2494.             if (!$this->isConnected(TRUE,$debug))
  2495.             {
  2496.                 ocsp_logError(__FILE__,__LINE__,"could not connect to the database",E_ERROR);
  2497.                 die();
  2498.             }
  2499.             $str_query ="SELECT p.*,UNIX_TIMESTAMP(PAG_SHOWFROM) AS SHOWFROM,UNIX_TIMESTAMP(PAG_SHOWTILL) AS SHOWTILL";
  2500.             $str_query.=" FROM T_CMS_PAGE p";
  2501.             $str_query.=" WHERE PROJ_ID=".intval($this->getProjId())." AND MEN_ID=".intval($this->getId());
  2502.             if (is_array($xtraConditions))
  2503.             {
  2504.                 foreach($xtraConditions as $str_col => $m_val)
  2505.                 {
  2506.                     if (!empty($m_val))
  2507.                     {
  2508.                         $str_query.=" AND ".$str_col."=".$this->myDBObj->qs_getSlashedValue($m_val);
  2509.                     }
  2510.                 }
  2511.             }
  2512.             $str_query.=" ORDER BY PAG_SORTORDER";
  2513.  
  2514.             if ($debugechoDebugLine(__FILE__,__LINE__,"page query$str_query");
  2515.  
  2516.             if (!$arr_pages=$this->myDBObj->queryArray($str_query,0,-1))
  2517.             {
  2518.                 return array();
  2519.             }
  2520.  
  2521.         if (!$online)
  2522.         {
  2523.             return $arr_pages;
  2524.         }
  2525.  
  2526.         $arr_ret=array();
  2527.         foreach($arr_pages as $i_pagId => $arr_pagVal)
  2528.         {
  2529.             if (($arr_pagVal['SHOWFROM'time()) && ($arr_pagVal['SHOWTILL'time()))
  2530.             {
  2531.                 if (isset($GLOBALS['OCSP_CMS']['PAGESTATE'][intval($arr_pagVal['PAG_STATE'])]['SHOW'])
  2532.                     && $GLOBALS['OCSP_CMS']['PAGESTATE'][intval($arr_pagVal['PAG_STATE'])]['SHOW'])
  2533.                 {
  2534.                     if (intval($arr_pagVal['PAG_SHOWGROUP']))
  2535.                     {
  2536.                         if ($GLOBALS['OCSP_OBJ']['USER']->isGroupMember($arr_pagVal['PAG_SHOWGROUP']))
  2537.                         {
  2538.                             $arr_ret[$i_pagId]=$arr_pagVal;
  2539.                         }
  2540.                     else {
  2541.                         $arr_ret[$i_pagId]=$arr_pagVal;
  2542.                     }
  2543.                 }
  2544.             else if ($debug{
  2545.                 echoDebugLine(__FILE__,__LINE__,"not adding page $i_pagId because of show date ".time()."<br />".print_r($arr_pagVal,TRUE));
  2546.             }
  2547.         }
  2548.         if ($b_useCache$this->myOnlinePageList=$arr_ret;
  2549.         return $arr_ret;
  2550.  
  2551.     }
  2552.  
  2553.  
  2554.     /**
  2555.       * get the where clause to select the menu pages
  2556.       *
  2557.       * @param boolean $showAll 
  2558.       * @param string $whereAdd 
  2559.       * @param boolean $debug 
  2560.       *
  2561.       * @global array $OCSP_OBJ (['USER'])
  2562.       *
  2563.       * @return string 
  2564.       *
  2565.       * @since pk-04-08-05
  2566.       * @version pk-05-11-01
  2567.       * @version pk-06-11-12 only use language if set
  2568.       *
  2569.       ***/
  2570.     function getPageWhere($showAll=FALSE,$whereAdd="",$debug=FALSE{
  2571.         global $OCSP_OBJ;
  2572.  
  2573.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getPageWhere()",($showAll "SHOWALL" "ONLINEMODUS")."\n\$whereAdd$whereAdd");
  2574.  
  2575.         $query =" WHERE PROJ_ID=".$this->getProjId();
  2576.         $query.="   AND MEN_ID =".$this->getId();
  2577.         if (intval($this->getLangId())) {
  2578.             $query.="   AND LANG_ID=".$this->getLangId();
  2579.         }
  2580.  
  2581.         if (!$showAll{
  2582.             $query.=" AND PAG_STATE IN (";
  2583.             $sep="";
  2584.             foreach($GLOBALS['OCSP_CMS']['PAGESTATE'as $key => $sArr{
  2585.                 if ($sArr['SHOW']{
  2586.                     $query.=$sep.$key;
  2587.                     $sep=",";
  2588.                 }
  2589.             }
  2590.             $query.=")";
  2591.             $query.=" AND PAG_SHOWFROM <= NOW()";
  2592.             $query.=" AND PAG_SHOWTILL >= NOW()";
  2593.  
  2594.             if (!$OCSP_OBJ['USER']->isAdmin($debug)) // <pk-05-11-01 />
  2595.                 $query.=" AND PAG_SHOWGROUP IN (";
  2596.                 $query.=$OCSP_OBJ['USER']->getGroups(",",FALSE,$debug);
  2597.                 $query.=")";
  2598.             }
  2599.         }
  2600.  
  2601.         $query.= $whereAdd;
  2602.         $query.= " ORDER BY PAG_SORTORDER ";
  2603.  
  2604.         return $query;
  2605.     }
  2606.  
  2607.     /**
  2608.       * gets an array of page database rows
  2609.       * 
  2610.       * 2 additional "colums" are calculated:
  2611.       * 
  2612.       * SHOWFROM_OK
  2613.       * SHOWTILL_OK
  2614.       *
  2615.       * @param boolean $showAll 
  2616.       * @param string $whereAdd 
  2617.       * @param boolean $debug 
  2618.       * @param string $orderBy (without keyword ORDER BY)
  2619.       *
  2620.       * @return array 
  2621.       *
  2622.       * @since pk-04-07-26
  2623.       * @version pk-07-10-01
  2624.       * @version pk-08-01-08 ($orderBy added)
  2625.       *
  2626.       * @todo CMS_MENU_NODE::getPageArray() inline SQL
  2627.       *
  2628.       ***/
  2629.     function getPageArray($showAll=FALSE,$whereAdd="",$debug=FALSE,$orderBy=""{
  2630.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getPageArray($showAll,$whereAdd ..)");
  2631.  
  2632.         if (!$this->isConnected(TRUE))
  2633.         {
  2634.             ocsp_logError(__FILE__,__LINE__,"no database connection",E_ERROR);
  2635.         }
  2636.  
  2637.         $str_query ="SELECT (PAG_SHOWFROM < NOW()) AS SHOWFROM_OK, (PAG_SHOWTILL > NOW()) AS SHOWTILL_OK, p.* FROM T_CMS_PAGE p";
  2638.         $str_query.=$this->getPageWhere($showAll,$whereAdd,$debug);
  2639.         
  2640.         // <pk-08-01-08>
  2641.         if (!empty($orderBy))
  2642.         {
  2643.             if (strstr($str_query,"ORDER BY"))
  2644.             {
  2645.                 $str_query=str_replace("ORDER BY","ORDER BY ".$orderBy.",",$str_query);
  2646.             else {
  2647.                 $str_query.=" ORDER BY ".$orderBy;
  2648.             }
  2649.             
  2650.         }
  2651.         // </pk-08-01-08>
  2652.  
  2653.         if ($debugechoDebugLine(__FILE__,__LINE__,$str_query);
  2654.  
  2655.         if ($obj_cursor=$this->myDBObj->query($str_query))
  2656.         {
  2657.             $arr_ret=array();
  2658.             while($arr_row=$obj_cursor->fetchArrayFld())
  2659.             {
  2660.                 $int_sortOrder=intval($arr_row['PAG_SORTORDER']);
  2661.                 while (isset($arr_ret[$int_sortOrder])) {$int_sortOrder++;}
  2662.                 $arr_ret[$int_sortOrder]=$arr_row;
  2663.             }
  2664.             return $arr_ret;
  2665.         }
  2666.         return FALSE;
  2667.     }
  2668.  
  2669.     /**
  2670.       *
  2671.       * @param boolean $useCache (pages are stored in $GLOBALS['OCSP_VAL']['DBMS_TREE'][$this->getGlobalTreeKey()]['PAGES'])
  2672.       * @param boolean $online (if true only pages to be shown online are returned)
  2673.       * @param boolean $debug 
  2674.       *
  2675.       * @return array of CMS_PAGE_V2*
  2676.       *
  2677.       * @since pk-07-08-13
  2678.       * @version pk-07-10-01
  2679.       * @version pk-08-08-12
  2680.       *
  2681.       * @todo caching
  2682.       * 
  2683.       */
  2684.     function getPageList($useCache=True,$online=True,$debug=False)
  2685.     {
  2686.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getPageList()");
  2687.  
  2688.         if ($this->pageListPopulateTS (time(ini_get('max_execution_time')))
  2689.         {
  2690.             $this->populatePages($debug);
  2691.         }
  2692.         
  2693.         if ($online)
  2694.         {
  2695.             $arr_ret array();
  2696.             foreach($this->myPages as &$obj_page)
  2697.             {
  2698.                 if ($obj_page->isOnline())
  2699.                 {
  2700.                     $arr_ret[$obj_page;
  2701.                 }
  2702.             }
  2703.             return $arr_ret;
  2704.         else {
  2705.             return $this->myPages;
  2706.         }
  2707.         
  2708.         
  2709.         
  2710.         /*
  2711.         
  2712.         global $OCSP_CONF,$OCSP_VAL;
  2713.  
  2714.         if ($useCache && isset($OCSP_VAL['PAGEOBJCACHE'][$this->getGlobalTreeKey()][$this->getId()]))
  2715.         {
  2716.             if ($online)
  2717.             {
  2718.                 $arr_ret=array();
  2719.                 foreach($OCSP_VAL['PAGEOBJCACHE'][$this->getGlobalTreeKey()][$this->getId()] as &$obj_page)
  2720.                 {
  2721.                     if ($obj_page->isOnline($debug)) $arr_ret[]=$obj_page;
  2722.                 }
  2723.                 return $arr_ret;
  2724.             } else {
  2725.                 return $OCSP_VAL['PAGEOBJCACHE'][$this->getGlobalTreeKey()][$this->getId()];
  2726.             }
  2727.         }
  2728.  
  2729.         require_once __OCSP_CMS_PHPINCPATH__."page"._OCSP_DIRSEP_."CMS_PAGE_V2.phpclass";
  2730.  
  2731.         $arr_ret=array();
  2732.         $b_showAll=($useCache || (!$online));
  2733.         if ($arr_pageRows=$this->getPageArray($b_showAll,"",$debug))
  2734.         {
  2735.             foreach($arr_pageRows as $arr_row)
  2736.             {
  2737.                 $arr_ret[]=CMS_PAGE_V2::CMS_PAGE_FROM_DBROW($arr_row,$debug);
  2738.             }
  2739.         }
  2740.  
  2741.         if ($useCache || (!$online))
  2742.         {
  2743.             $OCSP_VAL['PAGEOBJCACHE'][$this->getGlobalTreeKey()][$this->getId()]=$arr_ret;
  2744.         }
  2745.  
  2746.         if ($useCache && $online)
  2747.         {
  2748.             return $this->getPageList($useCache,$online,$debug);
  2749.         }
  2750.  
  2751.         return $arr_ret;
  2752.         */
  2753.     }
  2754.  
  2755.     /**
  2756.       * returns the current Page
  2757.       * this is the first page found and the user has rights to show
  2758.       *
  2759.       * @param boolean $goDown (check children if the node has no page to show)
  2760.       * @param boolean $online (check if the page is online if false all pages are returned)
  2761.       * @param array $xtraConditions (array of columns to check to)
  2762.       * @param boolean $debug 
  2763.       *
  2764.       * @return CMS_PAGE 
  2765.       *
  2766.       * @since pk-07-08-15
  2767.       * 
  2768.       * @version pk-08-02-16 return pointer (&)
  2769.       * @version pk-08-07-16
  2770.       */
  2771.     function &getCurrentPage($goDown=False,$online=True,$xtraConditions=Null,$debug=False)
  2772.     {
  2773.         pcf_require_class('CMS_PAGE',dirname(dirname(__FILE__)) "/page/");
  2774.       
  2775.         if (isset($this->myCurrentPage))
  2776.         {
  2777.             return $this->myCurrentPage;
  2778.         }
  2779.         
  2780.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getCurrentPage(".($goDown "goDown" "strict")." ".($online "online only" "all").")",$this->getTitle()."(".$this->getId().")");
  2781.  
  2782.         $str_query "SELECT * FROM T_CMS_PAGE ";
  2783.         $str_query.= " WHERE MEN_ID = " $this->getId();
  2784.         $str_query.= "   AND PROJ_ID = " $this->getProjId();
  2785.         
  2786.         if ($online True)
  2787.         {
  2788.             $str_query .= " AND UNIX_TIMESTAMP(PAG_SHOWFROM) <= " time();
  2789.             $str_query .= " AND UNIX_TIMESTAMP(PAG_SHOWTILL) >= " time();
  2790.             $str_query .= " AND PAG_STATE IN (" implode(',',OCSP_CMS_CONF::getInstance()->getPageOnlineStates()) ")";
  2791.         }
  2792.         
  2793.         if (is_array($xtraConditions&& sizeof($xtraConditions))
  2794.         {
  2795.             foreach($xtraConditions as $str_col => $m_val)
  2796.             {
  2797.                 if (substr($str_col,0,1)=='?')
  2798.                 {
  2799.                     $str_query .= " AND "  $m_val;
  2800.                 else {
  2801.                     $str_query.=" AND " $str_col "=" OCSP_OBJ::defaultReadDBObj()->qs_getSlashedValue($m_val);
  2802.                 }
  2803.             }
  2804.         }
  2805.         
  2806.         $str_query .= " ORDER BY PAG_SORTORDER";
  2807.         
  2808.         if ($debugechoDebugLine(__FILE__,__LINE__,"Page Query: " $str_query);
  2809.         
  2810.         if ($obj_cursor OCSP_OBJ::defaultReadDBObj()->query($str_query))
  2811.         {
  2812.             while($arr_row $obj_cursor->fetchArrayFld())
  2813.             {
  2814.                 if ($online{
  2815.                     if (OCSP_OBJ::currentUser()->isGroupMember($arr_row['PAG_SHOWGROUP']))
  2816.                     {
  2817.                         $this->myCurrentPage CMS_PAGE::factoryFromDBRow($arr_row);
  2818.                         $obj_cursor->free();
  2819.                         return $this->myCurrentPage;
  2820.                     }
  2821.                 else {
  2822.                     // cms editor mode
  2823.                     $arr_stateDesc OCSP_CMS_CONF::getStateDesc(intval($arr_row['PAG_STATE']));
  2824.                     if (OCSP_OBJ::currentUser()->isGroupMember($arr_stateDesc['GROUP']))
  2825.                     {
  2826.                         $this->myCurrentPage CMS_PAGE::factoryFromDBRow($arr_row);
  2827.                         $obj_cursor->free();
  2828.                         return $this->myCurrentPage;                        
  2829.                     }
  2830.                     if (OCSP_OBJ::currentUser()->isGroupMember($arr_row['PAG_EDITORGRP']))
  2831.                     {
  2832.                         $this->myCurrentPage CMS_PAGE::factoryFromDBRow($arr_row);
  2833.                         $obj_cursor->free();
  2834.                         return $this->myCurrentPage;
  2835.                     }
  2836.                     if (OCSP_OBJ::currentUser()->isGroupMember($arr_row['PAG_AUTHORGRP']))
  2837.                     {
  2838.                         $this->myCurrentPage CMS_PAGE::factoryFromDBRow($arr_row);
  2839.                         $obj_cursor->free();
  2840.                         return $this->myCurrentPage;
  2841.                     }
  2842.                 }
  2843.             }
  2844.         }
  2845.         
  2846.         if ($goDown)
  2847.         {
  2848.             if ($arr_children=$this->getChildrenList(TRUE,$debug,FALSE))
  2849.             {
  2850.                 foreach($arr_children as &$obj_child)
  2851.                 {
  2852.                     if (!$online || $obj_child->isToShow(TRUE,TRUE,$debug,TRUE)) // isToShow($checkDate=TRUE,$checkGroup=TRUE,$debug=FALSE,$checkShow=TRUE)
  2853.                     {
  2854.                         if ($this->myCurrentPage=$obj_child->getCurrentPage($goDown,$online,$xtraConditions,$debug))
  2855.                         {
  2856.                             return $this->myCurrentPage;
  2857.                         }
  2858.                     }
  2859.                 }
  2860.             }
  2861.         }
  2862.         if ($debugocsp_logError(__FILE__,__LINE__,"no page found for menu: ".$this->getTitle()."(".$this->getId().")",E_WARNING);
  2863.         
  2864.         //$obj_page = new CMS_PAGE();
  2865.         $obj_page Null;
  2866.         return $obj_page;
  2867.     }
  2868.  
  2869.     
  2870.  
  2871.     /**
  2872.       * returns the first pageId
  2873.       * if $goDown and no page is found for the menu childs are asked for a page
  2874.       *
  2875.       * @param boolean $goDown 
  2876.       * @param boolean $showAll 
  2877.       * @param string $whereAdd 
  2878.       * @param boolean $debug 
  2879.       *
  2880.       * @return int 
  2881.       * @access public
  2882.       *
  2883.       * @requires common/OCSP_DATE.phpclass
  2884.       *
  2885.       * @since pk-04-08-05
  2886.       * @version pk-05-07-12
  2887.       * @version pk-06-01-25
  2888.       * @version pk-07-06-09
  2889.       * @version pk-07-08-16
  2890.       *
  2891.       ***/
  2892.     function getPageId($goDown=FALSE,$showAll=FALSE,$whereAdd="",$debug=FALSE{
  2893.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getPageId()",($godown "GODOWN," "STRICT,").($showAll "SHOWALL" "ONLINEMODUS")."\n\$whereAdd$whereAdd");
  2894.  
  2895.         $online=($showAll FALSE TRUE);
  2896.         if ($arr_pVals=$this->getPageKeyArr($online,NULL,$debug))
  2897.         {
  2898.             foreach($arr_pVals as $arr_pKeys)
  2899.             {
  2900.                 if (intval($arr_pKeys['PAG_ID'])) return intval($arr_pKeys['PAG_ID']);
  2901.             }
  2902.         }
  2903.  
  2904.         if ($goDown)
  2905.         {
  2906.             if ($arr_children=$this->getChildrenList())
  2907.             {
  2908.                 foreach($arr_children as &$obj_child)
  2909.                 {
  2910.                     if (!$online || $obj_child->isToShow(TRUE,TRUE,$debug,TRUE)) // isToShow($checkDate=TRUE,$checkGroup=TRUE,$debug=FALSE,$checkShow=TRUE)
  2911.                     {
  2912.                         if ($i_ret=$obj_child->getPageId($goDown,$showAll,NULL,$debug))
  2913.                         {
  2914.                             return $i_ret;
  2915.                         }
  2916.                     }
  2917.                 }
  2918.             }
  2919.         }
  2920.     }
  2921.  
  2922.     /**
  2923.       * returns a link url to use in project tabs
  2924.       *
  2925.       * the links are stored in column MEN_PROJCROSSLNK
  2926.       *
  2927.       * @param int $projId 
  2928.       *
  2929.       * @return string 
  2930.       *
  2931.       * @since pk-04-12-06
  2932.       *
  2933.       * @todo get parent link if not set
  2934.       *
  2935.       ***/
  2936.     function getProjCrossLink_A($projId=0,$addTag="",$debug=FALSE{
  2937.         if ($debugecho "<p><b>CMS_MENU_NODE::getProjCrossLink($projId, ...)</b> (".get_class($this).")</p>";
  2938.  
  2939.         $crossLinks=@unserialize($this->MEN_PROJCROSSLNK);
  2940.  
  2941.         if (!empty($crossLinks[$projId]['LINK'])) {
  2942.             $ret="<a href=";
  2943.  
  2944.             switch($crossLinks[$projId]['TYPE']{
  2945.                 case 1:
  2946.                     // HTML-URL
  2947.                     require_once __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";
  2948.                     $ret="<a href=\"";
  2949.                     $ret.=pcf_tmpl_parse($crossLinks[$projId]['LINK'],$this->getDBVal(),$debug);
  2950.                     $ret.="\" target=\"".$crossLinks[$projId]['TARGET']."\" $aAddTag>";
  2951.                     return $ret;
  2952.                 case 2:
  2953.                     // MENU
  2954.                     if (empty($GLOBALS['CMS']['MENLINKURL'])) {
  2955.                         $GLOBALS['CMS']['MENLINKURL']="/index.php?";
  2956.                         $GLOBALS['CMS']['REWRITE']=FALSE;
  2957.                     }
  2958.                     $ret="<a href=\"".$GLOBALS['CMS']['MENLINKURL'];
  2959.                     if ($GLOBALS['CMS']['REWRITE']{
  2960.                         $ret.=$projId."/".$crossLinks[$projId]['LINK'];
  2961.                     else {
  2962.                         $ret.="PROJ_ID=".$projId."&MEN_ID=".$crossLinks[$projId]['LINK'];
  2963.                     }
  2964.                     $ret.="\" target=\"".$crossLinks[$projId]['TARGET']."\" $aAddTag>";
  2965.                     return $ret;
  2966.                 case 7:
  2967.                     // PopUp Window
  2968.                     require_once __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";
  2969.                     $url=pcf_tmpl_parse($crossLinks[$projId]['LINK'],$this->getDBVal(),$debug);
  2970.                     $ret.="\"#\" onClick=\"popup_window('".$url."',200,400);\" $aAddTag>";
  2971.                     return $ret;
  2972.                 case 8:
  2973.                     // JavaScript
  2974.                     require_once __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";
  2975.                     $url=pcf_tmpl_parse($this->MEN_LINK,$this->getDBVal(),$debug);
  2976.                     $ret.="\"#\" onClick=\"".$url."\"";
  2977.                     $ret.=" $aAddTag>";
  2978.                     return $ret;
  2979.                 default:
  2980.                     $ret="<a href=\"/index.php?PROJ_ID=".$projId;
  2981.                     $ret.="\" target=\"".$crossLinks[$projId]['TARGET']."\" $aAddTag>";
  2982.                     return $ret;
  2983.             }
  2984.         }
  2985.     }
  2986.  
  2987.     /**
  2988.      * returns the page template Id for the subpages
  2989.      *
  2990.      * @param boolean $debug 
  2991.      * 
  2992.      * @return int 
  2993.      * 
  2994.      * @since pk-08-06-07
  2995.      */
  2996.     public function getPageTmplateId($debug=False)
  2997.     {
  2998.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_MENU_NODE::getPageTmplateId()");
  2999.         if ($int_ret $this->getDBField('PTMP_ID'))
  3000.         {
  3001.             return $int_ret;
  3002.         else {
  3003.             return $this->getMyProject()->getPageTmplateId($debug);
  3004.         }
  3005.     }
  3006.     
  3007.  
  3008. }
  3009. ?>

Documentation generated on Thu, 08 Jan 2009 17:39:21 +0100 by phpDocumentor 1.4.0a2