ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
XML_RPC2_Backend_Php_Value_Base64 Class Reference
+ Inheritance diagram for XML_RPC2_Backend_Php_Value_Base64:
+ Collaboration diagram for XML_RPC2_Backend_Php_Value_Base64:

Public Member Functions

 __construct ($nativeValue)
 Constructor. More...
 
 encode ()
 Encode the instance into XML, for transport. More...
 
- Public Member Functions inherited from XML_RPC2_Backend_Php_Value
 getNativeValue ()
 nativeValue property getter More...
 

Static Public Member Functions

static decode ($xml)
 Decode transport XML and set the instance value accordingly. More...
 
- Static Public Member Functions inherited from XML_RPC2_Backend_Php_Value
static createFromNative ($nativeValue, $explicitType=null)
 Choose a XML_RPC2_Value subclass appropriate for the given value and create it. More...
 
static createFromDecode ($simpleXML)
 Decode an encoded value and build the applicable XML_RPC2_Value subclass. More...
 
- Static Public Member Functions inherited from XML_RPC2_Value
static createFromNative ($value, $explicitType=null)
 Factory method that constructs the appropriate XML-RPC encoded type value. More...
 

Additional Inherited Members

- Protected Member Functions inherited from XML_RPC2_Backend_Php_Value
 setNativeValue ($value)
 nativeValue setter More...
 

Detailed Description

Definition at line 64 of file Base64.php.

Constructor & Destructor Documentation

◆ __construct()

XML_RPC2_Backend_Php_Value_Base64::__construct (   $nativeValue)

Constructor.

Will build a new XML_RPC2_Backend_Php_Value_Base64 with the given value

This class handles encoding-decoding internally. Do not provide the native string base64-encoded

Parameters
mixedString $nativeValue to be transmited base64-encoded or "stdclass native value"

Definition at line 77 of file Base64.php.

References XML_RPC2_Backend_Php_Value\setNativeValue().

78  {
79  if ((is_object($nativeValue)) &&(strtolower(get_class($nativeValue)) == 'stdclass') && (isset($nativeValue->xmlrpc_type))) {
80  $scalar = $nativeValue->scalar;
81  } else {
82  if (!is_string($nativeValue)) {
83  throw new XML_RPC2_InvalidTypeException(sprintf('Cannot create XML_RPC2_Backend_Php_Value_Base64 from type \'%s\'.', gettype($nativeValue)));
84  }
85  $scalar = $nativeValue;
86  }
87  $tmp = new stdclass();
88  $tmp->scalar = $scalar;
89  $tmp->xmlrpc_type = 'base64';
90  $this->setNativeValue($tmp);
91  }
setNativeValue($value)
nativeValue setter
Definition: Value.php:89
+ Here is the call graph for this function:

Member Function Documentation

◆ decode()

static XML_RPC2_Backend_Php_Value_Base64::decode (   $xml)
static

Decode transport XML and set the instance value accordingly.

Parameters
mixed$xmlThe encoded XML-RPC value,

Definition at line 115 of file Base64.php.

References $result.

116  {
117  // TODO Remove reparsing of XML fragment, when SimpleXML proves more solid. Currently it segfaults when
118  // xpath is used both in an element and in one of its children
119  $xml = simplexml_load_string($xml->asXML());
120  $value = $xml->xpath('/value/base64/text()');
121  if (!array_key_exists(0, $value)) {
122  $value = $xml->xpath('/value/text()');
123  }
124  // Emulate xmlrpcext results (to be able to switch from a backend to another)
125  $result = new stdclass();
126  $result->scalar = base64_decode($value[0]);
127  $result->xmlrpc_type = 'base64';
128  return $result;
129  }
$result

◆ encode()

XML_RPC2_Backend_Php_Value_Base64::encode ( )

Encode the instance into XML, for transport.

Returns
string The encoded XML-RPC value,

Definition at line 101 of file Base64.php.

References XML_RPC2_Backend_Php_Value\getNativeValue().

102  {
103  $native = $this->getNativeValue();
104  return '<base64>' . base64_encode($native->scalar) . '</base64>';
105  }
getNativeValue()
nativeValue property getter
Definition: Value.php:76
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: