@@ -12,72 +12,72 @@ |
||
12 | 12 | * @access public |
13 | 13 | */ |
14 | 14 | class nusoap_fault extends nusoap_base { |
15 | - /** |
|
16 | - * The fault code (client|server) |
|
17 | - * @var string |
|
18 | - * @access private |
|
19 | - */ |
|
20 | - var $faultcode; |
|
21 | - /** |
|
22 | - * The fault actor |
|
23 | - * @var string |
|
24 | - * @access private |
|
25 | - */ |
|
26 | - var $faultactor; |
|
27 | - /** |
|
28 | - * The fault string, a description of the fault |
|
29 | - * @var string |
|
30 | - * @access private |
|
31 | - */ |
|
32 | - var $faultstring; |
|
33 | - /** |
|
34 | - * The fault detail, typically a string or array of string |
|
35 | - * @var mixed |
|
36 | - * @access private |
|
37 | - */ |
|
38 | - var $faultdetail; |
|
15 | + /** |
|
16 | + * The fault code (client|server) |
|
17 | + * @var string |
|
18 | + * @access private |
|
19 | + */ |
|
20 | + var $faultcode; |
|
21 | + /** |
|
22 | + * The fault actor |
|
23 | + * @var string |
|
24 | + * @access private |
|
25 | + */ |
|
26 | + var $faultactor; |
|
27 | + /** |
|
28 | + * The fault string, a description of the fault |
|
29 | + * @var string |
|
30 | + * @access private |
|
31 | + */ |
|
32 | + var $faultstring; |
|
33 | + /** |
|
34 | + * The fault detail, typically a string or array of string |
|
35 | + * @var mixed |
|
36 | + * @access private |
|
37 | + */ |
|
38 | + var $faultdetail; |
|
39 | 39 | |
40 | - /** |
|
41 | - * constructor |
|
42 | - * |
|
43 | - * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server) |
|
44 | - * @param string $faultactor only used when msg routed between multiple actors |
|
45 | - * @param string $faultstring human readable error message |
|
46 | - * @param mixed $faultdetail detail, typically a string or array of string |
|
47 | - */ |
|
48 | - function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){ |
|
49 | - parent::nusoap_base(); |
|
50 | - $this->faultcode = $faultcode; |
|
51 | - $this->faultactor = $faultactor; |
|
52 | - $this->faultstring = $faultstring; |
|
53 | - $this->faultdetail = $faultdetail; |
|
54 | - } |
|
40 | + /** |
|
41 | + * constructor |
|
42 | + * |
|
43 | + * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server) |
|
44 | + * @param string $faultactor only used when msg routed between multiple actors |
|
45 | + * @param string $faultstring human readable error message |
|
46 | + * @param mixed $faultdetail detail, typically a string or array of string |
|
47 | + */ |
|
48 | + function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){ |
|
49 | + parent::nusoap_base(); |
|
50 | + $this->faultcode = $faultcode; |
|
51 | + $this->faultactor = $faultactor; |
|
52 | + $this->faultstring = $faultstring; |
|
53 | + $this->faultdetail = $faultdetail; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * serialize a fault |
|
58 | - * |
|
59 | - * @return string The serialization of the fault instance. |
|
60 | - * @access public |
|
61 | - */ |
|
62 | - function serialize(){ |
|
63 | - $ns_string = ''; |
|
64 | - foreach($this->namespaces as $k => $v){ |
|
65 | - $ns_string .= "\n xmlns:$k=\"$v\""; |
|
66 | - } |
|
67 | - $return_msg = |
|
68 | - '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>'. |
|
69 | - '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.">\n". |
|
70 | - '<SOAP-ENV:Body>'. |
|
71 | - '<SOAP-ENV:Fault>'. |
|
72 | - $this->serialize_val($this->faultcode, 'faultcode'). |
|
73 | - $this->serialize_val($this->faultactor, 'faultactor'). |
|
74 | - $this->serialize_val($this->faultstring, 'faultstring'). |
|
75 | - $this->serialize_val($this->faultdetail, 'detail'). |
|
76 | - '</SOAP-ENV:Fault>'. |
|
77 | - '</SOAP-ENV:Body>'. |
|
78 | - '</SOAP-ENV:Envelope>'; |
|
79 | - return $return_msg; |
|
80 | - } |
|
56 | + /** |
|
57 | + * serialize a fault |
|
58 | + * |
|
59 | + * @return string The serialization of the fault instance. |
|
60 | + * @access public |
|
61 | + */ |
|
62 | + function serialize(){ |
|
63 | + $ns_string = ''; |
|
64 | + foreach($this->namespaces as $k => $v){ |
|
65 | + $ns_string .= "\n xmlns:$k=\"$v\""; |
|
66 | + } |
|
67 | + $return_msg = |
|
68 | + '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>'. |
|
69 | + '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.">\n". |
|
70 | + '<SOAP-ENV:Body>'. |
|
71 | + '<SOAP-ENV:Fault>'. |
|
72 | + $this->serialize_val($this->faultcode, 'faultcode'). |
|
73 | + $this->serialize_val($this->faultactor, 'faultactor'). |
|
74 | + $this->serialize_val($this->faultstring, 'faultstring'). |
|
75 | + $this->serialize_val($this->faultdetail, 'detail'). |
|
76 | + '</SOAP-ENV:Fault>'. |
|
77 | + '</SOAP-ENV:Body>'. |
|
78 | + '</SOAP-ENV:Envelope>'; |
|
79 | + return $return_msg; |
|
80 | + } |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @param string $faultstring human readable error message |
46 | 46 | * @param mixed $faultdetail detail, typically a string or array of string |
47 | 47 | */ |
48 | - function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){ |
|
48 | + function nusoap_fault($faultcode, $faultactor = '', $faultstring = '', $faultdetail = '') { |
|
49 | 49 | parent::nusoap_base(); |
50 | 50 | $this->faultcode = $faultcode; |
51 | 51 | $this->faultactor = $faultactor; |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | * @return string The serialization of the fault instance. |
60 | 60 | * @access public |
61 | 61 | */ |
62 | - function serialize(){ |
|
62 | + function serialize() { |
|
63 | 63 | $ns_string = ''; |
64 | - foreach($this->namespaces as $k => $v){ |
|
64 | + foreach ($this->namespaces as $k => $v) { |
|
65 | 65 | $ns_string .= "\n xmlns:$k=\"$v\""; |
66 | 66 | } |
67 | 67 | $return_msg = |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | var $root_struct_name = ''; |
19 | 19 | var $root_struct_namespace = ''; |
20 | 20 | var $root_header = ''; |
21 | - var $document = ''; // incoming SOAP body (text) |
|
21 | + var $document = ''; // incoming SOAP body (text) |
|
22 | 22 | // determines where in the message we are (envelope,header,body,method) |
23 | 23 | var $status = ''; |
24 | 24 | var $position = 0; |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | var $fault_detail = ''; |
34 | 34 | var $depth_array = array(); |
35 | 35 | var $debug_flag = true; |
36 | - var $soapresponse = NULL; // parsed SOAP Body |
|
37 | - var $soapheader = NULL; // parsed SOAP Header |
|
38 | - var $responseHeaders = ''; // incoming SOAP headers (text) |
|
36 | + var $soapresponse = NULL; // parsed SOAP Body |
|
37 | + var $soapheader = NULL; // parsed SOAP Header |
|
38 | + var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | 39 | var $body_position = 0; |
40 | 40 | // for multiref parsing: |
41 | 41 | // array of id => pos |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param string $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
55 | 55 | * @access public |
56 | 56 | */ |
57 | - function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ |
|
57 | + function nusoap_parser($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = true) { |
|
58 | 58 | parent::nusoap_base(); |
59 | 59 | $this->xml = $xml; |
60 | 60 | $this->xml_encoding = $encoding; |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | $this->decode_utf8 = $decode_utf8; |
63 | 63 | |
64 | 64 | // Check whether content has been read. |
65 | - if(!empty($this->xml)){ |
|
65 | + if (!empty($this->xml)) { |
|
66 | 66 | // Check XML encoding |
67 | 67 | $pos_xml = strpos($xml, '<?xml'); |
68 | 68 | if ($pos_xml !== FALSE) { |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
71 | 71 | $xml_encoding = $res[1]; |
72 | 72 | if (strtoupper($xml_encoding) != $encoding) { |
73 | - $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
73 | + $err = "Charset from HTTP Content-Type '".$encoding."' does not match encoding from XML declaration '".$xml_encoding."'"; |
|
74 | 74 | $this->debug($err); |
75 | 75 | if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
76 | 76 | $this->setError($err); |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | // Set the object for the parser. |
97 | 97 | xml_set_object($this->parser, $this); |
98 | 98 | // Set the element handlers for the parser. |
99 | - xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
100 | - xml_set_character_data_handler($this->parser,'character_data'); |
|
99 | + xml_set_element_handler($this->parser, 'start_element', 'end_element'); |
|
100 | + xml_set_character_data_handler($this->parser, 'character_data'); |
|
101 | 101 | |
102 | 102 | xml_parse($this->parser, $this->xml); |
103 | 103 | |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | xml_get_current_line_number($this->parser), |
110 | 110 | xml_error_string(xml_get_error_code($this->parser))); |
111 | 111 | $this->debug($err); |
112 | - $this->debug("XML payload:\n" . $xml); |
|
112 | + $this->debug("XML payload:\n".$xml); |
|
113 | 113 | $this->setError($err); |
114 | 114 | } else { |
115 | 115 | $this->debug('in nusoap_parser ctor, message:'); |
@@ -118,18 +118,18 @@ discard block |
||
118 | 118 | // get final value |
119 | 119 | $this->soapresponse = $this->message[$this->root_struct]['result']; |
120 | 120 | // get header value |
121 | - if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
121 | + if ($this->root_header != '' && isset($this->message[$this->root_header]['result'])) { |
|
122 | 122 | $this->soapheader = $this->message[$this->root_header]['result']; |
123 | 123 | } |
124 | 124 | // resolve hrefs/ids |
125 | - if(sizeof($this->multirefs) > 0){ |
|
126 | - foreach($this->multirefs as $id => $hrefs){ |
|
125 | + if (sizeof($this->multirefs) > 0) { |
|
126 | + foreach ($this->multirefs as $id => $hrefs) { |
|
127 | 127 | $this->debug('resolving multirefs for id: '.$id); |
128 | 128 | $idVal = $this->buildVal($this->ids[$id]); |
129 | 129 | if (is_array($idVal) && isset($idVal['!id'])) { |
130 | 130 | unset($idVal['!id']); |
131 | 131 | } |
132 | - foreach($hrefs as $refPos => $ref){ |
|
132 | + foreach ($hrefs as $refPos => $ref) { |
|
133 | 133 | $this->debug('resolving href at pos '.$refPos); |
134 | 134 | $this->multirefs[$id][$refPos] = $idVal; |
135 | 135 | } |
@@ -157,13 +157,13 @@ discard block |
||
157 | 157 | // update class level pos |
158 | 158 | $pos = $this->position++; |
159 | 159 | // and set mine |
160 | - $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
160 | + $this->message[$pos] = array('pos' => $pos, 'children'=>'', 'cdata'=>''); |
|
161 | 161 | // depth = how many levels removed from root? |
162 | 162 | // set mine as current global depth and increment global depth value |
163 | 163 | $this->message[$pos]['depth'] = $this->depth++; |
164 | 164 | |
165 | 165 | // else add self as child to whoever the current parent is |
166 | - if($pos != 0){ |
|
166 | + if ($pos != 0) { |
|
167 | 167 | $this->message[$this->parent]['children'] .= '|'.$pos; |
168 | 168 | } |
169 | 169 | // set my parent |
@@ -173,11 +173,11 @@ discard block |
||
173 | 173 | // set self as current value for this depth |
174 | 174 | $this->depth_array[$this->depth] = $pos; |
175 | 175 | // get element prefix |
176 | - if(strpos($name,':')){ |
|
176 | + if (strpos($name, ':')) { |
|
177 | 177 | // get ns prefix |
178 | - $prefix = substr($name,0,strpos($name,':')); |
|
178 | + $prefix = substr($name, 0, strpos($name, ':')); |
|
179 | 179 | // get unqualified name |
180 | - $name = substr(strstr($name,':'),1); |
|
180 | + $name = substr(strstr($name, ':'), 1); |
|
181 | 181 | } |
182 | 182 | // set status |
183 | 183 | if ($name == 'Envelope' && $this->status == '') { |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | } elseif ($name == 'Header' && $this->status == 'envelope') { |
186 | 186 | $this->root_header = $pos; |
187 | 187 | $this->status = 'header'; |
188 | - } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
188 | + } elseif ($name == 'Body' && $this->status == 'envelope') { |
|
189 | 189 | $this->status = 'body'; |
190 | 190 | $this->body_position = $pos; |
191 | 191 | // set method |
192 | - } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
192 | + } elseif ($this->status == 'body' && $pos == ($this->body_position + 1)) { |
|
193 | 193 | $this->status = 'method'; |
194 | 194 | $this->root_struct_name = $name; |
195 | 195 | $this->root_struct = $pos; |
@@ -205,23 +205,23 @@ discard block |
||
205 | 205 | |
206 | 206 | // loop through atts, logging ns and type declarations |
207 | 207 | $attstr = ''; |
208 | - foreach($attrs as $key => $value){ |
|
208 | + foreach ($attrs as $key => $value) { |
|
209 | 209 | $key_prefix = $this->getPrefix($key); |
210 | 210 | $key_localpart = $this->getLocalPart($key); |
211 | 211 | // if ns declarations, add to class level array of valid namespaces |
212 | - if($key_prefix == 'xmlns'){ |
|
213 | - if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
212 | + if ($key_prefix == 'xmlns') { |
|
213 | + if (preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/', $value)) { |
|
214 | 214 | $this->XMLSchemaVersion = $value; |
215 | 215 | $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
216 | 216 | $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
217 | 217 | } |
218 | 218 | $this->namespaces[$key_localpart] = $value; |
219 | 219 | // set method namespace |
220 | - if($name == $this->root_struct_name){ |
|
220 | + if ($name == $this->root_struct_name) { |
|
221 | 221 | $this->methodNamespace = $value; |
222 | 222 | } |
223 | 223 | // if it's a type declaration, set type |
224 | - } elseif($key_localpart == 'type'){ |
|
224 | + } elseif ($key_localpart == 'type') { |
|
225 | 225 | if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
226 | 226 | // do nothing: already processed arrayType |
227 | 227 | } else { |
@@ -229,14 +229,14 @@ discard block |
||
229 | 229 | $value_localpart = $this->getLocalPart($value); |
230 | 230 | $this->message[$pos]['type'] = $value_localpart; |
231 | 231 | $this->message[$pos]['typePrefix'] = $value_prefix; |
232 | - if(isset($this->namespaces[$value_prefix])){ |
|
232 | + if (isset($this->namespaces[$value_prefix])) { |
|
233 | 233 | $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
234 | - } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
234 | + } else if (isset($attrs['xmlns:'.$value_prefix])) { |
|
235 | 235 | $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
236 | 236 | } |
237 | 237 | // should do something here with the namespace of specified type? |
238 | 238 | } |
239 | - } elseif($key_localpart == 'arrayType'){ |
|
239 | + } elseif ($key_localpart == 'arrayType') { |
|
240 | 240 | $this->message[$pos]['type'] = 'array'; |
241 | 241 | /* do arrayType ereg here |
242 | 242 | [1] arrayTypeValue ::= atype asize |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | [6] nextDimension ::= Digit+ ',' |
248 | 248 | */ |
249 | 249 | $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
250 | - if(preg_match($expr,$value,$regs)){ |
|
250 | + if (preg_match($expr, $value, $regs)) { |
|
251 | 251 | $this->message[$pos]['typePrefix'] = $regs[1]; |
252 | 252 | $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
253 | 253 | if (isset($this->namespaces[$regs[1]])) { |
@@ -260,22 +260,22 @@ discard block |
||
260 | 260 | $this->message[$pos]['arrayCols'] = $regs[4]; |
261 | 261 | } |
262 | 262 | // specifies nil value (or not) |
263 | - } elseif ($key_localpart == 'nil'){ |
|
263 | + } elseif ($key_localpart == 'nil') { |
|
264 | 264 | $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
265 | 265 | // some other attribute |
266 | 266 | } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
267 | - $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
267 | + $this->message[$pos]['xattrs']['!'.$key] = $value; |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | if ($key == 'xmlns') { |
271 | 271 | $this->default_namespace = $value; |
272 | 272 | } |
273 | 273 | // log id |
274 | - if($key == 'id'){ |
|
274 | + if ($key == 'id') { |
|
275 | 275 | $this->ids[$value] = $pos; |
276 | 276 | } |
277 | 277 | // root |
278 | - if($key_localpart == 'root' && $value == 1){ |
|
278 | + if ($key_localpart == 'root' && $value == 1) { |
|
279 | 279 | $this->status = 'method'; |
280 | 280 | $this->root_struct_name = $name; |
281 | 281 | $this->root_struct = $pos; |
@@ -285,18 +285,18 @@ discard block |
||
285 | 285 | $attstr .= " $key=\"$value\""; |
286 | 286 | } |
287 | 287 | // get namespace - must be done after namespace atts are processed |
288 | - if(isset($prefix)){ |
|
288 | + if (isset($prefix)) { |
|
289 | 289 | $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
290 | 290 | $this->default_namespace = $this->namespaces[$prefix]; |
291 | 291 | } else { |
292 | 292 | $this->message[$pos]['namespace'] = $this->default_namespace; |
293 | 293 | } |
294 | - if($this->status == 'header'){ |
|
294 | + if ($this->status == 'header') { |
|
295 | 295 | if ($this->root_header != $pos) { |
296 | - $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
296 | + $this->responseHeaders .= "<".(isset($prefix) ? $prefix.':' : '')."$name$attstr>"; |
|
297 | 297 | } |
298 | - } elseif($this->root_struct_name != ''){ |
|
299 | - $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
298 | + } elseif ($this->root_struct_name != '') { |
|
299 | + $this->document .= "<".(isset($prefix) ? $prefix.':' : '')."$name$attstr>"; |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | |
@@ -312,27 +312,27 @@ discard block |
||
312 | 312 | $pos = $this->depth_array[$this->depth--]; |
313 | 313 | |
314 | 314 | // get element prefix |
315 | - if(strpos($name,':')){ |
|
315 | + if (strpos($name, ':')) { |
|
316 | 316 | // get ns prefix |
317 | - $prefix = substr($name,0,strpos($name,':')); |
|
317 | + $prefix = substr($name, 0, strpos($name, ':')); |
|
318 | 318 | // get unqualified name |
319 | - $name = substr(strstr($name,':'),1); |
|
319 | + $name = substr(strstr($name, ':'), 1); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | // build to native type |
323 | - if(isset($this->body_position) && $pos > $this->body_position){ |
|
323 | + if (isset($this->body_position) && $pos > $this->body_position) { |
|
324 | 324 | // deal w/ multirefs |
325 | - if(isset($this->message[$pos]['attrs']['href'])){ |
|
325 | + if (isset($this->message[$pos]['attrs']['href'])) { |
|
326 | 326 | // get id |
327 | - $id = substr($this->message[$pos]['attrs']['href'],1); |
|
327 | + $id = substr($this->message[$pos]['attrs']['href'], 1); |
|
328 | 328 | // add placeholder to href array |
329 | 329 | $this->multirefs[$id][$pos] = 'placeholder'; |
330 | 330 | // add set a reference to it as the result value |
331 | - $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
331 | + $this->message[$pos]['result'] = & $this->multirefs[$id][$pos]; |
|
332 | 332 | // build complexType values |
333 | - } elseif($this->message[$pos]['children'] != ''){ |
|
333 | + } elseif ($this->message[$pos]['children'] != '') { |
|
334 | 334 | // if result has already been generated (struct/array) |
335 | - if(!isset($this->message[$pos]['result'])){ |
|
335 | + if (!isset($this->message[$pos]['result'])) { |
|
336 | 336 | $this->message[$pos]['result'] = $this->buildVal($pos); |
337 | 337 | } |
338 | 338 | // build complexType values of attributes and possibly simpleContent |
@@ -382,15 +382,15 @@ discard block |
||
382 | 382 | } |
383 | 383 | |
384 | 384 | // for doclit |
385 | - if($this->status == 'header'){ |
|
385 | + if ($this->status == 'header') { |
|
386 | 386 | if ($this->root_header != $pos) { |
387 | - $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
387 | + $this->responseHeaders .= "</".(isset($prefix) ? $prefix.':' : '')."$name>"; |
|
388 | 388 | } |
389 | - } elseif($pos >= $this->root_struct){ |
|
390 | - $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
389 | + } elseif ($pos >= $this->root_struct) { |
|
390 | + $this->document .= "</".(isset($prefix) ? $prefix.':' : '')."$name>"; |
|
391 | 391 | } |
392 | 392 | // switch status |
393 | - if ($pos == $this->root_struct){ |
|
393 | + if ($pos == $this->root_struct) { |
|
394 | 394 | $this->status = 'body'; |
395 | 395 | $this->root_struct_namespace = $this->message[$pos]['namespace']; |
396 | 396 | } elseif ($pos == $this->root_header) { |
@@ -416,17 +416,17 @@ discard block |
||
416 | 416 | function character_data($parser, $data) |
417 | 417 | { |
418 | 418 | $pos = $this->depth_array[$this->depth]; |
419 | - if ($this->xml_encoding == 'UTF-8'){ |
|
419 | + if ($this->xml_encoding == 'UTF-8') { |
|
420 | 420 | // TODO: add an option to disable this for folks who want |
421 | 421 | // raw UTF-8 that, e.g., might not map to iso-8859-1 |
422 | 422 | // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
423 | - if($this->decode_utf8){ |
|
423 | + if ($this->decode_utf8) { |
|
424 | 424 | $data = utf8_decode($data); |
425 | 425 | } |
426 | 426 | } |
427 | 427 | $this->message[$pos]['cdata'] .= $data; |
428 | 428 | // for doclit |
429 | - if($this->status == 'header'){ |
|
429 | + if ($this->status == 'header') { |
|
430 | 430 | $this->responseHeaders .= $data; |
431 | 431 | } else { |
432 | 432 | $this->document .= $data; |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @access public |
441 | 441 | * @deprecated use get_soapbody instead |
442 | 442 | */ |
443 | - function get_response(){ |
|
443 | + function get_response() { |
|
444 | 444 | return $this->soapresponse; |
445 | 445 | } |
446 | 446 | |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * @return mixed |
451 | 451 | * @access public |
452 | 452 | */ |
453 | - function get_soapbody(){ |
|
453 | + function get_soapbody() { |
|
454 | 454 | return $this->soapresponse; |
455 | 455 | } |
456 | 456 | |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @return mixed |
461 | 461 | * @access public |
462 | 462 | */ |
463 | - function get_soapheader(){ |
|
463 | + function get_soapheader() { |
|
464 | 464 | return $this->soapheader; |
465 | 465 | } |
466 | 466 | |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * @return string XML or empty if no Header |
471 | 471 | * @access public |
472 | 472 | */ |
473 | - function getHeaders(){ |
|
473 | + function getHeaders() { |
|
474 | 474 | return $this->responseHeaders; |
475 | 475 | } |
476 | 476 | |
@@ -527,40 +527,40 @@ discard block |
||
527 | 527 | * @return mixed PHP value |
528 | 528 | * @access private |
529 | 529 | */ |
530 | - function buildVal($pos){ |
|
531 | - if(!isset($this->message[$pos]['type'])){ |
|
530 | + function buildVal($pos) { |
|
531 | + if (!isset($this->message[$pos]['type'])) { |
|
532 | 532 | $this->message[$pos]['type'] = ''; |
533 | 533 | } |
534 | 534 | $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
535 | 535 | // if there are children... |
536 | - if($this->message[$pos]['children'] != ''){ |
|
536 | + if ($this->message[$pos]['children'] != '') { |
|
537 | 537 | $this->debug('in buildVal, there are children'); |
538 | - $children = explode('|',$this->message[$pos]['children']); |
|
538 | + $children = explode('|', $this->message[$pos]['children']); |
|
539 | 539 | array_shift($children); // knock off empty |
540 | 540 | // md array |
541 | - if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
542 | - $r=0; // rowcount |
|
543 | - $c=0; // colcount |
|
544 | - foreach($children as $child_pos){ |
|
541 | + if (isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != '') { |
|
542 | + $r = 0; // rowcount |
|
543 | + $c = 0; // colcount |
|
544 | + foreach ($children as $child_pos) { |
|
545 | 545 | $this->debug("in buildVal, got an MD array element: $r, $c"); |
546 | 546 | $params[$r][] = $this->message[$child_pos]['result']; |
547 | 547 | $c++; |
548 | - if($c == $this->message[$pos]['arrayCols']){ |
|
548 | + if ($c == $this->message[$pos]['arrayCols']) { |
|
549 | 549 | $c = 0; |
550 | 550 | $r++; |
551 | 551 | } |
552 | 552 | } |
553 | 553 | // array |
554 | - } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
554 | + } elseif ($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array') { |
|
555 | 555 | $this->debug('in buildVal, adding array '.$this->message[$pos]['name']); |
556 | - foreach($children as $child_pos){ |
|
556 | + foreach ($children as $child_pos) { |
|
557 | 557 | $params[] = &$this->message[$child_pos]['result']; |
558 | 558 | } |
559 | 559 | // apache Map type: java hashtable |
560 | - } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){ |
|
560 | + } elseif ($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
561 | 561 | $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']); |
562 | - foreach($children as $child_pos){ |
|
563 | - $kv = explode("|",$this->message[$child_pos]['children']); |
|
562 | + foreach ($children as $child_pos) { |
|
563 | + $kv = explode("|", $this->message[$child_pos]['children']); |
|
564 | 564 | $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
565 | 565 | } |
566 | 566 | // generic compound type |
@@ -574,8 +574,8 @@ discard block |
||
574 | 574 | $notstruct = 0; |
575 | 575 | } |
576 | 576 | // |
577 | - foreach($children as $child_pos){ |
|
578 | - if($notstruct){ |
|
577 | + foreach ($children as $child_pos) { |
|
578 | + if ($notstruct) { |
|
579 | 579 | $params[] = &$this->message[$child_pos]['result']; |
580 | 580 | } else { |
581 | 581 | if (isset($params[$this->message[$child_pos]['name']])) { |
@@ -52,7 +52,7 @@ |
||
52 | 52 | * @param string $encoding character encoding scheme of message |
53 | 53 | * @param string $method method for which XML is parsed (unused?) |
54 | 54 | * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
55 | - * @return void|bool |
|
55 | + * @return false|null |
|
56 | 56 | * @access public |
57 | 57 | */ |
58 | 58 | function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ |
@@ -11,235 +11,235 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class nusoap_parser extends nusoap_base |
13 | 13 | { |
14 | - var $xml = ''; |
|
15 | - var $xml_encoding = ''; |
|
16 | - var $method = ''; |
|
17 | - var $root_struct = ''; |
|
18 | - var $root_struct_name = ''; |
|
19 | - var $root_struct_namespace = ''; |
|
20 | - var $root_header = ''; |
|
14 | + var $xml = ''; |
|
15 | + var $xml_encoding = ''; |
|
16 | + var $method = ''; |
|
17 | + var $root_struct = ''; |
|
18 | + var $root_struct_name = ''; |
|
19 | + var $root_struct_namespace = ''; |
|
20 | + var $root_header = ''; |
|
21 | 21 | var $document = ''; // incoming SOAP body (text) |
22 | - // determines where in the message we are (envelope,header,body,method) |
|
23 | - var $status = ''; |
|
24 | - var $position = 0; |
|
25 | - var $depth = 0; |
|
26 | - var $default_namespace = ''; |
|
27 | - var $namespaces = array(); |
|
28 | - var $message = array(); |
|
22 | + // determines where in the message we are (envelope,header,body,method) |
|
23 | + var $status = ''; |
|
24 | + var $position = 0; |
|
25 | + var $depth = 0; |
|
26 | + var $default_namespace = ''; |
|
27 | + var $namespaces = array(); |
|
28 | + var $message = array(); |
|
29 | 29 | var $parent; |
30 | - var $fault = false; |
|
31 | - var $fault_code = ''; |
|
32 | - var $fault_str = ''; |
|
33 | - var $fault_detail = ''; |
|
34 | - var $depth_array = array(); |
|
35 | - var $debug_flag = true; |
|
36 | - var $soapresponse = NULL; // parsed SOAP Body |
|
37 | - var $soapheader = NULL; // parsed SOAP Header |
|
38 | - var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | - var $body_position = 0; |
|
40 | - // for multiref parsing: |
|
41 | - // array of id => pos |
|
42 | - var $ids = array(); |
|
43 | - // array of id => hrefs => pos |
|
44 | - var $multirefs = array(); |
|
45 | - // toggle for auto-decoding element content |
|
46 | - var $decode_utf8 = true; |
|
30 | + var $fault = false; |
|
31 | + var $fault_code = ''; |
|
32 | + var $fault_str = ''; |
|
33 | + var $fault_detail = ''; |
|
34 | + var $depth_array = array(); |
|
35 | + var $debug_flag = true; |
|
36 | + var $soapresponse = NULL; // parsed SOAP Body |
|
37 | + var $soapheader = NULL; // parsed SOAP Header |
|
38 | + var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | + var $body_position = 0; |
|
40 | + // for multiref parsing: |
|
41 | + // array of id => pos |
|
42 | + var $ids = array(); |
|
43 | + // array of id => hrefs => pos |
|
44 | + var $multirefs = array(); |
|
45 | + // toggle for auto-decoding element content |
|
46 | + var $decode_utf8 = true; |
|
47 | 47 | |
48 | - /** |
|
49 | - * constructor that actually does the parsing |
|
50 | - * |
|
51 | - * @param string $xml SOAP message |
|
52 | - * @param string $encoding character encoding scheme of message |
|
53 | - * @param string $method method for which XML is parsed (unused?) |
|
54 | - * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
|
55 | - * @return void|bool |
|
56 | - * @access public |
|
57 | - */ |
|
58 | - function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ |
|
59 | - parent::nusoap_base(); |
|
60 | - $this->xml = $xml; |
|
61 | - $this->xml_encoding = $encoding; |
|
62 | - $this->method = $method; |
|
63 | - $this->decode_utf8 = $decode_utf8; |
|
48 | + /** |
|
49 | + * constructor that actually does the parsing |
|
50 | + * |
|
51 | + * @param string $xml SOAP message |
|
52 | + * @param string $encoding character encoding scheme of message |
|
53 | + * @param string $method method for which XML is parsed (unused?) |
|
54 | + * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
|
55 | + * @return void|bool |
|
56 | + * @access public |
|
57 | + */ |
|
58 | + function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ |
|
59 | + parent::nusoap_base(); |
|
60 | + $this->xml = $xml; |
|
61 | + $this->xml_encoding = $encoding; |
|
62 | + $this->method = $method; |
|
63 | + $this->decode_utf8 = $decode_utf8; |
|
64 | 64 | |
65 | - // Check whether content has been read. |
|
66 | - if(!empty($this->xml)){ |
|
67 | - // Check XML encoding |
|
68 | - $pos_xml = strpos($xml, '<?xml'); |
|
69 | - if ($pos_xml !== FALSE) { |
|
70 | - $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1); |
|
71 | - if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
|
72 | - $xml_encoding = $res[1]; |
|
73 | - if (strtoupper($xml_encoding) != $encoding) { |
|
74 | - $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
75 | - $this->debug($err); |
|
76 | - if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
|
77 | - $this->setError($err); |
|
78 | - return false; |
|
79 | - } |
|
80 | - // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed |
|
81 | - } else { |
|
82 | - $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration'); |
|
83 | - } |
|
84 | - } else { |
|
85 | - $this->debug('No encoding specified in XML declaration'); |
|
86 | - } |
|
87 | - } else { |
|
88 | - $this->debug('No XML declaration'); |
|
89 | - } |
|
90 | - $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding); |
|
91 | - // Create an XML parser - why not xml_parser_create_ns? |
|
92 | - $this->parser = xml_parser_create($this->xml_encoding); |
|
93 | - // Set the options for parsing the XML data. |
|
94 | - //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
95 | - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
96 | - xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); |
|
97 | - // Set the object for the parser. |
|
98 | - xml_set_object($this->parser, $this); |
|
99 | - // Set the element handlers for the parser. |
|
100 | - xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
101 | - xml_set_character_data_handler($this->parser,'character_data'); |
|
65 | + // Check whether content has been read. |
|
66 | + if(!empty($this->xml)){ |
|
67 | + // Check XML encoding |
|
68 | + $pos_xml = strpos($xml, '<?xml'); |
|
69 | + if ($pos_xml !== FALSE) { |
|
70 | + $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1); |
|
71 | + if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
|
72 | + $xml_encoding = $res[1]; |
|
73 | + if (strtoupper($xml_encoding) != $encoding) { |
|
74 | + $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
75 | + $this->debug($err); |
|
76 | + if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
|
77 | + $this->setError($err); |
|
78 | + return false; |
|
79 | + } |
|
80 | + // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed |
|
81 | + } else { |
|
82 | + $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration'); |
|
83 | + } |
|
84 | + } else { |
|
85 | + $this->debug('No encoding specified in XML declaration'); |
|
86 | + } |
|
87 | + } else { |
|
88 | + $this->debug('No XML declaration'); |
|
89 | + } |
|
90 | + $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding); |
|
91 | + // Create an XML parser - why not xml_parser_create_ns? |
|
92 | + $this->parser = xml_parser_create($this->xml_encoding); |
|
93 | + // Set the options for parsing the XML data. |
|
94 | + //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
95 | + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
96 | + xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); |
|
97 | + // Set the object for the parser. |
|
98 | + xml_set_object($this->parser, $this); |
|
99 | + // Set the element handlers for the parser. |
|
100 | + xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
101 | + xml_set_character_data_handler($this->parser,'character_data'); |
|
102 | 102 | |
103 | - xml_parse($this->parser, $this->xml); |
|
103 | + xml_parse($this->parser, $this->xml); |
|
104 | 104 | |
105 | - // Parse the XML file. |
|
106 | - //if (!xml_parse($this->parser,$xml,true)){ |
|
107 | - if (false) { |
|
108 | - // Display an error message. |
|
109 | - $err = sprintf('XML error parsing SOAP payload on line %d: %s', |
|
110 | - xml_get_current_line_number($this->parser), |
|
111 | - xml_error_string(xml_get_error_code($this->parser))); |
|
112 | - $this->debug($err); |
|
113 | - $this->debug("XML payload:\n" . $xml); |
|
114 | - $this->setError($err); |
|
115 | - } else { |
|
116 | - $this->debug('in nusoap_parser ctor, message:'); |
|
117 | - $this->appendDebug($this->varDump($this->message)); |
|
118 | - $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name); |
|
119 | - // get final value |
|
120 | - $this->soapresponse = $this->message[$this->root_struct]['result']; |
|
121 | - // get header value |
|
122 | - if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
123 | - $this->soapheader = $this->message[$this->root_header]['result']; |
|
124 | - } |
|
125 | - // resolve hrefs/ids |
|
126 | - if(sizeof($this->multirefs) > 0){ |
|
127 | - foreach($this->multirefs as $id => $hrefs){ |
|
128 | - $this->debug('resolving multirefs for id: '.$id); |
|
129 | - $idVal = $this->buildVal($this->ids[$id]); |
|
130 | - if (is_array($idVal) && isset($idVal['!id'])) { |
|
131 | - unset($idVal['!id']); |
|
132 | - } |
|
133 | - foreach($hrefs as $refPos => $ref){ |
|
134 | - $this->debug('resolving href at pos '.$refPos); |
|
135 | - $this->multirefs[$id][$refPos] = $idVal; |
|
136 | - } |
|
137 | - } |
|
138 | - } |
|
139 | - } |
|
140 | - xml_parser_free($this->parser); |
|
141 | - } else { |
|
142 | - $this->debug('xml was empty, didn\'t parse!'); |
|
143 | - $this->setError('xml was empty, didn\'t parse!'); |
|
144 | - } |
|
145 | - } |
|
105 | + // Parse the XML file. |
|
106 | + //if (!xml_parse($this->parser,$xml,true)){ |
|
107 | + if (false) { |
|
108 | + // Display an error message. |
|
109 | + $err = sprintf('XML error parsing SOAP payload on line %d: %s', |
|
110 | + xml_get_current_line_number($this->parser), |
|
111 | + xml_error_string(xml_get_error_code($this->parser))); |
|
112 | + $this->debug($err); |
|
113 | + $this->debug("XML payload:\n" . $xml); |
|
114 | + $this->setError($err); |
|
115 | + } else { |
|
116 | + $this->debug('in nusoap_parser ctor, message:'); |
|
117 | + $this->appendDebug($this->varDump($this->message)); |
|
118 | + $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name); |
|
119 | + // get final value |
|
120 | + $this->soapresponse = $this->message[$this->root_struct]['result']; |
|
121 | + // get header value |
|
122 | + if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
123 | + $this->soapheader = $this->message[$this->root_header]['result']; |
|
124 | + } |
|
125 | + // resolve hrefs/ids |
|
126 | + if(sizeof($this->multirefs) > 0){ |
|
127 | + foreach($this->multirefs as $id => $hrefs){ |
|
128 | + $this->debug('resolving multirefs for id: '.$id); |
|
129 | + $idVal = $this->buildVal($this->ids[$id]); |
|
130 | + if (is_array($idVal) && isset($idVal['!id'])) { |
|
131 | + unset($idVal['!id']); |
|
132 | + } |
|
133 | + foreach($hrefs as $refPos => $ref){ |
|
134 | + $this->debug('resolving href at pos '.$refPos); |
|
135 | + $this->multirefs[$id][$refPos] = $idVal; |
|
136 | + } |
|
137 | + } |
|
138 | + } |
|
139 | + } |
|
140 | + xml_parser_free($this->parser); |
|
141 | + } else { |
|
142 | + $this->debug('xml was empty, didn\'t parse!'); |
|
143 | + $this->setError('xml was empty, didn\'t parse!'); |
|
144 | + } |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * start-element handler |
|
149 | - * |
|
150 | - * @param resource $parser XML parser object |
|
151 | - * @param string $name element name |
|
152 | - * @param array $attrs associative array of attributes |
|
153 | - * @access private |
|
154 | - */ |
|
155 | - function start_element($parser, $name, $attrs) { |
|
147 | + /** |
|
148 | + * start-element handler |
|
149 | + * |
|
150 | + * @param resource $parser XML parser object |
|
151 | + * @param string $name element name |
|
152 | + * @param array $attrs associative array of attributes |
|
153 | + * @access private |
|
154 | + */ |
|
155 | + function start_element($parser, $name, $attrs) { |
|
156 | 156 | |
157 | - // position in a total number of elements, starting from 0 |
|
158 | - // update class level pos |
|
159 | - $pos = $this->position++; |
|
160 | - // and set mine |
|
161 | - $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
162 | - // depth = how many levels removed from root? |
|
163 | - // set mine as current global depth and increment global depth value |
|
164 | - $this->message[$pos]['depth'] = $this->depth++; |
|
157 | + // position in a total number of elements, starting from 0 |
|
158 | + // update class level pos |
|
159 | + $pos = $this->position++; |
|
160 | + // and set mine |
|
161 | + $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
162 | + // depth = how many levels removed from root? |
|
163 | + // set mine as current global depth and increment global depth value |
|
164 | + $this->message[$pos]['depth'] = $this->depth++; |
|
165 | 165 | |
166 | - // else add self as child to whoever the current parent is |
|
167 | - if($pos != 0){ |
|
168 | - $this->message[$this->parent]['children'] .= '|'.$pos; |
|
169 | - } |
|
170 | - // set my parent |
|
171 | - $this->message[$pos]['parent'] = $this->parent; |
|
172 | - // set self as current parent |
|
173 | - $this->parent = $pos; |
|
174 | - // set self as current value for this depth |
|
175 | - $this->depth_array[$this->depth] = $pos; |
|
176 | - // get element prefix |
|
177 | - if(strpos($name,':')){ |
|
178 | - // get ns prefix |
|
179 | - $prefix = substr($name,0,strpos($name,':')); |
|
180 | - // get unqualified name |
|
181 | - $name = substr(strstr($name,':'),1); |
|
182 | - } |
|
183 | - // set status |
|
184 | - if ($name == 'Envelope' && $this->status == '') { |
|
185 | - $this->status = 'envelope'; |
|
186 | - } elseif ($name == 'Header' && $this->status == 'envelope') { |
|
187 | - $this->root_header = $pos; |
|
188 | - $this->status = 'header'; |
|
189 | - } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
190 | - $this->status = 'body'; |
|
191 | - $this->body_position = $pos; |
|
192 | - // set method |
|
193 | - } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
194 | - $this->status = 'method'; |
|
195 | - $this->root_struct_name = $name; |
|
196 | - $this->root_struct = $pos; |
|
197 | - $this->message[$pos]['type'] = 'struct'; |
|
198 | - $this->debug("found root struct $this->root_struct_name, pos $this->root_struct"); |
|
199 | - } |
|
200 | - // set my status |
|
201 | - $this->message[$pos]['status'] = $this->status; |
|
202 | - // set name |
|
203 | - $this->message[$pos]['name'] = htmlspecialchars($name); |
|
204 | - // set attrs |
|
205 | - $this->message[$pos]['attrs'] = $attrs; |
|
166 | + // else add self as child to whoever the current parent is |
|
167 | + if($pos != 0){ |
|
168 | + $this->message[$this->parent]['children'] .= '|'.$pos; |
|
169 | + } |
|
170 | + // set my parent |
|
171 | + $this->message[$pos]['parent'] = $this->parent; |
|
172 | + // set self as current parent |
|
173 | + $this->parent = $pos; |
|
174 | + // set self as current value for this depth |
|
175 | + $this->depth_array[$this->depth] = $pos; |
|
176 | + // get element prefix |
|
177 | + if(strpos($name,':')){ |
|
178 | + // get ns prefix |
|
179 | + $prefix = substr($name,0,strpos($name,':')); |
|
180 | + // get unqualified name |
|
181 | + $name = substr(strstr($name,':'),1); |
|
182 | + } |
|
183 | + // set status |
|
184 | + if ($name == 'Envelope' && $this->status == '') { |
|
185 | + $this->status = 'envelope'; |
|
186 | + } elseif ($name == 'Header' && $this->status == 'envelope') { |
|
187 | + $this->root_header = $pos; |
|
188 | + $this->status = 'header'; |
|
189 | + } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
190 | + $this->status = 'body'; |
|
191 | + $this->body_position = $pos; |
|
192 | + // set method |
|
193 | + } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
194 | + $this->status = 'method'; |
|
195 | + $this->root_struct_name = $name; |
|
196 | + $this->root_struct = $pos; |
|
197 | + $this->message[$pos]['type'] = 'struct'; |
|
198 | + $this->debug("found root struct $this->root_struct_name, pos $this->root_struct"); |
|
199 | + } |
|
200 | + // set my status |
|
201 | + $this->message[$pos]['status'] = $this->status; |
|
202 | + // set name |
|
203 | + $this->message[$pos]['name'] = htmlspecialchars($name); |
|
204 | + // set attrs |
|
205 | + $this->message[$pos]['attrs'] = $attrs; |
|
206 | 206 | |
207 | - // loop through atts, logging ns and type declarations |
|
207 | + // loop through atts, logging ns and type declarations |
|
208 | 208 | $attstr = ''; |
209 | - foreach($attrs as $key => $value){ |
|
210 | - $key_prefix = $this->getPrefix($key); |
|
211 | - $key_localpart = $this->getLocalPart($key); |
|
212 | - // if ns declarations, add to class level array of valid namespaces |
|
209 | + foreach($attrs as $key => $value){ |
|
210 | + $key_prefix = $this->getPrefix($key); |
|
211 | + $key_localpart = $this->getLocalPart($key); |
|
212 | + // if ns declarations, add to class level array of valid namespaces |
|
213 | 213 | if($key_prefix == 'xmlns'){ |
214 | - if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
215 | - $this->XMLSchemaVersion = $value; |
|
216 | - $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
|
217 | - $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
|
218 | - } |
|
214 | + if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
215 | + $this->XMLSchemaVersion = $value; |
|
216 | + $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
|
217 | + $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
|
218 | + } |
|
219 | 219 | $this->namespaces[$key_localpart] = $value; |
220 | - // set method namespace |
|
221 | - if($name == $this->root_struct_name){ |
|
222 | - $this->methodNamespace = $value; |
|
223 | - } |
|
224 | - // if it's a type declaration, set type |
|
220 | + // set method namespace |
|
221 | + if($name == $this->root_struct_name){ |
|
222 | + $this->methodNamespace = $value; |
|
223 | + } |
|
224 | + // if it's a type declaration, set type |
|
225 | 225 | } elseif($key_localpart == 'type'){ |
226 | - if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
|
227 | - // do nothing: already processed arrayType |
|
228 | - } else { |
|
229 | - $value_prefix = $this->getPrefix($value); |
|
230 | - $value_localpart = $this->getLocalPart($value); |
|
231 | - $this->message[$pos]['type'] = $value_localpart; |
|
232 | - $this->message[$pos]['typePrefix'] = $value_prefix; |
|
233 | - if(isset($this->namespaces[$value_prefix])){ |
|
234 | - $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
|
235 | - } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
236 | - $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
|
237 | - } |
|
238 | - // should do something here with the namespace of specified type? |
|
239 | - } |
|
240 | - } elseif($key_localpart == 'arrayType'){ |
|
241 | - $this->message[$pos]['type'] = 'array'; |
|
242 | - /* do arrayType ereg here |
|
226 | + if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
|
227 | + // do nothing: already processed arrayType |
|
228 | + } else { |
|
229 | + $value_prefix = $this->getPrefix($value); |
|
230 | + $value_localpart = $this->getLocalPart($value); |
|
231 | + $this->message[$pos]['type'] = $value_localpart; |
|
232 | + $this->message[$pos]['typePrefix'] = $value_prefix; |
|
233 | + if(isset($this->namespaces[$value_prefix])){ |
|
234 | + $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
|
235 | + } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
236 | + $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
|
237 | + } |
|
238 | + // should do something here with the namespace of specified type? |
|
239 | + } |
|
240 | + } elseif($key_localpart == 'arrayType'){ |
|
241 | + $this->message[$pos]['type'] = 'array'; |
|
242 | + /* do arrayType ereg here |
|
243 | 243 | [1] arrayTypeValue ::= atype asize |
244 | 244 | [2] atype ::= QName rank* |
245 | 245 | [3] rank ::= '[' (',')* ']' |
@@ -247,129 +247,129 @@ discard block |
||
247 | 247 | [5] length ::= nextDimension* Digit+ |
248 | 248 | [6] nextDimension ::= Digit+ ',' |
249 | 249 | */ |
250 | - $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
|
251 | - if(preg_match($expr,$value,$regs)){ |
|
252 | - $this->message[$pos]['typePrefix'] = $regs[1]; |
|
253 | - $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
|
254 | - if (isset($this->namespaces[$regs[1]])) { |
|
255 | - $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]]; |
|
256 | - } else if (isset($attrs['xmlns:'.$regs[1]])) { |
|
257 | - $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]]; |
|
258 | - } |
|
259 | - $this->message[$pos]['arrayType'] = $regs[2]; |
|
260 | - $this->message[$pos]['arraySize'] = $regs[3]; |
|
261 | - $this->message[$pos]['arrayCols'] = $regs[4]; |
|
262 | - } |
|
263 | - // specifies nil value (or not) |
|
264 | - } elseif ($key_localpart == 'nil'){ |
|
265 | - $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
|
266 | - // some other attribute |
|
267 | - } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
|
268 | - $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
269 | - } |
|
250 | + $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
|
251 | + if(preg_match($expr,$value,$regs)){ |
|
252 | + $this->message[$pos]['typePrefix'] = $regs[1]; |
|
253 | + $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
|
254 | + if (isset($this->namespaces[$regs[1]])) { |
|
255 | + $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]]; |
|
256 | + } else if (isset($attrs['xmlns:'.$regs[1]])) { |
|
257 | + $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]]; |
|
258 | + } |
|
259 | + $this->message[$pos]['arrayType'] = $regs[2]; |
|
260 | + $this->message[$pos]['arraySize'] = $regs[3]; |
|
261 | + $this->message[$pos]['arrayCols'] = $regs[4]; |
|
262 | + } |
|
263 | + // specifies nil value (or not) |
|
264 | + } elseif ($key_localpart == 'nil'){ |
|
265 | + $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
|
266 | + // some other attribute |
|
267 | + } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
|
268 | + $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
269 | + } |
|
270 | 270 | |
271 | - if ($key == 'xmlns') { |
|
272 | - $this->default_namespace = $value; |
|
273 | - } |
|
274 | - // log id |
|
275 | - if($key == 'id'){ |
|
276 | - $this->ids[$value] = $pos; |
|
277 | - } |
|
278 | - // root |
|
279 | - if($key_localpart == 'root' && $value == 1){ |
|
280 | - $this->status = 'method'; |
|
281 | - $this->root_struct_name = $name; |
|
282 | - $this->root_struct = $pos; |
|
283 | - $this->debug("found root struct $this->root_struct_name, pos $pos"); |
|
284 | - } |
|
271 | + if ($key == 'xmlns') { |
|
272 | + $this->default_namespace = $value; |
|
273 | + } |
|
274 | + // log id |
|
275 | + if($key == 'id'){ |
|
276 | + $this->ids[$value] = $pos; |
|
277 | + } |
|
278 | + // root |
|
279 | + if($key_localpart == 'root' && $value == 1){ |
|
280 | + $this->status = 'method'; |
|
281 | + $this->root_struct_name = $name; |
|
282 | + $this->root_struct = $pos; |
|
283 | + $this->debug("found root struct $this->root_struct_name, pos $pos"); |
|
284 | + } |
|
285 | 285 | // for doclit |
286 | 286 | $attstr .= " $key=\"$value\""; |
287 | - } |
|
287 | + } |
|
288 | 288 | // get namespace - must be done after namespace atts are processed |
289 | - if(isset($prefix)){ |
|
290 | - $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
|
291 | - $this->default_namespace = $this->namespaces[$prefix]; |
|
292 | - } else { |
|
293 | - $this->message[$pos]['namespace'] = $this->default_namespace; |
|
294 | - } |
|
289 | + if(isset($prefix)){ |
|
290 | + $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
|
291 | + $this->default_namespace = $this->namespaces[$prefix]; |
|
292 | + } else { |
|
293 | + $this->message[$pos]['namespace'] = $this->default_namespace; |
|
294 | + } |
|
295 | 295 | if($this->status == 'header'){ |
296 | - if ($this->root_header != $pos) { |
|
297 | - $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
298 | - } |
|
296 | + if ($this->root_header != $pos) { |
|
297 | + $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
298 | + } |
|
299 | 299 | } elseif($this->root_struct_name != ''){ |
300 | - $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
300 | + $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
301 | 301 | } |
302 | - } |
|
302 | + } |
|
303 | 303 | |
304 | - /** |
|
305 | - * end-element handler |
|
306 | - * |
|
307 | - * @param resource $parser XML parser object |
|
308 | - * @param string $name element name |
|
309 | - * @access private |
|
310 | - */ |
|
311 | - function end_element($parser, $name) { |
|
312 | - // position of current element is equal to the last value left in depth_array for my depth |
|
313 | - $pos = $this->depth_array[$this->depth--]; |
|
304 | + /** |
|
305 | + * end-element handler |
|
306 | + * |
|
307 | + * @param resource $parser XML parser object |
|
308 | + * @param string $name element name |
|
309 | + * @access private |
|
310 | + */ |
|
311 | + function end_element($parser, $name) { |
|
312 | + // position of current element is equal to the last value left in depth_array for my depth |
|
313 | + $pos = $this->depth_array[$this->depth--]; |
|
314 | 314 | |
315 | 315 | // get element prefix |
316 | - if(strpos($name,':')){ |
|
317 | - // get ns prefix |
|
318 | - $prefix = substr($name,0,strpos($name,':')); |
|
319 | - // get unqualified name |
|
320 | - $name = substr(strstr($name,':'),1); |
|
321 | - } |
|
316 | + if(strpos($name,':')){ |
|
317 | + // get ns prefix |
|
318 | + $prefix = substr($name,0,strpos($name,':')); |
|
319 | + // get unqualified name |
|
320 | + $name = substr(strstr($name,':'),1); |
|
321 | + } |
|
322 | 322 | |
323 | - // build to native type |
|
324 | - if(isset($this->body_position) && $pos > $this->body_position){ |
|
325 | - // deal w/ multirefs |
|
326 | - if(isset($this->message[$pos]['attrs']['href'])){ |
|
327 | - // get id |
|
328 | - $id = substr($this->message[$pos]['attrs']['href'],1); |
|
329 | - // add placeholder to href array |
|
330 | - $this->multirefs[$id][$pos] = 'placeholder'; |
|
331 | - // add set a reference to it as the result value |
|
332 | - $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
323 | + // build to native type |
|
324 | + if(isset($this->body_position) && $pos > $this->body_position){ |
|
325 | + // deal w/ multirefs |
|
326 | + if(isset($this->message[$pos]['attrs']['href'])){ |
|
327 | + // get id |
|
328 | + $id = substr($this->message[$pos]['attrs']['href'],1); |
|
329 | + // add placeholder to href array |
|
330 | + $this->multirefs[$id][$pos] = 'placeholder'; |
|
331 | + // add set a reference to it as the result value |
|
332 | + $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
333 | 333 | // build complexType values |
334 | - } elseif($this->message[$pos]['children'] != ''){ |
|
335 | - // if result has already been generated (struct/array) |
|
336 | - if(!isset($this->message[$pos]['result'])){ |
|
337 | - $this->message[$pos]['result'] = $this->buildVal($pos); |
|
338 | - } |
|
339 | - // build complexType values of attributes and possibly simpleContent |
|
340 | - } elseif (isset($this->message[$pos]['xattrs'])) { |
|
341 | - if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
342 | - $this->message[$pos]['xattrs']['!'] = null; |
|
343 | - } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
344 | - if (isset($this->message[$pos]['type'])) { |
|
345 | - $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
346 | - } else { |
|
347 | - $parent = $this->message[$pos]['parent']; |
|
348 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
349 | - $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
350 | - } else { |
|
351 | - $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata']; |
|
352 | - } |
|
353 | - } |
|
354 | - } |
|
355 | - $this->message[$pos]['result'] = $this->message[$pos]['xattrs']; |
|
356 | - // set value of simpleType (or nil complexType) |
|
357 | - } else { |
|
358 | - //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']); |
|
359 | - if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
360 | - $this->message[$pos]['xattrs']['!'] = null; |
|
361 | - } elseif (isset($this->message[$pos]['type'])) { |
|
362 | - $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
363 | - } else { |
|
364 | - $parent = $this->message[$pos]['parent']; |
|
365 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
366 | - $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
367 | - } else { |
|
368 | - $this->message[$pos]['result'] = $this->message[$pos]['cdata']; |
|
369 | - } |
|
370 | - } |
|
334 | + } elseif($this->message[$pos]['children'] != ''){ |
|
335 | + // if result has already been generated (struct/array) |
|
336 | + if(!isset($this->message[$pos]['result'])){ |
|
337 | + $this->message[$pos]['result'] = $this->buildVal($pos); |
|
338 | + } |
|
339 | + // build complexType values of attributes and possibly simpleContent |
|
340 | + } elseif (isset($this->message[$pos]['xattrs'])) { |
|
341 | + if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
342 | + $this->message[$pos]['xattrs']['!'] = null; |
|
343 | + } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
344 | + if (isset($this->message[$pos]['type'])) { |
|
345 | + $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
346 | + } else { |
|
347 | + $parent = $this->message[$pos]['parent']; |
|
348 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
349 | + $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
350 | + } else { |
|
351 | + $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata']; |
|
352 | + } |
|
353 | + } |
|
354 | + } |
|
355 | + $this->message[$pos]['result'] = $this->message[$pos]['xattrs']; |
|
356 | + // set value of simpleType (or nil complexType) |
|
357 | + } else { |
|
358 | + //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']); |
|
359 | + if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
360 | + $this->message[$pos]['xattrs']['!'] = null; |
|
361 | + } elseif (isset($this->message[$pos]['type'])) { |
|
362 | + $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
363 | + } else { |
|
364 | + $parent = $this->message[$pos]['parent']; |
|
365 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
366 | + $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
367 | + } else { |
|
368 | + $this->message[$pos]['result'] = $this->message[$pos]['cdata']; |
|
369 | + } |
|
370 | + } |
|
371 | 371 | |
372 | - /* add value to parent's result, if parent is struct/array |
|
372 | + /* add value to parent's result, if parent is struct/array |
|
373 | 373 | $parent = $this->message[$pos]['parent']; |
374 | 374 | if($this->message[$parent]['type'] != 'map'){ |
375 | 375 | if(strtolower($this->message[$parent]['type']) == 'array'){ |
@@ -379,261 +379,261 @@ discard block |
||
379 | 379 | } |
380 | 380 | } |
381 | 381 | */ |
382 | - } |
|
383 | - } |
|
382 | + } |
|
383 | + } |
|
384 | 384 | |
385 | 385 | // for doclit |
386 | 386 | if($this->status == 'header'){ |
387 | - if ($this->root_header != $pos) { |
|
388 | - $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
389 | - } |
|
387 | + if ($this->root_header != $pos) { |
|
388 | + $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
389 | + } |
|
390 | 390 | } elseif($pos >= $this->root_struct){ |
391 | - $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
391 | + $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
392 | 392 | } |
393 | - // switch status |
|
394 | - if ($pos == $this->root_struct){ |
|
395 | - $this->status = 'body'; |
|
396 | - $this->root_struct_namespace = $this->message[$pos]['namespace']; |
|
397 | - } elseif ($pos == $this->root_header) { |
|
398 | - $this->status = 'envelope'; |
|
399 | - } elseif ($name == 'Body' && $this->status == 'body') { |
|
400 | - $this->status = 'envelope'; |
|
401 | - } elseif ($name == 'Header' && $this->status == 'header') { // will never happen |
|
402 | - $this->status = 'envelope'; |
|
403 | - } elseif ($name == 'Envelope' && $this->status == 'envelope') { |
|
404 | - $this->status = ''; |
|
405 | - } |
|
406 | - // set parent back to my parent |
|
407 | - $this->parent = $this->message[$pos]['parent']; |
|
408 | - } |
|
393 | + // switch status |
|
394 | + if ($pos == $this->root_struct){ |
|
395 | + $this->status = 'body'; |
|
396 | + $this->root_struct_namespace = $this->message[$pos]['namespace']; |
|
397 | + } elseif ($pos == $this->root_header) { |
|
398 | + $this->status = 'envelope'; |
|
399 | + } elseif ($name == 'Body' && $this->status == 'body') { |
|
400 | + $this->status = 'envelope'; |
|
401 | + } elseif ($name == 'Header' && $this->status == 'header') { // will never happen |
|
402 | + $this->status = 'envelope'; |
|
403 | + } elseif ($name == 'Envelope' && $this->status == 'envelope') { |
|
404 | + $this->status = ''; |
|
405 | + } |
|
406 | + // set parent back to my parent |
|
407 | + $this->parent = $this->message[$pos]['parent']; |
|
408 | + } |
|
409 | 409 | |
410 | - /** |
|
411 | - * element content handler |
|
412 | - * |
|
413 | - * @param resource $parser XML parser object |
|
414 | - * @param string $data element content |
|
415 | - * @access private |
|
416 | - */ |
|
417 | - function character_data($parser, $data) |
|
410 | + /** |
|
411 | + * element content handler |
|
412 | + * |
|
413 | + * @param resource $parser XML parser object |
|
414 | + * @param string $data element content |
|
415 | + * @access private |
|
416 | + */ |
|
417 | + function character_data($parser, $data) |
|
418 | 418 | { |
419 | - $pos = $this->depth_array[$this->depth]; |
|
420 | - if ($this->xml_encoding == 'UTF-8'){ |
|
421 | - // TODO: add an option to disable this for folks who want |
|
422 | - // raw UTF-8 that, e.g., might not map to iso-8859-1 |
|
423 | - // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
|
424 | - if($this->decode_utf8){ |
|
425 | - $data = utf8_decode($data); |
|
426 | - } |
|
427 | - } |
|
419 | + $pos = $this->depth_array[$this->depth]; |
|
420 | + if ($this->xml_encoding == 'UTF-8'){ |
|
421 | + // TODO: add an option to disable this for folks who want |
|
422 | + // raw UTF-8 that, e.g., might not map to iso-8859-1 |
|
423 | + // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
|
424 | + if($this->decode_utf8){ |
|
425 | + $data = utf8_decode($data); |
|
426 | + } |
|
427 | + } |
|
428 | 428 | $this->message[$pos]['cdata'] .= $data; |
429 | 429 | // for doclit |
430 | 430 | if($this->status == 'header'){ |
431 | - $this->responseHeaders .= $data; |
|
431 | + $this->responseHeaders .= $data; |
|
432 | 432 | } else { |
433 | - $this->document .= $data; |
|
433 | + $this->document .= $data; |
|
434 | 434 | } |
435 | - } |
|
435 | + } |
|
436 | 436 | |
437 | - /** |
|
438 | - * get the parsed message (SOAP Body) |
|
439 | - * |
|
440 | - * @return mixed |
|
441 | - * @access public |
|
442 | - * @deprecated use get_soapbody instead |
|
443 | - */ |
|
444 | - function get_response(){ |
|
445 | - return $this->soapresponse; |
|
446 | - } |
|
437 | + /** |
|
438 | + * get the parsed message (SOAP Body) |
|
439 | + * |
|
440 | + * @return mixed |
|
441 | + * @access public |
|
442 | + * @deprecated use get_soapbody instead |
|
443 | + */ |
|
444 | + function get_response(){ |
|
445 | + return $this->soapresponse; |
|
446 | + } |
|
447 | 447 | |
448 | - /** |
|
449 | - * get the parsed SOAP Body (NULL if there was none) |
|
450 | - * |
|
451 | - * @return mixed |
|
452 | - * @access public |
|
453 | - */ |
|
454 | - function get_soapbody(){ |
|
455 | - return $this->soapresponse; |
|
456 | - } |
|
448 | + /** |
|
449 | + * get the parsed SOAP Body (NULL if there was none) |
|
450 | + * |
|
451 | + * @return mixed |
|
452 | + * @access public |
|
453 | + */ |
|
454 | + function get_soapbody(){ |
|
455 | + return $this->soapresponse; |
|
456 | + } |
|
457 | 457 | |
458 | - /** |
|
459 | - * get the parsed SOAP Header (NULL if there was none) |
|
460 | - * |
|
461 | - * @return mixed |
|
462 | - * @access public |
|
463 | - */ |
|
464 | - function get_soapheader(){ |
|
465 | - return $this->soapheader; |
|
466 | - } |
|
458 | + /** |
|
459 | + * get the parsed SOAP Header (NULL if there was none) |
|
460 | + * |
|
461 | + * @return mixed |
|
462 | + * @access public |
|
463 | + */ |
|
464 | + function get_soapheader(){ |
|
465 | + return $this->soapheader; |
|
466 | + } |
|
467 | 467 | |
468 | - /** |
|
469 | - * get the unparsed SOAP Header |
|
470 | - * |
|
471 | - * @return string XML or empty if no Header |
|
472 | - * @access public |
|
473 | - */ |
|
474 | - function getHeaders(){ |
|
475 | - return $this->responseHeaders; |
|
476 | - } |
|
468 | + /** |
|
469 | + * get the unparsed SOAP Header |
|
470 | + * |
|
471 | + * @return string XML or empty if no Header |
|
472 | + * @access public |
|
473 | + */ |
|
474 | + function getHeaders(){ |
|
475 | + return $this->responseHeaders; |
|
476 | + } |
|
477 | 477 | |
478 | - /** |
|
479 | - * decodes simple types into PHP variables |
|
480 | - * |
|
481 | - * @param string $value value to decode |
|
482 | - * @param string $type XML type to decode |
|
483 | - * @param string $typens XML type namespace to decode |
|
484 | - * @return mixed PHP value |
|
485 | - * @access private |
|
486 | - */ |
|
487 | - function decodeSimple($value, $type, $typens) { |
|
488 | - // TODO: use the namespace! |
|
489 | - if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { |
|
490 | - return (string) $value; |
|
491 | - } |
|
492 | - if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') { |
|
493 | - return (int) $value; |
|
494 | - } |
|
495 | - if ($type == 'float' || $type == 'double' || $type == 'decimal') { |
|
496 | - return (double) $value; |
|
497 | - } |
|
498 | - if ($type == 'boolean') { |
|
499 | - if (strtolower($value) == 'false' || strtolower($value) == 'f') { |
|
500 | - return false; |
|
501 | - } |
|
502 | - return (boolean) $value; |
|
503 | - } |
|
504 | - if ($type == 'base64' || $type == 'base64Binary') { |
|
505 | - $this->debug('Decode base64 value'); |
|
506 | - return base64_decode($value); |
|
507 | - } |
|
508 | - // obscure numeric types |
|
509 | - if ($type == 'nonPositiveInteger' || $type == 'negativeInteger' |
|
510 | - || $type == 'nonNegativeInteger' || $type == 'positiveInteger' |
|
511 | - || $type == 'unsignedInt' |
|
512 | - || $type == 'unsignedShort' || $type == 'unsignedByte') { |
|
513 | - return (int) $value; |
|
514 | - } |
|
515 | - // bogus: parser treats array with no elements as a simple type |
|
516 | - if ($type == 'array') { |
|
517 | - return array(); |
|
518 | - } |
|
519 | - // everything else |
|
520 | - return (string) $value; |
|
521 | - } |
|
478 | + /** |
|
479 | + * decodes simple types into PHP variables |
|
480 | + * |
|
481 | + * @param string $value value to decode |
|
482 | + * @param string $type XML type to decode |
|
483 | + * @param string $typens XML type namespace to decode |
|
484 | + * @return mixed PHP value |
|
485 | + * @access private |
|
486 | + */ |
|
487 | + function decodeSimple($value, $type, $typens) { |
|
488 | + // TODO: use the namespace! |
|
489 | + if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { |
|
490 | + return (string) $value; |
|
491 | + } |
|
492 | + if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') { |
|
493 | + return (int) $value; |
|
494 | + } |
|
495 | + if ($type == 'float' || $type == 'double' || $type == 'decimal') { |
|
496 | + return (double) $value; |
|
497 | + } |
|
498 | + if ($type == 'boolean') { |
|
499 | + if (strtolower($value) == 'false' || strtolower($value) == 'f') { |
|
500 | + return false; |
|
501 | + } |
|
502 | + return (boolean) $value; |
|
503 | + } |
|
504 | + if ($type == 'base64' || $type == 'base64Binary') { |
|
505 | + $this->debug('Decode base64 value'); |
|
506 | + return base64_decode($value); |
|
507 | + } |
|
508 | + // obscure numeric types |
|
509 | + if ($type == 'nonPositiveInteger' || $type == 'negativeInteger' |
|
510 | + || $type == 'nonNegativeInteger' || $type == 'positiveInteger' |
|
511 | + || $type == 'unsignedInt' |
|
512 | + || $type == 'unsignedShort' || $type == 'unsignedByte') { |
|
513 | + return (int) $value; |
|
514 | + } |
|
515 | + // bogus: parser treats array with no elements as a simple type |
|
516 | + if ($type == 'array') { |
|
517 | + return array(); |
|
518 | + } |
|
519 | + // everything else |
|
520 | + return (string) $value; |
|
521 | + } |
|
522 | 522 | |
523 | - /** |
|
524 | - * builds response structures for compound values (arrays/structs) |
|
525 | - * and scalars |
|
526 | - * |
|
527 | - * @param integer $pos position in node tree |
|
528 | - * @return mixed PHP value |
|
529 | - * @access private |
|
530 | - */ |
|
531 | - function buildVal($pos){ |
|
532 | - if(!isset($this->message[$pos]['type'])){ |
|
533 | - $this->message[$pos]['type'] = ''; |
|
534 | - } |
|
535 | - $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
|
536 | - // if there are children... |
|
537 | - if($this->message[$pos]['children'] != ''){ |
|
538 | - $this->debug('in buildVal, there are children'); |
|
539 | - $children = explode('|',$this->message[$pos]['children']); |
|
540 | - array_shift($children); // knock off empty |
|
541 | - // md array |
|
542 | - if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
543 | - $r=0; // rowcount |
|
544 | - $c=0; // colcount |
|
545 | - foreach($children as $child_pos){ |
|
546 | - $this->debug("in buildVal, got an MD array element: $r, $c"); |
|
547 | - $params[$r][] = $this->message[$child_pos]['result']; |
|
548 | - $c++; |
|
549 | - if($c == $this->message[$pos]['arrayCols']){ |
|
550 | - $c = 0; |
|
551 | - $r++; |
|
552 | - } |
|
523 | + /** |
|
524 | + * builds response structures for compound values (arrays/structs) |
|
525 | + * and scalars |
|
526 | + * |
|
527 | + * @param integer $pos position in node tree |
|
528 | + * @return mixed PHP value |
|
529 | + * @access private |
|
530 | + */ |
|
531 | + function buildVal($pos){ |
|
532 | + if(!isset($this->message[$pos]['type'])){ |
|
533 | + $this->message[$pos]['type'] = ''; |
|
534 | + } |
|
535 | + $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
|
536 | + // if there are children... |
|
537 | + if($this->message[$pos]['children'] != ''){ |
|
538 | + $this->debug('in buildVal, there are children'); |
|
539 | + $children = explode('|',$this->message[$pos]['children']); |
|
540 | + array_shift($children); // knock off empty |
|
541 | + // md array |
|
542 | + if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
543 | + $r=0; // rowcount |
|
544 | + $c=0; // colcount |
|
545 | + foreach($children as $child_pos){ |
|
546 | + $this->debug("in buildVal, got an MD array element: $r, $c"); |
|
547 | + $params[$r][] = $this->message[$child_pos]['result']; |
|
548 | + $c++; |
|
549 | + if($c == $this->message[$pos]['arrayCols']){ |
|
550 | + $c = 0; |
|
551 | + $r++; |
|
552 | + } |
|
553 | 553 | } |
554 | 554 | // array |
555 | - } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
555 | + } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
556 | 556 | $this->debug('in buildVal, adding array '.$this->message[$pos]['name']); |
557 | 557 | foreach($children as $child_pos){ |
558 | - $params[] = &$this->message[$child_pos]['result']; |
|
558 | + $params[] = &$this->message[$child_pos]['result']; |
|
559 | 559 | } |
560 | 560 | // apache Map type: java hashtable |
561 | 561 | } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){ |
562 | 562 | $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']); |
563 | 563 | foreach($children as $child_pos){ |
564 | - $kv = explode("|",$this->message[$child_pos]['children']); |
|
565 | - $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
|
564 | + $kv = explode("|",$this->message[$child_pos]['children']); |
|
565 | + $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
|
566 | 566 | } |
567 | 567 | // generic compound type |
568 | 568 | //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') { |
569 | - } else { |
|
570 | - // Apache Vector type: treat as an array |
|
569 | + } else { |
|
570 | + // Apache Vector type: treat as an array |
|
571 | 571 | $this->debug('in buildVal, adding Java Vector or generic compound type '.$this->message[$pos]['name']); |
572 | - if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
573 | - $notstruct = 1; |
|
574 | - } else { |
|
575 | - $notstruct = 0; |
|
576 | - } |
|
577 | - // |
|
578 | - foreach($children as $child_pos){ |
|
579 | - if($notstruct){ |
|
580 | - $params[] = &$this->message[$child_pos]['result']; |
|
581 | - } else { |
|
582 | - if (isset($params[$this->message[$child_pos]['name']])) { |
|
583 | - // de-serialize repeated element name into an array |
|
584 | - if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) { |
|
585 | - $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]); |
|
586 | - } |
|
587 | - $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result']; |
|
588 | - } else { |
|
589 | - $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result']; |
|
590 | - } |
|
591 | - } |
|
572 | + if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
573 | + $notstruct = 1; |
|
574 | + } else { |
|
575 | + $notstruct = 0; |
|
592 | 576 | } |
593 | - } |
|
594 | - if (isset($this->message[$pos]['xattrs'])) { |
|
577 | + // |
|
578 | + foreach($children as $child_pos){ |
|
579 | + if($notstruct){ |
|
580 | + $params[] = &$this->message[$child_pos]['result']; |
|
581 | + } else { |
|
582 | + if (isset($params[$this->message[$child_pos]['name']])) { |
|
583 | + // de-serialize repeated element name into an array |
|
584 | + if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) { |
|
585 | + $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]); |
|
586 | + } |
|
587 | + $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result']; |
|
588 | + } else { |
|
589 | + $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result']; |
|
590 | + } |
|
591 | + } |
|
592 | + } |
|
593 | + } |
|
594 | + if (isset($this->message[$pos]['xattrs'])) { |
|
595 | 595 | $this->debug('in buildVal, handling attributes'); |
596 | - foreach ($this->message[$pos]['xattrs'] as $n => $v) { |
|
597 | - $params[$n] = $v; |
|
598 | - } |
|
599 | - } |
|
600 | - // handle simpleContent |
|
601 | - if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
596 | + foreach ($this->message[$pos]['xattrs'] as $n => $v) { |
|
597 | + $params[$n] = $v; |
|
598 | + } |
|
599 | + } |
|
600 | + // handle simpleContent |
|
601 | + if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
602 | 602 | $this->debug('in buildVal, handling simpleContent'); |
603 | - if (isset($this->message[$pos]['type'])) { |
|
604 | - $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
605 | - } else { |
|
606 | - $parent = $this->message[$pos]['parent']; |
|
607 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
608 | - $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
609 | - } else { |
|
610 | - $params['!'] = $this->message[$pos]['cdata']; |
|
611 | - } |
|
612 | - } |
|
613 | - } |
|
614 | - $ret = is_array($params) ? $params : array(); |
|
615 | - $this->debug('in buildVal, return:'); |
|
616 | - //$this->appendDebug($this->varDump($ret)); |
|
617 | - return $ret; |
|
618 | - } else { |
|
619 | - $this->debug('in buildVal, no children, building scalar'); |
|
620 | - $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : ''; |
|
621 | - if (isset($this->message[$pos]['type'])) { |
|
622 | - $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
623 | - $this->debug("in buildVal, return: $ret"); |
|
624 | - return $ret; |
|
625 | - } |
|
626 | - $parent = $this->message[$pos]['parent']; |
|
627 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
628 | - $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
629 | - $this->debug("in buildVal, return: $ret"); |
|
630 | - return $ret; |
|
631 | - } |
|
632 | - $ret = $this->message[$pos]['cdata']; |
|
633 | - $this->debug("in buildVal, return: $ret"); |
|
634 | - return $ret; |
|
635 | - } |
|
636 | - } |
|
603 | + if (isset($this->message[$pos]['type'])) { |
|
604 | + $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
605 | + } else { |
|
606 | + $parent = $this->message[$pos]['parent']; |
|
607 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
608 | + $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
609 | + } else { |
|
610 | + $params['!'] = $this->message[$pos]['cdata']; |
|
611 | + } |
|
612 | + } |
|
613 | + } |
|
614 | + $ret = is_array($params) ? $params : array(); |
|
615 | + $this->debug('in buildVal, return:'); |
|
616 | + //$this->appendDebug($this->varDump($ret)); |
|
617 | + return $ret; |
|
618 | + } else { |
|
619 | + $this->debug('in buildVal, no children, building scalar'); |
|
620 | + $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : ''; |
|
621 | + if (isset($this->message[$pos]['type'])) { |
|
622 | + $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
623 | + $this->debug("in buildVal, return: $ret"); |
|
624 | + return $ret; |
|
625 | + } |
|
626 | + $parent = $this->message[$pos]['parent']; |
|
627 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
628 | + $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
629 | + $this->debug("in buildVal, return: $ret"); |
|
630 | + return $ret; |
|
631 | + } |
|
632 | + $ret = $this->message[$pos]['cdata']; |
|
633 | + $this->debug("in buildVal, return: $ret"); |
|
634 | + return $ret; |
|
635 | + } |
|
636 | + } |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | /** |
@@ -16,189 +16,189 @@ |
||
16 | 16 | * @access public |
17 | 17 | */ |
18 | 18 | class nusoap_wsdlcache { |
19 | - /** |
|
20 | - * @var resource |
|
21 | - * @access private |
|
22 | - */ |
|
23 | - var $fplock; |
|
24 | - /** |
|
25 | - * @var integer |
|
26 | - * @access private |
|
27 | - */ |
|
28 | - var $cache_lifetime; |
|
29 | - /** |
|
30 | - * @var string |
|
31 | - * @access private |
|
32 | - */ |
|
33 | - var $cache_dir; |
|
34 | - /** |
|
35 | - * @var string |
|
36 | - * @access public |
|
37 | - */ |
|
38 | - var $debug_str = ''; |
|
19 | + /** |
|
20 | + * @var resource |
|
21 | + * @access private |
|
22 | + */ |
|
23 | + var $fplock; |
|
24 | + /** |
|
25 | + * @var integer |
|
26 | + * @access private |
|
27 | + */ |
|
28 | + var $cache_lifetime; |
|
29 | + /** |
|
30 | + * @var string |
|
31 | + * @access private |
|
32 | + */ |
|
33 | + var $cache_dir; |
|
34 | + /** |
|
35 | + * @var string |
|
36 | + * @access public |
|
37 | + */ |
|
38 | + var $debug_str = ''; |
|
39 | 39 | |
40 | - /** |
|
41 | - * constructor |
|
42 | - * |
|
43 | - * @param string $cache_dir directory for cache-files |
|
44 | - * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited |
|
45 | - * @access public |
|
46 | - */ |
|
47 | - function nusoap_wsdlcache($cache_dir='.', $cache_lifetime=0) { |
|
48 | - $this->fplock = array(); |
|
49 | - $this->cache_dir = $cache_dir != '' ? $cache_dir : '.'; |
|
50 | - $this->cache_lifetime = $cache_lifetime; |
|
51 | - } |
|
40 | + /** |
|
41 | + * constructor |
|
42 | + * |
|
43 | + * @param string $cache_dir directory for cache-files |
|
44 | + * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited |
|
45 | + * @access public |
|
46 | + */ |
|
47 | + function nusoap_wsdlcache($cache_dir='.', $cache_lifetime=0) { |
|
48 | + $this->fplock = array(); |
|
49 | + $this->cache_dir = $cache_dir != '' ? $cache_dir : '.'; |
|
50 | + $this->cache_lifetime = $cache_lifetime; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * creates the filename used to cache a wsdl instance |
|
55 | - * |
|
56 | - * @param string $wsdl The URL of the wsdl instance |
|
57 | - * @return string The filename used to cache the instance |
|
58 | - * @access private |
|
59 | - */ |
|
60 | - function createFilename($wsdl) { |
|
61 | - return $this->cache_dir.'/wsdlcache-' . md5($wsdl); |
|
62 | - } |
|
53 | + /** |
|
54 | + * creates the filename used to cache a wsdl instance |
|
55 | + * |
|
56 | + * @param string $wsdl The URL of the wsdl instance |
|
57 | + * @return string The filename used to cache the instance |
|
58 | + * @access private |
|
59 | + */ |
|
60 | + function createFilename($wsdl) { |
|
61 | + return $this->cache_dir.'/wsdlcache-' . md5($wsdl); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * adds debug data to the class level debug string |
|
66 | - * |
|
67 | - * @param string $string debug data |
|
68 | - * @access private |
|
69 | - */ |
|
70 | - function debug($string){ |
|
71 | - $this->debug_str .= get_class($this).": $string\n"; |
|
72 | - } |
|
64 | + /** |
|
65 | + * adds debug data to the class level debug string |
|
66 | + * |
|
67 | + * @param string $string debug data |
|
68 | + * @access private |
|
69 | + */ |
|
70 | + function debug($string){ |
|
71 | + $this->debug_str .= get_class($this).": $string\n"; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * gets a wsdl instance from the cache |
|
76 | - * |
|
77 | - * @param string $wsdl The URL of the wsdl instance |
|
78 | - * @return object wsdl The cached wsdl instance, null if the instance is not in the cache |
|
79 | - * @access public |
|
80 | - */ |
|
81 | - function get($wsdl) { |
|
82 | - $filename = $this->createFilename($wsdl); |
|
83 | - if ($this->obtainMutex($filename, "r")) { |
|
84 | - // check for expired WSDL that must be removed from the cache |
|
85 | - if ($this->cache_lifetime > 0) { |
|
86 | - if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) { |
|
87 | - unlink($filename); |
|
88 | - $this->debug("Expired $wsdl ($filename) from cache"); |
|
89 | - $this->releaseMutex($filename); |
|
90 | - return null; |
|
91 | - } |
|
92 | - } |
|
93 | - // see what there is to return |
|
94 | - if (!file_exists($filename)) { |
|
95 | - $this->debug("$wsdl ($filename) not in cache (1)"); |
|
96 | - $this->releaseMutex($filename); |
|
97 | - return null; |
|
98 | - } |
|
99 | - $fp = @fopen($filename, "r"); |
|
100 | - if ($fp) { |
|
101 | - $s = implode("", @file($filename)); |
|
102 | - fclose($fp); |
|
103 | - $this->debug("Got $wsdl ($filename) from cache"); |
|
104 | - } else { |
|
105 | - $s = null; |
|
106 | - $this->debug("$wsdl ($filename) not in cache (2)"); |
|
107 | - } |
|
108 | - $this->releaseMutex($filename); |
|
109 | - return (!is_null($s)) ? unserialize($s) : null; |
|
110 | - } else { |
|
111 | - $this->debug("Unable to obtain mutex for $filename in get"); |
|
112 | - } |
|
113 | - return null; |
|
114 | - } |
|
74 | + /** |
|
75 | + * gets a wsdl instance from the cache |
|
76 | + * |
|
77 | + * @param string $wsdl The URL of the wsdl instance |
|
78 | + * @return object wsdl The cached wsdl instance, null if the instance is not in the cache |
|
79 | + * @access public |
|
80 | + */ |
|
81 | + function get($wsdl) { |
|
82 | + $filename = $this->createFilename($wsdl); |
|
83 | + if ($this->obtainMutex($filename, "r")) { |
|
84 | + // check for expired WSDL that must be removed from the cache |
|
85 | + if ($this->cache_lifetime > 0) { |
|
86 | + if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) { |
|
87 | + unlink($filename); |
|
88 | + $this->debug("Expired $wsdl ($filename) from cache"); |
|
89 | + $this->releaseMutex($filename); |
|
90 | + return null; |
|
91 | + } |
|
92 | + } |
|
93 | + // see what there is to return |
|
94 | + if (!file_exists($filename)) { |
|
95 | + $this->debug("$wsdl ($filename) not in cache (1)"); |
|
96 | + $this->releaseMutex($filename); |
|
97 | + return null; |
|
98 | + } |
|
99 | + $fp = @fopen($filename, "r"); |
|
100 | + if ($fp) { |
|
101 | + $s = implode("", @file($filename)); |
|
102 | + fclose($fp); |
|
103 | + $this->debug("Got $wsdl ($filename) from cache"); |
|
104 | + } else { |
|
105 | + $s = null; |
|
106 | + $this->debug("$wsdl ($filename) not in cache (2)"); |
|
107 | + } |
|
108 | + $this->releaseMutex($filename); |
|
109 | + return (!is_null($s)) ? unserialize($s) : null; |
|
110 | + } else { |
|
111 | + $this->debug("Unable to obtain mutex for $filename in get"); |
|
112 | + } |
|
113 | + return null; |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * obtains the local mutex |
|
118 | - * |
|
119 | - * @param string $filename The Filename of the Cache to lock |
|
120 | - * @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode |
|
121 | - * @return boolean Lock successfully obtained ?! |
|
122 | - * @access private |
|
123 | - */ |
|
124 | - function obtainMutex($filename, $mode) { |
|
125 | - if (isset($this->fplock[md5($filename)])) { |
|
126 | - $this->debug("Lock for $filename already exists"); |
|
127 | - return false; |
|
128 | - } |
|
129 | - $this->fplock[md5($filename)] = fopen($filename.".lock", "w"); |
|
130 | - if ($mode == "r") { |
|
131 | - return flock($this->fplock[md5($filename)], LOCK_SH); |
|
132 | - } else { |
|
133 | - return flock($this->fplock[md5($filename)], LOCK_EX); |
|
134 | - } |
|
135 | - } |
|
116 | + /** |
|
117 | + * obtains the local mutex |
|
118 | + * |
|
119 | + * @param string $filename The Filename of the Cache to lock |
|
120 | + * @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode |
|
121 | + * @return boolean Lock successfully obtained ?! |
|
122 | + * @access private |
|
123 | + */ |
|
124 | + function obtainMutex($filename, $mode) { |
|
125 | + if (isset($this->fplock[md5($filename)])) { |
|
126 | + $this->debug("Lock for $filename already exists"); |
|
127 | + return false; |
|
128 | + } |
|
129 | + $this->fplock[md5($filename)] = fopen($filename.".lock", "w"); |
|
130 | + if ($mode == "r") { |
|
131 | + return flock($this->fplock[md5($filename)], LOCK_SH); |
|
132 | + } else { |
|
133 | + return flock($this->fplock[md5($filename)], LOCK_EX); |
|
134 | + } |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * adds a wsdl instance to the cache |
|
139 | - * |
|
140 | - * @param object wsdl $wsdl_instance The wsdl instance to add |
|
141 | - * @return boolean WSDL successfully cached |
|
142 | - * @access public |
|
143 | - */ |
|
144 | - function put($wsdl_instance) { |
|
145 | - $filename = $this->createFilename($wsdl_instance->wsdl); |
|
146 | - $s = serialize($wsdl_instance); |
|
147 | - if ($this->obtainMutex($filename, "w")) { |
|
148 | - $fp = fopen($filename, "w"); |
|
149 | - if (! $fp) { |
|
150 | - $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache"); |
|
151 | - $this->releaseMutex($filename); |
|
152 | - return false; |
|
153 | - } |
|
154 | - fputs($fp, $s); |
|
155 | - fclose($fp); |
|
156 | - $this->debug("Put $wsdl_instance->wsdl ($filename) in cache"); |
|
157 | - $this->releaseMutex($filename); |
|
158 | - return true; |
|
159 | - } else { |
|
160 | - $this->debug("Unable to obtain mutex for $filename in put"); |
|
161 | - } |
|
162 | - return false; |
|
163 | - } |
|
137 | + /** |
|
138 | + * adds a wsdl instance to the cache |
|
139 | + * |
|
140 | + * @param object wsdl $wsdl_instance The wsdl instance to add |
|
141 | + * @return boolean WSDL successfully cached |
|
142 | + * @access public |
|
143 | + */ |
|
144 | + function put($wsdl_instance) { |
|
145 | + $filename = $this->createFilename($wsdl_instance->wsdl); |
|
146 | + $s = serialize($wsdl_instance); |
|
147 | + if ($this->obtainMutex($filename, "w")) { |
|
148 | + $fp = fopen($filename, "w"); |
|
149 | + if (! $fp) { |
|
150 | + $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache"); |
|
151 | + $this->releaseMutex($filename); |
|
152 | + return false; |
|
153 | + } |
|
154 | + fputs($fp, $s); |
|
155 | + fclose($fp); |
|
156 | + $this->debug("Put $wsdl_instance->wsdl ($filename) in cache"); |
|
157 | + $this->releaseMutex($filename); |
|
158 | + return true; |
|
159 | + } else { |
|
160 | + $this->debug("Unable to obtain mutex for $filename in put"); |
|
161 | + } |
|
162 | + return false; |
|
163 | + } |
|
164 | 164 | |
165 | - /** |
|
166 | - * releases the local mutex |
|
167 | - * |
|
168 | - * @param string $filename The Filename of the Cache to lock |
|
169 | - * @return boolean Lock successfully released |
|
170 | - * @access private |
|
171 | - */ |
|
172 | - function releaseMutex($filename) { |
|
173 | - $ret = flock($this->fplock[md5($filename)], LOCK_UN); |
|
174 | - fclose($this->fplock[md5($filename)]); |
|
175 | - unset($this->fplock[md5($filename)]); |
|
176 | - if (! $ret) { |
|
177 | - $this->debug("Not able to release lock for $filename"); |
|
178 | - } |
|
179 | - return $ret; |
|
180 | - } |
|
165 | + /** |
|
166 | + * releases the local mutex |
|
167 | + * |
|
168 | + * @param string $filename The Filename of the Cache to lock |
|
169 | + * @return boolean Lock successfully released |
|
170 | + * @access private |
|
171 | + */ |
|
172 | + function releaseMutex($filename) { |
|
173 | + $ret = flock($this->fplock[md5($filename)], LOCK_UN); |
|
174 | + fclose($this->fplock[md5($filename)]); |
|
175 | + unset($this->fplock[md5($filename)]); |
|
176 | + if (! $ret) { |
|
177 | + $this->debug("Not able to release lock for $filename"); |
|
178 | + } |
|
179 | + return $ret; |
|
180 | + } |
|
181 | 181 | |
182 | - /** |
|
183 | - * removes a wsdl instance from the cache |
|
184 | - * |
|
185 | - * @param string $wsdl The URL of the wsdl instance |
|
186 | - * @return boolean Whether there was an instance to remove |
|
187 | - * @access public |
|
188 | - */ |
|
189 | - function remove($wsdl) { |
|
190 | - $filename = $this->createFilename($wsdl); |
|
191 | - if (!file_exists($filename)) { |
|
192 | - $this->debug("$wsdl ($filename) not in cache to be removed"); |
|
193 | - return false; |
|
194 | - } |
|
195 | - // ignore errors obtaining mutex |
|
196 | - $this->obtainMutex($filename, "w"); |
|
197 | - $ret = unlink($filename); |
|
198 | - $this->debug("Removed ($ret) $wsdl ($filename) from cache"); |
|
199 | - $this->releaseMutex($filename); |
|
200 | - return $ret; |
|
201 | - } |
|
182 | + /** |
|
183 | + * removes a wsdl instance from the cache |
|
184 | + * |
|
185 | + * @param string $wsdl The URL of the wsdl instance |
|
186 | + * @return boolean Whether there was an instance to remove |
|
187 | + * @access public |
|
188 | + */ |
|
189 | + function remove($wsdl) { |
|
190 | + $filename = $this->createFilename($wsdl); |
|
191 | + if (!file_exists($filename)) { |
|
192 | + $this->debug("$wsdl ($filename) not in cache to be removed"); |
|
193 | + return false; |
|
194 | + } |
|
195 | + // ignore errors obtaining mutex |
|
196 | + $this->obtainMutex($filename, "w"); |
|
197 | + $ret = unlink($filename); |
|
198 | + $this->debug("Removed ($ret) $wsdl ($filename) from cache"); |
|
199 | + $this->releaseMutex($filename); |
|
200 | + return $ret; |
|
201 | + } |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited |
45 | 45 | * @access public |
46 | 46 | */ |
47 | - function nusoap_wsdlcache($cache_dir='.', $cache_lifetime=0) { |
|
47 | + function nusoap_wsdlcache($cache_dir = '.', $cache_lifetime = 0) { |
|
48 | 48 | $this->fplock = array(); |
49 | 49 | $this->cache_dir = $cache_dir != '' ? $cache_dir : '.'; |
50 | 50 | $this->cache_lifetime = $cache_lifetime; |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @access private |
59 | 59 | */ |
60 | 60 | function createFilename($wsdl) { |
61 | - return $this->cache_dir.'/wsdlcache-' . md5($wsdl); |
|
61 | + return $this->cache_dir.'/wsdlcache-'.md5($wsdl); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param string $string debug data |
68 | 68 | * @access private |
69 | 69 | */ |
70 | - function debug($string){ |
|
70 | + function debug($string) { |
|
71 | 71 | $this->debug_str .= get_class($this).": $string\n"; |
72 | 72 | } |
73 | 73 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | $s = serialize($wsdl_instance); |
147 | 147 | if ($this->obtainMutex($filename, "w")) { |
148 | 148 | $fp = fopen($filename, "w"); |
149 | - if (! $fp) { |
|
149 | + if (!$fp) { |
|
150 | 150 | $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache"); |
151 | 151 | $this->releaseMutex($filename); |
152 | 152 | return false; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $ret = flock($this->fplock[md5($filename)], LOCK_UN); |
174 | 174 | fclose($this->fplock[md5($filename)]); |
175 | 175 | unset($this->fplock[md5($filename)]); |
176 | - if (! $ret) { |
|
176 | + if (!$ret) { |
|
177 | 177 | $this->debug("Not able to release lock for $filename"); |
178 | 178 | } |
179 | 179 | return $ret; |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | $params['session_id'] = api_get_session_id(); |
78 | 78 | $params['category_id'] = isset($params['category_id']) ? $params['category_id'] : 0; |
79 | 79 | |
80 | - $sql = "SELECT MAX(display_order) |
|
80 | + $sql = "SELECT MAX(display_order) |
|
81 | 81 | FROM ".$this->table." |
82 | 82 | WHERE |
83 | 83 | c_id = $courseId AND |
84 | - category_id = '" . intval($params['category_id'])."'"; |
|
84 | + category_id = '".intval($params['category_id'])."'"; |
|
85 | 85 | $result = Database:: query($sql); |
86 | 86 | list ($orderMax) = Database:: fetch_row($result); |
87 | 87 | $order = $orderMax + 1; |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | // We ensure URL to be absolute. |
187 | 187 | if (strpos($urllink, '://') === false) { |
188 | - $urllink = 'http://' . $urllink; |
|
188 | + $urllink = 'http://'.$urllink; |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | // If the title is empty, we use the URL as title. |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | 'c_id' => $course_id, |
208 | 208 | 'url' => $urllink, |
209 | 209 | 'title' => $title, |
210 | - 'description' => $description , |
|
210 | + 'description' => $description, |
|
211 | 211 | 'category_id' => $selectcategory, |
212 | 212 | 'on_homepage' => $onhomepage, |
213 | 213 | 'target' => $target, |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | if ((api_get_setting('search_enabled') == 'true') && |
221 | 221 | $link_id && extension_loaded('xapian') |
222 | 222 | ) { |
223 | - require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php'; |
|
224 | - require_once api_get_path(LIBRARY_PATH) . 'search/IndexableChunk.class.php'; |
|
225 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
223 | + require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php'; |
|
224 | + require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php'; |
|
225 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
226 | 226 | |
227 | 227 | $course_int_id = $_course['real_id']; |
228 | 228 | $courseCode = $_course['code']; |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | if (isset ($_REQUEST[$specific_field['code']])) { |
236 | 236 | $sterms = trim($_REQUEST[$specific_field['code']]); |
237 | 237 | if (!empty ($sterms)) { |
238 | - $all_specific_terms .= ' ' . $sterms; |
|
238 | + $all_specific_terms .= ' '.$sterms; |
|
239 | 239 | $sterms = explode(',', $sterms); |
240 | 240 | foreach ($sterms as $sterm) { |
241 | 241 | $ic_slide->addTerm( |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | SE_COURSE_ID => $courseCode, |
263 | 263 | SE_TOOL_ID => TOOL_LINK, |
264 | 264 | SE_DATA => array( |
265 | - 'link_id' => (int)$link_id |
|
265 | + 'link_id' => (int) $link_id |
|
266 | 266 | ), |
267 | - SE_USER => (int)api_get_user_id(), |
|
267 | + SE_USER => (int) api_get_user_id(), |
|
268 | 268 | ); |
269 | 269 | $ic_slide->xapian_data = serialize($xapian_data); |
270 | - $description = $all_specific_terms . ' ' . $description; |
|
270 | + $description = $all_specific_terms.' '.$description; |
|
271 | 271 | $ic_slide->addValue('content', $description); |
272 | 272 | |
273 | 273 | // Add category name if set. |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $sql_cat = sprintf( |
280 | 280 | $sql_cat, |
281 | 281 | $table_link_category, |
282 | - (int)$selectcategory, |
|
282 | + (int) $selectcategory, |
|
283 | 283 | $course_int_id |
284 | 284 | ); |
285 | 285 | $result = Database:: query($sql_cat); |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | // This will make a restore function possible for the platform administrator. |
400 | 400 | |
401 | 401 | $sql = "UPDATE $tbl_link SET on_homepage='0' |
402 | - WHERE c_id = $course_id AND id='" . $id . "'"; |
|
402 | + WHERE c_id = $course_id AND id='".$id."'"; |
|
403 | 403 | Database:: query($sql); |
404 | 404 | |
405 | 405 | api_item_property_update( |
@@ -415,12 +415,12 @@ discard block |
||
415 | 415 | break; |
416 | 416 | case 'category': |
417 | 417 | // First we delete the category itself and afterwards all the links of this category. |
418 | - $sql = "DELETE FROM " . $tbl_categories . " |
|
419 | - WHERE c_id = $course_id AND id='" . $id . "'"; |
|
418 | + $sql = "DELETE FROM ".$tbl_categories." |
|
419 | + WHERE c_id = $course_id AND id='".$id."'"; |
|
420 | 420 | Database:: query($sql); |
421 | 421 | |
422 | - $sql = "DELETE FROM " . $tbl_link . " |
|
423 | - WHERE c_id = $course_id AND category_id='" . $id . "'"; |
|
422 | + $sql = "DELETE FROM ".$tbl_link." |
|
423 | + WHERE c_id = $course_id AND category_id='".$id."'"; |
|
424 | 424 | Database:: query($sql); |
425 | 425 | |
426 | 426 | api_item_property_update( |
@@ -459,16 +459,16 @@ discard block |
||
459 | 459 | $row = Database:: fetch_array($res); |
460 | 460 | require_once api_get_path( |
461 | 461 | LIBRARY_PATH |
462 | - ) . 'search/ChamiloIndexer.class.php'; |
|
462 | + ).'search/ChamiloIndexer.class.php'; |
|
463 | 463 | $di = new ChamiloIndexer(); |
464 | - $di->remove_document((int)$row['search_did']); |
|
464 | + $di->remove_document((int) $row['search_did']); |
|
465 | 465 | } |
466 | 466 | $sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1'; |
467 | 467 | $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_LINK, $link_id); |
468 | 468 | Database:: query($sql); |
469 | 469 | |
470 | 470 | // Remove terms from db. |
471 | - require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php'; |
|
471 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
472 | 472 | delete_all_values_for_item($course_id, TOOL_DOCUMENT, $link_id); |
473 | 473 | } |
474 | 474 | } |
@@ -484,8 +484,8 @@ discard block |
||
484 | 484 | { |
485 | 485 | $tbl_link = Database:: get_course_table(TABLE_LINK); |
486 | 486 | $course_id = api_get_course_int_id(); |
487 | - $sql = "SELECT * FROM " . $tbl_link . " |
|
488 | - WHERE c_id = $course_id AND id='" . intval($id) . "' "; |
|
487 | + $sql = "SELECT * FROM ".$tbl_link." |
|
488 | + WHERE c_id = $course_id AND id='".intval($id)."' "; |
|
489 | 489 | $result = Database::query($sql); |
490 | 490 | $data = array(); |
491 | 491 | if (Database::num_rows($result)) { |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | |
515 | 515 | // We ensure URL to be absolute. |
516 | 516 | if (strpos($values['url'], '://') === false) { |
517 | - $values['url'] = 'http://' . $_POST['url']; |
|
517 | + $values['url'] = 'http://'.$_POST['url']; |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | // If the title is empty, we use the URL as title. |
@@ -532,18 +532,18 @@ discard block |
||
532 | 532 | } |
533 | 533 | |
534 | 534 | // Finding the old category_id. |
535 | - $sql = "SELECT * FROM " . $tbl_link . " |
|
536 | - WHERE c_id = $course_id AND id='" . $id . "'"; |
|
535 | + $sql = "SELECT * FROM ".$tbl_link." |
|
536 | + WHERE c_id = $course_id AND id='".$id."'"; |
|
537 | 537 | $result = Database:: query($sql); |
538 | 538 | $row = Database:: fetch_array($result); |
539 | 539 | $category_id = $row['category_id']; |
540 | 540 | |
541 | 541 | if ($category_id != $values['category_id']) { |
542 | 542 | $sql = "SELECT MAX(display_order) |
543 | - FROM " . $tbl_link . " |
|
543 | + FROM " . $tbl_link." |
|
544 | 544 | WHERE |
545 | 545 | c_id = $course_id AND |
546 | - category_id='" . intval($values['category_id']) . "'"; |
|
546 | + category_id='".intval($values['category_id'])."'"; |
|
547 | 547 | $result = Database:: query($sql); |
548 | 548 | list ($max_display_order) = Database:: fetch_row($result); |
549 | 549 | $max_display_order++; |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | 'target' => $values['target'], |
561 | 561 | 'category_id' => $values['category_id'], |
562 | 562 | ]; |
563 | - Database::update($tbl_link, $params, ['c_id = ? AND id = ?' => [$course_id, $id] ]); |
|
563 | + Database::update($tbl_link, $params, ['c_id = ? AND id = ?' => [$course_id, $id]]); |
|
564 | 564 | |
565 | 565 | // Update search enchine and its values table if enabled. |
566 | 566 | if (api_get_setting('search_enabled') == 'true') { |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | $_REQUEST[$specific_field['code']] |
614 | 614 | ); |
615 | 615 | if (!empty ($sterms)) { |
616 | - $all_specific_terms .= ' ' . $sterms; |
|
616 | + $all_specific_terms .= ' '.$sterms; |
|
617 | 617 | $sterms = explode(',', $sterms); |
618 | 618 | foreach ($sterms as $sterm) { |
619 | 619 | $ic_slide->addTerm( |
@@ -640,13 +640,13 @@ discard block |
||
640 | 640 | SE_COURSE_ID => $course_id, |
641 | 641 | SE_TOOL_ID => TOOL_LINK, |
642 | 642 | SE_DATA => array( |
643 | - 'link_id' => (int)$id |
|
643 | + 'link_id' => (int) $id |
|
644 | 644 | ), |
645 | - SE_USER => (int)api_get_user_id(), |
|
645 | + SE_USER => (int) api_get_user_id(), |
|
646 | 646 | |
647 | 647 | ); |
648 | 648 | $ic_slide->xapian_data = serialize($xapian_data); |
649 | - $link_description = $all_specific_terms . ' ' . $link_description; |
|
649 | + $link_description = $all_specific_terms.' '.$link_description; |
|
650 | 650 | $ic_slide->addValue('content', $link_description); |
651 | 651 | |
652 | 652 | // Add category name if set. |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | $di = new ChamiloIndexer(); |
675 | 675 | isset ($_POST['language']) ? $lang = Database:: escape_string($_POST['language']) : $lang = 'english'; |
676 | 676 | $di->connectDb(null, null, $lang); |
677 | - $di->remove_document((int)$se_ref['search_did']); |
|
677 | + $di->remove_document((int) $se_ref['search_did']); |
|
678 | 678 | $di->addChunk($ic_slide); |
679 | 679 | |
680 | 680 | // Index and return search engine document id. |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | $sql = "SELECT *, linkcat.id |
792 | 792 | FROM $tblLinkCategory linkcat |
793 | 793 | WHERE |
794 | - linkcat.c_id = " . $courseId . " |
|
794 | + linkcat.c_id = ".$courseId." |
|
795 | 795 | $sessionCondition |
796 | 796 | ORDER BY linkcat.display_order DESC"; |
797 | 797 | |
@@ -803,10 +803,10 @@ discard block |
||
803 | 803 | INNER JOIN $tblItemProperty itemproperties |
804 | 804 | ON (linkcat.id = itemproperties.ref AND linkcat.c_id = itemproperties.c_id) |
805 | 805 | WHERE |
806 | - itemproperties.tool = '" . TOOL_LINK_CATEGORY . "' AND |
|
806 | + itemproperties.tool = '".TOOL_LINK_CATEGORY."' AND |
|
807 | 807 | (itemproperties.visibility = '0' OR itemproperties.visibility = '1') |
808 | 808 | $sessionCondition AND |
809 | - linkcat.c_id = " . $courseId . " |
|
809 | + linkcat.c_id = ".$courseId." |
|
810 | 810 | ORDER BY linkcat.display_order DESC"; |
811 | 811 | |
812 | 812 | $result = Database::query($sql); |
@@ -829,10 +829,10 @@ discard block |
||
829 | 829 | INNER JOIN $tblItemProperty itemproperties |
830 | 830 | ON (linkcat.id = itemproperties.ref AND linkcat.c_id = itemproperties.c_id) |
831 | 831 | WHERE |
832 | - itemproperties.tool = '" . TOOL_LINK_CATEGORY . "' AND |
|
832 | + itemproperties.tool = '".TOOL_LINK_CATEGORY."' AND |
|
833 | 833 | (itemproperties.visibility = '0' OR itemproperties.visibility = '1') |
834 | 834 | $sessionCondition AND |
835 | - linkcat.c_id = " . $courseId . " |
|
835 | + linkcat.c_id = ".$courseId." |
|
836 | 836 | ORDER BY linkcat.display_order DESC |
837 | 837 | "; |
838 | 838 | $result = Database::query($sql); |
@@ -864,12 +864,12 @@ discard block |
||
864 | 864 | INNER JOIN $TABLE_ITEM_PROPERTY itemproperties |
865 | 865 | ON (link.id=itemproperties.ref AND link.c_id = itemproperties.c_id ) |
866 | 866 | WHERE |
867 | - itemproperties.tool='" . TOOL_LINK . "' AND |
|
868 | - link.category_id='" . $catid . "' AND |
|
867 | + itemproperties.tool='".TOOL_LINK."' AND |
|
868 | + link.category_id='" . $catid."' AND |
|
869 | 869 | (itemproperties.visibility='0' OR itemproperties.visibility='1') |
870 | 870 | $condition_session AND |
871 | - link.c_id = " . $course_id . " AND |
|
872 | - itemproperties.c_id = " . $course_id . " |
|
871 | + link.c_id = ".$course_id." AND |
|
872 | + itemproperties.c_id = " . $course_id." |
|
873 | 873 | ORDER BY link.display_order DESC"; |
874 | 874 | $result = Database:: query($sql); |
875 | 875 | $numberoflinks = Database:: num_rows($result); |
@@ -892,14 +892,14 @@ discard block |
||
892 | 892 | 'retweet', |
893 | 893 | 'default btn-sm', |
894 | 894 | array( |
895 | - 'onclick' => "check_url('" . $myrow['id'] . "', '" . addslashes($myrow['url']) . "');", |
|
895 | + 'onclick' => "check_url('".$myrow['id']."', '".addslashes($myrow['url'])."');", |
|
896 | 896 | 'title' => get_lang('CheckURL') |
897 | 897 | ) |
898 | 898 | ); |
899 | 899 | $link_validator .= Display::span( |
900 | 900 | '', |
901 | 901 | array( |
902 | - 'id' => 'url_id_' . $myrow['id'], |
|
902 | + 'id' => 'url_id_'.$myrow['id'], |
|
903 | 903 | 'class' => 'check-link' |
904 | 904 | ) |
905 | 905 | ); |
@@ -909,10 +909,10 @@ discard block |
||
909 | 909 | if (api_is_allowed_to_edit(null, true)) { |
910 | 910 | |
911 | 911 | if ($session_id == $myrow['session_id']) { |
912 | - $url = api_get_self() . '?' . api_get_cidreq() . |
|
913 | - '&action=editlink&category=' . (!empty ($category) ? $category : '') . |
|
914 | - '&id=' . $myrow['id'] . |
|
915 | - '&category_id=' . $myrow['id']; |
|
912 | + $url = api_get_self().'?'.api_get_cidreq(). |
|
913 | + '&action=editlink&category='.(!empty ($category) ? $category : ''). |
|
914 | + '&id='.$myrow['id']. |
|
915 | + '&category_id='.$myrow['id']; |
|
916 | 916 | $title = get_lang('Edit'); |
917 | 917 | $toolbar .= Display::toolbarButton( |
918 | 918 | '', |
@@ -940,10 +940,10 @@ discard block |
||
940 | 940 | }*/ |
941 | 941 | |
942 | 942 | if ($myrow['visibility'] == '1') { |
943 | - $url .= 'link.php?' . api_get_cidreq() . |
|
944 | - '&sec_token=' . $token . |
|
945 | - '&action=invisible&id=' . $myrow['id'] . |
|
946 | - '&scope=link&category_id=' . $myrow['category_id']; |
|
943 | + $url .= 'link.php?'.api_get_cidreq(). |
|
944 | + '&sec_token='.$token. |
|
945 | + '&action=invisible&id='.$myrow['id']. |
|
946 | + '&scope=link&category_id='.$myrow['category_id']; |
|
947 | 947 | $title = get_lang('MakeInvisible'); |
948 | 948 | $toolbar .= Display::toolbarButton( |
949 | 949 | '', |
@@ -957,7 +957,7 @@ discard block |
||
957 | 957 | |
958 | 958 | } |
959 | 959 | if ($myrow['visibility'] == '0') { |
960 | - $url .= 'link.php?' . api_get_cidreq() .'&sec_token=' . $token .'&action=visible&id=' . $myrow['id'] .'&scope=link&category_id=' . $myrow['category_id']; |
|
960 | + $url .= 'link.php?'.api_get_cidreq().'&sec_token='.$token.'&action=visible&id='.$myrow['id'].'&scope=link&category_id='.$myrow['category_id']; |
|
961 | 961 | $title = get_lang('MakeVisible'); |
962 | 962 | $toolbar .= Display::toolbarButton( |
963 | 963 | '', |
@@ -970,8 +970,8 @@ discard block |
||
970 | 970 | ); |
971 | 971 | } |
972 | 972 | |
973 | - $url .= api_get_self() . '?' . api_get_cidreq() .'&sec_token=' . $token .'&action=deletelink&id=' . $myrow['id'] .'&category_id=' . $myrow['category_id']; |
|
974 | - $event = "javascript: if(!confirm('" . get_lang('LinkDelconfirm') . "'))return false;"; |
|
973 | + $url .= api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=deletelink&id='.$myrow['id'].'&category_id='.$myrow['category_id']; |
|
974 | + $event = "javascript: if(!confirm('".get_lang('LinkDelconfirm')."'))return false;"; |
|
975 | 975 | $title = get_lang('Delete'); |
976 | 976 | |
977 | 977 | $toolbar .= Display::toolbarButton( |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | $content .= '<div class="pull-right"><div class="btn-group">'.$toolbar.'</div></div>'; |
1013 | 1013 | $content .= '<h4 class="list-group-item-heading">'; |
1014 | 1014 | $content .= $iconLink; |
1015 | - $url = 'link_goto.php?' . api_get_cidreq() .'&link_id=' . $myrow['id'] .'&link_url=' . urlencode($myrow['url']); |
|
1015 | + $url = 'link_goto.php?'.api_get_cidreq().'&link_id='.$myrow['id'].'&link_url='.urlencode($myrow['url']); |
|
1016 | 1016 | $content .= Display::tag( |
1017 | 1017 | 'a', |
1018 | 1018 | Security:: remove_XSS($myrow['title']), |
@@ -1025,7 +1025,7 @@ discard block |
||
1025 | 1025 | $content .= $session_img; |
1026 | 1026 | $content .= '</h4>'; |
1027 | 1027 | |
1028 | - $content .= '<p class="list-group-item-text">' . $myrow['description'] . '</p>'; |
|
1028 | + $content .= '<p class="list-group-item-text">'.$myrow['description'].'</p>'; |
|
1029 | 1029 | $content .= '</div>'; |
1030 | 1030 | } else { |
1031 | 1031 | if (api_is_allowed_to_edit(null, true)) { |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | $content .= '<div class="pull-right"><div class="btn-group">'.$toolbar.'</div></div>'; |
1034 | 1034 | $content .= '<h4 class="list-group-item-heading">'; |
1035 | 1035 | $content .= $iconLink; |
1036 | - $url = 'link_goto.php?' . api_get_cidreq() .'&link_id=' . $myrow['id'] . "&link_url=" . urlencode($myrow['url']); |
|
1036 | + $url = 'link_goto.php?'.api_get_cidreq().'&link_id='.$myrow['id']."&link_url=".urlencode($myrow['url']); |
|
1037 | 1037 | $content .= Display::tag( |
1038 | 1038 | 'a', |
1039 | 1039 | Security:: remove_XSS($myrow['title']), |
@@ -1046,7 +1046,7 @@ discard block |
||
1046 | 1046 | $content .= $link_validator; |
1047 | 1047 | $content .= $session_img; |
1048 | 1048 | $content .= '</h4>'; |
1049 | - $content .= '<p class="list-group-item-text">' . $myrow['description'] . '</p>'; |
|
1049 | + $content .= '<p class="list-group-item-text">'.$myrow['description'].'</p>'; |
|
1050 | 1050 | $content .= '</div>'; |
1051 | 1051 | } |
1052 | 1052 | } |
@@ -1068,58 +1068,58 @@ discard block |
||
1068 | 1068 | { |
1069 | 1069 | $categoryId = $category['id']; |
1070 | 1070 | $token = null; |
1071 | - $tools = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&sec_token=' . $token . '&action=editcategory&id=' . $categoryId . '&category_id=' . $categoryId . '" title=' . get_lang('Modify') . '">' . |
|
1071 | + $tools = '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=editcategory&id='.$categoryId.'&category_id='.$categoryId.'" title='.get_lang('Modify').'">'. |
|
1072 | 1072 | Display:: return_icon( |
1073 | 1073 | 'edit.png', |
1074 | 1074 | get_lang('Modify'), |
1075 | 1075 | array(), |
1076 | 1076 | ICON_SIZE_SMALL |
1077 | - ) . '</a>'; |
|
1077 | + ).'</a>'; |
|
1078 | 1078 | |
1079 | 1079 | // DISPLAY MOVE UP COMMAND only if it is not the top link. |
1080 | 1080 | if ($currentCategory != 0) { |
1081 | - $tools .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&sec_token=' . $token . '&action=up&up='.$categoryId.'&category_id='.$categoryId.'" title="'.get_lang('Up').'">'. |
|
1081 | + $tools .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=up&up='.$categoryId.'&category_id='.$categoryId.'" title="'.get_lang('Up').'">'. |
|
1082 | 1082 | Display:: return_icon( |
1083 | 1083 | 'up.png', |
1084 | 1084 | get_lang('Up'), |
1085 | 1085 | array(), |
1086 | 1086 | ICON_SIZE_SMALL |
1087 | - ) . '</a>'; |
|
1087 | + ).'</a>'; |
|
1088 | 1088 | } else { |
1089 | 1089 | $tools .= Display:: return_icon( |
1090 | 1090 | 'up_na.png', |
1091 | 1091 | get_lang('Up'), |
1092 | 1092 | array(), |
1093 | 1093 | ICON_SIZE_SMALL |
1094 | - ) . '</a>'; |
|
1094 | + ).'</a>'; |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | // DISPLAY MOVE DOWN COMMAND only if it is not the bottom link. |
1098 | - if ($currentCategory < $countCategories-1) { |
|
1099 | - $tools .= '<a href="' . api_get_self() . '?' . api_get_cidreq() .'&sec_token=' . $token .'&action=down&down=' . $categoryId .'&category_id=' . $categoryId . '">'. |
|
1098 | + if ($currentCategory < $countCategories - 1) { |
|
1099 | + $tools .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=down&down='.$categoryId.'&category_id='.$categoryId.'">'. |
|
1100 | 1100 | Display:: return_icon( |
1101 | 1101 | 'down.png', |
1102 | 1102 | get_lang('Down'), |
1103 | 1103 | array(), |
1104 | 1104 | ICON_SIZE_SMALL |
1105 | - ) . '</a>'; |
|
1105 | + ).'</a>'; |
|
1106 | 1106 | } else { |
1107 | 1107 | $tools .= Display:: return_icon( |
1108 | 1108 | 'down_na.png', |
1109 | 1109 | get_lang('Down'), |
1110 | 1110 | array(), |
1111 | 1111 | ICON_SIZE_SMALL |
1112 | - ) . '</a>'; |
|
1112 | + ).'</a>'; |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | - $tools .= '<a href="' . api_get_self() . '?' . api_get_cidreq() .'&sec_token=' . $token .'&action=deletecategory&id='.$categoryId. "&category_id=$categoryId\" |
|
1116 | - onclick=\"javascript: if(!confirm('" . get_lang('CategoryDelconfirm') . "')) return false;\">". |
|
1115 | + $tools .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&sec_token='.$token.'&action=deletecategory&id='.$categoryId."&category_id=$categoryId\" |
|
1116 | + onclick=\"javascript: if(!confirm('".get_lang('CategoryDelconfirm')."')) return false;\">". |
|
1117 | 1117 | Display:: return_icon( |
1118 | 1118 | 'delete.png', |
1119 | 1119 | get_lang('Delete'), |
1120 | 1120 | array(), |
1121 | 1121 | ICON_SIZE_SMALL |
1122 | - ) . '</a>'; |
|
1122 | + ).'</a>'; |
|
1123 | 1123 | |
1124 | 1124 | return $tools; |
1125 | 1125 | } |
@@ -1166,7 +1166,7 @@ discard block |
||
1166 | 1166 | $movetable = $tbl_link; |
1167 | 1167 | // Getting the category of the link. |
1168 | 1168 | if (!empty ($thiscatlinkId)) { |
1169 | - $sql = "SELECT category_id FROM " . $movetable . " |
|
1169 | + $sql = "SELECT category_id FROM ".$movetable." |
|
1170 | 1170 | WHERE c_id = $courseId AND id='$thiscatlinkId'"; |
1171 | 1171 | $result = Database:: query($sql); |
1172 | 1172 | $catid = Database:: fetch_array($result); |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | ORDER BY display_order $sortDirection"; |
1187 | 1187 | } else { |
1188 | 1188 | $sql = "SELECT id, display_order FROM $movetable |
1189 | - WHERE c_id = $courseId AND category_id='" . $catid[0] . "' |
|
1189 | + WHERE c_id = $courseId AND category_id='".$catid[0]."' |
|
1190 | 1190 | ORDER BY display_order $sortDirection"; |
1191 | 1191 | } |
1192 | 1192 | $linkresult = Database:: query($sql); |
@@ -1200,12 +1200,12 @@ discard block |
||
1200 | 1200 | $nextlinkOrder = $sortrow['display_order']; |
1201 | 1201 | |
1202 | 1202 | Database:: query( |
1203 | - "UPDATE " . $movetable . " |
|
1203 | + "UPDATE ".$movetable." |
|
1204 | 1204 | SET display_order = '$nextlinkOrder' |
1205 | 1205 | WHERE c_id = $courseId AND id = '$thiscatlinkId'" |
1206 | 1206 | ); |
1207 | 1207 | Database:: query( |
1208 | - "UPDATE " . $movetable . " |
|
1208 | + "UPDATE ".$movetable." |
|
1209 | 1209 | SET display_order = '$thislinkOrder' |
1210 | 1210 | WHERE c_id = $courseId AND id = '$nextlinkId'" |
1211 | 1211 | ); |
@@ -1233,10 +1233,10 @@ discard block |
||
1233 | 1233 | $course_id = api_get_course_int_id(); |
1234 | 1234 | |
1235 | 1235 | $result = Database:: query( |
1236 | - "SELECT id FROM " . $tbl_categories . " |
|
1237 | - WHERE c_id = $course_id AND category_title='" . Database::escape_string( |
|
1236 | + "SELECT id FROM ".$tbl_categories." |
|
1237 | + WHERE c_id = $course_id AND category_title='".Database::escape_string( |
|
1238 | 1238 | $catname |
1239 | - ) . "'" |
|
1239 | + )."'" |
|
1240 | 1240 | ); |
1241 | 1241 | if (Database:: num_rows($result) >= 1 && ($row = Database:: fetch_array( |
1242 | 1242 | $result |
@@ -1246,7 +1246,7 @@ discard block |
||
1246 | 1246 | } |
1247 | 1247 | |
1248 | 1248 | $result = Database:: query( |
1249 | - "SELECT MAX(display_order) FROM " . $tbl_categories . " WHERE c_id = $course_id " |
|
1249 | + "SELECT MAX(display_order) FROM ".$tbl_categories." WHERE c_id = $course_id " |
|
1250 | 1250 | ); |
1251 | 1251 | list ($max_order) = Database:: fetch_row($result); |
1252 | 1252 | |
@@ -1273,12 +1273,12 @@ discard block |
||
1273 | 1273 | $tbl_link = Database:: get_course_table(TABLE_LINK); |
1274 | 1274 | $course_id = api_get_course_int_id(); |
1275 | 1275 | |
1276 | - $urleq = "url='" . Database:: escape_string($url) . "'"; |
|
1277 | - $cateq = "category_id=" . intval($cat); |
|
1276 | + $urleq = "url='".Database:: escape_string($url)."'"; |
|
1277 | + $cateq = "category_id=".intval($cat); |
|
1278 | 1278 | |
1279 | 1279 | $result = Database:: query(" |
1280 | 1280 | SELECT id FROM $tbl_link |
1281 | - WHERE c_id = $course_id AND " . $urleq . ' AND ' . $cateq |
|
1281 | + WHERE c_id = $course_id AND ".$urleq.' AND '.$cateq |
|
1282 | 1282 | ); |
1283 | 1283 | |
1284 | 1284 | if (Database:: num_rows($result) >= 1 && ($row = Database:: fetch_array( |
@@ -1286,14 +1286,14 @@ discard block |
||
1286 | 1286 | )) |
1287 | 1287 | ) { |
1288 | 1288 | Database:: query( |
1289 | - "UPDATE $tbl_link set title='" . Database:: escape_string( |
|
1289 | + "UPDATE $tbl_link set title='".Database:: escape_string( |
|
1290 | 1290 | $title |
1291 | - ) . "', description='" . Database:: escape_string( |
|
1291 | + )."', description='".Database:: escape_string( |
|
1292 | 1292 | $description |
1293 | - ) . "' |
|
1294 | - WHERE c_id = $course_id AND id='" . Database:: escape_string( |
|
1293 | + )."' |
|
1294 | + WHERE c_id = $course_id AND id='".Database:: escape_string( |
|
1295 | 1295 | $row['id'] |
1296 | - ) . "'" |
|
1296 | + )."'" |
|
1297 | 1297 | ); |
1298 | 1298 | |
1299 | 1299 | $ipu = 'LinkUpdated'; |
@@ -1302,18 +1302,18 @@ discard block |
||
1302 | 1302 | // Add new link |
1303 | 1303 | $result = Database:: query( |
1304 | 1304 | "SELECT MAX(display_order) FROM $tbl_link |
1305 | - WHERE c_id = $course_id AND category_id='" . intval($cat) . "'" |
|
1305 | + WHERE c_id = $course_id AND category_id='".intval($cat)."'" |
|
1306 | 1306 | ); |
1307 | 1307 | list ($max_order) = Database:: fetch_row($result); |
1308 | 1308 | |
1309 | 1309 | Database:: query( |
1310 | 1310 | "INSERT INTO $tbl_link (c_id, url, title, description, category_id, display_order, on_homepage) |
1311 | - VALUES (" . api_get_course_int_id() . ", |
|
1312 | - '" . Database:: escape_string($url) . "', |
|
1313 | - '" . Database:: escape_string($title) . "', |
|
1314 | - '" . Database:: escape_string($description) . "', |
|
1315 | - '" . intval($cat) . "','" . (intval($max_order) + 1) . "', |
|
1316 | - '" . intval($on_homepage) . |
|
1311 | + VALUES (".api_get_course_int_id().", |
|
1312 | + '" . Database:: escape_string($url)."', |
|
1313 | + '" . Database:: escape_string($title)."', |
|
1314 | + '" . Database:: escape_string($description)."', |
|
1315 | + '" . intval($cat)."','".(intval($max_order) + 1)."', |
|
1316 | + '" . intval($on_homepage). |
|
1317 | 1317 | "')" |
1318 | 1318 | ); |
1319 | 1319 | |
@@ -1391,30 +1391,30 @@ discard block |
||
1391 | 1391 | ) |
1392 | 1392 | ) { // possibly in <...> |
1393 | 1393 | if (($kwlist = trim($regs[1])) != '') { |
1394 | - $kw = '<i kw="' . htmlspecialchars($kwlist) . '">'; |
|
1394 | + $kw = '<i kw="'.htmlspecialchars($kwlist).'">'; |
|
1395 | 1395 | } else { |
1396 | 1396 | $kw = ''; |
1397 | 1397 | } |
1398 | 1398 | // i.e. assume only one of the $hide_fields will be present |
1399 | 1399 | // and if found, hide the value as expando property of an <i> tag |
1400 | 1400 | } elseif (trim($value)) { |
1401 | - $d .= ', ' . $key . ':' . $value; |
|
1401 | + $d .= ', '.$key.':'.$value; |
|
1402 | 1402 | } |
1403 | 1403 | } |
1404 | 1404 | } |
1405 | 1405 | if (!empty($d)) { |
1406 | - $d = substr($d, 2) . ' - '; |
|
1406 | + $d = substr($d, 2).' - '; |
|
1407 | 1407 | } |
1408 | 1408 | |
1409 | 1409 | return Link::put_link( |
1410 | 1410 | $url, |
1411 | 1411 | $cat, |
1412 | 1412 | $title, |
1413 | - $kw . ereg_replace( |
|
1413 | + $kw.ereg_replace( |
|
1414 | 1414 | '\[((/?(b|big|i|small|sub|sup|u))|br/)\]', |
1415 | 1415 | '<\\1>', |
1416 | - htmlspecialchars($d . $linkdata['description']) |
|
1417 | - ) . ($kw ? '</i>' : ''), |
|
1416 | + htmlspecialchars($d.$linkdata['description']) |
|
1417 | + ).($kw ? '</i>' : ''), |
|
1418 | 1418 | $linkdata['on_homepage'] ? '1' : '0', |
1419 | 1419 | $linkdata['hidden'] ? '1' : '0' |
1420 | 1420 | ); |
@@ -1535,19 +1535,19 @@ discard block |
||
1535 | 1535 | echo '<div class="actions">'; |
1536 | 1536 | if (api_is_allowed_to_edit(null, true)) { |
1537 | 1537 | echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addlink&category_id='.$categoryId.'">'. |
1538 | - Display::return_icon('new_link.png', get_lang('LinkAdd'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
1538 | + Display::return_icon('new_link.png', get_lang('LinkAdd'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
1539 | 1539 | echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=addcategory&category_id='.$categoryId.'">'. |
1540 | - Display::return_icon('new_folder.png', get_lang('CategoryAdd'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
1540 | + Display::return_icon('new_folder.png', get_lang('CategoryAdd'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
1541 | 1541 | } |
1542 | 1542 | |
1543 | 1543 | $categories = Link::getLinkCategories($course_id, $session_id); |
1544 | 1544 | $count = count($categories); |
1545 | 1545 | if (!empty($count)) { |
1546 | 1546 | echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=list&show=none">'; |
1547 | - echo Display::return_icon('forum_listview.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM) . ' </a>'; |
|
1547 | + echo Display::return_icon('forum_listview.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).' </a>'; |
|
1548 | 1548 | |
1549 | 1549 | echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=list&show=all">'; |
1550 | - echo Display::return_icon('forum_nestedview.png', get_lang('NestedView'), '', ICON_SIZE_MEDIUM) . '</a>'; |
|
1550 | + echo Display::return_icon('forum_nestedview.png', get_lang('NestedView'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
1551 | 1551 | } |
1552 | 1552 | echo '</div>'; |
1553 | 1553 | |
@@ -1579,12 +1579,12 @@ discard block |
||
1579 | 1579 | $strVisibility = ''; |
1580 | 1580 | $visibilityClass = null; |
1581 | 1581 | if ($myrow['visibility'] == '1') { |
1582 | - $strVisibility = '<a href="link.php?' . api_get_cidreq() . '&sec_token='.$token.'&action=invisible&id=' . $myrow['id'] . '&scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Hide') . '">' . |
|
1583 | - Display :: return_icon('visible.png', get_lang('Hide'), array (), ICON_SIZE_SMALL) . '</a>'; |
|
1582 | + $strVisibility = '<a href="link.php?'.api_get_cidreq().'&sec_token='.$token.'&action=invisible&id='.$myrow['id'].'&scope='.TOOL_LINK_CATEGORY.'" title="'.get_lang('Hide').'">'. |
|
1583 | + Display :: return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL).'</a>'; |
|
1584 | 1584 | } elseif ($myrow['visibility'] == '0') { |
1585 | 1585 | $visibilityClass = 'invisible'; |
1586 | - $strVisibility = ' <a href="link.php?' . api_get_cidreq() . '&sec_token='.$token.'&action=visible&id=' . $myrow['id'] . '&scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Show') . '">' . |
|
1587 | - Display :: return_icon('invisible.png', get_lang('Show'), array (), ICON_SIZE_SMALL) . '</a>'; |
|
1586 | + $strVisibility = ' <a href="link.php?'.api_get_cidreq().'&sec_token='.$token.'&action=visible&id='.$myrow['id'].'&scope='.TOOL_LINK_CATEGORY.'" title="'.get_lang('Show').'">'. |
|
1587 | + Display :: return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL).'</a>'; |
|
1588 | 1588 | } |
1589 | 1589 | |
1590 | 1590 | $header = ''; |
@@ -477,6 +477,7 @@ discard block |
||
477 | 477 | * |
478 | 478 | * Get link info |
479 | 479 | * @param int link id |
480 | + * @param integer $id |
|
480 | 481 | * @return array link info |
481 | 482 | * |
482 | 483 | **/ |
@@ -1061,7 +1062,9 @@ discard block |
||
1061 | 1062 | /** |
1062 | 1063 | * Displays the edit, delete and move icons |
1063 | 1064 | * @param int Category ID |
1064 | - * @return void |
|
1065 | + * @param integer $currentCategory |
|
1066 | + * @param integer $countCategories |
|
1067 | + * @return string |
|
1065 | 1068 | * @author Patrick Cool <[email protected]>, Ghent University |
1066 | 1069 | */ |
1067 | 1070 | public static function showCategoryAdminTools($category, $currentCategory, $countCategories) |
@@ -1225,6 +1228,7 @@ discard block |
||
1225 | 1228 | /** |
1226 | 1229 | * CSV file import functions |
1227 | 1230 | * @author René Haentjens , Ghent University |
1231 | + * @param string $catname |
|
1228 | 1232 | */ |
1229 | 1233 | public static function get_cat($catname) |
1230 | 1234 | { |
@@ -1264,6 +1268,11 @@ discard block |
||
1264 | 1268 | /** |
1265 | 1269 | * CSV file import functions |
1266 | 1270 | * @author René Haentjens , Ghent University |
1271 | + * @param string $url |
|
1272 | + * @param string $title |
|
1273 | + * @param string $description |
|
1274 | + * @param string $on_homepage |
|
1275 | + * @param string $hidden |
|
1267 | 1276 | */ |
1268 | 1277 | public static function put_link($url, $cat, $title, $description, $on_homepage, $hidden) |
1269 | 1278 | { |
@@ -1622,7 +1631,6 @@ discard block |
||
1622 | 1631 | /** |
1623 | 1632 | * @param int $linkId |
1624 | 1633 | * @param $action |
1625 | - * @param null $urlview |
|
1626 | 1634 | * @param null $token |
1627 | 1635 | * @return FormValidator |
1628 | 1636 | */ |
@@ -21,12 +21,12 @@ discard block |
||
21 | 21 | * @assert () !== '' |
22 | 22 | * @assert ('abc','single') !== '' |
23 | 23 | */ |
24 | - function search_courses($needle,$type) |
|
24 | + function search_courses($needle, $type) |
|
25 | 25 | { |
26 | 26 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
27 | 27 | $xajax_response = new xajaxResponse(); |
28 | 28 | $return = ''; |
29 | - if(!empty($needle) && !empty($type)) { |
|
29 | + if (!empty($needle) && !empty($type)) { |
|
30 | 30 | // xajax send utf8 datas... datas in db can be non-utf8 datas |
31 | 31 | $charset = api_get_system_encoding(); |
32 | 32 | $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | $course_list = array(); |
39 | 39 | |
40 | 40 | $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
41 | - while($course = Database :: fetch_array($rs)) { |
|
41 | + while ($course = Database :: fetch_array($rs)) { |
|
42 | 42 | $course_list[] = $course['id']; |
43 | - $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
43 | + $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'], ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
44 | 44 | } |
45 | 45 | $return .= '</select>'; |
46 | - $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
46 | + $xajax_response -> addAssign('ajax_list_courses_multiple', 'innerHTML', api_utf8_encode($return)); |
|
47 | 47 | } |
48 | 48 | $_SESSION['course_list'] = $course_list; |
49 | 49 | return $xajax_response; |
@@ -25,29 +25,29 @@ |
||
25 | 25 | function search_courses($needle,$type) |
26 | 26 | { |
27 | 27 | $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); |
28 | - $xajax_response = new xajaxResponse(); |
|
29 | - $return = ''; |
|
30 | - if(!empty($needle) && !empty($type)) { |
|
31 | - // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
32 | - $charset = api_get_system_encoding(); |
|
33 | - $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
34 | - $needle = Database::escape_string($needle); |
|
28 | + $xajax_response = new xajaxResponse(); |
|
29 | + $return = ''; |
|
30 | + if(!empty($needle) && !empty($type)) { |
|
31 | + // xajax send utf8 datas... datas in db can be non-utf8 datas |
|
32 | + $charset = api_get_system_encoding(); |
|
33 | + $needle = api_convert_encoding($needle, $charset, 'utf-8'); |
|
34 | + $needle = Database::escape_string($needle); |
|
35 | 35 | |
36 | - $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id'; |
|
36 | + $sql = 'SELECT * FROM '.$tbl_session.' WHERE name LIKE "'.$needle.'%" ORDER BY id'; |
|
37 | 37 | |
38 | - $rs = Database::query($sql); |
|
39 | - $course_list = array(); |
|
38 | + $rs = Database::query($sql); |
|
39 | + $course_list = array(); |
|
40 | 40 | |
41 | - $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
42 | - while($course = Database :: fetch_array($rs)) { |
|
43 | - $course_list[] = $course['id']; |
|
44 | - $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
45 | - } |
|
46 | - $return .= '</select>'; |
|
47 | - $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
48 | - } |
|
49 | - $_SESSION['course_list'] = $course_list; |
|
41 | + $return .= '<select id="origin" name="NoSessionCategoryList[]" multiple="multiple" size="20" style="width:340px;">'; |
|
42 | + while($course = Database :: fetch_array($rs)) { |
|
43 | + $course_list[] = $course['id']; |
|
44 | + $return .= '<option value="'.$course['id'].'" title="'.htmlspecialchars($course['name'],ENT_QUOTES).'">'.$course['name'].'</option>'; |
|
45 | + } |
|
46 | + $return .= '</select>'; |
|
47 | + $xajax_response -> addAssign('ajax_list_courses_multiple','innerHTML',api_utf8_encode($return)); |
|
48 | + } |
|
49 | + $_SESSION['course_list'] = $course_list; |
|
50 | 50 | |
51 | - return $xajax_response; |
|
52 | - } |
|
51 | + return $xajax_response; |
|
52 | + } |
|
53 | 53 | } |
@@ -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 |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | $course_user_table = Database:: get_main_table(TABLE_MAIN_COURSE_USER); |
105 | 105 | $course_table = Database:: get_main_table(TABLE_MAIN_COURSE); |
106 | 106 | $user_table = Database:: get_main_table(TABLE_MAIN_USER); |
107 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
107 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
108 | 108 | $current_url_id = api_get_current_access_url_id(); |
109 | - $active_filter = $onlyActive?' AND active=1':''; |
|
110 | - $status_filter = isset($status)?' AND status = '.intval($status):''; |
|
109 | + $active_filter = $onlyActive ? ' AND active=1' : ''; |
|
110 | + $status_filter = isset($status) ? ' AND status = '.intval($status) : ''; |
|
111 | 111 | |
112 | 112 | if (api_is_multiple_url_enabled()) { |
113 | 113 | $sql = "SELECT COUNT(DISTINCT(u.user_id)) AS number |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | FROM $user_table |
132 | 132 | WHERE 1=1 $status_filter $active_filter"; |
133 | 133 | if (isset ($categoryCode)) { |
134 | - $status_filter = isset($status)?' AND status = '.intval($status):''; |
|
134 | + $status_filter = isset($status) ? ' AND status = '.intval($status) : ''; |
|
135 | 135 | $sql = "SELECT COUNT(DISTINCT(cu.user_id)) AS number |
136 | 136 | FROM $course_user_table cu, $course_table c |
137 | 137 | WHERE |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | public static function countSessions() |
157 | 157 | { |
158 | 158 | $session_table = Database :: get_main_table(TABLE_MAIN_SESSION); |
159 | - $access_url_rel_session_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
159 | + $access_url_rel_session_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION); |
|
160 | 160 | if (api_is_multiple_url_enabled()) { |
161 | 161 | $current_url_id = api_get_current_access_url_id(); |
162 | 162 | $sql = "SELECT COUNT(id) AS number |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | public static function getNumberOfActivities() |
180 | 180 | { |
181 | 181 | // Database table definitions |
182 | - $track_e_default = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT); |
|
182 | + $track_e_default = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT); |
|
183 | 183 | $table_user = Database::get_main_table(TABLE_MAIN_USER); |
184 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
184 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
185 | 185 | $current_url_id = api_get_current_access_url_id(); |
186 | 186 | if (api_is_multiple_url_enabled()) { |
187 | 187 | $sql = "SELECT count(default_id) AS total_number_of_items |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $from = intval($from); |
226 | 226 | $numberOfItems = intval($numberOfItems); |
227 | 227 | |
228 | - if (!in_array($direction, array('ASC','DESC'))) { |
|
228 | + if (!in_array($direction, array('ASC', 'DESC'))) { |
|
229 | 229 | $direction = 'DESC'; |
230 | 230 | } |
231 | 231 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $sql .= " LIMIT $from,$numberOfItems "; |
277 | 277 | |
278 | 278 | $res = Database::query($sql); |
279 | - $activities = array (); |
|
279 | + $activities = array(); |
|
280 | 280 | while ($row = Database::fetch_row($res)) { |
281 | 281 | |
282 | 282 | if (strpos($row[1], '_object') === false && strpos($row[1], '_array') === false) { |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $sql = "SELECT code, name FROM $categoryTable |
344 | 344 | ORDER BY tree_pos"; |
345 | 345 | $res = Database::query($sql); |
346 | - $categories = array (); |
|
346 | + $categories = array(); |
|
347 | 347 | while ($category = Database::fetch_object($res)) { |
348 | 348 | $categories[$category->code] = $category->name; |
349 | 349 | } |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $data_max = ($data_max < $value ? $value : $data_max); |
365 | 365 | } |
366 | 366 | reset($data); |
367 | - $result = array (); |
|
367 | + $result = array(); |
|
368 | 368 | $delta = $max / $data_max; |
369 | 369 | foreach ($data as $index => $value) { |
370 | 370 | $result[$index] = (int) round($value * $delta); |
@@ -398,9 +398,9 @@ discard block |
||
398 | 398 | } else { |
399 | 399 | $number_label = Statistics::makeSizeString($number); |
400 | 400 | } |
401 | - $percentage = ($total>0?number_format(100*$number/$total, 1, ',', '.'):'0'); |
|
401 | + $percentage = ($total > 0 ? number_format(100 * $number / $total, 1, ',', '.') : '0'); |
|
402 | 402 | |
403 | - echo '<tr class="row_'.($i%2 == 0 ? 'odd' : 'even').'"> |
|
403 | + echo '<tr class="row_'.($i % 2 == 0 ? 'odd' : 'even').'"> |
|
404 | 404 | <td width="150">'.$subtitle.'</td> |
405 | 405 | <td width="550">'.Display::bar_progress($percentage, false).'</td> |
406 | 406 | <td align="right">'.$number_label.'</td>'; |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | echo '<td align="right"> '.$percentage.'%</td>'; |
409 | 409 | } |
410 | 410 | echo '</tr>'; |
411 | - $i ++; |
|
411 | + $i++; |
|
412 | 412 | } |
413 | 413 | if ($showTotal) { |
414 | 414 | if (!$isFileSize) { |
@@ -428,17 +428,17 @@ discard block |
||
428 | 428 | public static function printLoginStats($type) |
429 | 429 | { |
430 | 430 | $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
431 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
431 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
432 | 432 | $current_url_id = api_get_current_access_url_id(); |
433 | 433 | |
434 | 434 | $table_url = null; |
435 | 435 | $where_url = null; |
436 | 436 | $now = api_get_utc_datetime(); |
437 | - $where_url_last = ' WHERE login_date > DATE_SUB("' . $now . '",INTERVAL 1 %s)'; |
|
437 | + $where_url_last = ' WHERE login_date > DATE_SUB("'.$now.'",INTERVAL 1 %s)'; |
|
438 | 438 | if (api_is_multiple_url_enabled()) { |
439 | 439 | $table_url = ", $access_url_rel_user_table"; |
440 | 440 | $where_url = " WHERE login_user_id=user_id AND access_url_id='".$current_url_id."'"; |
441 | - $where_url_last = ' AND login_date > DATE_SUB("' . $now . '",INTERVAL 1 %s)'; |
|
441 | + $where_url_last = ' AND login_date > DATE_SUB("'.$now.'",INTERVAL 1 %s)'; |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | $period = get_lang('PeriodMonth'); |
@@ -453,13 +453,13 @@ discard block |
||
453 | 453 | case 'hour': |
454 | 454 | $period = get_lang('PeriodHour'); |
455 | 455 | $sql = "SELECT DATE_FORMAT( login_date, '%H' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table.$table_url.$where_url." GROUP BY stat_date ORDER BY stat_date "; |
456 | - $sql_last_x = "SELECT DATE_FORMAT( login_date, '%H' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table.$table_url.$where_url.sprintf($where_url_last,'DAY')." GROUP BY stat_date ORDER BY stat_date "; |
|
456 | + $sql_last_x = "SELECT DATE_FORMAT( login_date, '%H' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table.$table_url.$where_url.sprintf($where_url_last, 'DAY')." GROUP BY stat_date ORDER BY stat_date "; |
|
457 | 457 | break; |
458 | 458 | case 'day': |
459 | 459 | $periodCollection = api_get_week_days_long(); |
460 | 460 | $period = get_lang('PeriodDay'); |
461 | 461 | $sql = "SELECT DATE_FORMAT( login_date, '%w' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table.$table_url.$where_url." GROUP BY stat_date ORDER BY DATE_FORMAT( login_date, '%w' ) "; |
462 | - $sql_last_x = "SELECT DATE_FORMAT( login_date, '%w' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table.$table_url.$where_url.sprintf($where_url_last,'WEEK')." GROUP BY stat_date ORDER BY DATE_FORMAT( login_date, '%w' ) "; |
|
462 | + $sql_last_x = "SELECT DATE_FORMAT( login_date, '%w' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table.$table_url.$where_url.sprintf($where_url_last, 'WEEK')." GROUP BY stat_date ORDER BY DATE_FORMAT( login_date, '%w' ) "; |
|
463 | 463 | break; |
464 | 464 | } |
465 | 465 | if ($sql_last_x) { |
@@ -501,14 +501,14 @@ discard block |
||
501 | 501 | { |
502 | 502 | $totalLogin = array(); |
503 | 503 | $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
504 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
504 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
505 | 505 | $current_url_id = api_get_current_access_url_id(); |
506 | 506 | if (api_is_multiple_url_enabled()) { |
507 | 507 | $table_url = ", $access_url_rel_user_table"; |
508 | 508 | $where_url = " AND login_user_id=user_id AND access_url_id='".$current_url_id."'"; |
509 | 509 | } else { |
510 | 510 | $table_url = ''; |
511 | - $where_url=''; |
|
511 | + $where_url = ''; |
|
512 | 512 | } |
513 | 513 | $now = api_get_utc_datetime(); |
514 | 514 | $field = 'login_user_id'; |
@@ -540,14 +540,14 @@ discard block |
||
540 | 540 | { |
541 | 541 | $totalLogin = []; |
542 | 542 | $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
543 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
543 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
544 | 544 | $current_url_id = api_get_current_access_url_id(); |
545 | 545 | if (api_is_multiple_url_enabled()) { |
546 | 546 | $table_url = ", $access_url_rel_user_table"; |
547 | 547 | $where_url = " AND login_user_id=user_id AND access_url_id='".$current_url_id."'"; |
548 | 548 | } else { |
549 | 549 | $table_url = ''; |
550 | - $where_url=''; |
|
550 | + $where_url = ''; |
|
551 | 551 | } |
552 | 552 | $now = api_get_utc_datetime(); |
553 | 553 | $field = 'login_user_id'; |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | $sql = "SELECT count($field) AS number, date(login_date) as login_date FROM $table $table_url WHERE DATE_ADD(login_date, INTERVAL 15 DAY) >= '$now' $where_url GROUP BY date(login_date)"; |
558 | 558 | |
559 | 559 | $res = Database::query($sql); |
560 | - while($row = Database::fetch_array($res,'ASSOC')){ |
|
560 | + while ($row = Database::fetch_array($res, 'ASSOC')) { |
|
561 | 561 | $totalLogin[$row['login_date']] = $row['number']; |
562 | 562 | } |
563 | 563 | |
@@ -652,13 +652,13 @@ discard block |
||
652 | 652 | public static function printUserPicturesStats() |
653 | 653 | { |
654 | 654 | $user_table = Database :: get_main_table(TABLE_MAIN_USER); |
655 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
655 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
656 | 656 | $current_url_id = api_get_current_access_url_id(); |
657 | 657 | $url_condition = null; |
658 | 658 | $url_condition2 = null; |
659 | 659 | $table = null; |
660 | 660 | if (api_is_multiple_url_enabled()) { |
661 | - $url_condition = ", $access_url_rel_user_table as url WHERE url.user_id=u.user_id AND access_url_id='".$current_url_id."'"; |
|
661 | + $url_condition = ", $access_url_rel_user_table as url WHERE url.user_id=u.user_id AND access_url_id='".$current_url_id."'"; |
|
662 | 662 | $url_condition2 = " AND url.user_id=u.user_id AND access_url_id='".$current_url_id."'"; |
663 | 663 | $table = ", $access_url_rel_user_table as url "; |
664 | 664 | } |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | 'width=200px', |
691 | 691 | false |
692 | 692 | ); |
693 | - $renderer =& $form->defaultRenderer(); |
|
693 | + $renderer = & $form->defaultRenderer(); |
|
694 | 694 | $renderer->setCustomElementTemplate('<span>{element}</span> '); |
695 | 695 | $form->addElement('hidden', 'report', 'activities'); |
696 | 696 | $form->addElement('hidden', 'activities_direction', 'DESC'); |
@@ -740,10 +740,10 @@ discard block |
||
740 | 740 | $columns[1] = 'access_date'; |
741 | 741 | $sql_order[SORT_ASC] = 'ASC'; |
742 | 742 | $sql_order[SORT_DESC] = 'DESC'; |
743 | - $per_page = isset($_GET['per_page'])?intval($_GET['per_page']) : 10; |
|
744 | - $page_nr = isset($_GET['page_nr'])?intval($_GET['page_nr']) : 1; |
|
745 | - $column = isset($_GET['column'])?intval($_GET['column']) : 0; |
|
746 | - $date_diff = isset($_GET['date_diff'])?intval($_GET['date_diff']) : 60; |
|
743 | + $per_page = isset($_GET['per_page']) ? intval($_GET['per_page']) : 10; |
|
744 | + $page_nr = isset($_GET['page_nr']) ? intval($_GET['page_nr']) : 1; |
|
745 | + $column = isset($_GET['column']) ? intval($_GET['column']) : 0; |
|
746 | + $date_diff = isset($_GET['date_diff']) ? intval($_GET['date_diff']) : 60; |
|
747 | 747 | |
748 | 748 | $direction = isset($_GET['direction']) ? $_GET['direction'] : SORT_ASC; |
749 | 749 | |
@@ -772,25 +772,25 @@ discard block |
||
772 | 772 | access_url_id='".$current_url_id."' |
773 | 773 | GROUP BY c_id |
774 | 774 | HAVING c_id <> '' |
775 | - AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ". $date_diff; |
|
775 | + AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ".$date_diff; |
|
776 | 776 | } else { |
777 | 777 | $sql = "SELECT * FROM $table |
778 | 778 | GROUP BY c_id |
779 | 779 | HAVING c_id <> '' |
780 | - AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ". $date_diff; |
|
780 | + AND DATEDIFF( '".date('Y-m-d h:i:s')."' , access_date ) <= ".$date_diff; |
|
781 | 781 | } |
782 | 782 | $sql .= ' ORDER BY '.$columns[$column].' '.$sql_order[$direction]; |
783 | - $from = ($page_nr -1) * $per_page; |
|
783 | + $from = ($page_nr - 1) * $per_page; |
|
784 | 784 | $sql .= ' LIMIT '.$from.','.$per_page; |
785 | 785 | |
786 | 786 | echo '<p>'.get_lang('LastAccess').' >= '.$date_diff.' '.get_lang('Days').'</p>'; |
787 | 787 | $res = Database::query($sql); |
788 | 788 | if (Database::num_rows($res) > 0) { |
789 | - $courses = array (); |
|
789 | + $courses = array(); |
|
790 | 790 | while ($obj = Database::fetch_object($res)) { |
791 | 791 | $courseInfo = api_get_course_info_by_id($obj->c_id); |
792 | - $course = array (); |
|
793 | - $course[]= '<a href="'.api_get_path(WEB_COURSE_PATH).$courseInfo['code'].'">'.$courseInfo['code'].' <a>'; |
|
792 | + $course = array(); |
|
793 | + $course[] = '<a href="'.api_get_path(WEB_COURSE_PATH).$courseInfo['code'].'">'.$courseInfo['code'].' <a>'; |
|
794 | 794 | // Allow sort by date hiding the numerical date |
795 | 795 | $course[] = '<span style="display:none;">'.$obj->access_date.'</span>'.api_convert_and_format_date($obj->access_date); |
796 | 796 | $courses[] = $course; |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | { |
864 | 864 | $user_friend_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
865 | 865 | $user_table = Database::get_main_table(TABLE_MAIN_USER); |
866 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
866 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
867 | 867 | $current_url_id = api_get_current_access_url_id(); |
868 | 868 | |
869 | 869 | if (api_is_multiple_url_enabled()) { |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | { |
896 | 896 | $totalLogin = array(); |
897 | 897 | $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); |
898 | - $access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
898 | + $access_url_rel_user_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); |
|
899 | 899 | $current_url_id = api_get_current_access_url_id(); |
900 | 900 | $total = self::countUsers(); |
901 | 901 | if (api_is_multiple_url_enabled()) { |
@@ -903,14 +903,14 @@ discard block |
||
903 | 903 | $where_url = " AND login_user_id=user_id AND access_url_id='".$current_url_id."'"; |
904 | 904 | } else { |
905 | 905 | $table_url = ''; |
906 | - $where_url=''; |
|
906 | + $where_url = ''; |
|
907 | 907 | } |
908 | 908 | $now = api_get_utc_datetime(); |
909 | - $sql[get_lang('ThisDay')] = |
|
909 | + $sql[get_lang('ThisDay')] = |
|
910 | 910 | "SELECT count(distinct(login_user_id)) AS number ". |
911 | 911 | " FROM $table $table_url ". |
912 | 912 | " WHERE DATE_ADD(login_date, INTERVAL 1 DAY) >= '$now' $where_url"; |
913 | - $sql[get_lang('Last7days')] = |
|
913 | + $sql[get_lang('Last7days')] = |
|
914 | 914 | "SELECT count(distinct(login_user_id)) AS number ". |
915 | 915 | " FROM $table $table_url ". |
916 | 916 | " WHERE DATE_ADD(login_date, INTERVAL 7 DAY) >= '$now' $where_url"; |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | "SELECT count(distinct(login_user_id)) AS number ". |
923 | 923 | " FROM $table $table_url ". |
924 | 924 | " WHERE DATE_ADD(login_date, INTERVAL 6 MONTH) >= '$now' $where_url"; |
925 | - $sql[get_lang('NeverConnected')] = |
|
925 | + $sql[get_lang('NeverConnected')] = |
|
926 | 926 | "SELECT count(distinct(login_user_id)) AS number ". |
927 | 927 | " FROM $table $table_url WHERE 1=1 $where_url"; |
928 | 928 | foreach ($sql as $index => $query) { |
@@ -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); } |
@@ -18,9 +18,11 @@ |
||
18 | 18 | |
19 | 19 | foreach ($event_config[$event_name]["actions"] as $func) { |
20 | 20 | $execute = true; |
21 | - if (!function_exists($func)) // if the function doesn't exist, we log |
|
21 | + if (!function_exists($func)) { |
|
22 | + // if the function doesn't exist, we log |
|
22 | 23 | { |
23 | 24 | error_log("EventsDispatcher warning : ".$func." does not exist."); |
25 | + } |
|
24 | 26 | $execute = false; |
25 | 27 | } |
26 | 28 |
@@ -38,7 +38,7 @@ |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | - * @return bool |
|
41 | + * @return false|null |
|
42 | 42 | */ |
43 | 43 | public function create_user_folder() |
44 | 44 | { |
@@ -34,8 +34,8 @@ |
||
34 | 34 | $idUserLocal = api_get_user_id(); |
35 | 35 | $userLocal = api_get_user_info($idUserLocal, true); |
36 | 36 | $htmlHeadXtra[] = '<script type="text/javascript" src="' |
37 | - . api_get_path(WEB_PATH) . 'web/assets/SimpleWebRTC/latest.js' |
|
38 | - . '"></script>' . "\n"; |
|
37 | + . api_get_path(WEB_PATH).'web/assets/SimpleWebRTC/latest.js' |
|
38 | + . '"></script>'."\n"; |
|
39 | 39 | |
40 | 40 | $template = new Template(); |
41 | 41 | $template->assign('room_name', $chatVideo->getRoomName()); |