Source for file DBMS_FIELD.phpclass

Documentation is available at DBMS_FIELD.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   field
  8.   *
  9.   * @author     Peter Krebs <pitlinz@sourceforge.net>
  10.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11.   *
  12.   * @version $Id: DBMS_FIELD.phpclass,v 1.54 2008/12/04 16:02:28 peterkrebs Exp $
  13.   */
  14.  
  15.  
  16. /**
  17.  * requirements
  18.  */
  19. if (!defined('PQT_SELECT'))
  20. {
  21.     require_once __OCSP_PHPINCPATH__."db"._OCSP_DIRSEP_."db.phpinc";
  22. }
  23.  
  24. /**
  25.  * constants
  26.  */
  27.  
  28. /**
  29.  * @const string DBMS_NO_DBFIELD used for fields with no table
  30.  * @since pk-07-10-26
  31.  */
  32. if (!defined('DBMS_NO_DBFIELD')) define ('DBMS_NO_DBFIELD',"__NO-DBFIELD__");
  33. if (!defined('DMBS_FIELD_DEFAULT_SIZE')) define('DMBS_FIELD_DEFAULT_SIZE',30);
  34.  
  35.  
  36.     pcf_require_interface('INFA_DBMS_FIELD',dirname(__FILE__)."/");
  37.     
  38.  
  39. /**
  40.   * class to handle a form field
  41.   *
  42.   * @project    Open CSP-Management
  43.   * @package    dbms_field
  44.   * @category   field
  45.   *
  46.   * @author     Peter Krebs <pitlinz@sourceforge.net>
  47.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  48.   *
  49.   * @version pk-03-10-19
  50.   * @version pk-03-10-22
  51.   * @version pk-03-12-13 function getValue added
  52.   * @version pk-05-11-13 showQuery added
  53.   * @version pk-06-01-19 $lstLabel added
  54.   * @version pk-06-11-15 changes in showQuery
  55.   * @version pk-07-03-01 ajax
  56.   * @version pk-08-09-08 extJS
  57.   * @version $Id: DBMS_FIELD.phpclass,v 1.54 2008/12/04 16:02:28 peterkrebs Exp $
  58.   */
  59. class DBMS_FIELD implements INFA_DBMS_FIELD 
  60. {
  61.  
  62.     // ###########################################################
  63.     // OBJECT (CONST) VAR DECLARATION
  64.     // ###########################################################
  65.  
  66.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~ static ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  67.  
  68.     /**
  69.       * source file of the class
  70.       *
  71.       * @staticvar string $classSrcFile 
  72.       * @since pk-05-01-11
  73.       ***/
  74.     protected $classSrcFile=__FILE__;
  75.  
  76.  
  77.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~ aggregations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  78.     /**
  79.       * @var AJAX $myAjaxObj 
  80.       * @since pk-07-03-01
  81.       * @access protected
  82.       ***/
  83.     protected $myAjaxObj=NULL;
  84.  
  85.     /**
  86.       * @var OCSP_FORM $myForm 
  87.       * @access protected
  88.       */
  89.     protected $myForm        = NULL;
  90.  
  91.     /**
  92.       * @var OCSP_FORM_BLOCK $myBlock 
  93.       * @access protected
  94.       */
  95.     protected $myBlock  = NULL;
  96.  
  97.     /**
  98.       * @var OCSP_FRMVIEW $myView 
  99.       * @access protected
  100.       */
  101.     protected $myView=NULL;
  102.  
  103.     /**
  104.       * @var OCSP_FRMCONTR $myControll 
  105.       * @access protected
  106.       */
  107.     protected $myControll=NULL;
  108.  
  109.  
  110.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~ attributes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  111.  
  112.     /**
  113.       * @var int $myFrmId id of the form the field belongs to
  114.       * @since pk-04-02-23
  115.       * @access protected
  116.       */
  117.     protected $myFrmId       = 0;
  118.  
  119.     /**
  120.       * @var int $myBlockId id of the form block the field belongs to
  121.       * @since pk-07-08.06
  122.       * @access protected
  123.       */
  124.     protected $myBlockId       = 0;
  125.  
  126.     /**
  127.       * @var string $myModuleKey 
  128.       * @since pk-07-08-07
  129.       * @access protected
  130.       */
  131.     protected $myModuleKey       = "DBMS";
  132.  
  133.  
  134.     /**
  135.       * @var boolean $myDeleteFlag 
  136.       * @since pk-07-08-08
  137.       * @access protected
  138.       */
  139.     protected $myDeleteFlag = False;
  140.  
  141.     /**
  142.      * DOM Id of the field (this MUST NOT be stored)
  143.      *
  144.      * @var string 
  145.      */
  146.     protected $myDOMId = "";
  147.     
  148.     // ~~~~~~~~~~~~~~~~~
  149.  
  150.  
  151.     /**
  152.       * @var string myTable name of the db table of the field
  153.       */
  154.     protected $myTable       = "";
  155.     /**
  156.      * alias of the table in a join
  157.      * 
  158.      * @var string myTableAlias
  159.      */
  160.     protected $myTableAlias  = "";
  161.     /**
  162.       * @var string myName column name in the table
  163.       */
  164.     protected $myName        = "";
  165.     /**
  166.       * @var string $myDesc 
  167.       ***/
  168.     protected $myDesc        = "";
  169.     /**
  170.       * @var array $dbDesc 
  171.       */
  172.     protected $dbDesc       = array();
  173.  
  174.     /**
  175.       * @var string $label 
  176.       */
  177.     protected $label         = "";
  178.  
  179.     /**
  180.       * @var string $lstLabel 
  181.       * @since pk-06-01-19
  182.       ***/
  183.     protected $lstLabel      = "";
  184.  
  185.     /**
  186.       * @var string $defaultValue 
  187.       ***/
  188.     protected $defaultValue  = "";
  189.     /**
  190.       * @var bool $isHidden 
  191.       */
  192.     protected $isHidden      = False;
  193.     /**
  194.       * @var bool $enableEdit 
  195.       ***/
  196.     protected $enableEdit    = True;
  197.     /**
  198.       * @var bool $enableEditIfEmpty can the field be edited if the field is empty and not $enableEdit ?
  199.       * @since pk-06-08-08
  200.       ***/
  201.     protected $enableEditIfEmpty=True;
  202.     /**
  203.       * @var bool $enableNew 
  204.       ***/
  205.     protected $enableNew     = True;
  206.     /**
  207.       * @var bool $enableCopy 
  208.       ***/
  209.     protected $enableCopy    = True;
  210.     /**
  211.       * @var bool $hideEdit 
  212.       ***/
  213.     protected $hideEdit      = False;
  214.     /**
  215.       * @var bool $hideNew 
  216.       */
  217.     protected $hideNew       = False;
  218.     /**
  219.       * @var bool $hideCopy 
  220.       ***/
  221.     protected $hideCopy       = False;
  222.  
  223.     /**
  224.       * @var bool $isSearchable 
  225.       ***/
  226.     protected $isSearchable  = False;
  227.     /**
  228.       * @var bool $showInList 
  229.       ***/
  230.     protected $showInList    = True;
  231.     /**
  232.       * @var int $sortOrder 
  233.       */
  234.     protected $sortOrder     = 99999;
  235.  
  236.     /**
  237.       * @var string $toolTip if is set a dialog box is linked with the label showing the toolTip
  238.       ***/
  239.     protected $toolTip        = "";
  240.  
  241.     /**
  242.       * @var int $size default value of the size
  243.       ***/
  244.     protected $size           = 30;
  245.     /**
  246.       * @var int maxlength default value of maxlength
  247.       ***/
  248.     protected $maxlength      = 65000;
  249.  
  250.     /**
  251.       * @var string $addTag htmlcode to add in fields input col
  252.       ***/
  253.     protected $addTag         = "";
  254.     /**
  255.       * @var bool $hideAddTag_ro hide addTag in readonly view
  256.       * @since pk-05-02-25
  257.       ***/
  258.     protected $hideAddTag_ro  = False;
  259.     /**
  260.       * @var $labeltd_add htmlcode to add in the <td > tag of the label
  261.       * @since pk-04-02-03
  262.       ***/
  263.     protected $labeltd_add    = "";
  264.     /**
  265.       * @var $labelcol_hide hide labelcolumn and set fieldcol rowspan=2
  266.       * @since pk-04-02-05
  267.       ***/
  268.     protected $labelcol_hide  = False;
  269.  
  270.     /**
  271.       * @var $fieldtd_add htmlcode to add in the <td > tag of the field
  272.       * @since pk-04-02-03
  273.       ***/
  274.     protected $fieldtd_add    = "";
  275.     /**
  276.       * @var bool $allowNull    is only used if db desc allows null
  277.       ***/
  278.     protected $allowNull     = True;
  279.  
  280.     /**
  281.       * @var string $nullErrMsg error message to set if value is null
  282.       ***/
  283.     protected $nullErrMsg    = "";
  284.     /**
  285.       * @var string $errMsg current ErrorMsg of the field if empty the field does not have an error
  286.       * @since pk-07-07-11
  287.       */
  288.     protected $errMsg = "";
  289.  
  290.     /**
  291.      * as we need the $arrName nearly everywhere it is defined as object var
  292.      * 
  293.      * @var string $myDataArrName 
  294.      *
  295.      * @version pk-03-10-19
  296.      */
  297.     protected $myDataArrName="DBVAL";
  298.  
  299.     /**
  300.      * the default value for $myDataArrName
  301.      * 
  302.      * @var string $ps_defaultDataArrName 
  303.      *
  304.      * @version  pk-03-10-19
  305.      */
  306.     protected $ps_defaultDataArrName="DBVAL";
  307.  
  308.     /**
  309.       * url to open for field help window if not empty a ? icon
  310.       * is added to the label and linked with the url as popup
  311.       *
  312.       * @var string $myHelpUrl 
  313.       *
  314.       * @since pk-03-12-17
  315.       *
  316.       ***/
  317.     protected $myHelpUrl="";
  318.  
  319.     /**
  320.       * fieldkey of the show group
  321.       *
  322.       * @var string $myGrpKey 
  323.       * @since pk-04-02-23
  324.       *
  325.       ***/
  326.     protected $myGrpKey="";
  327.  
  328.     /**
  329.       * debug
  330.       *
  331.       * @var bool $fldDebug 
  332.       * @since pk-04-06-02
  333.       *
  334.       */
  335.     protected $fldDebug=False;
  336.  
  337.     /**
  338.       * @var bool $fldDbgGetValue debug getValue Method
  339.       * @since pk-05-02-11
  340.       */
  341.     protected $fldDbgGetValue=False;
  342.  
  343.     /** 
  344.      * add javascript check
  345.      *
  346.      * @var bool $js_check 
  347.      * @since pk-04-07-23
  348.      *
  349.      */
  350.     protected $js_check=False;
  351.  
  352.     /**
  353.       * regex check
  354.       * @var string $regexcheck_pattern 
  355.       * @since pk-04-07-23
  356.       * @version pk-05-08-09
  357.       *
  358.       */
  359.     protected $regexcheck_pattern="";
  360.  
  361.     /**
  362.       * @var string $regexErrMsg 
  363.       * @since pk-05-08-09
  364.       */
  365.     protected $regexErrMsg="";
  366.  
  367.     /**
  368.       * @var boolean $trimValue 
  369.       * @since pk-05-09-14
  370.       */
  371.     protected $trimValue=False;
  372.  
  373.  
  374.     /**
  375.       * hide the file in read only mode
  376.       * hide is used to not have to update
  377.       * all forms
  378.       *
  379.       * @var boolean $showReadOnly 
  380.       * @since pk-04-10-13
  381.       */
  382.     protected $hideReadOnly=False;
  383.  
  384.     /**
  385.       * @var int $tabIndex 
  386.       * @since pk-05-02-18
  387.       */
  388.     protected $tabIndex=0;
  389.  
  390.     /**
  391.       * @var int $myCurrentMode 
  392.       * @since pk-05-02-25
  393.       */
  394.     protected $myCurrentMode=FRM_MODE_READONLY;
  395.  
  396.     /**
  397.       * @var int $lstColSpan 
  398.       * @since pk-05-03-17
  399.       */
  400.     protected $lstColSpan=1;
  401.     
  402.     /**
  403.      * col width in lists
  404.      * 
  405.      * @var int $lstWidth 
  406.      * 
  407.      * @since pk-08-06-03
  408.      */
  409.     protected $lstWidth = 0;
  410.     
  411.     /**
  412.       * @var string $lstTDAdd 
  413.       * @since pk-05-07-08
  414.       */
  415.     protected $lstTDAdd="";
  416.  
  417.     /**
  418.       * @var boolean $lstDisableLinks do not link list cell
  419.       * @since pk-05-03-17
  420.       */
  421.     protected $lstDisableLinks=False;
  422.  
  423.     /**
  424.       * @var array $lstLink link col ('A' => <a ....>, 'TEXT' => Button)
  425.       * @since pk-05-04-15
  426.       ***/
  427.     protected $lstLink=array();
  428.  
  429.     /**
  430.       * @var int $srcVersion  current version of the source to discover old version serialized object in the database
  431.       * @since pk-05-03-25
  432.       */
  433.     protected $srcVersion=0;
  434.  
  435.     /**
  436.       * @var boolean $toolTipAsTitle 
  437.       * @since pk-05-09-05
  438.       */
  439.     protected $toolTipAsTitle=False;
  440.  
  441.     /**
  442.       * @var boolean $searchGroup_allowAll add NULL in getTableValSelect()?
  443.       * @since pk-05-10-23
  444.       */
  445.     protected $searchGroup_allowAll=True;
  446.  
  447.     /**
  448.       * @var string $showQuery 
  449.       * @since pk-05-11-15
  450.       */
  451.     protected $showQuery="";
  452.  
  453.     /**
  454.       * @var boolean $showQasHidden if True the field is echoed hidden showQuery don't fit else field is not echoed
  455.       * @since since pk-06-11-15
  456.       */
  457.     protected $showQasHidden=False;
  458.  
  459.     /**
  460.       * @var int $showGroup the user must be member of this group (id) to see the field
  461.       * @since pk-06-10-08
  462.       * @access protected
  463.       */
  464.     protected $showGroup="0"// public as default
  465.  
  466.     /**
  467.       * @var string $inputAdd 
  468.       * @since pk-05-11-15
  469.       */
  470.     protected $inputAdd="";
  471.  
  472.     /**
  473.       * @var boolean $exportCSV 
  474.       * @since pk-06-09-27
  475.       */
  476.     protected $exportCSV=True;
  477.  
  478.     /**
  479.       * @var array $ajaxNotifyLst a list of fields and commands to notify onChange
  480.       * @since pk-07-03-05
  481.       * @access protected
  482.       */
  483.     protected $ajaxNotifyLst = array();
  484.  
  485.     /**
  486.       * @var boolean $ajaxDebug 
  487.       * @since pk-07-09-24
  488.       * @access protected
  489.       */
  490.     protected $ajaxDebug=False;
  491.  
  492.     /**
  493.      * xtype to use in the extJS framework for the field
  494.      * 
  495.      * @var string $extJSxType 
  496.      */
  497.     protected $extJSxType = 'field';
  498.     
  499.     /**
  500.      * extJS configuration options
  501.      *
  502.      * @var string 
  503.      */
  504.     protected $extConfOptions = "";
  505.     
  506.     // --------------------------------------------------------
  507.     // factory / construct
  508.     // --------------------------------------------------------
  509.     
  510.  
  511.     /**
  512.       * initialises the object
  513.       *
  514.       * @param string   $aTable     name of the table where the field is a column
  515.       * @param string   $aName      name of the table column
  516.       * @param array    $aDesc      database column description
  517.       * @param int      $sOrder     sort order
  518.       * @param string   $aLabel     Label of the field
  519.       * @param string   $aAlias     db table alias in a join
  520.       *
  521.       * @version pk-04-07-29
  522.       * @version pk-04-10-05 no params required
  523.       */
  524.     function DBMS_FIELD ($aTable=NULL,$aName=NULL,$aDesc=NULL,$sOrder=99999,$aLabel="",$aAlias=NULL,$aFormId=0{
  525.         if ($aTable != NULL{
  526.             $this->myTable  =$aTable;
  527.             $this->myName   =$aName;
  528.             $this->dbDesc   =$aDesc;
  529.             $this->sortOrder=$sOrder;
  530.  
  531.             if ($aAlias{
  532.                 $this->myTableAlias=$aAlias;
  533.             else {
  534.                 $this->myTableAlias=$aTable;
  535.             }
  536.             if (empty($aLabel)) {
  537.                 $this->label=$this->myName;
  538.             else {
  539.                 $this->label=$aLabel;
  540.             }
  541.  
  542.  
  543.             if (isset($aDesc['PRIMARY_KEY']&& $aDesc['PRIMARY_KEY']// <pk-06-09-21 /> E_ALL
  544.                 $this->enableEdit=False;
  545.                 $this->isSearchable=True;
  546.                 if ($aDesc['AUTO_INCREMENT'])
  547.                     $this->enableNew=False;
  548.                     $this->enableCopy=False;
  549.             }
  550.  
  551.             $this->maxlength    =(isset($aDesc['LEN']intval($aDesc['LEN']255);
  552.             $this->defaultValue =(isset($this->dbDesc['DEFAULT']$this->dbDesc['DEFAULT'NULL);
  553.             if ($this->size > $this->maxlength$this->size=$this->maxlength;
  554.             $this->allowNull = (isset($this->dbDesc['NULL']$this->dbDesc['NULL'True)// <pk-06-12-01 /> E_ALL
  555.         }
  556.     }
  557.  
  558.     // --------------------------------------------------------
  559.     // getter / setter
  560.     // --------------------------------------------------------
  561.     
  562.     
  563.     /**
  564.       * returns the source file of the class
  565.       * without
  566.       * - $GLOBALS['PROJECT']['PATH']
  567.       * - __OCSP_PHPINCPATH__ (if not in project path)
  568.       *
  569.       * overwrite this
  570.       *
  571.       * @param boolean $debug 
  572.       *
  573.       * @return string 
  574.       *
  575.       * @since pk-04-10-05
  576.       * @version pk-05-02-10
  577.       * @version pk-05-12-01 compleate rewrite of the method
  578.       *
  579.       */
  580.     function getSourceFile($debug=False{
  581.         if ($debugecho "<p><b>DBMS_FIELD::getSourceFile(...)</b> (".get_class($this).")";
  582.  
  583.         $s_ret=$this->classSrcFile;
  584.         if (strtolower(basename($s_ret))==strtolower(get_class($this)).".phpclass"{
  585.             // file named like class seams to be ok
  586.             if ($debugecho "<blockquote><p>filename is class name</p></blockquote>";
  587.             return pcf_pathToTmplate($s_ret);
  588.         else if (!empty($s_ret&& ($s_ret != __FILE__)) {
  589.             // classSrcFile is set somewhere child class
  590.             if ($debugecho "<blockquote><p>filename not ../DBMS_FIELD.phpclass</p></blockquote>";
  591.             return pcf_pathToTmplate($s_ret);
  592.         }
  593.  
  594.         // now we are in trubles where is the class loaded from?
  595.         // hope it's somewhere in the path or the object dealing with this information knows what to do
  596.         if ($debugecho "<blockquote><p>filename not set return className: ".strtoupper(get_class($this)).".phpclass</p></blockquote>";
  597.         return strtoupper(get_class($this)).".phpclass";
  598.    }
  599.  
  600.     /**
  601.       * returns an 2 dimensional array of object data
  602.       *
  603.       * - $ret['OBJDESC'] -> discription of the object
  604.       * - $ret['OBJVAL']  -> get_object_vars($this)
  605.       *
  606.       * @param boolean $debug 
  607.       *
  608.       * @return array 
  609.       *
  610.       * @since pk-04-10-05
  611.       * @version pk-07-03-06
  612.       *
  613.       * @access public
  614.       */
  615.     function getObjectData($debug=False{
  616.         if ($debugecho "<p><b>DBMS_FIELD::getObjectData(...)</b> (".get_class($this).")</p>";
  617.         $a_ret=array();
  618.  
  619.         $a_ret['OBJDESC']=array(
  620.             'CLASS'     => strtoupper(get_class($this)),
  621.             'SRCFILE'   => $this->getSourceFile($debug),
  622.             'CTIMESTMP' => time()
  623.         );
  624.  
  625.         $a_ret['OBJVAL']=$this->getObjectVars($debug);
  626.  
  627.         return $a_ret;
  628.     }
  629.  
  630.     /**
  631.       * returns an array of the object vars
  632.       * see also php function get_object_vars
  633.       *
  634.       * @param boolean $debug 
  635.       *
  636.       * @return array 
  637.       *
  638.       * @version pk-07-03-06
  639.       * @version pk-07-08-05
  640.       *
  641.       * @access public
  642.       *
  643.       */
  644.     function getObjectVars($debug=False{
  645.         if ($debugecho "<p><b>DBMS_FIELD::getObjectVars(...)</b> (".get_class($this).")</p>";
  646.  
  647.         $a_ret=get_object_vars($this);
  648.  
  649.         // <pk-07-08-04> remove linked objects and ensure the id's are set
  650.         if (pcf_is_instance_of($this->myForm,'OCSP_FORM'))
  651.         {
  652.             $a_ret['myFrmId']=$this->myForm->getId();
  653.         }
  654.         if (pcf_is_instance_of($this->myBlock,'OCSP_FORM_BLOCK'))
  655.         {
  656.             $a_ret['myBlockId']=$this->myBlock->getId();
  657.         }
  658.         unset($a_ret['myForm']);
  659.         unset($a_ret['myBlock']);
  660.         unset($a_ret['myAjaxObj']);
  661.         unset($a_ret['myControll']);
  662.         unset($a_ret['myView']);
  663.         unset($a_ret['myDOMId'])// <pk-08-06-09 />
  664.         unset($a_ret['exportCVS'])// <pk-08-11-27 />
  665.         // </pk-07-08-04>
  666.  
  667.         $a_ret['classSrcFile']=pcf_pathToTmplate($a_ret['classSrcFile']);
  668.  
  669.         return $a_ret;
  670.     }
  671.  
  672.     /**
  673.       * sets the objectvars
  674.       * return value is used to raise an error
  675.       * by default True is returned at the moment
  676.       *
  677.       * @param array $varArr 
  678.       * @param boolean $debug 
  679.       *
  680.       * @return boolean 
  681.       *
  682.       * @since pk-04-10-05
  683.       * @version pk-07-03-06
  684.       *
  685.       * @access public
  686.       */
  687.     function setObjectVars($varArr,$debug=False{
  688.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::setObjectVars(...)",print_r($varArr,True));
  689.  
  690.         if (is_array($varArr)) {
  691.             foreach($varArr as $s_name => $s_val{
  692.                 switch($s_name{
  693.                     case "classSrcFile":
  694.                         if (empty($this->classSrcFile|| (!file_exists($this->classSrcFile))) {
  695.                             $this->classSrcFile=pcf_parsePathTmpl($s_val,$varArr);
  696.                         }
  697.                         break;
  698.                     case "myForm":
  699.                         if ((pcf_is_instance_of($s_val,'DBMS_FORM')) && intval($s_val->getId())) {
  700.                             $this->setFrmId($s_val->getId());
  701.                         }
  702.                         break;
  703.                     case "className":
  704.                         unset($varArr['className'])// unused very old code
  705.                         break;
  706.                     case "myDOMId":
  707.                         unset($varArr['myDOMId'])// unset DOM Id
  708.                         break;
  709.                     case "exportCVS":
  710.                         unset($varArr['exportCVS'])// misspelled old var name <pk-08-11-27>
  711.                         $this->exportCSV = $s_val;
  712.                         break;
  713.                     default:
  714.                         $this->$s_name=$s_val;
  715.                 }
  716.             }
  717.         }
  718.     }
  719.  
  720.     /**
  721.       * sets the object vars from an other object
  722.       *
  723.       * @param DBMS_FIELD $fld 
  724.       * @param boolean $debug 
  725.       * 
  726.       * @version pk-07-10-31
  727.       */
  728.     function setObjVarsFrom($fld,$debug=False)
  729.     {
  730.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::setObjVarsFrom()");
  731.         $arr_oldVals=$fld->getObjectVars()// <pk-07-10-31 />
  732.  
  733.         if (isset($arr_oldVals['className'])) unset($arr_oldVals['className'])// old value
  734.         unset($arr_oldVals['classSrcFile']);
  735.  
  736.         foreach($arr_oldVals as $str_key => $mixed_val)
  737.         {
  738.             $this->{$str_key}=$mixed_val;
  739.         }
  740.  
  741.         try {
  742.             $this->setMyForm($fld->getMyForm());
  743.             $this->setMyBlock($fld->getMyBlock());
  744.             $this->myDOMId="";
  745.         catch(Exception $e{
  746.             if ($debugechoDebugLine(__FILE__,__LINE__,"<h1>Exception: </h1><pre>" print_r($e,True"</pre>");
  747.         }
  748.     }
  749.  
  750.     /**
  751.       * marks the field as deleted by setting $this->myDeleteFlag to true
  752.       * the next time the field is written to the database it should be deleted
  753.       */
  754.     function markDeleted()
  755.     {
  756.         $this->myDeleteFlag=True;
  757.     }
  758.  
  759.     /**
  760.       * returns if the field is marked as deleted
  761.       * @return boolen 
  762.       */
  763.     function isMarkedDeleted()
  764.     {
  765.         return $this->myDeleteFlag;
  766.     }
  767.  
  768.     /**
  769.       * removes the deleteFlag
  770.       */
  771.     function markUnDeleted()
  772.     {
  773.         $this->myDeleteFlag=False;
  774.     }
  775.  
  776.     //
  777.     // sorting methods --------------------------------------------------------------------------------
  778.     //
  779.  
  780.     /**
  781.       * returns the orderNr of the field
  782.       *
  783.       * @return int 
  784.       *
  785.       * @since pk-06-12-01
  786.       * @access public
  787.       *
  788.       * @version pk-07-05-02 bugfix orderNr => sortOrder
  789.       *
  790.       */
  791.     function getOrderNr({
  792.         return intval($this->sortOrder);
  793.     }
  794.  
  795.     /**
  796.       * sets the orderNr of the field
  797.       *
  798.       * @param int $anr 
  799.       *
  800.       * @since pk-06-12-01
  801.       * @access public
  802.       *
  803.       * @version pk-07-05-02 bugfix orderNr => sortOrder
  804.       *
  805.       */
  806.     function setOrderNr($aNr{
  807.         $this->sortOrder=intval($aNr);
  808.     }
  809.  
  810.     /**
  811.       * increase orderNr by 1
  812.       *
  813.       * @param int $by 
  814.       *
  815.       * @since pk-06-12-02
  816.       * @access public
  817.       *
  818.       * @version pk-07-05-02 bugfix orderNr => sortOrder
  819.       *
  820.       */
  821.     function incOrderNr($by=1{
  822.         $this->sortOrder=intval($this->sortOrder)+intval($by);
  823.     }
  824.     
  825.     /**
  826.      * returns the tabIndex of the field
  827.      *
  828.      * @return int 
  829.      * @since pk-07-10-26
  830.      */
  831.     function getTabIndex(
  832.     {
  833.         return intval($this->tabIndex);
  834.     }
  835.  
  836.     // ###########################################################
  837.     // OBJECT SETTINGS METHODS
  838.     // ###########################################################
  839.  
  840.     /**
  841.       * sets myDataArrName
  842.       *
  843.       * @param string $arrName 
  844.       *
  845.       * @since pk-04-09-08
  846.       *
  847.       ***/
  848.     function setDataArrName($arrName
  849.     {
  850.         if ($this->fldDebugecho "<p>Setting DataArrName to: ".$arrName."</p>";
  851.         if (!empty($arrName))  $this->myDataArrName=$arrName;
  852.     }
  853.  
  854.     /**
  855.       * @return string 
  856.       * @since pk-07-02-27
  857.       ***/
  858.     function getDataArrName(
  859.     {
  860.         return (!empty($this->myDataArrName$this->myDataArrName "DBVAL");
  861.     }
  862.  
  863.  
  864.     /**
  865.      * returns a field setting value
  866.      *
  867.      * @param string $name 
  868.      * 
  869.      * @return mixed 
  870.      * 
  871.      */
  872.     function getSetting($name
  873.     {
  874.         return $this->{$name};
  875.     }
  876.  
  877.     /**
  878.      * returns the database column type of the field
  879.      *
  880.      * @return string 
  881.      */
  882.     function getType(
  883.     {
  884.         return "string";
  885.     }
  886.  
  887.  
  888.     /**
  889.       * returns the database type of the fields column
  890.       *
  891.       * @return string 
  892.       * @since pk-07-04-28
  893.       * @access public
  894.       */
  895.     function getDBColType()
  896.     {
  897.         return $this->dbDesc['TYPE'];
  898.     }
  899.  
  900.     /**
  901.       * returns the table of the field
  902.       *
  903.       * @return string 
  904.       *
  905.       * @since pk-05-07-11
  906.       *
  907.       ***/
  908.     function getTable(
  909.     {
  910.         return $this->myTable;
  911.     }
  912.  
  913.     /**
  914.      * returns the table alias used in joins
  915.      * normaly this is the same as $this->myTable
  916.      *
  917.      * @return string 
  918.      * @since pk-07-10-26
  919.      */
  920.     function getTblAlias()
  921.     {
  922.         if (empty($this->myTableAlias))
  923.         {
  924.             return $this->myTable;
  925.         else {
  926.             return $this->myTableAlias;
  927.         }
  928.     }
  929.     
  930.     /**
  931.      * sets the table alias
  932.      *
  933.      * @param string $alias 
  934.      * 
  935.      * @since pk-08-07-12
  936.      */
  937.     public function setTblAlias($alias)
  938.     {
  939.         $this->myTableAlias $alias;
  940.     }
  941.     
  942.     /**
  943.       * returns the databas column name
  944.       *
  945.       * @param boolean $withAlias 
  946.       * 
  947.       *  if empty $this::dbDesc['COLNAME'] $this->getName() is returned
  948.       *  which should in most cases be same as dbDesc['COLNAME']
  949.       *
  950.       * @return string 
  951.       *
  952.       * @version pk-03-10-22
  953.       * @version pk-05-02-16
  954.       * @version pk-07-12-29 $withAlias added
  955.       *
  956.       */
  957.     function getDBColName($withAlias=True{
  958.         if (!empty($this->dbDesc['COLNAME'])) {
  959.             if ($withAlias)
  960.                 return $this->myTableAlias.".".$this->dbDesc['COLNAME'];
  961.             else                 
  962.                 return $this->dbDesc['COLNAME'];
  963.         else {
  964.             if ((!$withAlias&& ($this->myTable != DBMS_NO_DBFIELD)) {
  965.                 return $this->myName;                
  966.             }
  967.         }
  968.     }
  969.  
  970.     /**
  971.       * returns $dbDesc (COPY OF THE ARRAY)
  972.       *
  973.       * @return array 
  974.       *
  975.       * @version pk-03-10-22
  976.       *
  977.       */
  978.     function getdbDesc({
  979.         return $this->dbDesc;
  980.     }
  981.  
  982.     /**
  983.      * sets the database column description array
  984.      *  
  985.      * @param array $dbDesc 
  986.      * @since pk-07-09-19
  987.      */
  988.     function setdbDesc($dbDesc)
  989.     {
  990.         $this->dbDesc=$dbDesc;
  991.     }
  992.  
  993.     /**
  994.       * returns if the field is (part of) the primary key
  995.       * @param boolean $debug 
  996.       * @return boolean 
  997.       *
  998.       * @since pk-06-08-07
  999.       *
  1000.       ***/
  1001.     function isPrimaryKey($debug=False{
  1002.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::isPrimaryKey() [".$this->getKey()."]",print_r($this->dbDesc,True));
  1003.         if (isset($this->dbDesc['PRIMARY_KEY'])) {
  1004.             return (intval($this->dbDesc['PRIMARY_KEY']True False);
  1005.         else {
  1006.             return False;
  1007.         }
  1008.     }
  1009.     
  1010.  
  1011.     /**
  1012.       * returns the field key
  1013.       * ($this->myTableAlias.".".$this->myName)
  1014.       *
  1015.       * @return string 
  1016.       */
  1017.     function getKey({
  1018.         return $this->myTableAlias.".".$this->myName;
  1019.     }
  1020.  
  1021.  
  1022.  
  1023.  
  1024.     /**
  1025.       * returns the field name
  1026.       *
  1027.       * @return string 
  1028.       ***/
  1029.     function getName({
  1030.         return $this->myName;
  1031.     }
  1032.  
  1033.  
  1034.     /**
  1035.       * returns the debug mode of the field
  1036.       * - D fldDebug
  1037.       * - G fldDbgGetValue
  1038.       * - A ajaxDebug
  1039.       *
  1040.       * @return string 
  1041.       * @since pk-07-09-24
  1042.       */
  1043.     function getDebugMode()
  1044.     {
  1045.         $str_ret="";
  1046.         if ($this->fldDebug)            $str_ret.="D";
  1047.         if ($this->fldDbgGetValue)      $str_ret.="G";
  1048.         if ($this->ajaxDebug)           $str_ret.="A";
  1049.  
  1050.         return $str_ret;
  1051.     }
  1052.  
  1053.  
  1054.     // OCSP_FORM
  1055.  
  1056.     /**
  1057.       * sets the id of the form the field belongs to
  1058.       *
  1059.       * @parma int $aId;
  1060.       * @since pk-04-02-23
  1061.       *
  1062.       ***/
  1063.     function setFrmId($aId{
  1064.         $this->myFrmId=intval($aId);
  1065.     }
  1066.  
  1067.     /**
  1068.       * returns the id of the form the field belongs to
  1069.       *
  1070.       * @return int 
  1071.       *
  1072.       * @since pk-04-02-23
  1073.       * @access public
  1074.       ***/
  1075.     function getFrmId({
  1076.         return intval($this->myFrmId);
  1077.     }
  1078.  
  1079.     /**
  1080.       * sets the owner form Object
  1081.       *
  1082.       * @param DBMS_FORM $frmObj 
  1083.       * @param boolean $force 
  1084.       *
  1085.       * @since pk-05-09-14
  1086.       * @version pk-06-11-09 ensure myFrmId is also set
  1087.       * @version pk-08-01-16 $force
  1088.       * 
  1089.       */
  1090.     function setMyForm(&$frmObj,$force=False{
  1091.         if ($force || (!is_object($this->myForm|| ($this->myForm->getId(!= $frmObj->getId())))           
  1092.         {
  1093.             $this->myForm=$frmObj;
  1094.             $this->setFrmId($frmObj->getId());
  1095.         }
  1096.     }
  1097.  
  1098.     /**
  1099.       * returns a pointer to the owner form or NULL in case of error
  1100.       *
  1101.       * @param bool $debug since pk-05-01-11
  1102.       *
  1103.       * @return OCSP_FORM 
  1104.       *
  1105.       * @since pk-04-07-29
  1106.       * @version pk-05-01-11
  1107.       * @version pk-05-09-14
  1108.       * @version pk-06-11-19 always set myForm
  1109.       * @version pk-08-01-16
  1110.       *
  1111.       */
  1112.     function &getMyForm($debug=False{
  1113.         if (pcf_is_instance_of($this->myForm,'OCSP_FORM')) {
  1114.             return $this->myForm;
  1115.         else if ($int_formId $this->getFrmId()) {
  1116.                pcf_require_class('OCSP_FORM',"db/forms/");
  1117.             $this->myForm=OCSP_FORM::factory_from_id($this->getFrmId());
  1118.             return $this->myForm;
  1119.         else {            
  1120.             throw new Exception(_OCSP_EXCEP_NOFORM_);
  1121.         }
  1122.     }
  1123.  
  1124.     /**
  1125.       * returns the name of the form
  1126.       *
  1127.       * @return string 
  1128.       *
  1129.       * @since pk-04-12-29
  1130.       *
  1131.       ***/
  1132.     function getMyFormName({
  1133.         if ($myForm=$this->getMyForm()) {
  1134.             return $myForm->getHTMLName();
  1135.         else {
  1136.             return "frmEdit";
  1137.         }
  1138.     }
  1139.  
  1140.  
  1141.     // OCSP_FORM_BLOCK
  1142.  
  1143.     /**
  1144.       * @param OCSP_FORM_BLOCK &$aBlock 
  1145.       * @param boolean $debug 
  1146.       */
  1147.     function setMyBlock(&$aBlock,$debug=False)
  1148.     {
  1149.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::setMyBlock()");
  1150.         $this->myBlock=$aBlock;
  1151.         if (pcf_is_instance_of($this->myBlock,'OCSP_FORM_BLOCK'))
  1152.         {
  1153.             if ($debugechoDebugLine(__FILE__,__LINE__,"setting myBlockId to ".$this->myBlock->getId());
  1154.             $this->myBlockId=$this->myBlock->getId();
  1155.         else {
  1156.             if ($debugechoDebugLine(__FILE__,__LINE__,"setting myBlockId to 0 \n".get_class($aBlock));
  1157.             $this->myBlockId=0;
  1158.         }
  1159.     }
  1160.  
  1161.     /**
  1162.       * @return OCSP_FORM_BLOCK 
  1163.       * 
  1164.       * @version pk-08-08-08
  1165.       */
  1166.     function &getMyBlock()
  1167.     {
  1168.         if (pcf_is_instance_of($this->myBlock,'OCSP_FORM_BLOCK'))
  1169.         {
  1170.             return $this->myBlock;
  1171.         else if (intval($this->myBlockId&& $this->myForm{
  1172.             return $this->myForm->getBlock(intval($this->myBlockId));
  1173.         else {
  1174.             return $this->myBlock;
  1175.         }
  1176.     }
  1177.  
  1178.     /**
  1179.       * @return int 
  1180.       */
  1181.     function getBlockId()
  1182.     {
  1183.         if (pcf_is_instance_of($this->myBlock,'OCSP_FORM_BLOCK'))
  1184.         {
  1185.             return $this->myBlock->getId();
  1186.         else {
  1187.             return $this->myBlockId;
  1188.         }
  1189.     }
  1190.  
  1191.     /**
  1192.       * @return string 
  1193.       * @access public
  1194.       * @since pk-07-08-07
  1195.       */
  1196.     function getModuleKey()
  1197.     {
  1198.         if (empty($this->myModuleKey))
  1199.         {
  1200.             return "DBMS";
  1201.         else {
  1202.             return $this->myModuleKey;
  1203.         }
  1204.     }
  1205.  
  1206.     /**
  1207.       * @param string $modKey 
  1208.       * @access public
  1209.       * @since pk-07-08-07
  1210.       */
  1211.     function setModuleKey($modKey)
  1212.     {
  1213.         $this->myModuleKey=$modKey;
  1214.     }
  1215.  
  1216.  
  1217.     /**
  1218.       * returns the td id of the value col
  1219.       *
  1220.       * @return string 
  1221.       *
  1222.       * @since pk-07-02-28
  1223.       *
  1224.       * @access public
  1225.       ***/
  1226.     function getValId({
  1227.        return preg_replace("/[^a-zA-Z0-9]/","_","td_".$this->getFrmId()."_".$this->getKey());
  1228.     }
  1229.  
  1230.  
  1231.     /**
  1232.       * sets the field name
  1233.       * @param string $aName 
  1234.       *
  1235.       ***/
  1236.     function setName($aName{
  1237.         if (!empty($aName)) $this->myName=$aName;
  1238.     }
  1239.  
  1240.  
  1241.     /**
  1242.       * sets the field table (and load dbDesc again)
  1243.       *
  1244.       * @param string       $aTable 
  1245.       * @param bool         $getDesc    load field Desc from table def
  1246.       * @param string       $colPreFix  is added to db column name
  1247.       * @param bool         $debug 
  1248.       *
  1249.       * @return bool    success?
  1250.       *
  1251.       * @version pk-03-10-22
  1252.       * @version pk-06-07-14
  1253.       * @version pk-08-08-07
  1254.       */
  1255.     function setTable($aTable,$colPreFix="",$getDesc=True,$debug=False{
  1256.         if ($debugecho "<hr /><p><b>DBMS_FIELD::setTable($aTable,$colPreFix,$getDesc,$debug)</b></p><blockquote>";
  1257.  
  1258.         if (empty($aTable))  {
  1259.             if ($debugecho "<p>no table set</p></blockquote>";
  1260.             return False;
  1261.         }
  1262.  
  1263.         if ($aTable==DBMS_NO_DBFIELD || strstr($aTable,"OBJVAL")) {
  1264.             $this->myTable=$aTable;
  1265.             $this->myTableAlias=$aTable;
  1266.             $this->dbDesc['AUTO_INCREMENT']=False;
  1267.             $this->dbDesc['PRIMARY_KEY']=False;
  1268.             $this->dbDesc['KEY']=False;
  1269.             return True;
  1270.         }
  1271.         
  1272.         if (!OCSP_OBJ::defaultReadDBObj()->tblExists($aTable))  
  1273.         {
  1274.             if ($debugechoDebugLine(__FILE__,__LINE__,"<p style='color:red;'>returns False TABLE DOES NOT EXIST</p></blockquote><hr />");
  1275.             return False;    // table is not created
  1276.         }
  1277.  
  1278.         $fields=OCSP_OBJ::defaultReadDBObj()->getDBTblDesc($aTable);
  1279.         // if ($debug) {echo "<pre>".$colPreFix.$this->myName."\n";print_r($fields);echo "</pre>"; }
  1280.         if (is_array($fields[$colPreFix.$this->myName])) {
  1281.             $this->myTable=$aTable;
  1282.             $this->myTableAlias=$aTable;
  1283.             if ($getDesc{
  1284.                 $this->dbDesc=$fields[$colPreFix.$this->myName];
  1285.             }
  1286.             if ($debugechoDebugLine(__FILE__,__LINE__,"<pre>".print_r($this,True."</pre><p style='color:green;'>returns True</p></blockquote><hr />");
  1287.             return True;
  1288.         }
  1289.         if ($debugechoDebugLine(__FILE__,__LINE__,"<p style='color:red;'>returns False</p></blockquote><hr />");
  1290.         return False;
  1291.     }
  1292.  
  1293.     /**
  1294.       * sets the Form label text
  1295.       *
  1296.       * @param string $aLabel   text used in <td ...>$aLabel</td> column
  1297.       *
  1298.       ***/
  1299.     function setLabel($aLabel{
  1300.         if (!$aLabel$this->label=$aLabel;
  1301.     }
  1302.  
  1303.     /**
  1304.       * @return boolean 
  1305.       * @since pk-07-08-27
  1306.       */
  1307.     function labelIsHidden()
  1308.     {
  1309.         return $this->labelcol_hide;
  1310.     }
  1311.  
  1312.  
  1313.     /**
  1314.       * returns if the field is searchable or not
  1315.       *
  1316.       * @return boolean 
  1317.       *
  1318.       * @since pk-06-01-13
  1319.       *
  1320.       ***/
  1321.     function isSearchable({
  1322.         return $this->isSearchable;
  1323.     }
  1324.  
  1325.     /**
  1326.       * returns if the field is hidden or not
  1327.       *
  1328.       * @param string $scope 
  1329.       * @return boolean 
  1330.       * @access public
  1331.       *
  1332.       * @since pk-06-01-13
  1333.       * @version pk-07-05-02 scope added
  1334.       * @version pk-07-08-20 first check $this->isHidden
  1335.       * @version pk-08-06-03 $scope => setting
  1336.       ***/
  1337.     function isHidden($scope='setting'{
  1338.         switch($scope)
  1339.         {
  1340.             case "list":
  1341.                 if ($this->isHiddenreturn True;
  1342.                 return ($this->showInList ? False True);
  1343.             case "search":
  1344.                 if ($this->isHiddenreturn True;
  1345.                 return ($this->isSearchable(False True);
  1346.             case "form":
  1347.             default:
  1348.                 return $this->isHidden;
  1349.         }
  1350.     }
  1351.  
  1352.  
  1353.     /**
  1354.       * sets a field as hidden
  1355.       *
  1356.       * @param string $scope 
  1357.       * @access public
  1358.       *
  1359.       * @since pk-05-07-21
  1360.       * @version pk-07-05-02 scope added
  1361.       *
  1362.       ***/
  1363.     function setHidden($scope='form')
  1364.     {
  1365.         switch($scope)
  1366.         {
  1367.             case "list":
  1368.                 $this->showInList=False;
  1369.                 break;
  1370.             case "search":
  1371.                 $this->isSearchable=False;
  1372.                 break;
  1373.             case "form":
  1374.             default:
  1375.                 $this->isHidden=True;
  1376.                 break;
  1377.         }
  1378.     }
  1379.  
  1380.     /**
  1381.       * sets a field as shown
  1382.       *
  1383.       * @param string $scope 
  1384.       * @access public
  1385.       *
  1386.       * @since pk-05-07-21
  1387.       * @version pk-07-05-02 scope added
  1388.       *
  1389.       */
  1390.     function setShown($scope='form')
  1391.     {
  1392.         switch($scope)
  1393.         {
  1394.             case "list":
  1395.                 $this->showInList=True;
  1396.                 break;
  1397.             case "search":
  1398.                 $this->isSearchable=True;
  1399.                 break;
  1400.             case "form":
  1401.             default:
  1402.                 $this->isHidden=False;
  1403.                 break;
  1404.         }
  1405.     }
  1406.  
  1407.     /**
  1408.       * sets a field value
  1409.       *
  1410.       * @param string $varName 
  1411.       * @param mixed $value 
  1412.       * @param boolean $debug 
  1413.       *
  1414.       * @since pk-06-07-22
  1415.       *
  1416.       */
  1417.     function setFieldVar($varName,$value,$debug=False{
  1418.         $debug=($this->fldDebug $debug);
  1419.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::setFieldVar()","$varName$value");
  1420.  
  1421.         $this->{$varName}=$value;
  1422.     }
  1423.  
  1424.     // ###########################################################
  1425.     // FIELD DEFINITION DATA METHODS
  1426.     // ###########################################################
  1427.  
  1428.     /**
  1429.       * checks if a db fieldtype is compatible to the class
  1430.       *
  1431.       * @param string $fldType 
  1432.       * @param boolean $debug 
  1433.       *
  1434.       * @return boolean 
  1435.       *
  1436.       * @since pk-05-04-18
  1437.       *
  1438.       * @version pk-05-06-24
  1439.       * @version pk-06-02-10
  1440.       * @version pk-06-04-07 DECIMAL added
  1441.       *
  1442.       ***/
  1443.     function fldTypeIsUseable($fldType,$debug=False{
  1444.         if ($debugecho "<p><b>DBMS_FIELD::fldTypeIsUseable($fldType)</b> (".get_class($this)."/".$this->getName().")</p>";
  1445.  
  1446.         if (strtoupper($fldType)==strtoupper($this->dbDesc['TYPE'])) return True;
  1447.  
  1448.         /* ok no direct compare -> check more or other spellling */
  1449.  
  1450.         switch(strtoupper($fldType)) {
  1451.             case "REAL":   // <pk-05-06-24 />
  1452.                     if (strtoupper($this->dbDesc['TYPE']== "FLOAT"return True;
  1453.                     if (strtoupper($this->dbDesc['TYPE']== "DECIMAL"return True;
  1454.                     break;
  1455.             case "STRING":  // <pk-06-06-24 />
  1456.             case "VARCHAR":
  1457.                     if (strtoupper($this->dbDesc['TYPE']== "STRING"return True;
  1458.                     if (strtoupper($this->dbDesc['TYPE']== "VARCHAR"return True// <pk-06-02-10 />
  1459.                     break;
  1460.             case "INT":
  1461.             case "SMALLINT":
  1462.             case "TINYINT":
  1463.                     if (stristr($this->dbDesc['TYPE'],$fldType)) return True;
  1464.                     if (stristr("int",$fldType)) return True;
  1465.                     break;
  1466.             default:
  1467.                     if (stristr($this->dbDesc['TYPE'],$fldType)) return True;
  1468.         }
  1469.  
  1470.         return False;
  1471.     }
  1472.  
  1473.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1474.     // methods used in dbms admin (fieldlist.php*)
  1475.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1476.  
  1477.     /**
  1478.       * return a css style definition for the fieldlist
  1479.       *
  1480.       * @return string 
  1481.       *
  1482.       * @since pk-06-10-13
  1483.       *
  1484.       ***/
  1485.     function editLst_getAdminLstStyle({
  1486.         $s_style="";
  1487.         if ($this->isHidden)                                $s_style.="background: #c0c0c0;";
  1488.  
  1489.         if ((!$this->enableNew&& (!$this->enableEdit))    return $s_style."color: #FF0000;";
  1490.         if (!$this->enableNew)                              return $s_style."color: #FFCC66;";
  1491.         if (!$this->enableEdit)                             return $s_style."color: #DD66DD;";
  1492.  
  1493.         return $s_style;
  1494.     }
  1495.  
  1496.      /**
  1497.        * returns the option list for the class select element
  1498.        *
  1499.        * @param boolean $debug 
  1500.        *
  1501.        * @return string 
  1502.        * @since pk-07-08-06
  1503.        * 
  1504.        * @version pk-08-05-19
  1505.        * @version pk-08-06-06
  1506.        * 
  1507.        * @todo dirty workaround
  1508.        * 
  1509.        */
  1510.     function editLst_getClassSelectOptions($debug=False)
  1511.     {
  1512.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::editLst_getClassSelectOptions()");
  1513.  
  1514.         if (!isset($GLOBALS['DBMS_FIELD_DESC']))
  1515.         {
  1516.             include __OCSP_PHPINCPATH__ "db" _OCSP_DIRSEP_ "forms" _OCSP_DIRSEP_ "forms.phpinc";
  1517.         }
  1518.         
  1519.         $str_ret "";
  1520.         //$str_ret="<option>DBTYPE: " . $this->dbDesc['TYPE'] ."</option>";
  1521.         $a_options=array();
  1522.         foreach($GLOBALS['DBMS_FIELD_DESC'as $key => $fldArr{
  1523.             if ((stristr($key,"any")) || $this->fldTypeIsUseable($fldArr['FLD_TYPE']) ) {
  1524.                 $a_options[$fldArr['FLD_CLASS']]=$fldArr['FLD_SELNAME'];
  1525.             else if (strtoupper($this->dbDesc['TYPE']== strtoupper($fldArr['FLD_TYPE'])) {
  1526.                 //$str_ret .= "<option>NOT USABLE: " . $fldArr['FLD_TYPE'] . "</option>";
  1527.                 $a_options[$fldArr['FLD_CLASS']]=$fldArr['FLD_SELNAME'];
  1528.             else if (stristr($key,$this->dbDesc['TYPE'].'_')) {
  1529.                 $a_options[$fldArr['FLD_CLASS']]=$fldArr['FLD_SELNAME'];
  1530.             else if (strtoupper($this->dbDesc['TYPE']== "DATE"{
  1531.                 if (strtoupper($fldArr['FLD_TYPE']== "DATETIME"{
  1532.                     $a_options[$fldArr['FLD_CLASS']]=$fldArr['FLD_SELNAME'];
  1533.                 }
  1534.             }
  1535.         }
  1536.         asort($a_options);
  1537.         foreach($a_options as $key => $s_Name{
  1538.                 $str_ret.= "\t<option value=\"".$key."\"".((strtolower($key== strtolower(get_class($this))) "selected" "").">";
  1539.                 $str_ret.= $s_Name."</option>\n";
  1540.         }
  1541.  
  1542.         return $str_ret;
  1543.     }
  1544.  
  1545.  
  1546.     /**
  1547.       * returns the field definition form
  1548.       * from the field edit array @see editTbl_getFieldEditArr()
  1549.       *
  1550.       * @param array $fldEditArr 
  1551.       * @param boolen $debug 
  1552.       *
  1553.       * @return string 
  1554.       * @access public
  1555.       *
  1556.       * @since pk-07-05-03
  1557.       *
  1558.       */
  1559.     function editTbl_getForm($fldEditArr=NULL,$debug=False
  1560.     {
  1561.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::editTbl_echoForm","",0);
  1562.  
  1563.         if (!is_array($fldEditArr)) $fldEditArr=$this->editTbl_getFieldEditArr($debug);
  1564.  
  1565.         $str_ret="";
  1566.         foreach($fldEditArr as $s_section => $a_secFlds{
  1567.             if (!isset($a_secFlds['ISHIDDEN']|| (!$a_secFlds['ISHIDDEN'])) {
  1568.                 if (!empty($a_secFlds['TITLE'])) {
  1569.                     $str_ret.="<tr><th colspan=\"2\">".$a_secFlds['TITLE'];
  1570.                     if (!empty($a_secFlds['HIDDENFIELD'])) $str_ret.=$a_secFlds['HIDDENFIELD']// <pk-06-07-17 />
  1571.                     $str_ret.="</th></tr>\n";
  1572.                 else {
  1573.                     $str_ret.="<tr><td class=\"fldName\" colspan=\"2\"><hr width=\"75%\" align=\"center\">";
  1574.                     if (!empty($a_secFlds['HIDDENFIELD'])) $str_ret.=$a_secFlds['HIDDENFIELD']// <pk-06-07-17 />
  1575.                     $str_ret.="</td></tr>\n";
  1576.                 }
  1577.  
  1578.                 if (is_array($a_secFlds)) {
  1579.                     foreach($a_secFlds as $a_fld => $a_fldDesc{
  1580.                         if ((is_array($a_fldDesc)) && $a_fld != "TITLE" && $a_fld != "HIDDENFIELD" // <pk-06-07-17 />
  1581.                             $str_ret.="<tr>\n";
  1582.                             $str_ret.="\t<td class=\"fldName\" ".(isset($a_fldDesc['FLDTIT']"title=\"".$a_fldDesc['FLDTIT']."\"" "" ).">".(isset($a_fldDesc['FLDLAB']$a_fldDesc['FLDLAB'""."</td>\n";
  1583.                             $str_ret.="\t<td class=\"fldValue\">".$a_fldDesc['FLDVAL']."</td>\n";
  1584.                             $str_ret.="</tr>\n";
  1585.                         }
  1586.                     }
  1587.                 }
  1588.             }
  1589.         }
  1590.         return $str_ret;
  1591.     }    
  1592.     
  1593.     /**
  1594.       * echos the field definition form
  1595.       * from the field edit array @see editTbl_getFieldEditArr()
  1596.       *
  1597.       * @param array $fldEditArr 
  1598.       * @param boolen $debug 
  1599.       *
  1600.       * @since pk-06-04-26
  1601.       * @version pk-06-07-17
  1602.       * @version pk-07-05-03
  1603.       *
  1604.       ***/
  1605.     function editTbl_echoForm($fldEditArr=NULL,$debug=False{
  1606.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::editTbl_echoForm","",0);
  1607.         echo $this->editTbl_getForm($fldEditArr,$debug);
  1608.     }
  1609.  
  1610.  
  1611.  
  1612.     /**
  1613.       * show the filed definition form
  1614.       *
  1615.       * @param bool $showSize       show size input
  1616.       * @param bool $showNull       show input field to handle null values
  1617.       *
  1618.       * @version pk-04-10-13
  1619.       * @version pk-05-02-11 fldDbgGetValue added
  1620.       * @version pk-05-09-14 trimValue added
  1621.       * @deprecated since pk-06-04-26
  1622.       ***/
  1623.     function editTblForm($showSize=True,$showNull=True{
  1624.         $this->editTbl_echoForm($this->editTbl_getFieldEditArr(False));
  1625.     }
  1626.  
  1627.     /**
  1628.       * save the filed definition form
  1629.       *
  1630.       * @param bool $debug  since pk-04-07-23
  1631.       * @return bool return True
  1632.       *
  1633.       * @version pk-04-07-23 debug added
  1634.       * @version pk-04-10-13
  1635.       * @version pk-05-02-11 fldDbgGetValue added
  1636.       * @version pk-05-06-29 unsetGrpKey added
  1637.       * @version pk-05-08-09 regexcheck_pattern/regexErrMsg added
  1638.       * @version pk-05-09-14 trimValue added
  1639.       * @version pk-06-02-21 allowNull setting if $this->dbDesc['COLNAME'] is empty
  1640.       * @version pk-06-09-27 exportCSV added
  1641.       * @version pk-06-10-08 showGroup added
  1642.       *
  1643.       ***/
  1644.     function save($debug=False{
  1645.         return $this->editTabl_save($debug);
  1646.     }
  1647.  
  1648.     /**
  1649.       * compares the values of $aDesc (DB Field definition)
  1650.       * with the field definition stored in the object
  1651.       *
  1652.       * @param array $aDesc 
  1653.       *
  1654.       * @return bool 
  1655.       *
  1656.       ***/
  1657.     function check($aDesc{
  1658.         $ok=True;
  1659.         if (is_array($aDesc)) {
  1660.            while(list($key,$val)=each($aDesc)) {
  1661.               if (!isset($this->dbDesc[$key]|| ($this->dbDesc[$key]!=$val)) {
  1662.                  $ok=False;
  1663.                  $this->dbDesc[$key]=$val;
  1664.               }
  1665.            }
  1666.         }
  1667.         return $ok;
  1668.     }
  1669.  
  1670.  
  1671.     // ###########################################################
  1672.     // OBJECT DATA METHODS
  1673.     // ###########################################################
  1674.  
  1675.     /**
  1676.       * check if NULL values are allowed
  1677.       *
  1678.       * @return bool 
  1679.       *
  1680.       * @version pk-06-02-21 check for empty COLNAME
  1681.       * @version pk-06-11-27 allowNull is true whereas dbDesc['NULL'] is flase
  1682.       *
  1683.       ***/
  1684.     function allowNull({
  1685.         // <pk-06-08-03> E_ALL
  1686.         if (!isset($this->dbDesc['NULL']))      $this->dbDesc['NULL']=$this->allowNull;
  1687.         if (!isset($this->dbDesc['COLNAME']))   $this->dbDesc['COLNAME']="";
  1688.  
  1689.         if (!$this->dbDesc['NULL']// <pk-06-11-27>
  1690.             if (empty($this->dbDesc['COLNAME'])) return $this->allowNull;
  1691.             if (!empty($this->defaultValue))     return $this->allowNull;
  1692.             return False;
  1693.         }
  1694.         return $this->allowNull;
  1695.     }
  1696.  
  1697.     /**
  1698.       * returns the field database default value
  1699.       *
  1700.       * @return mixed 
  1701.       *
  1702.       * @version pk-03-10-14
  1703.       *
  1704.       ***/
  1705.     function getDbDefault({
  1706.         if (isset($this->dbDesc['AUTO_INCREMENT']&& ($this->dbDesc['AUTO_INCREMENT']))
  1707.            return NULL;
  1708.         if (isset($this->dbDesc['DEFAULT'])) {
  1709.             if (!empty($this->dbDesc['DEFAULT']))
  1710.                 return $this->dbDesc['DEFAULT'];
  1711.             if ($this->dbDesc['DEFAULT']===0)       // type compare INTEGER
  1712.                 return 0;
  1713.             if ($this->dbDesc['DEFAULT']===0.0)     // type compare FLOAT / DOUBLE
  1714.                 return 0;
  1715.             if ($this->dbDesc['DEFAULT']==="0")     // type compare STRING
  1716.                 return 0;
  1717.             if ($this->dbDesc['DEFAULT']==="0.0")   // type compare STRING
  1718.                 return 0;
  1719.         }
  1720.         return NULL;
  1721.     }
  1722.  
  1723.     /**
  1724.       * returns if the field represents an auto_increment column in the database
  1725.       *
  1726.       * @return boolean 
  1727.       *
  1728.       * @since pk-06-06-07
  1729.       * @version pk-06-08-03
  1730.       *
  1731.       ***/
  1732.     function isAutoInc({
  1733.         if (isset($this->dbDesc['AUTO_INCREMENT'])) {
  1734.             return $this->dbDesc['AUTO_INCREMENT'];
  1735.         else {
  1736.             return False;
  1737.         }
  1738.     }
  1739.  
  1740.  
  1741.     // ###########################################################
  1742.     // OBJECT HTML FORM METHODS
  1743.     // ###########################################################
  1744.  
  1745.     /**
  1746.       * @return boolean 
  1747.       * @since pk-06-09-27
  1748.       ***/
  1749.     function isLayoutFld({
  1750.         return False;
  1751.     }
  1752.  
  1753.     /**
  1754.       * returns the field default value
  1755.       *
  1756.       * if $defaultValue !empty it is returned
  1757.       * else getDbDefault is return
  1758.       *
  1759.       * @return mixed 
  1760.       *
  1761.       * @version pk-04-02-05
  1762.       * @version pk-05-03-17
  1763.       *
  1764.       ***/
  1765.     function getDefaultValue($debug=False){
  1766.         $debug=($debug || $this->fldDebug);
  1767.         if ($debugecho "<p><b>DBMS_FIELD::getDefaultValue($debug)</b> (".get_class($this)."/".$this->myName.")</p>";
  1768.         if (strlen($this->defaultValue."")) {
  1769.             require_once __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";
  1770.             /* <pk-05-03-17> Debugging changed */
  1771.             if ($debugecho "<blockquote><p>Template: ".htmlspecialchars($this->defaultValue)."</p>";
  1772.             $ret pcf_tmpl_parse($this->defaultValue,NULL,False);
  1773.             if ($debugecho "<p>Returned: ".htmlspecialchars($ret)."</p></blockquote>";
  1774.             /* </pk-05-03-17> */
  1775.             return $ret;
  1776.         else {
  1777.             if ($debugecho "<blockquote>Returning DB default (".$this->getDbDefault().")</blockquote>";
  1778.             return $this->getDbDefault();
  1779.         }
  1780.     }
  1781.  
  1782.     /**
  1783.       * returns the addTag parsed as template with global ${$arrName} as data
  1784.       *
  1785.       * @param string $arrName 
  1786.       *
  1787.       * @return string 
  1788.       *
  1789.       * @version pk-05-02-25
  1790.       *
  1791.       ***/
  1792.     function getAddTag($arrName="DBVAL"{
  1793.         if ($this->myCurrentMode==FRM_MODE_HIDDEN{
  1794.             return "";
  1795.         }
  1796.         if (($this->myCurrentMode==FRM_MODE_READONLY&& ($this->hideAddTag_ro)) {
  1797.             return "";
  1798.         else {
  1799.             global ${$arrName};
  1800.             require_once __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";
  1801.             return pcf_tmpl_parse($this->addTag,${$arrName});
  1802.         }
  1803.     }
  1804.  
  1805.     /**
  1806.      * returns the (show) size (chars) of a field
  1807.      * 
  1808.      * @return int 
  1809.      * 
  1810.      * @since pk-08-05-29
  1811.      */
  1812.     public function getSize()
  1813.     {
  1814.         if (intval($this->size))
  1815.         {
  1816.             return intval($this->size);    
  1817.         }
  1818.         if (intval($this->maxlength))
  1819.         {
  1820.             return intval($this->maxlength);
  1821.         }
  1822.         
  1823.         return DMBS_FIELD_DEFAULT_SIZE;
  1824.     }
  1825.     
  1826.     /**
  1827.       * returns the html code for a editable formular element
  1828.       *
  1829.       * @param mixed $aValue the value to set
  1830.       * @param string $arrName 
  1831.       * @param string $nameAdd  append something to name like "[VALUE]" for search forms
  1832.       * @param boolean $debug since pk-06-08-09
  1833.       *
  1834.       * @return string 
  1835.       *
  1836.       * @version pk-05-01-06
  1837.       * @version pk-06-05-18 inputAdd added
  1838.       * @version pk-06-08-09 debug added
  1839.       * @version pk-07-12-07 avoid maxlength 0
  1840.       *
  1841.       ***/
  1842.     function getInputTag($aValue,$arrName="DBVAL",$nameAdd="",$debug=False{
  1843.         if ($debugechoDebugMethod(__FILE__,get_class($this)."DBMS_FIELD::getInputTag()");
  1844.  
  1845.         $tag  "<input ";
  1846.         $tag .= "id=\"" $this->getDOMId("\" ";
  1847.         $tag .= "name=\"".$arrName."[".$this->myName."]".$nameAdd."\" ";
  1848.         $tag .= "value=\"".htmlspecialchars($aValue)."\" "/* <pk-05-01-06 /> */
  1849.         if (intval($this->size)) $tag.= "size=\"".$this->size."\" ";
  1850.         if (intval($this->maxlength)) $tag.= "maxlength=\"".$this->maxlength."\" ";
  1851.         if ($this->tabIndex$tag.="tabindex=\"".$this->tabIndex."\" ";
  1852.         if (!empty($this->inputAdd)) $tag.=" ".$this->inputAdd." ";
  1853.         $tag .= " />";
  1854.         return $tag;
  1855.     }
  1856.  
  1857.  
  1858.     /**
  1859.       * returns if a field is shown readonly
  1860.       *
  1861.       * @param int $mode 
  1862.       * @param boolean $debug 
  1863.       *
  1864.       * @return boolean 
  1865.       *
  1866.       * @since pk-04-09-15
  1867.       *
  1868.       ***/
  1869.     function isReadOnlyShown($mode,$debug=False{
  1870.         $debug=($debug || $this->fldDebug);
  1871.         if ($debugecho "<p><b>DBMS_FIELD::isReadOnlyShown($mode,...)</b> (".get_class($this).")";
  1872.  
  1873.         if ($this->isHiddenreturn False;
  1874.  
  1875.         switch($mode{
  1876.             case FRM_MODE_NEW:
  1877.                 return ($this->enableNew False True);
  1878.             case FRM_MODE_COPY:
  1879.                 return ($this->enableCopy False True);
  1880.             case FRM_MODE_EDIT:
  1881.                  return ($this->enableEdit False True);
  1882.             default:
  1883.                 return False;
  1884.         }
  1885.     }
  1886.  
  1887.     /**
  1888.       * returns the group id which is required to see the field
  1889.       *
  1890.       * @return int 
  1891.       *
  1892.       * @since pk-07-09-12
  1893.       */
  1894.     function getShowGroup()
  1895.     {
  1896.         return $this->showGroup;
  1897.     }
  1898.  
  1899.  
  1900.     /**
  1901.       * checks if the field is to show due to $this->showQuery
  1902.       *
  1903.       * @param int $mode 
  1904.       * @param array $dataArr 
  1905.       * @param boolean $debug 
  1906.       * @param boolean $inFieldGroup 
  1907.       *
  1908.       * @global array $OCSP_OBJ 
  1909.       *
  1910.       * @return boolean 
  1911.       *
  1912.       * @requires pcf_templates.phpinc
  1913.       *
  1914.       * @since pk-05-11-13
  1915.       * @version pk-05-11-15
  1916.       * @version pk-06-10-08
  1917.       * @version pk-07-01-09 use showQuery in FRM_MODE_SEARCH too
  1918.       * @version pk-07-09-12 global $OCSP_OBJ
  1919.       * @version pk-08-09-22 no global
  1920.       */
  1921.     function isToShow($mode,$dataArr,$debug=False,$inFieldGroup=False{
  1922.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::isToShow($mode,...)");
  1923.  
  1924.         if ($this->isHidden{
  1925.             if ($debug || $this->fldDebugechoDebugLine(__FILE__,__LINE__,"field is hidden");
  1926.             return False;
  1927.         }
  1928.  
  1929.         if (intval($this->showGroup)) {
  1930.             if (!OCSP_OBJ::currentUser(True)->isGroupMember($this->showGroup))
  1931.             {
  1932.                 if ($debug || $this->fldDebugechoDebugLine(__FILE__,__LINE__,"user is not member of ".$this->showGroup);
  1933.                 return False;
  1934.             }
  1935.         }
  1936.  
  1937.  
  1938.         if ($mode != FRM_MODE_LIST// <pk-07-01-09 />
  1939.             if (!empty($this->showQuery)) {
  1940.                 require_once __OCSP_PHPINCPATH__."common"._OCSP_DIRSEP_."pcf_templates.phpinc";
  1941.                 $s_query="SELECT ".pcf_tmpl_parse($this->showQuery,$dataArr);
  1942.                 if ($debugecho "<p>showQuery: <br />".$s_query."</p>\n";
  1943.  
  1944.                 if (!(OCSP_OBJ::defaultReadDBObj()->quickQuery($s_query,0))) {
  1945.                     if ($debug || $this->fldDebugechoDebugLine(__FILE__,__LINE__,"show query failed");
  1946.                     return False;
  1947.                 }
  1948.             }
  1949.             if ($this->getGrpKey(&& (!$inFieldGroup))
  1950.             {
  1951.                 if ($debug || $this->fldDebugechoDebugLine(__FILE__,__LINE__,"fieldgroup failed");
  1952.                 return False;
  1953.             }
  1954.         }
  1955.  
  1956.         switch($mode{
  1957.             case FRM_MODE_NEW:
  1958.                 if ($this->hideNew
  1959.                     return False;
  1960.                 else if ($this->isAutoInc())
  1961.                     return False
  1962.                 else 
  1963.                     return True;
  1964.             case FRM_MODE_EDIT:
  1965.                 if ($this->hideEditreturn Falseelse return True;
  1966.             case FRM_MODE_COPY:
  1967.                 if ($this->hideCopyreturn Falseelse return True;
  1968.             case FRM_MODE_LIST:
  1969.                 return $this->showInList;
  1970.             case FRM_MODE_SEARCH:
  1971.                 return $this->isSearchable;
  1972.             case FRM_MODE_HIDDEN:
  1973.                 return False;
  1974.             case FRM_MODE_READONLY:
  1975.                 if ($this->hideReadOnlyreturn Falseelse return True// <pk-05-11-15 />
  1976.             default:
  1977.                 return True;
  1978.         }
  1979.     }
  1980.  
  1981.     /**
  1982.      * returns if the field is in list (does not check rights)
  1983.      *
  1984.      * @return boolean 
  1985.      */
  1986.     function showInList()
  1987.     {
  1988.         return $this->showInList;
  1989.     }
  1990.     
  1991.     /**
  1992.       * returns if the field is enabled in $mode and to show
  1993.       *
  1994.       * @param int $mode 
  1995.       * @param boolean $debug 
  1996.       *
  1997.       * @return boolean 
  1998.       *
  1999.       * @since pk-06-09-12
  2000.       *
  2001.       ***/
  2002.     function isEnabled($mode,$debug=False{
  2003.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::isEnabled()");
  2004.         if ($this->isHidden()) return False// no need to check the field is not shown
  2005.         switch($mode{
  2006.             case FRM_MODE_NEW:
  2007.                 return $this->enableNew;
  2008.             case FRM_MODE_EDIT:
  2009.                 return $this->enableEdit;
  2010.             case FRM_MODE_COPY:
  2011.                 return $this->enableCopy;
  2012.             case FRM_MODE_SEARCH:
  2013.                 return $this->isSearchable();
  2014.             case FRM_MODE_READONLY:
  2015.             case FRM_MODE_LIST:
  2016.             default:
  2017.                 return False;
  2018.         }
  2019.     }
  2020.  
  2021.  
  2022.     /**
  2023.       * returns the html code for the field value input / show
  2024.       * adds $this->myName to ${$this->myDataArrName}['_DBMS_FIELDS']
  2025.       *
  2026.       * @param int $mode 
  2027.       * @param mixed $aValue 
  2028.       * @param boolean $debug 
  2029.       *
  2030.       * @return string 
  2031.       *
  2032.       * @since pk-04-09-08
  2033.       * @version pk-04-10-13
  2034.       * @version pk-04-12-21
  2035.       * @version pk-05-01-03
  2036.       * @version pk-06-02-26 getListValue()
  2037.       *
  2038.       ***/
  2039.     function getFieldTag($mode,$aValue=NULL,$debug=False{
  2040.         if (empty($this->myDataArrName)) $this->setDataArrName("DBVAL");
  2041.         global ${$this->myDataArrName};
  2042.         $debug=($debug || $this->fldDebug);
  2043.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::getFieldTag($mode,".htmlspecialchars(substr($aValue,0,20)).",...)",$this->myName);
  2044.  
  2045.         if (!isset(${$this->myDataArrName}['_DBMS_FIELDS'])) ${$this->myDataArrName}['_DBMS_FIELDS']=""//<pk-06-09-13 /> E_ALL
  2046.  
  2047.         $this->myCurrentMode=$mode/* </pk-05-02-25> */
  2048.         $ret="";
  2049.         switch($mode{
  2050.             case FRM_MODE_HIDDEN:
  2051.                 $ret .= "<input type=\"hidden\" ";
  2052.                 $ret .= "   name=\"".$this->myDataArrName."[".$this->myName."]\"";
  2053.                 $ret .= "   value=\"".htmlspecialchars($aValue)."\"";
  2054.                 $ret .= ">";
  2055.                 ${$this->myDataArrName}['_DBMS_FIELDS'].=$this->myName.",";
  2056.                 return $ret;
  2057.             case FRM_MODE_NEW:
  2058.                  if (empty($aValue&& ($aValue != "0")) $aValue=$this->getDefaultValue();  /* <pk-05-01-03 /> */
  2059.                  if ($this->enableNew{
  2060.                      $ret .= $this->getInputTag($aValue,$this->myDataArrName);
  2061.                      $ret .= $this->getAddTag($this->myDataArrName);
  2062.                      ${$this->myDataArrName}['_DBMS_FIELDS'].=$this->myName.",";;
  2063.                      return $ret;
  2064.                  else {
  2065.                     $ret.=$this->getFieldTag(FRM_MODE_READONLY,$aValue,$debug)/* <pk-04-12-21 /> */
  2066.                     $ret.=$this->getFieldTag(FRM_MODE_HIDDEN,$aValue,$debug);   /* <pk-04-12-21 /> */
  2067.                     return $ret;
  2068.                  }
  2069.             case FRM_MODE_COPY:
  2070.                  if (empty($aValue&& ($aValue != "0")) $aValue=$this->getDefaultValue();  /* <pk-05-01-03 /> */
  2071.                  if ($this->enableCopy{
  2072.                      $ret .= $this->getInputTag($aValue,$this->myDataArrName);
  2073.                      $ret .= $this->getAddTag($this->myDataArrName);
  2074.                      ${$this->myDataArrName}['_DBMS_FIELDS'].=$this->myName.",";;
  2075.                      return $ret;
  2076.                  else {
  2077.                     $ret.=$this->getFieldTag(FRM_MODE_READONLY,$aValue,$debug)/* <pk-04-12-21 /> */
  2078.                     $ret.=$this->getFieldTag(FRM_MODE_HIDDEN,$aValue,$debug);   /* <pk-04-12-21 /> */
  2079.                     return $ret;
  2080.                  }
  2081.             case FRM_MODE_EDIT:
  2082.                  if (($this->enableEdit|| (empty($aValue&& $this->enableEditIfEmpty)) // <pk-06-08-08 />
  2083.                      $ret .= $this->getInputTag($aValue,$this->myDataArrName);
  2084.                      $ret .= $this->getAddTag($this->myDataArrName);
  2085.                      ${$this->myDataArrName}['_DBMS_FIELDS'].=$this->myName.",";;
  2086.                      return $ret;
  2087.                  else {
  2088.                     $ret.=$this->getFieldTag(FRM_MODE_READONLY,$aValue,$debug)/* <pk-04-12-21 /> */
  2089.                     $ret.=$this->getFieldTag(FRM_MODE_HIDDEN,$aValue,$debug);   /* <pk-04-12-21 /> */
  2090.                     return $ret;
  2091.                  }
  2092.             case FRM_MODE_LIST:
  2093.                 return $this->getListValue($aValue,$this->myDataArrName,$debug)// <pk-06-04-26 />
  2094.             case FRM_MODE_SEARCH:
  2095.                 $ret.="<select name=\"".$this->myDataArrName."[".$this->myName."][ANDOR]\">";
  2096.                 // $ret.="  <option value=\"\">---</option>";
  2097.                 $ret.="  <option value=\"AND\">UND</option>";
  2098.                 $ret.="  <option value=\"OR\">ODER</option>";
  2099.                 $ret.="</select>\n";
  2100.                 $ret.=$this->getSearchCompTypes($this->myDataArrName);
  2101.                 $ret.= $this->getSearchInputTag($aValue,$this->myDataArrName);
  2102.                 ${$this->myDataArrName}['_DBMS_FIELDS'].=$this->myName.",";;
  2103.                 return $ret;
  2104.             case FRM_MODE_READONLY:
  2105.                 if ($this->hideReadOnlyreturn $ret;
  2106.                 // else use default -> no break
  2107.             default:
  2108.                 $ret .= $this->getScreenValue($aValue,$this->myDataArrName,$debug);
  2109.                 $ret .= $this->getAddTag($this->myDataArrName);
  2110.                 return $ret;
  2111.         }
  2112.     }
  2113.  
  2114.     /**
  2115.       * @return string 
  2116.       *
  2117.       * @since pk-05-10-03
  2118.       *
  2119.       ***/
  2120.     function getLabel({
  2121.         return $this->label;
  2122.     }
  2123.  
  2124.     /**
  2125.       * @return string 
  2126.       * @since pk-07-07-09
  2127.       */
  2128.     function getToolTip()
  2129.     {
  2130.         return $this->toolTip;
  2131.     }
  2132.  
  2133.     /**
  2134.       * @return string 
  2135.       *
  2136.       * @since pk-06-01-19
  2137.       *
  2138.       ***/
  2139.     function getLstLabel({
  2140.         if (!empty($this->lstLabel)) return $this->lstLabel;
  2141.         else return $this->getLabel();
  2142.     }
  2143.  
  2144.     /**
  2145.      * list colspan (<td colspan="x">)
  2146.      *
  2147.      * @return int 
  2148.      */
  2149.     function getLstColSpan()
  2150.     {
  2151.         return intval($this->lstColSpan);
  2152.     }
  2153.     
  2154.     /**
  2155.      * @return int 
  2156.      * @since pk-08-06-03
  2157.      */
  2158.        public function getLstWidth()
  2159.        {
  2160.            return intval($this->lstWidth);
  2161.        }
  2162.  
  2163.     
  2164.     /**
  2165.       * get the html tag for the label column
  2166.       *
  2167.       * @param bool     $useTh      if True <th>..</th> is returned else <td>..</td>
  2168.       * @param string   $style      a css class name for the column
  2169.       * @param bool     $debug 
  2170.       *
  2171.       * @global array $OCSP_CONF 
  2172.       *
  2173.       * @return string 
  2174.       *
  2175.       * @version pk-05-09-05 titel attribut added
  2176.       *
  2177.       ***/
  2178.     function getLabelColTag($useTh=False,$style="",$debug=False{
  2179.         global $OCSP_CONF;
  2180.  
  2181.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::getLabelColTag() [".$this->myName."]","\$style=$style\n\$this->labeltd_add=".$this->labeltd_add);
  2182.         if ($useTh)     $ret "<th ".$style." ".$this->labeltd_add.">";
  2183.         else            $ret "<td ".$style." ".$this->labeltd_add.">";
  2184.  
  2185.         $this->toolTip=str_replace("\r","",$this->toolTip);
  2186.  
  2187.         // <pk-04-08-17 />
  2188.         $ret .= "<label for=\"".$this->myDataArrName."[".$this->myName."]\" ";
  2189.         if (!empty($this->toolTip&& ($this->toolTipAsTitle)) {
  2190.             $ret.=" title=\"".str_replace('"','\'',$this->toolTip)."\"";
  2191.         }
  2192.         $ret.=">";
  2193.  
  2194.         if ($this->myCurrentMode != FRM_MODE_READONLY)
  2195.         {
  2196.             if ((!empty($this->toolTip)) && (!$this->toolTipAsTitle)) {
  2197.                 $ret .= "<a href=\"javascript:{alert('".str_replace("\n"," ",addslashes($this->toolTip))."');}\" class=\"fldName\">";
  2198.             }
  2199.         }
  2200.         $ret .= $this->label;
  2201.         if (!empty($this->toolTip&& ($this->myCurrentMode != FRM_MODE_READONLY)) $ret .= "</a>";
  2202.         if ($debug$ret .= "(".$this->sortOrder.")";
  2203.  
  2204.         if (!empty($this->myHelpUrl)) {
  2205.             $ret.="
  2206.                 <a href=\"#\" onClick=\"
  2207.                     var myCmd = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes'
  2208.                     myCmd = myCmd + ',width=640,height=480';
  2209.                     var myWnd = window.open('".$this->myHelpUrl."','".$this->myName."_hlp',myCmd);
  2210.                     myWnd.focus();
  2211.                 \"><img src=\"".$OCSP_CONF['SYSIMGURL']."form_buttons/icon_help.gif\" border=\"0\" alt=\"Eingabehilfe\"></a>";
  2212.         }
  2213.  
  2214.         // <pk-04-08-17 />
  2215.         $ret .= "</label>";
  2216.  
  2217.         if ($useTh)     $ret .= "</th>\n";
  2218.         else            $ret .= "</td>\n";
  2219.  
  2220.         return $ret;
  2221.     }
  2222.  
  2223.  
  2224.     /**
  2225.       * returns the html code for a field form row
  2226.       *
  2227.       * @param int $mode 
  2228.       * @param mixed $aValue 
  2229.       * @param boolean $debug 
  2230.       *
  2231.       * @return string 
  2232.       *
  2233.       * @since pk-04-09-08
  2234.       * @version pk-04-10-13
  2235.       * @version pk-07-03-05 id added to table row
  2236.       ***/
  2237.     function getFieldRow($mode,$aValue=NULL,$debug=False{
  2238.         $debug ($debug || $this->fldDebug);
  2239.         if ($debugechoDebugMethod(__FILE__." L: ".__LINE__,get_class($this),__CLASS__."::getFieldRow()","MODE$mode<br />\$aValue".htmlspecialchars($aValue));
  2240.  
  2241.         if ($mode == FRM_MODE_READONLY && $this->hideReadOnlyreturn ""// do nothing
  2242.         $this->myCurrentMode=$mode/* </pk-05-02-25> */
  2243.  
  2244.         $ret="";
  2245.         if (!$this->isHidden{
  2246.            switch($mode{
  2247.                 case FRM_MODE_NEW:
  2248.                     if (($hidden=$this->hideNew&& ($this->enableNew))
  2249.                         $ret.="\t".$this->getFieldTag(FRM_MODE_HIDDEN,$aValue,$debug)."\n";
  2250.                     break;
  2251.                 case FRM_MODE_COPY:
  2252.                     if (($hidden=$this->hideCopy&& ($this->enableCopy))
  2253.                         $ret.="\t".$this->getFieldTag(FRM_MODE_HIDDEN,$aValue,$debug)."\n";
  2254.                     break;
  2255.                 case FRM_MODE_EDIT:
  2256.                     if (($hidden=$this->hideEdit&& ($this->enableEdit))
  2257.                         $ret.="\t".$this->getFieldTag(FRM_MODE_HIDDEN,$aValue,$debug)."\n";
  2258.                     break;
  2259.                 default:
  2260.                     $hidden=False;
  2261.            }
  2262.         }
  2263.  
  2264.         if (!$hidden{
  2265.             $ret.="\t<tr id=\"tr_".$this->getJsName()."\">\n";
  2266.             $ret.=$this->getFieldRowCols($mode,$aValue,$debug);
  2267.             $ret.="\t</tr>\n";
  2268.         }
  2269.         return $ret;
  2270.     }
  2271.  
  2272.     /**
  2273.       * returns the row columns for a field row
  2274.       *
  2275.       * @param int $mode 
  2276.       * @param mixed $aValue 
  2277.       * @param boolean $debug 
  2278.       *
  2279.       * @return string 
  2280.       *
  2281.       * @since pk-05-02-08
  2282.       * @version pk-05-02-25 bugif colspan
  2283.       * @version pk-07-02-15 set class even if we have set $this->labeltd_add
  2284.       * @version pk-07-02-28 add id to value column
  2285.       *
  2286.       ***/
  2287.     function getFieldRowCols($mode,$aValue=NULL,$debug=False{
  2288.         $debug ($debug || $this->fldDebug);
  2289.         if ($debugecho "<p><b>DBMS_FIELD::getFieldRowCols($mode,".htmlspecialchars(substr($aValue,0,30))."...)</b> ".$this->myName." (".get_class($this).")</p>";
  2290.  
  2291.         $tdAdd="";$ret="";
  2292.         if (!$this->labelcol_hide{
  2293.             $class=" class=\"fldName\" ";
  2294.             //<pk-07-02-15 />
  2295.             //if (empty($this->labeltd_add)) {
  2296.             //    $class=" class=\"fldName\" ";
  2297.             //} else {
  2298.             //    $class="";
  2299.             //}
  2300.             //</pk-07-02-15>
  2301.             $ret.="\t\t".$this->getLabelColTag(False,$class,$debug);
  2302.         else {
  2303.             $tdAdd="colspan=\"2\" ";
  2304.         }
  2305.  
  2306.         if (!empty($this->fieldtd_add)) {
  2307.             $tdAdd.=" ".$this->fieldtd_add;
  2308.         else {
  2309.             switch($mode{
  2310.                 case FRM_MODE_READONLY:
  2311.                     $tdAdd.=" class=\"fldValueRO\" ";
  2312.                     break;
  2313.                 case FRM_MODE_NEW:
  2314.                     if ($this->hideNew$tdAdd.=" class=\"fldValueRO\" ";
  2315.                     else $tdAdd.=" class=\"fldValue\" ";
  2316.                     break;
  2317.                 case FRM_MODE_COPY:
  2318.                     if ($this->hideCopy$tdAdd.=" class=\"fldValueRO\" ";
  2319.                     else $tdAdd.=" class=\"fldValue\" ";
  2320.                     break;
  2321.                 case FRM_MODE_EDIT:
  2322.                     if ($this->hideEdit$tdAdd.=" class=\"fldValueRO\" ";
  2323.                     else $tdAdd.=" class=\"fldValue\" ";
  2324.                     break;
  2325.                 default:
  2326.                      $tdAdd.=" class=\"fldValue\" ";
  2327.            }
  2328.         }
  2329.  
  2330.         $ret.="\t\t<td ".$tdAdd." id=\"".$this->getValId()."\">";
  2331.         $ret.=$this->getFieldTag($mode,$aValue,$debug);
  2332.         $ret.="</td>\n";
  2333.         return $ret;
  2334.     }
  2335.  
  2336.     /**
  2337.       * returns the html representation of the field
  2338.       *
  2339.       * @param mixed    $aValue     the falue
  2340.       * @param string $arrName  name of the global array holding data values
  2341.       * @param bool     $debug      show debug info
  2342.       *
  2343.       * @return mixed   the html representation of the field
  2344.       ***/
  2345.     function getScreenValue($aValue=NULL,$arrName="DBVAL",$debug=False{
  2346.         return $aValue;
  2347.     }
  2348.  
  2349.     /**
  2350.       * @return string 
  2351.       * @since pk-07-10-16
  2352.       */
  2353.     function get_lstTDAdd()
  2354.     {
  2355.         return $this->lstTDAdd;
  2356.     }
  2357.  
  2358.     /**
  2359.       * returns the html representation of the field in a list (table col)
  2360.       *
  2361.       * @param mixed    $aValue     the falue
  2362.       * @param string $arrName  name of the global array holding data values
  2363.       * @param bool     $debug      show debug info
  2364.       *
  2365.       * @return mixed   the html representation of the field
  2366.       *
  2367.       * @since pk-06-04-26
  2368.       *
  2369.       ***/
  2370.     function getListValue($aValue=NULL,$arrName="DBVAL",$debug=False{
  2371.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::getListValue()");
  2372.         return $this->getScreenValue($aValue,$arrName,$debug);
  2373.     }
  2374.  
  2375.  
  2376.     /**
  2377.       * returns if the list cell can be linked with the ['EDIT'] link
  2378.       *
  2379.       * @return boolean 
  2380.       *
  2381.       * @since pk-06-01-30
  2382.       *
  2383.       ***/
  2384.     function lstLinksDisabled({
  2385.         if (isset($this->lstDisableLinks)) return $this->lstDisableLinks;
  2386.         else return False;
  2387.     }
  2388.  
  2389.     /**
  2390.       * @return array 
  2391.       * @since pk-07-07-04
  2392.       */
  2393.     function getListLinkArr()
  2394.     {
  2395.         if (!$this->lstLinksDisabled()) {
  2396.             return $this->lstLink;
  2397.         }
  2398.         return NULL;
  2399.     }
  2400.  
  2401.     /**
  2402.       * get the link url for a list entry
  2403.       *
  2404.       * @param mixed $aValue    value of the db field
  2405.       * @param string $arrName  name of the global array holding data values
  2406.       * @param boolean $debug 
  2407.       *
  2408.       * @global array ${$this->myDataArrName} 
  2409.       * 
  2410.       * @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
  2411.       *
  2412.       * @version pk-06-10-19
  2413.       * @version pk-06-10-25 "bugfix" parse link as template
  2414.       * @version pk-07-10-27 $this->myDataArrName instead of $GLOBAL
  2415.       */
  2416.     function getListLink($aValue,$arrName="",$debug=False{
  2417.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::getListLink");               
  2418.         
  2419.         if (!empty($arrName))
  2420.         {
  2421.             $this->myDataArrName=$arrName
  2422.         }
  2423.         global ${$this->myDataArrName};
  2424.         
  2425.         if (!$this->lstLinksDisabled()) {
  2426.             if ((isset($this->lstLink['A'])) && (!empty($this->lstLink['A']))) {
  2427.                 // <pk-06-10-25>
  2428.                 require_once __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";
  2429.                 return "<a ".pcf_tmpl_parse($this->lstLink['A'],${$this->myDataArrName}).">";
  2430.                 // </pk-06-10-25>
  2431.             else {
  2432.                 return "[EDIT]";
  2433.             }
  2434.         }
  2435.         return "";
  2436.     }
  2437.  
  2438.  
  2439. // ################################################
  2440. // SEARCH FORM METHODS
  2441. // ################################################
  2442.  
  2443.  
  2444.     /**
  2445.       * returns the html code for a searchformular element
  2446.       *
  2447.       * @param mixed $aValue the value to set
  2448.       * @param string $arrName 
  2449.       *
  2450.       * @return string 
  2451.       *
  2452.       ***/
  2453.     function getSearchInputTag($aValue,$arrName="DBVAL"{
  2454.         return $this->getInputTag($aValue,$arrName,"[VALUE]");
  2455.     }
  2456.  
  2457.  
  2458.     /**
  2459.       * returns the html code for the search compare type select
  2460.       *
  2461.       * @param string $arrName 
  2462.       *
  2463.       * @return string 
  2464.       *
  2465.       * @since pk-04-09-09
  2466.       *
  2467.       ***/
  2468.     function getSearchCompTypes($arrName{
  2469.         if (isset($_POST[$arrName][$this->myName]['COMPTYPE'])) // <pk-06-07-27 > E_ALL
  2470.             $s_val=$_POST[$arrName][$this->myName]['COMPTYPE'];
  2471.         else {
  2472.             $s_val="";
  2473.         }
  2474.         $ret=  "<select name=\"".$arrName."[".$this->myName."][COMPTYPE]\">";
  2475.         $ret.= "  <option value=\"=\" ".($s_val=="=" "selected" "").">=</option>";
  2476.         $ret.= "  <option value=\"LIKE\" ".($s_val=="LIKE" "selected" "").">wie</option>";
  2477.         $ret.= "  <option value=\"SOUNDEX\" ".($s_val=="SOUNDEX" "selected" "").">SOUNDEX</option>";
  2478.         $ret.= "</select>";
  2479.         return $ret;
  2480.     }
  2481.  
  2482.  
  2483.     /**
  2484.       * returns a html select with all values (distinct) where $aValue
  2485.       * is selected
  2486.       *
  2487.       * NOTE only works on database fields
  2488.       *
  2489.       * @param mixed $aValue 
  2490.       * @param string $arrName 
  2491.       * @param string $selTagAdd added into <select ...>
  2492.       * @param string $whereCond added to query ($s_query="SELECT ... FROM TABLE ".$whereCond." ORDER BY")
  2493.       *
  2494.       * @return string 
  2495.       *
  2496.       * @since pk-05-10-18
  2497.       * @version pk-07-01-15
  2498.       *
  2499.       * @todo object value tables
  2500.       *
  2501.       ***/
  2502.     function getTableValSelect(&$aValue,$arrName="",$selTagAdd="",$whereCond="",$nullLabel="",$debug=False{
  2503.         $debug=($debug || $this->fldDebug);
  2504.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::getTableValSelect(aValue=".$aValue.",arrName=".$arrName.")","WHERE$whereCond");
  2505.  
  2506.         if ($this->myTable != "DBMS_NO_DBFIELD"{
  2507.             if (!empty($arrName)) {
  2508.                 $s_selName=$arrName."[".$this->myName."]";
  2509.             else {
  2510.                 $s_selName=$this->myName;
  2511.             }
  2512.             $ret="\n<select name=\"".$s_selName."\" ".$selTagAdd.">\n";
  2513.             if (!empty($nullLabel)) {
  2514.                 $ret.="\t<option value=\"\">".$nullLabel."</option>\n";
  2515.             else if ($this->searchGroup_allowAll{
  2516.                 $ret.="\t<option value=\"\">--- ??? ---</option>\n";
  2517.             }
  2518.             $s_query ="SELECT DISTINCT IFNULL(".$this->myName.",'[NULL]') FROM ".$this->myTable// <pk-07-01-15 />
  2519.             if (!empty($whereCond)) {
  2520.                 $s_query.=$whereCond;
  2521.             }
  2522.             $s_query.=" ORDER BY ".$this->myName;
  2523.             if ($debugecho "<p>".$s_query."<br>DB: ".$this->get_gDBIDX()."</p><blockquote>";
  2524.             $a_Values=$GLOBALS[$this->get_gDBIDX()]->queryArray($s_query,0,0,True,$debug);
  2525.             if ($debugechoDebug(__FILE__,"</blockquote><p>Values:</p><pre>".print_r($a_Values,True)."</pre>");
  2526.             if (is_array($a_Values)) {
  2527.                 foreach($a_Values as $s_Value{
  2528.                     $ret.="\t<option value=\"".htmlspecialchars($s_Value)."\"";
  2529.                     if ((empty($nullLabel)) && (!$this->searchGroup_allowAll&& (empty($aValue))) {
  2530.                         // no null Label -> we have to set the $aValue called by ref
  2531.                         $aValue=$s_Value;
  2532.                     }
  2533.                     if (strval($aValue)==$s_Value{
  2534.                         $ret.=" selected";
  2535.                     }
  2536.                     $ret.=">".$s_Value."</option>\n";
  2537.                 }
  2538.             }
  2539.             $ret.="</select>\n";
  2540.             return $ret;
  2541.         else {
  2542.             return "\n<!-- no database field -->\n\n";
  2543.         }
  2544.     }
  2545.  
  2546.     // ###########################################################
  2547.     // OBJECT VALUE CHECK/RETURN METHODS
  2548.     // ###########################################################
  2549.  
  2550.  
  2551.     /**
  2552.       * returns the field value
  2553.       *
  2554.       * @param  string  $aValue     the value
  2555.       * @param  array   $err        error array
  2556.       * @param  string  $arrName    global data array name used for global ${$arrName}
  2557.       * @param  bool    $debug 
  2558.       *
  2559.       * @return string 
  2560.       *
  2561.       * @since   pk-03-12-13
  2562.       * @version pk-04-07-15
  2563.       * @version pk-05-02-11  fldDbgGetValue added
  2564.       * @version pk-05-10-19  debug if trimValue
  2565.       * @version pk-06-11-27  if allowNull is true $aValue is NULL and ! $this->dbDesc['NULL'] the default value is returned
  2566.       * @version pk-07-07-11 $this->errMsg added
  2567.       *
  2568.       ***/
  2569.     function getValue($aValue,&$err,$arrName="DBVAL",$debug=False{
  2570.         $debug ($debug || $this->fldDebug || $this->fldDbgGetValue);
  2571.         if ($debugecho "<hr><p><b>DBMS_FIELD::getValue($aValue,$err,$arrName,$debug)</b> (".get_class($this)." | ".$this->myName.")</p>";
  2572.  
  2573.         if ($this->trimValue{
  2574.             if ($debugecho "<blockquote><p>TRIMVALUE</p></blockquote>"// <pk-05-10-19 />
  2575.             $aValue=trim($aValue);
  2576.         }
  2577.  
  2578.         if (empty($aValue&& ($aValue != "0"&& ($aValue !== 0)) {
  2579.             if ($this->allowNull()) {
  2580.                 if (!$this->dbDesc['NULL']// <pk-06-11-27>
  2581.                     if ($debugecho "<p>Defaultvalue instead of NULL returned \$aValue=\"".htmlspecialchars($this->defaultValue)."\"</p>";
  2582.                     return $this->getDefaultValue($debug);
  2583.                 else {
  2584.                     if ($debugecho "<p>NULL returned \$aValue=\"".htmlspecialchars($aValue)."\"</p>";
  2585.                     return NULL;
  2586.                 }
  2587.             else {
  2588.                 $this->errMsg .= (empty($this->nullErrMsg$this->label.": NULL_NOT_ALLOWED" $this->nullErrMsg);
  2589.                 $err['ERROR']=True;
  2590.                 $err[$this->myName]['MSG']  =$this->errMsg;
  2591.                 $err[$this->myName]['LABEL']=$this->label;
  2592.                 if ($debug{echo "<pre style=\"font-color:red;font-weight:bolder\">";print_r($err);echo "</pre>";}
  2593.                 return False;
  2594.             }
  2595.         else {
  2596.             if (!empty($this->regexcheck_pattern)) {
  2597.                 if ($debugecho "<p>Checking Regex: ".htmlspecialchars($this->regexcheck_pattern)."</p>";
  2598.                 if (preg_match($this->regexcheck_pattern,$aValue)) {
  2599.                     return $aValue;
  2600.                 else {
  2601.                     $this->errMsg.=$err['ERROR']=True;
  2602.                     (empty($this->regexErrMsg$this->label.": ungltige Eingabe" $this->regexErrMsg);
  2603.                     $err[$this->myName]['MSG'].= $this->errMsg;
  2604.                     $err[$this->myName]['LABEL']=$this->label;
  2605.                 }
  2606.             }
  2607.             return $aValue;
  2608.         }
  2609.     }
  2610.  
  2611.  
  2612.     /**
  2613.       * returns the value with slashes create use in a db statement
  2614.       *
  2615.       * @param  string  $aValue     the value
  2616.       * @param  array   $err        error array
  2617.       * @param  string  $arrName    DBVAL
  2618.       *
  2619.       * @return string 
  2620.       *
  2621.       * @version pk-03-11-27    DB-Object used instead of DB_.. function
  2622.       * @version pk-03-12-13    use $this->getValue to check the Value
  2623.       * @version pk-04-06-02    handling 0
  2624.       *
  2625.       ***/
  2626.     function slashedValue($aValue,&$err,$arrName="DBVAL",$debug=False{
  2627.         if ($debug{
  2628.             echo "<hr><p><b>DBMS_FIELD::slashedValue($aValue,$err,$arrName,$debug)</b> (".get_class($this)." | ".$this->myName.")</p>";
  2629.             echo "<pre>\n".$this->myName."--".addSlashes($aValue)."--\n".$GLOBALS[$this->getGlobalDBObjIdx()]->qs_getSlashedValue($aValue)."</pre>\n";
  2630.         }
  2631.  
  2632.         $val=$this->getValue($aValue,$err,$arrName,$debug);
  2633.         if ($val === NULL{
  2634.             if ($debugecho "<p>slashedValueNULL returned for $aValue</p>";
  2635.             return $GLOBALS[$this->getGlobalDBObjIdx()]->qs_getNullStmt();
  2636.         else if ($val{
  2637.             if ($debugecho "<p>slashedValue: returned "$GLOBALS[$this->getGlobalDBObjIdx()]->qs_getSlashedValue($val)." for $aValue</p>";
  2638.             return $GLOBALS[$this->getGlobalDBObjIdx()]->qs_getSlashedValue($val);
  2639.         else if ($val === || $val === "0"/* <pk-04-06-02> */
  2640.             return $GLOBALS[$this->getGlobalDBObjIdx()]->qs_getSlashedValue("0");
  2641.         else {
  2642.             return False;
  2643.         }
  2644.     }
  2645.  
  2646.  
  2647.     /**
  2648.       * returns a where part for sql queries out of search form input
  2649.       *
  2650.       * @param  array $aArr the posted array of the filed form the search form
  2651.       * @param  bool  $debug 
  2652.       *
  2653.       * @return string 
  2654.       *
  2655.       * @version pk-07-02-14 ($this->myDataArrName)
  2656.       *
  2657.       ***/
  2658.     function searchWhere($aArr,$debug=False{
  2659.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DMBS_FIELD::searchWhere()");
  2660.         if (!is_array($aArr)) return "";
  2661.  
  2662.         // <pk-07-02-14>
  2663.         global ${$this->myDataArrName};
  2664.         ${$this->myDataArrName}=$aArr;
  2665.         // </pk-07-02-14>
  2666.  
  2667.         if ($debug{echo "<blockquote><pre>";print_r($aArr);echo "</pre></blockquote>";}
  2668.         if ((!empty($aArr['ANDOR'])) && (!empty($aArr['VALUE']))) {
  2669.             $ret=($aArr['ANDOR'== "OR" " OR " " AND ");
  2670.  
  2671.             switch($aArr['COMPTYPE']{
  2672.                 case "LIKE":
  2673.                     $ret.=$this->myTable.".".$this->myName;
  2674.                     $ret.=" LIKE ".DB_getSlashedValue("%".$aArr['VALUE']."%");
  2675.                     break;
  2676.                 case "SOUNDEX":
  2677.                     $ret.="SOUNDEX(LEFT(".$this->myTable.".".$this->myName.",10)) = ";
  2678.                     $ret.="SOUNDEX(LEFT(".DB_getSlashedValue($aArr['VALUE']).",10)) ";
  2679.                     break;
  2680.                 default:
  2681.                     $ret.=$this->myTable.".".$this->myName;
  2682.                     $ret.=" = ".$this->slashedValue($aArr['VALUE'],$err,$this->myDataArrName,$debug)// <pk-07-02-14 />
  2683.             }
  2684.             return $ret;
  2685.         else return "";
  2686.     }
  2687.  
  2688.     function getAssignment($aValue,&$err,$arrName="DBVAL",$debug=False{
  2689.         if ($debugecho "<hr /><p><b>DBMS_FIELD::getAssignment($aValue,$err,$arrName,$debug)</b>(".get_class($this)."/".$this->myName.")</p>";
  2690.         return $this->myName."=".$this->slashedValue($aValue,$err,$arrName,$debug);
  2691.     }
  2692.  
  2693.  
  2694.     /**
  2695.       * gets a htmltag for the value
  2696.       *
  2697.       * this is mainly used in CMS Module
  2698.       *
  2699.       * @param mixed $aValue 
  2700.       * @param string $arrName 
  2701.       * @param bool $debug 
  2702.       *
  2703.       * @return mixed 
  2704.       *
  2705.       * @since pk-04-07-29
  2706.       *
  2707.       ***/
  2708.     function getHtmlTag($aValue,$arrName="DBVAL",$debug=False{
  2709.         if ($debugecho "<p><b>DMBS_FIELD::getHtmlTag($aValue,$arrName ...)</b> (".get_class($this).")</p>";
  2710.         // return $this->getScreenValue($aValue,$arrName,$debug);
  2711.         return $aValue;
  2712.     }
  2713.  
  2714.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2715.     // error methods
  2716.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2717.  
  2718.     /**
  2719.       * returns if the field has an error ($this->errMsg not empty)
  2720.       * @return boolean 
  2721.       * @since pk-07-07-11
  2722.       */
  2723.     function hasErrors()
  2724.     {
  2725.         return (!empty($this->errMsg));
  2726.     }
  2727.  
  2728.     /**
  2729.       * returns the errMsg
  2730.       * @return string 
  2731.       * @since pk-07-07-11
  2732.       */
  2733.     function getErrorMsg()
  2734.     {
  2735.         return $this->errMsg;
  2736.     }
  2737.  
  2738.     /**
  2739.       * sets an error msg
  2740.       *
  2741.       * @param string $aErrorMsg 
  2742.       * @param boolean $append (if True append the message else overwrite the old message)
  2743.       * @param boolean $debug 
  2744.       *
  2745.       * @since pk-07-07-29
  2746.       */
  2747.     function setErrorMsg($aErrorMsg,$append=True,$debug=False)
  2748.     {
  2749.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::setErrorMsg($aErrorMsg[".$this->getKey()."]");
  2750.         if (($append&& (!strstr($this->errMsg,$aErrorMsg)))
  2751.         {
  2752.             $this->errMsg.="\n".$aErrorMsg;
  2753.         else {
  2754.             $this->errMsg=$aErrorMsg;
  2755.         }
  2756.     }
  2757.  
  2758.  
  2759.     function clearError()
  2760.     {
  2761.         $this->errMsg="";
  2762.     }
  2763.  
  2764.  
  2765.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2766.     // ajax js methods
  2767.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2768.  
  2769.     /**
  2770.       * retuns a string which can be used in js var and functions to name the field
  2771.       *
  2772.       * @return string 
  2773.       *
  2774.       * @since pk-07-03-02
  2775.       *
  2776.       ***/
  2777.     function getJsName({
  2778.         return $this->myName."_".md5($this->myForm->getHTMLName().$this->getKey());
  2779.     }
  2780.  
  2781.     /**
  2782.       *
  2783.       * @return string 
  2784.       *
  2785.       */
  2786.  
  2787.     /**
  2788.       * returns a serialized array to identify the field in the called ajax script
  2789.       *
  2790.       * @return string 
  2791.       *
  2792.       * @requires pcf_md5.phpinc
  2793.       *
  2794.       * @since pk-07-09-05
  2795.       *
  2796.       */
  2797.     function getAjaxFldKey()
  2798.     {
  2799.         require_once __OCSP_PHPINCPATH__."common/pcf_md5.phpinc";
  2800.         return pcfmd5_encrypt(serialize(array('FRM_ID'=>$this->myForm->getId(),'FLDKEY'=>$this->getKey())));
  2801.     }
  2802.  
  2803.     /**
  2804.       * js code that ensures the form is registered
  2805.       *
  2806.       * @param string $aJsName 
  2807.       * @param string $aName 
  2808.       * @param boolean $debug 
  2809.       *
  2810.       * @return string (js-code)
  2811.       * 
  2812.       * @deprecated since pk-08-02-22
  2813.       */
  2814.     function js_register_field($aJsName="",$aName="",$debug=False)
  2815.     {
  2816.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::js_register_form()");
  2817.  
  2818.         if (empty($aJsName)) $aJsName=$this->getJsName();
  2819.         if (empty($aName))   $aName  =$this->getInputName();
  2820.  
  2821.         //ensure $this->myView and $this->myControll is set
  2822.         $this->getControll();
  2823.         $this->getView();
  2824.  
  2825.         if (pcf_is_instance_of($this->myForm,'DBMS_FORM'))
  2826.         {
  2827.             $str_jsId="FRM_".$this->myForm->getId();
  2828.         else {
  2829.             $str_jsId=$this->myForm->getHTMLName();
  2830.         }
  2831.  
  2832.         if ($debug || $this->fldDebug || $this->ajaxDebug)
  2833.         {
  2834.             $str_jsDebug='true';
  2835.         else {
  2836.             $str_jsDebug='false';
  2837.         }
  2838.  
  2839.         $str_ret="
  2840.             var objForm=ocsp_form_getFrmObj('".$str_jsId."');
  2841.             if (!(objForm))
  2842.             {
  2843.                 objForm=ocsp_form_register_form(new ocsp_frmObj('".$str_jsId."','".get_class($this->myControll)."','".get_class($this->myView)."'),$str_jsDebug);
  2844.             }
  2845.  
  2846.             if (objForm)
  2847.             {
  2848.                 objField=objForm.registerField(new ocsp_fldObj('$aJsName','$aName',$str_jsDebug));";
  2849.         if ($debug || $this->fldDebug || $this->ajaxDebug)
  2850.         {
  2851.             $str_ret.="
  2852.                 if (!objField)
  2853.                 {
  2854.                     alert('could not register field $aJsName to form $str_jsId File".basename(__FILE__)." Line: ".__LINE__." (".get_class($this).")');
  2855.                 }";
  2856.         }
  2857.         $str_ret.="
  2858.             } else {
  2859.                 alert('Form $str_jsId not found in ocsp_frmList File".basename(__FILE__)." Line: ".__LINE__." (".get_class($this).")');
  2860.             }";
  2861.         if ($debug || $this->fldDebug || $this->ajaxDebug)
  2862.         {
  2863.             $str_ret.="alert('".$this->getKey().": '+objForm.myName);";
  2864.         }
  2865.         return $str_ret;
  2866.     }
  2867.  
  2868.  
  2869.  
  2870.  
  2871.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2872.     // cvs data export methods
  2873.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2874.  
  2875.     /**
  2876.       * returns if the field is to be added to the csv export
  2877.       *
  2878.       * @return boolen 
  2879.       *
  2880.       * @since pk-06-09-27
  2881.       *
  2882.       ***/
  2883.     function exportCSV({
  2884.         if ($this->isPrimaryKey()) return True// always export primary keys
  2885.         return $this->exportCSV;
  2886.     }
  2887.  
  2888.     /**
  2889.       * returns the CSV value of field
  2890.       *
  2891.       * @param mixed $aValue 
  2892.       * @param string $arrName 
  2893.       * @param char $txtSep enclose strings in $txtSep
  2894.       * @param boolean $debug 
  2895.       *
  2896.       * @return string 
  2897.       *
  2898.       * @since pk-06-09-27
  2899.       *
  2900.       ***/
  2901.     function getCSV_Value($aValue,$arrName="DBVAL",$debug=False{
  2902.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::getCSV()");
  2903.  
  2904.         /*
  2905.         $s_value=str_replace("\n"," ",strval($aValue));
  2906.         if (!empty($txtSep)) {
  2907.             $s_value=$txtSep.str_replace($txtSep,"\\".$txtSep,$s_value).$txtSep;
  2908.         }
  2909.         */
  2910.         return $aValue;
  2911.     }
  2912.  
  2913.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2914.     // xml data export methods
  2915.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2916.  
  2917.     /**
  2918.       *
  2919.       *
  2920.       * @param string $fldRoot 
  2921.       * @parma bool $debug
  2922.       *
  2923.       * @return bool; 
  2924.       *
  2925.       * @version pk-05-09-14
  2926.       ***/
  2927.     function xmladdDOMElement(&$domObj,&$fldRoot,$base64=True,$debug=False{
  2928.         $class=strtoupper(get_class($this));
  2929.         if ($debugecho "<blockquote><b><b>$class</b></p><blockquote>";
  2930.         //$node=$domObj->createElement("FLD_CLASS",utf8_encode($class));
  2931.         //$fldRoot->appendChild($node);
  2932.  
  2933.  
  2934.         $valRoot $domObj->createElement("FLD_VALUES");
  2935.         $fldRoot->appendChild($valRoot);
  2936.         $serValArr=array();
  2937.         foreach (get_object_vars($thisas $var=>$val{
  2938.             if (is_array($val|| is_object($val)) {
  2939.                 $serValArr[$var]=$var;
  2940.             else if (!empty($val)) {
  2941.                 if ($base64)    $val=base64_encode(strval($val));
  2942.                 else            $val=htmlspecialchars($val);
  2943.                 $valRoot->appendChild($domObj->createElement($var,utf8_encode($val)));
  2944.             }
  2945.         }
  2946.  
  2947.         $valRoot $domObj->createElement("FLD_SER_VALUES");
  2948.         $fldRoot->appendChild($valRoot);
  2949.         // unset($serValArr['dbDesc']);
  2950.         foreach($serValArr as $key{
  2951.             $val=serialize($this->{$key});
  2952.             if ($base64)    $val=base64_encode($val);
  2953.             else            $val=htmlspecialchars($val);
  2954.             $valRoot->appendChild($domObj->createElement($key,utf8_encode($val)));
  2955.         }
  2956.  
  2957.         if ($debugecho "</blockquote></blockquote>";
  2958.         return True;
  2959.     }
  2960.  
  2961.     function xml_loadDomElement(&$fldRoot,$debug=False{
  2962.         if ($debugecho "<pre>".$frmNode->nodeName.": ".$frmNode->childNodes->length."</pre>";
  2963.         foreach($fldRoot->childNodes as $node{
  2964.             if ($debugecho "<pre>".$node->nodeName.": ".$node->childNodes->length."</pre>";
  2965.             switch($node->nodeName{
  2966.                 case "FLD_VALUES":
  2967.                     foreach($node->childNodes as $valNode{
  2968.                         if ($debugecho "<blockquote><p><b>".$valNode->nodeName."</b> ".utf8_decode($valNode->nodeValue)."</p>";
  2969.                         $this->{$valNode->nodeName}=utf8_decode($valNode->nodeValue);
  2970.                         if ($debugecho "</blockquote>";
  2971.                     }
  2972.                     break;
  2973.                 case "FLD_SER_VALUES:":
  2974.                     foreach($node->childNodes as $valNode{
  2975.                         if ($debugecho "<blockquote><p><b>".$valNode->nodeName."</b> ".utf8_decode($valNode->nodeValue)."</p>";
  2976.                         $this->{$valNode->nodeName}=unserialize(utf8_decode($valNode->nodeValue));
  2977.                         if ($debugecho "</blockquote>";
  2978.                     }
  2979.                     break;
  2980.             }
  2981.         }
  2982.     }
  2983.  
  2984.     
  2985.     // ###########################################################
  2986.     // ###########################################################
  2987.     // ###########################################################
  2988.     // 
  2989.     // implementation of INFA_DBMS_FIELD
  2990.     //
  2991.     // ###########################################################
  2992.     // ###########################################################
  2993.     // ###########################################################
  2994.     
  2995.     
  2996.     // --------------------------------------------------------
  2997.     // getter / setter
  2998.     // --------------------------------------------------------
  2999.  
  3000.     /**
  3001.       * returns the input name
  3002.       *
  3003.       * @return string 
  3004.       *
  3005.       */
  3006.     function getInputName()
  3007.     {
  3008.         return $this->myDataArrName."[".$this->myName."]";
  3009.     }
  3010.  
  3011.     /**
  3012.       * returns a unique DOM id for the field
  3013.       * 
  3014.       * Note: $this->myDOMId MUST NOT be stored in the db make sure it is excluded
  3015.       * 
  3016.       * @return string 
  3017.       * 
  3018.       * @since pk-07-07-29
  3019.       */
  3020.     public function getDOMId(
  3021.     {
  3022.         if (empty($this->myDOMId))
  3023.         
  3024.             $this->myDOMId hash('md5',$this->getFrmId().$this->getBlockId().$this->getKey().$this->getOrderNr().$this->label.$this->getMyForm()->getHTMLName());
  3025.         }
  3026.         return $this->myDOMId;
  3027.     }    
  3028.     
  3029.     /**
  3030.      * sets the unique DOM id for the field
  3031.      * 
  3032.      * @param string $aDOMId 
  3033.      * 
  3034.      * @since pk-08-06-09
  3035.      */
  3036.     public function setDOMId($aDOMId)
  3037.     {
  3038.         $this->myDOMId $aDOMId;
  3039.     }
  3040.     
  3041.     // --------------------------------------------------------
  3042.     // field configuration
  3043.     // --------------------------------------------------------
  3044.         
  3045.     /**
  3046.      * returns an array of field to bie shown in the edit form
  3047.      * by using editTbl_echoForm
  3048.      * 
  3049.      * the array is in the form:
  3050.      *
  3051.      * <code>
  3052.      * [_sectionName_]
  3053.      *      [TITLE] -> string
  3054.      *      [_rowName_]
  3055.      *         [FLDLAB]  (complete html code with <td></td>)
  3056.      *         [FLDVAL] (complete html code with <td></td>)
  3057.      *         [FLDTIT] (title of the label column)
  3058.      * </code>
  3059.      *
  3060.      * NOTE as this is not implemented in the whole classTree at the moment ensure all parents use
  3061.      * editTbl_echoForm() in theire editTblForm otherwise you'll get a mismatch of field order
  3062.      * 
  3063.      * @param boolean $debug 
  3064.      * 
  3065.      * @return array 
  3066.      * 
  3067.      * @since pk-06-04-26
  3068.      * @version pk-06-07-17 HIDDEN added to array
  3069.      * @version pk-06-08-15 FLDTIT added
  3070.      * @version pk-06-09-12 Tabs & Link showQuery added
  3071.      * @version pk-07-08-31 language file
  3072.      *  
  3073.      */
  3074.     protected function editTbl_getFieldEditArr($debug=False
  3075.     {
  3076.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::editTbl_getFieldEditArr","",0);
  3077.         $a_ret=array();
  3078.  
  3079.         include __OCSP_PHPINCPATH__ "db" _OCSP_DIRSEP_ "forms" _OCSP_DIRSEP_ "languages" _OCSP_DIRSEP_ "DBMS_FIELD_FieldEditArr.de.phpinc";
  3080.  
  3081.         return $a_ret;
  3082.  
  3083.     }
  3084.     
  3085.     /**
  3086.       * save the filed definition form
  3087.       *
  3088.       * @param boolean $debug 
  3089.       * 
  3090.       * @global array $_POST 
  3091.       * 
  3092.       * @return boolean 
  3093.       *
  3094.       */
  3095.     public function editTabl_save($debug=False)
  3096.     {
  3097.         if ($debug{
  3098.             echo "<p><b>DBMS_FIELD::save()</b> (".get_class($this).")</p>";
  3099.             echo "<blockquote><pre>";echo htmlspecialchars(print_r($_POST,True));
  3100.             echo "</pre></blockquote>";
  3101.         }
  3102.  
  3103.         $this->fldDebug        =((isset($_POST['fldDebug']&& intval($_POST['fldDebug'])) True False)/* <pk-04-06-02> fldDebug added */
  3104.         $this->fldDbgGetValue  =((isset($_POST['fldDbgGetValue']&& intval($_POST['fldDbgGetValue'])) True False)/*<pk-05-02-11 /> fldDbgGetValue added */
  3105.         $this->ajaxDebug       =((isset($_POST['ajaxDebug']&& intval($_POST['ajaxDebug'])) True False);
  3106.         $this->label           =$_POST['label'];
  3107.         $this->lstLabel        =(isset($_POST['lstLabel']$_POST['lstLabel'$this->lstLabel);
  3108.         $this->toolTip         =(isset($_POST['TOOLTIP']$_POST['TOOLTIP'$this->toolTip);
  3109.         $this->toolTipAsTitle  =($_POST['toolTipAsTitle']==True False)// </pk-05-09-05>
  3110.         $this->isSearchable    =((isset($_POST['SEARCHABLE']&& intval($_POST['SEARCHABLE'])) True False);
  3111.         $this->showInList      =((isset($_POST['SHOWINLIST']&& intval($_POST['SHOWINLIST'])) True False);
  3112.         $this->lstColSpan      =((isset($_POST['lstColSpan']&& intval($_POST['lstColSpan'])) intval($_POST['lstColSpan']1);
  3113.         $this->lstWidth           =((isset($_POST['lstWidth']&& intval($_POST['lstWidth'])) intval($_POST['lstWidth']0);    
  3114.         /* <pk-05-04-15 /> */
  3115.         $this->lstLink=array();
  3116.         if (isset($_POST['lstLink_A']&& !empty($_POST['lstLink_A'])) {
  3117.             $this->lstLink['A']         =$_POST['lstLink_A'];
  3118.             $this->lstLink['TEXT']      =$_POST['lstLink_TEXT'];
  3119.             $this->lstLink['ASTAB']     =(intval($_POST['lstLink_ASTAB']True False);
  3120.             $this->lstLink['TABLAB']    =$_POST['lstLink_TABLAB'];
  3121.             $this->lstLink['SHOWQUERY'=$_POST['lstLink_SHOWQUERY'];
  3122.         }
  3123.         $this->lstTDAdd             =(isset($_POST['lstTDAdd']$_POST['lstTDAdd'"")// <pk-05-07-08 />
  3124.         $this->showQuery            =(isset($_POST['showQuery']$_POST['showQuery'$this->showQuery);  // <pk-05-11-13 />
  3125.         $this->showQasHidden        =((isset($_POST['showQasHidden']&& intval($_POST['showQasHidden'])) True False);
  3126.         $this->showGroup            =(isset($_POST['showGroup']intval($_POST['showGroup']$this->showGroup)// <pk-06-10-08 />
  3127.  
  3128.         $this->isHidden             =((isset($_POST['isHidden']&& intval($_POST['isHidden'])) True False)// <pk-06-10-21 />
  3129.         $this->hideReadOnly         =((isset($_POST['SHOWREADONLY']&& intval($_POST['SHOWREADONLY'])) False True);    // inverted value in form
  3130.         $this->enableNew            =((isset($_POST['ENABLENEW']&& intval($_POST['ENABLENEW'])) True False);
  3131.         $this->enableEdit           =((isset($_POST['ENABLEEDIT']&& intval($_POST['ENABLEEDIT'])) True False);
  3132.         $this->enableEditIfEmpty    =((isset($_POST['enableEditIfEmpty']&& intval($_POST['enableEditIfEmpty'])) True False);
  3133.         $this->enableCopy           =((isset($_POST['enableCopy']&& intval($_POST['enableCopy'])) True False);
  3134.         $this->hideNew              =((isset($_POST['HIDENEW']&& intval($_POST['HIDENEW'])) True False);
  3135.         $this->hideEdit             =((isset($_POST['HIDEEDIT']&& intval($_POST['HIDEEDIT'])) True False);
  3136.         $this->hideCopy             =((isset($_POST['hideCopy']&& intval($_POST['hideCopy'])) True False);
  3137.         $this->size                 =(isset($_POST['SIZE']intval($_POST['SIZE']32);
  3138.         $this->maxlength            =(isset($_POST['MAXLENGTH']intval($_POST['MAXLENGTH']32);
  3139.         $this->defaultValue         =(isset($_POST['DEFAULTVALUE']intval($_POST['DEFAULTVALUE']"");
  3140.         $this->addTag               =(isset($_POST['addTag']$_POST['addTag'$this->addTag);
  3141.         $this->inputAdd             =(isset($_POST['inputAdd']$_POST['inputAdd'$this->inputAdd);
  3142.         $this->hideAddTag_ro        =((isset($_POST['hideAddTag_ro']&& intval($_POST['hideAddTag_ro'])) True False)/* <pk-05-02-25> */
  3143.         $this->labeltd_add          =(isset($_POST['labeltd_add']$_POST['labeltd_add'$this->labeltd_add);
  3144.         $this->labelcol_hide        =((isset($_POST['labelcol_hide']&& (intval($_POST['labelcol_hide'])==1)) True False);
  3145.         $this->fieldtd_add          =(isset($_POST['fieldtd_add']$_POST['fieldtd_add'$this->fieldtd_add);
  3146.  
  3147.         // <pk-06-11-27>
  3148.         $this->allowNull            =((isset($_POST['allowNull']&& intval($_POST['allowNull'])) True False);
  3149.         if ((!$this->dbDesc['NULL']&& (!empty($this->dbDesc['COLNAME']))) // <pk-06-02-21 />
  3150.             if (empty($this->defaultValue)) {
  3151.                 $this->allowNull    = False;
  3152.             }
  3153.         }
  3154.         // <pk-06-11-27 />
  3155.  
  3156.         $this->searchGroup_allowAll=((isset($_POST['searchGroup_allowAll']&& intval($_POST['searchGroup_allowAll'])) True False);
  3157.  
  3158.         $this->nullErrMsg       =(isset($_POST['nullErrMsg']$_POST['nullErrMsg'"");
  3159.         $this->myHelpUrl        =(isset($_POST['myHelpUrl']$_POST['myHelpUrl'"");
  3160.  
  3161.         // <pk-04-07-23>
  3162.         $this->js_check             =((isset($_POST['js_check']&& intval($_POST['js_check'])) True False);
  3163.         $this->regexcheck_pattern   =(isset($_POST['regexcheck_pattern']$_POST['regexcheck_pattern'"");
  3164.         $this->regexErrMsg          =(isset($_POST['regexErrMsg']$_POST['regexErrMsg'"")// <pk-05-08-09 />
  3165.         // </pk-04-07-23>
  3166.         $this->trimValue            =((isset($_POST['trimValue']&& intval($_POST['trimValue'])) True False);
  3167.  
  3168.         $this->tabIndex             =(isset($_POST['tabIndex']intval($_POST['tabIndex']0)/* <pk-05-02-18 />*/
  3169.  
  3170.         // <pk-05-06-29>
  3171.         if (isset($_POST['inputAdd']&& isset($_POST['unsetGrpKey']&& intval($_POST['unsetGrpKey'])) {
  3172.             $this->myGrpKey=NULL;
  3173.         }
  3174.         // </pk-05-06-29 />
  3175.  
  3176.         $this->exportCSV        =((isset($_POST['exportCSV']&& (intval($_POST['exportCSV']))) True False)// <pk-06-09-27>
  3177.  
  3178.         // <pk-08-09-10>
  3179.         $this->extConfOptions    (isset($_POST['extConfOptions']$_POST['extConfOptions'"");
  3180.         
  3181.         return True;
  3182.     }
  3183.     
  3184.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3185.     // view & control
  3186.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3187.  
  3188.     /**
  3189.      * sets the view object
  3190.      * 
  3191.      * @param OCSP_FRMVIEW $aView 
  3192.      * @access public
  3193.      */
  3194.     public function setView(&$aView)
  3195.     {
  3196.         $this->myView=&$aView;
  3197.     }
  3198.  
  3199.     /**
  3200.      * returns the view object
  3201.      * 
  3202.      * @return OCSP_FRMVIEW 
  3203.      * @access public
  3204.      */
  3205.     public function &getView()
  3206.     {
  3207.         if (!pcf_is_instance_of($this->myView,'OCSP_FRMVIEW'))
  3208.         {
  3209.             if (pcf_is_instance_of($this->myForm,'OCSP_FORM'))
  3210.             {
  3211.                 $this->myView=$this->myForm->getView();
  3212.             }
  3213.         }
  3214.         return $this->myView;
  3215.     }
  3216.  
  3217.     /**
  3218.      * alias for $this->setControl()
  3219.      *
  3220.      * @param OCSP_FRMCONTR $aControl 
  3221.      * 
  3222.      * @deprecated since pk-08-11-24
  3223.      */
  3224.     public function setControll(&$aControl)
  3225.     {
  3226.         $this->setControl(&$aControl);
  3227.     }
  3228.     
  3229.     /** 
  3230.      * sets the controll object
  3231.      * 
  3232.      * @param OCSP_FRMCONTR $aControl 
  3233.      * @access public
  3234.      */
  3235.     public function setControl(&$aControl)
  3236.     {
  3237.         $this->myControll $aControl;
  3238.     }
  3239.     
  3240.     /**
  3241.      * alias for $this->getControl()
  3242.      * 
  3243.      * @return OCSP_FRMCONTR 
  3244.      * 
  3245.      * @deprecated since pk-08-11-24
  3246.      */
  3247.     public function &getControll()
  3248.     {
  3249.         return $this->getControl();
  3250.     }
  3251.     
  3252.     /**
  3253.      * returns the controll object
  3254.      * 
  3255.      * @return OCSP_FRMCONTR 
  3256.      * @access public
  3257.      */
  3258.     public function &getControl()
  3259.     {
  3260.         if (pcf_is_instance_of($this->myControll,'OCSP_FRMCONTR'|| ($this->checkControll()))
  3261.         {
  3262.             return $this->myControll;
  3263.         else if (pcf_is_instance_of($this->myForm,'DBMS_FORM')) // old form
  3264.             return $this->myControll;
  3265.         else {
  3266.             ocsp_logError(__FILE__,__LINE__,"unable to get controll",E_NOTICE);
  3267.         }
  3268.         return $this->myControll;
  3269.     }
  3270.  
  3271.     /**
  3272.      * alias for $this->checkControl()
  3273.      *
  3274.      * @param string $str_className 
  3275.      * @param boolean $debug 
  3276.      * 
  3277.      * @return boolean 
  3278.      * 
  3279.      * @deprecated since pk-08-11-27
  3280.      */
  3281.     function checkControll($str_className='OCSP_FRMCONTR',$debug=False)
  3282.     {
  3283.         return $this->checkControl($str_className,$debug);
  3284.     }
  3285.  
  3286.     /**
  3287.      * sets $this->myControll form $this->myForm if not pcf_is_instance_of $str_className
  3288.      *
  3289.      * @param string $str_className 
  3290.      * @param boolean $debug 
  3291.      * 
  3292.      * @return boolean 
  3293.      */
  3294.     function checkControl($str_className='OCSP_FRMCONTR',$debug=False)
  3295.     {
  3296.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::checkControll($str_className)");
  3297.         if (!pcf_is_instance_of($this->myControll,$str_className))
  3298.         {
  3299.             if (!$this->getMyForm())
  3300.             {
  3301.                 ocsp_logError(__FILE__,__LINE__,"unable to get form in field: ".$this->getKey(),E_WARNING);
  3302.                 return False;
  3303.             }
  3304.             if (pcf_is_instance_of($this->myForm,'OCSP_FORM'))
  3305.             {
  3306.                 $this->myControll=$this->myForm->getControllObj($str_className);
  3307.             }
  3308.             return pcf_is_instance_of($this->myControll,$str_className);
  3309.         else {
  3310.             return True;
  3311.         }
  3312.     }
  3313.             
  3314.     // --------------------------------------------------------
  3315.     // jOCSP
  3316.     // --------------------------------------------------------
  3317.     
  3318.     /**
  3319.      * returns an array of jOCSP/jQuery Modules which are required
  3320.      * 
  3321.      * $arr_ret[]="script url";
  3322.      *
  3323.      * @param boolean $debug 
  3324.      * 
  3325.      * @return string 
  3326.      */
  3327.     public function jOCSP_getRequiredModules($debug=False)
  3328.     {
  3329.         if ($debugechoDebugMethod(__FILE__,get_classe($this),"DBMS_FIELD::jOCSP_getRequiredModules()");      
  3330.         return array();
  3331.     }
  3332.     
  3333.     /**
  3334.      * returns additional object elements of the field object
  3335.      * 
  3336.      * array definition: [elemName] = value
  3337.      * 
  3338.      * @param boolean $debug 
  3339.      * 
  3340.      * @return array 
  3341.      * 
  3342.      * @since pk-08-02-06
  3343.      */
  3344.     protected function jOCSP_getAdditonalFieldObjElems($debug=False)
  3345.     {
  3346.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::jOCSP_getAdditonalFieldObjElems();");                
  3347.         return array();
  3348.     }
  3349.     
  3350.     /**
  3351.      * returns the javascript code to register the field to an form
  3352.      *
  3353.      * @param boolean $debug 
  3354.      * 
  3355.      * @return string (json)
  3356.      */
  3357.     public function jOCSP_getFieldObj($debug=False)
  3358.     {
  3359.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::jOCSP_getFieldObj()");
  3360.         
  3361.         $str_ret "{
  3362.             fldName: '" $this->myName "',
  3363.             table: '" $this->myTable "',
  3364.             domId: '" $this->getDOMId("', 
  3365.             inputName: '" $this->getInputName("',
  3366.             allowNull: " ($this->allowNull("true" "false");
  3367.  
  3368.         if ($this->getGrpKey(&& ($obj_grpFld $this->getGrpFld($debug))) 
  3369.         {
  3370.             $str_ret .= ",grpFldDomId: '" $obj_grpFld->getDOMId("'";
  3371.         }
  3372.             
  3373.         if ($arr_objElems $this->jOCSP_getAdditonalFieldObjElems($debug))
  3374.         {
  3375.             if (is_array($arr_objElems))
  3376.             {
  3377.                 foreach($arr_objElems as $str_id => $str_jsonVal)
  3378.                 {
  3379.                     $str_ret .= "," $str_id ": " $str_jsonVal;
  3380.                 }
  3381.             }
  3382.         }
  3383.         
  3384.         $str_ret .= "}";
  3385.         
  3386.         return $str_ret;
  3387.     }    
  3388.  
  3389.     // --------------------------------------------------------
  3390.     // extJS
  3391.     // --------------------------------------------------------
  3392.  
  3393.     /**
  3394.      * returns the xtype of the field
  3395.      * 
  3396.      * @see http://extjs.com/deploy/dev/docs/output/Ext.Component.html
  3397.      * 
  3398.      * @return string 
  3399.      */
  3400.     public function getExtJSxType()
  3401.     {
  3402.         return $this->extJSxType;    
  3403.     }
  3404.     
  3405.     /**
  3406.      * returns options of an ext js field config object
  3407.      * 
  3408.      * NOTE the return string is NOT enclosed by {}
  3409.      * 
  3410.      * @param boolean $debug 
  3411.      * 
  3412.      * @return array of json object values
  3413.      * 
  3414.      * @since pk-08-09-08
  3415.      */
  3416.     public function getExtJSConfigOptions($debug=False)
  3417.     {
  3418.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::getExtJSConfigOptions();");
  3419.         
  3420.         $arr_ret array(
  3421.                 'name'     =>  "'" $this->getInputName("'",
  3422.                 'id'       =>  "'" $this->getJsName("'",
  3423.                 'xtype'    =>    "'" $this->getExtJSxType("'",
  3424.                 'fieldLabel' => "'" pcf_js_escape($this->label"'"
  3425.             );
  3426.  
  3427.         if (!empty($this->extConfOptions))
  3428.         {
  3429.             $obj_json json_decode("{" $this->extConfOptions "}");
  3430.             $arr_vars get_object_vars($obj_json);
  3431.             foreach($arr_vars as $str_name => $mixValue)
  3432.             {
  3433.                 if (!isset($arr_ret[$str_name]))
  3434.                 {
  3435.                     $arr_ret[$str_name$mixValue;            
  3436.                 }
  3437.             }
  3438.         }            
  3439.             
  3440.         if (!$this->allowNull())
  3441.         {
  3442.             $arr_ret['allowBlank'"false";
  3443.         }
  3444.         
  3445.         if ($this->isHidden('form'))
  3446.         {
  3447.             $arr_ret['hidden'"true";
  3448.         }
  3449.         
  3450.         if (!($this->isEnabled($this->getMyForm()->getFrmMode())))
  3451.         {
  3452.             $arr_ret['disabled'"true";
  3453.         }
  3454.         
  3455.         return $arr_ret;
  3456.         
  3457.     }
  3458.     
  3459.     
  3460.     // --------------------------------------------------------
  3461.     // html form output
  3462.     // --------------------------------------------------------
  3463.         
  3464.     /**
  3465.      * returns the html tag for the label
  3466.      * 
  3467.      * @param int $mode 
  3468.      * @param boolean $debug 
  3469.      * 
  3470.      * @return string 
  3471.      *
  3472.      */
  3473.     public function getFormLabelTag($mode,$debug=False)
  3474.     {
  3475.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::getFormLabelTag()");
  3476.         return $this->getLabel();
  3477.     }
  3478.     
  3479.     
  3480.     /**
  3481.       * returns the html code for the field value input / show
  3482.       *
  3483.       * @param int $mode 
  3484.       * @param mixed $aValue 
  3485.       * @param boolean $debug 
  3486.       *
  3487.       * @return string 
  3488.       *
  3489.       */
  3490.     public function getFormFieldTag($mode,$aValue=NULL,$debug=False)
  3491.     {
  3492.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::getFormFieldTag()");
  3493.         
  3494.         return $this->getFieldTag($mode,$aValue,$debug);    
  3495.     }
  3496.  
  3497.     
  3498.     // --------------------------------------------------------
  3499.     // DBMS_FIELD_FLDGROUP hook
  3500.     // --------------------------------------------------------
  3501.  
  3502.     /**
  3503.       * @param string $aKey 
  3504.       * @since pk-04-02-23
  3505.       ***/
  3506.     function setGrpKey($aKey{
  3507.         $this->myGrpKey=$aKey;
  3508.     }    
  3509.     
  3510.     /**
  3511.       * @return string 
  3512.       * @since pk-04-02-23
  3513.       ***/
  3514.     function getGrpKey({
  3515.         return $this->myGrpKey;
  3516.     }
  3517.  
  3518.     /**
  3519.       * @param bool $debug 
  3520.       * @return DBMS_FIELD 
  3521.       *
  3522.       * @since pk-04-02-23
  3523.       * @version pk-07-08-08
  3524.       *
  3525.       ***/
  3526.     function &getGrpFld($debug=False{
  3527.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD::getGrpFld() [".$this->getKey()."]");
  3528.         if ($key=$this->getGrpKey())
  3529.         {
  3530.             if ($this->getMyForm())
  3531.             {
  3532.                 if ($obj_ret $this->myForm->getField($key))
  3533.                 {
  3534.                     return $obj_ret;
  3535.                 else {
  3536.                     $this->setGrpKey("");
  3537.                 }
  3538.             
  3539.         }        
  3540.         $ret=NULL;
  3541.         return $ret;
  3542.     }
  3543.     
  3544.     
  3545.      
  3546.     
  3547. // end class DBMS_FIELD
  3548. ?>

Documentation generated on Thu, 08 Jan 2009 17:40:27 +0100 by phpDocumentor 1.4.0a2