Source for file TMPL_CHAPTER_V3.phpclass
Documentation is available at TMPL_CHAPTER_V3.phpclass
* Class file TMPL_CHAPTER_V3.phpclass
* @project Open CSP-Management
* @category templates-chapter
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: TMPL_CHAPTER_V3.phpclass,v 1.16 2008/10/18 12:18:39 pitlinz Exp $
* @deprecated since pk-08-08-07
* @staticvar string OCSP_TMPL_FRMVALUE_ALIAS
if (!defined('OCSP_TMPL_FRMVALUE_ALIAS')) define('OCSP_TMPL_FRMVALUE_ALIAS','CHAPTER');
* Handels chapter templates
* @project Open CSP-Management
* @category templates-chapter
* @author Peter Krebs <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version pk-06-02-16 pageTmpl methods added
* @version $Id: TMPL_CHAPTER_V3.phpclass,v 1.16 2008/10/18 12:18:39 pitlinz Exp $
* @deprecated since pk-08-08-07
* @constant string CLASS_SRC_FILE
* @staticvar string $ptmplFld the column name for the page template foreign key
* @staticvar string $ptmplTable
* @staticvar string $ptmplClass
* @var string $myPageTmpl
* @staticvar string $colPrevix the column name for the chapter columns
* @var array $inputFields array of DBMS_FIELD objects for the input form
* @var string $myFrmFldTableName (table name set in dbms_formfields)
* @var string $classSrcFile source file of the class
* @var array $myFldValTypes array of allowed db types
protected $myFldValTypes=
array('string'=>
'String','int'=>
'Integer','float'=>
'Number','blob'=>
'Text');
* @var OCSP_FORM (dummy) formObject for the fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// constructor, var access methods
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* creates and inits and populates if all keys are set the object
* @param int $aId ID of the db COLUMN
* @param boolen $issep is the chapter a layout element with no input
if ($debug) echo
"<p><b>TMPL_CHAPTER_V3::TMPL_CHAPTER_V3($aId,$issep)</b>(".
get_class($this).
")</p>";
* returns a chapter template object from an id
* @return TMPL_CHAPTER_V3
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* returns a database form and hides some system fields
* also sets CTMP_ALLOWED_SHOWMODE to
function &dbGetForm($mode,$frmName=
"",$debug=
FALSE) {
if ($debug) echo
"<p><b>TMPL_CHAPTER_V3::dbGetForm($mode,$frmName,...)</b> (".
get_class($this).
")</p>";
if ($frmObj=
parent::dbGetForm($mode,$frmName,$debug)) {
$frmObj->hideField($this->colPrevix.
"FIELDS");
$frmObj->hideField($this->colPrevix.
"FIELDSV2");
$frmObj->hideField($this->colPrevix.
"FIELDCLASSES");
$frmObj->hideField($this->colPrevix.
"VERSION"); // <pk-05-07-20 />
// <pk-06-02-17> set field CTMP_ALLOWED_SHOWMODE values
if (!empty($s_showModes)) {
require_once $GLOBALS['OCSP']['DBMSFLD_PATH'].
"DBMS_FIELD_DBLOOKUPMULTISELECTLIST.phpclass";
$o_fld=
&$frmObj->getField("CTMP_ALLOWED_SHOWMODE",$this->myTable,$debug);
$o_fld=
pcf_castObject($o_fld,"DBMS_FIELD_DBLOOKUPMULTISELECTLIST",$debug);
$o_fld->lookupTable =
"T_LOOKUP_CHA_SHOWMODE";
$o_fld->lookupShowField =
"CONCAT(LUP_VALUE,' (',LUP_KEY,')')";
$o_fld->lookupField =
"LUP_KEY";
$o_fld->lookupWhere =
"LUP_KEY IN (".
$this->myPageTmpl->PTMP_CHASHOWMODES.
")";
if ($debug) echoDebug(__FILE__
,"<p>ERROR: no FORM</p>",1);
* replaces dbGetForm and returns a OCSP_FORM
* @param mixed $form (string) form name (int) form id
* @requires db/forms/OCSP_FORM.phpclass
function &getForm($mode=
FRM_MODE_READONLY,$form=
'',$frmClass=
'OCSP_FORM',$debug=
FALSE)
if ($objForm=
parent::getForm($mode,$form,$frmClass,$debug))
$objForm->hideField($this->colPrevix.
"FIELDS");
$objForm->hideField($this->colPrevix.
"FIELDSV2");
$objForm->hideField($this->colPrevix.
"FIELDCLASSES");
$objForm->hideField($this->colPrevix.
"VERSION"); // <pk-05-07-20 />
* clears $this->inputFields and populates it from the database
* returns the size of the input field array
* @param boolean $extractFlds
* @param boolean $autoUpdate update to version 3 if not already is in this version
return parent::populateInputFields($extractFlds,$debug,$autoUpdate);
if (intval($this->getId())) {
if (!$this->isConnected(TRUE))
ocsp_logError(__FILE__,__LINE__,"no database connection",E_ERROR);
$this->inputFields=array(); // reset inputFields
if ($debug) echo "<blockquote><p>Loding fields ......</p>";
if (empty($this->moduleKey)) $this->moduleKey=$this->getClass();
$s_Query ="SELECT * FROM ".$this->myFldTable;
$s_Query.=" WHERE ".$this->colPrevix."ID = ".$this->getId();
$s_Query.=" AND FRM_MODULE='".$this->moduleKey."'";
$s_Query.=" ORDER BY FLD_SORTORDER";
if ($debug) echo "<p>inputFields Query: <br />$s_Query</p>";
if ($o_Cursur=$this->myDBObj->query($s_Query)) {
while($a_fldRow = $o_Cursur->fetchArrayFld()) {
if ($debug) echo "<p>FIELD: ".$a_fldRow['FLD_KEY']."</p><blockquote style=\"background-color: #C0C0C0;\">";
$a_fldDesc=unserialize(base64_decode($a_fldRow['FLD_B64OBJECT']));
if ($debug) echo "<pre style=\"font-size:75%\">".print_r($a_fldDesc,TRUE)."</pre>";
$this->unserFldRow($a_fldRow['FLD_KEY'],$a_fldDesc,$debug);
if ($debug) echo "</blockquote>";
if (!sizeof($this->inputFields) && (!empty($this->{$this->colPrevix."FIELDS"}))) {
if ($debug) echo "<blockquote style=\"background-color: #D24843\"><h2><b>LOADING TMPL_CHAPTER_V2 FIELDS</b></h2>";
// we have an older version -> convert it to the new one
if (!empty($this->{$this->colPrevix."FIELDCLASSES"})) {
// we have table version > 16 with field classes -> ensure the class source is loaded
$fldClasses=explode(";",$this->{$this->colPrevix."FIELDCLASSES"});
if (is_array($fldClasses)) {
foreach($fldClasses as $fldClass) {
DBMS_field_IncludeSrc($fldClass,$debug);
// we have a very old version
DBMS_field_IncludeAllSrc($debug);
$this->inputFields=@unserialize($this->{$this->colPrevix."FIELDS"});
if (sizeof($this->inputFields)) {
$s_cmd ="UPDATE ".$this->myTable." SET ".$this->colPrevix."VERSION=3";
$s_cmd.=" WHERE ".$this->colPrevix."ID=".$this->getId();
$this->myDBObj->executeCmd($s_cmd);
$this->saveInputFields(TRUE,$debug,FALSE); // ([boolean $clearFirst = FALSE], [boolean $debug = FALSE], [boolean $extractFlds = TRUE])
if ($debug) echo "</blockquote>";
$this->p_extractFields(FALSE,$debug); // check if all fields defined in the
// template(s) are in $this->inputFields
if ($debug) echo "</blockquote>";
return sizeof($this->inputFields);
* unserializes a fieldRow (array element)
if ($debug) echo
"<p><b>DBMS_FORM::unserFldRow($key,...)</b> (".
get_class($this).
")</p><blockquote>";
if ($debug) echo
"<p>CLASSFILE: $classFile included</p>";
} else { // <pk-05-12-01>
if ($debug) echo
"<p>CLASSFILE: $classFile included</p>";
} else if (file_exists($fldDesc['OBJDESC']['SRCFILE'])) {
require_once $fldDesc['OBJDESC']['SRCFILE'];
if ($debug) echo
"<p>CLASSFILE: ".
$fldDesc['OBJDESC']['SRCFILE'].
" included</p>";
$fldDesc['OBJDESC']['CLASS']=
"DBMS_FIELD";
if ($debug) echo
"<p>CLASSFILE NOT FOUND -> CHANGED TO DBMS_FIELD</p>";
$cmd=
"\$this->inputFields['".
$key.
"']=new ".
$fldDesc['OBJDESC']['CLASS'].
"();";
if ($debug) echo
"<p><br />$cmd</p></blockquote>";
if ($debug) {echo
"<blockquote>ObjectData: <p style=\"font-size:75%\">";print_r($fldDesc['OBJVAL'],TRUE);echo
"</p></blockquote>";}
$this->inputFields[$key]->setObjectVars($fldDesc['OBJVAL']);
if ($debug) echo
"<p><b>NO OBJECT CREATED</b></p></blockquote>";
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* returns the page template id
if ($debug) echo
"<p><b>TMPL_CHAPTER_V3::getPTMPId()</b> (".
get_class($this).
")</p>";
* sets the page template id
// <pk-06-02-16> check $this->myPageTmpl
* loads the page template object if $this->myTmpl is not set or has a different ID
* uses $GLOBALS['OCSP']['CACHE'][$this->moduleKey.'PAGE_TEMPLATES'] as memory cache
* @param boolean $debug show debug information
* @param boolean $enableEmpty
* @returns boolean succeed ?
if ($debug) echo
"<p><b>TMPL_CHAPTER_V3::loadPageTemplate()</b> (".
get_class($this).
")</p>\n";
// we already loaded the template
isset
($GLOBALS['OCSP']['CACHE'][$this->moduleKey.
'PAGE_TEMPLATES'][$this->getPTMPId()]) &&
is_object($GLOBALS['OCSP']['CACHE'][$this->moduleKey.
'PAGE_TEMPLATES'][$this->getPTMPId()])
// use memory chached template
$this->myPageTmpl=
&$GLOBALS['OCSP']['CACHE'][$this->moduleKey.
'PAGE_TEMPLATES'][$this->getPTMPId()];
$s_cmd=
"\$this->myPageTmpl=new ".
$this->ptmplClass.
"(\$i_tmplId);";
$GLOBALS['OCSP']['CACHE'][$this->moduleKey.
'PAGE_TEMPLATES'][$this->{$this->ptmplFld}]=
&$this->myPageTmpl;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* returns the table head row for the fieldlist
if ($debug) echo
"<p><b>DBMS_fldLstHeader(...)</b> (".__FILE__.
")</p>";
<th align=\"center\">#</th>
<th align=\"center\">Field</th>
<th align=\"center\">Label</th>
<th align=\"center\">Input-Type</th>
<th align=\"center\">ShowClass</th>
<th colspan=\"6\"> </th>
* returns the htmlcode for a field row in the fieldlist
* @param DBMS_FIELD $fld the field object
* @param string $editUrl link to the field editor
* @param string $tdStyle column stylesheet (add ; at the end)
function fldLstRow(&$fld,$editUrl=
"",$funcUrl=
"",$tdStyle=
"",$debug=
FALSE) {
if ($debug) echo
"<p><b>DBMS_fldLstRow(...)</b> (".__FILE__.
")</p>";
if (empty($editUrl)) $editUrl=
$_SERVER['REQUEST_URI'];
$eLink=
"<a href=\"".
$editUrl.
"&FIELD=".
$fld->getName().
"\">";
if (empty($funcUrl)) $funcUrl=
$_SERVER['REQUEST_URI'];
if ($fld->isHidden('all')) $tdstyle.=
"background: #c0c0c0;";
) $tdstyle.=
"color: #FF0000;";
$style=
"style=\"".
$tdstyle.
"\"";
$ret.=
"\t<td $style>$eLink".
$fld->getOrderNr().
"</a></td>\n";
$ret.=
"\t<td $style>$eLink".
$fld->getName().
"</a></td>\n";
$ret.=
"\t<td $style>$eLink".
$fld->getLabel().
"</a></td>\n";
$ret.=
"\t<td $style><select name=\"ChangeType\" onChange=\"";
$ret.=
"if (confirm('Change Class To: '+this.options[this.selectedIndex].value)) { ";
$ret.=
" editLoc='".
$funcUrl.
"&TMPLFLDCMD=CHANGETYPE';";
$ret.=
" editLoc=editLoc+'&NEWTYPE='+this.options[this.selectedIndex].value;";
$ret.=
" document.location.href=editLoc;";
$ret.=
"\t\t<option value=\"".
$type.
"\" ";
if ($fld->getDBColType()==
$type) $ret.=
"selected";
$ret.=
">".
$name.
"</option>\n";
$ret.=
"</select></td>\n";
$ret.=
$fld->editLst_getClassSelect($editUrl.
"&TMPLFLDCMD=CHANGECLASS",$selName=
"ChangeClass",$style=
"",$debug=
FALSE);
$ret.=
"TMPL_CHAPTER_V3 no method (Line: ".__LINE__.
")";
// ~~~~~~~~~~~~~~~ BUTTONS ~~~~~~~~~~~~~~~~~~~~
$ret.=
"\t<td width=\"17\" align=\"center\" class=\"button\">";
if ($fld->getOrderNr() >
1) {
$ret.=
"<a href=\"".
$funcUrl.
"&TMPLFLDCMD=UP\"><img src=\"".
$GLOBALS['OCSP']['SYSIMGURL'].
"buttons/up.gif\" border=\"0\" alt=\"move up\"></a></td>";
$ret.=
"\t<td width=\"17\" align=\"center\" class=\"button\">";
if (!isset
($count)) $count=
1;
$ret.=
"<a href=\"".
$funcUrl.
"&TMPLFLDCMD=DOWN\"><img src=\"".
$GLOBALS['OCSP']['SYSIMGURL'].
"buttons/down.gif\" border=\"0\" alt=\"move down\"></a></td>";
$ret.=
"\t<td width=\"2\" style=\"font-size:1px;\"> </td>";
$ret.=
"\t<td width=\"17\" align=\"center\" class=\"button\">";
if ($fld->isHidden('all')) {
$ret.=
"<a href=\"".
$funcUrl.
"&TMPLFLDCMD=SHOW\"><img src=\"".
$GLOBALS['OCSP']['SYSIMGURL'].
"buttons/ishidden.gif\" border=\"0\" alt=\"show\"></a></td>";
$ret.=
"<a href=\"".
$funcUrl.
"&TMPLFLDCMD=HIDE\"><img src=\"".
$GLOBALS['OCSP']['SYSIMGURL'].
"buttons/isshown.gif\" border=\"0\" alt=\"hide\"></a></td>";
$ret.=
"\t<td width=\"2\" style=\"font-size:1px;\"> </td>";
$ret.=
"\t<td width=\"17\" align=\"center\" class=\"button\">";
$ret.=
"<a href=\"javascript:{if (confirm('Feld: ".
$fld->getName().
" löschen?')) ";
$ret.=
" document.location.href='".
$funcUrl.
"&TMPLFLDCMD=DELETE';";
$ret.=
"}\"><img src=\"".
$GLOBALS['OCSP']['SYSIMGURL'].
"buttons/delete.gif\" border=\"0\" alt=\"delete\"></a></td>\n";
* checks the field command ($_GET['TMPLFLDCMD'] if $fldCmd is empty) and
if (empty($fldCmd) && isset
($_GET['TMPLFLDCMD'])) $fldCmd=
$_GET['TMPLFLDCMD'];
$valTypes=
array('string'=>
'String','int'=>
'Integer','float'=>
'Number','blob'=>
'Text');
if (($_GET['NEWTYPE']) &&
(!empty($valTypes[$_GET['NEWTYPE']]))) {
$this->setFieldDBType($_GET['TMPLFIELD'],$_GET['NEWTYPE'],TRUE,$debug);
if ($debug) echo
"<p>Field: ".
$_GET['TMPLFIELD'].
"<pre>".
print_r($this->getField($_GET['TMPLFIELD']),TRUE).
"</pre>";
$ERR=
"Change class of field: <b>".
$fld->getName().
"</b> to <b>".
$_GET['NEWCLASS'].
"</b";
include $PROJECT['PHPINCPATH'].
"io/errors.phpinc";
$this->saveInpField($_GET['TMPLFIELD'],$o_Fld,$debug);
if ($o_Fld=
$this->getField($_GET['TMPLFIELD'])) {
$this->saveInpField($_GET['TMPLFIELD'],$o_Fld,$debug);
if ($o_Fld=
$this->getField($_GET['TMPLFIELD'])) {
$this->saveInpField($_GET['TMPLFIELD'],$o_Fld,$debug);
if ($o_Fld=
$this->getField($_GET['TMPLFIELD'])) {
$this->saveInpField($_GET['TMPLFIELD'],$o_Fld,$debug);
if ($debug) echo
"<p>Moving Fld ".
$_GET['TMPLFIELD'].
" Down</p>";
if ($o_Fld=
$this->getField($_GET['TMPLFIELD'])) {
if ($o_Fld->sortOrder <
sizeof($a_Flds)) { // this is not the last element
if ($debug) {foreach($a_Flds as $i =>
$o) echo
"<p>$i: ".
$o->getName().
" (ORDNR: ".
$o->sortOrder.
")</p>\n";echo
"<hr>";}
if ($o_NxtFld=
$a_Flds[($o_Fld->sortOrder+
1)]) {
$o_NxtFld->sortOrder=
$o_Fld->sortOrder;
if ($debug) echo
"<p>NextField: ".
$o_NxtFld->getName().
" (ORDNR: ".
$o_NxtFld->sortOrder.
")</p>\n";
$this->saveInpField($o_NxtFld->getName(),$o_NxtFld,$debug);
if ($debug) echo
"<p>Field: ".
$o_Fld->getName().
" (ORDNR: ".
$o_Fld->sortOrder.
")</p>\n";
$this->saveInpField($o_Fld->getName(),$o_Fld,$debug);
if ($debug) echo
"<p>Moving Fld ".
$_GET['TMPLFIELD'].
" Up</p>";
if ($o_Fld=
$this->getField($_GET['TMPLFIELD'])) {
if ($o_Fld->sortOrder >
1) { // this is not the last element
if ($debug) {foreach($a_Flds as $i =>
$o) echo
"<p>$i: ".
$o->getName().
" (ORDNR: ".
$o->sortOrder.
")</p>\n";echo
"<hr>";}
if ($o_PrevFld=
$a_Flds[($o_Fld->sortOrder-
1)]) {
$o_PrevFld->sortOrder=
$o_Fld->sortOrder;
if ($debug) echo
"<p>PrevField: ".
$o_PrevFld->getName().
" (ORDNR: ".
$o_PrevFld->sortOrder.
")</p>\n";
$this->saveInpField($o_PrevFld->getName(),$o_PrevFld,$debug);
if ($debug) echo
"<p>Field: ".
$o_Fld->getName().
" (ORDNR: ".
$o_Fld->sortOrder.
")</p>\n";
$this->saveInpField($o_Fld->getName(),$o_Fld,$debug);
#####################################
* checks the sortOrder of the input fields
if ($debug) echo
"<p><b>TMPL_CHAPTER_V3::p_checkSort(...)</b> (".
get_class($this).
")</p><blockquote>";
// first put the DBMS fields into a new array other objects will be deleted
// find the first free orderNr
if (intval($fld->getOrderNr())) {
// for objects where it is set
while(isset
($fldArr[$fld->getOrderNr()])) $fld->incOrderNr();
// for objects where it is not set
while(isset
($fldArr[$orderNr])) $orderNr++
;
$fld->setOrderNr($orderNr);
if ($debug) echo
"<p>".
$fld->getOrderNr().
": getting Field: ".
$fld->getName().
"</p>";
$fldArr[$fld->getOrderNr()]=
$fld;
if ($debug) echo
"<p>WRONG OBJECT: ".
print_r($fld).
"</p>";
// secound sort $fldArr and clear inputFields
// third set the new inputFields
foreach($fldArr as $fld) {
if ($debug) echo
"<p>setting Field: ".
$fld->getName().
" as Nr: ".
$fld->getOrderNr().
"</p>";
if ($debug) echo
"<p>No Fields in \$this->inputFields</p>";
if ($debug) echo
"</blockquote>";
* PRIVATE extracts template fields from code fields
* @param bool $clearFirst call $this->inputFields =array(); ?
* @param bool $debug show debug info
* @version pk-06-03-08 avoid adding chapter fields
echoDebugMethod(__FILE__
,get_class($this),"TMPL_CHAPTER_V3::p_extractFields(".
($clearFirst ?
"CLEARFIRST" :
"ADDONLY").
")");
echoDebug(__FILE__
,"<blockquote style=\"font-size:90%\">");
if ($debug) echo
"<p>INPUTFIELD: $fld</p><p style=\"font-family: courier; font-size: 10px;\">".
nl2br(htmlspecialchars($this->{$fld})).
"</p>";
echoDebug(__FILE__
,"<p>\$code is empty</p></blockquote>");
return FALSE; // <pk-05-08-26 />
foreach($a_varArr as $s_key =>
$a_fld) {
if (!empty($s_key)) { // <pk-05-02-08 />
if ($debug) echoDebug(__FILE__
,"<p>checking: $s_key </p><blockquote style=\"font-size:90%;\">");
if ($debug) echoDebug(__FILE__
,"<p style=\"font-size:80%\"><b>is Form Field</b> (".
print_r($a_fld,TRUE).
"</p>");
if ($debug) echoDebug(__FILE__
,"<p style=\"font-size:80%\">no Form Field (".
print_r($fld,TRUE).
"</p>");
if ($debug) echoDebug(__FILE__
,"</blockquote>");
if ($debug) echoDebug(__FILE__
,"<p>EMPTY FIELD</p>");
// <pk-05-02-10 remove fields with illegal chars in key >
$illegalchars=
array(" ","\n","<",">","&","?");
if ($debug) echoDebug(__FILE__
,"<p><b><u>Input Fields:</u></b></p>");
while (!$found && list
($idx,$iChar)=
each($illegalchars)) {
if (strstr($key,$iChar)) $found=
TRUE;
ocsp_logError(__FILE__
,__LINE__
,"no database connection",E_ERROR);
foreach($a_DBFields as $s_colName) {
if ($debug) echoDebug(__FILE__
,"</blockquote>");
// #################################
* @param boolean $forceDB
function deleteField($fldName,$debug=
FALSE,$forceDB=
TRUE) {
if ($debug) echo
"<p><b>TMPL_CHAPTER_V3::deleteField($fldName,...)</b> (".
get_class($this).
")</p>";
if ($forceDB &&
$this->getId()) {
$s_Cmd =
"DELETE FROM ".
$this->myFldTable;
$s_Cmd.=
" AND FRM_MODULE='".
$this->moduleKey.
"'";
$s_Cmd.=
" AND FLD_NAME=".
$this->myDBObj->qs_getSlashedValue($fldName);
$this->myDBObj->executeCmd($s_Cmd);
// #################################
* returns an array with pointers to the template fields
* @param boolean $autoSave
echoDebug(__FILE__
,"<blockquote style=\"font-size:80%\">\n");
if ($autoSave) $this->dbSave($debug);
$a_ret=
array(); // the return array
$a_orderNrFlds=
array(); // temp array with sortOrder as index inputFields key as value
$b_saveInputFields=
FALSE;
foreach($a_fldKeys as $s_key) {
if ($debug) echoDebug(__FILE__
,"<p>checking Field: $s_key</p>");
// loop throug input fields and create $a_orderNrFlds
// this array is the result if we use sortOrder of the fields
// douplicated values of sortOrder are increased
// no ensurance that the array has gaps in order numbers
// this will be checked later on
// no name set for the field -> set key as name
// ensure we have set a sortOrder
while(isset
($a_orderNrFlds[$this->inputFields[$s_key]->getOrderNr()])) {
if ($debug) echo
"<p>ups DUPLICATE ORDERNR</p>";
$a_orderNrFlds[$this->inputFields[$s_key]->getOrderNr()]=
$s_key;
// ok we now have an array but are there gaps in the index?
ksort($a_orderNrFlds); //sort the array by sortOrder
foreach($a_orderNrFlds as $s_key) {
if ($debug) echo
$this->inputFields[$s_key]->getOrderNr().
": ".
$s_key.
" ".
$this->inputFields[$s_key]->getLabel().
"; ";
if ($this->inputFields[$s_key]->getOrderNr <>
$i_orderNr) {
// update the field to the database
$this->saveInpField($s_key,$this->inputFields[$s_key],$debug);
} else if ($b_saveInputFields &&
$autoSave) {
// update the field to the database
$this->saveInpField($s_key,$this->inputFields[$s_key],$debug);
if ($debug) echo
"</blockquote>";
// #################################
* returns a serialized array of the input fields in $postArr
* if $fldArr is an array the fields are added/replaced
* otherwise a new array is created
* @param boolean $keepServerName (replace http://SERVER_NAME/ with / ?)
function getFieldValues($postArr,$keepServerName=
FALSE, $debug=
FALSE,$fldArr=
NULL) {
if ($debug) echo
"<p><b>TMPL_CHAPTER_V3::getFieldValues(\$postArr array(".
sizeof($postArr).
"),$keepServerName,$debug,\$fldArr array(".
sizeof($fldArr).
"))</b> (".
get_class($this).
")</p>";
// if ($debug) echo "<blockquote><pre>".htmlspecialchars(print_r($postArr,TRUE))."</pre></blockquote>";
if ($debug) echo
"<blockquote>Object: $key<pre>".
pcf_print_r($obj,TRUE,3).
"</pre>";
if (stristr($obj->className,"HTML")) {
if ((!$keepServerName) ||
($obj->getSetting("replaceServer"))) {
// replace http://servername/ with / to allow more systems
$retArr[$obj->myName]=
str_replace("http://".
$_SERVER['SERVER_NAME'].
"/","/",$postArr[$obj->myName]);
$retArr[$obj->myName]=
$postArr[$obj->myName];
$retArr[$obj->myName]=
$postArr[$obj->myName];
if ($debug) echo
"<blockquote>returns NULL</blockquote><hr>";
if ($debug) echo
"<blockquote>getFieldValues returns serialize of <pre>".
htmlspecialchars(print_r($retArr,TRUE)).
"</pre></blockquote><hr>";
* returns the html code for the template
* @param boolean $wysiwygPreView since pk-05-08-02
function getTag($vals=
array(),$var=
"HTMLCODE",$debug=
FALSE,$wysiwygPreView=
FALSE) {
$arrName=
"tmplValArr_".
$this->getId();
echo
"<p><b>Chapter Values:</b></p><pre style=\"font-size: 75%\">";print_r($vals);echo
"</pre>";
echo
"<hr></blockquote>";
if ((!empty($tag)) &&
(is_array($vals))) {
if (isset
($vals[$fld->getName()])) {
if (isset
($GLOBALS['OCSP_CMS']['LINKREPLACE']) &&
is_array($GLOBALS['OCSP_CMS']['LINKREPLACE'])) {
if ($debug) echo
"<p>['CMS']['LINKREPLACE']: </p><pre>".
print_r($GLOBALS['OCSP_CMS']['LINKREPLACE'],TRUE).
"</pre>";
$linkPattern=
"/(<a *)(href=\")([^\"]*)([^>]*)(>)/i";
foreach($links[3] as $lIdx =>
$repluri) {
// if ($debug) echo "<p>".trim($links[3][$lIdx])." -- ".$links[4][$lIdx]."</p>";
(!empty($GLOBALS['OCSP_CMS']['EXLINKDFLTTRG'])) &&
$rplTarget =
$links[4][$lIdx].
" target=\"".
$GLOBALS['OCSP_CMS']['EXLINKDFLTTRG'].
"\"";
if ($debug) echo
"<p>TARGETREPLACE: ".
$links[4][$lIdx].
"<br />.".
$rplTarget.
"</p>";
if ($debug) echo
("<p><b>Link $lIdx</b></p>");
foreach($GLOBALS['OCSP_CMS']['LINKREPLACE'] as $rIdx =>
$rLinkArr) {
if (strstr($repluri,$rLinkArr['SRC'])) {
$replWith =
$links[1][$lIdx];
$replWith .=
$links[2][$lIdx];
if (!empty($GLOBALS['OCSP_CMS']['LINKREPLACE'][$rIdx]['TARGET'])) {
$replWith .=
$links[4][$lIdx].
" target=\"".
$GLOBALS['OCSP_CMS']['LINKREPLACE'][$rIdx]['TARGET'].
"\" ";
if ($rplTarget) $replWith.=
$rplTarget;
else $replWith .=
$links[4][$lIdx];
$replWith .=
$links[5][$lIdx];
// echo "<pre>\n".htmlspecialchars($repluri."\n".$dst."\n".$tag)."</pre>";
$replWith=
$links[1][$lIdx].
$links[2][$lIdx].
$links[3][$lIdx].
$rplTarget.
$links[5][$lIdx];
$tag=
pcf_tmpl_parse($tag,$vals); // <pk-04-11-15 /> to replace values defined in the template values (forms for example)
Documentation generated on Thu, 08 Jan 2009 17:48:57 +0100 by phpDocumentor 1.4.0a2