Source for file OCSP_FORM.phpclass
Documentation is available at OCSP_FORM.phpclass
* Class file OCSP_FORM.phpclass
* @project Open CSP-Management
* @author Peter Krebs (pk) <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: OCSP_FORM.phpclass,v 1.66 2008/12/18 22:05:55 pitlinz Exp $
* @includes ./languages/de.phpinc
* @todo include the proper languange file
include_once dirname(__FILE__
).
_OCSP_DIRSEP_.
"languages".
_OCSP_DIRSEP_.
"de.phpinc";
* @requires OCSP_FORM_BLOCK.phpclass
* @requires INFA_OCSP_FORM.phpclass
* Database Formular Basic Elements
* this class is without any layout elements to extend to what
* @project Open CSP-Management
* @author Peter Krebs (pk) <pitlinz@users.sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @verions $Id: OCSP_FORM.phpclass,v 1.66 2008/12/18 22:05:55 pitlinz Exp $
/*** class constants --------------------------------------------- */
* @constant string CLASS_SRC_FILE
* @constant string FORM_CACHE_DIR
* @constant string FORM_CACHE_FILEEXT
/*** class variables --------------------------------------------- */
* @staticvar array $form_instances
* @staticvar array $staticClassVars vars which must not be copied
protected static $staticClassVars=
array('form_instances');
* @staticvar array $dbmsFieldClassDesc
protected static $dbmsFieldClassDesc =
array();
* @staticvar array $dbmsFieldTypeClasses
protected static $dbmsFieldTypeClasses =
array();
* returns the field class description for a field
if ($debug) echoDebugMethod(__FILE__
,"static","OCSP_FORM::getFieldClassDesc(" .
$aClassName .
")");
if (sizeof(self::$dbmsFieldClassDesc) <
1)
self::loadFieldClassDesc($debug);
if (isset
(self::$dbmsFieldClassDesc[$aClassName]))
return self::$dbmsFieldClassDesc[$aClassName];
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"returnung Null");
* returns all field class descriptions
return self::$dbmsFieldClassDesc;
* requires the a field class src file
* @param string $aClassName
if ($debug) echoDebugMethod(__FILE__
,"static","OCSP_FORM::requireFieldClass(" .
$aClassName .
");");
if (!$arr_fldDesc =
self::getFieldClassDesc($aClassName))
switch($arr_fldDesc['FLD_SYSTEM'])
if (!intval($arr_fldDesc['MOD_ID']))
pcf_require_class($aClassName,$obj_module->getModuleIncPath().
"/" .
$arr_fldDesc['FLD_CLASS_SRC']);
if (isset
($GLOBALS[$arr_fldDesc['FLD_SYSTEM']]['PHPINCPATH']))
pcf_require_class($aClassName,$GLOBALS[$arr_fldDesc['FLD_SYSTEM']]['PHPINCPATH'].
"/" .
$arr_fldDesc['FLD_CLASS_SRC']);
* loads the field Desc from File cache and sets self::$dbmsFieldClassDesc
if ($debug) echoDebugMethod(__FILE__
,"static","OCSP_FORM::loadFieldClassDesc()");
self::$dbmsFieldClassDesc =
$arr_desc['DESC'];
self::$dbmsFieldTypeClasses =
$arr_desc['TYPE'];
self::compat_setOCSP_DBMS_FIELDDESC($debug);
self::writeFieldDescToCache($debug);
* loads field definition from the db and caches to a file
if ($debug) echoDebugMethod(__FILE__
,"static","OCSP_FORM::writeFieldDescToCache()");
if (self::$dbmsFieldClassDesc =
OCSP_OBJ::defaultReadDBObj()->getIndexedArray('T_DBMS_FIELDDESC',NULL,'FLD_CLASS',Null,0,0,"FLD_ISTYPEDEF DESC, FLD_TYPE",$debug))
self::$dbmsFieldTypeClasses=
array();
foreach(self::$dbmsFieldClassDesc as $str_class =>
$arr_desc)
self::$dbmsFieldTypeClasses[$arr_desc['FLD_TYPE']][] =
$str_class;
self::compat_setOCSP_DBMS_FIELDDESC($debug);
ocsp_logError(__FILE__
,__LINE__
,"could not create cachedir: <br />$str_cacheDir");
'DESC' =>
self::$dbmsFieldClassDesc,
'TYPE' =>
self::$dbmsFieldTypeClasses
file_put_contents($str_cacheFile,serialize($arr_desc));
* sets the old style $GLOBALS['OCSP']['DBMS_FIELDDESC']
if ($debug) echoDebugMethod(__FILE__
,"static","OCSP_FORM::compat_setOCSP_DBMS_FIELDDESC();");
foreach(self::$dbmsFieldClassDesc as &$arr_dbRow)
$GLOBALS['OCSP']['DBMS_FIELDDESC']['C'][$arr_dbRow['FLD_CLASS']]=
$arr_dbRow;
$GLOBALS['OCSP']['DBMS_FIELDDESC']['T'][$arr_dbRow['FLD_TYPE']][]=
&$GLOBALS['OCSP']['DBMS_FIELDDESC']['C'][$arr_dbRow['FLD_CLASS']];
* clears the FieldClassDesc cache
if ($debug) echoDebugMethod(__FILE__
,"static","OCSP_FORM::clearFieldClassDescCache();");
* @var OCSP_FORM_BLOCK $myBlocks
* @var OCSP_FRMVIEW_LIST $myView
* @var OCSP_FRMCONTR_LIST $myControll
* @var OCSP_FORM_DBCONTROLL $myDBControll
* the current table object class
* @var DBMS_TABLE_OBJ $myTblObj
* the ajax object used by the fields
* @var OCSP_AJAXFORM $myAjaxObj
* index in self::instances_byId
* @var boolean $myFormValuesAreSet
* array with all tables the form uses
* note Index 0 is considered as master table
* the first table to load.
* if the tables are joined the order of adding to the join
* the array is populated by exploding $this->FRM_TABLES (,-seperated)
* db attributes stored in T_DBMS_FORM
* @var string $FRM_TABLES
* @var boolean $FRM_ISDEFLT
* @var int $FRM_SRCVERSION
* @var string $FRM_LAYOUT
* @var string $FRM_LSTGROUPS
* disable to check the form on ajax relaod
* @var array $myDBValues database representation of the form
* @var array $myFormDBCols (columns of T_DBMS_FORM to use in the object)
protected $myFormDBCols=
array('FRM_ID','FRM_NAME','FRM_TITLE','FRM_CLASS',
'FRM_TABLES','FRM_ISDEFLT','FRM_QUERY','FRM_JOIN',
'FRM_REVISION','FRM_SRCVERSION','FRM_LAYOUT','FRM_DEBUG','FRM_DESC','FRM_LSTGROUPS',
'FRM_DISABLEAJAXCHANGEFORM');
* include file for the table object
* @var string $tblObj_include
* class file of the table object
* @var string $tblObj_class
* @var array $layoutFields
* array [DBMS_FIELD->getKey()]:
* - [CSSCLASS] a css class to use for the table row <tr>
* - [CSSSTYLE] a css style to add inline to the row <td> / <th>
* - [USE_TH] boolean use <th> or <td> for the value
* - [TMPL] a template to parse
* - [ORDERBY] column(s) to add to sql sorting (if empty the field key is used)
* @var array $submitActions
* @var array $myErrors array of error messages array('LABEL','MSG')
* @var string $my_jsId a unique id of the form used to identify the form in the javascript array ocsp_frmList
* array of fields which have to been pass through to class
* if you need to add values to the form data on save
* without having it in the form available add it this array
* the fields will be passed encrypted and overwrites values
* @var array $myPassThroughFields
* are rights set for the form?
* alread loaded userrights from the db
* @var array $loadedUserRights
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* @param mixed $frmIdName
* @param global array $OCSP_CONF
* @return string (cache file path)
if ($debug) echoDebugMethod(__FILE__
,"static","OCSP_FORM::getCacheFileName($frmIdName)");
if (!empty($str_fileName)) {
return $str_cacheFile.
$str_fileName.
constant('OCSP_FORM::FORM_CACHE_FILEEXT');
ocsp_logError(__FILE__
,__LINE__
,"could not get chache file --$frmIdName--");
* @param mixed $frmIdName
* @param string $className
if ($debug) echoDebugMethod(__FILE__
,"static::","OCSP_FORM::get_existing_instance($frmIdName,$className)");
foreach(OCSP_FORM::$form_instances as $int_idx =>
$arr_instance)
if (intval($arr_instance['frmId']) ||
!empty($arr_instance['frmName']))
// only populated objects
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p>$int_idx: id: {$arr_instance['frmId']} name: {$arr_instance['frmName']}</p>");
if (($arr_instance['frmId']==
$frmIdName) ||
($arr_instance['frmName']==
$frmIdName)) {
if ($arr_instance['class']==
$className)
return $arr_instance['frmObj'];
$obj_found=
$arr_instance['frmObj'];
self::castObj(OCSP_FORM::$form_instances[$int_foundidx]['frmObj'],$className);
return OCSP_FORM::$form_instances[$int_foundidx]['frmObj'];
* @param string $className (if set overwrite 'FRM_CLASS' in cacheArr )
* @requires pcf_templates.phpinc
if ($debug) echoDebugMethod(__FILE__
,"static","OCSP_FORM::factory_from_cacheArr()","<pre>".
print_r($cacheArr['dbRow'],True).
"</pre>");
if (!isset
($cacheArr['dbRow']['FRM_ID']) ||
!intval($cacheArr['dbRow']['FRM_ID']))
ocsp_logError(__FILE__
,__LINE__
,"\$cacheArr['dbRow']['FRM_ID'] not set",E_ERROR);
if (!isset
($cacheArr['dbRow']['FRM_NAME']) ||
empty($cacheArr['dbRow']['FRM_NAME']))
ocsp_logError(__FILE__
,__LINE__
,"\$cacheArr['dbRow']['FRM_NAME'] not set",E_ERROR);
if (!isset
($cacheArr['FRM_CLASS']) ||
empty($cacheArr['FRM_CLASS']))
ocsp_logError(__FILE__
,__LINE__
,"\$cacheArr['FRM_CLASS'] not set",E_ERROR);
if (isset
($cacheArr['FRM_CLASSSRC']) &&
!empty($cacheArr['FRM_CLASSSRC']))
require_once $str_incFile;
ocsp_logError(__FILE__
,__LINE__
,"\$cacheArr['FRM_CLASSSRC'] not set",E_ERROR);
$className=
$cacheArr['FRM_CLASS'];
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"\$obj_form=new $className({$cacheArr['dbRow']['FRM_ID']},{$cacheArr['dbRow']['FRM_NAME']},$debug);");
$obj_form=
new $className($cacheArr['dbRow']['FRM_ID'],$cacheArr['dbRow']['FRM_NAME'],$debug);
$obj_form->setMyDBRow($cacheArr['dbRow'],$debug);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"returning ".
get_class($obj_form).
" ID: ".
$obj_form->getId().
" Name:".
$obj_form->getName());
* returns the form object with FRM_ID is $aId
* @param string $className (note need to be loaded before if not a standard openCSP form class)
* @param boolean $forceNew (do not check self::instances_byId)
* @global array $OCSP_CONF
static public function &factory_from_id($aId,$className=
'',$debug=
False,$forceNew=
False)
if ($debug) echoDebugMethod(__FILE__
,(isset
($this) ?
get_class($this) :
"direct call"),"OCSP_FORM::factory_from_id($aId,$className)");
$obj_ret=
NULL;return $obj_ret; // avoid warning
if ($obj_form=
self::get_existing_instance($aId,$className,$debug))
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"returning ".
get_class($o_tmp).
" ID: ".
$o_tmp->getId().
" Name:".
$o_tmp->getName());
if (empty($className)) $className=
'OCSP_FORM';
$o_tmp=
new $className($aId,'',$debug);
if ($debug) ocsp_logError(__FILE__
,__LINE__
,"could not factory $className",E_WARNING);
if ($o_frm=
$o_tmp->loadFromFileCache($aId,NULL,0.0,$debug))
self::castObj($o_frm,$className,$debug); // ensure the right class is set
if ($o_frm=
$o_tmp->loadFromDb($aId,NULL,0.0,$debug))
self::castObj($o_frm,$className,$debug); // ensure the right class is set
* returns the form object with FRM_NAME= $aName
* @global OCSP_FORM $OCSP_OBJ['FORMS']['BYID'][$o_tmp->getId()] used for memory cache of the form
* @global OCSP_FORM $OCSP_OBJ['FORMS']['BYNAME'][$o_tmp->getName()] used for memory cache of the form
* @param string $className (note need to be loaded before if not a standard openCSP form class)
* @param boolean $forceNew (do not check self::instances_byId)
static public function &factory_from_name($aName,$className=
NULL,$debug=
False,$forceNew=
False)
if ($debug) echoDebugMethod(__FILE__
,(isset
($this) ?
get_class($this) :
"direct call"),"OCSP_FORM::factory_from_name($aName,$className)");
if (empty($aName)) return False;
if ($obj_form=
self::get_existing_instance($aName,$className,$debug))
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"returning ".
get_class($o_tmp).
" ID: ".
$o_tmp->getId().
" Name:".
$o_tmp->getName());
if (empty($className)) $className=
'OCSP_FORM';
$o_tmp=
new $className(0,$aName,$debug);
if ($debug) ocsp_logError(__FILE__
,__LINE__
,"could not factory $className",E_WARNING);
if ($o_frm=
$o_tmp->loadFromDb(0,$aName,0.0,$debug))
self::castObj($o_frm,$className,$debug); // ensure the right class is set
* @requires pcf_md5.phpinc
if (isset
($_REQUEST['OCSP_FORM_CLASS']) &&
!empty($_REQUEST['OCSP_FORM_CLASS']))
//require_once __OCSP_PHPINCPATH__."common"._OCSP_DIRSEP_."pcf_md5.phpinc";
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"form class is ".
$str_className);
if (isset
($_REQUEST['OCSP_FORM_INC']) &&
!empty($_REQUEST['OCSP_FORM_INC']))
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"class include: ".
$str_incFile);
require_once $str_incFile;
if ($debug) ocsp_logError(__FILE__
,__LINE__
,"class $str_className not found");
$str_className=
'OCSP_FORM';
$str_className=
'OCSP_FORM';
if (isset
($_REQUEST['OCSP_FORM_SETTING_CRYPT']))
if (isset
($arr_frmSettings['ID']) &&
intval($arr_frmSettings['ID']))
$obj_ret =
self::factory_from_id(intval($arr_frmSettings['ID']),$str_className,$debug);
} else if (isset
($_REQUEST['DBMSFORMID']) &&
intval($_REQUEST['DBMSFORMID'])) {
$obj_ret =
self::factory_from_id(intval($_REQUEST['DBMSFORMID']),$str_className);
} else if (isset
($_REQUEST['OCSP_FORM_TBLOBJCLASS']) &&
!empty($_REQUEST['OCSP_FORM_TBLOBJCLASS'])) {
$obj_tblObj =
new $str_dbObjClass();
if (isset
($_REQUEST['FRMHTMLNAME']) &&
!empty($_REQUEST['FRMHTMLNAME']))
$obj_ret->setMyJsId(substr($_POST['FRMHTMLNAME'],4));
if ($debug) pcf_js_alert(__LINE__ .
"JsId set To" .
$obj_ret->getMyJsId());
echoDebugLine(__FILE__
,__LINE__
,"<p>\$arr_frmSettings: </p><pre>" .
print_r($arr_frmSettings,True) .
"</pre>");
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* returns an array of forms which fit's for $aTable
* @global array $OCSP_OBJ
if ($debug) echoDebugMethod(__FILE__
,"static","OCSP_FROM::findForm_listForTable(" .
$aTable .
")");
if ($obj_db =
$OCSP_OBJ['USER']->getMyDBObj())
$str_query =
"SELECT FRM_ID,FRM_NAME,FRM_DESC FROM T_DBMS_FORM";
$str_query .=
" WHERE FRM_TABLES LIKE '%" .
str_replace("'","%",$aTable) .
"%'";
$str_query .=
" ORDER BY FRM_ISDEFLT DESC";
if ($arr_ret =
$obj_db->queryArray($str_query,0,-
1))
* gets an html option list with all possible forms for $aTable
* @param int $selectedForm
if ($debug) echoDebugMethod(__FILE__
,"static","OCSP_FORM::findForm_getHTMLOptionList(" .
$aTable .
")");
if ($obj_db =
$OCSP_OBJ['USER']->getMyDBObj())
$str_query =
"SELECT FRM_ID,FRM_NAME,FRM_DESC FROM T_DBMS_FORM";
$str_query .=
" WHERE FRM_TABLES LIKE '%" .
str_replace("'","%",$aTable) .
"%'";
$str_query .=
" ORDER BY FRM_ISDEFLT DESC";
if ($arr_forms =
$obj_db->queryArray($str_query,0,-
1))
foreach($arr_forms as $arr_row)
$str_ret .=
"<option value=\"" .
$arr_row['FRM_ID'] .
"\"";
if ($arr_row['FRM_ID'] ==
$selectedForm)
$str_ret .=
" selected=\"selected\"";
$str_ret .=
" title=\"" .
str_replace("\"",""",$arr_row['FRM_DESC']) .
"\"";
$str_ret .=
">" .
$arr_row['FRM_NAME'] .
" (ID: " .
$arr_row['FRM_ID'] .
")</option>\n";
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'class' =>
get_class($this),
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* if $this->myDBObj is NULL a new connection to either
* the users db or the global database will be establisched
* @requires OCSP_DB.phpclass"
if (!$this->myDBObj->isConnected())
if (!$this->myDBObj->isConnected())
if (!$OCSP_OBJ['USRDB']->isConnected())
$OCSP_OBJ['USRDB']->connect();
$this->myDBObj=
&$OCSP_OBJ['USRDB'];
$this->myDBObj=
$OCSP_OBJ['USER']->getMyDBObj();
* @param OCSP_FORM_DBCONTROLL
* uses $OCSP_OBJ['DBCTRL'][get_class($this->myDBObj)] as cache
* @global array $OCSP_OBJ
* @return OCSP_FORM_DBCONTROLL
* @requires OCSP_FORM_DBCONTROLL.phpclass
if (!$this->getDBObj()) // to ensure we have $this->myDBObj set
require_once dirname(__FILE__
).
"/OCSP_FORM_DBCONTROLL.phpclass";
* returns the value of an object variable
if (isset
($this->{$varName})) return $this->{$varName};
* overwrite in child classes if get_class does not fit
if (intval($aId) ==
0) // copy form -> reset block id
foreach($arr_blocks as &$obj_block)
* if empty($this->my_jsId) it is set
* @return string (the js id of the form)
* returns the html form name
* returns the title of the form
* returns the post sub array name of the form fields
return "DBVAL_".
$this->getId();
* links a table object with the form
* @param DBMS_TABLE_OBJ $tblObj
* @param boolean $force (if False only $this->myTblObj is returned else it tries to instantiate a new object)
* @requires common/pcf_templates.phpinc
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Returning existing Object");
require_once $str_incFile;
echoDebugLine(__FILE__
,__LINE__
,"tblobj command: $str_cmd <br />Include: ".
$str_incFile);
ocsp_logError(__FILE__
,__LINE__
,"could not eval cmd: ".
$str_cmd,E_ERROR);
* returns the include file for the table object class
* @param string $className
// ------------------------------------------------------
// form global commands / actions
// ------------------------------------------------------
* get main commands of the form
* - js: execute a java script
* @param string $type ([ACTION|NEXT|RELOAD])
* sets a main cmmonad of the form
* - js: execute a java script
* @param string $type ([ACTION|NEXT|RELOAD])
* @return array (the unserialized value of FRM_JOIN)
* returns the language string
* @todo OCSP_FORM::getLangTxt() currently only DE is supported
if (isset
($GLOBALS['OCSP_FRMLANG']['DE'][$txt]))
return $GLOBALS['OCSP_FRMLANG']['DE'][$txt];
/*** ------------------------------------------------------------------------------------------- */
/*** ------------------------------------------------------------------------------------------- */
if (isset
($aRow[$str_col]))
$this->{$str_col}=
$aRow[$str_col];
if (isset
($aRow['FRM_TABLES']))
if (isset
($aRow['FRM_LAYOUT']) &&
!empty($aRow['FRM_LAYOUT']))
if (isset
($aRow['FRM_SUBMITACTION']) &&
(!empty($aRow['FRM_SUBMITACTION'])))
if (isset
($aRow['FRM_SRCVERSION']) &&
(intval($aRow['FRM_SRCVERSION']) <
4))
if (isset
($aRow['FRM_LNK_AFTERINSERT']) &&
(!empty($aRow['FRM_LNK_AFTERINSERT'])) &&
($aRow['FRM_LNK_AFTERINSERT'] !=
"index.php"))
$this->submitActions['AFTER']['FRM_MODE_NEW']=
$aRow['FRM_LNK_AFTERINSERT'];
if (isset
($aRow['FRM_LNK_AFTEREDIT']) &&
(!empty($aRow['FRM_LNK_AFTEREDIT'])) &&
($aRow['FRM_LNK_AFTEREDIT'] !=
"index.php"))
$this->submitActions['AFTER']['FRM_MODE_EDIT']=
$aRow['FRM_LNK_AFTEREDIT'];
if (isset
($aRow['FRM_LNK_AFTERDELETE']) &&
(!empty($aRow['FRM_LNK_AFTERDELETE'])) &&
($aRow['FRM_LNK_AFTERDELETE'] !=
"index.php"))
$this->submitActions['AFTER']['FRM_MODE_DELETE']=
$aRow['FRM_LNK_AFTERDELETE'];
if (isset
($this->{$str_col}))
$arr_dbRow[$str_col]=
$this->{$str_col};
$arr_dbRow[$str_col]=
NULL;
$arr_dbRow['FRM_LAYOUT'] =
NULL;
if (!isset
($arr_objVals['FRM_CLASS']))
$arr_dbRow['FRM_SUBMITACTION']=
NULL;
$arr_dbRow['FRM_SRCVERSION']=
4;
* returns a new form form the database
* @global OCSP_FORM $OCSP_OBJ['FORMS']['BYID'][$o_tmp->getId()] used for memory cache of the form
* @global OCSP_FORM $OCSP_OBJ['FORMS']['BYNAME'][$o_tmp->getName()] used for memory cache of the form
* @return OSCP_FORM_BASIC
function &loadFromDb($aId=
0,$aName=
"",$revision=
0.0,$debug)
$this->getDBObj($debug); // to ensure we have a db connection
$arr_Data=
$this->myDBObj->getArray("T_DBMS_FORM",array('FRM_ID' =>
intval($aId)),0,1,NULL,$debug);
if (!sizeof($arr_Data) &&
(!empty($aName)))
$arr_Data=
$this->myDBObj->getArray("T_DBMS_FORM",array('FRM_NAME' =>
$aName),0,1,NULL,$debug);
if (!empty($arr_Data['FRM_CLASS']))
self::castObj($o_tmp,$arr_Data['FRM_CLASS']);
if (isset
(OCSP_FORM::$form_instances[$this->myInstanceId]))
unset
(OCSP_FORM::$form_instances[$this->myInstanceId]);
* deletes a form and all dependencies
$str_cacheFile=
self::getCacheFileName($this->getId());
@rename($str_cacheFile,$str_cacheFile.
".bak");
$str_cacheFile=
self::getCacheFileName($this->getName());
@rename($str_cacheFile,$str_cacheFile.
".bak");;
$arr_delKey=
array('FRM_ID'=>
$this->getId());
$this->myDBObj->deleterows('T_DBMS_FORMFIELDS',$arr_delKey);
$this->myDBObj->deleterows('T_DBMS_FORMRIGHTS',$arr_delKey);
$this->myDBObj->deleterows('T_DBMS_FORMBLOCKS',$arr_delKey);
$this->myDBObj->deleterows('T_DBMS_FORM',$arr_delKey);
* stores a form object and all depending objects (blocks and fields) to the database
$arr_dbRow['FRM_UTIMESTAMP']=
time();
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"updateing existing form");
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"inserting new form");
unset
($arr_dbRow['FRM_ID']);
{ // to also have db default values loaded
foreach($arr_Data as $str_col =>
$mix_val)
$this->{$str_col}=
$mix_val;
ocsp_logError(__FILE__
,__LINE__
,"error reloading inserted form");
$o_block->setMyForm($this);
/*** ------------------------------------------------------------------------------------------- */
/*** ------------------------------------------------------------------------------------------- */
* returns the form export string (php array)
$str_ret .=
"\t'_BLOCKS' => array(\n";
foreach($arr_blocks as &$obj_block)
$str_ret .=
"\t\t'{$obj_block->getId()}' =>
array(\n
";
$str_ret .=
$str_tabs .
"'class' => \"" .
get_class($obj_block) .
"\",\n";
$str_ret .=
$str_tabs .
"'blockValues' => " .
$obj_block->getExportString();
$str_ret .=
"\t\t), // _BLOCK {$obj_block->getId()}\n
";
$str_ret .=
"\t), // _BLOCKS\n";
* imports the form from an array
* NOTE: does not save the form
if (isset
($impArray['FRM_ID'])) unset
($impArray['FRM_ID']);
if (isset
($impArray[$str_colName]) &&
!empty($impArray[$str_colName]))
foreach($arr_blocks as &$obj_block)
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"importing " .
sizeof($impArray['_BLOCKS']) .
" blocks");
foreach($impArray['_BLOCKS'] as $arr_block)
$this->myBlocks[$int_idx] =
new $arr_block['class']($this);
/*** ------------------------------------------------------------------------------------------- */
/*** ------------------------------------------------------------------------------------------- */
* deletes the form cache files
* returns a new form from the file cache
* @global OCSP_FORM $OCSP_OBJ['FORMS']['BYID'][$o_tmp->getId()] used for memory cache of the form
* @global OCSP_FORM $OCSP_OBJ['FORMS']['BYNAME'][$o_tmp->getName()] used for memory cache of the form
* @requires pcf_templates.phpinc
if (!empty($str_cacheDir)) {
echoDebugLine(__FILE__
,__LINE__
,"including ".
$str_cacheDir.
$aId.
".frm.cache");
include $str_cacheDir.
$aId.
".frm.cache";
@include $str_cacheDir.
$aId.
".frm.cache";
} else if (!empty($aName) &&
file_exists($str_cacheDir.
$aName.
".frm.cache")) {
echoDebugLine(__FILE__
,__LINE__
,"including ".
$str_cacheDir.
$aName.
".frm.cache");
include $str_cacheDir.
$aName.
".frm.cache";
@include $str_cacheDir.
$aName.
".frm.cache";
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"no cache File<br />".
$str_cacheDir.
$aId.
".frm.cache");
if ($arr_cache['CACHETS'] <
time() -
$GLOBALS['OCSP']['OBJCACHELIFETIME'])
// check the object class
require_once $str_incFile;
require_once dirname(__FILE__
).
"/".
$arr_cache['FRM_CLASS'].
".phpclass";
ocsp_logError(__FILE__
,__LINE__
,"form class ".
$arr_cache['FRM_CLASS'].
" not loaded");
eval
("\$o_tmp=new ".
$arr_cache['FRM_CLASS'].
"();");
@eval
("\$o_tmp=new ".
$arr_cache['FRM_CLASS'].
"();");
ocsp_logError(__FILE__
,__LINE__
,"form object (class: ".
$arr_cache['FRM_CLASS'].
") not instantiated");
if (!isset
($OCSP_OBJ['FORMS']['BYID'][$o_tmp->getId()]))
$OCSP_OBJ['FORMS']['BYID'][$o_tmp->getId()]=
$o_tmp;
$OCSP_OBJ['BYNAME'][$o_tmp->getName()]=
&$OCSP_OBJ['FORMS']['BYID'][$o_tmp->getId()];
return $OCSP_OBJ['FORMS']['BYID'][$o_tmp->getId()];
* writes the object to the file cache
* @requires pcf_directory.phpinc
if ($h_file=
fopen($str_cacheFile,'w'))
fwrite($h_file,"\$arr_cache=array($str_eol");
fwrite($h_file,"\n// ----------------------------- blocks ---------------------------- \n");
fwrite($h_file,"'arr_blocks'=>array($str_eol");
foreach($arr_blocks as &$obj_block)
fwrite($h_file,"'CACHETS'=>doubleval(".
time().
")$str_eol");
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"could not open cachefile: <br />".
$str_cacheDir.
"/".
$this->getId().
".frm.cache");
* @see OCSP_FORM::writeFieldDescToCache()
* @deprecated since pk-08-06-13
* writes field definition array (T_DBMS_FIELDDESC) to the cache
* - $GLOBALS['DBMS_FIELD_CLASSES']
* - $GLOBALS['DBMS_FIELD_DESC']
* @deprecated since pk-08-06-13
/*** ------------------------------------------------------------------------------------------- */
/*** ------------------------------------------------------------------------------------------- */
$this->getTables(); // ensure $this->myTables is set
if ($str_tbl !=
$aTbl) $arr_tmp[]=
$str_tbl;
* adds a table to the form
function addTable($aTable,$aBlockId=
0,$debug=
False)
if (!$obj_block=
$this->getBlock($aBlockId))
ocsp_logError(__FILE__
,__LINE__
,"Block $aBlockId not found in form");
if ($obj_block->addTable($aTable,$debug))
* register a table for use with the form
* unlicke add table the columns are not loaded
* removes a table an all table columns from the form
if ($arr_flds=
$this->getFields($aTable,$debug))
foreach($arr_flds as &$obj_fld)
* returns an array of all primary key's found in the form
* the return array has the following structure:
* array [table][] => &fieldobj
foreach ($arr_fields as &$obj_field)
if ($obj_field->isPrimaryKey($debug))
$arr_ret[$obj_field->getTable()][]=
$obj_field;
* returns the autoincrement field of $tbl
if ($arr_fields=
$this->getFields($tbl,$debug))
foreach($arr_fields as &$obj_field)
if ($obj_field->isAutoInc()) return $obj_field;
/*** ------------------------------------------------------------------------------------------- */
/*** ------------------------------------------------------------------------------------------- */
* returns the number of blocks
* @return OCSP_FORM_BLOCK
function &getBlock($blockId,$debug=
False)
if ($obj_block->getId()==
$blockId) return $obj_block;
ocsp_logError(__FILE__
,__LINE__
,"could not load block $blockId");
* returns the first block with $blockName as Name
* @param string $blockName
* @return OCSP_FORM_BLOCK
if ($obj_block->getName()==
$blockName) return $obj_block;
ocsp_logError(__FILE__
,__LINE__
,"could not load block $blockId");
* adds a new block to the form and returns the block
if (!isset
($_POST[$arrName]))
$arr_Data=
$_POST[$arrName];
if (!isset
($arr_Data['FRB_NAME']))
ocsp_logError(__FILE__
,__LINE__
,"\$_POST[$arrName]['FRB_NAME'] is not set");
* adds a new block to the form and returns the block
* @param array $blockData
function addNewBlock($blockData,$colNames=
NULL,$debug=
False)
$this->getDBObj(); // ensure $this->myDBObj isset
$str_query =
"SELECT COUNT(*) FROM T_DBMS_FORMBLOCKS ";
$str_query.=
" WHERE FRM_ID=".
$this->getId();
$str_query.=
" AND UPPER(FRB_NAME)=".
$this->myDBObj->qs_getSlashedValue(strtoupper(trim($blockData['FRB_NAME'])));
ocsp_logError(__FILE__
,__LINE__
,"Name: ".
$blockData['FRB_NAME'].
" already in use");
// check form is populated
$this->getBlocks($debug); // ensure the existing blocks are loaded
if (isset
($arr_Data['FRB_SORTORDER']) &&
intval($blockData['FRB_SORTORDER']))
$str_query=
"UPDATE T_DBMS_FORMBLOCKS SET FRB_SORTORDER=FRB_SORTORDER+1";
$str_query.=
" WHERE FRM_ID=".
$this->getId();
$str_query.=
" AND FRB_SORTORDER >= ".
intval($blockData['FRB_SORTORDER']);
$this->myDBObj->executeCmd($str_query);
$obj_block->setOrderNr(intval($blockData['FRB_SORTORDER']));
unset
($blockData['FRB_SORTORDER']);
$str_query=
"SELECT COUNT(*) FROM T_DBMS_FORMBLOCKS ";
$str_query.=
" WHERE FRM_ID=".
$this->getId();
$obj_block->setOrderNr(intval($this->myDBObj->getOne($str_query))+
1);
$arr_showCols=
$obj_block->getShowFields();
foreach($arr_showCols as $col =>
$lab)
if (isset
($blockData[$col]))
if (!empty($blockData[$col]))
$obj_block->setMyDBColValue($col,True);
$obj_block->setMyDBColValue($col,False);
$obj_block->setMyDBColValue($col,False);
foreach($blockData as $col =>
$val)
$obj_block->setMyDBColValue($col,$val);
$obj_block->storeToDb($debug); // to have an id
foreach($colNames as $str_colName)
if ($obj_field=
$this->getField($str_colName))
$obj_block->addFieldObj($obj_field,$debug);
ocsp_logError(__FILE__
,__LINE__
,"Field: ".
$str_colName.
" not found");
ocsp_logError(__FILE__
,__LINE__
,"OCSP_FORM::addNewBlockFromPost()".
$this->myDBObj->errorMsg('could not store block'));
* link a block from an other form
* @todo OCSP_FORM::linkBlock() inline SQL
$this->getBlocks($debug); // ensure the existing blocks are loaded
$str_query=
"SELECT * FROM T_DBMS_FORMBLOCKS WHERE FRB_ID=".
intval($blockId);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"loading Block: $str_query");
if ($arr_blockData=
$this->myDBObj->quickQuery($str_query))
unset
($arr_blockData['FRB_ID']);
$arr_blockData['FRM_ID']=
$this->getId();
$arr_blockData['FRB_ORIG_FRB_ID']=
$objFromBlock->getId();
$arr_blockData['FRB_ORIG_FRM_ID']=
$objFromForm->getId();
if ($arr_blockData['FRB_ID']=
$this->myDBObj->insertArray('T_DBMS_FORMBLOCKS',$arr_blockData))
$arr_fields=
$objFromBlock->getFields(-
1,$debug);
foreach($arr_fields as $objField)
if ($obj_frmField=
$this->getField($objField->getKey()))
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p>".
$objField->getKey().
" in form</p>");
//$obj_newBlock->addFieldObj($obj_frmField,$debug);
if ($obj_oldBlock=
$obj_frmField->getMyBlock())
$obj_oldBlock->removeFieldObj($obj_frmField,$debug);
$obj_newBlock->storeFldToDb($obj_frmField,$debug,True);
ocsp_logError(__FILE__
,__LINE__
,"could not load block with id: $blockId",E_WARNING);
* link a block from an other form
* @todo OCSP_FORM::linkBlock() inline SQL
$this->getBlocks($debug); // ensure the existing blocks are loaded
$str_query=
"SELECT * FROM T_DBMS_FORMBLOCKS WHERE FRB_ID=".
intval($blockId);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"loading Block: $str_query");
if ($arr_blockData=
$this->myDBObj->quickQuery($str_query))
unset
($arr_blockData['FRB_ID']);
$arr_blockData['FRM_ID']=
$this->getId();
$arr_blockData['FRB_ORIG_FRB_ID']=
0;
$arr_blockData['FRB_ORIG_FRM_ID']=
0;
if ($arr_blockData['FRB_ID']=
$this->myDBObj->insertArray('T_DBMS_FORMBLOCKS',$arr_blockData))
$arr_fields=
$objFromBlock->getFields(-
1,$debug);
foreach($arr_fields as $objField)
// check if the fields table is used in the form
$str_fldTbl =
$objField->getTblAlias();
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Checking Table: " .
$str_fldTbl);
if ('PAGEOBJVAL' ==
$str_fldTbl)
if ('__NO-DBFIELD__' !=
$str_fldTbl)
// the table is not used in the form omit field
if ($obj_frmField=
$this->getField($objField->getKey()))
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p>".
$objField->getKey().
" in form</p>");
$obj_fldOriBlock=
$obj_frmField->getMyBlock();
$obj_fldOriBlock->removeFieldObj($obj_frmField,$debug);
$objField->setMyForm($this);
$objField->setMyBlock($obj_blockNull);
$obj_newBlock->addFieldObj($objField);
ocsp_logError(__FILE__
,__LINE__
,"could not load block with id: $blockId",E_WARNING);
* loads the form blocks from the database
* @todo OCSP_FORM::loadBlocksFromDb() only Class OCSP_FORM_BLOCK is implemented
$this->getDBObj($debug); // to ensure we have a db connection
$this->myBlocks=
array(); // unset all blocks
if ($arr_Data=
$this->myDBObj->getArray("T_DBMS_FORMBLOCKS",array('FRM_ID'=>
$this->getId()),0,0,'FRB_SORTORDER')) {
$i_sortNr=
1;$arr_resort=
array();
foreach($arr_Data as $arr_row)
if (intval($arr_row['FRB_SORTORDER']) !=
$i_sortNr)
$str_cmd =
"UPDATE T_DBMS_FORMBLOCKS SET FRB_SORTORDER=".
$i_sortNr;
$str_cmd.=
" WHERE FRB_ID=".
$arr_row['FRB_ID'];
$str_cmd.=
" AND FRM_ID=".
$this->getId();
$this->myDBObj->executeCmd($str_cmd);
$this->myBlocks[$i_sortNr]->setOrderNr($i_sortNr);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"no blocks loaded from T_DBMS_FORMBLOCKS");
* marks a block as deleted (changes FRM_ID to $this->getId() * (-1))
if (!intval($blockId)) return False;
if (!($obj_block=
$this->getBlock($blockId)))
$str_cmd =
"UPDATE T_DBMS_FORMFIELDS SET FRB_ID=0";
$str_cmd.=
" WHERE FRB_ID=".
$obj_block->getId();
$str_cmd.=
" AND FRM_ID=".
$this->getId();
$this->getDBObj(); // ensure $this->myDBObj is set
$this->myDBObj->executeCmd($str_cmd);
$str_cmd=
"UPDATE T_DBMS_FORMBLOCKS SET FRM_ID=".
($this->getId()*
(-
1)).
", FRB_NAME=".
$this->myDBObj->qs_getSlashedValue($obj_block->getId().
"_".
$obj_block->getName());
$str_cmd.=
" WHERE FRB_ID=".
$obj_block->getId();
$str_cmd.=
" AND FRM_ID=".
$this->getId();
$this->myDBObj->executeCmd($str_cmd);
// -------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------
* returns the number of fields in the form
foreach($arr_blocks as &$obj_block)
* returns an array of fields
* @param string $aTable (empty to get all fields)
* @param form mode (-1 == all fields)
* @version pk-08-11-06 ($frmMode added)
function getFields($aTable=
"",$debug=
False,$frmMode = -
1)
foreach($arr_blocks as &$o_block)
$arr_bFields=
$o_block->getFields($frmMode,$debug);
foreach($arr_bFields as &$o_field)
if (empty($aTable) ||
($o_field->getTable()==
$aTable))
$arr_ret[$o_field->getKey()]=
&$o_field;
* @param string $aFldName
* @param string $aTable (empty to search in all tables)
* @param int $aBlockId (-1 to search in all blocks)
* @version pk-08-07-12 (OBJVALS_)
function &getField($aFldName,$aTable=
"",$aBlockId=-
1,$debug=
False)
if (empty($aTable) &&
strstr($aFldName,"."))
$str_searchFldKey =
$aFldName;
list
($aTable,$str_searchFldName)=
explode(".",$aFldName,2);
$str_searchFldName =
$aFldName;
if (!empty($aTable) &&
(substr($aTable,0,8) ==
"OBJVALS_")) // <pk-08-07-12 />
// table alias was used and object value
$str_searchTable =
substr($aTable,8) .
"_OV";
$str_searchTable =
$aTable;
if ($o_block=
$this->getBlock($aBlockId,$debug))
return $o_block->getField($str_searchFldName,$str_searchTable,$str_searchFldKey);
foreach($arr_blocks as &$o_block)
if ($obj_ret=
$o_block->getField($str_searchFldName,$str_searchTable,$str_searchFldKey))
* changes the class of a field object
* @param string $className
if (!($obj_fld=
$this->getField($fldKey)))
if (get_class($obj_fld)==
$className) // nothing to do
ocsp_logError(__FILE__
,__LINE__
,$className.
" not defined",E_ERROR);
$str_cmd=
"\$o_tmp=new $className();";
//echo "$str_cmd\n".get_class($o_tmp)."\n$className\n";
$o_tmp->setObjVarsFrom($obj_fld,$debug);
$obj_block=
$o_tmp->getMyBlock();
$obj_block->storeFldToDb($o_tmp,$debug);
$obj_block->loadMyFieldsFromDb();
* NOTE: does not delete the database column of this field
* NOTE: does not store the form this has to be done outside
if ($obj_field=
$this->getField($fldKey,"",$blockId,$debug))
$obj_field->markDeleted();
* creates the field column in the database
* @param mixed $filed (name or object)
ocsp_logError(__FILE__
,__LINE__
,"could not instatiate dbControll",E_ERROR);
* foctory a new field object
* @param string $fldClass
* @param array $fieldValues
function factory_field($fldName,$fldClass=
'',$dbDesc=
array(),$fieldValues=
array(),$debug=
False)
if ($debug) echoDebugMethod(__FILE__
,get_class($this),"OCSP_FORM::factory_field($fldName,$fldClass)","\$dbDesc:<pre>".
print_r($dbDesc,True).
"</pre>fieldValues:<pre>".
print_r($fieldValues,True).
"</pre>");
$obj_field =
new $fldClass((isset
($dbDesc['TABLE']) ?
$dbDesc['TABLE'] :
""),$fldName,$dbDesc);
$fieldValues['myName']=
$fldName;
$fieldValues['dbDesc']=
$dbDesc;
$obj_field->setObjectVars($fieldValues,$debug);
* @param string $aFldName
* @param string $scope @see DBMS_FIELD::setHidden()
function hideField($aFldName,$aTable=
"",$scope=
"all",$aBlockId=-
1,$debug=
False)
if ($obj_field=
$this->getField($aFldName,$aTable,$aBlockId,$debug))
$obj_field->setHidden($scope);
* returns an array with the primary key fields
if ($arr_fields =
$this->getFields($aTable,$debug))
foreach($arr_fields as &$obj_field)
if ($obj_field->isPrimaryKey())
/** -------------------------------------------------------------------------------------------
* -------------------------------------------------------------------------------------------
* returns a layout field (added into the tag)
* - FRMLST_ADDBEFORELINKS
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* instantiates a new class if $this->myControl not type of $contrClass
* NOTE the class must exists or have it's code in __FILE__
* @param string $viewClass
function &getViewObj($viewClass=
"OCSP_FRMVIEW",$debug=
False)
require_once dirname(__FILE__
).
"/".
$viewClass.
".phpclass";
ocsp_logError(__FILE__
,__LINE__
,"ViewClass: $viewClass does not exist");
eval
("\$this->myView=new $viewClass(\$this);");
@eval
("\$this->myView=new $viewClass(\$this);");
* @param string $viewClass
* @return OCSP_FRMVIEW_LIST
function &getListView($viewClass=
"OCSP_FRMVIEW_LIST",$debug=
False)
if (empty($viewClass)) $viewClass=
"OCSP_FRMVIEW_LIST";
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* alias for $this->getControl()
* @deprecated since pk-08-11-20
* alias for $this->getControlObj()
* @param string $contrClass
* @deprecated since pk-08-11-20
* instantiates a new class if $this->myControl not type of $contrClass
* NOTE the class must exists or have it's code in __FILE__
* @param string $contrClass
function &getControlObj($contrClass=
"OCSP_FRMCONTR",$debug=
False)
ocsp_logError(__FILE__
,__LINE__
,"ControllClass: $contrClass does not exist",E_ERROR);
$arr_contrValues=
$this->myControl->getObjectValues($debug);
$str_cmd=
"\$this->myControl=new $contrClass(\$obj_frmObj,".
($debug ?
"True" :
"False").
");";
$this->myControl->setObjectValues($arr_contrValues,$debug);
* NOTE also changes the controll in $this->myView
* and sets the view in $aControll if $sync is True
* @param OCSP_FRMCONTR $aControl
public function setControl(&$aControl,$sync=
True, $debug=
False)
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"syncing view and controll");
* @param OCSP_FRMCONTR $aControl
* @deprecated since pk-08-12-03
public function setControll(&$aControl,$sync=
True,$debug=
False)
* if $contrClass is not set to "NO" a controll object will be created
* if none exists ($this->myControl) is empty
* if $contrClass is set to "NO" $this->myControl is returned as is
* without checking that we
* @param string $contrClass
* @return OCSP_FRMCONTR_LIST
if (empty($contrClass)) $contrClass=
"OCSP_FRMCONTR_LIST";
if ($contrClass ==
"NO") {
* adds a pass-through field
* returns the pass-through fields array
* @return $this->myPassThroughFields;
* returns form command fields
* commands needed in subclasses to validate submitdata
* this is used in OCSP_FRMCONTR_FORM::getFormCmdFields()
* NOTE: only added if form class != OCSP_FORM
// --------------------------------- data validation --------------------------------
* @abstract for child objects to init on checkSubmitData
* @param array $frmSettings
* @param string $dataArrName
* @param array $frmValues
* sets the tableobject class and include from $dataArr and
* tries to instantiate by calling $this->getMyTblObj
* if class is set in $dataArr and it could not be instantiated False is returned
* @param array $dataArr (normaly $_POST)
if (isset
($dataArr['OCSP_FORM_TBLOBJCLASS']) &&
!empty($dataArr['OCSP_FORM_TBLOBJCLASS']))
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p>table object <strong>".
$this->tblObj_class.
"</strong> set in \$$dataArr</p>");
* @param string $method (POST|GET)
* @param string $contrClass (sub)class Name of OCSP_FRMCONTR
* @return boolean (True if no error found)
if (!isset
($arr_values['OCSP_FORM_SETTING_CRYPT']))
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"settings: <pre>".
print_r($arr_settings,True).
"</pre>");
$str_dataArrName=
"DBVAL_".
$arr_settings['ID'];
if (isset
($arr_values['PASSTHROUGH']) &&
is_array($arr_values['PASSTHROUGH']))
foreach($arr_values['PASSTHROUGH'] as $str_col =>
$str_serVal)
if (is_array($arr_values[$str_dataArrName]))
if (isset
($arr_values['b64_PASSTHROUGH']) &&
!empty($arr_values['b64_PASSTHROUGH']))
foreach($arr_passThrough as $str_col =>
$mix_val)
if (!isset
($arr_values['DELKEY']) ||
empty($arr_values['DELKEY']))
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"no data submitted");
$arr_values[$str_dataArrName]['DELKEY']=
$arr_values['DELKEY'];
if (!isset
($arr_values[$str_dataArrName]) ||
!is_array($arr_values[$str_dataArrName]))
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"no data submitted");
// only returns False if classname is in $arr_values and can not be instantiated
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"could not instanciate " .
$arr_values['OCSP_FORM_TBLOBJCLASS']);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<h3>After table set</h3><pre>" .
print_r($arr_values,True) .
"</pre>");
$this->myControl->setFilter($arr_settings['FILTER']);
if (isset
($arr_values['FRMTARGET']) &&
!empty($arr_values['FRMTARGET']))
if (isset
($arr_values['FRMACTION']) &&
!empty($arr_values['FRMACTION']))
foreach($arr_settings['FILTER'] as $str_col =>
$mix_val)
if (!isset
($arr_values[$str_dataArrName][$str_col]) ||
empty($arr_values[$str_dataArrName][$str_col]))
$arr_values[$str_dataArrName][$str_col]=
$mix_val;
return $this->myControl->validateSubmit($arr_settings['MODE'],$arr_values[$str_dataArrName],$debug);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* - (OCSP_FRMVIEW_LIST) VIEWOBJ
* - (OCSP_FRMCONTR_LIST) CONTROBJ
* - (array) CONTRBUTTONS (['C'] => command ['I'] => icon tag)
* - (array) FOOTERCMDS (['name'] => html)
* @param array $settings (array of settings to list view and controll)
* @return int (number of rows to show)
* @version pk-08-01-28 (CONTRROWCMD,CONTRBUTTONS added)
if (isset
($settings['VIEWOBJ']) &&
pcf_is_instance_of($settings['VIEWOBJ'],'OCSP_FRMVIEW'))
$this->myView=
&$settings['VIEWOBJ'];
$this->myView->setMyForm($this);
$this->getListView((isset
($settings['VIEWCLASS']) ?
$settings['VIEWCLASS'] :
""),$debug);
if (isset
($settings['CONTROBJ']) &&
pcf_is_instance_of($settings['CONTROBJ'],'OCSP_FRMCONTR'))
$this->getListControll((isset
($settings['CONTRCLASS']) ?
$settings['CONTRCLASS']:
""),$debug);
if (isset
($settings['LISTQUERY']))
$this->myControl->setListQuery($settings['LISTQUERY']);
if (isset
($settings['FILTER']) &&
is_array($settings['FILTER']))
$this->myControl->setFilter($settings['FILTER']);
if (isset
($settings['LSTGROUPS']) &&
is_array($settings['LSTGROUPS']))
foreach($this->listGroups as $str_col =>
$arr_def)
if (isset
($settings['LSTGROUPS'][$arr_def]))
unset
($settings['LSTGROUPS'][$arr_def]);
foreach($this->listGroups as $str_col =>
$arr_def)
$str_orderBy.=
(isset
($arr_def['ORDERBY']) ?
$arr_def['ORDERBY'] :
$str_col).
",";
if (isset
($settings['ORDERBY']) &&
!empty($settings['ORDERBY']))
$this->myControl->setOrderBy($str_orderBy.
$settings['ORDERBY']);
} else if (!empty($str_orderBy)) {
if (isset
($settings['OFFSET'])) $this->myControl->setOffset(intval($settings['OFFSET']));
if (isset
($settings['LIMIT'])) $this->myControl->setLimit(intval($settings['LIMIT']));
if (isset
($settings['CONTRROWCMD']) &&
is_array($settings['CONTRROWCMD']))
foreach($settings['CONTRROWCMD'] as $str_event =>
$str_cmd)
$this->myControl->setRowCmd($str_event,$str_cmd);
if (isset
($settings['CONTRBUTTONS']) &&
is_array($settings['CONTRBUTTONS']))
foreach($settings['CONTRBUTTONS'] as $str_btn =>
$mix_btnDev)
$this->myControl->addCmdButton($str_btn,$mix_btnDev['C']);
if (isset
($mix_btnDev['I']))
$this->myView->setButtonTag($str_btn,$mix_btnDev['I']);
$int_pos =
(isset
($mix_btnDev['POS']) ?
intval($mix_btnDev['POS']) :
1);
$this->myView->setButtonPos($str_btn,$int_pos);
$this->myControl->addCmdButton($str_btn,$mix_btnDev);
if (isset
($settings['FOOTERCMDS']) &&
is_array($settings['FOOTERCMDS']))
$this->myControl->setFooterCmdArr($settings['FOOTERCMDS']);
// <pk-08-05-30> session settings
$str_lstKey.=
(isset
($settings['LISTQUERY']) ?
$settings['LISTQUERY'] :
"");
$str_lstKey.=
(isset
($settings['FILTER']) ?
serialize($settings['FILTER']) :
"NO FILTER");
$settings['FRM_ID'] =
$this->getId();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* creates an OCSP_AJAXFORM for the form
* @param OCSP_AJAX $aAjaxFrmObj
* return if the form can be changed on an relaod
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* @param boolean $fieldsToo
* @todo clear field errors if $fieldsToo
foreach($arr_flds as &$obj_fld)
* returns if the form has errors
if (isset
($this->errors['ERROR'])) return $this->errors['ERROR'];
* adds an error to this::errors
* @param mixed $aError either an array with LABEL and MSG values or only the message if empty only $this->errors['ERROR'] is set to True
function setError($aError,$fld=
"",$debug=
False) {
$this->errors['ERROR']=
True;
} else if (!empty($aError)) {
$arr_Error=
array('LABEL'=>
"FORMULAR",'MSG'=>
$aError);
* returns the form errors
* @param boolean $withFields if True the field errors are also included
* @todo OCSP_FORM::getErrors() only FRM_DATATYPE_STRING implemented now
function getErrors($withFields=
False,$returnType=
FRM_DATATYPE_STRING,$debug=
False)
$str_ret.=
$str_sep.
$arr_Error['LABEL'].
" ".
$arr_Error['MSG'];
foreach($arr_flds as &$obj_fld)
$str_ret.=
$str_sep.
$obj_fld->getLabel().
" ".
$obj_fld->getErrorMsg();
* returns an array with all fields having an error
foreach($arr_flds as &$obj_field)
$i=
$obj_field->getOrderNr();
while(isset
($arr_ret[$i])) $i++
;
$arr_ret[$i]=
&$obj_field;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$str_query =
"SELECT COUNT(*) FROM T_DBMS_FORMRIGHTS WHERE FRM_ID = " .
$this->getId();
* loads the right settings from T_DBMS_FORMRIGHTS
* NOTE rights are only checked if a row is found in T_DBMS_FORMRIGHTS
$str_query =
"SELECT MAX({$str_col}) FROM T_DBMS_FORMRIGHTS";
$str_query.=
" WHERE FRM_ID = " .
$this->getId();
$str_query.=
" AND GRP_ID IN (" .
$str_groups .
")";
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Query: " .
$str_query);
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"no rights set for the form");
* returns if the current user is allowed to open the form readonly
* NOTE rights are only checked if a row is found in T_DBMS_FORMRIGHTS
* returns if the current user is allowed to open the form readonly
* NOTE rights are only checked if a row is found in T_DBMS_FORMRIGHTS
* returns if the current user is allowed to open the form readonly
* NOTE rights are only checked if a row is found in T_DBMS_FORMRIGHTS
* returns if the current user is allowed to open the form readonly
* NOTE rights are only checked if a row is found in T_DBMS_FORMRIGHTS
* returns if the current user is allowed to open the form readonly
* NOTE rights are only checked if a row is found in T_DBMS_FORMRIGHTS
* returns if the current user can save the form in the current mode
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* returns the html code for list from a query
* if $query is empty it is generated with:
* $query="SELECT ".$this->getList_SQLFieldLst().$this->getFromStmt();
* NOTE: use getList_SQLFieldLst() in the select statement if
* you have a LEFT JOIN to get the right fields and
* - FRMLST_TABLEADD (<table $this->FRMLST_TABLEADD>)
* - FRMLST_TRADD (<tr $this->FRMLST_TRADD[($rowNr % 2)] >)
* - FRMLST_TDADD (<td $this->FRMLST_TDADD >)
* @param int $nofRows return the number of rows processed
* @param string $query if empty the query is generated
* @global array $OCSP_OBJ
function getHTMLLstFromQuery(&$nofRows,$query=
"",$links=
NULL,$sortLnk=
NULL,$limit=
0,$offset=
0,$debug=
False)
$str_ret=
"\n<!-- old style form call -->\n";
foreach($links as $str_cmd =>
$arr_detail)
if (isset
($arr_detail['A']) &&
(!empty($arr_detail['A'])))
$this->myControl->addCmdButton($str_cmd,$arr_res[1]);
//$str_ret.="<pre>".htmlspecialchars(print_r($arr_res,True))."</pre>";
if (isset
($arr_detail['TEXT'])) {
$this->myView->setButtonTag($str_cmd,$arr_detail['TEXT']);
$str_ret.=
$this->myView->getList($debug);
Documentation generated on Thu, 08 Jan 2009 17:45:52 +0100 by phpDocumentor 1.4.0a2