Source for file TMPL_CHAPTER.phpclass
Documentation is available at TMPL_CHAPTER.phpclass
* openCSP class file TMPL_CHAPTER.phpclass
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: TMPL_CHAPTER.phpclass,v 1.11 2008/12/17 16:28:52 peterkrebs Exp $
// ---------------------------------------------------------
// ---------------------------------------------------------
if (!defined('OCSP_CMS_CHATMPL_DUMMYTABLE')) define('OCSP_CMS_CHATMPL_DUMMYTABLE','CHAOBJVAL');
// ---------------------------------------------------------
// ---------------------------------------------------------
* openCSP class TMPL_CHAPTER
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: TMPL_CHAPTER.phpclass,v 1.11 2008/12/17 16:28:52 peterkrebs Exp $
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* @constant string CLASS_SRC_FILE
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** class vars ------------------------------------------------------ */
* @staticvar array $loadedCMSChapterTmpls
protected static $loadedCMSChapterTmpls =
array();
/*** class methods --------------------------------------------------- */
* returns an instance of the unit of work
if ($debug) echoDebugMethod(__FILE__
,"static","TMPL_CHAPTER::getInstance({$aId})");
!isset
(self::$loadedCMSChapterTmpls[$aId]) ||
!pcf_class_implements(self::$loadedCMSChapterTmpls[$aId],'INFA_TMPL_CHAPTER')
self::$loadedCMSChapterTmpls[$aId] =
TMPL_CHAPTER::factoryFromId(intval($aId));
return self::$loadedCMSChapterTmpls[$aId];
* returns if we already have an instance of $aId
if (isset
(self::$loadedCMSChapterTmpls[$aId]))
return pcf_class_implements(self::$loadedCMSChapterTmpls[$aId],'INFA_TMPL_CHAPTER');
* adds a newsletter to the unit of work
* @param CMS_CHAPTER $aChapter
if (intval($aChapter->getId()))
self::$loadedCMSChapterTmpls[$aChapter->getId()] =
$aChapter;
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
/*** compostion --------------------------------------------------- */
* table of the input fields
* @var string $myTmplFieldsTable
* array of template form fields
* temlate form fields populate timestamp
/*** attributes -------------------------------------------------- */
protected $myTable =
"T_CMS_TMPL_CHAPTER";
* @var string $contTable the table holding the content
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* factories a new TMPL_CHAPTER object
$obj_ret =
new TMPL_CHAPTER();
$obj_ret->populateFromKeys(array('CTMP_ID' =>
intval($aId)));
* returns a new newsletter from a db row
$obj_ret->setDBRow($row,True);
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* returns the template id
* returns the template name
* returns the html template
* returns if the template is a seperator (no fields)
* (abstract) returns 'OCSP'
* sets the content table (name)
* @param string $aTable name of the content table
if (!empty($aTable)) $this->contTable=
$aTable;
* returns the content table (name)
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* inserts a new row to the table
* @param boolean $debug show debug info
* @returns int returns the autoIncFld ID if exists or 1 on success
$this->setDBField('CTMP_CREATED_AT',"CURRENT_TIMESTAMP");
* replaces a row in the table
* @param boolean $debug show debug info
* @param boolean $ignorPopulated (if False the table MUST have been populated)
public function dbReplace($debug=
False,$ignorPopulated=
False)
$this->setDBField('CTMP_LASTCHANGE',"CURRENT_TIMESTAMP");
if (parent::dbReplace($debug,$ignorPopulated))
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* returns the page template id
* sets the page template id
* returns the page template
* @return CMS_PAGE_TEMPLATE
* @param CMS_PAGE_TEMPLATE $aTemplate
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* returns if the template fields are populated
* resets $this->myTmplFieldsPopulateTS and repopulates it if $populate
* @param boolean $populate
* populates the input fields from the database
'CTMP_ID' =>
$this->getId()
foreach($arr_fields as $arr_row)
//if ($debug) echoDebugLine(__FILE__,__LINE__,"fldObjVal: <pre>" . print_r($arr_objData,True) . "</pre>");
$this->myTmplFields[$arr_row['FLD_KEY']] =
new $arr_row['FLD_CLASS']();
$this->myTmplFields[$arr_row['FLD_KEY']]->setObjectVars($arr_objData['OBJVAL']);
$this->myTmplFields[$arr_row['FLD_KEY']]->setOrderNr($int_sortorder);
if (intval($arr_row['FLD_SORTORDER']) != $int_sortorder)
if ($debug) echoDebugLine(__FILE__,__LINE__,"updateing sortorder of " . $this->myTmplFields[$arr_row['FLD_KEY']]->getName() . "[" . $arr_row['FLD_KEY'] . "]");
$this->myTmplFields[$arr_row['FLD_KEY']]->save();
* extracts the input fields from the te
$arr_cmsValues =
array_merge($arr_pageValues,$arr_cmsValues);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Vars found in code: <br />".
(print_r($arr_tmplVars,TRUE)));
$arr_illegalchars=
array(" ","\n","<",">","&","?");
foreach($arr_tmplVars as $str_key =>
$arr_fld)
if (!isset
($arr_cmsValues[$str_key]))
reset($arr_illegalchars);
while(!$bol_illegal && list
($idx,$cha_i)=
each($arr_illegalchars))
if (strstr($str_key,$cha_i)) {
if (!$bol_illegal &&
!empty($str_key)) // <pk-05-02-08 />
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"checking: $str_key");
switch($arr_fld['TYPE']) {
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"addinged field: {$str_key}");
if ($debug) echoDebug(__FILE__
,"<p style=\"font-size:80%\">no Form Field (".
print_r($fld,TRUE).
"</p>");
echoDebugLine(__FILE__
,__LINE__
,"fld: {$str_key} already exists ");
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p>EMPTY FIELD</p>");
//echoDebugLine(__FILE__,__LINE__,print_r($this->myTmplFields,True));
* saves one template field to the db
$a_ObjData=
$fld->getObjectData($debug);
if (!($fld->getName())) $fld->setName($fldKey);
"CTMP_ID" =>
$this->getId(),
'FLD_TABLE' =>
$fld->getTable(),
'FLD_NAME' =>
$fld->getName(),
'FLD_IS_HIDDEN' =>
intval($fld->isHidden('all')),
'FLD_SHOW_IN_LIST' =>
intval($fld->showInList()),
'FLD_SORTORDER' =>
intval($fld->getOrderNr()),
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<pre style=\"font-size:80%\">".
print_r($a_fldRow,True).
"</pre>");
* saves the template fields to the db
$str_cmd.=
" WHERE CTMP_ID=" .
$this->getId();
$str_cmd.=
" WHERE CTMP_ID=" .
$this->getId();
$str_cmd.=
" AND FLD_SORTORDER= -99";
* returns an array with the template fields
* returns the template field object
* moves a template field to $intPos
if ($toPos <
1) $toPos =
1;
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"checking {$str_key} {$int_sort} -- " .
$obj_fld->getOrderNr());
if ($obj_fld->getOrderNr() !=
$int_sort) {
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"moving {$str_key} to {$int_sort}");
$obj_fld->setOrderNr($int_sort);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"moving {$str_key} to {$toPos}");
$obj_fld->setOrderNr($toPos);
$obj_fld->setOrderNr($int_sort);
* deletes a template field
* note: if the field is still used in the template it will
* be added again when the fields are extracted
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"checking field: {$str_key}");
$arr_fields[$str_key] =
$obj_fld;
if ($obj_fld->getOrderNr() !=
$int_sort)
$obj_fld->setOrderNr($int_sort);
$str_cmd.=
" WHERE CTMP_ID=" .
$this->getId();
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* returns a new not populated chapter
$obj_ret->setMyTemplate($this);
* get's a chapter instance
$obj_ret->setMyTemplate($this);
$obj_ret->populateFromKeys(array('CHA_ID' =>
intval($aId)));
$obj_ret->setMyTemplate($this);
* returns a chapter object from a T_CMS_CHAPTER row
$obj_ret->setDBRow($aRow);
* adds the template input fields to $aForm
* @param CMS_CHAPTER_FORM $aForm
if ($obj_tmplValFld =
$aForm->getField('CTMP_ID'))
if ($obj_block =
$obj_tmplValFld->getMyBlock())
foreach($arr_fields as &$obj_fld)
$obj_block->addFieldObj($obj_fld,$debug);
* returns the chapter input form
* @param mixed $form (string) form name (int) form id
public function &getChapterForm($form=
'',$frmClass=
'CMS_CHAPTER_FORM',$debug=
False)
if (empty($frmClass) ||
($frmClass ==
'OCSP_FORM') ||
($frmClass ==
'CMS_CHAPTER_FORM')) // ensure form source is included
$frmClass=
'CMS_CHAPTER_FORM';
$obj_form=
OCSP_FORM::factory_from_Name($form,$frmClass,$debug);
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
* renders the template to html
if ($str_templ =
$this->getHtmlCode())
Documentation generated on Thu, 08 Jan 2009 17:48:50 +0100 by phpDocumentor 1.4.0a2