author | cavaliet@caf4f556-3d62-0410-8435-a86758001935 |
Fri, 21 Aug 2009 16:26:26 +0000 | |
branch | drupal |
changeset 74 | 0ff3ba646492 |
permissions | -rw-r--r-- |
74
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
1 |
<?php |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
2 |
// $Id: xmlrpc.inc,v 1.47.2.5 2009/01/14 21:36:16 goba Exp $ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
3 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
4 |
/** |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
5 |
* @file |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
6 |
* Drupal XML-RPC library. Based on the IXR - The Incutio XML-RPC Library - (c) Incutio Ltd 2002-2005 |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
7 |
* Version 1.7 (beta) - Simon Willison, 23rd May 2005 |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
8 |
* Site: http://scripts.incutio.com/xmlrpc/ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
9 |
* Manual: http://scripts.incutio.com/xmlrpc/manual.php |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
10 |
* This version is made available under the GNU GPL License |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
11 |
*/ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
12 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
13 |
/** |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
14 |
* Recursively turn a data structure into objects with 'data' and 'type' attributes. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
15 |
* |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
16 |
* @param $data |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
17 |
* The data structure. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
18 |
* @param $type |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
19 |
* Optional type assign to $data. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
20 |
* @return |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
21 |
* Object. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
22 |
*/ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
23 |
function xmlrpc_value($data, $type = FALSE) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
24 |
$xmlrpc_value = new stdClass(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
25 |
$xmlrpc_value->data = $data; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
26 |
if (!$type) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
27 |
$type = xmlrpc_value_calculate_type($xmlrpc_value); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
28 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
29 |
$xmlrpc_value->type = $type; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
30 |
if ($type == 'struct') { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
31 |
// Turn all the values in the array into new xmlrpc_values |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
32 |
foreach ($xmlrpc_value->data as $key => $value) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
33 |
$xmlrpc_value->data[$key] = xmlrpc_value($value); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
34 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
35 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
36 |
if ($type == 'array') { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
37 |
for ($i = 0, $j = count($xmlrpc_value->data); $i < $j; $i++) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
38 |
$xmlrpc_value->data[$i] = xmlrpc_value($xmlrpc_value->data[$i]); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
39 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
40 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
41 |
return $xmlrpc_value; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
42 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
43 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
44 |
/** |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
45 |
* Map PHP type to XML-RPC type. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
46 |
* |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
47 |
* @param $xmlrpc_value |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
48 |
* Variable whose type should be mapped. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
49 |
* @return |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
50 |
* XML-RPC type as string. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
51 |
* @see |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
52 |
* http://www.xmlrpc.com/spec#scalars |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
53 |
*/ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
54 |
function xmlrpc_value_calculate_type(&$xmlrpc_value) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
55 |
// http://www.php.net/gettype: Never use gettype() to test for a certain type [...] Instead, use the is_* functions. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
56 |
if (is_bool($xmlrpc_value->data)) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
57 |
return 'boolean'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
58 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
59 |
if (is_double($xmlrpc_value->data)) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
60 |
return 'double'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
61 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
62 |
if (is_int($xmlrpc_value->data)) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
63 |
return 'int'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
64 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
65 |
if (is_array($xmlrpc_value->data)) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
66 |
// empty or integer-indexed arrays are 'array', string-indexed arrays 'struct' |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
67 |
return empty($xmlrpc_value->data) || range(0, count($xmlrpc_value->data) - 1) === array_keys($xmlrpc_value->data) ? 'array' : 'struct'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
68 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
69 |
if (is_object($xmlrpc_value->data)) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
70 |
if ($xmlrpc_value->data->is_date) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
71 |
return 'date'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
72 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
73 |
if ($xmlrpc_value->data->is_base64) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
74 |
return 'base64'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
75 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
76 |
$xmlrpc_value->data = get_object_vars($xmlrpc_value->data); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
77 |
return 'struct'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
78 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
79 |
// default |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
80 |
return 'string'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
81 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
82 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
83 |
/** |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
84 |
* Generate XML representing the given value. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
85 |
* |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
86 |
* @param $xmlrpc_value |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
87 |
* @return |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
88 |
* XML representation of value. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
89 |
*/ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
90 |
function xmlrpc_value_get_xml($xmlrpc_value) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
91 |
switch ($xmlrpc_value->type) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
92 |
case 'boolean': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
93 |
return '<boolean>'. (($xmlrpc_value->data) ? '1' : '0') .'</boolean>'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
94 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
95 |
case 'int': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
96 |
return '<int>'. $xmlrpc_value->data .'</int>'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
97 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
98 |
case 'double': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
99 |
return '<double>'. $xmlrpc_value->data .'</double>'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
100 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
101 |
case 'string': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
102 |
// Note: we don't escape apostrophes because of the many blogging clients |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
103 |
// that don't support numerical entities (and XML in general) properly. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
104 |
return '<string>'. htmlspecialchars($xmlrpc_value->data) .'</string>'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
105 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
106 |
case 'array': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
107 |
$return = '<array><data>'."\n"; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
108 |
foreach ($xmlrpc_value->data as $item) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
109 |
$return .= ' <value>'. xmlrpc_value_get_xml($item) ."</value>\n"; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
110 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
111 |
$return .= '</data></array>'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
112 |
return $return; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
113 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
114 |
case 'struct': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
115 |
$return = '<struct>'."\n"; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
116 |
foreach ($xmlrpc_value->data as $name => $value) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
117 |
$return .= " <member><name>". check_plain($name) ."</name><value>"; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
118 |
$return .= xmlrpc_value_get_xml($value) ."</value></member>\n"; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
119 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
120 |
$return .= '</struct>'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
121 |
return $return; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
122 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
123 |
case 'date': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
124 |
return xmlrpc_date_get_xml($xmlrpc_value->data); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
125 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
126 |
case 'base64': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
127 |
return xmlrpc_base64_get_xml($xmlrpc_value->data); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
128 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
129 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
130 |
return FALSE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
131 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
132 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
133 |
/** |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
134 |
* Construct an object representing an XML-RPC message. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
135 |
* |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
136 |
* @param $message |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
137 |
* String containing XML as defined at http://www.xmlrpc.com/spec |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
138 |
* @return |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
139 |
* Object |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
140 |
*/ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
141 |
function xmlrpc_message($message) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
142 |
$xmlrpc_message = new stdClass(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
143 |
$xmlrpc_message->array_structs = array(); // The stack used to keep track of the current array/struct |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
144 |
$xmlrpc_message->array_structs_types = array(); // The stack used to keep track of if things are structs or array |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
145 |
$xmlrpc_message->current_struct_name = array(); // A stack as well |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
146 |
$xmlrpc_message->message = $message; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
147 |
return $xmlrpc_message; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
148 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
149 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
150 |
/** |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
151 |
* Parse an XML-RPC message. If parsing fails, the faultCode and faultString |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
152 |
* will be added to the message object. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
153 |
* |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
154 |
* @param $xmlrpc_message |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
155 |
* Object generated by xmlrpc_message() |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
156 |
* @return |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
157 |
* TRUE if parsing succeeded; FALSE otherwise |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
158 |
*/ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
159 |
function xmlrpc_message_parse(&$xmlrpc_message) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
160 |
// First remove the XML declaration |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
161 |
$xmlrpc_message->message = preg_replace('/<\?xml(.*)?\?'.'>/', '', $xmlrpc_message->message); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
162 |
if (trim($xmlrpc_message->message) == '') { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
163 |
return FALSE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
164 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
165 |
$xmlrpc_message->_parser = xml_parser_create(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
166 |
// Set XML parser to take the case of tags into account. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
167 |
xml_parser_set_option($xmlrpc_message->_parser, XML_OPTION_CASE_FOLDING, FALSE); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
168 |
// Set XML parser callback functions |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
169 |
xml_set_element_handler($xmlrpc_message->_parser, 'xmlrpc_message_tag_open', 'xmlrpc_message_tag_close'); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
170 |
xml_set_character_data_handler($xmlrpc_message->_parser, 'xmlrpc_message_cdata'); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
171 |
xmlrpc_message_set($xmlrpc_message); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
172 |
if (!xml_parse($xmlrpc_message->_parser, $xmlrpc_message->message)) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
173 |
return FALSE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
174 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
175 |
xml_parser_free($xmlrpc_message->_parser); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
176 |
// Grab the error messages, if any |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
177 |
$xmlrpc_message = xmlrpc_message_get(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
178 |
if ($xmlrpc_message->messagetype == 'fault') { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
179 |
$xmlrpc_message->fault_code = $xmlrpc_message->params[0]['faultCode']; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
180 |
$xmlrpc_message->fault_string = $xmlrpc_message->params[0]['faultString']; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
181 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
182 |
return TRUE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
183 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
184 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
185 |
/** |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
186 |
* Store a copy of the $xmlrpc_message object temporarily. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
187 |
* |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
188 |
* @param $value |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
189 |
* Object |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
190 |
* @return |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
191 |
* The most recently stored $xmlrpc_message |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
192 |
*/ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
193 |
function xmlrpc_message_set($value = NULL) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
194 |
static $xmlrpc_message; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
195 |
if ($value) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
196 |
$xmlrpc_message = $value; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
197 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
198 |
return $xmlrpc_message; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
199 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
200 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
201 |
function xmlrpc_message_get() { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
202 |
return xmlrpc_message_set(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
203 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
204 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
205 |
function xmlrpc_message_tag_open($parser, $tag, $attr) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
206 |
$xmlrpc_message = xmlrpc_message_get(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
207 |
$xmlrpc_message->current_tag_contents = ''; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
208 |
$xmlrpc_message->last_open = $tag; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
209 |
switch ($tag) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
210 |
case 'methodCall': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
211 |
case 'methodResponse': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
212 |
case 'fault': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
213 |
$xmlrpc_message->messagetype = $tag; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
214 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
215 |
// Deal with stacks of arrays and structs |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
216 |
case 'data': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
217 |
$xmlrpc_message->array_structs_types[] = 'array'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
218 |
$xmlrpc_message->array_structs[] = array(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
219 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
220 |
case 'struct': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
221 |
$xmlrpc_message->array_structs_types[] = 'struct'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
222 |
$xmlrpc_message->array_structs[] = array(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
223 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
224 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
225 |
xmlrpc_message_set($xmlrpc_message); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
226 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
227 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
228 |
function xmlrpc_message_cdata($parser, $cdata) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
229 |
$xmlrpc_message = xmlrpc_message_get(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
230 |
$xmlrpc_message->current_tag_contents .= $cdata; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
231 |
xmlrpc_message_set($xmlrpc_message); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
232 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
233 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
234 |
function xmlrpc_message_tag_close($parser, $tag) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
235 |
$xmlrpc_message = xmlrpc_message_get(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
236 |
$value_flag = FALSE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
237 |
switch ($tag) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
238 |
case 'int': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
239 |
case 'i4': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
240 |
$value = (int)trim($xmlrpc_message->current_tag_contents); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
241 |
$value_flag = TRUE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
242 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
243 |
case 'double': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
244 |
$value = (double)trim($xmlrpc_message->current_tag_contents); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
245 |
$value_flag = TRUE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
246 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
247 |
case 'string': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
248 |
$value = $xmlrpc_message->current_tag_contents; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
249 |
$value_flag = TRUE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
250 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
251 |
case 'dateTime.iso8601': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
252 |
$value = xmlrpc_date(trim($xmlrpc_message->current_tag_contents)); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
253 |
// $value = $iso->getTimestamp(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
254 |
$value_flag = TRUE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
255 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
256 |
case 'value': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
257 |
// If no type is indicated, the type is string |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
258 |
// We take special care for empty values |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
259 |
if (trim($xmlrpc_message->current_tag_contents) != '' || (isset($xmlrpc_message->last_open) && ($xmlrpc_message->last_open == 'value'))) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
260 |
$value = (string)$xmlrpc_message->current_tag_contents; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
261 |
$value_flag = TRUE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
262 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
263 |
unset($xmlrpc_message->last_open); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
264 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
265 |
case 'boolean': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
266 |
$value = (boolean)trim($xmlrpc_message->current_tag_contents); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
267 |
$value_flag = TRUE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
268 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
269 |
case 'base64': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
270 |
$value = base64_decode(trim($xmlrpc_message->current_tag_contents)); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
271 |
$value_flag = TRUE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
272 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
273 |
// Deal with stacks of arrays and structs |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
274 |
case 'data': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
275 |
case 'struct': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
276 |
$value = array_pop($xmlrpc_message->array_structs ); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
277 |
array_pop($xmlrpc_message->array_structs_types); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
278 |
$value_flag = TRUE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
279 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
280 |
case 'member': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
281 |
array_pop($xmlrpc_message->current_struct_name); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
282 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
283 |
case 'name': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
284 |
$xmlrpc_message->current_struct_name[] = trim($xmlrpc_message->current_tag_contents); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
285 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
286 |
case 'methodName': |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
287 |
$xmlrpc_message->methodname = trim($xmlrpc_message->current_tag_contents); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
288 |
break; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
289 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
290 |
if ($value_flag) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
291 |
if (count($xmlrpc_message->array_structs ) > 0) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
292 |
// Add value to struct or array |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
293 |
if ($xmlrpc_message->array_structs_types[count($xmlrpc_message->array_structs_types)-1] == 'struct') { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
294 |
// Add to struct |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
295 |
$xmlrpc_message->array_structs [count($xmlrpc_message->array_structs )-1][$xmlrpc_message->current_struct_name[count($xmlrpc_message->current_struct_name)-1]] = $value; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
296 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
297 |
else { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
298 |
// Add to array |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
299 |
$xmlrpc_message->array_structs [count($xmlrpc_message->array_structs )-1][] = $value; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
300 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
301 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
302 |
else { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
303 |
// Just add as a parameter |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
304 |
$xmlrpc_message->params[] = $value; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
305 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
306 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
307 |
if (!in_array($tag, array("data", "struct", "member"))) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
308 |
$xmlrpc_message->current_tag_contents = ''; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
309 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
310 |
xmlrpc_message_set($xmlrpc_message); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
311 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
312 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
313 |
/** |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
314 |
* Construct an object representing an XML-RPC request |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
315 |
* |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
316 |
* @param $method |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
317 |
* The name of the method to be called |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
318 |
* @param $args |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
319 |
* An array of parameters to send with the method. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
320 |
* @return |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
321 |
* Object |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
322 |
*/ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
323 |
function xmlrpc_request($method, $args) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
324 |
$xmlrpc_request = new stdClass(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
325 |
$xmlrpc_request->method = $method; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
326 |
$xmlrpc_request->args = $args; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
327 |
$xmlrpc_request->xml = <<<EOD |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
328 |
<?xml version="1.0"?> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
329 |
<methodCall> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
330 |
<methodName>{$xmlrpc_request->method}</methodName> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
331 |
<params> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
332 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
333 |
EOD; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
334 |
foreach ($xmlrpc_request->args as $arg) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
335 |
$xmlrpc_request->xml .= '<param><value>'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
336 |
$v = xmlrpc_value($arg); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
337 |
$xmlrpc_request->xml .= xmlrpc_value_get_xml($v); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
338 |
$xmlrpc_request->xml .= "</value></param>\n"; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
339 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
340 |
$xmlrpc_request->xml .= '</params></methodCall>'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
341 |
return $xmlrpc_request; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
342 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
343 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
344 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
345 |
function xmlrpc_error($code = NULL, $message = NULL, $reset = FALSE) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
346 |
static $xmlrpc_error; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
347 |
if (isset($code)) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
348 |
$xmlrpc_error = new stdClass(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
349 |
$xmlrpc_error->is_error = TRUE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
350 |
$xmlrpc_error->code = $code; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
351 |
$xmlrpc_error->message = $message; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
352 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
353 |
elseif ($reset) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
354 |
$xmlrpc_error = NULL; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
355 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
356 |
return $xmlrpc_error; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
357 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
358 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
359 |
function xmlrpc_error_get_xml($xmlrpc_error) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
360 |
return <<<EOD |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
361 |
<methodResponse> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
362 |
<fault> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
363 |
<value> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
364 |
<struct> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
365 |
<member> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
366 |
<name>faultCode</name> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
367 |
<value><int>{$xmlrpc_error->code}</int></value> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
368 |
</member> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
369 |
<member> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
370 |
<name>faultString</name> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
371 |
<value><string>{$xmlrpc_error->message}</string></value> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
372 |
</member> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
373 |
</struct> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
374 |
</value> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
375 |
</fault> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
376 |
</methodResponse> |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
377 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
378 |
EOD; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
379 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
380 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
381 |
function xmlrpc_date($time) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
382 |
$xmlrpc_date = new stdClass(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
383 |
$xmlrpc_date->is_date = TRUE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
384 |
// $time can be a PHP timestamp or an ISO one |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
385 |
if (is_numeric($time)) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
386 |
$xmlrpc_date->year = gmdate('Y', $time); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
387 |
$xmlrpc_date->month = gmdate('m', $time); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
388 |
$xmlrpc_date->day = gmdate('d', $time); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
389 |
$xmlrpc_date->hour = gmdate('H', $time); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
390 |
$xmlrpc_date->minute = gmdate('i', $time); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
391 |
$xmlrpc_date->second = gmdate('s', $time); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
392 |
$xmlrpc_date->iso8601 = gmdate('Ymd\TH:i:s', $time); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
393 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
394 |
else { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
395 |
$xmlrpc_date->iso8601 = $time; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
396 |
$time = str_replace(array('-', ':'), '', $time); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
397 |
$xmlrpc_date->year = substr($time, 0, 4); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
398 |
$xmlrpc_date->month = substr($time, 4, 2); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
399 |
$xmlrpc_date->day = substr($time, 6, 2); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
400 |
$xmlrpc_date->hour = substr($time, 9, 2); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
401 |
$xmlrpc_date->minute = substr($time, 11, 2); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
402 |
$xmlrpc_date->second = substr($time, 13, 2); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
403 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
404 |
return $xmlrpc_date; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
405 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
406 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
407 |
function xmlrpc_date_get_xml($xmlrpc_date) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
408 |
return '<dateTime.iso8601>'. $xmlrpc_date->year . $xmlrpc_date->month . $xmlrpc_date->day .'T'. $xmlrpc_date->hour .':'. $xmlrpc_date->minute .':'. $xmlrpc_date->second .'</dateTime.iso8601>'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
409 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
410 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
411 |
function xmlrpc_base64($data) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
412 |
$xmlrpc_base64 = new stdClass(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
413 |
$xmlrpc_base64->is_base64 = TRUE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
414 |
$xmlrpc_base64->data = $data; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
415 |
return $xmlrpc_base64; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
416 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
417 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
418 |
function xmlrpc_base64_get_xml($xmlrpc_base64) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
419 |
return '<base64>'. base64_encode($xmlrpc_base64->data) .'</base64>'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
420 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
421 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
422 |
/** |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
423 |
* Execute an XML remote procedural call. This is private function; call xmlrpc() |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
424 |
* in common.inc instead of this function. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
425 |
* |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
426 |
* @return |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
427 |
* A $xmlrpc_message object if the call succeeded; FALSE if the call failed |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
428 |
*/ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
429 |
function _xmlrpc() { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
430 |
$args = func_get_args(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
431 |
$url = array_shift($args); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
432 |
xmlrpc_clear_error(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
433 |
if (is_array($args[0])) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
434 |
$method = 'system.multicall'; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
435 |
$multicall_args = array(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
436 |
foreach ($args[0] as $call) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
437 |
$multicall_args[] = array('methodName' => array_shift($call), 'params' => $call); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
438 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
439 |
$args = array($multicall_args); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
440 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
441 |
else { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
442 |
$method = array_shift($args); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
443 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
444 |
$xmlrpc_request = xmlrpc_request($method, $args); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
445 |
$result = drupal_http_request($url, array("Content-Type" => "text/xml"), 'POST', $xmlrpc_request->xml); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
446 |
if ($result->code != 200) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
447 |
xmlrpc_error($result->code, $result->error); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
448 |
return FALSE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
449 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
450 |
$message = xmlrpc_message($result->data); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
451 |
// Now parse what we've got back |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
452 |
if (!xmlrpc_message_parse($message)) { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
453 |
// XML error |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
454 |
xmlrpc_error(-32700, t('Parse error. Not well formed')); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
455 |
return FALSE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
456 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
457 |
// Is the message a fault? |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
458 |
if ($message->messagetype == 'fault') { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
459 |
xmlrpc_error($message->fault_code, $message->fault_string); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
460 |
return FALSE; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
461 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
462 |
// Message must be OK |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
463 |
return $message->params[0]; |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
464 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
465 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
466 |
/** |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
467 |
* Returns the last XML-RPC client error number |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
468 |
*/ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
469 |
function xmlrpc_errno() { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
470 |
$error = xmlrpc_error(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
471 |
return ($error != NULL ? $error->code : NULL); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
472 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
473 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
474 |
/** |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
475 |
* Returns the last XML-RPC client error message |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
476 |
*/ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
477 |
function xmlrpc_error_msg() { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
478 |
$error = xmlrpc_error(); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
479 |
return ($error != NULL ? $error->message : NULL); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
480 |
} |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
481 |
|
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
482 |
/** |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
483 |
* Clears any previous error. |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
484 |
*/ |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
485 |
function xmlrpc_clear_error() { |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
486 |
xmlrpc_error(NULL, NULL, TRUE); |
0ff3ba646492
Create branch for drupal with first commit from local working copy
cavaliet@caf4f556-3d62-0410-8435-a86758001935
parents:
diff
changeset
|
487 |
} |