ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Value.php
Go to the documentation of this file.
1<?php
2
3/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
4
5// LICENSE AGREEMENT. If folded, press za here to unfold and read license {{{
6
40// }}}
41
42// dependencies {{{
43require_once 'XML/RPC2/Exception.php';
44require_once 'XML/RPC2/Backend.php';
45// }}}
46
58{
59
60 // {{{ createFromNative()
61
69 public static function createFromNative($value, $explicitType)
70 {
71 $type = strtolower($explicitType);
72 $availableTypes = array('datetime', 'base64', 'struct');
73 if (in_array($type, $availableTypes)) {
74 if ($type=='struct') {
75 if (!(is_array($value))) {
76 throw new XML_RPC2_Exception('With struct type, value has to be an array');
77 }
78 // Because of http://bugs.php.net/bug.php?id=21949
79 // is some cases (structs with numeric indexes), we need to be able to force the "struct" type
80 // (xmlrpc_set_type doesn't help for this, so we need this ugly hack)
81 $new = array();
82 while (list($k, $v) = each($value)) {
83 $new["xml_rpc2_ugly_struct_hack_$k"] = $v;
84 // with this "string" prefix, we are sure that the array will be seen as a "struct"
85 }
86 return $new;
87 }
88 $value2 = (string) $value;
89 if (!xmlrpc_set_type($value2, $type)) {
90 throw new XML_RPC2_Exception('Error returned from xmlrpc_set_type');
91 }
92 return $value2;
93 }
94 return $value;
95 }
96
97 // }}}
98
99}
100
101?>
static createFromNative($value, $explicitType)
Factory method that constructs the appropriate XML-RPC encoded type value.
Definition: Value.php:69