Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezsoapcodec.php
Go to the documentation of this file.
1 <?php
17 class eZSOAPCodec
18 {
23 static function encodeValue( $doc, $name, $value )
24 {
25 switch ( gettype( $value ) )
26 {
27 case "string" :
28 {
29 $node = $doc->createElement( $name );
30 $node->appendChild( $doc->createTextNode( $value ) );
31 $node->setAttribute( eZSOAPEnvelope::XSI_PREFIX . ':type',
32 eZSOAPEnvelope::XSD_PREFIX . ':string' );
33 return $node;
34 } break;
35
36 case "boolean" :
37 {
38 $node = $doc->createElement( $name );
39 $node->appendChild( $doc->createTextNode( $value ? 'true' : 'false' ) );
40 $node->setAttribute( eZSOAPEnvelope::XSI_PREFIX . ':type',
41 eZSOAPEnvelope::XSD_PREFIX . ':boolean' );
42 return $node;
43 } break;
44
45 case "integer" :
46 {
47 $node = $doc->createElement( $name );
48 $node->appendChild( $doc->createTextNode( $value ) );
49 $node->setAttribute( eZSOAPEnvelope::XSI_PREFIX . ':type',
50 eZSOAPEnvelope::XSD_PREFIX . ':int' );
51 return $node;
52 } break;
53
54 case "double" :
55 {
56 $node = $doc->createElement( $name );
57 $node->appendChild( $doc->createTextNode( $value ) );
58 $node->setAttribute( eZSOAPEnvelope::XSI_PREFIX . ':type',
59 eZSOAPEnvelope::XSD_PREFIX . ':float' );
60 return $node;
61 } break;
62
63 case "array" :
64 {
65 $arrayCount = count( $value );
66
67 $isStruct = false;
68 // Check for struct
69 $i = 0;
70 foreach( $value as $key => $val )
71 {
72 if ( $i !== $key )
73 {
74 $isStruct = true;
75 break;
76 }
77 $i++;
78 }
79
80 if ( $isStruct == true )
81 {
82 $node = $doc->createElement( $name );
83 $node->setAttribute( eZSOAPEnvelope::XSI_PREFIX . ':type',
84 eZSOAPEnvelope::ENC_PREFIX . ':SOAPStruct' );
85
86 foreach( $value as $key => $val )
87 {
88 $subNode = eZSOAPCodec::encodeValue( $doc, (string)$key, $val );
89 $node->appendChild( $subNode );
90 }
91 return $node;
92 }
93 else
94 {
95 $node = $doc->createElement( $name );
96 $node->setAttribute( eZSOAPEnvelope::XSI_PREFIX . ':type',
97 eZSOAPEnvelope::ENC_PREFIX . ':Array' );
98 $node->setAttribute( eZSOAPEnvelope::ENC_PREFIX . ':arrayType',
99 eZSOAPEnvelope::XSD_PREFIX . ":string[$arrayCount]" );
100
101 foreach ( $value as $arrayItem )
102 {
103 $subNode = eZSOAPCodec::encodeValue( $doc, "item", $arrayItem );
104 $node->appendChild( $subNode );
105 }
106
107 return $node;
108 }
109 } break;
110 }
111
112 return false;
113 }
114 }
115
116 ?>
eZSOAPCodec
The class eZSOAPCodec does.
Definition: ezsoapcodec.php:18
eZSOAPCodec\encodeValue
static encodeValue( $doc, $name, $value)
Definition: ezsoapcodec.php:23
eZSOAPEnvelope\XSI_PREFIX
const XSI_PREFIX
Definition: ezsoapenvelope.php:29
eZSOAPEnvelope\ENC_PREFIX
const ENC_PREFIX
Definition: ezsoapenvelope.php:28
eZSOAPEnvelope\XSD_PREFIX
const XSD_PREFIX
Definition: ezsoapenvelope.php:30
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.