Source for file OCSP_FRMCONTR_AJAXFORM.phpclass

Documentation is available at OCSP_FRMCONTR_AJAXFORM.phpclass

  1. <?php
  2. /**
  3.   * Class file OCSP_FRMCONTR_AJAXFORM.phpclass
  4.   *
  5.   *
  6.   * @project    Open CSP-Management
  7.   * @package    forms
  8.   * @category   dbms_form
  9.   *
  10.   * @author     Peter Krebs (pk) <pitlinz@users.sourceforge.net>
  11.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  12.   *
  13.   * @since  pk-07-07-02
  14.   *
  15.   ***/
  16.  
  17. require_once dirname(__FILE__)."/OCSP_FRMCONTR_FORM.phpclass";
  18.  
  19.  
  20. /**
  21.   * class OCSP_FRMCONTR_AJAXFORM
  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-07-02
  31.   *
  32.   */
  33. {
  34.  
  35.     /*** Aggregations: */
  36.  
  37.  
  38.     /*** Compositions: */
  39.  
  40.  
  41.     /*** Attributes: */
  42.  
  43.     /**
  44.       * @protected OCSP_AJAX $myAjaxObj
  45.       */
  46.     protected $myAjaxObj=NULL;
  47.  
  48.  
  49.     /**
  50.       * @protected OCSP_AJAX_FUNCTION $mySubmitFunction
  51.       */
  52.     protected $mySubmitFunction=NULL;
  53.     
  54.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  55.     // init methods
  56.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  57.  
  58.  
  59.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  60.     // getter/setter methods
  61.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  62.  
  63.     /**
  64.       * if $this->myAjaxObj is null it is set to the functions ajax object
  65.       *
  66.       * @param OCSP_AJAX_FUNCTION $aFuncObj 
  67.       * @param string $method (get or post)
  68.       * @param boolean $debug 
  69.       */
  70.     function setMySubmitFunction(&$aFuncObj,$method="",$debug=FALSE)
  71.     {
  72.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMCONTR_AJAXFORM::setMySubmitFunction()");
  73.         
  74.         $this->mySubmitFunction=&$aFuncObj;
  75.         if (!pcf_is_instance_of($this->myAjaxObj,'OCSP_AJAX'))
  76.         {
  77.             $this->myAjaxObj=$this->mySubmitFunction->getAjaxObj();
  78.         }
  79.         if (strtolower($method)=="get")
  80.         {
  81.             $this->myMethod="get";
  82.         else {
  83.             $this->myMethod="post";
  84.         }
  85.     }
  86.       
  87.  
  88.     /**
  89.       * returns the first set value of:
  90.       * - $this->myAction or
  91.       * - $this->mySubmitFunction->getRequestUri() or
  92.       * - $this->myAjaxObj->getActionUri() or
  93.       * - $_SERVER['REQUEST_URI']
  94.       * and sets to $this->myAction
  95.       *
  96.       * @return string 
  97.       */
  98.     function getAction()
  99.     {
  100.         if (!empty($this->myAction)) return $this->myAction;
  101.  
  102.         if (pcf_is_instance_of($this->mySubmitFunction,'OCSP_AJAX_FUNCTION'))
  103.         {
  104.             $this->myAction=$this->mySubmitFunction->getRequestUri();
  105.         }
  106.         if (!empty($this->myAction)) return $this->myAction;
  107.         
  108.         if (pcf_is_instance_of($this->myAjaxObj,'OCSP_AJAX'))
  109.         {
  110.             $this->myAction=$this->myAjaxObj->getActionUri();
  111.         }
  112.         if (!empty($this->myAction)) return $this->myAction;
  113.         
  114.         $this->myAction=$_SERVER['REQUEST_URI'];
  115.         return $this->myAction;
  116.     }
  117.     
  118.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  119.     // form db methods
  120.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  121.  
  122.  
  123.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  124.     // controll elementes
  125.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  126.  
  127.     // form tag <form ...>
  128.  
  129.  
  130.  
  131.     /**
  132.       * @param boolean $debug 
  133.       * @return string 
  134.       * @access public
  135.       */
  136.     function getFormEvents($aMode=FRM_MODE_READONLY,$debug=FALSE)
  137.     {
  138.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMCONTR_AJAXFORM::getFormEvents()");
  139.         $str_ret="";
  140.         
  141.         $this->myMode=$aMode;
  142.         
  143.         if (!empty($this->myMethod))
  144.         {
  145.             $str_ret.=" method=\"".$this->myMethod."\"";
  146.         else {
  147.             $str_ret.=" method=\"post\"";
  148.         }
  149.  
  150.         $str_ret.=" onsubmit=\"return ocspAjax_submitForm(this,'".$this->mySubmitFunction->getFuncName()."');\"";
  151.  
  152.         $str_ret.=" action=\"".$this->getAction()."\"";
  153.         
  154.         return $str_ret;
  155.     }
  156.  
  157.     /**
  158.       * @param boolean $debug 
  159.       * @access public
  160.       */
  161.     function getFormCmdButtons($debug=FALSE)
  162.     {
  163.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMCONTR_FORM::getFormCmdButtons()");
  164.         switch($this->myMode)
  165.         {
  166.             case FRM_MODE_NEW:
  167.             case FRM_MODE_EDIT:
  168.             case FRM_MODE_COPY:
  169.                 if (!isset($this->myCommands['_FORM_']['SAVE']))
  170.                 {
  171.                     $this->myCommands['_FORM_']['SAVE']=array(
  172.                         'TYPE'=>_OCSP_FRMCMDTYPE_BTNJS_,
  173.                         'CODE'=>"ocspAjax_submitForm(document.forms['".$this->getFormHTMLId()."'],'".$this->mySubmitFunction->getFuncName()."');"
  174.                         );
  175.                 }
  176.                 break;
  177.         }
  178.         return parent::getFormCmdButtons($debug);
  179.     }
  180.  
  181.     // footer
  182.  
  183. // end of OCSP_FRMCONTR_FORM
  184. ?>

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