Source for file CMS_TABLEOBJ.phpclass

Documentation is available at CMS_TABLEOBJ.phpclass

  1. <?php
  2. /**
  3.   * Class file CMS_TABLEOBJ.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.   ***/
  12.  
  13.  
  14.     // ---------------------------------------------------------
  15.     // requirements
  16.     // ---------------------------------------------------------
  17.  
  18.     pcf_require_class('DBMS_TABLEOBJ',__OCSP_PHPINCPATH__ "db/DBMS_TABLEOBJ.phpclass");
  19.     pcf_require_class('OCSP_CMS_CACHE',dirname(__FILE__"/OCSP_CMS_CACHE.phpclass");
  20.     pcf_require_class('OCSP_CMS_CONF',__OCSP_PHPINCPATH__ "cms/");
  21.  
  22. /**
  23.   * Abstract Class CMS_TABLEOBJ
  24.   *
  25.   * Extends DBMS_TABLEOBJ with some common cms aspects
  26.   *
  27.   * @project    Open CSP-Management
  28.   * @package    cms
  29.   *
  30.   * @author     Peter Krebs (pk)  <pitlinz@users.sourceforge.net>
  31.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  32.   *
  33.   * @version $Id: CMS_TABLEOBJ.phpclass,v 1.40 2008/12/17 16:28:52 peterkrebs Exp $
  34.   * 
  35.   */
  36. abstract class CMS_TABLEOBJ extends DBMS_TABLEOBJ {
  37.     
  38.     // ---------------------------------------------------------------------------
  39.     // constants
  40.     // ---------------------------------------------------------------------------
  41.     
  42.     // ---------------------------------------------------------------------------
  43.     // class (static)
  44.     // ---------------------------------------------------------------------------
  45.     
  46.     // -------------------- cms configuration ------------------------
  47.     
  48.     /**
  49.      * @static array $cms_conf_data
  50.      */
  51.     static $cms_conf_data array();
  52.         
  53.     /**
  54.      * returns a cms configuration
  55.      *
  56.      * @param string $name 
  57.      * 
  58.      * @return mixed 
  59.      * 
  60.      * @deprecated since pk-08-07-15
  61.      * 
  62.      */
  63.     public static function getCMSConf($name)
  64.     {
  65.         if (isset(self::$cms_conf_data[$name]))
  66.         {
  67.             return self::$cms_conf_data[$name];        
  68.         }
  69.         
  70.         if (isset($GLOBALS['OCSP_CMS'][$name]))
  71.         {
  72.             return $GLOBALS['OCSP_CMS'][$name];
  73.         }
  74.         
  75.         global $OCSP_CONF;
  76.         if (isset($OCSP_CONF[$name]))
  77.         {
  78.             return $OCSP_CONF[$name];
  79.         }
  80.         
  81.         if (($arr_conf OCSP_OBJ::getConf('CMS')) && isset($arr_conf[$name]))
  82.         {
  83.             return $arr_conf[$name];
  84.         }
  85.         
  86.         return Null;        
  87.     }
  88.         
  89.     /**
  90.      * returns the CMS configuration array or
  91.      *
  92.      * @param unknown_type $subElem 
  93.      * @return mixed 
  94.      * 
  95.      * @deprecated since pk-08-07-15
  96.      */
  97.     public static function getCmsConfArr($subElem="")
  98.     {
  99.         if (!empty($subElem))
  100.         {
  101.             return self::getCMSConf($subElem);
  102.         }
  103.         
  104.         $arr_conf OCSP_OBJ::getConf('CMS');
  105.         if (is_array($arr_conf))
  106.         {
  107.             array_merge($arr_conf,self::$cms_conf_data);
  108.         else {
  109.             return self::$cms_conf_data
  110.         }        
  111.     }    
  112.  
  113.     //
  114.     // -------------------- menu types -------------------------------
  115.     //
  116.     
  117.     /** ---------------------------------------------------------------
  118.      * @static array $cms_menu_types
  119.      */
  120.     static $cms_menu_types array();
  121.        
  122.     /**
  123.      * loads the cms menu types
  124.      *
  125.      * @param boolean $debug 
  126.      * 
  127.      * @since pk-08-06-10
  128.      */
  129.     public static function menuType_populate($debug=False)
  130.     {        
  131.         if ($debugechoDebugMethod(__FILE__,"static","CMS_TABLEOBJ::menuType_populate();");
  132.         
  133.         $bol_addToAPC      False;
  134.         $bol_useAPC      OCSP_CONF::getInstance('OCSP')->getValue('USECMSAPC');
  135.         
  136.         $bol_addToFCache False;
  137.         $bol_loaded         False;
  138.         
  139.         pcf_require_class('OCSP_CACHE_APC',__OCSP_PHPINCPATH__ "cache/OCSP_CACHE_APC.phpclass");
  140.         pcf_require_class('OCSP_CACHE_FILE',__OCSP_PHPINCPATH__ "cache/OCSP_CACHE_FILE.phpclass");
  141.         
  142.         if ($bol_useAPC && OCSP_CACHE_APC::isUseable())
  143.         {
  144.             if (self::$cms_menu_types=OCSP_CACHE_APC::getInstance('CMS')->getValue('MENUTYPES'))
  145.             {
  146.                 if ($debugechoDebugLine(__FILE__,__LINE__,"<h1>OCSP_CACHE_APC </h1><p>self::\$cms_menu_types</p><pre>" print_r(self::$cms_menu_types,True"<pre>");                
  147.                 $bol_loaded=True;
  148.             else {
  149.                 $bol_addToAPC=True;
  150.             }
  151.         }
  152.         
  153.         
  154.         if (OCSP_CACHE_FILE::isUseable(&& !$bol_loaded)
  155.         {
  156.             if (self::$cms_menu_types=OCSP_CACHE_FILE::getInstance('CMS')->getValue('MENUTYPES'))
  157.             {
  158.                 if ($debugechoDebugLine(__FILE__,__LINE__,"<h1>OCSP_CACHE_FILE</h1><p>self::\$cms_menu_types </p><pre>" print_r(self::$cms_menu_types,True"<pre>");                
  159.                 $bol_loaded=True;
  160.             else {
  161.                 $bol_addToFCache=True;
  162.             }
  163.         }
  164.         
  165.         if (!$bol_loaded || !is_array(self::$cms_menu_types|| !sizeof(self::$cms_menu_types))
  166.         {
  167.             if (!(self::$cms_menu_types=OCSP_OBJ::defaultReadDBObj()->getIndexedArray('T_CMS_MENUTYPE',array(),'MEN_OBJCLASS')))
  168.             {
  169.                 throw new Exception(_OCSP_EXCEP_CONFIGERROR_ ":could not get CMS_MENUTYPES");
  170.             }
  171.  
  172.             if ($debugechoDebugLine(__FILE__,__LINE__,"<h1>DB VALUES</h1><p>self::\$cms_menu_types</p><pre>" print_r(self::$cms_menu_types,True"<pre>");
  173.         }
  174.         
  175.         if ($bol_addToAPC)
  176.         {
  177.             OCSP_CACHE_APC::getInstance('CMS')->setValue('MENUTYPES',self::$cms_menu_types);
  178.         }
  179.         
  180.         if ($bol_addToFCache)
  181.         {
  182.             OCSP_CACHE_FILE::getInstance('CMS')->setValue('MENUTYPES',self::$cms_menu_types);
  183.         }
  184.         
  185.         // old system compat
  186.         foreach(self::$cms_menu_types as $str_key => $arr_def)
  187.         {
  188.             $GLOBALS['OCSP_CMS']['MENUTYPE'][$str_key$arr_def;
  189.             $GLOBALS['OCSP_CMS']['MENUTYPE'][$str_key]['CLASS']      $arr_def['MEN_OBJCLASS'];
  190.             $GLOBALS['OCSP_CMS']['MENUTYPE'][$str_key]['NAME']      $arr_def['MET_TITLE'];
  191.             $GLOBALS['OCSP_CMS']['MENUTYPE'][$str_key]['INCLUDE'self::menuType_getClassSrc($arr_def['MEN_OBJCLASS'],False,$debug);
  192.         }
  193.     }
  194.     
  195.     /**
  196.      * returns the source file (absolute path) of a menutype
  197.      *
  198.      * @param string $aClassName 
  199.      * @param boolean $canPopulate (to avoid endless loops)
  200.      * @param boolean $debug 
  201.      * 
  202.      * @return string 
  203.      * 
  204.      * @since pk-08-06-13
  205.      */
  206.     public static function menuType_getClassSrc($aClassName,$canPopulate=True,$debug=False)
  207.     {
  208.         if ($debugechoDebugLine(__FILE__,"static","CMS_TABLEOBJ::menuType_getClassSrc(".$aClassName.");");
  209.         
  210.         if (!isset(self::$cms_menu_types[$aClassName]))
  211.         {
  212.             if ($canPopulateself::menuType_populate($debug);
  213.             if (!isset(self::$cms_menu_types[$aClassName]))
  214.             {
  215.                 return Null;
  216.             }    
  217.         }
  218.         
  219.         if (!function_exists('pcf_checkFilePath')) require_once __OCSP_PHPINCPATH__ "common" _OCSP_DIRSEP_ "pcf_file.phpinc";
  220.         
  221.         $arr_type &self::$cms_menu_types[$aClassName]
  222.         
  223.         switch($arr_type['MET_SYSTEM'])
  224.         {
  225.             case 'OCSP':
  226.                 return pcf_checkFilePath(__OCSP_PHPINCPATH__ $arr_type['MET_INCLUDE']);
  227.             case 'MODULE':
  228.                 if (!intval($arr_type['MOD_ID']))
  229.                 {
  230.                     throw new Exception(_OCSP_EXCEP_NOID_ ":" $class " MODULE ID NOT SET");
  231.                 }
  232.                 
  233.                 pcf_require_class('OCSP_MODULE',__OCSP_PHPINCPATH__ "modules/OCSP_MODULE.phpclass");
  234.                 if ($obj_module OCSP_MODULE::factoryFromId($arr_type['MOD_ID']))
  235.                 {
  236.                     return pcf_checkFilePath($obj_module->getModuleIncPath("/" $arr_type['MET_INCLUDE']);
  237.                 else {
  238.                     return Null;
  239.                 }
  240.             default:
  241.                 if ($debugechoDebugLine(__FILE__,__LINE__,"SYSTEM: " $arr_type['MET_SYSTEM']);
  242.                 if (isset($GLOBALS[$arr_type['MET_SYSTEM']]['PHPINCPATH']))
  243.                 {
  244.                     $str_file pcf_checkFilePath($GLOBALS[$arr_type['MET_SYSTEM']]['PHPINCPATH'"/" $arr_type['MET_INCLUDE']);
  245.                     if (file_exists($str_file))
  246.                     {
  247.                         return $str_file;
  248.                     }
  249.                 }
  250.  
  251.                 $str_file pcf_checkFilePath(__OCSP_PROJECTPATH__ "/" $arr_type['MET_INCLUDE']);
  252.                 if (file_exists($str_file))
  253.                 {
  254.                     return $str_file;
  255.                 }
  256.                 
  257.                 $str_file pcf_checkFilePath(__OCSP_PHPINCPATH__ "/" $arr_type['MET_INCLUDE']);
  258.                 if (file_exists($str_file))
  259.                 {
  260.                     return $str_file;
  261.                 }
  262.                     
  263.         }
  264.     }
  265.     
  266.     /**
  267.      * require menu object class
  268.      * 
  269.      * @param string $class 
  270.      */
  271.     public static function menuType_requireClass($aClassName,$debug=False)
  272.     {       
  273.         if ($debugechoDebugMethod(__FILE__,"static","CMS_TABLEOBJ::menuType_requireClass()");
  274.           if (!class_exists($aClassName))
  275.         {
  276.             if ($str_src self::menuType_getClassSrc($aClassName,True,$debug))
  277.             {
  278.                 pcf_require_class($aClassName,$str_src);
  279.                 return True
  280.             else {
  281.                 return False;
  282.             }
  283.         else {
  284.             return True;    
  285.         }
  286.     }
  287.     
  288.     /**
  289.      * clears the menuType cache
  290.      * 
  291.      * @param boolean $debug 
  292.      * @since pk-08-06-14
  293.      */
  294.     public static function menuType_clearCache($debug=False)
  295.     {
  296.         pcf_require_class('OCSP_CACHE_APC',__OCSP_PHPINCPATH__ "cache/OCSP_CACHE_APC.phpclass");
  297.         pcf_require_class('OCSP_CACHE_FILE',__OCSP_PHPINCPATH__ "cache/OCSP_CACHE_FILE.phpclass");
  298.         
  299.            if (OCSP_CACHE_APC::isUseable())
  300.         {
  301.             OCSP_CACHE_APC::getInstance('CMS')->unsetValue('MENUTYPES');
  302.         }
  303.         
  304.         
  305.         if (OCSP_CACHE_FILE::isUseable(&& !$bol_loaded)
  306.         {
  307.             OCSP_CACHE_FILE::getInstance('CMS')->unsetValue('MENUTYPES');
  308.         }
  309.         self::$cms_menu_types=array();
  310.     }
  311.     
  312.     //
  313.    // -------------------- page template types ------------------------
  314.     //
  315.     
  316.     /**
  317.      * @staticvar array $cms_pageTmpl_types 
  318.      * @since pk-08-06-16
  319.      */
  320.     static $cms_pageTmpl_types array();
  321.  
  322.     /**
  323.      * loads the cms page types
  324.      *
  325.      * @param boolean $debug 
  326.      * 
  327.      * @since pk-08-06-16
  328.      */
  329.     public static function pageTmplType_populate($debug=False)
  330.     {        
  331.         if ($debugechoDebugMethod(__FILE__,"static","CMS_TABLEOBJ::pageTmplType_populate();");
  332.         
  333.         $bol_addToAPC      False;
  334.         $bol_useAPC      OCSP_CONF::getInstance('OCSP')->getValue('USECMSAPC');
  335.         
  336.         $bol_addToFCache False;
  337.         $bol_loaded         False;
  338.                 
  339.         if ($bol_useAPCpcf_require_class('OCSP_CACHE_APC',__OCSP_PHPINCPATH__ "cache/OCSP_CACHE_APC.phpclass");
  340.         pcf_require_class('OCSP_CACHE_FILE',__OCSP_PHPINCPATH__ "cache/OCSP_CACHE_FILE.phpclass");
  341.         
  342.         if ($bol_useAPC && OCSP_CACHE_APC::isUseable())
  343.         {
  344.             if (self::$cms_pageTmpl_types=OCSP_CACHE_APC::getInstance('CMSTEMPL')->getValue('PAGETEMPLTYPES'))
  345.             {
  346.                 if ($debugechoDebugLine(__FILE__,__LINE__,"<h1>OCSP_CACHE_APC </h1><p>self::\$cms_pageTmpl_types</p><pre>" print_r(self::$cms_pageTmpl_types,True"<pre>");                
  347.                 $bol_loaded=True;
  348.             else {
  349.                 $bol_addToAPC=True;
  350.             }
  351.         }
  352.         
  353.         
  354.         if ((OCSP_CACHE_FILE::isUseable(&& !$bol_loaded))
  355.         {
  356.             if (self::$cms_pageTmpl_types=OCSP_CACHE_FILE::getInstance('CMSTEMPL')->getValue('PAGETEMPLTYPES'))
  357.             {
  358.                 if ($debugechoDebugLine(__FILE__,__LINE__,"<h1>OCSP_CACHE_FILE</h1><p>self::\$cms_page_types </p><pre>" print_r(self::$cms_pageTmpl_types,True"<pre>");                
  359.                 $bol_loaded=True;
  360.             else {
  361.                 $bol_addToFCache=True;
  362.             }
  363.         }
  364.         
  365.         if (!$bol_loaded || !is_array(self::$cms_pageTmpl_types|| !sizeof(self::$cms_pageTmpl_types))
  366.         {
  367.             if (!(self::$cms_pageTmpl_types=OCSP_OBJ::defaultReadDBObj()->getIndexedArray('T_CMS_TMPL_PAGETYPE',array(),'PTMP_OBJCLASS')))
  368.             {
  369.                 throw new Exception(_OCSP_EXCEP_CONFIGERROR_ ":could not get CMS_PAGETYPES");
  370.             }
  371.  
  372.             if ($debugechoDebugLine(__FILE__,__LINE__,"<h1>DB VALUES</h1><p>self::\$cms_pageTmpl_types</p><pre>" print_r(self::$cms_pageTmpl_types,True"<pre>");
  373.             $bol_addToFCache=True;
  374.             $bol_addToAPC=True;
  375.         }
  376.         
  377.         if ($bol_addToAPC)
  378.         {
  379.             OCSP_CACHE_APC::getInstance('CMSTEMPL')->setValue('PAGETEMPLTYPES',self::$cms_pageTmpl_types);
  380.         }
  381.         
  382.         if ($bol_addToFCache)
  383.         {
  384.             OCSP_CACHE_FILE::getInstance('CMSTEMPL')->setValue('PAGETEMPLTYPES',self::$cms_pageTmpl_types);
  385.         }    
  386.     }
  387.     
  388.     /**
  389.      * returns the source file (absolute path) of a pagetype
  390.      *
  391.      * @param string $aClassName 
  392.      * @param boolean $canPopulate (to avoid endless loops)
  393.      * @param boolean $debug 
  394.      * 
  395.      * @return string 
  396.      * 
  397.      * @since pk-08-06-16
  398.      */
  399.     public static function pageTmplType_getClassSrc($aClassName,$canPopulate=True,$debug=False)
  400.     {
  401.         if ($debugechoDebugLine(__FILE__,"static","CMS_TABLEOBJ::pageType_getClassSrc(".$aClassName.");");
  402.         
  403.         if (!isset(self::$cms_pageTmpl_types[$aClassName]))
  404.         {
  405.             if ($canPopulateself::pageTmplType_populate($debug);
  406.             if (!isset(self::$cms_pageTmpl_types[$aClassName]))
  407.             {
  408.                 return Null;
  409.             }    
  410.         }
  411.         
  412.         if (!function_exists('pcf_checkFilePath')) require_once __OCSP_PHPINCPATH__ "common" _OCSP_DIRSEP_ "pcf_file.phpinc";
  413.         
  414.         $arr_type &self::$cms_pageTmpl_types[$aClassName]
  415.         
  416.         switch($arr_type['PTMT_SYSTEM'])
  417.         {
  418.             case 'OCSP':
  419.                 return pcf_checkFilePath(__OCSP_PHPINCPATH__ $arr_type['PTMT_INCLUDE']);
  420.             case 'MODULE':
  421.                 if (!intval($arr_type['MOD_ID']))
  422.                 {
  423.                     throw new Exception(_OCSP_EXCEP_NOID_ ":" $class " MODULE ID NOT SET");
  424.                 }
  425.                 
  426.                 pcf_require_class('OCSP_MODULE',__OCSP_PHPINCPATH__ "modules/OCSP_MODULE.phpclass");
  427.                 if ($obj_module OCSP_MODULE::factoryFromId($arr_type['MOD_ID']))
  428.                 {
  429.                     return pcf_checkFilePath($obj_module->getModuleIncPath("/" $arr_type['PTMT_INCLUDE']);
  430.                 else {
  431.                     return Null;
  432.                 }
  433.             default:
  434.                 if ($debugechoDebugLine(__FILE__,__LINE__,"SYSTEM: " $arr_type['PTMT_SYSTEM']);
  435.                 if (isset($GLOBALS[$arr_type['PTMT_SYSTEM']]['PHPINCPATH']))
  436.                 {
  437.                     $str_file pcf_checkFilePath($GLOBALS[$arr_type['PTMT_SYSTEM']]['PHPINCPATH'"/" $arr_type['PTMT_INCLUDE']);
  438.                     if (file_exists($str_file))
  439.                     {
  440.                         return $str_file;
  441.                     }
  442.                 }
  443.  
  444.                 $str_file pcf_checkFilePath(__OCSP_PROJECTPATH__ "/" $arr_type['PTMT_INCLUDE']);
  445.                 if (file_exists($str_file))
  446.                 {
  447.                     return $str_file;
  448.                 }
  449.                 
  450.                 $str_file pcf_checkFilePath(__OCSP_PHPINCPATH__ "/" $arr_type['PTMT_INCLUDE']);
  451.                 if (file_exists($str_file))
  452.                 {
  453.                     return $str_file;
  454.                 }
  455.                     
  456.         }
  457.     }    
  458.     
  459.     /**
  460.      * require page object class
  461.      * 
  462.      * @param string $class 
  463.      * 
  464.      * @return boolean 
  465.      * 
  466.      * @since pk-08-06-16
  467.      */
  468.     public static function pageTmplType_requireClass($aClassName,$debug=False)
  469.     {       
  470.         if ($debugechoDebugMethod(__FILE__,"static","CMS_TABLEOBJ::pageTmplType_requireClass()");
  471.           if (!class_exists($aClassName))
  472.         {
  473.             if ($str_src self::pageTmplType_getClassSrc($aClassName,True,$debug))
  474.             {
  475.                 pcf_require_class($aClassName,$str_src);
  476.                 return True
  477.             else {
  478.                 return False;
  479.             }
  480.         else {
  481.             return True;    
  482.         }
  483.     }    
  484.     
  485.     //
  486.     // -------------------- page types ---------------------------------
  487.     //
  488.     
  489.     /** ---------------------------------------------------------------
  490.      * @static array $cms_page_types
  491.      */
  492.     static $cms_page_types array();
  493.         
  494.     /**
  495.      * loads the cms page types
  496.      *
  497.      * @param boolean $debug 
  498.      * 
  499.      * @since pk-08-06-10
  500.      */
  501.     public static function pageType_populate($debug=False,$useCache=True)
  502.     {                    
  503.         if ($debugechoDebugMethod(__FILE__,"static","CMS_TABLEOBJ::pageType_populate();");
  504.         
  505.         $bol_addToAPC      False;
  506.         $bol_useAPC OCSP_CONF::getInstance('OCSP')->getValue('USECMSAPC');
  507.         
  508.         $bol_addToFCache False;
  509.         $bol_loaded         False;
  510.                 
  511.         
  512.         if ($bol_useAPCpcf_require_class('OCSP_CACHE_APC',__OCSP_PHPINCPATH__ "cache/OCSP_CACHE_APC.phpclass");
  513.         pcf_require_class('OCSP_CACHE_FILE',__OCSP_PHPINCPATH__ "cache/OCSP_CACHE_FILE.phpclass");
  514.         
  515.         if ($bol_useAPC && OCSP_CACHE_APC::isUseable())
  516.         {
  517.             if (self::$cms_page_types=OCSP_CACHE_APC::getInstance('CMS')->getValue('PAGETYPES',$debug))
  518.             {
  519.                 if ($debugechoDebugLine(__FILE__,__LINE__,"<h1>OCSP_CACHE_APC </h1><p>self::\$cms_page_types</p><pre>" print_r(self::$cms_page_types,True"<pre>");                
  520.                 $bol_loaded=True;
  521.             else {
  522.                 $bol_addToAPC=True;
  523.             }
  524.             if ($debugechoDebugLine(__FILE_,__LINE__,"APC VALUES: <pre>" print_r(self::$cms_page_types"</pre>");
  525.         }
  526.             
  527.         if ($useCache && !$bol_loaded && (OCSP_CACHE_FILE::isUseable()))
  528.         {
  529.             if (self::$cms_page_types=OCSP_CACHE_FILE::getInstance('CMS')->getValue('PAGETYPES',$debug))
  530.             {
  531.                 if ($debugechoDebugLine(__FILE__,__LINE__,"<h1>OCSP_CACHE_FILE</h1><p>self::\$cms_page_types </p><pre>" print_r(self::$cms_page_types,True"<pre>");                
  532.                 $bol_loaded=True;
  533.             else {
  534.                 $bol_addToFCache=True;
  535.             }
  536.         }
  537.         
  538.         if (!$bol_loaded || !is_array(self::$cms_page_types|| !sizeof(self::$cms_page_types))
  539.         {
  540.             if (!(self::$cms_page_types=OCSP_OBJ::defaultReadDBObj()->getIndexedArray('T_CMS_PAGETYPE',array(),'PAG_OBJCLASS')))
  541.             {
  542.                 throw new Exception(_OCSP_EXCEP_CONFIGERROR_ ":could not get CMS_PAGETYPES");
  543.             }
  544.             if ($debugechoDebugLine(__FILE__,__LINE__,"<h1>DB VALUES</h1><p>self::\$cms_page_types</p><pre>" print_r(self::$cms_page_types,True"<pre>");
  545.             $bol_addToFCache=True;
  546.             $bol_addToAPC=True;
  547.         }
  548.         
  549.         if ($bol_useAPC && $bol_addToAPC)
  550.         {
  551.             OCSP_CACHE_APC::getInstance('CMS')->setValue('PAGETYPES',self::$cms_page_types);
  552.         }
  553.         
  554.         if ($bol_addToFCache)
  555.         {
  556.             OCSP_CACHE_FILE::getInstance('CMS')->setValue('PAGETYPES',self::$cms_page_types);
  557.         }
  558.         
  559.         // old system compat
  560.         foreach(self::$cms_page_types as $str_key => $arr_def)
  561.         {
  562.             //echoDebugLine(__FILE__,__LINE__,"<hr /><pre>" . print_r($arr_def,True) . "</pre>");
  563.             if (!isset($arr_def['PAT_TMPLCLASS']))  $arr_def['PAT_TMPLCLASS''CMS_PAGE_TEMPLATE';
  564.             if ($debugecho "$str_key: <pre>print_r($arr_def,True"</pre>";
  565.             $GLOBALS['OCSP_CMS']['PAGETYPE'][$str_key]=array(
  566.                 'CLASS'     => $str_key,
  567.                 'TMPLCLASS' => $arr_def['PAT_TMPLCLASS'],
  568.                 'INCLUDE'   => self::pageTmplType_getClassSrc($arr_def['PAT_TMPLCLASS'],True,$debug),
  569.                 'OBJINC'    => self::pageType_getClassSrc($str_key,False,$debug),
  570.                 'DOCTYPE'   => "HTML 4.0 Transitional",
  571.                 'NAME'      => $arr_def['PAT_TITLE'],
  572.                 'PAGEINC'   => __OCSP_PROJECTPATH__ .$arr_def['PAT_TMPLCLASS']
  573.             );            
  574.         }
  575.     }   
  576.  
  577.  
  578.     /**
  579.      * returns the source file (absolute path) of a pagetype
  580.      *
  581.      * @param string $aClassName 
  582.      * @param boolean $canPopulate 
  583.      * @param boolean $debug 
  584.      * 
  585.      * @return string 
  586.      * 
  587.      * @since pk-08-06-16
  588.      */
  589.     public static function pageType_getClassSrc($aClassName,$canPopulate=True,$debug=False)
  590.     {        
  591.         if ($debugechoDebugMethod(__FILE__,"static","CMS_TABLEOBJ::pageType_getClassSrc(".$aClassName.");");
  592.         
  593.         if (!isset(self::$cms_page_types[$aClassName]))
  594.         {
  595.             if ($canPopulateself::pageType_populate($debug);
  596.             if (!isset(self::$cms_page_types[$aClassName]))
  597.             {
  598.                 return Null;
  599.             }    
  600.         }
  601.         
  602.         if (!function_exists('pcf_checkFilePath')) require_once __OCSP_PHPINCPATH__ "common" _OCSP_DIRSEP_ "pcf_file.phpinc";
  603.         
  604.         $arr_type self::$cms_page_types[$aClassName]
  605.         if (!isset($arr_type['PAT_SYSTEM'])) 
  606.         {
  607.             $arr_type['PAT_SYSTEM''OCSP'
  608.         }
  609.         
  610.         switch($arr_type['PAT_SYSTEM'])
  611.         {
  612.             case 'OCSP':
  613.                 return pcf_checkFilePath(__OCSP_PHPINCPATH__ $arr_type['PAT_INCLUDE']);
  614.             case 'MODULE':
  615.                 if (!intval($arr_type['MOD_ID']))
  616.                 {
  617.                     throw new Exception(_OCSP_EXCEP_NOID_ ":" $class " MODULE ID NOT SET");
  618.                 }
  619.                 
  620.                 pcf_require_class('OCSP_MODULE',__OCSP_PHPINCPATH__ "modules/OCSP_MODULE.phpclass");
  621.                 if ($obj_module OCSP_MODULE::factoryFromId($arr_type['MOD_ID']))
  622.                 {
  623.                     return pcf_checkFilePath($obj_module->getModuleIncPath("/" $arr_type['PAT_INCLUDE']);
  624.                 else {
  625.                     return Null;
  626.                 }
  627.             default:
  628.                 if ($debugechoDebugLine(__FILE__,__LINE__,"SYSTEM: " $arr_type['PAT_SYSTEM']);
  629.                 if (isset($GLOBALS[$arr_type['PAT_SYSTEM']]['PHPINCPATH']))
  630.                 {
  631.                     $str_file pcf_checkFilePath($GLOBALS[$arr_type['PAT_SYSTEM']]['PHPINCPATH'"/" $arr_type['PAT_INCLUDE']);
  632.                     if (file_exists($str_file))
  633.                     {
  634.                         return $str_file;
  635.                     }
  636.                 }
  637.  
  638.                 $str_file pcf_checkFilePath(__OCSP_PROJECTPATH__ "/" $arr_type['PAT_INCLUDE']);
  639.                 if (file_exists($str_file))
  640.                 {
  641.                     return $str_file;
  642.                 }
  643.                 
  644.                 $str_file pcf_checkFilePath(__OCSP_PHPINCPATH__ "/" $arr_type['PAT_INCLUDE']);
  645.                 if (file_exists($str_file))
  646.                 {
  647.                     return $str_file;
  648.                 }
  649.                     
  650.         }
  651.     }    
  652.         
  653.     /**
  654.      * require page object class
  655.      * 
  656.      * @param string $class 
  657.      */
  658.     public static function pageType_requireClass($aClassName,$debug=False)
  659.     {             
  660.         if ($debugechoDebugMethod(__FILE__,"static","CMS_TABLEOBJ::pageType_requireClass()");
  661.           if (!class_exists($aClassName))
  662.         {
  663.             if ($str_src self::pageType_getClassSrc($aClassName,True,$debug))
  664.             {
  665.                 pcf_require_class($aClassName,$str_src);
  666.                 return True
  667.             else {
  668.                 return False;
  669.             }
  670.         else {
  671.             return True;    
  672.         }
  673.     }    
  674.     
  675.     /**
  676.      * returns the default template class name of a page type
  677.      *
  678.      * @param string $aClassName 
  679.      * @param boolean $debug 
  680.      * 
  681.      * @return string 
  682.      * 
  683.      * @since pk-08-06-16
  684.      */
  685.     public static function pageType_getTmplClassName($aClassName,$debug=False)
  686.     {
  687.         if (!isset(self::$cms_page_types[$aClassName]))
  688.         {
  689.             self::pageType_populate($debug);
  690.         }
  691.         
  692.         if (!isset(self::$cms_page_types[$aClassName]))
  693.         {
  694.             return "CMS_PAGE_TEMPLATE";
  695.         else if (!isset(self::$cms_page_types[$aClassName]['PAT_TMPLCLASS'])) {
  696.             return "CMS_PAGE_TEMPLATE";
  697.         else if (empty(self::$cms_page_types[$aClassName]['PAT_TMPLCLASS'])) {
  698.             return "CMS_PAGE_TEMPLATE";
  699.         else {
  700.             return self::$cms_page_types[$aClassName]['PAT_TMPLCLASS'];
  701.         }
  702.         
  703.     }
  704.     
  705.     /**
  706.      * returns an array with all page types
  707.      * 
  708.      * @param boolean $debug 
  709.      * 
  710.      * @since pk-08-08-11
  711.      */
  712.     public static function pageType_getList($debug=False)
  713.     {
  714.         if (!sizeof(self::$cms_page_types))
  715.         {
  716.             self::pageType_populate($debug);
  717.         }
  718.         return self::$cms_page_types;
  719.     }
  720.     
  721.     //
  722.     // -------------------- current elements ----------------------------
  723.     //
  724.         
  725.     /**
  726.      * @staticvar CMS_PROJECT $currentProject 
  727.      */
  728.     protected static $currentProj Null;
  729.     
  730.     /**
  731.      * @staticvar CMS_MENU_NODE $currentMenu 
  732.      */
  733.     protected static $currentMenu Null;
  734.  
  735.     
  736.     /**
  737.      * @staticvar CMS_PAGE $currentPage 
  738.      */
  739.     protected static $currentPage Null;    
  740.     
  741.     /**
  742.       * @return string 
  743.       * @since pk-07-08-14
  744.       * @access public
  745.       */
  746.     public static function getPageIdGetName()
  747.     {
  748.         if (pcf_is_instance_of($this,'CMS_TABLEOBJ'))
  749.             return $this->myPageIdGetName;
  750.         else
  751.             return 'ocspS';
  752.     }
  753.  
  754.     /**
  755.       * @return string 
  756.       * @since pk-07-08-14
  757.       * @access public
  758.       */
  759.     public static function getPageIdColName()
  760.     {
  761.         if (pcf_is_instance_of($this,'CMS_TABLEOBJ'))
  762.             return $this->myPageIdCol;
  763.         else
  764.             return 'PAG_ID';
  765.     }
  766.     
  767.     /**
  768.      * returns the page sort column
  769.      *
  770.      * @return string 
  771.      */
  772.     public static function getPageSortColName()
  773.     {
  774.         if (pcf_is_instance_of($this,'CMS_PAGE_V2'))
  775.         {
  776.             return $this->colPrevix "SORTORDER";
  777.         else {
  778.             return 'PAG_SORTORDER';
  779.         }    
  780.     }
  781.     
  782.     /**
  783.      * returns the page table name
  784.      *
  785.      * @return string 
  786.      */
  787.     public static function getPageTable()
  788.     {
  789.         if (pcf_is_instance_of($this,'CMS_PAGE'))
  790.         {
  791.             return $this->myTable;
  792.         else {
  793.             return 'T_CMS_PAGE';
  794.         }
  795.     }
  796.     
  797.     /**
  798.       * @return string 
  799.       * @since pk-07-08-14
  800.       * @access public
  801.       */
  802.     public static function getMenuIdGetName()
  803.     {
  804.         if (pcf_is_instance_of($this,'CMS_TABLEOBJ'))
  805.             return $this->myMenuIdGetName;
  806.         else
  807.             return 'ocspM';
  808.     }
  809.  
  810.     /**
  811.       * @return string 
  812.       * @since pk-07-08-14
  813.       * @access public
  814.       */
  815.     public static function getMenuIdColName()
  816.     {
  817.         if (pcf_is_instance_of($this,'CMS_TABLEOBJ'))
  818.             return $this->myMenuIdCol;
  819.         else
  820.             return 'MEN_ID';
  821.     }
  822.  
  823.     /**
  824.       * @return string 
  825.       * @since pk-07-08-14
  826.       * @access public
  827.       */
  828.     public static function getProjIdGetName()
  829.     {
  830.         if (pcf_is_instance_of($this,'CMS_TABLEOBJ'))
  831.             return $this->myProjIdGetName;
  832.         else
  833.             return 'ocspP';
  834.     }
  835.  
  836.     /**
  837.       * @return string 
  838.       * @since pk-07-08-14
  839.       * @access public
  840.       */
  841.     public static function getProjIdColName()
  842.     {
  843.         if (pcf_is_instance_of($this,'CMS_TABLEOBJ'))
  844.             return $this->myProjIdCol;
  845.         else
  846.             return 'PROJ_ID';
  847.     }
  848.     
  849.  
  850.     
  851.     /**
  852.      * facotries the current elements from the environment
  853.      * 
  854.      * @param boolean $debug 
  855.      * 
  856.      * @return boolean 
  857.      */
  858.     public static function factoryCurrentElements($debug=False)
  859.     {        
  860.         if ($debugechoDebugMethod(__FILE__,"static","CMS_TABLEOBJ::factoryCurrentElements()");
  861.         
  862.         pcf_require_class('CMS_PROJECT',"cms/");
  863.         pcf_require_class('CMS_MENU_NODE',"cms/menu/");        
  864.         pcf_require_class('CMS_PAGE',"cms/page/");
  865.         
  866.         $int_projId (isset($_GET[self::getProjIdGetName()]intval($_GET[self::getProjIdGetName()](isset($_GET[self::getProjIdColName()]intval($_GET[self::getProjIdColName()]0));            
  867.            $str_menId  (isset($_GET[self::getMenuIdGetName()]$_GET[self::getMenuIdGetName()(isset($_GET[self::getMenuIdColName()]$_GET[self::getMenuIdColName()0));            
  868.         $int_pagId    (isset($_GET[self::getPageIdGetName()]intval($_GET[self::getPageIdGetName()](isset($_GET[self::getPageIdColName()]intval($_GET[self::getPageIdColName()]0));
  869.                     
  870.         switch(True)
  871.         {
  872.             case (intval($int_pagId)):
  873.                 if ($debugechoDebugLine(__FILE__,__LINE__,"using pageId: {$int_pagId}");                
  874.                 if (self::$currentPage CMS_PAGE::factoryFromId($int_pagId,False,$debug))
  875.                 {
  876.                     self::$currentMenu self::$currentPage->getMyMenuNode($debug);
  877.                     self::$currentProj self::$currentPage->getMyProject($debug);
  878.                     return True;
  879.                 }                
  880.             case (!empty($str_menId)):
  881.                 if ($debugechoDebugLine(__FILE__,__LINE__,"using menu: {$str_menId}");                
  882.                 if ($obj_menu CMS_MENU_NODE::factoryFromKey($int_pagId,$str_menId,$debug))
  883.                 {
  884.                     //$debug=True;echoDebugLine(__FILE__,__LINE__,"debug on");
  885.                     if (self::$currentPage $obj_menu->getCurrentPage(True,True,Null,$debug))
  886.                     {
  887.                         if ($debugechoDebugLine(__FILE__,__LINE__,"<h2>pageMenu: " self::$currentPage->getMyMenuNode()->getId(" env: " $obj_menu->getId("</h2>");
  888.                         
  889.                         if (self::$currentPage->getMyMenuNode()->getId(!= $obj_menu->getId())
  890.                         {
  891.                             self::$currentMenu self::$currentPage->getMyMenuNode();
  892.                         else {
  893.                             self::$currentMenu $obj_menu;
  894.                         }
  895.                         self::$currentProj self::$currentPage->getMyProject($debug);
  896.                         
  897.                         if ($debugechoDebugLine(__FILE__,__LINE__,"<h2>Set to: Proj:" self::$currentProj->getId(" Menu: " self::$currentMenu->getId(" Page: " self::$currentPage->getId("</h2>");
  898.                         return True;
  899.                     else {
  900.                         return False;
  901.                     }
  902.                 }
  903.             case intval($int_projId):
  904.                 if ($debugechoDebugLine(__FILE__,__LINE__,"using projId: {$int_projId}");
  905.                 if (self::$currentProj CMS_PROJECT::factoryFromId($int_projId))
  906.                 {
  907.                     self::$currentPage self::$currentProj->getCurrentPage($debug);
  908.                     self::$currentMenu self::$currentPage->getMyMenuNode($debug);
  909.                     return True;                    
  910.                 }
  911.             default:                
  912.                 if (pcf_class_implements(self::$currentProj,'INFA_CMS_PROJECT'))
  913.                 {
  914.                     self::$currentPage self::$currentProj->getCurrentPage($debug);
  915.                     self::$currentMenu self::$currentPage->getMyMenuNode($debug);
  916.                     return True;                    
  917.                 }
  918.                 
  919.                 if (self::$currentProj CMS_PROJECT::factoryFromEnv($debug))
  920.                 {
  921.                     self::$currentPage self::$currentProj->getCurrentPage($debug);
  922.                     self::$currentMenu self::$currentPage->getMyMenuNode($debug);
  923.                     return True;
  924.                 }
  925.         }        
  926.     }
  927.     
  928.     /**
  929.      * returns the current project
  930.      * 
  931.      * if !isset self::$currentProj and $OCSP_OBJ['CUR_CMSPROJ'] is set
  932.      * $OCSP_OBJ['CUR_CMSPROJ'] is set as current project
  933.      * 
  934.      * @return CMS_PROJECT 
  935.      */
  936.     public static function &get_currentProj()
  937.     {
  938.         if (pcf_class_implements(self::$currentProj,'INFA_CMS_PROJECT'))
  939.         {
  940.             global $OCSP_OBJ;
  941.             if (!self::$currentProj && isset($OCSP_OBJ['CUR_CMSPROJ']))
  942.             {
  943.                 self::$currentProj $OCSP_OBJ['CUR_CMSPROJ'];
  944.             }
  945.         }
  946.         return self::$currentProj;
  947.     }
  948.     
  949.     /**
  950.      * returns the current menu node
  951.      * 
  952.      * @return CMS_MENU_NODE 
  953.      * 
  954.      * @version pk-08-10-05 (compate with old global $OCSP_OBJ)
  955.      */
  956.     public static function &get_currentMenu()
  957.     {
  958.         if (!self::$currentMenu || !is_object(self::$currentMenu))
  959.         {
  960.             global $OCSP_OBJ;
  961.             if (isset($OCSP_OBJ['CUR_CMSMENU']&& is_object($OCSP_OBJ['CUR_CMSMENU']))
  962.             {
  963.                 self::$currentMenu $OCSP_OBJ['CUR_CMSMENU'];
  964.             else {
  965.                 /*
  966.                 if (self::$currentProj)
  967.                 {
  968.                     self::$currentMenu = self::$currentProj->getCurrentMenuNode();                    
  969.                 }
  970.                 */
  971.             }
  972.         }
  973.         return self::$currentMenu;
  974.     }
  975.  
  976.     /**
  977.      * @return CMS_PAGE 
  978.      */
  979.     public static function &get_currentPage()
  980.     {
  981.         if (!self::$currentPage || !is_object(self::$currentPage))
  982.         {
  983.             if (self::$currentMenu || is_object(self::$currentMenu))
  984.             {
  985.                 self::$currentPage self::$currentMenu->getCurrentPage(False,True);        
  986.             }
  987.         }
  988.         return self::$currentPage;
  989.     }
  990.     
  991.     /**
  992.      * @param CMS_PROJECT $project 
  993.      */
  994.     public static function set_currentProj(&$project,$debug=False)
  995.     {
  996.         if ($debugechoDebugMethod(__FILE__,"static","CMS_TABLEOBJ::set_currentProj()",get_class($project));
  997.         
  998.         if (pcf_class_implements($project,'INFA_CMS_PROJECT'))
  999.         {
  1000.             self::$currentProj $project;
  1001.         else if ($debug{
  1002.             echoDebugLine(__FILE__,__LINE__,get_class($project)." does not implements INFA_CMS_PROJECT");
  1003.         }
  1004.     }
  1005.     
  1006.     /**
  1007.      * @param CMS_MENU $menNode 
  1008.      */
  1009.     public static function set_currentMenu(&$menNode,$debug=False)
  1010.     {
  1011.         if ($debugechoDebugMethod(__FILE__,"static","CMS_TABLEOBJ::set_currentMenu()");
  1012.         
  1013.         if (pcf_class_implements($menNode,'INFA_CMS_MENU_NODE'))
  1014.         {            
  1015.             self::$currentMenu $menNode;
  1016.             if (!self::$currentProj)
  1017.             {
  1018.                 self::set_currentProj($menNode->getMyProject(),$debug);
  1019.             }
  1020.         }
  1021.     }    
  1022.  
  1023.     /**
  1024.      * @param CMS_PAGE $page 
  1025.      * @param boolean $debug 
  1026.      */
  1027.     public static function set_currentPage(&$page,$debug=False)
  1028.     {
  1029.         if ($debugechoDebugMethod(__FILE__,"static","CMS_TABLEOBJ::set_currentPage()");
  1030.         self::$currentPage $page;
  1031.         if (!self::$currentMenu)
  1032.         {
  1033.             self::set_currentMenu(self::$currentPage->getMyMenuNode());
  1034.         }
  1035.     }
  1036.     
  1037.     /** -----------------------------------------------------
  1038.       * Aggregations:
  1039.       */
  1040.  
  1041.     /** -----------------------------------------------------
  1042.       * Compositions:
  1043.       */
  1044.  
  1045.     /**
  1046.       * @var OCSP_CMS_PEARCACHE $myCmsCache 
  1047.       ***/
  1048.     protected $myCmsCache=NULL;
  1049.  
  1050.     /**
  1051.       * @var CMS_PROJECT $myProjObj 
  1052.       * @since pk-05-09-01
  1053.       ***/
  1054.     protected $myProjObj=Null;
  1055.  
  1056.     /**
  1057.      * @var CMS_MENU_NODE $myMenuNode 
  1058.      */
  1059.     protected $myMenuNode=Null;
  1060.  
  1061.     /**
  1062.      * @var CMS_PAGE $myPageObj 
  1063.      */
  1064.     protected $myPageObj=Null;
  1065.  
  1066.     /** -----------------------------------------------------
  1067.       * Attributes:
  1068.       */
  1069.  
  1070.     /**
  1071.       * @var string $myProjCol 
  1072.       * @since pk-05-07-21
  1073.       ***/
  1074.     protected $myProjIdCol = "PROJ_ID";
  1075.  
  1076.     /**
  1077.       * @var string $myProjIdGetName 
  1078.       * @since pk-07-06-07
  1079.       ***/
  1080.     protected $myProjIdGetName = "ocspP";
  1081.  
  1082.     /**
  1083.       * @staticvar string $myMenuIdCol 
  1084.       * @since pk-05-07-21
  1085.       ***/
  1086.     protected $myMenuIdCol = "MEN_ID";
  1087.  
  1088.     /**
  1089.       * @var string $myMenuIdGetName 
  1090.       ***/
  1091.     protected $myMenuIdGetName="ocspM";
  1092.  
  1093.     /**
  1094.       * @staticvar string $myPageIdCol 
  1095.       * @since pk-05-07-28
  1096.       * @access protected
  1097.       ***/
  1098.     protected $myPageIdCol  ="PAG_ID";
  1099.  
  1100.     /**
  1101.       * @var string $myPageIdGetName 
  1102.       * @access protected
  1103.       * @see CMS_TABLEOBJ::getPageIdGetName()
  1104.       ***/
  1105.     protected $myPageIdGetName="ocspS";
  1106.  
  1107.         
  1108.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1109.     // getter/setter
  1110.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1111.     
  1112.  
  1113.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1114.     // common methods
  1115.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1116.  
  1117.     /**
  1118.       * sets all fields of an array to the objcet
  1119.       * if $valArr['PEARCACHE_TS'] isset this will become the populateTS
  1120.       *
  1121.       * @param array $valArr 
  1122.       * @param boolean $debug 
  1123.       *
  1124.       * @rerturn boolean
  1125.       *
  1126.       * @since pk-05-08-30
  1127.       * @version pk-07-06-16
  1128.       ***/
  1129.     function setDBVal($valArr,$debug=FALSE{
  1130.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_TABLEOBJ::setDBVal()");
  1131.  
  1132.         if (!is_array($valArr)) {
  1133.             if ($debugechoDebugLine(__FILE__,__LINE__,"\$valArr is not an array");
  1134.             return FALSE;
  1135.         }
  1136.         if (isset($valArr['PEARCACHE_TS']))
  1137.         {
  1138.             $this->populateTS           =$valArr['PEARCACHE_TS'];
  1139.             $this->myObjValsPopulateTS  =$valArr['PEARCACHE_TS'];
  1140.             unset($valArr['PEARCACHE_TS']);
  1141.         }
  1142.         parent::setDBVal($valArr,$debug);
  1143.  
  1144.         if ($debugechoDebugLine(__FILE__,__LINE__,"Values of class: ".get_class($this)." set:<br />populateTS:".$this->getPopulateTs()."<br />myObjValsPopulateTS: ".$this->myObjValsPopulateTS);
  1145.     }
  1146.  
  1147.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1148.     // Project Methods
  1149.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1150.  
  1151.     /**
  1152.       * returns the cms project id
  1153.       *
  1154.       * @param boolean $debug 
  1155.       * @return int 
  1156.       *
  1157.       ***/
  1158.     function getProjId($debug=False
  1159.     {
  1160.         if ($debugechoDebugMethod(__FILE__,__LINE__,"CMS_TABLEOBJ::getProjId()");
  1161.  
  1162.         if (pcf_is_instance_of($this->myProjObj,'CMS_PROJECT'&& intval($this->myProjObj->getId()))
  1163.         {
  1164.             if($debugechoDebugMethod (__FILE__,__LINE__,"checking ".$this->myProjIdCol." with value from object");
  1165.             $this->setDBFieldIfDiff($this->myProjIdCol,$this->myProjObj->getId());
  1166.         }
  1167.         return intval($this->getDBField($this->myProjIdCol));
  1168.     }
  1169.  
  1170.     /**
  1171.       * sets the cms project id
  1172.       *
  1173.       * @param $aId int Project ID
  1174.       *
  1175.       * @version pk-03-12-12
  1176.       * @version pk-05-09-05 bugfix
  1177.       *
  1178.       ***/
  1179.     function setProjId($aId{
  1180.         $this->setDBFieldIfDiff($this->myProjIdCol,intval($aId));
  1181.     }
  1182.  
  1183.     /**
  1184.       * sets the project object of the page
  1185.       *
  1186.       * @param CMS_PROJECT aProjObj
  1187.       * @param boolean $debug 
  1188.       *
  1189.       * @global array $OCSP_OBJ; 
  1190.       *
  1191.       * @since pk-05-07-11
  1192.       * @version pk-06-07-26 setting project ID too
  1193.       * @version pk-07-08-13 setting memory cache
  1194.       *
  1195.       ***/
  1196.     function setMyProject(&$aProjObj,$debug=False
  1197.     {
  1198.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_TABLEOBJ::setMyProject(Object: ".get_class($aProjObj).")");
  1199.         
  1200.         $this->myProjObj=$aProjObj;
  1201.         
  1202.         if (method_exists($aProjObj,'getId'))
  1203.         {
  1204.             $this->setProjId($this->myProjObj->getId())// <pk-06-07-26 />
  1205.         }
  1206.     }
  1207.  
  1208.     /**
  1209.       * returns the Project Object
  1210.       *
  1211.       * @param boolean $setAsCurrent if true and method $this->setAsCurrent() exists it will be called
  1212.       * @param boolean $debug 
  1213.       * @param boolean $forceObj (if true a new object will be instanciated if none is set)
  1214.       *
  1215.       * @return CMS_PROJECT 
  1216.       * @access public
  1217.       *
  1218.       * @version pk-05-09-06
  1219.       * @version pk-07-06-07
  1220.       * @version pk-07-08-13
  1221.       * @version pk-08-11-22
  1222.       *
  1223.       * @requires CMS_PROJECT.phpclass
  1224.       */
  1225.     function &getMyProject($setAsCurrent=False,$debug=False,$forceObj=True
  1226.     {
  1227.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_TABLEOBJ::getMyProject()");
  1228.  
  1229.         pcf_require_class('CMS_PROJECT',"cms/");
  1230.         
  1231.         if (pcf_is_instance_of($this,'CMS_PROJECT')) 
  1232.         {
  1233.             if ($debugechoDebugLine(__FILE__,__LINE__,"returning \$this");
  1234.             return $this;
  1235.         }
  1236.         
  1237.         // <pk-08-11-22>
  1238.         if ($int_projId intval($this->getDBField('PROJ_ID')))
  1239.         {
  1240.             if ($obj_ret CMS_PROJECT::getInstance($int_projId))
  1241.             {
  1242.                 $this->myProjObj = $obj_ret;
  1243.                    if ($setAsCurrent && method_exists($this,'setAsCurrent')) $this->setAsCurrent($debug);                
  1244.                 return $this->myProjObj;
  1245.             }
  1246.         }
  1247.         // </pk-08-11-22>
  1248.         
  1249.         
  1250.         if (pcf_is_instance_of($this->myProjObj,'CMS_PROJECT'))
  1251.         {
  1252.             if ($debugechoDebugLine(__FILE__,__LINE__,"returning \$this->myProjObj");
  1253.             if ($setAsCurrent && method_exists($this,'setAsCurrent')) $this->setAsCurrent($debug);
  1254.             return $this->myProjObj;
  1255.         }
  1256.  
  1257.         if (pcf_is_instance_of($this->myPageObj,'CMS_PAGE_V2'&& (!pcf_is_instance_of($this,'CMS_PAGE_V2')))
  1258.         {
  1259.             if ($debugechoDebugLine(__FILE__,__LINE__,"returning \$this->myPageObj->getMyProject");
  1260.             $this->myProjObj=$this->myPageObj->getMyProject(FALSE,$debug,$forceObj);
  1261.             if ($setAsCurrent && method_exists($this,'setAsCurrent')) $this->setAsCurrent($debug);
  1262.             return $this->myProjObj;
  1263.         }
  1264.  
  1265.         if (pcf_is_instance_of($this->myMenuNode,'CMS_MENU_NODE'))
  1266.         {
  1267.             $this->myProjObj=$this->myMenuNode->getMyProject($debug,$forceObj);
  1268.             if ($setAsCurrent && method_exists($this,'setAsCurrent')) $this->setAsCurrent($debug);
  1269.             return $this->myProjObj;
  1270.         }
  1271.  
  1272.         if (!$forceObjreturn $this->myProjObj;
  1273.  
  1274.         if (CMS_PROJECT::isInstanced($this->getProjId()))
  1275.         {
  1276.             if ($setAsCurrent && method_exists($this,'setAsCurrent')) $this->setAsCurrent($debug);
  1277.             return CMS_PROJECT::getInstance($this->getProjId());
  1278.         else {        
  1279.             $this->myProjObjnew CMS_PROJECT(0);
  1280.             $this->myProjObj->setId($this->getProjId());
  1281.     
  1282.             if ($this->myProjObj->dbPopulate($debug))
  1283.             {
  1284.                 if ($this->cmsCacheIsUsable())
  1285.                 {
  1286.                     $this->myCmsCache->setProjDBValues($this,$debug);
  1287.                 }
  1288.             }
  1289.         }
  1290.         
  1291.         if ($debugechoDebugLine(__FILE__,__LINE__,"returning populated object");
  1292.  
  1293.         if ($setAsCurrent && method_exists($this,'setAsCurrent')) $this->setAsCurrent($debug);
  1294.         return $this->myProjObj;
  1295.             
  1296.     }
  1297.  
  1298.     /**
  1299.       * returns the cms language id
  1300.       *
  1301.       * @return int 
  1302.       *
  1303.       ***/
  1304.     function getLangId({
  1305.         return intval($this->LANG_ID);
  1306.     }
  1307.  
  1308.     /**
  1309.       * sets the cms language id
  1310.       *
  1311.       * @param int $aId 
  1312.       *
  1313.       *  since pk-04-07-30
  1314.       *
  1315.       ***/
  1316.     function setLangId($aId{
  1317.         $this->LANG_ID=intval($aId);
  1318.     }
  1319.  
  1320.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1321.     // Menu Methods
  1322.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1323.  
  1324.     /**
  1325.       * returns the cms menu id
  1326.       *
  1327.       * @return int 
  1328.       *
  1329.       * @version pk-08-06-17
  1330.       */
  1331.     function getMenId(
  1332.     {
  1333.         if (is_object($this->myMenuNode&& method_exists($this->myMenuNode,'getMenId'))
  1334.         {
  1335.             return $this->myMenuNode->getMenId();
  1336.         }
  1337.         return intval($this->getDBField($this->myMenuIdCol))// <pk-06-08-03 /> E_ALL
  1338.     }
  1339.  
  1340.     /**
  1341.       * sets the menu id
  1342.       *
  1343.       * @param int $aId 
  1344.       *
  1345.       * @since pk-05-07-21
  1346.       *
  1347.       ***/
  1348.     function setMenId($aId
  1349.     {
  1350.         if (!empty($this->myMenuIdCol)) $this->myMenuIdCol="MEN_ID";
  1351.         $this->{$this->myMenuIdCol}=intval($aId);
  1352.     }
  1353.  
  1354.     /**
  1355.       * returns the menu node of the object
  1356.       * if $this->myMenuNode is not set or NULL a new object is generated
  1357.       * if $this->myMenuNode->getId() != $this->getMenId() a new objec is generated
  1358.       *
  1359.       * @param boolean $debug 
  1360.       *
  1361.       * @return CMS_MENU_NODE 
  1362.       *
  1363.       * @since pk-06-11-12
  1364.       * @version pk-07-08-14 memory and pear cache usage
  1365.       *
  1366.       ***/
  1367.     function &getMyMenuNode($debug=False
  1368.     {                        
  1369.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_TABLEOBJ::getMyMenuNode(".$this->getMenId().")");
  1370.  
  1371.         if ($this->myMenuNode && is_object($this->myMenuNode&& pcf_class_implements($this->myMenuNode,'INFA_CMS_MENU_NODE')) 
  1372.         {
  1373.             if ($debugechoDebugLine(__FILE__,__LINE__,"getMyMenuNode() returns object attribute \$this->myMenuNode ID:".$this->myMenuNode->getKey());
  1374.             return $this->checkMenuNodeProject($debug);
  1375.         }
  1376.                 
  1377.         if (pcf_class_implements($this->myPageObj,'INFA_CMS_PAGE'&& !pcf_is_instance_of($this,'CMS_PAGE'))
  1378.         {
  1379.             // this is not a page object get menu from $this->myPageObj
  1380.             if ($debugechoDebugLine(__FILE__,__LINE__,"getting menu form page object: " get_class($this->myPageObj));
  1381.             //if ($this->myMenuNode=$this->myPageObj->getMenuNode($debug))
  1382.             if ($this->myMenuNode=$this->myPageObj->getMyMenuNode($debug))
  1383.             {
  1384.                 if ($debugechoDebugLine(__FILE__,__LINE__,"getMyMenuNode() returns \$this->myPageObj->getMenuNode() ID:".$this->myMenuNode->getId());
  1385.                 return $this->checkMenuNodeProject($debug);
  1386.             }
  1387.         }
  1388.  
  1389.         pcf_require_class('CMS_MENU',__OCSP_PHPINCPATH__ "cms/menu/");
  1390.         
  1391.         if (method_exists($this,'getMenKey'))
  1392.         {
  1393.             if ($this->myMenuNode = CMS_MENU::getInstance($this->getProjId())->getNode($this->getMenKey(),False))
  1394.             {
  1395.                 if ($debugechoDebugLine(__FILE__,__LINE__,"getMyMenuNode() returns menu from key: " $this->getMenKey());
  1396.                 return $this->checkMenuNodeProject($debug);
  1397.             }
  1398.         }            
  1399.         
  1400.         if (intval($this->getMenId())) 
  1401.         {
  1402.             if ($this->myMenuNode = CMS_MENU::getInstance($this->getProjId())->getNode($this->getMenId(),False)) 
  1403.             {
  1404.                 if ($debugechoDebugLine(__FILE__,__LINE__,"getMyMenuNode() returns menu from Id: " $this->getMenId());
  1405.                 return $this->checkMenuNodeProject($debug);
  1406.             else if ($debug{
  1407.                 ocsp_logError(__FILE__,__LINE__,"could not get menu tree form \$this->myProjObj",E_WARNING);
  1408.             }
  1409.         }
  1410.         
  1411.         if ($this->myMenuNode=CMS_MENU::getInstance($this->getProjId())->getNode($this->getMenId(),True,$debug))
  1412.         {
  1413.             if ($debugechoDebugLine(__FILE__,__LINE__,"getMyMenuNode() returns menu from Id: " $this->getMenId());
  1414.             return $this->checkMenuNodeProject($debug);
  1415.         else {
  1416.             throw new Exception(_OCSP_CMSEXCEP_NOMENU_.":".get_class($this));
  1417.         }
  1418.         
  1419.     }    
  1420.     
  1421.     /**
  1422.       * sets the menu node object
  1423.       *
  1424.       * @param CMS_MENU_NODE $aNode 
  1425.       * @param boolean $debug 
  1426.       *
  1427.       * @since pk-06-11-12
  1428.       * @version pk-07-10-01
  1429.       *
  1430.       ***/
  1431.     function setMyMenuNode(&$aNode,$debug=False
  1432.     {
  1433.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_TABLEOBJ::setMenuNodeObj()");
  1434.         $this->myMenuNode=$aNode;
  1435.         if (method_exists($aNode,'getId'))          $this->setMenId($aNode->getId());
  1436.         if (method_exists($aNode,'getMyProject'))   $this->setMyProject($aNode->getMyProject(),$debug);
  1437.     }
  1438.  
  1439.     /**
  1440.       * checks if $this->myMenuNode has a project object
  1441.       * if not $this->getMyProject is set to the menu
  1442.       *
  1443.       * @param boolean $debug 
  1444.       *
  1445.       * @return CMS_MENU_NODE $this->myMenuNode
  1446.       *
  1447.       * @since pk-07-08-23
  1448.       *
  1449.       * @access protected
  1450.       */
  1451.     protected function &checkMenuNodeProject($debug=FALSE)
  1452.     {
  1453.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_TABLEOBJ::checkMenuNodeProject()");
  1454.  
  1455.         if (!pcf_is_instance_of($this->myMenuNode,'CMS_MENU_NODE'))
  1456.         {
  1457.             return $this->myMenuNode;
  1458.         }
  1459.  
  1460.         if (!$this->myMenuNode->getMyProject($debug,False))
  1461.         {
  1462.             $this->myMenuNode->setMyProject($this->getMyProject(False,$debug,False));
  1463.         }
  1464.  
  1465.         return $this->myMenuNode;
  1466.     }
  1467.  
  1468.     /**
  1469.       * retuns the link url of the menu (without page)
  1470.       *
  1471.       * @param boolean $debug 
  1472.       *
  1473.       * @returns string
  1474.       *
  1475.       * @since pk-07-01-10
  1476.       *
  1477.       ***/
  1478.     function getMenLinkUrl($debug=FALSE{
  1479.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_TABLEOBJ::getMenLink()");
  1480.         if ($o_menObj=$this->getMyMenuNode($debug)) {
  1481.             return $o_menObj->getLinkUrl($debug);
  1482.         }
  1483.         return "/";
  1484.     }
  1485.  
  1486.  
  1487.  
  1488.     /**
  1489.       * returns the previous menĂ¼ id
  1490.       * goes up in the tree if no suitable sibling is found
  1491.       *
  1492.       * @param boolean $onlineOnly only check menus which are currently online
  1493.       * @param boolean $debug 
  1494.       *
  1495.       * @returns int
  1496.       *
  1497.       * @since pk-07-01-10
  1498.       *
  1499.       ***/
  1500.     function getPrevMenuId($onlineOnly=TRUE,$debug=FALSE{
  1501.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getPrevMenuId()");
  1502.  
  1503.         if ($o_menObj=$this->getMyMenuNode($debug)) {
  1504.             if ($o_menNode=$o_menObj->getPrevSibling(TRUE,TRUE,TRUE,$debug)) {
  1505.                 return $o_menNode->getId();
  1506.             }
  1507.         }
  1508.         return 0;
  1509.  
  1510.     }
  1511.  
  1512.     /**
  1513.       * returns the previous menĂ¼ id
  1514.       * goes up in the tree if no suitable sibling is found
  1515.       *
  1516.       * @param boolean $onlineOnly only check menus which are currently online
  1517.       * @param boolean $debug 
  1518.       *
  1519.       * @returns int
  1520.       *
  1521.       * @since pk-07-01-10
  1522.       *
  1523.       ***/
  1524.     function getNextMenuId($onlineOnly=TRUE,$debug=FALSE{
  1525.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getNextMenuId()");
  1526.  
  1527.         if ($o_menObj=$this->getMyMenuNode($debug)) {
  1528.             if ($o_menNode=$o_menObj->getNextSibling(TRUE,TRUE,TRUE,$debug)) {
  1529.                 return $o_menNode->getId();
  1530.             }
  1531.         }
  1532.         return 0;
  1533.     }
  1534.  
  1535.  
  1536.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1537.     // Page Methods
  1538.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1539.  
  1540.     /**
  1541.       * returns the cms page id
  1542.       *
  1543.       * @return int 
  1544.       *
  1545.       ***/
  1546.     function getPageId({
  1547.         return intval($this->getDBField($this->myPageIdCol));
  1548.     }
  1549.  
  1550.     /**
  1551.       * @param int $pagId 
  1552.       *
  1553.       * @since pk-05-07-28
  1554.       *
  1555.       ***/
  1556.     function setPageId($pagId{
  1557.         $this->setDBFieldIfDiff($this->myPageIdCol,intval($pagId));
  1558.     }
  1559.  
  1560.     /**
  1561.       * @param CMS_PAGE $aPageObj 
  1562.       * @param boolean $debug 
  1563.       */
  1564.     function setMyPageObj(&$aPageObj,$debug=FALSE)
  1565.     {
  1566.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_TABLEOBJ::setMyPageObj(a ".get_class($aPageObj)." object)");
  1567.         $this->myPageObj=$aPageObj;
  1568.         if (method_exists($aPageObj,'getId'))
  1569.         {
  1570.             $this->setPageId($aPageObj->getId());
  1571.         }
  1572.         if ($debugechoDebugLine(__FILE__,__LINE__,"PageId set to ".$this->getPageId()." PROJ_ID:".$aPageObj->getDBField('PROJ_ID'));
  1573.     }
  1574.  
  1575.     /**
  1576.       * @param boolean $debug 
  1577.       * @return CMS_PAGE 
  1578.       * 
  1579.       * @version pk-08-05-09 bugfix
  1580.       */
  1581.     function &getMyPageObj($debug=False)
  1582.     {
  1583.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_TABLEOBJ::getMyPageObj()");
  1584.         if (pcf_is_instance_of($this,"CMS_PAGE_V2")) {
  1585.             $this->myPageObj=&$this;
  1586.             if ($debugechoDebugLine(__FILE__,__LINE__,"returning set object");
  1587.             return $this->myPageObj;
  1588.         }
  1589.         if (pcf_is_instance_of($this->myPageObj,"CMS_PAGE_V2")) 
  1590.         {
  1591.             if ($debugechoDebugLine(__FILE__,__LINE__,"<p>returning set object</p><pre>".print_r($this->myPageObj->getDBVal(),TRUE)."</pre>");
  1592.             return $this->myPageObj;
  1593.         }
  1594.         if (intval($this->getPageId()))
  1595.         {     
  1596.             // <pk-08-05-09>
  1597.             require_once dirname(__FILE___OCSP_DIRSEP_ "page" _OCSP_DIRSEP_ "CMS_PAGE_V2.phpclass";
  1598.             $this->myPageObj = CMS_PAGE_V2::factoryFromId($this->getPageId());
  1599.             // </pk-08-05-09>
  1600.         else if ($debug{
  1601.             echoDebugLine(__FILE__,__LINE__,"no page id");
  1602.         }
  1603.         return $this->myPageObj;
  1604.     }
  1605.  
  1606.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1607.     // Cache Methods
  1608.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1609.  
  1610.     /**
  1611.       * returns if the cms cache is usable
  1612.       *
  1613.       * if (_OCSP_USEPEARCACHE_) it's ensured that
  1614.       * $GLOBALS['OCSP_OBJ']['CMS_PEARCHACHE'] is an object
  1615.       *
  1616.       * @return boolean 
  1617.       */
  1618.     function cmsCacheIsUsable()
  1619.     {
  1620.         if (_OCSP_USEPEARCACHE_{
  1621.             if (!pcf_is_instance_of($GLOBALS['OCSP_OBJ']['CMS_PEARCHACHE'],'OCSP_CMS_PEARCACHE'))
  1622.             {
  1623.                 require_once $GLOBALS['OCSP_CMS']['PHPINCPATH']."OCSP_CMS_PEARCACHE.phpclass";
  1624.                 $GLOBALS['OCSP_OBJ']['CMS_PEARCHACHE']=new OCSP_CMS_PEARCACHE();
  1625.             }
  1626.             if (pcf_is_instance_of($this,get_class($this)))
  1627.             {
  1628.                 // avoid setting when called static
  1629.                 $this->myCmsCache=&$GLOBALS['OCSP_OBJ']['CMS_PEARCHACHE'];
  1630.             }
  1631.  
  1632.             return TRUE;
  1633.         }
  1634.         return FALSE;
  1635.     }
  1636.  
  1637.     /**
  1638.       * sets the values from a cache array
  1639.       * if the object is not populated or have an older populateTS
  1640.       *
  1641.       * @param array $cacheArr 
  1642.       * @param boolean $debug 
  1643.       *
  1644.       * @return boolean 
  1645.       *
  1646.       */
  1647.     function setCmsCacheArr($cacheArr,$debug)
  1648.     {
  1649.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_TABLEOBJ::setCmsCacheArr()");
  1650.  
  1651.         if (!$cacheArr || !is_array($cacheArr)) {
  1652.             if ($debugechoDebugLine(__FILE__,__LINE__,"\$cacheArr is not an array");
  1653.             return FALSE;
  1654.         }
  1655.  
  1656.         if (!isset($cacheArr['PEARCACHE_TS']|| !doubleval($cacheArr['PEARCACHE_TS']))
  1657.         {
  1658.             if ($debugechoDebugLine(__FILE__,__LINE__,"\$cacheArr has no timestamp");
  1659.             return FALSE;
  1660.         }
  1661.  
  1662.         if ($this->isPopulated(&& $this->populateTS > $cacheArr['PEARCACHE_TS'])
  1663.         {
  1664.             if ($debugechoDebugLine(__FILE__,__LINE__,"object already populated with newer values");
  1665.             return FALSE;
  1666.         }
  1667.  
  1668.         $this->populateTS=$cacheArr['PEARCACHE_TS'];
  1669.         $this->setDBVal($cacheArr,$debug);
  1670.  
  1671.         return (intval($this->getId()) TRUE FALSE);
  1672.  
  1673.     }
  1674.  
  1675. }
  1676. ?>

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