Source for file DBMS_FIELD.phpclass
Documentation is available at DBMS_FIELD.phpclass
* Class file DBMS_FIELD.phpclass
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: DBMS_FIELD.phpclass,v 1.54 2008/12/04 16:02:28 peterkrebs Exp $
require_once __OCSP_PHPINCPATH__.
"db".
_OCSP_DIRSEP_.
"db.phpinc";
* @const string DBMS_NO_DBFIELD used for fields with no table
if (!defined('DBMS_NO_DBFIELD')) define ('DBMS_NO_DBFIELD',"__NO-DBFIELD__");
if (!defined('DMBS_FIELD_DEFAULT_SIZE')) define('DMBS_FIELD_DEFAULT_SIZE',30);
* class to handle a form field
* @project Open CSP-Management
* @author Peter Krebs <pitlinz@sourceforge.net>
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version pk-03-12-13 function getValue added
* @version pk-05-11-13 showQuery added
* @version pk-06-01-19 $lstLabel added
* @version pk-06-11-15 changes in showQuery
* @version pk-07-03-01 ajax
* @version pk-08-09-08 extJS
* @version $Id: DBMS_FIELD.phpclass,v 1.54 2008/12/04 16:02:28 peterkrebs Exp $
// ###########################################################
// OBJECT (CONST) VAR DECLARATION
// ###########################################################
// ~~~~~~~~~~~~~~~~~~~~~~~~~~ static ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* source file of the class
* @staticvar string $classSrcFile
// ~~~~~~~~~~~~~~~~~~~~~~~~~~ aggregations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* @var OCSP_FORM_BLOCK $myBlock
* @var OCSP_FRMVIEW $myView
* @var OCSP_FRMCONTR $myControll
// ~~~~~~~~~~~~~~~~~~~~~~~~~~ attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* @var int $myFrmId id of the form the field belongs to
* @var int $myBlockId id of the form block the field belongs to
* @var string $myModuleKey
* @var boolean $myDeleteFlag
* DOM Id of the field (this MUST NOT be stored)
* @var string myTable name of the db table of the field
* alias of the table in a join
* @var string myTableAlias
* @var string myName column name in the table
* @var string $defaultValue
* @var bool $enableEditIfEmpty can the field be edited if the field is empty and not $enableEdit ?
* @var bool $isSearchable
* @var string $toolTip if is set a dialog box is linked with the label showing the toolTip
* @var int $size default value of the size
* @var int maxlength default value of maxlength
* @var string $addTag htmlcode to add in fields input col
* @var bool $hideAddTag_ro hide addTag in readonly view
* @var $labeltd_add htmlcode to add in the <td > tag of the label
* @var $labelcol_hide hide labelcolumn and set fieldcol rowspan=2
* @var $fieldtd_add htmlcode to add in the <td > tag of the field
* @var bool $allowNull is only used if db desc allows null
* @var string $nullErrMsg error message to set if value is null
* @var string $errMsg current ErrorMsg of the field if empty the field does not have an error
* as we need the $arrName nearly everywhere it is defined as object var
* @var string $myDataArrName
* the default value for $myDataArrName
* @var string $ps_defaultDataArrName
* url to open for field help window if not empty a ? icon
* is added to the label and linked with the url as popup
* fieldkey of the show group
* @var bool $fldDbgGetValue debug getValue Method
* @var string $regexcheck_pattern
* @var string $regexErrMsg
* @var boolean $trimValue
* hide the file in read only mode
* hide is used to not have to update
* @var boolean $showReadOnly
* @var int $myCurrentMode
* @var boolean $lstDisableLinks do not link list cell
* @var array $lstLink link col ('A' => <a ....>, 'TEXT' => Button)
* @var int $srcVersion current version of the source to discover old version serialized object in the database
* @var boolean $toolTipAsTitle
* @var boolean $searchGroup_allowAll add NULL in getTableValSelect()?
* @var boolean $showQasHidden if True the field is echoed hidden showQuery don't fit else field is not echoed
* @since since pk-06-11-15
* @var int $showGroup the user must be member of this group (id) to see the field
* @var boolean $exportCSV
* @var array $ajaxNotifyLst a list of fields and commands to notify onChange
* @var boolean $ajaxDebug
* xtype to use in the extJS framework for the field
* @var string $extJSxType
* extJS configuration options
// --------------------------------------------------------
// --------------------------------------------------------
* @param string $aTable name of the table where the field is a column
* @param string $aName name of the table column
* @param array $aDesc database column description
* @param int $sOrder sort order
* @param string $aLabel Label of the field
* @param string $aAlias db table alias in a join
* @version pk-04-10-05 no params required
function DBMS_FIELD ($aTable=
NULL,$aName=
NULL,$aDesc=
NULL,$sOrder=
99999,$aLabel=
"",$aAlias=
NULL,$aFormId=
0) {
if (isset
($aDesc['PRIMARY_KEY']) &&
$aDesc['PRIMARY_KEY']) { // <pk-06-09-21 /> E_ALL
if ($aDesc['AUTO_INCREMENT'])
$this->allowNull =
(isset
($this->dbDesc['NULL']) ?
$this->dbDesc['NULL'] :
True); // <pk-06-12-01 /> E_ALL
// --------------------------------------------------------
// --------------------------------------------------------
* returns the source file of the class
* - $GLOBALS['PROJECT']['PATH']
* - __OCSP_PHPINCPATH__ (if not in project path)
* @version pk-05-12-01 compleate rewrite of the method
if ($debug) echo
"<p><b>DBMS_FIELD::getSourceFile(...)</b> (".
get_class($this).
")";
// file named like class seams to be ok
if ($debug) echo
"<blockquote><p>filename is class name</p></blockquote>";
} else if (!empty($s_ret) &&
($s_ret != __FILE__
)) {
// classSrcFile is set somewhere child class
if ($debug) echo
"<blockquote><p>filename not ../DBMS_FIELD.phpclass</p></blockquote>";
// now we are in trubles where is the class loaded from?
// hope it's somewhere in the path or the object dealing with this information knows what to do
if ($debug) echo
"<blockquote><p>filename not set return className: ".
strtoupper(get_class($this)).
".phpclass</p></blockquote>";
* returns an 2 dimensional array of object data
* - $ret['OBJDESC'] -> discription of the object
* - $ret['OBJVAL'] -> get_object_vars($this)
if ($debug) echo
"<p><b>DBMS_FIELD::getObjectData(...)</b> (".
get_class($this).
")</p>";
* returns an array of the object vars
* see also php function get_object_vars
if ($debug) echo
"<p><b>DBMS_FIELD::getObjectVars(...)</b> (".
get_class($this).
")</p>";
// <pk-07-08-04> remove linked objects and ensure the id's are set
$a_ret['myFrmId']=
$this->myForm->getId();
$a_ret['myBlockId']=
$this->myBlock->getId();
unset
($a_ret['myBlock']);
unset
($a_ret['myAjaxObj']);
unset
($a_ret['myControll']);
unset
($a_ret['myDOMId']); // <pk-08-06-09 />
unset
($a_ret['exportCVS']); // <pk-08-11-27 />
* return value is used to raise an error
* by default True is returned at the moment
foreach($varArr as $s_name =>
$s_val) {
unset
($varArr['className']); // unused very old code
unset
($varArr['myDOMId']); // unset DOM Id
unset
($varArr['exportCVS']); // misspelled old var name <pk-08-11-27>
* sets the object vars from an other object
$arr_oldVals=
$fld->getObjectVars(); // <pk-07-10-31 />
if (isset
($arr_oldVals['className'])) unset
($arr_oldVals['className']); // old value
unset
($arr_oldVals['classSrcFile']);
foreach($arr_oldVals as $str_key =>
$mixed_val)
$this->{$str_key}=
$mixed_val;
$this->setMyForm($fld->getMyForm());
$this->setMyBlock($fld->getMyBlock());
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<h1>Exception: </h1><pre>" .
print_r($e,True) .
"</pre>");
* marks the field as deleted by setting $this->myDeleteFlag to true
* the next time the field is written to the database it should be deleted
* returns if the field is marked as deleted
// sorting methods --------------------------------------------------------------------------------
* returns the orderNr of the field
* @version pk-07-05-02 bugfix orderNr => sortOrder
* sets the orderNr of the field
* @version pk-07-05-02 bugfix orderNr => sortOrder
* @version pk-07-05-02 bugfix orderNr => sortOrder
* returns the tabIndex of the field
// ###########################################################
// OBJECT SETTINGS METHODS
// ###########################################################
if ($this->fldDebug) echo
"<p>Setting DataArrName to: ".
$arrName.
"</p>";
* returns a field setting value
* returns the database column type of the field
* returns the database type of the fields column
* returns the table of the field
* returns the table alias used in joins
* normaly this is the same as $this->myTable
* returns the databas column name
* @param boolean $withAlias
* if empty $this::dbDesc['COLNAME'] $this->getName() is returned
* which should in most cases be same as dbDesc['COLNAME']
* @version pk-07-12-29 $withAlias added
if (!empty($this->dbDesc['COLNAME'])) {
return $this->dbDesc['COLNAME'];
* returns $dbDesc (COPY OF THE ARRAY)
* sets the database column description array
* returns if the field is (part of) the primary key
if (isset
($this->dbDesc['PRIMARY_KEY'])) {
return (intval($this->dbDesc['PRIMARY_KEY']) ?
True :
False);
* ($this->myTableAlias.".".$this->myName)
* returns the debug mode of the field
* sets the id of the form the field belongs to
* returns the id of the form the field belongs to
* sets the owner form Object
* @param DBMS_FORM $frmObj
* @version pk-06-11-09 ensure myFrmId is also set
* @version pk-08-01-16 $force
* returns a pointer to the owner form or NULL in case of error
* @param bool $debug since pk-05-01-11
* @version pk-06-11-19 always set myForm
} else if ($int_formId =
$this->getFrmId()) {
* returns the name of the form
return $myForm->getHTMLName();
* @param OCSP_FORM_BLOCK &$aBlock
* @return OCSP_FORM_BLOCK
* returns the td id of the value col
if (!empty($aName)) $this->myName=
$aName;
* sets the field table (and load dbDesc again)
* @param bool $getDesc load field Desc from table def
* @param string $colPreFix is added to db column name
function setTable($aTable,$colPreFix=
"",$getDesc=
True,$debug=
False) {
if ($debug) echo
"<hr /><p><b>DBMS_FIELD::setTable($aTable,$colPreFix,$getDesc,$debug)</b></p><blockquote>";
if ($debug) echo
"<p>no table set</p></blockquote>";
$this->dbDesc['AUTO_INCREMENT']=
False;
$this->dbDesc['PRIMARY_KEY']=
False;
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p style='color:red;'>returns False TABLE DOES NOT EXIST</p></blockquote><hr />");
return False; // table is not created
// if ($debug) {echo "<pre>".$colPreFix.$this->myName."\n";print_r($fields);echo "</pre>"; }
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<pre>".
print_r($this,True) .
"</pre><p style='color:green;'>returns True</p></blockquote><hr />");
if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p style='color:red;'>returns False</p></blockquote><hr />");
* sets the Form label text
* @param string $aLabel text used in <td ...>$aLabel</td> column
if (!$aLabel) $this->label=
$aLabel;
* returns if the field is searchable or not
* returns if the field is hidden or not
* @version pk-07-05-02 scope added
* @version pk-07-08-20 first check $this->isHidden
* @version pk-08-06-03 $scope => setting
* @version pk-07-05-02 scope added
* @version pk-07-05-02 scope added
$this->{$varName}=
$value;
// ###########################################################
// FIELD DEFINITION DATA METHODS
// ###########################################################
* checks if a db fieldtype is compatible to the class
* @version pk-06-04-07 DECIMAL added
if ($debug) echo
"<p><b>DBMS_FIELD::fldTypeIsUseable($fldType)</b> (".
get_class($this).
"/".
$this->getName().
")</p>";
/* ok no direct compare -> check more or other spellling */
case "REAL":
// <pk-05-06-24 />
case "STRING":
// <pk-06-06-24 />
if (strtoupper($this->dbDesc['TYPE']) ==
"VARCHAR") return True; // <pk-06-02-10 />
if (stristr("int",$fldType)) return True;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// methods used in dbms admin (fieldlist.php*)
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* return a css style definition for the fieldlist
if ($this->isHidden) $s_style.=
"background: #c0c0c0;";
if (!$this->enableNew) return $s_style.
"color: #FFCC66;";
if (!$this->enableEdit) return $s_style.
"color: #DD66DD;";
* returns the option list for the class select element
if (!isset
($GLOBALS['DBMS_FIELD_DESC']))
//$str_ret="<option>DBTYPE: " . $this->dbDesc['TYPE'] ."</option>";
foreach($GLOBALS['DBMS_FIELD_DESC'] as $key =>
$fldArr) {
$a_options[$fldArr['FLD_CLASS']]=
$fldArr['FLD_SELNAME'];
//$str_ret .= "<option>NOT USABLE: " . $fldArr['FLD_TYPE'] . "</option>";
$a_options[$fldArr['FLD_CLASS']]=
$fldArr['FLD_SELNAME'];
$a_options[$fldArr['FLD_CLASS']]=
$fldArr['FLD_SELNAME'];
if (strtoupper($fldArr['FLD_TYPE']) ==
"DATETIME") {
$a_options[$fldArr['FLD_CLASS']]=
$fldArr['FLD_SELNAME'];
foreach($a_options as $key =>
$s_Name) {
$str_ret.=
$s_Name.
"</option>\n";
* returns the field definition form
* from the field edit array @see editTbl_getFieldEditArr()
* @param array $fldEditArr
foreach($fldEditArr as $s_section =>
$a_secFlds) {
if (!isset
($a_secFlds['ISHIDDEN']) ||
(!$a_secFlds['ISHIDDEN'])) {
if (!empty($a_secFlds['TITLE'])) {
$str_ret.=
"<tr><th colspan=\"2\">".
$a_secFlds['TITLE'];
if (!empty($a_secFlds['HIDDENFIELD'])) $str_ret.=
$a_secFlds['HIDDENFIELD']; // <pk-06-07-17 />
$str_ret.=
"</th></tr>\n";
$str_ret.=
"<tr><td class=\"fldName\" colspan=\"2\"><hr width=\"75%\" align=\"center\">";
if (!empty($a_secFlds['HIDDENFIELD'])) $str_ret.=
$a_secFlds['HIDDENFIELD']; // <pk-06-07-17 />
$str_ret.=
"</td></tr>\n";
foreach($a_secFlds as $a_fld =>
$a_fldDesc) {
if ((is_array($a_fldDesc)) &&
$a_fld !=
"TITLE" &&
$a_fld !=
"HIDDENFIELD" ) { // <pk-06-07-17 />
$str_ret.=
"\t<td class=\"fldName\" ".
(isset
($a_fldDesc['FLDTIT']) ?
"title=\"".
$a_fldDesc['FLDTIT'].
"\"" :
"" ).
">".
(isset
($a_fldDesc['FLDLAB']) ?
$a_fldDesc['FLDLAB'] :
"") .
"</td>\n";
$str_ret.=
"\t<td class=\"fldValue\">".
$a_fldDesc['FLDVAL'].
"</td>\n";
* echos the field definition form
* from the field edit array @see editTbl_getFieldEditArr()
* @param array $fldEditArr
* show the filed definition form
* @param bool $showSize show size input
* @param bool $showNull show input field to handle null values
* @version pk-05-02-11 fldDbgGetValue added
* @version pk-05-09-14 trimValue added
* @deprecated since pk-06-04-26
* save the filed definition form
* @param bool $debug since pk-04-07-23
* @return bool return True
* @version pk-04-07-23 debug added
* @version pk-05-02-11 fldDbgGetValue added
* @version pk-05-06-29 unsetGrpKey added
* @version pk-05-08-09 regexcheck_pattern/regexErrMsg added
* @version pk-05-09-14 trimValue added
* @version pk-06-02-21 allowNull setting if $this->dbDesc['COLNAME'] is empty
* @version pk-06-09-27 exportCSV added
* @version pk-06-10-08 showGroup added
function save($debug=
False) {
* compares the values of $aDesc (DB Field definition)
* with the field definition stored in the object
while(list
($key,$val)=
each($aDesc)) {
if (!isset
($this->dbDesc[$key]) ||
($this->dbDesc[$key]!=
$val)) {
// ###########################################################
// ###########################################################
* check if NULL values are allowed
* @version pk-06-02-21 check for empty COLNAME
* @version pk-06-11-27 allowNull is true whereas dbDesc['NULL'] is flase
if (!isset
($this->dbDesc['COLNAME'])) $this->dbDesc['COLNAME']=
"";
if (!$this->dbDesc['NULL']) { // <pk-06-11-27>
* returns the field database default value
if (isset
($this->dbDesc['AUTO_INCREMENT']) &&
($this->dbDesc['AUTO_INCREMENT']))
if (isset
($this->dbDesc['DEFAULT'])) {
if (!empty($this->dbDesc['DEFAULT']))
return $this->dbDesc['DEFAULT'];
if ($this->dbDesc['DEFAULT']===
0) // type compare INTEGER
if ($this->dbDesc['DEFAULT']===
0.0) // type compare FLOAT / DOUBLE
if ($this->dbDesc['DEFAULT']===
"0") // type compare STRING
if ($this->dbDesc['DEFAULT']===
"0.0") // type compare STRING
* returns if the field represents an auto_increment column in the database
if (isset
($this->dbDesc['AUTO_INCREMENT'])) {
return $this->dbDesc['AUTO_INCREMENT'];
// ###########################################################
// OBJECT HTML FORM METHODS
// ###########################################################
* returns the field default value
* if $defaultValue !empty it is returned
* else getDbDefault is return
if ($debug) echo
"<p><b>DBMS_FIELD::getDefaultValue($debug)</b> (".
get_class($this).
"/".
$this->myName.
")</p>";
/* <pk-05-03-17> Debugging changed */
if ($debug) echo
"<blockquote>Returning DB default (".
$this->getDbDefault().
")</blockquote>";
* returns the addTag parsed as template with global ${$arrName} as data
* returns the (show) size (chars) of a field
* returns the html code for a editable formular element
* @param mixed $aValue the value to set
* @param string $nameAdd append something to name like "[VALUE]" for search forms
* @param boolean $debug since pk-06-08-09
* @version pk-06-05-18 inputAdd added
* @version pk-06-08-09 debug added
* @version pk-07-12-07 avoid maxlength 0
function getInputTag($aValue,$arrName=
"DBVAL",$nameAdd=
"",$debug=
False) {
$tag .=
"id=\"" .
$this->getDOMId() .
"\" ";
$tag .=
"name=\"".
$arrName.
"[".
$this->myName.
"]".
$nameAdd.
"\" ";
* returns if a field is shown readonly
if ($debug) echo
"<p><b>DBMS_FIELD::isReadOnlyShown($mode,...)</b> (".
get_class($this).
")";
* returns the group id which is required to see the field
* checks if the field is to show due to $this->showQuery
* @param boolean $inFieldGroup
* @global array $OCSP_OBJ
* @requires pcf_templates.phpinc
* @version pk-07-01-09 use showQuery in FRM_MODE_SEARCH too
* @version pk-07-09-12 global $OCSP_OBJ
* @version pk-08-09-22 no global
function isToShow($mode,$dataArr,$debug=
False,$inFieldGroup=
False) {
if ($debug) echo
"<p>showQuery: <br />".
$s_query.
"</p>\n";
if ($this->hideEdit) return False; else return True;
if ($this->hideCopy) return False; else return True;
if ($this->hideReadOnly) return False; else return True; // <pk-05-11-15 />
* returns if the field is in list (does not check rights)
* returns if the field is enabled in $mode and to show
if ($this->isHidden()) return False; // no need to check the field is not shown
* returns the html code for the field value input / show
* adds $this->myName to ${$this->myDataArrName}['_DBMS_FIELDS']
* @version pk-06-02-26 getListValue()
function getFieldTag($mode,$aValue=
NULL,$debug=
False) {
global $
{$this->myDataArrName};
$ret .=
"<input type=\"hidden\" ";
if (empty($aValue) &&
($aValue !=
"0")) $aValue=
$this->getDefaultValue(); /* <pk-05-01-03 /> */
if (empty($aValue) &&
($aValue !=
"0")) $aValue=
$this->getDefaultValue(); /* <pk-05-01-03 /> */
// $ret.=" <option value=\"\">---</option>";
$ret.=
" <option value=\"AND\">UND</option>";
$ret.=
" <option value=\"OR\">ODER</option>";
// else use default -> no break
* list colspan (<td colspan="x">)
* get the html tag for the label column
* @param bool $useTh if True <th>..</th> is returned else <td>..</td>
* @param string $style a css class name for the column
* @global array $OCSP_CONF
* @version pk-05-09-05 titel attribut added
if ($useTh) $ret =
"<th ".
$style.
" ".
$this->labeltd_add.
">";
if ($debug) $ret .=
"(".
$this->sortOrder.
")";
var myCmd = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes'
myCmd = myCmd + ',width=640,height=480';
var myWnd = window.open('".
$this->myHelpUrl.
"','".
$this->myName.
"_hlp',myCmd);
\"><img src=\"".
$OCSP_CONF['SYSIMGURL'].
"form_buttons/icon_help.gif\" border=\"0\" alt=\"Eingabehilfe\"></a>";
if ($useTh) $ret .=
"</th>\n";
* returns the html code for a field form row
* @version pk-07-03-05 id added to table row
function getFieldRow($mode,$aValue=
NULL,$debug=
False) {
$ret.=
"\t<tr id=\"tr_".
$this->getJsName().
"\">\n";
* returns the row columns for a field row
* @version pk-05-02-25 bugif colspan
* @version pk-07-02-15 set class even if we have set $this->labeltd_add
* @version pk-07-02-28 add id to value column
$class=
" class=\"fldName\" ";
//if (empty($this->labeltd_add)) {
// $class=" class=\"fldName\" ";
$tdAdd.=
" class=\"fldValueRO\" ";
if ($this->hideNew) $tdAdd.=
" class=\"fldValueRO\" ";
else $tdAdd.=
" class=\"fldValue\" ";
if ($this->hideCopy) $tdAdd.=
" class=\"fldValueRO\" ";
else $tdAdd.=
" class=\"fldValue\" ";
if ($this->hideEdit) $tdAdd.=
" class=\"fldValueRO\" ";
else $tdAdd.=
" class=\"fldValue\" ";
$tdAdd.=
" class=\"fldValue\" ";
$ret.=
"\t\t<td ".
$tdAdd.
" id=\"".
$this->getValId().
"\">";
* returns the html representation of the field
* @param mixed $aValue the falue
* @param string $arrName name of the global array holding data values
* @param bool $debug show debug info
* @return mixed the html representation of the field
* returns the html representation of the field in a list (table col)
* @param mixed $aValue the falue
* @param string $arrName name of the global array holding data values
* @param bool $debug show debug info
* @return mixed the html representation of the field
function getListValue($aValue=
NULL,$arrName=
"DBVAL",$debug=
False) {
* returns if the list cell can be linked with the ['EDIT'] link
* get the link url for a list entry
* @param mixed $aValue value of the db field
* @param string $arrName name of the global array holding data values
* @global array ${$this->myDataArrName}
* @return string empty if no link is to show a url if the field is linked or [EDIT] if the edit link can be used
* @version pk-06-10-25 "bugfix" parse link as template
* @version pk-07-10-27 $this->myDataArrName instead of $GLOBAL
function getListLink($aValue,$arrName=
"",$debug=
False) {
global $
{$this->myDataArrName};
// ################################################
// ################################################
* returns the html code for a searchformular element
* @param mixed $aValue the value to set
* returns the html code for the search compare type select
if (isset
($_POST[$arrName][$this->myName]['COMPTYPE'])) { // <pk-06-07-27 > E_ALL
$s_val=
$_POST[$arrName][$this->myName]['COMPTYPE'];
$ret=
"<select name=\"".
$arrName.
"[".
$this->myName.
"][COMPTYPE]\">";
$ret.=
" <option value=\"=\" ".
($s_val==
"=" ?
"selected" :
"").
">=</option>";
$ret.=
" <option value=\"LIKE\" ".
($s_val==
"LIKE" ?
"selected" :
"").
">wie</option>";
$ret.=
" <option value=\"SOUNDEX\" ".
($s_val==
"SOUNDEX" ?
"selected" :
"").
">SOUNDEX</option>";
* returns a html select with all values (distinct) where $aValue
* NOTE only works on database fields
* @param string $selTagAdd added into <select ...>
* @param string $whereCond added to query ($s_query="SELECT ... FROM TABLE ".$whereCond." ORDER BY")
* @todo object value tables
function getTableValSelect(&$aValue,$arrName=
"",$selTagAdd=
"",$whereCond=
"",$nullLabel=
"",$debug=
False) {
if ($debug) echoDebugMethod(__FILE__
,get_class($this),"DBMS_FIELD::getTableValSelect(aValue=".
$aValue.
",arrName=".
$arrName.
")","WHERE: $whereCond");
if ($this->myTable !=
"DBMS_NO_DBFIELD") {
$s_selName=
$arrName.
"[".
$this->myName.
"]";
$ret=
"\n<select name=\"".
$s_selName.
"\" ".
$selTagAdd.
">\n";
if (!empty($nullLabel)) {
$ret.=
"\t<option value=\"\">".
$nullLabel.
"</option>\n";
$ret.=
"\t<option value=\"\">--- ??? ---</option>\n";
$s_query =
"SELECT DISTINCT IFNULL(".
$this->myName.
",'[NULL]') FROM ".
$this->myTable; // <pk-07-01-15 />
if (!empty($whereCond)) {
$s_query.=
" ORDER BY ".
$this->myName;
if ($debug) echo
"<p>".
$s_query.
"<br>DB: ".
$this->get_gDBIDX().
"</p><blockquote>";
$a_Values=
$GLOBALS[$this->get_gDBIDX()]->queryArray($s_query,0,0,True,$debug);
if ($debug) echoDebug(__FILE__
,"</blockquote><p>Values:</p><pre>".
print_r($a_Values,True).
"</pre>");
foreach($a_Values as $s_Value) {
// no null Label -> we have to set the $aValue called by ref
if (strval($aValue)==
$s_Value) {
$ret.=
">".
$s_Value.
"</option>\n";
return "\n<!-- no database field -->\n\n";
// ###########################################################
// OBJECT VALUE CHECK/RETURN METHODS
// ###########################################################
* returns the field value
* @param string $aValue the value
* @param array $err error array
* @param string $arrName global data array name used for global ${$arrName}
* @version pk-05-02-11 fldDbgGetValue added
* @version pk-05-10-19 debug if trimValue
* @version pk-06-11-27 if allowNull is true $aValue is NULL and ! $this->dbDesc['NULL'] the default value is returned
* @version pk-07-07-11 $this->errMsg added
function getValue($aValue,&$err,$arrName=
"DBVAL",$debug=
False) {
if ($debug) echo
"<hr><p><b>DBMS_FIELD::getValue($aValue,$err,$arrName,$debug)</b> (".
get_class($this).
" | ".
$this->myName.
")</p>";
if ($debug) echo
"<blockquote><p>TRIMVALUE</p></blockquote>"; // <pk-05-10-19 />
if (empty($aValue) &&
($aValue !=
"0") &&
($aValue !==
0)) {
if (!$this->dbDesc['NULL']) { // <pk-06-11-27>
if ($debug) echo
"<p>NULL returned \$aValue=\"".
htmlspecialchars($aValue).
"\"</p>";
if ($debug) {echo
"<pre style=\"font-color:red;font-weight:bolder\">";print_r($err);echo
"</pre>";}
$this->errMsg.=
$err['ERROR']=
True;
* returns the value with slashes create use in a db statement
* @param string $aValue the value
* @param array $err error array
* @param string $arrName DBVAL
* @version pk-03-11-27 DB-Object used instead of DB_.. function
* @version pk-03-12-13 use $this->getValue to check the Value
* @version pk-04-06-02 handling 0
function slashedValue($aValue,&$err,$arrName=
"DBVAL",$debug=
False) {
echo
"<hr><p><b>DBMS_FIELD::slashedValue($aValue,$err,$arrName,$debug)</b> (".
get_class($this).
" | ".
$this->myName.
")</p>";
echo
"<pre>\n".
$this->myName.
"--".
addSlashes($aValue).
"--\n".
$GLOBALS[$this->getGlobalDBObjIdx()]->qs_getSlashedValue($aValue).
"</pre>\n";
$val=
$this->getValue($aValue,$err,$arrName,$debug);
if ($debug) echo
"<p>slashedValue: NULL returned for $aValue</p>";
return $GLOBALS[$this->getGlobalDBObjIdx()]->qs_getNullStmt();
if ($debug) echo
"<p>slashedValue: returned ".
$GLOBALS[$this->getGlobalDBObjIdx()]->qs_getSlashedValue($val).
" for $aValue</p>";
return $GLOBALS[$this->getGlobalDBObjIdx()]->qs_getSlashedValue($val);
} else if ($val ===
0 ||
$val ===
"0") { /* <pk-04-06-02> */
return $GLOBALS[$this->getGlobalDBObjIdx()]->qs_getSlashedValue("0");
* returns a where part for sql queries out of search form input
* @param array $aArr the posted array of the filed form the search form
* @version pk-07-02-14 ($this->myDataArrName)
global $
{$this->myDataArrName};
if ($debug) {echo
"<blockquote><pre>";print_r($aArr);echo
"</pre></blockquote>";}
if ((!empty($aArr['ANDOR'])) &&
(!empty($aArr['VALUE']))) {
$ret=
($aArr['ANDOR'] ==
"OR" ?
" OR " :
" AND ");
switch($aArr['COMPTYPE']) {
$ret.=
" LIKE ".
DB_getSlashedValue("%".
$aArr['VALUE'].
"%");
$ret.=
"SOUNDEX(LEFT(".
$this->myTable.
".".
$this->myName.
",10)) = ";
$ret.=
"SOUNDEX(LEFT(".
DB_getSlashedValue($aArr['VALUE']).
",10)) ";
function getAssignment($aValue,&$err,$arrName=
"DBVAL",$debug=
False) {
if ($debug) echo
"<hr /><p><b>DBMS_FIELD::getAssignment($aValue,$err,$arrName,$debug)</b>(".
get_class($this).
"/".
$this->myName.
")</p>";
* gets a htmltag for the value
* this is mainly used in CMS Module
function getHtmlTag($aValue,$arrName=
"DBVAL",$debug=
False) {
if ($debug) echo
"<p><b>DMBS_FIELD::getHtmlTag($aValue,$arrName ...)</b> (".
get_class($this).
")</p>";
// return $this->getScreenValue($aValue,$arrName,$debug);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* returns if the field has an error ($this->errMsg not empty)
return (!empty($this->errMsg));
* @param string $aErrorMsg
* @param boolean $append (if True append the message else overwrite the old message)
function setErrorMsg($aErrorMsg,$append=
True,$debug=
False)
$this->errMsg.=
"\n".
$aErrorMsg;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* retuns a string which can be used in js var and functions to name the field
* returns a serialized array to identify the field in the called ajax script
* @requires pcf_md5.phpinc
* js code that ensures the form is registered
* @return string (js-code)
* @deprecated since pk-08-02-22
if (empty($aJsName)) $aJsName=
$this->getJsName();
//ensure $this->myView and $this->myControll is set
$str_jsId=
"FRM_".
$this->myForm->getId();
$str_jsId=
$this->myForm->getHTMLName();
var objForm=ocsp_form_getFrmObj('".
$str_jsId.
"');
objField=objForm.registerField(new ocsp_fldObj('$aJsName','$aName',$str_jsDebug));";
alert('could not register field $aJsName to form $str_jsId File: ".
basename(__FILE__
).
" Line: ".__LINE__.
" (".
get_class($this).
")');
alert('Form $str_jsId not found in ocsp_frmList File: ".
basename(__FILE__
).
" Line: ".__LINE__.
" (".
get_class($this).
")');
$str_ret.=
"alert('".
$this->getKey().
": '+objForm.myName);";
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// cvs data export methods
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* returns if the field is to be added to the csv export
if ($this->isPrimaryKey()) return True; // always export primary keys
* returns the CSV value of field
* @param char $txtSep enclose strings in $txtSep
function getCSV_Value($aValue,$arrName=
"DBVAL",$debug=
False) {
$s_value=str_replace("\n"," ",strval($aValue));
$s_value=$txtSep.str_replace($txtSep,"\\".$txtSep,$s_value).$txtSep;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// xml data export methods
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if ($debug) echo
"<blockquote><b><b>$class</b></p><blockquote>";
//$node=$domObj->createElement("FLD_CLASS",utf8_encode($class));
//$fldRoot->appendChild($node);
$valRoot =
$domObj->createElement("FLD_VALUES");
$fldRoot->appendChild($valRoot);
} else if (!empty($val)) {
$valRoot->appendChild($domObj->createElement($var,utf8_encode($val)));
$valRoot =
$domObj->createElement("FLD_SER_VALUES");
$fldRoot->appendChild($valRoot);
// unset($serValArr['dbDesc']);
foreach($serValArr as $key) {
$valRoot->appendChild($domObj->createElement($key,utf8_encode($val)));
if ($debug) echo
"</blockquote></blockquote>";
if ($debug) echo
"<pre>".
$frmNode->nodeName.
": ".
$frmNode->childNodes->length.
"</pre>";
foreach($fldRoot->childNodes as $node) {
if ($debug) echo
"<pre>".
$node->nodeName.
": ".
$node->childNodes->length.
"</pre>";
switch($node->nodeName) {
foreach($node->childNodes as $valNode) {
if ($debug) echo
"<blockquote><p><b>".
$valNode->nodeName.
"</b> ".
utf8_decode($valNode->nodeValue).
"</p>";
$this->{$valNode->nodeName}=
utf8_decode($valNode->nodeValue);
if ($debug) echo
"</blockquote>";
foreach($node->childNodes as $valNode) {
if ($debug) echo
"<blockquote><p><b>".
$valNode->nodeName.
"</b> ".
utf8_decode($valNode->nodeValue).
"</p>";
if ($debug) echo
"</blockquote>";
// ###########################################################
// ###########################################################
// ###########################################################
// implementation of INFA_DBMS_FIELD
// ###########################################################
// ###########################################################
// ###########################################################
// --------------------------------------------------------
// --------------------------------------------------------
* returns a unique DOM id for the field
* Note: $this->myDOMId MUST NOT be stored in the db make sure it is excluded
* sets the unique DOM id for the field
// --------------------------------------------------------
// --------------------------------------------------------
* returns an array of field to bie shown in the edit form
* by using editTbl_echoForm
* the array is in the form:
* [FLDLAB] (complete html code with <td></td>)
* [FLDVAL] (complete html code with <td></td>)
* [FLDTIT] (title of the label column)
* NOTE as this is not implemented in the whole classTree at the moment ensure all parents use
* editTbl_echoForm() in theire editTblForm otherwise you'll get a mismatch of field order
* @version pk-06-07-17 HIDDEN added to array
* @version pk-06-08-15 FLDTIT added
* @version pk-06-09-12 Tabs & Link showQuery added
* @version pk-07-08-31 language file
* save the filed definition form
echo
"<p><b>DBMS_FIELD::save()</b> (".
get_class($this).
")</p>";
echo
"</pre></blockquote>";
$this->fldDebug =
((isset
($_POST['fldDebug']) &&
intval($_POST['fldDebug'])) ?
True :
False); /* <pk-04-06-02> fldDebug added */
$this->fldDbgGetValue =
((isset
($_POST['fldDbgGetValue']) &&
intval($_POST['fldDbgGetValue'])) ?
True :
False); /*<pk-05-02-11 /> fldDbgGetValue added */
$this->ajaxDebug =
((isset
($_POST['ajaxDebug']) &&
intval($_POST['ajaxDebug'])) ?
True :
False);
$this->label =
$_POST['label'];
$this->lstLabel =
(isset
($_POST['lstLabel']) ?
$_POST['lstLabel'] :
$this->lstLabel);
$this->toolTip =
(isset
($_POST['TOOLTIP']) ?
$_POST['TOOLTIP'] :
$this->toolTip);
$this->toolTipAsTitle =
($_POST['toolTipAsTitle']==
1 ?
True :
False); // </pk-05-09-05>
$this->isSearchable =
((isset
($_POST['SEARCHABLE']) &&
intval($_POST['SEARCHABLE'])) ?
True :
False);
$this->showInList =
((isset
($_POST['SHOWINLIST']) &&
intval($_POST['SHOWINLIST'])) ?
True :
False);
$this->lstColSpan =
((isset
($_POST['lstColSpan']) &&
intval($_POST['lstColSpan'])) ?
intval($_POST['lstColSpan']) :
1);
$this->lstWidth =
((isset
($_POST['lstWidth']) &&
intval($_POST['lstWidth'])) ?
intval($_POST['lstWidth']) :
0);
if (isset
($_POST['lstLink_A']) &&
!empty($_POST['lstLink_A'])) {
$this->lstLink['A'] =
$_POST['lstLink_A'];
$this->lstLink['TEXT'] =
$_POST['lstLink_TEXT'];
$this->lstLink['ASTAB'] =
(intval($_POST['lstLink_ASTAB']) ?
True :
False);
$this->lstLink['TABLAB'] =
$_POST['lstLink_TABLAB'];
$this->lstLink['SHOWQUERY'] =
$_POST['lstLink_SHOWQUERY'];
$this->lstTDAdd =
(isset
($_POST['lstTDAdd']) ?
$_POST['lstTDAdd'] :
""); // <pk-05-07-08 />
$this->showQuery =
(isset
($_POST['showQuery']) ?
$_POST['showQuery'] :
$this->showQuery); // <pk-05-11-13 />
$this->showQasHidden =
((isset
($_POST['showQasHidden']) &&
intval($_POST['showQasHidden'])) ?
True :
False);
$this->isHidden =
((isset
($_POST['isHidden']) &&
intval($_POST['isHidden'])) ?
True :
False); // <pk-06-10-21 />
$this->hideReadOnly =
((isset
($_POST['SHOWREADONLY']) &&
intval($_POST['SHOWREADONLY'])) ?
False :
True); // inverted value in form
$this->enableNew =
((isset
($_POST['ENABLENEW']) &&
intval($_POST['ENABLENEW'])) ?
True :
False);
$this->enableEdit =
((isset
($_POST['ENABLEEDIT']) &&
intval($_POST['ENABLEEDIT'])) ?
True :
False);
$this->enableEditIfEmpty =
((isset
($_POST['enableEditIfEmpty']) &&
intval($_POST['enableEditIfEmpty'])) ?
True :
False);
$this->enableCopy =
((isset
($_POST['enableCopy']) &&
intval($_POST['enableCopy'])) ?
True :
False);
$this->hideNew =
((isset
($_POST['HIDENEW']) &&
intval($_POST['HIDENEW'])) ?
True :
False);
$this->hideEdit =
((isset
($_POST['HIDEEDIT']) &&
intval($_POST['HIDEEDIT'])) ?
True :
False);
$this->hideCopy =
((isset
($_POST['hideCopy']) &&
intval($_POST['hideCopy'])) ?
True :
False);
$this->size =
(isset
($_POST['SIZE']) ?
intval($_POST['SIZE']) :
32);
$this->maxlength =
(isset
($_POST['MAXLENGTH']) ?
intval($_POST['MAXLENGTH']) :
32);
$this->defaultValue =
(isset
($_POST['DEFAULTVALUE']) ?
intval($_POST['DEFAULTVALUE']) :
"");
$this->addTag =
(isset
($_POST['addTag']) ?
$_POST['addTag'] :
$this->addTag);
$this->inputAdd =
(isset
($_POST['inputAdd']) ?
$_POST['inputAdd'] :
$this->inputAdd);
$this->hideAddTag_ro =
((isset
($_POST['hideAddTag_ro']) &&
intval($_POST['hideAddTag_ro'])) ?
True :
False); /* <pk-05-02-25> */
$this->labelcol_hide =
((isset
($_POST['labelcol_hide']) &&
(intval($_POST['labelcol_hide'])==
1)) ?
True :
False);
$this->allowNull =
((isset
($_POST['allowNull']) &&
intval($_POST['allowNull'])) ?
True :
False);
if ((!$this->dbDesc['NULL']) &&
(!empty($this->dbDesc['COLNAME']))) { // <pk-06-02-21 />
$this->nullErrMsg =
(isset
($_POST['nullErrMsg']) ?
$_POST['nullErrMsg'] :
"");
$this->myHelpUrl =
(isset
($_POST['myHelpUrl']) ?
$_POST['myHelpUrl'] :
"");
$this->js_check =
((isset
($_POST['js_check']) &&
intval($_POST['js_check'])) ?
True :
False);
$this->regexcheck_pattern =
(isset
($_POST['regexcheck_pattern']) ?
$_POST['regexcheck_pattern'] :
"");
$this->regexErrMsg =
(isset
($_POST['regexErrMsg']) ?
$_POST['regexErrMsg'] :
""); // <pk-05-08-09 />
$this->trimValue =
((isset
($_POST['trimValue']) &&
intval($_POST['trimValue'])) ?
True :
False);
$this->tabIndex =
(isset
($_POST['tabIndex']) ?
intval($_POST['tabIndex']) :
0); /* <pk-05-02-18 />*/
if (isset
($_POST['inputAdd']) && isset
($_POST['unsetGrpKey']) &&
intval($_POST['unsetGrpKey'])) {
$this->exportCSV =
((isset
($_POST['exportCSV']) &&
(intval($_POST['exportCSV']))) ?
True :
False); // <pk-06-09-27>
$this->extConfOptions =
(isset
($_POST['extConfOptions']) ?
$_POST['extConfOptions'] :
"");
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* @param OCSP_FRMVIEW $aView
* returns the view object
* alias for $this->setControl()
* @param OCSP_FRMCONTR $aControl
* @deprecated since pk-08-11-24
* sets the controll object
* @param OCSP_FRMCONTR $aControl
* alias for $this->getControl()
* @deprecated since pk-08-11-24
* returns the controll object
ocsp_logError(__FILE__
,__LINE__
,"unable to get controll",E_NOTICE);
* alias for $this->checkControl()
* @param string $str_className
* @deprecated since pk-08-11-27
function checkControll($str_className=
'OCSP_FRMCONTR',$debug=
False)
* sets $this->myControll form $this->myForm if not pcf_is_instance_of $str_className
* @param string $str_className
function checkControl($str_className=
'OCSP_FRMCONTR',$debug=
False)
// --------------------------------------------------------
// --------------------------------------------------------
* returns an array of jOCSP/jQuery Modules which are required
* $arr_ret[]="script url";
if ($debug) echoDebugMethod(__FILE__
,get_classe($this),"DBMS_FIELD::jOCSP_getRequiredModules()");
* returns additional object elements of the field object
* array definition: [elemName] = value
* returns the javascript code to register the field to an form
fldName: '" .
$this->myName .
"',
allowNull: " .
($this->allowNull() ?
"true" :
"false");
$str_ret .=
",grpFldDomId: '" .
$obj_grpFld->getDOMId() .
"'";
foreach($arr_objElems as $str_id =>
$str_jsonVal)
$str_ret .=
"," .
$str_id .
": " .
$str_jsonVal;
// --------------------------------------------------------
// --------------------------------------------------------
* returns the xtype of the field
* @see http://extjs.com/deploy/dev/docs/output/Ext.Component.html
* returns options of an ext js field config object
* NOTE the return string is NOT enclosed by {}
* @return array of json object values
foreach($arr_vars as $str_name =>
$mixValue)
if (!isset
($arr_ret[$str_name]))
$arr_ret[$str_name] =
$mixValue;
$arr_ret['allowBlank'] =
"false";
$arr_ret['hidden'] =
"true";
$arr_ret['disabled'] =
"true";
// --------------------------------------------------------
// --------------------------------------------------------
* returns the html tag for the label
* returns the html code for the field value input / show
// --------------------------------------------------------
// DBMS_FIELD_FLDGROUP hook
// --------------------------------------------------------
if ($obj_ret =
$this->myForm->getField($key))
} // end class DBMS_FIELD
Documentation generated on Thu, 08 Jan 2009 17:40:27 +0100 by phpDocumentor 1.4.0a2