Source for file OCSP_FRMVIEW_FORM_EXTJS.phpclass

Documentation is available at OCSP_FRMVIEW_FORM_EXTJS.phpclass

  1. <?php
  2. /**
  3.   * Class file OCSP_FRMVIEW_FORM_EXTJS.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-08-09-08
  13.   * @version $Id: OCSP_FRMVIEW_FORM_EXTJS.phpclass,v 1.5 2008/09/29 22:34:12 pitlinz Exp $
  14.   * 
  15.   */
  16.  
  17.  
  18.     // ---------------------------------------------------------
  19.     // requirements
  20.     // ---------------------------------------------------------
  21.  
  22.     pcf_require_class('OCSP_FRMVIEW_FORM',dirname(__FILE__)."/");
  23.  
  24. /**
  25.   * class OCSP_FRMVIEW_FORM_EXTJS
  26.   *
  27.   * @project    Open CSP-Management
  28.   * @package    forms
  29.   * @category   dbms_form
  30.   *
  31.   * @author     Peter Krebs (pk) <pitlinz@users.sourceforge.net>
  32.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  33.   *
  34.   * @since  pk-08-09-08
  35.   * @version $Id: OCSP_FRMVIEW_FORM_EXTJS.phpclass,v 1.5 2008/09/29 22:34:12 pitlinz Exp $
  36.   */
  37. {
  38.     // ---------------------------------------------------------------------------
  39.     // constants
  40.     // ---------------------------------------------------------------------------
  41.     
  42.     /**
  43.      * @constant string CLASS_SRC_FILE
  44.      */
  45.     const CLASS_SRC_FILE = __FILE__;
  46.  
  47.     // ---------------------------------------------------------------------------
  48.     // class (static)
  49.     // ---------------------------------------------------------------------------
  50.     
  51.     /*** class vars ------------------------------------------------------ */
  52.     
  53.     /*** class methods --------------------------------------------------- */
  54.     
  55.     // ---------------------------------------------------------------------------
  56.     // object vars
  57.     // ---------------------------------------------------------------------------
  58.     
  59.     /*** aggregations ------------------------------------------------- */
  60.  
  61.     /**
  62.      * the control object
  63.      *
  64.      * @var OCSP_FRMCONTR_FORM_EXTJS $myControl 
  65.      */
  66.     protected $myControl = Null;
  67.     
  68.     /*** compostion --------------------------------------------------- */
  69.     
  70.     
  71.     
  72.     /*** attributes  -------------------------------------------------- */
  73.     
  74.     // ---------------------------------------------------------------------------
  75.     // factory / construct
  76.     // ---------------------------------------------------------------------------
  77.     
  78.     // ---------------------------------------------------------------------------
  79.     // getter / setter
  80.     // ---------------------------------------------------------------------------    
  81.  
  82.     /**
  83.      * returns the field items of a block
  84.      *
  85.      * @param OCSP_FORM_BLOCK $aBlock 
  86.      * @param boolean $debug 
  87.      * 
  88.      * @return string (json)
  89.      */
  90.     public function getBlockFieldItems(&$aBlock,$debug=False)
  91.     {
  92.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_FORM_EXTJS::getBlockFieldItems()");
  93.         
  94.         $str_ret="";
  95.         $arr_fields=$aBlock->getFields($this->myForm->getFrmMode(),$debug);
  96.         if (is_array($arr_fields&& sizeof($arr_fields))
  97.         {
  98.             foreach($arr_fields as $int_ordNr => &$obj_field)
  99.             
  100.                 $mix_value $this->myControl->getFieldValue($obj_field,-1,$debug);
  101.                 
  102.                 if ($obj_field->isToShow($this->myForm->getFrmMode(),$this->myControl->getCurrentRow()))
  103.                 {
  104.                     $str_ret .= "{";
  105.                     $cha_sep '';
  106.                     $arr_fldOptions $obj_field->getExtJSConfigOptions($debug);
  107.                     foreach($arr_fldOptions as $str_name => $str_val)
  108.                     {
  109.                         $str_ret .= $cha_sep $str_name ":" $str_val ",";
  110.                     }   
  111.                     
  112.                     $str_ret .= "value: '" pcf_js_escape($mix_value"'";
  113.                     
  114.                     $str_ret .= "},";
  115.                 }
  116.             }
  117.         }
  118.         return $str_ret;
  119.         
  120.     }
  121.     
  122.     /**
  123.      * returns the json item list of the form
  124.      * 
  125.      * @param boolean $debug 
  126.      * 
  127.      * @return string (json)
  128.      */
  129.     public function getItemBlocks($debug=False)
  130.     {
  131.         if ($debugechoDebugMethod(__FILE__,get_class($this),'OCSP_FRMVIEW_FORM_EXTJS::getItemBlocks()');
  132.         
  133.         $arr_blocks $this->myForm->getBlocks($debug);
  134.         $arr_tabs   array();
  135.                 
  136.         $str_ret "[";
  137.         foreach($arr_blocks as $int_id => &$obj_block)
  138.         {
  139.             if ($obj_block->isToShow($this->myForm->getFrmMode(),$debug))
  140.             {
  141.                 switch($obj_block->getViewType())
  142.                 {
  143.                     case __OCSP_FRMBLK_VIEWTAB__:
  144.                         $arr_tabs[$obj_block;
  145.                         break;
  146.                     //case __OCSP_FRMBLK_VIEWFIELDSET__:
  147.                     //    break;
  148.                     default:
  149.                         $str_ret .= $this->getBlockFieldItems($obj_block,$debug);
  150.                 }
  151.             }
  152.         }        
  153.         
  154.         if (sizeof($arr_tabs)) 
  155.         {
  156.             $str_ret .= "{
  157.                 xtype:'ocspExt_formTabPanel',
  158.                 items: [ 
  159.             ";
  160.             
  161.             $cha_sep "";
  162.             foreach($arr_tabs as $obj_block)
  163.             {
  164.                 $str_ret .= $cha_sep "{
  165.                         title: '" pcf_js_escape($obj_block->getTitle()) "',
  166.                         // as we use deferredRender:false we mustn't
  167.                         // render tabs into display:none containers
  168.                         hideMode: 'offsets',                        
  169.                         items: [ " $this->getBlockFieldItems($obj_block,$debug."] 
  170.                     }";
  171.                 $cha_sep ",";
  172.             }
  173.             
  174.             $str_ret .= "]}";
  175.         }
  176.         
  177.         
  178.         $str_ret .= "]";
  179.         return $str_ret;
  180.     }
  181.     
  182.     public function getButtons($debug)
  183.     {
  184.         switch($this->myForm->getFrmMode())
  185.         {
  186.             case FRM_MODE_NEW:
  187.             case FRM_MODE_COPY:
  188.                 $str_txt t_admin('anlegen');
  189.                 break;
  190.             case FRM_MODE_EDIT:
  191.                 $str_txt t_admin('ändern');
  192.                 break;
  193.             default
  194.                 $str_txt t_admin("speichern");
  195.         }
  196.         $str_ret "{
  197.                 text: '" $str_txt "',
  198.                 //iconCls:'icon-disk',
  199.                 scope: this,
  200.                 handler:function() {
  201.                     obj_comp = Ext.getCmp('" $this->myControl->getFormHTMLId("');
  202.                     if (typeof(obj_comp.frmSubmit) == 'function')
  203.                     {
  204.                         obj_comp.frmSubmit();
  205.                     } else {
  206.                         alert('frm: " .  $this->myControl->getFormHTMLId(.".frmSubmit not found');                    
  207.                         obj_comp.getForm().submit();
  208.                     }
  209.                     
  210.                 }
  211.             }";
  212.         
  213.         if (OCSP_OBJ::currentUser(True)->isAdmin())
  214.         {
  215.             $str_ret .= ",{
  216.                     text: '" t_admin('Formular bearbeiten'"',
  217.                     qtip: 'Formular bearbeiten',
  218.                     //icon: '" OCSP_CONF::getInstance()->getValue('SYSIMGURL'"/icons-22x22/editConstruct.gif',
  219.                     handler: function() {
  220.                             var win = new Ext.Window({
  221.                                 title: '" t_admin('Formular bearbeiten'"',
  222.                                 width: 800,
  223.                                 height: 600,
  224.                                 items: [
  225.                                     {
  226.                                         xtype: 'panel',
  227.                                         layout: 'fit',
  228.                                         autoLoad : '" OCSP_OBJ::getConf('ADMINURL'"dbms/form.php?FRM_ID=" $this->getMyForm()->getId(."'
  229.                                     }                            
  230.                                 ]
  231.                             });
  232.                             win.show();
  233.                         }
  234.                 }";    
  235.         }
  236.  
  237.         return "[" $str_ret "]"
  238.     }
  239.     
  240.     /**
  241.      * returns the html code for the form
  242.      * 
  243.      * @param int $aMode 
  244.      * @param boolean $debug 
  245.      * @param boolean $withOuterDiv not used here
  246.      *
  247.      * @return string (json)
  248.      *
  249.      */
  250.     function getForm($aMode=-1,$debug=False,$withOuterDiv=True)    
  251.     {
  252.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_FORM_EXTJS::getForm()");
  253.         
  254.         $str_ret "{
  255.                 xtype: 'ocspExt_formPanel',
  256.                 id: '" $this->myControl->getFormHTMLId("',
  257.                 defaultType: 'textfield',
  258.                 items: " $this->getItemBlocks($debug",
  259.                 buttons: " $this->getButtons($debug",  
  260.                 ocspParams: {" $this->myControl->getFormAttributes($debug"},            
  261.             }";
  262.         
  263.         return $str_ret;
  264.         
  265.     }
  266. }
  267.  
  268. ?>

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