Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: Unknown

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5

File/phpxmlrpc/xmlrpc.php

Description
Includes
 include (is_a.php) (line 64)
 include (version_compare.php) (line 61)
 include (array_key_exists.php) (line 60)
 include (var_export.php) (line 63)
 include (is_scalar.php) (line 59)
Constants
PHP_XMLRPC_COMPAT_DIR = dirname(__FILE__).'/compat/' (line 55)
XMLRPC_EPI_ENABLED = '1' (line 2994)
Functions
decode_chunked (line 3106)

decode a string that is encoded w/ "chunked" transfer encoding as defined in rfc2068 par. 19.4.6 code shamelessly stolen from nusoap library by Dietrich Ayala

string decode_chunked (string $buffer)
  • string $buffer: the string to be decoded
guess_encoding (line 3609)

xml charset encoding guessing helper function.

Tries to determine the charset encoding of an XML chunk received over HTTP. NB: according to the spec (RFC 3023, if text/xml content-type is received over HTTP without a content-type, we SHOULD assume it is strictly US-ASCII. But we try to be more tolerant of unconforming (legacy?) clients/servers, which will be most probably using UTF-8 anyway...

  • todo: explore usage of mb_http_input(): does it detect http headers + post data? if so, use it instead of hand-detection!!!
void guess_encoding ([ $httpheader = ''], [string $xmlchunk = ''], [string $encoding_prefs = null], string $httpheaders)
  • string $httpheaders: the http Content-type header
  • string $xmlchunk: xml content buffer
  • string $encoding_prefs: comma separated list of character encodings to be used as default (when mb extension is enabled)
  • $httpheader
iso8601_decode (line 2913)
void iso8601_decode ( $idate, [ $utc = 0])
  • $idate
  • $utc
iso8601_encode (line 2881)
void iso8601_encode ( $timet, [ $utc = 0])
  • $timet
  • $utc
is_valid_charset (line 3700)

Checks if a given charset encoding is present in a list of encodings or

if it is a valid subset of any encoding in the list

void is_valid_charset (string $encoding, mixed $validlist)
  • string $encoding: charset to be tested
  • mixed $validlist: comma separated list of valid charsets (or array of charsets)
php_2_xmlrpc_type (line 3162)

Given a string defining a php type or phpxmlrpc type (loosely defined: strings accepted come from javadoc blocks), return corresponding phpxmlrpc type.

NB: for php 'resource' types returns empty string, since resources cannot be serialized; for php class names returns 'struct', since php objects can be serialized as xmlrpc structs

string php_2_xmlrpc_type (string $phptype)
  • string $phptype
php_xmlrpc_decode (line 2942)

Takes an xmlrpc value in PHP xmlrpcval object format and translates it into native PHP types.

Works with xmlrpc message objects as input, too.

mixed php_xmlrpc_decode (xmlrpcval $xmlrpc_val, [array $options = array()])
  • xmlrpcval $xmlrpc_val
  • array $options: if 'decode_php_objs' is set in the options array, xmlrpc structs can be decoded into php objects
php_xmlrpc_encode (line 3013)

Takes native php types and encodes them into xmlrpc PHP object format.

It will not re-encode xmlrpcval objects. Feature creep -- could support more types via optional type argument (string => datetime support has been added, ??? => base64 not yet)

xmlrpcval &php_xmlrpc_encode (mixed $php_val, [array $options = array()])
  • mixed $php_val: the value to be converted into an xmlrpcval object
  • array $options: can include 'encode_php_objs' and 'auto_dates'
wrap_php_function (line 3239)

Given a user-defined PHP function, create a PHP 'wrapper' function that can be exposed as xmlrpc method from an xmlrpc_server object and called from remote clients.

Since php is a typeless language, to infer types of input and output parameters, it relies on parsing the javadoc-style comment block associated with the given function. Usage of xmlrpc native types (such as datetime.dateTime.iso8601 and base64) in the @param tag is also allowed, if you need the php function to receive/send data in that particular format (note that base64 enncoding/decoding is transparently carried out by the lib, while datetime vals are passed around as strings)

Known limitations:

  • requires PHP 5.0.3 +
  • only works for user-defined functions, not for PHP internal functions (reflection does not support retrieving number/type of params for those)
  • functions returning php objects will generate special xmlrpc responses: when the xmlrpc decoding of those responses is carried out by this same lib, using the appropriate param in php_xmlrpc_decode, the php objects will be rebuilt. In short: php objects can be serialized, too (except for their resource members), using this function. Other libs might choke on the very same xml that will be generated in this case (i.e. it has a nonstandard attribute on struct element tags)
  • usage of javadoc @param tags using param names in a different order from the function prototype is not considered valid (to be fixed?)
Note that since rel. 2.0RC3 the preferred method to have the server call 'standard' php functions (ie. functions not expecting a single xmlrpcmsg obj as parameter) is by making use of the functions_parameters_type class member.

  • return: on error, or an array containing the name of the new php function, its signature and docs, to be used in the server dispatch map
  • todo: decide how to deal with params passed by ref: bomb out or allow?
  • todo: finish using javadoc info to build method sig if all params are named but out of order
  • todo: add a check for params of 'resource' type
  • todo: add some trigger_errors when returning false?
  • todo: what to do when the PHP function returns NULL? we are currently returning bogus responses!!!
false wrap_php_function (string $funcname, [ $newfuncname = ''])
  • string $funcname: the name of the PHP user function to be exposed as xmlrpc method; array($obj, 'methodname') might be ok too, in the future...
  • $newfuncname
wrap_xmlrpc_method (line 3481)

Given an xmlrpc client and a method name, register a php wrapper function

that will call it and return results using native php types for both params and results. The generated php function will return an xmlrpcresp oject for failed xmlrpc calls

Known limitations:

  • server must support system.methodsignature for the wanted xmlrpc method
  • for methods that expose many signatures, only one can be picked (we could in priciple check if signatures differ only by number of params and not by type, but it would be more complication than we can spare time)
  • nested xmlrpc params: the caller of the generated php function has to encode on its own the params passed to the php function if these are structs or arrays whose (sub)members include values of type datetime or base64
Notes: the connection properties of the given client will be copied and reused for the connection used during the call to the generated php function. Calling the generated php function 'might' be slow: a new xmlrpc client is created on every invocation and an xmlrpc-connection opened+closed. An extra 'debug' param is appended to param list of xmlrpc method, useful for debugging purposes.

  • return: the name of the generated php function (or false)
string wrap_xmlrpc_method (xmlrpc_client $client, string $methodname, [integer $signum = 0], [ $timeout = 0], [ $protocol = ''], [ $newfuncname = ''])
  • xmlrpc_client $client: an xmlrpc client set up correctly to communicate with target server
  • string $methodname: the xmlrpc method to be mapped to a php function
  • integer $signum: the index of the method signature to use in mapping (if method exposes many sigs)
  • $timeout
  • $protocol
  • $newfuncname
xmlrpc_cd (line 676)
void xmlrpc_cd ( $parser,  $data)
  • $parser
  • $data
xmlrpc_dh (line 703)
void xmlrpc_dh ( $parser,  $data)
  • $parser
  • $data
xmlrpc_ee (line 478)
void xmlrpc_ee ( $parser,  $name, [ $rebuild_xmlrpcvals = true])
  • $parser
  • $name
  • $rebuild_xmlrpcvals
xmlrpc_ee_fast (line 671)
void xmlrpc_ee_fast ( $parser,  $name)
  • $parser
  • $name
xmlrpc_encode_entitites (line 260)

Convert a string to the correct XML representation in a target charset

To help correct communication of non-ascii chars inside strings, regardless of the charset used when sending requests, parsing them, sending responses and parsing responses, an option is to convert all non-ascii chars present in the message into their equivalent 'charset entity'. Charset entities enumerated this way are independent of the charset encoding used to transmit them, and all XML parsers are bound to understand them. Note that in the std case we are not sending a charset encoding mime type along with http headers, so we are bound by RFC 3023 to emit strict us-ascii.

  • todo: do a bit of basic benchmarking (strtr vs. str_replace)
  • todo: make usage of iconv() or recode_string() or mb_string() where available
void xmlrpc_encode_entitites ( $data, [ $src_encoding = ''], [ $dest_encoding = ''])
  • $data
  • $src_encoding
  • $dest_encoding
xmlrpc_se (line 373)
void xmlrpc_se ( $parser,  $name,  $attrs)
  • $parser
  • $name
  • $attrs

Documentation generated on Mon, 05 Mar 2007 21:31:51 +0000 by phpDocumentor 1.3.1