| 52 |  |  | 
| 53 | $querytxt = $params->getParam(0); | $querytxt = $params->getParam(0); | 
| 54 | $nqlquery = $querytxt->getval(); | $nqlquery = $querytxt->getval(); | 
| 55 | nfo_debug_clean(); | #nfo_debug_clean(); | 
| 56 | #nfo_debug_write($params); | #nfo_debug_write($params); | 
| 57 | #nfo_debug_write($nqlquery); | #nfo_debug_write($nqlquery); | 
| 58 | $result = array(); | $result = array(); | 
| 59 | cms_query($nqlquery,&$result); | cms_query($nqlquery,&$result); | 
| 60 | nfo_debug_write($result); | #nfo_debug_write($result); | 
| 61 |  |  | 
| 62 | $structinfo = array(); | $structinfo = array(); | 
| 63 | $structcontent = array(); | $structcontent = array(); | 
| 64 | $structfields = array(); | $structfields = array(); | 
| 65 |  |  | 
| 66 | foreach ($result[0] as $key => $value) { | foreach ($result[0] as $key => $value) { | 
| 67 | $structinfo[$key] = new XML_RPC_Value($value,"string"); | $datall = array(); | 
| 68 |  | if ($key == 'all'){ | 
| 69 |  | #nfo_debug_write($value); | 
| 70 |  | foreach ($result[0][$key] as $keyall => $valall) { | 
| 71 |  | $datall2 = array(); | 
| 72 |  | if ($keyall == 'fieldlist'){ | 
| 73 |  | foreach ($result[0][$key][$keyall] as $fieldkey => $fieldval) | 
| 74 |  | { | 
| 75 |  | $datall2[$fieldkey] = new XML_RPC_Value($fieldval,"string"); | 
| 76 |  | } | 
| 77 |  | $datall[$keyall] = new XML_RPC_Value($datall2,"struct"); | 
| 78 |  | }elseif($keyall == 'with'){ | 
| 79 |  | //nothing yet | 
| 80 |  | }else{ | 
| 81 |  | $datall[$keyall] = new XML_RPC_Value($valall,"string"); | 
| 82 |  | } | 
| 83 | } | } | 
| 84 |  |  | 
| 85 | #foreach ($result[1] as $key => $value)  { | $structinfo[$key] = new XML_RPC_Value($datall,"struct"); | 
| 86 | #$structcontent[$key] = new XML_RPC_Value($value,"struct"); |  | 
| 87 | # } | }else{ | 
| 88 |  | $structinfo[$key] = new XML_RPC_Value($value,"string"); | 
| 89 |  | } | 
| 90 |  | } | 
| 91 |  |  | 
| 92 | foreach ($result[1] as $key => $value)  { | foreach ($result[1] as $key => $value)  { | 
| 93 | $cdata = array(); | $cdata = array(); | 
| 94 | foreach($value as $item => $data) { | foreach($value as $item => $data) { | 
| 95 | $cdata[$item] = new XML_RPC_Value($data,"string"); | $data = utf8_encode($data); | 
| 96 |  | $cdata[$item] = new XML_RPC_Value($data,"string"); | 
| 97 | } | } | 
| 98 | $structcontent[$key] = new XML_RPC_Value($cdata,"struct"); | $structcontent[$key] = new XML_RPC_Value($cdata,"struct"); | 
| 99 | } | } | 
| 100 |  |  | 
| 101 | foreach ($result[2] as $key => $value) { | foreach ($result[2] as $key => $value) { | 
| 102 | $structfields[$key] = new XML_RPC_Value($value,"string"); | $structfields[$key] = new XML_RPC_Value($value,"string"); | 
| 103 | } | } | 
| 104 |  |  | 
| 105 | $struct = array(); | $struct = array(); | 
| 106 | $struct[0] = new XML_RPC_Value($structinfo,"struct"); | $struct[0] = new XML_RPC_Value($structinfo,"struct"); | 
| 107 | $struct[1] = new XML_RPC_Value($structcontent,"struct"); | $struct[1] = new XML_RPC_Value($structcontent,"struct"); | 
| 108 | $struct[2] = new XML_RPC_Value($structfields,"struct"); | $struct[2] = new XML_RPC_Value($structfields,"struct"); | 
| 109 |  |  | 
| 110 | $xmldoc = new XML_RPC_Response(new XML_RPC_Value($struct, "struct")); | $xmldoc = new XML_RPC_Response(new XML_RPC_Value($struct, "struct")); | 
| 111 | nfo_debug_write($xmldoc); | #nfo_debug_write($xmldoc); | 
| 112 | #nfo_debug_write($xmldoc->serialize()); | #nfo_debug_write($xmldoc->serialize()); | 
| 113 |  |  | 
| 114 | return $xmldoc; | return $xmldoc; |