Openbiz 2.0 > Openbiz / Bin / ClientProxy.php

Questions? Need Help? Want to share? » PHP Forum
Script Name:
Openbiz 2.0

Download:
openbiz-2.0.zip

Category:
Development Tools

Archive Content:

Openbiz > Bin

Openbiz > Bin > Service

Openbiz > Bin

Openbiz

Openbiz > Document

Openbiz > Document > Apidoc20 > BizController

Openbiz > Document > Apidoc20 > BizDataObj

Openbiz > Document > Apidoc20 > BizSystem

Openbiz > Document > Apidoc20 > BizView

Openbiz > Document > Apidoc20

Openbiz > Document > Apidoc20 > Media

Openbiz > Document > Apidoc20 > Media > Images

Openbiz > Document > Apidoc20 > Media > Lib

Openbiz > Document > Apidoc20 > Media

Openbiz > Document > Apidoc20

Openbiz > Document > Apidoc20 > PluginService

Openbiz > Document

Openbiz

Openbiz > Metadata

Openbiz > Metadata > Service

Openbiz > Others > Adodb

Openbiz > Others > Adodb > Contrib

Openbiz > Others > Adodb > Cute Icons For Site

Openbiz > Others > Adodb > Datadict

Openbiz > Others > Adodb > Docs

Openbiz > Others > Adodb > Drivers

Openbiz > Others > Adodb > Lang

Openbiz > Others > Adodb

Openbiz > Others > Adodb > Pear > Auth > Container

Openbiz > Others > Adodb > Pear

Openbiz > Others > Adodb > Perf

Openbiz > Others > Adodb

Openbiz > Others > Adodb > Session

Openbiz > Others > Adodb > Session > Old

Openbiz > Others > Adodb > Session

Openbiz > Others > Adodb > Tests

Openbiz > Others > Adodb

Openbiz > Others > Adodb > Xsl

Openbiz > Others > Dompdf

Openbiz > Others > Dompdf > Include

Openbiz > Others > Dompdf

Openbiz > Others > Dompdf > Lib

Openbiz > Others > Dompdf > Lib > Fonts

Openbiz > Others > Dompdf > Lib > Res

Openbiz > Others > Dompdf > Lib

Openbiz > Others > Dompdf

Openbiz > Others > Dompdf > Www

Openbiz > Others > Dompdf > Www > Images

Openbiz > Others > Dompdf > Www

Openbiz > Others > Dompdf > Www > Test

Openbiz > Others > Dompdf > Www

Openbiz > Others > Smarty

Openbiz > Others > Smarty > Demo > Configs

Openbiz > Others > Smarty > Demo

Openbiz > Others > Smarty > Demo > Templates

Openbiz > Others > Smarty

Openbiz > Others > Smarty > Libs

Openbiz > Others > Smarty > Libs > Internals

Openbiz > Others > Smarty > Libs > Plugins

Openbiz > Others > Smarty > Libs

Openbiz > Others > Smarty > Misc

Openbiz > Others > Smarty

Openbiz > Others > Smarty > Unit Test

Openbiz > Others > Smarty > Unit Test > Configs

Openbiz > Others > Smarty > Unit Test

Openbiz > Others > Smarty > Unit Test > Templates

Openbiz > Others > Smarty > Unit Test

Demoapp > Bin

Demoapp > Bin > Service

Demoapp > Bin > Shared

Demoapp

Demoapp > Css

Demoapp

Demoapp > Images

Demoapp > Metadata

Demoapp > Metadata > Demo

Demoapp > Metadata > Service

Demoapp > Metadata > Shared

Demoapp

Demoapp > Templates

ClientProxy.php:


<?PHP

/**
 * ClientProxy class - a class that is treated as the bi-direction proxy of client. Through this class,  
 * others can get client form inputs,  redraw client form or call client javascript functions.
 * 
 * @package BizSystem
 * @author rocky swen 
 * @copyright Copyright (c) 2005
 * @access public 
 */
class ClientProxy
{
   protected 
$m_RequestArgs;
   protected 
$m_FormInputArray;
   protected 
$m_bRPCFlag false;
   
   public function 
SetRPCFlag($flag)
   {
      
$this->m_bRPCFlag $flag;
   }
   
   
/**
    * ClientProxy::GetRequestParam() - get the client form data passed by GET or POST
    * 
    * @param string $name
    * @return string
    */
   
public function GetRequestParam($name)
   {
      
$val = (isset($_REQUEST[$name]) ? $_REQUEST[$name] : "");
      return 
$val;
   }
   
   
/**
    * ClientProxy::SetFormInputData() - called by BizController to parse and save the client form data
    * 
    * @param string $formdata
    * @return void
    */
   
public function SetFormInputData($formdata)
   {
      
$input_array explode("^-^-^",  $formdata);
      foreach(
$input_array as $kvpair) {
         
$pos strpos($kvpair,  "=");
         
$field substr($kvpair,  0,  $pos);
         
$value substr($kvpair,  $pos+1,  strlen($kvpair)-$pos);
         if (
$field) {
            
$value str_replace("%2B", "+", $value);
            
$value str_replace("\\'", "'", $value);
            
$this->m_FormInputArray[$field] = $value;
         }
      }
   }
   
   
/**
    * ClientProxy::GetFormInputs() - get form all inputs or one input if ctrlName is given
    * 
    * @param string $ctrlName
    * @return array or string
    */
   
public function GetFormInputs($ctrlName=null)
   {
      if (
$ctrlName)
         return 
$this->m_FormInputArray[$ctrlName];
      else 
         return 
$this->m_FormInputArray;
   }
   
   
/**
    * ClientProxy::UpdateFormElements() - update the form controls on the client UI
    * 
    * @param string $formName - name of the html form on client
    * @param array $recArr - name/value pairs
    * @return array or string
    */
   
public function UpdateFormElements($formName,  &$recArr)
   {
      
$rtString "UPD_FLDS";
      foreach(
$recArr as $fld=>$val
         
$rtString .= "[".$fld."]=<".$val.">";
      return 
$this->_buildTgtCtnt($formName,  $rtString); 
   }
   
/**
    * ClientProxy::ReDrawForm() - replace the form content with the provided html text
    * 
    * @param string $formName - name of the html form on client
    * @param string $sHTML - html text to redraw the form
    * @return string - encoded html string returns to browser,  it'll be processed by client javascript.
    */
   
public function ReDrawForm($formName,  &$sHTML)
   {
      if (
$this->m_bRPCFlag)
         return 
$this->_buildTgtCtnt($formName,  $sHTML); 
   }
   
/**
    * ClientProxy::ShowClientAlert() - popup an alert window on the browser
    * 
    * @param string $alertText
    * @return string - encoded html string returns to browser,  it'll be processed by client javascript.
    */
   
public function ShowClientAlert($alertText)
   {
      
$msg str_replace("'",  "\'",  $alertText);
      if (
$this->m_bRPCFlag)
         return 
$this->CallClientFunction("alert('$msg')");
   }
   
   public function 
ShowErrorMessage($errMsg)
   {
      
$msg str_replace("'",  "\'",  $errMsg);
      if (
$this->m_bRPCFlag)
         return 
$this->CallClientFunction("alert('$msg')");
      else {
         echo 
"Error message: <font color=maroon>$errMsg</font>";
         
//BizSystem::ErrorBacktrace();
      
}
   }
   
   public function 
ShowErrorPopup($errMsg)
   {
      
$msg str_replace("\\",  "\\\\",  $errMsg);
      
$msg str_replace("'",  "\'",  $msg);
      
      if (
$this->m_bRPCFlag)
         return 
$this->CallClientFunction("popupErrorText('$msg')");
      else {
         echo 
$errMsg;
         
//BizSystem::ErrorBacktrace();
      
}
   }
   
   public function 
ClosePopup()
   {
      if (
$this->m_bRPCFlag)
         return 
$this->CallClientFunction("close()");
   }
   
   protected function 
CallClientFunction($funcStr)
   {
      if (
$this->m_bRPCFlag)
         return 
$this->_buildTgtCtnt("FUNCTION",  $funcStr); 
   }
   
   
/**
    * BuildTgtCtnt()
    * build target-content string with target str and content string as inputs. After RPC call,  this function is usually called to
    * set the HTML text to an UI element.
    * 
    * @param string $tgt the HTML element id,  i.e. the applet HTML id
    * @param string $ctnt the HTML text to be set as the content of the HTML element referred with the id
    * @return string
    **/
   
private function _buildTgtCtnt($tgt,  &$ctnt)
   {
      
$tmpStr "### TARGET:".strlen($tgt).":".$tgt.";";
      
$tmpStr .= "CONTENT:".strlen($ctnt).":".$ctnt;

      return 
$tmpStr;
   }
   
   
/**
    * ClientProxy::RedirectPage() - redirect page to the given url
    * 
    * @param string $pageURL
    * @return string - encoded html string returns to browser,  it'll be processed by client javascript.
    */
   
public function RedirectPage($pageURL)
   {
      return 
$this->CallClientFunction("RedirectPage('$pageURL')"); 
   }
   
/**
    * ClientProxy::RedirectView() - redirect page to the given view
    * 
    * @param string $view
    * @return string - encoded html string returns to browser,  it'll be processed by client javascript.
    */
   
public function RedirectView($view)
   {
      return 
$this->CallClientFunction("GoToView('$view', '')"); 
   }
}

?>


Other Development Tools Scripts:

WebMaster Resources Home

©RingsWorld.com