Source for file OCSP_AJAX_FUNCTION.phpclass

Documentation is available at OCSP_AJAX_FUNCTION.phpclass

  1. <?php
  2. /**
  3.   * Class file OCSP_AJAX_FUNCTION.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    cms
  7.   * @category   chapter
  8.   *
  9.   * @author     Peter Krebs (pk) <p.krebs@amicas.at>
  10.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11.   *
  12.   * @since pk-07-02-21
  13.   *
  14.   ***/
  15.  
  16. /**
  17.   * requirements ---------------------------------------------------------
  18.   */
  19. require_once __OCSP_PHPINCPATH__."common/pcf_directory.phpinc";
  20. require_once dirname(__FILE__)._OCSP_DIRSEP_."OCSP_AJAX.phpclass";
  21.  
  22. /**
  23.   * Class OCSP_AJAX_FUNCTION
  24.   *
  25.   * this class is designed to handle ajex functions
  26.   *
  27.   * @project    Open CSP-Management
  28.   * @package    cms
  29.   * @category   chapter
  30.   *
  31.   * @author     Peter Krebs (pk) <p.krebs@amicas.at>
  32.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  33.   *
  34.   * @since pk-07-02-21
  35.   *
  36.   ***/
  37.  
  38.     /** Aggregations: */
  39.  
  40.     /**
  41.       * @var OCSP_AJAX myAjaxObj
  42.       * @access protected
  43.       ***/
  44.     protected $myAjaxObj=NULL;
  45.  
  46.     /** Compositions: */
  47.  
  48.     /** Attributes: **/
  49.  
  50.     /**
  51.       * @var string $myFuncName 
  52.       * @access protected
  53.       */
  54.     protected $myFuncName=NULL;
  55.  
  56.     /**
  57.       * @var string $myFuncInc 
  58.       * @access protected
  59.       */
  60.     protected $myFuncInc=NULL;
  61.  
  62.     /**
  63.       * @var string $myRQMethod 
  64.       * @access protected
  65.       */
  66.     protected $myRQMethod=NULL;
  67.  
  68.     /**
  69.       * @var array $myFuncArgs 
  70.       * @access protected
  71.       */
  72.     protected $myFuncArgs=array();
  73.  
  74.     /**
  75.       * @var string $myFuncInc 
  76.       * @access protected
  77.       */
  78.     protected $myTargetId=NULL;
  79.  
  80.     /**
  81.       * @var string $myRQUri 
  82.       * @access protected
  83.       */
  84.     protected $myRQUri=NULL;
  85.  
  86.     /**
  87.       * @var string $myCacheValues 
  88.       * @access protected
  89.       */
  90.     protected $myCacheValues=array();
  91.  
  92.     /**
  93.       * @var string $mySourceFile 
  94.       * @access private
  95.       */
  96.     private $mySourceFile=__FILE__;
  97.  
  98.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  99.     // init methods
  100.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  101.     /**
  102.       * cunstruct
  103.       *
  104.       * @param AJAX $ajaxObj 
  105.       * @param string $funcName 
  106.       * @param string $funcInc the include file containing the php function
  107.       * @param array $funcArgs (array with NAME => VALUE paires for arguments)
  108.       * @param string $rqMethode the methode of the ajax request
  109.       *
  110.       * @access public
  111.       *
  112.       ***/
  113.     function OCSP_AJAX_FUNCTION(&$ajaxObj,$funcName,$funcInc="",$funcArgs=NULL,$rqMethode=OCSP_AJAX_RQMODE_GET{
  114.         $this->myAjaxObj    =$ajaxObj;
  115.         $this->setFuncName(trim($funcName));
  116.         $this->myFuncInc    =$funcInc;
  117.         $this->myFuncArgs   =$funcArgs;
  118.         $this->myRQMethod   =$rqMethode;
  119.     }
  120.  
  121.     /**
  122.       * @returns string
  123.       * @access public
  124.       ***/
  125.     function getFuncName({
  126.         return $this->myFuncName;
  127.     }
  128.  
  129.     /**
  130.       * @param string $funcName 
  131.       * @access public
  132.       ***/
  133.     function setFuncName($funcName{
  134.         $this->myFuncName=$funcName;
  135.     }
  136.  
  137.     /**
  138.       * @returns string
  139.       * @access public
  140.       ***/
  141.     function getTargetId({
  142.         return $this->myTargetId;
  143.     }
  144.  
  145.     /**
  146.       * @param string $targetId 
  147.       * @access public
  148.       ***/
  149.     function setTargetId($targetId{
  150.         $this->myTargetId=$targetId;
  151.     }
  152.  
  153.     /**
  154.       * @param string $aUri 
  155.       * @access public
  156.       ***/
  157.     function setRequestUri($aUri{
  158.         $this->myRQUri=$aUri;
  159.     }
  160.  
  161.     /**
  162.       * @return string 
  163.       */
  164.     function getRequestUri()
  165.     {
  166.         if (!empty($this->myRQUri))
  167.         {
  168.             return $this->myRQUri;
  169.         else {
  170.             $this->myAjaxObj->getActionUri();
  171.         }
  172.     }
  173.  
  174.     /**
  175.       * @return string 
  176.       * @access public
  177.       */
  178.     function getClassSrc({
  179.         return $this->mySourceFile;
  180.     }
  181.  
  182.     /**
  183.       * @return OCSP_AJAX 
  184.       */
  185.     function &getAjaxObj()
  186.     {
  187.         return $this->myAjaxObj;
  188.     }
  189.  
  190.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  191.     // function methods
  192.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  193.  
  194.  
  195.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  196.     // js methods
  197.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  198.  
  199.     /**
  200.       * returns the javascript function name
  201.       *
  202.       * @returns string
  203.       *
  204.       * @access public
  205.       *
  206.       ***/
  207.     function js_getFuncName({
  208.         return "oax_".preg_replace("/[^a-zA-Z0-9]/","_",$this->getFuncName());
  209.     }
  210.  
  211.     /**
  212.       * returns the javascript code to register the function
  213.       *
  214.       * @returns string
  215.       *
  216.       * @access public
  217.       *
  218.       ***/
  219.     function js_getRegisterFunction({
  220.         $s_ret ="var cur_oaxFunc=ocspAjax_register_function(";
  221.         $s_ret.="'".$this->myAjaxObj->get_objId()."',";
  222.         $s_ret.="'".$this->getFuncName()."',";
  223.         $s_ret.="'".$this->getTargetId()."',";
  224.         $s_ret.="'".$this->myAjaxObj->getActionUri()."'";
  225.         $s_ret.=");\n";
  226.  
  227.         if (is_array($this->myFuncArgs)) {
  228.             foreach($this->myFuncArgs as $s_key => $s_val{
  229.                 $s_ret.="\tcur_oaxFunc.setFuncArg('".$s_key."','".$s_val."');\n";
  230.             }
  231.         }
  232.  
  233.         if (!empty($this->myRQUri)) {
  234.             $s_ret.="cur_oaxFunc.setRequestUri('".$this->myRQUri."');\n";
  235.         }
  236.  
  237.         return $s_ret;
  238.     }
  239.  
  240.     /**
  241.       * returns the javascript representation of the function
  242.       *
  243.       * @param boolean $debug 
  244.       *
  245.       * @returns string
  246.       *
  247.       * @access public
  248.       *
  249.       ***/
  250.     function js_getFunction($debug=FALSE)
  251.     {
  252.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_AJAX_FUNCTION::js_getFunction()");
  253.  
  254.         $s_ret ="\n/** wrapper for ".$this->getFuncName()." Class: ".get_class($this)." **/\n";
  255.         $s_ret.=$this->js_getRegisterFunction();
  256.         $s_ret.="\tfunction ".$this->js_getFuncName()."(args) {ocspAjax_do_call('".$this->getFuncName()."', args);}\n\n";
  257.         return $s_ret;
  258.     }
  259.  
  260.     /**
  261.       * returns the js ajax call
  262.       *
  263.       * @param array $args 
  264.       * @param boolean $debug 
  265.       *
  266.       * @return string 
  267.       *
  268.       * @since pk-07-04-28
  269.       *
  270.       * @access public
  271.       */
  272.     function js_getAjaxCall($args=NULL,$debug=FALSE)
  273.     {
  274.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_AJAX_FUNCTION::js_getAjaxCall()",print_r($args,TRUE));
  275.  
  276.  
  277.         if (is_array($args&& sizeof($args))
  278.         {
  279.             $str_jsArg ="new Array(";
  280.             foreach($args as $str_key => $str_value)
  281.             {
  282.                 $str_jsArg.="new ocspAjax_funcArg('".$str_key."','".$str_value."'),";
  283.             }
  284.             $str_jsArg=substr($str_jsArg,0,-1).")";
  285.         else {
  286.             $str_jsArg="";
  287.         }
  288.  
  289.         return $this->js_getFuncName()."(".$str_jsArg.");";
  290.     }
  291.  
  292.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  293.     // cache methods
  294.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  295.  
  296.     /**
  297.       * returns the values to add to the cache
  298.       *
  299.       * @param boolean $debug 
  300.       *
  301.       * @returns array
  302.       *
  303.       * @access public
  304.       ***/
  305.     function getMyCacheValues({
  306.         return $this->myCacheValues;
  307.     }
  308. }

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