1: <?php
2:
3: /**
4: * An array containing other XMLRPCParameter objects.
5: *
6: * @package Elgg.Core
7: * @subpackage XMLRPC
8: *
9: */
10: class XMLRPCArrayParameter extends XMLRPCParameter
11: {
12: /**
13: * Construct an array.
14: *
15: * @param array $parameters Optional array of parameters, if not provided
16: * then addField must be used.
17: */
18: function __construct($parameters = NULL) {
19: parent::__construct();
20:
21: if (is_array($parameters)) {
22: foreach ($parameters as $v) {
23: $this->addField($v);
24: }
25: }
26: }
27:
28: /**
29: * Add a field to the container.
30: *
31: * @param XMLRPCParameter $value The value.
32: *
33: * @return void
34: */
35: public function addField(XMLRPCParameter $value) {
36: if (!is_array($this->value)) {
37: $this->value = array();
38: }
39:
40: $this->value[] = $value;
41: }
42:
43: /**
44: * Converts XML array to string
45: *
46: * @return string
47: */
48: function __toString() {
49: $params = "";
50: foreach ($this->value as $value) {
51: $params .= "$value";
52: }
53:
54: return "<array><data>$params</data></array>";
55: }
56: }
57: