Source for file CMS_PAGE_V2.phpclass

Documentation is available at CMS_PAGE_V2.phpclass

  1. <?php
  2. /**
  3.   * Class file CMS_PAGE_V2.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    cms
  7.   *
  8.   * @author     Peter Krebs <pitlinz@users.sourceforge.net>
  9.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  10.   *
  11.   * @version pk-07-05-08
  12.   *
  13.   ***/
  14.  
  15. if (!defined('__OCSP_CMS_PHPINCPATH__')) require_once __OCSP_DEFAULTCONFPATH__."cms.conf.phpinc";
  16. pcf_require_class('CMS_PAGE',dirname(__FILE__)."/CMS_PAGE.phpclass");
  17.  
  18.  
  19.  
  20.  
  21. /**
  22.   * class to handel PAGES
  23.   *
  24.   *
  25.   * @project    Open CSP-Management
  26.   * @package    cms
  27.   *
  28.   * @author     Peter Krebs <pitlinz@users.sourceforge.net>
  29.   *
  30.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  31.   *
  32.   * @version    pk-03-12-18
  33.   * @version    pk-05-07-11
  34.   *
  35.   * @deprecated since pk-08-06-16
  36.   */
  37. class CMS_PAGE_V2 extends CMS_PAGE {
  38.  
  39.     /*** class constants  --------------------------------------------- */
  40.  
  41.     /**
  42.       * @constant string CLASS_SRC_FILE
  43.       */
  44.     const CLASS_SRC_FILE = __FILE__;    
  45.     
  46.     /**
  47.      * unit of work singleton
  48.      * @staticvar array $cmsPageList 
  49.      * 
  50.      * @since pk-08-03-11
  51.      */
  52.     static $cmsPageList array();    
  53.     
  54.     /** -----------------------------------------------------
  55.       * Aggregations:
  56.       */
  57.  
  58.  
  59.     /** -----------------------------------------------------
  60.       * Compositions:
  61.       */
  62.  
  63.     /**
  64.       * @var CMS_PAGE_TEMPLATE $myTmpl 
  65.       * @access protected
  66.       */
  67.     protected $myTmpl         = NULL;
  68.  
  69.     /**
  70.       * @var array $chaTmpl (an array with chapter template objects used)
  71.       * @access protected
  72.       */
  73.     protected $chaTmpl        = array();
  74.  
  75.  
  76.  
  77.     /** -----------------------------------------------------
  78.       * Attributes:
  79.       */
  80.  
  81.  
  82.     /**
  83.       * @staticvar string $colPrevix fields in $this->myTable starts with
  84.       ***/
  85.     protected $colPrevix      = "PAG_";
  86.  
  87.     /**
  88.       * @staticvar string $myClassName name of the class
  89.       ***/
  90.     protected $myClassName    = "CMS_PAGE_V2";
  91.  
  92.  
  93.     /**
  94.       * @staticvar string $ctmplTable name of the chapter template table
  95.       ***/
  96.     var $ctmplTable     = "T_CMS_TMPL_CHAPTER";
  97.     /**
  98.       * @staticvar string $ctmplClass name of the default chapter template class (is used to generate a new chapter template object)
  99.       ***/
  100.     var $ctmplClass     = "TMPL_CHAPTER_V3"// <pk-05-08-26 />
  101.  
  102.     /**
  103.       * @staticvar string $cTable name of the chapter table
  104.       ***/
  105.     var $cTable         = "T_CMS_CHAPTER";
  106.     /**
  107.       * @staticvar string $chapPrevix prefix used in chapter table for column names
  108.       ***/
  109.     var $chapPrevix     = "CHA_";
  110.  
  111.     /**
  112.       * @staticvar string $myChapterClass 
  113.       * @since pk-05-10-10
  114.       *  NOTE make sure the class is included before calling chapter methods
  115.       ***/
  116.     var $myChapterClass="CMS_CHAPTER_V2";
  117.  
  118.     /**
  119.       * @var string $ctmplFldPrevix prefix of the template columns
  120.       */
  121.     var $ctmplFldPrevix = "CTMP_";
  122.  
  123.     /**
  124.       * @var array $chaTmplArr with loaded chapter templates to avoid reloading
  125.       ***/
  126.     var $chaTmplArr=array();
  127.  
  128.     /**
  129.       * @staticvar string $moduleKey 
  130.       * @since pk-06-02-17
  131.       ***/
  132.     var $moduleKey="CMS";
  133.  
  134.     
  135.     /**
  136.      * previous page id
  137.      *
  138.      * @var int 
  139.      */
  140.     protected $prevId = 0;
  141.     
  142.     /**
  143.      * next page id
  144.      *
  145.      * @var int 
  146.      */
  147.     protected $nextId = 0;
  148.     
  149.     
  150.     /**
  151.       *
  152.       * METHODS _____________________________________________
  153.       *
  154.       */
  155.     
  156.  
  157.     
  158.     /** -----------------------------------------------------
  159.       * Constructors
  160.       */
  161.  
  162.     /**
  163.       * init the object and populates it if (intval($aId))
  164.       *
  165.       * @param int $projId  the project ID
  166.       * @param int $menId   the menu ID
  167.       * @param int $aId     the page ID
  168.       * @param int $langId  the language ID
  169.       * @param bool $debug 
  170.       *
  171.       * @returns CMS_PAGE_V2
  172.       *
  173.       * @version pk-05-07-26
  174.       *
  175.       ***/
  176.     function CMS_PAGE_V2($projId=0,$menId=0,$aId=0,$langId=0,$debug=False{
  177.         $this->init();
  178.  
  179.         $this->setDBField($this->myProjIdCol,$projId);  // <pk-05-07-26 /> as PROJ_ID is no longer part of primary key
  180.         $this->setDBField('LANG_ID',$langId);           // <pk-05-07-26 /> as LANG_ID is no longer part of primary key
  181.         $this->setDBField($this->myMenuIdCol,$menId);   // <pk-05-07-26 /> as MEN_ID is no longer part of primary key
  182.         $this->db_SetKey($this->colPrevix."ID",$aId);
  183.         if (intval($aId)) {
  184.             $this->dbPopulate();
  185.         }
  186.     }
  187.  
  188.     /**
  189.       * @static_function
  190.       *
  191.       *  generates a new page object of class $className
  192.       *
  193.       * @param string $className 
  194.       * @param boolean $debug 
  195.       *
  196.       * @global OCSP_CONF 
  197.       *
  198.       * @return CMS_PAGE_V2 
  199.       *
  200.       */
  201.     function CMS_PAGE_SUBCLASS_NAME($className,$debug=False)
  202.     {
  203.         global $OCSP_CONF;
  204.         if ($debugechoDebugMethod(__FILE__,"static call","CMS_PAGE_V2::CMS_PAGE_FROM_CLASS($className)");
  205.         if (empty($className))
  206.         {
  207.             if (isset($OCSP_CONF['CMS']['DEFAULTPAGETYPE']&& !empty($OCSP_CONF['CMS']['DEFAULTPAGETYPE']))
  208.             {
  209.                 $className=$OCSP_CONF['CMS']['DEFAULTPAGETYPE'];
  210.             else {
  211.                 $className="CMS_PAGE_V2";
  212.             }
  213.         }
  214.  
  215.         if (!class_exists($className))
  216.         {
  217.             if (isset($OCSP_CONF['CMS']['PAGETYPE'][$className]['OBJINC']))
  218.             {
  219.                 require_once $OCSP_CONF['CMS']['PAGETYPE'][$className]['OBJINC'];
  220.             else {
  221.                 ocsp_logError(__FILE__,__LINE__,"\$OCSP_CONF['CMS']['PAGETYPE'][$className]['OBJINC'] not set",E_NOTICE);
  222.                 $className='CMS_PAGE_V2';
  223.             }
  224.         }
  225.  
  226.         $str_cmd="\$obj_ret=new $className();";
  227.         if ($debugechoDebugLine(__FILE__,__LINE__,"new cmd$str_cmd");
  228.         @eval($str_cmd);
  229.  
  230.         if (!pcf_is_instance_of($obj_ret,$className))
  231.         {
  232.             ocsp_logError(__FILE__,__LINE__,"cmd$str_cmd failed",E_ERROR);
  233.             return NULL;
  234.         }
  235.         if ($debugechoDebugLine(__FILE__,__LINE__,"CMS_PAGE_SUBCLASS_NAME returns ".get_class($obj_ret)." object");
  236.         return $obj_ret;
  237.     }
  238.  
  239.     /**
  240.       * @static_function
  241.       *
  242.       *  constructor for page objects out of a database row
  243.       *
  244.       * @param array $dbRow 
  245.       * @param CMS_MENU_NODE $aMenuNode 
  246.       * @param boolean $debug 
  247.       *
  248.       * @returns CMS_PAGE_V2*
  249.       * @since pk-07-08-13
  250.       *
  251.       */
  252.     function CMS_PAGE_FROM_DBROW($dbRow,$debug=False)
  253.     {
  254.         if ($debugechoDebugMethod(__FILE__,"static call","<hr />CMS_PAGE_V2::CMS_PAGE_FROM_DBROW()");
  255.         if (isset($dbRow['PAG_OBJCLASS']))
  256.         {
  257.             $o_ret=CMS_PAGE_V2::CMS_PAGE_SUBCLASS_NAME($dbRow['PAG_OBJCLASS'],$debug);
  258.         else {
  259.             $o_ret=new CMS_PAGE_V2();
  260.         }
  261.  
  262.         if (is_object($o_ret))
  263.         {
  264.             $o_ret->setDBRow($dbRow,True);
  265.         }
  266.         if ($debugechoDebugLine(__FILE__,__LINE__,"CMS_PAGE_FROM_DBROW returns ".get_class($o_ret)." object ID: ".$o_ret->getId());
  267.         return $o_ret;
  268.     }
  269.  
  270.  
  271.     /**
  272.       * @static_function
  273.       *
  274.       *  tries to get the page object from the querystring
  275.       *
  276.       * @param boolean $debug 
  277.       *
  278.       * @return CMS_PAGE_V2* 
  279.       *
  280.       */
  281.     function CMS_PAGE_FROM_GET($debug=False)
  282.     {       
  283.         if ($debugechoDebugMethod(__FILE__,"static call","CMS_PAGE_V2::CMS_PAGE_FROM_GET()");
  284.         return self::factoryFromQueryString(False,$debug);
  285.     }
  286.     
  287.     
  288.     
  289.     /** -----------------------------------------------------
  290.       * getter / setter
  291.       */
  292.  
  293.     /**
  294.       * returns a array of variables used by the page object
  295.       *
  296.       * array[varName]=array(
  297.       *     [TYPE]          datatype
  298.       *     [FLDCLASS]      name of DBMS_FIELD* class
  299.       *     [CLASSVALS]     array of values of [FLDCLASS]
  300.       *
  301.       * @returns array
  302.       *
  303.       * @since pk-04-08-10
  304.       *
  305.       */
  306.     protected function getObjVarDef($debug=False{
  307.         require_once __OCSP_PHPINCPATH__."db/frmClasses/DBMS_FIELD_HEADLINE.phpclass";
  308.         require_once __OCSP_PHPINCPATH__."db/frmClasses/DBMS_FIELD_TEXTAREA.phpclass";
  309.         $retArr=array(
  310.             "METAKEYWORDS"=>array(
  311.                 "TYPE"      =>"blob",
  312.                 "FLDCLASS"  => "DBMS_FIELD_TEXTAREA",
  313.                 "CLASSVALS" =>array(
  314.                     "label"         => "Meta Keywords",
  315.                     "nlToBr"        => False,
  316.                     "wrap"          => "off",
  317.                     "rows"          => 2,
  318.                     "allowNull"     => True,
  319.                     "isSearchable"  => False,
  320.                     "showInList"    => False,
  321.                     "toolTip"       => "Meta Keywords fr Suchmaschinen"
  322.                 )
  323.             ),
  324.             "METADESCRIPTION"=>array(
  325.                 "TYPE"      =>"blob",
  326.                 "FLDCLASS"  => "DBMS_FIELD_TEXTAREA",
  327.                 "CLASSVALS" =>array(
  328.                     "label"         => "Meta Description",
  329.                     "nlToBr"        => False,
  330.                     "wrap"          => "off",
  331.                     "rows"          => 2,
  332.                     "allowNull"     => True,
  333.                     "isSearchable"  => False,
  334.                     "showInList"    => False,
  335.                     "toolTip"       => "Beschreibung fr Suchmaschinen"
  336.                 )
  337.             )
  338.         );
  339.         return $retArr;
  340.     }
  341.  
  342.  
  343.     /**
  344.       * @returns int the page id
  345.       ***/
  346.     function getId({
  347.         return intval($this->getDBField($this->colPrevix."ID"));
  348.     }
  349.  
  350.     /**
  351.       * sets the page id
  352.       *
  353.       * @param int $aId 
  354.       *
  355.       * @since pk-03-12-17
  356.       *
  357.       ***/
  358.     function setId($aId{
  359.         $this->setDBField($this->colPrevix."ID",intval($aId));
  360.     }
  361.  
  362.  
  363.     /**
  364.       * returns the class name of the page object stored in the db
  365.       *
  366.       * @param boolean $debug; 
  367.       *
  368.       * @returns string
  369.       *
  370.       * @since pk-05-11-21
  371.       *
  372.       ***/
  373.     function getObjClass($debug=False{
  374.         if ($debugecho "<p><b>CMS_PAGE_V2::getObjClass()</b> (".get_class($this).")</p>\n";
  375.  
  376.         if (!$this->hasColumn("PAG_OBJCLASS")) {
  377.             return strtoupper(get_class($this));
  378.         }
  379.  
  380.         if (!empty($this->PAG_OBJCLASS)) {
  381.             return $this->PAG_OBJCLASS;
  382.         else {
  383.             return strtoupper(get_class($this));
  384.         }
  385.     }
  386.  
  387.     /**
  388.       * @return int 
  389.       * @since pk-07-08-13
  390.       */
  391.     function getOrderNr()
  392.     {
  393.         return intval($this->getDBField($this->colPrevix.'SORTORDER'));
  394.     }
  395.  
  396.         
  397.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  398.     // Project Methods
  399.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  400.  
  401.     /**
  402.       * sets the page as current page by setting projects myPageObj
  403.       *
  404.       * @param boolean $debug 
  405.       *
  406.       * @return boolean 
  407.       *
  408.       * @since pk-07-08-15
  409.       */
  410.     function setAsCurrent($debug)
  411.     {
  412.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::setAsCurrent()",$this->getId());
  413.         if (!pcf_is_instance_of($this->myProjObj,'CMS_PROJECT'))
  414.         {
  415.             if (!$this->getMyProject()) ocsp_logError(__FILE__,__LINE__,"could not get my project",E_WARNING);
  416.             return False;
  417.         }
  418.         $this->myProjObj->setMyPageObj($this,$debug);
  419.         return True;
  420.     }
  421.  
  422.  
  423.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  424.     // Database Methods
  425.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  426.  
  427.     /**
  428.       * populates the page and checks if the current object ($this) is of the class
  429.       * stored in the database PAG_OBJCLASS
  430.       * if this differs a new page object with the right class is returned
  431.       *
  432.       * @param boolean $debug 
  433.       *
  434.       * @return CMS_PAGE_V2 
  435.       *
  436.       * @since pk-07-08-14
  437.       */
  438.     function &populateValidated($debug=False)
  439.     {
  440.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::populateValidated()","ID: ".$this->getId());
  441.  
  442.         if ($this->cmsCacheIsUsable())
  443.         {
  444.             if ($arr_cachePageVal=$this->myCmsCache->getPageData($this->getId(),$debug&& isset($arr_cachePageVal['PAGVAL']['PAG_OBJCLASS']))
  445.             {
  446.                 if (strtoupper($arr_cachePageVal['PAGVAL']['PAG_OBJCLASS']!= strtoupper(get_class($this)))
  447.                 {
  448.                     return CMS_PAGE_V2::CMS_PAGE_FROM_PEARCACHEARR($arr_cachePageVal,$debug);
  449.                 else {
  450.                     $this->setCmsCacheArr($arr_cachePageVal['PAGVAL']);
  451.                     return $this;
  452.                 }
  453.             }
  454.         }
  455.  
  456.         if (!$this->isConnected(True))
  457.         {
  458.             ocsp_logError(__FILE__,__LINE__,"no database connection");
  459.             return NULL;
  460.         }
  461.         $str_query="SELECT * FROM ".$this->myTable.$this->getWhere($debug);
  462.         
  463.         
  464.         if ($debugechoDebugLine(__FILE__,__LINE__,"Page Query: ".$str_query);
  465.         if ($dbRow=$this->myDBObj->quickQuery($str_query))
  466.         {
  467.             if (!empty($dbRow['PAG_OBJCLASS']&& (get_class($this!= $dbRow['PAG_OBJCLASS']))
  468.             {
  469.                 if ($debugechoDebugMethod(__FILE__,__LINE__,"generating no object for class: ".$dbRow['PAG_OBJCLASS']." current class: ".get_class($this));
  470.                 if ($obj_ret=CMS_PAGE_V2::CMS_PAGE_FROM_DBROW($dbRow,$debug))
  471.                 {
  472.                     if ($debugechoDebugLine(__FILE__,__LINE__,"new page object (".get_class($obj_ret).") generated");
  473.                     $obj_ret->setDBObj($this->myDBObj);
  474.                     return $obj_ret;
  475.                 else {
  476.                     ocsp_logError(__FILE__,__LINE__,"could not get object from database row <pre>".print_r($dbRow,True)."</pre>",E_ERROR);
  477.                 }
  478.             else {
  479.                 $this->setDBRow($dbRow,True);
  480.                 return $this;
  481.             }
  482.         else {
  483.             return $this;
  484.         }
  485.     }
  486.  
  487.     /**
  488.       * @param bool   $debug  show debug info
  489.       *
  490.       * @returns int   returns the autoIncFld ID if exists or 1 on success
  491.       *
  492.       * @since pk-05-09-06
  493.       * @version pk-07-06-07
  494.       *
  495.       ***/
  496.     function dbInsert($debug=False{
  497.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::dbInsert()");
  498.  
  499.         if (!$this->isConnected(True,$debug))
  500.         {
  501.             ocsp_logError(__FILE__,__LINE__,"no database connection",E_ERROR);
  502.             die("No Database");
  503.         }
  504.  
  505.         if ($this->hasColumn($this->colPrevix."SORTORDER")) {
  506.             $i_sortOrder=intval($this->getDBField($this->colPrevix."SORTORDER"));
  507.             if (intval($i_sortOrder)) {
  508.                 $s_query ="SELECT COUNT(*) FROM ".$this->myTable;
  509.                 $s_query.=" WHERE ".$this->myProjIdCol."=".$this->getProjId();
  510.                 $s_query.="   AND ".$this->myMenuIdCol."=".$this->getMenId();
  511.                 $s_query.="   AND PAG_SORTORDER=".$i_sortOrder;
  512.                 if ($this->myDBObj->quickQuery($s_query,0)) {
  513.                     $s_query="UPDATE ".$this->myTable ." SET PAG_SORTORDER=PAG_SORTORDER+1 ";
  514.                     $s_query.=" WHERE ".$this->myProjIdCol."=".$this->getProjId();
  515.                     if (!empty($this->myMenuIdCol)) {
  516.                         $s_query.="   AND ".$this->myMenuIdCol."=".$this->getMenId();
  517.                     }
  518.                     $s_query.="   AND PAG_SORTORDER >= ".$i_sortOrder;
  519.                     $this->myDBObj->executeCmd($s_query);
  520.                 }
  521.             else {
  522.                 $s_query ="SELECT IFNULL(MAX(".$this->colPrevix."SORTORDER),0) FROM ".$this->myTable;
  523.                 $s_query.=" WHERE ".$this->myProjIdCol."=".$this->getProjId();
  524.                 $s_query.="   AND ".$this->myMenuIdCol."=".$this->getMenId();
  525.  
  526.                 $i_sortOrder=intval($this->myDBObj->quickQuery($s_query,0))+1;
  527.                 $this->setDBField($this->colPrevix."SORTORDER",$i_sortOrder);
  528.             }
  529.         }
  530.         $this->setDBFieldIfEmpty('PAG_OBJCLASS',get_class($this));
  531.  
  532.         return parent::dbInsert($debug);
  533.     }
  534.  
  535.  
  536.     /**
  537.       * deletes the row from the database
  538.       * and all chapters
  539.       *
  540.       * @note overwrite if not uses PAG_ID and T_CMS_CHAPTER
  541.       *
  542.       * @param boolean $backupData 
  543.       * @param boolean $debug 
  544.       *
  545.       * @returns boolean
  546.       *
  547.       * @since pk-05-03-12
  548.       * @version pk-05-09-06
  549.       * @version pk-05-10-05
  550.       *
  551.       */
  552.     function dbDelete($backupData=False,$debug=False{
  553.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::dbDelete()");
  554.  
  555.         if ($this->getId()) 
  556.         {            
  557.             $this->moveSortLast(True,$deug);
  558.             $a_chapters=$this->getChapterObjArray(0,False,$debug);
  559.             foreach($a_chapters as $o_chap{
  560.                 $o_chap->dbDelete($backupData,$debug);
  561.             }
  562.             return parent::dbDelete($backupData,$debug);
  563.         else {
  564.             return False;
  565.         }
  566.     }
  567.  
  568.  
  569.     /**
  570.       * sets the default values form the default form
  571.       *
  572.       * @param bool $debug 
  573.       *
  574.       * @since pk-05-01-20
  575.       *
  576.       ***/
  577.     function setDefaults($debug=False{
  578.         if ($debugecho "<p><b>CMS_PAGE_V2::setDefaults()</b> (".get_class($this).")</p><blockquote>";
  579.  
  580.         if ($frmObj=$this->dbGetForm(FRM_MODE_NEW,"",$debug)) {
  581.             $this->setDbRow($frmObj->getDefaultValArr("",$debug),False,$debug);
  582.         else {
  583.             if ($debugecho "<p><b>ERROR:<br />Could not load default form</p>";
  584.         }
  585.  
  586.         if ($debugecho "</blockquote>";
  587.     }
  588.  
  589.  
  590.     /*
  591.        #############################################################################
  592.             MOVE METHODS
  593.        #############################################################################
  594.     */
  595.  
  596.     /**
  597.       * moves the page to the first positon (SORTORDER)
  598.       * @note does not save the object
  599.       *
  600.       * @param boolean $allStates 
  601.       * @param boolean $debug 
  602.       *
  603.       * @returns boolean
  604.       *
  605.       * @version pk-05-07-26
  606.       *
  607.       * @todo only $allStates=True coded now
  608.       *
  609.       ***/
  610.     function moveSortFirst($allStates=True,$debug=False{
  611.         if ($debugecho "<p><b>CMS_PAGE_V2::sortMoveFirst(...)</b> (".get_class($this).")</p>";
  612.  
  613.         $query ="SELECT ".$this->colPrevix."ID FROM ".$this->myTable;
  614.         $query.=" WHERE ".$this->myProjIdCol."=".$this->getProjId();
  615.         $query.="   AND ".$this->myMenuIdCol." = ".$this->getMenId()// <pk-05-07-26 />
  616.         $query.="   AND ".$this->colPrevix."ID <> ".$this->getId();
  617.         $query.=" ORDER BY ".$this->colPrevix."SORTORDER ";
  618.  
  619.         if ($debugecho "<blockquote><p>$query</p></blockquote>";
  620.         $this->setDBField($this->colPrevix."SORTORDER",1);
  621.         if ($siblings=$this->myDBObj->queryArray($query)) {
  622.             $sortOrder=2;
  623.             foreach($siblings as $siblId{
  624.                 $cmd ="UPDATE ".$this->myTable." set ".$this->colPrevix."SORTORDER = ".$sortOrder++;
  625.                 $cmd.=" WHERE ".$this->colPrevix."ID =".$siblId;
  626.                 $this->myDBObj->executeCmd($cmd);
  627.             }
  628.             return True;
  629.         else {
  630.             return False;
  631.         }
  632.     }
  633.  
  634.     /**
  635.       * moves the page to the last positon (SORTORDER)
  636.       * @note does not save the object
  637.       *
  638.       * @param boolean $allStates 
  639.       * @param boolean $debug 
  640.       *
  641.       * @returns boolean
  642.       *
  643.       * @version pk-05-07-26
  644.       *
  645.       * @todo only $allStates=True coded now
  646.       *
  647.       ***/
  648.     function moveSortLast($allStates=True,$debug=False{
  649.         if ($debugecho "<p><b>CMS_PAGE_V2::sortMoveFirst(...)</b> (".get_class($this).")</p>";
  650.  
  651.         if (!$this->isConnected(True))
  652.         {
  653.             ocsp_logError(__FILE__,__LINE__,"no database connection",E_WARNING);
  654.             return False;
  655.         }
  656.  
  657.         $query ="SELECT ".$this->colPrevix."ID FROM ".$this->myTable;
  658.         $query.=" WHERE ".$this->myProjIdCol."=".$this->getProjId();
  659.         $query.="   AND ".$this->myMenuIdCol." = ".$this->getMenId()// <pk-05-07-26 />
  660.         $query.="   AND ".$this->colPrevix."ID <> ".$this->getId();
  661.         $query.=" ORDER BY ".$this->colPrevix."SORTORDER ";
  662.  
  663.         if ($debugecho "<blockquote><p>$query</p></blockquote>";
  664.         if ($siblings=$this->myDBObj->queryArray($query)) {
  665.             $sortOrder=1;
  666.             foreach($siblings as $siblId{
  667.                 $cmd ="UPDATE ".$this->myTable." set ".$this->colPrevix."SORTORDER = ".$sortOrder++;
  668.                 $cmd.=" WHERE ".$this->colPrevix."ID =".$siblId;
  669.                 $this->myDBObj->executeCmd($cmd);
  670.             }
  671.             $this->setDBField($this->colPrevix."SORTORDER",$sortOrder);
  672.             return True;
  673.         else {
  674.             return False;
  675.         }
  676.     }
  677.  
  678.     /**
  679.       * moves the page on position up in the sortorder
  680.       * decrease PAG_SORTORDER
  681.       *
  682.       * @param boolean $debug 
  683.       *
  684.       * @since pk-05-07-26
  685.       *
  686.       * @var int $i_myOrderNr 
  687.       * @var string $s_Query 
  688.       * @var array $a_prevPageRow 
  689.       *
  690.       ***/
  691.     function moveSortUp($debug{
  692.         if ($debugecho "<p><b>CMS_PAGE_V2::moveSortUp()</b> (".get_class($this).")</p>";
  693.         if ($debugecho "<blockquote>current OrderNr: (".$this->colPrevix."SORTORDER)".intval($this->{$this->colPrevix."SORTORDER"})."</blockquote>";
  694.  
  695.         if (!$this->isConnected(True))
  696.         {
  697.             ocsp_logError(__FILE__,__LINE__,"no database connection",E_WARNING);
  698.             return False;
  699.         }
  700.  
  701.         if ($i_myOrderNr=intval($this->{$this->colPrevix."SORTORDER"})) {
  702.             $s_Query ="SELECT * FROM ".$this->myTable;
  703.             $s_Query.=" WHERE ".$this->colPrevix."SORTORDER <= ".intval($this->{$this->colPrevix."SORTORDER"});
  704.             $s_Query.="   AND ".$this->colPrevix."ID <> ".$this->getId();
  705.             $s_Query.="   AND ".$this->myProjIdCol." = ".$this->getProjId();
  706.             $s_Query.="   AND ".$this->myMenuIdCol." = ".$this->getMenId();
  707.             $s_Query.=" ORDER BY ".$this->colPrevix."SORTORDER DESC";
  708.             if ($debugecho "<blockquote>Query: ".$s_Query."</blockquote>";
  709.             if ($a_prevPageRow=$this->myDBObj->quickQuery($s_Query)) {
  710.                 $this->{$this->colPrevix."SORTORDER"}=intval($a_prevPageRow[$this->colPrevix."SORTORDER"]);
  711.                 $a_prevPageRow[$this->colPrevix."SORTORDER"]=$this->{$this->colPrevix."SORTORDER"}+1;
  712.                 $this->myDBObj->replaceArray($this->myTable,$a_prevPageRow,$debug);
  713.                 $this->dbSave();
  714.             else if ($i_myOrderNr 1{
  715.                 $s_Query =" WHERE ".$this->myProjIdCol." = ".$this->getProjId();
  716.                 $s_Query.="   AND ".$this->myMenuIdCol." = ".$this->getMenId();
  717.                 $this->myDBObj->resortTable($this->myTable,$this->colPrevix."SORTORDER",$s_Query,$debug);
  718.             }
  719.         }
  720.     }
  721.  
  722.     /**
  723.       * moves the page on position up in the sortorder
  724.       * increase PAG_SORTORDER
  725.       *
  726.       * @param boolean $debug 
  727.       *
  728.       * @since pk-05-07-26
  729.       *
  730.       * @var int $i_myOrderNr 
  731.       * @var string $s_Query 
  732.       * @var array $a_nextPageRow 
  733.       *
  734.       ***/
  735.     function moveSortDown($debug{
  736.         if ($debugecho "<p><b>CMS_PAGE_V2::moveSortUp()</b> (".get_class($this).")</p>";
  737.         if ($i_myOrderNr=intval($this->{$this->colPrevix."SORTORDER"})) {
  738.             $s_Query ="SELECT * FROM ".$this->myTable;
  739.             $s_Query.=" WHERE ".$this->colPrevix."SORTORDER >= ".intval($this->{$this->colPrevix."SORTORDER"});
  740.             $s_Query.="   AND ".$this->colPrevix."ID <> ".$this->getId();
  741.             $s_Query.="   AND ".$this->myProjIdCol." = ".$this->getProjId();
  742.             $s_Query.="   AND ".$this->myMenuIdCol." = ".$this->getMenId();
  743.             $s_Query.=" ORDER BY ".$this->colPrevix."SORTORDER";
  744.             if ($debugecho "<blockquote>Query: ".$s_Query."</blockquote>";
  745.             if ($a_nextPageRow=$this->myDBObj->quickQuery($s_Query)) {
  746.                 $a_nextPageRow[$this->colPrevix."SORTORDER"]=$i_myOrderNr;
  747.                 $this->{$this->colPrevix."SORTORDER"}       =$i_myOrderNr+1;
  748.                 $this->myDBObj->replaceArray($this->myTable,$a_nextPageRow,$debug);
  749.                 $this->dbSave();
  750.             }
  751.         }
  752.     }
  753.  
  754.  
  755.     /*
  756.        #############################################################################
  757.             FEEDBACK METHODS
  758.        #############################################################################
  759.     */
  760.  
  761.     /**
  762.       * returns the feedback form object
  763.       *
  764.       * @param string $fbFormName 
  765.       * @param boolean $debug 
  766.       *
  767.       * @returns DBMS_FORM
  768.       *
  769.       * @since pk-05-05-02
  770.       *
  771.       ***/
  772.     function &getFeedbackForm($fbFormName="T_CMS_FEEDBACK",$debug=False{
  773.         if ($debugecho "<p><b>CMS_PAGE_V2::getFeedbackForm($fbFormName,...)</b> (".get_class($this).")</p>";
  774.  
  775.         require_once $GLOBALS['OCSP']['PHPFORMPATH']."forms.phpinc";
  776.         if ($frmObj=&DBMS_form_loadName($fbFormName)) {
  777.             return $frmObj;
  778.         }
  779.         if (($fbFormName != "T_CMS_FEEDBACK"&& ($frmObj=&DBMS_form_loadName("T_CMS_FEEDBACK"))) {
  780.             return $frmObj;
  781.         }
  782.         return NULL;
  783.     }
  784.  
  785.     /**
  786.       * stores feedback data and returns the data array
  787.       * or null if an error occured
  788.       *
  789.       * @param DBMS_FORM $frmObj 
  790.       * @param string $postName 
  791.       * @param boolean $debug 
  792.       *
  793.       * @returns array
  794.       *
  795.       * @since pk-05-05-02
  796.       *
  797.       ***/
  798.     function saveFeedBackForm(&$frmObj,$postName="DBVAL",$debug=False{
  799.         if ($debugecho "<p><b>CMS_PAGE_V2::saveFeedBackForm(...)</b> (".get_class($this).")</p>";
  800.         require_once __OCSP_PHPINCPATH__."common/pcf.phpinc";
  801.  
  802.         if (!pcf_is_instance_of($frmObj,"DBMS_FORM")) {
  803.             if (!($frmObj=&$this->getFeedbackForm("T_CMS_FEEDBACK",$debug))) {
  804.                 return NULL;
  805.             }
  806.         }
  807.  
  808.         if (!is_array($_POST[$postName]))                    return NULL;
  809.         if (!$DBVAL=$frmObj->getValueArray($_POST['DBVAL'])) return NULL;
  810.  
  811.         $DBVAL[$this->myProjIdCol]   =$this->{$this->myProjIdCol};
  812.         $DBVAL['MEN_ID']    =$this->MEN_ID;
  813.         $DBVAL['PAG_ID']    =$this->PAG_ID;
  814.         $DBVAL['LANG_ID']   =$this->LANG_ID;
  815.  
  816.         if ($DBVAL['CFB_ID']=$this->myDBObj->insertArray("T_CMS_FEEDBACK",$DBVAL,$debug))
  817.             return $DBVAL;
  818.  
  819.         return NULL;
  820.     }
  821.  
  822.     /*
  823.        #############################################################################
  824.             TEMPLATE FUNCTIONS
  825.        #############################################################################
  826.     */
  827.  
  828.     /**
  829.       * returns the body include file from the page template
  830.       * "" if none is set or no template could be loaded
  831.       *
  832.       * @param boolean $debug 
  833.       *
  834.       * @returns string
  835.       *
  836.       * @since pk-06-02-17
  837.       *
  838.       ***/
  839.     function getBodyInclude($debug=False{
  840.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getBodyInclude()","",0);
  841.         if (!$this->loadTemplate($debug)) return "";
  842.         return $this->myTemplate->getDBField("PTMP_BODYTMPLINC");
  843.     }
  844.     
  845.  
  846.     /**
  847.       * sets the template id
  848.       *
  849.       * @param int $ptmplId 
  850.       *
  851.       * @since pk-05-11-09
  852.       *
  853.       ***/
  854.     function setTemplateId($ptmpId{
  855.         $this->setDBField($this->ptmplFld,intval($ptmpID));
  856.     }
  857.  
  858.  
  859.     /**
  860.       * loads the page template object if $this->myTemplate is not set or has a different ID
  861.       *
  862.       * uses $GLOBALS['OCSP']['CACHE'][$this->moduleKey.'PAGE_TEMPLATES'] as memory cache
  863.       *
  864.       *
  865.       * @param boolean $debug show debug information
  866.       * @param boolean $enableEmpty 
  867.       *
  868.       * @returns int
  869.       *                  1 on success
  870.       *                  0 on error
  871.       *                 -1 empty template
  872.       *
  873.       * @version pk-05-12-13 enableEmpty added
  874.       * @version pk-06-02-16 use $this->{$this->ptmplFld} instead of $this->PTMP_ID; use Cache
  875.       * @version pk-07-06-07 use cache ask menu and project for PTMP_ID
  876.       *
  877.       * @deprecated since pk-08-06-19
  878.       */
  879.     function loadTemplate($debug=False,$enableEmpty=True{
  880.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::loadTemplate()");
  881.  
  882.         return ($this->getTemplate($debugTrue False);
  883.         
  884.     }
  885.  
  886.  
  887.     /**
  888.       *
  889.       * Overwrite in inherit classes with other tables or objects
  890.       *
  891.       * @param int $tmplId 
  892.       * @param boolean $debug 
  893.       *
  894.       * @version pk-05-08-26
  895.       *
  896.       * @requires $GLOBALS['OCSP_CMS']['PHPINCPATH']."template/chapter/TMPL_CHAPTER_V3.phpclass";
  897.       *
  898.       ***/
  899.     function loadChaTemplate($tmplId,$debug=False{
  900.         if ($debugecho "<p><b>CMS_PAGE_V2::loadChaTemplate($tmplId)</b> (".get_class($this).")</p>";
  901.         if (!$this->populateTS$this->dbPopulate();
  902.  
  903.         require_once $GLOBALS['OCSP_CMS']['PHPINCPATH']."template/chapter/TMPL_CHAPTER_V3.phpclass";
  904.  
  905.         $cmd="\$this->chaTmplArr[".$tmplId."] = new ".$this->ctmplClass."();";
  906.         if ($debugecho "<pre>".$cmd."</pre>";
  907.         eval ($cmd);
  908.  
  909.         if ($debugecho "<pre>".pcf_object_info($this->chaTmplArr[$tmplId])."</pre>";
  910.  
  911.         $this->chaTmplArr[$tmplId]->setProjId($this->getProjId());
  912.         $this->chaTmplArr[$tmplId]->setPTMPId($this->getTemplateId());
  913.         // $this->chaTmplArr[$tmplId]->setLangId(intval($chapRow['LANG_ID']));
  914.         $this->chaTmplArr[$tmplId]->setId($tmplId);
  915.         $this->chaTmplArr[$tmplId]->dbPopulate($debug);
  916.     }
  917.  
  918.  
  919.     /**
  920.       * returns the template object with ID $tmplId
  921.       *
  922.       * @param int $tmplId 
  923.       * @param boolean $debug 
  924.       *
  925.       * @returns TMPL_CHAPTER_V3
  926.       *
  927.       * @since pk-05-07-28
  928.       *
  929.       ***/
  930.     function &getChaTemplateObj($tmplId,$debug=False{
  931.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getChaTemplateObj($tmplId)");
  932.         if (!isset($this->chaTmplArr[$tmplId]|| !is_object($this->chaTmplArr[$tmplId])) {
  933.             $this->loadChaTemplate($tmplId,$debug);
  934.         }
  935.         return $this->chaTmplArr[$tmplId];
  936.     }
  937.  
  938.  
  939.  
  940.  
  941.  
  942.     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  943.     /* chapter methods                                                          */
  944.     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  945.  
  946.  
  947.  
  948.     /**
  949.       * returns the query string to select the chapters
  950.       *
  951.       * adds $addWhere between WHERE and ORDER BY
  952.       *
  953.       * <code>
  954.       * $query.=" AND LANG_ID=".$this->getLangId();
  955.       * $query.=$addWhere;
  956.       * $query.=" ORDER BY ".$this->."_SORTORDER";
  957.       * </code>
  958.       *
  959.       * @param bool $showAllStates      don't care about chapter state
  960.       * @param bool $showTimedOut       show chapters with SHOWTILL date in past
  961.       * @param bool $showFuture         show chapters with SHOWFROM date in futur
  962.       * @param mixed $showGroup         0=Public, -1 $OCSP_OBJ['USER']->getGroups(), False don't care else exakt the group
  963.       * @param string $addWhere 
  964.       * @param boolean $debug 
  965.       *
  966.       * @global array $OCSP_OBJ 
  967.       *
  968.       * @returns string
  969.       *
  970.       * @since pk-03-12-14
  971.       *
  972.       ***/
  973.     function getChapQuery($showAllStates=False,$showTimedOut=False,$showFuture=False,$showGroup=False,$addWhere="",$debug=False{
  974.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getChapQuery($showAll,$showTimedOut,$showFuter,$showGroup,$addWhere,$debug)");
  975.  
  976.         global $OCSP_OBJ;
  977.  
  978.         if (!$this->getDBObj())
  979.         {
  980.             ocsp_logError(__FILE__,__LINE__,"could not get DB Object");
  981.         }
  982.  
  983.         $query ="SELECT *";
  984.         if ($this->cTable == "T_CMS_CHAPTER"{
  985.             $query.=",(".$this->chapPrevix."SHOWFROM <= NOW()) AS SHOWFROM_OK";
  986.             $query.=",(".$this->chapPrevix."SHOWTILL > NOW()) AS SHOWTILL_OK";
  987.         }
  988.         $query.=" FROM ".$this->cTable;
  989.         $query.=" WHERE ".$this->colPrevix."ID=".$this->getId();
  990.         $query.=" AND ".$this->myProjIdCol."=".$this->getProjId();
  991.         $query.=" AND LANG_ID=".$this->getLangId();
  992.         if (!$showAllStates{
  993.             $query.=" AND ".$this->myDBObj->qs_getWhereIn($this->chapPrevix."STATE",$this->getChapOnlineStates(),False);
  994.         }
  995.         if (!$showTimedOut{
  996.             $query.=" AND ".$this->chapPrevix."SHOWTILL >= ".$this->myDBObj->qs_getNowStmt();
  997.         }
  998.         if (!$showFuture{
  999.             $query.=" AND ".$this->chapPrevix."SHOWFROM <= ".$this->myDBObj->qs_getNowStmt();
  1000.         }
  1001.         if ($showGroup !== False {    // note !== type equal compare (0 != False)
  1002.             if ($showGroup == -1{
  1003.                 $query.=" AND ".$this->myDBObj->qs_getWhereIn($this->chapPrevix."SHOWGROUP",$OCSP_OBJ['USER']->getGroups(),False);
  1004.             else {
  1005.                 $query.=" AND ".$this->chapPrevix."SHOWGROUP = ".$showGroup;
  1006.             }
  1007.         }
  1008.  
  1009.         $query.= " ".$addWhere;
  1010.         $query.=" ORDER BY ".$this->chapPrevix."SORTORDER";
  1011.  
  1012.         if ($debugechoDebugLine(__FILE__,__LINE__,"Returning$query");
  1013.         return $query;
  1014.     }
  1015.  
  1016.  
  1017.     /**
  1018.       * returns an array of chapter objects
  1019.       *
  1020.       * NOTE does not use CMS_PAGE_V2::getChapQuery()
  1021.       *
  1022.       * @param int $showMode (0=all)
  1023.       * @param boolean $onlineOnly 
  1024.       * @param boolean $debug 
  1025.       *
  1026.       * @returns array
  1027.       *
  1028.       * @since pk-05-10-05
  1029.       * @version pk-05-10-10
  1030.       * @version pk-05-11-16 checks if certain columns exists added
  1031.       * @version pk-07-09-11 use $this->getChapQuery
  1032.       *
  1033.       * @todo CMS_PAGE_V2::getChapterObjArray() cacheing
  1034.       *
  1035.       ***/
  1036.     function getChapterObjArray($showMode=0,$onlineOnly=False,$debug=False{
  1037.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getChapterObjArray($showMode)");
  1038.  
  1039.         if (!$this->isConnected(True))
  1040.         {
  1041.             ocsp_logError(__FILE__,__LINE__,"no database connect",E_ERROR);
  1042.             return False;
  1043.         }
  1044.  
  1045.         if ($onlineOnly)
  1046.         {
  1047.             $b_showOffLine=False;
  1048.             $showGroup=-1;
  1049.         else {
  1050.             $b_showOffLine=True;
  1051.             $showGroup=False;
  1052.         }
  1053.         $str_query=$this->getChapQuery($b_showOffLine,$b_showOffLine,$b_showOffLine,$showGroup,"",$debug);
  1054.         if ($debugechoDebugLine(__FILE__,__LINE__,"Chapter Query$str_query");
  1055.  
  1056.         $a_chapters=array();
  1057.         if ($o_cursor=$this->myDBObj->query($str_query)) {
  1058.             $i_idx=1;
  1059.             //if (!class_exists($this->myChapterClass)) $this->myChapterClass="CMS_CHAPTER_V2";
  1060.             while($a_row=$o_cursor->fetchArrayFld()) {
  1061.                 if (!($obj_chapter=$this->getChapterObj(intval($a_row[$this->chapPrevix.'ID']),$a_row,$debug)))
  1062.                 {
  1063.                     ocsp_logError(__FILE__,__LINE__,"could not instantion chapter object ",E_ERROR);
  1064.                 else {
  1065.                     if (method_exists($obj_chapter,'getSortOrder'))
  1066.                     {
  1067.                         $i_idx=$obj_chapter->getSortOrder();
  1068.                     }
  1069.                     while(isset($a_chapters[$i_idx])) $i_idx++;
  1070.                     $a_chapters[$i_idx]=$obj_chapter;
  1071.                     $i_idx++;
  1072.                 }
  1073.             }
  1074.         }
  1075.  
  1076.         ksort($a_chapters);
  1077.         return $a_chapters;
  1078.     }
  1079.  
  1080.     /**
  1081.       * @param int $chaId 
  1082.       * @param array $chaRow 
  1083.       * @param boolean $debug 
  1084.       *
  1085.       * @return CMS_CHAPTER_V2 
  1086.       *
  1087.       * @todo CMS_PAGE_V2::getChapterObj() use cache
  1088.       * @todo CMS_PAGE_V2::getChapterObj() include chapter class if not exists
  1089.       */
  1090.     function getChapterObj($chaId,$chaRow=NULL,$debug=False)
  1091.     {
  1092.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getChapterObj($chaId)");
  1093.  
  1094.         if (!is_array($chaRow|| (!isset($chaRow[$this->chapPrevix.'ID'])))
  1095.         {
  1096.             $str_query=$this->getChapQuery(True,True,True,False,"AND ".$this->chapPrevix."ID=".intval($chaId),$debug);
  1097.             if ($debugechoDebugLine(__FILE__,__LINE__,"Chapter Query: ".$str_query);
  1098.             if (!$chaRow=$this->myDBObj->quickQuery($str_query))
  1099.             {
  1100.                 ocsp_logError(__FILE__,__LINE__,"could not find chapter with id$chaId",E_WARNING);
  1101.                 return NULL;
  1102.             }
  1103.         }
  1104.  
  1105.         if ($debugechoDebugLine(__FILE__,__LINE__,"Row: <pre>".print_r($a_row,True)."</pre>");
  1106.         if (isset($chaRow[$this->chapPrevix.'CLASS']&& !empty($chaRow[$this->chapPrevix.'CLASS']))
  1107.         {
  1108.             $str_chaClass=$chaRow[$this->chapPrevix.'CLASS'];
  1109.         else {
  1110.             $str_chaClass=$this->myChapterClass;
  1111.         }
  1112.         if (empty($str_chaClass)) $str_chaClass="CMS_CHAPTER_V2";
  1113.         if (!class_exists($str_chaClass))
  1114.         {
  1115.             if (file_exists(__OCSP_CMS_PHPINCPATH__._OCSP_DIRSEP_.'chapter'._OCSP_DIRSEP_.$str_chaClass.'.phpclass'))
  1116.             {
  1117.                 require_once __OCSP_CMS_PHPINCPATH__._OCSP_DIRSEP_.'chapter'._OCSP_DIRSEP_.$str_chaClass.'.phpclass';
  1118.             else {
  1119.                 ocsp_logError(__FILE__,__LINE__,"chapter class $str_chaClass not loaded",E_WARNING);
  1120.                 $str_chaClass="CMS_CHAPTER_V2";
  1121.                 require_once __OCSP_CMS_PHPINCPATH__._OCSP_DIRSEP_.'chapter'._OCSP_DIRSEP_.$str_chaClass.'.phpclass';
  1122.             }
  1123.         }
  1124.  
  1125.         $str_cmd="\$obj_chapter=new ".$str_chaClass."();";
  1126.         eval ($str_cmd);
  1127.         $obj_chapter->setDBRow($chaRow,True,$debug);
  1128.         $obj_chapter->setMyPageObj($this);
  1129.  
  1130.         return $obj_chapter;
  1131.     }
  1132.  
  1133.  
  1134.     /**
  1135.       * copies the chpaters from the page with id $sourceId
  1136.       * into this page
  1137.       *
  1138.       * @param int $sourceId    PAG_ID of sourcepage
  1139.       * @param bool $outdated   if true copy only pages with show till > now
  1140.       * @param bool $debug 
  1141.       *
  1142.       * @version pk-05-03-12 bugfix
  1143.       * @version pk-07-10-02
  1144.       *
  1145.       * @todo CMS_PAGE_V2::copyChaptersFrom() inline SQL
  1146.       ***/
  1147.     function copyChaptersFrom($sourceId,$outdated=False,$debug=False{
  1148.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::copyChaptersFrom($sourceId)");
  1149.  
  1150.         $str_query ="SELECT * FROM ".$this->cTable." WHERE ".$this->colPrevix."ID=".intval($sourceId)/* <pk-05-03-12 /> */
  1151.         if (!$outdated{
  1152.             $str_query.=" AND ".$this->chapPrevix."SHOWTILL > ".$this->myDBObj->qs_getNowStmt();
  1153.         }
  1154.  
  1155.         if (!$this->isConnected(True))
  1156.         {
  1157.             ocsp_logError(__FILE__,__LINE__,"no database connection",E_ERROR);
  1158.             return False;
  1159.         }
  1160.  
  1161.         if ($debugechoDebugLine(__FILE__,__LINE__,$str_query);
  1162.         if ($obj_cursor $this->myDBObj->query($outdated)) {
  1163.             while ($arr_chapter $obj_cursor->fetchArrayFld()) {
  1164.                 if ($debugechoDebugLine(__FILE__,__LINE__,"<pre>".$arr_chapter."</pre>");
  1165.                 require_once __OCSP_PHPINCPATH__.'cms/chapter/'.$chapter['CHA_CLASS'].'.phpclass';
  1166.                 $o_newCha new $chapter['CHA_CLASS']();
  1167.                 $o_newCha->setDBRow($arr_chapter);
  1168.                 $o_newCha->setProjId($this->getProjId());
  1169.                 $o_newCha->setPageId($this->getId());
  1170.                 $o_newCha->setId(0);
  1171.                 $o_newCha->dbSave($debug);
  1172.             }
  1173.         }
  1174.         // </sw-05-12-30>
  1175.  
  1176.     }
  1177.  
  1178.     /**
  1179.       * resorts the chapters
  1180.       *
  1181.       * @param boolean $orderByState 
  1182.       * @param boolean $orderByShowMode 
  1183.       * @param boolean $debug 
  1184.       *
  1185.       * @since pk-05-03-23
  1186.       *
  1187.       ***/
  1188.     function resortChapters($orderByState=False,$orderByShowMode=True,$debug=False{
  1189.         if ($debugecho "<p><b>CMS_PAGE_V2::resortChapters()</b> (".get_class($this).")</p>";
  1190.  
  1191.         $query ="SELECT ".$this->chapPrevix."ID,".$this->chapPrevix."SORTORDER FROM ".$this->cTable;
  1192.  
  1193.         $where =" WHERE ".$this->colPrevix."ID=".intval($this->getId());
  1194.         $where.=" AND ".$this->myProjIdCol."=".intval($this->getProjId());
  1195.         $where.=" AND LANG_ID=".intval($this->getLangId());
  1196.         $query.=$where;
  1197.  
  1198.         $orderBy=" ORDER BY ";
  1199.         if ($orderByShowMode$orderBy.=$this->chapPrevix."SHOWMODE,";
  1200.         if ($orderByState)    $orderBy.=$this->chapPrevix."STATE,";
  1201.         $query.=$orderBy.$this->chapPrevix."SORTORDER";
  1202.  
  1203.         if ($debugecho "<blockquote><p>Query$query</p><ul>";
  1204.         if ($chaList=$this->myDBObj->queryArray($query,0,1)) {
  1205.             $sortOrder=1;
  1206.             foreach($chaList as $chaId => $sort{
  1207.                 if ($sort != $sortOrder{
  1208.  
  1209.                     $cmd ="UPDATE ".$this->cTable." SET ".$this->chapPrevix."SORTORDER=".$sortOrder;
  1210.                     $cmd.=$where." AND ".$this->chapPrevix."ID=".$chaId;
  1211.                     if ($debugecho "<li>$cmd</li>";
  1212.                     $this->myDBObj->executeCmd($cmd);
  1213.                 }
  1214.                 $sortOrder++;
  1215.             }
  1216.         }
  1217.         if ($debugecho "</ul></blockquote>";
  1218.     }
  1219.  
  1220.     /**
  1221.       * moves a chapter to a specified positon (SORTORDER)
  1222.       *
  1223.       * first updates the chapter and than
  1224.       * calls $this->resortChapters(False,True,$debug)
  1225.       *
  1226.       * @param int $chaId 
  1227.       * @param int $position 
  1228.       * @param boolean $debug 
  1229.       *
  1230.       ***/
  1231.     function chpater_MoveToPosition($chaId,$position,$debug=False{
  1232.         if ($debugecho "<p><b>CMS_PAGE_V2::chpater_MoveToPosition($chaId,$position,$debug)</b> (".get_class($this).")</p>";
  1233.  
  1234.         if (intval($chaId&& intval($position)) {
  1235.             $cmd ="UPDATE ".$this->cTable." SET ".$this->chapPrevix."SORTORDER=".intval($position);
  1236.             $cmd.=" WHERE ".$this->colPrevix."ID=".intval($this->getId());
  1237.             $cmd.=" AND ".$this->myProjIdCol."=".intval($this->getProjId());
  1238.             $cmd.=" AND LANG_ID=".intval($this->getLangId());
  1239.             $cmd.=" AND CHA_ID=".intval($chaId);
  1240.             if ($debugecho "<p>Cmd$cmd</p>";
  1241.             if ($this->myDBObj->executeCmd($cmd)) {
  1242.                 $this->resortChapters(False,True,$debug);
  1243.                 return True;
  1244.             }
  1245.         }
  1246.         return False;
  1247.     }
  1248.  
  1249.     // #########################################
  1250.  
  1251.     /**
  1252.       * returns a query to find a sibling
  1253.       * if $preview is True showdate is ignored
  1254.       *
  1255.       * @param boolean $preview 
  1256.       * @param boolean $idOnly 
  1257.       * @param boolean $debug 
  1258.       *
  1259.       * @returns string
  1260.       *
  1261.       * @version pk-05-03-16
  1262.       *
  1263.       ***/
  1264.     function getSiblingQueryString($preview=False,$idOnly=True,$debug=False{
  1265.         if ($debugecho "<p><b>CMS_PAGE_V2::getSiblingQueryString()</b> (".get_class($this).")</p>";
  1266.  
  1267.         if (!$this->populateTS$this->dbPopulate();
  1268.  
  1269.         $and="";
  1270.         $query="SELECT ";
  1271.         if ($idOnly$query.=$this->colPrevix."ID "else $query.="* ";
  1272.         $query.=" FROM ".$this->myTable." WHERE ";
  1273.  
  1274.         $keys=$this->myKeys;
  1275.         unset($keys[$this->colPrevix."ID"]);
  1276.  
  1277.         foreach($keys as $key => $val{
  1278.             $query.= $and $key" =\"".str_replace('"','\"',$this->{$key})."\"";
  1279.             $and " AND ";
  1280.         }
  1281.  
  1282.         if (isset($this->{$this->myProjIdCol})) {
  1283.             $query.=$and.$this->myProjIdCol."=".intval($this->getProjId());
  1284.             $and " AND ";
  1285.         }
  1286.  
  1287.         if (isset($this->MEN_ID)) {
  1288.             $query.=$and." MEN_ID=".intval($this->MEN_ID);
  1289.             $and " AND ";
  1290.         }
  1291.  
  1292.         if (!$preview{
  1293.             $query.= $and.$this->colPrevix."SHOWFROM <= NOW()";
  1294.             $query.= " AND ".$this->colPrevix."SHOWTILL >= NOW()";
  1295.             $and=" AND ";
  1296.         }
  1297.  
  1298.         if ($and==""{
  1299.             $query.=" 1=1 ";
  1300.         }
  1301.         return $query;
  1302.     }
  1303.  
  1304.     /**
  1305.       * returns the id of the next sibling
  1306.       *
  1307.       * @param boolean $preview 
  1308.       * @param boolean $debug 
  1309.       *
  1310.       * @returns int
  1311.       *
  1312.       ***/
  1313.     function getNextPage($preview=False,$debug=False{
  1314.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getNextPage()");
  1315.  
  1316.         $query=$this->getSiblingQueryString($preview,True,$debug);
  1317.         $query.= " AND ".$this->colPrevix."SORTORDER > ".intval($this->{$this->colPrevix."SORTORDER"});
  1318.  
  1319.         if (!$preview{
  1320.             $query.= " AND ".$this->colPrevix."STATE IN (";
  1321.             $sep="";
  1322.             foreach($GLOBALS['OCSP_CMS']['PAGESTATE'as $id => $sArr{
  1323.                 if ($sArr['SHOW']{
  1324.                     $query.=$sep.$id;
  1325.                     $sep=",";
  1326.                 }
  1327.             }
  1328.             $query.=")";
  1329.         }
  1330.         if ($debugecho "<blockquote><p>$query</p></blockquote>";
  1331.         return $this->myDBObj->quickQuery($query,0);
  1332.     }
  1333.  
  1334.     /**
  1335.       * returns the link to the next page by adding setting getParam PAG_ID in the menu query
  1336.       *
  1337.       * @param boolean $preview 
  1338.       * @param boolean $debug 
  1339.       *
  1340.       * @returns string
  1341.       *
  1342.       * @since pk-07-01-11
  1343.       *
  1344.       ***/
  1345.     function getNextPageUrl($preview=False,$debug=False{
  1346.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getNextPageUrl()");
  1347.  
  1348.         if ($i_pagId=$this->getNextPage($preview,$debug)) {
  1349.             return pcf_HTML_changeURI_GetValue($this->getMenLinkUrl($debug),'PAG_ID',$i_pagId);
  1350.         }
  1351.     }
  1352.  
  1353.     /**
  1354.       * returns the id of the previous sibling
  1355.       *
  1356.       * @param boolean $preview 
  1357.       * @param boolean $debug 
  1358.       *
  1359.       * @returns int
  1360.       *
  1361.       * @version pk-08-05-08
  1362.       */
  1363.     function getPreviousPage($preview=False,$debug=False{        
  1364.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getPreviousPage($preview,...)");
  1365.         
  1366.         if (!$this->isConnected(True,$debug))
  1367.         {
  1368.             throw new Exception(_OCSP_EXCEP_NODBCONN_);
  1369.         }
  1370.         
  1371.         $query=$this->getSiblingQueryString($preview,True,$debug);
  1372.         $query.= " AND ".$this->colPrevix."SORTORDER < ".intval($this->{$this->colPrevix."SORTORDER"});
  1373.  
  1374.         if (!$preview{
  1375.             $query.= " AND ".$this->colPrevix."STATE IN (";
  1376.             $sep="";
  1377.             foreach($GLOBALS['OCSP_CMS']['PAGESTATE'as $id => $sArr{
  1378.                 if ($sArr['SHOW']{
  1379.                     $query.=$sep.$id;
  1380.                     $sep=",";
  1381.                 }
  1382.             }
  1383.             $query.=")";
  1384.         }
  1385.         if ($debugecho "<blockquote><p>$query</p></blockquote>";
  1386.         return $this->myDBObj->quickQuery($query,0);
  1387.     }
  1388.  
  1389.  
  1390.  
  1391.     /**
  1392.       * returns the link to the parent menu
  1393.       *
  1394.       * @param boolean $debug 
  1395.       *
  1396.       * @returns string
  1397.       *
  1398.       * @since pk-07-02-15
  1399.       *
  1400.       ***/
  1401.     function getMyParentLink($debug=False{
  1402.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getMyParentLink()");
  1403.  
  1404.         $o_menNode=$this->getMyMenuNode();
  1405.         if ($o_menParent=$o_menNode->getParentObj()) {
  1406.             return $o_menParent->getLinkUrl($debug);
  1407.         else {
  1408.             return "/?PROJ_ID=".$this->getProjId();
  1409.         }
  1410.     }
  1411.  
  1412.  
  1413.  
  1414.     /**
  1415.       * returns the link to the first page state 7 (insert)
  1416.       *
  1417.       * @param boolean $preview 
  1418.       * @param boolean $debug 
  1419.       *
  1420.       * @returns string
  1421.       *
  1422.       * @since pk-05-03-16
  1423.       *
  1424.       ***/
  1425.     function getNewLink($preview=False,$debug=False{
  1426.         $ret=$_SERVER['SCRIPT_NAME'];
  1427.         $ret.="?".$this->myProjIdCol."=".$this->getProjId();
  1428.         $ret.="&MEN_ID=".$this->MEN_ID;
  1429.  
  1430.         $query =$this->getSiblingQueryString($preview,True,$debug);
  1431.         $query.=" AND ".$this->colPrevix."STATE =7";
  1432.  
  1433.         if ($pagId=$this->myDBObj->quickQuery($query,0)) {
  1434.             $ret.="&PAG_ID=".$pagId;
  1435.             return $ret;
  1436.         else {
  1437.             return NULL;
  1438.         }
  1439.     }
  1440.  
  1441.  
  1442.     /**
  1443.       * returns the link to the first page state 8 (edit)
  1444.       *
  1445.       * @param boolean $preview 
  1446.       * @param boolean $debug 
  1447.       *
  1448.       * @returns string
  1449.       *
  1450.       * @since pk-05-03-16
  1451.       *
  1452.       ***/
  1453.     function getEditLink($preview=False,$debug=False{
  1454.         if ($debugecho "<p><b>CMS_PAGE_V2::getEditLink()</b> (".get_class($this).")</p>";
  1455.         $ret=$_SERVER['SCRIPT_NAME'];
  1456.         $ret.="?".$this->myProjIdCol."=".$this->getProjId();
  1457.         $ret.="&MEN_ID=".$this->MEN_ID;
  1458.  
  1459.         $query =$this->getSiblingQueryString($preview,True,$debug);
  1460.         $query.=" AND ".$this->colPrevix."STATE =8";
  1461.  
  1462.         if ($debugecho "<blockquote><p>$query</p></blockquote>";
  1463.         if ($pagId=$this->myDBObj->quickQuery($query,0)) {
  1464.             $ret.="&PAG_ID=".$pagId;
  1465.             return $ret;
  1466.         else {
  1467.             return NULL;
  1468.         }
  1469.     }
  1470.  
  1471.  
  1472.     
  1473.     
  1474.     // #########################################
  1475.  
  1476.  
  1477.  
  1478.  
  1479.     /**
  1480.       * returns a comma seperated list of chapter page modes to show
  1481.       * from $GLOBALS['OCSP_CMS']['CHAPTERSTATE']
  1482.       *
  1483.       * @param 
  1484.       * @returns array
  1485.       *
  1486.       * @since pk-03-12-18
  1487.       *
  1488.       ***/
  1489.     function getChapPageModes({
  1490.         foreach($GLOBALS['OCSP_CMS']['CHAPTERSTATE'as $key => $settings{
  1491.             echo "<pre>";print_r($settings)echo "</pre>";
  1492.             if ($settings["SHOW"]$ret[]=$key;
  1493.         }
  1494.         echo "<pre>";print_r($ret)echo "</pre>";
  1495.         return $ret;
  1496.     }
  1497.  
  1498.  
  1499.     /**
  1500.       * shows the page in preview mode
  1501.       *
  1502.       * @param int  $mode 
  1503.       * @param bool $debug 
  1504.       *
  1505.       * @todo rewrite the method
  1506.       ***/
  1507.     function preview($mode=0,$debug=False{
  1508.         if ($debugecho "<p><b>CMS_PAGE_V2::preview($mode,$debug)</b> (".get_class($this).")</p>";
  1509.         
  1510.         echo "<h1>Todo</h1>";
  1511. /*                
  1512.         if (!is_object($this->myTemplate)) {
  1513.             if (!($this->loadTemplate($debug))) {
  1514.                 $ERR="TEMPLATE_NOT_FOUND ".$query;
  1515.                 include __OCSP_PHPINCPATH__."io/errors.phpinc";
  1516.                 die();
  1517.             }
  1518.         }
  1519.         echo "
  1520.             <!doctype public \"-//w3c//dtd html 4.01 transitional//en\" \"http://www.w3.org/TR/html4/loose.dtd\">
  1521.             <html lang=\"de-at\">\n";
  1522.         echo "<head><title>".$this->{$this->colPrevix."TITLE"}."</title><link type=\"text/css\" rel=\"stylesheet\" href=\"/cms/defaultStyles.php\" />";
  1523.         if ( intval($this->STY_ID)) { 
  1524.             echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"/cms/styles.php?STY_ID=".$this->STY_ID."&amp;".$this->myProjIdCol."=".$this->getProjId()."\" />";
  1525.         }
  1526.         echo $this->myTemplate->getMetaTag()."\n";
  1527.         echo $this->myTemplate->getCSSTag()."\n";
  1528.         echo $this->myTemplate->getJavaScriptTag()."\n";
  1529.         echo "</head>\n";
  1530.         
  1531.         echo $this->myTemplate->getBodyTag();
  1532.         echo $this->myTemplate->getHeadLineTag();
  1533.  
  1534.         echo $this->{$this->colPrevix."HEADER"};
  1535.  
  1536.         if ($debug) echo "<p>Chapter Query: ".$this->getChapQuery(True,False,True,False,"",$debug)."</p>";
  1537.         if ($cursor=$this->myDBObj->query($this->getChapQuery())) {
  1538.             while($row=$cursor->fetchArray()) {
  1539.                 if (!is_object($this->chaTmplArr[$row[$this->ctmplFldPrevix."ID"]])) {
  1540.                     $idx=$row[$this->ctmplFldPrevix."ID"];
  1541.                     $cmd="\$this->chaTmplArr[".$idx."] = new ".$this->ctmplClass."();";
  1542.                     eval ($cmd);
  1543.  
  1544.                 }
  1545.  
  1546.                 echo $this->chaTmplArr[$row[$this->ctmplFldPrevix."ID"]]->getTag(unserialize($row[$this->chapPrevix.'FIELDS']));
  1547.  
  1548.             }
  1549.         }
  1550.  
  1551.         echo $this->{$this->colPrevix."FEETER"};
  1552.         echo $this->myTemplate->getFeeterTag();
  1553.         echo "</body></html>";
  1554. */
  1555.     }
  1556.  
  1557.     /**
  1558.       * returns the html code of the page header
  1559.       *
  1560.       * @param boolean $withStyles 
  1561.       * @param boolean $debug 
  1562.       * @param boolean $withEndTag  </ pk-04-10-11>
  1563.       *
  1564.       * @returns string
  1565.       *
  1566.       * @version pk-04-10-11
  1567.       * @version pk-05-04-19 lang added to html (@see http://www.w3.org/TR/WCAG10-HTML-TECHS/#identify-primary-lang)
  1568.       * @version pk-05-07-12 bugfix $withStyles
  1569.       * @version pk-07-02-27 pcf_get_htmlJsInclude
  1570.       *
  1571.       * @todo take lang from the LANG_ID
  1572.       *
  1573.       * @requires __OCSP_PHPINCPATH__."common/OCSP_BROWSER.phpclass" (_OCSP_USEPEARCACHE_)
  1574.       ***/
  1575.     function getHead($withStyles=True,$debug=False,$withEndTag=True{
  1576.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getHead()");
  1577.  
  1578.         if ($this->cmsCacheIsUsable())
  1579.         {
  1580.             if ($str_header=$this->myCmsCache->getPageHeader($this,$debug))
  1581.             {
  1582.                return $str_header;
  1583.             }
  1584.         }
  1585.  
  1586.         if (!is_object($this->myTemplate)) {
  1587.             if (!($this->loadTemplate($debug))) {
  1588.                 // get the project default template
  1589.                 if (!intval($this->getProjId())) $this->setProjId(intval($_GET['PROJ_ID']));
  1590.  
  1591.                 $s_query ="SELECT PTMP_ID FROM T_CMS_TMPL_PAGE WHERE (PROJ_ID=".$this->getProjId()." OR PROJ_ID=0) ";
  1592.                 $s_query.=" ORDER BY PROJ_ID DESC,PTMP_ISDEFAULT DESC";
  1593.  
  1594.                 if (!$this->isConnected(True,$debug))
  1595.                 {
  1596.                     die("Database error");
  1597.                 }
  1598.                 if (!$i_TmplId=intval($this->myDBObj->quickQuery($s_query,0))) {
  1599.                     $ERR="TEMPLATE_NOT_FOUND ".$s_query;
  1600.                     include __OCSP_PHPINCPATH__."io/errors.phpinc";
  1601.                     die();
  1602.                 }
  1603.                 $this->setTemplateId($i_TmplId);
  1604.                 $this->loadTemplate($debug);
  1605.             }
  1606.         }
  1607.  
  1608.         if (!isset($GLOBALS['PROJECT']['HTML']['HEAD_PREPEND'])) $GLOBALS['PROJECT']['HTML']['HEAD_PREPEND']=""// <pk-06-07-26 /> E_ALL
  1609.         if (!isset($GLOBALS['PROJECT']['META']))                 $GLOBALS['PROJECT']['META']                =""// <pk-06-07-26 /> E_ALL
  1610.         if (!isset($GLOBALS['PROJECT']['HTML']['HEAD_APPEND']))  $GLOBALS['PROJECT']['HTML']['HEAD_APPEND'=""// <pk-06-07-26 /> E_ALL
  1611.  
  1612.         $str_header ="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n";
  1613.         $str_header.= "<html lang=\"de-at\">\n";
  1614.         $str_header.= "   <head>\n";
  1615.         $str_header.= "       <!-- GLOBAL HEAD_PREPEND -->\n".$GLOBALS['PROJECT']['HTML']['HEAD_PREPEND']."\n       <!-- END HEAD_PREPEND -->\n";
  1616.         $str_header.= "       <meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\">\n";
  1617.         $str_header.= "       <meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\">\n";
  1618.         $str_header.= "       <meta http-equiv=\"Content-Style-Type\" content=\"text/css\">\n";
  1619.         $str_header.= "       \n";
  1620.  
  1621.         $str_header.= pcf_get_htmlJsInclude($GLOBALS['OCSP']['JAVASCRIPTURL']."js_browser.js.phpinc");    // <pk-07-02-27 />
  1622.         $str_header.= pcf_get_htmlJsInclude($GLOBALS['OCSP']['JAVASCRIPTURL']."window.js.php");           // <pk-07-02-27 />
  1623.  
  1624.         $str_header.= $this->getHTMLTitle();
  1625.         $str_header.= $GLOBALS['PROJECT']['META']."\n\n";
  1626.  
  1627.         if ($withStyles{
  1628.             $str_header.= $this->getCSSHeaderTag($debug);
  1629.         }
  1630.         $str_header.= $this->getMetaHeaderTag();
  1631.         $str_header.= $this->getJavaHeaderTag();
  1632.         $str_header.="\n";
  1633.  
  1634.         $str_header.= "       <!-- GLOBAL HEAD_APPEND -->\n".$GLOBALS['PROJECT']['HTML']['HEAD_APPEND']."\n       <!-- END HEAD_APPEND -->\n";
  1635.         if ($withEndTag$str_header.= "   </head>\n\n";
  1636.  
  1637.         if ($debugecho "</blockquote>\n";
  1638.  
  1639.          if (_OCSP_USEPEARCACHE_ && is_object($obj_cache)) // <pk-07-05-31>
  1640.          {
  1641.             if ($debugechoDebug(__FILE__,"<p class=\"debug\">writing cache</p>");
  1642.             $str_cache.=$str_header."\n<!-- header comes from cache -->\n";
  1643.             $obj_cache->save($str_cache,"pageHeaders".$this->getCacheIdString(),$GLOBALS['OCSP_OBJ']['BROWSER']->getId());
  1644.          }
  1645.  
  1646.         return $str_header;
  1647.     }
  1648.  
  1649.  
  1650.  
  1651.     /**
  1652.       * returns the tag for a single chapter
  1653.       *
  1654.       * @param array $chapRow 
  1655.       * @param bool $chkShowVal 
  1656.       * @param boolean $debug 
  1657.       *
  1658.       * @returns $string
  1659.       * @access public
  1660.       *
  1661.       * @since pk-04-07-29
  1662.       * @version pk-05-10-10
  1663.       * @version pk-06-10-02 set MenId to the chapter
  1664.       * @version pk-07-06-01
  1665.       *
  1666.       ***/
  1667.     function getChapterTag($chapRow,$debug=False{
  1668.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getChapterTag()",nl2br(htmlspecialchars(print_r($chapRow))));
  1669.         if (!is_array($chapRow)) return "";
  1670.  
  1671.         $idx=$chapRow[$this->ctmplFldPrevix."ID"];
  1672.         if (!isset($this->chaTmplArr[$idx]|| !is_object($this->chaTmplArr[$idx])) {
  1673.             $this->loadChaTemplate($idx);
  1674.         }
  1675.         if (is_object($this->chaTmplArr[$idx])) {
  1676.             // <pk-05-10-10> <pk-06-09-28>
  1677.             if (!isset($chapRow['CHA_CLASS']|| empty($chapRow['CHA_CLASS']))
  1678.             {
  1679.                 $chapRow['CHA_CLASS']=$this->myChapterClass;
  1680.             }
  1681.  
  1682.             if (!class_exists($chapRow['CHA_CLASS'])) {
  1683.                 if (isset($GLOBALS['OCSP_CMS']['CHAPTERTYPE'][$chapRow['CHA_CLASS']]))
  1684.                 {
  1685.                     require_once $GLOBALS['OCSP_CMS']['CHAPTERTYPE'][$chapRow['CHA_CLASS']]['OBJINC'].$GLOBALS['OCSP_CMS']['CHAPTERTYPE'][$chapRow['CHA_CLASS']]['CLASS'].".phpclass";
  1686.                 else {
  1687.                     // use default
  1688.                     if ($debugechoDebug(__FILE__,"<p>Using default class CMS_CHAPTER_V2");
  1689.                     $chapRow['CHA_CLASS']='CMS_CHAPTER_V2';
  1690.                     require_once $GLOBALS['OCSP_CMS']['CHAPTERTYPE'][$chapRow['CHA_CLASS']]['OBJINC'].$GLOBALS['OCSP_CMS']['CHAPTERTYPE'][$chapRow['CHA_CLASS']]['CLASS'].".phpclass";
  1691.                 }
  1692.             }
  1693.             $s_cmd="\$o_chapter=new ".$chapRow['CHA_CLASS']."();";
  1694.             if ($debugecho "<p>ChapterCmd: ".$s_cmd."</p>";
  1695.             // </pk-06-09-28>
  1696.             eval ($s_cmd);
  1697.             // </pk-05-10-10>
  1698.             $o_chapter->setDBRow($chapRow);
  1699.             $o_chapter->setMenId($this->getMenId())// <pk-06-10-02 />
  1700.             $o_chapter->setTemplateObj($this->chaTmplArr[$idx]);
  1701.             return $o_chapter->getTag($this->getDBVal(),'$',False,$debug)// getTag($tmplVals=NULL,$tmplVarSign='$',$wysiwygPreView=False,$debug=False)
  1702.         else {
  1703.             if ($debugreturn "<p style=\"color:red\">NO TEMPLATE FOR ".$this->chapPrevix."ID ".$chapRow[$this->chapPrevix.'ID']."</p>";
  1704.             return "\n<!-- NO TEMPLATE FOR ".$this->chapPrevix."ID ".$chapRow[$this->chapPrevix.'ID']." -->\n";
  1705.         }
  1706.     }
  1707.  
  1708.  
  1709.  
  1710.     /**
  1711.      * returns the page feeter
  1712.      *
  1713.      * @param boolean $debug 
  1714.      * 
  1715.      * @return string (html)
  1716.      * 
  1717.      * @version pk-08-06-09
  1718.      */
  1719.     public function getFeeterTag($debug=False{
  1720.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getFeeterTag()");
  1721.         if (!isset($this->prevId)) {
  1722.             $this->prevId=$this->getPreviousPage($debug);
  1723.         }
  1724.         if (!isset($this->nextId)) {
  1725.             $this->nextId=$this->getNextPage($debug);
  1726.         }
  1727.  
  1728.         $str_ret "";
  1729.         
  1730.         $str_ret .=$this->getDBField($this->colPrevix."FEETER");
  1731.         $str_ret .= $this->myTemplate->getFeeterTag()."\n";
  1732.         if ($this->prevId$str_ret=str_replace("\$*PREVPAGE\$",$this->prevId,$str_ret);
  1733.         if ($this->nextId$str_ret=str_replace("\$*NEXTPAGE\$",$this->nextId,$str_ret);
  1734.         
  1735.         return $str_ret;
  1736.     }
  1737.  
  1738.     function getFeeter($debug=False{
  1739.         // old *inconsistent style*
  1740.         return $this->getFeeterTag($debug);
  1741.     }
  1742.  
  1743.  
  1744.     /**
  1745.       * executes a prepend script before the page output starts
  1746.       *
  1747.       * @abstract
  1748.       * @param boolean $debug 
  1749.       * @since pk-07-10-04
  1750.       */
  1751.     function execPrependCmds($debug=False)
  1752.     {
  1753.         if ($debugechoDebugMethod(__FILE__,get_class($this),"<i>abstract</i> CMS_PHPINC_PAGE::execPrependCmds()");
  1754.     }
  1755.  
  1756.  
  1757.     /**
  1758.       * echos the content of the page
  1759.       *
  1760.       * @param int $chaShowMode 
  1761.       * @param boolean $debug 
  1762.       *
  1763.       * @since pk-04-08-19
  1764.       * @version pk-05-11-10 debug infos
  1765.       ***/
  1766.     function content($chaShowMode=0,$debug=False{
  1767.         if ($debugechoDebugMethod(__FILE__,get_class($this),"<p>CMS_PAGE_V2::content($chaShowMode)");
  1768.         echo $this->getContent($chaShowMode,$debug);
  1769.  
  1770. /*
  1771.         if ($chaShowMode==0) echo $this->getHeadlineTag($debug);
  1772.         echo $this->getChapter($chaShowMode,$debug);
  1773.         if ($chaShowMode==0) echo $this->getFeeterTag($debug);
  1774. */
  1775.     }
  1776.  
  1777.  
  1778.     function view($chaShowMode=0,$debug=False{
  1779.  
  1780.         echo $this->getHead(False,$debug);
  1781.         echo $this->myTemplate->getBodyTag($debug);
  1782.         echo $this->getHeadlineTag($debug);
  1783.         $this->content($chaShowMode,$debug);
  1784.         echo $this->getFeeterTag($debug);
  1785.         $this->writeClosePage();
  1786.     }
  1787.  
  1788.     /**
  1789.       * returns the css tag to echo in the header
  1790.       *
  1791.       * @param boolean $debug 
  1792.       * @param boolean $asTemplate do not parse the return value with $this->getDBVal();
  1793.       *
  1794.       * @returns string
  1795.       *
  1796.       * @since pk-04-08-02
  1797.       * @version pk-04-11-18
  1798.       * @version pk-05-06-29 PROJ_ID added to style
  1799.       * @version pk-05-09-01
  1800.       * @version pk-05-12-13
  1801.       * @version pk-06-01-04
  1802.       * @version pk-06-07-19 write styles directly to the file
  1803.       *
  1804.       * @var string $s_ret 
  1805.       ***/
  1806.     function getCSSHeaderTag($debug=False,$asTemplate=False{
  1807.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::getCSSHeaderTag()");
  1808.         $s_ret"<!-- \n________CMS_PAGE_V2::getCSSHeaderTag________\n-->\n";
  1809.  
  1810.         if (!is_object($this->myTemplate)) $this->loadTemplate($debug,True)// ensure we have a template
  1811.  
  1812.         if (is_object($this->myProjObj)) // <pk-06-07-19>
  1813.             $s_ret.=$this->myProjObj->getCSS_definition("",False,False,$debug);
  1814.             $s_ret.=$this->myTemplate->getCSSTag(False,$debug);
  1815.         else {  // old version
  1816.             $s_ret.= "   <link type=\"text/css\" rel=\"stylesheet\" href=\"/cms/defaultStyles.php\">\n\n";
  1817.             $s_ret.= "   <link type=\"text/css\" rel=\"stylesheet\" href=\"/cms/defaultStyles.php?".$this->myProjIdCol."=".$this->getProjId()."\">\n";
  1818.             if ($o_proj=$this->getMyProject()) {
  1819.                 $s_ret.=$o_proj->getDBField("PROJ_CSSINCLUDE");
  1820.             }
  1821.             $s_tmplCss pcf_tmpl_parse($this->myTemplate->getCSSTag(),$this->getDBVal(),$debug);
  1822.             $s_ret.= "\n\t<!-- template styles -->\n";
  1823.             $s_ret.= $s_tmplCss."\n";
  1824.         }
  1825.  
  1826.         if (intval($this->getDBField('STY_ID'))) {
  1827.             require_once $GLOBALS['CMS']['PHPINCPATH']."css/CMS_CSSSTYLE.phpclass";
  1828.  
  1829.             $s_query="SELECT * FROM T_CMS_CSSSTYLES WHERE STY_ID=".intval($this->getDBField('STY_ID'));
  1830.             if ($a_sty=$this->myDBObj->quickQuery($s_query)) {
  1831.                 $s_ret.="<style type=\"text/css\">\n<!--\n";
  1832.                 $s_ret.="\n/* STYLE: ".$a_sty['STY_NAME']." PROJECT: ".$a_sty['PROJ_ID']." */\n";
  1833.  
  1834.                 $o_style=new CMS_CSSSTYLE();
  1835.                 $o_style->setDBRow($a_sty);
  1836.                 $s_ret.=$o_style->getCSSCode($media,-1,$debug);
  1837.  
  1838.                 $s_ret.="-->\n</style>\n";
  1839.                 if (!empty($a_sty['STY_JAVACODE'])) {
  1840.                     $s_ret.="<!-- __STY_JAVACODE__START__ -->\n";
  1841.                     $s_ret.="<script language=\"javascript\" type=\"text/javascript\">\n<!--\n";
  1842.                     $s_ret.=$a_sty['STY_JAVACODE'];
  1843.                     $s_ret.="\n//-->\n</script>\n";
  1844.                     $s_ret.="<!-- __STY_JAVACODE__END__ -->\n";
  1845.                 }
  1846.  
  1847.             // if ($a_sty=$this->myDBObj->quickQuery($s_query))
  1848.         // if (intval($this->getDBField('STY_ID')))
  1849.  
  1850.         $s_ret.= "\n<!-- _________________________________________________________ -->\n";
  1851.         $s_ret.= "<!--                      page styles done                     -->\n";
  1852.  
  1853.         if ($asTemplate{
  1854.             return $s_ret;
  1855.         else {
  1856.             require_once __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";
  1857.             return pcf_tmpl_parse($s_ret,$this->getDBVal(),$debug);
  1858.         }
  1859.  
  1860.         return $s_ret;
  1861.     }
  1862.  
  1863.     /**
  1864.       * returns the meta tag
  1865.       *
  1866.       * @returns string
  1867.       *
  1868.       * @since pk-04-08-02
  1869.       * @version pk-06-05-24
  1870.       *
  1871.       ***/
  1872.     function getMetaHeaderTag({
  1873.         if (!is_object($this->myTemplate)) {
  1874.             if (!($this->loadTemplate($debug))) {
  1875.                 return "";
  1876.             }
  1877.         }
  1878.         //$s_metaTag = $this->myTemplate->getMetaTag();
  1879.  
  1880.         $this->getMyProject()// to ensure $this->myProjObj is set
  1881.  
  1882.         $i_projMetaMethod=intval($this->myProjObj->getDBField('PROJ_META_DESCMETHOD'));
  1883.         switch($i_projMetaMethod{
  1884.             case 1// prepend
  1885.                 $s_pMetaDesc=$this->myProjObj->getDBField('PROJ_META_DESC')." ".$this->getDBField('METADESCRIPTION');
  1886.                 break;
  1887.             case 2// append
  1888.                 $s_pMetaDesc=$this->getDBField('METADESCRIPTION')." ".$this->myProjObj->getDBField('PROJ_META_DESC');
  1889.                 break;
  1890.             default:
  1891.                 $s_tmp=trim($this->getDBField('METADESCRIPTION'));
  1892.                 if (empty($s_tmp)) {
  1893.                     $s_pMetaDesc=$this->myProjObj->getDBField('PROJ_META_DESC');
  1894.                 else {
  1895.                     $s_pMetaDesc=$this->getDBField('METADESCRIPTION');
  1896.                 }
  1897.         }
  1898.  
  1899.         if (!empty($s_pMetaDesc)) {
  1900.             $s_metaTag.= "\t<meta name=\"description\" content=\"".str_replace("\"","''",trim($s_pMetaDesc))."\">";
  1901.         }
  1902.  
  1903.         $s_pMetaKeys=trim($this->PAG_OBJECTVARS['METAKEYWORDS']." ".$this->myProjObj->getDBField('PROJ_META_KEYS'));
  1904.         if (!empty($s_pMetaKeys)) {
  1905.             $s_metaTag.= "\t<meta name=\"keywords\" content=\"".str_replace("\"","''",$s_pMetaKeys)."\">";
  1906.         }
  1907.         return $s_metaTag;
  1908.     }
  1909.  
  1910.     /**
  1911.       * returns the java tag
  1912.       *
  1913.       * @param boolean $debug 
  1914.       *
  1915.       * @returns string
  1916.       *
  1917.       * @since pk-04-08-02
  1918.       * @version pk-04-09-08 param debug added
  1919.       *
  1920.       ***/
  1921.     function getJavaHeaderTag($debug=False{
  1922.         $s_tag="";
  1923.         if (!is_object($this->myTemplate)) {
  1924.             if (!($this->loadTemplate($debug))) {
  1925.                 return "";
  1926.             }
  1927.         }
  1928.  
  1929.         // $tag = "<script language=\"JavaScript\" src=\"".$GLOBALS['PROJECT']['JAVASCRIPTURL']."window.js\" type=\"text/javascript\"></script>\n";
  1930.         $s_tag.= $this->myTemplate->getJavaScriptTag();
  1931.         return pcf_tmpl_parse($s_tag,$this->getDBVal(),$debug);
  1932.     }
  1933.  
  1934.     /**
  1935.       * returns the html-title tag
  1936.       *
  1937.       * @returns string
  1938.       *
  1939.       * @since pk-04-08-04
  1940.       * @version pk-05-12-13 "\t" added
  1941.       ***/
  1942.     function getHTMLTitle({
  1943.         return "\t<title>".$this->getTitle()."</title>\n";
  1944.     }
  1945.  
  1946.  
  1947.  
  1948.  
  1949.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1950.     // navigation
  1951.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1952.  
  1953.     /**
  1954.       * returns a HTML Redirector
  1955.       *
  1956.       * @param string $destUrl 
  1957.       * @param string $destFrame 
  1958.       * @param boolean $debug 
  1959.       *
  1960.       * @returns string
  1961.       *
  1962.       * @since pk-05-09-06
  1963.       * @version pk-05-10-07 bugfix
  1964.       ***/
  1965.     function getHTMLRedirect($destUrl,$destFrame="_self",$debug{
  1966.         if ($debugecho "<p><b>CMS_PAGE_V2::getHTMLRedirect($destUrl,$destFrame)</b> (".get_class($this).")</p>"// <pk-05-10-07 />
  1967.  
  1968.         $ret="<script language=\"javascript\" type=\"text/javascript\">\n";
  1969.  
  1970.         if (!$debug{
  1971.             switch($destFrame{
  1972.                 case "_self":
  1973.                     $ret.="\tdocument.location.href=\"".$destUrl."\";\n";
  1974.                     break;
  1975.                 case "_parent":
  1976.                     $ret.="\tparent.location.href=\"".$destUrl."\";\n";
  1977.                     break;
  1978.                 case "_top":
  1979.                     $ret.="\ttop.location.href=\"".$destUrl."\";\n";
  1980.                     break;
  1981.                 default:
  1982.                     $ret.="\tvar myWnd = window.open(\"".$destUrl."\",\"".$destFrame."\");\n";
  1983.                     $ret.="\tmyWnd.focus();\n";
  1984.             }
  1985.         }
  1986.  
  1987.         $ret.="</script>";
  1988.         $ret.="<a href=\"".$destUrl."\" target=\"".$destFrame."\">Weiter</a>";
  1989.         return $ret;
  1990.  
  1991.  
  1992.     }
  1993.  
  1994.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1995.     // Cache Methods
  1996.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1997.  
  1998.  
  1999.     /**
  2000.       * writes the page values to the pear cache
  2001.       *
  2002.       * @param boolean $debug 
  2003.       *
  2004.       * @since pk-07-08-14
  2005.       */
  2006.     function cacheValues($debug=False)
  2007.     {
  2008.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_V2::cacheValues()");
  2009.         if ($this->isPopulated(&& $this->cmsCacheIsUsable())
  2010.         {
  2011.             $this->myCmsCache->setPageData($this,$debug);
  2012.         else if ($debug{
  2013.             echoDebugLine(__FILE__,__LINE__,"object not cached because: ".($this->isPopulated("caching disabled" "object not populated"));
  2014.         }
  2015.  
  2016.     }
  2017.  
  2018. }
  2019. ?>

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