Slightly better multi-dimensional array routine...

This commit is contained in:
Miles Lott 2001-08-26 15:17:24 +00:00
parent 6bb89c4162
commit e89f074cea

View File

@ -120,21 +120,78 @@
return array(0, "Wanted $wanted, got $got at param $pno)"); return array(0, "Wanted $wanted, got $got at param $pno)");
} }
function build_array($res) function reqtoarray($_req,$recursed=False)
{ {
@reset($res); switch(gettype($_req))
while(list($key,$val) = @each($res))
{ {
if(is_array($val)) case 'object':
{ if($recursed)
$ele[$key] = CreateObject('phpgwapi.xmlrpcval',$this->build_array($val),'struct'); {
} return $_req->getval();
else }
{ else
$ele[$key] = CreateObject('phpgwapi.xmlrpcval',$val,'string'); {
} $this->req_array[] = $_req;
}
break;
case 'array':
@reset($_req);
while(list($key,$val) = @each($_req))
{
$this->req_array[$key] = $this->reqtoarray($val,True);
}
break;
case 'string':
case 'int':
if($recursed)
{
return $_req;
}
else
{
$this->req_array[] = $_req;
}
break;
default:
break;
}
}
function build_resp($_res,$recursed=False)
{
switch(gettype($_res))
{
case 'array':
@reset($_res);
while(list($key,$val) = @each($_res))
{
$ele[$key] = $this->build_resp($val,True);
}
$this->resp_struct[] = CreateObject('phpgwapi.xmlrpcval',$ele,'struct');
break;
case 'string':
if($recursed)
{
return CreateObject('phpgwapi.xmlrpcval',$_res,'string');
}
else
{
$this->resp_struct[] = CreateObject('phpgwapi.xmlrpcval',$_res,'string');
}
break;
case 'integer':
if($recursed)
{
return CreateObject('phpgwapi.xmlrpcval',$_res,'int');
}
else
{
$this->resp_struct[] = CreateObject('phpgwapi.xmlrpcval',$_res,'int');
}
break;
default:
break;
} }
return $ele;
} }
function parseRequest($data='') function parseRequest($data='')
@ -241,7 +298,8 @@
$code = '$p = ' . $params . ';'; $code = '$p = ' . $params . ';';
eval($code); eval($code);
$params = $p->getval(); $params = $p->getval();
/* _debug_array($params); */
// _debug_array($params);
if(gettype($params) == 'array') if(gettype($params) == 'array')
{ {
@reset($params); @reset($params);
@ -256,11 +314,11 @@
if(get_class($val1) == 'xmlrpcval') if(get_class($val1) == 'xmlrpcval')
{ {
$tmp[$key1] = $val1->getval(); $tmp[$key1] = $val1->getval();
/* echo '<br>Adding xmlrpc val1: ' . $tmp[$key1] . "\n"; */ // echo '<br>Adding xmlrpc val1: ' . $tmp[$key1] . "\n";
} }
else else
{ {
/* echo '<br>Adding val1: ' . $val1 . "\n"; */ // echo '<br>Adding val1: ' . $val1 . "\n";
$tmp[$key1] = $val1; $tmp[$key1] = $val1;
} }
} }
@ -268,18 +326,24 @@
} }
else else
{ {
/* echo '<br>Adding val: ' . $val . "\n"; */ // echo '<br>Adding val: ' . $val . "\n";
$_params[$key] = $val; $_params[$key] = $val;
} }
} }
$params = $_params; $params = $_params;
} }
/* _debug_array($params); */ //$this->reqtoarray($params);
//_debug_array($this->req_array);
/* $res = ExecMethod($method,$this->req_array); */
$res = ExecMethod($method,$params); $res = ExecMethod($method,$params);
/* _debug_array($res);exit; */ /* _debug_array($res);exit; */
$this->resp_struct = '';
$r = CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$this->build_array($res),'struct')); $this->build_resp($res);
/* _debug_array($r);exit; */ /*_debug_array($this->resp_struct); */
$r = CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval',$this->resp_struct,'struct'));
/* _debug_array($r); */
} }
} }
} }