Source for file DBMS_FIELD_FLDGROUP.phpclass

Documentation is available at DBMS_FIELD_FLDGROUP.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_FLDGROUP.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   layout
  8.   *
  9.   * @author     Peter Krebs <pitlinz@users.sourceforge.net>
  10.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11.   *
  12.   * @version $Id: DBMS_FIELD_FLDGROUP.phpclass,v 1.11 2008/11/02 11:39:36 pitlinz Exp $
  13.   */
  14.  
  15. if (!class_exists('DBMS_FIELD_LAYOUT'))
  16. {
  17.     require_once dirname(__FILE___OCSP_DIRSEP_ "DBMS_FIELD_LAYOUT.phpclass";
  18. }
  19.  
  20.  
  21. /**
  22.   * Class DBMS_FIELD_FLDGROUP
  23.   *
  24.   * @project    Open CSP-Management
  25.   * @package    dbms_field
  26.   * @category   layout
  27.   *
  28.   * @author     Peter Krebs <p.krebs@amicas.at>
  29.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  30.   *
  31.   * @version pk-07-02-14 changed parent class to DBMS_FIELD_LAYOUT
  32.   *
  33.   * @version $Id: DBMS_FIELD_FLDGROUP.phpclass,v 1.11 2008/11/02 11:39:36 pitlinz Exp $
  34.   */
  35.     extends DBMS_FIELD_LAYOUT {
  36.  
  37.     // ---------------------------------------------------------------------------
  38.     // constants
  39.     // ---------------------------------------------------------------------------
  40.     
  41.     /**
  42.      * @constant string CLASS_SRC_FILE
  43.      */
  44.     const CLASS_SRC_FILE = __FILE__;        
  45.         
  46.     // ###########################################################
  47.     // OBJECT (CONST) VAR DECLARATION
  48.     // ###########################################################
  49.  
  50.     /**
  51.       * source file of the class
  52.       * (without $GLOBALS['PROJECT']['PATH']
  53.       *
  54.       * @var string $classSrcFile 
  55.       * @since pk-05-01-11
  56.       ***/
  57.     protected $classSrcFile=__FILE__;
  58.  
  59.     /**
  60.       * @var array $grpfldList 
  61.       */
  62.     protected $grpfldList = array();
  63.  
  64.     /**
  65.       * @var string $grpfldSep 
  66.       */
  67.     protected $grpfldSep = "/";
  68.  
  69.     /**
  70.       * @var boolean $addSubLabels 
  71.       * @since pk-04-08-10
  72.       ***/
  73.     protected $addSubLabels;
  74.  
  75.  
  76.     // ###########################################################
  77.     // OBJECT SETTINGS METHODS
  78.     // ###########################################################
  79.  
  80.  
  81.     /**
  82.       * returns an array of field to bie shown in the edit form
  83.       * by using editTbl_echoForm
  84.       *
  85.       * the array is in the form:
  86.       *
  87.       * <code>
  88.       * [_sectionName_]
  89.       *      [TITLE] -> string
  90.       *      [_rowName_]
  91.       *         [FLDLAB]  (complete html code with <td></td>)
  92.       *         [FLDVAL] (complete html code with <td></td>)
  93.       * </code>
  94.       *
  95.       * @param boolean $debug 
  96.       *
  97.       * @returns array
  98.       *
  99.       * @since pk-07-02-14
  100.       *
  101.       ***/
  102.     function editTbl_getFieldEditArr($debug=False{
  103.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_FLDGROUP::editTbl_getFieldEditArr","",0);
  104.         $a_ret=parent::editTbl_getFieldEditArr($debug);
  105.  
  106.         unset($a_ret['LIST']);
  107.  
  108.         if ($o_frmObj=$this->getMyForm($debug)) {
  109.             $fldLst=$o_frmObj->getFields('',$debug);
  110.         }
  111.  
  112.         $str_jsUpdate="
  113.                 document.frmFieldEdit.grpfldList.value='';
  114.                 var sep='';
  115.                 for(var i = 0; i < document.frmFieldEdit.assigned.options.length; i++)
  116.                 {
  117.                     document.frmFieldEdit.grpfldList.value=document.frmFieldEdit.grpfldList.value+sep+document.frmFieldEdit.assigned.options[i].value;
  118.                     sep=';';
  119.                 }
  120.             ";
  121.  
  122.         $s_fldSel="
  123.                     <input name=\"grpfldList\" value=\"".implode(";",$this->grpfldList)."\" size=\"80\" type=\"hidden\" />
  124.                     <table border=\"0\" cellspacing=\"1\" width=\"100%\" cellpadding=\"2\">
  125.                         <tr>
  126.                             <th align=\"center\">Zugeordnet</th>
  127.                             <th width=\"10%\">&nbsp;</th>
  128.                             <th align=\"center\">nicht Zugeordnet</th>
  129.                         </tr>
  130.                         <tr>
  131.                             <td>
  132.                                 <select name=\"assigned\" style=\"font-face:system;\" size=\"8\" onChange=\"
  133.                                     document.frmFieldEdit.lastSel.value=document.frmFieldEdit.assigned.options[document.frmFieldEdit.assigned.selectedIndex].value;
  134.                                     document.frmFieldEdit.notassigned.options[document.frmFieldEdit.notassigned.selectedIndex].selected=False;
  135.                                     \">\n";
  136.         foreach($fldLst as $key => $fld{
  137.             if ($fld->getKey(== $this->getKey()) // remove the field himself from the list
  138.                 unset($fldLst[$key]);
  139.             else if (in_array($fld->getKey(),$this->grpfldList)) {
  140.                 $s_fldSel.="\t<option value=\"".$fld->getKey()."\">".$fld->getKey()."</option>\n";
  141.                 unset($fldLst[$key]);
  142.             }
  143.         }
  144.         $s_fldSel.="
  145.                                 </select>
  146.                             </td>
  147.                             <td valign=\"middle\" align=\"center\">
  148.                                 <input type=\"button\" value=\"<--\" onClick=\"
  149.                                     document.frmFieldEdit.assigned.options[document.frmFieldEdit.assigned.options.length]=document.frmFieldEdit.notassigned.options[document.frmFieldEdit.notassigned.selectedIndex];
  150.                                     document.frmFieldEdit.notassigned.options[document.frmFieldEdit.notassigned.selectedIndex]=null;
  151.                                     $str_jsUpdate
  152.                                     \">
  153.                                 <br />
  154.                                 <input type=\"button\" value=\"-->\" onClick=\"
  155.                                     document.frmFieldEdit.notassigned.options[document.frmFieldEdit.notassigned.options.length]=document.frmFieldEdit.assigned.options[document.frmFieldEdit.assigned.selectedIndex];
  156.                                     document.frmFieldEdit.assigned.options[document.frmFieldEdit.assigned.selectedIndex]=null;
  157.                                     $str_jsUpdate
  158.                                     \"><br />
  159.                                 <input type=\"hidden\" name=\"lastSel\">
  160.                             </td>
  161.                             <td>
  162.                                 <select name=\"notassigned\" size=\"8\">\n";
  163.         foreach($fldLst as $key => $fld{
  164.             $s_fldSel.= "\t<option value=\"".$fld->getKey()."\">".$fld->getKey()."</option>\n";
  165.         }
  166.         $s_fldSel.="
  167.                                 </select>
  168.                             </td>
  169.                         </tr>
  170.                     </table>\n";
  171.  
  172.         $a_ret['FIELDS']=array(
  173.             'TITLE'         => "Gruppen-Felder",
  174.             'HIDDENFIELD'   => "",
  175.             'ISHIDDEN'      => False,
  176.             'FLD_FLDLST'    => array(
  177.                 'FLDLAB'=> "Felder",
  178.                 'FLDVAL'=> $s_fldSel
  179.             ),
  180.             'FLD_SEP'       => array(
  181.                 'FLDLAB'=>"Feldtrennung",
  182.                 'FLDVAL'=>"<input name=\"grpfldSep\" value=\"".htmlspecialchars($this->grpfldSep)."\" size=\"30\">"
  183.             ),
  184.             'FLD_ADDSUBLAB' => array(
  185.                 'FLDLAB'=>"Feldlabels in Formularen?",
  186.                 'FLDVAL'=>"
  187.                             <input name=\"addSubLabels\" type=\"radio\" value=\"0\" ".(($this->addSubLabels"" "checked").">nein
  188.                             <input name=\"addSubLabels\" type=\"radio\" value=\"1\" ".(($this->addSubLabels"checked" "").">ja
  189.                           "
  190.  
  191.             )
  192.         );
  193.  
  194.         return $a_ret;
  195.     }
  196.  
  197.  
  198.     /**
  199.       * save the filed definition form
  200.       **/
  201.  
  202.     function save({
  203.         $ret=parent::save();
  204.  
  205.         $this->isSearchable    =False;
  206.         $this->showInList      =False;
  207.  
  208.         if (isset($_POST['grpfldList']))
  209.         {
  210.             $this->grpfldList      =explode(";",$_POST['grpfldList']);
  211.         }
  212.         $this->grpfldSep       =$_POST['grpfldSep'];
  213.         $this->addSubLabels    =($_POST['addSubLabels']  == True False);
  214.  
  215.         $this->getMyForm();
  216.         foreach($this->grpfldList as $str_fldkey{
  217.             if ($fld=$this->myForm->getField($str_fldkey)) {
  218.                 $fld->setGrpKey($this->getKey());
  219.             }
  220.         }
  221.         return True;
  222.     }
  223.  
  224.     // ###########################################################
  225.     // OBJECT DATA METHODS
  226.     // ###########################################################
  227.  
  228.     /**
  229.       * adds a field to the group
  230.       *
  231.       * @param DBMS_FIELD &$aFld 
  232.       *
  233.       * @since pk-04-08-10
  234.       *
  235.       ***/
  236.     function addField(&$aField{
  237.         if ($fldKey=$aField->getKey()) {
  238.             if (!in_array($fldKey,$this->grpfldList)) {
  239.                 $this->grpfldList[]=$fldKey;
  240.                 $aField->setGrpKey($this->getKey());
  241.             }
  242.         }
  243.     }
  244.  
  245.  
  246.     // ###########################################################
  247.     // OBJECT HTML FORM METHODS
  248.     // ###########################################################
  249.  
  250.  
  251.     /**
  252.       * html output of the field (no value)
  253.       *
  254.       * @param int      $mode       show mode of the field
  255.       * @param mixed    $aValue     value of the field
  256.       * @param string   $arrName    array in Name of the html input form <input name=ARRNAME[FIELDNAME]>
  257.       *                              it also needs to be a global array global ${$arrName}
  258.       * @param bool     $debug      show debug info
  259.       *
  260.       * @return bool    True if an input field is written
  261.       *
  262.       * @version pk-04-12-28
  263.       * @version pk-05-02-04 set $fld->myDataArrName
  264.       * @version pk-07-08-27
  265.       *
  266.       * @todo DBMS_FIELD_FLDGROUP::getFieldTag remove old DBMS_FORM code
  267.       ***/
  268.     function getFieldTag($mode,$aValue="",$debug=False{
  269.         global ${$this->myDataArrName};
  270.  
  271.         $debug=($debug || $this->fldDebug)/* <pk-04-12-28 /> */
  272.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_FLDGROUP::getFieldTag($mode,$aValue)","DataArray: ".$this->myDataArrName."<br />Group Fields:<pre>".print_r($this->grpfldList,True)."</pre>");
  273.  
  274.         if (method_exists($this->myForm,'getControll'))
  275.         {
  276.             $obj_controll=$this->myForm->getControll();
  277.         else {
  278.             // DBMS_FORM style
  279.             $obj_controll=NULL;
  280.             $cha_sep='';
  281.         }
  282.  
  283.         //$frmObj=$this->getMyForm();
  284.         $arr_fields=array();
  285.         foreach($this->grpfldList as $str_fldKey)
  286.         {
  287.             if ($obj_field=$this->myForm->getField($str_fldKey))
  288.             {
  289.                 $int_orderNr=$obj_field->getOrderNr();
  290.                 while(isset($arr_fields[$int_orderNr])) $int_orderNr++;
  291.                 
  292.                 // <pk-08-05-21 moved here to set for any field in the group
  293.                 
  294.                 $obj_field->setDataArrName($this->myDataArrName);
  295.                 $obj_field->setMyForm($this->myForm);
  296.                 
  297.                 $arr_fields[$int_orderNr]=$obj_field;
  298.                 
  299.                 // </pk-08-05-21>
  300.             }
  301.         }
  302.  
  303.         ksort($arr_fields);
  304.  
  305.         $str_ret="";$str_fldSep="";$cha_sep="";
  306.         $arr_fldIds array();
  307.                 
  308.         foreach($arr_fields as &$obj_field)
  309.         {
  310.             if ($obj_field->isToShow($mode,${$this->myDataArrName},$debug,True))
  311.             {
  312.                 $str_ret.=$str_fldSep;
  313.                 if ($this->addSubLabels && (!$obj_field->labelIsHidden()))
  314.                 {
  315.                     $str_ret.=$obj_field->getLabel()." ";
  316.                 }
  317.                 if ($obj_controll)
  318.                 {
  319.                     if (!method_exists($obj_controll,"getFieldTag"))
  320.                     {
  321.                         $str_ret.="Error: wrong controll for field: ".$this->getName()." (".basename(__FILE__)." Line: ".__LINE__.")";
  322.                     else {
  323.                         $str_ret.=$obj_controll->getFieldTag($obj_field,$debug);
  324.                         $arr_fldIds[$obj_field->getDOMId();
  325.                     }
  326.                 else {
  327.                     $m_val=(isset(${$this->myDataArrName}[$obj_field->getName()]? ${$this->myDataArrName}[$obj_field->getName()NULL);
  328.                     $str_ret.=$obj_field->getFieldTag($mode,$m_val,$debug);
  329.                     $arr_fldIds[$obj_field->getDOMId();
  330.                     $cha_sep=",";
  331.                 }
  332.                 $str_fldSep=$this->grpfldSep;
  333.             }
  334.         }
  335.  
  336.         $str_ret.=$this->addTag;
  337.                 
  338.         return $str_ret;
  339.     }
  340.  
  341.  
  342.     // ###########################################################
  343.     // SEARCH FORM METHODS
  344.     // ###########################################################
  345.  
  346.  
  347.     // ###########################################################
  348.     // OBJECT HTML FORM METHODS
  349.     // ###########################################################
  350.  
  351.     /**
  352.      * returns if the field is a layout only field
  353.      *  
  354.      * @return boolean
  355.      */
  356.     function isLayoutFld(
  357.     {
  358.         return False;
  359.     }
  360.     
  361.     // ###########################################################
  362.     // OBJECT VALUE CHECK METHODS
  363.     // ###########################################################
  364.  
  365.     
  366.        // --------------------------------------------------------
  367.     // jOCSP
  368.     // -------------------------------------------------------- 
  369.     
  370.     /**
  371.      * returns an array of jOCSP/jQuery Modules which are required
  372.      * 
  373.      * $arr_ret[]="script url";
  374.      *
  375.      * @param boolean $debug
  376.      * 
  377.      * @global array $OCSP_CONF
  378.      * 
  379.      * @return string
  380.      * 
  381.      * @since pk-08-03-07
  382.      */
  383.     public function jOCSP_getRequiredModules($debug=False)
  384.     {
  385.         if ($debugechoDebugMethod(__FILE__,get_classe($this),"DBMS_FIELD::jOCSP_getRequiredModules()");
  386.         
  387.         $arr_ret parent::jOCSP_getRequiredModules($debug);
  388.         
  389.         $arr_ret[array(
  390.             'CLASS'    => 'jOCSP.FLDOBJ_FldGroup',
  391.             'SRC'    => OCSP_CONF::getInstance()->getValue('SYSTEMURL')."jOCSP/formFields/jOCSP_FLDOBJ_FldGroup.js"
  392.         );
  393.         
  394.         return $arr_ret;
  395.     }      
  396.  
  397.    /**
  398.      * returns additional object elements of the field object
  399.      * 
  400.      * array definition: [elemName] = value
  401.      * 
  402.      * NOTE: do not js_escapte value this is done when building the json object 
  403.      *
  404.      * @param boolean $debug
  405.      * 
  406.      * @return array
  407.      * 
  408.      * @since pk-08-03-07
  409.      */
  410.     protected function jOCSP_getAdditonalFieldObjElems($debug=False)
  411.     {
  412.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_SELECTLIST::jOCSP_getAdditonalFieldObjElems();");                
  413.  
  414.         $arr_ret parent::jOCSP_getAdditonalFieldObjElems($debug);
  415.  
  416.         $arr_ret['fldClass'"'FLDOBJ_FldGroup'";
  417.         return $arr_ret;
  418.     }
  419.     
  420. // end class DBMS_FIELD_HEADLINE
  421. ?>

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