Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
|
Public Member Functions | |
__construct (array $options=array()) | |
parse ($data, $returnType=self::RETURN_XMLRPCVALS, $accept=3, $options=array()) | |
Parses an xml-rpc xml string. | |
xmlrpc_cd ($parser, $data) | |
xml parser handler function for character data. | |
xmlrpc_dh ($parser, $data) | |
xml parser handler function for 'other stuff', i.e. | |
xmlrpc_ee ($parser, $name, $rebuildXmlrpcvals=1) | |
xml parser handler function for close element tags. | |
xmlrpc_ee_epi ($parser, $name) | |
Used in decoding xml-rpc requests/responses while building xmlrpc-extension Values (plain php for all but base64 and datetime). | |
xmlrpc_ee_fast ($parser, $name) | |
Used in decoding xml-rpc requests/responses without rebuilding xml-rpc Values. | |
xmlrpc_se ($parser, $name, $attrs, $acceptSingleVals=false) | |
xml parser handler function for opening element tags. | |
Static Public Member Functions | |
static | guessEncoding ($httpHeader='', $xmlChunk='', $encodingPrefs=null) |
xml charset encoding guessing helper function. | |
Protected Attributes | |
array | $_xh |
Used to store state during parsing and to pass parsing results to callers. | |
array | $current_parsing_options |
Used keys: accept, target_charset, methodname_callback, plus the ones set here. | |
int int | $maxChunkLength = 4194304 |
$accept self\ACCEPT_REQUEST | self\ACCEPT_RESPONSE by default | |
int | $maxLogValueLength = 100 |
The max length beyond which data will get truncated in error messages. | |
array | $parsing_options = array() |
$parsing_options | |
array[] | $xmlrpc_valid_parents |
PhpXmlRpc\Helper\XMLParser::__construct | ( | array | $options = array() | ) |
array | $options | integer keys: options passed to the inner xml parser string keys:
|
|
static |
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 non-conforming (legacy?) clients/servers, which will be most probably using UTF-8 anyway... In order of importance checks:
string | $httpHeader | the http Content-type header |
string | $xmlChunk | xml content buffer |
string | $encodingPrefs | comma separated list of character encodings to be used as default (when mb extension is enabled). This can also be set globally using PhpXmlRpc\$xmlrpc_detectencodings |
string | the encoding determined. Null if it can't be determined and mbstring is enabled, PhpXmlRpc\$xmlrpc_defencoding if it can't be determined and mbstring is not enabled |
PhpXmlRpc\Helper\XMLParser::parse | ( | $data, | |
$returnType = self::RETURN_XMLRPCVALS, | |||
$accept = 3, | |||
$options = array() ) |
Parses an xml-rpc xml string.
Results of the parsing are found in $this->['_xh']. Logs to the error log any issues which do not cause the parsing to fail.
string | $data | |
string | $returnType | self\RETURN_XMLRPCVALS, self\RETURN_PHP, self\RETURN_EPIVALS |
int | $accept | a bit-combination of self\ACCEPT_REQUEST, self\ACCEPT_RESPONSE, self\ACCEPT_VALUE |
array | $options | integer-key options are passed to the xml parser, string-key options are used independently. These options are added to options received in the constructor. Note that if options xmlrpc_null_extension, xmlrpc_return_datetimes and xmlrpc_reject_invalid_values are not set, the default settings from PhpXmlRpc\PhpXmlRpc are used |
array | see the definition of $this->_xh for the meaning of the results |
Exception | this can happen if a callback function is set and it does throw (i.e. we do not catch exceptions) |
refactor? we could 1. return the parsed data structure, and 2. move $returnType and $accept into options
feature-creep make it possible to pass in options overriding usage of PhpXmlRpc\$xmlrpc_XXX_format, so that parsing will be completely independent of global state. Note that it might incur a small perf hit...
PhpXmlRpc\Helper\XMLParser::xmlrpc_dh | ( | $parser, | |
$data ) |
xml parser handler function for 'other stuff', i.e.
not char data or element start/end tag. In fact, it only gets called on unknown entities...
|
protected |
Used to store state during parsing and to pass parsing results to callers.
Quick explanation of components: private: ac - used to accumulate values stack - array with genealogy of xml elements names, used to validate nesting of xml-rpc elements valuestack - array used for parsing arrays and structs lv - used to indicate "looking for a value": implements the logic to allow values with no types to be strings (values: 0=not looking, 1=looking, 3=found) public: isf - used to indicate an xml-rpc response fault (1), invalid xml-rpc fault (2), xml parsing fault (3) isf_reason - used for storing xml-rpc response fault string value - used to store the value in responses method - used to store method name in requests params - used to store parameters in requests pt - used to store the type of each received parameter. Useful if parameters are automatically decoded to php values rt - 'methodcall', 'methodresponse', 'value' or 'fault' (the last one used only in EPI emulation mode)
|
protected |
Used keys: accept, target_charset, methodname_callback, plus the ones set here.
We initialize it partially to help keep BC with subclasses which might have reimplemented parse()
but not the element handler methods
|
protected |
$accept self\ACCEPT_REQUEST | self\ACCEPT_RESPONSE by default
$maxChunkLength 4 MB by default. Any value below 10MB should be good
|
protected |