Source for file OCSP_AJAXFORM.phpclass

Documentation is available at OCSP_AJAXFORM.phpclass

  1. <?php
  2. /**
  3.   * Class file OCSP_AJAXFORM.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    cms
  7.   * @category   chapter
  8.   *
  9.   * @author     Peter Krebs (pk) <pitlinz@sourceforge.net>
  10.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11.   *
  12.   * @since pk-07-02-21
  13.   *
  14.   ***/
  15.  
  16. require_once __OCSP_PHPINCPATH__."common" _OCSP_DIRSEP_ "pcf_directory.phpinc";
  17. require_once dirname(__FILE__)._OCSP_DIRSEP_ "OCSP_AJAX.phpclass";
  18. require_once dirname(__FILE__)._OCSP_DIRSEP_ "OCSP_AJAX_FLDEVENT.phpclass";
  19.  
  20. /**
  21.   * Class OCSP_AJAXFORM
  22.   *
  23.   * this class is designed to handle ajex requests
  24.   *
  25.   * @project    Open CSP-Management
  26.   * @package    cms
  27.   * @category   chapter
  28.   *
  29.   * @author     Peter Krebs (pk) <pitlinz@sourceforge.net>
  30.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  31.   *
  32.   * @since pk-07-02-21
  33.   *
  34.   ***/
  35. class OCSP_AJAXFORM extends OCSP_AJAX {
  36.  
  37.     /**
  38.       * @constant string CLASS_SRC_FILE
  39.       */
  40.     const CLASS_SRC_FILE = __FILE__;      
  41.     
  42.     /** Aggregations: */
  43.  
  44.     /** Compositions: */
  45.  
  46.     /**
  47.       * @var DBMS_FORM $myForm 
  48.       * @access protected
  49.       ***/
  50.     protected $myForm=NULL;
  51.  
  52.  
  53.     /** Attributes: **/
  54.  
  55.     /**
  56.       * @var string $jsAction the action used
  57.       * @access protected
  58.       ***/
  59.     protected $jsAction="/system/forms/ajax_request.php";
  60.  
  61.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  62.     // init methods
  63.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  64.  
  65.     /**
  66.      * casts an ajax form object form an existing ajax object
  67.      * 
  68.      * @param OCSP_AJAX &$aObj 
  69.      * @param boolean $debug 
  70.      * 
  71.      * @return OCSP_AJAXFORM 
  72.      * 
  73.      */
  74.     static function castFromAjaxObj(&$aObj,$debug=FALSE)
  75.     {
  76.         if ($debugechoDebugMethod(__FILE__,'static call',"OCSP_AJAXFORM::castFromAjaxObj()");
  77.         
  78.         if (pcf_is_instance_of($aObj,'OCSP_AJAXFORM'))
  79.         {
  80.             if ($debugechoDebugLine(__FILE__,__LINE__,"object is already a form obj");
  81.             return $aObj;
  82.         }
  83.         
  84.         $obj_ret=new OCSP_AJAXFORM();
  85.         if (pcf_is_instance_of($aObj,'OCSP_AJAX'))
  86.         {
  87.             $obj_ret->set_myObject_vars($aObj->get_myObject_vars())
  88.         }
  89.         
  90.         return $obj_ret;
  91.     }
  92.     
  93.     /**
  94.       * @param string $aUri 
  95.       */
  96.     function setJSaction($aUri)
  97.     {
  98.         $this->jsAction=$aUri;
  99.     }
  100.  
  101.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  102.     // form methods
  103.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  104.  
  105.     /**
  106.       * sets the form
  107.       *
  108.       * @param DBMS_FORM $aFrmObj 
  109.       *
  110.       * @access public
  111.       *
  112.       ***/
  113.     function setFormObject(&$aFrmObj{
  114.         $this->myForm=$aFrmObj;
  115.     }
  116.  
  117.     /**
  118.       * register a field if not already done
  119.       *
  120.       * @param DBMS_FIELD $aFldObj 
  121.       * @param string $aEveMeth the field methode to call on the event
  122.       * @param array $func_args 
  123.       * @param string $rqMethode request methode
  124.       * @param boolean $debug 
  125.       *
  126.       * @returns OCSP_AJAX_FLDEVENT
  127.       *
  128.       * @access public
  129.       *
  130.       ***/
  131.     function &registerFieldEvent(&$aFldObj,$aEveMeth,$func_args=NULL,$rqMethode=AJAX_RQMODE_GET,$debug=FALSE{
  132.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_AJAXFORM::registerFieldEvent() [".$aFld->getKey()."|".get_class($aFld)."]");
  133.         if ((!isset($this->functionLst[$aFldObj->getKey()."_".$aEveMeth])) || (!pcf_is_instance_of($this->functionLst[$aFldObj->getKey()."_".$aEveMeth],'AJAX_FUNCTION'))) {
  134.             $this->functionLst[$aFldObj->getKey()."_".$aEveMeth]=new OCSP_AJAX_FLDEVENT($this,$aFldObj,$aEveMeth,$func_args,$rqMethode);
  135.         }
  136.         return $this->functionLst[$aFldObj->getKey()."_".$aEveMeth];
  137.     }
  138.  
  139.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  140.     // function methods
  141.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  142.  
  143.  
  144.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  145.     // js methods
  146.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  147.  
  148.  
  149.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  150.     // cache methods
  151.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  152.  
  153.     
  154.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  155.     // jOCSP static functions
  156.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  157.     
  158.     /**
  159.      * returns the js command to register an error
  160.      *
  161.      * @param string $str_msg 
  162.      * @param boolean $silient 
  163.      * @param string $str_debugInfo 
  164.      *
  165.      * @return string (js)
  166.      *   
  167.      */
  168.     static function jOCSP_registerError($str_msg,$silient=TRUE,$str_debugInfo=NULL)
  169.     {
  170.         $str_ret  ="jOCSP.addError({";
  171.         $str_ret .= "msg: '" pcf_js_escape($str_msg."'";
  172.         $str_ret .= ",debugInfo: '" pcf_js_escape($str_msg"'";
  173.         $str_ret .= ",reqURI: '" pcf_js_escape($_SERVER['REQUEST_URI']."'"
  174.         $str_ret .="});";
  175.         
  176.         if (!$silent)
  177.         {
  178.             $str_ret .= "alert('Fehler: " pcf_js_escape($str_msg."');";
  179.         }
  180.         
  181.         return $str_ret;
  182.     }
  183.     
  184.     /**
  185.      * returns the js code to open a form in a new layer
  186.      *
  187.      * @param string $str_OuterId 
  188.      * @param OCSP_FRM_VIEW $viewObj 
  189.      * @param int $frmMode 
  190.      * @param boolean $debug 
  191.      * 
  192.      * @return string (js)
  193.      * 
  194.      * @since pk-08-02-11
  195.      */
  196.     static function jOCSP_getFormLayer($str_OuterId,&$viewObj,$frmMode=FRM_MODE_EDIT,$debug=FALSE)
  197.     {
  198.         global $OCSP_CONF;
  199.         
  200.         $str_ret "
  201.             jOCSP.requestScript('" $OCSP_CONF['SYSTEMURL'"jOCSP/jOCSP_dom.js',true);        
  202.             obj_shadowLayer = jOCSP.dom.shadowLayer('" $str_OuterId "',true);
  203.             if (obj_frmLayer = jOCSP.dom.formLayerCreate('" $str_OuterId "'))
  204.             {
  205.                 obj_frmLayer.innerHTML = '" pcf_js_escape($viewObj->getForm($frmMode)) "';
  206.             } else {
  207.                 jOCSP.dom.shadowLayerClear('" $str_OuterId "');
  208.             }                    
  209.             ";
  210.         return $str_ret;
  211.     }
  212.     
  213.     
  214. }

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