Source for file OCSP_FRMVIEW_FORM.phpclass

Documentation is available at OCSP_FRMVIEW_FORM.phpclass

  1. <?php
  2. /**
  3.   * Class file OCSP_FRMVIEW_FORM.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    forms
  7.   * @category   dbms_form
  8.   *
  9.   * @author     Peter Krebs (pk) <pitlinz@users.sourceforge.net>
  10.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11.   *
  12.   * @since  pk-07-06-30
  13.   * @version $Id: OCSP_FRMVIEW_FORM.phpclass,v 1.28 2008/12/04 16:02:28 peterkrebs Exp $
  14.   * 
  15.   */
  16.  
  17. require_once dirname(__FILE__)."/OCSP_FRMVIEW.phpclass";
  18.  
  19.  
  20. /**
  21.   * class OCSP_FRMVIEW_FORM
  22.   *
  23.   * @project    Open CSP-Management
  24.   * @package    forms
  25.   * @category   dbms_form
  26.   *
  27.   * @author     Peter Krebs (pk) <pitlinz@users.sourceforge.net>
  28.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  29.   *
  30.   * @since  pk-07-06-30
  31.   * @version $Id: OCSP_FRMVIEW_FORM.phpclass,v 1.28 2008/12/04 16:02:28 peterkrebs Exp $
  32.   */
  33. {
  34.  
  35.     /*** Aggregations: */
  36.  
  37.  
  38.     /*** Compositions: */
  39.  
  40.     /**
  41.       * @var OCSP_FRMCONTR_FORM $myControl 
  42.       * @access protected
  43.       */
  44.     protected $myControl;       
  45.  
  46.     /*** Attributes: */
  47.  
  48.     /**
  49.       * button images
  50.       * @var array $buttonImages 
  51.       * @access protected
  52.       */
  53.     protected $buttonImages = array();
  54.  
  55.     /**
  56.       * hide form button pannel
  57.       * @var boolean $hideFrmBtnPannel 
  58.       * @access protected
  59.       */
  60.     protected $hideFrmBtnPannel=FALSE;
  61.  
  62.     /**
  63.       * @var string $outerDivStyle 
  64.       * @access protected
  65.       */
  66.     protected $outerDivStyle="display:inline;margin:0px;padding:0px;border:0px;";
  67.  
  68.     /*** Association */
  69.  
  70.  
  71.     
  72.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  73.     // init methods
  74.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  75.  
  76.  
  77.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  78.     // getter/setter methods
  79.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  80.  
  81.     /**
  82.       * @return int 
  83.       */
  84.     function getMode()
  85.     {
  86.         return intval($this->myForm->getFrmMode());
  87.     }
  88.  
  89.     /**
  90.       * @param int $aMode 
  91.       */
  92.     function setMode($aMode)
  93.     {
  94.         $this->myForm->setFrmMode($aMode);
  95.     }
  96.  
  97.  
  98.     /**
  99.       * @param boolean $debug 
  100.       * @return array 
  101.       */
  102.     function getFields($debug=FALSE)
  103.     {
  104.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_FORM::getFields()");
  105.         return $this->getFieldsMode($this->getMyForm()->getFrmMode(),$debug);
  106.     }
  107.  
  108.     /**
  109.       * sets $this->hideFrmBtnPannel to TRUE
  110.       */
  111.     function set_ButtonPannelHidden()
  112.     {
  113.         $this->hideFrmBtnPannel=TRUE;
  114.     }
  115.  
  116.     /**
  117.       * sets $this->hideFrmBtnPannel to FALSE
  118.       */
  119.     function set_ButtonPannelShown()
  120.     {
  121.         $this->hideFrmBtnPannel=FALSE;
  122.     }
  123.  
  124.     /**
  125.       * @return boolean 
  126.       */
  127.     function buttonPannelIsHidden()
  128.     {
  129.         return $this->hideFrmBtnPannel;
  130.     }
  131.  
  132.  
  133.     /**
  134.       * @param string $btnImgUrl 
  135.       */
  136.     function setButtonImg($cmd,$btnImgUrl)
  137.     {
  138.         $this->buttonImages[$cmd]=$btnImgUrl;
  139.     }
  140.  
  141.  
  142.     /**
  143.      * returns the first enabled field
  144.      * 
  145.      * @return DBMS_FIELD 
  146.      * 
  147.      * @since pk-08-12-04
  148.      */
  149.     public function &getFirstEnabledField()
  150.     {
  151.         if ($arr_fields $this->getFields())
  152.         {
  153.             foreach($arr_fields as &$obj_field)
  154.             {
  155.                 if ($obj_field->isToShow($this->getMyForm()->getFrmMode(),$this->getMyForm()->getControl()->getCurrentRow()))
  156.                 {
  157.                     if ($obj_field->isEnabled($this->getMyForm()->getFrmMode()))
  158.                     {
  159.                         return $obj_field;
  160.                     }
  161.                 }
  162.             }
  163.         }
  164.         $obj_ret Null;
  165.         return $obj_ret;
  166.     }
  167.     
  168.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  169.     // output
  170.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  171.  
  172.  
  173.  
  174.     // ----------- buttons -------------------------
  175.  
  176.     /**
  177.       * @param boolean $debug 
  178.       * @return string 
  179.       */
  180.     function getButtonPannel($debug=FALSE)
  181.     {
  182.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_FORM::getButtonPannel()");
  183.         $str_ret="";
  184.         if ($this->myControl->hasCmdButtons($debug))
  185.         {
  186.             $str_ret.="<div class=\"frmButtonPanel\">";
  187.             $str_ret.=$this->myControl->getFormCmdButtons($debug);
  188.             $str_ret.="</div>";
  189.         }
  190.         return $str_ret;
  191.     }
  192.     
  193.  
  194.     /**
  195.       * returns the image tag for a button
  196.       *
  197.       * @param string $cmd 
  198.       * @param boolean $debug 
  199.       *
  200.       * @global array $OCSP_CONF 
  201.       *
  202.       * @return string 
  203.       * @access public
  204.       */
  205.     function getButton($cmd,$debug=FALSE)
  206.     {
  207.         global $OCSP_CONF;
  208.  
  209.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_FORM::getButton()");
  210.  
  211.         if (isset($this->buttonImages[$cmd]))
  212.         {
  213.             return "<img src=\"".$this->buttonImages[$cmd]."\" border=\"0\" alt=\"$cmd\" class=\"button\" />";
  214.         }
  215.  
  216.         // some default settings
  217.         switch($cmd)
  218.         {
  219.             case "BACK":
  220.                 return "<img src=\"" OCSP_CONF::getInstance()->getValue('SYSIMGURL'"icons-22x22/back.png\" border=\"0\" alt=\"back\" title=\"".$this->myForm->getLangTxt('BACK')."\" class=\"button\">";
  221.             case "SAVE":
  222.                 switch($this->myForm->getFrmMode())
  223.                 {
  224.                     case FRM_MODE_NEW:
  225.                     case FRM_MODE_COPY:
  226.                         return "<img src=\"" OCSP_OBJ::getConf('SYSIMGURL'"icons-22x22/filesaveas.png\" border=\"0\" alt=\"save\" title=\"".$this->myForm->getLangTxt('SUBMIT')."\" class=\"button\" />";
  227.                     case FRM_MODE_DELETE:
  228.                         return "<img src=\"" OCSP_OBJ::getConf('SYSIMGURL'"icons-22x22/remove.png\" border=\"0\" alt=\"remove\" title=\"".$this->myForm->getLangTxt('DELETE')."\" class=\"button\" />";
  229.                     default:
  230.                         return "<img src=\"" OCSP_OBJ::getConf('SYSIMGURL'"icons-22x22/filesave.png\" border=\"0\" alt=\"save\" title=\"".$this->myForm->getLangTxt('SUBMIT')."\" class=\"button\" />";
  231.                 }
  232.             case "EDIT":
  233.                 return "<img src=\"" OCSP_OBJ::getConf('SYSIMGURL'"icons-22x22/edit.png\" border=\"0\" alt=\"edit\" title=\"".$this->myForm->getLangTxt('EDIT')."\" class=\"button\" />";                                 
  234.             case "DELETE":
  235.                 return "<img src=\"" OCSP_OBJ::getConf('SYSIMGURL'"icons-22x22/emptytrash.png\" border=\"0\" alt=\"save\" title=\"".$this->myForm->getLangTxt('DELETE')."\" class=\"button\" />";                 
  236.             case "RESET":
  237.                 return "<img src=\"" OCSP_OBJ::getConf('SYSIMGURL'"icons-22x22/undo.png\" border=\"0\" alt=\"reset\" title=\"".$this->myForm->getLangTxt('RESET')."\" class=\"button\" />";
  238.             case "RELOAD":
  239.                 return "<img src=\"" OCSP_OBJ::getConf('SYSIMGURL'"icons-16x16/reload.gif\" border=\"0\" alt=\"reload\" title=\"".$this->myForm->getLangTxt('RELOAD')."\" class=\"button\" />";
  240.             default:
  241.                 return $cmd;
  242.         }
  243.  
  244.     }
  245.  
  246.     /**
  247.       * returns the outer-div tag vor buttons
  248.       * @param boolean $debug 
  249.       */
  250.     function getButtonOuterDiv($debug=FALSE)
  251.     {
  252.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_FORM::getButtonOuterDiv()");
  253.         return "<div style=\"display: inline;\"  class=\"frmPanelButton\">";
  254.     }
  255.  
  256.     /**
  257.       * @param OCSP_FORM_BLOCK $aBlock 
  258.       * @param int $aMode 
  259.       * @param boolean $debug 
  260.       *
  261.       * @global array $OCSP_CONF 
  262.       *
  263.       * @return string (html)
  264.       *
  265.       */
  266.     function getTableBlock_Fields(&$aBlock,$debug=FALSE)
  267.     {
  268.         global $OCSP_CONF;
  269.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_FORM::getTableBlock_Fields(\$aBlock[id:".$aBlock->getId()."])");
  270.         $str_ret="";
  271.         $arr_fields=$aBlock->getFields($this->getMyForm()->getFrmMode(),$debug);
  272.         
  273.         if (!pcf_is_instance_of($this->myControl,'OCSP_FRMCONTR'))
  274.         {
  275.             $this->myControl = $this->getMyForm()->getControl();
  276.         }
  277.         
  278.         if (is_array($arr_fields&& sizeof($arr_fields))
  279.         {
  280.             foreach($arr_fields as $int_ordNr => &$obj_field)
  281.             {                
  282.                 $obj_field->setMyForm($this->myForm);
  283.                 $obj_field->setControll($this->myControl);
  284.                 
  285.                 if ($obj_field->isToShow($this->myForm->getFrmMode(),$this->myControl->getCurrentRow()))
  286.                 {
  287.                     if (pcf_is_instance_of($obj_field,'DBMS_FIELD_LAYOUT'&& $obj_field->isLayoutFld()) // <pk-08-03-07 /> isLayoutFld() added 
  288.                     {
  289.                         $str_ret.="\n<tr >";
  290.                         $str_ret.=$obj_field->getFieldRowCols($this->myForm->getFrmMode(),$this->myControl->getCurrentRow(),$debug);
  291.                         $str_ret.="</tr>";
  292.                     else {
  293.                         $str_ret.="\n<tr id=\"tr_".$obj_field->getDOMId()."\" >";
  294.                         if (!$obj_field->labelIsHidden())
  295.                         {
  296.                             $str_ret.="<td id=\"fldName_".$obj_field->getDOMId()."\" class=\"fldName\" ".$this->myControl->getFieldEvents('fldName').">";
  297.                             if ($this->myForm->getFrmMode(!= FRM_MODE_READONLY)
  298.                             {
  299.                                 $str_tip=$obj_field->getToolTip();
  300.                                 if (!empty($str_tip))
  301.                                 {
  302.                                     $str_ret.="<div style=\"float:right\" title=\"".$str_tip."\"><img src=\"".$OCSP_CONF['SYSIMGURL']."icons-16x16/tip.gif\" border=\"0\"></div>";
  303.                                 }
  304.                             }
  305.                             //$str_ret.=$this->myControl->getFieldLabelDiv($obj_field);
  306.                             $str_ret.=$obj_field->getLabel();
  307.                             if ($debug$str_ret.=" ".$obj_field->getTable();
  308.                             $str_ret.="</td>";
  309.                             $int_colspan=1;
  310.                         else {
  311.                             $int_colspan=2;
  312.                         }
  313.  
  314.                         switch($this->myForm->getFrmMode())
  315.                         {
  316.                             case FRM_MODE_READONLY:
  317.                                 $str_class="fldValueRO";
  318.                                 break;
  319.                             default:
  320.                                 $str_class="fldValue";
  321.                         }
  322.  
  323.                         $str_ret.="<td id=\"fldValue_".$obj_field->getDOMId()."\" class=\"$str_class\" colspan=\"$int_colspan\" ".$this->myControl->getFieldEvents('fldValue').">";
  324.                         $str_ret.=$this->myControl->getFieldTag($obj_field,$debug);
  325.                         $str_ret.="<div id=\"error_".$obj_field->getDOMId()."\" class=\"fldErrorMsg\" ".($obj_field->hasErrors("" "style=\"display:none\"").">".$obj_field->getErrorMsg()."</div>";
  326.                         $str_ret.="</td>";
  327.  
  328.                         $str_ret.="</tr>";
  329.                     }
  330.                 else {
  331.                     if ($debug$str_ret.="<tr><td colspan=\"2\">Hidden Field: ".$obj_field->getKey()." (".basename(__FILE__)." Line: ".__LINE__.")</td></tr>";
  332.                 }
  333.             }
  334.         }
  335.         return $str_ret;
  336.     }
  337.  
  338.     /**
  339.       * @param OCSP_FORM_BLOCK $aBlock 
  340.       * @param int $aMode 
  341.       * @param boolean $debug 
  342.       *
  343.       * @global array $OCSP_CONF 
  344.       *
  345.       * @return string (html)
  346.       *
  347.       * @todo OCSP_FRMVIEW_FORM::getFieldSetBlock_Fields() still uses table format
  348.       */
  349.     function getFieldSetBlock_Fields(&$aBlock,$debug=FALSE)
  350.     {
  351.         global $OCSP_CONF;
  352.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_FORM::getTableBlock_Fields(\$aBlock[id:".$aBlock->getId()."])");
  353.  
  354.         return $this->getTableBlock_Fields($aBlock,$debug);
  355.     }
  356.  
  357.  
  358.     /**
  359.      * returns the html code for the form
  360.      * 
  361.      * @param int $aMode 
  362.      * @param boolean $debug 
  363.      * @param boolean $withOuterDiv 
  364.      * @param boolean $withjOCSPInit 
  365.      *
  366.      * @return string (html)
  367.      *
  368.      * @todo OCSP_FRMVIEW_FORM::getForm -> block view tab
  369.      * 
  370.      * @version pk-08-01-29 id added
  371.      * @version pk-08-01-31 jOCSP_getFormInitCmd() added
  372.      * @version pk-08-11-02 $withjOCSPInit
  373.      */
  374.     function getForm($aMode=-1,$debug=False,$withOuterDiv=True,$withjOCSPInit=True)
  375.     {
  376.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_FORM::getForm()");    
  377.         
  378.         // ----------------------------        
  379.         // check settings
  380.         // ----------------------------
  381.         
  382.         if ($aMode > -1
  383.             $this->myForm->setFrmMode($aMode);
  384.             
  385.         if (!pcf_is_instance_of($this->myControl,'OCSP_FRMCONTR')) 
  386.             $this->myControl=$this->myForm->getControllObj('OCSP_FRMCONTR_FORM',$debug);
  387.         
  388.         // ----------------------------
  389.         // form start
  390.         // ----------------------------
  391.             
  392.         $str_ret "";
  393.         
  394.         if ($withjOCSPInit && $str_js $this->myControl->jOCSP_getFormInitCmd())
  395.         {
  396.             if ($obj_ajax $this->myForm->ajax_getObj(FALSE))
  397.             {
  398.                 $obj_ajax->addJsCode($str_js);
  399.             else {
  400.                 $str_ret .= "<script type=\"text/javascript\" language=\"javascript\">\n" $str_js "\n</script>";
  401.             }
  402.         }         
  403.         
  404.         if ($withOuterDiv$str_ret.="<div id=\"frmOuter_"$this->myControl->getFormHTMLId("\" style=\"".$this->outerDivStyle."\">\n";
  405.         
  406.         if ($debug$str_ret .= "<p>Form: " $this->myControl->getFormHTMLId(" (" basename(__FILE__" L: " . __LINE__ .")</p>";
  407.         $str_ret .= "<form name=\"" $this->myControl->getFormHTMLId("\"";
  408.         $str_ret .= " id=\"" $this->myControl->getFormHTMLId("\"" // <pk-08-01-29 />
  409.         $str_ret .= " " $this->myForm->getLayoutField('FRMFRM_FORMADD');
  410.         $str_ret .= " " $this->myControl->getFormEvents($aMode,$debug);
  411.         $str_ret .= ">\n";    
  412.  
  413.         $str_ret .= $this->myControl->getFormCmdFields($debug);
  414.         
  415.         // ----------------------------
  416.         // form blocks
  417.         // ----------------------------        
  418.         
  419.         $str_tabHeader     "";
  420.         $str_tabTabs    "";
  421.      
  422.         $bol_tabOpen        False;
  423.         $bol_tableOpen        False;
  424.         $bol_fieldSetOpen    False;
  425.         
  426.         if ($arr_blocks $this->myForm->getBlocks($debug))
  427.         {
  428.             foreach($arr_blocks as &$obj_block)
  429.             {
  430.                 if ($obj_block->isToShow($this->myForm->getFrmMode(),$debug))
  431.                 {
  432.                     if ($debugechoDebugLine(__FILE__,__LINE__,$obj_block->getTitle(" is to show in " $this->myForm->getFrmMode());
  433.                     switch($obj_block->getViewType())
  434.                     {
  435.                         case __OCSP_FRMBLK_VIEWFIELDSET__:
  436.                             if ($bol_tableOpen)     $str_ret .= "</table>";
  437.                             if ($bol_fieldSetOpen)    $str_ret .= "</fieldset>";                            
  438.                             
  439.                             $str_ret .= "<fieldset " $this->myForm->getLayoutField('FRMFRM_FIELDSETADD'"><legend>".$obj_block->getTitle()."</legend>";
  440.                             $str_ret .= "<table " $this->myForm->getLayoutField('FRMFRM_TABLEADD'">";
  441.  
  442.                             $bol_tableOpen         True;
  443.                             $bol_fieldSetOpen     True;
  444.                             
  445.                             $str_ret .= $this->getTableBlock_Fields($obj_block,$debug);
  446.                             
  447.                             break;
  448.                         case __OCSP_FRMBLK_VIEWTABLE__:
  449.                             if ($bol_tableOpen)     $str_ret .= "</table>";
  450.                             if ($bol_fieldSetOpen)    $str_ret .= "</fieldset>";
  451.                                                                             
  452.                             $str_ret .= "<table " $this->myForm->getLayoutField('FRMFRM_TABLEADD'">";
  453.                             $bol_tableOpen True;            
  454.                             
  455.                             $str_ret .= $this->getTableBlock_Fields($obj_block,$debug);
  456.                             
  457.                             break;
  458.                         case __OCSP_FRMBLK_VIEWINLINE__:
  459.                         default:
  460.                             if (!$bol_tableOpen{
  461.                                 $str_ret .= "<table " $this->myForm->getLayoutField('FRMFRM_TABLEADD'">";
  462.                                 $bol_tableOpen True;
  463.                             }
  464.                             
  465.                             if ($bol_tabOpen)
  466.                             {
  467.                                 $str_tabTabs .= $this->getTableBlock_Fields($obj_block,$debug);
  468.                             else {
  469.                                 $str_ret .= $this->getTableBlock_Fields($obj_block,$debug);    
  470.                             }                            
  471.                     }
  472.                     
  473.                 }
  474.             // foreach($arr_blocks as &$obj_block)
  475.         }
  476.         
  477.         if ($bol_tableOpen)     $str_ret .= "</table>";
  478.         if ($bol_fieldSetOpen)    $str_ret .= "</fieldset>";
  479.         
  480.         if (!empty($str_tabHeader))
  481.         {
  482.             $str_ret .= $str_tabHeader;
  483.             $str_ret .= $str_tabTabs;
  484.         }
  485.         
  486.         // ----------------------------
  487.         // form end
  488.         // ----------------------------
  489.         
  490.         if (!$this->hideFrmBtnPannel)
  491.         {
  492.             $str_btnPannnel=$this->getButtonPannel();
  493.             if (!empty($str_btnPannnel))
  494.             {
  495.                 $str_ret.=$this->getButtonPannel($debug);
  496.             }
  497.         }
  498.         
  499.         if (!empty($str_tabHeader))
  500.         {
  501.             $str_ret .= $str_tabHeader;
  502.             $str_ret .= $str_tabTabs;
  503.         }
  504.         
  505.                 
  506.         $str_ret .= "</form>";
  507.         if ($withOuterDiv$str_ret.="</div>";
  508.             
  509.         return $str_ret;
  510.         
  511.     }
  512.  
  513.  
  514. // end of OCSP_FRMVIEW_FORM
  515. ?>

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