}
/**
- * @internal this function will become protected in the future
+ * Gets/sets the xml-rpc method to be invoked.
*
- * @param string $charsetEncoding
- * @return string
+ * @param string $methodName the method to be set (leave empty not to set it)
+ * @return string the method that will be invoked
*/
- public function xml_header($charsetEncoding = '')
+ public function method($methodName = '')
{
- if ($charsetEncoding != '') {
- return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?" . ">\n<methodCall>\n";
- } else {
- return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n";
+ if ($methodName != '') {
+ $this->methodname = $methodName;
}
+
+ return $this->methodname;
}
/**
- * @internal this function will become protected in the future
+ * Add a parameter to the list of parameters to be used upon method invocation.
+ * Checks that $params is actually a Value object and not a plain php value.
*
- * @return string
+ * @param Value $param
+ * @return boolean false on failure
*/
- public function xml_footer()
+ public function addParam($param)
{
- return '</methodCall>';
+ // check: do not add to self params which are not xml-rpc values
+ if (is_object($param) && is_a($param, 'PhpXmlRpc\Value')) {
+ $this->params[] = $param;
+
+ return true;
+ } else {
+ $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': value passed in must be a PhpXmlRpc\Value');
+ return false;
+ }
}
/**
- * @internal this function will become protected in the future (and be folded into serialize)
+ * Returns the nth parameter in the request. The index zero-based.
*
- * @param string $charsetEncoding
- * @return void
+ * @param integer $i the index of the parameter to fetch (zero based)
+ * @return Value the i-th parameter
*/
- public function createPayload($charsetEncoding = '')
+ public function getParam($i)
{
- $this->logDeprecationUnlessCalledBy('serialize');
-
- if ($charsetEncoding != '') {
- $this->content_type = 'text/xml; charset=' . $charsetEncoding;
- } else {
- $this->content_type = 'text/xml';
- }
-
- $this->payload = $this->xml_header($charsetEncoding);
- $this->payload .= '<methodName>' . $this->getCharsetEncoder()->encodeEntities(
- $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</methodName>\n";
- $this->payload .= "<params>\n";
- foreach ($this->params as $p) {
- $this->payload .= "<param>\n" . $p->serialize($charsetEncoding) .
- "</param>\n";
- }
- $this->payload .= "</params>\n";
- $this->payload .= $this->xml_footer();
+ return $this->params[$i];
}
/**
- * Gets/sets the xml-rpc method to be invoked.
+ * Returns the number of parameters in the message.
*
- * @param string $methodName the method to be set (leave empty not to set it)
- * @return string the method that will be invoked
+ * @return integer the number of parameters currently set
*/
- public function method($methodName = '')
+ public function getNumParams()
{
- if ($methodName != '') {
- $this->methodname = $methodName;
- }
-
- return $this->methodname;
+ return count($this->params);
}
/**
- * Returns xml representation of the message. XML prologue included.
+ * Returns xml representation of the message, XML prologue included. Sets `payload` and `content_type` properties
*
* @param string $charsetEncoding
* @return string the xml representation of the message, xml prologue included
}
/**
- * Add a parameter to the list of parameters to be used upon method invocation.
- * Checks that $params is actually a Value object and not a plain php value.
+ * @internal this function will become protected in the future (and be folded into serialize)
*
- * @param Value $param
- * @return boolean false on failure
+ * @param string $charsetEncoding
+ * @return void
*/
- public function addParam($param)
+ public function createPayload($charsetEncoding = '')
{
- // check: do not add to self params which are not xml-rpc values
- if (is_object($param) && is_a($param, 'PhpXmlRpc\Value')) {
- $this->params[] = $param;
+ $this->logDeprecationUnlessCalledBy('serialize');
- return true;
+ if ($charsetEncoding != '') {
+ $this->content_type = 'text/xml; charset=' . $charsetEncoding;
} else {
- $this->getLogger()->error('XML-RPC: ' . __METHOD__ . ': value passed in must be a PhpXmlRpc\Value');
- return false;
+ $this->content_type = 'text/xml';
+ }
+
+ $result = $this->xml_header($charsetEncoding);
+ $result .= '<methodName>' . $this->getCharsetEncoder()->encodeEntities(
+ $this->methodname, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</methodName>\n";
+ $result .= "<params>\n";
+ foreach ($this->params as $p) {
+ $result .= "<param>\n" . $p->serialize($charsetEncoding) .
+ "</param>\n";
}
+ $result .= "</params>\n";
+ $result .= $this->xml_footer();
+
+ $this->payload = $result;
}
/**
- * Returns the nth parameter in the request. The index zero-based.
+ * @internal this function will become protected in the future (and be folded into serialize)
*
- * @param integer $i the index of the parameter to fetch (zero based)
- * @return Value the i-th parameter
+ * @param string $charsetEncoding
+ * @return string
*/
- public function getParam($i)
+ public function xml_header($charsetEncoding = '')
{
- return $this->params[$i];
+ $this->logDeprecationUnlessCalledBy('createPayload');
+
+ if ($charsetEncoding != '') {
+ return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\" ?" . ">\n<methodCall>\n";
+ } else {
+ return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n";
+ }
}
/**
- * Returns the number of parameters in the message.
+ * @internal this function will become protected in the future (and be folded into serialize)
*
- * @return integer the number of parameters currently set
+ * @return string
*/
- public function getNumParams()
+ public function xml_footer()
{
- return count($this->params);
+ $this->logDeprecationUnlessCalledBy('createPayload');
+
+ return '</methodCall>';
}
/**
/// @todo what if there is no end tag?
$end = strpos($data, '-->', $start);
$comments = substr($data, $start, $end - $start);
- $this->getLogger()->debug("---SERVER DEBUG INFO (DECODED) ---\n\t" .
+ $this->getLogger()->debug("---SERVER DEBUG INFO (DECODED)---\n\t" .
str_replace("\n", "\n\t", base64_decode($comments)) . "\n---END---", array('encoding' => $respEncoding));
}
}
static::$_xmlrpcs_occurred_errors . "+++END+++");
}
- $payload = $this->xml_header($respCharset);
+ $payload = $resp->xml_header($respCharset);
if ($this->debug > 0) {
$payload = $payload . $this->serializeDebug($respCharset);
}
if (!isset($dmap[$methodName]['function'])) {
// No such method
- return new Response(0,
- PhpXmlRpc::$xmlrpcerr['unknown_method'],
- PhpXmlRpc::$xmlrpcstr['unknown_method']);
+ return new Response(0, PhpXmlRpc::$xmlrpcerr['unknown_method'], PhpXmlRpc::$xmlrpcstr['unknown_method']);
}
// Check signature
$this->debug_info .= $string . "\n";
}
- /**
- * @param string $charsetEncoding
- * @return string
- */
- protected function xml_header($charsetEncoding = '')
- {
- if ($charsetEncoding != '') {
- return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?" . ">\n";
- } else {
- return "<?xml version=\"1.0\"?" . ">\n";
- }
- }
-
/**
* @param string $methName
* @return bool
return (strpos($methName, "system.") === 0);
}
-
/**
* @param array $dmap
* @return $this
public static function _xmlrpcs_multicall($server, $req)
{
$result = array();
- // let accept a plain list of php parameters, beside a single xml-rpc msg object
+ // let's accept a plain list of php parameters, beside a single xml-rpc msg object
if (is_object($req)) {
$calls = $req->getParam(0);
foreach ($calls as $call) {
}
}
}
+
+ // *** BC layer ***
+
+ /**
+ * @param string $charsetEncoding
+ * @return string
+ *
+ * @deprecated this method was moved to the Response class
+ */
+ protected function xml_header($charsetEncoding = '')
+ {
+ $this->logDeprecation('Method ' . __METHOD__ . ' is deprecated');
+
+ if ($charsetEncoding != '') {
+ return "<?xml version=\"1.0\" encoding=\"$charsetEncoding\"?" . ">\n";
+ } else {
+ return "<?xml version=\"1.0\"?" . ">\n";
+ }
+ }
}
}
}
+
+ /**
+ * Returns the value of a scalar xml-rpc value (base 64 decoding is automatically handled here)
+ *
+ * @return mixed
+ */
+ public function scalarVal()
+ {
+ $b = reset($this->me);
+
+ return $b;
+ }
+
+ /**
+ * Returns the type of the xml-rpc value.
+ *
+ * @return string For integers, 'int' is always returned in place of 'i4'. 'i8' is considered a separate type and
+ * returned as such
+ */
+ public function scalarTyp()
+ {
+ reset($this->me);
+ $a = key($this->me);
+ if ($a == static::$xmlrpcI4) {
+ $a = static::$xmlrpcInt;
+ }
+
+ return $a;
+ }
+
+ /**
+ * Returns the xml representation of the value. XML prologue not included.
+ *
+ * @param string $charsetEncoding the charset to be used for serialization. If null, US-ASCII is assumed
+ * @return string
+ */
+ public function serialize($charsetEncoding = '')
+ {
+ $val = reset($this->me);
+ $typ = key($this->me);
+
+ return '<value>' . $this->serializeData($typ, $val, $charsetEncoding) . "</value>\n";
+ }
+
/**
* @param string $typ
* @param Value[]|mixed $val
return $rs;
}
- /**
- * Returns the xml representation of the value. XML prologue not included.
- *
- * @param string $charsetEncoding the charset to be used for serialization. If null, US-ASCII is assumed
- * @return string
- */
- public function serialize($charsetEncoding = '')
- {
- $val = reset($this->me);
- $typ = key($this->me);
-
- return '<value>' . $this->serializeData($typ, $val, $charsetEncoding) . "</value>\n";
- }
-
- /**
- * Returns the value of a scalar xml-rpc value (base 64 decoding is automatically handled here)
- *
- * @return mixed
- */
- public function scalarVal()
- {
- $b = reset($this->me);
-
- return $b;
- }
-
- /**
- * Returns the type of the xml-rpc value.
- *
- * @return string For integers, 'int' is always returned in place of 'i4'. 'i8' is considered a separate type and
- * returned as such
- */
- public function scalarTyp()
- {
- reset($this->me);
- $a = key($this->me);
- if ($a == static::$xmlrpcI4) {
- $a = static::$xmlrpcInt;
- }
-
- return $a;
- }
-
/**
* Returns the number of members in an xml-rpc value:
* - 0 for uninitialized values