@@ -83,810 +83,810 @@ discard block |
||
83 | 83 | * @access public |
84 | 84 | */ |
85 | 85 | class nusoap_base { |
86 | - /** |
|
87 | - * Identification for HTTP headers. |
|
88 | - * |
|
89 | - * @var string |
|
90 | - * @access private |
|
91 | - */ |
|
92 | - var $title = 'NuSOAP'; |
|
93 | - /** |
|
94 | - * Version for HTTP headers. |
|
95 | - * |
|
96 | - * @var string |
|
97 | - * @access private |
|
98 | - */ |
|
99 | - var $version = '0.9.5'; |
|
100 | - /** |
|
101 | - * CVS revision for HTTP headers. |
|
102 | - * |
|
103 | - * @var string |
|
104 | - * @access private |
|
105 | - */ |
|
106 | - var $revision = '$Revision: 1.56 $'; |
|
86 | + /** |
|
87 | + * Identification for HTTP headers. |
|
88 | + * |
|
89 | + * @var string |
|
90 | + * @access private |
|
91 | + */ |
|
92 | + var $title = 'NuSOAP'; |
|
93 | + /** |
|
94 | + * Version for HTTP headers. |
|
95 | + * |
|
96 | + * @var string |
|
97 | + * @access private |
|
98 | + */ |
|
99 | + var $version = '0.9.5'; |
|
100 | + /** |
|
101 | + * CVS revision for HTTP headers. |
|
102 | + * |
|
103 | + * @var string |
|
104 | + * @access private |
|
105 | + */ |
|
106 | + var $revision = '$Revision: 1.56 $'; |
|
107 | 107 | /** |
108 | 108 | * Current error string (manipulated by getError/setError) |
109 | - * |
|
110 | - * @var string |
|
111 | - * @access private |
|
112 | - */ |
|
113 | - var $error_str = ''; |
|
109 | + * |
|
110 | + * @var string |
|
111 | + * @access private |
|
112 | + */ |
|
113 | + var $error_str = ''; |
|
114 | 114 | /** |
115 | 115 | * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment) |
116 | - * |
|
117 | - * @var string |
|
118 | - * @access private |
|
119 | - */ |
|
116 | + * |
|
117 | + * @var string |
|
118 | + * @access private |
|
119 | + */ |
|
120 | 120 | var $debug_str = ''; |
121 | 121 | /** |
122 | - * toggles automatic encoding of special characters as entities |
|
123 | - * (should always be true, I think) |
|
124 | - * |
|
125 | - * @var boolean |
|
126 | - * @access private |
|
127 | - */ |
|
128 | - var $charencoding = true; |
|
129 | - /** |
|
130 | - * the debug level for this instance |
|
131 | - * |
|
132 | - * @var integer |
|
133 | - * @access private |
|
134 | - */ |
|
135 | - var $debugLevel; |
|
136 | - |
|
137 | - /** |
|
138 | - * set schema version |
|
139 | - * |
|
140 | - * @var string |
|
141 | - * @access public |
|
142 | - */ |
|
143 | - var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; |
|
144 | - |
|
145 | - /** |
|
146 | - * charset encoding for outgoing messages |
|
147 | - * |
|
148 | - * @var string |
|
149 | - * @access public |
|
150 | - */ |
|
122 | + * toggles automatic encoding of special characters as entities |
|
123 | + * (should always be true, I think) |
|
124 | + * |
|
125 | + * @var boolean |
|
126 | + * @access private |
|
127 | + */ |
|
128 | + var $charencoding = true; |
|
129 | + /** |
|
130 | + * the debug level for this instance |
|
131 | + * |
|
132 | + * @var integer |
|
133 | + * @access private |
|
134 | + */ |
|
135 | + var $debugLevel; |
|
136 | + |
|
137 | + /** |
|
138 | + * set schema version |
|
139 | + * |
|
140 | + * @var string |
|
141 | + * @access public |
|
142 | + */ |
|
143 | + var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; |
|
144 | + |
|
145 | + /** |
|
146 | + * charset encoding for outgoing messages |
|
147 | + * |
|
148 | + * @var string |
|
149 | + * @access public |
|
150 | + */ |
|
151 | 151 | var $soap_defencoding = 'ISO-8859-1'; |
152 | - //var $soap_defencoding = 'UTF-8'; |
|
153 | - |
|
154 | - /** |
|
155 | - * namespaces in an array of prefix => uri |
|
156 | - * |
|
157 | - * this is "seeded" by a set of constants, but it may be altered by code |
|
158 | - * |
|
159 | - * @var array |
|
160 | - * @access public |
|
161 | - */ |
|
162 | - var $namespaces = array( |
|
163 | - 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', |
|
164 | - 'xsd' => 'http://www.w3.org/2001/XMLSchema', |
|
165 | - 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance', |
|
166 | - 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/' |
|
167 | - ); |
|
168 | - |
|
169 | - /** |
|
170 | - * namespaces used in the current context, e.g. during serialization |
|
171 | - * |
|
172 | - * @var array |
|
173 | - * @access private |
|
174 | - */ |
|
175 | - var $usedNamespaces = array(); |
|
176 | - |
|
177 | - /** |
|
178 | - * XML Schema types in an array of uri => (array of xml type => php type) |
|
179 | - * is this legacy yet? |
|
180 | - * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings. |
|
181 | - * @var array |
|
182 | - * @access public |
|
183 | - */ |
|
184 | - var $typemap = array( |
|
185 | - 'http://www.w3.org/2001/XMLSchema' => array( |
|
186 | - 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', |
|
187 | - 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'', |
|
188 | - 'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string', |
|
189 | - // abstract "any" types |
|
190 | - 'anyType'=>'string','anySimpleType'=>'string', |
|
191 | - // derived datatypes |
|
192 | - 'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'', |
|
193 | - 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer', |
|
194 | - 'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer', |
|
195 | - 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''), |
|
196 | - 'http://www.w3.org/2000/10/XMLSchema' => array( |
|
197 | - 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
198 | - 'float'=>'double','dateTime'=>'string', |
|
199 | - 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
200 | - 'http://www.w3.org/1999/XMLSchema' => array( |
|
201 | - 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
202 | - 'float'=>'double','dateTime'=>'string', |
|
203 | - 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
204 | - 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'), |
|
205 | - 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'), |
|
152 | + //var $soap_defencoding = 'UTF-8'; |
|
153 | + |
|
154 | + /** |
|
155 | + * namespaces in an array of prefix => uri |
|
156 | + * |
|
157 | + * this is "seeded" by a set of constants, but it may be altered by code |
|
158 | + * |
|
159 | + * @var array |
|
160 | + * @access public |
|
161 | + */ |
|
162 | + var $namespaces = array( |
|
163 | + 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', |
|
164 | + 'xsd' => 'http://www.w3.org/2001/XMLSchema', |
|
165 | + 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance', |
|
166 | + 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/' |
|
167 | + ); |
|
168 | + |
|
169 | + /** |
|
170 | + * namespaces used in the current context, e.g. during serialization |
|
171 | + * |
|
172 | + * @var array |
|
173 | + * @access private |
|
174 | + */ |
|
175 | + var $usedNamespaces = array(); |
|
176 | + |
|
177 | + /** |
|
178 | + * XML Schema types in an array of uri => (array of xml type => php type) |
|
179 | + * is this legacy yet? |
|
180 | + * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings. |
|
181 | + * @var array |
|
182 | + * @access public |
|
183 | + */ |
|
184 | + var $typemap = array( |
|
185 | + 'http://www.w3.org/2001/XMLSchema' => array( |
|
186 | + 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', |
|
187 | + 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'', |
|
188 | + 'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string', |
|
189 | + // abstract "any" types |
|
190 | + 'anyType'=>'string','anySimpleType'=>'string', |
|
191 | + // derived datatypes |
|
192 | + 'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'', |
|
193 | + 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer', |
|
194 | + 'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer', |
|
195 | + 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''), |
|
196 | + 'http://www.w3.org/2000/10/XMLSchema' => array( |
|
197 | + 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
198 | + 'float'=>'double','dateTime'=>'string', |
|
199 | + 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
200 | + 'http://www.w3.org/1999/XMLSchema' => array( |
|
201 | + 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
202 | + 'float'=>'double','dateTime'=>'string', |
|
203 | + 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
204 | + 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'), |
|
205 | + 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'), |
|
206 | 206 | 'http://xml.apache.org/xml-soap' => array('Map') |
207 | - ); |
|
208 | - |
|
209 | - /** |
|
210 | - * XML entities to convert |
|
211 | - * |
|
212 | - * @var array |
|
213 | - * @access public |
|
214 | - * @deprecated |
|
215 | - * @see expandEntities |
|
216 | - */ |
|
217 | - var $xmlEntities = array('quot' => '"','amp' => '&', |
|
218 | - 'lt' => '<','gt' => '>','apos' => "'"); |
|
219 | - |
|
220 | - /** |
|
221 | - * constructor |
|
222 | - * |
|
223 | - * @access public |
|
224 | - */ |
|
225 | - function nusoap_base() { |
|
226 | - $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * gets the global debug level, which applies to future instances |
|
231 | - * |
|
232 | - * @return integer Debug level 0-9, where 0 turns off |
|
233 | - * @access public |
|
234 | - */ |
|
235 | - function getGlobalDebugLevel() { |
|
236 | - return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
|
237 | - } |
|
238 | - |
|
239 | - /** |
|
240 | - * sets the global debug level, which applies to future instances |
|
241 | - * |
|
242 | - * @param int $level Debug level 0-9, where 0 turns off |
|
243 | - * @access public |
|
244 | - */ |
|
245 | - function setGlobalDebugLevel($level) { |
|
246 | - $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level; |
|
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * gets the debug level for this instance |
|
251 | - * |
|
252 | - * @return int Debug level 0-9, where 0 turns off |
|
253 | - * @access public |
|
254 | - */ |
|
255 | - function getDebugLevel() { |
|
256 | - return $this->debugLevel; |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * sets the debug level for this instance |
|
261 | - * |
|
262 | - * @param int $level Debug level 0-9, where 0 turns off |
|
263 | - * @access public |
|
264 | - */ |
|
265 | - function setDebugLevel($level) { |
|
266 | - $this->debugLevel = $level; |
|
267 | - } |
|
268 | - |
|
269 | - /** |
|
270 | - * adds debug data to the instance debug string with formatting |
|
271 | - * |
|
272 | - * @param string $string debug data |
|
273 | - * @access private |
|
274 | - */ |
|
275 | - function debug($string){ |
|
276 | - if ($this->debugLevel > 0) { |
|
277 | - $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n"); |
|
278 | - } |
|
279 | - } |
|
280 | - |
|
281 | - /** |
|
282 | - * adds debug data to the instance debug string without formatting |
|
283 | - * |
|
284 | - * @param string $string debug data |
|
285 | - * @access public |
|
286 | - */ |
|
287 | - function appendDebug($string){ |
|
288 | - if ($this->debugLevel > 0) { |
|
289 | - // it would be nice to use a memory stream here to use |
|
290 | - // memory more efficiently |
|
291 | - $this->debug_str .= $string; |
|
292 | - } |
|
293 | - } |
|
294 | - |
|
295 | - /** |
|
296 | - * clears the current debug data for this instance |
|
297 | - * |
|
298 | - * @access public |
|
299 | - */ |
|
300 | - function clearDebug() { |
|
301 | - // it would be nice to use a memory stream here to use |
|
302 | - // memory more efficiently |
|
303 | - $this->debug_str = ''; |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * gets the current debug data for this instance |
|
308 | - * |
|
309 | - * @return debug data |
|
310 | - * @access public |
|
311 | - */ |
|
312 | - function &getDebug() { |
|
313 | - // it would be nice to use a memory stream here to use |
|
314 | - // memory more efficiently |
|
315 | - return $this->debug_str; |
|
316 | - } |
|
317 | - |
|
318 | - /** |
|
319 | - * gets the current debug data for this instance as an XML comment |
|
320 | - * this may change the contents of the debug data |
|
321 | - * |
|
322 | - * @return debug data as an XML comment |
|
323 | - * @access public |
|
324 | - */ |
|
325 | - function &getDebugAsXMLComment() { |
|
326 | - // it would be nice to use a memory stream here to use |
|
327 | - // memory more efficiently |
|
328 | - while (strpos($this->debug_str, '--')) { |
|
329 | - $this->debug_str = str_replace('--', '- -', $this->debug_str); |
|
330 | - } |
|
331 | - $ret = "<!--\n" . $this->debug_str . "\n-->"; |
|
332 | - return $ret; |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * expands entities, e.g. changes '<' to '<'. |
|
337 | - * |
|
338 | - * @param string $val The string in which to expand entities. |
|
339 | - * @access private |
|
340 | - */ |
|
341 | - function expandEntities($val) { |
|
342 | - if ($this->charencoding) { |
|
343 | - $val = str_replace('&', '&', $val); |
|
344 | - $val = str_replace("'", ''', $val); |
|
345 | - $val = str_replace('"', '"', $val); |
|
346 | - $val = str_replace('<', '<', $val); |
|
347 | - $val = str_replace('>', '>', $val); |
|
348 | - } |
|
349 | - return $val; |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * returns error string if present |
|
354 | - * |
|
355 | - * @return mixed error string or false |
|
356 | - * @access public |
|
357 | - */ |
|
358 | - function getError(){ |
|
359 | - if($this->error_str != ''){ |
|
360 | - return $this->error_str; |
|
361 | - } |
|
362 | - return false; |
|
363 | - } |
|
364 | - |
|
365 | - /** |
|
366 | - * sets error string |
|
367 | - * |
|
368 | - * @return boolean $string error string |
|
369 | - * @access private |
|
370 | - */ |
|
371 | - function setError($str){ |
|
372 | - $this->error_str = $str; |
|
373 | - } |
|
374 | - |
|
375 | - /** |
|
376 | - * detect if array is a simple array or a struct (associative array) |
|
377 | - * |
|
378 | - * @param mixed $val The PHP array |
|
379 | - * @return string (arraySimple|arrayStruct) |
|
380 | - * @access private |
|
381 | - */ |
|
382 | - function isArraySimpleOrStruct($val) { |
|
207 | + ); |
|
208 | + |
|
209 | + /** |
|
210 | + * XML entities to convert |
|
211 | + * |
|
212 | + * @var array |
|
213 | + * @access public |
|
214 | + * @deprecated |
|
215 | + * @see expandEntities |
|
216 | + */ |
|
217 | + var $xmlEntities = array('quot' => '"','amp' => '&', |
|
218 | + 'lt' => '<','gt' => '>','apos' => "'"); |
|
219 | + |
|
220 | + /** |
|
221 | + * constructor |
|
222 | + * |
|
223 | + * @access public |
|
224 | + */ |
|
225 | + function nusoap_base() { |
|
226 | + $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * gets the global debug level, which applies to future instances |
|
231 | + * |
|
232 | + * @return integer Debug level 0-9, where 0 turns off |
|
233 | + * @access public |
|
234 | + */ |
|
235 | + function getGlobalDebugLevel() { |
|
236 | + return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
|
237 | + } |
|
238 | + |
|
239 | + /** |
|
240 | + * sets the global debug level, which applies to future instances |
|
241 | + * |
|
242 | + * @param int $level Debug level 0-9, where 0 turns off |
|
243 | + * @access public |
|
244 | + */ |
|
245 | + function setGlobalDebugLevel($level) { |
|
246 | + $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level; |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * gets the debug level for this instance |
|
251 | + * |
|
252 | + * @return int Debug level 0-9, where 0 turns off |
|
253 | + * @access public |
|
254 | + */ |
|
255 | + function getDebugLevel() { |
|
256 | + return $this->debugLevel; |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * sets the debug level for this instance |
|
261 | + * |
|
262 | + * @param int $level Debug level 0-9, where 0 turns off |
|
263 | + * @access public |
|
264 | + */ |
|
265 | + function setDebugLevel($level) { |
|
266 | + $this->debugLevel = $level; |
|
267 | + } |
|
268 | + |
|
269 | + /** |
|
270 | + * adds debug data to the instance debug string with formatting |
|
271 | + * |
|
272 | + * @param string $string debug data |
|
273 | + * @access private |
|
274 | + */ |
|
275 | + function debug($string){ |
|
276 | + if ($this->debugLevel > 0) { |
|
277 | + $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n"); |
|
278 | + } |
|
279 | + } |
|
280 | + |
|
281 | + /** |
|
282 | + * adds debug data to the instance debug string without formatting |
|
283 | + * |
|
284 | + * @param string $string debug data |
|
285 | + * @access public |
|
286 | + */ |
|
287 | + function appendDebug($string){ |
|
288 | + if ($this->debugLevel > 0) { |
|
289 | + // it would be nice to use a memory stream here to use |
|
290 | + // memory more efficiently |
|
291 | + $this->debug_str .= $string; |
|
292 | + } |
|
293 | + } |
|
294 | + |
|
295 | + /** |
|
296 | + * clears the current debug data for this instance |
|
297 | + * |
|
298 | + * @access public |
|
299 | + */ |
|
300 | + function clearDebug() { |
|
301 | + // it would be nice to use a memory stream here to use |
|
302 | + // memory more efficiently |
|
303 | + $this->debug_str = ''; |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * gets the current debug data for this instance |
|
308 | + * |
|
309 | + * @return debug data |
|
310 | + * @access public |
|
311 | + */ |
|
312 | + function &getDebug() { |
|
313 | + // it would be nice to use a memory stream here to use |
|
314 | + // memory more efficiently |
|
315 | + return $this->debug_str; |
|
316 | + } |
|
317 | + |
|
318 | + /** |
|
319 | + * gets the current debug data for this instance as an XML comment |
|
320 | + * this may change the contents of the debug data |
|
321 | + * |
|
322 | + * @return debug data as an XML comment |
|
323 | + * @access public |
|
324 | + */ |
|
325 | + function &getDebugAsXMLComment() { |
|
326 | + // it would be nice to use a memory stream here to use |
|
327 | + // memory more efficiently |
|
328 | + while (strpos($this->debug_str, '--')) { |
|
329 | + $this->debug_str = str_replace('--', '- -', $this->debug_str); |
|
330 | + } |
|
331 | + $ret = "<!--\n" . $this->debug_str . "\n-->"; |
|
332 | + return $ret; |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * expands entities, e.g. changes '<' to '<'. |
|
337 | + * |
|
338 | + * @param string $val The string in which to expand entities. |
|
339 | + * @access private |
|
340 | + */ |
|
341 | + function expandEntities($val) { |
|
342 | + if ($this->charencoding) { |
|
343 | + $val = str_replace('&', '&', $val); |
|
344 | + $val = str_replace("'", ''', $val); |
|
345 | + $val = str_replace('"', '"', $val); |
|
346 | + $val = str_replace('<', '<', $val); |
|
347 | + $val = str_replace('>', '>', $val); |
|
348 | + } |
|
349 | + return $val; |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * returns error string if present |
|
354 | + * |
|
355 | + * @return mixed error string or false |
|
356 | + * @access public |
|
357 | + */ |
|
358 | + function getError(){ |
|
359 | + if($this->error_str != ''){ |
|
360 | + return $this->error_str; |
|
361 | + } |
|
362 | + return false; |
|
363 | + } |
|
364 | + |
|
365 | + /** |
|
366 | + * sets error string |
|
367 | + * |
|
368 | + * @return boolean $string error string |
|
369 | + * @access private |
|
370 | + */ |
|
371 | + function setError($str){ |
|
372 | + $this->error_str = $str; |
|
373 | + } |
|
374 | + |
|
375 | + /** |
|
376 | + * detect if array is a simple array or a struct (associative array) |
|
377 | + * |
|
378 | + * @param mixed $val The PHP array |
|
379 | + * @return string (arraySimple|arrayStruct) |
|
380 | + * @access private |
|
381 | + */ |
|
382 | + function isArraySimpleOrStruct($val) { |
|
383 | 383 | $keyList = array_keys($val); |
384 | - foreach ($keyList as $keyListValue) { |
|
385 | - if (!is_int($keyListValue)) { |
|
386 | - return 'arrayStruct'; |
|
387 | - } |
|
388 | - } |
|
389 | - return 'arraySimple'; |
|
390 | - } |
|
391 | - |
|
392 | - /** |
|
393 | - * serializes PHP values in accordance w/ section 5. Type information is |
|
394 | - * not serialized if $use == 'literal'. |
|
395 | - * |
|
396 | - * @param mixed $val The value to serialize |
|
397 | - * @param string $name The name (local part) of the XML element |
|
398 | - * @param string $type The XML schema type (local part) for the element |
|
399 | - * @param string $name_ns The namespace for the name of the XML element |
|
400 | - * @param string $type_ns The namespace for the type of the element |
|
401 | - * @param array $attributes The attributes to serialize as name=>value pairs |
|
402 | - * @param string $use The WSDL "use" (encoded|literal) |
|
403 | - * @param boolean $soapval Whether this is called from soapval. |
|
404 | - * @return string The serialized element, possibly with child elements |
|
405 | - * @access public |
|
406 | - */ |
|
407 | - function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) { |
|
408 | - $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval"); |
|
409 | - $this->appendDebug('value=' . $this->varDump($val)); |
|
410 | - $this->appendDebug('attributes=' . $this->varDump($attributes)); |
|
411 | - |
|
412 | - if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) { |
|
413 | - $this->debug("serialize_val: serialize soapval"); |
|
414 | - $xml = $val->serialize($use); |
|
415 | - $this->appendDebug($val->getDebug()); |
|
416 | - $val->clearDebug(); |
|
417 | - $this->debug("serialize_val of soapval returning $xml"); |
|
418 | - return $xml; |
|
384 | + foreach ($keyList as $keyListValue) { |
|
385 | + if (!is_int($keyListValue)) { |
|
386 | + return 'arrayStruct'; |
|
387 | + } |
|
419 | 388 | } |
420 | - // force valid name if necessary |
|
421 | - if (is_numeric($name)) { |
|
422 | - $name = '__numeric_' . $name; |
|
423 | - } elseif (! $name) { |
|
424 | - $name = 'noname'; |
|
425 | - } |
|
426 | - // if name has ns, add ns prefix to name |
|
427 | - $xmlns = ''; |
|
389 | + return 'arraySimple'; |
|
390 | + } |
|
391 | + |
|
392 | + /** |
|
393 | + * serializes PHP values in accordance w/ section 5. Type information is |
|
394 | + * not serialized if $use == 'literal'. |
|
395 | + * |
|
396 | + * @param mixed $val The value to serialize |
|
397 | + * @param string $name The name (local part) of the XML element |
|
398 | + * @param string $type The XML schema type (local part) for the element |
|
399 | + * @param string $name_ns The namespace for the name of the XML element |
|
400 | + * @param string $type_ns The namespace for the type of the element |
|
401 | + * @param array $attributes The attributes to serialize as name=>value pairs |
|
402 | + * @param string $use The WSDL "use" (encoded|literal) |
|
403 | + * @param boolean $soapval Whether this is called from soapval. |
|
404 | + * @return string The serialized element, possibly with child elements |
|
405 | + * @access public |
|
406 | + */ |
|
407 | + function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) { |
|
408 | + $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval"); |
|
409 | + $this->appendDebug('value=' . $this->varDump($val)); |
|
410 | + $this->appendDebug('attributes=' . $this->varDump($attributes)); |
|
411 | + |
|
412 | + if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) { |
|
413 | + $this->debug("serialize_val: serialize soapval"); |
|
414 | + $xml = $val->serialize($use); |
|
415 | + $this->appendDebug($val->getDebug()); |
|
416 | + $val->clearDebug(); |
|
417 | + $this->debug("serialize_val of soapval returning $xml"); |
|
418 | + return $xml; |
|
419 | + } |
|
420 | + // force valid name if necessary |
|
421 | + if (is_numeric($name)) { |
|
422 | + $name = '__numeric_' . $name; |
|
423 | + } elseif (! $name) { |
|
424 | + $name = 'noname'; |
|
425 | + } |
|
426 | + // if name has ns, add ns prefix to name |
|
427 | + $xmlns = ''; |
|
428 | 428 | if($name_ns){ |
429 | - $prefix = 'nu'.rand(1000,9999); |
|
430 | - $name = $prefix.':'.$name; |
|
431 | - $xmlns .= " xmlns:$prefix=\"$name_ns\""; |
|
432 | - } |
|
433 | - // if type is prefixed, create type prefix |
|
434 | - if($type_ns != '' && $type_ns == $this->namespaces['xsd']){ |
|
435 | - // need to fix this. shouldn't default to xsd if no ns specified |
|
436 | - // w/o checking against typemap |
|
437 | - $type_prefix = 'xsd'; |
|
438 | - } elseif($type_ns){ |
|
439 | - $type_prefix = 'ns'.rand(1000,9999); |
|
440 | - $xmlns .= " xmlns:$type_prefix=\"$type_ns\""; |
|
441 | - } |
|
442 | - // serialize attributes if present |
|
443 | - $atts = ''; |
|
444 | - if($attributes){ |
|
445 | - foreach($attributes as $k => $v){ |
|
446 | - $atts .= " $k=\"".$this->expandEntities($v).'"'; |
|
447 | - } |
|
448 | - } |
|
449 | - // serialize null value |
|
450 | - if (is_null($val)) { |
|
451 | - $this->debug("serialize_val: serialize null"); |
|
452 | - if ($use == 'literal') { |
|
453 | - // TODO: depends on minOccurs |
|
454 | - $xml = "<$name$xmlns$atts/>"; |
|
455 | - $this->debug("serialize_val returning $xml"); |
|
456 | - return $xml; |
|
457 | - } else { |
|
458 | - if (isset($type) && isset($type_prefix)) { |
|
459 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
460 | - } else { |
|
461 | - $type_str = ''; |
|
462 | - } |
|
463 | - $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>"; |
|
464 | - $this->debug("serialize_val returning $xml"); |
|
465 | - return $xml; |
|
466 | - } |
|
467 | - } |
|
429 | + $prefix = 'nu'.rand(1000,9999); |
|
430 | + $name = $prefix.':'.$name; |
|
431 | + $xmlns .= " xmlns:$prefix=\"$name_ns\""; |
|
432 | + } |
|
433 | + // if type is prefixed, create type prefix |
|
434 | + if($type_ns != '' && $type_ns == $this->namespaces['xsd']){ |
|
435 | + // need to fix this. shouldn't default to xsd if no ns specified |
|
436 | + // w/o checking against typemap |
|
437 | + $type_prefix = 'xsd'; |
|
438 | + } elseif($type_ns){ |
|
439 | + $type_prefix = 'ns'.rand(1000,9999); |
|
440 | + $xmlns .= " xmlns:$type_prefix=\"$type_ns\""; |
|
441 | + } |
|
442 | + // serialize attributes if present |
|
443 | + $atts = ''; |
|
444 | + if($attributes){ |
|
445 | + foreach($attributes as $k => $v){ |
|
446 | + $atts .= " $k=\"".$this->expandEntities($v).'"'; |
|
447 | + } |
|
448 | + } |
|
449 | + // serialize null value |
|
450 | + if (is_null($val)) { |
|
451 | + $this->debug("serialize_val: serialize null"); |
|
452 | + if ($use == 'literal') { |
|
453 | + // TODO: depends on minOccurs |
|
454 | + $xml = "<$name$xmlns$atts/>"; |
|
455 | + $this->debug("serialize_val returning $xml"); |
|
456 | + return $xml; |
|
457 | + } else { |
|
458 | + if (isset($type) && isset($type_prefix)) { |
|
459 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
460 | + } else { |
|
461 | + $type_str = ''; |
|
462 | + } |
|
463 | + $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>"; |
|
464 | + $this->debug("serialize_val returning $xml"); |
|
465 | + return $xml; |
|
466 | + } |
|
467 | + } |
|
468 | 468 | // serialize if an xsd built-in primitive type |
469 | 469 | if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){ |
470 | - $this->debug("serialize_val: serialize xsd built-in primitive type"); |
|
471 | - if (is_bool($val)) { |
|
472 | - if ($type == 'boolean') { |
|
473 | - $val = $val ? 'true' : 'false'; |
|
474 | - } elseif (! $val) { |
|
475 | - $val = 0; |
|
476 | - } |
|
477 | - } else if (is_string($val)) { |
|
478 | - $val = $this->expandEntities($val); |
|
479 | - } |
|
480 | - if ($use == 'literal') { |
|
481 | - $xml = "<$name$xmlns$atts>$val</$name>"; |
|
482 | - $this->debug("serialize_val returning $xml"); |
|
483 | - return $xml; |
|
484 | - } else { |
|
485 | - $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>"; |
|
486 | - $this->debug("serialize_val returning $xml"); |
|
487 | - return $xml; |
|
488 | - } |
|
470 | + $this->debug("serialize_val: serialize xsd built-in primitive type"); |
|
471 | + if (is_bool($val)) { |
|
472 | + if ($type == 'boolean') { |
|
473 | + $val = $val ? 'true' : 'false'; |
|
474 | + } elseif (! $val) { |
|
475 | + $val = 0; |
|
476 | + } |
|
477 | + } else if (is_string($val)) { |
|
478 | + $val = $this->expandEntities($val); |
|
479 | + } |
|
480 | + if ($use == 'literal') { |
|
481 | + $xml = "<$name$xmlns$atts>$val</$name>"; |
|
482 | + $this->debug("serialize_val returning $xml"); |
|
483 | + return $xml; |
|
484 | + } else { |
|
485 | + $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>"; |
|
486 | + $this->debug("serialize_val returning $xml"); |
|
487 | + return $xml; |
|
488 | + } |
|
489 | 489 | } |
490 | - // detect type and serialize |
|
491 | - $xml = ''; |
|
492 | - switch(true) { |
|
493 | - case (is_bool($val) || $type == 'boolean'): |
|
494 | - $this->debug("serialize_val: serialize boolean"); |
|
495 | - if ($type == 'boolean') { |
|
496 | - $val = $val ? 'true' : 'false'; |
|
497 | - } elseif (! $val) { |
|
498 | - $val = 0; |
|
499 | - } |
|
500 | - if ($use == 'literal') { |
|
501 | - $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
502 | - } else { |
|
503 | - $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>"; |
|
504 | - } |
|
505 | - break; |
|
506 | - case (is_int($val) || is_long($val) || $type == 'int'): |
|
507 | - $this->debug("serialize_val: serialize int"); |
|
508 | - if ($use == 'literal') { |
|
509 | - $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
510 | - } else { |
|
511 | - $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>"; |
|
512 | - } |
|
513 | - break; |
|
514 | - case (is_float($val)|| is_double($val) || $type == 'float'): |
|
515 | - $this->debug("serialize_val: serialize float"); |
|
516 | - if ($use == 'literal') { |
|
517 | - $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
518 | - } else { |
|
519 | - $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>"; |
|
520 | - } |
|
521 | - break; |
|
522 | - case (is_string($val) || $type == 'string'): |
|
523 | - $this->debug("serialize_val: serialize string"); |
|
524 | - $val = $this->expandEntities($val); |
|
525 | - if ($use == 'literal') { |
|
526 | - $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
527 | - } else { |
|
528 | - $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>"; |
|
529 | - } |
|
530 | - break; |
|
531 | - case is_object($val): |
|
532 | - $this->debug("serialize_val: serialize object"); |
|
533 | - if (get_class($val) == 'soapval') { |
|
534 | - $this->debug("serialize_val: serialize soapval object"); |
|
535 | - $pXml = $val->serialize($use); |
|
536 | - $this->appendDebug($val->getDebug()); |
|
537 | - $val->clearDebug(); |
|
538 | - } else { |
|
539 | - if (! $name) { |
|
540 | - $name = get_class($val); |
|
541 | - $this->debug("In serialize_val, used class name $name as element name"); |
|
542 | - } else { |
|
543 | - $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val)); |
|
544 | - } |
|
545 | - foreach(get_object_vars($val) as $k => $v){ |
|
546 | - $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use); |
|
547 | - } |
|
548 | - } |
|
549 | - if(isset($type) && isset($type_prefix)){ |
|
550 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
551 | - } else { |
|
552 | - $type_str = ''; |
|
553 | - } |
|
554 | - if ($use == 'literal') { |
|
555 | - $xml .= "<$name$xmlns$atts>$pXml</$name>"; |
|
556 | - } else { |
|
557 | - $xml .= "<$name$xmlns$type_str$atts>$pXml</$name>"; |
|
558 | - } |
|
559 | - break; |
|
560 | - break; |
|
561 | - case (is_array($val) || $type): |
|
562 | - // detect if struct or array |
|
563 | - $valueType = $this->isArraySimpleOrStruct($val); |
|
490 | + // detect type and serialize |
|
491 | + $xml = ''; |
|
492 | + switch(true) { |
|
493 | + case (is_bool($val) || $type == 'boolean'): |
|
494 | + $this->debug("serialize_val: serialize boolean"); |
|
495 | + if ($type == 'boolean') { |
|
496 | + $val = $val ? 'true' : 'false'; |
|
497 | + } elseif (! $val) { |
|
498 | + $val = 0; |
|
499 | + } |
|
500 | + if ($use == 'literal') { |
|
501 | + $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
502 | + } else { |
|
503 | + $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>"; |
|
504 | + } |
|
505 | + break; |
|
506 | + case (is_int($val) || is_long($val) || $type == 'int'): |
|
507 | + $this->debug("serialize_val: serialize int"); |
|
508 | + if ($use == 'literal') { |
|
509 | + $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
510 | + } else { |
|
511 | + $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>"; |
|
512 | + } |
|
513 | + break; |
|
514 | + case (is_float($val)|| is_double($val) || $type == 'float'): |
|
515 | + $this->debug("serialize_val: serialize float"); |
|
516 | + if ($use == 'literal') { |
|
517 | + $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
518 | + } else { |
|
519 | + $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>"; |
|
520 | + } |
|
521 | + break; |
|
522 | + case (is_string($val) || $type == 'string'): |
|
523 | + $this->debug("serialize_val: serialize string"); |
|
524 | + $val = $this->expandEntities($val); |
|
525 | + if ($use == 'literal') { |
|
526 | + $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
527 | + } else { |
|
528 | + $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>"; |
|
529 | + } |
|
530 | + break; |
|
531 | + case is_object($val): |
|
532 | + $this->debug("serialize_val: serialize object"); |
|
533 | + if (get_class($val) == 'soapval') { |
|
534 | + $this->debug("serialize_val: serialize soapval object"); |
|
535 | + $pXml = $val->serialize($use); |
|
536 | + $this->appendDebug($val->getDebug()); |
|
537 | + $val->clearDebug(); |
|
538 | + } else { |
|
539 | + if (! $name) { |
|
540 | + $name = get_class($val); |
|
541 | + $this->debug("In serialize_val, used class name $name as element name"); |
|
542 | + } else { |
|
543 | + $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val)); |
|
544 | + } |
|
545 | + foreach(get_object_vars($val) as $k => $v){ |
|
546 | + $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use); |
|
547 | + } |
|
548 | + } |
|
549 | + if(isset($type) && isset($type_prefix)){ |
|
550 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
551 | + } else { |
|
552 | + $type_str = ''; |
|
553 | + } |
|
554 | + if ($use == 'literal') { |
|
555 | + $xml .= "<$name$xmlns$atts>$pXml</$name>"; |
|
556 | + } else { |
|
557 | + $xml .= "<$name$xmlns$type_str$atts>$pXml</$name>"; |
|
558 | + } |
|
559 | + break; |
|
560 | + break; |
|
561 | + case (is_array($val) || $type): |
|
562 | + // detect if struct or array |
|
563 | + $valueType = $this->isArraySimpleOrStruct($val); |
|
564 | 564 | if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ |
565 | - $this->debug("serialize_val: serialize array"); |
|
566 | - $i = 0; |
|
567 | - if(is_array($val) && count($val)> 0){ |
|
568 | - foreach($val as $v){ |
|
569 | - if(is_object($v) && get_class($v) == 'soapval'){ |
|
570 | - $tt_ns = $v->type_ns; |
|
571 | - $tt = $v->type; |
|
572 | - } elseif (is_array($v)) { |
|
573 | - $tt = $this->isArraySimpleOrStruct($v); |
|
574 | - } else { |
|
575 | - $tt = gettype($v); |
|
576 | - } |
|
577 | - $array_types[$tt] = 1; |
|
578 | - // TODO: for literal, the name should be $name |
|
579 | - $xml .= $this->serialize_val($v,'item',false,false,false,false,$use); |
|
580 | - ++$i; |
|
581 | - } |
|
582 | - if(count($array_types) > 1){ |
|
583 | - $array_typename = 'xsd:anyType'; |
|
584 | - } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) { |
|
585 | - if ($tt == 'integer') { |
|
586 | - $tt = 'int'; |
|
587 | - } |
|
588 | - $array_typename = 'xsd:'.$tt; |
|
589 | - } elseif(isset($tt) && $tt == 'arraySimple'){ |
|
590 | - $array_typename = 'SOAP-ENC:Array'; |
|
591 | - } elseif(isset($tt) && $tt == 'arrayStruct'){ |
|
592 | - $array_typename = 'unnamed_struct_use_soapval'; |
|
593 | - } else { |
|
594 | - // if type is prefixed, create type prefix |
|
595 | - if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){ |
|
596 | - $array_typename = 'xsd:' . $tt; |
|
597 | - } elseif ($tt_ns) { |
|
598 | - $tt_prefix = 'ns' . rand(1000, 9999); |
|
599 | - $array_typename = "$tt_prefix:$tt"; |
|
600 | - $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\""; |
|
601 | - } else { |
|
602 | - $array_typename = $tt; |
|
603 | - } |
|
604 | - } |
|
605 | - $array_type = $i; |
|
606 | - if ($use == 'literal') { |
|
607 | - $type_str = ''; |
|
608 | - } else if (isset($type) && isset($type_prefix)) { |
|
609 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
610 | - } else { |
|
611 | - $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\""; |
|
612 | - } |
|
613 | - // empty array |
|
614 | - } else { |
|
615 | - if ($use == 'literal') { |
|
616 | - $type_str = ''; |
|
617 | - } else if (isset($type) && isset($type_prefix)) { |
|
618 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
619 | - } else { |
|
620 | - $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\""; |
|
621 | - } |
|
622 | - } |
|
623 | - // TODO: for array in literal, there is no wrapper here |
|
624 | - $xml = "<$name$xmlns$type_str$atts>".$xml."</$name>"; |
|
625 | - } else { |
|
626 | - // got a struct |
|
627 | - $this->debug("serialize_val: serialize struct"); |
|
628 | - if(isset($type) && isset($type_prefix)){ |
|
629 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
630 | - } else { |
|
631 | - $type_str = ''; |
|
632 | - } |
|
633 | - if ($use == 'literal') { |
|
634 | - $xml .= "<$name$xmlns$atts>"; |
|
635 | - } else { |
|
636 | - $xml .= "<$name$xmlns$type_str$atts>"; |
|
637 | - } |
|
638 | - foreach($val as $k => $v){ |
|
639 | - // Apache Map |
|
640 | - if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') { |
|
641 | - $xml .= '<item>'; |
|
642 | - $xml .= $this->serialize_val($k,'key',false,false,false,false,$use); |
|
643 | - $xml .= $this->serialize_val($v,'value',false,false,false,false,$use); |
|
644 | - $xml .= '</item>'; |
|
645 | - } else { |
|
646 | - $xml .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
647 | - } |
|
648 | - } |
|
649 | - $xml .= "</$name>"; |
|
650 | - } |
|
651 | - break; |
|
652 | - default: |
|
653 | - $this->debug("serialize_val: serialize unknown"); |
|
654 | - $xml .= 'not detected, got '.gettype($val).' for '.$val; |
|
655 | - break; |
|
656 | - } |
|
657 | - $this->debug("serialize_val returning $xml"); |
|
658 | - return $xml; |
|
659 | - } |
|
660 | - |
|
661 | - /** |
|
662 | - * serializes a message |
|
663 | - * |
|
664 | - * @param string $body the XML of the SOAP body |
|
665 | - * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array |
|
666 | - * @param array $namespaces optional the namespaces used in generating the body and headers |
|
667 | - * @param string $style optional (rpc|document) |
|
668 | - * @param string $use optional (encoded|literal) |
|
669 | - * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
670 | - * @return string the message |
|
671 | - * @access public |
|
672 | - */ |
|
565 | + $this->debug("serialize_val: serialize array"); |
|
566 | + $i = 0; |
|
567 | + if(is_array($val) && count($val)> 0){ |
|
568 | + foreach($val as $v){ |
|
569 | + if(is_object($v) && get_class($v) == 'soapval'){ |
|
570 | + $tt_ns = $v->type_ns; |
|
571 | + $tt = $v->type; |
|
572 | + } elseif (is_array($v)) { |
|
573 | + $tt = $this->isArraySimpleOrStruct($v); |
|
574 | + } else { |
|
575 | + $tt = gettype($v); |
|
576 | + } |
|
577 | + $array_types[$tt] = 1; |
|
578 | + // TODO: for literal, the name should be $name |
|
579 | + $xml .= $this->serialize_val($v,'item',false,false,false,false,$use); |
|
580 | + ++$i; |
|
581 | + } |
|
582 | + if(count($array_types) > 1){ |
|
583 | + $array_typename = 'xsd:anyType'; |
|
584 | + } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) { |
|
585 | + if ($tt == 'integer') { |
|
586 | + $tt = 'int'; |
|
587 | + } |
|
588 | + $array_typename = 'xsd:'.$tt; |
|
589 | + } elseif(isset($tt) && $tt == 'arraySimple'){ |
|
590 | + $array_typename = 'SOAP-ENC:Array'; |
|
591 | + } elseif(isset($tt) && $tt == 'arrayStruct'){ |
|
592 | + $array_typename = 'unnamed_struct_use_soapval'; |
|
593 | + } else { |
|
594 | + // if type is prefixed, create type prefix |
|
595 | + if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){ |
|
596 | + $array_typename = 'xsd:' . $tt; |
|
597 | + } elseif ($tt_ns) { |
|
598 | + $tt_prefix = 'ns' . rand(1000, 9999); |
|
599 | + $array_typename = "$tt_prefix:$tt"; |
|
600 | + $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\""; |
|
601 | + } else { |
|
602 | + $array_typename = $tt; |
|
603 | + } |
|
604 | + } |
|
605 | + $array_type = $i; |
|
606 | + if ($use == 'literal') { |
|
607 | + $type_str = ''; |
|
608 | + } else if (isset($type) && isset($type_prefix)) { |
|
609 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
610 | + } else { |
|
611 | + $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\""; |
|
612 | + } |
|
613 | + // empty array |
|
614 | + } else { |
|
615 | + if ($use == 'literal') { |
|
616 | + $type_str = ''; |
|
617 | + } else if (isset($type) && isset($type_prefix)) { |
|
618 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
619 | + } else { |
|
620 | + $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\""; |
|
621 | + } |
|
622 | + } |
|
623 | + // TODO: for array in literal, there is no wrapper here |
|
624 | + $xml = "<$name$xmlns$type_str$atts>".$xml."</$name>"; |
|
625 | + } else { |
|
626 | + // got a struct |
|
627 | + $this->debug("serialize_val: serialize struct"); |
|
628 | + if(isset($type) && isset($type_prefix)){ |
|
629 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
630 | + } else { |
|
631 | + $type_str = ''; |
|
632 | + } |
|
633 | + if ($use == 'literal') { |
|
634 | + $xml .= "<$name$xmlns$atts>"; |
|
635 | + } else { |
|
636 | + $xml .= "<$name$xmlns$type_str$atts>"; |
|
637 | + } |
|
638 | + foreach($val as $k => $v){ |
|
639 | + // Apache Map |
|
640 | + if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') { |
|
641 | + $xml .= '<item>'; |
|
642 | + $xml .= $this->serialize_val($k,'key',false,false,false,false,$use); |
|
643 | + $xml .= $this->serialize_val($v,'value',false,false,false,false,$use); |
|
644 | + $xml .= '</item>'; |
|
645 | + } else { |
|
646 | + $xml .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
647 | + } |
|
648 | + } |
|
649 | + $xml .= "</$name>"; |
|
650 | + } |
|
651 | + break; |
|
652 | + default: |
|
653 | + $this->debug("serialize_val: serialize unknown"); |
|
654 | + $xml .= 'not detected, got '.gettype($val).' for '.$val; |
|
655 | + break; |
|
656 | + } |
|
657 | + $this->debug("serialize_val returning $xml"); |
|
658 | + return $xml; |
|
659 | + } |
|
660 | + |
|
661 | + /** |
|
662 | + * serializes a message |
|
663 | + * |
|
664 | + * @param string $body the XML of the SOAP body |
|
665 | + * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array |
|
666 | + * @param array $namespaces optional the namespaces used in generating the body and headers |
|
667 | + * @param string $style optional (rpc|document) |
|
668 | + * @param string $use optional (encoded|literal) |
|
669 | + * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
670 | + * @return string the message |
|
671 | + * @access public |
|
672 | + */ |
|
673 | 673 | function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){ |
674 | 674 | // TODO: add an option to automatically run utf8_encode on $body and $headers |
675 | 675 | // if $this->soap_defencoding is UTF-8. Not doing this automatically allows |
676 | 676 | // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1 |
677 | 677 | |
678 | - $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle"); |
|
679 | - $this->debug("headers:"); |
|
680 | - $this->appendDebug($this->varDump($headers)); |
|
681 | - $this->debug("namespaces:"); |
|
682 | - $this->appendDebug($this->varDump($namespaces)); |
|
678 | + $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle"); |
|
679 | + $this->debug("headers:"); |
|
680 | + $this->appendDebug($this->varDump($headers)); |
|
681 | + $this->debug("namespaces:"); |
|
682 | + $this->appendDebug($this->varDump($namespaces)); |
|
683 | 683 | |
684 | - // serialize namespaces |
|
684 | + // serialize namespaces |
|
685 | 685 | $ns_string = ''; |
686 | - foreach(array_merge($this->namespaces,$namespaces) as $k => $v){ |
|
687 | - $ns_string .= " xmlns:$k=\"$v\""; |
|
688 | - } |
|
689 | - if($encodingStyle) { |
|
690 | - $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string"; |
|
691 | - } |
|
692 | - |
|
693 | - // serialize headers |
|
694 | - if($headers){ |
|
695 | - if (is_array($headers)) { |
|
696 | - $xml = ''; |
|
697 | - foreach ($headers as $k => $v) { |
|
698 | - if (is_object($v) && get_class($v) == 'soapval') { |
|
699 | - $xml .= $this->serialize_val($v, false, false, false, false, false, $use); |
|
700 | - } else { |
|
701 | - $xml .= $this->serialize_val($v, $k, false, false, false, false, $use); |
|
702 | - } |
|
703 | - } |
|
704 | - $headers = $xml; |
|
705 | - $this->debug("In serializeEnvelope, serialized array of headers to $headers"); |
|
706 | - } |
|
707 | - $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>"; |
|
708 | - } |
|
709 | - // serialize envelope |
|
710 | - return |
|
711 | - '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">". |
|
712 | - '<SOAP-ENV:Envelope'.$ns_string.">". |
|
713 | - $headers. |
|
714 | - "<SOAP-ENV:Body>". |
|
715 | - $body. |
|
716 | - "</SOAP-ENV:Body>". |
|
717 | - "</SOAP-ENV:Envelope>"; |
|
718 | - } |
|
719 | - |
|
720 | - /** |
|
721 | - * formats a string to be inserted into an HTML stream |
|
722 | - * |
|
723 | - * @param string $str The string to format |
|
724 | - * @return string The formatted string |
|
725 | - * @access public |
|
726 | - * @deprecated |
|
727 | - */ |
|
686 | + foreach(array_merge($this->namespaces,$namespaces) as $k => $v){ |
|
687 | + $ns_string .= " xmlns:$k=\"$v\""; |
|
688 | + } |
|
689 | + if($encodingStyle) { |
|
690 | + $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string"; |
|
691 | + } |
|
692 | + |
|
693 | + // serialize headers |
|
694 | + if($headers){ |
|
695 | + if (is_array($headers)) { |
|
696 | + $xml = ''; |
|
697 | + foreach ($headers as $k => $v) { |
|
698 | + if (is_object($v) && get_class($v) == 'soapval') { |
|
699 | + $xml .= $this->serialize_val($v, false, false, false, false, false, $use); |
|
700 | + } else { |
|
701 | + $xml .= $this->serialize_val($v, $k, false, false, false, false, $use); |
|
702 | + } |
|
703 | + } |
|
704 | + $headers = $xml; |
|
705 | + $this->debug("In serializeEnvelope, serialized array of headers to $headers"); |
|
706 | + } |
|
707 | + $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>"; |
|
708 | + } |
|
709 | + // serialize envelope |
|
710 | + return |
|
711 | + '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">". |
|
712 | + '<SOAP-ENV:Envelope'.$ns_string.">". |
|
713 | + $headers. |
|
714 | + "<SOAP-ENV:Body>". |
|
715 | + $body. |
|
716 | + "</SOAP-ENV:Body>". |
|
717 | + "</SOAP-ENV:Envelope>"; |
|
718 | + } |
|
719 | + |
|
720 | + /** |
|
721 | + * formats a string to be inserted into an HTML stream |
|
722 | + * |
|
723 | + * @param string $str The string to format |
|
724 | + * @return string The formatted string |
|
725 | + * @access public |
|
726 | + * @deprecated |
|
727 | + */ |
|
728 | 728 | function formatDump($str){ |
729 | - $str = htmlspecialchars($str); |
|
730 | - return nl2br($str); |
|
731 | - } |
|
732 | - |
|
733 | - /** |
|
734 | - * contracts (changes namespace to prefix) a qualified name |
|
735 | - * |
|
736 | - * @param string $qname qname |
|
737 | - * @return string contracted qname |
|
738 | - * @access private |
|
739 | - */ |
|
740 | - function contractQname($qname){ |
|
741 | - // get element namespace |
|
742 | - //$this->xdebug("Contract $qname"); |
|
743 | - if (strrpos($qname, ':')) { |
|
744 | - // get unqualified name |
|
745 | - $name = substr($qname, strrpos($qname, ':') + 1); |
|
746 | - // get ns |
|
747 | - $ns = substr($qname, 0, strrpos($qname, ':')); |
|
748 | - $p = $this->getPrefixFromNamespace($ns); |
|
749 | - if ($p) { |
|
750 | - return $p . ':' . $name; |
|
751 | - } |
|
752 | - return $qname; |
|
753 | - } else { |
|
754 | - return $qname; |
|
755 | - } |
|
756 | - } |
|
757 | - |
|
758 | - /** |
|
759 | - * expands (changes prefix to namespace) a qualified name |
|
760 | - * |
|
761 | - * @param string $qname qname |
|
762 | - * @return string expanded qname |
|
763 | - * @access private |
|
764 | - */ |
|
765 | - function expandQname($qname){ |
|
766 | - // get element prefix |
|
767 | - if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){ |
|
768 | - // get unqualified name |
|
769 | - $name = substr(strstr($qname,':'),1); |
|
770 | - // get ns prefix |
|
771 | - $prefix = substr($qname,0,strpos($qname,':')); |
|
772 | - if(isset($this->namespaces[$prefix])){ |
|
773 | - return $this->namespaces[$prefix].':'.$name; |
|
774 | - } else { |
|
775 | - return $qname; |
|
776 | - } |
|
777 | - } else { |
|
778 | - return $qname; |
|
779 | - } |
|
780 | - } |
|
781 | - |
|
782 | - /** |
|
783 | - * returns the local part of a prefixed string |
|
784 | - * returns the original string, if not prefixed |
|
785 | - * |
|
786 | - * @param string $str The prefixed string |
|
787 | - * @return string The local part |
|
788 | - * @access public |
|
789 | - */ |
|
790 | - function getLocalPart($str){ |
|
791 | - if($sstr = strrchr($str,':')){ |
|
792 | - // get unqualified name |
|
793 | - return substr( $sstr, 1 ); |
|
794 | - } else { |
|
795 | - return $str; |
|
796 | - } |
|
797 | - } |
|
798 | - |
|
799 | - /** |
|
800 | - * returns the prefix part of a prefixed string |
|
801 | - * returns false, if not prefixed |
|
802 | - * |
|
803 | - * @param string $str The prefixed string |
|
804 | - * @return mixed The prefix or false if there is no prefix |
|
805 | - * @access public |
|
806 | - */ |
|
807 | - function getPrefix($str){ |
|
808 | - if($pos = strrpos($str,':')){ |
|
809 | - // get prefix |
|
810 | - return substr($str,0,$pos); |
|
811 | - } |
|
812 | - return false; |
|
813 | - } |
|
814 | - |
|
815 | - /** |
|
816 | - * pass it a prefix, it returns a namespace |
|
817 | - * |
|
818 | - * @param string $prefix The prefix |
|
819 | - * @return mixed The namespace, false if no namespace has the specified prefix |
|
820 | - * @access public |
|
821 | - */ |
|
822 | - function getNamespaceFromPrefix($prefix){ |
|
823 | - if (isset($this->namespaces[$prefix])) { |
|
824 | - return $this->namespaces[$prefix]; |
|
825 | - } |
|
826 | - //$this->setError("No namespace registered for prefix '$prefix'"); |
|
827 | - return false; |
|
828 | - } |
|
829 | - |
|
830 | - /** |
|
831 | - * returns the prefix for a given namespace (or prefix) |
|
832 | - * or false if no prefixes registered for the given namespace |
|
833 | - * |
|
834 | - * @param string $ns The namespace |
|
835 | - * @return mixed The prefix, false if the namespace has no prefixes |
|
836 | - * @access public |
|
837 | - */ |
|
838 | - function getPrefixFromNamespace($ns) { |
|
839 | - foreach ($this->namespaces as $p => $n) { |
|
840 | - if ($ns == $n || $ns == $p) { |
|
841 | - $this->usedNamespaces[$p] = $n; |
|
842 | - return $p; |
|
843 | - } |
|
844 | - } |
|
845 | - return false; |
|
846 | - } |
|
847 | - |
|
848 | - /** |
|
849 | - * returns the time in ODBC canonical form with microseconds |
|
850 | - * |
|
851 | - * @return string The time in ODBC canonical form with microseconds |
|
852 | - * @access public |
|
853 | - */ |
|
854 | - function getmicrotime() { |
|
855 | - if (function_exists('gettimeofday')) { |
|
856 | - $tod = gettimeofday(); |
|
857 | - $sec = $tod['sec']; |
|
858 | - $usec = $tod['usec']; |
|
859 | - } else { |
|
860 | - $sec = time(); |
|
861 | - $usec = 0; |
|
862 | - } |
|
863 | - return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec); |
|
864 | - } |
|
865 | - |
|
866 | - /** |
|
867 | - * Returns a string with the output of var_dump |
|
868 | - * |
|
869 | - * @param mixed $data The variable to var_dump |
|
870 | - * @return string The output of var_dump |
|
871 | - * @access public |
|
872 | - */ |
|
729 | + $str = htmlspecialchars($str); |
|
730 | + return nl2br($str); |
|
731 | + } |
|
732 | + |
|
733 | + /** |
|
734 | + * contracts (changes namespace to prefix) a qualified name |
|
735 | + * |
|
736 | + * @param string $qname qname |
|
737 | + * @return string contracted qname |
|
738 | + * @access private |
|
739 | + */ |
|
740 | + function contractQname($qname){ |
|
741 | + // get element namespace |
|
742 | + //$this->xdebug("Contract $qname"); |
|
743 | + if (strrpos($qname, ':')) { |
|
744 | + // get unqualified name |
|
745 | + $name = substr($qname, strrpos($qname, ':') + 1); |
|
746 | + // get ns |
|
747 | + $ns = substr($qname, 0, strrpos($qname, ':')); |
|
748 | + $p = $this->getPrefixFromNamespace($ns); |
|
749 | + if ($p) { |
|
750 | + return $p . ':' . $name; |
|
751 | + } |
|
752 | + return $qname; |
|
753 | + } else { |
|
754 | + return $qname; |
|
755 | + } |
|
756 | + } |
|
757 | + |
|
758 | + /** |
|
759 | + * expands (changes prefix to namespace) a qualified name |
|
760 | + * |
|
761 | + * @param string $qname qname |
|
762 | + * @return string expanded qname |
|
763 | + * @access private |
|
764 | + */ |
|
765 | + function expandQname($qname){ |
|
766 | + // get element prefix |
|
767 | + if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){ |
|
768 | + // get unqualified name |
|
769 | + $name = substr(strstr($qname,':'),1); |
|
770 | + // get ns prefix |
|
771 | + $prefix = substr($qname,0,strpos($qname,':')); |
|
772 | + if(isset($this->namespaces[$prefix])){ |
|
773 | + return $this->namespaces[$prefix].':'.$name; |
|
774 | + } else { |
|
775 | + return $qname; |
|
776 | + } |
|
777 | + } else { |
|
778 | + return $qname; |
|
779 | + } |
|
780 | + } |
|
781 | + |
|
782 | + /** |
|
783 | + * returns the local part of a prefixed string |
|
784 | + * returns the original string, if not prefixed |
|
785 | + * |
|
786 | + * @param string $str The prefixed string |
|
787 | + * @return string The local part |
|
788 | + * @access public |
|
789 | + */ |
|
790 | + function getLocalPart($str){ |
|
791 | + if($sstr = strrchr($str,':')){ |
|
792 | + // get unqualified name |
|
793 | + return substr( $sstr, 1 ); |
|
794 | + } else { |
|
795 | + return $str; |
|
796 | + } |
|
797 | + } |
|
798 | + |
|
799 | + /** |
|
800 | + * returns the prefix part of a prefixed string |
|
801 | + * returns false, if not prefixed |
|
802 | + * |
|
803 | + * @param string $str The prefixed string |
|
804 | + * @return mixed The prefix or false if there is no prefix |
|
805 | + * @access public |
|
806 | + */ |
|
807 | + function getPrefix($str){ |
|
808 | + if($pos = strrpos($str,':')){ |
|
809 | + // get prefix |
|
810 | + return substr($str,0,$pos); |
|
811 | + } |
|
812 | + return false; |
|
813 | + } |
|
814 | + |
|
815 | + /** |
|
816 | + * pass it a prefix, it returns a namespace |
|
817 | + * |
|
818 | + * @param string $prefix The prefix |
|
819 | + * @return mixed The namespace, false if no namespace has the specified prefix |
|
820 | + * @access public |
|
821 | + */ |
|
822 | + function getNamespaceFromPrefix($prefix){ |
|
823 | + if (isset($this->namespaces[$prefix])) { |
|
824 | + return $this->namespaces[$prefix]; |
|
825 | + } |
|
826 | + //$this->setError("No namespace registered for prefix '$prefix'"); |
|
827 | + return false; |
|
828 | + } |
|
829 | + |
|
830 | + /** |
|
831 | + * returns the prefix for a given namespace (or prefix) |
|
832 | + * or false if no prefixes registered for the given namespace |
|
833 | + * |
|
834 | + * @param string $ns The namespace |
|
835 | + * @return mixed The prefix, false if the namespace has no prefixes |
|
836 | + * @access public |
|
837 | + */ |
|
838 | + function getPrefixFromNamespace($ns) { |
|
839 | + foreach ($this->namespaces as $p => $n) { |
|
840 | + if ($ns == $n || $ns == $p) { |
|
841 | + $this->usedNamespaces[$p] = $n; |
|
842 | + return $p; |
|
843 | + } |
|
844 | + } |
|
845 | + return false; |
|
846 | + } |
|
847 | + |
|
848 | + /** |
|
849 | + * returns the time in ODBC canonical form with microseconds |
|
850 | + * |
|
851 | + * @return string The time in ODBC canonical form with microseconds |
|
852 | + * @access public |
|
853 | + */ |
|
854 | + function getmicrotime() { |
|
855 | + if (function_exists('gettimeofday')) { |
|
856 | + $tod = gettimeofday(); |
|
857 | + $sec = $tod['sec']; |
|
858 | + $usec = $tod['usec']; |
|
859 | + } else { |
|
860 | + $sec = time(); |
|
861 | + $usec = 0; |
|
862 | + } |
|
863 | + return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec); |
|
864 | + } |
|
865 | + |
|
866 | + /** |
|
867 | + * Returns a string with the output of var_dump |
|
868 | + * |
|
869 | + * @param mixed $data The variable to var_dump |
|
870 | + * @return string The output of var_dump |
|
871 | + * @access public |
|
872 | + */ |
|
873 | 873 | function varDump($data) { |
874 | - ob_start(); |
|
875 | - var_dump($data); |
|
876 | - $ret_val = ob_get_contents(); |
|
877 | - ob_end_clean(); |
|
878 | - return $ret_val; |
|
879 | - } |
|
880 | - |
|
881 | - /** |
|
882 | - * represents the object as a string |
|
883 | - * |
|
884 | - * @return string |
|
885 | - * @access public |
|
886 | - */ |
|
887 | - function __toString() { |
|
888 | - return $this->varDump($this); |
|
889 | - } |
|
874 | + ob_start(); |
|
875 | + var_dump($data); |
|
876 | + $ret_val = ob_get_contents(); |
|
877 | + ob_end_clean(); |
|
878 | + return $ret_val; |
|
879 | + } |
|
880 | + |
|
881 | + /** |
|
882 | + * represents the object as a string |
|
883 | + * |
|
884 | + * @return string |
|
885 | + * @access public |
|
886 | + */ |
|
887 | + function __toString() { |
|
888 | + return $this->varDump($this); |
|
889 | + } |
|
890 | 890 | } |
891 | 891 | |
892 | 892 | // XML Schema Datatype Helper Functions |
@@ -902,35 +902,35 @@ discard block |
||
902 | 902 | * @access public |
903 | 903 | */ |
904 | 904 | function timestamp_to_iso8601($timestamp,$utc=true){ |
905 | - $datestr = date('Y-m-d\TH:i:sO',$timestamp); |
|
906 | - $pos = strrpos($datestr, "+"); |
|
907 | - if ($pos === FALSE) { |
|
908 | - $pos = strrpos($datestr, "-"); |
|
909 | - } |
|
910 | - if ($pos !== FALSE) { |
|
911 | - if (strlen($datestr) == $pos + 5) { |
|
912 | - $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2); |
|
913 | - } |
|
914 | - } |
|
915 | - if($utc){ |
|
916 | - $pattern = '/'. |
|
917 | - '([0-9]{4})-'. // centuries & years CCYY- |
|
918 | - '([0-9]{2})-'. // months MM- |
|
919 | - '([0-9]{2})'. // days DD |
|
920 | - 'T'. // separator T |
|
921 | - '([0-9]{2}):'. // hours hh: |
|
922 | - '([0-9]{2}):'. // minutes mm: |
|
923 | - '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... |
|
924 | - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
925 | - '/'; |
|
926 | - |
|
927 | - if(preg_match($pattern,$datestr,$regs)){ |
|
928 | - return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); |
|
929 | - } |
|
930 | - return false; |
|
931 | - } else { |
|
932 | - return $datestr; |
|
933 | - } |
|
905 | + $datestr = date('Y-m-d\TH:i:sO',$timestamp); |
|
906 | + $pos = strrpos($datestr, "+"); |
|
907 | + if ($pos === FALSE) { |
|
908 | + $pos = strrpos($datestr, "-"); |
|
909 | + } |
|
910 | + if ($pos !== FALSE) { |
|
911 | + if (strlen($datestr) == $pos + 5) { |
|
912 | + $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2); |
|
913 | + } |
|
914 | + } |
|
915 | + if($utc){ |
|
916 | + $pattern = '/'. |
|
917 | + '([0-9]{4})-'. // centuries & years CCYY- |
|
918 | + '([0-9]{2})-'. // months MM- |
|
919 | + '([0-9]{2})'. // days DD |
|
920 | + 'T'. // separator T |
|
921 | + '([0-9]{2}):'. // hours hh: |
|
922 | + '([0-9]{2}):'. // minutes mm: |
|
923 | + '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... |
|
924 | + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
925 | + '/'; |
|
926 | + |
|
927 | + if(preg_match($pattern,$datestr,$regs)){ |
|
928 | + return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); |
|
929 | + } |
|
930 | + return false; |
|
931 | + } else { |
|
932 | + return $datestr; |
|
933 | + } |
|
934 | 934 | } |
935 | 935 | |
936 | 936 | /** |
@@ -941,35 +941,35 @@ discard block |
||
941 | 941 | * @access public |
942 | 942 | */ |
943 | 943 | function iso8601_to_timestamp($datestr){ |
944 | - $pattern = '/'. |
|
945 | - '([0-9]{4})-'. // centuries & years CCYY- |
|
946 | - '([0-9]{2})-'. // months MM- |
|
947 | - '([0-9]{2})'. // days DD |
|
948 | - 'T'. // separator T |
|
949 | - '([0-9]{2}):'. // hours hh: |
|
950 | - '([0-9]{2}):'. // minutes mm: |
|
951 | - '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss... |
|
952 | - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
953 | - '/'; |
|
954 | - if(preg_match($pattern,$datestr,$regs)){ |
|
955 | - // not utc |
|
956 | - if($regs[8] != 'Z'){ |
|
957 | - $op = substr($regs[8],0,1); |
|
958 | - $h = substr($regs[8],1,2); |
|
959 | - $m = substr($regs[8],strlen($regs[8])-2,2); |
|
960 | - if($op == '-'){ |
|
961 | - $regs[4] = $regs[4] + $h; |
|
962 | - $regs[5] = $regs[5] + $m; |
|
963 | - } elseif($op == '+'){ |
|
964 | - $regs[4] = $regs[4] - $h; |
|
965 | - $regs[5] = $regs[5] - $m; |
|
966 | - } |
|
967 | - } |
|
968 | - return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); |
|
944 | + $pattern = '/'. |
|
945 | + '([0-9]{4})-'. // centuries & years CCYY- |
|
946 | + '([0-9]{2})-'. // months MM- |
|
947 | + '([0-9]{2})'. // days DD |
|
948 | + 'T'. // separator T |
|
949 | + '([0-9]{2}):'. // hours hh: |
|
950 | + '([0-9]{2}):'. // minutes mm: |
|
951 | + '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss... |
|
952 | + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
953 | + '/'; |
|
954 | + if(preg_match($pattern,$datestr,$regs)){ |
|
955 | + // not utc |
|
956 | + if($regs[8] != 'Z'){ |
|
957 | + $op = substr($regs[8],0,1); |
|
958 | + $h = substr($regs[8],1,2); |
|
959 | + $m = substr($regs[8],strlen($regs[8])-2,2); |
|
960 | + if($op == '-'){ |
|
961 | + $regs[4] = $regs[4] + $h; |
|
962 | + $regs[5] = $regs[5] + $m; |
|
963 | + } elseif($op == '+'){ |
|
964 | + $regs[4] = $regs[4] - $h; |
|
965 | + $regs[5] = $regs[5] - $m; |
|
966 | + } |
|
967 | + } |
|
968 | + return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); |
|
969 | 969 | // return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z"); |
970 | - } else { |
|
971 | - return false; |
|
972 | - } |
|
970 | + } else { |
|
971 | + return false; |
|
972 | + } |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | /** |
@@ -981,15 +981,15 @@ discard block |
||
981 | 981 | */ |
982 | 982 | function usleepWindows($usec) |
983 | 983 | { |
984 | - $start = gettimeofday(); |
|
985 | - |
|
986 | - do |
|
987 | - { |
|
988 | - $stop = gettimeofday(); |
|
989 | - $timePassed = 1000000 * ($stop['sec'] - $start['sec']) |
|
990 | - + $stop['usec'] - $start['usec']; |
|
991 | - } |
|
992 | - while ($timePassed < $usec); |
|
984 | + $start = gettimeofday(); |
|
985 | + |
|
986 | + do |
|
987 | + { |
|
988 | + $stop = gettimeofday(); |
|
989 | + $timePassed = 1000000 * ($stop['sec'] - $start['sec']) |
|
990 | + + $stop['usec'] - $start['usec']; |
|
991 | + } |
|
992 | + while ($timePassed < $usec); |
|
993 | 993 | } |
994 | 994 | |
995 | 995 |
@@ -666,7 +666,7 @@ |
||
666 | 666 | $res = Database::query($sql); |
667 | 667 | $count1 = Database::fetch_object($res); |
668 | 668 | $sql = "SELECT COUNT(*) AS n FROM $user_table as u $table ". |
669 | - "WHERE LENGTH(picture_uri) > 0 $url_condition2"; |
|
669 | + "WHERE LENGTH(picture_uri) > 0 $url_condition2"; |
|
670 | 670 | $res = Database::query($sql); |
671 | 671 | $count2 = Database::fetch_object($res); |
672 | 672 | // #users without picture |
@@ -18,11 +18,11 @@ discard block |
||
18 | 18 | |
19 | 19 | class OpenGraph implements Iterator |
20 | 20 | { |
21 | - /** |
|
22 | - * There are base schema's based on type, this is just |
|
23 | - * a map so that the schema can be obtained |
|
24 | - * |
|
25 | - */ |
|
21 | + /** |
|
22 | + * There are base schema's based on type, this is just |
|
23 | + * a map so that the schema can be obtained |
|
24 | + * |
|
25 | + */ |
|
26 | 26 | public static $TYPES = array( |
27 | 27 | 'activity' => array('activity', 'sport'), |
28 | 28 | 'business' => array('bar', 'company', 'cafe', 'hotel', 'restaurant'), |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | 'website' => array('blog', 'website'), |
35 | 35 | ); |
36 | 36 | |
37 | - /** |
|
38 | - * Holds all the Open Graph values we've parsed from a page |
|
39 | - * |
|
40 | - */ |
|
37 | + /** |
|
38 | + * Holds all the Open Graph values we've parsed from a page |
|
39 | + * |
|
40 | + */ |
|
41 | 41 | private $_values = array(); |
42 | 42 | |
43 | - /** |
|
44 | - * Fetches a URI and parses it for Open Graph data, returns |
|
45 | - * false on error. |
|
46 | - * |
|
47 | - * @param $URI URI to page to parse for Open Graph data |
|
48 | - * @return OpenGraph |
|
49 | - */ |
|
43 | + /** |
|
44 | + * Fetches a URI and parses it for Open Graph data, returns |
|
45 | + * false on error. |
|
46 | + * |
|
47 | + * @param $URI URI to page to parse for Open Graph data |
|
48 | + * @return OpenGraph |
|
49 | + */ |
|
50 | 50 | static public function fetch($URI) { |
51 | 51 | $curl = curl_init($URI); |
52 | 52 | |
@@ -69,13 +69,13 @@ discard block |
||
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | - /** |
|
73 | - * Parses HTML and extracts Open Graph data, this assumes |
|
74 | - * the document is at least well formed. |
|
75 | - * |
|
76 | - * @param $HTML HTML to parse |
|
77 | - * @return OpenGraph |
|
78 | - */ |
|
72 | + /** |
|
73 | + * Parses HTML and extracts Open Graph data, this assumes |
|
74 | + * the document is at least well formed. |
|
75 | + * |
|
76 | + * @param $HTML HTML to parse |
|
77 | + * @return OpenGraph |
|
78 | + */ |
|
79 | 79 | static private function _parse($HTML) { |
80 | 80 | $old_libxml_error = libxml_use_internal_errors(true); |
81 | 81 | |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | return $page; |
141 | 141 | } |
142 | 142 | |
143 | - /** |
|
144 | - * Helper method to access attributes directly |
|
145 | - * Example: |
|
146 | - * $graph->title |
|
147 | - * |
|
148 | - * @param $key Key to fetch from the lookup |
|
149 | - */ |
|
143 | + /** |
|
144 | + * Helper method to access attributes directly |
|
145 | + * Example: |
|
146 | + * $graph->title |
|
147 | + * |
|
148 | + * @param $key Key to fetch from the lookup |
|
149 | + */ |
|
150 | 150 | public function __get($key) { |
151 | 151 | if (array_key_exists($key, $this->_values)) { |
152 | 152 | return $this->_values[$key]; |
@@ -161,29 +161,29 @@ discard block |
||
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | - /** |
|
165 | - * Return all the keys found on the page |
|
166 | - * |
|
167 | - * @return array |
|
168 | - */ |
|
164 | + /** |
|
165 | + * Return all the keys found on the page |
|
166 | + * |
|
167 | + * @return array |
|
168 | + */ |
|
169 | 169 | public function keys() { |
170 | 170 | return array_keys($this->_values); |
171 | 171 | } |
172 | 172 | |
173 | - /** |
|
174 | - * Helper method to check an attribute exists |
|
175 | - * |
|
176 | - * @param $key |
|
177 | - */ |
|
173 | + /** |
|
174 | + * Helper method to check an attribute exists |
|
175 | + * |
|
176 | + * @param $key |
|
177 | + */ |
|
178 | 178 | public function __isset($key) { |
179 | 179 | return array_key_exists($key, $this->_values); |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * Will return true if the page has location data embedded |
|
184 | - * |
|
185 | - * @return boolean Check if the page has location data |
|
186 | - */ |
|
182 | + /** |
|
183 | + * Will return true if the page has location data embedded |
|
184 | + * |
|
185 | + * @return boolean Check if the page has location data |
|
186 | + */ |
|
187 | 187 | public function hasLocation() { |
188 | 188 | if (array_key_exists('latitude', $this->_values) && array_key_exists('longitude', $this->_values)) { |
189 | 189 | return true; |
@@ -197,9 +197,9 @@ discard block |
||
197 | 197 | return $valid_address; |
198 | 198 | } |
199 | 199 | |
200 | - /** |
|
201 | - * Iterator code |
|
202 | - */ |
|
200 | + /** |
|
201 | + * Iterator code |
|
202 | + */ |
|
203 | 203 | private $_position = 0; |
204 | 204 | public function rewind() { reset($this->_values); $this->_position = 0; } |
205 | 205 | public function current() { return current($this->_values); } |
@@ -379,7 +379,7 @@ |
||
379 | 379 | $sql_delete = "DELETE FROM $tucc |
380 | 380 | WHERE id='" . $category_id . "' and user_id='" . $current_user_id . "'"; |
381 | 381 | $resultQuery = Database::query($sql_delete); |
382 | - if (Database::affected_rows($resultQuery)) { |
|
382 | + if (Database::affected_rows($resultQuery)) { |
|
383 | 383 | $result = true; |
384 | 384 | } |
385 | 385 | $sql = "UPDATE $TABLECOURSUSER |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | if (isset($_configuration['language_measure_frequency']) && |
104 | 104 | $_configuration['language_measure_frequency'] == 1 |
105 | 105 | ) { |
106 | - require_once api_get_path(SYS_CODE_PATH).'/cron/lang/langstats.class.php'; |
|
107 | - global $langstats; |
|
108 | - $langstats->add_use($variable,''); |
|
106 | + require_once api_get_path(SYS_CODE_PATH).'/cron/lang/langstats.class.php'; |
|
107 | + global $langstats; |
|
108 | + $langstats->add_use($variable,''); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | if (!isset($used_lang_vars)) { |
112 | - $used_lang_vars = array(); |
|
112 | + $used_lang_vars = array(); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | // Caching results from some API functions, for speed. |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | static $text_direction = array(); |
306 | 306 | |
307 | 307 | if (empty($language)) { |
308 | - $language = api_get_interface_language(); |
|
308 | + $language = api_get_interface_language(); |
|
309 | 309 | } |
310 | 310 | if (!isset($text_direction[$language])) { |
311 | 311 | $text_direction[$language] = in_array(api_purify_language_id($language), |
@@ -536,24 +536,24 @@ discard block |
||
536 | 536 | case DATE_FORMAT_ONLY_DAYNAME: |
537 | 537 | $date_format = get_lang('dateFormatOnlyDayName', '', $language); |
538 | 538 | if (INTL_INSTALLED) { |
539 | - $datetype = IntlDateFormatter::SHORT; |
|
540 | - $timetype = IntlDateFormatter::NONE; |
|
541 | - } |
|
539 | + $datetype = IntlDateFormatter::SHORT; |
|
540 | + $timetype = IntlDateFormatter::NONE; |
|
541 | + } |
|
542 | 542 | break; |
543 | 543 | case DATE_FORMAT_NUMBER_NO_YEAR: |
544 | 544 | $date_format = get_lang('dateFormatShortNumberNoYear', '', $language); |
545 | - if (INTL_INSTALLED) { |
|
546 | - $datetype = IntlDateFormatter::SHORT; |
|
547 | - $timetype = IntlDateFormatter::NONE; |
|
548 | - } |
|
545 | + if (INTL_INSTALLED) { |
|
546 | + $datetype = IntlDateFormatter::SHORT; |
|
547 | + $timetype = IntlDateFormatter::NONE; |
|
548 | + } |
|
549 | + break; |
|
550 | + case DATE_FORMAT_NUMBER: |
|
551 | + $date_format = get_lang('dateFormatShortNumber', '', $language); |
|
552 | + if (INTL_INSTALLED) { |
|
553 | + $datetype = IntlDateFormatter::SHORT; |
|
554 | + $timetype = IntlDateFormatter::NONE; |
|
555 | + } |
|
549 | 556 | break; |
550 | - case DATE_FORMAT_NUMBER: |
|
551 | - $date_format = get_lang('dateFormatShortNumber', '', $language); |
|
552 | - if (INTL_INSTALLED) { |
|
553 | - $datetype = IntlDateFormatter::SHORT; |
|
554 | - $timetype = IntlDateFormatter::NONE; |
|
555 | - } |
|
556 | - break; |
|
557 | 557 | case TIME_NO_SEC_FORMAT: |
558 | 558 | $date_format = get_lang('timeNoSecFormat', '', $language); |
559 | 559 | if (INTL_INSTALLED) { |
@@ -589,14 +589,14 @@ discard block |
||
589 | 589 | $timetype = IntlDateFormatter::SHORT; |
590 | 590 | } |
591 | 591 | break; |
592 | - case DATE_TIME_FORMAT_SHORT: |
|
592 | + case DATE_TIME_FORMAT_SHORT: |
|
593 | 593 | $date_format = get_lang('dateTimeFormatShort', '', $language); |
594 | 594 | if (INTL_INSTALLED) { |
595 | 595 | $datetype = IntlDateFormatter::FULL; |
596 | 596 | $timetype = IntlDateFormatter::SHORT; |
597 | 597 | } |
598 | 598 | break; |
599 | - case DATE_TIME_FORMAT_SHORT_TIME_FIRST: |
|
599 | + case DATE_TIME_FORMAT_SHORT_TIME_FIRST: |
|
600 | 600 | $date_format = get_lang('dateTimeFormatShortTimeFirst', '', $language); |
601 | 601 | if (INTL_INSTALLED) { |
602 | 602 | $datetype = IntlDateFormatter::FULL; |
@@ -1817,7 +1817,6 @@ discard block |
||
1817 | 1817 | |
1818 | 1818 | /** |
1819 | 1819 | * Return true a date is valid |
1820 | - |
|
1821 | 1820 | * @param string $date example: 2014-06-30 13:05:05 |
1822 | 1821 | * @param string $format example: "Y-m-d H:i:s" |
1823 | 1822 | * |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | ) { |
72 | 72 | mkdir($this->store_path.$this->session_id.'/'.$this->exercise_id.'/'.$this->question_id.'/'.$this->user_id, $directoryPermissions); |
73 | 73 | } |
74 | - } |
|
74 | + } |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Setting parameters: course id, session id, etc |
@@ -119,24 +119,24 @@ discard block |
||
119 | 119 | $this->question_id = 0; |
120 | 120 | } |
121 | 121 | |
122 | - $this->can_edit = false; |
|
122 | + $this->can_edit = false; |
|
123 | 123 | |
124 | - if (api_is_allowed_to_edit()) { |
|
125 | - $this->can_edit = true; |
|
126 | - } else { |
|
127 | - if ($this->user_id == api_get_user_id()) { |
|
128 | - $this->can_edit = true; |
|
129 | - } |
|
130 | - } |
|
124 | + if (api_is_allowed_to_edit()) { |
|
125 | + $this->can_edit = true; |
|
126 | + } else { |
|
127 | + if ($this->user_id == api_get_user_id()) { |
|
128 | + $this->can_edit = true; |
|
129 | + } |
|
130 | + } |
|
131 | 131 | |
132 | - // Settings the params array |
|
133 | - $this->params = $params; |
|
134 | - $this->store_path = api_get_path(SYS_COURSE_PATH).$this->course_info['path'].'/exercises/'; |
|
135 | - $this->create_user_folder(); |
|
136 | - $this->store_path = $this->store_path.implode('/', array($this->session_id, $this->exercise_id, $this->question_id, $this->user_id)).'/'; |
|
137 | - $this->filename = $this->generate_filename(); |
|
138 | - $this->store_filename = $this->store_path.$this->filename; |
|
139 | - } |
|
132 | + // Settings the params array |
|
133 | + $this->params = $params; |
|
134 | + $this->store_path = api_get_path(SYS_COURSE_PATH).$this->course_info['path'].'/exercises/'; |
|
135 | + $this->create_user_folder(); |
|
136 | + $this->store_path = $this->store_path.implode('/', array($this->session_id, $this->exercise_id, $this->question_id, $this->user_id)).'/'; |
|
137 | + $this->filename = $this->generate_filename(); |
|
138 | + $this->store_filename = $this->store_path.$this->filename; |
|
139 | + } |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * Generates the filename with the next format: |
@@ -187,30 +187,30 @@ discard block |
||
187 | 187 | return $delete_found; |
188 | 188 | } |
189 | 189 | |
190 | - /** |
|
191 | - * |
|
192 | - * Tricky stuff to deal with the feedback = 0 in exercises (all question per page) |
|
190 | + /** |
|
191 | + * |
|
192 | + * Tricky stuff to deal with the feedback = 0 in exercises (all question per page) |
|
193 | 193 | * @param int $exe_id |
194 | - */ |
|
194 | + */ |
|
195 | 195 | public function replace_with_real_exe($exe_id) |
196 | 196 | { |
197 | - $filename = null; |
|
198 | - //@ugly fix |
|
199 | - foreach($this->available_extensions as $extension) { |
|
200 | - $items = explode('-', $this->filename); |
|
201 | - $items[5] = 'temp_exe'; |
|
202 | - $filename = implode('-', $items); |
|
203 | - if (is_file($this->store_path.$filename.'.'.$extension)) { |
|
204 | - $old_name = $this->store_path.$filename.'.'.$extension; |
|
205 | - $items = explode('-', $this->filename); |
|
206 | - $items[5] = $exe_id; |
|
207 | - $filename = $filename = implode('-', $items); |
|
208 | - $new_name = $this->store_path.$filename.'.'.$extension; |
|
209 | - rename($old_name, $new_name); |
|
210 | - break; |
|
211 | - } |
|
212 | - } |
|
213 | - } |
|
197 | + $filename = null; |
|
198 | + //@ugly fix |
|
199 | + foreach($this->available_extensions as $extension) { |
|
200 | + $items = explode('-', $this->filename); |
|
201 | + $items[5] = 'temp_exe'; |
|
202 | + $filename = implode('-', $items); |
|
203 | + if (is_file($this->store_path.$filename.'.'.$extension)) { |
|
204 | + $old_name = $this->store_path.$filename.'.'.$extension; |
|
205 | + $items = explode('-', $this->filename); |
|
206 | + $items[5] = $exe_id; |
|
207 | + $filename = $filename = implode('-', $items); |
|
208 | + $new_name = $this->store_path.$filename.'.'.$extension; |
|
209 | + rename($old_name, $new_name); |
|
210 | + break; |
|
211 | + } |
|
212 | + } |
|
213 | + } |
|
214 | 214 | |
215 | 215 | /** |
216 | 216 | * @param bool $load_from_database |
@@ -218,24 +218,24 @@ discard block |
||
218 | 218 | */ |
219 | 219 | public function load_filename_if_exists($load_from_database = false) |
220 | 220 | { |
221 | - $filename = null; |
|
222 | - //@ugly fix |
|
223 | - foreach($this->available_extensions as $extension) { |
|
224 | - if (is_file($this->store_path.$this->filename.'.'.$extension)) { |
|
225 | - $filename = $this->filename.'.'.$extension; |
|
226 | - break; |
|
227 | - } |
|
228 | - } |
|
221 | + $filename = null; |
|
222 | + //@ugly fix |
|
223 | + foreach($this->available_extensions as $extension) { |
|
224 | + if (is_file($this->store_path.$this->filename.'.'.$extension)) { |
|
225 | + $filename = $this->filename.'.'.$extension; |
|
226 | + break; |
|
227 | + } |
|
228 | + } |
|
229 | 229 | |
230 | - // temp_exe |
|
231 | - if ($load_from_database) { |
|
230 | + // temp_exe |
|
231 | + if ($load_from_database) { |
|
232 | 232 | |
233 | - //Load the real filename just if exists |
|
234 | - if (isset($this->params['exe_id']) && isset($this->params['user_id']) && |
|
233 | + //Load the real filename just if exists |
|
234 | + if (isset($this->params['exe_id']) && isset($this->params['user_id']) && |
|
235 | 235 | isset($this->params['question_id']) && isset($this->params['session_id']) && isset($this->params['course_id']) |
236 | 236 | ) { |
237 | - $attempt_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
238 | - $sql = "SELECT filename FROM $attempt_table |
|
237 | + $attempt_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
238 | + $sql = "SELECT filename FROM $attempt_table |
|
239 | 239 | WHERE |
240 | 240 | exe_id = ".$this->params['exe_id']." AND |
241 | 241 | user_id = ".$this->params['user_id']." AND |
@@ -243,107 +243,107 @@ discard block |
||
243 | 243 | session_id = ".$this->params['session_id']." AND |
244 | 244 | course_code = '".$this->course_info['code']."' |
245 | 245 | LIMIT 1"; |
246 | - $result = Database::query($sql); |
|
247 | - $result = Database::fetch_row($result,'ASSOC'); |
|
246 | + $result = Database::query($sql); |
|
247 | + $result = Database::fetch_row($result,'ASSOC'); |
|
248 | 248 | |
249 | - if (isset($result) && isset($result[0]) && !empty($result[0])) { |
|
250 | - $filename = $result[0]; |
|
251 | - } |
|
252 | - } |
|
253 | - } |
|
249 | + if (isset($result) && isset($result[0]) && !empty($result[0])) { |
|
250 | + $filename = $result[0]; |
|
251 | + } |
|
252 | + } |
|
253 | + } |
|
254 | 254 | |
255 | - if (is_file($this->store_path.$filename)) { |
|
256 | - return $this->store_path.$filename; |
|
257 | - } |
|
255 | + if (is_file($this->store_path.$filename)) { |
|
256 | + return $this->store_path.$filename; |
|
257 | + } |
|
258 | 258 | |
259 | - return null; |
|
260 | - } |
|
259 | + return null; |
|
260 | + } |
|
261 | 261 | |
262 | - /** |
|
263 | - * |
|
264 | - * Get the URL of the file |
|
265 | - * path courses/XXX/exercises/(session_id)/(exercise_id)/(question_id)/(user_id)/ |
|
262 | + /** |
|
263 | + * |
|
264 | + * Get the URL of the file |
|
265 | + * path courses/XXX/exercises/(session_id)/(exercise_id)/(question_id)/(user_id)/ |
|
266 | 266 | * @param int $force_download |
267 | - * |
|
268 | - * @return string |
|
269 | - */ |
|
267 | + * |
|
268 | + * @return string |
|
269 | + */ |
|
270 | 270 | public function get_public_url($force_download = 0) |
271 | 271 | { |
272 | - $params = $this->get_params(); |
|
273 | - $filename = basename($this->load_filename_if_exists()); |
|
272 | + $params = $this->get_params(); |
|
273 | + $filename = basename($this->load_filename_if_exists()); |
|
274 | 274 | $url = api_get_path(WEB_COURSE_PATH).$this->course_info['path'].'/exercises/'.$params['session_id'].'/'.$params['exercise_id'].'/'.$params['question_id'].'/'.$params['user_id'].'/'.$filename; |
275 | - return $url; |
|
276 | - } |
|
275 | + return $url; |
|
276 | + } |
|
277 | 277 | |
278 | - /** |
|
279 | - * Uploads the nanogong wav file |
|
278 | + /** |
|
279 | + * Uploads the nanogong wav file |
|
280 | 280 | * @param bool |
281 | - */ |
|
282 | - public function upload_file($is_nano = false) |
|
283 | - { |
|
284 | - if (!empty($_FILES)) { |
|
285 | - $upload_ok = process_uploaded_file($_FILES['file'], false); |
|
286 | - |
|
287 | - if (!is_uploaded_file($_FILES['file']['tmp_name'])) { |
|
288 | - return 0; |
|
289 | - } |
|
281 | + */ |
|
282 | + public function upload_file($is_nano = false) |
|
283 | + { |
|
284 | + if (!empty($_FILES)) { |
|
285 | + $upload_ok = process_uploaded_file($_FILES['file'], false); |
|
290 | 286 | |
291 | - if ($upload_ok) { |
|
292 | - // Check if there is enough space to save the file |
|
293 | - if (!DocumentManager::enough_space($_FILES['file']['size'], DocumentManager::get_course_quota())) { |
|
294 | - return 0; |
|
295 | - } |
|
287 | + if (!is_uploaded_file($_FILES['file']['tmp_name'])) { |
|
288 | + return 0; |
|
289 | + } |
|
296 | 290 | |
297 | - //first we delete everything before uploading the file |
|
298 | - $this->delete_files(); |
|
291 | + if ($upload_ok) { |
|
292 | + // Check if there is enough space to save the file |
|
293 | + if (!DocumentManager::enough_space($_FILES['file']['size'], DocumentManager::get_course_quota())) { |
|
294 | + return 0; |
|
295 | + } |
|
299 | 296 | |
300 | - //Reload the filename variable |
|
301 | - $file_name = add_ext_on_mime($_FILES['file']['name'], $_FILES['file']['type']); |
|
302 | - $file_name = strtolower($file_name); |
|
303 | - $file_info = pathinfo($file_name); |
|
297 | + //first we delete everything before uploading the file |
|
298 | + $this->delete_files(); |
|
304 | 299 | |
305 | - if ($is_nano == true) { |
|
306 | - $file_info['extension'] = 'wav'; |
|
307 | - } |
|
300 | + //Reload the filename variable |
|
301 | + $file_name = add_ext_on_mime($_FILES['file']['name'], $_FILES['file']['type']); |
|
302 | + $file_name = strtolower($file_name); |
|
303 | + $file_info = pathinfo($file_name); |
|
308 | 304 | |
309 | - $file_name = $this->filename.'.'.$file_info['extension']; |
|
305 | + if ($is_nano == true) { |
|
306 | + $file_info['extension'] = 'wav'; |
|
307 | + } |
|
310 | 308 | |
311 | - if (in_array($file_info['extension'], $this->available_extensions)) { |
|
312 | - if (move_uploaded_file($_FILES['file']['tmp_name'], $this->store_path.$file_name)) { |
|
313 | - $this->store_filename = $this->store_path.$file_name; |
|
314 | - return 1; |
|
315 | - } |
|
316 | - } |
|
317 | - } |
|
318 | - } |
|
309 | + $file_name = $this->filename.'.'.$file_info['extension']; |
|
310 | + |
|
311 | + if (in_array($file_info['extension'], $this->available_extensions)) { |
|
312 | + if (move_uploaded_file($_FILES['file']['tmp_name'], $this->store_path.$file_name)) { |
|
313 | + $this->store_filename = $this->store_path.$file_name; |
|
314 | + return 1; |
|
315 | + } |
|
316 | + } |
|
317 | + } |
|
318 | + } |
|
319 | 319 | |
320 | - return 0; |
|
321 | - } |
|
320 | + return 0; |
|
321 | + } |
|
322 | 322 | |
323 | - /** |
|
324 | - * Show the audio file + a button to download |
|
323 | + /** |
|
324 | + * Show the audio file + a button to download |
|
325 | 325 | * @param bool |
326 | - */ |
|
327 | - public function show_audio_file($show_delete_button = false) |
|
328 | - { |
|
329 | - $html = ''; |
|
330 | - $file_path = $this->load_filename_if_exists(); |
|
331 | - |
|
332 | - if (!empty($file_path)) { |
|
333 | - $url = $this->get_public_url(true); |
|
334 | - $actions = Display::url(Display::return_icon('save.png', get_lang('Download'), array(), ICON_SIZE_SMALL), $url, array('target'=>'_blank')); |
|
335 | - $download_button = Display::url(get_lang('Download'), $url, array('class' =>'btn btn-default')); |
|
336 | - |
|
337 | - if ($show_delete_button) { |
|
338 | - $actions .= ' '.Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), "#", array('onclick'=>'delete_file();')); |
|
339 | - } |
|
326 | + */ |
|
327 | + public function show_audio_file($show_delete_button = false) |
|
328 | + { |
|
329 | + $html = ''; |
|
330 | + $file_path = $this->load_filename_if_exists(); |
|
331 | + |
|
332 | + if (!empty($file_path)) { |
|
333 | + $url = $this->get_public_url(true); |
|
334 | + $actions = Display::url(Display::return_icon('save.png', get_lang('Download'), array(), ICON_SIZE_SMALL), $url, array('target'=>'_blank')); |
|
335 | + $download_button = Display::url(get_lang('Download'), $url, array('class' =>'btn btn-default')); |
|
340 | 336 | |
341 | - $basename = basename($file_path); |
|
342 | - $path_info = pathinfo($basename); |
|
337 | + if ($show_delete_button) { |
|
338 | + $actions .= ' '.Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), "#", array('onclick'=>'delete_file();')); |
|
339 | + } |
|
343 | 340 | |
344 | - if ($path_info['extension'] == 'wav') { |
|
341 | + $basename = basename($file_path); |
|
342 | + $path_info = pathinfo($basename); |
|
345 | 343 | |
346 | - $html .= '<script> |
|
344 | + if ($path_info['extension'] == 'wav') { |
|
345 | + |
|
346 | + $html .= '<script> |
|
347 | 347 | $(document).ready( function() { |
348 | 348 | var java_enabled = navigator.javaEnabled(); |
349 | 349 | |
@@ -357,56 +357,56 @@ discard block |
||
357 | 357 | }); |
358 | 358 | </script>'; |
359 | 359 | |
360 | - $html .= '<div id="nanogong_player_id" class="nanogong_player_container">'; |
|
361 | - $html .= '<div class="action_player">'.$actions.'</div>'; |
|
362 | - $html .= '<div class="nanogong_player">'; |
|
363 | - $html .= '<applet id="nanogong_player" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" ALIGN="middle">'; |
|
364 | - $html .= '<param name="ShowRecordButton" value="false" />'; // default true |
|
365 | - $html .= '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
366 | - //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
367 | - $html .= '<param name="ShowTime" value="true" />'; // default false |
|
368 | - $html .= '<param name="Color" value="#FFFFFF" />'; |
|
360 | + $html .= '<div id="nanogong_player_id" class="nanogong_player_container">'; |
|
361 | + $html .= '<div class="action_player">'.$actions.'</div>'; |
|
362 | + $html .= '<div class="nanogong_player">'; |
|
363 | + $html .= '<applet id="nanogong_player" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" ALIGN="middle">'; |
|
364 | + $html .= '<param name="ShowRecordButton" value="false" />'; // default true |
|
365 | + $html .= '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
366 | + //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
367 | + $html .= '<param name="ShowTime" value="true" />'; // default false |
|
368 | + $html .= '<param name="Color" value="#FFFFFF" />'; |
|
369 | 369 | $html .= '<param name="ShowSpeedButton" value="false" />'; |
370 | - //echo '<param name="StartTime" value="10.5" />'; |
|
371 | - //echo '<param name="EndTime" value="65" />'; |
|
372 | - $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
373 | - //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
374 | - //Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
375 | - //echo '<param name="SamplingRate" value="32000" />'; |
|
376 | - //echo '<param name="MaxDuration" value="60" />'; |
|
377 | - $html .= '<param name="SoundFileURL" value="'.$url.'" />';//load a file |(default "") |
|
378 | - $html .= '</applet>'; |
|
379 | - $html .= '</div>'; |
|
380 | - $html .= '</div>'; |
|
370 | + //echo '<param name="StartTime" value="10.5" />'; |
|
371 | + //echo '<param name="EndTime" value="65" />'; |
|
372 | + $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
373 | + //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
374 | + //Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
375 | + //echo '<param name="SamplingRate" value="32000" />'; |
|
376 | + //echo '<param name="MaxDuration" value="60" />'; |
|
377 | + $html .= '<param name="SoundFileURL" value="'.$url.'" />';//load a file |(default "") |
|
378 | + $html .= '</applet>'; |
|
379 | + $html .= '</div>'; |
|
380 | + $html .= '</div>'; |
|
381 | 381 | $html .= '<div id="nanogong_warning">'.Display::return_message(get_lang('BrowserDoesNotSupportNanogongPlayer'), 'warning').$download_button.'</div>'; |
382 | 382 | |
383 | - } elseif(in_array($path_info['extension'],array('mp3', 'ogg','wav'))) { |
|
384 | - $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; |
|
385 | - $html .= '<link rel="stylesheet" href="'.$js_path.'jquery-jplayer/skin/blue.monday/css/jplayer.blue.monday.css" type="text/css">'; |
|
386 | - $html .= '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jplayer/jquery.jplayer.min.js"></script>'; |
|
383 | + } elseif(in_array($path_info['extension'],array('mp3', 'ogg','wav'))) { |
|
384 | + $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; |
|
385 | + $html .= '<link rel="stylesheet" href="'.$js_path.'jquery-jplayer/skin/blue.monday/css/jplayer.blue.monday.css" type="text/css">'; |
|
386 | + $html .= '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jplayer/jquery.jplayer.min.js"></script>'; |
|
387 | 387 | |
388 | - $html .= '<div class="nanogong_player"></div>'; |
|
389 | - $html .= '<br /><div class="action_player">'.$actions.'</div><br /><br /><br />'; |
|
388 | + $html .= '<div class="nanogong_player"></div>'; |
|
389 | + $html .= '<br /><div class="action_player">'.$actions.'</div><br /><br /><br />'; |
|
390 | 390 | |
391 | 391 | $params = array( |
392 | 392 | 'url' => $url, |
393 | 393 | 'extension' =>$path_info['extension'], |
394 | 394 | 'count'=> 1 |
395 | - ); |
|
395 | + ); |
|
396 | 396 | $jquery = DocumentManager::generate_jplayer_jquery($params); |
397 | - $html .= '<script> |
|
397 | + $html .= '<script> |
|
398 | 398 | $(document).ready( function() { |
399 | 399 | //Experimental changes to preview mp3, ogg files |
400 | 400 | '.$jquery.' |
401 | 401 | }); |
402 | 402 | </script>'; |
403 | - $html .= DocumentManager::generate_media_preview(1, 'advanced'); |
|
404 | - } |
|
405 | - } |
|
403 | + $html .= DocumentManager::generate_media_preview(1, 'advanced'); |
|
404 | + } |
|
405 | + } |
|
406 | 406 | return $html; |
407 | - } |
|
407 | + } |
|
408 | 408 | |
409 | - /* |
|
409 | + /* |
|
410 | 410 | var filename = document.getElementById("audio_title").value+".wav"; |
411 | 411 | var filename = filename.replace(/\s/g, "_");//replace spaces by _ |
412 | 412 | var filename = encodeURIComponent(filename); |
@@ -416,19 +416,19 @@ discard block |
||
416 | 416 | var urlnanogong="'.$url.'?filename="+filename+"&filepath="+filepath+"&dir="+dir+"&course_code="+course_code; |
417 | 417 | */ |
418 | 418 | |
419 | - /** |
|
420 | - * Returns the nanogong javascript code |
|
421 | - * @return string |
|
422 | - */ |
|
419 | + /** |
|
420 | + * Returns the nanogong javascript code |
|
421 | + * @return string |
|
422 | + */ |
|
423 | 423 | public function return_js() |
424 | 424 | { |
425 | - $params = $this->get_params(true); |
|
426 | - $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params.'&is_nano=1'; |
|
427 | - $url_load_file = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=show_audio&'.$params; |
|
425 | + $params = $this->get_params(true); |
|
426 | + $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params.'&is_nano=1'; |
|
427 | + $url_load_file = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=show_audio&'.$params; |
|
428 | 428 | |
429 | - $url_delete = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=delete&'.$params; |
|
429 | + $url_delete = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=delete&'.$params; |
|
430 | 430 | |
431 | - $js = '<script language="javascript"> |
|
431 | + $js = '<script language="javascript"> |
|
432 | 432 | |
433 | 433 | //lang vars |
434 | 434 | |
@@ -544,77 +544,77 @@ discard block |
||
544 | 544 | return false; |
545 | 545 | } |
546 | 546 | </script>'; |
547 | - return $js; |
|
548 | - } |
|
547 | + return $js; |
|
548 | + } |
|
549 | 549 | |
550 | - /** |
|
551 | - * Returns the HTML form to upload a nano file or upload a file |
|
550 | + /** |
|
551 | + * Returns the HTML form to upload a nano file or upload a file |
|
552 | 552 | * @param string |
553 | - */ |
|
554 | - public function return_form($message = null) |
|
553 | + */ |
|
554 | + public function return_form($message = null) |
|
555 | 555 | { |
556 | 556 | |
557 | - $params = $this->get_params(true); |
|
558 | - $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params; |
|
557 | + $params = $this->get_params(true); |
|
558 | + $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params; |
|
559 | 559 | |
560 | - //check browser support and load form |
|
561 | - $array_browser = api_browser_support('check_browser'); |
|
560 | + //check browser support and load form |
|
561 | + $array_browser = api_browser_support('check_browser'); |
|
562 | 562 | |
563 | - $preview_file = $this->show_audio_file(true, true); |
|
563 | + $preview_file = $this->show_audio_file(true, true); |
|
564 | 564 | |
565 | 565 | $preview_file = Display::div( |
566 | 566 | $preview_file, |
567 | 567 | array('id' => 'preview', 'style' => 'text-align:center; padding-left: 25px;') |
568 | 568 | ); |
569 | 569 | |
570 | - $html = '<center>'; |
|
570 | + $html = '<center>'; |
|
571 | 571 | |
572 | - //Use normal upload file |
|
573 | - $html .= Display::return_icon('microphone.png', get_lang('PressRecordButton'),'', ICON_SIZE_BIG); |
|
574 | - $html .='<br />'; |
|
572 | + //Use normal upload file |
|
573 | + $html .= Display::return_icon('microphone.png', get_lang('PressRecordButton'),'', ICON_SIZE_BIG); |
|
574 | + $html .='<br />'; |
|
575 | 575 | |
576 | - $html .= '<div id="nanogong_div">'; |
|
576 | + $html .= '<div id="nanogong_div">'; |
|
577 | 577 | |
578 | - $html .= '<applet id="nanogong" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" align="middle">'; |
|
579 | - //echo '<param name="ShowRecordButton" value="false" />'; // default true |
|
580 | - // echo '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
578 | + $html .= '<applet id="nanogong" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" align="middle">'; |
|
579 | + //echo '<param name="ShowRecordButton" value="false" />'; // default true |
|
580 | + // echo '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
581 | 581 | $html .= '<param name="ShowSpeedButton" value="false" />'; // default true |
582 | - //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
583 | - $html .= '<param name="ShowTime" value="true" />'; // default false |
|
584 | - $html .= '<param name="Color" value="#FFFFFF" />'; // default #FFFFFF |
|
585 | - //echo '<param name="StartTime" value="10.5" />'; |
|
586 | - //echo '<param name="EndTime" value="65" />'; |
|
587 | - $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
588 | - //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
582 | + //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
583 | + $html .= '<param name="ShowTime" value="true" />'; // default false |
|
584 | + $html .= '<param name="Color" value="#FFFFFF" />'; // default #FFFFFF |
|
585 | + //echo '<param name="StartTime" value="10.5" />'; |
|
586 | + //echo '<param name="EndTime" value="65" />'; |
|
587 | + $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
588 | + //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
589 | 589 | |
590 | - //echo '<param name="SamplingRate" value="32000" />';//Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
591 | - //echo '<param name="MaxDuration" value="60" />'; |
|
592 | - //echo '<param name="SoundFileURL" value="http://somewhere.com/mysoundfile.wav" />';//load a file |(default "") |
|
593 | - $html .= '</applet>'; |
|
590 | + //echo '<param name="SamplingRate" value="32000" />';//Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
591 | + //echo '<param name="MaxDuration" value="60" />'; |
|
592 | + //echo '<param name="SoundFileURL" value="http://somewhere.com/mysoundfile.wav" />';//load a file |(default "") |
|
593 | + $html .= '</applet>'; |
|
594 | 594 | |
595 | - $html .= '<br /><br /><br />'; |
|
595 | + $html .= '<br /><br /><br />'; |
|
596 | 596 | |
597 | 597 | $html .= '<form name="form_nanogong_advanced">'; |
598 | - $html .= '<input type="hidden" name="is_nano" value="1">'; |
|
599 | - $html .= '<a href="#" class="btn btn-default" onclick="send_voice()" />'.get_lang('SendRecord').'</a>'; |
|
600 | - $html .= '</form></div>'; |
|
598 | + $html .= '<input type="hidden" name="is_nano" value="1">'; |
|
599 | + $html .= '<a href="#" class="btn btn-default" onclick="send_voice()" />'.get_lang('SendRecord').'</a>'; |
|
600 | + $html .= '</form></div>'; |
|
601 | 601 | |
602 | 602 | $html .= Display::url(get_lang('ProblemsRecordingUploadYourOwnAudioFile'), 'javascript:void(0)', array('onclick' => 'show_simple_upload_form();')); |
603 | 603 | |
604 | - $html .= '<br /><br /><div id="no_nanogong_div">'; |
|
605 | - //$html .= Display::return_message(get_lang('BrowserNotSupportNanogongSend'), 'warning'); |
|
606 | - $html .= '<form id="form_nanogong_simple" class="form-search" action="'.$url.'" name="form_nanogong" method="POST" enctype="multipart/form-data">'; |
|
607 | - $html .= '<input type="file" name="file">'; |
|
608 | - $html .= '<a href="#" class="btn btn-default" onclick="upload_file()" /><em class="fa fa-upload"></em> '.get_lang('UploadFile').'</a>'; |
|
609 | - $html .= '</form>'; |
|
604 | + $html .= '<br /><br /><div id="no_nanogong_div">'; |
|
605 | + //$html .= Display::return_message(get_lang('BrowserNotSupportNanogongSend'), 'warning'); |
|
606 | + $html .= '<form id="form_nanogong_simple" class="form-search" action="'.$url.'" name="form_nanogong" method="POST" enctype="multipart/form-data">'; |
|
607 | + $html .= '<input type="file" name="file">'; |
|
608 | + $html .= '<a href="#" class="btn btn-default" onclick="upload_file()" /><em class="fa fa-upload"></em> '.get_lang('UploadFile').'</a>'; |
|
609 | + $html .= '</form>'; |
|
610 | 610 | $html .= '</div>'; |
611 | - $html .= '</center>'; |
|
612 | - $html .= '<div style="display:none" id="status_ok" class="confirmation-message"></div><div style="display:none" id="status_warning" class="warning-message"></div>'; |
|
613 | - $html .= '<div id="messages">'.$message.'</div>'; |
|
614 | - $html .= $preview_file; |
|
611 | + $html .= '</center>'; |
|
612 | + $html .= '<div style="display:none" id="status_ok" class="confirmation-message"></div><div style="display:none" id="status_warning" class="warning-message"></div>'; |
|
613 | + $html .= '<div id="messages">'.$message.'</div>'; |
|
614 | + $html .= $preview_file; |
|
615 | 615 | |
616 | - return $html; |
|
617 | - } |
|
616 | + return $html; |
|
617 | + } |
|
618 | 618 | |
619 | 619 | /** |
620 | 620 | * @param bool $return_as_query |
@@ -622,15 +622,15 @@ discard block |
||
622 | 622 | */ |
623 | 623 | public function get_params($return_as_query = false) |
624 | 624 | { |
625 | - if (empty($this->params)) { |
|
626 | - return false; |
|
627 | - } |
|
628 | - if ($return_as_query) { |
|
629 | - return http_build_query($this->params); |
|
630 | - } |
|
625 | + if (empty($this->params)) { |
|
626 | + return false; |
|
627 | + } |
|
628 | + if ($return_as_query) { |
|
629 | + return http_build_query($this->params); |
|
630 | + } |
|
631 | 631 | |
632 | - return $this->params; |
|
633 | - } |
|
632 | + return $this->params; |
|
633 | + } |
|
634 | 634 | |
635 | 635 | /** |
636 | 636 | * @param $attribute |
@@ -638,18 +638,18 @@ discard block |
||
638 | 638 | */ |
639 | 639 | public function get_param_value($attribute) |
640 | 640 | { |
641 | - if (isset($this->params[$attribute])) { |
|
642 | - return $this->params[$attribute]; |
|
643 | - } |
|
644 | - } |
|
645 | - |
|
646 | - /** |
|
647 | - * Show a button to load the form |
|
648 | - * @return string |
|
649 | - */ |
|
641 | + if (isset($this->params[$attribute])) { |
|
642 | + return $this->params[$attribute]; |
|
643 | + } |
|
644 | + } |
|
645 | + |
|
646 | + /** |
|
647 | + * Show a button to load the form |
|
648 | + * @return string |
|
649 | + */ |
|
650 | 650 | public function show_button() |
651 | 651 | { |
652 | - $params_string = $this->get_params(true); |
|
652 | + $params_string = $this->get_params(true); |
|
653 | 653 | |
654 | 654 | $url = api_get_path(WEB_AJAX_PATH) |
655 | 655 | . 'nanogong.ajax.php?a=show_form&' |
@@ -664,7 +664,7 @@ discard block |
||
664 | 664 | 'data-title' => get_lang('RecordAnswer') |
665 | 665 | ] |
666 | 666 | ); |
667 | - $html .= '<br /><br />'.Display::return_message(get_lang('UseTheMessageBelowToAddSomeComments')); |
|
668 | - return $html; |
|
669 | - } |
|
667 | + $html .= '<br /><br />'.Display::return_message(get_lang('UseTheMessageBelowToAddSomeComments')); |
|
668 | + return $html; |
|
669 | + } |
|
670 | 670 | } |
@@ -107,14 +107,14 @@ |
||
107 | 107 | return $resu; |
108 | 108 | } |
109 | 109 | |
110 | - /** |
|
111 | - * @author Sebastien Piraux <[email protected]> |
|
112 | - * @param sql : a sql query (as a string) |
|
113 | - * @return hours_array |
|
114 | - * @desc Return an assoc array. Keys are the hours, values are |
|
115 | - * the number of time this hours was found. |
|
116 | - * key 'total' return the sum of all number of time hours |
|
117 | - * appear |
|
110 | + /** |
|
111 | + * @author Sebastien Piraux <[email protected]> |
|
112 | + * @param sql : a sql query (as a string) |
|
113 | + * @return hours_array |
|
114 | + * @desc Return an assoc array. Keys are the hours, values are |
|
115 | + * the number of time this hours was found. |
|
116 | + * key 'total' return the sum of all number of time hours |
|
117 | + * appear |
|
118 | 118 | */ |
119 | 119 | public static function hoursTab($sql) |
120 | 120 | { |
@@ -5,42 +5,42 @@ |
||
5 | 5 | * @deprecated Don't use this class |
6 | 6 | */ |
7 | 7 | class Rights { |
8 | - private static $rights_cache = array(); |
|
9 | - private static $rights = array ( |
|
10 | - 'show_tabs:reports' => |
|
11 | - array ( |
|
12 | - 'type' => 'const', |
|
13 | - 'const' => 'true' ) |
|
14 | - ); |
|
8 | + private static $rights_cache = array(); |
|
9 | + private static $rights = array ( |
|
10 | + 'show_tabs:reports' => |
|
11 | + array ( |
|
12 | + 'type' => 'const', |
|
13 | + 'const' => 'true' ) |
|
14 | + ); |
|
15 | 15 | |
16 | - // warning the goal of this function is to enforce rights managment in Chamilo |
|
17 | - // thus default return value is always true |
|
18 | - public static function hasRight($handler) { |
|
19 | - if (array_key_exists($handler, self::$rights_cache)) |
|
20 | - return self::$rights_cache[$handler]; |
|
16 | + // warning the goal of this function is to enforce rights managment in Chamilo |
|
17 | + // thus default return value is always true |
|
18 | + public static function hasRight($handler) { |
|
19 | + if (array_key_exists($handler, self::$rights_cache)) |
|
20 | + return self::$rights_cache[$handler]; |
|
21 | 21 | |
22 | - if (!array_key_exists($handler, self::$rights)) |
|
23 | - return true; // handler does not exists |
|
22 | + if (!array_key_exists($handler, self::$rights)) |
|
23 | + return true; // handler does not exists |
|
24 | 24 | |
25 | - if (self::$rights[$handler]['type'] == 'sql') { |
|
26 | - $result = Database::query(self::$rights[$handler]['sql']); |
|
27 | - if (Database::num_rows($result) > 0) |
|
28 | - $result = true; |
|
29 | - else |
|
30 | - $result = false; |
|
31 | - } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | - $result = self::$rights[$handler]['const']; |
|
33 | - else if (self::$rights[$handler]['type'] == 'func') |
|
34 | - $result = self::$rights[$handler]['func'](); |
|
35 | - else // handler type not implemented |
|
36 | - return true; |
|
37 | - self::$rights_cache[$handler] = $result; |
|
38 | - return $result; |
|
39 | - } |
|
25 | + if (self::$rights[$handler]['type'] == 'sql') { |
|
26 | + $result = Database::query(self::$rights[$handler]['sql']); |
|
27 | + if (Database::num_rows($result) > 0) |
|
28 | + $result = true; |
|
29 | + else |
|
30 | + $result = false; |
|
31 | + } else if (self::$rights[$handler]['type'] == 'const') |
|
32 | + $result = self::$rights[$handler]['const']; |
|
33 | + else if (self::$rights[$handler]['type'] == 'func') |
|
34 | + $result = self::$rights[$handler]['func'](); |
|
35 | + else // handler type not implemented |
|
36 | + return true; |
|
37 | + self::$rights_cache[$handler] = $result; |
|
38 | + return $result; |
|
39 | + } |
|
40 | 40 | |
41 | - public static function hasRightClosePageWithError($handler) { |
|
42 | - if (hasRight($handler) == false) |
|
43 | - die("You are not allowed here"); //FIXME |
|
44 | - } |
|
41 | + public static function hasRightClosePageWithError($handler) { |
|
42 | + if (hasRight($handler) == false) |
|
43 | + die("You are not allowed here"); //FIXME |
|
44 | + } |
|
45 | 45 | |
46 | 46 | } |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
176 | - * @param string $pluginName |
|
177 | - * @param int $urlId |
|
178 | - */ |
|
176 | + * @param string $pluginName |
|
177 | + * @param int $urlId |
|
178 | + */ |
|
179 | 179 | public function uninstall($pluginName, $urlId = null) |
180 | 180 | { |
181 | 181 | if (empty($urlId)) { |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
255 | - * @param string $region |
|
256 | - * @param string $template |
|
257 | - * @param bool $forced |
|
258 | - * |
|
259 | - * @return null|string |
|
260 | - */ |
|
255 | + * @param string $region |
|
256 | + * @param string $template |
|
257 | + * @param bool $forced |
|
258 | + * |
|
259 | + * @return null|string |
|
260 | + */ |
|
261 | 261 | public function load_region($region, $template, $forced = false) |
262 | 262 | { |
263 | 263 | if ($region == 'course_tool_plugin') { |