|
From: Raymond I. <xw...@ya...> - 2003-06-18 13:32:30
|
Many thanks Cristian. Hope you'll be able to rejoin
use in development real soon.
Leif,
You can use this .php file as a start for the perl
version (ioelmsrv.perl.pl)
Glad to see that we're moving ahead with the
client-server communications.
PS. Could be cool if there was also a cold-fusion and
.jsp port :)
Best regards,
--
Raymond Irving
--- Cristian Grigoriu <cri...@pr...>
wrote:
> Raymond Irving wrote:
> > --- Aaron Shafovaloff <aar...@ya...> wrote:
> >
> >>Any idea when SODA will be ported to PHP?
> >
> >
> > Well, I don't know when, but I it's currently been
> > worked on.
> >
> > Any word on the PHP verion of IOelement or SODA?
> >
> > --
> > Raymond Irving
>
> I'm currently involved in a different project which
> is really urgent so
> I have slowed down the porting. I hope to return to
> dynapi & SODA in a
> couple of weeks. Until now, I'd like to hear about
> any new contribution.
>
> Attached you'll find my porting so far.
>
> Grig
> > <?php
>
> /*
> IOElement Server Library - For PHP Servers
> For use with DynAPI IOElement client-side
> javascript
>
> The DynAPI Distribution is distributed under the
> terms of the GNU LGPL license.
>
> Returned Data type: integer, float, string, date,
> array, object (associative array)
> */
>
> $wso_vars = array[]; // stores javascript
> variables to be returned to client
> $wso_endDocWrite = ""; // Prevent ws__docWrite
> from sending data to client
> $wso_IOResponse = ""; // Returned Content Format:
> text/html (default) or text/xml
> $wso_reqMethod = "";
>
> /* Add Variables - javascript variables to be sent
> to client - should only used with html RTC format */
> function wsAddVariable($name, $value){
> if(!$name) return;
> $wso_vars[$name] = $value; // add variable to be
> sent to client
> };
>
> /* Dispatch Variables - should only be used
> text/html RC format when working with SODA */
> function wsDispatchVariables() {
> global $wso_vars, $wso_IOResponse;
> $arr = "";
> foreach ($wso_vars as $varname => $value) $arr .=
> "var $varname=" . ws__Var2Text($value) . ";\n";
> $wso_IOResponse = wsGetRequest("IOResponse");
> ws__docWrite($arr);
> };
>
> /* End Response */
> function wsEndResponse(){
> $wso_endDocWrite = true;
> };
>
> /* Get Request */
> function wsGetRequest($name){
> // Get requested data sent by client via GET or
> POST
> // Note: ASP Request Object returned a very strange
> object type.
> // This is my only workaround
> // PHP: import_request_variables() could be used as
> well
> global $wso_reqMethod;
> $wso_reqMethod =
> strtolower($_SERVER("REQUEST_METHOD"));
> switch ($wso_reqMethod) {
> case "post" : return $_POST($name);
> case "get" : return $_GET($name);
> }
> }
>
> // [Private] Functions
> ----------------------------------------
> /* Doc Write */
> function ws__docWrite($h){
> if ($wso_endDocWrite) return;
> if($wso_IOResponse == "text/xml") $html = $h;
> else{
> $html = '<html><script language="javascript">\nvar
> ioObj,dynapi=parent.dynapi;\n';
> $html .= 'if (dynapi)
> ioObj=parent.IOElement.notify(this);\n';
> $html .= 'else alert(\'Error: Missing or invalid
> DynAPI library\');\n';
> $html .= $h . '\n</script></html>';
> }
> print $html;
> };
>
> // Var2Text
> function ws__Var2Text($v) {
> if (!isset($v)) return "null"; //doesn't make much
> sense. I wonder how is this working in the .js
> version
> if (is_string($v)) return "\'$v\'";
> if (is_array($v)) {
> $arr = "[";
> foreach ($v as $value) $arr .= ws_Var2Text($value)
> . "'";
> return substr($arr, 0, -1) . "]");
> }
> }
>
> // Var2Text Encode - converts multiline text into
> single line
>
> $repltable = array("\\" => "\\\\", "\'" => "\\'",
> "\r\n" => "\\n", "\n" => "\\n", "\r" => "\\r");
>
> function ws__Var2TextEncode($str) {
> global $repltable;
> if (is_null($str)) return;
> foreach ($repltable as $search => $replace) $str =
> str_replace($search, $replace, $str);
> return $str;
> }
>
> ?>
>
__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com
|