• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

payment/bmf/lib/SOAP/class.ilBMFBase.php

Go to the documentation of this file.
00001 <?php
00035 $GLOBALS['SOAP_OBJECT_STRUCT'] = true;
00036 
00045 $GLOBALS['SOAP_RAW_CONVERT'] = false;
00046 
00047 require_once 'PEAR.php';
00048 require_once dirname(__FILE__).'/Type/class.ilBMFType_dateTime.php';
00049 require_once dirname(__FILE__).'/Type/class.ilBMFType_hexBinary.php';
00050 
00051 // optional features
00052 $GLOBALS['SOAP_options'] = array();
00053 
00054 @include_once 'Mail/mimePart.php';
00055 @include_once 'Mail/mimeDecode.php';
00056 if (class_exists('Mail_mimePart')) {
00057     $GLOBALS['SOAP_options']['Mime'] = 1;
00058     define('MAIL_MIMEPART_CRLF', "\r\n");
00059 }
00060 
00061 @include_once 'Net/DIME.php';
00062 if (class_exists('Net_DIME_Message')) {
00063     $GLOBALS['SOAP_options']['DIME'] = 1;
00064 }
00065 
00072 $GLOBALS['SOAP_DEBUG'] = false;
00073 
00074 if (!function_exists('version_compare') ||
00075     version_compare(phpversion(), '4.1', '<')) {
00076     die("requires PHP 4.1 or higher\n");
00077 }
00078 if (version_compare(phpversion(), '4.1', '>=') &&
00079     version_compare(phpversion(), '4.2', '<')) {
00080     define('FLOAT', 'double');
00081 } else {
00082     define('FLOAT', 'float');
00083 }
00084 
00085 if (!defined('INF')) {
00086     define('INF', 1.8e307);
00087 }
00088 if (!defined('NAN')) {
00089     define('NAN', 0.0);
00090 }
00091 
00092 define('SOAP_LIBRARY_VERSION', '0.8.0RC4');
00093 define('SOAP_LIBRARY_NAME',    'PEAR-SOAP 0.8.0RC4-devel');
00094 
00095 // Set schema version.
00096 define('SOAP_XML_SCHEMA_VERSION',  'http://www.w3.org/2001/XMLSchema');
00097 define('SOAP_XML_SCHEMA_INSTANCE', 'http://www.w3.org/2001/XMLSchema-instance');
00098 define('SOAP_XML_SCHEMA_1999',     'http://www.w3.org/1999/XMLSchema');
00099 define('SOAP_SCHEMA',              'http://schemas.xmlsoap.org/wsdl/soap/');
00100 define('SOAP_SCHEMA_ENCODING',     'http://schemas.xmlsoap.org/soap/encoding/');
00101 define('SOAP_ENVELOP',             'http://schemas.xmlsoap.org/soap/envelope/');
00102 
00103 define('SCHEMA_DISCO',             'http://schemas.xmlsoap.org/disco/');
00104 define('SCHEMA_DISCO_SCL',         'http://schemas.xmlsoap.org/disco/scl/');
00105 
00106 define('SCHEMA_SOAP',              'http://schemas.xmlsoap.org/wsdl/soap/');
00107 define('SCHEMA_SOAP_HTTP',         'http://schemas.xmlsoap.org/soap/http');
00108 define('SCHEMA_WSDL_HTTP',         'http://schemas.xmlsoap.org/wsdl/http/');
00109 define('SCHEMA_MIME',              'http://schemas.xmlsoap.org/wsdl/mime/');
00110 define('SCHEMA_WSDL',              'http://schemas.xmlsoap.org/wsdl/');
00111 define('SCHEMA_DIME',              'http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/');
00112 define('SCHEMA_CONTENT',           'http://schemas.xmlsoap.org/ws/2002/04/content-type/');
00113 define('SCHEMA_REF',               'http://schemas.xmlsoap.org/ws/2002/04/reference/');
00114 
00115 /* Databay: Changes for BMF */
00116 #define('SOAP_DEFAULT_ENCODING',  'UTF-8');
00117 define('SOAP_DEFAULT_ENCODING',  'ISO-8859-1');
00118 
00119 class ilBMFBase_Object extends PEAR
00120 {
00127     var $_debug_flag = false;
00128 
00136     var $_debug_data = '';
00137 
00143     var $_encodings = array('ISO-8859-1', 'US-ASCII', 'UTF-8');
00144 
00150     var $_myfaultcode = '';
00151 
00157     var $fault = null;
00158 
00166     function ilBMFBase_Object($faultcode = 'Client')
00167     {
00168         $this->_myfaultcode = $faultcode;
00169         $this->_debug_flag = $GLOBALS['SOAP_DEBUG'];
00170         parent::PEAR('ilBMFFault');
00171     }
00172 
00191     function &_raiseSoapFault($str, $detail = '', $actorURI = '', $code = null,
00192                               $mode = null, $options = null, $skipmsg = false)
00193     {
00194         // Pass through previous faults.
00195         $is_instance = isset($this);
00196         if (is_object($str)) {
00197             $fault =& $str;
00198         } else {
00199             if (!$code) {
00200                 $code = $is_instance ? $this->_myfaultcode : 'Client';
00201             }
00202             $fault =& new ilBMFFault($str,
00203                                      $code,
00204                                      $actorURI,
00205                                      $detail,
00206                                      $mode,
00207                                      $options);
00208         }
00209         if ($is_instance) {
00210             $this->fault =& $fault;
00211         }
00212 
00213         return $fault;
00214     }
00215 
00216     function __isfault()
00217     {
00218         return $this->fault != null;
00219     }
00220 
00221     function &__getfault()
00222     {
00223         return $this->fault;
00224     }
00225 
00231     function _debug($string)
00232     {
00233         if ($this->_debug_flag) {
00234             $this->_debug_data .= get_class($this) . ': ' .
00235                 str_replace('>', ">\r\n", $string) . "\n";
00236         }
00237     }
00238 
00239 }
00240 
00248 class ilBMFBase extends ilBMFBase_Object
00249 {
00250     var $_XMLSchema = array('http://www.w3.org/2001/XMLSchema',
00251                             'http://www.w3.org/1999/XMLSchema');
00252     var $_XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
00253 
00254     // load types into typemap array
00255     var $_typemap = array(
00256         'http://www.w3.org/2001/XMLSchema' => array(
00257             'string' => 'string',
00258             'boolean' => 'boolean',
00259             'float' => FLOAT,
00260             'double' => FLOAT,
00261             'decimal' => FLOAT,
00262             'duration' => 'integer',
00263             'dateTime' => 'string',
00264             'time' => 'string',
00265             'date' => 'string',
00266             'gYearMonth' => 'integer',
00267             'gYear' => 'integer',
00268             'gMonthDay' => 'integer',
00269             'gDay' => 'integer',
00270             'gMonth' => 'integer',
00271             'hexBinary' => 'string',
00272             'base64Binary' => 'string',
00273             // derived datatypes
00274             'normalizedString' => 'string',
00275             'token' => 'string',
00276             'language' => 'string',
00277             'NMTOKEN' => 'string',
00278             'NMTOKENS' => 'string',
00279             'Name' => 'string',
00280             'NCName' => 'string',
00281             'ID' => 'string',
00282             'IDREF' => 'string',
00283             'IDREFS' => 'string',
00284             'ENTITY' => 'string',
00285             'ENTITIES' => 'string',
00286             'integer' => 'integer',
00287             'nonPositiveInteger' => 'integer',
00288             'negativeInteger' => 'integer',
00289             'long' => 'integer',
00290             'int' => 'integer',
00291             'short' => 'integer',
00292             'byte' => 'string',
00293             'nonNegativeInteger' => 'integer',
00294             'unsignedLong' => 'integer',
00295             'unsignedInt' => 'integer',
00296             'unsignedShort' => 'integer',
00297             'unsignedByte' => 'integer',
00298             'positiveInteger'  => 'integer',
00299             'anyType' => 'string',
00300             'anyURI' => 'string',
00301             'QName' => 'string'
00302         ),
00303         'http://www.w3.org/1999/XMLSchema' => array(
00304             'i4' => 'integer',
00305             'int' => 'integer',
00306             'boolean' => 'boolean',
00307             'string' => 'string',
00308             'double' => FLOAT,
00309             'float' => FLOAT,
00310             'dateTime' => 'string',
00311             'timeInstant' => 'string',
00312             'base64Binary' => 'string',
00313             'base64' => 'string',
00314             'ur-type' => 'string'
00315         ),
00316         'http://schemas.xmlsoap.org/soap/encoding/' => array(
00317             'base64' => 'string',
00318             'array' => 'array',
00319             'Array' => 'array',
00320             'Struct' => 'array')
00321     );
00322 
00328     var $_defaultObjectClassname = 'stdClass';
00329 
00330     // Load namespace URIs into an array of URI => prefix.
00331     var $_namespaces;
00332     var $_namespace;
00333 
00334     var $_xmlEntities = array('&' => '&amp;',
00335                               '<' => '&lt;',
00336                               '>' => '&gt;',
00337                               "'" => '&apos;',
00338                               '"' => '&quot;');
00339 
00340     var $_doconversion = false;
00341 
00342     var $__attachments = array();
00343 
00344     var $_wsdl = null;
00345 
00351     var $_section5 = true;
00352 
00353     // Handle type to class mapping.
00354     var $_auto_translation = false;
00355     var $_type_translation = array();
00356 
00364     function ilBMFBase($faultcode = 'Client')
00365     {
00366         parent::ilBMFBase_Object($faultcode);
00367         $this->_resetNamespaces();
00368     }
00369 
00370     function _resetNamespaces()
00371     {
00372         $this->_namespaces = array(
00373             'http://schemas.xmlsoap.org/soap/envelope/' => 'SOAP-ENV',
00374             'http://www.w3.org/2001/XMLSchema' => 'xsd',
00375             'http://www.w3.org/2001/XMLSchema-instance' => 'xsi',
00376             'http://schemas.xmlsoap.org/soap/encoding/' => 'SOAP-ENC');
00377     }
00378 
00387     function _setSchemaVersion($schemaVersion)
00388     {
00389         if (!in_array($schemaVersion, $this->_XMLSchema)) {
00390             return $this->_raiseSoapFault("unsuported XMLSchema $schemaVersion");
00391         }
00392         $this->_XMLSchemaVersion = $schemaVersion;
00393         $tmpNS = array_flip($this->_namespaces);
00394         $tmpNS['xsd'] = $this->_XMLSchemaVersion;
00395         $tmpNS['xsi'] = $this->_XMLSchemaVersion . '-instance';
00396         $this->_namespaces = array_flip($tmpNS);
00397     }
00398 
00399     function _getNamespacePrefix($ns)
00400     {
00401         if ($this->_namespace && $ns == $this->_namespace) {
00402             return '';
00403         }
00404         if (isset($this->_namespaces[$ns])) {
00405             return $this->_namespaces[$ns];
00406         }
00407         $prefix = 'ns' . count($this->_namespaces);
00408         $this->_namespaces[$ns] = $prefix;
00409         return $prefix;
00410     }
00411 
00412     function _getNamespaceForPrefix($prefix)
00413     {
00414         $flipped = array_flip($this->_namespaces);
00415         if (isset($flipped[$prefix])) {
00416             return $flipped[$prefix];
00417         }
00418         return null;
00419     }
00420 
00421     function _isSoapValue(&$value)
00422     {
00423         return is_a($value, 'ilBMFValue');
00424     }
00425 
00426     function _serializeValue(&$value, $name = '', $type = false, $elNamespace = NULL, $typeNamespace=NULL, $options=array(), $attributes = array(), $artype='', $OBJTypeNS = array())
00427     {
00428         $namespaces = array();
00429         $arrayType = $array_depth = $xmlout_value = null;
00430         $typePrefix = $elPrefix = $xmlout_offset = $xmlout_arrayType = $xmlout_type = $xmlns = '';
00431         $ptype = $array_type_ns = '';
00432 
00433         if (!$name || is_numeric($name)) {
00434             $name = 'item';
00435         }
00436 
00437         if ($this->_wsdl)
00438             list($ptype, $arrayType, $array_type_ns, $array_depth)
00439                     = $this->_wsdl->getSchemaType($type, $name, $typeNamespace);
00440 
00441         if (!$arrayType) $arrayType = $artype;
00442         if (!$ptype) $ptype = $this->_getType($value);
00443         if (!$type) $type = $ptype;
00444 
00445         if (strcasecmp($ptype,'Struct') == 0 || strcasecmp($type,'Struct') == 0) {
00446             // struct
00447             $vars = NULL;
00448             if (is_object($value)) {
00449                 $vars = get_object_vars($value);
00450             } else {
00451                 $vars = &$value;
00452             }
00453             if (is_array($vars)) {
00454                 foreach (array_keys($vars) as $k) {
00455                     if ($k[0]=='_') continue; // hide private vars
00456                     if (is_object($vars[$k])) {
00457                         if (is_a($vars[$k],'ilbmfvalue')) {
00458                             $xmlout_value .= $vars[$k]->serialize($this);
00459                         } else {
00460                             // XXX get the members and serialize them instead
00461                             // converting to an array is more overhead than we
00462                             // should realy do, but php-soap is on it's way.
00463                             $objarr = get_object_vars ( $vars[$k] );
00464                             if (!isset ($objarr['OBJTypeNS'])) {
00465                                 $xmlout_value .= $this->_serializeValue(get_object_vars($vars[$k]), $k, false, $this->_section5?NULL:$elNamespace, NULL, NULL, NULL, NULL);
00466                             } else {
00467                                 $xmlout_value .= $this->_serializeValue(get_object_vars($vars[$k]), $k, false, $this->_section5?NULL:$elNamespace, NULL, NULL, NULL, NULL, $objarr['OBJTypeNS']);
00468                             }
00469                         }
00470                     } else {
00471                         if ($k != 'OBJTypeNS') {
00472                             $xmlout_value .= $this->_serializeValue($vars[$k],$k, false, $this->_section5?NULL:$elNamespace);
00473                         }
00474                     }
00475                 }
00476             }
00477         } else if (strcasecmp($ptype,'Array')==0 || strcasecmp($type,'Array')==0) {
00478             // array
00479             $typeNamespace = SOAP_SCHEMA_ENCODING;
00480             $orig_type = $type;
00481             $type = 'Array';
00482             $numtypes = 0;
00483             // XXX this will be slow on larger array's.  Basicly, it flattens array's to allow us
00484             // to serialize multi-dimensional array's.  We only do this if arrayType is set,
00485             // which will typicaly only happen if we are using WSDL
00486             if (isset($options['flatten']) || ($arrayType && (strchr($arrayType,',') || strstr($arrayType,'][')))) {
00487                 $numtypes = $this->_multiArrayType($value, $arrayType, $ar_size, $xmlout_value);
00488             }
00489 
00490             $array_type = $array_type_prefix = '';
00491             if ($numtypes != 1) {
00492                 $arrayTypeQName =& new QName($arrayType);
00493                 $arrayType = $arrayTypeQName->name;
00494                 $array_types = array();
00495                 $array_val = NULL;
00496 
00497                 // serialize each array element
00498                 $ar_size = count($value);
00499                 foreach ($value as $array_val) {
00500                     if ($this->_isSoapValue($array_val)) {
00501                         $array_type = $array_val->type;
00502                         $array_types[$array_type] = 1;
00503                         $array_type_ns = $array_val->type_namespace;
00504                         $xmlout_value .= $array_val->serialize($this);
00505                     } else {
00506                         $array_type = $this->_getType($array_val);
00507                         $array_types[$array_type] = 1;
00508                         $objarr = get_object_vars ( $array_val );
00509                         if (isset($objarr['OBJTypeNS'])) {
00510                             $tmp_arr['item'] = $objarr['OBJTypeNS']['item'];
00511                             $xmlout_value .= $this->_serializeValue($array_val,'item', $array_type, $elNamespace, NULL, NULL, NULL, NULL, $tmp_arr);
00512                         } else {
00513                             $xmlout_value .= $this->_serializeValue($array_val,'item', $array_type, $elNamespace);
00514                         }
00515                     }
00516                 }
00517 
00518                 $xmlout_offset = " SOAP-ENC:offset=\"[0]\"";
00519                 if (!$arrayType) {
00520                     $numtypes = count($array_types);
00521                     if ($numtypes == 1) $arrayType = $array_type;
00522                     // using anyType is more interoperable
00523                     if ($array_type == 'Struct') {
00524                         $array_type = '';
00525                     } else if ($array_type == 'Array') {
00526                         $arrayType = 'anyType';
00527                         $array_type_prefix = 'xsd';
00528                     } else
00529                     if (!$arrayType) $arrayType = $array_type;
00530                 }
00531             }
00532             if (!$arrayType || $numtypes > 1) {
00533                 $arrayType = 'xsd:anyType'; // should reference what schema we're using
00534             } else {
00535                 if ($array_type_ns) {
00536                     $array_type_prefix = $this->_getNamespacePrefix($array_type_ns);
00537                 } else if (array_key_exists($arrayType, $this->_typemap[$this->_XMLSchemaVersion])) {
00538                     $array_type_prefix = $this->_namespaces[$this->_XMLSchemaVersion];
00539                 }
00540                 if ($array_type_prefix)
00541                     $arrayType = $array_type_prefix.':'.$arrayType;
00542             }
00543 
00544              if (isset($value[0]->OBJTypeNS)) {
00545                  $xmlout_arrayType = ' xmlns:' . $value[0]->OBJTypeNS['nsPrefix'] . '="' . $value[0]->OBJTypeNS['namespace'] . '" xsi:type="' . $value[0]->OBJTypeNS['nsPrefix'] . ':Array" ' . $value[0]->OBJTypeNS['nsPrefix'] . ':arrayType="' . $value[0]->OBJTypeNS['pnsPrefix'] . ':' . get_class($value[0]);
00546                  $xmlout_type = $xmlns = $xmlout_offset = $xml_attr = $arrayType = '';
00547              } else {
00548                  $xmlout_arrayType = " SOAP-ENC:arrayType=\"" . $arrayType;
00549              }
00550             if ($array_depth != null) {
00551                 for ($i = 0; $i < $array_depth; $i++) {
00552                     $xmlout_arrayType .= '[]';
00553                 }
00554             }
00555             $xmlout_arrayType .= "[$ar_size]\"";
00556         } else if ($this->_isSoapValue($value)) {
00557             $xmlout_value =& $value->serialize($this);
00558         } else if ($type == 'string') {
00559             $xmlout_value = htmlspecialchars($value);
00560         } else if ($type == 'rawstring') {
00561             $xmlout_value =& $value;
00562         } else if ($type == 'boolean') {
00563             $xmlout_value = $value?'true':'false';
00564         } else {
00565             $xmlout_value =& $value;
00566         }
00567 
00568         // add namespaces
00569         if ($elNamespace) {
00570             $elPrefix = $this->_getNamespacePrefix($elNamespace);
00571             $xmlout_name = "$elPrefix:$name";
00572         } else {
00573             $xmlout_name = $name;
00574         }
00575 
00576         if ($typeNamespace) {
00577             $typePrefix = $this->_getNamespacePrefix($typeNamespace);
00578             $xmlout_type = "$typePrefix:$type";
00579         } else if ($type && array_key_exists($type, $this->_typemap[$this->_XMLSchemaVersion])) {
00580             $typePrefix = $this->_namespaces[$this->_XMLSchemaVersion];
00581             $xmlout_type = "$typePrefix:$type";
00582         }
00583 
00584         // handle additional attributes
00585         $xml_attr = '';
00586         if (count($attributes) > 0) {
00587             foreach ($attributes as $k => $v) {
00588                 $kqn =& new QName($k);
00589                 $vqn =& new QName($v);
00590                 $xml_attr .= ' '.$kqn->fqn().'="'.$vqn->fqn().'"';
00591             }
00592         }
00593 
00594         // store the attachement for mime encoding
00595         if (isset($options['attachment']))
00596             $this->__attachments[] = $options['attachment'];
00597 
00598         if ($this->_section5) {
00599             if ($name == 'item' && isset($OBJTypeNS['item'])) {
00600                 $xmlout_type = $OBJTypeNS['item'];
00601             }
00602             
00603             if ($xmlout_type) $xmlout_type = " xsi:type=\"$xmlout_type\"";
00604             if (is_null($xmlout_value)) {
00605                 $xml = "";
00606             } else {
00607                 if (is_array($value) && isset ($value[0]->OBJTypeNS)) {
00608                     $xmlout_type = '';
00609                 }
00610                 $xml = "\r\n<$xmlout_name$xmlout_type$xmlns$xmlout_arrayType$xmlout_offset$xml_attr ";
00611                 if (isset($OBJTypeNS['namespace']) && isset($OBJTypeNS['type'])) {
00612                     if (trim($OBJTypeNS['namespace']) != '' || trim($OBJTypeNS['type']) != '') {
00613                         if (isset($OBJTypeNS['namespace']) && $OBJTypeNS['namespace'] != '') {
00614                            $xml .= ' xmlns:';
00615                            if ( isset($OBJTypeNS['nsPrefix']))
00616                               $xml .= $OBJTypeNS['nsPrefix'];
00617                            else
00618                                $xml .= 'intf';
00619                            $xml .= '="' . $OBJTypeNS['namespace'] . '"';
00620                         }
00621                         if (isset($OBJTypeNS['type']) && $OBJTypeNS['type'] != '') {
00622                            $xml .= ' xsi:type="';
00623                            if (strpos($OBJTypeNS['type'], "xsd:") === false){
00624                                if (isset($OBJTypeNS['nsPrefix']))
00625                                   $xml .= $OBJTypeNS['nsPrefix'] . ':';
00626                                else
00627                                    $xml .= 'intf:';
00628                            }
00629                            $xml .= $OBJTypeNS['type'] . '"';
00630                         }
00631                     }
00632                 }
00633                 $xml .= ">" . $xmlout_value . "</$xmlout_name>";
00634             }
00635         } else {
00636             if (is_null($xmlout_value)) {
00637                 $xml = "";
00638             } else {
00639                 $xml = "\r\n<$xmlout_name$xmlns$xml_attr>".
00640                     $xmlout_value."</$xmlout_name>";
00641             }
00642         }
00643         return $xml;
00644     }
00645 
00646 
00647 /* Databay: Changes for BMF */
00648 /*    function _serializeValue(&$value, $name = '', $type = false,
00649                              $elNamespace = null, $typeNamespace = null,
00650                              $options = array(), $attributes = array(),
00651                              $artype = '')
00652     {
00653         $namespaces = array();
00654         $arrayType = $array_depth = $xmlout_value = null;
00655         $typePrefix = $elPrefix = $xmlout_offset = $xmlout_arrayType = '';
00656         $xmlout_type = $xmlns = $ptype = $array_type_ns = '';
00657 
00658         if (!$name || is_numeric($name)) {
00659             $name = 'item';
00660         }
00661 
00662         if ($this->_wsdl) {
00663             list($ptype, $arrayType, $array_type_ns, $array_depth)
00664                 = $this->_wsdl->getSchemaType($type, $name, $typeNamespace);
00665         }
00666 
00667         if (!$arrayType) {
00668             $arrayType = $artype;
00669         }
00670         if (!$ptype) {
00671             $ptype = $this->_getType($value);
00672         }
00673         if (!$type) {
00674             $type = $ptype;
00675         }
00676 
00677         if (strcasecmp($ptype, 'Struct') == 0 ||
00678             strcasecmp($type, 'Struct') == 0) {
00679             // Struct
00680             $vars = null;
00681             if (is_object($value)) {
00682                 $vars = get_object_vars($value);
00683             } else {
00684                 $vars = &$value;
00685             }
00686             if (is_array($vars)) {
00687                 foreach (array_keys($vars) as $k) {
00688                     // Hide private vars.
00689                     if ($k[0] == '_') continue;
00690                     if (is_object($vars[$k])) {
00691                         if (is_a($vars[$k], 'ilBMFValue')) {
00692                             $xmlout_value .= $vars[$k]->serialize($this);
00693                         } else {
00694                             // XXX get the members and serialize them instead
00695                             // converting to an array is more overhead than we
00696                             // should really do.
00697                             $xmlout_value .= $this->_serializeValue(get_object_vars($vars[$k]), $k, false, $this->_section5 ? null : $elNamespace);
00698                         }
00699                     } else {
00700                         $xmlout_value .= $this->_serializeValue($vars[$k], $k, false, $this->_section5 ? null : $elNamespace);
00701                     }
00702                 }
00703             }
00704         } elseif (strcasecmp($ptype, 'Array') == 0 ||
00705                   strcasecmp($type, 'Array') == 0) {
00706             // Array.
00707             $typeNamespace = SOAP_SCHEMA_ENCODING;
00708             $orig_type = $type;
00709             $type = 'Array';
00710             $numtypes = 0;
00711             // XXX this will be slow on larger arrays.  Basically, it flattens
00712             // arrays to allow us to serialize multi-dimensional arrays.  We
00713             // only do this if arrayType is set, which will typically only
00714             // happen if we are using WSDL
00715             if (isset($options['flatten']) ||
00716                 ($arrayType &&
00717                  (strchr($arrayType, ',') || strstr($arrayType, '][')))) {
00718                 $numtypes = $this->_multiArrayType($value, $arrayType,
00719                                                    $ar_size, $xmlout_value);
00720             }
00721 
00722             $array_type = $array_type_prefix = '';
00723             if ($numtypes != 1) {
00724                 $arrayTypeQName =& new QName($arrayType);
00725                 $arrayType = $arrayTypeQName->name;
00726                 $array_types = array();
00727                 $array_val = null;
00728 
00729                 // Serialize each array element.
00730                 $ar_size = count($value);
00731                 foreach ($value as $array_val) {
00732                     if ($this->_isSoapValue($array_val)) {
00733                         $array_type = $array_val->type;
00734                         $array_types[$array_type] = 1;
00735                         $array_type_ns = $array_val->type_namespace;
00736                         $xmlout_value .= $array_val->serialize($this);
00737                     } else {
00738                         $array_type = $this->_getType($array_val);
00739                         $array_types[$array_type] = 1;
00740                         $xmlout_value .= $this->_serializeValue($array_val, 'item', $array_type, $this->_section5 ? null : $elNamespace);
00741                     }
00742                 }
00743 
00744                 $xmlout_offset = ' SOAP-ENC:offset="[0]"';
00745                 if (!$arrayType) {
00746                     $numtypes = count($array_types);
00747                     if ($numtypes == 1) {
00748                         $arrayType = $array_type;
00749                     }
00750                     // Using anyType is more interoperable.
00751                     if ($array_type == 'Struct') {
00752                         $array_type = '';
00753                     } elseif ($array_type == 'Array') {
00754                         $arrayType = 'anyType';
00755                         $array_type_prefix = 'xsd';
00756                     } else {
00757                         if (!$arrayType) {
00758                             $arrayType = $array_type;
00759                         }
00760                     }
00761                 }
00762             }
00763             if (!$arrayType || $numtypes > 1) {
00764                 // Should reference what schema we're using.
00765                 $arrayType = 'xsd:anyType';
00766             } else {
00767                 if ($array_type_ns) {
00768                     $array_type_prefix = $this->_getNamespacePrefix($array_type_ns);
00769                 } elseif (isset($this->_typemap[$this->_XMLSchemaVersion][$arrayType])) {
00770                     $array_type_prefix = $this->_namespaces[$this->_XMLSchemaVersion];
00771                 }
00772                 if ($array_type_prefix) {
00773                     $arrayType = $array_type_prefix . ':' . $arrayType;
00774                 }
00775             }
00776 
00777             $xmlout_arrayType = ' SOAP-ENC:arrayType="' . $arrayType;
00778             if ($array_depth != null) {
00779                 for ($i = 0; $i < $array_depth; $i++) {
00780                     $xmlout_arrayType .= '[]';
00781                 }
00782             }
00783             $xmlout_arrayType .= "[$ar_size]\"";
00784         } elseif ($this->_isSoapValue($value)) {
00785             $xmlout_value = $value->serialize($this);
00786         } elseif ($type == 'string') {
00787             $xmlout_value = htmlspecialchars($value);
00788         } elseif ($type == 'rawstring') {
00789             $xmlout_value =& $value;
00790         } elseif ($type == 'boolean') {
00791             $xmlout_value = $value ? 'true' : 'false';
00792         } else {
00793             $xmlout_value =& $value;
00794         }
00795 
00796         // Add namespaces.
00797         if ($elNamespace) {
00798             $elPrefix = $this->_getNamespacePrefix($elNamespace);
00799             if ($elPrefix) {
00800                 $xmlout_name = "$elPrefix:$name";
00801             } else {
00802                 $xmlout_name = $name;
00803             }
00804         } else {
00805             $xmlout_name = $name;
00806         }
00807 
00808         if ($typeNamespace) {
00809             $typePrefix = $this->_getNamespacePrefix($typeNamespace);
00810             if ($typePrefix) {
00811                 $xmlout_type = "$typePrefix:$type";
00812             } else {
00813                 $xmlout_type = $type;
00814             }
00815         } elseif ($type &&
00816                   isset($this->_typemap[$this->_XMLSchemaVersion][$type])) {
00817             $typePrefix = $this->_namespaces[$this->_XMLSchemaVersion];
00818             if ($typePrefix) {
00819                 $xmlout_type = "$typePrefix:$type";
00820             } else {
00821                 $xmlout_type = $type;
00822             }
00823         }
00824 
00825         // Handle additional attributes.
00826         $xml_attr = '';
00827         if (count($attributes)) {
00828             foreach ($attributes as $k => $v) {
00829                 $kqn =& new QName($k);
00830                 $vqn =& new QName($v);
00831                 $xml_attr .= ' ' . $kqn->fqn() . '="' . $vqn->fqn() . '"';
00832             }
00833         }
00834 
00835         // Store the attachment for mime encoding.
00836         if (isset($options['attachment']) &&
00837             !PEAR::isError($options['attachment'])) {
00838             $this->__attachments[] = $options['attachment'];
00839         }
00840 
00841         if ($this->_section5) {
00842             if ($xmlout_type) {
00843                 $xmlout_type = " xsi:type=\"$xmlout_type\"";
00844             }
00845             if (is_null($xmlout_value)) {
00846                 $xml = "\r\n<$xmlout_name$xmlout_type$xmlns$xmlout_arrayType" .
00847                     "$xml_attr xsi:nil=\"true\"/>";
00848             } else {
00849                 $xml = "\r\n<$xmlout_name$xmlout_type$xmlns$xmlout_arrayType" .
00850                     "$xmlout_offset$xml_attr>$xmlout_value</$xmlout_name>";
00851             }
00852         } else {
00853             if (is_null($xmlout_value)) {
00854                 $xml = "\r\n<$xmlout_name$xmlns$xml_attr/>";
00855             } else {
00856                 $xml = "\r\n<$xmlout_name$xmlns$xml_attr>" .
00857                     $xmlout_value . "</$xmlout_name>";
00858             }
00859         }
00860 
00861         return $xml;
00862     }
00863 */
00873     function _getType(&$value)
00874     {
00875         global $SOAP_OBJECT_STRUCT, $SOAP_RAW_CONVERT;
00876 
00877         $type = gettype($value);
00878         switch ($type) {
00879         case 'object':
00880             if (is_a($value, 'ilbmfvalue')) {
00881                 $type = $value->type;
00882             } else {
00883                 $type = 'Struct';
00884             }
00885             break;
00886 
00887         case 'array':
00888             // Hashes are always handled as structs.
00889             if ($this->_isHash($value)) {
00890                 $type = 'Struct';
00891             } else {
00892                 $ar_size = count($value);
00893                 reset($value);
00894                 $key1 = key($value);
00895                 if ($ar_size > 0 && is_a($key1, 'ilBMFValue')) {
00896                     // FIXME: for non-wsdl structs that are all the same type
00897                     $key2 = key($value);
00898                     if ($ar_size > 1 &&
00899                         $this->_isSoapValue($key1) &&
00900                         $this->_isSoapValue($key2) &&
00901                         $key1->name != $key2->name) {
00902                         // This is a struct, not an array.
00903                         $type = 'Struct';
00904                     } else {
00905                         $type = 'Array';
00906                     }
00907                 } else {
00908                     $type = 'Array';
00909                 }
00910             }
00911             break;
00912 
00913         case 'integer':
00914         case 'long':
00915             $type = 'int';
00916             break;
00917 
00918         case 'boolean':
00919             break;
00920 
00921         case 'double':
00922             // double is deprecated in PHP 4.2 and later.
00923             $type = 'decimal';
00924             break;
00925 
00926         case 'null':
00927             $type = '';
00928             break;
00929 
00930         case 'string':
00931 /* Databay: Changes for BMF */
00932 /*            if ($SOAP_RAW_CONVERT) {
00933                 if (is_numeric($value)) {
00934                     if (strstr($value, '.')) {
00935                         $type = 'float';
00936                     } else {
00937                         $type = 'int';
00938                     }
00939                 } else {
00940                     if (ilBMFType_hexBinary::is_hexbin($value)) {
00941                         $type = 'hexBinary';
00942                     } else {
00943                         if ($this->_isBase64($value)) {
00944                             $type = 'base64Binary';
00945                         } else {
00946                             $dt =& new ilBMFType_dateTime($value);
00947                             if ($dt->toUnixtime() != -1) {
00948                                 $type = 'dateTime';
00949                             }
00950                         }
00951                     }
00952                 }
00953             }
00954             break;*/
00955             if ($SOAP_RAW_CONVERT) {
00956                 if (is_numeric($value)) {
00957                     if (strstr($value,'.')) $type = 'float';
00958                     else $type = 'int';
00959                 } else
00960                 if (ilBMFType_hexBinary::is_hexbin($value)) {
00961                     $type = 'hexBinary';
00962                 } else
00963                 if ($this->_isBase64($value)) {
00964                     $type = 'base64Binary';
00965                 } else {
00966                     $dt =& new ilBMFType_dateTime($value);
00967                     if ($dt->toUnixtime() != -1) {
00968                         $type = 'dateTime';
00969                         #$value = $dt->toSOAP();
00970                     }
00971                 }
00972             } else {
00973                 $dt =& new ilBMFType_dateTime($value);
00974                 if ($dt->toUnixtime() != -1) {
00975                     $type = 'dateTime';
00976                     #$value = $dt->toSOAP();
00977                 }
00978             }
00979 
00980         default:
00981             break;
00982         }
00983 
00984         return $type;
00985     }
00986 
00987     function _multiArrayType(&$value, &$type, &$size, &$xml)
00988     {
00989         $sz = count($value);
00990         if (is_array($value)) {
00991             // Seems we have a multi dimensional array, figure it out if we
00992             // do.
00993             $c = count($value);
00994             for ($i = 0; $i < $c; $i++) {
00995                 $this->_multiArrayType($value[$i], $type, $size, $xml);
00996             }
00997 
00998             if ($size) {
00999                 $size = $sz. ',' . $size;
01000             } else {
01001                 $size = $sz;
01002             }
01003 
01004             return 1;
01005         } else {
01006             if (is_object($value)) {
01007                 $type = $value->type;
01008                 $xml .= $value->serialize($this);
01009             } else {
01010                 $type = $this->_getType($value);
01011                 $xml .= $this->_serializeValue($value, 'item', $type);
01012             }
01013         }
01014         $size = null;
01015 
01016         return 1;
01017     }
01018 
01026     function _isBase64(&$value)
01027     {
01028         $l = strlen($value);
01029         if ($l) {
01030             return $value[$l - 1] == '=' &&
01031                 preg_match('/[A-Za-z=\/\+]+/', $value);
01032         }
01033         return false;
01034     }
01035 
01043     function _isBase64Type($type)
01044     {
01045         return $type == 'base64' || $type == 'base64Binary';
01046     }
01047 
01055     function _isHash(&$a)
01056     {
01057         // I really dislike having to loop through this in PHP code, really
01058         // large arrays will be slow.  We need a C function to do this.
01059         $names = array();
01060         $it = 0;
01061         foreach ($a as $k => $v) {
01062             // Checking the type is faster than regexp.
01063             $t = gettype($k);
01064             if ($t != 'integer') {
01065                 return true;
01066             } elseif ($this->_isSoapValue($v)) {
01067                 $names[$v->name] = 1;
01068             }
01069             // If someone has a large hash they should really be defining the
01070             // type.
01071             if ($it++ > 10) {
01072                 return false;
01073             }
01074         }
01075         return count($names)>1;
01076     }
01077 
01078     function _un_htmlentities($string)
01079     {
01080         $trans_tbl = get_html_translation_table(HTML_ENTITIES);
01081         $trans_tbl = array_flip($trans_tbl);
01082         return strtr($string, $trans_tbl);
01083     }
01084 
01085     function &_decode(&$soapval)
01086     {
01087         global $SOAP_OBJECT_STRUCT;
01088 
01089         if (!$this->_isSoapValue($soapval)) {
01090             return $soapval;
01091         } elseif (is_array($soapval->value)) {
01092             if ($SOAP_OBJECT_STRUCT && $soapval->type != 'Array') {
01093                 $classname = $this->_defaultObjectClassname;
01094                 if (isset($this->_type_translation[$soapval->tqn->fqn()])) {
01095                     // This will force an error in PHP if the class does not
01096                     // exist.
01097                     $classname = $this->_type_translation[$soapval->tqn->fqn()];
01098                 } elseif (isset($this->_type_translation[$soapval->type])) {
01099                     // This will force an error in PHP if the class does not
01100                     // exist.
01101                     $classname = $this->_type_translation[$soapval->type];
01102                 } elseif ($this->_auto_translation) {
01103                     if (class_exists($soapval->type)) {
01104                         $classname = $soapval->type;
01105                     } elseif ($this->_wsdl) {
01106                         $t = $this->_wsdl->getComplexTypeNameForElement($soapval->name, $soapval->namespace);
01107                         if ($t && class_exists($t)) {
01108                             $classname = $t;
01109                         }
01110                     }
01111                 }
01112                 $return =& new $classname;
01113             } else {
01114                 $return = array();
01115             }
01116 
01117             $counter = 1;
01118             $isstruct = !$SOAP_OBJECT_STRUCT || !is_array($return);
01119             foreach ($soapval->value as $item) {
01120                 if (is_object($return)) {
01121                     if ($this->_wsdl) {
01122                         // Get this child's WSDL information.
01123                         // /$soapval->ns/$soapval->type/$item->ns/$item->name
01124                         $child_type = $this->_wsdl->getComplexTypeChildType(
01125                             $soapval->namespace,
01126                             $soapval->name,
01127                             $item->namespace,
01128                             $item->name);
01129                         if ($child_type) {
01130                             $item->type = $child_type;
01131                         }
01132                     }
01133                     if (!$isstruct || $item->type == 'Array') {
01134                         if (isset($return->{$item->name}) &&
01135                             is_object($return->{$item->name})) {
01136                             $return->{$item->name} =& $this->_decode($item);
01137                         } elseif (isset($return->{$item->name}) &&
01138                                   is_array($return->{$item->name})) {
01139                             $return->{$item->name}[] = $this->_decode($item);
01140                         } elseif (is_array($return)) {
01141                             $return[] =& $this->_decode($item);
01142                         } else {
01143                             $return->{$item->name} =& $this->_decode($item);
01144                         }
01145                     } elseif (isset($return->{$item->name})) {
01146                         $isstruct = false;
01147                         if (count(get_object_vars($return)) == 1) {
01148                             $d =& $this->_decode($item);
01149                             $return = array($return->{$item->name}, $d);
01150                         } else {
01151                             $d =& $this->_decode($item);
01152                             $return->{$item->name} = array($return->{$item->name}, $d);
01153                         }
01154                     } else {
01155                         $return->{$item->name} =& $this->_decode($item);
01156                     }
01157                     // Set the attributes as members in the class.
01158                     if (method_exists($return, '__set_attribute')) {
01159                         foreach ($soapval->attributes as $key => $value) {
01160                             call_user_func_array(array(&$return,
01161                                                        '__set_attribute'),
01162                                                  array($key, $value));
01163                         }
01164                     }
01165                 } else {
01166                     if ($soapval->arrayType && $this->_isSoapValue($item)) {
01167                         if ($this->_isBase64Type($item->type) &&
01168                             !$this->_isBase64Type($soapval->arrayType)) {
01169                             // Decode the value if we're losing the base64
01170                             // type information.
01171                             $item->value = base64_decode($item->value);
01172                         }
01173                         $item->type = $soapval->arrayType;
01174                     }
01175                     if (!$isstruct) {
01176                         $return[] = $this->_decode($item);
01177                     } elseif (isset($return[$item->name])) {
01178                         $isstruct = false;
01179                         $d =& $this->_decode($item);
01180                         $return = array($return[$item->name], $d);
01181                     } else {
01182                         $return[$item->name] = $this->_decode($item);
01183                     }
01184                 }
01185             }
01186 
01187             return $return;
01188         }
01189 
01190         if ($soapval->type == 'boolean') {
01191             if ($soapval->value != '0' &&
01192                 strcasecmp($soapval->value, 'false') != 0) {
01193                 $soapval->value = true;
01194             } else {
01195                 $soapval->value = false;
01196             }
01197         } elseif ($soapval->type &&
01198                   isset($this->_typemap[SOAP_XML_SCHEMA_VERSION][$soapval->type])) {
01199             // If we can, set variable type.
01200             settype($soapval->value,
01201                     $this->_typemap[SOAP_XML_SCHEMA_VERSION][$soapval->type]);
01202         }
01203 
01204         if ($this->_isBase64Type($soapval->type)) {
01205             return base64_decode($soapval->value);
01206         } else {
01207             return $soapval->value;
01208         }
01209     }
01210 
01223     function _makeEnvelope(&$method, &$headers,
01224                            $encoding = SOAP_DEFAULT_ENCODING,
01225                            $options = array())
01226     {
01227         $smsg = $header_xml = $ns_string = '';
01228 
01229         if ($headers) {
01230             $c = count($headers);
01231             for ($i = 0; $i < $c; $i++) {
01232                 $header_xml .= $headers[$i]->serialize($this);
01233             }
01234             $header_xml = "<SOAP-ENV:Header>\r\n$header_xml\r\n</SOAP-ENV:Header>\r\n";
01235         }
01236 
01237         if (!isset($options['input']) || $options['input'] == 'parse') {
01238             if (is_array($method)) {
01239                 $c = count($method);
01240                 for ($i = 0; $i < $c; $i++) {
01241                     $smsg .= $method[$i]->serialize($this);
01242                 }
01243             } else {
01244                 $smsg = $method->serialize($this);
01245             }
01246         } else {
01247             $smsg = $method;
01248         }
01249         $body = "<SOAP-ENV:Body>\r\n" . $smsg . "\r\n</SOAP-ENV:Body>\r\n";
01250 
01251         foreach ($this->_namespaces as $k => $v) {
01252             $ns_string .= " xmlns:$v=\"$k\"\r\n";
01253         }
01254         if ($this->_namespace) {
01255             $ns_string .= " xmlns=\"{$this->_namespace}\"\r\n";
01256         }
01257 
01258         /* If 'use' == 'literal', we do not put in the encodingStyle.  This is
01259          * denoted by $this->_section5 being false.  'use' can be defined at a
01260          * more granular level than we are dealing with here, so this does not
01261          * work for all services. */
01262         $xml = "<?xml version=\"1.0\" encoding=\"$encoding\"?>\r\n\r\n".
01263             "<SOAP-ENV:Envelope $ns_string".
01264             ($this->_section5 ? ' SOAP-ENV:encodingStyle="' . SOAP_SCHEMA_ENCODING . '"' : '').
01265             ">\r\n".
01266             "$header_xml$body</SOAP-ENV:Envelope>\r\n";
01267 
01268         return $xml;
01269     }
01270 
01271     function _makeMimeMessage(&$xml, $encoding = SOAP_DEFAULT_ENCODING)
01272     {
01273         global $SOAP_options;
01274 
01275         if (!isset($SOAP_options['Mime'])) {
01276             return $this->_raiseSoapFault('Mime is not installed');
01277         }
01278 
01279         // Encode any attachments.
01280         // See http://www.w3.org/TR/SOAP-attachments
01281         // Now we have to mime encode the message.
01282         $params = array('content_type' => 'multipart/related; type=text/xml');
01283         $msg =& new Mail_mimePart('', $params);
01284 
01285         // Add the xml part.
01286         $params['content_type'] = 'text/xml';
01287         $params['charset'] = $encoding;
01288         $params['encoding'] = 'base64';
01289         $msg->addSubPart($xml, $params);
01290 
01291         // Add the attachements
01292         $c = count($this->__attachments);
01293         for ($i = 0; $i < $c; $i++) {
01294             $attachment =& $this->__attachments[$i];
01295             $msg->addSubPart($attachment['body'], $attachment);
01296         }
01297 
01298         return $msg->encode();
01299     }
01300 
01301     // TODO: this needs to be used from the Transport system.
01302     function _makeDIMEMessage($xml)
01303     {
01304         global $SOAP_options;
01305 
01306         if (!isset($SOAP_options['DIME'])) {
01307             return $this->_raiseSoapFault('DIME is not installed');
01308         }
01309 
01310         // Encode any attachments.
01311         // See http://search.ietf.org/internet-drafts/draft-nielsen-dime-soap-00.txt
01312         // Now we have to DIME encode the message
01313         $dime =& new Net_DIME_Message();
01314         $msg = $dime->encodeData($xml, SOAP_ENVELOP, null, NET_DIME_TYPE_URI);
01315 
01316         // Add the attachments.
01317         $c = count($this->__attachments);
01318         for ($i = 0; $i < $c; $i++) {
01319             $attachment =& $this->__attachments[$i];
01320             $msg .= $dime->encodeData($attachment['body'],
01321                                       $attachment['content_type'],
01322                                       $attachment['cid'],
01323                                       NET_DIME_TYPE_MEDIA);
01324         }
01325         $msg .= $dime->endMessage();
01326 
01327         return $msg;
01328     }
01329 
01330     function _decodeMimeMessage(&$data, &$headers, &$attachments)
01331     {
01332         global $SOAP_options;
01333 
01334         if (!isset($SOAP_options['Mime'])) {
01335             $this->_raiseSoapFault('Mime Unsupported, install PEAR::Mail::Mime', '', '', 'Server');
01336             return;
01337         }
01338 
01339         $params['include_bodies'] = true;
01340         $params['decode_bodies']  = true;
01341         $params['decode_headers'] = true;
01342 
01343         // Lame thing to have to do for decoding.
01344         $decoder =& new Mail_mimeDecode($data);
01345         $structure = $decoder->decode($params);
01346 
01347         if (isset($structure->body)) {
01348             $data = $structure->body;
01349             $headers = $structure->headers;
01350 
01351             return;
01352         } elseif (isset($structure->parts)) {
01353             $data = $structure->parts[0]->body;
01354             $headers = array_merge($structure->headers,
01355                                    $structure->parts[0]->headers);
01356             if (count($structure->parts) > 1) {
01357                 $mime_parts = array_splice($structure->parts,1);
01358                 // Prepare the parts for the SOAP parser.
01359 
01360                 $c = count($mime_parts);
01361                 for ($i = 0; $i < $c; $i++) {
01362                     $p =& $mime_parts[$i];
01363                     if (isset($p->headers['content-location'])) {
01364                         // TODO: modify location per SwA note section 3
01365                         // http://www.w3.org/TR/SOAP-attachments
01366                         $attachments[$p->headers['content-location']] = $p->body;
01367                     } else {
01368                         $cid = 'cid:' . substr($p->headers['content-id'], 1, -1);
01369                         $attachments[$cid] = $p->body;
01370                     }
01371                 }
01372             }
01373 
01374             return;
01375         }
01376 
01377         $this->_raiseSoapFault('Mime parsing error', '', '', 'Server');
01378     }
01379 
01380     function _decodeDIMEMessage(&$data, &$headers, &$attachments)
01381     {
01382         global $SOAP_options;
01383 
01384         if (!isset($SOAP_options['DIME'])) {
01385             $this->_raiseSoapFault('DIME Unsupported, install PEAR::Net::DIME', '', '', 'Server');
01386             return;
01387         }
01388 
01389         // This SHOULD be moved to the transport layer, e.g. PHP itself should
01390         // handle parsing DIME ;)
01391         $dime =& new Net_DIME_Message();
01392         $err = $dime->decodeData($data);
01393         if (PEAR::isError($err)) {
01394             $this->_raiseSoapFault('Failed to decode the DIME message!', '', '', 'Server');
01395             return;
01396         }
01397         if (strcasecmp($dime->parts[0]['type'], SOAP_ENVELOP) != 0) {
01398             $this->_raiseSoapFault('DIME record 1 is not a SOAP envelop!', '', '', 'Server');
01399             return;
01400         }
01401 
01402         $data = $dime->parts[0]['data'];
01403         // Fake it for now.
01404         $headers['content-type'] = 'text/xml';
01405         $c = count($dime->parts);
01406         for ($i = 0; $i < $c; $i++) {
01407             $part =& $dime->parts[$i];
01408             // We need to handle URI's better.
01409             $id = strncmp($part['id'], 'cid:', 4)
01410                 ? 'cid:' . $part['id']
01411                 : $part['id'];
01412             $attachments[$id] = $part['data'];
01413         }
01414     }
01415 
01416     function __set_type_translation($type, $class = null)
01417     {
01418         $tq =& new QName($type);
01419         if (!$class) {
01420             $class = $tq->name;
01421         }
01422         $this->_type_translation[$type]=$class;
01423     }
01424 
01425 }
01426 
01434 class QName
01435 {
01436     var $name = '';
01437     var $ns = '';
01438     var $namespace='';
01439 
01440     function QName($name, $namespace = '')
01441     {
01442         if ($name && $name[0] == '{') {
01443             preg_match('/\{(.*?)\}(.*)/', $name, $m);
01444             $this->name = $m[2];
01445             $this->namespace = $m[1];
01446         } elseif (substr_count($name, ':') == 1) {
01447             $s = explode(':', $name);
01448             $s = array_reverse($s);
01449             $this->name = $s[0];
01450             $this->ns = $s[1];
01451             $this->namespace = $namespace;
01452         } else {
01453             $this->name = $name;
01454             $this->namespace = $namespace;
01455         }
01456 
01457         // A little more magic than should be in a qname.
01458         $p = strpos($this->name, '[');
01459         if ($p) {
01460             // TODO: Need to re-examine this logic later.
01461             // Chop off [].
01462             $this->arraySize = explode(',', substr($this->name, $p + 1, -$p - 2));
01463             $this->arrayInfo = substr($this->name, $p);
01464             $this->name = substr($this->name, 0, $p);
01465         }
01466     }
01467 
01468     function fqn()
01469     {
01470         if ($this->namespace) {
01471             return '{' . $this->namespace . '}' . $this->name;
01472         } elseif ($this->ns) {
01473             return $this->ns . ':' . $this->name;
01474         }
01475         return $this->name;
01476     }
01477 
01478 }

Generated on Fri Dec 13 2013 17:56:54 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1