Source for file CMS_PAGE_TEMPLATE.phpclass
Documentation is available at CMS_PAGE_TEMPLATE.phpclass
* Class file CMS_PAGE_TEMPLATE.phpclass
* @project Open CSP-Management
* @author Peter Krebs <p.krebs@wpus.at>
* @copyright (c) 2002-2004 by Peter Krebs and Landesverlag Unternehmensservice
* @copyright (c) 2005-2006 by WURM & Partner Unternehmensservice
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: CMS_PAGE_TEMPLATE.phpclass,v 1.14 2008/12/16 17:40:40 peterkrebs Exp $
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* @constant string CLASS_SRC_FILE
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** class vars ------------------------------------------------------ */
* @staticvar array $loadedTemplates
/*** class methods --------------------------------------------------- */
* returns an unit of work instance
* @return CMS_PAGE_TEMPLATE
if ($debug) echoDebugMethod(__FILE__
,"static","CMS_PAGE_TEMPLATE::getInstance({$aId})");
if (isset
(self::$loadedTemplates[$aId]) &&
is_object(self::$loadedTemplates[$aId]))
return self::$loadedTemplates[$aId];
// return the default template ID: 0;
self::$loadedTemplates[0] =
new CMS_PAGE_TEMPLATE();
return self::$loadedTemplates[0];
self::$loadedTemplates[$aId] =
self::factoryFromId($aId,$debug);
return self::$loadedTemplates[$aId];
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Exception: " .
$e->getMessage() .
" fired");
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** compostion --------------------------------------------------- */
* @staticvar string $type OBJECT TYPE
* @staticvar string $myTable name of the db table
* @var string $myClassSrcFile class source file
* METHODS _____________________________________________
/** -----------------------------------------------------
* init the object and populates the object if aId
* @param int $aId id of an existing template
* @param string $gDBIDX GLOBALS database Object index
* factory method for a template by PTMP_ID
* @return CMS_PAGE_TEMPLATE
return self::factoryFromId($aId);
* factories a page template from an id
* @return CMS_PAGE_TEMPLATE
if ($debug) echoDebugMethod(__FILE__
,"static","CMS_PAGE_TEMPLATE::factoryFromId({$aId})");
$arr_filter =
array('PTMP_ID' =>
intval($aId));
return self::factoryFromRow($obj_row,$debug);
pcf_require_class('OCSP_CACHE_APC',__OCSP_PHPINCPATH__ . "cache/OCSP_CACHE_APC.phpclass");
pcf_require_class('OCSP_CACHE_FILE',__OCSP_PHPINCPATH__ . "cache/OCSP_CACHE_FILE.phpclass");
$bol_useAPC = OCSP_CONF::getInstance('OCSP')->getValue('USECMSAPC');
$bol_addToFCache = False;
if ($bol_useAPC && OCSP_CACHE_APC::isUseable())
if ($arr_row=OCSP_CACHE_APC::getInstance('CMSTEMPLROW')->getValue($aId))
if ($debug) echoDebugLine(__FILE__,__LINE__,"<h1>OCSP_CACHE_APC </h1><pre>" . print_r($arr_row,True) . "<pre>");
if (!$bol_loaded && OCSP_CACHE_FILE::isUseable())
if ($arr_row=OCSP_CACHE_FILE::getInstance('CMSTEMPLROW')->getValue($aId))
if ($debug) echoDebugLine(__FILE__,__LINE__,"<h1>OCSP_CACHE_FILE</h1><pre>" . print_r($arr_row,True) . "<pre>");
if (!($arr_row = OCSP_OBJ::defaultReadDBObj()->getRow('T_CMS_TMPL_PAGE',array('PTMP_ID' => $aId),$debug)))
throw new Exception(_OCSP_EXCEP_NODATA_.":T_CMS_TMPL_PAGE.PTMP_ID=" . $aId);
if (!isset($arr_row['PTMP_OBJCLASS']) || empty($arr_row['PTMP_OBJCLASS']))
$arr_row['PTMP_OBJCLASS'] = 'CMS_PAGE_TEMPLATE';
if (!CMS_TABLEOBJ::pageTmplType_requireClass($arr_row['PTMP_OBJCLASS']))
throw new Exception(_OCSP_EXCEP_CLASSNOTFOUND_ . ":" . $arr_row['PTMP_OBJCLASS']);
$obj_tmpl = new $arr_row['PTMP_OBJCLASS']();
$obj_tmpl->setDBRow($arr_row,True);
if ($bol_addToFCache) OCSP_CACHE_FILE::getInstance('CMSTEMPLROW')->setValue($aId,$obj_tmpl->getDBRow());
if ($bol_useAPC && $bol_addToAPC) OCSP_CACHE_APC::getInstance('CMSTEMPLROW')->setValue($aId,$obj_tmpl->getDBRow());
* factories a page template from an id
* @return CMS_PAGE_TEMPLATE
if (!isset
($aRow['PTMP_OBJCLASS']) ||
empty($aRow['PTMP_OBJCLASS']))
$aRow['PTMP_OBJCLASS'] =
'CMS_PAGE_TEMPLATE';
$obj_tmpl =
new $aRow['PTMP_OBJCLASS']();
$obj_tmpl->setDBRow($aRow,True);
* returns the object type
* returns the name of the template
return "PTMP_ID: " .
$this->getId();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* saves the template and ensures that there is only one default template per project
function dbSave($debug=
FALSE) {
if ($debug) echo
"<p><b>CMS_PAGE_TEMPLATE::dbSave(...)</b> (".
get_class($this).
")</p><blockquote>";
$this->PTMP_LASTCHANGE=
NULL;
if ($ret=
parent::dbSave($debug)) {
if (intval($this->{$this->myColPrevix.
"_ISDEFAULT"})) { // make sure we do not have another default template
if ($debug) echo
"<p>ISDEFAULT CMD:<br />".
$s_Cmd.
"</p>";
$this->getDBObj('w')->executeCmd($s_Cmd);
if ($debug) echo
"</blockquote>";
* deletes the template with all chapter templates from the database
* NOTE: foreign tables are hardcoded here
* @param boolean $backupData
function dbDelete($backupData=
FALSE,$debug=
FALSE) {
$cmd=
"DELETE FROM T_CMS_TMPL_CHAPTER WHERE PTMP_ID=".
$this->getId();
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p>CMD: $cmd</p></blockquote>");
return $this->getDBObj('w')->executeCmd($cmd);
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
* returns a array of variables used by the page object
* [FLDCLASS] name of DBMS_FIELD* class
* [CLASSVALS] array of values of [FLDCLASS]
require_once $GLOBALS['OCSP']['DBMSFLD_PATH'].
"DBMS_FIELD_TEXTAREA.phpclass";
"FLDCLASS" =>
"DBMS_FIELD_TEXTAREA",
"label" =>
"Meta Keywords",
"toolTip" =>
"Meta Keywords fü Suchmaschinen"
"FLDCLASS" =>
"DBMS_FIELD_TEXTAREA",
"FLDCLASS" =>
"DBMS_FIELD_TEXTAREA",
"label" =>
"JavaScript Header",
"FLDCLASS" =>
"DBMS_FIELD_TEXTAREA",
"FLDCLASS" =>
"DBMS_FIELD_TEXTAREA",
"label" =>
"Headline Template",
"toolTip" =>
"Wird auf jeder Seite eingfügt."
"FLDCLASS" =>
"DBMS_FIELD_TEXTAREA",
"label" =>
"Fußzeilen Template",
"toolTip" =>
"Wird auf jeder Seite eingfügt."
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
* returns an array of db default values
if ($debug) echo
"<p><b>CMS_PAGE_TEMPLATE::getDefaults($debug)</b> (".
get_class($this).
")</p>";
$ret=
parent::getDefaults();
$ret['PTMP_TYPE']=
"CMS_PAGE_TEMPLATE";
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
* returns if the template or a chapter template is in use
* @param boolean $onlyOnline check only pages and chapters with online states
function isInUse($onlyOnline=
TRUE,$debug=
FALSE) {
$s_query=
"SELECT CTMP_ID FROM T_CMS_TMPL_CHAPTER WHERE PTMP_ID=".
$this->getId();
$a_ctmpIds=
$this->getDBObj()->queryArray($s_query);
$s_query =
"SELECT COUNT(*) FROM T_CMS_PAGE LEFT OUTER JOIN T_CMS_CHAPTER USING (PAG_ID)";
$s_query.=
" WHERE (PTMP_ID=".
$this->getId();
$str_query .=
" OR CTMP_ID IN (".
implode(',',$a_ctmpIds).
"))";
foreach($GLOBALS['OCSP_CMS']['PAGESTATE'] as $i_id =>
$a_state) {
if (($a_state['SHOW']) ||
($a_state['DIRECTSHOW'])) {
$s_query.=
" AND PAG_STATE IN (".
implode(',',$a_pStates).
")";
if ($debug) echo
"<p>$s_query</p>";
* returns if the current user can open the template
return $obj_proj->curUserIsAuthor($debug);
* returns if the current user can edit the template
return $obj_proj->curUserIsEditor();
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
* copies all chapter templates from $ptmpId
if ($debug) echoDebug(__FILE__
,"<p><b>CMS_PAGE_TEMPLATE::copyChapterFrom($ptmpId)</b> (".
get_class($this).
")</p>",0);
$s_query =
"SELECT * FROM T_CMS_TMPL_CHAPTER";
$s_query.=
" WHERE PTMP_ID=".
intval($ptmpId);
if ($debug) echoDebug(__FILE__
,"<blockquote>$s_query</blockquote>",1);
if ($o_cursor=
$this->getDBObj('r')->query($s_query)) {
while($a_chap=
$o_cursor->fetchArrayFld()) {
unset
($a_chap['CTMP_ID']);
$a_chap['PTMP_ID']=
$this->getId();
if (intval($a_chap['PROJ_ID'])) {
$this->getDBObj('w')->insertArray("T_CMS_TMPL_CHAPTER",$a_chap,$debug);
* returns a chapter template object
$obj_tmpl->setPageTemplate($this);
* returns an array of chapter template names with chapter template ID as index
$str_query =
"SELECT CTMP_ID,CTMP_NAME FROM T_CMS_TMPL_CHAPTER";
$str_query.=
" WHERE PTMP_ID = " .
$this->getId();
$str_query.=
" AND CTMP_DISABLED < 1";
$arr_ret =
$this->getDBObj('r')->queryArray($str_query,0,1);
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
* returns the style definition for the template
* includes the code of the style with id $this->STY_ID and
* appends the text (as is!!) in $this->getDBField('TMPL_CSSCODE')
* the return value is treatend as template and parsed with $this->getDBVal() values
* @param boolean $asTemplate do not parse the return value
function getCSSTag($asTemplate=
FALSE,$debug=
FALSE) {
$s_ret=
"<!-- \n________CMS_PAGE_TEMPLATE::getCSSTag________\n-->\n";
$s_query=
"SELECT * FROM T_CMS_CSSSTYLES WHERE STY_ID=".
intval($this->getDBField('STY_ID'));
if ($a_sty=
$GLOBALS[$this->get_gDBIDX()]->quickQuery($s_query)) {
$s_ret.=
"<style type=\"text/css\">\n<!--\n";
$s_ret.=
"\n/* STYLE: ".
$a_sty['STY_NAME'].
" PROJECT: ".
$a_sty['PROJ_ID'].
" */\n";
if (!empty($a_sty['STY_TEXT'])) {
$s_ret.=
"/* __STY_TEXT__START__ */\n".
$a_sty['STY_TEXT'].
"\n/* __STY_TEXT__END__ */\n";
$s_query=
"SELECT * FROM T_CMS_CSSCLASS WHERE STY_ID=".
$a_sty['STY_ID'];
if ($debug) $s_ret.=
"/*$s_query*/\n";
$s_query.=
" AND CSS_MEDIA=".
$GLOBALS[$this->get_gDBIDX()]->qs_getSlashedValue($media);
$s_query.=
" ORDER BY CSS_ORDERNR,CSS_MEDIA";
if ($o_cssCursor=
$GLOBALS[$this->get_gDBIDX()]->query($s_query)) {
$s_aktMedia=
"";$b_mediaOpen=
FALSE;
while($a_css=
$o_cssCursor->fetchArrayFld()) {
if (empty($a_css['CSS_MEDIA'])) $a_css['CSS_MEDIA']=
"all"; // ensure all is set
if ($a_css['CSS_MEDIA'] !=
$s_aktMedia) {
if ($b_mediaOpen) { // close it
$s_aktMedia=
$a_css['CSS_MEDIA'];
$s_ret.=
"@media ".
$s_aktMedia.
" {\n";
$s_ret.=
"\t".
trim($a_css['CSS_NAME']).
" {\n";
foreach($a_defLines as $s_line) {
if (!empty($s_line)) $s_ret.=
"\t\t".
trim($s_line).
";\n";
} // while($a_css=$o_cssCursor->fetchArrayFld())
$s_ret.=
"-->\n</style>\n";
if (!empty($a_sty['STY_JAVACODE'])) {
$s_ret.=
"<!-- __STY_JAVACODE__START__ -->\n";
$s_ret.=
"<script language=\"javascript\" type=\"text/javascript\">\n<!--\n";
$s_ret.=
$a_sty['STY_JAVACODE'];
$s_ret.=
"\n//-->\n</script>\n";
$s_ret.=
"<!-- __STY_JAVACODE__END__ -->\n";
} // if ($a_sty=$GLOBALS[$this->get_gDBIDX()]->quickQuery($s_query))
} // if (intval($this->getDBField('STY_ID')))
$s_oldCss=
$this->getDBField('CSS'); // old versions used this (mybe)
if (!empty($s_oldCss) ||
($this->getDBField("TMPL_CSSCODE"))) {
$s_ret.=
"<!--\n___START___TMPL_CSSCODE___ (CMS_PAGE_TEMPLATE::TMPL_CSS)\n-->\n";
$s_ret.=
$s_oldCss.
$this->getDBField("TMPL_CSSCODE").
"\n";
$s_ret.=
"\n<!--\n___END___TMPL_CSSCODE___\n-->\n";
require_once $GLOBALS['OCSP']['PHPINCPATH'].
"common/pcf_templates.phpinc";
Documentation generated on Thu, 08 Jan 2009 17:39:38 +0100 by phpDocumentor 1.4.0a2