Source for file CMS_PAGE_TEMPLATE.phpclass

Documentation is available at CMS_PAGE_TEMPLATE.phpclass

  1. <?php
  2. /**
  3.   * Class file CMS_PAGE_TEMPLATE.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    cms
  7.   * @categorie  templates
  8.   *
  9.   * @author     Peter Krebs <p.krebs@wpus.at>
  10.   * @copyright  (c) 2002-2004 by Peter Krebs and Landesverlag Unternehmensservice
  11.   * @copyright  (c) 2005-2006 by WURM & Partner Unternehmensservice
  12.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  13.   *
  14.   * @verision   pk-03-10-13
  15.   * @verision   pk-06-01-02
  16.   *
  17.   ***/
  18.  
  19.     pcf_require_interface('INFA_CMS_PAGE_TEMPLATE',dirname(__FILE__"/INFA_CMS_PAGE_TEMPLATE.phpclass");
  20.  
  21.     pcf_require_class('CMS_TABLEOBJ',"cms/");
  22.     pcf_require_class('CMS_PROJECT',"cms/");
  23.     pcf_require_class('TMPL_CHAPTER',"cms/template/chapter/");
  24.  
  25.  
  26. /**
  27.   * handels Page templates
  28.   *
  29.   * @project    Open CSP-Management
  30.   * @package    cms
  31.   *
  32.   * @author     Peter Krebs <pitlinz@users.sourceforge.net>
  33.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  34.   *
  35.   * @verision   pk-03-10-13
  36.   * @version $Id: CMS_PAGE_TEMPLATE.phpclass,v 1.14 2008/12/16 17:40:40 peterkrebs Exp $
  37.   */
  38. class CMS_PAGE_TEMPLATE extends CMS_TABLEOBJ implements INFA_CMS_PAGE_TEMPLATE 
  39. {
  40.     
  41.     // ---------------------------------------------------------------------------
  42.     // constants
  43.     // ---------------------------------------------------------------------------
  44.     
  45.     /**
  46.      * @constant string CLASS_SRC_FILE
  47.      *
  48.      * @abstract
  49.      */
  50.     const CLASS_SRC_FILE = __FILE__;
  51.     
  52.     // ---------------------------------------------------------------------------
  53.     // class (static)
  54.     // ---------------------------------------------------------------------------
  55.     
  56.     /*** class vars ------------------------------------------------------ */
  57.     
  58.     /**
  59.      * @staticvar array $loadedTemplates 
  60.      */
  61.     static protected $loadedTemplates = array();
  62.     
  63.     /*** class methods --------------------------------------------------- */
  64.     
  65.     /**
  66.      * returns an unit of work instance
  67.      *
  68.      * @param int $aId 
  69.      * @param boolean $debug 
  70.      * 
  71.      * @return CMS_PAGE_TEMPLATE 
  72.      */
  73.     static public function &getInstance($aId,$debug=False)
  74.     {
  75.         if ($debugechoDebugMethod(__FILE__,"static","CMS_PAGE_TEMPLATE::getInstance({$aId})");
  76.         
  77.         $aId intval($aId);
  78.         
  79.         if (isset(self::$loadedTemplates[$aId]&& is_object(self::$loadedTemplates[$aId]))
  80.         {
  81.             return self::$loadedTemplates[$aId];
  82.         }
  83.         
  84.         if (!intval($aId))
  85.         {
  86.             // return the default template ID: 0;
  87.             self::$loadedTemplates[0new CMS_PAGE_TEMPLATE();
  88.             return self::$loadedTemplates[0]
  89.         }
  90.         
  91.         try {
  92.             self::$loadedTemplates[$aIdself::factoryFromId($aId,$debug);
  93.             return self::$loadedTemplates[$aId];
  94.         catch(Exception $e{
  95.             if ($debugechoDebugLine(__FILE__,__LINE__,"Exception: " $e->getMessage(" fired");
  96.         }
  97.     }
  98.     
  99.     // ---------------------------------------------------------------------------
  100.     // object vars
  101.     // ---------------------------------------------------------------------------
  102.     
  103.     /*** compostion --------------------------------------------------- */
  104.     
  105.     
  106.     /**
  107.       * @staticvar string $type OBJECT TYPE
  108.       ***/
  109.     var $type       = "PAGE";
  110.     
  111.     /**
  112.       * @staticvar string $myTable name of the db table
  113.       ***/
  114.     var $myTable="T_CMS_TMPL_PAGE";
  115.  
  116.     /**
  117.       * @staticvar myColPrevix 
  118.       * @since pk-05-01-30
  119.       ***/
  120.     var $myColPrevix="PTMP";
  121.     
  122.     /**
  123.       * @var string $myClassSrcFile class source file
  124.       * @since pk-05-01-31
  125.       ***/
  126.     var $myClassSrcFile      = __FILE__;
  127.  
  128.     /**
  129.       *
  130.       * METHODS _____________________________________________
  131.       *
  132.       */
  133.  
  134.     /** -----------------------------------------------------
  135.       * Constructors
  136.       */
  137.     
  138.     /**
  139.       * init the object and populates the object if aId
  140.       *
  141.       * @param int      $aId id of an existing template
  142.       * @param string   $name 
  143.       * @param int      $projId 
  144.       * @param string   $gDBIDX   GLOBALS database Object index
  145.       * @param bool     $debug 
  146.       *
  147.       ***/
  148.     function CMS_PAGE_TEMPLATE($id=0,$name="",$projId=0,$debug=FALSE{
  149.         $this->init($debug);
  150.         
  151.         if (intval($id0{
  152.             $this->setId($id);
  153.             $this->dbPopulate($debug);
  154.         else {
  155.             $this->setProjId(intval($projId));
  156.             $this->setDBField($this->myColPrevix.'_NAME',$name);
  157.         }
  158.     }
  159.  
  160.     /**
  161.      * factory method for a template by PTMP_ID
  162.      *
  163.      * @param int $aId 
  164.      * @param boolean $debug 
  165.      * 
  166.      * @return CMS_PAGE_TEMPLATE 
  167.      * 
  168.      * @since pk-08-01-15
  169.      * 
  170.      */
  171.     static public function CMS_PAGE_TEMPLATE_FROM_ID($aId{
  172.         return self::factoryFromId($aId);
  173.     }
  174.     
  175.     /**
  176.      * factories a page template from an id
  177.      *
  178.      * @param int $aId 
  179.      * @param boolean $debug 
  180.      * 
  181.      * @return CMS_PAGE_TEMPLATE 
  182.      */
  183.     public static function factoryFromId($aId,$debug=False)
  184.     {
  185.         if ($debugechoDebugMethod(__FILE__,"static","CMS_PAGE_TEMPLATE::factoryFromId({$aId})");
  186.         
  187.         $arr_filter array('PTMP_ID' => intval($aId));
  188.         if ($obj_row OCSP_OBJ::defaultReadDBObj()->getRow('T_CMS_TMPL_PAGE',$arr_filter))
  189.         {
  190.             return self::factoryFromRow($obj_row,$debug);
  191.         }        
  192.         
  193.         return Null;
  194.         
  195.         /*
  196.         pcf_require_class('OCSP_CACHE_APC',__OCSP_PHPINCPATH__ . "cache/OCSP_CACHE_APC.phpclass");
  197.         pcf_require_class('OCSP_CACHE_FILE',__OCSP_PHPINCPATH__ . "cache/OCSP_CACHE_FILE.phpclass");
  198.                 
  199.         $bol_addToAPC      = False;
  200.         $bol_useAPC      = OCSP_CONF::getInstance('OCSP')->getValue('USECMSAPC');
  201.         
  202.         $bol_addToFCache = False;
  203.         $bol_loaded         = False;
  204.                 
  205.         if ($bol_useAPC && OCSP_CACHE_APC::isUseable())
  206.         {
  207.             if ($arr_row=OCSP_CACHE_APC::getInstance('CMSTEMPLROW')->getValue($aId))
  208.             {
  209.                 if ($debug) echoDebugLine(__FILE__,__LINE__,"<h1>OCSP_CACHE_APC </h1><pre>" . print_r($arr_row,True) . "<pre>");                
  210.                 $bol_loaded=True;
  211.             } else {
  212.                 $bol_addToAPC=True;
  213.             }        
  214.         }    
  215.  
  216.         if (!$bol_loaded && OCSP_CACHE_FILE::isUseable())
  217.         {
  218.             if ($arr_row=OCSP_CACHE_FILE::getInstance('CMSTEMPLROW')->getValue($aId))
  219.             {
  220.                 if ($debug) echoDebugLine(__FILE__,__LINE__,"<h1>OCSP_CACHE_FILE</h1><pre>" . print_r($arr_row,True) . "<pre>");                
  221.                 $bol_loaded=True;
  222.             } else {
  223.                 $bol_addToFCache=True;
  224.             }            
  225.         }
  226.         
  227.         if (!$bol_loaded)
  228.         {        
  229.             if (!($arr_row = OCSP_OBJ::defaultReadDBObj()->getRow('T_CMS_TMPL_PAGE',array('PTMP_ID' => $aId),$debug)))
  230.             {
  231.                 throw new Exception(_OCSP_EXCEP_NODATA_.":T_CMS_TMPL_PAGE.PTMP_ID=" . $aId);
  232.             }
  233.         }
  234.         
  235.         if (!isset($arr_row['PTMP_OBJCLASS']) || empty($arr_row['PTMP_OBJCLASS']))
  236.         {
  237.             $arr_row['PTMP_OBJCLASS'] = 'CMS_PAGE_TEMPLATE';
  238.         } else {
  239.             if (!CMS_TABLEOBJ::pageTmplType_requireClass($arr_row['PTMP_OBJCLASS']))
  240.             {
  241.                 throw new Exception(_OCSP_EXCEP_CLASSNOTFOUND_ . ":" . $arr_row['PTMP_OBJCLASS']);        
  242.             }
  243.         }
  244.         
  245.         $obj_tmpl = new $arr_row['PTMP_OBJCLASS']();
  246.         $obj_tmpl->setDBRow($arr_row,True);
  247.         
  248.         if ($bol_addToFCache)                 OCSP_CACHE_FILE::getInstance('CMSTEMPLROW')->setValue($aId,$obj_tmpl->getDBRow());
  249.         if ($bol_useAPC && $bol_addToAPC)    OCSP_CACHE_APC::getInstance('CMSTEMPLROW')->setValue($aId,$obj_tmpl->getDBRow());
  250.         
  251.         */
  252.  
  253.         return $obj_tmpl;        
  254.     }
  255.     
  256.    /**
  257.      * factories a page template from an id
  258.      *
  259.      * @param int $aId 
  260.      * @param boolean $debug 
  261.      * 
  262.      * @return CMS_PAGE_TEMPLATE 
  263.      * 
  264.      * @since pk-08-10-16
  265.      */
  266.     public static function factoryFromRow($aRow,$debug=False)
  267.     {  
  268.         if (!isset($aRow['PTMP_OBJCLASS']|| empty($aRow['PTMP_OBJCLASS']))
  269.         {
  270.             $aRow['PTMP_OBJCLASS''CMS_PAGE_TEMPLATE';
  271.         else {
  272.             if (!CMS_TABLEOBJ::pageTmplType_requireClass($aRow['PTMP_OBJCLASS']))
  273.             {
  274.                 throw new Exception(_OCSP_EXCEP_CLASSNOTFOUND_ ":" $aRow['PTMP_OBJCLASS']);        
  275.             }
  276.         }
  277.         
  278.         $obj_tmpl new $aRow['PTMP_OBJCLASS']();
  279.         $obj_tmpl->setDBRow($aRow,True)
  280.  
  281.         return $obj_tmpl;
  282.     
  283.     
  284.     /**
  285.       * returns the object type
  286.       *
  287.       * @return int 
  288.       *
  289.       ***/
  290.     function getType({
  291.         return $this->type;
  292.     }
  293.  
  294.     /**
  295.       * @return int 
  296.       ***/
  297.     function getId({
  298.         return intval($this->getDBField($this->myColPrevix . '_ID'));
  299.     }
  300.  
  301.     /**
  302.      * returns the name of the template
  303.      *
  304.      * @return string 
  305.      */
  306.     function getName()
  307.     {
  308.         $str_ret $this->getDBField('PTMP_NAME');
  309.         if (empty($str_ret))
  310.         {
  311.             return "PTMP_ID: " $this->getId();
  312.         else {
  313.             return $str_ret;
  314.         
  315.     }
  316.     
  317.     /**
  318.       * set the id
  319.       *
  320.       * @param int $aId 
  321.       *
  322.       * @since pk-06-01-02
  323.       *
  324.       ***/
  325.     function setId($aId{
  326.         $this->setDBField($this->myColPrevix.'_ID',intval($aId));
  327.     }
  328.  
  329.  
  330.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  331.     // DB OPERATIONS
  332.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  333.  
  334.     /**
  335.       * saves the template and ensures that there is only one default template per project
  336.       *
  337.       * @param string $gDBIDX 
  338.       * @param boolean $debug 
  339.       *
  340.       * @returns mixed
  341.       *
  342.       * @since pk-05-07-22
  343.       *
  344.       * @var mixed $ret 
  345.       * @var string $s_Cmd 
  346.       *
  347.       ***/
  348.     function dbSave($debug=FALSE{
  349.         if ($debugecho "<p><b>CMS_PAGE_TEMPLATE::dbSave(...)</b> (".get_class($this).")</p><blockquote>";
  350.  
  351.         $this->PTMP_LASTCHANGE=NULL;
  352.         $this->PTMP_OWNER=OCSP_OBJ::currentUser(True)->getId();
  353.  
  354.         if ($ret=parent::dbSave($debug)) {
  355.             if (intval($this->{$this->myColPrevix."_ISDEFAULT"})) // make sure we do not have another default template
  356.                 $s_Cmd ="UPDATE ".$this->myTable;
  357.                 $s_Cmd.="   SET ".$this->myColPrevix."_ISDEFAULT = 0";
  358.                 $s_Cmd.=" WHERE ".$this->myProjIdCol."=".$this->getProjId();
  359.                 $s_Cmd.="   AND ".$this->myColPrevix."_ID <> ".$this->getId();
  360.                 if ($debugecho "<p>ISDEFAULT CMD:<br />".$s_Cmd."</p>";
  361.                 $this->getDBObj('w')->executeCmd($s_Cmd);
  362.             }
  363.         }
  364.         if ($debugecho "</blockquote>";
  365.         return $ret;
  366.     }
  367.  
  368.  
  369.     /**
  370.       * deletes the template with all chapter templates from the database
  371.       *
  372.       * NOTE: foreign tables are hardcoded here
  373.       *
  374.       * @param string $gDBIDX 
  375.       * @param boolean $backupData 
  376.       * @param boolean $debug 
  377.       *
  378.       * @returns boolean
  379.       *
  380.       * @since pk-04-12-30
  381.       * @version pk-06-10-25
  382.       *
  383.       ***/
  384.     function dbDelete($backupData=FALSE,$debug=FALSE{
  385.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_TEMPLATE::dbDelete()");
  386.  
  387.         $cmd="DELETE FROM T_CMS_TMPL_CHAPTER WHERE PTMP_ID="$this->getId();
  388.         if ($debugechoDebugLine(__FILE__,__LINE__,"<p>CMD$cmd</p>");
  389.         $this->getDBObj('w')->executeCmd($cmd);
  390.  
  391.         $cmd ="DELETE FROM ".$this->myTable.$this->getWhere($debug);
  392.         if ($debugechoDebugLine(__FILE__,__LINE__,"<p>CMD$cmd</p></blockquote>");
  393.         return $this->getDBObj('w')->executeCmd($cmd);
  394.     }
  395.             
  396.     
  397.     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  398.     /* form methods                                                                                         */
  399.     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  400.  
  401.     /**
  402.       * returns a array of variables used by the page object
  403.       *
  404.       * array[varName]=array(
  405.       *     [TYPE]          datatype
  406.       *     [FLDCLASS]      name of DBMS_FIELD* class
  407.       *     [CLASSVALS]     array of values of [FLDCLASS]
  408.       *
  409.       *
  410.       *
  411.       * @returns array
  412.       *
  413.       * @since pk-05-01-30
  414.       *
  415.       ***/
  416.     function getObjVarDef({
  417.         require_once $GLOBALS['OCSP']['DBMSFLD_PATH']."DBMS_FIELD_TEXTAREA.phpclass";
  418.         $retArr=array(
  419.             "META"=>array(
  420.                 "TYPE"      =>"blob",
  421.                 "FLDCLASS"  => "DBMS_FIELD_TEXTAREA",
  422.                 "CLASSVALS" =>array(
  423.                     "label"         => "Meta Keywords",
  424.                     "nlToBr"        => FALSE,
  425.                     "wrap"          => "off",
  426.                     "rows"          => 4,
  427.                     "allowNull"     => TRUE,
  428.                     "isSearchable"  => FALSE,
  429.                     "showInList"    => FALSE,
  430.                     "toolTip"       => "Meta Keywords f&uuml; Suchmaschinen"
  431.                 )
  432.             ),
  433.             "CSS"=>array(
  434.                 "TYPE"      =>"blob",
  435.                 "FLDCLASS"  => "DBMS_FIELD_TEXTAREA",
  436.                 "CLASSVALS" =>array(
  437.                     "label"         => "CSS Header",
  438.                     "nlToBr"        => FALSE,
  439.                     "wrap"          => "off",
  440.                     "rows"          => 4,
  441.                     "allowNull"     => TRUE,
  442.                     "isSearchable"  => FALSE,
  443.                     "showInList"    => FALSE
  444.                 )
  445.             ),
  446.             "JAVASCRIPT"=>array(
  447.                 "TYPE"      =>"blob",
  448.                 "FLDCLASS"  => "DBMS_FIELD_TEXTAREA",
  449.                 "CLASSVALS" =>array(
  450.                     "label"         => "JavaScript Header",
  451.                     "nlToBr"        => FALSE,
  452.                     "wrap"          => "off",
  453.                     "rows"          => 4,
  454.                     "allowNull"     => TRUE,
  455.                     "isSearchable"  => FALSE,
  456.                     "showInList"    => FALSE
  457.                 )
  458.             ),
  459.             "BODY"=>array(
  460.                 "TYPE"      =>"blob",
  461.                 "FLDCLASS"  => "DBMS_FIELD_TEXTAREA",
  462.                 "CLASSVALS" =>array(
  463.                     "label"         => "BODY Tag",
  464.                     "nlToBr"        => FALSE,
  465.                     "wrap"          => "off",
  466.                     "rows"          => 2,
  467.                     "allowNull"     => TRUE,
  468.                     "isSearchable"  => FALSE,
  469.                     "showInList"    => FALSE
  470.                 )
  471.             ),
  472.             "HEADLINE"=>array(
  473.                 "TYPE"      =>"blob",
  474.                 "FLDCLASS"  => "DBMS_FIELD_TEXTAREA",
  475.                 "CLASSVALS" =>array(
  476.                     "label"         => "Headline Template",
  477.                     "nlToBr"        => FALSE,
  478.                     "wrap"          => "off",
  479.                     "rows"          => 5,
  480.                     "allowNull"     => TRUE,
  481.                     "isSearchable"  => FALSE,
  482.                     "showInList"    => FALSE,
  483.                     "toolTip"       => "Wird auf jeder Seite eingf&uuml;gt."
  484.                 )
  485.             ),
  486.             "FEETER"=>array(
  487.                 "TYPE"      =>"blob",
  488.                 "FLDCLASS"  => "DBMS_FIELD_TEXTAREA",
  489.                 "CLASSVALS" =>array(
  490.                     "label"         => "Fu&szlig;zeilen Template",
  491.                     "nlToBr"        => FALSE,
  492.                     "wrap"          => "off",
  493.                     "rows"          => 5,
  494.                     "allowNull"     => TRUE,
  495.                     "isSearchable"  => FALSE,
  496.                     "showInList"    => FALSE,
  497.                     "toolTip"       => "Wird auf jeder Seite eingf&uuml;gt."
  498.                 )
  499.             )
  500.         );
  501.         return $retArr;
  502.     }
  503.  
  504.  
  505.  
  506.     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  507.     /* data array methods                                                                                   */
  508.     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  509.  
  510.     /**
  511.       * returns an array of db default values
  512.       *
  513.       * @param bool     $debug 
  514.       *
  515.       * @returns array
  516.       *
  517.       * @since pk-04-08-12
  518.       *
  519.       ***/
  520.     function getDefaults($debug=FALSE{
  521.         if ($debugecho "<p><b>CMS_PAGE_TEMPLATE::getDefaults($debug)</b> (".get_class($this).")</p>";
  522.         $ret=parent::getDefaults();
  523.         $ret['PTMP_TYPE']="CMS_PAGE_TEMPLATE";
  524.  
  525.         return $ret;
  526.     }
  527.  
  528.     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  529.     /* checks & rights                                                                      */
  530.     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  531.  
  532.     /**
  533.       * returns if the template or a chapter template is in use
  534.       *
  535.       * @param boolean $onlyOnline check only pages and chapters with online states
  536.       * @param boolean $debug 
  537.       *
  538.       * @return boolean 
  539.       *
  540.       * @since pk-06-10-25
  541.       *
  542.       ***/
  543.     function isInUse($onlyOnline=TRUE,$debug=FALSE{
  544.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_TEMPLATE::isInUse()");
  545.  
  546.         $s_query="SELECT CTMP_ID FROM T_CMS_TMPL_CHAPTER WHERE PTMP_ID=".$this->getId();
  547.         $a_ctmpIds=$this->getDBObj()->queryArray($s_query);
  548.  
  549.         $s_query ="SELECT COUNT(*) FROM T_CMS_PAGE LEFT OUTER JOIN T_CMS_CHAPTER USING (PAG_ID)";
  550.         $s_query.=" WHERE (PTMP_ID=".$this->getId();
  551.         if (is_array($a_ctmpIds))
  552.         {
  553.             $str_query .= " OR CTMP_ID IN (".implode(',',$a_ctmpIds)."))";
  554.         }
  555.  
  556.         if ($onlyOnline{
  557.             $a_pStates=array();
  558.             foreach($GLOBALS['OCSP_CMS']['PAGESTATE'as $i_id => $a_state{
  559.                 if (($a_state['SHOW']|| ($a_state['DIRECTSHOW'])) {
  560.                     $a_pStates[]=$i_id;
  561.                 }
  562.             }
  563.             $s_query.=" AND PAG_STATE IN (".implode(',',$a_pStates).")";
  564.         }
  565.  
  566.         if ($debugecho "<p>$s_query</p>";
  567.  
  568.         return (intval($this->getDBObj()->quickQuery($s_query,0)));
  569.     }
  570.     
  571.     /**
  572.      * returns if the current user can open the template
  573.      * 
  574.      * @param boolean $debug 
  575.      * 
  576.      * @return boolean 
  577.      */
  578.     public function curUserCanShow($debug=False)
  579.     {
  580.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_TEMPLATE::curUserCanShow()");
  581.  
  582.         if ($obj_proj CMS_PROJECT::getInstance($int_projId,True))
  583.         {
  584.             return $obj_proj->curUserIsAuthor($debug);
  585.         }
  586.  
  587.         return False;        
  588.     }
  589.  
  590.     /**
  591.      * returns if the current user can edit the template
  592.      * 
  593.      * @param boolean $debug 
  594.      * 
  595.      * @return boolean 
  596.      * 
  597.      * @since pk-08-12-04
  598.      */
  599.     public function curUserCanEdit($debug=False)
  600.     {
  601.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_TEMPLATE::curUserCanEdit()");
  602.  
  603.         if ($obj_proj CMS_PROJECT::getInstance($int_projId,True))
  604.         {
  605.             return $obj_proj->curUserIsEditor();
  606.         }
  607.  
  608.         return False;
  609.             
  610.     }
  611.     
  612.  
  613.     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  614.     /* chapter templates                                                                    */
  615.     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  616.  
  617.     /**
  618.       * copies all chapter templates from $ptmpId
  619.       *
  620.       * @param int $ptmpId 
  621.       * @param boolean $debug 
  622.       *
  623.       * @since pk-06-01-02
  624.       *
  625.       ***/
  626.     function copyChapterFrom($ptmpId,$debug=FALSE{
  627.         if ($debugechoDebug(__FILE__,"<p><b>CMS_PAGE_TEMPLATE::copyChapterFrom($ptmpId)</b> (".get_class($this).")</p>",0);
  628.         if (intval($ptmpId)) {
  629.             $s_query ="SELECT * FROM T_CMS_TMPL_CHAPTER";
  630.             $s_query.=" WHERE PTMP_ID=".intval($ptmpId);
  631.             if ($debugechoDebug(__FILE__,"<blockquote>$s_query</blockquote>",1);
  632.             if ($o_cursor=$this->getDBObj('r')->query($s_query)) {
  633.                 while($a_chap=$o_cursor->fetchArrayFld()) {
  634.                     unset($a_chap['CTMP_ID']);
  635.                     $a_chap['PTMP_ID']=$this->getId();
  636.                     if (intval($a_chap['PROJ_ID'])) {
  637.                         $a_chap['PROJ_ID']=$this->getProjId();
  638.                     }
  639.                     $this->getDBObj('w')->insertArray("T_CMS_TMPL_CHAPTER",$a_chap,$debug);
  640.                 }
  641.             }
  642.         }
  643.     }
  644.     
  645.     /**
  646.      * returns a chapter template object
  647.      *
  648.      * @param int $ctmpId 
  649.      * @param boolean $debug 
  650.      * 
  651.      * @return TMPL_CHAPTER 
  652.      */
  653.     function &getChapterTemplate($ctmpId,$debug=False)
  654.     {
  655.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_TEMPLATE::getChapterTemplate({$ctmpId})");
  656.         
  657.         $obj_tmpl TMPL_CHAPTER::getInstance($ctmpId,$debug);
  658.         $obj_tmpl->setPageTemplate($this);
  659.         
  660.         return $obj_tmpl;
  661.     }
  662.         
  663.     /**
  664.      * returns an array of chapter template names with chapter template ID as index
  665.      *
  666.      * @param boolean $getAll 
  667.      * @param boolean $debug 
  668.      */
  669.     public function getChaTemplateNames($getAll=False,$debug=False)
  670.     {
  671.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_TAMPLATE::getChTemplateNames()");
  672.         $str_query "SELECT CTMP_ID,CTMP_NAME FROM T_CMS_TMPL_CHAPTER";
  673.         $str_query.= " WHERE PTMP_ID = " $this->getId();
  674.         if (!$getAll{
  675.             $str_query.="   AND CTMP_DISABLED < 1";
  676.         }
  677.         
  678.         if ($debugechoDebugLine(__FILE__,__LINE__,$str_query);
  679.         
  680.         $arr_ret $this->getDBObj('r')->queryArray($str_query,0,1);
  681.         return $arr_ret
  682.     }
  683.  
  684.     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  685.     /* chapter objects                                                                      */
  686.     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  687.     
  688.     public function factoryChapterFromRow($aRow)
  689.     {
  690.         
  691.     }
  692.     
  693.     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  694.     /* get Data                                                                             */
  695.     /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  696.  
  697.     /**
  698.       * @returns string
  699.       * @version pk-05-09-06
  700.       ***/
  701.     function getMetaTag({
  702.         return $this->getDBField('META');
  703.     }
  704.  
  705.     /**
  706.       * returns the style definition for the template
  707.       *
  708.       * includes the code of the style with id $this->STY_ID and
  709.       * appends the text (as is!!) in $this->getDBField('TMPL_CSSCODE')
  710.       *
  711.       * the return value is treatend as template and parsed with $this->getDBVal() values
  712.       *
  713.       * @param boolean $asTemplate do not parse the return value
  714.       * @param boolean $debug 
  715.       *
  716.       * @returns string
  717.       *
  718.       * @version pk-05-09-06
  719.       * @version pk-06-07-19
  720.       *
  721.       ***/
  722.     function getCSSTag($asTemplate=FALSE,$debug=FALSE{
  723.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PAGE_TEMPLATE::getCSSTag()");
  724.  
  725.         $s_ret="<!-- \n________CMS_PAGE_TEMPLATE::getCSSTag________\n-->\n";
  726.  
  727.         if (intval($this->getDBField('STY_ID'))) {
  728.             $s_query="SELECT * FROM T_CMS_CSSSTYLES WHERE STY_ID=".intval($this->getDBField('STY_ID'));
  729.             if ($a_sty=$GLOBALS[$this->get_gDBIDX()]->quickQuery($s_query)) {
  730.                 $s_ret.="<style type=\"text/css\">\n<!--\n";
  731.                 $s_ret.="\n/* STYLE: ".$a_sty['STY_NAME']." PROJECT: ".$a_sty['PROJ_ID']." */\n";
  732.                 if (!empty($a_sty['STY_TEXT'])) {
  733.                     $s_ret.="/* __STY_TEXT__START__ */\n".$a_sty['STY_TEXT']."\n/* __STY_TEXT__END__ */\n";
  734.                 }
  735.                 $s_query="SELECT * FROM T_CMS_CSSCLASS WHERE STY_ID=".$a_sty['STY_ID'];
  736.                 if ($debug$s_ret.="/*$s_query*/\n";
  737.                 if (!empty($media)) {
  738.                     $s_query.=" AND CSS_MEDIA=".$GLOBALS[$this->get_gDBIDX()]->qs_getSlashedValue($media);
  739.                 }
  740.                 $s_query.=" ORDER BY CSS_ORDERNR,CSS_MEDIA";
  741.                 if ($o_cssCursor=$GLOBALS[$this->get_gDBIDX()]->query($s_query)) {
  742.                     $s_aktMedia="";$b_mediaOpen=FALSE;
  743.                     while($a_css=$o_cssCursor->fetchArrayFld()) {
  744.                         if (empty($a_css['CSS_MEDIA'])) $a_css['CSS_MEDIA']="all"// ensure all is set
  745.                         if ($a_css['CSS_MEDIA'!= $s_aktMedia{
  746.                             if ($b_mediaOpen// close it
  747.                                 $s_ret.="}\n";
  748.                             }
  749.                             $s_aktMedia=$a_css['CSS_MEDIA'];
  750.                             $s_ret.="@media ".$s_aktMedia." {\n";
  751.                             $b_mediaOpen=TRUE;
  752.                         }
  753.                         $s_ret.="\t".trim($a_css['CSS_NAME'])." {\n";
  754.                         $s_def=str_replace("\n","",str_replace("\r","",$a_css['CSS_DEFINITION']));
  755.                         $a_defLines=explode(";",$s_def);
  756.                         foreach($a_defLines as $s_line{
  757.                             $s_line=trim($s_line);
  758.                             if (!empty($s_line)) $s_ret.="\t\t".trim($s_line).";\n";
  759.                         }
  760.                         $s_ret.="\t}\n";
  761.                     // while($a_css=$o_cssCursor->fetchArrayFld())
  762.                     if ($b_mediaOpen{
  763.                         $s_ret.="}\n";
  764.                     }
  765.                 }
  766.                 $s_ret.="-->\n</style>\n";
  767.                 if (!empty($a_sty['STY_JAVACODE'])) {
  768.                     $s_ret.="<!-- __STY_JAVACODE__START__ -->\n";
  769.                     $s_ret.="<script language=\"javascript\" type=\"text/javascript\">\n<!--\n";
  770.                     $s_ret.=$a_sty['STY_JAVACODE'];
  771.                     $s_ret.="\n//-->\n</script>\n";
  772.                     $s_ret.="<!-- __STY_JAVACODE__END__ -->\n";
  773.                 }
  774.  
  775.             // if ($a_sty=$GLOBALS[$this->get_gDBIDX()]->quickQuery($s_query))
  776.         // if (intval($this->getDBField('STY_ID')))
  777.  
  778.         $s_oldCss=$this->getDBField('CSS')// old versions used this (mybe)
  779.         if (!empty($s_oldCss|| ($this->getDBField("TMPL_CSSCODE"))) {
  780.             $s_ret.="<!--\n___START___TMPL_CSSCODE___ (CMS_PAGE_TEMPLATE::TMPL_CSS)\n-->\n";
  781.             $s_ret.=$s_oldCss.$this->getDBField("TMPL_CSSCODE")."\n";
  782.             $s_ret.="\n<!--\n___END___TMPL_CSSCODE___\n-->\n";
  783.         }
  784.  
  785.  
  786.         if ($asTemplate{
  787.             return $s_ret;
  788.         else {
  789.             require_once $GLOBALS['OCSP']['PHPINCPATH']."common/pcf_templates.phpinc";
  790.             return pcf_tmpl_parse($s_ret,$this->getDBVal(),$debug);
  791.         }
  792.     }
  793.  
  794.     /**
  795.       * @returns string
  796.       * @version pk-05-09-06
  797.       ***/
  798.     function getJavaScriptTag({
  799.         return $this->getDBField('JAVASCRIPT');
  800.     }
  801.  
  802.  
  803.     /**
  804.       * @returns string
  805.       * @version pk-05-09-06
  806.       ***/
  807.     function getBodyTag({
  808.         $s_body=$this->getDBField('BODY');
  809.         if (!empty($s_body))
  810.             return $s_body;
  811.         else
  812.             return "<body>";
  813.     }
  814.  
  815.     /**
  816.       * @returns string
  817.       * @version pk-05-09-06
  818.       ***/
  819.     function getHeadLineTag({
  820.         return $this->getDBField('HEADLINE');
  821.     }
  822.  
  823.     /**
  824.       * @returns string
  825.       * @version pk-05-09-06
  826.       ***/
  827.     function getFeeterTag({
  828.         return $this->getDBField('FEETER');
  829.     }
  830.  
  831. }
  832. ?>

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