xajaxCallableObject::generateClientScript PHP Method

generateClientScript() public method

Called by generateClientScript> while is generating the javascript to be sent to the browser. sXajaxPrefix - (string): The prefix to be prepended to the javascript function names.
public generateClientScript ( $sXajaxPrefix )
    public function generateClientScript($sXajaxPrefix)
    {
        $sClass = get_class($this->obj);
        echo "{$sXajaxPrefix}{$sClass} = {};\n";
        foreach (get_class_methods($this->obj) as $sMethodName) {
            $bInclude = true;
            // exclude magic __call, __construct, __destruct methods
            if (2 < strlen($sMethodName)) {
                if ("__" == substr($sMethodName, 0, 2)) {
                    $bInclude = false;
                }
            }
            // exclude constructor
            if ($sClass == $sMethodName) {
                $bInclude = false;
            }
            if ($bInclude) {
                echo "{$sXajaxPrefix}{$sClass}.{$sMethodName} = function() { ";
                echo "return xajax.request( ";
                echo "{ xjxcls: '{$sClass}', xjxmthd: '{$sMethodName}' }, ";
                echo "{ parameters: arguments";
                $sSeparator = ", ";
                if (isset($this->aConfiguration['*'])) {
                    foreach ($this->aConfiguration['*'] as $sKey => $sValue) {
                        echo "{$sSeparator}{$sKey}: {$sValue}";
                    }
                }
                if (isset($this->aConfiguration[strtolower($sMethodName)])) {
                    foreach ($this->aConfiguration[strtolower($sMethodName)] as $sKey => $sValue) {
                        echo "{$sSeparator}{$sKey}: {$sValue}";
                    }
                }
                echo " } ); ";
                echo "};\n";
            }
        }
    }